@wrongstack/tools 1.0.0 → 1.0.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.
Files changed (70) hide show
  1. package/dist/auto-proceed-loop-guard.d.ts +1 -1
  2. package/dist/auto-proceed-loop-guard.js +1 -1
  3. package/dist/bash.js +1 -1
  4. package/dist/builtin.js +15 -15
  5. package/dist/{chunk-VVZPQPTY.js → chunk-3AU6CZWL.js} +4 -2
  6. package/dist/{chunk-N3K2SFEI.js → chunk-52UXXQMP.js} +1408 -200
  7. package/dist/{chunk-NN2SNP2R.js → chunk-6H4ERJP7.js} +137 -21
  8. package/dist/{chunk-DK4J2WMH.js → chunk-7XUEPBNT.js} +2 -2
  9. package/dist/{chunk-IYH4OHBP.js → chunk-DKHMPKDG.js} +2 -2
  10. package/dist/{chunk-NU2IZ72J.js → chunk-DL2ARI4S.js} +7 -5
  11. package/dist/{chunk-M6UV67BH.js → chunk-EL2NJXSK.js} +2 -2
  12. package/dist/{chunk-YEISRT4S.js → chunk-HWXIRVKH.js} +1408 -235
  13. package/dist/{chunk-GKSG5CPH.js → chunk-KVTEIUND.js} +2 -2
  14. package/dist/{chunk-GDDXX27P.js → chunk-MBR5VAB5.js} +2 -2
  15. package/dist/{chunk-KDEXUQY7.js → chunk-MGPR7VG3.js} +261 -258
  16. package/dist/{chunk-YULVUTK5.js → chunk-NFX2IUQA.js} +3 -3
  17. package/dist/{chunk-37QKUQ2Z.js → chunk-NL2S2CXD.js} +1 -1
  18. package/dist/{chunk-ZTCJCYLN.js → chunk-TI5COGLY.js} +49 -6
  19. package/dist/{chunk-CGXTR34H.js → chunk-TU5MTW2S.js} +2 -2
  20. package/dist/{chunk-AB2CAUOP.js → chunk-UCXFTCAI.js} +186 -36
  21. package/dist/{chunk-MK2JK35J.js → chunk-UOYRAS4J.js} +3 -3
  22. package/dist/{chunk-UCYQTZ7F.js → chunk-ZKC5UNGD.js} +56 -2
  23. package/dist/codebase-index/atlas-brief.d.ts +90 -0
  24. package/dist/codebase-index/atlas-export.d.ts +38 -0
  25. package/dist/codebase-index/atlas-projection.d.ts +114 -0
  26. package/dist/codebase-index/atlas-types.d.ts +90 -0
  27. package/dist/codebase-index/background-indexer.d.ts +15 -4
  28. package/dist/codebase-index/codebase-context-tool.d.ts +54 -0
  29. package/dist/codebase-index/concept-enrichment.d.ts +154 -0
  30. package/dist/codebase-index/context-retrieval.d.ts +91 -0
  31. package/dist/codebase-index/embedding-pass.d.ts +95 -0
  32. package/dist/codebase-index/graph-adjacency-cache.d.ts +36 -0
  33. package/dist/codebase-index/graph-rank-pass.d.ts +46 -0
  34. package/dist/codebase-index/graph-rank.d.ts +198 -0
  35. package/dist/codebase-index/index-service.d.ts +15 -1
  36. package/dist/codebase-index/index.d.ts +34 -19
  37. package/dist/codebase-index/index.js +126 -9
  38. package/dist/codebase-index/parser-worker-script.js +3 -3
  39. package/dist/codebase-index/perf-metrics.d.ts +19 -0
  40. package/dist/codebase-index/project-server-protocol.d.ts +2 -0
  41. package/dist/codebase-index/project-server-query-cache.d.ts +4 -0
  42. package/dist/codebase-index/project-server.js +54 -7
  43. package/dist/codebase-index/repo-map-fallback.d.ts +18 -0
  44. package/dist/codebase-index/repo-map-render.d.ts +42 -0
  45. package/dist/codebase-index/repo-map-types.d.ts +21 -0
  46. package/dist/codebase-index/repo-map.d.ts +28 -16
  47. package/dist/codebase-index/schema.d.ts +20 -0
  48. package/dist/codebase-index/worker-protocol.d.ts +47 -1
  49. package/dist/codebase-index/worker.js +11 -5
  50. package/dist/codebase-index/writer-concepts.d.ts +84 -0
  51. package/dist/codebase-index/writer-graph-decorate.d.ts +30 -0
  52. package/dist/codebase-index/writer-graph-reader.d.ts +22 -0
  53. package/dist/codebase-index/writer-rank.d.ts +78 -0
  54. package/dist/codebase-index/writer-schema.d.ts +51 -0
  55. package/dist/codebase-index/writer-vectors.d.ts +53 -0
  56. package/dist/codebase-index/writer.d.ts +59 -0
  57. package/dist/edit.js +7 -7
  58. package/dist/exec.js +1 -1
  59. package/dist/{go-parser-D7ELWQ7F.js → go-parser-QIEXU3P2.js} +4 -2
  60. package/dist/index.d.ts +48 -48
  61. package/dist/index.js +43 -19
  62. package/dist/pack.js +16 -16
  63. package/dist/{parser-dispatch-BDVCJXTV.js → parser-dispatch-37FT3EXQ.js} +4 -4
  64. package/dist/patch.js +7 -7
  65. package/dist/{py-parser-QC6MR4GB.js → py-parser-6GJTGUXK.js} +3 -3
  66. package/dist/read.js +7 -7
  67. package/dist/replace.js +7 -7
  68. package/dist/tool-tier.js +17 -17
  69. package/dist/write.js +7 -7
  70. package/package.json +5 -5
