@kleber.mottajr/juninho 2.0.0 → 2.0.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.
@@ -24,95 +24,101 @@ function writeCommands(projectDir) {
24
24
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.finish-setup.md"), FINISH_SETUP);
25
25
  }
26
26
  // ─── /plan ────────────────────────────────────────────────────────────────────
27
- const PLAN = `# /plan — Strategic Planning
28
-
29
- Invoke the \`@j.planner\` agent to create an actionable plan from a goal.
30
-
31
- ## Usage
32
-
33
- \`\`\`
34
- /j.plan <goal or task description>
35
- \`\`\`
36
-
37
- ## Examples
38
-
39
- \`\`\`
40
- /j.plan add user authentication with email and Google OAuth
41
- /j.plan fix the N+1 query bug in the appointments list
42
- /j.plan refactor the service layer to use the repository pattern
43
- \`\`\`
44
-
45
- ## What happens
46
-
47
- 1. \`@j.planner\` classifies your intent
48
- 2. Explores the codebase for context
49
- 3. Interviews you (proportional to complexity)
50
- 4. Writes \`plan.md\` and \`CONTEXT.md\`
51
- 5. Spawns \`@j.plan-reviewer\` for automated quality check
52
- 6. **Presents the plan to you for explicit approval**
53
- 7. Marks plan as ready for \`/j.implement\` (only after your approval)
54
-
55
- ## Delegation Rule (MANDATORY)
56
-
57
- You MUST delegate this task to \`@j.planner\` using the \`task()\` tool.
58
- Do NOT perform the planning yourself — you are the orchestrator, not the executor.
59
-
60
- When ANY sub-agent returns output:
61
- - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
62
- - NEVER say "I'll continue myself" and take over the sub-agent's job
63
- - Sub-agent unknowns/ambiguities are VALUABLE DATA — forward them to the user via \`question\` tool
64
- - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
65
-
66
- ## After planning
67
-
68
- Run \`/j.implement\` to execute the plan, or \`/j.spec\` first for complex features.
27
+ const PLAN = `# /plan — Strategic Planning
28
+
29
+ Invoke the \`@j.planner\` agent to create an actionable plan from a goal.
30
+
31
+ ## Usage
32
+
33
+ \`\`\`
34
+ /j.plan <goal or task description>
35
+ \`\`\`
36
+
37
+ ## Examples
38
+
39
+ \`\`\`
40
+ /j.plan add user authentication with email and Google OAuth
41
+ /j.plan fix the N+1 query bug in the appointments list
42
+ /j.plan refactor the service layer to use the repository pattern
43
+ \`\`\`
44
+
45
+ ## What happens
46
+
47
+ 1. \`@j.planner\` classifies your intent
48
+ 2. Explores the codebase for context across all involved repositories
49
+ 3. Uses project rules, domain docs, and principle docs relevant to the goal before fixing the plan
50
+ 4. Classifies repositories into **write targets** (repos with code changes) and **reference projects** (read-only context)
51
+ 5. Interviews you (proportional to complexity)
52
+ 6. Writes \`plan.md\` and \`CONTEXT.md\` into each write target project's \`\$REPO_ROOT/docs/specs/{feature-slug}/\`
53
+ 7. Writes \`active-plan.json\` with all \`writeTargets\` and their \`targetRepoRoot\` paths
54
+ 8. Spawns \`@j.plan-reviewer\` for automated quality check
55
+ 9. **Presents the plan to you for explicit approval**
56
+ 10. Marks plan as ready for \`/j.implement\` (only after your approval)
57
+ 11. If a later \`/j.check\` pass finds required changes after a task is already COMPLETE, the planner should express that work as a new follow-up task instead of reopening the completed one
58
+
59
+ ## Delegation Rule (MANDATORY)
60
+
61
+ You MUST delegate this task to \`@j.planner\` using the \`task()\` tool.
62
+ Do NOT perform the planning yourself you are the orchestrator, not the executor.
63
+
64
+ When ANY sub-agent returns output:
65
+ - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
66
+ - NEVER say "I'll continue myself" and take over the sub-agent's job
67
+ - Sub-agent unknowns/ambiguities are VALUABLE DATA — forward them to the user via \`question\` tool
68
+ - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
69
+
70
+ ## After planning
71
+
72
+ Run \`/j.implement\` to execute the plan, or \`/j.spec\` first for complex features.
69
73
  `;
70
74
  // ─── /spec ────────────────────────────────────────────────────────────────────
71
- const SPEC = `# /spec — Feature Specification
72
-
73
- Invoke the \`@j.spec-writer\` agent to create a detailed spec before implementation.
74
-
75
- ## Usage
76
-
77
- \`\`\`
78
- /j.spec <feature name or description>
79
- \`\`\`
80
-
81
- ## Examples
82
-
83
- \`\`\`
84
- /j.spec user profile with avatar upload
85
- /j.spec appointment booking flow
86
- /j.spec payment integration with Stripe
87
- \`\`\`
88
-
89
- ## What happens
90
-
91
- 1. \`@j.spec-writer\` spawns \`@j.explore\` for codebase pre-research
92
- 2. Uses explore findings to inform a 5-phase interview:
93
- - Discovery: problem and users
94
- - Requirements: functional and non-functional
95
- - Contract: API and interface definitions
96
- - Data: schema and migration strategy
97
- - Review: **presents spec for your explicit approval**
98
- 3. Writes spec to \`docs/specs/{feature-name}.md\` (only after your approval)
99
-
100
- The session does NOT need to call \`@j.explore\` separately \`@j.spec-writer\` handles its own research internally.
101
-
102
- ## Delegation Rule (MANDATORY)
103
-
104
- You MUST delegate this task to \`@j.spec-writer\` using the \`task()\` tool.
105
- Do NOT perform the spec writing yourself — you are the orchestrator, not the executor.
106
-
107
- When ANY sub-agent returns output:
108
- - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
109
- - NEVER say "I'll continue myself" and take over the sub-agent's job
110
- - Sub-agent unknowns/ambiguities are VALUABLE DATA forward them to the user via \`question\` tool
111
- - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
112
-
113
- ## After spec
114
-
115
- Run \`/j.plan\` to create an execution plan, then \`/j.implement\` to build.
75
+ const SPEC = `# /spec — Feature Specification
76
+
77
+ Invoke the \`@j.spec-writer\` agent to create a detailed spec before implementation.
78
+
79
+ ## Usage
80
+
81
+ \`\`\`
82
+ /j.spec <feature name or description>
83
+ \`\`\`
84
+
85
+ ## Examples
86
+
87
+ \`\`\`
88
+ /j.spec user profile with avatar upload
89
+ /j.spec appointment booking flow
90
+ /j.spec payment integration with Stripe
91
+ \`\`\`
92
+
93
+ ## What happens
94
+
95
+ 1. \`@j.spec-writer\` spawns \`@j.explore\` for codebase pre-research
96
+ 2. Uses explore findings plus relevant project/domain/principle context to inform a 5-phase interview:
97
+ - Discovery: problem and users
98
+ - Requirements: functional and non-functional
99
+ - Contract: API and interface definitions
100
+ - Data: schema and migration strategy
101
+ - Review: **presents spec for your explicit approval**
102
+ 3. Classifies repositories into **write targets** (repos with code changes) and **reference projects** (read-only context)
103
+ 4. Writes spec to each write target project's \`\$REPO_ROOT/docs/specs/{feature-slug}/spec.md\` (only after your approval)
104
+ 5. Never creates \`docs/specs/\` artifacts in reference projects unless explicitly stated
105
+
106
+ The session does NOT need to call \`@j.explore\` separately — \`@j.spec-writer\` handles its own research internally.
107
+
108
+ ## Delegation Rule (MANDATORY)
109
+
110
+ You MUST delegate this task to \`@j.spec-writer\` using the \`task()\` tool.
111
+ Do NOT perform the spec writing yourself — you are the orchestrator, not the executor.
112
+
113
+ When ANY sub-agent returns output:
114
+ - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
115
+ - NEVER say "I'll continue myself" and take over the sub-agent's job
116
+ - Sub-agent unknowns/ambiguities are VALUABLE DATA — forward them to the user via \`question\` tool
117
+ - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
118
+
119
+ ## After spec
120
+
121
+ Run \`/j.plan\` to create an execution plan, then \`/j.implement\` to build.
116
122
  `;
