@saasontools/strauss-kb 0.1.17 → 0.1.19
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/ARCHITECTURE.md +26 -0
- package/README.md +31 -3
- package/dist/{chunk-RMJUGTAQ.js → chunk-CQBLH7CE.js} +2 -2
- package/dist/{chunk-ZKIQOBHT.js → chunk-MNQNHYWL.js} +1052 -195
- package/dist/chunk-MNQNHYWL.js.map +1 -0
- package/dist/{chunk-SA3A2SPY.js → chunk-ZWSCLHG6.js} +2 -2
- package/dist/cli-main.cjs +1083 -232
- package/dist/cli-main.cjs.map +1 -1
- package/dist/cli-main.js +2 -2
- package/dist/index.cjs +1062 -201
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +331 -10
- package/dist/index.d.ts +331 -10
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-main.cjs +1076 -225
- package/dist/mcp-main.cjs.map +1 -1
- package/dist/mcp-main.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-ZKIQOBHT.js.map +0 -1
- /package/dist/{chunk-RMJUGTAQ.js.map → chunk-CQBLH7CE.js.map} +0 -0
- /package/dist/{chunk-SA3A2SPY.js.map → chunk-ZWSCLHG6.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -68,6 +68,10 @@ declare const kbAnchorSchema: z.ZodObject<{
|
|
|
68
68
|
repo: z.ZodOptional<z.ZodString>;
|
|
69
69
|
ref: z.ZodOptional<z.ZodString>;
|
|
70
70
|
hash: z.ZodOptional<z.ZodString>;
|
|
71
|
+
hash_kind: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
raw: "raw";
|
|
73
|
+
ast: "ast";
|
|
74
|
+
}>>;
|
|
71
75
|
resolved_at: z.ZodOptional<z.ZodString>;
|
|
72
76
|
lines: z.ZodOptional<z.ZodNumber>;
|
|
73
77
|
resolver: z.ZodOptional<z.ZodEnum<{
|
|
@@ -142,6 +146,10 @@ declare const kbRecordFrontmatterSchema: z.ZodObject<{
|
|
|
142
146
|
repo: z.ZodOptional<z.ZodString>;
|
|
143
147
|
ref: z.ZodOptional<z.ZodString>;
|
|
144
148
|
hash: z.ZodOptional<z.ZodString>;
|
|
149
|
+
hash_kind: z.ZodOptional<z.ZodEnum<{
|
|
150
|
+
raw: "raw";
|
|
151
|
+
ast: "ast";
|
|
152
|
+
}>>;
|
|
145
153
|
resolved_at: z.ZodOptional<z.ZodString>;
|
|
146
154
|
lines: z.ZodOptional<z.ZodNumber>;
|
|
147
155
|
resolver: z.ZodOptional<z.ZodEnum<{
|
|
@@ -234,12 +242,23 @@ interface AnchorResolver {
|
|
|
234
242
|
/** The richer verdict the chain uses; defaults to `resolve`. */
|
|
235
243
|
attempt?(source: string, symbol: string, file?: string): ResolverAttempt;
|
|
236
244
|
resolve(source: string, symbol: string, file?: string): ResolvedSymbol | null;
|
|
245
|
+
/**
|
|
246
|
+
* The span's normalised token stream — comments dropped, runs of whitespace
|
|
247
|
+
* collapsed — or `null` when this resolver cannot parse the text.
|
|
248
|
+
*
|
|
249
|
+
* Only a resolver that understands the language can offer one, which is why
|
|
250
|
+
* it is optional: a text heuristic normalising by guess would call two
|
|
251
|
+
* different programs equal.
|
|
252
|
+
*/
|
|
253
|
+
normalize?(text: string, file?: string): string | null;
|
|
237
254
|
}
|
|
238
255
|
/** A resolved span, and which resolver produced it. */
|
|
239
256
|
type AnchorResolution = {
|
|
240
257
|
ok: true;
|
|
241
258
|
span: ResolvedSymbol;
|
|
242
259
|
resolver?: AnchorResolverName;
|
|
260
|
+
/** The span's token stream, when the resolver that spanned it can parse. */
|
|
261
|
+
normalized?: string;
|
|
243
262
|
} | {
|
|
244
263
|
ok: false;
|
|
245
264
|
reason: AnchorUnresolvedReason;
|
|
@@ -272,6 +291,25 @@ type AnchorDriftReason = "resolver-changed";
|
|
|
272
291
|
* commit it was taken from, and the code has moved since.
|
|
273
292
|
*/
|
|
274
293
|
type RemoteAnchorState = "matches-ref" | "drifted-from-ref" | "drifted-on-default";
|
|
294
|
+
/** What `hash` was taken over. Absent on an anchor means `raw`. */
|
|
295
|
+
type AnchorHashKind = "raw" | "ast";
|
|
296
|
+
/**
|
|
297
|
+
* How an anchor's code changed, once the bytes are known to differ.
|
|
298
|
+
*
|
|
299
|
+
* The classes a machine can settle, so a reader only sees the ones it cannot:
|
|
300
|
+
* `moved` and `cosmetic` are answered and closed, `gone` and `changed` are
|
|
301
|
+
* handed on. Deliberately shallow — whether the record's *claim* still holds
|
|
302
|
+
* is a reading, and no hash can stand in for one.
|
|
303
|
+
*/
|
|
304
|
+
declare const KB_DRIFT_CLASSES: readonly ["moved", "cosmetic", "gone", "changed"];
|
|
305
|
+
type KbDriftClass = (typeof KB_DRIFT_CLASSES)[number];
|
|
306
|
+
/** Where a `moved` anchor's stored hash turned up. */
|
|
307
|
+
type KbDriftMovedTo = {
|
|
308
|
+
file: string;
|
|
309
|
+
symbol?: string;
|
|
310
|
+
startLine: number;
|
|
311
|
+
endLine: number;
|
|
312
|
+
};
|
|
275
313
|
type KbAnchorDriftEntry = {
|
|
276
314
|
file: string;
|
|
277
315
|
symbol?: string;
|
|
@@ -286,6 +324,17 @@ type KbAnchorDriftEntry = {
|
|
|
286
324
|
/** Set only when the anchor was resolved against another repository. */
|
|
287
325
|
repo?: string;
|
|
288
326
|
remoteState?: RemoteAnchorState;
|
|
327
|
+
/** What the compared hashes were taken over. */
|
|
328
|
+
hashKind?: AnchorHashKind;
|
|
329
|
+
/**
|
|
330
|
+
* Provisional: `gone` or `changed`, the two a hash comparison alone can
|
|
331
|
+
* settle. `moved` and `cosmetic` cost a repository search and a git read, so
|
|
332
|
+
* `classifyDrift` refines this on the reassessment path rather than on every
|
|
333
|
+
* `load`.
|
|
334
|
+
*/
|
|
335
|
+
class?: KbDriftClass;
|
|
336
|
+
/** Set by `classifyDrift` when the class is `moved`. */
|
|
337
|
+
movedTo?: KbDriftMovedTo;
|
|
289
338
|
};
|
|
290
339
|
type AnchorRead = {
|
|
291
340
|
ok: true;
|
|
@@ -550,6 +599,12 @@ type KbWarningAnchor = {
|
|
|
550
599
|
/** Set only for an anchor resolved against another repository. */
|
|
551
600
|
repo?: string;
|
|
552
601
|
remoteState?: string;
|
|
602
|
+
/**
|
|
603
|
+
* `gone` or `changed` — what a hash comparison alone can settle. `moved` and
|
|
604
|
+
* `cosmetic` cost a repository search and a git read, so they are
|
|
605
|
+
* `kb_reassess`'s answer, not a read path's.
|
|
606
|
+
*/
|
|
607
|
+
class?: KbDriftClass;
|
|
553
608
|
};
|
|
554
609
|
type KbStanding = "current" | "superseded" | "rejected" | "unsettled" | "open";
|
|
555
610
|
type KbAdjudicated = {
|
|
@@ -688,6 +743,22 @@ type KbPackResult = {
|
|
|
688
743
|
*/
|
|
689
744
|
declare function pack(bundle: KbRecord[], rootId: string, options?: KbPackOptions): KbPackResult;
|
|
690
745
|
|
|
746
|
+
/**
|
|
747
|
+
* Selection by frontmatter `tags`. Matching is exact and no vocabulary is
|
|
748
|
+
* enforced — a tag is whatever a writer put there.
|
|
749
|
+
*/
|
|
750
|
+
type KbTagFilter = {
|
|
751
|
+
/** AND: a record matches only when it carries every one of these. */
|
|
752
|
+
tags?: string[];
|
|
753
|
+
/** A record carrying any one of these is dropped, even if `tags` matched. */
|
|
754
|
+
excludeTags?: string[];
|
|
755
|
+
};
|
|
756
|
+
/**
|
|
757
|
+
* Whether one record survives the filter. An empty filter keeps everything,
|
|
758
|
+
* so every caller can pass one unconditionally.
|
|
759
|
+
*/
|
|
760
|
+
declare function matchesTags(record: KbRecord, filter: KbTagFilter): boolean;
|
|
761
|
+
|
|
691
762
|
/** One record as the catalog names it — no body, no description, one line. */
|
|
692
763
|
type KbCatalogEntry = {
|
|
693
764
|
conceptId: string;
|
|
@@ -752,7 +823,7 @@ type KbCatalogResult = {
|
|
|
752
823
|
declare function catalog(bundle: KbRecord[], options?: {
|
|
753
824
|
type?: string;
|
|
754
825
|
now?: Date;
|
|
755
|
-
}): KbCatalogResult;
|
|
826
|
+
} & KbTagFilter): KbCatalogResult;
|
|
756
827
|
/**
|
|
757
828
|
* One entry, as one line.
|
|
758
829
|
*
|
|
@@ -965,6 +1036,15 @@ type KbStampResult = {
|
|
|
965
1036
|
/** Newest `generated.at` across the base, or null when none carries one. */
|
|
966
1037
|
newestAt: string | null;
|
|
967
1038
|
records: KbRecordStamp[];
|
|
1039
|
+
/**
|
|
1040
|
+
* Records with at least one anchor whose code no longer matches its hash.
|
|
1041
|
+
*
|
|
1042
|
+
* Outside the digest, and deliberately: drift is a fact about the working
|
|
1043
|
+
* tree, not about the base's content, and folding it in would make a stamp
|
|
1044
|
+
* change every time someone checked out a branch. `null` when the drift pass
|
|
1045
|
+
* could not run — an unknown count, which is not zero.
|
|
1046
|
+
*/
|
|
1047
|
+
drifted: number | null;
|
|
968
1048
|
};
|
|
969
1049
|
type KbWriteInput = {
|
|
970
1050
|
type: string;
|
|
@@ -1007,13 +1087,18 @@ declare class KbStore {
|
|
|
1007
1087
|
/** One record by concept id, or null when it does not exist. */
|
|
1008
1088
|
read(bundlePath: string, conceptId: string): Promise<KbRecord | null>;
|
|
1009
1089
|
/**
|
|
1010
|
-
* Every record in the bundle, optionally narrowed to one type
|
|
1090
|
+
* Every record in the bundle, optionally narrowed to one type and to the
|
|
1091
|
+
* records carrying every tag in `filter.tags`. Selection only — `excludeTags`
|
|
1092
|
+
* is not taken here, because `query`, `catalog` and `load` read through this
|
|
1093
|
+
* and must adjudicate over the whole base.
|
|
1011
1094
|
*
|
|
1012
1095
|
* A file that fails to parse is skipped and logged rather than thrown: one
|
|
1013
1096
|
* malformed record — hand-edited, or written by a producer we don't know —
|
|
1014
1097
|
* must not make the whole bundle unreadable.
|
|
1015
1098
|
*/
|
|
1016
|
-
list(bundlePath: string, type?: string
|
|
1099
|
+
list(bundlePath: string, type?: string, filter?: {
|
|
1100
|
+
tags?: string[];
|
|
1101
|
+
}): Promise<KbRecord[]>;
|
|
1017
1102
|
/**
|
|
1018
1103
|
* Moves a record's status, preserving everything else.
|
|
1019
1104
|
*
|
|
@@ -1071,7 +1156,7 @@ declare class KbStore {
|
|
|
1071
1156
|
type?: string;
|
|
1072
1157
|
includeNonCurrent?: boolean;
|
|
1073
1158
|
repoRoot?: string;
|
|
1074
|
-
}): Promise<KbAdjudicated[]>;
|
|
1159
|
+
} & KbTagFilter): Promise<KbAdjudicated[]>;
|
|
1075
1160
|
private rank;
|
|
1076
1161
|
/**
|
|
1077
1162
|
* Anchor drift over the records about to be handed back. Like the search
|
|
@@ -1133,21 +1218,28 @@ declare class KbStore {
|
|
|
1133
1218
|
type?: string;
|
|
1134
1219
|
all?: boolean;
|
|
1135
1220
|
repoRoot?: string;
|
|
1221
|
+
/** Records carrying any of these are left out. See `kb-tags.ts`. */
|
|
1222
|
+
excludeTags?: string[];
|
|
1136
1223
|
}): Promise<KbLoadResult>;
|
|
1137
1224
|
/**
|
|
1138
1225
|
* `load`'s digest without `load`'s bodies — the same records, adjudicated
|
|
1139
|
-
* the same way, handed back as a stamp.
|
|
1140
|
-
*
|
|
1141
|
-
*
|
|
1226
|
+
* the same way, handed back as a stamp.
|
|
1227
|
+
*
|
|
1228
|
+
* Drift is counted but kept out of the digest, which is what lets the reload
|
|
1229
|
+
* hook ask one question and get two answers: whether the base moved, and
|
|
1230
|
+
* whether the code under it did. A `load` and a `stamp` of the same base
|
|
1231
|
+
* still agree on the digest, because no warning has ever reached it.
|
|
1142
1232
|
*/
|
|
1143
|
-
stamp(bundlePath: string
|
|
1233
|
+
stamp(bundlePath: string, options?: {
|
|
1234
|
+
repoRoot?: string;
|
|
1235
|
+
}): Promise<KbStampResult>;
|
|
1144
1236
|
/** How a position was arrived at, as a timeline. See `trace.ts`. */
|
|
1145
1237
|
trace(bundlePath: string, seedId: string, options?: KbTraceOptions): Promise<KbTraceStep[]>;
|
|
1146
1238
|
/** Every record named in one line each. See `catalog.ts`. */
|
|
1147
1239
|
catalog(bundlePath: string, options?: {
|
|
1148
1240
|
type?: string;
|
|
1149
1241
|
now?: Date;
|
|
1150
|
-
}): Promise<KbCatalogResult>;
|
|
1242
|
+
} & KbTagFilter): Promise<KbCatalogResult>;
|
|
1151
1243
|
/** A bounded neighbourhood around one record. See `pack.ts`. */
|
|
1152
1244
|
pack(bundlePath: string, rootId: string, options?: KbPackOptions): Promise<KbPackResult>;
|
|
1153
1245
|
/** What breaks if this record changes. See `kb-links/impact.ts`. */
|
|
@@ -1421,6 +1513,32 @@ declare class TreeSitterResolver implements AnchorResolver {
|
|
|
1421
1513
|
resolve(source: string, symbol: string, file?: string): ResolvedSymbol | null;
|
|
1422
1514
|
/** Parsed trees are keyed by content hash, so an unchanged file parses once. */
|
|
1423
1515
|
private parse;
|
|
1516
|
+
/**
|
|
1517
|
+
* Every definition this file declares, as dotted symbol and span.
|
|
1518
|
+
*
|
|
1519
|
+
* The inverse of `attempt`: that asks "where is this name", this asks "what
|
|
1520
|
+
* names are here". `moved` needs the second — the stored hash has to be
|
|
1521
|
+
* looked for at every definition in the repository, and there is no name to
|
|
1522
|
+
* ask about, since the whole question is which name now carries that code.
|
|
1523
|
+
*/
|
|
1524
|
+
spans(source: string, file: string): {
|
|
1525
|
+
symbol: string;
|
|
1526
|
+
span: ResolvedSymbol;
|
|
1527
|
+
}[];
|
|
1528
|
+
/**
|
|
1529
|
+
* The token stream of a span: every leaf the parser sees, comments dropped,
|
|
1530
|
+
* joined by single spaces.
|
|
1531
|
+
*
|
|
1532
|
+
* This is what makes a reformat not be drift. Hashing it rather than the raw
|
|
1533
|
+
* text means indentation, line breaks, trailing commas the formatter moved,
|
|
1534
|
+
* and every comment above or inside the definition are outside the hash —
|
|
1535
|
+
* and a renamed identifier or a changed literal is still inside it, because
|
|
1536
|
+
* those are leaves.
|
|
1537
|
+
*
|
|
1538
|
+
* `null` when the file has no grammar, the grammar would not load, or the
|
|
1539
|
+
* text will not parse: no normalisation is better than a guessed one.
|
|
1540
|
+
*/
|
|
1541
|
+
normalize(text: string, file?: string): string | null;
|
|
1424
1542
|
/** Drops cached trees. Grammars stay loaded — they are immutable. */
|
|
1425
1543
|
reset(): void;
|
|
1426
1544
|
}
|
|
@@ -1520,6 +1638,10 @@ declare const composeInputSchema: z.ZodObject<{
|
|
|
1520
1638
|
repo: z.ZodOptional<z.ZodString>;
|
|
1521
1639
|
ref: z.ZodOptional<z.ZodString>;
|
|
1522
1640
|
hash: z.ZodOptional<z.ZodString>;
|
|
1641
|
+
hash_kind: z.ZodOptional<z.ZodEnum<{
|
|
1642
|
+
raw: "raw";
|
|
1643
|
+
ast: "ast";
|
|
1644
|
+
}>>;
|
|
1523
1645
|
resolved_at: z.ZodOptional<z.ZodString>;
|
|
1524
1646
|
lines: z.ZodOptional<z.ZodNumber>;
|
|
1525
1647
|
resolver: z.ZodOptional<z.ZodEnum<{
|
|
@@ -1662,9 +1784,15 @@ declare const pinsManifestSchema: z.ZodObject<{
|
|
|
1662
1784
|
}, z.core.$loose>;
|
|
1663
1785
|
type KbPin = z.infer<typeof pinSchema>;
|
|
1664
1786
|
type KbPinsManifest = z.infer<typeof pinsManifestSchema>;
|
|
1787
|
+
/** One profile's `context` settings, from the manifest or the built-ins. */
|
|
1665
1788
|
type KbContextBudgets = {
|
|
1666
1789
|
budgetTokens?: number;
|
|
1667
1790
|
fullUnderTokens?: number;
|
|
1791
|
+
/**
|
|
1792
|
+
* Frontmatter tags whose records this profile leaves out of the block —
|
|
1793
|
+
* `review`, say, kept out of session-start without unpinning the base.
|
|
1794
|
+
*/
|
|
1795
|
+
excludeTags?: string[];
|
|
1668
1796
|
};
|
|
1669
1797
|
/** A pin as the merged view hands it back: entry + where it came from. */
|
|
1670
1798
|
type KbMergedPin = KbPin & {
|
|
@@ -1804,6 +1932,12 @@ type KbContextOptions = {
|
|
|
1804
1932
|
* name.
|
|
1805
1933
|
*/
|
|
1806
1934
|
profile?: string;
|
|
1935
|
+
/**
|
|
1936
|
+
* Frontmatter tags whose records stay out of the block. Resolved like the
|
|
1937
|
+
* budgets, and a profile setting rather than a pin's: it says what this
|
|
1938
|
+
* context birth wants, so a base stays pinned and stays readable by tool.
|
|
1939
|
+
*/
|
|
1940
|
+
excludeTags?: string[];
|
|
1807
1941
|
/**
|
|
1808
1942
|
* Where budget pressure is reported outside the block itself: a full pin
|
|
1809
1943
|
* that had to degrade to an index, a block that refused. The block already
|
|
@@ -2128,6 +2262,10 @@ declare const decisionInputSchema: z.ZodObject<{
|
|
|
2128
2262
|
repo: z.ZodOptional<z.ZodString>;
|
|
2129
2263
|
ref: z.ZodOptional<z.ZodString>;
|
|
2130
2264
|
hash: z.ZodOptional<z.ZodString>;
|
|
2265
|
+
hash_kind: z.ZodOptional<z.ZodEnum<{
|
|
2266
|
+
raw: "raw";
|
|
2267
|
+
ast: "ast";
|
|
2268
|
+
}>>;
|
|
2131
2269
|
resolved_at: z.ZodOptional<z.ZodString>;
|
|
2132
2270
|
lines: z.ZodOptional<z.ZodNumber>;
|
|
2133
2271
|
resolver: z.ZodOptional<z.ZodEnum<{
|
|
@@ -2253,6 +2391,189 @@ type KbCommand<Shape extends z.ZodRawShape = z.ZodRawShape> = {
|
|
|
2253
2391
|
declare const KB_COMMANDS: KbCommand[];
|
|
2254
2392
|
declare const KB_COMMANDS_BY_NAME: Map<string, KbCommand>;
|
|
2255
2393
|
|
|
2394
|
+
/** Where a recovered file came from, so a packet can say how far back it looked. */
|
|
2395
|
+
type OldSourceOrigin =
|
|
2396
|
+
/** `git show <anchor.ref>:<file>` — the rev the record itself named. */
|
|
2397
|
+
{
|
|
2398
|
+
kind: "ref";
|
|
2399
|
+
ref: string;
|
|
2400
|
+
}
|
|
2401
|
+
/** The last commit touching the path before `resolved_at`. */
|
|
2402
|
+
| {
|
|
2403
|
+
kind: "history";
|
|
2404
|
+
ref: string;
|
|
2405
|
+
};
|
|
2406
|
+
|
|
2407
|
+
type MovedSearch = {
|
|
2408
|
+
/**
|
|
2409
|
+
* Where this anchor's stored hash turned up, or `undefined`.
|
|
2410
|
+
*
|
|
2411
|
+
* Shared across every anchor of a run: one `git ls-files`, one parse cache,
|
|
2412
|
+
* one set of loaded grammars. A `doctor --drifted` sweep over a base whose
|
|
2413
|
+
* records anchor into the same few languages parses each candidate once, not
|
|
2414
|
+
* once per drifted anchor.
|
|
2415
|
+
*/
|
|
2416
|
+
find(anchor: KbAnchor): Promise<KbDriftMovedTo | undefined>;
|
|
2417
|
+
};
|
|
2418
|
+
|
|
2419
|
+
/**
|
|
2420
|
+
* Turning "the bytes changed" into one of four answers, two of which end the
|
|
2421
|
+
* matter.
|
|
2422
|
+
*
|
|
2423
|
+
* The order is not arbitrary: `moved` is asked first because it is the only
|
|
2424
|
+
* class that needs no history at all, and `cosmetic` second because it is the
|
|
2425
|
+
* only one that needs the old text. What survives both is what a reader has to
|
|
2426
|
+
* read — and the whole point of asking the cheap questions first is that most
|
|
2427
|
+
* drift never reaches them.
|
|
2428
|
+
*
|
|
2429
|
+
* Everything here is read-only. Rebaselining a `moved` anchor is a write, and
|
|
2430
|
+
* writes belong to the verb the caller named.
|
|
2431
|
+
*/
|
|
2432
|
+
type ClassifiedAnchor = {
|
|
2433
|
+
anchor: KbAnchor;
|
|
2434
|
+
entry: KbAnchorDriftEntry;
|
|
2435
|
+
/** Resolved class. Never `undefined` — every reported anchor gets one. */
|
|
2436
|
+
class: KbDriftClass;
|
|
2437
|
+
/** The anchored text as it stands now. Absent when the class is `gone`. */
|
|
2438
|
+
newText?: string;
|
|
2439
|
+
/** The anchored text as it was, when history could produce it. */
|
|
2440
|
+
oldText?: string;
|
|
2441
|
+
oldOrigin?: OldSourceOrigin;
|
|
2442
|
+
};
|
|
2443
|
+
type ClassifyOptions = {
|
|
2444
|
+
/** Test seam: replaces the disk reader. */
|
|
2445
|
+
reader?: AnchorFileReader;
|
|
2446
|
+
/** Skip the history read. `cosmetic` cannot be reached without it. */
|
|
2447
|
+
withHistory?: boolean;
|
|
2448
|
+
/**
|
|
2449
|
+
* The run's shared `moved` search. A sweep classifying many records passes
|
|
2450
|
+
* one, so the repository is listed once and each candidate file is parsed
|
|
2451
|
+
* once for the whole sweep rather than once per record.
|
|
2452
|
+
*/
|
|
2453
|
+
search?: MovedSearch;
|
|
2454
|
+
};
|
|
2455
|
+
/**
|
|
2456
|
+
* Refines one record's drift entries. Anchors that matched, or that name
|
|
2457
|
+
* another repository, are not drift and never appear.
|
|
2458
|
+
*/
|
|
2459
|
+
declare function classifyDrift(repoRoot: string, record: KbRecord, entries: readonly KbAnchorDriftEntry[], options?: ClassifyOptions): Promise<ClassifiedAnchor[]>;
|
|
2460
|
+
|
|
2461
|
+
type UnifiedDiff = {
|
|
2462
|
+
/** `-`/`+`/` ` prefixed lines, with a `@@` header. */
|
|
2463
|
+
text: string;
|
|
2464
|
+
added: number;
|
|
2465
|
+
removed: number;
|
|
2466
|
+
/** Whether the cap cut it short. */
|
|
2467
|
+
truncated: boolean;
|
|
2468
|
+
};
|
|
2469
|
+
/**
|
|
2470
|
+
* One hunk, no context trimming: the two sides are already a symbol's span,
|
|
2471
|
+
* so the whole of both is the context a reader wants.
|
|
2472
|
+
*
|
|
2473
|
+
* The common subsequence is computed over line *hashes* through a simple
|
|
2474
|
+
* O(n·m) table. Spans are bounded by the anchor file cap, and a smarter
|
|
2475
|
+
* algorithm would be a second thing to be wrong about for a saving nobody can
|
|
2476
|
+
* measure at this size.
|
|
2477
|
+
*/
|
|
2478
|
+
declare function unifiedDiff(before: string, after: string, options?: {
|
|
2479
|
+
maxLines?: number;
|
|
2480
|
+
oldLabel?: string;
|
|
2481
|
+
newLabel?: string;
|
|
2482
|
+
}): UnifiedDiff;
|
|
2483
|
+
|
|
2484
|
+
/**
|
|
2485
|
+
* What a reader needs in order to decide whether a record still holds, without
|
|
2486
|
+
* opening the repository.
|
|
2487
|
+
*
|
|
2488
|
+
* A drift finding today says two hashes disagree, which is not a thing anyone
|
|
2489
|
+
* can judge. The packet is the same finding with the three pieces judgment
|
|
2490
|
+
* actually takes: what the record claims, what the code did, and what depends
|
|
2491
|
+
* on the answer. It stops there — the reading itself is the reader's, and
|
|
2492
|
+
* every default below is a starting point the protocol expects to be argued
|
|
2493
|
+
* with.
|
|
2494
|
+
*/
|
|
2495
|
+
type KbReassessDiff = {
|
|
2496
|
+
status: "ok";
|
|
2497
|
+
/** `ref` when the anchor pinned one, `history` when it was inferred. */
|
|
2498
|
+
source: "ref" | "history";
|
|
2499
|
+
/** The rev the old side was read at. */
|
|
2500
|
+
ref: string;
|
|
2501
|
+
unified: string;
|
|
2502
|
+
added: number;
|
|
2503
|
+
removed: number;
|
|
2504
|
+
truncated: boolean;
|
|
2505
|
+
}
|
|
2506
|
+
/** No committed text to diff against; see `readOldSource`. */
|
|
2507
|
+
| {
|
|
2508
|
+
status: "unrecoverable";
|
|
2509
|
+
};
|
|
2510
|
+
type KbReassessAnchor = {
|
|
2511
|
+
file: string;
|
|
2512
|
+
symbol?: string;
|
|
2513
|
+
class: KbDriftClass;
|
|
2514
|
+
reason?: string;
|
|
2515
|
+
storedHash: string;
|
|
2516
|
+
currentHash?: string;
|
|
2517
|
+
diffSize: number | null;
|
|
2518
|
+
movedTo?: KbDriftMovedTo;
|
|
2519
|
+
diff?: KbReassessDiff;
|
|
2520
|
+
};
|
|
2521
|
+
/**
|
|
2522
|
+
* What the type says about a record whose code changed under it.
|
|
2523
|
+
*
|
|
2524
|
+
* A `fact` is a claim about the world that the code was the evidence for, so
|
|
2525
|
+
* changed evidence presumptively unmakes it. A `decision` is a claim about a
|
|
2526
|
+
* choice, and the reasoning for a choice routinely outlives the code that
|
|
2527
|
+
* implemented it. Neither is a verdict — they are which way to lean while
|
|
2528
|
+
* reading, and naming the lean is what keeps it arguable.
|
|
2529
|
+
*/
|
|
2530
|
+
type KbReassessDefault = "presumed-invalidated" | "rationale-may-survive" | "review";
|
|
2531
|
+
type KbReassessPacket = {
|
|
2532
|
+
conceptId: string;
|
|
2533
|
+
title: string | null;
|
|
2534
|
+
type: string;
|
|
2535
|
+
standing: KbStanding;
|
|
2536
|
+
/** What breaks if this record is wrong — the record's `why`, stored as `description`. */
|
|
2537
|
+
why: string | null;
|
|
2538
|
+
/** The type's claim section — the sentence being reassessed. */
|
|
2539
|
+
claim: {
|
|
2540
|
+
section: string;
|
|
2541
|
+
text: string;
|
|
2542
|
+
} | null;
|
|
2543
|
+
anchors: KbReassessAnchor[];
|
|
2544
|
+
/**
|
|
2545
|
+
* The record's dependants. A fact that stopped holding did not stop holding
|
|
2546
|
+
* alone, and a reader deciding about it is deciding about these too.
|
|
2547
|
+
*/
|
|
2548
|
+
impact: {
|
|
2549
|
+
conceptId: string;
|
|
2550
|
+
title: string | null;
|
|
2551
|
+
standing: KbStanding;
|
|
2552
|
+
depth: number;
|
|
2553
|
+
}[];
|
|
2554
|
+
impactTruncated: boolean;
|
|
2555
|
+
default: KbReassessDefault;
|
|
2556
|
+
defaultNote: string;
|
|
2557
|
+
};
|
|
2558
|
+
type PacketOptions = ClassifyOptions & {
|
|
2559
|
+
/** Recover and render the old-vs-new span diff. Off by default: it reads git. */
|
|
2560
|
+
withDiff?: boolean;
|
|
2561
|
+
impact?: KbImpactResult;
|
|
2562
|
+
standing?: KbStanding;
|
|
2563
|
+
};
|
|
2564
|
+
/**
|
|
2565
|
+
* One record's packet, or `null` when nothing survived classification.
|
|
2566
|
+
*
|
|
2567
|
+
* A record whose every drifted anchor turned out to be `moved` or `cosmetic`
|
|
2568
|
+
* is a record with no reassessment work, and emitting an empty packet for it
|
|
2569
|
+
* would put it back in front of the reader the classification just cleared it
|
|
2570
|
+
* from.
|
|
2571
|
+
*/
|
|
2572
|
+
declare function reassessPacket(repoRoot: string, record: KbRecord, entries: readonly KbAnchorDriftEntry[], options?: PacketOptions): Promise<{
|
|
2573
|
+
packet: KbReassessPacket | null;
|
|
2574
|
+
classified: ClassifiedAnchor[];
|
|
2575
|
+
}>;
|
|
2576
|
+
|
|
2256
2577
|
/**
|
|
2257
2578
|
* A knowledge base's own MCP server, over stdio.
|
|
2258
2579
|
*
|
|
@@ -2385,4 +2706,4 @@ declare function parseMarkdownWithFrontmatter<S extends z.ZodType>(text: string,
|
|
|
2385
2706
|
frontmatter: ReturnType<S["safeParse"]>;
|
|
2386
2707
|
};
|
|
2387
2708
|
|
|
2388
|
-
export { type AnchorResolution, type AnchorResolver, type AnchorResolverName, BaseError, CONTEXT_BEGIN, CONTEXT_END, CONTEXT_PROFILES, type ComposeInput, type ComposeLink, type ComposedRecord, DECISION_TYPE, DEFAULT_AGING_DAYS, DEFAULT_EXPIRING_DAYS, DEFAULT_LOAD_BUDGET, DEFAULT_PACK_HOPS, DEFAULT_PACK_MAX_NODES, DEFAULT_TYPED_LINK_RELS, DEFAULT_UNVERIFIED_DAYS, type DecisionInput, type DiffFile, type DiffHunk, type DiffMatch, type ErrorDetails, type ErrorProps, ErrorTypes, Fault, type Grammar, type GrammarManifest, type GrammarOptions, INDEX_FILE, KB_CAUSAL_LINK_RELS, KB_COMMANDS, KB_COMMANDS_BY_NAME, KB_CONCEPT_ID_PATTERN, KB_CONFIDENCES, KB_DIR, KB_DOCTOR_CHECKS, KB_EDGE_KINDS, KB_LINK_RELS, KB_MATERIALITIES, KB_RECORD_STATUSES, KB_RECORD_TYPES, KB_SLUG_PATTERN, type KbActorStamp, type KbAdjudicated, type KbAnchor, type KbAnchorDriftEntry, type KbBacklink, type KbBacklinksResult, KbBaseFrozenError, type KbCatalogEntry, type KbCatalogResult, type KbCommand, type KbCommandContext, type KbContextBudgets, type KbContextOptions, type KbContextResult, type KbDoctorCheck, type KbDoctorFinding, type KbDoctorGroup, type KbDoctorOptions, type KbDoctorReport, type KbDoctorThresholds, type KbEdgeKind, type KbImpactOptions, type KbImpactResult, type KbImpactedRecord, type KbInboundEdge, KbInvalidConceptIdError, type KbLink, type KbLinkEdge, type KbLinkRel, type KbLinkRelSpec, type KbLoadResult, type KbLogEntry, type KbLogReadResult, type KbLogger, type KbMergedPin, type KbMergedPins, KbMissingFlagValueError, type KbNeighbour, KbPackBudgetExceededError, type KbPackOptions, type KbPackResult, type KbPackedRecord, type KbPin, type KbPinLayer, type KbPinOptions, type KbPinResult, type KbPinStatus, KbPinsMalformedError, type KbPinsManifest, type KbRecord, KbRecordAlreadyExistsError, type KbRecordFrontmatter, KbRecordNotFoundError, type KbRecordStatus, type KbRecordType, type KbRecordTypeSpec, type KbSearchLogger, KbSelfVerificationError, type KbSource, type KbStanding, KbStore, type KbSupersededStub, type KbSyncResult, type KbTraceEdge, type KbTraceOptions, type KbTraceStep, KbUnknownLinkRelError, type KbValidationProblem, type KbValidationSeverity, type KbVerifiedEvent, type KbWarning, KbWriteConflictError, type KbWriteInput, LINK_RELS, LOG_FILE, type MatchOptions, NO_DECISION_SLUG, PINS_FILE, PINS_LOCAL_FILE, PIN_LAYERS, type QmdModule, RECORD_TYPES, type RemoteAnchorState, type RemoteOptions, type RemoteRead, type ResolvedSymbol, type ResolverAttempt, SEARCH_INDEX_FILE, type SearchHit, type SearchOptions, type SymbolRange, TRACE_EDGES, TreeSitterResolver, adjudicate, anchorFilePath, assertBaseNotFrozen, backlinks, buildContext, catalog, composeDecisionRecord, composeInputSchema, composeLinkSchema, composeNoDecisionRecord, composeRecord, contextProfileBudgets, createKbMcpServer, decisionInputSchema, defaultAnchorResolvers, detectAnchorDrift, doctor, edgeNeighbours, ensureGrammar, grammarHints, grammarManifest, grammarsCacheRoot, hashAnchorText, impact, inboundIndex, indexIsStale, isCanonicalRepoUrl, isKbLinkRel, isKbRecordType, isNoDecisionRecord, kbActorStampSchema, kbAnchorSchema, kbConceptIdSchema, kbJsonSchemas, kbLinkSchema, kbLogEntrySchema, kbRecordFrontmatterSchema, kbSourceSchema, kbVerifiedEventSchema, languageForFile, listPins, loadQmd, matchToDiff, mergedContextBudgets, neighbours, pack, parseLog, parseMarkdownWithFrontmatter, pinBase, prepareResolvers, readMergedPins, readPinsLayer, readRemoteAnchors, regexResolver, renderCatalogLine, renderIndex, renderIndexLine, renderLogEntry, repoCacheDir, resolveAnchor, resolveAnchorSpan, resolveHeads, resolveHits, resolvePinPath, runKbCli, runKbMcpServer, searchBase, selectDecisions, splitMarkdownFrontmatter, stringifyMarkdownWithFrontmatter, syncInstructions, toHookJson, trace, treeSitterLanguages, unpinBase, validateBundle };
|
|
2709
|
+
export { type AnchorResolution, type AnchorResolver, type AnchorResolverName, BaseError, CONTEXT_BEGIN, CONTEXT_END, CONTEXT_PROFILES, type ClassifiedAnchor, type ComposeInput, type ComposeLink, type ComposedRecord, DECISION_TYPE, DEFAULT_AGING_DAYS, DEFAULT_EXPIRING_DAYS, DEFAULT_LOAD_BUDGET, DEFAULT_PACK_HOPS, DEFAULT_PACK_MAX_NODES, DEFAULT_TYPED_LINK_RELS, DEFAULT_UNVERIFIED_DAYS, type DecisionInput, type DiffFile, type DiffHunk, type DiffMatch, type ErrorDetails, type ErrorProps, ErrorTypes, Fault, type Grammar, type GrammarManifest, type GrammarOptions, INDEX_FILE, KB_CAUSAL_LINK_RELS, KB_COMMANDS, KB_COMMANDS_BY_NAME, KB_CONCEPT_ID_PATTERN, KB_CONFIDENCES, KB_DIR, KB_DOCTOR_CHECKS, KB_EDGE_KINDS, KB_LINK_RELS, KB_MATERIALITIES, KB_RECORD_STATUSES, KB_RECORD_TYPES, KB_SLUG_PATTERN, type KbActorStamp, type KbAdjudicated, type KbAnchor, type KbAnchorDriftEntry, type KbBacklink, type KbBacklinksResult, KbBaseFrozenError, type KbCatalogEntry, type KbCatalogResult, type KbCommand, type KbCommandContext, type KbContextBudgets, type KbContextOptions, type KbContextResult, type KbDoctorCheck, type KbDoctorFinding, type KbDoctorGroup, type KbDoctorOptions, type KbDoctorReport, type KbDoctorThresholds, type KbEdgeKind, type KbImpactOptions, type KbImpactResult, type KbImpactedRecord, type KbInboundEdge, KbInvalidConceptIdError, type KbLink, type KbLinkEdge, type KbLinkRel, type KbLinkRelSpec, type KbLoadResult, type KbLogEntry, type KbLogReadResult, type KbLogger, type KbMergedPin, type KbMergedPins, KbMissingFlagValueError, type KbNeighbour, KbPackBudgetExceededError, type KbPackOptions, type KbPackResult, type KbPackedRecord, type KbPin, type KbPinLayer, type KbPinOptions, type KbPinResult, type KbPinStatus, KbPinsMalformedError, type KbPinsManifest, type KbReassessAnchor, type KbReassessDefault, type KbReassessDiff, type KbReassessPacket, type KbRecord, KbRecordAlreadyExistsError, type KbRecordFrontmatter, KbRecordNotFoundError, type KbRecordStatus, type KbRecordType, type KbRecordTypeSpec, type KbSearchLogger, KbSelfVerificationError, type KbSource, type KbStanding, KbStore, type KbSupersededStub, type KbSyncResult, type KbTagFilter, type KbTraceEdge, type KbTraceOptions, type KbTraceStep, KbUnknownLinkRelError, type KbValidationProblem, type KbValidationSeverity, type KbVerifiedEvent, type KbWarning, KbWriteConflictError, type KbWriteInput, LINK_RELS, LOG_FILE, type MatchOptions, NO_DECISION_SLUG, PINS_FILE, PINS_LOCAL_FILE, PIN_LAYERS, type QmdModule, RECORD_TYPES, type RemoteAnchorState, type RemoteOptions, type RemoteRead, type ResolvedSymbol, type ResolverAttempt, SEARCH_INDEX_FILE, type SearchHit, type SearchOptions, type SymbolRange, TRACE_EDGES, TreeSitterResolver, adjudicate, anchorFilePath, assertBaseNotFrozen, backlinks, buildContext, catalog, classifyDrift, composeDecisionRecord, composeInputSchema, composeLinkSchema, composeNoDecisionRecord, composeRecord, contextProfileBudgets, createKbMcpServer, decisionInputSchema, defaultAnchorResolvers, detectAnchorDrift, doctor, edgeNeighbours, ensureGrammar, grammarHints, grammarManifest, grammarsCacheRoot, hashAnchorText, impact, inboundIndex, indexIsStale, isCanonicalRepoUrl, isKbLinkRel, isKbRecordType, isNoDecisionRecord, kbActorStampSchema, kbAnchorSchema, kbConceptIdSchema, kbJsonSchemas, kbLinkSchema, kbLogEntrySchema, kbRecordFrontmatterSchema, kbSourceSchema, kbVerifiedEventSchema, languageForFile, listPins, loadQmd, matchToDiff, matchesTags, mergedContextBudgets, neighbours, pack, parseLog, parseMarkdownWithFrontmatter, pinBase, prepareResolvers, readMergedPins, readPinsLayer, readRemoteAnchors, reassessPacket, regexResolver, renderCatalogLine, renderIndex, renderIndexLine, renderLogEntry, repoCacheDir, resolveAnchor, resolveAnchorSpan, resolveHeads, resolveHits, resolvePinPath, runKbCli, runKbMcpServer, searchBase, selectDecisions, splitMarkdownFrontmatter, stringifyMarkdownWithFrontmatter, syncInstructions, toHookJson, trace, treeSitterLanguages, unifiedDiff, unpinBase, validateBundle };
|