thoth-agents 0.3.11 → 0.3.12

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 (42) hide show
  1. package/README.md +119 -33
  2. package/dist/{chunk-CB3EBA7H.js → chunk-5UBJB5QO.js} +1 -1
  3. package/dist/{chunk-GIUU6FNE.js → chunk-DX4U3AD3.js} +95 -50
  4. package/dist/{chunk-ZEAAWBF2.js → chunk-VPVBYBPU.js} +575 -98
  5. package/dist/cli/codex-plugin-install.d.ts +16 -2
  6. package/dist/cli/index.js +7 -5
  7. package/dist/cli/tui/index.js +2 -2
  8. package/dist/harness/core/agent-pack.d.ts +26 -6
  9. package/dist/harness/core/sdd.d.ts +27 -15
  10. package/dist/harness/writers/codex-plugin-package.d.ts +1 -0
  11. package/dist/index.js +2 -2
  12. package/package.json +4 -4
  13. package/plugin/.claude-plugin/.thoth-agents-plugin-assets.json +2 -2
  14. package/plugin/.claude-plugin/plugin.json +1 -1
  15. package/plugin/.codex-plugin/plugin.json +1 -1
  16. package/plugin/agents/oracle.md +3 -3
  17. package/plugin/agents/orchestrator.md +35 -30
  18. package/plugin/skills/plan-reviewer/SKILL.md +54 -15
  19. package/plugin/skills/thoth-archive/SKILL.md +5 -0
  20. package/plugin/skills/thoth-constitution/SKILL.md +5 -0
  21. package/plugin/skills/thoth-constitution/templates/constitution.md +19 -2
  22. package/plugin/skills/thoth-init/SKILL.md +5 -0
  23. package/plugin/skills/thoth-sdd/SKILL.md +35 -10
  24. package/plugin/skills/thoth-sdd/references/phases/implement.md +13 -2
  25. package/plugin/skills/thoth-sdd/references/phases/tasks.md +23 -2
  26. package/plugin/skills/thoth-sdd/references/phases/verify.md +7 -5
  27. package/plugin/skills/thoth-sdd/scripts/validate.mjs +263 -30
  28. package/plugin/skills/thoth-sdd/templates/tasks.md +18 -2
  29. package/skills/README.md +2 -1
  30. package/skills/plan-reviewer/SKILL.md +54 -15
  31. package/skills/thoth-archive/SKILL.md +5 -0
  32. package/skills/thoth-constitution/SKILL.md +5 -0
  33. package/skills/thoth-constitution/templates/constitution.md +19 -2
  34. package/skills/thoth-init/SKILL.md +5 -0
  35. package/skills/thoth-sdd/SKILL.md +35 -10
  36. package/skills/thoth-sdd/references/phases/implement.md +13 -2
  37. package/skills/thoth-sdd/references/phases/tasks.md +23 -2
  38. package/skills/thoth-sdd/references/phases/verify.md +7 -5
  39. package/skills/thoth-sdd/scripts/validate.mjs +263 -30
  40. package/skills/thoth-sdd/templates/tasks.md +18 -2
  41. package/.agents/plugins/marketplace.json +0 -20
  42. package/.claude-plugin/marketplace.json +0 -21
package/README.md CHANGED
@@ -22,10 +22,13 @@ parallelism creates a net gain.
22
22
 
23
23
  The plugin ships the seven-role contract and thoth-owned SDD
24
24
  contracts that combine Spec Kit-grade traceability with OpenSpec-style durable
25
- deltas. Accelerated planning fast-forwards without routine pauses; structural
26
- `ready`/`closeout` gates and independent oracle review retain rigor. Root
27
- recommends Direct, Accelerated, or Full and the user selects the route. After
28
- `ready`, artifact-backed routes offer optional Oracle plan review or proceeding
25
+ deltas. The root shapes substantive work into dependency-aware, conflict-free
26
+ native waves and joins terminal native results before dependent synthesis.
27
+ Accelerated planning fast-forwards without routine pauses; structural
28
+ `ready`/`closeout` gates and proportional independent review retain rigor. Root
29
+ recommends Direct, Accelerated, or Full after summarizing context; explicit
30
+ answers win and the third answerless route question selects the recommendation.
31
+ After `ready`, artifact-backed routes offer optional Oracle plan review or proceeding
29
32
  without it; every final verification remains mandatory. During
30
33
  installation, the CLI obtains four mandatory external skills
31
34
  from their canonical repositories with `npx skills add` and invokes the official
@@ -41,8 +44,9 @@ before the CLI installs external skills and requests provider-owned thoth-mem
41
44
  setup.
42
45
 
43
46
  Runtime guarantees still differ by harness. OpenCode is the default and most
44
- integrated path; Codex and Claude preserve their own trust, policy, plugin-cache,
45
- and permission semantics.
47
+ integrated path; Codex and Claude preserve their own trust, policy, normal
48
+ plugin-cache, and permission semantics. Codex installation has one bounded
49
+ legacy-cache cleanup contract described below; Claude does not.
46
50
 
47
51
  ## Install
48
52
 
@@ -78,15 +82,23 @@ directly from the globally installed `thoth-sdd` skill; any legacy project
78
82
 
79
83
  ### Codex
80
84
 
81
- Preview, then run the combined native-plugin and global-layer installer:
85
+ Close Codex, preview, then run the combined native-plugin and global-layer
86
+ installer:
82
87
 
