@unbrained/pm-cli 2026.8.20 → 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 (167) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +22 -0
  3. package/dist/cli/error-guidance.d.ts +20 -0
  4. package/dist/cli/error-guidance.js +29 -30
  5. package/dist/cli-bundle/bundle-manifest.json +151 -151
  6. package/dist/cli-bundle/chunks/chunk-2MA6ZQVZ.js +197 -0
  7. package/dist/cli-bundle/chunks/{chunk-K3EN3LK2.js → chunk-3AFAUHUE.js} +2 -2
  8. package/dist/cli-bundle/chunks/chunk-7VHZS727.js +5 -0
  9. package/dist/cli-bundle/chunks/{chunk-L4LGPBJU.js → chunk-BKYB45NQ.js} +68 -68
  10. package/dist/cli-bundle/chunks/{chunk-4GB2LTOQ.js → chunk-BUNIEJNE.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-XYDDWBZN.js → chunk-JSLOFXGA.js} +3 -3
  12. package/dist/cli-bundle/chunks/{chunk-TSMWLCHS.js → chunk-LARJJ3RK.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-7BRF2BX2.js → chunk-LOVTQ52Z.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-US2ZQW2M.js → chunk-N3DSV4CH.js} +47 -47
  15. package/dist/cli-bundle/chunks/chunk-OCLPLFAY.js +35 -0
  16. package/dist/cli-bundle/chunks/chunk-S4IRYKBU.js +13 -0
  17. package/dist/cli-bundle/chunks/{register-list-query-JSAQCVOC.js → register-list-query-F57EWDEF.js} +2 -2
  18. package/dist/cli-bundle/chunks/{register-mutation-XJPAW63D.js → register-mutation-7IY2D5KO.js} +2 -2
  19. package/dist/cli-bundle/chunks/{register-operations-DSOSB2XQ.js → register-operations-FALL3YTU.js} +2 -2
  20. package/dist/cli-bundle/chunks/{register-setup-QUR6QL2C.js → register-setup-HXU7IZZD.js} +2 -2
  21. package/dist/cli-bundle/focused-chunks/{chunk-FUREQLQN.js → chunk-2NIY5NKG.js} +2 -2
  22. package/dist/cli-bundle/focused-chunks/{chunk-G3C5ERXG.js → chunk-4ERLO7QD.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/chunk-7WZRLCYF.js +50 -0
  24. package/dist/cli-bundle/focused-chunks/{chunk-AZBACT5T.js → chunk-CKKQSJNN.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/chunk-EEFKYMDR.js +16 -0
  26. package/dist/cli-bundle/focused-chunks/{chunk-GXWQBE3T.js → chunk-F2A56DHV.js} +2 -2
  27. package/dist/cli-bundle/focused-chunks/{chunk-M32HFIQB.js → chunk-F4YEW5I2.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/{chunk-UGSS4F5X.js → chunk-FH6DYED3.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-TDR5OGG3.js → chunk-FJ22HNRP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/chunk-FV5ACOK7.js +2 -0
  31. package/dist/cli-bundle/focused-chunks/{chunk-Q47EX4DI.js → chunk-JEAVFOWM.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-OM65KHGF.js → chunk-KDNG7TKQ.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-NJ63LOP6.js +155 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-NXRTQ7HI.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-JWKEDZJI.js → chunk-TJ7EMJ46.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-5L7M4AI7.js → chunk-UZE7XUZK.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-325UXIO7.js → chunk-YKBKIEAJ.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-BLJCGGID.js → chunk-ZOSEELYJ.js} +2 -2
  39. package/dist/cli-bundle/main.js +12 -12
  40. package/dist/cli-bundle/sdk-authoring.js +1 -1
  41. package/dist/cli-bundle/sdk-contracts.js +2 -2
  42. package/dist/cli-bundle/sdk-core.js +40 -40
  43. package/dist/cli-bundle/sdk-governance.js +1 -1
  44. package/dist/cli-bundle/sdk-graph.js +1 -1
  45. package/dist/cli-bundle/sdk-merge.js +32 -32
  46. package/dist/cli-bundle/sdk-query.js +1 -1
  47. package/dist/cli-bundle/sdk-runtime.js +1 -1
  48. package/dist/cli-bundle/sdk-testing.js +1 -1
  49. package/dist/cli-bundle/sdk.js +5 -5
  50. package/dist/core/shared/errors.d.ts +16 -0
  51. package/dist/core/shared/errors.js +2 -2
  52. package/dist/core/store/item-store.js +6 -91
  53. package/dist/core/store/tracker-preflight.d.ts +7 -0
  54. package/dist/core/store/tracker-preflight.js +142 -0
  55. package/dist/sdk/agent/tracker-preflight-contracts.d.ts +63 -0
  56. package/dist/sdk/agent/tracker-preflight-contracts.js +127 -0
  57. package/dist/sdk/annotations.js +6 -7
  58. package/dist/sdk/config.d.ts +5 -0
  59. package/dist/sdk/config.js +5 -5
  60. package/dist/sdk/context-intent-runtime.js +7 -4
  61. package/dist/sdk/contracts.d.ts +1 -0
  62. package/dist/sdk/contracts.js +3 -2
  63. package/dist/sdk/dependencies.js +5 -7
  64. package/dist/sdk/dependency-flag-validation.d.ts +1 -1
  65. package/dist/sdk/dependency-flag-validation.js +10 -4
  66. package/dist/sdk/environment/tracker-preflight.d.ts +6 -0
  67. package/dist/sdk/environment/tracker-preflight.js +10 -0
  68. package/dist/sdk/eval.js +5 -7
  69. package/dist/sdk/files.js +6 -10
  70. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +39 -3
  71. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +69 -8
  72. package/dist/sdk/governance/assurance.d.ts +36 -2
  73. package/dist/sdk/governance/assurance.js +184 -10
  74. package/dist/sdk/governance/gc.js +5 -6
  75. package/dist/sdk/governance/health.js +5 -6
  76. package/dist/sdk/governance/reindex.js +5 -6
  77. package/dist/sdk/governance/validate.d.ts +1 -2
  78. package/dist/sdk/governance/validate.js +6 -12
  79. package/dist/sdk/graph/governance.d.ts +7 -5
  80. package/dist/sdk/graph/governance.js +32 -16
  81. package/dist/sdk/graph/run.js +5 -7
  82. package/dist/sdk/graph/traversal.js +14 -5
  83. package/dist/sdk/history-compact.js +6 -9
  84. package/dist/sdk/history-read.js +5 -7
  85. package/dist/sdk/history-redact.js +5 -6
  86. package/dist/sdk/history-repair.js +6 -9
  87. package/dist/sdk/improvement-ledger.js +7 -10
  88. package/dist/sdk/index.d.ts +2 -0
  89. package/dist/sdk/index.js +4 -2
  90. package/dist/sdk/lifecycle/append.d.ts +0 -5
  91. package/dist/sdk/lifecycle/append.js +5 -6
  92. package/dist/sdk/lifecycle/claim.d.ts +0 -5
  93. package/dist/sdk/lifecycle/claim.js +6 -9
  94. package/dist/sdk/lifecycle/close-many.d.ts +0 -5
  95. package/dist/sdk/lifecycle/close-many.js +5 -6
  96. package/dist/sdk/lifecycle/close.d.ts +0 -5
  97. package/dist/sdk/lifecycle/close.js +5 -6
  98. package/dist/sdk/lifecycle/copy.d.ts +0 -5
  99. package/dist/sdk/lifecycle/copy.js +5 -6
  100. package/dist/sdk/lifecycle/create.d.ts +0 -5
  101. package/dist/sdk/lifecycle/create.js +5 -9
  102. package/dist/sdk/lifecycle/delete.js +5 -6
  103. package/dist/sdk/lifecycle/focus.d.ts +0 -5
  104. package/dist/sdk/lifecycle/focus.js +5 -6
  105. package/dist/sdk/lifecycle/plan.d.ts +0 -5
  106. package/dist/sdk/lifecycle/plan.js +5 -6
  107. package/dist/sdk/lifecycle/restore.js +5 -6
  108. package/dist/sdk/lifecycle/update-many.d.ts +0 -5
  109. package/dist/sdk/lifecycle/update-many.js +5 -6
  110. package/dist/sdk/lifecycle/update.d.ts +0 -5
  111. package/dist/sdk/lifecycle/update.js +48 -9
  112. package/dist/sdk/linked-artifacts.js +6 -7
  113. package/dist/sdk/merge/install.js +5 -6
  114. package/dist/sdk/mutation-events.js +5 -7
  115. package/dist/sdk/package-import-adapters.js +6 -8
  116. package/dist/sdk/profile.js +6 -7
  117. package/dist/sdk/query/activity.js +5 -6
  118. package/dist/sdk/query/calendar.js +5 -6
  119. package/dist/sdk/query/get.d.ts +0 -5
  120. package/dist/sdk/query/get.js +5 -6
  121. package/dist/sdk/query/history.d.ts +0 -5
  122. package/dist/sdk/query/history.js +5 -6
  123. package/dist/sdk/query/list.js +5 -7
  124. package/dist/sdk/query/search.js +5 -7
  125. package/dist/sdk/relationship-kinds/contract.d.ts +8 -0
  126. package/dist/sdk/relationship-kinds/contract.js +13 -13
  127. package/dist/sdk/relationships.d.ts +1 -1
  128. package/dist/sdk/relationships.js +20 -2
  129. package/dist/sdk/schema-migration.js +6 -7
  130. package/dist/sdk/schema.js +5 -6
  131. package/dist/sdk/stats.js +5 -8
  132. package/dist/sdk/templates.js +5 -6
  133. package/dist/sdk/test/batch.js +5 -7
  134. package/dist/sdk/test/execution.js +4 -5
  135. package/dist/sdk/test/runs.js +5 -7
  136. package/docs/AGENT_UX_CONTRACTS.md +8 -1
  137. package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -1
  138. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +37 -0
  139. package/docs/RELATIONSHIP_GRAPH.md +92 -10
  140. package/docs/SDK_PRIMITIVE_INVENTORY.md +15 -1
  141. package/marketplace.json +2 -2
  142. package/package.json +1 -1
  143. package/packages/pm-beads/package.json +1 -1
  144. package/packages/pm-calendar/package.json +1 -1
  145. package/packages/pm-command-kit/package.json +1 -1
  146. package/packages/pm-digital-twin/package.json +1 -1
  147. package/packages/pm-governance-audit/package.json +1 -1
  148. package/packages/pm-guide-shell/package.json +1 -1
  149. package/packages/pm-kanban/package.json +1 -1
  150. package/packages/pm-lifecycle-hooks/package.json +1 -1
  151. package/packages/pm-linked-test-adapters/package.json +1 -1
  152. package/packages/pm-search-advanced/package.json +1 -1
  153. package/packages/pm-templates/package.json +1 -1
  154. package/packages/pm-todos/package.json +1 -1
  155. package/packages/pm-vcs/package.json +1 -1
  156. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  157. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  158. package/sdk/public-surface.json +255 -21
  159. package/dist/cli-bundle/chunks/chunk-2RDVGYWE.js +0 -13
  160. package/dist/cli-bundle/chunks/chunk-BLVQHFSY.js +0 -35
  161. package/dist/cli-bundle/chunks/chunk-CU25EQVV.js +0 -5
  162. package/dist/cli-bundle/chunks/chunk-RS3IV2R6.js +0 -197
  163. package/dist/cli-bundle/focused-chunks/chunk-6AHG2YW7.js +0 -50
  164. package/dist/cli-bundle/focused-chunks/chunk-KYZ6JGPL.js +0 -155
  165. package/dist/cli-bundle/focused-chunks/chunk-RIHDMCUM.js +0 -2
  166. package/dist/cli-bundle/focused-chunks/chunk-T4ZFY7ZJ.js +0 -16
  167. package/dist/cli-bundle/focused-chunks/chunk-Z3PLWSGM.js +0 -2
@@ -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
@@ -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";
@@ -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";
@@ -4,8 +4,9 @@
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]="3ab4f16d-ce37-546e-a2f6-0495fd1967c7")}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, 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";
9
10
  import { mutateItemWithHistoryContextResolver } from "../../core/store/item-store.js";
10
11
  import { runClose } from "./close.js";
11
12
  import { normalizeRiskInput, normalizeSeverityInput, parseConfidenceInput, parseRegressionInput, } from "./metadata-normalizers.js";
@@ -440,9 +441,9 @@ function parseDependencyRemovals(raw, prefix) {
440
441
  if (!trimmed) {
441
442
  throw new PmCliError("--dep-remove requires id or key/value selectors", EXIT_CODE.USAGE);
442
443
  }
443
- if (trimmed.includes("=") ||
444
- /^(?:[-*+]\s+)?(?:id|kind|type|source_kind)\s*[:=]/i.test(trimmed) ||
445
- trimmed.startsWith("```")) {
444
+ const isStructured = looksLikeStructuredDependencyEntry(trimmed);
445
+ assertValidBareDependencyFlagValue(trimmed, isStructured, "--dep-remove");
446
+ if (isStructured) {
446
447
  const kv = parseCsvKv(trimmed, "--dep-remove");
447
448
  assertNoUnknownCsvKeys(kv, "--dep-remove", DEP_REMOVE_KEYS);
448
449
  const idRaw = kv.id?.trim();
@@ -1082,9 +1083,7 @@ async function buildNoopUpdateResult(params) {
1082
1083
  };
1083
1084
  }
1084
1085
  async function assertUpdateTrackerInitialized(pmRoot) {
1085
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
1086
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1087
- }
1086
+ await assertInitializedTracker(pmRoot);
1088
1087
  }
1089
1088
  function assertMatchingOrderRank(options) {
1090
1089
  if (options.order !== undefined &&
@@ -1313,6 +1312,44 @@ function applyTypeOptionMutation(document, context, activeTypeName, changedField
1313
1312
  }
1314
1313
  document.metadata.type_options = validation.normalized;
1315
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
+ }
1316
1353
  function applyDependencyMutations(document, context, changedFields) {
1317
1354
  if (context.options.dep === undefined &&
1318
1355
  context.options.depRemove === undefined &&
@@ -1323,6 +1360,7 @@ function applyDependencyMutations(document, context, changedFields) {
1323
1360
  ? []
1324
1361
  : [...(document.metadata.dependencies ?? [])];
1325
1362
  if (context.dependencyUpdates.additions.length > 0) {
1363
+ nextDependencies = normalizeTouchedDependencyIdentities(nextDependencies, context.dependencyUpdates.additions);
1326
1364
  const seen = new Set(nextDependencies.map((entry) => dependencyKey(entry)));
1327
1365
  for (const addition of context.dependencyUpdates.additions) {
1328
1366
  const key = dependencyKey(addition);
@@ -1333,6 +1371,7 @@ function applyDependencyMutations(document, context, changedFields) {
1333
1371
  }
1334
1372
  }
1335
1373
  if (context.dependencyRemovals.length > 0) {
1374
+ assertDependencyRemovalSelectorsMatch(nextDependencies, context.dependencyRemovals, document.metadata.id);
1336
1375
  nextDependencies = nextDependencies.filter((entry) => !context.dependencyRemovals.some((selector) => matchesDependencySelector(entry, selector)));
1337
1376
  }
1338
1377
  if (nextDependencies.length === 0) {
@@ -1982,4 +2021,4 @@ export const _testOnlyUpdateCommand = {
1982
2021
  resolveRuntimeUnsetDefinition: (token, registry) => resolveRuntimeUnsetFieldDefinition(token, "update", registry),
1983
2022
  };
1984
2023
  //# sourceMappingURL=update.js.map
1985
- //# debugId=3ab4f16d-ce37-546e-a2f6-0495fd1967c7
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,8 +1,3 @@
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";
@@ -4,8 +4,9 @@
4
4
  * Implements the SDK-owned item query shared by every surface.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="16d0a1cf-467d-5041-ab36-e2a9033a9342")}catch(e){}}();
8
- import { pathExists, getActiveExtensionRegistrations, toItemRecord, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, TYPE_TO_FOLDER, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, readLocatedItem, getHistoryPath, 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]="ff82974e-a48d-5d18-893f-fb618e378795")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { getActiveExtensionRegistrations, toItemRecord, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, TYPE_TO_FOLDER, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, readLocatedItem, getHistoryPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { readHistoryEntries } from "../history-read.js";
10
11
  import { renderPmCommand } from "../command-line.js";
11
12
  import { recordContextUsageTouches } from "../context-usage.js";
@@ -263,9 +264,7 @@ function resolveGetProjection(options, id) {
263
264
  }
264
265
  async function loadGetItemContext(id, global, at) {
265
266
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
266
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
267
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
268
- }
267
+ await assertInitializedTracker(pmRoot);
269
268
  const settings = await readSettings(pmRoot);
270
269
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
271
270
  if (at !== undefined) {
@@ -448,4 +447,4 @@ export const _testOnlyGetCommand = {
448
447
  shouldAutoIncludeGetChildren,
449
448
  };
450
449
  //# sourceMappingURL=get.js.map
451
- //# debugId=16d0a1cf-467d-5041-ab36-e2a9033a9342
450
+ //# debugId=ff82974e-a48d-5d18-893f-fb618e378795
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/history
3
- *
4
- * Implements the pm history command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type HistoryDiffValueEntry, verifyHistoryChain, type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type HistoryVerificationResult } from "../history-read.js";
8
3
  export { readHistoryEntries } from "../history-read.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm history command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f18d7526-01eb-593b-bf50-788c08a35e5d")}catch(e){}}();
8
- import { pathExists, computeHistoryDiff, patchPathToChangedField, normalizeReplayPatchOps, verifyHistoryChain, enforceHistoryStreamPolicyForItem, EXIT_CODE, PmCliError, getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, locateItem, readLocatedItem, getHistoryPath, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, getSettingsPath, resolvePmRoot, readSettings, WORKSPACE_HISTORY_ID, } 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]="314adea1-6837-5eeb-abc3-57337a495221")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { pathExists, computeHistoryDiff, patchPathToChangedField, normalizeReplayPatchOps, verifyHistoryChain, enforceHistoryStreamPolicyForItem, EXIT_CODE, PmCliError, getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, locateItem, readLocatedItem, getHistoryPath, getWorkspaceHistoryPath, inspectWorkspaceHistoryState, resolvePmRoot, readSettings, WORKSPACE_HISTORY_ID, } from "../runtime-primitives.js";
9
10
  import { readHistoryEntries, verifyHistoryEntries, } from "../history-read.js";
