@unbrained/pm-cli 2026.9.3 → 2026.9.5

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 (228) 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 +52 -0
  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 +15 -6
  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 +6 -2
  21. package/dist/cli-bundle/bundle-manifest.json +154 -154
  22. package/dist/cli-bundle/chunks/{chunk-EDPIS7EB.js → chunk-3HBDTJRK.js} +2 -2
  23. package/dist/cli-bundle/chunks/chunk-66VPKFP2.js +5 -0
  24. package/dist/cli-bundle/chunks/{chunk-Y4PJ6HPK.js → chunk-HUAQITVW.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-DKGP3QLE.js → chunk-IBYREGSP.js} +2 -2
  26. package/dist/cli-bundle/chunks/chunk-LUI4E32I.js +231 -0
  27. package/dist/cli-bundle/chunks/{chunk-UPPM2FOZ.js → chunk-QPZHQY2O.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-34HASX3S.js → chunk-SF6SM6U5.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-SVK5Y64D.js +40 -0
  30. package/dist/cli-bundle/chunks/chunk-V5GBD5KV.js +9 -0
  31. package/dist/cli-bundle/chunks/{chunk-LENC656S.js → chunk-WWAEGW4V.js} +67 -70
  32. package/dist/cli-bundle/chunks/chunk-ZRAQS3UA.js +8 -0
  33. package/dist/cli-bundle/chunks/{register-list-query-W2ZTOMKP.js → register-list-query-AYKGODWT.js} +3 -3
  34. package/dist/cli-bundle/chunks/{register-mutation-RVND5NCG.js → register-mutation-YZYG53SQ.js} +4 -4
  35. package/dist/cli-bundle/chunks/register-operations-KFSCC7QV.js +2 -0
  36. package/dist/cli-bundle/chunks/{register-setup-D3ZFHY3L.js → register-setup-UJCRVGBG.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/chunk-24IG6ONG.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-M5M6SVHS.js → chunk-3ASU6WGI.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/chunk-3ITLIBKS.js +56 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-3NQD5YDG.js +2 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-S27XMBIN.js → chunk-4OSHLNUE.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/chunk-65N6JHAN.js +2 -0
  43. package/dist/cli-bundle/focused-chunks/{chunk-5RFXUPN5.js → chunk-B2TTQGFG.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-GUBM3RGY.js +20 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-Q45NHPF2.js → chunk-H5FOGAVD.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-JX3RCVCX.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-D7KXFBXV.js → chunk-KWWCBWFO.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-MV752SUC.js +12 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-PKIPMCFS.js +6 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-4HJFY4MB.js → chunk-QL66QNWG.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-RJMR2JIF.js +9 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-WIUPWIZR.js +177 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-WOCIPMW7.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-GT7MXDLW.js → chunk-YEF5PQQ2.js} +2 -2
  55. package/dist/cli-bundle/main.js +22 -15
  56. package/dist/cli-bundle/sdk-authoring.js +1 -1
  57. package/dist/cli-bundle/sdk-contracts.js +1 -1
  58. package/dist/cli-bundle/sdk-core.js +29 -32
  59. package/dist/cli-bundle/sdk-governance.js +1 -1
  60. package/dist/cli-bundle/sdk-graph.js +1 -1
  61. package/dist/cli-bundle/sdk-merge.js +45 -37
  62. package/dist/cli-bundle/sdk-query.js +1 -1
  63. package/dist/cli-bundle/sdk-runtime.js +1 -1
  64. package/dist/cli-bundle/sdk-testing.js +1 -1
  65. package/dist/cli-bundle/sdk.js +10 -10
  66. package/dist/core/diagnostics/remediation.js +4 -4
  67. package/dist/core/extensions/extension-types.d.ts +2 -0
  68. package/dist/core/extensions/extension-types.js +2 -2
  69. package/dist/core/history/drift-scan.d.ts +5 -0
  70. package/dist/core/history/drift-scan.js +16 -6
  71. package/dist/core/history/event-classification.d.ts +1 -1
  72. package/dist/core/history/event-classification.js +3 -2
  73. package/dist/core/history/history.d.ts +37 -1
  74. package/dist/core/history/history.js +311 -59
  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 +70 -36
  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/lock/lock.d.ts +10 -0
  91. package/dist/core/lock/lock.js +42 -3
  92. package/dist/core/shared/author.d.ts +3 -1
  93. package/dist/core/shared/author.js +111 -23
  94. package/dist/core/shared/errors.d.ts +8 -0
  95. package/dist/core/shared/errors.js +2 -2
  96. package/dist/core/store/item-store.d.ts +14 -0
  97. package/dist/core/store/item-store.js +48 -10
  98. package/dist/core/store/settings-validator.js +3 -2
  99. package/dist/sdk/actionability.d.ts +1 -1
  100. package/dist/sdk/actionability.js +3 -3
  101. package/dist/sdk/cli-contracts/command-aliases.js +11 -2
  102. package/dist/sdk/cli-contracts/completeness.js +4 -3
  103. package/dist/sdk/cli-contracts/flag-contracts.js +29 -5
  104. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +19 -12
  105. package/dist/sdk/cli-contracts/tool-parameter-tables.js +14 -2
  106. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  107. package/dist/sdk/cli-contracts/tool-schema.js +19 -6
  108. package/dist/sdk/context-intent-contracts.js +3 -3
  109. package/dist/sdk/context-usage.js +9 -11
  110. package/dist/sdk/define.d.ts +1 -1
  111. package/dist/sdk/define.js +2 -2
  112. package/dist/sdk/environment/agent-environment.d.ts +296 -0
  113. package/dist/sdk/environment/agent-environment.js +467 -0
  114. package/dist/sdk/environment/project-runtime-compatibility.d.ts +19 -1
  115. package/dist/sdk/environment/project-runtime-compatibility.js +118 -21
  116. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +98 -38
  117. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +50 -2
  118. package/dist/sdk/governance/health.js +13 -44
  119. package/dist/sdk/governance/merge-receipt-history.d.ts +62 -0
  120. package/dist/sdk/governance/merge-receipt-history.js +207 -0
  121. package/dist/sdk/governance/provenance-health.js +9 -3
  122. package/dist/sdk/governance/validate-history-drift.js +16 -5
  123. package/dist/sdk/guide-topics.js +116 -2
  124. package/dist/sdk/history/salvage.d.ts +35 -0
  125. package/dist/sdk/history/salvage.js +248 -0
  126. package/dist/sdk/history-compact.js +41 -37
  127. package/dist/sdk/history-read.d.ts +3 -2
  128. package/dist/sdk/history-read.js +6 -3
  129. package/dist/sdk/history-redact.js +58 -23
  130. package/dist/sdk/history-repair.d.ts +5 -0
  131. package/dist/sdk/history-repair.js +28 -6
  132. package/dist/sdk/index.d.ts +2 -0
  133. package/dist/sdk/index.js +4 -2
  134. package/dist/sdk/lifecycle/claim.d.ts +4 -0
  135. package/dist/sdk/lifecycle/claim.js +9 -3
  136. package/dist/sdk/lifecycle/restore.d.ts +1 -0
  137. package/dist/sdk/lifecycle/restore.js +19 -7
  138. package/dist/sdk/merge/driver.d.ts +3 -1
  139. package/dist/sdk/merge/driver.js +9 -9
  140. package/dist/sdk/merge/index.d.ts +1 -1
  141. package/dist/sdk/merge/index.js +3 -3
  142. package/dist/sdk/merge/receipts.d.ts +17 -6
  143. package/dist/sdk/merge/receipts.js +246 -75
  144. package/dist/sdk/merge/reconcile.d.ts +9 -7
  145. package/dist/sdk/merge/reconcile.js +175 -12
  146. package/dist/sdk/merge/three-way.d.ts +22 -2
  147. package/dist/sdk/merge/three-way.js +92 -25
  148. package/dist/sdk/output-projection.d.ts +3 -1
  149. package/dist/sdk/output-projection.js +11 -3
  150. package/dist/sdk/public-surface.json +1 -0
  151. package/dist/sdk/query/context.d.ts +9 -0
  152. package/dist/sdk/query/context.js +33 -21
  153. package/dist/sdk/query/get.d.ts +2 -2
  154. package/dist/sdk/query/get.js +4 -3
  155. package/dist/sdk/query/history.d.ts +11 -0
  156. package/dist/sdk/query/history.js +34 -10
  157. package/dist/sdk/query/next.d.ts +15 -1
  158. package/dist/sdk/query/next.js +43 -20
  159. package/dist/sdk/query.d.ts +1 -0
  160. package/dist/sdk/query.js +3 -2
  161. package/dist/sdk/runtime-primitives.d.ts +3 -3
  162. package/dist/sdk/runtime-primitives.js +5 -5
  163. package/dist/types.d.ts +27 -0
  164. package/dist/types.js +2 -2
  165. package/docs/AGENT_ENVIRONMENTS.md +47 -0
  166. package/docs/AGENT_GUIDE.md +36 -0
  167. package/docs/AGENT_PROVENANCE_ADR.md +17 -2
  168. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +38 -1
  169. package/docs/HISTORY_RECOVERY.md +146 -0
  170. package/docs/MERGE_SAFETY.md +119 -23
  171. package/docs/README.md +2 -0
  172. package/docs/RELEASING.md +25 -11
  173. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +24 -2
  174. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +24 -1
  175. package/docs/SDK_EXECUTION_CONTRACTS.md +105 -0
  176. package/docs/SDK_RUNTIME_BOUNDARIES.md +17 -1
  177. package/docs/TESTING.md +5 -0
  178. package/docs/agent-task-token-baseline.json +17 -17
  179. package/docs/agent-task-transcripts.json +2 -1
  180. package/docs/examples/sdk-agent-environment/README.md +14 -0
  181. package/docs/examples/sdk-agent-environment/package.json +8 -0
  182. package/docs/examples/sdk-agent-environment/run-agent-environment.mjs +154 -0
  183. package/docs/generated/FLAG_LEXICON_BUDGETS.md +10 -10
  184. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +12 -3
  185. package/marketplace.json +2 -2
  186. package/package.json +5 -6
  187. package/packages/pm-beads/package.json +1 -1
  188. package/packages/pm-calendar/package.json +1 -1
  189. package/packages/pm-command-kit/package.json +1 -1
  190. package/packages/pm-digital-twin/package.json +1 -1
  191. package/packages/pm-governance-audit/package.json +1 -1
  192. package/packages/pm-guide-shell/package.json +1 -1
  193. package/packages/pm-kanban/package.json +1 -1
  194. package/packages/pm-lifecycle-hooks/package.json +1 -1
  195. package/packages/pm-linked-test-adapters/package.json +1 -1
  196. package/packages/pm-search-advanced/package.json +1 -1
  197. package/packages/pm-templates/package.json +1 -1
  198. package/packages/pm-todos/package.json +1 -1
  199. package/packages/pm-vcs/package.json +1 -1
  200. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  201. package/plugins/pm-claude/skills/pm-audit/SKILL.md +2 -2
  202. package/plugins/pm-claude/skills/pm-developer/SKILL.md +2 -2
  203. package/plugins/pm-claude/skills/pm-planner/SKILL.md +2 -2
  204. package/plugins/pm-claude/skills/pm-release/SKILL.md +2 -2
  205. package/plugins/pm-claude/skills/pm-workflow/SKILL.md +3 -3
  206. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  207. package/plugins/pm-codex/skills/pm-auditor/SKILL.md +2 -2
  208. package/plugins/pm-codex/skills/pm-native/SKILL.md +3 -4
  209. package/plugins/pm-codex/skills/pm-release/SKILL.md +2 -2
  210. package/scripts/finalize-build.mjs +13 -1
  211. package/dist/cli-bundle/chunks/chunk-AY324UJ5.js +0 -9
  212. package/dist/cli-bundle/chunks/chunk-E5RBBCXO.js +0 -230
  213. package/dist/cli-bundle/chunks/chunk-IEHHE6GA.js +0 -5
  214. package/dist/cli-bundle/chunks/chunk-L7B7343B.js +0 -8
  215. package/dist/cli-bundle/chunks/chunk-LISESA7W.js +0 -35
  216. package/dist/cli-bundle/chunks/register-operations-TTROIVC4.js +0 -2
  217. package/dist/cli-bundle/focused-chunks/chunk-3ZBI35HU.js +0 -176
  218. package/dist/cli-bundle/focused-chunks/chunk-4RRHC3S4.js +0 -6
  219. package/dist/cli-bundle/focused-chunks/chunk-4WR46RMG.js +0 -9
  220. package/dist/cli-bundle/focused-chunks/chunk-BWKHEIVF.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-GHCZ3YFR.js +0 -20
  222. package/dist/cli-bundle/focused-chunks/chunk-KBLZRU62.js +0 -2
  223. package/dist/cli-bundle/focused-chunks/chunk-KZ2NB3ET.js +0 -2
  224. package/dist/cli-bundle/focused-chunks/chunk-OL5EH6I3.js +0 -2
  225. package/dist/cli-bundle/focused-chunks/chunk-QKHCSUGJ.js +0 -51
  226. package/dist/cli-bundle/focused-chunks/chunk-TXE4TSHM.js +0 -12
  227. package/dist/cli-bundle/focused-chunks/chunk-UCLO3XDU.js +0 -2
  228. package/sdk/public-surface.json +0 -32524
@@ -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
@@ -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]="16112e3d-b640-5114-a2c2-5effc655fe50")}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) {
@@ -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=16112e3d-b640-5114-a2c2-5effc655fe50
@@ -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
  };