83
88
  ```bash
84
89
  npx thoth-agents@latest install --agent=codex --dry-run
85
90
  npx thoth-agents@latest install --agent=codex
86
91
  ```
87
92
 
88
- The CLI first uses Codex's native manager to register `EremesNG/thoth-agents`
89
- and install or enable `thoth-agents@thoth-agents`. It then writes the
93
+ The CLI first uses Codex's native manager to register
94
+ `https://github.com/EremesNG/thoth-plugins.git` as `thoth-plugins` and install
95
+ or enable the executing version of `thoth-agents@thoth-plugins`. After that
96
+ verification it removes only registered legacy IDs
97
+ `thoth-agents@thoth-agents` and `thoth-agents@thoth-agents-codex`, their two
98
+ marketplaces, and any still-orphaned exact thoth-agents roots that pass bounded
99
+ path/provenance checks. It never deletes sibling or discovered paths. A lock or
100
+ race retains the central plugin and asks you to keep Codex closed and retry;
101
+ restart activates state but does not garbage-collect caches. The CLI then writes the
90
102
  orchestrator block to `~/.codex/AGENTS.md`, creates six custom-agent TOMLs under
91
103
  `~/.codex/agents/`, merges the managed feature into `~/.codex/config.toml`,
92
104
  installs the external skills, and invokes provider-owned thoth-mem setup.
@@ -104,16 +116,61 @@ into the repository.
104
116
  Review `/plugins` and `/hooks` after installation. Codex trust and
105
117
  higher-precedence instructions remain in force.
106
118
 
119
+ #### Local Codex development
120
+
121
+ Keep a personal marketplace entry in `~/.agents/plugins/marketplace.json`
122
+ pointed at `./plugins/thoth-agents` relative to the home marketplace root:
123
+
124
+ ```json
125
+ {
126
+ "name": "personal",
127
+ "plugins": [
128
+ {
129
+ "name": "thoth-agents",
130
+ "source": {
131
+ "source": "local",
132
+ "path": "./plugins/thoth-agents"
133
+ },
134
+ "policy": {
135
+ "installation": "AVAILABLE",
136
+ "authentication": "ON_INSTALL"
137
+ },
138
+ "category": "Productivity"
139
+ }
140
+ ]
141
+ }
142
+ ```
143
+
144
+ Then build and synchronize both required Codex layers from this checkout:
145
+
146
+ ```bash
147
+ pnpm run setup:codex:local
148
+ ```
149
+
150
+ The command replaces `~/plugins/thoth-agents` through a staged local copy,
151
+ cache-busts the copied Codex and Claude manifest versions, and refreshes the
152
+ managed global Codex root block, six standalone role TOMLs, model state, and
153
+ feature configuration. It preserves the marketplace file and user model
154
+ overrides. It does not install or remove plugins, install external skills, or
155
+ invoke thoth-mem setup. Select the personal plugin in Codex and restart it after
156
+ each synchronization. The command rejects a state where both
157
+ `thoth-agents@thoth-plugins` and `thoth-agents@personal` are enabled.
158
+
107
159
  ### Claude Code
108
160
 
109
161
  Claude requires its two native marketplace steps before the plugin can expose
110
162
  agents or skills:
111
163
 
112
164
  ```bash
113
- claude plugin marketplace add EremesNG/thoth-agents --scope user
114
- claude plugin install thoth-agents@thoth-agents --scope user
165
+ claude plugin marketplace add https://github.com/EremesNG/thoth-plugins.git --scope user
166
+ claude plugin install thoth-agents@thoth-plugins --scope user
115
167
  ```
116
168
 
169
+ The shared catalog name is `thoth-plugins`. Existing bare or host-specific
170
+ thoth-agents marketplace identities remain manager-owned and are not removed
171
+ automatically; rerunning the current installer adds the central identity and
172
+ preserves legacy entries without updating or uninstalling them.
173
+
117
174
  Then install the mandatory external skills and invoke provider-owned thoth-mem
118
175
  setup:
119
176
 
@@ -193,7 +250,8 @@ correctness-critical work.
193
250
  <br>
194
251
  <i>Authoritative external research.</i>
195
252
  <br><br>
196
- Gathers current authoritative external evidence and labels inference.
253
+ Gathers current, unfamiliar, version-sensitive, or externally sourced
254
+ evidence and labels inference; stable local facts do not trigger research.
197
255
  <br><br>
198
256
  <b>Mode:</b> <code>read-only</code>
199
257
  </td>
@@ -210,8 +268,8 @@ correctness-critical work.
210
268
  <br>
211
269
  <i>Independent analysis and verification.</i>
212
270
  <br><br>
213
- Reviews plans when the user requests it and independently verifies every
214
- implementation.
271
+ Reviews explicitly or bounded-default selected plans and independently verifies material
272
+ risk plus every Accelerated or Full final implementation.
215
273
  <br><br>
216
274
  <b>Mode:</b> <code>read-only</code>
217
275
  </td>
@@ -230,7 +288,8 @@ correctness-critical work.
230
288
  <br>
231
289
  <i>UI/UX ownership and visual quality.</i>
232
290
  <br><br>
233
- Owns UI/UX choices, implementation, and visual verification.
291
+ Owns material UI/UX, interaction, accessibility, implementation, and visual
292
+ verification.
234
293
  <br><br>
235
294
  <b>Mode:</b> <code>write-capable</code>
236
295
  </td>
@@ -247,7 +306,8 @@ correctness-critical work.
247
306
  <br>
