@alecsibilia/luca 13.0.0-alpha.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.
Files changed (128) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +47 -0
  3. package/bin/luca.js +3 -0
  4. package/dist/chunks/branch.mjs +47 -0
  5. package/dist/chunks/bun-runtime.mjs +46 -0
  6. package/dist/chunks/checks.mjs +53 -0
  7. package/dist/chunks/claim-verify.mjs +465 -0
  8. package/dist/chunks/classify.mjs +105 -0
  9. package/dist/chunks/confidence.mjs +199 -0
  10. package/dist/chunks/doctor.mjs +158 -0
  11. package/dist/chunks/hook.mjs +696 -0
  12. package/dist/chunks/init.mjs +715 -0
  13. package/dist/chunks/muninndb-health.mjs +66 -0
  14. package/dist/chunks/phase.mjs +38 -0
  15. package/dist/chunks/pr-review.mjs +122 -0
  16. package/dist/chunks/preferences.mjs +61 -0
  17. package/dist/chunks/repair.mjs +111 -0
  18. package/dist/chunks/repo.mjs +58 -0
  19. package/dist/chunks/retro.mjs +86 -0
  20. package/dist/chunks/roadmap.mjs +58 -0
  21. package/dist/chunks/rules.mjs +527 -0
  22. package/dist/chunks/stale-mcp-server.mjs +90 -0
  23. package/dist/chunks/state.mjs +57 -0
  24. package/dist/chunks/stray-local-install.mjs +200 -0
  25. package/dist/chunks/telemetry.mjs +165 -0
  26. package/dist/chunks/todo.mjs +151 -0
  27. package/dist/chunks/vault-init.mjs +300 -0
  28. package/dist/chunks/verification.mjs +95 -0
  29. package/dist/chunks/version.mjs +70 -0
  30. package/dist/chunks/workflow.mjs +47 -0
  31. package/dist/claude/.claude/agents/architect.md +410 -0
  32. package/dist/claude/.claude/agents/build.md +111 -0
  33. package/dist/claude/.claude/agents/discuss.md +93 -0
  34. package/dist/claude/.claude/agents/discussion.md +149 -0
  35. package/dist/claude/.claude/agents/execute.md +416 -0
  36. package/dist/claude/.claude/agents/executor.md +161 -0
  37. package/dist/claude/.claude/agents/fast.md +84 -0
  38. package/dist/claude/.claude/agents/finalize.md +484 -0
  39. package/dist/claude/.claude/agents/learner.md +160 -0
  40. package/dist/claude/.claude/agents/plan-reviewer.md +129 -0
  41. package/dist/claude/.claude/agents/plan.md +96 -0
  42. package/dist/claude/.claude/agents/research.md +327 -0
  43. package/dist/claude/.claude/agents/researcher.md +78 -0
  44. package/dist/claude/.claude/agents/review.md +283 -0
  45. package/dist/claude/.claude/agents/reviewer.md +163 -0
  46. package/dist/claude/.claude/agents/shadow-scanner.md +257 -0
  47. package/dist/claude/.claude/agents/triage.md +230 -0
  48. package/dist/claude/.claude/agents/verifier.md +131 -0
  49. package/dist/claude/.claude/commands/bug-diagnose.md +12 -0
  50. package/dist/claude/.claude/commands/gh-issue-triage.md +14 -0
  51. package/dist/claude/.claude/commands/gh-pr-address.md +235 -0
  52. package/dist/claude/.claude/commands/gh-prepare.md +12 -0
  53. package/dist/claude/.claude/commands/grill-me.md +12 -0
  54. package/dist/claude/.claude/commands/lu-review.md +51 -0
  55. package/dist/claude/.claude/commands/lu.md +75 -0
  56. package/dist/claude/.claude/commands/luca-init.md +14 -0
  57. package/dist/claude/.claude/commands/luca-telemetry-report.md +12 -0
  58. package/dist/claude/.claude/commands/memory-audit.md +12 -0
  59. package/dist/claude/.claude/commands/milestone-new.md +122 -0
  60. package/dist/claude/.claude/commands/phase-discuss.md +45 -0
  61. package/dist/claude/.claude/commands/phase-execute.md +39 -0
  62. package/dist/claude/.claude/commands/phase-plan.md +53 -0
  63. package/dist/claude/.claude/commands/repo-cleanup.md +80 -0
  64. package/dist/claude/.claude/commands/todo-add.md +28 -0
  65. package/dist/claude/.claude/commands/todo-check.md +36 -0
  66. package/dist/claude/.claude/hooks/context-refresher.ts +285 -0
  67. package/dist/claude/.claude/hooks/continuation-messages.ts +215 -0
  68. package/dist/claude/.claude/hooks/pipeline-guard.ts +182 -0
  69. package/dist/claude/.claude/settings.json +41 -0
  70. package/dist/claude/skills/arch-audit/SKILL.md +161 -0
  71. package/dist/claude/skills/autopilot/SKILL.md +1299 -0
  72. package/dist/claude/skills/bug-diagnose/SKILL.md +102 -0
  73. package/dist/claude/skills/choose/SKILL.md +124 -0
  74. package/dist/claude/skills/gh-issue-triage/SKILL.md +97 -0
  75. package/dist/claude/skills/gh-pr-address/SKILL.md +235 -0
  76. package/dist/claude/skills/gh-prepare/SKILL.md +209 -0
  77. package/dist/claude/skills/grill-me/SKILL.md +46 -0
  78. package/dist/claude/skills/lu/SKILL.md +112 -0
  79. package/dist/claude/skills/lu-review/SKILL.md +51 -0
  80. package/dist/claude/skills/luca-init/SKILL.md +91 -0
  81. package/dist/claude/skills/luca-telemetry-report/SKILL.md +145 -0
  82. package/dist/claude/skills/luca-write-surface/SKILL.md +213 -0
  83. package/dist/claude/skills/memory-audit/SKILL.md +217 -0
  84. package/dist/claude/skills/milestone-audit/SKILL.md +545 -0
  85. package/dist/claude/skills/milestone-complete/SKILL.md +168 -0
  86. package/dist/claude/skills/milestone-gaps/SKILL.md +60 -0
  87. package/dist/claude/skills/milestone-new/SKILL.md +125 -0
  88. package/dist/claude/skills/note/SKILL.md +162 -0
  89. package/dist/claude/skills/phase-add/SKILL.md +91 -0
  90. package/dist/claude/skills/phase-assumptions/SKILL.md +92 -0
  91. package/dist/claude/skills/phase-discuss/SKILL.md +165 -0
  92. package/dist/claude/skills/phase-execute/SKILL.md +1786 -0
  93. package/dist/claude/skills/phase-insert/SKILL.md +100 -0
  94. package/dist/claude/skills/phase-plan/SKILL.md +461 -0
  95. package/dist/claude/skills/phase-remove/SKILL.md +113 -0
  96. package/dist/claude/skills/phase-research/SKILL.md +80 -0
  97. package/dist/claude/skills/post-init-tour/SKILL.md +58 -0
  98. package/dist/claude/skills/progress/SKILL.md +271 -0
  99. package/dist/claude/skills/project-new/SKILL.md +609 -0
  100. package/dist/claude/skills/quick/SKILL.md +256 -0
  101. package/dist/claude/skills/rename-audit/SKILL.md +52 -0
  102. package/dist/claude/skills/repo-audit/SKILL.md +88 -0
  103. package/dist/claude/skills/repo-cleanup/SKILL.md +80 -0
  104. package/dist/claude/skills/seed-memory/SKILL.md +235 -0
  105. package/dist/claude/skills/session-pause/SKILL.md +126 -0
  106. package/dist/claude/skills/session-plan/SKILL.md +112 -0
  107. package/dist/claude/skills/session-resume/SKILL.md +75 -0
  108. package/dist/claude/skills/todo-add/SKILL.md +85 -0
  109. package/dist/claude/skills/todo-check/SKILL.md +77 -0
  110. package/dist/claude/skills/workflow-save/SKILL.md +277 -0
  111. package/dist/index.d.mts +33 -0
  112. package/dist/index.d.ts +33 -0
  113. package/dist/index.mjs +69 -0
  114. package/dist/shared/luca.B3Mimc0P.mjs +52 -0
  115. package/dist/shared/luca.B3saVjJm.mjs +163 -0
  116. package/dist/shared/luca.BYdjkfnz.mjs +217 -0
  117. package/dist/shared/luca.BmhNkYe2.mjs +56 -0
  118. package/dist/shared/luca.C4gMUoBd.mjs +358 -0
  119. package/dist/shared/luca.CQ3g1xrD.mjs +19 -0
  120. package/dist/shared/luca.CRmaAfXR.mjs +713 -0
  121. package/dist/shared/luca.CrXzXueR.mjs +57 -0
  122. package/dist/shared/luca.DTomPq7I.mjs +91 -0
  123. package/dist/shared/luca.DjDTeDCi.mjs +1904 -0
  124. package/dist/shared/luca.HZxBTBgD.mjs +201 -0
  125. package/dist/shared/luca.TSMg1t7I.mjs +10 -0
  126. package/dist/shared/luca.dM-MKlNE.mjs +25 -0
  127. package/dist/shared/luca.naWEcQ4B.mjs +7 -0
  128. package/package.json +76 -0
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: bug-diagnose
3
+ description: "Disciplined diagnosis loop for hard bugs and performance regressions. Build a feedback loop first, then reproduce, hypothesise, instrument, fix, and clean up. Use when user says \"diagnose this\", \"debug this\", reports a bug, says something is broken/throwing/failing, describes a performance regression, or invokes /bug-diagnose."
4
+ ---
5
+
6
+ # Bug Diagnose
7
+
8
+ A discipline for hard bugs. Skip phases only when explicitly justified.
9
+
10
+ ## Phase 1 — Build a Feedback Loop
11
+
12
+ **This is the skill.** Everything else is mechanical. If you have a fast, deterministic, agent-runnable pass/fail signal for the bug, you will find the cause. If you don't, no amount of staring at code will save you.
13
+
14
+ Spend disproportionate effort here. Be aggressive. Be creative. Refuse to give up.
15
+
16
+ ### Ways to construct one — try in roughly this order
17
+
18
+ 1. **Failing test** at whatever seam reaches the bug — unit, integration, e2e
19
+ 2. **Curl / HTTP script** against a running dev server
20
+ 3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot
21
+ 4. **Headless browser script** (Playwright / Puppeteer) — drives the UI, asserts on DOM/console/network
22
+ 5. **Replay a captured trace** — save a real request/payload/event log; replay through the code path in isolation
23
+ 6. **Throwaway harness** — spin up a minimal subset of the system that exercises the bug code path
24
+ 7. **Property / fuzz loop** — if the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode
25
+ 8. **Bisection harness** — if the bug appeared between two known states, automate `git bisect run`
26
+ 9. **Differential loop** — run the same input through old-version vs new-version and diff outputs
27
+ 10. **HITL bash script** — last resort. If a human must click, structure the loop so captured output feeds back to you
28
+
29
+ ### Iterate on the loop itself
30
+
31
+ Treat the loop as a product. Once you have _a_ loop, ask:
32
+
33
+ - Can I make it faster? (Cache setup, skip unrelated init, narrow test scope)
34
+ - Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash")
35
+ - Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network)
36
+
37
+ ### Non-deterministic bugs
38
+
39
+ Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake is debuggable; 1% is not — keep raising the rate.
40
+
41
+ ### When you genuinely cannot build a loop
42
+
43
+ Stop and say so explicitly. List what you tried. Ask the user for: (a) access to the reproducing environment, (b) a captured artifact (HAR file, log dump, screen recording), or (c) permission to add temporary production instrumentation. **Do not proceed to Phase 2 without a loop.**
44
+
45
+ ## Phase 2 — Reproduce
46
+
47
+ Run the loop. Watch the bug appear. Confirm:
48
+
49
+ - [ ] The loop produces the failure mode the **user** described — not a different failure nearby
50
+ - [ ] The failure is reproducible across multiple runs (or at a high enough rate to debug)
51
+ - [ ] You have captured the exact symptom (error message, wrong output, slow timing)
52
+
53
+ Do not proceed until you reproduce the bug.
54
+
55
+ ## Phase 3 — Hypothesise
56
+
57
+ Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
58
+
59
+ Each hypothesis must be **falsifiable**: state the prediction it makes.
60
+
61
+ > Format: "If \<X\> is the cause, then \<changing Y\> will make the bug disappear / \<changing Z\> will make it worse."
62
+
63
+ If you cannot state the prediction, the hypothesis is a vibe — discard or sharpen it.
64
+
65
+ **Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly. Don't block on it — proceed with your ranking if the user is AFK.
66
+
67
+ ## Phase 4 — Instrument
68
+
69
+ Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
70
+
71
+ Tool preference:
72
+
73
+ 1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
74
+ 2. **Targeted logs** at the boundaries that distinguish hypotheses.
75
+ 3. Never "log everything and grep."
76
+
77
+ **Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep.
78
+
79
+ **Perf bugs**: logs are usually wrong. Establish a baseline measurement (timing harness, profiler, query plan), then bisect. Measure first, fix second.
80
+
81
+ ## Phase 5 — Fix + Regression Test
82
+
83
+ Write the regression test **before the fix** — but only if there is a correct seam for it.
84
+
85
+ A correct seam exercises the real bug pattern as it occurs at the call site. If the only available seam is too shallow, a regression test there gives false confidence. Note this — the architecture is preventing the bug from being locked down.
86
+
87
+ If a correct seam exists:
88
+
89
+ 1. Turn the minimised repro into a failing test at that seam
90
+ 2. Watch it fail
91
+ 3. Apply the fix
92
+ 4. Watch it pass
93
+ 5. Re-run the Phase 1 feedback loop against the original scenario
94
+
95
+ ## Phase 6 — Cleanup + Post-Mortem
96
+
97
+ Required before declaring done:
98
+
99
+ - [ ] Original repro passes (the bug is actually fixed)
100
+ - [ ] All debug logs/probes removed (grep for your `[DEBUG-` tag)
101
+ - [ ] Commit message explains **why** the bug happened and the fix
102
+ - [ ] Open questions (if any) left as TODOs or follow-up issues
@@ -0,0 +1,124 @@
1
+ ---
2
+ name: choose
3
+ description: Choose between issue-driven development and Luca spec-driven workflow for a task.
4
+ ---
5
+
6
+ <main>
7
+ # Luca Choose Workflow
8
+
9
+ Help users select the right development workflow for their task.
10
+
11
+ ## Two Development Paths
12
+
13
+ This project supports two complementary workflows:
14
+
15
+ | Workflow | Best For | Commands |
16
+ |----------|----------|----------|
17
+ | **Issue-Driven** | Quick fixes, single features | `/project:git/feature`, `bun commit` |
18
+ | **Luca** | Complex initiatives, multi-phase | `/project-new`, `/phase-execute` |
19
+
20
+ ## Decision Matrix
21
+
22
+ | Scenario | Recommended | Why |
23
+ |----------|-------------|-----|
24
+ | Quick bug fix | Issue workflow | Single commit, fast turnaround |
25
+ | Single feature (1-3 files) | Issue workflow | Simple scope, direct PR |
26
+ | New module/system (5+ phases) | Luca | Structured planning prevents context rot |
27
+ | Greenfield project | Luca | Full roadmap with research phases |
28
+ | Complex refactor | Luca | Phase-based execution with verification |
29
+ | Same-day completion | Issue workflow | No planning overhead needed |
30
+ | Multi-session work | Luca | State machine preserves context across sessions |
31
+
32
+ ## Process
33
+
34
+ ### Step 1: Ask About the Task
35
+
36
+ Use AskQuestion tool:
37
+
38
+ - header: "Workflow Selection"
39
+ - question: "What kind of work are you doing?"
40
+ - options:
41
+ - "Bug fix or small enhancement" → Issue workflow
42
+ - "Single feature (1-3 files changed)" → Issue workflow
43
+ - "New project or major initiative" → Luca
44
+ - "Complex refactor (many files)" → Luca
45
+ - "Not sure, help me decide" → Continue to Step 2
46
+
47
+ ### Step 2: Gather More Context (if needed)
48
+
49
+ Ask clarifying questions:
50
+
51
+ - How many phases/stages do you envision?
52
+ - Will this take multiple sessions to complete?
53
+ - Do you need structured research before implementation?
54
+
55
+ ### Step 3: Route to Workflow
56
+
57
+ **For Issue Workflow:**
58
+
59
+ ```
60
+ ## Recommended: Issue-Driven Workflow
61
+
62
+ This task is well-suited for the issue workflow.
63
+
64
+ **Next Steps:**
65
+ 1. Create or find a GitHub issue
66
+ 2. Run: `/project:git/feature {issue}--{description}`
67
+ 3. Implement with `bun commit` for each change
68
+ 4. Create PR when done
69
+
70
+ **Commands:**
71
+ - `/project:git/feature` — Create feature branch
72
+ - `/project:git/commit` — Conventional commit
73
+ - `/project:git/pr` — Create pull request
74
+ ```
75
+
76
+ **For Luca Workflow:**
77
+
78
+ ```
79
+ ## Recommended: Luca Workflow
80
+
81
+ This task benefits from structured planning and phased execution.
82
+
83
+ **Next Steps:**
84
+ 1. Run: `/project-new` to initialize
85
+ 2. Answer questions to build roadmap
86
+ 3. Execute phases with `/phase-execute`
87
+
88
+ **Commands:**
89
+ - `/project-new` — Initialize project with roadmap
90
+ - `/progress` — Check current status
91
+ - `/help` — See all Luca commands
92
+ ```
93
+
94
+ ## Key Differences
95
+
96
+ | Aspect | Issue Workflow | Luca |
97
+ |--------|----------------|------|
98
+ | Planning | `.cursor/plans/` | `.luca/` |
99
+ | Commits | `type(scope): #issue desc` | `type(phase-plan): #issue desc` |
100
+ | Branch | `{issue}--{description}` | `{issue}--{description}` |
101
+ | State | Git history | State machine (.luca/state.json) + Git |
102
+ | Verification | Manual testing | Automated phase verification |
103
+
104
+ ## Success Criteria
105
+
106
+ - [ ] User's task complexity understood
107
+ - [ ] Appropriate workflow recommended
108
+ - [ ] Next steps clearly explained
109
+ - [ ] User ready to proceed
110
+
111
+ ## Next Steps
112
+
113
+ This skill helps you decide between workflows. After choosing:
114
+
115
+ | Choice | Next Command |
116
+ |--------|--------------|
117
+ | Issue-driven | `/lu [TICKET-ID]` or `/lu {task}` |
118
+ | Luca | `/project-new` |
119
+ | Quick task | `/quick` |
120
+
121
+ **Common follow-ups:**
122
+ - `/help` — Review all available commands
123
+ - `/progress` — Check existing project status
124
+ </main>
@@ -0,0 +1,97 @@
1
+ ---
2
+ name: gh-issue-triage
3
+ description: "Pull open GitHub issues into the MuninnDB todo backlog for pipeline execution. Filters out issues labeled `skip-triage`, deduplicates against existing todos, and links each todo back to its originating issue so the PR can close it on merge. Use when user says \"triage issues\", \"pull in issues\", \"import issues\", \"sync issues to todos\", or invokes /gh-issue-triage."
4
+ ---
5
+
6
+ # GH Issue Triage
7
+
8
+ Pull open GitHub issues into the **MuninnDB todo backlog** so the Luca pipeline can pick them up. Each issue becomes a `todo:*` memory; when the pipeline ships a PR it closes the originating issue automatically via `Closes #N`.
9
+
10
+ ## Process
11
+
12
+ ### 1. Fetch open issues
13
+
14
+ ```bash
15
+ gh issue list --state open --json number,title,body,labels,assignees,createdAt --limit 100
16
+ ```
17
+
18
+ If no GitHub remote is detected, stop and tell the user.
19
+
20
+ ### 2. Load existing todos (for dedup)
21
+
22
+ Run `luca todo list`. It prints a `mcp__muninn__muninn_recall` instruction blob — execute it exactly as returned. Each recalled memory's `content` is JSON conforming to `TodoSchema`; collect every existing todo's `source` field. This is the dedup set for step 5.
23
+
24
+ ### 3. Filter
25
+
26
+ Remove issues that should not become todos:
27
+
28
+ - **`skip-triage`** label — explicitly excluded from automatic triage
29
+ - **Pull requests** — `gh issue list` may include PRs on some repos; filter by `pull_request` field if present
30
+ - **Already triaged** — drop any issue whose `gh-issue-#<N>` already appears in the dedup set from step 2
31
+
32
+ If `$ARGUMENTS` contains filter terms (e.g. a label name, milestone, or assignee), apply them:
33
+
34
+ ```bash
35
+ gh issue list --state open --label "<label>" ...
36
+ ```
37
+
38
+ ### 4. Present candidates
39
+
40
+ Show the filtered list to the user:
41
+
42
+ ```
43
+ ## Issues Ready for Triage
44
+
45
+ 1. #42 — Add webhook support [enhancement] (2 days ago)
46
+ 2. #38 — Login fails on Safari [bug] (5 days ago)
47
+ 3. #35 — Refactor auth module [refactor] (1 week ago)
48
+
49
+ Skipped: 2 issues (skip-triage), 1 already in backlog
50
+
51
+ Import all, or select by number?
52
+ ```
53
+
54
+ Wait for the user to confirm which issues to import. Accept "all" or a comma-separated list of numbers.
55
+
56
+ ### 5. Create todos
57
+
58
+ For each approved issue, stage the `metadata` object in a JSON file and run `luca todo add`:
59
+
60
+ ```
61
+ # /tmp/luca-todo-meta.json:
62
+ # { "priority": "<high|medium|low>", "area": "<ui|api|infra|...>" }
63
+ luca todo add \
64
+ --title "<issue title>" \
65
+ --body "> GitHub Issue: #<N> — <url>
66
+
67
+ <issue body, trimmed to essentials>" \
68
+ --source "gh-issue-#<N>" \
69
+ --metadata-file /tmp/luca-todo-meta.json
70
+ ```
71
+
72
+ - **`--source`** is `gh-issue-#<N>` — the link back to the originating issue. It carries the issue number through the entire pipeline.
73
+ - **`priority`** is inferred from labels (`critical`/`bug` → `high`, `enhancement` → `medium`, unlabeled → `medium`) and goes in the metadata file.
74
+ - **`area`** is inferred from labels when recognizable (`ui`, `api`, `infra`) and goes in the metadata file.
75
+
76
+ `luca todo add` validates the input and prints a `mcp__muninn__muninn_remember` instruction blob — execute that instruction **exactly as returned** to persist the todo. The todo `id` is derived from the title (kebab-slug).
77
+
78
+ ### 6. Report
79
+
80
+ Print a summary of what was imported:
81
+
82
+ ```
83
+ ## Triage Complete
84
+
85
+ Created 3 todos from GitHub issues:
86
+ - #42 → todo: add-webhook-support (pending)
87
+ - #38 → todo: login-fails-on-safari (pending, priority: high)
88
+ - #35 → todo: refactor-auth-module (pending)
89
+
90
+ Skipped: 1 duplicate (#31 already exists as a todo)
91
+
92
+ Next: run /lu to start working through the backlog.
93
+ ```
94
+
95
+ ## Closing the loop
96
+
97
+ When work ships a PR for a todo whose `source` is `gh-issue-#<N>`, the PR body must include `Closes #<N>` so the issue closes on merge. The `gh-prepare` skill reads the todo's `source` field to render that line — the `source` is the carrier that links issue → todo → PR.
@@ -0,0 +1,235 @@
1
+ ---
2
+ name: gh-pr-address
3
+ description: Address PR review comments — fetch, filter stale, categorize, fix, respond, regression-check.
4
+ ---
5
+
6
+ # /gh-pr-address
7
+
8
+ Address PR review comments by fetching them, dropping stale ones, categorizing by severity, implementing fixes, posting replies, and verifying the fix iteration introduced no regressions.
9
+
10
+ ## Parse arguments
11
+
12
+ Parse `$ARGUMENTS` for:
13
+
14
+ - A **PR number** (e.g. `42`) or **PR URL** (e.g. `https://github.com/owner/repo/pull/42`)
15
+ - `--dry-run` — show categorized comments and planned fixes without executing
16
+ - `--skip-validation` — skip categorization; treat all comments as actionable
17
+ - `--no-respond` — fix issues but don't post reply comments
18
+
19
+ If no PR number or URL is provided, detect it from the current branch:
20
+
21
+ ```bash
22
+ gh pr view --json number,url
23
+ ```
24
+
25
+ Resolve `<repo_vault>` from `.luca/config.json` → `muninn.vault`, falling back to `"default"`.
26
+
27
+ ## Step 1 — Fetch PR data
28
+
29
+ Fetch all reviews and review comments:
30
+
31
+ ```bash
32
+ gh pr view <number> --json reviews,comments,reviewDecision,title,body,number,url
33
+ gh api repos/{owner}/{repo}/pulls/<number>/comments --paginate
34
+ ```
35
+
36
+ Group the results:
37
+
38
+ - **Review comments** — inline code comments with file/line context (the `gh api pulls/<n>/comments` shape).
39
+ - **General comments** — conversation-level feedback.
40
+ - **Duplicates** — the same concern on different lines; group by content similarity and track every comment id in the group.
41
+
42
+ Build a comment map with fields: `commentId, author, body, file, line, inReplyTo, isDuplicate, duplicateGroupId`.
43
+
44
+ **Snapshot the iteration boundary.** Record the current `git rev-parse HEAD` SHA as `iterationStartSha` and the current time as `iterationStartTime` (ISO 8601). Step 7 uses the SHA to compute which paths the iteration modified and the timestamp to filter newly-created comments.
45
+
46
+ ## Step 1.5 — Filter stale comments
47
+
48
+ Comments filed against an earlier commit may already be addressed by later fix commits on the branch. Acting on them wastes iteration cycles.
49
+
50
+ Run the stale-comment filter on the **review comments** (the raw `gh api pulls/<n>/comments` objects — each carries `id, path, line, original_line, commit_id, original_commit_id, diff_hunk, body, in_reply_to_id?, user?`). Stage the review comments array in a JSON file, then run `luca pr-review filter-stale --file`:
51
+
52
+ ```
53
+ # /tmp/luca-pr-comments.json holds the review comments array from Step 1
54
+ luca pr-review filter-stale --file /tmp/luca-pr-comments.json
55
+ ```
56
+
57
+ The command partitions them into four buckets:
58
+
59
+ - **`actionable`** — cited code still exists at the same location. Continue with categorization for these.
60
+ - **`stale`** — cited code was rewritten, removed, or relocated beyond the drift tolerance. **Skip categorization.** When responding (Step 5), reply that the comment is stale and point at the commit that addressed the underlying code.
61
+ - **`replies`** — comments with `in_reply_to_id` set; pass through, not first-class findings.
62
+ - **`unknown`** — could not be re-anchored; treat conservatively as actionable.
63
+
64
+ Append a note to the Step 2 audit summary: `Stale: <n> comments (skipped from categorization)`.
65
+
66
+ ## Step 2 — Categorize comments
67
+
68
+ Unless `--skip-validation` is set, classify each unique actionable comment (deduplicated):
69
+
70
+ | Category | Action | Examples |
71
+ |----------|--------|---------|
72
+ | **security** | Must fix | Vulnerabilities, injection, credential exposure |
73
+ | **bug** | Must fix | Logic errors, regressions, broken behavior |
74
+ | **requirement** | Must fix | Missing acceptance criteria, spec violations |
75
+ | **style** | Should fix | Naming, formatting, established pattern violations |
76
+ | **improvement** | Should fix | Better approach, DX, readability |
77
+ | **question** | Respond only | Clarification requests, design rationale questions |
78
+ | **nit** | Optional | Trivial preferences, minor suggestions |
79
+ | **praise** | Respond only | Positive feedback |
80
+
81
+ Present a summary:
82
+
83
+ ```
84
+ ## PR #<number> Comment Audit
85
+
86
+ Must Fix: N comments (security: N, bug: N, requirement: N)
87
+ Should Fix: N comments (style: N, improvement: N)
88
+ Respond Only: N comments (question: N, praise: N)
89
+ Nit: N comments
90
+ Stale: N comments (skipped from categorization)
91
+
92
+ Total: N unique comments (N duplicates grouped)
93
+ ```
94
+
95
+ If `--dry-run`, stop here.
96
+
97
+ ## Step 2.5 — Detect cross-perspective convergence
98
+
99
+ When two or more independent reviewer perspectives flag the same location, that location is materially more likely to be a real issue. Auto-promote severity so converged findings are treated as must-fix.
100
+
101
+ Build a `findings` array — one entry per actionable comment, plus any findings from other perspectives this iteration has access to. If a pipeline phase is active, include the `luca-reviewer` MUST-FIX/SHOULD-FIX entries from `.luca/phases/<NN-slug>/audits/*.md`. Map each to:
102
+
103
+ ```
104
+ {
105
+ id: <stable id, e.g. comment id or "luca-reviewer:<n>">,
106
+ perspective: <who produced it, e.g. "Copilot", "luca-reviewer">,
107
+ path: <file path>,
108
+ line: <line number>,
109
+ severity: <"must-fix" | "should-fix" | "nit" | "style" | "improvement" | ...>,
110
+ category: <"security" | "bug" | "style" | ...>,
111
+ summary: <short description>
112
+ }
113
+ ```
114
+
115
+ Run convergence detection. Stage the findings array in a JSON file, then run `luca pr-review detect-convergence --file`:
116
+
117
+ ```
118
+ # /tmp/luca-pr-findings.json holds the findings array
119
+ luca pr-review detect-convergence --file /tmp/luca-pr-findings.json --line-tolerance 2
120
+ ```
121
+
122
+ For each entry in the returned `report.promotions`:
123
+
124
+ - Find the corresponding categorized comment in your audit map.
125
+ - Update its severity to **must-fix** (regardless of its original severity), preserving the original category. Add a note: `Promoted via convergence with <other perspectives>`.
126
+ - Surface it in the audit summary: `Converged: <n> findings promoted to must-fix via 2+ perspectives`.
127
+
128
+ Continue to Step 3 with the promoted findings.
129
+
130
+ ## Step 3 — Plan fixes
131
+
132
+ For comments with severity **must fix** and **should fix**:
133
+
134
+ 1. Group by file for efficient execution.
135
+ 2. Determine the fix approach for each comment.
136
+ 3. Order by severity: security → bug → requirement → style → improvement.
137
+
138
+ ## Step 4 — Execute fixes
139
+
140
+ Spawn **`luca-executor`** subagents (one per file group) via the `Agent` tool. Each subagent receives:
141
+
142
+ - The file path and the relevant comment details (body, line, category).
143
+ - Instructions to fix each issue and commit using the project's commit convention. Read it first by running `luca preferences read` and using the `commits` section (`convention`, `types`, `scopes`, `trailers`, `subjectMaxLength`). Reference the PR number per `commits.trailers.issueRef` when set; the executor adds the `Co-Authored-By` trailer automatically when `commits.trailers.coAuthor === true`.
144
+
145
+ After all executor subagents complete, run a type check:
146
+
147
+ ```bash
148
+ bunx --bun tsc --noEmit
149
+ ```
150
+
151
+ If the type check fails, fix the errors before proceeding.
152
+
153
+ ## Step 5 — Respond to comments
154
+
155
+ Unless `--no-respond` is set, post replies to **every** PR comment thread (including all duplicate ids in each group):
156
+
157
+ - **Fixed comments** → reply with what changed and which commit addresses it.
158
+ - **Stale comments** → reply that the comment is stale and point at the commit that already addressed the code.
159
+ - **Question comments** → reply with an answer based on codebase context.
160
+ - **Nit comments** → acknowledge briefly (applied or noted).
161
+ - **Praise comments** → thank and acknowledge briefly.
162
+
163
+ Post inline review-comment replies:
164
+
165
+ ```bash
166
+ gh api repos/{owner}/{repo}/pulls/<number>/comments/<commentId>/replies -f body="<reply>"
167
+ ```
168
+
169
+ Post top-level (conversation) replies:
170
+
171
+ ```bash
172
+ gh api repos/{owner}/{repo}/issues/<number>/comments -f body="<reply>"
173
+ ```
174
+
175
+ ## Step 6 — Push and verify
176
+
177
+ 1. Push the fixes: `git push`
178
+ 2. Verify zero unreplied threads remain:
179
+
180
+ ```bash
181
+ gh api repos/{owner}/{repo}/pulls/<number>/comments --paginate
182
+ ```
183
+
184
+ Check that every comment thread has a reply. Report any gaps.
185
+
186
+ ## Step 7 — Iteration-N regression check
187
+
188
+ Fix commits sometimes introduce new issues the original review didn't flag. Catch them now instead of paying for another full review pass.
189
+
190
+ 1. **Re-fetch all PR comments:**
191
+
192
+ ```bash
193
+ gh api repos/{owner}/{repo}/pulls/<number>/comments --paginate
194
+ ```
195
+
196
+ If the PR has automated reviewer hooks (Copilot, CodeRabbit, etc.) that re-run on push, allow a brief settle window (~30s) before re-fetching.
197
+
198
+ 2. **Build before/after finding arrays.** The `before` array is the `findings` array from Step 2.5 (pre-iteration state). The `after` array is built the same way from the freshly-fetched comments — include only comments with `created_at >= iterationStartTime` to filter out persistent prior findings.
199
+
200
+ 3. **Run the regression check** (it computes touched paths from the SHA range via `git diff`). Stage the full payload object in a JSON file, then run `luca pr-review regression-check --file`:
201
+
202
+ ```
203
+ # /tmp/luca-pr-regression.json holds:
204
+ # {
205
+ # "before": <pre-iteration findings>,
206
+ # "after": <post-iteration findings>,
207
+ # "from_sha": "<iterationStartSha>",
208
+ # "to_sha": "HEAD"
209
+ # }
210
+ luca pr-review regression-check --file /tmp/luca-pr-regression.json
211
+ ```
212
+
213
+ 4. **Handle the verdict.**
214
+
215
+ - No regressions (exit `0`, `report.regressions` empty) → iteration complete. Report `<n> resolved, <n> unchanged, <n> new on untouched paths` in the final summary.
216
+ - Regressions present (exit `1`, `report.regressions` non-empty) → fix commits introduced new findings. **Do not declare the iteration complete.** Re-enter Step 3 (Plan fixes) with `report.regressions` as the input set. The regression cycle is bounded — if 3 consecutive iterations fail this check, escalate to the user with a summary of what's regressing and pause the loop.
217
+
218
+ ## Step 8 — Store learnings
219
+
220
+ Store **recurring patterns** in MuninnDB (skip one-off fixes). The `pattern:*` prefix routes to the `"default"` vault per the vault-routing rule:
221
+
222
+ ```
223
+ mcp__muninn__muninn_remember_batch({
224
+ vault: "default",
225
+ memories: [
226
+ {
227
+ concept: "pattern:pr-review-<category>",
228
+ content: "<description of the recurring review-feedback pattern>",
229
+ tags: ["pr-review", "<category>"]
230
+ }
231
+ ]
232
+ })
233
+ ```
234
+
235
+ $ARGUMENTS