@kodrunhq/opencode-autopilot 1.17.0 → 1.19.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 (118) hide show
  1. package/README.md +95 -13
  2. package/assets/commands/oc-doctor.md +17 -0
  3. package/assets/commands/oc-update-docs.md +1 -1
  4. package/bin/configure-tui.ts +1 -1
  5. package/package.json +1 -1
  6. package/src/agents/index.ts +0 -12
  7. package/src/agents/pipeline/index.ts +0 -4
  8. package/src/autonomy/completion.ts +52 -0
  9. package/src/autonomy/controller.ts +144 -0
  10. package/src/autonomy/index.ts +25 -0
  11. package/src/autonomy/injector.ts +49 -0
  12. package/src/autonomy/state.ts +91 -0
  13. package/src/autonomy/types.ts +30 -0
  14. package/src/autonomy/verification.ts +86 -0
  15. package/src/background/database.ts +170 -0
  16. package/src/background/executor.ts +174 -0
  17. package/src/background/index.ts +8 -0
  18. package/src/background/manager.ts +232 -0
  19. package/src/background/repository.ts +174 -0
  20. package/src/background/schema.ts +24 -0
  21. package/src/background/sdk-runner.ts +40 -0
  22. package/src/background/slot-manager.ts +41 -0
  23. package/src/background/state-machine.ts +19 -0
  24. package/src/config/v7.ts +3 -3
  25. package/src/config.ts +105 -21
  26. package/src/context/budget.ts +45 -0
  27. package/src/context/compaction-handler.ts +58 -0
  28. package/src/context/discovery.ts +94 -0
  29. package/src/context/index.ts +14 -0
  30. package/src/context/injector.ts +119 -0
  31. package/src/context/types.ts +24 -0
  32. package/src/health/checks.ts +214 -3
  33. package/src/health/index.ts +7 -1
  34. package/src/health/runner.ts +14 -2
  35. package/src/index.ts +113 -6
  36. package/src/installer.ts +13 -0
  37. package/src/kernel/index.ts +6 -0
  38. package/src/kernel/migrations.ts +50 -0
  39. package/src/kernel/retry.ts +49 -0
  40. package/src/kernel/schema.ts +9 -1
  41. package/src/kernel/transaction.ts +40 -12
  42. package/src/logging/forensic-writer.ts +6 -2
  43. package/src/logging/index.ts +2 -0
  44. package/src/mcp/index.ts +34 -0
  45. package/src/mcp/manager.ts +206 -0
  46. package/src/mcp/scope-filter.ts +44 -0
  47. package/src/mcp/types.ts +38 -0
  48. package/src/orchestrator/arena.ts +7 -1
  49. package/src/orchestrator/fallback/event-handler.ts +12 -1
  50. package/src/orchestrator/handlers/challenge.ts +8 -1
  51. package/src/orchestrator/handlers/plan.ts +8 -1
  52. package/src/orchestrator/handlers/recon.ts +8 -1
  53. package/src/orchestrator/handlers/types.ts +2 -2
  54. package/src/orchestrator/lesson-memory.ts +6 -1
  55. package/src/orchestrator/orchestration-logger.ts +15 -3
  56. package/src/orchestrator/skill-injection.ts +7 -1
  57. package/src/orchestrator/state.ts +6 -1
  58. package/src/recovery/classifier.ts +127 -0
  59. package/src/recovery/event-handler.ts +263 -0
  60. package/src/recovery/index.ts +20 -0
  61. package/src/recovery/orchestrator.ts +180 -0
  62. package/src/recovery/persistence.ts +87 -0
  63. package/src/recovery/strategies.ts +107 -0
  64. package/src/recovery/types.ts +31 -0
  65. package/src/registry/model-groups.ts +2 -19
  66. package/src/registry/resolver.ts +38 -9
  67. package/src/review/agent-catalog.ts +83 -251
  68. package/src/review/agents/architecture-verifier.ts +41 -0
  69. package/src/review/agents/code-hygiene-auditor.ts +40 -0
  70. package/src/review/agents/correctness-auditor.ts +41 -0
  71. package/src/review/agents/frontend-auditor.ts +39 -0
  72. package/src/review/agents/index.ts +15 -42
  73. package/src/review/agents/language-idioms-auditor.ts +39 -0
  74. package/src/review/agents/security-auditor.ts +12 -8
  75. package/src/review/stack-gate.ts +2 -6
  76. package/src/routing/categories.ts +111 -0
  77. package/src/routing/classifier.ts +152 -0
  78. package/src/routing/engine.ts +89 -0
  79. package/src/routing/index.ts +4 -0
  80. package/src/routing/types.ts +14 -0
  81. package/src/skills/adaptive-injector.ts +34 -3
  82. package/src/skills/loader.ts +4 -0
  83. package/src/tools/background.ts +196 -0
  84. package/src/tools/configure.ts +1 -1
  85. package/src/tools/delegate.ts +205 -0
  86. package/src/tools/loop.ts +94 -0
  87. package/src/tools/recover.ts +172 -0
  88. package/src/types/background.ts +51 -0
  89. package/src/types/mcp.ts +27 -0
  90. package/src/types/recovery.ts +49 -0
  91. package/src/types/routing.ts +39 -0
  92. package/src/ux/context-warnings.ts +81 -0
  93. package/src/ux/error-hints.ts +38 -0
  94. package/src/ux/index.ts +7 -0
  95. package/src/ux/notifications.ts +67 -0
  96. package/src/ux/progress.ts +77 -0
  97. package/src/ux/session-summary.ts +67 -0
  98. package/src/ux/task-status.ts +109 -0
  99. package/src/ux/types.ts +24 -0
  100. package/src/agents/db-specialist.ts +0 -295
  101. package/src/agents/devops.ts +0 -352
  102. package/src/agents/documenter.ts +0 -44
  103. package/src/agents/frontend-engineer.ts +0 -541
  104. package/src/agents/pipeline/oc-explorer.ts +0 -46
  105. package/src/agents/pipeline/oc-retrospector.ts +0 -42
  106. package/src/review/agents/auth-flow-verifier.ts +0 -47
  107. package/src/review/agents/concurrency-checker.ts +0 -47
  108. package/src/review/agents/dead-code-scanner.ts +0 -47
  109. package/src/review/agents/go-idioms-auditor.ts +0 -46
  110. package/src/review/agents/python-django-auditor.ts +0 -46
  111. package/src/review/agents/react-patterns-auditor.ts +0 -46
  112. package/src/review/agents/rust-safety-auditor.ts +0 -46
  113. package/src/review/agents/scope-intent-verifier.ts +0 -45
  114. package/src/review/agents/silent-failure-hunter.ts +0 -45
  115. package/src/review/agents/spec-checker.ts +0 -45
  116. package/src/review/agents/state-mgmt-auditor.ts +0 -46
  117. package/src/review/agents/type-soundness.ts +0 -46
  118. package/src/review/agents/wiring-inspector.ts +0 -46
