@flyingrobots/graft 0.3.5 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/ARCHITECTURE.md +386 -0
  2. package/CHANGELOG.md +69 -0
  3. package/CODE_OF_CONDUCT.md +65 -0
  4. package/README.md +153 -17
  5. package/bin/graft.js +4 -11
  6. package/docs/ADVANCED_GUIDE.md +49 -0
  7. package/docs/CLI.md +43 -0
  8. package/docs/GUIDE.md +321 -32
  9. package/docs/MCP.md +44 -0
  10. package/package.json +17 -4
  11. package/src/adapters/node-fs.ts +4 -0
  12. package/src/adapters/node-git.ts +47 -0
  13. package/src/adapters/node-process-runner.ts +27 -0
  14. package/src/cli/index-cmd.ts +86 -0
  15. package/src/cli/init.ts +808 -57
  16. package/src/cli/main.ts +437 -0
  17. package/src/contracts/capabilities.ts +341 -0
  18. package/src/contracts/causal-ontology.ts +622 -0
  19. package/src/contracts/causal-surface-next-action.ts +18 -0
  20. package/src/contracts/output-schemas.ts +1169 -0
  21. package/src/git/diff.ts +25 -21
  22. package/src/git/target-git-hook-bootstrap.ts +56 -0
  23. package/src/hooks/posttooluse-read.ts +21 -74
  24. package/src/hooks/pretooluse-read.ts +20 -56
  25. package/src/hooks/read-governor.ts +95 -0
  26. package/src/hooks/read-messages.ts +53 -0
  27. package/src/mcp/burden.ts +123 -0
  28. package/src/mcp/cache.ts +51 -0
  29. package/src/mcp/cached-file.ts +10 -8
  30. package/src/mcp/context.ts +67 -2
  31. package/src/mcp/daemon-control-plane.ts +554 -0
  32. package/src/mcp/daemon-job-scheduler.ts +279 -0
  33. package/src/mcp/daemon-repos.ts +216 -0
  34. package/src/mcp/daemon-server.ts +396 -0
  35. package/src/mcp/daemon-worker-pool.ts +310 -0
  36. package/src/mcp/daemon-worker-process.ts +52 -0
  37. package/src/mcp/metrics.ts +108 -1
  38. package/src/mcp/monitor-tick-job.ts +99 -0
  39. package/src/mcp/persisted-local-history.ts +1246 -0
  40. package/src/mcp/persistent-monitor-runtime.ts +549 -0
  41. package/src/mcp/policy.ts +84 -0
  42. package/src/mcp/receipt.ts +82 -12
  43. package/src/mcp/repo-concurrency.ts +318 -0
  44. package/src/mcp/repo-state.ts +777 -0
  45. package/src/mcp/repo-tool-job.ts +302 -0
  46. package/src/mcp/run-capture-config.ts +33 -0
  47. package/src/mcp/runtime-causal-context.ts +72 -0
  48. package/src/mcp/runtime-observability.ts +219 -0
  49. package/src/mcp/runtime-staged-target.ts +161 -0
  50. package/src/mcp/runtime-workspace-overlay.ts +255 -0
  51. package/src/mcp/semantic-transition-guidance.ts +60 -0
  52. package/src/mcp/semantic-transition-summary.ts +130 -0
  53. package/src/mcp/server.ts +704 -45
  54. package/src/mcp/stdio-server.ts +12 -0
  55. package/src/mcp/stdio.ts +2 -5
  56. package/src/mcp/tools/activity-view.ts +325 -0
  57. package/src/mcp/tools/causal-attach.ts +67 -0
  58. package/src/mcp/tools/causal-status.ts +58 -0
  59. package/src/mcp/tools/changed-since.ts +13 -11
  60. package/src/mcp/tools/code-find.ts +164 -0
  61. package/src/mcp/tools/code-refs.ts +466 -0
  62. package/src/mcp/tools/code-show.ts +252 -0
  63. package/src/mcp/tools/daemon-monitors.ts +14 -0
  64. package/src/mcp/tools/daemon-repos.ts +22 -0
  65. package/src/mcp/tools/daemon-sessions.ts +14 -0
  66. package/src/mcp/tools/daemon-status.ts +12 -0
  67. package/src/mcp/tools/doctor.ts +45 -2
  68. package/src/mcp/tools/explain.ts +4 -0
  69. package/src/mcp/tools/file-outline.ts +7 -3
  70. package/src/mcp/tools/git-files.ts +73 -0
  71. package/src/mcp/tools/graft-diff.ts +12 -4
  72. package/src/mcp/tools/map.ts +136 -0
  73. package/src/mcp/tools/monitor-pause.ts +18 -0
  74. package/src/mcp/tools/monitor-resume.ts +18 -0
  75. package/src/mcp/tools/monitor-start.ts +20 -0
  76. package/src/mcp/tools/monitor-stop.ts +18 -0
  77. package/src/mcp/tools/precision-match.ts +51 -0
  78. package/src/mcp/tools/precision-query.ts +127 -0
  79. package/src/mcp/tools/precision.ts +312 -0
  80. package/src/mcp/tools/run-capture.ts +126 -44
  81. package/src/mcp/tools/safe-read.ts +14 -12
  82. package/src/mcp/tools/since.ts +49 -0
  83. package/src/mcp/tools/state.ts +11 -3
  84. package/src/mcp/tools/stats.ts +5 -1
  85. package/src/mcp/tools/workspace-authorizations.ts +14 -0
  86. package/src/mcp/tools/workspace-authorize.ts +20 -0
  87. package/src/mcp/tools/workspace-bind.ts +25 -0
  88. package/src/mcp/tools/workspace-rebind.ts +25 -0
  89. package/src/mcp/tools/workspace-revoke.ts +18 -0
  90. package/src/mcp/tools/workspace-status.ts +12 -0
  91. package/src/mcp/warp-pool.ts +36 -0
  92. package/src/mcp/workspace-router.ts +984 -0
  93. package/src/operations/file-outline.ts +12 -2
  94. package/src/operations/graft-diff.ts +56 -10
  95. package/src/operations/safe-read.ts +27 -4
  96. package/src/operations/state.ts +6 -9
  97. package/src/parser/lang.ts +19 -3
  98. package/src/parser/outline.ts +191 -2
  99. package/src/parser/types.ts +9 -1
  100. package/src/policy/types.ts +4 -3
  101. package/src/ports/filesystem.ts +1 -0
  102. package/src/ports/git.ts +16 -0
  103. package/src/ports/process-runner.ts +22 -0
  104. package/src/release/security-gate.ts +102 -0
  105. package/src/session/tracker.ts +31 -0
  106. package/src/version.ts +3 -0
  107. package/src/warp/indexer.ts +513 -0
  108. package/src/warp/observers.ts +105 -0
  109. package/src/warp/open.ts +31 -0
  110. package/src/warp/plumbing.d.ts +15 -0
  111. package/src/warp/writer-id.ts +30 -0
