@kleber.mottajr/juninho 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +14 -15
  2. package/dist/config.d.ts +31 -1
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +57 -3
  5. package/dist/config.js.map +1 -1
  6. package/dist/installer.d.ts.map +1 -1
  7. package/dist/installer.js +59 -45
  8. package/dist/installer.js.map +1 -1
  9. package/dist/lint-detection.d.ts +2 -2
  10. package/dist/lint-detection.d.ts.map +1 -1
  11. package/dist/lint-detection.js +33 -7
  12. package/dist/lint-detection.js.map +1 -1
  13. package/dist/project-types.d.ts +7 -2
  14. package/dist/project-types.d.ts.map +1 -1
  15. package/dist/project-types.js +36 -3
  16. package/dist/project-types.js.map +1 -1
  17. package/dist/templates/agents.d.ts +2 -2
  18. package/dist/templates/agents.d.ts.map +1 -1
  19. package/dist/templates/agents.js +551 -100
  20. package/dist/templates/agents.js.map +1 -1
  21. package/dist/templates/commands.d.ts.map +1 -1
  22. package/dist/templates/commands.js +330 -285
  23. package/dist/templates/commands.js.map +1 -1
  24. package/dist/templates/docs.js +36 -24
  25. package/dist/templates/docs.js.map +1 -1
  26. package/dist/templates/plugins.d.ts.map +1 -1
  27. package/dist/templates/plugins.js +699 -99
  28. package/dist/templates/plugins.js.map +1 -1
  29. package/dist/templates/state.d.ts.map +1 -1
  30. package/dist/templates/state.js +138 -186
  31. package/dist/templates/state.js.map +1 -1
  32. package/dist/templates/support-scripts.d.ts.map +1 -1
  33. package/dist/templates/support-scripts.js +927 -247
  34. package/dist/templates/support-scripts.js.map +1 -1
  35. package/dist/templates/tools.d.ts +2 -2
  36. package/dist/templates/tools.d.ts.map +1 -1
  37. package/dist/templates/tools.js +2 -2
  38. package/dist/templates/tools.js.map +1 -1
  39. package/package.json +5 -2
