kibi-cli 0.19.0 → 1.0.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 (506) hide show
  1. package/dist/cli-operation-loader.d.ts.map +1 -1
  2. package/dist/cli-operation-loader.js +53 -20
  3. package/dist/cli-operation-metadata.d.ts +20 -8
  4. package/dist/cli-operation-metadata.d.ts.map +1 -1
  5. package/dist/cli-operation-metadata.js +23 -8
  6. package/dist/cli-protocol.d.ts.map +1 -1
  7. package/dist/cli-protocol.js +38 -8
  8. package/dist/cli-register-foundation.d.ts.map +1 -1
  9. package/dist/cli-register-foundation.js +14 -2
  10. package/dist/cli-register-maintenance.d.ts.map +1 -1
  11. package/dist/cli-register-maintenance.js +26 -4
  12. package/dist/cli-register-reporting.d.ts.map +1 -1
  13. package/dist/cli-register-reporting.js +10 -0
  14. package/dist/cli-register-verification.d.ts +3 -0
  15. package/dist/cli-register-verification.d.ts.map +1 -0
  16. package/dist/cli-register-verification.js +16 -0
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +2 -0
  19. package/dist/commands/aggregated-checks.d.ts +1 -2
  20. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  21. package/dist/commands/aggregated-checks.js +14 -9
  22. package/dist/commands/branch.d.ts +36 -0
  23. package/dist/commands/branch.d.ts.map +1 -1
  24. package/dist/commands/branch.js +371 -40
  25. package/dist/commands/check.d.ts.map +1 -1
  26. package/dist/commands/check.js +20 -67
  27. package/dist/commands/discovery-shared.d.ts.map +1 -1
  28. package/dist/commands/discovery-shared.js +10 -19
  29. package/dist/commands/doctor.d.ts +4 -1
  30. package/dist/commands/doctor.d.ts.map +1 -1
  31. package/dist/commands/doctor.js +259 -24
  32. package/dist/commands/engine.d.ts.map +1 -1
  33. package/dist/commands/engine.js +10 -7
  34. package/dist/commands/gc.d.ts +5 -2
  35. package/dist/commands/gc.d.ts.map +1 -1
  36. package/dist/commands/gc.js +140 -71
  37. package/dist/commands/github-init.d.ts +56 -0
  38. package/dist/commands/github-init.d.ts.map +1 -0
  39. package/dist/commands/github-init.js +310 -0
  40. package/dist/commands/init-helpers.d.ts +1 -1
  41. package/dist/commands/init-helpers.d.ts.map +1 -1
  42. package/dist/commands/init-helpers.js +73 -25
  43. package/dist/commands/init.d.ts +2 -0
  44. package/dist/commands/init.d.ts.map +1 -1
  45. package/dist/commands/init.js +79 -24
  46. package/dist/commands/legacy-storage-migration.d.ts +54 -0
  47. package/dist/commands/legacy-storage-migration.d.ts.map +1 -0
  48. package/dist/commands/legacy-storage-migration.js +277 -0
  49. package/dist/commands/migrate.d.ts +7 -0
  50. package/dist/commands/migrate.d.ts.map +1 -1
  51. package/dist/commands/migrate.js +244 -91
  52. package/dist/commands/report.d.ts +24 -0
  53. package/dist/commands/report.d.ts.map +1 -0
  54. package/dist/commands/report.js +191 -0
  55. package/dist/commands/sync/cache.d.ts +16 -3
  56. package/dist/commands/sync/cache.d.ts.map +1 -1
  57. package/dist/commands/sync/cache.js +111 -4
  58. package/dist/commands/sync/discovery.d.ts +23 -2
  59. package/dist/commands/sync/discovery.d.ts.map +1 -1
  60. package/dist/commands/sync/discovery.js +196 -15
  61. package/dist/commands/sync/extraction.d.ts +8 -1
  62. package/dist/commands/sync/extraction.d.ts.map +1 -1
  63. package/dist/commands/sync/extraction.js +38 -4
  64. package/dist/commands/sync/manifest.d.ts +8 -5
  65. package/dist/commands/sync/manifest.d.ts.map +1 -1
  66. package/dist/commands/sync/manifest.js +142 -39
  67. package/dist/commands/sync/persistence.d.ts.map +1 -1
  68. package/dist/commands/sync/persistence.js +3 -0
  69. package/dist/commands/sync.d.ts +6 -0
  70. package/dist/commands/sync.d.ts.map +1 -1
  71. package/dist/commands/sync.js +304 -79
  72. package/dist/commands/verify.d.ts +10 -0
  73. package/dist/commands/verify.d.ts.map +1 -0
  74. package/dist/commands/verify.js +126 -0
  75. package/dist/diagnostics.d.ts +1 -1
  76. package/dist/diagnostics.d.ts.map +1 -1
  77. package/dist/engine.d.ts +96 -3
  78. package/dist/engine.d.ts.map +1 -1
  79. package/dist/engine.js +392 -23
  80. package/dist/env.d.ts.map +1 -1
  81. package/dist/env.js +5 -6
  82. package/dist/extractors/manifest.d.ts +8 -1
  83. package/dist/extractors/manifest.d.ts.map +1 -1
  84. package/dist/extractors/manifest.js +51 -9
  85. package/dist/extractors/markdown.d.ts +2 -1
  86. package/dist/extractors/markdown.d.ts.map +1 -1
  87. package/dist/extractors/markdown.js +21 -3
  88. package/dist/extractors/playwright-cases.d.ts +24 -0
  89. package/dist/extractors/playwright-cases.d.ts.map +1 -0
  90. package/dist/extractors/playwright-cases.js +126 -0
  91. package/dist/extractors/relationships.d.ts.map +1 -1
  92. package/dist/extractors/relationships.js +1 -0
  93. package/dist/extractors/symbol-coordinates.d.ts +81 -3
  94. package/dist/extractors/symbol-coordinates.d.ts.map +1 -1
  95. package/dist/extractors/symbol-coordinates.js +389 -51
  96. package/dist/extractors/symbols-coordinator.js +11 -1
  97. package/dist/intent-search.d.ts +60 -0
  98. package/dist/intent-search.d.ts.map +1 -0
  99. package/dist/intent-search.js +433 -0
  100. package/dist/operations/bootstrap/activation.d.ts.map +1 -0
  101. package/dist/operations/{autopilot → bootstrap}/activation.js +48 -31
  102. package/dist/operations/{autopilot → bootstrap}/candidate-helpers.d.ts.map +1 -1
  103. package/dist/operations/bootstrap/candidates.d.ts +4 -0
  104. package/dist/operations/{autopilot → bootstrap}/candidates.d.ts.map +1 -1
  105. package/dist/operations/{autopilot → bootstrap}/candidates.js +22 -8
  106. package/dist/operations/{autopilot → bootstrap}/discovery-evidence.d.ts +2 -2
  107. package/dist/operations/{autopilot → bootstrap}/discovery-evidence.d.ts.map +1 -1
  108. package/dist/operations/{autopilot → bootstrap}/discovery-evidence.js +46 -6
  109. package/dist/operations/{autopilot → bootstrap}/discovery.d.ts +1 -1
  110. package/dist/operations/bootstrap/discovery.d.ts.map +1 -0
  111. package/dist/operations/{autopilot → bootstrap}/discovery.js +21 -14
  112. package/dist/operations/bootstrap/generate.d.ts +8 -0
  113. package/dist/operations/bootstrap/generate.d.ts.map +1 -0
  114. package/dist/operations/bootstrap/generate.js +204 -0
  115. package/dist/operations/{autopilot → bootstrap}/guidance-actions.d.ts +2 -2
  116. package/dist/operations/{autopilot → bootstrap}/guidance-actions.d.ts.map +1 -1
  117. package/dist/operations/{autopilot → bootstrap}/guidance-actions.js +4 -4
  118. package/dist/operations/{autopilot → bootstrap}/guidance.d.ts +2 -2
  119. package/dist/operations/{autopilot → bootstrap}/guidance.d.ts.map +1 -1
  120. package/dist/operations/{autopilot → bootstrap}/guidance.js +2 -0
  121. package/dist/operations/{autopilot → bootstrap}/markdown-candidates.d.ts +2 -2
  122. package/dist/operations/{autopilot → bootstrap}/markdown-candidates.d.ts.map +1 -1
  123. package/dist/operations/{autopilot → bootstrap}/markdown-candidates.js +4 -3
  124. package/dist/operations/bootstrap/presentation.d.ts +15 -0
  125. package/dist/operations/bootstrap/presentation.d.ts.map +1 -0
  126. package/dist/operations/bootstrap/presentation.js +177 -0
  127. package/dist/operations/{autopilot → bootstrap}/requirement-claims.d.ts.map +1 -1
  128. package/dist/operations/{autopilot → bootstrap}/types.d.ts +63 -21
  129. package/dist/operations/bootstrap/types.d.ts.map +1 -0
  130. package/dist/operations/bootstrap/types.js +25 -0
  131. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  132. package/dist/operations/modeling/model-requirement.js +4 -17
  133. package/dist/operations/modeling/predicate-applicability.d.ts +16 -0
  134. package/dist/operations/modeling/predicate-applicability.d.ts.map +1 -0
  135. package/dist/operations/modeling/predicate-applicability.js +276 -0
  136. package/dist/operations/modeling/predicate-applyplan.d.ts +13 -2
  137. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  138. package/dist/operations/modeling/predicate-applyplan.js +100 -3
  139. package/dist/operations/modeling/predicate-bindings.d.ts +6 -0
  140. package/dist/operations/modeling/predicate-bindings.d.ts.map +1 -0
  141. package/dist/operations/modeling/predicate-bindings.js +122 -0
  142. package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -1
  143. package/dist/operations/modeling/predicate-catalog-4.js +155 -0
  144. package/dist/operations/modeling/predicate-inference-1.d.ts.map +1 -1
  145. package/dist/operations/modeling/predicate-inference-1.js +8 -0
  146. package/dist/operations/modeling/predicate-inference-launcher.d.ts +10 -0
  147. package/dist/operations/modeling/predicate-inference-launcher.d.ts.map +1 -0
  148. package/dist/operations/modeling/predicate-inference-launcher.js +13 -0
  149. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  150. package/dist/operations/modeling/predicate-inference.js +4 -0
  151. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  152. package/dist/operations/modeling/predicate-loader.js +7 -0
  153. package/dist/operations/modeling/predicate-ranker.d.ts +8 -1
  154. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
  155. package/dist/operations/modeling/predicate-ranker.js +156 -24
  156. package/dist/operations/modeling/predicate-score-3.d.ts.map +1 -1
  157. package/dist/operations/modeling/predicate-score-3.js +6 -0
  158. package/dist/operations/modeling/predicate-types.d.ts +34 -0
  159. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  160. package/dist/operations/modeling/predicate-usage-hints-3.d.ts.map +1 -1
  161. package/dist/operations/modeling/predicate-usage-hints-3.js +40 -0
  162. package/dist/operations/modeling/predicate-utils.d.ts.map +1 -1
  163. package/dist/operations/modeling/predicate-utils.js +2 -0
  164. package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
  165. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  166. package/dist/operations/modeling/suggest-predicates.js +170 -32
  167. package/dist/operations/mutation/delete.d.ts.map +1 -1
  168. package/dist/operations/mutation/delete.js +415 -19
  169. package/dist/operations/mutation/entity-projection.d.ts +11 -0
  170. package/dist/operations/mutation/entity-projection.d.ts.map +1 -0
  171. package/dist/operations/mutation/entity-projection.js +14 -0
  172. package/dist/operations/mutation/relationships.d.ts +10 -0
  173. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  174. package/dist/operations/mutation/relationships.js +71 -1
  175. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  176. package/dist/operations/mutation/serialization.js +1 -0
  177. package/dist/operations/mutation/source-authoring.d.ts +61 -0
  178. package/dist/operations/mutation/source-authoring.d.ts.map +1 -0
  179. package/dist/operations/mutation/source-authoring.js +543 -0
  180. package/dist/operations/mutation/symbol-compiler-lock.d.ts +51 -0
  181. package/dist/operations/mutation/symbol-compiler-lock.d.ts.map +1 -0
  182. package/dist/operations/mutation/symbol-compiler-lock.js +274 -0
  183. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  184. package/dist/operations/mutation/symbol-granularity.js +34 -3
  185. package/dist/operations/mutation/symbol-refresh.d.ts +18 -1
  186. package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
  187. package/dist/operations/mutation/symbol-refresh.js +225 -63
  188. package/dist/operations/mutation/types.d.ts +57 -1
  189. package/dist/operations/mutation/types.d.ts.map +1 -1
  190. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  191. package/dist/operations/mutation/upsert.js +363 -24
  192. package/dist/operations/mutation/validation.d.ts.map +1 -1
  193. package/dist/operations/mutation/validation.js +1 -0
  194. package/dist/operations/planning/apply-plan.d.ts +117 -0
  195. package/dist/operations/planning/apply-plan.d.ts.map +1 -0
  196. package/dist/operations/planning/apply-plan.js +1437 -0
  197. package/dist/operations/planning/compile-intent.d.ts +106 -0
  198. package/dist/operations/planning/compile-intent.d.ts.map +1 -0
  199. package/dist/operations/planning/compile-intent.js +562 -0
  200. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  201. package/dist/operations/semantic-advisor/analyze-prose.js +6 -2
  202. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  203. package/dist/operations/semantic-advisor/clauses.js +15 -2
  204. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -1
  205. package/dist/operations/semantic-advisor/ingestion-boundary.js +7 -3
  206. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +51 -0
  207. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -0
  208. package/dist/operations/semantic-advisor/predicate-rules-launcher.js +96 -0
  209. package/dist/operations/semantic-advisor/types.d.ts +13 -5
  210. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  211. package/dist/operations/verification/ingest-verification.d.ts +29 -0
  212. package/dist/operations/verification/ingest-verification.d.ts.map +1 -0
  213. package/dist/operations/verification/ingest-verification.js +192 -0
  214. package/dist/prolog/codec.d.ts.map +1 -1
  215. package/dist/prolog/codec.js +2 -1
  216. package/dist/prolog.d.ts.map +1 -1
  217. package/dist/prolog.js +27 -8
  218. package/dist/public/branch-resolver.d.ts +1 -0
  219. package/dist/public/branch-resolver.d.ts.map +1 -1
  220. package/dist/public/branch-resolver.js +1 -0
  221. package/dist/public/check-types.d.ts +2 -2
  222. package/dist/public/check-types.d.ts.map +1 -1
  223. package/dist/public/check-types.js +16 -16
  224. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  225. package/dist/public/diagnostic-usage.js +69 -1
  226. package/dist/public/distribution-parity.d.ts +1 -1
  227. package/dist/public/distribution-parity.d.ts.map +1 -1
  228. package/dist/public/distribution-parity.js +1 -0
  229. package/dist/public/ignore-policy.d.ts.map +1 -1
  230. package/dist/public/ignore-policy.js +16 -4
  231. package/dist/public/impact/coverage-depth-quality.d.ts +6 -1
  232. package/dist/public/impact/coverage-depth-quality.d.ts.map +1 -1
  233. package/dist/public/impact/coverage-depth-quality.js +21 -3
  234. package/dist/public/impact/full-kb-quality.d.ts +4 -2
  235. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  236. package/dist/public/impact/full-kb-quality.js +61 -1
  237. package/dist/public/impact/manifest.d.ts.map +1 -1
  238. package/dist/public/impact/manifest.js +2 -5
  239. package/dist/public/operational-artifacts.d.ts.map +1 -1
  240. package/dist/public/operational-artifacts.js +7 -1
  241. package/dist/public/operations/catalog.d.ts +682 -67
  242. package/dist/public/operations/catalog.d.ts.map +1 -1
  243. package/dist/public/operations/catalog.js +126 -4
  244. package/dist/public/operations/check-executor.d.ts +2 -2
  245. package/dist/public/operations/check-executor.d.ts.map +1 -1
  246. package/dist/public/operations/check-executor.js +72 -13
  247. package/dist/public/operations/check-format-shared.d.ts +3 -0
  248. package/dist/public/operations/check-format-shared.d.ts.map +1 -1
  249. package/dist/public/operations/check-format-shared.js +3 -0
  250. package/dist/public/operations/check-helpers.d.ts +27 -2
  251. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  252. package/dist/public/operations/check-helpers.js +62 -26
  253. package/dist/public/operations/contracts.d.ts +11 -0
  254. package/dist/public/operations/contracts.d.ts.map +1 -0
  255. package/dist/public/operations/contracts.js +325 -0
  256. package/dist/public/operations/discovery-executors.d.ts +37 -1
  257. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  258. package/dist/public/operations/discovery-executors.js +206 -6
  259. package/dist/public/operations/index.d.ts +9 -4
  260. package/dist/public/operations/index.d.ts.map +1 -1
  261. package/dist/public/operations/index.js +8 -3
  262. package/dist/public/operations/migration-plan.d.ts +101 -0
  263. package/dist/public/operations/migration-plan.d.ts.map +1 -0
  264. package/dist/public/operations/migration-plan.js +537 -0
  265. package/dist/public/operations/node-ports.d.ts.map +1 -1
  266. package/dist/public/operations/node-ports.js +68 -8
  267. package/dist/public/operations/prolog-json.d.ts +14 -0
  268. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  269. package/dist/public/operations/prolog-json.js +44 -5
  270. package/dist/public/operations/repair-plan.d.ts.map +1 -1
  271. package/dist/public/operations/repair-plan.js +1 -0
  272. package/dist/public/operations/result-envelope.d.ts +13 -0
  273. package/dist/public/operations/result-envelope.d.ts.map +1 -0
  274. package/dist/public/operations/result-envelope.js +104 -0
  275. package/dist/public/operations/runtime-types.d.ts +97 -7
  276. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  277. package/dist/public/operations/source-relationship-parity.d.ts +13 -0
  278. package/dist/public/operations/source-relationship-parity.d.ts.map +1 -0
  279. package/dist/public/operations/source-relationship-parity.js +162 -0
  280. package/dist/public/operations/specs/{autopilot.d.ts → bootstrap.d.ts} +9 -9
  281. package/dist/public/operations/specs/bootstrap.d.ts.map +1 -0
  282. package/dist/public/operations/specs/{autopilot.js → bootstrap.js} +8 -7
  283. package/dist/public/operations/specs/check.d.ts +4 -4
  284. package/dist/public/operations/specs/check.d.ts.map +1 -1
  285. package/dist/public/operations/specs/check.js +4 -3
  286. package/dist/public/operations/specs/discovery.d.ts +87 -3
  287. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  288. package/dist/public/operations/specs/discovery.js +53 -3
  289. package/dist/public/operations/specs/modeling.d.ts +3 -3
  290. package/dist/public/operations/specs/modeling.js +3 -3
  291. package/dist/public/operations/specs/mutation-schemas.d.ts +190 -47
  292. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  293. package/dist/public/operations/specs/mutation-schemas.js +3 -1
  294. package/dist/public/operations/specs/mutation.d.ts +42 -2
  295. package/dist/public/operations/specs/mutation.d.ts.map +1 -1
  296. package/dist/public/operations/specs/mutation.js +26 -2
  297. package/dist/public/operations/specs/planning.d.ts +270 -0
  298. package/dist/public/operations/specs/planning.d.ts.map +1 -0
  299. package/dist/public/operations/specs/planning.js +191 -0
  300. package/dist/public/operations/specs/reporting.d.ts +4 -1
  301. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  302. package/dist/public/operations/specs/reporting.js +46 -1
  303. package/dist/public/operations/specs/upsert.d.ts +204 -47
  304. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  305. package/dist/public/operations/specs/upsert.js +9 -0
  306. package/dist/public/operations/specs/verification.d.ts +78 -0
  307. package/dist/public/operations/specs/verification.d.ts.map +1 -0
  308. package/dist/public/operations/specs/verification.js +62 -0
  309. package/dist/public/operations/symbol-repair-plan.d.ts +11 -0
  310. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -0
  311. package/dist/public/operations/symbol-repair-plan.js +123 -0
  312. package/dist/public/operations/types.d.ts +52 -1
  313. package/dist/public/operations/types.d.ts.map +1 -1
  314. package/dist/public/playwright-case-id.d.ts +8 -0
  315. package/dist/public/playwright-case-id.d.ts.map +1 -0
  316. package/dist/public/playwright-case-id.js +25 -0
  317. package/dist/public/schemas/entity.d.ts.map +1 -1
  318. package/dist/public/schemas/entity.js +4 -2
  319. package/dist/public/skills/kibi-bootstrap/SKILL.md +58 -0
  320. package/dist/public/skills/kibi-bootstrap/resources/bootstrap.md +11 -0
  321. package/dist/public/skills/kibi-bootstrap/resources/branch-lifecycle.md +7 -0
  322. package/dist/public/skills/kibi-bootstrap/resources/operation-access.md +5 -0
  323. package/dist/public/skills/kibi-bootstrap/resources/source-authoring.md +8 -0
  324. package/dist/public/skills/kibi-freshness/SKILL.md +39 -9
  325. package/dist/public/skills/kibi-freshness/resources/branch-lifecycle.md +7 -0
  326. package/dist/public/skills/kibi-freshness/resources/operation-access.md +6 -0
  327. package/dist/public/skills/kibi-freshness/resources/source-authoring.md +7 -0
  328. package/dist/public/skills/kibi-traceability/SKILL.md +47 -47
  329. package/dist/public/skills/kibi-traceability/resources/branch-lifecycle.md +7 -0
  330. package/dist/public/skills/kibi-traceability/resources/operation-access.md +5 -0
  331. package/dist/public/skills/kibi-traceability/resources/source-authoring.md +6 -0
  332. package/dist/public/skills/kibi-traceability/resources/traceability.md +8 -0
  333. package/dist/public/skills/kibi-usage/SKILL.md +115 -239
  334. package/dist/public/skills/kibi-usage/resources/branch-lifecycle.md +31 -0
  335. package/dist/public/skills/kibi-usage/resources/kb-improvement.md +38 -0
  336. package/dist/public/skills/kibi-usage/resources/operation-access.md +36 -38
  337. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +3 -3
  338. package/dist/public/skills/kibi-usage/resources/source-authoring.md +31 -0
  339. package/dist/public/skills/kibi-usage/resources/workflows.md +56 -3
  340. package/dist/public/symbol-granularity.d.ts +1 -1
  341. package/dist/public/symbol-granularity.d.ts.map +1 -1
  342. package/dist/public/symbol-granularity.js +1 -0
  343. package/dist/public/telemetry-acceptance.d.ts +7 -0
  344. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  345. package/dist/public/telemetry-acceptance.js +8 -1
  346. package/dist/public/telemetry-remediation.js +1 -1
  347. package/dist/public/verification-receipt.d.ts +206 -39
  348. package/dist/public/verification-receipt.d.ts.map +1 -1
  349. package/dist/public/verification-receipt.js +171 -4
  350. package/dist/relationships/shards.d.ts +16 -0
  351. package/dist/relationships/shards.d.ts.map +1 -1
  352. package/dist/relationships/shards.js +87 -2
  353. package/dist/report/brand.d.ts +19 -0
  354. package/dist/report/brand.d.ts.map +1 -0
  355. package/dist/report/brand.js +112 -0
  356. package/dist/report/html-report.d.ts +19 -0
  357. package/dist/report/html-report.d.ts.map +1 -0
  358. package/dist/report/html-report.js +963 -0
  359. package/dist/report/relative-time.d.ts +4 -0
  360. package/dist/report/relative-time.d.ts.map +1 -0
  361. package/dist/report/relative-time.js +46 -0
  362. package/dist/report/report-view.d.ts +17 -0
  363. package/dist/report/report-view.d.ts.map +1 -0
  364. package/dist/report/report-view.js +33 -0
  365. package/dist/report/repository.d.ts +35 -0
  366. package/dist/report/repository.d.ts.map +1 -0
  367. package/dist/report/repository.js +151 -0
  368. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  369. package/dist/runtime/cli-runtime.js +82 -22
  370. package/dist/schemas/entity.schema.json +1148 -273
  371. package/dist/traceability/evidence-model.d.ts +2 -2
  372. package/dist/traceability/evidence-model.d.ts.map +1 -1
  373. package/dist/traceability/evidence-model.js +2 -2
  374. package/dist/traceability/git-staged.d.ts.map +1 -1
  375. package/dist/traceability/git-staged.js +15 -40
  376. package/dist/traceability/markdown-validate.d.ts.map +1 -1
  377. package/dist/traceability/markdown-validate.js +12 -7
  378. package/dist/traceability/staged-impact-contract.d.ts +3 -3
  379. package/dist/traceability/staged-impact-contract.d.ts.map +1 -1
  380. package/dist/traceability/staged-impact-contract.js +10 -38
  381. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  382. package/dist/traceability/staged-symbols-manifest.js +8 -3
  383. package/dist/traceability/temp-kb.d.ts.map +1 -1
  384. package/dist/traceability/temp-kb.js +3 -0
  385. package/dist/types/entities.d.ts +3 -0
  386. package/dist/types/entities.d.ts.map +1 -1
  387. package/dist/utils/branch-resolver.d.ts +24 -10
  388. package/dist/utils/branch-resolver.d.ts.map +1 -1
  389. package/dist/utils/branch-resolver.js +121 -38
  390. package/dist/utils/branch-store-locator.d.ts +23 -0
  391. package/dist/utils/branch-store-locator.d.ts.map +1 -0
  392. package/dist/utils/branch-store-locator.js +90 -0
  393. package/dist/utils/branch-store.d.ts +15 -0
  394. package/dist/utils/branch-store.d.ts.map +1 -0
  395. package/dist/utils/branch-store.js +130 -0
  396. package/dist/utils/config.d.ts +39 -37
  397. package/dist/utils/config.d.ts.map +1 -1
  398. package/dist/utils/config.js +107 -119
  399. package/dist/utils/kb-manifest.d.ts +35 -0
  400. package/dist/utils/kb-manifest.d.ts.map +1 -0
  401. package/dist/utils/kb-manifest.js +154 -0
  402. package/dist/utils/kb-paths.d.ts +54 -0
  403. package/dist/utils/kb-paths.d.ts.map +1 -0
  404. package/dist/utils/kb-paths.js +125 -0
  405. package/dist/utils/manifest-paths.d.ts +4 -4
  406. package/dist/utils/manifest-paths.d.ts.map +1 -1
  407. package/dist/utils/manifest-paths.js +8 -56
  408. package/dist/utils/rule-registry.d.ts +48 -20
  409. package/dist/utils/rule-registry.d.ts.map +1 -1
  410. package/dist/utils/rule-registry.js +82 -77
  411. package/dist/utils/schema-version.d.ts +5 -5
  412. package/dist/utils/schema-version.d.ts.map +1 -1
  413. package/dist/utils/schema-version.js +26 -6
  414. package/dist/utils/strict-modeling.d.ts +0 -4
  415. package/dist/utils/strict-modeling.d.ts.map +1 -1
  416. package/dist/utils/strict-modeling.js +7 -8
  417. package/dist/verification/playwright-reporter.d.ts +21 -0
  418. package/dist/verification/playwright-reporter.d.ts.map +1 -0
  419. package/dist/verification/playwright-reporter.js +114 -0
  420. package/package.json +46 -7
  421. package/schema/config.json +2 -2
  422. package/schema/manifest.json +26 -0
  423. package/src/public/branch-resolver.ts +1 -0
  424. package/src/public/check-types.ts +22 -19
  425. package/src/public/diagnostic-usage.ts +79 -1
  426. package/src/public/distribution-parity.ts +1 -0
  427. package/src/public/ignore-policy.ts +16 -10
  428. package/src/public/impact/coverage-depth-quality.ts +36 -0
  429. package/src/public/impact/full-kb-quality.ts +118 -5
  430. package/src/public/impact/manifest.ts +2 -4
  431. package/src/public/operational-artifacts.ts +9 -1
  432. package/src/public/operations/catalog.ts +146 -9
  433. package/src/public/operations/check-executor.ts +102 -15
  434. package/src/public/operations/check-format-shared.ts +6 -0
  435. package/src/public/operations/check-helpers.ts +74 -35
  436. package/src/public/operations/contracts.ts +366 -0
  437. package/src/public/operations/discovery-executors.ts +299 -12
  438. package/src/public/operations/index.ts +9 -4
  439. package/src/public/operations/migration-plan.ts +740 -0
  440. package/src/public/operations/node-ports.ts +84 -10
  441. package/src/public/operations/prolog-json.ts +60 -5
  442. package/src/public/operations/repair-plan.ts +1 -0
  443. package/src/public/operations/result-envelope.ts +136 -0
  444. package/src/public/operations/runtime-types.ts +91 -5
  445. package/src/public/operations/source-relationship-parity.ts +226 -0
  446. package/src/public/operations/specs/{autopilot.ts → bootstrap.ts} +17 -16
  447. package/src/public/operations/specs/check.ts +4 -3
  448. package/src/public/operations/specs/discovery.ts +57 -3
  449. package/src/public/operations/specs/modeling.ts +3 -3
  450. package/src/public/operations/specs/mutation-schemas.ts +6 -1
  451. package/src/public/operations/specs/mutation.ts +27 -2
  452. package/src/public/operations/specs/planning.ts +234 -0
  453. package/src/public/operations/specs/reporting.ts +55 -1
  454. package/src/public/operations/specs/upsert.ts +10 -0
  455. package/src/public/operations/specs/verification.ts +78 -0
  456. package/src/public/operations/symbol-repair-plan.ts +164 -0
  457. package/src/public/operations/types.ts +62 -1
  458. package/src/public/playwright-case-id.ts +35 -0
  459. package/src/public/schemas/entity.ts +7 -2
  460. package/src/public/skills/kibi-bootstrap/SKILL.md +58 -0
  461. package/src/public/skills/kibi-bootstrap/resources/bootstrap.md +11 -0
  462. package/src/public/skills/kibi-bootstrap/resources/branch-lifecycle.md +7 -0
  463. package/src/public/skills/kibi-bootstrap/resources/operation-access.md +5 -0
  464. package/src/public/skills/kibi-bootstrap/resources/source-authoring.md +8 -0
  465. package/src/public/skills/kibi-freshness/SKILL.md +39 -9
  466. package/src/public/skills/kibi-freshness/resources/branch-lifecycle.md +7 -0
  467. package/src/public/skills/kibi-freshness/resources/operation-access.md +6 -0
  468. package/src/public/skills/kibi-freshness/resources/source-authoring.md +7 -0
  469. package/src/public/skills/kibi-traceability/SKILL.md +47 -47
  470. package/src/public/skills/kibi-traceability/resources/branch-lifecycle.md +7 -0
  471. package/src/public/skills/kibi-traceability/resources/operation-access.md +5 -0
  472. package/src/public/skills/kibi-traceability/resources/source-authoring.md +6 -0
  473. package/src/public/skills/kibi-traceability/resources/traceability.md +8 -0
  474. package/src/public/skills/kibi-usage/SKILL.md +115 -239
  475. package/src/public/skills/kibi-usage/resources/branch-lifecycle.md +31 -0
  476. package/src/public/skills/kibi-usage/resources/kb-improvement.md +38 -0
  477. package/src/public/skills/kibi-usage/resources/operation-access.md +36 -38
  478. package/src/public/skills/kibi-usage/resources/relationship-directions.md +3 -3
  479. package/src/public/skills/kibi-usage/resources/source-authoring.md +31 -0
  480. package/src/public/skills/kibi-usage/resources/workflows.md +56 -3
  481. package/src/public/symbol-granularity.ts +1 -0
  482. package/src/public/telemetry-acceptance.ts +16 -1
  483. package/src/public/telemetry-remediation.ts +1 -1
  484. package/src/public/verification-receipt.ts +248 -6
  485. package/src/schemas/entity.schema.json +1148 -273
  486. package/templates/github/kibi-badge.yml +86 -0
  487. package/templates/github/kibi-report.yml +84 -0
  488. package/dist/operations/autopilot/activation.d.ts.map +0 -1
  489. package/dist/operations/autopilot/candidates.d.ts +0 -4
  490. package/dist/operations/autopilot/discovery.d.ts.map +0 -1
  491. package/dist/operations/autopilot/generate.d.ts +0 -8
  492. package/dist/operations/autopilot/generate.d.ts.map +0 -1
  493. package/dist/operations/autopilot/generate.js +0 -112
  494. package/dist/operations/autopilot/presentation.d.ts +0 -13
  495. package/dist/operations/autopilot/presentation.d.ts.map +0 -1
  496. package/dist/operations/autopilot/presentation.js +0 -91
  497. package/dist/operations/autopilot/types.d.ts.map +0 -1
  498. package/dist/operations/autopilot/types.js +0 -8
  499. package/dist/public/operations/specs/autopilot.d.ts.map +0 -1
  500. package/dist/public/skills/init-kibi/SKILL.md +0 -62
  501. package/src/public/skills/init-kibi/SKILL.md +0 -62
  502. /package/dist/operations/{autopilot → bootstrap}/activation.d.ts +0 -0
  503. /package/dist/operations/{autopilot → bootstrap}/candidate-helpers.d.ts +0 -0
  504. /package/dist/operations/{autopilot → bootstrap}/candidate-helpers.js +0 -0
  505. /package/dist/operations/{autopilot → bootstrap}/requirement-claims.d.ts +0 -0
  506. /package/dist/operations/{autopilot → bootstrap}/requirement-claims.js +0 -0
