@lumenflow/mcp 3.1.3 → 3.2.1

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/dist/bin.d.ts +16 -0
  2. package/dist/bin.d.ts.map +1 -0
  3. package/dist/bin.js.map +1 -0
  4. package/dist/cli-runner.d.ts +58 -0
  5. package/dist/cli-runner.d.ts.map +1 -0
  6. package/dist/cli-runner.js +164 -0
  7. package/dist/cli-runner.js.map +1 -0
  8. package/dist/index.d.ts +37 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/mcp-constants.d.ts +177 -0
  12. package/dist/mcp-constants.d.ts.map +1 -0
  13. package/dist/mcp-constants.js +197 -0
  14. package/dist/mcp-constants.js.map +1 -0
  15. package/dist/resources.d.ts +53 -0
  16. package/dist/resources.d.ts.map +1 -0
  17. package/dist/resources.js +131 -0
  18. package/dist/resources.js.map +1 -0
  19. package/dist/runtime-cache.d.ts +7 -0
  20. package/dist/runtime-cache.d.ts.map +1 -0
  21. package/dist/runtime-cache.js +28 -0
  22. package/dist/runtime-cache.js.map +1 -0
  23. package/dist/runtime-tool-resolver.constants.d.ts +26 -0
  24. package/dist/runtime-tool-resolver.constants.d.ts.map +1 -0
  25. package/dist/runtime-tool-resolver.constants.js +36 -0
  26. package/dist/runtime-tool-resolver.constants.js.map +1 -0
  27. package/dist/runtime-tool-resolver.d.ts +5 -0
  28. package/dist/runtime-tool-resolver.d.ts.map +1 -0
  29. package/dist/runtime-tool-resolver.js +2030 -0
  30. package/dist/runtime-tool-resolver.js.map +1 -0
  31. package/dist/server.d.ts +58 -0
  32. package/dist/server.d.ts.map +1 -0
  33. package/dist/server.js +212 -0
  34. package/dist/server.js.map +1 -0
  35. package/dist/tools/agent-tools.d.ts +18 -0
  36. package/dist/tools/agent-tools.d.ts.map +1 -0
  37. package/dist/tools/agent-tools.js +235 -0
  38. package/dist/tools/agent-tools.js.map +1 -0
  39. package/dist/tools/context-tools.d.ts +13 -0
  40. package/dist/tools/context-tools.d.ts.map +1 -0
  41. package/dist/tools/context-tools.js +58 -0
  42. package/dist/tools/context-tools.js.map +1 -0
  43. package/dist/tools/flow-tools.d.ts +22 -0
  44. package/dist/tools/flow-tools.d.ts.map +1 -0
  45. package/dist/tools/flow-tools.js +130 -0
  46. package/dist/tools/flow-tools.js.map +1 -0
  47. package/dist/tools/initiative-tools.d.ts +34 -0
  48. package/dist/tools/initiative-tools.d.ts.map +1 -0
  49. package/dist/tools/initiative-tools.js +420 -0
  50. package/dist/tools/initiative-tools.js.map +1 -0
  51. package/dist/tools/memory-tools.d.ts +58 -0
  52. package/dist/tools/memory-tools.d.ts.map +1 -0
  53. package/dist/tools/memory-tools.js +523 -0
  54. package/dist/tools/memory-tools.js.map +1 -0
  55. package/dist/tools/orchestration-tools.d.ts +18 -0
  56. package/dist/tools/orchestration-tools.d.ts.map +1 -0
  57. package/dist/tools/orchestration-tools.js +202 -0
  58. package/dist/tools/orchestration-tools.js.map +1 -0
  59. package/dist/tools/parity-tools.d.ts +138 -0
  60. package/dist/tools/parity-tools.d.ts.map +1 -0
  61. package/dist/tools/parity-tools.js +1690 -0
  62. package/dist/tools/parity-tools.js.map +1 -0
  63. package/dist/tools/runtime-task-constants.d.ts +19 -0
  64. package/dist/tools/runtime-task-constants.d.ts.map +1 -0
  65. package/dist/tools/runtime-task-constants.js +21 -0
  66. package/dist/tools/runtime-task-constants.js.map +1 -0
  67. package/dist/tools/runtime-task-tools.d.ts +10 -0
  68. package/dist/tools/runtime-task-tools.d.ts.map +1 -0
  69. package/dist/tools/runtime-task-tools.js +116 -0
  70. package/dist/tools/runtime-task-tools.js.map +1 -0
  71. package/dist/tools/setup-tools.d.ts +34 -0
  72. package/dist/tools/setup-tools.d.ts.map +1 -0
  73. package/dist/tools/setup-tools.js +254 -0
  74. package/dist/tools/setup-tools.js.map +1 -0
  75. package/dist/tools/validation-tools.d.ts +26 -0
  76. package/dist/tools/validation-tools.d.ts.map +1 -0
  77. package/dist/tools/validation-tools.js +180 -0
  78. package/dist/tools/validation-tools.js.map +1 -0
  79. package/dist/tools/wu-tools.d.ts +101 -0
  80. package/dist/tools/wu-tools.d.ts.map +1 -0
  81. package/dist/tools/wu-tools.js +964 -0
  82. package/dist/tools/wu-tools.js.map +1 -0
  83. package/dist/tools-shared.d.ts +257 -0
  84. package/dist/tools-shared.d.ts.map +1 -0
  85. package/dist/tools-shared.js +410 -0
  86. package/dist/tools-shared.js.map +1 -0
  87. package/dist/tools.d.ts +99 -0
  88. package/dist/tools.d.ts.map +1 -0
  89. package/dist/tools.js +253 -0
  90. package/dist/tools.js.map +1 -0
  91. package/dist/worktree-enforcement.d.ts +32 -0
  92. package/dist/worktree-enforcement.d.ts.map +1 -0
  93. package/dist/worktree-enforcement.js +154 -0
  94. package/dist/worktree-enforcement.js.map +1 -0
  95. package/package.json +5 -5
