@blackbelt-technology/pi-dashboard-kb 0.7.0 → 0.8.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 +23 -0
- package/dist/cli.js +52 -5
- package/dist/config.d.ts +16 -0
- package/dist/config.js +16 -2
- package/dist/dox-triage.d.ts +66 -0
- package/dist/dox-triage.js +176 -0
- package/dist/dox.d.ts +24 -2
- package/dist/dox.js +145 -4
- package/dist/eval.d.ts +6 -0
- package/dist/eval.js +14 -0
- package/dist/indexer.d.ts +2 -1
- package/dist/indexer.js +2 -2
- package/dist/render.js +19 -2
- package/dist/sqlite-store.d.ts +33 -0
- package/dist/sqlite-store.js +345 -69
- package/dist/types.d.ts +19 -0
- package/package.json +3 -1
- package/src/cli.ts +46 -5
- package/src/config.ts +27 -2
- package/src/dox-triage.ts +223 -0
- package/src/dox.ts +141 -6
- package/src/eval.ts +19 -0
- package/src/indexer.ts +2 -2
- package/src/render.ts +18 -2
- package/src/sqlite-store.ts +317 -58
- package/src/types.ts +15 -0
- package/src/AGENTS.md +0 -23
package/dist/dox.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// `kb agents <path>` nearest-applicable chain (design §6d). Pure-local,
|
|
3
3
|
// deterministic, no LLM/embedding. The detect-don't-write rule: `dox init`
|
|
4
4
|
// and `--fix` only fill PATH columns / prune orphans; the LLM authors purposes.
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync, appendFileSync } from "node:fs";
|
|
6
|
-
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
7
5
|
import { createHash } from "node:crypto";
|
|
6
|
+
import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
7
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
8
8
|
// delta ②: exclude worktree checkouts, archived openspec proposals, and doc-example noise.
|
|
9
9
|
// Also exclude build output (`out`) and the electron bundled/vendored trees
|
|
10
10
|
// (`bundled-extensions`, `electron/resources/server`) — all gitignored, zero
|
|
@@ -16,8 +16,20 @@ import { createHash } from "node:crypto";
|
|
|
16
16
|
// navigable source) and self-evident top-level docs (`CHANGELOG.md`, `CLAUDE.md`,
|
|
17
17
|
// repo-root `README.md`) with no per-file DOX value; `README` anchored to root so
|
|
18
18
|
// package READMEs stay documented.
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
// `.pi` is NOT excluded wholesale: `.pi/skills/`, `.pi/agents/` and `.pi/prompts/`
|
|
20
|
+
// carry per-file DOX rows per the Documentation Update Protocol, and excluding the
|
|
21
|
+
// whole tree blinded the orphan check there. Only the non-source `.pi` subdirs
|
|
22
|
+
// (caches, kb index, npm/git mirrors, flow run state) are skipped.
|
|
23
|
+
const DEFAULT_EXCLUDE = /(^|\/)(node_modules|\.git|\.github|dist|build|out|\.next|coverage|\.kb|\.worktrees|\.reverse-spec-scratch|openspec|doc-example|bundled-extensions|mockups|research|site|Prompt stories)(\/|$)|(^|\/)\.pi\/(dashboard|npm|git|flows)(\/|$)|(^|\/)electron\/resources\/server(\/|$)|(^|\/)(CHANGELOG|CLAUDE)\.md$|^README\.md$/;
|
|
24
|
+
/**
|
|
25
|
+
* `AGENTS.override.md` (pi 0.84.0) REPLACES a directory's context rather than
|
|
26
|
+
* adding to it, so it is listed first and shadows the other candidates in the
|
|
27
|
+
* SAME directory. Mirrors pi's own first-match-wins candidate list in
|
|
28
|
+
* `dist/core/resource-loader.js`. Ancestor inheritance is unaffected.
|
|
29
|
+
* See change: update-pi-core-0-84-adopt-apis.
|
|
30
|
+
*/
|
|
31
|
+
const AGENTS_OVERRIDE_FILE = "AGENTS.override.md";
|
|
32
|
+
const AGENTS_FILES = [AGENTS_OVERRIDE_FILE, "AGENTS.md"];
|
|
21
33
|
// delta ①: dox init now maps SOURCE, not docs. Source globs, minus type decls and tests.
|
|
22
34
|
const SOURCE_EXT = /\.(ts|tsx|js|jsx)$/;
|
|
23
35
|
const MD_EXT = /\.(md|mdx)$/i;
|
|
@@ -63,7 +75,16 @@ export function agentsChain(cwd, targetPath, opts = {}) {
|
|
|
63
75
|
const ordered = dirs.reverse();
|
|
64
76
|
const chain = [];
|
|
65
77
|
ordered.forEach((dir, depth) => {
|
|
78
|
+
// An override replaces this directory's context: take it alone and skip the
|
|
79
|
+
// siblings, otherwise the same logical scope is injected twice.
|
|
80
|
+
const override = join(dir, AGENTS_OVERRIDE_FILE);
|
|
81
|
+
if (existsSync(override)) {
|
|
82
|
+
chain.push({ path: override, rel: relative(cwd, override) || AGENTS_OVERRIDE_FILE, depth });
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
66
85
|
for (const name of names) {
|
|
86
|
+
if (name === AGENTS_OVERRIDE_FILE)
|
|
87
|
+
continue;
|
|
67
88
|
const p = join(dir, name);
|
|
68
89
|
if (existsSync(p))
|
|
69
90
|
chain.push({ path: p, rel: relative(cwd, p) || name, depth });
|
|
@@ -245,6 +266,84 @@ export function doxInit(opts) {
|
|
|
245
266
|
}
|
|
246
267
|
return plan;
|
|
247
268
|
}
|
|
269
|
+
// --- dox lint ---
|
|
270
|
+
/**
|
|
271
|
+
* Pull repo-path REFERENCES out of a row's purpose cell.
|
|
272
|
+
*
|
|
273
|
+
* The lint hashes the file behind each row but never validates paths written
|
|
274
|
+
* inside the prose, so a directory move silently rots cross-references (this is
|
|
275
|
+
* how a routing rule kept pointing at two deleted dirs). The hard part is not
|
|
276
|
+
* finding candidates — it is rejecting the ~99% that are not repo paths at all:
|
|
277
|
+
* URL routes, MIME types, npm specifiers, `~`/absolute paths, model ids, code
|
|
278
|
+
* fragments like `get/list/remove`, and descriptions of OTHER projects' layouts.
|
|
279
|
+
*
|
|
280
|
+
* Discriminators, in order of how much noise each removes:
|
|
281
|
+
* 1. first segment must be a real top-level entry of THIS repo — kills
|
|
282
|
+
* `lib/validations.ts` (consumer-project prose) and `provider/model`
|
|
283
|
+
* 2. must carry a source-file extension or be a glob — kills bare route paths
|
|
284
|
+
* 3. structural rejects: leading `~` or `/`, `@` scopes, and any char that
|
|
285
|
+
* cannot appear in a path we would write (`:?="'()[]{}<>` , whitespace…)
|
|
286
|
+
*/
|
|
287
|
+
export function extractRefPaths(cell, topLevel) {
|
|
288
|
+
const out = [];
|
|
289
|
+
for (const m of cell.matchAll(/`([^`]+)`/g)) {
|
|
290
|
+
const raw = m[1].trim();
|
|
291
|
+
if (!raw.includes("/"))
|
|
292
|
+
continue;
|
|
293
|
+
if (/^[~/@]/.test(raw))
|
|
294
|
+
continue; // home, absolute, npm scope
|
|
295
|
+
if (/[:?="'()[\]{}<>|,;!#\s]/.test(raw))
|
|
296
|
+
continue; // routes, code, prose, placeholders
|
|
297
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: intentional non-ASCII guard
|
|
298
|
+
if (/[^\x20-\x7e]/.test(raw))
|
|
299
|
+
continue;
|
|
300
|
+
const p = raw.replace(/^\.\//, "").replace(/\/$/, "");
|
|
301
|
+
if (!p.includes("/"))
|
|
302
|
+
continue;
|
|
303
|
+
if (!topLevel.has(p.split("/")[0]))
|
|
304
|
+
continue;
|
|
305
|
+
if (!/\.[a-z0-9]{1,5}$/i.test(p) && !p.includes("*"))
|
|
306
|
+
continue;
|
|
307
|
+
// Build output and excluded trees (`packages/electron/out/*`, `.worktrees/*`)
|
|
308
|
+
// are legitimately absent until built/created — flagging them is noise, and a
|
|
309
|
+
// check that cries wolf gets ignored.
|
|
310
|
+
if (DEFAULT_EXCLUDE.test(p))
|
|
311
|
+
continue;
|
|
312
|
+
out.push(p);
|
|
313
|
+
}
|
|
314
|
+
return out;
|
|
315
|
+
}
|
|
316
|
+
/** Cheap glob test for `*` / `**` reference paths (no dependency on a matcher). */
|
|
317
|
+
function globHit(pattern, cwd) {
|
|
318
|
+
const rx = new RegExp(`^${pattern
|
|
319
|
+
.split("/")
|
|
320
|
+
.map((s) => s
|
|
321
|
+
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
|
|
322
|
+
.replace(/\*\*/g, "\u0001")
|
|
323
|
+
.replace(/\*/g, "[^/]*")
|
|
324
|
+
.replace(/\u0001/g, ".*"))
|
|
325
|
+
.join("/")}$`);
|
|
326
|
+
const walk = (dir, rel) => {
|
|
327
|
+
let entries = [];
|
|
328
|
+
try {
|
|
329
|
+
entries = readdirSync(dir, { withFileTypes: true });
|
|
330
|
+
}
|
|
331
|
+
catch {
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
for (const e of entries) {
|
|
335
|
+
const r = rel ? `${rel}/${e.name}` : e.name;
|
|
336
|
+
if (DEFAULT_EXCLUDE.test(r))
|
|
337
|
+
continue;
|
|
338
|
+
if (rx.test(r))
|
|
339
|
+
return true;
|
|
340
|
+
if (e.isDirectory() && walk(join(dir, e.name), r))
|
|
341
|
+
return true;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
};
|
|
345
|
+
return walk(cwd, "");
|
|
346
|
+
}
|
|
248
347
|
function fileSha(p) {
|
|
249
348
|
try {
|
|
250
349
|
return createHash("sha256").update(readFileSync(p)).digest("hex");
|
|
@@ -265,6 +364,17 @@ export function doxLint(opts) {
|
|
|
265
364
|
const cwd = opts.cwd;
|
|
266
365
|
const issues = [];
|
|
267
366
|
let fixed = 0;
|
|
367
|
+
// Top-level entries of THIS repo — the primary discriminator that stops
|
|
368
|
+
// broken-ref from firing on prose that merely looks path-shaped.
|
|
369
|
+
const topLevelEntries = new Set();
|
|
370
|
+
try {
|
|
371
|
+
for (const e of readdirSync(cwd, { withFileTypes: true }))
|
|
372
|
+
topLevelEntries.add(e.name);
|
|
373
|
+
}
|
|
374
|
+
catch {
|
|
375
|
+
/* empty cwd — leave the set empty, which disables broken-ref entirely */
|
|
376
|
+
}
|
|
377
|
+
const seenRefs = new Set();
|
|
268
378
|
// find all AGENTS.md
|
|
269
379
|
const agentsFiles = [];
|
|
270
380
|
// Test the path RELATIVE to cwd (mirrors walkFiles) so an ancestor dir named
|
|
@@ -329,6 +439,19 @@ export function doxLint(opts) {
|
|
|
329
439
|
continue;
|
|
330
440
|
}
|
|
331
441
|
const rp = m[1];
|
|
442
|
+
// Cross-references inside the PURPOSE cell. Rot here is invisible to the
|
|
443
|
+
// hash check, because the row's own file is untouched by the move.
|
|
444
|
+
const purposeCell = line.slice(line.indexOf("|", line.indexOf("`" + rp + "`")) + 1);
|
|
445
|
+
for (const ref of extractRefPaths(purposeCell, topLevelEntries)) {
|
|
446
|
+
if (seenRefs.has(ref))
|
|
447
|
+
continue;
|
|
448
|
+
seenRefs.add(ref);
|
|
449
|
+
const hit = ref.includes("*")
|
|
450
|
+
? globHit(ref, cwd)
|
|
451
|
+
: existsSync(join(cwd, ref)) || existsSync(join(afDir, ref));
|
|
452
|
+
if (!hit)
|
|
453
|
+
issues.push({ kind: "broken-ref", agentsFile: afRel, path: ref, detail: `broken-ref: row prose cites ${ref}, which does not exist` });
|
|
454
|
+
}
|
|
332
455
|
const abs = resolveRowPath(afDir, cwd, rp);
|
|
333
456
|
const rel = relative(cwd, abs);
|
|
334
457
|
rowPaths.add(rel);
|
|
@@ -382,6 +505,24 @@ export function doxLint(opts) {
|
|
|
382
505
|
}
|
|
383
506
|
}
|
|
384
507
|
}
|
|
508
|
+
// missing rows, SOURCE arm (design D9): a .ts/.tsx in a covered area with no
|
|
509
|
+
// row in ANY ancestor AGENTS.md and no <file>.AGENTS.md sidecar is unreachable
|
|
510
|
+
// through the `agents` doc-type lane that retrieval depends on. Opt-in, and
|
|
511
|
+
// never auto-fixed: a blank purpose row is worse than an honest finding.
|
|
512
|
+
if (opts.sourceFileRows) {
|
|
513
|
+
for (const abs of sourceFiles(cwd)) {
|
|
514
|
+
const rel = relative(cwd, abs);
|
|
515
|
+
if (rowPaths.has(rel))
|
|
516
|
+
continue;
|
|
517
|
+
if (existsSync(join(cwd, `${rel}.AGENTS.md`)))
|
|
518
|
+
continue;
|
|
519
|
+
const dir = rel.includes("/") ? rel.slice(0, rel.lastIndexOf("/")) : ".";
|
|
520
|
+
const owner = ownerOf(dir);
|
|
521
|
+
if (!owner)
|
|
522
|
+
continue;
|
|
523
|
+
issues.push({ kind: "missing", arm: "source", agentsFile: relative(cwd, owner) || "AGENTS.md", path: rel, detail: `no row for source file ${rel}` });
|
|
524
|
+
}
|
|
525
|
+
}
|
|
385
526
|
// missing companions: large source/md files with no <file>.agent.md
|
|
386
527
|
for (const md of allMd) {
|
|
387
528
|
const abs = join(cwd, md);
|
package/dist/eval.d.ts
CHANGED
|
@@ -10,6 +10,12 @@ export interface EvalMetrics {
|
|
|
10
10
|
"Recall@K": number;
|
|
11
11
|
MRR: number;
|
|
12
12
|
"nDCG@K": number;
|
|
13
|
+
/** Mean count of distinct `(root, path)` sources per top-K page (D8). */
|
|
14
|
+
distinctSourcesAtK: number;
|
|
15
|
+
/** Mean fraction of slots whose source already appeared earlier on the page. */
|
|
16
|
+
duplicateSlotShare: number;
|
|
17
|
+
/** Fraction of queries whose whole top-K page comes from one source. */
|
|
18
|
+
singleSourcePageRate: number;
|
|
13
19
|
avgLatencyMs: number;
|
|
14
20
|
}
|
|
15
21
|
export declare function evaluate(store: KbStore, golden: GoldenItem[], opts?: SearchOpts & {
|
package/dist/eval.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export function evaluate(store, golden, opts = {}) {
|
|
2
2
|
const k = opts.k ?? 10;
|
|
3
3
|
let p1 = 0, p5 = 0, recall = 0, mrr = 0, ndcg = 0, lat = 0;
|
|
4
|
+
// Redundancy accumulators (D8). Precision/recall are blind to page composition
|
|
5
|
+
// by construction, so redundancy is tracked as its own first-class metric.
|
|
6
|
+
let distinct = 0, dupShare = 0, singleSource = 0, pages = 0;
|
|
4
7
|
for (const g of golden) {
|
|
5
8
|
const t = performance.now();
|
|
6
9
|
const res = store.search(g.q, { ...opts, limit: k });
|
|
@@ -19,6 +22,14 @@ export function evaluate(store, golden, opts = {}) {
|
|
|
19
22
|
mrr += 1 / first;
|
|
20
23
|
ndcg += 1 / Math.log2(first + 1); // IDCG=1 (single relevant target)
|
|
21
24
|
}
|
|
25
|
+
if (res.length) {
|
|
26
|
+
const sources = new Set(res.map((r) => `${r.root}\u001f${r.path}`));
|
|
27
|
+
distinct += sources.size;
|
|
28
|
+
dupShare += (res.length - sources.size) / res.length;
|
|
29
|
+
if (sources.size === 1)
|
|
30
|
+
singleSource++;
|
|
31
|
+
pages++;
|
|
32
|
+
}
|
|
22
33
|
}
|
|
23
34
|
const n = golden.length || 1;
|
|
24
35
|
return {
|
|
@@ -28,6 +39,9 @@ export function evaluate(store, golden, opts = {}) {
|
|
|
28
39
|
"Recall@K": +(recall / n).toFixed(3),
|
|
29
40
|
MRR: +(mrr / n).toFixed(3),
|
|
30
41
|
"nDCG@K": +(ndcg / n).toFixed(3),
|
|
42
|
+
distinctSourcesAtK: +(distinct / (pages || 1)).toFixed(3),
|
|
43
|
+
duplicateSlotShare: +(dupShare / (pages || 1)).toFixed(3),
|
|
44
|
+
singleSourcePageRate: +(singleSource / (pages || 1)).toFixed(3),
|
|
31
45
|
avgLatencyMs: +(lat / n).toFixed(2),
|
|
32
46
|
};
|
|
33
47
|
}
|
package/dist/indexer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FacetKeyConfig } from "./frontmatter.js";
|
|
2
|
-
import type { KbStore } from "./types.js";
|
|
2
|
+
import type { DocType, KbStore } from "./types.js";
|
|
3
3
|
export interface IndexSource {
|
|
4
4
|
root: string;
|
|
5
5
|
dir: string;
|
|
@@ -25,4 +25,5 @@ export interface IndexStats {
|
|
|
25
25
|
parseFailures?: number;
|
|
26
26
|
missing?: boolean;
|
|
27
27
|
}
|
|
28
|
+
export declare function docTypeOf(rel: string, includeSourceMarkdown: boolean): DocType;
|
|
28
29
|
export declare function indexSource(store: KbStore, src: IndexSource, opts?: IndexOptions): Promise<IndexStats>;
|
package/dist/indexer.js
CHANGED
|
@@ -42,12 +42,12 @@ function walk(dir, base, out = []) {
|
|
|
42
42
|
}
|
|
43
43
|
return out;
|
|
44
44
|
}
|
|
45
|
-
function docTypeOf(rel, includeSourceMarkdown) {
|
|
45
|
+
export function docTypeOf(rel, includeSourceMarkdown) {
|
|
46
46
|
const base = rel.split("/").pop() ?? "";
|
|
47
47
|
// `<File>.AGENTS.md` = per-file index sidecar (large-row promotion). Classified
|
|
48
48
|
// `agents` so it is searchable, but its name != "AGENTS.md" so pi's native
|
|
49
49
|
// up-walk never auto-injects it (pull-only via kb search).
|
|
50
|
-
if (base === "AGENTS.md" || base === "CLAUDE.md" || base.endsWith(".AGENTS.md"))
|
|
50
|
+
if (base === "AGENTS.override.md" || base === "AGENTS.md" || base === "CLAUDE.md" || base.endsWith(".AGENTS.md"))
|
|
51
51
|
return "agents";
|
|
52
52
|
if (includeSourceMarkdown && /(^|\/)(src|lib|app|packages)\//.test(rel))
|
|
53
53
|
return "source-md";
|
package/dist/render.js
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
1
|
const SNIPPET_MAX = 160;
|
|
2
|
+
/** Leaf of a `A > B > C` breadcrumb. 47% of a rendered page was breadcrumb text
|
|
3
|
+
* and 38% of that was a prefix repeated inside one file group, while the leaf
|
|
4
|
+
* carries the discriminating token. Full `headingPath` stays in `KbHit` and in
|
|
5
|
+
* the JSON format so `kb_get(path, section)` addressing still works.
|
|
6
|
+
* See change: fix-kb-search-retrieval-quality (design D5). */
|
|
7
|
+
function leafHeading(headingPath) {
|
|
8
|
+
const parts = headingPath.split(" > ");
|
|
9
|
+
return parts[parts.length - 1] || headingPath;
|
|
10
|
+
}
|
|
2
11
|
/** Render hits to text. `rank` is a 1-based ordinal over the given (post-limit) list. */
|
|
3
12
|
export function renderHits(hits, opts) {
|
|
4
13
|
const { leading, parentGlyph, multiline } = opts;
|
|
5
14
|
return hits
|
|
6
15
|
.map((h, i) => {
|
|
7
16
|
const lead = leading === "rank" ? String(i + 1) : h.score.toFixed(2);
|
|
8
|
-
const head = `${lead} ${h.path} :: ${h.headingPath}`;
|
|
9
|
-
const
|
|
17
|
+
const head = `${lead} ${h.path} :: ${leafHeading(h.headingPath)}`;
|
|
18
|
+
const marks = [];
|
|
19
|
+
if (h.akaPaths?.length)
|
|
20
|
+
marks.push(`(+${h.akaPaths.length} dup)`);
|
|
21
|
+
// Per-source match count from source-level dedup: a free relevance signal
|
|
22
|
+
// ("this file is the topic authority") in five tokens.
|
|
23
|
+
const sup = h.suppressedSections ?? 0;
|
|
24
|
+
if (sup > 0)
|
|
25
|
+
marks.push(`(+${sup} more section${sup === 1 ? "" : "s"})`);
|
|
26
|
+
const dup = marks.join(" ");
|
|
10
27
|
const snippet = h.snippet.replace(/\s+/g, " ").slice(0, SNIPPET_MAX);
|
|
11
28
|
if (multiline) {
|
|
12
29
|
const lines = [head];
|
package/dist/sqlite-store.d.ts
CHANGED
|
@@ -38,10 +38,43 @@ export declare class SqliteFtsStore implements KbStore {
|
|
|
38
38
|
insertChunk(c: Chunk): void;
|
|
39
39
|
addNode(n: GraphNode): void;
|
|
40
40
|
addEdge(e: GraphEdge): void;
|
|
41
|
+
/** Porter stems for raw tokens, computed by SQLite's OWN tokenizer so they
|
|
42
|
+
* match what FTS5 actually indexed. A raw token is NOT a usable key into the
|
|
43
|
+
* vocab table: FTS5 stores `collaps`, and no prefix range anchored at
|
|
44
|
+
* `collapsed` can reach a key that sorts BEFORE it. The helper tables live in
|
|
45
|
+
* `temp.`, so this works against a read-only main DB. */
|
|
46
|
+
private stemReady;
|
|
47
|
+
private stemCache;
|
|
48
|
+
private stems;
|
|
49
|
+
/** Corpus document frequency for raw tokens, via the fts5vocab shadow table.
|
|
50
|
+
* Keys are exact porter stems (see `stems()`), so df is exact rather than a
|
|
51
|
+
* prefix over-estimate. `fts5vocab` is a live view over the FTS index, but
|
|
52
|
+
* `dfCache` is not — it is dropped on `commit()`/`deleteByPath`, the points at
|
|
53
|
+
* which an index batch can have moved the counts. Falls back to df=0 when the
|
|
54
|
+
* vocab table cannot be created (e.g. a read-only DB). */
|
|
55
|
+
private dfCache;
|
|
56
|
+
private vocabReady;
|
|
57
|
+
private documentFrequencies;
|
|
58
|
+
/** IDF weights for the given tokens over the current corpus. */
|
|
59
|
+
private idf;
|
|
41
60
|
search(query: string, opts?: SearchOpts): KbHit[];
|
|
42
61
|
neighbors(node: string, depth: number, rel?: GraphEdge["rel"]): GraphNode[];
|
|
43
62
|
backlinks(node: string): GraphNode[];
|
|
63
|
+
/** Fetch a chunk by path (+ optional section). A path-only fetch of a
|
|
64
|
+
* multi-chunk file returns the FIRST chunk plus a `suppressedSections` count
|
|
65
|
+
* — it must never silently hand back one arbitrary slice of N (design D7). */
|
|
44
66
|
getChunk(root: string, path: string, headingPath?: string): Chunk | null;
|
|
67
|
+
/** All chunks of a file in document order — the non-truncating companion to a
|
|
68
|
+
* path-only `getChunk`. */
|
|
69
|
+
getChunks(root: string, path: string): Chunk[];
|
|
70
|
+
/** Rerank by IDF-weighted coverage of the ORIGINAL query terms, BM25 as the
|
|
71
|
+
* tiebreak. PRF-appended terms count at half weight so expansion can never
|
|
72
|
+
* dominate the sort (design D4). */
|
|
73
|
+
private coverageRerank;
|
|
74
|
+
/** RM3-style pseudo-relevance feedback: mine the top candidates of a first
|
|
75
|
+
* pass for terms absent from the query and below the corpus-frequency
|
|
76
|
+
* ceiling, rank by freq × IDF, return the top `terms` (design D4). */
|
|
77
|
+
private prfTerms;
|
|
45
78
|
getChunkById(root: string, chunkId: string): Chunk | null;
|
|
46
79
|
counts(): {
|
|
47
80
|
files: number;
|