@flyingrobots/graft 0.4.0 → 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.
- package/ARCHITECTURE.md +386 -0
- package/CHANGELOG.md +47 -0
- package/CODE_OF_CONDUCT.md +65 -0
- package/README.md +153 -17
- package/bin/graft.js +4 -14
- package/docs/ADVANCED_GUIDE.md +49 -0
- package/docs/CLI.md +43 -0
- package/docs/GUIDE.md +321 -32
- package/docs/MCP.md +44 -0
- package/package.json +15 -4
- package/src/adapters/node-fs.ts +4 -0
- package/src/adapters/node-git.ts +47 -0
- package/src/adapters/node-process-runner.ts +27 -0
- package/src/cli/index-cmd.ts +75 -11
- package/src/cli/init.ts +808 -57
- package/src/cli/main.ts +437 -0
- package/src/contracts/capabilities.ts +341 -0
- package/src/contracts/causal-ontology.ts +622 -0
- package/src/contracts/causal-surface-next-action.ts +18 -0
- package/src/contracts/output-schemas.ts +1169 -0
- package/src/git/diff.ts +25 -21
- package/src/git/target-git-hook-bootstrap.ts +56 -0
- package/src/hooks/posttooluse-read.ts +21 -74
- package/src/hooks/pretooluse-read.ts +20 -56
- package/src/hooks/read-governor.ts +95 -0
- package/src/hooks/read-messages.ts +53 -0
- package/src/mcp/burden.ts +123 -0
- package/src/mcp/cache.ts +51 -0
- package/src/mcp/cached-file.ts +10 -8
- package/src/mcp/context.ts +65 -2
- package/src/mcp/daemon-control-plane.ts +554 -0
- package/src/mcp/daemon-job-scheduler.ts +279 -0
- package/src/mcp/daemon-repos.ts +216 -0
- package/src/mcp/daemon-server.ts +396 -0
- package/src/mcp/daemon-worker-pool.ts +310 -0
- package/src/mcp/daemon-worker-process.ts +52 -0
- package/src/mcp/metrics.ts +108 -1
- package/src/mcp/monitor-tick-job.ts +99 -0
- package/src/mcp/persisted-local-history.ts +1246 -0
- package/src/mcp/persistent-monitor-runtime.ts +549 -0
- package/src/mcp/policy.ts +84 -0
- package/src/mcp/receipt.ts +82 -12
- package/src/mcp/repo-concurrency.ts +318 -0
- package/src/mcp/repo-state.ts +777 -0
- package/src/mcp/repo-tool-job.ts +302 -0
- package/src/mcp/run-capture-config.ts +33 -0
- package/src/mcp/runtime-causal-context.ts +72 -0
- package/src/mcp/runtime-observability.ts +219 -0
- package/src/mcp/runtime-staged-target.ts +161 -0
- package/src/mcp/runtime-workspace-overlay.ts +255 -0
- package/src/mcp/semantic-transition-guidance.ts +60 -0
- package/src/mcp/semantic-transition-summary.ts +130 -0
- package/src/mcp/server.ts +696 -55
- package/src/mcp/stdio-server.ts +12 -0
- package/src/mcp/stdio.ts +2 -5
- package/src/mcp/tools/activity-view.ts +325 -0
- package/src/mcp/tools/causal-attach.ts +67 -0
- package/src/mcp/tools/causal-status.ts +58 -0
- package/src/mcp/tools/changed-since.ts +13 -11
- package/src/mcp/tools/code-find.ts +164 -0
- package/src/mcp/tools/code-refs.ts +466 -0
- package/src/mcp/tools/code-show.ts +252 -0
- package/src/mcp/tools/daemon-monitors.ts +14 -0
- package/src/mcp/tools/daemon-repos.ts +22 -0
- package/src/mcp/tools/daemon-sessions.ts +14 -0
- package/src/mcp/tools/daemon-status.ts +12 -0
- package/src/mcp/tools/doctor.ts +45 -2
- package/src/mcp/tools/explain.ts +4 -0
- package/src/mcp/tools/file-outline.ts +7 -3
- package/src/mcp/tools/git-files.ts +73 -0
- package/src/mcp/tools/graft-diff.ts +12 -4
- package/src/mcp/tools/map.ts +92 -38
- package/src/mcp/tools/monitor-pause.ts +18 -0
- package/src/mcp/tools/monitor-resume.ts +18 -0
- package/src/mcp/tools/monitor-start.ts +20 -0
- package/src/mcp/tools/monitor-stop.ts +18 -0
- package/src/mcp/tools/precision-match.ts +51 -0
- package/src/mcp/tools/precision-query.ts +127 -0
- package/src/mcp/tools/precision.ts +312 -0
- package/src/mcp/tools/run-capture.ts +126 -44
- package/src/mcp/tools/safe-read.ts +14 -12
- package/src/mcp/tools/since.ts +7 -2
- package/src/mcp/tools/state.ts +11 -3
- package/src/mcp/tools/stats.ts +5 -1
- package/src/mcp/tools/workspace-authorizations.ts +14 -0
- package/src/mcp/tools/workspace-authorize.ts +20 -0
- package/src/mcp/tools/workspace-bind.ts +25 -0
- package/src/mcp/tools/workspace-rebind.ts +25 -0
- package/src/mcp/tools/workspace-revoke.ts +18 -0
- package/src/mcp/tools/workspace-status.ts +12 -0
- package/src/mcp/warp-pool.ts +36 -0
- package/src/mcp/workspace-router.ts +984 -0
- package/src/operations/file-outline.ts +12 -2
- package/src/operations/graft-diff.ts +56 -10
- package/src/operations/safe-read.ts +27 -4
- package/src/operations/state.ts +6 -9
- package/src/parser/lang.ts +19 -3
- package/src/parser/outline.ts +191 -2
- package/src/parser/types.ts +9 -1
- package/src/policy/types.ts +4 -3
- package/src/ports/filesystem.ts +1 -0
- package/src/ports/git.ts +16 -0
- package/src/ports/process-runner.ts +22 -0
- package/src/release/security-gate.ts +102 -0
- package/src/session/tracker.ts +31 -0
- package/src/version.ts +3 -0
- package/src/warp/indexer.ts +171 -56
- package/src/warp/observers.ts +1 -1
- package/src/warp/open.ts +4 -3
- package/src/warp/plumbing.d.ts +5 -1
- package/src/warp/writer-id.ts +30 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// NodeProcessRunner — implements the ProcessRunner port
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import type { ProcessRunRequest, ProcessRunResult, ProcessRunner } from "../ports/process-runner.js";
|
|
7
|
+
|
|
8
|
+
class NodeProcessRunner implements ProcessRunner {
|
|
9
|
+
run(request: ProcessRunRequest): ProcessRunResult {
|
|
10
|
+
const result = spawnSync(request.command, [...request.args], {
|
|
11
|
+
cwd: request.cwd,
|
|
12
|
+
encoding: "utf-8",
|
|
13
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
14
|
+
...(request.timeoutMs !== undefined ? { timeout: request.timeoutMs } : {}),
|
|
15
|
+
...(request.maxBufferBytes !== undefined ? { maxBuffer: request.maxBufferBytes } : {}),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
status: result.status,
|
|
20
|
+
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
21
|
+
stderr: typeof result.stderr === "string" ? result.stderr : "",
|
|
22
|
+
...(result.error !== undefined ? { error: result.error } : {}),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const nodeProcessRunner: ProcessRunner = new NodeProcessRunner();
|
package/src/cli/index-cmd.ts
CHANGED
|
@@ -1,22 +1,86 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanonicalJsonCodec } from "../adapters/canonical-json.js";
|
|
2
|
+
import { nodeGit } from "../adapters/node-git.js";
|
|
3
|
+
import { attachCliSchemaMeta, validateCliOutput } from "../contracts/output-schemas.js";
|
|
2
4
|
import { indexCommits } from "../warp/indexer.js";
|
|
5
|
+
import { openWarp } from "../warp/open.js";
|
|
6
|
+
|
|
7
|
+
const codec = new CanonicalJsonCodec();
|
|
8
|
+
|
|
9
|
+
interface Writer {
|
|
10
|
+
write(chunk: string): unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface RunIndexOptions {
|
|
14
|
+
cwd?: string | undefined;
|
|
15
|
+
args?: readonly string[] | undefined;
|
|
16
|
+
stdout?: Writer | undefined;
|
|
17
|
+
stderr?: Writer | undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function parseIndexArgs(args: readonly string[]): { json: boolean; from: string | null } {
|
|
21
|
+
let json = false;
|
|
22
|
+
let from: string | null = null;
|
|
3
23
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
24
|
+
for (const arg of args) {
|
|
25
|
+
if (arg === "--json") {
|
|
26
|
+
json = true;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
from ??= arg;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return { json, from };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function writeLine(writer: Writer, line = ""): void {
|
|
36
|
+
writer.write(`${line}\n`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function emitIndexJson(result: Record<string, unknown>, writer: Writer): void {
|
|
40
|
+
writer.write(`${codec.encode(validateCliOutput("index", attachCliSchemaMeta("index", result)))}\n`);
|
|
41
|
+
}
|
|
7
42
|
|
|
8
|
-
|
|
43
|
+
export async function runIndex(options: RunIndexOptions = {}): Promise<void> {
|
|
44
|
+
const cwd = options.cwd ?? process.cwd();
|
|
45
|
+
const args = options.args ?? process.argv.slice(3);
|
|
46
|
+
const stdout = options.stdout ?? process.stdout;
|
|
47
|
+
const stderr = options.stderr ?? process.stderr;
|
|
48
|
+
const { json, from } = parseIndexArgs(args);
|
|
9
49
|
|
|
10
50
|
try {
|
|
11
51
|
const warp = await openWarp({ cwd });
|
|
12
|
-
const result = await indexCommits(warp, {
|
|
52
|
+
const result = await indexCommits(warp, {
|
|
53
|
+
cwd,
|
|
54
|
+
git: nodeGit,
|
|
55
|
+
...(from !== null ? { from } : {}),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (json) {
|
|
59
|
+
emitIndexJson({
|
|
60
|
+
ok: true,
|
|
61
|
+
cwd,
|
|
62
|
+
from,
|
|
63
|
+
commitsIndexed: result.commitsIndexed,
|
|
64
|
+
patchesWritten: result.patchesWritten,
|
|
65
|
+
}, stdout);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
13
68
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
69
|
+
writeLine(stdout);
|
|
70
|
+
writeLine(stdout, `Indexing structural history in ${cwd}`);
|
|
71
|
+
writeLine(stdout);
|
|
72
|
+
writeLine(stdout, ` commits indexed: ${String(result.commitsIndexed)}`);
|
|
73
|
+
writeLine(stdout, ` patches written: ${String(result.patchesWritten)}`);
|
|
74
|
+
writeLine(stdout);
|
|
75
|
+
writeLine(stdout, "Done.");
|
|
76
|
+
writeLine(stdout);
|
|
17
77
|
} catch (err: unknown) {
|
|
18
|
-
const
|
|
19
|
-
console.error(`Error: ${msg}`);
|
|
78
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
20
79
|
process.exitCode = 1;
|
|
80
|
+
if (json) {
|
|
81
|
+
emitIndexJson({ ok: false, cwd, from, error: message }, stdout);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
writeLine(stderr, `Error: ${message}`);
|
|
21
85
|
}
|
|
22
86
|
}
|