kibi-cli 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/dist/cli-register-proof.d.ts.map +1 -1
  2. package/dist/cli-register-proof.js +25 -1
  3. package/dist/cli-register-reporting.d.ts.map +1 -1
  4. package/dist/cli-register-reporting.js +6 -0
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +2 -0
  7. package/dist/commands/check-generated.d.ts +7 -0
  8. package/dist/commands/check-generated.d.ts.map +1 -0
  9. package/dist/commands/check-generated.js +192 -0
  10. package/dist/commands/check.d.ts.map +1 -1
  11. package/dist/commands/check.js +3 -2
  12. package/dist/commands/doctor.d.ts.map +1 -1
  13. package/dist/commands/doctor.js +122 -1
  14. package/dist/commands/engine.d.ts.map +1 -1
  15. package/dist/commands/engine.js +3 -1
  16. package/dist/commands/init-helpers.d.ts.map +1 -1
  17. package/dist/commands/init-helpers.js +13 -7
  18. package/dist/commands/proof-explain.d.ts +10 -0
  19. package/dist/commands/proof-explain.d.ts.map +1 -0
  20. package/dist/commands/proof-explain.js +45 -0
  21. package/dist/commands/proof-impact.d.ts +7 -0
  22. package/dist/commands/proof-impact.d.ts.map +1 -0
  23. package/dist/commands/proof-impact.js +39 -0
  24. package/dist/commands/proof-migrate-legacy.js +1 -1
  25. package/dist/commands/proof-prune.js +1 -1
  26. package/dist/commands/prove.js +4 -4
  27. package/dist/commands/report.d.ts.map +1 -1
  28. package/dist/commands/report.js +17 -2
  29. package/dist/commands/sync/manifest.d.ts +1 -0
  30. package/dist/commands/sync/manifest.d.ts.map +1 -1
  31. package/dist/commands/sync/manifest.js +18 -16
  32. package/dist/commands/sync/persistence.d.ts.map +1 -1
  33. package/dist/commands/sync/persistence.js +6 -0
  34. package/dist/engine.d.ts +3 -1
  35. package/dist/engine.d.ts.map +1 -1
  36. package/dist/engine.js +134 -61
  37. package/dist/env/bootstrap.d.ts +84 -0
  38. package/dist/env/bootstrap.d.ts.map +1 -0
  39. package/dist/env/bootstrap.js +310 -0
  40. package/dist/extractors/manifest.d.ts.map +1 -1
  41. package/dist/extractors/manifest.js +1 -1
  42. package/dist/extractors/markdown.d.ts +2 -0
  43. package/dist/extractors/markdown.d.ts.map +1 -1
  44. package/dist/extractors/markdown.js +19 -0
  45. package/dist/extractors/symbols-coordinator.d.ts +8 -0
  46. package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
  47. package/dist/extractors/symbols-coordinator.js +40 -0
  48. package/dist/extractors/symbols-ts.d.ts +8 -19
  49. package/dist/extractors/symbols-ts.d.ts.map +1 -1
  50. package/dist/extractors/symbols-ts.js +33 -503
  51. package/dist/intent-search.d.ts.map +1 -1
  52. package/dist/intent-search.js +4 -5
  53. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  54. package/dist/operations/modeling/model-requirement.js +4 -0
  55. package/dist/operations/modeling/suggest-predicates.d.ts +1 -1
  56. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  57. package/dist/operations/modeling/suggest-predicates.js +30 -3
  58. package/dist/operations/mutation/symbol-granularity.d.ts.map +1 -1
  59. package/dist/operations/mutation/symbol-granularity.js +9 -87
  60. package/dist/operations/planning/compile-intent.d.ts +49 -0
  61. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  62. package/dist/operations/planning/compile-intent.js +63 -3
  63. package/dist/operations/proof/baseline-diff.d.ts +41 -0
  64. package/dist/operations/proof/baseline-diff.d.ts.map +1 -0
  65. package/dist/operations/proof/baseline-diff.js +153 -0
  66. package/dist/operations/proof/explain.d.ts +75 -0
  67. package/dist/operations/proof/explain.d.ts.map +1 -0
  68. package/dist/operations/proof/explain.js +294 -0
  69. package/dist/operations/proof/impact.d.ts +45 -0
  70. package/dist/operations/proof/impact.d.ts.map +1 -0
  71. package/dist/operations/proof/impact.js +118 -0
  72. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  73. package/dist/operations/proof/ingest-proof.js +44 -3
  74. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  75. package/dist/operations/proof/migrate-legacy-receipts.js +21 -17
  76. package/dist/operations/proof/prune-receipts.js +1 -1
  77. package/dist/operations/proof/receipt-document.js +2 -2
  78. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  79. package/dist/operations/semantic-advisor/analysis-receipt.js +3 -9
  80. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  81. package/dist/operations/semantic-advisor/analyze-prose.js +18 -67
  82. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts +63 -0
  83. package/dist/operations/semantic-advisor/plugin-orchestration.d.ts.map +1 -0
  84. package/dist/operations/semantic-advisor/plugin-orchestration.js +489 -0
  85. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts +15 -2
  86. package/dist/operations/semantic-advisor/predicate-rules-core.d.ts.map +1 -1
  87. package/dist/operations/semantic-advisor/predicate-rules-core.js +7 -140
  88. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts +11 -12
  89. package/dist/operations/semantic-advisor/predicate-rules-launcher.d.ts.map +1 -1
  90. package/dist/operations/semantic-advisor/predicate-rules-launcher.js +6 -94
  91. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts +16 -0
  92. package/dist/operations/semantic-advisor/predicate-rules-policy.d.ts.map +1 -1
  93. package/dist/operations/semantic-advisor/predicate-rules-policy.js +7 -150
  94. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts +9 -0
  95. package/dist/operations/semantic-advisor/predicate-rules-product-tail.d.ts.map +1 -1
  96. package/dist/operations/semantic-advisor/predicate-rules-product-tail.js +7 -102
  97. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts +13 -0
  98. package/dist/operations/semantic-advisor/predicate-rules-product.d.ts.map +1 -1
  99. package/dist/operations/semantic-advisor/predicate-rules-product.js +7 -133
  100. package/dist/operations/semantic-advisor/types.d.ts +1 -0
  101. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  102. package/dist/plugins/compose-ontology-packs.d.ts +51 -0
  103. package/dist/plugins/compose-ontology-packs.d.ts.map +1 -0
  104. package/dist/plugins/compose-ontology-packs.js +257 -0
  105. package/dist/plugins/compose-semantic-classifier.d.ts +42 -0
  106. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -0
  107. package/dist/plugins/compose-semantic-classifier.js +211 -0
  108. package/dist/plugins/external-allowlist.d.ts +10 -0
  109. package/dist/plugins/external-allowlist.d.ts.map +1 -0
  110. package/dist/plugins/external-allowlist.js +16 -0
  111. package/dist/plugins/index.d.ts +9 -0
  112. package/dist/plugins/index.d.ts.map +1 -0
  113. package/dist/plugins/index.js +33 -0
  114. package/dist/plugins/load-plugin.d.ts +19 -0
  115. package/dist/plugins/load-plugin.d.ts.map +1 -0
  116. package/dist/plugins/load-plugin.js +59 -0
  117. package/dist/plugins/project-config.d.ts +28 -0
  118. package/dist/plugins/project-config.d.ts.map +1 -0
  119. package/dist/plugins/project-config.js +90 -0
  120. package/dist/plugins/registry.d.ts +93 -0
  121. package/dist/plugins/registry.d.ts.map +1 -0
  122. package/dist/plugins/registry.js +338 -0
  123. package/dist/plugins/resolve-package.d.ts +47 -0
  124. package/dist/plugins/resolve-package.d.ts.map +1 -0
  125. package/dist/plugins/resolve-package.js +262 -0
  126. package/dist/plugins/source-analysis-service.d.ts +44 -0
  127. package/dist/plugins/source-analysis-service.d.ts.map +1 -0
  128. package/dist/plugins/source-analysis-service.js +232 -0
  129. package/dist/prolog/janitor.d.ts.map +1 -1
  130. package/dist/prolog/janitor.js +1 -1
  131. package/dist/prolog/store-lock.d.ts +1 -1
  132. package/dist/prolog/store-lock.d.ts.map +1 -1
  133. package/dist/proof/inspect.js +1 -1
  134. package/dist/proof/producers/playwright-case-id.js +2 -2
  135. package/dist/proof/producers/playwright-reporter.js +4 -4
  136. package/dist/public/extractors/symbols-coordinator.d.ts +1 -1
  137. package/dist/public/extractors/symbols-coordinator.d.ts.map +1 -1
  138. package/dist/public/extractors/symbols-coordinator.js +1 -1
  139. package/dist/public/impact/analyzer.d.ts +1 -1
  140. package/dist/public/impact/analyzer.d.ts.map +1 -1
  141. package/dist/public/impact/analyzer.js +6 -4
  142. package/dist/public/operations/catalog.d.ts +4 -1
  143. package/dist/public/operations/catalog.d.ts.map +1 -1
  144. package/dist/public/operations/check-executor.js +1 -1
  145. package/dist/public/operations/check-helpers.d.ts +1 -1
  146. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  147. package/dist/public/operations/check-helpers.js +1 -1
  148. package/dist/public/operations/contracts.d.ts.map +1 -1
  149. package/dist/public/operations/contracts.js +35 -12
  150. package/dist/public/operations/discovery-entities.d.ts +12 -0
  151. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  152. package/dist/public/operations/discovery-entities.js +34 -0
  153. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  154. package/dist/public/operations/discovery-executors.js +23 -18
  155. package/dist/public/operations/prolog-json.d.ts +1 -1
  156. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  157. package/dist/public/operations/prolog-json.js +7 -7
  158. package/dist/public/operations/runtime-types.d.ts +16 -1
  159. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  160. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  161. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  162. package/dist/public/operations/specs/check-rules.generated.js +2 -1
  163. package/dist/public/operations/specs/check.d.ts +1 -1
  164. package/dist/public/operations/specs/discovery.d.ts +3 -0
  165. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  166. package/dist/public/operations/specs/discovery.js +3 -0
  167. package/dist/public/operations/specs/proof.js +1 -1
  168. package/dist/public/operations/specs/reporting.d.ts +1 -0
  169. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  170. package/dist/public/operations/specs/reporting.js +2 -2
  171. package/dist/public/operations/specs/semantic.d.ts +1 -1
  172. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  173. package/dist/public/operations/specs/semantic.js +54 -4
  174. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  175. package/dist/public/operations/symbol-repair-plan.js +3 -1
  176. package/dist/public/operations/types.d.ts +5 -0
  177. package/dist/public/operations/types.d.ts.map +1 -1
  178. package/dist/public/proof-protocol.js +4 -4
  179. package/dist/public/skills/kibi-usage/SKILL.md +4 -1
  180. package/dist/public/skills/kibi-usage/resources/proof.md +45 -0
  181. package/dist/public/symbol-granularity.d.ts +1 -1
  182. package/dist/public/symbol-granularity.d.ts.map +1 -1
  183. package/dist/public/symbol-granularity.generated.d.ts.map +1 -1
  184. package/dist/public/symbol-granularity.generated.js +38 -5
  185. package/dist/report/html-report.css +1239 -281
  186. package/dist/runtime/cli-runtime.d.ts.map +1 -1
  187. package/dist/runtime/cli-runtime.js +18 -0
  188. package/dist/traceability/symbol-extract.d.ts +24 -7
  189. package/dist/traceability/symbol-extract.d.ts.map +1 -1
  190. package/dist/traceability/symbol-extract.js +64 -208
  191. package/dist/utils/rule-registry.generated.d.ts +5 -0
  192. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  193. package/dist/utils/rule-registry.generated.js +6 -0
  194. package/package.json +14 -11
  195. package/src/public/extractors/symbols-coordinator.ts +1 -0
  196. package/src/public/impact/analyzer.ts +15 -12
  197. package/src/public/operations/check-executor.ts +1 -1
  198. package/src/public/operations/check-helpers.ts +2 -2
  199. package/src/public/operations/contracts.ts +40 -12
  200. package/src/public/operations/discovery-entities.ts +46 -0
  201. package/src/public/operations/discovery-executors.ts +39 -26
  202. package/src/public/operations/prolog-json.ts +13 -5
  203. package/src/public/operations/runtime-types.ts +21 -2
  204. package/src/public/operations/specs/check-rules.generated.ts +2 -1
  205. package/src/public/operations/specs/discovery.ts +3 -0
  206. package/src/public/operations/specs/proof.ts +1 -1
  207. package/src/public/operations/specs/reporting.ts +2 -2
  208. package/src/public/operations/specs/semantic.ts +79 -17
  209. package/src/public/operations/symbol-repair-plan.ts +3 -4
  210. package/src/public/operations/types.ts +5 -0
  211. package/src/public/proof-fingerprint.ts +1 -1
  212. package/src/public/proof-protocol-types.d.ts +1 -1
  213. package/src/public/proof-protocol.ts +4 -4
  214. package/src/public/skills/kibi-usage/SKILL.md +4 -1
  215. package/src/public/skills/kibi-usage/resources/proof.md +45 -0
  216. package/src/public/symbol-granularity.generated.ts +45 -12
  217. package/src/public/symbol-granularity.ts +3 -3