117
123
  // ─── /implement ───────────────────────────────────────────────────────────────
118
124
  const IMPLEMENT = `# /implement — Execute Plan or Spec
@@ -136,41 +142,37 @@ Invoke the \`@j.implementer\` agent to build what was planned or specified.
136
142
 
137
143
  ## What happens
138
144
 
139
- 1. \`@j.implementer\` reads the active \`plan.md\` (auto-loaded by plan-autoload plugin)
140
- 2. Reads \`.opencode/juninho-config.json\` (\`workflow\` section) to understand handoff and UNIFY behavior
141
- 3. Reads feature-local execution context from \`docs/specs/{feature-slug}/state/\`, especially \`implementer-work.md\` plus dependency task state under \`state/tasks/task-{id}/\` when running a specific task
142
- 4. Optionally reads \`spec.md\` if it exists (spec is NOT required plan-only flow is supported)
143
- 5. Executes in waves:
144
- - Wave 1: Foundation (schema, types, migrations)
145
- - Wave 2: Core logic (services, API routes)
146
- - Wave 3: Integration (wire-up, tests)
147
- 6. Parallel waves are capped at **2 concurrent task subagents** to reduce silent provider/OpenCode stream stalls
148
- 7. Each task writes and refreshes its own execution lease in \`docs/specs/{feature-slug}/state/tasks/task-{id}/execution-state.md\`
149
- 8. If a spawned task never writes state or its heartbeat goes stale, the watchdog/orchestrator may launch **one retry attempt in the same stalled session** for that task in the same wave
150
- 9. Uses the fast pre-commit path while implementing:
145
+ 1. \`@j.implementer\` reads the active \`plan.md\` (auto-loaded by plan-autoload plugin).
146
+ 2. Reads \`.opencode/juninho-config.json\` (\`workflow\` section) to understand implement, watchdog, handoff, and UNIFY behavior.
147
+ 3. If \`/j.implement\` receives no specific task/file, it executes against the whole active plan. For multi-project plans, it must iterate all \`writeTargets\`, using each target project's own \`docs/specs/{feature-slug}/plan.md\` plus local state artifacts.
148
+ 4. If a specific task/file is provided, it narrows scope to that target while still respecting dependencies and the latest \`check-review.md\` findings.
149
+ 5. Creates or switches to a single canonical plan branch \`feature/{feature-slug}\` for the entire run.
150
+ 6. Delegates each implementation task to its own task-scoped \`@j.implementer\` subagent so every task starts with a fresh context window.
151
+ 7. Because all commits land on the same plan branch, task workers commit sequentially even when the plan has multiple tasks in the same wave.
152
+ 8. Each task writes and refreshes its own execution lease in \`docs/specs/{feature-slug}/state/tasks/task-{id}/execution-state.md\`.
153
+ 9. If \`workflow.implement.watchdogSessionStale\` is enabled and a spawned task never writes state or its heartbeat goes stale, the watchdog/orchestrator may launch one retry attempt for that task.
154
+ 10. Uses the fast pre-commit path while implementing:
151
155
  - \`.opencode/scripts/lint-structure.sh\`
156
+ - \`.opencode/scripts/build-verify.sh\`
152
157
  - \`.opencode/scripts/test-related.sh\`
153
158
  - focused test execution is routed through \`.opencode/scripts/run-test-scope.sh\`
154
- 10. Spawns \`@j.validator\` for compliance (validates against spec if present, otherwise against plan \`<done>\` criteria)
155
- 11. **State is written to canonical repo root**, never inside worktrees:
156
- - Per-task state: \`docs/specs/{feature-slug}/state/tasks/task-{id}/execution-state.md\`
157
- - Validator results: \`docs/specs/{feature-slug}/state/tasks/task-{id}/validator-work.md\`
158
- - Implementer log: \`docs/specs/{feature-slug}/state/implementer-work.md\` (append-only)
159
- - Retry budget/state: \`docs/specs/{feature-slug}/state/tasks/task-{id}/retry-state.json\`
160
- - Runtime metadata: \`docs/specs/{feature-slug}/state/tasks/task-{id}/runtime.json\` and \`docs/specs/{feature-slug}/state/sessions/{sessionID}-runtime.json\`
161
- 12. Canonical feature integration is tracked in \`docs/specs/{feature-slug}/state/integration-state.json\`
162
- 13. Each APPROVED task records its exact \`validatedCommit\` and is integrated immediately into \`feature/{feature-slug}\` as a single feature-branch commit for that task
163
- 14. A watchdog notification fires when a session appears stalled, but notifications never block the run
164
- 15. If cleanup is ever needed for a retry, it applies only to the failed task's worktree never to unrelated worktrees in the same feature
165
- 16. Exits when code changes and task-level tests are complete and already integrated into \`feature/{feature-slug}\`
166
- 17. The caller then runs \`.opencode/scripts/check-all.sh\` or \`/j.check\`, which validate the canonical integrated feature branch
167
- 18. If the repo-wide check fails, delegate back to \`@j.implementer\` with the failing output
159
+ 11. Spawns \`@j.validator\` after each task commit to validate the just-implemented task against spec/plan intent, QA expectations, and code quality expectations within task scope.
160
+ 12. Task state, validator state, implementer log, retry budget, and runtime metadata all live under \`docs/specs/{feature-slug}/state/\` in each task's target project repo root. Multi-project runs must keep state isolated per write target.
161
+ 13. Canonical task commit bookkeeping is tracked in \`docs/specs/{feature-slug}/state/integration-state.json\`.
162
+ 14. A task is only marked COMPLETE after its commit succeeds, validator approval is written, and the task bookkeeping for that commit is recorded successfully.
163
+ 15. The task commit must include the task's updated state files when those files change as part of the successful loop.
164
+ 16. If \`workflow.implement.watchdogSessionStale\` is enabled, watchdog notifications may surface stalled sessions, but notifications never block the run.
165
+ 17. Before final exit on a successful whole-feature run, request a feature-level validator pass for each write target to write that target project's \`docs/specs/{feature-slug}/state/functional-validation-plan.md\`.
166
+ 18. Exit only when code changes, task-level tests, and target-local functional validation plans are complete for every write target on \`feature/{feature-slug}\`.
167
+ 19. The caller then runs \`.opencode/scripts/check-all.sh\` or \`/j.check\`, which validate the canonical plan branch using \`check-review.md\` plus \`functional-validation-plan.md\`.
168
+ 20. If the repo-wide check fails, delegate back to \`@j.implementer\` with the failing output and those generated artifacts.
169
+ 21. If that reentry requires changing work from a task that is already COMPLETE, the harness should create a new follow-up task instead of reopening the completed one.
168
170
 
169
171
  ## History Rules
170
172
 
171
- - A task branch must never cherry-pick or merge another task's commit by hand.
173
+ - A task must commit directly on the canonical plan branch \`feature/{feature-slug}\`.
174
+ - The preferred history is one commit per task; one commit per wave is acceptable only when the workflow owner explicitly decides to bundle a wave.
172
175
  - If a task needs earlier task code to exist, that relationship must be expressed via \`depends\` in \`plan.md\`.
173
- - The final feature branch should read like \`one implemented task -> one feature-branch commit\`, with no synthetic \`integrate task\` merge commits.
174
176
  - Closeout docs that should land in git history must be explicit plan tasks, not post-hoc UNIFY-only commits.
175
177
 
176
178
  ## Delegation Rule (MANDATORY)
@@ -191,81 +193,91 @@ When ANY sub-agent returns output:
191
193
  ## After implementation
192
194
 
193
195
  Run \`/j.check\` for repo-wide verification.
194
- If \`/j.check\` fails, invoke \`/j.implement\` again with the failing output.
196
+ If \`/j.check\` fails, invoke \`/j.implement\` again with the failing output, \`check-review.md\`, and \`functional-validation-plan.md\`.
197
+ Treat the \`## Reentry Contract\` section inside \`check-review.md\` as the authoritative next-action contract when it is present.
198
+ If the correction applies to already completed work, create a new follow-up task first and implement that task forward-only.
195
199
  Run \`/j.unify\` only after the full check passes and \`juninho-config.json\` enables UNIFY.
196
200
  `;
