kibi-cli 0.16.1 → 0.18.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 (229) hide show
  1. package/dist/cli-json-command.d.ts.map +1 -1
  2. package/dist/cli-json-command.js +87 -11
  3. package/dist/cli-register-maintenance.d.ts.map +1 -1
  4. package/dist/cli-register-maintenance.js +8 -0
  5. package/dist/cli-register-reporting.d.ts.map +1 -1
  6. package/dist/cli-register-reporting.js +5 -0
  7. package/dist/cli.d.ts.map +1 -1
  8. package/dist/cli.js +2 -1
  9. package/dist/commands/aggregated-checks.d.ts.map +1 -1
  10. package/dist/commands/aggregated-checks.js +1 -0
  11. package/dist/commands/check.d.ts.map +1 -1
  12. package/dist/commands/check.js +1 -1
  13. package/dist/commands/coverage.d.ts +5 -0
  14. package/dist/commands/coverage.d.ts.map +1 -1
  15. package/dist/commands/coverage.js +5 -0
  16. package/dist/commands/discovery-table.d.ts.map +1 -1
  17. package/dist/commands/discovery-table.js +96 -5
  18. package/dist/commands/sync/cache.d.ts +2 -0
  19. package/dist/commands/sync/cache.d.ts.map +1 -1
  20. package/dist/commands/sync/cache.js +8 -0
  21. package/dist/commands/sync/manifest.d.ts +12 -1
  22. package/dist/commands/sync/manifest.d.ts.map +1 -1
  23. package/dist/commands/sync/manifest.js +22 -5
  24. package/dist/commands/sync/persistence.d.ts.map +1 -1
  25. package/dist/commands/sync/persistence.js +76 -2
  26. package/dist/commands/sync.d.ts.map +1 -1
  27. package/dist/commands/sync.js +72 -15
  28. package/dist/commands/usage-metrics.d.ts +66 -2
  29. package/dist/commands/usage-metrics.d.ts.map +1 -1
  30. package/dist/commands/usage-metrics.js +34 -24
  31. package/dist/commands/usage-remediation.d.ts +9 -0
  32. package/dist/commands/usage-remediation.d.ts.map +1 -0
  33. package/dist/commands/usage-remediation.js +52 -0
  34. package/dist/extractors/markdown.d.ts +17 -1
  35. package/dist/extractors/markdown.d.ts.map +1 -1
  36. package/dist/extractors/markdown.js +81 -2
  37. package/dist/logic/ir.d.ts +112 -0
  38. package/dist/logic/ir.d.ts.map +1 -0
  39. package/dist/logic/ir.js +729 -0
  40. package/dist/operations/modeling/logic-modeling.d.ts +22 -0
  41. package/dist/operations/modeling/logic-modeling.d.ts.map +1 -0
  42. package/dist/operations/modeling/logic-modeling.js +120 -0
  43. package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
  44. package/dist/operations/modeling/model-requirement.js +83 -2
  45. package/dist/operations/modeling/predicate-applyplan.d.ts +1 -1
  46. package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
  47. package/dist/operations/modeling/predicate-applyplan.js +29 -4
  48. package/dist/operations/modeling/predicate-inference.d.ts.map +1 -1
  49. package/dist/operations/modeling/predicate-inference.js +3 -0
  50. package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
  51. package/dist/operations/modeling/predicate-loader.js +7 -1
  52. package/dist/operations/modeling/predicate-ranker.d.ts.map +1 -1
  53. package/dist/operations/modeling/predicate-ranker.js +40 -2
  54. package/dist/operations/modeling/predicate-types.d.ts +12 -1
  55. package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
  56. package/dist/operations/modeling/requirement-types.d.ts +12 -0
  57. package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
  58. package/dist/operations/modeling/suggest-predicates.d.ts.map +1 -1
  59. package/dist/operations/modeling/suggest-predicates.js +35 -11
  60. package/dist/operations/mutation/audit.js +1 -1
  61. package/dist/operations/mutation/contradictions.d.ts +1 -1
  62. package/dist/operations/mutation/contradictions.d.ts.map +1 -1
  63. package/dist/operations/mutation/contradictions.js +23 -18
  64. package/dist/operations/mutation/relationships.d.ts.map +1 -1
  65. package/dist/operations/mutation/relationships.js +8 -0
  66. package/dist/operations/mutation/serialization.d.ts.map +1 -1
  67. package/dist/operations/mutation/serialization.js +6 -0
  68. package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
  69. package/dist/operations/mutation/strict-fact.js +68 -3
  70. package/dist/operations/mutation/upsert.d.ts +3 -1
  71. package/dist/operations/mutation/upsert.d.ts.map +1 -1
  72. package/dist/operations/mutation/upsert.js +51 -12
  73. package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
  74. package/dist/operations/mutation/validate-upsert.js +18 -2
  75. package/dist/operations/mutation/validation.d.ts.map +1 -1
  76. package/dist/operations/mutation/validation.js +8 -0
  77. package/dist/operations/semantic-advisor/analysis-receipt.d.ts +2 -2
  78. package/dist/operations/semantic-advisor/analysis-receipt.d.ts.map +1 -1
  79. package/dist/operations/semantic-advisor/analysis-receipt.js +30 -16
  80. package/dist/operations/semantic-advisor/analyze-prose.d.ts +1 -1
  81. package/dist/operations/semantic-advisor/analyze-prose.d.ts.map +1 -1
  82. package/dist/operations/semantic-advisor/analyze-prose.js +464 -27
  83. package/dist/operations/semantic-advisor/clauses.d.ts +1 -0
  84. package/dist/operations/semantic-advisor/clauses.d.ts.map +1 -1
  85. package/dist/operations/semantic-advisor/clauses.js +7 -7
  86. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts +18 -0
  87. package/dist/operations/semantic-advisor/ingestion-boundary.d.ts.map +1 -0
  88. package/dist/operations/semantic-advisor/ingestion-boundary.js +167 -0
  89. package/dist/operations/semantic-advisor/observation-plan.d.ts.map +1 -1
  90. package/dist/operations/semantic-advisor/observation-plan.js +15 -3
  91. package/dist/operations/semantic-advisor/shared.d.ts +9 -0
  92. package/dist/operations/semantic-advisor/shared.d.ts.map +1 -1
  93. package/dist/operations/semantic-advisor/shared.js +38 -4
  94. package/dist/operations/semantic-advisor/types.d.ts +66 -1
  95. package/dist/operations/semantic-advisor/types.d.ts.map +1 -1
  96. package/dist/prolog/codec.d.ts.map +1 -1
  97. package/dist/prolog/codec.js +19 -2
  98. package/dist/prolog.d.ts +6 -0
  99. package/dist/prolog.d.ts.map +1 -1
  100. package/dist/prolog.js +247 -63
  101. package/dist/public/diagnostic-usage.d.ts +17 -0
  102. package/dist/public/diagnostic-usage.d.ts.map +1 -0
  103. package/dist/public/diagnostic-usage.js +152 -0
  104. package/dist/public/distribution-parity.d.ts +90 -0
  105. package/dist/public/distribution-parity.d.ts.map +1 -0
  106. package/dist/public/distribution-parity.js +367 -0
  107. package/dist/public/impact/full-kb-quality.d.ts +2 -0
  108. package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
  109. package/dist/public/impact/full-kb-quality.js +53 -1
  110. package/dist/public/impact-diagnostics.d.ts +2 -0
  111. package/dist/public/impact-diagnostics.d.ts.map +1 -1
  112. package/dist/public/impact-diagnostics.js +1 -0
  113. package/dist/public/operations/catalog.d.ts +235 -11
  114. package/dist/public/operations/catalog.d.ts.map +1 -1
  115. package/dist/public/operations/check-executor.d.ts.map +1 -1
  116. package/dist/public/operations/check-executor.js +4 -0
  117. package/dist/public/operations/discovery-executors.d.ts +6 -0
  118. package/dist/public/operations/discovery-executors.d.ts.map +1 -1
  119. package/dist/public/operations/discovery-executors.js +18 -2
  120. package/dist/public/operations/index.d.ts +5 -0
  121. package/dist/public/operations/index.d.ts.map +1 -1
  122. package/dist/public/operations/index.js +5 -0
  123. package/dist/public/operations/legacy-migration-plan.d.ts +113 -0
  124. package/dist/public/operations/legacy-migration-plan.d.ts.map +1 -0
  125. package/dist/public/operations/legacy-migration-plan.js +409 -0
  126. package/dist/public/operations/node-ports.d.ts.map +1 -1
  127. package/dist/public/operations/node-ports.js +90 -0
  128. package/dist/public/operations/repair-plan.d.ts +184 -0
  129. package/dist/public/operations/repair-plan.d.ts.map +1 -0
  130. package/dist/public/operations/repair-plan.js +397 -0
  131. package/dist/public/operations/runtime-types.d.ts +7 -0
  132. package/dist/public/operations/runtime-types.d.ts.map +1 -1
  133. package/dist/public/operations/specs/check.d.ts +3 -3
  134. package/dist/public/operations/specs/check.d.ts.map +1 -1
  135. package/dist/public/operations/specs/check.js +5 -2
  136. package/dist/public/operations/specs/discovery.d.ts +1 -1
  137. package/dist/public/operations/specs/discovery.js +1 -1
  138. package/dist/public/operations/specs/modeling.d.ts +35 -1
  139. package/dist/public/operations/specs/modeling.d.ts.map +1 -1
  140. package/dist/public/operations/specs/modeling.js +32 -1
  141. package/dist/public/operations/specs/mutation-schemas.d.ts +133 -3
  142. package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
  143. package/dist/public/operations/specs/mutation-schemas.js +67 -1
  144. package/dist/public/operations/specs/reporting.d.ts +42 -1
  145. package/dist/public/operations/specs/reporting.d.ts.map +1 -1
  146. package/dist/public/operations/specs/reporting.js +70 -6
  147. package/dist/public/operations/specs/semantic.d.ts +30 -2
  148. package/dist/public/operations/specs/semantic.d.ts.map +1 -1
  149. package/dist/public/operations/specs/semantic.js +35 -3
  150. package/dist/public/operations/specs/upsert.d.ts +133 -3
  151. package/dist/public/operations/specs/upsert.d.ts.map +1 -1
  152. package/dist/public/operations/workspace-snapshot.d.ts +10 -0
  153. package/dist/public/operations/workspace-snapshot.d.ts.map +1 -0
  154. package/dist/public/operations/workspace-snapshot.js +20 -0
  155. package/dist/public/schemas/entity.d.ts.map +1 -1
  156. package/dist/public/schemas/entity.js +332 -0
  157. package/dist/public/schemas/relationship.d.ts.map +1 -1
  158. package/dist/public/schemas/relationship.js +1 -0
  159. package/dist/public/skills/kibi-traceability/SKILL.md +7 -1
  160. package/dist/public/skills/kibi-usage/SKILL.md +44 -12
  161. package/dist/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
  162. package/dist/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  163. package/dist/public/skills/kibi-usage/resources/operation-access.md +19 -19
  164. package/dist/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  165. package/dist/public/skills/kibi-usage/resources/workflows.md +40 -8
  166. package/dist/public/symbol-granularity.d.ts +9 -0
  167. package/dist/public/symbol-granularity.d.ts.map +1 -1
  168. package/dist/public/symbol-granularity.js +16 -0
  169. package/dist/public/telemetry-acceptance.d.ts +89 -0
  170. package/dist/public/telemetry-acceptance.d.ts.map +1 -0
  171. package/dist/public/telemetry-acceptance.js +597 -0
  172. package/dist/public/telemetry-remediation.d.ts +33 -0
  173. package/dist/public/telemetry-remediation.d.ts.map +1 -0
  174. package/dist/public/telemetry-remediation.js +257 -0
  175. package/dist/public/verification-receipt.d.ts +75 -0
  176. package/dist/public/verification-receipt.d.ts.map +1 -0
  177. package/dist/public/verification-receipt.js +129 -0
  178. package/dist/schemas/entity.schema.json +401 -4
  179. package/dist/traceability/staged-diagnostics.d.ts +1 -1
  180. package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
  181. package/dist/traceability/staged-diagnostics.js +17 -10
  182. package/dist/traceability/staged-impact-contract.js +1 -1
  183. package/dist/traceability/staged-symbols-manifest.d.ts.map +1 -1
  184. package/dist/traceability/staged-symbols-manifest.js +28 -10
  185. package/dist/traceability/temp-kb.d.ts.map +1 -1
  186. package/dist/traceability/temp-kb.js +49 -3
  187. package/dist/types/entities.d.ts +1 -0
  188. package/dist/types/entities.d.ts.map +1 -1
  189. package/dist/types/relationships.d.ts +1 -1
  190. package/dist/types/relationships.d.ts.map +1 -1
  191. package/dist/utils/rule-registry.d.ts +2 -0
  192. package/dist/utils/rule-registry.d.ts.map +1 -1
  193. package/dist/utils/rule-registry.js +18 -0
  194. package/dist/utils/schema-version.d.ts +1 -1
  195. package/dist/utils/schema-version.js +1 -1
  196. package/package.json +34 -2
  197. package/src/public/diagnostic-usage.ts +206 -0
  198. package/src/public/distribution-parity.ts +580 -0
  199. package/src/public/impact/full-kb-quality.ts +74 -1
  200. package/src/public/impact-diagnostics.ts +16 -0
  201. package/src/public/operations/check-executor.ts +4 -0
  202. package/src/public/operations/discovery-executors.ts +24 -2
  203. package/src/public/operations/index.ts +5 -0
  204. package/src/public/operations/legacy-migration-plan.ts +688 -0
  205. package/src/public/operations/node-ports.ts +109 -0
  206. package/src/public/operations/repair-plan.ts +562 -0
  207. package/src/public/operations/runtime-types.ts +8 -0
  208. package/src/public/operations/specs/check.ts +5 -2
  209. package/src/public/operations/specs/discovery.ts +1 -1
  210. package/src/public/operations/specs/modeling.ts +39 -1
  211. package/src/public/operations/specs/mutation-schemas.ts +77 -1
  212. package/src/public/operations/specs/reporting.ts +91 -6
  213. package/src/public/operations/specs/semantic.ts +42 -3
  214. package/src/public/operations/workspace-snapshot.ts +28 -0
  215. package/src/public/schemas/entity.ts +340 -1
  216. package/src/public/schemas/relationship.ts +1 -0
  217. package/src/public/skills/kibi-traceability/SKILL.md +7 -1
  218. package/src/public/skills/kibi-usage/SKILL.md +44 -12
  219. package/src/public/skills/kibi-usage/resources/fact-lanes.md +12 -2
  220. package/src/public/skills/kibi-usage/resources/logic-ir.md +43 -0
  221. package/src/public/skills/kibi-usage/resources/operation-access.md +19 -19
  222. package/src/public/skills/kibi-usage/resources/ui-requirements.md +96 -0
  223. package/src/public/skills/kibi-usage/resources/workflows.md +40 -8
  224. package/src/public/symbol-granularity.ts +25 -0
  225. package/src/public/telemetry-acceptance.ts +859 -0
  226. package/src/public/telemetry-remediation.ts +462 -0
  227. package/src/public/verification-receipt.ts +170 -0
  228. package/src/schemas/entity.schema.json +401 -4
  229. package/src/schemas/relationship.schema.json +1 -0