@@ -0,0 +1,410 @@
1
+ // Copyright (c) 2026 Hellmai Ltd
2
+ // SPDX-License-Identifier: AGPL-3.0-only
3
+ /**
4
+ * @file tools-shared.ts
5
+ * @description Shared types, constants, error codes, and helpers used across MCP tool domain modules.
6
+ *
7
+ * WU-1642: Extracted from tools.ts during modular decomposition.
8
+ */
9
+ import { ExecutionContextSchema, TOOL_ERROR_CODES, } from '@lumenflow/kernel';
10
+ import { z } from 'zod';
11
+ import { runCliCommand } from './cli-runner.js';
12
+ import { getRuntimeForWorkspace, resetMcpRuntimeCache, } from './runtime-cache.js';
13
+ import { packToolCapabilityResolver } from './runtime-tool-resolver.js';
14
+ import { McpEnvironmentVariables, MigrationCompatModes, MigrationFallbackErrorCodes, MigrationFallbackOutcomes, MigrationFallbackReasons, } from './mcp-constants.js';
15
+ // Import core functions for context operations only (async to avoid circular deps)
16
+ let coreModule = null;
17
+ export async function getCore() {
18
+ if (!coreModule) {
19
+ coreModule = await import('@lumenflow/core');
20
+ }
21
+ return coreModule;
22
+ }
23
+ /**
24
+ * WU-1859: Narrowed from wildcard write (`**` / `write`) to read-only.
25
+ * Maintenance-mode operations should only need read access by default;
26
+ * write scopes are declared explicitly per-tool via `contextInput.allowedScopes`.
27
+ */
28
+ export const DEFAULT_MAINTENANCE_SCOPE = {
29
+ type: 'path',
30
+ pattern: '**',
31
+ access: 'read',
32
+ };
33
+ const MAINTENANCE_TASK_PREFIX = 'maintenance';
34
+ const MAINTENANCE_SESSION_PREFIX = 'session-maintenance';
35
+ const MAINTENANCE_CONTEXT_MODE = 'maintenance';
36
+ const TASK_CONTEXT_MODE = 'task';
37
+ const DEFAULT_FALLBACK_ERROR_CODE = 'TOOL_EXECUTE_ERROR';
38
+ /**
39
+ * WU-1866: Allowlist of error codes that MAY trigger CLI fallback.
40
+ *
41
+ * Default-deny: any error code NOT in this set is returned directly to the
42
+ * caller without retrying via CLI. This prevents new kernel denial codes
43
+ * (e.g., future AUTH_DENIED) from silently falling through to CLI fallback.
44
+ *
45
+ * Only TOOL_NOT_FOUND is allowed to fall back, for migration/backward compat
46
+ * when a tool exists in CLI but hasn't been registered in the kernel yet.
47
+ */
48
+ export const FALLBACK_ALLOWED_ERROR_CODES = new Set([
49
+ TOOL_ERROR_CODES.TOOL_NOT_FOUND,
50
+ ]);
51
+ /**
52
+ * Error codes used by tool implementations
53
+ */
54
+ export const ErrorCodes = {
55
+ MISSING_PARAMETER: 'MISSING_PARAMETER',
56
+ CONTEXT_ERROR: 'CONTEXT_ERROR',
57
+ WU_LIST_ERROR: 'WU_LIST_ERROR',
58
+ WU_STATUS_ERROR: 'WU_STATUS_ERROR',
59
+ WU_CREATE_ERROR: 'WU_CREATE_ERROR',
60
+ WU_CLAIM_ERROR: 'WU_CLAIM_ERROR',
61
+ WU_DONE_ERROR: 'WU_DONE_ERROR',
62
+ WRONG_LOCATION: 'WRONG_LOCATION',
63
+ GATES_ERROR: 'GATES_ERROR',
64
+ WU_BLOCK_ERROR: 'WU_BLOCK_ERROR',
65
+ WU_UNBLOCK_ERROR: 'WU_UNBLOCK_ERROR',
66
+ WU_EDIT_ERROR: 'WU_EDIT_ERROR',
67
+ WU_RELEASE_ERROR: 'WU_RELEASE_ERROR',
68
+ WU_RECOVER_ERROR: 'WU_RECOVER_ERROR',
69
+ WU_REPAIR_ERROR: 'WU_REPAIR_ERROR',
70
+ WU_DEPS_ERROR: 'WU_DEPS_ERROR',
71
+ WU_PREP_ERROR: 'WU_PREP_ERROR',
72
+ WU_PREFLIGHT_ERROR: 'WU_PREFLIGHT_ERROR',
73
+ WU_PRUNE_ERROR: 'WU_PRUNE_ERROR',
74
+ WU_DELETE_ERROR: 'WU_DELETE_ERROR',
75
+ WU_CLEANUP_ERROR: 'WU_CLEANUP_ERROR',
76
+ WU_BRIEF_ERROR: 'WU_BRIEF_ERROR',
77
+ WU_DELEGATE_ERROR: 'WU_DELEGATE_ERROR',
78
+ WU_VALIDATE_ERROR: 'WU_VALIDATE_ERROR',
79
+ WU_INFER_LANE_ERROR: 'WU_INFER_LANE_ERROR',
80
+ WU_UNLOCK_LANE_ERROR: 'WU_UNLOCK_LANE_ERROR',
81
+ TASK_CLAIM_ERROR: 'TASK_CLAIM_ERROR',
82
+ TASK_CREATE_ERROR: 'TASK_CREATE_ERROR',
83
+ TASK_COMPLETE_ERROR: 'TASK_COMPLETE_ERROR',
84
+ TASK_BLOCK_ERROR: 'TASK_BLOCK_ERROR',
85
+ TASK_UNBLOCK_ERROR: 'TASK_UNBLOCK_ERROR',
86
+ TASK_INSPECT_ERROR: 'TASK_INSPECT_ERROR',
87
+ TOOL_EXECUTE_ERROR: 'TOOL_EXECUTE_ERROR',
88
+ BACKLOG_PRUNE_ERROR: 'BACKLOG_PRUNE_ERROR',
89
+ DOCS_SYNC_ERROR: 'DOCS_SYNC_ERROR',
90
+ GATES_ALIAS_ERROR: 'GATES_ALIAS_ERROR',
91
+ LANE_HEALTH_ERROR: 'LANE_HEALTH_ERROR',
92
+ LANE_SUGGEST_ERROR: 'LANE_SUGGEST_ERROR',
93
+ LUMENFLOW_ALIAS_ERROR: 'LUMENFLOW_ALIAS_ERROR',
94
+ LUMENFLOW_GATES_ERROR: 'LUMENFLOW_GATES_ERROR',
95
+ LUMENFLOW_VALIDATE_ERROR: 'LUMENFLOW_VALIDATE_ERROR',
96
+ LUMENFLOW_METRICS_ERROR: 'LUMENFLOW_METRICS_ERROR',
97
+ METRICS_ERROR: 'METRICS_ERROR',
98
+ STATE_BOOTSTRAP_ERROR: 'STATE_BOOTSTRAP_ERROR',
99
+ STATE_CLEANUP_ERROR: 'STATE_CLEANUP_ERROR',
100
+ STATE_DOCTOR_ERROR: 'STATE_DOCTOR_ERROR',
101
+ SYNC_TEMPLATES_ALIAS_ERROR: 'SYNC_TEMPLATES_ALIAS_ERROR',
102
+ FILE_READ_ERROR: 'FILE_READ_ERROR',
103
+ FILE_WRITE_ERROR: 'FILE_WRITE_ERROR',
104
+ FILE_EDIT_ERROR: 'FILE_EDIT_ERROR',
105
+ FILE_DELETE_ERROR: 'FILE_DELETE_ERROR',
106
+ // WU-1853: Worktree enforcement for MCP file tools
107
+ WORKTREE_ENFORCEMENT_BLOCKED: 'WORKTREE_ENFORCEMENT_BLOCKED',
108
+ GIT_STATUS_ERROR: 'GIT_STATUS_ERROR',
109
+ GIT_DIFF_ERROR: 'GIT_DIFF_ERROR',
110
+ GIT_LOG_ERROR: 'GIT_LOG_ERROR',
111
+ GIT_BRANCH_ERROR: 'GIT_BRANCH_ERROR',
112
+ INIT_PLAN_ERROR: 'INIT_PLAN_ERROR',
113
+ PLAN_CREATE_ERROR: 'PLAN_CREATE_ERROR',
114
+ PLAN_EDIT_ERROR: 'PLAN_EDIT_ERROR',
115
+ PLAN_LINK_ERROR: 'PLAN_LINK_ERROR',
116
+ PLAN_PROMOTE_ERROR: 'PLAN_PROMOTE_ERROR',
117
+ SIGNAL_CLEANUP_ERROR: 'SIGNAL_CLEANUP_ERROR',
118
+ CONFIG_SET_ERROR: 'CONFIG_SET_ERROR',
119
+ CONFIG_GET_ERROR: 'CONFIG_GET_ERROR',
120
+ CLOUD_CONNECT_ERROR: 'CLOUD_CONNECT_ERROR',
121
+ ONBOARD_ERROR: 'ONBOARD_ERROR',
122
+ LUMENFLOW_ONBOARD_ERROR: 'LUMENFLOW_ONBOARD_ERROR',
123
+ WORKSPACE_INIT_ERROR: 'WORKSPACE_INIT_ERROR',
124
+ WU_PROTO_ERROR: 'WU_PROTO_ERROR',
125
+ // WU-1426: Flow/Metrics error codes
126
+ FLOW_BOTTLENECKS_ERROR: 'FLOW_BOTTLENECKS_ERROR',
127
+ FLOW_REPORT_ERROR: 'FLOW_REPORT_ERROR',
128
+ METRICS_SNAPSHOT_ERROR: 'METRICS_SNAPSHOT_ERROR',
129
+ // WU-1426: Validation error codes
130
+ VALIDATE_ERROR: 'VALIDATE_ERROR',
131
+ VALIDATE_AGENT_SKILLS_ERROR: 'VALIDATE_AGENT_SKILLS_ERROR',
132
+ VALIDATE_AGENT_SYNC_ERROR: 'VALIDATE_AGENT_SYNC_ERROR',
133
+ VALIDATE_BACKLOG_SYNC_ERROR: 'VALIDATE_BACKLOG_SYNC_ERROR',
134
+ VALIDATE_SKILLS_SPEC_ERROR: 'VALIDATE_SKILLS_SPEC_ERROR',
135
+ // WU-1426: Setup error codes
136
+ LUMENFLOW_INIT_ERROR: 'LUMENFLOW_INIT_ERROR',
137
+ LUMENFLOW_DOCTOR_ERROR: 'LUMENFLOW_DOCTOR_ERROR',
138
+ LUMENFLOW_INTEGRATE_ERROR: 'LUMENFLOW_INTEGRATE_ERROR',
139
+ LUMENFLOW_UPGRADE_ERROR: 'LUMENFLOW_UPGRADE_ERROR',
140
+ LUMENFLOW_COMMANDS_ERROR: 'LUMENFLOW_COMMANDS_ERROR',
141
+ LUMENFLOW_DOCS_SYNC_ERROR: 'LUMENFLOW_DOCS_SYNC_ERROR',
142
+ LUMENFLOW_RELEASE_ERROR: 'LUMENFLOW_RELEASE_ERROR',
143
+ LUMENFLOW_SYNC_TEMPLATES_ERROR: 'LUMENFLOW_SYNC_TEMPLATES_ERROR',
144
+ };
145
+ /**
146
+ * Error messages used by tool implementations
147
+ */
148
+ export const ErrorMessages = {
149
+ ID_REQUIRED: 'id is required',
150
+ LANE_REQUIRED: 'lane is required',
151
+ TITLE_REQUIRED: 'title is required',
152
+ PATH_REQUIRED: 'path is required',
153
+ CONTENT_REQUIRED: 'content is required',
154
+ OLD_STRING_REQUIRED: 'old_string is required',
155
+ NEW_STRING_REQUIRED: 'new_string is required',
156
+ REASON_REQUIRED: 'reason is required',
157
+ CLIENT_REQUIRED: 'client is required',
158
+ PARENT_WU_REQUIRED: 'parent_wu is required',
159
+ SECTION_REQUIRED: 'section is required',
160
+ PLAN_REQUIRED: 'plan is required',
161
+ KEY_REQUIRED: 'key is required',
162
+ VALUE_REQUIRED: 'value is required',
163
+ ENDPOINT_REQUIRED: 'endpoint is required',
164
+ ORG_ID_REQUIRED: 'org_id is required',
165
+ PROJECT_ID_REQUIRED: 'project_id is required',
166
+ };
167
+ /**
168
+ * CLI argument constants for commonly used flags
169
+ */
170
+ export const CliArgs = {
171
+ DESCRIPTION: '--description',
172
+ INITIATIVE: '--initiative',
173
+ PHASE: '--phase',
174
+ JSON: '--json',
175
+ DOCS_ONLY: '--docs-only',
176
+ CODE_PATHS: '--code-paths',
177
+ BASE_DIR: '--base-dir',
178
+ ENCODING: '--encoding',
179
+ // WU-1452: Commands using --format json (initiative:*, flow:*, metrics)
180
+ FORMAT_JSON: ['--format', 'json'],
181
+ DRY_RUN: '--dry-run',
182
+ THRESHOLD: '--threshold',
183
+ RECOVER: '--recover',
184
+ WU: '--wu',
185
+ // WU-1851: Governed flags (3+ tool threshold)
186
+ FORCE: '--force',
187
+ VERBOSE: '--verbose',
188
+ QUIET: '--quiet',
189
+ EXECUTE: '--execute',
190
+ ID: '--id',
191
+ LANE: '--lane',
192
+ REASON: '--reason',
193
+ PATH: '--path',
194
+ FORMAT: '--format',
195
+ SINCE: '--since',
196
+ STATUS: '--status',
197
+ };
198
+ /**
199
+ * Shared error messages to avoid duplication across different tool categories
200
+ */
201
+ export const SharedErrorMessages = {
202
+ WU_REQUIRED: 'wu is required',
203
+ INITIATIVE_REQUIRED: 'initiative is required',
204
+ };
205
+ export const SuccessMessages = {
206
+ ALL_GATES_PASSED: 'All gates passed',
207
+ };
208
+ /**
209
+ * Create a successful tool result
210
+ */
211
+ export function success(data) {
212
+ return { success: true, data };
213
+ }
214
+ /**
215
+ * Create an error tool result
216
+ */
217
+ export function error(message, code) {
218
+ return { success: false, error: { message, code } };
219
+ }
220
+ export function buildGatesArgs(input, options = {}) {
221
+ const args = [];
222
+ if (options.forceDocsOnly || input.docs_only)
223
+ args.push(CliArgs.DOCS_ONLY);
224
+ if (input.full_lint)
225
+ args.push('--full-lint');
226
+ if (input.full_tests)
227
+ args.push('--full-tests');
228
+ if (input.full_coverage)
229
+ args.push('--full-coverage');
230
+ if (input.coverage_mode)
231
+ args.push('--coverage-mode', input.coverage_mode);
232
+ if (input.verbose)
233
+ args.push(CliArgs.VERBOSE);
234
+ return args;
235
+ }
236
+ export function buildMetricsArgs(input) {
237
+ const args = [];
238
+ if (input.subcommand)
239
+ args.push(input.subcommand);
240
+ if (input.days !== undefined)
241
+ args.push('--days', String(input.days));
242
+ if (input.format)
243
+ args.push('--format', input.format);
244
+ if (input.output)
245
+ args.push('--output', input.output);
246
+ if (input.dry_run)
247
+ args.push('--dry-run');
248
+ return args;
249
+ }
250
+ /**
251
+ * Build common argument list for wu:brief / wu:delegate prompt tools.
252
+ */
253
+ export function buildWuPromptArgs(input) {
254
+ const args = ['--id', input.id];
255
+ if (input.client)
256
+ args.push('--client', input.client);
257
+ if (input.thinking)
258
+ args.push('--thinking');
259
+ if (input.budget)
260
+ args.push('--budget', String(input.budget));
261
+ if (input.parent_wu)
262
+ args.push('--parent-wu', input.parent_wu);
263
+ if (input.no_context)
264
+ args.push('--no-context');
265
+ return args;
266
+ }
267
+ function buildMaintenanceSuffix(timestamp) {
268
+ return timestamp.getTime().toString(36);
269
+ }
270
+ export function buildExecutionContext(input = {}) {
271
+ const now = input.now ?? (() => new Date());
272
+ const timestamp = now();
273
+ const maintenanceSuffix = buildMaintenanceSuffix(timestamp);
274
+ const taskId = input.taskId ?? `${MAINTENANCE_TASK_PREFIX}-${maintenanceSuffix}`;
275
+ const runId = input.runId ?? `run-${taskId}-${maintenanceSuffix}`;
276
+ const sessionId = input.sessionId ?? `${MAINTENANCE_SESSION_PREFIX}-${maintenanceSuffix}`;
277
+ const invocationMode = input.taskId ? TASK_CONTEXT_MODE : MAINTENANCE_CONTEXT_MODE;
278
+ return ExecutionContextSchema.parse({
279
+ run_id: runId,
280
+ task_id: taskId,
281
+ session_id: sessionId,
282
+ allowed_scopes: input.allowedScopes ?? [DEFAULT_MAINTENANCE_SCOPE],
283
+ metadata: {
284
+ invocation_mode: invocationMode,
285
+ ...(input.metadata ?? {}),
286
+ },
287
+ });
288
+ }
289
+ export function resetExecuteViaPackRuntimeCache() {
290
+ resetMcpRuntimeCache();
291
+ }
292
+ async function runtimeFactoryForPack(workspaceRoot) {
293
+ return getRuntimeForWorkspace(workspaceRoot, packToolCapabilityResolver);
294
+ }
295
+ function resolveMigrationCompatMode(mode) {
296
+ if (mode) {
297
+ return mode;
298
+ }
299
+ const envMode = process.env[McpEnvironmentVariables.MIGRATION_COMPAT_MODE]?.trim().toLowerCase();
300
+ return envMode === MigrationCompatModes.COMPAT
301
+ ? MigrationCompatModes.COMPAT
302
+ : MigrationCompatModes.STRICT;
303
+ }
304
+ function buildMigrationFallbackTelemetryEvent(options) {
305
+ return {
306
+ toolName: options.toolName,
307
+ reason: options.reason,
308
+ workspaceRoot: options.workspaceRoot,
309
+ command: options.command,
310
+ args: options.args,
311
+ mode: options.mode,
312
+ outcome: options.outcome,
313
+ };
314
+ }
315
+ export async function executeViaPack(toolName, toolInput, options) {
316
+ const projectRoot = options.projectRoot ?? process.cwd();
317
+ const runtimeFactory = options.runtimeFactory ?? runtimeFactoryForPack;
318
+ const cliRunner = options.cliRunner ?? runCliCommand;
319
+ const executionContext = options.context ?? buildExecutionContext(options.contextInput);
320
+ const compatMode = resolveMigrationCompatMode(options.migrationCompatMode);
321
+ let runtimeFailureMessage;
322
+ let fallbackReason;
323
+ // Separate runtime init from tool execution so that init failures
324
+ // (factory throws) still fall back to CLI, while executeTool failures
325
+ // are handled by the allowlist below.
326
+ let runtime;
327
+ try {
328
+ runtime = await runtimeFactory(projectRoot);
329
+ }
330
+ catch (cause) {
331
+ runtimeFailureMessage = cause.message;
332
+ fallbackReason = MigrationFallbackReasons.RUNTIME_INIT_FAILED;
333
+ }
334
+ if (runtime) {
335
+ try {
336
+ const runtimeResult = await runtime.executeTool(toolName, toolInput, executionContext);
337
+ if (runtimeResult.success) {
338
+ return success(runtimeResult);
339
+ }
340
+ // WU-1866: Allowlist pattern -- only error codes in
341
+ // FALLBACK_ALLOWED_ERROR_CODES may trigger CLI fallback.
342
+ // All other codes (including unknown/future codes) are returned
343
+ // directly. This is default-deny for fallback.
344
+ const errorCode = runtimeResult.error?.code;
345
+ if (!errorCode || !FALLBACK_ALLOWED_ERROR_CODES.has(errorCode)) {
346
+ return error(runtimeResult.error?.message ?? `${toolName} failed`, errorCode ?? DEFAULT_FALLBACK_ERROR_CODE);
347
+ }
348
+ runtimeFailureMessage = runtimeResult.error?.message;
349
+ fallbackReason = MigrationFallbackReasons.RUNTIME_TOOL_NOT_FOUND;
350
+ }
351
+ catch (cause) {
352
+ // WU-1866: Thrown exceptions from executeTool are returned directly.
353
+ // They represent unexpected runtime failures that should not be
354
+ // silently retried via CLI.
355
+ return error(cause.message, DEFAULT_FALLBACK_ERROR_CODE);
356
+ }
357
+ }
358
+ if (fallbackReason && compatMode === MigrationCompatModes.STRICT) {
359
+ options.onFallbackTelemetry?.(buildMigrationFallbackTelemetryEvent({
360
+ toolName,
361
+ reason: fallbackReason,
362
+ workspaceRoot: projectRoot,
363
+ command: options.fallback.command,
364
+ args: options.fallback.args ?? [],
365
+ mode: compatMode,
366
+ outcome: MigrationFallbackOutcomes.BLOCKED,
367
+ }));
368
+ const strictMessageDetail = runtimeFailureMessage ??
369
+ `runtime fallback reason: ${fallbackReason === MigrationFallbackReasons.RUNTIME_INIT_FAILED ? 'runtime initialization failed' : 'runtime reported tool not found'}`;
370
+ return error(`Migration fallback is disabled in strict mode for ${toolName}: ${strictMessageDetail}`, MigrationFallbackErrorCodes.DISABLED);
371
+ }
372
+ const fallbackResult = await cliRunner(options.fallback.command, options.fallback.args ?? [], {
373
+ projectRoot,
374
+ ...(options.fallbackCliOptions ?? {}),
375
+ });
376
+ const fallbackTelemetry = fallbackReason
377
+ ? buildMigrationFallbackTelemetryEvent({
378
+ toolName,
379
+ reason: fallbackReason,
380
+ workspaceRoot: projectRoot,
381
+ command: options.fallback.command,
382
+ args: options.fallback.args ?? [],
383
+ mode: compatMode,
384
+ outcome: fallbackResult.success
385
+ ? MigrationFallbackOutcomes.SUCCEEDED
386
+ : MigrationFallbackOutcomes.FAILED,
387
+ })
388
+ : undefined;
389
+ if (fallbackTelemetry) {
390
+ options.onFallbackTelemetry?.(fallbackTelemetry);
391
+ }
392
+ if (fallbackResult.success) {
393
+ return success({
394
+ message: fallbackResult.stdout || `${options.fallback.command} succeeded`,
395
+ ...(fallbackTelemetry ? { fallbackTelemetry } : {}),
396
+ });
397
+ }
398
+ const fallbackErrorCode = fallbackReason && compatMode === MigrationCompatModes.COMPAT
399
+ ? (options.fallback.migrationErrorCode ??
400
+ options.fallback.errorCode ??
401
+ MigrationFallbackErrorCodes.EXECUTION_FAILED)
402
+ : (options.fallback.errorCode ?? DEFAULT_FALLBACK_ERROR_CODE);
403
+ return error(fallbackResult.stderr ||
404
+ fallbackResult.error?.message ||
405
+ runtimeFailureMessage ||
406
+ `${options.fallback.command} failed`, fallbackErrorCode);
407
+ }
408
+ // Re-export cli-runner types used by domain modules
409
+ export { runCliCommand };
410
+ //# sourceMappingURL=tools-shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools-shared.js","sourceRoot":"","sources":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O,OAAO,CAAC;YACb,OAAO,EAAE,cAAc,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,YAAY;YACzE,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACpD,CAAC,CAAC;IACL,CAAC;IAED,MAAM,iBAAiB,GACrB,cAAc,IAAI,UAAU,KAAK,oBAAoB,CAAC,MAAM;QAC1D,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;YACpC,OAAO,CAAC,QAAQ,CAAC,SAAS;YAC1B,2BAA2B,CAAC,gBAAgB,CAAC;QAC/C,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,IAAI,2BAA2B,CAAC,CAAC;IAElE,OAAO,KAAK,CACV,cAAc,CAAC,MAAM;QACnB,cAAc,CAAC,KAAK,EAAE,OAAO;QAC7B,qBAAqB;QACrB,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,SAAS,EACtC,iBAAiB,CAClB,CAAC;AACJ,CAAC;AAED,oDAAoD;AACpD,OAAO,EAAE,aAAa,EAAyB,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @file tools.ts
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
17
+ *
18
+ * WU-1412: Tools available: context_get, wu_list, wu_status, wu_create, wu_claim, wu_done, gates_run
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
23
+ * WU-1431: Uses shared Zod schemas from @lumenflow/core for CLI/MCP parity
24
+ * WU-1454: All 16 WU lifecycle commands now use shared schemas
25
+ * WU-1456: Memory commands use shared schemas where available
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
+ * WU-1952: CLI added pack:author; MCP parity follow-up remains tracked explicitly in INIT-032.
30
+ * WU-1980: CLI added cloud:connect; MCP parity implementation is intentionally
31
+ * tracked in WU-1983 (INIT-033 phase sequence).
32
+ */
33
+ export type { ToolResult, ToolDefinition } from './tools-shared.js';
34
+ export { contextGetTool, wuListTool } from './tools/context-tools.js';
35
+ export { wuStatusTool, wuCreateTool, wuClaimTool, wuSandboxTool, wuDoneTool, gatesRunTool, wuBlockTool, wuUnblockTool, wuEditTool, wuReleaseTool, wuRecoverTool, wuRepairTool, wuDepsTool, wuPrepTool, wuPreflightTool, wuPruneTool, wuDeleteTool, wuCleanupTool, wuBriefTool, wuDelegateTool, wuValidateTool, wuInferLaneTool, wuUnlockLaneTool, } from './tools/wu-tools.js';
36
+ export { taskBlockTool, taskClaimTool, taskCompleteTool, taskCreateTool, taskInspectTool, taskToolExecuteTool, taskUnblockTool, } from './tools/runtime-task-tools.js';
37
+ export { initiativeListTool, initiativeStatusTool, initiativeCreateTool, initiativeEditTool, initiativeAddWuTool, initiativeRemoveWuTool, initiatiBulkAssignTool, initiativePlanTool, } from './tools/initiative-tools.js';
38
+ export { memInitTool, memStartTool, memReadyTool, memCheckpointTool, memCleanupTool, memContextTool, memCreateTool, memDeleteTool, memExportTool, memInboxTool, memSignalTool, memSummarizeTool, memTriageTool, memRecoverTool, } from './tools/memory-tools.js';
39
+ export { agentSessionTool, agentSessionEndTool, agentLogIssueTool, agentIssuesQueryTool, } from './tools/agent-tools.js';
40
+ export { orchestrateInitiativeTool, orchestrateInitStatusTool, orchestrateMonitorTool, delegationListTool, } from './tools/orchestration-tools.js';
41
+ export { flowBottlenecksTool, flowReportTool, metricsSnapshotTool, lumenflowMetricsTool, metricsTool, } from './tools/flow-tools.js';
42
+ export { validateTool, validateAgentSkillsTool, validateAgentSyncTool, validateBacklogSyncTool, validateSkillsSpecTool, lumenflowValidateTool, } from './tools/validation-tools.js';
43
+ export { lumenflowInitTool, lumenflowDoctorTool, lumenflowIntegrateTool, lumenflowUpgradeTool, lumenflowCommandsTool, lumenflowDocsSyncTool, lumenflowReleaseTool, lumenflowSyncTemplatesTool, } from './tools/setup-tools.js';
44
+ 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, configSetTool, configGetTool, cloudConnectTool, onboardTool, lumenflowOnboardTool, workspaceInitTool, wuProtoTool, } from './tools/parity-tools.js';
45
+ import type { ToolDefinition } from './tools-shared.js';
46
+ /**
47
+ * MCP parity exclusions for tools that are intentionally MCP-only or maintainer-only.
48
+ *
49
+ * These names are excluded from strict public CLI parity comparison because
50
+ * they have no public command in packages/@lumenflow/cli/src/public-manifest.ts.
51
+ */
52
+ export declare const MCP_PUBLIC_PARITY_ALLOWED_EXTRA_TOOLS: readonly ["context_get", "gates_run", "initiative_remove_wu", "task_block", "task_complete", "task_create", "task_inspect", "task_unblock", "tool_execute", "validate_agent_skills", "validate_agent_sync", "validate_backlog_sync", "validate_skills_spec", "wu_list"];
53
+ /**
54
+ * Public CLI commands intentionally out of MCP scope.
55
+ *
56
+ * These normalized command names are excluded from the "missing" parity
57
+ * calculation so MCP parity reflects the supported public MCP surface.
58
+ */
59
+ export declare const MCP_PUBLIC_PARITY_ALLOWED_MISSING_TOOLS: readonly ["lane_edit", "lane_lock", "lane_setup", "lane_status", "lane_validate", "pack_scaffold"];
60
+ export interface McpManifestParityReport {
61
+ missing: string[];
62
+ allowedExtra: string[];
63
+ unexpectedExtra: string[];
64
+ }
65
+ /**
66
+ * Normalize public CLI command names to MCP tool naming.
67
+ *
68
+ * Example:
69
+ * - "wu:create" -> "wu_create"
70
+ * - "plan:promote" -> "plan_promote"
71
+ */
72
+ export declare function normalizePublicManifestCommandName(commandName: string): string;
73
+ /**
74
+ * Compare public CLI manifest command names against MCP tool names.
75
+ */
76
+ export declare function buildMcpManifestParityReport(manifestCommandNames: readonly string[], mcpToolNames: readonly string[]): McpManifestParityReport;
77
+ /**
78
+ * All available tools
79
+ */
80
+ export declare const allTools: ToolDefinition[];
81
+ /**
82
+ * Runtime-backed additive MCP tools.
83
+ *
84
+ * These are intentionally isolated from legacy CLI-shell tools so we can
85
+ * migrate command-by-command without breaking parity gates.
86
+ *
87
+ * NOTE:
88
+ * `allTools` remains the legacy parity baseline for strict CLI parity checks
89
+ * that intentionally ignore runtime migration deltas.
90
+ *
91
+ * Phase-4 closure metrics use `registeredTools` (production registry) so
92
+ * runtime-migrated tools are measured against the real server surface.
93
+ */
94
+ export declare const runtimeTaskTools: ToolDefinition[];
95
+ /**
96
+ * Production MCP registry consumed by server startup.
97
+ */
98
+ export declare const registeredTools: ToolDefinition[];
99
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,YAAY,EAAE,UAAU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