@unbrained/pm-cli 2026.8.19 → 2026.8.21

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 (229) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +41 -0
  3. package/dist/cli/error-guidance.d.ts +20 -0
  4. package/dist/cli/error-guidance.js +29 -30
  5. package/dist/cli/register-list-query.js +12 -10
  6. package/dist/cli/register-structured-mutation.d.ts +2 -0
  7. package/dist/cli/register-structured-mutation.js +29 -6
  8. package/dist/cli-bundle/bundle-manifest.json +156 -148
  9. package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +197 -0
  10. package/dist/cli-bundle/chunks/{chunk-4NRRH7AM.js → chunk-3AFAUHUE.js} +2 -2
  11. package/dist/cli-bundle/chunks/chunk-7VHZS727.js +5 -0
  12. package/dist/cli-bundle/chunks/chunk-BKYB45NQ.js +2092 -0
  13. package/dist/cli-bundle/chunks/{chunk-BHYMXLAE.js → chunk-BUNIEJNE.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-QXSH7BLM.js → chunk-JSLOFXGA.js} +3 -3
  15. package/dist/cli-bundle/chunks/chunk-LARJJ3RK.js +3 -0
  16. package/dist/cli-bundle/chunks/{chunk-TOXJM4WA.js → chunk-LOVTQ52Z.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-N3DSV4CH.js +77 -0
  18. package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +35 -0
  19. package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +13 -0
  20. package/dist/cli-bundle/chunks/register-list-query-F57EWDEF.js +11 -0
  21. package/dist/cli-bundle/chunks/{register-mutation-AUWVCW4M.js → register-mutation-7IY2D5KO.js} +20 -20
  22. package/dist/cli-bundle/chunks/{register-operations-PZQPHXW5.js → register-operations-FALL3YTU.js} +2 -2
  23. package/dist/cli-bundle/chunks/{register-setup-I4LUHGVW.js → register-setup-HXU7IZZD.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/chunk-2NIY5NKG.js +18 -0
  25. package/dist/cli-bundle/focused-chunks/{chunk-US7VEYZG.js → chunk-4ERLO7QD.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +50 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-MCZXYZAF.js → chunk-CKKQSJNN.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +16 -0
  29. package/dist/cli-bundle/focused-chunks/{chunk-ZBIQQYMI.js → chunk-F2A56DHV.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-ESISGDAY.js → chunk-F4YEW5I2.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-ODHQEECS.js → chunk-FH6DYED3.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/chunk-FJ22HNRP.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-JEAVFOWM.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-EXBCLIBU.js → chunk-KDNG7TKQ.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +155 -0
  37. package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +2 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-JDOMQ7VQ.js → chunk-TJ7EMJ46.js} +3 -3
  39. package/dist/cli-bundle/focused-chunks/chunk-UZE7XUZK.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-DKPLYW3L.js → chunk-YKBKIEAJ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-VXDSU5MC.js → chunk-ZOSEELYJ.js} +2 -2
  42. package/dist/cli-bundle/main.js +12 -12
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +2 -2
  45. package/dist/cli-bundle/sdk-core.js +41 -41
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +32 -32
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +5 -5
  53. package/dist/core/output/mutation-projection.js +26 -2
  54. package/dist/core/shared/constants.d.ts +1 -5
  55. package/dist/core/shared/constants.js +3 -81
  56. package/dist/core/shared/errors.d.ts +16 -0
  57. package/dist/core/shared/errors.js +2 -2
  58. package/dist/core/shared/item-metadata-contract.d.ts +14 -0
  59. package/dist/core/shared/item-metadata-contract.js +90 -0
  60. package/dist/core/store/item-store.d.ts +60 -0
  61. package/dist/core/store/item-store.js +26 -94
  62. package/dist/core/store/tracker-preflight.d.ts +7 -0
  63. package/dist/core/store/tracker-preflight.js +142 -0
  64. package/dist/sdk/agent/closed-domain-contracts.d.ts +25 -0
  65. package/dist/sdk/agent/closed-domain-contracts.js +140 -0
  66. package/dist/sdk/agent/refusal-closure.d.ts +13 -1
  67. package/dist/sdk/agent/refusal-closure.js +45 -3
  68. package/dist/sdk/agent/refusal-reachability.d.ts +26 -0
  69. package/dist/sdk/agent/refusal-reachability.js +26 -2
  70. package/dist/sdk/agent/tracker-preflight-contracts.d.ts +63 -0
  71. package/dist/sdk/agent/tracker-preflight-contracts.js +127 -0
  72. package/dist/sdk/agent-capability-contracts.js +6 -11
  73. package/dist/sdk/annotations.js +6 -7
  74. package/dist/sdk/cli-contracts/completeness.js +8 -2
  75. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -2
  76. package/dist/sdk/cli-contracts/enum-contracts.js +16 -6
  77. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  78. package/dist/sdk/cli-contracts/flag-contracts.js +11 -2
  79. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +19 -2
  80. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +105 -5
  81. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +2 -2
  82. package/dist/sdk/cli-contracts/grammar-contracts.js +5 -2
  83. package/dist/sdk/cli-contracts/runtime-contracts.js +7 -3
  84. package/dist/sdk/cli-contracts/tool-schema.js +7 -2
  85. package/dist/sdk/cli-contracts.d.ts +2 -2
  86. package/dist/sdk/cli-contracts.js +4 -4
  87. package/dist/sdk/config.d.ts +5 -0
  88. package/dist/sdk/config.js +5 -5
  89. package/dist/sdk/context-intent-runtime.js +7 -4
  90. package/dist/sdk/contracts.d.ts +2 -0
  91. package/dist/sdk/contracts.js +4 -2
  92. package/dist/sdk/core.d.ts +1 -1
  93. package/dist/sdk/core.js +3 -3
  94. package/dist/sdk/dependencies.js +5 -7
  95. package/dist/sdk/dependency-flag-validation.d.ts +1 -1
  96. package/dist/sdk/dependency-flag-validation.js +10 -4
  97. package/dist/sdk/environment/tracker-preflight.d.ts +6 -0
  98. package/dist/sdk/environment/tracker-preflight.js +10 -0
  99. package/dist/sdk/eval.js +5 -7
  100. package/dist/sdk/files.js +6 -10
  101. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +110 -2
  102. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +179 -46
  103. package/dist/sdk/governance/assurance.d.ts +36 -2
  104. package/dist/sdk/governance/assurance.js +184 -10
  105. package/dist/sdk/governance/gc.js +5 -6
  106. package/dist/sdk/governance/health.js +5 -6
  107. package/dist/sdk/governance/reindex.js +5 -6
  108. package/dist/sdk/governance/validate.d.ts +1 -2
  109. package/dist/sdk/governance/validate.js +6 -12
  110. package/dist/sdk/graph/governance.d.ts +7 -5
  111. package/dist/sdk/graph/governance.js +32 -16
  112. package/dist/sdk/graph/run.js +5 -7
  113. package/dist/sdk/graph/traversal.js +14 -5
  114. package/dist/sdk/history-compact.js +6 -9
  115. package/dist/sdk/history-read.js +5 -7
  116. package/dist/sdk/history-redact.js +5 -6
  117. package/dist/sdk/history-repair.js +6 -9
  118. package/dist/sdk/improvement-ledger.js +7 -10
  119. package/dist/sdk/index.d.ts +7 -3
  120. package/dist/sdk/index.js +8 -4
  121. package/dist/sdk/init-agent-guidance.d.ts +5 -3
  122. package/dist/sdk/init-agent-guidance.js +69 -9
  123. package/dist/sdk/lifecycle/append.d.ts +0 -5
  124. package/dist/sdk/lifecycle/append.js +5 -6
  125. package/dist/sdk/lifecycle/claim.d.ts +0 -5
  126. package/dist/sdk/lifecycle/claim.js +6 -9
  127. package/dist/sdk/lifecycle/close-many.d.ts +0 -5
  128. package/dist/sdk/lifecycle/close-many.js +5 -6
  129. package/dist/sdk/lifecycle/close.d.ts +0 -5
  130. package/dist/sdk/lifecycle/close.js +5 -6
  131. package/dist/sdk/lifecycle/copy.d.ts +0 -5
  132. package/dist/sdk/lifecycle/copy.js +5 -6
  133. package/dist/sdk/lifecycle/create.d.ts +0 -5
  134. package/dist/sdk/lifecycle/create.js +5 -9
  135. package/dist/sdk/lifecycle/delete.js +5 -6
  136. package/dist/sdk/lifecycle/focus.d.ts +0 -5
  137. package/dist/sdk/lifecycle/focus.js +5 -6
  138. package/dist/sdk/lifecycle/mcp-actions.d.ts +18 -0
  139. package/dist/sdk/lifecycle/mcp-actions.js +52 -0
  140. package/dist/sdk/lifecycle/plan.d.ts +0 -5
  141. package/dist/sdk/lifecycle/plan.js +5 -6
  142. package/dist/sdk/lifecycle/reopen.d.ts +44 -0
  143. package/dist/sdk/lifecycle/reopen.js +69 -0
  144. package/dist/sdk/lifecycle/restore.js +5 -6
  145. package/dist/sdk/lifecycle/update-many.d.ts +0 -5
  146. package/dist/sdk/lifecycle/update-many.js +5 -6
  147. package/dist/sdk/lifecycle/update.d.ts +31 -5
  148. package/dist/sdk/lifecycle/update.js +140 -19
  149. package/dist/sdk/linked-artifacts.js +6 -7
  150. package/dist/sdk/merge/install.js +5 -6
  151. package/dist/sdk/mutation-events.js +5 -7
  152. package/dist/sdk/package-import-adapters.js +6 -8
  153. package/dist/sdk/profile.js +6 -7
  154. package/dist/sdk/query/activity.js +5 -6
  155. package/dist/sdk/query/calendar.js +5 -6
  156. package/dist/sdk/query/get.d.ts +1 -6
  157. package/dist/sdk/query/get.js +20 -55
  158. package/dist/sdk/query/history.d.ts +0 -5
  159. package/dist/sdk/query/history.js +5 -6
  160. package/dist/sdk/query/list.d.ts +7 -21
  161. package/dist/sdk/query/list.js +38 -54
  162. package/dist/sdk/query/projection-contracts.d.ts +33 -0
  163. package/dist/sdk/query/projection-contracts.js +185 -0
  164. package/dist/sdk/query/search-contracts.d.ts +2 -1
  165. package/dist/sdk/query/search-contracts.js +18 -87
  166. package/dist/sdk/query/search.d.ts +15 -0
  167. package/dist/sdk/query/search.js +34 -10
  168. package/dist/sdk/relationship-kinds/contract.d.ts +8 -0
  169. package/dist/sdk/relationship-kinds/contract.js +13 -13
  170. package/dist/sdk/relationships.d.ts +1 -1
  171. package/dist/sdk/relationships.js +20 -2
  172. package/dist/sdk/runtime-primitives.d.ts +1 -1
  173. package/dist/sdk/runtime-primitives.js +3 -3
  174. package/dist/sdk/runtime.d.ts +6 -0
  175. package/dist/sdk/runtime.js +18 -14
  176. package/dist/sdk/schema-migration.js +6 -7
  177. package/dist/sdk/schema.js +5 -6
  178. package/dist/sdk/similarity.d.ts +13 -0
  179. package/dist/sdk/similarity.js +32 -6
  180. package/dist/sdk/stats.js +5 -8
  181. package/dist/sdk/templates.js +5 -6
  182. package/dist/sdk/test/batch.js +5 -7
  183. package/dist/sdk/test/execution.js +4 -5
  184. package/dist/sdk/test/runs.js +5 -7
  185. package/docs/AGENT_UX_CONTRACTS.md +8 -1
  186. package/docs/COMMANDS.md +13 -1
  187. package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -1
  188. package/docs/README.md +1 -0
  189. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +151 -0
  190. package/docs/RELATIONSHIP_GRAPH.md +92 -10
  191. package/docs/SDK.md +10 -2
  192. package/docs/SDK_CONTEXT_INTEGRITY.md +45 -0
  193. package/docs/SDK_PRIMITIVE_INVENTORY.md +15 -1
  194. package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -1
  195. package/docs/performance/sdk-entrypoint-import-costs.md +14 -21
  196. package/marketplace.json +2 -2
  197. package/package.json +5 -5
  198. package/packages/pm-beads/package.json +1 -1
  199. package/packages/pm-calendar/package.json +1 -1
  200. package/packages/pm-command-kit/package.json +1 -1
  201. package/packages/pm-digital-twin/package.json +1 -1
  202. package/packages/pm-governance-audit/package.json +1 -1
  203. package/packages/pm-guide-shell/package.json +1 -1
  204. package/packages/pm-kanban/package.json +1 -1
  205. package/packages/pm-lifecycle-hooks/package.json +1 -1
  206. package/packages/pm-linked-test-adapters/package.json +1 -1
  207. package/packages/pm-search-advanced/package.json +1 -1
  208. package/packages/pm-templates/package.json +1 -1
  209. package/packages/pm-todos/package.json +1 -1
  210. package/packages/pm-vcs/package.json +1 -1
  211. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  212. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  213. package/sdk/public-surface.json +640 -44
  214. package/dist/cli-bundle/chunks/chunk-4THEB6PD.js +0 -13
  215. package/dist/cli-bundle/chunks/chunk-GWMXAQOD.js +0 -197
  216. package/dist/cli-bundle/chunks/chunk-HVFQTLYM.js +0 -35
  217. package/dist/cli-bundle/chunks/chunk-OI4XI562.js +0 -5
  218. package/dist/cli-bundle/chunks/chunk-OIOKV6NO.js +0 -2092
  219. package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +0 -3
  220. package/dist/cli-bundle/chunks/chunk-YBMRWW4E.js +0 -77
  221. package/dist/cli-bundle/chunks/register-list-query-Y56KINDU.js +0 -11
  222. package/dist/cli-bundle/focused-chunks/chunk-34QBIYZI.js +0 -155
  223. package/dist/cli-bundle/focused-chunks/chunk-BJRYFVSH.js +0 -2
  224. package/dist/cli-bundle/focused-chunks/chunk-EF6ZS5GH.js +0 -50
  225. package/dist/cli-bundle/focused-chunks/chunk-L623ZPNK.js +0 -2
  226. package/dist/cli-bundle/focused-chunks/chunk-PRHY2IMX.js +0 -18
  227. package/dist/cli-bundle/focused-chunks/chunk-RZU5U6Q7.js +0 -2
  228. package/dist/cli-bundle/focused-chunks/chunk-YBMGXBFV.js +0 -16
  229. package/dist/cli-bundle/focused-chunks/chunk-YLVBJ6GF.js +0 -2
@@ -4,8 +4,9 @@
4
4
  * Implements the pm append 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]="9e3ba7e9-8822-53ba-981e-e177be5219f3")}catch(e){}}();
