opencode-herdr-orchestration 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,43 @@ This package registers the agents, provides complete structured worker-response
6
6
 
7
7
  Requires Node.js 22.22.2 or newer when running the package CLI or tests.
8
8
 
9
+ ## Installation
10
+
11
+ Add the published package to the global OpenCode configuration at `~/.config/opencode/opencode.json` or `~/.config/opencode/opencode.jsonc`:
12
+
13
+ ```jsonc
14
+ {
15
+ "$schema": "https://opencode.ai/config.json",
16
+ "plugin": ["opencode-herdr-orchestration"]
17
+ }
18
+ ```
19
+
20
+ If `plugin` already contains entries, append `"opencode-herdr-orchestration"` instead of replacing them. OpenCode installs npm plugins automatically when it starts.
21
+
22
+ Optionally install the shared Git push policy for all current and future repositories:
23
+
24
+ ```bash
25
+ npx opencode-herdr-orchestration install-hooks
26
+ ```
27
+
28
+ Then quit and restart OpenCode intentionally. Agent and plugin configuration is loaded only at process startup; installing the package does not restart or modify running OpenCode sessions.
29
+
30
+ Confirm the installed agents:
31
+
32
+ ```bash
33
+ opencode agent list
34
+ ```
35
+
36
+ The expected package agents are `shepherd-plan`, `shepherd-build`, `sheep-plan`, `sheep-build`, `shearer-review-low`, and `shearer-review-medium`.
37
+
38
+ ### Migrating from standalone agent files
39
+
40
+ Agent definitions are merged by agent name. A local file with the same name as a package agent overrides the corresponding package fields, including its prompt and permissions.
41
+
42
+ Before switching completely, archive or remove standalone files named `sheep-plan.md`, `sheep-build.md`, `shepherd-plan.md`, or `shepherd-build.md` after any existing OpenCode processes that depend on them have ended. Older misspelled files such as `sheperd-plan.md` and `sheperd-build.md` do not override the correctly named package agents; they load as additional legacy agents until removed.
43
+
44
+ Do not remove agent files merely to affect an already-running process. Complete or stop that process first, update the files, then start a new OpenCode process and verify the effective agent list.
45
+
9
46
  ## Architecture
10
47
 
11
48
  ```text
@@ -30,7 +67,7 @@ shepherd-build
30
67
 
31
68
  The build shepherd chooses low review for localized mechanical changes with strong deterministic coverage. It chooses medium review for security, architecture, migrations, public APIs, deployment, concurrency, cross-component work, weak coverage, or material uncertainty.
32
69
 
33
- ## Install the plugin
70
+ ## Plugin configuration
34
71
 
35
72
  During local development, reference the source directly in the global OpenCode configuration:
36
73
 
@@ -43,7 +80,7 @@ During local development, reference the source directly in the global OpenCode c
43
80
  }
44
81
  ```
45
82
 
46
- After publishing, use the package name instead:
83
+ For the published package, use:
47
84
 
48
85
  ```jsonc
49
86
  {
@@ -67,9 +104,29 @@ Plugin tuple options can override model defaults:
67
104
  }
68
105
  ```
69
106
 
107
+ Machine-specific `shepherd-build` permissions and instructions can also be added declaratively without a local JavaScript wrapper:
108
+
109
+ ```jsonc
110
+ {
111
+ "plugin": [
112
+ [
113
+ "opencode-herdr-orchestration",
114
+ {
115
+ "shepherdBuildPermissions": {
116
+ "private_deployment_status": "allow"
117
+ },
118
+ "shepherdBuildPromptAppend": "Use private deployment tools according to local policy."
119
+ }
120
+ ]
121
+ ]
122
+ }
123
+ ```
124
+
125
+ `shepherdBuildPermissions` is merged over the package's `shepherd-build` permissions. `shepherdBuildPromptAppend` is appended as a separate final paragraph. Keep secrets out of plugin options because configuration may be displayed by diagnostics.
126
+
70
127
  Local agent definitions with the same names are merged over plugin defaults. This permits deliberate user customization without losing unspecified plugin permissions or prompts.
71
128
 
