kibi-cli 0.14.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (432) 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 +52 -94
  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 +1 -1
  60. package/dist/commands/sync/manifest.d.ts.map +1 -1
  61. package/dist/commands/sync/manifest.js +9 -17
  62. package/dist/commands/sync/persistence.d.ts.map +1 -1
  63. package/dist/commands/sync/persistence.js +22 -1
  64. package/dist/extractors/markdown.d.ts +14 -2
  65. package/dist/extractors/markdown.d.ts.map +1 -1
  66. package/dist/extractors/markdown.js +38 -1
  67. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  68. package/dist/extractors/symbols-ts.js +11 -1
  69. package/dist/operations/autopilot/activation.d.ts +4 -0
  70. package/dist/operations/autopilot/activation.d.ts.map +1 -0
  71. package/dist/operations/autopilot/activation.js +130 -0
  72. package/dist/operations/autopilot/candidate-helpers.d.ts +13 -0
  73. package/dist/operations/autopilot/candidate-helpers.d.ts.map +1 -0
  74. package/dist/operations/autopilot/candidate-helpers.js +55 -0
  75. package/dist/operations/autopilot/candidates.d.ts +4 -0
  76. package/dist/operations/autopilot/candidates.d.ts.map +1 -0
  77. package/dist/operations/autopilot/candidates.js +114 -0
  78. package/dist/operations/autopilot/discovery-evidence.d.ts +10 -0
  79. package/dist/operations/autopilot/discovery-evidence.d.ts.map +1 -0
  80. package/dist/operations/autopilot/discovery-evidence.js +158 -0
  81. package/dist/operations/autopilot/discovery.d.ts +4 -0
  82. package/dist/operations/autopilot/discovery.d.ts.map +1 -0
  83. package/dist/operations/autopilot/discovery.js +100 -0
  84. package/dist/operations/autopilot/generate.d.ts +8 -0
  85. package/dist/operations/autopilot/generate.d.ts.map +1 -0
  86. package/dist/operations/autopilot/generate.js +112 -0
  87. package/dist/operations/autopilot/guidance-actions.d.ts +3 -0
  88. package/dist/operations/autopilot/guidance-actions.d.ts.map +1 -0
  89. package/dist/operations/autopilot/guidance-actions.js +79 -0
  90. package/dist/operations/autopilot/guidance.d.ts +14 -0
  91. package/dist/operations/autopilot/guidance.d.ts.map +1 -0
  92. package/dist/operations/autopilot/guidance.js +124 -0
  93. package/dist/operations/autopilot/markdown-candidates.d.ts +7 -0
  94. package/dist/operations/autopilot/markdown-candidates.d.ts.map +1 -0
  95. package/dist/operations/autopilot/markdown-candidates.js +134 -0
  96. package/dist/operations/autopilot/presentation.d.ts +13 -0
  97. package/dist/operations/autopilot/presentation.d.ts.map +1 -0
  98. package/dist/operations/autopilot/presentation.js +91 -0
  99. package/dist/operations/autopilot/requirement-claims.d.ts +3 -0
  100. package/dist/operations/autopilot/requirement-claims.d.ts.map +1 -0
  101. package/dist/operations/autopilot/requirement-claims.js +48 -0
  102. package/dist/operations/autopilot/types.d.ts +117 -0
  103. package/dist/operations/autopilot/types.d.ts.map +1 -0
  104. package/dist/operations/autopilot/types.js +8 -0
  105. package/dist/operations/modeling/model-requirement.d.ts +10 -0
  106. package/dist/operations/modeling/model-requirement.d.ts.map +1 -0
  107. package/dist/operations/modeling/model-requirement.js +108 -0
  108. package/dist/operations/modeling/predicate-applyplan.d.ts +6 -0
  109. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -0
  110. package/dist/operations/modeling/predicate-applyplan.js +104 -0
  111. package/dist/operations/modeling/predicate-catalog-1.d.ts +3 -0
  112. package/dist/operations/modeling/predicate-catalog-1.d.ts.map +1 -0
  113. package/dist/operations/modeling/predicate-catalog-1.js +200 -0
  114. package/dist/operations/modeling/predicate-catalog-2.d.ts +3 -0
  115. package/dist/operations/modeling/predicate-catalog-2.d.ts.map +1 -0
  116. package/dist/operations/modeling/predicate-catalog-2.js +197 -0
  117. package/dist/operations/modeling/predicate-catalog-3.d.ts +3 -0
  118. package/dist/operations/modeling/predicate-catalog-3.d.ts.map +1 -0
  119. package/dist/operations/modeling/predicate-catalog-3.js +193 -0
  120. package/dist/operations/modeling/predicate-catalog-4.d.ts +3 -0
  121. package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -0
  122. package/dist/operations/modeling/predicate-catalog-4.js +149 -0
  123. package/dist/operations/modeling/predicate-catalog.d.ts +5 -0
  124. package/dist/operations/modeling/predicate-catalog.d.ts.map +1 -0
  125. package/dist/operations/modeling/predicate-catalog.js +29 -0
  126. package/dist/operations/modeling/predicate-inference-1.d.ts +16 -0
  127. package/dist/operations/modeling/predicate-inference-1.d.ts.map +1 -0
  128. package/dist/operations/modeling/predicate-inference-1.js +161 -0
  129. package/dist/operations/modeling/predicate-inference-2.d.ts +19 -0
  130. package/dist/operations/modeling/predicate-inference-2.d.ts.map +1 -0
  131. package/dist/operations/modeling/predicate-inference-2.js +169 -0
  132. package/dist/operations/modeling/predicate-inference-3.d.ts +15 -0
  133. package/dist/operations/modeling/predicate-inference-3.d.ts.map +1 -0
  134. package/dist/operations/modeling/predicate-inference-3.js +163 -0
  135. package/dist/operations/modeling/predicate-inference.d.ts +5 -0
  136. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -0
  137. package/dist/operations/modeling/predicate-inference.js +148 -0
  138. package/dist/operations/modeling/predicate-loader.d.ts +10 -0
  139. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -0
  140. package/dist/operations/modeling/predicate-loader.js +88 -0
  141. package/dist/operations/modeling/predicate-ranker.d.ts +3 -0
  142. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -0
  143. package/dist/operations/modeling/predicate-ranker.js +24 -0
  144. package/dist/operations/modeling/predicate-score-1.d.ts +3 -0
  145. package/dist/operations/modeling/predicate-score-1.d.ts.map +1 -0
  146. package/dist/operations/modeling/predicate-score-1.js +121 -0
  147. package/dist/operations/modeling/predicate-score-2.d.ts +3 -0
  148. package/dist/operations/modeling/predicate-score-2.d.ts.map +1 -0
  149. package/dist/operations/modeling/predicate-score-2.js +122 -0
  150. package/dist/operations/modeling/predicate-score-3.d.ts +3 -0
  151. package/dist/operations/modeling/predicate-score-3.d.ts.map +1 -0
  152. package/dist/operations/modeling/predicate-score-3.js +54 -0
  153. package/dist/operations/modeling/predicate-types.d.ts +61 -0
  154. package/dist/operations/modeling/predicate-types.d.ts.map +1 -0
  155. package/dist/operations/modeling/predicate-types.js +1 -0
  156. package/dist/operations/modeling/predicate-usage-hints-1.d.ts +3 -0
  157. package/dist/operations/modeling/predicate-usage-hints-1.d.ts.map +1 -0
  158. package/dist/operations/modeling/predicate-usage-hints-1.js +211 -0
  159. package/dist/operations/modeling/predicate-usage-hints-2.d.ts +3 -0
  160. package/dist/operations/modeling/predicate-usage-hints-2.d.ts.map +1 -0
  161. package/dist/operations/modeling/predicate-usage-hints-2.js +209 -0
  162. package/dist/operations/modeling/predicate-usage-hints-3.d.ts +3 -0
  163. package/dist/operations/modeling/predicate-usage-hints-3.d.ts.map +1 -0
  164. package/dist/operations/modeling/predicate-usage-hints-3.js +45 -0
  165. package/dist/operations/modeling/predicate-utils.d.ts +23 -0
  166. package/dist/operations/modeling/predicate-utils.d.ts.map +1 -0
  167. package/dist/operations/modeling/predicate-utils.js +187 -0
  168. package/dist/operations/modeling/requirement-applyplan.d.ts +4 -0
  169. package/dist/operations/modeling/requirement-applyplan.d.ts.map +1 -0
  170. package/dist/operations/modeling/requirement-applyplan.js +44 -0
  171. package/dist/operations/modeling/requirement-heuristics.d.ts +4 -0
  172. package/dist/operations/modeling/requirement-heuristics.d.ts.map +1 -0
  173. package/dist/operations/modeling/requirement-heuristics.js +114 -0
  174. package/dist/operations/modeling/requirement-modeler.d.ts +8 -0
  175. package/dist/operations/modeling/requirement-modeler.d.ts.map +1 -0
  176. package/dist/operations/modeling/requirement-modeler.js +70 -0
  177. package/dist/operations/modeling/requirement-types.d.ts +49 -0
  178. package/dist/operations/modeling/requirement-types.d.ts.map +1 -0
  179. package/dist/operations/modeling/requirement-types.js +1 -0
  180. package/dist/operations/modeling/requirement-utils.d.ts +10 -0
  181. package/dist/operations/modeling/requirement-utils.d.ts.map +1 -0
  182. package/dist/operations/modeling/requirement-utils.js +65 -0
  183. package/dist/operations/modeling/suggest-predicates.d.ts +6 -0
  184. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -0
  185. package/dist/operations/modeling/suggest-predicates.js +64 -0
  186. package/dist/operations/mutation/audit.d.ts +6 -0
  187. package/dist/operations/mutation/audit.d.ts.map +1 -0
  188. package/dist/operations/mutation/audit.js +22 -0
  189. package/dist/operations/mutation/contradictions.d.ts +10 -0
  190. package/dist/operations/mutation/contradictions.d.ts.map +1 -0
  191. package/dist/operations/mutation/contradictions.js +40 -0
  192. package/dist/operations/mutation/delete.d.ts +5 -0
  193. package/dist/operations/mutation/delete.d.ts.map +1 -0
  194. package/dist/operations/mutation/delete.js +67 -0
  195. package/dist/operations/mutation/relationships.d.ts +17 -0
  196. package/dist/operations/mutation/relationships.d.ts.map +1 -0
  197. package/dist/operations/mutation/relationships.js +134 -0
  198. package/dist/operations/mutation/save.d.ts +4 -0
  199. package/dist/operations/mutation/save.d.ts.map +1 -0
  200. package/dist/operations/mutation/save.js +14 -0
  201. package/dist/operations/mutation/serialization.d.ts +5 -0
  202. package/dist/operations/mutation/serialization.d.ts.map +1 -0
  203. package/dist/operations/mutation/serialization.js +85 -0
  204. package/dist/operations/mutation/strict-fact.d.ts +4 -0
  205. package/dist/operations/mutation/strict-fact.d.ts.map +1 -0
  206. package/dist/operations/mutation/strict-fact.js +67 -0
  207. package/dist/operations/mutation/symbol-granularity.d.ts +4 -0
  208. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -0
  209. package/dist/operations/mutation/symbol-granularity.js +109 -0
  210. package/dist/operations/mutation/symbol-refresh.d.ts +10 -0
  211. package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -0
  212. package/dist/operations/mutation/symbol-refresh.js +105 -0
  213. package/dist/operations/mutation/types.d.ts +43 -0
  214. package/dist/operations/mutation/types.d.ts.map +1 -0
  215. package/dist/operations/mutation/types.js +1 -0
  216. package/dist/operations/mutation/upsert.d.ts +5 -0
  217. package/dist/operations/mutation/upsert.d.ts.map +1 -0
  218. package/dist/operations/mutation/upsert.js +103 -0
  219. package/dist/operations/mutation/validate-upsert.d.ts +5 -0
  220. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -0
  221. package/dist/operations/mutation/validate-upsert.js +50 -0
  222. package/dist/operations/mutation/validation.d.ts +5 -0
  223. package/dist/operations/mutation/validation.d.ts.map +1 -0
  224. package/dist/operations/mutation/validation.js +107 -0
  225. package/dist/operations/mutation/warnings.d.ts +4 -0
  226. package/dist/operations/mutation/warnings.d.ts.map +1 -0
  227. package/dist/operations/mutation/warnings.js +17 -0
  228. package/dist/operations/semantic-advisor/analysis-receipt.d.ts +5 -0
  229. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -0
  230. package/dist/operations/semantic-advisor/analysis-receipt.js +112 -0
  231. package/dist/operations/semantic-advisor/analyze-prose.d.ts +5 -0
  232. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -0
  233. package/dist/operations/semantic-advisor/analyze-prose.js +271 -0
  234. package/dist/operations/semantic-advisor/clauses.d.ts +10 -0
  235. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -0
  236. package/dist/operations/semantic-advisor/clauses.js +43 -0
  237. package/dist/operations/semantic-advisor/observation-plan.d.ts +3 -0
  238. package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -0
  239. package/dist/operations/semantic-advisor/observation-plan.js +19 -0
  240. package/dist/operations/semantic-advisor/predicate-rule.d.ts +14 -0
  241. package/dist/operations/semantic-advisor/predicate-rule.d.ts.map +1 -0
  242. package/dist/operations/semantic-advisor/predicate-rule.js +22 -0
  243. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +79 -0
  244. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -0
  245. package/dist/operations/semantic-advisor/predicate-rules-core.js +140 -0
  246. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +83 -0
  247. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -0
  248. package/dist/operations/semantic-advisor/predicate-rules-policy.js +150 -0
  249. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +48 -0
  250. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -0
  251. package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +102 -0
  252. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +71 -0
  253. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -0
  254. package/dist/operations/semantic-advisor/predicate-rules-product.js +133 -0
  255. package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts +29 -0
  256. package/dist/operations/semantic-advisor/prose-coverage-evaluator.d.ts.map +1 -0
  257. package/dist/operations/semantic-advisor/prose-coverage-evaluator.js +54 -0
  258. package/dist/operations/semantic-advisor/shared.d.ts +18 -0
  259. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -0
  260. package/dist/operations/semantic-advisor/shared.js +209 -0
  261. package/dist/operations/semantic-advisor/strict-count-rules.d.ts +4 -0
  262. package/dist/operations/semantic-advisor/strict-count-rules.d.ts.map +1 -0
  263. package/dist/operations/semantic-advisor/strict-count-rules.js +62 -0
  264. package/dist/operations/semantic-advisor/strict-rules.d.ts +4 -0
  265. package/dist/operations/semantic-advisor/strict-rules.d.ts.map +1 -0
  266. package/dist/operations/semantic-advisor/strict-rules.js +106 -0
  267. package/dist/operations/semantic-advisor/types.d.ts +135 -0
  268. package/dist/operations/semantic-advisor/types.d.ts.map +1 -0
  269. package/dist/operations/semantic-advisor/types.js +1 -0
  270. package/dist/prolog/codec.d.ts.map +1 -1
  271. package/dist/prolog/codec.js +9 -2
  272. package/dist/prolog.d.ts +5 -0
  273. package/dist/prolog.d.ts.map +1 -1
  274. package/dist/prolog.js +82 -30
  275. package/dist/public/impact/diagnostics.d.ts.map +1 -1
  276. package/dist/public/impact/diagnostics.js +8 -4
  277. package/dist/public/impact/full-kb-quality.d.ts +1 -1
  278. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  279. package/dist/public/impact/full-kb-quality.js +34 -1
  280. package/dist/public/impact/requirement-quality.d.ts.map +1 -1
  281. package/dist/public/impact/requirement-quality.js +6 -23
  282. package/dist/public/operations/catalog.d.ts +907 -0
  283. package/dist/public/operations/catalog.d.ts.map +1 -0
  284. package/dist/public/operations/catalog.js +42 -0
  285. package/dist/public/operations/check-executor.d.ts +21 -0
  286. package/dist/public/operations/check-executor.d.ts.map +1 -0
  287. package/dist/public/operations/check-executor.js +111 -0
  288. package/dist/public/operations/check-format-shared.d.ts +36 -0
  289. package/dist/public/operations/check-format-shared.d.ts.map +1 -0
  290. package/dist/public/operations/check-format-shared.js +107 -0
  291. package/dist/public/operations/check-helpers.d.ts +10 -0
  292. package/dist/public/operations/check-helpers.d.ts.map +1 -0
  293. package/dist/public/operations/check-helpers.js +107 -0
  294. package/dist/public/operations/discovery-entities.d.ts +14 -0
  295. package/dist/public/operations/discovery-entities.d.ts.map +1 -0
  296. package/dist/public/operations/discovery-entities.js +91 -0
  297. package/dist/public/operations/discovery-executors.d.ts +39 -0
  298. package/dist/public/operations/discovery-executors.d.ts.map +1 -0
  299. package/dist/public/operations/discovery-executors.js +101 -0
  300. package/dist/public/operations/index.d.ts +20 -0
  301. package/dist/public/operations/index.d.ts.map +1 -0
  302. package/dist/public/operations/index.js +18 -0
  303. package/dist/public/operations/node-ports.d.ts +15 -0
  304. package/dist/public/operations/node-ports.d.ts.map +1 -0
  305. package/dist/public/operations/node-ports.js +57 -0
  306. package/dist/public/operations/prolog-json.d.ts +5 -0
  307. package/dist/public/operations/prolog-json.d.ts.map +1 -0
  308. package/dist/public/operations/prolog-json.js +44 -0
  309. package/dist/public/operations/runtime-types.d.ts +69 -0
  310. package/dist/public/operations/runtime-types.d.ts.map +1 -0
  311. package/dist/public/operations/runtime-types.js +17 -0
  312. package/dist/public/operations/specs/autopilot.d.ts +82 -0
  313. package/dist/public/operations/specs/autopilot.d.ts.map +1 -0
  314. package/dist/public/operations/specs/autopilot.js +72 -0
  315. package/dist/public/operations/specs/check.d.ts +51 -0
  316. package/dist/public/operations/specs/check.d.ts.map +1 -0
  317. package/dist/public/operations/specs/check.js +62 -0
  318. package/dist/public/operations/specs/discovery.d.ts +94 -0
  319. package/dist/public/operations/specs/discovery.d.ts.map +1 -0
  320. package/dist/public/operations/specs/discovery.js +98 -0
  321. package/dist/public/operations/specs/modeling.d.ts +126 -0
  322. package/dist/public/operations/specs/modeling.d.ts.map +1 -0
  323. package/dist/public/operations/specs/modeling.js +117 -0
  324. package/dist/public/operations/specs/mutation-schemas.d.ts +233 -0
  325. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -0
  326. package/dist/public/operations/specs/mutation-schemas.js +267 -0
  327. package/dist/public/operations/specs/mutation.d.ts +56 -0
  328. package/dist/public/operations/specs/mutation.d.ts.map +1 -0
  329. package/dist/public/operations/specs/mutation.js +44 -0
  330. package/dist/public/operations/specs/reporting.d.ts +185 -0
  331. package/dist/public/operations/specs/reporting.d.ts.map +1 -0
  332. package/dist/public/operations/specs/reporting.js +158 -0
  333. package/dist/public/operations/specs/semantic.d.ts +53 -0
  334. package/dist/public/operations/specs/semantic.d.ts.map +1 -0
  335. package/dist/public/operations/specs/semantic.js +105 -0
  336. package/dist/public/operations/specs/skills.d.ts +70 -0
  337. package/dist/public/operations/specs/skills.d.ts.map +1 -0
  338. package/dist/public/operations/specs/skills.js +107 -0
  339. package/dist/public/operations/specs/sparql.d.ts +39 -0
  340. package/dist/public/operations/specs/sparql.d.ts.map +1 -0
  341. package/dist/public/operations/specs/sparql.js +121 -0
  342. package/dist/public/operations/specs/upsert.d.ts +256 -0
  343. package/dist/public/operations/specs/upsert.d.ts.map +1 -0
  344. package/dist/public/operations/specs/upsert.js +27 -0
  345. package/dist/public/operations/types.d.ts +24 -0
  346. package/dist/public/operations/types.d.ts.map +1 -0
  347. package/dist/public/operations/types.js +1 -0
  348. package/dist/public/schemas/entity.d.ts.map +1 -1
  349. package/dist/public/schemas/entity.js +27 -0
  350. package/dist/public/skill-system/errors.d.ts +19 -0
  351. package/dist/public/skill-system/errors.d.ts.map +1 -0
  352. package/dist/public/skill-system/errors.js +36 -0
  353. package/dist/public/skill-system/loader.d.ts +9 -0
  354. package/dist/public/skill-system/loader.d.ts.map +1 -0
  355. package/dist/public/skill-system/loader.js +76 -0
  356. package/dist/public/skill-system/paths.d.ts +6 -0
  357. package/dist/public/skill-system/paths.d.ts.map +1 -0
  358. package/dist/public/skill-system/paths.js +25 -0
  359. package/dist/public/skill-system/types.d.ts +15 -0
  360. package/dist/public/skill-system/types.d.ts.map +1 -0
  361. package/dist/public/skill-system/types.js +1 -0
  362. package/dist/public/skill-system/validation.d.ts +10 -0
  363. package/dist/public/skill-system/validation.d.ts.map +1 -0
  364. package/dist/public/skill-system/validation.js +119 -0
  365. package/dist/public/skills/init-kibi/SKILL.md +62 -0
  366. package/dist/public/skills/kibi-freshness/SKILL.md +44 -0
  367. package/dist/public/skills/kibi-traceability/SKILL.md +54 -0
  368. package/dist/public/skills/kibi-usage/SKILL.md +119 -99
  369. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +102 -0
  370. package/dist/public/skills/kibi-usage/resources/operation-access.md +44 -0
  371. package/dist/public/skills/kibi-usage/resources/workflows.md +26 -3
  372. package/dist/public/skills.d.ts +4 -41
  373. package/dist/public/skills.d.ts.map +1 -1
  374. package/dist/public/skills.js +3 -270
  375. package/dist/runtime/cli-runtime.d.ts +3 -0
  376. package/dist/runtime/cli-runtime.d.ts.map +1 -0
  377. package/dist/runtime/cli-runtime.js +96 -0
  378. package/dist/schemas/entity.schema.json +23 -0
  379. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  380. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  381. package/dist/traceability/staged-symbols-manifest.d.ts +1 -0
  382. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  383. package/dist/traceability/staged-symbols-manifest.js +38 -27
  384. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  385. package/dist/traceability/symbol-extract.js +17 -1
  386. package/dist/traceability/temp-kb.d.ts.map +1 -1
  387. package/dist/traceability/temp-kb.js +34 -1
  388. package/dist/types/entities.d.ts +3 -0
  389. package/dist/types/entities.d.ts.map +1 -1
  390. package/dist/utils/rule-registry.d.ts.map +1 -1
  391. package/dist/utils/rule-registry.js +6 -0
  392. package/package.json +56 -2
  393. package/src/public/impact/diagnostics.ts +18 -11
  394. package/src/public/impact/full-kb-quality.ts +30 -3
  395. package/src/public/impact/requirement-quality.ts +6 -26
  396. package/src/public/operations/catalog.ts +60 -0
  397. package/src/public/operations/check-executor.ts +185 -0
  398. package/src/public/operations/check-format-shared.ts +178 -0
  399. package/src/public/operations/check-helpers.ts +141 -0
  400. package/src/public/operations/discovery-entities.ts +122 -0
  401. package/src/public/operations/discovery-executors.ts +176 -0
  402. package/src/public/operations/index.ts +19 -0
  403. package/src/public/operations/node-ports.ts +78 -0
  404. package/src/public/operations/prolog-json.ts +71 -0
  405. package/src/public/operations/runtime-types.ts +106 -0
  406. package/src/public/operations/specs/autopilot.ts +98 -0
  407. package/src/public/operations/specs/check.ts +72 -0
  408. package/src/public/operations/specs/discovery.ts +126 -0
  409. package/src/public/operations/specs/modeling.ts +154 -0
  410. package/src/public/operations/specs/mutation-schemas.ts +296 -0
  411. package/src/public/operations/specs/mutation.ts +58 -0
  412. package/src/public/operations/specs/reporting.ts +249 -0
  413. package/src/public/operations/specs/semantic.ts +135 -0
  414. package/src/public/operations/specs/skills.ts +142 -0
  415. package/src/public/operations/specs/sparql.ts +149 -0
  416. package/src/public/operations/specs/upsert.ts +40 -0
  417. package/src/public/operations/types.ts +57 -0
  418. package/src/public/schemas/entity.ts +27 -0
  419. package/src/public/skill-system/errors.ts +38 -0
  420. package/src/public/skill-system/loader.ts +108 -0
  421. package/src/public/skill-system/paths.ts +27 -0
  422. package/src/public/skill-system/types.ts +14 -0
  423. package/src/public/skill-system/validation.ts +175 -0
  424. package/src/public/skills/init-kibi/SKILL.md +62 -0
  425. package/src/public/skills/kibi-freshness/SKILL.md +44 -0
  426. package/src/public/skills/kibi-traceability/SKILL.md +54 -0
  427. package/src/public/skills/kibi-usage/SKILL.md +119 -99
  428. package/src/public/skills/kibi-usage/resources/fact-lanes.md +102 -0
  429. package/src/public/skills/kibi-usage/resources/operation-access.md +44 -0
  430. package/src/public/skills/kibi-usage/resources/workflows.md +26 -3
  431. package/src/public/skills.ts +18 -427
  432. package/src/schemas/entity.schema.json +23 -0