package/dist/engine.js CHANGED
@@ -15,12 +15,14 @@ import { fileURLToPath } from "node:url";
15
15
  import { PrologProcess, resolveKbPlPath } from "./prolog.js";
16
16
  import { parseEntityFromList, parseListOfLists } from "./prolog/codec.js";
17
17
  import { isValidBranchName } from "./utils/branch-resolver.js";
18
+ import { ensureBranchStoreManifest } from "./utils/branch-store-locator.js";
18
19
  export const ENGINE_PROTOCOL_VERSION = 1;
19
20
  export const ENGINE_IDLE_TIMEOUT_MS = 10 * 60 * 1000;
20
21
  export const ENGINE_PACKAGE_VERSIONS = process.env.KIBI_PACKAGE_VERSIONS ?? "unknown";
21
22
  const ENGINE_QUERY_CACHE_MAX_ENTRIES = 128;
22
23
  const ENGINE_QUERY_CACHE_MAX_RESULT_BYTES = 8 * 1024 * 1024;
23
24
  const ENGINE_FRESHNESS_CACHE_MS = 100;
25
+ const ENGINE_PUBLICATION_LOCK_STALE_MS = 5_000;
24
26
  function engineIdleTimeoutMs() {
25
27
  const configured = Number.parseInt(process.env.KIBI_ENGINE_IDLE_TIMEOUT_MS ?? "", 10);
26
28
  return Number.isFinite(configured) && configured >= 100
@@ -48,15 +50,84 @@ function cacheableEngineGoal(goal) {
48
50
  function mutatingEngineGoal(goal) {
49
51
  return /(?:kb_(?:assert|retract|commit|save|delete)|rdf_transaction|rdf_assert|rdf_retract)/.test(goal);
50
52
  }
53
+ function maskPrologData(goal) {
54
+ const chars = [...goal];
55
+ let quote = null;
56
+ let lineComment = false;
57
+ let blockComment = false;
58
+ for (let index = 0; index < chars.length; index += 1) {
59
+ const current = chars[index];
60
+ const next = chars[index + 1];
61
+ if (lineComment) {
62
+ if (current === "\n")
63
+ lineComment = false;
64
+ else
65
+ chars[index] = " ";
66
+ continue;
67
+ }
68
+ if (blockComment) {
69
+ if (current === "*" && next === "/") {
70
+ chars[index] = " ";
71
+ chars[index + 1] = " ";
72
+ index += 1;
73
+ blockComment = false;
74
+ }
75
+ else if (current !== "\n") {
76
+ chars[index] = " ";
77
+ }
78
+ continue;
79
+ }
80
+ if (quote !== null) {
81
+ if (current === "\\") {
82
+ chars[index] = " ";
83
+ if (index + 1 < chars.length) {
84
+ chars[index + 1] = " ";
85
+ index += 1;
86
+ }
87
+ }
88
+ else if (current === quote) {
89
+ if (next === quote) {
90
+ chars[index] = " ";
91
+ chars[index + 1] = " ";
92
+ index += 1;
93
+ }
94
+ else {
95
+ chars[index] = " ";
96
+ quote = null;
97
+ }
98
+ }
99
+ else if (current !== "\n") {
100
+ chars[index] = " ";
101
+ }
102
+ continue;
103
+ }
104
+ if (current === "%") {
105
+ chars[index] = " ";
106
+ lineComment = true;
107
+ }
108
+ else if (current === "/" && next === "*") {
109
+ chars[index] = " ";
110
+ chars[index + 1] = " ";
111
+ index += 1;
112
+ blockComment = true;
113
+ }
114
+ else if (current === "'" || current === '"' || current === "`") {
115
+ chars[index] = " ";
116
+ quote = current;
117
+ }
118
+ }
119
+ return chars.join("");
120
+ }
51
121
  function safeEngineGoal(goal) {
52
122
  // The socket is a local capability boundary, not a general-purpose SWI
53
123
  // console. Public clients may compose the typed Kibi predicates needed by
54
- // the 18 operation contracts, but process/filesystem/network escape hatches
124
+ // the typed operation contracts, but process/filesystem/network escape hatches
55
125
  // are rejected before they reach Prolog.
56
- if (/\b(?:halt|abort|shell|system|process_create|consult|load_files|open|close|delete_file|rename_file|make_directory|thread_create|rdf_attach_db|rdf_load|rdf_save|assertz|asserta|retractall)\s*\(/.test(goal)) {
126
+ const executable = maskPrologData(goal);
127
+ if (/\b(?:halt|abort|shell|system|process_create|consult|load_files|open|close|delete_file|rename_file|make_directory|thread_create|rdf_attach_db|rdf_load|rdf_save|assertz|asserta|retractall|set_prolog_flag)\s*\(/.test(executable)) {
57
128
  return false;
58
129
  }
59
- return /(?:^|[(:,\s])(?:kb_|checks:|status:|discovery:|requirement_proof:|findall\(|aggregate_all\(|rdf_transaction\(|set_prolog_flag\(|use_module\(|atom_json_dict\(|member\(|once\(|true\b|fail\b)/.test(goal.trim());
130
+ return /(?:^|[(:,\s])(?:kb_|checks:|status:|discovery:|requirement_proof:|findall\(|aggregate_all\(|rdf_transaction\(|use_module\(|atom_json_dict\(|member\(|once\(|true\b|fail\b)/.test(goal.trim());
60
131
  }
61
132
  function frame(value) {
62
133
  const payload = Buffer.from(JSON.stringify(value), "utf8");
@@ -199,6 +270,127 @@ export function engineStartLockPath(workspaceRoot, branch) {
199
270
  }
200
271
  return `${engineSocketPath(workspaceRoot, branch)}.start.lock`;
201
272
  }
273
+ /**
274
+ * A generation publisher holds this lease from the existing daemon shutdown
275
+ * through the atomic branch-store cutover. Engine clients honor the lease so
276
+ * another process cannot auto-start a writer in the stop-to-publish gap.
277
+ */
278
+ export function enginePublicationLockPath(workspaceRoot, branch) {
279
+ return `${engineSocketPath(workspaceRoot, branch)}.publish.lock`;
280
+ }
281
+ function publicationLockOwner(lockPath) {
282
+ try {
283
+ const [pidText, createdText] = readFileSync(lockPath, "utf8")
284
+ .trim()
285
+ .split(":");
286
+ const pid = Number.parseInt(pidText ?? "", 10);
287
+ const createdAt = Number.parseInt(createdText ?? "", 10);
288
+ if (!Number.isInteger(pid) || pid <= 1 || !Number.isFinite(createdAt)) {
289
+ return null;
290
+ }
291
+ return { pid, createdAt };
292
+ }
293
+ catch {
294
+ return null;
295
+ }
296
+ }
297
+ function processIsAlive(pid) {
298
+ try {
299
+ process.kill(pid, 0);
300
+ return true;
301
+ }
302
+ catch {
303
+ return false;
304
+ }
305
+ }
306
+ function clearStalePublicationLock(lockPath) {
307
+ if (!existsSync(lockPath))
308
+ return true;
309
+ const owner = publicationLockOwner(lockPath);
310
+ let age = 0;
311
+ try {
312
+ age = Date.now() - statSync(lockPath).mtimeMs;
313
+ }
314
+ catch {
315
+ return false;
316
+ }
317
+ if ((owner === null || !processIsAlive(owner.pid)) &&
318
+ age > ENGINE_PUBLICATION_LOCK_STALE_MS) {
319
+ try {
320
+ unlinkSync(lockPath);
321
+ return true;
322
+ }
323
+ catch {
324
+ return false;
325
+ }
326
+ }
327
+ return false;
328
+ }
329
+ function publicationLockIsActive(lockPath) {
330
+ if (!existsSync(lockPath))
331
+ return false;
332
+ if (clearStalePublicationLock(lockPath))
333
+ return false;
334
+ return existsSync(lockPath);
335
+ }
336
+ export function acquireEnginePublicationLease(workspaceRoot, branch) {
337
+ const lockPath = enginePublicationLockPath(workspaceRoot, branch);
338
+ mkdirSync(path.dirname(lockPath), { recursive: true, mode: 0o700 });
339
+ let descriptor = null;
340
+ try {
341
+ descriptor = openSync(lockPath, "wx", 0o600);
342
+ }
343
+ catch {
344
+ if (clearStalePublicationLock(lockPath)) {
345
+ try {
346
+ descriptor = openSync(lockPath, "wx", 0o600);
347
+ }
348
+ catch {
349
+ // Fall through to the stable fail-closed error below.
350
+ }
351
+ }
352
+ }
353
+ if (descriptor === null) {
354
+ throw new Error(`Kibi engine publication is already in progress: ${lockPath}`);
355
+ }
356
+ try {
357
+ writeFileSync(lockPath, `${process.pid}:${Date.now()}\n`, { flag: "w" });
358
+ }
359
+ catch (error) {
360
+ closeSync(descriptor);
361
+ unlinkSync(lockPath);
362
+ throw error;
363
+ }
364
+ const startLockPath = engineStartLockPath(workspaceRoot, branch);
365
+ const startDescriptor = tryAcquireStartLock(startLockPath);
366
+ if (startDescriptor === null) {
367
+ closeSync(descriptor);
368
+ unlinkSync(lockPath);
369
+ throw new Error(`Kibi engine publication cannot acquire the engine start lease: ${startLockPath}`);
370
+ }
371
+ let released = false;
372
+ return {
373
+ path: lockPath,
374
+ release: () => {
375
+ if (released)
376
+ return;
377
+ released = true;
378
+ try {
379
+ closeSync(descriptor);
380
+ }
381
+ catch {
382
+ // The descriptor may already have been closed during process cleanup.
383
+ }
384
+ releaseStartLock(startLockPath, startDescriptor);
385
+ try {
386
+ unlinkSync(lockPath);
387
+ }
388
+ catch {
389
+ // A subsequent publisher may have replaced a stale lock after a crash.
390
+ }
391
+ },
392
+ };
393
+ }
202
394
  function tryAcquireStartLock(lockPath) {
203
395
  try {
204
396
  const descriptor = openSync(lockPath, "wx", 0o600);
@@ -377,6 +569,7 @@ export class EngineClient {
377
569
  workspaceRoot;
378
570
  branch;
379
571
  timeout;
572
+ allowPublicationLock;
380
573
  socket = null;
381
574
  daemon = null;
382
575
  inputBuffer = Buffer.alloc(0);
@@ -397,11 +590,17 @@ export class EngineClient {
397
590
  }
398
591
  this.branch = options.branch;
399
592
  this.timeout = options.timeout ?? 120_000;
593
+ this.allowPublicationLock = options.allowPublicationLock ?? false;
400
594
  }
401
595
  async start(allowSpawn = true) {
402
596
  if (this.socket !== null && !this.socket.destroyed)
403
597
  return;
404
598
  const socketPath = engineSocketPath(this.workspaceRoot, this.branch);
599
+ const publicationLockPath = enginePublicationLockPath(this.workspaceRoot, this.branch);
600
+ if (!this.allowPublicationLock &&
601
+ publicationLockIsActive(publicationLockPath)) {
602
+ throw new Error(`Kibi engine publication is in progress: ${publicationLockPath}`);
603
+ }
405
604
  try {
406
605
  if (existsSync(socketPath)) {
407
606
  this.socket = await connectWithRetry(socketPath, 150);
@@ -576,22 +775,28 @@ export class EngineClient {
576
775
  release();
577
776
  }
578
777
  }
778
+ /** Execute a versioned, goal-free engine command. Raw query remains private
779
+ * compatibility traffic for the in-process Prolog adapter only. */
780
+ async command(command, signal) {
781
+ return this.request({ method: "command", command }, signal);
782
+ }
579
783
  async queryBatch(goals) {
580
784
  const normalized = goals.map((goal) => goal.trim().replace(/\.+\s*$/, ""));
581
785
  return this.query(`rdf_transaction((${normalized.join(", ")}))`);
582
786
  }
583
- async queryEntities(input) {
584
- const result = await this.request({
585
- method: "entities",
787
+ async queryEntities(input, signal) {
788
+ const result = await this.command({
789
+ version: 1,
790
+ kind: "entities",
586
791
  ...(input.type !== undefined ? { type: input.type } : {}),
587
- ...(input.id !== undefined ? { entityId: input.id } : {}),
792
+ ...(input.id !== undefined ? { id: input.id } : {}),
588
793
  ...(input.tags !== undefined ? { tags: input.tags } : {}),
589
794
  ...(input.sourceFile !== undefined
590
795
  ? { sourceFile: input.sourceFile }
591
796
  : {}),
592
797
  limit: input.limit,
593
798
  offset: input.offset,
594
- });
799
+ }, signal);
595
800
  if (!result.success) {
596
801
  throw new Error(result.error ?? "Indexed entity query failed");
597
802
  }
@@ -604,14 +809,15 @@ export class EngineClient {
604
809
  count: Number.isFinite(count) ? count : rows.length,
605
810
  };
606
811
  }
607
- async searchEntities(input) {
608
- const result = await this.request({
609
- method: "search",
610
- searchQuery: input.query,
812
+ async searchEntities(input, signal) {
813
+ const result = await this.command({
814
+ version: 1,
815
+ kind: "search",
816
+ query: input.query,
611
817
  ...(input.type !== undefined ? { type: input.type } : {}),
612
818
  limit: input.limit,
613
819
  offset: input.offset,
614
- });
820
+ }, signal);
615
821
  if (!result.success) {
616
822
  throw new Error(result.error ?? "Indexed search candidate query failed");
617
823
  }
@@ -645,20 +851,20 @@ export class EngineClient {
645
851
  this.lastResult = null;
646
852
  return result;
647
853
  }
648
- async save() {
649
- return this.query("kb_save");
854
+ async save(signal) {
855
+ return this.query("kb_save", signal);
650
856
  }
651
857
  async storageStatus() {
652
858
  return this.request({ method: "status" });
653
859
  }
654
860
  async checkpoint() {
655
- return this.request({ method: "checkpoint" });
861
+ return this.command({ version: 1, kind: "checkpoint" });
656
862
  }
657
863
  async queryStatusJson() {
658
- return this.request({ method: "kbStatus" });
864
+ return this.command({ version: 1, kind: "status" });
659
865
  }
660
866
  async compact() {
661
- return this.request({ method: "compact" });
867
+ return this.command({ version: 1, kind: "compact" });
662
868
  }
663
869
  async exportStorage(targetDirectory) {
664
870
  return this.request({
@@ -693,9 +899,19 @@ export class EngineClient {
693
899
  throw new Error("Unable to start Kibi engine for stop request");
694
900
  }
695
901
  }
696
- if (!this.isRunning())
902
+ if (!this.isRunning()) {
903
+ if (existsSync(socketPath)) {
904
+ throw new Error(`Kibi engine socket remains present but is not reachable: ${socketPath}`);
905
+ }
697
906
  return;
698
- await this.request({ method: "stop" }).catch(() => undefined);
907
+ }
908
+ let requestError;
909
+ try {
910
+ await this.request({ method: "stop" });
911
+ }
912
+ catch (error) {
913
+ requestError = error;
914
+ }
699
915
  this.socket?.destroy();
700
916
  this.socket = null;
701
917
  // The daemon acknowledges stop before its SWI child has flushed and the
@@ -705,6 +921,10 @@ export class EngineClient {
705
921
  while (existsSync(socketPath) && Date.now() < deadline) {
706
922
  await new Promise((resolve) => setTimeout(resolve, 25));
707
923
  }
924
+ if (existsSync(socketPath)) {
925
+ const detail = requestError instanceof Error ? `: ${requestError.message}` : "";
926
+ throw new Error(`Kibi engine did not stop within 5 seconds${detail}`);
927
+ }
708
928
  }
709
929
  async terminate() {
710
930
  // Closing a client connection releases the engine; the daemon remains
@@ -924,10 +1144,10 @@ export async function runEngineDaemon(options) {
924
1144
  if (!isValidBranchName(options.branch)) {
925
1145
  throw new Error(`Invalid Kibi engine branch name: ${options.branch}`);
926
1146
  }
927
- await ensureJournaledBranchStoreAsync(path.join(options.workspaceRoot, ".kb", "branches", options.branch));
1147
+ const branchPath = ensureBranchStoreManifest(options.workspaceRoot, options.branch);
1148
+ await ensureJournaledBranchStoreAsync(branchPath);
928
1149
  const prolog = new PrologProcess({ timeout: 120_000, oneShot: false });
929
1150
  await prolog.start();
930
- const branchPath = path.join(options.workspaceRoot, ".kb", "branches", options.branch);
931
1151
  const attached = await prolog.query(`kb_attach('${quoteProlog(branchPath)}')`);
932
1152
  if (!attached.success)
933
1153
  throw new Error(attached.error ?? "Failed to attach branch KB");
@@ -968,6 +1188,25 @@ export async function runEngineDaemon(options) {
968
1188
  const cancelledRequests = new Set();
969
1189
  const clients = new Set();
970
1190
  let shuttingDown = false;
1191
+ const exactBranchStatus = (result) => {
1192
+ if (!result.success || typeof result.bindings.JsonString !== "string") {
1193
+ return result;
1194
+ }
1195
+ try {
1196
+ const decoded = JSON.parse(JSON.parse(result.bindings.JsonString));
1197
+ decoded.branch = options.branch;
1198
+ return {
1199
+ ...result,
1200
+ bindings: {
1201
+ ...result.bindings,
1202
+ JsonString: JSON.stringify(JSON.stringify(decoded)),
1203
+ },
1204
+ };
1205
+ }
1206
+ catch {
1207
+ return result;
1208
+ }
1209
+ };
971
1210
  const scheduleIdleExit = () => {
972
1211
  if (activeClients > 0)
973
1212
  return;
@@ -1057,12 +1296,142 @@ export async function runEngineDaemon(options) {
1057
1296
  }
1058
1297
  return result;
1059
1298
  }
1299
+ case "command": {
1300
+ const command = request.command;
1301
+ if (command === undefined || command.version !== 1) {
1302
+ throw new Error("engine.command must use version 1");
1303
+ }
1304
+ switch (command.kind) {
1305
+ case "status":
1306
+ return exactBranchStatus(await prolog.query("status:kb_status_json(JsonString)"));
1307
+ case "checkpoint": {
1308
+ queryCache.clear();
1309
+ freshnessCache = null;
1310
+ const result = await prolog.query("kb_sync_checkpoint");
1311
+ if (result.success)
1312
+ fsyncJournaledBranchStore(branchPath);
1313
+ return result;
1314
+ }
1315
+ case "compact": {
1316
+ const result = await prolog.query("kb_storage_compact");
1317
+ if (result.success)
1318
+ fsyncJournaledBranchStore(branchPath);
1319
+ return result;
1320
+ }
1321
+ case "save": {
1322
+ const result = await prolog.query("kb_save");
1323
+ if (result.success)
1324
+ fsyncJournaledBranchStore(branchPath);
1325
+ return result;
1326
+ }
1327
+ case "check": {
1328
+ if (command.rule !== undefined &&
1329
+ !/^[a-z][a-z0-9_]*$/.test(command.rule)) {
1330
+ throw new Error("engine.check.rule must be a lowercase rule name");
1331
+ }
1332
+ // Rule selection is intentionally resolved inside the engine. A
1333
+ // caller never supplies a Prolog goal over the command boundary.
1334
+ return prolog.query("checks:check_all_json(JsonString)");
1335
+ }
1336
+ case "relationship": {
1337
+ if (!command.type || !command.from || !command.to) {
1338
+ throw new Error("engine.relationship requires type, from, and to");
1339
+ }
1340
+ const type = quoteProlog(command.type);
1341
+ const from = quoteProlog(command.from);
1342
+ const to = quoteProlog(command.to);
1343
+ const goal = command.action === "assert"
1344
+ ? `kb_assert_relationship('${type}', '${from}', '${to}', [])`
1345
+ : `kb_retract_relationship('${type}', '${from}', '${to}')`;
1346
+ const result = await prolog.query(goal);
1347
+ if (result.success) {
1348
+ queryCache.clear();
1349
+ freshnessCache = null;
1350
+ fsyncJournaledBranchStore(branchPath);
1351
+ }
1352
+ return result;
1353
+ }
1354
+ case "persistence": {
1355
+ const goal = command.action === "checkpoint"
1356
+ ? "kb_sync_checkpoint"
1357
+ : command.action === "compact"
1358
+ ? "kb_storage_compact"
1359
+ : command.action === "save"
1360
+ ? "kb_save"
1361
+ : command.targetDirectory
1362
+ ? `kb_storage_export('${quoteProlog(command.targetDirectory)}')`
1363
+ : null;
1364
+ if (goal === null) {
1365
+ throw new Error("engine.persistence.export requires targetDirectory");
1366
+ }
1367
+ const result = await prolog.query(goal);
1368
+ if (result.success)
1369
+ fsyncJournaledBranchStore(branchPath);
1370
+ return result;
1371
+ }
1372
+ case "lifecycle": {
1373
+ if (command.action === "stop") {
1374
+ setImmediate(() => void shutdown());
1375
+ return { stopped: true };
1376
+ }
1377
+ if (!Number.isInteger(command.requestId)) {
1378
+ throw new Error("engine.lifecycle.cancel requires requestId");
1379
+ }
1380
+ const requestId = command.requestId;
1381
+ cancelledRequests.add(requestId);
1382
+ return { cancelled: requestId };
1383
+ }
1384
+ case "stop":
1385
+ setImmediate(() => void shutdown());
1386
+ return { stopped: true };
1387
+ case "cancel":
1388
+ cancelledRequests.add(command.requestId);
1389
+ return { cancelled: command.requestId };
1390
+ case "entities": {
1391
+ if (!Number.isInteger(command.limit) ||
1392
+ !Number.isInteger(command.offset) ||
1393
+ command.limit < 0 ||
1394
+ command.offset < 0 ||
1395
+ command.limit > 100_000) {
1396
+ throw new Error("engine.entities.limit/offset must be bounded integers");
1397
+ }
1398
+ const type = command.type === undefined
1399
+ ? "none"
1400
+ : `'${quoteProlog(command.type)}'`;
1401
+ const id = command.id === undefined
1402
+ ? "none"
1403
+ : `'${quoteProlog(command.id)}'`;
1404
+ const tags = `[${(command.tags ?? []).map((tag) => `'${quoteProlog(tag)}'`).join(",")}]`;
1405
+ const source = command.sourceFile === undefined
1406
+ ? "none"
1407
+ : `'${quoteProlog(command.sourceFile)}'`;
1408
+ return prolog.query(`kb_query_entities(${type}, ${id}, ${tags}, ${source}, ${command.limit}, ${command.offset}, Rows, Count)`);
1409
+ }
1410
+ case "search": {
1411
+ if (!command.query.trim())
1412
+ throw new Error("engine.search.query must be non-empty");
1413
+ if (!Number.isInteger(command.limit) ||
1414
+ !Number.isInteger(command.offset) ||
1415
+ command.limit < 0 ||
1416
+ command.offset < 0 ||
1417
+ command.limit > 100_000) {
1418
+ throw new Error("engine.search.limit/offset must be bounded integers");
1419
+ }
1420
+ const type = command.type === undefined
1421
+ ? "none"
1422
+ : `'${quoteProlog(command.type)}'`;
1423
+ return prolog.query(`kb_search_entities(${type}, '${quoteProlog(command.query)}', ${command.limit}, ${command.offset}, Rows, Count)`);
1424
+ }
1425
+ default:
1426
+ throw new Error("engine.command kind is unsupported");
1427
+ }
1428
+ }
1060
1429
  case "kbStatus": {
1061
1430
  if (freshnessCache !== null &&
1062
1431
  Date.now() - freshnessCache.capturedAt <= ENGINE_FRESHNESS_CACHE_MS) {
1063
1432
  return freshnessCache.result;
1064
1433
  }
1065
- const result = await prolog.query("status:kb_status_json(JsonString)");
1434
+ const result = exactBranchStatus(await prolog.query("status:kb_status_json(JsonString)"));
1066
1435
  if (result.success) {
1067
1436
  freshnessCache = { capturedAt: Date.now(), result };
1068
1437
  }
package/dist/env.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAoBA,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAGtD;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAGxD;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAGlD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAG9C"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAeA,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,SAAS,CAMtD;AAED,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAGxD;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C;AAED,wBAAgB,wBAAwB,IAAI,OAAO,CAGlD;AAED,wBAAgB,oBAAoB,IAAI,OAAO,CAG9C"}
package/dist/env.js CHANGED
@@ -11,13 +11,12 @@ function getEnvValue(key) {
11
11
  const value = process.env[key];
12
12
  return typeof value === "string" ? value : undefined;
13
13
  }
14
- function getTrimmedEnvValue(key) {
15
- const value = getEnvValue(key)?.trim();
16
- return value ? value : undefined;
17
- }
18
14
  export function getBranchOverride() {
19
- // implements REQ-003
20
- return getTrimmedEnvValue("KIBI_BRANCH");
15
+ // Branch identity is exact and must not be normalized. Preserve whitespace
16
+ // so the Git-ref validator rejects an accidental value instead of silently
17
+ // attaching a different branch.
18
+ const value = getEnvValue("KIBI_BRANCH");
19
+ return value === undefined || value.length === 0 ? undefined : value;
21
20
  }
22
21
  export function getKbPlPathOverride() {
23
22
  // implements REQ-003
@@ -25,7 +25,8 @@ export interface ExtractionResult {
25
25
  }
26
26
  export declare class ManifestError extends Error {
27
27
  filePath: string;
28
- constructor(message: string, filePath: string);
28
+ readonly classification?: "coordinate-artifact" | undefined;
29
+ constructor(message: string, filePath: string, classification?: "coordinate-artifact" | undefined);
29
30
  }
30
31
  export interface ManifestSymbolRecord {
31
32
  id?: string;
@@ -56,6 +57,12 @@ export interface ManifestSymbolRecord {
56
57
  coordinatesGeneratedAt?: string;
57
58
  [key: string]: unknown;
58
59
  }
60
+ /**
61
+ * Convert overlay-merged manifest symbol records into extraction results.
62
+ * Exported so mutation flows can re-extract one canonical entity from the
63
+ * authored manifest plus generated coordinate artifact before committing.
64
+ */
65
+ export declare function extractManifestSymbolRecords(manifestSymbols: ManifestSymbolRecord[], filePath: string): ExtractionResult[];
59
66
  export declare function extractFromManifestString(content: string, filePath: string): ExtractionResult[];
60
67
  export declare function extractManifestSymbolRecordsString(content: string, filePath: string): ManifestSymbolRecord[];
61
68
  export declare function extractFromManifest(filePath: string): ExtractionResult[];
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/extractors/manifest.ts"],"names":[],"mappings":"AA6BA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ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