8
- import { pathExists, EXIT_CODE, PmCliError, resolveAuthor, toItemRecord, createStdinTokenResolver, mutateItem, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.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]="73184370-6517-533e-90db-536893402616")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { EXIT_CODE, PmCliError, resolveAuthor, toItemRecord, createStdinTokenResolver, mutateItem, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
10
  /** Implements run append for the public runtime surface of this module. */
10
11
  export async function runAppend(id, options, global) {
11
12
  if (options.body === undefined) {
@@ -13,9 +14,7 @@ export async function runAppend(id, options, global) {
13
14
  }
14
15
  const stdinResolver = createStdinTokenResolver();
15
16
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
16
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
17
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
18
- }
17
+ await assertInitializedTracker(pmRoot);
19
18
  const settings = await readSettings(pmRoot);
20
19
  const author = resolveAuthor(options.author, settings.author_default);
21
20
  // options.body is guaranteed defined by the guard above, so resolveValue returns a defined string.
@@ -52,4 +51,4 @@ export async function runAppend(id, options, global) {
52
51
  };
53
52
  }
54
53
  //# sourceMappingURL=append.js.map
55
- //# debugId=9e3ba7e9-8822-53ba-981e-e177be5219f3
54
+ //# debugId=73184370-6517-533e-90db-536893402616
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/claim
3
- *
4
- * Implements the pm claim command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type NextRecommendation, type NextOptions } from "../query/next.js";
8
3
  /** Stable warning/error code for an exhausted atomic next-work walk. */
