@lumenflow/mcp 2.18.2 → 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.
Files changed (49) hide show
  1. package/dist/tools/agent-tools.d.ts +26 -0
  2. package/dist/tools/agent-tools.d.ts.map +1 -0
  3. package/dist/tools/agent-tools.js +161 -0
  4. package/dist/tools/agent-tools.js.map +1 -0
  5. package/dist/tools/context-tools.d.ts +19 -0
  6. package/dist/tools/context-tools.d.ts.map +1 -0
  7. package/dist/tools/context-tools.js +73 -0
  8. package/dist/tools/context-tools.js.map +1 -0
  9. package/dist/tools/flow-tools.d.ts +30 -0
  10. package/dist/tools/flow-tools.d.ts.map +1 -0
  11. package/dist/tools/flow-tools.js +141 -0
  12. package/dist/tools/flow-tools.js.map +1 -0
  13. package/dist/tools/initiative-tools.d.ts +42 -0
  14. package/dist/tools/initiative-tools.d.ts.map +1 -0
  15. package/dist/tools/initiative-tools.js +304 -0
  16. package/dist/tools/initiative-tools.js.map +1 -0
  17. package/dist/tools/memory-tools.d.ts +66 -0
  18. package/dist/tools/memory-tools.d.ts.map +1 -0
  19. package/dist/tools/memory-tools.js +419 -0
  20. package/dist/tools/memory-tools.js.map +1 -0
  21. package/dist/tools/orchestration-tools.d.ts +26 -0
  22. package/dist/tools/orchestration-tools.d.ts.map +1 -0
  23. package/dist/tools/orchestration-tools.js +158 -0
  24. package/dist/tools/orchestration-tools.js.map +1 -0
  25. package/dist/tools/parity-tools.d.ts +118 -0
  26. package/dist/tools/parity-tools.d.ts.map +1 -0
  27. package/dist/tools/parity-tools.js +897 -0
  28. package/dist/tools/parity-tools.js.map +1 -0
  29. package/dist/tools/setup-tools.d.ts +42 -0
  30. package/dist/tools/setup-tools.d.ts.map +1 -0
  31. package/dist/tools/setup-tools.js +167 -0
  32. package/dist/tools/setup-tools.js.map +1 -0
  33. package/dist/tools/validation-tools.d.ts +34 -0
  34. package/dist/tools/validation-tools.d.ts.map +1 -0
  35. package/dist/tools/validation-tools.js +134 -0
  36. package/dist/tools/validation-tools.js.map +1 -0
  37. package/dist/tools/wu-tools.d.ts +116 -0
  38. package/dist/tools/wu-tools.d.ts.map +1 -0
  39. package/dist/tools/wu-tools.js +711 -0
  40. package/dist/tools/wu-tools.js.map +1 -0
  41. package/dist/tools-shared.d.ts +170 -0
  42. package/dist/tools-shared.d.ts.map +1 -0
  43. package/dist/tools-shared.js +203 -0
  44. package/dist/tools-shared.js.map +1 -0
  45. package/dist/tools.d.ts +34 -466
  46. package/dist/tools.d.ts.map +1 -1
  47. package/dist/tools.js +54 -3323
  48. package/dist/tools.js.map +1 -1
  49. package/package.json +2 -2