@@ -0,0 +1,106 @@
1
+ import { normalizeSubjectKey, strictSuggestion, } from "./shared.js";
2
+ import { detectCountStrictSuggestion } from "./strict-count-rules.js";
3
+ function suggestion(payload, match, claim, rationale, confidence, evidence = match[0]) {
4
+ return strictSuggestion(payload, evidence, claim, rationale, confidence);
5
+ }
6
+ // implements REQ-mcp-semantic-advisor-preflight
7
+ export function detectStrictSuggestion(payload, statement) {
8
+ const expiry = statement.match(/^(?<subject>.+?)\s+expir(?:e|es)\s+after\s+(?<value>\d+)\s+(?<unit>days?|months?|years?|hours?|minutes?)\.?$/i);
9
+ if (expiry?.groups?.subject && expiry.groups.value && expiry.groups.unit) {
10
+ const unit = expiry.groups.unit.toLowerCase().replace(/s?$/, "s");
11
+ return suggestion(payload, expiry, {
12
+ subject_key: normalizeSubjectKey(expiry.groups.subject),
13
+ property_key: `expiry_${unit}`,
14
+ operator: "eq",
15
+ value_type: "int",
16
+ value_int: Number(expiry.groups.value),
17
+ unit,
18
+ }, "Expiry duration is a scalar strict property and should be explicit.", 0.88, `expire after ${expiry.groups.value} ${expiry.groups.unit}`);
19
+ }
20
+ const comparative = statement.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+(?<operator>less\s+than|greater\s+than|below|above|minimum|maximum|at\s+least|at\s+most)\s+(?<value>\d+)\.?$/i);
21
+ if (comparative?.groups?.subject &&
22
+ comparative.groups.operator &&
23
+ comparative.groups.value) {
24
+ const operatorText = comparative.groups.operator.toLowerCase();
25
+ const operator = /less|below/.test(operatorText)
26
+ ? "lt"
27
+ : /greater|above/.test(operatorText)
28
+ ? "gt"
29
+ : /minimum|least/.test(operatorText)
30
+ ? "gte"
31
+ : "lte";
32
+ return suggestion(payload, comparative, {
33
+ subject_key: normalizeSubjectKey(comparative.groups.subject),
34
+ property_key: "value",
35
+ operator,
36
+ value_type: "int",
37
+ value_int: Number(comparative.groups.value),
38
+ }, "Comparative numeric prose is a strict property constraint.", 0.86, `${comparative.groups.operator} ${comparative.groups.value}`);
39
+ }
40
+ const precision = statement.match(/^.+?\s+(?:must|shall|should)\s+normalize\s+into\s+canonical\s+integer\s+decisecond\s+(?<subject>[a-z][a-z0-9_-]*)\s+values?\.?$/i);
41
+ if (precision?.groups?.subject) {
42
+ return suggestion(payload, precision, {
43
+ subject_key: normalizeSubjectKey(precision.groups.subject),
44
+ property_key: "slot_precision",
45
+ operator: "eq",
46
+ value_type: "string",
47
+ value_string: "decisecond",
48
+ }, "Canonical decisecond slot prose is a strict precision property.", 0.9);
49
+ }
50
+ const threshold = statement.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+return\s+within\s+(?<value>\d+)\s+(?<unit>ms|milliseconds?|s|sec|secs|seconds?)\.?$/i);
51
+ if (threshold?.groups?.subject &&
52
+ threshold.groups.value &&
53
+ threshold.groups.unit) {
54
+ const unit = threshold.groups.unit.toLowerCase().startsWith("m")
55
+ ? "ms"
56
+ : "seconds";
57
+ return suggestion(payload, threshold, {
58
+ subject_key: normalizeSubjectKey(threshold.groups.subject),
59
+ property_key: unit === "ms" ? "latency_ms" : "latency_seconds",
60
+ operator: "lte",
61
+ value_type: "int",
62
+ value_int: Number(threshold.groups.value),
63
+ unit,
64
+ }, "Response-time thresholds are bounded numeric properties and should be modeled explicitly.", 0.88, `within ${threshold.groups.value} ${threshold.groups.unit}`);
65
+ }
66
+ const booleanState = statement.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+(?<state>enabled|disabled)\.?$/i);
67
+ if (booleanState?.groups?.subject && booleanState.groups.state) {
68
+ return suggestion(payload, booleanState, {
69
+ subject_key: normalizeSubjectKey(booleanState.groups.subject),
70
+ property_key: "enabled",
71
+ operator: "eq",
72
+ value_type: "bool",
73
+ value_bool: booleanState.groups.state.toLowerCase() === "enabled",
74
+ }, "Enabled/disabled requirements are boolean properties and can participate in strict checks.", 0.88, `be ${booleanState.groups.state}`);
75
+ }
76
+ const retention = statement.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+retained\s+for\s+(?<value>\d+)\s+(?<unit>days?|months?|years?)\.?$/i);
77
+ if (retention?.groups?.subject &&
78
+ retention.groups.value &&
79
+ retention.groups.unit) {
80
+ const unit = retention.groups.unit.toLowerCase().replace(/s$/, "s");
81
+ return suggestion(payload, retention, {
82
+ subject_key: normalizeSubjectKey(retention.groups.subject),
83
+ property_key: `retention_${unit}`,
84
+ operator: "eq",
85
+ value_type: "int",
86
+ value_int: Number(retention.groups.value),
87
+ unit,
88
+ }, "Retention duration is a scalar strict property and can participate in contradiction checks.", 0.92, `retained for ${retention.groups.value} ${retention.groups.unit}`);
89
+ }
90
+ const enumSet = statement.match(/^(?<subject>.+?)\s+(?:must|shall|should)\s+be\s+one\s+of\s+(?<values>.+?)\.?$/i);
91
+ if (enumSet?.groups?.subject && enumSet.groups.values) {
92
+ const values = enumSet.groups.values
93
+ .split(/,|\bor\b/i)
94
+ .map((value) => value.trim())
95
+ .filter(Boolean);
96
+ if (values.length > 1)
97
+ return suggestion(payload, enumSet, {
98
+ subject_key: normalizeSubjectKey(enumSet.groups.subject),
99
+ property_key: "allowed_values",
100
+ operator: "eq",
101
+ value_type: "string",
102
+ value_string: values.join("|"),
103
+ }, "Allowed enum sets are explicit property values and should not remain prose-only.", 0.86, `one of ${enumSet.groups.values}`);
104
+ }
105
+ return detectCountStrictSuggestion(payload, statement);
106
+ }
@@ -0,0 +1,135 @@
1
+ export type SemanticAdvisorLane = "strict_property" | "predicate" | "observation_review" | "none";
2
+ export type SemanticAdvisorReadiness = "modeled" | "needs_modeling" | "not_applicable";
3
+ export type SemanticLogicCoverageStatus = "complete" | "partial" | "unverified" | "not_applicable";
4
+ export type SemanticSignalKind = "normative_modal" | "numeric_cardinality" | "numeric_threshold" | "conditional" | "permission" | "state_or_default";
5
+ export interface SemanticSignal {
6
+ readonly kind: SemanticSignalKind;
7
+ readonly evidence: string;
8
+ readonly candidate_lane: SemanticAdvisorLane;
9
+ readonly confidence: number;
10
+ }
11
+ export interface SemanticAmbiguityWitness {
12
+ readonly signal_kind: SemanticSignalKind;
13
+ readonly evidence: string;
14
+ readonly interpretations: readonly string[];
15
+ readonly message: string;
16
+ }
17
+ export interface SemanticStrictPropertyClaim {
18
+ readonly subject_key: string;
19
+ readonly property_key: string;
20
+ readonly operator: "eq" | "neq" | "lt" | "lte" | "gt" | "gte";
21
+ readonly value_type: "string" | "int" | "number" | "bool";
22
+ readonly value_string?: string;
23
+ readonly value_int?: number;
24
+ readonly value_number?: number;
25
+ readonly value_bool?: boolean;
26
+ readonly unit?: string;
27
+ }
28
+ export interface SemanticPredicateClaim {
29
+ readonly predicate_name: string;
30
+ readonly predicate_args: readonly string[];
31
+ readonly canonical_key: string;
32
+ readonly polarity: "assert" | "deny";
33
+ }
34
+ export type SemanticModelingSuggestion = {
35
+ readonly kind: "strict_property";
36
+ readonly claim_key: string;
37
+ readonly claim_text: string;
38
+ readonly confidence: number;
39
+ readonly evidence: string;
40
+ readonly rationale: string;
41
+ readonly suggested_next_tool: "kb_model_requirement";
42
+ readonly claim: SemanticStrictPropertyClaim;
43
+ readonly rejected_alternatives: readonly string[];
44
+ readonly applyPlan: readonly Readonly<Record<string, unknown>>[];
45
+ } | {
46
+ readonly kind: "predicate";
47
+ readonly claim_key: string;
48
+ readonly claim_text: string;
49
+ readonly confidence: number;
50
+ readonly evidence: string;
51
+ readonly rationale: string;
52
+ readonly suggested_next_tool: "kb_suggest_predicates";
53
+ readonly predicate: SemanticPredicateClaim;
54
+ readonly rejected_alternatives: readonly string[];
55
+ readonly applyPlan: readonly Readonly<Record<string, unknown>>[];
56
+ readonly relationshipPlan: Readonly<Record<string, unknown>> | null;
57
+ } | {
58
+ readonly kind: "ambiguity_observation";
59
+ readonly claim_key: string;
60
+ readonly claim_text: string;
61
+ readonly confidence: number;
62
+ readonly evidence: string;
63
+ readonly rationale: string;
64
+ readonly ambiguity: readonly string[];
65
+ readonly suggested_next_tool: "kb_model_requirement" | "kb_suggest_predicates";
66
+ readonly applyPlan: readonly Readonly<Record<string, unknown>>[];
67
+ } | {
68
+ readonly kind: "ontology_gap";
69
+ readonly claim_key: string;
70
+ readonly claim_text: string;
71
+ readonly confidence: number;
72
+ readonly evidence: string;
73
+ readonly rationale: string;
74
+ readonly suggested_next_tool: "kb_suggest_predicates";
75
+ readonly recommendedPredicateSchema: {
76
+ readonly predicate_name: string;
77
+ readonly argument_names: readonly string[];
78
+ readonly argument_types: readonly string[];
79
+ } | null;
80
+ readonly applyPlan: readonly Readonly<Record<string, unknown>>[];
81
+ };
82
+ export interface SemanticAdvisorReceipt {
83
+ readonly version: string;
84
+ readonly payload_hash: string;
85
+ readonly logic_readiness: SemanticAdvisorReadiness;
86
+ readonly candidate_lane: SemanticAdvisorLane;
87
+ readonly signals: readonly SemanticSignal[];
88
+ readonly ambiguity_witnesses: readonly SemanticAmbiguityWitness[];
89
+ readonly suggestions: readonly SemanticModelingSuggestion[];
90
+ readonly clauses: readonly {
91
+ readonly claim_key: string;
92
+ readonly text: string;
93
+ readonly index: number;
94
+ readonly normative: boolean;
95
+ readonly source: "detected" | "supplied";
96
+ readonly suggestion_indexes: readonly number[];
97
+ }[];
98
+ readonly logic_coverage: {
99
+ readonly status: SemanticLogicCoverageStatus;
100
+ readonly expected_claim_keys: readonly string[];
101
+ readonly declared_claim_keys: readonly string[];
102
+ readonly missing_claim_keys: readonly string[];
103
+ readonly unresolved_claim_keys: readonly string[];
104
+ };
105
+ readonly suggested_next_tools: readonly string[];
106
+ readonly summary: string;
107
+ }
108
+ export interface SemanticAdvisorInput {
109
+ readonly payload: Readonly<Record<string, unknown>>;
110
+ readonly clauses?: readonly string[];
111
+ }
112
+ export interface SemanticAdvisorAnalysisResult {
113
+ readonly receipt: SemanticAdvisorReceipt;
114
+ readonly warnings: readonly string[];
115
+ }
116
+ export interface SemanticAdvisorArgs {
117
+ readonly text: string;
118
+ readonly clauses?: readonly string[];
119
+ readonly type?: string;
120
+ readonly id?: string;
121
+ readonly title?: string;
122
+ readonly source?: string;
123
+ readonly status?: string;
124
+ }
125
+ export interface SemanticAdvisorOperationResult {
126
+ readonly content: readonly {
127
+ readonly type: "text";
128
+ readonly text: string;
129
+ }[];
130
+ readonly structuredContent: {
131
+ readonly receipt: SemanticAdvisorReceipt;
132
+ readonly warnings: readonly string[];
133
+ };
134
+ }
135
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/semantic-advisor/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAC3B,iBAAiB,GACjB,WAAW,GACX,oBAAoB,GACpB,MAAM,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAChC,SAAS,GACT,gBAAgB,GAChB,gBAAgB,CAAC;AACrB,MAAM,MAAM,2BAA2B,GACnC,UAAU,GACV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EAAE,MAAM,GAAG,MAAM,EAAE,CAenD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAmBlE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAoBzE;AAuDD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,EAAE,CA6DjE"}
@@ -138,7 +138,7 @@ export function parseEntityFromList(data) {
138
138
  return { ...props, id: normalizeEntityId(stripOuterQuotes(id)), type };
139
139
  }
