thoth-agents 0.6.0 → 0.7.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 (59) hide show
  1. package/README.md +7 -1
  2. package/dist/agents/prompt-dialects.d.ts +1 -0
  3. package/dist/{chunk-MRFCA3U2.js → chunk-3MHJGWS4.js} +2 -1
  4. package/dist/{chunk-U7FNFTM5.js → chunk-P3GDM5RH.js} +39 -38
  5. package/dist/{chunk-OW6I7ZUU.js → chunk-QOIZYJ5C.js} +322 -151
  6. package/dist/{chunk-7YCSKK2X.js → chunk-W5TSNGEE.js} +61 -5
  7. package/dist/cli/index.js +4 -4
  8. package/dist/cli/pi-install.d.ts +1 -0
  9. package/dist/cli/tui/index.js +3 -3
  10. package/dist/config/constants.d.ts +30 -3
  11. package/dist/config/schema.d.ts +4 -0
  12. package/dist/harness/adapters/claude-code.d.ts +1 -1
  13. package/dist/harness/core/agent-pack.d.ts +6 -2
  14. package/dist/harness/core/result-contract.d.ts +366 -0
  15. package/dist/harness/core/sdd.d.ts +1 -1
  16. package/dist/harness/writers/pi-agent.d.ts +1 -0
  17. package/dist/index.js +2 -2
  18. package/dist/pi.js +2 -2
  19. package/package.json +5 -3
  20. package/pi/.thoth-agents-assets.json +5 -5
  21. package/pi/agents/thoth-designer.md +15 -20
  22. package/pi/agents/thoth-explorer.md +15 -19
  23. package/pi/agents/thoth-librarian.md +15 -19
  24. package/pi/agents/thoth-oracle.md +30 -22
  25. package/pi/agents/thoth-worker.md +13 -18
  26. package/plugin/.claude-plugin/.thoth-agents-plugin-assets.json +6 -6
  27. package/plugin/.claude-plugin/plugin.json +1 -1
  28. package/plugin/.codex-plugin/plugin.json +1 -1
  29. package/plugin/agents/designer.md +9 -14
  30. package/plugin/agents/explorer.md +10 -14
  31. package/plugin/agents/librarian.md +9 -13
  32. package/plugin/agents/oracle.md +24 -18
  33. package/plugin/agents/orchestrator.md +38 -61
  34. package/plugin/agents/worker.md +9 -14
  35. package/plugin/skills/plan-reviewer/SKILL.md +16 -8
  36. package/plugin/skills/thoth-archive/SKILL.md +2 -1
  37. package/plugin/skills/thoth-constitution/SKILL.md +1 -1
  38. package/plugin/skills/thoth-constitution/templates/constitution.md +1 -1
  39. package/plugin/skills/thoth-init/SKILL.md +1 -1
  40. package/plugin/skills/thoth-sdd/SKILL.md +67 -2
  41. package/plugin/skills/thoth-sdd/references/phases/verify.md +11 -1
  42. package/plugin/skills/thoth-sdd/scripts/result-contract.json +210 -0
  43. package/plugin/skills/thoth-sdd/scripts/validate-result.d.mts +47 -0
  44. package/plugin/skills/thoth-sdd/scripts/validate-result.mjs +390 -0
  45. package/plugin/skills/thoth-sdd/scripts/validate.mjs +213 -8
  46. package/plugin/skills/thoth-sdd/templates/change.md +8 -0
  47. package/skills/plan-reviewer/SKILL.md +16 -8
  48. package/skills/thoth-archive/SKILL.md +2 -1
  49. package/skills/thoth-constitution/SKILL.md +1 -1
  50. package/skills/thoth-constitution/templates/constitution.md +1 -1
  51. package/skills/thoth-init/SKILL.md +1 -1
  52. package/skills/thoth-sdd/SKILL.md +67 -2
  53. package/skills/thoth-sdd/references/phases/verify.md +11 -1
  54. package/skills/thoth-sdd/scripts/result-contract.json +210 -0
  55. package/skills/thoth-sdd/scripts/validate-result.d.mts +47 -0
  56. package/skills/thoth-sdd/scripts/validate-result.mjs +390 -0
  57. package/skills/thoth-sdd/scripts/validate.mjs +213 -8
  58. package/skills/thoth-sdd/templates/change.md +8 -0
  59. package/thoth-agents.schema.json +14 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: thoth-sdd