@@ -0,0 +1,95 @@
1
+ /**
2
+ * The semantic embedding pass.
3
+ *
4
+ * Embeds one vector per file so the index can answer questions phrased in the
5
+ * problem's vocabulary rather than the code's — "where do we back off after a
6
+ * 429" instead of `retryAfterMsFromHeaders`.
7
+ *
8
+ * ## What gets embedded, and why it is the file
9
+ *
10
+ * A bare declaration is poor material for an embedding: `function resolve(id:
11
+ * string): Widget` carries almost nothing a lexical index does not already
12
+ * have, and BM25 over FTS5 already matches it better. What carries meaning is
13
+ * the concept layer's description of what a file is *for*, so that is the text
14
+ * this pass embeds, falling back to the file's declaration names when no
15
+ * summary exists yet.
16
+ *
17
+ * That also makes it eight times cheaper than a symbol-level pass on this
18
+ * repository — eight thousand files against sixty-six thousand symbols.
19
+ *
20
+ * ## Why it is a pass and not part of indexing
21
+ *
22
+ * Model inference is asynchronous and batched. The indexer's write path is a
23
+ * synchronous SQLite transaction; running inference inside it would hold a
24
+ * write lock open across thousands of inferences. The older char-trigram
25
+ * embedding could live there precisely because it was neither of those things
26
+ * — and it was also not semantic, which is why it is being superseded rather
27
+ * than extended.
28
+ *
29
+ * ## Why the vectors never silently mix
30
+ *
31
+ * Two models produce incomparable spaces. The provider id is stored with every
32
+ * row and checked before a pass; a change wipes the table and re-embeds rather
33
+ * than leaving half the index in one space and half in another.
34
+ */
35
+ import { type IndexStore } from './writer.js';
36
+ /**
37
+ * The host-supplied embedding model.
38
+ *
39
+ * Structurally identical to the `EmbeddingProvider` that
40
+ * `packages/vector-memory` already defines, so its transformers-backed
41
+ * implementation satisfies this without an adapter. Injected rather than
42
+ * imported for the same reason the summariser is: `packages/tools` must not
43
+ * depend on an optional native model runtime.
44
+ */
45
+ export interface EmbeddingPort {
46
+ /** Stable id including the model and quantisation. Changing it re-embeds. */
47
+ readonly id: string;
48
+ /** Vector length. Must not change for a given `id`. */
49
+ readonly dimensions: number;
50
+ /** Embed a batch. Must return exactly one vector per input, in order. */
51
+ embed(texts: string[]): Promise<Float32Array[]>;
52
+ }
53
+ /** Texts sent per inference call. */
54
+ export declare const DEFAULT_BATCH_SIZE = 16;
55
+ /** Ceiling on embedded text. Beyond this a summary is not a summary. */
56
+ export declare const MAX_EMBED_CHARS = 2000;
57
+ export interface EmbedOptions {
58
+ /** Stop after this many files. */
59
+ maxFiles?: number | undefined;
60
+ batchSize?: number | undefined;
61
+ /** Re-embed even when the stored text hash still matches. */
62
+ force?: boolean | undefined;
63
+ signal?: AbortSignal | undefined;
64
+ onProgress?: ((done: number, total: number) => void) | undefined;
65
+ }
66
+ export interface EmbedResult {
67
+ embedded: number;
68
+ /** Files whose embedded text was unchanged. */
69
+ cached: number;
70
+ /** Vectors dropped because their file left the index. */
71
+ pruned: number;
72
+ /** True when a provider change forced a full re-embed. */
73
+ providerChanged: boolean;
74
+ /** Files with no summary, embedded from their declaration names instead. */
75
+ fromDeclarations: number;
76
+ durationMs: number;
77
+ errors: string[];
78
+ }
79
+ /**
80
+ * Run one embedding pass. Never throws: an inference failure costs that batch
81
+ * its vectors, is recorded in `errors`, and the walk continues.
82
+ */
83
+ export declare function embedFiles(store: IndexStore, port: EmbeddingPort, relativeOf: (file: string) => string, options?: EmbedOptions): Promise<EmbedResult>;
84
+ /** Reported when a project has no index to embed. */
85
+ export type EmbedIndexMissing = {
86
+ indexed: false;
87
+ };
88
+ /**
89
+ * Embed a project's files, owning the store lifetime so callers outside this
90
+ * package never touch `indexStorePool`. Refuses to run without an index.
91
+ */
92
+ export declare function embedProjectFiles(projectRoot: string, port: EmbeddingPort, options?: EmbedOptions & {
93
+ indexDir?: string | undefined;
94
+ }): Promise<EmbedResult | EmbedIndexMissing>;
95
+ //# sourceMappingURL=embedding-pass.d.ts.map
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Process-local cache of the wiring graph.
3
+ *
4
+ * Building the graph means pulling ~180k resolved refs, ~66k symbol→file
5
+ * pairs, the homonym counts and the import-visibility map, then laying the
6
+ * whole thing out as CSR — around half a second on this repo. That is fine
7
+ * once per index generation and unacceptable once per query, and the
8
+ * personalised retrieval walk is a per-query operation.
9
+ *
10
+ * The cache holds one graph. In the detached project server that is exactly
11
+ * right: one daemon serves one project. A caller for a different project (or
12
+ * a different index directory) simply replaces the entry rather than growing
13
+ * a map that would keep tens of megabytes alive for a project nobody is
14
+ * querying any more.
15
+ *
16
+ * Freshness is decided by the index's own `last_indexed` stamp plus the row
17
+ * counts, read fresh on every request. That costs three trivial queries and
18
+ * makes the cache self-invalidating from any path — daemon, worker, or
19
+ * inline — without having to be wired into the server's generation plumbing.
20
+ */
21
+ import { type WiringGraph } from './graph-rank.js';
22
+ import type { IndexStore } from './writer.js';
23
+ /** Everything the walk needs, built together and invalidated together. */
24
+ export interface WiringSnapshot {
25
+ graph: WiringGraph;
26
+ /** Declaring file per symbol id — the walk reports files, not just nodes. */
27
+ fileOf: ReadonlyMap<number, string>;
28
+ }
29
+ /**
30
+ * Return the wiring graph for this store, building it only when the index has
31
+ * changed since the last call.
32
+ */
33
+ export declare function getWiringSnapshot(store: IndexStore, projectRoot: string, indexDir: string | undefined): WiringSnapshot;
34
+ /** Drop the cached graph. Tests and shutdown paths only. */
35
+ export declare function clearWiringSnapshot(): void;
36
+ //# sourceMappingURL=graph-adjacency-cache.d.ts.map
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The index-time centrality pass.
3
+ *
4
+ * Runs inside the indexer's atomic update, immediately after ref resolution
5
+ * and module resolution have settled: `refs.to_id` is only final at that
6
+ * point, and a rank computed from half-resolved refs would describe a graph
7
+ * that never existed.
8
+ *
9
+ * Rank is a property of the whole graph, so this recomputes everything or
10
+ * nothing. That is affordable on a full run and wasteful on a one-file
11
+ * watcher run, which is what {@link shouldRefreshRanks} arbitrates.
12
+ */
13
+ import type { IndexStore } from './writer.js';
14
+ /**
15
+ * Data-version marker for the rank layer, in the same spirit as
16
+ * `relation_graph_version`: bumping it forces every index to recompute ranks
17
+ * once without a `SCHEMA_VERSION` bump (which would drop and rebuild the
18
+ * entire database). Older processes sharing the DB cannot downgrade it.
19
+ */
20
+ export declare const RANK_VERSION = "1";
21
+ export declare const RANK_VERSION_KEY = "rank_version";
22
+ /**
23
+ * Above this many files in a targeted run, recompute. A watcher run that
24
+ * touches one file barely moves any score, so leaving ranks one generation
25
+ * stale is the cheaper trade; a bulk targeted run is effectively a full run
26
+ * and should not be served stale ranks.
27
+ */
28
+ export declare const RANK_REFRESH_FILE_THRESHOLD = 25;
29
+ export interface RankPassResult {
30
+ /** False when the pass decided the existing ranks were good enough. */
31
+ computed: boolean;
32
+ symbols: number;
33
+ files: number;
34
+ durationMs: number;
35
+ }
36
+ export declare function shouldRefreshRanks(store: IndexStore, opts: {
37
+ files?: readonly string[] | undefined;
38
+ force?: boolean | undefined;
39
+ }): boolean;
40
+ /**
41
+ * Recompute and persist both rank tables. Never throws: a failed rank pass
42
+ * leaves the previous (or empty) ranks in place and must not take the index
43
+ * run down with it — every consumer treats a missing rank as "unranked".
44
+ */
45
+ export declare function runGraphRankPass(store: IndexStore, errors: string[]): RankPassResult;
46
+ //# sourceMappingURL=graph-rank-pass.d.ts.map
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Graph centrality over the symbol wiring graph.
3
+ *
4
+ * Two modes share one implementation:
5
+ *
6
+ * - **Global** — computed once per index run with a uniform restart
7
+ * distribution, persisted to `symbol_rank` / `file_rank`. Answers "what is
8
+ * architecturally central in this repo", and drives the repo map, the
9
+ * CodeMap node sizing and the atlas projection.
10
+ * - **Personalised** — computed per query with the lexical (BM25) hit scores
11
+ * as the restart distribution. Answers "what is central *to this query*".
12
+ * Lexical search proposes the seeds; the graph decides the ordering.
13
+ *
14
+ * The walk runs over an **undirected** view of the graph: a caller and its
15
+ * callee are mutually relevant when you are trying to understand either one,
16
+ * and a directed walk starves leaf utilities that everything depends on.
17
+ * Directed in/out degrees are still reported separately, because they are
18
+ * what a human reads as "blast radius" vs "coupling".
19
+ *
20
+ * Only refs that resolved to a real symbol id participate. At the time of
21
+ * writing roughly a third of this repo's refs stay unresolved (stdlib and
22
+ * third-party targets that were never indexed); including them would mean
23
+ * walking to nodes that carry no code.
24
+ *
25
+ * Edge multiplicity is deliberately preserved. Five calls from A to B produce
26
+ * five edges, so B receives five shares of A's mass: repeated coupling is
27
+ * stronger coupling. Self-references are dropped — recursion should not make
28
+ * a symbol important on its own account.
29
+ *
30
+ * ## Why edges carry a confidence weight
31
+ *
32
+ * The index resolves a ref by matching `to_name` to the lowest symbol id in
33
+ * the same language family — it is not file- or import-aware, which
34
+ * `findIncomingCallsByName` already documents as an ambiguity source. For a
35
+ * per-query answer that is a caveat; for a global ranking it is fatal. On this
36
+ * repo roughly half of all resolved refs point at a name that several symbols
37
+ * declare, and the worst offenders are test globals and single-letter locals:
38
+ * every `it(...)` in the suite lands on whichever `it` happens to hold the
39
+ * lowest id, handing that one symbol thousands of incoming edges it never had.
40
+ *
41
+ * So an edge into a name that `n` symbols declare carries weight `1 / n`: the
42
+ * resolver guessed one of `n` equally plausible targets, and the walk spreads
43
+ * exactly that much belief. Unique names — the half we can actually trust —
44
+ * keep full weight.
45
+ *
46
+ * Homonym counting alone is not enough, because the worst misresolutions are
47
+ * to names that really are unique. Every `it(...)` in the test suite resolves
48
+ * to the one `const it: Catalog` in the desktop app's i18n file — the Italian
49
+ * locale — handing a translation table 5,500 incoming edges. Nothing declares
50
+ * a competing `it`, so no homonym penalty applies.
51
+ *
52
+ * The second weight is therefore visibility, in three tiers. An edge is fully
53
+ * trusted when the two symbols share a file, or when the source file actually
54
+ * imports the target's file — the module resolver already recorded those pairs
55
+ * in `refs.to_file`. Otherwise the question is whether we can believe the
56
+ * absence of that import:
57
+ *
58
+ * - The source file has resolved imports, and the target's file is not among
59
+ * them. The resolver worked here and still did not connect these two files,
60
+ * so the reference almost certainly is not to this symbol
61
+ * ({@link CONTRADICTED_VISIBILITY_WEIGHT}).
62
+ * - The source file has no resolved imports at all. Resolution failed
63
+ * wholesale for it, so its silence is not evidence either way, and the edge
64
+ * keeps a reduced but meaningful weight
65
+ * ({@link UNVERIFIED_VISIBILITY_WEIGHT}).
66
+ *
67
+ * These stay penalties rather than filters: module resolution only resolves
68
+ * about three fifths of this repo's import specifiers, and dropping the rest
69
+ * outright would gut the graph.
70
+ *
71
+ * Both of these are ranking-quality fixes, not resolver fixes; making ref
72
+ * resolution import-aware would remove the need for either.
73
+ */
74
+ /** Ref shape as returned by `IndexStore.getAllResolvedRefs()`. */
75
+ export interface ResolvedRefEdge {
76
+ fromId: number;
77
+ toId: number;
78
+ callType: string;
79
+ }
80
+ /**
81
+ * Compressed sparse row adjacency over a dense node numbering.
82
+ *
83
+ * `neighbours[offsets[u] .. offsets[u + 1]]` are the dense indices adjacent to
84
+ * dense node `u`. `ids[u]` maps back to the original symbol id.
85
+ */
86
+ export interface WiringGraph {
87
+ /** Number of nodes. */
88
+ size: number;
89
+ /** Original symbol id for each dense index. */
90
+ ids: Int32Array;
91
+ /** Dense index for each original symbol id. */
92
+ index: Map<number, number>;
93
+ /** CSR row offsets, length `size + 1`. */
94
+ offsets: Int32Array;
95
+ /** CSR adjacency entries, length `offsets[size]`. */
96
+ neighbours: Int32Array;
97
+ /**
98
+ * Confidence per adjacency entry, parallel to `neighbours`, in `(0, 1]`.
99
+ *
100
+ * This attenuates rather than redistributes: an edge with confidence `c`
101
+ * carries `c` of the mass it would otherwise carry, and the remaining
102
+ * `1 - c` returns to the restart distribution as belief the walk declined
103
+ * to place. Normalising these away — dividing each node's split by the sum
104
+ * of its weights — would make them inert, because a node with a single
105
+ * low-confidence edge would still hand over all of its mass.
106
+ */
107
+ weights: Float64Array;
108
+ /** Directed in-degree per dense node (how many symbols reference it). */
109
+ inDegree: Int32Array;
110
+ /** Directed out-degree per dense node (how many symbols it references). */
111
+ outDegree: Int32Array;
112
+ }
113
+ export interface PageRankOptions {
114
+ /**
115
+ * Restart (teleport) probability — the share of mass that returns to the
116
+ * restart distribution each iteration. Higher keeps the walk closer to its
117
+ * seeds. 0.25 is the value Graft settled on for code graphs; the classic
118
+ * web-PageRank 0.15 wanders too far for personalised queries.
119
+ */
120
+ restart?: number;
121
+ /** Power iterations. 25 converges comfortably at this graph size. */
122
+ iterations?: number;
123
+ /**
124
+ * Seed weights by **dense index**, for a personalised walk. Weights need not
125
+ * be normalised. Omitted (or empty) means a uniform restart distribution.
126
+ */
127
+ seeds?: ReadonlyMap<number, number> | undefined;
128
+ }
129
+ export declare const DEFAULT_RESTART = 0.25;
130
+ export declare const DEFAULT_ITERATIONS = 25;
131
+ /**
132
+ * Weight for a cross-file edge from a file whose imports never resolved. We
133
+ * cannot corroborate the edge, but we cannot contradict it either.
134
+ */
135
+ export declare const UNVERIFIED_VISIBILITY_WEIGHT = 0.25;
136
+ /**
137
+ * Weight for a cross-file edge from a file whose imports DID resolve, to a
138
+ * file it does not import. Near-zero rather than zero so a single resolver
139
+ * miss degrades one edge instead of erasing it.
140
+ */
141
+ export declare const CONTRADICTED_VISIBILITY_WEIGHT = 0.02;
142
+ /**
143
+ * Build the undirected CSR wiring graph from the resolved ref list.
144
+ *
145
+ * Two passes over the edge list (count, then fill) so the adjacency lands in
146
+ * flat typed arrays with no intermediate per-node arrays — at 180k edges the
147
+ * array-of-arrays shape costs more in allocation than the walk itself.
148
+ */
149
+ export interface WiringGraphOptions {
150
+ /**
151
+ * How many symbols declare the name each target symbol carries, keyed by
152
+ * target symbol id. Absent ids are treated as unambiguous (weight 1).
153
+ */
154
+ candidates?: ReadonlyMap<number, number> | undefined;
155
+ /** Declaring file per symbol id, used for the visibility check. */
156
+ fileOf?: ReadonlyMap<number, string> | undefined;
157
+ /** Files each source file imports, as resolved by the module resolver. */
158
+ importsOf?: ReadonlyMap<string, ReadonlySet<string>> | undefined;
159
+ }
160
+ export declare function buildWiringGraph(refs: readonly ResolvedRefEdge[], options?: WiringGraphOptions): WiringGraph;
161
+ /**
162
+ * Power-iterate PageRank over `graph`, returning scores normalised so the
163
+ * highest is exactly 1.0. Nodes the walk never reaches score 0.
164
+ *
165
+ * Mass is conserved exactly: every node hands `restart` of its mass back to
166
+ * the restart distribution, spreads the rest over its neighbours, and a node
167
+ * with no neighbours hands everything back. Low-confidence edges return their
168
+ * unspent share to the same pool. Without it the total would leak downwards
169
+ * and the final normalisation would hide the leak.
170
+ */
171
+ export declare function pageRank(graph: WiringGraph, options?: PageRankOptions): Float64Array;
172
+ /** One persisted `symbol_rank` row. */
173
+ export interface SymbolRankRow {
174
+ symbolId: number;
175
+ rank: number;
176
+ inDeg: number;
177
+ outDeg: number;
178
+ }
179
+ /** One persisted `file_rank` row. */
180
+ export interface FileRankRow {
181
+ file: string;
182
+ rank: number;
183
+ inDeg: number;
184
+ outDeg: number;
185
+ }
186
+ /** Materialise the score vector as persistable symbol rows. */
187
+ export declare function toSymbolRankRows(graph: WiringGraph, scores: Float64Array): SymbolRankRow[];
188
+ /**
189
+ * Roll symbol scores up to files.
190
+ *
191
+ * A file's rank is the **sum** of its symbols' ranks, not the mean: a module
192
+ * that exports twenty things everyone uses is more central than one that
193
+ * exports a single equally-used thing, and averaging erases exactly that.
194
+ * Degrees roll up the same way. The result is re-normalised to max 1.0 so
195
+ * file and symbol ranks share a scale.
196
+ */
197
+ export declare function aggregateFileRank(rows: readonly SymbolRankRow[], fileOf: ReadonlyMap<number, string>): FileRankRow[];
198
+ //# sourceMappingURL=graph-rank.d.ts.map
@@ -11,8 +11,9 @@
11
11
  * run on one event loop, so a pooled connection is both safe and substantially
