@oisincoveney/pipeline 2.1.1 → 2.2.0

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.
Files changed (37) hide show
  1. package/defaults/pipeline.yaml +111 -0
  2. package/defaults/profiles.yaml +212 -0
  3. package/defaults/runners.yaml +24 -0
  4. package/dist/argo-graph.js +59 -27
  5. package/dist/argo-submit.js +10 -2
  6. package/dist/claude-settings-config.js +44 -0
  7. package/dist/cli/program.js +10 -2
  8. package/dist/config/defaults.js +7 -350
  9. package/dist/config/schemas.d.ts +5 -5
  10. package/dist/install-commands/claude-code.js +160 -0
  11. package/dist/install-commands/opencode.js +39 -32
  12. package/dist/install-commands/shared.js +32 -5
  13. package/dist/install-commands.js +26 -15
  14. package/dist/json-config-merge.js +47 -0
  15. package/dist/mcp/gateway.js +9 -1
  16. package/dist/moka-submit.d.ts +7 -7
  17. package/dist/opencode-project-config.js +2 -45
  18. package/dist/pipeline-runtime.js +50 -8
  19. package/dist/runner-command-contract.d.ts +2 -2
  20. package/dist/runner-event-schema.d.ts +349 -0
  21. package/dist/runner-event-schema.js +185 -0
  22. package/dist/runner-output.js +2 -2
  23. package/dist/runner.d.ts +2 -0
  24. package/dist/runtime/agent-node/agent-node.js +1 -0
  25. package/dist/runtime/contracts/contracts.d.ts +2 -0
  26. package/dist/runtime/node-state-store.js +7 -0
  27. package/dist/runtime/opencode-adapter.js +28 -8
  28. package/dist/runtime/opencode-agent-name.js +18 -0
  29. package/dist/runtime/opencode-runtime.js +62 -0
  30. package/dist/runtime/opencode-server.js +67 -0
  31. package/dist/runtime/opencode-session-executor.js +206 -0
  32. package/docs/adr-opencode-first-goal-loop-runtime.md +1 -1
  33. package/docs/config-architecture.md +11 -6
  34. package/docs/mcp-gateway.md +4 -4
  35. package/docs/operator-guide.md +7 -5
  36. package/docs/slash-command-adapter-contract.md +1 -0
  37. package/package.json +6 -1
@@ -7,356 +7,13 @@ const PIPELINE_CONFIG_PATH = ".pipeline/pipeline.yaml";
7
7
  const RUNNERS_CONFIG_PATH = ".pipeline/runners.yaml";
8
8
  const PROFILES_CONFIG_PATH = ".pipeline/profiles.yaml";
9
9
  const OPENCODE_ECOSYSTEM_MANIFEST_PATH = "defaults/opencode-ecosystem.yaml";