@@ -9,9 +9,10 @@
9
9
  * re-deriving readiness from a full `pm context` snapshot every turn.
10
10
  */
11
11
 
12
- !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]="b0f3d72c-ff0b-59bb-a6bc-8476eb9fb6c1")}catch(e){}}();
13
- import { collectBlockedByIds, computeActionabilityReport, } from "../actionability.js";
14
- import { resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, nowIso, normalizeStatusInput, normalizeStatusForRegistry, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
12
+ !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]="6035e85b-81ed-512e-b291-b0d86af1848b")}catch(e){}}();
13
+ import { collectBlockedByIds, computeActionabilityReport, resolveItemExecutionRole, selectActionableEntries, } from "../actionability.js";
14
+ import { resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, nowIso, normalizeStatusInput, normalizeStatusForRegistry, resolvePmRoot, readSettings, resolveAuthor, resolveItemTypeRegistry, } from "../runtime-primitives.js";
15
+ import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
15
16
  import { parseIntegerLimit } from "./parsers.js";
16
17
  import { buildChildrenByParent, collectSubtreeIds, compareCriticalItems, mergeSortedWarnings, packRankedContextItems, resolveContextTokenBudget, toContextPackingSummary, toContextRankingSummary, toContextFocusItem, } from "./context.js";
