@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 update 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]="e797d654-df89-554b-876b-cb2faa350bd0")}catch(e){}}();
8
- import { pathExists, createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, toItemRecord, applyAcceptanceCriteriaMutations, applyTagRemovals, mergeAdditiveTags, parseOptionalNonNegativeInteger, parseTags, splitAcceptanceCriteria, resolvePriority, normalizeStatusInput, resolveItemTypeRegistry, resolveTypeName, collectRuntimeUpdateFieldValues, buildInvalidTypeError, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, stableValueEquals, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, 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]="7a157c2e-e9e6-5bce-b124-0a7d34e3c7dc")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, toItemRecord, applyAcceptanceCriteriaMutations, applyTagRemovals, mergeAdditiveTags, parseOptionalNonNegativeInteger, parseTags, splitAcceptanceCriteria, resolvePriority, normalizeStatusInput, resolveItemTypeRegistry, resolveTypeName, collectRuntimeUpdateFieldValues, buildInvalidTypeError, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, stableValueEquals, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { assertDependencyTargetsResolvable } from "../dependency-flag-validation.js";
10
11
  import { parseStatusFilterCsv } from "../../core/item/status-filter.js";
11
12
  import { hasListFilters } from "../query/list-filter-shared.js";
@@ -588,9 +589,7 @@ const buildUnmatchedIdFields = (plan) => plan.unmatchedIds === undefined
588
589
  /** Loads tracker settings and runtime registries for update-many execution. */
589
590
  const loadUpdateManyRuntimeContext = async (global) => {
590
591
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
591
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
592
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
593
- }
592
+ await assertInitializedTracker(pmRoot);
594
593
  const settings = await readSettings(pmRoot);
595
594
  return {
596
595
  pmRoot,
@@ -853,4 +852,4 @@ export const _testOnlyUpdateManyCommand = {
853
852
  toComparablePreviewValue,
854
853
  };
855
854
  //# sourceMappingURL=update-many.js.map
856
- //# debugId=e797d654-df89-554b-876b-cb2faa350bd0
855
+ //# debugId=7a157c2e-e9e6-5bce-b124-0a7d34e3c7dc
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/update
3
- *
4
- * Implements the pm update command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { resolveItemTypeRegistry, type RuntimeFieldRegistry, type RuntimeStatusRegistry, type NormalizedTypeWorkflow, type GlobalOptions, PmCliError, getActiveExtensionRegistrations, readSettings } from "../runtime-primitives.js";
7
2
  import type { Dependency, GovernanceWorkflowEnforcement, ItemDocument } from "../../types/index.js";
8
3
  import { DEPENDENCY_KIND_VALUES } from "../../types/index.js";
@@ -67,6 +62,35 @@ export interface UpdateResult {
67
62
  /** Value that configures or reports warnings for this contract. */
68
63
  warnings: string[];
69
64
  }
65
+ /** Terminal evidence captured atomically before a recurrence transition. */
66
+ export interface PreviousTerminalEvidence {
67
+ /** Prior close reason, when recorded. */
68
+ close_reason?: string;
69
+ /** Prior structured resolution, when recorded. */
70
+ resolution?: string;
71
+ /** Prior expected result, when recorded. */
72
+ expected_result?: string;
73
+ /** Prior actual result, when recorded. */
74
+ actual_result?: string;
75
+ /** Prior fixed version, when recorded. */
76
+ fixed_version?: string;
77
+ }
78
+ /** Internal update-path receipt consumed by the public recurrence primitive. */
79
+ export interface ReopenUpdateReceipt {
80
+ /** Recurrence reason stored in immutable history context. */
81
+ reason: string;
82
+ /** Terminal status observed while holding the item lock. */
83
+ from_status: string;
84
+ /** Active status written by the update path. */
85
+ to_status: string;
86
+ /** Terminal evidence removed from active metadata but retained in history. */
87
+ previous_terminal: PreviousTerminalEvidence;
88
+ }
89
+ /** Update result carrying the recurrence receipt produced by the locked transition. */
90
+ export interface ReopenUpdateResult extends UpdateResult {
91
+ /** Lifecycle-specific receipt populated by the recurrence primitive. */
92
+ lifecycle_transition: ReopenUpdateReceipt;
93
+ }
70
94
  declare function normalizeLegacyNoneUpdateOptions(options: UpdateCommandOptions): UpdateCommandOptions;
71
95
  declare function parseUpdateUnsetTargets(raw: string[] | undefined, runtimeFieldRegistry?: RuntimeFieldRegistry, extensionFieldNames?: readonly string[]): {
72
96
  metadataKeys: Set<string>;
@@ -139,6 +163,8 @@ type UpdateStatusMutationContext = Pick<UpdateMutationContext, "options" | "stat
139
163
  declare function applyStatusAndCloseReasonMutations(document: ItemDocument, context: UpdateStatusMutationContext, previousStatusNormalized: string, changedFields: string[]): void;
140
164
  /** Implements run update for the public runtime surface of this module. */
141
165
  export declare function runUpdate(id: string, options: UpdateCommandOptions, global: GlobalOptions): Promise<UpdateResult>;
166
+ /** Execute a recurrence transition through the exact atomic update pipeline. */
167
+ export declare function runReopenUpdate(id: string, options: UpdateCommandOptions, global: GlobalOptions, recurrenceReason: string): Promise<ReopenUpdateResult>;
142
168
  /** Public contract for test only update command, shared by SDK and presentation-layer consumers. */
143
169
  export declare const _testOnlyUpdateCommand: {
144
170
  applyStatusAndCloseReasonMutations: typeof applyStatusAndCloseReasonMutations;
@@ -4,8 +4,10 @@
4
4
  * Implements the pm update 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]="a421c150-13a9-5334-85a4-5b3199a5d2c7")}catch(e){}}();
