@unbrained/pm-cli 2026.9.4 → 2026.9.6

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 (277) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
  2. package/.agents/skills/README.md +2 -2
  3. package/.agents/skills/pm-developer/SKILL.md +4 -1
  4. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +10 -0
  5. package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +3 -1
  6. package/.agents/skills/pm-extensions/SKILL.md +2 -2
  7. package/.agents/skills/pm-extensions/references/LIFECYCLE.md +3 -3
  8. package/.agents/skills/pm-extensions/references/TROUBLESHOOTING.md +3 -3
  9. package/.agents/skills/pm-user/SKILL.md +2 -0
  10. package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +5 -0
  11. package/.agents/skills/pm-user/references/WORKFLOWS.md +20 -5
  12. package/.claude-plugin/marketplace.json +2 -2
  13. package/CHANGELOG.md +58 -3
  14. package/dist/cli/commander-usage.d.ts +2 -0
  15. package/dist/cli/commander-usage.js +15 -12
  16. package/dist/cli/help-json-payload.js +12 -7
  17. package/dist/cli/main.js +22 -11
  18. package/dist/cli/register-list-query.js +4 -2
  19. package/dist/cli/register-mutation.js +4 -2
  20. package/dist/cli/register-operations.js +17 -8
  21. package/dist/cli-bundle/bundle-manifest.json +153 -161
  22. package/dist/cli-bundle/chunks/chunk-AZDFJGH6.js +9 -0
  23. package/dist/cli-bundle/chunks/{chunk-V72UV7QS.js → chunk-BAX2BYUW.js} +73 -73
  24. package/dist/cli-bundle/chunks/{chunk-HI6BHPCU.js → chunk-CKOL5U7J.js} +51 -51
  25. package/dist/cli-bundle/chunks/{chunk-A24WAVE6.js → chunk-JT6XF6GE.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-I2AS367G.js → chunk-JX4DH4WC.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-YW4QK2G7.js → chunk-NPN5I67J.js} +2 -2
  28. package/dist/cli-bundle/chunks/chunk-OF76PSDQ.js +5 -0
  29. package/dist/cli-bundle/chunks/chunk-QUWFABDM.js +232 -0
  30. package/dist/cli-bundle/chunks/{chunk-RI4XNOYS.js → chunk-RWWBOWJ5.js} +2 -2
  31. package/dist/cli-bundle/chunks/chunk-WGAOYSYH.js +40 -0
  32. package/dist/cli-bundle/chunks/{chunk-X6CMGV6L.js → chunk-WI2AYPA7.js} +2 -2
  33. package/dist/cli-bundle/chunks/{register-list-query-Z5YYSJJG.js → register-list-query-5JL52D33.js} +3 -3
  34. package/dist/cli-bundle/chunks/{register-mutation-ELSP6I4I.js → register-mutation-ZPG7KMVP.js} +4 -4
  35. package/dist/cli-bundle/chunks/register-operations-I5W3KMGB.js +2 -0
  36. package/dist/cli-bundle/chunks/{register-setup-E2AE72QG.js → register-setup-H4SVAVX7.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-3646BZ4W.js → chunk-3BZEOXLT.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-AL5ON6K6.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-CHC2IDXA.js +6 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-CK6QFAPZ.js +20 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-NBMJD6MK.js → chunk-EZR3GHFE.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-H2WJWK7L.js +56 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-53IHPICX.js → chunk-LIJIA4TY.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-25UJBH4M.js → chunk-M6PBRFSH.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/{chunk-AJR3OP2E.js → chunk-NTPY5GSO.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-P5O7MP5Y.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/chunk-PDMW2E36.js +177 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-MHKUIPJW.js → chunk-PEFABF7E.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/{chunk-6PWPQKDN.js → chunk-QTVCLMSZ.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-7N2TV7WZ.js → chunk-QTZRBUYA.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-SGQST3PQ.js +12 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-UKHASMMP.js +10 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-ZPEKQHOC.js +2 -0
  54. package/dist/cli-bundle/main.js +22 -15
  55. package/dist/cli-bundle/sdk-authoring.js +1 -1
  56. package/dist/cli-bundle/sdk-contracts.js +2 -2
  57. package/dist/cli-bundle/sdk-core.js +37 -37
  58. package/dist/cli-bundle/sdk-governance.js +1 -1
  59. package/dist/cli-bundle/sdk-graph.js +1 -1
  60. package/dist/cli-bundle/sdk-merge.js +42 -39
  61. package/dist/cli-bundle/sdk-query.js +1 -1
  62. package/dist/cli-bundle/sdk-runtime.js +1 -1
  63. package/dist/cli-bundle/sdk-testing.js +1 -1
  64. package/dist/cli-bundle/sdk.js +9 -9
  65. package/dist/core/extensions/extension-types.d.ts +2 -0
  66. package/dist/core/extensions/extension-types.js +2 -2
  67. package/dist/core/extensions/module-graph-snapshot.js +5 -4
  68. package/dist/core/fs/host-environment-errors.d.ts +27 -0
  69. package/dist/core/fs/host-environment-errors.js +142 -0
  70. package/dist/core/history/drift-scan.d.ts +5 -0
  71. package/dist/core/history/drift-scan.js +16 -6
  72. package/dist/core/history/event-classification.d.ts +1 -1
  73. package/dist/core/history/event-classification.js +3 -2
  74. package/dist/core/history/history.js +37 -5
  75. package/dist/core/history/identity.d.ts +15 -0
  76. package/dist/core/history/identity.js +31 -0
  77. package/dist/core/history/projection.js +50 -17
  78. package/dist/core/history/read.js +6 -3
  79. package/dist/core/history/replay.d.ts +1 -2
  80. package/dist/core/history/replay.js +4 -4
  81. package/dist/core/history/version-address.d.ts +13 -0
  82. package/dist/core/history/version-address.js +33 -0
  83. package/dist/core/item/actionability.d.ts +21 -1
  84. package/dist/core/item/actionability.js +45 -10
  85. package/dist/core/item/id.js +8 -4
  86. package/dist/core/item/item-type-definition.d.ts +2 -0
  87. package/dist/core/item/item-type-definition.js +9 -2
  88. package/dist/core/item/type-registry.d.ts +5 -1
  89. package/dist/core/item/type-registry.js +9 -4
  90. package/dist/core/output/mutation-projection.js +12 -5
  91. package/dist/core/shared/errors.d.ts +8 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-query-index.js +13 -10
  94. package/dist/core/store/item-metadata-read-work.d.ts +19 -0
  95. package/dist/core/store/item-metadata-read-work.js +44 -0
  96. package/dist/core/store/item-store.d.ts +14 -0
  97. package/dist/core/store/item-store.js +52 -10
  98. package/dist/core/store/settings-validator.js +3 -2
  99. package/dist/core/validate/fix-planning.d.ts +1 -1
  100. package/dist/core/validate/fix-planning.js +2 -2
  101. package/dist/core/validate/missing-link-owners.d.ts +1 -1
  102. package/dist/core/validate/missing-link-owners.js +5 -3
  103. package/dist/core/validate/stale-file-classification.d.ts +6 -4
  104. package/dist/core/validate/stale-file-classification.js +20 -5
  105. package/dist/mcp/server.js +12 -5
  106. package/dist/sdk/actionability.d.ts +1 -1
  107. package/dist/sdk/actionability.js +3 -3
  108. package/dist/sdk/cli-contracts/command-aliases.js +11 -2
  109. package/dist/sdk/cli-contracts/completeness.js +4 -3
  110. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  111. package/dist/sdk/cli-contracts/flag-contracts.js +31 -5
  112. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +21 -13
  113. package/dist/sdk/cli-contracts/grammar-contracts.js +11 -2
  114. package/dist/sdk/cli-contracts/runtime-contracts.js +5 -2
  115. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +254 -5
  116. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +52 -2
  117. package/dist/sdk/cli-contracts/tool-parameter-tables.js +30 -6
  118. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  119. package/dist/sdk/cli-contracts/tool-schema.js +32 -7
  120. package/dist/sdk/context/usage-ledger.d.ts +41 -0
  121. package/dist/sdk/context/usage-ledger.js +186 -0
  122. package/dist/sdk/context-intent-contracts.js +3 -3
  123. package/dist/sdk/context-usage.d.ts +18 -9
  124. package/dist/sdk/context-usage.js +44 -121
  125. package/dist/sdk/define.d.ts +1 -1
  126. package/dist/sdk/define.js +2 -2
  127. package/dist/sdk/dependency-provenance.d.ts +7 -0
  128. package/dist/sdk/dependency-provenance.js +14 -4
  129. package/dist/sdk/duplicates.d.ts +2 -0
  130. package/dist/sdk/duplicates.js +3 -2
  131. package/dist/sdk/environment/host-environment-errors.d.ts +5 -27
  132. package/dist/sdk/environment/host-environment-errors.js +4 -137
  133. package/dist/sdk/extension/install-runtime.js +9 -6
  134. package/dist/sdk/extension/install-snapshot.js +7 -6
  135. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +104 -56
  136. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +50 -2
  137. package/dist/sdk/governance/assurance-action.d.ts +3 -2
  138. package/dist/sdk/governance/assurance-action.js +23 -11
  139. package/dist/sdk/governance/assurance-runtime.d.ts +2 -0
  140. package/dist/sdk/governance/assurance-runtime.js +6 -3
  141. package/dist/sdk/governance/defect-recurrence-coverage.d.ts +93 -0
  142. package/dist/sdk/governance/defect-recurrence-coverage.js +189 -0
  143. package/dist/sdk/governance/defect-recurrence-graph.d.ts +33 -0
  144. package/dist/sdk/governance/defect-recurrence-graph.js +121 -0
  145. package/dist/sdk/governance/defect-recurrence.d.ts +8 -0
  146. package/dist/sdk/governance/defect-recurrence.js +118 -17
  147. package/dist/sdk/governance/health.d.ts +17 -2
  148. package/dist/sdk/governance/health.js +31 -10
  149. package/dist/sdk/governance/linked-file-report.d.ts +41 -0
  150. package/dist/sdk/governance/linked-file-report.js +72 -0
  151. package/dist/sdk/governance/validate-history-drift.js +16 -5
  152. package/dist/sdk/governance/validate.d.ts +5 -2
  153. package/dist/sdk/governance/validate.js +21 -37
  154. package/dist/sdk/governance.d.ts +2 -0
  155. package/dist/sdk/governance.js +4 -2
  156. package/dist/sdk/guide-topics.js +116 -2
  157. package/dist/sdk/history/salvage.d.ts +35 -0
  158. package/dist/sdk/history/salvage.js +248 -0
  159. package/dist/sdk/history-compact.js +32 -37
  160. package/dist/sdk/history-read.d.ts +3 -2
  161. package/dist/sdk/history-read.js +6 -3
  162. package/dist/sdk/history-repair.d.ts +12 -0
  163. package/dist/sdk/history-repair.js +60 -13
  164. package/dist/sdk/lifecycle/claim.d.ts +4 -0
  165. package/dist/sdk/lifecycle/claim.js +9 -3
  166. package/dist/sdk/lifecycle/close.d.ts +8 -0
  167. package/dist/sdk/lifecycle/close.js +16 -8
  168. package/dist/sdk/lifecycle/create.js +9 -12
  169. package/dist/sdk/lifecycle/restore.d.ts +1 -0
  170. package/dist/sdk/lifecycle/restore.js +19 -7
  171. package/dist/sdk/lifecycle/update.js +12 -12
  172. package/dist/sdk/lifecycle-policy.d.ts +3 -0
  173. package/dist/sdk/lifecycle-policy.js +2 -2
  174. package/dist/sdk/merge/abandoned-receipts.d.ts +15 -0
  175. package/dist/sdk/merge/abandoned-receipts.js +47 -0
  176. package/dist/sdk/merge/driver.js +4 -2
  177. package/dist/sdk/merge/index.d.ts +1 -0
  178. package/dist/sdk/merge/index.js +2 -2
  179. package/dist/sdk/merge/receipt-operation.d.ts +15 -0
  180. package/dist/sdk/merge/receipt-operation.js +97 -0
  181. package/dist/sdk/merge/receipt-schema.d.ts +20 -0
  182. package/dist/sdk/merge/receipt-schema.js +398 -0
  183. package/dist/sdk/merge/receipts.d.ts +16 -7
  184. package/dist/sdk/merge/receipts.js +54 -340
  185. package/dist/sdk/merge/reconcile.d.ts +2 -0
  186. package/dist/sdk/merge/reconcile.js +11 -4
  187. package/dist/sdk/output-projection.d.ts +3 -1
  188. package/dist/sdk/output-projection.js +11 -3
  189. package/dist/sdk/public-surface.json +1 -0
  190. package/dist/sdk/query/context.d.ts +9 -0
  191. package/dist/sdk/query/context.js +33 -21
  192. package/dist/sdk/query/duplicate-candidates.d.ts +7 -0
  193. package/dist/sdk/query/duplicate-candidates.js +71 -0
  194. package/dist/sdk/query/get.d.ts +2 -2
  195. package/dist/sdk/query/get.js +9 -8
  196. package/dist/sdk/query/history.d.ts +11 -0
  197. package/dist/sdk/query/history.js +34 -10
  198. package/dist/sdk/query/next.d.ts +15 -1
  199. package/dist/sdk/query/next.js +43 -20
  200. package/dist/sdk/query.d.ts +3 -0
  201. package/dist/sdk/query.js +5 -2
  202. package/dist/sdk/read-output-session.js +5 -3
  203. package/dist/sdk/runtime-primitives.d.ts +1 -1
  204. package/dist/sdk/runtime-primitives.js +3 -3
  205. package/dist/sdk/runtime.js +4 -2
  206. package/dist/sdk/similarity.d.ts +24 -3
  207. package/dist/sdk/similarity.js +50 -55
  208. package/dist/types.d.ts +2 -0
  209. package/dist/types.js +2 -2
  210. package/docs/AGENT_GUIDE.md +58 -1
  211. package/docs/BOUNDED_CONTEXT_READS.md +185 -0
  212. package/docs/CLOSE_EVIDENCE_RECOVERY.md +35 -0
  213. package/docs/COMMANDS.md +30 -8
  214. package/docs/CONTEXT_RELEVANCE.md +16 -4
  215. package/docs/DEFECT_RECURRENCE.md +80 -6
  216. package/docs/EXTENSIONS.md +18 -19
  217. package/docs/HISTORY_RECOVERY.md +146 -0
  218. package/docs/MERGE_SAFETY.md +50 -0
  219. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +66 -0
  220. package/docs/PR_REVIEW_LOOP.md +18 -3
  221. package/docs/README.md +19 -1
  222. package/docs/RELEASING.md +31 -13
  223. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +24 -1
  224. package/docs/SDK_EXECUTION_CONTRACTS.md +105 -0
  225. package/docs/SDK_LIFECYCLE.md +27 -0
  226. package/docs/SDK_RUNTIME_BOUNDARIES.md +11 -0
  227. package/docs/TESTING.md +5 -0
  228. package/docs/agent-task-token-baseline.json +17 -17
  229. package/docs/agent-task-transcripts.json +2 -1
  230. package/docs/generated/FLAG_LEXICON_BUDGETS.md +11 -11
  231. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +11 -3
  232. package/marketplace.json +2 -2
  233. package/package.json +8 -6
  234. package/packages/pm-beads/package.json +1 -1
  235. package/packages/pm-calendar/package.json +1 -1
  236. package/packages/pm-command-kit/package.json +1 -1
  237. package/packages/pm-digital-twin/package.json +1 -1
  238. package/packages/pm-governance-audit/README.md +10 -1
  239. package/packages/pm-governance-audit/extensions/governance-audit/dedupe-audit.ts +50 -65
  240. package/packages/pm-governance-audit/extensions/governance-audit/index.ts +2 -2
  241. package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +1 -0
  242. package/packages/pm-governance-audit/package.json +1 -1
  243. package/packages/pm-guide-shell/package.json +1 -1
  244. package/packages/pm-kanban/package.json +1 -1
  245. package/packages/pm-lifecycle-hooks/package.json +1 -1
  246. package/packages/pm-linked-test-adapters/package.json +1 -1
  247. package/packages/pm-search-advanced/package.json +1 -1
  248. package/packages/pm-templates/package.json +1 -1
  249. package/packages/pm-todos/package.json +1 -1
  250. package/packages/pm-vcs/package.json +1 -1
  251. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  252. package/plugins/pm-claude/skills/pm-audit/SKILL.md +2 -2
  253. package/plugins/pm-claude/skills/pm-developer/SKILL.md +2 -2
  254. package/plugins/pm-claude/skills/pm-planner/SKILL.md +2 -2
  255. package/plugins/pm-claude/skills/pm-release/SKILL.md +2 -2
  256. package/plugins/pm-claude/skills/pm-workflow/SKILL.md +3 -3
  257. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  258. package/plugins/pm-codex/skills/pm-auditor/SKILL.md +2 -2
  259. package/plugins/pm-codex/skills/pm-native/SKILL.md +3 -4
  260. package/plugins/pm-codex/skills/pm-release/SKILL.md +2 -2
  261. package/scripts/finalize-build.mjs +13 -1
  262. package/dist/cli-bundle/chunks/chunk-6XSKPNCF.js +0 -230
  263. package/dist/cli-bundle/chunks/chunk-OGBVU67G.js +0 -5
  264. package/dist/cli-bundle/chunks/chunk-TXW6VL33.js +0 -38
  265. package/dist/cli-bundle/chunks/chunk-VGLHECAP.js +0 -9
  266. package/dist/cli-bundle/chunks/register-operations-OH7R3ZT4.js +0 -2
  267. package/dist/cli-bundle/focused-chunks/chunk-4YRAVI43.js +0 -12
  268. package/dist/cli-bundle/focused-chunks/chunk-5P4HVOWG.js +0 -176
  269. package/dist/cli-bundle/focused-chunks/chunk-636VVQ7F.js +0 -54
  270. package/dist/cli-bundle/focused-chunks/chunk-B3A6MJYE.js +0 -2
  271. package/dist/cli-bundle/focused-chunks/chunk-BFDDJ2T2.js +0 -2
  272. package/dist/cli-bundle/focused-chunks/chunk-BHUIRZWQ.js +0 -9
  273. package/dist/cli-bundle/focused-chunks/chunk-JADHHPY6.js +0 -6
  274. package/dist/cli-bundle/focused-chunks/chunk-NSKBLHVI.js +0 -20
  275. package/dist/cli-bundle/focused-chunks/chunk-P2GOAOQN.js +0 -2
  276. package/dist/cli-bundle/focused-chunks/chunk-YARWJM2B.js +0 -2
  277. package/sdk/public-surface.json +0 -33034
@@ -7,7 +7,7 @@
7
7
  * consumers from a single source of truth.
8
8
  */
9
9
 
10
- !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]="b81a68c1-565d-56f6-a0eb-35d2c737bdb7")}catch(e){}}();
10
+ !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]="e72f4ab4-5bf7-53fb-a3a3-174c4064f6a4")}catch(e){}}();
11
11
  import { normalizeUniqueStringList } from "./string-lists.js";