17
18
  import { runList } from "./list.js";
@@ -94,7 +95,7 @@ function buildRecommendationReasons(entry, statusRegistry, now, completedContain
94
95
  reasons.push(`advances ${item.parent.trim()}`);
95
96
  }
96
97
  if (entry.unblocks.length > 0) {
97
- reasons.push(`unblocks ${entry.unblocks.length} item(s): ${entry.unblocks.join(", ")}`);
98
+ reasons.push(`unblocks ${entry.unblocks.length} item(s)`);
98
99
  }
99
100
  return reasons;
100
101
  }
@@ -118,12 +119,12 @@ export const _testOnlyNextCommand = {
118
119
  resolveNextCallerAuthor: (options, settingsAuthor) => resolveNextCallerAuthor(options, settingsAuthor),
119
120
  };
120
121
  /** Separates human-gated decisions from autonomous agent work unless the caller explicitly opts into decision claims. */
121
- export function partitionDecisionEntries(ready, includeDecisions) {
122
- const decisions = ready.filter((entry) => entry.item.type.trim().toLowerCase() === "decision");
122
+ export function partitionDecisionEntries(ready, includeDecisions, typeRegistry) {
123
+ const decisions = ready.filter((entry) => resolveItemExecutionRole(entry.item.type, typeRegistry) === "human");
123
124
  return {
124
125
  agent: includeDecisions
125
126
  ? ready
126
- : ready.filter((entry) => entry.item.type.trim().toLowerCase() !== "decision"),
127
+ : ready.filter((entry) => resolveItemExecutionRole(entry.item.type, typeRegistry) !== "human"),
127
128
  decisions: includeDecisions ? [] : decisions,
128
129
  };
129
130
  }
@@ -195,13 +196,17 @@ function buildNextRecommendation(params) {
195
196
  reasons: buildRecommendationReasons(params.projectedReady[0], params.statusRegistry, params.now, params.completedContainer),
196
197
  };
197
198
  }
