kibi-cli 0.14.0 → 0.17.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/bin/kibi +3 -1
- package/dist/cli-command.d.ts +5 -0
- package/dist/cli-command.d.ts.map +1 -0
- package/dist/cli-command.js +9 -0
- package/dist/cli-errors.d.ts +13 -0
- package/dist/cli-errors.d.ts.map +1 -0
- package/dist/cli-errors.js +26 -0
- package/dist/cli-input.d.ts +6 -0
- package/dist/cli-input.d.ts.map +1 -0
- package/dist/cli-input.js +54 -0
- package/dist/cli-json-command.d.ts +14 -0
- package/dist/cli-json-command.d.ts.map +1 -0
- package/dist/cli-json-command.js +96 -0
- package/dist/cli-protocol.d.ts +12 -0
- package/dist/cli-protocol.d.ts.map +1 -0
- package/dist/cli-protocol.js +37 -0
- package/dist/cli-register-foundation.d.ts +3 -0
- package/dist/cli-register-foundation.d.ts.map +1 -0
- package/dist/cli-register-foundation.js +90 -0
- package/dist/cli-register-maintenance.d.ts +3 -0
- package/dist/cli-register-maintenance.d.ts.map +1 -0
- package/dist/cli-register-maintenance.js +36 -0
- package/dist/cli-register-reporting.d.ts +3 -0
- package/dist/cli-register-reporting.d.ts.map +1 -0
- package/dist/cli-register-reporting.js +101 -0
- package/dist/cli-register-skills.d.ts +3 -0
- package/dist/cli-register-skills.d.ts.map +1 -0
- package/dist/cli-register-skills.js +71 -0
- package/dist/cli-validate.d.ts +18 -0
- package/dist/cli-validate.d.ts.map +1 -0
- package/dist/cli-validate.js +45 -0
- package/dist/cli.d.ts +4 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +48 -211
- package/dist/commands/aggregated-checks.d.ts +1 -1
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +28 -34
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +53 -95
- package/dist/commands/coverage.d.ts.map +1 -1
- package/dist/commands/coverage.js +12 -17
- package/dist/commands/discovery-shared.d.ts +2 -1
- package/dist/commands/discovery-shared.d.ts.map +1 -1
- package/dist/commands/discovery-shared.js +6 -18
- package/dist/commands/gaps.d.ts.map +1 -1
- package/dist/commands/gaps.js +15 -19
- package/dist/commands/graph.d.ts.map +1 -1
- package/dist/commands/graph.js +15 -21
- package/dist/commands/query.d.ts +7 -7
- package/dist/commands/query.d.ts.map +1 -1
- package/dist/commands/query.js +98 -204
- package/dist/commands/search.d.ts +4 -4
- package/dist/commands/search.d.ts.map +1 -1
- package/dist/commands/search.js +14 -27
- package/dist/commands/status.d.ts +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +6 -7
- package/dist/commands/sync/manifest.d.ts +13 -2
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +31 -22
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +39 -1
- package/dist/extractors/markdown.d.ts +22 -2
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +50 -1
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +11 -1
- package/dist/logic/ir.d.ts +112 -0
- package/dist/logic/ir.d.ts.map +1 -0
- package/dist/logic/ir.js +729 -0
- package/dist/operations/autopilot/activation.d.ts +4 -0
- package/dist/operations/autopilot/activation.d.ts.map +1 -0
- package/dist/operations/autopilot/activation.js +130 -0
- package/dist/operations/autopilot/candidate-helpers.d.ts +13 -0
- package/dist/operations/autopilot/candidate-helpers.d.ts.map +1 -0
- package/dist/operations/autopilot/candidate-helpers.js +55 -0
- package/dist/operations/autopilot/candidates.d.ts +4 -0
- package/dist/operations/autopilot/candidates.d.ts.map +1 -0
- package/dist/operations/autopilot/candidates.js +114 -0
- package/dist/operations/autopilot/discovery-evidence.d.ts +10 -0
- package/dist/operations/autopilot/discovery-evidence.d.ts.map +1 -0
- package/dist/operations/autopilot/discovery-evidence.js +158 -0
- package/dist/operations/autopilot/discovery.d.ts +4 -0
- package/dist/operations/autopilot/discovery.d.ts.map +1 -0
- package/dist/operations/autopilot/discovery.js +100 -0
- package/dist/operations/autopilot/generate.d.ts +8 -0
- package/dist/operations/autopilot/generate.d.ts.map +1 -0
- package/dist/operations/autopilot/generate.js +112 -0
- package/dist/operations/autopilot/guidance-actions.d.ts +3 -0
- package/dist/operations/autopilot/guidance-actions.d.ts.map +1 -0
- package/dist/operations/autopilot/guidance-actions.js +79 -0
- package/dist/operations/autopilot/guidance.d.ts +14 -0
- package/dist/operations/autopilot/guidance.d.ts.map +1 -0
- package/dist/operations/autopilot/guidance.js +124 -0
- package/dist/operations/autopilot/markdown-candidates.d.ts +7 -0
- package/dist/operations/autopilot/markdown-candidates.d.ts.map +1 -0
- package/dist/operations/autopilot/markdown-candidates.js +134 -0
- package/dist/operations/autopilot/presentation.d.ts +13 -0
- package/dist/operations/autopilot/presentation.d.ts.map +1 -0
- package/dist/operations/autopilot/presentation.js +91 -0
- package/dist/operations/autopilot/requirement-claims.d.ts +3 -0
- package/dist/operations/autopilot/requirement-claims.d.ts.map +1 -0
- package/dist/operations/autopilot/requirement-claims.js +48 -0
- package/dist/operations/autopilot/types.d.ts +117 -0
- package/dist/operations/autopilot/types.d.ts.map +1 -0
- package/dist/operations/autopilot/types.js +8 -0
- package/dist/operations/modeling/logic-modeling.d.ts +22 -0
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
- package/dist/operations/modeling/logic-modeling.js +111 -0
- package/dist/operations/modeling/model-requirement.d.ts +10 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -0
- package/dist/operations/modeling/model-requirement.js +164 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts +6 -0
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-applyplan.js +117 -0
- package/dist/operations/modeling/predicate-catalog-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-1.js +200 -0
- package/dist/operations/modeling/predicate-catalog-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-2.js +197 -0
- package/dist/operations/modeling/predicate-catalog-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-3.js +193 -0
- package/dist/operations/modeling/predicate-catalog-4.d.ts +3 -0
- package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog-4.js +149 -0
- package/dist/operations/modeling/predicate-catalog.d.ts +5 -0
- package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-catalog.js +29 -0
- package/dist/operations/modeling/predicate-inference-1.d.ts +16 -0
- package/dist/operations/modeling/predicate-inference-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-1.js +161 -0
- package/dist/operations/modeling/predicate-inference-2.d.ts +19 -0
- package/dist/operations/modeling/predicate-inference-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-2.js +169 -0
- package/dist/operations/modeling/predicate-inference-3.d.ts +15 -0
- package/dist/operations/modeling/predicate-inference-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference-3.js +163 -0
- package/dist/operations/modeling/predicate-inference.d.ts +5 -0
- package/dist/operations/modeling/predicate-inference.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-inference.js +163 -0
- package/dist/operations/modeling/predicate-loader.d.ts +10 -0
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-loader.js +94 -0
- package/dist/operations/modeling/predicate-ranker.d.ts +3 -0
- package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-ranker.js +62 -0
- package/dist/operations/modeling/predicate-score-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-1.js +121 -0
- package/dist/operations/modeling/predicate-score-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-2.js +122 -0
- package/dist/operations/modeling/predicate-score-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-score-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-score-3.js +54 -0
- package/dist/operations/modeling/predicate-types.d.ts +64 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-types.js +1 -0
- package/dist/operations/modeling/predicate-usage-hints-1.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-1.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-1.js +211 -0
- package/dist/operations/modeling/predicate-usage-hints-2.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-2.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-2.js +209 -0
- package/dist/operations/modeling/predicate-usage-hints-3.d.ts +3 -0
- package/dist/operations/modeling/predicate-usage-hints-3.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-usage-hints-3.js +45 -0
- package/dist/operations/modeling/predicate-utils.d.ts +23 -0
- package/dist/operations/modeling/predicate-utils.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-utils.js +187 -0
- package/dist/operations/modeling/requirement-applyplan.d.ts +4 -0
- package/dist/operations/modeling/requirement-applyplan.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-applyplan.js +44 -0
- package/dist/operations/modeling/requirement-heuristics.d.ts +4 -0
- package/dist/operations/modeling/requirement-heuristics.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-heuristics.js +114 -0
- package/dist/operations/modeling/requirement-modeler.d.ts +8 -0
- package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-modeler.js +70 -0
- package/dist/operations/modeling/requirement-types.d.ts +61 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-types.js +1 -0
- package/dist/operations/modeling/requirement-utils.d.ts +10 -0
- package/dist/operations/modeling/requirement-utils.d.ts.map +1 -0
- package/dist/operations/modeling/requirement-utils.js +65 -0
- package/dist/operations/modeling/suggest-predicates.d.ts +6 -0
- package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -0
- package/dist/operations/modeling/suggest-predicates.js +64 -0
- package/dist/operations/mutation/audit.d.ts +6 -0
- package/dist/operations/mutation/audit.d.ts.map +1 -0
- package/dist/operations/mutation/audit.js +22 -0
- package/dist/operations/mutation/contradictions.d.ts +10 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -0
- package/dist/operations/mutation/contradictions.js +40 -0
- package/dist/operations/mutation/delete.d.ts +5 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -0
- package/dist/operations/mutation/delete.js +67 -0
- package/dist/operations/mutation/relationships.d.ts +17 -0
- package/dist/operations/mutation/relationships.d.ts.map +1 -0
- package/dist/operations/mutation/relationships.js +142 -0
- package/dist/operations/mutation/save.d.ts +4 -0
- package/dist/operations/mutation/save.d.ts.map +1 -0
- package/dist/operations/mutation/save.js +14 -0
- package/dist/operations/mutation/serialization.d.ts +5 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -0
- package/dist/operations/mutation/serialization.js +88 -0
- package/dist/operations/mutation/strict-fact.d.ts +4 -0
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -0
- package/dist/operations/mutation/strict-fact.js +132 -0
- package/dist/operations/mutation/symbol-granularity.d.ts +4 -0
- package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -0
- package/dist/operations/mutation/symbol-granularity.js +109 -0
- package/dist/operations/mutation/symbol-refresh.d.ts +10 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -0
- package/dist/operations/mutation/symbol-refresh.js +105 -0
- package/dist/operations/mutation/types.d.ts +43 -0
- package/dist/operations/mutation/types.d.ts.map +1 -0
- package/dist/operations/mutation/types.js +1 -0
- package/dist/operations/mutation/upsert.d.ts +5 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -0
- package/dist/operations/mutation/upsert.js +103 -0
- package/dist/operations/mutation/validate-upsert.d.ts +5 -0
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -0
- package/dist/operations/mutation/validate-upsert.js +50 -0
- package/dist/operations/mutation/validation.d.ts +5 -0
- package/dist/operations/mutation/validation.d.ts.map +1 -0
- package/dist/operations/mutation/validation.js +107 -0
- package/dist/operations/mutation/warnings.d.ts +4 -0
- package/dist/operations/mutation/warnings.d.ts.map +1 -0
- package/dist/operations/mutation/warnings.js +17 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts +5 -0
- package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/analysis-receipt.js +120 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts +5 -0
- package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/analyze-prose.js +693 -0
- package/dist/operations/semantic-advisor/clauses.d.ts +10 -0
- package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/clauses.js +43 -0
- package/dist/operations/semantic-advisor/observation-plan.d.ts +3 -0
- package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/observation-plan.js +31 -0
- package/dist/operations/semantic-advisor/predicate-rule.d.ts +14 -0
- package/dist/operations/semantic-advisor/predicate-rule.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rule.js +22 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +79 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-core.js +140 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +83 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-policy.js +150 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +48 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +102 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +71 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/predicate-rules-product.js +133 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts +29 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/prose-coverage-evaluator.js +54 -0
- package/dist/operations/semantic-advisor/shared.d.ts +19 -0
- package/dist/operations/semantic-advisor/shared.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/shared.js +209 -0
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts +4 -0
- package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/strict-count-rules.js +62 -0
- package/dist/operations/semantic-advisor/strict-rules.d.ts +4 -0
- package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/strict-rules.js +106 -0
- package/dist/operations/semantic-advisor/types.d.ts +195 -0
- package/dist/operations/semantic-advisor/types.d.ts.map +1 -0
- package/dist/operations/semantic-advisor/types.js +1 -0
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +20 -3
- package/dist/prolog.d.ts +5 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +89 -32
- package/dist/public/impact/diagnostics.d.ts.map +1 -1
- package/dist/public/impact/diagnostics.js +8 -4
- package/dist/public/impact/full-kb-quality.d.ts +1 -1
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +34 -1
- package/dist/public/impact/requirement-quality.d.ts.map +1 -1
- package/dist/public/impact/requirement-quality.js +6 -23
- package/dist/public/operations/catalog.d.ts +986 -0
- package/dist/public/operations/catalog.d.ts.map +1 -0
- package/dist/public/operations/catalog.js +42 -0
- package/dist/public/operations/check-executor.d.ts +21 -0
- package/dist/public/operations/check-executor.d.ts.map +1 -0
- package/dist/public/operations/check-executor.js +111 -0
- package/dist/public/operations/check-format-shared.d.ts +36 -0
- package/dist/public/operations/check-format-shared.d.ts.map +1 -0
- package/dist/public/operations/check-format-shared.js +107 -0
- package/dist/public/operations/check-helpers.d.ts +10 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -0
- package/dist/public/operations/check-helpers.js +107 -0
- package/dist/public/operations/discovery-entities.d.ts +14 -0
- package/dist/public/operations/discovery-entities.d.ts.map +1 -0
- package/dist/public/operations/discovery-entities.js +91 -0
- package/dist/public/operations/discovery-executors.d.ts +39 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -0
- package/dist/public/operations/discovery-executors.js +101 -0
- package/dist/public/operations/index.d.ts +21 -0
- package/dist/public/operations/index.d.ts.map +1 -0
- package/dist/public/operations/index.js +19 -0
- package/dist/public/operations/node-ports.d.ts +15 -0
- package/dist/public/operations/node-ports.d.ts.map +1 -0
- package/dist/public/operations/node-ports.js +57 -0
- package/dist/public/operations/prolog-json.d.ts +5 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -0
- package/dist/public/operations/prolog-json.js +44 -0
- package/dist/public/operations/runtime-types.d.ts +69 -0
- package/dist/public/operations/runtime-types.d.ts.map +1 -0
- package/dist/public/operations/runtime-types.js +17 -0
- package/dist/public/operations/specs/autopilot.d.ts +82 -0
- package/dist/public/operations/specs/autopilot.d.ts.map +1 -0
- package/dist/public/operations/specs/autopilot.js +72 -0
- package/dist/public/operations/specs/check.d.ts +51 -0
- package/dist/public/operations/specs/check.d.ts.map +1 -0
- package/dist/public/operations/specs/check.js +65 -0
- package/dist/public/operations/specs/discovery.d.ts +94 -0
- package/dist/public/operations/specs/discovery.d.ts.map +1 -0
- package/dist/public/operations/specs/discovery.js +98 -0
- package/dist/public/operations/specs/modeling.d.ts +142 -0
- package/dist/public/operations/specs/modeling.d.ts.map +1 -0
- package/dist/public/operations/specs/modeling.js +133 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts +268 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -0
- package/dist/public/operations/specs/mutation-schemas.js +294 -0
- package/dist/public/operations/specs/mutation.d.ts +56 -0
- package/dist/public/operations/specs/mutation.d.ts.map +1 -0
- package/dist/public/operations/specs/mutation.js +44 -0
- package/dist/public/operations/specs/reporting.d.ts +185 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -0
- package/dist/public/operations/specs/reporting.js +158 -0
- package/dist/public/operations/specs/semantic.d.ts +81 -0
- package/dist/public/operations/specs/semantic.d.ts.map +1 -0
- package/dist/public/operations/specs/semantic.js +137 -0
- package/dist/public/operations/specs/skills.d.ts +70 -0
- package/dist/public/operations/specs/skills.d.ts.map +1 -0
- package/dist/public/operations/specs/skills.js +107 -0
- package/dist/public/operations/specs/sparql.d.ts +39 -0
- package/dist/public/operations/specs/sparql.d.ts.map +1 -0
- package/dist/public/operations/specs/sparql.js +121 -0
- package/dist/public/operations/specs/upsert.d.ts +291 -0
- package/dist/public/operations/specs/upsert.d.ts.map +1 -0
- package/dist/public/operations/specs/upsert.js +27 -0
- package/dist/public/operations/types.d.ts +24 -0
- package/dist/public/operations/types.d.ts.map +1 -0
- package/dist/public/operations/types.js +1 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +317 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skill-system/errors.d.ts +19 -0
- package/dist/public/skill-system/errors.d.ts.map +1 -0
- package/dist/public/skill-system/errors.js +36 -0
- package/dist/public/skill-system/loader.d.ts +9 -0
- package/dist/public/skill-system/loader.d.ts.map +1 -0
- package/dist/public/skill-system/loader.js +76 -0
- package/dist/public/skill-system/paths.d.ts +6 -0
- package/dist/public/skill-system/paths.d.ts.map +1 -0
- package/dist/public/skill-system/paths.js +25 -0
- package/dist/public/skill-system/types.d.ts +15 -0
- package/dist/public/skill-system/types.d.ts.map +1 -0
- package/dist/public/skill-system/types.js +1 -0
- package/dist/public/skill-system/validation.d.ts +10 -0
- package/dist/public/skill-system/validation.d.ts.map +1 -0
- package/dist/public/skill-system/validation.js +119 -0
- package/dist/public/skills/init-kibi/SKILL.md +62 -0
- package/dist/public/skills/kibi-freshness/SKILL.md +44 -0
- package/dist/public/skills/kibi-traceability/SKILL.md +54 -0
- package/dist/public/skills/kibi-usage/SKILL.md +145 -99
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +112 -0
- package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +41 -3
- package/dist/public/skills.d.ts +4 -41
- package/dist/public/skills.d.ts.map +1 -1
- package/dist/public/skills.js +3 -270
- package/dist/public/symbol-granularity.d.ts +9 -0
- package/dist/public/symbol-granularity.d.ts.map +1 -1
- package/dist/public/symbol-granularity.js +16 -0
- package/dist/runtime/cli-runtime.d.ts +3 -0
- package/dist/runtime/cli-runtime.d.ts.map +1 -0
- package/dist/runtime/cli-runtime.js +96 -0
- package/dist/schemas/entity.schema.json +329 -3
- package/dist/traceability/staged-diagnostics.d.ts +2 -2
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-diagnostics.js +17 -10
- package/dist/traceability/staged-impact-contract.js +1 -1
- package/dist/traceability/staged-symbols-manifest.d.ts +1 -0
- package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
- package/dist/traceability/staged-symbols-manifest.js +53 -24
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +17 -1
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +47 -1
- package/dist/types/entities.d.ts +3 -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/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.js +24 -0
- package/dist/utils/schema-version.d.ts +1 -1
- package/dist/utils/schema-version.js +1 -1
- package/package.json +60 -2
- package/src/public/impact/diagnostics.ts +18 -11
- package/src/public/impact/full-kb-quality.ts +30 -3
- package/src/public/impact/requirement-quality.ts +6 -26
- package/src/public/operations/catalog.ts +60 -0
- package/src/public/operations/check-executor.ts +185 -0
- package/src/public/operations/check-format-shared.ts +178 -0
- package/src/public/operations/check-helpers.ts +141 -0
- package/src/public/operations/discovery-entities.ts +122 -0
- package/src/public/operations/discovery-executors.ts +176 -0
- package/src/public/operations/index.ts +20 -0
- package/src/public/operations/node-ports.ts +78 -0
- package/src/public/operations/prolog-json.ts +71 -0
- package/src/public/operations/runtime-types.ts +106 -0
- package/src/public/operations/specs/autopilot.ts +98 -0
- package/src/public/operations/specs/check.ts +75 -0
- package/src/public/operations/specs/discovery.ts +126 -0
- package/src/public/operations/specs/modeling.ts +174 -0
- package/src/public/operations/specs/mutation-schemas.ts +326 -0
- package/src/public/operations/specs/mutation.ts +58 -0
- package/src/public/operations/specs/reporting.ts +249 -0
- package/src/public/operations/specs/semantic.ts +174 -0
- package/src/public/operations/specs/skills.ts +142 -0
- package/src/public/operations/specs/sparql.ts +149 -0
- package/src/public/operations/specs/upsert.ts +40 -0
- package/src/public/operations/types.ts +57 -0
- package/src/public/schemas/entity.ts +324 -1
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skill-system/errors.ts +38 -0
- package/src/public/skill-system/loader.ts +108 -0
- package/src/public/skill-system/paths.ts +27 -0
- package/src/public/skill-system/types.ts +14 -0
- package/src/public/skill-system/validation.ts +175 -0
- package/src/public/skills/init-kibi/SKILL.md +62 -0
- package/src/public/skills/kibi-freshness/SKILL.md +44 -0
- package/src/public/skills/kibi-traceability/SKILL.md +54 -0
- package/src/public/skills/kibi-usage/SKILL.md +145 -99
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +112 -0
- package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +41 -3
- package/src/public/skills.ts +18 -427
- package/src/public/symbol-granularity.ts +25 -0
- package/src/schemas/entity.schema.json +329 -3
- package/src/schemas/relationship.schema.json +1 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# UI / Visual Requirement Modeling
|
|
2
|
+
|
|
3
|
+
Optional, per-project lane for recording what the screen should look like so UI edits cannot
|
|
4
|
+
silently drift from the spec. Non-UI projects skip it entirely; no check rule requires it.
|
|
5
|
+
|
|
6
|
+
## Three layers
|
|
7
|
+
|
|
8
|
+
1. **Prose `req`** — the full on-screen description lives in the requirement body as the
|
|
9
|
+
searchable anchor agents discover with `kb_search` / `kb_query`.
|
|
10
|
+
2. **Strict facts** — checkable visual invariants as `fact_kind: subject` (`subject_key`,
|
|
11
|
+
linked `constrains`) plus `fact_kind: property_value` (`property_key`, `operator`, typed
|
|
12
|
+
`value_*`, linked `requires_property`). Incompatible values on the same subject/property
|
|
13
|
+
from two current requirements are rejected on write unless `supersedes`.
|
|
14
|
+
3. **Relational predicates** — ground `fact_kind: predicate` linked with `requires_predicate`.
|
|
15
|
+
The built-in `visual_layout_rule(subject, relation, target)` covers "X must remain visually
|
|
16
|
+
aligned with Y" (relation `aligned_with`). Other relational layout claims need a
|
|
17
|
+
project-local `predicate_schema` when the task authorizes ontology extension.
|
|
18
|
+
|
|
19
|
+
Kibi enforces stated facts and links, not pixels. Freeform spatial prose is stored and
|
|
20
|
+
searchable but is not machine-checked.
|
|
21
|
+
|
|
22
|
+
## Button position
|
|
23
|
+
|
|
24
|
+
```yaml
|
|
25
|
+
id: FACT-UI-SUBMIT-REGION
|
|
26
|
+
fact_kind: subject
|
|
27
|
+
subject_key: settings.screen.submit_button
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
id: FACT-UI-SUBMIT-POSITION
|
|
32
|
+
fact_kind: property_value
|
|
33
|
+
subject_key: settings.screen.submit_button
|
|
34
|
+
property_key: position
|
|
35
|
+
operator: eq
|
|
36
|
+
value_type: string
|
|
37
|
+
value_string: bottom_right
|
|
38
|
+
canonical_key: settings.screen.submit_button.position.eq.bottom_right
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Link both facts from the requirement:
|
|
42
|
+
|
|
43
|
+
```yaml
|
|
44
|
+
id: REQ-UI-SETTINGS
|
|
45
|
+
relationships:
|
|
46
|
+
- type: constrains
|
|
47
|
+
from: REQ-UI-SETTINGS
|
|
48
|
+
to: FACT-UI-SUBMIT-REGION
|
|
49
|
+
- type: requires_property
|
|
50
|
+
from: REQ-UI-SETTINGS
|
|
51
|
+
to: FACT-UI-SUBMIT-POSITION
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A later requirement writing `position: top_left` on the same subject is rejected on write.
|
|
55
|
+
|
|
56
|
+
## Header item order
|
|
57
|
+
|
|
58
|
+
Use one indexed `property_key` per slot against the same subject region:
|
|
59
|
+
`nav_order_1: home`, `nav_order_2: search`, `nav_order_3: profile`, each as a separate
|
|
60
|
+
`property_value` fact linked with `requires_property`. This makes each slot independently
|
|
61
|
+
contradiction-checkable.
|
|
62
|
+
|
|
63
|
+
## Relational alignment
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
id: FACT-UI-NAV-ALIGN
|
|
67
|
+
fact_kind: predicate
|
|
68
|
+
predicate_name: visual_layout_rule
|
|
69
|
+
predicate_args: [navigation_rail, aligned_with, header]
|
|
70
|
+
polarity: assert
|
|
71
|
+
canonical_key: visual_layout_rule(navigation_rail,aligned_with,header)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Link with `requires_predicate`. An `assert`/`deny` pair over the same predicate namespace,
|
|
75
|
+
name, and ordered arguments is a blocking `domain-contradictions` conflict.
|
|
76
|
+
|
|
77
|
+
## UI component traceability
|
|
78
|
+
|
|
79
|
+
Model the component as a `symbol` with `sourceFile` and `symbol_role: behavioral`, linked
|
|
80
|
+
`implements` to the requirement, so component edits surface the visual spec in impact
|
|
81
|
+
diagnostics (`symbol_semantic_review_needed`).
|
|
82
|
+
|
|
83
|
+
## Workflow
|
|
84
|
+
|
|
85
|
+
1. `kb_semantic_advisor` on the full description; audit or supply `clauses`.
|
|
86
|
+
2. Relational clauses: `kb_suggest_predicates`, apply the predicate plan and
|
|
87
|
+
`requires_predicate`.
|
|
88
|
+
3. Scalar placement/alignment/order clauses: `kb_model_requirement`, apply the strict
|
|
89
|
+
subject/property plan and `constrains` / `requires_property`.
|
|
90
|
+
4. Preserve `claim_key` / `claim_text`; merge every key into the requirement
|
|
91
|
+
`logic_claims` manifest.
|
|
92
|
+
5. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`.
|
|
93
|
+
6. `kb_check` with `logic-coverage`, `predicate-verifiability`, `domain-contradictions`,
|
|
94
|
+
then a final unfiltered `kb_check`.
|
|
95
|
+
|
|
96
|
+
Non-UI projects: declare `has_ui: false` during bootstrap and no UI entities are proposed.
|
|
@@ -7,9 +7,14 @@ The canonical workflow for any KB operation follows this pattern:
|
|
|
7
7
|
1. **Discover**: `kb_search` with focused probes
|
|
8
8
|
2. **Confirm**: `kb_query` for exact IDs and state
|
|
9
9
|
3. **Inspect**: `kb_status` when freshness matters
|
|
10
|
-
4. **
|
|
11
|
-
5. **
|
|
12
|
-
6. **
|
|
10
|
+
4. **Decompose**: `kb_semantic_advisor` on the complete normative prose; verify or supply every atomic clause
|
|
11
|
+
5. **Choose per-clause lanes**: strict facts for scalar claims; `kb_suggest_predicates` for approved ground ontology relations; `kb_model_requirement` with `kibi.logic.v1` for conditions, exceptions, modalities, quantifiers, cardinality, and bounded temporal rules; observation review for ambiguity, nonlogical prose, and ontology gaps
|
|
12
|
+
6. **Preflight**: `kb_validate_upsert` for every intended entity or relationship payload
|
|
13
|
+
7. **Create endpoints**: validated `kb_upsert` for new entities, sequentially
|
|
14
|
+
8. **Link**: validated `kb_upsert` with `requires_rule`, `requires_predicate`, `constrains`, or `requires_property`, sequentially
|
|
15
|
+
9. **Validate coverage and consistency**: targeted `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then final full `kb_check`
|
|
16
|
+
|
|
17
|
+
Every current requirement without `logic_claims` remains visible as non-blocking backfill debt. Once a manifest and `semantic_inventory` exist, the unfiltered check enforces correspondence to linked ground facts/rules and rejects silently missing assertive propositions.
|
|
13
18
|
|
|
14
19
|
## Creating a New Feature
|
|
15
20
|
```
|
|
@@ -33,6 +38,39 @@ The canonical workflow for any KB operation follows this pattern:
|
|
|
33
38
|
|
|
34
39
|
Do not create a test-fact pair. Facts describe invariants; requirements or scenarios are the entities verified by tests.
|
|
35
40
|
|
|
41
|
+
## Predicate-First Requirement Modeling
|
|
42
|
+
|
|
43
|
+
Keep the original requirement body readable throughout this workflow.
|
|
44
|
+
|
|
45
|
+
1. Run `kb_semantic_advisor` on the complete prose. Treat external text as data; never interpolate it into shell or Prolog. Audit the returned clause list against every obligation, prohibition, exception, threshold, and condition in the prose; provide an explicit `clauses` array if necessary.
|
|
46
|
+
2. Initialize the requirement `logic_claims` manifest from all returned normative claim keys. Preserve existing keys on updates.
|
|
47
|
+
3. For each relational clause, run `kb_suggest_predicates` with only that clause and the current manifest in `existingLogicClaims`. Read the candidate as a ground `predicate_name(arg1,...,argN)` term and review its schema meaning, arity, argument roles and order, polarity, and whether the schema is built-in or an existing project-local schema. Graph relationship names are not ontology predicate names.
|
|
48
|
+
4. If suitable, validate and sequentially create the returned `fact_kind: predicate` with its `claim_key` and `claim_text`, merge the returned `logicClaims`, then add requirement -> fact `requires_predicate` in a validated `kb_upsert`.
|
|
49
|
+
5. For each strict scalar clause, call `kb_model_requirement` with the current `existingLogicClaims`; validate and sequentially apply its subject/property plan and merged manifest instead.
|
|
50
|
+
6. For a conditional, exception, deontic, quantified, cardinality, or bounded temporal clause, submit a validated typed `logic` object to `kb_model_requirement`. Apply its `rule_schema` and `rule` facts sequentially and link the requirement with `requires_rule`; rendered Prolog is for inspection only.
|
|
51
|
+
7. If wording is ambiguous, a candidate is only a lexical false positive, or no schema/IR interpretation fits, create the advised observation review artifact and apply its returned `relates_to` review anchor when present; report that claim key as unresolved. Use `review:ambiguity` for unresolved interpretation, `review:keyword-false-positive` for a vocabulary match that is not a domain assertion, and `review:ontology-gap` only for a true catalog gap. Define a new `predicate_schema` only when the task explicitly authorizes ontology extension and provides a stable signature.
|
|
52
|
+
8. Read back the requirement, proposition ledger, and all facts. Confirm every manifest key occurs on exactly one intended ground fact/rule, no punctuation variant minted a second claim, and no two claim keys encode the same logical term. Exact query output may represent repeated relationship types as arrays, so inspect every target. Then run `kb_check` with `rule-safety`, `rule-verifiability`, `semantic-completeness`, `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`. Finish with an unfiltered `kb_check`.
|
|
53
|
+
|
|
54
|
+
Do not treat the manifest itself as proof of grounding. The advisor keeps readiness partial while there are fewer logical edge slots than normative claims; final readback and `logic-coverage` bind those slots to exact claim keys and ground terms.
|
|
55
|
+
|
|
56
|
+
Examples: built-in permission and deny claims use the suggested `permission_rule`; a project-local `commit_action` is valid only after its schema exists; session timeout is strict scalar; “better support” is ambiguous; `publishes_event` for publishing an article is a false positive; annotation anchoring without a fitting schema is an ontology gap. The authoritative payloads are in `resources/fact-lanes.md`.
|
|
57
|
+
|
|
58
|
+
On resume after interruption, repeat `kb_query` for exact endpoints and apply only missing validated writes. Keep `kb_upsert` concurrency at one.
|
|
59
|
+
|
|
60
|
+
## UI / Visual Requirement Modeling
|
|
61
|
+
|
|
62
|
+
Optional per-project workflow for recording what the screen should look like. Non-UI projects skip this lane entirely.
|
|
63
|
+
|
|
64
|
+
1. Create a prose `req` holding the full visual description; it is the searchable anchor agents discover before touching a UI file.
|
|
65
|
+
2. Run `kb_semantic_advisor` on the description; audit or supply `clauses`.
|
|
66
|
+
3. For relational layout clauses ("X must remain visually aligned with Y"), call `kb_suggest_predicates`, apply the returned `fact_kind: predicate` plan with `predicate_name: visual_layout_rule` and `requires_predicate`.
|
|
67
|
+
4. For scalar placement, alignment, and ordering clauses, call `kb_model_requirement` and apply strict `fact_kind: subject` / `fact_kind: property_value` facts linked with `constrains` / `requires_property`. Model header order as indexed property keys (`nav_order_1`, `nav_order_2`, ...) against one subject region.
|
|
68
|
+
5. Preserve `claim_key` / `claim_text` on every ground fact and merge every key into the requirement `logic_claims` manifest.
|
|
69
|
+
6. Model UI components as `symbol` entities with `sourceFile` and `symbol_role: behavioral`, linked `implements` to the requirement.
|
|
70
|
+
7. `kb_validate_upsert`, create endpoints first, then sequential `kb_upsert`. Run `kb_check` with `logic-coverage`, `predicate-verifiability`, and `domain-contradictions`, then a final unfiltered `kb_check`.
|
|
71
|
+
|
|
72
|
+
Incompatible values on the same subject/property from two current requirements are rejected on write; change an intentional value via a replacement requirement linked with `supersedes`. Full payloads are in `resources/ui-requirements.md`.
|
|
73
|
+
|
|
36
74
|
## Fixing a Traceability Gap
|
|
37
75
|
```
|
|
38
76
|
1. kb_query --sourceFile <code-file> to find linked entities
|
package/dist/public/skills.d.ts
CHANGED
|
@@ -1,42 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
name: string;
|
|
6
|
-
description: string;
|
|
7
|
-
version: string;
|
|
8
|
-
kibiCompatibility: string;
|
|
9
|
-
tags?: string[];
|
|
10
|
-
resources?: string[];
|
|
11
|
-
}
|
|
12
|
-
export interface SkillBundle {
|
|
13
|
-
manifest: SkillManifest;
|
|
14
|
-
body: string;
|
|
15
|
-
rootDir: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class SkillNotFoundError extends Error {
|
|
18
|
-
constructor(id: string);
|
|
19
|
-
}
|
|
20
|
-
export declare class SkillResourceNotFoundError extends Error {
|
|
21
|
-
constructor(id: string, resourcePath: string);
|
|
22
|
-
}
|
|
23
|
-
export declare class SkillResourceOutOfBoundsError extends Error {
|
|
24
|
-
constructor(id: string, resourcePath: string);
|
|
25
|
-
}
|
|
26
|
-
export declare class SkillValidationError extends Error {
|
|
27
|
-
readonly field: string;
|
|
28
|
-
constructor(field: string, message: string);
|
|
29
|
-
}
|
|
30
|
-
export declare class SkillOversizeError extends Error {
|
|
31
|
-
readonly maxBytes: number;
|
|
32
|
-
readonly actualBytes: number;
|
|
33
|
-
constructor(pathLike: string, maxBytes: number, actualBytes: number);
|
|
34
|
-
}
|
|
35
|
-
export declare function listBundledSkills(): SkillManifest[];
|
|
36
|
-
export declare function loadBundledSkill(id: string): SkillBundle;
|
|
37
|
-
export declare function readBundledSkillResource(id: string, resourcePath: string): string;
|
|
38
|
-
export declare function validateSkillBundle(pathLike: string): {
|
|
39
|
-
valid: boolean;
|
|
40
|
-
errors: SkillValidationError[];
|
|
41
|
-
};
|
|
1
|
+
export { SkillNotFoundError, SkillOversizeError, SkillResourceNotFoundError, SkillResourceOutOfBoundsError, SkillValidationError, } from "./skill-system/errors.js";
|
|
2
|
+
export { listBundledSkills, loadBundledSkill, loadBundledSkillFrom, readBundledSkillResource, readBundledSkillResourceFrom, resetBundledSkillsDir, setBundledSkillsDir, } from "./skill-system/loader.js";
|
|
3
|
+
export type { SkillBundle, SkillManifest } from "./skill-system/types.js";
|
|
4
|
+
export { validateSkillBundle } from "./skill-system/validation.js";
|
|
42
5
|
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/public/skills.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/public/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC"}
|
package/dist/public/skills.js
CHANGED
|
@@ -1,270 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import matter from "gray-matter";
|
|
5
|
-
const SKILL_MARKDOWN_MAX_BYTES = 256 * 1024;
|
|
6
|
-
const RESOURCE_MAX_BYTES = 128 * 1024;
|
|
7
|
-
const SKILL_FILE_NAME = "SKILL.md";
|
|
8
|
-
const moduleDir = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
let bundledSkillsDir = resolve(moduleDir, "skills");
|
|
10
|
-
const defaultBundledSkillsDir = bundledSkillsDir;
|
|
11
|
-
export function setBundledSkillsDir(dir) {
|
|
12
|
-
bundledSkillsDir = dir;
|
|
13
|
-
}
|
|
14
|
-
export function resetBundledSkillsDir() {
|
|
15
|
-
bundledSkillsDir = defaultBundledSkillsDir;
|
|
16
|
-
}
|
|
17
|
-
export class SkillNotFoundError extends Error {
|
|
18
|
-
constructor(id) {
|
|
19
|
-
super(`Skill not found: ${id}`);
|
|
20
|
-
this.name = "SkillNotFoundError";
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export class SkillResourceNotFoundError extends Error {
|
|
24
|
-
constructor(id, resourcePath) {
|
|
25
|
-
super(`Skill resource not found: ${id}/${resourcePath}`);
|
|
26
|
-
this.name = "SkillResourceNotFoundError";
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class SkillResourceOutOfBoundsError extends Error {
|
|
30
|
-
constructor(id, resourcePath) {
|
|
31
|
-
super(`Skill resource escapes bundle root: ${id}/${resourcePath}`);
|
|
32
|
-
this.name = "SkillResourceOutOfBoundsError";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class SkillValidationError extends Error {
|
|
36
|
-
field;
|
|
37
|
-
constructor(field, message) {
|
|
38
|
-
super(message);
|
|
39
|
-
this.name = "SkillValidationError";
|
|
40
|
-
this.field = field;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
export class SkillOversizeError extends Error {
|
|
44
|
-
maxBytes;
|
|
45
|
-
actualBytes;
|
|
46
|
-
constructor(pathLike, maxBytes, actualBytes) {
|
|
47
|
-
super(`Skill file exceeds ${maxBytes} bytes: ${pathLike} (${actualBytes} bytes)`);
|
|
48
|
-
this.name = "SkillOversizeError";
|
|
49
|
-
this.maxBytes = maxBytes;
|
|
50
|
-
this.actualBytes = actualBytes;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function listBundledSkills() {
|
|
54
|
-
// implements REQ-001
|
|
55
|
-
if (!existsSync(bundledSkillsDir)) {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
return readdirSync(bundledSkillsDir, { withFileTypes: true })
|
|
59
|
-
.filter((entry) => entry.isDirectory())
|
|
60
|
-
.map((entry) => join(bundledSkillsDir, entry.name))
|
|
61
|
-
.filter((rootDir) => existsSync(join(rootDir, SKILL_FILE_NAME)))
|
|
62
|
-
.map((rootDir) => parseSkillBundle(rootDir).manifest)
|
|
63
|
-
.sort((left, right) => left.id.localeCompare(right.id));
|
|
64
|
-
}
|
|
65
|
-
export function loadBundledSkill(id) {
|
|
66
|
-
// implements REQ-001
|
|
67
|
-
const rootDir = findBundledSkillRoot(id);
|
|
68
|
-
if (!rootDir) {
|
|
69
|
-
throw new SkillNotFoundError(id);
|
|
70
|
-
}
|
|
71
|
-
return parseSkillBundle(rootDir);
|
|
72
|
-
}
|
|
73
|
-
export function readBundledSkillResource(id, resourcePath) {
|
|
74
|
-
// implements REQ-001
|
|
75
|
-
const bundle = loadBundledSkill(id);
|
|
76
|
-
const declaredResource = normalizeResourcePath(resourcePath);
|
|
77
|
-
if (!declaredResource || isPathOutOfBounds(resourcePath)) {
|
|
78
|
-
throw new SkillResourceOutOfBoundsError(id, resourcePath);
|
|
79
|
-
}
|
|
80
|
-
if (!isDeclaredResource(bundle.manifest, declaredResource)) {
|
|
81
|
-
throw new SkillResourceNotFoundError(id, resourcePath);
|
|
82
|
-
}
|
|
83
|
-
const candidatePath = resolve(bundle.rootDir, declaredResource);
|
|
84
|
-
let realResourcePath;
|
|
85
|
-
let realRootDir;
|
|
86
|
-
try {
|
|
87
|
-
realResourcePath = realpathSync(candidatePath);
|
|
88
|
-
realRootDir = realpathSync(bundle.rootDir);
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
throw new SkillResourceNotFoundError(id, resourcePath);
|
|
92
|
-
}
|
|
93
|
-
if (!isWithinRoot(realRootDir, realResourcePath)) {
|
|
94
|
-
throw new SkillResourceOutOfBoundsError(id, resourcePath);
|
|
95
|
-
}
|
|
96
|
-
assertMaxBytes(candidatePath, RESOURCE_MAX_BYTES);
|
|
97
|
-
return readFileSync(candidatePath, "utf8");
|
|
98
|
-
}
|
|
99
|
-
export function validateSkillBundle(pathLike) {
|
|
100
|
-
// implements REQ-001
|
|
101
|
-
const skillFilePath = resolveSkillFilePath(pathLike);
|
|
102
|
-
const errors = [];
|
|
103
|
-
if (!existsSync(skillFilePath)) {
|
|
104
|
-
errors.push(new SkillValidationError("SKILL.md", `Missing ${SKILL_FILE_NAME}`));
|
|
105
|
-
return { valid: false, errors };
|
|
106
|
-
}
|
|
107
|
-
const parsed = matter(readFileSync(skillFilePath, "utf8"));
|
|
108
|
-
errors.push(...validateManifestData(parsed.data));
|
|
109
|
-
if (errors.length === 0) {
|
|
110
|
-
validateBundleContents(skillFilePath, coerceManifest(parsed.data), errors);
|
|
111
|
-
}
|
|
112
|
-
return { valid: errors.length === 0, errors };
|
|
113
|
-
}
|
|
114
|
-
function validateBundleContents(skillFilePath, manifest, errors) {
|
|
115
|
-
try {
|
|
116
|
-
assertMaxBytes(skillFilePath, SKILL_MARKDOWN_MAX_BYTES);
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
errors.push(new SkillValidationError("SKILL.md", error instanceof Error ? error.message : String(error)));
|
|
120
|
-
}
|
|
121
|
-
const rootDir = dirname(skillFilePath);
|
|
122
|
-
let realRootDir;
|
|
123
|
-
try {
|
|
124
|
-
realRootDir = realpathSync(rootDir);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
errors.push(new SkillValidationError("SKILL.md", error instanceof Error ? error.message : String(error)));
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
for (const resource of manifest.resources ?? []) {
|
|
131
|
-
const resourcePath = resolve(rootDir, resource);
|
|
132
|
-
try {
|
|
133
|
-
if (!existsSync(resourcePath)) {
|
|
134
|
-
errors.push(new SkillValidationError("resources", `Missing skill resource: ${resource}`));
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
const realResourcePath = realpathSync(resourcePath);
|
|
138
|
-
if (!isWithinRoot(realRootDir, realResourcePath)) {
|
|
139
|
-
errors.push(new SkillValidationError("resources", `Skill resource escapes bundle root: ${resource}`));
|
|
140
|
-
continue;
|
|
141
|
-
}
|
|
142
|
-
assertMaxBytes(resourcePath, RESOURCE_MAX_BYTES);
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
errors.push(new SkillValidationError("resources", error instanceof Error ? error.message : String(error)));
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function findBundledSkillRoot(id) {
|
|
150
|
-
if (!existsSync(bundledSkillsDir)) {
|
|
151
|
-
return undefined;
|
|
152
|
-
}
|
|
153
|
-
for (const entry of readdirSync(bundledSkillsDir, { withFileTypes: true })) {
|
|
154
|
-
if (!entry.isDirectory()) {
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
const rootDir = join(bundledSkillsDir, entry.name);
|
|
158
|
-
const skillFilePath = join(rootDir, SKILL_FILE_NAME);
|
|
159
|
-
if (!existsSync(skillFilePath)) {
|
|
160
|
-
continue;
|
|
161
|
-
}
|
|
162
|
-
const manifest = parseSkillBundle(rootDir).manifest;
|
|
163
|
-
if (manifest.id === id) {
|
|
164
|
-
return rootDir;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return undefined;
|
|
168
|
-
}
|
|
169
|
-
function parseSkillBundle(rootDir) {
|
|
170
|
-
const skillFilePath = join(rootDir, SKILL_FILE_NAME);
|
|
171
|
-
assertMaxBytes(skillFilePath, SKILL_MARKDOWN_MAX_BYTES);
|
|
172
|
-
const parsed = matter(readFileSync(skillFilePath, "utf8"));
|
|
173
|
-
const errors = validateManifestData(parsed.data);
|
|
174
|
-
if (errors.length > 0) {
|
|
175
|
-
throw errors[0];
|
|
176
|
-
}
|
|
177
|
-
return {
|
|
178
|
-
manifest: coerceManifest(parsed.data),
|
|
179
|
-
body: parsed.content,
|
|
180
|
-
rootDir: resolve(rootDir),
|
|
181
|
-
};
|
|
182
|
-
}
|
|
183
|
-
function validateManifestData(data) {
|
|
184
|
-
const errors = [];
|
|
185
|
-
const requiredFields = [
|
|
186
|
-
"id",
|
|
187
|
-
"name",
|
|
188
|
-
"description",
|
|
189
|
-
"version",
|
|
190
|
-
"kibiCompatibility",
|
|
191
|
-
];
|
|
192
|
-
for (const field of requiredFields) {
|
|
193
|
-
if (typeof data[field] !== "string" || data[field].trim() === "") {
|
|
194
|
-
errors.push(new SkillValidationError(field, `Missing required skill field: ${field}`));
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
if (typeof data.version === "string" &&
|
|
198
|
-
!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(data.version)) {
|
|
199
|
-
errors.push(new SkillValidationError("version", `Invalid skill version: ${data.version}`));
|
|
200
|
-
}
|
|
201
|
-
if (data.tags !== undefined && !isStringArray(data.tags)) {
|
|
202
|
-
errors.push(new SkillValidationError("tags", "Skill tags must be strings"));
|
|
203
|
-
}
|
|
204
|
-
if (data.resources !== undefined) {
|
|
205
|
-
if (!isStringArray(data.resources)) {
|
|
206
|
-
errors.push(new SkillValidationError("resources", "Skill resources must be strings"));
|
|
207
|
-
}
|
|
208
|
-
else {
|
|
209
|
-
for (const resource of data.resources) {
|
|
210
|
-
const normalized = normalizeResourcePath(resource);
|
|
211
|
-
if (!normalized || isPathOutOfBounds(resource)) {
|
|
212
|
-
errors.push(new SkillValidationError("resources", `Invalid skill resource: ${resource}`));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return errors;
|
|
218
|
-
}
|
|
219
|
-
function coerceManifest(data) {
|
|
220
|
-
const manifest = {
|
|
221
|
-
id: String(data.id),
|
|
222
|
-
name: String(data.name),
|
|
223
|
-
description: String(data.description),
|
|
224
|
-
version: String(data.version),
|
|
225
|
-
kibiCompatibility: String(data.kibiCompatibility),
|
|
226
|
-
};
|
|
227
|
-
if (isStringArray(data.tags)) {
|
|
228
|
-
manifest.tags = data.tags;
|
|
229
|
-
}
|
|
230
|
-
if (isStringArray(data.resources)) {
|
|
231
|
-
manifest.resources = data.resources.map((resource) => normalizeResourcePath(resource));
|
|
232
|
-
}
|
|
233
|
-
return manifest;
|
|
234
|
-
}
|
|
235
|
-
function isStringArray(value) {
|
|
236
|
-
return (Array.isArray(value) && value.every((item) => typeof item === "string"));
|
|
237
|
-
}
|
|
238
|
-
function normalizeResourcePath(pathLike) {
|
|
239
|
-
return normalize(pathLike).replaceAll("\\", "/");
|
|
240
|
-
}
|
|
241
|
-
function isPathOutOfBounds(pathLike) {
|
|
242
|
-
const normalized = normalizeResourcePath(pathLike);
|
|
243
|
-
return (isAbsolute(pathLike) ||
|
|
244
|
-
normalized === ".." ||
|
|
245
|
-
normalized.startsWith("../") ||
|
|
246
|
-
normalized.includes("/../"));
|
|
247
|
-
}
|
|
248
|
-
function isDeclaredResource(manifest, resourcePath) {
|
|
249
|
-
return (manifest.resources ?? []).some((declared) => normalizeResourcePath(declared) === resourcePath);
|
|
250
|
-
}
|
|
251
|
-
function isWithinRoot(rootDir, candidatePath) {
|
|
252
|
-
const relativePath = relative(rootDir, candidatePath);
|
|
253
|
-
return (relativePath === "" ||
|
|
254
|
-
(!relativePath.startsWith("..") && !isAbsolute(relativePath)));
|
|
255
|
-
}
|
|
256
|
-
function assertMaxBytes(pathLike, maxBytes) {
|
|
257
|
-
const size = statSync(pathLike).size;
|
|
258
|
-
if (size > maxBytes) {
|
|
259
|
-
throw new SkillOversizeError(pathLike, maxBytes, size);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
function resolveSkillFilePath(pathLike) {
|
|
263
|
-
const resolved = resolve(pathLike);
|
|
264
|
-
if (existsSync(resolved) && statSync(resolved).isDirectory()) {
|
|
265
|
-
return join(resolved, SKILL_FILE_NAME);
|
|
266
|
-
}
|
|
267
|
-
return resolved.endsWith(SKILL_FILE_NAME)
|
|
268
|
-
? resolved
|
|
269
|
-
: join(resolved, SKILL_FILE_NAME);
|
|
270
|
-
}
|
|
1
|
+
export { SkillNotFoundError, SkillOversizeError, SkillResourceNotFoundError, SkillResourceOutOfBoundsError, SkillValidationError, } from "./skill-system/errors.js";
|
|
2
|
+
export { listBundledSkills, loadBundledSkill, loadBundledSkillFrom, readBundledSkillResource, readBundledSkillResourceFrom, resetBundledSkillsDir, setBundledSkillsDir, } from "./skill-system/loader.js";
|
|
3
|
+
export { validateSkillBundle } from "./skill-system/validation.js";
|
|
@@ -4,6 +4,14 @@ export declare const TRACEABILITY_RELATIONSHIP_TYPES: readonly ["implements", "c
|
|
|
4
4
|
export type TraceabilityRelationshipType = (typeof TRACEABILITY_RELATIONSHIP_TYPES)[number];
|
|
5
5
|
export declare const ALLOWED_GRANULARITY_REASONS: readonly ["config-artifact", "module-level-behavior", "extractor-miss", "legacy-link"];
|
|
6
6
|
export type GranularityReason = (typeof ALLOWED_GRANULARITY_REASONS)[number];
|
|
7
|
+
/**
|
|
8
|
+
* Granularity reasons that document coarse file/module-level coverage for which
|
|
9
|
+
* generated per-symbol coordinates are not expected. These anchors legitimately
|
|
10
|
+
* carry no coordinate artifact entries. `legacy-link` is intentionally excluded:
|
|
11
|
+
* it is a canonical reason but still coordinates a real extractable symbol.
|
|
12
|
+
*/
|
|
13
|
+
export declare const COARSE_GRANULARITY_REASONS: readonly ["config-artifact", "module-level-behavior", "extractor-miss", "test-suite"];
|
|
14
|
+
export type CoarseGranularityReason = (typeof COARSE_GRANULARITY_REASONS)[number];
|
|
7
15
|
export type SymbolKind = "function" | "class" | "method" | "property" | "accessor" | "interface" | "type" | "variable" | "enum" | "unknown";
|
|
8
16
|
export type SourceSymbolKind = SymbolKind;
|
|
9
17
|
export interface GranularSymbolCandidate {
|
|
@@ -16,6 +24,7 @@ export declare const inferSymbolRoleFromKind: typeof inferSymbolRole;
|
|
|
16
24
|
export declare function isSymbolRole(value: unknown): value is SymbolRole;
|
|
17
25
|
export declare function isTraceabilityRelationshipType(value: unknown): value is TraceabilityRelationshipType;
|
|
18
26
|
export declare function isAllowedGranularityReason(value: unknown): value is GranularityReason;
|
|
27
|
+
export declare function isCoarseGranularityReason(value: unknown): value is CoarseGranularityReason;
|
|
19
28
|
export declare function getSymbolRole(candidate: GranularSymbolCandidate): SymbolRole;
|
|
20
29
|
export declare function isBehavioralSymbol(candidate: GranularSymbolCandidate): boolean;
|
|
21
30
|
export declare function getBehavioralSymbolNames(candidates: GranularSymbolCandidate[]): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../src/public/symbol-granularity.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,oFAOf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,+BAA+B,yDAIlC,CAAC;AAEX,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,eAAO,MAAM,2BAA2B,wFAK9B,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,OAAO,GACP,QAAQ,GACR,UAAU,GACV,UAAU,GACV,WAAW,GACX,MAAM,GACN,UAAU,GACV,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE1C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"symbol-granularity.d.ts","sourceRoot":"","sources":["../../src/public/symbol-granularity.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,oFAOf,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,eAAO,MAAM,+BAA+B,yDAIlC,CAAC;AAEX,MAAM,MAAM,4BAA4B,GACtC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,eAAO,MAAM,2BAA2B,wFAK9B,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,uFAK7B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GACjC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9C,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,OAAO,GACP,QAAQ,GACR,UAAU,GACV,UAAU,GACV,WAAW,GACX,MAAM,GACN,UAAU,GACV,MAAM,GACN,SAAS,CAAC;AAEd,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE1C,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAYD,wBAAgB,eAAe,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CAgB5D;AAED,eAAO,MAAM,uBAAuB,wBAAkB,CAAC;AAEvD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAIhE;AAED,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,4BAA4B,CAIvC;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,iBAAiB,CAE5B;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,uBAAuB,CAElC;AAED,wBAAgB,aAAa,CAAC,SAAS,EAAE,uBAAuB,GAAG,UAAU,CAI5E;AAED,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,uBAAuB,GACjC,OAAO,CAET;AAED,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,uBAAuB,EAAE,GACpC,MAAM,EAAE,CAMV;AAED,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,uBAAuB,EAAE,GACpC,MAAM,EAAE,CAQV"}
|
|
@@ -17,8 +17,21 @@ export const ALLOWED_GRANULARITY_REASONS = [
|
|
|
17
17
|
"extractor-miss",
|
|
18
18
|
"legacy-link",
|
|
19
19
|
];
|
|
20
|
+
/**
|
|
21
|
+
* Granularity reasons that document coarse file/module-level coverage for which
|
|
22
|
+
* generated per-symbol coordinates are not expected. These anchors legitimately
|
|
23
|
+
* carry no coordinate artifact entries. `legacy-link` is intentionally excluded:
|
|
24
|
+
* it is a canonical reason but still coordinates a real extractable symbol.
|
|
25
|
+
*/
|
|
26
|
+
export const COARSE_GRANULARITY_REASONS = [
|
|
27
|
+
"config-artifact",
|
|
28
|
+
"module-level-behavior",
|
|
29
|
+
"extractor-miss",
|
|
30
|
+
"test-suite",
|
|
31
|
+
];
|
|
20
32
|
const traceabilityRelationshipTypeSet = new Set(TRACEABILITY_RELATIONSHIP_TYPES);
|
|
21
33
|
const allowedGranularityReasonSet = new Set(ALLOWED_GRANULARITY_REASONS);
|
|
34
|
+
const coarseGranularityReasonSet = new Set(COARSE_GRANULARITY_REASONS);
|
|
22
35
|
export function inferSymbolRole(kind) {
|
|
23
36
|
switch (kind) {
|
|
24
37
|
case "function":
|
|
@@ -46,6 +59,9 @@ export function isTraceabilityRelationshipType(value) {
|
|
|
46
59
|
export function isAllowedGranularityReason(value) {
|
|
47
60
|
return typeof value === "string" && allowedGranularityReasonSet.has(value);
|
|
48
61
|
}
|
|
62
|
+
export function isCoarseGranularityReason(value) {
|
|
63
|
+
return typeof value === "string" && coarseGranularityReasonSet.has(value);
|
|
64
|
+
}
|
|
49
65
|
export function getSymbolRole(candidate) {
|
|
50
66
|
if (candidate.role)
|
|
51
67
|
return candidate.role;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/cli-runtime.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAEV,gBAAgB,EAGhB,cAAc,EACf,MAAM,uCAAuC,CAAC;AAwC/C,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,cAAmB,GAC3B,gBAAgB,CAoElB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { PrologProcess } from "../prolog.js";
|
|
3
|
+
import { nodeFilesystem, nodeGit, nodeNetwork, } from "../public/operations/node-ports.js";
|
|
4
|
+
import { resolveActiveBranch } from "../utils/branch-resolver.js";
|
|
5
|
+
function createDefaultProlog() {
|
|
6
|
+
const process = new PrologProcess({ timeout: 120_000 });
|
|
7
|
+
let lastResult = null;
|
|
8
|
+
return {
|
|
9
|
+
start: () => process.start(),
|
|
10
|
+
query: async (goal) => {
|
|
11
|
+
lastResult = await process.query(goal);
|
|
12
|
+
return lastResult;
|
|
13
|
+
},
|
|
14
|
+
nextSolution: async () => {
|
|
15
|
+
const result = lastResult;
|
|
16
|
+
lastResult = null;
|
|
17
|
+
return result;
|
|
18
|
+
},
|
|
19
|
+
save: () => process.query("kb_save"),
|
|
20
|
+
terminate: () => process.terminate(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function workspaceRoot(options) {
|
|
24
|
+
const envRoot = process.env.KIBI_WORKSPACE ??
|
|
25
|
+
process.env.KIBI_PROJECT_ROOT ??
|
|
26
|
+
process.env.KIBI_ROOT;
|
|
27
|
+
return path.resolve(options.workspaceRoot ?? envRoot ?? process.cwd());
|
|
28
|
+
}
|
|
29
|
+
function quoteProlog(value) {
|
|
30
|
+
return value.replaceAll("'", "''");
|
|
31
|
+
}
|
|
32
|
+
// implements REQ-kibi-operation-interface-parity
|
|
33
|
+
export function createCliRuntime(options = {}) {
|
|
34
|
+
const ownedPrologs = new WeakMap();
|
|
35
|
+
return {
|
|
36
|
+
open: async (spec, invocationOptions = {}) => {
|
|
37
|
+
const merged = {
|
|
38
|
+
...options,
|
|
39
|
+
...invocationOptions,
|
|
40
|
+
};
|
|
41
|
+
const root = workspaceRoot(merged);
|
|
42
|
+
const signal = merged.signal ?? new AbortController().signal;
|
|
43
|
+
const clock = merged.clock ?? (() => new Date());
|
|
44
|
+
const git = merged.git ?? nodeGit;
|
|
45
|
+
const contextBase = {
|
|
46
|
+
workspaceRoot: root,
|
|
47
|
+
signal,
|
|
48
|
+
clock,
|
|
49
|
+
fs: merged.fs ?? nodeFilesystem,
|
|
50
|
+
git,
|
|
51
|
+
net: merged.net ?? nodeNetwork,
|
|
52
|
+
};
|
|
53
|
+
if (!spec.requiresProlog) {
|
|
54
|
+
return contextBase;
|
|
55
|
+
}
|
|
56
|
+
const prolog = merged.prolog ?? createDefaultProlog();
|
|
57
|
+
try {
|
|
58
|
+
await prolog.start?.();
|
|
59
|
+
let branch = process.env.KIBI_BRANCH?.trim();
|
|
60
|
+
if (!branch) {
|
|
61
|
+
const resolved = resolveActiveBranch(root);
|
|
62
|
+
if ("error" in resolved) {
|
|
63
|
+
const isNonGitContext = resolved.code === "NOT_A_GIT_REPO" ||
|
|
64
|
+
resolved.code === "GIT_NOT_AVAILABLE";
|
|
65
|
+
if (isNonGitContext) {
|
|
66
|
+
branch = "main";
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error(`Failed to resolve active branch: ${resolved.error}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
branch = resolved.branch;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const kbPath = path.join(root, ".kb", "branches", branch);
|
|
77
|
+
const attached = await prolog.query(`kb_attach('${quoteProlog(kbPath)}')`);
|
|
78
|
+
if (!attached.success) {
|
|
79
|
+
throw new Error(attached.error ?? "Failed to attach branch KB");
|
|
80
|
+
}
|
|
81
|
+
const context = { ...contextBase, prolog };
|
|
82
|
+
ownedPrologs.set(context, prolog);
|
|
83
|
+
return context;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
await prolog.terminate?.();
|
|
87
|
+
throw error;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
afterSuccess: async () => undefined,
|
|
91
|
+
close: async (context) => {
|
|
92
|
+
await ownedPrologs.get(context)?.terminate?.();
|
|
93
|
+
ownedPrologs.delete(context);
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|