12
12
  import { PM_TOOL_ACTIONS } from "./enum-contracts.js";
13
13
  import { TOOL_CREATE_OPTION_CONTRACTS, TOOL_SHARED_CREATE_UPDATE_OPTION_CONTRACTS, TOOL_UPDATE_OPTION_CONTRACTS, TOOL_UPDATE_MANY_FILTER_OPTION_CONTRACTS, TOOL_CONTEXT_OPTION_CONTRACTS, TOOL_ACTIVITY_OPTION_CONTRACTS, TOOL_LIST_FILTER_OPTION_CONTRACTS, TOOL_AGGREGATE_OPTION_CONTRACTS, TOOL_SEARCH_FILTER_OPTION_CONTRACTS, TOOL_CLOSE_MANY_FILTER_OPTION_CONTRACTS, } from "./tool-option-contracts.js";
@@ -216,7 +216,6 @@ const LIST_CONTRACT_PARAMETER_KEYS = toSchemaKeyList([
216
216
  "full",
217
217
  ]);
218
218
  const FIXED_STATUS_LIST_CONTRACT_PARAMETER_KEYS = LIST_CONTRACT_PARAMETER_KEYS.filter((parameter) => parameter !== "all" && parameter !== "status");
219
- const ALL_STATUS_LIST_CONTRACT_PARAMETER_KEYS = LIST_CONTRACT_PARAMETER_KEYS.filter((parameter) => parameter !== "status");
220
219
  const LIST_WINDOW_MUTUALLY_EXCLUSIVE_GROUPS = [
221
220
  [
222
221
  { property: "today", schema: { const: true } },
@@ -291,6 +290,8 @@ const NEXT_CONTRACT_PARAMETER_KEYS = toSchemaKeyList([
291
290
  "readyOnly",
292
291
  "format",
293
292
  "includeDecisions",
293
+ "includeGates",
294
+ "includeContainers",
294
295
  "tokenBudget",
295
296
  "explainRanking",
296
297
  ]);
@@ -482,7 +483,7 @@ const PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
482
483
  mutuallyExclusiveWhen: LIST_WINDOW_MUTUALLY_EXCLUSIVE_GROUPS,
483
484
  },
484
485
  "list-all": {
485
- optional: ALL_STATUS_LIST_CONTRACT_PARAMETER_KEYS,
486
+ optional: LIST_CONTRACT_PARAMETER_KEYS,
486
487
  mutuallyExclusiveWhen: LIST_WINDOW_MUTUALLY_EXCLUSIVE_GROUPS,
487
488
  },
488
489
  "list-draft": {
@@ -643,9 +644,20 @@ const PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
643
644
  "all",
644
645
  "dryRun",
645
646
  "normalizeProvenance",
647
+ "salvageTail",
646
648
  ...AUTHOR_MESSAGE_FORCE_PARAMETER_KEYS,
647
649
  ],
648
650
  oneOfRequired: [["id"], ["all"]],
651
+ mutuallyExclusiveWhen: [
652
+ [
653
+ { property: "salvageTail", schema: { const: true } },
654
+ { property: "all", schema: { const: true } },
655
+ ],
656
+ [
657
+ { property: "salvageTail", schema: { const: true } },
658
+ { property: "normalizeProvenance", schema: { const: true } },
659
+ ],
660
+ ],
649
661
  },
