@unbrained/pm-cli 2026.5.18 → 2026.5.24

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 (225) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +2 -1
  3. package/dist/cli/commander-usage.js +16 -2
  4. package/dist/cli/commander-usage.js.map +1 -1
  5. package/dist/cli/commands/annotation-command.d.ts +49 -0
  6. package/dist/cli/commands/annotation-command.js +135 -0
  7. package/dist/cli/commands/annotation-command.js.map +1 -0
  8. package/dist/cli/commands/append.js +3 -7
  9. package/dist/cli/commands/append.js.map +1 -1
  10. package/dist/cli/commands/calendar.js +3 -6
  11. package/dist/cli/commands/calendar.js.map +1 -1
  12. package/dist/cli/commands/claim.js +12 -22
  13. package/dist/cli/commands/claim.js.map +1 -1
  14. package/dist/cli/commands/close.js +61 -9
  15. package/dist/cli/commands/close.js.map +1 -1
  16. package/dist/cli/commands/comments.d.ts +5 -0
  17. package/dist/cli/commands/comments.js +27 -117
  18. package/dist/cli/commands/comments.js.map +1 -1
  19. package/dist/cli/commands/completion.js +102 -15
  20. package/dist/cli/commands/completion.js.map +1 -1
  21. package/dist/cli/commands/context.js +4 -10
  22. package/dist/cli/commands/context.js.map +1 -1
  23. package/dist/cli/commands/contracts.js +168 -36
  24. package/dist/cli/commands/contracts.js.map +1 -1
  25. package/dist/cli/commands/create.js +49 -44
  26. package/dist/cli/commands/create.js.map +1 -1
  27. package/dist/cli/commands/dedupe-audit.js +7 -4
  28. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  29. package/dist/cli/commands/delete.d.ts +3 -0
  30. package/dist/cli/commands/delete.js +9 -8
  31. package/dist/cli/commands/delete.js.map +1 -1
  32. package/dist/cli/commands/docs.d.ts +1 -0
  33. package/dist/cli/commands/docs.js +4 -8
  34. package/dist/cli/commands/docs.js.map +1 -1
  35. package/dist/cli/commands/event-validation-messages.d.ts +3 -0
  36. package/dist/cli/commands/event-validation-messages.js +44 -0
  37. package/dist/cli/commands/event-validation-messages.js.map +1 -0
  38. package/dist/cli/commands/extension.d.ts +1 -0
  39. package/dist/cli/commands/extension.js +138 -21
  40. package/dist/cli/commands/extension.js.map +1 -1
  41. package/dist/cli/commands/files.js +6 -13
  42. package/dist/cli/commands/files.js.map +1 -1
  43. package/dist/cli/commands/gc.js +17 -4
  44. package/dist/cli/commands/gc.js.map +1 -1
  45. package/dist/cli/commands/get.d.ts +3 -2
  46. package/dist/cli/commands/get.js +50 -8
  47. package/dist/cli/commands/get.js.map +1 -1
  48. package/dist/cli/commands/health.d.ts +10 -0
  49. package/dist/cli/commands/health.js +254 -75
  50. package/dist/cli/commands/health.js.map +1 -1
  51. package/dist/cli/commands/history-redact.d.ts +8 -0
  52. package/dist/cli/commands/history-redact.js +14 -97
  53. package/dist/cli/commands/history-redact.js.map +1 -1
  54. package/dist/cli/commands/history-repair.d.ts +33 -0
  55. package/dist/cli/commands/history-repair.js +166 -0
  56. package/dist/cli/commands/history-repair.js.map +1 -0
  57. package/dist/cli/commands/history.d.ts +4 -4
  58. package/dist/cli/commands/history.js +10 -88
  59. package/dist/cli/commands/history.js.map +1 -1
  60. package/dist/cli/commands/index.d.ts +3 -1
  61. package/dist/cli/commands/index.js +5 -3
  62. package/dist/cli/commands/index.js.map +1 -1
  63. package/dist/cli/commands/init.d.ts +28 -0
  64. package/dist/cli/commands/init.js +23 -2
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/cli/commands/learnings.js +20 -119
  67. package/dist/cli/commands/learnings.js.map +1 -1
  68. package/dist/cli/commands/linked-test-entry.d.ts +3 -0
  69. package/dist/cli/commands/linked-test-entry.js +62 -0
  70. package/dist/cli/commands/linked-test-entry.js.map +1 -0
  71. package/dist/cli/commands/list.js +32 -22
  72. package/dist/cli/commands/list.js.map +1 -1
  73. package/dist/cli/commands/notes.js +20 -119
  74. package/dist/cli/commands/notes.js.map +1 -1
  75. package/dist/cli/commands/plan.d.ts +3 -0
  76. package/dist/cli/commands/plan.js +184 -22
  77. package/dist/cli/commands/plan.js.map +1 -1
  78. package/dist/cli/commands/restore.js +7 -50
  79. package/dist/cli/commands/restore.js.map +1 -1
  80. package/dist/cli/commands/schema.d.ts +31 -0
  81. package/dist/cli/commands/schema.js +98 -0
  82. package/dist/cli/commands/schema.js.map +1 -0
  83. package/dist/cli/commands/search.js +151 -40
  84. package/dist/cli/commands/search.js.map +1 -1
  85. package/dist/cli/commands/templates.d.ts +4 -0
  86. package/dist/cli/commands/templates.js +89 -17
  87. package/dist/cli/commands/templates.js.map +1 -1
  88. package/dist/cli/commands/test-all.js +4 -8
  89. package/dist/cli/commands/test-all.js.map +1 -1
  90. package/dist/cli/commands/test.d.ts +1 -0
  91. package/dist/cli/commands/test.js +7 -10
  92. package/dist/cli/commands/test.js.map +1 -1
  93. package/dist/cli/commands/update-many.js +4 -8
  94. package/dist/cli/commands/update-many.js.map +1 -1
  95. package/dist/cli/commands/update.js +109 -51
  96. package/dist/cli/commands/update.js.map +1 -1
  97. package/dist/cli/commands/validate.d.ts +3 -1
  98. package/dist/cli/commands/validate.js +23 -71
  99. package/dist/cli/commands/validate.js.map +1 -1
  100. package/dist/cli/error-guidance.js +96 -6
  101. package/dist/cli/error-guidance.js.map +1 -1
  102. package/dist/cli/extension-command-help.d.ts +0 -1
  103. package/dist/cli/extension-command-help.js +2 -13
  104. package/dist/cli/extension-command-help.js.map +1 -1
  105. package/dist/cli/extension-command-options.d.ts +1 -0
  106. package/dist/cli/extension-command-options.js +106 -7
  107. package/dist/cli/extension-command-options.js.map +1 -1
  108. package/dist/cli/help-content.d.ts +0 -1
  109. package/dist/cli/help-content.js +13 -9
  110. package/dist/cli/help-content.js.map +1 -1
  111. package/dist/cli/help-json-payload.d.ts +1 -0
  112. package/dist/cli/help-json-payload.js +33 -3
  113. package/dist/cli/help-json-payload.js.map +1 -1
  114. package/dist/cli/main.js +35 -29
  115. package/dist/cli/main.js.map +1 -1
  116. package/dist/cli/register-list-query.d.ts +1 -1
  117. package/dist/cli/register-list-query.js +40 -17
  118. package/dist/cli/register-list-query.js.map +1 -1
  119. package/dist/cli/register-mutation.d.ts +1 -1
  120. package/dist/cli/register-mutation.js +232 -64
  121. package/dist/cli/register-mutation.js.map +1 -1
  122. package/dist/cli/register-operations.js +16 -11
  123. package/dist/cli/register-operations.js.map +1 -1
  124. package/dist/cli/register-setup.js +26 -14
  125. package/dist/cli/register-setup.js.map +1 -1
  126. package/dist/cli/registration-helpers.d.ts +0 -2
  127. package/dist/cli/registration-helpers.js +13 -40
  128. package/dist/cli/registration-helpers.js.map +1 -1
  129. package/dist/cli.js +23 -3
  130. package/dist/cli.js.map +1 -1
  131. package/dist/core/extensions/index.d.ts +0 -1
  132. package/dist/core/extensions/index.js +2 -14
  133. package/dist/core/extensions/index.js.map +1 -1
  134. package/dist/core/extensions/loader.js +3 -9
  135. package/dist/core/extensions/loader.js.map +1 -1
  136. package/dist/core/fs/path-utils.d.ts +1 -0
  137. package/dist/core/fs/path-utils.js +12 -0
  138. package/dist/core/fs/path-utils.js.map +1 -0
  139. package/dist/core/history/drift-scan.d.ts +11 -0
  140. package/dist/core/history/drift-scan.js +67 -0
  141. package/dist/core/history/drift-scan.js.map +1 -0
  142. package/dist/core/history/replay.d.ts +82 -0
  143. package/dist/core/history/replay.js +249 -0
  144. package/dist/core/history/replay.js.map +1 -0
  145. package/dist/core/item/item-format.js +11 -8
  146. package/dist/core/item/item-format.js.map +1 -1
  147. package/dist/core/item/item-type-definition.d.ts +52 -0
  148. package/dist/core/item/item-type-definition.js +123 -0
  149. package/dist/core/item/item-type-definition.js.map +1 -0
  150. package/dist/core/item/parse.js +3 -2
  151. package/dist/core/item/parse.js.map +1 -1
  152. package/dist/core/item/priority.d.ts +23 -0
  153. package/dist/core/item/priority.js +55 -0
  154. package/dist/core/item/priority.js.map +1 -0
  155. package/dist/core/item/status.d.ts +14 -1
  156. package/dist/core/item/status.js +22 -2
  157. package/dist/core/item/status.js.map +1 -1
  158. package/dist/core/item/toon-decode.d.ts +19 -0
  159. package/dist/core/item/toon-decode.js +69 -0
  160. package/dist/core/item/toon-decode.js.map +1 -0
  161. package/dist/core/item/type-registry.js +13 -84
  162. package/dist/core/item/type-registry.js.map +1 -1
  163. package/dist/core/packages/manifest.js +3 -9
  164. package/dist/core/packages/manifest.js.map +1 -1
  165. package/dist/core/schema/item-types-file.d.ts +85 -0
  166. package/dist/core/schema/item-types-file.js +243 -0
  167. package/dist/core/schema/item-types-file.js.map +1 -0
  168. package/dist/core/schema/runtime-schema.d.ts +2 -1
  169. package/dist/core/schema/runtime-schema.js +11 -9
  170. package/dist/core/schema/runtime-schema.js.map +1 -1
  171. package/dist/core/search/semantic-defaults.js +3 -3
  172. package/dist/core/search/semantic-defaults.js.map +1 -1
  173. package/dist/core/shared/author.d.ts +1 -0
  174. package/dist/core/shared/author.js +9 -0
  175. package/dist/core/shared/author.js.map +1 -0
  176. package/dist/core/shared/lazy-module.d.ts +1 -0
  177. package/dist/core/shared/lazy-module.js +11 -0
  178. package/dist/core/shared/lazy-module.js.map +1 -0
  179. package/dist/core/shared/option-alias-visibility.d.ts +44 -0
  180. package/dist/core/shared/option-alias-visibility.js +76 -0
  181. package/dist/core/shared/option-alias-visibility.js.map +1 -0
  182. package/dist/core/shared/text-normalization.d.ts +0 -1
  183. package/dist/core/shared/text-normalization.js +2 -5
  184. package/dist/core/shared/text-normalization.js.map +1 -1
  185. package/dist/core/store/item-store.d.ts +2 -0
  186. package/dist/core/store/item-store.js +70 -39
  187. package/dist/core/store/item-store.js.map +1 -1
  188. package/dist/core/store/settings-validator.d.ts +106 -0
  189. package/dist/core/store/settings-validator.js +279 -0
  190. package/dist/core/store/settings-validator.js.map +1 -0
  191. package/dist/core/store/settings.js +6 -343
  192. package/dist/core/store/settings.js.map +1 -1
  193. package/dist/core/telemetry/runtime.js +5 -3
  194. package/dist/core/telemetry/runtime.js.map +1 -1
  195. package/dist/mcp/server.js +64 -13
  196. package/dist/mcp/server.js.map +1 -1
  197. package/dist/sdk/cli-contracts.d.ts +9 -2
  198. package/dist/sdk/cli-contracts.js +204 -13
  199. package/dist/sdk/cli-contracts.js.map +1 -1
  200. package/dist/sdk/runtime.d.ts +25 -1
  201. package/dist/sdk/runtime.js +46 -3
  202. package/dist/sdk/runtime.js.map +1 -1
  203. package/dist/types.d.ts +6 -0
  204. package/dist/types.js +10 -2
  205. package/dist/types.js.map +1 -1
  206. package/docs/AGENT_GUIDE.md +7 -1
  207. package/docs/ARCHITECTURE.md +1 -1
  208. package/docs/COMMANDS.md +39 -6
  209. package/docs/CONFIGURATION.md +1 -1
  210. package/docs/RELEASING.md +11 -7
  211. package/docs/SDK.md +11 -2
  212. package/package.json +12 -11
  213. package/packages/pm-calendar/README.md +3 -1
  214. package/packages/pm-calendar/extensions/calendar/index.js +21 -2
  215. package/packages/pm-calendar/extensions/calendar/index.ts +21 -2
  216. package/packages/pm-search-advanced/README.md +8 -0
  217. package/packages/pm-search-advanced/extensions/search-advanced/index.js +74 -0
  218. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +74 -0
  219. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +67 -9
  220. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +67 -9
  221. package/packages/pm-templates/extensions/templates/runtime.js +11 -202
  222. package/packages/pm-templates/extensions/templates/runtime.ts +38 -230
  223. package/dist/core/output/command-aware.d.ts +0 -1
  224. package/dist/core/output/command-aware.js +0 -397
  225. package/dist/core/output/command-aware.js.map +0 -1