12
12
  * cheaper than re-running schema/FTS drift checks for every edited file.
13
13
  */
14
+ import type { ContextResult } from './context-retrieval.js';
14
15
  import type { CodeMapGraph, IndexResult, IndexStats } from './schema.js';
15
- import type { CallRefsOpArgs, IndexOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs } from './worker-protocol.js';
16
+ import type { CallRefsOpArgs, ContextOpArgs, IndexOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs, VectorSearchOpArgs, VectorSearchOpResult } from './worker-protocol.js';
16
17
  interface ServiceHooks {
17
18
  signal?: AbortSignal | undefined;
18
19
  onProgress?: ((current: number, total: number) => void) | undefined;
@@ -21,6 +22,19 @@ interface ServiceHooks {
21
22
  export declare function indexService(args: IndexOpArgs, hooks?: ServiceHooks): Promise<IndexResult>;
22
23
  /** Ranked symbol search (FTS5 inside SQLite; BM25 fallback without FTS5). */
23
24
  export declare function searchService(args: SearchOpArgs): SearchOpResult;
25
+ /**
26
+ * Personalised retrieval: lexical seeds walked through the wiring graph.
27
+ *
28
+ * Path relativisation happens here rather than in the retriever so the pure
29
+ * algorithm stays free of `node:path`, and so the daemon — which knows the
30
+ * project root it was started for — is the one that decides what "relative"
31
+ * means.
32
+ */
33
+ export declare function contextService(args: ContextOpArgs): ContextResult;
34
+ /**
35
+ * Nearest files to a query vector. The caller embeds; this only compares.
36
+ */
37
+ export declare function vectorSearchService(args: VectorSearchOpArgs): VectorSearchOpResult;
24
38
  /** Index health and statistics. */
25
39
  export declare function statsService(args: StatsOpArgs): IndexStats;
26
40
  /** Package-level dependency graph. */
@@ -13,36 +13,51 @@
13
13
  * fallback so every mapped language always enters the index
14
14
  * Ranking: Okapi BM25 / FTS5 (k1=1.5, b=0.75)
15
15
  */
16
- export { resolveProjectIndexDaemonAvailability, type ProjectIndexDaemonAvailability, } from './project-server-client.js';
16
+ export { type InvariantEvaluationResult, type InvariantRuleId, type InvariantViolation, type ModuleContract, PolyglotInvariantEngine, polyglotInvariantEngine, } from './ast-invariant-engine.js';
17
+ export { type MutateSymbolOptions, type MutateSymbolResult, replaceSymbolInFile, } from './ast-symbol-mutator.js';
17
18
  export { cancelPendingReindexes, checkCodebaseIndexServerHealth, codebaseIndexStats, enqueueReindex, ensureCodebaseIndexServer, fileGraphService, getIndexState, incomingCallsService, isIndexableFile, isIndexing, isIndexReady, onIndexStateChange, outgoingCallsService, packageGraphService, runStartupIndex, searchCodebaseIndex, shutdownCodebaseIndexHost, shutdownCodebaseIndexServer, symbolGraphService, } from './background-indexer.js';
18
19
  export { buildBm25Index, buildIndexableText, tokenise, } from './bm25.js';
20
+ export { getCodebaseIndexPerfSnapshot, resetCodebaseIndexPerfMetrics, type CodebaseIndexPerfSnapshot, } from './perf-metrics.js';
19
21
  export type { CircuitSnapshot, CircuitState } from './circuit-breaker.js';
20
22
  export { CircuitOpenError, IndexCircuitBreaker, IndexTimeoutError, indexCircuitBreaker, resetIndexCircuitBreaker, } from './circuit-breaker.js';
21
- export { codebaseAstReplaceTool, type CodebaseAstReplaceInput, type CodebaseAstReplaceOutput, } from './codebase-ast-replace-tool.js';
22
- export { codebaseInvariantCheckTool, type CodebaseInvariantCheckInput, type CodebaseInvariantCheckOutput, } from './codebase-invariant-check-tool.js';
23
- export { replaceSymbolInFile, type MutateSymbolOptions, type MutateSymbolResult, } from './ast-symbol-mutator.js';
24
- export { codebaseImpactAnalysisTool, type CodebaseImpactAnalysisInput, type CodebaseImpactAnalysisOutput, type ImpactAnalysisInput, type ImpactAnalysisOutput, type ImpactCallSite, } from './codebase-impact-analysis-tool.js';
25
- export { codebaseIncomingCallsTool, type CodebaseIncomingCallsInput, type CodebaseIncomingCallsOutput, type IncomingCallsInput, type IncomingCallsOutput, } from './codebase-incoming-calls-tool.js';
26
- export { codebaseIndexTool, type CodebaseIndexInput, type CodebaseIndexOutput, } from './codebase-index-tool.js';
27
- export { codebaseOutgoingCallsTool, type CodebaseOutgoingCallsInput, type CodebaseOutgoingCallsOutput, type OutgoingCallsInput, type OutgoingCallsOutput, } from './codebase-outgoing-calls-tool.js';
28
- export { codebaseRepoMapTool, type CodebaseRepoMapInput, type CodebaseRepoMapOutput, } from './codebase-repo-map-tool.js';
29
- export { codebaseSearchTool, type CodebaseSearchInput, type CodebaseSearchOutput, } from './codebase-search-tool.js';
30
- export { codebaseSkeletonTool, type CodebaseSkeletonInput, type CodebaseSkeletonOutput, } from './codebase-skeleton-tool.js';
31
- export { codebaseStatsTool, type CodebaseStatsInput, type CodebaseStatsOutput, } from './codebase-stats-tool.js';
32
- export { codebaseTargetedTestTool, type CodebaseTargetedTestInput, type CodebaseTargetedTestOutput, type TargetedTestInput, type TargetedTestOutput, } from './codebase-targeted-test-tool.js';
33
- export { generateRepoMap, type RepoMapOptions, type RepoMapResult, } from './repo-map.js';
34
- export { extractDirectorySkeleton, extractFileSkeleton, type FileSkeletonResult, type SkeletonOptions, type SkeletonSymbolRange, } from './skeleton-extractor.js';
35
- export { deadCodeScanTool, runDeadCodeScan } from './dead-code-scan.js';
23
+ export { type CodebaseAstReplaceInput, type CodebaseAstReplaceOutput, codebaseAstReplaceTool, } from './codebase-ast-replace-tool.js';
24
+ export { type CodebaseImpactAnalysisInput, type CodebaseImpactAnalysisOutput, codebaseImpactAnalysisTool, type ImpactAnalysisInput, type ImpactAnalysisOutput, type ImpactCallSite, } from './codebase-impact-analysis-tool.js';
25
+ export { type CodebaseIncomingCallsInput, type CodebaseIncomingCallsOutput, codebaseIncomingCallsTool, type IncomingCallsInput, type IncomingCallsOutput, } from './codebase-incoming-calls-tool.js';
26
+ export { type CodebaseIndexInput, type CodebaseIndexOutput, codebaseIndexTool, } from './codebase-index-tool.js';
27
+ export { type CodebaseInvariantCheckInput, type CodebaseInvariantCheckOutput, codebaseInvariantCheckTool, } from './codebase-invariant-check-tool.js';
28
+ export { type CodebaseOutgoingCallsInput, type CodebaseOutgoingCallsOutput, codebaseOutgoingCallsTool, type OutgoingCallsInput, type OutgoingCallsOutput, } from './codebase-outgoing-calls-tool.js';
29
+ export { type CodebaseRepoMapInput, type CodebaseRepoMapOutput, codebaseRepoMapTool, } from './codebase-repo-map-tool.js';
30
+ export { type CodebaseSearchInput, type CodebaseSearchOutput, codebaseSearchTool, } from './codebase-search-tool.js';
31
+ export { type CodebaseSkeletonInput, type CodebaseSkeletonOutput, codebaseSkeletonTool, } from './codebase-skeleton-tool.js';
32
+ export { type CodebaseStatsInput, type CodebaseStatsOutput, codebaseStatsTool, } from './codebase-stats-tool.js';
33
+ export { type CodebaseTargetedTestInput, type CodebaseTargetedTestOutput, codebaseTargetedTestTool, type TargetedTestInput, type TargetedTestOutput, } from './codebase-targeted-test-tool.js';
36
34
  export type { DeadCodeScanInput, DeadCodeScanOutput, DeadFile, DeadPackage, DeadSymbol, } from './dead-code-scan.js';
35
+ export { deadCodeScanTool, runDeadCodeScan } from './dead-code-scan.js';
36
+ export { compileGitignore, type IgnoreMatcher, loadGitignoreMatcher, } from './gitignore.js';
37
37
  export { runIndexer } from './indexer.js';
38
- export { compileGitignore, loadGitignoreMatcher, type IgnoreMatcher, } from './gitignore.js';
39
38
  export { detectLang, INDEXABLE_EXTENSIONS, isIndexablePath } from './languages.js';
40
39
  export { internalKindToLspKind, lspKindToInternalKind, } from './lsp-kind.js';
41
40
  export type { ProjectIndexServerClientHealth, ProjectIndexServerConnectionState, ProjectIndexServerConnectionStatus, } from './project-server-client.js';
41
+ export { type ProjectIndexDaemonAvailability, resolveProjectIndexDaemonAvailability, } from './project-server-client.js';
42
+ export { projectIndexServerEndpoint, projectIndexServerMetadataPath, } from './project-server-endpoint.js';
42
43
  export type { ProjectIndexServerActivity, ProjectIndexServerHealth, } from './project-server-protocol.js';
44
+ export { generateRepoMap, type RepoMapOptions, type RepoMapResult, } from './repo-map.js';
43
45
  export type { CallSite, CodeMapGraph, FileMeta, FileSymbols, GraphEdge, GraphNode, IndexResult, IndexStats, SearchResult, Symbol, SymbolKind, SymbolLang, } from './schema.js';
44
- export { projectIndexServerEndpoint, projectIndexServerMetadataPath, } from './project-server-endpoint.js';
45
46
  export { SCHEMA_VERSION } from './schema.js';
47
+ export { extractDirectorySkeleton, extractFileSkeleton, type FileSkeletonResult, type SkeletonOptions, type SkeletonSymbolRange, } from './skeleton-extractor.js';
46
48
  export { codebaseIndexDirOverride, IndexStore, resolveIndexDir } from './writer.js';
47
- export { PolyglotInvariantEngine, polyglotInvariantEngine, type InvariantEvaluationResult, type InvariantRuleId, type InvariantViolation, type ModuleContract, } from './ast-invariant-engine.js';
49
+ export { type AtlasBrief, type AtlasBriefHub, type AtlasBriefIndexMissing, type AtlasBriefPackage, type AtlasBriefSubsystem, BRIEF_HUB_LIMIT, BRIEF_PACKAGE_LIMIT, BRIEF_SUBSYSTEM_LIMIT, buildAtlasBrief, buildProjectAtlasBrief, } from './atlas-brief.js';
50
+ export { type AtlasExportOptions, EXPORT_FILE_LIMIT, EXPORT_PACKAGE_LIMIT, renderAtlasHtml, } from './atlas-export.js';
51
+ export { ATLAS_DIR, ATLAS_FILE_LIMIT, ATLAS_JSON, ATLAS_MANIFEST, ATLAS_MARKDOWN, ATLAS_SCHEMA, type AtlasDocument, type AtlasEdge, type AtlasFile, type AtlasFreshness, type AtlasIndexMissing, type AtlasManifest, type AtlasPackage, type AtlasProjection, type AtlasSymbol, buildAtlas, checkAtlasFreshness, checkProjectAtlasFreshness, exportProjectAtlasHtml, MAX_REPORTED_DRIFT, type WrittenAtlas, writeAtlas, writeProjectAtlas, } from './atlas-projection.js';
52
+ export { type CodebaseContextInput, type CodebaseContextOutput, codebaseContextTool, setContextQueryEmbedder, } from './codebase-context-tool.js';
53
+ export { type ConceptIndexMissing, DEFAULT_CONCURRENCY, type EnrichOptions, type EnrichResult, enrichConcepts, enrichProjectConcepts, MAX_CRUX_LINES, MAX_SOURCE_CHARS, MAX_SUMMARY_CHARS, type SummarizeFileInput, type SummarizeFileResult, type SummarizerPort, type SummarizeSubsystemInput, type SummarizeSubsystemResult, } from './concept-enrichment.js';
54
+ export { type ContextEntry, type ContextOptions, type ContextResult, type ContextSymbol, DEFAULT_LIMIT, DEFAULT_SYMBOLS_PER_FILE, retrieveContext, SEED_LIMIT, } from './context-retrieval.js';
55
+ export { DEFAULT_BATCH_SIZE, type EmbeddingPort, type EmbedIndexMissing, type EmbedOptions, type EmbedResult, embedFiles, embedProjectFiles, MAX_EMBED_CHARS, } from './embedding-pass.js';
56
+ export { clearWiringSnapshot, getWiringSnapshot, type WiringSnapshot, } from './graph-adjacency-cache.js';
57
+ export { aggregateFileRank, buildWiringGraph, CONTRADICTED_VISIBILITY_WEIGHT, DEFAULT_ITERATIONS, DEFAULT_RESTART, type FileRankRow, type PageRankOptions, pageRank, type ResolvedRefEdge, type SymbolRankRow, toSymbolRankRows, UNVERIFIED_VISIBILITY_WEIGHT, type WiringGraph, type WiringGraphOptions, } from './graph-rank.js';
58
+ export { RANK_REFRESH_FILE_THRESHOLD, RANK_VERSION, RANK_VERSION_KEY, type RankPassResult, runGraphRankPass, shouldRefreshRanks, } from './graph-rank-pass.js';
59
+ export { CONCEPT_RELATIONS, type ConceptCoverage, type ConceptEdge, type ConceptRelation, type ConceptState, type FileConcept, isConceptRelation, type Subsystem, } from './writer-concepts.js';
60
+ export { decorateGraphNodes } from './writer-graph-decorate.js';
61
+ export type { RankedFileRow } from './writer-rank.js';
62
+ export { FILE_VECTOR_PROVIDER_KEY, type FileVectorRow, type FileVectorState, type VectorHit, } from './writer-vectors.js';
48
63
  //# sourceMappingURL=index.d.ts.map