@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,7 +4,8 @@
4
4
  * Implements the pm history compact 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]="c6609492-75a9-5111-b9b3-1b81908f3084")}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]="adcf4d1b-689d-52cb-903b-5fba857707f3")}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 { createHistoryEntry } from "../core/history/history.js";
@@ -23,7 +24,7 @@ import { PmCliError } from "../core/shared/errors.js";
23
24
  import { nowIso } from "../core/shared/time.js";
24
25
  import { getActiveExtensionRegistrations, runActiveOnReadHooks, runActiveOnWriteHooks, } from "../core/extensions/index.js";
25
26
  import { readLocatedItem } from "../core/store/item-store.js";
26
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
27
+ import { resolvePmRoot } from "../core/store/paths.js";
27
28
  import { readSettings } from "../core/store/settings.js";
28
29
  import { resolveAuthor } from "../core/shared/author.js";
29
30
  import { resolveHistorySubject } from "./history-redact.js";
@@ -212,9 +213,7 @@ async function applyHistoryCompactRewrite(params) {
212
213
  /** Implements run history compact for the public runtime surface of this module. */
213
214
  export async function runHistoryCompact(id, options, global) {
214
215
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
215
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
216
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
217
- }
216
+ await assertInitializedTracker(pmRoot);
218
217
  const settings = await readSettings(pmRoot);
219
218
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
220
219
  const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);
@@ -438,9 +437,7 @@ async function runHistoryCompactBulkRow(params) {
438
437
  */
439
438
  export async function runHistoryCompactBulk(options, global) {
440
439
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
441
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
442
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
443
- }
440
+ await assertInitializedTracker(pmRoot);
444
441
  const settings = await readSettings(pmRoot);
445
442
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
446
443
  const { candidates, preselectionErrors } = await collectHistoryCompactBulkCandidates({
@@ -505,4 +502,4 @@ export async function runHistoryCompactBulk(options, global) {
505
502
  };
506
503
  }
507
504
  //# sourceMappingURL=history-compact.js.map
508
- //# debugId=c6609492-75a9-5111-b9b3-1b81908f3084
505
+ //# debugId=adcf4d1b-689d-52cb-903b-5fba857707f3
@@ -7,9 +7,9 @@
7
7
  * systems without acquiring locks or appending history.
8
8
  */
9
9
 
10
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="04f5d4d2-4021-5ce2-b35a-2134d98d2ad7")}catch(e){}}();
10
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aca866d3-32b9-5212-bb4b-f1484e41bb27")}catch(e){}}();
11
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
11
12
  import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
12
- import { pathExists } from "../core/fs/fs-utils.js";
13
13
  import { applyHistoryPatch, ensureMaterializedHistoryTarget, extractPatchFailureContext, replayHistoryToTarget, resolveHistoryTarget, } from "../core/history/projection.js";
14
14
  import { readHistoryEntries } from "../core/history/read.js";
15
15
  import { hashDocument, hashEmptyDocument, } from "../core/history/history.js";
@@ -17,7 +17,7 @@ import { replayToCanonicalItemDocument, verifyHistoryChain, } from "../core/hist
17
17
  import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
18
18
  import { EXIT_CODE } from "../core/shared/constants.js";
19
19
  import { PmCliError } from "../core/shared/errors.js";
20
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
20
+ import { resolvePmRoot } from "../core/store/paths.js";
21
21
  import { readSettings } from "../core/store/settings.js";
22
22
  import { resolveHistorySubject } from "./history-redact.js";
23
23
  /**
@@ -55,9 +55,7 @@ export function verifyHistoryEntries(history, currentDocument) {
55
55
  */
56
56
  export async function getItemAt(id, target, options = {}) {
57
57
  const pmRoot = resolvePmRoot(options.cwd ?? process.cwd(), options.pmRoot);
58
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
59
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
60
- }
58
+ await assertInitializedTracker(pmRoot);
61
59
  const settings = await readSettings(pmRoot);
62
60
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
63
61
  const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);
@@ -85,4 +83,4 @@ export async function getItemAt(id, target, options = {}) {
85
83
  }
86
84
  export { applyHistoryPatch, ensureMaterializedHistoryTarget, extractPatchFailureContext, readHistoryEntries, replayHistoryToTarget, resolveHistoryTarget, };
87
85
  //# sourceMappingURL=history-read.js.map