@@ -1,13 +1,13 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="877f600b-5e09-5d62-bf4e-7bf9f9e38289")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="c5b24e35-02f9-5f45-9ef2-e5c850396686")}catch(e){}}();
3
3
  import fs from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
6
6
  import { pathExists, readFileIfExists } from "../../core/fs/fs-utils.js";
7
7
  import { activateExtensions, getActiveExtensionRegistrations, loadExtensions, runActiveOnReadHooks } from "../../core/extensions/index.js";
8
8
  import { EXTENSION_CAPABILITY_CONTRACT, KNOWN_EXTENSION_CAPABILITIES, parseLegacyExtensionCapabilityAliasWarning, parseUnknownExtensionCapabilityWarning, } from "../../core/extensions/loader.js";
9
- import { hashDocument } from "../../core/history/history.js";
10
9
  import { enforceHistoryStreamPolicyForItems } from "../../core/history/history-stream-policy.js";
10
+ import { scanHistoryDrift } from "../../core/history/drift-scan.js";
11
11
  import { readVectorizationStatusLedger, refreshSemanticEmbeddingsForMutatedItems, } from "../../core/search/cache.js";
12
12
  import { resolveEmbeddingProviders } from "../../core/search/providers.js";
13
13
  import { resolveSettingsWithSemanticRuntimeDefaults } from "../../core/search/semantic-defaults.js";