248
307
  <i>Fast bounded implementation.</i>
249
308
  <br><br>
250
- Makes narrow, clear, low-risk edits within an explicit surface.
309
+ Makes known narrow, clear, low-risk edits within an isolated explicit
310
+ surface.
251
311
  <br><br>
252
312
  <b>Mode:</b> <code>write-capable</code>
253
313
  </td>
@@ -273,9 +333,13 @@ correctness-critical work.
273
333
  </table>
274
334
 
275
335
  Children do not delegate. Each mutable surface has one writer. Parallel work is
276
- limited to independent surfaces. The implementation writer never reviews or
277
- approves its own result: `oracle` owns every `verify`, including Direct and
278
- Accelerated work.
336
+ limited to independent surfaces. The root marks input-ready lanes ready and
337
+ upstream-dependent lanes blocked, dispatches every ready conflict-free lane in a
338
+ native wave before waiting, and fans in only terminal native results. Every route
339
+ verifies: trivial deterministic Direct work may use focused root checks; material
340
+ risk in Direct and every Accelerated or Full final verify require a fresh
341
+ read-only `oracle`. The implementation writer never reviews or approves its own
342
+ result.
279
343
 
280
344
  ## SDD routes
281
345
 
@@ -287,28 +351,37 @@ Full: explore -> specify -> plan -> tasks -> implement -> verify -> archi
287
351
 
288
352
  | Route | Use when | Artifacts |
289
353
  | --- | --- | --- |
290
- | Direct | Clear, bounded, low-risk work, including multi-file documentation/mechanical edits | None; oracle returns its verdict in-session. |
354
+ | Direct | Clear, bounded, low-risk work, including multi-file documentation/mechanical edits | None; focused root checks cover trivial deterministic work, while material risk requires a fresh Oracle. |
291
355
  | Accelerated | Generic SDD request, partial clarity, moderate risk, multi-surface behavior, or architecture | Canonical artifacts with fast-forward specification/planning/tasks. |
292
356
  | Full | Material uncertainty, cross-cutting behavior/architecture, high contract risk, or high failure cost | Accelerated artifacts plus exploration and separate planning gates. |
293
357
 
294
358
  The root loads only the current phase contract from the bundled `thoth-sdd`
295
359
  skill. It owns specification, clarification, planning, requirements checklists,
296
360
  task decomposition, convergence, report persistence, and archive. `explorer`
297
- owns Full discovery; `oracle` owns user-selected plan review and every `verify`.
361
+ owns broad or uncertain Full discovery; `oracle` owns explicitly or
362
+ bounded-default selected plan review, plus final
363
+ verification gates that require independent judgment.
298
364
 
299
365
  An explicitly named route is the user's selection and wins. Otherwise root
300
- recommends one of all three routes and waits for the user's choice. A generic
301
- request to use SDD sets Accelerated as the minimum recommendation. Accelerated
302
- writes `spec.md -> plan.md -> tasks.md` in one uninterrupted root pass and does
303
- not pause for routine approval between those planning phases.
366
+ summarizes the relevant context, scope, clarity, risk, and why one of the three
367
+ routes is recommended before asking. Any explicit answer wins. After at most
368
+ three total answerless native results, the third selects the recommended route.
369
+ A generic request to use SDD sets Accelerated as the minimum recommendation.
370
+ Accelerated writes `spec.md -> plan.md -> tasks.md` in one uninterrupted root
371
+ pass and does not pause for routine approval between those planning phases.
304
372
 
305
373
  Conditional phases remain deliberately narrow:
306
374
 
307
375
  - `clarify` runs only for a material ambiguity and updates canonical `spec.md`;
308
376
  - `checklist` audits high-risk requirement quality with `CHK###` taxonomy and a
309
377
  separate revalidation pass;
310
- - `plan-review` is offered after `ready` on Accelerated and Full; the user chooses
311
- `Review plan with Oracle (Recommended)` or `Proceed without review`;
378
+ - `plan-review` is offered after `ready` on Accelerated and Full; any explicit
379
+ answer wins, while the third answerless result selects
380
+ `Review plan with Oracle (Recommended)`. Same-intent rejections are repaired
381
+ and revalidated before fresh Oracle rounds until approval or a material human
382
+ blocker. After approval, root summarizes the plan before asking
383
+ `Implement (Recommended)` or `Stop`; the third answerless result selects
384
+ implementation, while an explicit answer always wins;
312
385
  - `converge` appends tasks only after failed artifact-backed verification; and
313
386
  - `architectural-grilling` runs before specification only when explicitly
314
387
  requested or a material human-owned decision remains unresolved.
@@ -323,6 +396,16 @@ Handled failures roll back within the active process; forced process or OS
323
396
  termination is not crash-atomic. See
324
397
  [SDD Pipeline](docs/sdd-pipeline.md).
325
398
 
399
+ The role decision is semantic and route-independent: `librarian` handles current
400
+ or external facts (for example, checking the current official API), `designer`
401
+ handles material user-facing UI/UX or accessibility, and `quick` handles a known
402
+ narrow low-risk isolated edit. `deep` handles coupled or high-risk work, while
403
+ `explorer` handles broad local uncertainty. Native harness execution and
404
+ lifecycle are the sole authority for role selection, fan-out/fan-in,
405
+ status/wait, steering, cancellation, and terminal results; an unavailable
406
+ primitive is reported and followed by a truthful sequential fallback. No
407
+ additional thoth coordination mechanism is involved.
408
+
326
409
  ## Skills
