pindex 1.4.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -23
- package/dist/cli/daemon.d.ts +1 -1
- package/dist/cli/daemon.d.ts.map +1 -1
- package/dist/cli/daemon.js +25 -6
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/federate.d.ts +6 -0
- package/dist/cli/federate.d.ts.map +1 -0
- package/dist/cli/federate.js +121 -0
- package/dist/cli/federate.js.map +1 -0
- package/dist/cli/index.js +46 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +14 -7
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/project-detector.d.ts +16 -3
- package/dist/cli/project-detector.d.ts.map +1 -1
- package/dist/cli/project-detector.js +83 -11
- package/dist/cli/project-detector.js.map +1 -1
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +3 -5
- package/dist/cli/setup.js.map +1 -1
- package/dist/db/queries.d.ts +14 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +22 -3
- package/dist/db/queries.js.map +1 -1
- package/dist/federation/merge.d.ts +4 -0
- package/dist/federation/merge.d.ts.map +1 -0
- package/dist/federation/merge.js +15 -0
- package/dist/federation/merge.js.map +1 -0
- package/dist/federation/registry-name.d.ts +6 -0
- package/dist/federation/registry-name.d.ts.map +1 -0
- package/dist/federation/registry-name.js +17 -0
- package/dist/federation/registry-name.js.map +1 -0
- package/dist/federation/repo-set.d.ts +27 -0
- package/dist/federation/repo-set.d.ts.map +1 -0
- package/dist/federation/repo-set.js +41 -0
- package/dist/federation/repo-set.js.map +1 -0
- package/dist/federation/repos-env.d.ts +16 -0
- package/dist/federation/repos-env.d.ts.map +1 -0
- package/dist/federation/repos-env.js +27 -0
- package/dist/federation/repos-env.js.map +1 -0
- package/dist/gui/server.d.ts.map +1 -1
- package/dist/gui/server.js +63 -23
- package/dist/gui/server.js.map +1 -1
- package/dist/index.js +36 -34
- package/dist/index.js.map +1 -1
- package/dist/indexer/detect-languages.d.ts +10 -0
- package/dist/indexer/detect-languages.d.ts.map +1 -0
- package/dist/indexer/detect-languages.js +36 -0
- package/dist/indexer/detect-languages.js.map +1 -0
- package/dist/indexer/index.d.ts +2 -0
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +21 -9
- package/dist/indexer/index.js.map +1 -1
- package/dist/indexer/parser.d.ts.map +1 -1
- package/dist/indexer/parser.js +36 -5
- package/dist/indexer/parser.js.map +1 -1
- package/dist/indexer/summarizer.d.ts.map +1 -1
- package/dist/indexer/summarizer.js +3 -0
- package/dist/indexer/summarizer.js.map +1 -1
- package/dist/memory/retention.d.ts +16 -0
- package/dist/memory/retention.d.ts.map +1 -0
- package/dist/memory/retention.js +32 -0
- package/dist/memory/retention.js.map +1 -0
- package/dist/monitoring/server.d.ts.map +1 -1
- package/dist/monitoring/server.js +22 -1
- package/dist/monitoring/server.js.map +1 -1
- package/dist/monitoring/ui/dashboard.js +83 -31
- package/dist/monitoring/ui/esc.js +17 -0
- package/dist/monitoring/ui/index.html +17 -11
- package/dist/monitoring/ui/styles.css +24 -4
- package/dist/server-config.d.ts +18 -0
- package/dist/server-config.d.ts.map +1 -0
- package/dist/server-config.js +41 -0
- package/dist/server-config.js.map +1 -0
- package/dist/server.d.ts +5 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +21 -14
- package/dist/server.js.map +1 -1
- package/dist/tools/find_usages.d.ts +2 -2
- package/dist/tools/find_usages.d.ts.map +1 -1
- package/dist/tools/find_usages.js +24 -10
- package/dist/tools/find_usages.js.map +1 -1
- package/dist/tools/get_context.d.ts +2 -2
- package/dist/tools/get_context.d.ts.map +1 -1
- package/dist/tools/get_context.js +54 -50
- package/dist/tools/get_context.js.map +1 -1
- package/dist/tools/get_dependencies.d.ts +2 -2
- package/dist/tools/get_dependencies.d.ts.map +1 -1
- package/dist/tools/get_dependencies.js +24 -11
- package/dist/tools/get_dependencies.js.map +1 -1
- package/dist/tools/get_doc_chunk.d.ts +2 -2
- package/dist/tools/get_doc_chunk.d.ts.map +1 -1
- package/dist/tools/get_doc_chunk.js +38 -29
- package/dist/tools/get_doc_chunk.js.map +1 -1
- package/dist/tools/get_file_summary.d.ts +2 -2
- package/dist/tools/get_file_summary.d.ts.map +1 -1
- package/dist/tools/get_file_summary.js +48 -37
- package/dist/tools/get_file_summary.js.map +1 -1
- package/dist/tools/get_project_overview.d.ts +2 -3
- package/dist/tools/get_project_overview.d.ts.map +1 -1
- package/dist/tools/get_project_overview.js +22 -22
- package/dist/tools/get_project_overview.js.map +1 -1
- package/dist/tools/get_symbol.d.ts +2 -2
- package/dist/tools/get_symbol.d.ts.map +1 -1
- package/dist/tools/get_symbol.js +33 -27
- package/dist/tools/get_symbol.js.map +1 -1
- package/dist/tools/schemas.d.ts +9 -0
- package/dist/tools/schemas.d.ts.map +1 -1
- package/dist/tools/schemas.js +20 -2
- package/dist/tools/schemas.js.map +1 -1
- package/dist/tools/search_docs.d.ts +2 -2
- package/dist/tools/search_docs.d.ts.map +1 -1
- package/dist/tools/search_docs.js +40 -28
- package/dist/tools/search_docs.js.map +1 -1
- package/dist/tools/search_symbols.d.ts +2 -3
- package/dist/tools/search_symbols.d.ts.map +1 -1
- package/dist/tools/search_symbols.js +35 -46
- package/dist/tools/search_symbols.js.map +1 -1
- package/dist/types.d.ts +24 -10
- package/dist/types.d.ts.map +1 -1
- package/dist/util/net.d.ts +25 -0
- package/dist/util/net.d.ts.map +1 -0
- package/dist/util/net.js +50 -0
- package/dist/util/net.js.map +1 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_usages.d.ts","sourceRoot":"","sources":["../../src/tools/find_usages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"find_usages.d.ts","sourceRoot":"","sources":["../../src/tools/find_usages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,GAAG,WAAW,EAAE,CAwBlF"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
import { getSymbolByName, getUsagesBySymbol } from '../db/queries.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
import { dedupByKey } from '../federation/merge.js';
|
|
3
|
+
export function findUsages(repoSet, input) {
|
|
4
|
+
const repos = repoSet.filter(input.repos);
|
|
5
|
+
const all = [];
|
|
6
|
+
for (const repo of repos) {
|
|
7
|
+
try {
|
|
8
|
+
const symbol = getSymbolByName(repo.db, input.symbol);
|
|
9
|
+
if (!symbol)
|
|
10
|
+
continue;
|
|
11
|
+
const usages = getUsagesBySymbol(repo.db, symbol.id);
|
|
12
|
+
for (const u of usages) {
|
|
13
|
+
all.push({
|
|
14
|
+
file: u.file_path,
|
|
15
|
+
line: u.used_at_line,
|
|
16
|
+
context: `${u.file_path}:${u.used_at_line}`,
|
|
17
|
+
project: repo.name,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
process.stderr.write(`[pindex] find_usages failed for repo '${repo.name}': ${String(err)}\n`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return dedupByKey(all, (r) => `${r.project}::${r.file}::${r.line}`);
|
|
12
26
|
}
|
|
13
27
|
//# sourceMappingURL=find_usages.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find_usages.js","sourceRoot":"","sources":["../../src/tools/find_usages.ts"],"names":[],"mapp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CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
1
|
import type { GetContextInput, GetContextOutput } from '../types.js';
|
|
2
|
+
import type { RepoSet } from '../federation/repo-set.js';
|
|
3
3
|
/** Loads a specific line range from a file on disk.
|
|
4
4
|
* The DB is consulted only for the language – actual code is read live. */
|
|
5
|
-
export declare function getContext(
|
|
5
|
+
export declare function getContext(repoSet: RepoSet, input: GetContextInput): Promise<GetContextOutput[]>;
|
|
6
6
|
//# sourceMappingURL=get_context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_context.d.ts","sourceRoot":"","sources":["../../src/tools/get_context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get_context.d.ts","sourceRoot":"","sources":["../../src/tools/get_context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAIzD;4EAC4E;AAC5E,wBAAsB,UAAU,CAC9B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAkE7B"}
|
|
@@ -5,58 +5,62 @@ import { resolveWithinRoot } from '../util/paths.js';
|
|
|
5
5
|
const DEFAULT_RANGE = 30;
|
|
6
6
|
/** Loads a specific line range from a file on disk.
|
|
7
7
|
* The DB is consulted only for the language – actual code is read live. */
|
|
8
|
-
export async function getContext(
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
export async function getContext(repoSet, input) {
|
|
9
|
+
const repos = repoSet.filter(input.repos);
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const repo of repos) {
|
|
12
|
+
const fileRecord = getFileByPath(repo.db, input.file);
|
|
13
|
+
if (!fileRecord)
|
|
14
|
+
continue;
|
|
15
|
+
const absolutePath = resolveWithinRoot(repo.path, input.file);
|
|
16
|
+
if (!absolutePath || !existsSync(absolutePath))
|
|
17
|
+
continue;
|
|
18
|
+
const range = input.range ?? DEFAULT_RANGE;
|
|
19
|
+
const targetLine = Math.max(1, input.line);
|
|
20
|
+
const halfRange = Math.floor(range / 2);
|
|
21
|
+
// Collect a buffer of ~2×range lines around the target (enough for boundary adjustment).
|
|
22
|
+
// This avoids reading the entire file when only ~30 lines are needed.
|
|
23
|
+
const collectStart = Math.max(1, targetLine - range);
|
|
24
|
+
const collectEnd = targetLine + range;
|
|
25
|
+
const rl = createInterface({ input: createReadStream(absolutePath, { encoding: 'utf-8' }) });
|
|
26
|
+
const collected = [];
|
|
27
|
+
let lineCount = 0;
|
|
28
|
+
let hitEof = true;
|
|
29
|
+
try {
|
|
30
|
+
for await (const line of rl) {
|
|
31
|
+
lineCount++;
|
|
32
|
+
if (lineCount >= collectStart) {
|
|
33
|
+
collected.push(line);
|
|
34
|
+
}
|
|
35
|
+
if (lineCount >= collectEnd) {
|
|
36
|
+
hitEof = false;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
}
|
|
41
|
+
finally {
|
|
42
|
+
rl.close();
|
|
43
|
+
}
|
|
44
|
+
// If we didn't exhaust the file, there are more lines beyond collectEnd.
|
|
45
|
+
// Use a large sentinel so endLine is not artificially capped.
|
|
46
|
+
const effectiveTotal = hitEof ? lineCount : Infinity;
|
|
47
|
+
let startLine = Math.max(1, targetLine - halfRange);
|
|
48
|
+
let endLine = Math.min(effectiveTotal, startLine + range - 1);
|
|
49
|
+
// Adjust if we hit the bottom boundary
|
|
50
|
+
if (endLine - startLine < range - 1) {
|
|
51
|
+
startLine = Math.max(1, endLine - range + 1);
|
|
52
|
+
}
|
|
53
|
+
const offset = startLine - collectStart;
|
|
54
|
+
const selectedLines = collected.slice(offset, offset + (endLine - startLine + 1));
|
|
55
|
+
const code = selectedLines.join('\n');
|
|
56
|
+
out.push({
|
|
57
|
+
code,
|
|
58
|
+
language: fileRecord.language,
|
|
59
|
+
startLine,
|
|
60
|
+
endLine,
|
|
61
|
+
project: repo.name,
|
|
62
|
+
});
|
|
39
63
|
}
|
|
40
|
-
|
|
41
|
-
rl.close();
|
|
42
|
-
}
|
|
43
|
-
// If we didn't exhaust the file, there are more lines beyond collectEnd.
|
|
44
|
-
// Use a large sentinel so endLine is not artificially capped.
|
|
45
|
-
const effectiveTotal = hitEof ? lineCount : Infinity;
|
|
46
|
-
let startLine = Math.max(1, targetLine - halfRange);
|
|
47
|
-
let endLine = Math.min(effectiveTotal, startLine + range - 1);
|
|
48
|
-
// Adjust if we hit the bottom boundary
|
|
49
|
-
if (endLine - startLine < range - 1) {
|
|
50
|
-
startLine = Math.max(1, endLine - range + 1);
|
|
51
|
-
}
|
|
52
|
-
const offset = startLine - collectStart;
|
|
53
|
-
const selectedLines = collected.slice(offset, offset + (endLine - startLine + 1));
|
|
54
|
-
const code = selectedLines.join('\n');
|
|
55
|
-
return {
|
|
56
|
-
code,
|
|
57
|
-
language: fileRecord.language,
|
|
58
|
-
startLine,
|
|
59
|
-
endLine,
|
|
60
|
-
};
|
|
64
|
+
return out;
|
|
61
65
|
}
|
|
62
66
|
//# sourceMappingURL=get_context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_context.js","sourceRoot":"","sources":["../../src/tools/get_context.ts"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C,CAAC,EAAE,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,MAAM,MAAM,GAAG,SAAS,GAAG,YAAY,CAAC;QACxC,MAAM,aAAa,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,OAAO,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC;QAClF,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtC,GAAG,CAAC,IAAI,CAAC;YACP,IAAI;YACJ,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,SAAS;YACT,OAAO;YACP,OAAO,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
1
|
import type { GetDependenciesInput, GetDependenciesOutput } from '../types.js';
|
|
3
|
-
|
|
2
|
+
import type { RepoSet } from '../federation/repo-set.js';
|
|
3
|
+
export declare function getDependencies(repoSet: RepoSet, input: GetDependenciesInput): GetDependenciesOutput[];
|
|
4
4
|
//# sourceMappingURL=get_dependencies.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_dependencies.d.ts","sourceRoot":"","sources":["../../src/tools/get_dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get_dependencies.d.ts","sourceRoot":"","sources":["../../src/tools/get_dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD,wBAAgB,eAAe,CAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,oBAAoB,GAC1B,qBAAqB,EAAE,CA4BzB"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
import { getFileByPath, getDependenciesByFile, getImportedByFile } from '../db/queries.js';
|
|
2
|
-
|
|
2
|
+
import { resolveWithinRoot } from '../util/paths.js';
|
|
3
|
+
export function getDependencies(repoSet, input) {
|
|
4
|
+
const repos = repoSet.filter(input.repos);
|
|
3
5
|
const direction = input.direction ?? 'both';
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const out = [];
|
|
7
|
+
for (const repo of repos) {
|
|
8
|
+
if (repo.path && !resolveWithinRoot(repo.path, input.target))
|
|
9
|
+
continue;
|
|
10
|
+
const file = getFileByPath(repo.db, input.target);
|
|
11
|
+
if (!file)
|
|
12
|
+
continue;
|
|
13
|
+
const result = {
|
|
14
|
+
file: input.target,
|
|
15
|
+
project: repo.name,
|
|
16
|
+
imports: [],
|
|
17
|
+
importedBy: [],
|
|
18
|
+
};
|
|
19
|
+
if (direction === 'imports' || direction === 'both') {
|
|
20
|
+
result.imports = getDependenciesByFile(repo.db, file.id);
|
|
21
|
+
}
|
|
22
|
+
if (direction === 'imported_by' || direction === 'both') {
|
|
23
|
+
result.importedBy = getImportedByFile(repo.db, file.id);
|
|
24
|
+
}
|
|
25
|
+
out.push(result);
|
|
7
26
|
}
|
|
8
|
-
|
|
9
|
-
? getDependenciesByFile(db, file.id)
|
|
10
|
-
: [];
|
|
11
|
-
const importedBy = direction === 'imported_by' || direction === 'both'
|
|
12
|
-
? getImportedByFile(db, file.id)
|
|
13
|
-
: [];
|
|
14
|
-
return { imports, importedBy };
|
|
27
|
+
return out;
|
|
15
28
|
}
|
|
16
29
|
//# sourceMappingURL=get_dependencies.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_dependencies.js","sourceRoot":"","sources":["../../src/tools/get_dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_dependencies.js","sourceRoot":"","sources":["../../src/tools/get_dependencies.ts"],"names":[],"mapp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ED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
1
|
import type { GetDocChunkInput, GetDocChunkOutput } from '../types.js';
|
|
3
|
-
|
|
2
|
+
import type { RepoSet } from '../federation/repo-set.js';
|
|
3
|
+
export declare function getDocChunk(repoSet: RepoSet, input: GetDocChunkInput): GetDocChunkOutput[];
|
|
4
4
|
//# sourceMappingURL=get_doc_chunk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_doc_chunk.d.ts","sourceRoot":"","sources":["../../src/tools/get_doc_chunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get_doc_chunk.d.ts","sourceRoot":"","sources":["../../src/tools/get_doc_chunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAY,MAAM,aAAa,CAAC;AAEjF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,GAAG,iBAAiB,EAAE,CAyC1F"}
|
|
@@ -1,32 +1,41 @@
|
|
|
1
1
|
import { getFileByPath, getDocumentChunksByFileId } from '../db/queries.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
2
|
+
import { resolveWithinRoot } from '../util/paths.js';
|
|
3
|
+
export function getDocChunk(repoSet, input) {
|
|
4
|
+
const repos = repoSet.filter(input.repos);
|
|
5
|
+
const out = [];
|
|
6
|
+
for (const repo of repos) {
|
|
7
|
+
if (repo.path && !resolveWithinRoot(repo.path, input.file))
|
|
8
|
+
continue;
|
|
9
|
+
const fileRecord = getFileByPath(repo.db, input.file);
|
|
10
|
+
if (!fileRecord)
|
|
11
|
+
continue;
|
|
12
|
+
const allChunks = getDocumentChunksByFileId(repo.db, fileRecord.id);
|
|
13
|
+
if (allChunks.length === 0)
|
|
14
|
+
continue;
|
|
15
|
+
const chunks = input.chunk_index !== undefined
|
|
16
|
+
? allChunks
|
|
17
|
+
.filter((c) => c.chunk_index === input.chunk_index)
|
|
18
|
+
.map((c) => ({
|
|
19
|
+
index: c.chunk_index,
|
|
20
|
+
heading: c.heading,
|
|
21
|
+
start_line: c.start_line,
|
|
22
|
+
end_line: c.end_line,
|
|
23
|
+
content: c.content,
|
|
24
|
+
}))
|
|
25
|
+
: allChunks.map((c) => ({
|
|
26
|
+
index: c.chunk_index,
|
|
27
|
+
heading: c.heading,
|
|
28
|
+
start_line: c.start_line,
|
|
29
|
+
end_line: c.end_line,
|
|
30
|
+
content: c.content,
|
|
31
|
+
}));
|
|
32
|
+
out.push({
|
|
33
|
+
file: input.file,
|
|
34
|
+
total_chunks: allChunks.length,
|
|
35
|
+
chunks,
|
|
36
|
+
project: repo.name,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
31
40
|
}
|
|
32
41
|
//# sourceMappingURL=get_doc_chunk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_doc_chunk.js","sourceRoot":"","sources":["../../src/tools/get_doc_chunk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_doc_chunk.js","sourceRoot":"","sources":["../../src/tools/get_doc_chunk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM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B,OAAO,EAAE,CAAC,CAAC,OAAO;gBAClB,UAAU,EAAE,CAAC,CAAC,UAAU;gBACxB,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,OAAO,EAAE,CAAC,CAAC,OAAO;aACnB,CAAC,CAAC,CAAC;QAEV,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,YAAY,EAAE,SAAS,CAAC,MAAM;YAC9B,MAAM;YACN,OAAO,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
1
|
import type { GetFileSummaryInput, GetFileSummaryOutput } from '../types.js';
|
|
3
|
-
|
|
2
|
+
import type { RepoSet } from '../federation/repo-set.js';
|
|
3
|
+
export declare function getFileSummary(repoSet: RepoSet, input: GetFileSummaryInput): GetFileSummaryOutput[];
|
|
4
4
|
//# sourceMappingURL=get_file_summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_file_summary.d.ts","sourceRoot":"","sources":["../../src/tools/get_file_summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"get_file_summary.d.ts","sourceRoot":"","sources":["../../src/tools/get_file_summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAc,MAAM,aAAa,CAAC;AAOzF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGzD,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,mBAAmB,GACzB,oBAAoB,EAAE,CAuDxB"}
|
|
@@ -1,42 +1,53 @@
|
|
|
1
1
|
import { getFileByPath, getSymbolsByFileId, getDependenciesByFile, getObservationsByFile, } from '../db/queries.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
// Attach memory context if prior observations exist for this file
|
|
31
|
-
const observations = getObservationsByFile(db, input.file, 3);
|
|
32
|
-
if (observations.length > 0) {
|
|
33
|
-
const hasStale = observations.some((o) => o.stale === 1);
|
|
34
|
-
output.memory_context = {
|
|
35
|
-
last_seen_session: observations[0]?.session_id ?? null,
|
|
36
|
-
observations: observations.map((o) => o.observation),
|
|
37
|
-
stale: hasStale,
|
|
2
|
+
import { resolveWithinRoot } from '../util/paths.js';
|
|
3
|
+
export function getFileSummary(repoSet, input) {
|
|
4
|
+
const repos = repoSet.filter(input.repos);
|
|
5
|
+
const out = [];
|
|
6
|
+
for (const repo of repos) {
|
|
7
|
+
// Defense-in-depth: reject paths that escape the repo root before serving
|
|
8
|
+
// any metadata (mirrors get_context.ts; closes the SEC-08 read-back surface).
|
|
9
|
+
if (repo.path && !resolveWithinRoot(repo.path, input.file))
|
|
10
|
+
continue;
|
|
11
|
+
const file = getFileByPath(repo.db, input.file);
|
|
12
|
+
if (!file)
|
|
13
|
+
continue;
|
|
14
|
+
const symbols = getSymbolsByFileId(repo.db, file.id);
|
|
15
|
+
const imports = getDependenciesByFile(repo.db, file.id);
|
|
16
|
+
const exports = symbols.filter((s) => s.is_exported === 1).map((s) => s.name);
|
|
17
|
+
const summary = {
|
|
18
|
+
summary: file.summary,
|
|
19
|
+
language: file.language,
|
|
20
|
+
symbols: symbols.map((s) => ({
|
|
21
|
+
name: s.name,
|
|
22
|
+
kind: s.kind,
|
|
23
|
+
signature: s.signature,
|
|
24
|
+
})),
|
|
25
|
+
imports,
|
|
26
|
+
exports,
|
|
27
|
+
tokenEstimate: file.raw_token_estimate ?? undefined,
|
|
28
|
+
project: repo.name,
|
|
38
29
|
};
|
|
30
|
+
// Compute line count from token estimate (rough: 1 token ≈ 4 chars ≈ 0.5 lines)
|
|
31
|
+
// Better: count lines stored via raw_token_estimate proxy. We expose both.
|
|
32
|
+
// raw_token_estimate is already stored; derive line count from it if needed.
|
|
33
|
+
// For files that have been indexed, we can read the line count from the DB.
|
|
34
|
+
// Since line count is not stored, derive an estimate: ~80 chars per line.
|
|
35
|
+
if (file.raw_token_estimate != null) {
|
|
36
|
+
const estimatedChars = file.raw_token_estimate * 4;
|
|
37
|
+
summary.lineCount = Math.round(estimatedChars / 50); // ~50 chars per line avg
|
|
38
|
+
}
|
|
39
|
+
// Attach memory context if prior observations exist for this file
|
|
40
|
+
const observations = getObservationsByFile(repo.db, input.file, 3);
|
|
41
|
+
if (observations.length > 0) {
|
|
42
|
+
const hasStale = observations.some((o) => o.stale === 1);
|
|
43
|
+
summary.memory_context = {
|
|
44
|
+
last_seen_session: observations[0]?.session_id ?? null,
|
|
45
|
+
observations: observations.map((o) => o.observation),
|
|
46
|
+
stale: hasStale,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
out.push(summary);
|
|
39
50
|
}
|
|
40
|
-
return
|
|
51
|
+
return out;
|
|
41
52
|
}
|
|
42
53
|
//# sourceMappingURL=get_file_summary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_file_summary.js","sourceRoot":"","sources":["../../src/tools/get_file_summary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_file_summary.js","sourceRoot":"","sources":["../../src/tools/get_file_summary.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAE1B,OA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H,OAAO;YACP,OAAO;YACP,aAAa,EAAE,IAAI,CAAC,kBAAkB,IAAI,SAAS;YACnD,OAAO,EAAE,IAAI,CAAC,IAAI;SACnB,CAAC;QAEF,gFAAgF;QAChF,2EAA2E;QAC3E,6EAA6E;QAC7E,4EAA4E;QAC5E,0EAA0E;QAC1E,IAAI,IAAI,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;YACpC,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,GAAG,CAAC,CAAC;YACnD,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC,CAAC,yBAAyB;QAChF,CAAC;QAED,kEAAkE;QAClE,MAAM,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACnE,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;YACzD,OAAO,CAAC,cAAc,GAAG;gBACvB,iBAAiB,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,UAAU,IAAI,IAAI;gBACtD,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC;gBACpD,KAAK,EAAE,QAAQ;aAChB,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type Database from 'better-sqlite3';
|
|
2
1
|
import type { GetProjectOverviewInput, GetProjectOverviewOutput } from '../types.js';
|
|
3
|
-
import type {
|
|
4
|
-
export declare function getProjectOverview(
|
|
2
|
+
import type { RepoSet } from '../federation/repo-set.js';
|
|
3
|
+
export declare function getProjectOverview(repoSet: RepoSet, primaryProjectRoot: string, sessionId?: string, input?: GetProjectOverviewInput): GetProjectOverviewOutput;
|
|
5
4
|
//# sourceMappingURL=get_project_overview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_project_overview.d.ts","sourceRoot":"","sources":["../../src/tools/get_project_overview.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_project_overview.d.ts","sourceRoot":"","sources":["../../src/tools/get_project_overview.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EAIzB,MAAM,aAAa,CAAC;AAOrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAkHzD,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,GAAE,MAAkB,EAC7B,KAAK,CAAC,EAAE,uBAAuB,GAC9B,wBAAwB,CAsB1B"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getAllFiles, countStaleObservations, countPriorSessions, getAntiPatternEvents, } from '../db/queries.js';
|
|
2
|
-
|
|
3
|
-
const mode = input?.mode ?? 'full';
|
|
2
|
+
function buildSnapshot(db, name, sessionId, projectRoot, mode = 'full') {
|
|
4
3
|
const files = getAllFiles(db);
|
|
5
4
|
if (files.length === 0) {
|
|
6
5
|
return {
|
|
7
|
-
|
|
6
|
+
project: name,
|
|
7
|
+
rootPath: projectRoot ?? '',
|
|
8
8
|
language: 'unknown',
|
|
9
9
|
entryPoints: [],
|
|
10
10
|
modules: [],
|
|
@@ -45,14 +45,15 @@ export function getProjectOverview(db, projectRoot, federatedDbs = [], sessionId
|
|
|
45
45
|
symbolCount: symbolCounts.get(f.id) ?? 0,
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const snapshot = {
|
|
49
|
+
project: name,
|
|
50
|
+
rootPath: projectRoot ?? '',
|
|
50
51
|
language,
|
|
51
52
|
entryPoints,
|
|
52
53
|
modules,
|
|
53
54
|
stats: { totalFiles: files.length, totalSymbols },
|
|
54
55
|
};
|
|
55
|
-
// Session memory summary (passive surfacing)
|
|
56
|
+
// Session memory summary (passive surfacing) — only for primary
|
|
56
57
|
if (sessionId) {
|
|
57
58
|
const staleCount = countStaleObservations(db);
|
|
58
59
|
const priorSessions = countPriorSessions(db, sessionId);
|
|
@@ -67,18 +68,13 @@ export function getProjectOverview(db, projectRoot, federatedDbs = [], sessionId
|
|
|
67
68
|
active_anti_patterns: antiPatterns,
|
|
68
69
|
hint: hasContext ? 'call get_session_memory for details' : null,
|
|
69
70
|
};
|
|
70
|
-
|
|
71
|
+
snapshot.session_memory = session_memory;
|
|
71
72
|
}
|
|
72
73
|
// ── Index recommendation ──────────────────────────────────────────────────
|
|
73
|
-
// Estimate whether using PindeX tools saves tokens vs direct file reads.
|
|
74
|
-
// Break-even: tool-def overhead (~800 tokens/turn × ~6 turns = ~5K) vs
|
|
75
|
-
// savings from avoiding full-file reads (avgFileTokens × avoidsPerSession).
|
|
76
|
-
// Heuristic thresholds tuned against benchmark data.
|
|
77
74
|
const BREAK_EVEN_FILES = 40;
|
|
78
75
|
const BREAK_EVEN_AVG_LINES = 150;
|
|
79
76
|
const tokenRow = db.prepare('SELECT COALESCE(SUM(raw_token_estimate), 0) as total FROM files').get();
|
|
80
77
|
const avgFileTokens = files.length > 0 ? tokenRow.total / files.length : 0;
|
|
81
|
-
// 1 token ≈ 4 chars ≈ 1/50 line (assuming ~200 chars/line avg)
|
|
82
78
|
const avgFileLinesEstimate = Math.round(avgFileTokens * 4 / 50);
|
|
83
79
|
const worthwhile = files.length >= BREAK_EVEN_FILES || avgFileLinesEstimate >= BREAK_EVEN_AVG_LINES;
|
|
84
80
|
const recommendation = {
|
|
@@ -89,15 +85,19 @@ export function getProjectOverview(db, projectRoot, federatedDbs = [], sessionId
|
|
|
89
85
|
avgFileLinesEstimate,
|
|
90
86
|
breakEvenFiles: BREAK_EVEN_FILES,
|
|
91
87
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
snapshot.index_recommendation = recommendation;
|
|
89
|
+
return snapshot;
|
|
90
|
+
}
|
|
91
|
+
export function getProjectOverview(repoSet, primaryProjectRoot, sessionId = 'default', input) {
|
|
92
|
+
const mode = input?.mode ?? 'full';
|
|
93
|
+
const repos = repoSet.filter(input?.repos);
|
|
94
|
+
const primary = repoSet.primary;
|
|
95
|
+
const snapshots = repos.map((repo) => buildSnapshot(repo.db, repo.name, repo.isPrimary ? sessionId : '', repo.isPrimary ? primaryProjectRoot : repo.path, mode));
|
|
96
|
+
const primarySnap = snapshots.find((s) => s.project === primary.name) ?? snapshots[0];
|
|
97
|
+
const federated = snapshots.filter((s) => s !== primarySnap);
|
|
98
|
+
return {
|
|
99
|
+
...primarySnap,
|
|
100
|
+
federated_projects: federated.length > 0 ? federated : undefined,
|
|
101
|
+
};
|
|
102
102
|
}
|
|
103
103
|
//# sourceMappingURL=get_project_overview.js.map
|