140
140
  export function parsePropertyList(propsStr) {
141
- // implements REQ-009
141
+ // implements REQ-009, REQ-skillopt-logical-evidence-fidelity
142
142
  const props = {};
143
143
  let cleaned = propsStr.trim();
144
144
  if (cleaned.startsWith("[")) {
@@ -158,7 +158,14 @@ export function parsePropertyList(propsStr) {
158
158
  continue;
159
159
  }
160
160
  const parsed = parsePrologValue(value);
161
- props[key] = parsed;
161
+ if (!Object.hasOwn(props, key)) {
162
+ props[key] = parsed;
163
+ continue;
164
+ }
165
+ const existing = props[key];
166
+ props[key] = Array.isArray(existing)
167
+ ? [...existing, parsed]
168
+ : [existing, parsed];
162
169
  }
163
170
  return props;
164
171
  }
package/dist/prolog.d.ts CHANGED
@@ -13,7 +13,10 @@ export declare class PrologProcess {
13
13
  private swiplPath;
14
14
  private timeout;
15
15
  private outputBuffer;
16
+ private outputBufferBytes;
17
+ private outputOverflowed;
16
18
  private errorBuffer;
19
+ private errorBufferBytes;
17
20
  private cache;
18
21
  private interactiveQueryTail;
19
22
  private terminationPromise;
@@ -32,6 +35,8 @@ export declare class PrologProcess {
32
35
  private execOneShot;
33
36
  private normalizeGoal;
34
37
  private clearQueryBuffers;
38
+ private appendOutputChunk;
39
+ private appendErrorChunk;
35
40
  private isProcessUsable;
36
41
  private extractBindings;
37
42
  private translateError;
@@ -1 +1 @@
1
- {"version":3,"file":"prolog.d.ts","sourceRoot":"","sources":["../src/prolog.ts"],"names":[],"mappings":"AA4BA,wBAAgB,eAAe,IAAI,MAAM,CAsCxC;AACD,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,aAAa;IACxB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,WAAW,CAAM;IACzB,OAAO,CAAC,KAAK,CAAuC;IACpD,OAAO,CAAC,oBAAoB,CAAoC;IAChE,OAAO,CAAC,kBAAkB,CAA8B;IACxD,OAAO,CAAC,cAAc,CACyC;IAC/D,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,aAAa,CAA6B;gBAEtC,OAAO,GAAE,aAAkB;IAKjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAuCd,YAAY;IA2CpB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAyK1D,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,kBAAkB;YAIZ,YA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,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC;IAgL1D,eAAe,IAAI,IAAI;IAIvB,OAAO,CAAC,eAAe;IAavB,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,kBAAkB;YAIZ,YAAY;IA2C1B,OAAO,CAAC,WAAW;IA+GnB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,iBAAiB;IAQzB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,eAAe;IAkBvB,OAAO,CAAC,cAAc;IA6DtB,SAAS,IAAI,OAAO;IAMpB,MAAM,IAAI,MAAM;IAIV,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CAwCjC"}
package/dist/prolog.js CHANGED
@@ -22,6 +22,9 @@ import path from "node:path";
22
22
  import { fileURLToPath } from "node:url";
23
23
  import { getKbPlPathOverride, isPrologDebugEnabled } from "./env.js";
24
24
  const importMetaDir = path.dirname(fileURLToPath(import.meta.url));
25
+ const PROLOG_OUTPUT_MAX_BUFFER_BYTES = 8 * 1024 * 1024;
26
+ const PROLOG_OUTPUT_OVERFLOW_ERROR = "Query exceeded bounded Prolog output capacity (ENOBUFS); narrow the operation or reduce stored entity size";
27
+ const INTERACTIVE_QUERY_FRAME_END = "__KIBI_QUERY_FRAME_END__";
25
28
  const require = createRequire(import.meta.url);
26
29
  export function resolveKbPlPath() {
27
30
  // implements REQ-009
@@ -64,7 +67,10 @@ export class PrologProcess {
64
67
  swiplPath;
65
68
  timeout;
66
69
  outputBuffer = "";
70
+ outputBufferBytes = 0;
71
+ outputOverflowed = false;
67
72
  errorBuffer = "";
73
+ errorBufferBytes = 0;
68
74
  cache = new Map();
69
75
  interactiveQueryTail = Promise.resolve();
70
76
  terminationPromise = null;
@@ -90,10 +96,10 @@ export class PrologProcess {
90
96
  throw new Error("Failed to spawn Prolog process");
91
97
  }
92
98
  this.process.stdout.on("data", (chunk) => {
93
- this.outputBuffer += chunk.toString();
99
+ this.appendOutputChunk(chunk);
94
100
  });
95
101
  this.process.stderr.on("data", (chunk) => {
96
- this.errorBuffer += chunk.toString();
102
+ this.appendErrorChunk(chunk);
97
103
  });
98
104
  this.process.stdin.write("true.\n");
99
105
  if (!this.onProcessExit) {
@@ -118,8 +124,7 @@ export class PrologProcess {
118
124
  throw new Error(`Failed to load kb module: ${this.translateError(this.errorBuffer)}`);
119
125
  }
120
126
  if (this.outputBuffer.includes("true.")) {
121
- this.outputBuffer = "";
122
- this.errorBuffer = "";
127
+ this.clearQueryBuffers();
123
128
  return;
124
129
  }
125
130
  // brief pause
@@ -130,8 +135,7 @@ export class PrologProcess {
130
135
  if (this.errorBuffer.includes("ERROR")) {
131
136
  throw new Error(`Failed to load kb module: ${this.translateError(this.errorBuffer)}`);
132
137
  }
133
- this.outputBuffer = "";
134
- this.errorBuffer = "";
138
+ this.clearQueryBuffers();
135
139
  }
136
140
  // implements REQ-core-prolog-process-management
137
141
  async query(goal) {
@@ -172,7 +176,7 @@ export class PrologProcess {
172
176
  if (debug) {
173
177
  console.error(`[prolog debug] start query: ${normalizedGoal}`);
174
178
  }
175
- this.process?.stdin?.write(`${wrappedGoal}.\n`);
179
+ this.process?.stdin?.write(`${wrappedGoal}.\nwriteln('${INTERACTIVE_QUERY_FRAME_END}').\n`);
176
180
  return new Promise((resolve, reject) => {
177
181
  let settled = false;
178
182
  const timeoutId = setTimeout(() => {
@@ -193,6 +197,28 @@ export class PrologProcess {
193
197
  if (settled) {
194
198
  return;
195
199
  }
200
+ if (this.outputOverflowed) {
201
+ clearTimeout(timeoutId);
202
+ settled = true;
203
+ void this.terminate().finally(() => {
204
+ resolve({
205
+ success: false,
206
+ bindings: {},
207
+ error: PROLOG_OUTPUT_OVERFLOW_ERROR,
208
+ });
209
+ });
210
+ return;
211
+ }
212
+ if (!this.isProcessUsable()) {
213
+ clearTimeout(timeoutId);
214
+ settled = true;
215
+ resolve({
216
+ success: false,
217
+ bindings: {},
218
+ error: "Query interrupted because the Prolog process terminated",
219
+ });
220
+ return;
221
+ }
196
222
  if (this.errorBuffer.length > 0 &&
197
223
  this.errorBuffer.includes("ERROR")) {
198
224
  clearTimeout(timeoutId);
@@ -207,14 +233,22 @@ export class PrologProcess {
207
233
  });
208
234
  return;
209
235
  }
210
- if (this.outputBuffer.includes("true.") ||
211
- this.outputBuffer.match(/^[A-Z_][A-Za-z0-9_]*\s*=\s*.+\./m) ||
212
- this.outputBuffer.match(/\]\s*$/m)) {
236
+ const frameEnd = this.outputBuffer.indexOf(INTERACTIVE_QUERY_FRAME_END);
237
+ if (frameEnd >= 0) {
213
238
  clearTimeout(timeoutId);
214
239
  settled = true;
240
+ const framedOutput = this.outputBuffer.slice(0, frameEnd).trimEnd();
241
+ if (/(?:^|\n)(?:false|fail)\.\s*$/.test(framedOutput)) {
242
+ resolve({
243
+ success: false,
244
+ bindings: {},
245
+ error: "Query failed",
246
+ });
247
+ return;
248
+ }
215
249
  const result = {
216
250
  success: true,
217
- bindings: this.extractBindings(this.outputBuffer),
251
+ bindings: this.extractBindings(framedOutput),
218
252
  };
219
253
  // Treat any batch/compound goal as non-cacheable to preserve
220
254
  // read-after-write consistency. A batch goal is produced when
@@ -234,25 +268,6 @@ export class PrologProcess {
234
268
  resolve(result);
235
269
  return;
236
270
  }
237
- if (this.outputBuffer.includes("false.") ||
238
- this.outputBuffer.includes("fail.")) {
239
- clearTimeout(timeoutId);
240
- settled = true;
241
- if (debug) {
242
- console.error(`[prolog debug] query failed (false): ${normalizedGoal}`);
243
- }
244
- // Check errorBuffer first — Prolog catch/3 writes ERROR to stderr
245
- // then fail to stdout. If stderr has the real error, surface it.
246
- const errorMessage = this.errorBuffer.length > 0 && this.errorBuffer.includes("ERROR")
247
- ? this.translateError(this.errorBuffer)
248
- : "Query failed";
249
- resolve({
250
- success: false,
251
- bindings: {},
252
- error: errorMessage,
253
- });
254
- return;
255
- }
256
271
  setTimeout(checkResult, 50);
257
272
  };
258
273
  checkResult();
@@ -369,6 +384,7 @@ export class PrologProcess {
369
384
  const result = spawnSync(this.swiplPath, ["-q", "-g", prologGoal, "-t", "halt"], {
370
385
  encoding: "utf8",
371
386
  timeout: this.timeout,
387
+ maxBuffer: PROLOG_OUTPUT_MAX_BUFFER_BYTES,
372
388
  env: {
373
389
  ...process.env,
374
390
  KIBI_GOAL: combinedGoal,
@@ -382,6 +398,13 @@ export class PrologProcess {
382
398
  result.error.message.includes("ETIMEDOUT"))) {
383
399
  throw new Error(`Query timeout after ${this.timeout / 1000}s`);
384
400
  }
401
+ if (result.error?.message.includes("ENOBUFS")) {
402
+ return {
403
+ success: false,
404
+ bindings: {},
405
+ error: PROLOG_OUTPUT_OVERFLOW_ERROR,
406
+ };
407
+ }
385
408
  const stdout = result.stdout ?? "";
386
409
  const stderr = result.stderr ?? "";
387
410
  if (stderr.includes("ERROR")) {
@@ -419,7 +442,36 @@ export class PrologProcess {
419
442
  }
420
443
  clearQueryBuffers() {
421
444
  this.outputBuffer = "";
445
+ this.outputBufferBytes = 0;
446
+ this.outputOverflowed = false;
422
447
  this.errorBuffer = "";
448
+ this.errorBufferBytes = 0;
449
+ }
450
+ appendOutputChunk(chunk) {
451
+ if (this.outputOverflowed)
452
+ return;
453
+ const remaining = PROLOG_OUTPUT_MAX_BUFFER_BYTES - this.outputBufferBytes;
454
+ if (chunk.byteLength > remaining) {
455
+ this.outputBuffer += chunk.subarray(0, remaining).toString();
456
+ this.outputBufferBytes = PROLOG_OUTPUT_MAX_BUFFER_BYTES;
457
+ this.outputOverflowed = true;
458
+ return;
459
+ }
460
+ this.outputBuffer += chunk.toString();
461
+ this.outputBufferBytes += chunk.byteLength;
462
+ }
463
+ appendErrorChunk(chunk) {
464
+ if (this.outputOverflowed)
465
+ return;
466
+ const remaining = PROLOG_OUTPUT_MAX_BUFFER_BYTES - this.errorBufferBytes;
467
+ if (chunk.byteLength > remaining) {
468
+ this.errorBuffer += chunk.subarray(0, remaining).toString();
469
+ this.errorBufferBytes = PROLOG_OUTPUT_MAX_BUFFER_BYTES;
470
+ this.outputOverflowed = true;
471
+ return;
472
+ }
473
+ this.errorBuffer += chunk.toString();
474
+ this.errorBufferBytes += chunk.byteLength;
423
475
  }
424
476
  // implements REQ-009
425
477
  isProcessUsable() {
@@ -1 +1 @@
1
- {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAWrF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AAoFpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CA+CxB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAsBxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
1
+ {"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../../src/public/impact/diagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAWrF,OAAO,KAAK,EACV,iBAAiB,EACjB,gCAAgC,EAChC,mCAAmC,EACpC,MAAM,YAAY,CAAC;AA2FpB,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,mCAAmC,GAC3C,oBAAoB,EAAE,CA+CxB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,gCAAgC,GACxC,oBAAoB,EAAE,CAsBxB;AAED,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,SAAS,oBAAoB,EAAE,GAC3C,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,SAAS,iBAAiB,EAAE,GACxC,OAAO,CAIT"}
@@ -38,8 +38,12 @@ function readSourceSymbols(sourceFile, sourceContentByFile, workspaceRoot) {
38
38
  });
39
39
  }
40
40
  function getGranularSymbolsForSourceFile(sourceFile, options) {
41
- return (options.symbolsByFile.get(sourceFile) ??
42
- readSourceSymbols(sourceFile, options.sourceContentByFile, options.workspaceRoot ?? process.cwd()));
41
+ const sourceSymbols = readSourceSymbols(sourceFile, options.sourceContentByFile, options.workspaceRoot ?? process.cwd());
42
+ const changedSymbols = options.symbolsByFile.get(sourceFile);
43
+ return {
44
+ candidateSymbols: changedSymbols ?? sourceSymbols,
45
+ sourceSymbols: sourceSymbols.length > 0 ? sourceSymbols : (changedSymbols ?? []),
46
+ };
43
47
  }
44
48
  function formatRelationshipTargets(symbol) {
45
49
  const targets = [
@@ -69,8 +73,8 @@ export function createSymbolGranularityDiagnostics(options) {
69
73
  continue;
70
74
  if (hasValidGranularityReason(result))
71
75
  continue;
72
- const granularSymbols = getGranularSymbolsForSourceFile(result.sourceFile, options);
73
- const narrowerSymbols = granularSymbols.filter((symbol) => isNarrowerSymbol(result.entity.title, symbol, granularSymbols));
76
+ const { candidateSymbols, sourceSymbols } = getGranularSymbolsForSourceFile(result.sourceFile, options);
77
+ const narrowerSymbols = candidateSymbols.filter((symbol) => isNarrowerSymbol(result.entity.title, symbol, sourceSymbols));
74
78
  if (narrowerSymbols.length === 0)
75
79
  continue;
76
80
  const behavioralNames = getBehavioralSymbolNames(narrowerSymbols);
@@ -1,7 +1,7 @@
1
1
  import type { PrologProcess } from "../../prolog.js";
2
2
  import type { QualityDiagnostic } from "./types.js";
3
3
  type FullKbQualityDiagnosticsOptions = {
4
- readonly prolog: PrologProcess;
4
+ readonly prolog: Pick<PrologProcess, "query">;
5
5
  readonly hardViolationEntityIds?: ReadonlySet<string>;
6
6
  readonly maxDiagnostics?: number;
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqBpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AA+IF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAmBvC"}
1
+ {"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqBpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AA0KF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAmBvC"}
@@ -63,6 +63,9 @@ function toExtractedEntity(entity) {
63
63
  const textRef = optionalStringField(entity, "text_ref");
64
64
  if (textRef !== undefined)
65
65
  extracted.text_ref = textRef;
66
+ const logicClaims = optionalStringArrayField(entity, "logic_claims");
67
+ if (logicClaims !== undefined)
68
+ extracted.logic_claims = logicClaims;
66
69
  const granularityReason = optionalStringField(entity, "granularity_reason");
67
70
  if (granularityReason !== undefined) {
68
71
  extracted.granularity_reason = granularityReason;
@@ -95,9 +98,39 @@ function toExtractedEntity(entity) {
95
98
  if (factKind === "subject" ||
96
99
  factKind === "property_value" ||
97
100
  factKind === "observation" ||
98
- factKind === "meta") {
101
+ factKind === "meta" ||
102
+ factKind === "predicate_schema" ||
103
+ factKind === "predicate") {
99
104
  extracted.fact_kind = factKind;
100
105
  }
106
+ const claimKey = optionalStringField(entity, "claim_key");
107
+ if (claimKey !== undefined)
108
+ extracted.claim_key = claimKey;
109
+ const claimText = optionalStringField(entity, "claim_text");
110
+ if (claimText !== undefined)
111
+ extracted.claim_text = claimText;
112
+ const predicateName = optionalStringField(entity, "predicate_name");
113
+ if (predicateName !== undefined)
114
+ extracted.predicate_name = predicateName;
115
+ const predicateNamespace = optionalStringField(entity, "predicate_namespace");
116
+ if (predicateNamespace !== undefined) {
117
+ extracted.predicate_namespace = predicateNamespace;
118
+ }
119
+ const predicateArity = optionalNumberField(entity, "predicate_arity");
120
+ if (predicateArity !== undefined)
121
+ extracted.predicate_arity = predicateArity;
122
+ for (const field of [
123
+ "argument_names",
124
+ "argument_types",
125
+ "argument_descriptions",
126
+ "aliases",
127
+ "examples",
128
+ "predicate_args",
129
+ ]) {
130
+ const values = optionalStringArrayField(entity, field);
131
+ if (values !== undefined)
132
+ extracted[field] = values;
133
+ }
101
134
  return extracted;
102
135
  }
103
136
  function sourceFileFor(entity) {
@@ -1 +1 @@
1
- {"version":3,"file":"requirement-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/requirement-quality.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AA+QvE,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,oCAAoC,GAC5C,oBAAoB,EAAE,CAMxB"}
1
+ {"version":3,"file":"requirement-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/requirement-quality.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,YAAY,CAAC;AA2PvE,wBAAgB,mCAAmC,CACjD,OAAO,EAAE,oCAAoC,GAC5C,oBAAoB,EAAE,CAMxB"}