327
410
 
328
411
  Every harness package includes the workflow contracts owned by thoth-agents:
@@ -362,10 +445,11 @@ diagnostics, manual actions, and receipt paths remain visible for recovery.
362
445
  | Codex | The CLI installs the native plugin and manages global `AGENTS.md`, six agent TOMLs, config, external skills, and thoth-mem setup; `$thoth-init` only initializes per-repository SDD governance. Runtime role matching and some permissions remain instruction-level. |
363
446
  | Claude Code | Run both native marketplace commands before the CLI installs external skills and requests thoth-mem setup. The native manager owns cache files; fine-grained path restrictions remain instruction-level. |
364
447
 
365
- Codex and Claude marketplace manifests are versioned in
366
- `.agents/plugins/marketplace.json` and `.claude-plugin/marketplace.json`. The
367
- two catalogs resolve to the same generated `plugin/` bundle. Build and npm
368
- version lifecycle commands keep that shared bundle synchronized.
448
+ Codex and Claude marketplace manifests are versioned in the separate
449
+ `EremesNG/thoth-plugins` repository. Both central entries resolve to this
450
+ repository's generated `plugin/` bundle at an immutable version tag. Build and
451
+ npm version lifecycle commands keep that bundle synchronized; release commands
452
+ publish only the new thoth-agents pin after the product tag is visible remotely.
369
453
 
370
454
  ## Models and provider boundaries
371
455
 
@@ -429,8 +513,10 @@ edit, preview and apply remain limited to the dirty roles. In OpenCode, both
429
513
  `Apply` and `Apply changes` materialize the complete effective roster and
430
514
  activate the named `agents` preset.
431
515
 
432
- It does not bypass native marketplace trust or edit manager-owned caches
433
- directly; Codex and Claude own their native manager mutations.
516
+ It does not bypass native marketplace trust. Codex and Claude own normal native
517
+ manager mutations; the Codex installer additionally owns only the fixed,
518
+ twice-validated thoth-agents legacy-root fallback. Claude cache state is never
519
+ edited directly.
434
520
 
435
521
  ## Documentation
436
522
 
@@ -16,7 +16,7 @@ import {
16
16
  loadAgentPrompt,
17
17
  renderAgentRoutingDescription,
18
18
  renderRolePrompt
19
- } from "./chunk-GIUU6FNE.js";
19
+ } from "./chunk-DX4U3AD3.js";
20
20
 
21
21
  // src/agents/deep.ts
