@saluzi/codegraph 0.1.0 → 0.2.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 (246) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +885 -0
  3. package/package.json +42 -10
  4. package/scripts/add-lang/bench.sh +60 -0
  5. package/scripts/add-lang/check-grammar.mjs +75 -0
  6. package/scripts/add-lang/dump-ast.mjs +103 -0
  7. package/scripts/add-lang/verify-extraction.mjs +70 -0
  8. package/scripts/agent-eval/ab-adoption.sh +91 -0
  9. package/scripts/agent-eval/ab-hook.sh +86 -0
  10. package/scripts/agent-eval/ab-impl.sh +78 -0
  11. package/scripts/agent-eval/ab-new-vs-baseline.sh +102 -0
  12. package/scripts/agent-eval/ab-sufficiency.sh +78 -0
  13. package/scripts/agent-eval/arms-F.sh +21 -0
  14. package/scripts/agent-eval/arms-matrix.sh +37 -0
  15. package/scripts/agent-eval/audit.sh +68 -0
  16. package/scripts/agent-eval/bench-readme.sh +28 -0
  17. package/scripts/agent-eval/bench-why-repo.sh +22 -0
  18. package/scripts/agent-eval/block-read-hook.sh +19 -0
  19. package/scripts/agent-eval/hook-settings.json +15 -0
  20. package/scripts/agent-eval/itrun.sh +120 -0
  21. package/scripts/agent-eval/offload-eval-3arm.sh +72 -0
  22. package/scripts/agent-eval/offload-eval-cost.mjs +133 -0
  23. package/scripts/agent-eval/offload-eval-effort.mjs +108 -0
  24. package/scripts/agent-eval/offload-eval-frontload-matrix.sh +25 -0
  25. package/scripts/agent-eval/offload-eval-frontload.sh +47 -0
  26. package/scripts/agent-eval/offload-eval-ground-truth.json +18 -0
  27. package/scripts/agent-eval/offload-eval-hook.mjs +84 -0
  28. package/scripts/agent-eval/offload-eval-judge.mjs +103 -0
  29. package/scripts/agent-eval/offload-eval-matrix.sh +20 -0
  30. package/scripts/agent-eval/offload-eval-metrics.mjs +94 -0
  31. package/scripts/agent-eval/offload-eval-refs1.sh +50 -0
  32. package/scripts/agent-eval/offload-eval-setup.sh +24 -0
  33. package/scripts/agent-eval/offload-eval-styles.sh +72 -0
  34. package/scripts/agent-eval/offload-eval-summarize.mjs +68 -0
  35. package/scripts/agent-eval/offload-eval.md +76 -0
  36. package/scripts/agent-eval/parse-arms.mjs +116 -0
  37. package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
  38. package/scripts/agent-eval/parse-run.mjs +45 -0
  39. package/scripts/agent-eval/parse-session.mjs +93 -0
  40. package/scripts/agent-eval/probe-context.mjs +21 -0
  41. package/scripts/agent-eval/probe-explore.mjs +40 -0
  42. package/scripts/agent-eval/probe-node.mjs +20 -0
  43. package/scripts/agent-eval/probe-sweep.mjs +119 -0
  44. package/scripts/agent-eval/probe-trace.mjs +20 -0
  45. package/scripts/agent-eval/redirect-read-hook.sh +38 -0
  46. package/scripts/agent-eval/repro-concurrent-explore.mjs +119 -0
  47. package/scripts/agent-eval/repro-daemon-clients.mjs +125 -0
  48. package/scripts/agent-eval/run-agent.sh +34 -0
  49. package/scripts/agent-eval/run-all.sh +75 -0
  50. package/scripts/agent-eval/run-arms.sh +56 -0
  51. package/scripts/agent-eval/seq-matrix.mjs +137 -0
  52. package/scripts/build-bundle.sh +123 -0
  53. package/scripts/extract-release-notes.mjs +130 -0
  54. package/scripts/local-install.sh +41 -0
  55. package/scripts/npm-sdk.js +75 -0
  56. package/scripts/npm-shim.js +275 -0
  57. package/scripts/pack-npm.sh +119 -0
  58. package/scripts/prepare-release.mjs +270 -0
  59. package/dist/bin/codegraph.d.ts +0 -25
  60. package/dist/bin/node-version-check.d.ts +0 -37
  61. package/dist/bin/uninstall.d.ts +0 -14
  62. package/dist/context/formatter.d.ts +0 -33
  63. package/dist/context/formatter.js +0 -244
  64. package/dist/context/index.d.ts +0 -117
  65. package/dist/context/index.js +0 -1050
  66. package/dist/db/index.d.ts +0 -101
  67. package/dist/db/index.js +0 -250
  68. package/dist/db/migrations.d.ts +0 -47
  69. package/dist/db/migrations.js +0 -131
  70. package/dist/db/queries.d.ts +0 -291
  71. package/dist/db/queries.js +0 -1349
  72. package/dist/db/schema.sql +0 -151
  73. package/dist/db/sqlite-adapter.d.ts +0 -49
  74. package/dist/db/sqlite-adapter.js +0 -141
  75. package/dist/directory.d.ts +0 -62
  76. package/dist/directory.js +0 -264
  77. package/dist/errors.d.ts +0 -149
  78. package/dist/errors.js +0 -219
  79. package/dist/extraction/dfm-extractor.d.ts +0 -31
  80. package/dist/extraction/dfm-extractor.js +0 -151
  81. package/dist/extraction/grammars.d.ts +0 -94
  82. package/dist/extraction/grammars.js +0 -357
  83. package/dist/extraction/index.d.ts +0 -148
  84. package/dist/extraction/index.js +0 -1286
  85. package/dist/extraction/languages/c-cpp.d.ts +0 -4
  86. package/dist/extraction/languages/c-cpp.js +0 -126
  87. package/dist/extraction/languages/csharp.d.ts +0 -3
  88. package/dist/extraction/languages/csharp.js +0 -72
  89. package/dist/extraction/languages/dart.d.ts +0 -3
  90. package/dist/extraction/languages/dart.js +0 -192
  91. package/dist/extraction/languages/go.d.ts +0 -3
  92. package/dist/extraction/languages/go.js +0 -58
  93. package/dist/extraction/languages/index.d.ts +0 -10
  94. package/dist/extraction/languages/index.js +0 -49
  95. package/dist/extraction/languages/java.d.ts +0 -3
  96. package/dist/extraction/languages/java.js +0 -64
  97. package/dist/extraction/languages/javascript.d.ts +0 -3
  98. package/dist/extraction/languages/javascript.js +0 -90
  99. package/dist/extraction/languages/kotlin.d.ts +0 -3
  100. package/dist/extraction/languages/kotlin.js +0 -253
  101. package/dist/extraction/languages/lua.d.ts +0 -3
  102. package/dist/extraction/languages/lua.js +0 -150
  103. package/dist/extraction/languages/luau.d.ts +0 -3
  104. package/dist/extraction/languages/luau.js +0 -37
  105. package/dist/extraction/languages/pascal.d.ts +0 -3
  106. package/dist/extraction/languages/pascal.js +0 -66
  107. package/dist/extraction/languages/php.d.ts +0 -3
  108. package/dist/extraction/languages/php.js +0 -107
  109. package/dist/extraction/languages/python.d.ts +0 -3
  110. package/dist/extraction/languages/python.js +0 -56
  111. package/dist/extraction/languages/ruby.d.ts +0 -3
  112. package/dist/extraction/languages/ruby.js +0 -114
  113. package/dist/extraction/languages/rust.d.ts +0 -3
  114. package/dist/extraction/languages/rust.js +0 -109
  115. package/dist/extraction/languages/scala.d.ts +0 -3
  116. package/dist/extraction/languages/scala.js +0 -139
  117. package/dist/extraction/languages/swift.d.ts +0 -3
  118. package/dist/extraction/languages/swift.js +0 -91
  119. package/dist/extraction/languages/typescript.d.ts +0 -3
  120. package/dist/extraction/languages/typescript.js +0 -129
  121. package/dist/extraction/liquid-extractor.d.ts +0 -52
  122. package/dist/extraction/liquid-extractor.js +0 -313
  123. package/dist/extraction/parse-worker.d.ts +0 -8
  124. package/dist/extraction/parse-worker.js +0 -94
  125. package/dist/extraction/svelte-extractor.d.ts +0 -56
  126. package/dist/extraction/svelte-extractor.js +0 -272
  127. package/dist/extraction/tree-sitter-helpers.d.ts +0 -39
  128. package/dist/extraction/tree-sitter-helpers.js +0 -103
  129. package/dist/extraction/tree-sitter-types.d.ts +0 -191
  130. package/dist/extraction/tree-sitter-types.js +0 -10
  131. package/dist/extraction/tree-sitter.d.ts +0 -238
  132. package/dist/extraction/tree-sitter.js +0 -2430
  133. package/dist/extraction/vue-extractor.d.ts +0 -36
  134. package/dist/extraction/vue-extractor.js +0 -163
  135. package/dist/extraction/wasm/tree-sitter-c.wasm +0 -0
  136. package/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
  137. package/dist/extraction/wasm/tree-sitter-cpp.wasm +0 -0
  138. package/dist/extraction/wasm/tree-sitter-dart.wasm +0 -0
  139. package/dist/extraction/wasm/tree-sitter-go.wasm +0 -0
  140. package/dist/extraction/wasm/tree-sitter-java.wasm +0 -0
  141. package/dist/extraction/wasm/tree-sitter-javascript.wasm +0 -0
  142. package/dist/extraction/wasm/tree-sitter-kotlin.wasm +0 -0
  143. package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
  144. package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
  145. package/dist/extraction/wasm/tree-sitter-pascal.wasm +0 -0
  146. package/dist/extraction/wasm/tree-sitter-php.wasm +0 -0
  147. package/dist/extraction/wasm/tree-sitter-python.wasm +0 -0
  148. package/dist/extraction/wasm/tree-sitter-ruby.wasm +0 -0
  149. package/dist/extraction/wasm/tree-sitter-rust.wasm +0 -0
  150. package/dist/extraction/wasm/tree-sitter-scala.wasm +0 -0
  151. package/dist/extraction/wasm/tree-sitter-swift.wasm +0 -0
  152. package/dist/extraction/wasm/tree-sitter-tsx.wasm +0 -0
  153. package/dist/extraction/wasm/tree-sitter-typescript.wasm +0 -0
  154. package/dist/extraction/wasm-runtime-flags.d.ts +0 -46
  155. package/dist/extraction/wasm-runtime-flags.js +0 -105
  156. package/dist/graph/index.d.ts +0 -8
  157. package/dist/graph/index.js +0 -13
  158. package/dist/graph/queries.d.ts +0 -109
  159. package/dist/graph/queries.js +0 -366
  160. package/dist/graph/traversal.d.ts +0 -137
  161. package/dist/graph/traversal.js +0 -528
  162. package/dist/index.d.ts +0 -509
  163. package/dist/index.js +0 -800
  164. package/dist/installer/claude-md-template.d.ts +0 -19
  165. package/dist/installer/config-writer.d.ts +0 -29
  166. package/dist/installer/index.d.ts +0 -140
  167. package/dist/installer/instructions-template.d.ts +0 -30
  168. package/dist/installer/targets/claude.d.ts +0 -55
  169. package/dist/installer/targets/codex.d.ts +0 -18
  170. package/dist/installer/targets/cursor.d.ts +0 -35
  171. package/dist/installer/targets/hermes.d.ts +0 -18
  172. package/dist/installer/targets/opencode.d.ts +0 -30
  173. package/dist/installer/targets/registry.d.ts +0 -38
  174. package/dist/installer/targets/shared.d.ts +0 -92
  175. package/dist/installer/targets/toml.d.ts +0 -64
  176. package/dist/installer/targets/types.d.ts +0 -122
  177. package/dist/mcp/index.d.ts +0 -98
  178. package/dist/mcp/server-instructions.d.ts +0 -20
  179. package/dist/mcp/tools.d.ts +0 -269
  180. package/dist/mcp/transport.d.ts +0 -117
  181. package/dist/resolution/frameworks/cargo-workspace.d.ts +0 -20
  182. package/dist/resolution/frameworks/cargo-workspace.js +0 -225
  183. package/dist/resolution/frameworks/csharp.d.ts +0 -8
  184. package/dist/resolution/frameworks/csharp.js +0 -213
  185. package/dist/resolution/frameworks/drupal.d.ts +0 -51
  186. package/dist/resolution/frameworks/drupal.js +0 -335
  187. package/dist/resolution/frameworks/express.d.ts +0 -8
  188. package/dist/resolution/frameworks/express.js +0 -225
  189. package/dist/resolution/frameworks/go.d.ts +0 -8
  190. package/dist/resolution/frameworks/go.js +0 -158
  191. package/dist/resolution/frameworks/index.d.ts +0 -52
  192. package/dist/resolution/frameworks/index.js +0 -137
  193. package/dist/resolution/frameworks/java.d.ts +0 -8
  194. package/dist/resolution/frameworks/java.js +0 -177
  195. package/dist/resolution/frameworks/laravel.d.ts +0 -13
  196. package/dist/resolution/frameworks/laravel.js +0 -248
  197. package/dist/resolution/frameworks/nestjs.d.ts +0 -26
  198. package/dist/resolution/frameworks/nestjs.js +0 -374
  199. package/dist/resolution/frameworks/python.d.ts +0 -10
  200. package/dist/resolution/frameworks/python.js +0 -278
  201. package/dist/resolution/frameworks/react.d.ts +0 -8
  202. package/dist/resolution/frameworks/react.js +0 -272
  203. package/dist/resolution/frameworks/ruby.d.ts +0 -8
  204. package/dist/resolution/frameworks/ruby.js +0 -198
  205. package/dist/resolution/frameworks/rust.d.ts +0 -8
  206. package/dist/resolution/frameworks/rust.js +0 -207
  207. package/dist/resolution/frameworks/svelte.d.ts +0 -9
  208. package/dist/resolution/frameworks/svelte.js +0 -249
  209. package/dist/resolution/frameworks/swift.d.ts +0 -10
  210. package/dist/resolution/frameworks/swift.js +0 -376
  211. package/dist/resolution/frameworks/vue.d.ts +0 -9
  212. package/dist/resolution/frameworks/vue.js +0 -306
  213. package/dist/resolution/import-resolver.d.ts +0 -61
  214. package/dist/resolution/import-resolver.js +0 -663
  215. package/dist/resolution/index.d.ts +0 -118
  216. package/dist/resolution/index.js +0 -744
  217. package/dist/resolution/lru-cache.d.ts +0 -24
  218. package/dist/resolution/lru-cache.js +0 -62
  219. package/dist/resolution/name-matcher.d.ts +0 -50
  220. package/dist/resolution/name-matcher.js +0 -384
  221. package/dist/resolution/path-aliases.d.ts +0 -72
  222. package/dist/resolution/path-aliases.js +0 -238
  223. package/dist/resolution/strip-comments.d.ts +0 -40
  224. package/dist/resolution/strip-comments.js +0 -441
  225. package/dist/resolution/types.d.ts +0 -181
  226. package/dist/resolution/types.js +0 -8
  227. package/dist/search/query-parser.d.ts +0 -61
  228. package/dist/search/query-parser.js +0 -177
  229. package/dist/search/query-utils.d.ts +0 -59
  230. package/dist/search/query-utils.js +0 -383
  231. package/dist/sync/git-hooks.d.ts +0 -54
  232. package/dist/sync/git-hooks.js +0 -223
  233. package/dist/sync/index.d.ts +0 -25
  234. package/dist/sync/index.js +0 -28
  235. package/dist/sync/watch-policy.d.ts +0 -51
  236. package/dist/sync/watch-policy.js +0 -124
  237. package/dist/sync/watcher.d.ts +0 -83
  238. package/dist/sync/watcher.js +0 -192
  239. package/dist/types.d.ts +0 -433
  240. package/dist/types.js +0 -75
  241. package/dist/ui/glyphs.d.ts +0 -42
  242. package/dist/ui/shimmer-progress.d.ts +0 -11
  243. package/dist/ui/shimmer-worker.d.ts +0 -2
  244. package/dist/ui/types.d.ts +0 -20
  245. package/dist/utils.d.ts +0 -231
  246. package/dist/utils.js +0 -549