@@ -18,12 +18,12 @@ import { PmCliError } from "../../core/shared/errors.js";
18
18
  import { toNonEmptyStringOrUndefined } from "../../core/shared/primitives.js";
19
19
  import { nowIso } from "../../core/shared/time.js";
20
20
  import { parseItemDocument } from "../../core/item/item-format.js";
21
- import { listAllFrontMatterWithBody } from "../../core/store/item-store.js";
22
- import { getHistoryPath, getItemFormatFromPath, getSettingsPath, ITEM_FILE_EXTENSIONS, resolveGlobalPmRoot, resolvePmRoot, } from "../../core/store/paths.js";
21
+ import { listAllFrontMatter, listAllFrontMatterWithBody } from "../../core/store/item-store.js";
22
+ import { getItemFormatFromPath, getSettingsPath, ITEM_FILE_EXTENSIONS, resolveGlobalPmRoot, resolvePmRoot, } from "../../core/store/paths.js";
23
23
  import { readSettingsWithMetadata } from "../../core/store/settings.js";
24
24
  import { readManagedExtensionState } from "./extension.js";
25
- import { verifyHistoryChain } from "./history.js";
26
25
  const STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
26
+ const BRIEF_HEALTH_DETAIL_LIMIT = 8;
27
27
  const TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
