kibi-cli 2.3.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 +39 -11
- 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 +13 -5
- package/dist/cli-operation-metadata.d.ts.map +1 -1
- package/dist/cli-operation-metadata.js +15 -5
- 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-maintenance.d.ts.map +1 -1
- package/dist/cli-register-maintenance.js +7 -0
- 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/merge-driver.d.ts +31 -0
- package/dist/commands/merge-driver.d.ts.map +1 -0
- package/dist/commands/merge-driver.js +268 -0
- 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 +55 -39
- package/dist/operations/bootstrap/discovery.js +1 -1
- 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 +107 -37
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +3 -0
- package/dist/operations/bootstrap/guidance.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance.js +7 -1
- package/dist/operations/bootstrap/intent-claims.d.ts +17 -0
- package/dist/operations/bootstrap/intent-claims.d.ts.map +1 -0
- package/dist/operations/bootstrap/intent-claims.js +103 -0
- 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 +2 -0
- package/dist/operations/bootstrap/presentation.d.ts.map +1 -1
- package/dist/operations/bootstrap/presentation.js +66 -3
- 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/types.d.ts +28 -0
- package/dist/operations/bootstrap/types.d.ts.map +1 -1
- package/dist/operations/bootstrap/types.js +16 -0
- 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/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +4 -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/diagnostic-usage.d.ts +14 -0
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +55 -1
- 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 +203 -20
- 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/bootstrap.d.ts +73 -1
- package/dist/public/operations/specs/bootstrap.d.ts.map +1 -1
- package/dist/public/operations/specs/bootstrap.js +66 -1
- 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/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +3 -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 +52 -11
- package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/dist/public/skills/kibi-usage/SKILL.md +82 -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 +29 -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 +64 -0
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +143 -7
- 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/diagnostic-usage.ts +59 -1
- 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/bootstrap.ts +78 -4
- 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/symbol-repair-plan.ts +3 -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 +52 -11
- package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +12 -1
- package/src/public/skills/kibi-usage/SKILL.md +82 -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 +29 -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 +210 -7
- 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,268 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { isMap, isSeq, parseDocument } from "yaml";
|
|
4
|
+
/**
|
|
5
|
+
* Same serialization options as authored manifest writes, so a merge that
|
|
6
|
+
* changes nothing reproduces the input bytes and edits never refold rows.
|
|
7
|
+
*/
|
|
8
|
+
const AUTHORED_YAML_OPTIONS = { lineWidth: 0 };
|
|
9
|
+
/**
|
|
10
|
+
* Top-level lists Kibi keeps keyed by `id`: `.kb/symbols.yaml` and the
|
|
11
|
+
* `.kb/relationships/*.yaml` shards.
|
|
12
|
+
*/
|
|
13
|
+
const ID_KEYED_LISTS = ["symbols", "relationships"];
|
|
14
|
+
/** Record fields whose values are sets: concurrent additions union instead of conflicting. */
|
|
15
|
+
const SET_FIELDS = new Set(["relationships", "links"]);
|
|
16
|
+
function canonical(value) {
|
|
17
|
+
if (Array.isArray(value))
|
|
18
|
+
return `[${value.map(canonical).join(",")}]`;
|
|
19
|
+
if (value && typeof value === "object") {
|
|
20
|
+
const entries = Object.entries(value)
|
|
21
|
+
.filter(([, entry]) => entry !== undefined)
|
|
22
|
+
.sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0));
|
|
23
|
+
return `{${entries
|
|
24
|
+
.map(([key, entry]) => `${JSON.stringify(key)}:${canonical(entry)}`)
|
|
25
|
+
.join(",")}}`;
|
|
26
|
+
}
|
|
27
|
+
return JSON.stringify(value) ?? "undefined";
|
|
28
|
+
}
|
|
29
|
+
function same(left, right) {
|
|
30
|
+
return canonical(left) === canonical(right);
|
|
31
|
+
}
|
|
32
|
+
function parseManifest(label, content, conflicts) {
|
|
33
|
+
const doc = parseDocument(content);
|
|
34
|
+
if (doc.errors.length > 0) {
|
|
35
|
+
conflicts.push(`${label}: not valid YAML (${doc.errors[0]?.message})`);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const top = doc.toJS() ?? {};
|
|
39
|
+
if (typeof top !== "object" || Array.isArray(top)) {
|
|
40
|
+
conflicts.push(`${label}: top level is not a mapping`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const listKeys = ID_KEYED_LISTS.filter((key) => key in top);
|
|
44
|
+
if (listKeys.length > 1) {
|
|
45
|
+
conflicts.push(`${label}: holds both ${listKeys.join(" and ")}`);
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const listKey = listKeys[0];
|
|
49
|
+
const rest = { ...top };
|
|
50
|
+
if (listKey)
|
|
51
|
+
delete rest[listKey];
|
|
52
|
+
const records = new Map();
|
|
53
|
+
const order = [];
|
|
54
|
+
const seq = listKey ? doc.get(listKey, true) : undefined;
|
|
55
|
+
if (seq === undefined || seq === null) {
|
|
56
|
+
return { doc, listKey, records, order, rest };
|
|
57
|
+
}
|
|
58
|
+
if (!isSeq(seq)) {
|
|
59
|
+
conflicts.push(`${label}: ${listKey} is not a list`);
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
for (const item of seq.items) {
|
|
63
|
+
const id = isMap(item) ? item.get("id") : undefined;
|
|
64
|
+
if (!isMap(item) || typeof id !== "string" || !id) {
|
|
65
|
+
conflicts.push(`${label}: ${listKey} entry without a string id`);
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (records.has(id)) {
|
|
69
|
+
conflicts.push(`${label}: duplicate id ${id}`);
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
records.set(id, { node: item, value: item.toJS(doc) });
|
|
73
|
+
order.push(id);
|
|
74
|
+
}
|
|
75
|
+
return { doc, listKey, records, order, rest };
|
|
76
|
+
}
|
|
77
|
+
/** Three-way merge of a set-valued field: keep ours, drop their removals, add their additions. */
|
|
78
|
+
function mergeSet(base, ours, theirs) {
|
|
79
|
+
const list = (value) => (Array.isArray(value) ? value : []);
|
|
80
|
+
const baseKeys = new Set(list(base).map(canonical));
|
|
81
|
+
const theirKeys = new Set(list(theirs).map(canonical));
|
|
82
|
+
const merged = list(ours).filter((entry) => {
|
|
83
|
+
const key = canonical(entry);
|
|
84
|
+
return !(baseKeys.has(key) && !theirKeys.has(key));
|
|
85
|
+
});
|
|
86
|
+
const mergedKeys = new Set(merged.map(canonical));
|
|
87
|
+
for (const entry of list(theirs)) {
|
|
88
|
+
const key = canonical(entry);
|
|
89
|
+
if (baseKeys.has(key) || mergedKeys.has(key))
|
|
90
|
+
continue;
|
|
91
|
+
merged.push(entry);
|
|
92
|
+
mergedKeys.add(key);
|
|
93
|
+
}
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
function mergeRecord(id, base, ours, theirs, conflicts) {
|
|
97
|
+
const merged = {};
|
|
98
|
+
const keys = [
|
|
99
|
+
...Object.keys(ours),
|
|
100
|
+
...Object.keys(theirs).filter((key) => !(key in ours)),
|
|
101
|
+
];
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
const baseValue = base?.[key];
|
|
104
|
+
const ourValue = ours[key];
|
|
105
|
+
const theirValue = theirs[key];
|
|
106
|
+
let value;
|
|
107
|
+
if (same(ourValue, theirValue) || same(theirValue, baseValue)) {
|
|
108
|
+
value = ourValue;
|
|
109
|
+
}
|
|
110
|
+
else if (same(ourValue, baseValue)) {
|
|
111
|
+
value = theirValue;
|
|
112
|
+
}
|
|
113
|
+
else if (SET_FIELDS.has(key) &&
|
|
114
|
+
[baseValue, ourValue, theirValue].every((entry) => entry === undefined || Array.isArray(entry))) {
|
|
115
|
+
value = mergeSet(baseValue, ourValue, theirValue);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
conflicts.push(`${id}: both sides changed ${key}`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if (value !== undefined)
|
|
122
|
+
merged[key] = value;
|
|
123
|
+
}
|
|
124
|
+
return merged;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Three-way merge of an id-keyed Kibi manifest (`.kb/symbols.yaml` or a
|
|
128
|
+
* `.kb/relationships/*.yaml` shard).
|
|
129
|
+
*
|
|
130
|
+
* Both sides usually append new records at the end of the list, which Git
|
|
131
|
+
* reports as a conflict although the additions are independent. This merge
|
|
132
|
+
* keeps every record either side added, applies edits made on only one
|
|
133
|
+
* side, honors a deletion made on one side when the other left the record
|
|
134
|
+
* unchanged, and unions concurrent relationship and link additions on one
|
|
135
|
+
* symbol. Anything else both sides changed differently is a real conflict
|
|
136
|
+
* and is reported rather than guessed.
|
|
137
|
+
*/
|
|
138
|
+
// implements REQ-cli-kb-merge-driver
|
|
139
|
+
export function mergeKbManifests(baseContent, oursContent, theirsContent) {
|
|
140
|
+
const conflicts = [];
|
|
141
|
+
const base = parseManifest("base", baseContent, conflicts);
|
|
142
|
+
const ours = parseManifest("ours", oursContent, conflicts);
|
|
143
|
+
const theirs = parseManifest("theirs", theirsContent, conflicts);
|
|
144
|
+
if (!base || !ours || !theirs)
|
|
145
|
+
return { status: "conflict", conflicts };
|
|
146
|
+
const listKeys = new Set([base.listKey, ours.listKey, theirs.listKey].filter(Boolean));
|
|
147
|
+
if (listKeys.size > 1) {
|
|
148
|
+
return {
|
|
149
|
+
status: "conflict",
|
|
150
|
+
conflicts: [`sides hold different lists: ${[...listKeys].join(", ")}`],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
const listKey = ours.listKey ?? theirs.listKey;
|
|
154
|
+
if (!same(ours.rest, theirs.rest) && !same(theirs.rest, base.rest)) {
|
|
155
|
+
if (!same(ours.rest, base.rest)) {
|
|
156
|
+
return {
|
|
157
|
+
status: "conflict",
|
|
158
|
+
conflicts: ["both sides changed top-level manifest fields"],
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
for (const key of Object.keys(ours.rest)) {
|
|
162
|
+
if (!(key in theirs.rest))
|
|
163
|
+
ours.doc.delete(key);
|
|
164
|
+
}
|
|
165
|
+
for (const [key, value] of Object.entries(theirs.rest)) {
|
|
166
|
+
ours.doc.set(key, value);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!listKey) {
|
|
170
|
+
return {
|
|
171
|
+
status: "merged",
|
|
172
|
+
content: ours.doc.toString(AUTHORED_YAML_OPTIONS),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
const items = [];
|
|
176
|
+
for (const id of ours.order) {
|
|
177
|
+
const ourRecord = ours.records.get(id);
|
|
178
|
+
if (!ourRecord)
|
|
179
|
+
continue;
|
|
180
|
+
const baseRecord = base.records.get(id);
|
|
181
|
+
const theirRecord = theirs.records.get(id);
|
|
182
|
+
if (!theirRecord) {
|
|
183
|
+
if (!baseRecord)
|
|
184
|
+
items.push(ourRecord.node);
|
|
185
|
+
else if (!same(ourRecord.value, baseRecord.value)) {
|
|
186
|
+
conflicts.push(`${id}: changed on ours but deleted on theirs`);
|
|
187
|
+
}
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
if (same(ourRecord.value, theirRecord.value) ||
|
|
191
|
+
(baseRecord && same(theirRecord.value, baseRecord.value))) {
|
|
192
|
+
items.push(ourRecord.node);
|
|
193
|
+
}
|
|
194
|
+
else if (baseRecord && same(ourRecord.value, baseRecord.value)) {
|
|
195
|
+
items.push(theirRecord.node.clone());
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
const merged = mergeRecord(id, baseRecord?.value, ourRecord.value, theirRecord.value, conflicts);
|
|
199
|
+
items.push(ours.doc.createNode(merged));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
for (const id of theirs.order) {
|
|
203
|
+
if (ours.records.has(id))
|
|
204
|
+
continue;
|
|
205
|
+
const theirRecord = theirs.records.get(id);
|
|
206
|
+
if (!theirRecord)
|
|
207
|
+
continue;
|
|
208
|
+
const baseRecord = base.records.get(id);
|
|
209
|
+
if (!baseRecord)
|
|
210
|
+
items.push(theirRecord.node.clone());
|
|
211
|
+
else if (!same(theirRecord.value, baseRecord.value)) {
|
|
212
|
+
conflicts.push(`${id}: deleted on ours but changed on theirs`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (conflicts.length > 0)
|
|
216
|
+
return { status: "conflict", conflicts };
|
|
217
|
+
const seq = ours.doc.get(listKey, true);
|
|
218
|
+
if (isSeq(seq))
|
|
219
|
+
seq.items = items;
|
|
220
|
+
else
|
|
221
|
+
ours.doc.set(listKey, ours.doc.createNode(items));
|
|
222
|
+
return {
|
|
223
|
+
status: "merged",
|
|
224
|
+
content: ours.doc.toString(AUTHORED_YAML_OPTIONS),
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function readOptional(filePath) {
|
|
228
|
+
try {
|
|
229
|
+
return readFileSync(filePath, "utf8");
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
if (error.code === "ENOENT")
|
|
233
|
+
return "";
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Git merge driver entry point: `kibi merge-driver %O %A %B`.
|
|
239
|
+
*
|
|
240
|
+
* Writes the merged manifest to the current (`%A`) file and exits 0. On a
|
|
241
|
+
* real conflict it prints each one and falls back to Git's textual merge so
|
|
242
|
+
* the file carries ordinary conflict markers, then exits 1 so Git keeps the
|
|
243
|
+
* path unmerged.
|
|
244
|
+
*/
|
|
245
|
+
// implements REQ-cli-kb-merge-driver
|
|
246
|
+
export async function mergeDriverCommand(basePath, currentPath, otherPath) {
|
|
247
|
+
const result = mergeKbManifests(readOptional(basePath), readFileSync(currentPath, "utf8"), readFileSync(otherPath, "utf8"));
|
|
248
|
+
if (result.status === "merged") {
|
|
249
|
+
writeFileSync(currentPath, result.content);
|
|
250
|
+
return { exitCode: 0 };
|
|
251
|
+
}
|
|
252
|
+
for (const conflict of result.conflicts) {
|
|
253
|
+
console.error(`kibi merge-driver: ${conflict}`);
|
|
254
|
+
}
|
|
255
|
+
spawnSync("git", [
|
|
256
|
+
"merge-file",
|
|
257
|
+
"-L",
|
|
258
|
+
"ours",
|
|
259
|
+
"-L",
|
|
260
|
+
"base",
|
|
261
|
+
"-L",
|
|
262
|
+
"theirs",
|
|
263
|
+
currentPath,
|
|
264
|
+
basePath,
|
|
265
|
+
otherPath,
|
|
266
|
+
], { stdio: "inherit" });
|
|
267
|
+
return { exitCode: 1 };
|
|
268
|
+
}
|
|
@@ -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":"AAiEA,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,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qFAAqF;IACrF,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAgKD,wBAAgB,mBAAmB,CACjC,gBAAgB,EAAE,OAAO,EACzB,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,MAAM,CAUR;AAsXD,wBAAgB,+BAA+B,IAAI;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAKtE;AAGD,wBAAsB,cAAc,CAClC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAuS/B"}
|