kibi-cli 0.14.0 → 0.17.0

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