197
201
  // ─── /sync-docs ───────────────────────────────────────────────────────────────
198
- const SYNC_DOCS = `# /sync-docs — Refresh AGENTS and Documentation
199
-
200
- Generate or update \`AGENTS.md\`, domain docs, and principle docs using the current code as source of truth.
201
-
202
- ## Usage
203
-
204
- \`\`\`
205
- /j.sync-docs
206
- /j.sync-docs <path or domain>
207
- \`\`\`
208
-
209
- ## What happens
210
-
202
+ const SYNC_DOCS = `# /sync-docs — Refresh AGENTS and Documentation
203
+
204
+ Generate or update \`AGENTS.md\`, domain docs, and principle docs using the current code as source of truth.
205
+
206
+ ## Usage
207
+
208
+ \`\`\`
209
+ /j.sync-docs
210
+ /j.sync-docs <path or domain>
211
+ \`\`\`
212
+
213
+ ## What happens
214
+
211
215
  1. Read \`.opencode/juninho-config.json\` to understand documentation-related workflow defaults
212
- 2. Identify key files for the requested scope
213
- 3. Update the right doc surface for each kind of knowledge:
214
- - \`AGENTS.md\` for directory-local working rules and commands
215
- - \`docs/domain/*\` for business behavior and invariants
216
- - \`docs/principles/*\` for cross-cutting technical patterns
217
- 4. Add or refresh sync markers such as:
218
- - \`<!-- juninho:sync source=src/payments/service.ts hash=abc123 -->\`
219
- 5. Update \`docs/domain/INDEX.md\` and \`docs/principles/manifest\` when new docs are added or renamed
220
-
221
- ## Rules
222
-
223
- - Prefer small, high-signal \`AGENTS.md\` files close to the code they describe
224
- - Keep business behavior out of \`AGENTS.md\`; put it in \`docs/domain/*\`
225
- - Keep technical principles reusable; do not bury them in a module-specific doc
226
- - Use key-file sync markers so doc drift is visible during later updates
227
-
228
- ## Delegation Rule (MANDATORY)
229
-
230
- You MUST delegate this task to \`@j.implementer\` using the \`task()\` tool.
231
- Do NOT rewrite the docs yourself when the harness workflow asks for agent execution.
232
-
233
- ## When to use
234
-
235
- - After finishing a feature before human review
236
- - After major refactors that changed local rules or business behavior
237
- - When CARL recall quality degrades because docs or manifests are stale
216
+ 2. Read \`.opencode/state/active-plan.json\` to discover write targets (if active)
217
+ 3. Resolve the target project:
218
+ - If a path/domain argument is provided, resolve the containing project root
219
+ - If an active plan exists, operate on all write target projects
220
+ - Otherwise, operate on the single discovered project or ask the user
221
+ 4. For each target project (\`\$PROJECT_ROOT\`):
222
+ - Identify key files for the requested scope
223
+ - Update \`\$PROJECT_ROOT/AGENTS.md\` and directory-level \`AGENTS.md\` files
224
+ - Update \`\$PROJECT_ROOT/docs/domain/*\` for business behavior and invariants
225
+ - Update \`\$PROJECT_ROOT/docs/principles/*\` for cross-cutting technical patterns
226
+ - Add or refresh sync markers such as:
227
+ - \`<!-- juninho:sync source=src/payments/service.ts hash=abc123 -->\`
228
+ - Update \`\$PROJECT_ROOT/docs/domain/INDEX.md\` and \`\$PROJECT_ROOT/docs/principles/manifest\` when new docs are added or renamed
229
+
230
+ ## Rules
231
+
232
+ - Prefer small, high-signal \`AGENTS.md\` files close to the code they describe
233
+ - Keep business behavior out of \`AGENTS.md\`; put it in \`docs/domain/*\`
234
+ - Keep technical principles reusable; do not bury them in a module-specific doc
235
+ - Use key-file sync markers so doc drift is visible during later updates
236
+
237
+ ## Delegation Rule (MANDATORY)
238
+
239
+ You MUST delegate this task to \`@j.implementer\` using the \`task()\` tool.
240
+ Do NOT rewrite the docs yourself when the harness workflow asks for agent execution.
241
+
242
+ ## When to use
243
+
244
+ - After finishing a feature before human review
245
+ - After major refactors that changed local rules or business behavior
246
+ - When CARL recall quality degrades because docs or manifests are stale
238
247
  `;
239
248
  // ─── /start-work ─────────────────────────────────────────────────────────────
240
- const START_WORK = `# /start-work — Begin a Work Session
241
-
242
- Initialize context for a focused work session on a specific task.
243
-
244
- ## Usage
245
-
246
- \`\`\`
247
- /j.start-work <task description or issue number>
248
- \`\`\`
249
-
250
- ## Examples
251
-
252
- \`\`\`
253
- /j.start-work issue #42 — fix login redirect loop
254
- /j.start-work implement the dashboard analytics widget
255
- /j.start-work #123
256
- \`\`\`
257
-
258
- ## What happens
259
-
260
- 1. Loads \`docs/domain/INDEX.md\` for domain context
261
- 2. Checks \`execution-state.md\` for any in-progress work
262
- 3. If a \`plan.md\` exists: loads it and presents next steps
263
- 4. If no plan: asks whether to \`/j.plan\` first or jump straight to \`/j.implement\`
264
- 5. Sets up \`execution-state.md\` with the current task
265
-
266
- ## After starting work
267
-
268
- The session is now focused. Use \`/j.implement\` to build, \`@j.validator\` to check, \`/j.handoff\` when done.
249
+ const START_WORK = `# /start-work — Begin a Work Session
250
+
251
+ Initialize context for a focused work session on a specific task.
252
+
253
+ ## Usage
254
+
255
+ \`\`\`
256
+ /j.start-work <task description or issue number>
257
+ \`\`\`
258
+
259
+ ## Examples
260
+
261
+ \`\`\`
262
+ /j.start-work issue #42 — fix login redirect loop
263
+ /j.start-work implement the dashboard analytics widget
264
+ /j.start-work #123
265
+ \`\`\`
266
+
267
+ ## What happens
268
+
269
+ 1. Reads \`.opencode/state/active-plan.json\` to discover write targets
270
+ 2. For each write target project, loads \`docs/domain/INDEX.md\` for domain context
271
+ 3. Checks per-target \`docs/specs/{feature-slug}/state/\` for any in-progress work
272
+ 4. If a \`plan.md\` exists in any target: loads it and presents next steps
273
+ 5. If no plan: asks whether to \`/j.plan\` first or jump straight to \`/j.implement\`
274
+ 6. Sets up execution state for the current task
275
+
276
+ In multi-repo mode, shows status across all write targets so you can see which projects have pending work.
277
+
278
+ ## After starting work
279
+
280
+ The session is now focused. Use \`/j.implement\` to build, \`@j.validator\` to check, \`/j.handoff\` when done.
269
281
  `;