3
- description: Apply proportional understanding and risk-aware SDD classification, with one ID-named record for substantial changes.
3
+ description: Governs SDD changes, including the single ID-named record for substantial work. Use for any change requiring proportional understanding and risk-aware classification, whether small or substantial.
4
4
  license: MIT
5
5
  compatibility: Requires Node.js >=22.19 for bundled product validation.
6
6
  metadata:
@@ -74,7 +74,7 @@ At substantial `ready`, first show the user a concise plan summary (goal,
74
74
  acceptance, key decisions, units, risks, record path), then always offer
75
75
  `Review plan with Oracle (Recommended)` or `Proceed without review`, even when implementation was already authorized.
76
76
  Silence is never an explicit review skip; run a fresh read-only review only when
77
- selected. After a selected `[OKAY]`, separately offer `Implement (Recommended)` /
77
+ selected. After a validated plan-review `OKAY`, separately offer `Implement (Recommended)` /
78
78
  `Stop`; prior explicit authorization remains valid, while an explicit later
79
79
  `Stop` supersedes it. Record the plan-review selection as
80
80
  `EXPLICIT_REVIEW`, `EXPLICIT_SKIP`, or `DEFAULT_REVIEW_AFTER_3`; `SKIPPED`
@@ -88,6 +88,19 @@ independent review; never claim independent PASS or archive.
88
88
 
89
89
  ## Bounded execution
90
90
 
91
+ Root uses the harness progress tool (Pi `todo`, Claude `TodoWrite`, OpenCode
92
+ `todowrite`, Codex `update_plan`) to show SDD progress. Before implementation,
93
+ create one item per remaining applicable stage:
94
+ explore/specify/clarify/classify/plan/tasks/ready/plan review/authorization.
95
+ Pi `todo` may hold several in_progress items for concurrently active stages or
96
+ tasks (e.g. parallel delegated units); Claude `TodoWrite`, OpenCode `todowrite`
97
+ and Codex `update_plan` keep one in_progress item; complete each stage/task
98
+ immediately. At implementation, replace stage items with the record's task rows
99
+ plus final verification and archive (for small changes, use the settled work
100
+ steps plus verification). Keep one list per change; prefix items with the change
101
+ ID when several changes are active. This native progress view is not a sidecar
102
+ record and never replaces SDD gates or authorization.
103
+
91
104
  Apply these rules across all workflow stages. Each assignment names one
92
105
  independently acceptable outcome, exact known entrypoints and skill paths,
93
106
  concrete accepted inputs and dependencies, its produced result, owned writes and
@@ -143,12 +156,54 @@ parent. Read only the current phase under
143
156
  plan review and archive are sibling skill contracts. Use installed local assets
144
157
  only; do not provision skills or run a network installer mid-workflow.
145
158
 