8
- import { pathExists, COMMON_MUTATION_COMMAND_OPTION_KEYS, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, normalizeItemId, toItemRecord, buildInvalidTypeError, assertParentReferenceIsNotSelf, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, applyAcceptanceCriteriaMutations, applyTagRemovals, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, splitAcceptanceCriteria, resolvePriority, normalizeStatusInput, isTerminalStatus, collectRuntimeUpdateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, describeAllowedTransitions, evaluateTransition, resolveTypeWorkflows, EXIT_CODE, PmCliError, stableValueEquals, resolveIsoOrRelative, getActiveExtensionRegistrations, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, buildItemNotFoundError, listAllItemMetadataLight, locateItem, mutateItem, readLocatedItem, 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]="d024d9cf-81f8-5690-b8f4-03620e3e9bf8")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { COMMON_MUTATION_COMMAND_OPTION_KEYS, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, normalizeItemId, toItemRecord, buildInvalidTypeError, assertParentReferenceIsNotSelf, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, applyAcceptanceCriteriaMutations, applyTagRemovals, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, splitAcceptanceCriteria, resolvePriority, normalizeStatusInput, isTerminalStatus, collectRuntimeUpdateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, describeAllowedTransitions, evaluateTransition, resolveTypeWorkflows, EXIT_CODE, PmCliError, stableValueEquals, resolveIsoOrRelative, getActiveExtensionRegistrations, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, buildItemNotFoundError, listAllItemMetadataLight, locateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
+ import { mutateItemWithHistoryContextResolver } from "../../core/store/item-store.js";
9
11
  import { runClose } from "./close.js";
10
12
  import { normalizeRiskInput, normalizeSeverityInput, parseConfidenceInput, parseRegressionInput, } from "./metadata-normalizers.js";
11
13
  import { applyLegacyNoneCollectionNormalizers, createLegacyNoneCollectionNormalizers, assertNoLegacyNoneToken, assertNoLegacyNoneTokens, isLegacyNoneToken, } from "./legacy-none-tokens.js";
@@ -439,9 +441,9 @@ function parseDependencyRemovals(raw, prefix) {
439
441
  if (!trimmed) {
440
442
  throw new PmCliError("--dep-remove requires id or key/value selectors", EXIT_CODE.USAGE);
441
443
  }
442
- if (trimmed.includes("=") ||
443
- /^(?:[-*+]\s+)?(?:id|kind|type|source_kind)\s*[:=]/i.test(trimmed) ||
444
- trimmed.startsWith("```")) {
444
+ const isStructured = looksLikeStructuredDependencyEntry(trimmed);
445
+ assertValidBareDependencyFlagValue(trimmed, isStructured, "--dep-remove");
446
+ if (isStructured) {
445
447
  const kv = parseCsvKv(trimmed, "--dep-remove");
446
448
  assertNoUnknownCsvKeys(kv, "--dep-remove", DEP_REMOVE_KEYS);
447
449
  const idRaw = kv.id?.trim();
@@ -1081,9 +1083,7 @@ async function buildNoopUpdateResult(params) {
1081
1083
  };
1082
1084
  }
1083
1085
  async function assertUpdateTrackerInitialized(pmRoot) {
1084
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
1085
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1086
- }
1086
+ await assertInitializedTracker(pmRoot);
1087
1087
  }
1088
1088
  function assertMatchingOrderRank(options) {
1089
1089
  if (options.order !== undefined &&
@@ -1214,8 +1214,8 @@ function applyStatusMutation(document, context, statusInput, previousStatusNorma
1214
1214
  changedFields.push("closed_at", "completed_at");
1215
1215
  return;
1216
1216
  }
1217
- if (status !== context.statusRegistry.close_status &&
1218
- previousStatusNormalized === context.statusRegistry.close_status &&
1217
+ if (!isTerminalStatus(status, context.statusRegistry) &&
1218
+ isTerminalStatus(previousStatusNormalized, context.statusRegistry) &&
1219
1219
  document.metadata.closed_at !== undefined) {
1220
1220
  delete document.metadata.closed_at;
1221
1221
  changedFields.push("closed_at");
@@ -1254,8 +1254,8 @@ function applyCloseReasonMutations(document, context, previousStatusNormalized,
1254
1254
  return;
1255
1255
  }
1256
1256
  if (context.options.status !== undefined &&
1257
- previousStatusNormalized === context.statusRegistry.close_status &&
1258
- document.metadata.status !== context.statusRegistry.canceled_status &&
1257
+ isTerminalStatus(previousStatusNormalized, context.statusRegistry) &&
1258
+ !isTerminalStatus(document.metadata.status, context.statusRegistry) &&
1259
1259
  document.metadata.close_reason !== undefined) {
1260
1260
  delete document.metadata.close_reason;
1261
1261
  changedFields.push("close_reason");
@@ -1312,6 +1312,44 @@ function applyTypeOptionMutation(document, context, activeTypeName, changedField
1312
1312
  }
1313
1313
  document.metadata.type_options = validation.normalized;
1314
1314
  }
1315
+ /** Collapse duplicate rows only for identities explicitly touched by this mutation. */
1316
+ function normalizeTouchedDependencyIdentities(current, additions) {
1317
+ const touchedKeys = new Set(additions.map((entry) => dependencyKey(entry)));
1318
+ const retainedTouchedKeys = new Set();
1319
+ return current.filter((entry) => {
1320
+ const key = dependencyKey(entry);
1321
+ if (!touchedKeys.has(key)) {
1322
+ return true;
1323
+ }
1324
+ if (retainedTouchedKeys.has(key)) {
1325
+ return false;
1326
+ }
1327
+ retainedTouchedKeys.add(key);
1328
+ return true;
1329
+ });
1330
+ }
1331
+ /** Refuse lossless removals unless every selector resolves against stored edges. */
1332
+ function assertDependencyRemovalSelectorsMatch(current, selectors, itemId) {
1333
+ const unmatchedSelectors = selectors.filter((selector) => !current.some((entry) => matchesDependencySelector(entry, selector)));
1334
+ if (unmatchedSelectors.length === 0) {
1335
+ return;
1336
+ }
1337
+ throw new PmCliError(`Dependency removal did not match ${unmatchedSelectors.length === 1 ? "a stored edge" : "stored edges"}.`, EXIT_CODE.NOT_FOUND, {
1338
+ code: "dependency_remove_no_match",
1339
+ reason: "selector_not_found",
1340
+ unmatched_selectors: unmatchedSelectors,
1341
+ available_dependencies: current.map((entry) => ({
1342
+ id: entry.id,
1343
+ kind: entry.kind,
1344
+ source_kind: entry.source_kind,
1345
+ })),
1346
+ why: "Failing on a zero-match selector prevents a mistyped dependency removal from being reported as successful.",
1347
+ nextSteps: [
1348
+ `Inspect the current item with: pm get ${itemId} --full`,
1349
+ "Retry --dep-remove with the exact id, kind, and optional source_kind shown in dependencies.",
1350
+ ],
1351
+ });
1352
+ }
1315
1353
  function applyDependencyMutations(document, context, changedFields) {
1316
1354
  if (context.options.dep === undefined &&
1317
1355
  context.options.depRemove === undefined &&
@@ -1322,6 +1360,7 @@ function applyDependencyMutations(document, context, changedFields) {
1322
1360
  ? []
1323
1361
  : [...(document.metadata.dependencies ?? [])];
1324
1362
  if (context.dependencyUpdates.additions.length > 0) {
1363
+ nextDependencies = normalizeTouchedDependencyIdentities(nextDependencies, context.dependencyUpdates.additions);
1325
1364
  const seen = new Set(nextDependencies.map((entry) => dependencyKey(entry)));
1326
1365
  for (const addition of context.dependencyUpdates.additions) {
1327
1366
  const key = dependencyKey(addition);
@@ -1332,6 +1371,7 @@ function applyDependencyMutations(document, context, changedFields) {
1332
1371
  }
1333
1372
  }
1334
1373
  if (context.dependencyRemovals.length > 0) {
1374
+ assertDependencyRemovalSelectorsMatch(nextDependencies, context.dependencyRemovals, document.metadata.id);
1335
1375
  nextDependencies = nextDependencies.filter((entry) => !context.dependencyRemovals.some((selector) => matchesDependencySelector(entry, selector)));
1336
1376
  }
1337
1377
  if (nextDependencies.length === 0) {
@@ -1700,7 +1740,7 @@ function mutateUpdateDocument(document, context) {
1700
1740
  return { changedFields: actualChangedFields, warnings };
1701
1741
  }
1702
1742
  /** Implements run update for the public runtime surface of this module. */
1703
- export async function runUpdate(id, options, global) {
1743
+ async function runUpdateWithContext(id, options, global, execution = {}) {
1704
1744
  options = await resolveStdinUpdateOptions(options);
1705
1745
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
1706
1746
  await assertUpdateTrackerInitialized(pmRoot);
@@ -1820,23 +1860,32 @@ export async function runUpdate(id, options, global) {
1820
1860
  let graphBeforeUpdate = fieldFlags.dep || fieldFlags.depRemove || fieldFlags.blockedBy
1821
1861
  ? await listAllItemMetadataLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, undefined, settings.schema)
1822
1862
  : undefined;
1823
- const result = await mutateItem({
1863
+ let lifecycleTransition;
1864
+ let recurrenceHistoryContext;
1865
+ const result = await mutateItemWithHistoryContextResolver({
1824
1866
  pmRoot,
1825
1867
  settings,
1826
1868
  typeToFolder: typeRegistry.type_to_folder,
1827
1869
  id,
1828
- op: options.ownershipMetadataBypass === true ||
1829
- options.ownershipDependencyBypass === true
1830
- ? "update_ownership_bypass"
1831
- : "update",
1870
+ op: resolveUpdateHistoryOperation(options, execution),
1832
1871
  author,
1833
1872
  message: options.message,
1873
+ resolveHistoryContext: () => recurrenceHistoryContext,
1834
1874
  force: options.force,
1835
1875
  bypassAssigneeConflict: options.ownershipMetadataBypass === true ||
1836
1876
  options.ownershipDependencyBypass === true,
1837
1877
  extensionFieldNames,
1838
1878
  skipNoop: true,
1839
1879
  mutate(document) {
1880
+ lifecycleTransition = prepareRecurrenceTransition({
1881
+ document,
1882
+ recurrenceReason: execution.recurrenceReason,
1883
+ requestedStatus: options.status,
1884
+ statusRegistry,
1885
+ });
1886
+ recurrenceHistoryContext = lifecycleTransition
1887
+ ? { recurrence: lifecycleTransition }
1888
+ : undefined;
1840
1889
  graphBeforeUpdate = graphBeforeUpdate?.map((item) => item.id === document.metadata.id
1841
1890
  ? structuredClone(document.metadata)
1842
1891
  : item);
@@ -1880,8 +1929,80 @@ export async function runUpdate(id, options, global) {
1880
1929
  ...orderingCycleWarnings,
1881
1930
  ...result.warnings,
1882
1931
  ],
1932
+ ...(lifecycleTransition === undefined
1933
+ ? {}
1934
+ : { lifecycle_transition: lifecycleTransition }),
1935
+ };
1936
+ }
1937
+ /** Resolve the immutable operation name for ordinary, bypass, and recurrence updates. */
1938
+ function resolveUpdateHistoryOperation(options, execution) {
1939
+ if (options.ownershipMetadataBypass === true ||
1940
+ options.ownershipDependencyBypass === true) {
1941
+ return "update_ownership_bypass";
1942
+ }
1943
+ return execution.recurrenceReason === undefined ? "update" : "reopen";
1944
+ }
1945
+ /** Validate and capture a terminal-to-active recurrence while the item lock is held. */
1946
+ function prepareRecurrenceTransition(params) {
1947
+ if (params.recurrenceReason === undefined) {
1948
+ return undefined;
1949
+ }
1950
+ const fromStatus = normalizeStatusInput(params.document.metadata.status, params.statusRegistry) ?? params.document.metadata.status;
1951
+ if (!isTerminalStatus(fromStatus, params.statusRegistry)) {
1952
+ throw new PmCliError(`Item ${params.document.metadata.id} is already active with status ${fromStatus}; recurrence transitions require a terminal item.`, EXIT_CODE.CONFLICT, {
1953
+ code: "item_already_active",
1954
+ reason: "recurrence_requires_terminal_item",
1955
+ required: "Use item reopen only for a terminal item whose work has recurred.",
1956
+ why: "Appending a recurrence event to active work would corrupt lifecycle history.",
1957
+ recovery: {
1958
+ suggested_retry: `pm get ${params.document.metadata.id} --full`,
1959
+ suggested_retry_args: ["get", params.document.metadata.id, "--full"],
1960
+ },
1961
+ nextSteps: [
1962
+ `Inspect the active item with: pm get ${params.document.metadata.id} --full`,
1963
+ `Continue the existing work with: pm update ${params.document.metadata.id} ...`,
1964
+ ],
1965
+ });
1966
+ }
1967
+ const requestedStatus = params.requestedStatus ?? params.statusRegistry.open_status;
1968
+ const toStatus = normalizeStatusInput(requestedStatus, params.statusRegistry) ??
1969
+ requestedStatus;
1970
+ const metadata = toItemRecord(params.document.metadata);
1971
+ const previousTerminal = Object.fromEntries([
1972
+ "close_reason",
1973
+ "resolution",
1974
+ "expected_result",
1975
+ "actual_result",
1976
+ "fixed_version",
1977
+ ].flatMap((key) => {
1978
+ const value = metadata[key];
1979
+ return typeof value === "string" ? [[key, value]] : [];
1980
+ }));
1981
+ return {
1982
+ reason: params.recurrenceReason,
1983
+ from_status: fromStatus,
1984
+ to_status: toStatus,
1985
+ previous_terminal: previousTerminal,
1883
1986
  };
1884
1987
  }
1988
+ /** Implements run update for the public runtime surface of this module. */
1989
+ export async function runUpdate(id, options, global) {
1990
+ return runUpdateWithContext(id, options, global);
1991
+ }
1992
+ /** Execute a recurrence transition through the exact atomic update pipeline. */
1993
+ export async function runReopenUpdate(id, options, global, recurrenceReason) {
1994
+ const result = await runUpdateWithContext(id, options, global, {
1995
+ recurrenceReason,
1996
+ });
1997
+ if (result.lifecycle_transition === undefined) {
1998
+ throw new PmCliError(`Item ${id} did not produce the required recurrence receipt.`, EXIT_CODE.GENERIC_FAILURE, {
1999
+ code: "reopen_receipt_missing",
2000
+ reason: "recurrence_transition_not_recorded",
2001
+ required: "A successful reopen must return the terminal-to-active lifecycle transition recorded in immutable history.",
2002
+ });
2003
+ }
2004
+ return { ...result, lifecycle_transition: result.lifecycle_transition };
2005
+ }
1885
2006
  /* c8 ignore stop */
1886
2007
  /** Public contract for test only update command, shared by SDK and presentation-layer consumers. */
1887
2008
  export const _testOnlyUpdateCommand = {
@@ -1900,4 +2021,4 @@ export const _testOnlyUpdateCommand = {
1900
2021
  resolveRuntimeUnsetDefinition: (token, registry) => resolveRuntimeUnsetFieldDefinition(token, "update", registry),
1901
2022
  };
1902
2023
  //# sourceMappingURL=update.js.map
1903
- //# debugId=a421c150-13a9-5334-85a4-5b3199a5d2c7
2024
+ //# debugId=d024d9cf-81f8-5690-b8f4-03620e3e9bf8
@@ -4,11 +4,12 @@
4
4
  * Implements the pm linked artifacts 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]="72f57c4d-65c5-57f1-a16a-f6c970aca680")}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]="1832e2b3-0ece-523d-8f38-598303d3f590")}catch(e){}}();
8
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
8
9
  import fs from "node:fs/promises";
9
10
  import path from "node:path";
10
11
  import fg from "fast-glob";
11
- import { isFileAbsentError, pathExists } from "../core/fs/fs-utils.js";
12
+ import { isFileAbsentError } from "../core/fs/fs-utils.js";
12
13
  import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
13
14
  import { assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, parseCsvKv, } from "../core/item/parse.js";
14
15
  import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
@@ -18,7 +19,7 @@ import { PmCliError } from "../core/shared/errors.js";
18
19
  import { splitCommaList } from "../core/shared/split-comma-list.js";
19
20
  import { stableValueEquals } from "../core/shared/serialization.js";
20
21
  import { locateItem, mutateItem, readLocatedItem, } from "../core/store/item-store.js";
21
- import { getSettingsPath, resolvePmRoot, resolveWorkspaceRoot, } from "../core/store/paths.js";
22
+ import { resolvePmRoot, resolveWorkspaceRoot, } from "../core/store/paths.js";
22
23
  import { readSettings } from "../core/store/settings.js";
23
24
  import { SCOPE_VALUES } from "../types/index.js";
24
25
  import { resolveAuthor } from "../core/shared/author.js";
@@ -450,9 +451,7 @@ export async function runLinkedArtifacts(id, options, global, config) {
450
451
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
451
452
  const workspaceRoot = resolveWorkspaceRoot(pmRoot);
452
453
  const invocationRoot = process.cwd();
453
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
454
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
455
- }
454
+ await assertInitializedTracker(pmRoot);
456
455
  const settings = await readSettings(pmRoot);
457
456
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
458
457
  const resolvedAdds = await stdinResolver.resolveList(options.add, "--add");
@@ -539,4 +538,4 @@ export function renameArtifactsResultKey(result, key) {
539
538
  return out;
540
539
  }
541
540
  //# sourceMappingURL=linked-artifacts.js.map
542
- //# debugId=72f57c4d-65c5-57f1-a16a-f6c970aca680
541
+ //# debugId=1832e2b3-0ece-523d-8f38-598303d3f590
@@ -8,7 +8,8 @@
8
8
  * mutations refresh the fenced block automatically once it is installed.
9
9
  */
10
10
 
11
- !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]="5e1810a5-04b8-5929-8eee-7a63f1684860")}catch(e){}}();
11
+ !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]="dea4137f-adbd-5dca-bfc7-b56c99c7aa79")}catch(e){}}();
12
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
12
13
  import { isFileMissingError } from "../../core/fs/fs-utils.js";
13
14
  import { readFile, realpath, writeFile } from "node:fs/promises";
14
15
  import { execFile } from "node:child_process";
@@ -22,7 +23,7 @@ import { EXIT_CODE } from "../../core/shared/constants.js";
22
23
  import { PmCliError } from "../../core/shared/errors.js";
23
24
  import { resolveAuthor } from "../../core/shared/author.js";
24
25
  import { nowIso } from "../../core/shared/time.js";
25
- import { getSettingsPath, resolvePmRoot } from "../../core/store/paths.js";
26
+ import { resolvePmRoot } from "../../core/store/paths.js";
26
27
  import { readSettings, resolveGovernanceKnobs, } from "../../core/store/settings.js";
27
28
  import { isPathOutsideRoot } from "../workspace.js";
28
29
  import { resolveSourceContextWritePolicy } from "../environment/source-context.js";
@@ -453,9 +454,7 @@ export async function runMergeInstall(options, global) {
453
454
  environment: process.env,
454
455
  });
455
456
  const pmRoot = context.pm_root;
456
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
457
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
458
- }
457
+ await assertInitializedTracker(pmRoot);
459
458
  const workspaceRoot = await resolveGitWorkspaceRoot(context.workspace_start);