650
662
  "history-author-acknowledge": {
651
663
  optional: [
@@ -1001,6 +1013,7 @@ const PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
1001
1013
  test: {
1002
1014
  required: ["id"],
1003
1015
  optional: [
1016
+ "list",
1004
1017
  "add",
1005
1018
  "addJson",
1006
1019
  "remove",
@@ -1110,7 +1123,7 @@ const PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
1110
1123
  ],
1111
1124
  },
1112
1125
  duplicates: {
1113
- optional: ["status", "since", "threshold", "limit"],
1126
+ optional: ["status", "since", "threshold", "limit", "exhaustive"],
1114
1127
  },
1115
1128
  health: {
1116
1129
  optional: [
@@ -1195,12 +1208,24 @@ const PM_TOOL_ACTION_SCHEMA_CONTRACTS = {
1195
1208
  required: ["preset", "owner"],
1196
1209
  },
1197
1210
  { property: "subcommand", value: "derive", required: ["owner"] },
1211
+ { property: "subcommand", value: "risk", required: ["definition"] },
1212
+ { property: "subcommand", value: "lineages", required: ["definition"] },
1198
1213
  {
1199
1214
  property: "subcommand",
1200
1215
  value: "promote",
1201
1216
  required: ["id", "enforcement"],
1202
1217
  },
1203
1218
  ],
1219
+ mutuallyExclusiveWhen: [
1220
+ [
1221
+ { property: "subcommand", schema: { const: "risk" } },
1222
+ { property: "definition", schema: { not: { required: ["policy", "change"] } } },
1223
+ ],
1224
+ [
1225
+ { property: "subcommand", schema: { const: "lineages" } },
1226
+ { property: "definition", schema: { anyOf: [{ required: ["change"] }, { not: { required: ["policy"] } }] } },
1227
+ ],
1228
+ ],
1204
1229
  },
1205
1230
  gc: { optional: ["dryRun", "gcScope"] },
1206
1231
  contracts: {
@@ -1555,14 +1580,14 @@ function createLazyContractSchema(build) {
1555
1580
  });
1556
1581
  }
1557
1582
  /** Canonical version of the action-scoped strict MCP tool-parameters schema (`PM_TOOL_PARAMETERS_SCHEMA`). Exported as the single source of truth so the MCP server, the `pm contracts` command, SDK consumers, and contract tests bind to one version constant. Bump the patch/minor for additive, backward-compatible schema changes; bump the MAJOR for breaking changes — the major also drives the `$id` `tool-parameters-v{major}` slug, so the two never drift. */
1558
- export const PM_TOOL_PARAMETERS_SCHEMA_VERSION = "4.10.1";
1583
+ export const PM_TOOL_PARAMETERS_SCHEMA_VERSION = "4.14.0";
1559
1584
  /**
1560
1585
  * Major component of {@link PM_TOOL_PARAMETERS_SCHEMA_VERSION}, used to build the
1561
1586
  * schema `$id` slug so a breaking version bump renames the document in lockstep.
1562
1587
  */
1563
1588
  export const PM_TOOL_PARAMETERS_SCHEMA_MAJOR = PM_TOOL_PARAMETERS_SCHEMA_VERSION.split(".")[0];
1564
1589
  /** Version of the provider-compatible flat tool-parameters schema (`PM_PROVIDER_TOOL_PARAMETERS_SCHEMA`). Tracked separately from the strict schema because the flat projection evolves independently. */
1565
- export const PM_PROVIDER_TOOL_PARAMETERS_SCHEMA_VERSION = "1.4.0";
1590
+ export const PM_PROVIDER_TOOL_PARAMETERS_SCHEMA_VERSION = "1.7.0";
1566
1591
  /** Public contract for pm tool parameters schema, shared by SDK and presentation-layer consumers. */
1567
1592
  export const PM_TOOL_PARAMETERS_SCHEMA = createLazyContractSchema(() => ({
1568
1593
  $schema: "https://json-schema.org/draft/2020-12/schema",
@@ -1637,4 +1662,4 @@ export const _testOnlyCliContracts = {
1637
1662
  withFlagAliasMetadata,
1638
1663
  };
1639
1664
  //# sourceMappingURL=tool-schema.js.map
1640
- //# debugId=b81a68c1-565d-56f6-a0eb-35d2c737bdb7
1665
+ //# debugId=e72f4ab4-5bf7-53fb-a3a3-174c4064f6a4
@@ -0,0 +1,41 @@
1
+ import type { ContextUsageEvent, ContextUsageLedgerOptions } from "../context-usage.js";
2
+ /** Public storage and sampling ceilings shared by every feedback producer. */
3
+ export declare const CONTEXT_USAGE_LIMITS: {
4
+ readonly max_serving_rows: 256;
5
+ readonly max_bytes: 262144;
6
+ readonly max_event_bytes: 32768;
7
+ readonly retained_byte_fraction: 0.5;
8
+ readonly max_events: 2048;
9
+ readonly retention_days: 30;
10
+ };
11
+ /** Measured persistence work for one lock-protected feedback write. */
12
+ export interface ContextUsageWriteReceipt {
13
+ /** Bytes written to the append or replacement file; excludes lock metadata. */
14
+ written_bytes: number;
15
+ /** Physical ledger size at the end of the protected write. */
16
+ ledger_bytes: number;
17
+ /** Whether this write replaced the ledger with a retained suffix. */
18
+ compacted: boolean;
19
+ /** Wall-clock time waiting to acquire the cross-process ledger lock. */
20
+ lock_wait_ms: number;
21
+ }
22
+ /** Named validation failure emitted by context-usage SDK inputs. */
23
+ export declare class ContextUsageValidationError extends TypeError {
24
+ /** Stable code for package and CLI hosts. */
25
+ readonly code = "context_usage_validation_failed";
26
+ /** Reject invalid feedback controls without exposing ledger contents. */
27
+ constructor(message: string);
28
+ }
29
+ /** Normalize one timestamp so filtering and serialization share the same clock. */
30
+ export declare function resolveNow(options: ContextUsageLedgerOptions): {
31
+ iso: string;
32
+ ms: number;
33
+ };
34
+ /** Read only a bounded file suffix, dropping a partial first JSONL row. */
35
+ export declare function readEvents(options: ContextUsageLedgerOptions): Promise<ContextUsageEvent[]>;
36
+ /**
37
+ * Append once, or compact atomically to a half-full suffix at the high-water mark.
38
+ * Requires trusted, stable workspace directory entries and ancestors; the lock
39
+ * coordinates cooperating writers and cannot constrain hostile path replacement.
40
+ */
41
+ export declare function appendEvents(options: ContextUsageLedgerOptions, events: readonly ContextUsageEvent[], deliveryServeId?: string): Promise<ContextUsageWriteReceipt>;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * @module sdk/context/usage-ledger
3
+ *
4
+ * Bounds derived feedback reads and writes in bytes. High-water compaction
5
+ * retains a half-full suffix under the same lock as append, leaving headroom
6
+ * for subsequent serves without rewriting on every context request.
7
+ */
8
+
9
+ !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]="f3af7f8f-a462-5eb4-af08-c64c3c327e62")}catch(e){}}();
10
+ import { randomUUID } from "node:crypto";
11
+ import { constants } from "node:fs";
12
+ import { lstat, mkdir, open, rename, rm } from "node:fs/promises";
13
+ import path from "node:path";
14
+ import { isFileMissingError } from "../../core/fs/fs-utils.js";
15
+ import { acquireLock } from "../../core/lock/lock.js";
16
+ /** Public storage and sampling ceilings shared by every feedback producer. */
17
+ export const CONTEXT_USAGE_LIMITS = {
18
+ max_serving_rows: 256,
19
+ max_bytes: 262_144,
20
+ max_event_bytes: 32_768,
21
+ retained_byte_fraction: 0.5,
22
+ max_events: 2_048,
23
+ retention_days: 30,
24
+ };
25
+ /** Named validation failure emitted by context-usage SDK inputs. */
26
+ export class ContextUsageValidationError extends TypeError {
27
+ /** Stable code for package and CLI hosts. */
28
+ code = "context_usage_validation_failed";
29
+ /** Reject invalid feedback controls without exposing ledger contents. */
30
+ constructor(message) {
31
+ super(message);
32
+ this.name = "ContextUsageValidationError";
33
+ }
34
+ }
35
+ /** Normalize one timestamp so filtering and serialization share the same clock. */
36
+ export function resolveNow(options) {
37
+ const ms = Date.parse(options.now ?? new Date().toISOString());
38
+ if (!Number.isFinite(ms))
39
+ throw new ContextUsageValidationError("Context usage now must be a valid timestamp");
40
+ return { iso: new Date(ms).toISOString(), ms };
41
+ }
42
+ /** Resolve checked byte, count and time bounds before touching storage. */
43
+ function bounds(options) {
44
+ const maxBytes = options.maxBytes ?? CONTEXT_USAGE_LIMITS.max_bytes;
45
+ const maxEvents = options.maxEvents ?? CONTEXT_USAGE_LIMITS.max_events;
46
+ const retentionDays = options.retentionDays ?? CONTEXT_USAGE_LIMITS.retention_days;
47
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 1024 || maxBytes > CONTEXT_USAGE_LIMITS.max_bytes ||
48
+ !Number.isSafeInteger(maxEvents) || maxEvents < 1 || !Number.isFinite(retentionDays) || retentionDays <= 0) {
49
+ throw new ContextUsageValidationError("Context usage retention requires positive maxEvents and retentionDays, and maxBytes from 1024 through 262144");
50
+ }
51
+ return { maxBytes, maxEvents, cutoff: resolveNow(options).ms - retentionDays * 86_400_000 };
52
+ }
53
+ /** Open only a private regular ledger, refusing redirected runtime directories and file links. */
54
+ async function openLedger(target, flags) {
55
+ if (!(await lstat(path.dirname(target))).isDirectory()) {
56
+ throw new ContextUsageValidationError("Context usage runtime must be a real directory");
57
+ }
58
+ try {
59
+ if ((await lstat(target)).isSymbolicLink()) {
60
+ throw new ContextUsageValidationError("Context usage ledger must not be a symbolic link");
61
+ }
62
+ }
63
+ catch (error) {
64
+ if (!isFileMissingError(error))
65
+ throw error;
66
+ }
67
+ // Unsupported platform flags contribute zero to the numeric bit mask. The
68
+ // lstat check also rejects existing links where no-follow is unavailable.
69
+ const handle = await open(target, flags | constants.O_NOFOLLOW | constants.O_NONBLOCK, 0o600);
70
+ try {
71
+ const metadata = await handle.stat();
72
+ if (!metadata.isFile() || metadata.nlink !== 1) {
73
+ throw new ContextUsageValidationError("Context usage ledger must be an unshared regular file");
74
+ }
75
+ return handle;
76
+ }
77
+ catch (error) {
78
+ await handle.close();
79
+ throw error;
80
+ }
81
+ }
82
+ /** Read only a bounded file suffix, dropping a partial first JSONL row. */
83
+ export async function readEvents(options) {
84
+ const policy = bounds(options);
85
+ try {
86
+ const handle = await openLedger(path.join(options.pmRoot, "runtime", "context-usage.jsonl"), constants.O_RDONLY);
87
+ try {
88
+ const size = (await handle.stat()).size;
89
+ const start = Math.max(0, size - policy.maxBytes);
90
+ const buffer = Buffer.alloc(Math.min(size, policy.maxBytes));
91
+ const { bytesRead } = await handle.read(buffer, 0, buffer.length, start);
92
+ const text = buffer.subarray(0, bytesRead).toString("utf8");
93
+ const lines = (start > 0 ? (text.includes("\n") ? text.slice(text.indexOf("\n") + 1) : "") : text).split("\n");
94
+ return lines.flatMap((line) => {
95
+ try {
96
+ const event = JSON.parse(line);
97
+ return event && Date.parse(event.at) >= policy.cutoff ? [event] : [];
98
+ }
99
+ catch {
100
+ return [];
101
+ }
102
+ }).slice(-policy.maxEvents);
103
+ }
104
+ finally {
105
+ await handle.close();
106
+ }
107
+ }
108
+ catch {
109
+ return [];
110
+ }
111
+ }
112
+ /** Retain a contiguous newest suffix within both byte and event-count bounds. */
113
+ function retainedText(events, byteLimit, maxEvents) {
114
+ const lines = [];
115
+ let bytes = 0;
116
+ for (let index = events.length - 1; index >= 0 && lines.length < maxEvents; index -= 1) {
117
+ const line = `${JSON.stringify(events[index])}\n`;
118
+ bytes += Buffer.byteLength(line);
119
+ if (bytes > byteLimit)
120
+ break;
121
+ lines.push(line);
122
+ }
123
+ return lines.reverse().join("");
124
+ }
125
+ /**
126
+ * Append once, or compact atomically to a half-full suffix at the high-water mark.
127
+ * Requires trusted, stable workspace directory entries and ancestors; the lock
128
+ * coordinates cooperating writers and cannot constrain hostile path replacement.
129
+ */
130
+ export async function appendEvents(options, events, deliveryServeId) {
131
+ const policy = bounds(options);
132
+ const target = path.join(options.pmRoot, "runtime", "context-usage.jsonl");
133
+ const retainedBytes = Math.floor(policy.maxBytes * CONTEXT_USAGE_LIMITS.retained_byte_fraction);
134
+ const eventLimit = Math.min(CONTEXT_USAGE_LIMITS.max_event_bytes, retainedBytes);
135
+ if (events.some((event) => Buffer.byteLength(`${JSON.stringify(event)}\n`) > eventLimit)) {
136
+ throw new ContextUsageValidationError("Context usage event exceeds the declared byte ceiling");
137
+ }
138
+ const current = events.filter((event) => Date.parse(event.at) >= policy.cutoff);
139
+ const appended = retainedText(current, retainedBytes, policy.maxEvents);
140
+ const lockStarted = performance.now();
141
+ const releaseLock = await acquireLock(options.pmRoot, "context-usage-ledger", 30, `context-usage:${process.pid}`, false, false, 3_000);
142
+ const lockWaitMs = performance.now() - lockStarted;
143
+ try {
144
+ await mkdir(path.dirname(target), { recursive: true });
145
+ let handle = await openLedger(target, constants.O_WRONLY | constants.O_CREAT | constants.O_APPEND);
146
+ try {
147
+ const size = (await handle.stat()).size;
148
+ const previous = deliveryServeId === undefined ? undefined : await readEvents(options);
149
+ if (previous?.some((event) => event.kind === "delivery" && event.serve_id === deliveryServeId)) {
150
+ return { written_bytes: 0, ledger_bytes: size, compacted: false, lock_wait_ms: lockWaitMs };
151
+ }
152
+ const customRetention = options.maxEvents !== undefined || options.retentionDays !== undefined;
153
+ if (!customRetention && size + Buffer.byteLength(appended) <= policy.maxBytes) {
154
+ await handle.writeFile(appended, "utf8");
155
+ return { written_bytes: Buffer.byteLength(appended), ledger_bytes: size + Buffer.byteLength(appended), compacted: false, lock_wait_ms: lockWaitMs };
156
+ }
157
+ const retained = retainedText([...(previous ?? await readEvents(options)), ...current], retainedBytes, policy.maxEvents);
158
+ const temporary = `${target}.${process.pid}.${randomUUID()}.tmp`;
159
+ const replacement = await open(temporary, "wx", 0o600);
160
+ try {
161
+ try {
162
+ await replacement.writeFile(retained, "utf8");
163
+ }
164
+ finally {
165
+ await replacement.close();
166
+ }
167
+ // Windows cannot replace the destination while our append handle is open.
168
+ await handle.close();
169
+ handle = undefined;
170
+ await rename(temporary, target);
171
+ return { written_bytes: Buffer.byteLength(retained), ledger_bytes: Buffer.byteLength(retained), compacted: true, lock_wait_ms: lockWaitMs };
172
+ }
173
+ finally {
174
+ await rm(temporary, { force: true });
175
+ }
176
+ }
177
+ finally {
178
+ await handle?.close();
179
+ }
180
+ }
181
+ finally {
182
+ await releaseLock();
183
+ }
184
+ }
185
+ //# sourceMappingURL=usage-ledger.js.map
186
+ //# debugId=f3af7f8f-a462-5eb4-af08-c64c3c327e62
@@ -5,7 +5,7 @@
5
5
  * workspace configuration, and packages.