10
- const PACKAGE_DEFAULT_RUNNERS_YAML = `version: 1
11
- runners:
12
- opencode:
13
- type: opencode
14
- capabilities:
15
- native_subagents: true
16
- rules: true
17
- skills: true
18
- mcp_servers: true
19
- tools: [read, list, grep, glob, bash, edit, write]
20
- filesystem: [read-only, workspace-write]
21
- network: [inherit, disabled]
22
- output_formats: [text, json, jsonl, json_schema]
23
- command:
24
- type: command
25
- capabilities:
26
- native_subagents: false
27
- rules: false
28
- skills: false
29
- mcp_servers: false
30
- tools: [bash]
31
- filesystem: [read-only, workspace-write]
32
- network: [inherit, disabled]
33
- output_formats: [text, json]
34
- `;
35
- const PACKAGE_DEFAULT_PROFILES_YAML = `version: 1
36
- mcp_gateway:
37
- provider: toolhive
38
- mode: local
39
- url: https://pipeline-mcp.momokaya.ee/mcp/
40
- url_env: PIPELINE_MCP_GATEWAY_URL
41
- authorization_env: PIPELINE_MCP_GATEWAY_AUTHORIZATION
42
- default_profile: default
43
- backends:
44
- context7:
45
- locality: shared-remote
46
- tool_prefixes: [context7]
47
- uidotsh:
48
- locality: shared-remote
49
- tool_prefixes: [uidotsh]
50
- qdrant:
51
- locality: repo-scoped-remote
52
- tool_prefixes: [qdrant]
53
- fallow:
54
- locality: repo-local
55
- workspace_path_source: PIPELINE_TARGET_PATH
56
- required: false
57
- tool_prefixes: [fallow]
58
- serena:
59
- locality: repo-local
60
- workspace_path_source: PIPELINE_TARGET_PATH
61
- tool_prefixes: [serena]
62
- backlog:
63
- locality: repo-local
64
- workspace_path_source: PIPELINE_TARGET_PATH
65
- tool_prefixes: [backlog]
66
- skills:
67
- execute:
68
- path: .agents/skills/execute/SKILL.md
69
- source_root: package
70
- inspect:
71
- path: .agents/skills/inspect/SKILL.md
72
- source_root: package
73
- quick:
74
- path: .agents/skills/quick/SKILL.md
75
- source_root: package
76
- critique:
77
- path: .agents/skills/critique/SKILL.md
78
- source_root: package
79
- doubt:
80
- path: .agents/skills/doubt/SKILL.md
81
- source_root: package
82
- fix:
83
- path: .agents/skills/fix/SKILL.md
84
- source_root: package
85
- library-first-development:
86
- path: .agents/skills/library-first-development/SKILL.md
87
- source_root: package
88
- migrate:
89
- path: .agents/skills/migrate/SKILL.md
90
- source_root: package
91
- optimize:
92
- path: .agents/skills/optimize/SKILL.md
93
- source_root: package
94
- research:
95
- path: .agents/skills/research/SKILL.md
96
- source_root: package
97
- schedule-graph-shaping:
98
- path: .agents/skills/schedule-graph-shaping/SKILL.md
99
- source_root: package
100
- scope:
101
- path: .agents/skills/scope/SKILL.md
102
- source_root: package
103
- secure:
104
- path: .agents/skills/secure/SKILL.md
105
- source_root: package
106
- spec:
107
- path: .agents/skills/spec/SKILL.md
108
- source_root: package
109
- test:
110
- path: .agents/skills/test/SKILL.md
111
- source_root: package
112
- trace:
113
- path: .agents/skills/trace/SKILL.md
114
- source_root: package
115
- verify:
116
- path: .agents/skills/verify/SKILL.md
117
- source_root: package
118
- profiles:
119
- moka-orchestrator:
120
- runner: opencode
121
- description: Orchestrate the configured pipeline and enforce gates.
122
- instructions: { inline: "Orchestrate the configured pipeline through package-defined entrypoints, native agents, and gates. Do not bypass configured runner subprocesses or package-configured gates." }
123
- skills: [execute, quick, inspect]
124
- mcp_servers: [pipeline-gateway]
125
- tools: [read, list, grep, glob, bash]
126
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
127
- network: { mode: inherit }
128
- moka-researcher:
129
- runner: opencode
130
- description: Research the requested task and produce structured findings.
131
- instructions: { inline: "Inspect first-party source, tests, docs, and task context for the current task only. Produce concise findings with file references and stop; do not perform open-ended repository exploration." }
132
- timeout_ms: 900000
133
- skills: [research, spec, scope]
134
- mcp_servers: [pipeline-gateway]
135
- tools: [read, list, grep, glob, bash]
136
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
137
- network: { mode: inherit }
138
- output:
139
- format: json_schema
140
- schema_path: .pipeline/schemas/research.schema.json
141
- repair: { enabled: true, max_attempts: 1 }
142
- moka-inspector:
143
- runner: opencode
144
- model: openai/gpt-5.5-low
145
- description: Inspect the repository without modifying files.
146
- instructions: { inline: "Inspect the repository without modifying files." }
147
- skills: [research]
148
- mcp_servers: [pipeline-gateway]
149
- tools: [read, list, grep, glob, bash]
150
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
151
- network: { mode: inherit }
152
- moka-schedule-planner:
153
- runner: opencode
154
- model: openai/gpt-5.5-xhigh
155
- description: Refine a baseline schedule into a specialized approved-plan artifact.
156
- instructions: { inline: "Generate exactly one workflow named root as an explicit schedule graph. Return YAML only." }
157
- timeout_ms: 300000
158
- skills: [schedule-graph-shaping]
159
- mcp_servers: [pipeline-gateway]
160
- tools: [read, list, grep, glob, bash]
161
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
162
- network: { mode: inherit }
163
- moka-test-writer:
164
- runner: opencode
165
- scheduling_roles: [implementation]
166
- description: Add focused failing tests for the requested behavior.
167
- instructions: { inline: "Add focused failing tests for the requested behavior only. Do not change production code. Only edit files matching test paths such as **/*.test.*, **/*.spec.*, **/*_test.*, **/__tests__/**, test/**, or tests/**. Return only valid JSON with top-level changes and verification. Every changes entry must include summary, why, and files. Include risks, followups, and lessons when present. Do not use Markdown fences or prose outside the JSON object." }
168
- skills: [test]
169
- mcp_servers: [pipeline-gateway]
170
- tools: [read, list, grep, glob, bash, edit, write]
171
- filesystem: { mode: workspace-write, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
172
- network: { mode: inherit }
173
- output:
174
- format: json_schema
175
- schema_path: .pipeline/schemas/implementation.schema.json
176
- repair: { enabled: true, max_attempts: 1 }
177
- moka-code-writer:
178
- runner: opencode
179
- scheduling_roles: [implementation]
180
- description: Implement production code until the failing tests pass.
181
- instructions: { inline: "Implement the smallest production change that satisfies the failing tests. Return only valid JSON with top-level changes and verification. Every changes entry must include summary, why, and files. Include risks, followups, and lessons when present. Do not use Markdown fences or prose outside the JSON object." }
182
- skills: [trace, test, fix, library-first-development]
183
- mcp_servers: [pipeline-gateway]
184
- tools: [read, list, grep, glob, bash, edit, write]
185
- filesystem: { mode: workspace-write, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
186
- network: { mode: inherit }
187
- output:
188
- format: json_schema
189
- schema_path: .pipeline/schemas/implementation.schema.json
190
- repair: { enabled: true, max_attempts: 1 }
191
- moka-acceptance-reviewer:
192
- runner: opencode
193
- scheduling_roles: [coverage]
194
- description: Audit the finished change against every acceptance criterion.
195
- instructions: { inline: 'Audit the completed change against each canonical acceptance criterion independently. Return only valid JSON with top-level "verdict", "evidence", "acceptance", and optional "violations". Each "acceptance" entry must include "id", "verdict", and non-empty "evidence". Do not use Markdown fences or prose outside the JSON object.' }
196
- skills: [critique, doubt]
197
- mcp_servers: [pipeline-gateway]
198
- tools: [read, list, grep, glob, bash]
199
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
200
- network: { mode: inherit }
201
- output:
202
- format: json_schema
203
- schema_path: .pipeline/schemas/acceptance.schema.json
204
- repair: { enabled: true, max_attempts: 1 }
205
- moka-thermo-nuclear-reviewer:
206
- runner: opencode
207
- scheduling_roles: [coverage]
208
- description: Perform the final thermo-nuclear code quality review of the integration branch.
209
- instructions: { inline: "Perform the final code quality review of the integration branch." }
210
- skills: [critique]
211
- mcp_servers: [pipeline-gateway]
212
- tools: [read, list, grep, glob, bash]
213
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
214
- network: { mode: inherit }
215
- output:
216
- format: json_schema
217
- schema_path: .pipeline/schemas/review.schema.json
218
- repair: { enabled: true, max_attempts: 1 }
219
- moka-verifier:
220
- runner: opencode
221
- scheduling_roles: [coverage]
222
- description: Verify checks, implementation fit, and final evidence.
223
- instructions: { inline: 'Verify checks, implementation fit, and final evidence. Return only valid JSON with top-level "verdict", "evidence", and optional "violations". Do not use Markdown fences or prose outside the JSON object.' }
224
- skills: [verify, critique, secure, optimize]
225
- mcp_servers: [pipeline-gateway]
226
- tools: [read, list, grep, glob, bash]
227
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
228
- network: { mode: inherit }
229
- output:
230
- format: json_schema
231
- schema_path: .pipeline/schemas/verify.schema.json
232
- repair: { enabled: true, max_attempts: 1 }
233
- moka-learner:
234
- runner: opencode
235
- model: openai/gpt-5.5-low
236
- description: Store durable lessons from the completed run.
237
- instructions: { inline: "Store durable lessons from the completed run when useful." }
238
- skills: [migrate]
239
- mcp_servers: [pipeline-gateway]
240
- tools: [read, list, grep, glob, bash]
241
- filesystem: { mode: read-only, allow: ["**/*"], deny: ["node_modules/**", "dist/**", ".git/**"] }
242
- network: { mode: inherit }
243
- output:
244
- format: json_schema
245
- schema_path: .pipeline/schemas/learn.schema.json
246
- repair: { enabled: true, max_attempts: 1 }
247
- `;
248
- const PACKAGE_DEFAULT_PIPELINE_YAML = `version: 1
249
- default_workflow: inspect
250
- orchestrator:
251
- profile: moka-orchestrator
252
- entrypoints:
253
- quick:
254
- schedule: quick-schedule
255
- description: Compact planner-generated pipeline for small work
256
- execute:
257
- schedule: execute-schedule
258
- description: Full planner-generated pipeline for repository work
259
- inspect:
260
- workflow: inspect
261
- description: Read-only repository inspection
262
- hooks:
263
- functions:
264
- generated-defaults-audit:
265
- kind: command
266
- command: [node, -e, "const fs=require('node:fs'); fs.writeFileSync(process.env.PIPELINE_HOOK_RESULT, JSON.stringify({status:'pass',summary:'Generated defaults audit passed'}));"]
267
- trusted: true
268
- timeout_ms: 5000
269
- output_limit_bytes: 4096
270
- on:
271
- workflow.start:
272
- - id: generated-defaults-audit
273
- function: generated-defaults-audit
274
- failure: fail
275
- runner_command:
276
- environment:
277
- setup:
278
- - command: bun
279
- args: [install, --frozen-lockfile]
280
- scheduler:
281
- commands:
282
- quick:
283
- schedule: quick-schedule
284
- catalog: quick
285
- execute:
286
- schedule: execute-schedule
287
- catalog: execute
288
- node_catalogs:
289
- quick:
290
- required_categories: [intake, red, green, mechanical, verification]
291
- nodes:
292
- backlog-intake:
293
- category: intake
294
- profile: moka-researcher
295
- models: [openai/gpt-5.5-medium]
296
- red-tests:
297
- category: red
298
- profile: moka-test-writer
299
- models: [openai/gpt-5.5-high, kimi-for-coding/kimi-k2-thinking]
300
- green-implementation:
301
- category: green
302
- profile: moka-code-writer
303
- models: [openai/gpt-5.5-high, kimi-for-coding/k2p6, opencode-go/qwen3.7-max]
304
- verification:
305
- category: verification
306
- profile: moka-verifier
307
- models: [openai/gpt-5.5-medium]
308
- execute:
309
- required_categories: [intake, research, red, green, mechanical, acceptance, verification, learn]
310
- nodes:
311
- backlog-intake:
312
- category: intake
313
- profile: moka-researcher
314
- models: [openai/gpt-5.5-medium]
315
- research:
316
- category: research
317
- profile: moka-researcher
318
- models: [openai/gpt-5.5-medium, kimi-for-coding/k2p6]
319
- red-tests:
320
- category: red
321
- profile: moka-test-writer
322
- models: [openai/gpt-5.5-high, kimi-for-coding/kimi-k2-thinking]
323
- green-backend:
324
- category: green
325
- profile: moka-code-writer
326
- models: [openai/gpt-5.5-high, kimi-for-coding/k2p6, opencode-go/qwen3.7-max]
327
- green-frontend:
328
- category: green
329
- profile: moka-code-writer
330
- models: [openai/gpt-5.5-high, kimi-for-coding/k2p6, opencode-go/qwen3.7-max]
331
- acceptance-review:
332
- category: acceptance
333
- profile: moka-acceptance-reviewer
334
- models: [openai/gpt-5.5-medium]
335
- verification:
336
- category: verification
337
- profile: moka-verifier
338
- models: [openai/gpt-5.5-medium]
339
- learn:
340
- category: learn
341
- profile: moka-learner
342
- models: [openai/gpt-5.5-low]
343
- schedules:
344
- quick-schedule:
345
- baseline: quick
346
- planner_profile: moka-schedule-planner
347
- node_catalog: quick
348
- execute-schedule:
349
- baseline: execute
350
- planner_profile: moka-schedule-planner
351
- node_catalog: execute
352
- workflows:
353
- inspect:
354
- description: Read-only repository inspection workflow.
355
- nodes:
356
- - id: inspect
357
- kind: agent
358
- profile: moka-inspector
359
- `;
10
+ const DEFAULT_PACKAGE_DEFAULTS_ROOT = new URL("../../defaults/", import.meta.url);
11
+ function loadDefaultYaml(filename) {
12
+ return readFileSync(new URL(filename, DEFAULT_PACKAGE_DEFAULTS_ROOT), "utf8");
13
+ }
14
+ const PACKAGE_DEFAULT_RUNNERS_YAML = loadDefaultYaml("runners.yaml");
15
+ const PACKAGE_DEFAULT_PROFILES_YAML = loadDefaultYaml("profiles.yaml");
16
+ const PACKAGE_DEFAULT_PIPELINE_YAML = loadDefaultYaml("pipeline.yaml");
360
17
  const DEFAULT_OPENCODE_ECOSYSTEM_MANIFEST_URL = new URL(`../../${OPENCODE_ECOSYSTEM_MANIFEST_PATH}`, import.meta.url);
