kibi-cli 2.4.0 → 2.5.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-json-command.d.ts +6 -0
- package/dist/cli-json-command.d.ts.map +1 -1
- package/dist/cli-json-command.js +37 -9
- package/dist/cli-operation-loader.d.ts.map +1 -1
- package/dist/cli-operation-loader.js +7 -0
- package/dist/cli-operation-metadata.d.ts +12 -4
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +14 -4
- package/dist/cli-protocol.d.ts +14 -0
- package/dist/cli-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +31 -2
- package/dist/cli-register-proof.d.ts.map +1 -1
- package/dist/cli-register-proof.js +13 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +11 -2
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +8 -2
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +4 -2
- package/dist/commands/gc.d.ts.map +1 -1
- package/dist/commands/gc.js +7 -0
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +0 -1
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +281 -14
- package/dist/commands/proof-compact.d.ts +9 -0
- package/dist/commands/proof-compact.d.ts.map +1 -0
- package/dist/commands/proof-compact.js +58 -0
- package/dist/commands/prove.d.ts +38 -0
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +222 -47
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +61 -16
- package/dist/commands/sync.d.ts +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +42 -16
- package/dist/diagnostics.js +1 -1
- package/dist/engine-limits.d.ts +74 -0
- package/dist/engine-limits.d.ts.map +1 -0
- package/dist/engine-limits.js +201 -0
- package/dist/engine.d.ts +10 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +57 -9
- package/dist/extractors/manifest.d.ts +8 -0
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +34 -5
- package/dist/extractors/markdown.d.ts +8 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +57 -0
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +2 -0
- package/dist/intent-search.d.ts +4 -1
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +186 -33
- package/dist/operations/bootstrap/candidate-helpers.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidate-helpers.js +8 -1
- package/dist/operations/bootstrap/candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/candidates.js +54 -38
- package/dist/operations/bootstrap/generate.d.ts +2 -0
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +87 -33
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/intent-claims.js +12 -4
- package/dist/operations/bootstrap/markdown-candidates.d.ts +2 -0
- package/dist/operations/bootstrap/markdown-candidates.d.ts.map +1 -1
- package/dist/operations/bootstrap/markdown-candidates.js +32 -10
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +6 -2
- package/dist/operations/bootstrap/requirement-claims.d.ts +1 -0
- package/dist/operations/bootstrap/requirement-claims.d.ts.map +1 -1
- package/dist/operations/bootstrap/requirement-claims.js +13 -1
- package/dist/operations/bootstrap/validation.d.ts +4 -0
- package/dist/operations/bootstrap/validation.d.ts.map +1 -0
- package/dist/operations/bootstrap/validation.js +20 -0
- package/dist/operations/migration/inventory-rederive.d.ts +81 -0
- package/dist/operations/migration/inventory-rederive.d.ts.map +1 -0
- package/dist/operations/migration/inventory-rederive.js +484 -0
- package/dist/operations/migration/kb-sources.d.ts +53 -0
- package/dist/operations/migration/kb-sources.d.ts.map +1 -0
- package/dist/operations/migration/kb-sources.js +233 -0
- package/dist/operations/migration/origin-backfill.d.ts +39 -0
- package/dist/operations/migration/origin-backfill.d.ts.map +1 -0
- package/dist/operations/migration/origin-backfill.js +164 -0
- package/dist/operations/migration/polarity-values.d.ts +10 -0
- package/dist/operations/migration/polarity-values.d.ts.map +1 -0
- package/dist/operations/migration/polarity-values.js +60 -0
- package/dist/operations/migration/schema6.d.ts +59 -0
- package/dist/operations/migration/schema6.d.ts.map +1 -0
- package/dist/operations/migration/schema6.js +379 -0
- package/dist/operations/migration/source-paths.d.ts +131 -0
- package/dist/operations/migration/source-paths.d.ts.map +1 -0
- package/dist/operations/migration/source-paths.js +308 -0
- package/dist/operations/migration/superseded-closure.d.ts +54 -0
- package/dist/operations/migration/superseded-closure.d.ts.map +1 -0
- package/dist/operations/migration/superseded-closure.js +187 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +3 -5
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +225 -67
- package/dist/operations/mutation/contradictions.d.ts +16 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +32 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +15 -7
- package/dist/operations/mutation/origin.d.ts +21 -0
- package/dist/operations/mutation/origin.d.ts.map +1 -0
- package/dist/operations/mutation/origin.js +78 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts +182 -0
- package/dist/operations/mutation/plan-apply-journal.d.ts.map +1 -0
- package/dist/operations/mutation/plan-apply-journal.js +613 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +3 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.js +13 -2
- package/dist/operations/mutation/relationships.d.ts +5 -5
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +31 -11
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +3 -1
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +7 -1
- package/dist/operations/mutation/types.d.ts +14 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +30 -3
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +105 -35
- package/dist/operations/mutation/validate-upsert.d.ts +6 -0
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +34 -30
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +751 -144
- package/dist/operations/planning/compile-intent.d.ts +34 -1
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +314 -98
- package/dist/operations/proof/code-scope.d.ts +28 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +72 -0
- package/dist/operations/proof/compact-receipts.d.ts +49 -0
- package/dist/operations/proof/compact-receipts.d.ts.map +1 -0
- package/dist/operations/proof/compact-receipts.js +160 -0
- package/dist/operations/proof/ingest-proof.d.ts +2 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +44 -23
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +5 -9
- package/dist/operations/proof/receipt-compaction.d.ts +48 -0
- package/dist/operations/proof/receipt-compaction.d.ts.map +1 -0
- package/dist/operations/proof/receipt-compaction.js +121 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analysis-receipt.js +12 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +2 -1
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/analyze-prose.js +51 -5
- package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/clauses.js +11 -1
- package/dist/operations/semantic-advisor/conditional-rules.d.ts +33 -0
- package/dist/operations/semantic-advisor/conditional-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/conditional-rules.js +262 -0
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +3 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
- package/dist/operations/semantic-advisor/ingestion-boundary.js +14 -6
- package/dist/operations/semantic-advisor/plugin-orchestration.js +1 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -1
- package/dist/prolog.d.ts +9 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +56 -10
- package/dist/proof/command-test-report.d.ts +74 -0
- package/dist/proof/command-test-report.d.ts.map +1 -0
- package/dist/proof/command-test-report.js +206 -0
- package/dist/public/branch-resolver.d.ts +1 -0
- package/dist/public/branch-resolver.d.ts.map +1 -1
- package/dist/public/branch-resolver.js +1 -0
- package/dist/public/entity-origin.d.ts +69 -0
- package/dist/public/entity-origin.d.ts.map +1 -0
- package/dist/public/entity-origin.js +142 -0
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +1 -0
- package/dist/public/impact/requirement-quality.js +1 -1
- package/dist/public/operations/catalog.d.ts +130 -19
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/catalog.js +3 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +8 -0
- package/dist/public/operations/contracts.d.ts +0 -5
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +63 -14
- package/dist/public/operations/discovery-entities.d.ts +15 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +59 -0
- package/dist/public/operations/discovery-executors.d.ts +6 -1
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +65 -6
- package/dist/public/operations/index.d.ts +1 -0
- package/dist/public/operations/index.d.ts.map +1 -1
- package/dist/public/operations/index.js +1 -0
- package/dist/public/operations/migration-plan.d.ts +5 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +26 -1
- package/dist/public/operations/node-ports.d.ts.map +1 -1
- package/dist/public/operations/node-ports.js +24 -3
- package/dist/public/operations/origin-review.d.ts +51 -0
- package/dist/public/operations/origin-review.d.ts.map +1 -0
- package/dist/public/operations/origin-review.js +307 -0
- package/dist/public/operations/predicate-schema-conformance.js +1 -1
- package/dist/public/operations/repair-plan.d.ts.map +1 -1
- package/dist/public/operations/repair-plan.js +4 -0
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +17 -5
- package/dist/public/operations/runtime-types.d.ts +9 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/schema6-check-actions.d.ts +127 -0
- package/dist/public/operations/schema6-check-actions.d.ts.map +1 -0
- package/dist/public/operations/schema6-check-actions.js +575 -0
- package/dist/public/operations/source-path-dangling.d.ts +17 -0
- package/dist/public/operations/source-path-dangling.d.ts.map +1 -0
- package/dist/public/operations/source-path-dangling.js +66 -0
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +15 -1
- package/dist/public/operations/specs/check.d.ts +2 -2
- package/dist/public/operations/specs/check.js +1 -1
- package/dist/public/operations/specs/composite.d.ts +351 -0
- package/dist/public/operations/specs/composite.d.ts.map +1 -0
- package/dist/public/operations/specs/composite.js +96 -0
- package/dist/public/operations/specs/discovery.d.ts +8 -3
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +8 -3
- package/dist/public/operations/specs/modeling.d.ts +2 -2
- package/dist/public/operations/specs/modeling.js +2 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts +73 -8
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +43 -7
- package/dist/public/operations/specs/mutation.d.ts +1 -1
- package/dist/public/operations/specs/mutation.js +1 -1
- package/dist/public/operations/specs/planning.d.ts +2 -2
- package/dist/public/operations/specs/planning.js +4 -4
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +13 -26
- package/dist/public/operations/specs/upsert.d.ts +79 -9
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +6 -1
- package/dist/public/operations/types.d.ts +1 -1
- package/dist/public/operations/types.d.ts.map +1 -1
- package/dist/public/proof-receipt.d.ts +1 -0
- package/dist/public/proof-receipt.d.ts.map +1 -1
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +52 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +2 -0
- package/dist/public/skills/kibi-bootstrap/SKILL.md +6 -1
- package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
- package/dist/public/skills/kibi-usage/SKILL.md +68 -18
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/dist/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/dist/public/skills/kibi-usage/resources/operation-access.md +25 -1
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/dist/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/dist/public/telemetry-acceptance.d.ts +58 -2
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +136 -10
- package/dist/public/telemetry-remediation.d.ts.map +1 -1
- package/dist/public/telemetry-remediation.js +26 -10
- package/dist/relationships/shards.d.ts +13 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +54 -28
- package/dist/runtime/cli-runtime.d.ts.map +1 -1
- package/dist/runtime/cli-runtime.js +44 -3
- package/dist/runtime/detached-snapshot.d.ts +38 -0
- package/dist/runtime/detached-snapshot.d.ts.map +1 -0
- package/dist/runtime/detached-snapshot.js +92 -0
- package/dist/schemas/entity.schema.json +122 -0
- package/dist/search-answer.d.ts +157 -0
- package/dist/search-answer.d.ts.map +1 -0
- package/dist/search-answer.js +846 -0
- package/dist/traceability/impact-knowledge.d.ts.map +1 -1
- package/dist/traceability/impact-knowledge.js +7 -0
- package/dist/traceability/symbol-extract.js +3 -3
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +12 -0
- package/dist/types/entities.d.ts +13 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/branch-resolver.d.ts +37 -1
- package/dist/utils/branch-resolver.d.ts.map +1 -1
- package/dist/utils/branch-resolver.js +130 -3
- package/dist/utils/repo-relative-path.d.ts +18 -0
- package/dist/utils/repo-relative-path.d.ts.map +1 -0
- package/dist/utils/repo-relative-path.js +58 -0
- package/dist/utils/rule-registry.generated.d.ts +75 -3
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +89 -3
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.d.ts.map +1 -1
- package/dist/utils/schema-version.js +4 -3
- package/dist/utils/strict-modeling.d.ts +1 -1
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +23 -3
- package/package.json +3 -3
- package/schema/entities.pl +22 -0
- package/schema/relationships.pl +14 -0
- package/schema/validation.pl +45 -1
- package/src/public/branch-resolver.ts +1 -0
- package/src/public/entity-origin.ts +175 -0
- package/src/public/impact/full-kb-quality.ts +1 -0
- package/src/public/impact/requirement-quality.ts +1 -1
- package/src/public/operations/catalog.ts +3 -0
- package/src/public/operations/check-executor.ts +15 -0
- package/src/public/operations/contracts.ts +75 -15
- package/src/public/operations/discovery-entities.ts +74 -0
- package/src/public/operations/discovery-executors.ts +88 -10
- package/src/public/operations/index.ts +1 -0
- package/src/public/operations/migration-plan.ts +30 -1
- package/src/public/operations/node-ports.ts +24 -3
- package/src/public/operations/origin-review.ts +375 -0
- package/src/public/operations/predicate-schema-conformance.ts +1 -1
- package/src/public/operations/repair-plan.ts +4 -0
- package/src/public/operations/result-envelope.ts +18 -6
- package/src/public/operations/runtime-types.ts +9 -0
- package/src/public/operations/schema6-check-actions.ts +699 -0
- package/src/public/operations/source-path-dangling.ts +81 -0
- package/src/public/operations/specs/check-rules.generated.ts +15 -1
- package/src/public/operations/specs/check.ts +1 -1
- package/src/public/operations/specs/composite.ts +141 -0
- package/src/public/operations/specs/discovery.ts +9 -3
- package/src/public/operations/specs/modeling.ts +2 -2
- package/src/public/operations/specs/mutation-schemas.ts +49 -7
- package/src/public/operations/specs/mutation.ts +1 -1
- package/src/public/operations/specs/planning.ts +4 -4
- package/src/public/operations/specs/reporting.ts +13 -38
- package/src/public/operations/specs/upsert.ts +7 -1
- package/src/public/operations/types.ts +2 -0
- package/src/public/proof-receipt.ts +1 -0
- package/src/public/schemas/entity.ts +57 -0
- package/src/public/schemas/relationship.ts +2 -0
- package/src/public/skills/kibi-bootstrap/SKILL.md +6 -1
- package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +6 -0
- package/src/public/skills/kibi-usage/SKILL.md +68 -18
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -5
- package/src/public/skills/kibi-usage/resources/kb-improvement.md +1 -1
- package/src/public/skills/kibi-usage/resources/logic-ir.md +2 -2
- package/src/public/skills/kibi-usage/resources/operation-access.md +25 -1
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +4 -4
- package/src/public/skills/kibi-usage/resources/workflows.md +42 -25
- package/src/public/telemetry-acceptance-types.d.ts +4 -1
- package/src/public/telemetry-acceptance.ts +204 -10
- package/src/public/telemetry-remediation.ts +39 -10
- package/src/schemas/entity.schema.json +122 -0
- package/src/schemas/relationship.schema.json +2 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import path from "node:path";
|
|
19
|
+
import { extractFromMarkdown, } from "../../extractors/markdown.js";
|
|
20
|
+
import { migrationAction, } from "../../public/operations/migration-plan.js";
|
|
21
|
+
import { CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID, CLOSE_SUPERSEDED_REQUIREMENTS_CODE, MIGRATION_SYNC_ACTION_ID, MIGRATION_SYNC_CODE, SOURCE_PATH_REWRITE_ACTION_ID, SOURCE_PATH_REWRITE_CODE, closeSupersededRequirementsActionInput, exceptionUnapprovedActionInput, migrationSyncActionInput, sourcePathReviewActionInput, sourcePathRewriteActionInput, supersessionCycleReviewActionInput, } from "../../public/operations/schema6-check-actions.js";
|
|
22
|
+
import { readAllShards } from "../../relationships/shards.js";
|
|
23
|
+
import { applyInventoryRederivation, planInventoryRederivation, } from "./inventory-rederive.js";
|
|
24
|
+
import { listLaneMarkdownFiles } from "./kb-sources.js";
|
|
25
|
+
import { applyOriginBackfill, planOriginBackfill } from "./origin-backfill.js";
|
|
26
|
+
import { POLARITY_VALUE_BACKFILL_CODE, applyPolarityValueBackfill, planPolarityValueBackfill, } from "./polarity-values.js";
|
|
27
|
+
import { applySourcePathRepairs, findSourceRepairs, plannedSourcePathRepairs, } from "./source-paths.js";
|
|
28
|
+
import { applySupersededClosures, planSupersededClosures, } from "./superseded-closure.js";
|
|
29
|
+
/** The KB schema generation that introduced entity `origin`. */
|
|
30
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
31
|
+
export const ORIGIN_SCHEMA_VERSION = 6;
|
|
32
|
+
/** Automatic: re-derive a drifted inventory with the current advisor. */
|
|
33
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
34
|
+
export const SEMANTIC_INVENTORY_REDERIVE_CODE = "semantic_inventory_rederive";
|
|
35
|
+
/** Review: a drifted inventory Kibi cannot re-derive safely. */
|
|
36
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
37
|
+
export const SEMANTIC_INVENTORY_REVIEW_CODE = "semantic_inventory_review";
|
|
38
|
+
/** Automatic: stamp `origin: {kind: migration}` on authored entities. */
|
|
39
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
40
|
+
export const ENTITY_ORIGIN_BACKFILL_CODE = "entity_origin_backfill";
|
|
41
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
42
|
+
export const ENTITY_ORIGIN_BACKFILL_ACTION_ID = "entity-origin-backfill";
|
|
43
|
+
export { CLOSE_SUPERSEDED_REQUIREMENTS_CODE, MIGRATION_SYNC_ACTION_ID, MIGRATION_SYNC_CODE, SOURCE_PATH_REWRITE_CODE, };
|
|
44
|
+
const CURRENT_REQUIREMENT_STATUSES = new Set([
|
|
45
|
+
"open",
|
|
46
|
+
"in_progress",
|
|
47
|
+
"closed",
|
|
48
|
+
"active",
|
|
49
|
+
"approved",
|
|
50
|
+
]);
|
|
51
|
+
function rederiveAction(plan) {
|
|
52
|
+
const changed = plan.changes.filter((change) => change.change !== "kept");
|
|
53
|
+
return migrationAction({
|
|
54
|
+
id: `semantic-inventory-rederive-${plan.requirementId}`,
|
|
55
|
+
code: SEMANTIC_INVENTORY_REDERIVE_CODE,
|
|
56
|
+
category: "semantic",
|
|
57
|
+
safety: "automatic",
|
|
58
|
+
autoApplicable: true,
|
|
59
|
+
invocation: { kind: "cli", command_argv: ["kibi", "migrate", "--yes"] },
|
|
60
|
+
affectedEntityIds: [plan.requirementId],
|
|
61
|
+
affectedFiles: [plan.path],
|
|
62
|
+
postconditions: [
|
|
63
|
+
{
|
|
64
|
+
check: "proposition-complete-ingestion",
|
|
65
|
+
entityId: plan.requirementId,
|
|
66
|
+
errors: 0,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
evidence: {
|
|
70
|
+
reason: "The stored semantic inventory no longer matches the current semantic advisor, so kibi sync rejects this requirement.",
|
|
71
|
+
ingestionErrors: plan.errors,
|
|
72
|
+
summary: plan.summary,
|
|
73
|
+
changes: changed,
|
|
74
|
+
contractHash: plan.contractHash,
|
|
75
|
+
rule: "Claims whose claim_key and claim_text still match keep their status and grounding; new or changed claims are unresolved, never modeled.",
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function reviewAction(plan) {
|
|
80
|
+
return migrationAction({
|
|
81
|
+
id: `semantic-inventory-review-${plan.requirementId}`,
|
|
82
|
+
code: SEMANTIC_INVENTORY_REVIEW_CODE,
|
|
83
|
+
category: "semantic",
|
|
84
|
+
safety: "review",
|
|
85
|
+
invocation: {
|
|
86
|
+
kind: "review",
|
|
87
|
+
instruction: `${plan.requirementId} (${plan.path}) no longer matches the current semantic advisor and cannot be re-derived automatically: ${plan.reasons.join("; ")}. Fix it by hand: run \`kibi model --input -\` with {"mode":"analyze","payload":{"type":"req","id":"${plan.requirementId}","properties":<the requirement's current properties>}} to get the current inventory; re-ground or remove each listed grounding link (kb_delete with the relationship) so modeled claims and requires_* links match one to one; kb_upsert the requirement with the returned semantic_inventory, logic_claims and semantic_source_hash (keep modeled only for claims that still have a grounding fact with the same claim_key); then run kibi sync.`,
|
|
88
|
+
},
|
|
89
|
+
affectedEntityIds: [plan.requirementId],
|
|
90
|
+
affectedFiles: [plan.path],
|
|
91
|
+
dispositionRequired: true,
|
|
92
|
+
allowedDispositions: ["fixed", "deferred"],
|
|
93
|
+
evidence: {
|
|
94
|
+
ingestionErrors: plan.errors,
|
|
95
|
+
reasons: plan.reasons,
|
|
96
|
+
summary: plan.summary,
|
|
97
|
+
changes: plan.changes.filter((change) => change.change !== "kept"),
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Exceptions without approved_by, read from authored sources so the list is
|
|
103
|
+
* available before the KB compiles.
|
|
104
|
+
*/
|
|
105
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
106
|
+
export function unapprovedExceptionsFromSources(workspaceRoot) {
|
|
107
|
+
const requirements = new Map();
|
|
108
|
+
const relationships = [];
|
|
109
|
+
for (const file of listLaneMarkdownFiles(workspaceRoot, ["requirements"])) {
|
|
110
|
+
try {
|
|
111
|
+
const result = extractFromMarkdown(file.absolutePath);
|
|
112
|
+
requirements.set(result.entity.id, {
|
|
113
|
+
id: result.entity.id,
|
|
114
|
+
status: result.entity.status,
|
|
115
|
+
approvedBy: (result.entity.approved_by ?? "").trim(),
|
|
116
|
+
source: file.relativePath,
|
|
117
|
+
});
|
|
118
|
+
relationships.push(...result.relationships);
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
// Unreadable requirements fail sync with their own diagnostic.
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
relationships.push(...readAllShards(path.join(workspaceRoot, ".kb")));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
// Malformed shards fail sync with their own diagnostic.
|
|
129
|
+
}
|
|
130
|
+
const superseded = new Set(relationships
|
|
131
|
+
.filter((relationship) => relationship.type === "supersedes")
|
|
132
|
+
.map((relationship) => relationship.to));
|
|
133
|
+
const exempts = new Map();
|
|
134
|
+
for (const relationship of relationships) {
|
|
135
|
+
if (relationship.type !== "exempts")
|
|
136
|
+
continue;
|
|
137
|
+
const bases = exempts.get(relationship.from) ?? new Set();
|
|
138
|
+
bases.add(relationship.to);
|
|
139
|
+
exempts.set(relationship.from, bases);
|
|
140
|
+
}
|
|
141
|
+
return [...exempts.entries()]
|
|
142
|
+
.flatMap(([exceptionId, bases]) => {
|
|
143
|
+
const requirement = requirements.get(exceptionId);
|
|
144
|
+
if (requirement === undefined ||
|
|
145
|
+
requirement.approvedBy !== "" ||
|
|
146
|
+
!CURRENT_REQUIREMENT_STATUSES.has(requirement.status) ||
|
|
147
|
+
superseded.has(exceptionId)) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
return [
|
|
151
|
+
{
|
|
152
|
+
exceptionId,
|
|
153
|
+
exempts: [...bases].sort(),
|
|
154
|
+
source: requirement.source,
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
})
|
|
158
|
+
.sort((left, right) => left.exceptionId.localeCompare(right.exceptionId));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Source-derived migration actions: inventory re-derivation whenever an
|
|
162
|
+
* advisor change makes stored inventories drift and the lifecycle repairs
|
|
163
|
+
* (superseded requirements to close, dangling source paths) at any schema
|
|
164
|
+
* version, and, for a KB older than schema 6, the origin backfill plus the
|
|
165
|
+
* exceptions that stop exempting anything. Read-only.
|
|
166
|
+
*/
|
|
167
|
+
// implements REQ-cli-schema-migration, REQ-agent-guided-migration-orchestration, REQ-kibi-proposition-complete-ingestion
|
|
168
|
+
export function buildSchema6MigrationFragment(input) {
|
|
169
|
+
const actions = [];
|
|
170
|
+
const sourceRewriteActionIds = [];
|
|
171
|
+
const diagnostics = [];
|
|
172
|
+
const polarityTargets = planPolarityValueBackfill(input.workspaceRoot);
|
|
173
|
+
if (polarityTargets.length > 0) {
|
|
174
|
+
const id = "polarity-value-backfill";
|
|
175
|
+
sourceRewriteActionIds.push(id);
|
|
176
|
+
actions.push(migrationAction({
|
|
177
|
+
id,
|
|
178
|
+
code: POLARITY_VALUE_BACKFILL_CODE,
|
|
179
|
+
category: "schema",
|
|
180
|
+
safety: "automatic",
|
|
181
|
+
autoApplicable: true,
|
|
182
|
+
invocation: { kind: "cli", command_argv: ["kibi", "migrate", "--yes"] },
|
|
183
|
+
affectedEntityIds: polarityTargets.map((row) => row.id),
|
|
184
|
+
affectedFiles: polarityTargets.map((row) => row.path),
|
|
185
|
+
postconditions: [{ rule: "strict-fact-shape", findings: 0 }],
|
|
186
|
+
evidence: {
|
|
187
|
+
count: polarityTargets.length,
|
|
188
|
+
encoding: { operator: "eq", value_type: "bool", value_bool: true },
|
|
189
|
+
preserves: "IDs, polarity and authored body",
|
|
190
|
+
},
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
const drift = planInventoryRederivation(input.workspaceRoot);
|
|
194
|
+
for (const plan of drift) {
|
|
195
|
+
const action = plan.safe ? rederiveAction(plan) : reviewAction(plan);
|
|
196
|
+
actions.push(action);
|
|
197
|
+
if (plan.safe)
|
|
198
|
+
sourceRewriteActionIds.push(action.id);
|
|
199
|
+
}
|
|
200
|
+
if (drift.some((plan) => !plan.safe)) {
|
|
201
|
+
diagnostics.push(`${drift.filter((plan) => !plan.safe).length} requirement inventory(ies) need a manual fix before kibi sync succeeds; see the semantic_inventory_review actions.`);
|
|
202
|
+
}
|
|
203
|
+
// A missing or invalid version upgrades through every step, schema 6's
|
|
204
|
+
// backfill included, so it is planned here too.
|
|
205
|
+
const preOrigin = input.currentSchemaVersion === null ||
|
|
206
|
+
input.currentSchemaVersion < ORIGIN_SCHEMA_VERSION;
|
|
207
|
+
if (preOrigin) {
|
|
208
|
+
const backfill = planOriginBackfill(input.workspaceRoot);
|
|
209
|
+
if (backfill.targets.length > 0) {
|
|
210
|
+
const byType = {};
|
|
211
|
+
for (const target of backfill.targets) {
|
|
212
|
+
byType[target.type || "unknown"] =
|
|
213
|
+
(byType[target.type || "unknown"] ?? 0) + 1;
|
|
214
|
+
}
|
|
215
|
+
actions.push(migrationAction({
|
|
216
|
+
id: ENTITY_ORIGIN_BACKFILL_ACTION_ID,
|
|
217
|
+
code: ENTITY_ORIGIN_BACKFILL_CODE,
|
|
218
|
+
category: "schema",
|
|
219
|
+
safety: "automatic",
|
|
220
|
+
autoApplicable: true,
|
|
221
|
+
invocation: {
|
|
222
|
+
kind: "cli",
|
|
223
|
+
command_argv: ["kibi", "migrate", "--yes"],
|
|
224
|
+
},
|
|
225
|
+
affectedFiles: [".kb/"],
|
|
226
|
+
postconditions: [{ entitiesWithoutOrigin: 0 }],
|
|
227
|
+
evidence: {
|
|
228
|
+
reason: "Schema 6 records who authored each entity. Entities written before it get origin {kind: migration, ref: 'kibi migrate v5->v6', recorded_at}; the frontmatter is otherwise unchanged.",
|
|
229
|
+
count: backfill.targets.length,
|
|
230
|
+
byType,
|
|
231
|
+
entityIds: backfill.targets.map((target) => target.id),
|
|
232
|
+
skipped: backfill.skipped,
|
|
233
|
+
...(input.currentSchemaVersion === null ||
|
|
234
|
+
input.currentSchemaVersion < 5
|
|
235
|
+
? {
|
|
236
|
+
note: "Knowledge the schema upgrade moves into .kb/ is stamped when it moves.",
|
|
237
|
+
}
|
|
238
|
+
: {}),
|
|
239
|
+
},
|
|
240
|
+
}));
|
|
241
|
+
sourceRewriteActionIds.push(ENTITY_ORIGIN_BACKFILL_ACTION_ID);
|
|
242
|
+
}
|
|
243
|
+
for (const exception of unapprovedExceptionsFromSources(input.workspaceRoot)) {
|
|
244
|
+
actions.push(migrationAction(exceptionUnapprovedActionInput(exception)));
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// Blocking lifecycle findings with a mechanical fix are planned at any
|
|
248
|
+
// schema version: they block kibi check until they are resolved.
|
|
249
|
+
const lifecycle = buildLifecycleRepairActions(input.workspaceRoot);
|
|
250
|
+
actions.push(...lifecycle.actions);
|
|
251
|
+
sourceRewriteActionIds.push(...lifecycle.sourceRewriteActionIds);
|
|
252
|
+
return { actions, sourceRewriteActionIds, diagnostics };
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Actions for the superseded-requirement-open and source-path-dangling
|
|
256
|
+
* findings in authored sources: close superseded requirements, and rewrite
|
|
257
|
+
* moved or remove redundant and dead source values, automatically; one
|
|
258
|
+
* review per supersession cycle and per source value Kibi cannot edit
|
|
259
|
+
* safely. Read-only.
|
|
260
|
+
*/
|
|
261
|
+
// implements REQ-cli-schema-migration, REQ-core-validation-rules, REQ-kibi-schema6-migration
|
|
262
|
+
export function buildLifecycleRepairActions(workspaceRoot) {
|
|
263
|
+
const actions = [];
|
|
264
|
+
const sourceRewriteActionIds = [];
|
|
265
|
+
const supersession = planSupersededClosures(workspaceRoot);
|
|
266
|
+
if (supersession.closures.length > 0) {
|
|
267
|
+
actions.push(migrationAction(closeSupersededRequirementsActionInput(supersession.closures)));
|
|
268
|
+
sourceRewriteActionIds.push(CLOSE_SUPERSEDED_REQUIREMENTS_ACTION_ID);
|
|
269
|
+
}
|
|
270
|
+
for (const cycle of supersession.cycles) {
|
|
271
|
+
actions.push(migrationAction(supersessionCycleReviewActionInput(cycle)));
|
|
272
|
+
}
|
|
273
|
+
const repairs = findSourceRepairs(workspaceRoot);
|
|
274
|
+
for (const repair of repairs) {
|
|
275
|
+
if (repair.refused === undefined)
|
|
276
|
+
continue;
|
|
277
|
+
actions.push(migrationAction(sourcePathReviewActionInput({
|
|
278
|
+
entityId: repair.entityId,
|
|
279
|
+
value: repair.value,
|
|
280
|
+
file: repair.file,
|
|
281
|
+
reason: repair.refused,
|
|
282
|
+
...(repair.fix.kind === "rewrite" ? { rewrite: repair.fix.to } : {}),
|
|
283
|
+
})));
|
|
284
|
+
}
|
|
285
|
+
const planned = plannedSourcePathRepairs(repairs);
|
|
286
|
+
if (planned.rewrites.length > 0 || planned.removals.length > 0) {
|
|
287
|
+
actions.push(migrationAction(sourcePathRewriteActionInput(planned)));
|
|
288
|
+
sourceRewriteActionIds.push(SOURCE_PATH_REWRITE_ACTION_ID);
|
|
289
|
+
}
|
|
290
|
+
return { actions, sourceRewriteActionIds };
|
|
291
|
+
}
|
|
292
|
+
/** The sync that recompiles sources rewritten by earlier actions. */
|
|
293
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
294
|
+
export function migrationSyncAction(dependsOn) {
|
|
295
|
+
return migrationAction(migrationSyncActionInput(dependsOn));
|
|
296
|
+
}
|
|
297
|
+
function plannedRecords(value) {
|
|
298
|
+
if (!Array.isArray(value))
|
|
299
|
+
return [];
|
|
300
|
+
return value.filter((raw) => raw !== null && typeof raw === "object" && !Array.isArray(raw));
|
|
301
|
+
}
|
|
302
|
+
/** The rewrites and removals an approved source_path_rewrite action lists. */
|
|
303
|
+
// implements REQ-kibi-schema6-migration
|
|
304
|
+
function plannedRepairs(action) {
|
|
305
|
+
const rewrites = [];
|
|
306
|
+
for (const { entityId, file, from, to } of plannedRecords(action.evidence.rewrites)) {
|
|
307
|
+
if (typeof entityId === "string" &&
|
|
308
|
+
typeof file === "string" &&
|
|
309
|
+
typeof from === "string" &&
|
|
310
|
+
typeof to === "string") {
|
|
311
|
+
rewrites.push({ entityId, file, from, to });
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const removals = [];
|
|
315
|
+
for (const { entityId, file, from, reason } of plannedRecords(action.evidence.removals)) {
|
|
316
|
+
if (typeof entityId === "string" &&
|
|
317
|
+
typeof file === "string" &&
|
|
318
|
+
typeof from === "string" &&
|
|
319
|
+
(reason === "self" || reason === "dangling")) {
|
|
320
|
+
removals.push({ entityId, file, from, reason });
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return { rewrites, removals };
|
|
324
|
+
}
|
|
325
|
+
/** Execute one automatic action produced by this module. */
|
|
326
|
+
// implements REQ-cli-schema-migration, REQ-agent-guided-migration-orchestration
|
|
327
|
+
export async function applySchema6MigrationAction(action, context) {
|
|
328
|
+
switch (action.code) {
|
|
329
|
+
case POLARITY_VALUE_BACKFILL_CODE: {
|
|
330
|
+
applyPolarityValueBackfill(context.workspaceRoot);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
case SEMANTIC_INVENTORY_REDERIVE_CODE: {
|
|
334
|
+
const requirementId = action.affectedEntityIds[0];
|
|
335
|
+
if (requirementId === undefined)
|
|
336
|
+
throw new Error("Inventory re-derivation names no requirement.");
|
|
337
|
+
const contractHash = typeof action.evidence.contractHash === "string"
|
|
338
|
+
? action.evidence.contractHash
|
|
339
|
+
: undefined;
|
|
340
|
+
applyInventoryRederivation(context.workspaceRoot, requirementId, contractHash);
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
case ENTITY_ORIGIN_BACKFILL_CODE:
|
|
344
|
+
applyOriginBackfill(context.workspaceRoot, context.clock().toISOString());
|
|
345
|
+
return;
|
|
346
|
+
case CLOSE_SUPERSEDED_REQUIREMENTS_CODE: {
|
|
347
|
+
const result = applySupersededClosures(context.workspaceRoot, new Set(action.affectedEntityIds));
|
|
348
|
+
if (result.skipped.length > 0)
|
|
349
|
+
throw new Error(`Could not close ${result.skipped.map((skip) => `${skip.path} (${skip.reason})`).join(", ")}; set status: closed by hand.`);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
case SOURCE_PATH_REWRITE_CODE: {
|
|
353
|
+
const result = applySourcePathRepairs(context.workspaceRoot, plannedRepairs(action));
|
|
354
|
+
if (result.skipped.length > 0)
|
|
355
|
+
throw new Error(`Could not repair the source of ${result.skipped.map((skip) => `${skip.file} (${skip.reason})`).join(", ")}; rerun kibi migrate and approve the new plan.`);
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
case MIGRATION_SYNC_CODE: {
|
|
359
|
+
const { syncCommand } = await import("../../commands/sync.js");
|
|
360
|
+
const result = await syncCommand({
|
|
361
|
+
workspaceRoot: context.workspaceRoot,
|
|
362
|
+
});
|
|
363
|
+
if (!result.success)
|
|
364
|
+
throw new Error("kibi sync did not complete after the migration rewrote sources; run kibi sync to see why.");
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
default:
|
|
368
|
+
throw new Error(`Migration action '${action.code}' has no schema 6 executor.`);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// implements REQ-kibi-schema6-migration, REQ-cli-schema-migration
|
|
372
|
+
export const SCHEMA6_AUTOMATIC_CODES = new Set([
|
|
373
|
+
POLARITY_VALUE_BACKFILL_CODE,
|
|
374
|
+
SEMANTIC_INVENTORY_REDERIVE_CODE,
|
|
375
|
+
ENTITY_ORIGIN_BACKFILL_CODE,
|
|
376
|
+
CLOSE_SUPERSEDED_REQUIREMENTS_CODE,
|
|
377
|
+
SOURCE_PATH_REWRITE_CODE,
|
|
378
|
+
MIGRATION_SYNC_CODE,
|
|
379
|
+
]);
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The authored `source` frontmatter field is dead data. The compiled
|
|
3
|
+
* `source` is always the entity's own file: the Markdown extractor ignores
|
|
4
|
+
* the field, and Kibi never writes it. Values written before the canonical
|
|
5
|
+
* `.kb/` layout still name knowledge files by their old path: under the
|
|
6
|
+
* retired `documentation/` tree, or relative to the knowledge root
|
|
7
|
+
* (`requirements/REQ-x.md`). This module finds the values that resolve to
|
|
8
|
+
* nothing (the `source-path-dangling` check) and every value `kibi migrate`
|
|
9
|
+
* repairs: a moved file is rewritten to its `.kb/` path, and a value that
|
|
10
|
+
* names the entity's own file or nothing Kibi can map is removed. A value
|
|
11
|
+
* naming another existing workspace path, an entity id or an http(s) URL is
|
|
12
|
+
* provenance and stays.
|
|
13
|
+
*/
|
|
14
|
+
/** One authored `source` value and the entity file that carries it. */
|
|
15
|
+
export type AuthoredSourceRef = Readonly<{
|
|
16
|
+
entityId: string;
|
|
17
|
+
/** Workspace-relative, `/`-separated path of the entity's own file. */
|
|
18
|
+
file: string;
|
|
19
|
+
value: unknown;
|
|
20
|
+
}>;
|
|
21
|
+
export type AuthoredSourceScan = Readonly<{
|
|
22
|
+
refs: readonly AuthoredSourceRef[];
|
|
23
|
+
/** Ids of every authored entity, symbols included. */
|
|
24
|
+
entityIds: ReadonlySet<string>;
|
|
25
|
+
}>;
|
|
26
|
+
export type SourceResolution = Readonly<{
|
|
27
|
+
kind: "missing" | "path" | "entity" | "url";
|
|
28
|
+
}>
|
|
29
|
+
/** Names the entity's own file; `resolves` is false when that spelling names no existing path. */
|
|
30
|
+
| Readonly<{
|
|
31
|
+
kind: "self";
|
|
32
|
+
resolves: boolean;
|
|
33
|
+
}> | Readonly<{
|
|
34
|
+
kind: "dangling";
|
|
35
|
+
rewrite?: string;
|
|
36
|
+
}>;
|
|
37
|
+
/** Why `kibi migrate` removes an authored `source` value. */
|
|
38
|
+
export type SourceRemovalReason = "self" | "dangling";
|
|
39
|
+
/** The edit `kibi migrate` makes to one authored `source` value. */
|
|
40
|
+
export type SourceFix = Readonly<{
|
|
41
|
+
kind: "rewrite";
|
|
42
|
+
to: string;
|
|
43
|
+
}> | Readonly<{
|
|
44
|
+
kind: "remove";
|
|
45
|
+
reason: SourceRemovalReason;
|
|
46
|
+
}>;
|
|
47
|
+
/** One authored `source` value that is redundant or resolves to nothing. */
|
|
48
|
+
export type SourceRepair = AuthoredSourceRef & Readonly<{
|
|
49
|
+
/** Names no existing path, entity id or URL: `source-path-dangling` blocks it. */
|
|
50
|
+
dangling: boolean;
|
|
51
|
+
fix: SourceFix;
|
|
52
|
+
/** Why the value cannot be edited safely; a person must edit it. */
|
|
53
|
+
refused?: string;
|
|
54
|
+
}>;
|
|
55
|
+
/** An authored value as plain text, the form plans record and compare. */
|
|
56
|
+
export declare function shownSourceValue(value: unknown): string;
|
|
57
|
+
/**
|
|
58
|
+
* Read every authored entity's `source` field and id in one pass over the
|
|
59
|
+
* canonical lanes, plus the symbol ids of the symbols manifest. Only the id
|
|
60
|
+
* and source lines are parsed. Read-only.
|
|
61
|
+
*/
|
|
62
|
+
export declare function scanAuthoredSources(workspaceRoot: string): AuthoredSourceScan;
|
|
63
|
+
/**
|
|
64
|
+
* Resolve one authored `source` value: an existing workspace path (any
|
|
65
|
+
* `#anchor` suffix ignored), an existing entity id or an http(s) URL. With
|
|
66
|
+
* the entity's own `file`, a value naming that file (canonical or
|
|
67
|
+
* pre-canonical spelling, `./` and `#anchor` ignored, compared
|
|
68
|
+
* case-insensitively) resolves to `self`. A dangling
|
|
69
|
+
* `documentation/<lane>/...` or `<lane>/...` value carries the
|
|
70
|
+
* `.kb/<lane>/...` rewrite when that file exists.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveAuthoredSource(value: unknown, context: Readonly<{
|
|
73
|
+
workspaceRoot: string;
|
|
74
|
+
entityIds: ReadonlySet<string>;
|
|
75
|
+
exists: (relativePath: string) => boolean;
|
|
76
|
+
/** Workspace-relative path of the entity's own file. */
|
|
77
|
+
file?: string;
|
|
78
|
+
}>): SourceResolution;
|
|
79
|
+
/** A memoized existence test confined to the workspace. */
|
|
80
|
+
export declare function workspacePathExists(workspaceRoot: string): (relativePath: string) => boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Every authored `source` value that resolves to nothing, sorted by entity
|
|
83
|
+
* id, with the fix `kibi migrate` makes and, when the edit is not safe, why.
|
|
84
|
+
* Each path is checked once per call. Read-only.
|
|
85
|
+
*/
|
|
86
|
+
export declare function findDanglingSources(workspaceRoot: string): SourceRepair[];
|
|
87
|
+
/**
|
|
88
|
+
* Every authored `source` value `kibi migrate` rewrites or removes: the
|
|
89
|
+
* dangling ones plus existing values that name the entity's own file.
|
|
90
|
+
* Read-only.
|
|
91
|
+
*/
|
|
92
|
+
export declare function findSourceRepairs(workspaceRoot: string): SourceRepair[];
|
|
93
|
+
export type SourcePathRewrite = Readonly<{
|
|
94
|
+
entityId: string;
|
|
95
|
+
file: string;
|
|
96
|
+
from: string;
|
|
97
|
+
to: string;
|
|
98
|
+
}>;
|
|
99
|
+
export type SourcePathRemoval = Readonly<{
|
|
100
|
+
entityId: string;
|
|
101
|
+
file: string;
|
|
102
|
+
from: string;
|
|
103
|
+
reason: SourceRemovalReason;
|
|
104
|
+
}>;
|
|
105
|
+
export type PlannedSourcePathRepairs = Readonly<{
|
|
106
|
+
rewrites: readonly SourcePathRewrite[];
|
|
107
|
+
removals: readonly SourcePathRemoval[];
|
|
108
|
+
}>;
|
|
109
|
+
export type SourcePathRepairResult = Readonly<{
|
|
110
|
+
rewritten: readonly SourcePathRewrite[];
|
|
111
|
+
removed: readonly SourcePathRemoval[];
|
|
112
|
+
skipped: readonly Readonly<{
|
|
113
|
+
file: string;
|
|
114
|
+
reason: string;
|
|
115
|
+
}>[];
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* The rewrite and removal records a migration plan lists for these repairs.
|
|
119
|
+
* Repairs Kibi cannot edit safely are left out; they need a person.
|
|
120
|
+
*/
|
|
121
|
+
export declare function plannedSourcePathRepairs(repairs: readonly SourceRepair[]): PlannedSourcePathRepairs;
|
|
122
|
+
/**
|
|
123
|
+
* Repair each redundant or dead `source` value, editing only its line: a
|
|
124
|
+
* moved knowledge file is rewritten to its `.kb/` path, and a value naming
|
|
125
|
+
* the entity's own file or nothing Kibi can map is removed. With `planned`,
|
|
126
|
+
* only those repairs are applied, and only while the value still reads as
|
|
127
|
+
* planned. A value that cannot be edited safely is skipped with a reason.
|
|
128
|
+
* Idempotent: a repaired value is not found again.
|
|
129
|
+
*/
|
|
130
|
+
export declare function applySourcePathRepairs(workspaceRoot: string, planned?: PlannedSourcePathRepairs): SourcePathRepairResult;
|
|
131
|
+
//# sourceMapp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