@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
@@ -267,6 +267,15 @@ interface ContextAgendaSummary {
267
267
  scheduled: number;
268
268
  }
269
269
  interface ContextSummary {
270
+ /** Population counters honor item filters and parent scope, never output limits. */
271
+ scope?: "matching_items";
272
+ /** Counts for the bounded focus selection, separate from the matching population. */
273
+ returned_focus?: {
274
+ active_items: number;
275
+ in_progress: number;
276
+ open: number;
277
+ blocked: number;
278
+ };
270
279
  active_items: number;
271
280
  in_progress: number;
272
281
  open: number;
@@ -4,9 +4,10 @@
4
4
  * Implements the pm context command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !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]="56205e5f-fc26-59ab-abdf-45bdcaf1c263")}catch(e){}}();
8
- import { SETTINGS_DEFAULTS, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, isTerminalStatus, normalizeStatusForRegistry, normalizeStatusInput, resolveRuntimeStatusRegistry, resolvePmRoot, readSettings, resolveAuthor, discoverExtensions, } from "../runtime-primitives.js";
9
- import { collectDependencyBlockedIds, resolveItemBlockers, } from "../actionability.js";
7
+ !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]="4f8e82a2-f4ea-5ecb-8ef5-3ca795cdeda5")}catch(e){}}();
8
+ import { SETTINGS_DEFAULTS, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, isTerminalStatus, normalizeStatusForRegistry, normalizeStatusInput, resolveRuntimeStatusRegistry, resolvePmRoot, readSettings, resolveAuthor, discoverExtensions, resolveItemTypeRegistry, } from "../runtime-primitives.js";
9
+ import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
10
+ import { collectDependencyBlockedIds, resolveItemBlockers, resolveItemExecutionRole, computeActionabilityReport, } from "../actionability.js";
10
11
  import { CONTEXT_DEPTH_VALUES, CONTEXT_SECTION_VALUES, } from "../../types/index.js";
11
12
  import { parseIntegerLimit } from "./parsers.js";
12
13
  import { runCalendar, } from "./calendar.js";
@@ -1201,7 +1202,6 @@ function buildUnpaginatedContextListOptions(baseListOptions, extra) {
1201
1202
  };
1202
1203
  }
1203
1204
  async function loadContextCorpus(global, runtime) {
1204
- const needsAllItems = contextNeedsAllItems(runtime.sectionsIncluded);
1205
1205
  // One full-corpus scan serves every consumer: runList always reads all item
1206
1206
  // files before filtering, so deriving the non-terminal subset in memory is
1207
1207
  // free and keeps terminal blocker targets available for the shared
@@ -1211,9 +1211,7 @@ async function loadContextCorpus(global, runtime) {
1211
1211
  }), global);
1212
1212
  const fullCorpus = listed.items;
1213
1213
  let listedItemMetadata = fullCorpus.filter((item) => !isTerminalStatus(item.status, runtime.statusRegistry));
1214
- let allItems = needsAllItems || runtime.parentScope !== undefined
1215
- ? fullCorpus
1216
- : listedItemMetadata;
1214
+ let allItems = fullCorpus;
1217
1215
  const subtreeIds = resolveContextSubtreeIds(runtime.parentScope, fullCorpus);
1218
1216
  if (subtreeIds) {
1219
1217
  listedItemMetadata = listedItemMetadata.filter((item) => subtreeIds.has(item.id.trim().toLowerCase()));
@@ -1231,7 +1229,14 @@ function resolveContextSubtreeIds(parentScope, fullCorpus) {
1231
1229
  }
1232
1230
  return subtree.ids;
1233
1231
  }