270
282
  // ─── /handoff ─────────────────────────────────────────────────────────────────
271
283
  const HANDOFF = `# /handoff — End-of-Session Handoff
@@ -280,18 +292,19 @@ Prepare a handoff document for the next session or team member.
280
292
 
281
293
  ## What happens
282
294
 
283
- 1. Reads global session summary from \`.opencode/state/execution-state.md\`
284
- 2. Reads per-task state from \`docs/specs/{feature-slug}/state/tasks/task-*/execution-state.md\`
285
- 3. Reads the feature-local implementer log from \`docs/specs/{feature-slug}/state/implementer-work.md\`
286
- 4. Reads \`docs/specs/{feature-slug}/state/integration-state.json\` for validated SHAs and integration/cleanup status
287
- 5. Reads session runtime metadata from \`docs/specs/{feature-slug}/state/sessions/\` when session ownership/context is relevant
288
- 5. Summarizes:
295
+ 1. Reads \`.opencode/state/active-plan.json\` to discover all write targets
296
+ 2. For each write target project (\`\$REPO_ROOT\`):
297
+ - Reads per-task state from \`\$REPO_ROOT/docs/specs/{feature-slug}/state/tasks/task-*/execution-state.md\`
298
+ - Reads the feature-local implementer log from \`\$REPO_ROOT/docs/specs/{feature-slug}/state/implementer-work.md\`
299
+ - Reads \`\$REPO_ROOT/docs/specs/{feature-slug}/state/integration-state.json\` for validated SHAs and commit bookkeeping/cleanup status
300
+ - Reads session runtime metadata from \`\$REPO_ROOT/docs/specs/{feature-slug}/state/sessions/\` when session ownership/context is relevant
301
+ 3. Summarizes (across all write targets):
289
302
  - What was completed this session
290
303
  - What is in progress (with file names, attempt number, and last heartbeat)
291
304
  - What is blocked and why
292
305
  - What was retried and why
293
- - What is already integrated into \`feature/{feature-slug}\` and which feature-branch commit represents each task
294
- - What still needs integration or cleanup
306
+ - What is already committed into \`feature/{feature-slug}\` and which commit represents each task
307
+ - What still needs bookkeeping or cleanup
295
308
  - Exact next step to continue
296
309
 
297
310
  6. Updates local execution state with handoff notes
@@ -326,261 +339,297 @@ Prepare a handoff document for the next session or team member.
326
339
  const ULW_LOOP = `# /ulw-loop — Ultra Work Loop
327
340
 
328
341
  Activate high-throughput mode — work until all tasks in the plan are complete.
329
-
330
- ## Usage
331
-
332
- \`\`\`
333
- /j.ulw-loop
334
- /j.ulw-loop <task or goal>
335
- \`\`\`
336
-
337
- ## What happens
338
-
339
- 1. Reads task list from the active \`plan.md\` (auto-loaded by plan-autoload plugin)
340
- 2. Reads \`.opencode/state/execution-state.md\` for the active plan path and session summary
341
- 3. Reads feature-local state from \`docs/specs/{feature-slug}/state/\`, especially \`implementer-work.md\` and prior task execution files
342
- 4. Identifies tasks that can run in parallel (no dependencies)
343
- 5. Spins up \`@j.implementer\` agents in parallel via worktrees with a hard cap of **2 concurrent task subagents** per batch:
344
- - Each worktree works on independent files
345
- - No merge conflicts by design
346
- - **All state is written to canonical repo root** (\`docs/specs/{feature-slug}/state/\`), never inside worktrees
347
- - Each task reads dependency execution/validator state before coding
348
- 6. Each task maintains a heartbeat in \`tasks/task-{id}/execution-state.md\`
349
- - Retry budget is tracked per task in \`tasks/task-{id}/retry-state.json\`
350
- 7. If a task never starts or its heartbeat goes stale, the loop may launch **one retry attempt in the same stalled session** for that task in the same wave
351
- 8. A watchdog notification surfaces stalled sessions without blocking the run
352
- 9. \`@j.validator\` runs after each wave, writing results to \`docs/specs/{feature-slug}/state/tasks/task-{id}/validator-work.md\`
353
- 10. Loop continues until all tasks are marked complete
354
- 11. Integrate each APPROVED task commit into the canonical branch \`feature/{feature-slug}\` as one resulting feature-branch commit per task, and keep \`docs/specs/{feature-slug}/state/integration-state.json\` current
355
- 12. Run \`/j.check\` once task-level work is done; this must validate the canonical integrated feature branch, not a task worktree
356
- 13. \`@j.unify\` runs only if closeout is enabled in \`.opencode/juninho-config.json\` under \`workflow.unify.enabled\` and should only do closeout/cleanup/PR work
357
-
358
- ## When to use
359
-
360
- - Many independent tasks in the backlog
361
- - Large feature that can be parallelized
342
+
343
+ ## Usage
344
+
345
+ \`\`\`
346
+ /j.ulw-loop
347
+ /j.ulw-loop <task or goal>
348
+ \`\`\`
349
+
350
+ ## What happens
351
+
352
+ 1. Reads task list from the active \`plan.md\` (auto-loaded by plan-autoload plugin for all write targets)
353
+ 2. Reads \`.opencode/state/active-plan.json\` to discover all write targets
354
+ 3. For multi-project plans, iterates all write targets — each target has its own \`plan.md\` and \`docs/specs/{feature-slug}/state/\` tree
355
+ 4. Reads feature-local state from each target's \`docs/specs/{feature-slug}/state/\`, especially \`implementer-work.md\` and prior task execution files
356
+ 5. Identifies tasks that can run in parallel (no dependencies)
357
+ 6. Creates or switches to the shared implementation branch \`feature/{feature-slug}\` in each target repo
358
+ 7. Delegates each task to its own task-scoped \`@j.implementer\` subagent with the task's \`targetRepoRoot\` so every task gets a fresh context window scoped to its target project
359
+ 8. Executes those task workers sequentially on the shared branch
360
+ 9. Each task reads dependency execution/validator state before coding and writes state to its target repo root (\`\$REPO_ROOT/docs/specs/{feature-slug}/state/\`)
361
+ 10. Each task maintains a heartbeat in \`tasks/task-{id}/execution-state.md\`
362
+ - Retry budget is tracked per task in \`tasks/task-{id}/retry-state.json\`
363
+ 11. If \`workflow.implement.watchdogSessionStale\` is enabled and a task never starts or its heartbeat goes stale, the loop may launch one retry attempt for that task
364
+ 12. If \`workflow.implement.watchdogSessionStale\` is enabled, a watchdog notification may surface stalled sessions without blocking the run
365
+ 13. \`@j.validator\` runs after each task, writing results to the target's \`docs/specs/{feature-slug}/state/tasks/task-{id}/validator-work.md\`
366
+ 14. Loop continues until all tasks across all write targets are marked complete
367
+ 15. Record each APPROVED task commit in the target's \`docs/specs/{feature-slug}/state/integration-state.json\`
368
+ 16. Run \`/j.check\` once task-level work is done; this must validate the canonical plan branch in every target repo
369
+ 17. \`@j.unify\` runs only if closeout is enabled in \`.opencode/juninho-config.json\` under \`workflow.unify.enabled\` and should only do closeout/cleanup/PR work
370
+
371
+ ## When to use
372
+
373
+ - Many independent tasks in the backlog
374
+ - Large feature that can be parallelized
362
375
  - When you want the highest safe throughput
363
-
364
- ## Parallel execution model
365
-
366
- \`\`\`
367
- Wave 1 (parallel):
368
- worktree-a: implement service layer state at docs/specs/{slug}/state/task-1-*
369
- worktree-b: implement API routes state at docs/specs/{slug}/state/task-2-*
370
- batch boundary
371
- worktree-c: implement UI components → state at docs/specs/{slug}/state/task-3-*
372
-
373
- Wave 2 (sequential):
374
- main: wire everything together
375
-
376
- Wave 3 (parallel):
377
- test: unit tests
378
- test: integration tests
379
- \`\`\`
380
-
381
- ## Safety
382
-
383
- - Each worktree is isolated — no cross-contamination
376
+
377
+ ## Execution model
378
+
379
+ \`\`\`
380
+ Wave 1:
381
+ task-worker-1: implement service layer commit on feature/{slug}
382
+ task-worker-2: implement API routes commit on feature/{slug}
383
+ task-worker-3: implement UI components → commit on feature/{slug}
384
+
385
+ Wave 2:
386
+ task-worker-4: wire everything together → commit on feature/{slug}
387
+
388
+ Wave 3:
389
+ task-worker-5: unit tests → commit on feature/{slug}
390
+ task-worker-6: integration tests → commit on feature/{slug}
391
+ \`\`\`
392
+
393
+ ## Safety
394
+
395
+ - Each task gets a fresh task-scoped subagent session
384
396
  - All state files go to repo root, so the orchestrator always has visibility
385
- - Parallel execution is capped at 2 tasks to reduce silent stream loss
397
+ - Shared-branch execution keeps commit history linear and predictable
386
398
  - Each task carries its own lease and heartbeat in feature-local state
387
399
  - Stale tasks can be retried once without allowing two attempts to commit concurrently
388
- - Any worktree cleanup is targeted to the failed task only, never all worktrees in the feature
389
- - Code integration happens during implementation, task by task, into the canonical feature branch using \`ff-only\` or \`cherry-pick -x\`, not synthetic merge commits
400
+ - Cleanup applies only to harness bookkeeping artifacts, not task worktrees
401
+ - Code integration happens immediately because each task commits directly into the canonical feature branch
390
402
  - UNIFY performs cleanup only; it must not be responsible for first-time code integration
391
403
  - If any wave fails, the loop pauses and reports blockers — read \`docs/specs/{slug}/state/\` for details
392
404
  `;