@@ -4,8 +4,9 @@
4
4
  * Implements the pm claim 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]="f70f1329-4dfb-5625-ae0a-66c858d88f7b")}catch(e){}}();
8
- import { pathExists, resolveRuntimeStatusRegistry, statusIsTerminal, EXIT_CODE, PmCliError, toItemRecord, mutateItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.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]="1a61bf25-e320-5adc-8f5a-a427bc89af1a")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { resolveRuntimeStatusRegistry, statusIsTerminal, EXIT_CODE, PmCliError, toItemRecord, mutateItem, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
9
10
  import { wrapOwnershipConflict } from "../annotations.js";
10
11
  import { describeItemOwnershipConflict } from "../ownership-source.js";
11
12
  import { runNext, } from "../query/next.js";
@@ -26,9 +27,7 @@ export function isAlreadyClaimedError(error) {
26
27
  /** Implements run claim for the public runtime surface of this module. */
27
28
  export async function runClaim(id, force, global, options = {}) {
28
29
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
29
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
30
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
31
- }
30
+ await assertInitializedTracker(pmRoot);
32
31
  const settings = await readSettings(pmRoot);
33
32
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
34
33
  const author = resolveAuthor(options.author, settings.author_default);
@@ -184,9 +183,7 @@ export async function claimNextFromRecommendations(recommendations, force, globa
184
183
  /** Implements run release for the public runtime surface of this module. */
185
184
  export async function runRelease(id, force, global, options = {}) {
186
185
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
187
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
188
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
189
- }
186
+ await assertInitializedTracker(pmRoot);
190
187
  const settings = await readSettings(pmRoot);
191
188
  const author = resolveAuthor(options.author, settings.author_default);
192
189
  const claimPrincipal = resolveClaimPrincipal(author);
@@ -237,4 +234,4 @@ export async function runRelease(id, force, global, options = {}) {
237
234
  };
238
235
  }
239
236
  //# sourceMappingURL=claim.js.map
240
- //# debugId=f70f1329-4dfb-5625-ae0a-66c858d88f7b
237
+ //# debugId=1a61bf25-e320-5adc-8f5a-a427bc89af1a
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/close-many
3
- *
4
- * Implements the pm close many command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions, readSettings } from "../runtime-primitives.js";
7
2
  import { type ListOptions } from "../query/list.js";
8
3
  import { type PmCommandEffectReceipt } from "../cli-contracts/command-exit-contracts.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm close many 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]="4da07a98-855e-59cf-a6a4-2f59a8b3c0bd")}catch(e){}}();
8
- import { pathExists, createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, resolveAuthor, nowIso, listAllItemMetadataLight, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.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]="a7113374-b169-5f92-9c20-075a47520440")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, resolveAuthor, nowIso, listAllItemMetadataLight, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
10
  import { runClose } from "./close.js";
