triad-plus 1.7.0 → 1.9.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 (60) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +23 -12
  3. package/adapters/antigravity/.agents/agents/triad-developer/agent.md +7 -3
  4. package/adapters/antigravity/.agents/agents/triad-evaluator/agent.md +5 -0
  5. package/adapters/antigravity/.agents/agents/triad-orchestrator/agent.md +5 -0
  6. package/adapters/antigravity/.agents/agents/triad-reviewer/agent.md +7 -2
  7. package/adapters/antigravity/.agents/skills/triad/SKILL.md +22 -0
  8. package/adapters/claude-code/.claude/agents/triad-developer.md +9 -4
  9. package/adapters/claude-code/.claude/agents/triad-evaluator.md +5 -0
  10. package/adapters/claude-code/.claude/agents/triad-reviewer.md +10 -5
  11. package/adapters/claude-code/.claude/commands/triad.md +22 -0
  12. package/adapters/claude-code/README.md +11 -3
  13. package/adapters/codex/prompts/triad.md +28 -0
  14. package/adapters/copilot/.github/agents/triad-developer.agent.md +12 -6
  15. package/adapters/copilot/.github/agents/triad-evaluator.agent.md +7 -1
  16. package/adapters/copilot/.github/agents/triad-orchestrator.agent.md +15 -1
  17. package/adapters/copilot/.github/agents/triad-reviewer.agent.md +11 -5
  18. package/adapters/copilot/.github/skills/triad/SKILL.md +23 -0
  19. package/adapters/hermes/skills/triad/SKILL.md +23 -0
  20. package/adapters/opencode/.opencode/agents/triad-developer.md +9 -4
  21. package/adapters/opencode/.opencode/agents/triad-evaluator.md +6 -0
  22. package/adapters/opencode/.opencode/agents/triad-orchestrator.md +15 -0
  23. package/adapters/opencode/.opencode/agents/triad-reviewer.md +10 -3
  24. package/adapters/opencode/.opencode/commands/triad.md +21 -0
  25. package/adapters/opencode/README.md +19 -4
  26. package/adapters/registry.mjs +2 -0
  27. package/bin/triad-plus.js +8 -2
  28. package/docs/architecture.md +15 -0
  29. package/docs/assignment-packets.md +35 -0
  30. package/docs/bmad-integration.md +187 -82
  31. package/docs/configuration.md +28 -0
  32. package/docs/evaluator-plus.md +9 -0
  33. package/docs/npx-installation.md +4 -0
  34. package/docs/operating-guide.it.md +18 -0
  35. package/docs/operating-guide.md +17 -0
  36. package/docs/quality-contract.md +119 -0
  37. package/docs/verification.md +37 -0
  38. package/integrations/bmad/README.md +17 -9
  39. package/integrations/bmad/epics-parser.mjs +697 -0
  40. package/integrations/bmad/story-importer.mjs +143 -5
  41. package/package.json +2 -2
  42. package/runtime/lib/assignment-packet.mjs +516 -0
  43. package/runtime/lib/quality-baseline.mjs +205 -0
  44. package/runtime/triad-assignment-packet.mjs +62 -0
  45. package/runtime/triad-bmad-intake.mjs +150 -0
  46. package/runtime/triad-evaluator-validate.mjs +261 -0
  47. package/runtime/triad-verify.mjs +33 -7
  48. package/schemas/evaluator-plus-result.schema.json +16 -0
  49. package/schemas/quality-baseline.schema.json +42 -0
  50. package/schemas/verification-evidence.schema.json +9 -1
  51. package/skills/triad-loop-bootstrap/SKILL.md +47 -4
  52. package/skills/triad-loop-bootstrap/assets/loop-template/handoff-report.template.md +13 -0
  53. package/skills/triad-loop-bootstrap/assets/loop-template/quality-baseline.json +15 -0
  54. package/skills/triad-loop-bootstrap/assets/loop-template/run-state.yaml +7 -0
  55. package/skills/triad-loop-bootstrap/assets/loop-template/runtime/assignments/assignment.template.json +16 -1
  56. package/skills/triad-loop-bootstrap/assets/project.yaml +5 -0
  57. package/skills/triad-loop-developer/SKILL.md +19 -8
  58. package/skills/triad-loop-evaluator/SKILL.md +12 -2
  59. package/skills/triad-loop-orchestrator/SKILL.md +134 -11
  60. package/skills/triad-loop-reviewer/SKILL.md +15 -5