393
405
  // ─── /check ───────────────────────────────────────────────────────────────────
394
406
  const CHECK = `# /check — Run All Quality Gates
395
407
 
396
- Run the full repository verification after \`@j.implementer\` exits, then perform a detailed PR-style review pass.
397
-
398
- ## Usage
399
-
400
- \`\`\`
401
- /j.check
402
- \`\`\`
403
-
408
+ Invoke the \`@j.checker\` agent to run the full repository verification after \`@j.implementer\` exits, then perform a detailed PR-style review pass.
409
+
410
+ ## Usage
411
+
412
+ \`\`\`
413
+ /j.check
414
+ \`\`\`
415
+
404
416
  ## What runs
405
417
 
406
- 1. \`.opencode/scripts/check-all.sh\`
407
- 2. A detailed read-only review via \`@j.reviewer\`
418
+ 1. \`@j.checker\` reads \`.opencode/state/active-plan.json\` to discover all write targets
419
+ 2. \`@j.checker\` runs \`.opencode/scripts/check-all.sh\`, which iterates every target repo from the active multi-project plan
420
+ 3. For each write target (\`\$REPO_ROOT\`), \`@j.checker\` reads \`\$REPO_ROOT/docs/specs/{feature-slug}/state/functional-validation-plan.md\` when it exists
421
+ 4. \`@j.checker\` delegates a detailed read-only multi-pass review to \`@j.reviewer\` covering all write targets
408
422
 
409
423
  This script is expected to run the repository-wide checks for the current stack.
410
424
  Typical examples:
411
425
  - \`npm run typecheck && npm run lint && npm test\`
412
- - \`./gradlew test\`
413
- - \`./mvnw test\`
426
+ - \`./gradlew ktlintCheck && ./gradlew compileKotlin compileTestKotlin && ./gradlew test\`
427
+ - \`./mvnw spotless:check && ./mvnw -DskipTests compile test-compile && ./mvnw test\`
414
428
 
415
429
  The review pass must inspect the resulting integrated branch like a real PR review and look for:
416
430
  - bugs and missed edge cases
417
431
  - spec or plan intent drift
418
432
  - business-rule/domain-rule violations
419
433
  - project pattern or AGENTS violations
434
+ - unnecessary complexity, over-engineering, abstraction inflation, or code bloat
420
435
  - maintainability or safety concerns worth correcting before closeout
421
436
 
422
- If a feature slug is active, persist the report to:
423
- - \`docs/specs/{feature-slug}/state/check-review.md\`
437
+ The review must be performed in multiple passes, not one shallow pass:
438
+ - Pass 1: correctness, bugs, edge cases, failure paths
439
+ - Pass 2: spec/plan/domain/rule alignment and runtime blind spots
440
+ - Pass 3: project patterns, simplicity, bloat, and maintainability
441
+
442
+ If a feature slug is active, persist the report to each write target:
443
+ - \`\$REPO_ROOT/docs/specs/{feature-slug}/state/check-review.md\`
424
444
 
425
445
  Operational rule:
426
446
  - delegate the review to \`@j.reviewer\`
447
+ - provide \`functional-validation-plan.md\` to the reviewer when it exists
448
+ - persist the full verification transcript to \`docs/specs/{feature-slug}/state/check-all-output.txt\`
427
449
  - then write the returned markdown review to \`docs/specs/{feature-slug}/state/check-review.md\`
428
450
  - then summarize whether the repository is blocked by failing checks, review findings, or both
429
451
 
430
452
  The report should contain Critical / Important / Minor findings plus intent-coverage and domain-risk sections.
453
+ The persisted \`check-review.md\` must also contain a \`## Reentry Contract\` section with exact artifact paths and the expected next action for \`/j.implement\`.
431
454
 
432
455
  If \`check-all.sh\` fails, still produce the review report when enough context exists. The report should mention whether failures came from verification, code review findings, or both.
433
-
434
- ## When to use
435
-
436
- - After \`/j.implement\` returns control to the caller
437
- - Before \`/j.unify\`
438
- - After a refactor that touched many files or workflows
439
-
456
+ If \`functional-validation-plan.md\` exists, the review must also call out runtime or integration risks that remain unproven or unsupported by the current implementation.
457
+
458
+ ## When to use
459
+
460
+ - After \`/j.implement\` returns control to the caller
461
+ - Before \`/j.unify\`
462
+ - After a refactor that touched many files or workflows
463
+
440
464
  ## Notes
441
465
 
442
466
  This is intentionally broader than the pre-commit hook.
443
- The pre-commit hook stays fast and only runs structure lint plus tests related to staged files.
467
+ The pre-commit hook stays fast and runs synchronous, blocking gates for structure lint, build verification, and tests related to staged files.
444
468
 
445
469
  If the check script fails or the review report contains Critical or Important findings, invoke \`/j.implement\` again with:
446
470
  - the failing verification output
447
471
  - the path to \`docs/specs/{feature-slug}/state/check-review.md\`
472
+ - the path to \`docs/specs/{feature-slug}/state/check-all-output.txt\`
473
+ - the path to \`docs/specs/{feature-slug}/state/functional-validation-plan.md\` when it exists
474
+
475
+ Forward-only correction rule:
476
+ - if a required correction targets work from a task already marked COMPLETE, create a new follow-up task instead of reopening the completed task
477
+ - \`check-review.md\` should make that explicit when it applies
448
478
 
449
479
  \`@j.implementer\` must treat that review report as actionable correction input for the next pass.
480
+ \`@j.implementer\` must also treat \`functional-validation-plan.md\` as the validation contract for the next \`/j.check\` pass.
481
+
482
+ ## Delegation Rule (MANDATORY)
483
+
484
+ You MUST delegate this command to \`@j.checker\` using the \`task()\` tool.
485
+ Do NOT run the full \`/j.check\` logic yourself — you are the orchestrator, not the checker.
486
+
487
+ \`@j.checker\` is responsible for running \`.opencode/scripts/check-all.sh\`, invoking \`@j.reviewer\`, and persisting \`check-review.md\`.
488
+
489
+ When ANY sub-agent returns output:
490
+ - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
491
+ - NEVER say "I'll continue myself" and take over the sub-agent's job
492
+ - If the checker or reviewer needs more context, provide that context and re-delegate
493
+ - If checks or review findings block progress, route the result back into \`/j.implement\` with the generated artifacts
450
494
  `;