88
- //# debugId=04f5d4d2-4021-5ce2-b35a-2134d98d2ad7
86
+ //# debugId=aca866d3-32b9-5212-bb4b-f1484e41bb27
@@ -4,7 +4,8 @@
4
4
  * Implements the pm history redact 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]="cd2a27ec-0f12-591d-ab34-529ddda05063")}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]="05b945f2-4f96-5f88-98ff-84cc856d0d57")}catch(e){}}();
8
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
8
9
  import fs from "node:fs/promises";
9
10
  import { pathExists, readFileIfExists, writeFileAtomic, } from "../core/fs/fs-utils.js";
10
11
  import { createHistoryEntry } from "../core/history/history.js";
@@ -22,7 +23,7 @@ import { nowIso } from "../core/shared/time.js";
22
23
  import { getActiveExtensionRegistrations, runActiveOnWriteHooks, } from "../core/extensions/index.js";
23
24
  import { locateItem, readLocatedItem } from "../core/store/item-store.js";
24
25
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../core/store/item-metadata-cache.js";
25
- import { getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, } from "../core/store/paths.js";
26
+ import { getHistoryPath, getItemPath, resolvePmRoot, } from "../core/store/paths.js";
26
27
  import { readSettings } from "../core/store/settings.js";
27
28
  import { resolveAuthor } from "../core/shared/author.js";
28
29
  function normalizeStringArrayInput(value) {
@@ -486,9 +487,7 @@ export async function resolveHistorySubject(pmRoot, id, settings, typeToFolder)
486
487
  /** Implements run history redact for the public runtime surface of this module. */
487
488
  export async function runHistoryRedact(id, options, global) {
488
489
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
489
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
490
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
491
- }
490
+ await assertInitializedTracker(pmRoot);
492
491
  const settings = await readSettings(pmRoot);
493
492
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
494
493
  const replacementInput = options.replacement ?? "";
@@ -607,4 +606,4 @@ export const _testOnly = {
607
606
  redactUnknownValue,
608
607
  };
609
608
  //# sourceMappingURL=history-redact.js.map
610
- //# debugId=cd2a27ec-0f12-591d-ab34-529ddda05063
609
+ //# debugId=05b945f2-4f96-5f88-98ff-84cc856d0d57
@@ -4,7 +4,8 @@
4
4
  * Implements the pm history repair 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]="de9b7f82-0f51-599d-b1fa-2d54e3acbdbc")}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]="d201aa9f-1ed3-5655-8c06-e5729557b86a")}catch(e){}}();
8
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
8
9
  import jsonPatch from "fast-json-patch";
9
10
  import { patchPathToChangedField } from "../core/history/history-diff.js";
10
11
  import { pathExists, readFileIfExists } from "../core/fs/fs-utils.js";
@@ -20,7 +21,7 @@ import { resolveAuthor } from "../core/shared/author.js";
20
21
  import { nowIso } from "../core/shared/time.js";
21
22
  import { getActiveExtensionRegistrations, runActiveOnWriteHooks, } from "../core/extensions/index.js";
22
23
  import { listAllItemMetadataWithBody, readLocatedItem, } from "../core/store/item-store.js";
23
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
24
+ import { resolvePmRoot } from "../core/store/paths.js";
24
25
  import { readSettings } from "../core/store/settings.js";
25
26
  import { resolveHistorySubject } from "./history-redact.js";
26
27
  import { listInvalidProvenanceHistoryStreamIds, normalizeInvalidHistoryProvenance, } from "./governance/provenance-health.js";
@@ -233,9 +234,7 @@ async function applyHistoryRepairRewrite(params) {
233
234
  /** Implements run history repair for the public runtime surface of this module. */
234
235
  export async function runHistoryRepair(id, options, global) {
235
236
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
236
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
237
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
238
- }
237
+ await assertInitializedTracker(pmRoot);
239
238
  const settings = await readSettings(pmRoot);
240
239
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
241
240
  const subject = await resolveHistorySubject(pmRoot, id, settings, typeRegistry.type_to_folder);
@@ -377,9 +376,7 @@ export function assertHistoryRepairTarget(id, all) {
377
376
  /** Bulk drift repair: scan every item's history stream with the same drift scan `pm health` uses, then run the audited single-stream repair (ownership check, lock, no-drift verification, audit marker) for each drifted stream. One failing stream never aborts the rest; failures are collected per row and the caller decides the exit code from `totals.failed`. */
378
377
  export async function runHistoryRepairAll(options, global) {
379
378
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
380
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
381
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
382
- }
379
+ await assertInitializedTracker(pmRoot);
383
380
  const settings = await readSettings(pmRoot);
384
381
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
385
382
  const itemReadWarnings = [];
@@ -443,4 +440,4 @@ export async function runHistoryRepairAll(options, global) {
443
440
  };
444
441
  }
445
442
  //# sourceMappingURL=history-repair.js.map
446
- //# debugId=de9b7f82-0f51-599d-b1fa-2d54e3acbdbc
443
+ //# debugId=d201aa9f-1ed3-5655-8c06-e5729557b86a
@@ -5,19 +5,20 @@
5
5
  * singleton and exposes bounded trend reads for self-improvement loops.
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]="aaa927b3-4bc4-561f-aff1-85dc95c12ea1")}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]="c2e1edc9-c454-5cfa-85c8-e9fb0a76a296")}catch(e){}}();
9
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
9
10
  import { createHash } from "node:crypto";