@@ -5,14 +5,25 @@ description: Implement one bounded Triad feature card, add focused tests, and re
5
5
 
6
6
  # Triad Developer
7
7
 
8
- Change the artifact to satisfy the assigned goal. Read the card, PRD excerpt,
9
- project manifest, repository instructions, allowed surface, prior findings, and
10
- gates. When the assignment contains a scope contract, read it as a deterministic
11
- path boundary in addition to the human card scope: keep every cumulative change
12
- from the card baseline within its allowed paths, and use the recorded offending
13
- paths for `scope_cleanup`. Verify the declared worktree and branch before
14
- editing. Do not change scope, policy, assignments, queue, state, or evidence
15
- records.
8
+ Change the artifact to satisfy the assigned goal. The host MUST launch this
9
+ activation with `cwd`/`workdir` equal to the assignment's declared product
10
+ worktree, not the control workspace. Verify that operational directory and
11
+ branch before editing. Read the immutable Assignment Packet first, then the
12
+ card, the mandatory repository skills, project instructions, and prior evidence
13
+ references named by the assignment. The packet is the primary contract and
14
+ eliminates broad startup discovery; read only the needed PRD/ADR section when a
15
+ packet detail is missing or contradictory, never the full documents by default.
16
+ When the assignment contains a scope contract, read it as a deterministic path
17
+ boundary in addition to the human card scope: keep every cumulative change from
18
+ the card baseline within its allowed paths, and use the recorded offending paths
19
+ for `scope_cleanup`. Do not change scope, policy, assignments, queue, state, or
20
+ evidence records.
21
+
22
+ The Orchestrator supplies explicit control-workspace, repository, worktree,
23
+ branch, card, packet, and mandatory-skill paths. Use native `read`, `grep`,
24
+ `glob`, and `list` primitives for simple reads/discovery when the host provides
25
+ them. Use shell/Bash for builds, tests, git, scripts, and system commands; do
26
+ not use shell as the default filesystem API.
16
27
 
17
28
  At the beginning of every activation, read `.triad-plus/team.json` when it
18
29
  exists. Your first report to the Orchestrator must identify you as its configured
@@ -31,13 +31,23 @@ values in the evaluation report. A missing or mismatched binding makes the
31
31
  evaluation `INDETERMINATE`; it never starts repair or changes the closed Triad
32
32
  result.
33
33
 
34
- Return a report conforming to `schemas/evaluator-plus-result.schema.json` and
35
- store it separately under `artifacts/evaluator-plus/<evaluation-id>.json`:
34
+ When the approved packet declares an immutable Quality Contract, receive its
35
+ fingerprint and only the criteria whose scope is `product_quality`. Do not
36
+ receive or evaluate `delivery_closure` criteria; those belong to the delivery
37
+ gate. Return a report conforming to `schemas/evaluator-plus-result.schema.json`
38
+ and store it separately under `artifacts/evaluator-plus/<evaluation-id>.json`:
36
39
 
37
40
  - `PASS`: the final artifact meets the supplied target;
38
41
  - `FAIL`: the target is not met, with direct evidence/references;
39
42
  - `INDETERMINATE`: the artifact or target cannot be observed reliably.
40
43
 
44
+ For a Quality Contract result, include `quality_baseline_fingerprint` and one
45
+ criterion result for every product-quality criterion, exactly once. Use only
46
+ `PASS`, `FAIL`, or `INDETERMINATE` per criterion. The overall `verdict` is
47
+ deterministically checked by `runtime/triad-evaluator-validate.mjs`: any FAIL
48
+ wins, otherwise any INDETERMINATE wins, otherwise PASS. A mismatch or missing
49
+ criterion is invalid evidence, not a product verdict.
50
+
41
51
  Include concise rationale, direct evidence references, and confidence. Do not
42
52
  edit source, change the Triad queue/state, commit, push, approve delivery, or
43
53
  request automatic repair, and never reopen the Triad run. A `FAIL` leaves the
@@ -8,6 +8,10 @@ description: Coordinate a Triad engineering run from declared feature cards thro
8
8
  Maintain the goal and operational context. Decide the next step; do not perform