1234
- async function resolveContextFocusGroups(listedItemMetadata, allItems, fullCorpus, blockedIds, statusRegistry, sectionsIncluded, limit, now, author, cursor, cursorFingerprint, useBoundedPage, pmRoot, tokenBudget, claimFocus) {
1232
+ /** Classify strategic and human-directed context through the shared execution rules. */
1233
+ function collectHighLevelContextIds(activeItems, fullCorpus, statusRegistry, typeRegistry) {
1234
+ const containers = new Set(computeActionabilityReport(activeItems, fullCorpus, statusRegistry, typeRegistry)
1235
+ .containers.map((entry) => entry.item.id));
1236
+ return new Set(activeItems.filter((item) => HIGH_LEVEL_TYPES.has(item.type) || containers.has(item.id) ||
1237
+ resolveItemExecutionRole(item.type, typeRegistry) !== "agent").map((item) => item.id));
1238
+ }
1239
+ async function resolveContextFocusGroups(listedItemMetadata, allItems, fullCorpus, blockedIds, statusRegistry, sectionsIncluded, limit, now, author, cursor, cursorFingerprint, useBoundedPage, pmRoot, tokenBudget, claimFocus, typeRegistry) {
1235
1240
  const structural = [...listedItemMetadata].sort((left, right) => compareCriticalItems(left, right, statusRegistry));
1236
1241
  const usage = await readContextUsageAffinity({
1237
1242
  pmRoot,
@@ -1293,12 +1298,13 @@ async function resolveContextFocusGroups(listedItemMetadata, allItems, fullCorpu
1293
1298
  .map((blocker) => blocker.id);
1294
1299
  return focus;
1295
1300
  };
1301
+ const highLevelIds = collectHighLevelContextIds(activeItems, fullCorpus, statusRegistry, typeRegistry);
1296
1302
  const highLevel = activeItems
1297
- .filter((item) => HIGH_LEVEL_TYPES.has(item.type))
1303
+ .filter((item) => highLevelIds.has(item.id))
1298
1304
  .slice(0, useBoundedPage ? focusPage.length : limit)
1299
1305
  .map(projectFocusItem);
1300
1306
  const lowLevel = activeItems
1301
- .filter((item) => !HIGH_LEVEL_TYPES.has(item.type))
1307
+ .filter((item) => !highLevelIds.has(item.id))
1302
1308
  .slice(0, useBoundedPage ? focusPage.length : limit)
1303
1309
  .map(projectFocusItem);
1304
1310
  const blockedFallbackUsed = rankedActiveItems.length === 0;
@@ -1409,12 +1415,16 @@ async function buildOptionalContextSections(params) {
1409
1415
  tests: has("tests") ? buildTestHealth(focusGroups.activeItems) : undefined,
1410
1416
  };
1411
1417
  }
1412
- function buildContextSummaryExtras(needsAllItems, allItems, statusRegistry) {
1413
- if (!needsAllItems) {
1414
- return {};
1415
- }
1418
+ function buildContextSummaryExtras(allItems, statusRegistry, blockedIds) {
1416
1419
  const canceledStatus = normalizeStatusInput("canceled", statusRegistry);
1420
+ const activeItems = allItems.filter((item) => statusRegistry.active_statuses.has(normalizeStatusForRegistry(item.status, statusRegistry)));
1421
+ const inProgress = countContextStatus(activeItems, statusRegistry.in_progress_status, statusRegistry);
1417
1422
  return {
1423
+ scope: "matching_items",
1424
+ active_items: activeItems.length,
1425
+ open: activeItems.length - inProgress,
1426
+ in_progress: inProgress,
1427
+ blocked: allItems.filter((item) => blockedIds.has(item.id.trim().toLowerCase())).length,
1418
1428
  total_items: allItems.length,
1419
1429
  closed: allItems.filter((item) => isClosedStatus(item.status, statusRegistry)).length,
1420
1430
  canceled: allItems.filter((item) => normalizeStatusForRegistry(item.status, statusRegistry) ===
@@ -1595,7 +1605,7 @@ export async function runContext(options, global) {
1595
1605
  // Single shared edge-aware blocked classification (GH-578): resolved against
1596
1606
  // the full corpus so terminal blocker targets count as satisfied at every depth.
1597
1607
  const blockedIds = collectDependencyBlockedIds(corpus.fullCorpus, runtime.statusRegistry);
1598
- const focusGroups = await resolveContextFocusGroups(corpus.listedItemMetadata, corpus.allItems, corpus.fullCorpus, blockedIds, runtime.statusRegistry, runtime.sectionsIncluded, runtime.limit, nowIso(), author, options.after, buildContextCursorFingerprint(options), shouldPageContextFocus(options, corpus.fullCorpus.length), pmRoot, runtime.tokenBudget, claimFocus);
1608
+ const focusGroups = await resolveContextFocusGroups(corpus.listedItemMetadata, corpus.allItems, corpus.fullCorpus, blockedIds, runtime.statusRegistry, runtime.sectionsIncluded, runtime.limit, nowIso(), author, options.after, buildContextCursorFingerprint(options), shouldPageContextFocus(options, corpus.fullCorpus.length), pmRoot, runtime.tokenBudget, claimFocus, resolveItemTypeRegistry(runtime.settings, getActiveExtensionRegistrations()));
1599
1609
  const agendaContext = await buildContextAgenda(global, runtime, corpus.subtreeIds, new Set([
1600
1610
  ...focusGroups.highLevel,
1601
1611
  ...focusGroups.lowLevel,
@@ -1618,7 +1628,7 @@ export async function runContext(options, global) {
1618
1628
  now: agendaContext.agenda.now,
1619
1629
  global,
1620
1630
  });
1621
- const summaryExtras = buildContextSummaryExtras(contextNeedsAllItems(runtime.sectionsIncluded), corpus.allItems, runtime.statusRegistry);
1631
+ const summaryExtras = buildContextSummaryExtras(corpus.allItems, runtime.statusRegistry, blockedIds);
1622
1632
  const result = {
1623
1633
  output_default: "toon",
1624
1634
  now: agendaContext.agenda.now,
@@ -1649,10 +1659,12 @@ export async function runContext(options, global) {
1649
1659
  {}),
1650
1660
  },
1651
1661
  summary: {
1652
- active_items: focusGroups.activeItems.length,
1653
- in_progress: inProgressCount,
1654
- open: openCount,
1655
- blocked: focusGroups.blockedItems.length,
1662
+ returned_focus: {
1663
+ active_items: focusGroups.activeItems.length,
1664
+ in_progress: inProgressCount,
1665
+ open: openCount,
1666
+ blocked: focusGroups.blockedItems.length,
1667
+ },
1656
1668
  blocked_fallback_used: focusGroups.blockedFallbackUsed,
1657
1669
  high_level: focusGroups.highLevel.length,
1658
1670
  low_level: focusGroups.lowLevel.length,
@@ -1688,4 +1700,4 @@ export async function runContext(options, global) {
1688
1700
  return result;
1689
1701
  }
1690
1702
  //# sourceMappingURL=context.js.map
1691
- //# debugId=56205e5f-fc26-59ab-abdf-45bdcaf1c263
1703
+ //# debugId=4f8e82a2-f4ea-5ecb-8ef5-3ca795cdeda5
@@ -0,0 +1,7 @@
1
+ import type { PreparedSimilarityText } from "../similarity-scoring.js";
2
+ /** Declared safety bound applies to retained pairs, never silently to recall. */
3
+ export declare const MAX_DUPLICATE_CANDIDATE_PAIRS = 1000000;
4
+ /** Generate every potentially qualifying pair once, with an explicit exhaustive oracle. */
5
+ export declare function collectDuplicateCandidatePairs(items: readonly {
6
+ prepared: PreparedSimilarityText;
7
+ }[], maxPairs?: number, threshold?: number, exhaustive?: boolean): Set<string>;
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @module sdk/query/duplicate-candidates
3
+ *
4
+ * Lossless prefix filtering for Jaccard joins. A globally ordered prefix of
5
+ * length n-ceil(threshold*n)+1 must intersect the corresponding prefix of
6
+ * every qualifying set. Exact titles and issue codes remain independent
7
+ * signals, including titles with no word tokens.
8
+ */
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]="d425cf45-5b62-5613-a5ce-78da6b0e201b")}catch(e){}}();
11
+ import { EXIT_CODE } from "../../core/shared/constants.js";
12
+ import { PmCliError } from "../../core/shared/errors.js";
13
+ /** Declared safety bound applies to retained pairs, never silently to recall. */
14
+ export const MAX_DUPLICATE_CANDIDATE_PAIRS = 1_000_000;
15
+ /** Generate every potentially qualifying pair once, with an explicit exhaustive oracle. */
16
+ export function collectDuplicateCandidatePairs(items, maxPairs = MAX_DUPLICATE_CANDIDATE_PAIRS, threshold = 0.8, exhaustive = false) {
17
+ const candidates = new Set();
18
+ /** Deduplicate a candidate pair and refuse before publishing an over-budget result. */
19
+ const add = (left, right) => {
20
+ candidates.add(`${left}:${right}`);
21
+ if (candidates.size > maxPairs) {
22
+ throw new PmCliError(`Duplicate sweep exceeded ${maxPairs} candidate pairs; narrow it with statuses or since.`, EXIT_CODE.CONFLICT, { code: "duplicate_sweep_cost_limit", required: "Narrow the duplicate query or increase its similarity threshold. No partial result was returned." });
23
+ }
24
+ };
25
+ if (exhaustive || threshold === 0) {
26
+ for (let right = 0; right < items.length; right += 1) {
27
+ for (let left = 0; left < right; left += 1)
28
+ add(left, right);
29
+ }
30
+ return candidates;
31
+ }
32
+ const frequencies = new Map();
33
+ for (const { prepared } of items) {
34
+ for (const token of prepared.tokens)
35
+ frequencies.set(token, (frequencies.get(token) ?? 0) + 1);
36
+ }
37
+ const exact = new Map();
38
+ const codes = new Map();
39
+ const prefixes = new Map();
40
+ for (const [right, { prepared }] of items.entries()) {
41
+ const tokens = [...prepared.tokens].sort((left, other) => frequencies.get(left) - frequencies.get(other) || left.localeCompare(other));
42
+ // An epsilon expands rather than shrinks the prefix at floating boundaries.
43
+ const prefixLength = tokens.length - Math.ceil(threshold * tokens.length - 1e-12) + 1;
44
+ const signals = [
45
+ { index: exact, keys: [prepared.normalized], lengthFilter: false },
46
+ { index: codes, keys: threshold <= 0.99 ? prepared.issueCodes : [], lengthFilter: false },
47
+ { index: prefixes, keys: tokens.length === 0 ? [""] : tokens.slice(0, prefixLength), lengthFilter: true },
48
+ ];
49
+ for (const signal of signals) {
50
+ appendPostingCandidates(items, right, signal, threshold, add);
51
+ }
52
+ }
53
+ return candidates;
54
+ }
55
+ /** Join one exact/code/prefix posting list, applying the Jaccard length bound only to tokens. */
56
+ function appendPostingCandidates(items, right, signal, threshold, add) {
57
+ const rightLength = items[right].prepared.tokens.length;
58
+ for (const key of signal.keys) {
59
+ const posting = signal.index.get(key) ?? [];
60
+ for (const left of posting) {
61
+ const leftLength = items[left].prepared.tokens.length;
62
+ if (signal.lengthFilter && Math.min(leftLength, rightLength) / Math.max(leftLength, rightLength) + 1e-12 < threshold)
63
+ continue;
64
+ add(left, right);
65
+ }
66
+ posting.push(right);
67
+ signal.index.set(key, posting);
68
+ }
69
+ }
70
+ //# sourceMappingURL=duplicate-candidates.js.map
71
+ //# debugId=d425cf45-5b62-5613-a5ce-78da6b0e201b
@@ -52,8 +52,8 @@ export interface GetResult {
52
52
  schedule?: Partial<ItemScheduleContext>;
53
53
  /** True when the item was reconstructed from immutable history. */
54
54
  reconstructed?: true;
55
- /** One-based history version represented by a reconstructed read. */
56
- as_of_version?: number;
55
+ /** Durable version, or null when legacy compaction lost the numeric mapping. */
56
+ as_of_version?: number | null;
57
57
  /** Timestamp of the last history entry included in a reconstructed read. */
58
58
  as_of_timestamp?: string;
59
59
  /** Value that configures or reports tree for this contract. */
@@ -4,7 +4,7 @@
4
4
  * Implements the SDK-owned item query shared by every surface.
5
5
  */
6
6
 
7
- !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]="ff82974e-a48d-5d18-893f-fb618e378795")}catch(e){}}();
7
+ !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]="88732a1d-ae5a-5dfb-93d6-9659cb6f05c3")}catch(e){}}();
8
8
  import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