@@ -12,7 +12,6 @@ function writeCommands(projectDir) {
12
12
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.spec.md"), SPEC);
13
13
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.implement.md"), IMPLEMENT);
14
14
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.sync-docs.md"), SYNC_DOCS);
15
- (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.init-deep.md"), INIT_DEEP);
16
15
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.start-work.md"), START_WORK);
17
16
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.handoff.md"), HANDOFF);
18
17
  (0, fs_1.writeFileSync)(path_1.default.join(commandsDir, "j.ulw-loop.md"), ULW_LOOP);
@@ -116,58 +115,84 @@ When ANY sub-agent returns output:
116
115
  Run \`/j.plan\` to create an execution plan, then \`/j.implement\` to build.
117
116
  `;
118
117
  // ─── /implement ───────────────────────────────────────────────────────────────
119
- const IMPLEMENT = `# /implement — Execute Plan or Spec
120
-
121
- Invoke the \`@j.implementer\` agent to build what was planned or specified.
122
-
123
- ## Usage
124
-
125
- \`\`\`
126
- /j.implement
127
- /j.implement <specific task or file>
128
- \`\`\`
129
-
130
- ## Examples
131
-
132
- \`\`\`
133
- /j.implement
134
- /j.implement the authentication middleware
135
- /j.implement docs/specs/user-profile.md
136
- \`\`\`
137
-
138
- ## What happens
139
-
140
- 1. \`@j.implementer\` reads the active \`plan.md\` (auto-loaded by plan-autoload plugin)
141
- 2. Reads \`.opencode/state/workflow-config.md\` to understand handoff and UNIFY behavior
142
- 3. Or reads the specified spec file
143
- 4. 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
- 5. Uses the fast pre-commit path while implementing:
148
- - \`.opencode/scripts/lint-structure.sh\`
149
- - \`.opencode/scripts/test-related.sh\`
150
- 6. Spawns \`@j.validator\` for spec compliance
151
- 7. Exits when code changes and task-level tests are complete
152
- 8. The caller then runs \`.opencode/scripts/check-all.sh\` or \`/j.check\`
153
- 9. If the repo-wide check fails, delegate back to \`@j.implementer\` with the failing output
154
-
155
- ## Delegation Rule (MANDATORY)
156
-
157
- You MUST delegate this task to \`@j.implementer\` using the \`task()\` tool.
158
- Do NOT implement code yourself — you are the orchestrator, not the executor.
159
-
160
- When ANY sub-agent returns output:
161
- - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
162
- - NEVER say "I'll continue myself" and take over the sub-agent's job
163
- - Sub-agent unknowns/ambiguities are VALUABLE DATA forward them to the user via \`question\` tool
164
- - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
165
-
166
- ## After implementation
167
-
168
- Run \`/j.check\` for repo-wide verification.
169
- If \`/j.check\` fails, invoke \`/j.implement\` again with the failing output.
170
- Run \`/j.unify\` only after the full check passes and \`workflow-config.md\` enables UNIFY.
118
+ const IMPLEMENT = `# /implement — Execute Plan or Spec
119
+
120
+ Invoke the \`@j.implementer\` agent to build what was planned or specified.
121
+
122
+ ## Usage
123
+
124
+ \`\`\`
125
+ /j.implement
126
+ /j.implement <specific task or file>
127
+ \`\`\`
128
+
129
+ ## Examples
130
+
131
+ \`\`\`
132
+ /j.implement
133
+ /j.implement the authentication middleware
134
+ /j.implement docs/specs/user-profile.md
135
+ \`\`\`
136
+
137
+ ## What happens
138
+
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:
151
+ - \`.opencode/scripts/lint-structure.sh\`
152
+ - \`.opencode/scripts/test-related.sh\`
153
+ - 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
168
+
169
+ ## History Rules
170
+
171
+ - A task branch must never cherry-pick or merge another task's commit by hand.
172
+ - 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
+ - Closeout docs that should land in git history must be explicit plan tasks, not post-hoc UNIFY-only commits.
175
+
176
+ ## Delegation Rule (MANDATORY)
177
+
178
+ You MUST delegate this task to \`@j.implementer\` using the \`task()\` tool.
179
+ Do NOT implement code yourself — you are the orchestrator, not the executor.
180
+
181
+ The first delegated \`@j.implementer\` session is the workflow owner.
182
+ It must not immediately delegate the same whole implementation workflow to another generic \`@j.implementer\`.
183
+ Only explicit task-worker prompts such as \`Execute task {id} ...\` may create child \`@j.implementer\` sessions.
184
+
185
+ When ANY sub-agent returns output:
186
+ - NEVER dismiss it as "incomplete" or "the agent didn't do what was asked"
187
+ - NEVER say "I'll continue myself" and take over the sub-agent's job
188
+ - Sub-agent unknowns/ambiguities are VALUABLE DATA — forward them to the user via \`question\` tool
189
+ - If the sub-agent's report has gaps, pass those gaps to the user as questions — do NOT fill them yourself
190
+
191
+ ## After implementation
192
+
193
+ Run \`/j.check\` for repo-wide verification.
194
+ If \`/j.check\` fails, invoke \`/j.implement\` again with the failing output.
195
+ Run \`/j.unify\` only after the full check passes and \`juninho-config.json\` enables UNIFY.
171
196
  `;
172
197
  // ─── /sync-docs ───────────────────────────────────────────────────────────────
173
198
  const SYNC_DOCS = `# /sync-docs — Refresh AGENTS and Documentation
@@ -183,7 +208,7 @@ Generate or update \`AGENTS.md\`, domain docs, and principle docs using the curr
183
208
 
184
209
  ## What happens
185
210
 
186
- 1. Read \`.opencode/state/workflow-config.md\`
211
+ 1. Read \`.opencode/juninho-config.json\` to understand documentation-related workflow defaults
187
212
  2. Identify key files for the requested scope
188
213
  3. Update the right doc surface for each kind of knowledge:
189
214
  - \`AGENTS.md\` for directory-local working rules and commands
@@ -211,73 +236,6 @@ Do NOT rewrite the docs yourself when the harness workflow asks for agent execut
211
236
  - After major refactors that changed local rules or business behavior
212
237
  - When CARL recall quality degrades because docs or manifests are stale
213
238
  `;
214
- // ─── /init-deep ───────────────────────────────────────────────────────────────
215
- const INIT_DEEP = `# /init-deep — Deep Codebase Initialization
216
-
217
- Perform a deep scan of the codebase and generate hierarchical AGENTS.md files, domain documentation, and local quality-gate scripts.
218
-
219
- ## Usage
220
-
221
- \`\`\`
222
- /j.init-deep
223
- \`\`\`
224
-
225
- ## What happens
226
-
227
- ### 1. Generate hierarchical AGENTS.md files
228
-
229
- Scans the directory tree and generates \`AGENTS.md\` files at each significant level:
230
-
231
- - **Root \`AGENTS.md\`** (already exists): stack summary, build/test commands, critical rules — keep under 200 lines
232
- - **\`src/AGENTS.md\`**: source-tree architecture, directory layout, barrel export conventions, import rules
233
- - **\`src/{module}/AGENTS.md\`**: module-specific rules, business invariants, known pitfalls, integration contracts
234
-
235
- Each file contains only context relevant to its directory — no duplication.
236
- The \`directory-agents-injector\` plugin automatically injects the relevant levels when an agent reads any file.
237
-
238
- ### 2. Populate domain documentation
239
-
240
- Writes to \`docs/domain/INDEX.md\`:
241
- - Domain entity catalog with CARL Keywords and Files entries
242
- - API route inventory
243
- - Service layer patterns
244
-
245
- ### 3. Update principles manifest
246
-
247
- Adds entries to \`docs/principles/manifest\` (KEY=VALUE format):
248
- - Canonical code patterns discovered
249
- - Architectural directives
250
- - Technology decisions
251
-
252
- ### 4. Refresh local automation stubs
253
-
254
- - Validate \`.opencode/scripts/lint-structure.sh\`
255
- - Validate \`.opencode/scripts/test-related.sh\`
256
- - Validate \`.opencode/scripts/check-all.sh\`
257
- - Align commands in \`AGENTS.md\` with the actual repository scripts
258
-
259
- ## When to use
260
-
261
- - First time setting up the framework on an existing project
262
- - After major refactors that change module structure
263
- - When onboarding agents to a new area of the codebase
264
- - After \`/j.init-deep\` generates files, review and augment them with non-obvious domain knowledge
265
-
266
- ## Result
267
-
268
- \`\`\`
269
- project/
270
- ├── AGENTS.md # Updated with stack summary
271
- ├── src/
272
- │ ├── AGENTS.md # Generated: src-level architecture context
273
- │ └── payments/
274
- │ └── AGENTS.md # Generated: payments-specific context
275
- └── docs/domain/INDEX.md # Populated with CARL entries
276
- \`\`\`
277
-
278
- The CARL plugin uses \`INDEX.md\` to inject domain context automatically.
279
- The \`directory-agents-injector\` plugin injects the right \`AGENTS.md\` layers per file read.
280
- `;
281
239
  // ─── /start-work ─────────────────────────────────────────────────────────────
282
240
  const START_WORK = `# /start-work — Begin a Work Session
283
241
 
@@ -310,57 +268,64 @@ Initialize context for a focused work session on a specific task.
310
268
  The session is now focused. Use \`/j.implement\` to build, \`@j.validator\` to check, \`/j.handoff\` when done.
311
269
  `;
312
270
  // ─── /handoff ─────────────────────────────────────────────────────────────────
313
- const HANDOFF = `# /handoff — End-of-Session Handoff
314
-
315
- Prepare a handoff document for the next session or team member.
316
-
317
- ## Usage
318
-
319
- \`\`\`
320
- /j.handoff
321
- \`\`\`
322
-
323
- ## What happens
324
-
325
- 1. Reads current \`execution-state.md\`
326
- 2. Summarizes:
327
- - What was completed this session
328
- - What is in progress (with file names and last known state)
329
- - What is blocked and why
330
- - Exact next step to continue
331
-
332
- 3. Updates \`execution-state.md\` with handoff notes
333
-
334
- 4. Optionally commits the state files:
335
- \`git add .opencode/state/ && git commit -m "chore: session handoff"\`
336
-
337
- ## Output format
338
-
339
- \`\`\`markdown
340
- # Session Handoff — {date}
341
-
342
- ## Completed
343
- - [x] Task description
344
-
345
- ## In Progress
346
- - [ ] Task description
347
- - Last state: {what was done}
348
- - Next step: {exactly what to do next}
349
- - Files: {relevant files}
350
-
351
- ## Blocked
352
- - [ ] Task description
353
- - Blocker: {what's blocking}
354
- - Resolution needed: {what needs to happen}
355
-
356
- ## Next Session: Start with
357
- {single, clear action to take first}
358
- \`\`\`
271
+ const HANDOFF = `# /handoff — End-of-Session Handoff
272
+
273
+ Prepare a handoff document for the next session or team member.
274
+
275
+ ## Usage
276
+
277
+ \`\`\`
278
+ /j.handoff
279
+ \`\`\`
280
+
281
+ ## What happens
282
+
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:
289
+ - What was completed this session
290
+ - What is in progress (with file names, attempt number, and last heartbeat)
291
+ - What is blocked and why
292
+ - 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
295
+ - Exact next step to continue
296
+
297
+ 6. Updates local execution state with handoff notes
298
+
299
+ 7. Optionally commits the state files:
300
+ \`git add .opencode/state/ docs/specs/*/state/ && git commit -m "chore: session handoff"\`
301
+
302
+ ## Output format
303
+
304
+ \`\`\`markdown
305
+ # Session Handoff {date}
306
+
307
+ ## Completed
308
+ - [x] Task description
309
+
310
+ ## In Progress
311
+ - [ ] Task description
312
+ - Last state: {what was done}
313
+ - Next step: {exactly what to do next}
314
+ - Files: {relevant files}
315
+
316
+ ## Blocked
317
+ - [ ] Task description
318
+ - Blocker: {what's blocking}
319
+ - Resolution needed: {what needs to happen}
320
+
321
+ ## Next Session: Start with
322
+ {single, clear action to take first}
323
+ \`\`\`
359
324
  `;
360
325
  // ─── /ulw-loop ────────────────────────────────────────────────────────────────
361
- const ULW_LOOP = `# /ulw-loop — Ultra Work Loop
362
-
363
- Activate maximum parallelism mode — work until all tasks in execution-state.md are complete.
326
+ const ULW_LOOP = `# /ulw-loop — Ultra Work Loop
327
+
328
+ Activate high-throughput mode — work until all tasks in the plan are complete.
364
329
 
365
330
  ## Usage
366
331
 
@@ -371,29 +336,39 @@ Activate maximum parallelism mode — work until all tasks in execution-state.md
371
336
 
372
337
  ## What happens
373
338
 
374
- 1. Reads \`execution-state.md\` for task list
375
- 2. Identifies tasks that can run in parallel (no dependencies)
376
- 3. Spins up multiple \`@j.implementer\` agents in parallel via worktrees:
377
- - Each worktree works on independent files
378
- - No merge conflicts by design
379
- 4. \`@j.validator\` runs after each wave
380
- 5. Loop continues until all tasks are marked complete
381
- 6. Run \`/j.check\` once task-level work is done
382
- 7. \`@j.unify\` runs only if closeout is enabled in \`workflow-config.md\`
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
383
357
 
384
358
  ## When to use
385
359
 
386
360
  - Many independent tasks in the backlog
387
361
  - Large feature that can be parallelized
388
- - When you want maximum throughput
362
+ - When you want the highest safe throughput
389
363
 
390
364
  ## Parallel execution model
391
365
 
392
366
  \`\`\`
393
- Wave 1 (parallel):
394
- worktree-a: implement service layer
395
- worktree-b: implement API routes
396
- worktree-c: implement UI components
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-*
397
372
 
398
373
  Wave 2 (sequential):
399
374
  main: wire everything together
@@ -405,14 +380,20 @@ Wave 3 (parallel):
405
380
 
406
381
  ## Safety
407
382
 
408
- - Each worktree is isolated — no cross-contamination
409
- - Merge happens only after all waves pass validation and the repo-wide check passes
410
- - If any wave fails, the loop pauses and reports blockers
383
+ - Each worktree is isolated — no cross-contamination
384
+ - 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
386
+ - Each task carries its own lease and heartbeat in feature-local state
387
+ - 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
390
+ - UNIFY performs cleanup only; it must not be responsible for first-time code integration
391
+ - If any wave fails, the loop pauses and reports blockers — read \`docs/specs/{slug}/state/\` for details
411
392
  `;
412
393
  // ─── /check ───────────────────────────────────────────────────────────────────
413
- const CHECK = `# /check — Run All Quality Gates
414
-
415
- Run the full repository verification after \`@j.implementer\` exits.
394
+ const CHECK = `# /check — Run All Quality Gates
395
+
396
+ Run the full repository verification after \`@j.implementer\` exits, then perform a detailed PR-style review pass.
416
397
 
417
398
  ## Usage
418
399
 
@@ -420,15 +401,35 @@ Run the full repository verification after \`@j.implementer\` exits.
420
401
  /j.check
421
402
  \`\`\`
422
403
 
423
- ## What runs
424
-
425
- \`.opencode/scripts/check-all.sh\`
426
-
427
- This script is expected to run the repository-wide checks for the current stack.
428
- Typical examples:
429
- - \`npm run typecheck && npm run lint && npm test\`
430
- - \`./gradlew test\`
431
- - \`./mvnw test\`
404
+ ## What runs
405
+
406
+ 1. \`.opencode/scripts/check-all.sh\`
407
+ 2. A detailed read-only review via \`@j.reviewer\`
408
+
409
+ This script is expected to run the repository-wide checks for the current stack.
410
+ Typical examples:
411
+ - \`npm run typecheck && npm run lint && npm test\`
412
+ - \`./gradlew test\`
413
+ - \`./mvnw test\`
414
+
415
+ The review pass must inspect the resulting integrated branch like a real PR review and look for:
416
+ - bugs and missed edge cases
417
+ - spec or plan intent drift
418
+ - business-rule/domain-rule violations
419
+ - project pattern or AGENTS violations
420
+ - maintainability or safety concerns worth correcting before closeout
421
+
422
+ If a feature slug is active, persist the report to:
423
+ - \`docs/specs/{feature-slug}/state/check-review.md\`
424
+
425
+ Operational rule:
426
+ - delegate the review to \`@j.reviewer\`
427
+ - then write the returned markdown review to \`docs/specs/{feature-slug}/state/check-review.md\`
428
+ - then summarize whether the repository is blocked by failing checks, review findings, or both
429
+
430
+ The report should contain Critical / Important / Minor findings plus intent-coverage and domain-risk sections.
431
+
432
+ 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.
432
433
 
433
434
  ## When to use
434
435
 
@@ -436,10 +437,16 @@ Typical examples:
436
437
  - Before \`/j.unify\`
437
438
  - After a refactor that touched many files or workflows
438
439
 
439
- ## Notes
440
-
441
- This is intentionally broader than the pre-commit hook.
442
- The pre-commit hook stays fast and only runs structure lint plus tests related to staged files.
440
+ ## Notes
441
+
442
+ 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.
444
+
445
+ If the check script fails or the review report contains Critical or Important findings, invoke \`/j.implement\` again with:
446
+ - the failing verification output
447
+ - the path to \`docs/specs/{feature-slug}/state/check-review.md\`
448
+
449
+ \`@j.implementer\` must treat that review report as actionable correction input for the next pass.
443
450
  `;
444
451
  // ─── /lint ────────────────────────────────────────────────────────────────────
445
452
  const LINT = `# /lint — Run Linter
@@ -509,8 +516,8 @@ Launch the \`@j.reviewer\` agent to perform an advisory code review on the curre
509
516
  ## What happens
510
517
 
511
518
  1. \`@j.reviewer\` reads all files changed in the current branch (vs main)
512
- 2. Reviews for: logic correctness, clarity, security, performance, maintainability
513
- 3. Returns a structured report: Critical / Important / Minor / Positive Notes
519
+ 2. Reviews for: bugs, edge cases, intent drift, business-rule risk, clarity, security, performance, maintainability
520
+ 3. Returns a structured report: Critical / Important / Minor / Positive Notes / Intent Coverage / Domain Rule Risks
514
521
  4. Report is **advisory only** — does not block any merge or pipeline step
515
522
 
516
523
  ## When to use
@@ -537,23 +544,26 @@ Aim for PR artifacts with the same quality bar as a strong human-authored engine
537
544
  - provide runnable validation steps with expected outcomes
538
545
  `;
539
546
  // ─── /status ──────────────────────────────────────────────────────────────────
540
- const STATUS = `# /status — Show Current Work Status
541
-
542
- Display the current \`execution-state.md\` summary — tasks, progress, and blockers.
547
+ const STATUS = `# /status — Show Current Work Status
548
+
549
+ Display session summary and per-task state — tasks, progress, and blockers.
543
550
 
544
551
  ## Usage
545
552
 
546
- \`\`\`
547
- /j.status
548
- \`\`\`
553
+ \`\`\`
554
+ /j.status
555
+ /j.status <feature-slug>
556
+ \`\`\`
549
557
 
550
558
  ## What shows
551
559
 
552
- - Current goal and active plan path
553
- - Task table: ID / description / agent / status
554
- - In-progress items with last known state
555
- - Blocked items with blocker descriptions
556
- - Session log (recent actions)
560
+ - Current goal and active plan path (from global session state)
561
+ - Task table: ID / description / agent / status / attempt
562
+ - Integration table details from \`integration-state.json\`: validated commit, resulting feature commit, and integration method/status
563
+ - In-progress items with last known state and heartbeat
564
+ - Blocked items with blocker descriptions
565
+ - Retried or stale items visible from per-task execution state
566
+ - Session log (recent actions)
557
567
 
558
568
  ## When to use
559
569
 
@@ -563,13 +573,21 @@ Display the current \`execution-state.md\` summary — tasks, progress, and bloc
563
573
 
564
574
  ## Source
565
575
 
566
- Reads \`.opencode/state/execution-state.md\` directly.
567
- No agent needed — this is a direct state file read.
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
581
+
582
+ 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.
584
+
585
+ No agent needed — this is a direct state file read.
568
586
  `;
569
587
  // ─── /unify ───────────────────────────────────────────────────────────────────
570
- const UNIFY_CMD = `# /unify — Close the Loop
571
-
572
- Invoke the \`@j.unify\` agent to reconcile plan vs delivery and execute only the enabled closeout steps.
588
+ const UNIFY_CMD = `# /unify — Close the Loop
589
+
590
+ Invoke the \`@j.unify\` agent to reconcile plan vs delivery and execute only the enabled closeout steps.
573
591
 
574
592
  ## Usage
575
593
 
@@ -579,18 +597,19 @@ Invoke the \`@j.unify\` agent to reconcile plan vs delivery and execute only the
579
597
 
580
598
  ## What happens
581
599
 
582
- 1. Read \`.opencode/state/workflow-config.md\`
583
- 2. Reconcile \`plan.md\` vs actual git diff — mark tasks DONE/PARTIAL/SKIPPED
584
- 3. Run only the enabled closeout steps, such as:
585
- - update \`persistent-context.md\`
586
- - refresh \`docs/domain/\` or \`docs/domain/INDEX.md\`
587
- - merge worktrees
588
- - create a PR
600
+ 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:
603
+ - 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
589
607
  4. If PR creation is enabled, draft a rich PR body with purpose, problem, solution, changed files, and validation steps
590
608
 
591
609
  ## When to use
592
610
 
593
- After \`@j.implementer\` exits, \`/j.check\` passes, and \`@j.validator\` has approved the required work.
611
+ 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}\`.
594
613
 
595
614
  ## Prerequisites
596
615
 
@@ -600,13 +619,17 @@ After \`@j.implementer\` exits, \`/j.check\` passes, and \`@j.validator\` has ap
600
619
 
601
620
  ## Note
602
621
 
603
- UNIFY behavior is controlled by \`.opencode/state/workflow-config.md\`.
604
- If PR creation or doc updates are disabled there, \`@j.unify\` should skip those steps and report what was intentionally not executed.
622
+ UNIFY behavior is controlled by \`.opencode/juninho-config.json\` under \`workflow\`.
623
+ If PR creation or doc updates are disabled there, \`@j.unify\` should skip those steps and report what was intentionally not executed.
624
+ UNIFY is no longer responsible for first-time code integration.
625
+ UNIFY should also avoid creating a final synthetic git commit; history should already reflect the planned task commits by the time \`/j.unify\` runs.
605
626
  `;
606
627
  // ─── /finish-setup ───────────────────────────────────────────────────────────
607
- const FINISH_SETUP = `# /finish-setup — Generate Dynamic Skills and Documentation
608
-
609
- Scan the entire codebase, discover recurring file patterns, generate dynamic skills, and populate domain/principles documentation.
628
+ const FINISH_SETUP = `# /finish-setup — Bootstrap Repository Knowledge
629
+
630
+ This is the canonical repository bootstrap command after installing the harness.
631
+
632
+ Scan the entire codebase, generate hierarchical AGENTS.md files, discover recurring file patterns, generate dynamic skills, and populate domain/principles documentation.
610
633
 
611
634
  ## Usage
612
635
 
@@ -616,65 +639,87 @@ Scan the entire codebase, discover recurring file patterns, generate dynamic ski
616
639
 
617
640
  ## What happens
618
641
 
619
- ### Phase 1 — Structural Scan (via @j.explore)
620
-
621
- 1. Invoke \`@j.explore\` to scan the entire codebase
622
- 2. Identify recurring file patterns by suffix/convention:
623
- - \`*Repository.ts\`, \`*Repository.java\`, \`*Repository.kt\`, \`*_repository.py\` pattern "repository"
624
- - \`*Service.ts\`, \`*Service.java\`, \`*Service.kt\`, \`*_service.py\` pattern "service"
625
- - \`*Controller.ts\`, \`*Controller.java\`, \`*Controller.kt\` pattern "controller"
626
- - \`*Handler.go\`, \`*handler.go\` pattern "handler"
627
- - \`*Middleware.*\` → pattern "middleware"
628
- - \`*Schema.*\`, \`*Model.*\` → pattern "model/schema"
629
- - \`*DTO.*\`, \`*Request.*\`, \`*Response.*\` → pattern "dto"
630
- - \`*Factory.*\`, \`*Builder.*\` → pattern "factory/builder"
631
- - Any other recurring naming pattern (\`*Hook.ts\`, \`*Composable.ts\`, \`*Store.ts\`, etc.)
632
- 3. For each pattern found, read 2-3 exemplar files and extract:
633
- - Common structure (imports, exports, class vs function)
634
- - Naming conventions
635
- - Dependency patterns (what it injects, what it returns)
636
- - Error handling patterns
637
- - Validation patterns
638
-
639
- ### Phase 2 Generate Dynamic Skills
640
-
641
- 4. For each discovered pattern, create a skill in \`.opencode/skills/j.{pattern}-writing/SKILL.md\`:
642
- - Frontmatter with \`name\`, \`description\`
643
- - "When this skill activates" with the glob patterns from the project
644
- - "Required Steps" extracted from the exemplar file analysis
645
- - "Anti-patterns to avoid" based on what the exemplars do NOT do
646
- - Canonical example copied/adapted from a real project file
647
- 5. Update \`.opencode/state/skill-map.json\` with new regex patterns for each skill
648
-
649
- ### Phase 3 Generate Documentation
650
-
651
- 6. Generate initial docs in \`docs/domain/\` (subdirectories by discovered domain)
652
- 7. Generate initial docs in \`docs/principles/\` based on patterns found
653
- 8. Populate \`docs/principles/manifest\` with real keywords
654
- 9. Populate \`docs/domain/INDEX.md\` with real entries and CARL keywords
655
- 10. Update root \`AGENTS.md\` with discovered information (stack, build commands, test commands, directory layout)
642
+ ### Phase 1 — Structural Scan (via @j.explore)
643
+
644
+ 1. Invoke \`@j.explore\` to scan the entire codebase
645
+ 2. Identify significant directory boundaries for local instructions:
646
+ - root project context for the main \`AGENTS.md\`
647
+ - source-tree boundaries such as \`src/\`, \`app/\`, \`internal/\`, \`pkg/\`, \`services/\`, \`modules/\`
648
+ - major domain/module directories that deserve their own local \`AGENTS.md\`
649
+ 3. Identify recurring file patterns by suffix/convention:
650
+ - \`*Repository.ts\`, \`*Repository.java\`, \`*Repository.kt\`, \`*_repository.py\` → pattern "repository"
651
+ - \`*Service.ts\`, \`*Service.java\`, \`*Service.kt\`, \`*_service.py\` → pattern "service"
652
+ - \`*Controller.ts\`, \`*Controller.java\`, \`*Controller.kt\` → pattern "controller"
653
+ - \`*Handler.go\`, \`*handler.go\` → pattern "handler"
654
+ - \`*Middleware.*\` pattern "middleware"
655
+ - \`*Schema.*\`, \`*Model.*\` pattern "model/schema"
656
+ - \`*DTO.*\`, \`*Request.*\`, \`*Response.*\` pattern "dto"
657
+ - \`*Factory.*\`, \`*Builder.*\` → pattern "factory/builder"
658
+ - Any other recurring naming pattern (\`*Hook.ts\`, \`*Composable.ts\`, \`*Store.ts\`, etc.)
659
+ 4. For each pattern found, read 2-3 exemplar files and extract:
660
+ - Common structure (imports, exports, class vs function)
661
+ - Naming conventions
662
+ - Dependency patterns (what it injects, what it returns)
663
+ - Error handling patterns
664
+ - Validation patterns
665
+
666
+ ### Phase 2 Generate Hierarchical AGENTS.md
667
+
668
+ 5. Generate or refresh hierarchical \`AGENTS.md\` files:
669
+ - Root \`AGENTS.md\`: stack summary, real build/test commands, directory layout, critical repo rules
670
+ - Directory-level \`AGENTS.md\`: local architecture, invariants, module boundaries, integration contracts
671
+ 6. Keep each generated \`AGENTS.md\` scoped to its directory only:
672
+ - no copy-pasting the entire root file into child directories
673
+ - no business-domain detail that belongs in \`docs/domain/*\`
674
+ - commands must match the actual repository scripts and build tools
675
+
676
+ ### Phase 3 Generate Dynamic Skills
677
+
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
685
+
686
+ ### Phase 4 — Generate Documentation
687
+
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
692
+
693
+ ### Phase 5 — Refresh Local Automation Stubs
694
+
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
656
699
 
657
700
  ## Delegation Rule (MANDATORY)
658
701
 
659
702
  You MUST use \`@j.explore\` for Phase 1. Do NOT try to scan the codebase yourself.
660
703
 
661
- When \`@j.explore\` returns its report:
662
- - Read the FULL report
663
- - Extract all file patterns and structural findings
664
- - Use them to generate skills and docs
665
-
666
- ## When to use
704
+ When \`@j.explore\` returns its report:
705
+ - Read the FULL report
706
+ - Extract all file patterns and structural findings
707
+ - Use them to generate AGENTS, skills, and docs
667
708
 
668
- - After initial \`juninho setup\` to customize skills for the specific project
669
- - After major structural refactors that introduce new file patterns
670
- - When onboarding a new project to the framework
709
+ ## When to use
710
+
711
+ - Right after \`juninho setup\` on an existing project
712
+ - After major structural refactors that introduce new file patterns
713
+ - When onboarding a new project to the framework
714
+ - After \`/j.finish-setup\` generates files, review and augment them with non-obvious domain knowledge
671
715
 
672
716
  ## Result
673
717
 
674
- After completion, the project will have:
675
- - Custom skills that match its specific file patterns and conventions
676
- - Domain documentation populated with real business domains
677
- - Principles documentation reflecting actual codebase patterns
678
- - An updated AGENTS.md with project-specific information
718
+ After completion, the project will have:
719
+ - 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
723
+ - Updated local automation stubs and command references
679
724
  `;
680
725
  //# sourceMappingURL=commands.js.map