10
11
  import { hasListFilters } from "../query/list-filter-shared.js";
11
12
  import { runList } from "../query/list.js";
@@ -336,9 +337,7 @@ async function resolveCloseManyCheckpointInfo(params) {
336
337
  /** Implements run close many for the public runtime surface of this module. */
337
338
  export async function runCloseMany(options, global) {
338
339
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
339
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
340
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
341
- }
340
+ await assertInitializedTracker(pmRoot);
342
341
  const settings = await readSettings(pmRoot);
343
342
  const dryRun = options.dryRun === true;
344
343
  const rollbackId = resolveCloseManyRollbackId(options);
@@ -428,4 +427,4 @@ export const _testOnly = {
428
427
  resolveReason,
429
428
  };
430
429
  //# sourceMappingURL=close-many.js.map
431
- //# debugId=4da07a98-855e-59cf-a6a4-2f59a8b3c0bd
430
+ //# debugId=a7113374-b169-5f92-9c20-075a47520440
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/close
3
- *
4
- * Implements the pm close command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { collectBlockedByIds } from "../actionability.js";
8
3
  import { type CloseOperationOptions, type CloseOperationResult } from "../lifecycle-policy.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm close 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]="83affe54-a56c-5d84-b6b0-9634d4238ff5")}catch(e){}}();
8
- import { pathExists, toItemRecord, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, mutateItem, readLocatedItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveIsoOrRelative, shouldCompletePlanOnClose, getActiveExtensionRegistrations, } from "../runtime-primitives.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]="781b5118-7b07-53c7-802f-c889cb797a96")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { toItemRecord, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, mutateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, resolveIsoOrRelative, shouldCompletePlanOnClose, getActiveExtensionRegistrations, } from "../runtime-primitives.js";
9
10
  import { collectBlockedByIds, indexBlockedByIds } from "../actionability.js";
10
11
  import { applyTerminalOrderingPolicy, requireTerminalReason, } from "../lifecycle-policy.js";
11
12
  import { renderPmCommand } from "../command-line.js";
@@ -367,9 +368,7 @@ export const _testOnlyCloseCommand = {
367
368
  /** Close one item through the SDK-owned lifecycle transaction and policy. */
368
369
  export async function closeItem(id, closeReasonText, options, global) {
369
370
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
370
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
371
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
372
- }
371
+ await assertInitializedTracker(pmRoot);
373
372
  const settings = await readSettings(pmRoot);
374
373
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
375
374
  const author = resolveAuthor(options.author, settings.author_default);
@@ -458,4 +457,4 @@ export function runClose(id, closeReasonText, options, global) {
458
457
  return closeItem(id, closeReasonText, options, global);
459
458
  }
460
459
  //# sourceMappingURL=close.js.map
461
- //# debugId=83affe54-a56c-5d84-b6b0-9634d4238ff5
460
+ //# debugId=781b5118-7b07-53c7-802f-c889cb797a96
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/copy
3
- *
4
- * Implements the SDK-owned copy lifecycle operation shared by every surface.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type SimilarityAdvisory } from "../similarity.js";
8
3
  import type { ItemMetadata } from "../../types/index.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the SDK-owned copy lifecycle operation 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]="4eb2056a-4444-514a-a0db-79b8875c3d65")}catch(e){}}();
8
- import { pathExists, removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, canonicalDocument, serializeItemDocument, acquireLock, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, collectRegisteredItemFieldNames, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, nowIso, PmCliError, resolveItemTypeRegistry, buildItemNotFoundError, locateItem, readLocatedItem, getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.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]="b59e8e54-f9e0-5cdb-bc59-6dcbf67f278d")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, canonicalDocument, serializeItemDocument, acquireLock, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, collectRegisteredItemFieldNames, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, nowIso, PmCliError, resolveItemTypeRegistry, buildItemNotFoundError, locateItem, readLocatedItem, getHistoryPath, getItemPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { evaluateSimilarityGovernance, similarityAdvisoryWarnings, } from "../similarity.js";
10
11
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../item-metadata-index.js";
11
12
  function buildChangedFields(itemMetadata, body) {
@@ -29,9 +30,7 @@ function buildCopyMessage(sourceId, message) {
29
30
  /** Implements run copy for the public runtime surface of this module. */
30
31
  export async function runCopy(sourceId, options, global) {
31
32
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
32
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
33
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
34
- }
33
+ await assertInitializedTracker(pmRoot);
35
34
  const settings = await readSettings(pmRoot);
36
35
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
37
36
  const located = await locateItem(pmRoot, sourceId, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
@@ -211,4 +210,4 @@ export async function runCopy(sourceId, options, global) {
211
210
  };
212
211
  }
213
212
  //# sourceMappingURL=copy.js.map
214
- //# debugId=4eb2056a-4444-514a-a0db-79b8875c3d65
213
+ //# debugId=b59e8e54-f9e0-5cdb-bc59-6dcbf67f278d
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/create
3
- *
4
- * Implements the pm create command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type ResolvedItemTypeDefinition, type RuntimeFieldRegistry, type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type SimilarityAdvisory } from "../similarity.js";
8
3
  import { type LifecycleTransitionSuggestion } from "./lifecycle-transitions.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm create 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]="7d69bb56-9fab-5059-9357-5b6bea2078b9")}catch(e){}}();
8
- import { pathExists, removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, normalizeItemId, canonicalDocument, normalizeItemMetadata, serializeItemDocument, assertParentReferenceIsNotSelf, isPlaceholderReferenceToken, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, resolvePriority, getFocusedItem, normalizeStatusInput, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, acquireLock, printError, buildInvalidTypeError, resolveTypeSynonym, collectRuntimeCreateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, PmCliError, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveCommandHandler, runActiveBeforeMutationHooks, runActiveOnWriteHooks, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, listAllItemMetadataLight, locateItem, createMutationGuardSdk, getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.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]="a10348fe-746d-5dc7-8cd4-30453c602a3f")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, normalizeItemId, canonicalDocument, normalizeItemMetadata, serializeItemDocument, assertParentReferenceIsNotSelf, isPlaceholderReferenceToken, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, resolvePriority, getFocusedItem, normalizeStatusInput, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, acquireLock, printError, buildInvalidTypeError, resolveTypeSynonym, collectRuntimeCreateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, PmCliError, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveCommandHandler, runActiveBeforeMutationHooks, runActiveOnWriteHooks, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, listAllItemMetadataLight, locateItem, createMutationGuardSdk, getHistoryPath, getItemPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { requireTerminalReasonWithRecovery } from "../lifecycle-policy.js";
10
11
  import { evaluateSimilarityGovernance, similarityAdvisoryWarnings, } from "../similarity.js";
