waymark-engine 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 (42) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +96 -0
  3. package/bin/waymark-ask.mjs +4 -0
  4. package/bin/waymark-chart.mjs +4 -0
  5. package/bin/waymark-discover.mjs +4 -0
  6. package/dist/src/astExtractor.d.ts +45 -0
  7. package/dist/src/astExtractor.js +388 -0
  8. package/dist/src/astExtractor.js.map +1 -0
  9. package/dist/src/capnAdapter.d.ts +16 -0
  10. package/dist/src/capnAdapter.js +149 -0
  11. package/dist/src/capnAdapter.js.map +1 -0
  12. package/dist/src/cli.d.ts +7 -0
  13. package/dist/src/cli.js +149 -0
  14. package/dist/src/cli.js.map +1 -0
  15. package/dist/src/discoveryRouter.d.ts +13 -0
  16. package/dist/src/discoveryRouter.js +137 -0
  17. package/dist/src/discoveryRouter.js.map +1 -0
  18. package/dist/src/index.d.ts +6 -0
  19. package/dist/src/index.js +9 -0
  20. package/dist/src/index.js.map +1 -0
  21. package/dist/src/integrity.d.ts +10 -0
  22. package/dist/src/integrity.js +93 -0
  23. package/dist/src/integrity.js.map +1 -0
  24. package/dist/src/mcp/capnIndex.d.ts +2 -0
  25. package/dist/src/mcp/capnIndex.js +15 -0
  26. package/dist/src/mcp/capnIndex.js.map +1 -0
  27. package/dist/src/mcp/capnTools.d.ts +5 -0
  28. package/dist/src/mcp/capnTools.js +190 -0
  29. package/dist/src/mcp/capnTools.js.map +1 -0
  30. package/dist/src/mcp/server.d.ts +22 -0
  31. package/dist/src/mcp/server.js +241 -0
  32. package/dist/src/mcp/server.js.map +1 -0
  33. package/dist/src/mcp/types.d.ts +80 -0
  34. package/dist/src/mcp/types.js +2 -0
  35. package/dist/src/mcp/types.js.map +1 -0
  36. package/dist/src/paths.d.ts +39 -0
  37. package/dist/src/paths.js +134 -0
  38. package/dist/src/paths.js.map +1 -0
  39. package/dist/src/types.d.ts +44 -0
  40. package/dist/src/types.js +11 -0
  41. package/dist/src/types.js.map +1 -0
  42. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Waymark contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Waymark Discovery Engine
