@lumenflow/mcp 3.1.2 → 3.1.3

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 (95) hide show
  1. package/package.json +5 -5
  2. package/dist/bin.d.ts +0 -16
  3. package/dist/bin.d.ts.map +0 -1
  4. package/dist/bin.js.map +0 -1
  5. package/dist/cli-runner.d.ts +0 -58
  6. package/dist/cli-runner.d.ts.map +0 -1
  7. package/dist/cli-runner.js +0 -164
  8. package/dist/cli-runner.js.map +0 -1
  9. package/dist/index.d.ts +0 -37
  10. package/dist/index.d.ts.map +0 -1
  11. package/dist/index.js.map +0 -1
  12. package/dist/mcp-constants.d.ts +0 -173
  13. package/dist/mcp-constants.d.ts.map +0 -1
  14. package/dist/mcp-constants.js +0 -193
  15. package/dist/mcp-constants.js.map +0 -1
  16. package/dist/resources.d.ts +0 -53
  17. package/dist/resources.d.ts.map +0 -1
  18. package/dist/resources.js +0 -131
  19. package/dist/resources.js.map +0 -1
  20. package/dist/runtime-cache.d.ts +0 -7
  21. package/dist/runtime-cache.d.ts.map +0 -1
  22. package/dist/runtime-cache.js +0 -28
  23. package/dist/runtime-cache.js.map +0 -1
  24. package/dist/runtime-tool-resolver.constants.d.ts +0 -33
  25. package/dist/runtime-tool-resolver.constants.d.ts.map +0 -1
  26. package/dist/runtime-tool-resolver.constants.js +0 -35
  27. package/dist/runtime-tool-resolver.constants.js.map +0 -1
  28. package/dist/runtime-tool-resolver.d.ts +0 -5
  29. package/dist/runtime-tool-resolver.d.ts.map +0 -1
  30. package/dist/runtime-tool-resolver.js +0 -2030
  31. package/dist/runtime-tool-resolver.js.map +0 -1
  32. package/dist/server.d.ts +0 -58
  33. package/dist/server.d.ts.map +0 -1
  34. package/dist/server.js +0 -219
  35. package/dist/server.js.map +0 -1
  36. package/dist/tools/agent-tools.d.ts +0 -18
  37. package/dist/tools/agent-tools.d.ts.map +0 -1
  38. package/dist/tools/agent-tools.js +0 -235
  39. package/dist/tools/agent-tools.js.map +0 -1
  40. package/dist/tools/context-tools.d.ts +0 -13
  41. package/dist/tools/context-tools.d.ts.map +0 -1
  42. package/dist/tools/context-tools.js +0 -58
  43. package/dist/tools/context-tools.js.map +0 -1
  44. package/dist/tools/flow-tools.d.ts +0 -22
  45. package/dist/tools/flow-tools.d.ts.map +0 -1
  46. package/dist/tools/flow-tools.js +0 -130
  47. package/dist/tools/flow-tools.js.map +0 -1
  48. package/dist/tools/initiative-tools.d.ts +0 -34
  49. package/dist/tools/initiative-tools.d.ts.map +0 -1
  50. package/dist/tools/initiative-tools.js +0 -420
  51. package/dist/tools/initiative-tools.js.map +0 -1
  52. package/dist/tools/memory-tools.d.ts +0 -58
  53. package/dist/tools/memory-tools.d.ts.map +0 -1
  54. package/dist/tools/memory-tools.js +0 -523
  55. package/dist/tools/memory-tools.js.map +0 -1
  56. package/dist/tools/orchestration-tools.d.ts +0 -18
  57. package/dist/tools/orchestration-tools.d.ts.map +0 -1
  58. package/dist/tools/orchestration-tools.js +0 -202
  59. package/dist/tools/orchestration-tools.js.map +0 -1
  60. package/dist/tools/parity-tools.d.ts +0 -122
  61. package/dist/tools/parity-tools.d.ts.map +0 -1
  62. package/dist/tools/parity-tools.js +0 -1479
  63. package/dist/tools/parity-tools.js.map +0 -1
  64. package/dist/tools/runtime-task-constants.d.ts +0 -19
  65. package/dist/tools/runtime-task-constants.d.ts.map +0 -1
  66. package/dist/tools/runtime-task-constants.js +0 -21
  67. package/dist/tools/runtime-task-constants.js.map +0 -1
  68. package/dist/tools/runtime-task-tools.d.ts +0 -10
  69. package/dist/tools/runtime-task-tools.d.ts.map +0 -1
  70. package/dist/tools/runtime-task-tools.js +0 -116
  71. package/dist/tools/runtime-task-tools.js.map +0 -1
  72. package/dist/tools/setup-tools.d.ts +0 -34
  73. package/dist/tools/setup-tools.d.ts.map +0 -1
  74. package/dist/tools/setup-tools.js +0 -254
  75. package/dist/tools/setup-tools.js.map +0 -1
  76. package/dist/tools/validation-tools.d.ts +0 -26
  77. package/dist/tools/validation-tools.d.ts.map +0 -1
  78. package/dist/tools/validation-tools.js +0 -180
  79. package/dist/tools/validation-tools.js.map +0 -1
  80. package/dist/tools/wu-tools.d.ts +0 -101
  81. package/dist/tools/wu-tools.d.ts.map +0 -1
  82. package/dist/tools/wu-tools.js +0 -964
  83. package/dist/tools/wu-tools.js.map +0 -1
  84. package/dist/tools-shared.d.ts +0 -250
  85. package/dist/tools-shared.d.ts.map +0 -1
  86. package/dist/tools-shared.js +0 -403
  87. package/dist/tools-shared.js.map +0 -1
  88. package/dist/tools.d.ts +0 -97
  89. package/dist/tools.d.ts.map +0 -1
  90. package/dist/tools.js +0 -248
  91. package/dist/tools.js.map +0 -1
  92. package/dist/worktree-enforcement.d.ts +0 -32
  93. package/dist/worktree-enforcement.d.ts.map +0 -1
  94. package/dist/worktree-enforcement.js +0 -154
  95. package/dist/worktree-enforcement.js.map +0 -1
