@aicodepulse/core 0.1.1 → 0.1.2
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/dist/index.d.ts +6 -1
- package/dist/index.js +104 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -47,6 +47,8 @@ interface ContextRequest {
|
|
|
47
47
|
focusPath?: string;
|
|
48
48
|
format: 'markdown' | 'xml';
|
|
49
49
|
layers?: LayerName[];
|
|
50
|
+
taskKeywords?: string[];
|
|
51
|
+
autoBudget?: boolean;
|
|
50
52
|
}
|
|
51
53
|
interface LayerResult {
|
|
52
54
|
layer: LayerName;
|
|
@@ -59,6 +61,7 @@ interface ContextResult {
|
|
|
59
61
|
budgetTokens: number;
|
|
60
62
|
layers: LayerResult[];
|
|
61
63
|
rendered: string;
|
|
64
|
+
skipped?: boolean;
|
|
62
65
|
}
|
|
63
66
|
interface CodePulseConfig {
|
|
64
67
|
exclude: string[];
|
|
@@ -139,4 +142,6 @@ declare class Indexer {
|
|
|
139
142
|
|
|
140
143
|
declare function generateContext(db: DB, request: ContextRequest, config: CodePulseConfig): ContextResult;
|
|
141
144
|
|
|
142
|
-
|
|
145
|
+
declare function extractKeywords(task: string): string[];
|
|
146
|
+
|
|
147
|
+
export { type CodePulseConfig, type CodeSymbol, type ContextRequest, type ContextResult, DEFAULT_CONFIG, type FileRecord, FileRepository, type ImportEdge, type IndexMeta, type IndexStats, Indexer, type LayerName, type LayerResult, MetaRepository, type SymbolKind, SymbolRepository, extractKeywords, generateContext, openDatabase };
|
package/dist/index.js
CHANGED
|
@@ -1197,8 +1197,70 @@ function renderDirectoryMap(db, budget) {
|
|
|
1197
1197
|
return { content, truncated: countTokens(content) > budget };
|
|
1198
1198
|
}
|
|
1199
1199
|
|
|
1200
|
+
// src/context/TaskAnalyzer.ts
|
|
1201
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
1202
|
+
"a",
|
|
1203
|
+
"an",
|
|
1204
|
+
"the",
|
|
1205
|
+
"is",
|
|
1206
|
+
"in",
|
|
1207
|
+
"it",
|
|
1208
|
+
"of",
|
|
1209
|
+
"to",
|
|
1210
|
+
"and",
|
|
1211
|
+
"or",
|
|
1212
|
+
"for",
|
|
1213
|
+
"on",
|
|
1214
|
+
"at",
|
|
1215
|
+
"by",
|
|
1216
|
+
"with",
|
|
1217
|
+
"from",
|
|
1218
|
+
"this",
|
|
1219
|
+
"that",
|
|
1220
|
+
"be",
|
|
1221
|
+
"are",
|
|
1222
|
+
"was",
|
|
1223
|
+
"can",
|
|
1224
|
+
"do",
|
|
1225
|
+
"get",
|
|
1226
|
+
"use",
|
|
1227
|
+
"how",
|
|
1228
|
+
"what",
|
|
1229
|
+
"my",
|
|
1230
|
+
"me",
|
|
1231
|
+
"i",
|
|
1232
|
+
"we",
|
|
1233
|
+
"you",
|
|
1234
|
+
"show",
|
|
1235
|
+
"make",
|
|
1236
|
+
"add",
|
|
1237
|
+
"fix",
|
|
1238
|
+
"update",
|
|
1239
|
+
"change",
|
|
1240
|
+
"want",
|
|
1241
|
+
"need",
|
|
1242
|
+
"all"
|
|
1243
|
+
]);
|
|
1244
|
+
function extractKeywords(task) {
|
|
1245
|
+
return task.toLowerCase().replace(/[^a-z0-9\s_/-]/g, " ").split(/\s+/).filter((w) => w.length > 2 && !STOPWORDS.has(w));
|
|
1246
|
+
}
|
|
1247
|
+
function scoreFile(filePath, symbols, keywords) {
|
|
1248
|
+
if (keywords.length === 0) return 0;
|
|
1249
|
+
const pathLower = filePath.toLowerCase();
|
|
1250
|
+
let score = 0;
|
|
1251
|
+
for (const kw of keywords) {
|
|
1252
|
+
if (pathLower.includes(kw)) score += 3;
|
|
1253
|
+
for (const sym of symbols) {
|
|
1254
|
+
if (sym.name.toLowerCase().includes(kw)) score += 2;
|
|
1255
|
+
if (sym.signature?.toLowerCase().includes(kw)) score += 1;
|
|
1256
|
+
if (sym.docComment?.toLowerCase().includes(kw)) score += 1;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
return score;
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1200
1262
|
// src/context/layers/SymbolTableLayer.ts
|
|
1201
|
-
function renderSymbolTable(db, budget) {
|
|
1263
|
+
function renderSymbolTable(db, budget, taskKeywords = []) {
|
|
1202
1264
|
const repo = new SymbolRepository(db);
|
|
1203
1265
|
const symbols = repo.getAllExported();
|
|
1204
1266
|
const byFile = /* @__PURE__ */ new Map();
|
|
@@ -1206,7 +1268,10 @@ function renderSymbolTable(db, budget) {
|
|
|
1206
1268
|
if (!byFile.has(s.filePath)) byFile.set(s.filePath, []);
|
|
1207
1269
|
byFile.get(s.filePath).push(s);
|
|
1208
1270
|
}
|
|
1209
|
-
const sorted = [...byFile.entries()].sort((a, b) =>
|
|
1271
|
+
const sorted = [...byFile.entries()].sort((a, b) => {
|
|
1272
|
+
const scoreDiff = scoreFile(b[0], b[1], taskKeywords) - scoreFile(a[0], a[1], taskKeywords);
|
|
1273
|
+
return scoreDiff !== 0 ? scoreDiff : b[1].length - a[1].length;
|
|
1274
|
+
});
|
|
1210
1275
|
const lines = [];
|
|
1211
1276
|
let usedTokens = 0;
|
|
1212
1277
|
let truncated = false;
|
|
@@ -1283,14 +1348,24 @@ function renderFocusLayer(db, focusPath, budget) {
|
|
|
1283
1348
|
|
|
1284
1349
|
// src/context/ContextGenerator.ts
|
|
1285
1350
|
var DEFAULT_LAYERS = ["repo_overview", "directory_map", "symbol_table", "import_graph", "focus"];
|
|
1286
|
-
|
|
1351
|
+
var SKIP_THRESHOLD = 10;
|
|
1352
|
+
var SMALL_REPO_BUDGET = 800;
|
|
1353
|
+
var MEDIUM_REPO_BUDGET = 2e3;
|
|
1354
|
+
var LARGE_REPO_BUDGET = 4e3;
|
|
1355
|
+
function autoBudget(totalFiles) {
|
|
1356
|
+
if (totalFiles < SKIP_THRESHOLD) return null;
|
|
1357
|
+
if (totalFiles < 30) return SMALL_REPO_BUDGET;
|
|
1358
|
+
if (totalFiles < 150) return MEDIUM_REPO_BUDGET;
|
|
1359
|
+
return LARGE_REPO_BUDGET;
|
|
1360
|
+
}
|
|
1361
|
+
function renderLayer(db, layer, budget, focusPath, taskKeywords = []) {
|
|
1287
1362
|
switch (layer) {
|
|
1288
1363
|
case "repo_overview":
|
|
1289
1364
|
return renderRepoOverview(db, budget);
|
|
1290
1365
|
case "directory_map":
|
|
1291
1366
|
return renderDirectoryMap(db, budget);
|
|
1292
1367
|
case "symbol_table":
|
|
1293
|
-
return renderSymbolTable(db, budget);
|
|
1368
|
+
return renderSymbolTable(db, budget, taskKeywords);
|
|
1294
1369
|
case "import_graph":
|
|
1295
1370
|
return renderImportGraph(db, budget);
|
|
1296
1371
|
case "focus":
|
|
@@ -1313,12 +1388,33 @@ ${inner}
|
|
|
1313
1388
|
function generateContext(db, request, config) {
|
|
1314
1389
|
const layers = request.layers ?? DEFAULT_LAYERS;
|
|
1315
1390
|
const hasFocus = Boolean(request.focusPath);
|
|
1316
|
-
const
|
|
1391
|
+
const taskKeywords = request.taskKeywords ?? [];
|
|
1392
|
+
let budgetTokens = request.budgetTokens;
|
|
1393
|
+
let skipped = false;
|
|
1394
|
+
if (request.autoBudget) {
|
|
1395
|
+
const meta = new MetaRepository(db).getIndexMeta();
|
|
1396
|
+
const resolved = autoBudget(meta.totalFiles);
|
|
1397
|
+
if (resolved === null) {
|
|
1398
|
+
skipped = true;
|
|
1399
|
+
} else {
|
|
1400
|
+
budgetTokens = resolved;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
if (skipped) {
|
|
1404
|
+
return {
|
|
1405
|
+
totalTokens: 0,
|
|
1406
|
+
budgetTokens: 0,
|
|
1407
|
+
layers: [],
|
|
1408
|
+
rendered: "",
|
|
1409
|
+
skipped: true
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
const budgets = allocateBudget(budgetTokens, config, hasFocus, layers);
|
|
1317
1413
|
let remainingSurplus = 0;
|
|
1318
1414
|
const results = [];
|
|
1319
1415
|
for (const { layer, tokens } of budgets) {
|
|
1320
1416
|
const layerBudget = tokens + remainingSurplus;
|
|
1321
|
-
const { content, truncated } = renderLayer(db, layer, layerBudget, request.focusPath);
|
|
1417
|
+
const { content, truncated } = renderLayer(db, layer, layerBudget, request.focusPath, taskKeywords);
|
|
1322
1418
|
const used = countTokens(content);
|
|
1323
1419
|
remainingSurplus = truncated ? 0 : layerBudget - used;
|
|
1324
1420
|
results.push({ layer, tokensUsed: used, content, truncated });
|
|
@@ -1327,7 +1423,7 @@ function generateContext(db, request, config) {
|
|
|
1327
1423
|
const totalTokens = countTokens(rendered);
|
|
1328
1424
|
return {
|
|
1329
1425
|
totalTokens,
|
|
1330
|
-
budgetTokens
|
|
1426
|
+
budgetTokens,
|
|
1331
1427
|
layers: results,
|
|
1332
1428
|
rendered
|
|
1333
1429
|
};
|
|
@@ -1338,6 +1434,7 @@ export {
|
|
|
1338
1434
|
Indexer,
|
|
1339
1435
|
MetaRepository,
|
|
1340
1436
|
SymbolRepository,
|
|
1437
|
+
extractKeywords,
|
|
1341
1438
|
generateContext,
|
|
1342
1439
|
openDatabase
|
|
1343
1440
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/storage/Database.ts","../src/storage/FileRepository.ts","../src/storage/SymbolRepository.ts","../src/storage/MetaRepository.ts","../src/indexer/Indexer.ts","../src/parser/ParserRegistry.ts","../src/parser/languages/typescript.ts","../src/parser/languages/python.ts","../src/parser/languages/go.ts","../src/parser/languages/rust.ts","../src/parser/languages/java.ts","../src/parser/languages/c.ts","../src/parser/languages/csharp.ts","../src/parser/languages/ruby.ts","../src/parser/languages/php.ts","../src/parser/languages/bash.ts","../src/parser/languages/kotlin.ts","../src/parser/languages/swift.ts","../src/parser/SymbolExtractor.ts","../src/parser/ImportExtractor.ts","../src/indexer/HashUtil.ts","../src/indexer/FileWalker.ts","../src/indexer/GitDiff.ts","../src/context/BudgetAllocator.ts","../src/context/TokenCounter.ts","../src/context/layers/RepoOverviewLayer.ts","../src/context/layers/DirectoryMapLayer.ts","../src/context/layers/SymbolTableLayer.ts","../src/context/layers/ImportGraphLayer.ts","../src/context/layers/FocusLayer.ts","../src/context/ContextGenerator.ts"],"sourcesContent":["export interface IndexMeta {\n schemaVersion: number;\n lastIndexedCommit: string;\n lastIndexedAt: number;\n repoRoot: string;\n totalFiles: number;\n totalSymbols: number;\n}\n\nexport type SymbolKind =\n | 'function' | 'class' | 'interface' | 'type' | 'enum'\n | 'variable' | 'constant' | 'method' | 'property' | 'module';\n\nexport interface FileRecord {\n id: number;\n path: string;\n language: string;\n contentHash: string;\n sizeBytes: number;\n linesTotal: number;\n indexedAt: number;\n isDeleted: boolean;\n}\n\nexport interface CodeSymbol {\n id: number;\n fileId: number;\n filePath: string;\n name: string;\n kind: SymbolKind;\n line: number;\n endLine: number;\n isExported: boolean;\n signature: string | null;\n docComment: string | null;\n parentName: string | null;\n}\n\nexport interface ImportEdge {\n id: number;\n fromFileId: number;\n fromPath: string;\n toPath: string | null;\n toPackage: string | null;\n importedNames: string[];\n isTypeOnly: boolean;\n}\n\nexport type LayerName =\n | 'repo_overview'\n | 'directory_map'\n | 'symbol_table'\n | 'import_graph'\n | 'focus';\n\nexport interface ContextRequest {\n budgetTokens: number;\n focusPath?: string;\n format: 'markdown' | 'xml';\n layers?: LayerName[];\n}\n\nexport interface LayerResult {\n layer: LayerName;\n tokensUsed: number;\n content: string;\n truncated: boolean;\n}\n\nexport interface ContextResult {\n totalTokens: number;\n budgetTokens: number;\n layers: LayerResult[];\n rendered: string;\n}\n\nexport interface CodePulseConfig {\n exclude: string[];\n maxFileSizeBytes: number;\n defaultBudgetTokens: number;\n layerWeights: Record<LayerName, number>;\n languages?: string[];\n}\n\nexport const DEFAULT_CONFIG: CodePulseConfig = {\n exclude: ['node_modules', '.git', 'dist', 'build', '.next', '__pycache__', '*.min.js'],\n maxFileSizeBytes: 512 * 1024,\n defaultBudgetTokens: 4000,\n layerWeights: {\n repo_overview: 0.10,\n directory_map: 0.20,\n symbol_table: 0.45,\n import_graph: 0.15,\n focus: 0.10,\n },\n};\n","import BetterSqlite3 from 'better-sqlite3';\n\nconst SCHEMA_VERSION = 1;\n\nconst SCHEMA_SQL = `\nCREATE TABLE IF NOT EXISTS index_meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS file_records (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n path TEXT NOT NULL UNIQUE,\n language TEXT NOT NULL,\n content_hash TEXT NOT NULL,\n size_bytes INTEGER NOT NULL,\n lines_total INTEGER NOT NULL,\n indexed_at INTEGER NOT NULL,\n is_deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_file_language ON file_records(language);\nCREATE INDEX IF NOT EXISTS idx_file_deleted ON file_records(is_deleted);\n\nCREATE TABLE IF NOT EXISTS symbols (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n file_id INTEGER NOT NULL REFERENCES file_records(id) ON DELETE CASCADE,\n file_path TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL,\n line INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n is_exported INTEGER NOT NULL DEFAULT 0,\n signature TEXT,\n doc_comment TEXT,\n parent_name TEXT\n);\nCREATE INDEX IF NOT EXISTS idx_symbol_file ON symbols(file_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_name ON symbols(name);\nCREATE INDEX IF NOT EXISTS idx_symbol_exported ON symbols(is_exported);\n\nCREATE TABLE IF NOT EXISTS import_edges (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n from_file_id INTEGER NOT NULL REFERENCES file_records(id) ON DELETE CASCADE,\n from_path TEXT NOT NULL,\n to_path TEXT,\n to_package TEXT,\n imported_names TEXT NOT NULL,\n is_type_only INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_import_from ON import_edges(from_file_id);\nCREATE INDEX IF NOT EXISTS idx_import_to ON import_edges(to_path);\n`;\n\nexport type DB = BetterSqlite3.Database;\n\nexport function openDatabase(dbPath: string): DB {\n const db = new BetterSqlite3(dbPath);\n db.pragma('journal_mode = WAL');\n db.pragma('foreign_keys = ON');\n runMigrations(db);\n return db;\n}\n\nfunction runMigrations(db: DB): void {\n db.exec(SCHEMA_SQL);\n\n const existing = db.prepare(\"SELECT value FROM index_meta WHERE key = 'schema_version'\").get() as { value: string } | undefined;\n if (!existing) {\n db.prepare(\"INSERT INTO index_meta (key, value) VALUES ('schema_version', ?)\").run(String(SCHEMA_VERSION));\n }\n}\n","import type { DB } from './Database.js';\nimport type { FileRecord } from '../types.js';\n\nfunction rowToFile(row: Record<string, unknown>): FileRecord {\n return {\n id: row.id as number,\n path: row.path as string,\n language: row.language as string,\n contentHash: row.content_hash as string,\n sizeBytes: row.size_bytes as number,\n linesTotal: row.lines_total as number,\n indexedAt: row.indexed_at as number,\n isDeleted: Boolean(row.is_deleted),\n };\n}\n\nexport class FileRepository {\n constructor(private db: DB) {}\n\n upsert(file: Omit<FileRecord, 'id'>): number {\n const result = this.db.prepare(`\n INSERT INTO file_records (path, language, content_hash, size_bytes, lines_total, indexed_at, is_deleted)\n VALUES (@path, @language, @contentHash, @sizeBytes, @linesTotal, @indexedAt, @isDeleted)\n ON CONFLICT(path) DO UPDATE SET\n language = excluded.language,\n content_hash = excluded.content_hash,\n size_bytes = excluded.size_bytes,\n lines_total = excluded.lines_total,\n indexed_at = excluded.indexed_at,\n is_deleted = excluded.is_deleted\n `).run({\n path: file.path,\n language: file.language,\n contentHash: file.contentHash,\n sizeBytes: file.sizeBytes,\n linesTotal: file.linesTotal,\n indexedAt: file.indexedAt,\n isDeleted: file.isDeleted ? 1 : 0,\n });\n return result.lastInsertRowid as number;\n }\n\n getByPath(path: string): FileRecord | null {\n const row = this.db.prepare('SELECT * FROM file_records WHERE path = ?').get(path) as Record<string, unknown> | undefined;\n return row ? rowToFile(row) : null;\n }\n\n markDeleted(path: string): void {\n this.db.prepare('UPDATE file_records SET is_deleted = 1 WHERE path = ?').run(path);\n }\n\n getAllActive(): FileRecord[] {\n const rows = this.db.prepare('SELECT * FROM file_records WHERE is_deleted = 0 ORDER BY path').all() as Record<string, unknown>[];\n return rows.map(rowToFile);\n }\n\n getLanguageStats(): { language: string; count: number }[] {\n return this.db.prepare(`\n SELECT language, COUNT(*) as count\n FROM file_records WHERE is_deleted = 0\n GROUP BY language ORDER BY count DESC\n `).all() as { language: string; count: number }[];\n }\n}\n","import type { DB } from './Database.js';\nimport type { CodeSymbol, ImportEdge } from '../types.js';\n\nfunction rowToSymbol(row: Record<string, unknown>): CodeSymbol {\n return {\n id: row.id as number,\n fileId: row.file_id as number,\n filePath: row.file_path as string,\n name: row.name as string,\n kind: row.kind as CodeSymbol['kind'],\n line: row.line as number,\n endLine: row.end_line as number,\n isExported: Boolean(row.is_exported),\n signature: row.signature as string | null,\n docComment: row.doc_comment as string | null,\n parentName: row.parent_name as string | null,\n };\n}\n\nfunction rowToImport(row: Record<string, unknown>): ImportEdge {\n return {\n id: row.id as number,\n fromFileId: row.from_file_id as number,\n fromPath: row.from_path as string,\n toPath: row.to_path as string | null,\n toPackage: row.to_package as string | null,\n importedNames: JSON.parse(row.imported_names as string),\n isTypeOnly: Boolean(row.is_type_only),\n };\n}\n\nexport class SymbolRepository {\n constructor(private db: DB) {}\n\n insertSymbols(fileId: number, symbols: Omit<CodeSymbol, 'id'>[]): void {\n const stmt = this.db.prepare(`\n INSERT INTO symbols (file_id, file_path, name, kind, line, end_line, is_exported, signature, doc_comment, parent_name)\n VALUES (@fileId, @filePath, @name, @kind, @line, @endLine, @isExported, @signature, @docComment, @parentName)\n `);\n for (const s of symbols) {\n stmt.run({\n fileId: s.fileId,\n filePath: s.filePath,\n name: s.name,\n kind: s.kind,\n line: s.line,\n endLine: s.endLine,\n isExported: s.isExported ? 1 : 0,\n signature: s.signature,\n docComment: s.docComment,\n parentName: s.parentName,\n });\n }\n }\n\n insertImports(fileId: number, edges: Omit<ImportEdge, 'id'>[]): void {\n const stmt = this.db.prepare(`\n INSERT INTO import_edges (from_file_id, from_path, to_path, to_package, imported_names, is_type_only)\n VALUES (@fromFileId, @fromPath, @toPath, @toPackage, @importedNames, @isTypeOnly)\n `);\n for (const e of edges) {\n stmt.run({\n fromFileId: e.fromFileId,\n fromPath: e.fromPath,\n toPath: e.toPath,\n toPackage: e.toPackage,\n importedNames: JSON.stringify(e.importedNames),\n isTypeOnly: e.isTypeOnly ? 1 : 0,\n });\n }\n }\n\n deleteByFileId(fileId: number): void {\n this.db.prepare('DELETE FROM symbols WHERE file_id = ?').run(fileId);\n this.db.prepare('DELETE FROM import_edges WHERE from_file_id = ?').run(fileId);\n }\n\n getExportedByFile(filePath: string): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE file_path = ? AND is_exported = 1 ORDER BY line'\n ).all(filePath) as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n getAllExported(): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE is_exported = 1 ORDER BY file_path, line'\n ).all() as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n search(query: string, limit = 20): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE name LIKE ? AND is_exported = 1 LIMIT ?'\n ).all(`%${query}%`, limit) as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n getImportsFrom(filePath: string): ImportEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM import_edges WHERE from_path = ?'\n ).all(filePath) as Record<string, unknown>[];\n return rows.map(rowToImport);\n }\n\n getImportersOf(filePath: string): string[] {\n const rows = this.db.prepare(\n 'SELECT DISTINCT from_path FROM import_edges WHERE to_path = ?'\n ).all(filePath) as { from_path: string }[];\n return rows.map(r => r.from_path);\n }\n\n getTopImportedFiles(limit = 20): { path: string; importerCount: number }[] {\n return this.db.prepare(`\n SELECT to_path as path, COUNT(*) as importerCount\n FROM import_edges WHERE to_path IS NOT NULL\n GROUP BY to_path ORDER BY importerCount DESC LIMIT ?\n `).all(limit) as { path: string; importerCount: number }[];\n }\n}\n","import type { DB } from './Database.js';\nimport type { IndexMeta } from '../types.js';\n\nexport class MetaRepository {\n constructor(private db: DB) {}\n\n get(key: string): string | null {\n const row = this.db.prepare('SELECT value FROM index_meta WHERE key = ?').get(key) as { value: string } | undefined;\n return row?.value ?? null;\n }\n\n set(key: string, value: string): void {\n this.db.prepare('INSERT OR REPLACE INTO index_meta (key, value) VALUES (?, ?)').run(key, value);\n }\n\n getIndexMeta(): IndexMeta {\n const fileCount = (this.db.prepare(\"SELECT COUNT(*) as c FROM file_records WHERE is_deleted = 0\").get() as { c: number }).c;\n const symbolCount = (this.db.prepare(\"SELECT COUNT(*) as c FROM symbols\").get() as { c: number }).c;\n return {\n schemaVersion: Number(this.get('schema_version') ?? 1),\n lastIndexedCommit: this.get('last_indexed_commit') ?? '',\n lastIndexedAt: Number(this.get('last_indexed_at') ?? 0),\n repoRoot: this.get('repo_root') ?? '',\n totalFiles: fileCount,\n totalSymbols: symbolCount,\n };\n }\n\n saveIndexMeta(commit: string, repoRoot: string): void {\n this.set('last_indexed_commit', commit);\n this.set('last_indexed_at', String(Date.now()));\n this.set('repo_root', repoRoot);\n }\n}\n","import Parser from 'tree-sitter';\nimport { readFileSync, statSync } from 'fs';\nimport { join } from 'path';\nimport type { DB } from '../storage/Database.js';\nimport { FileRepository } from '../storage/FileRepository.js';\nimport { SymbolRepository } from '../storage/SymbolRepository.js';\nimport { MetaRepository } from '../storage/MetaRepository.js';\nimport { getLanguageForExtension, extensionFromPath } from '../parser/ParserRegistry.js';\nimport { extractSymbols } from '../parser/SymbolExtractor.js';\nimport { extractImports } from '../parser/ImportExtractor.js';\nimport { hashContent } from './HashUtil.js';\nimport { walkFiles } from './FileWalker.js';\nimport { getHeadCommit, getChangedFiles } from './GitDiff.js';\nimport type { CodePulseConfig } from '../types.js';\n\nexport interface IndexStats {\n filesAdded: number;\n filesUpdated: number;\n filesDeleted: number;\n filesSkipped: number;\n symbolsTotal: number;\n durationMs: number;\n mode: 'full' | 'incremental';\n}\n\nexport class Indexer {\n private parser = new Parser();\n private files: FileRepository;\n private symbols: SymbolRepository;\n private meta: MetaRepository;\n\n constructor(private db: DB, private repoRoot: string, private config: CodePulseConfig) {\n this.files = new FileRepository(db);\n this.symbols = new SymbolRepository(db);\n this.meta = new MetaRepository(db);\n }\n\n async runFull(): Promise<IndexStats> {\n const start = Date.now();\n const allFiles = await walkFiles(this.repoRoot, this.config);\n let added = 0, updated = 0, skipped = 0;\n\n const transaction = this.db.transaction(() => {\n for (const { absolutePath, relativePath } of allFiles) {\n const result = this.indexFile(absolutePath, relativePath);\n if (result === 'added') added++;\n else if (result === 'updated') updated++;\n else skipped++;\n }\n });\n transaction();\n\n const commit = getHeadCommit(this.repoRoot);\n this.meta.saveIndexMeta(commit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: 0,\n filesSkipped: skipped,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'full',\n };\n }\n\n async runIncremental(): Promise<IndexStats> {\n const start = Date.now();\n const lastCommit = this.meta.get('last_indexed_commit') ?? '';\n const currentCommit = getHeadCommit(this.repoRoot);\n\n // Fall back to full scan if no prior index or git unavailable\n if (!lastCommit || lastCommit === currentCommit) {\n if (!lastCommit) return this.runFull();\n return { filesAdded: 0, filesUpdated: 0, filesDeleted: 0, filesSkipped: 0, symbolsTotal: this.meta.getIndexMeta().totalSymbols, durationMs: 0, mode: 'incremental' };\n }\n\n const changes = getChangedFiles(this.repoRoot, lastCommit);\n if (!changes) return this.runFull();\n\n let added = 0, updated = 0, deleted = 0, skipped = 0;\n\n const transaction = this.db.transaction(() => {\n for (const change of changes) {\n const absPath = join(this.repoRoot, change.path);\n if (change.status === 'D') {\n const existing = this.files.getByPath(change.path);\n if (existing) {\n this.symbols.deleteByFileId(existing.id);\n this.files.markDeleted(change.path);\n deleted++;\n }\n } else {\n const result = this.indexFile(absPath, change.path);\n if (result === 'added') added++;\n else if (result === 'updated') updated++;\n else skipped++;\n }\n }\n });\n transaction();\n\n this.meta.saveIndexMeta(currentCommit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: deleted,\n filesSkipped: skipped,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'incremental',\n };\n }\n\n private indexFile(absolutePath: string, relativePath: string): 'added' | 'updated' | 'skipped' {\n let stat;\n try {\n stat = statSync(absolutePath);\n } catch {\n return 'skipped';\n }\n\n if (stat.size > this.config.maxFileSizeBytes) return 'skipped';\n\n const ext = extensionFromPath(relativePath);\n // We'll still record file even if no parser — skip symbol extraction only\n let content: string;\n try {\n content = readFileSync(absolutePath, 'utf8');\n } catch {\n return 'skipped';\n }\n\n const contentHash = hashContent(content);\n const existing = this.files.getByPath(relativePath);\n\n if (existing && existing.contentHash === contentHash && !existing.isDeleted) {\n return 'skipped';\n }\n\n const isNew = !existing;\n const lines = content.split('\\n').length;\n\n const langConfig = null; // resolved below async — we need sync parsing\n // Note: language config loading done synchronously via cached registry\n const fileId = this.files.upsert({\n path: relativePath,\n language: 'unknown',\n contentHash,\n sizeBytes: stat.size,\n linesTotal: lines,\n indexedAt: Date.now(),\n isDeleted: false,\n });\n\n // We use the actual file id (insert returns rowid, but on conflict we need the real id)\n const record = this.files.getByPath(relativePath);\n if (!record) return 'skipped';\n\n this.symbols.deleteByFileId(record.id);\n\n // Return early — async language loading handled in parseAndStore\n return isNew ? 'added' : 'updated';\n }\n\n async parseAndIndex(absolutePath: string, relativePath: string): Promise<void> {\n const langConfig = getLanguageForExtension(extensionFromPath(relativePath));\n if (!langConfig) return;\n\n let content: string;\n try {\n content = readFileSync(absolutePath, 'utf8');\n } catch {\n return;\n }\n\n this.parser.setLanguage(langConfig.language);\n const tree = this.parser.parse(content);\n\n const record = this.files.getByPath(relativePath);\n if (!record) return;\n\n // Update language now that we know it\n this.files.upsert({ ...record, language: langConfig.name });\n\n const symbols = extractSymbols(tree, relativePath, record.id, langConfig.name, content);\n const imports = extractImports(tree, relativePath, record.id, langConfig.name);\n\n this.symbols.deleteByFileId(record.id);\n if (symbols.length > 0) this.symbols.insertSymbols(record.id, symbols);\n if (imports.length > 0) this.symbols.insertImports(record.id, imports);\n }\n\n async runFullWithParsing(onProgress?: (done: number, total: number) => void): Promise<IndexStats> {\n const start = Date.now();\n const allFiles = await walkFiles(this.repoRoot, this.config);\n\n // First pass: record all files synchronously\n const transaction = this.db.transaction(() => {\n for (const { absolutePath, relativePath } of allFiles) {\n this.indexFile(absolutePath, relativePath);\n }\n });\n transaction();\n\n // Second pass: parse all files async (Tree-Sitter is sync but language loading is async)\n const parseable = allFiles.filter(f => {\n const ext = extensionFromPath(f.relativePath);\n return ext !== '';\n });\n\n let done = 0;\n for (const { absolutePath, relativePath } of parseable) {\n await this.parseAndIndex(absolutePath, relativePath);\n done++;\n onProgress?.(done, parseable.length);\n }\n\n const commit = getHeadCommit(this.repoRoot);\n this.meta.saveIndexMeta(commit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: parseable.length,\n filesUpdated: 0,\n filesDeleted: 0,\n filesSkipped: allFiles.length - parseable.length,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'full',\n };\n }\n\n async runIncrementalWithParsing(onProgress?: (done: number, total: number) => void): Promise<IndexStats> {\n const start = Date.now();\n const lastCommit = this.meta.get('last_indexed_commit') ?? '';\n const currentCommit = getHeadCommit(this.repoRoot);\n\n if (!lastCommit) return this.runFullWithParsing(onProgress);\n if (lastCommit === currentCommit) {\n const metaInfo = this.meta.getIndexMeta();\n return { filesAdded: 0, filesUpdated: 0, filesDeleted: 0, filesSkipped: 0, symbolsTotal: metaInfo.totalSymbols, durationMs: 0, mode: 'incremental' };\n }\n\n const changes = getChangedFiles(this.repoRoot, lastCommit);\n if (!changes) return this.runFullWithParsing(onProgress);\n\n let added = 0, updated = 0, deleted = 0;\n const toReparse: { abs: string; rel: string }[] = [];\n\n for (const change of changes) {\n const absPath = join(this.repoRoot, change.path);\n if (change.status === 'D') {\n const existing = this.files.getByPath(change.path);\n if (existing) {\n this.symbols.deleteByFileId(existing.id);\n this.files.markDeleted(change.path);\n deleted++;\n }\n } else {\n const result = this.indexFile(absPath, change.path);\n if (result !== 'skipped') {\n toReparse.push({ abs: absPath, rel: change.path });\n if (result === 'added') added++; else updated++;\n }\n }\n }\n\n let done = 0;\n for (const { abs, rel } of toReparse) {\n await this.parseAndIndex(abs, rel);\n done++;\n onProgress?.(done, toReparse.length);\n }\n\n this.meta.saveIndexMeta(currentCommit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: deleted,\n filesSkipped: 0,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'incremental',\n };\n }\n}\n","import Parser from 'tree-sitter';\nimport { createRequire } from 'module';\n\nconst req = createRequire(import.meta.url);\n\nexport interface LanguageConfig {\n language: Parser.Language;\n extensions: string[];\n name: string;\n}\n\nlet registry: Map<string, LanguageConfig> | null = null;\n\nfunction buildRegistry(): Map<string, LanguageConfig> {\n const map = new Map<string, LanguageConfig>();\n\n const entries: [string[], string, string, ((mod: unknown) => Parser.Language)?][] = [\n [['.js', '.mjs', '.cjs'], 'javascript', 'tree-sitter-javascript'],\n [['.ts', '.tsx', '.mts', '.cts'], 'typescript', 'tree-sitter-typescript', (m) => (m as { typescript: Parser.Language }).typescript],\n [['.py', '.pyw'], 'python', 'tree-sitter-python'],\n [['.go'], 'go', 'tree-sitter-go'],\n [['.rs'], 'rust', 'tree-sitter-rust'],\n [['.java'], 'java', 'tree-sitter-java'],\n [['.c', '.h'], 'c', 'tree-sitter-c'],\n [['.cpp', '.cc', '.cxx', '.hpp', '.hxx'], 'cpp', 'tree-sitter-cpp'],\n [['.cs'], 'csharp', 'tree-sitter-c-sharp'],\n [['.rb'], 'ruby', 'tree-sitter-ruby'],\n [['.php'], 'php', 'tree-sitter-php', (m) => (m as { php: Parser.Language }).php],\n [['.sh', '.bash'], 'bash', 'tree-sitter-bash'],\n [['.kt', '.kts'], 'kotlin', 'tree-sitter-kotlin'],\n [['.swift'], 'swift', 'tree-sitter-swift'],\n ];\n\n for (const [exts, name, pkg, extract] of entries) {\n try {\n const mod = req(pkg);\n const lang = extract ? extract(mod) : (mod as Parser.Language);\n const config: LanguageConfig = { language: lang, extensions: exts, name };\n for (const ext of exts) map.set(ext, config);\n } catch {\n // grammar not installed or platform unsupported — skip silently\n }\n }\n\n return map;\n}\n\nexport function getRegistry(): Map<string, LanguageConfig> {\n if (!registry) registry = buildRegistry();\n return registry;\n}\n\nexport function getLanguageForExtension(ext: string): LanguageConfig | null {\n return getRegistry().get(ext) ?? null;\n}\n\nexport function extensionFromPath(filePath: string): string {\n const dot = filePath.lastIndexOf('.');\n return dot === -1 ? '' : filePath.slice(dot).toLowerCase();\n}\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const typescriptQueries: LanguageQueries = {\n symbols: `\n (export_statement\n (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_statement\n (class_declaration name: (type_identifier) @name) @node\n (#set! kind \"class\"))\n\n (export_statement\n (interface_declaration name: (type_identifier) @name) @node\n (#set! kind \"interface\"))\n\n (export_statement\n (type_alias_declaration name: (type_identifier) @name) @node\n (#set! kind \"type\"))\n\n (export_statement\n (enum_declaration name: (identifier) @name) @node\n (#set! kind \"enum\"))\n\n (export_statement\n (lexical_declaration\n (variable_declarator name: (identifier) @name)) @node\n (#set! kind \"variable\"))\n\n (export_statement\n declaration: (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_default_declaration\n (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_default_declaration\n (class_declaration name: (type_identifier) @name) @node\n (#set! kind \"class\"))\n `,\n imports: `\n (import_statement\n source: (string (string_fragment) @source)\n (import_clause\n (named_imports\n (import_specifier name: (identifier) @specifier)))) @node\n\n (import_statement\n source: (string (string_fragment) @source)) @node\n `,\n};\n\nexport const javascriptQueries = typescriptQueries;\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const pythonQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (identifier) @name) @node\n\n (class_definition name: (identifier) @name) @node\n\n (expression_statement\n (assignment\n left: (identifier) @name)) @node\n `,\n imports: `\n (import_statement\n name: (dotted_name) @source) @node\n\n (import_from_statement\n module_name: (dotted_name) @source\n name: (import_from_as_names\n (dotted_name) @specifier)) @node\n\n (import_from_statement\n module_name: (dotted_name) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const goQueries: LanguageQueries = {\n symbols: `\n (function_declaration name: (identifier) @name) @node\n\n (method_declaration name: (field_identifier) @name) @node\n\n (type_declaration\n (type_spec name: (type_identifier) @name)) @node\n\n (var_declaration\n (var_spec name: (identifier) @name)) @node\n\n (const_declaration\n (const_spec name: (identifier) @name)) @node\n `,\n imports: `\n (import_spec path: (interpreted_string_literal) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const rustQueries: LanguageQueries = {\n symbols: `\n (function_item name: (identifier) @name) @node\n\n (struct_item name: (type_identifier) @name) @node\n\n (enum_item name: (type_identifier) @name) @node\n\n (trait_item name: (type_identifier) @name) @node\n\n (impl_item type: (type_identifier) @name) @node\n\n (type_item name: (type_identifier) @name) @node\n\n (const_item name: (identifier) @name) @node\n `,\n imports: `\n (use_declaration\n argument: (scoped_identifier path: (identifier) @source)) @node\n\n (extern_crate_declaration name: (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const javaQueries: LanguageQueries = {\n symbols: `\n (class_declaration name: (identifier) @name) @node\n\n (interface_declaration name: (identifier) @name) @node\n\n (enum_declaration name: (identifier) @name) @node\n\n (method_declaration name: (identifier) @name) @node\n\n (field_declaration\n declarator: (variable_declarator name: (identifier) @name)) @node\n `,\n imports: `\n (import_declaration (scoped_identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const cQueries: LanguageQueries = {\n symbols: `\n (function_definition\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (declaration\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (struct_specifier name: (type_identifier) @name) @node\n\n (enum_specifier name: (type_identifier) @name) @node\n\n (type_definition\n declarator: (type_identifier) @name) @node\n `,\n imports: `\n (preproc_include path: (string_literal) @source) @node\n (preproc_include path: (system_lib_string) @source) @node\n `,\n};\n\nexport const cppQueries: LanguageQueries = {\n symbols: `\n (function_definition\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (function_definition\n declarator: (function_declarator\n declarator: (qualified_identifier name: (identifier) @name))) @node\n\n (class_specifier name: (type_identifier) @name) @node\n\n (struct_specifier name: (type_identifier) @name) @node\n\n (enum_specifier name: (type_identifier) @name) @node\n\n (namespace_definition name: (identifier) @name) @node\n `,\n imports: `\n (preproc_include path: (string_literal) @source) @node\n (preproc_include path: (system_lib_string) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const csharpQueries: LanguageQueries = {\n symbols: `\n (class_declaration name: (identifier) @name) @node\n\n (interface_declaration name: (identifier) @name) @node\n\n (enum_declaration name: (identifier) @name) @node\n\n (struct_declaration name: (identifier) @name) @node\n\n (method_declaration name: (identifier) @name) @node\n\n (property_declaration name: (identifier) @name) @node\n\n (record_declaration name: (identifier) @name) @node\n `,\n imports: `\n (using_directive (qualified_name) @source) @node\n (using_directive (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const rubyQueries: LanguageQueries = {\n symbols: `\n (method name: (identifier) @name) @node\n\n (singleton_method name: (identifier) @name) @node\n\n (class name: (constant) @name) @node\n\n (module name: (constant) @name) @node\n `,\n imports: `\n (call\n method: (identifier) @method\n arguments: (argument_list (string (string_content) @source))\n (#match? @method \"^(require|require_relative|load)$\")) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const phpQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (name) @name) @node\n\n (class_declaration name: (name) @name) @node\n\n (interface_declaration name: (name) @name) @node\n\n (trait_declaration name: (name) @name) @node\n\n (enum_declaration name: (name) @name) @node\n\n (method_declaration name: (name) @name) @node\n `,\n imports: `\n (namespace_use_declaration\n (namespace_use_clause (qualified_name) @source)) @node\n\n (require_expression (string (string_value) @source)) @node\n (include_expression (string (string_value) @source)) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const bashQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (word) @name) @node\n `,\n imports: `\n (command\n name: (command_name (word) @cmd)\n argument: (word) @source\n (#match? @cmd \"^(source|\\\\.)$\")) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const kotlinQueries: LanguageQueries = {\n symbols: `\n (function_declaration (simple_identifier) @name) @node\n\n (class_declaration (type_identifier) @name) @node\n\n (object_declaration (type_identifier) @name) @node\n\n (interface_declaration (type_identifier) @name) @node\n `,\n imports: `\n (import_header (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const swiftQueries: LanguageQueries = {\n symbols: `\n (function_declaration name: (simple_identifier) @name) @node\n\n (class_declaration name: (type_identifier) @name) @node\n\n (struct_declaration name: (type_identifier) @name) @node\n\n (enum_declaration name: (type_identifier) @name) @node\n\n (protocol_declaration name: (type_identifier) @name) @node\n\n (typealias_declaration name: (type_identifier) @name) @node\n `,\n imports: `\n (import_declaration (identifier) @source) @node\n `,\n};\n","import Parser from 'tree-sitter';\nimport type { CodeSymbol, SymbolKind } from '../types.js';\nimport { typescriptQueries, javascriptQueries } from './languages/typescript.js';\nimport { pythonQueries } from './languages/python.js';\nimport { goQueries } from './languages/go.js';\nimport { rustQueries } from './languages/rust.js';\nimport { javaQueries } from './languages/java.js';\nimport { cQueries, cppQueries } from './languages/c.js';\nimport { csharpQueries } from './languages/csharp.js';\nimport { rubyQueries } from './languages/ruby.js';\nimport { phpQueries } from './languages/php.js';\nimport { bashQueries } from './languages/bash.js';\nimport { kotlinQueries } from './languages/kotlin.js';\nimport { swiftQueries } from './languages/swift.js';\n\nexport interface LanguageQueries {\n symbols: string;\n imports: string;\n}\n\nconst LANGUAGE_QUERIES: Record<string, LanguageQueries> = {\n typescript: typescriptQueries,\n javascript: javascriptQueries,\n python: pythonQueries,\n go: goQueries,\n rust: rustQueries,\n java: javaQueries,\n c: cQueries,\n cpp: cppQueries,\n csharp: csharpQueries,\n ruby: rubyQueries,\n php: phpQueries,\n bash: bashQueries,\n kotlin: kotlinQueries,\n swift: swiftQueries,\n};\n\nconst KIND_DEFAULTS: Record<string, SymbolKind> = {\n function_definition: 'function',\n function_declaration: 'function',\n function_item: 'function',\n method_declaration: 'method',\n method_definition: 'method',\n class_declaration: 'class',\n class_definition: 'class',\n class_specifier: 'class',\n class_item: 'class',\n interface_declaration: 'interface',\n interface_item: 'interface',\n type_alias_declaration: 'type',\n type_item: 'type',\n type_definition: 'type',\n enum_declaration: 'enum',\n enum_item: 'enum',\n struct_item: 'class',\n struct_specifier: 'class',\n trait_item: 'interface',\n trait_declaration: 'interface',\n export_statement: 'variable',\n lexical_declaration: 'variable',\n var_declaration: 'variable',\n const_item: 'constant',\n const_declaration: 'constant',\n};\n\nfunction inferKind(node: Parser.SyntaxNode): SymbolKind {\n const type = node.type;\n if (KIND_DEFAULTS[type]) return KIND_DEFAULTS[type];\n for (const child of node.children) {\n if (KIND_DEFAULTS[child.type]) return KIND_DEFAULTS[child.type];\n }\n return 'variable';\n}\n\nfunction extractDocComment(node: Parser.SyntaxNode): string | null {\n const prev = node.previousNamedSibling;\n if (!prev) return null;\n const text = prev.text;\n if (text.startsWith('/**') || text.startsWith('///') || text.startsWith('#')) {\n const line = text.split('\\n')[0].replace(/^[/*#\\s]+/, '').trim();\n return line || null;\n }\n return null;\n}\n\nfunction extractSignature(node: Parser.SyntaxNode, name: string): string | null {\n const params = node.childForFieldName('parameters')\n ?? node.children.find(c => c.type === 'formal_parameters' || c.type === 'parameters');\n if (!params) return null;\n const retType = node.childForFieldName('return_type') ?? node.childForFieldName('type');\n const sig = retType ? `${params.text}: ${retType.text}` : params.text;\n return sig.length > 80 ? sig.slice(0, 77) + '...' : sig;\n}\n\nexport function extractSymbols(\n tree: Parser.Tree,\n filePath: string,\n fileId: number,\n language: string,\n source: string,\n): Omit<CodeSymbol, 'id'>[] {\n const queries = LANGUAGE_QUERIES[language];\n if (!queries) return [];\n\n const symbols: Omit<CodeSymbol, 'id'>[] = [];\n const lines = source.split('\\n');\n const isExportedLang = ['typescript', 'javascript'].includes(language);\n\n // Simple AST walk for languages without explicit export syntax\n function walk(node: Parser.SyntaxNode, depth = 0): void {\n const nodeType = node.type;\n const nameNode = node.childForFieldName('name');\n\n if (nameNode && KIND_DEFAULTS[nodeType]) {\n const name = nameNode.text;\n // For TS/JS, only count if inside an export_statement\n const isExported = isExportedLang\n ? (node.parent?.type === 'export_statement' || node.parent?.type === 'export_default_declaration')\n : name.length > 0 && name[0] === name[0].toUpperCase();\n\n if (name && name.length > 0) {\n symbols.push({\n fileId,\n filePath,\n name,\n kind: inferKind(node),\n line: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n isExported,\n signature: extractSignature(node, name),\n docComment: extractDocComment(node),\n parentName: null,\n });\n }\n }\n\n for (const child of node.children) {\n if (depth < 6) walk(child, depth + 1);\n }\n }\n\n walk(tree.rootNode);\n return symbols;\n}\n","import Parser from 'tree-sitter';\nimport { resolve, dirname, extname } from 'path';\nimport type { ImportEdge } from '../types.js';\n\nfunction resolveImportPath(source: string, fromFile: string): { toPath: string | null; toPackage: string | null } {\n if (source.startsWith('.')) {\n const dir = dirname(fromFile);\n let resolved = resolve(dir, source);\n // Add extension if missing\n if (!extname(resolved)) resolved += '.ts';\n return { toPath: resolved, toPackage: null };\n }\n // External package — extract package name\n const parts = source.split('/');\n const pkg = source.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n return { toPath: null, toPackage: pkg };\n}\n\nfunction walkForImports(\n node: Parser.SyntaxNode,\n filePath: string,\n fileId: number,\n language: string,\n edges: Omit<ImportEdge, 'id'>[],\n depth = 0,\n): void {\n if (depth > 4) return;\n\n const type = node.type;\n\n // TypeScript/JavaScript: import_statement\n if (type === 'import_statement') {\n const sourceNode = node.children.find(c => c.type === 'string');\n if (sourceNode) {\n const raw = sourceNode.text.replace(/['\"]/g, '');\n const { toPath, toPackage } = resolveImportPath(raw, filePath);\n const isTypeOnly = node.children.some(c => c.text === 'type');\n const names: string[] = [];\n const namedImports = node.children.find(c => c.type === 'import_clause');\n if (namedImports) {\n const named = namedImports.children.find(c => c.type === 'named_imports');\n if (named) {\n for (const spec of named.children) {\n if (spec.type === 'import_specifier') {\n const n = spec.childForFieldName('name');\n if (n) names.push(n.text);\n }\n }\n }\n if (names.length === 0) names.push('*');\n }\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath, toPackage, importedNames: names, isTypeOnly });\n }\n }\n\n // Python: import_statement / import_from_statement\n if (language === 'python') {\n if (type === 'import_statement') {\n const name = node.children.find(c => c.type === 'dotted_name');\n if (name) {\n const mod = name.text.replace(/\\./g, '/');\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: mod, importedNames: ['*'], isTypeOnly: false });\n }\n }\n if (type === 'import_from_statement') {\n const mod = node.childForFieldName('module_name')?.text ?? '';\n const names: string[] = [];\n const nameList = node.children.find(c => c.type === 'import_from_as_names');\n if (nameList) {\n for (const c of nameList.children) {\n if (c.type === 'dotted_name') names.push(c.text);\n }\n }\n if (names.length === 0) names.push('*');\n const isRelative = mod.startsWith('.');\n const { toPath, toPackage } = isRelative ? resolveImportPath(mod, filePath) : { toPath: null, toPackage: mod };\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath, toPackage, importedNames: names, isTypeOnly: false });\n }\n }\n\n // Go: import_spec\n if (language === 'go' && type === 'import_spec') {\n const pathNode = node.childForFieldName('path');\n if (pathNode) {\n const raw = pathNode.text.replace(/\"/g, '');\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: raw, importedNames: ['*'], isTypeOnly: false });\n }\n }\n\n // Rust: use_declaration\n if (language === 'rust' && type === 'use_declaration') {\n const arg = node.children.find(c => c.type !== 'use' && c.type !== ';');\n if (arg) {\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: arg.text, importedNames: ['*'], isTypeOnly: false });\n }\n }\n\n for (const child of node.children) {\n walkForImports(child, filePath, fileId, language, edges, depth + 1);\n }\n}\n\nexport function extractImports(\n tree: Parser.Tree,\n filePath: string,\n fileId: number,\n language: string,\n): Omit<ImportEdge, 'id'>[] {\n const edges: Omit<ImportEdge, 'id'>[] = [];\n walkForImports(tree.rootNode, filePath, fileId, language, edges);\n return edges;\n}\n","import { createHash } from 'crypto';\n\nexport function hashContent(content: string): string {\n return createHash('sha256').update(content).digest('hex').slice(0, 16);\n}\n","import { glob } from 'glob';\nimport Ignore from 'ignore';\nimport { readFileSync, existsSync } from 'fs';\nimport { join, relative } from 'path';\nimport type { CodePulseConfig } from '../types.js';\n\nexport interface WalkedFile {\n absolutePath: string;\n relativePath: string;\n}\n\nexport async function walkFiles(repoRoot: string, config: CodePulseConfig): Promise<WalkedFile[]> {\n const ig = Ignore.default();\n\n // Load .gitignore if present\n const gitignorePath = join(repoRoot, '.gitignore');\n if (existsSync(gitignorePath)) {\n ig.add(readFileSync(gitignorePath, 'utf8'));\n }\n\n // Add config excludes\n ig.add(config.exclude);\n\n const pattern = '**/*';\n const files = await glob(pattern, {\n cwd: repoRoot,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n const result: WalkedFile[] = [];\n for (const rel of files) {\n if (ig.ignores(rel)) continue;\n result.push({\n absolutePath: join(repoRoot, rel),\n relativePath: rel.replace(/\\\\/g, '/'),\n });\n }\n\n return result;\n}\n","import { execSync } from 'child_process';\n\nexport type ChangeStatus = 'M' | 'A' | 'D' | 'R';\n\nexport interface ChangedFile {\n status: ChangeStatus;\n path: string;\n oldPath?: string;\n}\n\nexport function getHeadCommit(repoRoot: string): string {\n try {\n return execSync('git rev-parse HEAD', { cwd: repoRoot, encoding: 'utf8' }).trim();\n } catch {\n return '';\n }\n}\n\nexport function getChangedFiles(repoRoot: string, sinceCommit: string): ChangedFile[] | null {\n if (!sinceCommit) return null;\n\n try {\n const output = execSync(\n `git diff --name-status ${sinceCommit} HEAD`,\n { cwd: repoRoot, encoding: 'utf8' }\n );\n\n const changes: ChangedFile[] = [];\n for (const line of output.trim().split('\\n')) {\n if (!line) continue;\n const parts = line.split('\\t');\n const rawStatus = parts[0].charAt(0) as ChangeStatus;\n const status = ['M', 'A', 'D', 'R'].includes(rawStatus) ? rawStatus : 'M';\n\n if (status === 'R') {\n changes.push({ status: 'D', path: parts[1] });\n changes.push({ status: 'A', path: parts[2] });\n } else {\n changes.push({ status, path: parts[1] });\n }\n }\n return changes;\n } catch {\n return null;\n }\n}\n","import type { LayerName, CodePulseConfig } from '../types.js';\n\nexport interface LayerBudget {\n layer: LayerName;\n tokens: number;\n}\n\nexport function allocateBudget(\n totalTokens: number,\n config: CodePulseConfig,\n hasFocusPath: boolean,\n layers: LayerName[],\n): LayerBudget[] {\n const weights = { ...config.layerWeights };\n\n if (!hasFocusPath) {\n // Redistribute focus weight to symbol_table\n const focusWeight = weights.focus;\n delete (weights as Record<string, number>).focus;\n const remaining = layers.filter(l => l !== 'focus');\n const total = remaining.reduce((s, l) => s + (weights[l] ?? 0), 0);\n for (const l of remaining) {\n weights[l] = ((weights[l] ?? 0) / total) * (1 - focusWeight / 1) + (l === 'symbol_table' ? focusWeight : 0);\n }\n }\n\n const activeLayers = hasFocusPath ? layers : layers.filter(l => l !== 'focus');\n\n // Normalize weights for active layers\n const activeTotal = activeLayers.reduce((s, l) => s + (weights[l] ?? 0), 0);\n return activeLayers.map(layer => ({\n layer,\n tokens: Math.floor(totalTokens * (weights[layer] ?? 0) / activeTotal),\n }));\n}\n","import { encode } from 'gpt-tokenizer';\n\nexport function countTokens(text: string): number {\n return encode(text).length;\n}\n","import type { DB } from '../../storage/Database.js';\nimport { MetaRepository } from '../../storage/MetaRepository.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\nimport { basename } from 'path';\n\nexport function renderRepoOverview(db: DB, budget: number): { content: string; truncated: boolean } {\n const meta = new MetaRepository(db).getIndexMeta();\n const files = new FileRepository(db);\n const langStats = files.getLanguageStats();\n\n const repoName = basename(meta.repoRoot) || 'unknown';\n const lastIndexed = meta.lastIndexedAt\n ? new Date(meta.lastIndexedAt).toISOString().slice(0, 10)\n : 'never';\n\n const langSummary = langStats\n .slice(0, 8)\n .map(l => `${l.language}: ${l.count}`)\n .join(', ');\n\n const content = [\n `# Repository: ${repoName}`,\n `Files: ${meta.totalFiles} | Symbols: ${meta.totalSymbols} | Last indexed: ${lastIndexed}`,\n `Languages: ${langSummary}`,\n ].join('\\n');\n\n return { content, truncated: countTokens(content) > budget };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nfunction buildTree(paths: string[]): Map<string, Set<string>> {\n const tree = new Map<string, Set<string>>();\n for (const p of paths) {\n const parts = p.split('/');\n // Add each directory level\n for (let i = 1; i < parts.length; i++) {\n const dir = parts.slice(0, i).join('/') || '.';\n if (!tree.has(dir)) tree.set(dir, new Set());\n tree.get(dir)!.add(parts.slice(0, i + 1).join('/'));\n }\n }\n return tree;\n}\n\nfunction renderTree(paths: string[], maxLines: number): string {\n const dirs = new Map<string, string[]>();\n for (const p of paths) {\n const slash = p.lastIndexOf('/');\n const dir = slash === -1 ? '.' : p.slice(0, slash);\n if (!dirs.has(dir)) dirs.set(dir, []);\n dirs.get(dir)!.push(slash === -1 ? p : p.slice(slash + 1));\n }\n\n const lines: string[] = [];\n // Show top-level dirs and their file counts\n const topLevel = new Map<string, number>();\n for (const p of paths) {\n const top = p.split('/')[0];\n topLevel.set(top, (topLevel.get(top) ?? 0) + 1);\n }\n\n for (const [dir, count] of [...topLevel.entries()].sort()) {\n if (lines.length >= maxLines) { lines.push('...'); break; }\n lines.push(`${dir}/ (${count} files)`);\n }\n\n return lines.join('\\n');\n}\n\nexport function renderDirectoryMap(db: DB, budget: number): { content: string; truncated: boolean } {\n const allFiles = new FileRepository(db).getAllActive();\n const paths = allFiles.map(f => f.path);\n const charsPerToken = 4;\n const maxLines = Math.floor((budget * charsPerToken) / 30);\n\n const content = renderTree(paths, maxLines);\n return { content, truncated: countTokens(content) > budget };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nexport function renderSymbolTable(db: DB, budget: number): { content: string; truncated: boolean } {\n const repo = new SymbolRepository(db);\n const symbols = repo.getAllExported();\n\n // Group by file\n const byFile = new Map<string, typeof symbols>();\n for (const s of symbols) {\n if (!byFile.has(s.filePath)) byFile.set(s.filePath, []);\n byFile.get(s.filePath)!.push(s);\n }\n\n // Sort files by symbol count descending (most-exported files first)\n const sorted = [...byFile.entries()].sort((a, b) => b[1].length - a[1].length);\n\n const lines: string[] = [];\n let usedTokens = 0;\n let truncated = false;\n\n for (const [file, syms] of sorted) {\n const header = `### ${file}`;\n const symLines = syms.map(s => {\n const sig = s.signature ? `${s.name}${s.signature}` : s.name;\n const doc = s.docComment ? ` — ${s.docComment}` : '';\n return ` ${s.kind} ${sig}${doc}`;\n });\n\n const block = [header, ...symLines].join('\\n');\n const blockTokens = countTokens(block);\n\n if (usedTokens + blockTokens > budget) {\n truncated = true;\n break;\n }\n\n lines.push(block);\n usedTokens += blockTokens;\n }\n\n return { content: lines.join('\\n\\n'), truncated };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nexport function renderImportGraph(db: DB, budget: number): { content: string; truncated: boolean } {\n const repo = new SymbolRepository(db);\n const hubs = repo.getTopImportedFiles(30);\n\n const lines: string[] = ['### Most-imported modules'];\n let usedTokens = countTokens(lines[0]);\n let truncated = false;\n\n for (const { path, importerCount } of hubs) {\n const line = ` ${path} ← imported by ${importerCount} files`;\n const t = countTokens(line);\n if (usedTokens + t > budget) { truncated = true; break; }\n lines.push(line);\n usedTokens += t;\n }\n\n return { content: lines.join('\\n'), truncated };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nexport function renderFocusLayer(db: DB, focusPath: string, budget: number): { content: string; truncated: boolean } {\n const symRepo = new SymbolRepository(db);\n const fileRepo = new FileRepository(db);\n\n // Find all files under focusPath\n const allFiles = fileRepo.getAllActive().filter(f => f.path.startsWith(focusPath));\n const lines: string[] = [`### Focus: ${focusPath}`];\n let usedTokens = countTokens(lines[0]);\n let truncated = false;\n\n for (const file of allFiles) {\n const syms = symRepo.getExportedByFile(file.path);\n if (syms.length === 0) continue;\n\n const importers = symRepo.getImportersOf(file.path);\n\n const fileLines = [` ${file.path}:`];\n for (const s of syms) {\n const sig = s.signature ? `${s.name}${s.signature}` : s.name;\n fileLines.push(` ${s.kind} ${sig}`);\n }\n if (importers.length > 0) {\n fileLines.push(` ← imported by: ${importers.slice(0, 3).join(', ')}${importers.length > 3 ? ` +${importers.length - 3} more` : ''}`);\n }\n\n const block = fileLines.join('\\n');\n const t = countTokens(block);\n if (usedTokens + t > budget) { truncated = true; break; }\n lines.push(block);\n usedTokens += t;\n }\n\n return { content: lines.join('\\n'), truncated };\n}\n","import type { DB } from '../storage/Database.js';\nimport type { ContextRequest, ContextResult, LayerResult, LayerName, CodePulseConfig } from '../types.js';\nimport { allocateBudget } from './BudgetAllocator.js';\nimport { renderRepoOverview } from './layers/RepoOverviewLayer.js';\nimport { renderDirectoryMap } from './layers/DirectoryMapLayer.js';\nimport { renderSymbolTable } from './layers/SymbolTableLayer.js';\nimport { renderImportGraph } from './layers/ImportGraphLayer.js';\nimport { renderFocusLayer } from './layers/FocusLayer.js';\nimport { countTokens } from './TokenCounter.js';\n\nconst DEFAULT_LAYERS: LayerName[] = ['repo_overview', 'directory_map', 'symbol_table', 'import_graph', 'focus'];\n\nfunction renderLayer(db: DB, layer: LayerName, budget: number, focusPath?: string): { content: string; truncated: boolean } {\n switch (layer) {\n case 'repo_overview': return renderRepoOverview(db, budget);\n case 'directory_map': return renderDirectoryMap(db, budget);\n case 'symbol_table': return renderSymbolTable(db, budget);\n case 'import_graph': return renderImportGraph(db, budget);\n case 'focus': return focusPath ? renderFocusLayer(db, focusPath, budget) : { content: '', truncated: false };\n default: return { content: '', truncated: false };\n }\n}\n\nfunction wrapMarkdown(layers: LayerResult[]): string {\n return layers.map(l => l.content).filter(Boolean).join('\\n\\n');\n}\n\nfunction wrapXML(layers: LayerResult[]): string {\n const inner = layers\n .filter(l => l.content)\n .map(l => ` <${l.layer}>\\n${l.content}\\n </${l.layer}>`)\n .join('\\n');\n return `<codebase_context>\\n${inner}\\n</codebase_context>`;\n}\n\nexport function generateContext(db: DB, request: ContextRequest, config: CodePulseConfig): ContextResult {\n const layers = request.layers ?? DEFAULT_LAYERS;\n const hasFocus = Boolean(request.focusPath);\n\n const budgets = allocateBudget(request.budgetTokens, config, hasFocus, layers);\n\n let remainingSurplus = 0;\n const results: LayerResult[] = [];\n\n for (const { layer, tokens } of budgets) {\n const layerBudget = tokens + remainingSurplus;\n const { content, truncated } = renderLayer(db, layer, layerBudget, request.focusPath);\n const used = countTokens(content);\n remainingSurplus = truncated ? 0 : layerBudget - used;\n\n results.push({ layer, tokensUsed: used, content, truncated });\n }\n\n const rendered = request.format === 'xml' ? wrapXML(results) : wrapMarkdown(results);\n const totalTokens = countTokens(rendered);\n\n return {\n totalTokens,\n budgetTokens: request.budgetTokens,\n layers: results,\n rendered,\n };\n}\n"],"mappings":";AAoFO,IAAM,iBAAkC;AAAA,EAC7C,SAAS,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,SAAS,eAAe,UAAU;AAAA,EACrF,kBAAkB,MAAM;AAAA,EACxB,qBAAqB;AAAA,EACrB,cAAc;AAAA,IACZ,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA,IACd,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AACF;;;AC/FA,OAAO,mBAAmB;AAE1B,IAAM,iBAAiB;AAEvB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDZ,SAAS,aAAa,QAAoB;AAC/C,QAAM,KAAK,IAAI,cAAc,MAAM;AACnC,KAAG,OAAO,oBAAoB;AAC9B,KAAG,OAAO,mBAAmB;AAC7B,gBAAc,EAAE;AAChB,SAAO;AACT;AAEA,SAAS,cAAc,IAAc;AACnC,KAAG,KAAK,UAAU;AAElB,QAAM,WAAW,GAAG,QAAQ,2DAA2D,EAAE,IAAI;AAC7F,MAAI,CAAC,UAAU;AACb,OAAG,QAAQ,kEAAkE,EAAE,IAAI,OAAO,cAAc,CAAC;AAAA,EAC3G;AACF;;;ACnEA,SAAS,UAAU,K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AAO;AAAA,EAAuB,KAAK;AAAA;AACrC;AAEO,SAAS,gBAAgB,IAAQ,SAAyB,QAAwC;AACvG,QAAM,SAAS,QAAQ,UAAU;AACjC,QAAM,WAAW,QAAQ,QAAQ,SAAS;AAE1C,QAAM,UAAU,eAAe,QAAQ,cAAc,QAAQ,UAAU,MAAM;AAE7E,MAAI,mBAAmB;AACvB,QAAM,UAAyB,CAAC;AAEhC,aAAW,EAAE,OAAO,OAAO,KAAK,SAAS;AACvC,UAAM,cAAc,SAAS;AAC7B,UAAM,EAAE,SAAS,UAAU,IAAI,YAAY,IAAI,OAAO,aAAa,QAAQ,SAAS;AACpF,UAAM,OAAO,YAAY,OAAO;AAChC,uBAAmB,YAAY,IAAI,cAAc;AAEjD,YAAQ,KAAK,EAAE,OAAO,YAAY,MAAM,SAAS,UAAU,CAAC;AAAA,EAC9D;AAEA,QAAM,WAAW,QAAQ,WAAW,QAAQ,QAAQ,OAAO,IAAI,aAAa,OAAO;AACnF,QAAM,cAAc,YAAY,QAAQ;AAExC,SAAO;AAAA,IACL;AAAA,IACA,cAAc,QAAQ;AAAA,IACtB,QAAQ;AAAA,IACR;AAAA,EACF;AACF;","names":["readFileSync","join","join","readFileSync","metaInfo"]}
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/storage/Database.ts","../src/storage/FileRepository.ts","../src/storage/SymbolRepository.ts","../src/storage/MetaRepository.ts","../src/indexer/Indexer.ts","../src/parser/ParserRegistry.ts","../src/parser/languages/typescript.ts","../src/parser/languages/python.ts","../src/parser/languages/go.ts","../src/parser/languages/rust.ts","../src/parser/languages/java.ts","../src/parser/languages/c.ts","../src/parser/languages/csharp.ts","../src/parser/languages/ruby.ts","../src/parser/languages/php.ts","../src/parser/languages/bash.ts","../src/parser/languages/kotlin.ts","../src/parser/languages/swift.ts","../src/parser/SymbolExtractor.ts","../src/parser/ImportExtractor.ts","../src/indexer/HashUtil.ts","../src/indexer/FileWalker.ts","../src/indexer/GitDiff.ts","../src/context/BudgetAllocator.ts","../src/context/TokenCounter.ts","../src/context/layers/RepoOverviewLayer.ts","../src/context/layers/DirectoryMapLayer.ts","../src/context/TaskAnalyzer.ts","../src/context/layers/SymbolTableLayer.ts","../src/context/layers/ImportGraphLayer.ts","../src/context/layers/FocusLayer.ts","../src/context/ContextGenerator.ts"],"sourcesContent":["export interface IndexMeta {\n schemaVersion: number;\n lastIndexedCommit: string;\n lastIndexedAt: number;\n repoRoot: string;\n totalFiles: number;\n totalSymbols: number;\n}\n\nexport type SymbolKind =\n | 'function' | 'class' | 'interface' | 'type' | 'enum'\n | 'variable' | 'constant' | 'method' | 'property' | 'module';\n\nexport interface FileRecord {\n id: number;\n path: string;\n language: string;\n contentHash: string;\n sizeBytes: number;\n linesTotal: number;\n indexedAt: number;\n isDeleted: boolean;\n}\n\nexport interface CodeSymbol {\n id: number;\n fileId: number;\n filePath: string;\n name: string;\n kind: SymbolKind;\n line: number;\n endLine: number;\n isExported: boolean;\n signature: string | null;\n docComment: string | null;\n parentName: string | null;\n}\n\nexport interface ImportEdge {\n id: number;\n fromFileId: number;\n fromPath: string;\n toPath: string | null;\n toPackage: string | null;\n importedNames: string[];\n isTypeOnly: boolean;\n}\n\nexport type LayerName =\n | 'repo_overview'\n | 'directory_map'\n | 'symbol_table'\n | 'import_graph'\n | 'focus';\n\nexport interface ContextRequest {\n budgetTokens: number;\n focusPath?: string;\n format: 'markdown' | 'xml';\n layers?: LayerName[];\n taskKeywords?: string[]; // rank content by relevance to these keywords\n autoBudget?: boolean; // scale budget automatically by repo size\n}\n\nexport interface LayerResult {\n layer: LayerName;\n tokensUsed: number;\n content: string;\n truncated: boolean;\n}\n\nexport interface ContextResult {\n totalTokens: number;\n budgetTokens: number;\n layers: LayerResult[];\n rendered: string;\n skipped?: boolean;\n}\n\nexport interface CodePulseConfig {\n exclude: string[];\n maxFileSizeBytes: number;\n defaultBudgetTokens: number;\n layerWeights: Record<LayerName, number>;\n languages?: string[];\n}\n\nexport const DEFAULT_CONFIG: CodePulseConfig = {\n exclude: ['node_modules', '.git', 'dist', 'build', '.next', '__pycache__', '*.min.js'],\n maxFileSizeBytes: 512 * 1024,\n defaultBudgetTokens: 4000,\n layerWeights: {\n repo_overview: 0.10,\n directory_map: 0.20,\n symbol_table: 0.45,\n import_graph: 0.15,\n focus: 0.10,\n },\n};\n","import BetterSqlite3 from 'better-sqlite3';\n\nconst SCHEMA_VERSION = 1;\n\nconst SCHEMA_SQL = `\nCREATE TABLE IF NOT EXISTS index_meta (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS file_records (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n path TEXT NOT NULL UNIQUE,\n language TEXT NOT NULL,\n content_hash TEXT NOT NULL,\n size_bytes INTEGER NOT NULL,\n lines_total INTEGER NOT NULL,\n indexed_at INTEGER NOT NULL,\n is_deleted INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_file_language ON file_records(language);\nCREATE INDEX IF NOT EXISTS idx_file_deleted ON file_records(is_deleted);\n\nCREATE TABLE IF NOT EXISTS symbols (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n file_id INTEGER NOT NULL REFERENCES file_records(id) ON DELETE CASCADE,\n file_path TEXT NOT NULL,\n name TEXT NOT NULL,\n kind TEXT NOT NULL,\n line INTEGER NOT NULL,\n end_line INTEGER NOT NULL,\n is_exported INTEGER NOT NULL DEFAULT 0,\n signature TEXT,\n doc_comment TEXT,\n parent_name TEXT\n);\nCREATE INDEX IF NOT EXISTS idx_symbol_file ON symbols(file_id);\nCREATE INDEX IF NOT EXISTS idx_symbol_name ON symbols(name);\nCREATE INDEX IF NOT EXISTS idx_symbol_exported ON symbols(is_exported);\n\nCREATE TABLE IF NOT EXISTS import_edges (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n from_file_id INTEGER NOT NULL REFERENCES file_records(id) ON DELETE CASCADE,\n from_path TEXT NOT NULL,\n to_path TEXT,\n to_package TEXT,\n imported_names TEXT NOT NULL,\n is_type_only INTEGER NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_import_from ON import_edges(from_file_id);\nCREATE INDEX IF NOT EXISTS idx_import_to ON import_edges(to_path);\n`;\n\nexport type DB = BetterSqlite3.Database;\n\nexport function openDatabase(dbPath: string): DB {\n const db = new BetterSqlite3(dbPath);\n db.pragma('journal_mode = WAL');\n db.pragma('foreign_keys = ON');\n runMigrations(db);\n return db;\n}\n\nfunction runMigrations(db: DB): void {\n db.exec(SCHEMA_SQL);\n\n const existing = db.prepare(\"SELECT value FROM index_meta WHERE key = 'schema_version'\").get() as { value: string } | undefined;\n if (!existing) {\n db.prepare(\"INSERT INTO index_meta (key, value) VALUES ('schema_version', ?)\").run(String(SCHEMA_VERSION));\n }\n}\n","import type { DB } from './Database.js';\nimport type { FileRecord } from '../types.js';\n\nfunction rowToFile(row: Record<string, unknown>): FileRecord {\n return {\n id: row.id as number,\n path: row.path as string,\n language: row.language as string,\n contentHash: row.content_hash as string,\n sizeBytes: row.size_bytes as number,\n linesTotal: row.lines_total as number,\n indexedAt: row.indexed_at as number,\n isDeleted: Boolean(row.is_deleted),\n };\n}\n\nexport class FileRepository {\n constructor(private db: DB) {}\n\n upsert(file: Omit<FileRecord, 'id'>): number {\n const result = this.db.prepare(`\n INSERT INTO file_records (path, language, content_hash, size_bytes, lines_total, indexed_at, is_deleted)\n VALUES (@path, @language, @contentHash, @sizeBytes, @linesTotal, @indexedAt, @isDeleted)\n ON CONFLICT(path) DO UPDATE SET\n language = excluded.language,\n content_hash = excluded.content_hash,\n size_bytes = excluded.size_bytes,\n lines_total = excluded.lines_total,\n indexed_at = excluded.indexed_at,\n is_deleted = excluded.is_deleted\n `).run({\n path: file.path,\n language: file.language,\n contentHash: file.contentHash,\n sizeBytes: file.sizeBytes,\n linesTotal: file.linesTotal,\n indexedAt: file.indexedAt,\n isDeleted: file.isDeleted ? 1 : 0,\n });\n return result.lastInsertRowid as number;\n }\n\n getByPath(path: string): FileRecord | null {\n const row = this.db.prepare('SELECT * FROM file_records WHERE path = ?').get(path) as Record<string, unknown> | undefined;\n return row ? rowToFile(row) : null;\n }\n\n markDeleted(path: string): void {\n this.db.prepare('UPDATE file_records SET is_deleted = 1 WHERE path = ?').run(path);\n }\n\n getAllActive(): FileRecord[] {\n const rows = this.db.prepare('SELECT * FROM file_records WHERE is_deleted = 0 ORDER BY path').all() as Record<string, unknown>[];\n return rows.map(rowToFile);\n }\n\n getLanguageStats(): { language: string; count: number }[] {\n return this.db.prepare(`\n SELECT language, COUNT(*) as count\n FROM file_records WHERE is_deleted = 0\n GROUP BY language ORDER BY count DESC\n `).all() as { language: string; count: number }[];\n }\n}\n","import type { DB } from './Database.js';\nimport type { CodeSymbol, ImportEdge } from '../types.js';\n\nfunction rowToSymbol(row: Record<string, unknown>): CodeSymbol {\n return {\n id: row.id as number,\n fileId: row.file_id as number,\n filePath: row.file_path as string,\n name: row.name as string,\n kind: row.kind as CodeSymbol['kind'],\n line: row.line as number,\n endLine: row.end_line as number,\n isExported: Boolean(row.is_exported),\n signature: row.signature as string | null,\n docComment: row.doc_comment as string | null,\n parentName: row.parent_name as string | null,\n };\n}\n\nfunction rowToImport(row: Record<string, unknown>): ImportEdge {\n return {\n id: row.id as number,\n fromFileId: row.from_file_id as number,\n fromPath: row.from_path as string,\n toPath: row.to_path as string | null,\n toPackage: row.to_package as string | null,\n importedNames: JSON.parse(row.imported_names as string),\n isTypeOnly: Boolean(row.is_type_only),\n };\n}\n\nexport class SymbolRepository {\n constructor(private db: DB) {}\n\n insertSymbols(fileId: number, symbols: Omit<CodeSymbol, 'id'>[]): void {\n const stmt = this.db.prepare(`\n INSERT INTO symbols (file_id, file_path, name, kind, line, end_line, is_exported, signature, doc_comment, parent_name)\n VALUES (@fileId, @filePath, @name, @kind, @line, @endLine, @isExported, @signature, @docComment, @parentName)\n `);\n for (const s of symbols) {\n stmt.run({\n fileId: s.fileId,\n filePath: s.filePath,\n name: s.name,\n kind: s.kind,\n line: s.line,\n endLine: s.endLine,\n isExported: s.isExported ? 1 : 0,\n signature: s.signature,\n docComment: s.docComment,\n parentName: s.parentName,\n });\n }\n }\n\n insertImports(fileId: number, edges: Omit<ImportEdge, 'id'>[]): void {\n const stmt = this.db.prepare(`\n INSERT INTO import_edges (from_file_id, from_path, to_path, to_package, imported_names, is_type_only)\n VALUES (@fromFileId, @fromPath, @toPath, @toPackage, @importedNames, @isTypeOnly)\n `);\n for (const e of edges) {\n stmt.run({\n fromFileId: e.fromFileId,\n fromPath: e.fromPath,\n toPath: e.toPath,\n toPackage: e.toPackage,\n importedNames: JSON.stringify(e.importedNames),\n isTypeOnly: e.isTypeOnly ? 1 : 0,\n });\n }\n }\n\n deleteByFileId(fileId: number): void {\n this.db.prepare('DELETE FROM symbols WHERE file_id = ?').run(fileId);\n this.db.prepare('DELETE FROM import_edges WHERE from_file_id = ?').run(fileId);\n }\n\n getExportedByFile(filePath: string): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE file_path = ? AND is_exported = 1 ORDER BY line'\n ).all(filePath) as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n getAllExported(): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE is_exported = 1 ORDER BY file_path, line'\n ).all() as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n search(query: string, limit = 20): CodeSymbol[] {\n const rows = this.db.prepare(\n 'SELECT * FROM symbols WHERE name LIKE ? AND is_exported = 1 LIMIT ?'\n ).all(`%${query}%`, limit) as Record<string, unknown>[];\n return rows.map(rowToSymbol);\n }\n\n getImportsFrom(filePath: string): ImportEdge[] {\n const rows = this.db.prepare(\n 'SELECT * FROM import_edges WHERE from_path = ?'\n ).all(filePath) as Record<string, unknown>[];\n return rows.map(rowToImport);\n }\n\n getImportersOf(filePath: string): string[] {\n const rows = this.db.prepare(\n 'SELECT DISTINCT from_path FROM import_edges WHERE to_path = ?'\n ).all(filePath) as { from_path: string }[];\n return rows.map(r => r.from_path);\n }\n\n getTopImportedFiles(limit = 20): { path: string; importerCount: number }[] {\n return this.db.prepare(`\n SELECT to_path as path, COUNT(*) as importerCount\n FROM import_edges WHERE to_path IS NOT NULL\n GROUP BY to_path ORDER BY importerCount DESC LIMIT ?\n `).all(limit) as { path: string; importerCount: number }[];\n }\n}\n","import type { DB } from './Database.js';\nimport type { IndexMeta } from '../types.js';\n\nexport class MetaRepository {\n constructor(private db: DB) {}\n\n get(key: string): string | null {\n const row = this.db.prepare('SELECT value FROM index_meta WHERE key = ?').get(key) as { value: string } | undefined;\n return row?.value ?? null;\n }\n\n set(key: string, value: string): void {\n this.db.prepare('INSERT OR REPLACE INTO index_meta (key, value) VALUES (?, ?)').run(key, value);\n }\n\n getIndexMeta(): IndexMeta {\n const fileCount = (this.db.prepare(\"SELECT COUNT(*) as c FROM file_records WHERE is_deleted = 0\").get() as { c: number }).c;\n const symbolCount = (this.db.prepare(\"SELECT COUNT(*) as c FROM symbols\").get() as { c: number }).c;\n return {\n schemaVersion: Number(this.get('schema_version') ?? 1),\n lastIndexedCommit: this.get('last_indexed_commit') ?? '',\n lastIndexedAt: Number(this.get('last_indexed_at') ?? 0),\n repoRoot: this.get('repo_root') ?? '',\n totalFiles: fileCount,\n totalSymbols: symbolCount,\n };\n }\n\n saveIndexMeta(commit: string, repoRoot: string): void {\n this.set('last_indexed_commit', commit);\n this.set('last_indexed_at', String(Date.now()));\n this.set('repo_root', repoRoot);\n }\n}\n","import Parser from 'tree-sitter';\nimport { readFileSync, statSync } from 'fs';\nimport { join } from 'path';\nimport type { DB } from '../storage/Database.js';\nimport { FileRepository } from '../storage/FileRepository.js';\nimport { SymbolRepository } from '../storage/SymbolRepository.js';\nimport { MetaRepository } from '../storage/MetaRepository.js';\nimport { getLanguageForExtension, extensionFromPath } from '../parser/ParserRegistry.js';\nimport { extractSymbols } from '../parser/SymbolExtractor.js';\nimport { extractImports } from '../parser/ImportExtractor.js';\nimport { hashContent } from './HashUtil.js';\nimport { walkFiles } from './FileWalker.js';\nimport { getHeadCommit, getChangedFiles } from './GitDiff.js';\nimport type { CodePulseConfig } from '../types.js';\n\nexport interface IndexStats {\n filesAdded: number;\n filesUpdated: number;\n filesDeleted: number;\n filesSkipped: number;\n symbolsTotal: number;\n durationMs: number;\n mode: 'full' | 'incremental';\n}\n\nexport class Indexer {\n private parser = new Parser();\n private files: FileRepository;\n private symbols: SymbolRepository;\n private meta: MetaRepository;\n\n constructor(private db: DB, private repoRoot: string, private config: CodePulseConfig) {\n this.files = new FileRepository(db);\n this.symbols = new SymbolRepository(db);\n this.meta = new MetaRepository(db);\n }\n\n async runFull(): Promise<IndexStats> {\n const start = Date.now();\n const allFiles = await walkFiles(this.repoRoot, this.config);\n let added = 0, updated = 0, skipped = 0;\n\n const transaction = this.db.transaction(() => {\n for (const { absolutePath, relativePath } of allFiles) {\n const result = this.indexFile(absolutePath, relativePath);\n if (result === 'added') added++;\n else if (result === 'updated') updated++;\n else skipped++;\n }\n });\n transaction();\n\n const commit = getHeadCommit(this.repoRoot);\n this.meta.saveIndexMeta(commit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: 0,\n filesSkipped: skipped,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'full',\n };\n }\n\n async runIncremental(): Promise<IndexStats> {\n const start = Date.now();\n const lastCommit = this.meta.get('last_indexed_commit') ?? '';\n const currentCommit = getHeadCommit(this.repoRoot);\n\n // Fall back to full scan if no prior index or git unavailable\n if (!lastCommit || lastCommit === currentCommit) {\n if (!lastCommit) return this.runFull();\n return { filesAdded: 0, filesUpdated: 0, filesDeleted: 0, filesSkipped: 0, symbolsTotal: this.meta.getIndexMeta().totalSymbols, durationMs: 0, mode: 'incremental' };\n }\n\n const changes = getChangedFiles(this.repoRoot, lastCommit);\n if (!changes) return this.runFull();\n\n let added = 0, updated = 0, deleted = 0, skipped = 0;\n\n const transaction = this.db.transaction(() => {\n for (const change of changes) {\n const absPath = join(this.repoRoot, change.path);\n if (change.status === 'D') {\n const existing = this.files.getByPath(change.path);\n if (existing) {\n this.symbols.deleteByFileId(existing.id);\n this.files.markDeleted(change.path);\n deleted++;\n }\n } else {\n const result = this.indexFile(absPath, change.path);\n if (result === 'added') added++;\n else if (result === 'updated') updated++;\n else skipped++;\n }\n }\n });\n transaction();\n\n this.meta.saveIndexMeta(currentCommit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: deleted,\n filesSkipped: skipped,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'incremental',\n };\n }\n\n private indexFile(absolutePath: string, relativePath: string): 'added' | 'updated' | 'skipped' {\n let stat;\n try {\n stat = statSync(absolutePath);\n } catch {\n return 'skipped';\n }\n\n if (stat.size > this.config.maxFileSizeBytes) return 'skipped';\n\n const ext = extensionFromPath(relativePath);\n // We'll still record file even if no parser — skip symbol extraction only\n let content: string;\n try {\n content = readFileSync(absolutePath, 'utf8');\n } catch {\n return 'skipped';\n }\n\n const contentHash = hashContent(content);\n const existing = this.files.getByPath(relativePath);\n\n if (existing && existing.contentHash === contentHash && !existing.isDeleted) {\n return 'skipped';\n }\n\n const isNew = !existing;\n const lines = content.split('\\n').length;\n\n const langConfig = null; // resolved below async — we need sync parsing\n // Note: language config loading done synchronously via cached registry\n const fileId = this.files.upsert({\n path: relativePath,\n language: 'unknown',\n contentHash,\n sizeBytes: stat.size,\n linesTotal: lines,\n indexedAt: Date.now(),\n isDeleted: false,\n });\n\n // We use the actual file id (insert returns rowid, but on conflict we need the real id)\n const record = this.files.getByPath(relativePath);\n if (!record) return 'skipped';\n\n this.symbols.deleteByFileId(record.id);\n\n // Return early — async language loading handled in parseAndStore\n return isNew ? 'added' : 'updated';\n }\n\n async parseAndIndex(absolutePath: string, relativePath: string): Promise<void> {\n const langConfig = getLanguageForExtension(extensionFromPath(relativePath));\n if (!langConfig) return;\n\n let content: string;\n try {\n content = readFileSync(absolutePath, 'utf8');\n } catch {\n return;\n }\n\n this.parser.setLanguage(langConfig.language);\n const tree = this.parser.parse(content);\n\n const record = this.files.getByPath(relativePath);\n if (!record) return;\n\n // Update language now that we know it\n this.files.upsert({ ...record, language: langConfig.name });\n\n const symbols = extractSymbols(tree, relativePath, record.id, langConfig.name, content);\n const imports = extractImports(tree, relativePath, record.id, langConfig.name);\n\n this.symbols.deleteByFileId(record.id);\n if (symbols.length > 0) this.symbols.insertSymbols(record.id, symbols);\n if (imports.length > 0) this.symbols.insertImports(record.id, imports);\n }\n\n async runFullWithParsing(onProgress?: (done: number, total: number) => void): Promise<IndexStats> {\n const start = Date.now();\n const allFiles = await walkFiles(this.repoRoot, this.config);\n\n // First pass: record all files synchronously\n const transaction = this.db.transaction(() => {\n for (const { absolutePath, relativePath } of allFiles) {\n this.indexFile(absolutePath, relativePath);\n }\n });\n transaction();\n\n // Second pass: parse all files async (Tree-Sitter is sync but language loading is async)\n const parseable = allFiles.filter(f => {\n const ext = extensionFromPath(f.relativePath);\n return ext !== '';\n });\n\n let done = 0;\n for (const { absolutePath, relativePath } of parseable) {\n await this.parseAndIndex(absolutePath, relativePath);\n done++;\n onProgress?.(done, parseable.length);\n }\n\n const commit = getHeadCommit(this.repoRoot);\n this.meta.saveIndexMeta(commit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: parseable.length,\n filesUpdated: 0,\n filesDeleted: 0,\n filesSkipped: allFiles.length - parseable.length,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'full',\n };\n }\n\n async runIncrementalWithParsing(onProgress?: (done: number, total: number) => void): Promise<IndexStats> {\n const start = Date.now();\n const lastCommit = this.meta.get('last_indexed_commit') ?? '';\n const currentCommit = getHeadCommit(this.repoRoot);\n\n if (!lastCommit) return this.runFullWithParsing(onProgress);\n if (lastCommit === currentCommit) {\n const metaInfo = this.meta.getIndexMeta();\n return { filesAdded: 0, filesUpdated: 0, filesDeleted: 0, filesSkipped: 0, symbolsTotal: metaInfo.totalSymbols, durationMs: 0, mode: 'incremental' };\n }\n\n const changes = getChangedFiles(this.repoRoot, lastCommit);\n if (!changes) return this.runFullWithParsing(onProgress);\n\n let added = 0, updated = 0, deleted = 0;\n const toReparse: { abs: string; rel: string }[] = [];\n\n for (const change of changes) {\n const absPath = join(this.repoRoot, change.path);\n if (change.status === 'D') {\n const existing = this.files.getByPath(change.path);\n if (existing) {\n this.symbols.deleteByFileId(existing.id);\n this.files.markDeleted(change.path);\n deleted++;\n }\n } else {\n const result = this.indexFile(absPath, change.path);\n if (result !== 'skipped') {\n toReparse.push({ abs: absPath, rel: change.path });\n if (result === 'added') added++; else updated++;\n }\n }\n }\n\n let done = 0;\n for (const { abs, rel } of toReparse) {\n await this.parseAndIndex(abs, rel);\n done++;\n onProgress?.(done, toReparse.length);\n }\n\n this.meta.saveIndexMeta(currentCommit, this.repoRoot);\n\n const metaInfo = this.meta.getIndexMeta();\n return {\n filesAdded: added,\n filesUpdated: updated,\n filesDeleted: deleted,\n filesSkipped: 0,\n symbolsTotal: metaInfo.totalSymbols,\n durationMs: Date.now() - start,\n mode: 'incremental',\n };\n }\n}\n","import Parser from 'tree-sitter';\nimport { createRequire } from 'module';\n\nconst req = createRequire(import.meta.url);\n\nexport interface LanguageConfig {\n language: Parser.Language;\n extensions: string[];\n name: string;\n}\n\nlet registry: Map<string, LanguageConfig> | null = null;\n\nfunction buildRegistry(): Map<string, LanguageConfig> {\n const map = new Map<string, LanguageConfig>();\n\n const entries: [string[], string, string, ((mod: unknown) => Parser.Language)?][] = [\n [['.js', '.mjs', '.cjs'], 'javascript', 'tree-sitter-javascript'],\n [['.ts', '.tsx', '.mts', '.cts'], 'typescript', 'tree-sitter-typescript', (m) => (m as { typescript: Parser.Language }).typescript],\n [['.py', '.pyw'], 'python', 'tree-sitter-python'],\n [['.go'], 'go', 'tree-sitter-go'],\n [['.rs'], 'rust', 'tree-sitter-rust'],\n [['.java'], 'java', 'tree-sitter-java'],\n [['.c', '.h'], 'c', 'tree-sitter-c'],\n [['.cpp', '.cc', '.cxx', '.hpp', '.hxx'], 'cpp', 'tree-sitter-cpp'],\n [['.cs'], 'csharp', 'tree-sitter-c-sharp'],\n [['.rb'], 'ruby', 'tree-sitter-ruby'],\n [['.php'], 'php', 'tree-sitter-php', (m) => (m as { php: Parser.Language }).php],\n [['.sh', '.bash'], 'bash', 'tree-sitter-bash'],\n [['.kt', '.kts'], 'kotlin', 'tree-sitter-kotlin'],\n [['.swift'], 'swift', 'tree-sitter-swift'],\n ];\n\n for (const [exts, name, pkg, extract] of entries) {\n try {\n const mod = req(pkg);\n const lang = extract ? extract(mod) : (mod as Parser.Language);\n const config: LanguageConfig = { language: lang, extensions: exts, name };\n for (const ext of exts) map.set(ext, config);\n } catch {\n // grammar not installed or platform unsupported — skip silently\n }\n }\n\n return map;\n}\n\nexport function getRegistry(): Map<string, LanguageConfig> {\n if (!registry) registry = buildRegistry();\n return registry;\n}\n\nexport function getLanguageForExtension(ext: string): LanguageConfig | null {\n return getRegistry().get(ext) ?? null;\n}\n\nexport function extensionFromPath(filePath: string): string {\n const dot = filePath.lastIndexOf('.');\n return dot === -1 ? '' : filePath.slice(dot).toLowerCase();\n}\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const typescriptQueries: LanguageQueries = {\n symbols: `\n (export_statement\n (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_statement\n (class_declaration name: (type_identifier) @name) @node\n (#set! kind \"class\"))\n\n (export_statement\n (interface_declaration name: (type_identifier) @name) @node\n (#set! kind \"interface\"))\n\n (export_statement\n (type_alias_declaration name: (type_identifier) @name) @node\n (#set! kind \"type\"))\n\n (export_statement\n (enum_declaration name: (identifier) @name) @node\n (#set! kind \"enum\"))\n\n (export_statement\n (lexical_declaration\n (variable_declarator name: (identifier) @name)) @node\n (#set! kind \"variable\"))\n\n (export_statement\n declaration: (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_default_declaration\n (function_declaration name: (identifier) @name) @node\n (#set! kind \"function\"))\n\n (export_default_declaration\n (class_declaration name: (type_identifier) @name) @node\n (#set! kind \"class\"))\n `,\n imports: `\n (import_statement\n source: (string (string_fragment) @source)\n (import_clause\n (named_imports\n (import_specifier name: (identifier) @specifier)))) @node\n\n (import_statement\n source: (string (string_fragment) @source)) @node\n `,\n};\n\nexport const javascriptQueries = typescriptQueries;\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const pythonQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (identifier) @name) @node\n\n (class_definition name: (identifier) @name) @node\n\n (expression_statement\n (assignment\n left: (identifier) @name)) @node\n `,\n imports: `\n (import_statement\n name: (dotted_name) @source) @node\n\n (import_from_statement\n module_name: (dotted_name) @source\n name: (import_from_as_names\n (dotted_name) @specifier)) @node\n\n (import_from_statement\n module_name: (dotted_name) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const goQueries: LanguageQueries = {\n symbols: `\n (function_declaration name: (identifier) @name) @node\n\n (method_declaration name: (field_identifier) @name) @node\n\n (type_declaration\n (type_spec name: (type_identifier) @name)) @node\n\n (var_declaration\n (var_spec name: (identifier) @name)) @node\n\n (const_declaration\n (const_spec name: (identifier) @name)) @node\n `,\n imports: `\n (import_spec path: (interpreted_string_literal) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const rustQueries: LanguageQueries = {\n symbols: `\n (function_item name: (identifier) @name) @node\n\n (struct_item name: (type_identifier) @name) @node\n\n (enum_item name: (type_identifier) @name) @node\n\n (trait_item name: (type_identifier) @name) @node\n\n (impl_item type: (type_identifier) @name) @node\n\n (type_item name: (type_identifier) @name) @node\n\n (const_item name: (identifier) @name) @node\n `,\n imports: `\n (use_declaration\n argument: (scoped_identifier path: (identifier) @source)) @node\n\n (extern_crate_declaration name: (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const javaQueries: LanguageQueries = {\n symbols: `\n (class_declaration name: (identifier) @name) @node\n\n (interface_declaration name: (identifier) @name) @node\n\n (enum_declaration name: (identifier) @name) @node\n\n (method_declaration name: (identifier) @name) @node\n\n (field_declaration\n declarator: (variable_declarator name: (identifier) @name)) @node\n `,\n imports: `\n (import_declaration (scoped_identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const cQueries: LanguageQueries = {\n symbols: `\n (function_definition\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (declaration\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (struct_specifier name: (type_identifier) @name) @node\n\n (enum_specifier name: (type_identifier) @name) @node\n\n (type_definition\n declarator: (type_identifier) @name) @node\n `,\n imports: `\n (preproc_include path: (string_literal) @source) @node\n (preproc_include path: (system_lib_string) @source) @node\n `,\n};\n\nexport const cppQueries: LanguageQueries = {\n symbols: `\n (function_definition\n declarator: (function_declarator\n declarator: (identifier) @name)) @node\n\n (function_definition\n declarator: (function_declarator\n declarator: (qualified_identifier name: (identifier) @name))) @node\n\n (class_specifier name: (type_identifier) @name) @node\n\n (struct_specifier name: (type_identifier) @name) @node\n\n (enum_specifier name: (type_identifier) @name) @node\n\n (namespace_definition name: (identifier) @name) @node\n `,\n imports: `\n (preproc_include path: (string_literal) @source) @node\n (preproc_include path: (system_lib_string) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const csharpQueries: LanguageQueries = {\n symbols: `\n (class_declaration name: (identifier) @name) @node\n\n (interface_declaration name: (identifier) @name) @node\n\n (enum_declaration name: (identifier) @name) @node\n\n (struct_declaration name: (identifier) @name) @node\n\n (method_declaration name: (identifier) @name) @node\n\n (property_declaration name: (identifier) @name) @node\n\n (record_declaration name: (identifier) @name) @node\n `,\n imports: `\n (using_directive (qualified_name) @source) @node\n (using_directive (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const rubyQueries: LanguageQueries = {\n symbols: `\n (method name: (identifier) @name) @node\n\n (singleton_method name: (identifier) @name) @node\n\n (class name: (constant) @name) @node\n\n (module name: (constant) @name) @node\n `,\n imports: `\n (call\n method: (identifier) @method\n arguments: (argument_list (string (string_content) @source))\n (#match? @method \"^(require|require_relative|load)$\")) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const phpQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (name) @name) @node\n\n (class_declaration name: (name) @name) @node\n\n (interface_declaration name: (name) @name) @node\n\n (trait_declaration name: (name) @name) @node\n\n (enum_declaration name: (name) @name) @node\n\n (method_declaration name: (name) @name) @node\n `,\n imports: `\n (namespace_use_declaration\n (namespace_use_clause (qualified_name) @source)) @node\n\n (require_expression (string (string_value) @source)) @node\n (include_expression (string (string_value) @source)) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const bashQueries: LanguageQueries = {\n symbols: `\n (function_definition name: (word) @name) @node\n `,\n imports: `\n (command\n name: (command_name (word) @cmd)\n argument: (word) @source\n (#match? @cmd \"^(source|\\\\.)$\")) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const kotlinQueries: LanguageQueries = {\n symbols: `\n (function_declaration (simple_identifier) @name) @node\n\n (class_declaration (type_identifier) @name) @node\n\n (object_declaration (type_identifier) @name) @node\n\n (interface_declaration (type_identifier) @name) @node\n `,\n imports: `\n (import_header (identifier) @source) @node\n `,\n};\n","import type { LanguageQueries } from '../SymbolExtractor.js';\n\nexport const swiftQueries: LanguageQueries = {\n symbols: `\n (function_declaration name: (simple_identifier) @name) @node\n\n (class_declaration name: (type_identifier) @name) @node\n\n (struct_declaration name: (type_identifier) @name) @node\n\n (enum_declaration name: (type_identifier) @name) @node\n\n (protocol_declaration name: (type_identifier) @name) @node\n\n (typealias_declaration name: (type_identifier) @name) @node\n `,\n imports: `\n (import_declaration (identifier) @source) @node\n `,\n};\n","import Parser from 'tree-sitter';\nimport type { CodeSymbol, SymbolKind } from '../types.js';\nimport { typescriptQueries, javascriptQueries } from './languages/typescript.js';\nimport { pythonQueries } from './languages/python.js';\nimport { goQueries } from './languages/go.js';\nimport { rustQueries } from './languages/rust.js';\nimport { javaQueries } from './languages/java.js';\nimport { cQueries, cppQueries } from './languages/c.js';\nimport { csharpQueries } from './languages/csharp.js';\nimport { rubyQueries } from './languages/ruby.js';\nimport { phpQueries } from './languages/php.js';\nimport { bashQueries } from './languages/bash.js';\nimport { kotlinQueries } from './languages/kotlin.js';\nimport { swiftQueries } from './languages/swift.js';\n\nexport interface LanguageQueries {\n symbols: string;\n imports: string;\n}\n\nconst LANGUAGE_QUERIES: Record<string, LanguageQueries> = {\n typescript: typescriptQueries,\n javascript: javascriptQueries,\n python: pythonQueries,\n go: goQueries,\n rust: rustQueries,\n java: javaQueries,\n c: cQueries,\n cpp: cppQueries,\n csharp: csharpQueries,\n ruby: rubyQueries,\n php: phpQueries,\n bash: bashQueries,\n kotlin: kotlinQueries,\n swift: swiftQueries,\n};\n\nconst KIND_DEFAULTS: Record<string, SymbolKind> = {\n function_definition: 'function',\n function_declaration: 'function',\n function_item: 'function',\n method_declaration: 'method',\n method_definition: 'method',\n class_declaration: 'class',\n class_definition: 'class',\n class_specifier: 'class',\n class_item: 'class',\n interface_declaration: 'interface',\n interface_item: 'interface',\n type_alias_declaration: 'type',\n type_item: 'type',\n type_definition: 'type',\n enum_declaration: 'enum',\n enum_item: 'enum',\n struct_item: 'class',\n struct_specifier: 'class',\n trait_item: 'interface',\n trait_declaration: 'interface',\n export_statement: 'variable',\n lexical_declaration: 'variable',\n var_declaration: 'variable',\n const_item: 'constant',\n const_declaration: 'constant',\n};\n\nfunction inferKind(node: Parser.SyntaxNode): SymbolKind {\n const type = node.type;\n if (KIND_DEFAULTS[type]) return KIND_DEFAULTS[type];\n for (const child of node.children) {\n if (KIND_DEFAULTS[child.type]) return KIND_DEFAULTS[child.type];\n }\n return 'variable';\n}\n\nfunction extractDocComment(node: Parser.SyntaxNode): string | null {\n const prev = node.previousNamedSibling;\n if (!prev) return null;\n const text = prev.text;\n if (text.startsWith('/**') || text.startsWith('///') || text.startsWith('#')) {\n const line = text.split('\\n')[0].replace(/^[/*#\\s]+/, '').trim();\n return line || null;\n }\n return null;\n}\n\nfunction extractSignature(node: Parser.SyntaxNode, name: string): string | null {\n const params = node.childForFieldName('parameters')\n ?? node.children.find(c => c.type === 'formal_parameters' || c.type === 'parameters');\n if (!params) return null;\n const retType = node.childForFieldName('return_type') ?? node.childForFieldName('type');\n const sig = retType ? `${params.text}: ${retType.text}` : params.text;\n return sig.length > 80 ? sig.slice(0, 77) + '...' : sig;\n}\n\nexport function extractSymbols(\n tree: Parser.Tree,\n filePath: string,\n fileId: number,\n language: string,\n source: string,\n): Omit<CodeSymbol, 'id'>[] {\n const queries = LANGUAGE_QUERIES[language];\n if (!queries) return [];\n\n const symbols: Omit<CodeSymbol, 'id'>[] = [];\n const lines = source.split('\\n');\n const isExportedLang = ['typescript', 'javascript'].includes(language);\n\n // Simple AST walk for languages without explicit export syntax\n function walk(node: Parser.SyntaxNode, depth = 0): void {\n const nodeType = node.type;\n const nameNode = node.childForFieldName('name');\n\n if (nameNode && KIND_DEFAULTS[nodeType]) {\n const name = nameNode.text;\n // For TS/JS, only count if inside an export_statement\n const isExported = isExportedLang\n ? (node.parent?.type === 'export_statement' || node.parent?.type === 'export_default_declaration')\n : name.length > 0 && name[0] === name[0].toUpperCase();\n\n if (name && name.length > 0) {\n symbols.push({\n fileId,\n filePath,\n name,\n kind: inferKind(node),\n line: node.startPosition.row + 1,\n endLine: node.endPosition.row + 1,\n isExported,\n signature: extractSignature(node, name),\n docComment: extractDocComment(node),\n parentName: null,\n });\n }\n }\n\n for (const child of node.children) {\n if (depth < 6) walk(child, depth + 1);\n }\n }\n\n walk(tree.rootNode);\n return symbols;\n}\n","import Parser from 'tree-sitter';\nimport { resolve, dirname, extname } from 'path';\nimport type { ImportEdge } from '../types.js';\n\nfunction resolveImportPath(source: string, fromFile: string): { toPath: string | null; toPackage: string | null } {\n if (source.startsWith('.')) {\n const dir = dirname(fromFile);\n let resolved = resolve(dir, source);\n // Add extension if missing\n if (!extname(resolved)) resolved += '.ts';\n return { toPath: resolved, toPackage: null };\n }\n // External package — extract package name\n const parts = source.split('/');\n const pkg = source.startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];\n return { toPath: null, toPackage: pkg };\n}\n\nfunction walkForImports(\n node: Parser.SyntaxNode,\n filePath: string,\n fileId: number,\n language: string,\n edges: Omit<ImportEdge, 'id'>[],\n depth = 0,\n): void {\n if (depth > 4) return;\n\n const type = node.type;\n\n // TypeScript/JavaScript: import_statement\n if (type === 'import_statement') {\n const sourceNode = node.children.find(c => c.type === 'string');\n if (sourceNode) {\n const raw = sourceNode.text.replace(/['\"]/g, '');\n const { toPath, toPackage } = resolveImportPath(raw, filePath);\n const isTypeOnly = node.children.some(c => c.text === 'type');\n const names: string[] = [];\n const namedImports = node.children.find(c => c.type === 'import_clause');\n if (namedImports) {\n const named = namedImports.children.find(c => c.type === 'named_imports');\n if (named) {\n for (const spec of named.children) {\n if (spec.type === 'import_specifier') {\n const n = spec.childForFieldName('name');\n if (n) names.push(n.text);\n }\n }\n }\n if (names.length === 0) names.push('*');\n }\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath, toPackage, importedNames: names, isTypeOnly });\n }\n }\n\n // Python: import_statement / import_from_statement\n if (language === 'python') {\n if (type === 'import_statement') {\n const name = node.children.find(c => c.type === 'dotted_name');\n if (name) {\n const mod = name.text.replace(/\\./g, '/');\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: mod, importedNames: ['*'], isTypeOnly: false });\n }\n }\n if (type === 'import_from_statement') {\n const mod = node.childForFieldName('module_name')?.text ?? '';\n const names: string[] = [];\n const nameList = node.children.find(c => c.type === 'import_from_as_names');\n if (nameList) {\n for (const c of nameList.children) {\n if (c.type === 'dotted_name') names.push(c.text);\n }\n }\n if (names.length === 0) names.push('*');\n const isRelative = mod.startsWith('.');\n const { toPath, toPackage } = isRelative ? resolveImportPath(mod, filePath) : { toPath: null, toPackage: mod };\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath, toPackage, importedNames: names, isTypeOnly: false });\n }\n }\n\n // Go: import_spec\n if (language === 'go' && type === 'import_spec') {\n const pathNode = node.childForFieldName('path');\n if (pathNode) {\n const raw = pathNode.text.replace(/\"/g, '');\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: raw, importedNames: ['*'], isTypeOnly: false });\n }\n }\n\n // Rust: use_declaration\n if (language === 'rust' && type === 'use_declaration') {\n const arg = node.children.find(c => c.type !== 'use' && c.type !== ';');\n if (arg) {\n edges.push({ fromFileId: fileId, fromPath: filePath, toPath: null, toPackage: arg.text, importedNames: ['*'], isTypeOnly: false });\n }\n }\n\n for (const child of node.children) {\n walkForImports(child, filePath, fileId, language, edges, depth + 1);\n }\n}\n\nexport function extractImports(\n tree: Parser.Tree,\n filePath: string,\n fileId: number,\n language: string,\n): Omit<ImportEdge, 'id'>[] {\n const edges: Omit<ImportEdge, 'id'>[] = [];\n walkForImports(tree.rootNode, filePath, fileId, language, edges);\n return edges;\n}\n","import { createHash } from 'crypto';\n\nexport function hashContent(content: string): string {\n return createHash('sha256').update(content).digest('hex').slice(0, 16);\n}\n","import { glob } from 'glob';\nimport Ignore from 'ignore';\nimport { readFileSync, existsSync } from 'fs';\nimport { join, relative } from 'path';\nimport type { CodePulseConfig } from '../types.js';\n\nexport interface WalkedFile {\n absolutePath: string;\n relativePath: string;\n}\n\nexport async function walkFiles(repoRoot: string, config: CodePulseConfig): Promise<WalkedFile[]> {\n const ig = Ignore.default();\n\n // Load .gitignore if present\n const gitignorePath = join(repoRoot, '.gitignore');\n if (existsSync(gitignorePath)) {\n ig.add(readFileSync(gitignorePath, 'utf8'));\n }\n\n // Add config excludes\n ig.add(config.exclude);\n\n const pattern = '**/*';\n const files = await glob(pattern, {\n cwd: repoRoot,\n nodir: true,\n dot: false,\n absolute: false,\n });\n\n const result: WalkedFile[] = [];\n for (const rel of files) {\n if (ig.ignores(rel)) continue;\n result.push({\n absolutePath: join(repoRoot, rel),\n relativePath: rel.replace(/\\\\/g, '/'),\n });\n }\n\n return result;\n}\n","import { execSync } from 'child_process';\n\nexport type ChangeStatus = 'M' | 'A' | 'D' | 'R';\n\nexport interface ChangedFile {\n status: ChangeStatus;\n path: string;\n oldPath?: string;\n}\n\nexport function getHeadCommit(repoRoot: string): string {\n try {\n return execSync('git rev-parse HEAD', { cwd: repoRoot, encoding: 'utf8' }).trim();\n } catch {\n return '';\n }\n}\n\nexport function getChangedFiles(repoRoot: string, sinceCommit: string): ChangedFile[] | null {\n if (!sinceCommit) return null;\n\n try {\n const output = execSync(\n `git diff --name-status ${sinceCommit} HEAD`,\n { cwd: repoRoot, encoding: 'utf8' }\n );\n\n const changes: ChangedFile[] = [];\n for (const line of output.trim().split('\\n')) {\n if (!line) continue;\n const parts = line.split('\\t');\n const rawStatus = parts[0].charAt(0) as ChangeStatus;\n const status = ['M', 'A', 'D', 'R'].includes(rawStatus) ? rawStatus : 'M';\n\n if (status === 'R') {\n changes.push({ status: 'D', path: parts[1] });\n changes.push({ status: 'A', path: parts[2] });\n } else {\n changes.push({ status, path: parts[1] });\n }\n }\n return changes;\n } catch {\n return null;\n }\n}\n","import type { LayerName, CodePulseConfig } from '../types.js';\n\nexport interface LayerBudget {\n layer: LayerName;\n tokens: number;\n}\n\nexport function allocateBudget(\n totalTokens: number,\n config: CodePulseConfig,\n hasFocusPath: boolean,\n layers: LayerName[],\n): LayerBudget[] {\n const weights = { ...config.layerWeights };\n\n if (!hasFocusPath) {\n // Redistribute focus weight to symbol_table\n const focusWeight = weights.focus;\n delete (weights as Record<string, number>).focus;\n const remaining = layers.filter(l => l !== 'focus');\n const total = remaining.reduce((s, l) => s + (weights[l] ?? 0), 0);\n for (const l of remaining) {\n weights[l] = ((weights[l] ?? 0) / total) * (1 - focusWeight / 1) + (l === 'symbol_table' ? focusWeight : 0);\n }\n }\n\n const activeLayers = hasFocusPath ? layers : layers.filter(l => l !== 'focus');\n\n // Normalize weights for active layers\n const activeTotal = activeLayers.reduce((s, l) => s + (weights[l] ?? 0), 0);\n return activeLayers.map(layer => ({\n layer,\n tokens: Math.floor(totalTokens * (weights[layer] ?? 0) / activeTotal),\n }));\n}\n","import { encode } from 'gpt-tokenizer';\n\nexport function countTokens(text: string): number {\n return encode(text).length;\n}\n","import type { DB } from '../../storage/Database.js';\nimport { MetaRepository } from '../../storage/MetaRepository.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\nimport { basename } from 'path';\n\nexport function renderRepoOverview(db: DB, budget: number): { content: string; truncated: boolean } {\n const meta = new MetaRepository(db).getIndexMeta();\n const files = new FileRepository(db);\n const langStats = files.getLanguageStats();\n\n const repoName = basename(meta.repoRoot) || 'unknown';\n const lastIndexed = meta.lastIndexedAt\n ? new Date(meta.lastIndexedAt).toISOString().slice(0, 10)\n : 'never';\n\n const langSummary = langStats\n .slice(0, 8)\n .map(l => `${l.language}: ${l.count}`)\n .join(', ');\n\n const content = [\n `# Repository: ${repoName}`,\n `Files: ${meta.totalFiles} | Symbols: ${meta.totalSymbols} | Last indexed: ${lastIndexed}`,\n `Languages: ${langSummary}`,\n ].join('\\n');\n\n return { content, truncated: countTokens(content) > budget };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nfunction buildTree(paths: string[]): Map<string, Set<string>> {\n const tree = new Map<string, Set<string>>();\n for (const p of paths) {\n const parts = p.split('/');\n // Add each directory level\n for (let i = 1; i < parts.length; i++) {\n const dir = parts.slice(0, i).join('/') || '.';\n if (!tree.has(dir)) tree.set(dir, new Set());\n tree.get(dir)!.add(parts.slice(0, i + 1).join('/'));\n }\n }\n return tree;\n}\n\nfunction renderTree(paths: string[], maxLines: number): string {\n const dirs = new Map<string, string[]>();\n for (const p of paths) {\n const slash = p.lastIndexOf('/');\n const dir = slash === -1 ? '.' : p.slice(0, slash);\n if (!dirs.has(dir)) dirs.set(dir, []);\n dirs.get(dir)!.push(slash === -1 ? p : p.slice(slash + 1));\n }\n\n const lines: string[] = [];\n // Show top-level dirs and their file counts\n const topLevel = new Map<string, number>();\n for (const p of paths) {\n const top = p.split('/')[0];\n topLevel.set(top, (topLevel.get(top) ?? 0) + 1);\n }\n\n for (const [dir, count] of [...topLevel.entries()].sort()) {\n if (lines.length >= maxLines) { lines.push('...'); break; }\n lines.push(`${dir}/ (${count} files)`);\n }\n\n return lines.join('\\n');\n}\n\nexport function renderDirectoryMap(db: DB, budget: number): { content: string; truncated: boolean } {\n const allFiles = new FileRepository(db).getAllActive();\n const paths = allFiles.map(f => f.path);\n const charsPerToken = 4;\n const maxLines = Math.floor((budget * charsPerToken) / 30);\n\n const content = renderTree(paths, maxLines);\n return { content, truncated: countTokens(content) > budget };\n}\n","import type { CodeSymbol } from '../types.js';\n\nconst STOPWORDS = new Set([\n 'a', 'an', 'the', 'is', 'in', 'it', 'of', 'to', 'and', 'or', 'for',\n 'on', 'at', 'by', 'with', 'from', 'this', 'that', 'be', 'are', 'was',\n 'can', 'do', 'get', 'use', 'how', 'what', 'my', 'me', 'i', 'we', 'you',\n 'show', 'make', 'add', 'fix', 'update', 'change', 'want', 'need', 'all',\n]);\n\nexport function extractKeywords(task: string): string[] {\n return task\n .toLowerCase()\n .replace(/[^a-z0-9\\s_/-]/g, ' ')\n .split(/\\s+/)\n .filter(w => w.length > 2 && !STOPWORDS.has(w));\n}\n\nexport function scoreFile(filePath: string, symbols: CodeSymbol[], keywords: string[]): number {\n if (keywords.length === 0) return 0;\n const pathLower = filePath.toLowerCase();\n let score = 0;\n\n for (const kw of keywords) {\n if (pathLower.includes(kw)) score += 3;\n for (const sym of symbols) {\n if (sym.name.toLowerCase().includes(kw)) score += 2;\n if (sym.signature?.toLowerCase().includes(kw)) score += 1;\n if (sym.docComment?.toLowerCase().includes(kw)) score += 1;\n }\n }\n\n return score;\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { countTokens } from '../TokenCounter.js';\nimport { scoreFile } from '../TaskAnalyzer.js';\n\nexport function renderSymbolTable(db: DB, budget: number, taskKeywords: string[] = []): { content: string; truncated: boolean } {\n const repo = new SymbolRepository(db);\n const symbols = repo.getAllExported();\n\n // Group by file\n const byFile = new Map<string, typeof symbols>();\n for (const s of symbols) {\n if (!byFile.has(s.filePath)) byFile.set(s.filePath, []);\n byFile.get(s.filePath)!.push(s);\n }\n\n // Sort by task relevance first, then by symbol count\n const sorted = [...byFile.entries()].sort((a, b) => {\n const scoreDiff = scoreFile(b[0], b[1], taskKeywords) - scoreFile(a[0], a[1], taskKeywords);\n return scoreDiff !== 0 ? scoreDiff : b[1].length - a[1].length;\n });\n\n const lines: string[] = [];\n let usedTokens = 0;\n let truncated = false;\n\n for (const [file, syms] of sorted) {\n const header = `### ${file}`;\n const symLines = syms.map(s => {\n const sig = s.signature ? `${s.name}${s.signature}` : s.name;\n const doc = s.docComment ? ` — ${s.docComment}` : '';\n return ` ${s.kind} ${sig}${doc}`;\n });\n\n const block = [header, ...symLines].join('\\n');\n const blockTokens = countTokens(block);\n\n if (usedTokens + blockTokens > budget) {\n truncated = true;\n break;\n }\n\n lines.push(block);\n usedTokens += blockTokens;\n }\n\n return { content: lines.join('\\n\\n'), truncated };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nexport function renderImportGraph(db: DB, budget: number): { content: string; truncated: boolean } {\n const repo = new SymbolRepository(db);\n const hubs = repo.getTopImportedFiles(30);\n\n const lines: string[] = ['### Most-imported modules'];\n let usedTokens = countTokens(lines[0]);\n let truncated = false;\n\n for (const { path, importerCount } of hubs) {\n const line = ` ${path} ← imported by ${importerCount} files`;\n const t = countTokens(line);\n if (usedTokens + t > budget) { truncated = true; break; }\n lines.push(line);\n usedTokens += t;\n }\n\n return { content: lines.join('\\n'), truncated };\n}\n","import type { DB } from '../../storage/Database.js';\nimport { SymbolRepository } from '../../storage/SymbolRepository.js';\nimport { FileRepository } from '../../storage/FileRepository.js';\nimport { countTokens } from '../TokenCounter.js';\n\nexport function renderFocusLayer(db: DB, focusPath: string, budget: number): { content: string; truncated: boolean } {\n const symRepo = new SymbolRepository(db);\n const fileRepo = new FileRepository(db);\n\n // Find all files under focusPath\n const allFiles = fileRepo.getAllActive().filter(f => f.path.startsWith(focusPath));\n const lines: string[] = [`### Focus: ${focusPath}`];\n let usedTokens = countTokens(lines[0]);\n let truncated = false;\n\n for (const file of allFiles) {\n const syms = symRepo.getExportedByFile(file.path);\n if (syms.length === 0) continue;\n\n const importers = symRepo.getImportersOf(file.path);\n\n const fileLines = [` ${file.path}:`];\n for (const s of syms) {\n const sig = s.signature ? `${s.name}${s.signature}` : s.name;\n fileLines.push(` ${s.kind} ${sig}`);\n }\n if (importers.length > 0) {\n fileLines.push(` ← imported by: ${importers.slice(0, 3).join(', ')}${importers.length > 3 ? ` +${importers.length - 3} more` : ''}`);\n }\n\n const block = fileLines.join('\\n');\n const t = countTokens(block);\n if (usedTokens + t > budget) { truncated = true; break; }\n lines.push(block);\n usedTokens += t;\n }\n\n return { content: lines.join('\\n'), truncated };\n}\n","import type { DB } from '../storage/Database.js';\nimport type { ContextRequest, ContextResult, LayerResult, LayerName, CodePulseConfig } from '../types.js';\nimport { MetaRepository } from '../storage/MetaRepository.js';\nimport { allocateBudget } from './BudgetAllocator.js';\nimport { renderRepoOverview } from './layers/RepoOverviewLayer.js';\nimport { renderDirectoryMap } from './layers/DirectoryMapLayer.js';\nimport { renderSymbolTable } from './layers/SymbolTableLayer.js';\nimport { renderImportGraph } from './layers/ImportGraphLayer.js';\nimport { renderFocusLayer } from './layers/FocusLayer.js';\nimport { countTokens } from './TokenCounter.js';\n\nconst DEFAULT_LAYERS: LayerName[] = ['repo_overview', 'directory_map', 'symbol_table', 'import_graph', 'focus'];\n\nconst SKIP_THRESHOLD = 10; // repos smaller than this get skipped entirely\nconst SMALL_REPO_BUDGET = 800;\nconst MEDIUM_REPO_BUDGET = 2000;\nconst LARGE_REPO_BUDGET = 4000;\n\nfunction autoBudget(totalFiles: number): number | null {\n if (totalFiles < SKIP_THRESHOLD) return null; // null = skip\n if (totalFiles < 30) return SMALL_REPO_BUDGET;\n if (totalFiles < 150) return MEDIUM_REPO_BUDGET;\n return LARGE_REPO_BUDGET;\n}\n\nfunction renderLayer(db: DB, layer: LayerName, budget: number, focusPath?: string, taskKeywords: string[] = []): { content: string; truncated: boolean } {\n switch (layer) {\n case 'repo_overview': return renderRepoOverview(db, budget);\n case 'directory_map': return renderDirectoryMap(db, budget);\n case 'symbol_table': return renderSymbolTable(db, budget, taskKeywords);\n case 'import_graph': return renderImportGraph(db, budget);\n case 'focus': return focusPath ? renderFocusLayer(db, focusPath, budget) : { content: '', truncated: false };\n default: return { content: '', truncated: false };\n }\n}\n\nfunction wrapMarkdown(layers: LayerResult[]): string {\n return layers.map(l => l.content).filter(Boolean).join('\\n\\n');\n}\n\nfunction wrapXML(layers: LayerResult[]): string {\n const inner = layers\n .filter(l => l.content)\n .map(l => ` <${l.layer}>\\n${l.content}\\n </${l.layer}>`)\n .join('\\n');\n return `<codebase_context>\\n${inner}\\n</codebase_context>`;\n}\n\nexport function generateContext(db: DB, request: ContextRequest, config: CodePulseConfig): ContextResult {\n const layers = request.layers ?? DEFAULT_LAYERS;\n const hasFocus = Boolean(request.focusPath);\n const taskKeywords = request.taskKeywords ?? [];\n\n // Resolve budget — auto-scale by repo size if requested\n let budgetTokens = request.budgetTokens;\n let skipped = false;\n if (request.autoBudget) {\n const meta = new MetaRepository(db).getIndexMeta();\n const resolved = autoBudget(meta.totalFiles);\n if (resolved === null) {\n skipped = true;\n } else {\n budgetTokens = resolved;\n }\n }\n\n if (skipped) {\n return {\n totalTokens: 0,\n budgetTokens: 0,\n layers: [],\n rendered: '',\n skipped: true,\n };\n }\n\n const budgets = allocateBudget(budgetTokens, config, hasFocus, layers);\n\n let remainingSurplus = 0;\n const results: LayerResult[] = [];\n\n for (const { layer, tokens } of budgets) {\n const layerBudget = tokens + remainingSurplus;\n const { content, truncated } = renderLayer(db, layer, layerBudget, request.focusPath, taskKeywords);\n const used = countTokens(content);\n remainingSurplus = truncated ? 0 : layerBudget - used;\n\n results.push({ layer, tokensUsed: used, content, truncated });\n }\n\n const rendered = request.format === 'xml' ? wrapXML(results) : wrapMarkdown(results);\n const totalTokens = countTokens(rendered);\n\n return {\n totalTokens,\n budgetTokens,\n layers: results,\n rendered,\n };\n}\n"],"mappings":";AAuFO,IAAM,iBAAkC;AAAA,EAC7C,SAAS,CAAC,gBAAgB,QAAQ,QAAQ,SAAS,SAAS,eAAe,UAAU;AAAA,EACrF,kBAAkB,MAAM;AAAA,EACxB,qBAAqB;AAAA,EACrB,cAAc;AAAA,IACZ,eAAe;AAAA,IACf,eAAe;AAAA,IACf,cAAc;AAAA,IACd,cAAc;AAAA,IACd,OAAO;AAAA,EACT;AACF;;;AClGA,OAAO,mBAAmB;AAE1B,IAAM,iBAAiB;AAEvB,IAAM,aAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmDZ,SAAS,aAAa,QAAoB;AAC/C,QAAM,KAAK,IAAI,cAAc,MAAM;AACnC,KAAG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