22
22
  var DEEP_PROMPT = renderRolePrompt(
@@ -743,24 +743,27 @@ var AGENT_ROLES = [
743
743
  dispatch: "root-coordinator",
744
744
  canMutateWorkspace: true,
745
745
  scope: "requirements, SDD coordination, routing, bounded implementation, decisions, and synthesis",
746
- responsibility: "Keep requirements, decisions, sequential SDD coordination, and final synthesis in the root thread; evaluate implementation ownership independently in every route and implement directly or delegate according to explicit user direction and demonstrated net gain.",
746
+ responsibility: "Keep requirements, decisions, sequential SDD coordination, and final synthesis in the root thread; evaluate implementation ownership independently in every route, implement directly or delegate by demonstrated net gain, and run focused verification for trivial deterministic Direct work.",
747
747
  useWhen: [
748
748
  "Coordinate requirements, governed artifacts, routing, and synthesis.",
749
749
  "Implement an accepted mutable surface in any route when accumulated context and continuity outweigh delegation overhead."
750
750
  ],
751
- doNotUseWhen: ["Not for independent plan review or final verification."],
751
+ doNotUseWhen: [
752
+ "Not for independent plan review or Oracle-required final verification."
753
+ ],
752
754
  escalateWhen: [
753
755
  "Delegate implementation when specialization, context isolation, or independent bounded work creates a demonstrated net gain; then select designer, quick, or deep by task shape."
754
756
  ],
755
757
  toolGovernance: [
756
- "may inspect and edit the accepted bounded implementation surface in every route, but every verification is delegated to oracle",
758
+ "may inspect and edit the accepted bounded implementation surface in every route and may verify trivial deterministic Direct work without self-approval",
757
759
  "loads the matching thoth-sdd phase contract on demand instead of carrying every phase protocol in its prompt",
758
760
  "owns governed coordination writes under openspec/ and uses append-only tasks.md updates during convergence",
759
761
  "delegates independent or specialist work only when it produces a net gain",
760
762
  "keeps requirements, decisions, and final synthesis in the root thread"
761
763
  ],
762
764
  verification: [
763
- "delegates selected plan-review and every verify phase to oracle; plan review stays optional and final verification stays mandatory",
765
+ "runs focused checks for trivial deterministic Direct work while final verification remains mandatory",
766
+ "delegates selected plan review plus Accelerated, Full, and material-risk Direct final verification to a fresh oracle",
764
767
  "consolidates summarized evidence returned by child agents"
765
768
  ]
766
769
  },
@@ -804,9 +807,9 @@ var AGENT_ROLES = [
804
807
  dispatch: "synchronous-task-only",
805
808
  canMutateWorkspace: false,
806
809
  scope: "diagnosis, architecture, optional plan review, and independent verification",
807
- responsibility: "Independently review plans when the user requests it and perform every implementation verification, exposing correctness risks and judging whether results satisfy their contracts.",
810
+ responsibility: "Independently review plans when the user requests it and provide independent judgment for artifact-backed or material-risk final verification, exposing correctness risks and judging whether results satisfy their contracts.",
808
811
  useWhen: [
809
- "Selected plan review, diagnosis, or final verification needs independent judgment."
812
+ "Selected plan review, persistent diagnosis, material architecture or security risk, contradictory evidence, high failure cost, or artifact-backed final verification needs independent judgment."
810
813
  ],
811
814
  doNotUseWhen: [
812
815
  "Not for implementation, mutation, persistence, or self-review."
@@ -909,6 +912,34 @@ var ORCHESTRATION_POLICY = {
909
912
  "cheaper model price without end-to-end evidence"
910
913
  ]
911
914
  },
915
+ taskShaping: {
916
+ steps: [
917
+ "bound-work",
918
+ "map-dependencies",
919
+ "assign-ownership",
920
+ "select-specialists",
921
+ "mark-ready-and-blocked",
922
+ "dispatch-ready-wave",
923
+ "wait-for-terminal-evidence",
924
+ "reconcile-and-verify"
925
+ ],
926
+ nativeAuthority: true,
927
+ boundedWidth: true,
928
+ decisions: {
929
+ dependency: "block a lane until every concrete upstream output exists",
930
+ ownershipConflict: "serialize overlapping mutable surfaces or assign one writer",
931
+ readyWave: "dispatch all independent conflict-free ready lanes before waiting",
932
+ terminalEvidence: "silence, timeout, and malformed status remain nonterminal",
933
+ degradation: "report an unavailable native primitive and use a truthful sequential fallback"
934
+ }
935
+ },
936
+ specialistDirectory: AGENT_ROLES.filter(
937
+ (role) => role.name !== "orchestrator"
938
+ ).map((role) => ({
939
+ role: role.name,
940
+ selectWhen: role.useWhen.join(" "),
941
+ rejectWhen: role.doNotUseWhen.join(" ")
942
+ })),
912
943
  rules: [
913
944
  "Direct, Accelerated, Full, and no-artifact execution govern artifacts and gates, not implementation ownership.",
914
945
  "Root or a specialist may implement in every route; delegate only when specialization, context isolation, independent bounded work, or safe parallelism creates a demonstrated quality, latency, or total-cost net gain.",
@@ -919,6 +950,7 @@ var ORCHESTRATION_POLICY = {
919
950
  "A fresh subagent instance is the default when the objective, SDD phase, mutable surface, or independent judgment changes.",
920
951
  "Continue an existing subagent only to steer, complete, or clarify the same bounded assignment; completed agents are not a reusable role pool.",
921
952
  "Every Oracle plan review, verification round, and approval or PASS judgment uses a fresh Oracle instance; reuse is limited to clarifying current findings.",
953
+ "Final verification is mandatory: root owns trivial deterministic Direct checks; a fresh Oracle owns Accelerated, Full, and material-risk Direct judgment.",
922
954
  "Wait and status operations collect only the active nonterminal assignment and do not authorize later reuse.",
923
955
  "Child agents return distilled evidence instead of raw logs or file dumps."
924
956
  ]
@@ -991,6 +1023,16 @@ function getAgentPackContract() {
991
1023
  ...AGENT_PACK_CONTRACT.orchestrationPolicy.implementationOwnership.insufficientSignals
992
1024
  ]
993
1025
  },
1026
+ taskShaping: {
1027
+ ...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping,
1028
+ steps: [...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping.steps],
1029
+ decisions: {
1030
+ ...AGENT_PACK_CONTRACT.orchestrationPolicy.taskShaping.decisions
1031
+ }
1032
+ },
1033
+ specialistDirectory: AGENT_PACK_CONTRACT.orchestrationPolicy.specialistDirectory.map(
1034
+ (decision) => ({ ...decision })
1035
+ ),
994
1036
  rules: [...AGENT_PACK_CONTRACT.orchestrationPolicy.rules]
995
1037
  },
996
1038
  returnContract: [...AGENT_PACK_CONTRACT.returnContract],
@@ -1260,8 +1302,8 @@ var SDD_PHASES = [
1260
1302
  producesArtifact: true,
1261
1303
  defaultAgentRole: "oracle",
1262
1304
  eligibleAgentRoles: ["oracle"],
1263
- reason: "Offer independent blocker-only plan review when the user selects it after planning passes ready.",
1264
- condition: "Activate only after ready when the user chooses Review plan with Oracle (Recommended)."
1305
+ reason: "Offer independent blocker-only plan review after explicit or bounded recommended-default selection once planning passes ready.",
1306
+ condition: "Activate after ready when review is selected explicitly or by the bounded recommended default after three answerless attempts."
1265
1307
  },
1266
1308
  {
1267
1309
  id: "implement",
@@ -1283,9 +1325,9 @@ var SDD_PHASES = [
1283
1325
  activation: "required",
1284
1326
  prerequisites: ["implement"],
1285
1327
  producesArtifact: true,
1286
- defaultAgentRole: "oracle",
1287
- eligibleAgentRoles: ["oracle"],
1288
- reason: "Independently judge the result against requirements, contracts, and focused checks."
1328
+ defaultAgentRole: "adaptive-verification",
1329
+ eligibleAgentRoles: ["orchestrator", "oracle"],
1330
+ reason: "Keep verification mandatory while selecting root for trivial deterministic Direct checks and a fresh Oracle for material-risk Direct or artifact-backed judgment."
1289
1331
  },
1290
1332
  {
1291
1333
  id: "converge",
@@ -1347,25 +1389,25 @@ var SDD_WORKFLOW_CONTRACT = {
1347
1389
  validationGates: [...policy.validationGates]
1348
1390
  })),
1349
1391
  routingRules: [
1350
- "The root recommends direct, accelerated, or full from risk evidence, but the user selects the route; an explicitly requested route already counts as selection.",
1392
+ "The root summarizes context and recommends direct, accelerated, or full from risk evidence; an explicit answer wins, while the third answerless route question selects the displayed recommendation, and an explicitly requested route already counts as selection.",
1351
1393
  "Direct work is the default for clear, bounded, low-risk changes; documentation and mechanical work may remain direct across multiple files.",
1352
1394
  "Accelerated SDD is used for multi-surface behavior, architecture, partial clarity, moderate risk, or broad non-behavioral coordination.",
1353
- "Accelerated planning fast-forwards specify, plan, and tasks without pauses between those artifacts, then offers the user optional oracle plan review after ready.",
1395
+ "Accelerated planning fast-forwards specify, plan, and tasks without pauses between those artifacts, then offers optional oracle plan review after ready; an explicit answer wins and the third answerless review question selects Review plan with Oracle (Recommended).",
1354
1396
  "Full SDD is used for unresolved scope, cross-cutting behavior or architecture, high contract risk, or high failure cost.",
1355
1397
  "Use architectural-grilling before specification only when the user explicitly requests it or material product or architecture decisions remain human-owned and unresolved; never require it merely because the route is Full.",
1356
- "Route selection and the post-ready plan-review choice are explicit user decisions; other input is requested only when a material unresolved decision changes the result."
1398
+ "Route selection and the post-ready plan-review choice resolve through an explicit answer or their bounded recommended fallback; other input is requested only when a material unresolved decision changes the result."
1357
1399
  ],
1358
1400
  artifactRules: [
1359
1401
  "Spec Kit artifact semantics are preserved inside the governed openspec store.",
1360
1402
  "Accelerated and full routes require spec.md, plan.md, tasks.md, verify-report.md, and archive-report.md.",
1361
1403
  "Research, data model, contracts, quickstart, requirements checklist, and plan-review.md are optional and created only when useful or selected.",
1362
- "The adaptive root writes coordination artifacts after loading the matching bundled phase contract; Accelerated and Full implementation selects designer, quick, or deep, while Direct permits one isolated low-risk root micro-action.",
1404
+ "The adaptive root writes coordination artifacts after loading the matching bundled phase contract; every route selects root, designer, quick, or deep from task shape, explicit direction, and demonstrated net gain.",
1363
1405
  "After oracle PASS, archive transactionally synchronizes only explicitly declared durable ADDED, MODIFIED, REMOVED, and RENAMED requirement deltas into openspec/specs; INTERNAL requirements and undeclared prose never update permanent specifications.",
1364
1406
  "Archive stages and backs up writes so handled failures roll back within the active process; forced process or operating-system termination is not crash-atomic."
1365
1407
  ],
1366
1408
  verificationRules: [
1367
- "Every route delegates focused verification to read-only oracle; the implementation writer never verifies its own work.",
1368
- "Accelerated and Full offer read-only oracle plan review after ready; it runs only when the user selects it and never replaces final verification.",
1409
+ "Every route requires final verification; trivial deterministic Direct checks are root-owned, while materially risky Direct and every Accelerated or Full final verification use a fresh read-only oracle, and no implementation writer self-approves.",
1410
+ "Accelerated and Full offer read-only oracle plan review after ready; it runs when selected explicitly or by the bounded recommended fallback and never replaces final verification.",
1369
1411
  "Accelerated and full verification persists verify-report.md with a pass or fail verdict and requirement compliance matrix.",
1370
1412
  "An artifact-backed fail verdict routes through append-only convergence, implementation, and verification again; direct work returns straight to implementation.",
1371
1413
  "A pass verdict is required before accelerated or full work can archive."
@@ -1508,12 +1550,20 @@ function renderImplementationOwnershipPolicy(policy) {
1508
1550
  - Only after deciding delegation creates net gain: use ${roleTemplate("designer")} for UI/UX, ${roleTemplate("quick")} for known narrow low-risk work, and ${roleTemplate("deep")} for coupled or high-risk work.
1509
1551
  </implementation-ownership>`;
1510
1552
  }
1511
- function renderRoleDirectory() {
1512
- return [
1513
- `- ${roleTemplate("explorer")}: uncertain local discovery; read-only.`,
1514
- `- ${roleTemplate("librarian")}: external evidence; read-only.`,
1515
- `- ${roleTemplate("oracle")}: review/verify; read-only, never implementer.`
1516
- ].join("\n");
1553
+ function renderRoleDirectory(directory) {
1554
+ return directory.map(
1555
+ ({ role, selectWhen, rejectWhen }) => `- ${roleTemplate(role)}: Select when ${selectWhen} Reject when ${rejectWhen}`
1556
+ ).join("\n");
1557
+ }
1558
+ function renderTaskShapingPolicy(policy) {
1559
+ return `<task-shaping>
1560
+ ${policy.steps.join(" -> ")}
1561
+ - ${policy.decisions.dependency}; bind each lane to output, mutable ownership, specialist fit, and verification input.
1562
+ - ${policy.decisions.ownershipConflict}; avoid duplicate evidence work.
1563
+ - ${policy.decisions.readyWave} through \`{{backgroundDelegationTool}}\` within native capacity, then use \`{{backgroundStatusTool}}\`.
1564
+ - Fan in only from {{lifecycleTerminalState}}; {{lifecycleNonterminalState}}, ${policy.decisions.terminalEvidence}.
1565
+ - Reconcile against intent, dependencies, ownership, conflicts, and verification before synthesis; native execution remains authoritative; ${policy.decisions.degradation}.
1566
+ </task-shaping>`;
1517
1567
  }
1518
1568
  function createOrchestratorPromptSections() {
1519
1569
  const workflow = getSddWorkflowContract();
@@ -1526,7 +1576,7 @@ You are the adaptive root for thoth-agents. Keep requirements, decisions, owners
1526
1576
  </role>
1527
1577
 
1528
1578
  <operating-model>
1529
- - Handle bounded implementation directly in any route when continuity outweighs delegation overhead; never self-verify.
1579
+ - Handle bounded implementation directly in any route when continuity outweighs delegation overhead; never self-approve.
1530
1580
  - The maximum delegation depth is ${policy.maxDelegationDepth}; children never delegate.
1531
1581
  - Keep one writer per mutable surface; parallelize only non-overlapping work.
1532
1582
  - Keep prompts bounded; request distilled evidence, not raw logs or full files.
@@ -1544,51 +1594,46 @@ You are the adaptive root for thoth-agents. Keep requirements, decisions, owners
1544
1594
  </delegation-lifecycle>
1545
1595
 
1546
1596
  <routing>
1547
- ${renderRoleDirectory()}
1597
+ ${renderRoleDirectory(policy.specialistDirectory)}
1548
1598
  </routing>
1549
1599
 
1550
1600
  ${renderImplementationOwnershipPolicy(policy.implementationOwnership)}
1551
1601
 
1602
+ ${renderTaskShapingPolicy(policy.taskShaping)}
1603
+
1552
1604
  <sdd-routing>
1553
- - An explicitly requested route wins: no duplicate route-selection prompt. Otherwise assess and recommend one route, ask with \`{{userQuestionTool}}\`, and wait for the user to select Direct, Accelerated, or Full. The recommendation is not the decision. The user's selected route wins; explain risk without overriding it. A generic SDD request sets Accelerated as the minimum unless Full risk applies.
1554
- - Direct: clear, bounded, low-risk work. ${renderSddRoute("direct")}.
1555
- - Documentation or mechanical work may remain Direct across multiple files when it is clear and low risk.
1556
- - Accelerated SDD: multi-surface behavior, architecture, partial clarity, or moderate risk. ${renderSddRoute("accelerated")}.
1557
- - For Accelerated, run specify -> plan -> tasks in one uninterrupted root pass. Do not pause between those planning artifacts; ask only for a material unresolved decision.
1558
- - Its thoth-sdd validator gates are ${accelerated.validationGates.join(" -> ")}; optional artifacts are off by default.
1559
- - Full SDD: uncertain scope, cross-cutting behavior or architecture, high contract risk, or high failure cost. ${renderSddRoute("full")}.
1560
- - Full gates are ${full.validationGates.join(" -> ")}; checklist remains conditional.
1561
- - After \`ready\` on Accelerated/Full, ask with \`{{userQuestionTool}}\`: \`Review plan with Oracle (Recommended)\` or \`Proceed without review\`. Skipping plan review means no pre-implementation Oracle review. If selected, load \`plan-reviewer\`, delegate read-only review, and accept only \`[OKAY]\` or \`[REJECT]\` with at most 3 actionable blockers. After \`[OKAY]\`, summarize and ask whether to implement or stop. Plan review never replaces mandatory final Oracle verify.
1605
+ - An explicitly requested route wins: no duplicate route-selection prompt. Otherwise assess and recommend one route; summarize the relevant request context, assessed scope, clarity, risk, and why the recommendation fits before asking with \`{{userQuestionTool}}\` for Direct, Accelerated, or Full. On an answerless result, make at most three total attempts. After the third answerless result, treat the recommended route as selected. Any explicit user answer wins. A generic SDD request sets Accelerated as the minimum unless Full risk applies.
1606
+ - Direct is clear, bounded, low-risk: ${renderSddRoute("direct")}. Documentation or mechanical work may remain Direct across multiple files when clear and low risk.
1607
+ - Accelerated SDD covers multi-surface behavior, architecture, partial clarity, or moderate risk: ${renderSddRoute("accelerated")}; run specify -> plan -> tasks in one uninterrupted root pass. Do not pause between those planning artifacts except for a material unresolved decision. Gates: ${accelerated.validationGates.join(" -> ")}.
1608
+ - Full SDD covers uncertainty, cross-cutting behavior/architecture, high contract risk, or high failure cost: ${renderSddRoute("full")}. Gates: ${full.validationGates.join(" -> ")}; checklist conditional.
1609
+ - After \`ready\` on Accelerated/Full, ask with \`{{userQuestionTool}}\`: \`Review plan with Oracle (Recommended)\` or \`Proceed without review\`. Any explicit \`Proceed without review\` answer wins. If the review question returns answerless, retry to that limit. After the third answerless result, treat \`Review plan with Oracle (Recommended)\` as selected. For review, load \`plan-reviewer\`; accept only \`[OKAY]\`/\`[REJECT]\` with at most 3 actionable blockers. On \`[REJECT]\`, repair same-intent planning artifacts, revalidate affected gates, and use fresh Oracle rounds until \`[OKAY]\` or a human-owned blocker. On \`[OKAY]\`, summarize the approved scope, approach, ownership, verification, and material risks before asking with \`{{userQuestionTool}}\`: \`Implement (Recommended)\` or \`Stop\`. Reuse the answerless limit. After the third answerless result, treat implementation as selected. Any explicit \`Stop\` answer wins; \`[OKAY]\` alone does not authorize implementation. Plan review never replaces mandatory final Oracle verify.
1610
+ - Bounded fallbacks are only for route, plan-review, and implementation questions; never for secrets, destructive/security-sensitive actions, or material human-owned decisions.
1562
1611
  - Happy path: verify -> archive. Artifact-backed failure loop: verify fail -> converge -> implement -> verify. Direct failure loop: verify fail -> implement -> verify.
1563
- - Conditional phases: clarify for material ambiguity; checklist for requirement risk; plan-review by user choice; converge for verification defects.
1564
- - When implementation discoveries refine the same intent, update the canonical artifact and revalidate only affected downstream artifacts. Split a new change when the intent changes.
1565
- - Load the bundled \`thoth-sdd\` skill only after selecting Accelerated or Full, then read only the reference for the current phase.
1566
- - Root owns specify, clarify, plan, checklist, tasks, converge, and archive coordination; these phases are not delegated merely to change prompts.
1567
- - Record owner, net-gain rationale, surface, requirements, and checks before implement or dispatch.
1568
- - Delegate each user-selected plan review and every verify phase to ${roleTemplate("oracle")}. The implementation writer must never review itself.
1612
+ - Same-intent discoveries update the artifact and revalidate only affected downstream artifacts; new intent starts a change.
1613
+ - After Accelerated/Full selection, load the bundled \`thoth-sdd\` skill and read only the reference for the current phase. Run thoth-sdd validator. Root owns specify, clarify, plan, checklist, tasks, converge, and archive; do not delegate just to change prompts. Record owner, rationale, surface, requirements, and checks before implementation.
1614
+ - Final verification is mandatory. Use a fresh ${roleTemplate("oracle")} for Accelerated/Full and materially risky Direct work. Root may run focused verification only for trivial deterministic Direct work; no implementation writer may approve its own work.
1569
1615
  </sdd-routing>
1570
1616
 
1571
1617
  <external-skills>
1572
1618
  - Use bundled \`thoth-constitution\` for constitution lifecycle and \`thoth-archive\` for verified artifact-backed closeout.
1573
1619
  - Use the installed mandatory \`tdd\` skill for behavior changes and \`simplify\` after implementation without changing behavior.
1574
- - During an SDD, never invoke the thoth-agents CLI, \`npx skills add\`, or a network fetch. A missing local contract means incomplete installation.
1620
+ - During SDD, never invoke the thoth-agents CLI, \`npx skills add\`, or network; a missing contract means incomplete installation.
1575
1621
  - Use progressive-context-router only for repository instruction or context-router work.
1576
1622
  - Use architectural-grilling before specification only when the user explicitly asks to be grilled or material human-owned product or architecture decisions remain unresolved.
1577
- - Do not invoke it merely because the route is Full. While grilling, ask one material question per turn and await explicit closure.
1578
- - Feed accepted decisions forward; spec.md and plan.md remain canonical instead of creating a duplicate blueprint artifact by default.
1623
+ - Do not invoke it merely because the route is Full; while grilling, ask one material question per turn.
1624
+ - Feed decisions forward; spec.md and plan.md remain canonical, without a duplicate blueprint by default.
1579
1625
  </external-skills>
1580
1626
 
1581
1627
  <memory>
1582
- - Load the installed \`thoth-mem\` skill for resume or prior work; never invent its protocol.
1583
- - Preserve a durable decision, root cause, convention, or discovery only when reusable. Root owns the stable root session ID, project, lifecycle, real-user intent, and authorization.
1584
- - Follow the skill at verified compaction or a meaningful semantic boundary; children receive only bounded MEMORY and never own root lifecycle.
1585
- - \`openspec/\` remains canonical; do not mirror SDD phase artifacts. A memory failure does not block unrelated work.
1628
+ - For resume/prior work, load the installed \`thoth-mem\` skill; never invent its protocol.
1629
+ - Preserve only a reusable decision, root cause, convention, or discovery. Root owns the stable root session ID, project, lifecycle, real-user intent, and authorization.
1630
+ - Follow it at verified compaction or a meaningful semantic boundary; children get bounded MEMORY, never root lifecycle.
1631
+ - \`openspec/\` remains canonical; do not mirror SDD artifacts. A memory failure does not block unrelated work.
1586
1632
  </memory>
1587
1633
 
1588
1634
  <artifacts>
1589
- - In ${workflow.artifactRoot}, Accelerated and Full require spec.md, plan.md, tasks.md, verify-report.md, and archive-report.md.
1590
- - Root owns openspec/ gates and task state, moves [~] -> [x] after evidence, and keeps one product writer.
1591
- - ${roleTemplate("oracle")} returns read-only findings; root persists verification and archives declared durable deltas after PASS.
1635
+ - Accelerated/Full require ${workflow.artifactRoot}{spec.md,plan.md,tasks.md,verify-report.md,archive-report.md}.
1636
+ - Root owns gates/task state, moves [~] -> [x] on evidence, and keeps one product writer. ${roleTemplate("oracle")} returns read-only findings; root persists verification and archives declared deltas after PASS.
1592
1637
  </artifacts>
1593
1638
 
1594
1639
  <delegation>