@unbrained/pm-cli 2026.9.1 → 2026.9.3

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 (133) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +27 -0
  3. package/dist/cli/after-command-context-usage.js +16 -3
  4. package/dist/cli-bundle/bundle-manifest.json +153 -153
  5. package/dist/cli-bundle/chunks/{chunk-6XIIGE7U.js → chunk-34HASX3S.js} +2 -2
  6. package/dist/cli-bundle/chunks/chunk-AY324UJ5.js +9 -0
  7. package/dist/cli-bundle/chunks/{chunk-TAG4VC22.js → chunk-DKGP3QLE.js} +27 -27
  8. package/dist/cli-bundle/chunks/chunk-E5RBBCXO.js +230 -0
  9. package/dist/cli-bundle/chunks/{chunk-DTGWEL23.js → chunk-EDPIS7EB.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-X4RCGLTX.js → chunk-IEHHE6GA.js} +5 -5
  11. package/dist/cli-bundle/chunks/{chunk-U45JXJCC.js → chunk-L7B7343B.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-2MC2LCXZ.js → chunk-LENC656S.js} +41 -41
  13. package/dist/cli-bundle/chunks/chunk-LISESA7W.js +35 -0
  14. package/dist/cli-bundle/chunks/{chunk-3WICXLVT.js → chunk-UPPM2FOZ.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-Y7VOMSZT.js → chunk-Y4PJ6HPK.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-list-query-XYNX4ASQ.js → register-list-query-W2ZTOMKP.js} +2 -2
  17. package/dist/cli-bundle/chunks/{register-mutation-2MVLRS3J.js → register-mutation-RVND5NCG.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-operations-WCIDXBU3.js → register-operations-TTROIVC4.js} +2 -2
  19. package/dist/cli-bundle/chunks/{register-setup-KVNC5KPL.js → register-setup-D3ZFHY3L.js} +2 -2
  20. package/dist/cli-bundle/focused-chunks/chunk-3ZBI35HU.js +176 -0
  21. package/dist/cli-bundle/focused-chunks/{chunk-SVXJYD6G.js → chunk-4HJFY4MB.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/chunk-4RRHC3S4.js +6 -0
  23. package/dist/cli-bundle/focused-chunks/chunk-4WR46RMG.js +9 -0
  24. package/dist/cli-bundle/focused-chunks/chunk-5RFXUPN5.js +3 -0
  25. package/dist/cli-bundle/focused-chunks/chunk-BWKHEIVF.js +2 -0
  26. package/dist/cli-bundle/focused-chunks/{chunk-4O4CJAR6.js → chunk-D7KXFBXV.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-MKHG3T76.js → chunk-GHCZ3YFR.js} +3 -3
  28. package/dist/cli-bundle/focused-chunks/{chunk-KB5OFSFD.js → chunk-GT7MXDLW.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-KBLZRU62.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/chunk-KZ2NB3ET.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/chunk-M5M6SVHS.js +3 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-BEVHCEWG.js → chunk-OL5EH6I3.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-MEASX544.js → chunk-Q45NHPF2.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-Y6JJIX6I.js → chunk-QKHCSUGJ.js} +48 -48
  35. package/dist/cli-bundle/focused-chunks/chunk-S27XMBIN.js +8 -0
  36. package/dist/cli-bundle/focused-chunks/chunk-TXE4TSHM.js +12 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-UCLO3XDU.js +2 -0
  38. package/dist/cli-bundle/main.js +15 -15
  39. package/dist/cli-bundle/sdk-authoring.js +1 -1
  40. package/dist/cli-bundle/sdk-contracts.js +1 -1
  41. package/dist/cli-bundle/sdk-core.js +28 -28
  42. package/dist/cli-bundle/sdk-governance.js +1 -1
  43. package/dist/cli-bundle/sdk-graph.js +1 -1
  44. package/dist/cli-bundle/sdk-merge.js +35 -33
  45. package/dist/cli-bundle/sdk-query.js +1 -1
  46. package/dist/cli-bundle/sdk-runtime.js +1 -1
  47. package/dist/cli-bundle/sdk-testing.js +1 -1
  48. package/dist/cli-bundle/sdk.js +9 -9
  49. package/dist/core/diagnostics/remediation.js +9 -4
  50. package/dist/core/history/event-classification.d.ts +21 -0
  51. package/dist/core/history/event-classification.js +109 -0
  52. package/dist/core/history/event-index.d.ts +14 -3
  53. package/dist/core/history/event-index.js +543 -88
  54. package/dist/core/history/history.js +47 -18
  55. package/dist/core/history/workspace-history.js +7 -6
  56. package/dist/core/lock/lock.d.ts +22 -2
  57. package/dist/core/lock/lock.js +121 -19
  58. package/dist/core/output/output.js +31 -7
  59. package/dist/core/shared/time.d.ts +2 -0
  60. package/dist/core/shared/time.js +8 -2
  61. package/dist/core/store/item-metadata-query-index.js +5 -5
  62. package/dist/sdk/context/recency.d.ts +9 -0
  63. package/dist/sdk/context/recency.js +34 -0
  64. package/dist/sdk/context/usage-egress.d.ts +9 -0
  65. package/dist/sdk/context/usage-egress.js +30 -0
  66. package/dist/sdk/context-intent-contracts.js +7 -3
  67. package/dist/sdk/context-relevance.d.ts +23 -0
  68. package/dist/sdk/context-relevance.js +94 -23
  69. package/dist/sdk/context-signal-store.d.ts +7 -3
  70. package/dist/sdk/context-signal-store.js +155 -42
  71. package/dist/sdk/context-usage.d.ts +54 -0
  72. package/dist/sdk/context-usage.js +245 -16
  73. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +26 -14
  74. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
  75. package/dist/sdk/governance/health.js +77 -11
  76. package/dist/sdk/governance/validate.js +4 -2
  77. package/dist/sdk/index.d.ts +2 -0
  78. package/dist/sdk/index.js +4 -2
  79. package/dist/sdk/init.d.ts +2 -0
  80. package/dist/sdk/init.js +18 -9
  81. package/dist/sdk/merge/index.d.ts +1 -1
  82. package/dist/sdk/merge/index.js +2 -2
  83. package/dist/sdk/merge/receipts.d.ts +24 -0
  84. package/dist/sdk/merge/receipts.js +122 -30
  85. package/dist/sdk/query/context.d.ts +3 -1
  86. package/dist/sdk/query/context.js +21 -9
  87. package/dist/sdk/query/next.js +18 -9
  88. package/dist/sdk/runtime-input.d.ts +2 -0
  89. package/dist/sdk/runtime-input.js +25 -2
  90. package/dist/sdk/runtime.d.ts +1 -0
  91. package/dist/sdk/runtime.js +17 -26
  92. package/dist/types.d.ts +2 -0
  93. package/dist/types.js +2 -2
  94. package/docs/CONTEXT_RECOVERY_PRIMITIVES.md +11 -2
  95. package/docs/CONTEXT_RELEVANCE.md +44 -1
  96. package/docs/MERGE_SAFETY.md +16 -2
  97. package/docs/PERFORMANCE.md +6 -3
  98. package/docs/READ_OUTPUT_CONTRACTS.md +9 -1
  99. package/docs/SDK.md +11 -8
  100. package/docs/SDK_CONTEXT.md +7 -0
  101. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +5 -3
  102. package/marketplace.json +2 -2
  103. package/package.json +4 -4
  104. package/packages/pm-beads/package.json +1 -1
  105. package/packages/pm-calendar/package.json +1 -1
  106. package/packages/pm-command-kit/package.json +1 -1
  107. package/packages/pm-digital-twin/package.json +1 -1
  108. package/packages/pm-governance-audit/package.json +1 -1
  109. package/packages/pm-guide-shell/package.json +1 -1
  110. package/packages/pm-kanban/package.json +1 -1
  111. package/packages/pm-lifecycle-hooks/package.json +1 -1
  112. package/packages/pm-linked-test-adapters/package.json +1 -1
  113. package/packages/pm-search-advanced/package.json +1 -1
  114. package/packages/pm-templates/package.json +1 -1
  115. package/packages/pm-todos/package.json +1 -1
  116. package/packages/pm-vcs/package.json +1 -1
  117. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  118. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  119. package/sdk/public-surface.json +268 -28
  120. package/dist/cli-bundle/chunks/chunk-ALKKAUFN.js +0 -35
  121. package/dist/cli-bundle/chunks/chunk-GOACULJW.js +0 -13
  122. package/dist/cli-bundle/chunks/chunk-NOPL37X4.js +0 -205
  123. package/dist/cli-bundle/focused-chunks/chunk-2FEZ5SKM.js +0 -3
  124. package/dist/cli-bundle/focused-chunks/chunk-6GCRSLPG.js +0 -2
  125. package/dist/cli-bundle/focused-chunks/chunk-7VATS5QY.js +0 -16
  126. package/dist/cli-bundle/focused-chunks/chunk-FWPLDEXF.js +0 -2
  127. package/dist/cli-bundle/focused-chunks/chunk-JEFKLWMM.js +0 -2
  128. package/dist/cli-bundle/focused-chunks/chunk-PF3E6Q36.js +0 -8
  129. package/dist/cli-bundle/focused-chunks/chunk-QDFJIRKN.js +0 -4
  130. package/dist/cli-bundle/focused-chunks/chunk-RMRCQPWU.js +0 -2
  131. package/dist/cli-bundle/focused-chunks/chunk-S4U5CN5Q.js +0 -2
  132. package/dist/cli-bundle/focused-chunks/chunk-T2LXXSOD.js +0 -158
  133. package/dist/cli-bundle/focused-chunks/chunk-Z2USIBR2.js +0 -5
@@ -19,7 +19,7 @@
19
19
  */
20
20
  /** Registry of every non-extension `pm health` / `pm validate` warning code and its remediation. Extension findings keep their richer, contextual `details.triage.remediation` produced by the extension health triage and are intentionally excluded here (see pm-0hnu: "all non-extension checks"). */
21
21
 
22
- !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]="bb094b44-42b2-5a1c-9fc2-7a0eeaf9fbfd")}catch(e){}}();
22
+ !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]="24a69725-363a-59e1-96c6-1e1ca079a311")}catch(e){}}();
23
23
  export const REMEDIATION_REGISTRY = Object.freeze([
24
24
  // --- pm health: directories ---
25
25
  {
@@ -200,8 +200,13 @@ export const REMEDIATION_REGISTRY = Object.freeze([
200
200
  },
201
201
  {
202
202
  code: "merge_receipt_evidence_invalid",
203
- command: "pm health --check-only --full",
204
- summary: "One or more receipt files failed bounded-file, schema, or identity validation; use the full health count to inspect the clone-local and durable receipt directories, then repair or remove only confirmed invalid evidence.",
203
+ command: "pm merge report --include-reconciled --json",
204
+ summary: "One or more receipt candidates failed bounded-file, schema, identity, or copy-consistency validation; inspect the report's privacy-safe source, receipt id, and reason before repairing only the named evidence.",
205
+ },
206
+ {
207
+ code: "merge_receipt_history_reference_missing",
208
+ command: "pm health --check-only --full --json",
209
+ summary: "One or more append-only history coordinates reference receipt evidence that is no longer present; inspect the bounded item, line, and privacy-safe receipt locator, then recover the named evidence from an authoritative clone or backup without rewriting history.",
205
210
  },
206
211
  {
207
212
  code: "validate_merge_decisions_unreviewed",
@@ -499,4 +504,4 @@ export function buildRemediationCommands(warnings) {
499
504
  return Object.values(buildRemediationMap(warnings));
500
505
  }
501
506
  //# sourceMappingURL=remediation.js.map
502
- //# debugId=bb094b44-42b2-5a1c-9fc2-7a0eeaf9fbfd
507
+ //# debugId=24a69725-363a-59e1-96c6-1e1ca079a311
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @module core/history/event-classification
3
+ *
4
+ * Declares the stable semantic boundary between history events that advance
5
+ * project work and maintenance events that only preserve tracker governance.
6
+ */
7
+ import type { HistoryEntry } from "../../types/index.js";
8
+ /** Current version of the public history-event classification policy. */
9
+ export declare const HISTORY_EVENT_CLASSIFICATION_VERSION: 1;
10
+ /** Semantic effect of an immutable history event on project recency. */
11
+ export type HistoryEventClass = "substantive" | "maintenance";
12
+ /** Operations whose meaning is always governance or storage maintenance. */
13
+ export declare const MAINTENANCE_HISTORY_OPERATIONS: readonly ["docs_add", "files_add", "history:author-acknowledge", "history_author_acknowledge", "history_compact", "history_compact_baseline", "history_redact", "history_repair", "normalize", "release", "test_run_track", "tests_add", "tests_remove", "update_audit", "update_ownership_bypass"];
14
+ /** Operations whose meaning always advances lifecycle or working context. */
15
+ export declare const SUBSTANTIVE_HISTORY_OPERATIONS: readonly ["append", "cancel", "claim", "close", "comment_add", "create", "learning_add", "note_add", "reopen"];
16
+ /**
17
+ * Classify an immutable event using its declared class when present, then the
18
+ * versioned operation/path contract. Unknown events fail closed as substantive
19
+ * so new work cannot silently disappear from temporal relevance.
20
+ */
21
+ export declare function classifyHistoryEvent(entry: Pick<HistoryEntry, "op" | "patch" | "event_class">): HistoryEventClass;
@@ -0,0 +1,109 @@
1
+ /** Current version of the public history-event classification policy. */
2
+
3
+ !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]="6398c65d-fb5c-5479-93c2-0be963352a92")}catch(e){}}();
4
+ export const HISTORY_EVENT_CLASSIFICATION_VERSION = 1;
5
+ /** Operations whose meaning is always governance or storage maintenance. */
6
+ export const MAINTENANCE_HISTORY_OPERATIONS = [
7
+ "docs_add",
8
+ "files_add",
9
+ "history:author-acknowledge",
10
+ "history_author_acknowledge",
11
+ "history_compact",
12
+ "history_compact_baseline",
13
+ "history_redact",
14
+ "history_repair",
15
+ "normalize",
16
+ "release",
17
+ "test_run_track",
18
+ "tests_add",
19
+ "tests_remove",
20
+ "update_audit",
21
+ "update_ownership_bypass",
22
+ ];
23
+ /** Operations whose meaning always advances lifecycle or working context. */
24
+ export const SUBSTANTIVE_HISTORY_OPERATIONS = [
25
+ "append",
26
+ "cancel",
27
+ "claim",
28
+ "close",
29
+ "comment_add",
30
+ "create",
31
+ "learning_add",
32
+ "note_add",
33
+ "reopen",
34
+ ];
35
+ const MAINTENANCE_OPERATIONS = new Set(MAINTENANCE_HISTORY_OPERATIONS);
36
+ const SUBSTANTIVE_OPERATIONS = new Set(SUBSTANTIVE_HISTORY_OPERATIONS);
37
+ const MAINTENANCE_UPDATE_FIELDS = new Set([
38
+ "actual_result",
39
+ "affected_version",
40
+ "assignee",
41
+ "blocked_by",
42
+ "blocked_reason",
43
+ "close_reason",
44
+ "confidence",
45
+ "customer_impact",
46
+ "definition_of_ready",
47
+ "dependencies",
48
+ "docs",
49
+ "environment",
50
+ "expected_result",
51
+ "files",
52
+ "fixed_version",
53
+ "goal",
54
+ "impact",
55
+ "learnings",
56
+ "notes",
57
+ "objective",
58
+ "order",
59
+ "outcome",
60
+ "parent",
61
+ "release",
62
+ "reminders",
63
+ "reporter",
64
+ "repro_steps",
65
+ "resolution",
66
+ "reviewer",
67
+ "severity",
68
+ "sprint",
69
+ "tests",
70
+ "test_runs",
71
+ "unblock_note",
72
+ "updated_at",
73
+ "value",
74
+ "why_now",
75
+ ]);
76
+ function topLevelPatchField(operation) {
77
+ const segments = operation.path.split("/").filter(Boolean);
78
+ if (segments[0] === "metadata" || segments[0] === "front_matter") {
79
+ return segments[1];
80
+ }
81
+ return segments[0] === "body" ? "body" : undefined;
82
+ }
83
+ /**
84
+ * Classify an immutable event using its declared class when present, then the
85
+ * versioned operation/path contract. Unknown events fail closed as substantive
86
+ * so new work cannot silently disappear from temporal relevance.
87
+ */
88
+ export function classifyHistoryEvent(entry) {
89
+ if (entry.event_class === "substantive" ||
90
+ entry.event_class === "maintenance") {
91
+ return entry.event_class;
92
+ }
93
+ if (MAINTENANCE_OPERATIONS.has(entry.op))
94
+ return "maintenance";
95
+ if (SUBSTANTIVE_OPERATIONS.has(entry.op))
96
+ return "substantive";
97
+ if (entry.op !== "update")
98
+ return "substantive";
99
+ return Array.isArray(entry.patch) &&
100
+ entry.patch.length > 0 &&
101
+ entry.patch.every((operation) => {
102
+ const field = topLevelPatchField(operation);
103
+ return field !== undefined && MAINTENANCE_UPDATE_FIELDS.has(field);
104
+ })
105
+ ? "maintenance"
106
+ : "substantive";
107
+ }
108
+ //# sourceMappingURL=event-classification.js.map
109
+ //# debugId=6398c65d-fb5c-5479-93c2-0be963352a92
@@ -47,6 +47,8 @@ export interface HistoryEventIndexQueryResult {
47
47
  /** Whether another matching event exists. */
48
48
  has_more: boolean;
49
49
  }
50
+ /** Latest substantive immutable event for each requested history stream. */
51
+ export type LatestSubstantiveHistoryEvents = Readonly<Record<string, IndexedHistoryEvent>>;
50
52
  declare function loadDatabaseSync(loadModule: (specifier: string) => unknown): DatabaseSyncConstructor | null;
51
53
  declare function loadStableDatabaseSync(nodeVersion: string, loadModule: (specifier: string) => unknown): DatabaseSyncConstructor | null;
52
54
  /** Rebuild the complete optional event projection from authoritative streams. */
@@ -57,16 +59,25 @@ export declare function rebuildHistoryEventIndex(pmRoot: string): Promise<boolea
57
59
  */
58
60
  export declare function queryHistoryEventStreams(pmRoot: string, query: HistoryEventIndexQuery): Promise<HistoryEventIndexQueryResult>;
59
61
  /**
60
- * Update an already-built event projection after one authoritative append.
61
- * Absence is a cheap no-op; corrupt projections are removed for lazy rebuild.
62
+ * Serialize an authoritative append with its optional SQLite projection.
63
+ * The database write lock spans the file append and size capture, so compliant
64
+ * cross-process writers cannot certify a newer stream size with older rows.
62
65
  */
63
- export declare function updateHistoryEventIndexAfterAppend(historyPath: string, entry: HistoryEntry): Promise<void>;
66
+ export declare function appendHistoryEntryWithEventIndex(historyPath: string, entry: HistoryEntry, append: () => Promise<void>): Promise<void>;
64
67
  /** Invalidate the optional event projection after a non-append rewrite. */
65
68
  export declare function removeHistoryEventIndexForHistoryPath(historyPath: string): Promise<void>;
66
69
  /** Query the optional event projection without scanning history streams. */
67
70
  export declare function queryHistoryEventIndex(pmRoot: string, query: HistoryEventIndexQuery): Promise<HistoryEventIndexQueryResult | null>;
71
+ declare function collectLatestSubstantiveEvents(events: readonly IndexedHistoryEvent[], requested: ReadonlySet<string>): Record<string, IndexedHistoryEvent>;
72
+ /**
73
+ * Read one latest substantive coordinate per requested stream. The optional
74
+ * SQLite projection is preferred; individual authoritative streams are the
75
+ * fail-closed fallback and remain the source of truth.
76
+ */
77
+ export declare function readLatestSubstantiveHistoryEvents(pmRoot: string, streamIds: readonly string[]): Promise<LatestSubstantiveHistoryEvents>;
68
78
  /** Test-only dependency seam for runtimes without `node:sqlite`. */
69
79
  export declare const _testOnly: {
80
+ collectLatestSubstantiveEvents: typeof collectLatestSubstantiveEvents;
70
81
  loadDatabaseSync: typeof loadDatabaseSync;
71
82
  loadStableDatabaseSync: typeof loadStableDatabaseSync;
72
83
  setDatabaseSync(databaseSync: DatabaseSyncConstructor | null): () => void;