11
12
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../item-metadata-index.js";
@@ -837,12 +838,7 @@ async function loadCreateTemplateOptionsFromRuntime(templateName, global, pmRoot
837
838
  return readTemplateOptionsFromRuntimeResult(handlerResult.result, templateName);
838
839
  }
839
840
  function ensureInitHasRun(pmRoot) {
840
- return pathExists(getSettingsPath(pmRoot)).then((exists) => {
841
- /* c8 ignore next -- init guard failures are covered by top-level create command tests. */
842
- if (!exists) {
843
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
844
- }
845
- });
841
+ return assertInitializedTracker(pmRoot);
846
842
  }
847
843
  /**
848
844
  * Resolve an optional string item-metadata field for {@link runCreate}: yields
@@ -1890,4 +1886,4 @@ export const _testOnlyCreateCommand = {
1890
1886
  typeOptionExampleValue,
1891
1887
  };
1892
1888
  //# sourceMappingURL=create.js.map
1893
- //# debugId=7d69bb56-9fab-5059-9357-5b6bea2078b9
1889
+ //# debugId=a10348fe-746d-5dc7-8cd4-30453c602a3f
@@ -4,15 +4,14 @@
4
4
  * Implements the SDK-owned delete lifecycle operation 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]="14aa55e1-cb5f-55ea-bf4c-412217d87449")}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]="7819b53c-b0e4-50b0-a670-f80b36765085")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
8
9
  import path from "node:path";
9
- import { pathExists, EXIT_CODE, PmCliError, toItemRecord, deleteItem, getHistoryPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
+ import { toItemRecord, deleteItem, getHistoryPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
11
  /** Implements run delete for the public runtime surface of this module. */