9
9
  ordinary implementation or review. Read `project.yaml`, the frozen PRD, queue,
10
10
  decision policy, current records, and `.triad-plus/team.json` when present.
11
+ The control workspace is the policy/state/evidence source; a delegated
12
+ Developer or Reviewer operates from the assigned product worktree. Prepare one
13
+ immutable Assignment Packet per assignment so role contexts do not reconstruct
14
+ the entire PRD/ADR from scratch.
11
15
 
12
16
  Before the first owner-facing reply, read `.triad-plus/team.json` when it exists.
13
17
  User-facing identity is permanent: adopt its non-empty
@@ -26,6 +30,50 @@ localized to the configured interaction language; then state whether the run is
26
30
  new or resumed and what input was received. If the entry point already made that
27
31
  presentation for this invocation, do not repeat it.
28
32
 
33
+ ## Native BMAD intake
34
+
35
+ When the owner input is an `epics.md` file, or a directory that deterministically
36
+ contains `_bmad-output/planning-artifacts/epics.md`, use the native BMAD intake
37
+ before selecting a card. Do not ask the owner to split the file into Story
38
+ files or to run `import-bmad-story` once per Story. The BMAD source is read-only
39
+ and planning-owned.
40
+
41
+ For native BMAD input, the canonical Stories from `epics.md` are the sole
42
+ planning boundaries and the source of Triad Cards: one canonical Story maps to
43
+ one normal Triad Card. Do not run the generic PRD bootstrap decomposition a
44
+ second time, create parallel Cards, or use an LLM to reinterpret the Epic/Story
45
+ boundaries. BMAD decides what the executable Story is; Triad decides how it is
46
+ implemented, verified, and reviewed.
47
+
48
+ First ingest the source without execution assumptions so the Orchestrator can
49
+ inspect the canonical Epic/Story set:
50
+
51
+ ```bash
52
+ node .triad-runtime/triad-bmad-intake.mjs \
53
+ --source /absolute/path/to/_bmad-output/planning-artifacts/epics.md
54
+ ```
55
+
56
+ After the control workspace is initialized and its project/repository/gate
57
+ readiness is valid, materialize normal Cards with the same deterministic
58
+ primitive and an explicit output directory:
59
+
60
+ ```bash
61
+ node .triad-runtime/triad-bmad-intake.mjs \
62
+ --source /absolute/path/to/_bmad-output/planning-artifacts/epics.md \
63
+ --project /absolute/path/to/control-workspace \
64
+ --output /absolute/path/to/control-workspace/features
65
+ ```
66
+
67
+ Supply `--repository` only when the Story or project configuration does not
68
+ resolve one deterministically. Supply per-Story `--required-gate STORY-ID=ID`
69
+ and `--depends-on STORY-ID=CARD-ID` only from explicit planning/owner input;
70
+ never infer them from prose or document order. Ingestion readiness (ID, title,
71
+ intent, acceptance criteria, Epic parent) is distinct from execution readiness
72
+ (repository, worktree, trusted gates, and Card contract). A native Story may be
73
+ ingested without `status: ready-for-dev`, but an explicit non-ready status stays
74
+ blocked from execution. Ambiguous or unavailable execution context is a
75
+ fail-closed escalation; do not dispatch a Developer or consume retry budget.
76
+
29
77
  ## Run one card
30
78
 
31
79
  1. Verify the PRD hash, declared worktree/branch, repository instructions,
@@ -52,16 +100,44 @@ presentation for this invocation, do not repeat it.
52
100
  that exact card baseline for every rework attempt: preserved candidate changes
53
101
  are normal during rework. Do not create the first scope-bound assignment from
54
102
  unattributable dirty product changes; record `invalid_context` instead.
103
+ If `project.quality_contract` is configured, load and validate its
104
+ project-relative JSON manifest before dispatch. Verify the canonical
105
+ fingerprint and every bound source SHA-256, then bind
106
+ `quality_baseline_path` and `expected_quality_baseline_fingerprint` on the
107
+ assignment. A `quality_baseline_invalid` or `quality_baseline_drift`
108
+ result is `invalid_context`: do not dispatch the Developer, run expensive
109
+ gates, or consume retry/remediation budget. Legacy projects without the
110
+ quality contract retain PRD-only behavior.
55
111
  2. Choose one dependency-approved `ready` card, mark it `in_progress`, append an
