@lumenflow/mcp 2.18.3 → 2.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.
- package/dist/tools/agent-tools.d.ts +26 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +161 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/context-tools.d.ts +19 -0
- package/dist/tools/context-tools.d.ts.map +1 -0
- package/dist/tools/context-tools.js +73 -0
- package/dist/tools/context-tools.js.map +1 -0
- package/dist/tools/flow-tools.d.ts +30 -0
- package/dist/tools/flow-tools.d.ts.map +1 -0
- package/dist/tools/flow-tools.js +141 -0
- package/dist/tools/flow-tools.js.map +1 -0
- package/dist/tools/initiative-tools.d.ts +42 -0
- package/dist/tools/initiative-tools.d.ts.map +1 -0
- package/dist/tools/initiative-tools.js +304 -0
- package/dist/tools/initiative-tools.js.map +1 -0
- package/dist/tools/memory-tools.d.ts +66 -0
- package/dist/tools/memory-tools.d.ts.map +1 -0
- package/dist/tools/memory-tools.js +419 -0
- package/dist/tools/memory-tools.js.map +1 -0
- package/dist/tools/orchestration-tools.d.ts +26 -0
- package/dist/tools/orchestration-tools.d.ts.map +1 -0
- package/dist/tools/orchestration-tools.js +158 -0
- package/dist/tools/orchestration-tools.js.map +1 -0
- package/dist/tools/parity-tools.d.ts +118 -0
- package/dist/tools/parity-tools.d.ts.map +1 -0
- package/dist/tools/parity-tools.js +897 -0
- package/dist/tools/parity-tools.js.map +1 -0
- package/dist/tools/setup-tools.d.ts +42 -0
- package/dist/tools/setup-tools.d.ts.map +1 -0
- package/dist/tools/setup-tools.js +167 -0
- package/dist/tools/setup-tools.js.map +1 -0
- package/dist/tools/validation-tools.d.ts +34 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +134 -0
- package/dist/tools/validation-tools.js.map +1 -0
- package/dist/tools/wu-tools.d.ts +116 -0
- package/dist/tools/wu-tools.d.ts.map +1 -0
- package/dist/tools/wu-tools.js +711 -0
- package/dist/tools/wu-tools.js.map +1 -0
- package/dist/tools-shared.d.ts +170 -0
- package/dist/tools-shared.d.ts.map +1 -0
- package/dist/tools-shared.js +203 -0
- package/dist/tools-shared.js.map +1 -0
- package/dist/tools.d.ts +34 -466
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +54 -3323
- package/dist/tools.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file wu-tools.ts
|
|
3
|
+
* @description WU lifecycle tool implementations (create, claim, done, block, edit, etc.)
|
|
4
|
+
*
|
|
5
|
+
* WU-1642: Extracted from tools.ts during domain decomposition.
|
|
6
|
+
* WU-1412: Core WU tools: wu_status, wu_create, wu_claim, wu_done, gates_run
|
|
7
|
+
* WU-1422: Additional WU tools
|
|
8
|
+
* WU-1431: Uses shared Zod schemas from @lumenflow/core for CLI/MCP parity
|
|
9
|
+
* WU-1454: All 16 WU lifecycle commands now use shared schemas
|
|
10
|
+
*/
|
|
11
|
+
import { z } from 'zod';
|
|
12
|
+
import { wuCreateSchema, wuClaimSchema, wuStatusSchema, wuDoneSchema, gatesSchema,
|
|
13
|
+
// WU-1454: Lifecycle command schemas
|
|
14
|
+
wuBlockSchema, wuUnblockSchema, wuEditSchema, wuReleaseSchema, wuRecoverSchema, wuRepairSchema, wuDepsSchema, wuPrepSchema, wuPreflightSchema, wuPruneSchema, wuDeleteSchema, wuCleanupSchema, wuSpawnSchema, wuValidateSchema, wuInferLaneSchema, wuUnlockLaneSchema, } from '@lumenflow/core';
|
|
15
|
+
import { ErrorCodes, ErrorMessages, CliArgs, SuccessMessages, getCore, success, error, buildWuPromptArgs, runCliCommand, } from '../tools-shared.js';
|
|
16
|
+
/**
|
|
17
|
+
* wu_status - Get status of a specific WU
|
|
18
|
+
* Uses CLI shell-out for consistency
|
|
19
|
+
*
|
|
20
|
+
* WU-1431: Uses shared wuStatusSchema for parity with CLI
|
|
21
|
+
* Note: CLI allows id to be optional (auto-detect from worktree), but MCP requires it
|
|
22
|
+
* since there's no "current directory" concept for MCP clients
|
|
23
|
+
*/
|
|
24
|
+
export const wuStatusTool = {
|
|
25
|
+
name: 'wu_status',
|
|
26
|
+
description: 'Get detailed status of a specific Work Unit',
|
|
27
|
+
// WU-1431: Extend shared schema to require id for MCP (CLI allows optional for auto-detect)
|
|
28
|
+
inputSchema: wuStatusSchema.extend({
|
|
29
|
+
id: z.string().describe('WU ID (e.g., WU-1412)'),
|
|
30
|
+
}),
|
|
31
|
+
async execute(input, options) {
|
|
32
|
+
if (!input.id) {
|
|
33
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
34
|
+
}
|
|
35
|
+
const args = ['--id', input.id, '--json'];
|
|
36
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
37
|
+
const result = await runCliCommand('wu:status', args, cliOptions);
|
|
38
|
+
if (result.success) {
|
|
39
|
+
try {
|
|
40
|
+
const data = JSON.parse(result.stdout);
|
|
41
|
+
return success(data);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return success({ message: result.stdout });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return error(result.stderr || result.error?.message || 'wu:status failed', ErrorCodes.WU_STATUS_ERROR);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* wu_create - Create a new WU
|
|
54
|
+
*
|
|
55
|
+
* WU-1431: Uses shared wuCreateSchema for CLI/MCP parity
|
|
56
|
+
*/
|
|
57
|
+
export const wuCreateTool = {
|
|
58
|
+
name: 'wu_create',
|
|
59
|
+
description: 'Create a new Work Unit specification',
|
|
60
|
+
// WU-1431: Use shared schema - CLI-only aliases are not exposed here
|
|
61
|
+
inputSchema: wuCreateSchema,
|
|
62
|
+
async execute(input, options) {
|
|
63
|
+
if (!input.lane) {
|
|
64
|
+
return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
65
|
+
}
|
|
66
|
+
if (!input.title) {
|
|
67
|
+
return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
68
|
+
}
|
|
69
|
+
const args = ['--lane', input.lane, '--title', input.title];
|
|
70
|
+
if (input.id)
|
|
71
|
+
args.push('--id', input.id);
|
|
72
|
+
if (input.description)
|
|
73
|
+
args.push(CliArgs.DESCRIPTION, input.description);
|
|
74
|
+
if (input.acceptance) {
|
|
75
|
+
for (const criterion of input.acceptance) {
|
|
76
|
+
args.push('--acceptance', criterion);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (input.code_paths) {
|
|
80
|
+
for (const p of input.code_paths) {
|
|
81
|
+
args.push(CliArgs.CODE_PATHS, p);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (input.exposure)
|
|
85
|
+
args.push('--exposure', input.exposure);
|
|
86
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
87
|
+
const result = await runCliCommand('wu:create', args, cliOptions);
|
|
88
|
+
if (result.success) {
|
|
89
|
+
return success({ message: result.stdout || 'WU created successfully' });
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return error(result.stderr || result.error?.message || 'wu:create failed', ErrorCodes.WU_CREATE_ERROR);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* wu_claim - Claim a WU and create worktree
|
|
98
|
+
*
|
|
99
|
+
* WU-1431: Uses shared wuClaimSchema for CLI/MCP parity
|
|
100
|
+
* WU-1491: Supports --cloud, --branch-only, and --pr-mode passthrough
|
|
101
|
+
*/
|
|
102
|
+
export const wuClaimTool = {
|
|
103
|
+
name: 'wu_claim',
|
|
104
|
+
description: 'Claim a Work Unit and create worktree for implementation',
|
|
105
|
+
// WU-1431: Use shared schema
|
|
106
|
+
inputSchema: wuClaimSchema,
|
|
107
|
+
async execute(input, options) {
|
|
108
|
+
if (!input.id) {
|
|
109
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
110
|
+
}
|
|
111
|
+
if (!input.lane) {
|
|
112
|
+
return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
113
|
+
}
|
|
114
|
+
const args = ['--id', input.id, '--lane', input.lane];
|
|
115
|
+
// WU-1491: Pass mode flags through to CLI
|
|
116
|
+
if (input.cloud)
|
|
117
|
+
args.push('--cloud');
|
|
118
|
+
if (input.branch_only)
|
|
119
|
+
args.push('--branch-only');
|
|
120
|
+
if (input.pr_mode)
|
|
121
|
+
args.push('--pr-mode');
|
|
122
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
123
|
+
const result = await runCliCommand('wu:claim', args, cliOptions);
|
|
124
|
+
if (result.success) {
|
|
125
|
+
return success({ message: result.stdout || 'WU claimed successfully' });
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return error(result.stderr || result.error?.message || 'wu:claim failed', ErrorCodes.WU_CLAIM_ERROR);
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* wu_done - Complete a WU (must be run from main checkout)
|
|
134
|
+
*
|
|
135
|
+
* WU-1431: Uses shared wuDoneSchema for CLI/MCP parity
|
|
136
|
+
*/
|
|
137
|
+
export const wuDoneTool = {
|
|
138
|
+
name: 'wu_done',
|
|
139
|
+
description: 'Complete a Work Unit (merge, stamp, cleanup). MUST be run from main checkout.',
|
|
140
|
+
// WU-1431: Use shared schema
|
|
141
|
+
inputSchema: wuDoneSchema,
|
|
142
|
+
async execute(input, options) {
|
|
143
|
+
if (!input.id) {
|
|
144
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
145
|
+
}
|
|
146
|
+
// Fail fast if not on main checkout (AC: wu_done fails fast if not on main checkout)
|
|
147
|
+
try {
|
|
148
|
+
const core = await getCore();
|
|
149
|
+
const context = await core.computeWuContext({
|
|
150
|
+
cwd: options?.projectRoot,
|
|
151
|
+
});
|
|
152
|
+
if (context.location.type === 'worktree') {
|
|
153
|
+
return error('wu_done must be run from main checkout, not from a worktree. ' +
|
|
154
|
+
'Run "pnpm wu:prep" first from the worktree, then cd to main and run wu:done.', ErrorCodes.WRONG_LOCATION);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// If we can't determine context, proceed anyway - CLI will validate
|
|
159
|
+
}
|
|
160
|
+
const args = ['--id', input.id];
|
|
161
|
+
if (input.skip_gates) {
|
|
162
|
+
args.push('--skip-gates');
|
|
163
|
+
if (input.reason)
|
|
164
|
+
args.push('--reason', input.reason);
|
|
165
|
+
if (input.fix_wu)
|
|
166
|
+
args.push('--fix-wu', input.fix_wu);
|
|
167
|
+
}
|
|
168
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
169
|
+
const result = await runCliCommand('wu:done', args, cliOptions);
|
|
170
|
+
if (result.success) {
|
|
171
|
+
return success({ message: result.stdout || 'WU completed successfully' });
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return error(result.stderr || result.error?.message || 'wu:done failed', ErrorCodes.WU_DONE_ERROR);
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* gates_run - Run quality gates
|
|
180
|
+
*
|
|
181
|
+
* WU-1431: Uses shared gatesSchema for CLI/MCP parity
|
|
182
|
+
*/
|
|
183
|
+
export const gatesRunTool = {
|
|
184
|
+
name: 'gates_run',
|
|
185
|
+
description: 'Run LumenFlow quality gates (lint, typecheck, tests)',
|
|
186
|
+
// WU-1431: Use shared schema
|
|
187
|
+
inputSchema: gatesSchema,
|
|
188
|
+
async execute(input, options) {
|
|
189
|
+
const args = [];
|
|
190
|
+
if (input.docs_only) {
|
|
191
|
+
args.push(CliArgs.DOCS_ONLY);
|
|
192
|
+
}
|
|
193
|
+
const cliOptions = {
|
|
194
|
+
projectRoot: options?.projectRoot,
|
|
195
|
+
timeout: 600000, // 10 minutes for gates
|
|
196
|
+
};
|
|
197
|
+
const result = await runCliCommand('gates', args, cliOptions);
|
|
198
|
+
if (result.success) {
|
|
199
|
+
return success({ message: result.stdout || SuccessMessages.ALL_GATES_PASSED });
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return error(result.stderr || result.error?.message || 'Gates failed', ErrorCodes.GATES_ERROR);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* wu_block - Block a WU and move it to blocked status
|
|
208
|
+
*/
|
|
209
|
+
export const wuBlockTool = {
|
|
210
|
+
name: 'wu_block',
|
|
211
|
+
description: 'Block a Work Unit and move it from in_progress to blocked status',
|
|
212
|
+
// WU-1454: Use shared schema
|
|
213
|
+
inputSchema: wuBlockSchema,
|
|
214
|
+
async execute(input, options) {
|
|
215
|
+
if (!input.id) {
|
|
216
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
217
|
+
}
|
|
218
|
+
if (!input.reason) {
|
|
219
|
+
return error(ErrorMessages.REASON_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
220
|
+
}
|
|
221
|
+
const args = ['--id', input.id, '--reason', input.reason];
|
|
222
|
+
if (input.remove_worktree) {
|
|
223
|
+
args.push('--remove-worktree');
|
|
224
|
+
}
|
|
225
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
226
|
+
const result = await runCliCommand('wu:block', args, cliOptions);
|
|
227
|
+
if (result.success) {
|
|
228
|
+
return success({ message: result.stdout || 'WU blocked successfully' });
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
return error(result.stderr || result.error?.message || 'wu:block failed', ErrorCodes.WU_BLOCK_ERROR);
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
/**
|
|
236
|
+
* wu_unblock - Unblock a WU and move it back to in_progress status
|
|
237
|
+
*/
|
|
238
|
+
export const wuUnblockTool = {
|
|
239
|
+
name: 'wu_unblock',
|
|
240
|
+
description: 'Unblock a Work Unit and move it from blocked to in_progress status',
|
|
241
|
+
// WU-1454: Use shared schema
|
|
242
|
+
inputSchema: wuUnblockSchema,
|
|
243
|
+
async execute(input, options) {
|
|
244
|
+
if (!input.id) {
|
|
245
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
246
|
+
}
|
|
247
|
+
const args = ['--id', input.id];
|
|
248
|
+
if (input.reason)
|
|
249
|
+
args.push('--reason', input.reason);
|
|
250
|
+
if (input.create_worktree)
|
|
251
|
+
args.push('--create-worktree');
|
|
252
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
253
|
+
const result = await runCliCommand('wu:unblock', args, cliOptions);
|
|
254
|
+
if (result.success) {
|
|
255
|
+
return success({ message: result.stdout || 'WU unblocked successfully' });
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
return error(result.stderr || result.error?.message || 'wu:unblock failed', ErrorCodes.WU_UNBLOCK_ERROR);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
/**
|
|
263
|
+
* wu_edit - Edit WU spec fields
|
|
264
|
+
*/
|
|
265
|
+
export const wuEditTool = {
|
|
266
|
+
name: 'wu_edit',
|
|
267
|
+
description: 'Edit Work Unit spec fields with micro-worktree isolation',
|
|
268
|
+
// WU-1454: Use shared schema
|
|
269
|
+
inputSchema: wuEditSchema,
|
|
270
|
+
async execute(input, options) {
|
|
271
|
+
if (!input.id) {
|
|
272
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
273
|
+
}
|
|
274
|
+
const args = ['--id', input.id];
|
|
275
|
+
if (input.description)
|
|
276
|
+
args.push(CliArgs.DESCRIPTION, input.description);
|
|
277
|
+
if (input.acceptance) {
|
|
278
|
+
for (const criterion of input.acceptance) {
|
|
279
|
+
args.push('--acceptance', criterion);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (input.notes)
|
|
283
|
+
args.push('--notes', input.notes);
|
|
284
|
+
if (input.code_paths) {
|
|
285
|
+
for (const p of input.code_paths) {
|
|
286
|
+
args.push(CliArgs.CODE_PATHS, p);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (input.lane)
|
|
290
|
+
args.push('--lane', input.lane);
|
|
291
|
+
if (input.priority)
|
|
292
|
+
args.push('--priority', input.priority);
|
|
293
|
+
if (input.initiative)
|
|
294
|
+
args.push(CliArgs.INITIATIVE, input.initiative);
|
|
295
|
+
if (input.phase)
|
|
296
|
+
args.push(CliArgs.PHASE, String(input.phase));
|
|
297
|
+
if (input.no_strict)
|
|
298
|
+
args.push('--no-strict');
|
|
299
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
300
|
+
const result = await runCliCommand('wu:edit', args, cliOptions);
|
|
301
|
+
if (result.success) {
|
|
302
|
+
return success({ message: result.stdout || 'WU edited successfully' });
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return error(result.stderr || result.error?.message || 'wu:edit failed', ErrorCodes.WU_EDIT_ERROR);
|
|
306
|
+
}
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
/**
|
|
310
|
+
* wu_release - Release an orphaned WU from in_progress to ready status
|
|
311
|
+
*/
|
|
312
|
+
export const wuReleaseTool = {
|
|
313
|
+
name: 'wu_release',
|
|
314
|
+
description: 'Release an orphaned WU from in_progress back to ready state for reclaiming',
|
|
315
|
+
// WU-1454: Use shared schema
|
|
316
|
+
inputSchema: wuReleaseSchema,
|
|
317
|
+
async execute(input, options) {
|
|
318
|
+
if (!input.id) {
|
|
319
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
320
|
+
}
|
|
321
|
+
const args = ['--id', input.id];
|
|
322
|
+
if (input.reason)
|
|
323
|
+
args.push('--reason', input.reason);
|
|
324
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
325
|
+
const result = await runCliCommand('wu:release', args, cliOptions);
|
|
326
|
+
if (result.success) {
|
|
327
|
+
return success({ message: result.stdout || 'WU released successfully' });
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
return error(result.stderr || result.error?.message || 'wu:release failed', ErrorCodes.WU_RELEASE_ERROR);
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* wu_recover - Analyze and fix WU state inconsistencies
|
|
336
|
+
*/
|
|
337
|
+
export const wuRecoverTool = {
|
|
338
|
+
name: 'wu_recover',
|
|
339
|
+
description: 'Analyze and fix WU state inconsistencies',
|
|
340
|
+
// WU-1454: Use shared schema
|
|
341
|
+
inputSchema: wuRecoverSchema,
|
|
342
|
+
async execute(input, options) {
|
|
343
|
+
if (!input.id) {
|
|
344
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
345
|
+
}
|
|
346
|
+
const args = ['--id', input.id];
|
|
347
|
+
if (input.action)
|
|
348
|
+
args.push('--action', input.action);
|
|
349
|
+
if (input.force)
|
|
350
|
+
args.push('--force');
|
|
351
|
+
if (input.json)
|
|
352
|
+
args.push(CliArgs.JSON);
|
|
353
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
354
|
+
const result = await runCliCommand('wu:recover', args, cliOptions);
|
|
355
|
+
if (result.success) {
|
|
356
|
+
try {
|
|
357
|
+
const data = JSON.parse(result.stdout);
|
|
358
|
+
return success(data);
|
|
359
|
+
}
|
|
360
|
+
catch {
|
|
361
|
+
return success({ message: result.stdout || 'WU recovered successfully' });
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
return error(result.stderr || result.error?.message || 'wu:recover failed', ErrorCodes.WU_RECOVER_ERROR);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* wu_repair - Unified WU repair tool for state issues
|
|
371
|
+
*/
|
|
372
|
+
export const wuRepairTool = {
|
|
373
|
+
name: 'wu_repair',
|
|
374
|
+
description: 'Unified WU repair tool - detect and fix WU state issues',
|
|
375
|
+
// WU-1454: Use shared schema
|
|
376
|
+
inputSchema: wuRepairSchema,
|
|
377
|
+
async execute(input, options) {
|
|
378
|
+
const args = [];
|
|
379
|
+
if (input.id)
|
|
380
|
+
args.push('--id', input.id);
|
|
381
|
+
if (input.check)
|
|
382
|
+
args.push('--check');
|
|
383
|
+
if (input.all)
|
|
384
|
+
args.push('--all');
|
|
385
|
+
if (input.claim)
|
|
386
|
+
args.push('--claim');
|
|
387
|
+
if (input.admin)
|
|
388
|
+
args.push('--admin');
|
|
389
|
+
if (input.repair_state)
|
|
390
|
+
args.push('--repair-state');
|
|
391
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
392
|
+
const result = await runCliCommand('wu:repair', args, cliOptions);
|
|
393
|
+
if (result.success) {
|
|
394
|
+
return success({ message: result.stdout || 'WU repair completed' });
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
return error(result.stderr || result.error?.message || 'wu:repair failed', ErrorCodes.WU_REPAIR_ERROR);
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* wu_deps - Visualize WU dependency graph
|
|
403
|
+
*/
|
|
404
|
+
export const wuDepsTool = {
|
|
405
|
+
name: 'wu_deps',
|
|
406
|
+
description: 'Visualize WU dependency graph',
|
|
407
|
+
// WU-1454: Use shared schema
|
|
408
|
+
inputSchema: wuDepsSchema,
|
|
409
|
+
async execute(input, options) {
|
|
410
|
+
if (!input.id) {
|
|
411
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
412
|
+
}
|
|
413
|
+
const args = ['--id', input.id];
|
|
414
|
+
if (input.format)
|
|
415
|
+
args.push('--format', input.format);
|
|
416
|
+
if (input.depth)
|
|
417
|
+
args.push('--depth', String(input.depth));
|
|
418
|
+
if (input.direction)
|
|
419
|
+
args.push('--direction', input.direction);
|
|
420
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
421
|
+
const result = await runCliCommand('wu:deps', args, cliOptions);
|
|
422
|
+
if (result.success) {
|
|
423
|
+
try {
|
|
424
|
+
const data = JSON.parse(result.stdout);
|
|
425
|
+
return success(data);
|
|
426
|
+
}
|
|
427
|
+
catch {
|
|
428
|
+
return success({ message: result.stdout });
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
return error(result.stderr || result.error?.message || 'wu:deps failed', ErrorCodes.WU_DEPS_ERROR);
|
|
433
|
+
}
|
|
434
|
+
},
|
|
435
|
+
};
|
|
436
|
+
/**
|
|
437
|
+
* wu_prep - Prepare WU for completion (run gates in worktree)
|
|
438
|
+
*/
|
|
439
|
+
export const wuPrepTool = {
|
|
440
|
+
name: 'wu_prep',
|
|
441
|
+
description: 'Prepare WU for completion by running gates in worktree',
|
|
442
|
+
// WU-1454: Use shared schema
|
|
443
|
+
inputSchema: wuPrepSchema,
|
|
444
|
+
async execute(input, options) {
|
|
445
|
+
if (!input.id) {
|
|
446
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
447
|
+
}
|
|
448
|
+
const args = ['--id', input.id];
|
|
449
|
+
if (input.docs_only)
|
|
450
|
+
args.push(CliArgs.DOCS_ONLY);
|
|
451
|
+
if (input.full_tests)
|
|
452
|
+
args.push('--full-tests');
|
|
453
|
+
const cliOptions = {
|
|
454
|
+
projectRoot: options?.projectRoot,
|
|
455
|
+
timeout: 600000, // 10 minutes for gates
|
|
456
|
+
};
|
|
457
|
+
const result = await runCliCommand('wu:prep', args, cliOptions);
|
|
458
|
+
if (result.success) {
|
|
459
|
+
return success({ message: result.stdout || 'WU prep completed' });
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
return error(result.stderr || result.error?.message || 'wu:prep failed', ErrorCodes.WU_PREP_ERROR);
|
|
463
|
+
}
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
/**
|
|
467
|
+
* wu_preflight - Fast validation before gates run
|
|
468
|
+
*/
|
|
469
|
+
export const wuPreflightTool = {
|
|
470
|
+
name: 'wu_preflight',
|
|
471
|
+
description: 'Fast validation of code_paths and test paths before gates run (under 5 seconds vs 2+ minutes)',
|
|
472
|
+
// WU-1454: Use shared schema
|
|
473
|
+
inputSchema: wuPreflightSchema,
|
|
474
|
+
async execute(input, options) {
|
|
475
|
+
if (!input.id) {
|
|
476
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
477
|
+
}
|
|
478
|
+
const args = ['--id', input.id];
|
|
479
|
+
if (input.worktree)
|
|
480
|
+
args.push('--worktree', input.worktree);
|
|
481
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
482
|
+
const result = await runCliCommand('wu:preflight', args, cliOptions);
|
|
483
|
+
if (result.success) {
|
|
484
|
+
return success({ message: result.stdout || 'Preflight checks passed' });
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
return error(result.stderr || result.error?.message || 'wu:preflight failed', ErrorCodes.WU_PREFLIGHT_ERROR);
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
/**
|
|
492
|
+
* wu_prune - Clean stale worktrees
|
|
493
|
+
*/
|
|
494
|
+
export const wuPruneTool = {
|
|
495
|
+
name: 'wu_prune',
|
|
496
|
+
description: 'Clean stale worktrees (dry-run by default)',
|
|
497
|
+
// WU-1454: Use shared schema
|
|
498
|
+
inputSchema: wuPruneSchema,
|
|
499
|
+
async execute(input, options) {
|
|
500
|
+
const args = [];
|
|
501
|
+
if (input.execute)
|
|
502
|
+
args.push('--execute');
|
|
503
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
504
|
+
const result = await runCliCommand('wu:prune', args, cliOptions);
|
|
505
|
+
if (result.success) {
|
|
506
|
+
return success({ message: result.stdout || 'Prune completed' });
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
return error(result.stderr || result.error?.message || 'wu:prune failed', ErrorCodes.WU_PRUNE_ERROR);
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* wu_delete - Safely delete WU YAML files
|
|
515
|
+
*/
|
|
516
|
+
export const wuDeleteTool = {
|
|
517
|
+
name: 'wu_delete',
|
|
518
|
+
description: 'Safely delete WU YAML files with micro-worktree isolation',
|
|
519
|
+
// WU-1454: Use shared schema
|
|
520
|
+
inputSchema: wuDeleteSchema,
|
|
521
|
+
async execute(input, options) {
|
|
522
|
+
if (!input.id && !input.batch) {
|
|
523
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
524
|
+
}
|
|
525
|
+
const args = [];
|
|
526
|
+
if (input.id)
|
|
527
|
+
args.push('--id', input.id);
|
|
528
|
+
if (input.dry_run)
|
|
529
|
+
args.push(CliArgs.DRY_RUN);
|
|
530
|
+
if (input.batch)
|
|
531
|
+
args.push('--batch', input.batch);
|
|
532
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
533
|
+
const result = await runCliCommand('wu:delete', args, cliOptions);
|
|
534
|
+
if (result.success) {
|
|
535
|
+
return success({ message: result.stdout || 'WU deleted' });
|
|
536
|
+
}
|
|
537
|
+
else {
|
|
538
|
+
return error(result.stderr || result.error?.message || 'wu:delete failed', ErrorCodes.WU_DELETE_ERROR);
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
};
|
|
542
|
+
/**
|
|
543
|
+
* wu_cleanup - Clean up worktree and branch after PR merge
|
|
544
|
+
*/
|
|
545
|
+
export const wuCleanupTool = {
|
|
546
|
+
name: 'wu_cleanup',
|
|
547
|
+
description: 'Clean up worktree and branch after PR merge (PR-based completion workflow)',
|
|
548
|
+
// WU-1454: Use shared schema
|
|
549
|
+
inputSchema: wuCleanupSchema,
|
|
550
|
+
async execute(input, options) {
|
|
551
|
+
if (!input.id) {
|
|
552
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
553
|
+
}
|
|
554
|
+
const args = ['--id', input.id];
|
|
555
|
+
if (input.artifacts)
|
|
556
|
+
args.push('--artifacts');
|
|
557
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
558
|
+
const result = await runCliCommand('wu:cleanup', args, cliOptions);
|
|
559
|
+
if (result.success) {
|
|
560
|
+
return success({ message: result.stdout || 'Cleanup complete' });
|
|
561
|
+
}
|
|
562
|
+
else {
|
|
563
|
+
return error(result.stderr || result.error?.message || 'wu:cleanup failed', ErrorCodes.WU_CLEANUP_ERROR);
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* wu_brief - Generate handoff prompt for sub-agent WU execution (WU-1603)
|
|
569
|
+
*
|
|
570
|
+
* This is the canonical prompt-generation tool.
|
|
571
|
+
*/
|
|
572
|
+
export const wuBriefTool = {
|
|
573
|
+
name: 'wu_brief',
|
|
574
|
+
description: 'Generate handoff prompt for sub-agent WU execution',
|
|
575
|
+
// WU-1454: Use shared schema (same parameters as wu:delegate)
|
|
576
|
+
inputSchema: wuSpawnSchema,
|
|
577
|
+
async execute(input, options) {
|
|
578
|
+
if (!input.id) {
|
|
579
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
580
|
+
}
|
|
581
|
+
const args = buildWuPromptArgs(input);
|
|
582
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
583
|
+
const result = await runCliCommand('wu:brief', args, cliOptions);
|
|
584
|
+
if (result.success) {
|
|
585
|
+
return success({ message: result.stdout || 'Brief prompt generated' });
|
|
586
|
+
}
|
|
587
|
+
else {
|
|
588
|
+
return error(result.stderr || result.error?.message || 'wu:brief failed', ErrorCodes.WU_BRIEF_ERROR);
|
|
589
|
+
}
|
|
590
|
+
},
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* wu_delegate - Generate prompt and explicitly record delegation lineage intent
|
|
594
|
+
*/
|
|
595
|
+
export const wuDelegateTool = {
|
|
596
|
+
name: 'wu_delegate',
|
|
597
|
+
description: 'Generate delegation prompt and record explicit lineage intent',
|
|
598
|
+
inputSchema: wuSpawnSchema,
|
|
599
|
+
async execute(input, options) {
|
|
600
|
+
if (!input.id) {
|
|
601
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
602
|
+
}
|
|
603
|
+
if (!input.parent_wu) {
|
|
604
|
+
return error(ErrorMessages.PARENT_WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
605
|
+
}
|
|
606
|
+
const args = buildWuPromptArgs(input);
|
|
607
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
608
|
+
const result = await runCliCommand('wu:delegate', args, cliOptions);
|
|
609
|
+
if (result.success) {
|
|
610
|
+
return success({ message: result.stdout || 'Delegation prompt generated' });
|
|
611
|
+
}
|
|
612
|
+
else {
|
|
613
|
+
return error(result.stderr || result.error?.message || 'wu:delegate failed', ErrorCodes.WU_DELEGATE_ERROR);
|
|
614
|
+
}
|
|
615
|
+
},
|
|
616
|
+
};
|
|
617
|
+
/**
|
|
618
|
+
* wu_validate - Validate WU YAML files
|
|
619
|
+
*/
|
|
620
|
+
export const wuValidateTool = {
|
|
621
|
+
name: 'wu_validate',
|
|
622
|
+
description: 'Validate WU YAML files against schema (strict mode by default)',
|
|
623
|
+
// WU-1454: Use shared schema
|
|
624
|
+
inputSchema: wuValidateSchema,
|
|
625
|
+
async execute(input, options) {
|
|
626
|
+
if (!input.id) {
|
|
627
|
+
return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
628
|
+
}
|
|
629
|
+
const args = ['--id', input.id];
|
|
630
|
+
if (input.no_strict)
|
|
631
|
+
args.push('--no-strict');
|
|
632
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
633
|
+
const result = await runCliCommand('wu:validate', args, cliOptions);
|
|
634
|
+
if (result.success) {
|
|
635
|
+
return success({ message: result.stdout || 'WU is valid' });
|
|
636
|
+
}
|
|
637
|
+
else {
|
|
638
|
+
return error(result.stderr || result.error?.message || 'wu:validate failed', ErrorCodes.WU_VALIDATE_ERROR);
|
|
639
|
+
}
|
|
640
|
+
},
|
|
641
|
+
};
|
|
642
|
+
/**
|
|
643
|
+
* wu_infer_lane - Suggest lane for a WU based on code paths and description
|
|
644
|
+
*/
|
|
645
|
+
export const wuInferLaneTool = {
|
|
646
|
+
name: 'wu_infer_lane',
|
|
647
|
+
description: 'Suggest lane for a WU based on code paths and description',
|
|
648
|
+
// WU-1454: Use shared schema
|
|
649
|
+
inputSchema: wuInferLaneSchema,
|
|
650
|
+
async execute(input, options) {
|
|
651
|
+
const args = [];
|
|
652
|
+
if (input.id)
|
|
653
|
+
args.push('--id', input.id);
|
|
654
|
+
if (input.paths) {
|
|
655
|
+
for (const p of input.paths) {
|
|
656
|
+
args.push('--paths', p);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
if (input.desc)
|
|
660
|
+
args.push('--desc', input.desc);
|
|
661
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
662
|
+
const result = await runCliCommand('wu:infer-lane', args, cliOptions);
|
|
663
|
+
if (result.success) {
|
|
664
|
+
return success({ lane: result.stdout?.trim() || 'Unknown' });
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
return error(result.stderr || result.error?.message || 'wu:infer-lane failed', ErrorCodes.WU_INFER_LANE_ERROR);
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
};
|
|
671
|
+
/**
|
|
672
|
+
* wu_unlock_lane - Safely unlock a lane lock with audit logging
|
|
673
|
+
*/
|
|
674
|
+
export const wuUnlockLaneTool = {
|
|
675
|
+
name: 'wu_unlock_lane',
|
|
676
|
+
description: 'Safely unlock a lane lock with audit logging',
|
|
677
|
+
// WU-1454: Use shared schema
|
|
678
|
+
inputSchema: wuUnlockLaneSchema,
|
|
679
|
+
async execute(input, options) {
|
|
680
|
+
// If list mode, no lane required
|
|
681
|
+
if (!input.list && !input.lane) {
|
|
682
|
+
return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
|
|
683
|
+
}
|
|
684
|
+
const args = [];
|
|
685
|
+
if (input.lane)
|
|
686
|
+
args.push('--lane', input.lane);
|
|
687
|
+
if (input.reason)
|
|
688
|
+
args.push('--reason', input.reason);
|
|
689
|
+
if (input.force)
|
|
690
|
+
args.push('--force');
|
|
691
|
+
if (input.list)
|
|
692
|
+
args.push('--list');
|
|
693
|
+
if (input.status)
|
|
694
|
+
args.push('--status');
|
|
695
|
+
const cliOptions = { projectRoot: options?.projectRoot };
|
|
696
|
+
const result = await runCliCommand('wu:unlock-lane', args, cliOptions);
|
|
697
|
+
if (result.success) {
|
|
698
|
+
try {
|
|
699
|
+
const data = JSON.parse(result.stdout);
|
|
700
|
+
return success(data);
|
|
701
|
+
}
|
|
702
|
+
catch {
|
|
703
|
+
return success({ message: result.stdout || 'Lane unlocked' });
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
else {
|
|
707
|
+
return error(result.stderr || result.error?.message || 'wu:unlock-lane failed', ErrorCodes.WU_UNLOCK_LANE_ERROR);
|
|
708
|
+
}
|
|
709
|
+
},
|
|
710
|
+
};
|
|
711
|
+
//# sourceMappingURL=wu-tools.js.map
|