kibi-cli 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/dist/cli-protocol.d.ts.map +1 -1
  2. package/dist/cli-protocol.js +3 -2
  3. package/dist/commands/aggregated-checks.d.ts +7 -0
  4. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  5. package/dist/commands/aggregated-checks.js +25 -1
  6. package/dist/commands/check.d.ts.map +1 -1
  7. package/dist/commands/check.js +21 -13
  8. package/dist/commands/doctor.d.ts.map +1 -1
  9. package/dist/commands/doctor.js +105 -24
  10. package/dist/commands/github-init.d.ts +1 -1
  11. package/dist/commands/github-init.d.ts.map +1 -1
  12. package/dist/commands/github-init.js +1 -1
  13. package/dist/commands/init-helpers.d.ts +17 -2
  14. package/dist/commands/init-helpers.d.ts.map +1 -1
  15. package/dist/commands/init-helpers.js +123 -23
  16. package/dist/commands/init.d.ts.map +1 -1
  17. package/dist/commands/init.js +110 -15
  18. package/dist/commands/prove.d.ts.map +1 -1
  19. package/dist/commands/prove.js +10 -18
  20. package/dist/commands/sync/cache.d.ts +20 -1
  21. package/dist/commands/sync/cache.d.ts.map +1 -1
  22. package/dist/commands/sync/cache.js +51 -2
  23. package/dist/commands/sync/discovery.d.ts.map +1 -1
  24. package/dist/commands/sync/discovery.js +1 -1
  25. package/dist/commands/sync/persistence.d.ts.map +1 -1
  26. package/dist/commands/sync/persistence.js +8 -0
  27. package/dist/commands/sync.d.ts.map +1 -1
  28. package/dist/commands/sync.js +11 -3
  29. package/dist/engine.d.ts +26 -0
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +126 -29
  32. package/dist/extractors/manifest.d.ts.map +1 -1
  33. package/dist/extractors/manifest.js +66 -28
  34. package/dist/extractors/markdown.d.ts +2 -0
  35. package/dist/extractors/markdown.d.ts.map +1 -1
  36. package/dist/extractors/markdown.js +14 -3
  37. package/dist/extractors/relationships.d.ts.map +1 -1
  38. package/dist/extractors/relationships.js +1 -0
  39. package/dist/intent-search.d.ts.map +1 -1
  40. package/dist/intent-search.js +68 -29
  41. package/dist/operations/bootstrap/generate.d.ts.map +1 -1
  42. package/dist/operations/bootstrap/generate.js +4 -3
  43. package/dist/operations/modeling/model-requirement.d.ts +1 -1
  44. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  45. package/dist/operations/modeling/model-requirement.js +176 -10
  46. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  47. package/dist/operations/modeling/predicate-applyplan.js +14 -2
  48. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  49. package/dist/operations/modeling/predicate-loader.js +24 -0
  50. package/dist/operations/modeling/predicate-types.d.ts +4 -0
  51. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  52. package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
  53. package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
  54. package/dist/operations/modeling/predicate-vocabulary.js +169 -0
  55. package/dist/operations/modeling/requirement-types.d.ts +5 -0
  56. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  57. package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
  58. package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
  59. package/dist/operations/modeling/vocabulary-alignment.js +178 -0
  60. package/dist/operations/mutation/contradictions.d.ts +3 -0
  61. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  62. package/dist/operations/mutation/contradictions.js +29 -0
  63. package/dist/operations/mutation/delete.d.ts.map +1 -1
  64. package/dist/operations/mutation/delete.js +33 -1
  65. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
  66. package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
  67. package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
  68. package/dist/operations/mutation/relationships.d.ts +1 -1
  69. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  70. package/dist/operations/mutation/relationships.js +1 -0
  71. package/dist/operations/mutation/saga.d.ts +5 -0
  72. package/dist/operations/mutation/saga.d.ts.map +1 -1
  73. package/dist/operations/mutation/saga.js +10 -0
  74. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  75. package/dist/operations/mutation/serialization.js +2 -0
  76. package/dist/operations/mutation/source-authoring.d.ts +6 -0
  77. package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
  78. package/dist/operations/mutation/source-authoring.js +65 -26
  79. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  80. package/dist/operations/mutation/strict-fact.js +5 -0
  81. package/dist/operations/mutation/types.d.ts +17 -0
  82. package/dist/operations/mutation/types.d.ts.map +1 -1
  83. package/dist/operations/mutation/upsert.d.ts +6 -0
  84. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  85. package/dist/operations/mutation/upsert.js +72 -4
  86. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  87. package/dist/operations/mutation/validate-upsert.js +24 -1
  88. package/dist/operations/mutation/validation.d.ts.map +1 -1
  89. package/dist/operations/mutation/validation.js +16 -3
  90. package/dist/operations/planning/apply-plan.d.ts.map +1 -1
  91. package/dist/operations/planning/apply-plan.js +61 -17
  92. package/dist/operations/planning/compile-intent.d.ts.map +1 -1
  93. package/dist/operations/planning/compile-intent.js +3 -1
  94. package/dist/operations/proof/code-scope.d.ts +17 -0
  95. package/dist/operations/proof/code-scope.d.ts.map +1 -0
  96. package/dist/operations/proof/code-scope.js +60 -0
  97. package/dist/operations/proof/ingest-proof.d.ts +4 -2
  98. package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
  99. package/dist/operations/proof/ingest-proof.js +207 -74
  100. package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
  101. package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
  102. package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
  103. package/dist/operations/proof/prune-receipts.js +7 -5
  104. package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
  105. package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
  106. package/dist/plugins/compose-semantic-classifier.js +8 -3
  107. package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
  108. package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
  109. package/dist/plugins/compose-vocabulary-alignment.js +141 -0
  110. package/dist/plugins/external-allowlist.d.ts +7 -0
  111. package/dist/plugins/external-allowlist.d.ts.map +1 -1
  112. package/dist/plugins/external-allowlist.js +13 -0
  113. package/dist/plugins/index.d.ts +2 -0
  114. package/dist/plugins/index.d.ts.map +1 -1
  115. package/dist/plugins/index.js +4 -0
  116. package/dist/plugins/registry.d.ts +2 -1
  117. package/dist/plugins/registry.d.ts.map +1 -1
  118. package/dist/plugins/registry.js +22 -1
  119. package/dist/prolog/codec.d.ts.map +1 -1
  120. package/dist/prolog/codec.js +2 -0
  121. package/dist/prolog.d.ts +36 -0
  122. package/dist/prolog.d.ts.map +1 -1
  123. package/dist/prolog.js +78 -9
  124. package/dist/public/diagnostic-usage.d.ts.map +1 -1
  125. package/dist/public/diagnostic-usage.js +7 -25
  126. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  127. package/dist/public/impact/full-kb-quality.js +4 -12
  128. package/dist/public/operations/catalog.d.ts +36 -7
  129. package/dist/public/operations/catalog.d.ts.map +1 -1
  130. package/dist/public/operations/check-executor.d.ts.map +1 -1
  131. package/dist/public/operations/check-executor.js +10 -2
  132. package/dist/public/operations/check-helpers.d.ts +6 -0
  133. package/dist/public/operations/check-helpers.d.ts.map +1 -1
  134. package/dist/public/operations/check-helpers.js +21 -1
  135. package/dist/public/operations/contracts.d.ts.map +1 -1
  136. package/dist/public/operations/contracts.js +16 -0
  137. package/dist/public/operations/discovery-entities.d.ts +42 -2
  138. package/dist/public/operations/discovery-entities.d.ts.map +1 -1
  139. package/dist/public/operations/discovery-entities.js +195 -22
  140. package/dist/public/operations/discovery-executors.d.ts +1 -0
  141. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  142. package/dist/public/operations/discovery-executors.js +75 -46
  143. package/dist/public/operations/migration-plan.d.ts +2 -0
  144. package/dist/public/operations/migration-plan.d.ts.map +1 -1
  145. package/dist/public/operations/migration-plan.js +50 -0
  146. package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
  147. package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
  148. package/dist/public/operations/predicate-schema-conformance.js +242 -0
  149. package/dist/public/operations/prolog-json.d.ts.map +1 -1
  150. package/dist/public/operations/prolog-json.js +9 -3
  151. package/dist/public/operations/result-envelope.d.ts +34 -1
  152. package/dist/public/operations/result-envelope.d.ts.map +1 -1
  153. package/dist/public/operations/result-envelope.js +78 -2
  154. package/dist/public/operations/runtime-types.d.ts +1 -1
  155. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  156. package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
  157. package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
  158. package/dist/public/operations/specs/check-rules.generated.js +8 -1
  159. package/dist/public/operations/specs/check.d.ts +1 -1
  160. package/dist/public/operations/specs/discovery.d.ts +7 -1
  161. package/dist/public/operations/specs/discovery.d.ts.map +1 -1
  162. package/dist/public/operations/specs/discovery.js +7 -1
  163. package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
  164. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  165. package/dist/public/operations/specs/mutation-schemas.js +21 -3
  166. package/dist/public/operations/specs/reporting.d.ts +8 -0
  167. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  168. package/dist/public/operations/specs/reporting.js +46 -15
  169. package/dist/public/operations/specs/upsert.d.ts +28 -5
  170. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  171. package/dist/public/operations/specs/upsert.js +1 -1
  172. package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
  173. package/dist/public/operations/symbol-repair-plan.js +8 -3
  174. package/dist/public/schemas/entity.d.ts.map +1 -1
  175. package/dist/public/schemas/entity.js +22 -0
  176. package/dist/public/schemas/relationship.d.ts.map +1 -1
  177. package/dist/public/schemas/relationship.js +1 -0
  178. package/dist/public/skills/kibi-usage/SKILL.md +7 -3
  179. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  180. package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  181. package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  182. package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
  183. package/dist/public/telemetry-acceptance.d.ts.map +1 -1
  184. package/dist/public/telemetry-acceptance.js +21 -5
  185. package/dist/relationships/shards.d.ts +6 -0
  186. package/dist/relationships/shards.d.ts.map +1 -1
  187. package/dist/relationships/shards.js +26 -19
  188. package/dist/schemas/entity.schema.json +32 -0
  189. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  190. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  191. package/dist/traceability/staged-entity-id-style.d.ts +12 -0
  192. package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
  193. package/dist/traceability/staged-entity-id-style.js +68 -0
  194. package/dist/traceability/temp-kb.d.ts.map +1 -1
  195. package/dist/traceability/temp-kb.js +8 -0
  196. package/dist/traceability/validate.js +1 -1
  197. package/dist/types/entities.d.ts +2 -0
  198. package/dist/types/entities.d.ts.map +1 -1
  199. package/dist/types/relationships.d.ts +1 -1
  200. package/dist/types/relationships.d.ts.map +1 -1
  201. package/dist/utils/entity-id-style.d.ts +27 -0
  202. package/dist/utils/entity-id-style.d.ts.map +1 -0
  203. package/dist/utils/entity-id-style.js +81 -0
  204. package/dist/utils/git-repository-context.d.ts +50 -0
  205. package/dist/utils/git-repository-context.d.ts.map +1 -0
  206. package/dist/utils/git-repository-context.js +259 -0
  207. package/dist/utils/rule-registry.d.ts +5 -0
  208. package/dist/utils/rule-registry.d.ts.map +1 -1
  209. package/dist/utils/rule-registry.generated.d.ts +37 -0
  210. package/dist/utils/rule-registry.generated.d.ts.map +1 -1
  211. package/dist/utils/rule-registry.generated.js +44 -0
  212. package/dist/utils/strict-modeling.d.ts +7 -0
  213. package/dist/utils/strict-modeling.d.ts.map +1 -1
  214. package/dist/utils/strict-modeling.js +11 -0
  215. package/package.json +4 -4
  216. package/schema/entities.pl +60 -1
  217. package/schema/relationships.pl +17 -4
  218. package/schema/validation.pl +118 -20
  219. package/src/public/diagnostic-usage.ts +16 -24
  220. package/src/public/impact/full-kb-quality.ts +4 -16
  221. package/src/public/operations/check-executor.ts +12 -1
  222. package/src/public/operations/check-helpers.ts +27 -1
  223. package/src/public/operations/contracts.ts +19 -0
  224. package/src/public/operations/discovery-entities.ts +292 -23
  225. package/src/public/operations/discovery-executors.ts +91 -55
  226. package/src/public/operations/migration-plan.ts +57 -0
  227. package/src/public/operations/predicate-schema-conformance.ts +362 -0
  228. package/src/public/operations/prolog-json.ts +9 -3
  229. package/src/public/operations/result-envelope.ts +114 -2
  230. package/src/public/operations/runtime-types.ts +1 -1
  231. package/src/public/operations/specs/check-rules.generated.ts +8 -1
  232. package/src/public/operations/specs/discovery.ts +8 -1
  233. package/src/public/operations/specs/mutation-schemas.ts +23 -3
  234. package/src/public/operations/specs/reporting.ts +69 -22
  235. package/src/public/operations/specs/upsert.ts +1 -1
  236. package/src/public/operations/symbol-repair-plan.ts +13 -3
  237. package/src/public/schemas/entity.ts +22 -0
  238. package/src/public/schemas/relationship.ts +1 -0
  239. package/src/public/skills/kibi-usage/SKILL.md +7 -3
  240. package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
  241. package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
  242. package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
  243. package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
  244. package/src/public/telemetry-acceptance.ts +37 -6
  245. package/src/schemas/entity.schema.json +32 -0
  246. package/src/schemas/relationship.schema.json +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"cli-protocol.d.ts","sourceRoot":"","sources":["../src/c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,13 +5,14 @@ import { isOperationName } from "./cli-operation-metadata.js";
5
5
  import { prepareOperationInput, } from "./cli-validate.js";
6
6
  import { operationData, toKibiResult, } from "./public/operations/result-envelope.js";
7
7
  const outputValidator = new Ajv2020({ strict: false, allErrors: true });
8
- function errorResult(operation, error, spec) {
8
+ function errorResult(operation, error, spec, attempted = true) {
9
9
  const envelope = toKibiResult(spec ?? {
10
10
  name: operation,
11
11
  effects: [],
12
12
  resultVersion: `kibi.${operation}.v1`,
13
13
  }, null, {
14
14
  status: "error",
15
+ attempted,
15
16
  error: {
16
17
  code: error.code,
17
18
  message: error.detail,
@@ -42,7 +43,7 @@ export async function executeOperation(catalogName, input, context) {
42
43
  const spec = await loadOperationSpec(catalogName);
43
44
  const prepared = prepareOperationInput(input, spec.businessInputSchema);
44
45
  if (!prepared.valid) {
45
- return errorResult(catalogName, new InputError("VALIDATION_FAILED", prepared.errors.join("; ")), spec);
46
+ return errorResult(catalogName, new InputError("VALIDATION_FAILED", prepared.errors.join("; ")), spec, false);
46
47
  }
47
48
  try {
48
49
  const executionContext = prepared.telemetry
@@ -1,5 +1,12 @@
1
1
  import { type PrologProcess } from "../prolog.js";
2
2
  import type { Violation } from "./check.js";
3
+ /**
4
+ * Forward the invoking process's ontology-quality thresholds. The engine
5
+ * daemon outlives the CLI/MCP call that started it, so its own environment
6
+ * would otherwise decide. Prolog validates the values and falls back to its
7
+ * defaults for anything out of range.
8
+ */
9
+ export declare function ontologyQualityOverridesGoal(env?: NodeJS.ProcessEnv): string;
3
10
  /**
4
11
  * Run all checks using the aggregated Prolog predicates.
5
12
  * This makes a single Prolog call and parses JSON output, significantly
@@ -1 +1 @@
1
- {"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAW5C;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EACpC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC,CA8DtB"}
1
+ {"version":3,"file":"aggregated-checks.d.ts","sourceRoot":"","sources":["../../src/commands/aggregated-checks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,cAAc,CAAC;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAiB5C;;;;;GAKG;AAEH,wBAAgB,4BAA4B,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAYR;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,EACpC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,GACjC,OAAO,CAAC,SAAS,EAAE,CAAC,CA8DtB"}
@@ -1,6 +1,30 @@
1
1
  import path from "node:path";
2
2
  import { resolveKbPlPath } from "../prolog.js";
3
3
  import { escapeAtom, toPrologAtom } from "../prolog/codec.js";
4
+ function ontologyQualitySetting(raw) {
5
+ if (raw === undefined || raw.trim() === "")
6
+ return "default";
7
+ const value = Number(raw.trim());
8
+ return Number.isFinite(value) ? String(value) : "default";
9
+ }
10
+ /**
11
+ * Forward the invoking process's ontology-quality thresholds. The engine
12
+ * daemon outlives the CLI/MCP call that started it, so its own environment
13
+ * would otherwise decide. Prolog validates the values and falls back to its
14
+ * defaults for anything out of range.
15
+ */
16
+ // implements REQ-kibi-ontology-quality
17
+ export function ontologyQualityOverridesGoal(env = process.env) {
18
+ const ratio = ontologyQualitySetting(env.KIBI_ONTOLOGY_QUALITY_MAX_SINGLETON_RATIO);
19
+ const minFacts = ontologyQualitySetting(env.KIBI_ONTOLOGY_QUALITY_MIN_FACTS);
20
+ // call/1 defers resolution: a literal module-qualified goal is checked by
21
+ // the toplevel when the query is read, before use_module has loaded
22
+ // semantic_quality.pl (the same reason the check calls use call/1).
23
+ return `( predicate_property(semantic_quality:set_ontology_quality_overrides(_, _), defined)
24
+ -> call(semantic_quality:set_ontology_quality_overrides(${ratio}, ${minFacts}))
25
+ ; true
26
+ )`;
27
+ }
4
28
  /**
5
29
  * Run all checks using the aggregated Prolog predicates.
6
30
  * This makes a single Prolog call and parses JSON output, significantly
@@ -25,7 +49,7 @@ export async function runAggregatedChecks(prolog, rulesAllowlist) {
25
49
  ; ${fallbackQuery}
26
50
  )`
27
51
  : fallbackQuery;
28
- const query = `(use_module('${checksPlPathEscaped}'), ${checksQuery})`;
52
+ const query = `(use_module('${checksPlPathEscaped}'), ${ontologyQualityOverridesGoal()}, ${checksQuery})`;
29
53
  const result = await prolog.query(query);
30
54
  if (!result.success) {
31
55
  throw new Error(`Aggregated checks query failed: ${result.error || "Unknown error"}`);
@@ -1 +1 @@
1
- {"version":3,"file":"check.d.ts","sourceRoot":"","sources":["../../src/commands/check.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAgE7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAE3D,YAAY,EAAE,SAAS,EAAE,CAAC;AAE1B,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAifD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACtC,MAAM,EAAE,CAAC,GAAG,IA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ACZ,OAAO,CAAC,MAAM,EAAE,CAAC,CAiBnB;AACD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAgEtB;AAID,wBAAsB,aAAa,CACjC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAmGtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,YAAY,EAAE,MAAM,EAAE,GACrB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyCtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAgDtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CA0BtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,SAAS,EAAE,CAAC,CA+BtB"}
@@ -29,6 +29,7 @@ import { KIBI_NO_IMPACT_DECLARATION, KIBI_SYMBOLS_MANIFEST_PATH, KIBI_SYMBOL_COO
29
29
  import { getStagedInventory, supportedStagedFiles, } from "../traceability/git-staged.js";
30
30
  import { validateStagedMarkdown } from "../traceability/markdown-validate.js";
31
31
  import { collectStagedKibiDiagnostics, } from "../traceability/staged-diagnostics.js";
32
+ import { createStagedEntityIdStyleDiagnostics } from "../traceability/staged-entity-id-style.js";
32
33
  import { analyzeStagedFileCoverage, } from "../traceability/staged-file-coverage.js";
33
34
  import { classifyKibiImpactEvidence, isBehaviorSourceEdit, parseKibiImpactOverride, } from "../traceability/staged-impact-contract.js";
34
35
  import { assessStagedSymbolsManifest, collectStagedAuthoredSymbolsManifestEvidence, } from "../traceability/staged-symbols-manifest.js";
@@ -544,23 +545,26 @@ export async function checkCommand(options) {
544
545
  ? { activeEntityIds: activeStagedSymbolEntityIds }
545
546
  : {}),
546
547
  symbolsByFile,
547
- }), ...createSemanticReviewDiagnostics({ symbolsByFile }));
548
+ }), ...createSemanticReviewDiagnostics({ symbolsByFile }), ...createStagedEntityIdStyleDiagnostics(markdownFiles));
548
549
  if (allSymbols.length === 0 && stagedEntityResults.length === 0) {
549
550
  if (stagedKibiDiagnostics.length > 0) {
551
+ const blocking = hasBlockingImpactDiagnostics(stagedKibiDiagnostics);
550
552
  printStagedResult({
551
553
  format: options.format,
552
554
  coverage: stagedCoverage,
553
555
  qualityDiagnostics: stagedKibiDiagnostics,
554
- messages: [formatStagedKibiDiagnostics(stagedKibiDiagnostics)],
556
+ messages: [
557
+ formatStagedKibiDiagnostics(stagedKibiDiagnostics),
558
+ // Advisory-only findings still pass; say so explicitly.
559
+ ...(!blocking
560
+ ? ["✓ No violations found in staged files."]
561
+ : []),
562
+ ],
555
563
  });
556
564
  if (options.dryRun) {
557
565
  return { exitCode: 0 };
558
566
  }
559
- return {
560
- exitCode: hasBlockingImpactDiagnostics(stagedKibiDiagnostics)
561
- ? 1
562
- : 0,
563
- };
567
+ return { exitCode: blocking ? 1 : 0 };
564
568
  }
565
569
  printStagedResult({
566
570
  format: options.format,
@@ -573,20 +577,23 @@ export async function checkCommand(options) {
573
577
  }
574
578
  if (allSymbols.length === 0) {
575
579
  if (stagedKibiDiagnostics.length > 0) {
580
+ const blocking = hasBlockingImpactDiagnostics(stagedKibiDiagnostics);
576
581
  printStagedResult({
577
582
  format: options.format,
578
583
  coverage: stagedCoverage,
579
584
  qualityDiagnostics: stagedKibiDiagnostics,
580
- messages: [formatStagedKibiDiagnostics(stagedKibiDiagnostics)],
585
+ messages: [
586
+ formatStagedKibiDiagnostics(stagedKibiDiagnostics),
587
+ // Advisory-only findings still pass; say so explicitly.
588
+ ...(!blocking
589
+ ? ["✓ No violations found in staged files."]
590
+ : []),
591
+ ],
581
592
  });
582
593
  if (options.dryRun) {
583
594
  return { exitCode: 0 };
584
595
  }
585
- return {
586
- exitCode: hasBlockingImpactDiagnostics(stagedKibiDiagnostics)
587
- ? 1
588
- : 0,
589
- };
596
+ return { exitCode: blocking ? 1 : 0 };
590
597
  }
591
598
  printStagedResult({
592
599
  format: options.format,
@@ -850,6 +857,7 @@ export async function checkNoDanglingRefs(prolog) {
850
857
  "constrains",
851
858
  "requires_property",
852
859
  "supersedes",
860
+ "restates",
853
861
  "relates_to",
854
862
  ];
855
863
  const allRels = [];
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AA6DA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAwF/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAkEA,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAGD,wBAAsB,aAAa,CACjC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAgG/B;AAED,wBAAsB,4BAA4B,CAChD,IAAI,GAAE,MAAM,OAAO,CAAC;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,CACT,GACxC,OAAO,CAAC,OAAO,CAAC,CAOlB;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;;;;;;;;;;;;;;;;MAkE3C;AAkGD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGzE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAepB"}
@@ -23,7 +23,9 @@ import { fileURLToPath } from "node:url";
23
23
  import { bootstrapKibiEnvironment, secretSourceFromBootstrap, } from "../env/bootstrap.js";
24
24
  import { describeConfiguredCapabilityPlugins, readProjectKibiConfig, } from "../plugins/project-config.js";
25
25
  import { buildMigrationPlan, migrationAction, } from "../public/operations/migration-plan.js";
26
+ import { resolveGitRepository, } from "../utils/git-repository-context.js";
26
27
  import { readKbManifestStatus } from "../utils/kb-manifest.js";
28
+ import { hasManagedHooks, outdatedManagedHooks } from "./init-helpers.js";
27
29
  import { planLegacyStorageMigration } from "./legacy-storage-migration.js";
28
30
  /**
29
31
  * First-party plugin diagnostics known without importing the package.
@@ -38,6 +40,10 @@ const JEV_DEFAULT_MODEL = "jev-latest";
38
40
  const JEV_MAX_TIMEOUT_MS = 120_000;
39
41
  // implements REQ-003
40
42
  export async function doctorCommand(options = {}) {
43
+ // The repository context is per-diagnostic-run state: clearing here keeps
44
+ // repeated in-process invocations honest when core.hooksPath changes
45
+ // between runs, without introducing another ambient cache.
46
+ cachedRepositoryContext = undefined;
41
47
  const checks = [
42
48
  {
43
49
  name: "SWI-Prolog",
@@ -71,6 +77,10 @@ export async function doctorCommand(options = {}) {
71
77
  name: "post-rewrite hook",
72
78
  check: checkPostRewriteHook,
73
79
  },
80
+ {
81
+ name: "Kibi-managed hook sections",
82
+ check: checkManagedHookSections,
83
+ },
74
84
  {
75
85
  name: "Capability plugins",
76
86
  check: checkCapabilityPlugins,
@@ -525,15 +535,86 @@ function checkGitRepository() {
525
535
  };
526
536
  }
527
537
  }
538
+ // Hook health must be diagnosed against the hooks directory Git actually
539
+ // executes (resolved via git rev-parse --git-path hooks, honoring
540
+ // core.hooksPath and linked worktrees), not against <cwd>/.git/hooks.
541
+ // implements REQ-git-hook-effective-install
542
+ let cachedRepositoryContext;
543
+ function doctorRepositoryContext() {
544
+ const cwd = process.cwd();
545
+ if (cachedRepositoryContext?.cwd !== cwd) {
546
+ const resolution = resolveGitRepository(cwd);
547
+ cachedRepositoryContext = {
548
+ cwd,
549
+ context: resolution.status === "ok" ? resolution.context : null,
550
+ };
551
+ }
552
+ return cachedRepositoryContext.context;
553
+ }
554
+ function effectiveHooksDir() {
555
+ const context = doctorRepositoryContext();
556
+ return (context?.effectiveHooksDir ?? path.join(process.cwd(), ".git", "hooks"));
557
+ }
558
+ function shellQuote(value) {
559
+ return `'${value.replace(/'/g, `'\\''`)}'`;
560
+ }
561
+ function remediationHookPaths(...hooks) {
562
+ const dir = effectiveHooksDir();
563
+ return `Run: chmod +x ${hooks.map((hook) => shellQuote(path.join(dir, hook))).join(" ")}`;
564
+ }
565
+ function hooksPathSuffix() {
566
+ const context = doctorRepositoryContext();
567
+ if (!context?.hooksPathConfig)
568
+ return "";
569
+ const origin = context.hooksPathOrigin
570
+ ? ` from ${context.hooksPathOrigin}`
571
+ : "";
572
+ return ` (core.hooksPath=${context.hooksPathConfig}${origin})`;
573
+ }
574
+ /**
575
+ * Kibi-managed hook sections must match what this CLI installs. A section
576
+ * written by an older CLI keeps running while silently lacking newer gates
577
+ * (the pre-commit `check-generated` step, for example), and the other hook
578
+ * checks only confirm that kibi is invoked at all.
579
+ */
580
+ // implements REQ-cli-doctor
581
+ function checkManagedHookSections() {
582
+ const hooksDir = effectiveHooksDir();
583
+ let outdated;
584
+ try {
585
+ if (!hasManagedHooks(hooksDir)) {
586
+ return { passed: true, message: "Not installed (optional)" };
587
+ }
588
+ outdated = outdatedManagedHooks(hooksDir);
589
+ }
590
+ catch {
591
+ return {
592
+ passed: false,
593
+ message: "Unable to read hook content",
594
+ remediation: "Run: kibi init",
595
+ };
596
+ }
597
+ if (outdated.length > 0) {
598
+ return {
599
+ passed: false,
600
+ message: `Outdated for this Kibi CLI: ${outdated.join(", ")} (installed by a different version; newer gates may be missing)${hooksPathSuffix()}`,
601
+ remediation: "Run: kibi init to refresh the kibi-managed hook sections",
602
+ };
603
+ }
604
+ return { passed: true, message: "Current for this Kibi CLI" };
605
+ }
528
606
  function checkGitHooks() {
529
- const postCheckoutPath = path.join(process.cwd(), ".git/hooks/post-checkout");
530
- const postMergePath = path.join(process.cwd(), ".git/hooks/post-merge");
607
+ const postCheckoutPath = path.join(effectiveHooksDir(), "post-checkout");
608
+ const postMergePath = path.join(effectiveHooksDir(), "post-merge");
609
+ const preCommitPath = path.join(effectiveHooksDir(), "pre-commit");
531
610
  const postCheckoutExists = existsSync(postCheckoutPath);
532
611
  const postMergeExists = existsSync(postMergePath);
533
- if (!postCheckoutExists && !postMergeExists) {
612
+ // An existing pre-commit is hard enforcement; the companions being absent
613
+ // must not downgrade the summary to "optional".
614
+ if (!postCheckoutExists && !postMergeExists && !existsSync(preCommitPath)) {
534
615
  return {
535
616
  passed: true,
536
- message: "Not installed (optional)",
617
+ message: `Not installed (optional)${hooksPathSuffix()}`,
537
618
  };
538
619
  }
539
620
  if (postCheckoutExists && postMergeExists) {
@@ -545,13 +626,13 @@ function checkGitHooks() {
545
626
  if (checkoutExecutable && mergeExecutable) {
546
627
  return {
547
628
  passed: true,
548
- message: "Installed and executable",
629
+ message: `Installed and executable${hooksPathSuffix()}`,
549
630
  };
550
631
  }
551
632
  return {
552
633
  passed: false,
553
- message: "Installed but not executable",
554
- remediation: "Run: chmod +x .git/hooks/post-checkout .git/hooks/post-merge",
634
+ message: `Installed but not executable${hooksPathSuffix()}`,
635
+ remediation: remediationHookPaths("post-checkout", "post-merge"),
555
636
  };
556
637
  }
557
638
  catch (error) {
@@ -563,20 +644,20 @@ function checkGitHooks() {
563
644
  }
564
645
  return {
565
646
  passed: false,
566
- message: "Partially installed",
647
+ message: `Partially installed${hooksPathSuffix()}`,
567
648
  remediation: "Run: kibi init",
568
649
  };
569
650
  }
570
651
  function checkPreCommitHook() {
571
- const postCheckoutPath = path.join(process.cwd(), ".git/hooks/post-checkout");
572
- const postMergePath = path.join(process.cwd(), ".git/hooks/post-merge");
573
- const preCommitPath = path.join(process.cwd(), ".git/hooks/pre-commit");
652
+ const postCheckoutPath = path.join(effectiveHooksDir(), "post-checkout");
653
+ const postMergePath = path.join(effectiveHooksDir(), "post-merge");
654
+ const preCommitPath = path.join(effectiveHooksDir(), "pre-commit");
574
655
  const postCheckoutExists = existsSync(postCheckoutPath);
575
656
  const postMergeExists = existsSync(postMergePath);
576
- if (!postCheckoutExists && !postMergeExists) {
657
+ if (!postCheckoutExists && !postMergeExists && !existsSync(preCommitPath)) {
577
658
  return {
578
659
  passed: true,
579
- message: "Not installed (optional)",
660
+ message: `Not installed (optional)${hooksPathSuffix()}`,
580
661
  };
581
662
  }
582
663
  const preCommitExists = existsSync(preCommitPath);
@@ -620,7 +701,7 @@ function checkPreCommitHook() {
620
701
  }
621
702
  return {
622
703
  passed: true,
623
- message: "Installed and executable (resolves kibi CLI; uses 'kibi check --staged')",
704
+ message: `Installed and executable (resolves kibi CLI; uses 'kibi check --staged')${hooksPathSuffix()}`,
624
705
  };
625
706
  }
626
707
  // Warn but pass if using legacy kibi check without --staged
@@ -632,8 +713,8 @@ function checkPreCommitHook() {
632
713
  }
633
714
  return {
634
715
  passed: false,
635
- message: "Installed but not executable",
636
- remediation: "Run: chmod +x .git/hooks/pre-commit",
716
+ message: `Installed but not executable${hooksPathSuffix()}`,
717
+ remediation: remediationHookPaths("pre-commit"),
637
718
  };
638
719
  }
639
720
  catch (error) {
@@ -645,15 +726,15 @@ function checkPreCommitHook() {
645
726
  }
646
727
  }
647
728
  function checkPostRewriteHook() {
648
- const postCheckoutPath = path.join(process.cwd(), ".git/hooks/post-checkout");
649
- const postMergePath = path.join(process.cwd(), ".git/hooks/post-merge");
650
- const postRewritePath = path.join(process.cwd(), ".git/hooks/post-rewrite");
729
+ const postCheckoutPath = path.join(effectiveHooksDir(), "post-checkout");
730
+ const postMergePath = path.join(effectiveHooksDir(), "post-merge");
731
+ const postRewritePath = path.join(effectiveHooksDir(), "post-rewrite");
651
732
  const postCheckoutExists = existsSync(postCheckoutPath);
652
733
  const postMergeExists = existsSync(postMergePath);
653
- if (!postCheckoutExists && !postMergeExists) {
734
+ if (!postCheckoutExists && !postMergeExists && !existsSync(postRewritePath)) {
654
735
  return {
655
736
  passed: true,
656
- message: "Not installed (optional)",
737
+ message: `Not installed (optional)${hooksPathSuffix()}`,
657
738
  };
658
739
  }
659
740
  const postRewriteExists = existsSync(postRewritePath);
@@ -689,13 +770,13 @@ function checkPostRewriteHook() {
689
770
  }
690
771
  return {
691
772
  passed: true,
692
- message: "Installed and executable",
773
+ message: `Installed and executable${hooksPathSuffix()}`,
693
774
  };
694
775
  }
695
776
  return {
696
777
  passed: false,
697
- message: "Installed but not executable",
698
- remediation: "Run: chmod +x .git/hooks/post-rewrite",
778
+ message: `Installed but not executable${hooksPathSuffix()}`,
779
+ remediation: remediationHookPaths("post-rewrite"),
699
780
  };
700
781
  }
701
782
  catch (error) {
@@ -2,7 +2,7 @@ export declare const GITHUB_REPORT_WORKFLOW_RELPATH = ".github/workflows/kibi-re
2
2
  export declare const GITHUB_BADGE_WORKFLOW_RELPATH = ".github/workflows/kibi-badge.yml";
3
3
  export declare const GITHUB_PAGES_NAMESPACE = "kibi-report";
4
4
  export declare const KIBI_BADGE_ALT = "Kibi requirement health";
5
- export declare const KIBI_METRIC_DOCS_URL = "https://github.com/Looted/kibi/blob/develop/docs/github-integration.md#what-the-badge-means";
5
+ export declare const KIBI_METRIC_DOCS_URL = "https://looted.github.io/kibi/guide/github-integration.html#what-the-badge-means";
6
6
  export declare const PLACEHOLDER_OWNER = "OWNER";
7
7
  export declare const PLACEHOLDER_REPO = "REPOSITORY";
8
8
  export type GitHubRepo = Readonly<{
@@ -1 +1 @@
1
- {"version":3,"file":"github-init.d.ts","sourceRoot":"","sources":["../../src/commands/github-init.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,8BAA8B,sCACN,CAAC;AACtC,eAAO,MAAM,6BAA6B,qCAAqC,CAAC;AAChF,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,cAAc,4BAA4B,CAAC;AACxD,eAAO,MAAM,oBAAoB,gGAC8D,CAAC;AAChG,eAAO,MAAM,iBAAiB,UAAU,CAAC;AACzC,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAM7C,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd,CAAC,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb,CAAC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,CA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B,cAAc,CAC5B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,KAAK,EAAE,MAAM,GACZ,MAAM,CAMR"}
@@ -25,7 +25,7 @@ export const GITHUB_REPORT_WORKFLOW_RELPATH = ".github/workflows/kibi-report.yml
25
25
  export const GITHUB_BADGE_WORKFLOW_RELPATH = ".github/workflows/kibi-badge.yml";
26
26
  export const GITHUB_PAGES_NAMESPACE = "kibi-report";
27
27
  export const KIBI_BADGE_ALT = "Kibi requirement health";
28
- export const KIBI_METRIC_DOCS_URL = "https://github.com/Looted/kibi/blob/develop/docs/github-integration.md#what-the-badge-means";
28
+ export const KIBI_METRIC_DOCS_URL = "https://looted.github.io/kibi/guide/github-integration.html#what-the-badge-means";
29
29
  export const PLACEHOLDER_OWNER = "OWNER";
30
30
  export const PLACEHOLDER_REPO = "REPOSITORY";
31
31
  const README_CANDIDATES = ["README.md", "readme.md", "Readme.md"];
@@ -4,6 +4,21 @@ export declare function createManifestFile(kbDir: string): void;
4
4
  export declare function updateGitIgnore(cwd: string): void;
5
5
  export declare function ensureSymbolsManifestFile(cwd: string): void;
6
6
  export declare function copySchemaFiles(kbDir: string, schemaSourceDir: string): Promise<void>;
7
- export declare function installHook(hookPath: string, content: string): void;
8
- export declare function installGitHooks(gitDir: string): void;
7
+ export type InstallHookResult = "installed" | "updated" | "skipped-foreign" | "skipped-symlink" | "skipped-unsupported";
8
+ export declare function installHook(hookPath: string, content: string): InstallHookResult;
9
+ export interface GitHookInstallResult {
10
+ hook: "pre-commit" | "post-checkout" | "post-merge" | "post-rewrite";
11
+ result: InstallHookResult;
12
+ }
13
+ /**
14
+ * Installed kibi-managed hooks whose managed section differs from what this
15
+ * CLI installs, such as a pre-commit gate written before `check-generated`
16
+ * joined it. User-authored hooks without kibi markers are not reported.
17
+ */
18
+ export declare function outdatedManagedHooks(hooksDir: string): string[];
19
+ /** Whether any hook in the directory carries a kibi-managed section. */
20
+ export declare function hasManagedHooks(hooksDir: string): boolean;
21
+ export declare function installGitHooks(hooksDir: string, options?: {
22
+ hooksPathOrigin?: string | null;
23
+ }): GitHookInstallResult[];
9
24
  //# sourceMappingURL=init-helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/init-helpers.ts"],"names":[],"mappings":"AAuIA,wBAAsB,gBAAgB,CACpC,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,IAAI,CAUN;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA6BjD;AAkDD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAU3D;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE,MAAM,EACb,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAYf;AASD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAkCnE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAiBpD"}
1
+ {"version":3,"file":"init-helpers.d.ts","sourceRoot":"","sources":["../../src/commands/init-helpers.ts"],"names":[],"mappings":"AAyIA,wBAAsB,gBAAgB,CACpC,GAAG,GAAE,MAAsB,GAC1B,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,aAAa,EAAE,MAAM,GACpB,IAAI,CAUN;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtD;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CA6BjD;AAkDD,wBAAgB,yBAAyB,CAAC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