28
28
  const TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
29
29
  const TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS = 2_500;
@@ -550,6 +550,227 @@ function summarizeList(values, limit) {
550
550
  truncated: true,
551
551
  };
552
552
  }
553
+ function summarizeRecordList(value, limit) {
554
+ if (!Array.isArray(value)) {
555
+ return {
556
+ count: 0,
557
+ sample: [],
558
+ truncated: false,
559
+ };
560
+ }
561
+ return {
562
+ count: value.length,
563
+ sample: value.slice(0, limit),
564
+ truncated: value.length > limit,
565
+ };
566
+ }
567
+ function summarizeExtensionRecord(value) {
568
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
569
+ return {};
570
+ }
571
+ const record = value;
572
+ return {
573
+ layer: record.layer,
574
+ directory: record.directory,
575
+ name: record.name,
576
+ version: record.version,
577
+ enabled: record.enabled,
578
+ status: record.status,
579
+ has_activate: record.has_activate,
580
+ capabilities: record.capabilities,
581
+ };
582
+ }
583
+ function summarizeExtensionList(value, limit) {
584
+ const summary = summarizeRecordList(value, limit);
585
+ return {
586
+ ...summary,
587
+ sample: summary.sample.map((entry) => summarizeExtensionRecord(entry)),
588
+ };
589
+ }
590
+ function summarizeStringList(value, limit) {
591
+ if (!Array.isArray(value)) {
592
+ return {
593
+ count: 0,
594
+ sample: [],
595
+ truncated: false,
596
+ };
597
+ }
598
+ const strings = value.filter((entry) => typeof entry === "string");
599
+ return {
600
+ count: strings.length,
601
+ sample: strings.slice(0, limit),
602
+ truncated: strings.length > limit,
603
+ };
604
+ }
605
+ function summarizeHealthCheckDetails(check, limit) {
606
+ const details = check.details;
607
+ if (check.name === "settings") {
608
+ return {
609
+ version: details.version,
610
+ id_prefix: details.id_prefix,
611
+ locks_ttl_seconds: details.locks_ttl_seconds,
612
+ warnings: summarizeStringList(details.warnings, limit),
613
+ };
614
+ }
615
+ if (check.name === "directories") {
616
+ return {
617
+ required_count: Array.isArray(details.required) ? details.required.length : 0,
618
+ optional_count: Array.isArray(details.optional) ? details.optional.length : 0,
619
+ missing_required: summarizeStringList(details.missing_required, limit),
620
+ missing_optional: summarizeStringList(details.missing_optional, limit),
621
+ missing: summarizeStringList(details.missing, limit),
622
+ strict_directories: details.strict_directories,
623
+ };
624
+ }
625
+ if (check.name === "settings_values") {
626
+ return {
627
+ warnings: summarizeStringList(details.warnings, limit),
628
+ };
629
+ }
630
+ if (check.name === "telemetry") {
631
+ return {
632
+ enabled: details.enabled,
633
+ capture_level: details.capture_level,
634
+ endpoint: details.endpoint,
635
+ queue_exists: details.queue_exists,
636
+ queue_entries: details.queue_entries,
637
+ queue_draining: details.queue_draining,
638
+ queue_invalid_rows: details.queue_invalid_rows,
639
+ queue_rows_total: details.queue_rows_total,
640
+ last_successful_flush_at: details.last_successful_flush_at,
641
+ last_failed_flush_at: details.last_failed_flush_at,
642
+ endpoint_probe: details.endpoint_probe,
643
+ env_overrides: details.env_overrides,
644
+ };
645
+ }
646
+ if (check.name === "extensions") {
647
+ const activation = typeof details.activation === "object" && details.activation !== null ? details.activation : {};
648
+ return {
649
+ disabled_by_flag: details.disabled_by_flag,
650
+ discovered: summarizeExtensionList(details.discovered, limit),
651
+ effective: summarizeExtensionList(details.effective, limit),
652
+ loaded: summarizeExtensionList(details.loaded, limit),
653
+ failed: summarizeRecordList(details.failed, limit),
654
+ warnings: summarizeStringList(details.warnings, limit),
655
+ activation: {
656
+ failed: summarizeRecordList(activation.failed, limit),
657
+ warnings: summarizeStringList(activation.warnings, limit),
658
+ hook_counts: activation.hook_counts,
659
+ command_handler_count: activation.command_handler_count,
660
+ service_override_count: activation.service_override_count,
661
+ renderer_override_count: activation.renderer_override_count,
662
+ registration_counts: activation.registration_counts,
663
+ migration_status: typeof activation.migration_status === "object" && activation.migration_status !== null
664
+ ? {
665
+ applied_count: activation.migration_status.applied_count,
666
+ pending_count: activation.migration_status.pending_count,
667
+ failed_count: activation.migration_status.failed_count,
668
+ }
669
+ : null,
670
+ },
671
+ triage: details.triage,
672
+ capability_contract: details.capability_contract,
673
+ capability_guidance: summarizeRecordList(details.capability_guidance, limit),
674
+ };
675
+ }
676
+ if (check.name === "storage") {
677
+ return details;
678
+ }
679
+ if (check.name === "integrity") {
680
+ return {
681
+ checked_item_files: details.checked_item_files,
682
+ checked_history_streams: details.checked_history_streams,
683
+ counts: details.counts,
684
+ item_unreadable: summarizeStringList(details.item_unreadable, limit),
685
+ item_conflict_markers: summarizeRecordList(details.item_conflict_markers, limit),
686
+ item_parse_failures: summarizeStringList(details.item_parse_failures, limit),
687
+ history_unreadable: summarizeStringList(details.history_unreadable, limit),
688
+ history_conflict_markers: summarizeRecordList(details.history_conflict_markers, limit),
689
+ history_invalid_json: summarizeRecordList(details.history_invalid_json, limit),
690
+ skipped: details.skipped,
691
+ };
692
+ }
693
+ if (check.name === "history_drift") {
694
+ return {
695
+ checked_items: details.checked_items,
696
+ counts: details.counts,
697
+ drifted_items: summarizeStringList(details.drifted_items, limit),
698
+ missing_streams: summarizeStringList(details.missing_streams, limit),
699
+ unreadable_streams: summarizeStringList(details.unreadable_streams, limit),
700
+ hash_mismatches: summarizeStringList(details.hash_mismatches, limit),
701
+ chain_mismatches: summarizeStringList(details.chain_mismatches, limit),
702
+ skipped: details.skipped,
703
+ };
704
+ }
705
+ if (check.name === "vectorization") {
706
+ return {
707
+ semantic_runtime_available: details.semantic_runtime_available,
708
+ compatibility_mode_auto_defaults: details.compatibility_mode_auto_defaults,
709
+ auto_ollama_defaults_applied: details.auto_ollama_defaults_applied,
710
+ refresh_policy: details.refresh_policy,
711
+ provider_active: details.provider_active,
712
+ vector_store_active: details.vector_store_active,
713
+ items: details.items,
714
+ ledger_entries_before: details.ledger_entries_before,
715
+ stale_items_before_total: details.stale_items_before_total,
716
+ stale_items_before: summarizeStringList(details.stale_items_before, limit),
717
+ refresh_attempted: details.refresh_attempted,
718
+ refresh_skipped_reason: details.refresh_skipped_reason,
719
+ refresh_result: details.refresh_result,
720
+ ledger_entries_after: details.ledger_entries_after,
721
+ stale_items_after_total: details.stale_items_after_total,
722
+ stale_items_after: summarizeStringList(details.stale_items_after, limit),
723
+ skipped: details.skipped,
724
+ };
725
+ }
726
+ return details;
727
+ }
728
+ function applyBriefHealthProjection(result) {
729
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
730
+ return {
731
+ ok: result.ok,
732
+ checks: result.checks.map((check) => ({
733
+ name: check.name,
734
+ status: check.status,
735
+ details: summarizeHealthCheckDetails(check, BRIEF_HEALTH_DETAIL_LIMIT),
736
+ })),
737
+ warnings: warningsSummary.sample,
738
+ projection: {
739
+ mode: "brief",
740
+ warning_count: warningsSummary.count,
741
+ warnings_truncated: warningsSummary.truncated,
742
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT,
743
+ },
744
+ generated_at: result.generated_at,
745
+ };
746
+ }
747
+ function isSkippedHealthCheck(check) {
748
+ return check.details.skipped === true;
749
+ }
750
+ function applySummaryHealthProjection(result) {
751
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
752
+ const omittedChecks = result.checks.filter(isSkippedHealthCheck).map((check) => check.name);
753
+ return {
754
+ ok: result.ok,
755
+ checks: result.checks
756
+ .filter((check) => !isSkippedHealthCheck(check))
757
+ .map((check) => ({
758
+ name: check.name,
759
+ status: check.status,
760
+ details: {},
761
+ })),
762
+ warning_count: warningsSummary.count,
763
+ warnings: warningsSummary.sample,
764
+ projection: {
765
+ mode: "summary",
766
+ warning_count: warningsSummary.count,
767
+ warnings_truncated: warningsSummary.truncated,
768
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT,
769
+ omitted_checks: omittedChecks,
770
+ },
771
+ generated_at: result.generated_at,
772
+ };
773
+ }
553
774
  function selectStaleItemDetail(values, verboseStaleItems) {
554
775
  if (verboseStaleItems) {
555
776
  return {
@@ -732,7 +953,8 @@ async function buildTelemetryCheck(settings, options) {
732
953
  attempted: false,
733
954
  },
734
955
  env_overrides: {
735
- telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED"),
956
+ telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED") || telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
957
+ pm_no_telemetry: telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
736
958
  telemetry_otel_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_OTEL_DISABLED"),
737
959
  },
738
960
  },
@@ -741,61 +963,7 @@ async function buildTelemetryCheck(settings, options) {
741
963
  };
742
964
  }
743
965
  async function buildHistoryDriftCheck(pmRoot, items) {
744
- const missingStreams = [];
745
- const unreadableStreams = [];
746
- const hashMismatches = [];
747
- const chainMismatches = [];
748
- for (const item of items) {
749
- const historyPath = getHistoryPath(pmRoot, item.id);
750
- let latestAfterHash = null;
751
- try {
752
- const raw = await fs.readFile(historyPath, "utf8");
753
- if (raw.trim().length === 0) {
754
- missingStreams.push(item.id);
755
- continue;
756
- }
757
- const lines = raw.split(/\r?\n/);
758
- const entries = [];
759
- for (const line of lines) {
760
- const trimmed = line.trim();
761
- if (trimmed.length === 0) {
762
- continue;
763
- }
764
- const parsed = JSON.parse(trimmed);
765
- if (typeof parsed.after_hash !== "string" || parsed.after_hash.trim().length === 0) {
766
- throw new Error("missing after_hash");
767
- }
768
- entries.push(parsed);
769
- latestAfterHash = parsed.after_hash;
770
- }
771
- const chainVerification = verifyHistoryChain(entries);
772
- if (!chainVerification.ok) {
773
- chainMismatches.push(item.id);
774
- }
775
- }
776
- catch (error) {
777
- if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
778
- missingStreams.push(item.id);
779
- }
780
- else {
781
- unreadableStreams.push(item.id);
782
- }
783
- continue;
784
- }
785
- if (!latestAfterHash) {
786
- missingStreams.push(item.id);
787
- continue;
788
- }
789
- const { body, ...frontMatter } = item;
790
- const currentHash = hashDocument({
791
- metadata: frontMatter,
792
- body,
793
- });
794
- if (latestAfterHash !== currentHash) {
795
- hashMismatches.push(item.id);
796
- }
797
- }
798
- const driftedItems = [...new Set([...missingStreams, ...unreadableStreams, ...hashMismatches, ...chainMismatches])].sort((a, b) => a.localeCompare(b));
966
+ const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems } = await scanHistoryDrift(pmRoot, items);
799
967
  const warnings = [
800
968
  ...missingStreams.map((id) => `history_drift_missing_stream:${id}`),
801
969
  ...unreadableStreams.map((id) => `history_drift_unreadable_stream:${id}`),
@@ -973,28 +1141,35 @@ export async function runHealth(global, options = {}) {
973
1141
  checkTelemetry: options.checkTelemetry === true,
974
1142
  });