460
459
  return installMergeFence({
461
460
  pmRoot,
@@ -561,4 +560,4 @@ export async function installMergeFence(options) {
561
560
  };
562
561
  }
563
562
  //# sourceMappingURL=install.js.map
564
- //# debugId=5e1810a5-04b8-5929-8eee-7a63f1684860
563
+ //# debugId=dea4137f-adbd-5dca-bfc7-b56c99c7aa79
@@ -5,15 +5,15 @@
5
5
  * history store without requiring a daemon or shell subprocess.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e8cd5790-eacf-5ef7-bc0a-11ea3fe17d2d")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="01043e67-99d4-5b68-a1b2-33f35f5cef5f")}catch(e){}}();
9
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
9
10
  import { createHash } from "node:crypto";
10
11
  import { setTimeout as delay } from "node:timers/promises";
11
12
  import { queryHistoryEventIndex, queryHistoryEventStreams, rebuildHistoryEventIndex, } from "../core/history/event-index.js";
12
- import { pathExists } from "../core/fs/fs-utils.js";
13
13
  import { EXIT_CODE } from "../core/shared/constants.js";
14
14
  import { PmCliError } from "../core/shared/errors.js";
15
15
  import { stableStringify } from "../core/shared/serialization.js";
16
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
16
+ import { resolvePmRoot } from "../core/store/paths.js";
17
17
  import { readSettings } from "../core/store/settings.js";
18
18
  import { parseHistoryProvenanceFilters, projectHistoryProvenance, resolveHistoryProvenanceDimensions, summarizeHistoryProvenance, } from "./history-provenance.js";
19
19
  const MUTATION_EVENT_CURSOR_VERSION = 1;
@@ -150,9 +150,7 @@ function resolveMutationEventCursorMode(value) {
150
150
  /** Read one bounded page of mutation events from the persistent projection. */
151
151
  export async function listMutationEvents(options = {}) {
152
152
  const pmRoot = resolvePmRoot(options.cwd ?? process.cwd(), options.pmRoot);
153
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
154
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
155
- }
153
+ await assertInitializedTracker(pmRoot);
156
154
  const requestedLimit = parseMutationEventLimit(options.limit);
157
155
  const cursorMode = resolveMutationEventCursorMode(options.cursorMode);
158
156
  if (options.full === true && options.provenance === true) {
@@ -292,4 +290,4 @@ export const _testOnlyMutationEvents = {
292
290
  resolveMutationEventStart,
293
291
  };
294
292
  //# sourceMappingURL=mutation-events.js.map
295
- //# debugId=e8cd5790-eacf-5ef7-bc0a-11ea3fe17d2d
293
+ //# debugId=01043e67-99d4-5b68-a1b2-33f35f5cef5f
@@ -13,19 +13,20 @@
13
13
  * helper bodies while keeping each package's explicit field mapping in the package.
14
14
  */
15
15
 
16
- !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]="c2567f6a-cd1c-56b5-a93d-41e92ed574bf")}catch(e){}}();
16
+ !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]="863df651-49e0-552f-a7f0-92c3cc9a12a2")}catch(e){}}();
17
17
  import { appendHistoryEntry, createHistoryEntry, } from "../core/history/history.js";