451
495
  // ─── /lint ────────────────────────────────────────────────────────────────────
452
- const LINT = `# /lint — Run Linter
453
-
454
- Run the structure lint used by the pre-commit path.
455
-
456
- ## Usage
457
-
458
- \`\`\`
459
- /j.lint
460
- \`\`\`
461
-
462
- ## What runs
463
-
464
- \`.opencode/scripts/lint-structure.sh\`
465
-
466
- ## When to use
467
-
468
- - During active implementation, to catch structural issues quickly
469
- - When the pre-commit hook fails on lint and you want the same check on demand
470
- - After editing docs, scripts, or config files that need non-test validation
496
+ const LINT = `# /lint — Run Linter
497
+
498
+ Run the structure lint used by the pre-commit path.
499
+
500
+ This command is only the lint gate. The pre-commit hook then runs \`.opencode/scripts/build-verify.sh\` and \`.opencode/scripts/test-related.sh\`, waiting for each one to succeed before continuing.
501
+
502
+ ## Usage
503
+
504
+ \`\`\`
505
+ /j.lint
506
+ \`\`\`
507
+
508
+ ## What runs
509
+
510
+ \`.opencode/scripts/lint-structure.sh\`
511
+
512
+ ## When to use
513
+
514
+ - During active implementation, to catch structural issues quickly
515
+ - When the pre-commit hook fails on lint and you want the same check on demand
516
+ - After editing docs, scripts, or config files that need non-test validation
471
517
  `;
472
518
  // ─── /test ────────────────────────────────────────────────────────────────────
473
- const TEST = `# /test — Run Test Suite
474
-
475
- Run fast, change-scoped tests during implementation.
476
-
477
- ## Usage
478
-
479
- \`\`\`
480
- /j.test
481
- /j.test <pattern>
482
- \`\`\`
483
-
484
- ## Examples
485
-
486
- \`\`\`
487
- /j.test
488
- /j.test src/payments
489
- /j.test --watch
490
- \`\`\`
491
-
492
- ## What runs
493
-
494
- \`.opencode/scripts/test-related.sh\`
495
-
496
- If the repository defines \`test:related\`, that script is preferred.
497
- Otherwise the default fallback tries tools such as \`jest --findRelatedTests\` or \`vitest related\`.
498
-
499
- ## When to use
500
-
501
- - During implementation, before leaving \`@j.implementer\`
502
- - When the pre-commit hook fails on related tests and you want to rerun the same scope
503
- - Use \`/j.check\` for the full repository suite after implementation
519
+ const TEST = `# /test — Run Test Suite
520
+
521
+ Run fast, change-scoped tests during implementation after lint/build gates are green.
522
+
523
+ ## Usage
524
+
525
+ \`\`\`
526
+ /j.test
527
+ /j.test <pattern>
528
+ \`\`\`
529
+
530
+ ## Examples
531
+
532
+ \`\`\`
533
+ /j.test
534
+ /j.test src/payments
535
+ /j.test --watch
536
+ \`\`\`
537
+
538
+ ## What runs
539
+
540
+ \`.opencode/scripts/test-related.sh\`
541
+
542
+ If the repository defines \`test:related\`, that script is preferred.
543
+ Otherwise the default fallback tries tools such as \`jest --findRelatedTests\` or \`vitest related\`.
544
+
545
+ ## When to use
546
+
547
+ - During implementation, before leaving \`@j.implementer\`
548
+ - When the pre-commit hook fails on related tests and you want to rerun the same scope
549
+ - After \`.opencode/scripts/build-verify.sh\` passes when you need the same local gating order as pre-commit
550
+ - Use \`/j.check\` for the full repository suite after implementation
504
551
  `;
505
552
  // ─── /pr-review ───────────────────────────────────────────────────────────────
506
- const PR_REVIEW = `# /pr-review — Advisory PR Review
507
-
508
- Launch the \`@j.reviewer\` agent to perform an advisory code review on the current branch diff.
509
-
510
- ## Usage
511
-
512
- \`\`\`
513
- /j.pr-review
514
- \`\`\`
515
-
516
- ## What happens
517
-
518
- 1. \`@j.reviewer\` reads all files changed in the current branch (vs main)
553
+ const PR_REVIEW = `# /pr-review — Advisory PR Review
554
+
555
+ Launch the \`@j.reviewer\` agent to perform an advisory code review on the current branch diff.
556
+
557
+ ## Usage
558
+
559
+ \`\`\`
560
+ /j.pr-review
561
+ \`\`\`
562
+
563
+ ## What happens
564
+
565
+ 1. \`@j.reviewer\` reads all files changed in the current branch (vs main)
519
566
  2. Reviews for: bugs, edge cases, intent drift, business-rule risk, clarity, security, performance, maintainability
520
567
  3. Returns a structured report: Critical / Important / Minor / Positive Notes / Intent Coverage / Domain Rule Risks
521
- 4. Report is **advisory only** — does not block any merge or pipeline step
522
-
523
- ## When to use
524
-
525
- - After \`/j.unify\` creates the PR, before human review
526
- - When you want a second opinion on the implementation quality
527
- - For pre-merge quality assurance
528
-
529
- ## Distinction from @j.validator
530
-
531
- | \`@j.reviewer\` | \`@j.validator\` |
532
- |---|---|
533
- | Post-PR, advisory | During implementation loop |
534
- | "Is this good code?" | "Does this satisfy the spec?" |
535
- | Never blocks | Gates the pipeline |
536
- | Read-only | Can fix issues directly |
537
-
538
- ## Quality target
539
-
540
- Aim for PR artifacts with the same quality bar as a strong human-authored engineering PR:
541
- - state the purpose and problem clearly
542
- - summarize the solution in reviewer-friendly steps
543
- - map changed files to responsibilities
544
- - provide runnable validation steps with expected outcomes
568
+ 4. Report is **advisory only** — does not block any merge or pipeline step
569
+
570
+ ## When to use
571
+
572
+ - After \`/j.unify\` creates the PR, before human review
573
+ - When you want a second opinion on the implementation quality
574
+ - For pre-merge quality assurance
575
+
576
+ ## Distinction from @j.validator
577
+
578
+ | \`@j.reviewer\` | \`@j.validator\` |
579
+ |---|---|
580
+ | Post-PR, advisory | During implementation loop |
581
+ | "Is this good code?" | "Does this satisfy the spec?" |
582
+ | Never blocks | Gates the pipeline |
583
+ | Read-only | Can fix issues directly |
584
+
585
+ ## Quality target
586
+
587
+ Aim for PR artifacts with the same quality bar as a strong human-authored engineering PR:
588
+ - state the purpose and problem clearly
589
+ - summarize the solution in reviewer-friendly steps
590
+ - map changed files to responsibilities
591
+ - provide runnable validation steps with expected outcomes
545
592
  `;
546
593
  // ─── /status ──────────────────────────────────────────────────────────────────