@@ -1,192 +0,0 @@
1
- "use strict";
2
- /**
3
- * File Watcher
4
- *
5
- * Watches the project directory for file changes and triggers
6
- * debounced sync operations to keep the code graph up-to-date.
7
- *
8
- * Uses Node.js native fs.watch with recursive mode (macOS FSEvents,
9
- * Windows ReadDirectoryChangesW, Linux inotify on Node 19+).
10
- */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
23
- Object.defineProperty(o, "default", { enumerable: true, value: v });
24
- }) : function(o, v) {
25
- o["default"] = v;
26
- });
27
- var __importStar = (this && this.__importStar) || (function () {
28
- var ownKeys = function(o) {
29
- ownKeys = Object.getOwnPropertyNames || function (o) {
30
- var ar = [];
31
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
32
- return ar;
33
- };
34
- return ownKeys(o);
35
- };
36
- return function (mod) {
37
- if (mod && mod.__esModule) return mod;
38
- var result = {};
39
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
40
- __setModuleDefault(result, mod);
41
- return result;
42
- };
43
- })();
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.FileWatcher = void 0;
46
- const fs = __importStar(require("fs"));
47
- const extraction_1 = require("../extraction");
48
- const errors_1 = require("../errors");
49
- const utils_1 = require("../utils");
50
- const watch_policy_1 = require("./watch-policy");
51
- /**
52
- * FileWatcher monitors a project directory for changes and triggers
53
- * debounced sync operations via a provided callback.
54
- *
55
- * Design goals:
56
- * - Minimal resource usage (native OS file events, no polling)
57
- * - Debounced to avoid thrashing on rapid saves
58
- * - Filters to supported source files by extension
59
- * - Ignores .codegraph/ directory changes
60
- */
61
- class FileWatcher {
62
- watcher = null;
63
- debounceTimer = null;
64
- hasChanges = false;
65
- syncing = false;
66
- stopped = false;
67
- projectRoot;
68
- debounceMs;
69
- syncFn;
70
- onSyncComplete;
71
- onSyncError;
72
- constructor(projectRoot, syncFn, options = {}) {
73
- this.projectRoot = projectRoot;
74
- this.syncFn = syncFn;
75
- this.debounceMs = options.debounceMs ?? 2000;
76
- this.onSyncComplete = options.onSyncComplete;
77
- this.onSyncError = options.onSyncError;
78
- }
79
- /**
80
- * Start watching for file changes.
81
- * Returns true if watching started successfully, false otherwise.
82
- */
83
- start() {
84
- if (this.watcher)
85
- return true; // Already watching
86
- this.stopped = false;
87
- // Some environments make recursive fs.watch unusable — most notably WSL2
88
- // /mnt/ drives, where setup blocks long enough to break MCP startup
89
- // handshakes (issue #199). Skip watching there; callers fall back to
90
- // manual `codegraph sync` or the git sync hooks.
91
- const disabledReason = (0, watch_policy_1.watchDisabledReason)(this.projectRoot);
92
- if (disabledReason) {
93
- (0, errors_1.logDebug)('File watcher disabled', { reason: disabledReason, projectRoot: this.projectRoot });
94
- return false;
95
- }
96
- try {
97
- this.watcher = fs.watch(this.projectRoot, { recursive: true }, (_eventType, filename) => {
98
- if (!filename || this.stopped)
99
- return;
100
- // Normalize path separators
101
- const normalized = (0, utils_1.normalizePath)(filename);
102
- // Ignore .codegraph/ directory changes (our own DB writes)
103
- if (normalized === '.codegraph' ||
104
- normalized.startsWith('.codegraph/') ||
105
- normalized.startsWith('.codegraph\\')) {
106
- return;
107
- }
108
- // Only sync changes to files we can actually parse.
109
- if (!(0, extraction_1.isSourceFile)(normalized)) {
110
- return;
111
- }
112
- (0, errors_1.logDebug)('File change detected', { file: normalized });
113
- this.hasChanges = true;
114
- this.scheduleSync();
115
- });
116
- // Handle watcher errors gracefully
117
- this.watcher.on('error', (err) => {
118
- (0, errors_1.logWarn)('File watcher error', { error: String(err) });
119
- // Don't crash — watcher may recover or user can restart
120
- });
121
- (0, errors_1.logDebug)('File watcher started', { projectRoot: this.projectRoot, debounceMs: this.debounceMs });
122
- return true;
123
- }
124
- catch (err) {
125
- // Recursive watch not supported (e.g., Linux < Node 19)
126
- (0, errors_1.logWarn)('Could not start file watcher — recursive fs.watch not supported on this platform', { error: String(err) });
127
- return false;
128
- }
129
- }
130
- /**
131
- * Stop watching for file changes.
132
- */
133
- stop() {
134
- this.stopped = true;
135
- if (this.debounceTimer) {
136
- clearTimeout(this.debounceTimer);
137
- this.debounceTimer = null;
138
- }
139
- if (this.watcher) {
140
- this.watcher.close();
141
- this.watcher = null;
142
- }
143
- this.hasChanges = false;
144
- (0, errors_1.logDebug)('File watcher stopped');
145
- }
146
- /**
147
- * Whether the watcher is currently active.
148
- */
149
- isActive() {
150
- return this.watcher !== null && !this.stopped;
151
- }
152
- /**
153
- * Schedule a debounced sync.
154
- */
155
- scheduleSync() {
156
- if (this.debounceTimer) {
157
- clearTimeout(this.debounceTimer);
158
- }
159
- this.debounceTimer = setTimeout(() => {
160
- this.debounceTimer = null;
161
- this.flush();
162
- }, this.debounceMs);
163
- }
164
- /**
165
- * Flush pending changes by running sync.
166
- */
167
- async flush() {
168
- // If already syncing, the post-sync check will re-trigger
169
- if (this.syncing || this.stopped)
170
- return;
171
- this.hasChanges = false;
172
- this.syncing = true;
173
- try {
174
- const result = await this.syncFn();
175
- this.onSyncComplete?.(result);
176
- }
177
- catch (err) {
178
- const error = err instanceof Error ? err : new Error(String(err));
179
- (0, errors_1.logWarn)('Watch sync failed', { error: error.message });
180
- this.onSyncError?.(error);
181
- }
182
- finally {
183
- this.syncing = false;
184
- // If new changes arrived during sync, schedule another
185
- if (this.hasChanges && !this.stopped) {
186
- this.scheduleSync();
187
- }
188
- }
189
- }
190
- }
191
- exports.FileWatcher = FileWatcher;
192
- //# sourceMappingURL=watcher.js.map
package/dist/types.d.ts DELETED
@@ -1,433 +0,0 @@
1
- /**
2
- * CodeGraph Type Definitions
3
- *
4
- * Core types for the semantic knowledge graph system.
5
- */
6
- /**
7
- * Types of nodes in the knowledge graph.
8
- *
9
- * Defined as a runtime-iterable `as const` array so the same source
10
- * of truth backs both the TS type and any runtime validation
11
- * (e.g. the search query parser).
12
- */
13
- export declare const NODE_KINDS: readonly [
14
- 'file',
15
- 'module',
16
- 'class',
17
- 'struct',
18
- 'interface',
19
- 'trait',
20
- 'protocol',
21
- 'function',
22
- 'method',
23
- 'property',
24
- 'field',
25
- 'variable',
26
- 'constant',
27
- 'enum',
28
- 'enum_member',
29
- 'type_alias',
30
- 'namespace',
31
- 'parameter',
32
- 'import',
33
- 'export',
34
- 'route',
35
- 'component',
36
- ]
37
- export type NodeKind = (typeof NODE_KINDS)[number]
38
- /**
39
- * Types of edges (relationships) between nodes
40
- */
41
- export type EdgeKind =
42
- | 'contains'
43
- | 'calls'
44
- | 'imports'
45
- | 'exports'
46
- | 'extends'
47
- | 'implements'
48
- | 'references'
49
- | 'type_of'
50
- | 'returns'
51
- | 'instantiates'
52
- | 'overrides'
53
- | 'decorates'
54
- /**
55
- * Supported programming languages. See NODE_KINDS for why this is a
56
- * runtime-iterable const array.
57
- */
58
- export declare const LANGUAGES: readonly [
59
- 'typescript',
60
- 'javascript',
61
- 'tsx',
62
- 'jsx',
63
- 'python',
64
- 'go',
65
- 'rust',
66
- 'java',
67
- 'c',
68
- 'cpp',
69
- 'csharp',
70
- 'php',
71
- 'ruby',
72
- 'swift',
73
- 'kotlin',
74
- 'dart',
75
- 'svelte',
76
- 'vue',
77
- 'liquid',
78
- 'pascal',
79
- 'scala',
80
- 'lua',
81
- 'luau',
82
- 'yaml',
83
- 'twig',
84
- 'unknown',
85
- ]
86
- export type Language = (typeof LANGUAGES)[number]
87
- /**
88
- * A node in the knowledge graph representing a code symbol
89
- */
90
- export interface Node {
91
- /** Unique identifier (hash of file path + qualified name) */
92
- id: string
93
- /** Type of code element */
94
- kind: NodeKind
95
- /** Simple name (e.g., "calculateTotal") */
96
- name: string
97
- /** Fully qualified name (e.g., "src/utils.ts::MathHelper.calculateTotal") */
98
- qualifiedName: string
99
- /** File path relative to project root */
100
- filePath: string
101
- /** Programming language */
102
- language: Language
103
- /** Starting line number (1-indexed) */
104
- startLine: number
105
- /** Ending line number (1-indexed) */
106
- endLine: number
107
- /** Starting column (0-indexed) */
108
- startColumn: number
109
- /** Ending column (0-indexed) */
110
- endColumn: number
111
- /** Documentation string if present */
112
- docstring?: string
113
- /** Function/method signature */
114
- signature?: string
115
- /** Visibility modifier */
116
- visibility?: 'public' | 'private' | 'protected' | 'internal'
117
- /** Whether symbol is exported */
118
- isExported?: boolean
119
- /** Whether symbol is async */
120
- isAsync?: boolean
121
- /** Whether symbol is static */
122
- isStatic?: boolean
123
- /** Whether symbol is abstract */
124
- isAbstract?: boolean
125
- /** Decorators/annotations applied */
126
- decorators?: string[]
127
- /** Generic type parameters */
128
- typeParameters?: string[]
129
- /** When the node was last updated */
130
- updatedAt: number
131
- }
132
- /**
133
- * An edge representing a relationship between two nodes
134
- */
135
- export interface Edge {
136
- /** Source node ID */
137
- source: string
138
- /** Target node ID */
139
- target: string
140
- /** Type of relationship */
141
- kind: EdgeKind
142
- /** Additional context about the relationship */
143
- metadata?: Record<string, unknown>
144
- /** Line number where relationship occurs (e.g., call site) */
145
- line?: number
146
- /** Column number where relationship occurs */
147
- column?: number
148
- /** How this edge was created */
149
- provenance?: 'tree-sitter' | 'scip' | 'heuristic'
150
- }
151
- /**
152
- * Metadata about a tracked file
153
- */
154
- export interface FileRecord {
155
- /** File path relative to project root */
156
- path: string
157
- /** Content hash for change detection */
158
- contentHash: string
159
- /** Detected language */
160
- language: Language
161
- /** File size in bytes */
162
- size: number
163
- /** Last modification timestamp */
164
- modifiedAt: number
165
- /** When last indexed */
166
- indexedAt: number
167
- /** Number of nodes extracted */
168
- nodeCount: number
169
- /** Any extraction errors */
170
- errors?: ExtractionError[]
171
- }
172
- /**
173
- * Result from parsing a source file
174
- */
175
- export interface ExtractionResult {
176
- /** Extracted nodes */
177
- nodes: Node[]
178
- /** Extracted edges */
179
- edges: Edge[]
180
- /** References that couldn't be resolved yet */
181
- unresolvedReferences: UnresolvedReference[]
182
- /** Any errors during extraction */
183
- errors: ExtractionError[]
184
- /** Extraction duration in milliseconds */
185
- durationMs: number
186
- }
187
- /**
188
- * Error during code extraction
189
- */
190
- export interface ExtractionError {
191
- /** Error message */
192
- message: string
193
- /** File path where the error occurred */
194
- filePath?: string
195
- /** Line number if available */
196
- line?: number
197
- /** Column number if available */
198
- column?: number
199
- /** Error severity */
200
- severity: 'error' | 'warning'
201
- /** Error code for categorization */
202
- code?: string
203
- }
204
- /**
205
- * A reference that couldn't be resolved during extraction
206
- */
207
- export interface UnresolvedReference {
208
- /** ID of the node containing the reference */
209
- fromNodeId: string
210
- /** Name being referenced */
211
- referenceName: string
212
- /** Type of reference (call, type, import, etc.) */
213
- referenceKind: EdgeKind
214
- /** Location of the reference */
215
- line: number
216
- column: number
217
- /** File path where reference occurs (denormalized for performance) */
218
- filePath?: string
219
- /** Language of the source file (denormalized for performance) */
220
- language?: Language
221
- /** Possible qualified names it might resolve to */
222
- candidates?: string[]
223
- }
224
- /**
225
- * A subgraph containing a subset of the knowledge graph
226
- */
227
- export interface Subgraph {
228
- /** Nodes in this subgraph */
229
- nodes: Map<string, Node>
230
- /** Edges in this subgraph */
231
- edges: Edge[]
232
- /** Root node IDs (entry points) */
233
- roots: string[]
234
- }
235
- /**
236
- * Options for graph traversal
237
- */
238
- export interface TraversalOptions {
239
- /** Maximum depth to traverse (default: Infinity) */
240
- maxDepth?: number
241
- /** Edge types to follow (default: all) */
242
- edgeKinds?: EdgeKind[]
243
- /** Node types to include (default: all) */
244
- nodeKinds?: NodeKind[]
245
- /** Direction of traversal */
246
- direction?: 'outgoing' | 'incoming' | 'both'
247
- /** Maximum nodes to return */
248
- limit?: number
249
- /** Whether to include the starting node */
250
- includeStart?: boolean
251
- }
252
- /**
253
- * Options for searching the graph
254
- */
255
- export interface SearchOptions {
256
- /** Node types to search */
257
- kinds?: NodeKind[]
258
- /** Languages to include */
259
- languages?: Language[]
260
- /** File path patterns to include */
261
- includePatterns?: string[]
262
- /** File path patterns to exclude */
263
- excludePatterns?: string[]
264
- /** Maximum results to return */
265
- limit?: number
266
- /** Offset for pagination */
267
- offset?: number
268
- /** Whether search is case-sensitive */
269
- caseSensitive?: boolean
270
- }
271
- /**
272
- * A search result with relevance scoring
273
- */
274
- export interface SearchResult {
275
- /** Matching node */
276
- node: Node
277
- /** Relevance score (0-1) */
278
- score: number
279
- /** Matched text snippets for highlighting */
280
- highlights?: string[]
281
- }
282
- /**
283
- * Context information for code understanding
284
- */
285
- export interface Context {
286
- /** Primary node being examined */
287
- focal: Node
288
- /** Nodes containing the focal node (file, class, etc.) */
289
- ancestors: Node[]
290
- /** Nodes directly contained by focal node */
291
- children: Node[]
292
- /** Incoming references (who calls/uses this) */
293
- incomingRefs: Array<{
294
- node: Node
295
- edge: Edge
296
- }>
297
- /** Outgoing references (what this calls/uses) */
298
- outgoingRefs: Array<{
299
- node: Node
300
- edge: Edge
301
- }>
302
- /** Related type information */
303
- types: Node[]
304
- /** Relevant imports */
305
- imports: Node[]
306
- }
307
- /**
308
- * A block of code with context
309
- */
310
- export interface CodeBlock {
311
- /** The code content */
312
- content: string
313
- /** File path */
314
- filePath: string
315
- /** Starting line */
316
- startLine: number
317
- /** Ending line */
318
- endLine: number
319
- /** Language for syntax highlighting */
320
- language: Language
321
- /** Associated node if extracted */
322
- node?: Node
323
- }
324
- /**
325
- * Database schema version info
326
- */
327
- export interface SchemaVersion {
328
- /** Current schema version */
329
- version: number
330
- /** When schema was created/updated */
331
- appliedAt: number
332
- /** Description of this version */
333
- description?: string
334
- }
335
- /**
336
- * Statistics about the knowledge graph
337
- */
338
- export interface GraphStats {
339
- /** Total number of nodes */
340
- nodeCount: number
341
- /** Total number of edges */
342
- edgeCount: number
343
- /** Number of tracked files */
344
- fileCount: number
345
- /** Node counts by kind */
346
- nodesByKind: Record<NodeKind, number>
347
- /** Edge counts by kind */
348
- edgesByKind: Record<EdgeKind, number>
349
- /** File counts by language */
350
- filesByLanguage: Record<Language, number>
351
- /** Database size in bytes */
352
- dbSizeBytes: number
353
- /** Last update timestamp */
354
- lastUpdated: number
355
- }
356
- /**
357
- * Input for building task context
358
- */
359
- export type TaskInput =
360
- | string
361
- | {
362
- title: string
363
- description?: string
364
- }
365
- /**
366
- * Options for building task context
367
- */
368
- export interface BuildContextOptions {
369
- /** Maximum number of nodes to include (default: 50) */
370
- maxNodes?: number
371
- /** Maximum number of code blocks to include (default: 10) */
372
- maxCodeBlocks?: number
373
- /** Maximum characters per code block (default: 2000) */
374
- maxCodeBlockSize?: number
375
- /** Whether to include code blocks (default: true) */
376
- includeCode?: boolean
377
- /** Output format (default: 'markdown') */
378
- format?: 'markdown' | 'json'
379
- /** Number of semantic search results (default: 5) */
380
- searchLimit?: number
381
- /** Graph traversal depth from entry points (default: 2) */
382
- traversalDepth?: number
383
- /** Minimum semantic similarity score (default: 0.3) */
384
- minScore?: number
385
- }
386
- /**
387
- * Full context for a task, ready for Claude
388
- */
389
- export interface TaskContext {
390
- /** The original query/task */
391
- query: string
392
- /** Subgraph of relevant nodes and edges */
393
- subgraph: Subgraph
394
- /** Entry point nodes (from semantic search) */
395
- entryPoints: Node[]
396
- /** Code blocks extracted from key nodes */
397
- codeBlocks: CodeBlock[]
398
- /** Files involved in this context */
399
- relatedFiles: string[]
400
- /** Brief summary of the context */
401
- summary: string
402
- /** Statistics about the context */
403
- stats: {
404
- /** Number of nodes included */
405
- nodeCount: number
406
- /** Number of edges included */
407
- edgeCount: number
408
- /** Number of files touched */
409
- fileCount: number
410
- /** Number of code blocks included */
411
- codeBlockCount: number
412
- /** Total characters in code blocks */
413
- totalCodeSize: number
414
- }
415
- }
416
- /**
417
- * Options for finding relevant context
418
- */
419
- export interface FindRelevantContextOptions {
420
- /** Number of semantic search results (default: 5) */
421
- searchLimit?: number
422
- /** Graph traversal depth (default: 2) */
423
- traversalDepth?: number
424
- /** Maximum nodes in result (default: 50) */
425
- maxNodes?: number
426
- /** Minimum semantic similarity score (default: 0.3) */
427
- minScore?: number
428
- /** Edge types to follow in traversal */
429
- edgeKinds?: EdgeKind[]
430
- /** Node types to include */
431
- nodeKinds?: NodeKind[]
432
- }
433
- //# sourceMappingURL=types.d.ts.map
package/dist/types.js DELETED
@@ -1,75 +0,0 @@
1
- "use strict";
2
- /**
3
- * CodeGraph Type Definitions
4
- *
5
- * Core types for the semantic knowledge graph system.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.LANGUAGES = exports.NODE_KINDS = void 0;
9
- // =============================================================================
10
- // Union Types
11
- // =============================================================================
12
- /**
13
- * Types of nodes in the knowledge graph.
14
- *
15
- * Defined as a runtime-iterable `as const` array so the same source
16
- * of truth backs both the TS type and any runtime validation
17
- * (e.g. the search query parser).
18
- */
19
- exports.NODE_KINDS = [
20
- 'file',
21
- 'module',
22
- 'class',
23
- 'struct',
24
- 'interface',
25
- 'trait',
26
- 'protocol',
27
- 'function',
28
- 'method',
29
- 'property',
30
- 'field',
31
- 'variable',
32
- 'constant',
33
- 'enum',
34
- 'enum_member',
35
- 'type_alias',
36
- 'namespace',
37
- 'parameter',
38
- 'import',
39
- 'export',
40
- 'route',
41
- 'component',
42
- ];
43
- /**
44
- * Supported programming languages. See NODE_KINDS for why this is a
45
- * runtime-iterable const array.
46
- */
47
- exports.LANGUAGES = [
48
- 'typescript',
49
- 'javascript',
50
- 'tsx',
51
- 'jsx',
52
- 'python',
53
- 'go',
54
- 'rust',
55
- 'java',
56
- 'c',
57
- 'cpp',
58
- 'csharp',
59
- 'php',
60
- 'ruby',
61
- 'swift',
62
- 'kotlin',
63
- 'dart',
64
- 'svelte',
65
- 'vue',
66
- 'liquid',
67
- 'pascal',
68
- 'scala',
69
- 'lua',
70
- 'luau',
71
- 'yaml',
72
- 'twig',
73
- 'unknown',
74
- ];
75
- //# sourceMappingURL=types.js.map