6
6
  */
7
7
 
8
- !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]="5dc9c6e4-6db8-560f-a87f-368132e2ffb3")}catch(e){}}();
8
+ !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]="d6fc4c70-c955-5fb5-ab4b-5dfa1200d58d")}catch(e){}}();
9
9
  import { AsyncLocalStorage } from "node:async_hooks";
10
10
  import { renderPmCommand } from "./command-line.js";
11
11
  import { attachOutputOmissionReceipt } from "./output-projection.js";
@@ -410,7 +410,7 @@ const CONTEXT_INTENT_ROW_KEYS = {
410
410
  ],
411
411
  get: ["children"],
412
412
  list: ["items"],
413
- next: ["ready", "decision_needed", "blocked", "held_by_others"],
413
+ next: ["ready", "decision_needed", "gate_needed", "containers", "blocked", "held_by_others"],
414
414
  search: ["items"],
415
415
  };
416
416
  /** Decode the cursor fields required to preserve a row-compacted continuation. */
@@ -707,4 +707,4 @@ export function attachReadOutputContracts(command, options, result) {
707
707
  return suppressed;
708
708
  }
709
709
  //# sourceMappingURL=context-intent-contracts.js.map
710
- //# debugId=5dc9c6e4-6db8-560f-a87f-368132e2ffb3
710
+ //# debugId=d6fc4c70-c955-5fb5-ab4b-5dfa1200d58d
@@ -1,3 +1,5 @@
1
+ import { type ContextUsageWriteReceipt } from "./context/usage-ledger.js";
2
+ export { ContextUsageValidationError, CONTEXT_USAGE_LIMITS, type ContextUsageWriteReceipt } from "./context/usage-ledger.js";
1
3
  import type { ContextRelevanceSurface } from "./context-relevance.js";