547
594
  const STATUS = `# /status — Show Current Work Status
548
595
 
549
596
  Display session summary and per-task state — tasks, progress, and blockers.
550
-
551
- ## Usage
552
-
597
+
598
+ ## Usage
599
+
553
600
  \`\`\`
554
601
  /j.status
555
602
  /j.status <feature-slug>
556
603
  \`\`\`
557
-
558
- ## What shows
559
-
604
+
605
+ ## What shows
606
+
560
607
  - Current goal and active plan path (from global session state)
561
608
  - Task table: ID / description / agent / status / attempt
562
- - Integration table details from \`integration-state.json\`: validated commit, resulting feature commit, and integration method/status
609
+ - Integration table details from \`integration-state.json\`: validated commit on the shared feature branch and bookkeeping status
563
610
  - In-progress items with last known state and heartbeat
564
611
  - Blocked items with blocker descriptions
565
612
  - Retried or stale items visible from per-task execution state
566
613
  - Session log (recent actions)
567
-
568
- ## When to use
569
-
570
- - At the start of a session to orient yourself
571
- - After resuming work to see what's left
572
- - To check if all tasks are complete before running \`/j.unify\`
573
-
574
- ## Source
575
-
576
- Reads state from **two locations** (in order):
577
-
578
- 1. **Global session summary**: \`.opencode/state/execution-state.md\` — high-level session info (goal, plan path, session log)
579
- 2. **Per-task state**: \`docs/specs/{feature-slug}/state/tasks/task-{id}/execution-state.md\` — detailed task progress, attempts, heartbeats, blockers, and validated commit
580
- 3. **Integration manifest**: \`docs/specs/{feature-slug}/state/integration-state.json\` — canonical feature branch, task validated SHAs, resulting feature SHAs, and integration/cleanup status
614
+
615
+ ## When to use
616
+
617
+ - At the start of a session to orient yourself
618
+ - After resuming work to see what's left
619
+ - To check if all tasks are complete before running \`/j.unify\`
620
+
621
+ ## Source
622
+
623
+ Reads state from \`.opencode/state/active-plan.json\` to discover all write targets, then reads per-target artifacts:
624
+
625
+ 1. **Active plan**: \`.opencode/state/active-plan.json\` — identifies write targets and their \`targetRepoRoot\` paths
626
+ 2. **Per-target task state**: \`{targetRepoRoot}/docs/specs/{feature-slug}/state/tasks/task-{id}/execution-state.md\` — detailed task progress, attempts, heartbeats, blockers, and validated commit
627
+ 3. **Per-target integration manifest**: \`{targetRepoRoot}/docs/specs/{feature-slug}/state/integration-state.json\` — canonical feature branch, task validated SHAs, and commit bookkeeping/cleanup status
628
+
629
+ In multi-repo mode, show a section for each write target project so it's clear which tasks belong to which repo.
581
630
 
582
631
  If a \`<feature-slug>\` argument is provided, only show per-task state for that feature.
583
- If omitted, infer the slug from the active plan path in the active execution-state file.
632
+ If omitted, infer the slug from the active plan.
584
633
 
585
634
  No agent needed — this is a direct state file read.
586
635
  `;
@@ -588,60 +637,81 @@ No agent needed — this is a direct state file read.
588
637
  const UNIFY_CMD = `# /unify — Close the Loop
589
638
 
590
639
  Invoke the \`@j.unify\` agent to reconcile plan vs delivery and execute only the enabled closeout steps.
591
-
592
- ## Usage
593
-
594
- \`\`\`
595
- /j.unify
596
- \`\`\`
597
-
598
- ## What happens
599
-
640
+
641
+ ## Usage
642
+
643
+ \`\`\`
644
+ /j.unify
645
+ \`\`\`
646
+
647
+ ## What happens
648
+
600
649
  1. Read \`.opencode/juninho-config.json\` (\`workflow\` section)
601
- 2. Reconcile \`plan.md\` vs actual git diff — mark tasks DONE/PARTIAL/SKIPPED
602
- 3. Run only the enabled closeout steps, such as:
650
+ 2. Read \`.opencode/state/active-plan.json\` to discover all write targets
651
+ 3. For each write target (\`\$REPO_ROOT\`), reconcile \`\$REPO_ROOT/docs/specs/{feature-slug}/plan.md\` vs actual git diff — mark tasks DONE/PARTIAL/SKIPPED
652
+ 4. Run only the enabled closeout steps per target, such as:
603
653
  - reconcile \`persistent-context.md\`
604
- - reconcile \`docs/domain/\` or \`docs/domain/INDEX.md\`
605
- - cleanup integrated task worktrees/branches using \`integration-state.json\`
606
- - create a PR
607
- 4. If PR creation is enabled, draft a rich PR body with purpose, problem, solution, changed files, and validation steps
608
-
609
- ## When to use
610
-
654
+ - reconcile \`\$REPO_ROOT/docs/domain/\` or \`\$REPO_ROOT/docs/domain/INDEX.md\`
655
+ - cleanup integration bookkeeping using \`\$REPO_ROOT/docs/specs/{feature-slug}/state/integration-state.json\`
656
+ - create a PR (per target repo when applicable)
657
+ 4. If PR creation is enabled, draft a rich PR body with purpose, problem, solution, changed files, and validation steps
658
+ 5. Treat forward-only follow-up tasks created after \`/j.check\` as first-class delivery units when reconciling plan vs delivery
659
+ 6. Use the latest \`check-review.md\` reentry contract, when present, to explain what was corrected before closeout
660
+
661
+ ## When to use
662
+
611
663
  After \`@j.implementer\` exits, \`/j.check\` passes, and \`@j.validator\` has approved the required work.
612
- By this point, code must already be integrated into \`feature/{feature-slug}\`.
613
-
614
- ## Prerequisites
615
-
616
- - All tasks in \`execution-state.md\` should be marked complete
617
- - All validator passes should return APPROVED or APPROVED_WITH_NOTES
618
- - \`gh\` CLI must be authenticated (\`gh auth login\`)
619
-
620
- ## Note
621
-
664
+ By this point, code must already be committed into \`feature/{feature-slug}\`.
665
+
666
+ ## Prerequisites
667
+
668
+ - All tasks in \`execution-state.md\` should be marked complete
669
+ - All validator passes should return APPROVED or APPROVED_WITH_NOTES
670
+ - \`gh\` CLI must be authenticated (\`gh auth login\`)
671
+
672
+ ## Note
673
+
622
674
  UNIFY behavior is controlled by \`.opencode/juninho-config.json\` under \`workflow\`.
623
675
  If PR creation or doc updates are disabled there, \`@j.unify\` should skip those steps and report what was intentionally not executed.
624
676
  UNIFY is no longer responsible for first-time code integration.
625
677
  UNIFY should also avoid creating a final synthetic git commit; history should already reflect the planned task commits by the time \`/j.unify\` runs.
678
+ If review-driven follow-up tasks were added after completed work, UNIFY should report them as forward-only corrections, not reopened task ownership.
626
679
  `;
627
680
  // ─── /finish-setup ───────────────────────────────────────────────────────────