@@ -0,0 +1,341 @@
1
+ export const MCP_TOOL_NAMES = [
2
+ "safe_read",
3
+ "file_outline",
4
+ "read_range",
5
+ "changed_since",
6
+ "graft_diff",
7
+ "graft_since",
8
+ "graft_map",
9
+ "code_show",
10
+ "code_find",
11
+ "code_refs",
12
+ "daemon_repos",
13
+ "daemon_status",
14
+ "daemon_sessions",
15
+ "daemon_monitors",
16
+ "monitor_start",
17
+ "monitor_pause",
18
+ "monitor_resume",
19
+ "monitor_stop",
20
+ "workspace_authorize",
21
+ "workspace_authorizations",
22
+ "workspace_revoke",
23
+ "workspace_bind",
24
+ "workspace_status",
25
+ "activity_view",
26
+ "causal_status",
27
+ "causal_attach",
28
+ "workspace_rebind",
29
+ "run_capture",
30
+ "state_save",
31
+ "state_load",
32
+ "set_budget",
33
+ "explain",
34
+ "doctor",
35
+ "stats",
36
+ ] as const;
37
+
38
+ export type McpToolName = typeof MCP_TOOL_NAMES[number];
39
+
40
+ export const CLI_COMMAND_NAMES = [
41
+ "init",
42
+ "index",
43
+ "read_safe",
44
+ "read_outline",
45
+ "read_range",
46
+ "read_changed",
47
+ "struct_diff",
48
+ "struct_since",
49
+ "struct_map",
50
+ "symbol_show",
51
+ "symbol_find",
52
+ "diag_doctor",
53
+ "diag_activity",
54
+ "diag_explain",
55
+ "diag_stats",
56
+ "diag_capture",
57
+ ] as const;
58
+
59
+ export type CliCommandName = typeof CLI_COMMAND_NAMES[number];
60
+
61
+ export interface CapabilityDefinition {
62
+ readonly id: string;
63
+ readonly description: string;
64
+ readonly mcpTool?: McpToolName | undefined;
65
+ readonly cliCommand?: CliCommandName | undefined;
66
+ readonly cliPath?: readonly [string, ...string[]] | undefined;
67
+ readonly parity: "peer" | "cli_only" | "mcp_only";
68
+ }
69
+
70
+ export const CAPABILITY_REGISTRY: readonly CapabilityDefinition[] = [
71
+ {
72
+ id: "init",
73
+ description: "Initialize graft in a repo",
74
+ cliCommand: "init",
75
+ cliPath: ["init"],
76
+ parity: "cli_only",
77
+ },
78
+ {
79
+ id: "index",
80
+ description: "Explicit WARP indexing",
81
+ cliCommand: "index",
82
+ cliPath: ["index"],
83
+ parity: "cli_only",
84
+ },
85
+ {
86
+ id: "safe_read",
87
+ description: "Policy-enforced file read",
88
+ mcpTool: "safe_read",
89
+ cliCommand: "read_safe",
90
+ cliPath: ["read", "safe"],
91
+ parity: "peer",
92
+ },
93
+ {
94
+ id: "file_outline",
95
+ description: "Structural file outline",
96
+ mcpTool: "file_outline",
97
+ cliCommand: "read_outline",
98
+ cliPath: ["read", "outline"],
99
+ parity: "peer",
100
+ },
101
+ {
102
+ id: "read_range",
103
+ description: "Bounded range read",
104
+ mcpTool: "read_range",
105
+ cliCommand: "read_range",
106
+ cliPath: ["read", "range"],
107
+ parity: "peer",
108
+ },
109
+ {
110
+ id: "changed_since",
111
+ description: "Change since last observation",
112
+ mcpTool: "changed_since",
113
+ cliCommand: "read_changed",
114
+ cliPath: ["read", "changed"],
115
+ parity: "peer",
116
+ },
117
+ {
118
+ id: "graft_diff",
119
+ description: "Structural diff between refs",
120
+ mcpTool: "graft_diff",
121
+ cliCommand: "struct_diff",
122
+ cliPath: ["struct", "diff"],
123
+ parity: "peer",
124
+ },
125
+ {
126
+ id: "graft_since",
127
+ description: "Structural changes since ref",
128
+ mcpTool: "graft_since",
129
+ cliCommand: "struct_since",
130
+ cliPath: ["struct", "since"],
131
+ parity: "peer",
132
+ },
133
+ {
134
+ id: "graft_map",
135
+ description: "Structural directory map",
136
+ mcpTool: "graft_map",
137
+ cliCommand: "struct_map",
138
+ cliPath: ["struct", "map"],
139
+ parity: "peer",
140
+ },
141
+ {
142
+ id: "code_show",
143
+ description: "Focus on a symbol by name",
144
+ mcpTool: "code_show",
145
+ cliCommand: "symbol_show",
146
+ cliPath: ["symbol", "show"],
147
+ parity: "peer",
148
+ },
149
+ {
150
+ id: "code_find",
151
+ description: "Search symbols by name or kind",
152
+ mcpTool: "code_find",
153
+ cliCommand: "symbol_find",
154
+ cliPath: ["symbol", "find"],
155
+ parity: "peer",
156
+ },
157
+ {
158
+ id: "code_refs",
159
+ description: "Search import sites, callsites, property access, or text references",
160
+ mcpTool: "code_refs",
161
+ parity: "mcp_only",
162
+ },
163
+ {
164
+ id: "daemon_repos",
165
+ description: "List authorized canonical repos with bounded daemon-wide summary",
166
+ mcpTool: "daemon_repos",
167
+ parity: "mcp_only",
168
+ },
169
+ {
170
+ id: "daemon_status",
171
+ description: "Inspect daemon-wide health and control-plane posture",
172
+ mcpTool: "daemon_status",
173
+ parity: "mcp_only",
174
+ },
175
+ {
176
+ id: "daemon_sessions",
177
+ description: "List active daemon sessions",
178
+ mcpTool: "daemon_sessions",
179
+ parity: "mcp_only",
180
+ },
181
+ {
182
+ id: "daemon_monitors",
183
+ description: "List daemon-managed persistent repo monitors",
184
+ mcpTool: "daemon_monitors",
185
+ parity: "mcp_only",
186
+ },
187
+ {
188
+ id: "monitor_start",
189
+ description: "Start a repo-scoped persistent monitor",
190
+ mcpTool: "monitor_start",
191
+ parity: "mcp_only",
192
+ },
193
+ {
194
+ id: "monitor_pause",
195
+ description: "Pause a repo-scoped persistent monitor",
196
+ mcpTool: "monitor_pause",
197
+ parity: "mcp_only",
198
+ },
199
+ {
200
+ id: "monitor_resume",
201
+ description: "Resume a repo-scoped persistent monitor",
202
+ mcpTool: "monitor_resume",
203
+ parity: "mcp_only",
204
+ },
205
+ {
206
+ id: "monitor_stop",
207
+ description: "Stop a repo-scoped persistent monitor",
208
+ mcpTool: "monitor_stop",
209
+ parity: "mcp_only",
210
+ },
211
+ {
212
+ id: "workspace_authorize",
213
+ description: "Authorize a workspace for daemon binding",
214
+ mcpTool: "workspace_authorize",
215
+ parity: "mcp_only",
216
+ },
217
+ {
218
+ id: "workspace_authorizations",
219
+ description: "List daemon-authorized workspaces",
220
+ mcpTool: "workspace_authorizations",
221
+ parity: "mcp_only",
222
+ },
223
+ {
224
+ id: "workspace_revoke",
225
+ description: "Revoke daemon authorization for a workspace",
226
+ mcpTool: "workspace_revoke",
227
+ parity: "mcp_only",
228
+ },
229
+ {
230
+ id: "workspace_bind",
231
+ description: "Bind a daemon session to a workspace",
232
+ mcpTool: "workspace_bind",
233
+ parity: "mcp_only",
234
+ },
235
+ {
236
+ id: "workspace_status",
237
+ description: "Inspect daemon workspace binding state",
238
+ mcpTool: "workspace_status",
239
+ parity: "mcp_only",
240
+ },
241
+ {
242
+ id: "activity_view",
243
+ description: "Inspect recent bounded local artifact history for the active workspace, anchored to the current commit when possible",
244
+ mcpTool: "activity_view",
245
+ cliCommand: "diag_activity",
246
+ cliPath: ["diag", "activity"],
247
+ parity: "peer",
248
+ },
249
+ {
250
+ id: "causal_status",
251
+ description: "Inspect the active causal workspace and persisted local-history posture",
252
+ mcpTool: "causal_status",
253
+ parity: "mcp_only",
254
+ },
255
+ {
256
+ id: "causal_attach",
257
+ description: "Explicitly declare lawful continuation or handoff for the current causal workspace",
258
+ mcpTool: "causal_attach",
259
+ parity: "mcp_only",
260
+ },
261
+ {
262
+ id: "workspace_rebind",
263
+ description: "Rebind a daemon session to a different workspace",
264
+ mcpTool: "workspace_rebind",
265
+ parity: "mcp_only",
266
+ },
267
+ {
268
+ id: "run_capture",
269
+ description: "Structured shell-output capture",
270
+ mcpTool: "run_capture",
271
+ cliCommand: "diag_capture",
272
+ cliPath: ["diag", "capture"],
273
+ parity: "peer",
274
+ },
275
+ {
276
+ id: "explain",
277
+ description: "Explain a reason code",
278
+ mcpTool: "explain",
279
+ cliCommand: "diag_explain",
280
+ cliPath: ["diag", "explain"],
281
+ parity: "peer",
282
+ },
283
+ {
284
+ id: "doctor",
285
+ description: "Runtime health and repo state",
286
+ mcpTool: "doctor",
287
+ cliCommand: "diag_doctor",
288
+ cliPath: ["diag", "doctor"],
289
+ parity: "peer",
290
+ },
291
+ {
292
+ id: "stats",
293
+ description: "Decision metrics summary",
294
+ mcpTool: "stats",
295
+ cliCommand: "diag_stats",
296
+ cliPath: ["diag", "stats"],
297
+ parity: "peer",
298
+ },
299
+ {
300
+ id: "set_budget",
301
+ description: "Session byte budget control",
302
+ mcpTool: "set_budget",
303
+ parity: "mcp_only",
304
+ },
305
+ {
306
+ id: "state_save",
307
+ description: "Session bookmark save",
308
+ mcpTool: "state_save",
309
+ parity: "mcp_only",
310
+ },
311
+ {
312
+ id: "state_load",
313
+ description: "Session bookmark load",
314
+ mcpTool: "state_load",
315
+ parity: "mcp_only",
316
+ },
317
+ ] as const;
318
+
319
+ export const CLI_COMMAND_PATHS = Object.freeze(Object.fromEntries(
320
+ CAPABILITY_REGISTRY
321
+ .filter((capability) => capability.cliCommand !== undefined && capability.cliPath !== undefined)
322
+ .map((capability) => [capability.cliCommand, capability.cliPath]),
323
+ ) as Record<CliCommandName, readonly [string, ...string[]]>);
324
+
325
+ export const CLI_COMMAND_TO_MCP_TOOL = Object.freeze(Object.fromEntries(
326
+ CAPABILITY_REGISTRY
327
+ .filter((capability) => capability.cliCommand !== undefined && capability.mcpTool !== undefined)
328
+ .map((capability) => [capability.cliCommand, capability.mcpTool]),
329
+ ) as Partial<Record<CliCommandName, McpToolName>>);
330
+
331
+ export const CLI_ONLY_COMMANDS = Object.freeze(
332
+ CLI_COMMAND_NAMES.filter((command) => CLI_COMMAND_TO_MCP_TOOL[command] === undefined),
333
+ );
334
+
335
+ export function cliCommandPath(command: CliCommandName): readonly [string, ...string[]] {
336
+ return CLI_COMMAND_PATHS[command];
337
+ }
338
+
339
+ export function cliCommandKey(path: readonly string[]): string {
340
+ return path.join(" ");
341
+ }