agent-knowledge 1.5.2 → 1.6.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.
- package/README.md +14 -1
- package/agent-desk-plugin.json +2 -1
- package/dist/dashboard.d.ts.map +1 -1
- package/dist/dashboard.js +43 -0
- package/dist/dashboard.js.map +1 -1
- package/dist/ui/app.js +7 -0
- package/dist/ui/index.html +92 -7
- package/dist/ui/render-graph.js +482 -0
- package/dist/ui/styles.css +72 -0
- package/dist/ui/vis-network.min.js +34 -0
- package/docs/INGEST.md +189 -0
- package/docs/SETUP.md +71 -10
- package/docs/hooks.md +116 -0
- package/package.json +6 -1
- package/scripts/copy-ui.js +4 -0
- package/scripts/hooks/precompact-distill.mjs +105 -0
- package/scripts/hooks/session-start-ingest.mjs +238 -0
- package/scripts/hooks/sessionend-distill.mjs +122 -0
- package/scripts/setup.js +217 -0
- package/scripts/tree-sitter-extract.mjs +464 -0
- package/scripts/tree-sitter-lang.mjs +366 -0
- package/skills/knowledge-ingest/SKILL.md +224 -0
- package/skills/knowledge-ingest/scripts/validate.mjs +170 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// =============================================================================
|
|
4
|
+
// tree-sitter-extract.mjs — deterministic structural extraction from codebases
|
|
5
|
+
//
|
|
6
|
+
// Parses source files via web-tree-sitter (WASM) and outputs a JSON structure
|
|
7
|
+
// containing symbols, imports, exports, call edges, rationale comments, and
|
|
8
|
+
// a file-level dependency graph. Zero LLM tokens consumed.
|
|
9
|
+
//
|
|
10
|
+
// Usage:
|
|
11
|
+
// node scripts/tree-sitter-extract.mjs <path> [options]
|
|
12
|
+
//
|
|
13
|
+
// Options:
|
|
14
|
+
// --include "*.py,*.ts" Glob patterns to include (default: all supported)
|
|
15
|
+
// --exclude "node_modules,dist" Directories/patterns to exclude
|
|
16
|
+
// --max-files 2000 Cap on number of files to process
|
|
17
|
+
// --json Pretty-print JSON output (default: compact)
|
|
18
|
+
// =============================================================================
|
|
19
|
+
|
|
20
|
+
import { readFileSync, readdirSync, statSync } from 'fs';
|
|
21
|
+
import { join, extname, relative, resolve, dirname } from 'path';
|
|
22
|
+
import { createHash } from 'crypto';
|
|
23
|
+
import { fileURLToPath } from 'url';
|
|
24
|
+
import { createRequire } from 'module';
|
|
25
|
+
import { LANGUAGE_CONFIG, RATIONALE_PATTERNS, buildExtensionMap } from './tree-sitter-lang.mjs';
|
|
26
|
+
|
|
27
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
28
|
+
const __dirname = dirname(__filename);
|
|
29
|
+
const require = createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
// ---- Defaults ----
|
|
32
|
+
|
|
33
|
+
const DEFAULT_EXCLUDE = [
|
|
34
|
+
'node_modules',
|
|
35
|
+
'.git',
|
|
36
|
+
'dist',
|
|
37
|
+
'build',
|
|
38
|
+
'target',
|
|
39
|
+
'vendor',
|
|
40
|
+
'__pycache__',
|
|
41
|
+
'.venv',
|
|
42
|
+
'venv',
|
|
43
|
+
'.tox',
|
|
44
|
+
'.mypy_cache',
|
|
45
|
+
'.next',
|
|
46
|
+
'.nuxt',
|
|
47
|
+
'coverage',
|
|
48
|
+
'.pytest_cache',
|
|
49
|
+
'.cargo',
|
|
50
|
+
'bin',
|
|
51
|
+
'obj',
|
|
52
|
+
'.gradle',
|
|
53
|
+
'.idea',
|
|
54
|
+
'.vscode',
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
const DEFAULT_MAX_FILES = 2000;
|
|
58
|
+
|
|
59
|
+
// ---- CLI argument parsing ----
|
|
60
|
+
|
|
61
|
+
function parseArgs(argv) {
|
|
62
|
+
const args = {
|
|
63
|
+
path: null,
|
|
64
|
+
include: [],
|
|
65
|
+
exclude: [...DEFAULT_EXCLUDE],
|
|
66
|
+
maxFiles: DEFAULT_MAX_FILES,
|
|
67
|
+
pretty: false,
|
|
68
|
+
};
|
|
69
|
+
let i = 2;
|
|
70
|
+
while (i < argv.length) {
|
|
71
|
+
const arg = argv[i];
|
|
72
|
+
if (arg === '--include' && argv[i + 1]) {
|
|
73
|
+
args.include = argv[++i].split(',').map((s) => s.trim());
|
|
74
|
+
} else if (arg === '--exclude' && argv[i + 1]) {
|
|
75
|
+
args.exclude = [...DEFAULT_EXCLUDE, ...argv[++i].split(',').map((s) => s.trim())];
|
|
76
|
+
} else if (arg === '--max-files' && argv[i + 1]) {
|
|
77
|
+
args.maxFiles = parseInt(argv[++i], 10);
|
|
78
|
+
} else if (arg === '--json') {
|
|
79
|
+
args.pretty = true;
|
|
80
|
+
} else if (!arg.startsWith('--')) {
|
|
81
|
+
args.path = arg;
|
|
82
|
+
}
|
|
83
|
+
i++;
|
|
84
|
+
}
|
|
85
|
+
if (!args.path) {
|
|
86
|
+
console.error(
|
|
87
|
+
'Usage: node tree-sitter-extract.mjs <path> [--include "*.py,*.ts"] [--exclude "dir1,dir2"] [--max-files N] [--json]',
|
|
88
|
+
);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
args.path = resolve(args.path);
|
|
92
|
+
return args;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ---- File discovery ----
|
|
96
|
+
|
|
97
|
+
function walkDir(dir, exclude, extMap, includeExts, maxFiles) {
|
|
98
|
+
const files = [];
|
|
99
|
+
|
|
100
|
+
function walk(currentDir) {
|
|
101
|
+
if (files.length >= maxFiles) return;
|
|
102
|
+
let entries;
|
|
103
|
+
try {
|
|
104
|
+
entries = readdirSync(currentDir, { withFileTypes: true });
|
|
105
|
+
} catch {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (files.length >= maxFiles) return;
|
|
110
|
+
const name = entry.name;
|
|
111
|
+
if (exclude.some((ex) => name === ex || name.startsWith(ex + '/'))) continue;
|
|
112
|
+
const fullPath = join(currentDir, name);
|
|
113
|
+
if (entry.isDirectory()) {
|
|
114
|
+
walk(fullPath);
|
|
115
|
+
} else if (entry.isFile()) {
|
|
116
|
+
const ext = extname(name).toLowerCase();
|
|
117
|
+
if (!extMap.has(ext)) continue;
|
|
118
|
+
if (includeExts.length > 0 && !includeExts.some((ie) => name.endsWith(ie) || ext === ie))
|
|
119
|
+
continue;
|
|
120
|
+
let mtime;
|
|
121
|
+
try {
|
|
122
|
+
mtime = statSync(fullPath).mtimeMs;
|
|
123
|
+
} catch {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
files.push({ fullPath, ext, mtime });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
walk(dir);
|
|
132
|
+
files.sort((a, b) => b.mtime - a.mtime);
|
|
133
|
+
return files.slice(0, maxFiles);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// ---- Tree-sitter initialization ----
|
|
137
|
+
|
|
138
|
+
let TreeSitter;
|
|
139
|
+
let parserInstance;
|
|
140
|
+
const loadedLanguages = new Map();
|
|
141
|
+
|
|
142
|
+
async function initTreeSitter() {
|
|
143
|
+
const mod = await import('web-tree-sitter');
|
|
144
|
+
TreeSitter = mod.default || mod;
|
|
145
|
+
await TreeSitter.init();
|
|
146
|
+
parserInstance = new TreeSitter();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function getLanguage(langName) {
|
|
150
|
+
if (loadedLanguages.has(langName)) return loadedLanguages.get(langName);
|
|
151
|
+
const config = LANGUAGE_CONFIG[langName];
|
|
152
|
+
if (!config) return null;
|
|
153
|
+
|
|
154
|
+
let wasmPath;
|
|
155
|
+
try {
|
|
156
|
+
wasmPath = require.resolve(config.grammarPackage);
|
|
157
|
+
} catch {
|
|
158
|
+
try {
|
|
159
|
+
wasmPath = fileURLToPath(import.meta.resolve(config.grammarPackage));
|
|
160
|
+
} catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const lang = await TreeSitter.Language.load(wasmPath);
|
|
166
|
+
loadedLanguages.set(langName, lang);
|
|
167
|
+
return lang;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// ---- Extraction ----
|
|
171
|
+
|
|
172
|
+
function sha256(content) {
|
|
173
|
+
return createHash('sha256').update(content).digest('hex');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function extractRationale(source) {
|
|
177
|
+
const results = [];
|
|
178
|
+
const lines = source.split('\n');
|
|
179
|
+
for (let i = 0; i < lines.length; i++) {
|
|
180
|
+
for (const pattern of RATIONALE_PATTERNS) {
|
|
181
|
+
const re = new RegExp(pattern.source, pattern.flags.replace('g', ''));
|
|
182
|
+
const match = re.exec(lines[i]);
|
|
183
|
+
if (match) {
|
|
184
|
+
results.push({
|
|
185
|
+
line: i + 1,
|
|
186
|
+
tag: match[1].toUpperCase(),
|
|
187
|
+
text: match[2].trim(),
|
|
188
|
+
});
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return results;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function runQuery(tree, language, queryStr) {
|
|
197
|
+
if (!queryStr || !queryStr.trim()) return [];
|
|
198
|
+
try {
|
|
199
|
+
const query = language.query(queryStr);
|
|
200
|
+
return query.matches(tree.rootNode);
|
|
201
|
+
} catch {
|
|
202
|
+
return [];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function extractDocstring(node, source) {
|
|
207
|
+
const nextSibling = node.nextNamedSibling;
|
|
208
|
+
if (nextSibling && nextSibling.type === 'expression_statement') {
|
|
209
|
+
const child = nextSibling.firstNamedChild;
|
|
210
|
+
if (child && child.type === 'string') {
|
|
211
|
+
const text = child.text.replace(/^["']{1,3}|["']{1,3}$/g, '').trim();
|
|
212
|
+
if (text.length > 0 && text.length < 500) return text;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const prev = node.previousNamedSibling;
|
|
217
|
+
if (prev && prev.type === 'comment') {
|
|
218
|
+
const text = prev.text
|
|
219
|
+
.replace(/^\/\*\*?|\*\/$/g, '')
|
|
220
|
+
.replace(/^\s*\*\s?/gm, '')
|
|
221
|
+
.trim();
|
|
222
|
+
if (text.length > 0 && text.length < 500) return text;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let sibling = node.previousSibling;
|
|
226
|
+
while (sibling && sibling.type === 'comment') {
|
|
227
|
+
sibling = sibling.previousSibling;
|
|
228
|
+
}
|
|
229
|
+
if (sibling !== node.previousSibling && node.previousSibling?.type === 'comment') {
|
|
230
|
+
const commentNodes = [];
|
|
231
|
+
let s = node.previousSibling;
|
|
232
|
+
while (s && s.type === 'comment') {
|
|
233
|
+
commentNodes.unshift(s);
|
|
234
|
+
s = s.previousSibling;
|
|
235
|
+
}
|
|
236
|
+
const text = commentNodes
|
|
237
|
+
.map((c) => c.text.replace(/^\/\/\s?/, ''))
|
|
238
|
+
.join('\n')
|
|
239
|
+
.trim();
|
|
240
|
+
if (text.length > 0 && text.length < 500) return text;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function getCapture(match, name) {
|
|
247
|
+
const cap = match.captures.find((c) => c.name === name);
|
|
248
|
+
return cap ? cap.node : null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function getCaptureText(match, name) {
|
|
252
|
+
const node = getCapture(match, name);
|
|
253
|
+
return node ? node.text : null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
async function extractFile(filePath, langName, source) {
|
|
257
|
+
const config = LANGUAGE_CONFIG[langName];
|
|
258
|
+
const language = await getLanguage(langName);
|
|
259
|
+
if (!language) return null;
|
|
260
|
+
|
|
261
|
+
parserInstance.setLanguage(language);
|
|
262
|
+
const tree = parserInstance.parse(source);
|
|
263
|
+
|
|
264
|
+
const symbols = [];
|
|
265
|
+
const imports = [];
|
|
266
|
+
const exports = [];
|
|
267
|
+
const calls = [];
|
|
268
|
+
|
|
269
|
+
const classMatches = runQuery(tree, language, config.queries.classes);
|
|
270
|
+
for (const match of classMatches) {
|
|
271
|
+
const nameNode = getCapture(match, 'name');
|
|
272
|
+
const mainCapture = match.captures.find((c) =>
|
|
273
|
+
['class', 'interface', 'struct', 'enum', 'trait', 'impl', 'typedef'].includes(c.name),
|
|
274
|
+
);
|
|
275
|
+
if (nameNode) {
|
|
276
|
+
symbols.push({
|
|
277
|
+
kind: mainCapture?.name || 'class',
|
|
278
|
+
name: nameNode.text,
|
|
279
|
+
line: nameNode.startPosition.row + 1,
|
|
280
|
+
endLine: (mainCapture?.node || nameNode).endPosition.row + 1,
|
|
281
|
+
params: null,
|
|
282
|
+
docstring: extractDocstring(mainCapture?.node || nameNode, source),
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const funcMatches = runQuery(tree, language, config.queries.functions);
|
|
288
|
+
for (const match of funcMatches) {
|
|
289
|
+
const nameNode = getCapture(match, 'name');
|
|
290
|
+
const paramsNode = getCapture(match, 'params');
|
|
291
|
+
const mainCapture = match.captures.find((c) =>
|
|
292
|
+
['func', 'method', 'arrow_decl', 'constructor'].includes(c.name),
|
|
293
|
+
);
|
|
294
|
+
if (nameNode) {
|
|
295
|
+
symbols.push({
|
|
296
|
+
kind: mainCapture?.name === 'method' ? 'method' : 'function',
|
|
297
|
+
name: nameNode.text,
|
|
298
|
+
line: nameNode.startPosition.row + 1,
|
|
299
|
+
endLine: (mainCapture?.node || nameNode).endPosition.row + 1,
|
|
300
|
+
params: paramsNode ? paramsNode.text : null,
|
|
301
|
+
docstring: extractDocstring(mainCapture?.node || nameNode, source),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const importMatches = runQuery(tree, language, config.queries.imports);
|
|
307
|
+
const importMap = new Map();
|
|
308
|
+
for (const match of importMatches) {
|
|
309
|
+
const sourceNode = getCapture(match, 'source');
|
|
310
|
+
const nameNode = getCapture(match, 'imported_name');
|
|
311
|
+
if (sourceNode) {
|
|
312
|
+
const src = sourceNode.text.replace(/^["']|["']$/g, '');
|
|
313
|
+
if (!importMap.has(src)) importMap.set(src, []);
|
|
314
|
+
if (nameNode) importMap.get(src).push(nameNode.text);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
for (const [source, names] of importMap) {
|
|
318
|
+
imports.push({ source, names: [...new Set(names)] });
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (config.queries.exports) {
|
|
322
|
+
const exportMatches = runQuery(tree, language, config.queries.exports);
|
|
323
|
+
for (const match of exportMatches) {
|
|
324
|
+
const mainNode = match.captures[0]?.node;
|
|
325
|
+
if (mainNode) {
|
|
326
|
+
const text = mainNode.text;
|
|
327
|
+
const nameMatch = text.match(
|
|
328
|
+
/export\s+(?:default\s+)?(?:function|class|const|let|var|interface|type|enum)\s+(\w+)/,
|
|
329
|
+
);
|
|
330
|
+
if (nameMatch) exports.push(nameMatch[1]);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const callMatches = runQuery(tree, language, config.queries.calls);
|
|
336
|
+
const seenCalls = new Set();
|
|
337
|
+
for (const match of callMatches) {
|
|
338
|
+
const calleeNode = getCapture(match, 'callee');
|
|
339
|
+
if (calleeNode) {
|
|
340
|
+
const callee = calleeNode.text;
|
|
341
|
+
const line = calleeNode.startPosition.row + 1;
|
|
342
|
+
const enclosingFunc = symbols.find(
|
|
343
|
+
(s) =>
|
|
344
|
+
(s.kind === 'function' || s.kind === 'method') && line >= s.line && line <= s.endLine,
|
|
345
|
+
);
|
|
346
|
+
const caller = enclosingFunc ? enclosingFunc.name : '<module>';
|
|
347
|
+
const key = `${caller}→${callee}`;
|
|
348
|
+
if (!seenCalls.has(key)) {
|
|
349
|
+
seenCalls.add(key);
|
|
350
|
+
calls.push({ caller, callee });
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
tree.delete();
|
|
356
|
+
return { symbols, imports, exports, calls };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// ---- Dependency graph ----
|
|
360
|
+
|
|
361
|
+
function buildDependencyGraph(files, rootPath) {
|
|
362
|
+
const graph = {};
|
|
363
|
+
const pathMap = new Map();
|
|
364
|
+
|
|
365
|
+
for (const f of files) {
|
|
366
|
+
const rel = f.relativePath;
|
|
367
|
+
pathMap.set(rel, true);
|
|
368
|
+
const base = rel.replace(/\.[^.]+$/, '');
|
|
369
|
+
pathMap.set(base, rel);
|
|
370
|
+
const indexBase = base.replace(/\/index$/, '');
|
|
371
|
+
if (indexBase !== base) pathMap.set(indexBase, rel);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
for (const f of files) {
|
|
375
|
+
if (!f.extracted) continue;
|
|
376
|
+
const deps = [];
|
|
377
|
+
for (const imp of f.extracted.imports) {
|
|
378
|
+
const src = imp.source;
|
|
379
|
+
if (src.startsWith('.')) {
|
|
380
|
+
const dir = dirname(f.relativePath);
|
|
381
|
+
const resolved = join(dir, src).replace(/\\/g, '/');
|
|
382
|
+
const found = pathMap.get(resolved);
|
|
383
|
+
if (found && found !== true) deps.push(found);
|
|
384
|
+
else if (pathMap.has(resolved)) deps.push(resolved);
|
|
385
|
+
} else {
|
|
386
|
+
deps.push(src.split('/')[0]);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
if (deps.length > 0) graph[f.relativePath] = [...new Set(deps)];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
return graph;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// ---- Main ----
|
|
396
|
+
|
|
397
|
+
async function main() {
|
|
398
|
+
const args = parseArgs(process.argv);
|
|
399
|
+
const extMap = buildExtensionMap();
|
|
400
|
+
|
|
401
|
+
const discovered = walkDir(args.path, args.exclude, extMap, args.include, args.maxFiles);
|
|
402
|
+
|
|
403
|
+
await initTreeSitter();
|
|
404
|
+
|
|
405
|
+
const fileResults = [];
|
|
406
|
+
for (const file of discovered) {
|
|
407
|
+
const langName = extMap.get(file.ext);
|
|
408
|
+
let source;
|
|
409
|
+
try {
|
|
410
|
+
source = readFileSync(file.fullPath, 'utf-8');
|
|
411
|
+
} catch {
|
|
412
|
+
continue;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const relativePath = relative(args.path, file.fullPath).replace(/\\/g, '/');
|
|
416
|
+
const hash = sha256(source);
|
|
417
|
+
const rationale = extractRationale(source);
|
|
418
|
+
const extracted = await extractFile(file.fullPath, langName, source);
|
|
419
|
+
|
|
420
|
+
fileResults.push({
|
|
421
|
+
path: relativePath,
|
|
422
|
+
language: langName,
|
|
423
|
+
sha256: hash,
|
|
424
|
+
size: source.length,
|
|
425
|
+
symbols: extracted?.symbols || [],
|
|
426
|
+
imports: extracted?.imports || [],
|
|
427
|
+
exports: extracted?.exports || [],
|
|
428
|
+
rationale,
|
|
429
|
+
calls: extracted?.calls || [],
|
|
430
|
+
relativePath,
|
|
431
|
+
extracted,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const dependencyGraph = buildDependencyGraph(fileResults, args.path);
|
|
436
|
+
|
|
437
|
+
const output = {
|
|
438
|
+
version: 1,
|
|
439
|
+
timestamp: new Date().toISOString(),
|
|
440
|
+
root: args.path.replace(/\\/g, '/'),
|
|
441
|
+
fileCount: fileResults.length,
|
|
442
|
+
files: fileResults.map((f) => ({
|
|
443
|
+
path: f.path,
|
|
444
|
+
language: f.language,
|
|
445
|
+
sha256: f.sha256,
|
|
446
|
+
size: f.size,
|
|
447
|
+
symbols: f.symbols,
|
|
448
|
+
imports: f.imports,
|
|
449
|
+
exports: f.exports,
|
|
450
|
+
rationale: f.rationale,
|
|
451
|
+
calls: f.calls,
|
|
452
|
+
})),
|
|
453
|
+
dependencyGraph,
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const json = args.pretty ? JSON.stringify(output, null, 2) : JSON.stringify(output);
|
|
457
|
+
process.stdout.write(json + '\n');
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
main().catch((err) => {
|
|
461
|
+
console.error('tree-sitter-extract failed:', err.message || err);
|
|
462
|
+
if (err.stack) console.error(err.stack);
|
|
463
|
+
process.exit(1);
|
|
464
|
+
});
|