11
12
  export async function runDelete(id, options, global) {
12
13
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
13
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
14
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
15
- }
14
+ await assertInitializedTracker(pmRoot);
16
15
  const settings = await readSettings(pmRoot);
17
16
  const author = resolveAuthor(options.author, settings.author_default);
18
17
  const result = await deleteItem({
@@ -44,4 +43,4 @@ export async function runDelete(id, options, global) {
44
43
  };
45
44
  }
46
45
  //# sourceMappingURL=delete.js.map
47
- //# debugId=14aa55e1-cb5f-55ea-bf4c-412217d87449
46
+ //# debugId=7819b53c-b0e4-50b0-a670-f80b36765085
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/focus
3
- *
4
- * Implements the SDK-owned focus lifecycle operation shared by every surface.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  /** Documents the focus options payload exchanged by command, SDK, and package integrations. */
8
3
  export interface FocusOptions {
@@ -4,13 +4,12 @@
4
4
  * Implements the SDK-owned focus lifecycle operation 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]="0f43df79-0b27-53b3-b8bd-9f2a35561733")}catch(e){}}();
8
- import { pathExists, getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, EXIT_CODE, PmCliError, clearFocusedItem, getFocusedItem, setFocusedItem, buildItemNotFoundError, locateItem, readLocatedItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.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]="a5ddb139-9780-50e0-87a5-621913cb0de4")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, EXIT_CODE, PmCliError, clearFocusedItem, getFocusedItem, setFocusedItem, buildItemNotFoundError, locateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
9
10
  import { recordFocusSemanticAttribution } from "../context/semantic-session-attribution.js";
10
11
  async function ensureInitialized(pmRoot) {
11
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
12
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
13
- }
12
+ await assertInitializedTracker(pmRoot);
14
13
  }
15
14
  /** Implements run focus for the public runtime surface of this module. */
16
15
  export async function runFocus(id, options, global) {
@@ -90,4 +89,4 @@ function nonEmptyTitleOrNull(title) {
90
89
  return title.trim().length > 0 ? title : null;
91
90
  }
92
91
  //# sourceMappingURL=focus.js.map
93
- //# debugId=0f43df79-0b27-53b3-b8bd-9f2a35561733
92
+ //# debugId=a5ddb139-9780-50e0-87a5-621913cb0de4
@@ -0,0 +1,18 @@
1
+ import type { GlobalOptions } from "../../core/shared/command-types.js";
2
+ /** Minimal generic dispatch context consumed by lifecycle mutation adapters. */
3
+ export interface LifecycleMutationActionContext {
4
+ /** Flat MCP/action arguments. */
5
+ args: Record<string, unknown>;
6
+ /** Normalized command option bag. */
7
+ options: Record<string, unknown>;
8
+ /** Item id resolved from flat arguments, when present. */
9
+ id: string | undefined;
10
+ /** Normalized transport-level force override. */
11
+ force?: boolean;
12
+ /** Presentation-neutral global command options. */
13
+ global: GlobalOptions;
14
+ }
15
+ /** Dispatch close through the shared MCP mutation compaction contract. */
16
+ export declare function runMcpCloseAction(context: LifecycleMutationActionContext): Promise<unknown>;
17
+ /** Dispatch recurrence through the shared MCP mutation compaction contract. */
18
+ export declare function runMcpReopenAction(context: LifecycleMutationActionContext): Promise<unknown>;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @module sdk/runtime-mutation-actions
3
+ *
4
+ * Keeps lifecycle-specific MCP mutation adapters outside the generic runtime
5
+ * dispatcher while preserving the shared token-efficient result projection.
6
+ */
7
+
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="55869854-565d-52d2-8dca-b66aade074bb")}catch(e){}}();
9
+ import { projectMutationResult } from "../../core/output/mutation-projection.js";
10
+ import { PmCliError } from "../../core/shared/errors.js";
11
+ import { runClose } from "./close.js";
12
+ import { runReopen } from "./reopen.js";
13
+ import { readRuntimeString, withMutationCompaction } from "../runtime-input.js";
14
+ function requireLifecycleItemId(context, options) {
15
+ const id = context.id ?? readRuntimeString(options, "id");
16
+ if (!id) {
17
+ throw new PmCliError("Missing required argument: id", 64);
18
+ }
19
+ return id;
20
+ }
21
+ function readLifecycleReason(context, options) {
22
+ return (readRuntimeString(context.args, "reason") ??
23
+ readRuntimeString(context.args, "text") ??
24
+ readRuntimeString(options, "reason") ??
25
+ readRuntimeString(options, "text"));
26
+ }
27
+ /** Dispatch close through the shared MCP mutation compaction contract. */
28
+ export async function runMcpCloseAction(context) {
29
+ const { changedFields, idOnly, runnerOptions } = withMutationCompaction(context.args, context.options);
30
+ return projectMutationResult(await runClose(requireLifecycleItemId(context, runnerOptions), readLifecycleReason(context, runnerOptions), {
31
+ ...runnerOptions,
32
+ force: context.force === true || runnerOptions.force === true,
33
+ }, context.global), {
34
+ changedFields,
35
+ compactEnvelope: changedFields === "compact" && !idOnly,
36
+ idOnly,
37
+ });
38
+ }
39
+ /** Dispatch recurrence through the shared MCP mutation compaction contract. */
40
+ export async function runMcpReopenAction(context) {
41
+ const { changedFields, idOnly, runnerOptions } = withMutationCompaction(context.args, context.options);
42
+ return projectMutationResult(await runReopen(requireLifecycleItemId(context, runnerOptions), readLifecycleReason(context, runnerOptions) ?? "", {
43
+ ...runnerOptions,
44
+ force: context.force === true || runnerOptions.force === true,
45
+ }, context.global), {
46
+ changedFields,
47
+ compactEnvelope: changedFields === "compact" && !idOnly,
48
+ idOnly,
49
+ });
50
+ }
51
+ //# sourceMappingURL=mcp-actions.js.map
52
+ //# debugId=55869854-565d-52d2-8dca-b66aade074bb
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/plan
3
- *
4
- * Implements the pm plan command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import type { DependencyKind, ItemMetadata, PlanDecision, PlanDiscovery, PlanHarness, PlanMode, PlanStep, PlanStepStatus, PlanValidationCheck } from "../../types/index.js";
8
3
  import type { MutationMetadataCommandOptions, SharedLinkedResourceOptions } from "./mutation-command-options.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm plan 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]="3d5ea029-26ef-51bc-bacc-b1d4d807a024")}catch(e){}}();
