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