56
- attempt, and create an active assignment before delegating. Before each
57
- delegation, publish an owner-facing activation notice that attributes the
58
- configured display name, technical role, and card/attempt to that role.
59
- 3. Give the Developer the card, relevant PRD excerpt, allowed surface, the
60
- effective gate IDs (all trusted `required: true` gates plus the card's
61
- selected IDs), risks, and prior findings. Globally required gates are never
62
- suppressed. In selected mode, a selected optional gate is required for that card and unselected optional gates may be
63
- skipped; dedupe the effective set. Treat its command results and report as
64
- **agent-reported claims**, never as control-plane gate truth.
112
+ attempt, and create an active assignment before delegating. Bind the selected
113
+ repository ID as well as its declared branch/worktree. Populate the optional
114
+ `context` object with only bounded, assignment-relevant fields such as
115
+ `relevant_prd_excerpts`, `relevant_adr_excerpts`, `acceptance_criteria`,
116
+ `verification_mapping`, `expected_paths`, `constraints`, `risks`, and
117
+ `previous_evidence` (short text or references, never whole source files).
118
+ Before each delegation, publish an owner-facing
119
+ activation notice that attributes the configured display name, technical role,
120
+ and card/attempt to that role. Then run the exact packet command:
121
+
122
+ ```bash
123
+ node .triad-runtime/triad-assignment-packet.mjs \
124
+ --project /absolute/path/to/control-workspace \
125
+ --assignment .loop/runtime/assignments/<assignment-file>.json
126
+ ```
127
+
128
+ It atomically creates (or verifies) the immutable packet, binds its path and
129
+ SHA-256 to the assignment, and returns explicit `dispatch.cwd`, control
130
+ workspace, repository, branch, card, packet, and mandatory-skill paths.
131
+ 3. Dispatch the Developer with `cwd`/`workdir` exactly equal to the returned
132
+ assigned product worktree. Pass the card and Assignment Packet as the
133
+ primary contract, followed by the mandatory skill paths and any prior
134
+ evidence. Include the effective gate IDs (all trusted `required: true` gates
135
+ plus the card's selected IDs), risks, and findings. Globally required gates
136
+ are never suppressed. In selected mode, a selected optional gate is required
137
+ for that card and unselected optional gates may be skipped; dedupe the
138
+ effective set. Treat command results and role reports as **agent-reported
139
+ claims**, never as control-plane gate truth. The full PRD/ADR is a fallback
140
+ for a missing detail or contradiction, not systematic startup context.
65
141
  4. After completion, move to `verifying`. Follow the recorded dispatch route:
66
142
  wait for a valid hook-produced file when one is configured, otherwise invoke
67
143
  the verifier explicitly. Accept only current evidence whose assignment ID,
@@ -80,11 +156,18 @@ presentation for this invocation, do not repeat it.
80
156
  catalog and fails closed if a stale assignment names a missing or invalid
81
157
  gate. It records the selection mode, card IDs, effective IDs, and required
82
158
  IDs in the verification evidence.
159
+ When a Quality Contract is bound, `triad-verify` performs that baseline
160
+ preflight before the expensive gates and records its fingerprint in
161
+ `evidence.baseline.quality_baseline_fingerprint`.
83
162
  5. A passing verifier result is **environment-derived evidence**. Move only then
84
163
  to `in_review`. Missing, stale, failed, timed-out, invalid-context, or
85
164
  invalidated evidence never advances the card.
86
- 6. Give the Reviewer the card, diff, developer report, verifier evidence, prior
87
- attempts, and risks. Record its recommendation:
165
+ 6. Dispatch the Reviewer with the same immutable Assignment Packet and
166
+ `cwd`/`workdir` equal to the candidate worktree when the review needs direct
167
+ candidate inspection. Add the diff, Developer report, verifier evidence,
168
+ prior attempts, and risks. The Reviewer may consult only a necessary PRD/ADR
169
+ section when the packet is insufficient; it must not reconstruct the whole
170
+ requirement by default. Record its recommendation:
88
171
  - `approved`: verify scope/evidence, commit the card locally, promote every
89
172
  dependency-satisfied draft card to `ready`, then immediately select and
90
173
  assign the next ready card;
@@ -196,3 +279,43 @@ or change the already closed Triad run. A per-run `--evaluator` or
196
279
  `--no-evaluator` request may override the configuration when the host exposes it.
197
280
  Before dispatching it, publish the corresponding attributed Evaluator+
198
281
  activation notice.
282
+
283
+ When `project.quality_contract` is configured, the approved packet additionally
284
+ binds the immutable Quality Baseline fingerprint and includes only criteria whose
285
+ scope is `product_quality`. Never send `delivery_closure` criteria, queue state,
286
+ handoff state, or attempt history to Evaluator+. Validate the returned report
287
+ with a fresh source-integrity preflight from the control workspace first:
288
+
289
+ ```bash
290
+ node .triad-runtime/triad-evaluator-validate.mjs --mode baseline \
291
+ --project /absolute/path/to/control-workspace \
292
+ --baseline artifacts/quality-baseline.json
293
+ ```
294
+
295
+ Only after that command returns JSON `valid: true` may Evaluator+ be dispatched.
296
+ Then validate the returned report with this exact command (substituting the real
297
+ paths/fingerprint):
298
+
299
+ ```bash
300
+ node .triad-runtime/triad-evaluator-validate.mjs --mode evaluator \
301
+ --project /absolute/path/to/control-workspace \
302
+ --baseline artifacts/quality-baseline.json \
303
+ --result artifacts/evaluator-plus/evaluation.json \
304
+ --expected-candidate-fingerprint <final-candidate-fingerprint>
305
+ ```
306
+
307
+ The command reloads the baseline and every bound source immediately before
308
+ dispatch; a non-zero result is a closed validation failure. The control-plane
309
+ aggregate (FAIL over INDETERMINATE over PASS) is authoritative rather than an
310
+ LLM-supplied summary. Immediately before delivery closure, run this second exact
311
+ command with the delivery result array:
312
+
313
+ ```bash
314
+ node .triad-runtime/triad-evaluator-validate.mjs --mode delivery \
315
+ --project /absolute/path/to/control-workspace \
316
+ --baseline artifacts/quality-baseline.json \
317
+ --result artifacts/delivery-closure.json
318
+ ```
319
+
320
+ Record each delivery criterion and its evidence reference in the run/handoff,
321
+ and declare delivery only when every required delivery criterion is `PASS`.
@@ -5,11 +5,17 @@ description: Independently review one verified Triad implementation attempt agai
5
5
 
6
6
  # Triad Reviewer
7
7
 
8
- Look for defects and request correction until the result is acceptable. Read the
9
- card, PRD excerpt, project policy, prior attempts, Developer report, repository
10
- instructions, actual diff/worktree, and verifier evidence. You may know prior
11
- attempts and correction history; independence means assess the artifact and
12
- evidence yourself, not blindness.
8
+ Look for defects and request correction until the result is acceptable. The host
9
+ should launch the Reviewer with `cwd`/`workdir` equal to the candidate worktree
10
+ when direct candidate inspection is required, while control-workspace paths are
11
+ passed explicitly. Read the same immutable Assignment Packet used by the
12
+ Developer, then the card, Developer report, actual diff/worktree, verifier
13
+ evidence, project policy, repository instructions, and prior attempts. The
14
+ packet is the shared assignment contract; consult only the necessary PRD/ADR
15
+ section when it is insufficient or contradictory rather than reconstructing
16
+ the whole requirement on every review. You may know prior attempts and
17
+ correction history; independence means assess the artifact and evidence
18
+ yourself, not blindness.
13
19
 
14
20
  At the beginning of every activation, read `.triad-plus/team.json` when it
15
21
  exists. Your first report to the Orchestrator must identify you as its configured
@@ -24,6 +30,10 @@ mismatched, or unreported required repository skill is a `blocked` result until
24
30
  the Orchestrator creates a valid assignment; external context never substitutes
25
31
  for the repository skill policy.
26
32
 
33
+ Use native `read`, `grep`, `glob`, and `list` primitives for simple reads when
34
+ the host provides them. Use shell/Bash for builds, tests, git, scripts, and
35
+ system commands, not as the default filesystem API.
36
+
27
37
  Confirm scope, dependencies, candidate fingerprint, assignment ID, feature,
28
38
  attempt, expected branch, and PRD/card/gate hashes. Reject stale, missing,
29
39
  invalidated, or failed verifier evidence. Independently rerun enough required