@nanonets/graft 0.2.1 → 0.3.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.
- package/README.md +22 -0
- package/dist/ask/ask.d.ts +14 -0
- package/dist/ask/ask.d.ts.map +1 -1
- package/dist/ask/ask.js +118 -5
- package/dist/ask/ask.js.map +1 -1
- package/dist/claude/format.d.ts +32 -0
- package/dist/claude/format.d.ts.map +1 -0
- package/dist/claude/format.js +118 -0
- package/dist/claude/format.js.map +1 -0
- package/dist/claude/hooks.d.ts +3 -0
- package/dist/claude/hooks.d.ts.map +1 -0
- package/dist/claude/hooks.js +123 -0
- package/dist/claude/hooks.js.map +1 -0
- package/dist/claude/init.d.ts +11 -0
- package/dist/claude/init.d.ts.map +1 -0
- package/dist/claude/init.js +34 -0
- package/dist/claude/init.js.map +1 -0
- package/dist/claude/paths.d.ts +5 -0
- package/dist/claude/paths.d.ts.map +1 -0
- package/dist/claude/paths.js +16 -0
- package/dist/claude/paths.js.map +1 -0
- package/dist/claude/settings-merge.d.ts +7 -0
- package/dist/claude/settings-merge.d.ts.map +1 -0
- package/dist/claude/settings-merge.js +40 -0
- package/dist/claude/settings-merge.js.map +1 -0
- package/dist/claude/shim-template.d.ts +3 -0
- package/dist/claude/shim-template.d.ts.map +1 -0
- package/dist/claude/shim-template.js +18 -0
- package/dist/claude/shim-template.js.map +1 -0
- package/dist/claude/state.d.ts +31 -0
- package/dist/claude/state.d.ts.map +1 -0
- package/dist/claude/state.js +83 -0
- package/dist/claude/state.js.map +1 -0
- package/dist/claude/stats.d.ts +5 -0
- package/dist/claude/stats.d.ts.map +1 -0
- package/dist/claude/stats.js +23 -0
- package/dist/claude/stats.js.map +1 -0
- package/dist/claude/statusline.d.ts +12 -0
- package/dist/claude/statusline.d.ts.map +1 -0
- package/dist/claude/statusline.js +40 -0
- package/dist/claude/statusline.js.map +1 -0
- package/dist/claude/sync-run.d.ts +3 -0
- package/dist/claude/sync-run.d.ts.map +1 -0
- package/dist/claude/sync-run.js +38 -0
- package/dist/claude/sync-run.js.map +1 -0
- package/dist/cli.d.ts +7 -5
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +36 -7
- package/dist/cli.js.map +1 -1
- package/dist/engine.d.ts +3 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +2 -1
- package/dist/engine.js.map +1 -1
- package/dist/graph/build.d.ts +2 -0
- package/dist/graph/build.d.ts.map +1 -1
- package/dist/graph/build.js +1 -0
- package/dist/graph/build.js.map +1 -1
- package/dist/graph/cards.d.ts.map +1 -1
- package/dist/graph/cards.js +3 -5
- package/dist/graph/cards.js.map +1 -1
- package/dist/graph/enrich.d.ts +3 -1
- package/dist/graph/enrich.d.ts.map +1 -1
- package/dist/graph/enrich.js +30 -17
- package/dist/graph/enrich.js.map +1 -1
- package/dist/graph/extract.d.ts.map +1 -1
- package/dist/graph/extract.js +1 -0
- package/dist/graph/extract.js.map +1 -1
- package/dist/graph/types.d.ts +1 -0
- package/dist/graph/types.d.ts.map +1 -1
- package/package.json +6 -3
- package/scripts/build-viewer.mjs +28 -0
- package/scripts/postinstall.mjs +11 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { mkdirSync, writeFileSync, readFileSync, existsSync, chmodSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { execFileSync } from 'node:child_process';
|
|
4
|
+
import { mergeGraftSettings } from './settings-merge.js';
|
|
5
|
+
import { statuslineShim, hooksShim } from './shim-template.js';
|
|
6
|
+
export function runInit(dir, opts = {}) {
|
|
7
|
+
const helpersDir = join(dir, '.claude', 'helpers');
|
|
8
|
+
mkdirSync(helpersDir, { recursive: true });
|
|
9
|
+
const settingsPath = join(dir, '.claude', 'settings.json');
|
|
10
|
+
let existing = {};
|
|
11
|
+
try {
|
|
12
|
+
existing = JSON.parse(readFileSync(settingsPath, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
catch { /* none/invalid → start fresh */ }
|
|
15
|
+
const { merged, warnings } = mergeGraftSettings(existing);
|
|
16
|
+
writeFileSync(settingsPath, `${JSON.stringify(merged, null, 2)}\n`);
|
|
17
|
+
const sl = join(helpersDir, 'graft-statusline.cjs');
|
|
18
|
+
const hk = join(helpersDir, 'graft-hooks.cjs');
|
|
19
|
+
writeFileSync(sl, statuslineShim());
|
|
20
|
+
chmodSync(sl, 0o755);
|
|
21
|
+
writeFileSync(hk, hooksShim());
|
|
22
|
+
chmodSync(hk, 0o755);
|
|
23
|
+
let built = false;
|
|
24
|
+
const wiring = join(dir, 'graft', '.graph', 'wiring.json');
|
|
25
|
+
if (opts.build !== false && opts.cliPath && !existsSync(wiring)) {
|
|
26
|
+
try {
|
|
27
|
+
execFileSync(process.execPath, [opts.cliPath, 'build', '.'], { cwd: dir, stdio: 'inherit', timeout: 300000 });
|
|
28
|
+
built = true;
|
|
29
|
+
}
|
|
30
|
+
catch { /* build best-effort; user can run `graft build` manually */ }
|
|
31
|
+
}
|
|
32
|
+
return { settingsPath, shims: [sl, hk], warnings, built };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/claude/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAS/D,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,OAA8C,EAAE;IACnF,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,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AC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;YAC9G,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;QAAC,MAAM,CAAC,CAAC,4DAA4D,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Absolute path to the graft CLI (`<pkgRoot>/dist/cli.js`), resolved from this module. */
|
|
2
|
+
export declare function graftCliPath(): string;
|
|
3
|
+
/** Absolute path to a sibling script in the claude dir (e.g. `sync-run.js`). */
|
|
4
|
+
export declare function claudeScriptPath(name: string): string;
|
|
5
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/claude/paths.ts"],"names":[],"mappings":"AASA,2FAA2F;AAC3F,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,gFAAgF;AAChF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
// This module ships inside the package at <pkgRoot>/dist/claude/paths.js. Resolving graft's
|
|
4
|
+
// own CLI and sibling scripts relative to THIS file — not the project dir — is what makes the
|
|
5
|
+
// hooks work when graft is installed as a dependency in someone else's repo (where
|
|
6
|
+
// <projectDir>/dist/ does not exist). In graft's own repo it resolves to ./dist all the same.
|
|
7
|
+
const CLAUDE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
/** Absolute path to the graft CLI (`<pkgRoot>/dist/cli.js`), resolved from this module. */
|
|
9
|
+
export function graftCliPath() {
|
|
10
|
+
return join(CLAUDE_DIR, '..', 'cli.js');
|
|
11
|
+
}
|
|
12
|
+
/** Absolute path to a sibling script in the claude dir (e.g. `sync-run.js`). */
|
|
13
|
+
export function claudeScriptPath(name) {
|
|
14
|
+
return join(CLAUDE_DIR, name);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/claude/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,4FAA4F;AAC5F,8FAA8F;AAC9F,mFAAmF;AACnF,8FAA8F;AAC9F,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-merge.d.ts","sourceRoot":"","sources":["../../src/claude/settings-merge.ts"],"names":[],"mappings":"AAAA,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAoBhC,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,IAAI,GAAG;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAwBvF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const SL_CMD = 'node "${CLAUDE_PROJECT_DIR:-.}/.claude/helpers/graft-statusline.cjs"';
|
|
2
|
+
const FOOTER = 'graft/[\\w./-]+\\.md';
|
|
3
|
+
function hookCmd(arg) {
|
|
4
|
+
return `node "\${CLAUDE_PROJECT_DIR:-.}/.claude/helpers/graft-hooks.cjs" ${arg}`;
|
|
5
|
+
}
|
|
6
|
+
function graftBlocks() {
|
|
7
|
+
return {
|
|
8
|
+
PostToolUse: { matcher: 'Write|Edit|MultiEdit', hooks: [{ type: 'command', command: hookCmd('post-edit'), timeout: 10000 }] },
|
|
9
|
+
UserPromptSubmit: { hooks: [{ type: 'command', command: hookCmd('prompt'), timeout: 8000 }] },
|
|
10
|
+
SessionStart: { hooks: [{ type: 'command', command: hookCmd('session-start'), timeout: 8000 }] },
|
|
11
|
+
Stop: { hooks: [{ type: 'command', command: hookCmd('stop'), timeout: 8000 }] },
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function isGraftHookEntry(entry) {
|
|
15
|
+
return JSON.stringify(entry ?? '').includes('graft-hooks.cjs');
|
|
16
|
+
}
|
|
17
|
+
export function mergeGraftSettings(existing) {
|
|
18
|
+
const merged = { ...(existing ?? {}) };
|
|
19
|
+
const warnings = [];
|
|
20
|
+
if (!merged.statusLine)
|
|
21
|
+
merged.statusLine = { type: 'command', command: SL_CMD };
|
|
22
|
+
else if (merged.statusLine.command !== SL_CMD)
|
|
23
|
+
warnings.push('Existing statusLine left untouched (a session allows only one). To use Graft, point it at .claude/helpers/graft-statusline.cjs.');
|
|
24
|
+
if (!merged.subagentStatusLine)
|
|
25
|
+
merged.subagentStatusLine = { type: 'command', command: SL_CMD };
|
|
26
|
+
else if (merged.subagentStatusLine.command !== SL_CMD)
|
|
27
|
+
warnings.push('Existing subagentStatusLine left untouched.');
|
|
28
|
+
merged.hooks = { ...(merged.hooks ?? {}) };
|
|
29
|
+
for (const [event, block] of Object.entries(graftBlocks())) {
|
|
30
|
+
const prior = Array.isArray(merged.hooks[event]) ? merged.hooks[event] : [];
|
|
31
|
+
const foreign = prior.filter((e) => !isGraftHookEntry(e)); // drop old Graft entries → idempotent
|
|
32
|
+
merged.hooks[event] = [...foreign, block];
|
|
33
|
+
}
|
|
34
|
+
const footer = Array.isArray(merged.footerLinksRegexes) ? [...merged.footerLinksRegexes] : [];
|
|
35
|
+
if (!footer.includes(FOOTER))
|
|
36
|
+
footer.push(FOOTER);
|
|
37
|
+
merged.footerLinksRegexes = footer;
|
|
38
|
+
return { merged, warnings };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=settings-merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-merge.js","sourceRoot":"","sources":["../../src/claude/settings-merge.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,GAAG,sEAAsE,CAAC;AACtF,MAAM,MAAM,GAAG,sBAAsB,CAAC;AAEtC,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,oEAAoE,GAAG,EAAE,CAAC;AACnF,CAAC;AACD,SAAS,WAAW;IAClB,OAAO;QACL,WAAW,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE;QAC7H,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;QAC7F,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,eAAe,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,EAAE;QAChG,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,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,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,sCAAsC;QACvG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9F,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;QAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC;IAEnC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shim-template.d.ts","sourceRoot":"","sources":["../../src/claude/shim-template.ts"],"names":[],"mappings":"AAgBA,wBAAgB,cAAc,IAAI,MAAM,CAA8C;AACtF,wBAAgB,SAAS,IAAI,MAAM,CAAwD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function shim(entryFile, call) {
|
|
2
|
+
return `#!/usr/bin/env node
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const dir = process.env.CLAUDE_PROJECT_DIR || process.cwd();
|
|
5
|
+
function entry(name) {
|
|
6
|
+
try {
|
|
7
|
+
const pkg = require.resolve('@nanonets/graft/package.json', { paths: [dir] });
|
|
8
|
+
return path.join(path.dirname(pkg), 'dist', 'claude', name);
|
|
9
|
+
} catch {
|
|
10
|
+
return path.join(dir, 'dist', 'claude', name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
import(entry(${JSON.stringify(entryFile)})).then((m) => ${call}).catch(() => { /* graft unavailable — no-op */ });
|
|
14
|
+
`;
|
|
15
|
+
}
|
|
16
|
+
export function statuslineShim() { return shim('statusline.js', 'm.main()'); }
|
|
17
|
+
export function hooksShim() { return shim('hooks.js', 'm.main(process.argv[2])'); }
|
|
18
|
+
//# sourceMappingURL=shim-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shim-template.js","sourceRoot":"","sources":["../../src/claude/shim-template.ts"],"names":[],"mappings":"AAAA,SAAS,IAAI,CAAC,SAAiB,EAAE,IAAY;IAC3C,OAAO;;;;;;;;;;;eAWM,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,kBAAkB,IAAI;CAC7D,CAAC;AACF,CAAC;AAED,MAAM,UAAU,cAAc,KAAa,OAAO,IAAI,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;AACtF,MAAM,UAAU,SAAS,KAAa,OAAO,IAAI,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface Stats {
|
|
2
|
+
nodeCount: number;
|
|
3
|
+
edgeCount: number;
|
|
4
|
+
languages: string[];
|
|
5
|
+
totalCount: number;
|
|
6
|
+
readyCount: number;
|
|
7
|
+
staleCount: number;
|
|
8
|
+
dirty: boolean;
|
|
9
|
+
syncing: boolean;
|
|
10
|
+
syncedAt: string | null;
|
|
11
|
+
lastFile: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SessionState {
|
|
14
|
+
lastQuery: string | null;
|
|
15
|
+
perAgentQuery: Record<string, string>;
|
|
16
|
+
graftReads: number;
|
|
17
|
+
sourceReads: number;
|
|
18
|
+
/** Cumulative tokens saved this session via `ask --source` retrieval (est.). */
|
|
19
|
+
savedTokens: number;
|
|
20
|
+
}
|
|
21
|
+
export declare const LOCK_STALE_MS = 300000;
|
|
22
|
+
export declare function emptyStats(): Stats;
|
|
23
|
+
export declare function cacheDir(projectDir: string): string;
|
|
24
|
+
export declare function readStats(d: string): Stats | null;
|
|
25
|
+
export declare function writeStats(d: string, s: Stats): void;
|
|
26
|
+
export declare function patchStats(d: string, patch: Partial<Stats>): Stats;
|
|
27
|
+
export declare function readSession(d: string, id: string): SessionState;
|
|
28
|
+
export declare function writeSession(d: string, id: string, s: SessionState): void;
|
|
29
|
+
export declare function acquireLock(d: string): boolean;
|
|
30
|
+
export declare function releaseLock(d: string): void;
|
|
31
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/claude/state.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,KAAK;IACpB,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC1D,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IACvC,UAAU,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC;IACrD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClD;AACD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IACxC,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC,wBAAgB,UAAU,IAAI,KAAK,CAGlC;AAKD,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAgD;AAepG,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAA0C;AAC5F,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,GAAG,IAAI,CAAsC;AAG3F,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAIlE;AACD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,CAE/D;AACD,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,GAAG,IAAI,CAEzE;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAgB9C;AACD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAA8D"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, renameSync, rmSync, statSync } from 'node:fs';
|
|
2
|
+
import { join, dirname } from 'node:path';
|
|
3
|
+
export const LOCK_STALE_MS = 300000;
|
|
4
|
+
export function emptyStats() {
|
|
5
|
+
return { nodeCount: 0, edgeCount: 0, languages: [], totalCount: 0, readyCount: 0,
|
|
6
|
+
staleCount: 0, dirty: false, syncing: false, syncedAt: null, lastFile: null };
|
|
7
|
+
}
|
|
8
|
+
function emptySession() {
|
|
9
|
+
return { lastQuery: null, perAgentQuery: {}, graftReads: 0, sourceReads: 0, savedTokens: 0 };
|
|
10
|
+
}
|
|
11
|
+
export function cacheDir(projectDir) { return join(projectDir, 'graft', '.cache'); }
|
|
12
|
+
function statsPath(d) { return join(cacheDir(d), 'stats.json'); }
|
|
13
|
+
function sessionPath(d, id) { return join(cacheDir(d), 'session', `${id}.json`); }
|
|
14
|
+
function lockPath(d) { return join(cacheDir(d), '.sync.lock'); }
|
|
15
|
+
function readJson(p) {
|
|
16
|
+
try {
|
|
17
|
+
return JSON.parse(readFileSync(p, 'utf8'));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function writeJsonAtomic(p, value) {
|
|
24
|
+
mkdirSync(dirname(p), { recursive: true });
|
|
25
|
+
const tmp = `${p}.${process.pid}.tmp`;
|
|
26
|
+
writeFileSync(tmp, JSON.stringify(value, null, 2));
|
|
27
|
+
renameSync(tmp, p);
|
|
28
|
+
}
|
|
29
|
+
export function readStats(d) { return readJson(statsPath(d)); }
|
|
30
|
+
export function writeStats(d, s) { writeJsonAtomic(statsPath(d), s); }
|
|
31
|
+
// Best-effort read-modify-write; not atomic across concurrent processes, but acceptable
|
|
32
|
+
// for episodic hook writes (worst case is a lost update, not corruption).
|
|
33
|
+
export function patchStats(d, patch) {
|
|
34
|
+
const next = { ...(readStats(d) ?? emptyStats()), ...patch };
|
|
35
|
+
writeStats(d, next);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
export function readSession(d, id) {
|
|
39
|
+
return readJson(sessionPath(d, id)) ?? emptySession();
|
|
40
|
+
}
|
|
41
|
+
export function writeSession(d, id, s) {
|
|
42
|
+
writeJsonAtomic(sessionPath(d, id), s);
|
|
43
|
+
}
|
|
44
|
+
export function acquireLock(d) {
|
|
45
|
+
const p = lockPath(d);
|
|
46
|
+
mkdirSync(cacheDir(d), { recursive: true });
|
|
47
|
+
const payload = JSON.stringify({ pid: process.pid, at: new Date().toISOString() });
|
|
48
|
+
try {
|
|
49
|
+
writeFileSync(p, payload, { flag: 'wx' }); // atomic exclusive create
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
if (e?.code !== 'EEXIST')
|
|
54
|
+
throw e;
|
|
55
|
+
let stale;
|
|
56
|
+
try {
|
|
57
|
+
stale = Date.now() - statSync(p).mtimeMs >= LOCK_STALE_MS;
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
stale = true;
|
|
61
|
+
}
|
|
62
|
+
if (!stale)
|
|
63
|
+
return false;
|
|
64
|
+
try {
|
|
65
|
+
rmSync(p);
|
|
66
|
+
}
|
|
67
|
+
catch { /* another process reclaimed it */ }
|
|
68
|
+
try {
|
|
69
|
+
writeFileSync(p, payload, { flag: 'wx' });
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
catch (e2) {
|
|
73
|
+
if (e2?.code === 'EEXIST')
|
|
74
|
+
return false;
|
|
75
|
+
throw e2;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export function releaseLock(d) { try {
|
|
80
|
+
rmSync(lockPath(d));
|
|
81
|
+
}
|
|
82
|
+
catch { /* already gone */ } }
|
|
83
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/claude/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAc,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3G,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgB1C,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC,MAAM,UAAU,UAAU;IACxB,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC;QAC9E,UAAU,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAClF,CAAC;AACD,SAAS,YAAY;IACnB,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,WA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AC,OAAO,CAAM,EAAE,CAAC;QAChB,IAAI,CAAC,EAAE,IAAI,KAAK,QAAQ;YAAE,MAAM,CAAC,CAAC;QAClC,IAAI,KAAc,CAAC;QACnB,IAAI,CAAC;YAAC,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,IAAI,aAAa,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC;YAAC,KAAK,GAAG,IAAI,CAAC;QAAC,CAAC;QAC1F,IAAI,CAAC,KAAK;YAAE,OAAO,KAAK,CAAC;QACzB,IAAI,CAAC;YAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,kCAAkC,CAAC,CAAC;QAC/D,IAAI,CAAC;YAAC,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAAC,OAAO,IAAI,CAAC;QAAC,CAAC;QAC/D,OAAO,EAAO,EAAE,CAAC;YAAC,IAAI,EAAE,EAAE,IAAI,KAAK,QAAQ;gBAAE,OAAO,KAAK,CAAC;YAAC,MAAM,EAAE,CAAC;QAAC,CAAC;IACxE,CAAC;AACH,CAAC;AACD,MAAM,UAAU,WAAW,CAAC,CAAS,IAAU,IAAI,CAAC;IAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAAC,CAAC;AAAC,MAAM,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GraphV1 } from '../graph/types.js';
|
|
2
|
+
import type { Stats } from './state.js';
|
|
3
|
+
export declare function readWiring(projectDir: string): GraphV1 | null;
|
|
4
|
+
export declare function computeStats(w: GraphV1): Pick<Stats, 'nodeCount' | 'edgeCount' | 'languages' | 'totalCount' | 'readyCount'>;
|
|
5
|
+
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/claude/stats.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,wBAAgB,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAI7D;AAED,wBAAgB,YAAY,CAC1B,CAAC,EAAE,OAAO,GACT,IAAI,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC,CAWpF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export function readWiring(projectDir) {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(readFileSync(join(projectDir, 'graft', '.graph', 'wiring.json'), 'utf8'));
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function computeStats(w) {
|
|
12
|
+
const nodes = w.nodes ?? [];
|
|
13
|
+
const edges = w.edges ?? [];
|
|
14
|
+
const readyCount = nodes.filter((n) => n.summary_state === 'ready').length;
|
|
15
|
+
return {
|
|
16
|
+
nodeCount: w.meta?.nodeCount ?? nodes.length,
|
|
17
|
+
edgeCount: w.meta?.edgeCount ?? edges.length,
|
|
18
|
+
languages: w.meta?.languages ?? [],
|
|
19
|
+
totalCount: nodes.length,
|
|
20
|
+
readyCount,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=stats.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stats.js","sourceRoot":"","sources":["../../src/claude/stats.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,UAAU,UAAU,CAAC,UAAkB;IAC3C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,MAAM,CAAC,CAAY,CAAC;IACzG,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,IAAI,CAAC;IAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,CAAU;IAEV,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IAC5B,MAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,OAAO,CAAC,CAAC,MAAM,CAAC;IAC3E,OAAO;QACL,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,MAAM;QAC5C,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,IAAI,KAAK,CAAC,MAAM;QAC5C,SAAS,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,IAAI,EAAE;QAClC,UAAU,EAAE,KAAK,CAAC,MAAM;QACxB,UAAU;KACX,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Stats } from './state.js';
|
|
2
|
+
/**
|
|
3
|
+
* The statusline's fast path is the hook-maintained cache (graft/.cache/stats.json).
|
|
4
|
+
* When it's absent — a fresh checkout, or a plain `graft build` that doesn't write the
|
|
5
|
+
* cache — fall back to reading the graph itself (wiring.json) so the bar reflects reality
|
|
6
|
+
* immediately instead of showing "not built". The graph carries no drift signal, so it
|
|
7
|
+
* reads as synced until the next edit repopulates the cache. Still a pure read (no
|
|
8
|
+
* subprocess): the cache is preferred because it carries live dirty/stale state.
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveStats(dir: string): Stats | null;
|
|
11
|
+
export declare function main(): void;
|
|
12
|
+
//# sourceMappingURL=statusline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusline.d.ts","sourceRoot":"","sources":["../../src/claude/statusline.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsC,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAG5E;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAMtD;AAED,wBAAgB,IAAI,IAAI,IAAI,CAW3B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { renderStatusline, renderSubagent } from './format.js';
|
|
3
|
+
import { readStats, readSession, emptyStats } from './state.js';
|
|
4
|
+
import { readWiring, computeStats } from './stats.js';
|
|
5
|
+
/**
|
|
6
|
+
* The statusline's fast path is the hook-maintained cache (graft/.cache/stats.json).
|
|
7
|
+
* When it's absent — a fresh checkout, or a plain `graft build` that doesn't write the
|
|
8
|
+
* cache — fall back to reading the graph itself (wiring.json) so the bar reflects reality
|
|
9
|
+
* immediately instead of showing "not built". The graph carries no drift signal, so it
|
|
10
|
+
* reads as synced until the next edit repopulates the cache. Still a pure read (no
|
|
11
|
+
* subprocess): the cache is preferred because it carries live dirty/stale state.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveStats(dir) {
|
|
14
|
+
const cached = readStats(dir);
|
|
15
|
+
if (cached && cached.nodeCount > 0)
|
|
16
|
+
return cached;
|
|
17
|
+
const wiring = readWiring(dir);
|
|
18
|
+
if (wiring)
|
|
19
|
+
return { ...emptyStats(), ...computeStats(wiring) };
|
|
20
|
+
return cached;
|
|
21
|
+
}
|
|
22
|
+
export function main() {
|
|
23
|
+
let input = {};
|
|
24
|
+
try {
|
|
25
|
+
input = JSON.parse(readFileSync(0, 'utf8'));
|
|
26
|
+
}
|
|
27
|
+
catch { /* no/invalid stdin */ }
|
|
28
|
+
const dir = process.env.CLAUDE_PROJECT_DIR || input.cwd || process.cwd();
|
|
29
|
+
const session = readSession(dir, input.session_id || 'default');
|
|
30
|
+
const agent = input?.agent?.name;
|
|
31
|
+
if (agent) {
|
|
32
|
+
process.stdout.write(renderSubagent(agent, session));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const stats = resolveStats(dir);
|
|
36
|
+
const raw = input?.context_window?.used_percentage;
|
|
37
|
+
const ctxPct = typeof raw === 'number' ? Math.round(raw) : null;
|
|
38
|
+
process.stdout.write(renderStatusline(stats, session, { ctxPct }).join('\n'));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=statusline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusline.js","sourceRoot":"","sources":["../../src/claude/statusline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9B,IAAI,MAAM,IAAI,MAAM,CAAC,SAAS,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IAClD,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM;QAAE,OAAO,EAAE,GAAG,UAAU,EAAE,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;IAChE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED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MAAM,KAAK,IAAgB,GAAG,IAAI,CAcjF;AAED,wBAAgB,IAAI,IAAI,IAAI,CAG3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { pathToFileURL } from 'node:url';
|
|
3
|
+
import { readWiring, computeStats } from './stats.js';
|
|
4
|
+
import { patchStats, releaseLock } from './state.js';
|
|
5
|
+
import { graftCliPath } from './paths.js';
|
|
6
|
+
/** MONEY GUARD: plain `graft build` only — structural, $0, offline. Never --deep. */
|
|
7
|
+
function realBuild(dir) {
|
|
8
|
+
execFileSync(process.execPath, [graftCliPath(), 'build', '.'], { cwd: dir, stdio: 'ignore', timeout: 120000 });
|
|
9
|
+
}
|
|
10
|
+
export function runSync(dir, build = realBuild) {
|
|
11
|
+
try {
|
|
12
|
+
build(dir);
|
|
13
|
+
const w = readWiring(dir);
|
|
14
|
+
if (!w) {
|
|
15
|
+
patchStats(dir, { syncing: false });
|
|
16
|
+
return;
|
|
17
|
+
} // build ran but output unreadable — stay dirty, retry
|
|
18
|
+
patchStats(dir, {
|
|
19
|
+
dirty: false, staleCount: 0, syncing: false, syncedAt: new Date().toISOString(),
|
|
20
|
+
...computeStats(w),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
patchStats(dir, { syncing: false }); // leave dirty=true; retry next turn
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
releaseLock(dir);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function main() {
|
|
31
|
+
const dir = process.argv[2];
|
|
32
|
+
if (dir)
|
|
33
|
+
runSync(dir);
|
|
34
|
+
}
|
|
35
|
+
// Run only when executed directly (node dist/claude/sync-run.js <dir>), not on import.
|
|
36
|
+
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href)
|
|
37
|
+
main();
|
|
38
|
+
//# sourceMappingURL=sync-run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+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C;YAAS,CAAC;QACT,WAAW,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,IAAI;IAClB,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,IAAI,GAAG;QAAE,OAAO,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,uFAAuF;AACvF,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* `graft` CLI.
|
|
3
|
+
* `graft` CLI. Commands:
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* check fail if
|
|
5
|
+
* build build graft/ from your code (structural graph; --deep adds LLM summaries).
|
|
6
|
+
* ask query the graph ($0, no LLM).
|
|
7
|
+
* check fail if graft/ has drifted from the code — for CI.
|
|
8
|
+
* viz serve the interactive graph viewer.
|
|
9
|
+
* init set up the Claude Code integration (.claude/ statusline + hooks) in this repo.
|
|
8
10
|
*
|
|
9
|
-
* Git is the sync: commit
|
|
11
|
+
* Git is the sync: commit graft/ and anyone who clones the repo has the
|
|
10
12
|
* graph, with no setup.
|
|
11
13
|
*/
|
|
12
14
|
import "dotenv/config";
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,eAAe,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* `graft` CLI.
|
|
3
|
+
* `graft` CLI. Commands:
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* check fail if
|
|
5
|
+
* build build graft/ from your code (structural graph; --deep adds LLM summaries).
|
|
6
|
+
* ask query the graph ($0, no LLM).
|
|
7
|
+
* check fail if graft/ has drifted from the code — for CI.
|
|
8
|
+
* viz serve the interactive graph viewer.
|
|
9
|
+
* init set up the Claude Code integration (.claude/ statusline + hooks) in this repo.
|
|
8
10
|
*
|
|
9
|
-
* Git is the sync: commit
|
|
11
|
+
* Git is the sync: commit graft/ and anyone who clones the repo has the
|
|
10
12
|
* graph, with no setup.
|
|
11
13
|
*/
|
|
12
14
|
import "dotenv/config";
|
|
13
15
|
import { Command } from "commander";
|
|
14
|
-
import { relative } from "node:path";
|
|
16
|
+
import { relative, resolve } from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
15
18
|
import { Graft } from "./engine.js";
|
|
16
19
|
import { resolveConfig } from "./ai/providers.js";
|
|
17
20
|
import { formatCheckReport } from "./context/check.js";
|
|
18
21
|
import { formatGraphCheckReport } from "./graph/check.js";
|
|
22
|
+
import { runInit } from "./claude/init.js";
|
|
19
23
|
const program = new Command();
|
|
20
24
|
program
|
|
21
25
|
.name("graft")
|
|
@@ -32,7 +36,13 @@ program
|
|
|
32
36
|
.argument("[dir]", "repository root", ".")
|
|
33
37
|
.option("--deep", "run the LLM pass: concept nodes (graft/*.md) + per-symbol summary/crux")
|
|
34
38
|
.option("-e, --extensions <exts...>", 'code extensions to include (e.g. ".ts" ".py")')
|
|
39
|
+
.option("-j, --concurrency <n>", "files summarized in parallel during --deep (default 5)")
|
|
35
40
|
.action(async (dir, opts) => {
|
|
41
|
+
const concurrency = opts.concurrency ? Math.max(1, Number(opts.concurrency)) : undefined;
|
|
42
|
+
if (opts.concurrency && !Number.isFinite(concurrency)) {
|
|
43
|
+
console.error(`✗ --concurrency must be a number, got "${opts.concurrency}"`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
36
46
|
const engine = engineFrom();
|
|
37
47
|
const fmt = (o) => Object.entries(o)
|
|
38
48
|
.sort((a, b) => b[1] - a[1])
|
|
@@ -62,6 +72,7 @@ program
|
|
|
62
72
|
// Wiring graph (Tier-2 cards + Tier-3 wiring.json) — always. LLM meaning only with --deep.
|
|
63
73
|
const g = await engine.graph(dir, {
|
|
64
74
|
llm: deep,
|
|
75
|
+
concurrency,
|
|
65
76
|
onProgress: ({ phase, index, total, file }) => process.stderr.write(`\r${phase === "enrich" ? "summarizing" : "parsing"} ${index + 1}/${total}: ${file.slice(0, 50).padEnd(50)}`),
|
|
66
77
|
});
|
|
67
78
|
process.stderr.write("\n");
|
|
@@ -82,10 +93,11 @@ program
|
|
|
82
93
|
.argument("<query>", "what you want to understand, in plain words")
|
|
83
94
|
.argument("[dir]", "repository root", ".")
|
|
84
95
|
.option("-n, --limit <n>", "max results", "8")
|
|
96
|
+
.option("--source", "inline the source at each file:line hit (retriever mode — the pack IS the answer, no need to re-open files)")
|
|
85
97
|
.option("--json", "output the result as JSON")
|
|
86
98
|
.action(async (query, dir, opts) => {
|
|
87
99
|
const engine = engineFrom();
|
|
88
|
-
const r = engine.ask(dir, query, { limit: Number(opts.limit) });
|
|
100
|
+
const r = engine.ask(dir, query, { limit: Number(opts.limit), source: opts.source });
|
|
89
101
|
if (opts.json) {
|
|
90
102
|
console.log(JSON.stringify(r, null, 2));
|
|
91
103
|
}
|
|
@@ -150,6 +162,23 @@ program
|
|
|
150
162
|
spawn(opener, [srv.url], { stdio: "ignore", detached: true, shell: process.platform === "win32" }).unref();
|
|
151
163
|
}
|
|
152
164
|
});
|
|
165
|
+
program
|
|
166
|
+
.command("init")
|
|
167
|
+
.description("Set up the Claude Code integration (.claude/ statusline + hooks) in this repo")
|
|
168
|
+
.argument("[dir]", "target repo directory", ".")
|
|
169
|
+
.option("--no-build", "skip building the graph (wire files only)")
|
|
170
|
+
.action((dir, opts) => {
|
|
171
|
+
const cliPath = fileURLToPath(import.meta.url);
|
|
172
|
+
const res = runInit(resolve(dir), { build: opts.build, cliPath });
|
|
173
|
+
console.error(`✓ wrote ${res.settingsPath}`);
|
|
174
|
+
for (const s of res.shims)
|
|
175
|
+
console.error(`✓ wrote ${s}`);
|
|
176
|
+
console.error(res.built ? "✓ built the graph (graft build)" : "· skipped graph build");
|
|
177
|
+
for (const w of res.warnings)
|
|
178
|
+
console.error(`⚠ ${w}`);
|
|
179
|
+
console.error("\nDone. The statusline + hooks activate in Claude Code sessions in this repo.");
|
|
180
|
+
console.error("For LLM summaries: set OPENROUTER_API_KEY and run `graft build --deep`.");
|
|
181
|
+
});
|
|
153
182
|
program.parseAsync().catch((err) => {
|
|
154
183
|
console.error(err instanceof Error ? err.message : err);
|
|
155
184
|
process.exit(1);
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AACH,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE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AW,GAAG,CAAC,YAAY,EAAE,CAAC,CAAC;IAC7C,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACzD,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC;IACvF,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACtD,OAAO,CAAC,KAAK,CAAC,+EAA+E,CAAC,CAAC;IAC/F,OAAO,CAAC,KAAK,CAAC,yEAAyE,CAAC,CAAC;AAC3F,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjC,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/engine.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export interface CheckRunOptions {
|
|
|
30
30
|
export interface GraphRunOptions {
|
|
31
31
|
/** Run the Tier-2 LLM meaning pass (summary + crux). Absent → Tier-1 only. */
|
|
32
32
|
llm?: boolean;
|
|
33
|
+
/** Max files summarized in parallel during the LLM pass. */
|
|
34
|
+
concurrency?: number;
|
|
33
35
|
onProgress?: GraphBuildOptions["onProgress"];
|
|
34
36
|
}
|
|
35
37
|
export declare class Graft {
|
|
@@ -54,6 +56,7 @@ export declare class Graft {
|
|
|
54
56
|
*/
|
|
55
57
|
ask(dir: string, query: string, opts?: {
|
|
56
58
|
limit?: number;
|
|
59
|
+
source?: boolean;
|
|
57
60
|
}): AskResult;
|
|
58
61
|
/** The OpenRouter API key, or a clear error telling the user how to set it. */
|
|
59
62
|
private requireKey;
|