9
  import { getActiveExtensionRegistrations, toItemRecord, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, TYPE_TO_FOLDER, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, readLocatedItem, getHistoryPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
10
  import { readHistoryEntries } from "../history-read.js";
@@ -310,6 +310,7 @@ function shouldIncludeGetField(params) {
310
310
  }
311
311
  return depth !== "brief";
312
312
  }
313
+ /** Derive claim evidence from the selected physical history prefix, excluding future claims. */
313
314
  async function resolveGetClaimState(context, includeClaimState) {
314
315
  if (!includeClaimState) {
315
316
  return undefined;
@@ -317,7 +318,7 @@ async function resolveGetClaimState(context, includeClaimState) {
317
318
  const historyPath = getHistoryPath(context.pmRoot, context.locatedId);
318
319
  const history = await readHistoryEntries(historyPath, context.locatedId);
319
320
  return resolveClaimStateContext(context.metadata.assignee, context.historical
320
- ? history.slice(0, context.historical.as_of_version)
321
+ ? history.slice(0, context.historical.target.historyIndex + 1)
321
322
  : history);
322
323
  }
323
324
  function attachGetLinked(result, context, fields, includeLinked) {
@@ -336,14 +337,14 @@ function attachGetLinked(result, context, fields, includeLinked) {
336
337
  docs: includeLinkedDocs ? (context.metadata.docs ?? []) : [],
337
338
  };
338
339
  }
339
- async function buildGetChildrenRollup(context, includeChildren, includeEmpty, includeSample) {
340
+ /** Enumerate hierarchy metadata only when the caller explicitly requested a child rollup. */
341
+ async function buildGetChildrenRollup(context, includeChildren) {
340
342
  if (!includeChildren) {
341
343
  return undefined;
342
344
  }
343
345
  const statusRegistry = resolveRuntimeStatusRegistry(context.settings.schema);
344
346
  const corpus = await listAllItemMetadataLight(context.pmRoot, context.settings.item_format, context.typeToFolder, undefined, context.settings.schema);
345
- const rollup = buildItemChildrenRollup(context.locatedId, corpus, statusRegistry, includeSample ? undefined : 0);
346
- return rollup.count > 0 || includeEmpty ? rollup : undefined;
347
+ return buildItemChildrenRollup(context.locatedId, corpus, statusRegistry);
347
348
  }
348
349
  function attachGetSchedule(result, context, fields, includeSchedule) {
349
350
  if (!includeSchedule) {
@@ -394,7 +395,7 @@ export async function runGet(id, global, options = {}) {
394
395
  const includeChildren = context.historical === undefined &&
395
396
  (projection.fieldProjection
396
397
  ? fieldsIncludeRoot(projection.fields, "children")
397
- : projection.depth !== "brief" &&
398
+ : projection.depth === "deep" &&
398
399
  shouldAutoIncludeGetChildren(context.metadata.type));
399
400
  const includeSchedule = projection.fieldProjection
400
401
  ? fieldsIncludeRoot(projection.fields, "schedule")
@@ -413,7 +414,7 @@ export async function runGet(id, global, options = {}) {
413
414
  result.claim_state = claimState;
414
415
  }
415
416
  attachGetSchedule(result, context, projection.fields, includeSchedule);
416
- const children = await buildGetChildrenRollup(context, includeChildren, projection.fieldProjection, projection.fieldProjection || projection.depth === "deep");
417
+ const children = await buildGetChildrenRollup(context, includeChildren);
417
418
  if (children !== undefined) {
418
419
  result.children = children;
419
420
  }
@@ -447,4 +448,4 @@ export const _testOnlyGetCommand = {
447
448
  shouldAutoIncludeGetChildren,
448
449
  };
449
450
  //# sourceMappingURL=get.js.map
450
- //# debugId=ff82974e-a48d-5d18-893f-fb618e378795
451
+ //# debugId=88732a1d-ae5a-5dfb-93d6-9659cb6f05c3
@@ -32,6 +32,8 @@ export interface HistoryCommandOptions {
32
32
  export interface HistoryDiffEntry {
33
33
  /** Value that configures or reports index for this contract. */
34
34
  index: number;
35
+ /** Durable version address after compaction; null for unmapped legacy checkpoints. */
36
+ version?: number | null;
35
37
  /** Value that configures or reports ts for this contract. */
36
38
  ts: string;
37
39
  /** Value that configures or reports op for this contract. */
@@ -74,6 +76,15 @@ export interface HistoryResult {
74
76
  verification?: HistoryVerificationResult;
75
77
  /** Constant-size provenance completeness metrics. */
76
78
  provenance_summary?: HistoryProvenanceSummary;
79
+ /** Present after compaction; row indices remain physical stream positions. */
80
+ version_addressing?: {
81
+ /** Add to a physical one-based index; null when the original mapping is lost. */
82
+ offset: number | null;
83
+ /** Earliest reconstructable original version, or null for legacy checkpoints. */
84
+ first_version: number | null;
85
+ /** Latest addressable version, including maintenance audit events. */
86
+ last_version: number | null;
87
+ };
77
88
  }
78
89
  /** Implements run history for the public runtime surface of this module. */
79
90
  export declare function runHistory(id: string, options: HistoryCommandOptions, global: GlobalOptions): Promise<HistoryResult>;
@@ -4,8 +4,9 @@
4
4
  * Implements the pm history command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !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]="314adea1-6837-5eeb-abc3-57337a495221")}catch(e){}}();
7
+ !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]="13e944b0-f049-55e5-8ff8-6335ce888b65")}catch(e){}}();
8
8
  import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { historyVersionOffset } from "../../core/history/version-address.js";