10
11
  export { readHistoryEntries } from "../history-read.js";
11
12
  import { parseLimit } from "./parsers.js";
@@ -39,9 +40,7 @@ function buildDiffEntries(entries, startIndex) {
39
40
  }
40
41
  async function resolveHistoryReadTarget(id, global) {
41
42
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
42
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
43
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
44
- }
43
+ await assertInitializedTracker(pmRoot);
45
44
  const settings = await readSettings(pmRoot);
46
45
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
47
46
  const workspaceHistoryRequested = id.trim() === WORKSPACE_HISTORY_ID;
@@ -161,4 +160,4 @@ export async function runHistory(id, options, global) {
161
160
  return result;
162
161
  }
163
162
  //# sourceMappingURL=history.js.map
164
- //# debugId=f18d7526-01eb-593b-bf50-788c08a35e5d
163
+ //# debugId=314adea1-6837-5eeb-abc3-57337a495221
@@ -4,8 +4,8 @@
4
4
  * Implements the pm list 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]="67c5ff91-1c04-5506-ae5b-32f6552f1d07")}catch(e){}}();
8
- import { pathExists } from "../../core/fs/fs-utils.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]="361f891a-5f10-529c-8161-dc5193c7e12a")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
9
  import { getActiveExtensionRegistrations, hasActiveOnReadHooks, } from "../../core/extensions/index.js";