159
+ ## Specialist result validation
160
+
161
+ Only Oracle gate assignments (plan-review and final-verification) return a
162
+ structured envelope. Before recording plan-review `OKAY` or final-verification
163
+ `PASS`, root resolves `<skill-dir>` from the installed thoth-sdd SKILL.md
164
+ directory, exactly as for `scripts/validate.mjs`, and runs:
165
+
166
+ ```text
167
+ node "<skill-dir>/scripts/validate-result.mjs" --review-kind <kind> [--record-sha256 <hex>] [--no-record] [--input <path>]
168
+ ```
169
+
170
+ Pass the unchanged native terminal result via stdin, or `--input <path>` when
171
+ piping is impractical; do not extract, rewrite, or wrap the envelope, or create
172
+ persisted evidence files. Set `--review-kind` to the assigned `plan-review` or
173
+ `final-verification`. For final verification of a substantial record, set
174
+ `--record-sha256` to the independently calculated expected SHA-256 of exact UTF-8
175
+ bytes before `## Authorization` (see the [verify phase](references/phases/verify.md)).
176
+ Confirm `reviewedRecord` identifies the assigned record.
177
+ For Oracle final verification of a small change without a record, root passes
178
+ `--no-record`; Oracle omits both `reviewedRecord` and `reviewedRecordSha256`.
179
+ Do not combine `--no-record` with `--record-sha256` or plan-review.
180
+ Without `--no-record`, final verification still requires both binding fields.
181
+
182
+ - Exit **0** means structurally valid only. Root still judges scope, evidence,
183
+ checks, freshness, provenance, independence, and content before recording any
184
+ approval, and presents accepted results to the user in readable prose.
185
+ - Exit **1** means no approval. Allow at most one format-only repair request per assignment,
186
+ shared with any runtime enforcement; it must not change findings or verdict.
187
+ Exhaustion is a contract failure reported truthfully, never converted into an Oracle `BLOCKED` judgment.
188
+ - Exit **2** or an unavailable skill/validator means validation cannot be completed:
189
+ report the error (missing assets are installation drift). This blocks only gate approvals;
190
+ ordinary delegations proceed. Do not provision replacements mid-workflow.
191
+
192
+ Other Thoth specialist returns use compact markdown fields and are judged on content,
193
+ not validated for format. User-defined custom agents retain their own free format;
194
+ neither ordinary specialist results nor custom agents are rejected for format or
195
+ count as approvals. Oracle `diagnosis` and `advice` never authorize implementation
196
+ or closeout and return compact markdown, not envelopes. Approval comes only from
197
+ the validated gate review field, never free text; validation itself is not user authorization.
198
+
146
199
  ## Gates and CLI
147
200
 
148
201
  ```text
149
202
  node "<skill-dir>/scripts/validate.mjs" --change .thoth/changes/<id> --through <explore|specify|clarify|plan|tasks|checklist|ready|verify|closeout> --json
150
203
  ```
151
204
 
205
+ Substantial records must not contain other `thoth-result` fences or `**Oracle envelope**:` marker lines anywhere in the file; write examples inline instead.
206
+
152
207
  The early gates validate the one record proportionally. `plan` validates without
153
208
  requiring tasks. `tasks` and `ready` require concrete coverage of every accepted
154
209
  outcome. `ready` requires settled material decisions before the mandatory
@@ -159,6 +214,16 @@ implementation authorization, and reviewed source digests/baselines. It permits
159
214
  final-review and Archive placeholders. `closeout` additionally requires a fresh
160
215
  independent Oracle PASS, every acceptance outcome with concrete PASS
161
216
  check/evidence, exactly one matching record SHA-256 field, and Archive READY.
217
+ Order: `verify` → fresh final Oracle → root validates and pastes → `closeout` → archive.
218
+ After accepting a validated PASS, root pastes the Oracle's unchanged
219
+ final-verification envelope under `**Oracle envelope**:` in the record's
220
+ Verification section (post-PASS bookkeeping in Verification; no new review).
221
+ Plan-review envelopes are not embedded. Closeout fails without exactly one valid
222
+ PASS envelope matching the record path and prefix digest, consistent with
223
+ `**Verdict**` and `**Reviewed record SHA-256**`. Preserve the envelope unchanged
224
+ when archiving; archived validation accepts its original active record path.
225
+ Historical archived records are not retrofitted or re-validated by this rule.
226
+
162
227
  The initial `PENDING` selection placeholder is allowed before `verify` only.
163
228
  `SKIPPED` requires `EXPLICIT_SKIP`; `OKAY` requires `EXPLICIT_REVIEW` or
164
229
  `DEFAULT_REVIEW_AFTER_3`. Every canonical spec affected by a durable delta must
@@ -2,6 +2,16 @@
2
2
 
3
3
  Every change requires final verification against accepted outcomes and actual execution evidence. Small low-risk work uses focused independent root checks; substantial or materially risky work requires a fresh read-only Oracle independent from the writer. Judge the actual diff, behavior, completeness, correctness, coherence, checks, and residual risks.
