@entelligentsia/forgecli 0.10.1 → 0.11.2

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 (161) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +21 -3
  3. package/dist/CHANGELOG-forge-plugin.md +22 -0
  4. package/dist/extensions/forgecli/add-pipeline.d.ts +19 -0
  5. package/dist/extensions/forgecli/add-pipeline.js +143 -0
  6. package/dist/extensions/forgecli/add-pipeline.js.map +1 -0
  7. package/dist/extensions/forgecli/add-task.d.ts +20 -0
  8. package/dist/extensions/forgecli/add-task.js +154 -0
  9. package/dist/extensions/forgecli/add-task.js.map +1 -0
  10. package/dist/extensions/forgecli/calibrate.d.ts +61 -0
  11. package/dist/extensions/forgecli/calibrate.js +488 -0
  12. package/dist/extensions/forgecli/calibrate.js.map +1 -0
  13. package/dist/extensions/forgecli/fix-bug.d.ts +9 -1
  14. package/dist/extensions/forgecli/fix-bug.js +70 -8
  15. package/dist/extensions/forgecli/fix-bug.js.map +1 -1
  16. package/dist/extensions/forgecli/forge-commands.js +15 -22
  17. package/dist/extensions/forgecli/forge-commands.js.map +1 -1
  18. package/dist/extensions/forgecli/forge-subagent.js +34 -7
  19. package/dist/extensions/forgecli/forge-subagent.js.map +1 -1
  20. package/dist/extensions/forgecli/forge-update-command.d.ts +9 -0
  21. package/dist/extensions/forgecli/forge-update-command.js +106 -7
  22. package/dist/extensions/forgecli/forge-update-command.js.map +1 -1
  23. package/dist/extensions/forgecli/health-check.d.ts +22 -1
  24. package/dist/extensions/forgecli/health-check.js +177 -4
  25. package/dist/extensions/forgecli/health-check.js.map +1 -1
  26. package/dist/extensions/forgecli/hook-dispatcher.d.ts +25 -1
  27. package/dist/extensions/forgecli/hook-dispatcher.js +104 -9
  28. package/dist/extensions/forgecli/hook-dispatcher.js.map +1 -1
  29. package/dist/extensions/forgecli/hooks/check-update.d.ts +81 -0
  30. package/dist/extensions/forgecli/hooks/check-update.js +308 -0
  31. package/dist/extensions/forgecli/hooks/check-update.js.map +1 -0
  32. package/dist/extensions/forgecli/hooks/forge-permissions.d.ts +32 -0
  33. package/dist/extensions/forgecli/hooks/forge-permissions.js +119 -0
  34. package/dist/extensions/forgecli/hooks/forge-permissions.js.map +1 -0
  35. package/dist/extensions/forgecli/hooks/triage-error.d.ts +23 -0
  36. package/dist/extensions/forgecli/hooks/triage-error.js +62 -0
  37. package/dist/extensions/forgecli/hooks/triage-error.js.map +1 -0
  38. package/dist/extensions/forgecli/hooks/write-guard.d.ts +28 -0
  39. package/dist/extensions/forgecli/hooks/write-guard.js +225 -0
  40. package/dist/extensions/forgecli/hooks/write-guard.js.map +1 -0
  41. package/dist/extensions/forgecli/index.js +60 -0
  42. package/dist/extensions/forgecli/index.js.map +1 -1
  43. package/dist/extensions/forgecli/init-context.d.ts +1 -1
  44. package/dist/extensions/forgecli/init-context.js +21 -6
  45. package/dist/extensions/forgecli/init-context.js.map +1 -1
  46. package/dist/extensions/forgecli/materialize.d.ts +16 -0
  47. package/dist/extensions/forgecli/materialize.js +195 -0
  48. package/dist/extensions/forgecli/materialize.js.map +1 -0
  49. package/dist/extensions/forgecli/migrate.d.ts +19 -0
  50. package/dist/extensions/forgecli/migrate.js +258 -0
  51. package/dist/extensions/forgecli/migrate.js.map +1 -0
  52. package/dist/extensions/forgecli/migration-engine.d.ts +111 -0
  53. package/dist/extensions/forgecli/migration-engine.js +533 -0
  54. package/dist/extensions/forgecli/migration-engine.js.map +1 -0
  55. package/dist/extensions/forgecli/quiz-agent.d.ts +17 -0
  56. package/dist/extensions/forgecli/quiz-agent.js +98 -0
  57. package/dist/extensions/forgecli/quiz-agent.js.map +1 -0
  58. package/dist/extensions/forgecli/remove-command.d.ts +17 -0
  59. package/dist/extensions/forgecli/remove-command.js +124 -0
  60. package/dist/extensions/forgecli/remove-command.js.map +1 -0
  61. package/dist/extensions/forgecli/report-bug.d.ts +25 -0
  62. package/dist/extensions/forgecli/report-bug.js +159 -0
  63. package/dist/extensions/forgecli/report-bug.js.map +1 -0
  64. package/dist/extensions/forgecli/retrospective.d.ts +19 -0
  65. package/dist/extensions/forgecli/retrospective.js +156 -0
  66. package/dist/extensions/forgecli/retrospective.js.map +1 -0
  67. package/dist/extensions/forgecli/run-sprint.js +34 -0
  68. package/dist/extensions/forgecli/run-sprint.js.map +1 -1
  69. package/dist/extensions/forgecli/run-task.d.ts +9 -1
  70. package/dist/extensions/forgecli/run-task.js +64 -10
  71. package/dist/extensions/forgecli/run-task.js.map +1 -1
  72. package/dist/extensions/forgecli/session-registry.d.ts +27 -2
  73. package/dist/extensions/forgecli/session-registry.js +52 -1
  74. package/dist/extensions/forgecli/session-registry.js.map +1 -1
  75. package/dist/extensions/forgecli/status-command.d.ts +19 -0
  76. package/dist/extensions/forgecli/status-command.js +140 -0
  77. package/dist/extensions/forgecli/status-command.js.map +1 -0
  78. package/dist/extensions/forgecli/store-query.d.ts +22 -0
  79. package/dist/extensions/forgecli/store-query.js +107 -0
  80. package/dist/extensions/forgecli/store-query.js.map +1 -0
  81. package/dist/extensions/forgecli/store-repair.d.ts +17 -0
  82. package/dist/extensions/forgecli/store-repair.js +123 -0
  83. package/dist/extensions/forgecli/store-repair.js.map +1 -0
  84. package/dist/extensions/forgecli/thread-switcher.js +213 -28
  85. package/dist/extensions/forgecli/thread-switcher.js.map +1 -1
  86. package/dist/extensions/forgecli/update-tools.d.ts +23 -0
  87. package/dist/extensions/forgecli/update-tools.js +136 -0
  88. package/dist/extensions/forgecli/update-tools.js.map +1 -0
  89. package/dist/extensions/forgecli/viewport-theme.js +4 -0
  90. package/dist/extensions/forgecli/viewport-theme.js.map +1 -1
  91. package/dist/forge-payload/.claude-plugin/plugin.json +1 -1
  92. package/dist/forge-payload/.schemas/config.schema.json +83 -0
  93. package/dist/forge-payload/.schemas/migrations.json +2049 -0
  94. package/dist/forge-payload/commands/regenerate.md +17 -1
  95. package/dist/forge-payload/meta/personas/README.md +16 -0
  96. package/dist/forge-payload/meta/personas/meta-architect.md +70 -0
  97. package/dist/forge-payload/meta/personas/meta-bug-fixer.md +73 -0
  98. package/dist/forge-payload/meta/personas/meta-collator.md +72 -0
  99. package/dist/forge-payload/meta/personas/meta-engineer.md +70 -0
  100. package/dist/forge-payload/meta/personas/meta-orchestrator.md +71 -0
  101. package/dist/forge-payload/meta/personas/meta-product-manager.md +82 -0
  102. package/dist/forge-payload/meta/personas/meta-qa-engineer.md +91 -0
  103. package/dist/forge-payload/meta/personas/meta-supervisor.md +92 -0
  104. package/dist/forge-payload/meta/skill-recommendations.md +154 -0
  105. package/dist/forge-payload/meta/skills/meta-architect-skills.md +43 -0
  106. package/dist/forge-payload/meta/skills/meta-bug-fixer-skills.md +43 -0
  107. package/dist/forge-payload/meta/skills/meta-collator-skills.md +41 -0
  108. package/dist/forge-payload/meta/skills/meta-engineer-skills.md +43 -0
  109. package/dist/forge-payload/meta/skills/meta-generic-skills.md +58 -0
  110. package/dist/forge-payload/meta/skills/meta-qa-engineer-skills.md +46 -0
  111. package/dist/forge-payload/meta/skills/meta-supervisor-skills.md +43 -0
  112. package/dist/forge-payload/meta/store-schema/bug.schema.md +71 -0
  113. package/dist/forge-payload/meta/store-schema/event.schema.md +76 -0
  114. package/dist/forge-payload/meta/store-schema/feature.schema.md +65 -0
  115. package/dist/forge-payload/meta/store-schema/sprint.schema.md +64 -0
  116. package/dist/forge-payload/meta/store-schema/task.schema.md +78 -0
  117. package/dist/forge-payload/meta/templates/meta-code-review.md +26 -0
  118. package/dist/forge-payload/meta/templates/meta-plan-review.md +28 -0
  119. package/dist/forge-payload/meta/templates/meta-plan.md +28 -0
  120. package/dist/forge-payload/meta/templates/meta-progress.md +25 -0
  121. package/dist/forge-payload/meta/templates/meta-retrospective.md +28 -0
  122. package/dist/forge-payload/meta/templates/meta-sprint-manifest.md +26 -0
  123. package/dist/forge-payload/meta/templates/meta-sprint-requirements.md +91 -0
  124. package/dist/forge-payload/meta/templates/meta-task-prompt.md +26 -0
  125. package/dist/forge-payload/meta/tool-specs/collate.spec.md +88 -0
  126. package/dist/forge-payload/meta/tool-specs/generation-manifest.spec.md +139 -0
  127. package/dist/forge-payload/meta/tool-specs/manage-config.spec.md +143 -0
  128. package/dist/forge-payload/meta/tool-specs/seed-store.spec.md +91 -0
  129. package/dist/forge-payload/meta/tool-specs/store-cli.spec.md +328 -0
  130. package/dist/forge-payload/meta/tool-specs/validate-store.spec.md +191 -0
  131. package/dist/forge-payload/meta/workflows/_fragments/context-injection.md +75 -0
  132. package/dist/forge-payload/meta/workflows/_fragments/event-emission-schema.md +73 -0
  133. package/dist/forge-payload/meta/workflows/_fragments/finalize.md +13 -0
  134. package/dist/forge-payload/meta/workflows/_fragments/friction-emit.md +73 -0
  135. package/dist/forge-payload/meta/workflows/_fragments/progress-reporting.md +38 -0
  136. package/dist/forge-payload/meta/workflows/_fragments/store-cli-verbs.md +39 -0
  137. package/dist/forge-payload/meta/workflows/meta-approve.md +119 -0
  138. package/dist/forge-payload/meta/workflows/meta-collate.md +89 -0
  139. package/dist/forge-payload/meta/workflows/meta-commit.md +93 -0
  140. package/dist/forge-payload/meta/workflows/meta-enhance.md +286 -0
  141. package/dist/forge-payload/meta/workflows/meta-fix-bug.md +501 -0
  142. package/dist/forge-payload/meta/workflows/meta-implement.md +132 -0
  143. package/dist/forge-payload/meta/workflows/meta-migrate.md +455 -0
  144. package/dist/forge-payload/meta/workflows/meta-orchestrate.md +993 -0
  145. package/dist/forge-payload/meta/workflows/meta-plan-task.md +133 -0
  146. package/dist/forge-payload/meta/workflows/meta-quiz-agent.md +135 -0
  147. package/dist/forge-payload/meta/workflows/meta-retrospective.md +65 -0
  148. package/dist/forge-payload/meta/workflows/meta-review-implementation.md +119 -0
  149. package/dist/forge-payload/meta/workflows/meta-review-plan.md +108 -0
  150. package/dist/forge-payload/meta/workflows/meta-review-sprint-completion.md +65 -0
  151. package/dist/forge-payload/meta/workflows/meta-sprint-intake.md +76 -0
  152. package/dist/forge-payload/meta/workflows/meta-sprint-plan.md +147 -0
  153. package/dist/forge-payload/meta/workflows/meta-update-implementation.md +76 -0
  154. package/dist/forge-payload/meta/workflows/meta-update-plan.md +76 -0
  155. package/dist/forge-payload/meta/workflows/meta-validate.md +111 -0
  156. package/dist/forge-payload/tools/check-structure.cjs +344 -0
  157. package/dist/forge-payload/tools/list-skills.js +76 -0
  158. package/dist/forge-payload/tools/store-cli.cjs +27 -1
  159. package/dist/forge-payload/tools/substitute-placeholders.cjs +60 -8
  160. package/dist/forge-payload/tools/verify-integrity.cjs +86 -0
  161. package/package.json +2 -2
