@lumenflow/mcp 3.2.0 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.d.ts +16 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli-runner.d.ts +58 -0
- package/dist/cli-runner.d.ts.map +1 -0
- package/dist/cli-runner.js +164 -0
- package/dist/cli-runner.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp-constants.d.ts +177 -0
- package/dist/mcp-constants.d.ts.map +1 -0
- package/dist/mcp-constants.js +197 -0
- package/dist/mcp-constants.js.map +1 -0
- package/dist/resources.d.ts +53 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +131 -0
- package/dist/resources.js.map +1 -0
- package/dist/runtime-cache.d.ts +7 -0
- package/dist/runtime-cache.d.ts.map +1 -0
- package/dist/runtime-cache.js +28 -0
- package/dist/runtime-cache.js.map +1 -0
- package/dist/runtime-tool-resolver.constants.d.ts +26 -0
- package/dist/runtime-tool-resolver.constants.d.ts.map +1 -0
- package/dist/runtime-tool-resolver.constants.js +36 -0
- package/dist/runtime-tool-resolver.constants.js.map +1 -0
- package/dist/runtime-tool-resolver.d.ts +5 -0
- package/dist/runtime-tool-resolver.d.ts.map +1 -0
- package/dist/runtime-tool-resolver.js +2030 -0
- package/dist/runtime-tool-resolver.js.map +1 -0
- package/dist/server.d.ts +58 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +212 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/agent-tools.d.ts +18 -0
- package/dist/tools/agent-tools.d.ts.map +1 -0
- package/dist/tools/agent-tools.js +235 -0
- package/dist/tools/agent-tools.js.map +1 -0
- package/dist/tools/context-tools.d.ts +13 -0
- package/dist/tools/context-tools.d.ts.map +1 -0
- package/dist/tools/context-tools.js +58 -0
- package/dist/tools/context-tools.js.map +1 -0
- package/dist/tools/flow-tools.d.ts +22 -0
- package/dist/tools/flow-tools.d.ts.map +1 -0
- package/dist/tools/flow-tools.js +130 -0
- package/dist/tools/flow-tools.js.map +1 -0
- package/dist/tools/initiative-tools.d.ts +34 -0
- package/dist/tools/initiative-tools.d.ts.map +1 -0
- package/dist/tools/initiative-tools.js +420 -0
- package/dist/tools/initiative-tools.js.map +1 -0
- package/dist/tools/memory-tools.d.ts +58 -0
- package/dist/tools/memory-tools.d.ts.map +1 -0
- package/dist/tools/memory-tools.js +523 -0
- package/dist/tools/memory-tools.js.map +1 -0
- package/dist/tools/orchestration-tools.d.ts +18 -0
- package/dist/tools/orchestration-tools.d.ts.map +1 -0
- package/dist/tools/orchestration-tools.js +202 -0
- package/dist/tools/orchestration-tools.js.map +1 -0
- package/dist/tools/parity-tools.d.ts +138 -0
- package/dist/tools/parity-tools.d.ts.map +1 -0
- package/dist/tools/parity-tools.js +1690 -0
- package/dist/tools/parity-tools.js.map +1 -0
- package/dist/tools/runtime-task-constants.d.ts +19 -0
- package/dist/tools/runtime-task-constants.d.ts.map +1 -0
- package/dist/tools/runtime-task-constants.js +21 -0
- package/dist/tools/runtime-task-constants.js.map +1 -0
- package/dist/tools/runtime-task-tools.d.ts +10 -0
- package/dist/tools/runtime-task-tools.d.ts.map +1 -0
- package/dist/tools/runtime-task-tools.js +116 -0
- package/dist/tools/runtime-task-tools.js.map +1 -0
- package/dist/tools/setup-tools.d.ts +34 -0
- package/dist/tools/setup-tools.d.ts.map +1 -0
- package/dist/tools/setup-tools.js +254 -0
- package/dist/tools/setup-tools.js.map +1 -0
- package/dist/tools/validation-tools.d.ts +26 -0
- package/dist/tools/validation-tools.d.ts.map +1 -0
- package/dist/tools/validation-tools.js +180 -0
- package/dist/tools/validation-tools.js.map +1 -0
- package/dist/tools/wu-tools.d.ts +101 -0
- package/dist/tools/wu-tools.d.ts.map +1 -0
- package/dist/tools/wu-tools.js +964 -0
- package/dist/tools/wu-tools.js.map +1 -0
- package/dist/tools-shared.d.ts +257 -0
- package/dist/tools-shared.d.ts.map +1 -0
- package/dist/tools-shared.js +410 -0
- package/dist/tools-shared.js.map +1 -0
- package/dist/tools.d.ts +99 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +253 -0
- package/dist/tools.js.map +1 -0
- package/dist/worktree-enforcement.d.ts +32 -0
- package/dist/worktree-enforcement.d.ts.map +1 -0
- package/dist/worktree-enforcement.js +154 -0
- package/dist/worktree-enforcement.js.map +1 -0
- package/package.json +5 -5
package/dist/tools.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
// Re-export domain tools -- context/read operations
|
|
4
|
+
export { contextGetTool, wuListTool } from './tools/context-tools.js';
|
|
5
|
+
// Re-export domain tools -- WU lifecycle
|
|
6
|
+
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';
|
|
7
|
+
// Re-export runtime tracer-bullet tools
|
|
8
|
+
export { taskBlockTool, taskClaimTool, taskCompleteTool, taskCreateTool, taskInspectTool, taskToolExecuteTool, taskUnblockTool, } from './tools/runtime-task-tools.js';
|
|
9
|
+
// Re-export domain tools -- initiative
|
|
10
|
+
export { initiativeListTool, initiativeStatusTool, initiativeCreateTool, initiativeEditTool, initiativeAddWuTool, initiativeRemoveWuTool, initiatiBulkAssignTool, initiativePlanTool, } from './tools/initiative-tools.js';
|
|
11
|
+
// Re-export domain tools -- memory
|
|
12
|
+
export { memInitTool, memStartTool, memReadyTool, memCheckpointTool, memCleanupTool, memContextTool, memCreateTool, memDeleteTool, memExportTool, memInboxTool, memSignalTool, memSummarizeTool, memTriageTool, memRecoverTool, } from './tools/memory-tools.js';
|
|
13
|
+
// Re-export domain tools -- agent
|
|
14
|
+
export { agentSessionTool, agentSessionEndTool, agentLogIssueTool, agentIssuesQueryTool, } from './tools/agent-tools.js';
|
|
15
|
+
// Re-export domain tools -- orchestration + delegation
|
|
16
|
+
export { orchestrateInitiativeTool, orchestrateInitStatusTool, orchestrateMonitorTool, delegationListTool, } from './tools/orchestration-tools.js';
|
|
17
|
+
// Re-export domain tools -- flow/metrics
|
|
18
|
+
export { flowBottlenecksTool, flowReportTool, metricsSnapshotTool, lumenflowMetricsTool, metricsTool, } from './tools/flow-tools.js';
|
|
19
|
+
// Re-export domain tools -- validation
|
|
20
|
+
export { validateTool, validateAgentSkillsTool, validateAgentSyncTool, validateBacklogSyncTool, validateSkillsSpecTool, lumenflowValidateTool, } from './tools/validation-tools.js';
|
|
21
|
+
// Re-export domain tools -- setup
|
|
22
|
+
export { lumenflowInitTool, lumenflowDoctorTool, lumenflowIntegrateTool, lumenflowUpgradeTool, lumenflowCommandsTool, lumenflowDocsSyncTool, lumenflowReleaseTool, lumenflowSyncTemplatesTool, } from './tools/setup-tools.js';
|
|
23
|
+
// Re-export domain tools -- wave-1/wave-2 parity
|
|
24
|
+
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';
|
|
25
|
+
import { contextGetTool, wuListTool } from './tools/context-tools.js';
|
|
26
|
+
import { 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';
|
|
27
|
+
import { taskBlockTool, taskClaimTool, taskCompleteTool, taskCreateTool, taskInspectTool, taskToolExecuteTool, taskUnblockTool, } from './tools/runtime-task-tools.js';
|
|
28
|
+
import { RuntimeTaskToolNames } from './tools/runtime-task-constants.js';
|
|
29
|
+
import { initiativeListTool, initiativeStatusTool, initiativeCreateTool, initiativeEditTool, initiativeAddWuTool, initiativeRemoveWuTool, initiatiBulkAssignTool, initiativePlanTool, } from './tools/initiative-tools.js';
|
|
30
|
+
import { memInitTool, memStartTool, memReadyTool, memCheckpointTool, memCleanupTool, memContextTool, memCreateTool, memDeleteTool, memExportTool, memInboxTool, memSignalTool, memSummarizeTool, memTriageTool, memRecoverTool, } from './tools/memory-tools.js';
|
|
31
|
+
import { agentSessionTool, agentSessionEndTool, agentLogIssueTool, agentIssuesQueryTool, } from './tools/agent-tools.js';
|
|
32
|
+
import { orchestrateInitiativeTool, orchestrateInitStatusTool, orchestrateMonitorTool, delegationListTool, } from './tools/orchestration-tools.js';
|
|
33
|
+
import { flowBottlenecksTool, flowReportTool, metricsSnapshotTool, lumenflowMetricsTool, metricsTool, } from './tools/flow-tools.js';
|
|
34
|
+
import { validateTool, validateAgentSkillsTool, validateAgentSyncTool, validateBacklogSyncTool, validateSkillsSpecTool, lumenflowValidateTool, } from './tools/validation-tools.js';
|
|
35
|
+
import { lumenflowInitTool, lumenflowDoctorTool, lumenflowIntegrateTool, lumenflowUpgradeTool, lumenflowCommandsTool, lumenflowDocsSyncTool, lumenflowReleaseTool, lumenflowSyncTemplatesTool, } from './tools/setup-tools.js';
|
|
36
|
+
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, configSetTool, configGetTool, cloudConnectTool, onboardTool, lumenflowOnboardTool, workspaceInitTool, wuProtoTool, } from './tools/parity-tools.js';
|
|
37
|
+
/**
|
|
38
|
+
* MCP parity exclusions for tools that are intentionally MCP-only or maintainer-only.
|
|
39
|
+
*
|
|
40
|
+
* These names are excluded from strict public CLI parity comparison because
|
|
41
|
+
* they have no public command in packages/@lumenflow/cli/src/public-manifest.ts.
|
|
42
|
+
*/
|
|
43
|
+
export const MCP_PUBLIC_PARITY_ALLOWED_EXTRA_TOOLS = [
|
|
44
|
+
'context_get',
|
|
45
|
+
'gates_run',
|
|
46
|
+
'initiative_remove_wu',
|
|
47
|
+
RuntimeTaskToolNames.TASK_BLOCK,
|
|
48
|
+
RuntimeTaskToolNames.TASK_COMPLETE,
|
|
49
|
+
RuntimeTaskToolNames.TASK_CREATE,
|
|
50
|
+
RuntimeTaskToolNames.TASK_INSPECT,
|
|
51
|
+
RuntimeTaskToolNames.TASK_UNBLOCK,
|
|
52
|
+
RuntimeTaskToolNames.TOOL_EXECUTE,
|
|
53
|
+
'validate_agent_skills',
|
|
54
|
+
'validate_agent_sync',
|
|
55
|
+
'validate_backlog_sync',
|
|
56
|
+
'validate_skills_spec',
|
|
57
|
+
'wu_list',
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Public CLI commands intentionally out of MCP scope.
|
|
61
|
+
*
|
|
62
|
+
* These normalized command names are excluded from the "missing" parity
|
|
63
|
+
* calculation so MCP parity reflects the supported public MCP surface.
|
|
64
|
+
*/
|
|
65
|
+
export const MCP_PUBLIC_PARITY_ALLOWED_MISSING_TOOLS = [
|
|
66
|
+
'lane_edit',
|
|
67
|
+
'lane_lock',
|
|
68
|
+
'lane_setup',
|
|
69
|
+
'lane_status',
|
|
70
|
+
'lane_validate',
|
|
71
|
+
'pack_scaffold',
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* Normalize public CLI command names to MCP tool naming.
|
|
75
|
+
*
|
|
76
|
+
* Example:
|
|
77
|
+
* - "wu:create" -> "wu_create"
|
|
78
|
+
* - "plan:promote" -> "plan_promote"
|
|
79
|
+
*/
|
|
80
|
+
export function normalizePublicManifestCommandName(commandName) {
|
|
81
|
+
return commandName.replace(/[:-]/g, '_');
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Compare public CLI manifest command names against MCP tool names.
|
|
85
|
+
*/
|
|
86
|
+
export function buildMcpManifestParityReport(manifestCommandNames, mcpToolNames) {
|
|
87
|
+
const normalizedManifest = new Set(manifestCommandNames.map((commandName) => normalizePublicManifestCommandName(commandName)));
|
|
88
|
+
const mcpToolSet = new Set(mcpToolNames);
|
|
89
|
+
const allowedExtraSet = new Set(MCP_PUBLIC_PARITY_ALLOWED_EXTRA_TOOLS);
|
|
90
|
+
const allowedMissingSet = new Set(MCP_PUBLIC_PARITY_ALLOWED_MISSING_TOOLS);
|
|
91
|
+
const missing = [...normalizedManifest]
|
|
92
|
+
.filter((name) => !mcpToolSet.has(name) && !allowedMissingSet.has(name))
|
|
93
|
+
.sort();
|
|
94
|
+
const allowedExtra = [...mcpToolSet]
|
|
95
|
+
.filter((name) => !normalizedManifest.has(name) && allowedExtraSet.has(name))
|
|
96
|
+
.sort();
|
|
97
|
+
const unexpectedExtra = [...mcpToolSet]
|
|
98
|
+
.filter((name) => !normalizedManifest.has(name) && !allowedExtraSet.has(name))
|
|
99
|
+
.sort();
|
|
100
|
+
return { missing, allowedExtra, unexpectedExtra };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* All available tools
|
|
104
|
+
*/
|
|
105
|
+
export const allTools = [
|
|
106
|
+
contextGetTool,
|
|
107
|
+
wuListTool,
|
|
108
|
+
wuStatusTool,
|
|
109
|
+
wuCreateTool,
|
|
110
|
+
wuClaimTool,
|
|
111
|
+
wuSandboxTool,
|
|
112
|
+
wuDoneTool,
|
|
113
|
+
gatesRunTool,
|
|
114
|
+
// WU-1482: Wave-1 public parity tools
|
|
115
|
+
backlogPruneTool,
|
|
116
|
+
docsSyncTool,
|
|
117
|
+
gatesTool,
|
|
118
|
+
gatesDocsTool,
|
|
119
|
+
laneHealthTool,
|
|
120
|
+
laneSuggestTool,
|
|
121
|
+
lumenflowTool,
|
|
122
|
+
lumenflowGatesTool,
|
|
123
|
+
lumenflowValidateTool,
|
|
124
|
+
lumenflowMetricsTool,
|
|
125
|
+
metricsTool,
|
|
126
|
+
stateBootstrapTool,
|
|
127
|
+
stateCleanupTool,
|
|
128
|
+
stateDoctorTool,
|
|
129
|
+
syncTemplatesTool,
|
|
130
|
+
// WU-1483: Wave-2 public parity tools
|
|
131
|
+
fileReadTool,
|
|
132
|
+
fileWriteTool,
|
|
133
|
+
fileEditTool,
|
|
134
|
+
fileDeleteTool,
|
|
135
|
+
gitStatusTool,
|
|
136
|
+
gitDiffTool,
|
|
137
|
+
gitLogTool,
|
|
138
|
+
gitBranchTool,
|
|
139
|
+
initPlanTool,
|
|
140
|
+
planCreateTool,
|
|
141
|
+
planEditTool,
|
|
142
|
+
planLinkTool,
|
|
143
|
+
planPromoteTool,
|
|
144
|
+
signalCleanupTool,
|
|
145
|
+
// WU-1902: Config tools
|
|
146
|
+
configSetTool,
|
|
147
|
+
configGetTool,
|
|
148
|
+
// WU-1983: Bootstrap/cloud parity tools
|
|
149
|
+
cloudConnectTool,
|
|
150
|
+
onboardTool,
|
|
151
|
+
lumenflowOnboardTool,
|
|
152
|
+
workspaceInitTool,
|
|
153
|
+
wuProtoTool,
|
|
154
|
+
// WU-1422: Additional WU tools
|
|
155
|
+
wuBlockTool,
|
|
156
|
+
wuUnblockTool,
|
|
157
|
+
wuEditTool,
|
|
158
|
+
wuReleaseTool,
|
|
159
|
+
wuRecoverTool,
|
|
160
|
+
wuRepairTool,
|
|
161
|
+
wuDepsTool,
|
|
162
|
+
wuPrepTool,
|
|
163
|
+
wuPreflightTool,
|
|
164
|
+
wuPruneTool,
|
|
165
|
+
wuDeleteTool,
|
|
166
|
+
wuCleanupTool,
|
|
167
|
+
wuBriefTool,
|
|
168
|
+
wuDelegateTool,
|
|
169
|
+
wuValidateTool,
|
|
170
|
+
wuInferLaneTool,
|
|
171
|
+
wuUnlockLaneTool,
|
|
172
|
+
// WU-1424: Initiative tools
|
|
173
|
+
initiativeListTool,
|
|
174
|
+
initiativeStatusTool,
|
|
175
|
+
initiativeCreateTool,
|
|
176
|
+
initiativeEditTool,
|
|
177
|
+
initiativeAddWuTool,
|
|
178
|
+
initiativeRemoveWuTool,
|
|
179
|
+
initiatiBulkAssignTool,
|
|
180
|
+
initiativePlanTool,
|
|
181
|
+
// WU-1424: Memory tools
|
|
182
|
+
memInitTool,
|
|
183
|
+
memStartTool,
|
|
184
|
+
memReadyTool,
|
|
185
|
+
memCheckpointTool,
|
|
186
|
+
memCleanupTool,
|
|
187
|
+
memContextTool,
|
|
188
|
+
memCreateTool,
|
|
189
|
+
memDeleteTool,
|
|
190
|
+
memExportTool,
|
|
191
|
+
memInboxTool,
|
|
192
|
+
memSignalTool,
|
|
193
|
+
memSummarizeTool,
|
|
194
|
+
memTriageTool,
|
|
195
|
+
memRecoverTool,
|
|
196
|
+
// WU-1425: Agent tools
|
|
197
|
+
agentSessionTool,
|
|
198
|
+
agentSessionEndTool,
|
|
199
|
+
agentLogIssueTool,
|
|
200
|
+
agentIssuesQueryTool,
|
|
201
|
+
// WU-1425: Orchestration tools
|
|
202
|
+
orchestrateInitiativeTool,
|
|
203
|
+
orchestrateInitStatusTool,
|
|
204
|
+
orchestrateMonitorTool,
|
|
205
|
+
// WU-1425: Delegation tools
|
|
206
|
+
delegationListTool,
|
|
207
|
+
// WU-1426: Flow/Metrics tools
|
|
208
|
+
flowBottlenecksTool,
|
|
209
|
+
flowReportTool,
|
|
210
|
+
metricsSnapshotTool,
|
|
211
|
+
// WU-1426: Validation tools
|
|
212
|
+
validateTool,
|
|
213
|
+
validateAgentSkillsTool,
|
|
214
|
+
validateAgentSyncTool,
|
|
215
|
+
validateBacklogSyncTool,
|
|
216
|
+
validateSkillsSpecTool,
|
|
217
|
+
// WU-1426: Setup tools
|
|
218
|
+
lumenflowInitTool,
|
|
219
|
+
lumenflowDoctorTool,
|
|
220
|
+
lumenflowIntegrateTool,
|
|
221
|
+
lumenflowUpgradeTool,
|
|
222
|
+
lumenflowCommandsTool,
|
|
223
|
+
lumenflowDocsSyncTool,
|
|
224
|
+
lumenflowReleaseTool,
|
|
225
|
+
lumenflowSyncTemplatesTool,
|
|
226
|
+
];
|
|
227
|
+
/**
|
|
228
|
+
* Runtime-backed additive MCP tools.
|
|
229
|
+
*
|
|
230
|
+
* These are intentionally isolated from legacy CLI-shell tools so we can
|
|
231
|
+
* migrate command-by-command without breaking parity gates.
|
|
232
|
+
*
|
|
233
|
+
* NOTE:
|
|
234
|
+
* `allTools` remains the legacy parity baseline for strict CLI parity checks
|
|
235
|
+
* that intentionally ignore runtime migration deltas.
|
|
236
|
+
*
|
|
237
|
+
* Phase-4 closure metrics use `registeredTools` (production registry) so
|
|
238
|
+
* runtime-migrated tools are measured against the real server surface.
|
|
239
|
+
*/
|
|
240
|
+
export const runtimeTaskTools = [
|
|
241
|
+
taskClaimTool,
|
|
242
|
+
taskCreateTool,
|
|
243
|
+
taskCompleteTool,
|
|
244
|
+
taskBlockTool,
|
|
245
|
+
taskUnblockTool,
|
|
246
|
+
taskInspectTool,
|
|
247
|
+
taskToolExecuteTool,
|
|
248
|
+
];
|
|
249
|
+
/**
|
|
250
|
+
* Production MCP registry consumed by server startup.
|
|
251
|
+
*/
|
|
252
|
+
export const registeredTools = [...allTools, ...runtimeTaskTools];
|
|
253
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAsCzC,oDAAoD;AACpD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtE,yCAAyC;AACzC,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,YAAY,EACZ,WAAW,EACX,aAAa,EACb,UAAU,EACV,aAAa,EACb,aAAa,EACb,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,WAAW,EACX,YAAY,EACZ,aAAa,EACb,WAAW,EACX,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAE7B,wCAAwC;AACxC,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,eAAe,GAChB,MAAM,+BAA+B,CAAC;AAEvC,uCAAuC;AACvC,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,6BAA6B,CAAC;AAErC,mCAAmC;AACnC,OAAO,EACL,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,cAAc,GACf,MAAM,yBAAyB,CAAC;AAEjC,kCAAkC;AAClC,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,uDAAuD;AACvD,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,sBA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;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,aAAa;IACb,eAAe;IACf,eAAe;IACf,mBAAmB;CACpB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAqB,CAAC,GAAG,QAAQ,EAAE,GAAG,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error code returned when a write is blocked by worktree enforcement.
|
|
3
|
+
*/
|
|
4
|
+
export declare const WORKTREE_ENFORCEMENT_ERROR_CODE = "WORKTREE_ENFORCEMENT_BLOCKED";
|
|
5
|
+
/**
|
|
6
|
+
* Result of a worktree enforcement check.
|
|
7
|
+
*/
|
|
8
|
+
export interface WorktreeEnforcementResult {
|
|
9
|
+
/** Whether the write operation is allowed */
|
|
10
|
+
allowed: boolean;
|
|
11
|
+
/** Error code when blocked */
|
|
12
|
+
errorCode?: string;
|
|
13
|
+
/** Human-readable reason when blocked */
|
|
14
|
+
reason?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface WorktreeEnforcementInput {
|
|
17
|
+
/** Path to the file being written (relative or absolute) */
|
|
18
|
+
filePath: string;
|
|
19
|
+
/** Project root override (defaults to auto-detection) */
|
|
20
|
+
projectRoot?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Check whether a file write/edit should be allowed based on worktree enforcement policy.
|
|
24
|
+
*
|
|
25
|
+
* Mirrors the logic in enforce-worktree.sh but runs in-process for MCP tools.
|
|
26
|
+
*
|
|
27
|
+
* Graceful degradation: if any check fails (config unreadable, git unavailable,
|
|
28
|
+
* .lumenflow not configured), the operation is allowed to prevent blocking
|
|
29
|
+
* legitimate work.
|
|
30
|
+
*/
|
|
31
|
+
export declare function checkWorktreeEnforcement(input: WorktreeEnforcementInput): WorktreeEnforcementResult;
|
|
32
|
+
//# sourceMappingURL=worktree-enforcement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-enforcement.d.ts","sourceRoot":"","sources":["../src/worktree-enforcement.ts"],"names":[],"mappings":"AAwBA;;GAEG;AACH,eAAO,MAAM,+BAA+B,iCAAiC,CAAC;AAkB9E;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,6CAA6C;IAC7C,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,wBAAwB,GAC9B,yBAAyB,CA8D3B"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// Copyright (c) 2026 Hellmai Ltd
|
|
2
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
3
|
+
/**
|
|
4
|
+
* @file worktree-enforcement.ts
|
|
5
|
+
* @description Worktree enforcement guard for MCP file_write and file_edit tools.
|
|
6
|
+
*
|
|
7
|
+
* WU-1853: MCP tool calls do not trigger Claude Code PreToolUse hooks, so
|
|
8
|
+
* file_write and file_edit can bypass the enforce-worktree.sh hook that blocks
|
|
9
|
+
* direct writes to the main checkout. This module mirrors the shell hook logic
|
|
10
|
+
* in TypeScript so the MCP server can enforce the same policy.
|
|
11
|
+
*
|
|
12
|
+
* Enforcement check mirrors enforce-worktree.sh:
|
|
13
|
+
* - Allow writes inside worktrees/
|
|
14
|
+
* - Allow writes to .lumenflow/, .claude/, docs/tasks/wu/, plan/
|
|
15
|
+
* - Block everything else when on main/master and enforcement is active
|
|
16
|
+
* - Gracefully allow if config cannot be read
|
|
17
|
+
*/
|
|
18
|
+
import path from 'node:path';
|
|
19
|
+
import { existsSync } from 'node:fs';
|
|
20
|
+
import { execFileSync } from 'node:child_process';
|
|
21
|
+
import { getConfig, findProjectRoot } from '@lumenflow/core';
|
|
22
|
+
/**
|
|
23
|
+
* Error code returned when a write is blocked by worktree enforcement.
|
|
24
|
+
*/
|
|
25
|
+
export const WORKTREE_ENFORCEMENT_ERROR_CODE = 'WORKTREE_ENFORCEMENT_BLOCKED';
|
|
26
|
+
/**
|
|
27
|
+
* Branches that are considered "main" and subject to enforcement.
|
|
28
|
+
*/
|
|
29
|
+
const PROTECTED_BRANCHES = ['main', 'master'];
|
|
30
|
+
/**
|
|
31
|
+
* Relative path prefixes that are always allowed on main checkout.
|
|
32
|
+
* Mirrors the allowlist in enforce-worktree.sh.
|
|
33
|
+
*/
|
|
34
|
+
const ALLOWLISTED_PATH_PREFIXES = [
|
|
35
|
+
'docs/04-operations/tasks/wu/',
|
|
36
|
+
'.lumenflow/',
|
|
37
|
+
'.claude/',
|
|
38
|
+
'plan/',
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Check whether a file write/edit should be allowed based on worktree enforcement policy.
|
|
42
|
+
*
|
|
43
|
+
* Mirrors the logic in enforce-worktree.sh but runs in-process for MCP tools.
|
|
44
|
+
*
|
|
45
|
+
* Graceful degradation: if any check fails (config unreadable, git unavailable,
|
|
46
|
+
* .lumenflow not configured), the operation is allowed to prevent blocking
|
|
47
|
+
* legitimate work.
|
|
48
|
+
*/
|
|
49
|
+
export function checkWorktreeEnforcement(input) {
|
|
50
|
+
const { filePath } = input;
|
|
51
|
+
try {
|
|
52
|
+
const projectRoot = input.projectRoot ?? findProjectRoot();
|
|
53
|
+
// Graceful degradation: LumenFlow not configured
|
|
54
|
+
const lumenflowDir = path.join(projectRoot, '.lumenflow');
|
|
55
|
+
if (!existsSync(lumenflowDir)) {
|
|
56
|
+
return { allowed: true };
|
|
57
|
+
}
|
|
58
|
+
// Read enforcement config
|
|
59
|
+
const config = getConfig({ projectRoot });
|
|
60
|
+
const enforcement = config?.agents?.clients?.['claude-code']?.enforcement;
|
|
61
|
+
if (!enforcement?.block_outside_worktree) {
|
|
62
|
+
return { allowed: true };
|
|
63
|
+
}
|
|
64
|
+
// Detect current branch
|
|
65
|
+
const currentBranch = detectCurrentBranch(projectRoot);
|
|
66
|
+
if (!currentBranch) {
|
|
67
|
+
// Branch detection failed -- graceful degradation
|
|
68
|
+
return { allowed: true };
|
|
69
|
+
}
|
|
70
|
+
// Allow operations on non-main branches
|
|
71
|
+
if (!isProtectedBranch(currentBranch)) {
|
|
72
|
+
return { allowed: true };
|
|
73
|
+
}
|
|
74
|
+
// Resolve the file path to a relative path within the project
|
|
75
|
+
const resolvedPath = resolveFilePath(filePath, projectRoot);
|
|
76
|
+
// Allow if path is outside the project entirely
|
|
77
|
+
if (resolvedPath === null) {
|
|
78
|
+
return { allowed: true };
|
|
79
|
+
}
|
|
80
|
+
// Allow if path is inside a worktree
|
|
81
|
+
if (resolvedPath.startsWith('worktrees/')) {
|
|
82
|
+
return { allowed: true };
|
|
83
|
+
}
|
|
84
|
+
// Allow if path matches the allowlist
|
|
85
|
+
if (isAllowlistedPath(resolvedPath)) {
|
|
86
|
+
return { allowed: true };
|
|
87
|
+
}
|
|
88
|
+
// Block the write
|
|
89
|
+
return {
|
|
90
|
+
allowed: false,
|
|
91
|
+
errorCode: WORKTREE_ENFORCEMENT_ERROR_CODE,
|
|
92
|
+
reason: `Write to '${filePath}' blocked: you are on the '${currentBranch}' branch. ` +
|
|
93
|
+
'Direct writes to main checkout are not allowed when worktree enforcement is active. ' +
|
|
94
|
+
'Use pnpm wu:claim to create a worktree and work there instead.',
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Graceful degradation: any unexpected error allows the operation
|
|
99
|
+
return { allowed: true };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Detect the current git branch for the given project root.
|
|
104
|
+
* Returns null if detection fails.
|
|
105
|
+
*/
|
|
106
|
+
function detectCurrentBranch(projectRoot) {
|
|
107
|
+
try {
|
|
108
|
+
// eslint-disable-next-line sonarjs/no-os-command-from-path -- git resolved from PATH; workflow tooling requires git
|
|
109
|
+
const result = execFileSync('git', ['rev-parse', '--abbrev-ref', 'HEAD'], {
|
|
110
|
+
cwd: projectRoot,
|
|
111
|
+
encoding: 'utf8',
|
|
112
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
113
|
+
});
|
|
114
|
+
return result.trim() || null;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Check if a branch name is a protected branch (main/master).
|
|
122
|
+
*/
|
|
123
|
+
function isProtectedBranch(branchName) {
|
|
124
|
+
return PROTECTED_BRANCHES.includes(branchName);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Resolve a file path to a relative path within the project.
|
|
128
|
+
* Returns null if the path is outside the project root.
|
|
129
|
+
*/
|
|
130
|
+
function resolveFilePath(filePath, projectRoot) {
|
|
131
|
+
let resolved;
|
|
132
|
+
if (path.isAbsolute(filePath)) {
|
|
133
|
+
resolved = filePath;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
// Relative path is relative to project root
|
|
137
|
+
resolved = path.resolve(projectRoot, filePath);
|
|
138
|
+
}
|
|
139
|
+
// Normalize both paths for comparison
|
|
140
|
+
const normalizedProject = projectRoot.endsWith('/') ? projectRoot : `${projectRoot}/`;
|
|
141
|
+
// Check if the resolved path is inside the project
|
|
142
|
+
if (!resolved.startsWith(normalizedProject) && resolved !== projectRoot) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
// Return the relative path
|
|
146
|
+
return path.relative(projectRoot, resolved);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Check if a relative path matches the allowlist.
|
|
150
|
+
*/
|
|
151
|
+
function isAllowlistedPath(relativePath) {
|
|
152
|
+
return ALLOWLISTED_PATH_PREFIXES.some((prefix) => relativePath.startsWith(prefix));
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=worktree-enforcement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-enforcement.js","sourceRoot":"","sources":["../src/worktree-enforcement.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,yCAAyC;AAEzC;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,8BAA8B,CAAC;AAE9E;;GAEG;AACH,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAU,CAAC;AAEvD;;;GAGG;AACH,MAAM,yBAAyB,GAAG;IAChC,8BAA8B;IAC9B,aAAa;IACb,UAAU;IACV,OAAO;CACC,CAAC;AAqBX;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAA+B;IAE/B,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,eAAe,EAAE,CAAC;QAE3D,iDAAiD;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;QAC1D,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC3B,CAAC;QAED,0BAA0B;QAC1B,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,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CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,YAAoB;IAC7C,OAAO,yBAAyB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;AACrF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lumenflow/mcp",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "MCP stdio server for LumenFlow workflow framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lumenflow",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
55
55
|
"zod": "^4.3.6",
|
|
56
|
-
"@lumenflow/
|
|
57
|
-
"@lumenflow/
|
|
58
|
-
"@lumenflow/
|
|
59
|
-
"@lumenflow/
|
|
56
|
+
"@lumenflow/core": "3.2.2",
|
|
57
|
+
"@lumenflow/memory": "3.2.2",
|
|
58
|
+
"@lumenflow/kernel": "3.2.2",
|
|
59
|
+
"@lumenflow/metrics": "3.2.2"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@vitest/coverage-v8": "^4.0.18",
|