@@ -0,0 +1,39 @@
1
+ /*
2
+ Kibi — repo-local, per-branch, queryable long-term memory for software projects
3
+ Copyright (C) 2026 Piotr Franczyk
4
+
5
+ This program is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU Affero General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+ */
10
+ import { executeProofImpact, proofImpactExitCode, } from "../operations/proof/impact.js";
11
+ import { createCliRuntime } from "../runtime/cli-runtime.js";
12
+ // implements REQ-kibi-verification-evidence-contract
13
+ export async function proofImpactCommand(options) {
14
+ const runtime = createCliRuntime();
15
+ const context = await runtime.open({
16
+ name: "kibi_proof_impact",
17
+ effects: [],
18
+ requiresProlog: true,
19
+ execute: async () => undefined,
20
+ }, {});
21
+ let completed = false;
22
+ try {
23
+ const { result, text } = await executeProofImpact(context);
24
+ if (options.json) {
25
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
26
+ }
27
+ else {
28
+ process.stdout.write(text);
29
+ }
30
+ completed = true;
31
+ await runtime.afterSuccess({ name: "kibi_proof_impact" }, context);
32
+ return { exitCode: proofImpactExitCode(result) };
33
+ }
34
+ finally {
35
+ await runtime.close(context, completed
36
+ ? { status: "success", result: 0 }
37
+ : { status: "error", error: 1 });
38
+ }
39
+ }
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { executeMigrateLegacyReceipts } from "../operations/proof/migrate-legacy-receipts.js";
19
19
  import { createCliRuntime } from "../runtime/cli-runtime.js";