4
4
 
5
+ For Oracle final verification of a small change without a record, root passes `--no-record`; Oracle omits both `reviewedRecord` and `reviewedRecordSha256`. Do not combine `--no-record` with `--record-sha256` or plan-review. Otherwise final verification still requires both binding fields.
6
+
5
7
  Before requesting final Oracle for substantial work, run `node "<skill-dir>/scripts/validate.mjs" --change .thoth/changes/<id> --through verify --json`. This gate requires ready coverage, complete tasks, authorization disposition/provenance, and reviewed source digests/baselines; final-review fields, AC evidence rows, and Archive may remain placeholders. For each capability named by a durable delta, add exactly one `Source` entry for `.thoth/specs/<capability>/spec.md`: its reviewed SHA-256 when it exists, or `absent` only when no canonical file exists.
6
8
 
7
- After review, record each outcome's concrete PASS evidence, actual checks, source SHA-256 digests, and the hash of exact UTF-8 record bytes preceding the case-sensitive `## Authorization` heading. After PASS, edits confined to Authorization, Verification, or Closeout need no new review; any edit before `## Authorization` requires fresh independent review and a new digest. This allowance never waives structural checks, truthful provenance, stale-source rejection, or review of changed implementation. Recheck baselines after review; missing or stale digests/absence, missing evidence, or blockers prevent closeout and archive. Never create a verification report or evidence directory; route actionable findings to convergence.
9
+ Assign Oracle a `final-verification` review of the substantial record. Oracle returns exactly one fenced `thoth-result` JSON envelope as the entire final message, following the Oracle gate contract with `role: "oracle"`, `review.kind: "final-verification"`, and `review.verdict: "PASS" | "FAIL" | "BLOCKED"`. Its review includes `reviewedRecord` naming the reviewed record path and `reviewedRecordSha256` containing the 64 lowercase hex SHA-256 of exact UTF-8 record bytes preceding the case-sensitive `## Authorization` heading. PASS requires `status: "complete"` and no blocking risks. FAIL reports findings; BLOCKED is an actual inability to complete review, never a substitute for a malformed result or exhausted format repair.
10
+
11
+ Root validates the unchanged native terminal result using the thoth-sdd **Specialist result validation** procedure with `--review-kind final-verification --record-sha256 <hex>`, where `<hex>` is the independently calculated expected record-prefix digest. Confirm `reviewedRecord` identifies the assigned record. Root records `**Reviewer**: oracle`, `**Independent from implementer**: Yes`, `**Verdict**: PASS`, and `**Reviewed record SHA-256**` only from a validated PASS envelope whose digest matches the current record, after judging the content and confirming reviewer independence. Invalid results, FAIL, BLOCKED, and diagnosis/advice reviews do not authorize closeout or archive; route findings to convergence and report contract failures truthfully.
12
+
13
+ Substantial records must not contain other `thoth-result` fences or `**Oracle envelope**:` marker lines anywhere in the file; write examples inline instead.
14
+
15
+ Order: `verify` → fresh final Oracle → root validates and pastes → `closeout` → archive. After accepting a validated PASS, root pastes the Oracle's unchanged final-verification envelope under `**Oracle envelope**:` in the record's Verification section (post-PASS bookkeeping in Verification; no new review). Plan-review envelopes are not embedded. Closeout fails without exactly one valid PASS envelope matching the record path and prefix digest, consistent with `**Verdict**` and `**Reviewed record SHA-256**`. Preserve the envelope unchanged when archiving; archived validation accepts its original active record path. Historical archived records are not retrofitted or re-validated by this rule.
16
+
17
+ After accepted review, record each outcome's concrete PASS evidence, actual checks, source SHA-256 digests, and the matched record-prefix hash. After PASS, edits confined to Authorization, Verification, or Closeout need no new review; any edit before `## Authorization` requires fresh independent review and a new digest. This allowance never waives structural checks, truthful provenance, stale-source rejection, or review of changed implementation. Recheck baselines after review; missing or stale digests/absence, missing evidence, or blockers prevent closeout and archive. Never create a verification report or evidence directory; route actionable findings to convergence.
@@ -0,0 +1,210 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "fence": "thoth-result",
4
+ "common": {
5
+ "type": "object",
6
+ "properties": {
7
+ "schemaVersion": {
8
+ "type": "number",
9
+ "const": 1
10
+ },
11
+ "role": {
12
+ "type": "string",
13
+ "enum": ["oracle"]
14
+ },
15
+ "status": {
16
+ "type": "string",
17
+ "enum": ["complete", "partial", "blocked", "failed"]
18
+ },
19
+ "conclusion": {
20
+ "type": "string"
21
+ },
22
+ "evidence": {
23
+ "type": "array",
24
+ "items": {
25
+ "type": "object",
26
+ "properties": {
27
+ "id": {
28
+ "type": "string",
29
+ "minLength": 1
30
+ },
31
+ "kind": {
32
+ "type": "string"
33
+ },
34
+ "locator": {
35
+ "type": "string"
36
+ },
37
+ "claim": {
38
+ "type": "string"
39
+ },
40
+ "basis": {
41
+ "type": "string",
42
+ "enum": ["observed", "inferred"]
43
+ },
44
+ "uncertainty": {
45
+ "type": "string"
46
+ }
47
+ },
48
+ "required": [
49
+ "id",
50
+ "kind",
51
+ "locator",
52
+ "claim",
53
+ "basis",
54
+ "uncertainty"
55
+ ],
56
+ "additionalProperties": false
57
+ }
58
+ },
59
+ "verification": {
60
+ "type": "array",
61
+ "items": {
62
+ "type": "object",
63
+ "properties": {
64
+ "check": {
65
+ "type": "string"
66
+ },
67
+ "method": {
68
+ "type": "string"
69
+ },
70
+ "outcome": {
71
+ "type": "string",
72
+ "enum": ["pass", "fail", "not-run"]
73
+ },
74
+ "evidenceIds": {
75
+ "type": "array",
76
+ "items": {
77
+ "type": "string"
78
+ }
79
+ },
80
+ "reason": {
81
+ "type": "string"
82
+ }
83
+ },
84
+ "required": ["check", "method", "outcome", "evidenceIds", "reason"],
85
+ "additionalProperties": false
86
+ }
87
+ },
88
+ "risks": {
89
+ "type": "array",
90
+ "items": {
91
+ "type": "object",
92
+ "properties": {
93
+ "description": {
94
+ "type": "string"
95
+ },
96
+ "severity": {
97
+ "type": "string",
98
+ "enum": ["low", "medium", "high", "critical"]
99
+ },
100
+ "blocking": {
101
+ "type": "boolean"
102
+ },
103
+ "evidenceIds": {
104
+ "type": "array",
105
+ "items": {
106
+ "type": "string"
107
+ }
108
+ }
109
+ },
110
+ "required": ["description", "severity", "blocking", "evidenceIds"],
111
+ "additionalProperties": false
112
+ }
113
+ },
114
+ "openQuestions": {
115
+ "type": "array",
116
+ "items": {
117
+ "type": "object",
118
+ "properties": {
119
+ "question": {
120
+ "type": "string"
121
+ },
122
+ "owner": {
123
+ "type": "string"
124
+ },
125
+ "options": {
126
+ "type": "array",
127
+ "items": {
128
+ "type": "string"
129
+ }
130
+ },
131
+ "facts": {
132
+ "type": "array",
133
+ "items": {
134
+ "type": "string"
135
+ }
136
+ }
137
+ },
138
+ "required": ["question", "owner", "options", "facts"],
139
+ "additionalProperties": false
140
+ }
141
+ }
142
+ },
143
+ "required": [
144
+ "schemaVersion",
145
+ "role",
146
+ "status",
147
+ "conclusion",
148
+ "evidence",
149
+ "verification",
150
+ "risks",
151
+ "openQuestions"
152
+ ],
153
+ "additionalProperties": false
154
+ },
155
+ "roles": {
156
+ "oracle": {
157
+ "type": "object",
158
+ "properties": {
159
+ "nextAction": {
160
+ "type": ["string", "null"]
161
+ },
162
+ "review": {
163
+ "type": "object",
164
+ "properties": {
165
+ "kind": {
166
+ "type": "string",
167
+ "enum": ["plan-review", "final-verification"]
168
+ },
169
+ "verdict": {
170
+ "type": "string"
171
+ },
172
+ "reviewedRecord": {
173
+ "type": "string",
174
+ "minLength": 1
175
+ },
176
+ "reviewedRecordSha256": {
177
+ "type": "string",
178
+ "pattern": "^[a-f0-9]{64}$"
179
+ }
180
+ },
181
+ "required": ["kind", "verdict"],
182
+ "additionalProperties": false
183
+ }
184
+ },
185
+ "required": ["nextAction", "review"],
186
+ "additionalProperties": false
187
+ }
188
+ },
189
+ "reviewKinds": {
190
+ "plan-review": {
191
+ "verdicts": ["OKAY", "REJECT"]
192
+ },
193
+ "final-verification": {
194
+ "verdicts": ["PASS", "FAIL", "BLOCKED"]
195
+ }
196
+ },
197
+ "rules": {
198
+ "positiveVerdicts": ["OKAY", "PASS"],
199
+ "positiveStatus": "complete",
200
+ "positiveAllowsBlockingRisks": false,
201
+ "evidenceIdUnique": true,
202
+ "evidenceReferences": ["verification", "risks"],
203
+ "recordBindingReviewKind": "final-verification",
204
+ "recordBindingRequiredFields": ["reviewedRecord", "reviewedRecordSha256"],
205
+ "recordBindingForbiddenUnderNoRecord": [
206
+ "reviewedRecord",
207
+ "reviewedRecordSha256"
208
+ ]
209
+ }
210
+ }
@@ -0,0 +1,47 @@
1
+ import type {
2
+ SpecialistResult,
3
+ SpecialistRole,
4
+ OracleReviewKind,
5
+ } from '../../../src/harness/core/result-contract';
6
+
7
+ export interface ResultValidationOptions {
8
+ role?: SpecialistRole;
9
+ reviewKind?: OracleReviewKind;
10
+ recordSha256?: string;
11
+ noRecord?: boolean;
12
+ }
13
+ export type ResultIssueCode =
14
+ | 'ENVELOPE_FORMAT'
15
+ | 'JSON_SYNTAX'
16
+ | 'JSON_DUPLICATE_KEY'
17
+ | 'REQUIRED_FIELD'
18
+ | 'UNDECLARED_FIELD'
19
+ | 'TYPE_MISMATCH'
20
+ | 'INVALID_VALUE'
21
+ | 'ROLE_MISMATCH'
22
+ | 'REVIEW_KIND_MISMATCH'
23
+ | 'EVIDENCE_ID_DUPLICATE'
24
+ | 'EVIDENCE_REFERENCE'
25
+ | 'VERDICT_MISMATCH'
26
+ | 'VERDICT_STATUS'
27
+ | 'BLOCKING_RISK'
28
+ | 'RECORD_BINDING_REQUIRED'
29
+ | 'RECORD_BINDING_FORBIDDEN'
30
+ | 'RECORD_DIGEST_MISMATCH'
31
+ | 'EXPECTATION_INVALID'
32
+ | 'CLI_USAGE'
33
+ | 'CLI_INPUT';
34
+ export interface ResultValidationIssue {
35
+ code: ResultIssueCode;
36
+ /** JSON Pointer; the empty string denotes the whole message/envelope. */
37
+ path: string;
38
+ message: string;
39
+ }
40
+ export type ResultValidation =
41
+ | { valid: true; envelope: SpecialistResult; issues: [] }
42
+ | { valid: false; envelope?: never; issues: ResultValidationIssue[] };
43
+ export function validateResult(
44
+ message: string,
45
+ options?: ResultValidationOptions,
46
+ ): ResultValidation;
47
+ export const RESULT_VALIDATOR_USAGE: string;