kibi-cli 2.0.0 → 2.2.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.
Files changed (377) hide show
  1. package/dist/cli-protocol.d.ts.map +1 -1
  2. package/dist/cli-protocol.js +3 -2
  3. package/dist/cli-register-proof.d.ts.map +1 -1
  4. package/dist/cli-register-proof.js +25 -1
  5. package/dist/cli-register-reporting.d.ts.map +1 -1
  6. package/dist/cli-register-reporting.js +6 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +2 -0
  9. package/dist/commands/aggregated-checks.d.ts +7 -0
  10. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  11. package/dist/commands/aggregated-checks.js +25 -1
  12. package/dist/commands/check-generated.d.ts +7 -0
  13. package/dist/commands/check-generated.d.ts.map +1 -0
  14. package/dist/commands/check-generated.js +192 -0
  15. package/dist/commands/check.d.ts.map +1 -1
  16. package/dist/commands/check.js +24 -15
  17. package/dist/commands/doctor.d.ts.map +1 -1
  18. package/dist/commands/doctor.js +227 -25
  19. package/dist/commands/engine.d.ts.map +1 -1
  20. package/dist/commands/engine.js +3 -1
  21. package/dist/commands/github-init.d.ts +1 -1
  22. package/dist/commands/github-init.d.ts.map +1 -1
  23. package/dist/commands/github-init.js +1 -1
  24. package/dist/commands/init-helpers.d.ts +17 -2
  25. package/dist/commands/init-helpers.d.ts.map +1 -1
  26. package/dist/commands/init-helpers.js +136 -30
  27. package/dist/commands/init.d.ts.map +1 -1
  28. package/dist/commands/init.js +110 -15
  29. package/dist/commands/proof-explain.d.ts +10 -0
  30. package/dist/commands/proof-explain.d.ts.map +1 -0
  31. package/dist/commands/proof-explain.js +45 -0
  32. package/dist/commands/proof-impact.d.ts +7 -0
  33. package/dist/commands/proof-impact.d.ts.map +1 -0
  34. package/dist/commands/proof-impact.js +39 -0
  35. package/dist/commands/proof-migrate-legacy.js +1 -1
  36. package/dist/commands/proof-prune.js +1 -1
  37. package/dist/commands/prove.d.ts.map +1 -1
  38. package/dist/commands/prove.js +14 -22
  39. package/dist/commands/report.d.ts.map +1 -1
  40. package/dist/commands/report.js +17 -2
  41. package/dist/commands/sync/cache.d.ts +20 -1
  42. package/dist/commands/sync/cache.d.ts.map +1 -1
  43. package/dist/commands/sync/cache.js +51 -2
  44. package/dist/commands/sync/discovery.d.ts.map +1 -1
  45. package/dist/commands/sync/discovery.js +1 -1
  46. package/dist/commands/sync/manifest.d.ts +1 -0
  47. package/dist/commands/sync/manifest.d.ts.map +1 -1
  48. package/dist/commands/sync/manifest.js +18 -16
  49. package/dist/commands/sync/persistence.d.ts.map +1 -1
  50. package/dist/commands/sync/persistence.js +14 -0
  51. package/dist/commands/sync.d.ts.map +1 -1
  52. package/dist/commands/sync.js +11 -3
  53. package/dist/engine.d.ts +29 -1
  54. package/dist/engine.d.ts.map +1 -1
  55. package/dist/engine.js +259 -89
  56. package/dist/env/bootstrap.d.ts +84 -0
  57. package/dist/env/bootstrap.d.ts.map +1 -0
  58. package/dist/env/bootstrap.js +310 -0
  59. package/dist/extractors/manifest.d.ts.map +1 -1
  60. package/dist/extractors/manifest.js +67 -29
  61. package/dist/extractors/markdown.d.ts +4 -0
  62. package/dist/extractors/markdown.d.ts.map +1 -1
  63. package/dist/extractors/markdown.js +33 -3
  64. package/dist/extractors/relationships.d.ts.map +1 -1
  65. package/dist/extractors/relationships.js +1 -0
  66. package/dist/extractors/symbols-coordinator.d.ts +8 -0
  67. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  68. package/dist/extractors/symbols-coordinator.js +40 -0
  69. package/dist/extractors/symbols-ts.d.ts +8 -19
  70. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  71. package/dist/extractors/symbols-ts.js +33 -503
  72. package/dist/intent-search.d.ts.map +1 -1
  73. package/dist/intent-search.js +68 -30
  74. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  75. package/dist/operations/bootstrap/generate.js +4 -3
  76. package/dist/operations/modeling/model-requirement.d.ts +1 -1
  77. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  78. package/dist/operations/modeling/model-requirement.js +179 -9
  79. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  80. package/dist/operations/modeling/predicate-applyplan.js +14 -2
  81. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  82. package/dist/operations/modeling/predicate-loader.js +24 -0
  83. package/dist/operations/modeling/predicate-types.d.ts +4 -0
  84. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  85. package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
  86. package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
  87. package/dist/operations/modeling/predicate-vocabulary.js +169 -0
  88. package/dist/operations/modeling/requirement-types.d.ts +5 -0
  89. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  90. package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
  91. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  92. package/dist/operations/modeling/suggest-predicates.js +30 -3
  93. package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
  94. package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
  95. package/dist/operations/modeling/vocabulary-alignment.js +178 -0
  96. package/dist/operations/mutation/contradictions.d.ts +3 -0
  97. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  98. package/dist/operations/mutation/contradictions.js +29 -0
  99. package/dist/operations/mutation/delete.d.ts.map +1 -1
  100. package/dist/operations/mutation/delete.js +33 -1
  101. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
  102. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
  103. package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
  104. package/dist/operations/mutation/relationships.d.ts +1 -1
  105. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  106. package/dist/operations/mutation/relationships.js +1 -0
  107. package/dist/operations/mutation/saga.d.ts +5 -0
  108. package/dist/operations/mutation/saga.d.ts.map +1 -1
  109. package/dist/operations/mutation/saga.js +10 -0
  110. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  111. package/dist/operations/mutation/serialization.js +2 -0
  112. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  113. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  114. package/dist/operations/mutation/source-authoring.js +65 -26
  115. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  116. package/dist/operations/mutation/strict-fact.js +5 -0
  117. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  118. package/dist/operations/mutation/symbol-granularity.js +9 -87
  119. package/dist/operations/mutation/types.d.ts +17 -0
  120. package/dist/operations/mutation/types.d.ts.map +1 -1
  121. package/dist/operations/mutation/upsert.d.ts +6 -0
  122. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  123. package/dist/operations/mutation/upsert.js +72 -4
  124. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  125. package/dist/operations/mutation/validate-upsert.js +24 -1
  126. package/dist/operations/mutation/validation.d.ts.map +1 -1
  127. package/dist/operations/mutation/validation.js +16 -3
  128. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  129. package/dist/operations/planning/apply-plan.js +61 -17
  130. package/dist/operations/planning/compile-intent.d.ts +49 -0
  131. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  132. package/dist/operations/planning/compile-intent.js +66 -4
  133. package/dist/operations/proof/baseline-diff.d.ts +41 -0
  134. package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
  135. package/dist/operations/proof/baseline-diff.js +153 -0
  136. package/dist/operations/proof/code-scope.d.ts +17 -0
  137. package/dist/operations/proof/code-scope.d.ts.map +1 -0
  138. package/dist/operations/proof/code-scope.js +60 -0
  139. package/dist/operations/proof/explain.d.ts +75 -0
  140. package/dist/operations/proof/explain.d.ts.map +1 -0
  141. package/dist/operations/proof/explain.js +294 -0
  142. package/dist/operations/proof/impact.d.ts +45 -0
  143. package/dist/operations/proof/impact.d.ts.map +1 -0
  144. package/dist/operations/proof/impact.js +118 -0
  145. package/dist/operations/proof/ingest-proof.d.ts +4 -2
  146. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  147. package/dist/operations/proof/ingest-proof.js +251 -77
  148. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  149. package/dist/operations/proof/migrate-legacy-receipts.js +28 -22
  150. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  151. package/dist/operations/proof/prune-receipts.js +8 -6
  152. package/dist/operations/proof/receipt-document.js +2 -2
  153. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  154. package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
  155. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  156. package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
  157. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
  158. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
  159. package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
  160. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
  161. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
  162. package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
  163. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
  164. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
  165. package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
  166. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
  167. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
  168. package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
  169. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
  170. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
  171. package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
  172. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
  173. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
  174. package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
  175. package/dist/operations/semantic-advisor/types.d.ts +1 -0
  176. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  177. package/dist/plugins/compose-ontology-packs.d.ts +51 -0
  178. package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
  179. package/dist/plugins/compose-ontology-packs.js +257 -0
  180. package/dist/plugins/compose-semantic-classifier.d.ts +47 -0
  181. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
  182. package/dist/plugins/compose-semantic-classifier.js +216 -0
  183. package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
  184. package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
  185. package/dist/plugins/compose-vocabulary-alignment.js +141 -0
  186. package/dist/plugins/external-allowlist.d.ts +17 -0
  187. package/dist/plugins/external-allowlist.d.ts.map +1 -0
  188. package/dist/plugins/external-allowlist.js +29 -0
  189. package/dist/plugins/index.d.ts +11 -0
  190. package/dist/plugins/index.d.ts.map +1 -0
  191. package/dist/plugins/index.js +37 -0
  192. package/dist/plugins/load-plugin.d.ts +19 -0
  193. package/dist/plugins/load-plugin.d.ts.map +1 -0
  194. package/dist/plugins/load-plugin.js +59 -0
  195. package/dist/plugins/project-config.d.ts +28 -0
  196. package/dist/plugins/project-config.d.ts.map +1 -0
  197. package/dist/plugins/project-config.js +90 -0
  198. package/dist/plugins/registry.d.ts +94 -0
  199. package/dist/plugins/registry.d.ts.map +1 -0
  200. package/dist/plugins/registry.js +359 -0
  201. package/dist/plugins/resolve-package.d.ts +47 -0
  202. package/dist/plugins/resolve-package.d.ts.map +1 -0
  203. package/dist/plugins/resolve-package.js +262 -0
  204. package/dist/plugins/source-analysis-service.d.ts +44 -0
  205. package/dist/plugins/source-analysis-service.d.ts.map +1 -0
  206. package/dist/plugins/source-analysis-service.js +232 -0
  207. package/dist/prolog/codec.d.ts.map +1 -1
  208. package/dist/prolog/codec.js +2 -0
  209. package/dist/prolog/janitor.d.ts.map +1 -1
  210. package/dist/prolog/janitor.js +1 -1
  211. package/dist/prolog/store-lock.d.ts +1 -1
  212. package/dist/prolog/store-lock.d.ts.map +1 -1
  213. package/dist/prolog.d.ts +36 -0
  214. package/dist/prolog.d.ts.map +1 -1
  215. package/dist/prolog.js +78 -9
  216. package/dist/proof/inspect.js +1 -1
  217. package/dist/proof/producers/playwright-case-id.js +2 -2
  218. package/dist/proof/producers/playwright-reporter.js +4 -4
  219. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  220. package/dist/public/diagnostic-usage.js +7 -25
  221. package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
  222. package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
  223. package/dist/public/extractors/symbols-coordinator.js +1 -1
  224. package/dist/public/impact/analyzer.d.ts +1 -1
  225. package/dist/public/impact/analyzer.d.ts.map +1 -1
  226. package/dist/public/impact/analyzer.js +6 -4
  227. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  228. package/dist/public/impact/full-kb-quality.js +4 -12
  229. package/dist/public/operations/catalog.d.ts +39 -7
  230. package/dist/public/operations/catalog.d.ts.map +1 -1
  231. package/dist/public/operations/check-executor.d.ts.map +1 -1
  232. package/dist/public/operations/check-executor.js +11 -3
  233. package/dist/public/operations/check-helpers.d.ts +7 -1
  234. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  235. package/dist/public/operations/check-helpers.js +22 -2
  236. package/dist/public/operations/contracts.d.ts.map +1 -1
  237. package/dist/public/operations/contracts.js +51 -12
  238. package/dist/public/operations/discovery-entities.d.ts +53 -1
  239. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  240. package/dist/public/operations/discovery-entities.js +219 -12
  241. package/dist/public/operations/discovery-executors.d.ts +1 -0
  242. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  243. package/dist/public/operations/discovery-executors.js +93 -59
  244. package/dist/public/operations/migration-plan.d.ts +2 -0
  245. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  246. package/dist/public/operations/migration-plan.js +50 -0
  247. package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
  248. package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
  249. package/dist/public/operations/predicate-schema-conformance.js +242 -0
  250. package/dist/public/operations/prolog-json.d.ts +1 -1
  251. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  252. package/dist/public/operations/prolog-json.js +16 -10
  253. package/dist/public/operations/result-envelope.d.ts +34 -1
  254. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  255. package/dist/public/operations/result-envelope.js +78 -2
  256. package/dist/public/operations/runtime-types.d.ts +17 -2
  257. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  258. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  259. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  260. package/dist/public/operations/specs/check-rules.generated.js +9 -1
  261. package/dist/public/operations/specs/check.d.ts +1 -1
  262. package/dist/public/operations/specs/discovery.d.ts +10 -1
  263. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  264. package/dist/public/operations/specs/discovery.js +10 -1
  265. package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
  266. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  267. package/dist/public/operations/specs/mutation-schemas.js +21 -3
  268. package/dist/public/operations/specs/proof.js +1 -1
  269. package/dist/public/operations/specs/reporting.d.ts +9 -0
  270. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  271. package/dist/public/operations/specs/reporting.js +48 -17
  272. package/dist/public/operations/specs/semantic.d.ts +1 -1
  273. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  274. package/dist/public/operations/specs/semantic.js +54 -4
  275. package/dist/public/operations/specs/upsert.d.ts +28 -5
  276. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  277. package/dist/public/operations/specs/upsert.js +1 -1
  278. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  279. package/dist/public/operations/symbol-repair-plan.js +11 -4
  280. package/dist/public/operations/types.d.ts +5 -0
  281. package/dist/public/operations/types.d.ts.map +1 -1
  282. package/dist/public/proof-protocol.js +4 -4
  283. package/dist/public/schemas/entity.d.ts.map +1 -1
  284. package/dist/public/schemas/entity.js +22 -0
  285. package/dist/public/schemas/relationship.d.ts.map +1 -1
  286. package/dist/public/schemas/relationship.js +1 -0
  287. package/dist/public/skills/kibi-usage/SKILL.md +10 -3
  288. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  289. package/dist/public/skills/kibi-usage/resources/proof.md +45 -0
  290. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  291. package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  292. package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
  293. package/dist/public/symbol-granularity.d.ts +1 -1
  294. package/dist/public/symbol-granularity.d.ts.map +1 -1
  295. package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
  296. package/dist/public/symbol-granularity.generated.js +38 -5
  297. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  298. package/dist/public/telemetry-acceptance.js +21 -5
  299. package/dist/relationships/shards.d.ts +6 -0
  300. package/dist/relationships/shards.d.ts.map +1 -1
  301. package/dist/relationships/shards.js +26 -19
  302. package/dist/report/html-report.css +1239 -281
  303. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  304. package/dist/runtime/cli-runtime.js +18 -0
  305. package/dist/schemas/entity.schema.json +32 -0
  306. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  307. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  308. package/dist/traceability/staged-entity-id-style.d.ts +12 -0
  309. package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
  310. package/dist/traceability/staged-entity-id-style.js +68 -0
  311. package/dist/traceability/symbol-extract.d.ts +24 -7
  312. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  313. package/dist/traceability/symbol-extract.js +64 -208
  314. package/dist/traceability/temp-kb.d.ts.map +1 -1
  315. package/dist/traceability/temp-kb.js +8 -0
  316. package/dist/traceability/validate.js +1 -1
  317. package/dist/types/entities.d.ts +2 -0
  318. package/dist/types/entities.d.ts.map +1 -1
  319. package/dist/types/relationships.d.ts +1 -1
  320. package/dist/types/relationships.d.ts.map +1 -1
  321. package/dist/utils/entity-id-style.d.ts +27 -0
  322. package/dist/utils/entity-id-style.d.ts.map +1 -0
  323. package/dist/utils/entity-id-style.js +81 -0
  324. package/dist/utils/git-repository-context.d.ts +50 -0
  325. package/dist/utils/git-repository-context.d.ts.map +1 -0
  326. package/dist/utils/git-repository-context.js +259 -0
  327. package/dist/utils/rule-registry.d.ts +5 -0
  328. package/dist/utils/rule-registry.d.ts.map +1 -1
  329. package/dist/utils/rule-registry.generated.d.ts +42 -0
  330. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  331. package/dist/utils/rule-registry.generated.js +50 -0
  332. package/dist/utils/strict-modeling.d.ts +7 -0
  333. package/dist/utils/strict-modeling.d.ts.map +1 -1
  334. package/dist/utils/strict-modeling.js +11 -0
  335. package/package.json +14 -11
  336. package/schema/entities.pl +60 -1
  337. package/schema/relationships.pl +17 -4
  338. package/schema/validation.pl +118 -20
  339. package/src/public/diagnostic-usage.ts +16 -24
  340. package/src/public/extractors/symbols-coordinator.ts +1 -0
  341. package/src/public/impact/analyzer.ts +15 -12
  342. package/src/public/impact/full-kb-quality.ts +4 -16
  343. package/src/public/operations/check-executor.ts +13 -2
  344. package/src/public/operations/check-helpers.ts +29 -3
  345. package/src/public/operations/contracts.ts +59 -12
  346. package/src/public/operations/discovery-entities.ts +327 -12
  347. package/src/public/operations/discovery-executors.ts +110 -61
  348. package/src/public/operations/migration-plan.ts +57 -0
  349. package/src/public/operations/predicate-schema-conformance.ts +362 -0
  350. package/src/public/operations/prolog-json.ts +22 -8
  351. package/src/public/operations/result-envelope.ts +114 -2
  352. package/src/public/operations/runtime-types.ts +22 -3
  353. package/src/public/operations/specs/check-rules.generated.ts +9 -1
  354. package/src/public/operations/specs/discovery.ts +11 -1
  355. package/src/public/operations/specs/mutation-schemas.ts +23 -3
  356. package/src/public/operations/specs/proof.ts +1 -1
  357. package/src/public/operations/specs/reporting.ts +71 -24
  358. package/src/public/operations/specs/semantic.ts +79 -17
  359. package/src/public/operations/specs/upsert.ts +1 -1
  360. package/src/public/operations/symbol-repair-plan.ts +16 -7
  361. package/src/public/operations/types.ts +5 -0
  362. package/src/public/proof-fingerprint.ts +1 -1
  363. package/src/public/proof-protocol-types.d.ts +1 -1
  364. package/src/public/proof-protocol.ts +4 -4
  365. package/src/public/schemas/entity.ts +22 -0
  366. package/src/public/schemas/relationship.ts +1 -0
  367. package/src/public/skills/kibi-usage/SKILL.md +10 -3
  368. package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  369. package/src/public/skills/kibi-usage/resources/proof.md +45 -0
  370. package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  371. package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  372. package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
  373. package/src/public/symbol-granularity.generated.ts +45 -12
  374. package/src/public/symbol-granularity.ts +3 -3
  375. package/src/public/telemetry-acceptance.ts +37 -6
  376. package/src/schemas/entity.schema.json +32 -0
  377. package/src/schemas/relationship.schema.json +1 -0
