kibi-cli 2.26.3 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-operation-metadata.d.ts +1 -1
- package/dist/cli-operation-metadata.js +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +17 -2
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +2 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +24 -0
- package/dist/commands/sync/persistence.d.ts +10 -0
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +24 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +5 -1
- package/dist/diagnostics.d.ts +6 -0
- package/dist/diagnostics.d.ts.map +1 -1
- package/dist/diagnostics.js +25 -9
- package/dist/intent-search.d.ts +2 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +5 -0
- package/dist/operations/bootstrap/activation.d.ts +6 -0
- package/dist/operations/bootstrap/activation.d.ts.map +1 -1
- package/dist/operations/bootstrap/activation.js +22 -0
- package/dist/operations/bootstrap/claim-restatement.d.ts +2 -0
- package/dist/operations/bootstrap/claim-restatement.d.ts.map +1 -1
- package/dist/operations/bootstrap/conflict-review.d.ts +24 -0
- package/dist/operations/bootstrap/conflict-review.d.ts.map +1 -0
- package/dist/operations/bootstrap/conflict-review.js +92 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +18 -5
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +4 -1
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/intent-claims.js +1 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +6 -2
- package/dist/operations/bootstrap/types.d.ts +7 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/migration/entity-type.d.ts +35 -0
- package/dist/operations/migration/entity-type.d.ts.map +1 -0
- package/dist/operations/migration/entity-type.js +89 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -1
- package/dist/operations/migration/schema6.js +32 -0
- package/dist/operations/mutation/symbol-granularity.d.ts +7 -1
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-granularity.js +46 -8
- package/dist/operations/mutation/upsert.d.ts +9 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +46 -9
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +21 -0
- package/dist/operations/planning/compile-intent.d.ts +16 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +118 -5
- package/dist/operations/planning/conflict-review.d.ts +69 -0
- package/dist/operations/planning/conflict-review.d.ts.map +1 -0
- package/dist/operations/planning/conflict-review.js +133 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +8 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +43 -2
- package/dist/public/impact/analyzer.d.ts.map +1 -1
- package/dist/public/impact/analyzer.js +26 -2
- package/dist/public/impact/requirement-statements.d.ts +29 -0
- package/dist/public/impact/requirement-statements.d.ts.map +1 -0
- package/dist/public/impact/requirement-statements.js +127 -0
- package/dist/public/operations/catalog.d.ts +26 -2
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-format-shared.d.ts +1 -1
- package/dist/public/operations/check-format-shared.d.ts.map +1 -1
- package/dist/public/operations/check-format-shared.js +19 -4
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +20 -13
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +14 -4
- 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 +21 -9
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/operations/specs/planning.d.ts +25 -1
- package/dist/public/operations/specs/planning.d.ts.map +1 -1
- package/dist/public/operations/specs/planning.js +16 -1
- package/dist/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/dist/public/skills/kibi-usage/SKILL.md +11 -1
- package/dist/public/symbol-granularity.d.ts +5 -0
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.js +12 -3
- package/dist/traceability/staged-consistency.d.ts +1 -1
- package/dist/traceability/staged-consistency.d.ts.map +1 -1
- package/dist/traceability/staged-consistency.js +2 -2
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-context.d.ts +18 -0
- package/dist/traceability/staged-entity-context.d.ts.map +1 -0
- package/dist/traceability/staged-entity-context.js +66 -0
- package/dist/utils/config.d.ts +8 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +10 -0
- package/package.json +2 -2
- package/src/public/impact/analyzer.ts +38 -2
- package/src/public/impact/requirement-statements.ts +171 -0
- package/src/public/operations/check-format-shared.ts +27 -4
- package/src/public/operations/discovery-executors.ts +20 -13
- package/src/public/operations/migration-plan.ts +24 -6
- package/src/public/operations/result-envelope.ts +18 -4
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/operations/specs/planning.ts +17 -1
- package/src/public/skills/kibi-bootstrap/SKILL.md +2 -2
- package/src/public/skills/kibi-usage/SKILL.md +11 -1
- package/src/public/symbol-granularity.ts +13 -5
|
@@ -91,7 +91,7 @@ export declare const CLI_OPERATION_METADATA: readonly [{
|
|
|
91
91
|
}, {
|
|
92
92
|
readonly name: "kb_compile_intent";
|
|
93
93
|
readonly cliName: "compile-intent";
|
|
94
|
-
readonly description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. No mutation side effects.";
|
|
94
|
+
readonly description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. contradictionAnalysis.outcome is no_conflict only when the check could decide: an unmodeled proposition or a related current requirement without logic leaves it unresolved with reasons and reviewCandidates to compare and judge through conflictReviews. No mutation side effects.";
|
|
95
95
|
}, {
|
|
96
96
|
readonly name: "kb_apply_plan";
|
|
97
97
|
readonly cliName: "apply-plan";
|
|
@@ -110,7 +110,7 @@ export const CLI_OPERATION_METADATA = [
|
|
|
110
110
|
{
|
|
111
111
|
name: "kb_compile_intent",
|
|
112
112
|
cliName: "compile-intent",
|
|
113
|
-
description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. No mutation side effects.",
|
|
113
|
+
description: "Compile complete change intent into a deterministic, snapshot-bound read-only plan. Reuses intent-aware discovery and semantic modeling, accounts for every proposition, reports contradiction witnesses, proposes traceability links, and emits dependency-ordered kb_upsert-style steps only for resolved typed claims. contradictionAnalysis.outcome is no_conflict only when the check could decide: an unmodeled proposition or a related current requirement without logic leaves it unresolved with reasons and reviewCandidates to compare and judge through conflictReviews. No mutation side effects.",
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
name: "kb_apply_plan",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AAqCA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc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C,CAkEtB;AAID,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAmGtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAgDtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CA0BtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB"}
|
package/dist/commands/check.js
CHANGED
|
@@ -35,6 +35,7 @@ import { validateStagedMarkdown } from "../traceability/markdown-validate.js";
|
|
|
35
35
|
import { readSnapshotKnowledge } from "../traceability/snapshot-knowledge.js";
|
|
36
36
|
import { collectIntroducedConsistencyViolations, formatConsistencyViolations, stagesKnowledge, } from "../traceability/staged-consistency.js";
|
|
37
37
|
import { collectStagedKibiDiagnostics, } from "../traceability/staged-diagnostics.js";
|
|
38
|
+
import { collectIntroducedEntityContextViolations } from "../traceability/staged-entity-context.js";
|
|
38
39
|
import { createStagedEntityIdStyleDiagnostics } from "../traceability/staged-entity-id-style.js";
|
|
39
40
|
import { analyzeStagedFileCoverage, } from "../traceability/staged-file-coverage.js";
|
|
40
41
|
import { classifyKibiImpactEvidence, isBehaviorSourceEdit, parseKibiImpactOverride, } from "../traceability/staged-impact-contract.js";
|
|
@@ -608,6 +609,11 @@ export async function checkCommand(options) {
|
|
|
608
609
|
return { exitCode: options.dryRun ? 0 : 1 };
|
|
609
610
|
}
|
|
610
611
|
}
|
|
612
|
+
// implements REQ-cli-staged-entity-context
|
|
613
|
+
// An entity document the commit adds or edits must carry the body
|
|
614
|
+
// context full `kibi check` requires; debt already at the base, or
|
|
615
|
+
// acknowledged by the migration, does not block.
|
|
616
|
+
const contextViolations = collectIntroducedEntityContextViolations(snapshot, markdownFiles.map((file) => file.path), snapshotEntities);
|
|
611
617
|
const inventoryDrift = stagedInventoryDriftViolations({
|
|
612
618
|
stagedPaths: new Set(markdownFiles.map((file) => file.path)),
|
|
613
619
|
snapshotEntities,
|
|
@@ -814,16 +820,25 @@ export async function checkCommand(options) {
|
|
|
814
820
|
const passMessage = allSymbols.length === 0
|
|
815
821
|
? "✓ No violations found in staged files."
|
|
816
822
|
: "✓ No violations found in staged symbols.";
|
|
817
|
-
if (violationsRaw.length > 0 ||
|
|
823
|
+
if (violationsRaw.length > 0 ||
|
|
824
|
+
coverageViolations.length > 0 ||
|
|
825
|
+
contextViolations.length > 0) {
|
|
818
826
|
print({
|
|
819
827
|
format: options.format,
|
|
820
828
|
coverage: stagedCoverage,
|
|
821
|
-
violations: [
|
|
829
|
+
violations: [
|
|
830
|
+
...violationsRaw,
|
|
831
|
+
...coverageViolations,
|
|
832
|
+
...contextViolations,
|
|
833
|
+
],
|
|
822
834
|
qualityDiagnostics: stagedKibiDiagnostics,
|
|
823
835
|
messages: [
|
|
824
836
|
...(stagedKibiDiagnostics.length > 0
|
|
825
837
|
? [formatStagedKibiDiagnostics(stagedKibiDiagnostics)]
|
|
826
838
|
: []),
|
|
839
|
+
...(contextViolations.length > 0
|
|
840
|
+
? formatConsistencyViolations(contextViolations, "entity context")
|
|
841
|
+
: []),
|
|
827
842
|
...(coverageViolations.length > 0
|
|
828
843
|
? [formatCoverageViolations(coverageViolations)]
|
|
829
844
|
: []),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAyGA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuH/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -27,6 +27,7 @@ import { SwiplResolutionError, inspectSwiplBundle, probeRequiredLibraries, resol
|
|
|
27
27
|
import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
|
|
28
28
|
import { resolveBranchAttachment, resolveReadBranchAttachment, } from "../utils/branch-resolver.js";
|
|
29
29
|
import { branchStoreCompilation, inspectBranchStore, storeLockTakeoverReason, uncompiledBranchStoreReason, } from "../utils/branch-store.js";
|
|
30
|
+
import { LEGACY_KB_MIGRATION_COMMAND, LEGACY_KB_MIGRATION_NOTE, } from "../utils/config.js";
|
|
30
31
|
import { resolveGitRepository, } from "../utils/git-repository-context.js";
|
|
31
32
|
import { readKbManifestStatus } from "../utils/kb-manifest.js";
|
|
32
33
|
import { MERGE_DRIVER_SETUP, manifestMergeDriverGaps, } from "../utils/merge-driver-setup.js";
|
|
@@ -612,7 +613,7 @@ function checkKbManifest() {
|
|
|
612
613
|
message: "Not found",
|
|
613
614
|
remediation: legacy.legacyConfig === "absent"
|
|
614
615
|
? "Run: kibi init"
|
|
615
|
-
:
|
|
616
|
+
: `Run: ${LEGACY_KB_MIGRATION_COMMAND} (${LEGACY_KB_MIGRATION_NOTE})`,
|
|
616
617
|
};
|
|
617
618
|
}
|
|
618
619
|
if (status.state !== "ok") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AA+DA,OAAO,KAAK,EACV,eAAe,EAGhB,MAAM,wCAAwC,CAAC;AAwBhD,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,IAAI,C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AAC,GACpC,OAAO,CAOT"}
|
package/dist/commands/migrate.js
CHANGED
|
@@ -17,6 +17,8 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { existsSync, mkdirSync, renameSync, writeFileSync, } from "node:fs";
|
|
19
19
|
import * as path from "node:path";
|
|
20
|
+
import { countByType } from "../operations/migration/entity-body-context.js";
|
|
21
|
+
import { applyEntityTypeBackfill, planEntityTypeBackfill, } from "../operations/migration/entity-type.js";
|
|
20
22
|
import { applySafeInventoryRederivations, planInventoryRederivation, } from "../operations/migration/inventory-rederive.js";
|
|
21
23
|
import { applyOriginBackfill, planOriginBackfill, } from "../operations/migration/origin-backfill.js";
|
|
22
24
|
import { applyDeliveredStatusMappings, planRequirementStatusMappings, } from "../operations/migration/requirement-status.js";
|
|
@@ -357,6 +359,24 @@ function mapLegacyRequirementStatuses(cwd, dryRun) {
|
|
|
357
359
|
review: planRequirementStatusMappings(cwd),
|
|
358
360
|
};
|
|
359
361
|
}
|
|
362
|
+
/**
|
|
363
|
+
* State the folder-implied type on entity files without one, so the first
|
|
364
|
+
* kb_upsert on such a file changes only what it was asked to change.
|
|
365
|
+
* Returns how many files were (or, on a dry run, would be) rewritten.
|
|
366
|
+
*/
|
|
367
|
+
// implements REQ-cli-migrate-entity-type-backfill
|
|
368
|
+
function stateFolderImpliedTypes(cwd, dryRun) {
|
|
369
|
+
const plan = dryRun
|
|
370
|
+
? planEntityTypeBackfill(cwd)
|
|
371
|
+
: applyEntityTypeBackfill(cwd);
|
|
372
|
+
if (plan.targets.length > 0)
|
|
373
|
+
console.log(`${dryRun ? "dry run: would state" : "Stated"} the folder-implied type on ${plan.targets.length} entity file(s) without one (${Object.entries(countByType(plan.targets))
|
|
374
|
+
.map(([type, count]) => `${count} ${type}`)
|
|
375
|
+
.join(", ")}); no other line changes.`);
|
|
376
|
+
for (const skip of plan.skipped)
|
|
377
|
+
printWarning(`Type not stated for ${skip.path}: ${skip.reason}.`);
|
|
378
|
+
return plan.targets.length;
|
|
379
|
+
}
|
|
360
380
|
/**
|
|
361
381
|
* Print what a `kibi migrate --yes` run left for a person, naming the
|
|
362
382
|
* requirements kibi sync cannot compile first. Returns false when nothing
|
|
@@ -467,6 +487,7 @@ export async function migrateCommand(options = {}) {
|
|
|
467
487
|
const polarityCount = options.dryRun
|
|
468
488
|
? planPolarityValueBackfill(cwd).length
|
|
469
489
|
: applyPolarityValueBackfill(cwd);
|
|
490
|
+
const typesStated = stateFolderImpliedTypes(cwd, options.dryRun === true);
|
|
470
491
|
// Delivery statuses keep requirements out of the store at any version;
|
|
471
492
|
// map them before the drift check, which only sees compiled requirements.
|
|
472
493
|
const statuses = mapLegacyRequirementStatuses(cwd, options.dryRun === true);
|
|
@@ -476,6 +497,7 @@ export async function migrateCommand(options = {}) {
|
|
|
476
497
|
const lifecycle = repairLifecycleFindings(cwd, options.dryRun === true);
|
|
477
498
|
const legacyLinks = markLegacySymbolLinks(cwd, options.dryRun === true);
|
|
478
499
|
const rewroteSources = polarityCount > 0 ||
|
|
500
|
+
typesStated > 0 ||
|
|
479
501
|
statuses.mapped > 0 ||
|
|
480
502
|
legacyLinks > 0 ||
|
|
481
503
|
drift.rederived.length > 0 ||
|
|
@@ -569,6 +591,7 @@ export async function migrateCommand(options = {}) {
|
|
|
569
591
|
console.log(`dry run: would record origin {kind: migration} on ${backfill.targets.length} authored entit(ies) without one.`);
|
|
570
592
|
}
|
|
571
593
|
}
|
|
594
|
+
stateFolderImpliedTypes(cwd, true);
|
|
572
595
|
mapLegacyRequirementStatuses(cwd, true);
|
|
573
596
|
rederiveDriftedInventories(cwd, true);
|
|
574
597
|
repairLifecycleFindings(cwd, true);
|
|
@@ -600,6 +623,7 @@ export async function migrateCommand(options = {}) {
|
|
|
600
623
|
? "pending"
|
|
601
624
|
: "not_applicable");
|
|
602
625
|
const migratedAt = new Date().toISOString();
|
|
626
|
+
stateFolderImpliedTypes(cwd, false);
|
|
603
627
|
const polarityValuesRewritten = applyPolarityValueBackfill(cwd);
|
|
604
628
|
if (polarityValuesRewritten > 0)
|
|
605
629
|
console.log(`Encoded ${polarityValuesRewritten} legacy polarity-only fact(s) as typed booleans.`);
|
|
@@ -12,6 +12,16 @@ export declare function retractEntitiesById(prolog: PrologProcess, entityIds: re
|
|
|
12
12
|
/** Clear outgoing inline relationships for entities whose payload changed. */
|
|
13
13
|
export declare function retractEntityRelationshipsById(prolog: PrologProcess, entityIds: readonly string[]): Promise<void>;
|
|
14
14
|
export declare function retractRelationships(prolog: PrologProcess, relationships: readonly ExtractedRelationship[]): Promise<number>;
|
|
15
|
+
/** What the store holds after a sync, by entity type, plus relationships. */
|
|
16
|
+
export type StoreTotals = Readonly<{
|
|
17
|
+
entities: Record<string, number>;
|
|
18
|
+
relationships: number;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Count what the store holds after this sync. Undefined when the store
|
|
22
|
+
* cannot be counted; the summary then shows only what was imported.
|
|
23
|
+
*/
|
|
24
|
+
export declare function queryStoreTotals(prolog: Pick<PrologProcess, "query">): Promise<StoreTotals | undefined>;
|
|
15
25
|
export declare function persistEntities(prolog: PrologProcess, results: ExtractionResult[], entityIds: Set<string>, options?: {
|
|
16
26
|
loadExistingEntityIds?: boolean;
|
|
17
27
|
}): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AA2HrD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AAuFD,iFAAiF;AACjF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,SAAS,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AE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO,GAChD,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAoRvD;AA4BD,wBAAgB,0BAA0B,CACxC,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,CAER;AAGD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,gBAAgB,EAAE,EAC3B,kBAAkB,EAAE,qBAAqB,EAAE,EAC3C,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,MAAM,CAAA;CAAO,GACvC,OAAO,CAAC;IAAE,iBAAiB,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC,CAmO7D"}
|
|
@@ -284,6 +284,30 @@ async function tryResetPrologProcess(prolog) {
|
|
|
284
284
|
return false;
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
|
+
/**
|
|
288
|
+
* Count what the store holds after this sync. Undefined when the store
|
|
289
|
+
* cannot be counted; the summary then shows only what was imported.
|
|
290
|
+
*/
|
|
291
|
+
// implements REQ-cli-sync-summary-kb-totals
|
|
292
|
+
export async function queryStoreTotals(prolog) {
|
|
293
|
+
const result = await prolog
|
|
294
|
+
.query(
|
|
295
|
+
// kb_entity and kb_relationship need the type bound.
|
|
296
|
+
"findall(Type-Count, (member(Type, [req,scenario,test,adr,flag,event,symbol,fact]), aggregate_all(count, kb_entity(_, Type, _), Count), Count > 0), Counts), aggregate_all(count, (kibi_relationships:relationship_type(Rel), kb_relationship(Rel, _, _)), Relationships)")
|
|
297
|
+
.catch(() => undefined);
|
|
298
|
+
const counts = result?.success ? result.bindings?.Counts : undefined;
|
|
299
|
+
const relationships = result?.success
|
|
300
|
+
? Number(result.bindings?.Relationships)
|
|
301
|
+
: Number.NaN;
|
|
302
|
+
if (typeof counts !== "string" || !Number.isInteger(relationships))
|
|
303
|
+
return undefined;
|
|
304
|
+
const entities = {};
|
|
305
|
+
for (const [, type, count] of counts.matchAll(/([a-z]+)-(\d+)/g)) {
|
|
306
|
+
if (type !== undefined && count !== undefined)
|
|
307
|
+
entities[type] = Number(count);
|
|
308
|
+
}
|
|
309
|
+
return { entities, relationships };
|
|
310
|
+
}
|
|
287
311
|
export async function persistEntities(
|
|
288
312
|
// implements REQ-009
|
|
289
313
|
prolog, results, entityIds, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6BjE,OAAO,EAEL,yBAAyB,EAE1B,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,6BAA6B,CAAC;AA0BrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA6BjE,OAAO,EAEL,yBAAyB,EAE1B,MAAM,gDAAgD,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,6BAA6B,CAAC;AA0BrC,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAmCxE,qBAAa,SAAU,SAAQ,KAAK;gBACtB,OAAO,EAAE,MAAM;CAI5B;AAmCD,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,MAAM,EACrB,gBAAgB,EAAE,MAAM,EACxB,4BAA4B,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AAgB,iCAAiC,CAC/C,WAAW,EAAE,UAAU,EAAE,EACzB,oBAAoB,EAAE,OAAO,EAC7B,iBAAiB,EAAE,MAAM,EACzB,WAAW,EAAE,MAAM,GAClB,IAAI,CAUN;AAGD,wBAAsB,WAAW,CAC/B,OAAO,GAAE;IACP,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,CAAC;CACZ,EACN,OAAO,GAAE,kBAAuB,GAC/B,OAAO,CAAC,UAAU,CAAC,CA2uCrB;AAED,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/commands/sync.js
CHANGED
|
@@ -34,7 +34,7 @@ import { SYNC_CACHE_TTL_MS, SYNC_CACHE_VERSION, SYNC_COMPILER_FINGERPRINT, faile
|
|
|
34
34
|
import { clearRecoveredPendingSourceReceipts, discoverSourceFiles, } from "./sync/discovery.js";
|
|
35
35
|
import { normalizeExtractionSources, processExtractions, } from "./sync/extraction.js";
|
|
36
36
|
import { normalizeManifestLayout, refreshManifestCoordinates, } from "./sync/manifest.js";
|
|
37
|
-
import { persistEntities, persistRelationships, retractEntitiesById, retractEntitiesForSources, retractEntityRelationshipsById, retractRelationships, } from "./sync/persistence.js";
|
|
37
|
+
import { persistEntities, persistRelationships, queryStoreTotals, retractEntitiesById, retractEntitiesForSources, retractEntityRelationshipsById, retractRelationships, } from "./sync/persistence.js";
|
|
38
38
|
import { atomicPublish, atomicPublishGeneration, cleanupStaging, createUniqueStagingPath, prepareStagingEnvironment, } from "./sync/staging.js";
|
|
39
39
|
import { adoptUpsertOnlySymbolManifest, findUntrackedDocumentMatches, } from "./sync/untracked-targets.js";
|
|
40
40
|
// Manual deletion of a written-but-unstaged source leaves a recovery receipt
|
|
@@ -990,6 +990,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
990
990
|
}
|
|
991
991
|
}
|
|
992
992
|
const { relationshipCount, kbModified: relationshipsModified } = await persistRelationships(engineProlog, results, [...shardDeltaByKey.values()], { workspaceRoot });
|
|
993
|
+
const storeTotals = await queryStoreTotals(engineProlog);
|
|
993
994
|
const kbModified = removedCount > 0 ||
|
|
994
995
|
relationshipChanged ||
|
|
995
996
|
entitiesModified ||
|
|
@@ -1039,6 +1040,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
1039
1040
|
branch: currentBranch,
|
|
1040
1041
|
timestamp: new Date().toISOString(),
|
|
1041
1042
|
entityCounts,
|
|
1043
|
+
...(storeTotals !== undefined ? { storeTotals } : {}),
|
|
1042
1044
|
relationshipCount,
|
|
1043
1045
|
success: true,
|
|
1044
1046
|
published,
|
|
@@ -1143,6 +1145,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
1143
1145
|
prolog.invalidateCache();
|
|
1144
1146
|
}
|
|
1145
1147
|
await runtime.beforeSave?.({ ...runtimeContext, kbModified });
|
|
1148
|
+
const storeTotals = await queryStoreTotals(prolog);
|
|
1146
1149
|
const saveResult = await prolog.query("kb_save");
|
|
1147
1150
|
if (!saveResult.success) {
|
|
1148
1151
|
throw new SyncError(`Failed to save staging KB: ${saveResult.error || "Unknown error"}`);
|
|
@@ -1226,6 +1229,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
1226
1229
|
branch: currentBranch,
|
|
1227
1230
|
timestamp: new Date().toISOString(),
|
|
1228
1231
|
entityCounts,
|
|
1232
|
+
...(storeTotals !== undefined ? { storeTotals } : {}),
|
|
1229
1233
|
relationshipCount,
|
|
1230
1234
|
success: true,
|
|
1231
1235
|
published,
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -17,7 +17,13 @@ export interface SyncSummary {
|
|
|
17
17
|
branch: string;
|
|
18
18
|
commit?: string;
|
|
19
19
|
timestamp: string;
|
|
20
|
+
/** Entities this sync imported (changed sources only), by type. */
|
|
20
21
|
entityCounts: Record<string, number>;
|
|
22
|
+
/** What the store holds after this sync, when counted. */
|
|
23
|
+
storeTotals?: Readonly<{
|
|
24
|
+
entities: Record<string, number>;
|
|
25
|
+
relationships: number;
|
|
26
|
+
}>;
|
|
21
27
|
relationshipCount: number;
|
|
22
28
|
success: boolean;
|
|
23
29
|
published: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../src/diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,kBAAkB,GAC1B,2BAA2B,GAC3B,YAAY,GACZ,kBAAkB,GAClB,mBAAmB,GACnB,YAAY,GACZ,kBAAkB,GAClB,oBAAoB,CAAC;AAEzB,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,eAAe,GACf,eAA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estion: `Move ${embeddedTypes.join(" and ")} to separate entity files and link them using 'links' with relationship types like 'specified_by' or 'verified_by'.`,
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
+
function pushCounts(lines, counts) {
|
|
49
|
+
const sortedTypes = Object.keys(counts).sort();
|
|
50
|
+
if (sortedTypes.length === 0) {
|
|
51
|
+
lines.push(" (none)");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (const type of sortedTypes) {
|
|
55
|
+
lines.push(` ${type}: ${counts[type]}`);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
48
58
|
/**
|
|
49
59
|
* Format sync summary for CLI output
|
|
50
60
|
*/
|
|
@@ -57,18 +67,24 @@ export function formatSyncSummary(summary) {
|
|
|
57
67
|
}
|
|
58
68
|
lines.push(`Timestamp: ${summary.timestamp}`);
|
|
59
69
|
lines.push("");
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
70
|
+
// A sync recompiles only changed sources, so what it imported is a delta;
|
|
71
|
+
// the store totals are what the KB holds now.
|
|
72
|
+
// implements REQ-cli-sync-summary-kb-totals
|
|
73
|
+
const totals = summary.storeTotals;
|
|
74
|
+
if (totals === undefined) {
|
|
75
|
+
lines.push("Entity Counts:");
|
|
76
|
+
pushCounts(lines, summary.entityCounts);
|
|
77
|
+
lines.push(`Total Relationships: ${summary.relationshipCount}`);
|
|
65
78
|
}
|
|
66
79
|
else {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
80
|
+
const entityTotal = Object.values(totals.entities).reduce((sum, count) => sum + count, 0);
|
|
81
|
+
const imported = Object.values(summary.entityCounts).reduce((sum, count) => sum + count, 0);
|
|
82
|
+
lines.push(`KB Totals: ${entityTotal} entities`);
|
|
83
|
+
pushCounts(lines, totals.entities);
|
|
84
|
+
lines.push(`KB Relationships: ${totals.relationships}`);
|
|
85
|
+
lines.push(`Imported This Sync (changed sources only): ${imported} entities, ${summary.relationshipCount} relationship records`);
|
|
86
|
+
pushCounts(lines, summary.entityCounts);
|
|
70
87
|
}
|
|
71
|
-
lines.push(`Total Relationships: ${summary.relationshipCount}`);
|
|
72
88
|
lines.push("");
|
|
73
89
|
lines.push(`Status: ${summary.success ? "✓ Success" : "✗ Failed"}`);
|
|
74
90
|
lines.push(`Published: ${summary.published ? "Yes" : "No"}`);
|
package/dist/intent-search.d.ts
CHANGED
|
@@ -63,6 +63,8 @@ type GraphEdge = Readonly<{
|
|
|
63
63
|
}>;
|
|
64
64
|
/** Workspace file paths the question names in its text, in order, once each. */
|
|
65
65
|
export declare function questionPaths(query: string): string[];
|
|
66
|
+
/** The signal tokens intent ranking compares (stop words dropped, stemmed). */
|
|
67
|
+
export declare function intentTokens(value: string): readonly string[];
|
|
66
68
|
/** Markdown bodies already read in this search, keyed by entity source. */
|
|
67
69
|
export type MarkdownBodyCache = Map<string, string | null>;
|
|
68
70
|
export declare function rankIntentEntities(entities: readonly Record<string, unknown>[], options: IntentSearchOptions, workspaceRoot: string, graphEdges?: readonly GraphEdge[], bodyCache?: MarkdownBodyCache): Promise<IntentSearchResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,SAAS,GACT,SAAS,GACT,aAAa,GACb,SAAS,CAAC;AAGd,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CACvC,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAC1D,CAAC;AAGF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC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AE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAGD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CA0C1E"}
|
package/dist/intent-search.js
CHANGED
|
@@ -198,6 +198,11 @@ function tokens(value) {
|
|
|
198
198
|
.split(" ")
|
|
199
199
|
.filter((token) => token.length > 0 && !STOP_WORDS.has(token))));
|
|
200
200
|
}
|
|
201
|
+
/** The signal tokens intent ranking compares (stop words dropped, stemmed). */
|
|
202
|
+
// implements REQ-kibi-contradiction-review-candidates
|
|
203
|
+
export function intentTokens(value) {
|
|
204
|
+
return tokens(value);
|
|
205
|
+
}
|
|
201
206
|
// Clause boundaries an agent writes when it packs several questions into one
|
|
202
207
|
// query: "user roles: how many can a user have, support role".
|
|
203
208
|
const CLAUSE_SEPARATOR = /[;:,!?\n]+|\.(?=\s|$)|\s[-\u2013\u2014]\s/;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { OperationContext } from "../../public/operations/runtime-types.js";
|
|
2
2
|
import type { ActivationPolicy, Candidate } from "./types.js";
|
|
3
3
|
export declare function missingManifestActivation(vendored: boolean, projectSignal: boolean): ActivationPolicy;
|
|
4
|
+
/**
|
|
5
|
+
* A legacy `.kb/config.json` without a manifest holds knowledge written by an
|
|
6
|
+
* older Kibi: it is migrated, never initialized, so the first step is the one
|
|
7
|
+
* `kibi doctor` names.
|
|
8
|
+
*/
|
|
9
|
+
export declare function legacyKbActivation(): ActivationPolicy;
|
|
4
10
|
/**
|
|
5
11
|
* On a seeded KB the plan may hold declared intent claims, already
|
|
6
12
|
* deduplicated against the existing KB. Such a plan is applicable like a thin
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/activation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAQjF,OAAO,KAAK,EAAE,gBAAgB,EAAmB,SAAS,EAAE,MAAM,YAAY,CAAC;AAI/E,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,OAAO,EACjB,aAAa,EAAE,OAAO,GACrB,gBAAgB,CAIlB;AAED;;;;GAIG;AAEH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAWrD;AAkED;;;;GAIG;AAGH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EACxB,UAAU,EAAE,SAAS,SAAS,EAAE,GAC/B,gBAAgB,CAelB;AAyDD,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,gBAAgB,EACzB,KAAK,GAAE,SAAS,MAAM,EAAO,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA8E3B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import { LEGACY_KB_MIGRATION_COMMAND, LEGACY_KB_MIGRATION_NOTE, readLegacyKbConfig, } from "../../utils/config.js";
|
|
2
3
|
import { readKbManifestStatus } from "../../utils/kb-manifest.js";
|
|
3
4
|
import { KB_PATHS } from "../../utils/kb-paths.js";
|
|
4
5
|
// implements REQ-KIBI-BOOTSTRAP-PLAN
|
|
@@ -6,6 +7,24 @@ import { KB_PATHS } from "../../utils/kb-paths.js";
|
|
|
6
7
|
export function missingManifestActivation(vendored, projectSignal) {
|
|
7
8
|
return activationFor(vendored && !projectSignal ? "vendored_only" : "root_uninitialized");
|
|
8
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* A legacy `.kb/config.json` without a manifest holds knowledge written by an
|
|
12
|
+
* older Kibi: it is migrated, never initialized, so the first step is the one
|
|
13
|
+
* `kibi doctor` names.
|
|
14
|
+
*/
|
|
15
|
+
// implements REQ-legacy-kb-first-step-migrate
|
|
16
|
+
export function legacyKbActivation() {
|
|
17
|
+
return {
|
|
18
|
+
activationState: "root_partial",
|
|
19
|
+
activationMode: "repair_bootstrap",
|
|
20
|
+
applyBlocked: true,
|
|
21
|
+
allowCandidateGeneration: true,
|
|
22
|
+
allowDeclaredClaims: true,
|
|
23
|
+
reason: `Workspace has a legacy .kb/config.json and no .kb/manifest.json; run \`${LEGACY_KB_MIGRATION_COMMAND}\` (${LEGACY_KB_MIGRATION_NOTE}) before planning bootstrap knowledge.`,
|
|
24
|
+
handoffMessage: `This knowledge base was written by an older Kibi. Run \`${LEGACY_KB_MIGRATION_COMMAND}\` (${LEGACY_KB_MIGRATION_NOTE}), then check kb_status again.`,
|
|
25
|
+
nextOperation: LEGACY_KB_MIGRATION_COMMAND,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
9
28
|
function activationFor(state) {
|
|
10
29
|
switch (state) {
|
|
11
30
|
case "root_uninitialized":
|
|
@@ -138,6 +157,9 @@ export async function classifyActivation(context, files = []) {
|
|
|
138
157
|
return relative.replaceAll("\\", "/");
|
|
139
158
|
});
|
|
140
159
|
const manifestStatus = readKbManifestStatus(context.workspaceRoot);
|
|
160
|
+
if (manifestStatus.state === "missing" &&
|
|
161
|
+
readLegacyKbConfig(context.workspaceRoot).kind !== "none")
|
|
162
|
+
return legacyKbActivation();
|
|
141
163
|
if (manifestStatus.state === "missing") {
|
|
142
164
|
const vendored = normalizedFiles.some((file) => file.startsWith("kibi/"));
|
|
143
165
|
const projectSignalFromFiles = normalizedFiles.some((file) => !file.startsWith("kibi/") &&
|
|
@@ -3,6 +3,8 @@ export type ExistingRequirement = {
|
|
|
3
3
|
readonly id: string;
|
|
4
4
|
readonly title: string;
|
|
5
5
|
readonly semanticText: string;
|
|
6
|
+
/** Whether it has a logical representation; unknown when not loaded. */
|
|
7
|
+
readonly modeled?: boolean;
|
|
6
8
|
};
|
|
7
9
|
/**
|
|
8
10
|
* Token-set Jaccard at or above which a claim that is not an exact
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claim-restatement.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/claim-restatement.ts"],"names":[],"mappings":"AAKA,iEAAiE;AAEjE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"claim-restatement.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/claim-restatement.ts"],"names":[],"mappings":"AAKA,iEAAiE;AAEjE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,wEAAwE;IACxE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF;;;;;GAKG;AAEH,eAAO,MAAM,wBAAwB,MAAsB,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,6EAA6E;IAC7E,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAAC;IAC1C,sEAAsE;IACtE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AAEH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM7D;AAwBD;;;;;;;GAOG;AAEH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,EAC3C,YAAY,EAAE,SAAS,mBAAmB,EAAE,GAC3C,gBAAgB,GAAG,IAAI,CAoCzB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ExistingRequirement } from "./claim-restatement.js";
|
|
2
|
+
import type { Candidate, SourceOnlySignal } from "./types.js";
|
|
3
|
+
/** Whether a candidate or signal names requirements to compare it with. */
|
|
4
|
+
export declare function needsConflictReview(row: {
|
|
5
|
+
readonly evidence: readonly string[];
|
|
6
|
+
}): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Intent claims are checked for contradictions only against current
|
|
9
|
+
* requirements that have a logical representation. For each claim, name the
|
|
10
|
+
* current requirements on the same topic that have none, so the reviewer
|
|
11
|
+
* compares them instead of reading the plan as consistent: the diagnostic
|
|
12
|
+
* names both, and the claim's evidence gains `review_against:<id>` for each.
|
|
13
|
+
* A planned claim is compared before approval; a claim left for authoring
|
|
14
|
+
* (a source-only signal) is compared when it is compiled with
|
|
15
|
+
* kb_compile_intent, which takes the verdicts through conflictReviews.
|
|
16
|
+
* Ranking is the intent search kb_search uses, over the unmodeled
|
|
17
|
+
* requirements only.
|
|
18
|
+
*/
|
|
19
|
+
export declare function withConflictReviewSignals(candidates: readonly Candidate[], requirements: readonly ExistingRequirement[], workspaceRoot: string, signals?: readonly SourceOnlySignal[]): Promise<{
|
|
20
|
+
candidates: Candidate[];
|
|
21
|
+
signals: SourceOnlySignal[];
|
|
22
|
+
diagnostics: string[];
|
|
23
|
+
}>;
|
|
24
|
+
//# sourceMappingURL=conflict-review.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict-review.d.ts","sourceRoot":"","sources":["../../../src/operations/bootstrap/conflict-review.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAK9D,2EAA2E;AAE3E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE;IACvC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC,GAAG,OAAO,CAEV;AAUD;;;;;;;;;;;GAWG;AAEH,wBAAsB,yBAAyB,CAC7C,UAAU,EAAE,SAAS,SAAS,EAAE,EAChC,YAAY,EAAE,SAAS,mBAAmB,EAAE,EAC5C,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,SAAS,gBAAgB,EAAO,GACxC,OAAO,CAAC;IACT,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC,CA6ED"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { rankIntentEntities } from "../../intent-search.js";
|
|
2
|
+
import { MAX_REVIEW_CANDIDATES, REVIEW_CANDIDATE_MIN_SCORE, } from "../planning/conflict-review.js";
|
|
3
|
+
/** Evidence a claim gains for each requirement it must be compared with. */
|
|
4
|
+
const REVIEW_AGAINST = "review_against:";
|
|
5
|
+
/** Whether a candidate or signal names requirements to compare it with. */
|
|
6
|
+
// implements REQ-kibi-contradiction-review-candidates, REQ-bootstrap-authoring-claim-review
|
|
7
|
+
export function needsConflictReview(row) {
|
|
8
|
+
return row.evidence.some((entry) => entry.startsWith(REVIEW_AGAINST));
|
|
9
|
+
}
|
|
10
|
+
function claimCitation(evidence, fallback) {
|
|
11
|
+
return (evidence
|
|
12
|
+
.find((entry) => entry.startsWith("intent_claim:"))
|
|
13
|
+
?.slice("intent_claim:".length) ?? fallback);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Intent claims are checked for contradictions only against current
|
|
17
|
+
* requirements that have a logical representation. For each claim, name the
|
|
18
|
+
* current requirements on the same topic that have none, so the reviewer
|
|
19
|
+
* compares them instead of reading the plan as consistent: the diagnostic
|
|
20
|
+
* names both, and the claim's evidence gains `review_against:<id>` for each.
|
|
21
|
+
* A planned claim is compared before approval; a claim left for authoring
|
|
22
|
+
* (a source-only signal) is compared when it is compiled with
|
|
23
|
+
* kb_compile_intent, which takes the verdicts through conflictReviews.
|
|
24
|
+
* Ranking is the intent search kb_search uses, over the unmodeled
|
|
25
|
+
* requirements only.
|
|
26
|
+
*/
|
|
27
|
+
// implements REQ-kibi-contradiction-review-candidates, REQ-bootstrap-authoring-claim-review
|
|
28
|
+
export async function withConflictReviewSignals(candidates, requirements, workspaceRoot, signals = []) {
|
|
29
|
+
const unmodeled = requirements
|
|
30
|
+
.filter((requirement) => requirement.modeled === false)
|
|
31
|
+
.map((requirement) => ({
|
|
32
|
+
id: requirement.id,
|
|
33
|
+
type: "req",
|
|
34
|
+
title: requirement.title,
|
|
35
|
+
semantic_text: requirement.semanticText,
|
|
36
|
+
}));
|
|
37
|
+
if (unmodeled.length === 0)
|
|
38
|
+
return {
|
|
39
|
+
candidates: [...candidates],
|
|
40
|
+
signals: [...signals],
|
|
41
|
+
diagnostics: [],
|
|
42
|
+
};
|
|
43
|
+
const titles = new Map(requirements.map((requirement) => [requirement.id, requirement.title]));
|
|
44
|
+
const related = async (query) => {
|
|
45
|
+
const ranked = await rankIntentEntities(unmodeled, { query, type: "req", minScore: REVIEW_CANDIDATE_MIN_SCORE }, workspaceRoot);
|
|
46
|
+
return ranked.matches
|
|
47
|
+
.slice(0, MAX_REVIEW_CANDIDATES)
|
|
48
|
+
.map((match) => String(match.entity.id ?? ""))
|
|
49
|
+
.filter(Boolean);
|
|
50
|
+
};
|
|
51
|
+
const named = (ids) => ids.map((id) => `${id} ("${titles.get(id) ?? ""}")`).join(", ");
|
|
52
|
+
const diagnostics = [];
|
|
53
|
+
const reviewed = [];
|
|
54
|
+
for (const candidate of candidates) {
|
|
55
|
+
if (candidate.sourceKind !== "intent_claim" ||
|
|
56
|
+
candidate.entityType !== "req") {
|
|
57
|
+
reviewed.push(candidate);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const ids = await related(candidate.title);
|
|
61
|
+
if (ids.length === 0) {
|
|
62
|
+
reviewed.push(candidate);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
diagnostics.push(`conflict-review: Intent claim at ${claimCitation(candidate.evidence, candidate.sourcePath)} ("${candidate.title}") was not checked for contradictions against current requirement ${named(ids)}, which has no logical representation. Compare them before approval: on a contradiction show both to the human, then drop the claim or keep it and supersede the requirement after apply; record a conflict the human has not decided as a review:conflict observation fact.`);
|
|
66
|
+
reviewed.push({
|
|
67
|
+
...candidate,
|
|
68
|
+
evidence: [
|
|
69
|
+
...candidate.evidence,
|
|
70
|
+
...ids.map((id) => REVIEW_AGAINST + id),
|
|
71
|
+
],
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
const reviewedSignals = [];
|
|
75
|
+
for (const signal of signals) {
|
|
76
|
+
if (signal.kind !== "req" || signal.claimStatement === undefined) {
|
|
77
|
+
reviewedSignals.push(signal);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const ids = await related(signal.claimStatement);
|
|
81
|
+
if (ids.length === 0) {
|
|
82
|
+
reviewedSignals.push(signal);
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
diagnostics.push(`conflict-review: Intent claim at ${claimCitation(signal.evidence, signal.sourcePath)} ("${signal.claimStatement}") needs authoring and was not checked for contradictions against current requirement ${named(ids)}, which has no logical representation. When you compile the claim with kb_compile_intent, compare it with them and report each verdict through conflictReviews; on a contradiction show both to the human before writing.`);
|
|
86
|
+
reviewedSignals.push({
|
|
87
|
+
...signal,
|
|
88
|
+
evidence: [...signal.evidence, ...ids.map((id) => REVIEW_AGAINST + id)],
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return { candidates: reviewed, signals: reviewedSignals, diagnostics };
|
|
92
|
+
}
|