9
10
  import { pathExists, computeHistoryDiff, patchPathToChangedField, normalizeReplayPatchOps, verifyHistoryChain, enforceHistoryStreamPolicyForItem, EXIT_CODE, PmCliError, getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, locateItem, readLocatedItem, getHistoryPath, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, resolvePmRoot, readSettings, WORKSPACE_HISTORY_ID, } from "../runtime-primitives.js";
10
11
  import { readHistoryEntries, verifyHistoryEntries, } from "../history-read.js";
11
12
  export { readHistoryEntries } from "../history-read.js";
@@ -18,8 +19,9 @@ function limitEntries(values, limit) {
18
19
  return values;
19
20
  return values.slice(Math.max(0, values.length - limit));
20
21
  }
21
- function buildDiffEntries(entries, startIndex) {
22
- return entries.map((entry, index) => {
22
+ /** Summarize patch fields with physical indices and separately mapped durable versions. */
23
+ function buildDiffEntries(entries, addressing) {
24
+ return entries.map(({ entry, version }) => {
23
25
  const changedFields = new Set();
24
26
  const patch = normalizeReplayPatchOps(entry.patch);
25
27
  for (const op of patch) {
@@ -29,7 +31,8 @@ function buildDiffEntries(entries, startIndex) {
29
31
  }
30
32
  }
31
33
  return {
32
- index: startIndex + index + 1,
34
+ index: version,
35
+ ...(addressing ? { version: addressing.offset === null ? null : addressing.offset + version } : {}),
33
36
  ts: entry.ts,
34
37
  op: entry.op,
35
38
  author: entry.author,
@@ -38,6 +41,17 @@ function buildDiffEntries(entries, startIndex) {
38
41
  };
39
42
  });
40
43
  }
44
+ /** Describe the checkpoint mapping without changing physical diagnostic indices. */
45
+ function buildVersionAddressing(history) {
46
+ if (history[0]?.op !== "history_compact_baseline")
47
+ return undefined;
48
+ const offset = historyVersionOffset(history, true);
49
+ return {
50
+ offset,
51
+ first_version: offset === null ? null : offset + 1,
52
+ last_version: offset === null ? null : offset + history.length,
53
+ };
54
+ }
41
55
  async function resolveHistoryReadTarget(id, global) {
42
56
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
43
57
  await assertInitializedTracker(pmRoot);
@@ -71,6 +85,7 @@ export async function runHistory(id, options, global) {
71
85
  const limit = parseLimit(options.limit);
72
86
  const { historyPath, located, resolvedId, settings } = await resolveHistoryReadTarget(id, global);
73
87
  const fullHistory = await readHistoryEntries(historyPath, resolvedId);
88
+ const addressing = buildVersionAddressing(fullHistory);
74
89
  const vocabulary = settings.agent_identity.identity_vocabulary;
75
90
  const provenanceDimensions = resolveHistoryProvenanceDimensions(settings.agent_identity.harness_signals);
76
91
  const matchesProvenance = compileHistoryProvenanceMatcher({
@@ -78,19 +93,18 @@ export async function runHistory(id, options, global) {
78
93
  agentInstance: options.agentInstance,
79
94
  provenance: options.provenanceFilter,
80
95
  }, vocabulary, provenanceDimensions);
81
- const filteredHistory = fullHistory
82
- .map((entry, index) => ({ entry, version: index + 1 }))
96
+ const filteredHistory = indexHistoryEntries(fullHistory)
83
97
  .filter(({ entry }) => matchesProvenance(entry));
84
98
  const selectedHistory = limitEntries(filteredHistory, limit);
85
99
  const history = selectedHistory.map(({ entry }) => entry);
86
100
  const compact = options.compact === true;
87
101
  const compactHistory = compact
88
- ? buildDiffEntries(history, Math.max(0, fullHistory.length - history.length))
102
+ ? buildDiffEntries(selectedHistory, addressing)
89
103
  : undefined;
90
104
  const provenanceHistory = options.provenance === true
91
- ? selectedHistory.map(({ entry, version }) => projectHistoryProvenance(entry, vocabulary, {
105
+ ? selectedHistory.map(({ entry, durableVersion }) => projectHistoryProvenance(entry, vocabulary, {
92
106
  itemId: resolvedId,
93
- version,
107
+ version: durableVersion,
94
108
  }))
95
109
  : undefined;
96
110
  const projectionMode = options.provenance === true ? "provenance" : compact ? "compact" : "full";
@@ -115,6 +129,7 @@ export async function runHistory(id, options, global) {
115
129
  omission_receipt: resolveModePairedOutputOmissionReceipt("history", projectionMode),
116
130
  count: history.length,
117
131
  limit: limit ?? null,
132
+ version_addressing: addressing,
118
133
  ...(options.provenanceSummary === true
119
134
  ? {
120
135
  provenance_summary: summarizeHistoryProvenance(filteredHistory.map(({ entry }) => entry), vocabulary, provenanceDimensions),
@@ -159,5 +174,14 @@ export async function runHistory(id, options, global) {
159
174
  }
160
175
  return result;
161
176
  }
177
+ /** Attach physical and durable coordinates before filtering or limiting the stream. */
178
+ function indexHistoryEntries(history) {
179
+ const offset = historyVersionOffset(history, true);
180
+ return history.map((entry, index) => ({
181
+ entry,
182
+ version: index + 1,
183
+ durableVersion: offset === null ? undefined : offset + index + 1,
184
+ }));
185
+ }
162
186
  //# sourceMappingURL=history.js.map
163
- //# debugId=314adea1-6837-5eeb-abc3-57337a495221
187
+ //# debugId=13e944b0-f049-55e5-8ff8-6335ce888b65
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import { type ActionableEntry } from "../actionability.js";
12
12
  import { type GlobalOptions } from "../runtime-primitives.js";
13
+ import type { ItemTypeRegistry } from "../../core/item/type-registry.js";
13
14
  import type { ItemStatus } from "../../types/index.js";
14
15
  import { type ContextFocusItem, type ContextRankingSummary, type ContextPackingSummary } from "./context.js";
15
16
  /** Supported values accepted by the next output contract. */
@@ -48,6 +49,10 @@ export interface NextOptions {
48
49
  tokenBudget?: string | number;
49
50
  /** Include human-gated Decision items in the claimable ready queue. */
50
51
  includeDecisions?: boolean;
52
+ /** Opt into gate-shaped leaf work; blockers and ownership restrictions still apply. */
53
+ includeGates?: boolean;
54
+ /** Opt into containers with unfinished descendants; blockers and ownership restrictions still apply. */
55
+ includeContainers?: boolean;
51
56
  /** Internal caller override used to align claim-next ranking with --author. */
52
57
  callerAuthor?: string;
53
58
  [key: string]: unknown;
@@ -95,6 +100,7 @@ interface NextSummary {
95
100
  candidates: number;
96
101
  containers: number;
97
102
  decision_needed: number;
103
+ gate_needed?: number;
98
104
  held_by_others: number;
99
105
  }
100
106
  /** Documents the `pm next` result payload exchanged by command, SDK, and package integrations. */
@@ -109,6 +115,10 @@ export interface NextResult {
109
115
  ready: NextActionableItem[];
110
116
  /** Human-gated decisions kept visible without dispatching them to agents. */
111
117
  decision_needed: NextActionableItem[];
118
+ /** Outcome gates held out of autonomous dispatch. */
119
+ gate_needed?: NextActionableItem[];
120
+ /** Containers with unfinished descendants, retained as readable worklists. */
121
+ containers?: NextActionableItem[];
112
122
  /** Value that configures or reports blocked for this contract. */
113
123
  blocked: NextActionableItem[];
114
124
  /** Value that configures or reports held by others for this contract. */
@@ -132,6 +142,8 @@ export interface NextResult {
132
142
  blocked_limit: number;
133
143
  ready_only: boolean;
134
144
  include_decisions: boolean;
145
+ include_gates?: boolean;
146
+ include_containers?: boolean;
135
147
  token_budget: number;
136
148
  };
137
149
  /** Value that configures or reports suggestions for this contract. */
@@ -146,6 +158,8 @@ export interface NextResult {
146
158
  truncation?: {
147
159
  decision_needed_total?: number;
148
160
  held_by_others_total?: number;
161
+ gate_needed_total?: number;
162
+ containers_total?: number;
149
163
  };
150
164
  }
151
165
  /** Resolves the effective `pm next` output format from the command `--format` flag and the global `--json` switch, rejecting the contradictory `--json --format markdown|toon` combination. Defaults to `toon`. */
@@ -163,7 +177,7 @@ export declare const _testOnlyNextCommand: {
163
177
  resolveNextCallerAuthor: (options: NextOptions, settingsAuthor: string) => string;
164
178
  };
165
179
  /** Separates human-gated decisions from autonomous agent work unless the caller explicitly opts into decision claims. */
166
- export declare function partitionDecisionEntries(ready: ActionableEntry[], includeDecisions: boolean): {
180
+ export declare function partitionDecisionEntries(ready: ActionableEntry[], includeDecisions: boolean, typeRegistry?: ItemTypeRegistry): {
167
181
  agent: ActionableEntry[];
168
182
  decisions: ActionableEntry[];
169
183
  };