synorch 0.1.0 → 0.3.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 (90) hide show
  1. package/CHANGELOG.md +72 -22
  2. package/LICENSE +21 -21
  3. package/README.md +346 -56
  4. package/dist/application/doctor-service.d.ts +16 -0
  5. package/dist/application/doctor-service.d.ts.map +1 -1
  6. package/dist/application/doctor-service.js +230 -32
  7. package/dist/application/doctor-service.js.map +1 -1
  8. package/dist/application/generated-skill-doctor.d.ts +9 -0
  9. package/dist/application/generated-skill-doctor.d.ts.map +1 -0
  10. package/dist/application/generated-skill-doctor.js +433 -0
  11. package/dist/application/generated-skill-doctor.js.map +1 -0
  12. package/dist/application/project-discovery.d.ts +12 -0
  13. package/dist/application/project-discovery.d.ts.map +1 -1
  14. package/dist/application/project-discovery.js +65 -2
  15. package/dist/application/project-discovery.js.map +1 -1
  16. package/dist/application/safe-path.d.ts +19 -0
  17. package/dist/application/safe-path.d.ts.map +1 -0
  18. package/dist/application/safe-path.js +35 -0
  19. package/dist/application/safe-path.js.map +1 -0
  20. package/dist/application/size-ceiling.d.ts +15 -0
  21. package/dist/application/size-ceiling.d.ts.map +1 -0
  22. package/dist/application/size-ceiling.js +32 -0
  23. package/dist/application/size-ceiling.js.map +1 -0
  24. package/dist/application/structure-service.d.ts.map +1 -1
  25. package/dist/application/structure-service.js +10 -1
  26. package/dist/application/structure-service.js.map +1 -1
  27. package/dist/cli.js +27 -18
  28. package/dist/cli.js.map +1 -1
  29. package/dist/domain/canonical-contracts.d.ts +69 -0
  30. package/dist/domain/canonical-contracts.d.ts.map +1 -0
  31. package/dist/domain/canonical-contracts.js +92 -0
  32. package/dist/domain/canonical-contracts.js.map +1 -0
  33. package/dist/domain/generated-skill.d.ts +55 -0
  34. package/dist/domain/generated-skill.d.ts.map +1 -0
  35. package/dist/domain/generated-skill.js +90 -0
  36. package/dist/domain/generated-skill.js.map +1 -0
  37. package/dist/domain/generation.d.ts +15 -2
  38. package/dist/domain/generation.d.ts.map +1 -1
  39. package/dist/domain/observation-ledger.d.ts +118 -0
  40. package/dist/domain/observation-ledger.d.ts.map +1 -0
  41. package/dist/domain/observation-ledger.js +183 -0
  42. package/dist/domain/observation-ledger.js.map +1 -0
  43. package/dist/domain/product.d.ts +1 -1
  44. package/dist/domain/product.js +1 -1
  45. package/dist/domain/relative-path.d.ts +21 -0
  46. package/dist/domain/relative-path.d.ts.map +1 -0
  47. package/dist/domain/relative-path.js +43 -0
  48. package/dist/domain/relative-path.js.map +1 -0
  49. package/dist/domain/skill-packs.d.ts.map +1 -1
  50. package/dist/domain/skill-packs.js +2 -0
  51. package/dist/domain/skill-packs.js.map +1 -1
  52. package/dist/domain/skill-sources.d.ts.map +1 -1
  53. package/dist/domain/skill-sources.js +0 -1
  54. package/dist/domain/skill-sources.js.map +1 -1
  55. package/dist/domain/zod-issues.d.ts +21 -0
  56. package/dist/domain/zod-issues.d.ts.map +1 -0
  57. package/dist/domain/zod-issues.js +27 -0
  58. package/dist/domain/zod-issues.js.map +1 -0
  59. package/dist/infrastructure/bundled-skill-library.d.ts.map +1 -1
  60. package/dist/infrastructure/bundled-skill-library.js +2 -0
  61. package/dist/infrastructure/bundled-skill-library.js.map +1 -1
  62. package/dist/infrastructure/frontmatter.d.ts +25 -0
  63. package/dist/infrastructure/frontmatter.d.ts.map +1 -0
  64. package/dist/infrastructure/frontmatter.js +75 -0
  65. package/dist/infrastructure/frontmatter.js.map +1 -0
  66. package/dist/templates/agent-manifests.d.ts +19 -0
  67. package/dist/templates/agent-manifests.d.ts.map +1 -0
  68. package/dist/templates/agent-manifests.js +302 -0
  69. package/dist/templates/agent-manifests.js.map +1 -0
  70. package/dist/templates/base-skills.d.ts +23 -0
  71. package/dist/templates/base-skills.d.ts.map +1 -0
  72. package/dist/templates/base-skills.js +477 -0
  73. package/dist/templates/base-skills.js.map +1 -0
  74. package/dist/templates/skill-creator-skill.d.ts +23 -0
  75. package/dist/templates/skill-creator-skill.d.ts.map +1 -0
  76. package/dist/templates/skill-creator-skill.js +235 -0
  77. package/dist/templates/skill-creator-skill.js.map +1 -0
  78. package/dist/templates/skill-references.d.ts +13 -0
  79. package/dist/templates/skill-references.d.ts.map +1 -0
  80. package/dist/templates/skill-references.js +280 -0
  81. package/dist/templates/skill-references.js.map +1 -0
  82. package/dist/templates/structure-templates.d.ts.map +1 -1
  83. package/dist/templates/structure-templates.js +280 -349
  84. package/dist/templates/structure-templates.js.map +1 -1
  85. package/dist/templates/task-conductor-skill.d.ts +2 -0
  86. package/dist/templates/task-conductor-skill.d.ts.map +1 -0
  87. package/dist/templates/task-conductor-skill.js +78 -0
  88. package/dist/templates/task-conductor-skill.js.map +1 -0
  89. package/package.json +59 -59
  90. package/skill-sources/ingenium/skills/task-conductor/SKILL.md +0 -158