2
4
  /** One propensity row disclosed when context or next serves a candidate. */
3
5
  export interface ContextUsageServingRow {
@@ -18,6 +20,10 @@ export interface ContextUsageServingReceipt {
18
20
  surface: ContextRelevanceSurface;
19
21
  /** Propensity-complete ranked rows assembled before egress. */
20
22
  rows: readonly ContextUsageServingRow[];
23
+ /** Persisted sample identities; absent on legacy unsampled receipts. */
24
+ recorded_item_ids?: readonly string[];
25
+ /** Measured bounded persistence; absent on legacy receipts. */
26
+ storage?: ContextUsageWriteReceipt;
21
27
  }
22
28
  /** Append-only serving or subsequent-touch event. */
23
29
  export type ContextUsageEvent = {
@@ -29,6 +35,10 @@ export type ContextUsageEvent = {
29
35
  surface: ContextRelevanceSurface;
30
36
  profile: string;
31
37
  rows: ContextUsageServingRow[];
38
+ /** Full candidate population before deterministic prefix sampling. */
39
+ candidate_count?: number;
40
+ /** Candidate rows excluded from this bounded feedback sample. */
41
+ omitted_row_count?: number;
32
42
  result_omitted?: boolean;
33
43
  packed_item_ids?: string[];
34
44
  /** Legacy pre-egress field ignored by the v2 affinity fold. */
@@ -51,12 +61,18 @@ export type ContextUsageEvent = {
51
61
  };
52
62
  /** Runtime controls for the bounded derived ledger. */
53
63
  export interface ContextUsageLedgerOptions {
54
- /** Tracker root containing the runtime directory. */
64
+ /**
65
+ * Tracker root containing the runtime directory. Its directory entries and
66
+ * ancestors must remain controlled by trusted cooperating processes during
67
+ * ledger operations; hostile concurrent path replacement is unsupported.
68
+ */
55
69
  pmRoot: string;
56
70
  /** Disable all reads and writes with zero filesystem work. */
57
71
  enabled?: boolean;
58
72
  /** Maximum retained event rows. */
59
73
  maxEvents?: number;
74
+ /** Physical byte ceiling; compaction retains at most half to provide headroom. */
75
+ maxBytes?: number;
60
76
  /** Retention horizon in days. */
61
77
  retentionDays?: number;
62
78
  /** Deterministic timestamp override. */
@@ -90,14 +106,7 @@ export declare function finalizeContextUsageDelivery(options: {
90
106
  /** Final projected response returned or rendered to the caller. */
91
107
  result: unknown;
92
108
  }): Promise<boolean>;
93
- /** Named validation failure emitted by context-usage SDK inputs. */
94
- export declare class ContextUsageValidationError extends TypeError {
95
- /** Stable machine-readable error code for package and CLI hosts. */
96
- readonly code = "context_usage_validation_failed";
97
- /** Creates a typed validation error without exposing derived ledger contents. */
98
- constructor(message: string);
99
- }
100
- /** Records a propensity-complete context/next serving event. */
109
+ /** Records a bounded prefix of ranked context candidates with explicit sampling counts. */
101
110
  export declare function recordContextUsageServing(options: ContextUsageLedgerOptions & {
102
111
  author: string;
103
112
  surface: ContextRelevanceSurface;