@gtrabanco/pi-agentic-workflow 0.1.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 (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +154 -0
  3. package/README.md +148 -0
  4. package/dist/config/defaults.d.ts +8 -0
  5. package/dist/config/defaults.js +11 -0
  6. package/dist/config/load.d.ts +19 -0
  7. package/dist/config/load.js +76 -0
  8. package/dist/config/merge.d.ts +4 -0
  9. package/dist/config/merge.js +43 -0
  10. package/dist/config/schema.d.ts +21 -0
  11. package/dist/config/schema.js +144 -0
  12. package/dist/config/types.d.ts +53 -0
  13. package/dist/config/types.js +12 -0
  14. package/dist/extension/factory.d.ts +47 -0
  15. package/dist/extension/factory.js +49 -0
  16. package/dist/extension/index.d.ts +4 -0
  17. package/dist/extension/index.js +84 -0
  18. package/dist/routing/catalogue.d.ts +35 -0
  19. package/dist/routing/catalogue.js +79 -0
  20. package/dist/routing/dispatch.d.ts +34 -0
  21. package/dist/routing/dispatch.js +191 -0
  22. package/dist/routing/state.d.ts +13 -0
  23. package/dist/routing/state.js +65 -0
  24. package/dist/routing/types.d.ts +90 -0
  25. package/dist/routing/types.js +3 -0
  26. package/dist/settings/console.d.ts +55 -0
  27. package/dist/settings/console.js +266 -0
  28. package/dist/settings/store.d.ts +3 -0
  29. package/dist/settings/store.js +24 -0
  30. package/dist/settings/view.d.ts +11 -0
  31. package/dist/settings/view.js +46 -0
  32. package/package.json +59 -0
  33. package/skills/audit-docs/SKILL.md +171 -0
  34. package/skills/audit-pr/SKILL.md +201 -0
  35. package/skills/audit-pr/references/01_MERGE_GATES.md +24 -0
  36. package/skills/audit-pr/references/02_CLOSURE_AND_SCOPE_GATES.md +83 -0
  37. package/skills/audit-pr/references/03_AUDIT_PROCESS.md +69 -0
  38. package/skills/audit-pr/references/04_VERDICT.md +69 -0
  39. package/skills/audit-pr/references/05_ROUTING_AND_GUARDRAILS.md +58 -0
  40. package/skills/audit-pr/references/PORTABILITY.md +17 -0
  41. package/skills/design-feature/SKILL.md +162 -0
  42. package/skills/design-feature/references/INTERVIEW.md +52 -0
  43. package/skills/design-feature/references/PORTABILITY.md +15 -0
  44. package/skills/design-feature/references/UPSERT_EXAMPLE.md +8 -0
  45. package/skills/design-feature/references/WRITE_AND_UPSERT.md +92 -0
  46. package/skills/discover-repository-state/SKILL.md +83 -0
  47. package/skills/execute-phase/SKILL.md +115 -0
  48. package/skills/execute-phase/references/BATCH_AND_PORTABILITY.md +54 -0
  49. package/skills/execute-phase/references/CLOSEOUT.md +74 -0
  50. package/skills/execute-phase/references/DESCOPE.md +35 -0
  51. package/skills/execute-phase/references/EXECUTION_CONTRACT.md +147 -0
  52. package/skills/execute-phase/references/FOLDING.md +73 -0
  53. package/skills/execute-phase/references/FORGE_BODY.md +24 -0
  54. package/skills/execute-phase/references/HANDOFF.md +21 -0
  55. package/skills/execute-phase/references/OPPORTUNISTIC_FINDING.md +45 -0
  56. package/skills/execute-phase/references/PREFLIGHT.md +152 -0
  57. package/skills/execute-phase/references/UNIT_LOOP.md +88 -0
  58. package/skills/execute-phase/references/WORKFLOWS_FEATURE.md +37 -0
  59. package/skills/execute-phase/references/WORKFLOWS_FIX.md +43 -0
  60. package/skills/execute-phase/references/WORKFLOWS_LEGACY.md +26 -0
  61. package/skills/execute-phase/references/WORKFLOWS_SMALL_PHASED.md +38 -0
  62. package/skills/fold-findings/SKILL.md +141 -0
  63. package/skills/fold-findings/references/FOLD_POLICY.md +43 -0
  64. package/skills/fold-findings/references/FOLD_PROCESS.md +41 -0
  65. package/skills/generate-docs/SKILL.md +145 -0
  66. package/skills/generate-docs/references/ADAPTERS.md +15 -0
  67. package/skills/generate-docs/references/ADAPTER_DISCOVERY.md +33 -0
  68. package/skills/generate-docs/references/GENERATION_PROCESS.md +90 -0
  69. package/skills/init-workspace/SKILL.md +152 -0
  70. package/skills/init-workspace/references/BOOTSTRAP_DISCOVERY.md +70 -0
  71. package/skills/init-workspace/references/BOOTSTRAP_WRITE.md +58 -0
  72. package/skills/init-workspace/references/PORTABILITY.md +16 -0
  73. package/skills/init-workspace/references/UPGRADE.md +83 -0
  74. package/skills/log-session/SKILL.md +159 -0
  75. package/skills/loop-review-fold/SKILL.md +168 -0
  76. package/skills/orchestration-envelope/SKILL.md +81 -0
  77. package/skills/orchestration-envelope/references/TURN_CONTRACT.md +21 -0
  78. package/skills/phase-contract/SKILL.md +82 -0
  79. package/skills/plan-feature/SKILL.md +179 -0
  80. package/skills/plan-feature/references/ROUTING.md +83 -0
  81. package/skills/plan-feature-from-issue/SKILL.md +140 -0
  82. package/skills/plan-feature-scaffold/SKILL.md +93 -0
  83. package/skills/plan-feature-scaffold/references/SCAFFOLD_PROCESS.md +76 -0
  84. package/skills/plan-fix/SKILL.md +115 -0
  85. package/skills/plan-fix/references/PLANNING_PROCESS.md +118 -0
  86. package/skills/plan-fix/references/SPEC_CONTRACT.md +22 -0
  87. package/skills/planning-preflight/SKILL.md +130 -0
  88. package/skills/product-audit/SKILL.md +225 -0
  89. package/skills/product-audit/references/AUDIT_DIMENSIONS.md +24 -0
  90. package/skills/product-audit/references/AUDIT_PROCESS.md +85 -0
  91. package/skills/resolve-repository-state/SKILL.md +79 -0
  92. package/skills/review-a11y/SKILL.md +60 -0
  93. package/skills/review-brand/SKILL.md +65 -0
  94. package/skills/review-change/SKILL.md +156 -0
  95. package/skills/review-change/references/ADVERSARIAL_RECOMMENDATION.md +31 -0
  96. package/skills/review-change/references/ADVERSARIAL_SETUP.md +86 -0
  97. package/skills/review-change/references/ADVERSARIAL_SYNTHESIS.md +53 -0
  98. package/skills/review-change/references/OUTPUT_AND_GUARDRAILS.md +85 -0
  99. package/skills/review-change/references/PERSIST_AND_DECIDE.md +151 -0
  100. package/skills/review-change/references/PORTABILITY.md +74 -0
  101. package/skills/review-change/references/REVIEW_PROCESS.md +86 -0
  102. package/skills/review-code/SKILL.md +69 -0
  103. package/skills/review-debt/SKILL.md +72 -0
  104. package/skills/review-design/SKILL.md +60 -0
  105. package/skills/review-implementation/SKILL.md +108 -0
  106. package/skills/review-implementation/references/CLASSIFY.md +96 -0
  107. package/skills/review-implementation/references/FIND.md +35 -0
  108. package/skills/review-perf/SKILL.md +79 -0
  109. package/skills/review-security/SKILL.md +65 -0
  110. package/skills/review-seo/SKILL.md +65 -0
  111. package/skills/review-verify/SKILL.md +66 -0
  112. package/skills/ship-roadmap/SKILL.md +120 -0
  113. package/skills/ship-roadmap/references/ADVANCE.md +90 -0
  114. package/skills/ship-roadmap/references/AUDIT_AND_MERGE.md +64 -0
  115. package/skills/ship-roadmap/references/CLOSEOUT_AND_LOG.md +26 -0
  116. package/skills/ship-roadmap/references/FOUNDING.md +101 -0
  117. package/skills/ship-roadmap/references/GUARDRAILS.md +56 -0
  118. package/skills/ship-roadmap/references/MODEL_ROUTING.md +14 -0
  119. package/skills/ship-roadmap/references/PORTABILITY.md +34 -0
  120. package/skills/ship-roadmap/references/RECOVERY_AND_SELECTION.md +93 -0
  121. package/skills/ship-roadmap/references/STOP_CONDITIONS.md +9 -0
  122. package/skills/ship-roadmap/references/TERMINAL_REPORT.md +34 -0
  123. package/skills/triage-issue/SKILL.md +148 -0
  124. package/skills/triage-issue/references/AUDIT_FINDINGS.md +35 -0
  125. package/skills/triage-issue/references/FOLD_LEDGER.md +32 -0
  126. package/skills/triage-issue/references/ISSUE_PROCESS.md +101 -0
  127. package/skills/triage-issue/references/LABELS.md +83 -0
  128. package/skills/triage-issue/references/REVIEW_FINDING_PROCESS.md +41 -0
  129. package/skills/verification-contract/SKILL.md +77 -0
  130. package/skills/workflow-status/SKILL.md +143 -0
  131. package/skills/workflow-status/references/CRASH_RECOVERY.md +66 -0
  132. package/skills/workflow-status/references/ENVELOPE_CORE.md +107 -0
  133. package/skills/workflow-status/references/ENVELOPE_FIELDS.md +77 -0
  134. package/skills/workflow-status/references/GUARDRAILS.md +17 -0
  135. package/skills/workflow-status/references/PORTABILITY.md +14 -0
  136. package/skills/workflow-status/references/SENSOR_CORE.md +95 -0
  137. package/skills/workflow-status/references/SENSOR_SIGNALS.md +128 -0
@@ -0,0 +1,88 @@
1
+ ## Whole-unit execution loop
2
+
3
+ This route runs only when the user omitted `P<n>`. One user invocation advances
4
+ every remaining planned phase; phase boundaries still own scope, gates,
5
+ documentation, and commits.
6
+
7
+ ### Dispatch
8
+
9
+ - `execute-phase <NN>` → all remaining feature phases.
10
+ - `execute-phase --fix <n>` → all remaining fix phases.
11
+ - An explicit `P<n>` never loads this route and executes exactly one phase.
12
+ - Default `--max-attempts 3` limits repair attempts for the same unchanged gate
13
+ failure inside one phase. A positive user value overrides it.
14
+
15
+ ### Queue
16
+
17
+ Read the unit ledger once and select unfinished phases in ascending order. A
18
+ phase is unfinished when any task is unticked or its evidence/commit is absent.
19
+ Reconcile ticks against repository evidence before selection; contradictory
20
+ state with no unique next phase returns `AMBIGUOUS` and stops.
21
+
22
+ Materialize the queue before work as explicit phase IDs (`P2, P3, P4`), never
23
+ an empty array, ellipsis, or template placeholder. Every terminal report names
24
+ the phases actually attempted/completed.
25
+
26
+ The final `Hardening & PR`/close-out phase remains last. Never run it while an
27
+ earlier phase is unfinished.
28
+
29
+ ### Loop — one transaction per phase
30
+
31
+ For each queued phase:
32
+
33
+ 1. Recompute the frozen `ACCEPTANCE.md` blob and compare it with the acceptance
34
+ receipt. Mismatch/missing → `ACCEPTANCE GATE BLOCKED`; no edits.
35
+ 2. Run phase-lint, architectural-invariant, dependency/own-status fast paths,
36
+ and the selected mode workflow for this phase. A fail-closed gate ends the
37
+ whole invocation with its existing fixed block.
38
+ 3. Prefer a fresh worker context when the host supports subagents/headless
39
+ workers; give it only `ACCEPTANCE.md`, `SPEC.md`, this phase's tasks, the last
40
+ `progress.md` receipt, and the selected workflow contracts. The conductor
41
+ keeps receipts, never raw source context. Without that primitive, execute
42
+ inline and apply the same input cap.
43
+ 4. Implement the phase, run its exact validators and normal project gate, update
44
+ unit docs, and commit. Never commit red and never weaken a validator.
45
+ 5. On a red gate, feed back only the failing command, exit status, failing test
46
+ names, and smallest relevant output. Repair the same phase and retry. Same
47
+ failure with no diff twice, or `--max-attempts` exhausted, stops:
48
+
49
+ ```text
50
+ UNIT LOOP — <unit> BLOCKED at <P<n>>
51
+ Reason: <NO-PROGRESS|ATTEMPT-BUDGET> · Attempts: <n>
52
+ Last validator: <command> → <exit/status + compact failure>
53
+ Preserved: no red commit; acceptance blob <sha> unchanged
54
+
55
+ → Next: inspect the named blocker, then re-run /execute-phase <unit>
56
+ · architecture/product decision required → resolve it before resuming
57
+ · continue atomically → /execute-phase <unit> <P<n>>
58
+ ```
59
+
60
+ 6. Before the commit append a compact cycle receipt to `progress.md`:
61
+
62
+ ```text
63
+ ## Unit-loop receipt — <P<n>>
64
+ - Commit: pending · Gate: <command> (exit 0) · Acceptance blob: <sha>
65
+ - Next: <P<n+1>|close-out|none> · Attempts: <n>
66
+ ```
67
+
68
+ Commit it with the phase, then replace `pending` with the resulting SHA in
69
+ the next phase's reconciliation note (never amend an already-published
70
+ commit only to self-reference it). Reduce working state to the receipt.
71
+ 7. Do **not** stop for intermediate review checkpoint triggers. Record any
72
+ trigger in the receipt for final risk selection; the mandatory independent
73
+ end review covers the frozen final candidate once.
74
+
75
+ ### Terminal
76
+
77
+ When the last implementation phase is green, run the existing close-out phase:
78
+ mark done, push, open/link the PR, and leave the branch remote-current. Then:
79
+
80
+ ```text
81
+ UNIT LOOP — <unit> COMPLETE
82
+ Phases: <n> · Commits: <sha list> · Acceptance: <blob> · Gate: PASS
83
+ PR: <url>
84
+
85
+ → Next: /loop-review-fold <unit> — select the persisted review/fold route, then triage or replan unresolved findings
86
+ · manual path → /review-change, then /fold-findings and re-review as required
87
+ · merge gate after REVIEW-PASS → /audit-pr
88
+ ```
@@ -0,0 +1,37 @@
1
+ ## Feature mode workflow
2
+
3
+ **Atomic feature phase** — `docs/features/<NN>-<slug>/`. An explicit `P<n>`
4
+ runs this once; whole-unit mode calls it once per remaining phase.
5
+
6
+ 1. Verify branch (create if on `main`). **P1 only:** if the planning artifacts
7
+ (`docs/features/<NN>-<slug>/`) are still uncommitted, commit them first on the
8
+ feature branch — `git add docs/features/<NN>-<slug> && git commit -m "docs(<NN>-<slug>): planning artifacts"` —
9
+ so planning history stays separate from implementation.
10
+ 2. Read `progress.md` first (the phase handoff record — fixed schema above;
11
+ the last entry's `Remains:`/`Gotchas:` lines are the previous phase's
12
+ message to you), then `SPEC.md` + the requested phase's `TASKS.md`
13
+ section. That is the whole handoff — never rely on session memory from a
14
+ previous phase, and honor the *Context budget* for everything beyond
15
+ these files.
16
+ 3. Implement only that phase (see *Implementation guidance*).
17
+ 4. Run the gate (type-check, tests, build). **If red:** fix within the phase's
18
+ scope and re-run — never commit red. If the failure can't be fixed within
19
+ this phase's scope, record it in `known-issues.md`, leave the work
20
+ uncommitted, and stop with a clear report.
21
+ 5. Update the per-phase docs.
22
+ 6. Stage and commit: `git add <changed files>` then `git commit -m "<type>(<scope>): <summary>"` — one commit per phase, conventional format. Run this; don't just describe what should be committed.
23
+ 7. **Explicit-phase mode only:** check the review checkpoint triggers and make
24
+ the existing non-blocking recommendation when one fires. Whole-unit mode
25
+ records the trigger in its phase receipt and continues; it never interrupts
26
+ for an intermediate review. The end review stays mandatory.
27
+
28
+ **Resuming an interrupted phase (stated contract — any agent must honor it).**
29
+ If, on entry, the unit branch already carries dirty files or commits belonging
30
+ to the requested phase (a prior run died mid-turn — e.g. the driver process
31
+ restarted), do **not** restart the phase from scratch: reconcile against
32
+ `TASKS.md` first — verify each ticked task's evidence actually exists (code
33
+ path / test present), untick any tick without evidence, then continue from the
34
+ first unticked task. Idempotent re-entry is the contract `workflow-status`'s
35
+ crash-recovery verdict `RESUMABLE` relies on. If the ledger contradicts the
36
+ commits in a way that has no unique next task, stop and report instead of
37
+ guessing (that is its `AMBIGUOUS` verdict — a human decides).
@@ -0,0 +1,43 @@
1
+ ## Fix mode workflow
2
+
3
+ **`--fix`** — `docs/fix/<n>-<topic>/`, template `docs/fix/_TEMPLATE/SPEC.md`,
4
+ index `docs/fix/README.md`. A phased fix runs every remaining phase when `P<k>`
5
+ is omitted and one phase when it is explicit. The final `Hardening & PR` phase
6
+ runs close-out (steps 7–9) after prior phases are green; legacy SPECs run once.
7
+
8
+ 1. Verify the issue exists (`gh issue view <n>`); if it doesn't, create it
9
+ (`gh issue create --template fix.yml --body-file <path>`, body from the SPEC
10
+ written to a Markdown file — per the Markdown rule above).
11
+ 2. **If `docs/fix/<n>-<topic>/SPEC.md` already exists (e.g. from `plan-fix`), use it — do not re-draft.** Otherwise copy the template, fill every section, and register the entry in `docs/fix/README.md`.
12
+ 3. Verify branch (`fix/<n>-<topic>`).
13
+ 4. Implement the fix (no separate planning artifacts; the SPEC and its `## Phases` ledger are enough).
14
+ 5. Run the gate.
15
+ 6. Stage and commit: `git add <changed files>` then `git commit -m "fix(<scope>): <summary>"`. An explicit implementation phase **STOPs here — no push, no PR**; whole-unit mode continues to the next phase.
16
+ 7. **Mark done + open the PR — always (the close-out; in a phased SPEC these
17
+ are the final `Hardening & PR` phase's tasks).** Set the
18
+ `docs/fix/README.md` entry's status to `done` (built, not yet merged), commit,
19
+ `git push`, then open the PR with the body written to a Markdown file (per the
20
+ Markdown rule above): `gh pr create --base main --title "fix(<scope>): <summary>" --body-file <path>`
21
+ (the body includes `Closes #<n>`). Run the commands. Then, with the returned URL: **print it in the chat**,
22
+ set the `docs/fix/README.md` entry to `done · [#<pr>](<pr-url>)`, commit
23
+ (`docs: link PR #<n>`), and push again. A fix **never ends branch-only** —
24
+ it always leaves an open, chat-linked PR.
25
+ 8. **Mandatory review hand-off** → `/review-change`, then `audit-pr` as the merge gate.
26
+ Print the next step. **Keep the fix-index entry** until the PR is actually merged
27
+ (don't drop issue tracking early; the merge gate also blocks on pending docs).
28
+ 9. **After merge only:** remove the `docs/fix/README.md` entry (or archive it to the
29
+ project's fix history per its convention) — never before the merge.
30
+
31
+ **Resuming an interrupted phase (stated contract — any agent must honor it).**
32
+ If, on entry, the fix branch already carries dirty files or commits belonging
33
+ to the requested phase (a prior run died mid-turn — e.g. the driver process
34
+ restarted), do **not** restart the phase from scratch: reconcile against the
35
+ SPEC's `## Phases` checkboxes first — verify each ticked task's evidence
36
+ actually exists (code path / test present), untick any tick without evidence,
37
+ then continue from the first unticked task. Idempotent re-entry is the contract
38
+ `workflow-status`'s crash-recovery verdict `RESUMABLE` relies on. If the ledger
39
+ contradicts the commits in a way that has no unique next task, stop and report
40
+ instead of guessing (that is its `AMBIGUOUS` verdict — a human decides).
41
+
42
+ (The `Depends on:` check for fixes is the same Dependency gate above — it runs
43
+ before step 1, transitively, and blocks unless `--force`.)
@@ -0,0 +1,26 @@
1
+ ## Legacy mode workflow
2
+
3
+ **Legacy single-pass** — a SPEC **without** a `## Phases` section (drafted
4
+ before `plan-feature-scaffold` 1.8.0 / `plan-fix` 2.1.0) runs the whole unit
5
+ end-to-end in **one pass**. This is the fallback shared by small-feature and
6
+ `--fix` modes; a SPEC that carries `## Phases` never runs it.
7
+
8
+ 1. Verify branch.
9
+ 2. Read `SPEC.md` (+ `DECISIONS.md` if present) and the docs its documentation map points to.
10
+ 3. If the SPEC is ambiguous on scope / edge cases / UI, ask first — one question at a time, nothing it already answers.
11
+ 4. Implement end-to-end (see *Implementation guidance*).
12
+ 5. Run the gate; write `CHECKLIST.md` (below).
13
+ 6. Stage and commit: `git add <changed files>` then `git commit -m "<type>(<scope>): <summary>"`.
14
+ 7. **Mark done + open the PR — always (the close-out).** Flip the roadmap
15
+ row to `done` (it's *built*; merge state lives in the forge, not the status —
16
+ see *Marking done*), commit that flip, then `git push` and open the PR
17
+ (body written to a file as Markdown, per the Markdown rule above):
18
+ `gh pr create --base main --title "<type>(<scope>): <summary>" --body-file <path>`
19
+ (put `Closes #<n>` in that body when issue-born). Then, with the URL `gh pr create`
20
+ returned: **print it in the chat**, update the roadmap row to
21
+ `done · [#<pr>](<pr-url>)`, commit (`docs: link PR #<n>`), and push again —
22
+ the link commit rides the same open PR. A single-pass unit **never ends
23
+ branch-only** — it always leaves an open, chat-linked PR, regardless of the
24
+ review/audit still to come.
25
+ 8. **Mandatory review hand-off** → `/review-change` (the required final quality step;
26
+ see *Review checkpoint*), then `audit-pr` as the merge gate. Print the next step.
@@ -0,0 +1,38 @@
1
+ ## Small/phased mode workflow
2
+
3
+ **Phased single-pass units — the default for small (XS/S) feature SPECs.**
4
+ Every current XS/S feature SPEC carries `## Phases` (**≥ 2 phases**; final =
5
+ `Hardening & PR`). `execute-phase <NN>` runs every remaining phase; explicit
6
+ `P<k>` runs one. The SPEC's checkboxes are the execution ledger (there is no
7
+ `TASKS.md`): tick each task with evidence.
8
+
9
+ **Resuming an interrupted phase (stated contract — any agent must honor it).**
10
+ If, on entry, the unit branch already carries dirty files or commits belonging
11
+ to the requested phase (a prior run died mid-turn — e.g. the driver process
12
+ restarted), do **not** restart the phase from scratch: reconcile against the
13
+ SPEC's checkboxes first — verify each ticked task's evidence actually exists
14
+ (code path / test present), untick any tick without evidence, then continue
15
+ from the first unticked task. Idempotent re-entry is the contract
16
+ `workflow-status`'s crash-recovery verdict `RESUMABLE` relies on. If the ledger
17
+ contradicts the commits in a way that has no unique next task, stop and report
18
+ instead of guessing (that is its `AMBIGUOUS` verdict — a human decides).
19
+
20
+ Each phase appends its handoff entry to a `progress.md` beside the SPEC
21
+ (created on P1 — see *Phase handoff record*). An implementation phase runs the
22
+ per-phase steps below. Explicit-phase mode **STOPs after the phase commit — no
23
+ push, no PR** (the turn contract's box 5 "unit not finished" rule); unit-loop
24
+ mode continues. The final `Hardening & PR` phase runs close-out after every
25
+ prior phase is green; its pre-written tasks ARE the close-out chain.
26
+
27
+ Per-phase steps (implementation phases only):
28
+
29
+ 1. Verify branch.
30
+ 2. Read `SPEC.md` (+ `DECISIONS.md` if present) and the docs its documentation map points to.
31
+ 3. If the SPEC is ambiguous on scope / edge cases / UI, ask first — one question at a time, nothing it already answers.
32
+ 4. Implement end-to-end (see *Implementation guidance*).
33
+ 5. Run the gate; write `CHECKLIST.md` (below).
34
+ 6. Stage and commit: `git add <changed files>` then `git commit -m "<type>(<scope>): <summary>"`. **STOP** — no push, no PR until the final phase.
35
+
36
+ A SPEC **without** `## Phases` (drafted before those versions) runs the
37
+ **legacy single-pass flow** unchanged, end-to-end in one pass — see
38
+ [legacy workflow](WORKFLOWS_LEGACY.md).
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: fold-findings
3
+ user-invocable: true
4
+ version: 1.2.2
5
+ argument-hint: [finding-id …]
6
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
7
+ license: MIT
8
+ description: >
9
+ Repair persisted fix-now findings in compatible atomic batches: root-cause
10
+ fixes, green gate, commit/push, and per-row `folded: yes` updates. Never
11
+ reclassify or substitute backlog notes. Triggers: "fold-findings", "fix the
12
+ review findings", "repair audit blockers".
13
+ ---
14
+
15
+ # Fold Findings
16
+
17
+ Repair persisted fix-now findings. `review-change` and `audit-pr` classify; this
18
+ skill fixes each root cause, never relabeling, deferring, or weakening its check.
19
+
20
+ ## Turn contract — verify before ending the turn
21
+
22
+ ```
23
+ ✓ 1. Every finding taken up this turn produced its fixed per-finding output
24
+ line (FOLDED <sha> | DISPUTED <reason> | BLOCKED <missing input> |
25
+ REPLAN <proposed phase(s)>) — no finding silently skipped.
26
+ ✓ 2. For each FOLDED batch: the gate was RUN (not assumed) and green, one
27
+ atomic commit was RUN with its sha pasted, and (if the branch has an open PR)
28
+ `git push` was RUN immediately after that commit.
29
+ ✓ 3. The ledger row for each FOLDED finding was flipped `folded: no → yes`
30
+ in the same commit — never a bare code fix with the ledger left stale.
31
+ ✓ 4. No finding was reclassified: no severity downgrade, no fix-now →
32
+ non-fix-now, no "actually this is fine" — a genuine objection produced
33
+ `DISPUTED` with evidence for a user decision, never a silent drop/issue.
34
+ ✓ 5. The closing `Folded: n/m · Disputed: k · Blocked: j[ · Replan: r]` tally
35
+ and outcome-branched `→ Next:` block are printed as the ABSOLUTE last output.
36
+ Every affected finding ID is named in that block, joined with ` + `.
37
+ ```
38
+
39
+ Any unchecked box means the turn is not done.
40
+
41
+ ## When to use
42
+
43
+ After `/review-change` reports `REVIEW-FAIL` with fix-now rows, or `/audit-pr`
44
+ reports `VERDICT: BLOCKED` (every blocker is fix-now). If the ledger is absent or
45
+ incomplete, reconstruct rows from the verdict in Step 0. Never process
46
+ postpone/wontfix/promote/documented-tradeoff rows; those belong to `/triage-issue`.
47
+
48
+ ## Step 0 — Discover the project (always first)
49
+
50
+ Per Workflow conventions, read:
51
+
52
+ 1. The unit's `review-findings.md` under `docs/features/<NN>-<slug>/` or
53
+ `docs/fix/<n>-<topic>/`; schema is owned by `review-change`/`audit-pr`:
54
+
55
+ ```
56
+ | id | file:line | axis | severity | class | route | folded |
57
+ ```
58
+
59
+ After `VERDICT: BLOCKED`, append missing rows (`class: fix-now`, `folded: no`,
60
+ next free `Fn`, dedupe `file:line`+axis), commit as
61
+ `docs(<unit>): reconstruct fold ledger from audit-pr blockers`, then fold;
62
+ never report “no findings”.
63
+ 2. Queue `folded: no` rows; explicit IDs restrict it and leave other rows
64
+ untouched. Group by root cause, verifier and rollback boundary.
65
+ 3. The project's verification gate and forge CLI (use the declared forge).
66
+ 4. Whether the branch has an open PR; this decides immediate push after commit.
67
+
68
+ ## Progressive loading — fold queue
69
+
70
+ The allowlist is exactly these two paths; read both, in order, before changing
71
+ code or the ledger:
72
+
73
+ 1. [frozen classification, definition of fixed, and forbidden actions](references/FOLD_POLICY.md)
74
+ 2. [per-finding fold process](references/FOLD_PROCESS.md)
75
+
76
+ Both are normative and one hop from this file. Missing resource → stop; never
77
+ infer a classification or fold procedure.
78
+
79
+ ## Report — return exactly this structure (fixed output contract)
80
+
81
+ Per finding, in processing order:
82
+
83
+ ```
84
+ | <finding-id> | verdict: FOLDED <sha> | DISPUTED <reason → user decision> | BLOCKED <missing input> | REPLAN <proposed phase(s) → /execute-phase> |
85
+ ```
86
+
87
+ Then exactly:
88
+
89
+ ```
90
+ Folded: n/m · Disputed: k · Blocked: j · Replan: r
91
+ ```
92
+
93
+ Omit `· Replan: r` when `r = 0` (preserves the existing three-field format).
94
+
95
+ ## Guardrails
96
+
97
+ Scope is the ledger (or explicit ID subset); unlisted discoveries are proposals
98
+ for user triage. Batch only when one root-cause correction, validator set and
99
+ rollback boundary own the rows: one commit/push, individual ticks/lines. Split
100
+ otherwise. Do not widen beyond a finding's file/line/axis unless its root cause
101
+ requires it; explain that in the commit. Artifact language follows user
102
+ instruction > project docs language > English; conversation language never decides.
103
+
104
+ ## Portability (agents other than Claude Code)
105
+
106
+ Use explicit fallbacks when a primitive is absent: open named `SKILL.md` files in
107
+ a fresh context; use the strongest model for subtle logic/security and never
108
+ weaker than the author; process the compatible queue once and re-run only after
109
+ new review evidence.
110
+
111
+ ## Relationship to other skills
112
+
113
+ ```
114
+ review-change ──FAIL──┐
115
+ audit-pr ──BLOCKED─────┼──▶ fold-findings ──FOLDED──▶ re-run review-change / audit-pr
116
+ │ ──DISPUTED─▶ user decision
117
+ │ ──BLOCKED──▶ user supplies missing input
118
+ ```
119
+
120
+ `review-change`/`audit-pr` classify and persist; this skill only flips
121
+ `folded: no` to `yes` after a real fix. `execute-phase`'s embedded fold checklist
122
+ is the inline fallback; this standalone path keeps frozen classification and its
123
+ forbidden list and never runs above its tier. `DISPUTED` stops for user evidence;
124
+ no issue is created.
125
+
126
+ ## Done when
127
+
128
+ Every queued finding has its per-finding verdict and tally; every `FOLDED`
129
+ finding belongs to a pushed atomic batch and ticked row. Nothing is reclassified
130
+ or touched outside the queue.
131
+
132
+ ```
133
+ → Next: (branches on outcome; list every affected finding ID once as `F1 + F2 + …`)
134
+ · all FOLDED (<F1> + <F2> + …) → /review-change — re-review the branch now that all listed findings are fixed
135
+ · any DISPUTED (<F1> + <F2> + …) → user decision — resolve every evidenced dispute without creating backlog
136
+ · any BLOCKED (<F1> + <F2> + …) → supply the listed missing inputs, then re-run /fold-findings
137
+ · any REPLAN (<F1> + <F2> + …) → confirm all proposed SPEC phases, then /execute-phase on this same branch
138
+ ```
139
+
140
+ Replace placeholders with every actual affected finding ID before printing; never
141
+ print `<F2>`, `…`, or a single representative ID in a live hand-off.
@@ -0,0 +1,43 @@
1
+ ## Frozen classification (hard rule, never relaxed)
2
+
3
+ This skill **never** edits a finding's `severity`, `class`, or `route`, and
4
+ never moves a finding out of fix-now. Those fields belong to `review-change` /
5
+ `audit-pr`, the skills that produced the verdict — reopening them here would
6
+ let a fix turn into a reclassification. If, while investigating, the finding
7
+ genuinely looks wrong (not reproducible, already fixed elsewhere, or the
8
+ axis/severity is mistaken), that is **evidence for a dispute**, not a
9
+ license to edit the row: mark it `DISPUTED` with the evidence and stop for a
10
+ user decision — the row's `severity`/`class`/`route` stay exactly as written.
11
+
12
+ ## Definition of fixed (checklist — every box, every finding)
13
+
14
+ A finding is `FOLDED` only when **all** of these hold:
15
+
16
+ ```
17
+ ✓ A root-cause diff exists — the actual defect is fixed, not worked around
18
+ ✓ The gate is green (type-check + tests + build actually RUN, exit codes
19
+ pasted — never assumed)
20
+ ✓ If the finding was behavioral (a bug, not a style/debt nit): a test or
21
+ check was added/updated that fails without the fix and passes with it
22
+ ✓ The ledger row is ticked `folded: yes`, in the same commit as the fix
23
+ ✓ The commit is made AND pushed — an unpushed fix does not exist for CI, the
24
+ reviewer, or the merge gate (skip the push only if the branch has no PR yet
25
+ and the unit's own workflow says push happens later, at the PR step)
26
+ ```
27
+
28
+ ## Forbidden (never — even if it "would resolve the finding")
29
+
30
+ ```
31
+ ✗ Adding a known-issues.md / backlog entry instead of fixing the code
32
+ ✗ A decisions.md tradeoff note that accepts the defect as-is
33
+ ✗ Deleting, skipping (.skip, .only elsewhere), or loosening a test to make it pass
34
+ ✗ eslint-disable / @ts-ignore / equivalent suppression AS the fix
35
+ ✗ A TODO/FIXME stub left in place of the actual fix
36
+ ✗ Ticking `folded: yes` without a reviewer-mappable diff behind it
37
+ ✗ Fixing anything NOT on the ledger (or not in the explicit finding-ID
38
+ scope this turn was given) — record an independent proposal for explicit
39
+ user triage, never bundle it silently or create an issue
40
+ ```
41
+
42
+ Something forbidden looks like the only option → stop, do not apply it, and
43
+ mark the finding `DISPUTED` or `BLOCKED` with the reason instead.
@@ -0,0 +1,41 @@
1
+ ## Process
2
+
3
+ 1. **Build the queue.** Take every `folded: no` fix-now row, or the explicit ID
4
+ subset, in severity/id order. `replan-in-unit` rows emit `REPLAN`; they stay
5
+ on the same SPEC/branch/PR and never become issues.
6
+ 2. **Form the fewest atomic correction groups.** Findings may share one group
7
+ only when all boxes pass:
8
+
9
+ - one root cause or one homogeneous mechanical correction owns them;
10
+ - one validator set proves every member fixed;
11
+ - they can ship and roll back together without partial correctness;
12
+ - no member needs a separate product/architecture decision or stronger
13
+ release sequence;
14
+ - the combined diff remains reviewable and inside the current unit.
15
+
16
+ Shared files are neither required nor sufficient. A cross-file auth repair
17
+ may group; two unrelated nits in one file may not. Record each group's IDs,
18
+ shared cause, validators, and rollback boundary before editing.
19
+ 3. **Repair one group at a time.** Diagnose the shared cause, implement the
20
+ smallest complete correction, and add/update regression coverage for every
21
+ behavioral member. Use the strongest tier required by the most subtle member.
22
+ 4. **Verify.** Run the group's validators plus the normal project gate. Red →
23
+ continue repairing only this group. Same failure with no diff twice →
24
+ `BLOCKED NO-PROGRESS`; never commit red or weaken a check.
25
+ 5. **Persist atomically.** Flip every group row `folded: no → yes`; stage the
26
+ group diff + ledger; commit:
27
+
28
+ ```text
29
+ fix(<scope>): fold <F1+F2+…> — <shared correction>
30
+ ```
31
+
32
+ If the PR is open, push immediately. Emit one `FOLDED <same-sha>` line per
33
+ member so no finding disappears inside the batch.
34
+ 6. **Continue groups.** A blocked/disputed group does not prevent independent
35
+ groups from folding. Leave its rows `no` and emit individual outcomes.
36
+ 7. **Disputes.** Non-reproducible/already-fixed/wrong findings become
37
+ `DISPUTED <evidence → user decision>`; never edit classification or create an
38
+ issue.
39
+ 8. **Replan.** If the smallest correct group exceeds a reviewable correction,
40
+ emit `REPLAN` with proposed phases appended to the same unit. After user
41
+ confirmation, `/execute-phase <unit>` completes them and ticks the rows.
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: generate-docs
3
+ user-invocable: true
4
+ version: 2.0.1
5
+ argument-hint: "[NN-slug | fix-n | path/glob] [--review]"
6
+ author: "Gabriel Trabanco <gtrabanco@users.noreply.github.com>"
7
+ license: MIT
8
+ description: >
9
+ Generate incremental, diff-driven developer guides through the project's
10
+ detected docs adapter. Never regenerate the whole site, scaffold it, or edit
11
+ source. Triggers: "generate-docs", "generate the docs", "document this unit".
12
+ ---
13
+
14
+ # Generate Docs
15
+
16
+ Turn the knowledge produced by a unit of work into developer documentation a
17
+ contributor can read on the project's docs website — incrementally, as a
18
+ by-product of shipping, so a public repo's docs stay current instead of
19
+ rotting. A commit says what changed; a guide says how to use it ("how do I
20
+ create a domain event and where do I register its handler").
21
+
22
+ ## Turn contract — verify before ending the turn
23
+
24
+ ```
25
+ ✓ The docs adapter was resolved through the Step 0 detection checklist and the
26
+ outcome (adapter name, or NOT CONFIGURED) is stated in the report
27
+ ✓ Every generated/updated page is WRITTEN to disk (paths listed in the report)
28
+ and carries the provenance frontmatter — or zero pages were written and the
29
+ report says exactly why
30
+ ✓ The verify step was RUN (docs build command or link check) and its result
31
+ pasted — never assumed
32
+ ✓ Artifact language: explicit user instruction > the project's declared docs
33
+ language > English. The CONVERSATION language never decides
34
+ ✓ The fixed report block is printed, then the closing `→ Next:` block, as the
35
+ ABSOLUTE last output
36
+ ```
37
+
38
+ About to end the turn with any box unchecked? The turn is NOT done — complete
39
+ the missing box first (weak models drop end-of-document duties; this list is
40
+ first on purpose).
41
+
42
+ ## When to use
43
+
44
+ - **After finishing a unit of work** — `execute-phase` recommends this skill at
45
+ close-out when the project declares a docs site: document what the unit
46
+ changed while the context is fresh.
47
+ - **On demand** for a specific area: `generate-docs src/domain/events/`.
48
+ - **`--review`** — export the latest `review-change` report as a docs page so
49
+ humans can review findings from the website.
50
+ - Not for writing SPECs/planning docs (`plan-feature`), session journals
51
+ (`log-session`), or reviewing code (`review-change` produces the findings;
52
+ this skill only publishes an existing report on request).
53
+
54
+ ## Progressive loading — resolve the docs route
55
+
56
+ The reference allowlist is exactly the three paths below. Read them in this
57
+ order; every selected resource is normative and one hop from this entrypoint.
58
+
59
+ 1. Every invocation: read [adapter discovery](references/ADAPTER_DISCOVERY.md)
60
+ and resolve the adapter with evidence. `NOT CONFIGURED` stops writing.
61
+ 2. Configured adapter only: before choosing any output path or format, read
62
+ [adapter slots](references/ADAPTERS.md).
63
+ 3. Read [generation process](references/GENERATION_PROCESS.md) and execute the
64
+ scope, incrementality, map/review, verify, and report steps.
65
+
66
+ Do not load steps 2–3 after `NOT CONFIGURED`. Missing required resource → stop;
67
+ never guess an adapter, output path, or fixed contract.
68
+
69
+ ## Allowed & forbidden (fixed lists — no interpretation)
70
+
71
+ **Allowed:**
72
+ - Writing/updating pages under the adapter's guides location
73
+ - Updating only the adapter's declared manual sidebar config when the adapter
74
+ table requires it
75
+ - Running the declared docs build/verify command
76
+ - Reading anything (diff, code, docs)
77
+
78
+ **Forbidden — never, even if it "would help":**
79
+ - Whole-project doc regeneration (the incrementality checklist is the only
80
+ page selector)
81
+ - Editing source code, tests, or any config other than the adapter's declared
82
+ manual sidebar config
83
+ - Scaffolding a docs site (installing Astro/Starlight, creating configs)
84
+ - Writing outside the adapter's content locations, except that declared manual
85
+ sidebar config
86
+ - Pages without the provenance frontmatter
87
+ - Committing or pushing (the unit's workflow owns the commit)
88
+
89
+ ## Return exactly
90
+
91
+ ```
92
+ GENERATE DOCS — adapter: <starlight|docusaurus|markdown|NOT CONFIGURED> — scope: <scope>
93
+
94
+ | Page | Action | Source-unit | Subject paths |
95
+ |---|---|---|---|
96
+ | <content-path> | created|updated | <NN-slug> | <paths> |
97
+
98
+ Map: regenerated (<command>) | n/a — no map command declared | invalid output — <reason>
99
+ Review export: <page path> | not requested | no report available
100
+ Verify: <command + exit code | links checked: <n>, broken: 0 | n/a — not configured>
101
+ Pages: <n> written, <n> skipped by incrementality checklist
102
+ Decision: PASS | FAIL | NOT-CONFIGURED
103
+ ```
104
+
105
+ `FAIL` only when the verify step is red or a written page had to be reverted;
106
+ `NOT-CONFIGURED` per Step 0.5; `PASS` otherwise (including 0 pages).
107
+
108
+ ## Portability (agents other than Claude Code)
109
+
110
+ The workflow is the contract; Claude Code features are conveniences. On an
111
+ agent that lacks one, apply the fallback — never skip the step the feature
112
+ enables:
113
+
114
+ - **No slash-command menu** — where this skill says `/<skill>`, open that
115
+ skill's `SKILL.md` and follow it literally in a fresh conversation.
116
+ - **No per-skill `model:`/`effort:`** — writing guides is structured
117
+ summarization over a diff: a **mid-tier** model suffices; never below the
118
+ tier that can read the project's language accurately.
119
+ - **No argument passing** — state the scope in the invocation message
120
+ ("generate docs for 01-generate-docs"); the Process step 1 order still
121
+ applies.
122
+
123
+ ## Relationship to other skills
124
+
125
+ - **`execute-phase`** recommends this skill at unit close-out when the
126
+ documentation map declares a docs site (hand-off via `→ Next:` — never
127
+ composed in-turn).
128
+ - **`audit-docs`** detects orphan/stale generated pages via the provenance
129
+ frontmatter.
130
+ - **`init-workspace`** records the `Docs site` declaration this skill's Step 0
131
+ reads.
132
+ - Not a review: findings/quality belong to `review-change`.
133
+
134
+ ## Done when
135
+
136
+ - The adapter outcome is stated with evidence; every selected page is written
137
+ with provenance frontmatter; the verify step ran and is green (or the
138
+ NOT-CONFIGURED report was printed and nothing was written).
139
+ - The fixed report block was returned, then:
140
+
141
+ ```
142
+ → Next: commit these pages with the unit's close-out (they ride the unit's PR)
143
+ · unit already closed → commit as docs(<unit>): generated guides on the unit's branch
144
+ · adapter NOT CONFIGURED → add the Docs site block to the documentation map, then re-run /generate-docs
145
+ ```
@@ -0,0 +1,15 @@
1
+ ## Adapters (reference implementations)
2
+
3
+ The generic contract is the slots below; anything stack-specific lives only in
4
+ this table. Starlight is the first-class reference.
5
+
6
+ | Slot | Starlight (reference) | Docusaurus | Plain markdown (fallback) |
7
+ |---|---|---|---|
8
+ | Content dir | `src/content/docs/` (or the declared one) | `<site>/docs/` (or the declared one) | `docs/site/` |
9
+ | Page format | `.mdx`; frontmatter `title`, `description` + provenance keys | `.mdx`; frontmatter `title`, `description` + provenance keys | `.md`; H1 title + provenance keys in an HTML comment frontmatter block |
10
+ | Guides | `<content>/guides/<area>/<topic>.mdx` | `<content>/guides/<area>/<topic>.mdx` | `docs/site/guides/<area>/<topic>.md` |
11
+ | Knowledge map | `<content>/map/graph.json` + `<content>/map/<module>.mdx` wrappers | `<content>/map/graph.json` + `<content>/map/<module>.mdx` wrappers | `docs/site/map/graph.json` + `docs/site/map/<module>.md` |
12
+ | Review reports | `<content>/reviews/<unit>-<date>.mdx` | `<content>/reviews/<unit>-<date>.mdx` | `docs/site/reviews/<unit>-<date>.md` |
13
+ | Sidebar | Starlight autogenerated sidebar (directory-based); no manual sidebar edits | If the project declares a manual `sidebars.js`/`sidebars.ts`, update only that declared config; otherwise use the Docusaurus autogenerated sidebar and make no sidebar edit. Stop when the sidebar mode or declared config path cannot be resolved. | n/a — directory listing |
14
+ | Verify | declared build command (`npx astro check` / `astro build`) | declared Docusaurus build command (`npx docusaurus build` or project equivalent) | intra-docs link check |
15
+ | Assets | none generated | none generated | none generated |
@@ -0,0 +1,33 @@
1
+ ## Step 0 — Discover the project (always first)
2
+
3
+ Per the agent guide's **Workflow conventions** + **documentation map**, then
4
+ resolve the **docs adapter** with this checklist — fixed order, first match
5
+ wins, evidence required for the match:
6
+
7
+ 1. **Explicit declaration** — the documentation map contains a `Docs site`
8
+ block (format, content dir, build command, map command). Evidence: quote
9
+ the block. → use the declared adapter.
10
+ 2. **Starlight** — an `astro.config.*` exists AND `@astrojs/starlight` is in
11
+ the project's dependencies. Evidence: config path + the dependency line.
12
+ → Starlight adapter.
13
+ 3. **Docusaurus** — a `docusaurus.config.*` exists AND `@docusaurus/core` is a
14
+ dependency. Evidence: config path + the dependency line. → Docusaurus
15
+ adapter (same slots as Starlight; `.mdx` under the site's `docs/` dir,
16
+ sidebar per its convention).
17
+ 4. **Plain-markdown fallback** — a `docs/` directory exists. → plain-markdown
18
+ adapter (always available).
19
+ 5. **None of the above** → **NOT CONFIGURED**: write nothing. Print the report
20
+ with `Decision: NOT-CONFIGURED`, and include this snippet for the user to
21
+ add to their documentation map:
22
+
23
+ ```markdown
24
+ ## Docs site
25
+ - format: starlight | docusaurus | markdown
26
+ - content-dir: <path, e.g. src/content/docs/>
27
+ - build: <command, e.g. npx astro check | none>
28
+ - map: <command emitting a nodes/edges JSON | none>
29
+ ```
30
+
31
+ Detection is per invocation — never cached, never guessed. A monorepo with
32
+ more than one docs site is a documented limitation: use the first declaration
33
+ found and say so in the report (see the feature's `known-issues.md`).