198
- function buildNextSuggestions(recommended, blockedRows) {
199
+ function buildNextSuggestions(recommended, blockedRows, gateCount) {
199
200
  if (recommended !== null) {
200
201
  return undefined;
201
202
  }
203
+ const gateGuidance = gateCount > 0
204
+ ? ["No executable recommendation: outcome gates require verification. Inspect gate_needed, or use pm next --include-gates to opt in."]
205
+ : [];
202
206
  if (blockedRows.length > 0) {
203
207
  const blockedWithReferences = blockedRows.find((item) => item.blockers.length > 0);
204
208
  return [
209
+ ...gateGuidance,
205
210
  blockedWithReferences
206
211
  ? `${blockedRows.length} item(s) are blocked; unblock the top one by closing ${blockedWithReferences.blockers.map((blocker) => blocker.id).join(", ")}`
207
212
  : `${blockedRows.length} item(s) are blocked; add blocker context or move the top item back to an active status`,
@@ -210,6 +215,7 @@ function buildNextSuggestions(recommended, blockedRows) {
210
215
  ];
211
216
  }
212
217
  return [
218
+ ...gateGuidance,
213
219
  'pm create --type Task --title "..." to add a new work item',
214
220
  "pm list --status in_progress to review work already underway",
215
221
  "pm context --depth deep for the full project snapshot",
@@ -271,7 +277,7 @@ async function finalizeNextResult(params) {
271
277
  params.result.ranking = toContextRankingSummary(params.readyRanking, params.featureStore);
272
278
  params.result.packing = toContextPackingSummary(params.packing);
273
279
  }
274
- params.result.suggestions = buildNextSuggestions(params.recommended, params.blockedRows);
280
+ params.result.suggestions = buildNextSuggestions(params.recommended, params.blockedRows, params.gateCount);
275
281
  await attachNextUsageFeedback({
276
282
  result: params.result,
277
283
  pmRoot: params.pmRoot,
@@ -291,9 +297,9 @@ function filterCandidatesByParentScope(candidates, corpus, parentScope) {
291
297
  }
292
298
  return candidates.filter((item) => subtree.ids.has(item.id.trim().toLowerCase()));
293
299
  }
294
- async function rankReadyEntriesWithRelevance(rankedReady, childrenByParent, statusRegistry, now, callerAuthor, pmRoot, tokenBudget) {
300
+ async function rankReadyEntriesWithRelevance(rankedReady, childrenByParent, statusRegistry, now, callerAuthor, pmRoot, tokenBudget, includeContainers) {
295
301
  const concreteReady = rankedReady.filter((entry) => !hasCompletedDescendants(entry.item, childrenByParent));
296
- const structuralReady = concreteReady.length > 0 ? concreteReady : rankedReady;
302
+ const structuralReady = includeContainers || concreteReady.length === 0 ? rankedReady : concreteReady;
297
303
  const usage = await readContextUsageAffinity({
298
304
  pmRoot,
299
305
  author: callerAuthor,
@@ -316,7 +322,7 @@ async function rankReadyEntriesWithRelevance(rankedReady, childrenByParent, stat
316
322
  return {
317
323
  projectedReady,
318
324
  ranking,
319
- completedContainer: concreteReady.length === 0,
325
+ completedContainer: concreteReady.length === 0 && !includeContainers,
320
326
  packing,
321
327
  featureStore,
322
328
  };
@@ -335,6 +341,7 @@ export async function runNext(options, global) {
335
341
  const settings = await readSettings(pmRoot);
336
342
  const callerAuthor = resolveNextCallerAuthor(options, settings.author_default);
337
343
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
344
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
338
345
  const now = nowIso();
339
346
  const limit = parseNextLimit(options.limit, "--limit", DEFAULT_NEXT_LIMIT);
340
347
  const tokenBudget = resolveContextTokenBudget(options.tokenBudget, Math.max(192, limit * 128));
@@ -350,16 +357,18 @@ export async function runNext(options, global) {
350
357
  const corpusList = await runList(undefined, { excludeTerminal: false, noTruncate: true }, global);
351
358
  const candidates = filterCandidatesByParentScope(candidatesList.items, corpusList.items, parentScope);
352
359
  const corpus = corpusList.items;
353
- const report = computeActionabilityReport(candidates, corpus, statusRegistry);
360
+ const report = computeActionabilityReport(candidates, corpus, statusRegistry, typeRegistry);
354
361
  const childrenByParent = buildChildrenByParent(corpus);
355
- const partitionedByDecision = partitionDecisionEntries(report.ready, options.includeDecisions === true);
356
- const callerPartition = partitionCallerOwnedReady(partitionedByDecision.agent, settings.author_default, callerAuthor);
362
+ const selected = selectActionableEntries(report, statusRegistry, options, typeRegistry);
363
+ const callerPartition = partitionCallerOwnedReady(selected.ready, settings.author_default, callerAuthor);
357
364
  const rankedReady = rankNextReadyEntries(callerPartition.available, childrenByParent, statusRegistry);
358
365
  const rankedBlocked = [...report.blocked].sort((left, right) => compareCriticalItems(left.item, right.item, statusRegistry));
359
- const { projectedReady, ranking: readyRanking, completedContainer, packing: readyPacking, featureStore, } = await rankReadyEntriesWithRelevance(rankedReady, childrenByParent, statusRegistry, now, callerAuthor, pmRoot, tokenBudget);
366
+ const { projectedReady, ranking: readyRanking, completedContainer, packing: readyPacking, featureStore, } = await rankReadyEntriesWithRelevance(rankedReady, childrenByParent, statusRegistry, now, callerAuthor, pmRoot, tokenBudget, options.includeContainers === true);
360
367
  const readyRows = projectedReady.map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
361
368
  const blockedRows = rankedBlocked.map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
362
- const decisionRows = rankNextReadyEntries(partitionedByDecision.decisions, childrenByParent, statusRegistry).map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
369
+ const decisionRows = rankNextReadyEntries(selected.decisions, childrenByParent, statusRegistry).map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
370
+ const gateRows = rankNextReadyEntries(selected.gates, childrenByParent, statusRegistry).map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
371
+ const containerRows = rankNextReadyEntries(report.containers, childrenByParent, statusRegistry).map((entry, index) => toNextActionableItem(entry, statusRegistry, childrenByParent, index + 1));
363
372
  const recommended = buildNextRecommendation({
364
373
  projectedReady,
365
374
  readyRows,
@@ -367,13 +376,19 @@ export async function runNext(options, global) {
367
376
  now,
368
377
  completedContainer,
369
378
  });
370
- const truncation = buildNextTruncation(decisionRows.length, callerPartition.held.length, limit);
379
+ const truncation = buildNextTruncation(decisionRows.length, callerPartition.held.length, limit) ?? {};
380
+ if (gateRows.length > limit)
381
+ truncation.gate_needed_total = gateRows.length;
382
+ if (containerRows.length > limit)
383
+ truncation.containers_total = containerRows.length;
371
384
  const result = {
372
385
  output_default: "toon",
373
386
  now,
374
387
  recommended,
375
388
  ready: readyRows.slice(1, limit + 1),
376
389
  decision_needed: decisionRows.slice(0, limit),
390
+ gate_needed: gateRows.slice(0, limit),
391
+ containers: containerRows.slice(0, limit),
377
392
  blocked: readyOnly ? [] : blockedRows.slice(0, blockedLimit),
378
393
  held_by_others: callerPartition.held.slice(0, limit),
379
394
  summary: {
@@ -384,6 +399,7 @@ export async function runNext(options, global) {
384
399
  candidates: report.active_count,
385
400
  containers: report.container_count,
386
401
  decision_needed: decisionRows.length,
402
+ gate_needed: gateRows.length,
387
403
  held_by_others: callerPartition.held.length,
388
404
  },
389
405
  filters: {
@@ -399,14 +415,17 @@ export async function runNext(options, global) {
399
415
  blocked_limit: blockedLimit,
400
416
  ready_only: readyOnly,
401
417
  include_decisions: options.includeDecisions === true,
418
+ include_gates: options.includeGates === true,
419
+ include_containers: options.includeContainers === true,
402
420
  token_budget: tokenBudget,
403
421
  },
404
- truncation,
422
+ truncation: Object.keys(truncation).length > 0 ? truncation : undefined,
405
423
  };
406
424
  return finalizeNextResult({
407
425
  result,
408
426
  recommended,
409
427
  blockedRows,
428
+ gateCount: gateRows.length,
410
429
  candidatesWarnings: candidatesList.warnings,
411
430
  corpusWarnings: corpusList.warnings,
412
431
  readyRanking,
@@ -424,6 +443,10 @@ export async function runNext(options, global) {
424
443
  */
425
444
  export function renderNextMarkdown(result) {
426
445
  const lines = ["# pm next", "", ...renderNextSummaryLines(result)];
446
+ for (const [title, rows] of [["Gate verification needed", result.gate_needed], ["Containers", result.containers]]) {
447
+ if (rows && rows.length > 0)
448
+ lines.push(...renderNextSection(title, rows.map((item) => `- ${formatNextLine(item)}`), ""));
449
+ }
427
450
  lines.push(...renderNextSection("Recommended", renderNextRecommendedRows(result.recommended), "No ready work."));
428
451
  lines.push(...renderNextSection("Decision needed",
429
452
  // `?? []` tolerates JSON payloads from pre-decision-queue builds (the
@@ -488,4 +511,4 @@ function formatNextLine(item) {
488
511
  return `${rankToken}${item.id} p${item.priority} ${item.status} ${item.type} deadline:${deadlineToken}${parentToken}${unblocksToken} ${item.title}`;
489
512
  }
490
513
  //# sourceMappingURL=next.js.map
491
- //# debugId=b0f3d72c-ff0b-59bb-a6bc-8476eb9fb6c1
514
+ //# debugId=6035e85b-81ed-512e-b291-b0d86af1848b
@@ -13,6 +13,7 @@ export { CONTEXT_OUTPUT_VALUES, applyContextTagProjection, buildChildrenByParent
13
13
  export * from "./query/get.js";
14
14
  export * from "./query/history.js";
15
15
  export * from "./query/next.js";
16
+ export * from "./actionability.js";
16
17
  export * from "./query/search-pagination.js";
17
18
  export * from "./query/search-rendering.js";
18
19
  export * from "./query/item-filter-options.js";
package/dist/sdk/query.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Provides focused read, search, pagination, and context-ranking primitives.
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]="036baf5a-3ba9-55ea-a11b-d9e94a848b92")}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]="214c6bc1-313b-53c1-883a-d2d0536f8aea")}catch(e){}}();
8
8
  export * from "./query/list.js";
9
9
  export * from "./query/complete-list.js";
10
10
  export * from "./query/search.js";
@@ -15,6 +15,7 @@ export { CONTEXT_OUTPUT_VALUES, applyContextTagProjection, buildChildrenByParent
15
15
  export * from "./query/get.js";
16
16
  export * from "./query/history.js";
17
17
  export * from "./query/next.js";
18
+ export * from "./actionability.js";
18
19
  export * from "./query/search-pagination.js";
19
20
  export * from "./query/search-rendering.js";
20
21
  export * from "./query/item-filter-options.js";
@@ -30,4 +31,4 @@ export * from "./context-usage.js";
30
31
  export * from "./workspace-memory.js";
31
32
  export * from "./duplicates.js";
32
33
  //# sourceMappingURL=query.js.map
33
- //# debugId=036baf5a-3ba9-55ea-a11b-d9e94a848b92
34
+ //# debugId=214c6bc1-313b-53c1-883a-d2d0536f8aea
@@ -17,10 +17,10 @@ export { isFileMissingError, pathExists, readFileIfExists, removeFileIfExists, w
17
17
  export { normalizeBulkIdsValue, parseBulkIdsText, resolveCliBulkIdsInput, type BulkIdsFileReader, type BulkIdsInputReaders, type BulkIdsStdinReader, type BulkIdsValue, } from "../core/io/bulk-ids-input.js";
18
18
  export { type HistoryDiffValueEntry, computeHistoryDiff, patchPathToChangedField, } from "../core/history/history-diff.js";
19
19
  export { enforceHistoryStreamPolicyForItem, enforceHistoryStreamPolicyForItems, } from "../core/history/history-stream-policy.js";
20
- export { appendHistoryEntry, CURRENT_HISTORY_ITEM_HASH_VERSION, createHistoryEntry, hashDocument, hashDocumentForVersion, hashEmptyDocument, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, type HistoryItemHashVersion, } from "../core/history/history.js";
20
+ export { appendHistoryEntry, CURRENT_HISTORY_ITEM_HASH_VERSION, CURRENT_HISTORY_RECORD_HASH_VERSION, createHistoryEntry, hashDocument, hashDocumentForVersion, hashEmptyDocument, hashHistoryPatch, hashHistoryRecord, hashHistoryStream, resealHistoryRewrite, sealHistoryRecord, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, SUPPORTED_HISTORY_RECORD_HASH_VERSIONS, verifyHistoryRecordHash, verifyHistoryRewriteEvidence, type HistoryItemHashVersion, type HistoryRecordHashVersion, } from "../core/history/history.js";
21
21
  export { readHistoryEntries } from "../core/history/read.js";
22
22
  export { appendWorkspaceAuditEvent, appendWorkspaceHistoryChange, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, mutateWorkspaceJsonWithHistory, reconcileWorkspaceJsonHistory, restoreWorkspaceJsonFromHistory, WORKSPACE_HISTORY_ID, writeWorkspaceJsonWithHistory, type WorkspaceAuditEventOptions, type WorkspaceHistoryChange, type WorkspaceHistoryStateAgreement, type WorkspaceJsonMutation, type WorkspaceJsonMutationOptions, type WorkspaceJsonReconciliationOptions, type WorkspaceJsonRestoreOptions, type WorkspaceJsonRestoreResult, type WorkspaceJsonWriteOptions, } from "../core/history/workspace-history.js";
23
- export { normalizeReplayPatchOps, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, verifyHistoryChainWithVersion, } from "../core/history/replay.js";
23
+ export { normalizeReplayPatchOps, reanchorHistoryEntries, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, verifyHistoryChain, verifyHistoryChainWithVersion, } from "../core/history/replay.js";
24
24
  export { resolveBodyFileContent } from "../core/io/body-file.js";
25
25
  export { generateItemId, normalizeItemId, normalizeRawItemId, } from "../core/item/id.js";
26
26
  export { canonicalDocument, normalizeItemMetadata, parseItemDocument, serializeItemDocument, } from "../core/item/item-format.js";
@@ -34,7 +34,7 @@ export { isTerminalStatus, normalizeStatusForRegistry, normalizeStatusInput, } f
34
34
  export { COMMON_MUTATION_COMMAND_OPTION_KEYS, type ItemTypeRegistry, type ResolvedItemTypeDefinition, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveCommandOptionPolicyState, resolveItemTypeRegistry, resolveTypeDefinition, resolveTypeName, validateTypeOptions, } from "../core/item/type-registry.js";
35
35
  export { resolveTypeSynonym } from "../core/item/type-synonyms.js";
36
36
  export { acquireLock } from "../core/lock/lock.js";
37
- export { printError, printResult, writeStdout } from "../core/output/output.js";
37
+ export { printError, printResult, writeStderr, writeStdout } from "../core/output/output.js";
38
38
  export { renderRowsAsCsv, renderRowsAsTable } from "../core/output/tabular.js";
39
39
  export { parseLimit } from "../core/shared/numeric-parsers.js";
40
40
  export { resolveConfiguredPmPackageRoot, resolvePmCliVersion, resolvePmPackageRootFromModule, } from "../core/packages/root.js";