10
10
  import { toItemRecord } from "../../core/item/item-record.js";
11
11
  import { isTerminalStatus } from "../../core/item/status.js";
@@ -24,7 +24,7 @@ import { compareTimestampStrings, matchesTimestampFilters, nowIso, resolveIsoOrR
24
24
  import { listAllItemMetadata, listAllItemMetadataLight, listAllItemMetadataWithBody, } from "../../core/store/item-store.js";
25
25
  import { HEAVY_METADATA_KEYS, readItemMetadataDerivedIndexState, } from "../../core/store/item-metadata-cache.js";
26
26
  import { queryItemMetadataIndex } from "../../core/store/item-metadata-query-index.js";
27
- import { getSettingsPath, resolvePmRoot } from "../../core/store/paths.js";
27
+ import { resolvePmRoot } from "../../core/store/paths.js";
28
28
  import { readSettings } from "../../core/store/settings.js";
29
29
  import { LIST_FILTER_FLAG_CONTRACTS } from "../cli-contracts/flag-contracts.js";
30
30
  import { createQueryFingerprint, encodeQueryCursor, resolveQueryCursorStart, selectCursorSemanticOptions, } from "../pagination.js";
@@ -891,9 +891,7 @@ function buildListPageExtras(limit, hasMore, nextCursor) {
891
891
  }
892
892
  async function resolveListRuntimeContext(options, global) {
893
893
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
894
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
895
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
896
- }
894
+ await assertInitializedTracker(pmRoot);
897
895
  const settings = await readSettings(pmRoot);
898
896
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
899
897
  const runtimeFieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
@@ -1243,4 +1241,4 @@ export const _testOnly = {
1243
1241
  withTreeMetadata,
1244
1242
  };
1245
1243
  //# sourceMappingURL=list.js.map
1246
- //# debugId=67c5ff91-1c04-5506-ae5b-32f6552f1d07
1244
+ //# debugId=361f891a-5f10-529c-8161-dc5193c7e12a