20
- // implements REQ-kibi-proof-evidence-protocol
20
+ // implements REQ-kibi-verification-evidence-contract
21
21
  export async function proofMigrateLegacyCommand(options) {
22
22
  const runtime = createCliRuntime();
23
23
  const context = await runtime.open({
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import { executePruneReceipts } from "../operations/proof/prune-receipts.js";
19
19
  import { createCliRuntime } from "../runtime/cli-runtime.js";
20
- // implements REQ-kibi-proof-evidence-protocol
20
+ // implements REQ-kibi-verification-evidence-contract
21
21
  export async function proofPruneCommand(options) {
22
22
  const keepRaw = options.keep ?? "1";
23
23
  const keep = Number.parseInt(keepRaw, 10);
@@ -16,7 +16,7 @@ import { createCliRuntime } from "../runtime/cli-runtime.js";
16
16
  * Snapshot-relevant changes come first (receipt-only and ignored edits do
17
17
  * not affect the hash), and the list is capped to keep the error readable.
18
18
  */
19
- // implements REQ-kibi-proof-evidence-protocol
19
+ // implements REQ-kibi-verification-evidence-contract
20
20
  export function describeWorkspaceDrift(snapshot) {
21
21
  if (!snapshot.available)
22
22
  return " (workspace snapshot unavailable)";
@@ -40,7 +40,7 @@ export function describeWorkspaceDrift(snapshot) {
40
40
  * trimmed, non-empty ids. Empty selectors yield an empty set; blank items
41
41
  * fail fast instead of silently narrowing the selection.
42
42
  */
43
- // implements REQ-kibi-proof-evidence-protocol
43
+ // implements REQ-kibi-verification-evidence-contract
44
44
  export function parseIntegrationSelector(value, flagName) {
45
45
  if (value === undefined || value.trim() === "")
46
46
  return new Set();
@@ -84,7 +84,7 @@ async function runChild(commandArgv, cwd, env) {
84
84
  child.once("close", (code) => resolve(code ?? 1));
85
85
  });
86
86
  }
87
- // implements REQ-kibi-proof-evidence-protocol
87
+ // implements REQ-kibi-verification-evidence-contract
88
88
  export function commandEnvironment(integration, commandArgv, snapshot, workspaceRoot, testIds, outputPath) {
89
89
  return {
90
90
  ...process.env,
@@ -240,7 +240,7 @@ function summarize(result) {
240
240
  parts.push(`unchanged ${result.unchanged}`);
241
241
  return parts.join(", ");
242
242
  }
243
- // implements REQ-kibi-proof-evidence-protocol
243
+ // implements REQ-kibi-verification-evidence-contract
244
244
  export async function proveCommand(options, deps = {}) {
245
245
  const workspaceRoot = options.workspaceRoot ?? process.cwd();
246
246
  const ingestProof = deps.ingestProof ?? executeIngestProof;
@@ -1 +1 @@
1
- {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/commands/report.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,KAAK,cAAc,GAAG,QAAQ,CAAC;IAC7B,YAAY,EAAE,kBAAkB,CAAC;IACjC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC,CAAC;AA4HH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBhE;AAeD,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAyEjB"}
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/commands/report.ts"],"names":[],"mappings":"AAYA,OAAO,EACL,KAAK,kBAAkB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAC;AAGjC,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,KAAK,cAAc,GAAG,QAAQ,CAAC;IAC7B,YAAY,EAAE,kBAAkB,CAAC;IACjC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,YAAY,CAAC,EAAE,CACb,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,KAAK,EAAE,MAAM,KACV,OAAO,CAAC,cAAc,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B,CAAC,CAAC;AA+HH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgChE;AAeD,wBAAsB,aAAa,CACjC,OAAO,EAAE,aAAa,EACtB,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAyEjB"}
@@ -7,7 +7,6 @@ import { coverageSpec } from "../public/operations/specs/reporting.js";
7
7
  import { KIBI_BRAND, renderKibiBadge } from "../report/brand.js";
8
8
  import { renderHtmlReport, } from "../report/html-report.js";
9
9
  import { resolveReportRepository, } from "../report/repository.js";
10
- import { createCliRuntime } from "../runtime/cli-runtime.js";
11
10
  import { listGitRemotes } from "./github-init.js";
12
11
  function gitCommitSha(cwd) {
13
12
  try {
@@ -79,6 +78,9 @@ async function executeCoverageInContext(context, tags, limit) {
79
78
  };
80
79
  }
81
80
  async function loadCoverage(tags, limit) {
81
+ // Lazy-load the CLI runtime so coverage suites that inject loadCoverage do
82
+ // not pull the engine/plugin graph into every reportCommand import.
83
+ const { createCliRuntime } = await import("../runtime/cli-runtime.js");
82
84
  const runtime = createCliRuntime();
83
85
  const runtimeSpec = coverageSpec;
84
86
  const context = await runtime.open(runtimeSpec);
@@ -118,8 +120,21 @@ export async function openReport(filePath) {
118
120
  detached: true,
119
121
  stdio: "ignore",
120
122
  });
121
- child.once("error", reject);
123
+ const timer = setTimeout(() => {
124
+ try {
125
+ child.unref();
126
+ }
127
+ catch {
128
+ // Best-effort unref if the child never spawned.
129
+ }
130
+ reject(new Error(`Timed out opening report via ${command}`));
131
+ }, 5_000);
132
+ child.once("error", (error) => {
133
+ clearTimeout(timer);
134
+ reject(error);
135
+ });
122
136
  child.once("spawn", () => {
137
+ clearTimeout(timer);
123
138
  child.unref();
124
139
  resolve();
125
140
  });
@@ -31,6 +31,7 @@ export { COARSE_GRANULARITY_REASONS };
31
31
  export declare function isCoarseGranularityAnchor(entry: ManifestSymbolEntry): boolean;
32
32
  export declare function refreshManifestCoordinates(manifestPath: string, workspaceRoot: string, deps?: Partial<ManifestDeps> & {
33
33
  refreshSymbolCoordinates?: boolean;
34
+ quiet?: boolean;
34
35
  }): Promise<void>;
35
36
  export declare function hasAllGeneratedCoordinates(entry: ManifestSymbolEntry): boolean;
36
37
  export declare function isEligibleForCoordinateRefresh(sourceFile: string | undefined, workspaceRoot: string, deps?: Partial<ManifestDeps>): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.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E,CAAC;AAEtC,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAG7E;AAoHD,wBAAsB,0BAA0B,CAE9C,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;IAC7B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,GACA,OAAO,CAAC,IAAI,CAAC,CAuMf;AAED,wBAAgB,0BAA0B,CAExC,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAOT;AAED,wBAAgB,8BAA8B,CAE5C,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,MAAM,EACrB,IAAI,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC3B,OAAO,CAUT"}
@@ -285,22 +285,24 @@ manifestPath, workspaceRoot, deps) {
285
285
  // The generated coordinates live in the artifact beside the manifest, not
286
286
  // in the authored symbols.yaml this command also rewrites; naming the
287
287
  // artifact keeps diff audits pointed at the file that actually changed.
288
- const counts = `(refreshed=${refreshed}, unchanged=${unchanged}, failed=${failures.length})`;
289
- if (coordinatesPath !== null) {
290
- console.log(`\u2713 Refreshed symbol coordinates in ${path.relative(workspaceRoot, coordinatesPath)} ${counts}`);
291
- }
292
- else {
293
- console.log(`\u2713 Normalized symbol manifest ${path.relative(workspaceRoot, manifestPath)} ${counts}`);
294
- }
295
- const maxReportedFailures = 10;
296
- for (const failure of failures.slice(0, maxReportedFailures)) {
297
- console.log(` failed ${failure.id}: ${failure.reason}`);
298
- }
299
- if (failures.length > maxReportedFailures) {
300
- console.log(` ... and ${failures.length - maxReportedFailures} more failed symbol(s)`);
301
- }
302
- if (failures.length > 0) {
303
- console.log(" Symbols without a published coordinate entry are dropped from coverage on the next plain sync until they succeed.");
288
+ if (!deps?.quiet) {
289
+ const counts = `(refreshed=${refreshed}, unchanged=${unchanged}, failed=${failures.length})`;
290
+ if (coordinatesPath !== null) {
291
+ console.log(`\u2713 Refreshed symbol coordinates in ${path.relative(workspaceRoot, coordinatesPath)} ${counts}`);
292
+ }
293
+ else {
294
+ console.log(`\u2713 Normalized symbol manifest ${path.relative(workspaceRoot, manifestPath)} ${counts}`);
295
+ }
296
+ const maxReportedFailures = 10;
297
+ for (const failure of failures.slice(0, maxReportedFailures)) {
298
+ console.log(` failed ${failure.id}: ${failure.reason}`);
299
+ }
300
+ if (failures.length > maxReportedFailures) {
301
+ console.log(` ... and ${failures.length - maxReportedFailures} more failed symbol(s)`);
302
+ }
303
+ if (failures.length > 0) {
304
+ console.log(" Symbols without a published coordinate entry are dropped from coverage on the next plain sync until they succeed.");
305
+ }
304
306
  }
305
307
  }
306
308
  export function hasAllGeneratedCoordinates(
@@ -1 +1 @@
1
- {"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/persistence.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAEV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAiHrD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,EAAE,OAAO,CAAC;CACrB;AA8CD,iFAAiF;AACjF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,EACrB,WAAW,EAAE,SAAS,MAAM,EAAE,GAC7B,OAAO,CAAC,MAAM,CAAC,CAkCjB;AAED,0EAA0E;AAC1E,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,OAAO,CAAC,MAAM,CAAC,CAmBjB;AAED,8EAA8E;AAC9E,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,SAAS,MAAM,EAAE,GAC3B,O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
341
341
  props.push(`semantic_inventory=${toPrologString(JSON.stringify(entity.semantic_inventory))}`);
342
342
  }
343
+ if (entity.type === "req" && entity.proof_exempt !== undefined) {
344
+ props.push(`proof_exempt=${entity.proof_exempt}`);
345
+ }
346
+ if (entity.type === "req" && entity.proof_exempt_reason !== undefined) {
347
+ props.push(`proof_exempt_reason=${toPrologString(entity.proof_exempt_reason)}`);
348
+ }
343
349
  if (sourceFile)
344
350
  props.push(`sourceFile=${toPrologString(sourceFile)}`);
345
351
  if (entity.type === "symbol") {
package/dist/engine.d.ts CHANGED
@@ -58,6 +58,8 @@ export declare class EngineClient {
58
58
  start(allowSpawn?: boolean): Promise<void>;
59
59
  private connect;
60
60
  private attachSocket;
61
+ /** Settle a pending RPC at most once (abort vs response race-safe). */
62
+ private settlePending;
61
63
  private handleResponse;
62
64
  private request;
63
65
  query(goal: string, signal?: AbortSignal): Promise<PrologQueryResult>;
@@ -73,7 +75,7 @@ export declare class EngineClient {
73
75
  save(signal?: AbortSignal): Promise<PrologQueryResult>;
74
76
  storageStatus(): Promise<PrologQueryResult>;
75
77
  checkpoint(): Promise<PrologQueryResult>;
76
- queryStatusJson(): Promise<PrologQueryResult>;
78
+ queryStatusJson(signal?: AbortSignal): Promise<PrologQueryResult>;
77
79
  compact(): Promise<PrologQueryResult>;
78
80
  exportStorage(targetDirectory: string): Promise<PrologQueryResult>;
79
81
  invalidateCache(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAO9C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,a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iB,CAAC;IAI3C,UAAU,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAIxC,eAAe,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOjE,OAAO,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAIrC,aAAa,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAOxE,eAAe,IAAI,IAAI;IAIvB,SAAS,IAAI,OAAO;YAIN,oBAAoB;YAMpB,mBAAmB;YA0BnB,uBAAuB;IA6BrC,MAAM,IAAI,MAAM;IASV,IAAI,CAAC,cAAc,UAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB1C,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;CASjC;AAGD,wBAAsB,+BAA+B,CACnD,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAoJf;AAkFD,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GAAG,OAAO,CAAC,IAAI,CAAC,CA+oBhB"}
package/dist/engine.js CHANGED
@@ -783,16 +783,26 @@ export class EngineClient {
783
783
  socket.on("close", () => {
784
784
  this.socket = null;
785
785
  const error = new Error("Kibi engine connection closed");
786
- for (const pending of this.pending.values())
787
- pending.reject(error);
786
+ for (const pending of this.pending.values()) {
787
+ this.settlePending(pending, () => pending.reject(error));
788
+ }
788
789
  this.pending.clear();
789
790
  });
790
791
  socket.on("error", (error) => {
791
- for (const pending of this.pending.values())
792
- pending.reject(error);
792
+ for (const pending of this.pending.values()) {
793
+ this.settlePending(pending, () => pending.reject(error));
794
+ }
793
795
  this.pending.clear();
794
796
  });
795
797
  }
798
+ /** Settle a pending RPC at most once (abort vs response race-safe). */
799
+ settlePending(pending, settle) {
800
+ if (pending.settled)
801
+ return false;
802
+ pending.settled = true;
803
+ settle();
804
+ return true;
805
+ }
796
806
  handleResponse(value) {
797
807
  if (value === null || typeof value !== "object")
798
808
  return;
@@ -803,55 +813,20 @@ export class EngineClient {
803
813
  if (!pending)
804
814
  return;
805
815
  this.pending.delete(response.id);
806
- if (response.ok)
807
- pending.resolve(response.result);
808
- else
809
- pending.reject(new Error(response.error ?? "Kibi engine request failed"));
816
+ if (response.ok) {
817
+ this.settlePending(pending, () => pending.resolve(response.result));
818
+ }
819
+ else {
820
+ this.settlePending(pending, () => pending.reject(new Error(response.error ?? "Kibi engine request failed")));
821
+ }
810
822
  }
811
823
  async request(request, signal) {
824
+ // Connect/reconcile before taking the client queue. Holding requestTail
825
+ // across start()→reconcileAttachment()→queryStatusJson() deadlocks because
826
+ // that nested status RPC needs the same queue (see command-first clients).
812
827
  await this.start();
813
- const socket = this.socket;
814
- if (socket === null || socket.destroyed)
815
- throw new Error("Kibi engine is not connected");
816
- const id = ++this.requestId;
817
- const result = new Promise((resolve, reject) => {
818
- this.pending.set(id, {
819
- resolve: resolve,
820
- reject,
821
- });
822
- try {
823
- socket.write(frame({
824
- ...request,
825
- id,
826
- protocolVersion: ENGINE_PROTOCOL_VERSION,
827
- packageVersions: ENGINE_PACKAGE_VERSIONS,
828
- workspaceRoot: this.workspaceRoot,
829
- branch: this.branch,
830
- }));
831
- }
832
- catch (error) {
833
- this.pending.delete(id);
834
- reject(error instanceof Error ? error : new Error(String(error)));
835
- return;
836
- }
837
- if (signal !== undefined) {
838
- const abort = () => {
839
- if (!this.pending.has(id))
840
- return;
841
- this.pending.delete(id);
842
- this.cancel(id);
843
- reject(new Error("Kibi engine request cancelled"));
844
- };
845
- if (signal.aborted)
846
- abort();
847
- else
848
- signal.addEventListener("abort", abort, { once: true });
849
- }
850
- });
851
- return result;
852
- }
853
- async query(goal, signal) {
854
- let result;
828
+ // Serialize query and command frames on one socket so concurrent MCP
829
+ // traffic cannot interleave length-prefixed writes/responses.
855
830
  const previous = this.requestTail;
856
831
  let release;
857
832
  this.requestTail = new Promise((resolve) => {
@@ -859,14 +834,59 @@ export class EngineClient {
859
834
  });
860
835
  await previous;
861
836
  try {
862
- result = await this.request({ method: "query", goal }, signal);
863
- this.lastResult = result;
864
- return result;
837
+ const socket = this.socket;
838
+ if (socket === null || socket.destroyed)
839
+ throw new Error("Kibi engine is not connected");
840
+ const id = ++this.requestId;
841
+ return await new Promise((resolve, reject) => {
842
+ this.pending.set(id, {
843
+ resolve: resolve,
844
+ reject,
845
+ settled: false,
846
+ });
847
+ try {
848
+ socket.write(frame({
849
+ ...request,
850
+ id,
851
+ protocolVersion: ENGINE_PROTOCOL_VERSION,
852
+ packageVersions: ENGINE_PACKAGE_VERSIONS,
853
+ workspaceRoot: this.workspaceRoot,
854
+ branch: this.branch,
855
+ }));
856
+ }
857
+ catch (error) {
858
+ const pending = this.pending.get(id);
859
+ this.pending.delete(id);
860
+ if (pending) {
861
+ this.settlePending(pending, () => reject(error instanceof Error ? error : new Error(String(error))));
862
+ }
863
+ return;
864
+ }
865
+ if (signal !== undefined) {
866
+ const abort = () => {
867
+ const pending = this.pending.get(id);
868
+ if (!pending || pending.settled)
869
+ return;
870
+ this.pending.delete(id);
871
+ this.cancel(id);
872
+ this.settlePending(pending, () => reject(new Error("Kibi engine request cancelled")));
873
+ };
874
+ if (signal.aborted)
875
+ abort();
876
+ else
877
+ signal.addEventListener("abort", abort, { once: true });
878
+ }
879
+ });
865
880
  }
866
881
  finally {
867
882
  release();
868
883
  }
869
884
  }
885
+ async query(goal, signal) {
886
+ const result = await this.request({ method: "query", goal }, signal);
887
+ this.lastResult = result;
888
+ return result;
889
+ }
870
890
  /** Execute a versioned, goal-free engine command. Raw query remains private
871
891
  * compatibility traffic for the in-process Prolog adapter only. */
872
892
  async command(command, signal) {
@@ -952,8 +972,8 @@ export class EngineClient {
952
972
  async checkpoint() {
953
973
  return this.command({ version: 1, kind: "checkpoint" });
954
974
  }
955
- async queryStatusJson() {
956
- return this.command({ version: 1, kind: "status" });
975
+ async queryStatusJson(signal) {
976
+ return this.command({ version: 1, kind: "status" }, signal);
957
977
  }
958
978
  async compact() {
959
979
  return this.command({ version: 1, kind: "compact" });
@@ -1299,16 +1319,55 @@ export async function runEngineDaemon(options) {
1299
1319
  }
1300
1320
  mkdirSync(path.dirname(options.socketPath), { recursive: true, mode: 0o700 });
1301
1321
  if (existsSync(options.socketPath)) {
1322
+ const isLivePeerSignal = (error) => {
1323
+ if (error && typeof error === "object") {
1324
+ const code = "code" in error ? String(error.code) : "";
1325
+ if (code === "EPIPE" || code === "ECONNRESET")
1326
+ return true;
1327
+ const errno = "errno" in error
1328
+ ? Number(error.errno)
1329
+ : Number.NaN;
1330
+ // POSIX EPIPE
1331
+ if (errno === -32)
1332
+ return true;
1333
+ }
1334
+ const message = error instanceof Error ? error.message : String(error);
1335
+ return /\bEPIPE\b|\bECONNRESET\b|broken pipe/i.test(message);
1336
+ };
1302
1337
  let live = false;
1303
1338
  try {
1304
1339
  const existing = await connectSocket(options.socketPath, 100);
1305
- existing.destroy();
1340
+ // Keep a permanent error sink. Bun 1.4 can surface write EPIPE from
1341
+ // teardown into the caller promise on some CI runners, replacing the
1342
+ // intended live-listener error.
1343
+ existing.on("error", () => undefined);
1306
1344
  live = true;
1345
+ try {
1346
+ existing.destroy();
1347
+ }
1348
+ catch {
1349
+ // Ignore destroy races; live detection already succeeded.
1350
+ }
1351
+ existing.unref?.();
1307
1352
  }
1308
- catch {
1309
- // A refused connection means this is a stale filesystem socket.
1353
+ catch (error) {
1354
+ // Bun 1.4 can reject the probe with EPIPE/ECONNRESET against a live
1355
+ // unix listener instead of resolving connect.
1356
+ if (isLivePeerSignal(error)) {
1357
+ live = true;
1358
+ }
1359
+ // Otherwise a refused connection means a stale filesystem socket.
1310
1360
  }
1311
1361
  if (live) {
1362
+ try {
1363
+ await prolog.terminate();
1364
+ }
1365
+ catch (error) {
1366
+ // Best-effort cleanup; Bun may surface late EPIPE here too.
1367
+ if (!isLivePeerSignal(error)) {
1368
+ // Ignore non-EPIPE terminate failures.
1369
+ }
1370
+ }
1312
1371
  throw new Error(`A Kibi engine is already listening at ${options.socketPath}`);
1313
1372
  }
1314
1373
  try {
@@ -1326,7 +1385,6 @@ export async function runEngineDaemon(options) {
1326
1385
  let idleCompactionQueued = false;
1327
1386
  const queryCache = new Map();
1328
1387
  let freshnessCache = null;
1329
- const cancelledRequests = new Set();
1330
1388
  const clients = new Set();
1331
1389
  let shuttingDown = false;
1332
1390
  const exactBranchStatus = (result) => {
@@ -1398,7 +1456,7 @@ export async function runEngineDaemon(options) {
1398
1456
  void shutdown();
1399
1457
  }, engineIdleTimeoutMs());
1400
1458
  };
1401
- const handle = async (request) => {
1459
+ const handle = async (request, cancelledRequests) => {
1402
1460
  if (request.protocolVersion !== ENGINE_PROTOCOL_VERSION) {
1403
1461
  throw new Error(`Kibi engine protocol mismatch: client=${request.protocolVersion ?? "missing"}, server=${ENGINE_PROTOCOL_VERSION}`);
1404
1462
  }
@@ -1661,6 +1719,13 @@ export async function runEngineDaemon(options) {
1661
1719
  setImmediate(() => void shutdown());
1662
1720
  return { stopped: true };
1663
1721
  case "cancel":
1722
+ // Best-effort: marks the id so a *queued* request on this connection
1723
+ // is skipped before handle(). A request already inside
1724
+ // `await prolog.query(...)` cannot be interrupted without redesigning
1725
+ // SWI interactive cancellation; the client still rejects locally on
1726
+ // AbortSignal, but the daemon queue remains occupied until that Prolog
1727
+ // call returns. Cancel marks are per-connection. See
1728
+ // docs/mcp-reference.md ("Engine cancellation limits").
1664
1729
  if (typeof request.cancelOf === "number") {
1665
1730
  cancelledRequests.add(request.cancelOf);
1666
1731
  }
@@ -1720,6 +1785,9 @@ export async function runEngineDaemon(options) {
1720
1785
  server.on("connection", (socket) => {
1721
1786
  clients.add(socket);
1722
1787
  activeClients += 1;
1788
+ // Request ids are per-connection. Cancel marks must not be daemon-global
1789
+ // or Client B's id=1 is poisoned by Client A's cancelOf=1.
1790
+ const cancelledRequests = new Set();
1723
1791
  let buffer = Buffer.alloc(0);
1724
1792
  socket.on("data", (chunk) => {
1725
1793
  try {
@@ -1742,7 +1810,7 @@ export async function runEngineDaemon(options) {
1742
1810
  return;
1743
1811
  }
1744
1812
  try {
1745
- const result = await handle(request);
1813
+ const result = await handle(request, cancelledRequests);
1746
1814
  writeSocketFrame(socket, {
1747
1815
  id: request.id,
1748
1816
  ok: true,
@@ -1758,6 +1826,11 @@ export async function runEngineDaemon(options) {
1758
1826
  serverPackageVersions: ENGINE_PACKAGE_VERSIONS,
1759
1827
  });
1760
1828
  }
1829
+ finally {
1830
+ // Drop stale cancel marks for in-flight goals that still ran
1831
+ // to completion after cancelOf (SWI cannot interrupt them).
1832
+ cancelledRequests.delete(request.id);
1833
+ }
1761
1834
  })
1762
1835
  .catch(() => undefined);
1763
1836
  });
@@ -0,0 +1,84 @@
1
+ /** Preferred project-local Kibi env file (harness-independent). */
2
+ export declare const KIBI_PROJECT_ENV_FILE = ".env.kibi";
3
+ /** Legacy generic dotenv still loaded for compatibility only. */
4
+ export declare const KIBI_LEGACY_ENV_FILE = ".env";
5
+ export type EnvValueSource = "process" | "project_env" | "user_env" | "legacy_env" | "missing";
6
+ export type BootstrapKibiEnvironmentResult = Readonly<{
7
+ workspaceRoot: string;
8
+ userEnvPath: string;
9
+ projectEnvPath: string;
10
+ legacyEnvPath: string;
11
+ /** Attribution for keys present after bootstrap (never includes secret values). */
12
+ sources: Readonly<Record<string, EnvValueSource>>;
13
+ keysLoadedFromUser: readonly string[];
14
+ keysLoadedFromProject: readonly string[];
15
+ keysLoadedFromLegacy: readonly string[];
16
+ }>;
17
+ export type BootstrapKibiEnvironmentOptions = Readonly<{
18
+ env?: NodeJS.ProcessEnv;
19
+ startDir?: string;
20
+ homedir?: string;
21
+ /** Override XDG config home (defaults to env.XDG_CONFIG_HOME). */
22
+ xdgConfigHome?: string;
23
+ /**
24
+ * Keys that were non-empty on the real process before any Kibi file load.
25
+ * Callers normally omit this; the first default-env bootstrap remembers it.
26
+ */
27
+ initialNonEmptyProcessKeys?: ReadonlySet<string>;
28
+ }>;
29
+ type EnvEntry = Readonly<{
30
+ key: string;
31
+ value: string;
32
+ }>;
33
+ /**
34
+ * Test-only: clear remembered process-key snapshot and last bootstrap result.
35
+ */
36
+ export declare function resetKibiEnvironmentBootstrapStateForTests(): void;
37
+ /**
38
+ * Last bootstrap against the real `process.env`, if any.
39
+ */
40
+ export declare function getLastBootstrapResult(): BootstrapKibiEnvironmentResult | null;
41
+ /**
42
+ * Canonical workspace root for Kibi env files and KB attachment.
43
+ * Uses KIBI_WORKSPACE / KIBI_PROJECT_ROOT / KIBI_ROOT, then .kb / .git discovery.
44
+ */
45
+ export declare function resolveKibiWorkspaceRoot(startDir?: string, env?: NodeJS.ProcessEnv): string;
46
+ export declare function resolveEnvFilePath(envFileName: string, workspaceRoot: string): string;
47
+ /** User-wide Kibi env file: $XDG_CONFIG_HOME/kibi/env or ~/.config/kibi/env. */
48
+ export declare function resolveKibiUserEnvPath(options?: Readonly<{
49
+ homedir?: string;
50
+ xdgConfigHome?: string;
51
+ env?: NodeJS.ProcessEnv;
52
+ }>): string;
53
+ export declare function resolveKibiProjectEnvPath(workspaceRoot: string, env?: NodeJS.ProcessEnv): string;
54
+ export declare function parseEnvContent(content: string): EnvEntry[];
55
+ /**
56
+ * Load Kibi-owned env files into `process.env` (or an injectable env object).
57
+ * Blank values are treated as unset (never applied, never overwrite).
58
+ * Existing non-empty process keys are never overwritten. Project overrides user.
59
+ * Legacy `.env` only gap-fills and is attributed as `legacy_env`.
60
+ * Call only from CLI/MCP entrypoints — not on library import.
61
+ */
62
+ export declare function bootstrapKibiEnvironment(options?: BootstrapKibiEnvironmentOptions): BootstrapKibiEnvironmentResult;
63
+ /**
64
+ * Resolve a secret source label from an actual bootstrap result.
65
+ * Never reconstructs attribution by re-reading files alone.
66
+ */
67
+ export declare function secretSourceFromBootstrap(key: string, bootstrap: BootstrapKibiEnvironmentResult, env?: NodeJS.ProcessEnv): EnvValueSource;
68
+ export type InspectSecretSourceOptions = BootstrapKibiEnvironmentOptions & Readonly<{
69
+ /** @deprecated Prefer bootstrap result sources; kept for targeted tests. */
70
+ initialProcessKeys?: ReadonlySet<string>;
71
+ }>;
72
+ /**
73
+ * Read-only secret attribution via a dry bootstrap on an env snapshot.
74
+ * Prefer `secretSourceFromBootstrap` with the real entrypoint bootstrap result.
75
+ * Never returns secret values.
76
+ */
77
+ export declare function inspectSecretSource(key: string, options?: InspectSecretSourceOptions): EnvValueSource;
78
+ /**
79
+ * Whether a secret is available for provider use (non-empty after resolution).
80
+ * Blank values are unset.
81
+ */
82
+ export declare function isSecretAvailable(key: string, options?: InspectSecretSourceOptions): boolean;
83
+ export {};
84
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/env/bootstrap.ts"],"names":[],"mappings":"AA4BA,mEAAmE;AAEnE,eAAO,MAAM,qBAAqB,cAAc,CAAC;AAEjD,iEAAiE;AAEjE,eAAO,MAAM,oBAAoB,SAAS,CAAC;AAG3C,MAAM,MAAM,cAAc,GACtB,SAAS,GACT,aAAa,GACb,UAAU,GACV,YAAY,GACZ,SAAS,CAAC;AAGd,MAAM,MAAM,8BAA8B,GAAG,QAAQ,CAAC;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,mFAAmF;IACnF,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAClD,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,CAAC,CAAC;AAGH,MAAM,MAAM,+BAA+B,GAAG,QAA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