975
1143
  const extensionCheck = await buildExtensionCheck(pmRoot, settings, Boolean(global.noExtensions));
1144
+ const summaryMode = options.summary === true && options.full !== true;
1145
+ const fastProjectionCheckOnly = options.checkOnly === true && (options.brief === true || options.summary === true) && options.full !== true;
1146
+ const skipIntegrity = (options.skipIntegrity === true || fastProjectionCheckOnly) && options.full !== true;
1147
+ const skipDrift = (options.skipDrift === true || fastProjectionCheckOnly) && options.full !== true;
1148
+ const skipVectors = (options.skipVectors === true || fastProjectionCheckOnly) && options.full !== true;
976
1149
  const itemReadWarnings = [];
977
- const items = await listAllFrontMatterWithBody(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema);
1150
+ const items = skipDrift && skipVectors
1151
+ ? await listAllFrontMatter(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema)
1152
+ : await listAllFrontMatterWithBody(pmRoot, settings.item_format, typeRegistry.type_to_folder, itemReadWarnings, settings.schema);
1153
+ const itemsWithBody = items;
978
1154
  const normalizedItemReadWarnings = [...new Set(itemReadWarnings)];
979
- const historyPolicy = await enforceHistoryStreamPolicyForItems({
980
- pmRoot,
981
- settings,
982
- itemIds: items.map((item) => item.id),
983
- commandLabel: "health",
984
- });
1155
+ const historyPolicy = skipDrift
1156
+ ? { warnings: [] }
1157
+ : await enforceHistoryStreamPolicyForItems({
1158
+ pmRoot,
1159
+ settings,
1160
+ itemIds: items.map((item) => item.id),
1161
+ commandLabel: "health",
1162
+ });
985
1163
  const historySummary = await countHistoryStreams(pmRoot);