8
- import { pathExists, getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, resolveTypeName, EXIT_CODE, PmCliError, splitCommaList, nowIso, locateItem, mutateItem, readLocatedItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, isTerminalPlanMode, } from "../runtime-primitives.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]="49fd5730-99c2-5a93-a80e-83c806a124bf")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, resolveTypeName, EXIT_CODE, PmCliError, splitCommaList, nowIso, locateItem, mutateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, isTerminalPlanMode, } from "../runtime-primitives.js";
9
10
  import { PLAN_HARNESS_VALUES, PLAN_MODE_VALUES, PLAN_STEP_LINK_KIND_VALUES, PLAN_STEP_STATUS_VALUES, } from "../../types/index.js";
10
11
  import { runCreate, } from "./create.js";
11
12
  import { createUnknownSubcommandError } from "../agent/subcommand-recovery.js";
@@ -547,9 +548,7 @@ function ensurePlanItem(item) {
547
548
  }
548
549
  async function loadContext(global) {
549
550
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
550
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
551
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
552
- }
551
+ await assertInitializedTracker(pmRoot);
553
552
  const settings = await readSettings(pmRoot);
554
553
  return { pmRoot, settings };
555
554
  }
@@ -1587,4 +1586,4 @@ export const _testOnlyPlanCommand = {
1587
1586
  changedPlanMetadataFields,
1588
1587
  };
1589
1588
  //# sourceMappingURL=plan.js.map
1590
- //# debugId=3d5ea029-26ef-51bc-bacc-b1d4d807a024
1589
+ //# debugId=49fd5730-99c2-5a93-a80e-83c806a124bf
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @module sdk/lifecycle/reopen
3
+ *
4
+ * Reopens terminal work as a recurrence while preserving immutable closure
5
+ * evidence and delegating every state change to the canonical update pipeline.
6
+ */
7
+ import type { GlobalOptions } from "../../core/shared/command-types.js";
8
+ import { type PreviousTerminalEvidence } from "./update.js";
9
+ export type { PreviousTerminalEvidence } from "./update.js";
10
+ /** Options accepted by the SDK and `pm item reopen` recurrence primitive. */
11
+ export interface ReopenCommandOptions {
12
+ /** Active target status; only the workspace open or in-progress status is allowed. */
13
+ status?: string;
14
+ /** Explicit mutation author override. */
15
+ author?: string;
16
+ /** Optional human-readable history message in addition to structured recurrence context. */
17
+ message?: string;
18
+ /** Override an ownership or stale-lock conflict. */
19
+ force?: boolean;
20
+ }
21
+ /** Structured recurrence receipt returned by every presentation surface. */
22
+ export interface RecurrenceReceipt {
23
+ /** Required reason that the terminal work became active again. */
24
+ reason: string;
25
+ /** Terminal status observed while holding the item lock. */
26
+ from_status: string;
27
+ /** Active status written through the update pipeline. */
28
+ to_status: string;
29
+ /** Prior terminal evidence retained in immutable history. */
30
+ previous_terminal: PreviousTerminalEvidence;
31
+ }
32
+ /** Result returned after a terminal item is reopened. */
33
+ export interface ReopenResult {
34
+ /** Reopened item metadata. */
35
+ item: Record<string, unknown>;
36
+ /** Fields changed by the canonical update pipeline. */
37
+ changed_fields: string[];
38
+ /** Non-fatal mutation and extension warnings. */
39
+ warnings: string[];
40
+ /** Immutable recurrence transition receipt. */
41
+ recurrence: RecurrenceReceipt;
42
+ }
43
+ /** Reopen terminal work through the canonical update mutation and history path. */
44
+ export declare function runReopen(id: string, reason: string, options: ReopenCommandOptions, global: GlobalOptions): Promise<ReopenResult>;
@@ -0,0 +1,69 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="08dcee99-5572-5133-b76a-6a50e4e292e7")}catch(e){}}();
3
+ import { EXIT_CODE } from "../../core/shared/constants.js";
4
+ import { PmCliError } from "../../core/shared/errors.js";
5
+ import { normalizeStatusInput } from "../../core/item/status.js";
6
+ import { resolveRuntimeStatusRegistry } from "../../core/schema/runtime-schema.js";
7
+ import { resolvePmRoot } from "../../core/store/paths.js";
8
+ import { readSettings } from "../../core/store/settings.js";
9
+ import { resolveStartTaskInProgressStatus } from "../start-task-status.js";
10
+ import { runReopenUpdate, } from "./update.js";
11
+ /** Reopen terminal work through the canonical update mutation and history path. */
12
+ export async function runReopen(id, reason, options, global) {
13
+ const normalizedReason = reason.trim();
14
+ if (normalizedReason.length === 0) {
15
+ throw new PmCliError("pm item reopen requires a non-empty recurrence reason.", EXIT_CODE.USAGE, {
16
+ code: "reopen_reason_required",
17
+ required: "Describe why the terminal work became active again.",
18
+ recovery: {
19
+ suggested_retry: `pm item reopen ${id} "<recurrence reason>"`,
20
+ suggested_retry_args: ["item", "reopen", id, "<recurrence reason>"],
21
+ },
22
+ });
23
+ }
24
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
25
+ const statusRegistry = resolveRuntimeStatusRegistry((await readSettings(pmRoot)).schema);
26
+ const openStatus = statusRegistry.open_status;
27
+ const inProgressStatus = resolveStartTaskInProgressStatus(statusRegistry);
28
+ const requestedStatus = options.status ?? openStatus;
29
+ const targetStatus = normalizeStatusInput(requestedStatus, statusRegistry) ?? requestedStatus;
30
+ if (targetStatus !== openStatus && targetStatus !== inProgressStatus) {
31
+ throw new PmCliError(`Reopen target status must be ${openStatus} or ${inProgressStatus}; received ${requestedStatus}.`, EXIT_CODE.USAGE, {
32
+ code: "reopen_target_status_invalid",
33
+ required: "Choose the workspace open or in-progress lifecycle status.",
34
+ recovery: {
35
+ allowed_values: [...new Set([openStatus, inProgressStatus])],
36
+ suggested_retry: `pm item reopen ${id} "${normalizedReason}" --status ${openStatus}`,
37
+ suggested_retry_args: [
38
+ "item",
39
+ "reopen",
40
+ id,
41
+ normalizedReason,
42
+ "--status",
43
+ openStatus,
44
+ ],
45
+ },
46
+ });
47
+ }
48
+ const update = await runReopenUpdate(id, {
49
+ status: targetStatus,
50
+ unset: [
51
+ "close-reason",
52
+ "resolution",
53
+ "expected-result",
54
+ "actual-result",
55
+ "fixed-version",
56
+ ],
57
+ author: options.author,
58
+ message: options.message,
59
+ force: options.force,
60
+ }, global, normalizedReason);
61
+ return {
62
+ item: update.item,
63
+ changed_fields: update.changed_fields,
64
+ warnings: update.warnings,
65
+ recurrence: update.lifecycle_transition,
66
+ };
67
+ }
68
+ //# sourceMappingURL=reopen.js.map
69
+ //# debugId=08dcee99-5572-5133-b76a-6a50e4e292e7
@@ -4,10 +4,11 @@
4
4
  * Implements the SDK-owned restore lifecycle operation 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]="353be665-9f67-5d0e-99c9-6bbb7e927e0b")}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]="db5f3a6d-9ae5-5f9b-bedf-766b2b79324c")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