18
18
  import { acquireLock } from "../core/lock/lock.js";
19
19
  import { parseTags } from "../core/item/parse.js";
20
20
  import { normalizeStatusInput } from "../core/item/status.js";
21
21
  import { serializeItemDocument } from "../core/item/item-format.js";
22
- import { getHistoryPath, getSettingsPath } from "../core/store/paths.js";
23
- import { pathExists, removeFileIfExists, writeFileAtomic, } from "../core/fs/fs-utils.js";
22
+ import { getHistoryPath } from "../core/store/paths.js";
23
+ import { removeFileIfExists, writeFileAtomic, } from "../core/fs/fs-utils.js";
24
24
  import { runActiveOnWriteHooks } from "../core/extensions/index.js";
25
25
  import { EXIT_CODE } from "../core/shared/constants.js";
26
26
  import { PmCliError } from "../core/shared/errors.js";
27
27
  import { resolveAuthor } from "../core/shared/author.js";
28
28
  import { nowIso } from "../core/shared/time.js";
29
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
29
30
  /** Returns the trimmed string when `value` is a non-empty string, else undefined. */
30
31
  export function toNonEmptyImportString(value) {
31
32
  if (typeof value !== "string") {
@@ -367,10 +368,7 @@ function toImportLinkedTestAssertions(entry) {
367
368
  }
368
369
  /** Throws a NOT_FOUND PmCliError when the tracker has not been initialized. */
369
370
  export async function ensureTrackerInitialized(pmRoot) {
370
- const exists = await pathExists(getSettingsPath(pmRoot));
371
- if (!exists) {
372
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
373
- }
371
+ await assertInitializedTracker(pmRoot);
374
372
  }
375
373
  /** Returns an empty item document used as the `before` state on import. */
376
374
  export function emptyImportedDocument() {
@@ -442,4 +440,4 @@ export async function commitImportedItem(params) {
442
440
  }
443
441
  }
444
442
  //# sourceMappingURL=package-import-adapters.js.map
445
- //# debugId=c2567f6a-cd1c-56b5-a93d-41e92ed574bf
443
+ //# debugId=863df651-49e0-552f-a7f0-92c3cc9a12a2
@@ -10,16 +10,17 @@
10
10
  * and human formatting around it.
11
11
  */
12
12
 
13
- !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]="a1e34cfb-3d4e-5b79-8585-3162e71e574c")}catch(e){}}();
13
+ !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]="f65b4f1f-5501-5829-a04b-d4fbcfb59f5c")}catch(e){}}();
14
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
14
15
  import path from "node:path";