628
681
  const FINISH_SETUP = `# /finish-setup — Bootstrap Repository Knowledge
629
682
 
630
683
  This is the canonical repository bootstrap command after installing the harness.
631
684
 
632
- Scan the entire codebase, generate hierarchical AGENTS.md files, discover recurring file patterns, generate dynamic skills, and populate domain/principles documentation.
633
-
634
- ## Usage
635
-
636
- \`\`\`
637
- /j.finish-setup
638
- \`\`\`
639
-
640
- ## What happens
641
-
685
+ Scan a project codebase, generate hierarchical AGENTS.md files, discover recurring file patterns, generate dynamic skills, and populate domain/principles documentation.
686
+
687
+ ## Usage
688
+
689
+ \`\`\`
690
+ /j.finish-setup
691
+ /j.finish-setup <project-path-or-name>
692
+ \`\`\`
693
+
694
+ When a project argument is provided, all artifacts are generated **inside that project's root**, not at the workspace root.
695
+ When no argument is provided and the harness runs from a workspace root with multiple discovered projects, ask which project to bootstrap.
696
+
697
+ ## Multi-Repo Behavior
698
+
699
+ The harness can run from a workspace root (e.g., \`~/repos/\`) that contains multiple project repositories.
700
+ In this mode, \`/j.finish-setup\` must resolve the **target project root** before starting any phase.
701
+
702
+ **Target resolution order:**
703
+ 1. Explicit argument: \`/j.finish-setup olxbr/trp-partner-api\` or \`/j.finish-setup /absolute/path/to/repo\`
704
+ 2. Single project in workspace: use it automatically
705
+ 3. Active plan target: if \`active-plan.json\` exists, offer to bootstrap each write target that lacks docs
706
+ 4. Multiple projects, no argument: list discovered projects and ask the user to choose
707
+
708
+ **All generated paths below are relative to the resolved \`\$PROJECT_ROOT\`, not the workspace root.**
709
+
710
+ ## What happens
711
+
642
712
  ### Phase 1 — Structural Scan (via @j.explore)
643
713
 
644
- 1. Invoke \`@j.explore\` to scan the entire codebase
714
+ 1. Invoke \`@j.explore\` to scan the **target project codebase** at \`\$PROJECT_ROOT\`
645
715
  2. Identify significant directory boundaries for local instructions:
646
716
  - root project context for the main \`AGENTS.md\`
647
717
  - source-tree boundaries such as \`src/\`, \`app/\`, \`internal/\`, \`pkg/\`, \`services/\`, \`modules/\`
@@ -665,8 +735,8 @@ Scan the entire codebase, generate hierarchical AGENTS.md files, discover recurr
665
735
 
666
736
  ### Phase 2 — Generate Hierarchical AGENTS.md
667
737
 
668
- 5. Generate or refresh hierarchical \`AGENTS.md\` files:
669
- - Root \`AGENTS.md\`: stack summary, real build/test commands, directory layout, critical repo rules
738
+ 5. Generate or refresh hierarchical \`AGENTS.md\` files inside \`\$PROJECT_ROOT\`:
739
+ - Root \`\$PROJECT_ROOT/AGENTS.md\`: stack summary, real build/test commands, directory layout, critical repo rules
670
740
  - Directory-level \`AGENTS.md\`: local architecture, invariants, module boundaries, integration contracts
671
741
  6. Keep each generated \`AGENTS.md\` scoped to its directory only:
672
742
  - no copy-pasting the entire root file into child directories
@@ -675,51 +745,57 @@ Scan the entire codebase, generate hierarchical AGENTS.md files, discover recurr
675
745
 
676
746
  ### Phase 3 — Generate Dynamic Skills
677
747
 
678
- 7. For each discovered pattern, create a skill in \`.opencode/skills/j.{pattern}-writing/SKILL.md\`:
679
- - Frontmatter with \`name\`, \`description\`
680
- - "When this skill activates" with the glob patterns from the project
681
- - "Required Steps" extracted from the exemplar file analysis
682
- - "Anti-patterns to avoid" based on what the exemplars do NOT do
683
- - Canonical example copied/adapted from a real project file
684
- 8. Update \`.opencode/skill-map.json\` with new regex patterns for each skill
748
+ 7. For each discovered pattern, create a skill in \`.opencode/skills/j.{pattern}-writing/SKILL.md\` (at the **harness root**, not the project root — skills are shared across projects):
749
+ - Frontmatter with \`name\`, \`description\`
750
+ - "When this skill activates" with the glob patterns from the project
751
+ - "Required Steps" extracted from the exemplar file analysis
752
+ - "Anti-patterns to avoid" based on what the exemplars do NOT do
753
+ - Canonical example copied/adapted from a real project file
754
+ - Before finalizing or revising any skill, load and apply the local \`skill-creator\` skill so the description, trigger criteria, and eval hooks are explicit
755
+ 8. Update \`.opencode/skill-map.json\` (at the harness root) with new regex patterns for each skill
756
+ 9. For every created or changed skill, add intelligent eval coverage that proves:
757
+ - the skill triggers under realistic prompts
758
+ - near-miss prompts do not trigger it
759
+ - the skill changes agent behavior on at least one implementation task
685
760
 
686
761
  ### Phase 4 — Generate Documentation
687
762
 
688
- 9. Generate initial docs in \`docs/domain/\` (subdirectories by discovered domain)
689
- 10. Generate initial docs in \`docs/principles/\` based on patterns found
690
- 11. Populate \`docs/principles/manifest\` with real keywords
691
- 12. Populate \`docs/domain/INDEX.md\` with real entries and CARL keywords
763
+ 10. Generate initial docs in \`\$PROJECT_ROOT/docs/domain/\` (subdirectories by discovered domain)
764
+ 11. Generate initial docs in \`\$PROJECT_ROOT/docs/principles/\` based on patterns found
765
+ 12. Populate \`\$PROJECT_ROOT/docs/principles/manifest\` with real keywords
766
+ 13. Populate \`\$PROJECT_ROOT/docs/domain/INDEX.md\` with real entries and CARL keywords
692
767
 
693
768
  ### Phase 5 — Refresh Local Automation Stubs
694
769
 
695
- 13. Validate \`.opencode/scripts/lint-structure.sh\`
696
- 14. Validate \`.opencode/scripts/test-related.sh\`
697
- 15. Validate \`.opencode/scripts/check-all.sh\`
698
- 16. Align commands documented in generated \`AGENTS.md\` files with the actual repository scripts
699
-
700
- ## Delegation Rule (MANDATORY)
701
-
702
- You MUST use \`@j.explore\` for Phase 1. Do NOT try to scan the codebase yourself.
703
-
770
+ 14. Validate \`.opencode/scripts/lint-structure.sh\` (at harness root)
771
+ 15. Validate \`.opencode/scripts/test-related.sh\` (at harness root)
772
+ 16. Validate \`.opencode/scripts/check-all.sh\` (at harness root)
773
+ 17. Align commands documented in generated \`AGENTS.md\` files with the actual repository scripts and build tools found in \`\$PROJECT_ROOT\`
774
+
775
+ ## Delegation Rule (MANDATORY)
776
+
777
+ You MUST use \`@j.explore\` for Phase 1. Do NOT try to scan the codebase yourself.
778
+
704
779
  When \`@j.explore\` returns its report:
705
780
  - Read the FULL report
706
781
  - Extract all file patterns and structural findings
707
782
  - Use them to generate AGENTS, skills, and docs
708
-
783
+
709
784
  ## When to use
710
785
 
711
786
  - Right after \`juninho setup\` on an existing project
712
787
  - After major structural refactors that introduce new file patterns
713
788
  - When onboarding a new project to the framework
789
+ - In multi-repo workspaces, to bootstrap a target project that lacks context artifacts (AGENTS.md, docs/domain, docs/principles)
714
790
  - After \`/j.finish-setup\` generates files, review and augment them with non-obvious domain knowledge
715
-
716
- ## Result
717
-
718
- After completion, the project will have:
791
+
792
+ ## Result
793
+
794
+ After completion, the target project will have:
719
795
  - Hierarchical \`AGENTS.md\` files aligned to the real directory structure
720
- - Custom skills that match its specific file patterns and conventions
721
- - Domain documentation populated with real business domains
722
- - Principles documentation reflecting actual codebase patterns
796
+ - Custom skills registered in the harness that match the project's file patterns and conventions
797
+ - Domain documentation populated with real business domains at \`\$PROJECT_ROOT/docs/domain/\`
798
+ - Principles documentation reflecting actual codebase patterns at \`\$PROJECT_ROOT/docs/principles/\`
723
799
  - Updated local automation stubs and command references
724
800
  `;
725
801
  //# sourceMappingURL=commands.js.map