@prowi/deskcheck 0.1.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 (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/build/agents/executor-prompt.d.ts +10 -0
  4. package/build/agents/executor-prompt.d.ts.map +1 -0
  5. package/build/agents/executor-prompt.js +65 -0
  6. package/build/agents/executor-prompt.js.map +1 -0
  7. package/build/agents/orchestrator.d.ts +52 -0
  8. package/build/agents/orchestrator.d.ts.map +1 -0
  9. package/build/agents/orchestrator.js +343 -0
  10. package/build/agents/orchestrator.js.map +1 -0
  11. package/build/agents/planner.d.ts +28 -0
  12. package/build/agents/planner.d.ts.map +1 -0
  13. package/build/agents/planner.js +138 -0
  14. package/build/agents/planner.js.map +1 -0
  15. package/build/cli.d.ts +3 -0
  16. package/build/cli.d.ts.map +1 -0
  17. package/build/cli.js +467 -0
  18. package/build/cli.js.map +1 -0
  19. package/build/core/config.d.ts +16 -0
  20. package/build/core/config.d.ts.map +1 -0
  21. package/build/core/config.js +81 -0
  22. package/build/core/config.js.map +1 -0
  23. package/build/core/context-extractor.d.ts +17 -0
  24. package/build/core/context-extractor.d.ts.map +1 -0
  25. package/build/core/context-extractor.js +69 -0
  26. package/build/core/context-extractor.js.map +1 -0
  27. package/build/core/glob-matcher.d.ts +32 -0
  28. package/build/core/glob-matcher.d.ts.map +1 -0
  29. package/build/core/glob-matcher.js +51 -0
  30. package/build/core/glob-matcher.js.map +1 -0
  31. package/build/core/module-parser.d.ts +26 -0
  32. package/build/core/module-parser.d.ts.map +1 -0
  33. package/build/core/module-parser.js +98 -0
  34. package/build/core/module-parser.js.map +1 -0
  35. package/build/core/plan-builder.d.ts +12 -0
  36. package/build/core/plan-builder.d.ts.map +1 -0
  37. package/build/core/plan-builder.js +66 -0
  38. package/build/core/plan-builder.js.map +1 -0
  39. package/build/core/storage.d.ts +118 -0
  40. package/build/core/storage.d.ts.map +1 -0
  41. package/build/core/storage.js +590 -0
  42. package/build/core/storage.js.map +1 -0
  43. package/build/core/types.d.ts +268 -0
  44. package/build/core/types.d.ts.map +1 -0
  45. package/build/core/types.js +5 -0
  46. package/build/core/types.js.map +1 -0
  47. package/build/mcp/tools.d.ts +10 -0
  48. package/build/mcp/tools.d.ts.map +1 -0
  49. package/build/mcp/tools.js +354 -0
  50. package/build/mcp/tools.js.map +1 -0
  51. package/build/mcp-server.d.ts +3 -0
  52. package/build/mcp-server.d.ts.map +1 -0
  53. package/build/mcp-server.js +15 -0
  54. package/build/mcp-server.js.map +1 -0
  55. package/build/renderers/json.d.ts +4 -0
  56. package/build/renderers/json.d.ts.map +1 -0
  57. package/build/renderers/json.js +5 -0
  58. package/build/renderers/json.js.map +1 -0
  59. package/build/renderers/markdown.d.ts +4 -0
  60. package/build/renderers/markdown.d.ts.map +1 -0
  61. package/build/renderers/markdown.js +36 -0
  62. package/build/renderers/markdown.js.map +1 -0
  63. package/build/renderers/shared.d.ts +23 -0
  64. package/build/renderers/shared.d.ts.map +1 -0
  65. package/build/renderers/shared.js +30 -0
  66. package/build/renderers/shared.js.map +1 -0
  67. package/build/renderers/terminal.d.ts +4 -0
  68. package/build/renderers/terminal.d.ts.map +1 -0
  69. package/build/renderers/terminal.js +88 -0
  70. package/build/renderers/terminal.js.map +1 -0
  71. package/build/renderers/watch.d.ts +4 -0
  72. package/build/renderers/watch.d.ts.map +1 -0
  73. package/build/renderers/watch.js +119 -0
  74. package/build/renderers/watch.js.map +1 -0
  75. package/build/serve.d.ts +9 -0
  76. package/build/serve.d.ts.map +1 -0
  77. package/build/serve.js +249 -0
  78. package/build/serve.js.map +1 -0
  79. package/package.json +41 -0
  80. package/ui/dist/index.html +92 -0
@@ -0,0 +1,343 @@
1
+ import path from "node:path";
2
+ import { query } from "@anthropic-ai/claude-agent-sdk";
3
+ import { ReviewStorage } from "../core/storage.js";
4
+ import { extractContext } from "../core/context-extractor.js";
5
+ import { buildExecutorPrompt } from "./executor-prompt.js";
6
+ // =============================================================================
7
+ // Helpers
8
+ // =============================================================================
9
+ const VALID_SEVERITIES = new Set([
10
+ "critical",
11
+ "warning",
12
+ "info",
13
+ ]);
14
+ /**
15
+ * Parse executor output into a validated array of findings.
16
+ *
17
+ * The executor is instructed to output only a JSON array. This function
18
+ * extracts the JSON from the response text, handles cases where the agent
19
+ * wraps it in markdown fences, and validates each finding's structure.
20
+ */
21
+ function parseFindings(output) {
22
+ // Try to extract JSON array from the output
23
+ let jsonText = output.trim();
24
+ // Strip markdown code fences if present
25
+ const fencedMatch = jsonText.match(/```(?:json)?\s*\n?([\s\S]*?)\n?\s*```/);
26
+ if (fencedMatch) {
27
+ jsonText = fencedMatch[1].trim();
28
+ }
29
+ // Find the JSON array boundaries
30
+ const startIdx = jsonText.indexOf("[");
31
+ const endIdx = jsonText.lastIndexOf("]");
32
+ if (startIdx === -1 || endIdx === -1 || endIdx <= startIdx) {
33
+ console.error(`[deskcheck] Warning: executor output did not contain a JSON array. Output: ${output.slice(0, 200)}`);
34
+ return [];
35
+ }
36
+ jsonText = jsonText.slice(startIdx, endIdx + 1);
37
+ let parsed;
38
+ try {
39
+ parsed = JSON.parse(jsonText);
40
+ }
41
+ catch (error) {
42
+ console.error(`[deskcheck] Warning: failed to parse executor JSON output: ${error instanceof Error ? error.message : String(error)}. Output: ${jsonText.slice(0, 200)}`);
43
+ return [];
44
+ }
45
+ if (!Array.isArray(parsed)) {
46
+ console.error(`[deskcheck] Warning: executor output parsed but was not an array. Type: ${typeof parsed}`);
47
+ return [];
48
+ }
49
+ // Validate and normalize each finding
50
+ const findings = [];
51
+ for (const item of parsed) {
52
+ if (typeof item !== "object" || item === null) {
53
+ console.error(`[deskcheck] Warning: skipping invalid finding (not an object): ${JSON.stringify(item).slice(0, 100)}`);
54
+ continue;
55
+ }
56
+ const record = item;
57
+ const severity = String(record.severity ?? "info");
58
+ if (!VALID_SEVERITIES.has(severity)) {
59
+ console.error(`[deskcheck] Warning: skipping finding with invalid severity "${severity}"`);
60
+ continue;
61
+ }
62
+ findings.push({
63
+ severity: severity,
64
+ file: String(record.file ?? ""),
65
+ line: typeof record.line === "number" ? record.line : null,
66
+ description: String(record.description ?? ""),
67
+ suggestion: typeof record.suggestion === "string" ? record.suggestion : null,
68
+ });
69
+ }
70
+ return findings;
71
+ }
72
+ /**
73
+ * Build the merged MCP servers map for an executor agent.
74
+ *
75
+ * Combines shared MCP servers from config with any additional servers
76
+ * defined for the executor role.
77
+ */
78
+ function buildMcpServers(config) {
79
+ const servers = {};
80
+ // Add shared servers
81
+ for (const [name, serverConfig] of Object.entries(config.shared.mcp_servers)) {
82
+ servers[name] = {
83
+ type: "stdio",
84
+ command: serverConfig.command,
85
+ args: serverConfig.args,
86
+ env: serverConfig.env,
87
+ };
88
+ }
89
+ // Add executor-specific additional servers
90
+ const executorServers = config.agents.executor.additional_mcp_servers;
91
+ if (executorServers) {
92
+ for (const [name, serverConfig] of Object.entries(executorServers)) {
93
+ servers[name] = {
94
+ type: "stdio",
95
+ command: serverConfig.command,
96
+ args: serverConfig.args,
97
+ env: serverConfig.env,
98
+ };
99
+ }
100
+ }
101
+ return servers;
102
+ }
103
+ /**
104
+ * Build the merged allowed tools list for an executor agent.
105
+ *
106
+ * Combines shared tools from config with any additional tools defined
107
+ * for the executor role.
108
+ */
109
+ function buildAllowedTools(config) {
110
+ const tools = [...config.shared.allowed_tools];
111
+ const executorTools = config.agents.executor.additional_tools;
112
+ if (executorTools) {
113
+ for (const tool of executorTools) {
114
+ if (!tools.includes(tool)) {
115
+ tools.push(tool);
116
+ }
117
+ }
118
+ }
119
+ return tools;
120
+ }
121
+ // =============================================================================
122
+ // ReviewOrchestrator
123
+ // =============================================================================
124
+ /**
125
+ * Executes a review plan by dispatching tasks to executor agents via the
126
+ * Claude Agent SDK and collecting their findings.
127
+ *
128
+ * Uses an async generator to yield progress events, allowing callers to
129
+ * react to task starts, completions, errors, and overall progress in real time.
130
+ */
131
+ export class ReviewOrchestrator {
132
+ config;
133
+ projectRoot;
134
+ constructor(config, projectRoot) {
135
+ this.config = config;
136
+ this.projectRoot = projectRoot;
137
+ }
138
+ /**
139
+ * Execute all pending tasks in a plan.
140
+ *
141
+ * Runs up to `maxConcurrent` executor agents at a time using a concurrency
142
+ * pool. Each executor receives a system prompt built from the task, uses
143
+ * the Claude Agent SDK to analyze the code, and outputs findings as JSON.
144
+ */
145
+ async *execute(planId, options) {
146
+ const maxConcurrent = options?.maxConcurrent ?? 5;
147
+ const storageDir = path.resolve(this.projectRoot, this.config.storage_dir);
148
+ const storage = new ReviewStorage(storageDir);
149
+ const plan = storage.getPlan(planId);
150
+ const pendingTasks = storage.getPendingTasks(planId);
151
+ if (pendingTasks.length === 0) {
152
+ yield { type: "complete", totalFindings: 0 };
153
+ return;
154
+ }
155
+ const allowedTools = buildAllowedTools(this.config);
156
+ const mcpServers = buildMcpServers(this.config);
157
+ let completedCount = 0;
158
+ let totalFindings = 0;
159
+ const total = pendingTasks.length;
160
+ // Event queue: executor promises push events here, generator yields them
161
+ const eventQueue = [];
162
+ let resolveWaiting = null;
163
+ function pushEvent(event) {
164
+ eventQueue.push(event);
165
+ if (resolveWaiting) {
166
+ resolveWaiting();
167
+ resolveWaiting = null;
168
+ }
169
+ }
170
+ /** Run a single executor agent for a task. */
171
+ const runExecutor = async (task) => {
172
+ const modelId = task.model;
173
+ pushEvent({
174
+ type: "task_started",
175
+ taskId: task.task_id,
176
+ reviewId: task.review_id,
177
+ model: modelId,
178
+ files: task.files,
179
+ });
180
+ let taskUsage = null;
181
+ try {
182
+ // Extract context and claim the task
183
+ const extracted = extractContext(plan.source.type, plan.source.target, task.files, this.projectRoot, task.symbol ?? undefined);
184
+ // Read the criterion prompt from the module file
185
+ const modulePrompt = task.prompt ?? plan.modules[task.review_id]?.description ?? "";
186
+ // Claim the task in storage (sets status to in_progress, fills context)
187
+ storage.claimTask(planId, task.task_id, {
188
+ contextType: extracted.contextType,
189
+ content: extracted.content,
190
+ symbol: extracted.symbol ?? undefined,
191
+ prompt: modulePrompt,
192
+ });
193
+ // Re-read the task with filled context for prompt building
194
+ const claimedPlan = storage.getPlan(planId);
195
+ const claimedTask = claimedPlan.tasks[task.task_id];
196
+ // Build the executor prompt
197
+ const executorPrompt = buildExecutorPrompt(claimedTask);
198
+ // Spawn executor agent via Claude Agent SDK with a 5-minute timeout
199
+ const abortController = new AbortController();
200
+ const timeout = setTimeout(() => abortController.abort(), 5 * 60 * 1000);
201
+ let resultText = "";
202
+ try {
203
+ for await (const message of query({
204
+ prompt: executorPrompt,
205
+ options: {
206
+ model: modelId,
207
+ tools: allowedTools,
208
+ permissionMode: "dontAsk",
209
+ maxTurns: 25,
210
+ cwd: this.projectRoot,
211
+ persistSession: false,
212
+ abortController,
213
+ ...(Object.keys(mcpServers).length > 0 ? { mcpServers } : {}),
214
+ },
215
+ })) {
216
+ if (message.type === "result") {
217
+ // Capture usage data from result (available on both success and error)
218
+ const msg = message;
219
+ const usage = msg.usage;
220
+ taskUsage = {
221
+ input_tokens: usage?.input_tokens ?? 0,
222
+ output_tokens: usage?.output_tokens ?? 0,
223
+ cache_read_tokens: usage?.cache_read_input_tokens ?? 0,
224
+ cache_creation_tokens: usage?.cache_creation_input_tokens ?? 0,
225
+ cost_usd: msg.total_cost_usd ?? 0,
226
+ duration_ms: msg.duration_ms ?? 0,
227
+ duration_api_ms: msg.duration_api_ms ?? 0,
228
+ num_turns: msg.num_turns ?? 0,
229
+ model: modelId,
230
+ };
231
+ if (message.subtype === "success") {
232
+ resultText = message.result;
233
+ }
234
+ else {
235
+ throw new Error(`Executor failed: ${message.errors.join(", ")}`);
236
+ }
237
+ }
238
+ }
239
+ }
240
+ finally {
241
+ clearTimeout(timeout);
242
+ }
243
+ // Parse findings from executor output
244
+ const findings = parseFindings(resultText);
245
+ // Complete the task in storage
246
+ storage.completeTask(planId, task.task_id, findings, taskUsage);
247
+ completedCount++;
248
+ totalFindings += findings.length;
249
+ pushEvent({
250
+ type: "task_completed",
251
+ taskId: task.task_id,
252
+ reviewId: task.review_id,
253
+ files: task.files,
254
+ findingCount: findings.length,
255
+ usage: taskUsage,
256
+ });
257
+ pushEvent({
258
+ type: "batch_progress",
259
+ completed: completedCount,
260
+ total,
261
+ });
262
+ }
263
+ catch (error) {
264
+ completedCount++;
265
+ // Mark the task as errored (preserves the distinction from "complete with 0 findings")
266
+ try {
267
+ storage.errorTask(planId, task.task_id, error instanceof Error ? error.message : String(error), taskUsage);
268
+ }
269
+ catch {
270
+ // Storage error on top of executor error — just report
271
+ }
272
+ pushEvent({
273
+ type: "task_error",
274
+ taskId: task.task_id,
275
+ reviewId: task.review_id,
276
+ files: task.files,
277
+ error: error instanceof Error ? error.message : String(error),
278
+ });
279
+ pushEvent({
280
+ type: "batch_progress",
281
+ completed: completedCount,
282
+ total,
283
+ });
284
+ }
285
+ };
286
+ // Concurrency pool
287
+ const pool = [];
288
+ let taskIndex = 0;
289
+ // Start initial batch
290
+ while (taskIndex < pendingTasks.length && pool.length < maxConcurrent) {
291
+ const task = pendingTasks[taskIndex];
292
+ taskIndex++;
293
+ const p = runExecutor(task).then(() => {
294
+ pool.splice(pool.indexOf(p), 1);
295
+ });
296
+ pool.push(p);
297
+ }
298
+ // Process events and spawn new tasks as slots free up
299
+ while (completedCount < total) {
300
+ // Yield any queued events
301
+ while (eventQueue.length > 0) {
302
+ yield eventQueue.shift();
303
+ }
304
+ // If still tasks to process, wait for a slot to free up
305
+ if (pool.length > 0) {
306
+ await new Promise((resolve) => {
307
+ resolveWaiting = resolve;
308
+ // Also resolve when a pool item completes (in case no events are pushed)
309
+ if (eventQueue.length > 0) {
310
+ resolve();
311
+ resolveWaiting = null;
312
+ }
313
+ else {
314
+ // Set a timeout to check periodically (prevents deadlock)
315
+ const interval = setInterval(() => {
316
+ if (eventQueue.length > 0 || completedCount >= total) {
317
+ clearInterval(interval);
318
+ resolve();
319
+ resolveWaiting = null;
320
+ }
321
+ }, 100);
322
+ }
323
+ });
324
+ // Spawn more tasks if slots available
325
+ while (taskIndex < pendingTasks.length && pool.length < maxConcurrent) {
326
+ const task = pendingTasks[taskIndex];
327
+ taskIndex++;
328
+ const p = runExecutor(task).then(() => {
329
+ pool.splice(pool.indexOf(p), 1);
330
+ });
331
+ pool.push(p);
332
+ }
333
+ }
334
+ }
335
+ // Yield any remaining events
336
+ while (eventQueue.length > 0) {
337
+ yield eventQueue.shift();
338
+ }
339
+ // Final completion event
340
+ yield { type: "complete", totalFindings };
341
+ }
342
+ }
343
+ //# sourceMappingURL=orchestrator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrator.js","sourceRoot":"","sources":["../../src/agents/orchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAqB3D,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAkB;IACrE,UAAU;IACV,SAAS;IACT,MAAM;CACP,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,MAAc;IACnC,4CAA4C;IAC5C,IAAI,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAE7B,wCAAwC;IACxC,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC5E,IAAI,WAAW,EAAE,CAAC;QAChB,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED,iCAAiC;IACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,QAAQ,CAA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viewConfig, ReviewPlan } from "../core/types.js";
2
+ /**
3
+ * Plans review tasks by delegating intent detection to an Agent SDK agent.
4
+ *
5
+ * Instead of parsing user intent with regex heuristics, the planner spawns
6
+ * a Claude agent that has access to git, the filesystem, and review planning
7
+ * tools. The agent interprets what the user wants to review and creates the
8
+ * plan accordingly.
9
+ */
10
+ export declare class ReviewPlanner {
11
+ private readonly config;
12
+ private readonly projectRoot;
13
+ constructor(config: ReviewConfig, projectRoot: string);
14
+ /**
15
+ * Create a review plan from natural language input.
16
+ *
17
+ * Spawns a planner agent that:
18
+ * 1. Interprets the user's intent (what files/branch/symbol to review)
19
+ * 2. Uses git/filesystem to get the list of files
20
+ * 3. Calls the planning MCP tools to create the plan
21
+ *
22
+ * The planner agent has access to an in-process MCP server with tools
23
+ * for creating plans and tasks, plus standard git/read tools for
24
+ * discovering what to review.
25
+ */
26
+ plan(input: string): Promise<ReviewPlan>;
27
+ }
28
+ //# sourceMappingURL=planner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.d.ts","sourceRoot":"","sources":["../../src/agents/planner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEjE;;;;;;;GAOG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;gBAEzB,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM;IAKrD;;;;;;;;;;;OAWG;IACG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CAwH/C"}
@@ -0,0 +1,138 @@
1
+ import path from "node:path";
2
+ import { query } from "@anthropic-ai/claude-agent-sdk";
3
+ import { z } from "zod";
4
+ import { createSdkMcpServer, tool } from "@anthropic-ai/claude-agent-sdk";
5
+ import { discoverModules } from "../core/module-parser.js";
6
+ import { buildPlanWithTasks } from "../core/plan-builder.js";
7
+ import { ReviewStorage } from "../core/storage.js";
8
+ /**
9
+ * Plans review tasks by delegating intent detection to an Agent SDK agent.
10
+ *
11
+ * Instead of parsing user intent with regex heuristics, the planner spawns
12
+ * a Claude agent that has access to git, the filesystem, and review planning
13
+ * tools. The agent interprets what the user wants to review and creates the
14
+ * plan accordingly.
15
+ */
16
+ export class ReviewPlanner {
17
+ config;
18
+ projectRoot;
19
+ constructor(config, projectRoot) {
20
+ this.config = config;
21
+ this.projectRoot = projectRoot;
22
+ }
23
+ /**
24
+ * Create a review plan from natural language input.
25
+ *
26
+ * Spawns a planner agent that:
27
+ * 1. Interprets the user's intent (what files/branch/symbol to review)
28
+ * 2. Uses git/filesystem to get the list of files
29
+ * 3. Calls the planning MCP tools to create the plan
30
+ *
31
+ * The planner agent has access to an in-process MCP server with tools
32
+ * for creating plans and tasks, plus standard git/read tools for
33
+ * discovering what to review.
34
+ */
35
+ async plan(input) {
36
+ const storageDir = path.resolve(this.projectRoot, this.config.storage_dir);
37
+ const storage = new ReviewStorage(storageDir);
38
+ const modulesDir = path.resolve(this.projectRoot, this.config.modules_dir);
39
+ const modules = discoverModules(modulesDir);
40
+ // Build the module summary for the agent's context
41
+ const moduleDescriptions = modules.map((m) => `- ${m.id} (severity: ${m.severity}, model: ${m.model})\n Globs: ${m.globs.join(", ")}\n Mode: ${m.mode}`).join("\n");
42
+ // Track the plan ID created by the agent
43
+ let createdPlanId = null;
44
+ // Create an in-process MCP server with planning tools
45
+ const plannerServer = createSdkMcpServer({
46
+ name: "deskcheck-planner",
47
+ version: "0.1.0",
48
+ tools: [
49
+ tool("create_plan", "Create a review plan and tasks. Call this once you know what files to review.", {
50
+ name: z.string().describe("Human-readable name for this review, e.g. 'changes against develop' or 'full review: Commission.php'"),
51
+ source_type: z.enum(["diff", "file", "symbol"]).describe("Type of review: diff (branch comparison), file (full file), symbol (specific function/method)"),
52
+ source_target: z.string().describe("The target: branch name for diff, file path for file, symbol name for symbol"),
53
+ source_file: z.string().optional().describe("For symbol mode only: the file containing the symbol"),
54
+ files: z.array(z.string()).describe("List of file paths to review"),
55
+ }, async (args) => {
56
+ const source = {
57
+ type: args.source_type,
58
+ target: args.source_target,
59
+ ...(args.source_file ? { file: args.source_file } : {}),
60
+ };
61
+ const finalPlan = buildPlanWithTasks(storage, args.name, source, args.files, modules);
62
+ createdPlanId = finalPlan.plan_id;
63
+ const taskCount = Object.keys(finalPlan.tasks).length;
64
+ const moduleCount = Object.keys(finalPlan.modules).length;
65
+ return {
66
+ content: [{
67
+ type: "text",
68
+ text: `Plan created: ${finalPlan.plan_id}\n${taskCount} tasks across ${moduleCount} modules\n${finalPlan.matched_files.length} files matched, ${finalPlan.unmatched_files.length} not covered`,
69
+ }],
70
+ };
71
+ }),
72
+ ],
73
+ });
74
+ // Build planner model — use short names (haiku/sonnet/opus)
75
+ // The Agent SDK resolves these to full model IDs internally
76
+ const plannerModel = this.config.agents.planner.model ?? "haiku";
77
+ const systemPrompt = `You are a deskcheck planner. The user will tell you what they want to check. Your job is to figure out which files are involved and call the create_plan tool.
78
+
79
+ ## Available Criteria
80
+
81
+ ${moduleDescriptions}
82
+
83
+ ## How to Determine Files
84
+
85
+ - If the user mentions a **directory** (e.g., "everything in app/Services/"): use Bash to list all files recursively: \`find <path> -type f -name "*.php" -o -name "*.ts" -o -name "*.vue"\` or similar. Then pass ALL those file paths to create_plan.
86
+ - If the user mentions a **branch** or "changes" or "diff": run \`git diff <branch> --name-only\` to get changed files.
87
+ - If the user mentions a **specific file**: use that file path directly.
88
+ - If the user mentions a **function/method name** and a file: use the file path, set source_type to "symbol".
89
+ - If the user is vague: use Bash to explore the filesystem and figure out what files are relevant.
90
+
91
+ ## What to Do
92
+
93
+ 1. Figure out which files to check (use Bash to run commands like find, ls, git diff)
94
+ 2. Call the create_plan tool with the file list and appropriate source type (use "file" for directory/file reviews, "diff" for branch comparisons)
95
+ 3. Report what you created
96
+
97
+ You MUST call the create_plan tool. Do NOT review code yourself. Your only job is to determine the file list and call create_plan.`;
98
+ // Spawn the planner agent with a 5-minute timeout
99
+ const abortController = new AbortController();
100
+ const timeout = setTimeout(() => abortController.abort(), 5 * 60 * 1000);
101
+ try {
102
+ for await (const message of query({
103
+ prompt: input,
104
+ options: {
105
+ model: plannerModel,
106
+ systemPrompt,
107
+ tools: [
108
+ "Bash",
109
+ "Read",
110
+ "Glob",
111
+ "Grep",
112
+ "mcp__deskcheck-planner__*",
113
+ ],
114
+ permissionMode: "bypassPermissions",
115
+ maxTurns: 15,
116
+ cwd: this.projectRoot,
117
+ persistSession: false,
118
+ abortController,
119
+ mcpServers: {
120
+ "deskcheck-planner": plannerServer,
121
+ },
122
+ },
123
+ })) {
124
+ if (message.type === "result" && message.subtype !== "success") {
125
+ throw new Error(`Planner agent failed: ${JSON.stringify(message)}`);
126
+ }
127
+ }
128
+ }
129
+ finally {
130
+ clearTimeout(timeout);
131
+ }
132
+ if (!createdPlanId) {
133
+ throw new Error("Planner agent did not create a plan. It may not have understood the request.");
134
+ }
135
+ return storage.getPlan(createdPlanId);
136
+ }
137
+ }
138
+ //# sourceMappingURL=planner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planner.js","sourceRoot":"","sources":["../../src/agents/planner.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IACP,MAAM,CAAe;IACrB,WAAW,CAAS;IAErC,YAAY,MA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AC,aAAa,CAAC,CAAC;IACxC,CAAC;CACF"}
package/build/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}