kibi-cli 0.14.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +52 -94
- 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 +1 -1
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +9 -17
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +22 -1
- package/dist/extractors/markdown.d.ts +14 -2
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +38 -1
- package/dist/extractors/symbols-ts.d.ts.map +1 -1
- package/dist/extractors/symbols-ts.js +11 -1
- 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/model-requirement.d.ts +10 -0
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -0
- package/dist/operations/modeling/model-requirement.js +108 -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 +104 -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 +148 -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 +88 -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 +24 -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 +61 -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 +49 -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 +134 -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 +85 -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 +67 -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 +112 -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 +271 -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 +19 -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 +18 -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 +135 -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 +9 -2
- package/dist/prolog.d.ts +5 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +82 -30
- 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 +907 -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 +20 -0
- package/dist/public/operations/index.d.ts.map +1 -0
- package/dist/public/operations/index.js +18 -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 +62 -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 +126 -0
- package/dist/public/operations/specs/modeling.d.ts.map +1 -0
- package/dist/public/operations/specs/modeling.js +117 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts +233 -0
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -0
- package/dist/public/operations/specs/mutation-schemas.js +267 -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 +53 -0
- package/dist/public/operations/specs/semantic.d.ts.map +1 -0
- package/dist/public/operations/specs/semantic.js +105 -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 +256 -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 +27 -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 +119 -99
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +102 -0
- package/dist/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +26 -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/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 +23 -0
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +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 +38 -27
- 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 +34 -1
- package/dist/types/entities.d.ts +3 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.js +6 -0
- package/package.json +56 -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 +19 -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 +72 -0
- package/src/public/operations/specs/discovery.ts +126 -0
- package/src/public/operations/specs/modeling.ts +154 -0
- package/src/public/operations/specs/mutation-schemas.ts +296 -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 +135 -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 +27 -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 +119 -99
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +102 -0
- package/src/public/skills/kibi-usage/resources/operation-access.md +44 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +26 -3
- package/src/public/skills.ts +18 -427
- package/src/schemas/entity.schema.json +23 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { Violation } from "../check-types.js";
|
|
2
|
+
/*
|
|
3
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
4
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import type { ChangedFileImpactResult } from "../impact-diagnostics.js";
|
|
20
|
+
import type { QualityDiagnostic } from "../impact-diagnostics.js";
|
|
21
|
+
|
|
22
|
+
// implements REQ-mcp-tool-check
|
|
23
|
+
export interface CheckDiagnostic {
|
|
24
|
+
readonly category: string;
|
|
25
|
+
readonly severity: "error" | "warning";
|
|
26
|
+
readonly message: string;
|
|
27
|
+
readonly file?: string;
|
|
28
|
+
readonly suggestion?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// implements REQ-mcp-tool-check
|
|
32
|
+
export interface CheckStructuredContent {
|
|
33
|
+
readonly violations: readonly Violation[];
|
|
34
|
+
readonly count: number;
|
|
35
|
+
readonly diagnostics: readonly CheckDiagnostic[];
|
|
36
|
+
readonly qualityDiagnostics?: readonly QualityDiagnostic[];
|
|
37
|
+
readonly impactDiagnostics?: ChangedFileImpactResult["impactDiagnostics"];
|
|
38
|
+
readonly sourceFiles?: ChangedFileImpactResult["sourceFiles"];
|
|
39
|
+
readonly extractedSymbols?: ChangedFileImpactResult["extractedSymbols"];
|
|
40
|
+
readonly linkedEntities?: ChangedFileImpactResult["linkedEntities"];
|
|
41
|
+
readonly nextActions?: ChangedFileImpactResult["nextActions"];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function formatDiagnostics(diagnostics: readonly CheckDiagnostic[]) {
|
|
45
|
+
return diagnostics.map((d) => ({
|
|
46
|
+
category: d.category,
|
|
47
|
+
severity: d.severity,
|
|
48
|
+
message: d.message,
|
|
49
|
+
...(d.file !== undefined ? { file: d.file } : {}),
|
|
50
|
+
...(d.suggestion !== undefined ? { suggestion: d.suggestion } : {}),
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// implements REQ-mcp-tool-check
|
|
55
|
+
export function formatImpactText(
|
|
56
|
+
impactResult: ChangedFileImpactResult,
|
|
57
|
+
): string {
|
|
58
|
+
if (impactResult.impactDiagnostics.length === 0) {
|
|
59
|
+
return "No impact diagnostics found";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const details = impactResult.impactDiagnostics.map((diagnostic) => {
|
|
63
|
+
const files =
|
|
64
|
+
diagnostic.files.length > 0
|
|
65
|
+
? diagnostic.files.join(", ")
|
|
66
|
+
: "unknown-source";
|
|
67
|
+
return `- ${diagnostic.id} | ${diagnostic.severity} | ${files} | ${diagnostic.message} Suggestion: ${diagnostic.suggestion}`;
|
|
68
|
+
});
|
|
69
|
+
return `${impactResult.impactDiagnostics.length} impact diagnostics found\n${details.join("\n")}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function formatOptionalList(
|
|
73
|
+
label: string,
|
|
74
|
+
values: readonly string[] | undefined,
|
|
75
|
+
) {
|
|
76
|
+
if (values === undefined || values.length === 0) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
return [`${label}: ${values.join(", ")}`];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// implements REQ-mcp-tool-check
|
|
83
|
+
export function formatQualityDiagnosticsText(
|
|
84
|
+
diagnostics: readonly QualityDiagnostic[],
|
|
85
|
+
): string {
|
|
86
|
+
if (diagnostics.length === 0) {
|
|
87
|
+
return "No quality diagnostics found";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const details = diagnostics.map((diagnostic) => {
|
|
91
|
+
const parts = [
|
|
92
|
+
diagnostic.id,
|
|
93
|
+
diagnostic.severity,
|
|
94
|
+
diagnostic.category,
|
|
95
|
+
diagnostic.message,
|
|
96
|
+
];
|
|
97
|
+
const metadata = [
|
|
98
|
+
`Blocking: ${diagnostic.blocking ? "yes" : "no"}`,
|
|
99
|
+
...formatOptionalList("Files", diagnostic.files),
|
|
100
|
+
...formatOptionalList("Docs", diagnostic.docs),
|
|
101
|
+
...(diagnostic.entityId !== undefined
|
|
102
|
+
? [`Entity: ${diagnostic.entityId}`]
|
|
103
|
+
: []),
|
|
104
|
+
...(diagnostic.source !== undefined
|
|
105
|
+
? [`Source: ${diagnostic.source}`]
|
|
106
|
+
: []),
|
|
107
|
+
`Suggestion: ${diagnostic.suggestion}`,
|
|
108
|
+
];
|
|
109
|
+
return `- ${parts.join(" | ")}\n ${metadata.join("\n ")}`;
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
return `${diagnostics.length} quality diagnostic${diagnostics.length === 1 ? "" : "s"} found\n${details.join("\n")}`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// implements REQ-mcp-tool-check
|
|
116
|
+
export function formatViolationText(violations: readonly Violation[]): string {
|
|
117
|
+
if (violations.length === 0) {
|
|
118
|
+
return "No violations found";
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const details = violations.map((violation) => {
|
|
122
|
+
const parts = [
|
|
123
|
+
violation.rule,
|
|
124
|
+
violation.entityId,
|
|
125
|
+
violation.source ?? "unknown-source",
|
|
126
|
+
violation.description,
|
|
127
|
+
];
|
|
128
|
+
if (violation.suggestion) {
|
|
129
|
+
parts.push(`Suggestion: ${violation.suggestion}`);
|
|
130
|
+
}
|
|
131
|
+
return `- ${parts.join(" | ")}`;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return `${violations.length} violations found\n${details.join("\n")}`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// implements REQ-mcp-tool-check
|
|
138
|
+
export function buildStructuredContent(input: {
|
|
139
|
+
violations: readonly Violation[];
|
|
140
|
+
diagnostics: readonly CheckDiagnostic[];
|
|
141
|
+
qualityDiagnostics?: readonly QualityDiagnostic[];
|
|
142
|
+
impactResult: ChangedFileImpactResult | undefined;
|
|
143
|
+
}): CheckStructuredContent {
|
|
144
|
+
const qualityDiagnostics = input.qualityDiagnostics ?? [];
|
|
145
|
+
return {
|
|
146
|
+
violations: [...input.violations],
|
|
147
|
+
count: input.violations.length,
|
|
148
|
+
diagnostics: formatDiagnostics(input.diagnostics),
|
|
149
|
+
...(qualityDiagnostics.length > 0
|
|
150
|
+
? { qualityDiagnostics: [...qualityDiagnostics] }
|
|
151
|
+
: {}),
|
|
152
|
+
...(input.impactResult
|
|
153
|
+
? {
|
|
154
|
+
impactDiagnostics: input.impactResult.impactDiagnostics,
|
|
155
|
+
sourceFiles: input.impactResult.sourceFiles,
|
|
156
|
+
extractedSymbols: input.impactResult.extractedSymbols,
|
|
157
|
+
linkedEntities: input.impactResult.linkedEntities,
|
|
158
|
+
nextActions: input.impactResult.nextActions,
|
|
159
|
+
}
|
|
160
|
+
: {}),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// implements REQ-mcp-tool-check
|
|
165
|
+
export function buildSummary(input: {
|
|
166
|
+
readonly violations: readonly Violation[];
|
|
167
|
+
readonly impactResult: ChangedFileImpactResult | undefined;
|
|
168
|
+
readonly qualityDiagnostics: readonly QualityDiagnostic[];
|
|
169
|
+
}): string {
|
|
170
|
+
const sections = [formatViolationText(input.violations)];
|
|
171
|
+
if (input.impactResult !== undefined) {
|
|
172
|
+
sections.push(formatImpactText(input.impactResult));
|
|
173
|
+
}
|
|
174
|
+
if (input.qualityDiagnostics.length > 0) {
|
|
175
|
+
sections.push(formatQualityDiagnosticsText(input.qualityDiagnostics));
|
|
176
|
+
}
|
|
177
|
+
return sections.join("\n");
|
|
178
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
/*
|
|
3
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
4
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
5
|
+
|
|
6
|
+
This program is free software: you can redistribute it and/or modify
|
|
7
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
(at your option) any later version.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it will be useful,
|
|
12
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
GNU Affero General Public License for more details.
|
|
15
|
+
|
|
16
|
+
You should have received a copy of the GNU Affero General Public License
|
|
17
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
18
|
+
*/
|
|
19
|
+
import { readFile } from "node:fs/promises";
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { getKbPlPathOverride } from "../../env.js";
|
|
22
|
+
import { resolveKbPlPath } from "../../prolog.js";
|
|
23
|
+
import { analyzePrologQueryPlanSafety } from "../../utils/prolog-query-plan-safety.js";
|
|
24
|
+
import {
|
|
25
|
+
type ChecksConfig,
|
|
26
|
+
DEFAULT_CHECKS_CONFIG,
|
|
27
|
+
RULE_NAMES,
|
|
28
|
+
type Violation,
|
|
29
|
+
getEffectiveRules,
|
|
30
|
+
} from "../../utils/rule-registry.js";
|
|
31
|
+
import {
|
|
32
|
+
type ChangedFileImpactResult,
|
|
33
|
+
type QualityDiagnostic,
|
|
34
|
+
analyzeChangedFileImpact,
|
|
35
|
+
} from "../impact-diagnostics.js";
|
|
36
|
+
import type { CheckInput } from "./check-executor.js";
|
|
37
|
+
|
|
38
|
+
export { RULE_NAMES, getEffectiveRules };
|
|
39
|
+
|
|
40
|
+
function resolveChecksPlPath(): string {
|
|
41
|
+
const override = getKbPlPathOverride();
|
|
42
|
+
return path.join(path.dirname(override ?? resolveKbPlPath()), "checks.pl");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// implements REQ-mcp-tool-check
|
|
46
|
+
export function collectQueryPlanSafetyViolations(): Violation[] {
|
|
47
|
+
const checksPlPath = resolveChecksPlPath();
|
|
48
|
+
const source = readFileSync(checksPlPath, "utf8");
|
|
49
|
+
return analyzePrologQueryPlanSafety(source).map((v) => ({
|
|
50
|
+
rule: "query-plan-safety",
|
|
51
|
+
entityId: v.predicate,
|
|
52
|
+
description: v.description,
|
|
53
|
+
suggestion: v.suggestion,
|
|
54
|
+
source: `${checksPlPath}:${v.line}`,
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// implements REQ-mcp-tool-check
|
|
59
|
+
export async function loadChecksConfig(
|
|
60
|
+
workspaceRoot: string,
|
|
61
|
+
): Promise<ChecksConfig> {
|
|
62
|
+
const configPath = path.join(workspaceRoot, ".kb", "config.json");
|
|
63
|
+
try {
|
|
64
|
+
const content = await readFile(configPath, "utf8");
|
|
65
|
+
const parsed = JSON.parse(content) as {
|
|
66
|
+
checks?: Partial<ChecksConfig>;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const parsedRules = parsed.checks?.rules;
|
|
70
|
+
const normalizedRules: Record<string, boolean> = {
|
|
71
|
+
...DEFAULT_CHECKS_CONFIG.rules,
|
|
72
|
+
};
|
|
73
|
+
if (parsedRules && typeof parsedRules === "object") {
|
|
74
|
+
for (const [key, value] of Object.entries(parsedRules)) {
|
|
75
|
+
if (typeof value === "boolean") {
|
|
76
|
+
normalizedRules[key] = value;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const parsedSt = parsed.checks?.symbolTraceability;
|
|
82
|
+
const normalizedSt = { ...DEFAULT_CHECKS_CONFIG.symbolTraceability };
|
|
83
|
+
if (
|
|
84
|
+
parsedSt &&
|
|
85
|
+
typeof parsedSt === "object" &&
|
|
86
|
+
typeof parsedSt.requireAdr === "boolean"
|
|
87
|
+
) {
|
|
88
|
+
normalizedSt.requireAdr = parsedSt.requireAdr;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return { rules: normalizedRules, symbolTraceability: normalizedSt };
|
|
92
|
+
} catch {
|
|
93
|
+
return DEFAULT_CHECKS_CONFIG;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// implements REQ-mcp-tool-check
|
|
98
|
+
export function hasImpactOptions(args: CheckInput): boolean {
|
|
99
|
+
return Boolean(
|
|
100
|
+
args.includeImpactDiagnostics ||
|
|
101
|
+
args.staged ||
|
|
102
|
+
args.includeWorkingTreeDiff ||
|
|
103
|
+
(args.sourceFiles !== undefined && args.sourceFiles.length > 0),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// implements REQ-mcp-tool-check
|
|
108
|
+
export function analyzeKbCheckImpact(
|
|
109
|
+
workspaceRoot: string,
|
|
110
|
+
args: CheckInput,
|
|
111
|
+
): ChangedFileImpactResult | undefined {
|
|
112
|
+
if (!hasImpactOptions(args)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return analyzeChangedFileImpact({
|
|
116
|
+
workspaceRoot,
|
|
117
|
+
...(args.sourceFiles !== undefined
|
|
118
|
+
? { sourceFiles: args.sourceFiles }
|
|
119
|
+
: {}),
|
|
120
|
+
...(args.staged !== undefined ? { staged: args.staged } : {}),
|
|
121
|
+
...(args.includeWorkingTreeDiff !== undefined
|
|
122
|
+
? { includeWorkingTreeDiff: args.includeWorkingTreeDiff }
|
|
123
|
+
: {}),
|
|
124
|
+
...(args.includeImpactDiagnostics !== undefined
|
|
125
|
+
? { includeImpactDiagnostics: args.includeImpactDiagnostics }
|
|
126
|
+
: {}),
|
|
127
|
+
...(args.maxDiagnostics !== undefined
|
|
128
|
+
? { maxDiagnostics: args.maxDiagnostics }
|
|
129
|
+
: {}),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// implements REQ-mcp-tool-check
|
|
134
|
+
export function qualityDiagnosticsFromImpact(
|
|
135
|
+
impactResult: ChangedFileImpactResult | undefined,
|
|
136
|
+
): readonly QualityDiagnostic[] {
|
|
137
|
+
if (impactResult === undefined) return [];
|
|
138
|
+
return impactResult.impactDiagnostics.filter(
|
|
139
|
+
(d) => !d.blocking && d.severity !== "error",
|
|
140
|
+
);
|
|
141
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
escapeAtomContent,
|
|
3
|
+
parseEntityFromBinding,
|
|
4
|
+
parseEntityFromList,
|
|
5
|
+
parseListOfLists,
|
|
6
|
+
} from "../../prolog/codec.js";
|
|
7
|
+
import type { PrologPort } from "./runtime-types.js";
|
|
8
|
+
|
|
9
|
+
export type EntityQueryInput = {
|
|
10
|
+
readonly type?: string;
|
|
11
|
+
readonly id?: string;
|
|
12
|
+
readonly tags?: readonly string[];
|
|
13
|
+
readonly sourceFile?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const VALID_ENTITY_TYPES = [
|
|
17
|
+
"req",
|
|
18
|
+
"scenario",
|
|
19
|
+
"test",
|
|
20
|
+
"adr",
|
|
21
|
+
"flag",
|
|
22
|
+
"event",
|
|
23
|
+
"symbol",
|
|
24
|
+
"fact",
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
// implements REQ-002, REQ-013
|
|
28
|
+
export function validateEntityType(type?: string): void {
|
|
29
|
+
if (type && !VALID_ENTITY_TYPES.some((candidate) => candidate === type)) {
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Invalid type '${type}'. Valid types: ${VALID_ENTITY_TYPES.join(", ")}. Use a single type value, or omit this parameter to query all entities.`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// implements REQ-002, REQ-013
|
|
37
|
+
export function buildEntityGoal(input: EntityQueryInput): string {
|
|
38
|
+
const { type, id, tags, sourceFile } = input;
|
|
39
|
+
if (sourceFile) {
|
|
40
|
+
const safeSource = escapeAtomContent(sourceFile);
|
|
41
|
+
if (type) {
|
|
42
|
+
const safeType = escapeAtomContent(type);
|
|
43
|
+
return `findall([Id,'${safeType}',Props], (kb_entities_by_source('${safeSource}', SourceIds), member(Id, SourceIds), kb_entity(Id, '${safeType}', Props)), Results)`;
|
|
44
|
+
}
|
|
45
|
+
return `findall([Id,Type,Props], (kb_entities_by_source('${safeSource}', SourceIds), member(Id, SourceIds), kb_entity(Id, Type, Props)), Results)`;
|
|
46
|
+
}
|
|
47
|
+
if (id && type) {
|
|
48
|
+
const safeId = escapeAtomContent(id);
|
|
49
|
+
const safeType = escapeAtomContent(type);
|
|
50
|
+
return `findall(['${safeId}','${safeType}',Props], kb_entity('${safeId}', '${safeType}', Props), Results)`;
|
|
51
|
+
}
|
|
52
|
+
if (id) {
|
|
53
|
+
const safeId = escapeAtomContent(id);
|
|
54
|
+
return `findall(['${safeId}',Type,Props], kb_entity('${safeId}', Type, Props), Results)`;
|
|
55
|
+
}
|
|
56
|
+
if (tags && tags.length > 0) {
|
|
57
|
+
if (type) {
|
|
58
|
+
const safeType = escapeAtomContent(type);
|
|
59
|
+
return `findall([Id,'${safeType}',Props], kb_entity(Id, '${safeType}', Props), Results)`;
|
|
60
|
+
}
|
|
61
|
+
return "findall([Id,Type,Props], kb_entity(Id, Type, Props), Results)";
|
|
62
|
+
}
|
|
63
|
+
if (type) {
|
|
64
|
+
const safeType = escapeAtomContent(type);
|
|
65
|
+
return `findall([Id,'${safeType}',Props], kb_entity(Id, '${safeType}', Props), Results)`;
|
|
66
|
+
}
|
|
67
|
+
return "findall([Id,Type,Props], kb_entity(Id, Type, Props), Results)";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// implements REQ-002, REQ-013
|
|
71
|
+
export async function loadEntities(
|
|
72
|
+
prolog: Pick<PrologPort, "query">,
|
|
73
|
+
input: EntityQueryInput,
|
|
74
|
+
): Promise<Record<string, unknown>[]> {
|
|
75
|
+
validateEntityType(input.type);
|
|
76
|
+
const queryResult = await prolog.query(buildEntityGoal(input));
|
|
77
|
+
if (!queryResult.success) {
|
|
78
|
+
throw new Error(queryResult.error || "Query failed with unknown error");
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let entities: Record<string, unknown>[] = [];
|
|
82
|
+
const resultsBinding = queryResult.bindings.Results;
|
|
83
|
+
const resultBinding = queryResult.bindings.Result;
|
|
84
|
+
if (resultsBinding) {
|
|
85
|
+
entities = parseListOfLists(resultsBinding).map(parseEntityFromList);
|
|
86
|
+
} else if (resultBinding) {
|
|
87
|
+
entities = [parseEntityFromBinding(resultBinding)];
|
|
88
|
+
}
|
|
89
|
+
if (input.tags && input.tags.length > 0) {
|
|
90
|
+
const requested = new Set(input.tags.map((tag) => tag.trim()));
|
|
91
|
+
entities = entities.filter((entity) => {
|
|
92
|
+
const tags = entity.tags;
|
|
93
|
+
return (
|
|
94
|
+
Array.isArray(tags) &&
|
|
95
|
+
tags.some((tag) => requested.has(String(tag).trim()))
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return dedupeEntities(entities);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// implements REQ-002
|
|
103
|
+
export function paginateResults<T>(
|
|
104
|
+
results: readonly T[],
|
|
105
|
+
limit = 100,
|
|
106
|
+
offset = 0,
|
|
107
|
+
): T[] {
|
|
108
|
+
return results.slice(offset, offset + limit);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// implements REQ-002
|
|
112
|
+
export function dedupeEntities(
|
|
113
|
+
entities: readonly Record<string, unknown>[],
|
|
114
|
+
): Record<string, unknown>[] {
|
|
115
|
+
const seen = new Set<string>();
|
|
116
|
+
return entities.filter((entity) => {
|
|
117
|
+
const key = `${String(entity.type ?? "")}::${String(entity.id ?? "")}`;
|
|
118
|
+
if (seen.has(key)) return false;
|
|
119
|
+
seen.add(key);
|
|
120
|
+
return true;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { rankEntities } from "../../search-ranking.js";
|
|
2
|
+
import type { SearchMatch } from "../../search-ranking.js";
|
|
3
|
+
import {
|
|
4
|
+
loadEntities,
|
|
5
|
+
paginateResults,
|
|
6
|
+
validateEntityType,
|
|
7
|
+
} from "./discovery-entities.js";
|
|
8
|
+
import { runOperationJsonQuery } from "./prolog-json.js";
|
|
9
|
+
import type { OperationContext, PrologPort } from "./runtime-types.js";
|
|
10
|
+
import type { OperationResult } from "./types.js";
|
|
11
|
+
|
|
12
|
+
export type QueryInput = {
|
|
13
|
+
readonly type?: string;
|
|
14
|
+
readonly id?: string;
|
|
15
|
+
readonly tags?: readonly string[];
|
|
16
|
+
readonly sourceFile?: string;
|
|
17
|
+
readonly limit?: number;
|
|
18
|
+
readonly offset?: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type QueryPayload = {
|
|
22
|
+
readonly entities: readonly Record<string, unknown>[];
|
|
23
|
+
readonly count: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type SearchInput = {
|
|
27
|
+
readonly query: string;
|
|
28
|
+
readonly type?: string;
|
|
29
|
+
readonly limit?: number;
|
|
30
|
+
readonly offset?: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type SearchPayload = {
|
|
34
|
+
readonly results: readonly SearchMatch[];
|
|
35
|
+
readonly count: number;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type StatusInput = Readonly<Record<string, never>>;
|
|
39
|
+
|
|
40
|
+
export type StatusPayload = {
|
|
41
|
+
readonly branch: string;
|
|
42
|
+
readonly snapshotId: string;
|
|
43
|
+
readonly syncedAt: string | null;
|
|
44
|
+
readonly dirty: boolean;
|
|
45
|
+
readonly syncState: string;
|
|
46
|
+
readonly kbPath?: string;
|
|
47
|
+
readonly lastSyncSource?: string;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function requireProlog(context: OperationContext): PrologPort {
|
|
51
|
+
if (!context.prolog) {
|
|
52
|
+
throw new Error("Discovery operation requires a Prolog context");
|
|
53
|
+
}
|
|
54
|
+
return context.prolog;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isStatusPayload(value: unknown): value is StatusPayload {
|
|
58
|
+
if (value === null || typeof value !== "object") return false;
|
|
59
|
+
const record = Object.fromEntries(Object.entries(value));
|
|
60
|
+
return (
|
|
61
|
+
typeof record.branch === "string" &&
|
|
62
|
+
typeof record.snapshotId === "string" &&
|
|
63
|
+
(typeof record.syncedAt === "string" || record.syncedAt === null) &&
|
|
64
|
+
typeof record.dirty === "boolean" &&
|
|
65
|
+
typeof record.syncState === "string"
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export async function executeQuery(
|
|
70
|
+
input: QueryInput,
|
|
71
|
+
context: OperationContext,
|
|
72
|
+
): Promise<OperationResult<QueryPayload>> {
|
|
73
|
+
// implements REQ-kibi-operation-interface-parity
|
|
74
|
+
const { type, id, tags, sourceFile, limit = 100, offset = 0 } = input;
|
|
75
|
+
try {
|
|
76
|
+
const entities = await loadEntities(requireProlog(context), {
|
|
77
|
+
...(type !== undefined ? { type } : {}),
|
|
78
|
+
...(id !== undefined ? { id } : {}),
|
|
79
|
+
...(tags !== undefined ? { tags } : {}),
|
|
80
|
+
...(sourceFile !== undefined ? { sourceFile } : {}),
|
|
81
|
+
});
|
|
82
|
+
const paginated = paginateResults(entities, limit, offset);
|
|
83
|
+
const text =
|
|
84
|
+
entities.length === 0
|
|
85
|
+
? `No entities found${type ? ` of type '${type}'` : ""}.`
|
|
86
|
+
: `Found ${entities.length} entities${type ? ` of type '${type}'` : ""}. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
87
|
+
.map((entity) => {
|
|
88
|
+
const entityId = String(entity.id ?? "").replace(
|
|
89
|
+
/^file:\/\/.*\//,
|
|
90
|
+
"",
|
|
91
|
+
);
|
|
92
|
+
return `${entityId} (${String(entity.title ?? "")}, status=${String(entity.status ?? "")})`;
|
|
93
|
+
})
|
|
94
|
+
.join(", ")}`;
|
|
95
|
+
return {
|
|
96
|
+
content: [{ type: "text", text }],
|
|
97
|
+
structuredContent: { entities: paginated, count: entities.length },
|
|
98
|
+
};
|
|
99
|
+
} catch (error) {
|
|
100
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
101
|
+
throw new Error(`Query execution failed: ${message}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function executeSearch(
|
|
106
|
+
input: SearchInput,
|
|
107
|
+
context: OperationContext,
|
|
108
|
+
): Promise<OperationResult<SearchPayload>> {
|
|
109
|
+
// implements REQ-kibi-operation-interface-parity, REQ-mcp-search-discovery
|
|
110
|
+
const { query, type, limit = 20, offset = 0 } = input;
|
|
111
|
+
const trimmedQuery = query.trim();
|
|
112
|
+
if (!trimmedQuery) {
|
|
113
|
+
throw new Error(
|
|
114
|
+
"Search execution failed: query must be a non-empty string",
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
validateEntityType(type);
|
|
118
|
+
try {
|
|
119
|
+
const entities = await loadEntities(requireProlog(context), {
|
|
120
|
+
...(type !== undefined ? { type } : {}),
|
|
121
|
+
});
|
|
122
|
+
const matches = await rankEntities(
|
|
123
|
+
entities,
|
|
124
|
+
trimmedQuery,
|
|
125
|
+
context.workspaceRoot,
|
|
126
|
+
);
|
|
127
|
+
const paginated = paginateResults(matches, limit, offset);
|
|
128
|
+
const text =
|
|
129
|
+
matches.length === 0
|
|
130
|
+
? `No search results for '${trimmedQuery}'.`
|
|
131
|
+
: `Found ${matches.length} search results for '${trimmedQuery}'. Showing ${paginated.length} (offset ${offset}, limit ${limit}): ${paginated
|
|
132
|
+
.map(
|
|
133
|
+
(match) =>
|
|
134
|
+
`${String(match.entity.id ?? "")} [${match.reasons.join(", ")}]`,
|
|
135
|
+
)
|
|
136
|
+
.join(", ")}`;
|
|
137
|
+
return {
|
|
138
|
+
content: [{ type: "text", text }],
|
|
139
|
+
structuredContent: { results: paginated, count: matches.length },
|
|
140
|
+
};
|
|
141
|
+
} catch (error) {
|
|
142
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
143
|
+
if (message.startsWith("Search execution failed:")) throw error;
|
|
144
|
+
throw new Error(`Search execution failed: ${message}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export async function executeStatus(
|
|
149
|
+
_input: StatusInput,
|
|
150
|
+
context: OperationContext,
|
|
151
|
+
): Promise<OperationResult<StatusPayload>> {
|
|
152
|
+
// implements REQ-kibi-operation-interface-parity, REQ-cli-status-pre-first-sync
|
|
153
|
+
try {
|
|
154
|
+
const payload = await runOperationJsonQuery<StatusPayload>(
|
|
155
|
+
requireProlog(context),
|
|
156
|
+
"status.pl",
|
|
157
|
+
"status:kb_status_json(JsonString)",
|
|
158
|
+
"Status execution",
|
|
159
|
+
);
|
|
160
|
+
if (!isStatusPayload(payload)) {
|
|
161
|
+
throw new Error("Status execution query returned an invalid payload");
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
content: [
|
|
165
|
+
{
|
|
166
|
+
type: "text",
|
|
167
|
+
text: `Branch ${payload.branch} is ${payload.syncState} (snapshot ${payload.snapshotId}, dirty=${payload.dirty})`,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
structuredContent: payload,
|
|
171
|
+
};
|
|
172
|
+
} catch (error) {
|
|
173
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
174
|
+
throw new Error(`Status execution failed: ${message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export * from "./catalog.js";
|
|
2
|
+
export * from "./check-executor.js";
|
|
3
|
+
export * from "./discovery-entities.js";
|
|
4
|
+
export * from "./discovery-executors.js";
|
|
5
|
+
export * from "./runtime-types.js";
|
|
6
|
+
export * from "./node-ports.js";
|
|
7
|
+
export * from "./specs/autopilot.js";
|
|
8
|
+
export * from "./specs/check.js";
|
|
9
|
+
export * from "./specs/discovery.js";
|
|
10
|
+
export * from "./specs/modeling.js";
|
|
11
|
+
export * from "./specs/mutation.js";
|
|
12
|
+
export * from "./specs/reporting.js";
|
|
13
|
+
export * from "./specs/semantic.js";
|
|
14
|
+
export * from "./specs/skills.js";
|
|
15
|
+
export * from "./specs/sparql.js";
|
|
16
|
+
export * from "./types.js";
|
|
17
|
+
export * from "../../operations/autopilot/generate.js";
|
|
18
|
+
export * from "../../operations/autopilot/presentation.js";
|
|
19
|
+
export type * from "../../operations/autopilot/types.js";
|