@@ -1,5 +1,8 @@
1
1
  import { SYNORCH_GENERATOR_NAME, SYNORCH_VERSION } from "../domain/product.js";
2
2
  import { stringifyYaml } from "../infrastructure/serialization.js";
3
+ import { AGENT_DOCUMENTS } from "./agent-manifests.js";
4
+ import { BASE_SKILL_DOCUMENTS } from "./base-skills.js";
5
+ import { skillCreatorLedgerFiles } from "./skill-creator-skill.js";
3
6
  export function createStructureFiles(scope) {
4
7
  return [
5
8
  file("AGENTS.md", codexEntrypoint, "entrypoint"),
@@ -29,18 +32,11 @@ export function createStructureFiles(scope) {
29
32
  file(".ai/protocols/core/verification.md", verificationProtocol, "protocol"),
30
33
  file(".ai/protocols/core/failure-recovery.md", failureRecoveryProtocol, "protocol"),
31
34
  file(".ai/protocols/core/user-communication.md", userCommunicationProtocol, "protocol"),
32
- file(".ai/agents/orchestrator/AGENT.md", orchestratorAgent, "agent"),
33
- file(".ai/agents/explorer/AGENT.md", explorerAgent, "agent"),
34
- file(".ai/agents/implementer/AGENT.md", implementerAgent, "agent"),
35
- file(".ai/agents/debugger/AGENT.md", debuggerAgent, "agent"),
36
- file(".ai/agents/reviewer/AGENT.md", reviewerAgent, "agent"),
37
- file(".ai/skills/planning/SKILL.md", planningSkill, "skill"),
38
- file(".ai/skills/project-discovery/SKILL.md", projectDiscoverySkill, "skill"),
39
- file(".ai/skills/codebase-exploration/SKILL.md", explorationSkill, "skill"),
40
- file(".ai/skills/implementation/SKILL.md", implementationSkill, "skill"),
41
- file(".ai/skills/verification/SKILL.md", verificationSkill, "skill"),
42
- file(".ai/skills/debugging/SKILL.md", debuggingSkill, "skill"),
43
- file(".ai/skills/code-review/SKILL.md", codeReviewSkill, "skill"),
35
+ ...AGENT_DOCUMENTS.map((agent) => file(`.ai/agents/${agent.id}/AGENT.md`, agent.manifest, "agent")),
36
+ ...BASE_SKILL_DOCUMENTS.flatMap((skill) => [
37
+ file(`.ai/skills/${skill.id}/SKILL.md`, skill.skill, "skill"),
38
+ ...skill.references.map((reference) => file(`.ai/skills/${skill.id}/references/${reference.fileName}`, reference.content, "reference")),
39
+ ]),
44
40
  file(".ai/model-profiles/openai.yaml", openAiProfile, "canonical"),
45
41
  file(".ai/model-profiles/claude.yaml", claudeProfile, "canonical"),
46
42
  file(".ai/schemas/context-packet.schema.json", contextPacketSchema, "schema"),
@@ -48,6 +44,7 @@ export function createStructureFiles(scope) {
48
44
  file(".ai/providers/codex.md", codexAdapter, "provider"),
49
45
  file(".ai/providers/claude-code.md", claudeAdapter, "provider"),
50
46
  file(".ai/tasks/.gitkeep", "", "canonical"),
47
+ ...skillCreatorLedgerFiles,
51
48
  ];
52
49
  }
53
50
  function file(relativePath, content, kind) {
@@ -57,357 +54,271 @@ function file(relativePath, content, kind) {
57
54
  kind,
58
55
  };
59
56
  }
60
- const codexEntrypoint = `# Codex Orchestration Entrypoint
61
-
62
- This session is the orchestrator. Read \`.ai/constitution.md\` and the applicable core protocols before acting.
63
-
64
- ## Mandatory session bootstrap
65
-
66
- Before the first task:
67
-
68
- 1. Read \`.ai/manifest.yaml\` and \`.ai/model-profiles/openai.yaml\`.
69
- 2. Show the active orchestrator, complex-worker and fast-worker models, routing mode, fallback policy and override source.
70
- 3. Ask the user whether to continue with or change that profile.
71
- 4. Do not begin discovery or planning until the user confirms.
72
- 5. For the active project, read its record from \`.ai/workspace.yaml\`, then read the referenced \`skill_registry\`.
73
- 6. Read \`.ai/skills/catalog.yaml\` descriptions. Load registered technology skills first; load an on-demand bundled skill only when its description directly matches the current task. Never load the whole library.
74
-
75
- ## Non-negotiable behavior
76
-
77
- - Never write or edit product code, tests, project configuration or project documentation yourself.
78
- - You may write control-plane artifacts only under \`.ai/tasks/**\`.
79
- - Plan every new task and obtain user approval before execution.
80
- - Delegate all implementation to worker agents.
81
- - Give each worker a minimal, evidence-backed task context packet.
82
- - Require independent verification before reporting completion.
83
- - Only the orchestrator communicates with the user.
84
-
85
- If the host cannot provide the configured model or worker delegation capability, report the limitation. Never silently fall back or implement the work yourself.
57
+ const codexEntrypoint = `# Codex Orchestration Entrypoint
58
+
59
+ This session is the orchestrator. Read \`.ai/constitution.md\` and the applicable core protocols before acting.
60
+
61
+ ## Mandatory session bootstrap
62
+
63
+ Before the first task:
64
+
65
+ 1. Read \`.ai/manifest.yaml\` and \`.ai/model-profiles/openai.yaml\`.
66
+ 2. Show the active orchestrator, complex-worker and fast-worker models, routing mode, fallback policy and override source.
67
+ 3. Ask the user whether to continue with or change that profile.
68
+ 4. Do not begin discovery or planning until the user confirms.
69
+ 5. For the active project, read its record from \`.ai/workspace.yaml\`, then read the referenced \`skill_registry\`.
70
+ 6. Treat registry entries as active, catalog entries as merely available, and skill contents as unloaded until the current work requires them. Do not scan or load the whole catalog during bootstrap.
71
+ 7. Outside the registry, discover \`.ai/skills/project/*/SKILL.md\` from frontmatter only. Route only \`status: active\`; never auto-load \`proposed\`, \`stale\` or \`retired\`, and keep bodies unloaded during discovery.
72
+ 8. For a non-trivial brief, load \`.ai/skills/task-conductor/SKILL.md\` as the central decomposition and routing discipline. For a one-line or single-step fix, keep the workflow trivial and do not create an orchestra.
73
+ 9. Load other skills just in time when their description matches the work. Load a generated skill body only when its active metadata matches.
74
+
75
+ ## Non-negotiable behavior
76
+
77
+ - Never write or edit product code, tests, project configuration or project documentation yourself.
78
+ - You may write control-plane artifacts only under \`.ai/tasks/**\`.
79
+ - Plan every new task and obtain user approval before execution.
80
+ - Delegate all implementation to worker agents.
81
+ - Give each worker a minimal, evidence-backed task context packet.
82
+ - Match verification cost to explicit risk. Trivial work uses exact diff and claim-specific evidence without an independent reviewer. Material standard and high-risk work require independent review.
83
+ - Headed browser verification is opt-in: use it only when the user requested it or after approval for a named criterion that cheaper evidence cannot settle.
84
+ - Only the orchestrator communicates with the user.
85
+
86
+ If the host cannot provide the configured model or worker delegation capability, report the limitation. Never silently fall back or implement the work yourself.
86
87
  `;
87
- const claudeEntrypoint = `# Claude Code Orchestration Entrypoint
88
-
89
- This session is the orchestrator. Read \`.ai/constitution.md\` and the applicable core protocols before acting.
90
-
91
- ## Mandatory session bootstrap
92
-
93
- Before the first task:
94
-
95
- 1. Read \`.ai/manifest.yaml\` and \`.ai/model-profiles/claude.yaml\`.
96
- 2. Show the active orchestrator, complex-worker and fast-worker models, routing mode, fallback policy and override source.
97
- 3. Ask the user whether to continue with or change that profile.
98
- 4. Do not begin discovery or planning until the user confirms.
99
- 5. For the active project, read its record from \`.ai/workspace.yaml\`, then read the referenced \`skill_registry\`.
100
- 6. Read \`.ai/skills/catalog.yaml\` descriptions. Load registered technology skills first; load an on-demand bundled skill only when its description directly matches the current task. Never load the whole library.
101
-
102
- ## Non-negotiable behavior
103
-
104
- - Never write or edit product code, tests, project configuration or project documentation yourself.
105
- - You may write control-plane artifacts only under \`.ai/tasks/**\`.
106
- - Plan every new task and obtain user approval before execution.
107
- - Delegate all implementation to worker agents.
108
- - Give each worker a minimal, evidence-backed task context packet.
109
- - Require independent verification before reporting completion.
110
- - Only the orchestrator communicates with the user.
111
-
112
- If the host cannot provide the configured model or worker delegation capability, report the limitation. Never silently fall back or implement the work yourself.
88
+ const claudeEntrypoint = `# Claude Code Orchestration Entrypoint
89
+
90
+ This session is the orchestrator. Read \`.ai/constitution.md\` and the applicable core protocols before acting.
91
+
92
+ ## Mandatory session bootstrap
93
+
94
+ Before the first task:
95
+
96
+ 1. Read \`.ai/manifest.yaml\` and \`.ai/model-profiles/claude.yaml\`.
97
+ 2. Show the active orchestrator, complex-worker and fast-worker models, routing mode, fallback policy and override source.
98
+ 3. Ask the user whether to continue with or change that profile.
99
+ 4. Do not begin discovery or planning until the user confirms.
100
+ 5. For the active project, read its record from \`.ai/workspace.yaml\`, then read the referenced \`skill_registry\`.
101
+ 6. Treat registry entries as active, catalog entries as merely available, and skill contents as unloaded until the current work requires them. Do not scan or load the whole catalog during bootstrap.
102
+ 7. Outside the registry, discover \`.ai/skills/project/*/SKILL.md\` from frontmatter only. Route only \`status: active\`; never auto-load \`proposed\`, \`stale\` or \`retired\`, and keep bodies unloaded during discovery.
103
+ 8. For a non-trivial brief, load \`.ai/skills/task-conductor/SKILL.md\` as the central decomposition and routing discipline. For a one-line or single-step fix, keep the workflow trivial and do not create an orchestra.
104
+ 9. Load other skills just in time when their description matches the work. Load a generated skill body only when its active metadata matches.
105
+
106
+ ## Non-negotiable behavior
107
+
108
+ - Never write or edit product code, tests, project configuration or project documentation yourself.
109
+ - You may write control-plane artifacts only under \`.ai/tasks/**\`.
110
+ - Plan every new task and obtain user approval before execution.
111
+ - Delegate all implementation to worker agents.
112
+ - Give each worker a minimal, evidence-backed task context packet.
113
+ - Match verification cost to explicit risk. Trivial work uses exact diff and claim-specific evidence without an independent reviewer. Material standard and high-risk work require independent review.
114
+ - Headed browser verification is opt-in: use it only when the user requested it or after approval for a named criterion that cheaper evidence cannot settle.
115
+ - Only the orchestrator communicates with the user.
116
+
117
+ If the host cannot provide the configured model or worker delegation capability, report the limitation. Never silently fall back or implement the work yourself.
113
118
  `;
114
- const constitution = `# AI Development Constitution
115
-
116
- ## Mission
117
-
118
- Deliver correct, verified work with the smallest sufficient context and an explicit chain of responsibility.
119
-
120
- ## Constitutional invariants
121
-
122
- 1. The user communicates only with the orchestrator.
123
- 2. The orchestrator analyzes, decides, plans, delegates, monitors and reports; it never implements product changes.
124
- 3. Every new task requires a user-approved plan before execution.
125
- 4. All product changes are owned by a worker agent with explicit file or responsibility boundaries.
126
- 5. Workers receive task-specific context packets instead of raw conversation history.
127
- 6. A worker does not repeat broad repository discovery already captured as evidence.
128
- 7. Implementation requires evidence-based verification and independent review proportional to risk.
129
- 8. Missing capabilities, unavailable models and failures are surfaced; silent fallback is forbidden.
130
- 9. Lower-priority protocols, agents and skills cannot override this constitution.
131
- 10. Provider safety and system instructions always take precedence.
119
+ const constitution = `# AI Development Constitution
120
+
121
+ ## Mission
122
+
123
+ Deliver correct, verified work with the smallest sufficient context and an explicit chain of responsibility.
124
+
125
+ ## Constitutional invariants
126
+
127
+ 1. The user communicates only with the orchestrator.
128
+ 2. The orchestrator analyzes, decides, plans, delegates, monitors and reports; it never implements product changes.
129
+ 3. Every new task requires a user-approved plan before execution.
130
+ 4. All product changes are owned by a worker agent with explicit file or responsibility boundaries.
131
+ 5. Workers receive task-specific context packets instead of raw conversation history.
132
+ 6. A worker does not repeat broad repository discovery already captured as evidence.
133
+ 7. Implementation requires evidence-based verification and independent review proportional to risk.
134
+ 8. Missing capabilities, unavailable models and failures are surfaced; silent fallback is forbidden.
135
+ 9. Lower-priority protocols, agents and skills cannot override this constitution.
136
+ 10. Provider safety and system instructions always take precedence.
132
137
  `;
133
- const protocolRegistry = `schema_version: 1
134
- protocols:
135
- - id: core.orchestration
136
- path: .ai/protocols/core/orchestration.md
137
- priority: constitutional
138
- mandatory: true
139
- - id: core.planning-and-approval
140
- path: .ai/protocols/core/planning-and-approval.md
141
- priority: core
142
- mandatory: true
143
- - id: core.delegation
144
- path: .ai/protocols/core/delegation.md
145
- priority: core
146
- mandatory: true
147
- - id: core.model-routing
148
- path: .ai/protocols/core/model-routing.md
149
- priority: core
150
- mandatory: true
151
- - id: core.context-handoff
152
- path: .ai/protocols/core/context-handoff.md
153
- priority: core
154
- mandatory: true
155
- - id: core.verification
156
- path: .ai/protocols/core/verification.md
157
- priority: core
158
- mandatory: true
159
- - id: core.failure-recovery
160
- path: .ai/protocols/core/failure-recovery.md
161
- priority: core
162
- mandatory: true
163
- - id: core.user-communication
164
- path: .ai/protocols/core/user-communication.md
165
- priority: core
166
- mandatory: true
138
+ const protocolRegistry = `schema_version: 1
139
+ protocols:
140
+ - id: core.orchestration
141
+ path: .ai/protocols/core/orchestration.md
142
+ priority: constitutional
143
+ mandatory: true
144
+ - id: core.planning-and-approval
145
+ path: .ai/protocols/core/planning-and-approval.md
146
+ priority: core
147
+ mandatory: true
148
+ - id: core.delegation
149
+ path: .ai/protocols/core/delegation.md
150
+ priority: core
151
+ mandatory: true
152
+ - id: core.model-routing
153
+ path: .ai/protocols/core/model-routing.md
154
+ priority: core
155
+ mandatory: true
156
+ - id: core.context-handoff
157
+ path: .ai/protocols/core/context-handoff.md
158
+ priority: core
159
+ mandatory: true
160
+ - id: core.verification
161
+ path: .ai/protocols/core/verification.md
162
+ priority: core
163
+ mandatory: true
164
+ - id: core.failure-recovery
165
+ path: .ai/protocols/core/failure-recovery.md
166
+ priority: core
167
+ mandatory: true
168
+ - id: core.user-communication
169
+ path: .ai/protocols/core/user-communication.md
170
+ priority: core
171
+ mandatory: true
167
172
  `;
168
- const orchestrationProtocol = `---
169
- id: core.orchestration
170
- version: 1.0.0
171
- priority: constitutional
172
- mandatory: true
173
- overridable: false
174
- ---
175
-
176
- # Orchestration Protocol
177
-
178
- Use the state machine:
179
-
180
- \`SESSION_BOOTSTRAP → MODEL_PROFILE_CONFIRMATION → INTAKE → DISCOVERY → CLARIFICATION → PLAN → USER_APPROVAL → DECOMPOSITION → DISPATCH → MONITORING → VERIFICATION → REVIEW → FINAL_REPORT\`.
181
-
182
- The orchestrator must not skip a gate. It may read project files and write only task-control records under \`.ai/tasks/**\`. Every product mutation is delegated. Worker questions return to the orchestrator; only material decisions are escalated to the user.
173
+ const orchestrationProtocol = `---
174
+ id: core.orchestration
175
+ version: 1.1.0
176
+ priority: constitutional
177
+ mandatory: true
178
+ overridable: false
179
+ ---
180
+
181
+ # Orchestration Protocol
182
+
183
+ Required lifecycle:
184
+
185
+ \`SESSION_BOOTSTRAP → MODEL_PROFILE_CONFIRMATION → INTAKE → RISK_CLASSIFICATION → PLAN → USER_APPROVAL → DISPATCH → PROPORTIONAL_VERIFICATION → FINAL_REPORT\`.
186
+
187
+ Classify work before expanding the workflow:
188
+
189
+ - \`trivial\`: one local, reversible change without behavior, contract, dependency, security, data or architecture impact.
190
+ - \`standard\`: bounded behavior across a small related surface.
191
+ - \`high-risk\`: security, authentication, payments, persistence, migrations, public contracts, concurrency, destructive operations or wide architecture.
192
+
193
+ Discovery, clarification, decomposition, monitoring and independent review are conditional tools, not mandatory ceremony. Use them only when risk, uncertainty or dependency structure justifies them. User approval, delegated product mutation and evidence for completion remain mandatory.
194
+
195
+ The orchestrator may read project files and write only task-control records under \`.ai/tasks/**\`. Every product mutation is delegated. Worker questions return to the orchestrator; only material decisions are escalated to the user.
183
196
  `;
184
- const planningProtocol = `---
185
- id: core.planning-and-approval
186
- version: 1.0.0
187
- priority: core
188
- mandatory: true
189
- ---
190
-
191
- # Planning and Approval
192
-
193
- Before execution, present the understood goal, verified current state, proposed approach, affected areas, task decomposition, model choices, verification plan, assumptions and risks. Wait for explicit user approval. Re-open approval when scope or a material decision changes.
197
+ const planningProtocol = `---
198
+ id: core.planning-and-approval
199
+ version: 1.1.0
200
+ priority: core
201
+ mandatory: true
202
+ ---
203
+
204
+ # Planning and Approval
205
+
206
+ Before execution, present the understood goal, risk tier, proposed approach, ownership and verification budget. Wait for explicit user approval. Re-open approval when scope, tier or a material decision changes.
207
+
208
+ For trivial work, use one compact paragraph: exact change, one fast worker, owned path and claim-specific proof. Do not invent workstreams, broad discovery or a reviewer. Standard plans include affected areas, focused discovery and targeted checks. High-risk plans include dependencies, failure modes, independent review and rollback or recovery where relevant.
194
209
  `;
195
- const delegationProtocol = `---
196
- id: core.delegation
197
- version: 1.0.0
198
- priority: core
199
- mandatory: true
200
- ---
201
-
202
- # Delegation
203
-
204
- Give every worker one bounded objective, explicit ownership, constraints, acceptance criteria and an expected report contract. Parallelize only independent tasks. Workers are not alone in the codebase and must not revert or overwrite other workers' changes. Shared-file ownership requires serialization or an explicit integration owner.
210
+ const delegationProtocol = `---
211
+ id: core.delegation
212
+ version: 1.0.0
213
+ priority: core
214
+ mandatory: true
215
+ ---
216
+
217
+ # Delegation
218
+
219
+ Give every worker one bounded objective, explicit ownership, constraints, acceptance criteria and an expected report contract. Parallelize only independent tasks. Workers are not alone in the codebase and must not revert or overwrite other workers' changes. Shared-file ownership requires serialization or an explicit integration owner.
205
220
  `;
206
- const modelRoutingProtocol = `---
207
- id: core.model-routing
208
- version: 1.0.0
209
- priority: core
210
- mandatory: true
211
- ---
212
-
213
- # Model Routing
214
-
215
- Use the active provider profile. Route architecture and final decisions to the orchestrator tier, complex implementation/debugging to the complex-worker tier, and small local low-risk work to the fast-worker tier. Small tasks are still delegated. Do not silently substitute unavailable models. Session overrides do not become persistent defaults unless the user explicitly requests it.
221
+ const modelRoutingProtocol = `---
222
+ id: core.model-routing
223
+ version: 1.1.0
224
+ priority: core
225
+ mandatory: true
226
+ ---
227
+
228
+ # Model Routing
229
+
230
+ Use the active provider profile and the classified risk:
231
+
232
+ - Trivial work uses exactly one fast worker unless the required capability is unavailable.
233
+ - Standard work uses the smallest capable worker set; prefer a fast worker for local edits and a complex worker for non-local reasoning.
234
+ - High-risk work uses complex workers for implementation or debugging and an independent reviewer.
235
+
236
+ The orchestrator owns architecture and final decisions but never implementation. Use Task Conductor as the central decomposition and skill-routing discipline for non-trivial briefs. Do not silently substitute unavailable models. Session overrides do not become persistent defaults unless the user explicitly requests it.
216
237
  `;
217
- const contextHandoffProtocol = `---
218
- id: core.context-handoff
219
- version: 1.0.0
220
- priority: core
221
- mandatory: true
222
- ---
223
-
224
- # Context Handoff
225
-
226
- Prefer minimal inherited history plus an explicit task context packet. Include objective, rationale, owned/read/forbidden scope, verified facts with provenance, decisions, relevant files and symbols, acceptance criteria, verification commands, non-goals and escalation conditions.
227
-
228
- Workers may inspect target files and narrowly verify critical facts, but must not repeat broad discovery. Missing context is requested from the orchestrator. Follow-up work uses a delta packet. Worker output follows the completion-packet schema.
238
+ const contextHandoffProtocol = `---
239
+ id: core.context-handoff
240
+ version: 1.0.0
241
+ priority: core
242
+ mandatory: true
243
+ ---
244
+
245
+ # Context Handoff
246
+
247
+ Prefer minimal inherited history plus an explicit task context packet. Include objective, rationale, owned/read/forbidden scope, verified facts with provenance, decisions, relevant files and symbols, acceptance criteria, verification commands, non-goals and escalation conditions.
248
+
249
+ Workers may inspect target files and narrowly verify critical facts, but must not repeat broad discovery. Missing context is requested from the orchestrator. Follow-up work uses a delta packet. Worker output follows the completion-packet schema.
229
250
  `;
230
- const verificationProtocol = `---
231
- id: core.verification
232
- version: 1.0.0
233
- priority: core
234
- mandatory: true
235
- ---
236
-
237
- # Verification
238
-
239
- No task is complete without evidence. Run the narrowest relevant checks first, then broader checks proportional to risk. Record exact commands and outcomes. Never claim a check ran when it did not. A separate reviewer evaluates requirement coverage, diff risk and evidence for material changes.
251
+ const verificationProtocol = `---
252
+ id: core.verification
253
+ version: 1.1.0
254
+ priority: core
255
+ mandatory: true
256
+ ---
257
+
258
+ # Verification
259
+
260
+ No task is complete without evidence, but unrelated checks do not increase correctness. Stop at the cheapest evidence that proves the approved claim:
261
+
262
+ 1. Exact diff, search, parse or static inspection tied to the change.
263
+ 2. Narrow existing lint, typecheck, unit or component checks for the affected scope.
264
+ 3. Broader build, integration or end-to-end checks only when behavior or boundaries justify them.
265
+ 4. Independent review for material standard work and all high-risk work.
266
+
267
+ Trivial work must not trigger a full-project lint, build, test suite, independent reviewer or browser unless the change itself invalidates that rule. Record exact commands and outcomes, including intentionally skipped checks. Never claim a check ran when it did not.
268
+
269
+ Headed browser verification is opt-in. Use it only when the user requested it, or when a named acceptance criterion cannot be resolved by static, automated or structural evidence. In the latter case, explain the gap and obtain approval first. Never create browser automation or screenshot infrastructure as an incidental verification step.
240
270
  `;
241
- const failureRecoveryProtocol = `---
242
- id: core.failure-recovery
243
- version: 1.0.0
244
- priority: core
245
- mandatory: true
246
- ---
247
-
248
- # Failure, Retry and Escalation
249
-
250
- On failure, preserve evidence, classify the cause and retry only with a materially changed hypothesis or instruction. Do not loop. Scope changes, stale context, ownership conflicts, unavailable capabilities and user decisions return to the orchestrator. The orchestrator never takes over implementation as a recovery mechanism.
271
+ const failureRecoveryProtocol = `---
272
+ id: core.failure-recovery
273
+ version: 1.0.0
274
+ priority: core
275
+ mandatory: true
276
+ ---
277
+
278
+ # Failure, Retry and Escalation
279
+
280
+ On failure, preserve evidence, classify the cause and retry only with a materially changed hypothesis or instruction. Do not loop. Scope changes, stale context, ownership conflicts, unavailable capabilities and user decisions return to the orchestrator. The orchestrator never takes over implementation as a recovery mechanism.
251
281
  `;
252
- const userCommunicationProtocol = `---
253
- id: core.user-communication
254
- version: 1.0.0
255
- priority: core
256
- mandatory: true
257
- ---
258
-
259
- # User Communication
260
-
261
- Only the orchestrator speaks to the user. Lead with outcomes and decisions. Ask only for choices that materially affect scope or result. Plans and final reports include model routing and verification evidence without exposing unnecessary internal chatter.
282
+ const userCommunicationProtocol = `---
283
+ id: core.user-communication
284
+ version: 1.0.0
285
+ priority: core
286
+ mandatory: true
287
+ ---
288
+
289
+ # User Communication
290
+
291
+ Only the orchestrator speaks to the user. Lead with outcomes and decisions. Ask only for choices that materially affect scope or result. Plans and final reports include model routing and verification evidence without exposing unnecessary internal chatter.
262
292
  `;
263
- const orchestratorAgent = `---
264
- name: orchestrator
265
- role: control-plane
266
- writes_product_files: false
267
- control_plane_write_scope: .ai/tasks/**
268
- ---
269
-
270
- # Orchestrator
271
-
272
- Own requirements, decisions, plans, delegation, context packets, monitoring, review synthesis and user communication. Never implement. Use the planning, project-discovery and verification skills. Treat worker claims as untrusted until supported by evidence.
293
+ const openAiProfile = `schema_version: 1
294
+ provider: openai
295
+ defaults:
296
+ orchestrator: gpt-6-astra
297
+ complex_worker: gpt-5.6-sol
298
+ fast_worker: gpt-5.6-luna
273
299
  `;
274
- const explorerAgent = `---
275
- name: explorer
276
- role: read-only-evidence
277
- writes_product_files: false
278
- ---
279
-
280
- # Explorer
281
-
282
- Answer one bounded codebase question with paths, symbols and evidence. Do not modify files. Reuse existing project snapshots and task evidence before searching. Report unknowns and confidence explicitly.
300
+ const claudeProfile = `schema_version: 1
301
+ provider: claude
302
+ defaults:
303
+ orchestrator: fable-5
304
+ complex_worker: opus-5
305
+ fast_worker: sonnet-5
283
306
  `;
284
- const implementerAgent = `---
285
- name: implementer
286
- role: product-change
287
- writes_product_files: true
288
- ---
289
-
290
- # Implementer
291
-
292
- Implement only the assigned objective and owned paths. Read the task packet first, preserve concurrent work, run required checks and return a structured completion packet. Escalate scope changes instead of expanding the task.
307
+ const codexAdapter = `# Codex Adapter
308
+
309
+ - Root entrypoint: \`AGENTS.md\`
310
+ - Canonical profile: \`.ai/model-profiles/openai.yaml\`
311
+ - Prefer explicit task packets over full-history forks.
312
+ - Select worker model tiers only when the host supports per-agent model selection.
313
+ - If configured models or delegation are unavailable, stop and report the capability mismatch.
293
314
  `;
294
- const debuggerAgent = `---
295
- name: debugger
296
- role: root-cause-and-fix
297
- writes_product_files: true
298
- ---
299
-
300
- # Debugger
301
-
302
- Reproduce, narrow the search space, form falsifiable hypotheses, identify root cause, implement the smallest justified fix and prove it. Do not patch symptoms without evidence.
303
- `;
304
- const reviewerAgent = `---
305
- name: reviewer
306
- role: independent-review
307
- writes_product_files: false
308
- ---
309
-
310
- # Reviewer
311
-
312
- Independently compare the approved plan, acceptance criteria, diff and verification evidence. Report actionable findings by severity. Do not approve based only on the implementer's summary and do not modify the implementation.
313
- `;
314
- const planningSkill = `---
315
- name: planning
316
- description: Use for every new user task before implementation begins.
317
- ---
318
-
319
- # Planning
320
-
321
- 1. State the goal and non-goals.
322
- 2. Separate verified facts, assumptions and decisions.
323
- 3. Identify risks and material questions.
324
- 4. Build a dependency-aware task graph with ownership.
325
- 5. Select worker tiers and verification.
326
- 6. Present the plan and wait for user approval.
327
- `;
328
- const projectDiscoverySkill = `---
329
- name: project-discovery
330
- description: Use after manual sync or when a registered project's facts need bounded refresh.
331
- ---
332
-
333
- # Project Discovery
334
-
335
- Read existing AI instructions first. Inspect manifests, lockfiles, README, CI and configuration before source code. Record only evidence-backed languages, frameworks, commands and boundaries. Mark uncertain interpretations as hypotheses. Never invent architecture for an empty project.
336
- `;
337
- const explorationSkill = `---
338
- name: codebase-exploration
339
- description: Use to answer a specific codebase question before planning or delegation.
340
- ---
341
-
342
- # Codebase Exploration
343
-
344
- Start from the project snapshot and existing evidence. Search by symbol and path, not by reading the entire repository. Return relevant files, relationships, conventions, risks and unanswered questions with provenance.
345
- `;
346
- const implementationSkill = `---
347
- name: implementation
348
- description: Use by a worker after an approved plan and task packet exist.
349
- ---
350
-
351
- # Implementation
352
-
353
- Confirm objective, ownership and constraints. Inspect the latest target files, make the smallest coherent change, preserve unrelated work, verify incrementally and return a completion packet. Stop and escalate when scope or assumptions change.
354
- `;
355
- const verificationSkill = `---
356
- name: verification
357
- description: Use before any implementation is reported complete.
358
- ---
359
-
360
- # Verification
361
-
362
- Map each acceptance criterion to evidence. Run focused tests first, then lint/typecheck/build or broader tests according to risk. Record commands, exit status and failures. Distinguish passed, failed and not-run checks.
363
- `;
364
- const debuggingSkill = `---
365
- name: debugging
366
- description: Use for defects, flaky behavior and unexplained failures.
367
- ---
368
-
369
- # Debugging
370
-
371
- Reproduce first. Establish a minimal failing case, rank hypotheses, gather evidence that can disprove each one, locate root cause, add a regression test, implement the smallest fix and rerun relevant verification.
372
- `;
373
- const codeReviewSkill = `---
374
- name: code-review
375
- description: Use for independent review after implementation.
376
- ---
377
-
378
- # Code Review
379
-
380
- Review against the approved task, not personal preference. Inspect the actual diff and surrounding code. Prioritize correctness, regressions, security, concurrency and missing tests. Report precise locations and consequences; state explicitly when no actionable finding exists.
381
- `;
382
- const openAiProfile = `schema_version: 1
383
- provider: openai
384
- defaults:
385
- orchestrator: gpt-6-astra
386
- complex_worker: gpt-5.6-sol
387
- fast_worker: gpt-5.6-luna
388
- `;
389
- const claudeProfile = `schema_version: 1
390
- provider: claude
391
- defaults:
392
- orchestrator: fable-5
393
- complex_worker: opus-5
394
- fast_worker: sonnet-5
395
- `;
396
- const codexAdapter = `# Codex Adapter
397
-
398
- - Root entrypoint: \`AGENTS.md\`
399
- - Canonical profile: \`.ai/model-profiles/openai.yaml\`
400
- - Prefer explicit task packets over full-history forks.
401
- - Select worker model tiers only when the host supports per-agent model selection.
402
- - If configured models or delegation are unavailable, stop and report the capability mismatch.
403
- `;
404
- const claudeAdapter = `# Claude Code Adapter
405
-
406
- - Root entrypoint: \`CLAUDE.md\`
407
- - Canonical profile: \`.ai/model-profiles/claude.yaml\`
408
- - Prefer explicit task packets over copying the full conversation into subagents.
409
- - Select worker model tiers only when the host supports per-agent model selection.
410
- - If configured models or delegation are unavailable, stop and report the capability mismatch.
315
+ const claudeAdapter = `# Claude Code Adapter
316
+
317
+ - Root entrypoint: \`CLAUDE.md\`
318
+ - Canonical profile: \`.ai/model-profiles/claude.yaml\`
319
+ - Prefer explicit task packets over copying the full conversation into subagents.
320
+ - Select worker model tiers only when the host supports per-agent model selection.
321
+ - If configured models or delegation are unavailable, stop and report the capability mismatch.
411
322
  `;
412
323
  const contextPacketSchema = JSON.stringify({
413
324
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -418,9 +329,14 @@ const contextPacketSchema = JSON.stringify({
418
329
  "task_id",
419
330
  "assigned_role",
420
331
  "model_tier",
332
+ "risk_tier",
421
333
  "objective",
422
334
  "scope",
423
335
  "acceptance_criteria",
336
+ "verification_commands",
337
+ "review_required",
338
+ "browser_policy",
339
+ "loaded_skills",
424
340
  "expected_report",
425
341
  ],
426
342
  properties: {
@@ -428,6 +344,10 @@ const contextPacketSchema = JSON.stringify({
428
344
  parent_task_id: { type: ["string", "null"] },
429
345
  assigned_role: { type: "string", minLength: 1 },
430
346
  model_tier: { enum: ["complex_worker", "fast_worker"] },
347
+ risk_tier: { enum: ["trivial", "standard", "high-risk"] },
348
+ review_required: { type: "boolean" },
349
+ browser_policy: { enum: ["disabled", "ask-first", "user-approved"] },
350
+ loaded_skills: { type: "array", items: { type: "string", minLength: 1 } },
431
351
  objective: { type: "string", minLength: 1 },
432
352
  rationale: { type: "string" },
433
353
  scope: {
@@ -455,7 +375,16 @@ const completionPacketSchema = JSON.stringify({
455
375
  title: "Worker Completion Packet",
456
376
  type: "object",
457
377
  additionalProperties: false,
458
- required: ["task_id", "status", "summary", "changed_files", "commands_run", "unresolved_risks"],
378
+ required: [
379
+ "task_id",
380
+ "status",
381
+ "summary",
382
+ "changed_files",
383
+ "commands_run",
384
+ "checks_skipped",
385
+ "loaded_skills",
386
+ "unresolved_risks",
387
+ ],
459
388
  properties: {
460
389
  task_id: { type: "string", minLength: 1 },
461
390
  status: { enum: ["completed", "failed", "needs_context", "blocked"] },
@@ -463,6 +392,8 @@ const completionPacketSchema = JSON.stringify({
463
392
  root_cause: { type: ["string", "null"] },
464
393
  changed_files: { type: "array", items: { type: "string" } },
465
394
  commands_run: { type: "array", items: { type: "object" } },
395
+ checks_skipped: { type: "array", items: { type: "string" } },
396
+ loaded_skills: { type: "array", items: { type: "string", minLength: 1 } },
466
397
  decisions_made: { type: "array", items: { type: "string" } },
467
398
  unresolved_risks: { type: "array", items: { type: "string" } },
468
399
  recommended_context_updates: { type: "array", items: { type: "string" } },