@@ -0,0 +1,133 @@
1
+ ---
2
+ requirements:
3
+ reasoning: High
4
+ context: Medium
5
+ speed: Low
6
+ audience: subagent
7
+ phase: plan
8
+ context:
9
+ architecture: true
10
+ prior_summaries: delta
11
+ persona: summary
12
+ master_index: false
13
+ diff_mode: false
14
+ deps:
15
+ personas: [architect]
16
+ skills: [architect, generic]
17
+ templates: [PLAN_TEMPLATE, TASK_PROMPT_TEMPLATE]
18
+ sub_workflows: [review_plan]
19
+ kb_docs: [architecture/stack.md]
20
+ config_fields: [commands.test, paths.engineering]
21
+ ---
22
+
23
+ # 🌱 Meta-Workflow: Plan Task
24
+
25
+ ## Purpose
26
+
27
+ The Engineer reads the task prompt, researches the codebase, and produces an implementation plan.
28
+
29
+ ## Algorithm
30
+
31
+ ```
32
+
33
+ 0. Pre-flight Gate Check:
34
+ - Resolve FORGE_ROOT (`node -e "console.log(require('./.forge/config.json').paths.forgeRoot)"`).
35
+ - **Entity-mode resolution:** read the kickoff arguments. `--task {id}` → `entity_kind = "task"`, `record_id = {id}`. `--bug {id}` → `entity_kind = "bug"`, `record_id = {id}`. All store-cli calls below substitute `{entity_kind}` and `{record_id}` for the literal "task"/{taskId} placeholders.
36
+ - Run: `node "$FORGE_ROOT/tools/preflight-gate.cjs" --phase plan --{entity_kind} {record_id}`
37
+ - Exit 1 (gate failed) → print stderr and HALT. Do not proceed; do not attempt to produce the artifact.
38
+ - Exit 2 (misconfiguration) → print stderr and HALT.
39
+ - Exit 0 → continue.
40
+ 1. Load Context:
41
+ - Read `.forge/personas/architect.md` first; print the persona identity line (emoji, name, tagline) to stdout before any other tool use.
42
+ - store-cli verbs: `read` | `list` | `write` | `emit` | `update-status` | `set-summary` | `describe` | `nlp` | `query` | `delete` — there is no `get`/`set`/`find`. See `_fragments/store-cli-verbs.md` for full notes; run `--help` before improvising.
43
+ - Read task prompt (source of truth)
44
+ - Query the store for this task and any related entities:
45
+ ```sh
46
+ node "$FORGE_ROOT/tools/store-cli.cjs" nlp "{taskId} with sprint with feature"
47
+ ```
48
+ Use store results directly if they include title, status, sprint, and excerpt.
49
+ - Read the architecture summary from your injected context (if present).
50
+ - Read business domain docs relevant to the task
51
+ - Read stack checklist
52
+
53
+ 2. Research:
54
+ - Identify files for modification (Glob, Grep, Read)
55
+ - Map existing patterns in the target area
56
+ - Identify existing tests to be maintained or expanded
57
+ - Identify whether the change is **material** (triggers version bump) or not:
58
+ - Bug fixes to any command, hook, tool spec, or workflow → material
59
+ - Tool-spec changes that alter generated tool behaviour → material
60
+ - Command-file changes that alter behaviour → material
61
+ - Hook changes → material
62
+ - Schema changes to `.forge/store/` or `.forge/config.json` → material
63
+ - Docs-only changes → NOT material
64
+
65
+ 3. Plan:
66
+ - Generate PLAN.md using the project plan template
67
+ - Ensure inclusion of: Objective, Approach, Files to Modify, Data Model Changes, Testing Strategy, Acceptance Criteria, and Operational Impact
68
+
69
+ 4. Knowledge Writeback:
70
+ - If new patterns were discovered, update architecture or business domain docs
71
+
72
+ 5. Finalize:
73
+ - Transitions:
74
+ - **Task mode** — legal target from this step: `draft → planned`. Out-of-band escapes (any state): `plan-revision-required`, `code-revision-required`, `blocked`, `escalated`, `abandoned`.
75
+ Update status: `node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {taskId} status planned`
76
+ - **Bug mode** — NO status write. The bug remains `in-progress` until the commit phase transitions it to `fixed`. Writing `bug.status` here violates `meta-fix-bug.md § Iron Laws #2`.
77
+ - **Do NOT emit a phase event yourself.** The orchestrator owns event emission — it composes the canonical event from runtime telemetry (model, provider, tokens, wall times) plus the SUMMARY you write in the next step. Subagents that call `store-cli emit` for phase events hallucinate runtime facts (see Plan 11 / Slice 2). Write the SUMMARY and return.
78
+
79
+ 6. Emit Summary Sidecar:
80
+ - Write `PLAN-SUMMARY.json` (task mode) or `BUG-FIX-PLAN-SUMMARY.json` (bug mode) to the record's directory. Shape:
81
+ ```json
82
+ {
83
+ "objective": "<one sentence — what this plan sets out to build>",
84
+ "key_changes": ["<up to 12 bullets, 200 chars each>"],
85
+ "verdict": "n/a",
86
+ "written_at": "<current ISO 8601 timestamp>",
87
+ "artifact_ref":"PLAN.md"
88
+ }
89
+ ```
90
+ - Call (task mode):
91
+ ```
92
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-summary {taskId} plan \
93
+ engineering/sprints/{sprint}/{task}/PLAN-SUMMARY.json
94
+ ```
95
+ Or (bug mode):
96
+ ```
97
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-bug-summary {bugId} plan \
98
+ engineering/bugs/{bugDir}/BUG-FIX-PLAN-SUMMARY.json
99
+ ```
100
+ - If the set-summary call exits non-zero, fix the sidecar JSON and retry. Do not proceed without a valid summary.
101
+ ```
102
+
103
+ ## Iron Laws
104
+
105
+ - Follow the Algorithm step by step. No code, pseudocode, or implementation sketches in the plan.
106
+ - Read `.forge/personas/architect.md` first; print the persona identity line to stdout before any other tool use.
107
+ - All store I/O via `forge_store` (or `node "$FORGE_ROOT/tools/store-cli.cjs"`). Never edit `.forge/store/*.json` directly.
108
+
109
+ ## Store-Write Verification
110
+
111
+ Every `forge_store` write MUST succeed before advancing. If `store-cli` exits
112
+ non-zero or the `PreToolUse` write-boundary hook blocks the call (exit 2):
113
+
114
+ 1. Parse the structured error (names the offending field + schema file).
115
+ 2. Correct the JSON to satisfy the schema.
116
+ 3. Retry. Repeat up to 3 times.
117
+ 4. After 3 failures, halt and escalate with original payload, corrected payload, and all error messages.
118
+
119
+ Never set `FORGE_SKIP_WRITE_VALIDATION=1` — operator-only emergency switch.
120
+
121
+ ## Friction Emit
122
+ Emit `type:friction` `{workflow:plan-task, persona:architect, issue}` per `_fragments/friction-emit.md`.
123
+
124
+ ## Generation Instructions
125
+
126
+ - **Workflow Structure:** Strict "Algorithm" block format.
127
+ - **Markers (required by `/forge:plan` kickoff shim):** Generated workflow MUST include the "Iron Laws" section, the "Store-Write Verification" section, the literal `forge_store` token, and the `architect.md` persona path. Missing any → kickoff shim refuses to dispatch.
128
+ - **Context Isolation:** Forbid inline execution. Delegate complex sub-tasks via the `Agent` tool.
129
+ - **Project Specifics:**
130
+ - Replace architecture/domain doc placeholders with actual project file paths.
131
+ - Embed the project's specific PLAN template path.
132
+ - **Token Reporting:** See `_fragments/finalize.md` — wire via `file_ref:`.
133
+ - **Event Emission:** Ensure the "complete" event includes the `eventId` passed by the orchestrator.
@@ -0,0 +1,135 @@
1
+ ---
2
+ requirements:
3
+ reasoning: Medium
4
+ context: High
5
+ speed: Low
6
+ deps:
7
+ personas: [qa-engineer]
8
+ skills: [qa-engineer, generic]
9
+ templates: []
10
+ sub_workflows: []
11
+ kb_docs: [architecture/stack.md, MASTER_INDEX.md]
12
+ config_fields: [paths.engineering]
13
+ ---
14
+
15
+ # 🍵 Meta-Workflow: Quiz Agent
16
+
17
+ ## Purpose
18
+
19
+ Verify that an agent has correctly loaded and understood the project's knowledge
20
+ base before beginning a high-stakes task (e.g. a schema change, a significant
21
+ refactor, a deployment, or a migration step).
22
+
23
+ The quiz is short — 5–7 questions drawn directly from the project's own architecture
24
+ and process docs. Vague answers fail. Pass requires specific, factual responses.
25
+
26
+ ## Algorithm
27
+
28
+ ```
29
+ 1. Ask the quiz questions below (in order).
30
+
31
+ 2. Evaluate each answer:
32
+ - PASS: specific and factually correct per the project KB
33
+ - FAIL: vague ("some validation"), wrong, or "I'm not sure"
34
+
35
+ 3. Verdict:
36
+ - All pass → proceed with the original task.
37
+ - Any fail → re-read the KB docs listed in "Fail Action", then retry the quiz.
38
+ - Fail twice → escalate to the user before beginning the task.
39
+ ```
40
+
41
+ ## Questions
42
+
43
+ (Project-specific questions are generated here during init — see Generation Instructions.)
44
+
45
+ ## Pass Criteria
46
+
47
+ All questions answered correctly and specifically. Vague answers fail.
48
+
49
+ ## Fail Action
50
+
51
+ Re-read the project knowledge base docs listed here, then retry:
52
+
53
+ (Project-specific KB doc paths are embedded here during init.)
54
+
55
+ Then retry the quiz. If the agent fails twice, escalate to the user before
56
+ beginning the task.
57
+
58
+ ---
59
+
60
+ ## Generation Instructions
61
+
62
+ ### Overview
63
+
64
+ The generated `quiz_agent.md` tests whether an agent genuinely understands
65
+ THIS project's conventions, architecture, and processes — not Forge in general.
66
+
67
+ Questions must be answerable only by reading the project's own KB docs.
68
+ Generic questions about Claude Code or Forge internals are NOT appropriate
69
+ unless this project's KB explicitly documents them as project conventions.
70
+
71
+ ### Question generation
72
+
73
+ Read the following (already generated by earlier phases):
74
+ - `{KB_PATH}/architecture/` — all .md files
75
+ - `{KB_PATH}/business-domain/` — all .md files
76
+ - `{KB_PATH}/stack-checklist.md`
77
+ - `{KB_PATH}/MASTER_INDEX.md`
78
+
79
+ Generate 5–7 questions that test specific knowledge of this project. Each
80
+ question must:
81
+ 1. Reference a specific fact from the project KB (not common knowledge)
82
+ 2. Have an unambiguous correct answer findable in the KB
83
+ 3. Cover at least three of these categories:
84
+ - Stack conventions (language, framework rules, linting, build)
85
+ - Architecture (key components, service boundaries, data flow)
86
+ - Domain entities (core business objects and their relationships)
87
+ - Process (how work is tracked, committed, reviewed, deployed)
88
+ - Constraints (what is explicitly forbidden or required)
89
+
90
+ Avoid yes/no questions. Prefer "what", "where", "name", "describe" forms.
91
+
92
+ ### Fail Action doc list
93
+
94
+ List the architecture and business-domain docs that cover the question topics.
95
+ Use the actual paths as generated (e.g. `{KB_PATH}/architecture/stack.md`).
96
+ Include `{KB_PATH}/stack-checklist.md` always.
97
+
98
+ ### File structure
99
+
100
+ ```markdown
101
+ # 🍵 Workflow: Quiz Agent — {Project Name}
102
+
103
+ ## Purpose
104
+
105
+ Verify that an agent has correctly loaded and understood the {Project Name}
106
+ knowledge base before beginning a high-stakes task.
107
+
108
+ ---
109
+
110
+ ## Questions
111
+
112
+ 1. **[Category]:** [Question text]
113
+ 2. ...
114
+
115
+ ## Pass Criteria
116
+
117
+ All [N] questions answered correctly and specifically. Vague answers
118
+ ("generally something", "I think it's...") fail.
119
+
120
+ ## Fail Action
121
+
122
+ Re-read:
123
+ - `{KB_PATH}/architecture/[doc1].md`
124
+ - `{KB_PATH}/architecture/[doc2].md`
125
+ - `{KB_PATH}/stack-checklist.md`
126
+ - (any other docs covering the question topics)
127
+
128
+ Then retry the quiz. If the agent fails twice, escalate to the user before
129
+ beginning the task.
130
+ ```
131
+
132
+ ### Token Reporting
133
+
134
+ The generated `quiz_agent.md` does NOT include Token Reporting or Event Emission —
135
+ it is invoked inline by other workflows (not by the orchestrator as a task phase).
@@ -0,0 +1,65 @@
1
+ ---
2
+ requirements:
3
+ reasoning: High
4
+ context: Medium
5
+ speed: Low
6
+ deps:
7
+ personas: [architect]
8
+ skills: [architect, generic]
9
+ templates: [RETROSPECTIVE_TEMPLATE]
10
+ sub_workflows: []
11
+ kb_docs: [architecture/stack.md]
12
+ config_fields: [paths.engineering]
13
+ ---
14
+
15
+ # 🗻 Meta-Workflow: Retrospective
16
+
17
+ ## Purpose
18
+
19
+ Close a sprint by reviewing learnings, updating the knowledge base, and improving workflows.
20
+
21
+ ## Algorithm
22
+
23
+ ```
24
+ 1. Load Context:
25
+ - Read all task manifests for the sprint
26
+ - Read all event logs (including token usage)
27
+ - Read all retrospective notes gathered during the sprint
28
+
29
+ 2. Analysis:
30
+ - Calculate total sprint cost (tokens/USD)
31
+ - Identify "bottleneck" tasks (high iteration counts or long duration)
32
+ - Analyze common failure modes in reviews
33
+
34
+ 3. Knowledge Update:
35
+ - Update architecture/domain docs with "lessons learned"
36
+ - Propose improvements to meta-workflows based on analysis
37
+ - Update stack-checklist with new verification steps
38
+
39
+ 4. Finalize:
40
+ - Write SPRINT_RETROSPECTIVE.md
41
+ - Update sprint status via `node "$FORGE_ROOT/tools/store-cli.cjs" update-status sprint {sprintId} status retrospective-done`
42
+ - Run `node "$FORGE_ROOT/tools/collate.cjs" {sprintId} --purge-events`
43
+ This single deterministic step: generates COST_REPORT.md from all
44
+ accumulated events, then deletes `.forge/store/events/{sprintId}/`.
45
+ COST_REPORT.md is the durable record; the raw event files are not
46
+ retained after retrospective close.
47
+ - **Do NOT emit a phase event yourself.** The orchestrator (or kickoff handler) owns event emission — it composes the canonical event from runtime telemetry (model, provider, tokens, wall times) plus the SUMMARY you write in the next step. Subagents that call `store-cli emit` for phase events hallucinate runtime facts (see Plan 11 / Slice 2). Write the SUMMARY and return.
48
+ (tombstone — written after the purge; the only event in the directory
49
+ going forward)
50
+ ```
51
+
52
+ ## Generation Instructions
53
+
54
+ - **Persona Self-Load:** The generated workflow MUST begin by reading `.forge/personas/architect.md` as its first step (before any other tool use). This replaces the former inline `## Persona` section. The persona identity line (emoji, name, tagline) should be printed to stdout after reading the file.
55
+ - **Workflow Structure:** The generated `retrospective.md` must follow the strict "Algorithm" block format.
56
+ - **Context Isolation:** Forbid inline execution of cost analysis or doc updates; use the `Agent` tool for sub-tasks.
57
+ - **Project Specifics:**
58
+ - Reference project's cost reporting templates.
59
+ - **Token Reporting:** The generated workflow MUST mandate the following before returning:
60
+ 1. Probe session token usage: invoke `/cost` if the host runtime supports it
61
+ (Claude Code only); on any other runtime treat as unavailable and proceed.
62
+ Do NOT shell out to a `cost-cli.cjs` — there is no such tool.
63
+ 2. Parse: `inputTokens`, `outputTokens`, `cacheReadTokens`, `cacheWriteTokens`, `estimatedCostUSD`.
64
+ 3. Write the usage sidecar via `node "$FORGE_ROOT/tools/store-cli.cjs" emit {sprintId} '{sidecar-json}' --sidecar`.
65
+ - **Event Emission:** Ensure the "complete" event includes the `eventId` passed by the orchestrator.
@@ -0,0 +1,119 @@
1
+ ---
2
+ requirements:
3
+ reasoning: High
4
+ context: Medium
5
+ speed: Low
6
+ audience: subagent
7
+ phase: review-code
8
+ context:
9
+ architecture: false
10
+ prior_summaries: delta
11
+ persona: summary
12
+ master_index: false
13
+ diff_mode: true
14
+ deps:
15
+ personas: [supervisor]
16
+ skills: [supervisor, generic]
17
+ templates: [CODE_REVIEW_TEMPLATE]
18
+ sub_workflows: []
19
+ kb_docs: [architecture/stack.md, architecture/routing.md]
20
+ config_fields: [commands.test, paths.engineering]
21
+ ---
22
+
23
+ # 🌿 Meta-Workflow: Review Implementation
24
+
25
+ ## Purpose
26
+
27
+ The Supervisor reviews the Engineer's implementation for correctness, quality, and compliance with the approved plan.
28
+
29
+ ## Iron Laws
30
+
31
+ - Evaluate the code against the approved PLAN.md and the original task prompt. Do not accept "it works" as a substitute for "it is correct and maintainable."
32
+ - Read `.forge/personas/supervisor.md` first; print the persona identity line (emoji, name, tagline) to stdout before any other tool use.
33
+ - All store I/O via `forge_store` (or `node "$FORGE_ROOT/tools/store-cli.cjs"`). Never edit `.forge/store/*.json` directly.
34
+
35
+ ## Store-Write Verification
36
+
37
+ Every `forge_store` write MUST succeed before advancing. If `store-cli` exits
38
+ non-zero or the `PreToolUse` write-boundary hook blocks the call (exit 2):
39
+
40
+ 1. Parse the structured error (names the offending field + schema file).
41
+ 2. Correct the JSON to satisfy the schema.
42
+ 3. Retry. Repeat up to 3 times.
43
+ 4. After 3 failures, halt and escalate with original payload, corrected payload, and all error messages.
44
+
45
+ Never set `FORGE_SKIP_WRITE_VALIDATION=1` — operator-only emergency switch.
46
+
47
+ ## Algorithm
48
+
49
+ ```
50
+
51
+ 0. Pre-flight Gate Check:
52
+ - Resolve FORGE_ROOT (`node -e "console.log(require('./.forge/config.json').paths.forgeRoot)"`).
53
+ - **Entity-mode resolution:** read the kickoff arguments. `--task {id}` → `entity_kind = "task"`, `record_id = {id}`. `--bug {id}` → `entity_kind = "bug"`, `record_id = {id}`. All store-cli calls below substitute `{entity_kind}` and `{record_id}` for the literal "task"/{taskId} placeholders.
54
+ - Run: `node "$FORGE_ROOT/tools/preflight-gate.cjs" --phase review-code --{entity_kind} {record_id}`
55
+ - Exit 1 (gate failed) → print stderr and HALT. Do not proceed; do not attempt to produce the artifact.
56
+ - Exit 2 (misconfiguration) → print stderr and HALT.
57
+ - Exit 0 → continue.
58
+ 1. Load Context:
59
+ - Read task prompt
60
+ - Read approved PLAN.md
61
+ - Read PROGRESS.md
62
+
63
+ **Read mode: diff-first.** Read `git diff $(git merge-base HEAD origin/main)..HEAD -- <files-listed-in-PLAN>` first. Read full source files only when the diff context is insufficient to judge a finding (e.g., the change is an inversion of an invariant defined elsewhere). Do not pre-load full source — tool calls earn their tokens.
64
+
65
+ 2. Review:
66
+ - Verify all plan steps were executed
67
+ - Review code for quality, security, and architecture alignment
68
+ - Verify test evidence in PROGRESS.md is authentic and complete
69
+
70
+ 3. Verdict:
71
+ - Write CODE_REVIEW.md using the format:
72
+ **Verdict:** [Approved | Revision Required]
73
+ - If Revision Required: provide numbered, actionable items
74
+ - If Approved: provide any advisory notes
75
+
76
+ 4. Knowledge Writeback:
77
+ - Update stack-checklist.md if new patterns or pitfalls were discovered
78
+
79
+ 5. Finalize:
80
+ - Transitions:
81
+ - **Task mode** — Update status: `node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {taskId} status review-approved` (if Approved) or `... status code-revision-required` (if Revision Required).
82
+ - **Bug mode** — NO status write. The bug remains `in-progress`. The verdict signal travels through `summaries.code_review.verdict` (read by `read-verdict.cjs § BUG_PHASE_VERDICT_SOURCE`), not `bug.status`. Writing `bug.status` here violates `meta-fix-bug.md § Iron Laws #2`.
83
+ - **Do NOT emit a phase event yourself.** The orchestrator (or kickoff handler) owns event emission — it composes the canonical event from runtime telemetry (model, provider, tokens, wall times) plus the SUMMARY you write in the next step. Subagents that call `store-cli emit` for phase events hallucinate runtime facts (see Plan 11 / Slice 2). Write the SUMMARY and return.
84
+
85
+ 6. Emit Summary Sidecar:
86
+ - Write `REVIEW-IMPL-SUMMARY.json` to the record's directory with the following shape:
87
+ ```json
88
+ {
89
+ "objective": "<one sentence — what this review assessed>",
90
+ "findings": ["<up to 12 bullets, 200 chars each — key issues or confirmations>"],
91
+ "verdict": "<approved | revision>",
92
+ "written_at": "<current ISO 8601 timestamp>",
93
+ "artifact_ref":"CODE_REVIEW.md"
94
+ }
95
+ ```
96
+ - Call (task mode):
97
+ ```
98
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-summary {taskId} code_review \
99
+ engineering/sprints/{sprint}/{task}/REVIEW-IMPL-SUMMARY.json
100
+ ```
101
+ Or (bug mode):
102
+ ```
103
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-bug-summary {bugId} code_review \
104
+ engineering/bugs/{bugDir}/REVIEW-IMPL-SUMMARY.json
105
+ ```
106
+ - If the set-summary call exits non-zero, fix the sidecar JSON and retry. Do not proceed without a valid summary.
107
+ ```
108
+
109
+ ## Generation Instructions
110
+
111
+ - **Workflow Structure:** The generated `review_implementation.md` must follow the strict "Algorithm" block format.
112
+ - **Markers (required by `/forge:run-task` kickoff shim):** Generated workflow MUST include the "Iron Laws" section, the "Store-Write Verification" section, the literal `forge_store` token, and the `.forge/personas/supervisor.md` persona path. Missing any → kickoff shim refuses to dispatch.
113
+ - **Verdict Detection:** The generated workflow MUST enforce the strict `**Verdict:** [Approved | Revision Required]` format.
114
+ - **Context Isolation:** Forbid inline execution of complex code review logic; use the `Agent` tool for sub-tasks.
115
+ - **Project Specifics:**
116
+ - Embed project-specific code quality standards and linting rules.
117
+ - **Token Reporting:** See `_fragments/finalize.md` — wire via `file_ref:`.
118
+ - **Diff-mode:** Generated workflow MUST include the diff-first read mode instruction (see PLAN.md A6).
119
+ - **Event Emission:** Ensure the "complete" event includes the `eventId` passed by the orchestrator.
@@ -0,0 +1,108 @@
1
+ ---
2
+ requirements:
3
+ reasoning: High
4
+ context: Medium
5
+ speed: Low
6
+ audience: subagent
7
+ phase: review-plan
8
+ context:
9
+ architecture: false
10
+ prior_summaries: delta
11
+ persona: summary
12
+ master_index: false
13
+ diff_mode: false
14
+ deps:
15
+ personas: [supervisor]
16
+ skills: [supervisor, generic]
17
+ templates: [PLAN_REVIEW_TEMPLATE]
18
+ sub_workflows: []
19
+ kb_docs: [architecture/stack.md]
20
+ config_fields: [paths.engineering]
21
+ ---
22
+
23
+ # 🌿 Meta-Workflow: Review Plan
24
+
25
+ ## Iron Laws
26
+
27
+ - Evaluate the plan against what the task actually requires, not against what the plan claims to deliver. Plans routinely understate complexity, omit edge cases, or skip security steps. Your job is adversarial review, not approval.
28
+ - Read `.forge/personas/supervisor.md` first; print the persona identity line (emoji, name, tagline) to stdout before any other tool use.
29
+ - All store I/O via `forge_store` (or `node "$FORGE_ROOT/tools/store-cli.cjs"`). Never edit `.forge/store/*.json` directly.
30
+
31
+ ## Store-Write Verification
32
+
33
+ Every `forge_store` write MUST succeed before advancing. If `store-cli` exits
34
+ non-zero or the `PreToolUse` write-boundary hook blocks the call (exit 2):
35
+
36
+ 1. Parse the structured error (names the offending field + schema file).
37
+ 2. Correct the JSON to satisfy the schema.
38
+ 3. Retry. Repeat up to 3 times.
39
+ 4. After 3 failures, halt and escalate with original payload, corrected payload, and all error messages.
40
+
41
+ Never set `FORGE_SKIP_WRITE_VALIDATION=1` — operator-only emergency switch.
42
+
43
+ ## Algorithm
44
+
45
+ ```
46
+
47
+ 0. Pre-flight Gate Check:
48
+ - Resolve FORGE_ROOT (`node -e "console.log(require('./.forge/config.json').paths.forgeRoot)"`).
49
+ - **Entity-mode resolution:** read the kickoff arguments. `--task {id}` → `entity_kind = "task"`, `record_id = {id}`. `--bug {id}` → `entity_kind = "bug"`, `record_id = {id}`. All store-cli calls below substitute `{entity_kind}` and `{record_id}` for the literal "task"/{taskId} placeholders.
50
+ - Run: `node "$FORGE_ROOT/tools/preflight-gate.cjs" --phase review-plan --{entity_kind} {record_id}`
51
+ - Exit 1 (gate failed) → print stderr and HALT. Do not proceed; do not attempt to produce the artifact.
52
+ - Exit 2 (misconfiguration) → print stderr and HALT.
53
+ - Exit 0 → continue.
54
+ 1. Load Context:
55
+ - Read task prompt (source of truth)
56
+ - Read PLAN.md (subject of review)
57
+ - Read stack checklist if available
58
+
59
+ 2. Review:
60
+ - Evaluate feasibility, completeness, security, architecture alignment, and testing strategy
61
+ - Identify missing edge cases or failure modes
62
+
63
+ 3. Verdict:
64
+ - Write PLAN_REVIEW.md using the format:
65
+ **Verdict:** [Approved | Revision Required]
66
+ - If Revision Required: provide numbered, actionable items
67
+ - If Approved: provide any advisory notes
68
+
69
+ 4. Finalize:
70
+ - Transitions:
71
+ - **Task mode** — predecessor must be `planned`.
72
+ - Approved → `plan-approved`
73
+ - Revision Required → `plan-revision-required`
74
+ - Out-of-band escapes (any state): `code-revision-required`, `blocked`, `escalated`, `abandoned`
75
+ Update status: `node "$FORGE_ROOT/tools/store-cli.cjs" update-status task {taskId} status plan-approved` (if Approved) or `... status plan-revision-required` (if Revision Required)
76
+ - **Bug mode** — NO status write. The bug remains `in-progress`. The verdict signal travels through `summaries.review_plan.verdict` (read by `read-verdict.cjs § BUG_PHASE_VERDICT_SOURCE`), not `bug.status`. Writing `bug.status` here violates `meta-fix-bug.md § Iron Laws #2`.
77
+ - **Do NOT emit a phase event yourself.** The orchestrator owns event emission — it composes the canonical event from runtime telemetry (model, provider, tokens, wall times) plus the SUMMARY you write in the next step. Subagents that call `store-cli emit` for phase events hallucinate runtime facts (see Plan 11 / Slice 2). Write the SUMMARY and return.
78
+
79
+ 5. Emit Summary Sidecar:
80
+ - Write `REVIEW-PLAN-SUMMARY.json` to the record's directory with the following shape:
81
+ ```json
82
+ {
83
+ "objective": "<one sentence — what this review assessed>",
84
+ "findings": ["<up to 12 bullets, 200 chars each — key issues or confirmations>"],
85
+ "verdict": "<approved | revision>",
86
+ "written_at": "<current ISO 8601 timestamp>",
87
+ "artifact_ref":"PLAN_REVIEW.md"
88
+ }
89
+ ```
90
+ - Call (task mode):
91
+ ```
92
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-summary {taskId} review_plan \
93
+ engineering/sprints/{sprint}/{task}/REVIEW-PLAN-SUMMARY.json
94
+ ```
95
+ Or (bug mode):
96
+ ```
97
+ node "$FORGE_ROOT/tools/store-cli.cjs" set-bug-summary {bugId} review_plan \
98
+ engineering/bugs/{bugDir}/REVIEW-PLAN-SUMMARY.json
99
+ ```
100
+ - If the set-summary call exits non-zero, fix the sidecar JSON and retry. Do not proceed without a valid summary.
101
+ ```
102
+
103
+ ## Generation Notes
104
+
105
+ - Enforce `**Verdict:** [Approved | Revision Required]` format exactly — orchestrator branches on this.
106
+ - **Markers (required by `/forge:run-task` kickoff shim):** Generated workflow MUST include the "Iron Laws" section, the "Store-Write Verification" section, the literal `forge_store` token, and the `.forge/personas/supervisor.md` persona path. Missing any → kickoff shim refuses to dispatch.
107
+ - Token Reporting: `_fragments/finalize.md` — wire via `file_ref:`.
108
+ - Event Emission: "complete" event MUST include the `eventId` passed by the orchestrator.
@@ -0,0 +1,65 @@
1
+ ---
2
+ requirements:
3
+ reasoning: High
4
+ context: Medium
5
+ speed: Low
6
+ deps:
7
+ personas: [architect]
8
+ skills: [architect, generic]
9
+ templates: []
10
+ sub_workflows: []
11
+ kb_docs: [architecture/stack.md]
12
+ config_fields: [paths.engineering]
13
+ ---
14
+
15
+ # 🗻 Meta-Workflow: Review Sprint Completion
16
+
17
+ ## Purpose
18
+
19
+ Verify that all tasks in a sprint have been completed, committed, and validated before closing the sprint.
20
+
21
+ ## Algorithm
22
+
23
+ ```
24
+ 1. Load Context:
25
+ - Read sprint manifest
26
+ - Read all task manifests in the sprint
27
+ - Check VCS for all expected commit hashes
28
+
29
+ 2. Verification:
30
+ - Confirm every task is in `committed` status
31
+ - Verify all `approved` tasks have a corresponding commit
32
+ - Check for any lingering "escalated" tasks
33
+
34
+ 3. Verdict:
35
+ - Write SPRINT_COMPLETION_REVIEW.md using the format:
36
+ **Verdict:** [Approved | Revision Required]
37
+ - If Revision Required: list missing commits or unresolved tasks
38
+ - If Approved: confirm sprint is ready for retrospective
39
+
40
+ 4. Finalize:
41
+ - If step-3 verdict is `Approved`:
42
+ - Update sprint status to `completed` via
43
+ `node "$FORGE_ROOT/tools/store-cli.cjs" update-status sprint {sprintId} status completed`
44
+ - If step-3 verdict is `Revision Required` and orchestrator passed `mode=partial`:
45
+ - Update sprint status to `partially-completed` via
46
+ `node "$FORGE_ROOT/tools/store-cli.cjs" update-status sprint {sprintId} status partially-completed`
47
+ - If step-3 verdict is `Revision Required` and orchestrator passed `mode=complete`:
48
+ - Do NOT transition status. Leave the sprint at its current status and exit;
49
+ the orchestrator will surface the verdict to the user.
50
+ - **Do NOT emit a phase event yourself.** The orchestrator (or kickoff handler) owns event emission — it composes the canonical event from runtime telemetry (model, provider, tokens, wall times) plus the SUMMARY you write in the next step. Subagents that call `store-cli emit` for phase events hallucinate runtime facts (see Plan 11 / Slice 2). Write the SUMMARY and return.
51
+ ```
52
+
53
+ ## Generation Instructions
54
+
55
+ - **Persona Self-Load:** The generated workflow MUST begin by reading `.forge/personas/architect.md` as its first step (before any other tool use). This replaces the former inline `## Persona` section. The persona identity line (emoji, name, tagline) should be printed to stdout after reading the file.
56
+ - **Workflow Structure:** The generated `review_sprint_completion.md` must follow the strict "Algorithm" block format.
57
+ - **Verdict Detection:** The generated workflow MUST enforce the strict `**Verdict:** [Approved | Revision Required]` format.
58
+ - **Context Isolation:** Forbid inline execution of sprint-wide audits; use the `Agent` tool for sub-tasks.
59
+ - **Token Reporting:** The generated workflow MUST mandate the following before returning:
60
+ 1. Probe session token usage: invoke `/cost` if the host runtime supports it
61
+ (Claude Code only); on any other runtime treat as unavailable and proceed.
62
+ Do NOT shell out to a `cost-cli.cjs` — there is no such tool.
63
+ 2. Parse: `inputTokens`, `outputTokens`, `cacheReadTokens`, `cacheWriteTokens`, `estimatedCostUSD`.
64
+ 3. Write the usage sidecar via `node "$FORGE_ROOT/tools/store-cli.cjs" emit {sprintId} '{sidecar-json}' --sidecar`.
65
+ - **Event Emission:** Ensure the "complete" event includes the `eventId` passed by the orchestrator.