@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.
Files changed (123) hide show
  1. package/CHANGELOG.md +72 -126
  2. package/README.md +290 -102
  3. package/dist/cli.js +41 -1
  4. package/dist/cli.js.map +1 -1
  5. package/dist/edges.js +22 -11
  6. package/dist/edges.js.map +1 -1
  7. package/dist/indexer.js +3 -3
  8. package/dist/indexer.js.map +1 -1
  9. package/dist/init.d.ts +28 -0
  10. package/dist/init.js +112 -0
  11. package/dist/init.js.map +1 -0
  12. package/dist/interactions.d.ts +5 -4
  13. package/dist/interactions.js +0 -0
  14. package/dist/interactions.js.map +1 -1
  15. package/dist/mcp.js +119 -90
  16. package/dist/mcp.js.map +1 -1
  17. package/dist/repo-resolve.d.ts +47 -0
  18. package/dist/repo-resolve.js +195 -0
  19. package/dist/repo-resolve.js.map +1 -0
  20. package/dist/storage.js +10 -1
  21. package/dist/storage.js.map +1 -1
  22. package/dist/symbols.js +26 -2
  23. package/dist/symbols.js.map +1 -1
  24. package/dist/validation.js +30 -4
  25. package/dist/validation.js.map +1 -1
  26. package/dist/validators.d.ts +1 -5
  27. package/dist/validators.js +0 -11
  28. package/dist/validators.js.map +1 -1
  29. package/dist/watcher.d.ts +10 -0
  30. package/dist/watcher.js +70 -7
  31. package/dist/watcher.js.map +1 -1
  32. package/examples/README.md +105 -0
  33. package/examples/claude-code/README.md +125 -0
  34. package/examples/claude-code/claude-routing.md +102 -0
  35. package/examples/claude-code/claude_config.json +8 -0
  36. package/examples/cline/.clinerules +39 -0
  37. package/examples/cline/README.md +104 -0
  38. package/examples/cline/cline_mcp_settings.json +10 -0
  39. package/examples/continue/.continuerules +39 -0
  40. package/examples/continue/README.md +98 -0
  41. package/examples/continue/config.json +13 -0
  42. package/examples/cursor/.cursorrules +39 -0
  43. package/examples/cursor/README.md +98 -0
  44. package/examples/cursor/mcp.json +11 -0
  45. package/examples/windsurf/.windsurfrules +39 -0
  46. package/examples/windsurf/README.md +85 -0
  47. package/examples/windsurf/mcp_config.json +8 -0
  48. package/package.json +14 -4
  49. package/.editorconfig +0 -15
  50. package/.github/CODEOWNERS +0 -22
  51. package/.github/FUNDING.yml +0 -1
  52. package/.github/ISSUE_TEMPLATE/bug_report.md +0 -33
  53. package/.github/ISSUE_TEMPLATE/config.yml +0 -5
  54. package/.github/ISSUE_TEMPLATE/feature_request.md +0 -23
  55. package/.github/PULL_REQUEST_TEMPLATE.md +0 -19
  56. package/.github/dependabot.yml +0 -15
  57. package/.github/workflows/ci.yml +0 -62
  58. package/.github/workflows/release.yml +0 -50
  59. package/.prettierignore +0 -19
  60. package/.prettierrc.json +0 -20
  61. package/CODE_OF_CONDUCT.md +0 -83
  62. package/CONTRIBUTING.md +0 -111
  63. package/bench/README.md +0 -544
  64. package/bench/results/agent-tier-2026-05-22.md +0 -28
  65. package/bench/results/agent-tier-summary.md +0 -44
  66. package/bench/results/baseline-tier-2026-05-22.md +0 -23
  67. package/bench/results/baseline.json +0 -810
  68. package/bench/results/baseline.md +0 -28
  69. package/bench/run-agent-tier-automated.ts +0 -234
  70. package/bench/run-agent-tier.md +0 -125
  71. package/bench/run-baseline-tier.ts +0 -200
  72. package/bench/run.ts +0 -210
  73. package/bench/runner-baseline.ts +0 -177
  74. package/bench/runner-graphpilot.ts +0 -131
  75. package/bench/score-agent-tier.ts +0 -191
  76. package/bench/score.ts +0 -59
  77. package/bench/tasks.ts +0 -236
  78. package/dist/provenance.d.ts +0 -74
  79. package/dist/provenance.js +0 -95
  80. package/dist/provenance.js.map +0 -1
  81. package/docs/architecture.md +0 -311
  82. package/docs/limitations.md +0 -156
  83. package/docs/mcp-setup.md +0 -231
  84. package/docs/quickstart.md +0 -202
  85. package/eslint.config.js +0 -148
  86. package/lefthook.yml +0 -81
  87. package/pnpm-workspace.yaml +0 -6
  88. package/scripts/smoke-stdio.mjs +0 -97
  89. package/src/cli.ts +0 -171
  90. package/src/edges.ts +0 -202
  91. package/src/git.ts +0 -255
  92. package/src/graph-schema.ts +0 -229
  93. package/src/impact.ts +0 -218
  94. package/src/indexer.ts +0 -152
  95. package/src/interactions.ts +0 -0
  96. package/src/mcp.ts +0 -652
  97. package/src/parser.ts +0 -138
  98. package/src/provenance.ts +0 -115
  99. package/src/query.ts +0 -148
  100. package/src/redact.ts +0 -122
  101. package/src/storage.ts +0 -115
  102. package/src/symbols.ts +0 -173
  103. package/src/validation.ts +0 -69
  104. package/src/validators.ts +0 -253
  105. package/src/watcher.ts +0 -383
  106. package/tests/edges.test.ts +0 -175
  107. package/tests/fixtures/sample.ts +0 -32
  108. package/tests/git.test.ts +0 -303
  109. package/tests/graph-schema.test.ts +0 -321
  110. package/tests/impact.test.ts +0 -454
  111. package/tests/interactions.test.ts +0 -180
  112. package/tests/lint-policy.test.ts +0 -106
  113. package/tests/mcp-stdio.test.ts +0 -171
  114. package/tests/mcp.test.ts +0 -335
  115. package/tests/parser.test.ts +0 -31
  116. package/tests/provenance.test.ts +0 -132
  117. package/tests/query.test.ts +0 -160
  118. package/tests/redact.test.ts +0 -167
  119. package/tests/security.test.ts +0 -144
  120. package/tests/symbols.test.ts +0 -78
  121. package/tests/validators.test.ts +0 -193
  122. package/tests/watcher.test.ts +0 -250
  123. 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
- }
Binary file