@@ -1,1479 +0,0 @@
1
- // Copyright (c) 2026 Hellmai Ltd
2
- // SPDX-License-Identifier: AGPL-3.0-only
3
- /**
4
- * @file parity-tools.ts
5
- * @description Wave-1 and Wave-2 public parity tool implementations
6
- *
7
- * WU-1642: Extracted from tools.ts during domain decomposition.
8
- * WU-1482: Wave-1 public parity tools
9
- * WU-1483: Wave-2 public parity tools (file, git, plan, signal, wu:proto)
10
- */
11
- import path from 'node:path';
12
- import { z } from 'zod';
13
- import { gatesSchema, lumenflowInitSchema, initiativePlanSchema } from '@lumenflow/core';
14
- import { ErrorCodes, ErrorMessages, CliArgs, SharedErrorMessages, SuccessMessages, success, error, buildGatesArgs, executeViaPack, } from '../tools-shared.js';
15
- import { CliCommands, MetadataKeys } from '../mcp-constants.js';
16
- import { checkWorktreeEnforcement } from '../worktree-enforcement.js';
17
- // WU-1482: Schemas for wave-1 parity commands not yet modeled in @lumenflow/core
18
- const backlogPruneSchema = z.object({
19
- execute: z.boolean().optional(),
20
- dry_run: z.boolean().optional(),
21
- stale_days_in_progress: z.number().optional(),
22
- stale_days_ready: z.number().optional(),
23
- archive_days: z.number().optional(),
24
- });
25
- const docsSyncMcpSchema = z.object({
26
- vendor: z.enum(['claude', 'cursor', 'aider', 'all', 'none']).optional(),
27
- force: z.boolean().optional(),
28
- });
29
- const laneHealthSchema = z.object({
30
- json: z.boolean().optional(),
31
- verbose: z.boolean().optional(),
32
- no_coverage: z.boolean().optional(),
33
- });
34
- const laneSuggestSchema = z.object({
35
- dry_run: z.boolean().optional(),
36
- interactive: z.boolean().optional(),
37
- output: z.string().optional(),
38
- json: z.boolean().optional(),
39
- no_llm: z.boolean().optional(),
40
- include_git: z.boolean().optional(),
41
- });
42
- /**
43
- * WU-1802: Fallback messages for lane tools migrated to executeViaPack.
44
- */
45
- const LaneMessages = {
46
- HEALTH_PASSED: 'Lane health check complete',
47
- HEALTH_FAILED: 'lane:health failed',
48
- SUGGEST_GENERATED: 'Lane suggestions generated',
49
- SUGGEST_FAILED: 'lane:suggest failed',
50
- };
51
- const LaneFlags = {
52
- NO_COVERAGE: '--no-coverage',
53
- DRY_RUN: '--dry-run',
54
- INTERACTIVE: '--interactive',
55
- OUTPUT: '--output',
56
- NO_LLM: '--no-llm',
57
- INCLUDE_GIT: '--include-git',
58
- };
59
- const GatesRuntimeMessages = {
60
- GATES_FAILED: 'gates failed',
61
- GATES_DOCS_PASSED: 'Docs-only gates passed',
62
- GATES_DOCS_FAILED: 'gates:docs failed',
63
- LUMENFLOW_GATES_FAILED: 'lumenflow-gates failed',
64
- };
65
- const GatesRuntimeConstants = {
66
- FALLBACK_TIMEOUT_MS: 600000,
67
- };
68
- const stateBootstrapSchema = z.object({
69
- execute: z.boolean().optional(),
70
- dry_run: z.boolean().optional(),
71
- force: z.boolean().optional(),
72
- wu_dir: z.string().optional(),
73
- state_dir: z.string().optional(),
74
- });
75
- const stateCleanupSchema = z.object({
76
- dry_run: z.boolean().optional(),
77
- signals_only: z.boolean().optional(),
78
- memory_only: z.boolean().optional(),
79
- events_only: z.boolean().optional(),
80
- json: z.boolean().optional(),
81
- quiet: z.boolean().optional(),
82
- base_dir: z.string().optional(),
83
- });
84
- const stateDoctorSchema = z.object({
85
- fix: z.boolean().optional(),
86
- dry_run: z.boolean().optional(),
87
- json: z.boolean().optional(),
88
- quiet: z.boolean().optional(),
89
- base_dir: z.string().optional(),
90
- });
91
- const syncTemplatesMcpSchema = z.object({
92
- dry_run: z.boolean().optional(),
93
- verbose: z.boolean().optional(),
94
- check_drift: z.boolean().optional(),
95
- });
96
- // WU-1483: Schemas for wave-2 parity commands not yet modeled in @lumenflow/core
97
- const fileReadSchema = z.object({
98
- path: z.string().optional(),
99
- encoding: z.string().optional(),
100
- start_line: z.number().optional(),
101
- end_line: z.number().optional(),
102
- max_size: z.number().optional(),
103
- });
104
- const fileWriteSchema = z.object({
105
- path: z.string().optional(),
106
- content: z.string().optional(),
107
- encoding: z.string().optional(),
108
- no_create_dirs: z.boolean().optional(),
109
- });
110
- const fileEditSchema = z.object({
111
- path: z.string().optional(),
112
- old_string: z.string().optional(),
113
- new_string: z.string().optional(),
114
- encoding: z.string().optional(),
115
- replace_all: z.boolean().optional(),
116
- });
117
- const fileDeleteSchema = z.object({
118
- path: z.string().optional(),
119
- recursive: z.boolean().optional(),
120
- force: z.boolean().optional(),
121
- });
122
- const gitStatusSchema = z.object({
123
- base_dir: z.string().optional(),
124
- path: z.string().optional(),
125
- porcelain: z.boolean().optional(),
126
- short: z.boolean().optional(),
127
- });
128
- const gitDiffSchema = z.object({
129
- base_dir: z.string().optional(),
130
- ref: z.string().optional(),
131
- staged: z.boolean().optional(),
132
- name_only: z.boolean().optional(),
133
- stat: z.boolean().optional(),
134
- path: z.string().optional(),
135
- });
136
- const gitLogSchema = z.object({
137
- base_dir: z.string().optional(),
138
- ref: z.string().optional(),
139
- oneline: z.boolean().optional(),
140
- max_count: z.number().optional(),
141
- format: z.string().optional(),
142
- since: z.string().optional(),
143
- author: z.string().optional(),
144
- });
145
- const gitBranchSchema = z.object({
146
- base_dir: z.string().optional(),
147
- list: z.boolean().optional(),
148
- all: z.boolean().optional(),
149
- remotes: z.boolean().optional(),
150
- show_current: z.boolean().optional(),
151
- contains: z.string().optional(),
152
- });
153
- const planCreateSchema = z.object({
154
- id: z.string().optional(),
155
- title: z.string().optional(),
156
- });
157
- const planEditSchema = z.object({
158
- id: z.string().optional(),
159
- section: z.string().optional(),
160
- content: z.string().optional(),
161
- append: z.string().optional(),
162
- });
163
- const planLinkSchema = z.object({
164
- id: z.string().optional(),
165
- plan: z.string().optional(),
166
- });
167
- const planPromoteSchema = z.object({
168
- id: z.string().optional(),
169
- force: z.boolean().optional(),
170
- });
171
- const signalCleanupSchema = z.object({
172
- dry_run: z.boolean().optional(),
173
- ttl: z.string().optional(),
174
- unread_ttl: z.string().optional(),
175
- max_entries: z.number().optional(),
176
- json: z.boolean().optional(),
177
- quiet: z.boolean().optional(),
178
- base_dir: z.string().optional(),
179
- });
180
- // WU-1902: Schemas for config:set and config:get commands
181
- const configSetSchema = z.object({
182
- key: z.string().optional(),
183
- value: z.string().optional(),
184
- });
185
- const configGetSchema = z.object({
186
- key: z.string().optional(),
187
- });
188
- const wuProtoSchema = z.object({
189
- lane: z.string().optional(),
190
- title: z.string().optional(),
191
- description: z.string().optional(),
192
- code_paths: z.array(z.string()).optional(),
193
- labels: z.array(z.string()).optional(),
194
- assigned_to: z.string().optional(),
195
- });
196
- const GIT_RUNTIME_TOOL_NAME = CliCommands.GIT_STATUS;
197
- const GIT_BINARY = 'git';
198
- const RUNTIME_PROJECT_ROOT_KEY = MetadataKeys.PROJECT_ROOT;
199
- const GIT_COMMAND_RESULT_STDOUT_KEY = 'stdout';
200
- const GIT_COMMAND_RESULTS_KEY = 'command_results';
201
- const GIT_OUTPUT_KEY = 'output';
202
- function unwrapExecuteViaPackData(data) {
203
- if (!data || typeof data !== 'object') {
204
- return data;
205
- }
206
- if (!('success' in data)) {
207
- return data;
208
- }
209
- const output = data;
210
- if (!output.success) {
211
- return data;
212
- }
213
- return output.data ?? {};
214
- }
215
- function resolveRuntimeProjectRoot(baseDir, projectRoot) {
216
- if (typeof baseDir !== 'string' || baseDir.trim().length === 0) {
217
- return projectRoot ?? process.cwd();
218
- }
219
- return path.resolve(projectRoot ?? process.cwd(), baseDir);
220
- }
221
- function extractGitOutput(data) {
222
- if (!data || typeof data !== 'object') {
223
- return '';
224
- }
225
- const runtimeData = data;
226
- if (typeof runtimeData[GIT_OUTPUT_KEY] === 'string') {
227
- return runtimeData[GIT_OUTPUT_KEY];
228
- }
229
- const commandResults = runtimeData[GIT_COMMAND_RESULTS_KEY];
230
- if (!Array.isArray(commandResults) || commandResults.length === 0) {
231
- return '';
232
- }
233
- const lastCommandResult = commandResults[commandResults.length - 1];
234
- return typeof lastCommandResult[GIT_COMMAND_RESULT_STDOUT_KEY] === 'string'
235
- ? lastCommandResult[GIT_COMMAND_RESULT_STDOUT_KEY]
236
- : '';
237
- }
238
- // ============================================================================
239
- // Wave-1 Public Parity Operations (WU-1482)
240
- // ============================================================================
241
- /**
242
- * backlog_prune - Clean stale backlog entries
243
- */
244
- export const backlogPruneTool = {
245
- name: 'backlog_prune',
246
- description: 'Clean stale backlog entries and archive old completed WUs',
247
- inputSchema: backlogPruneSchema,
248
- async execute(input, options) {
249
- const args = [];
250
- if (input.execute)
251
- args.push(CliArgs.EXECUTE);
252
- if (input.dry_run)
253
- args.push('--dry-run');
254
- if (input.stale_days_in_progress !== undefined) {
255
- args.push('--stale-days-in-progress', String(input.stale_days_in_progress));
256
- }
257
- if (input.stale_days_ready !== undefined) {
258
- args.push('--stale-days-ready', String(input.stale_days_ready));
259
- }
260
- if (input.archive_days !== undefined) {
261
- args.push('--archive-days', String(input.archive_days));
262
- }
263
- const execution = await executeViaPack(CliCommands.BACKLOG_PRUNE, {
264
- execute: input.execute,
265
- dry_run: input.dry_run,
266
- stale_days_in_progress: input.stale_days_in_progress,
267
- stale_days_ready: input.stale_days_ready,
268
- archive_days: input.archive_days,
269
- }, {
270
- projectRoot: options?.projectRoot,
271
- contextInput: {
272
- metadata: {
273
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
274
- },
275
- },
276
- fallback: {
277
- command: CliCommands.BACKLOG_PRUNE,
278
- args,
279
- errorCode: ErrorCodes.BACKLOG_PRUNE_ERROR,
280
- },
281
- });
282
- if (!execution.success) {
283
- return execution;
284
- }
285
- return success(unwrapExecuteViaPackData(execution.data));
286
- },
287
- };
288
- /**
289
- * docs_sync - Sync agent docs to existing project
290
- */
291
- export const docsSyncTool = {
292
- name: 'docs_sync',
293
- description: 'Sync agent onboarding docs and skills to existing projects',
294
- inputSchema: docsSyncMcpSchema,
295
- async execute(input, options) {
296
- const args = [];
297
- if (input.vendor)
298
- args.push('--vendor', input.vendor);
299
- if (input.force)
300
- args.push(CliArgs.FORCE);
301
- const execution = await executeViaPack(CliCommands.DOCS_SYNC, {
302
- vendor: input.vendor,
303
- force: input.force,
304
- }, {
305
- projectRoot: options?.projectRoot,
306
- contextInput: {
307
- metadata: {
308
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
309
- },
310
- },
311
- fallback: {
312
- command: CliCommands.DOCS_SYNC,
313
- args,
314
- errorCode: ErrorCodes.DOCS_SYNC_ERROR,
315
- },
316
- });
317
- if (!execution.success) {
318
- return execution;
319
- }
320
- return success(unwrapExecuteViaPackData(execution.data));
321
- },
322
- };
323
- /**
324
- * gates - Public gates command
325
- */
326
- export const gatesTool = {
327
- name: 'gates',
328
- description: 'Run LumenFlow quality gates',
329
- inputSchema: gatesSchema,
330
- async execute(input, options) {
331
- const args = buildGatesArgs(input);
332
- const result = await executeViaPack(CliCommands.GATES, input, {
333
- projectRoot: options?.projectRoot,
334
- contextInput: {
335
- metadata: {
336
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
337
- },
338
- },
339
- fallback: {
340
- command: CliCommands.GATES,
341
- args,
342
- errorCode: ErrorCodes.GATES_ALIAS_ERROR,
343
- },
344
- fallbackCliOptions: {
345
- timeout: GatesRuntimeConstants.FALLBACK_TIMEOUT_MS,
346
- },
347
- });
348
- return result.success
349
- ? success(result.data ?? { message: SuccessMessages.ALL_GATES_PASSED })
350
- : error(result.error?.message ?? GatesRuntimeMessages.GATES_FAILED, ErrorCodes.GATES_ALIAS_ERROR);
351
- },
352
- };
353
- /**
354
- * gates_docs - Public docs-only gates alias
355
- */
356
- export const gatesDocsTool = {
357
- name: 'gates_docs',
358
- description: 'Run docs-only quality gates',
359
- inputSchema: gatesSchema,
360
- async execute(input, options) {
361
- const args = buildGatesArgs(input, { forceDocsOnly: true });
362
- const result = await executeViaPack(CliCommands.GATES, input, {
363
- projectRoot: options?.projectRoot,
364
- contextInput: {
365
- metadata: {
366
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
367
- },
368
- },
369
- fallback: {
370
- command: CliCommands.GATES,
371
- args,
372
- errorCode: ErrorCodes.GATES_ALIAS_ERROR,
373
- },
374
- fallbackCliOptions: {
375
- timeout: GatesRuntimeConstants.FALLBACK_TIMEOUT_MS,
376
- },
377
- });
378
- return result.success
379
- ? success(result.data ?? { message: GatesRuntimeMessages.GATES_DOCS_PASSED })
380
- : error(result.error?.message ?? GatesRuntimeMessages.GATES_DOCS_FAILED, ErrorCodes.GATES_ALIAS_ERROR);
381
- },
382
- };
383
- /**
384
- * lane_health - Diagnose lane configuration issues
385
- * WU-1802: Migrated from CLI shell-out to executeViaPack (runtime-first)
386
- */
387
- export const laneHealthTool = {
388
- name: 'lane_health',
389
- description: 'Check lane configuration health (overlaps and coverage gaps)',
390
- inputSchema: laneHealthSchema,
391
- async execute(input, options) {
392
- const args = [];
393
- if (input.json)
394
- args.push(CliArgs.JSON);
395
- if (input.verbose)
396
- args.push(CliArgs.VERBOSE);
397
- if (input.no_coverage)
398
- args.push(LaneFlags.NO_COVERAGE);
399
- const result = await executeViaPack(CliCommands.LANE_HEALTH, input, {
400
- projectRoot: options?.projectRoot,
401
- fallback: {
402
- command: CliCommands.LANE_HEALTH,
403
- args,
404
- errorCode: ErrorCodes.LANE_HEALTH_ERROR,
405
- },
406
- });
407
- return result.success
408
- ? success(result.data ?? { message: LaneMessages.HEALTH_PASSED })
409
- : error(result.error?.message ?? LaneMessages.HEALTH_FAILED, ErrorCodes.LANE_HEALTH_ERROR);
410
- },
411
- };
412
- /**
413
- * lane_suggest - Suggest lane definitions from project context
414
- * WU-1802: Migrated from CLI shell-out to executeViaPack (runtime-first)
415
- */
416
- export const laneSuggestTool = {
417
- name: 'lane_suggest',
418
- description: 'Generate lane suggestions from codebase context',
419
- inputSchema: laneSuggestSchema,
420
- async execute(input, options) {
421
- const args = [];
422
- if (input.dry_run)
423
- args.push(LaneFlags.DRY_RUN);
424
- if (input.interactive)
425
- args.push(LaneFlags.INTERACTIVE);
426
- if (input.output)
427
- args.push(LaneFlags.OUTPUT, input.output);
428
- if (input.json)
429
- args.push(CliArgs.JSON);
430
- if (input.no_llm)
431
- args.push(LaneFlags.NO_LLM);
432
- if (input.include_git)
433
- args.push(LaneFlags.INCLUDE_GIT);
434
- const result = await executeViaPack(CliCommands.LANE_SUGGEST, input, {
435
- projectRoot: options?.projectRoot,
436
- fallback: {
437
- command: CliCommands.LANE_SUGGEST,
438
- args,
439
- errorCode: ErrorCodes.LANE_SUGGEST_ERROR,
440
- },
441
- });
442
- return result.success
443
- ? success(result.data ?? { message: LaneMessages.SUGGEST_GENERATED })
444
- : error(result.error?.message ?? LaneMessages.SUGGEST_FAILED, ErrorCodes.LANE_SUGGEST_ERROR);
445
- },
446
- };
447
- /**
448
- * lumenflow - Public initializer command
449
- */
450
- export const lumenflowTool = {
451
- name: 'lumenflow',
452
- description: 'Initialize LumenFlow in a project',
453
- inputSchema: lumenflowInitSchema,
454
- async execute(input, options) {
455
- const args = [];
456
- if (input.client)
457
- args.push('--client', input.client);
458
- if (input.merge)
459
- args.push('--merge');
460
- if (input.full)
461
- args.push('--full');
462
- if (input.minimal)
463
- args.push('--minimal');
464
- if (input.framework)
465
- args.push('--framework', input.framework);
466
- const execution = await executeViaPack(CliCommands.LUMENFLOW, {
467
- client: input.client,
468
- merge: input.merge,
469
- full: input.full,
470
- minimal: input.minimal,
471
- framework: input.framework,
472
- }, {
473
- projectRoot: options?.projectRoot,
474
- contextInput: {
475
- metadata: {
476
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
477
- },
478
- },
479
- fallback: {
480
- command: CliCommands.LUMENFLOW,
481
- args,
482
- errorCode: ErrorCodes.LUMENFLOW_ALIAS_ERROR,
483
- },
484
- });
485
- if (!execution.success) {
486
- return execution;
487
- }
488
- return success(unwrapExecuteViaPackData(execution.data));
489
- },
490
- };
491
- /**
492
- * lumenflow_gates - Public gates alias
493
- */
494
- export const lumenflowGatesTool = {
495
- name: 'lumenflow_gates',
496
- description: 'Run quality gates (lumenflow-gates alias)',
497
- inputSchema: gatesSchema,
498
- async execute(input, options) {
499
- const args = buildGatesArgs(input);
500
- const result = await executeViaPack(CliCommands.GATES, input, {
501
- projectRoot: options?.projectRoot,
502
- contextInput: {
503
- metadata: {
504
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
505
- },
506
- },
507
- fallback: {
508
- command: CliCommands.GATES,
509
- args,
510
- errorCode: ErrorCodes.LUMENFLOW_GATES_ERROR,
511
- },
512
- fallbackCliOptions: {
513
- timeout: GatesRuntimeConstants.FALLBACK_TIMEOUT_MS,
514
- },
515
- });
516
- return result.success
517
- ? success(result.data ?? { message: SuccessMessages.ALL_GATES_PASSED })
518
- : error(result.error?.message ?? GatesRuntimeMessages.LUMENFLOW_GATES_FAILED, ErrorCodes.LUMENFLOW_GATES_ERROR);
519
- },
520
- };
521
- /**
522
- * state_bootstrap - Bootstrap event store from WU YAMLs
523
- */
524
- export const stateBootstrapTool = {
525
- name: 'state_bootstrap',
526
- description: 'Bootstrap state store from existing WU YAML files',
527
- inputSchema: stateBootstrapSchema,
528
- async execute(input, options) {
529
- const args = [];
530
- if (input.execute)
531
- args.push(CliArgs.EXECUTE);
532
- if (input.dry_run)
533
- args.push('--dry-run');
534
- if (input.force)
535
- args.push(CliArgs.FORCE);
536
- if (input.wu_dir)
537
- args.push('--wu-dir', input.wu_dir);
538
- if (input.state_dir)
539
- args.push('--state-dir', input.state_dir);
540
- const execution = await executeViaPack(CliCommands.STATE_BOOTSTRAP, {
541
- execute: input.execute,
542
- dry_run: input.dry_run,
543
- force: input.force,
544
- wu_dir: input.wu_dir,
545
- state_dir: input.state_dir,
546
- }, {
547
- projectRoot: options?.projectRoot,
548
- contextInput: {
549
- metadata: {
550
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
551
- },
552
- },
553
- fallback: {
554
- command: CliCommands.STATE_BOOTSTRAP,
555
- args,
556
- errorCode: ErrorCodes.STATE_BOOTSTRAP_ERROR,
557
- },
558
- });
559
- if (!execution.success) {
560
- return execution;
561
- }
562
- return success(unwrapExecuteViaPackData(execution.data));
563
- },
564
- };
565
- /**
566
- * state_cleanup - Run unified state cleanup
567
- */
568
- export const stateCleanupTool = {
569
- name: 'state_cleanup',
570
- description: 'Clean stale state, memory, and signal data',
571
- inputSchema: stateCleanupSchema,
572
- async execute(input, options) {
573
- const args = [];
574
- if (input.dry_run)
575
- args.push('--dry-run');
576
- if (input.signals_only)
577
- args.push('--signals-only');
578
- if (input.memory_only)
579
- args.push('--memory-only');
580
- if (input.events_only)
581
- args.push('--events-only');
582
- if (input.json)
583
- args.push(CliArgs.JSON);
584
- if (input.quiet)
585
- args.push(CliArgs.QUIET);
586
- if (input.base_dir)
587
- args.push(CliArgs.BASE_DIR, input.base_dir);
588
- const execution = await executeViaPack(CliCommands.STATE_CLEANUP, {
589
- dry_run: input.dry_run,
590
- signals_only: input.signals_only,
591
- memory_only: input.memory_only,
592
- events_only: input.events_only,
593
- json: input.json,
594
- quiet: input.quiet,
595
- base_dir: input.base_dir,
596
- }, {
597
- projectRoot: options?.projectRoot,
598
- contextInput: {
599
- metadata: {
600
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
601
- },
602
- },
603
- fallback: {
604
- command: CliCommands.STATE_CLEANUP,
605
- args,
606
- errorCode: ErrorCodes.STATE_CLEANUP_ERROR,
607
- },
608
- });
609
- if (!execution.success) {
610
- return execution;
611
- }
612
- return success(unwrapExecuteViaPackData(execution.data));
613
- },
614
- };
615
- /**
616
- * state_doctor - Diagnose and repair state issues
617
- */
618
- export const stateDoctorTool = {
619
- name: 'state_doctor',
620
- description: 'Diagnose state store integrity issues',
621
- inputSchema: stateDoctorSchema,
622
- async execute(input, options) {
623
- const args = [];
624
- if (input.fix)
625
- args.push('--fix');
626
- if (input.dry_run)
627
- args.push('--dry-run');
628
- if (input.json)
629
- args.push(CliArgs.JSON);
630
- if (input.quiet)
631
- args.push(CliArgs.QUIET);
632
- if (input.base_dir)
633
- args.push(CliArgs.BASE_DIR, input.base_dir);
634
- const execution = await executeViaPack(CliCommands.STATE_DOCTOR, {
635
- fix: input.fix,
636
- dry_run: input.dry_run,
637
- json: input.json,
638
- quiet: input.quiet,
639
- base_dir: input.base_dir,
640
- }, {
641
- projectRoot: options?.projectRoot,
642
- contextInput: {
643
- metadata: {
644
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
645
- },
646
- },
647
- fallback: {
648
- command: CliCommands.STATE_DOCTOR,
649
- args,
650
- errorCode: ErrorCodes.STATE_DOCTOR_ERROR,
651
- },
652
- });
653
- if (!execution.success) {
654
- return execution;
655
- }
656
- return success(unwrapExecuteViaPackData(execution.data));
657
- },
658
- };
659
- /**
660
- * sync_templates - Sync templates from source docs
661
- */
662
- export const syncTemplatesTool = {
663
- name: 'sync_templates',
664
- description: 'Sync internal docs to CLI templates',
665
- inputSchema: syncTemplatesMcpSchema,
666
- async execute(input, options) {
667
- const args = [];
668
- if (input.dry_run)
669
- args.push('--dry-run');
670
- if (input.verbose)
671
- args.push(CliArgs.VERBOSE);
672
- if (input.check_drift)
673
- args.push('--check-drift');
674
- const execution = await executeViaPack(CliCommands.SYNC_TEMPLATES, {
675
- dry_run: input.dry_run,
676
- verbose: input.verbose,
677
- check_drift: input.check_drift,
678
- }, {
679
- projectRoot: options?.projectRoot,
680
- contextInput: {
681
- metadata: {
682
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
683
- },
684
- },
685
- fallback: {
686
- command: CliCommands.SYNC_TEMPLATES,
687
- args,
688
- errorCode: ErrorCodes.SYNC_TEMPLATES_ALIAS_ERROR,
689
- },
690
- });
691
- if (!execution.success) {
692
- return execution;
693
- }
694
- return success(unwrapExecuteViaPackData(execution.data));
695
- },
696
- };
697
- // ============================================================================
698
- // Wave-2 Public Parity Operations (WU-1483)
699
- // ============================================================================
700
- /**
701
- * file_read - Read file content with audit trail
702
- */
703
- export const fileReadTool = {
704
- name: 'file_read',
705
- description: 'Read a file with optional line ranges and encoding',
706
- inputSchema: fileReadSchema,
707
- async execute(input, options) {
708
- if (!input.path) {
709
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
710
- }
711
- const args = [CliArgs.PATH, input.path];
712
- if (input.encoding)
713
- args.push(CliArgs.ENCODING, input.encoding);
714
- if (input.start_line !== undefined)
715
- args.push('--start-line', String(input.start_line));
716
- if (input.end_line !== undefined)
717
- args.push('--end-line', String(input.end_line));
718
- if (input.max_size !== undefined)
719
- args.push('--max-size', String(input.max_size));
720
- const execution = await executeViaPack(CliCommands.FILE_READ, {
721
- path: input.path,
722
- encoding: input.encoding,
723
- start_line: input.start_line,
724
- end_line: input.end_line,
725
- max_size: input.max_size,
726
- }, {
727
- projectRoot: options?.projectRoot,
728
- contextInput: {
729
- metadata: {
730
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
731
- },
732
- },
733
- fallback: {
734
- command: CliCommands.FILE_READ,
735
- args,
736
- errorCode: ErrorCodes.FILE_READ_ERROR,
737
- },
738
- });
739
- if (!execution.success) {
740
- return execution;
741
- }
742
- return success(unwrapExecuteViaPackData(execution.data));
743
- },
744
- };
745
- /**
746
- * file_write - Write file content with audit trail
747
- */
748
- export const fileWriteTool = {
749
- name: 'file_write',
750
- description: 'Write content to a file with audit trail',
751
- inputSchema: fileWriteSchema,
752
- async execute(input, options) {
753
- if (!input.path) {
754
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
755
- }
756
- if (input.content === undefined) {
757
- return error(ErrorMessages.CONTENT_REQUIRED, ErrorCodes.MISSING_PARAMETER);
758
- }
759
- // WU-1853: Check worktree enforcement before writing
760
- const enforcement = checkWorktreeEnforcement({
761
- filePath: input.path,
762
- projectRoot: options?.projectRoot,
763
- });
764
- if (!enforcement.allowed) {
765
- return error(enforcement.reason ?? 'Write blocked by worktree enforcement', enforcement.errorCode ?? ErrorCodes.WORKTREE_ENFORCEMENT_BLOCKED);
766
- }
767
- const args = [
768
- CliArgs.PATH,
769
- input.path,
770
- '--content',
771
- input.content,
772
- ];
773
- if (input.encoding)
774
- args.push(CliArgs.ENCODING, input.encoding);
775
- if (input.no_create_dirs)
776
- args.push('--no-create-dirs');
777
- const execution = await executeViaPack(CliCommands.FILE_WRITE, {
778
- path: input.path,
779
- content: input.content,
780
- encoding: input.encoding,
781
- no_create_dirs: input.no_create_dirs,
782
- }, {
783
- projectRoot: options?.projectRoot,
784
- contextInput: {
785
- metadata: {
786
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
787
- },
788
- },
789
- fallback: {
790
- command: CliCommands.FILE_WRITE,
791
- args,
792
- errorCode: ErrorCodes.FILE_WRITE_ERROR,
793
- },
794
- });
795
- if (!execution.success) {
796
- return execution;
797
- }
798
- return success(unwrapExecuteViaPackData(execution.data));
799
- },
800
- };
801
- /**
802
- * file_edit - Replace exact string matches in a file
803
- */
804
- export const fileEditTool = {
805
- name: 'file_edit',
806
- description: 'Edit a file via exact string replacement',
807
- inputSchema: fileEditSchema,
808
- async execute(input, options) {
809
- if (!input.path) {
810
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
811
- }
812
- if (!input.old_string) {
813
- return error(ErrorMessages.OLD_STRING_REQUIRED, ErrorCodes.MISSING_PARAMETER);
814
- }
815
- if (input.new_string === undefined) {
816
- return error(ErrorMessages.NEW_STRING_REQUIRED, ErrorCodes.MISSING_PARAMETER);
817
- }
818
- // WU-1853: Check worktree enforcement before editing
819
- const enforcement = checkWorktreeEnforcement({
820
- filePath: input.path,
821
- projectRoot: options?.projectRoot,
822
- });
823
- if (!enforcement.allowed) {
824
- return error(enforcement.reason ?? 'Edit blocked by worktree enforcement', enforcement.errorCode ?? ErrorCodes.WORKTREE_ENFORCEMENT_BLOCKED);
825
- }
826
- const args = [
827
- CliArgs.PATH,
828
- input.path,
829
- '--old-string',
830
- input.old_string,
831
- '--new-string',
832
- input.new_string,
833
- ];
834
- if (input.encoding)
835
- args.push(CliArgs.ENCODING, input.encoding);
836
- if (input.replace_all)
837
- args.push('--replace-all');
838
- const execution = await executeViaPack(CliCommands.FILE_EDIT, {
839
- path: input.path,
840
- old_string: input.old_string,
841
- new_string: input.new_string,
842
- encoding: input.encoding,
843
- replace_all: input.replace_all,
844
- }, {
845
- projectRoot: options?.projectRoot,
846
- contextInput: {
847
- metadata: {
848
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
849
- },
850
- },
851
- fallback: {
852
- command: CliCommands.FILE_EDIT,
853
- args,
854
- errorCode: ErrorCodes.FILE_EDIT_ERROR,
855
- },
856
- });
857
- if (!execution.success) {
858
- return execution;
859
- }
860
- return success(unwrapExecuteViaPackData(execution.data));
861
- },
862
- };
863
- /**
864
- * file_delete - Delete file or directory with audit trail
865
- */
866
- export const fileDeleteTool = {
867
- name: 'file_delete',
868
- description: 'Delete files or directories with safety flags',
869
- inputSchema: fileDeleteSchema,
870
- async execute(input, options) {
871
- if (!input.path) {
872
- return error(ErrorMessages.PATH_REQUIRED, ErrorCodes.MISSING_PARAMETER);
873
- }
874
- const args = [CliArgs.PATH, input.path];
875
- if (input.recursive)
876
- args.push('--recursive');
877
- if (input.force)
878
- args.push(CliArgs.FORCE);
879
- const execution = await executeViaPack(CliCommands.FILE_DELETE, {
880
- path: input.path,
881
- recursive: input.recursive,
882
- force: input.force,
883
- }, {
884
- projectRoot: options?.projectRoot,
885
- contextInput: {
886
- metadata: {
887
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
888
- },
889
- },
890
- fallback: {
891
- command: CliCommands.FILE_DELETE,
892
- args,
893
- errorCode: ErrorCodes.FILE_DELETE_ERROR,
894
- },
895
- });
896
- if (!execution.success) {
897
- return execution;
898
- }
899
- return success(unwrapExecuteViaPackData(execution.data));
900
- },
901
- };
902
- /**
903
- * git_status - Show git status
904
- */
905
- export const gitStatusTool = {
906
- name: 'git_status',
907
- description: 'Show git status with optional porcelain/short modes',
908
- inputSchema: gitStatusSchema,
909
- async execute(input, options) {
910
- const runtimeProjectRoot = resolveRuntimeProjectRoot(input.base_dir, options?.projectRoot);
911
- const args = [];
912
- if (input.base_dir)
913
- args.push(CliArgs.BASE_DIR, input.base_dir);
914
- if (input.porcelain)
915
- args.push('--porcelain');
916
- if (input.short)
917
- args.push('--short');
918
- if (input.path)
919
- args.push(input.path);
920
- const gitCommandArgs = ['status'];
921
- if (input.porcelain)
922
- gitCommandArgs.push('--porcelain');
923
- if (input.short)
924
- gitCommandArgs.push('--short');
925
- if (input.path)
926
- gitCommandArgs.push(input.path);
927
- const execution = await executeViaPack(GIT_RUNTIME_TOOL_NAME, {
928
- commands: [[GIT_BINARY, ...gitCommandArgs]],
929
- }, {
930
- projectRoot: runtimeProjectRoot,
931
- contextInput: {
932
- metadata: {
933
- [RUNTIME_PROJECT_ROOT_KEY]: runtimeProjectRoot,
934
- },
935
- },
936
- fallback: {
937
- command: CliCommands.GIT_STATUS,
938
- args,
939
- errorCode: ErrorCodes.GIT_STATUS_ERROR,
940
- },
941
- });
942
- if (!execution.success) {
943
- return execution;
944
- }
945
- const runtimeData = unwrapExecuteViaPackData(execution.data);
946
- return success({ output: extractGitOutput(runtimeData) });
947
- },
948
- };
949
- /**
950
- * git_diff - Show git diff
951
- */
952
- export const gitDiffTool = {
953
- name: 'git_diff',
954
- description: 'Show git diff with staged/name-only/stat modes',
955
- inputSchema: gitDiffSchema,
956
- async execute(input, options) {
957
- const runtimeProjectRoot = resolveRuntimeProjectRoot(input.base_dir, options?.projectRoot);
958
- const args = [];
959
- if (input.base_dir)
960
- args.push(CliArgs.BASE_DIR, input.base_dir);
961
- if (input.staged)
962
- args.push('--staged');
963
- if (input.name_only)
964
- args.push('--name-only');
965
- if (input.stat)
966
- args.push('--stat');
967
- if (input.ref)
968
- args.push(input.ref);
969
- if (input.path)
970
- args.push('--', input.path);
971
- const gitCommandArgs = ['diff'];
972
- if (input.staged)
973
- gitCommandArgs.push('--staged');
974
- if (input.name_only)
975
- gitCommandArgs.push('--name-only');
976
- if (input.stat)
977
- gitCommandArgs.push('--stat');
978
- if (input.ref)
979
- gitCommandArgs.push(input.ref);
980
- if (input.path)
981
- gitCommandArgs.push('--', input.path);
982
- const execution = await executeViaPack(GIT_RUNTIME_TOOL_NAME, {
983
- commands: [[GIT_BINARY, ...gitCommandArgs]],
984
- }, {
985
- projectRoot: runtimeProjectRoot,
986
- contextInput: {
987
- metadata: {
988
- [RUNTIME_PROJECT_ROOT_KEY]: runtimeProjectRoot,
989
- },
990
- },
991
- fallback: {
992
- command: CliCommands.GIT_DIFF,
993
- args,
994
- errorCode: ErrorCodes.GIT_DIFF_ERROR,
995
- },
996
- });
997
- if (!execution.success) {
998
- return execution;
999
- }
1000
- const runtimeData = unwrapExecuteViaPackData(execution.data);
1001
- return success({ output: extractGitOutput(runtimeData) });
1002
- },
1003
- };
1004
- /**
1005
- * git_log - Show commit history
1006
- */
1007
- export const gitLogTool = {
1008
- name: 'git_log',
1009
- description: 'Show git commit log with filters',
1010
- inputSchema: gitLogSchema,
1011
- async execute(input, options) {
1012
- const runtimeProjectRoot = resolveRuntimeProjectRoot(input.base_dir, options?.projectRoot);
1013
- const args = [];
1014
- if (input.base_dir)
1015
- args.push(CliArgs.BASE_DIR, input.base_dir);
1016
- if (input.oneline)
1017
- args.push('--oneline');
1018
- if (input.max_count !== undefined)
1019
- args.push('-n', String(input.max_count));
1020
- if (input.format)
1021
- args.push(CliArgs.FORMAT, input.format);
1022
- if (input.since)
1023
- args.push(CliArgs.SINCE, input.since);
1024
- if (input.author)
1025
- args.push('--author', input.author);
1026
- if (input.ref)
1027
- args.push(input.ref);
1028
- const gitCommandArgs = ['log'];
1029
- if (input.oneline)
1030
- gitCommandArgs.push('--oneline');
1031
- if (input.max_count !== undefined)
1032
- gitCommandArgs.push('-n', String(input.max_count));
1033
- if (input.format)
1034
- gitCommandArgs.push(CliArgs.FORMAT, input.format);
1035
- if (input.since)
1036
- gitCommandArgs.push(CliArgs.SINCE, input.since);
1037
- if (input.author)
1038
- gitCommandArgs.push('--author', input.author);
1039
- if (input.ref)
1040
- gitCommandArgs.push(input.ref);
1041
- const execution = await executeViaPack(GIT_RUNTIME_TOOL_NAME, {
1042
- commands: [[GIT_BINARY, ...gitCommandArgs]],
1043
- }, {
1044
- projectRoot: runtimeProjectRoot,
1045
- contextInput: {
1046
- metadata: {
1047
- [RUNTIME_PROJECT_ROOT_KEY]: runtimeProjectRoot,
1048
- },
1049
- },
1050
- fallback: {
1051
- command: CliCommands.GIT_LOG,
1052
- args,
1053
- errorCode: ErrorCodes.GIT_LOG_ERROR,
1054
- },
1055
- });
1056
- if (!execution.success) {
1057
- return execution;
1058
- }
1059
- const runtimeData = unwrapExecuteViaPackData(execution.data);
1060
- return success({ output: extractGitOutput(runtimeData) });
1061
- },
1062
- };
1063
- /**
1064
- * git_branch - Show branch information
1065
- */
1066
- export const gitBranchTool = {
1067
- name: 'git_branch',
1068
- description: 'Show git branch listing and current branch',
1069
- inputSchema: gitBranchSchema,
1070
- async execute(input, options) {
1071
- const runtimeProjectRoot = resolveRuntimeProjectRoot(input.base_dir, options?.projectRoot);
1072
- const args = [];
1073
- if (input.base_dir)
1074
- args.push(CliArgs.BASE_DIR, input.base_dir);
1075
- if (input.list)
1076
- args.push('--list');
1077
- if (input.all)
1078
- args.push('--all');
1079
- if (input.remotes)
1080
- args.push('--remotes');
1081
- if (input.show_current)
1082
- args.push('--show-current');
1083
- if (input.contains)
1084
- args.push('--contains', input.contains);
1085
- const gitCommandArgs = ['branch'];
1086
- if (input.list)
1087
- gitCommandArgs.push('--list');
1088
- if (input.all)
1089
- gitCommandArgs.push('--all');
1090
- if (input.remotes)
1091
- gitCommandArgs.push('--remotes');
1092
- if (input.show_current)
1093
- gitCommandArgs.push('--show-current');
1094
- if (input.contains)
1095
- gitCommandArgs.push('--contains', input.contains);
1096
- const execution = await executeViaPack(GIT_RUNTIME_TOOL_NAME, {
1097
- commands: [[GIT_BINARY, ...gitCommandArgs]],
1098
- }, {
1099
- projectRoot: runtimeProjectRoot,
1100
- contextInput: {
1101
- metadata: {
1102
- [RUNTIME_PROJECT_ROOT_KEY]: runtimeProjectRoot,
1103
- },
1104
- },
1105
- fallback: {
1106
- command: CliCommands.GIT_BRANCH,
1107
- args,
1108
- errorCode: ErrorCodes.GIT_BRANCH_ERROR,
1109
- },
1110
- });
1111
- if (!execution.success) {
1112
- return execution;
1113
- }
1114
- const runtimeData = unwrapExecuteViaPackData(execution.data);
1115
- return success({ output: extractGitOutput(runtimeData) });
1116
- },
1117
- };
1118
- /**
1119
- * init_plan - Link plan to initiative (alias)
1120
- */
1121
- export const initPlanTool = {
1122
- name: 'init_plan',
1123
- description: 'Link or create a plan for an initiative',
1124
- inputSchema: initiativePlanSchema,
1125
- async execute(input, options) {
1126
- if (!input.initiative) {
1127
- return error(SharedErrorMessages.INITIATIVE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1128
- }
1129
- if (!input.plan && !input.create) {
1130
- return error(ErrorMessages.PLAN_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1131
- }
1132
- const args = ['--initiative', input.initiative];
1133
- if (input.plan)
1134
- args.push('--plan', input.plan);
1135
- if (input.create)
1136
- args.push('--create');
1137
- const execution = await executeViaPack(CliCommands.INIT_PLAN, input, {
1138
- projectRoot: options?.projectRoot,
1139
- contextInput: {
1140
- metadata: {
1141
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1142
- },
1143
- },
1144
- fallback: {
1145
- command: CliCommands.INIT_PLAN,
1146
- args,
1147
- errorCode: ErrorCodes.INIT_PLAN_ERROR,
1148
- },
1149
- });
1150
- return execution.success
1151
- ? success(unwrapExecuteViaPackData(execution.data))
1152
- : error(execution.error?.message ?? 'init:plan failed', ErrorCodes.INIT_PLAN_ERROR);
1153
- },
1154
- };
1155
- /**
1156
- * plan_create - Create a plan file
1157
- */
1158
- export const planCreateTool = {
1159
- name: 'plan_create',
1160
- description: 'Create a new plan for a WU or initiative',
1161
- inputSchema: planCreateSchema,
1162
- async execute(input, options) {
1163
- if (!input.id) {
1164
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1165
- }
1166
- if (!input.title) {
1167
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1168
- }
1169
- const args = [CliArgs.ID, input.id, '--title', input.title];
1170
- const execution = await executeViaPack(CliCommands.PLAN_CREATE, {
1171
- id: input.id,
1172
- title: input.title,
1173
- }, {
1174
- projectRoot: options?.projectRoot,
1175
- contextInput: {
1176
- metadata: {
1177
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1178
- },
1179
- },
1180
- fallback: {
1181
- command: CliCommands.PLAN_CREATE,
1182
- args,
1183
- errorCode: ErrorCodes.PLAN_CREATE_ERROR,
1184
- },
1185
- });
1186
- if (!execution.success) {
1187
- return execution;
1188
- }
1189
- return success(unwrapExecuteViaPackData(execution.data));
1190
- },
1191
- };
1192
- /**
1193
- * plan_edit - Edit an existing plan section
1194
- */
1195
- export const planEditTool = {
1196
- name: 'plan_edit',
1197
- description: 'Edit or append content to a plan section',
1198
- inputSchema: planEditSchema,
1199
- async execute(input, options) {
1200
- if (!input.id) {
1201
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1202
- }
1203
- if (!input.section) {
1204
- return error(ErrorMessages.SECTION_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1205
- }
1206
- if (!input.content && !input.append) {
1207
- return error(ErrorMessages.CONTENT_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1208
- }
1209
- const args = [CliArgs.ID, input.id, '--section', input.section];
1210
- if (input.content)
1211
- args.push('--content', input.content);
1212
- if (input.append)
1213
- args.push('--append', input.append);
1214
- const execution = await executeViaPack(CliCommands.PLAN_EDIT, {
1215
- id: input.id,
1216
- section: input.section,
1217
- content: input.content,
1218
- append: input.append,
1219
- }, {
1220
- projectRoot: options?.projectRoot,
1221
- contextInput: {
1222
- metadata: {
1223
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1224
- },
1225
- },
1226
- fallback: {
1227
- command: CliCommands.PLAN_EDIT,
1228
- args,
1229
- errorCode: ErrorCodes.PLAN_EDIT_ERROR,
1230
- },
1231
- });
1232
- if (!execution.success) {
1233
- return execution;
1234
- }
1235
- return success(unwrapExecuteViaPackData(execution.data));
1236
- },
1237
- };
1238
- /**
1239
- * plan_link - Link plan URI to WU/initiative
1240
- */
1241
- export const planLinkTool = {
1242
- name: 'plan_link',
1243
- description: 'Link an existing plan URI to a WU or initiative',
1244
- inputSchema: planLinkSchema,
1245
- async execute(input, options) {
1246
- if (!input.id) {
1247
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1248
- }
1249
- if (!input.plan) {
1250
- return error(ErrorMessages.PLAN_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1251
- }
1252
- const args = [CliArgs.ID, input.id, '--plan', input.plan];
1253
- const execution = await executeViaPack(CliCommands.PLAN_LINK, {
1254
- id: input.id,
1255
- plan: input.plan,
1256
- }, {
1257
- projectRoot: options?.projectRoot,
1258
- contextInput: {
1259
- metadata: {
1260
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1261
- },
1262
- },
1263
- fallback: {
1264
- command: CliCommands.PLAN_LINK,
1265
- args,
1266
- errorCode: ErrorCodes.PLAN_LINK_ERROR,
1267
- },
1268
- });
1269
- if (!execution.success) {
1270
- return execution;
1271
- }
1272
- return success(unwrapExecuteViaPackData(execution.data));
1273
- },
1274
- };
1275
- /**
1276
- * plan_promote - Promote plan to approved status
1277
- */
1278
- export const planPromoteTool = {
1279
- name: 'plan_promote',
1280
- description: 'Promote plan from draft to approved status',
1281
- inputSchema: planPromoteSchema,
1282
- async execute(input, options) {
1283
- if (!input.id) {
1284
- return error(ErrorMessages.ID_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1285
- }
1286
- const args = [CliArgs.ID, input.id];
1287
- if (input.force)
1288
- args.push(CliArgs.FORCE);
1289
- const execution = await executeViaPack(CliCommands.PLAN_PROMOTE, {
1290
- id: input.id,
1291
- force: input.force,
1292
- }, {
1293
- projectRoot: options?.projectRoot,
1294
- contextInput: {
1295
- metadata: {
1296
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1297
- },
1298
- },
1299
- fallback: {
1300
- command: CliCommands.PLAN_PROMOTE,
1301
- args,
1302
- errorCode: ErrorCodes.PLAN_PROMOTE_ERROR,
1303
- },
1304
- });
1305
- if (!execution.success) {
1306
- return execution;
1307
- }
1308
- return success(unwrapExecuteViaPackData(execution.data));
1309
- },
1310
- };
1311
- /**
1312
- * signal_cleanup - Clean stale signals
1313
- */
1314
- export const signalCleanupTool = {
1315
- name: 'signal_cleanup',
1316
- description: 'Cleanup stale signals using TTL policy',
1317
- inputSchema: signalCleanupSchema,
1318
- async execute(input, options) {
1319
- const args = [];
1320
- if (input.dry_run)
1321
- args.push('--dry-run');
1322
- if (input.ttl)
1323
- args.push('--ttl', input.ttl);
1324
- if (input.unread_ttl)
1325
- args.push('--unread-ttl', input.unread_ttl);
1326
- if (input.max_entries !== undefined)
1327
- args.push('--max-entries', String(input.max_entries));
1328
- if (input.json)
1329
- args.push(CliArgs.JSON);
1330
- if (input.quiet)
1331
- args.push(CliArgs.QUIET);
1332
- if (input.base_dir)
1333
- args.push(CliArgs.BASE_DIR, input.base_dir);
1334
- const execution = await executeViaPack(CliCommands.SIGNAL_CLEANUP, {
1335
- dry_run: input.dry_run,
1336
- ttl: input.ttl,
1337
- unread_ttl: input.unread_ttl,
1338
- max_entries: input.max_entries,
1339
- json: input.json,
1340
- quiet: input.quiet,
1341
- base_dir: input.base_dir,
1342
- }, {
1343
- projectRoot: options?.projectRoot,
1344
- contextInput: {
1345
- metadata: {
1346
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1347
- },
1348
- },
1349
- fallback: {
1350
- command: CliCommands.SIGNAL_CLEANUP,
1351
- args,
1352
- errorCode: ErrorCodes.SIGNAL_CLEANUP_ERROR,
1353
- },
1354
- });
1355
- if (!execution.success) {
1356
- return execution;
1357
- }
1358
- return success(unwrapExecuteViaPackData(execution.data));
1359
- },
1360
- };
1361
- /**
1362
- * config_set - Safely update .lumenflow.config.yaml via micro-worktree
1363
- * WU-1902: config:set MCP parity tool
1364
- */
1365
- export const configSetTool = {
1366
- name: 'config_set',
1367
- description: 'Safely update .lumenflow.config.yaml via micro-worktree',
1368
- inputSchema: configSetSchema,
1369
- async execute(input, options) {
1370
- if (!input.key) {
1371
- return error(ErrorMessages.KEY_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1372
- }
1373
- if (input.value === undefined) {
1374
- return error(ErrorMessages.VALUE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1375
- }
1376
- const args = ['--key', input.key, '--value', input.value];
1377
- const execution = await executeViaPack(CliCommands.CONFIG_SET, {
1378
- key: input.key,
1379
- value: input.value,
1380
- }, {
1381
- projectRoot: options?.projectRoot,
1382
- contextInput: {
1383
- metadata: {
1384
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1385
- },
1386
- },
1387
- fallback: {
1388
- command: CliCommands.CONFIG_SET,
1389
- args,
1390
- errorCode: ErrorCodes.CONFIG_SET_ERROR,
1391
- },
1392
- });
1393
- if (!execution.success) {
1394
- return execution;
1395
- }
1396
- return success(unwrapExecuteViaPackData(execution.data));
1397
- },
1398
- };
1399
- /**
1400
- * config_get - Read and display a value from .lumenflow.config.yaml
1401
- * WU-1902: config:get MCP parity tool
1402
- */
1403
- export const configGetTool = {
1404
- name: 'config_get',
1405
- description: 'Read and display a value from .lumenflow.config.yaml',
1406
- inputSchema: configGetSchema,
1407
- async execute(input, options) {
1408
- if (!input.key) {
1409
- return error(ErrorMessages.KEY_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1410
- }
1411
- const args = ['--key', input.key];
1412
- const execution = await executeViaPack(CliCommands.CONFIG_GET, {
1413
- key: input.key,
1414
- }, {
1415
- projectRoot: options?.projectRoot,
1416
- contextInput: {
1417
- metadata: {
1418
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1419
- },
1420
- },
1421
- fallback: {
1422
- command: CliCommands.CONFIG_GET,
1423
- args,
1424
- errorCode: ErrorCodes.CONFIG_GET_ERROR,
1425
- },
1426
- });
1427
- if (!execution.success) {
1428
- return execution;
1429
- }
1430
- return success(unwrapExecuteViaPackData(execution.data));
1431
- },
1432
- };
1433
- /**
1434
- * wu_proto - Create and claim a prototype WU
1435
- */
1436
- export const wuProtoTool = {
1437
- name: 'wu_proto',
1438
- description: 'Create and claim a prototype WU with relaxed validation',
1439
- inputSchema: wuProtoSchema,
1440
- async execute(input, options) {
1441
- if (!input.lane) {
1442
- return error(ErrorMessages.LANE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1443
- }
1444
- if (!input.title) {
1445
- return error(ErrorMessages.TITLE_REQUIRED, ErrorCodes.MISSING_PARAMETER);
1446
- }
1447
- const args = [CliArgs.LANE, input.lane, '--title', input.title];
1448
- if (input.description)
1449
- args.push(CliArgs.DESCRIPTION, input.description);
1450
- if (Array.isArray(input.code_paths)) {
1451
- for (const codePath of input.code_paths) {
1452
- args.push(CliArgs.CODE_PATHS, String(codePath));
1453
- }
1454
- }
1455
- if (Array.isArray(input.labels) && input.labels.length > 0) {
1456
- args.push('--labels', input.labels.join(','));
1457
- }
1458
- if (input.assigned_to)
1459
- args.push('--assigned-to', input.assigned_to);
1460
- const execution = await executeViaPack(CliCommands.WU_PROTO, input, {
1461
- projectRoot: options?.projectRoot,
1462
- contextInput: {
1463
- metadata: {
1464
- [MetadataKeys.PROJECT_ROOT]: options?.projectRoot,
1465
- },
1466
- },
1467
- fallback: {
1468
- command: CliCommands.WU_PROTO,
1469
- args,
1470
- errorCode: ErrorCodes.WU_PROTO_ERROR,
1471
- },
1472
- });
1473
- if (!execution.success) {
1474
- return error(execution.error?.message ?? 'wu:proto failed', ErrorCodes.WU_PROTO_ERROR);
1475
- }
1476
- return success(execution.data ?? { message: 'Prototype WU created' });
1477
- },
1478
- };
1479
- //# sourceMappingURL=parity-tools.js.map