package/dist/tools.js CHANGED
@@ -1,3331 +1,62 @@
1
1
  /**
2
2
  * @file tools.ts
3
- * @description MCP tool implementations for LumenFlow operations
3
+ * @description MCP tool barrel - re-exports all domain tool modules and assembles the allTools registry.
4
+ *
5
+ * WU-1642: Decomposed from monolithic tools.ts into domain-scoped modules:
6
+ * - tools-shared.ts: Types, constants, helpers shared across domains
7
+ * - tools/context-tools.ts: context_get, wu_list
8
+ * - tools/wu-tools.ts: WU lifecycle (create, claim, done, block, edit, etc.)
9
+ * - tools/initiative-tools.ts: Initiative operations
10
+ * - tools/memory-tools.ts: Memory operations
11
+ * - tools/agent-tools.ts: Agent session/issue operations
12
+ * - tools/orchestration-tools.ts: Orchestration + spawn operations
13
+ * - tools/flow-tools.ts: Flow/metrics operations
14
+ * - tools/validation-tools.ts: Validation operations
15
+ * - tools/setup-tools.ts: Setup/LumenFlow operations
16
+ * - tools/parity-tools.ts: Wave-1 + Wave-2 public parity operations
4
17
  *
5
18
  * WU-1412: Tools available: context_get, wu_list, wu_status, wu_create, wu_claim, wu_done, gates_run
6
- * WU-1422: Additional WU tools: wu_block, wu_unblock, wu_edit, wu_release, wu_recover, wu_repair,
7
- * wu_deps, wu_prep, wu_preflight, wu_prune, wu_delete, wu_cleanup, wu_validate,
8
- * wu_infer_lane, wu_unlock_lane
9
- * WU-1424: Initiative tools: initiative_list, initiative_status, initiative_create, initiative_edit,
10
- * initiative_add_wu, initiative_remove_wu, initiative_bulk_assign, initiative_plan
11
- * Memory tools: mem_init, mem_start, mem_ready, mem_checkpoint, mem_cleanup, mem_context,
12
- * mem_create, mem_delete, mem_export, mem_inbox, mem_signal, mem_summarize, mem_triage,
13
- * mem_recover
14
- * WU-1425: Agent tools: agent_session, agent_session_end, agent_log_issue, agent_issues_query
15
- * Orchestration tools: orchestrate_initiative, orchestrate_init_status, orchestrate_monitor
16
- * Spawn tools: spawn_list
17
- * WU-1426: Flow/Metrics tools: flow_bottlenecks, flow_report, metrics_snapshot
18
- * Validation tools: validate, validate_agent_skills, validate_agent_sync,
19
- * validate_backlog_sync, validate_skills_spec
20
- * Setup tools: lumenflow_init, lumenflow_doctor, lumenflow_integrate, lumenflow_upgrade,
21
- * lumenflow_commands, lumenflow_docs_sync, lumenflow_release, lumenflow_sync_templates
19
+ * WU-1422: Additional WU tools
20
+ * WU-1424: Initiative tools, Memory tools
21
+ * WU-1425: Agent tools, Orchestration tools, Spawn tools
22
+ * WU-1426: Flow/Metrics tools, Validation tools, Setup tools
22
23
  * WU-1431: Uses shared Zod schemas from @lumenflow/core for CLI/MCP parity
23
24
  * WU-1454: All 16 WU lifecycle commands now use shared schemas
24
25
  * WU-1456: Memory commands use shared schemas where available
25
- * WU-1457: All remaining commands (flow, validation, setup, agent, orchestration, spawn) use shared schemas
26
- *
27
- * Architecture:
28
- * - Read operations (context_get) use @lumenflow/core directly for context
29
- * - All other operations shell out to CLI for consistency and safety
30
- * - Input schemas are derived from shared schemas in @lumenflow/core (WU-1431, WU-1454)
31
- */
32
- import { z } from 'zod';
33
- import { runCliCommand } from './cli-runner.js';
34
- // WU-1431: Import shared command schemas for CLI/MCP parity
35
- // WU-1454: Import WU lifecycle schemas for full coverage
36
- // WU-1457: Import flow, validation, setup, agent, orchestration, spawn schemas
37
- // These are the single source of truth for command validation
38
- import { wuCreateSchema, wuClaimSchema, wuStatusSchema, wuDoneSchema, gatesSchema, wuStatusEnum,
39
- // WU-1454: Lifecycle command schemas
40
- wuBlockSchema, wuUnblockSchema, wuEditSchema, wuReleaseSchema, wuRecoverSchema, wuRepairSchema, wuDepsSchema, wuPrepSchema, wuPreflightSchema, wuPruneSchema, wuDeleteSchema, wuCleanupSchema, wuSpawnSchema, wuValidateSchema, wuInferLaneSchema, wuUnlockLaneSchema,
41
- // WU-1455: Initiative command schemas
42
- initiativeCreateSchema, initiativeEditSchema, initiativeListSchema, initiativeStatusSchema, initiativeAddWuSchema, initiativeRemoveWuSchema, initiativeBulkAssignSchema, initiativePlanSchema,
43
- // WU-1456: Memory command schemas
44
- memInitSchema, memStartSchema, memReadySchema, memCheckpointSchema, memCleanupSchema, memContextSchema, memCreateSchema, memDeleteSchema, memExportSchema, memInboxSchema, memSignalSchema, memSummarizeSchema, memTriageSchema,
45
- // WU-1457: Flow/Metrics command schemas
46
- flowBottlenecksSchema, flowReportSchema, metricsSnapshotSchema, metricsSchema,
47
- // WU-1457: Validation command schemas
48
- validateSchema, validateAgentSkillsSchema, validateAgentSyncSchema, validateBacklogSyncSchema, validateSkillsSpecSchema,
49
- // WU-1457: Setup command schemas
50
- lumenflowInitSchema, lumenflowDoctorSchema, lumenflowIntegrateSchema, lumenflowUpgradeSchema, lumenflowCommandsSchema, docsSyncSchema, releaseSchema, syncTemplatesSchema,
51
- // WU-1457: Agent command schemas
52
- agentSessionSchema, agentSessionEndSchema, agentLogIssueSchema, agentIssuesQuerySchema,
53
- // WU-1457: Orchestration command schemas
54
- orchestrateInitiativeSchema, orchestrateInitStatusSchema, orchestrateMonitorSchema,
55
- // WU-1457: Spawn command schemas
56
- spawnListSchema, } from '@lumenflow/core';
57
- // Import core functions for context operations only (async to avoid circular deps)
58
- let coreModule = null;
59
- async function getCore() {
60
- if (!coreModule) {
61
- coreModule = await import('@lumenflow/core');
62
- }
63
- return coreModule;
64
- }
65
- /**
66
- * Error codes used by tool implementations
67
- */
68
- const ErrorCodes = {
69
- MISSING_PARAMETER: 'MISSING_PARAMETER',
70
- CONTEXT_ERROR: 'CONTEXT_ERROR',
71
- WU_LIST_ERROR: 'WU_LIST_ERROR',
72
- WU_STATUS_ERROR: 'WU_STATUS_ERROR',
73
- WU_CREATE_ERROR: 'WU_CREATE_ERROR',
74
- WU_CLAIM_ERROR: 'WU_CLAIM_ERROR',
75
- WU_DONE_ERROR: 'WU_DONE_ERROR',
76
- WRONG_LOCATION: 'WRONG_LOCATION',
77
- GATES_ERROR: 'GATES_ERROR',
78
- WU_BLOCK_ERROR: 'WU_BLOCK_ERROR',
79
- WU_UNBLOCK_ERROR: 'WU_UNBLOCK_ERROR',
80
- WU_EDIT_ERROR: 'WU_EDIT_ERROR',
81
- WU_RELEASE_ERROR: 'WU_RELEASE_ERROR',
82
- WU_RECOVER_ERROR: 'WU_RECOVER_ERROR',
83
- WU_REPAIR_ERROR: 'WU_REPAIR_ERROR',
84
- WU_DEPS_ERROR: 'WU_DEPS_ERROR',
85
- WU_PREP_ERROR: 'WU_PREP_ERROR',
86
- WU_PREFLIGHT_ERROR: 'WU_PREFLIGHT_ERROR',
87
- WU_PRUNE_ERROR: 'WU_PRUNE_ERROR',
88
- WU_DELETE_ERROR: 'WU_DELETE_ERROR',
89
- WU_CLEANUP_ERROR: 'WU_CLEANUP_ERROR',
90
- WU_BRIEF_ERROR: 'WU_BRIEF_ERROR',
91
- WU_DELEGATE_ERROR: 'WU_DELEGATE_ERROR',
92
- WU_VALIDATE_ERROR: 'WU_VALIDATE_ERROR',
93
- WU_INFER_LANE_ERROR: 'WU_INFER_LANE_ERROR',
94
- WU_UNLOCK_LANE_ERROR: 'WU_UNLOCK_LANE_ERROR',
95
- BACKLOG_PRUNE_ERROR: 'BACKLOG_PRUNE_ERROR',
96
- DOCS_SYNC_ERROR: 'DOCS_SYNC_ERROR',
97
- GATES_ALIAS_ERROR: 'GATES_ALIAS_ERROR',
98
- LANE_HEALTH_ERROR: 'LANE_HEALTH_ERROR',
99
- LANE_SUGGEST_ERROR: 'LANE_SUGGEST_ERROR',
100
- LUMENFLOW_ALIAS_ERROR: 'LUMENFLOW_ALIAS_ERROR',
101
- LUMENFLOW_GATES_ERROR: 'LUMENFLOW_GATES_ERROR',
102
- LUMENFLOW_VALIDATE_ERROR: 'LUMENFLOW_VALIDATE_ERROR',
103
- LUMENFLOW_METRICS_ERROR: 'LUMENFLOW_METRICS_ERROR',
104
- METRICS_ERROR: 'METRICS_ERROR',
105
- STATE_BOOTSTRAP_ERROR: 'STATE_BOOTSTRAP_ERROR',
106
- STATE_CLEANUP_ERROR: 'STATE_CLEANUP_ERROR',
107
- STATE_DOCTOR_ERROR: 'STATE_DOCTOR_ERROR',
108
- SYNC_TEMPLATES_ALIAS_ERROR: 'SYNC_TEMPLATES_ALIAS_ERROR',
109
- FILE_READ_ERROR: 'FILE_READ_ERROR',
110
- FILE_WRITE_ERROR: 'FILE_WRITE_ERROR',
111
- FILE_EDIT_ERROR: 'FILE_EDIT_ERROR',
112
- FILE_DELETE_ERROR: 'FILE_DELETE_ERROR',
113
- GIT_STATUS_ERROR: 'GIT_STATUS_ERROR',
114
- GIT_DIFF_ERROR: 'GIT_DIFF_ERROR',
115
- GIT_LOG_ERROR: 'GIT_LOG_ERROR',
116
- GIT_BRANCH_ERROR: 'GIT_BRANCH_ERROR',
117
- INIT_PLAN_ERROR: 'INIT_PLAN_ERROR',
118
- PLAN_CREATE_ERROR: 'PLAN_CREATE_ERROR',
119
- PLAN_EDIT_ERROR: 'PLAN_EDIT_ERROR',
120
- PLAN_LINK_ERROR: 'PLAN_LINK_ERROR',
121
- PLAN_PROMOTE_ERROR: 'PLAN_PROMOTE_ERROR',
122
- SIGNAL_CLEANUP_ERROR: 'SIGNAL_CLEANUP_ERROR',
123
- WU_PROTO_ERROR: 'WU_PROTO_ERROR',
124
- // WU-1426: Flow/Metrics error codes
125
- FLOW_BOTTLENECKS_ERROR: 'FLOW_BOTTLENECKS_ERROR',
126
- FLOW_REPORT_ERROR: 'FLOW_REPORT_ERROR',
127
- METRICS_SNAPSHOT_ERROR: 'METRICS_SNAPSHOT_ERROR',
128
- // WU-1426: Validation error codes
129
- VALIDATE_ERROR: 'VALIDATE_ERROR',
130
- VALIDATE_AGENT_SKILLS_ERROR: 'VALIDATE_AGENT_SKILLS_ERROR',
131
- VALIDATE_AGENT_SYNC_ERROR: 'VALIDATE_AGENT_SYNC_ERROR',
132
- VALIDATE_BACKLOG_SYNC_ERROR: 'VALIDATE_BACKLOG_SYNC_ERROR',
133
- VALIDATE_SKILLS_SPEC_ERROR: 'VALIDATE_SKILLS_SPEC_ERROR',
134
- // WU-1426: Setup error codes
135
- LUMENFLOW_INIT_ERROR: 'LUMENFLOW_INIT_ERROR',
136
- LUMENFLOW_DOCTOR_ERROR: 'LUMENFLOW_DOCTOR_ERROR',
137
- LUMENFLOW_INTEGRATE_ERROR: 'LUMENFLOW_INTEGRATE_ERROR',
138
- LUMENFLOW_UPGRADE_ERROR: 'LUMENFLOW_UPGRADE_ERROR',
139
- LUMENFLOW_COMMANDS_ERROR: 'LUMENFLOW_COMMANDS_ERROR',
140
- LUMENFLOW_DOCS_SYNC_ERROR: 'LUMENFLOW_DOCS_SYNC_ERROR',
141
- LUMENFLOW_RELEASE_ERROR: 'LUMENFLOW_RELEASE_ERROR',
142
- LUMENFLOW_SYNC_TEMPLATES_ERROR: 'LUMENFLOW_SYNC_TEMPLATES_ERROR',
143
- };
144
- /**
145
- * Error messages used by tool implementations
146
- */
147
- const ErrorMessages = {
148
- ID_REQUIRED: 'id is required',
149
- LANE_REQUIRED: 'lane is required',
150
- TITLE_REQUIRED: 'title is required',
151
- PATH_REQUIRED: 'path is required',
152
- CONTENT_REQUIRED: 'content is required',
153
- OLD_STRING_REQUIRED: 'old_string is required',
154
- NEW_STRING_REQUIRED: 'new_string is required',
155
- REASON_REQUIRED: 'reason is required',
156
- CLIENT_REQUIRED: 'client is required',
157
- PARENT_WU_REQUIRED: 'parent_wu is required',
158
- SECTION_REQUIRED: 'section is required',
159
- PLAN_REQUIRED: 'plan is required',
160
- };
161
- /**
162
- * CLI argument constants for commonly used flags
163
- */
164
- const CliArgs = {
165
- DESCRIPTION: '--description',
166
- INITIATIVE: '--initiative',
167
- PHASE: '--phase',
168
- JSON: '--json',
169
- DOCS_ONLY: '--docs-only',
170
- CODE_PATHS: '--code-paths',
171
- BASE_DIR: '--base-dir',
172
- ENCODING: '--encoding',
173
- // WU-1452: Commands using --format json (initiative:*, flow:*, metrics)
174
- FORMAT_JSON: ['--format', 'json'],
175
- DRY_RUN: '--dry-run',
176
- THRESHOLD: '--threshold',
177
- RECOVER: '--recover',
178
- WU: '--wu',
179
- };
180
- /**
181
- * Shared error messages to avoid duplication across different tool categories
182
- */
183
- const SharedErrorMessages = {
184
- WU_REQUIRED: 'wu is required',
185
- INITIATIVE_REQUIRED: 'initiative is required',
186
- };
187
- const SuccessMessages = {
188
- ALL_GATES_PASSED: 'All gates passed',
189
- };
190
- // WU-1482: Schemas for wave-1 parity commands not yet modeled in @lumenflow/core
191
- const backlogPruneSchema = z.object({
192
- execute: z.boolean().optional(),
193
- dry_run: z.boolean().optional(),
194
- stale_days_in_progress: z.number().optional(),
195
- stale_days_ready: z.number().optional(),
196
- archive_days: z.number().optional(),
197
- });
198
- const docsSyncMcpSchema = z.object({
199
- vendor: z.enum(['claude', 'cursor', 'aider', 'all', 'none']).optional(),
200
- force: z.boolean().optional(),
201
- });
202
- const laneHealthSchema = z.object({
203
- json: z.boolean().optional(),
204
- verbose: z.boolean().optional(),
205
- no_coverage: z.boolean().optional(),
206
- });
207
- const laneSuggestSchema = z.object({
208
- dry_run: z.boolean().optional(),
209
- interactive: z.boolean().optional(),
210
- output: z.string().optional(),
211
- json: z.boolean().optional(),
212
- no_llm: z.boolean().optional(),
213
- include_git: z.boolean().optional(),
214
- });
215
- const stateBootstrapSchema = z.object({
216
- execute: z.boolean().optional(),
217
- dry_run: z.boolean().optional(),
218
- force: z.boolean().optional(),
219
- wu_dir: z.string().optional(),
220
- state_dir: z.string().optional(),
221
- });
222
- const stateCleanupSchema = z.object({
223
- dry_run: z.boolean().optional(),
224
- signals_only: z.boolean().optional(),
225
- memory_only: z.boolean().optional(),
226
- events_only: z.boolean().optional(),
227
- json: z.boolean().optional(),
228
- quiet: z.boolean().optional(),
229
- base_dir: z.string().optional(),
230
- });
231
- const stateDoctorSchema = z.object({
232
- fix: z.boolean().optional(),
233
- dry_run: z.boolean().optional(),
234
- json: z.boolean().optional(),
235
- quiet: z.boolean().optional(),
236
- base_dir: z.string().optional(),
237
- });
238
- const syncTemplatesMcpSchema = z.object({
239
- dry_run: z.boolean().optional(),
240
- verbose: z.boolean().optional(),
241
- check_drift: z.boolean().optional(),
242
- });
243
- // mem:recover public parity schema (not yet modeled in @lumenflow/core memory schemas)
244
- const memRecoverSchema = z.object({
245
- wu: z.string().optional(),
246
- max_size: z.number().optional(),
247
- format: z.enum(['json', 'human']).optional(),
248
- quiet: z.boolean().optional(),
249
- base_dir: z.string().optional(),
250
- });
251
- // WU-1483: Schemas for wave-2 parity commands not yet modeled in @lumenflow/core
252
- const fileReadSchema = z.object({
253
- path: z.string().optional(),
254
- encoding: z.string().optional(),
255
- start_line: z.number().optional(),
256
- end_line: z.number().optional(),
257
- max_size: z.number().optional(),
258
- });
259
- const fileWriteSchema = z.object({
260
- path: z.string().optional(),
261
- content: z.string().optional(),
262
- encoding: z.string().optional(),
263
- no_create_dirs: z.boolean().optional(),
264
- scan_phi: z.boolean().optional(),
265
- });
266
- const fileEditSchema = z.object({
267
- path: z.string().optional(),
268
- old_string: z.string().optional(),
269
- new_string: z.string().optional(),
270
- encoding: z.string().optional(),
271
- replace_all: z.boolean().optional(),
272
- });
273
- const fileDeleteSchema = z.object({
274
- path: z.string().optional(),
275
- recursive: z.boolean().optional(),
276
- force: z.boolean().optional(),
277
- });
278
- const gitStatusSchema = z.object({
279
- base_dir: z.string().optional(),
280
- path: z.string().optional(),
281
- porcelain: z.boolean().optional(),
282
- short: z.boolean().optional(),
283
- });
284
- const gitDiffSchema = z.object({
285
- base_dir: z.string().optional(),
286
- ref: z.string().optional(),
287
- staged: z.boolean().optional(),
288
- name_only: z.boolean().optional(),
289
- stat: z.boolean().optional(),
290
- path: z.string().optional(),
291
- });
292
- const gitLogSchema = z.object({
293
- base_dir: z.string().optional(),
294
- ref: z.string().optional(),
295
- oneline: z.boolean().optional(),
296
- max_count: z.number().optional(),
297
- format: z.string().optional(),
298
- since: z.string().optional(),
299
- author: z.string().optional(),
300
- });
301
- const gitBranchSchema = z.object({
302
- base_dir: z.string().optional(),
303
- list: z.boolean().optional(),
304
- all: z.boolean().optional(),
305
- remotes: z.boolean().optional(),
306
- show_current: z.boolean().optional(),
307
- contains: z.string().optional(),
308
- });
309
- const planCreateSchema = z.object({
310
- id: z.string().optional(),
311
- title: z.string().optional(),
312
- });
313
- const planEditSchema = z.object({
314
- id: z.string().optional(),
315
- section: z.string().optional(),
316
- content: z.string().optional(),
317
- append: z.string().optional(),
318
- });
319
- const planLinkSchema = z.object({
320
- id: z.string().optional(),
321
- plan: z.string().optional(),
322
- });
323
- const planPromoteSchema = z.object({
324
- id: z.string().optional(),
325
- force: z.boolean().optional(),
326
- });
327
- const signalCleanupSchema = z.object({
328
- dry_run: z.boolean().optional(),
329
- ttl: z.string().optional(),
330
- unread_ttl: z.string().optional(),
331
- max_entries: z.number().optional(),
332
- json: z.boolean().optional(),
333
- quiet: z.boolean().optional(),
334
- base_dir: z.string().optional(),
335
- });
336
- const wuProtoSchema = z.object({
337
- lane: z.string().optional(),
338
- title: z.string().optional(),
339
- description: z.string().optional(),
340
- code_paths: z.array(z.string()).optional(),
341
- labels: z.array(z.string()).optional(),
342
- assigned_to: z.string().optional(),
343
- });
344
- function buildGatesArgs(input, options = {}) {
345
- const args = [];
346
- if (options.forceDocsOnly || input.docs_only)
347
- args.push(CliArgs.DOCS_ONLY);
348
- if (input.full_lint)
349
- args.push('--full-lint');
350
- if (input.full_tests)
351
- args.push('--full-tests');
352
- if (input.full_coverage)
353
- args.push('--full-coverage');
354
- if (input.coverage_mode)
355
- args.push('--coverage-mode', input.coverage_mode);
356
- if (input.verbose)
357
- args.push('--verbose');
358
- return args;
359
- }
360
- function buildMetricsArgs(input) {
361
- const args = [];
362
- if (input.subcommand)
363
- args.push(input.subcommand);
364
- if (input.days !== undefined)
365
- args.push('--days', String(input.days));
366
- if (input.format)
367
- args.push('--format', input.format);
368
- if (input.output)
369
- args.push('--output', input.output);
370
- if (input.dry_run)
371
- args.push('--dry-run');
372
- return args;
373
- }
374
- /**
375
- * Create a successful tool result
376
- */
377
- function success(data) {
378
- return { success: true, data };
379
- }
380
- /**
381
- * Create an error tool result
382
- */
383
- function error(message, code) {
384
- return { success: false, error: { message, code } };
385
- }
386
- // ============================================================================
387
- // Read Operations (via @lumenflow/core)
388
- // ============================================================================
389
- /**
390
- * context_get - Get current WU context (location, git state, WU state)
391
- */
392
- export const contextGetTool = {
393
- name: 'context_get',
394
- description: 'Get current LumenFlow context including location, git state, and active WU',
395
- inputSchema: z.object({}).optional(),
396
- async execute(_input, options) {
397
- try {
398
- const core = await getCore();
399
- const context = await core.computeWuContext({
400
- cwd: options?.projectRoot,
401
- });
402
- return success(context);
403
- }
404
- catch (err) {
405
- return error(err instanceof Error ? err.message : String(err), ErrorCodes.CONTEXT_ERROR);
406
- }
407
- },
408
- };
409
- /**
410
- * wu_list - List all WUs with optional status filter
411
- * Uses CLI shell-out for consistency with other tools
412
- *
413
- * WU-1431: Uses shared wuStatusEnum for status filter
414
- */
415
- export const wuListTool = {
416
- name: 'wu_list',
417
- description: 'List all Work Units (WUs) with optional status filter',
418
- // WU-1431: Uses shared wuStatusEnum for status filter
419
- // (wu_list is MCP-specific, not a shared CLI command, so inline schema is OK)
420
- inputSchema: z.object({
421
- status: wuStatusEnum.optional(),
422
- lane: z.string().optional(),
423
- }),
424
- async execute(input, options) {
425
- // Use spec:linter which validates and lists all WUs
426
- const cliOptions = { projectRoot: options?.projectRoot };
427
- // Shell out to get all WU YAMLs via validate --all
428
- const result = await runCliCommand('wu:validate', ['--all', '--json'], cliOptions);
429
- if (result.success) {
430
- try {
431
- const data = JSON.parse(result.stdout);
432
- let wus = Array.isArray(data) ? data : data.wus || [];
433
- // Apply filters
434
- if (input.status) {
435
- wus = wus.filter((wu) => wu.status === input.status);
436
- }
437
- if (input.lane) {
438
- wus = wus.filter((wu) => wu.lane === input.lane);
439
- }
440
- return success(wus);
441
- }
442
- catch {
443
- // If JSON parse fails, return raw output
444
- return success({ message: result.stdout });
445
- }
446
- }
447
- else {
448
- return error(result.stderr || result.error?.message || 'wu_list failed', ErrorCodes.WU_LIST_ERROR);
449
- }
450
- },
451
- };
452
- /**
453
- * wu_status - Get status of a specific WU
454
- * Uses CLI shell-out for consistency
455
- *
456
- * WU-1431: Uses shared wuStatusSchema for parity with CLI
457
- * Note: CLI allows id to be optional (auto-detect from worktree), but MCP requires it
458
- * since there's no "current directory" concept for MCP clients
459
- */
460
- export const wuStatusTool = {
461
- name: 'wu_status',
462
- description: 'Get detailed status of a specific Work Unit',
463
- // WU-1431: Extend shared schema to require id for MCP (CLI allows optional for auto-detect)
464
- inputSchema: wuStatusSchema.extend({
465
- id: z.string().describe('WU ID (e.g., WU-1412)'),
466
- }),
467
- async execute(input, options) {
468
- if (!input.id) {
469
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
470
- }
471
- const args = ['--id', input.id, '--json'];
472
- const cliOptions = { projectRoot: options?.projectRoot };
473
- const result = await runCliCommand('wu:status', args, cliOptions);
474
- if (result.success) {
475
- try {
476
- const data = JSON.parse(result.stdout);
477
- return success(data);
478
- }
479
- catch {
480
- return success({ message: result.stdout });
481
- }
482
- }
483
- else {
484
- return error(result.stderr || result.error?.message || 'wu:status failed', ErrorCodes.WU_STATUS_ERROR);
485
- }
486
- },
487
- };
488
- // ============================================================================
489
- // Write Operations (via CLI shell-out)
490
- // ============================================================================
491
- /**
492
- * wu_create - Create a new WU
493
- *
494
- * WU-1431: Uses shared wuCreateSchema for CLI/MCP parity
495
- */
496
- export const wuCreateTool = {
497
- name: 'wu_create',
498
- description: 'Create a new Work Unit specification',
499
- // WU-1431: Use shared schema - CLI-only aliases are not exposed here
500
- inputSchema: wuCreateSchema,
501
- async execute(input, options) {
502
- if (!input.lane) {
503
- return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
504
- }
505
- if (!input.title) {
506
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
507
- }
508
- const args = ['--lane', input.lane, '--title', input.title];
509
- if (input.id)
510
- args.push('--id', input.id);
511
- if (input.description)
512
- args.push(CliArgs.DESCRIPTION, input.description);
513
- if (input.acceptance) {
514
- for (const criterion of input.acceptance) {
515
- args.push('--acceptance', criterion);
516
- }
517
- }
518
- if (input.code_paths) {
519
- for (const p of input.code_paths) {
520
- args.push(CliArgs.CODE_PATHS, p);
521
- }
522
- }
523
- if (input.exposure)
524
- args.push('--exposure', input.exposure);
525
- const cliOptions = { projectRoot: options?.projectRoot };
526
- const result = await runCliCommand('wu:create', args, cliOptions);
527
- if (result.success) {
528
- return success({ message: result.stdout || 'WU created successfully' });
529
- }
530
- else {
531
- return error(result.stderr || result.error?.message || 'wu:create failed', ErrorCodes.WU_CREATE_ERROR);
532
- }
533
- },
534
- };
535
- /**
536
- * wu_claim - Claim a WU and create worktree
537
- *
538
- * WU-1431: Uses shared wuClaimSchema for CLI/MCP parity
539
- * WU-1491: Supports --cloud, --branch-only, and --pr-mode passthrough
540
- */
541
- export const wuClaimTool = {
542
- name: 'wu_claim',
543
- description: 'Claim a Work Unit and create worktree for implementation',
544
- // WU-1431: Use shared schema
545
- inputSchema: wuClaimSchema,
546
- async execute(input, options) {
547
- if (!input.id) {
548
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
549
- }
550
- if (!input.lane) {
551
- return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
552
- }
553
- const args = ['--id', input.id, '--lane', input.lane];
554
- // WU-1491: Pass mode flags through to CLI
555
- if (input.cloud)
556
- args.push('--cloud');
557
- if (input.branch_only)
558
- args.push('--branch-only');
559
- if (input.pr_mode)
560
- args.push('--pr-mode');
561
- const cliOptions = { projectRoot: options?.projectRoot };
562
- const result = await runCliCommand('wu:claim', args, cliOptions);
563
- if (result.success) {
564
- return success({ message: result.stdout || 'WU claimed successfully' });
565
- }
566
- else {
567
- return error(result.stderr || result.error?.message || 'wu:claim failed', ErrorCodes.WU_CLAIM_ERROR);
568
- }
569
- },
570
- };
571
- /**
572
- * wu_done - Complete a WU (must be run from main checkout)
573
- *
574
- * WU-1431: Uses shared wuDoneSchema for CLI/MCP parity
575
- */
576
- export const wuDoneTool = {
577
- name: 'wu_done',
578
- description: 'Complete a Work Unit (merge, stamp, cleanup). MUST be run from main checkout.',
579
- // WU-1431: Use shared schema
580
- inputSchema: wuDoneSchema,
581
- async execute(input, options) {
582
- if (!input.id) {
583
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
584
- }
585
- // Fail fast if not on main checkout (AC: wu_done fails fast if not on main checkout)
586
- try {
587
- const core = await getCore();
588
- const context = await core.computeWuContext({
589
- cwd: options?.projectRoot,
590
- });
591
- if (context.location.type === 'worktree') {
592
- return error('wu_done must be run from main checkout, not from a worktree. ' +
593
- 'Run "pnpm wu:prep" first from the worktree, then cd to main and run wu:done.', ErrorCodes.WRONG_LOCATION);
594
- }
595
- }
596
- catch {
597
- // If we can't determine context, proceed anyway - CLI will validate
598
- }
599
- const args = ['--id', input.id];
600
- if (input.skip_gates) {
601
- args.push('--skip-gates');
602
- if (input.reason)
603
- args.push('--reason', input.reason);
604
- if (input.fix_wu)
605
- args.push('--fix-wu', input.fix_wu);
606
- }
607
- const cliOptions = { projectRoot: options?.projectRoot };
608
- const result = await runCliCommand('wu:done', args, cliOptions);
609
- if (result.success) {
610
- return success({ message: result.stdout || 'WU completed successfully' });
611
- }
612
- else {
613
- return error(result.stderr || result.error?.message || 'wu:done failed', ErrorCodes.WU_DONE_ERROR);
614
- }
615
- },
616
- };
617
- /**
618
- * gates_run - Run quality gates
619
- *
620
- * WU-1431: Uses shared gatesSchema for CLI/MCP parity
621
- */
622
- export const gatesRunTool = {
623
- name: 'gates_run',
624
- description: 'Run LumenFlow quality gates (lint, typecheck, tests)',
625
- // WU-1431: Use shared schema
626
- inputSchema: gatesSchema,
627
- async execute(input, options) {
628
- const args = [];
629
- if (input.docs_only) {
630
- args.push(CliArgs.DOCS_ONLY);
631
- }
632
- const cliOptions = {
633
- projectRoot: options?.projectRoot,
634
- timeout: 600000, // 10 minutes for gates
635
- };
636
- const result = await runCliCommand('gates', args, cliOptions);
637
- if (result.success) {
638
- return success({ message: result.stdout || SuccessMessages.ALL_GATES_PASSED });
639
- }
640
- else {
641
- return error(result.stderr || result.error?.message || 'Gates failed', ErrorCodes.GATES_ERROR);
642
- }
643
- },
644
- };
645
- // ============================================================================
646
- // Wave-1 Public Parity Operations (WU-1482)
647
- // ============================================================================
648
- /**
649
- * backlog_prune - Clean stale backlog entries
650
- */
651
- export const backlogPruneTool = {
652
- name: 'backlog_prune',
653
- description: 'Clean stale backlog entries and archive old completed WUs',
654
- inputSchema: backlogPruneSchema,
655
- async execute(input, options) {
656
- const args = [];
657
- if (input.execute)
658
- args.push('--execute');
659
- if (input.dry_run)
660
- args.push('--dry-run');
661
- if (input.stale_days_in_progress !== undefined) {
662
- args.push('--stale-days-in-progress', String(input.stale_days_in_progress));
663
- }
664
- if (input.stale_days_ready !== undefined) {
665
- args.push('--stale-days-ready', String(input.stale_days_ready));
666
- }
667
- if (input.archive_days !== undefined) {
668
- args.push('--archive-days', String(input.archive_days));
669
- }
670
- const cliOptions = { projectRoot: options?.projectRoot };
671
- const result = await runCliCommand('backlog:prune', args, cliOptions);
672
- if (result.success) {
673
- return success({ message: result.stdout || 'Backlog prune complete' });
674
- }
675
- return error(result.stderr || result.error?.message || 'backlog:prune failed', ErrorCodes.BACKLOG_PRUNE_ERROR);
676
- },
677
- };
678
- /**
679
- * docs_sync - Sync agent docs to existing project
680
- */
681
- export const docsSyncTool = {
682
- name: 'docs_sync',
683
- description: 'Sync agent onboarding docs and skills to existing projects',
684
- inputSchema: docsSyncMcpSchema,
685
- async execute(input, options) {
686
- const args = [];
687
- if (input.vendor)
688
- args.push('--vendor', input.vendor);
689
- if (input.force)
690
- args.push('--force');
691
- const cliOptions = { projectRoot: options?.projectRoot };
692
- const result = await runCliCommand('docs:sync', args, cliOptions);
693
- if (result.success) {
694
- return success({ message: result.stdout || 'Docs sync complete' });
695
- }
696
- return error(result.stderr || result.error?.message || 'docs:sync failed', ErrorCodes.DOCS_SYNC_ERROR);
697
- },
698
- };
699
- /**
700
- * gates - Public gates command
701
- */
702
- export const gatesTool = {
703
- name: 'gates',
704
- description: 'Run LumenFlow quality gates',
705
- inputSchema: gatesSchema,
706
- async execute(input, options) {
707
- const args = buildGatesArgs(input);
708
- const cliOptions = {
709
- projectRoot: options?.projectRoot,
710
- timeout: 600000,
711
- };
712
- const result = await runCliCommand('gates', args, cliOptions);
713
- if (result.success) {
714
- return success({ message: result.stdout || SuccessMessages.ALL_GATES_PASSED });
715
- }
716
- return error(result.stderr || result.error?.message || 'gates failed', ErrorCodes.GATES_ALIAS_ERROR);
717
- },
718
- };
719
- /**
720
- * gates_docs - Public docs-only gates alias
721
- */
722
- export const gatesDocsTool = {
723
- name: 'gates_docs',
724
- description: 'Run docs-only quality gates',
725
- inputSchema: gatesSchema,
726
- async execute(input, options) {
727
- const args = buildGatesArgs(input, { forceDocsOnly: true });
728
- const cliOptions = {
729
- projectRoot: options?.projectRoot,
730
- timeout: 600000,
731
- };
732
- const result = await runCliCommand('gates', args, cliOptions);
733
- if (result.success) {
734
- return success({ message: result.stdout || 'Docs-only gates passed' });
735
- }
736
- return error(result.stderr || result.error?.message || 'gates:docs failed', ErrorCodes.GATES_ALIAS_ERROR);
737
- },
738
- };
739
- /**
740
- * lane_health - Diagnose lane configuration issues
741
- */
742
- export const laneHealthTool = {
743
- name: 'lane_health',
744
- description: 'Check lane configuration health (overlaps and coverage gaps)',
745
- inputSchema: laneHealthSchema,
746
- async execute(input, options) {
747
- const args = [];
748
- if (input.json)
749
- args.push('--json');
750
- if (input.verbose)
751
- args.push('--verbose');
752
- if (input.no_coverage)
753
- args.push('--no-coverage');
754
- const cliOptions = { projectRoot: options?.projectRoot };
755
- const result = await runCliCommand('lane:health', args, cliOptions);
756
- if (result.success) {
757
- try {
758
- const data = JSON.parse(result.stdout);
759
- return success(data);
760
- }
761
- catch {
762
- return success({ message: result.stdout || 'Lane health check complete' });
763
- }
764
- }
765
- return error(result.stderr || result.error?.message || 'lane:health failed', ErrorCodes.LANE_HEALTH_ERROR);
766
- },
767
- };
768
- /**
769
- * lane_suggest - Suggest lane definitions from project context
770
- */
771
- export const laneSuggestTool = {
772
- name: 'lane_suggest',
773
- description: 'Generate lane suggestions from codebase context',
774
- inputSchema: laneSuggestSchema,
775
- async execute(input, options) {
776
- const args = [];
777
- if (input.dry_run)
778
- args.push('--dry-run');
779
- if (input.interactive)
780
- args.push('--interactive');
781
- if (input.output)
782
- args.push('--output', input.output);
783
- if (input.json)
784
- args.push('--json');
785
- if (input.no_llm)
786
- args.push('--no-llm');
787
- if (input.include_git)
788
- args.push('--include-git');
789
- const cliOptions = { projectRoot: options?.projectRoot };
790
- const result = await runCliCommand('lane:suggest', args, cliOptions);
791
- if (result.success) {
792
- try {
793
- const data = JSON.parse(result.stdout);
794
- return success(data);
795
- }
796
- catch {
797
- return success({ message: result.stdout || 'Lane suggestions generated' });
798
- }
799
- }
800
- return error(result.stderr || result.error?.message || 'lane:suggest failed', ErrorCodes.LANE_SUGGEST_ERROR);
801
- },
802
- };
803
- /**
804
- * lumenflow - Public initializer command
805
- */
806
- export const lumenflowTool = {
807
- name: 'lumenflow',
808
- description: 'Initialize LumenFlow in a project',
809
- inputSchema: lumenflowInitSchema,
810
- async execute(input, options) {
811
- const args = [];
812
- if (input.client)
813
- args.push('--client', input.client);
814
- if (input.merge)
815
- args.push('--merge');
816
- if (input.full)
817
- args.push('--full');
818
- if (input.minimal)
819
- args.push('--minimal');
820
- if (input.framework)
821
- args.push('--framework', input.framework);
822
- const cliOptions = { projectRoot: options?.projectRoot };
823
- const result = await runCliCommand('lumenflow', args, cliOptions);
824
- if (result.success) {
825
- return success({ message: result.stdout || 'LumenFlow initialized' });
826
- }
827
- return error(result.stderr || result.error?.message || 'lumenflow failed', ErrorCodes.LUMENFLOW_ALIAS_ERROR);
828
- },
829
- };
830
- /**
831
- * lumenflow_gates - Public gates alias
832
- */
833
- export const lumenflowGatesTool = {
834
- name: 'lumenflow_gates',
835
- description: 'Run quality gates (lumenflow-gates alias)',
836
- inputSchema: gatesSchema,
837
- async execute(input, options) {
838
- const args = buildGatesArgs(input);
839
- const cliOptions = {
840
- projectRoot: options?.projectRoot,
841
- timeout: 600000,
842
- };
843
- const result = await runCliCommand('gates', args, cliOptions);
844
- if (result.success) {
845
- return success({ message: result.stdout || SuccessMessages.ALL_GATES_PASSED });
846
- }
847
- return error(result.stderr || result.error?.message || 'lumenflow-gates failed', ErrorCodes.LUMENFLOW_GATES_ERROR);
848
- },
849
- };
850
- /**
851
- * lumenflow_validate - Public validate alias
852
- */
853
- export const lumenflowValidateTool = {
854
- name: 'lumenflow_validate',
855
- description: 'Run validation checks (lumenflow-validate alias)',
856
- inputSchema: validateSchema,
857
- async execute(input, options) {
858
- const args = [];
859
- if (input.id)
860
- args.push('--id', input.id);
861
- if (input.strict)
862
- args.push('--strict');
863
- if (input.done_only)
864
- args.push('--done-only');
865
- const cliOptions = { projectRoot: options?.projectRoot };
866
- const result = await runCliCommand('validate', args, cliOptions);
867
- if (result.success) {
868
- return success({ message: result.stdout || 'Validation passed' });
869
- }
870
- return error(result.stderr || result.error?.message || 'lumenflow-validate failed', ErrorCodes.LUMENFLOW_VALIDATE_ERROR);
871
- },
872
- };
873
- /**
874
- * lumenflow_metrics - Public metrics alias
875
- */
876
- export const lumenflowMetricsTool = {
877
- name: 'lumenflow_metrics',
878
- description: 'View workflow metrics (lumenflow:metrics alias)',
879
- inputSchema: metricsSchema,
880
- async execute(input, options) {
881
- const args = buildMetricsArgs(input);
882
- const cliOptions = { projectRoot: options?.projectRoot };
883
- const result = await runCliCommand('metrics', args, cliOptions);
884
- if (result.success) {
885
- return success({ message: result.stdout || 'Metrics generated' });
886
- }
887
- return error(result.stderr || result.error?.message || 'lumenflow:metrics failed', ErrorCodes.LUMENFLOW_METRICS_ERROR);
888
- },
889
- };
890
- /**
891
- * metrics - Unified workflow metrics command
892
- */
893
- export const metricsTool = {
894
- name: 'metrics',
895
- description: 'View workflow metrics (lanes, dora, flow, all)',
896
- inputSchema: metricsSchema,
897
- async execute(input, options) {
898
- const args = buildMetricsArgs(input);
899
- const cliOptions = { projectRoot: options?.projectRoot };
900
- const result = await runCliCommand('metrics', args, cliOptions);
901
- if (result.success) {
902
- return success({ message: result.stdout || 'Metrics generated' });
903
- }
904
- return error(result.stderr || result.error?.message || 'metrics failed', ErrorCodes.METRICS_ERROR);
905
- },
906
- };
907
- /**
908
- * state_bootstrap - Bootstrap event store from WU YAMLs
909
- */
910
- export const stateBootstrapTool = {
911
- name: 'state_bootstrap',
912
- description: 'Bootstrap state store from existing WU YAML files',
913
- inputSchema: stateBootstrapSchema,
914
- async execute(input, options) {
915
- const args = [];
916
- if (input.execute)
917
- args.push('--execute');
918
- if (input.dry_run)
919
- args.push('--dry-run');
920
- if (input.force)
921
- args.push('--force');
922
- if (input.wu_dir)
923
- args.push('--wu-dir', input.wu_dir);
924
- if (input.state_dir)
925
- args.push('--state-dir', input.state_dir);
926
- const cliOptions = { projectRoot: options?.projectRoot };
927
- const result = await runCliCommand('state:bootstrap', args, cliOptions);
928
- if (result.success) {
929
- return success({ message: result.stdout || 'State bootstrap complete' });
930
- }
931
- return error(result.stderr || result.error?.message || 'state:bootstrap failed', ErrorCodes.STATE_BOOTSTRAP_ERROR);
932
- },
933
- };
934
- /**
935
- * state_cleanup - Run unified state cleanup
936
- */
937
- export const stateCleanupTool = {
938
- name: 'state_cleanup',
939
- description: 'Clean stale state, memory, and signal data',
940
- inputSchema: stateCleanupSchema,
941
- async execute(input, options) {
942
- const args = [];
943
- if (input.dry_run)
944
- args.push('--dry-run');
945
- if (input.signals_only)
946
- args.push('--signals-only');
947
- if (input.memory_only)
948
- args.push('--memory-only');
949
- if (input.events_only)
950
- args.push('--events-only');
951
- if (input.json)
952
- args.push('--json');
953
- if (input.quiet)
954
- args.push('--quiet');
955
- if (input.base_dir)
956
- args.push(CliArgs.BASE_DIR, input.base_dir);
957
- const cliOptions = { projectRoot: options?.projectRoot };
958
- const result = await runCliCommand('state:cleanup', args, cliOptions);
959
- if (result.success) {
960
- return success({ message: result.stdout || 'State cleanup complete' });
961
- }
962
- return error(result.stderr || result.error?.message || 'state:cleanup failed', ErrorCodes.STATE_CLEANUP_ERROR);
963
- },
964
- };
965
- /**
966
- * state_doctor - Diagnose and repair state issues
967
- */
968
- export const stateDoctorTool = {
969
- name: 'state_doctor',
970
- description: 'Diagnose state store integrity issues',
971
- inputSchema: stateDoctorSchema,
972
- async execute(input, options) {
973
- const args = [];
974
- if (input.fix)
975
- args.push('--fix');
976
- if (input.dry_run)
977
- args.push('--dry-run');
978
- if (input.json)
979
- args.push('--json');
980
- if (input.quiet)
981
- args.push('--quiet');
982
- if (input.base_dir)
983
- args.push(CliArgs.BASE_DIR, input.base_dir);
984
- const cliOptions = { projectRoot: options?.projectRoot };
985
- const result = await runCliCommand('state:doctor', args, cliOptions);
986
- if (result.success) {
987
- return success({ message: result.stdout || 'State doctor complete' });
988
- }
989
- return error(result.stderr || result.error?.message || 'state:doctor failed', ErrorCodes.STATE_DOCTOR_ERROR);
990
- },
991
- };
992
- /**
993
- * sync_templates - Sync templates from source docs
994
- */
995
- export const syncTemplatesTool = {
996
- name: 'sync_templates',
997
- description: 'Sync internal docs to CLI templates',
998
- inputSchema: syncTemplatesMcpSchema,
999
- async execute(input, options) {
1000
- const args = [];
1001
- if (input.dry_run)
1002
- args.push('--dry-run');
1003
- if (input.verbose)
1004
- args.push('--verbose');
1005
- if (input.check_drift)
1006
- args.push('--check-drift');
1007
- const cliOptions = { projectRoot: options?.projectRoot };
1008
- const result = await runCliCommand('sync:templates', args, cliOptions);
1009
- if (result.success) {
1010
- return success({ message: result.stdout || 'Template sync complete' });
1011
- }
1012
- return error(result.stderr || result.error?.message || 'sync:templates failed', ErrorCodes.SYNC_TEMPLATES_ALIAS_ERROR);
1013
- },
1014
- };
1015
- // ============================================================================
1016
- // Wave-2 Public Parity Operations (WU-1483)
1017
- // ============================================================================
1018
- /**
1019
- * file_read - Read file content with audit trail
1020
- */
1021
- export const fileReadTool = {
1022
- name: 'file_read',
1023
- description: 'Read a file with optional line ranges and encoding',
1024
- inputSchema: fileReadSchema,
1025
- async execute(input, options) {
1026
- if (!input.path) {
1027
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1028
- }
1029
- const args = ['--path', input.path];
1030
- if (input.encoding)
1031
- args.push(CliArgs.ENCODING, input.encoding);
1032
- if (input.start_line !== undefined)
1033
- args.push('--start-line', String(input.start_line));
1034
- if (input.end_line !== undefined)
1035
- args.push('--end-line', String(input.end_line));
1036
- if (input.max_size !== undefined)
1037
- args.push('--max-size', String(input.max_size));
1038
- const cliOptions = { projectRoot: options?.projectRoot };
1039
- const result = await runCliCommand('file:read', args, cliOptions);
1040
- if (result.success) {
1041
- return success({ content: result.stdout });
1042
- }
1043
- return error(result.stderr || result.error?.message || 'file:read failed', ErrorCodes.FILE_READ_ERROR);
1044
- },
1045
- };
1046
- /**
1047
- * file_write - Write file content with audit trail
1048
- */
1049
- export const fileWriteTool = {
1050
- name: 'file_write',
1051
- description: 'Write content to a file with optional PHI scan',
1052
- inputSchema: fileWriteSchema,
1053
- async execute(input, options) {
1054
- if (!input.path) {
1055
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1056
- }
1057
- if (input.content === undefined) {
1058
- return error(ErrorMessages.CONTENT_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1059
- }
1060
- const args = ['--path', input.path, '--content', input.content];
1061
- if (input.encoding)
1062
- args.push(CliArgs.ENCODING, input.encoding);
1063
- if (input.no_create_dirs)
1064
- args.push('--no-create-dirs');
1065
- if (input.scan_phi)
1066
- args.push('--scan-phi');
1067
- const cliOptions = { projectRoot: options?.projectRoot };
1068
- const result = await runCliCommand('file:write', args, cliOptions);
1069
- if (result.success) {
1070
- return success({ message: result.stdout || 'File written' });
1071
- }
1072
- return error(result.stderr || result.error?.message || 'file:write failed', ErrorCodes.FILE_WRITE_ERROR);
1073
- },
1074
- };
1075
- /**
1076
- * file_edit - Replace exact string matches in a file
1077
- */
1078
- export const fileEditTool = {
1079
- name: 'file_edit',
1080
- description: 'Edit a file via exact string replacement',
1081
- inputSchema: fileEditSchema,
1082
- async execute(input, options) {
1083
- if (!input.path) {
1084
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1085
- }
1086
- if (!input.old_string) {
1087
- return error(ErrorMessages.OLD_STRING_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1088
- }
1089
- if (input.new_string === undefined) {
1090
- return error(ErrorMessages.NEW_STRING_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1091
- }
1092
- const args = [
1093
- '--path',
1094
- input.path,
1095
- '--old-string',
1096
- input.old_string,
1097
- '--new-string',
1098
- input.new_string,
1099
- ];
1100
- if (input.encoding)
1101
- args.push(CliArgs.ENCODING, input.encoding);
1102
- if (input.replace_all)
1103
- args.push('--replace-all');
1104
- const cliOptions = { projectRoot: options?.projectRoot };
1105
- const result = await runCliCommand('file:edit', args, cliOptions);
1106
- if (result.success) {
1107
- return success({ message: result.stdout || 'File edited' });
1108
- }
1109
- return error(result.stderr || result.error?.message || 'file:edit failed', ErrorCodes.FILE_EDIT_ERROR);
1110
- },
1111
- };
1112
- /**
1113
- * file_delete - Delete file or directory with audit trail
1114
- */
1115
- export const fileDeleteTool = {
1116
- name: 'file_delete',
1117
- description: 'Delete files or directories with safety flags',
1118
- inputSchema: fileDeleteSchema,
1119
- async execute(input, options) {
1120
- if (!input.path) {
1121
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1122
- }
1123
- const args = ['--path', input.path];
1124
- if (input.recursive)
1125
- args.push('--recursive');
1126
- if (input.force)
1127
- args.push('--force');
1128
- const cliOptions = { projectRoot: options?.projectRoot };
1129
- const result = await runCliCommand('file:delete', args, cliOptions);
1130
- if (result.success) {
1131
- return success({ message: result.stdout || 'Delete complete' });
1132
- }
1133
- return error(result.stderr || result.error?.message || 'file:delete failed', ErrorCodes.FILE_DELETE_ERROR);
1134
- },
1135
- };
1136
- /**
1137
- * git_status - Show git status
1138
- */
1139
- export const gitStatusTool = {
1140
- name: 'git_status',
1141
- description: 'Show git status with optional porcelain/short modes',
1142
- inputSchema: gitStatusSchema,
1143
- async execute(input, options) {
1144
- const args = [];
1145
- if (input.base_dir)
1146
- args.push(CliArgs.BASE_DIR, input.base_dir);
1147
- if (input.porcelain)
1148
- args.push('--porcelain');
1149
- if (input.short)
1150
- args.push('--short');
1151
- if (input.path)
1152
- args.push(input.path);
1153
- const cliOptions = { projectRoot: options?.projectRoot };
1154
- const result = await runCliCommand('git:status', args, cliOptions);
1155
- if (result.success) {
1156
- return success({ output: result.stdout });
1157
- }
1158
- return error(result.stderr || result.error?.message || 'git:status failed', ErrorCodes.GIT_STATUS_ERROR);
1159
- },
1160
- };
1161
- /**
1162
- * git_diff - Show git diff
1163
- */
1164
- export const gitDiffTool = {
1165
- name: 'git_diff',
1166
- description: 'Show git diff with staged/name-only/stat modes',
1167
- inputSchema: gitDiffSchema,
1168
- async execute(input, options) {
1169
- const args = [];
1170
- if (input.base_dir)
1171
- args.push(CliArgs.BASE_DIR, input.base_dir);
1172
- if (input.staged)
1173
- args.push('--staged');
1174
- if (input.name_only)
1175
- args.push('--name-only');
1176
- if (input.stat)
1177
- args.push('--stat');
1178
- if (input.ref)
1179
- args.push(input.ref);
1180
- if (input.path)
1181
- args.push('--', input.path);
1182
- const cliOptions = { projectRoot: options?.projectRoot };
1183
- const result = await runCliCommand('git:diff', args, cliOptions);
1184
- if (result.success) {
1185
- return success({ output: result.stdout });
1186
- }
1187
- return error(result.stderr || result.error?.message || 'git:diff failed', ErrorCodes.GIT_DIFF_ERROR);
1188
- },
1189
- };
1190
- /**
1191
- * git_log - Show commit history
1192
- */
1193
- export const gitLogTool = {
1194
- name: 'git_log',
1195
- description: 'Show git commit log with filters',
1196
- inputSchema: gitLogSchema,
1197
- async execute(input, options) {
1198
- const args = [];
1199
- if (input.base_dir)
1200
- args.push(CliArgs.BASE_DIR, input.base_dir);
1201
- if (input.oneline)
1202
- args.push('--oneline');
1203
- if (input.max_count !== undefined)
1204
- args.push('-n', String(input.max_count));
1205
- if (input.format)
1206
- args.push('--format', input.format);
1207
- if (input.since)
1208
- args.push('--since', input.since);
1209
- if (input.author)
1210
- args.push('--author', input.author);
1211
- if (input.ref)
1212
- args.push(input.ref);
1213
- const cliOptions = { projectRoot: options?.projectRoot };
1214
- const result = await runCliCommand('git:log', args, cliOptions);
1215
- if (result.success) {
1216
- return success({ output: result.stdout });
1217
- }
1218
- return error(result.stderr || result.error?.message || 'git:log failed', ErrorCodes.GIT_LOG_ERROR);
1219
- },
1220
- };
1221
- /**
1222
- * git_branch - Show branch information
1223
- */
1224
- export const gitBranchTool = {
1225
- name: 'git_branch',
1226
- description: 'Show git branch listing and current branch',
1227
- inputSchema: gitBranchSchema,
1228
- async execute(input, options) {
1229
- const args = [];
1230
- if (input.base_dir)
1231
- args.push(CliArgs.BASE_DIR, input.base_dir);
1232
- if (input.list)
1233
- args.push('--list');
1234
- if (input.all)
1235
- args.push('--all');
1236
- if (input.remotes)
1237
- args.push('--remotes');
1238
- if (input.show_current)
1239
- args.push('--show-current');
1240
- if (input.contains)
1241
- args.push('--contains', input.contains);
1242
- const cliOptions = { projectRoot: options?.projectRoot };
1243
- const result = await runCliCommand('git:branch', args, cliOptions);
1244
- if (result.success) {
1245
- return success({ output: result.stdout });
1246
- }
1247
- return error(result.stderr || result.error?.message || 'git:branch failed', ErrorCodes.GIT_BRANCH_ERROR);
1248
- },
1249
- };
1250
- /**
1251
- * init_plan - Link plan to initiative (alias)
1252
- */
1253
- export const initPlanTool = {
1254
- name: 'init_plan',
1255
- description: 'Link or create a plan for an initiative',
1256
- inputSchema: initiativePlanSchema,
1257
- async execute(input, options) {
1258
- if (!input.initiative) {
1259
- return error(SharedErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1260
- }
1261
- if (!input.plan && !input.create) {
1262
- return error(ErrorMessages.PLAN_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1263
- }
1264
- const args = ['--initiative', input.initiative];
1265
- if (input.plan)
1266
- args.push('--plan', input.plan);
1267
- if (input.create)
1268
- args.push('--create');
1269
- const cliOptions = { projectRoot: options?.projectRoot };
1270
- const result = await runCliCommand('init:plan', args, cliOptions);
1271
- if (result.success) {
1272
- return success({ message: result.stdout || 'Plan linked' });
1273
- }
1274
- return error(result.stderr || result.error?.message || 'init:plan failed', ErrorCodes.INIT_PLAN_ERROR);
1275
- },
1276
- };
1277
- /**
1278
- * plan_create - Create a plan file
1279
- */
1280
- export const planCreateTool = {
1281
- name: 'plan_create',
1282
- description: 'Create a new plan for a WU or initiative',
1283
- inputSchema: planCreateSchema,
1284
- async execute(input, options) {
1285
- if (!input.id) {
1286
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1287
- }
1288
- if (!input.title) {
1289
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1290
- }
1291
- const args = ['--id', input.id, '--title', input.title];
1292
- const cliOptions = { projectRoot: options?.projectRoot };
1293
- const result = await runCliCommand('plan:create', args, cliOptions);
1294
- if (result.success) {
1295
- return success({ message: result.stdout || 'Plan created' });
1296
- }
1297
- return error(result.stderr || result.error?.message || 'plan:create failed', ErrorCodes.PLAN_CREATE_ERROR);
1298
- },
1299
- };
1300
- /**
1301
- * plan_edit - Edit an existing plan section
1302
- */
1303
- export const planEditTool = {
1304
- name: 'plan_edit',
1305
- description: 'Edit or append content to a plan section',
1306
- inputSchema: planEditSchema,
1307
- async execute(input, options) {
1308
- if (!input.id) {
1309
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1310
- }
1311
- if (!input.section) {
1312
- return error(ErrorMessages.SECTION_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1313
- }
1314
- if (!input.content && !input.append) {
1315
- return error(ErrorMessages.CONTENT_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1316
- }
1317
- const args = ['--id', input.id, '--section', input.section];
1318
- if (input.content)
1319
- args.push('--content', input.content);
1320
- if (input.append)
1321
- args.push('--append', input.append);
1322
- const cliOptions = { projectRoot: options?.projectRoot };
1323
- const result = await runCliCommand('plan:edit', args, cliOptions);
1324
- if (result.success) {
1325
- return success({ message: result.stdout || 'Plan edited' });
1326
- }
1327
- return error(result.stderr || result.error?.message || 'plan:edit failed', ErrorCodes.PLAN_EDIT_ERROR);
1328
- },
1329
- };
1330
- /**
1331
- * plan_link - Link plan URI to WU/initiative
1332
- */
1333
- export const planLinkTool = {
1334
- name: 'plan_link',
1335
- description: 'Link an existing plan URI to a WU or initiative',
1336
- inputSchema: planLinkSchema,
1337
- async execute(input, options) {
1338
- if (!input.id) {
1339
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1340
- }
1341
- if (!input.plan) {
1342
- return error(ErrorMessages.PLAN_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1343
- }
1344
- const args = ['--id', input.id, '--plan', input.plan];
1345
- const cliOptions = { projectRoot: options?.projectRoot };
1346
- const result = await runCliCommand('plan:link', args, cliOptions);
1347
- if (result.success) {
1348
- return success({ message: result.stdout || 'Plan linked' });
1349
- }
1350
- return error(result.stderr || result.error?.message || 'plan:link failed', ErrorCodes.PLAN_LINK_ERROR);
1351
- },
1352
- };
1353
- /**
1354
- * plan_promote - Promote plan to approved status
1355
- */
1356
- export const planPromoteTool = {
1357
- name: 'plan_promote',
1358
- description: 'Promote plan from draft to approved status',
1359
- inputSchema: planPromoteSchema,
1360
- async execute(input, options) {
1361
- if (!input.id) {
1362
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1363
- }
1364
- const args = ['--id', input.id];
1365
- if (input.force)
1366
- args.push('--force');
1367
- const cliOptions = { projectRoot: options?.projectRoot };
1368
- const result = await runCliCommand('plan:promote', args, cliOptions);
1369
- if (result.success) {
1370
- return success({ message: result.stdout || 'Plan promoted' });
1371
- }
1372
- return error(result.stderr || result.error?.message || 'plan:promote failed', ErrorCodes.PLAN_PROMOTE_ERROR);
1373
- },
1374
- };
1375
- /**
1376
- * signal_cleanup - Clean stale signals
1377
- */
1378
- export const signalCleanupTool = {
1379
- name: 'signal_cleanup',
1380
- description: 'Cleanup stale signals using TTL policy',
1381
- inputSchema: signalCleanupSchema,
1382
- async execute(input, options) {
1383
- const args = [];
1384
- if (input.dry_run)
1385
- args.push('--dry-run');
1386
- if (input.ttl)
1387
- args.push('--ttl', input.ttl);
1388
- if (input.unread_ttl)
1389
- args.push('--unread-ttl', input.unread_ttl);
1390
- if (input.max_entries !== undefined)
1391
- args.push('--max-entries', String(input.max_entries));
1392
- if (input.json)
1393
- args.push('--json');
1394
- if (input.quiet)
1395
- args.push('--quiet');
1396
- if (input.base_dir)
1397
- args.push(CliArgs.BASE_DIR, input.base_dir);
1398
- const cliOptions = { projectRoot: options?.projectRoot };
1399
- const result = await runCliCommand('signal:cleanup', args, cliOptions);
1400
- if (result.success) {
1401
- return success({ message: result.stdout || 'Signal cleanup complete' });
1402
- }
1403
- return error(result.stderr || result.error?.message || 'signal:cleanup failed', ErrorCodes.SIGNAL_CLEANUP_ERROR);
1404
- },
1405
- };
1406
- /**
1407
- * wu_proto - Create and claim a prototype WU
1408
- */
1409
- export const wuProtoTool = {
1410
- name: 'wu_proto',
1411
- description: 'Create and claim a prototype WU with relaxed validation',
1412
- inputSchema: wuProtoSchema,
1413
- async execute(input, options) {
1414
- if (!input.lane) {
1415
- return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1416
- }
1417
- if (!input.title) {
1418
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1419
- }
1420
- const args = ['--lane', input.lane, '--title', input.title];
1421
- if (input.description)
1422
- args.push(CliArgs.DESCRIPTION, input.description);
1423
- if (Array.isArray(input.code_paths)) {
1424
- for (const codePath of input.code_paths) {
1425
- args.push(CliArgs.CODE_PATHS, String(codePath));
1426
- }
1427
- }
1428
- if (Array.isArray(input.labels) && input.labels.length > 0) {
1429
- args.push('--labels', input.labels.join(','));
1430
- }
1431
- if (input.assigned_to)
1432
- args.push('--assigned-to', input.assigned_to);
1433
- const cliOptions = { projectRoot: options?.projectRoot };
1434
- const result = await runCliCommand('wu:proto', args, cliOptions);
1435
- if (result.success) {
1436
- return success({ message: result.stdout || 'Prototype WU created' });
1437
- }
1438
- return error(result.stderr || result.error?.message || 'wu:proto failed', ErrorCodes.WU_PROTO_ERROR);
1439
- },
1440
- };
1441
- // ============================================================================
1442
- // Additional WU Operations (WU-1422)
1443
- // ============================================================================
1444
- /**
1445
- * wu_block - Block a WU and move it to blocked status
1446
- */
1447
- export const wuBlockTool = {
1448
- name: 'wu_block',
1449
- description: 'Block a Work Unit and move it from in_progress to blocked status',
1450
- // WU-1454: Use shared schema
1451
- inputSchema: wuBlockSchema,
1452
- async execute(input, options) {
1453
- if (!input.id) {
1454
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1455
- }
1456
- if (!input.reason) {
1457
- return error(ErrorMessages.REASON_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1458
- }
1459
- const args = ['--id', input.id, '--reason', input.reason];
1460
- if (input.remove_worktree) {
1461
- args.push('--remove-worktree');
1462
- }
1463
- const cliOptions = { projectRoot: options?.projectRoot };
1464
- const result = await runCliCommand('wu:block', args, cliOptions);
1465
- if (result.success) {
1466
- return success({ message: result.stdout || 'WU blocked successfully' });
1467
- }
1468
- else {
1469
- return error(result.stderr || result.error?.message || 'wu:block failed', ErrorCodes.WU_BLOCK_ERROR);
1470
- }
1471
- },
1472
- };
1473
- /**
1474
- * wu_unblock - Unblock a WU and move it back to in_progress status
1475
- */
1476
- export const wuUnblockTool = {
1477
- name: 'wu_unblock',
1478
- description: 'Unblock a Work Unit and move it from blocked to in_progress status',
1479
- // WU-1454: Use shared schema
1480
- inputSchema: wuUnblockSchema,
1481
- async execute(input, options) {
1482
- if (!input.id) {
1483
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1484
- }
1485
- const args = ['--id', input.id];
1486
- if (input.reason)
1487
- args.push('--reason', input.reason);
1488
- if (input.create_worktree)
1489
- args.push('--create-worktree');
1490
- const cliOptions = { projectRoot: options?.projectRoot };
1491
- const result = await runCliCommand('wu:unblock', args, cliOptions);
1492
- if (result.success) {
1493
- return success({ message: result.stdout || 'WU unblocked successfully' });
1494
- }
1495
- else {
1496
- return error(result.stderr || result.error?.message || 'wu:unblock failed', ErrorCodes.WU_UNBLOCK_ERROR);
1497
- }
1498
- },
1499
- };
1500
- /**
1501
- * wu_edit - Edit WU spec fields
1502
- */
1503
- export const wuEditTool = {
1504
- name: 'wu_edit',
1505
- description: 'Edit Work Unit spec fields with micro-worktree isolation',
1506
- // WU-1454: Use shared schema
1507
- inputSchema: wuEditSchema,
1508
- async execute(input, options) {
1509
- if (!input.id) {
1510
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1511
- }
1512
- const args = ['--id', input.id];
1513
- if (input.description)
1514
- args.push(CliArgs.DESCRIPTION, input.description);
1515
- if (input.acceptance) {
1516
- for (const criterion of input.acceptance) {
1517
- args.push('--acceptance', criterion);
1518
- }
1519
- }
1520
- if (input.notes)
1521
- args.push('--notes', input.notes);
1522
- if (input.code_paths) {
1523
- for (const p of input.code_paths) {
1524
- args.push(CliArgs.CODE_PATHS, p);
1525
- }
1526
- }
1527
- if (input.lane)
1528
- args.push('--lane', input.lane);
1529
- if (input.priority)
1530
- args.push('--priority', input.priority);
1531
- if (input.initiative)
1532
- args.push(CliArgs.INITIATIVE, input.initiative);
1533
- if (input.phase)
1534
- args.push(CliArgs.PHASE, String(input.phase));
1535
- if (input.no_strict)
1536
- args.push('--no-strict');
1537
- const cliOptions = { projectRoot: options?.projectRoot };
1538
- const result = await runCliCommand('wu:edit', args, cliOptions);
1539
- if (result.success) {
1540
- return success({ message: result.stdout || 'WU edited successfully' });
1541
- }
1542
- else {
1543
- return error(result.stderr || result.error?.message || 'wu:edit failed', ErrorCodes.WU_EDIT_ERROR);
1544
- }
1545
- },
1546
- };
1547
- /**
1548
- * wu_release - Release an orphaned WU from in_progress to ready status
1549
- */
1550
- export const wuReleaseTool = {
1551
- name: 'wu_release',
1552
- description: 'Release an orphaned WU from in_progress back to ready state for reclaiming',
1553
- // WU-1454: Use shared schema
1554
- inputSchema: wuReleaseSchema,
1555
- async execute(input, options) {
1556
- if (!input.id) {
1557
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1558
- }
1559
- const args = ['--id', input.id];
1560
- if (input.reason)
1561
- args.push('--reason', input.reason);
1562
- const cliOptions = { projectRoot: options?.projectRoot };
1563
- const result = await runCliCommand('wu:release', args, cliOptions);
1564
- if (result.success) {
1565
- return success({ message: result.stdout || 'WU released successfully' });
1566
- }
1567
- else {
1568
- return error(result.stderr || result.error?.message || 'wu:release failed', ErrorCodes.WU_RELEASE_ERROR);
1569
- }
1570
- },
1571
- };
1572
- /**
1573
- * wu_recover - Analyze and fix WU state inconsistencies
1574
- */
1575
- export const wuRecoverTool = {
1576
- name: 'wu_recover',
1577
- description: 'Analyze and fix WU state inconsistencies',
1578
- // WU-1454: Use shared schema
1579
- inputSchema: wuRecoverSchema,
1580
- async execute(input, options) {
1581
- if (!input.id) {
1582
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1583
- }
1584
- const args = ['--id', input.id];
1585
- if (input.action)
1586
- args.push('--action', input.action);
1587
- if (input.force)
1588
- args.push('--force');
1589
- if (input.json)
1590
- args.push(CliArgs.JSON);
1591
- const cliOptions = { projectRoot: options?.projectRoot };
1592
- const result = await runCliCommand('wu:recover', args, cliOptions);
1593
- if (result.success) {
1594
- try {
1595
- const data = JSON.parse(result.stdout);
1596
- return success(data);
1597
- }
1598
- catch {
1599
- return success({ message: result.stdout || 'WU recovered successfully' });
1600
- }
1601
- }
1602
- else {
1603
- return error(result.stderr || result.error?.message || 'wu:recover failed', ErrorCodes.WU_RECOVER_ERROR);
1604
- }
1605
- },
1606
- };
1607
- /**
1608
- * wu_repair - Unified WU repair tool for state issues
1609
- */
1610
- export const wuRepairTool = {
1611
- name: 'wu_repair',
1612
- description: 'Unified WU repair tool - detect and fix WU state issues',
1613
- // WU-1454: Use shared schema
1614
- inputSchema: wuRepairSchema,
1615
- async execute(input, options) {
1616
- const args = [];
1617
- if (input.id)
1618
- args.push('--id', input.id);
1619
- if (input.check)
1620
- args.push('--check');
1621
- if (input.all)
1622
- args.push('--all');
1623
- if (input.claim)
1624
- args.push('--claim');
1625
- if (input.admin)
1626
- args.push('--admin');
1627
- if (input.repair_state)
1628
- args.push('--repair-state');
1629
- const cliOptions = { projectRoot: options?.projectRoot };
1630
- const result = await runCliCommand('wu:repair', args, cliOptions);
1631
- if (result.success) {
1632
- return success({ message: result.stdout || 'WU repair completed' });
1633
- }
1634
- else {
1635
- return error(result.stderr || result.error?.message || 'wu:repair failed', ErrorCodes.WU_REPAIR_ERROR);
1636
- }
1637
- },
1638
- };
1639
- /**
1640
- * wu_deps - Visualize WU dependency graph
1641
- */
1642
- export const wuDepsTool = {
1643
- name: 'wu_deps',
1644
- description: 'Visualize WU dependency graph',
1645
- // WU-1454: Use shared schema
1646
- inputSchema: wuDepsSchema,
1647
- async execute(input, options) {
1648
- if (!input.id) {
1649
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1650
- }
1651
- const args = ['--id', input.id];
1652
- if (input.format)
1653
- args.push('--format', input.format);
1654
- if (input.depth)
1655
- args.push('--depth', String(input.depth));
1656
- if (input.direction)
1657
- args.push('--direction', input.direction);
1658
- const cliOptions = { projectRoot: options?.projectRoot };
1659
- const result = await runCliCommand('wu:deps', args, cliOptions);
1660
- if (result.success) {
1661
- try {
1662
- const data = JSON.parse(result.stdout);
1663
- return success(data);
1664
- }
1665
- catch {
1666
- return success({ message: result.stdout });
1667
- }
1668
- }
1669
- else {
1670
- return error(result.stderr || result.error?.message || 'wu:deps failed', ErrorCodes.WU_DEPS_ERROR);
1671
- }
1672
- },
1673
- };
1674
- /**
1675
- * wu_prep - Prepare WU for completion (run gates in worktree)
1676
- */
1677
- export const wuPrepTool = {
1678
- name: 'wu_prep',
1679
- description: 'Prepare WU for completion by running gates in worktree',
1680
- // WU-1454: Use shared schema
1681
- inputSchema: wuPrepSchema,
1682
- async execute(input, options) {
1683
- if (!input.id) {
1684
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1685
- }
1686
- const args = ['--id', input.id];
1687
- if (input.docs_only)
1688
- args.push(CliArgs.DOCS_ONLY);
1689
- const cliOptions = {
1690
- projectRoot: options?.projectRoot,
1691
- timeout: 600000, // 10 minutes for gates
1692
- };
1693
- const result = await runCliCommand('wu:prep', args, cliOptions);
1694
- if (result.success) {
1695
- return success({ message: result.stdout || 'WU prep completed' });
1696
- }
1697
- else {
1698
- return error(result.stderr || result.error?.message || 'wu:prep failed', ErrorCodes.WU_PREP_ERROR);
1699
- }
1700
- },
1701
- };
1702
- /**
1703
- * wu_preflight - Fast validation before gates run
1704
- */
1705
- export const wuPreflightTool = {
1706
- name: 'wu_preflight',
1707
- description: 'Fast validation of code_paths and test paths before gates run (under 5 seconds vs 2+ minutes)',
1708
- // WU-1454: Use shared schema
1709
- inputSchema: wuPreflightSchema,
1710
- async execute(input, options) {
1711
- if (!input.id) {
1712
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1713
- }
1714
- const args = ['--id', input.id];
1715
- if (input.worktree)
1716
- args.push('--worktree', input.worktree);
1717
- const cliOptions = { projectRoot: options?.projectRoot };
1718
- const result = await runCliCommand('wu:preflight', args, cliOptions);
1719
- if (result.success) {
1720
- return success({ message: result.stdout || 'Preflight checks passed' });
1721
- }
1722
- else {
1723
- return error(result.stderr || result.error?.message || 'wu:preflight failed', ErrorCodes.WU_PREFLIGHT_ERROR);
1724
- }
1725
- },
1726
- };
1727
- /**
1728
- * wu_prune - Clean stale worktrees
1729
- */
1730
- export const wuPruneTool = {
1731
- name: 'wu_prune',
1732
- description: 'Clean stale worktrees (dry-run by default)',
1733
- // WU-1454: Use shared schema
1734
- inputSchema: wuPruneSchema,
1735
- async execute(input, options) {
1736
- const args = [];
1737
- if (input.execute)
1738
- args.push('--execute');
1739
- const cliOptions = { projectRoot: options?.projectRoot };
1740
- const result = await runCliCommand('wu:prune', args, cliOptions);
1741
- if (result.success) {
1742
- return success({ message: result.stdout || 'Prune completed' });
1743
- }
1744
- else {
1745
- return error(result.stderr || result.error?.message || 'wu:prune failed', ErrorCodes.WU_PRUNE_ERROR);
1746
- }
1747
- },
1748
- };
1749
- /**
1750
- * wu_delete - Safely delete WU YAML files
1751
- */
1752
- export const wuDeleteTool = {
1753
- name: 'wu_delete',
1754
- description: 'Safely delete WU YAML files with micro-worktree isolation',
1755
- // WU-1454: Use shared schema
1756
- inputSchema: wuDeleteSchema,
1757
- async execute(input, options) {
1758
- if (!input.id && !input.batch) {
1759
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1760
- }
1761
- const args = [];
1762
- if (input.id)
1763
- args.push('--id', input.id);
1764
- if (input.dry_run)
1765
- args.push(CliArgs.DRY_RUN);
1766
- if (input.batch)
1767
- args.push('--batch', input.batch);
1768
- const cliOptions = { projectRoot: options?.projectRoot };
1769
- const result = await runCliCommand('wu:delete', args, cliOptions);
1770
- if (result.success) {
1771
- return success({ message: result.stdout || 'WU deleted' });
1772
- }
1773
- else {
1774
- return error(result.stderr || result.error?.message || 'wu:delete failed', ErrorCodes.WU_DELETE_ERROR);
1775
- }
1776
- },
1777
- };
1778
- /**
1779
- * wu_cleanup - Clean up worktree and branch after PR merge
1780
- */
1781
- export const wuCleanupTool = {
1782
- name: 'wu_cleanup',
1783
- description: 'Clean up worktree and branch after PR merge (PR-based completion workflow)',
1784
- // WU-1454: Use shared schema
1785
- inputSchema: wuCleanupSchema,
1786
- async execute(input, options) {
1787
- if (!input.id) {
1788
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1789
- }
1790
- const args = ['--id', input.id];
1791
- if (input.artifacts)
1792
- args.push('--artifacts');
1793
- const cliOptions = { projectRoot: options?.projectRoot };
1794
- const result = await runCliCommand('wu:cleanup', args, cliOptions);
1795
- if (result.success) {
1796
- return success({ message: result.stdout || 'Cleanup complete' });
1797
- }
1798
- else {
1799
- return error(result.stderr || result.error?.message || 'wu:cleanup failed', ErrorCodes.WU_CLEANUP_ERROR);
1800
- }
1801
- },
1802
- };
1803
- /**
1804
- * Build common argument list for wu:brief / wu:delegate prompt tools.
1805
- */
1806
- function buildWuPromptArgs(input) {
1807
- const args = ['--id', input.id];
1808
- if (input.client)
1809
- args.push('--client', input.client);
1810
- if (input.thinking)
1811
- args.push('--thinking');
1812
- if (input.budget)
1813
- args.push('--budget', String(input.budget));
1814
- if (input.parent_wu)
1815
- args.push('--parent-wu', input.parent_wu);
1816
- if (input.no_context)
1817
- args.push('--no-context');
1818
- return args;
1819
- }
1820
- /**
1821
- * wu_brief - Generate handoff prompt for sub-agent WU execution (WU-1603)
1822
- *
1823
- * This is the canonical prompt-generation tool.
1824
- */
1825
- export const wuBriefTool = {
1826
- name: 'wu_brief',
1827
- description: 'Generate handoff prompt for sub-agent WU execution',
1828
- // WU-1454: Use shared schema (same parameters as wu:delegate)
1829
- inputSchema: wuSpawnSchema,
1830
- async execute(input, options) {
1831
- if (!input.id) {
1832
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1833
- }
1834
- const args = buildWuPromptArgs(input);
1835
- const cliOptions = { projectRoot: options?.projectRoot };
1836
- const result = await runCliCommand('wu:brief', args, cliOptions);
1837
- if (result.success) {
1838
- return success({ message: result.stdout || 'Brief prompt generated' });
1839
- }
1840
- else {
1841
- return error(result.stderr || result.error?.message || 'wu:brief failed', ErrorCodes.WU_BRIEF_ERROR);
1842
- }
1843
- },
1844
- };
1845
- /**
1846
- * wu_delegate - Generate prompt and explicitly record delegation lineage intent
1847
- */
1848
- export const wuDelegateTool = {
1849
- name: 'wu_delegate',
1850
- description: 'Generate delegation prompt and record explicit lineage intent',
1851
- inputSchema: wuSpawnSchema,
1852
- async execute(input, options) {
1853
- if (!input.id) {
1854
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1855
- }
1856
- if (!input.parent_wu) {
1857
- return error(ErrorMessages.PARENT_WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1858
- }
1859
- const args = buildWuPromptArgs(input);
1860
- const cliOptions = { projectRoot: options?.projectRoot };
1861
- const result = await runCliCommand('wu:delegate', args, cliOptions);
1862
- if (result.success) {
1863
- return success({ message: result.stdout || 'Delegation prompt generated' });
1864
- }
1865
- else {
1866
- return error(result.stderr || result.error?.message || 'wu:delegate failed', ErrorCodes.WU_DELEGATE_ERROR);
1867
- }
1868
- },
1869
- };
1870
- /**
1871
- * wu_validate - Validate WU YAML files
1872
- */
1873
- export const wuValidateTool = {
1874
- name: 'wu_validate',
1875
- description: 'Validate WU YAML files against schema (strict mode by default)',
1876
- // WU-1454: Use shared schema
1877
- inputSchema: wuValidateSchema,
1878
- async execute(input, options) {
1879
- if (!input.id) {
1880
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1881
- }
1882
- const args = ['--id', input.id];
1883
- if (input.no_strict)
1884
- args.push('--no-strict');
1885
- const cliOptions = { projectRoot: options?.projectRoot };
1886
- const result = await runCliCommand('wu:validate', args, cliOptions);
1887
- if (result.success) {
1888
- return success({ message: result.stdout || 'WU is valid' });
1889
- }
1890
- else {
1891
- return error(result.stderr || result.error?.message || 'wu:validate failed', ErrorCodes.WU_VALIDATE_ERROR);
1892
- }
1893
- },
1894
- };
1895
- /**
1896
- * wu_infer_lane - Suggest lane for a WU based on code paths and description
1897
- */
1898
- export const wuInferLaneTool = {
1899
- name: 'wu_infer_lane',
1900
- description: 'Suggest lane for a WU based on code paths and description',
1901
- // WU-1454: Use shared schema
1902
- inputSchema: wuInferLaneSchema,
1903
- async execute(input, options) {
1904
- const args = [];
1905
- if (input.id)
1906
- args.push('--id', input.id);
1907
- if (input.paths) {
1908
- for (const p of input.paths) {
1909
- args.push('--paths', p);
1910
- }
1911
- }
1912
- if (input.desc)
1913
- args.push('--desc', input.desc);
1914
- const cliOptions = { projectRoot: options?.projectRoot };
1915
- const result = await runCliCommand('wu:infer-lane', args, cliOptions);
1916
- if (result.success) {
1917
- return success({ lane: result.stdout?.trim() || 'Unknown' });
1918
- }
1919
- else {
1920
- return error(result.stderr || result.error?.message || 'wu:infer-lane failed', ErrorCodes.WU_INFER_LANE_ERROR);
1921
- }
1922
- },
1923
- };
1924
- /**
1925
- * wu_unlock_lane - Safely unlock a lane lock with audit logging
1926
- */
1927
- export const wuUnlockLaneTool = {
1928
- name: 'wu_unlock_lane',
1929
- description: 'Safely unlock a lane lock with audit logging',
1930
- // WU-1454: Use shared schema
1931
- inputSchema: wuUnlockLaneSchema,
1932
- async execute(input, options) {
1933
- // If list mode, no lane required
1934
- if (!input.list && !input.lane) {
1935
- return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1936
- }
1937
- const args = [];
1938
- if (input.lane)
1939
- args.push('--lane', input.lane);
1940
- if (input.reason)
1941
- args.push('--reason', input.reason);
1942
- if (input.force)
1943
- args.push('--force');
1944
- if (input.list)
1945
- args.push('--list');
1946
- if (input.status)
1947
- args.push('--status');
1948
- const cliOptions = { projectRoot: options?.projectRoot };
1949
- const result = await runCliCommand('wu:unlock-lane', args, cliOptions);
1950
- if (result.success) {
1951
- try {
1952
- const data = JSON.parse(result.stdout);
1953
- return success(data);
1954
- }
1955
- catch {
1956
- return success({ message: result.stdout || 'Lane unlocked' });
1957
- }
1958
- }
1959
- else {
1960
- return error(result.stderr || result.error?.message || 'wu:unlock-lane failed', ErrorCodes.WU_UNLOCK_LANE_ERROR);
1961
- }
1962
- },
1963
- };
1964
- // ============================================================================
1965
- // Initiative Operations (WU-1424)
1966
- // ============================================================================
1967
- /**
1968
- * Error codes for initiative tools
1969
- */
1970
- const InitiativeErrorCodes = {
1971
- INITIATIVE_LIST_ERROR: 'INITIATIVE_LIST_ERROR',
1972
- INITIATIVE_STATUS_ERROR: 'INITIATIVE_STATUS_ERROR',
1973
- INITIATIVE_CREATE_ERROR: 'INITIATIVE_CREATE_ERROR',
1974
- INITIATIVE_EDIT_ERROR: 'INITIATIVE_EDIT_ERROR',
1975
- INITIATIVE_ADD_WU_ERROR: 'INITIATIVE_ADD_WU_ERROR',
1976
- INITIATIVE_REMOVE_WU_ERROR: 'INITIATIVE_REMOVE_WU_ERROR',
1977
- INITIATIVE_BULK_ASSIGN_ERROR: 'INITIATIVE_BULK_ASSIGN_ERROR',
1978
- INITIATIVE_PLAN_ERROR: 'INITIATIVE_PLAN_ERROR',
1979
- };
1980
- /**
1981
- * Error messages for initiative tools (uses shared messages to avoid duplication)
1982
- */
1983
- const InitiativeErrorMessages = {
1984
- INITIATIVE_REQUIRED: SharedErrorMessages.INITIATIVE_REQUIRED,
1985
- WU_REQUIRED: SharedErrorMessages.WU_REQUIRED,
1986
- };
1987
- /**
1988
- * initiative_list - List all initiatives
1989
- */
1990
- export const initiativeListTool = {
1991
- name: 'initiative_list',
1992
- description: 'List all initiatives with optional status filter',
1993
- // WU-1455: Use shared schema from @lumenflow/core
1994
- inputSchema: initiativeListSchema,
1995
- async execute(input, options) {
1996
- const args = [];
1997
- if (input.status)
1998
- args.push('--status', input.status);
1999
- // WU-1455: Use format field from shared schema
2000
- if (input.format)
2001
- args.push('--format', input.format);
2002
- const cliOptions = { projectRoot: options?.projectRoot };
2003
- const result = await runCliCommand('initiative:list', args, cliOptions);
2004
- if (result.success) {
2005
- try {
2006
- const data = JSON.parse(result.stdout);
2007
- return success(data);
2008
- }
2009
- catch {
2010
- return success({ message: result.stdout });
2011
- }
2012
- }
2013
- else {
2014
- return error(result.stderr || result.error?.message || 'initiative:list failed', InitiativeErrorCodes.INITIATIVE_LIST_ERROR);
2015
- }
2016
- },
2017
- };
2018
- /**
2019
- * initiative_status - Get status of a specific initiative
2020
- */
2021
- export const initiativeStatusTool = {
2022
- name: 'initiative_status',
2023
- description: 'Get detailed status of a specific initiative including WUs and progress',
2024
- // WU-1455: Use shared schema from @lumenflow/core
2025
- inputSchema: initiativeStatusSchema,
2026
- async execute(input, options) {
2027
- if (!input.id) {
2028
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2029
- }
2030
- const args = ['--id', input.id];
2031
- // WU-1455: Use format field from shared schema
2032
- if (input.format)
2033
- args.push('--format', input.format);
2034
- const cliOptions = { projectRoot: options?.projectRoot };
2035
- const result = await runCliCommand('initiative:status', args, cliOptions);
2036
- if (result.success) {
2037
- try {
2038
- const data = JSON.parse(result.stdout);
2039
- return success(data);
2040
- }
2041
- catch {
2042
- return success({ message: result.stdout });
2043
- }
2044
- }
2045
- else {
2046
- return error(result.stderr || result.error?.message || 'initiative:status failed', InitiativeErrorCodes.INITIATIVE_STATUS_ERROR);
2047
- }
2048
- },
2049
- };
2050
- /**
2051
- * initiative_create - Create a new initiative
2052
- */
2053
- export const initiativeCreateTool = {
2054
- name: 'initiative_create',
2055
- description: 'Create a new initiative for multi-phase project orchestration',
2056
- // WU-1455: Use shared schema from @lumenflow/core
2057
- inputSchema: initiativeCreateSchema,
2058
- async execute(input, options) {
2059
- if (!input.id) {
2060
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2061
- }
2062
- if (!input.title) {
2063
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2064
- }
2065
- // WU-1455: Map shared schema fields to CLI flags
2066
- const args = [
2067
- '--id',
2068
- input.id,
2069
- '--slug',
2070
- input.slug,
2071
- '--title',
2072
- input.title,
2073
- ];
2074
- if (input.priority)
2075
- args.push('--priority', input.priority);
2076
- if (input.owner)
2077
- args.push('--owner', input.owner);
2078
- if (input.target_date)
2079
- args.push('--target-date', input.target_date);
2080
- const cliOptions = { projectRoot: options?.projectRoot };
2081
- const result = await runCliCommand('initiative:create', args, cliOptions);
2082
- if (result.success) {
2083
- return success({ message: result.stdout || 'Initiative created successfully' });
2084
- }
2085
- else {
2086
- return error(result.stderr || result.error?.message || 'initiative:create failed', InitiativeErrorCodes.INITIATIVE_CREATE_ERROR);
2087
- }
2088
- },
2089
- };
2090
- /**
2091
- * initiative_edit - Edit initiative fields
2092
- */
2093
- export const initiativeEditTool = {
2094
- name: 'initiative_edit',
2095
- description: 'Edit initiative fields',
2096
- // WU-1455: Use shared schema from @lumenflow/core
2097
- inputSchema: initiativeEditSchema,
2098
- async execute(input, options) {
2099
- if (!input.id) {
2100
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2101
- }
2102
- // WU-1455: Map shared schema fields to CLI flags
2103
- const args = ['--id', input.id];
2104
- if (input.description)
2105
- args.push(CliArgs.DESCRIPTION, input.description);
2106
- if (input.status)
2107
- args.push('--status', input.status);
2108
- if (input.blocked_by)
2109
- args.push('--blocked-by', input.blocked_by);
2110
- if (input.blocked_reason)
2111
- args.push('--blocked-reason', input.blocked_reason);
2112
- if (input.unblock)
2113
- args.push('--unblock');
2114
- if (input.notes)
2115
- args.push('--notes', input.notes);
2116
- if (input.phase_id)
2117
- args.push('--phase-id', input.phase_id);
2118
- if (input.phase_status)
2119
- args.push('--phase-status', input.phase_status);
2120
- if (input.created)
2121
- args.push('--created', input.created);
2122
- if (input.add_lane) {
2123
- for (const lane of input.add_lane) {
2124
- args.push('--add-lane', lane);
2125
- }
2126
- }
2127
- if (input.remove_lane) {
2128
- for (const lane of input.remove_lane) {
2129
- args.push('--remove-lane', lane);
2130
- }
2131
- }
2132
- if (input.add_phase) {
2133
- for (const phase of input.add_phase) {
2134
- args.push('--add-phase', phase);
2135
- }
2136
- }
2137
- if (input.add_success_metric) {
2138
- for (const metric of input.add_success_metric) {
2139
- args.push('--add-success-metric', metric);
2140
- }
2141
- }
2142
- const cliOptions = { projectRoot: options?.projectRoot };
2143
- const result = await runCliCommand('initiative:edit', args, cliOptions);
2144
- if (result.success) {
2145
- return success({ message: result.stdout || 'Initiative edited successfully' });
2146
- }
2147
- else {
2148
- return error(result.stderr || result.error?.message || 'initiative:edit failed', InitiativeErrorCodes.INITIATIVE_EDIT_ERROR);
2149
- }
2150
- },
2151
- };
2152
- /**
2153
- * initiative_add_wu - Add a WU to an initiative
2154
- */
2155
- export const initiativeAddWuTool = {
2156
- name: 'initiative_add_wu',
2157
- description: 'Add a Work Unit to an initiative, optionally assigning to a phase',
2158
- // WU-1455: Use shared schema from @lumenflow/core
2159
- inputSchema: initiativeAddWuSchema,
2160
- async execute(input, options) {
2161
- if (!input.initiative) {
2162
- return error(InitiativeErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2163
- }
2164
- if (!input.wu) {
2165
- return error(InitiativeErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2166
- }
2167
- const args = [CliArgs.INITIATIVE, input.initiative, '--wu', input.wu];
2168
- if (input.phase !== undefined)
2169
- args.push(CliArgs.PHASE, String(input.phase));
2170
- const cliOptions = { projectRoot: options?.projectRoot };
2171
- const result = await runCliCommand('initiative:add-wu', args, cliOptions);
2172
- if (result.success) {
2173
- return success({ message: result.stdout || 'WU added to initiative' });
2174
- }
2175
- else {
2176
- return error(result.stderr || result.error?.message || 'initiative:add-wu failed', InitiativeErrorCodes.INITIATIVE_ADD_WU_ERROR);
2177
- }
2178
- },
2179
- };
2180
- /**
2181
- * initiative_remove_wu - Remove a WU from an initiative
2182
- */
2183
- export const initiativeRemoveWuTool = {
2184
- name: 'initiative_remove_wu',
2185
- description: 'Remove a Work Unit from an initiative',
2186
- // WU-1455: Use shared schema from @lumenflow/core
2187
- inputSchema: initiativeRemoveWuSchema,
2188
- async execute(input, options) {
2189
- if (!input.initiative) {
2190
- return error(InitiativeErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2191
- }
2192
- if (!input.wu) {
2193
- return error(InitiativeErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2194
- }
2195
- const args = [CliArgs.INITIATIVE, input.initiative, '--wu', input.wu];
2196
- const cliOptions = { projectRoot: options?.projectRoot };
2197
- const result = await runCliCommand('initiative:remove-wu', args, cliOptions);
2198
- if (result.success) {
2199
- return success({ message: result.stdout || 'WU removed from initiative' });
2200
- }
2201
- else {
2202
- return error(result.stderr || result.error?.message || 'initiative:remove-wu failed', InitiativeErrorCodes.INITIATIVE_REMOVE_WU_ERROR);
2203
- }
2204
- },
2205
- };
2206
- /**
2207
- * initiative_bulk_assign - Bulk assign WUs to an initiative
2208
- */
2209
- export const initiatiBulkAssignTool = {
2210
- name: 'initiative_bulk_assign',
2211
- description: 'Bulk assign WUs to an initiative based on lane prefix rules',
2212
- // WU-1455: Use shared schema from @lumenflow/core
2213
- inputSchema: initiativeBulkAssignSchema,
2214
- async execute(input, options) {
2215
- // WU-1455: Map shared schema fields to CLI flags
2216
- const args = [];
2217
- if (input.config)
2218
- args.push('--config', input.config);
2219
- if (input.apply)
2220
- args.push('--apply');
2221
- if (input.sync_from_initiative)
2222
- args.push('--reconcile-initiative', input.sync_from_initiative);
2223
- const cliOptions = { projectRoot: options?.projectRoot };
2224
- const result = await runCliCommand('initiative:bulk-assign', args, cliOptions);
2225
- if (result.success) {
2226
- return success({ message: result.stdout || 'Bulk assignment completed' });
2227
- }
2228
- else {
2229
- return error(result.stderr || result.error?.message || 'initiative:bulk-assign failed', InitiativeErrorCodes.INITIATIVE_BULK_ASSIGN_ERROR);
2230
- }
2231
- },
2232
- };
2233
- /**
2234
- * initiative_plan - Link or create a plan for an initiative
2235
- */
2236
- export const initiativePlanTool = {
2237
- name: 'initiative_plan',
2238
- description: 'Link an existing plan or create a new plan template for an initiative',
2239
- // WU-1455: Use shared schema from @lumenflow/core
2240
- inputSchema: initiativePlanSchema,
2241
- async execute(input, options) {
2242
- if (!input.initiative) {
2243
- return error(InitiativeErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2244
- }
2245
- const args = [CliArgs.INITIATIVE, input.initiative];
2246
- if (input.plan)
2247
- args.push('--plan', input.plan);
2248
- if (input.create)
2249
- args.push('--create');
2250
- const cliOptions = { projectRoot: options?.projectRoot };
2251
- const result = await runCliCommand('initiative:plan', args, cliOptions);
2252
- if (result.success) {
2253
- return success({ message: result.stdout || 'Plan linked to initiative' });
2254
- }
2255
- else {
2256
- return error(result.stderr || result.error?.message || 'initiative:plan failed', InitiativeErrorCodes.INITIATIVE_PLAN_ERROR);
2257
- }
2258
- },
2259
- };
2260
- // ============================================================================
2261
- // Memory Operations (WU-1424)
2262
- // ============================================================================
2263
- /**
2264
- * Error codes for memory tools
2265
- */
2266
- const MemoryErrorCodes = {
2267
- MEM_INIT_ERROR: 'MEM_INIT_ERROR',
2268
- MEM_START_ERROR: 'MEM_START_ERROR',
2269
- MEM_READY_ERROR: 'MEM_READY_ERROR',
2270
- MEM_CHECKPOINT_ERROR: 'MEM_CHECKPOINT_ERROR',
2271
- MEM_CLEANUP_ERROR: 'MEM_CLEANUP_ERROR',
2272
- MEM_CONTEXT_ERROR: 'MEM_CONTEXT_ERROR',
2273
- MEM_CREATE_ERROR: 'MEM_CREATE_ERROR',
2274
- MEM_DELETE_ERROR: 'MEM_DELETE_ERROR',
2275
- MEM_EXPORT_ERROR: 'MEM_EXPORT_ERROR',
2276
- MEM_INBOX_ERROR: 'MEM_INBOX_ERROR',
2277
- MEM_SIGNAL_ERROR: 'MEM_SIGNAL_ERROR',
2278
- MEM_SUMMARIZE_ERROR: 'MEM_SUMMARIZE_ERROR',
2279
- MEM_TRIAGE_ERROR: 'MEM_TRIAGE_ERROR',
2280
- MEM_RECOVER_ERROR: 'MEM_RECOVER_ERROR',
2281
- };
2282
- /**
2283
- * Error messages for memory tools (uses shared messages to avoid duplication)
2284
- */
2285
- const MemoryErrorMessages = {
2286
- WU_REQUIRED: SharedErrorMessages.WU_REQUIRED,
2287
- MESSAGE_REQUIRED: 'message is required',
2288
- };
2289
- /**
2290
- * mem_init - Initialize memory for a WU
2291
- */
2292
- export const memInitTool = {
2293
- name: 'mem_init',
2294
- description: 'Initialize memory layer for a Work Unit',
2295
- inputSchema: memInitSchema,
2296
- async execute(input, options) {
2297
- if (!input.wu) {
2298
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2299
- }
2300
- const args = ['--wu', input.wu];
2301
- const cliOptions = { projectRoot: options?.projectRoot };
2302
- const result = await runCliCommand('mem:init', args, cliOptions);
2303
- if (result.success) {
2304
- return success({ message: result.stdout || 'Memory initialized' });
2305
- }
2306
- else {
2307
- return error(result.stderr || result.error?.message || 'mem:init failed', MemoryErrorCodes.MEM_INIT_ERROR);
2308
- }
2309
- },
2310
- };
2311
- /**
2312
- * mem_start - Start a memory session
2313
- */
2314
- export const memStartTool = {
2315
- name: 'mem_start',
2316
- description: 'Start a memory session for a Work Unit',
2317
- inputSchema: memStartSchema,
2318
- async execute(input, options) {
2319
- if (!input.wu) {
2320
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2321
- }
2322
- const args = ['--wu', input.wu];
2323
- if (input.lane)
2324
- args.push('--lane', input.lane);
2325
- const cliOptions = { projectRoot: options?.projectRoot };
2326
- const result = await runCliCommand('mem:start', args, cliOptions);
2327
- if (result.success) {
2328
- return success({ message: result.stdout || 'Session started' });
2329
- }
2330
- else {
2331
- return error(result.stderr || result.error?.message || 'mem:start failed', MemoryErrorCodes.MEM_START_ERROR);
2332
- }
2333
- },
2334
- };
2335
- /**
2336
- * mem_ready - Check pending nodes
2337
- */
2338
- export const memReadyTool = {
2339
- name: 'mem_ready',
2340
- description: 'Check pending memory nodes for a Work Unit',
2341
- inputSchema: memReadySchema,
2342
- async execute(input, options) {
2343
- if (!input.wu) {
2344
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2345
- }
2346
- const args = ['--wu', input.wu];
2347
- const cliOptions = { projectRoot: options?.projectRoot };
2348
- const result = await runCliCommand('mem:ready', args, cliOptions);
2349
- if (result.success) {
2350
- try {
2351
- const data = JSON.parse(result.stdout);
2352
- return success(data);
2353
- }
2354
- catch {
2355
- return success({ message: result.stdout });
2356
- }
2357
- }
2358
- else {
2359
- return error(result.stderr || result.error?.message || 'mem:ready failed', MemoryErrorCodes.MEM_READY_ERROR);
2360
- }
2361
- },
2362
- };
2363
- /**
2364
- * mem_checkpoint - Save progress checkpoint
2365
- */
2366
- export const memCheckpointTool = {
2367
- name: 'mem_checkpoint',
2368
- description: 'Save a progress checkpoint for a Work Unit',
2369
- inputSchema: memCheckpointSchema,
2370
- async execute(input, options) {
2371
- if (!input.wu) {
2372
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2373
- }
2374
- const args = ['--wu', input.wu];
2375
- if (input.message)
2376
- args.push('--message', input.message);
2377
- const cliOptions = { projectRoot: options?.projectRoot };
2378
- const result = await runCliCommand('mem:checkpoint', args, cliOptions);
2379
- if (result.success) {
2380
- return success({ message: result.stdout || 'Checkpoint saved' });
2381
- }
2382
- else {
2383
- return error(result.stderr || result.error?.message || 'mem:checkpoint failed', MemoryErrorCodes.MEM_CHECKPOINT_ERROR);
2384
- }
2385
- },
2386
- };
2387
- /**
2388
- * mem_cleanup - Clean up stale memory data
2389
- */
2390
- export const memCleanupTool = {
2391
- name: 'mem_cleanup',
2392
- description: 'Clean up stale memory data',
2393
- inputSchema: memCleanupSchema,
2394
- async execute(input, options) {
2395
- const args = [];
2396
- if (input.dry_run)
2397
- args.push(CliArgs.DRY_RUN);
2398
- const cliOptions = { projectRoot: options?.projectRoot };
2399
- const result = await runCliCommand('mem:cleanup', args, cliOptions);
2400
- if (result.success) {
2401
- return success({ message: result.stdout || 'Cleanup completed' });
2402
- }
2403
- else {
2404
- return error(result.stderr || result.error?.message || 'mem:cleanup failed', MemoryErrorCodes.MEM_CLEANUP_ERROR);
2405
- }
2406
- },
2407
- };
2408
- /**
2409
- * mem_context - Get context for current lane/WU
2410
- */
2411
- export const memContextTool = {
2412
- name: 'mem_context',
2413
- description: 'Get memory context for a Work Unit, optionally filtered by lane',
2414
- inputSchema: memContextSchema,
2415
- async execute(input, options) {
2416
- if (!input.wu) {
2417
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2418
- }
2419
- const args = ['--wu', input.wu];
2420
- if (input.lane)
2421
- args.push('--lane', input.lane);
2422
- const cliOptions = { projectRoot: options?.projectRoot };
2423
- const result = await runCliCommand('mem:context', args, cliOptions);
2424
- if (result.success) {
2425
- try {
2426
- const data = JSON.parse(result.stdout);
2427
- return success(data);
2428
- }
2429
- catch {
2430
- return success({ message: result.stdout });
2431
- }
2432
- }
2433
- else {
2434
- return error(result.stderr || result.error?.message || 'mem:context failed', MemoryErrorCodes.MEM_CONTEXT_ERROR);
2435
- }
2436
- },
2437
- };
2438
- /**
2439
- * mem_create - Create a memory node
2440
- */
2441
- export const memCreateTool = {
2442
- name: 'mem_create',
2443
- description: 'Create a memory node (e.g., for bug discovery)',
2444
- inputSchema: memCreateSchema,
2445
- async execute(input, options) {
2446
- if (!input.message) {
2447
- return error(MemoryErrorMessages.MESSAGE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2448
- }
2449
- if (!input.wu) {
2450
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2451
- }
2452
- const args = [input.message, '--wu', input.wu];
2453
- if (input.type)
2454
- args.push('--type', input.type);
2455
- if (input.tags)
2456
- args.push('--tags', input.tags.join(','));
2457
- const cliOptions = { projectRoot: options?.projectRoot };
2458
- const result = await runCliCommand('mem:create', args, cliOptions);
2459
- if (result.success) {
2460
- return success({ message: result.stdout || 'Memory node created' });
2461
- }
2462
- else {
2463
- return error(result.stderr || result.error?.message || 'mem:create failed', MemoryErrorCodes.MEM_CREATE_ERROR);
2464
- }
2465
- },
2466
- };
2467
- /**
2468
- * mem_delete - Delete/archive a memory node
2469
- */
2470
- export const memDeleteTool = {
2471
- name: 'mem_delete',
2472
- description: 'Delete or archive a memory node',
2473
- inputSchema: memDeleteSchema,
2474
- async execute(input, options) {
2475
- if (!input.id) {
2476
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2477
- }
2478
- const args = ['--id', input.id];
2479
- const cliOptions = { projectRoot: options?.projectRoot };
2480
- const result = await runCliCommand('mem:delete', args, cliOptions);
2481
- if (result.success) {
2482
- return success({ message: result.stdout || 'Memory node deleted' });
2483
- }
2484
- else {
2485
- return error(result.stderr || result.error?.message || 'mem:delete failed', MemoryErrorCodes.MEM_DELETE_ERROR);
2486
- }
2487
- },
2488
- };
2489
- /**
2490
- * mem_export - Export memory as markdown
2491
- */
2492
- export const memExportTool = {
2493
- name: 'mem_export',
2494
- description: 'Export memory for a Work Unit as markdown or JSON',
2495
- inputSchema: memExportSchema,
2496
- async execute(input, options) {
2497
- if (!input.wu) {
2498
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2499
- }
2500
- const args = ['--wu', input.wu];
2501
- if (input.format)
2502
- args.push('--format', input.format);
2503
- const cliOptions = { projectRoot: options?.projectRoot };
2504
- const result = await runCliCommand('mem:export', args, cliOptions);
2505
- if (result.success) {
2506
- return success({ message: result.stdout });
2507
- }
2508
- else {
2509
- return error(result.stderr || result.error?.message || 'mem:export failed', MemoryErrorCodes.MEM_EXPORT_ERROR);
2510
- }
2511
- },
2512
- };
2513
- /**
2514
- * mem_inbox - Check coordination signals
2515
- */
2516
- export const memInboxTool = {
2517
- name: 'mem_inbox',
2518
- description: 'Check coordination signals from other agents',
2519
- inputSchema: memInboxSchema,
2520
- async execute(input, options) {
2521
- const args = [];
2522
- if (input.since)
2523
- args.push('--since', input.since);
2524
- if (input.wu)
2525
- args.push(CliArgs.WU, input.wu);
2526
- if (input.lane)
2527
- args.push('--lane', input.lane);
2528
- const cliOptions = { projectRoot: options?.projectRoot };
2529
- const result = await runCliCommand('mem:inbox', args, cliOptions);
2530
- if (result.success) {
2531
- try {
2532
- const data = JSON.parse(result.stdout);
2533
- return success(data);
2534
- }
2535
- catch {
2536
- return success({ message: result.stdout });
2537
- }
2538
- }
2539
- else {
2540
- return error(result.stderr || result.error?.message || 'mem:inbox failed', MemoryErrorCodes.MEM_INBOX_ERROR);
2541
- }
2542
- },
2543
- };
2544
- /**
2545
- * mem_signal - Broadcast coordination signal
2546
- */
2547
- export const memSignalTool = {
2548
- name: 'mem_signal',
2549
- description: 'Broadcast a coordination signal to other agents',
2550
- inputSchema: memSignalSchema,
2551
- async execute(input, options) {
2552
- if (!input.message) {
2553
- return error(MemoryErrorMessages.MESSAGE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2554
- }
2555
- if (!input.wu) {
2556
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2557
- }
2558
- const args = [input.message, '--wu', input.wu];
2559
- const cliOptions = { projectRoot: options?.projectRoot };
2560
- const result = await runCliCommand('mem:signal', args, cliOptions);
2561
- if (result.success) {
2562
- return success({ message: result.stdout || 'Signal broadcast' });
2563
- }
2564
- else {
2565
- return error(result.stderr || result.error?.message || 'mem:signal failed', MemoryErrorCodes.MEM_SIGNAL_ERROR);
2566
- }
2567
- },
2568
- };
2569
- /**
2570
- * mem_summarize - Summarize memory context
2571
- */
2572
- export const memSummarizeTool = {
2573
- name: 'mem_summarize',
2574
- description: 'Summarize memory context for a Work Unit',
2575
- inputSchema: memSummarizeSchema,
2576
- async execute(input, options) {
2577
- if (!input.wu) {
2578
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2579
- }
2580
- const args = ['--wu', input.wu];
2581
- const cliOptions = { projectRoot: options?.projectRoot };
2582
- const result = await runCliCommand('mem:summarize', args, cliOptions);
2583
- if (result.success) {
2584
- return success({ message: result.stdout });
2585
- }
2586
- else {
2587
- return error(result.stderr || result.error?.message || 'mem:summarize failed', MemoryErrorCodes.MEM_SUMMARIZE_ERROR);
2588
- }
2589
- },
2590
- };
2591
- /**
2592
- * mem_triage - Triage discovered bugs
2593
- */
2594
- export const memTriageTool = {
2595
- name: 'mem_triage',
2596
- description: 'Triage discovered bugs for a Work Unit, optionally promoting to WU',
2597
- inputSchema: memTriageSchema,
2598
- async execute(input, options) {
2599
- if (!input.wu) {
2600
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2601
- }
2602
- const args = ['--wu', input.wu];
2603
- if (input.promote)
2604
- args.push('--promote', input.promote);
2605
- if (input.lane)
2606
- args.push('--lane', input.lane);
2607
- const cliOptions = { projectRoot: options?.projectRoot };
2608
- const result = await runCliCommand('mem:triage', args, cliOptions);
2609
- if (result.success) {
2610
- try {
2611
- const data = JSON.parse(result.stdout);
2612
- return success(data);
2613
- }
2614
- catch {
2615
- return success({ message: result.stdout });
2616
- }
2617
- }
2618
- else {
2619
- return error(result.stderr || result.error?.message || 'mem:triage failed', MemoryErrorCodes.MEM_TRIAGE_ERROR);
2620
- }
2621
- },
2622
- };
2623
- /**
2624
- * mem_recover - Generate post-compaction recovery context for a Work Unit
2625
- */
2626
- export const memRecoverTool = {
2627
- name: 'mem_recover',
2628
- description: 'Generate recovery context after compaction for a Work Unit',
2629
- inputSchema: memRecoverSchema,
2630
- async execute(input, options) {
2631
- if (!input.wu) {
2632
- return error(MemoryErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2633
- }
2634
- const args = ['--wu', input.wu];
2635
- if (input.max_size !== undefined)
2636
- args.push('--max-size', String(input.max_size));
2637
- if (input.format)
2638
- args.push('--format', input.format);
2639
- if (input.quiet)
2640
- args.push('--quiet');
2641
- if (input.base_dir)
2642
- args.push(CliArgs.BASE_DIR, input.base_dir);
2643
- const cliOptions = { projectRoot: options?.projectRoot };
2644
- const result = await runCliCommand('mem:recover', args, cliOptions);
2645
- if (result.success) {
2646
- if (input.format === 'json') {
2647
- try {
2648
- const data = JSON.parse(result.stdout);
2649
- return success(data);
2650
- }
2651
- catch {
2652
- return success({ message: result.stdout || 'Recovery context generated' });
2653
- }
2654
- }
2655
- return success({ message: result.stdout || 'Recovery context generated' });
2656
- }
2657
- else {
2658
- return error(result.stderr || result.error?.message || 'mem:recover failed', MemoryErrorCodes.MEM_RECOVER_ERROR);
2659
- }
2660
- },
2661
- };
2662
- // ============================================================================
2663
- // Agent Operations (WU-1425)
2664
- // ============================================================================
2665
- /**
2666
- * Error codes for agent tools
2667
- */
2668
- const AgentErrorCodes = {
2669
- AGENT_SESSION_ERROR: 'AGENT_SESSION_ERROR',
2670
- AGENT_SESSION_END_ERROR: 'AGENT_SESSION_END_ERROR',
2671
- AGENT_LOG_ISSUE_ERROR: 'AGENT_LOG_ISSUE_ERROR',
2672
- AGENT_ISSUES_QUERY_ERROR: 'AGENT_ISSUES_QUERY_ERROR',
2673
- };
2674
- /**
2675
- * Error messages for agent tools
2676
- */
2677
- const AgentErrorMessages = {
2678
- WU_REQUIRED: SharedErrorMessages.WU_REQUIRED,
2679
- TIER_REQUIRED: 'tier is required',
2680
- CATEGORY_REQUIRED: 'category is required',
2681
- SEVERITY_REQUIRED: 'severity is required',
2682
- TITLE_REQUIRED: 'title is required',
2683
- DESCRIPTION_REQUIRED: 'description is required',
2684
- };
2685
- /**
2686
- * agent_session - Start an agent session for tracking WU execution
2687
- */
2688
- export const agentSessionTool = {
2689
- name: 'agent_session',
2690
- description: 'Start an agent session for tracking WU execution',
2691
- inputSchema: agentSessionSchema,
2692
- async execute(input, options) {
2693
- if (!input.wu) {
2694
- return error(AgentErrorMessages.WU_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2695
- }
2696
- if (input.tier === undefined || input.tier === null) {
2697
- return error(AgentErrorMessages.TIER_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2698
- }
2699
- const args = ['--wu', input.wu, '--tier', String(input.tier)];
2700
- if (input.agent_type)
2701
- args.push('--agent-type', input.agent_type);
2702
- const cliOptions = { projectRoot: options?.projectRoot };
2703
- const result = await runCliCommand('agent:session', args, cliOptions);
2704
- if (result.success) {
2705
- return success({ message: result.stdout || 'Session started' });
2706
- }
2707
- else {
2708
- return error(result.stderr || result.error?.message || 'agent:session failed', AgentErrorCodes.AGENT_SESSION_ERROR);
2709
- }
2710
- },
2711
- };
2712
- /**
2713
- * agent_session_end - End the current agent session
2714
- */
2715
- export const agentSessionEndTool = {
2716
- name: 'agent_session_end',
2717
- description: 'End the current agent session and return summary',
2718
- inputSchema: agentSessionEndSchema,
2719
- async execute(_input, options) {
2720
- const cliOptions = { projectRoot: options?.projectRoot };
2721
- const result = await runCliCommand('agent:session-end', [], cliOptions);
2722
- if (result.success) {
2723
- try {
2724
- const data = JSON.parse(result.stdout);
2725
- return success(data);
2726
- }
2727
- catch {
2728
- return success({ message: result.stdout || 'Session ended' });
2729
- }
2730
- }
2731
- else {
2732
- return error(result.stderr || result.error?.message || 'agent:session-end failed', AgentErrorCodes.AGENT_SESSION_END_ERROR);
2733
- }
2734
- },
2735
- };
2736
- /**
2737
- * agent_log_issue - Log a workflow issue or incident during agent execution
2738
- */
2739
- export const agentLogIssueTool = {
2740
- name: 'agent_log_issue',
2741
- description: 'Log a workflow issue or incident during agent execution',
2742
- inputSchema: agentLogIssueSchema,
2743
- async execute(input, options) {
2744
- if (!input.category) {
2745
- return error(AgentErrorMessages.CATEGORY_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2746
- }
2747
- if (!input.severity) {
2748
- return error(AgentErrorMessages.SEVERITY_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2749
- }
2750
- if (!input.title) {
2751
- return error(AgentErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2752
- }
2753
- if (!input.description) {
2754
- return error(AgentErrorMessages.DESCRIPTION_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2755
- }
2756
- const args = [
2757
- '--category',
2758
- input.category,
2759
- '--severity',
2760
- input.severity,
2761
- '--title',
2762
- input.title,
2763
- CliArgs.DESCRIPTION,
2764
- input.description,
2765
- ];
2766
- if (input.resolution)
2767
- args.push('--resolution', input.resolution);
2768
- if (input.tags) {
2769
- for (const tag of input.tags) {
2770
- args.push('--tag', tag);
2771
- }
2772
- }
2773
- if (input.step)
2774
- args.push('--step', input.step);
2775
- if (input.files) {
2776
- for (const file of input.files) {
2777
- args.push('--file', file);
2778
- }
2779
- }
2780
- const cliOptions = { projectRoot: options?.projectRoot };
2781
- const result = await runCliCommand('agent:log-issue', args, cliOptions);
2782
- if (result.success) {
2783
- return success({ message: result.stdout || 'Issue logged' });
2784
- }
2785
- else {
2786
- return error(result.stderr || result.error?.message || 'agent:log-issue failed', AgentErrorCodes.AGENT_LOG_ISSUE_ERROR);
2787
- }
2788
- },
2789
- };
2790
- /**
2791
- * agent_issues_query - Query and display logged agent incidents
2792
- */
2793
- export const agentIssuesQueryTool = {
2794
- name: 'agent_issues_query',
2795
- description: 'Query and display logged agent incidents/issues summary',
2796
- inputSchema: agentIssuesQuerySchema,
2797
- async execute(input, options) {
2798
- const args = ['summary'];
2799
- if (input.since)
2800
- args.push('--since', String(input.since));
2801
- if (input.category)
2802
- args.push('--category', input.category);
2803
- if (input.severity)
2804
- args.push('--severity', input.severity);
2805
- const cliOptions = { projectRoot: options?.projectRoot };
2806
- const result = await runCliCommand('agent:issues-query', args, cliOptions);
2807
- if (result.success) {
2808
- return success({ message: result.stdout || 'Query complete' });
2809
- }
2810
- else {
2811
- return error(result.stderr || result.error?.message || 'agent:issues-query failed', AgentErrorCodes.AGENT_ISSUES_QUERY_ERROR);
2812
- }
2813
- },
2814
- };
2815
- // ============================================================================
2816
- // Orchestration Operations (WU-1425)
2817
- // ============================================================================
2818
- /**
2819
- * Error codes for orchestration tools
2820
- */
2821
- const OrchestrationErrorCodes = {
2822
- ORCHESTRATE_INITIATIVE_ERROR: 'ORCHESTRATE_INITIATIVE_ERROR',
2823
- ORCHESTRATE_INIT_STATUS_ERROR: 'ORCHESTRATE_INIT_STATUS_ERROR',
2824
- ORCHESTRATE_MONITOR_ERROR: 'ORCHESTRATE_MONITOR_ERROR',
2825
- };
2826
- /**
2827
- * Error messages for orchestration tools
2828
- */
2829
- const OrchestrationErrorMessages = {
2830
- INITIATIVE_REQUIRED: SharedErrorMessages.INITIATIVE_REQUIRED,
2831
- };
2832
- /**
2833
- * orchestrate_initiative - Orchestrate initiative execution with parallel agent spawning
2834
- */
2835
- export const orchestrateInitiativeTool = {
2836
- name: 'orchestrate_initiative',
2837
- description: 'Orchestrate initiative execution with parallel agent spawning',
2838
- inputSchema: orchestrateInitiativeSchema,
2839
- async execute(input, options) {
2840
- if (!input.initiative) {
2841
- return error(OrchestrationErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2842
- }
2843
- const args = [CliArgs.INITIATIVE, input.initiative];
2844
- if (input.dry_run)
2845
- args.push(CliArgs.DRY_RUN);
2846
- if (input.progress)
2847
- args.push('--progress');
2848
- if (input.checkpoint_per_wave)
2849
- args.push('--checkpoint-per-wave');
2850
- const cliOptions = {
2851
- projectRoot: options?.projectRoot,
2852
- timeout: 300000, // 5 minutes for orchestration
2853
- };
2854
- const result = await runCliCommand('orchestrate:initiative', args, cliOptions);
2855
- if (result.success) {
2856
- return success({ message: result.stdout || 'Orchestration complete' });
2857
- }
2858
- else {
2859
- return error(result.stderr || result.error?.message || 'orchestrate:initiative failed', OrchestrationErrorCodes.ORCHESTRATE_INITIATIVE_ERROR);
2860
- }
2861
- },
2862
- };
2863
- /**
2864
- * orchestrate_init_status - Show initiative progress status
2865
- */
2866
- export const orchestrateInitStatusTool = {
2867
- name: 'orchestrate_init_status',
2868
- description: 'Show compact initiative progress status including WUs and lane availability',
2869
- inputSchema: orchestrateInitStatusSchema,
2870
- async execute(input, options) {
2871
- if (!input.initiative) {
2872
- return error(OrchestrationErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2873
- }
2874
- const args = [CliArgs.INITIATIVE, input.initiative];
2875
- const cliOptions = { projectRoot: options?.projectRoot };
2876
- const result = await runCliCommand('orchestrate:init-status', args, cliOptions);
2877
- if (result.success) {
2878
- return success({ message: result.stdout || 'Status displayed' });
2879
- }
2880
- else {
2881
- return error(result.stderr || result.error?.message || 'orchestrate:init-status failed', OrchestrationErrorCodes.ORCHESTRATE_INIT_STATUS_ERROR);
2882
- }
2883
- },
2884
- };
2885
- /**
2886
- * orchestrate_monitor - Monitor spawned agent progress and spawn health
2887
- */
2888
- export const orchestrateMonitorTool = {
2889
- name: 'orchestrate_monitor',
2890
- description: 'Monitor spawned agent progress and spawn health (stuck detection, zombie locks)',
2891
- inputSchema: orchestrateMonitorSchema,
2892
- async execute(input, options) {
2893
- const args = [];
2894
- if (input.threshold)
2895
- args.push(CliArgs.THRESHOLD, String(input.threshold));
2896
- if (input.recover)
2897
- args.push(CliArgs.RECOVER);
2898
- if (input.dry_run)
2899
- args.push(CliArgs.DRY_RUN);
2900
- if (input.since)
2901
- args.push('--since', input.since);
2902
- if (input.wu)
2903
- args.push(CliArgs.WU, input.wu);
2904
- if (input.signals_only)
2905
- args.push('--signals-only');
2906
- const cliOptions = {
2907
- projectRoot: options?.projectRoot,
2908
- timeout: 180000, // 3 minutes for monitoring
2909
- };
2910
- const result = await runCliCommand('orchestrate:monitor', args, cliOptions);
2911
- if (result.success) {
2912
- return success({ message: result.stdout || 'Monitor complete' });
2913
- }
2914
- else {
2915
- return error(result.stderr || result.error?.message || 'orchestrate:monitor failed', OrchestrationErrorCodes.ORCHESTRATE_MONITOR_ERROR);
2916
- }
2917
- },
2918
- };
2919
- // ============================================================================
2920
- // Spawn Operations (WU-1425)
2921
- // ============================================================================
2922
- /**
2923
- * Error codes for spawn tools
2924
- */
2925
- const SpawnErrorCodes = {
2926
- SPAWN_LIST_ERROR: 'SPAWN_LIST_ERROR',
2927
- };
2928
- /**
2929
- * Error messages for spawn tools
2930
- */
2931
- const SpawnErrorMessages = {
2932
- WU_OR_INITIATIVE_REQUIRED: 'Either wu or initiative is required',
2933
- };
2934
- /**
2935
- * spawn_list - Display spawn trees for WUs or initiatives
2936
- */
2937
- export const spawnListTool = {
2938
- name: 'spawn_list',
2939
- description: 'Display spawn trees for WUs or initiatives',
2940
- inputSchema: spawnListSchema,
2941
- async execute(input, options) {
2942
- if (!input.wu && !input.initiative) {
2943
- return error(SpawnErrorMessages.WU_OR_INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
2944
- }
2945
- const args = [];
2946
- if (input.wu)
2947
- args.push(CliArgs.WU, input.wu);
2948
- if (input.initiative)
2949
- args.push(CliArgs.INITIATIVE, input.initiative);
2950
- if (input.json)
2951
- args.push('--json');
2952
- const cliOptions = { projectRoot: options?.projectRoot };
2953
- const result = await runCliCommand('spawn:list', args, cliOptions);
2954
- if (result.success) {
2955
- try {
2956
- const data = JSON.parse(result.stdout);
2957
- return success(data);
2958
- }
2959
- catch {
2960
- return success({ message: result.stdout || 'Spawn list displayed' });
2961
- }
2962
- }
2963
- else {
2964
- return error(result.stderr || result.error?.message || 'spawn:list failed', SpawnErrorCodes.SPAWN_LIST_ERROR);
2965
- }
2966
- },
2967
- };
2968
- // ============================================================================
2969
- // Flow/Metrics Operations (WU-1426)
2970
- // ============================================================================
2971
- /**
2972
- * flow_bottlenecks - Identify flow bottlenecks
2973
- */
2974
- export const flowBottlenecksTool = {
2975
- name: 'flow_bottlenecks',
2976
- description: 'Identify flow bottlenecks in the workflow (WIP violations, stuck WUs, etc.)',
2977
- inputSchema: flowBottlenecksSchema,
2978
- async execute(input, options) {
2979
- const args = [];
2980
- // WU-1457: Use shared schema fields (limit, format match CLI flags)
2981
- if (input.limit)
2982
- args.push('--limit', String(input.limit));
2983
- if (input.format)
2984
- args.push('--format', input.format);
2985
- // WU-1452: flow:bottlenecks uses --format json, not --json
2986
- if (input.json)
2987
- args.push(...CliArgs.FORMAT_JSON);
2988
- const cliOptions = { projectRoot: options?.projectRoot };
2989
- const result = await runCliCommand('flow:bottlenecks', args, cliOptions);
2990
- if (result.success) {
2991
- try {
2992
- const data = JSON.parse(result.stdout);
2993
- return success(data);
2994
- }
2995
- catch {
2996
- return success({ message: result.stdout || 'Bottleneck analysis complete' });
2997
- }
2998
- }
2999
- else {
3000
- return error(result.stderr || result.error?.message || 'flow:bottlenecks failed', ErrorCodes.FLOW_BOTTLENECKS_ERROR);
3001
- }
3002
- },
3003
- };
3004
- /**
3005
- * flow_report - Generate flow metrics report
3006
- */
3007
- export const flowReportTool = {
3008
- name: 'flow_report',
3009
- description: 'Generate flow metrics report with cycle time, throughput, and other DORA metrics',
3010
- inputSchema: flowReportSchema,
3011
- async execute(input, options) {
3012
- const args = [];
3013
- // WU-1457: Use shared schema field names (start/end match CLI flags)
3014
- if (input.start)
3015
- args.push('--start', input.start);
3016
- if (input.end)
3017
- args.push('--end', input.end);
3018
- if (input.days)
3019
- args.push('--days', String(input.days));
3020
- // WU-1452: flow:report uses --format, not --json
3021
- if (input.format)
3022
- args.push('--format', input.format);
3023
- if (input.json)
3024
- args.push(...CliArgs.FORMAT_JSON);
3025
- const cliOptions = { projectRoot: options?.projectRoot };
3026
- const result = await runCliCommand('flow:report', args, cliOptions);
3027
- if (result.success) {
3028
- try {
3029
- const data = JSON.parse(result.stdout);
3030
- return success(data);
3031
- }
3032
- catch {
3033
- return success({ message: result.stdout || 'Flow report generated' });
3034
- }
3035
- }
3036
- else {
3037
- return error(result.stderr || result.error?.message || 'flow:report failed', ErrorCodes.FLOW_REPORT_ERROR);
3038
- }
3039
- },
3040
- };
3041
- /**
3042
- * metrics_snapshot - Capture metrics snapshot
3043
- */
3044
- export const metricsSnapshotTool = {
3045
- name: 'metrics_snapshot',
3046
- description: 'Capture a snapshot of current LumenFlow metrics',
3047
- inputSchema: metricsSnapshotSchema,
3048
- async execute(_input, options) {
3049
- // WU-1452: metrics:snapshot always outputs JSON (writes to file); no --json flag exists
3050
- const args = [];
3051
- const cliOptions = { projectRoot: options?.projectRoot };
3052
- const result = await runCliCommand('metrics:snapshot', args, cliOptions);
3053
- if (result.success) {
3054
- try {
3055
- const data = JSON.parse(result.stdout);
3056
- return success(data);
3057
- }
3058
- catch {
3059
- return success({ message: result.stdout || 'Metrics snapshot captured' });
3060
- }
3061
- }
3062
- else {
3063
- return error(result.stderr || result.error?.message || 'metrics:snapshot failed', ErrorCodes.METRICS_SNAPSHOT_ERROR);
3064
- }
3065
- },
3066
- };
3067
- // ============================================================================
3068
- // Validation Operations (WU-1426)
3069
- // ============================================================================
3070
- /**
3071
- * validate - Validate WU YAML files
3072
- */
3073
- export const validateTool = {
3074
- name: 'validate',
3075
- description: 'Validate WU YAML files and status consistency',
3076
- inputSchema: validateSchema,
3077
- async execute(input, options) {
3078
- const args = [];
3079
- if (input.id)
3080
- args.push('--id', input.id);
3081
- if (input.strict)
3082
- args.push('--strict');
3083
- if (input.done_only)
3084
- args.push('--done-only');
3085
- const cliOptions = { projectRoot: options?.projectRoot };
3086
- const result = await runCliCommand('validate', args, cliOptions);
3087
- if (result.success) {
3088
- return success({ message: result.stdout || 'Validation passed' });
3089
- }
3090
- else {
3091
- return error(result.stderr || result.error?.message || 'Validation failed', ErrorCodes.VALIDATE_ERROR);
3092
- }
3093
- },
3094
- };
3095
- /**
3096
- * validate_agent_skills - Validate agent skill definitions
3097
- */
3098
- export const validateAgentSkillsTool = {
3099
- name: 'validate_agent_skills',
3100
- description: 'Validate agent skill definitions in .claude/skills/',
3101
- inputSchema: validateAgentSkillsSchema,
3102
- async execute(input, options) {
3103
- const args = [];
3104
- if (input.skill)
3105
- args.push('--skill', input.skill);
3106
- const cliOptions = { projectRoot: options?.projectRoot };
3107
- const result = await runCliCommand('validate:agent-skills', args, cliOptions);
3108
- if (result.success) {
3109
- return success({ message: result.stdout || 'All skills valid' });
3110
- }
3111
- else {
3112
- return error(result.stderr || result.error?.message || 'validate:agent-skills failed', ErrorCodes.VALIDATE_AGENT_SKILLS_ERROR);
3113
- }
3114
- },
3115
- };
3116
- /**
3117
- * validate_agent_sync - Validate agent sync state
3118
- */
3119
- export const validateAgentSyncTool = {
3120
- name: 'validate_agent_sync',
3121
- description: 'Validate agent synchronization state',
3122
- inputSchema: validateAgentSyncSchema,
3123
- async execute(_input, options) {
3124
- const cliOptions = { projectRoot: options?.projectRoot };
3125
- const result = await runCliCommand('validate:agent-sync', [], cliOptions);
3126
- if (result.success) {
3127
- return success({ message: result.stdout || 'Agent sync valid' });
3128
- }
3129
- else {
3130
- return error(result.stderr || result.error?.message || 'validate:agent-sync failed', ErrorCodes.VALIDATE_AGENT_SYNC_ERROR);
3131
- }
3132
- },
3133
- };
3134
- /**
3135
- * validate_backlog_sync - Validate backlog synchronization
3136
- */
3137
- export const validateBacklogSyncTool = {
3138
- name: 'validate_backlog_sync',
3139
- description: 'Validate backlog synchronization between WU YAMLs and backlog.md',
3140
- inputSchema: validateBacklogSyncSchema,
3141
- async execute(_input, options) {
3142
- const cliOptions = { projectRoot: options?.projectRoot };
3143
- const result = await runCliCommand('validate:backlog-sync', [], cliOptions);
3144
- if (result.success) {
3145
- return success({ message: result.stdout || 'Backlog sync valid' });
3146
- }
3147
- else {
3148
- return error(result.stderr || result.error?.message || 'validate:backlog-sync failed', ErrorCodes.VALIDATE_BACKLOG_SYNC_ERROR);
3149
- }
3150
- },
3151
- };
3152
- /**
3153
- * validate_skills_spec - Validate skills specification
3154
- */
3155
- export const validateSkillsSpecTool = {
3156
- name: 'validate_skills_spec',
3157
- description: 'Validate skills specification files',
3158
- inputSchema: validateSkillsSpecSchema,
3159
- async execute(_input, options) {
3160
- const cliOptions = { projectRoot: options?.projectRoot };
3161
- const result = await runCliCommand('validate:skills-spec', [], cliOptions);
3162
- if (result.success) {
3163
- return success({ message: result.stdout || 'Skills spec valid' });
3164
- }
3165
- else {
3166
- return error(result.stderr || result.error?.message || 'validate:skills-spec failed', ErrorCodes.VALIDATE_SKILLS_SPEC_ERROR);
3167
- }
3168
- },
3169
- };
3170
- // ============================================================================
3171
- // Setup/LumenFlow Operations (WU-1426)
3172
- // ============================================================================
3173
- /**
3174
- * lumenflow_init - Initialize LumenFlow in a project
3175
- */
3176
- export const lumenflowInitTool = {
3177
- name: 'lumenflow_init',
3178
- description: 'Initialize LumenFlow workflow framework in a project',
3179
- inputSchema: lumenflowInitSchema,
3180
- async execute(input, options) {
3181
- const args = [];
3182
- if (input.client)
3183
- args.push('--client', input.client);
3184
- if (input.merge)
3185
- args.push('--merge');
3186
- const cliOptions = { projectRoot: options?.projectRoot };
3187
- const result = await runCliCommand('lumenflow', args, cliOptions);
3188
- if (result.success) {
3189
- return success({ message: result.stdout || 'LumenFlow initialized' });
3190
- }
3191
- else {
3192
- return error(result.stderr || result.error?.message || 'lumenflow failed', ErrorCodes.LUMENFLOW_INIT_ERROR);
3193
- }
3194
- },
3195
- };
3196
- /**
3197
- * lumenflow_doctor - Diagnose LumenFlow configuration
3198
- */
3199
- export const lumenflowDoctorTool = {
3200
- name: 'lumenflow_doctor',
3201
- description: 'Diagnose LumenFlow configuration and safety components',
3202
- inputSchema: lumenflowDoctorSchema,
3203
- async execute(_input, options) {
3204
- const cliOptions = { projectRoot: options?.projectRoot };
3205
- const result = await runCliCommand('lumenflow:doctor', [], cliOptions);
3206
- if (result.success) {
3207
- return success({ message: result.stdout || 'LumenFlow safety: ACTIVE' });
3208
- }
3209
- else {
3210
- return error(result.stderr || result.error?.message || 'Doctor found issues', ErrorCodes.LUMENFLOW_DOCTOR_ERROR);
3211
- }
3212
- },
3213
- };
3214
- /**
3215
- * lumenflow_integrate - Generate enforcement hooks for a client
3216
- */
3217
- export const lumenflowIntegrateTool = {
3218
- name: 'lumenflow_integrate',
3219
- description: 'Generate enforcement hooks for a specific client (e.g., claude-code)',
3220
- inputSchema: lumenflowIntegrateSchema,
3221
- async execute(input, options) {
3222
- if (!input.client) {
3223
- return error(ErrorMessages.CLIENT_REQUIRED, ErrorCodes.MISSING_PARAMETER);
3224
- }
3225
- const args = ['--client', input.client];
3226
- const cliOptions = { projectRoot: options?.projectRoot };
3227
- const result = await runCliCommand('lumenflow:integrate', args, cliOptions);
3228
- if (result.success) {
3229
- return success({ message: result.stdout || 'Hooks generated' });
3230
- }
3231
- else {
3232
- return error(result.stderr || result.error?.message || 'lumenflow:integrate failed', ErrorCodes.LUMENFLOW_INTEGRATE_ERROR);
3233
- }
3234
- },
3235
- };
3236
- /**
3237
- * lumenflow_upgrade - Upgrade LumenFlow packages
3238
- */
3239
- export const lumenflowUpgradeTool = {
3240
- name: 'lumenflow_upgrade',
3241
- description: 'Upgrade LumenFlow packages to latest versions',
3242
- inputSchema: lumenflowUpgradeSchema,
3243
- async execute(_input, options) {
3244
- const cliOptions = { projectRoot: options?.projectRoot };
3245
- const result = await runCliCommand('lumenflow:upgrade', [], cliOptions);
3246
- if (result.success) {
3247
- return success({ message: result.stdout || 'LumenFlow upgraded' });
3248
- }
3249
- else {
3250
- return error(result.stderr || result.error?.message || 'lumenflow:upgrade failed', ErrorCodes.LUMENFLOW_UPGRADE_ERROR);
3251
- }
3252
- },
3253
- };
3254
- /**
3255
- * lumenflow_commands - List all available CLI commands
3256
- */
3257
- export const lumenflowCommandsTool = {
3258
- name: 'lumenflow_commands',
3259
- description: 'List all available LumenFlow CLI commands',
3260
- inputSchema: lumenflowCommandsSchema,
3261
- async execute(_input, options) {
3262
- const cliOptions = { projectRoot: options?.projectRoot };
3263
- const result = await runCliCommand('lumenflow', ['commands'], cliOptions);
3264
- if (result.success) {
3265
- return success({ message: result.stdout || 'Commands listed' });
3266
- }
3267
- else {
3268
- return error(result.stderr || result.error?.message || 'lumenflow commands failed', ErrorCodes.LUMENFLOW_COMMANDS_ERROR);
3269
- }
3270
- },
3271
- };
3272
- /**
3273
- * lumenflow_docs_sync - Sync agent documentation
3274
- */
3275
- export const lumenflowDocsSyncTool = {
3276
- name: 'lumenflow_docs_sync',
3277
- description: 'Sync agent documentation after upgrading LumenFlow packages',
3278
- inputSchema: docsSyncSchema,
3279
- async execute(_input, options) {
3280
- const cliOptions = { projectRoot: options?.projectRoot };
3281
- const result = await runCliCommand('docs:sync', [], cliOptions);
3282
- if (result.success) {
3283
- return success({ message: result.stdout || 'Docs synced' });
3284
- }
3285
- else {
3286
- return error(result.stderr || result.error?.message || 'docs:sync failed', ErrorCodes.LUMENFLOW_DOCS_SYNC_ERROR);
3287
- }
3288
- },
3289
- };
3290
- /**
3291
- * lumenflow_release - Run release workflow
3292
- */
3293
- export const lumenflowReleaseTool = {
3294
- name: 'lumenflow_release',
3295
- description: 'Run LumenFlow release workflow (versioning, npm publish)',
3296
- inputSchema: releaseSchema,
3297
- async execute(input, options) {
3298
- const args = [];
3299
- if (input.dry_run)
3300
- args.push(CliArgs.DRY_RUN);
3301
- const cliOptions = { projectRoot: options?.projectRoot };
3302
- const result = await runCliCommand('lumenflow:release', args, cliOptions);
3303
- if (result.success) {
3304
- return success({ message: result.stdout || 'Release complete' });
3305
- }
3306
- else {
3307
- return error(result.stderr || result.error?.message || 'release failed', ErrorCodes.LUMENFLOW_RELEASE_ERROR);
3308
- }
3309
- },
3310
- };
3311
- /**
3312
- * lumenflow_sync_templates - Sync templates to project
3313
- */
3314
- export const lumenflowSyncTemplatesTool = {
3315
- name: 'lumenflow_sync_templates',
3316
- description: 'Sync LumenFlow templates to the project',
3317
- inputSchema: syncTemplatesSchema,
3318
- async execute(_input, options) {
3319
- const cliOptions = { projectRoot: options?.projectRoot };
3320
- const result = await runCliCommand('sync:templates', [], cliOptions);
3321
- if (result.success) {
3322
- return success({ message: result.stdout || 'Templates synced' });
3323
- }
3324
- else {
3325
- return error(result.stderr || result.error?.message || 'sync:templates failed', ErrorCodes.LUMENFLOW_SYNC_TEMPLATES_ERROR);
3326
- }
3327
- },
3328
- };
26
+ * WU-1457: All remaining commands use shared schemas
27
+ * WU-1482: Wave-1 public parity tools
28
+ * WU-1483: Wave-2 public parity tools
29
+ */
30
+ // Re-export domain tools -- context/read operations
31
+ export { contextGetTool, wuListTool } from './tools/context-tools.js';
32
+ // Re-export domain tools -- WU lifecycle
33
+ export { wuStatusTool, wuCreateTool, wuClaimTool, wuDoneTool, gatesRunTool, wuBlockTool, wuUnblockTool, wuEditTool, wuReleaseTool, wuRecoverTool, wuRepairTool, wuDepsTool, wuPrepTool, wuPreflightTool, wuPruneTool, wuDeleteTool, wuCleanupTool, wuBriefTool, wuDelegateTool, wuValidateTool, wuInferLaneTool, wuUnlockLaneTool, } from './tools/wu-tools.js';
34
+ // Re-export domain tools -- initiative
35
+ export { initiativeListTool, initiativeStatusTool, initiativeCreateTool, initiativeEditTool, initiativeAddWuTool, initiativeRemoveWuTool, initiatiBulkAssignTool, initiativePlanTool, } from './tools/initiative-tools.js';
36
+ // Re-export domain tools -- memory
37
+ export { memInitTool, memStartTool, memReadyTool, memCheckpointTool, memCleanupTool, memContextTool, memCreateTool, memDeleteTool, memExportTool, memInboxTool, memSignalTool, memSummarizeTool, memTriageTool, memRecoverTool, } from './tools/memory-tools.js';
38
+ // Re-export domain tools -- agent
39
+ export { agentSessionTool, agentSessionEndTool, agentLogIssueTool, agentIssuesQueryTool, } from './tools/agent-tools.js';
40
+ // Re-export domain tools -- orchestration + delegation
41
+ export { orchestrateInitiativeTool, orchestrateInitStatusTool, orchestrateMonitorTool, delegationListTool, } from './tools/orchestration-tools.js';
42
+ // Re-export domain tools -- flow/metrics
43
+ export { flowBottlenecksTool, flowReportTool, metricsSnapshotTool, lumenflowMetricsTool, metricsTool, } from './tools/flow-tools.js';
44
+ // Re-export domain tools -- validation
45
+ export { validateTool, validateAgentSkillsTool, validateAgentSyncTool, validateBacklogSyncTool, validateSkillsSpecTool, lumenflowValidateTool, } from './tools/validation-tools.js';
46
+ // Re-export domain tools -- setup
47
+ export { lumenflowInitTool, lumenflowDoctorTool, lumenflowIntegrateTool, lumenflowUpgradeTool, lumenflowCommandsTool, lumenflowDocsSyncTool, lumenflowReleaseTool, lumenflowSyncTemplatesTool, } from './tools/setup-tools.js';
48
+ // Re-export domain tools -- wave-1/wave-2 parity
49
+ export { backlogPruneTool, docsSyncTool, gatesTool, gatesDocsTool, laneHealthTool, laneSuggestTool, lumenflowTool, lumenflowGatesTool, stateBootstrapTool, stateCleanupTool, stateDoctorTool, syncTemplatesTool, fileReadTool, fileWriteTool, fileEditTool, fileDeleteTool, gitStatusTool, gitDiffTool, gitLogTool, gitBranchTool, initPlanTool, planCreateTool, planEditTool, planLinkTool, planPromoteTool, signalCleanupTool, wuProtoTool, } from './tools/parity-tools.js';
50
+ import { contextGetTool, wuListTool } from './tools/context-tools.js';
51
+ import { wuStatusTool, wuCreateTool, wuClaimTool, wuDoneTool, gatesRunTool, wuBlockTool, wuUnblockTool, wuEditTool, wuReleaseTool, wuRecoverTool, wuRepairTool, wuDepsTool, wuPrepTool, wuPreflightTool, wuPruneTool, wuDeleteTool, wuCleanupTool, wuBriefTool, wuDelegateTool, wuValidateTool, wuInferLaneTool, wuUnlockLaneTool, } from './tools/wu-tools.js';
52
+ import { initiativeListTool, initiativeStatusTool, initiativeCreateTool, initiativeEditTool, initiativeAddWuTool, initiativeRemoveWuTool, initiatiBulkAssignTool, initiativePlanTool, } from './tools/initiative-tools.js';
53
+ import { memInitTool, memStartTool, memReadyTool, memCheckpointTool, memCleanupTool, memContextTool, memCreateTool, memDeleteTool, memExportTool, memInboxTool, memSignalTool, memSummarizeTool, memTriageTool, memRecoverTool, } from './tools/memory-tools.js';
54
+ import { agentSessionTool, agentSessionEndTool, agentLogIssueTool, agentIssuesQueryTool, } from './tools/agent-tools.js';
55
+ import { orchestrateInitiativeTool, orchestrateInitStatusTool, orchestrateMonitorTool, delegationListTool, } from './tools/orchestration-tools.js';
56
+ import { flowBottlenecksTool, flowReportTool, metricsSnapshotTool, lumenflowMetricsTool, metricsTool, } from './tools/flow-tools.js';
57
+ import { validateTool, validateAgentSkillsTool, validateAgentSyncTool, validateBacklogSyncTool, validateSkillsSpecTool, lumenflowValidateTool, } from './tools/validation-tools.js';
58
+ import { lumenflowInitTool, lumenflowDoctorTool, lumenflowIntegrateTool, lumenflowUpgradeTool, lumenflowCommandsTool, lumenflowDocsSyncTool, lumenflowReleaseTool, lumenflowSyncTemplatesTool, } from './tools/setup-tools.js';
59
+ import { backlogPruneTool, docsSyncTool, gatesTool, gatesDocsTool, laneHealthTool, laneSuggestTool, lumenflowTool, lumenflowGatesTool, stateBootstrapTool, stateCleanupTool, stateDoctorTool, syncTemplatesTool, fileReadTool, fileWriteTool, fileEditTool, fileDeleteTool, gitStatusTool, gitDiffTool, gitLogTool, gitBranchTool, initPlanTool, planCreateTool, planEditTool, planLinkTool, planPromoteTool, signalCleanupTool, wuProtoTool, } from './tools/parity-tools.js';
3329
60
  /**
3330
61
  * MCP parity exclusions for tools that are intentionally MCP-only or maintainer-only.
3331
62
  *
@@ -3462,8 +193,8 @@ export const allTools = [
3462
193
  orchestrateInitiativeTool,
3463
194
  orchestrateInitStatusTool,
3464
195
  orchestrateMonitorTool,
3465
- // WU-1425: Spawn tools
3466
- spawnListTool,
196
+ // WU-1425: Delegation tools
197
+ delegationListTool,
3467
198
  // WU-1426: Flow/Metrics tools
3468
199
  flowBottlenecksTool,
3469
200
  flowReportTool,