10
11
  import { execFile } from "node:child_process";
11
12
  import path from "node:path";
12
13
  import { promisify } from "node:util";
13
- import { pathExists, readFileIfExists } from "../core/fs/fs-utils.js";
14
+ import { readFileIfExists } from "../core/fs/fs-utils.js";
14
15
  import { mutateWorkspaceJsonWithHistory } from "../core/history/workspace-history.js";
15
16
  import { EXIT_CODE } from "../core/shared/constants.js";
16
17
  import { resolveAuthor } from "../core/shared/author.js";
17
18
  import { PmCliError } from "../core/shared/errors.js";
18
19
  import { stableStringify } from "../core/shared/serialization.js";
19
20
  import { nowIso } from "../core/shared/time.js";
20
- import { getSettingsPath, resolvePmRoot, resolveWorkspaceRoot, } from "../core/store/paths.js";
21
+ import { resolvePmRoot, resolveWorkspaceRoot, } from "../core/store/paths.js";
21
22
  import { readSettings } from "../core/store/settings.js";
22
23
  import { parseImprovementLedgerDocument as parseLedger } from "./improvement-ledger-validation.js";
23
24
  const execFileAsync = promisify(execFile);
@@ -179,9 +180,7 @@ function trendForMetric(observations) {
179
180
  /** Record one audited observation, returning an idempotent receipt on retry. */
180
181
  export async function recordImprovementObservation(options, global = {}) {
181
182
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
182
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
183
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
184
- }
183
+ await assertInitializedTracker(pmRoot);
185
184
  const settings = await readSettings(pmRoot);
186
185
  const observation = await buildImprovementObservation(pmRoot, settings, options);
187
186
  const filePath = path.join(pmRoot, "improvement-ledger.json");
@@ -219,9 +218,7 @@ export async function recordImprovementObservation(options, global = {}) {
219
218
  /** Read a bounded newest-first observation page and derive complete trends. */
220
219
  export async function readImprovementLedger(options = {}) {
221
220
  const pmRoot = resolvePmRoot(options.cwd ?? process.cwd(), options.pmRoot);
222
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
223
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
224
- }
221
+ await assertInitializedTracker(pmRoot);
225
222
  const metric = options.metric === undefined
226
223
  ? undefined
227
224
  : normalizeMetricName(options.metric);
@@ -258,4 +255,4 @@ export const _testOnlyImprovementLedger = {
258
255
  trendForMetric,
259
256
  };
260
257
  //# sourceMappingURL=improvement-ledger.js.map
261
- //# debugId=aaa927b3-4bc4-561f-aff1-85dc95c12ea1
258
+ //# debugId=c2e1edc9-c454-5cfa-85c8-e9fb0a76a296
@@ -45,6 +45,7 @@ export { findSimilarItems, findDuplicateClusters, evaluateSimilarityGovernance,
45
45
  export { inspectStaleInProgressItems, scanStaleInProgressItems, type InspectStaleInProgressOptions, type StaleInProgressItem, type StaleInProgressScan, } from "./governance/stale-work.js";
46
46
  export { describeItemOwnershipConflict } from "./ownership-source.js";
47
47
  export { discoverNearbyPmRoot } from "./tracker-root-discovery.js";
48
+ export { assertInitializedTracker, assertReadableTrackerRoot, buildTrackerInitializationRecovery, } from "./environment/tracker-preflight.js";
48
49
  export { _testOnly as _testOnlyTemplates, type TemplateSource, } from "./templates.js";
49
50
  export { runConfig, _testOnlyConfigCommand, type NestedSettingResultValue, } from "./config.js";
50
51
  export { INIT_AGENT_GUIDANCE_MODE_VALUES, runInitAgentGuidance, _testOnly as _testOnlyInitAgentGuidance, type InitAgentGuidanceMode, type InitAgentGuidanceSummary, type RunInitAgentGuidanceOptions, type RunInitAgentGuidanceResult, } from "./init-agent-guidance.js";
@@ -123,6 +124,7 @@ export * from "./generated-error-code-catalog.js";
123
124
  export * from "./agent/refusal-reachability.js";
124
125
  export * from "./agent/refusal-closure.js";
125
126
  export * from "./agent/closed-domain-contracts.js";
127
+ export * from "./agent/tracker-preflight-contracts.js";
126
128
  export * from "./agent/subcommand-recovery.js";
127
129
  export * from "./flag-invocation-contracts.js";
128
130
  export * from "./cli-contracts/flag-lexicon-contracts.js";
package/dist/sdk/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Defines public SDK APIs and package-author helpers for Index.
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]="69a0f0d4-50f9-5063-9cc6-64de2abac82e")}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]="148a713d-523e-5f89-875a-3e3a569d46c0")}catch(e){}}();
8
8
  export { PM_COMMAND_CAPABILITY_CONTRACTS, PM_COMMAND_VISIBILITY_CONTRACTS, PM_MCP_PROMPT_CONTRACTS, PM_MCP_RESOURCE_CONTRACTS, PM_MCP_TOOL_COMMAND_CONTRACTS, listPmCommandsForFamily, listPmCommandsForTier, listPmMcpToolsForProfile, renderPmCommandVisibilityMarkdown, resolvePmCommandCapabilityFamily, resolvePmCommandVisibilityTier, } from "./agent-capability-contracts.js";
