kibi-cli 2.25.0 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-errors.d.ts +14 -0
- package/dist/cli-errors.d.ts.map +1 -1
- package/dist/cli-errors.js +31 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +28 -0
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +115 -4
- package/dist/commands/sync/cache.d.ts +30 -0
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +61 -0
- package/dist/commands/sync/extraction.d.ts +6 -0
- package/dist/commands/sync/extraction.d.ts.map +1 -1
- package/dist/commands/sync/extraction.js +4 -1
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +27 -1
- package/dist/operations/bootstrap/claim-restatement.d.ts +37 -0
- package/dist/operations/bootstrap/claim-restatement.d.ts.map +1 -0
- package/dist/operations/bootstrap/claim-restatement.js +83 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +23 -12
- package/dist/operations/bootstrap/intent-claims.d.ts +5 -2
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/intent-claims.js +44 -4
- package/dist/operations/migration/requirement-status.d.ts +41 -2
- package/dist/operations/migration/requirement-status.d.ts.map +1 -1
- package/dist/operations/migration/requirement-status.js +75 -7
- package/dist/operations/migration/schema6.d.ts +9 -5
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +82 -13
- package/dist/operations/migration/symbol-coordinates-refresh.d.ts +36 -0
- package/dist/operations/migration/symbol-coordinates-refresh.d.ts.map +1 -0
- package/dist/operations/migration/symbol-coordinates-refresh.js +99 -0
- package/dist/operations/mutation/source-authoring.d.ts +9 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +20 -0
- package/dist/operations/mutation/stored-entity.d.ts +5 -0
- package/dist/operations/mutation/stored-entity.d.ts.map +1 -1
- package/dist/operations/mutation/uncompiled-source.d.ts +43 -0
- package/dist/operations/mutation/uncompiled-source.d.ts.map +1 -0
- package/dist/operations/mutation/uncompiled-source.js +115 -0
- package/dist/operations/mutation/upsert.d.ts +6 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +32 -5
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +13 -3
- package/dist/public/impact/diagnostics.js +1 -1
- package/dist/public/impact/unowned-files.d.ts +31 -0
- package/dist/public/impact/unowned-files.d.ts.map +1 -0
- package/dist/public/impact/unowned-files.js +171 -0
- package/dist/public/operations/catalog.d.ts +1 -1
- package/dist/public/operations/discovery-entities.d.ts +11 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +28 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +13 -1
- package/dist/public/operations/result-envelope.d.ts +2 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +1 -0
- package/dist/public/operations/source-relationship-parity.d.ts.map +1 -1
- package/dist/public/operations/source-relationship-parity.js +22 -7
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/SKILL.md +11 -5
- package/dist/traceability/git-change-snapshot.d.ts.map +1 -1
- package/dist/traceability/git-change-snapshot.js +44 -3
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-migration.d.ts +13 -0
- package/dist/traceability/staged-migration.d.ts.map +1 -0
- package/dist/traceability/staged-migration.js +59 -0
- package/dist/traceability/staged-symbols-manifest.d.ts +11 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +50 -16
- package/package.json +2 -2
- package/src/public/impact/analyzer.ts +21 -7
- package/src/public/impact/diagnostics.ts +1 -1
- package/src/public/impact/unowned-files.ts +229 -0
- package/src/public/operations/discovery-entities.ts +36 -0
- package/src/public/operations/discovery-executors.ts +17 -1
- package/src/public/operations/result-envelope.ts +3 -0
- package/src/public/operations/source-relationship-parity.ts +22 -7
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/SKILL.md +11 -5
|
@@ -27,6 +27,7 @@ import { storedEntityLookup, } from "./stored-entity.js";
|
|
|
27
27
|
import { acquireSymbolCompilerLock, releaseSymbolCompilerLock, } from "./symbol-compiler-lock.js";
|
|
28
28
|
import { validateSymbolGranularity } from "./symbol-granularity.js";
|
|
29
29
|
import { refreshSymbolCoordinatesForManifest } from "./symbol-refresh.js";
|
|
30
|
+
import { assertAuthoredWriteCompiles, authoredEntityLookup, readUncompiledAuthoredSource, } from "./uncompiled-source.js";
|
|
30
31
|
import { validateUpsertInput } from "./validation.js";
|
|
31
32
|
import { scenarioCoverageWarnings, symbolCoverageWarnings, } from "./warnings.js";
|
|
32
33
|
import { acquireWorkspaceMutationLock, releaseWorkspaceMutationLock, } from "./workspace-mutation-lock.js";
|
|
@@ -147,12 +148,14 @@ export async function effectiveRelationships(input, entity, relationships, conte
|
|
|
147
148
|
// Relationships an earlier plan step adds from this entity will exist when
|
|
148
149
|
// this upsert runs.
|
|
149
150
|
const plannedOwn = (staged?.relationships ?? []).filter((relationship) => relationship.from === input.id);
|
|
150
|
-
const
|
|
151
|
+
const resolved = lookup ?? storedEntityLookup(prolog, input.id, input.type);
|
|
152
|
+
const exists = await resolved.exists();
|
|
151
153
|
if (!exists && plannedOwn.length === 0)
|
|
152
154
|
return relationships;
|
|
153
155
|
try {
|
|
154
156
|
const current = exists
|
|
155
|
-
? (
|
|
157
|
+
? (resolved.relationships ??
|
|
158
|
+
(await existingRelationships(prolog, String(entity.id))))
|
|
156
159
|
// An upsert owns only relationships whose source is the upserted
|
|
157
160
|
// entity. Incoming relationships must not be copied into its
|
|
158
161
|
// validation or canonical source projection.
|
|
@@ -231,15 +234,32 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
|
|
|
231
234
|
// The payload must be valid on its own before the store is read.
|
|
232
235
|
const checked = validateUpsertInput(payload, context.clock());
|
|
233
236
|
validateRelationshipSources(payload.id, checked.relationships);
|
|
237
|
+
// Symbol granularity reads only the payload and its source file, and stored
|
|
238
|
+
// state never changes a symbol payload, so it runs before the store is read.
|
|
239
|
+
await validateSymbolGranularity(checked.entity, checked.relationships, context);
|
|
234
240
|
// One read of the entity this upsert replaces, shared by the ledger merge
|
|
235
241
|
// and the stored origin below.
|
|
236
|
-
|
|
242
|
+
let lookup = storedEntityLookup(prolog, payload.id, payload.type);
|
|
243
|
+
// implements REQ-kibi-uncompiled-source-visibility
|
|
244
|
+
// An entity missing from the store whose authored file exists (one sync
|
|
245
|
+
// could not extract, or one written since the last sync) is an update of
|
|
246
|
+
// that file, not a create: the writer merges into it. Judge the write
|
|
247
|
+
// against the file's own state so every stored-state check applies.
|
|
248
|
+
const uncompiledSource = staged?.entities.has(payload.id) === true || (await lookup.exists())
|
|
249
|
+
? null
|
|
250
|
+
: await readUncompiledAuthoredSource(context, payload);
|
|
251
|
+
if (uncompiledSource !== null)
|
|
252
|
+
lookup = authoredEntityLookup(uncompiledSource);
|
|
237
253
|
const input = await withStoredRequirementSemantics(payload, prolog, staged, lookup);
|
|
238
254
|
const validated = input === payload ? checked : validateUpsertInput(input, context.clock());
|
|
255
|
+
if (uncompiledSource !== null)
|
|
256
|
+
lookup = {
|
|
257
|
+
...lookup,
|
|
258
|
+
relationships: assertAuthoredWriteCompiles(uncompiledSource, input, validated.entity),
|
|
259
|
+
};
|
|
239
260
|
if (options.allowReceiptsPrune !== true) {
|
|
240
261
|
await validateAppendOnlyProofReceipts(validated.entity, context, staged);
|
|
241
262
|
}
|
|
242
|
-
await validateSymbolGranularity(validated.entity, validated.relationships, context);
|
|
243
263
|
const relationships = await effectiveRelationships(input, validated.entity, validated.relationships, context, staged, lookup);
|
|
244
264
|
await validateStrictLanePairing(prolog, validated.relationships, staged);
|
|
245
265
|
await validateLiveRelationshipTargets(prolog, validated.entity, validated.relationships, staged);
|
|
@@ -259,6 +279,7 @@ export async function validateUpsertForCommit(payload, context, options = {}) {
|
|
|
259
279
|
: validateUpsertInput(decided, context.clock()),
|
|
260
280
|
relationships,
|
|
261
281
|
semantic,
|
|
282
|
+
...(uncompiledSource !== null ? { uncompiledSource } : {}),
|
|
262
283
|
};
|
|
263
284
|
}
|
|
264
285
|
/**
|
|
@@ -370,7 +391,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
370
391
|
// upserts cannot lose updates.
|
|
371
392
|
compilerLock = await acquireSymbolCompilerLock(context.workspaceRoot);
|
|
372
393
|
}
|
|
373
|
-
const { validated, relationships, semantic } = await validateUpsertForCommit(input, context, {
|
|
394
|
+
const { validated, relationships, semantic, uncompiledSource } = await validateUpsertForCommit(input, context, {
|
|
374
395
|
allowReceiptsPrune: options.allowReceiptsPrune === true,
|
|
375
396
|
});
|
|
376
397
|
relationshipCount = validated.relationships.length;
|
|
@@ -604,6 +625,12 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
604
625
|
relationships_created: validated.relationships.length,
|
|
605
626
|
warnings: [
|
|
606
627
|
...planRecoveryWarnings,
|
|
628
|
+
// implements REQ-kibi-uncompiled-source-visibility
|
|
629
|
+
...(uncompiledSource !== undefined
|
|
630
|
+
? [
|
|
631
|
+
`${input.id} was not in the compiled KB; this write updated its authored file ${uncompiledSource.path}${uncompiledSource.extractionError === null ? "" : `, which kibi sync could not compile before (${uncompiledSource.extractionError})`}. Run kibi sync to recompile it.`,
|
|
632
|
+
]
|
|
633
|
+
: []),
|
|
607
634
|
...semantic.warnings,
|
|
608
635
|
...coverage,
|
|
609
636
|
...idStyleWarnings,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../../src/public/impact/analyzer.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACxB,MAAM,YAAY,CAAC;AAGpB,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,uBAAuB,CAAC,CAmKlC"}
|
|
@@ -11,6 +11,7 @@ import { normalizeSourceFile } from "./source-changes.js";
|
|
|
11
11
|
import { collectSourceChanges, uniqueSorted } from "./source-changes.js";
|
|
12
12
|
import { buildNextActions, collectLinkedEntities, formatExtractedSymbols, } from "./summaries.js";
|
|
13
13
|
import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
|
|
14
|
+
import { createUnownedFileDiagnostics } from "./unowned-files.js";
|
|
14
15
|
export async function analyzeChangedFileImpact(options) {
|
|
15
16
|
const workspaceRoot = path.resolve(options.workspaceRoot);
|
|
16
17
|
const snapshot = options.staged
|
|
@@ -77,9 +78,20 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
77
78
|
const activeSourceFiles = new Set(sourceFiles);
|
|
78
79
|
const activeManifestResults = manifestResults.filter((result) => result.sourceFile !== undefined &&
|
|
79
80
|
activeSourceFiles.has(result.sourceFile));
|
|
81
|
+
const linkedSourceFiles = new Set(manifestResults
|
|
82
|
+
.filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
|
|
83
|
+
.map((result) => result.sourceFile)
|
|
84
|
+
.filter((file) => file !== undefined));
|
|
80
85
|
const impactDiagnostics = options.includeImpactDiagnostics === false
|
|
81
86
|
? []
|
|
82
87
|
: [
|
|
88
|
+
// Named files first: a file without links is the answer a scoped
|
|
89
|
+
// check most easily misreads as "no rule applies".
|
|
90
|
+
...createUnownedFileDiagnostics({
|
|
91
|
+
workspaceRoot,
|
|
92
|
+
requestedFiles: [...filter],
|
|
93
|
+
linkedSourceFiles,
|
|
94
|
+
}),
|
|
83
95
|
...createSymbolGranularityDiagnostics({
|
|
84
96
|
manifestResults: activeManifestResults,
|
|
85
97
|
symbolsByFile,
|
|
@@ -93,9 +105,7 @@ export async function analyzeChangedFileImpact(options) {
|
|
|
93
105
|
}),
|
|
94
106
|
...createSemanticReviewDiagnostics({
|
|
95
107
|
symbolsByFile,
|
|
96
|
-
linkedSourceFiles: new Set(
|
|
97
|
-
.filter((result) => result.relationships.some((relationship) => isTraceabilityRelationshipType(relationship.type)))
|
|
98
|
-
.map((result) => result.sourceFile)),
|
|
108
|
+
linkedSourceFiles: new Set([...linkedSourceFiles].filter((file) => activeSourceFiles.has(file))),
|
|
99
109
|
}),
|
|
100
110
|
];
|
|
101
111
|
const maxDiagnostics = options.maxDiagnostics;
|
|
@@ -136,7 +136,7 @@ export function createSemanticReviewDiagnostics(options) {
|
|
|
136
136
|
? `Changed behavioral symbol ${symbol.name} is in a file no requirement owns, so no recorded intent covers the behavior it has after this change`
|
|
137
137
|
: `Changed behavioral symbol ${symbol.name} needs semantic review against linked Kibi coverage: ${linkedTargets}`,
|
|
138
138
|
suggestion: unlinked
|
|
139
|
-
? `If the change adds or alters behavior, record it
|
|
139
|
+
? `If the change adds or alters behavior, record it as part of this change; that is part of finishing it, not a separate request, so it needs no permission: kb_search({query:"<the behavior>", sourceLocations:[{path:"${file}"}]}) for a requirement that already describes it and link ${symbol.name} to it; if none does, kb_upsert a requirement with a scenario and link the symbol with implements. If behavior is unchanged (a refactor, renaming), say so in the final report instead.`
|
|
140
140
|
: `Use kb_search and kb_query for ${file}, then verify that ${linkedTargets} actually describe and test the changed behavior or UI copy. Update Kibi links or requirements/tests while the edit context is fresh.`,
|
|
141
141
|
});
|
|
142
142
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { KibiImpactDiagnostic } from "../../traceability/staged-diagnostics.js";
|
|
2
|
+
/**
|
|
3
|
+
* The topic words of a workspace path, without layout, language and role
|
|
4
|
+
* words (`src/app/pages/coach-dashboard/coach-dashboard.html` -> `coach`,
|
|
5
|
+
* `dashboard`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function pathTopicWords(relativePath: string): string[];
|
|
8
|
+
export type RequirementCandidate = {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly title: string;
|
|
11
|
+
readonly status?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Current requirements ranked by how many of the path's topic words their
|
|
15
|
+
* title shares, then by how often the title uses them, then by id; only
|
|
16
|
+
* those sharing at least one word.
|
|
17
|
+
*/
|
|
18
|
+
export declare function rankRequirementCandidates(relativePath: string, requirements: readonly RequirementCandidate[], limit?: number): RequirementCandidate[];
|
|
19
|
+
export type UnownedFileDiagnosticsOptions = {
|
|
20
|
+
readonly workspaceRoot: string;
|
|
21
|
+
/** Workspace-relative files the check was asked about. */
|
|
22
|
+
readonly requestedFiles: readonly string[];
|
|
23
|
+
/** Files where some manifest symbol carries a traceability link. */
|
|
24
|
+
readonly linkedSourceFiles: ReadonlySet<string>;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* One `source_file_unowned` note per requested file without a linked symbol,
|
|
28
|
+
* naming the current requirements whose titles share its path words.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createUnownedFileDiagnostics(options: UnownedFileDiagnosticsOptions): KibiImpactDiagnostic[];
|
|
31
|
+
//# sourceMappingURL=unowned-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unowned-files.d.ts","sourceRoot":"","sources":["../../../src/public/impact/unowned-files.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAqDrF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAS7D;AAGD,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGF;;;;GAIG;AACH,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,SAAS,oBAAoB,EAAE,EAC7C,KAAK,GAAE,MAAuB,GAC7B,oBAAoB,EAAE,CAyBxB;AA+DD,MAAM,MAAM,6BAA6B,GAAG;IAC1C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACjD,CAAC;AAGF;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,6BAA6B,GACrC,oBAAoB,EAAE,CAqCxB"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { closeSync, openSync, readSync, readdirSync } from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* A file `kb_check` was asked about that no symbol links to a requirement.
|
|
5
|
+
* No link is not no rule, so the check says so and names the current
|
|
6
|
+
* requirements whose titles share the file's path words: candidates to
|
|
7
|
+
* confirm, never owners. Kibi's hooks name the same candidates before an edit
|
|
8
|
+
* (kibi-agent-core `requirement-candidates`), with the same word rules.
|
|
9
|
+
*/
|
|
10
|
+
const REQUIREMENTS_DIR = path.join(".kb", "requirements");
|
|
11
|
+
const HEAD_BYTES = 4096;
|
|
12
|
+
const MAX_CANDIDATES = 3;
|
|
13
|
+
const MAX_TITLE = 100;
|
|
14
|
+
/** Path words that name a layout, a language or a role, not a behavior. */
|
|
15
|
+
const LAYOUT_WORDS = new Set(("src app apps lib libs source page pages component components view views " +
|
|
16
|
+
"screen screens package packages main index shared common core util utils " +
|
|
17
|
+
"helper helpers public static asset assets web client server frontend " +
|
|
18
|
+
"backend module modules feature features internal service services test " +
|
|
19
|
+
"tests spec specs dist build html htm tsx jsx mjs cjs vue svelte css scss " +
|
|
20
|
+
"less json yaml yml java swift php").split(" "));
|
|
21
|
+
/** Words of a title or path that carry no topic. */
|
|
22
|
+
const FILLER_WORDS = new Set(("the and for with must should shall may can are its their that this " +
|
|
23
|
+
"from into when each every all not req auto").split(" "));
|
|
24
|
+
const RETIRED_STATUS = /supersed|deprecat|reject|obsolete|retired|archived|removed/i;
|
|
25
|
+
/** Lowercase word stems of an identifier, path segment or title. */
|
|
26
|
+
function words(text) {
|
|
27
|
+
return text
|
|
28
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.split(/[^a-z0-9]+/)
|
|
31
|
+
.filter((word) => word.length >= 3 && !/\d/.test(word))
|
|
32
|
+
.map((word) => word.length > 4 && word.endsWith("s") && !word.endsWith("ss")
|
|
33
|
+
? word.slice(0, -1)
|
|
34
|
+
: word);
|
|
35
|
+
}
|
|
36
|
+
// implements REQ-kb-unowned-file-candidates
|
|
37
|
+
/**
|
|
38
|
+
* The topic words of a workspace path, without layout, language and role
|
|
39
|
+
* words (`src/app/pages/coach-dashboard/coach-dashboard.html` -> `coach`,
|
|
40
|
+
* `dashboard`).
|
|
41
|
+
*/
|
|
42
|
+
export function pathTopicWords(relativePath) {
|
|
43
|
+
const segments = relativePath.split(/[\\/]/).filter(Boolean);
|
|
44
|
+
const last = segments.pop() ?? "";
|
|
45
|
+
const dot = last.indexOf(".");
|
|
46
|
+
const parts = dot >= 0 ? [last.slice(0, dot), last.slice(dot + 1)] : [last];
|
|
47
|
+
const found = [...segments, ...parts]
|
|
48
|
+
.flatMap(words)
|
|
49
|
+
.filter((word) => !LAYOUT_WORDS.has(word) && !FILLER_WORDS.has(word));
|
|
50
|
+
return [...new Set(found)];
|
|
51
|
+
}
|
|
52
|
+
// implements REQ-kb-unowned-file-candidates
|
|
53
|
+
/**
|
|
54
|
+
* Current requirements ranked by how many of the path's topic words their
|
|
55
|
+
* title shares, then by how often the title uses them, then by id; only
|
|
56
|
+
* those sharing at least one word.
|
|
57
|
+
*/
|
|
58
|
+
export function rankRequirementCandidates(relativePath, requirements, limit = MAX_CANDIDATES) {
|
|
59
|
+
const topic = new Set(pathTopicWords(relativePath));
|
|
60
|
+
if (topic.size === 0)
|
|
61
|
+
return [];
|
|
62
|
+
const scored = [];
|
|
63
|
+
for (const requirement of requirements) {
|
|
64
|
+
if (requirement.status !== undefined &&
|
|
65
|
+
RETIRED_STATUS.test(requirement.status))
|
|
66
|
+
continue;
|
|
67
|
+
const matched = words(requirement.title).filter((word) => topic.has(word));
|
|
68
|
+
const shared = new Set(matched).size;
|
|
69
|
+
if (shared > 0)
|
|
70
|
+
scored.push({ requirement, shared, uses: matched.length });
|
|
71
|
+
}
|
|
72
|
+
scored.sort((a, b) => b.shared - a.shared ||
|
|
73
|
+
b.uses - a.uses ||
|
|
74
|
+
a.requirement.id.localeCompare(b.requirement.id));
|
|
75
|
+
return scored.slice(0, limit).map((entry) => entry.requirement);
|
|
76
|
+
}
|
|
77
|
+
function unquote(value) {
|
|
78
|
+
const trimmed = value.trim();
|
|
79
|
+
return /^(["']).*\1$/.test(trimmed) ? trimmed.slice(1, -1) : trimmed;
|
|
80
|
+
}
|
|
81
|
+
function readRequirementHead(file) {
|
|
82
|
+
let head;
|
|
83
|
+
try {
|
|
84
|
+
const descriptor = openSync(file, "r");
|
|
85
|
+
try {
|
|
86
|
+
const buffer = Buffer.alloc(HEAD_BYTES);
|
|
87
|
+
const bytes = readSync(descriptor, buffer, 0, buffer.length, 0);
|
|
88
|
+
head = buffer.subarray(0, bytes).toString("utf8");
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
closeSync(descriptor);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const lines = head.split(/\r?\n/);
|
|
98
|
+
if (lines[0]?.trim() !== "---")
|
|
99
|
+
return undefined;
|
|
100
|
+
const fields = {};
|
|
101
|
+
for (const line of lines.slice(1)) {
|
|
102
|
+
if (line.trim() === "---")
|
|
103
|
+
break;
|
|
104
|
+
const match = /^(id|title|status):\s*(.+)$/.exec(line);
|
|
105
|
+
if (match?.[1] && match[2])
|
|
106
|
+
fields[match[1]] = unquote(match[2]);
|
|
107
|
+
}
|
|
108
|
+
if (!fields.id || !fields.title)
|
|
109
|
+
return undefined;
|
|
110
|
+
return {
|
|
111
|
+
id: fields.id,
|
|
112
|
+
title: fields.title,
|
|
113
|
+
...(fields.status ? { status: fields.status } : {}),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function readRequirementHeads(workspaceRoot) {
|
|
117
|
+
const directory = path.join(workspaceRoot, REQUIREMENTS_DIR);
|
|
118
|
+
let names;
|
|
119
|
+
try {
|
|
120
|
+
names = readdirSync(directory).filter((name) => name.endsWith(".md"));
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
return names
|
|
126
|
+
.map((name) => readRequirementHead(path.join(directory, name)))
|
|
127
|
+
.filter((requirement) => requirement !== undefined);
|
|
128
|
+
}
|
|
129
|
+
function truncate(text, limit) {
|
|
130
|
+
return text.length > limit ? `${text.slice(0, limit - 1)}…` : text;
|
|
131
|
+
}
|
|
132
|
+
/** Files the unowned note does not apply to: the KB itself and prose. */
|
|
133
|
+
function isKnowledgeOrProse(file) {
|
|
134
|
+
return file.startsWith(".kb/") || /\.mdx?$/i.test(file);
|
|
135
|
+
}
|
|
136
|
+
// implements REQ-kb-unowned-file-candidates
|
|
137
|
+
/**
|
|
138
|
+
* One `source_file_unowned` note per requested file without a linked symbol,
|
|
139
|
+
* naming the current requirements whose titles share its path words.
|
|
140
|
+
*/
|
|
141
|
+
export function createUnownedFileDiagnostics(options) {
|
|
142
|
+
const files = [...new Set(options.requestedFiles)].filter((file) => !options.linkedSourceFiles.has(file) && !isKnowledgeOrProse(file));
|
|
143
|
+
if (files.length === 0)
|
|
144
|
+
return [];
|
|
145
|
+
const requirements = readRequirementHeads(options.workspaceRoot);
|
|
146
|
+
return files.map((file) => {
|
|
147
|
+
const candidates = rankRequirementCandidates(file, requirements);
|
|
148
|
+
const named = candidates
|
|
149
|
+
.map((candidate) => `${candidate.id} (${truncate(candidate.title, MAX_TITLE)})`)
|
|
150
|
+
.join("; ");
|
|
151
|
+
const lead = `No symbol in ${file} is linked to a requirement, so this check finds no owner for it; that does not mean no recorded rule covers the behavior it implements.`;
|
|
152
|
+
const record = "If none does and the change adds behavior, record a requirement with a scenario and link it with implements as part of this change; if behavior is unchanged, say so in the final report.";
|
|
153
|
+
return {
|
|
154
|
+
id: "source_file_unowned",
|
|
155
|
+
severity: "info",
|
|
156
|
+
blocking: false,
|
|
157
|
+
category: "requirement",
|
|
158
|
+
files: [file],
|
|
159
|
+
docs: ["docs/symbol-traceability-taxonomy.md"],
|
|
160
|
+
message: candidates.length > 0
|
|
161
|
+
? `${lead} Requirements whose titles share its path words: ${named}.`
|
|
162
|
+
: lead,
|
|
163
|
+
suggestion: candidates.length > 0
|
|
164
|
+
? `kb_query each candidate to see whether it describes the changed behavior; when one does, link the symbol that implements it (for markup, the component that renders it) with implements and name the requirement in the final report. ${record}`
|
|
165
|
+
: `kb_search({query:"<the behavior>", sourceLocations:[{path:${JSON.stringify(file)}}]}) for a requirement that already describes it. ${record}`,
|
|
166
|
+
evidence: {
|
|
167
|
+
candidates: candidates.map(({ id, title }) => ({ id, title })),
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
@@ -1858,7 +1858,7 @@ export declare const OPERATION_CATALOG: readonly [{
|
|
|
1858
1858
|
};
|
|
1859
1859
|
readonly includeImpactDiagnostics: {
|
|
1860
1860
|
readonly type: "boolean";
|
|
1861
|
-
readonly description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation and
|
|
1861
|
+
readonly description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation, symbol_semantic_review_needed and source_file_unowned in structured output.";
|
|
1862
1862
|
};
|
|
1863
1863
|
readonly maxDiagnostics: {
|
|
1864
1864
|
readonly type: "integer";
|
|
@@ -59,6 +59,17 @@ export declare function queryEntityChunks(readChunk: (input: PrologEntityQueryIn
|
|
|
59
59
|
export declare function queryEntitiesViaQuery(prolog: Pick<PrologPort, "query">, input: PrologEntityQueryInput, signal?: AbortSignal): Promise<PrologEntityQueryResult>;
|
|
60
60
|
/** Every entity id, without materializing entity properties. */
|
|
61
61
|
export declare function loadEntityIds(prolog: Pick<PrologPort, "query">): Promise<string[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Id, title and semantic text of every current requirement (open,
|
|
64
|
+
* in_progress, closed and the legacy active/approved statuses, not superseded),
|
|
65
|
+
* in id order. Projected rows only: semantic inventories and other large
|
|
66
|
+
* properties stay in the store.
|
|
67
|
+
*/
|
|
68
|
+
export declare function loadCurrentRequirementTexts(prolog: Pick<PrologPort, "query">): Promise<{
|
|
69
|
+
id: string;
|
|
70
|
+
title: string;
|
|
71
|
+
semanticText: string;
|
|
72
|
+
}[]>;
|
|
62
73
|
/**
|
|
63
74
|
* Properties a projected entity row keeps: what intent ranking, result
|
|
64
75
|
* summaries and the search answer layer read. Large structured properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-entities.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-entities.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,UAAU,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|
|
|
273
273
|
}
|
|
274
274
|
return parseAtomList(result.bindings.Ids ?? "[]").map(normalizeEntityId);
|
|
275
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Id, title and semantic text of every current requirement (open,
|
|
278
|
+
* in_progress, closed and the legacy active/approved statuses, not superseded),
|
|
279
|
+
* in id order. Projected rows only: semantic inventories and other large
|
|
280
|
+
* properties stay in the store.
|
|
281
|
+
*/
|
|
282
|
+
// implements REQ-bootstrap-claim-restatement
|
|
283
|
+
export async function loadCurrentRequirementTexts(prolog) {
|
|
284
|
+
const result = await prolog.query("findall(R, kb:current_req(R), Ids)");
|
|
285
|
+
if (!result.success) {
|
|
286
|
+
throw new Error(`Current requirement enumeration failed: ${result.error ?? "Unknown error"}`);
|
|
287
|
+
}
|
|
288
|
+
const ids = parseAtomList(result.bindings.Ids ?? "[]").map(normalizeEntityId);
|
|
289
|
+
const rows = await loadEntityRows(prolog, ids, [
|
|
290
|
+
"id",
|
|
291
|
+
"title",
|
|
292
|
+
"semantic_text",
|
|
293
|
+
]);
|
|
294
|
+
return rows
|
|
295
|
+
.filter((row) => row.type === "req")
|
|
296
|
+
.map((row) => ({
|
|
297
|
+
id: String(row.id ?? ""),
|
|
298
|
+
title: typeof row.title === "string" ? row.title : "",
|
|
299
|
+
semanticText: typeof row.semantic_text === "string" ? row.semantic_text : "",
|
|
300
|
+
}))
|
|
301
|
+
.filter((row) => row.id !== "")
|
|
302
|
+
.sort((left, right) => left.id < right.id ? -1 : left.id > right.id ? 1 : 0);
|
|
303
|
+
}
|
|
276
304
|
/**
|
|
277
305
|
* Properties a projected entity row keeps: what intent ranking, result
|
|
278
306
|
* summaries and the search answer layer read. Large structured properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-executors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"discovery-executors.d.ts","sourceRoot":"","sources":["../../../src/public/operations/discovery-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printReason } from "../../commands/sync/cache.js";
|
|
3
|
+
import { compilerFingerprintReason, sourceExtractionFailureReasons, } from "../../commands/sync/cache.js";
|
|
4
4
|
import { effectiveFirmness } from "../../decision-firmness.js";
|
|
5
5
|
import { EngineClient } from "../../engine.js";
|
|
6
6
|
import { executeIntentSearch, questionPaths, validateIntentSearchInput, } from "../../intent-search.js";
|
|
@@ -788,6 +788,12 @@ export async function executeStatus(_input, context) {
|
|
|
788
788
|
// A stale-lock takeover heals itself; report it without making the KB stale.
|
|
789
789
|
const takeoverNotice = storeLockTakeoverReason(store.path);
|
|
790
790
|
const compilerReason = compilerFingerprintReason(store.path);
|
|
791
|
+
// implements REQ-kibi-uncompiled-source-visibility
|
|
792
|
+
// A source the last sync could not extract is missing from the store
|
|
793
|
+
// even when every compiled file is current.
|
|
794
|
+
const extractionReasons = store.state === "healthy"
|
|
795
|
+
? sourceExtractionFailureReasons(context.workspaceRoot, store.path)
|
|
796
|
+
: [];
|
|
791
797
|
const engineReason = engineStatus
|
|
792
798
|
? {
|
|
793
799
|
code: engineStatus.errorCode ?? "engine_status_unavailable",
|
|
@@ -811,6 +817,7 @@ export async function executeStatus(_input, context) {
|
|
|
811
817
|
...(storeReason ? [storeReason] : []),
|
|
812
818
|
...(lockReason ? [lockReason] : []),
|
|
813
819
|
...(compilerReason ? [compilerReason] : []),
|
|
820
|
+
...extractionReasons,
|
|
814
821
|
...(engineReason ? [engineReason] : []),
|
|
815
822
|
].sort((left, right) => String(left.path ?? "").localeCompare(String(right.path ?? "")));
|
|
816
823
|
const enrichedPayload = {
|
|
@@ -818,6 +825,11 @@ export async function executeStatus(_input, context) {
|
|
|
818
825
|
// Source hashes can all match while the compilation itself is lossy, so
|
|
819
826
|
// a compiler contract change alone makes the store stale.
|
|
820
827
|
...(compilerReason ? { syncState: "stale", dirty: true } : {}),
|
|
828
|
+
// An authored source sync cannot extract leaves its entities out of
|
|
829
|
+
// the store, so the KB is not current until the file is fixed.
|
|
830
|
+
...(extractionReasons.length > 0
|
|
831
|
+
? { syncState: "stale", dirty: true }
|
|
832
|
+
: {}),
|
|
821
833
|
// A missing or empty store has no stale file to report, yet nothing in
|
|
822
834
|
// it is current: the authored sources were never compiled. (A missing
|
|
823
835
|
// store without authored sources, and an unreadable or incomplete one,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { KibiResult, OperationEffect, OperationName } from "./types.js";
|
|
2
|
+
export { codedErrorOf } from "../../cli-errors.js";
|
|
3
|
+
export type { CodedErrorFields } from "../../cli-errors.js";
|
|
2
4
|
export declare const KIBI_PROTOCOL_VERSION: 1;
|
|
3
5
|
export declare function failedEffectStatus(effect: OperationEffect, failure: Record<string, unknown>): KibiResult["effects"][number];
|
|
4
6
|
export declare function resultVersion(spec: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-envelope.d.ts","sourceRoot":"","sources":["../../../src/public/operations/result-envelope.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAE7E,eAAO,MAAM,qBAAqB,EAAG,CAAU,CAAC;AAkEhD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,UAAU,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,CAS/B;AAoFD,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,MAAM,CAET;AAYD,wBAAgB,YAAY,CAAC,CAAC,EAC5B,IAAI,EAAE;IACJ,QAAQ,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,QAAQ,CAAC,aAAa,CAAC,E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OAAO,CAAC,EAC/B,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC3C,IAAI,CAKN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MIGRATION_PLAN_REFUSED } from "../../operations/planning/migration-refusal.js";
|
|
2
|
+
export { codedErrorOf } from "../../cli-errors.js";
|
|
2
3
|
export const KIBI_PROTOCOL_VERSION = 1;
|
|
3
4
|
function record(value) {
|
|
4
5
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-relationship-parity.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-relationship-parity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source-relationship-parity.d.ts","sourceRoot":"","sources":["../../../src/public/operations/source-relationship-parity.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;CACpC,CAAC,CAAC;AAaH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,SAAS,wBAAwB,EAAE,EAC7C,QAAQ,EAAE,SAAS,wBAAwB,EAAE,GAC5C,SAAS,EAAE,CAwDb;AAuCD,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,wBAAwB,EAAE,CAmB5B;AA6BD,wBAAsB,yCAAyC,CAC7D,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAwEtB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { sourceExtractionRemediation } from "../../commands/sync/cache.js";
|
|
3
4
|
import { discoverSourceFiles } from "../../commands/sync/discovery.js";
|
|
4
5
|
import { processExtractions } from "../../commands/sync/extraction.js";
|
|
5
6
|
import { findUntrackedDocumentMatches } from "../../commands/sync/untracked-targets.js";
|
|
@@ -156,14 +157,28 @@ export async function collectSourceRelationshipParityViolations(workspaceRoot, p
|
|
|
156
157
|
];
|
|
157
158
|
}
|
|
158
159
|
const extraction = await processExtractions(discovery.markdownFiles, discovery.manifestFiles, true, workspaceRoot);
|
|
160
|
+
// implements REQ-kibi-uncompiled-source-visibility
|
|
161
|
+
// A source sync cannot extract is missing from the compiled KB with every
|
|
162
|
+
// entity and relationship it declares: one blocking finding per file names
|
|
163
|
+
// it, the extraction error and the fix.
|
|
159
164
|
if (extraction.errors.length > 0) {
|
|
160
|
-
return extraction.errors.map(({ file, message }) =>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
return extraction.errors.map(({ file, message }) => {
|
|
166
|
+
const relative = path
|
|
167
|
+
.relative(workspaceRoot, file)
|
|
168
|
+
.replaceAll(path.sep, "/");
|
|
169
|
+
return {
|
|
170
|
+
rule: "source-relationship-parity",
|
|
171
|
+
entityId: relative,
|
|
172
|
+
source: relative,
|
|
173
|
+
description: `${relative} cannot be compiled, so the entities and relationships it declares are missing from the KB: ${message}`,
|
|
174
|
+
suggestion: `${sourceExtractionRemediation(relative, message)} Then rerun kb_check.`,
|
|
175
|
+
evidence: {
|
|
176
|
+
direction: "source_extraction",
|
|
177
|
+
file: relative,
|
|
178
|
+
error: message,
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
});
|
|
167
182
|
}
|
|
168
183
|
const authored = extraction.results.flatMap(({ entity, relationships }) => relationships.map((relationship) => authoredRelationship(relationship, entity.source)));
|
|
169
184
|
for (const relationship of readAllShards(path.join(workspaceRoot, ".kb"))) {
|
|
@@ -31,7 +31,7 @@ export declare const checkSpec: {
|
|
|
31
31
|
};
|
|
32
32
|
readonly includeImpactDiagnostics: {
|
|
33
33
|
readonly type: "boolean";
|
|
34
|
-
readonly description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation and
|
|
34
|
+
readonly description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation, symbol_semantic_review_needed and source_file_unowned in structured output.";
|
|
35
35
|
};
|
|
36
36
|
readonly maxDiagnostics: {
|
|
37
37
|
readonly type: "integer";
|
|
@@ -30,7 +30,7 @@ export const checkSpec = {
|
|
|
30
30
|
},
|
|
31
31
|
includeImpactDiagnostics: {
|
|
32
32
|
type: "boolean",
|
|
33
|
-
description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation and
|
|
33
|
+
description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation, symbol_semantic_review_needed and source_file_unowned in structured output.",
|
|
34
34
|
},
|
|
35
35
|
maxDiagnostics: {
|
|
36
36
|
type: "integer",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
id: kibi-bootstrap
|
|
3
3
|
name: kibi-bootstrap
|
|
4
4
|
description: "Use for any Kibi bootstrap or onboarding task: seeding a new or thin knowledge base; reviewing a bootstrap or onboarding plan, preview, or evidence; judging approval readiness or coverage; diagnosing a blocked, partial, or failed bootstrap or its repair; applying an approved bootstrap plan; or asking the human which knowledge sources hold intent. Covers kb_status first, source interview, cited intent claims, read-only kb_plan_bootstrap preview, explicit approval, exact-plan kb_apply_plan, and repair-safe close-out."
|
|
5
|
-
version: 3.
|
|
5
|
+
version: 3.14.0
|
|
6
6
|
kibiCompatibility: ">=1.0.0"
|
|
7
7
|
tags:
|
|
8
8
|
- kibi
|
|
@@ -24,7 +24,7 @@ Make `kb_status` your first tool call on every bootstrap task. This includes rev
|
|
|
24
24
|
- **Review a supplied plan or preview, or judge approval readiness or coverage:** call `kb_status`, then run your own read-only `kb_plan_bootstrap` preview. Compare it with the supplied one: hash, candidates, citations, `suppressedCandidates`, `sourceOnlySignals`, and diagnostics. Report what is ready, what is missing or uncited, and any conflicts for the human. Do not apply. End with `kb_status`.
|
|
25
25
|
- **Blocked, partial, failed, or repair:** never conclude from `kb_status` alone. Run a read-only `kb_plan_bootstrap` preview and report its eligibility and next-action fields (for example `planEligible`, `nextAction`). If it names operator-only repair such as `doctor`, report it and stop. Read `resources/branch-lifecycle.md` before migration or repair. End with `kb_status`.
|
|
26
26
|
- **New or thin knowledge base, or apply an approved plan:** follow the procedure below.
|
|
27
|
-
- **Knowledge base already seeded** (`activationMode: attached_seeded_handoff`): follow the same procedure. Kibi generates no discovered candidates here, but it still plans the intent claims you declare, deduplicated against the existing KB:
|
|
27
|
+
- **Knowledge base already seeded** (`activationMode: attached_seeded_handoff`): follow the same procedure. Kibi generates no discovered candidates here, but it still plans the intent claims you declare, deduplicated against the existing KB: a claim whose entity exists, or whose statement or excerpt restates a current requirement (same words once case and punctuation are ignored), is counted as already in the KB with the matched id, and a plan of the rest is `ready` and applies with `kb_apply_plan` after approval. A diagnostic saying a claim "closely restates" a requirement means that claim is still planned: show both to the human before approval, and drop the claim or link the two with `restates` or `supersedes`. Never fall back to one `kb_compile_intent` plus one write per claim while such a plan exists. Use `kb_compile_intent` only for claims the plan could not write (`sourceOnlySignals`, `suppressed_by_activation`, `invalid_write`), and `kb_search`/`kb_query` for existing knowledge.
|
|
28
28
|
|
|
29
29
|
## Goal
|
|
30
30
|
|