15
- import { pathExists, readFileIfExists, } from "../core/fs/fs-utils.js";
16
+ import { readFileIfExists, } from "../core/fs/fs-utils.js";
16
17
  import { writeWorkspaceJsonWithHistory } from "../core/history/workspace-history.js";
17
18
  import { acquireLock } from "../core/lock/lock.js";
18
19
  import { EXIT_CODE } from "../core/shared/constants.js";
19
20
  import { PmCliError } from "../core/shared/errors.js";
20
21
  import { resolveAuthor } from "../core/shared/author.js";
21
22
  import { nowIso } from "../core/shared/time.js";
22
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
23
+ import { resolvePmRoot } from "../core/store/paths.js";
23
24
  import { readSettings, resolveGovernanceKnobs, writeSettings, } from "../core/store/settings.js";
24
25
  import { DEFAULT_RUNTIME_SCHEMA_FILE_PATHS, filePathForSchemaSection, normalizeRuntimeSchemaSettings, } from "../core/schema/runtime-schema.js";
25
26
  import { normalizeAddTypeInput, serializeItemTypesFile, } from "../core/schema/item-types-file.js";
@@ -198,9 +199,7 @@ function buildApplyResult(profile, plan, applied, dryRun, warnings) {
198
199
  };
199
200
  }