361
18
  const ecosystemStringArraySchema = z.array(z.string().min(1));
362
19
  const ecosystemRuntimeSchema = z.object({
@@ -310,6 +310,7 @@ declare const configSchema: z.ZodObject<{
310
310
  skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
311
311
  timeout_ms: z.ZodOptional<z.ZodNumber>;
312
312
  tools: z.ZodOptional<z.ZodArray<z.ZodEnum<{
313
+ task: "task";
313
314
  read: "read";
314
315
  list: "list";
315
316
  grep: "grep";
@@ -317,7 +318,6 @@ declare const configSchema: z.ZodObject<{
317
318
  bash: "bash";
318
319
  edit: "edit";
319
320
  write: "write";
320
- task: "task";
321
321
  }>>>;
322
322
  }, z.core.$strict>>>;
323
323
  runner_command: z.ZodDefault<z.ZodObject<{
@@ -343,8 +343,8 @@ declare const configSchema: z.ZodObject<{
343
343
  rules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
344
344
  path: z.ZodString;
345
345
  source_root: z.ZodDefault<z.ZodEnum<{
346
- package: "package";
347
346
  project: "project";
347
+ package: "package";
348
348
  }>>;
349
349
  }, z.core.$strict>>>;
350
350
  runners: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
@@ -369,6 +369,7 @@ declare const configSchema: z.ZodObject<{
369
369
  rules: z.ZodOptional<z.ZodBoolean>;
370
370
  skills: z.ZodOptional<z.ZodBoolean>;
371
371
  tools: z.ZodOptional<z.ZodArray<z.ZodEnum<{
372
+ task: "task";
372
373
  read: "read";
373
374
  list: "list";
374
375
  grep: "grep";
@@ -376,7 +377,6 @@ declare const configSchema: z.ZodObject<{
376
377
  bash: "bash";
377
378
  edit: "edit";
378
379
  write: "write";
379
- task: "task";
380
380
  }>>>;
381
381
  }, z.core.$strict>;
382
382
  command: z.ZodOptional<z.ZodString>;
@@ -471,8 +471,8 @@ declare const configSchema: z.ZodObject<{
471
471
  schedules: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
472
472
  description: z.ZodOptional<z.ZodString>;
473
473
  baseline: z.ZodEnum<{
474
- execute: "execute";
475
474
  quick: "quick";
475
+ execute: "execute";
476
476
  }>;
477
477
  max_parallel_nodes: z.ZodOptional<z.ZodNumber>;
478
478
  node_catalog: z.ZodOptional<z.ZodString>;
@@ -484,8 +484,8 @@ declare const configSchema: z.ZodObject<{
484
484
  skills: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
485
485
  path: z.ZodString;
486
486
  source_root: z.ZodDefault<z.ZodEnum<{
487
- package: "package";
488
487
  project: "project";
488
+ package: "package";
489
489
  }>>;
490
490
  }, z.core.$strict>>>;
491
491
  task_context: z.ZodOptional<z.ZodObject<{
@@ -0,0 +1,160 @@
1
+ import { renderClaudeGatewayMcpServers } from "../mcp/gateway.js";
2
+ import { opencodeAgentName } from "../runtime/opencode-agent-name.js";
3
+ import { mergeClaudeSettings } from "../claude-settings-config.js";
4
+ import { CLAUDE_PROJECT_CONFIG_PATH, commandIdForHost, compactLines, entrypointDescription, entrypointEntries, instructionsPointer, invocationForHost } from "./shared.js";
5
+ import { agentDispatchRoutes, entrypointDispatchBlock, grants, header, markdown, projectAgentsMdDefinition, resolvedHostModel, scheduledEntrypointK8sNote } from "./opencode.js";
6
+ //#region src/install-commands/claude-code.ts
7
+ const CLAUDE_CODE_HOST = "claude-code";
8
+ const CLAUDE_ALLOWED_TOOLS = "Task, Bash(opencode run *)";
9
+ const CLAUDE_AGENT_TOOLS = "Bash, Read";
10
+ const MOKA_PROFILE_PREFIX = "moka-";
11
+ function claudeAgentNameForProfile(profileId) {
12
+ return profileId.startsWith(MOKA_PROFILE_PREFIX) ? profileId : `${MOKA_PROFILE_PREFIX}${profileId}`;
13
+ }
14
+ function cliRoutesForConfig(config) {
15
+ return entrypointEntries(config).flatMap(([, entrypoint]) => "workflow" in entrypoint ? agentDispatchRoutes(CLAUDE_CODE_HOST, config, entrypoint.workflow) : []);
16
+ }
17
+ function distinctCliProfiles(config) {
18
+ const seen = /* @__PURE__ */ new Set();
19
+ const profiles = [];
20
+ for (const route of cliRoutesForConfig(config)) {
21
+ if (route.kind !== "cli" || seen.has(route.profileId)) continue;
22
+ seen.add(route.profileId);
23
+ profiles.push(route);
24
+ }
25
+ return profiles.sort((a, b) => a.profileId.localeCompare(b.profileId));
26
+ }
27
+ function commandDispatchBody(config, id, entrypoint) {
28
+ if (!("workflow" in entrypoint)) return entrypointDispatchBlock(CLAUDE_CODE_HOST, config, id, entrypoint) ?? "";
29
+ const routes = agentDispatchRoutes(CLAUDE_CODE_HOST, config, entrypoint.workflow);
30
+ return [
31
+ `Run workflow \`${entrypoint.workflow}\` for the user task.`,
32
+ "",
33
+ "Delegate each agent node to a Claude Code `Task` subagent that wraps a local `opencode run` subprocess.",
34
+ "Spawn one node at a time respecting `needs`; run nodes whose dependencies are satisfied in parallel.",
35
+ "",
36
+ "Node routes:",
37
+ ...routes.map(claudeNodeRouteLine),
38
+ "",
39
+ "For each node prompt include:",
40
+ "- user task",
41
+ `- workflow id: ${entrypoint.workflow}`,
42
+ "- node id",
43
+ "- profile id",
44
+ "- profile instructions reference",
45
+ "- profile grants",
46
+ "- dependency outputs",
47
+ "",
48
+ "Only package-configured gates are blocking. Do not invent RED, GREEN, full-suite, typecheck, or unrelated-drift gates.",
49
+ "If a node returns targeted evidence and has no configured blocking gate, advance to the next node.",
50
+ "The Task subagents wrap `opencode run` subprocesses; do not claim these worker nodes are Claude Code native agents."
51
+ ].join("\n");
52
+ }
53
+ function claudeNodeRouteLine(route) {
54
+ const needs = route.needs.length > 0 ? route.needs.join(",") : "none";
55
+ return `- ${route.nodeId}: Task subagent_type=${claudeAgentNameForProfile(route.profileId)} runner=${route.runnerId} agent="${opencodeAgentName(route.profileId)}" needs=${needs}`;
56
+ }
57
+ function commandDefinitions(config) {
58
+ return entrypointEntries(config).map(([id, entrypoint]) => ({
59
+ content: markdown({
60
+ "argument-hint": "<task description>",
61
+ "allowed-tools": CLAUDE_ALLOWED_TOOLS,
62
+ description: entrypointDescription(id, entrypoint)
63
+ }, compactLines([
64
+ header(CLAUDE_CODE_HOST).trimEnd(),
65
+ "",
66
+ `Invoke this command with \`${invocationForHost(CLAUDE_CODE_HOST, id)}\`.`,
67
+ "",
68
+ "Load and follow the `execute` skill for the execution doctrine before dispatching work.",
69
+ "",
70
+ scheduledEntrypointK8sNote(entrypoint),
71
+ scheduledEntrypointK8sNote(entrypoint) ? "" : void 0,
72
+ commandDispatchBody(config, id, entrypoint)
73
+ ]).join("\n")),
74
+ host: CLAUDE_CODE_HOST,
75
+ invocation: invocationForHost(CLAUDE_CODE_HOST, id),
76
+ path: `.claude/commands/${commandIdForHost(CLAUDE_CODE_HOST, id)}.md`
77
+ }));
78
+ }
79
+ function agentModelProjection(config, profile) {
80
+ const model = resolvedHostModel(config, CLAUDE_CODE_HOST, profile);
81
+ return model ? { model } : {};
82
+ }
83
+ function agentDefinitions(config) {
84
+ return distinctCliProfiles(config).map((route) => {
85
+ const profile = route.profile;
86
+ const agentName = claudeAgentNameForProfile(route.profileId);
87
+ const displayName = opencodeAgentName(route.profileId);
88
+ return {
89
+ content: markdown({
90
+ name: agentName,
91
+ description: profile.description ?? route.profileId,
92
+ tools: CLAUDE_AGENT_TOOLS,
93
+ ...agentModelProjection(config, profile)
94
+ }, [
95
+ header(CLAUDE_CODE_HOST).trimEnd(),
96
+ "",
97
+ profile.description ?? route.profileId,
98
+ "",
99
+ `Run EXACTLY ONE \`opencode run --agent "${displayName}" --format json --dir "$PWD" '<node prompt>'\` subprocess for this node.`,
100
+ "Stay inside this node's scope and do not branch into adjacent nodes.",
101
+ "Do not claim completion without fresh evidence from the subprocess output.",
102
+ "Return only: { command, exit status, parsed evidence, touched files, blockers }.",
103
+ "",
104
+ "Configured grants:",
105
+ grants(profile),
106
+ "",
107
+ instructionsPointer(profile)
108
+ ].join("\n")),
109
+ host: CLAUDE_CODE_HOST,
110
+ invocation: invocationForHost(CLAUDE_CODE_HOST),
111
+ path: `.claude/agents/${agentName}.md`
112
+ };
113
+ });
114
+ }
115
+ function settingsDefinition(config) {
116
+ const settings = { permissions: { allow: ["Task", "Bash(opencode run *)"] } };
117
+ if (config.mcp_gateway) settings.mcpServers = renderClaudeGatewayMcpServers(config);
118
+ return [{
119
+ content: `${JSON.stringify(settings, null, 2)}\n`,
120
+ host: CLAUDE_CODE_HOST,
121
+ invocation: invocationForHost(CLAUDE_CODE_HOST),
122
+ path: CLAUDE_PROJECT_CONFIG_PATH
123
+ }];
124
+ }
125
+ function claudeCodeDefinitions(config, cwd) {
126
+ return [
127
+ ...commandDefinitions(config),
128
+ ...agentDefinitions(config),
129
+ ...settingsDefinition(config),
130
+ projectAgentsMdDefinition(cwd, CLAUDE_CODE_HOST)
131
+ ];
132
+ }
133
+ /**
134
+ * The claude-code HostAdapter. Encapsulates all Claude Code-specific command
135
+ * generation, resource roots, and settings-merge behaviour.
136
+ */
137
+ const claudeCodeAdapter = {
138
+ host: "claude-code",
139
+ resourceRoots: [".claude/commands", ".claude/agents"],
140
+ definitions(config, cwd) {
141
+ return claudeCodeDefinitions(config, cwd);
142
+ },
143
+ mergeDefinition(definition, existingContent) {
144
+ if (definition.path !== ".claude/settings.json") return;
145
+ const merged = mergeClaudeSettings(existingContent, JSON.parse(definition.content));
146
+ if (!merged.ok) return {
147
+ ok: false,
148
+ content: definition.content
149
+ };
150
+ return {
151
+ ok: true,
152
+ content: merged.content
153
+ };
154
+ },
155
+ isAlwaysForced(definition) {
156
+ return definition.path === CLAUDE_PROJECT_CONFIG_PATH;
157
+ }
158
+ };
159
+ //#endregion
160
+ export { claudeCodeAdapter };