9
9
  export * from "./cli-contracts/grammar-contracts.js";
10
10
  export * from "./agent-session-context.js";
@@ -45,6 +45,7 @@ export { findSimilarItems, findDuplicateClusters, evaluateSimilarityGovernance,
45
45
  export { inspectStaleInProgressItems, scanStaleInProgressItems, } from "./governance/stale-work.js";
46
46
  export { describeItemOwnershipConflict } from "./ownership-source.js";
47
47
  export { discoverNearbyPmRoot } from "./tracker-root-discovery.js";
48
+ export { assertInitializedTracker, assertReadableTrackerRoot, buildTrackerInitializationRecovery, } from "./environment/tracker-preflight.js";
48
49
  export { _testOnly as _testOnlyTemplates, } from "./templates.js";
49
50
  export { runConfig, _testOnlyConfigCommand, } from "./config.js";
50
51
  export { INIT_AGENT_GUIDANCE_MODE_VALUES, runInitAgentGuidance, _testOnly as _testOnlyInitAgentGuidance, } from "./init-agent-guidance.js";
@@ -120,6 +121,7 @@ export * from "./generated-error-code-catalog.js";
120
121
  export * from "./agent/refusal-reachability.js";
121
122
  export * from "./agent/refusal-closure.js";
122
123
  export * from "./agent/closed-domain-contracts.js";
124
+ export * from "./agent/tracker-preflight-contracts.js";
123
125
  export * from "./agent/subcommand-recovery.js";
124
126
  export * from "./flag-invocation-contracts.js";
125
127
  export * from "./cli-contracts/flag-lexicon-contracts.js";
@@ -159,4 +161,4 @@ export * from "./governance.js";
159
161
  export * from "./query.js";
160
162
  export * from "./testing.js";
161
163
  //# sourceMappingURL=index.js.map
162
- //# debugId=69a0f0d4-50f9-5063-9cc6-64de2abac82e
164
+ //# debugId=148a713d-523e-5f89-875a-3e3a569d46c0
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/append
3
- *
4
- * Implements the pm append command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  /** Documents the append command options payload exchanged by command, SDK, and package integrations. */
8
3
  export interface AppendCommandOptions {
@@ -4,8 +4,9 @@
4
4
  * Implements the pm append command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9e3ba7e9-8822-53ba-981e-e177be5219f3")}catch(e){}}();
8
- import { pathExists, EXIT_CODE, PmCliError, resolveAuthor, toItemRecord, createStdinTokenResolver, mutateItem, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="73184370-6517-533e-90db-536893402616")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { EXIT_CODE, PmCliError, resolveAuthor, toItemRecord, createStdinTokenResolver, mutateItem, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
10
  /** Implements run append for the public runtime surface of this module. */
10
11
  export async function runAppend(id, options, global) {
11
12
  if (options.body === undefined) {
@@ -13,9 +14,7 @@ export async function runAppend(id, options, global) {
13
14
  }
14
15
  const stdinResolver = createStdinTokenResolver();
15
16
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
16
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
17
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
18
- }
17
+ await assertInitializedTracker(pmRoot);
19
18
  const settings = await readSettings(pmRoot);
20
19
  const author = resolveAuthor(options.author, settings.author_default);
21
20
  // options.body is guaranteed defined by the guard above, so resolveValue returns a defined string.
@@ -52,4 +51,4 @@ export async function runAppend(id, options, global) {
52
51
  };
53
52
  }
54
53
  //# sourceMappingURL=append.js.map
55
- //# debugId=9e3ba7e9-8822-53ba-981e-e177be5219f3
54
+ //# debugId=73184370-6517-533e-90db-536893402616
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/claim
3
- *
4
- * Implements the pm claim command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type NextRecommendation, type NextOptions } from "../query/next.js";
8
3
  /** Stable warning/error code for an exhausted atomic next-work walk. */
@@ -4,8 +4,9 @@
4
4
  * Implements the pm claim command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f70f1329-4dfb-5625-ae0a-66c858d88f7b")}catch(e){}}();
8
- import { pathExists, resolveRuntimeStatusRegistry, statusIsTerminal, EXIT_CODE, PmCliError, toItemRecord, mutateItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1a61bf25-e320-5adc-8f5a-a427bc89af1a")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { resolveRuntimeStatusRegistry, statusIsTerminal, EXIT_CODE, PmCliError, toItemRecord, mutateItem, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
9
10
  import { wrapOwnershipConflict } from "../annotations.js";
10
11
  import { describeItemOwnershipConflict } from "../ownership-source.js";
11
12
  import { runNext, } from "../query/next.js";
@@ -26,9 +27,7 @@ export function isAlreadyClaimedError(error) {
26
27
  /** Implements run claim for the public runtime surface of this module. */
27
28
  export async function runClaim(id, force, global, options = {}) {
28
29
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
29
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
30
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
31
- }
30
+ await assertInitializedTracker(pmRoot);
32
31
  const settings = await readSettings(pmRoot);
33
32
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
34
33
  const author = resolveAuthor(options.author, settings.author_default);
@@ -184,9 +183,7 @@ export async function claimNextFromRecommendations(recommendations, force, globa
184
183
  /** Implements run release for the public runtime surface of this module. */
185
184
  export async function runRelease(id, force, global, options = {}) {
186
185
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
187
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
188
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
189
- }
186
+ await assertInitializedTracker(pmRoot);
190
187
  const settings = await readSettings(pmRoot);
191
188
  const author = resolveAuthor(options.author, settings.author_default);
192
189
  const claimPrincipal = resolveClaimPrincipal(author);
@@ -237,4 +234,4 @@ export async function runRelease(id, force, global, options = {}) {
237
234
  };
238
235
  }
239
236
  //# sourceMappingURL=claim.js.map
240
- //# debugId=f70f1329-4dfb-5625-ae0a-66c858d88f7b
237
+ //# debugId=1a61bf25-e320-5adc-8f5a-a427bc89af1a
@@ -1,8 +1,3 @@
1
- /**
2
- * @module cli/commands/close-many
3
- *
4
- * Implements the pm close many command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions, readSettings } from "../runtime-primitives.js";
7
2
  import { type ListOptions } from "../query/list.js";
8
3
  import { type PmCommandEffectReceipt } from "../cli-contracts/command-exit-contracts.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm close many command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4da07a98-855e-59cf-a6a4-2f59a8b3c0bd")}catch(e){}}();
8
- import { pathExists, createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, resolveAuthor, nowIso, listAllItemMetadataLight, getSettingsPath, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a7113374-b169-5f92-9c20-075a47520440")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { createCheckpointId, loadMutationCheckpoint, restoreCheckpointItems, writeMutationCheckpoint, getActiveExtensionRegistrations, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, toErrorMessage, resolveAuthor, nowIso, listAllItemMetadataLight, resolvePmRoot, readSettings, } from "../runtime-primitives.js";
9
10
  import { runClose } from "./close.js";
10
11
  import { hasListFilters } from "../query/list-filter-shared.js";
11
12
  import { runList } from "../query/list.js";
@@ -336,9 +337,7 @@ async function resolveCloseManyCheckpointInfo(params) {
336
337
  /** Implements run close many for the public runtime surface of this module. */
337
338
  export async function runCloseMany(options, global) {
338
339
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
339
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
340
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
341
- }
340
+ await assertInitializedTracker(pmRoot);
342
341
  const settings = await readSettings(pmRoot);
343
342
  const dryRun = options.dryRun === true;
344
343
  const rollbackId = resolveCloseManyRollbackId(options);
@@ -428,4 +427,4 @@ export const _testOnly = {
428
427
  resolveReason,
429
428
  };
430
429
  //# sourceMappingURL=close-many.js.map
431
- //# debugId=4da07a98-855e-59cf-a6a4-2f59a8b3c0bd
430
+ //# debugId=a7113374-b169-5f92-9c20-075a47520440
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/close
3
- *
4
- * Implements the pm close command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { collectBlockedByIds } from "../actionability.js";
8
3
  import { type CloseOperationOptions, type CloseOperationResult } from "../lifecycle-policy.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm close command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="83affe54-a56c-5d84-b6b0-9634d4238ff5")}catch(e){}}();
8
- import { pathExists, toItemRecord, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, mutateItem, readLocatedItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveIsoOrRelative, shouldCompletePlanOnClose, getActiveExtensionRegistrations, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="781b5118-7b07-53c7-802f-c889cb797a96")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { toItemRecord, isTerminalStatus, resolveItemTypeRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, PmCliError, buildItemNotFoundError, listAllItemMetadataLight, locateItem, mutateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, resolveIsoOrRelative, shouldCompletePlanOnClose, getActiveExtensionRegistrations, } from "../runtime-primitives.js";
9
10
  import { collectBlockedByIds, indexBlockedByIds } from "../actionability.js";
10
11
  import { applyTerminalOrderingPolicy, requireTerminalReason, } from "../lifecycle-policy.js";
11
12
  import { renderPmCommand } from "../command-line.js";
@@ -367,9 +368,7 @@ export const _testOnlyCloseCommand = {
367
368
  /** Close one item through the SDK-owned lifecycle transaction and policy. */
368
369
  export async function closeItem(id, closeReasonText, options, global) {
369
370
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
370
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
371
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
372
- }
371
+ await assertInitializedTracker(pmRoot);
373
372
  const settings = await readSettings(pmRoot);
374
373
  const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
375
374
  const author = resolveAuthor(options.author, settings.author_default);
@@ -458,4 +457,4 @@ export function runClose(id, closeReasonText, options, global) {
458
457
  return closeItem(id, closeReasonText, options, global);
459
458
  }
460
459
  //# sourceMappingURL=close.js.map
461
- //# debugId=83affe54-a56c-5d84-b6b0-9634d4238ff5
460
+ //# debugId=781b5118-7b07-53c7-802f-c889cb797a96
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/copy
3
- *
4
- * Implements the SDK-owned copy lifecycle operation shared by every surface.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type SimilarityAdvisory } from "../similarity.js";
8
3
  import type { ItemMetadata } from "../../types/index.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the SDK-owned copy lifecycle operation shared by every surface.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4eb2056a-4444-514a-a0db-79b8875c3d65")}catch(e){}}();
8
- import { pathExists, removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, canonicalDocument, serializeItemDocument, acquireLock, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, collectRegisteredItemFieldNames, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, nowIso, PmCliError, resolveItemTypeRegistry, buildItemNotFoundError, locateItem, readLocatedItem, getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b59e8e54-f9e0-5cdb-bc59-6dcbf67f278d")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, canonicalDocument, serializeItemDocument, acquireLock, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnWriteHooks, collectRegisteredItemFieldNames, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, nowIso, PmCliError, resolveItemTypeRegistry, buildItemNotFoundError, locateItem, readLocatedItem, getHistoryPath, getItemPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { evaluateSimilarityGovernance, similarityAdvisoryWarnings, } from "../similarity.js";
10
11
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../item-metadata-index.js";
11
12
  function buildChangedFields(itemMetadata, body) {
@@ -29,9 +30,7 @@ function buildCopyMessage(sourceId, message) {
29
30
  /** Implements run copy for the public runtime surface of this module. */
30
31
  export async function runCopy(sourceId, options, global) {
31
32
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
32
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
33
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
34
- }
33
+ await assertInitializedTracker(pmRoot);
35
34
  const settings = await readSettings(pmRoot);
36
35
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
37
36
  const located = await locateItem(pmRoot, sourceId, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder);
@@ -211,4 +210,4 @@ export async function runCopy(sourceId, options, global) {
211
210
  };
212
211
  }
213
212
  //# sourceMappingURL=copy.js.map
214
- //# debugId=4eb2056a-4444-514a-a0db-79b8875c3d65
213
+ //# debugId=b59e8e54-f9e0-5cdb-bc59-6dcbf67f278d
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/create
3
- *
4
- * Implements the pm create command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type ResolvedItemTypeDefinition, type RuntimeFieldRegistry, type GlobalOptions } from "../runtime-primitives.js";
7
2
  import { type SimilarityAdvisory } from "../similarity.js";
8
3
  import { type LifecycleTransitionSuggestion } from "./lifecycle-transitions.js";
@@ -4,8 +4,9 @@
4
4
  * Implements the pm create command surface and its agent-facing runtime behavior.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7d69bb56-9fab-5059-9357-5b6bea2078b9")}catch(e){}}();
8
- import { pathExists, removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, normalizeItemId, canonicalDocument, normalizeItemMetadata, serializeItemDocument, assertParentReferenceIsNotSelf, isPlaceholderReferenceToken, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, resolvePriority, getFocusedItem, normalizeStatusInput, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, acquireLock, printError, buildInvalidTypeError, resolveTypeSynonym, collectRuntimeCreateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, PmCliError, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveCommandHandler, runActiveBeforeMutationHooks, runActiveOnWriteHooks, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, listAllItemMetadataLight, locateItem, createMutationGuardSdk, getHistoryPath, getItemPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a10348fe-746d-5dc7-8cd4-30453c602a3f")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { removeFileIfExists, writeFileAtomic, appendHistoryEntry, createHistoryEntry, generateItemId, normalizeItemId, canonicalDocument, normalizeItemMetadata, serializeItemDocument, assertParentReferenceIsNotSelf, isPlaceholderReferenceToken, normalizeParentReferenceValue, validateMissingParentReference, validateSprintOrReleaseValue, assertNoUnknownCsvKeys, createStdinTokenResolver, looksLikeGenericKeyValueEntry, mergeAdditiveTags, parseCsvKv, parseOptionalNonNegativeInteger, parseOptionalNumber, parseTags, resolvePriority, getFocusedItem, normalizeStatusInput, canonicalizeCommandOptionKey, commandOptionFlagLabel, resolveItemTypeRegistry, resolveCommandOptionPolicyState, resolveTypeDefinition, resolveTypeName, validateTypeOptions, acquireLock, printError, buildInvalidTypeError, resolveTypeSynonym, collectRuntimeCreateFieldValues, resolveItemTypesFilePath, resolveRuntimeFieldRegistry, resolveRuntimeStatusRegistry, EXIT_CODE, ITEM_METADATA_KEY_ORDER, PmCliError, nowIso, resolveIsoOrRelative, getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveCommandHandler, runActiveBeforeMutationHooks, runActiveOnWriteHooks, collectRegisteredItemFieldNames, applyRegisteredItemFieldDefaultsAndValidation, parseRegisteredItemFieldAssignments, listAllItemMetadataLight, locateItem, createMutationGuardSdk, getHistoryPath, getItemPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
9
10
  import { requireTerminalReasonWithRecovery } from "../lifecycle-policy.js";
10
11
  import { evaluateSimilarityGovernance, similarityAdvisoryWarnings, } from "../similarity.js";
11
12
  import { acquireItemMetadataDerivedIndexLock, refreshItemMetadataDerivedIndex, } from "../item-metadata-index.js";
@@ -837,12 +838,7 @@ async function loadCreateTemplateOptionsFromRuntime(templateName, global, pmRoot
837
838
  return readTemplateOptionsFromRuntimeResult(handlerResult.result, templateName);
838
839
  }
839
840
  function ensureInitHasRun(pmRoot) {
840
- return pathExists(getSettingsPath(pmRoot)).then((exists) => {
841
- /* c8 ignore next -- init guard failures are covered by top-level create command tests. */
842
- if (!exists) {
843
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
844
- }
845
- });
841
+ return assertInitializedTracker(pmRoot);
846
842
  }
847
843
  /**
848
844
  * Resolve an optional string item-metadata field for {@link runCreate}: yields
@@ -1890,4 +1886,4 @@ export const _testOnlyCreateCommand = {
1890
1886
  typeOptionExampleValue,
1891
1887
  };
1892
1888
  //# sourceMappingURL=create.js.map
1893
- //# debugId=7d69bb56-9fab-5059-9357-5b6bea2078b9
1889
+ //# debugId=a10348fe-746d-5dc7-8cd4-30453c602a3f
@@ -4,15 +4,14 @@
4
4
  * Implements the SDK-owned delete lifecycle operation shared by every surface.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="14aa55e1-cb5f-55ea-bf4c-412217d87449")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7819b53c-b0e4-50b0-a670-f80b36765085")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
8
9
  import path from "node:path";
9
- import { pathExists, EXIT_CODE, PmCliError, toItemRecord, deleteItem, getHistoryPath, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
+ import { toItemRecord, deleteItem, getHistoryPath, resolvePmRoot, readSettings, resolveAuthor, } from "../runtime-primitives.js";
10
11
  /** Implements run delete for the public runtime surface of this module. */
11
12
  export async function runDelete(id, options, global) {
12
13
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
13
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
14
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
15
- }
14
+ await assertInitializedTracker(pmRoot);
16
15
  const settings = await readSettings(pmRoot);
17
16
  const author = resolveAuthor(options.author, settings.author_default);
18
17
  const result = await deleteItem({
@@ -44,4 +43,4 @@ export async function runDelete(id, options, global) {
44
43
  };
45
44
  }
46
45
  //# sourceMappingURL=delete.js.map
47
- //# debugId=14aa55e1-cb5f-55ea-bf4c-412217d87449
46
+ //# debugId=7819b53c-b0e4-50b0-a670-f80b36765085
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/focus
3
- *
4
- * Implements the SDK-owned focus lifecycle operation shared by every surface.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  /** Documents the focus options payload exchanged by command, SDK, and package integrations. */
8
3
  export interface FocusOptions {
@@ -4,13 +4,12 @@
4
4
  * Implements the SDK-owned focus lifecycle operation shared by every surface.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0f43df79-0b27-53b3-b8bd-9f2a35561733")}catch(e){}}();
8
- import { pathExists, getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, EXIT_CODE, PmCliError, clearFocusedItem, getFocusedItem, setFocusedItem, buildItemNotFoundError, locateItem, readLocatedItem, getSettingsPath, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a5ddb139-9780-50e0-87a5-621913cb0de4")}catch(e){}}();
8
+ import { assertInitializedTracker } from "../environment/tracker-preflight.js";
9
+ import { getActiveExtensionRegistrations, normalizeItemId, resolveItemTypeRegistry, EXIT_CODE, PmCliError, clearFocusedItem, getFocusedItem, setFocusedItem, buildItemNotFoundError, locateItem, readLocatedItem, resolvePmRoot, readSettings, resolveAuthor, resolveClaimPrincipal, } from "../runtime-primitives.js";
9
10
  import { recordFocusSemanticAttribution } from "../context/semantic-session-attribution.js";
10
11
  async function ensureInitialized(pmRoot) {
11
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
12
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
13
- }
12
+ await assertInitializedTracker(pmRoot);
14
13
  }
15
14
  /** Implements run focus for the public runtime surface of this module. */
16
15
  export async function runFocus(id, options, global) {
@@ -90,4 +89,4 @@ function nonEmptyTitleOrNull(title) {
90
89
  return title.trim().length > 0 ? title : null;
91
90
  }
92
91
  //# sourceMappingURL=focus.js.map
93
- //# debugId=0f43df79-0b27-53b3-b8bd-9f2a35561733
92
+ //# debugId=a5ddb139-9780-50e0-87a5-621913cb0de4
@@ -1,8 +1,3 @@
1
- /**
2
- * @module sdk/lifecycle/plan
3
- *
4
- * Implements the pm plan command surface and its agent-facing runtime behavior.
5
- */
6
1
  import { type GlobalOptions } from "../runtime-primitives.js";
7
2
  import type { DependencyKind, ItemMetadata, PlanDecision, PlanDiscovery, PlanHarness, PlanMode, PlanStep, PlanStepStatus, PlanValidationCheck } from "../../types/index.js";
8
3
  import type { MutationMetadataCommandOptions, SharedLinkedResourceOptions } from "./mutation-command-options.js";