@@ -1,16 +1,6 @@
1
1
  import type { AgentCategory, AgentDefinition } from "./types";
2
2
 
3
- /**
4
- * NOTE: This catalog is reference data and is NOT yet wired into the review pipeline.
5
- * The pipeline uses the agent definitions from src/review/agents/*.ts directly.
6
- * This file may be integrated in a future milestone to drive dynamic agent selection.
7
- *
8
- * Complete registry of review agents ported from the ace review engine.
9
- * Core squad always runs. Parallel specialists run based on stack gate.
10
- * Sequenced specialists run after all prior findings are collected.
11
- */
12
3
  export const AGENT_CATALOG: readonly AgentDefinition[] = Object.freeze([
13
- // --- Core Squad (always runs) ---
14
4
  Object.freeze({
15
5
  name: "logic-auditor",
16
6
  category: "core" as const,
@@ -57,171 +47,143 @@ export const AGENT_CATALOG: readonly AgentDefinition[] = Object.freeze([
57
47
  hardGatesSummary:
58
48
  "Reads both sides of every API boundary, compares shapes/methods/URLs/error codes",
59
49
  }),
60
-
61
- // --- Parallel Specialists ---
62
50
  Object.freeze({
63
- name: "wiring-inspector",
51
+ name: "security-auditor",
64
52
  category: "parallel" as const,
65
- domain: "End-to-end connectivity (UI -> API -> DB -> response -> UI)",
53
+ domain: "Systematic OWASP auditing, auth/authz correctness, secrets, injection, crypto",
66
54
  catches: Object.freeze([
67
- "Disconnected flows",
68
- "Wrong endpoint URLs",
69
- "Mismatched request/response shapes",
70
- "Missing error propagation across layers",
71
- "Orphaned handlers",
55
+ "Hardcoded secrets",
56
+ "SQL/NoSQL/command injection",
57
+ "XSS",
58
+ "CSRF gaps",
59
+ "Broken route protection",
60
+ "Privilege escalation",
61
+ "Token validation gaps",
62
+ "Insecure crypto",
63
+ "SSRF",
64
+ "Sensitive data in logs",
72
65
  ]),
73
66
  triggerSignals: Object.freeze([
74
- "Changes span 2+ architectural layers",
75
- "New API endpoints",
76
- "New UI components that fetch data",
67
+ "User input handling",
68
+ "API endpoint changes",
69
+ "Auth middleware or session code",
70
+ "Database query construction",
71
+ "Crypto usage",
77
72
  ]),
78
73
  stackAffinity: Object.freeze(["universal"]),
79
74
  hardGatesSummary:
80
- "Traces every feature path from UI event to DB write and back, documents each verified link",
75
+ "Checks OWASP Top 10 categories systematically and verifies auth guard, token, and password-handling flows end-to-end",
81
76
  }),
82
77
  Object.freeze({
83
- name: "dead-code-scanner",
78
+ name: "code-hygiene-auditor",
84
79
  category: "parallel" as const,
85
- domain: "Unused code, imports, unreachable branches",
80
+ domain: "Unused code, unreachable branches, debug artifacts, and silent failure patterns",
86
81
  catches: Object.freeze([
87
82
  "Unused imports",
88
83
  "Orphaned functions",
89
- "TODO/FIXME",
84
+ "Unreachable branches",
85
+ "Empty catch blocks",
86
+ "Silent fallbacks that hide failures",
90
87
  "Console.log/debugger",
91
- "Hardcoded secrets",
92
88
  "Commented-out code",
93
89
  ]),
94
90
  triggerSignals: Object.freeze([
95
91
  "Refactors",
96
92
  "Feature removals",
97
93
  "Large diffs",
98
- "File deletions with remaining references",
94
+ "New error handling or fallback logic",
99
95
  ]),
100
96
  stackAffinity: Object.freeze(["universal"]),
101
97
  hardGatesSummary:
102
- "Checks all changed files for unused imports, orphaned functions, debug artifacts, hardcoded secrets",
98
+ "Checks all changed files for dead code, production leftovers, and error paths that fail silently instead of surfacing problems",
103
99
  }),
104
100
  Object.freeze({
105
- name: "spec-checker",
101
+ name: "architecture-verifier",
106
102
  category: "parallel" as const,
107
- domain: "Requirements alignment with issue/spec context",
103
+ domain: "End-to-end connectivity, scope and intent alignment, and requirement compliance",
108
104
  catches: Object.freeze([
109
- "Missing requirements",
105
+ "Disconnected flows",
106
+ "Broken cross-layer shape alignment",
107
+ "Missing error propagation across layers",
110
108
  "Partial implementations",
111
- "Ungoverned changes",
112
- "Extra features not in spec",
113
- ]),
114
- triggerSignals: Object.freeze([
115
- "Linked GitHub issue exists",
116
- "PR description references requirements",
117
- "Changes touch feature code",
118
- ]),
119
- stackAffinity: Object.freeze(["universal"]),
120
- hardGatesSummary: "Maps each requirement to implementation status (done/partial/missing/extra)",
121
- }),
122
- Object.freeze({
123
- name: "database-auditor",
124
- category: "parallel" as const,
125
- domain: "Migrations, query performance, schema design, connection management",
126
- catches: Object.freeze([
127
- "Destructive migrations without rollback",
128
- "Missing indexes on FKs",
129
- "N+1 queries",
130
- "Raw SQL injection",
131
- "Wrong column types",
109
+ "Scope creep and unguided architectural surface area",
132
110
  ]),
133
111
  triggerSignals: Object.freeze([
134
- "Migration files in diff",
135
- "Schema changes",
136
- "ORM model changes without corresponding migrations",
137
- ]),
138
- stackAffinity: Object.freeze(["universal"]),
139
- hardGatesSummary:
140
- "Verifies rollback path, checks index coverage, detects N+1 patterns, checks for SQL injection",
141
- }),
142
- Object.freeze({
143
- name: "auth-flow-verifier",
144
- category: "parallel" as const,
145
- domain: "Auth/authz correctness, middleware guards, token handling",
146
- catches: Object.freeze([
147
- "Unprotected routes",
148
- "Privilege escalation",
149
- "Token validation gaps",
150
- "Session fixation",
151
- "Plaintext password storage",
152
- ]),
153
- triggerSignals: Object.freeze([
154
- "Changes to auth middleware",
155
- "Login/logout handlers",
156
- "Role/permission checks",
157
- "JWT/session code",
112
+ "Changes span 2+ architectural layers",
113
+ "New API endpoints",
114
+ "Requirements-driven feature work",
115
+ "New dependencies or architectural changes",
158
116
  ]),
159
117
  stackAffinity: Object.freeze(["universal"]),
160
118
  hardGatesSummary:
161
- "Traces every protected route to verify guard, checks token validation flow end-to-end",
119
+ "Traces feature paths end-to-end, maps each change to the requested scope, and flags missing or extra architectural work",
162
120
  }),
163
121
  Object.freeze({
164
- name: "type-soundness",
122
+ name: "correctness-auditor",
165
123
  category: "parallel" as const,
166
- domain: "Type correctness, invariant design, encapsulation, generics",
124
+ domain: "Type correctness, invariant design, async safety, concurrency safety",
167
125
  catches: Object.freeze([
168
126
  "Unsafe any usage",
169
127
  "Incorrect type narrowing",
170
- "Meaningless generic constraints",
171
128
  "Unsafe type assertions",
172
- "Violated invariants",
129
+ "Race conditions",
130
+ "Missing await or dropped promises",
131
+ "Missing cancellation or cleanup",
173
132
  ]),
174
133
  triggerSignals: Object.freeze([
175
134
  "New type definitions",
176
- "Complex generics",
135
+ "Complex async or concurrency code",
177
136
  "Type assertion usage",
178
- "any in diff",
137
+ "Shared mutable state",
179
138
  ]),
180
- stackAffinity: Object.freeze(["typescript", "kotlin", "rust", "go"]),
139
+ stackAffinity: Object.freeze(["universal"]),
181
140
  hardGatesSummary:
182
- "Flags every any usage, verifies type narrowing correctness, evaluates invariant enforcement",
141
+ "Flags type escape hatches, traces async and concurrent execution paths, and verifies cleanup on every code path",
183
142
  }),
184
143
  Object.freeze({
185
- name: "state-mgmt-auditor",
144
+ name: "frontend-auditor",
186
145
  category: "parallel" as const,
187
- domain: "UI state consistency, reactivity bugs, stale state, race conditions in UI",
146
+ domain: "Frontend framework rules, hooks/reactivity, state management, stale closures",
188
147
  catches: Object.freeze([
148
+ "Hooks or lifecycle rule violations",
189
149
  "Stale closures",
190
- "Infinite re-render loops",
191
- "Derived state stored instead of computed",
150
+ "Infinite re-render or reactive loops",
151
+ "Derived state anti-patterns",
152
+ "Hydration or server/client boundary mismatches",
192
153
  "Missing optimistic update rollback",
193
154
  ]),
194
155
  triggerSignals: Object.freeze([
195
- "React useState/useReducer",
196
- "Redux/Zustand/Pinia store changes",
197
- "Vue reactive state",
198
- "Svelte stores",
156
+ "React/Next.js component changes",
157
+ "Vue/Svelte/Angular reactive state changes",
158
+ "Hooks, watchers, or store updates",
199
159
  ]),
200
- stackAffinity: Object.freeze(["react", "vue", "svelte", "angular"]),
160
+ stackAffinity: Object.freeze(["react", "nextjs", "vue", "svelte", "angular"]),
201
161
  hardGatesSummary:
202
- "Traces state flow from update to render, verifies no stale closures in hooks",
162
+ "Traces state from update to render, verifies framework rule compliance, and catches stale closures and hydration risks",
203
163
  }),
204
164
  Object.freeze({
205
- name: "concurrency-checker",
165
+ name: "language-idioms-auditor",
206
166
  category: "parallel" as const,
207
- domain: "Thread/async/goroutine safety, deadlocks, resource leaks",
167
+ domain: "Go idioms, Python or Django or FastAPI patterns, and Rust safety conventions",
208
168
  catches: Object.freeze([
209
- "Goroutine leaks",
210
- "Mutex misuse",
211
- "Race conditions",
212
- "Missing context cancellation",
213
- "Missing await",
169
+ "defer-in-loop and goroutine leaks",
170
+ "Nil interface or context misuse",
171
+ "N+1 queries in templates or handlers",
172
+ "Mutable default arguments",
173
+ "Missing CSRF on cookie-based auth flows",
174
+ "Unsafe Rust blocks without justification",
175
+ "unwrap/expect in non-test Rust code",
176
+ "Send/Sync or resource lifecycle misuse",
214
177
  ]),
215
178
  triggerSignals: Object.freeze([
216
- "Goroutine creation",
217
- "Mutex/lock usage",
218
- "Async/await patterns",
219
- "Worker threads",
220
- "Promise.all usage",
179
+ "Go files in diff",
180
+ "Django/FastAPI files in diff",
181
+ "Rust files in diff",
182
+ "Language-specific framework or runtime primitives",
221
183
  ]),
222
- stackAffinity: Object.freeze(["universal"]),
184
+ stackAffinity: Object.freeze(["go", "django", "fastapi", "rust"]),
223
185
  hardGatesSummary:
224
- "Verifies every goroutine/thread has a termination path, checks lock/unlock pairs",
186
+ "Applies stack-specific correctness checks for Go, Python web frameworks, and Rust that generic reviewers often miss",
225
187
  }),
226
188
  Object.freeze({
227
189
  name: "code-quality-auditor",
@@ -245,149 +207,25 @@ export const AGENT_CATALOG: readonly AgentDefinition[] = Object.freeze([
245
207
  "Measures function length, file length, nesting depth; checks naming conventions",
246
208
  }),
247
209
  Object.freeze({
248
- name: "security-auditor",
249
- category: "parallel" as const,
250
- domain: "Systematic OWASP auditing, secrets, injection, crypto",
251
- catches: Object.freeze([
252
- "Hardcoded secrets",
253
- "SQL/NoSQL/command injection",
254
- "XSS",
255
- "CSRF gaps",
256
- "Insecure crypto",
257
- "SSRF",
258
- "Sensitive data in logs",
259
- ]),
260
- triggerSignals: Object.freeze([
261
- "User input handling",
262
- "API endpoint changes",
263
- "Database query construction",
264
- "Crypto usage",
265
- ]),
266
- stackAffinity: Object.freeze(["universal"]),
267
- hardGatesSummary: "Checks OWASP Top 10 categories systematically, scans for hardcoded secrets",
268
- }),
269
- Object.freeze({
270
- name: "scope-intent-verifier",
210
+ name: "database-auditor",
271
211
  category: "parallel" as const,
272
- domain: "Scope creep, project alignment, feature coherence",
212
+ domain: "Migrations, query performance, schema design, connection management",
273
213
  catches: Object.freeze([
274
- "Features not in any spec/issue",
275
- "Changes conflicting with project philosophy",
276
- "Unnecessary dependencies",
214
+ "Destructive migrations without rollback",
215
+ "Missing indexes on FKs",
216
+ "N+1 queries",
217
+ "Raw SQL injection",
218
+ "Wrong column types",
277
219
  ]),
278
220
  triggerSignals: Object.freeze([
279
- "New capabilities added",
280
- "New dependencies",
281
- "Changes to core architecture",
221
+ "Migration files in diff",
222
+ "Schema changes",
223
+ "ORM model changes without corresponding migrations",
282
224
  ]),
283
225
  stackAffinity: Object.freeze(["universal"]),
284
226
  hardGatesSummary:
285
- "Reads project docs to understand purpose, maps each change to a user need or spec requirement",
286
- }),
287
- Object.freeze({
288
- name: "silent-failure-hunter",
289
- category: "parallel" as const,
290
- domain: "Error handling quality, swallowed errors, empty catches, silent fallbacks",
291
- catches: Object.freeze([
292
- "Empty catch blocks",
293
- "Generic error swallowing",
294
- "Console.log-only error handling",
295
- "Optional chaining masking nulls",
296
- "Fallbacks hiding failures",
297
- ]),
298
- triggerSignals: Object.freeze([
299
- "New/modified try-catch blocks",
300
- "Error callbacks",
301
- "Fallback logic",
302
- "Default values on failure paths",
303
- ]),
304
- stackAffinity: Object.freeze(["universal"]),
305
- hardGatesSummary: "Every catch block must log with context and surface actionable feedback",
306
- }),
307
- Object.freeze({
308
- name: "react-patterns-auditor",
309
- category: "parallel" as const,
310
- domain: "React/Next.js specific bug classes",
311
- catches: Object.freeze([
312
- "Hooks rules violations",
313
- "Stale closures",
314
- "Missing useEffect deps",
315
- "Server/client boundary violations",
316
- "Hydration mismatches",
317
- ]),
318
- triggerSignals: Object.freeze([
319
- "React component files in diff",
320
- "Hooks usage",
321
- "Next.js page/layout files",
322
- ]),
323
- stackAffinity: Object.freeze(["react", "nextjs"]),
324
- hardGatesSummary:
325
- "Checks every hook call for rules compliance, verifies every useEffect deps array",
326
- }),
327
- Object.freeze({
328
- name: "go-idioms-auditor",
329
- category: "parallel" as const,
330
- domain: "Go-specific bug classes",
331
- catches: Object.freeze([
332
- "defer-in-loop",
333
- "Goroutine leaks",
334
- "Nil interface traps",
335
- "Error shadowing with :=",
336
- "Context misuse",
337
- ]),
338
- triggerSignals: Object.freeze([
339
- "Go files in diff",
340
- "Goroutine creation",
341
- "Defer statements",
342
- "Context.Context usage",
343
- ]),
344
- stackAffinity: Object.freeze(["go"]),
345
- hardGatesSummary:
346
- "Checks every defer for loop placement, every goroutine for cancellation path",
347
- }),
348
- Object.freeze({
349
- name: "python-django-auditor",
350
- category: "parallel" as const,
351
- domain: "Python/Django-specific bug classes",
352
- catches: Object.freeze([
353
- "N+1 in templates",
354
- "Unvalidated ModelForms",
355
- "Missing CSRF",
356
- "Lazy eval traps",
357
- "Mutable default args",
358
- ]),
359
- triggerSignals: Object.freeze([
360
- "Django view/model/form/template files",
361
- "Python files with ORM queries",
362
- "settings.py changes",
363
- ]),
364
- stackAffinity: Object.freeze(["django", "fastapi"]),
365
- hardGatesSummary:
366
- "Checks every queryset for select_related/prefetch_related, every ModelForm for explicit fields",
367
- }),
368
- Object.freeze({
369
- name: "rust-safety-auditor",
370
- category: "parallel" as const,
371
- domain: "Rust-specific bug classes",
372
- catches: Object.freeze([
373
- "Unjustified unsafe blocks",
374
- ".unwrap() in non-test code",
375
- "Lifetime correctness issues",
376
- "Send/Sync violations",
377
- "mem::forget misuse",
378
- ]),
379
- triggerSignals: Object.freeze([
380
- "Rust files in diff",
381
- "Unsafe blocks",
382
- ".unwrap()/.expect() calls",
383
- "Lifetime annotations",
384
- ]),
385
- stackAffinity: Object.freeze(["rust"]),
386
- hardGatesSummary:
387
- "Every unsafe block must have a SAFETY comment, every .unwrap() in non-test code is flagged",
227
+ "Verifies rollback path, checks index coverage, detects N+1 patterns, checks for SQL injection",
388
228
  }),
389
-
390
- // --- Sequenced Specialists (run after all prior findings) ---
391
229
  Object.freeze({
392
230
  name: "product-thinker",
393
231
  category: "sequenced" as const,
@@ -424,16 +262,10 @@ export const AGENT_CATALOG: readonly AgentDefinition[] = Object.freeze([
424
262
  }),
425
263
  ]);
426
264
 
427
- /**
428
- * The three core squad agents that always run regardless of stack or scoring.
429
- */
430
265
  export const CORE_SQUAD: readonly AgentDefinition[] = Object.freeze(
431
266
  AGENT_CATALOG.filter((a) => a.category === "core"),
432
267
  );
433
268
 
434
- /**
435
- * Filter agents by category.
436
- */
437
269
  export function getAgentsByCategory(category: AgentCategory): readonly AgentDefinition[] {
438
270
  return AGENT_CATALOG.filter((a) => a.category === category);
439
271
  }
@@ -0,0 +1,41 @@
1
+ import type { ReviewAgent } from "../types";
2
+
3
+ export const architectureVerifier: Readonly<ReviewAgent> = Object.freeze({
4
+ name: "architecture-verifier",
5
+ description:
6
+ "Verifies end-to-end connectivity, scope and intent alignment, and requirement compliance across architectural boundaries.",
7
+ relevantStacks: [] as readonly string[],
8
+ severityFocus: ["CRITICAL", "HIGH", "MEDIUM", "LOW"] as const,
9
+ prompt: `You are the Architecture Verifier. You verify that the change is fully wired, aligned with the intended scope, and actually satisfies the stated requirements.
10
+
11
+ ## Instructions
12
+
13
+ Check each category systematically against the changed code and the stated project context:
14
+
15
+ 1. **End-to-End Connectivity** -- Trace every changed user or system flow across boundaries: caller to callee, UI to API, API to storage, config to runtime behavior. Flag broken links, orphaned handlers, and mismatched request/response contracts.
16
+ 2. **Cross-Layer Shape Alignment** -- Verify field names, optionality, and payload shapes stay consistent across all touched layers. Flag fields that exist in one layer but are missing or renamed in another.
17
+ 3. **Error Propagation Across Layers** -- Verify backend failures, validation errors, and dependency failures propagate with actionable handling instead of disappearing between layers.
18
+ 4. **Requirement Coverage** -- Build a requirement-to-implementation map from the task, issue, diff intent, and project docs. Flag missing requirements, partial implementations, and missing acceptance-path coverage.
19
+ 5. **Scope and Intent Alignment** -- Flag user-facing features, dependencies, or architectural changes that do not map to the stated goal or that contradict the project’s documented philosophy.
20
+ 6. **Unnecessary Surface Area** -- Flag extra endpoints, handlers, or capabilities that increase maintenance cost without serving the requested outcome.
21
+
22
+ Show your trace when possible: "I traced feature X from entry point A to B to C. The chain breaks at D because ..."
23
+
24
+ Do not comment on naming or micro-style issues -- focus on architecture, connectivity, scope, and spec compliance.
25
+
26
+ ## Diff
27
+ {{DIFF}}
28
+
29
+ ## Prior Findings (for cross-verification)
30
+ {{PRIOR_FINDINGS}}
31
+
32
+ ## Project Memory (false positive suppression)
33
+ {{MEMORY}}
34
+
35
+ ## Output
36
+ For each finding, output a JSON object:
37
+ {"severity": "CRITICAL|HIGH|MEDIUM|LOW", "domain": "architecture", "title": "short title", "file": "path/to/file.ts", "line": 42, "agent": "architecture-verifier", "source": "phase1", "evidence": "what was found", "problem": "why it is an issue", "fix": "how to fix it"}
38
+
39
+ If no findings: {"findings": []}
40
+ Wrap all findings in: {"findings": [...]}`,
41
+ });
@@ -0,0 +1,40 @@
1
+ import type { ReviewAgent } from "../types";
2
+
3
+ export const codeHygieneAuditor: Readonly<ReviewAgent> = Object.freeze({
4
+ name: "code-hygiene-auditor",
5
+ description:
6
+ "Audits unused code, unreachable branches, debug artifacts, swallowed errors, empty catches, and silent fallback patterns.",
7
+ relevantStacks: [] as readonly string[],
8
+ severityFocus: ["CRITICAL", "HIGH", "MEDIUM", "LOW"] as const,
9
+ prompt: `You are the Code Hygiene Auditor. You hunt for dead code, silent failure paths, and production leftovers that make the codebase misleading or unsafe to operate.
10
+
11
+ ## Instructions
12
+
13
+ Check each category systematically in the changed code:
14
+
15
+ 1. **Unused Imports and Symbols** -- For every import statement and top-level declaration in changed files, verify at least one real usage exists. Flag imports, helpers, exports, or branches that are no longer referenced.
16
+ 2. **Orphaned and Unreachable Code** -- Flag exported functions with no consumers, impossible branches, stale feature-flag branches, and code after guaranteed return/throw paths.
17
+ 3. **TODO/FIXME/HACK Debt** -- Flag TODO, FIXME, HACK, or XXX markers in production code when they ship incomplete or misleading behavior.
18
+ 4. **Debug Artifacts and Commented-Out Code** -- Flag console.log/debugger/print leftovers, commented-out code blocks, and temporary diagnostics left in production paths.
19
+ 5. **Empty or Ineffective Catch Blocks** -- Flag catches with no action, comment-only bodies, log-only handling, or generic swallowing that allows execution to continue without recovery.
20
+ 6. **Silent Fallbacks** -- Flag fallback values, optional chaining chains, or default branches that mask broken data, failed IO, or invalid state instead of surfacing the problem.
21
+ 7. **Actionable Error Surfacing** -- Verify failures include enough context to debug and are either handled meaningfully or propagated. Flag generic error strings and fire-and-forget async calls with no failure handling.
22
+
23
+ Do not comment on styling or feature architecture -- only code hygiene, dead code, and silent failure risks.
24
+
25
+ ## Diff
26
+ {{DIFF}}
27
+
28
+ ## Prior Findings (for cross-verification)
29
+ {{PRIOR_FINDINGS}}
30
+
31
+ ## Project Memory (false positive suppression)
32
+ {{MEMORY}}
33
+
34
+ ## Output
35
+ For each finding, output a JSON object:
36
+ {"severity": "CRITICAL|HIGH|MEDIUM|LOW", "domain": "code-hygiene", "title": "short title", "file": "path/to/file.ts", "line": 42, "agent": "code-hygiene-auditor", "source": "phase1", "evidence": "what was found", "problem": "why it is an issue", "fix": "how to fix it"}
37
+
38
+ If no findings: {"findings": []}
39
+ Wrap all findings in: {"findings": [...]}`,
40
+ });
@@ -0,0 +1,41 @@
1
+ import type { ReviewAgent } from "../types";
2
+
3
+ export const correctnessAuditor: Readonly<ReviewAgent> = Object.freeze({
4
+ name: "correctness-auditor",
5
+ description:
6
+ "Audits type correctness, invariant enforcement, async correctness, concurrency safety, and resource lifecycle handling.",
7
+ relevantStacks: [] as readonly string[],
8
+ severityFocus: ["CRITICAL", "HIGH", "MEDIUM"] as const,
9
+ prompt: `You are the Correctness Auditor. You verify that the code is type-sound enough to trust, async-safe enough to run, and concurrency-safe enough to avoid subtle runtime failures.
10
+
11
+ ## Instructions
12
+
13
+ Check each category systematically in the changed code:
14
+
15
+ 1. **Type Escape Hatches** -- Flag explicit any usage, unsafe assertions, double casts, incorrect narrowing, or generic designs that erase useful guarantees.
16
+ 2. **Invariant Enforcement** -- Verify domain constraints are enforced before values are trusted. Flag casts or unchecked assumptions that let invalid state cross module boundaries.
17
+ 3. **Async Correctness** -- Flag missing await, dropped promises, unhandled Promise.all failures, and async code paths that silently ignore rejection or partial failure.
18
+ 4. **Concurrent Access Safety** -- For shared mutable state, verify synchronization, atomicity, or message-passing protection. Flag races, unsafe mutation across workers/goroutines, and unsynchronized reads/writes.
19
+ 5. **Termination and Cancellation** -- Verify long-running tasks, goroutines, workers, and async loops have termination, cleanup, timeout, or cancellation paths.
20
+ 6. **Lock and Resource Balance** -- Verify locks, handles, and disposable resources are released on every path including errors. Flag missing finally/defer cleanup and leak-prone control flow.
21
+
22
+ Show your reasoning when a guarantee is violated: explain how the type or concurrency gap becomes a runtime bug.
23
+
24
+ Do not comment on styling or product scope -- only correctness, safety, and runtime integrity.
25
+
26
+ ## Diff
27
+ {{DIFF}}
28
+
29
+ ## Prior Findings (for cross-verification)
30
+ {{PRIOR_FINDINGS}}
31
+
32
+ ## Project Memory (false positive suppression)
33
+ {{MEMORY}}
34
+
35
+ ## Output
36
+ For each finding, output a JSON object:
37
+ {"severity": "CRITICAL|HIGH|MEDIUM|LOW", "domain": "correctness", "title": "short title", "file": "path/to/file.ts", "line": 42, "agent": "correctness-auditor", "source": "phase1", "evidence": "what was found", "problem": "why it is an issue", "fix": "how to fix it"}
38
+
39
+ If no findings: {"findings": []}
40
+ Wrap all findings in: {"findings": [...]}`,
41
+ });
@@ -0,0 +1,39 @@
1
+ import type { ReviewAgent } from "../types";
2
+
3
+ export const frontendAuditor: Readonly<ReviewAgent> = Object.freeze({
4
+ name: "frontend-auditor",
5
+ description:
6
+ "Audits frontend framework correctness including hooks rules, reactive state flow, stale closures, hydration risks, and optimistic state handling.",
7
+ relevantStacks: ["react", "nextjs", "vue", "svelte", "angular"] as readonly string[],
8
+ severityFocus: ["CRITICAL", "HIGH", "MEDIUM"] as const,
9
+ prompt: `You are the Frontend Auditor. You verify that frontend framework code follows platform rules, manages state safely, and does not hide reactivity bugs that only appear at runtime.
10
+
11
+ ## Instructions
12
+
13
+ Check each category systematically in the changed UI code:
14
+
15
+ 1. **Framework Rule Compliance** -- Verify hooks/composables/reactive primitives are called in valid locations and lifecycle APIs are used according to framework rules.
16
+ 2. **Stale Closures and Dependencies** -- Trace callbacks, effects, subscriptions, and memoized handlers. Flag stale closure bugs, missing dependencies, and reactivity graphs that stop updating when state changes.
17
+ 3. **Infinite Re-render or Reactive Loops** -- Flag effects/watchers/computed blocks that write to state they immediately depend on without a guard, causing runaway updates.
18
+ 4. **Derived State and Shared Mutation** -- Flag duplicated derived state, mutation of shared state objects, and store/component boundaries that can drift out of sync.
19
+ 5. **Optimistic Update and Async UI Safety** -- Verify optimistic UI writes have rollback paths and pending async work cannot overwrite newer state with stale responses.
20
+ 6. **SSR, Hydration, and Client Boundary Safety** -- Flag server/client boundary violations, hydration mismatch risks, and rendering logic that depends on client-only data without proper guards.
21
+
22
+ Do not comment on styling preferences or API design -- only frontend correctness and state integrity.
23
+
24
+ ## Diff
25
+ {{DIFF}}
26
+
27
+ ## Prior Findings (for cross-verification)
28
+ {{PRIOR_FINDINGS}}
29
+
30
+ ## Project Memory (false positive suppression)
31
+ {{MEMORY}}
32
+
33
+ ## Output
34
+ For each finding, output a JSON object:
35
+ {"severity": "CRITICAL|HIGH|MEDIUM|LOW", "domain": "frontend", "title": "short title", "file": "path/to/file.ts", "line": 42, "agent": "frontend-auditor", "source": "phase1", "evidence": "what was found", "problem": "why it is an issue", "fix": "how to fix it"}
36
+
37
+ If no findings: {"findings": []}
38
+ Wrap all findings in: {"findings": [...]}`,
39
+ });