hatch3r 1.5.0 → 1.5.1
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.
- package/commands/hatch3r-revision.md +47 -120
- package/commands/revision/revision-board-integration.md +87 -0
- package/commands/revision/revision-delegation.md +93 -0
- package/commands/revision/revision-modes.md +91 -0
- package/commands/revision/revision-quality.md +96 -0
- package/dist/cli/index.js +225 -261
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
id: hatch3r-revision
|
|
3
3
|
type: command
|
|
4
|
-
description: User-guided revision of agent-implemented code in a fresh context window. Reconstructs what was done, interviews the user for feedback, fixes issues, cleans up leftovers, and drives toward merge readiness.
|
|
4
|
+
description: User-guided revision of agent-implemented code in a fresh context window. Reconstructs what was done, interviews the user for feedback, fixes issues, cleans up leftovers, and drives toward merge readiness. Delegation, quality pipeline, modes, and board integration details are in commands/revision/.
|
|
5
5
|
tags: [implementation, team]
|
|
6
6
|
quality_charter: agents/shared/quality-charter.md
|
|
7
7
|
---
|
|
@@ -15,7 +15,10 @@ quality_charter: agents/shared/quality-charter.md
|
|
|
15
15
|
| 3. Leftover Scan + Triage Routing | Orchestrator (inline) | No | Yes |
|
|
16
16
|
| 4. Fix Implementation | `hatch3r-implementer`, `hatch3r-lint-fixer`, `hatch3r-test-writer` | Per finding type | [FIX NOW] items only |
|
|
17
17
|
| 5a. Review Loop | `hatch3r-reviewer` -> `hatch3r-fixer` (max 3 iterations) | No (sequential) | Yes |
|
|
18
|
-
| 5b. Final Quality | `hatch3r-test-writer`
|
|
18
|
+
| 5b. Final Quality — Testing | `hatch3r-test-writer` | Yes | Yes (code changes) |
|
|
19
|
+
| 5c. Final Quality — Security | `hatch3r-security-auditor` | Yes | Yes (code changes) |
|
|
20
|
+
| 5d. Final Quality — Docs | `hatch3r-docs-writer` | Yes | When APIs/architecture/UX affected |
|
|
21
|
+
| 5e. Final Quality — Conditional | `hatch3r-lint-fixer`, `hatch3r-a11y-auditor`, `hatch3r-perf-profiler` | Yes | When triggered |
|
|
19
22
|
|
|
20
23
|
## Browser Automation
|
|
21
24
|
|
|
@@ -37,7 +40,7 @@ The user is the reviewer. The agent is the interviewer and fixer.
|
|
|
37
40
|
|
|
38
41
|
## Shared Context
|
|
39
42
|
|
|
40
|
-
**If board context exists** (current branch has an associated PR linked to
|
|
43
|
+
**If board context exists** (current branch has an associated PR linked to issues), **read the `hatch3r-board-shared` command at the start of the run.** It contains Board Configuration, Platform Detection, Platform Context, Board Sync Procedure, and tooling directives. Cache all values for the duration of this run.
|
|
41
44
|
|
|
42
45
|
If no board context exists (plain instruction, no PR, no linked issues), skip shared context loading and work from the git diff alone.
|
|
43
46
|
|
|
@@ -52,6 +55,10 @@ If no board context exists (plain instruction, no PR, no linked issues), skip sh
|
|
|
52
55
|
3. **Do NOT re-read shared context files** -- their content is available via always-applied rules or inline in this command.
|
|
53
56
|
4. **Limit documentation reads.** Read project documentation selectively -- TOC/headers first, full content only for relevant sections.
|
|
54
57
|
|
|
58
|
+
## Run Cache
|
|
59
|
+
|
|
60
|
+
Initialize the run cache at the start of the workflow. See `commands/revision/revision-board-integration.md` for the full schema. The cache tracks: diff, findings with triage routing and fix status, quality agents spawned, errors encountered.
|
|
61
|
+
|
|
55
62
|
---
|
|
56
63
|
|
|
57
64
|
## Workflow
|
|
@@ -68,16 +75,22 @@ Rebuild full context in the fresh window. No prior implementation context is ass
|
|
|
68
75
|
2. Determine the default branch from `.agents/hatch.json` (`board.defaultBranch`). Fall back to `main` if unavailable.
|
|
69
76
|
3. Compute the diff: `git diff {defaultBranch}...HEAD --stat` for a summary, then `git diff {defaultBranch}...HEAD` for the full diff.
|
|
70
77
|
4. Parse the diff summary: files changed, lines added/removed, file types affected.
|
|
71
|
-
5. Identify affected areas from the file paths (e.g., `src/routes/`
|
|
78
|
+
5. Identify affected areas from the file paths (e.g., `src/routes/` -> API, `src/components/` -> UI, `tests/` -> testing).
|
|
72
79
|
|
|
73
80
|
#### 1b. Find Associated PR and Issues
|
|
74
81
|
|
|
75
|
-
|
|
76
|
-
|
|
82
|
+
> Platform-specific CLI commands: see `commands/board/shared-{platform}.md` for PR/issue lookup
|
|
83
|
+
|
|
84
|
+
1. Detect the platform from `.agents/hatch.json` (`board.platform`). Fall back to GitHub if unavailable.
|
|
85
|
+
2. Search for an open PR on this branch using the platform CLI:
|
|
86
|
+
- **GitHub:** `gh pr list --head {branch} --state open --json number,title,body,url --limit 1`
|
|
87
|
+
- **Azure DevOps:** `az repos pr list --source-branch {branch} --status active --top 1`
|
|
88
|
+
- **GitLab:** `glab mr list --source-branch {branch} --state opened --per-page 1`
|
|
89
|
+
3. If a PR exists:
|
|
77
90
|
- Read the PR body.
|
|
78
91
|
- Extract linked issues from `Closes #N`, `Fixes #N`, `Relates to #N` references.
|
|
79
|
-
- For each linked issue:
|
|
80
|
-
|
|
92
|
+
- For each linked issue: fetch title, body, labels, and acceptance criteria using the platform CLI.
|
|
93
|
+
4. If no PR exists: note this and work from the branch diff alone.
|
|
81
94
|
|
|
82
95
|
#### 1c. Load Project Rules
|
|
83
96
|
|
|
@@ -96,6 +109,7 @@ Present a reconstruction summary to the user:
|
|
|
96
109
|
```
|
|
97
110
|
Revision Context:
|
|
98
111
|
Branch: {branch}
|
|
112
|
+
Platform: {GitHub / Azure DevOps / GitLab}
|
|
99
113
|
PR: #{N} — {title} ({url}) | No PR found
|
|
100
114
|
Linked issues: #{N} — {title} (×{count}) | None
|
|
101
115
|
Diff: {files_changed} files changed (+{additions} / -{deletions})
|
|
@@ -265,7 +279,7 @@ If the user attempts to defer a Critical finding, execute the Critical Deferral
|
|
|
265
279
|
Deferral rationale: {user's stated rationale}
|
|
266
280
|
```
|
|
267
281
|
|
|
268
|
-
4. **Flag for triage.** The `Critical-deferred` tag
|
|
282
|
+
4. **Flag for triage.** The `Critical-deferred` tag signals board-fill to surface this item with elevated visibility during the next triage cycle. Board-fill should treat `Critical-deferred` items as priority:p0 candidates regardless of other signals.
|
|
269
283
|
|
|
270
284
|
The user is never blocked — this protocol adds accountability, not a veto.
|
|
271
285
|
|
|
@@ -299,7 +313,7 @@ If any findings are routed to [DEFER]:
|
|
|
299
313
|
2. Present summary:
|
|
300
314
|
`"Deferred {N} findings to todo.md. Run /hatch3r-board-fill to triage them into an epic with full dependency analysis."`
|
|
301
315
|
|
|
302
|
-
3. Cache the deferred findings list for use in Steps 8 and 9.
|
|
316
|
+
3. Cache the deferred findings list for use in Steps 8 and 9. Update run cache `deferred_findings`.
|
|
303
317
|
|
|
304
318
|
If no findings are routed to [DEFER] (including the "fix all" shortcut), skip this sub-step entirely.
|
|
305
319
|
|
|
@@ -307,99 +321,19 @@ If no findings are routed to [DEFER] (including the "fix all" shortcut), skip th
|
|
|
307
321
|
|
|
308
322
|
### Step 6: Fix Implementation (Sub-Agent Delegation)
|
|
309
323
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
If all findings were deferred (no [FIX NOW] items), skip Step 6 entirely and proceed to Step 7.
|
|
313
|
-
|
|
314
|
-
#### 6a. Group Findings by Specialist
|
|
315
|
-
|
|
316
|
-
| Finding Category | Sub-Agent | Protocol |
|
|
317
|
-
|-----------------|-----------|----------|
|
|
318
|
-
| Bugs, missing features, error handling, logic fixes | `hatch3r-implementer` | hatch3r-implementer agent protocol |
|
|
319
|
-
| Dead code, unused imports, type fixes, lint errors | `hatch3r-lint-fixer` | hatch3r-lint-fixer agent protocol |
|
|
320
|
-
| Missing tests, insufficient coverage | `hatch3r-test-writer` | hatch3r-test-writer agent protocol |
|
|
321
|
-
|
|
322
|
-
If findings span multiple independent areas, spawn one `hatch3r-implementer` per area to parallelize.
|
|
323
|
-
|
|
324
|
-
#### 6b. Spawn Sub-Agents
|
|
325
|
-
|
|
326
|
-
Use the Task tool with `subagent_type: "generalPurpose"`. Launch as many independent sub-agents in parallel as the platform supports.
|
|
324
|
+
> Full details: see `commands/revision/revision-delegation.md`
|
|
327
325
|
|
|
328
|
-
|
|
329
|
-
- The specific findings to address (file paths, line numbers, descriptions, expected behavior).
|
|
330
|
-
- Instruction to follow the corresponding agent protocol (e.g., "Follow the hatch3r-implementer agent protocol").
|
|
331
|
-
- All `scope: always` rule directives from `.agents/rules/` -- sub-agents do not inherit rules automatically.
|
|
332
|
-
- Acceptance criteria from linked issues (if available from Step 1b).
|
|
333
|
-
- Relevant learnings from `.agents/learnings/` (if found in Step 1d).
|
|
334
|
-
- Explicit instruction: do NOT create branches, commits, or PRs.
|
|
335
|
-
- Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
326
|
+
Delegate [FIX NOW] findings to specialist sub-agents. The delegation protocol covers complexity assessment (using `hatch3r-deep-context` scoring), blast-radius-aware finding grouping, expanded sub-agent prompt templates, and cross-agent conflict resolution.
|
|
336
327
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
1. Await all sub-agents. Collect their structured results (files changed, tests written, issues encountered).
|
|
340
|
-
2. If any sub-agent reports BLOCKED or PARTIAL, **ASK** the user how to proceed (skip, provide guidance, fix manually).
|
|
341
|
-
3. If sub-agents modified overlapping files, review for conflicts and resolve.
|
|
342
|
-
4. Apply all changes to the working tree.
|
|
328
|
+
If all findings were deferred (no [FIX NOW] items), skip Step 6 entirely and proceed to Step 7.
|
|
343
329
|
|
|
344
330
|
---
|
|
345
331
|
|
|
346
332
|
### Step 7: Quality Verification
|
|
347
333
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
#### 7a. Run Quality Gates
|
|
351
|
-
|
|
352
|
-
1. Lint check (e.g., `npm run lint`)
|
|
353
|
-
2. Type check (e.g., `npm run typecheck`)
|
|
354
|
-
3. Test suite (e.g., `npm run test`)
|
|
355
|
-
|
|
356
|
-
#### 7b. Verify User-Reported Issues
|
|
357
|
-
|
|
358
|
-
Walk through each critical and important finding from Step 5. Verify it is addressed by the changes made in Step 6. If acceptance criteria exist from linked issues, verify each criterion.
|
|
359
|
-
|
|
360
|
-
For each verified finding and acceptance criterion, rate verification confidence: high (fix confirmed via tests or direct observation), medium (code change addresses the issue but edge cases not independently tested), low (fix applied but uncertain of completeness).
|
|
361
|
-
|
|
362
|
-
#### 7c. Review Loop
|
|
363
|
-
|
|
364
|
-
Run an iterative review loop (max 3 iterations) until 0 Critical + 0 Warning findings remain:
|
|
334
|
+
> Full details: see `commands/revision/revision-quality.md`
|
|
365
335
|
|
|
366
|
-
1
|
|
367
|
-
|
|
368
|
-
The reviewer prompt MUST include:
|
|
369
|
-
- The diff of all changes made (use `git diff` on the working tree).
|
|
370
|
-
- All `scope: always` rule directives from `.agents/rules/`.
|
|
371
|
-
- Iteration number and previous findings (if not the first iteration).
|
|
372
|
-
- Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
373
|
-
|
|
374
|
-
2. Process reviewer output:
|
|
375
|
-
- If **0 Critical and 0 Warning** findings: review loop is clean. Proceed to Step 7d.
|
|
376
|
-
- If Critical or Warning findings remain: spawn `hatch3r-fixer` sub-agent to address them, then re-run the reviewer (next iteration).
|
|
377
|
-
|
|
378
|
-
3. If 3 iterations complete and findings remain, **ASK** the user whether to proceed or fix manually.
|
|
379
|
-
|
|
380
|
-
After each reviewer iteration, assess the reviewer's findings confidence: if the reviewer rates any finding as low-confidence, flag it separately in the ASK prompt so the user can prioritize human review of uncertain findings.
|
|
381
|
-
|
|
382
|
-
4. After any fixes, re-run quality gates (Step 7a) to verify nothing broke.
|
|
383
|
-
|
|
384
|
-
#### 7d. Final Quality
|
|
385
|
-
|
|
386
|
-
After the review loop is clean, spawn both agents in parallel via the Task tool:
|
|
387
|
-
|
|
388
|
-
1. `hatch3r-test-writer` — write or update tests for code changes.
|
|
389
|
-
2. `hatch3r-security-auditor` — security review of code changes.
|
|
390
|
-
|
|
391
|
-
Both prompts MUST include:
|
|
392
|
-
- The diff of all changes made.
|
|
393
|
-
- All `scope: always` rule directives from `.agents/rules/`.
|
|
394
|
-
- Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
395
|
-
|
|
396
|
-
Apply any resulting changes (new tests, security fixes). Re-run quality gates (Step 7a) if changes were made.
|
|
397
|
-
|
|
398
|
-
#### 7e. Handle Failures
|
|
399
|
-
|
|
400
|
-
- If quality checks fail: identify the specific failures, fix them directly (for simple issues) or loop back to Step 6 with specific failures.
|
|
401
|
-
- Max 2 retry loops on quality check failures. After 2 retries, **ASK** the user for guidance: "Quality checks still failing. Fix confidence: {high/medium/low — based on whether root cause is identified}."
|
|
402
|
-
- If a user-reported issue was not fully addressed: **ASK** the user whether to attempt another fix or defer.
|
|
336
|
+
Two-stage quality pipeline: Stage 1 runs a sequential review loop (`hatch3r-reviewer` -> `hatch3r-fixer`, max 3 iterations). Stage 2 spawns final quality specialists in parallel — mandatory (`hatch3r-test-writer`, `hatch3r-security-auditor`), evaluated (`hatch3r-docs-writer`), and conditional (`hatch3r-a11y-auditor`, `hatch3r-perf-profiler`, `hatch3r-lint-fixer`).
|
|
403
337
|
|
|
404
338
|
---
|
|
405
339
|
|
|
@@ -430,6 +364,8 @@ git push
|
|
|
430
364
|
|
|
431
365
|
If `git push` fails (e.g., remote branch does not exist yet), use `git push -u origin {branch}`.
|
|
432
366
|
|
|
367
|
+
**Post-commit board integration:** If board context exists, update the PR description with a revision summary. See `commands/revision/revision-board-integration.md` for the full procedure.
|
|
368
|
+
|
|
433
369
|
---
|
|
434
370
|
|
|
435
371
|
### Step 9: Merge Readiness Assessment
|
|
@@ -460,7 +396,17 @@ Verdict: READY / NOT READY ({remaining items})
|
|
|
460
396
|
|
|
461
397
|
A deferred finding counts as "tracked" not "unaddressed" -- it does not block merge readiness.
|
|
462
398
|
|
|
463
|
-
#### 9b.
|
|
399
|
+
#### 9b. Board Housekeeping
|
|
400
|
+
|
|
401
|
+
> Full details: see `commands/revision/revision-board-integration.md`
|
|
402
|
+
|
|
403
|
+
When board context exists, run the board housekeeping steps:
|
|
404
|
+
- **9b.i. Refresh Board Dashboard** (mandatory when `meta:board-overview` exists).
|
|
405
|
+
- **9b.ii. Lightweight Reconciliation** — verify PR body integrity, deferred findings in todo.md, and issue status consistency.
|
|
406
|
+
|
|
407
|
+
When no board context exists, skip 9b entirely.
|
|
408
|
+
|
|
409
|
+
#### 9c. Present Assessment
|
|
464
410
|
|
|
465
411
|
**ASK:** "Revision complete. {verdict}. Options: (a) ready to merge, (b) run another revision cycle with new feedback, (c) done for now."
|
|
466
412
|
|
|
@@ -490,27 +436,8 @@ Capture revision-specific learnings. Focus on patterns that inform future implem
|
|
|
490
436
|
|
|
491
437
|
---
|
|
492
438
|
|
|
493
|
-
## Error Handling
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
- **Sub-agent failure**: Retry once. If the retry fails, fall back to direct implementation for that finding.
|
|
499
|
-
- **Quality check failure after 2 retries**: Present the specific failures and **ASK** the user whether to proceed with a partial fix commit or continue debugging.
|
|
500
|
-
- **Push failure**: Present the error. Common fixes: `git push -u origin {branch}` for new branches, `git pull --rebase` for diverged branches.
|
|
501
|
-
- **Context degradation (>25 turns)**: Suggest starting a fresh chat with a progress summary. The revision command is designed for fresh contexts -- it can be re-run.
|
|
502
|
-
|
|
503
|
-
## Guardrails
|
|
504
|
-
|
|
505
|
-
- **Never skip ASK checkpoints.** Every significant decision requires user confirmation.
|
|
506
|
-
- **Never skip the proactive scan (Step 4)** -- even if the user reports no issues. Agents leave leftovers.
|
|
507
|
-
- **Always run quality checks (Step 7)** before committing. Never commit code that fails lint, typecheck, or tests.
|
|
508
|
-
- **Stay within the revision scope.** Fix what was reported and what the scan found. Do not refactor unrelated code, add new features, or expand beyond the original implementation's intent.
|
|
509
|
-
- **Always commit and push** at the end of a revision cycle. The user invoked this command to get fixes merged -- do not exit without committing (unless the user explicitly abandons).
|
|
510
|
-
- **Respect the original implementation's architecture.** Revision fixes issues within the existing patterns. If the architecture itself is flawed, note it as a finding but do not restructure -- suggest a separate refactor instead.
|
|
511
|
-
- **One sub-agent per concern.** Delegate to specialist sub-agents based on finding type. Do not ask the implementer to also fix lint issues or write tests.
|
|
512
|
-
- **Git safety.** Never force-push. Never rewrite history. Always create new commits for revision changes.
|
|
513
|
-
- **This command composes existing hatch3r agents** -- it does not replace them. The reviewer, implementer, lint-fixer, and test-writer agents handle the actual work.
|
|
514
|
-
- **Critical findings default to FIX NOW.** If the user overrides this, execute the Critical Deferral Protocol (Step 5b): structured warning with specific risk, require written rationale, record in todo.md with `Critical-deferred` tag, and flag for elevated triage in board-fill. The user is never blocked — rationale adds accountability, not a veto.
|
|
515
|
-
- **Deferred findings go to `todo.md`, not directly to GitHub issues.** The board-fill pipeline handles triage, epic creation, dependency analysis, and readiness assessment. Revision does not shortcut this process.
|
|
516
|
-
- **Always format deferred items as a single epic block** in `todo.md`, regardless of count. This ensures board-fill groups them together during the next run.
|
|
439
|
+
## Auto-Advance Mode, Error Handling, and Guardrails
|
|
440
|
+
|
|
441
|
+
> Full details: see `commands/revision/revision-modes.md`
|
|
442
|
+
|
|
443
|
+
The modes file contains: auto-advance mode (`--auto`), safety guardrails, error handling, and session report format for revision.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-revision-board-integration
|
|
3
|
+
type: command
|
|
4
|
+
description: Board integration for revision. Covers run cache schema, post-commit PR updates, dashboard refresh (Step 9a), and lightweight reconciliation (Step 9b).
|
|
5
|
+
tags: [implementation, team]
|
|
6
|
+
quality_charter: agents/shared/quality-charter.md
|
|
7
|
+
---
|
|
8
|
+
# Revision — Board Integration
|
|
9
|
+
|
|
10
|
+
Board integration protocols for `hatch3r-revision`. Referenced from the core command file. All board integration steps are conditional — they execute only when board context exists (PR with linked issues found in Step 1b). When no board context exists, skip all steps in this file silently.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Run Cache
|
|
15
|
+
|
|
16
|
+
Initialize at the start of the revision workflow (before Step 1). Maintain throughout the run:
|
|
17
|
+
|
|
18
|
+
| Key | Type | Description |
|
|
19
|
+
|-----|------|-------------|
|
|
20
|
+
| `diff_cache` | `string` | Cached diff from Step 1 (reused per token-saving directives) |
|
|
21
|
+
| `findings` | `Map<id, {description, severity, route, status}>` | All findings with triage routing and fix status |
|
|
22
|
+
| `fixed_findings` | `id[]` | Finding IDs resolved in this run |
|
|
23
|
+
| `deferred_findings` | `id[]` | Finding IDs written to todo.md |
|
|
24
|
+
| `quality_agents` | `{agent, status, findings_count}[]` | Specialist agents spawned and their results |
|
|
25
|
+
| `pr_updated` | `boolean` | Whether PR description was updated with revision summary |
|
|
26
|
+
| `errors` | `{step, message, recoverable}[]` | All errors encountered during the run |
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Post-Commit Board Integration (After Step 8)
|
|
31
|
+
|
|
32
|
+
After committing and pushing revision changes, update the PR if board context exists:
|
|
33
|
+
|
|
34
|
+
1. **Update PR description** with a revision summary appended to the existing body:
|
|
35
|
+
|
|
36
|
+
```markdown
|
|
37
|
+
---
|
|
38
|
+
## Revision Summary ({date})
|
|
39
|
+
|
|
40
|
+
**Fixed ({N}):**
|
|
41
|
+
- {finding description} ({severity})
|
|
42
|
+
- ...
|
|
43
|
+
|
|
44
|
+
**Deferred to todo.md ({M}):**
|
|
45
|
+
- {finding description} ({severity})
|
|
46
|
+
- ...
|
|
47
|
+
|
|
48
|
+
**Quality agents:** {list of agents spawned}
|
|
49
|
+
**Overall confidence:** {high/medium/low}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
2. Do NOT change issue status labels. Revision does not alter the issue lifecycle — the original PR's `Closes #N` references handle that on merge.
|
|
53
|
+
|
|
54
|
+
3. Do NOT modify `Closes #N` / `Relates to #N` references in the PR body. The original references from board-pickup are authoritative.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Step 9a: Refresh Board Dashboard
|
|
59
|
+
|
|
60
|
+
**This step is mandatory when board context exists. Skip silently when no board context.**
|
|
61
|
+
|
|
62
|
+
If a `meta:board-overview` issue exists on the board, refresh it now using cached board data. Use the same procedure as `hatch3r-board-pickup` Step 9a: update with current board state reflecting any changes from this revision session.
|
|
63
|
+
|
|
64
|
+
Do NOT re-fetch all issues. Use cached data from Step 1 combined with mutations from this run (findings fixed, PR updated). Skip silently if no `meta:board-overview` issue exists.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Step 9b: Lightweight Reconciliation
|
|
69
|
+
|
|
70
|
+
**This step is mandatory when board context exists. Skip silently when no board context.**
|
|
71
|
+
|
|
72
|
+
Run a focused reconciliation (not the full board-shared reconciliation procedure, since revision does not create or update issues):
|
|
73
|
+
|
|
74
|
+
1. **PR body integrity:** Verify the PR body still contains correct `Closes #N` references for all linked issues after the revision summary was appended. If any references were accidentally removed or corrupted, restore them.
|
|
75
|
+
|
|
76
|
+
2. **Deferred findings integrity:** If findings were deferred in Step 5c, verify they are written to `todo.md` with correct severity tags and epic grouping format. Report any write failures.
|
|
77
|
+
|
|
78
|
+
3. **Orphaned status check:** For each issue linked to this PR, verify the issue still has `status:in-review` label. If any issue has drifted to a different status (e.g., manually changed during the revision session), warn the user.
|
|
79
|
+
|
|
80
|
+
Output a reconciliation report:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
Reconciliation:
|
|
84
|
+
PR body: {ok / {N} references restored}
|
|
85
|
+
Deferred findings: {ok / {N} write failures}
|
|
86
|
+
Issue status: {ok / {N} status drift warnings}
|
|
87
|
+
```
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-revision-delegation
|
|
3
|
+
type: command
|
|
4
|
+
description: Fix delegation protocol for revision Step 6. Covers complexity-aware grouping, blast radius context, sub-agent prompt templates, and cross-agent conflict resolution.
|
|
5
|
+
tags: [implementation, team]
|
|
6
|
+
quality_charter: agents/shared/quality-charter.md
|
|
7
|
+
---
|
|
8
|
+
# Revision — Fix Delegation (Step 6)
|
|
9
|
+
|
|
10
|
+
Delegation details for Step 6 of `hatch3r-revision`. Referenced from the core command file.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 6.pre: Complexity Assessment
|
|
15
|
+
|
|
16
|
+
Before delegating [FIX NOW] findings, score the aggregate fix batch using `hatch3r-deep-context` complexity signals. Score across the full set of findings, not per-finding:
|
|
17
|
+
|
|
18
|
+
| Signal | Weight | Detection |
|
|
19
|
+
|--------|--------|-----------|
|
|
20
|
+
| Findings span multiple modules/layers | +3 | Count distinct directories across all [FIX NOW] findings |
|
|
21
|
+
| Any finding involves behavioral contract changes (API, types, events) | +2 | Check finding descriptions for interface/signature changes |
|
|
22
|
+
| Findings touch security-sensitive areas (auth, payments, data access) | +2 | Match affected files against security-sensitive directories |
|
|
23
|
+
| Total affected files > 5 | +2 | Count distinct files across all findings |
|
|
24
|
+
| Any finding requires new dependencies or integrations | +2 | Check whether fixes introduce new imports or services |
|
|
25
|
+
|
|
26
|
+
### Tier Assignment
|
|
27
|
+
|
|
28
|
+
| Total Weight | Tier | Action |
|
|
29
|
+
|-------------|------|--------|
|
|
30
|
+
| 0–2 | 1 (Light) | Proceed directly to 6a. No research needed |
|
|
31
|
+
| 3–5 | 2 (Standard) | Spawn `hatch3r-researcher` with `similar-implementation` at `quick` depth before delegating. Use discovered reference patterns to inform fix conventions |
|
|
32
|
+
| 6+ | 3 (Deep) | Spawn `hatch3r-researcher` with `codebase-impact` at `deep` depth. **Warn the user** that fix scope may warrant a new board issue rather than a revision fix |
|
|
33
|
+
|
|
34
|
+
For Tier 2/3: cache researcher output (reference conventions, blast radius data) for inclusion in sub-agent prompts below.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 6a. Group Findings by Specialist
|
|
39
|
+
|
|
40
|
+
| Finding Category | Sub-Agent | Protocol |
|
|
41
|
+
|-----------------|-----------|----------|
|
|
42
|
+
| Bugs, missing features, error handling, logic fixes | `hatch3r-implementer` | hatch3r-implementer agent protocol |
|
|
43
|
+
| Dead code, unused imports, type fixes, lint errors | `hatch3r-lint-fixer` | hatch3r-lint-fixer agent protocol |
|
|
44
|
+
| Missing tests, insufficient coverage | `hatch3r-test-writer` | hatch3r-test-writer agent protocol |
|
|
45
|
+
|
|
46
|
+
### Blast-Radius-Aware Grouping
|
|
47
|
+
|
|
48
|
+
When multiple findings affect the same file or module, batch them to a single sub-agent to avoid cross-agent file conflicts:
|
|
49
|
+
|
|
50
|
+
1. Build a file-to-findings map from all [FIX NOW] items.
|
|
51
|
+
2. Findings in the same file go to the same sub-agent instance, even if they span categories (use the highest-priority specialist: implementer > lint-fixer > test-writer).
|
|
52
|
+
3. Findings in disjoint files can run in parallel sub-agents.
|
|
53
|
+
4. If findings span independent areas within the same specialist type, spawn one sub-agent per area to parallelize.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 6b. Spawn Sub-Agents
|
|
58
|
+
|
|
59
|
+
Use the Task tool with `subagent_type: "generalPurpose"`. Launch independent sub-agents in parallel.
|
|
60
|
+
|
|
61
|
+
Each sub-agent prompt MUST include:
|
|
62
|
+
|
|
63
|
+
1. The specific findings to address (file paths, line numbers, descriptions, expected behavior).
|
|
64
|
+
2. Instruction to follow the corresponding agent protocol (e.g., "Follow the hatch3r-implementer agent protocol").
|
|
65
|
+
3. All `scope: always` rule directives from `.agents/rules/` — sub-agents do not inherit rules automatically.
|
|
66
|
+
4. Acceptance criteria from linked issues (if available from Step 1b).
|
|
67
|
+
5. Relevant learnings from `.agents/learnings/` (if found in Step 1d).
|
|
68
|
+
6. Explicit instruction: do NOT create branches, commits, or PRs.
|
|
69
|
+
7. Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
70
|
+
8. Revision-specific constraint: "You are fixing existing code, not implementing new features. Stay within the architecture established by the original implementation."
|
|
71
|
+
|
|
72
|
+
**When Tier 2/3 research was performed (6.pre):**
|
|
73
|
+
|
|
74
|
+
9. Reference conventions from `similar-implementation` output — triggers the implementer's Convention Lock step.
|
|
75
|
+
10. Blast radius data from `codebase-impact` output (Tier 3) — transitive dependency trace informing which consumers and contracts the fix must preserve.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## 6c. Await and Integrate Results
|
|
80
|
+
|
|
81
|
+
1. Await all sub-agents. Collect their structured results (files changed, tests written, issues encountered).
|
|
82
|
+
2. If any sub-agent reports BLOCKED or PARTIAL, **ASK** the user how to proceed (skip, provide guidance, fix manually).
|
|
83
|
+
|
|
84
|
+
### Cross-Agent Conflict Resolution
|
|
85
|
+
|
|
86
|
+
When sub-agents modified overlapping files:
|
|
87
|
+
|
|
88
|
+
- **Disjoint regions** (different functions, different sections): accept both sets of changes.
|
|
89
|
+
- **Overlapping regions** (same function or block): merge using the larger-scope change as the base, applying the smaller change on top. If merging is ambiguous, present both versions to the user.
|
|
90
|
+
- **Semantic conflicts** (contradictory logic): surface to the user with both sub-agents' rationale. Do not auto-resolve semantic conflicts.
|
|
91
|
+
|
|
92
|
+
3. Apply all resolved changes to the working tree.
|
|
93
|
+
4. Update the run cache with fix results (files changed, findings addressed).
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-revision-modes
|
|
3
|
+
type: command
|
|
4
|
+
description: Auto-advance mode, safety guardrails, error handling, and session report for revision. Covers --auto operation, never-skip rules, platform-aware error recovery, and end-of-session summary.
|
|
5
|
+
tags: [implementation, team]
|
|
6
|
+
quality_charter: agents/shared/quality-charter.md
|
|
7
|
+
---
|
|
8
|
+
# Revision — Modes, Guardrails, and Error Handling
|
|
9
|
+
|
|
10
|
+
Supplementary protocols for `hatch3r-revision`. Referenced from the core command file.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Auto-Advance Mode
|
|
15
|
+
|
|
16
|
+
When invoked with `--auto`, revision operates with reduced human checkpoints for sustained autonomous operation (e.g., CI integration, repeated revision cycles).
|
|
17
|
+
|
|
18
|
+
### Behavior Changes in Auto Mode
|
|
19
|
+
|
|
20
|
+
| Checkpoint | Normal Mode | Auto Mode |
|
|
21
|
+
|-----------|-------------|-----------|
|
|
22
|
+
| Step 2 context validation | ASK user | Auto-proceed when PR + linked issues found. If no PR found, fall back to normal mode for this step |
|
|
23
|
+
| Step 3 user interview | ASK user for feedback | Skip interview. Work from leftover scan (Step 4) only |
|
|
24
|
+
| Step 5b routing approval | ASK user to confirm routing | Auto-accept suggested routing heuristics |
|
|
25
|
+
| Step 7e quality failure | ASK user after 2 retries | Auto-defer remaining findings to todo.md after 2 retries |
|
|
26
|
+
| Step 9b merge readiness | ASK user for next action | Auto-select (a) ready to merge when READY; auto-select (c) done for now when NOT READY |
|
|
27
|
+
|
|
28
|
+
### Safety Guardrails (Never Skipped)
|
|
29
|
+
|
|
30
|
+
These checkpoints are NEVER skipped, even in auto mode:
|
|
31
|
+
|
|
32
|
+
- **Critical findings** default to FIX NOW. If a critical finding cannot be fixed after 2 retries, auto-mode records it as `Critical-deferred` with rationale "auto-deferred: fix attempts exhausted after 2 retries" and the `Critical-deferred` tag in todo.md
|
|
33
|
+
- **Quality gates** (lint, typecheck, tests) must pass before commit. Auto-mode does not bypass quality checks
|
|
34
|
+
- **Critical Deferral Protocol** still applies — auto-mode provides a structured rationale rather than skipping the protocol
|
|
35
|
+
- **No force-push.** Never rewrite history
|
|
36
|
+
- **Max 2 retry loops** on quality failures. Auto-mode does not retry indefinitely
|
|
37
|
+
- **Proactive leftover scan** (Step 4) always runs. This is the primary input in auto-mode since the user interview is skipped
|
|
38
|
+
|
|
39
|
+
### Activation
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
/hatch3r revision --auto
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Session Report
|
|
46
|
+
|
|
47
|
+
At the end of an auto session (or any session when `--auto` is active), generate a summary:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Revision Session Report:
|
|
51
|
+
Findings: {N} total ({critical}/{important}/{cleanup}/{cosmetic})
|
|
52
|
+
Fixed: {N}
|
|
53
|
+
Deferred: {M} (written to todo.md)
|
|
54
|
+
Quality agents spawned: {list}
|
|
55
|
+
Quality gate status: {pass/fail}
|
|
56
|
+
Commits: {N}
|
|
57
|
+
Learnings captured: {count}
|
|
58
|
+
Overall confidence: {high/medium/low}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Error Handling
|
|
64
|
+
|
|
65
|
+
> Platform-specific CLI commands: see `commands/board/shared-{platform}.md` for fallback chains
|
|
66
|
+
|
|
67
|
+
- **Git diff failure**: If `git diff` fails (e.g., no commits on branch, detached HEAD), **ASK** the user for the correct branch or base ref.
|
|
68
|
+
- **No changes detected**: If the diff is empty, inform the user and exit. There is nothing to revise.
|
|
69
|
+
- **PR/issue fetch failure**: Retry once using the platform CLI. If retry fails, proceed without PR/issue context. Work from the diff alone. Warn the user that acceptance criteria are unavailable.
|
|
70
|
+
- **Sub-agent failure**: Retry once. If the retry fails, fall back to direct implementation for that finding.
|
|
71
|
+
- **Quality check failure after 2 retries**: Present the specific failures and **ASK** the user whether to proceed with a partial fix commit or continue debugging.
|
|
72
|
+
- **Push failure**: Present the error. Common fixes: `git push -u origin {branch}` for new branches, `git pull --rebase` for diverged branches.
|
|
73
|
+
- **Context degradation (>25 turns)**: Suggest starting a fresh chat with a progress summary. The revision command is designed for fresh contexts — it can be re-run.
|
|
74
|
+
- **Board sync failure** (when board context exists): Warn and continue. Board sync is advisory in revision — it does not block the fix pipeline.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## Guardrails
|
|
79
|
+
|
|
80
|
+
- **Never skip ASK checkpoints** (unless auto-advance mode is active for that specific checkpoint).
|
|
81
|
+
- **Never skip the proactive scan (Step 4)** — even if the user reports no issues. Agents leave leftovers.
|
|
82
|
+
- **Always run quality checks (Step 7)** before committing. Never commit code that fails lint, typecheck, or tests.
|
|
83
|
+
- **Stay within the revision scope.** Fix what was reported and what the scan found. Do not refactor unrelated code, add new features, or expand beyond the original implementation's intent.
|
|
84
|
+
- **Always commit and push** at the end of a revision cycle. The user invoked this command to get fixes merged — do not exit without committing (unless the user explicitly abandons).
|
|
85
|
+
- **Respect the original implementation's architecture.** Revision fixes issues within the existing patterns. If the architecture itself is flawed, note it as a finding but do not restructure — suggest a separate refactor instead.
|
|
86
|
+
- **One sub-agent per concern.** Delegate to specialist sub-agents based on finding type. Do not ask the implementer to also fix lint issues or write tests.
|
|
87
|
+
- **Git safety.** Never force-push. Never rewrite history. Always create new commits for revision changes.
|
|
88
|
+
- **This command composes existing hatch3r agents** — it does not replace them. The reviewer, implementer, lint-fixer, and test-writer agents handle the actual work.
|
|
89
|
+
- **Critical findings default to FIX NOW.** If the user overrides this, execute the Critical Deferral Protocol (Step 5b): structured warning with specific risk, require written rationale, record in todo.md with `Critical-deferred` tag, and flag for elevated triage in board-fill. The user is never blocked — rationale adds accountability, not a veto.
|
|
90
|
+
- **Deferred findings go to `todo.md`, not directly to GitHub/GitLab/Azure DevOps issues.** The board-fill pipeline handles triage, epic creation, dependency analysis, and readiness assessment. Revision does not shortcut this process.
|
|
91
|
+
- **Always format deferred items as a single epic block** in `todo.md`, regardless of count. This groups them together during the next board-fill run.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-revision-quality
|
|
3
|
+
type: command
|
|
4
|
+
description: Quality verification pipeline for revision Step 7. Covers review loop (Stage 1), final quality with conditional specialists (Stage 2), and failure handling.
|
|
5
|
+
tags: [implementation, team]
|
|
6
|
+
quality_charter: agents/shared/quality-charter.md
|
|
7
|
+
---
|
|
8
|
+
# Revision — Quality Verification (Step 7)
|
|
9
|
+
|
|
10
|
+
Quality pipeline for `hatch3r-revision`. Referenced from the core command file.
|
|
11
|
+
|
|
12
|
+
Run the project's quality checks after fix implementation. Refer to `package.json` scripts, `README.md`, or `AGENTS.md` for the appropriate commands.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 7a. Run Quality Gates
|
|
17
|
+
|
|
18
|
+
1. Lint check (e.g., `npm run lint`)
|
|
19
|
+
2. Type check (e.g., `npm run typecheck`)
|
|
20
|
+
3. Test suite (e.g., `npm run test`)
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 7b. Verify User-Reported Issues
|
|
25
|
+
|
|
26
|
+
Walk through each critical and important finding from Step 5. Verify it is addressed by the changes made in Step 6. If acceptance criteria exist from linked issues, verify each criterion.
|
|
27
|
+
|
|
28
|
+
For each verified finding and acceptance criterion, rate verification confidence: high (fix confirmed via tests or direct observation), medium (code change addresses the issue but edge cases not independently tested), low (fix applied but uncertain of completeness).
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Stage 1: Review Loop (Sequential)
|
|
33
|
+
|
|
34
|
+
Run an iterative review loop (max 3 iterations) until 0 Critical + 0 Warning findings remain:
|
|
35
|
+
|
|
36
|
+
1. Spawn `hatch3r-reviewer` sub-agent via the Task tool (`subagent_type: "generalPurpose"`).
|
|
37
|
+
|
|
38
|
+
The reviewer prompt MUST include:
|
|
39
|
+
- The diff of all changes made (use `git diff` on the working tree).
|
|
40
|
+
- All `scope: always` rule directives from `.agents/rules/`.
|
|
41
|
+
- Iteration number and previous findings (if not the first iteration).
|
|
42
|
+
- Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
43
|
+
|
|
44
|
+
**When Tier 2/3 research was performed** (from Step 6.pre):
|
|
45
|
+
- Include blast radius data so the reviewer can verify fixes preserve dependent consumers and contracts.
|
|
46
|
+
- Include reference conventions so the reviewer can verify fixes follow established patterns.
|
|
47
|
+
|
|
48
|
+
2. Process reviewer output:
|
|
49
|
+
- If **0 Critical and 0 Warning** findings: review loop is clean. Proceed to Stage 2.
|
|
50
|
+
- If Critical or Warning findings remain: spawn `hatch3r-fixer` sub-agent to address them. When fixes touch shared or public interfaces, include blast radius data and reference conventions in the fixer prompt. Then re-run the reviewer (next iteration).
|
|
51
|
+
|
|
52
|
+
3. If 3 iterations complete and findings remain, **ASK** the user whether to proceed or fix manually.
|
|
53
|
+
|
|
54
|
+
After each reviewer iteration, assess the reviewer's findings confidence: if the reviewer rates any finding as low-confidence, flag it separately in the ASK prompt so the user can prioritize human review of uncertain findings.
|
|
55
|
+
|
|
56
|
+
4. After any fixes, re-run quality gates (7a) to verify nothing broke.
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Stage 2: Final Quality (Parallel)
|
|
61
|
+
|
|
62
|
+
After the review loop is clean, spawn specialist agents in parallel via the Task tool.
|
|
63
|
+
|
|
64
|
+
### Always Spawn (Mandatory for Code Changes)
|
|
65
|
+
|
|
66
|
+
- **`hatch3r-test-writer`** — write or update tests for code changes. Unit tests for new logic, regression tests for bug fixes, integration tests for cross-module changes.
|
|
67
|
+
- **`hatch3r-security-auditor`** — security review of code changes. Audit data flows, access control, input validation, and secret management.
|
|
68
|
+
|
|
69
|
+
### Always Evaluate (Spawn When Applicable)
|
|
70
|
+
|
|
71
|
+
- **`hatch3r-docs-writer`** — spawn when revision fixes affect public APIs, architectural patterns, or user-facing behavior. Skip silently when no documentation impact is detected (no API signature changes, no UX behavioral changes, no new configuration options).
|
|
72
|
+
|
|
73
|
+
### Conditional Specialists (Spawn When Triggered)
|
|
74
|
+
|
|
75
|
+
- **`hatch3r-lint-fixer`** — spawn when lint errors are present after fix implementation (Step 6 lint-fixer may have missed errors introduced by other sub-agents).
|
|
76
|
+
- **`hatch3r-a11y-auditor`** — spawn when the diff includes UI component changes (`area:ui` or `area:a11y` label on linked issues, or component/style files in the diff).
|
|
77
|
+
- **`hatch3r-perf-profiler`** — spawn when the diff includes hot-path changes (`area:performance` label on linked issues, or changes to database queries, API handlers, rendering loops).
|
|
78
|
+
|
|
79
|
+
### Specialist Prompt Requirements
|
|
80
|
+
|
|
81
|
+
Each specialist sub-agent prompt MUST include:
|
|
82
|
+
- The agent protocol to follow (e.g., "Follow the hatch3r-test-writer agent protocol").
|
|
83
|
+
- All `scope: always` rule directives from `.agents/rules/` (sub-agents do not inherit rules automatically).
|
|
84
|
+
- The diff or file changes to review.
|
|
85
|
+
- The linked issue's acceptance criteria (if available).
|
|
86
|
+
- Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
|
|
87
|
+
|
|
88
|
+
Await all specialist sub-agents. Apply their feedback (fixes, additional tests, documentation updates). Re-run quality gates (7a) if changes were made.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 7e. Handle Failures
|
|
93
|
+
|
|
94
|
+
- If quality checks fail: identify the specific failures, fix them directly (for simple issues) or loop back to Step 6 with specific failures.
|
|
95
|
+
- Max 2 retry loops on quality check failures. After 2 retries, **ASK** the user for guidance: "Quality checks still failing. Fix confidence: {high/medium/low — based on whether root cause is identified}."
|
|
96
|
+
- If a user-reported issue was not fully addressed: **ASK** the user whether to attempt another fix or defer.
|