@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,225 +0,0 @@
1
- "use strict";
2
- /**
3
- * Cargo Workspace Resolver Helper
4
- *
5
- * Parses a project's root Cargo.toml and member crate manifests to
6
- * build a crate-name -> member-directory map. Used by the Rust
7
- * resolver to resolve `use crate_name::...` references that point
8
- * into workspace member crates.
9
- */
10
- var __importDefault = (this && this.__importDefault) || function (mod) {
11
- return (mod && mod.__esModule) ? mod : { "default": mod };
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.getCargoWorkspaceCrateMap = getCargoWorkspaceCrateMap;
15
- const picomatch_1 = __importDefault(require("picomatch"));
16
- const GLOB_CHARS = /[*?[\]{}!]/;
17
- const SKIP_DIRS = new Set(['target', 'node_modules', '.git', 'dist', 'build']);
18
- const MAX_GLOB_WALK_DEPTH = 5;
19
- function getSection(content, sectionName) {
20
- const lines = content.split('\n');
21
- let inSection = false;
22
- const sectionLines = [];
23
- for (const line of lines) {
24
- const trimmed = line.trim();
25
- if (!inSection) {
26
- if (trimmed === `[${sectionName}]`) {
27
- inSection = true;
28
- }
29
- continue;
30
- }
31
- if (/^\[[^\]]+\]$/.test(trimmed)) {
32
- break;
33
- }
34
- sectionLines.push(line);
35
- }
36
- if (!inSection)
37
- return null;
38
- return sectionLines.join('\n');
39
- }
40
- function extractQuotedValues(valueList) {
41
- const values = [];
42
- let quote = null;
43
- let escaped = false;
44
- let current = '';
45
- for (const ch of valueList) {
46
- if (!quote) {
47
- if (ch === '"' || ch === "'") {
48
- quote = ch;
49
- current = '';
50
- }
51
- continue;
52
- }
53
- if (escaped) {
54
- current += ch;
55
- escaped = false;
56
- continue;
57
- }
58
- if (ch === '\\') {
59
- escaped = true;
60
- continue;
61
- }
62
- if (ch === quote) {
63
- values.push(current.trim());
64
- quote = null;
65
- current = '';
66
- continue;
67
- }
68
- current += ch;
69
- }
70
- return values.filter(Boolean);
71
- }
72
- function escapeRegExp(value) {
73
- return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
74
- }
75
- function getArrayValue(section, key) {
76
- const keyRegex = new RegExp(`\\b${escapeRegExp(key)}\\b\\s*=`, 'm');
77
- const keyMatch = keyRegex.exec(section);
78
- if (!keyMatch)
79
- return null;
80
- let i = keyMatch.index + keyMatch[0].length;
81
- while (i < section.length && /\s/.test(section.charAt(i)))
82
- i++;
83
- if (section.charAt(i) !== '[')
84
- return null;
85
- i++;
86
- let inQuote = null;
87
- let escaped = false;
88
- let depth = 1;
89
- const start = i;
90
- while (i < section.length) {
91
- const ch = section.charAt(i);
92
- if (inQuote) {
93
- if (escaped) {
94
- escaped = false;
95
- }
96
- else if (ch === '\\') {
97
- escaped = true;
98
- }
99
- else if (ch === inQuote) {
100
- inQuote = null;
101
- }
102
- i++;
103
- continue;
104
- }
105
- if (ch === '"' || ch === "'") {
106
- inQuote = ch;
107
- i++;
108
- continue;
109
- }
110
- if (ch === '[') {
111
- depth++;
112
- i++;
113
- continue;
114
- }
115
- if (ch === ']') {
116
- depth--;
117
- if (depth === 0) {
118
- return section.slice(start, i);
119
- }
120
- i++;
121
- continue;
122
- }
123
- i++;
124
- }
125
- return null;
126
- }
127
- function parseWorkspaceMembers(cargoToml) {
128
- const workspaceSection = getSection(cargoToml, 'workspace');
129
- if (!workspaceSection)
130
- return [];
131
- const membersValue = getArrayValue(workspaceSection, 'members');
132
- if (!membersValue)
133
- return [];
134
- return extractQuotedValues(membersValue);
135
- }
136
- function parsePackageName(cargoToml) {
137
- const packageSection = getSection(cargoToml, 'package');
138
- if (!packageSection)
139
- return null;
140
- const packageNameMatch = packageSection.match(/name\s*=\s*["']([^"'\n]+)["']/);
141
- return packageNameMatch?.[1]?.trim() ?? null;
142
- }
143
- function addCrateAlias(map, crateName, memberPath) {
144
- const normalized = crateName.replace(/-/g, '_');
145
- map.set(crateName, memberPath);
146
- if (normalized !== crateName) {
147
- map.set(normalized, memberPath);
148
- }
149
- }
150
- function cleanPath(memberPath) {
151
- return memberPath.replace(/\\/g, '/').replace(/\/$/, '');
152
- }
153
- function expandGlobMember(member, context) {
154
- if (!context.listDirectories)
155
- return [];
156
- const firstGlobIdx = member.search(GLOB_CHARS);
157
- const staticPrefix = member
158
- .slice(0, firstGlobIdx)
159
- .replace(/[^/]*$/, '')
160
- .replace(/\/$/, '');
161
- const matcher = (0, picomatch_1.default)(member, { dot: false });
162
- const matches = [];
163
- const seen = new Set();
164
- function walk(dir, depth) {
165
- if (depth > MAX_GLOB_WALK_DEPTH)
166
- return;
167
- const children = context.listDirectories(dir);
168
- for (const child of children) {
169
- if (SKIP_DIRS.has(child) || child.startsWith('.'))
170
- continue;
171
- const rel = dir === '.' ? child : `${dir}/${child}`;
172
- if (matcher(rel) && !seen.has(rel)) {
173
- seen.add(rel);
174
- matches.push(rel);
175
- }
176
- walk(rel, depth + 1);
177
- }
178
- }
179
- walk(staticPrefix || '.', 0);
180
- return matches;
181
- }
182
- function expandMembers(members, context) {
183
- const expanded = [];
184
- const seen = new Set();
185
- for (const member of members) {
186
- const candidates = GLOB_CHARS.test(member)
187
- ? expandGlobMember(member, context)
188
- : [member];
189
- for (const candidate of candidates) {
190
- const cleaned = cleanPath(candidate);
191
- if (seen.has(cleaned))
192
- continue;
193
- seen.add(cleaned);
194
- expanded.push(cleaned);
195
- }
196
- }
197
- return expanded;
198
- }
199
- /**
200
- * Build a map from crate-name aliases to workspace member directory paths.
201
- * Example: "mytool-core" and "mytool_core" -> "crates/mytool-core"
202
- *
203
- * Supports glob members (e.g. `members = ["crates/*"]`) via picomatch
204
- * when the context exposes `listDirectories`.
205
- */
206
- function getCargoWorkspaceCrateMap(context) {
207
- const result = new Map();
208
- const rootCargoToml = context.readFile('Cargo.toml');
209
- if (!rootCargoToml)
210
- return result;
211
- const rawMembers = parseWorkspaceMembers(rootCargoToml);
212
- const members = expandMembers(rawMembers, context);
213
- for (const memberPath of members) {
214
- const memberCargoPath = `${memberPath}/Cargo.toml`;
215
- const memberCargoToml = context.readFile(memberCargoPath);
216
- if (!memberCargoToml)
217
- continue;
218
- const packageName = parsePackageName(memberCargoToml);
219
- if (!packageName)
220
- continue;
221
- addCrateAlias(result, packageName, memberPath);
222
- }
223
- return result;
224
- }
225
- //# sourceMappingURL=cargo-workspace.js.map
@@ -1,8 +0,0 @@
1
- /**
2
- * C# Framework Resolver
3
- *
4
- * Handles ASP.NET Core, ASP.NET MVC, and common C# patterns.
5
- */
6
- import { FrameworkResolver } from '../types'
7
- export declare const aspnetResolver: FrameworkResolver
8
- //# sourceMappingURL=csharp.d.ts.map
@@ -1,213 +0,0 @@
1
- "use strict";
2
- /**
3
- * C# Framework Resolver
4
- *
5
- * Handles ASP.NET Core, ASP.NET MVC, and common C# patterns.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.aspnetResolver = void 0;
9
- const strip_comments_1 = require("../strip-comments");
10
- exports.aspnetResolver = {
11
- name: 'aspnet',
12
- languages: ['csharp'],
13
- detect(context) {
14
- // Check for .csproj files with ASP.NET references
15
- const allFiles = context.getAllFiles();
16
- for (const file of allFiles) {
17
- if (file.endsWith('.csproj')) {
18
- const content = context.readFile(file);
19
- if (content && (content.includes('Microsoft.AspNetCore') ||
20
- content.includes('Microsoft.NET.Sdk.Web') ||
21
- content.includes('System.Web.Mvc'))) {
22
- return true;
23
- }
24
- }
25
- }
26
- // Check for Program.cs with WebApplication
27
- const programCs = context.readFile('Program.cs');
28
- if (programCs && (programCs.includes('WebApplication') ||
29
- programCs.includes('CreateHostBuilder') ||
30
- programCs.includes('UseStartup'))) {
31
- return true;
32
- }
33
- // Check for Startup.cs (ASP.NET Core signature)
34
- if (context.fileExists('Startup.cs')) {
35
- return true;
36
- }
37
- // Check for Controllers directory
38
- return allFiles.some((f) => f.includes('/Controllers/') && f.endsWith('Controller.cs'));
39
- },
40
- resolve(ref, context) {
41
- // Pattern 1: Controller references
42
- if (ref.referenceName.endsWith('Controller')) {
43
- const result = resolveByNameAndKind(ref.referenceName, CLASS_KINDS, CONTROLLER_DIRS, context);
44
- if (result) {
45
- return {
46
- original: ref,
47
- targetNodeId: result,
48
- confidence: 0.85,
49
- resolvedBy: 'framework',
50
- };
51
- }
52
- }
53
- // Pattern 2: Service references (dependency injection)
54
- if (ref.referenceName.endsWith('Service') || ref.referenceName.startsWith('I') && ref.referenceName.length > 1) {
55
- const result = resolveByNameAndKind(ref.referenceName, SERVICE_KINDS, SERVICE_DIRS, context);
56
- if (result) {
57
- return {
58
- original: ref,
59
- targetNodeId: result,
60
- confidence: 0.85,
61
- resolvedBy: 'framework',
62
- };
63
- }
64
- }
65
- // Pattern 3: Repository references
66
- if (ref.referenceName.endsWith('Repository')) {
67
- const result = resolveByNameAndKind(ref.referenceName, SERVICE_KINDS, REPO_DIRS, context);
68
- if (result) {
69
- return {
70
- original: ref,
71
- targetNodeId: result,
72
- confidence: 0.85,
73
- resolvedBy: 'framework',
74
- };
75
- }
76
- }
77
- // Pattern 4: Model/Entity references
78
- if (/^[A-Z][a-zA-Z]+$/.test(ref.referenceName)) {
79
- const result = resolveByNameAndKind(ref.referenceName, CLASS_KINDS, MODEL_DIRS, context);
80
- if (result) {
81
- return {
82
- original: ref,
83
- targetNodeId: result,
84
- confidence: 0.7,
85
- resolvedBy: 'framework',
86
- };
87
- }
88
- }
89
- // Pattern 5: ViewModel references
90
- if (ref.referenceName.endsWith('ViewModel') || ref.referenceName.endsWith('Dto')) {
91
- const result = resolveByNameAndKind(ref.referenceName, CLASS_KINDS, VIEWMODEL_DIRS, context);
92
- if (result) {
93
- return {
94
- original: ref,
95
- targetNodeId: result,
96
- confidence: 0.8,
97
- resolvedBy: 'framework',
98
- };
99
- }
100
- }
101
- return null;
102
- },
103
- extract(filePath, content) {
104
- if (!filePath.endsWith('.cs'))
105
- return { nodes: [], references: [] };
106
- const nodes = [];
107
- const references = [];
108
- const now = Date.now();
109
- const safe = (0, strip_comments_1.stripCommentsForRegex)(content, 'csharp');
110
- // [HttpGet("path")], [HttpPost("path")], etc.
111
- const attrRegex = /\[(HttpGet|HttpPost|HttpPut|HttpPatch|HttpDelete)\s*\(\s*"([^"]+)"\s*\)\]/g;
112
- let match;
113
- while ((match = attrRegex.exec(safe)) !== null) {
114
- const [, verb, routePath] = match;
115
- const method = verb.replace(/^Http/, '').toUpperCase();
116
- const line = safe.slice(0, match.index).split('\n').length;
117
- const routeNode = {
118
- id: `route:${filePath}:${line}:${method}:${routePath}`,
119
- kind: 'route',
120
- name: `${method} ${routePath}`,
121
- qualifiedName: `${filePath}::route:${routePath}`,
122
- filePath,
123
- startLine: line,
124
- endLine: line,
125
- startColumn: 0,
126
- endColumn: match[0].length,
127
- language: 'csharp',
128
- updatedAt: now,
129
- };
130
- nodes.push(routeNode);
131
- // Capture the next method declaration
132
- const tail = safe.slice(match.index + match[0].length);
133
- const methodMatch = tail.match(/(?:public|private|protected|internal)\s+[\w<>,\s\[\]]+?\s+(\w+)\s*\(/);
134
- if (methodMatch) {
135
- references.push({
136
- fromNodeId: routeNode.id,
137
- referenceName: methodMatch[1],
138
- referenceKind: 'references',
139
- line,
140
- column: 0,
141
- filePath,
142
- language: 'csharp',
143
- });
144
- }
145
- }
146
- // Minimal APIs: app.MapGet("/path", handler)
147
- const minimalRegex = /\.Map(Get|Post|Put|Patch|Delete)\s*\(\s*"([^"]+)"\s*,\s*([^,)]+)/g;
148
- while ((match = minimalRegex.exec(safe)) !== null) {
149
- const [, verb, routePath, handlerExpr] = match;
150
- const method = verb.toUpperCase();
151
- const line = safe.slice(0, match.index).split('\n').length;
152
- const routeNode = {
153
- id: `route:${filePath}:${line}:${method}:${routePath}`,
154
- kind: 'route',
155
- name: `${method} ${routePath}`,
156
- qualifiedName: `${filePath}::route:${routePath}`,
157
- filePath,
158
- startLine: line,
159
- endLine: line,
160
- startColumn: 0,
161
- endColumn: match[0].length,
162
- language: 'csharp',
163
- updatedAt: now,
164
- };
165
- nodes.push(routeNode);
166
- const handlerName = extractCSharpTailIdent(handlerExpr);
167
- if (handlerName) {
168
- references.push({
169
- fromNodeId: routeNode.id,
170
- referenceName: handlerName,
171
- referenceKind: 'references',
172
- line,
173
- column: 0,
174
- filePath,
175
- language: 'csharp',
176
- });
177
- }
178
- }
179
- return { nodes, references };
180
- },
181
- };
182
- /** Extract last identifier from an expression like `MyService.Handler` or `Handler`. */
183
- function extractCSharpTailIdent(expr) {
184
- const cleaned = expr.trim().replace(/\s+/g, '');
185
- const m = cleaned.match(/(?:\.|^)([A-Za-z_][A-Za-z0-9_]*)$/);
186
- return m ? m[1] : null;
187
- }
188
- // Directory patterns
189
- const CONTROLLER_DIRS = ['/Controllers/'];
190
- const SERVICE_DIRS = ['/Services/', '/Service/', '/Application/'];
191
- const REPO_DIRS = ['/Repositories/', '/Repository/', '/Data/', '/Infrastructure/'];
192
- const MODEL_DIRS = ['/Models/', '/Model/', '/Entities/', '/Entity/', '/Domain/'];
193
- const VIEWMODEL_DIRS = ['/ViewModels/', '/ViewModel/', '/DTOs/', '/Dto/'];
194
- const CLASS_KINDS = new Set(['class']);
195
- const SERVICE_KINDS = new Set(['class', 'interface']);
196
- /**
197
- * Resolve a symbol by name using indexed queries instead of scanning all files.
198
- */
199
- function resolveByNameAndKind(name, kinds, preferredDirPatterns, context) {
200
- const candidates = context.getNodesByName(name);
201
- if (candidates.length === 0)
202
- return null;
203
- const kindFiltered = candidates.filter((n) => kinds.has(n.kind));
204
- if (kindFiltered.length === 0)
205
- return null;
206
- // Prefer candidates in framework-conventional directories
207
- const preferred = kindFiltered.filter((n) => preferredDirPatterns.some((d) => n.filePath.includes(d)));
208
- if (preferred.length > 0)
209
- return preferred[0].id;
210
- // Fall back to any match
211
- return kindFiltered[0].id;
212
- }
213
- //# sourceMappingURL=csharp.js.map
@@ -1,51 +0,0 @@
1
- /**
2
- * Drupal Framework Resolver
3
- *
4
- * Supports Drupal 8/9/10/11 (Composer-based projects). Drupal 7 is not supported.
5
- *
6
- * ## What this resolver does
7
- *
8
- * 1. **Detection** — reads composer.json and checks for any `drupal/*` dependency in
9
- * `require` or `require-dev`.
10
- *
11
- * 2. **Route extraction** — parses `*.routing.yml` files and emits `route` nodes for each
12
- * Drupal route, with `references` edges to the `_controller`, `_form`, or entity handler
13
- * class/method.
14
- *
15
- * 3. **Hook detection** — scans `.module`, `.install`, `.theme`, and `.inc` files for Drupal
16
- * hook implementations. Two strategies are used:
17
- * a. Docblock: `@Implements hook_X()` → precise, no false positives.
18
- * b. Name pattern: function `{moduleName}_{hookSuffix}()` → catches hooks without
19
- * docblocks but may produce false positives on helper functions.
20
- * Detected hooks emit an `UnresolvedRef` from the implementing function node to the
21
- * canonical `hook_X` name, linking implementations to the hook when `codegraph_callers`
22
- * is invoked.
23
- *
24
- * ## Design decisions (review in future iterations)
25
- *
26
- * - Hook graph resolution (v1): hook references are stored as UnresolvedRef pointing to the
27
- * canonical `hook_X` name. If Drupal core is indexed, these will resolve to core hook
28
- * definitions. Without core, they remain unresolved but are still searchable via
29
- * `codegraph_search("form_alter")`. Full hook-node creation (virtual nodes for every hook)
30
- * is deferred to a future iteration.
31
- *
32
- * - Services / plugins (out of scope for v1): `*.services.yml` service definitions and plugin
33
- * annotations (`@Block`, `@FormElement`, etc.) are not extracted. Add a TODO below when
34
- * ready to implement.
35
- *
36
- * - Twig templates (out of scope for v1): `.twig` files are tracked as file nodes but no
37
- * symbol extraction is performed (no tree-sitter Twig grammar). Implement when a Twig
38
- * grammar WASM is available.
39
- *
40
- * ## TODOs for future iterations
41
- *
42
- * - TODO: Extract service definitions from `*.services.yml` files (class → service-id edges).
43
- * - TODO: Extract plugin annotations (`@Block`, `@FormElement`, `@Field`, etc.) from PHP
44
- * docblocks and emit plugin nodes with references to the annotated class.
45
- * - TODO: Add Twig symbol extraction when a tree-sitter Twig grammar becomes available.
46
- * - TODO: Improve hook resolution: create virtual `hook_*` nodes so `codegraph_callers`
47
- * returns all implementations even when Drupal core is not indexed.
48
- */
49
- import { FrameworkResolver } from '../types'
50
- export declare const drupalResolver: FrameworkResolver
51
- //# sourceMappingURL=drupal.d.ts.map