@graphpilot-oss/graphpilot 0.0.1 → 1.0.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/CHANGELOG.md +72 -126
- package/README.md +290 -102
- package/dist/cli.js +41 -1
- package/dist/cli.js.map +1 -1
- package/dist/edges.js +22 -11
- package/dist/edges.js.map +1 -1
- package/dist/indexer.js +3 -3
- package/dist/indexer.js.map +1 -1
- package/dist/init.d.ts +28 -0
- package/dist/init.js +112 -0
- package/dist/init.js.map +1 -0
- package/dist/interactions.d.ts +5 -4
- package/dist/interactions.js +0 -0
- package/dist/interactions.js.map +1 -1
- package/dist/mcp.js +119 -90
- package/dist/mcp.js.map +1 -1
- package/dist/repo-resolve.d.ts +47 -0
- package/dist/repo-resolve.js +195 -0
- package/dist/repo-resolve.js.map +1 -0
- package/dist/storage.js +10 -1
- package/dist/storage.js.map +1 -1
- package/dist/symbols.js +26 -2
- package/dist/symbols.js.map +1 -1
- package/dist/validation.js +30 -4
- package/dist/validation.js.map +1 -1
- package/dist/validators.d.ts +1 -5
- package/dist/validators.js +0 -11
- package/dist/validators.js.map +1 -1
- package/dist/watcher.d.ts +10 -0
- package/dist/watcher.js +70 -7
- package/dist/watcher.js.map +1 -1
- package/examples/README.md +105 -0
- package/examples/claude-code/README.md +125 -0
- package/examples/claude-code/claude-routing.md +102 -0
- package/examples/claude-code/claude_config.json +8 -0
- package/examples/cline/.clinerules +39 -0
- package/examples/cline/README.md +104 -0
- package/examples/cline/cline_mcp_settings.json +10 -0
- package/examples/continue/.continuerules +39 -0
- package/examples/continue/README.md +98 -0
- package/examples/continue/config.json +13 -0
- package/examples/cursor/.cursorrules +39 -0
- package/examples/cursor/README.md +98 -0
- package/examples/cursor/mcp.json +11 -0
- package/examples/windsurf/.windsurfrules +39 -0
- package/examples/windsurf/README.md +85 -0
- package/examples/windsurf/mcp_config.json +8 -0
- package/package.json +14 -4
- package/.editorconfig +0 -15
- package/.github/CODEOWNERS +0 -22
- package/.github/FUNDING.yml +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -33
- package/.github/ISSUE_TEMPLATE/config.yml +0 -5
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -19
- package/.github/dependabot.yml +0 -15
- package/.github/workflows/ci.yml +0 -62
- package/.github/workflows/release.yml +0 -50
- package/.prettierignore +0 -19
- package/.prettierrc.json +0 -20
- package/CODE_OF_CONDUCT.md +0 -83
- package/CONTRIBUTING.md +0 -111
- package/bench/README.md +0 -544
- package/bench/results/agent-tier-2026-05-22.md +0 -28
- package/bench/results/agent-tier-summary.md +0 -44
- package/bench/results/baseline-tier-2026-05-22.md +0 -23
- package/bench/results/baseline.json +0 -810
- package/bench/results/baseline.md +0 -28
- package/bench/run-agent-tier-automated.ts +0 -234
- package/bench/run-agent-tier.md +0 -125
- package/bench/run-baseline-tier.ts +0 -200
- package/bench/run.ts +0 -210
- package/bench/runner-baseline.ts +0 -177
- package/bench/runner-graphpilot.ts +0 -131
- package/bench/score-agent-tier.ts +0 -191
- package/bench/score.ts +0 -59
- package/bench/tasks.ts +0 -236
- package/dist/provenance.d.ts +0 -74
- package/dist/provenance.js +0 -95
- package/dist/provenance.js.map +0 -1
- package/docs/architecture.md +0 -311
- package/docs/limitations.md +0 -156
- package/docs/mcp-setup.md +0 -231
- package/docs/quickstart.md +0 -202
- package/eslint.config.js +0 -148
- package/lefthook.yml +0 -81
- package/pnpm-workspace.yaml +0 -6
- package/scripts/smoke-stdio.mjs +0 -97
- package/src/cli.ts +0 -171
- package/src/edges.ts +0 -202
- package/src/git.ts +0 -255
- package/src/graph-schema.ts +0 -229
- package/src/impact.ts +0 -218
- package/src/indexer.ts +0 -152
- package/src/interactions.ts +0 -0
- package/src/mcp.ts +0 -652
- package/src/parser.ts +0 -138
- package/src/provenance.ts +0 -115
- package/src/query.ts +0 -148
- package/src/redact.ts +0 -122
- package/src/storage.ts +0 -115
- package/src/symbols.ts +0 -173
- package/src/validation.ts +0 -69
- package/src/validators.ts +0 -253
- package/src/watcher.ts +0 -383
- package/tests/edges.test.ts +0 -175
- package/tests/fixtures/sample.ts +0 -32
- package/tests/git.test.ts +0 -303
- package/tests/graph-schema.test.ts +0 -321
- package/tests/impact.test.ts +0 -454
- package/tests/interactions.test.ts +0 -180
- package/tests/lint-policy.test.ts +0 -106
- package/tests/mcp-stdio.test.ts +0 -171
- package/tests/mcp.test.ts +0 -335
- package/tests/parser.test.ts +0 -31
- package/tests/provenance.test.ts +0 -132
- package/tests/query.test.ts +0 -160
- package/tests/redact.test.ts +0 -167
- package/tests/security.test.ts +0 -144
- package/tests/symbols.test.ts +0 -78
- package/tests/validators.test.ts +0 -193
- package/tests/watcher.test.ts +0 -250
- package/tsconfig.json +0 -18
package/src/indexer.ts
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import fg from 'fast-glob';
|
|
2
|
-
import { realpathSync } from 'node:fs';
|
|
3
|
-
import { resolve, relative } from 'node:path';
|
|
4
|
-
import { parseFile } from './parser.js';
|
|
5
|
-
import { extractSymbols, type SymbolRecord } from './symbols.js';
|
|
6
|
-
import { extractRawCalls, resolveCallEdges, type CallEdge, type RawCall } from './edges.js';
|
|
7
|
-
import { MAX_FILES_PER_INDEX } from './validation.js';
|
|
8
|
-
import { readGitInfo, type GitInfo } from './git.js';
|
|
9
|
-
|
|
10
|
-
export interface IndexResult {
|
|
11
|
-
rootPath: string;
|
|
12
|
-
filesIndexed: number;
|
|
13
|
-
filesFailed: number;
|
|
14
|
-
symbols: SymbolRecord[];
|
|
15
|
-
edges: CallEdge[];
|
|
16
|
-
durationMs: number;
|
|
17
|
-
/**
|
|
18
|
-
* Git provenance — populated when the indexed root lives inside a
|
|
19
|
-
* git worktree. Used by the CLI / MCP layer to stamp the saved
|
|
20
|
-
* Graph with `indexedSha` / `indexedBranch` so every later tool
|
|
21
|
-
* response can carry a verifiable evidence anchor (per v0.1.5
|
|
22
|
-
* differentiation pivot).
|
|
23
|
-
*/
|
|
24
|
-
git: GitInfo;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface IndexOptions {
|
|
28
|
-
/** Override the default include patterns. */
|
|
29
|
-
include?: string[];
|
|
30
|
-
/** Extra ignore patterns appended to the defaults. */
|
|
31
|
-
ignore?: string[];
|
|
32
|
-
/** Store file paths relative to rootPath in symbols. Default: true. */
|
|
33
|
-
relativePaths?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const DEFAULT_INCLUDE = ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.mjs', '**/*.cjs'];
|
|
37
|
-
|
|
38
|
-
const DEFAULT_IGNORE = [
|
|
39
|
-
'**/node_modules/**',
|
|
40
|
-
'**/dist/**',
|
|
41
|
-
'**/build/**',
|
|
42
|
-
'**/.git/**',
|
|
43
|
-
'**/coverage/**',
|
|
44
|
-
'**/.next/**',
|
|
45
|
-
'**/.nuxt/**',
|
|
46
|
-
'**/.cache/**',
|
|
47
|
-
'**/out/**',
|
|
48
|
-
'**/*.d.ts',
|
|
49
|
-
];
|
|
50
|
-
|
|
51
|
-
export async function indexDirectory(
|
|
52
|
-
rootPath: string,
|
|
53
|
-
opts: IndexOptions = {},
|
|
54
|
-
): Promise<IndexResult> {
|
|
55
|
-
const start = Date.now();
|
|
56
|
-
const absRoot = resolve(rootPath);
|
|
57
|
-
const include = opts.include ?? DEFAULT_INCLUDE;
|
|
58
|
-
const ignore = [...DEFAULT_IGNORE, ...(opts.ignore ?? [])];
|
|
59
|
-
const useRelative = opts.relativePaths ?? true;
|
|
60
|
-
|
|
61
|
-
// Resolve symlinks at the root so the boundary check below is correct.
|
|
62
|
-
// Defence against T2 (symlink escape): we'll verify every file's realpath
|
|
63
|
-
// stays within this resolved root.
|
|
64
|
-
const realRoot = realpathSync(absRoot);
|
|
65
|
-
|
|
66
|
-
const files = await fg(include, {
|
|
67
|
-
cwd: absRoot,
|
|
68
|
-
ignore,
|
|
69
|
-
absolute: true,
|
|
70
|
-
onlyFiles: true,
|
|
71
|
-
suppressErrors: true,
|
|
72
|
-
// T2 defence #1: don't even descend into symlinked directories.
|
|
73
|
-
followSymbolicLinks: false,
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
// T10 defence: hard cap on files indexed per run. Throws so the CLI prints
|
|
77
|
-
// a clear error instead of silently chewing through a million-file tree.
|
|
78
|
-
if (files.length > MAX_FILES_PER_INDEX) {
|
|
79
|
-
throw new Error(
|
|
80
|
-
`Refusing to index ${files.length} files (limit: ${MAX_FILES_PER_INDEX}). ` +
|
|
81
|
-
`Narrow the path or add patterns to ignore.`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const symbols: SymbolRecord[] = [];
|
|
86
|
-
const rawCalls: RawCall[] = [];
|
|
87
|
-
let filesIndexed = 0;
|
|
88
|
-
let filesFailed = 0;
|
|
89
|
-
let filesSkippedSymlink = 0;
|
|
90
|
-
|
|
91
|
-
for (const file of files) {
|
|
92
|
-
try {
|
|
93
|
-
// T2 defence #2: belt-and-suspenders — even if a symlink slipped through,
|
|
94
|
-
// verify the file's real path lives under the real root.
|
|
95
|
-
let realFile: string;
|
|
96
|
-
try {
|
|
97
|
-
realFile = realpathSync(file);
|
|
98
|
-
} catch {
|
|
99
|
-
filesFailed++;
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
if (!realFile.startsWith(realRoot)) {
|
|
103
|
-
filesSkippedSymlink++;
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const parsed = parseFile(file);
|
|
108
|
-
if (!parsed) continue;
|
|
109
|
-
const fileSymbols = extractSymbols(parsed);
|
|
110
|
-
const fileCalls = extractRawCalls(parsed, fileSymbols);
|
|
111
|
-
|
|
112
|
-
if (useRelative) {
|
|
113
|
-
const rel = relative(absRoot, file);
|
|
114
|
-
// Track id rewrites so call edges can be remapped in lockstep.
|
|
115
|
-
const idRewrites = new Map<string, string>();
|
|
116
|
-
for (const s of fileSymbols) {
|
|
117
|
-
const oldId = s.id;
|
|
118
|
-
s.file = rel;
|
|
119
|
-
s.id = oldId.replace(file, rel);
|
|
120
|
-
idRewrites.set(oldId, s.id);
|
|
121
|
-
}
|
|
122
|
-
for (const c of fileCalls) {
|
|
123
|
-
c.file = rel;
|
|
124
|
-
c.fromId = idRewrites.get(c.fromId) ?? c.fromId;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
symbols.push(...fileSymbols);
|
|
129
|
-
rawCalls.push(...fileCalls);
|
|
130
|
-
filesIndexed++;
|
|
131
|
-
} catch {
|
|
132
|
-
filesFailed++;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Second pass: resolve names to symbol ids now that we've seen every file.
|
|
137
|
-
const edges = resolveCallEdges(rawCalls, symbols);
|
|
138
|
-
|
|
139
|
-
// Capture git provenance for the index timestamp. Best-effort — if
|
|
140
|
-
// the root isn't a git repo, all fields are null.
|
|
141
|
-
const git = readGitInfo(absRoot);
|
|
142
|
-
|
|
143
|
-
return {
|
|
144
|
-
rootPath: absRoot,
|
|
145
|
-
filesIndexed,
|
|
146
|
-
filesFailed: filesFailed + filesSkippedSymlink,
|
|
147
|
-
symbols,
|
|
148
|
-
edges,
|
|
149
|
-
durationMs: Date.now() - start,
|
|
150
|
-
git,
|
|
151
|
-
};
|
|
152
|
-
}
|
package/src/interactions.ts
DELETED
|
Binary file
|