@@ -0,0 +1,141 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { NEW_SUBJECT_CHOICE, validateCompareClaimsResult, validateRankSubjectsResult, } from "kibi-plugin-sdk";
19
+ import { diagnosticFromError, withFallback, } from "./compose-semantic-classifier.js";
20
+ import { allowsExternalVocabularyAlignment } from "./external-allowlist.js";
21
+ async function attempt(binding, strategy, input) {
22
+ try {
23
+ return { ok: true, results: await strategy.run(binding.capability, input) };
24
+ }
25
+ catch (error) {
26
+ return { ok: false, diagnostic: diagnosticFromError(binding, error) };
27
+ }
28
+ }
29
+ function mergeByKey(strategy, input, primary, fallback) {
30
+ const primaryByKey = new Map(primary.map((r) => [strategy.keyOf(r), r]));
31
+ const fallbackByKey = new Map(fallback.map((r) => [strategy.keyOf(r), r]));
32
+ return strategy.itemKeys(input).flatMap((key) => {
33
+ const result = primaryByKey.get(key) ?? fallbackByKey.get(key);
34
+ return result === undefined ? [] : [result];
35
+ });
36
+ }
37
+ /**
38
+ * replace / augment / shadow with the same semantics as the semantic
39
+ * classifier: a replace provider owns the result and falls back to builtin
40
+ * (stamped fallbackUsed) on any failure; augment providers only refine items
41
+ * the builtin left unresolved; shadow providers are recorded for comparison
42
+ * and never change the result. External providers run only for allowlisted
43
+ * operations.
44
+ */
45
+ async function compose(resolution, strategy, input, operationName) {
46
+ const allowExternal = allowsExternalVocabularyAlignment(operationName);
47
+ const stamps = [];
48
+ const diagnostics = [];
49
+ const shadowComparisons = [];
50
+ let fallbackUsed = false;
51
+ let results = [];
52
+ const builtin = await attempt(resolution.builtin, strategy, input);
53
+ const builtinResults = builtin.ok ? builtin.results : [];
54
+ if (allowExternal && resolution.replace) {
55
+ const replaced = await attempt(resolution.replace, strategy, input);
56
+ if (replaced.ok) {
57
+ results = mergeByKey(strategy, input, replaced.results, builtinResults);
58
+ stamps.push(resolution.replace.stamp);
59
+ }
60
+ else {
61
+ diagnostics.push(replaced.diagnostic);
62
+ fallbackUsed = true;
63
+ if (builtin.ok) {
64
+ results = [...builtinResults];
65
+ stamps.push(withFallback(resolution.builtin.stamp, true));
66
+ }
67
+ else {
68
+ diagnostics.push(builtin.diagnostic);
69
+ }
70
+ }
71
+ }
72
+ else {
73
+ if (builtin.ok) {
74
+ results = [...builtinResults];
75
+ stamps.push(resolution.builtin.stamp);
76
+ }
77
+ else {
78
+ diagnostics.push(builtin.diagnostic);
79
+ }
80
+ if (allowExternal) {
81
+ for (const augment of resolution.augment) {
82
+ const unresolved = new Set(results.filter(strategy.unresolved).map(strategy.keyOf));
83
+ if (unresolved.size === 0)
84
+ break;
85
+ const augmented = await attempt(augment, strategy, strategy.subset(input, unresolved));
86
+ if (!augmented.ok) {
87
+ diagnostics.push(augmented.diagnostic);
88
+ continue;
89
+ }
90
+ stamps.push(augment.stamp);
91
+ const improvements = augmented.results.filter((result) => unresolved.has(strategy.keyOf(result)) && strategy.improves(result));
92
+ results = mergeByKey(strategy, input, improvements, results);
93
+ }
94
+ }
95
+ }
96
+ if (allowExternal) {
97
+ for (const shadow of resolution.shadow) {
98
+ const shadowed = await attempt(shadow, strategy, input);
99
+ if (!shadowed.ok) {
100
+ diagnostics.push(shadowed.diagnostic);
101
+ continue;
102
+ }
103
+ stamps.push(shadow.stamp);
104
+ shadowComparisons.push({
105
+ stamp: shadow.stamp,
106
+ results: shadowed.results,
107
+ });
108
+ }
109
+ }
110
+ return { results, stamps, shadowComparisons, fallbackUsed, diagnostics };
111
+ }
112
+ const RANK_SUBJECTS = {
113
+ keyOf: (decision) => decision.claimKey,
114
+ itemKeys: (input) => input.clauses.map((clause) => clause.claimKey),
115
+ subset: (input, keys) => ({
116
+ clauses: input.clauses.filter((clause) => keys.has(clause.claimKey)),
117
+ }),
118
+ run: async (provider, input) => validateRankSubjectsResult(await provider.rankSubjects(input), input.clauses).decisions,
119
+ unresolved: (decision) => decision.choice === NEW_SUBJECT_CHOICE,
120
+ improves: (decision) => decision.choice !== NEW_SUBJECT_CHOICE,
121
+ };
122
+ const COMPARE_CLAIMS = {
123
+ keyOf: (judgment) => judgment.pairKey,
124
+ itemKeys: (input) => input.pairs.map((pair) => pair.pairKey),
125
+ subset: (input, keys) => ({
126
+ pairs: input.pairs.filter((pair) => keys.has(pair.pairKey)),
127
+ }),
128
+ run: async (provider, input) => validateCompareClaimsResult(await provider.compareClaims(input), input.pairs.map((pair) => pair.pairKey)).judgments,
129
+ unresolved: (judgment) => !judgment.sameObligation,
130
+ improves: (judgment) => judgment.sameObligation,
131
+ };
132
+ /** Choose an existing subject (or new_subject) for each clause. */
133
+ // implements REQ-kibi-vocabulary-alignment-capability
134
+ export function composeSubjectRanking(resolution, input, options) {
135
+ return compose(resolution, RANK_SUBJECTS, input, options.operationName);
136
+ }
137
+ /** Judge claim pairs; true judgments are review candidates, never verdicts. */
138
+ // implements REQ-kibi-vocabulary-alignment-capability
139
+ export function composeClaimComparison(resolution, input, options) {
140
+ return compose(resolution, COMPARE_CLAIMS, input, options.operationName);
141
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * External capability plugins may be imported only from these operation
3
+ * boundaries. sync / check / validate-upsert / upsert / migration / status /
4
+ * proof / doctor / coverage / suggest-predicates must never import a
5
+ * third-party plugin module — allowlisting the classifier call is not enough.
6
+ */
7
+ export declare const EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS: readonly ["kb_semantic_advisor", "kb_compile_intent"];
8
+ export type ExternalSemanticClassifierOperation = (typeof EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS)[number];
9
+ export declare function allowsExternalSemanticClassifier(operationName: string): boolean;
10
+ /**
11
+ * Operations that may call external kibi.vocabulary-alignment.v1 providers.
12
+ * kb_check and every other operation stay builtin-only: vocabulary alignment is
13
+ * modeling-time advice and never participates in pass/fail checks.
14
+ */
15
+ export declare const EXTERNAL_VOCABULARY_ALIGNMENT_OPERATIONS: readonly ["kb_model_requirement"];
16
+ export declare function allowsExternalVocabularyAlignment(operationName: string): boolean;
17
+ //# sourceMappingURL=external-allowlist.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-allowlist.d.ts","sourceRoot":"","sources":["../../src/plugins/external-allowlist.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,uCAAuC,uDAG1C,CAAC;AAGX,MAAM,MAAM,mCAAmC,GAC7C,CAAC,OAAO,uCAAuC,CAAC,CAAC,MAAM,CAAC,CAAC;AAK3D,wBAAgB,gCAAgC,CAC9C,aAAa,EAAE,MAAM,GACpB,OAAO,CAET;AAED;;;;GAIG;AAEH,eAAO,MAAM,wCAAwC,mCAE3C,CAAC;AAGX,wBAAgB,iCAAiC,CAC/C,aAAa,EAAE,MAAM,GACpB,OAAO,CAIT"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * External capability plugins may be imported only from these operation
3
+ * boundaries. sync / check / validate-upsert / upsert / migration / status /
4
+ * proof / doctor / coverage / suggest-predicates must never import a
5
+ * third-party plugin module — allowlisting the classifier call is not enough.
6
+ */
7
+ // implements REQ-capability-plugin-activation-disclosure-v1
8
+ export const EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS = [
9
+ "kb_semantic_advisor",
10
+ "kb_compile_intent",
11
+ ];
12
+ const ALLOWED = new Set(EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS);
13
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
14
+ export function allowsExternalSemanticClassifier(operationName) {
15
+ return ALLOWED.has(operationName);
16
+ }
17
+ /**
18
+ * Operations that may call external kibi.vocabulary-alignment.v1 providers.
19
+ * kb_check and every other operation stay builtin-only: vocabulary alignment is
20
+ * modeling-time advice and never participates in pass/fail checks.
21
+ */
22
+ // implements REQ-kibi-vocabulary-alignment-capability
23
+ export const EXTERNAL_VOCABULARY_ALIGNMENT_OPERATIONS = [
24
+ "kb_model_requirement",
25
+ ];
26
+ // implements REQ-kibi-vocabulary-alignment-capability
27
+ export function allowsExternalVocabularyAlignment(operationName) {
28
+ return EXTERNAL_VOCABULARY_ALIGNMENT_OPERATIONS.includes(operationName);
29
+ }
@@ -0,0 +1,11 @@
1
+ export { describeConfiguredCapabilityPlugins, readProjectKibiConfig, readProjectPackageJson, type ConfiguredCapabilityPluginDiagnostic, type ProjectPackageManifest, } from "./project-config.js";
2
+ export { PluginResolutionError, PluginValidationError, assertBarePackageName, assertResolvedEntryInsidePackageRoot, hasConsumerNodeModulesLink, hasDeclaredProjectDependency, isBarePackageName, isProjectScopedPackage, packageJsonForResolvedFile, resolveProjectLocalPackage, type ResolvedProjectPackage, } from "./resolve-package.js";
3
+ export { loadPluginPackage, type LoadPluginOptions, type LoadedPlugin, } from "./load-plugin.js";
4
+ export { CapabilityRegistry, CapabilityRegistryCache, createCapabilityRegistry, createCapabilityRegistryCache, createStubBuiltinPlugin, ensureCapabilityRegistry, type BuiltinPluginFactory, type CapabilityModeResolution, type CapabilityProviderBinding, type CapabilityRegistryOptions, type EnsureCapabilityRegistryOptions, } from "./registry.js";
5
+ export { composeSemanticClassification, publicCapabilityStamp, type ComposedSemanticClassifierResult, type SemanticClassifierDiagnostic, } from "./compose-semantic-classifier.js";
6
+ export { composeOntologyCatalog, composeOntologyMatches, type ComposedOntologyCatalog, type StampedOntologyCandidate, } from "./compose-ontology-packs.js";
7
+ export { SourceAnalysisService, analyzeWithResolution, createConservativeFallbackAnalysis, createSourceAnalysisService, type HostSourceAnalysisResult, type SourceAnalysisServiceOptions, } from "./source-analysis-service.js";
8
+ export { EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS, allowsExternalSemanticClassifier, type ExternalSemanticClassifierOperation, } from "./external-allowlist.js";
9
+ export { composeClaimComparison, composeSubjectRanking, type ComposedVocabularyResult, type VocabularyAlignmentDiagnostic, } from "./compose-vocabulary-alignment.js";
10
+ export { EXTERNAL_VOCABULARY_ALIGNMENT_OPERATIONS, allowsExternalVocabularyAlignment, } from "./external-allowlist.js";
11
+ //# sourceMappingURL=index.d.ts.map
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rB,KAAK,wBAAwB,EAC7B,KAAK,6BAA6B,GACnC,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACL,wCAAwC,EACxC,iCAAiC,GAClC,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,37 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ // implements REQ-capability-plugin-activation-disclosure-v1
19
+ export { describeConfiguredCapabilityPlugins, readProjectKibiConfig, readProjectPackageJson, } from "./project-config.js";
20
+ // implements REQ-capability-plugin-activation-disclosure-v1
21
+ export { PluginResolutionError, PluginValidationError, assertBarePackageName, assertResolvedEntryInsidePackageRoot, hasConsumerNodeModulesLink, hasDeclaredProjectDependency, isBarePackageName, isProjectScopedPackage, packageJsonForResolvedFile, resolveProjectLocalPackage, } from "./resolve-package.js";
22
+ // implements REQ-capability-plugin-activation-disclosure-v1
23
+ export { loadPluginPackage, } from "./load-plugin.js";
24
+ // implements REQ-capability-plugin-activation-disclosure-v1
25
+ export { CapabilityRegistry, CapabilityRegistryCache, createCapabilityRegistry, createCapabilityRegistryCache, createStubBuiltinPlugin, ensureCapabilityRegistry, } from "./registry.js";
26
+ // implements REQ-capability-plugin-activation-disclosure-v1
27
+ export { composeSemanticClassification, publicCapabilityStamp, } from "./compose-semantic-classifier.js";
28
+ // implements REQ-capability-plugin-activation-disclosure-v1
29
+ export { composeOntologyCatalog, composeOntologyMatches, } from "./compose-ontology-packs.js";
30
+ // implements REQ-capability-plugin-activation-disclosure-v1
31
+ export { SourceAnalysisService, analyzeWithResolution, createConservativeFallbackAnalysis, createSourceAnalysisService, } from "./source-analysis-service.js";
32
+ // implements REQ-capability-plugin-activation-disclosure-v1
33
+ export { EXTERNAL_SEMANTIC_CLASSIFIER_OPERATIONS, allowsExternalSemanticClassifier, } from "./external-allowlist.js";
34
+ // implements REQ-kibi-vocabulary-alignment-capability
35
+ export { composeClaimComparison, composeSubjectRanking, } from "./compose-vocabulary-alignment.js";
36
+ // implements REQ-kibi-vocabulary-alignment-capability
37
+ export { EXTERNAL_VOCABULARY_ALIGNMENT_OPERATIONS, allowsExternalVocabularyAlignment, } from "./external-allowlist.js";
@@ -0,0 +1,19 @@
1
+ import { type KibiPluginV1 } from "kibi-plugin-sdk";
2
+ import { type ResolvedProjectPackage } from "./resolve-package.js";
3
+ export type LoadedPlugin = Readonly<{
4
+ packageName: string;
5
+ resolved: ResolvedProjectPackage;
6
+ plugin: KibiPluginV1;
7
+ }>;
8
+ export type LoadPluginOptions = Readonly<{
9
+ /** Injectable dynamic import for tests. */
10
+ importModule?: (url: string) => Promise<unknown>;
11
+ /** Injectable package resolver for tests. */
12
+ resolvePackage?: (workspaceRoot: string, packageName: string) => ResolvedProjectPackage;
13
+ }>;
14
+ /**
15
+ * Dynamically import a project-local plugin package and validate the named
16
+ * `kibiPlugin` export against kibi.plugin.v1.
17
+ */
18
+ export declare function loadPluginPackage(workspaceRoot: string, packageName: string, options?: LoadPluginOptions): Promise<LoadedPlugin>;
19
+ //# sourceMappingURL=load-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-plugin.d.ts","sourceRoot":"","sources":["../../src/plugins/load-plugin.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,YAAY,EAGlB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,sBAAsB,CAAC;AAG9B,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,sBAAsB,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC,CAAC;AAGH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,6CAA6C;IAC7C,cAAc,CAAC,EAAE,CACf,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,KAChB,sBAAsB,CAAC;CAC7B,CAAC,CAAC;AAMH;;;GAGG;AAEH,wBAAsB,iBAAiB,CACrC,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,YAAY,CAAC,CA8CvB"}
@@ -0,0 +1,59 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import { PluginValidationError, validateKibiPlugin, } from "kibi-plugin-sdk";
19
+ import { PluginResolutionError, resolveProjectLocalPackage, } from "./resolve-package.js";
20
+ function isRecord(value) {
21
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22
+ }
23
+ /**
24
+ * Dynamically import a project-local plugin package and validate the named
25
+ * `kibiPlugin` export against kibi.plugin.v1.
26
+ */
27
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
28
+ export async function loadPluginPackage(workspaceRoot, packageName, options = {}) {
29
+ const resolvePackage = options.resolvePackage ?? resolveProjectLocalPackage;
30
+ const importModule = options.importModule ?? ((url) => import(url));
31
+ const resolved = resolvePackage(workspaceRoot, packageName);
32
+ let moduleExports;
33
+ try {
34
+ moduleExports = await importModule(resolved.entryUrl);
35
+ }
36
+ catch (error) {
37
+ const message = error instanceof Error ? error.message : String(error);
38
+ throw new PluginResolutionError("PLUGIN_IMPORT_FAILED", `Failed to import plugin package '${packageName}': ${message}`);
39
+ }
40
+ if (!isRecord(moduleExports) || !("kibiPlugin" in moduleExports)) {
41
+ throw new PluginValidationError("MISSING_KIBI_PLUGIN_EXPORT", `Package '${packageName}' must export a named 'kibiPlugin' binding`);
42
+ }
43
+ const plugin = validateKibiPlugin(moduleExports.kibiPlugin);
44
+ const packageVersion = typeof resolved.packageJson.version === "string"
45
+ ? resolved.packageJson.version.trim()
46
+ : "";
47
+ if (!packageVersion) {
48
+ throw new PluginValidationError("MISSING_PACKAGE_VERSION", `Package '${packageName}' package.json must declare a version for provider provenance`);
49
+ }
50
+ if (plugin.version !== packageVersion) {
51
+ throw new PluginValidationError("PLUGIN_VERSION_MISMATCH", `Plugin '${plugin.id}' export version '${plugin.version}' does not match resolved package.json version '${packageVersion}'`);
52
+ }
53
+ // Host provenance always uses the resolved package manifest version.
54
+ const stamped = {
55
+ ...plugin,
56
+ version: packageVersion,
57
+ };
58
+ return { packageName, resolved, plugin: stamped };
59
+ }
@@ -0,0 +1,28 @@
1
+ import { type ProjectKibiConfig } from "kibi-plugin-sdk";
2
+ export type ProjectPackageManifest = Readonly<{
3
+ name?: string;
4
+ dependencies?: Readonly<Record<string, string>>;
5
+ devDependencies?: Readonly<Record<string, string>>;
6
+ optionalDependencies?: Readonly<Record<string, string>>;
7
+ peerDependencies?: Readonly<Record<string, string>>;
8
+ kibi?: unknown;
9
+ }>;
10
+ export declare function readProjectPackageJson(workspaceRoot: string): ProjectPackageManifest;
11
+ /**
12
+ * Read and validate `package.json#kibi` for capability-plugin activation.
13
+ * Missing package.json, `kibi`, or `kibi.plugins` yields empty config
14
+ * (builtin-only), matching historical workspaces without a package manifest.
15
+ */
16
+ export declare function readProjectKibiConfig(workspaceRoot: string): ProjectKibiConfig;
17
+ export type ConfiguredCapabilityPluginDiagnostic = Readonly<{
18
+ package: string;
19
+ capability: string;
20
+ mode: string;
21
+ /** True when the package is listed in dependencies, devDependencies, or optionalDependencies. */
22
+ declared: boolean;
23
+ }>;
24
+ /**
25
+ * Parsed `package.json#kibi.plugins` rows. Does not import plugin modules.
26
+ */
27
+ export declare function describeConfiguredCapabilityPlugins(workspaceRoot: string): readonly ConfiguredCapabilityPluginDiagnostic[];
28
+ //# sourceMappingURL=project-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/plugins/project-config.ts"],"names":[],"mappings":"AAoBA,OAAO,EAGL,KAAK,iBAAiB,EAEvB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,eAAe,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,oBAAoB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACxD,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC,CAAC;AAGH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,GACpB,sBAAsB,CAyBxB;AAED;;;;GAIG;AAEH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,GACpB,iBAAiB,CAOnB;AAED,MAAM,MAAM,oCAAoC,GAAG,QAAQ,CAAC;IAC1D,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,iGAAiG;IACjG,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAkBH;;GAEG;AAGH,wBAAgB,mCAAmC,CACjD,aAAa,EAAE,MAAM,GACpB,SAAS,oCAAoC,EAAE,CAsBjD"}
@@ -0,0 +1,90 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ This program is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU Affero General Public License for more details.
14
+
15
+ You should have received a copy of the GNU Affero General Public License
16
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+ */
18
+ import * as fs from "node:fs";
19
+ import { join } from "node:path";
20
+ import { PluginValidationError, validateProjectKibiConfig, } from "kibi-plugin-sdk";
21
+ // implements REQ-capability-plugin-activation-disclosure-v1
22
+ export function readProjectPackageJson(workspaceRoot) {
23
+ const packageJsonPath = join(workspaceRoot, "package.json");
24
+ if (!fs.existsSync(packageJsonPath)) {
25
+ throw new PluginValidationError("MISSING_PACKAGE_JSON", `No package.json found at ${packageJsonPath}`);
26
+ }
27
+ let parsed;
28
+ try {
29
+ parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
30
+ }
31
+ catch (error) {
32
+ const message = error instanceof Error ? error.message : String(error);
33
+ throw new PluginValidationError("INVALID_PACKAGE_JSON", `Failed to parse package.json: ${message}`);
34
+ }
35
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
36
+ throw new PluginValidationError("INVALID_PACKAGE_JSON", "package.json must be a JSON object");
37
+ }
38
+ return parsed;
39
+ }
40
+ /**
41
+ * Read and validate `package.json#kibi` for capability-plugin activation.
42
+ * Missing package.json, `kibi`, or `kibi.plugins` yields empty config
43
+ * (builtin-only), matching historical workspaces without a package manifest.
44
+ */
45
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
46
+ export function readProjectKibiConfig(workspaceRoot) {
47
+ const packageJsonPath = join(workspaceRoot, "package.json");
48
+ if (!fs.existsSync(packageJsonPath)) {
49
+ return {};
50
+ }
51
+ const manifest = readProjectPackageJson(workspaceRoot);
52
+ return validateProjectKibiConfig(manifest.kibi);
53
+ }
54
+ // implements REQ-capability-plugin-activation-disclosure-v1
55
+ function dependencyDeclared(manifest, packageName) {
56
+ return [
57
+ manifest.dependencies,
58
+ manifest.devDependencies,
59
+ manifest.optionalDependencies,
60
+ ].some((dependencies) => Boolean(dependencies) &&
61
+ Object.prototype.hasOwnProperty.call(dependencies, packageName));
62
+ }
63
+ /**
64
+ * Parsed `package.json#kibi.plugins` rows. Does not import plugin modules.
65
+ */
66
+ // implements REQ-capability-plugin-activation-disclosure-v1, REQ-capability-plugin-observable-behavior-v1
67
+ // covered_by TEST-e2e-capability-plugins
68
+ export function describeConfiguredCapabilityPlugins(workspaceRoot) {
69
+ const config = readProjectKibiConfig(workspaceRoot);
70
+ const plugins = config.plugins ?? [];
71
+ if (plugins.length === 0)
72
+ return [];
73
+ const manifest = readProjectPackageJson(workspaceRoot);
74
+ const rows = [];
75
+ for (const plugin of plugins) {
76
+ const declared = dependencyDeclared(manifest, plugin.package);
77
+ for (const capability of Object.keys(plugin.capabilities)) {
78
+ const entry = plugin.capabilities[capability];
79
+ if (!entry)
80
+ continue;
81
+ rows.push({
82
+ package: plugin.package,
83
+ capability,
84
+ mode: entry.mode,
85
+ declared,
86
+ });
87
+ }
88
+ }
89
+ return rows;
90
+ }
@@ -0,0 +1,94 @@
1
+ import { type CapabilityId, type KibiPluginV1, type OntologyPackV1, type PluginMode, type PluginPermissions, type PluginProviderStamp, type ProjectKibiConfig, type SemanticClassifierV1, type SymbolExtractorV1, type VocabularyAlignmentV1 } from "kibi-plugin-sdk";
2
+ import { type LoadPluginOptions, loadPluginPackage } from "./load-plugin.js";
3
+ export type BuiltinPluginFactory = () => KibiPluginV1 | Promise<KibiPluginV1>;
4
+ export type CapabilityProviderBinding<T> = Readonly<{
5
+ pluginId: string;
6
+ pluginVersion: string;
7
+ packageName: string | null;
8
+ mode: PluginMode | "builtin";
9
+ permissions: PluginPermissions;
10
+ external: boolean;
11
+ capability: T;
12
+ stamp: PluginProviderStamp;
13
+ }>;
14
+ export type CapabilityModeResolution<T> = Readonly<{
15
+ builtin: CapabilityProviderBinding<T>;
16
+ /** At most one replace provider for this capability. */
17
+ replace: CapabilityProviderBinding<T> | null;
18
+ /** Augment providers in package.json activation order. */
19
+ augment: readonly CapabilityProviderBinding<T>[];
20
+ /** Shadow providers never participate in canonical results. */
21
+ shadow: readonly CapabilityProviderBinding<T>[];
22
+ }>;
23
+ export type CapabilityRegistryOptions = Readonly<{
24
+ workspaceRoot: string;
25
+ /** Injected builtin plugin; defaults to a local stub. */
26
+ builtinFactory?: BuiltinPluginFactory;
27
+ /** Pre-validated project config; skips package.json when provided. */
28
+ projectConfig?: ProjectKibiConfig;
29
+ /** Injectable project-config reader for tests. */
30
+ readConfig?: (workspaceRoot: string) => ProjectKibiConfig;
31
+ /** Injectable plugin loader for tests. */
32
+ loadPlugin?: (workspaceRoot: string, packageName: string, options?: LoadPluginOptions) => Promise<Awaited<ReturnType<typeof loadPluginPackage>>>;
33
+ loadPluginOptions?: LoadPluginOptions;
34
+ }>;
35
+ /**
36
+ * Minimal builtin used when no factory is injected and the builtin package is
37
+ * not yet wired. Satisfies kibi.plugin.v1 validation.
38
+ */
39
+ export declare function createStubBuiltinPlugin(): KibiPluginV1;
40
+ /**
41
+ * Per-workspace capability registry. Builtin providers are always present;
42
+ * configured packages load lazily the first time a capability is resolved.
43
+ * Not a process-wide singleton — inject or construct per test/runtime.
44
+ */
45
+ export declare class CapabilityRegistry {
46
+ readonly workspaceRoot: string;
47
+ private readonly builtinFactory;
48
+ private readonly readConfig;
49
+ private readonly loadPlugin;
50
+ private readonly loadPluginOptions;
51
+ private readonly injectedConfig;
52
+ private builtinPluginPromise;
53
+ private configPromise;
54
+ private readonly loadedPackages;
55
+ private readonly capabilityCache;
56
+ constructor(options: CapabilityRegistryOptions);
57
+ getBuiltinPlugin(): Promise<KibiPluginV1>;
58
+ getProjectConfig(): Promise<ProjectKibiConfig>;
59
+ resolveSemanticClassifiers(): Promise<CapabilityModeResolution<SemanticClassifierV1>>;
60
+ resolveOntologyPacks(): Promise<CapabilityModeResolution<OntologyPackV1>>;
61
+ resolveSymbolExtractors(): Promise<CapabilityModeResolution<SymbolExtractorV1>>;
62
+ resolveVocabularyAlignment(): Promise<CapabilityModeResolution<VocabularyAlignmentV1>>;
63
+ resolveCapability(capabilityId: CapabilityId): Promise<CapabilityModeResolution<unknown>>;
64
+ /**
65
+ * Canonical providers only (builtin + optional replace + augment).
66
+ * Shadow bindings are excluded.
67
+ */
68
+ canonicalProviders<T>(resolution: CapabilityModeResolution<T>): readonly CapabilityProviderBinding<T>[];
69
+ private buildCapabilityResolution;
70
+ private ensurePackageLoaded;
71
+ }
72
+ /**
73
+ * Explicit cache keyed by workspace root. Injectable — not a hidden global.
74
+ */
75
+ export declare class CapabilityRegistryCache {
76
+ private readonly registries;
77
+ get(workspaceRoot: string): CapabilityRegistry | undefined;
78
+ getOrCreate(workspaceRoot: string, options?: Omit<CapabilityRegistryOptions, "workspaceRoot">): CapabilityRegistry;
79
+ set(workspaceRoot: string, registry: CapabilityRegistry): void;
80
+ clear(): void;
81
+ }
82
+ export declare function createCapabilityRegistry(options: CapabilityRegistryOptions): CapabilityRegistry;
83
+ export declare function createCapabilityRegistryCache(): CapabilityRegistryCache;
84
+ export type EnsureCapabilityRegistryOptions = CapabilityRegistryOptions & {
85
+ readonly cache?: CapabilityRegistryCache;
86
+ };
87
+ /**
88
+ * Lazily construct and cache a registry per workspace root.
89
+ * Callers should supply a cache instance — there is no process-global store.
90
+ */
91
+ export declare function ensureCapabilityRegistry(workspaceRootOrOptions: string | EnsureCapabilityRegistryOptions, options?: Omit<CapabilityRegistryOptions, "workspaceRoot"> & {
92
+ readonly cache?: CapabilityRegistryCache;
93
+ }): CapabilityRegistry;
94
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/plugins/registry.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,YAAY,EAEjB,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EAItB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAEtB,KAAK,qBAAqB,EAG3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,KAAK,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAK7E,MAAM,MAAM,oBAAoB,GAAG,MAAM,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AAG9E,MAAM,MAAM,yBAAyB,CAAC,CAAC,IAAI,QAAQ,CAAC;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,CAAC,CAAC;IACd,KAAK,EAAE,mBAAmB,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