200
201
  async function assertProfileTrackerInitialized(pmRoot) {
201
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
202
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
203
- }
202
+ await assertInitializedTracker(pmRoot);
204
203
  }
205
204
  function resolveProfileForCommand(name) {
206
205
  try {
@@ -453,4 +452,4 @@ export function formatProfileApplyHuman(result) {
453
452
  }
454
453
  /* c8 ignore stop */
455
454
  //# sourceMappingURL=profile.js.map
456
- //# debugId=a1e34cfb-3d4e-5b79-8585-3162e71e574c
455
+ //# debugId=f65b4f1f-5501-5829-a04b-d4fbcfb59f5c
@@ -4,11 +4,12 @@
4
4
  * Implements the pm activity 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]="49304d18-d722-5413-8e4d-4f2c3df4a1ca")}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]="7005305a-5fd4-56b8-a0a0-5612e8bf48cc")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
8
9
  import { isFileMissingError } from "../../core/fs/fs-utils.js";
9
10
  import fs from "node:fs/promises";
10
11
  import path from "node:path";
11
- import { getActiveExtensionRegistrations, runActiveOnReadHooks, pathExists, enforceHistoryStreamPolicyForItems, resolveItemTypeRegistry, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, resolveIsoOrRelative, listAllItemMetadataLight, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
12
+ import { getActiveExtensionRegistrations, runActiveOnReadHooks, enforceHistoryStreamPolicyForItems, resolveItemTypeRegistry, EXIT_CODE, PmCliError, compareTimestampStrings, nowIso, resolveIsoOrRelative, listAllItemMetadataLight, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
12
13
  import { readHistoryEntries } from "../history-read.js";
13
14
  import { parseLimit } from "./parsers.js";
14
15
  import { resolveModePairedOutputOmissionReceipt, } from "../output-projection.js";
@@ -168,9 +169,7 @@ function resolveActivityFilters(options, projectionMode) {
168
169
  }
169
170
  async function resolveActivityRuntimeContext(global) {
170
171
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
171
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
172
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
173
- }
172
+ await assertInitializedTracker(pmRoot);
174
173
  return {
175
174
  pmRoot,
176
175
  settings: await readSettings(pmRoot),
@@ -400,4 +399,4 @@ export async function runActivity(options, global) {
400
399
  };
401
400
  }
402
401
  //# sourceMappingURL=activity.js.map
403
- //# debugId=49304d18-d722-5413-8e4d-4f2c3df4a1ca
402
+ //# debugId=7005305a-5fd4-56b8-a0a0-5612e8bf48cc
@@ -4,9 +4,10 @@
4
4
  * Implements the pm calendar 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]="f1677c6e-872e-5c42-ae3d-f73f4ec73616")}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]="47de55f1-589f-5743-bcb8-3b7a6302dfbb")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