8
9
  import jsonPatch from "fast-json-patch";
9
10
  import fs from "node:fs/promises";
10
- import { pathExists, readFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, enforceHistoryStreamPolicyForItem, normalizeItemId, normalizeRawItemId, canonicalDocument, serializeItemDocument, resolveItemTypeRegistry, acquireLock, EXIT_CODE, PmCliError, nowIso, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, runActiveBeforeMutationHooks, locateItem, createMutationGuardSdk, readLocatedItem, getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
11
+ import { pathExists, readFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, replayToCanonicalItemDocument, replayToItemDocument, toReplayDocument, enforceHistoryStreamPolicyForItem, normalizeItemId, normalizeRawItemId, canonicalDocument, serializeItemDocument, resolveItemTypeRegistry, acquireLock, EXIT_CODE, PmCliError, nowIso, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, runActiveBeforeMutationHooks, locateItem, createMutationGuardSdk, readLocatedItem, getHistoryPath, getItemPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
11
12
  import { applyHistoryPatch, ensureMaterializedHistoryTarget as ensureMaterializedRestoreTarget, extractPatchFailureContext, readHistoryEntries, replayHistoryToTarget as replayToTarget, resolveHistoryTarget, } from "../history-read.js";
12
13
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../item-metadata-index.js";
13
14
  /** Resolve restore targets with the command's established wording and at-or-before timestamp semantics. */
@@ -163,9 +164,7 @@ async function runRestoreWriteHooks(params) {
163
164
  /** Implements run restore for the public runtime surface of this module. */
164
165
  export async function runRestore(id, target, options, global) {
165
166
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
166
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
167
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
168
- }
167
+ await assertInitializedTracker(pmRoot);
169
168
  const settings = await readSettings(pmRoot);
170
169
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
171
170
  const subject = await resolveRestoreSubject(pmRoot, id, settings, typeRegistry.type_to_folder);
@@ -317,4 +316,4 @@ export const _testOnlyRestoreCommand = {
317
316
  resolveRestoreSubject,
318
317
  };
319
318
  //# sourceMappingURL=restore.js.map
320
- //# debugId=353be665-9f67-5d0e-99c9-6bbb7e927e0b
319
+ //# debugId=db5f3a6d-9ae5-5f9b-bedf-766b2b79324c
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/update-many
3
- *
4
- * Implements the pm update many command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type RuntimeFieldRegistry, type RuntimeStatusRegistry, type GlobalOptions } from "../runtime-primitives.js";
7
2
  import type { ItemStatus, PmSettings } from "../../types/index.js";
8
3
  import { hasListFilters } from "../query/list-filter-shared.js";