@@ -0,0 +1,90 @@
1
+ export declare const DISTRIBUTION_PARITY_VERSION: "kibi.distribution-parity.v1";
2
+ export declare const REQUIREMENT_COMPILER_CAPABILITIES: readonly ["semantic_inventory", "contradiction_witnesses", "conservative_proof", "repair_plan", "verification_receipts", "telemetry_acceptance"];
3
+ export type RequirementCompilerCapability = (typeof REQUIREMENT_COMPILER_CAPABILITIES)[number];
4
+ export type DistributionRuntimeKind = "source_checkout" | "packed_artifact" | "project_resolved";
5
+ export type DistributionSurface = "cli" | "mcp";
6
+ export type CapabilityState = "supported" | "unsupported" | "failed";
7
+ export interface DistributionRuntimeProvenance {
8
+ readonly status: "resolved" | "unresolved";
9
+ readonly executable: string;
10
+ readonly entrypoint?: string;
11
+ readonly packageRoot?: string;
12
+ readonly version?: string;
13
+ readonly evidence: "executable_resolution" | "entrypoint_resolution";
14
+ readonly detail?: string;
15
+ }
16
+ export interface DistributionRuntime {
17
+ readonly id: string;
18
+ readonly kind: DistributionRuntimeKind;
19
+ readonly surface: DistributionSurface;
20
+ readonly project?: string;
21
+ readonly provenance: DistributionRuntimeProvenance;
22
+ readonly actions?: Partial<Record<RequirementCompilerCapability, DistributionParityAction>>;
23
+ }
24
+ export interface DistributionParityAction {
25
+ readonly kind: "upgrade" | "compatibility";
26
+ readonly detail: string;
27
+ }
28
+ export interface DistributionCapabilityResult {
29
+ readonly state: CapabilityState;
30
+ readonly outcome?: unknown;
31
+ readonly diagnosticIds?: readonly string[];
32
+ readonly detail?: string;
33
+ }
34
+ export interface DistributionRuntimeAdapter {
35
+ readonly runtime: DistributionRuntime;
36
+ readonly execute: (capability: RequirementCompilerCapability) => Promise<DistributionCapabilityResult>;
37
+ }
38
+ export interface DistributionParityObservation extends DistributionCapabilityResult {
39
+ readonly runtimeId: string;
40
+ readonly capability: RequirementCompilerCapability;
41
+ }
42
+ export type DistributionComparison = "match" | "diverged" | "unsupported" | "failed" | "not_compared";
43
+ export interface DistributionParityRow {
44
+ readonly runtimeId: string;
45
+ readonly kind: DistributionRuntimeKind;
46
+ readonly surface: DistributionSurface;
47
+ readonly project?: string;
48
+ readonly capability: RequirementCompilerCapability;
49
+ readonly state: CapabilityState | "missing";
50
+ readonly comparison: DistributionComparison;
51
+ readonly referenceRuntimeId?: string;
52
+ readonly normalizedOutcome?: unknown;
53
+ readonly diagnosticIds: readonly string[];
54
+ readonly action?: DistributionParityAction;
55
+ readonly detail?: string;
56
+ }
57
+ export type DistributionParityIssueCode = "duplicate_runtime_id" | "missing_current_runtime" | "unresolved_runtime_provenance" | "missing_capability_observation" | "duplicate_capability_observation" | "current_capability_unsupported" | "capability_execution_failed" | "source_packed_mismatch" | "project_divergence_without_action";
58
+ export interface DistributionParityIssue {
59
+ readonly code: DistributionParityIssueCode;
60
+ readonly runtimeId?: string;
61
+ readonly surface?: DistributionSurface;
62
+ readonly capability?: RequirementCompilerCapability;
63
+ readonly detail: string;
64
+ }
65
+ export interface DistributionParityReport {
66
+ readonly version: typeof DISTRIBUTION_PARITY_VERSION;
67
+ readonly status: "passed" | "failed";
68
+ readonly capabilities: readonly RequirementCompilerCapability[];
69
+ readonly runtimes: readonly DistributionRuntime[];
70
+ readonly rows: readonly DistributionParityRow[];
71
+ readonly issues: readonly DistributionParityIssue[];
72
+ readonly summary: {
73
+ readonly runtimeCount: number;
74
+ readonly observationCount: number;
75
+ readonly matchCount: number;
76
+ readonly divergenceCount: number;
77
+ readonly unsupportedCount: number;
78
+ readonly failedCount: number;
79
+ readonly actionCount: number;
80
+ };
81
+ }
82
+ export interface DistributionParityOptions {
83
+ readonly workspaceRoots?: readonly string[];
84
+ readonly volatileKeys?: ReadonlySet<string>;
85
+ }
86
+ export declare function resolveDistributionRuntimeProvenance(executable: string): DistributionRuntimeProvenance;
87
+ export declare function normalizeDistributionParityValue(value: unknown, options?: DistributionParityOptions): unknown;
88
+ export declare function buildDistributionParityReport(runtimes: readonly DistributionRuntime[], observations: readonly DistributionParityObservation[], options?: DistributionParityOptions): DistributionParityReport;
89
+ export declare function runDistributionParityMatrix(adapters: readonly DistributionRuntimeAdapter[], options?: DistributionParityOptions): Promise<DistributionParityReport>;
90
+ //# sourceMappingURL=distribution-parity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"distribution-parity.d.ts","sourceRoot":"","sources":["../../src/public/distribution-parity.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,2BAA2B,EACtC,6BAAsC,CAAC;AAEzC,eAAO,MAAM,iCAAiC,kJAOpC,CAAC;AAEX,MAAM,MAAM,6BAA6B,GACvC,CAAC,OAAO,iCAAiC,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,MAAM,MAAM,uBAAuB,GAC/B,iBAAiB,GACjB,iBAAiB,GACjB,kBAAkB,CAAC;AACvB,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,CAAC;AAChD,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,aAAa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AA6B,CAC3C,QAAQ,EAAE,SAAS,mBAAmB,EAAE,EACxC,YAAY,EAAE,SAAS,6BAA6B,EAAE,EACtD,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAsM1B;AAGD,wBAAsB,2BAA2B,CAC/C,QAAQ,EAAE,SAAS,0BAA0B,EAAE,EAC/C,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,wBAAwB,CAAC,CA0BnC"}
@@ -0,0 +1,367 @@
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 { existsSync, readFileSync, realpathSync } from "node:fs";
11
+ import path from "node:path";
12
+ export const DISTRIBUTION_PARITY_VERSION = "kibi.distribution-parity.v1";
13
+ export const REQUIREMENT_COMPILER_CAPABILITIES = [
14
+ "semantic_inventory",
15
+ "contradiction_witnesses",
16
+ "conservative_proof",
17
+ "repair_plan",
18
+ "verification_receipts",
19
+ "telemetry_acceptance",
20
+ ];
21
+ const DEFAULT_VOLATILE_KEYS = new Set([
22
+ "_diagnostic_telemetry",
23
+ "active_branch",
24
+ "artifact_digest",
25
+ "branch",
26
+ "branchName",
27
+ "code_snapshot",
28
+ "created_at",
29
+ "createdAt",
30
+ "elapsedMs",
31
+ "environment_hash",
32
+ "finished_at",
33
+ "finishedAt",
34
+ "pid",
35
+ "planId",
36
+ "prologPid",
37
+ "receipt_id",
38
+ "request_id",
39
+ "requestId",
40
+ "snapshot_id",
41
+ "snapshotId",
42
+ "started_at",
43
+ "startedAt",
44
+ "timestamp",
45
+ "updated_at",
46
+ "updatedAt",
47
+ "usageLogLineNumber",
48
+ "verificationSnapshot",
49
+ ]);
50
+ function nearestPackageInfo(entrypoint) {
51
+ let current = path.dirname(entrypoint);
52
+ while (true) {
53
+ const manifestPath = path.join(current, "package.json");
54
+ if (existsSync(manifestPath)) {
55
+ try {
56
+ const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
57
+ return {
58
+ packageRoot: current,
59
+ ...(manifest.version === undefined
60
+ ? {}
61
+ : { version: manifest.version }),
62
+ };
63
+ }
64
+ catch {
65
+ return { packageRoot: current };
66
+ }
67
+ }
68
+ const parent = path.dirname(current);
69
+ if (parent === current)
70
+ return {};
71
+ current = parent;
72
+ }
73
+ }
74
+ function declaredEntrypoint(contents) {
75
+ const shimTarget = contents.match(/^# cmd-shim-target=(.+)$/m)?.[1]?.trim();
76
+ if (shimTarget)
77
+ return shimTarget;
78
+ const absoluteImport = contents.match(/\bfrom\s+["'](\/(?:[^"']+))["']/)?.[1];
79
+ return absoluteImport;
80
+ }
81
+ // implements REQ-kibi-distribution-parity-matrix
82
+ export function resolveDistributionRuntimeProvenance(executable) {
83
+ const requested = path.resolve(executable);
84
+ if (!existsSync(requested)) {
85
+ return {
86
+ status: "unresolved",
87
+ executable: requested,
88
+ evidence: "executable_resolution",
89
+ detail: `Executable does not exist: ${requested}`,
90
+ };
91
+ }
92
+ try {
93
+ const resolvedExecutable = realpathSync(requested);
94
+ const contents = readFileSync(resolvedExecutable, "utf8");
95
+ const declared = declaredEntrypoint(contents);
96
+ const entrypoint = declared
97
+ ? realpathSync(path.resolve(path.dirname(resolvedExecutable), declared))
98
+ : resolvedExecutable;
99
+ const packageInfo = nearestPackageInfo(entrypoint);
100
+ return {
101
+ status: "resolved",
102
+ executable: resolvedExecutable,
103
+ entrypoint,
104
+ ...packageInfo,
105
+ evidence: entrypoint === resolvedExecutable
106
+ ? "executable_resolution"
107
+ : "entrypoint_resolution",
108
+ };
109
+ }
110
+ catch (error) {
111
+ return {
112
+ status: "unresolved",
113
+ executable: requested,
114
+ evidence: "executable_resolution",
115
+ detail: error instanceof Error ? error.message : String(error),
116
+ };
117
+ }
118
+ }
119
+ function normalizeString(value, roots) {
120
+ let normalized = value;
121
+ for (const root of [...roots].sort((left, right) => right.length - left.length)) {
122
+ normalized = normalized.replaceAll(root, "<workspace>");
123
+ }
124
+ return normalized
125
+ .replaceAll(/[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gi, "<uuid>")
126
+ .replaceAll(/\b\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z\b/g, "<timestamp>");
127
+ }
128
+ // implements REQ-kibi-distribution-parity-matrix
129
+ export function normalizeDistributionParityValue(value, options = {}) {
130
+ if (typeof value === "string") {
131
+ return normalizeString(value, options.workspaceRoots ?? []);
132
+ }
133
+ if (Array.isArray(value)) {
134
+ return value.map((entry) => normalizeDistributionParityValue(entry, options));
135
+ }
136
+ if (value === null || typeof value !== "object") {
137
+ return value;
138
+ }
139
+ const volatileKeys = options.volatileKeys ?? DEFAULT_VOLATILE_KEYS;
140
+ const normalized = {};
141
+ for (const key of Object.keys(value).sort()) {
142
+ if (volatileKeys.has(key))
143
+ continue;
144
+ normalized[key] = normalizeDistributionParityValue(value[key], options);
145
+ }
146
+ return normalized;
147
+ }
148
+ function semanticFingerprint(value) {
149
+ return JSON.stringify(value);
150
+ }
151
+ function sortedUnique(values) {
152
+ return [...new Set(values ?? [])].sort((left, right) => left.localeCompare(right));
153
+ }
154
+ function currentRuntime(runtimes, kind, surface) {
155
+ return runtimes.find((runtime) => runtime.kind === kind && runtime.surface === surface);
156
+ }
157
+ function observationKey(runtimeId, capability) {
158
+ return `${runtimeId}\0${capability}`;
159
+ }
160
+ function compareObservation(observation, reference, normalized, normalizedReference) {
161
+ if (observation.state === "failed")
162
+ return "failed";
163
+ if (observation.state === "unsupported")
164
+ return "unsupported";
165
+ if (!reference || reference.state !== "supported")
166
+ return "not_compared";
167
+ return semanticFingerprint(normalized) ===
168
+ semanticFingerprint(normalizedReference)
169
+ ? "match"
170
+ : "diverged";
171
+ }
172
+ // implements REQ-kibi-distribution-parity-matrix
173
+ export function buildDistributionParityReport(runtimes, observations, options = {}) {
174
+ const issues = [];
175
+ const runtimeIds = new Set();
176
+ for (const runtime of runtimes) {
177
+ if (runtimeIds.has(runtime.id)) {
178
+ issues.push({
179
+ code: "duplicate_runtime_id",
180
+ runtimeId: runtime.id,
181
+ surface: runtime.surface,
182
+ detail: `Runtime id ${runtime.id} is declared more than once.`,
183
+ });
184
+ }
185
+ runtimeIds.add(runtime.id);
186
+ if (runtime.provenance.status === "unresolved") {
187
+ issues.push({
188
+ code: "unresolved_runtime_provenance",
189
+ runtimeId: runtime.id,
190
+ surface: runtime.surface,
191
+ detail: runtime.provenance.detail ??
192
+ `Runtime ${runtime.id} has no executable resolution evidence.`,
193
+ });
194
+ }
195
+ }
196
+ for (const surface of ["cli", "mcp"]) {
197
+ for (const kind of ["source_checkout", "packed_artifact"]) {
198
+ if (!currentRuntime(runtimes, kind, surface)) {
199
+ issues.push({
200
+ code: "missing_current_runtime",
201
+ surface,
202
+ detail: `Missing ${kind} runtime for ${surface}.`,
203
+ });
204
+ }
205
+ }
206
+ }
207
+ const indexed = new Map();
208
+ for (const observation of observations) {
209
+ const key = observationKey(observation.runtimeId, observation.capability);
210
+ if (indexed.has(key)) {
211
+ issues.push({
212
+ code: "duplicate_capability_observation",
213
+ runtimeId: observation.runtimeId,
214
+ capability: observation.capability,
215
+ detail: `Capability ${observation.capability} was observed more than once for ${observation.runtimeId}.`,
216
+ });
217
+ continue;
218
+ }
219
+ indexed.set(key, observation);
220
+ }
221
+ const rows = [];
222
+ for (const runtime of [...runtimes].sort((left, right) => left.id.localeCompare(right.id))) {
223
+ const source = currentRuntime(runtimes, "source_checkout", runtime.surface);
224
+ for (const capability of REQUIREMENT_COMPILER_CAPABILITIES) {
225
+ const observation = indexed.get(observationKey(runtime.id, capability));
226
+ const reference = source
227
+ ? indexed.get(observationKey(source.id, capability))
228
+ : undefined;
229
+ const action = runtime.actions?.[capability];
230
+ if (!observation) {
231
+ issues.push({
232
+ code: "missing_capability_observation",
233
+ runtimeId: runtime.id,
234
+ surface: runtime.surface,
235
+ capability,
236
+ detail: `Runtime ${runtime.id} has no ${capability} observation.`,
237
+ });
238
+ rows.push({
239
+ runtimeId: runtime.id,
240
+ kind: runtime.kind,
241
+ surface: runtime.surface,
242
+ ...(runtime.project === undefined
243
+ ? {}
244
+ : { project: runtime.project }),
245
+ capability,
246
+ state: "missing",
247
+ comparison: "not_compared",
248
+ ...(source === undefined ? {} : { referenceRuntimeId: source.id }),
249
+ diagnosticIds: [],
250
+ ...(action === undefined ? {} : { action }),
251
+ });
252
+ continue;
253
+ }
254
+ const normalized = normalizeDistributionParityValue(observation.outcome, options);
255
+ const normalizedReference = normalizeDistributionParityValue(reference?.outcome, options);
256
+ const comparison = runtime.kind === "source_checkout"
257
+ ? observation.state === "supported"
258
+ ? "match"
259
+ : observation.state
260
+ : compareObservation(observation, reference, normalized, normalizedReference);
261
+ if (runtime.kind !== "project_resolved" &&
262
+ observation.state === "unsupported") {
263
+ issues.push({
264
+ code: "current_capability_unsupported",
265
+ runtimeId: runtime.id,
266
+ surface: runtime.surface,
267
+ capability,
268
+ detail: `Current ${runtime.kind} runtime does not support ${capability}.`,
269
+ });
270
+ }
271
+ if (observation.state === "failed") {
272
+ issues.push({
273
+ code: "capability_execution_failed",
274
+ runtimeId: runtime.id,
275
+ surface: runtime.surface,
276
+ capability,
277
+ detail: observation.detail ??
278
+ `Runtime ${runtime.id} failed while executing ${capability}.`,
279
+ });
280
+ }
281
+ if (runtime.kind === "packed_artifact" && comparison === "diverged") {
282
+ issues.push({
283
+ code: "source_packed_mismatch",
284
+ runtimeId: runtime.id,
285
+ surface: runtime.surface,
286
+ capability,
287
+ detail: `Packed ${runtime.surface} outcome diverges from source for ${capability}.`,
288
+ });
289
+ }
290
+ if (runtime.kind === "project_resolved" &&
291
+ (comparison === "diverged" || comparison === "unsupported") &&
292
+ !action) {
293
+ issues.push({
294
+ code: "project_divergence_without_action",
295
+ runtimeId: runtime.id,
296
+ surface: runtime.surface,
297
+ capability,
298
+ detail: `Project runtime ${runtime.id} needs an upgrade or compatibility action for ${capability}.`,
299
+ });
300
+ }
301
+ rows.push({
302
+ runtimeId: runtime.id,
303
+ kind: runtime.kind,
304
+ surface: runtime.surface,
305
+ ...(runtime.project === undefined ? {} : { project: runtime.project }),
306
+ capability,
307
+ state: observation.state,
308
+ comparison,
309
+ ...(runtime.kind === "source_checkout" || source === undefined
310
+ ? {}
311
+ : { referenceRuntimeId: source.id }),
312
+ ...(observation.state === "supported"
313
+ ? { normalizedOutcome: normalized }
314
+ : {}),
315
+ diagnosticIds: sortedUnique(observation.diagnosticIds),
316
+ ...(action === undefined ? {} : { action }),
317
+ ...(observation.detail === undefined
318
+ ? {}
319
+ : { detail: observation.detail }),
320
+ });
321
+ }
322
+ }
323
+ return {
324
+ version: DISTRIBUTION_PARITY_VERSION,
325
+ status: issues.length === 0 ? "passed" : "failed",
326
+ capabilities: REQUIREMENT_COMPILER_CAPABILITIES,
327
+ runtimes: [...runtimes].sort((left, right) => left.id.localeCompare(right.id)),
328
+ rows,
329
+ issues,
330
+ summary: {
331
+ runtimeCount: runtimes.length,
332
+ observationCount: observations.length,
333
+ matchCount: rows.filter((row) => row.comparison === "match").length,
334
+ divergenceCount: rows.filter((row) => row.comparison === "diverged")
335
+ .length,
336
+ unsupportedCount: rows.filter((row) => row.state === "unsupported")
337
+ .length,
338
+ failedCount: rows.filter((row) => row.state === "failed").length,
339
+ actionCount: rows.filter((row) => row.action !== undefined).length,
340
+ },
341
+ };
342
+ }
343
+ // implements REQ-kibi-distribution-parity-matrix
344
+ export async function runDistributionParityMatrix(adapters, options = {}) {
345
+ const observations = [];
346
+ for (const adapter of adapters) {
347
+ for (const capability of REQUIREMENT_COMPILER_CAPABILITIES) {
348
+ try {
349
+ const result = await adapter.execute(capability);
350
+ observations.push({
351
+ runtimeId: adapter.runtime.id,
352
+ capability,
353
+ ...result,
354
+ });
355
+ }
356
+ catch (error) {
357
+ observations.push({
358
+ runtimeId: adapter.runtime.id,
359
+ capability,
360
+ state: "failed",
361
+ detail: error instanceof Error ? error.message : String(error),
362
+ });
363
+ }
364
+ }
365
+ }
366
+ return buildDistributionParityReport(adapters.map((adapter) => adapter.runtime), observations, options);
367
+ }
@@ -4,6 +4,8 @@ type FullKbQualityDiagnosticsOptions = {
4
4
  readonly prolog: Pick<PrologProcess, "query">;
5
5
  readonly hardViolationEntityIds?: ReadonlySet<string>;
6
6
  readonly maxDiagnostics?: number;
7
+ readonly workspaceRoot?: string;
8
+ readonly now?: Date;
7
9
  };
8
10
  export declare function collectFullKbQualityDiagnostics(options: FullKbQualityDiagnosticsOptions): Promise<readonly QualityDiagnostic[]>;
9
11
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AASrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqBpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,CAAC;AA0KF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAmBvC"}
1
+ {"version":3,"file":"full-kb-quality.d.ts","sourceRoot":"","sources":["../../../src/public/impact/full-kb-quality.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAcrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAqBpD,KAAK,+BAA+B,GAAG;IACrC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC9C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtD,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;CACrB,CAAC;AAmOF,wBAAsB,+BAA+B,CACnD,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CA0BvC"}
@@ -1,4 +1,7 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
1
3
  import { parseEntityFromList, parseListOfLists, parseTriples, } from "../../prolog/codec.js";
4
+ import { analyzeTelemetryAcceptance, createTelemetryAcceptanceDiagnostics, parseTelemetryUsageLog, } from "../telemetry-acceptance.js";
2
5
  import { createCoverageDepthQualityDiagnostics } from "./coverage-depth-quality.js";
3
6
  import { createRequirementQualityDiagnostics } from "./requirement-quality.js";
4
7
  import { createSymbolQualityDiagnostics } from "./symbol-quality.js";
@@ -63,6 +66,9 @@ function toExtractedEntity(entity) {
63
66
  const textRef = optionalStringField(entity, "text_ref");
64
67
  if (textRef !== undefined)
65
68
  extracted.text_ref = textRef;
69
+ const semanticText = optionalStringField(entity, "semantic_text");
70
+ if (semanticText !== undefined)
71
+ extracted.semantic_text = semanticText;
66
72
  const logicClaims = optionalStringArrayField(entity, "logic_claims");
67
73
  if (logicClaims !== undefined)
68
74
  extracted.logic_claims = logicClaims;
@@ -171,10 +177,56 @@ function capDiagnostics(diagnostics, maxDiagnostics) {
171
177
  ? diagnostics.slice(0, maxDiagnostics)
172
178
  : diagnostics;
173
179
  }
180
+ function telemetryReadDiagnostic(message) {
181
+ return {
182
+ id: "telemetry_evidence_unreadable",
183
+ severity: "review",
184
+ blocking: false,
185
+ category: "telemetry",
186
+ source: ".kb/usage.log",
187
+ message,
188
+ suggestion: "Repair or regenerate .kb/usage.log through Kibi diagnostic mode, then rerun kibi usage-metrics --require-acceptance and an unfiltered kb_check.",
189
+ };
190
+ }
191
+ async function collectTelemetryDiagnostics(workspaceRoot, now) {
192
+ if (workspaceRoot === undefined)
193
+ return [];
194
+ const usageLogPath = path.join(workspaceRoot, ".kb", "usage.log");
195
+ let contents;
196
+ try {
197
+ contents = await readFile(usageLogPath, "utf8");
198
+ }
199
+ catch (error) {
200
+ if (typeof error === "object" &&
201
+ error !== null &&
202
+ "code" in error &&
203
+ error.code === "ENOENT") {
204
+ return [];
205
+ }
206
+ const message = error instanceof Error ? error.message : String(error);
207
+ return [
208
+ telemetryReadDiagnostic(`Telemetry acceptance evidence is unreadable: ${message}`),
209
+ ];
210
+ }
211
+ try {
212
+ const report = analyzeTelemetryAcceptance(parseTelemetryUsageLog(contents), now);
213
+ return createTelemetryAcceptanceDiagnostics(report);
214
+ }
215
+ catch (error) {
216
+ const message = error instanceof Error ? error.message : String(error);
217
+ return [
218
+ telemetryReadDiagnostic(`Telemetry acceptance evidence is malformed: ${message}`),
219
+ ];
220
+ }
221
+ }
174
222
  export async function collectFullKbQualityDiagnostics(options) {
175
- const manifestResults = await loadKbExtractionResults(options.prolog);
223
+ const [manifestResults, telemetryDiagnostics] = await Promise.all([
224
+ loadKbExtractionResults(options.prolog),
225
+ collectTelemetryDiagnostics(options.workspaceRoot, options.now ?? new Date()),
226
+ ]);
176
227
  const coverageDepthDiagnostics = createCoverageDepthQualityDiagnostics(manifestResults);
177
228
  const diagnostics = [
229
+ ...telemetryDiagnostics,
178
230
  ...createRequirementQualityDiagnostics({
179
231
  manifestResults,
180
232
  ...(options.hardViolationEntityIds !== undefined
@@ -3,5 +3,7 @@ export { collectFullKbQualityDiagnostics } from "./impact/full-kb-quality.js";
3
3
  export { createSemanticReviewDiagnostics, createSymbolGranularityDiagnostics, hasBlockingImpactDiagnostics, hasBlockingQualityDiagnostics, } from "./impact/diagnostics.js";
4
4
  export { createRequirementQualityDiagnostics } from "./impact/requirement-quality.js";
5
5
  export { createSymbolQualityDiagnostics } from "./impact/symbol-quality.js";
6
+ export { DEFAULT_TELEMETRY_ACCEPTANCE_POLICY, TELEMETRY_ACCEPTANCE_VERSION, analyzeTelemetryAcceptance, createTelemetryAcceptanceDiagnostics, parseTelemetryUsageLog, } from "./telemetry-acceptance.js";
6
7
  export type { ChangedFileImpactOptions, ChangedFileImpactResult, ImpactExtractedSymbol, ImpactLinkedEntity, QualityDiagnostic, QualityDiagnosticSeverity, RequirementQualityDiagnosticsOptions, SemanticReviewDiagnosticsOptions, SymbolGranularityDiagnosticsOptions, SymbolQualityDiagnosticsOptions, } from "./impact/types.js";
8
+ export type { TelemetryAcceptanceMetric, TelemetryAcceptancePolicy, TelemetryAcceptanceReport, TelemetryAcceptanceStatus, TelemetryMetricId, TelemetryMetricStatus, TelemetryUsageEvent, } from "./telemetry-acceptance.js";
7
9
  //# sourceMappingURL=impact-diagnostics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"impact-diagnostics.d.ts","sourceRoot":"","sources":["../../src/public/impact-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,gCAAgC,EAChC,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"impact-diagnostics.d.ts","sourceRoot":"","sources":["../../src/public/impact-diagnostics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,+BAA+B,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EACL,+BAA+B,EAC/B,kCAAkC,EAClC,4BAA4B,EAC5B,6BAA6B,GAC9B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EACL,mCAAmC,EACnC,4BAA4B,EAC5B,0BAA0B,EAC1B,oCAAoC,EACpC,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACV,wBAAwB,EACxB,uBAAuB,EACvB,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,yBAAyB,EACzB,oCAAoC,EACpC,gCAAgC,EAChC,mCAAmC,EACnC,+BAA+B,GAChC,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC"}
@@ -3,3 +3,4 @@ export { collectFullKbQualityDiagnostics } from "./impact/full-kb-quality.js";
3
3
  export { createSemanticReviewDiagnostics, createSymbolGranularityDiagnostics, hasBlockingImpactDiagnostics, hasBlockingQualityDiagnostics, } from "./impact/diagnostics.js";
4
4
  export { createRequirementQualityDiagnostics } from "./impact/requirement-quality.js";
5
5
  export { createSymbolQualityDiagnostics } from "./impact/symbol-quality.js";
6
+ export { DEFAULT_TELEMETRY_ACCEPTANCE_POLICY, TELEMETRY_ACCEPTANCE_VERSION, analyzeTelemetryAcceptance, createTelemetryAcceptanceDiagnostics, parseTelemetryUsageLog, } from "./telemetry-acceptance.js";