2
+
3
+ A single-process, zero-daemon discovery engine that answers one-shot code questions
4
+ through a **two-phase router** — no plugin choice, no index to build, no embeddings:
5
+
6
+ | Phase | Engine | Answers | Properties |
7
+ | :--- | :--- | :--- | :--- |
8
+ | **Symbolic** | In-process Tree-sitter WASM AST (30+ grammars) | *Who calls `verifySignature`? Where is it declared? What are the entrypoints?* | 100% precision, millisecond-range parses, exact 1-indexed line spans |
9
+ | **Semantic** | Capn charted memory (SQLite FTS5 lexical recall, no embedding model) | *How does authentication work here?* | Charted answers with backing file references |
10
+
11
+ The router decides intent from the question: structural queries (`who calls`, `entrypoints`,
12
+ `trace X`) go to the AST; conceptual questions go to charted memory; **misses fall through
13
+ cleanly instead of hallucinating**.
14
+
15
+ ## Why this exists
16
+
17
+ The engine is the extracted discovery half of the original Waymark project (the in-flight
18
+ continuity ledger was removed). Its design goal: an agent should never pay 10,000–50,000
19
+ tokens of blind re-reading when a sub-second in-process scan answers the question with
20
+ exact file, symbol, and line spans — and it should say "miss" rather than guess.
21
+
22
+ Also retained standalone from the continuity layer, because it is the cheapest
23
+ tamper-evidence primitive for later integration:
24
+
25
+ - `src/integrity.ts` — `verifyHop(root, hop, maxWindows)`: hash-pinned span verification
26
+ (FRESH / MOVED / STALE) with bounded relocation windows.
27
+ - `src/paths.ts` — `anchorForRange(root, path, range)`: full-file hash + normalized span
28
+ hash + structural signature. Pin "this span said X" to a later integrity check.
29
+
30
+ ## Quick start
31
+
32
+ Requires Node.js 22+. No build steps beyond `npm ci && npm run build`.
33
+
34
+ ### CLI
35
+
36
+ ```bash
37
+ # One-shot symbol discovery (repository-relative file)
38
+ node dist/src/cli.js discover-symbols --path src/example.ts [--language typescript|python]
39
+
40
+ # Two-phase question router
41
+ node dist/src/cli.js ask "Who calls capnChartArgs?"
42
+ node dist/src/cli.js ask "Where is function publish declared?"
43
+ node dist/src/cli.js ask --profile none "anything" # deterministic miss (no external calls)
44
+
45
+ # Chart an answer into Capn memory (profile none = no-op)
46
+ node dist/src/cli.js chart --question "<q>" --answer "<a>" --files "a.ts,b.ts"
47
+ ```
48
+
49
+ Env: `WAYMARK_CAPN_PROFILE` (`capn-cli` | `none`, default `capn-cli`),
50
+ `WAYMARK_CAPN_EXECUTABLE` (default `capn`). The library and CLI work with or without a
51
+ Git repository — `repoRoot()` resolves `git rev-parse --show-toplevel` and falls back to
52
+ the process cwd.
53
+
54
+ ### MCP (stdio)
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "waymark": {
60
+ "command": "node",
61
+ "args": ["<path-to-waymark>/dist/src/mcp/capnIndex.js"]
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ Exposed tools: `capn_ask`, `capn_chart`, `waymark_discover_symbols`.
68
+ Resource: `capn://status`.
69
+
70
+ ### Library
71
+
72
+ ```ts
73
+ import { detectAstIntent, queryWasmAst } from "./src/discoveryRouter.js";
74
+ import { ask } from "./src/capnAdapter.js";
75
+ import { discoverSymbolsInFile } from "./src/astExtractor.js";
76
+ import { anchorForRange } from "./src/paths.js";
77
+ import { verifyHop } from "./src/integrity.js";
78
+ ```
79
+
80
+ ## Build & verify
81
+
82
+ ```bash
83
+ npm ci
84
+ npm run verify # tsc build + node --test dist/test/**/*.test.js
85
+ ```
86
+
87
+ ## Operating posture
88
+
89
+ - **Zero runtime dependencies, zero daemons.** AST runs in-process (pure WASM); Capn is
90
+ an external CLI invoked per call (lexical FTS5 recall, `capn init --no-embedding`
91
+ recommended: deterministic, no embedding model, no GPU).
92
+ - **Fail closed on integrity, fail open on infrastructure.** `verifyHop` quarantines
93
+ (STALE) spans it cannot prove; a missing Capn chart returns a clean `miss` rather than
94
+ a guess.
95
+ - **Real-adapter testing.** The suite exercises the actual capn-hook CLI surface, not a
96
+ protocol fake.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // waymark-ask: one-shot two-phase question router (AST first, Capn fallback).
3
+ import { runCli } from "../dist/src/cli.js";
4
+ await runCli("ask", process.argv.slice(2));
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // waymark-chart: chart a question + answer (+ optional files) into Capn memory.
3
+ import { runCli } from "../dist/src/cli.js";
4
+ await runCli("chart", process.argv.slice(2));
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ // waymark-discover: one-shot symbolic symbol discovery for one repository-relative file.
3
+ import { runCli } from "../dist/src/cli.js";
4
+ await runCli("discover-symbols", process.argv.slice(2));
@@ -0,0 +1,45 @@
1
+ export interface SymbolDefinition {
2
+ name: string;
3
+ qualifiedName: string;
4
+ kind: "Class" | "Method" | "Function" | "Interface" | "Type";
5
+ file: string;
6
+ startLine: number;
7
+ endLine: number;
8
+ }
9
+ export interface CallRelationship {
10
+ caller: string;
11
+ callee: string;
12
+ file: string;
13
+ line: number;
14
+ }
15
+ export interface AstExtractionResult {
16
+ symbols: SymbolDefinition[];
17
+ calls: CallRelationship[];
18
+ callersMap: Map<string, string[]>;
19
+ calleesMap: Map<string, string[]>;
20
+ filesParsed: number;
21
+ parseDurationMs: number;
22
+ }
23
+ export type StructuredLanguage = "typescript" | "python";
24
+ export type StructuredSymbolKind = "class" | "function" | "method" | "interface" | "type";
25
+ export interface StructuredSymbolPosition {
26
+ line: number;
27
+ column: number;
28
+ }
29
+ export interface StructuredSymbol {
30
+ name: string;
31
+ kind: StructuredSymbolKind;
32
+ start: StructuredSymbolPosition;
33
+ end: StructuredSymbolPosition;
34
+ }
35
+ export interface SymbolDiscoveryResult {
36
+ ok: true;
37
+ path: string;
38
+ language: StructuredLanguage;
39
+ symbols: StructuredSymbol[];
40
+ }
41
+ export declare const MAX_SYMBOL_DISCOVERY_FILE_BYTES: number;
42
+ export declare function initParser(): Promise<void>;
43
+ export declare function getLanguageForExtension(ext: string, customDir?: string): Promise<unknown>;
44
+ export declare function discoverSymbolsInFile(repoRoot: string, rawPath: string, requestedLanguage?: string): Promise<SymbolDiscoveryResult>;
45
+ export declare function extractAstFromRepo(repoRoot: string, includeDirs?: string[]): Promise<AstExtractionResult>;
@@ -0,0 +1,388 @@
1
+ import Parser from "web-tree-sitter";
2
+ import path from "node:path";
3
+ import fs from "node:fs";
4
+ import { createRequire } from "node:module";
5
+ import { normalizeRelativePath, readFileText } from "./paths.js";
6
+ import { WaymarkError } from "./types.js";
7
+ const require = createRequire(import.meta.url);
8
+ export const MAX_SYMBOL_DISCOVERY_FILE_BYTES = 1024 * 1024;
9
+ const EXT_TO_WASM = {
10
+ // TypeScript & JavaScript
11
+ ".ts": "tree-sitter-typescript.wasm",
12
+ ".tsx": "tree-sitter-tsx.wasm",
13
+ ".js": "tree-sitter-javascript.wasm",
14
+ ".mjs": "tree-sitter-javascript.wasm",
15
+ ".cjs": "tree-sitter-javascript.wasm",
16
+ ".jsx": "tree-sitter-javascript.wasm",
17
+ // Python
18
+ ".py": "tree-sitter-python.wasm",
19
+ // Go
20
+ ".go": "tree-sitter-go.wasm",
21
+ // Rust
22
+ ".rs": "tree-sitter-rust.wasm",
23
+ // Java & JVM
24
+ ".java": "tree-sitter-java.wasm",
25
+ ".kt": "tree-sitter-kotlin.wasm",
26
+ ".kts": "tree-sitter-kotlin.wasm",
27
+ ".scala": "tree-sitter-scala.wasm",
28
+ // C, C++, Objective-C
29
+ ".c": "tree-sitter-c.wasm",
30
+ ".h": "tree-sitter-c.wasm",
31
+ ".cpp": "tree-sitter-cpp.wasm",
32
+ ".hpp": "tree-sitter-cpp.wasm",
33
+ ".cc": "tree-sitter-cpp.wasm",
34
+ ".cxx": "tree-sitter-cpp.wasm",
35
+ ".m": "tree-sitter-objc.wasm",
36
+ // C#
37
+ ".cs": "tree-sitter-c_sharp.wasm",
38
+ // Ruby & PHP
39
+ ".rb": "tree-sitter-ruby.wasm",
40
+ ".php": "tree-sitter-php.wasm",
41
+ // Swift
42
+ ".swift": "tree-sitter-swift.wasm",
43
+ // Shell scripts
44
+ ".sh": "tree-sitter-bash.wasm",
45
+ ".bash": "tree-sitter-bash.wasm",
46
+ // Lua
47
+ ".lua": "tree-sitter-lua.wasm",
48
+ // Systems / Functional / Smart Contracts
49
+ ".zig": "tree-sitter-zig.wasm",
50
+ ".dart": "tree-sitter-dart.wasm",
51
+ ".el": "tree-sitter-elisp.wasm",
52
+ ".ex": "tree-sitter-elixir.wasm",
53
+ ".exs": "tree-sitter-elixir.wasm",
54
+ ".elm": "tree-sitter-elm.wasm",
55
+ ".ml": "tree-sitter-ocaml.wasm",
56
+ ".mli": "tree-sitter-ocaml.wasm",
57
+ ".res": "tree-sitter-rescript.wasm",
58
+ ".sol": "tree-sitter-solidity.wasm",
59
+ };
60
+ const STRUCTURED_EXTENSIONS = {
61
+ ".ts": "typescript",
62
+ ".tsx": "typescript",
63
+ ".py": "python",
64
+ };
65
+ const STRUCTURED_LANGUAGE_WASM = {
66
+ typescript: "tree-sitter-typescript.wasm",
67
+ python: "tree-sitter-python.wasm",
68
+ };
69
+ let parserInitialized = false;
70
+ const loadedLanguages = new Map();
71
+ export async function initParser() {
72
+ if (!parserInitialized) {
73
+ await Parser.init();
74
+ parserInitialized = true;
75
+ }
76
+ }
77
+ function resolveWasmPath(wasmName, customDir) {
78
+ if (customDir) {
79
+ const candidate = path.join(customDir, wasmName);
80
+ if (fs.existsSync(candidate))
81
+ return candidate;
82
+ }
83
+ try {
84
+ const pkgPath = require.resolve("tree-sitter-wasms/package.json");
85
+ const outDir = path.join(path.dirname(pkgPath), "out");
86
+ const candidate = path.join(outDir, wasmName);
87
+ if (fs.existsSync(candidate))
88
+ return candidate;
89
+ }
90
+ catch {
91
+ // fallback to relative search
92
+ }
93
+ const fallback = path.resolve(process.cwd(), "node_modules", "tree-sitter-wasms", "out", wasmName);
94
+ if (fs.existsSync(fallback))
95
+ return fallback;
96
+ return null;
97
+ }
98
+ async function getLanguageForWasm(wasmName, customDir) {
99
+ await initParser();
100
+ if (loadedLanguages.has(wasmName)) {
101
+ return loadedLanguages.get(wasmName);
102
+ }
103
+ const wasmPath = resolveWasmPath(wasmName, customDir);
104
+ if (!wasmPath)
105
+ return null;
106
+ const Lang = await Parser.Language.load(wasmPath);
107
+ loadedLanguages.set(wasmName, Lang);
108
+ return Lang;
109
+ }
110
+ export async function getLanguageForExtension(ext, customDir) {
111
+ const wasmName = EXT_TO_WASM[ext.toLowerCase()];
112
+ if (!wasmName)
113
+ return null;
114
+ return getLanguageForWasm(wasmName, customDir);
115
+ }
116
+ function resolveStructuredLanguage(storedPath, requestedLanguage) {
117
+ const detected = STRUCTURED_EXTENSIONS[path.extname(storedPath).toLowerCase()];
118
+ const requested = requestedLanguage?.trim().toLowerCase();
119
+ if (requested && !STRUCTURED_LANGUAGE_WASM[requested]) {
120
+ throw new WaymarkError("UNSUPPORTED_LANGUAGE", `Unsupported discovery language: ${requested}`, 2);
121
+ }
122
+ if (requested && detected && requested !== detected) {
123
+ throw new WaymarkError("LANGUAGE_EXTENSION_MISMATCH", `Language ${requested} does not match ${path.extname(storedPath)}`, 2);
124
+ }
125
+ if (requested)
126
+ return requested;
127
+ if (detected)
128
+ return detected;
129
+ throw new WaymarkError("UNSUPPORTED_LANGUAGE", `Cannot detect a supported discovery language for ${storedPath}`, 2);
130
+ }
131
+ function structuredSymbol(node, kind, name) {
132
+ return {
133
+ name,
134
+ kind,
135
+ // Tree-sitter columns are zero-based UTF-8 byte offsets; end is exclusive.
136
+ start: { line: node.startPosition.row + 1, column: node.startPosition.column },
137
+ end: { line: node.endPosition.row + 1, column: node.endPosition.column },
138
+ };
139
+ }
140
+ function collectStructuredSymbols(rootNode) {
141
+ const symbols = [];
142
+ function walk(node, currentClass = null) {
143
+ let nextClass = currentClass;
144
+ if (node.type === "class_declaration" || node.type === "class_definition") {
145
+ const name = node.childForFieldName("name")?.text;
146
+ if (name) {
147
+ symbols.push(structuredSymbol(node, "class", name));
148
+ nextClass = name;
149
+ }
150
+ }
151
+ else if (node.type === "interface_declaration") {
152
+ const name = node.childForFieldName("name")?.text;
153
+ if (name)
154
+ symbols.push(structuredSymbol(node, "interface", name));
155
+ }
156
+ else if (node.type === "type_alias_declaration") {
157
+ const name = node.childForFieldName("name")?.text;
158
+ if (name)
159
+ symbols.push(structuredSymbol(node, "type", name));
160
+ }
161
+ else if (node.type === "method_definition") {
162
+ const name = node.childForFieldName("name")?.text;
163
+ if (name)
164
+ symbols.push(structuredSymbol(node, "method", name));
165
+ }
166
+ else if (node.type === "function_declaration" || node.type === "function_definition") {
167
+ const name = node.childForFieldName("name")?.text;
168
+ if (name)
169
+ symbols.push(structuredSymbol(node, currentClass ? "method" : "function", name));
170
+ }
171
+ else if (node.type === "variable_declarator") {
172
+ const name = node.childForFieldName("name")?.text;
173
+ const value = node.childForFieldName("value");
174
+ if (name && value && ["arrow_function", "function_expression", "function"].includes(value.type)) {
175
+ symbols.push(structuredSymbol(node, currentClass ? "method" : "function", name));
176
+ }
177
+ }
178
+ for (const child of node.children)
179
+ walk(child, nextClass);
180
+ }
181
+ walk(rootNode);
182
+ return symbols;
183
+ }
184
+ export async function discoverSymbolsInFile(repoRoot, rawPath, requestedLanguage) {
185
+ const storedPath = normalizeRelativePath(rawPath);
186
+ const language = resolveStructuredLanguage(storedPath, requestedLanguage);
187
+ const file = readFileText(repoRoot, storedPath);
188
+ if (file.bytes.byteLength > MAX_SYMBOL_DISCOVERY_FILE_BYTES) {
189
+ throw new WaymarkError("FILE_TOO_LARGE", `Discovery only accepts files up to ${MAX_SYMBOL_DISCOVERY_FILE_BYTES} bytes`, 2);
190
+ }
191
+ let grammar;
192
+ try {
193
+ grammar = await getLanguageForWasm(STRUCTURED_LANGUAGE_WASM[language]);
194
+ }
195
+ catch {
196
+ throw new WaymarkError("PARSER_UNAVAILABLE", `Waymark grammar is unavailable for ${language}`, 2);
197
+ }
198
+ if (!grammar)
199
+ throw new WaymarkError("PARSER_UNAVAILABLE", `Waymark grammar is unavailable for ${language}`, 2);
200
+ const parser = new Parser();
201
+ let tree;
202
+ try {
203
+ parser.setLanguage(grammar);
204
+ tree = parser.parse(file.text);
205
+ }
206
+ catch {
207
+ throw new WaymarkError("PARSE_ERROR", `Unable to parse ${language} source: ${storedPath}`, 2);
208
+ }
209
+ if (tree.rootNode.hasError) {
210
+ throw new WaymarkError("PARSE_ERROR", `Malformed ${language} source: ${storedPath}`, 2);
211
+ }
212
+ return {
213
+ ok: true,
214
+ path: storedPath,
215
+ language,
216
+ symbols: collectStructuredSymbols(tree.rootNode),
217
+ };
218
+ }
219
+ export async function extractAstFromRepo(repoRoot, includeDirs = ["src"]) {
220
+ const t0 = performance.now();
221
+ await initParser();
222
+ const parser = new Parser();
223
+ const symbols = [];
224
+ const calls = [];
225
+ const callersMap = new Map();
226
+ const calleesMap = new Map();
227
+ let filesParsed = 0;
228
+ function scanDir(dir) {
229
+ const results = [];
230
+ if (!fs.existsSync(dir))
231
+ return results;
232
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
233
+ for (const ent of entries) {
234
+ const full = path.join(dir, ent.name);
235
+ if (ent.isDirectory()) {
236
+ if (ent.name !== "node_modules" && ent.name !== ".git" && ent.name !== "dist" && ent.name !== ".capn" && ent.name !== ".waymark") {
237
+ results.push(...scanDir(full));
238
+ }
239
+ }
240
+ else if (ent.isFile()) {
241
+ const ext = path.extname(ent.name);
242
+ if (EXT_TO_WASM[ext]) {
243
+ results.push(full);
244
+ }
245
+ }
246
+ }
247
+ return results;
248
+ }
249
+ const allFiles = [];
250
+ for (const d of includeDirs) {
251
+ allFiles.push(...scanDir(path.join(repoRoot, d)));
252
+ }
253
+ // Load every needed grammar BEFORE parsing. web-tree-sitter compiles a grammar's
254
+ // wasm lazily per Language.load; loading a grammar while parsed trees from another
255
+ // language sit on the heap is pathologically slow on some hosts (observed 3-20s for
256
+ // the python grammar after a single TypeScript parse, vs 5-25ms cold). Concurrent
257
+ // upfront loads cost ~20-50ms total and keep every subsequent parse in the
258
+ // millisecond range regardless of host.
259
+ const neededExts = new Set(allFiles.map((filePath) => path.extname(filePath)));
260
+ await Promise.all([...neededExts].map((ext) => getLanguageForExtension(ext)));
261
+ for (const filePath of allFiles) {
262
+ const ext = path.extname(filePath);
263
+ const lang = await getLanguageForExtension(ext);
264
+ if (!lang)
265
+ continue;
266
+ parser.setLanguage(lang);
267
+ const content = fs.readFileSync(filePath, "utf8");
268
+ const tree = parser.parse(content);
269
+ filesParsed++;
270
+ const relPath = path.relative(repoRoot, filePath).replace(/\\/g, "/");
271
+ function walk(node, currentClass = null, currentFunction = null) {
272
+ if (node.type === "class_declaration" || node.type === "class_definition") {
273
+ const nameNode = node.childForFieldName("name");
274
+ const className = nameNode ? nameNode.text : "AnonymousClass";
275
+ symbols.push({
276
+ name: className,
277
+ qualifiedName: `${relPath}:${className}`,
278
+ kind: "Class",
279
+ file: relPath,
280
+ startLine: node.startPosition.row + 1,
281
+ endLine: node.endPosition.row + 1,
282
+ });
283
+ for (const child of node.children) {
284
+ walk(child, className, currentFunction);
285
+ }
286
+ return;
287
+ }
288
+ if (node.type === "interface_declaration") {
289
+ const nameNode = node.childForFieldName("name");
290
+ const interfaceName = nameNode ? nameNode.text : "AnonymousInterface";
291
+ symbols.push({
292
+ name: interfaceName,
293
+ qualifiedName: `${relPath}:${interfaceName}`,
294
+ kind: "Interface",
295
+ file: relPath,
296
+ startLine: node.startPosition.row + 1,
297
+ endLine: node.endPosition.row + 1,
298
+ });
299
+ for (const child of node.children) {
300
+ walk(child, currentClass, currentFunction);
301
+ }
302
+ return;
303
+ }
304
+ if (node.type === "method_definition" ||
305
+ node.type === "function_declaration" ||
306
+ node.type === "function_definition") {
307
+ const nameNode = node.childForFieldName("name");
308
+ const fnName = nameNode ? nameNode.text : "anonymous";
309
+ const kind = currentClass ? "Method" : "Function";
310
+ const qualifiedName = currentClass ? `${currentClass}.${fnName}` : fnName;
311
+ symbols.push({
312
+ name: fnName,
313
+ qualifiedName: `${relPath}:${qualifiedName}`,
314
+ kind,
315
+ file: relPath,
316
+ startLine: node.startPosition.row + 1,
317
+ endLine: node.endPosition.row + 1,
318
+ });
319
+ for (const child of node.children) {
320
+ walk(child, currentClass, qualifiedName);
321
+ }
322
+ return;
323
+ }
324
+ if (node.type === "variable_declarator") {
325
+ const nameNode = node.childForFieldName("name");
326
+ const valueNode = node.childForFieldName("value");
327
+ if (nameNode &&
328
+ valueNode &&
329
+ (valueNode.type === "arrow_function" ||
330
+ valueNode.type === "function_expression" ||
331
+ valueNode.type === "function")) {
332
+ const fnName = nameNode.text;
333
+ const kind = currentClass ? "Method" : "Function";
334
+ const qualifiedName = currentClass ? `${currentClass}.${fnName}` : fnName;
335
+ symbols.push({
336
+ name: fnName,
337
+ qualifiedName: `${relPath}:${qualifiedName}`,
338
+ kind,
339
+ file: relPath,
340
+ startLine: node.startPosition.row + 1,
341
+ endLine: node.endPosition.row + 1,
342
+ });
343
+ for (const child of node.children) {
344
+ walk(child, currentClass, qualifiedName);
345
+ }
346
+ return;
347
+ }
348
+ }
349
+ if (node.type === "call_expression" || node.type === "call") {
350
+ const fnNode = node.childForFieldName("function");
351
+ if (fnNode && currentFunction) {
352
+ const rawCall = fnNode.text;
353
+ const calleeBare = rawCall.replace(/^.*\.([A-Za-z0-9_]+)$/, "$1");
354
+ calls.push({
355
+ caller: currentFunction,
356
+ callee: calleeBare,
357
+ file: relPath,
358
+ line: node.startPosition.row + 1,
359
+ });
360
+ const existingCallers = callersMap.get(calleeBare) || [];
361
+ if (!existingCallers.includes(currentFunction)) {
362
+ existingCallers.push(currentFunction);
363
+ callersMap.set(calleeBare, existingCallers);
364
+ }
365
+ const existingCallees = calleesMap.get(currentFunction) || [];
366
+ if (!existingCallees.includes(calleeBare)) {
367
+ existingCallees.push(calleeBare);
368
+ calleesMap.set(currentFunction, existingCallees);
369
+ }
370
+ }
371
+ }
372
+ for (const child of node.children) {
373
+ walk(child, currentClass, currentFunction);
374
+ }
375
+ }
376
+ walk(tree.rootNode);
377
+ }
378
+ const parseDurationMs = performance.now() - t0;
379
+ return {
380
+ symbols,
381
+ calls,
382
+ callersMap,
383
+ calleesMap,
384
+ filesParsed,
385
+ parseDurationMs,
386
+ };
387
+ }
388
+ //# sourceMappingURL=astExtractor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"astExtractor.js","sourceRoot":"","sources":["../../src/astExtractor.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAA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KAAK;QACL,UAAU;QACV,UAAU;QACV,WAAW;QACX,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { AdapterProfile, PublicationResult } from "./types.js";
2
+ export declare function resolveWindowsExecutable(executable: string): string;
3
+ export declare function capnChartArgs(question: string, answer: string, files: readonly string[]): string[];
4
+ /**
5
+ * Chart a question + answer (+ optional file references) into Capn memory.
6
+ * Profile "none" disables publication (deterministic no-op for tests and
7
+ * offline use); "capn-cli" invokes the real capn-hook CLI.
8
+ */
9
+ export declare function publish(root: string, profile: AdapterProfile, executable: string, question: string, answer: string, files: readonly string[]): Promise<PublicationResult>;
10
+ /**
11
+ * The two-phase discovery router: structural questions (who calls / where is /
12
+ * entrypoints) are answered by the in-process Tree-sitter WASM AST; everything
13
+ * else falls through to Capn's charted semantic memory. A clean miss is a miss —
14
+ * the router never guesses.
15
+ */
16
+ export declare function ask(root: string, profile: AdapterProfile, executable: string, question: string): Promise<Record<string, unknown>>;