986
- const skipIntegrity = options.skipIntegrity === true && options.full !== true;
987
- const skipDrift = options.skipDrift === true && options.full !== true;
988
- const skipVectors = options.skipVectors === true && options.full !== true;
989
1164
  const integrityCheck = skipIntegrity
990
1165
  ? { check: { name: "integrity", status: "ok", details: { skipped: true } }, warnings: [] }
991
1166
  : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema);
992
1167
  const historyDriftCheck = skipDrift
993
1168
  ? { check: { name: "history_drift", status: "ok", details: { skipped: true } }, warnings: [] }
994
- : await buildHistoryDriftCheck(pmRoot, items);
1169
+ : await buildHistoryDriftCheck(pmRoot, itemsWithBody);
995
1170
  const vectorizationCheck = skipVectors
996
1171
  ? { check: { name: "vectorization", status: "ok", details: { skipped: true } }, warnings: [] }
997
- : await buildVectorizationCheck(pmRoot, settings, items, refreshPolicy, options.verboseStaleItems === true);
1172
+ : await buildVectorizationCheck(pmRoot, settings, itemsWithBody, refreshPolicy, options.verboseStaleItems === true);
998
1173
  const checks = [
999
1174
  {
1000
1175
  name: "settings",
@@ -1055,12 +1230,16 @@ export async function runHealth(global, options = {}) {
1055
1230
  ...hookWarnings,
1056
1231
  ];
1057
1232
  const normalizedWarnings = [...new Set(warnings)];
1058
- return {
1233
+ const result = {
1059
1234
  ok: normalizedWarnings.length === 0,
1060
1235
  checks,
1061
1236
  warnings: normalizedWarnings,
1062
1237
  generated_at: nowIso(),
1063
1238
  };
1239
+ if (summaryMode) {
1240
+ return applySummaryHealthProjection(result);
1241
+ }
1242
+ return options.brief === true ? applyBriefHealthProjection(result) : result;
1064
1243
  }
1065
1244
  //# sourceMappingURL=health.js.map
1066
- //# debugId=877f600b-5e09-5d62-bf4e-7bf9f9e38289
1245
+ //# debugId=c5b24e35-02f9-5f45-9ef2-e5c850396686