8
9
  import { encode as encodeToon } from "@toon-format/toon";
9
- import { pathExists, getActiveExtensionRegistrations, resolveItemTypeRegistry, normalizeStatusInput, collectRuntimeFilterValues, matchesRuntimeFilters, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, levenshteinDistanceWithinLimit, compareTimestampStrings, nowIso, resolveIsoOrRelative, listAllItemMetadataLight, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
10
+ import { getActiveExtensionRegistrations, resolveItemTypeRegistry, normalizeStatusInput, collectRuntimeFilterValues, matchesRuntimeFilters, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, levenshteinDistanceWithinLimit, compareTimestampStrings, nowIso, resolveIsoOrRelative, listAllItemMetadataLight, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
10
11
  import { parseIntegerLimit, parsePriority, parseType, } from "./parsers.js";
11
12
  import { weekdayOrderIndex, } from "../../types/index.js";
12
13
  const CALENDAR_VIEW_VALUES = ["agenda", "day", "week", "month"];
@@ -928,9 +929,7 @@ function buildCalendarRangeResult(options, rangeBounds) {
928
929
  /** Implements run calendar for the public runtime surface of this module. */
929
930
  export async function runCalendar(options, global) {
930
931
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
931
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
932
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
933
- }
932
+ await assertInitializedTracker(pmRoot);
934
933
  const inputs = resolveCalendarExecutionInputs(options);
935
934
  const settings = await readSettings(pmRoot);
936
935
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
@@ -963,4 +962,4 @@ export async function runCalendar(options, global) {
963
962
  };
964
963
  }
965
964
  //# sourceMappingURL=calendar.js.map
966
- //# debugId=f1677c6e-872e-5c42-ae3d-f73f4ec73616
965
+ //# debugId=47de55f1-589f-5743-bcb8-3b7a6302dfbb
@@ -1,12 +1,8 @@
1
- /**
2
- * @module sdk/query/get
3
- *
4
- * Implements the SDK-owned item query shared by every surface.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type ChildRollupContext } from "../item-children.js";
8
3
  import { type ItemScheduleContext } from "../item-schedule.js";
9
4
  import type { ItemMetadata, LinkedDoc, LinkedFile, LinkedTest } from "../../types/index.js";
5
+ export { GET_DEPTH_VALUES, listGetProjectionFields, } from "./projection-contracts.js";
10
6
  interface ClaimHistoryContext {
11
7
  ts: string;
12
8
  author: string;
@@ -92,4 +88,3 @@ export declare function runGet(id: string, global: GlobalOptions, options?: GetO
92
88
  export declare const _testOnlyGetCommand: {
93
89
  shouldAutoIncludeGetChildren: typeof shouldAutoIncludeGetChildren;
94
90
  };
95
- export {};