72
- During migration, existing files such as `~/.config/opencode/agents/shepherd-build.md` continue to override the plugin prompt. Keep them while existing sessions depend on them. After those sessions end and the plugin has been validated, archive or remove the duplicate standalone definitions so the package becomes the single source of truth. Do not remove files merely to activate the plugin in already-running OpenCode processes; configuration is loaded at process startup.
129
+ Machine- or organization-specific MCP tools, deployment rules, and private service instructions should stay in a local `shepherd-build` override rather than this public package. Add only the private permissions and prompt additions required by your environment; unspecified package defaults remain intact through deep merging.
73
130
 
74
131
  OpenCode loads plugins and agent definitions at startup. Restart OpenCode when intentionally enabling or updating the plugin. The installer never stops or restarts an OpenCode process.
75
132
 
File without changes
package/package.json CHANGED
@@ -1,46 +1,49 @@
1
- {
2
- "name": "opencode-herdr-orchestration",
3
- "version": "0.1.0",
4
- "description": "Capability-separated Herdr orchestration agents for OpenCode",
5
- "author": "CodingJinxx",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/CodingJinxx/opencode-herdr-orchestration.git"
9
- },
10
- "homepage": "https://github.com/CodingJinxx/opencode-herdr-orchestration#readme",
11
- "bugs": {
12
- "url": "https://github.com/CodingJinxx/opencode-herdr-orchestration/issues"
13
- },
14
- "type": "module",
15
- "exports": "./src/index.js",
16
- "bin": {
17
- "opencode-herdr-orchestration": "bin/orchestration.js"
18
- },
19
- "files": [
20
- "bin",
21
- "hooks",
22
- "src",
23
- "README.md",
24
- "LICENSE"
25
- ],
26
- "scripts": {
27
- "test": "node --test",
28
- "check": "node --check src/index.js && node --check src/agents.js && node --check src/prompts.js && node --check src/response.js && node --check bin/orchestration.js"
29
- },
30
- "engines": {
31
- "node": ">=22.22.2"
32
- },
33
- "peerDependencies": {
34
- "@opencode-ai/plugin": ">=1.3.0 <2"
35
- },
36
- "devDependencies": {
37
- "@opencode-ai/plugin": "1.3.14"
38
- },
39
- "keywords": [
40
- "opencode",
41
- "herdr",
42
- "orchestration",
43
- "agents"
44
- ],
45
- "license": "MIT"
46
- }
1
+ {
2
+ "name": "opencode-herdr-orchestration",
3
+ "version": "0.1.1",
4
+ "description": "Capability-separated Herdr orchestration agents for OpenCode",
5
+ "author": "CodingJinxx",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/CodingJinxx/opencode-herdr-orchestration.git"
9
+ },
10
+ "homepage": "https://github.com/CodingJinxx/opencode-herdr-orchestration#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/CodingJinxx/opencode-herdr-orchestration/issues"
13
+ },
14
+ "type": "module",
15
+ "exports": {
16
+ ".": "./src/plugin.js",
17
+ "./core": "./src/index.js"
18
+ },
19
+ "bin": {
20
+ "opencode-herdr-orchestration": "bin/orchestration.js"
21
+ },
22
+ "files": [
23
+ "bin",
24
+ "hooks",
25
+ "src",
26
+ "README.md",
27
+ "LICENSE"
28
+ ],
29
+ "scripts": {
30
+ "test": "node --test",
31
+ "check": "node --check src/plugin.js && node --check src/index.js && node --check src/agents.js && node --check src/prompts.js && node --check src/response.js && node --check bin/orchestration.js"
32
+ },
33
+ "engines": {
34
+ "node": ">=22.22.2"
35
+ },
36
+ "peerDependencies": {
37
+ "@opencode-ai/plugin": ">=1.3.0 <2"
38
+ },
39
+ "devDependencies": {
40
+ "@opencode-ai/plugin": "1.3.14"
41
+ },
42
+ "keywords": [
43
+ "opencode",
44
+ "herdr",
45
+ "orchestration",
46
+ "agents"
47
+ ],
48
+ "license": "MIT"
49
+ }
package/src/agents.js CHANGED
@@ -77,6 +77,8 @@ export function mergeAgent(defaults, override) {
77
77
  export function createAgents(options = {}) {
78
78
  const workerModel = options.workerModel ?? "litellm/glm-5.3-flash";
79
79
  const reviewerModel = options.reviewerModel ?? "litellm-responses/gpt-5.6-terra";
80
+ const shepherdBuildPermissions = options.shepherdBuildPermissions ?? {};
81
+ const shepherdBuildPrompt = appendPrompt(SHEPHERD_BUILD_PROMPT, options.shepherdBuildPromptAppend);
80
82
 
81
83
  return {
82
84
  "shepherd-plan": {
@@ -128,17 +130,12 @@ export function createAgents(options = {}) {
128
130
  "shepherd-build": {
129
131
  mode: "primary",
130
132
  description: "Executes approved plans through planning, implementation, and independent review workers.",
131
- prompt: SHEPHERD_BUILD_PROMPT,
133
+ prompt: shepherdBuildPrompt,
132
134
  permission: {
133
135
  grep: "allow",
134
136
  edit: markdownOnly,
135
137
  apply_patch: markdownOnly,
136
138
  herdr_agent_response: "allow",
137
- "ia-forge_deployment_status": "allow",
138
- "ia-forge_file_logs": "allow",
139
- "ia-forge_run_preset": "allow",
140
- "ia-forge_service_control": "allow",
141
- "ia-forge_service_logs": "allow",
142
139
  bash: {
143
140
  "*": "deny",
144
141
  ...herdrInspection,
@@ -178,6 +175,7 @@ export function createAgents(options = {}) {
178
175
  ...separatorDenials,
179
176
  },
180
177
  task: "deny",
178
+ ...shepherdBuildPermissions,
181
179
  },
182
180
  },
183
181
 
@@ -235,6 +233,14 @@ export function createAgents(options = {}) {
235
233
  };
236
234
  }
237
235
 
236
+ function appendPrompt(prompt, addition) {
237
+ if (addition === undefined || addition === "") return prompt;
238
+ if (typeof addition !== "string") {
239
+ throw new TypeError("shepherdBuildPromptAppend must be a string.");
240
+ }
241
+ return `${prompt.trimEnd()}\n\n${addition.trim()}`;
242
+ }
243
+
238
244
  function reviewerAgent(model, variant) {
239
245
  return {
240
246
  mode: "primary",
package/src/plugin.js ADDED
@@ -0,0 +1 @@
1
+ export { HerdrOrchestrationPlugin as server } from "./index.js";
package/src/prompts.js CHANGED
@@ -1,7 +1,7 @@
1
1
  export const SHEPHERD_PLAN_PROMPT = String.raw`
2
2
  You are shepherd-plan, a planning orchestrator. Research the user's goal through repository evidence and sheep-plan workers, then present an implementation-ready plan. Planning may mutate planning infrastructure and Markdown planning artifacts, but never product implementation.
3
3
 
4
- Before using Herdr, verify HERDR_ENV=1. If absent, explain that orchestration requires a Herdr-managed pane and stop. Inspect repository instructions, status, branches, worktrees, HEAD, and relevant history. Preserve unrelated changes. Use todos for substantial planning.
4
+ Before using Herdr, verify HERDR_ENV=1. If absent, explain that orchestration requires a Herdr-managed pane and stop. Learn the installed command syntax with herdr --help and herdr agent; the installed CLI is authoritative. Inspect repository instructions, status, branches, worktrees, HEAD, and relevant history. Preserve unrelated changes. Use todos for substantial planning.
5
5
 
6
6
  You may write only Markdown plans, research notes, task briefs, and handoffs. You may commit intended Markdown artifacts and push only the current attached non-protected branch using an approved HEAD push command. Immediately before pushing, inspect the current branch and stop on main, master, detached HEAD, or any repository-defined protected branch. Never merge, deploy, implement, or spawn an implementation-capable agent.
7
7
 
@@ -11,9 +11,13 @@ herdr agent start <name> --kind opencode --pane <pane-id> -- --agent sheep-plan
11
11
 
12
12
  Never pass another agent, model, --auto, or extra OpenCode argument. Use send-keys only to interrupt a genuinely stuck worker with Ctrl+C after inspection. Never type commands, answer arbitrary prompts, or use a worker terminal as a capability bypass.
13
13
 
14
+ Worker names must be unique and satisfy Herdr's naming rules. Assign bounded work with herdr agent prompt <name> "..." --wait --timeout <milliseconds>. If additional research is needed, prompt the same worker again or create another non-overlapping sheep-plan assignment.
15
+
14
16
  After a worker settles, use herdr_agent_response as the authoritative result channel. Call it first with the worker name, then call it with each returned cursor until complete is true. Do not summarize, decide, or act on the worker result until every page has been read in order. Use herdr agent read only for live status, blocked dialogs, and stuck-worker diagnosis; terminal snapshots are never the completed worker response. If retrieval says the worker is not settled, wait and retry. If an interrupted worker has no completed response, inspect its actual partial state and redesign the task.
15
17
 
16
- Assume workers may fail on very large one-shot writes. Identify large-file work and plan generators or coherent bounded stages with valid checkpoints. If a worker later fails on a large write, the shepherd owns recovery: inspect partial state, preserve valid work, and redesign the task rather than repeating the same oversized prompt.
18
+ If a worker is blocked, inspect it with herdr agent get and herdr agent read; do not answer approvals or questions without applying the user's safety constraints. Treat unknown as inconclusive, not complete. Synthesize worker findings instead of forwarding raw reports. Resolve contradictions when repository evidence permits and surface unresolved product choices to the user.
19
+
20
+ Assume workers may fail on very large one-shot writes. Identify large-file work and plan generators or coherent bounded stages with valid checkpoints. If a worker later fails on a large write, the shepherd owns recovery: inspect partial state, preserve valid work, and redesign the task rather than repeating the same oversized prompt. Before committing a plan, inspect the staged diff and confirm it contains only intended Markdown planning artifacts.
17
21
 
18
22
  Every final plan must begin with:
19
23
 
@@ -27,7 +31,7 @@ Include scope, ordered tasks, likely files and symbols, dependencies, delegation
27
31
  export const SHEPHERD_BUILD_PROMPT = String.raw`
28
32
  You are shepherd-build, a delivery orchestrator. Selecting this agent after shepherd-plan approves the latest presented plan. You coordinate; every non-Markdown implementation change must come from a sheep-build commit. You may directly write only Markdown task briefs, handoffs, and review notes.
29
33
 
30
- Before using Herdr, verify HERDR_ENV=1. Inspect repository instructions, status, branches, worktrees, current HEAD, and history. Preserve unrelated changes and never force-push, bypass hooks, or rewrite history.
34
+ Before using Herdr, verify HERDR_ENV=1. If absent, explain that orchestration requires a Herdr-managed pane and stop. Learn the installed command syntax with herdr --help and herdr agent; the installed CLI is authoritative. Inspect repository instructions, status, branches, worktrees, current HEAD, and history. Preserve unrelated changes and never force-push, bypass hooks, or rewrite history.
31
35
 
32
36
  At startup identify and report:
33
37
 
@@ -39,6 +43,8 @@ Inspect divergence from the approved base. Continue through mechanical drift, re
39
43
 
40
44
  Delegate using structured contracts containing, where relevant: task_id, plan_id, base_commit, objective, owned_paths, forbidden_paths, dependencies, acceptance_criteria, verification, escalate_if, and deliver. Resolve global ambiguity before delegating. Workers must escalate rather than guess when evidence contradicts the task, scope expands, public APIs or migrations change unexpectedly, a product or architecture decision is required, permissions block work, or repeated attempts fail.
41
45
 
46
+ Parallelize only tasks that will not conflict. When implementation tasks can run concurrently, give each sheep-build a dedicated branch and worktree with non-overlapping ownership and explicit integration order.
47
+
42
48
  Spawn only these configured workers with no extra OpenCode arguments:
43
49
 
44
50
  herdr agent start <name> --kind opencode --pane <pane-id> -- --agent sheep-plan
@@ -48,19 +54,22 @@ herdr agent start <name> --kind opencode --pane <pane-id> -- --agent shearer-rev
48
54
 
49
55
  Use sheep-plan for research and sheep-build for implementation. Choose Terra low review for localized, mechanical changes with strong deterministic coverage. Choose Terra medium for security, architecture, migrations, public APIs, deployment, concurrency, cross-component work, weak coverage, or material uncertainty.
50
56
 
57
+ Worker names must be unique and satisfy Herdr's naming rules. Assign work with herdr agent prompt <name> "..." --wait --timeout <milliseconds>.
58
+
51
59
  Use send-keys only to interrupt a genuinely stuck worker with Ctrl+C after inspection. Never type implementation commands, answer arbitrary prompts, or use a worker terminal as a capability bypass. After interruption, inspect any completed response and actual diff, preserve valid partial work, and issue a bounded recovery task.
52
60
 
53
61
  After any worker or shearer settles, use herdr_agent_response as the authoritative result channel. Call it first with the agent name, then call it with each returned cursor until complete is true. Do not summarize, review, integrate, or act on the result until every page has been read in order. Use herdr agent read only for live status, blocked dialogs, and stuck-worker diagnosis; terminal snapshots are never a completed response. If retrieval says the agent is not settled, wait and retry. If an interrupted worker has no completed response, inspect its actual partial state and redesign the task.
54
62
 
63
+ If an agent is blocked, inspect it with herdr agent get and herdr agent read; do not answer approvals or questions without applying the user's safety constraints. Treat unknown as inconclusive, not complete.
64
+
55
65
  Assume workers may fail on very large one-shot writes. Prefer repository-native generators or coherent bounded stages with valid checkpoints. If a write fails, inspect partial state and redesign the prompt; never discard correct work, reduce required functionality, or repeat the same oversized prompt blindly.
56
66
 
57
67
  Require sheep-build to return a local commit, files changed, checks and results, assumptions, risks, and blockers. Sheep never pushes, merges, opens PRs, or delivers. Run or delegate deterministic repository-native checks before semantic review. Give the shearer fresh bounded context: user goal, approved plan, task contract, base and implementation commits, diff, and verification results, not the worker conversation.
58
68
 
59
69
  Review verdicts are PASS, REWORK, or ESCALATE. PASS permits integration after your own checks. REWORK returns concrete findings to the responsible sheep-build and requires review of the correction. ESCALATE returns to you for research, re-planning, or user judgment. After two failed semantic review cycles for the same task, escalate rather than loop indefinitely.
60
70
 
61
- Integrate only reviewed committed work. Perform repository-level verification after integration. Own push, PR, merge, and deployment according to repository instructions and user scope. Use gh only for GitHub repositories and only when PR delivery is requested. Finish with plan ID, assignments, commits, checks, review verdicts, integration and delivery result, deviations, and unresolved risks.
71
+ Integrate only reviewed committed work. Inspect every worker commit for scope and unintended changes before integration, and return defects to the responsible sheep-build rather than editing implementation yourself. Prefer fast-forward or ordinary non-interactive merges. Delegate non-Markdown conflict resolution to sheep-build. Perform repository-level verification after integration. Do not merge or push while tests fail, unintended changes remain, or a deployment gate is failing. Before pushing, confirm the current branch and remote target. Merge into a protected branch only when requested or authorized by the user's end-to-end delivery scope and all acceptance criteria and repository gates pass. Own push, PR, merge, and deployment according to repository instructions and user scope. Use gh only for GitHub repositories and only when PR delivery is requested. Finish with plan ID, assignments, commits, checks, review verdicts, integration and delivery result, deviations, and unresolved risks.
62
72
 
63
- When ia-forge tools are available, use them as the source of truth for managed deployments and services. After pushing an infrastructure change, poll deployment status until the attempt finishes; success requires a successful attempt at the pushed commit. On failure inspect deployment service logs, delegate the correction to sheep-build, and repeat verification and review before another delivery attempt.
64
73
  `.trim();
65
74
 
66
75
  export const SHEEP_PLAN_PROMPT = String.raw`