@unbrained/pm-cli 2026.8.20 → 2026.8.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +38 -0
  3. package/dist/cli/error-guidance.d.ts +29 -4
  4. package/dist/cli/error-guidance.js +43 -43
  5. package/dist/cli/main.d.ts +3 -0
  6. package/dist/cli/main.js +40 -7
  7. package/dist/cli-bundle/bundle-manifest.json +150 -150
  8. package/dist/cli-bundle/chunks/{chunk-L4LGPBJU.js → chunk-BWX4SK46.js} +58 -58
  9. package/dist/cli-bundle/chunks/chunk-EMWDM5FI.js +13 -0
  10. package/dist/cli-bundle/chunks/chunk-HYG6LRL4.js +200 -0
  11. package/dist/cli-bundle/chunks/{chunk-TSMWLCHS.js → chunk-MYYI3ZOA.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-4GB2LTOQ.js → chunk-MZTZQTMS.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-7BRF2BX2.js → chunk-QI2CT3IX.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-SMWXHMVB.js +35 -0
  15. package/dist/cli-bundle/chunks/{chunk-US2ZQW2M.js → chunk-U6GQ4VMV.js} +47 -47
  16. package/dist/cli-bundle/chunks/{chunk-K3EN3LK2.js → chunk-VMMIL3SI.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-WG4STC36.js +5 -0
  18. package/dist/cli-bundle/chunks/{chunk-XYDDWBZN.js → chunk-YBPJAOQQ.js} +3 -3
  19. package/dist/cli-bundle/chunks/{register-list-query-JSAQCVOC.js → register-list-query-HZKBQNWW.js} +2 -2
  20. package/dist/cli-bundle/chunks/{register-mutation-XJPAW63D.js → register-mutation-HTKEEGRD.js} +2 -2
  21. package/dist/cli-bundle/chunks/{register-operations-DSOSB2XQ.js → register-operations-6EMRWJJY.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-setup-QUR6QL2C.js → register-setup-QK4OTOXN.js} +2 -2
  23. package/dist/cli-bundle/focused-chunks/{chunk-TDR5OGG3.js → chunk-2ARQGDDW.js} +2 -2
  24. package/dist/cli-bundle/focused-chunks/{chunk-AZBACT5T.js → chunk-2AZT5WXZ.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-M32HFIQB.js → chunk-2POVTNLY.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-3LKU6PTJ.js +4 -0
  27. package/dist/cli-bundle/focused-chunks/chunk-5SHSBMX2.js +2 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-UGSS4F5X.js → chunk-6S2MO3Q3.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-5L7M4AI7.js → chunk-A2BC5PQL.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/chunk-C4S4A4JJ.js +5 -0
  31. package/dist/cli-bundle/focused-chunks/{chunk-OM65KHGF.js → chunk-D6RBZEJJ.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/chunk-E2EWYPY6.js +16 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-G3C5ERXG.js → chunk-GMYPD4FX.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-L5LDSRO2.js +155 -0
  35. package/dist/cli-bundle/focused-chunks/{chunk-BLJCGGID.js → chunk-MB37AYN6.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/chunk-MCOR37QK.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-FUREQLQN.js → chunk-PH2OXXVZ.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-325UXIO7.js → chunk-PMGJUFNQ.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/chunk-R6SR45XU.js +50 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-WZE4LIPW.js +8 -0
  41. package/dist/cli-bundle/main.js +13 -13
  42. package/dist/cli-bundle/sdk-authoring.js +1 -1
  43. package/dist/cli-bundle/sdk-contracts.js +2 -2
  44. package/dist/cli-bundle/sdk-core.js +40 -40
  45. package/dist/cli-bundle/sdk-governance.js +1 -1
  46. package/dist/cli-bundle/sdk-graph.js +1 -1
  47. package/dist/cli-bundle/sdk-merge.js +32 -32
  48. package/dist/cli-bundle/sdk-query.js +1 -1
  49. package/dist/cli-bundle/sdk-runtime.js +1 -1
  50. package/dist/cli-bundle/sdk-testing.js +1 -1
  51. package/dist/cli-bundle/sdk.js +5 -5
  52. package/dist/core/extensions/extension-hook-runtime.js +22 -20
  53. package/dist/core/extensions/extension-types.d.ts +8 -1
  54. package/dist/core/extensions/extension-types.js +2 -2
  55. package/dist/core/extensions/loader.js +7 -3
  56. package/dist/core/extensions/service-ownership.d.ts +8 -0
  57. package/dist/core/extensions/service-ownership.js +20 -0
  58. package/dist/core/item/id.js +20 -5
  59. package/dist/core/item/item-format.js +27 -2
  60. package/dist/core/shared/errors.d.ts +20 -0
  61. package/dist/core/shared/errors.js +2 -2
  62. package/dist/core/store/item-store.js +6 -91
  63. package/dist/core/store/tracker-preflight.d.ts +7 -0
  64. package/dist/core/store/tracker-preflight.js +142 -0
  65. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  66. package/dist/sdk/agent/tracker-preflight-contracts.d.ts +63 -0
  67. package/dist/sdk/agent/tracker-preflight-contracts.js +127 -0
  68. package/dist/sdk/annotations.js +6 -7
  69. package/dist/sdk/authoring.d.ts +1 -1
  70. package/dist/sdk/authoring.js +2 -2
  71. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +77 -0
  72. package/dist/sdk/cli-contracts/agent-output-contracts.js +324 -2
  73. package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -3
  74. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +3 -1
  75. package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
  76. package/dist/sdk/cli-contracts.d.ts +1 -1
  77. package/dist/sdk/cli-contracts.js +3 -3
  78. package/dist/sdk/config.d.ts +5 -0
  79. package/dist/sdk/config.js +5 -5
  80. package/dist/sdk/context-intent-runtime.js +7 -4
  81. package/dist/sdk/contracts.d.ts +1 -0
  82. package/dist/sdk/contracts.js +3 -2
  83. package/dist/sdk/dependencies.js +5 -7
  84. package/dist/sdk/dependency-flag-validation.d.ts +1 -1
  85. package/dist/sdk/dependency-flag-validation.js +10 -4
  86. package/dist/sdk/environment/tracker-preflight.d.ts +6 -0
  87. package/dist/sdk/environment/tracker-preflight.js +10 -0
  88. package/dist/sdk/eval.js +5 -7
  89. package/dist/sdk/extension/install-sources.d.ts +1 -1
  90. package/dist/sdk/extension/install-sources.js +6 -3
  91. package/dist/sdk/extension/output-ownership.d.ts +1 -0
  92. package/dist/sdk/extension/output-ownership.js +3 -2
  93. package/dist/sdk/files.js +6 -10
  94. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +75 -15
  95. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +81 -8
  96. package/dist/sdk/governance/assurance.d.ts +36 -2
  97. package/dist/sdk/governance/assurance.js +184 -10
  98. package/dist/sdk/governance/gc.js +5 -6
  99. package/dist/sdk/governance/health.d.ts +3 -0
  100. package/dist/sdk/governance/health.js +42 -11
  101. package/dist/sdk/governance/hierarchy-validation.d.ts +29 -0
  102. package/dist/sdk/governance/hierarchy-validation.js +109 -0
  103. package/dist/sdk/governance/reindex.js +5 -6
  104. package/dist/sdk/governance/validate.d.ts +2 -9
  105. package/dist/sdk/governance/validate.js +51 -109
  106. package/dist/sdk/graph/assembly.d.ts +6 -1
  107. package/dist/sdk/graph/assembly.js +16 -22
  108. package/dist/sdk/graph/governance-contracts.d.ts +1 -1
  109. package/dist/sdk/graph/governance-contracts.js +8 -2
  110. package/dist/sdk/graph/governance.d.ts +7 -5
  111. package/dist/sdk/graph/governance.js +76 -16
  112. package/dist/sdk/graph/hierarchy-integrity.d.ts +94 -0
  113. package/dist/sdk/graph/hierarchy-integrity.js +311 -0
  114. package/dist/sdk/graph/index.d.ts +2 -1
  115. package/dist/sdk/graph/index.js +3 -2
  116. package/dist/sdk/graph/remediation.js +32 -2
  117. package/dist/sdk/graph/run.d.ts +31 -2
  118. package/dist/sdk/graph/run.js +83 -36
  119. package/dist/sdk/graph/traversal.js +14 -5
  120. package/dist/sdk/graph/workspace-relationship-kind-registry.d.ts +8 -0
  121. package/dist/sdk/graph/workspace-relationship-kind-registry.js +28 -0
  122. package/dist/sdk/history-compact.js +6 -9
  123. package/dist/sdk/history-read.js +5 -7
  124. package/dist/sdk/history-redact.js +5 -6
  125. package/dist/sdk/history-repair.js +6 -9
  126. package/dist/sdk/improvement-ledger.js +7 -10
  127. package/dist/sdk/index.d.ts +4 -2
  128. package/dist/sdk/index.js +5 -3
  129. package/dist/sdk/item-children.js +21 -8
  130. package/dist/sdk/lifecycle/append.d.ts +0 -5
  131. package/dist/sdk/lifecycle/append.js +5 -6
  132. package/dist/sdk/lifecycle/claim.d.ts +0 -5
  133. package/dist/sdk/lifecycle/claim.js +6 -9
  134. package/dist/sdk/lifecycle/close-many.d.ts +0 -5
  135. package/dist/sdk/lifecycle/close-many.js +5 -6
  136. package/dist/sdk/lifecycle/close.d.ts +0 -5
  137. package/dist/sdk/lifecycle/close.js +5 -6
  138. package/dist/sdk/lifecycle/copy.d.ts +0 -5
  139. package/dist/sdk/lifecycle/copy.js +5 -6
  140. package/dist/sdk/lifecycle/create.d.ts +0 -5
  141. package/dist/sdk/lifecycle/create.js +127 -102
  142. package/dist/sdk/lifecycle/delete.js +5 -6
  143. package/dist/sdk/lifecycle/focus.d.ts +0 -5
  144. package/dist/sdk/lifecycle/focus.js +5 -6
  145. package/dist/sdk/lifecycle/hierarchy-mutation-lock.d.ts +15 -0
  146. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +25 -0
  147. package/dist/sdk/lifecycle/plan.d.ts +0 -5
  148. package/dist/sdk/lifecycle/plan.js +5 -6
  149. package/dist/sdk/lifecycle/restore.js +5 -6
  150. package/dist/sdk/lifecycle/update-many.d.ts +0 -5
  151. package/dist/sdk/lifecycle/update-many.js +5 -6
  152. package/dist/sdk/lifecycle/update.d.ts +2 -5
  153. package/dist/sdk/lifecycle/update.js +211 -84
  154. package/dist/sdk/linked-artifacts.js +6 -7
  155. package/dist/sdk/merge/install.js +5 -6
  156. package/dist/sdk/mutation-events.js +5 -7
  157. package/dist/sdk/package-import-adapters.js +6 -8
  158. package/dist/sdk/profile.js +6 -7
  159. package/dist/sdk/query/activity.js +5 -6
  160. package/dist/sdk/query/calendar.js +5 -6
  161. package/dist/sdk/query/complete-list.d.ts +3 -3
  162. package/dist/sdk/query/complete-list.js +46 -3
  163. package/dist/sdk/query/get.d.ts +0 -5
  164. package/dist/sdk/query/get.js +5 -6
  165. package/dist/sdk/query/history.d.ts +0 -5
  166. package/dist/sdk/query/history.js +5 -6
  167. package/dist/sdk/query/list.d.ts +4 -3
  168. package/dist/sdk/query/list.js +92 -54
  169. package/dist/sdk/query/search.js +5 -7
  170. package/dist/sdk/read-output-contracts.d.ts +5 -1
  171. package/dist/sdk/read-output-contracts.js +87 -22
  172. package/dist/sdk/relationship-context.js +3 -4
  173. package/dist/sdk/relationship-kinds/contract.d.ts +8 -0
  174. package/dist/sdk/relationship-kinds/contract.js +13 -13
  175. package/dist/sdk/relationships.d.ts +1 -1
  176. package/dist/sdk/relationships.js +27 -2
  177. package/dist/sdk/runtime.d.ts +3 -2
  178. package/dist/sdk/runtime.js +3 -2
  179. package/dist/sdk/schema-migration.js +6 -7
  180. package/dist/sdk/schema.js +5 -6
  181. package/dist/sdk/stats.js +5 -8
  182. package/dist/sdk/templates.js +5 -6
  183. package/dist/sdk/test/batch.js +15 -9
  184. package/dist/sdk/test/execution.js +12 -5
  185. package/dist/sdk/test/runs.js +5 -7
  186. package/dist/types.d.ts +11 -0
  187. package/dist/types.js +2 -2
  188. package/docs/AGENT_UX_CONTRACTS.md +24 -1
  189. package/docs/COMMANDS.md +29 -14
  190. package/docs/DEPENDENCY_KIND_CONTRACT.md +40 -1
  191. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +98 -0
  192. package/docs/EXTENSIONS.md +2 -1
  193. package/docs/README.md +1 -0
  194. package/docs/READ_OUTPUT_CONTRACTS.md +9 -2
  195. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +37 -0
  196. package/docs/RELATIONSHIP_GRAPH.md +97 -12
  197. package/docs/SDK_PRIMITIVE_INVENTORY.md +15 -1
  198. package/docs/TESTING.md +15 -0
  199. package/marketplace.json +2 -2
  200. package/package.json +1 -1
  201. package/packages/pm-beads/package.json +1 -1
  202. package/packages/pm-calendar/package.json +1 -1
  203. package/packages/pm-command-kit/package.json +1 -1
  204. package/packages/pm-digital-twin/package.json +1 -1
  205. package/packages/pm-governance-audit/package.json +1 -1
  206. package/packages/pm-guide-shell/package.json +1 -1
  207. package/packages/pm-kanban/package.json +1 -1
  208. package/packages/pm-lifecycle-hooks/package.json +1 -1
  209. package/packages/pm-linked-test-adapters/package.json +1 -1
  210. package/packages/pm-search-advanced/package.json +1 -1
  211. package/packages/pm-templates/package.json +1 -1
  212. package/packages/pm-todos/package.json +1 -1
  213. package/packages/pm-vcs/package.json +1 -1
  214. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  215. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  216. package/sdk/public-surface.json +848 -56
  217. package/dist/cli-bundle/chunks/chunk-2RDVGYWE.js +0 -13
  218. package/dist/cli-bundle/chunks/chunk-BLVQHFSY.js +0 -35
  219. package/dist/cli-bundle/chunks/chunk-CU25EQVV.js +0 -5
  220. package/dist/cli-bundle/chunks/chunk-RS3IV2R6.js +0 -197
  221. package/dist/cli-bundle/focused-chunks/chunk-6AHG2YW7.js +0 -50
  222. package/dist/cli-bundle/focused-chunks/chunk-GXWQBE3T.js +0 -8
  223. package/dist/cli-bundle/focused-chunks/chunk-JWKEDZJI.js +0 -4
  224. package/dist/cli-bundle/focused-chunks/chunk-KYZ6JGPL.js +0 -155
  225. package/dist/cli-bundle/focused-chunks/chunk-Q47EX4DI.js +0 -2
  226. package/dist/cli-bundle/focused-chunks/chunk-RIHDMCUM.js +0 -2
  227. package/dist/cli-bundle/focused-chunks/chunk-T4ZFY7ZJ.js +0 -16
  228. package/dist/cli-bundle/focused-chunks/chunk-Z3PLWSGM.js +0 -2
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @module sdk/agent/tracker-preflight-contracts
3
+ *
4
+ * Declares and scores executable recovery for tracker filesystem preflight failures.
5
+ */
6
+ /** Filesystem states distinguished by the shared tracker preflight. */
7
+ export type PmTrackerPreflightFailureKind = "missing_root" | "settings_missing" | "not_directory" | "unreadable_root";
8
+ /** Recovery behavior that is safe for a tracker preflight failure. */
9
+ export type PmTrackerPreflightRecoveryKind = "initialize" | "select_directory" | "repair_permissions";
10
+ /** Static refusal and recovery obligation for one tracker filesystem state. */
11
+ export interface PmTrackerPreflightRecoveryContract {
12
+ /** Stable probe identifier used by repository gates and evidence. */
13
+ probe_id: string;
14
+ /** Filesystem state created by the executable probe. */
15
+ failure_kind: PmTrackerPreflightFailureKind;
16
+ /** Stable structured error code required from CLI and SDK transports. */
17
+ expected_error_code: string;
18
+ /** Process exit code required from the CLI transport. */
19
+ expected_exit_code: 1 | 2 | 3;
20
+ /** Safe recovery behavior for this filesystem state. */
21
+ recovery_kind: PmTrackerPreflightRecoveryKind;
22
+ }
23
+ /** Runtime evidence captured from one executable tracker preflight probe. */
24
+ export interface PmTrackerPreflightRecoveryObservation {
25
+ /** Stable probe identifier from the corresponding contract. */
26
+ probe_id: string;
27
+ /** Structured error code emitted by the refusal. */
28
+ error_code: string;
29
+ /** Process exit code emitted by the refusal. */
30
+ exit_code: number;
31
+ /** Recovery behavior exercised by the probe driver. */
32
+ recovery_kind: PmTrackerPreflightRecoveryKind;
33
+ /** Tokenized retry emitted by the refusal, or an empty list when no deterministic retry is safe. */
34
+ suggested_retry_args: string[];
35
+ /** Whether the emitted retry or safe alternate-root retry executed successfully. */
36
+ retry_succeeded: boolean;
37
+ /** Whether a file-path refusal incorrectly recommended tracker initialization. */
38
+ unsafe_init_recommended: boolean;
39
+ }
40
+ /** Actionable failure emitted by the tracker preflight closure scorer. */
41
+ export interface PmTrackerPreflightRecoveryFinding {
42
+ /** Stable finding code for automation and ratchets. */
43
+ code: "missing_probe" | "error_code_mismatch" | "exit_code_mismatch" | "recovery_kind_mismatch" | "missing_init_recovery" | "unsafe_init_recovery" | "retry_failed";
44
+ /** Probe that failed its recovery obligation. */
45
+ probe_id: string;
46
+ /** Human-readable explanation of the failed obligation. */
47
+ detail: string;
48
+ }
49
+ /** Aggregate executable-closure report for the tracker preflight corpus. */
50
+ export interface PmTrackerPreflightRecoveryReport {
51
+ /** Whether every declared probe met its refusal and recovery contract. */
52
+ ok: boolean;
53
+ /** Number of declared tracker preflight probes. */
54
+ probe_count: number;
55
+ /** Number of probes with no findings. */
56
+ closed_probe_count: number;
57
+ /** Deterministically ordered failed obligations. */
58
+ findings: PmTrackerPreflightRecoveryFinding[];
59
+ }
60
+ /** Return defensive copies of every core tracker preflight recovery contract. */
61
+ export declare function listTrackerPreflightRecoveryContracts(): PmTrackerPreflightRecoveryContract[];
62
+ /** Score runtime observations against the complete tracker preflight recovery corpus. */
63
+ export declare function scoreTrackerPreflightRecoveryClosure(observations: readonly PmTrackerPreflightRecoveryObservation[]): PmTrackerPreflightRecoveryReport;
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @module sdk/agent/tracker-preflight-contracts
3
+ *
4
+ * Declares and scores executable recovery for tracker filesystem preflight failures.
5
+ */
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]="941a11a9-f756-56b3-9dc1-8afd78bc9328")}catch(e){}}();
8
+ const TRACKER_PREFLIGHT_RECOVERY_CONTRACTS = [
9
+ {
10
+ probe_id: "tracker-root-missing",
11
+ failure_kind: "missing_root",
12
+ expected_error_code: "tracker_root_missing",
13
+ expected_exit_code: 3,
14
+ recovery_kind: "initialize",
15
+ },
16
+ {
17
+ probe_id: "tracker-root-settings-missing",
18
+ failure_kind: "settings_missing",
19
+ expected_error_code: "tracker_not_initialized",
20
+ expected_exit_code: 3,
21
+ recovery_kind: "initialize",
22
+ },
23
+ {
24
+ probe_id: "tracker-root-not-directory",
25
+ failure_kind: "not_directory",
26
+ expected_error_code: "tracker_root_not_directory",
27
+ expected_exit_code: 2,
28
+ recovery_kind: "select_directory",
29
+ },
30
+ {
31
+ probe_id: "tracker-root-unreadable",
32
+ failure_kind: "unreadable_root",
33
+ expected_error_code: "tracker_root_unreadable",
34
+ expected_exit_code: 1,
35
+ recovery_kind: "repair_permissions",
36
+ },
37
+ ];
38
+ /** Return defensive copies of every core tracker preflight recovery contract. */
39
+ export function listTrackerPreflightRecoveryContracts() {
40
+ return TRACKER_PREFLIGHT_RECOVERY_CONTRACTS.map((contract) => ({
41
+ ...contract,
42
+ }));
43
+ }
44
+ function findTrackerPreflightObservationFindings(contract, observation) {
45
+ const findings = [];
46
+ if (observation.error_code !== contract.expected_error_code) {
47
+ findings.push({
48
+ code: "error_code_mismatch",
49
+ probe_id: contract.probe_id,
50
+ detail: `Expected ${contract.expected_error_code}, received ${observation.error_code}.`,
51
+ });
52
+ }
53
+ if (observation.exit_code !== contract.expected_exit_code) {
54
+ findings.push({
55
+ code: "exit_code_mismatch",
56
+ probe_id: contract.probe_id,
57
+ detail: `Expected exit ${contract.expected_exit_code}, received ${observation.exit_code}.`,
58
+ });
59
+ }
60
+ if (observation.recovery_kind !== contract.recovery_kind) {
61
+ findings.push({
62
+ code: "recovery_kind_mismatch",
63
+ probe_id: contract.probe_id,
64
+ detail: `Expected ${contract.recovery_kind}, received ${observation.recovery_kind}.`,
65
+ });
66
+ }
67
+ const initIndex = observation.suggested_retry_args.indexOf("init");
68
+ const validInitCommand = initIndex === 0 ||
69
+ (initIndex === 2 &&
70
+ observation.suggested_retry_args[0] === "--pm-path" &&
71
+ observation.suggested_retry_args[1]?.length > 0);
72
+ if (contract.recovery_kind === "initialize" && !validInitCommand) {
73
+ findings.push({
74
+ code: "missing_init_recovery",
75
+ probe_id: contract.probe_id,
76
+ detail: "Missing and uninitialized roots must emit a tokenized init retry.",
77
+ });
78
+ }
79
+ if (observation.unsafe_init_recommended ||
80
+ (contract.recovery_kind !== "initialize" &&
81
+ observation.suggested_retry_args.includes("init"))) {
82
+ findings.push({
83
+ code: "unsafe_init_recovery",
84
+ probe_id: contract.probe_id,
85
+ detail: "A tracker root that cannot be initialized safely must not recommend initialization.",
86
+ });
87
+ }
88
+ if (!observation.retry_succeeded) {
89
+ findings.push({
90
+ code: "retry_failed",
91
+ probe_id: contract.probe_id,
92
+ detail: "The emitted retry or safe alternate-root recovery did not execute successfully.",
93
+ });
94
+ }
95
+ return findings;
96
+ }
97
+ /** Score runtime observations against the complete tracker preflight recovery corpus. */
98
+ export function scoreTrackerPreflightRecoveryClosure(observations) {
99
+ const observationsByProbe = new Map(observations.map((observation) => [observation.probe_id, observation]));
100
+ const findings = [];
101
+ let closedProbeCount = 0;
102
+ for (const contract of TRACKER_PREFLIGHT_RECOVERY_CONTRACTS) {
103
+ const observation = observationsByProbe.get(contract.probe_id);
104
+ if (observation === undefined) {
105
+ findings.push({
106
+ code: "missing_probe",
107
+ probe_id: contract.probe_id,
108
+ detail: "No runtime observation was supplied for this contract.",
109
+ });
110
+ continue;
111
+ }
112
+ const observationFindings = findTrackerPreflightObservationFindings(contract, observation);
113
+ findings.push(...observationFindings);
114
+ if (observationFindings.length === 0)
115
+ closedProbeCount += 1;
116
+ }
117
+ findings.sort((left, right) => left.probe_id.localeCompare(right.probe_id) ||
118
+ left.code.localeCompare(right.code));
119
+ return {
120
+ ok: findings.length === 0,
121
+ probe_count: TRACKER_PREFLIGHT_RECOVERY_CONTRACTS.length,
122
+ closed_probe_count: closedProbeCount,
123
+ findings,
124
+ };
125
+ }
126
+ //# sourceMappingURL=tracker-preflight-contracts.js.map
127
+ //# debugId=941a11a9-f756-56b3-9dc1-8afd78bc9328
@@ -4,9 +4,10 @@
4
4
  * Implements the pm annotation command 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]="0af9967c-ca72-563a-9518-2e68da0c0fe0")}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]="eac75dc5-80b4-50d2-b615-4f96edca7346")}catch(e){}}();
8
+ import { assertInitializedTracker } from "./environment/tracker-preflight.js";
8
9
  import { readFile } from "node:fs/promises";
9
- import { isFileAbsentError, pathExists } from "../core/fs/fs-utils.js";
10
+ import { isFileAbsentError } from "../core/fs/fs-utils.js";
10
11
  import { getActiveExtensionRegistrations } from "../core/extensions/index.js";
11
12
  import { resolveItemTypeRegistry } from "../core/item/type-registry.js";
12
13
  import { createStdinTokenResolver, parseCsvKv } from "../core/item/parse.js";
@@ -16,7 +17,7 @@ import { parseLimit } from "../core/shared/numeric-parsers.js";
16
17
  import { nowIso } from "../core/shared/time.js";
17
18
  import { resolveAuthor } from "../core/shared/author.js";
18
19
  import { locateItem, mutateItem, readLocatedItem, } from "../core/store/item-store.js";
19
- import { getSettingsPath, resolvePmRoot } from "../core/store/paths.js";
20
+ import { resolvePmRoot } from "../core/store/paths.js";
20
21
  import { readSettings } from "../core/store/settings.js";
21
22
  /** Map transport-level `full` onto the SDK annotation history option. */
22
23
  export function normalizeAnnotationTransportOptions(options) {
@@ -215,9 +216,7 @@ function assertAnnotationMessageHasTextSource(config, options) {
215
216
  export async function runAnnotationCommand(id, options, global, config) {
216
217
  assertAnnotationMessageHasTextSource(config, options);
217
218
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
218
- if (!(await pathExists(getSettingsPath(pmRoot)))) {
219
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
220
- }
219
+ await assertInitializedTracker(pmRoot);
221
220
  const settings = await readSettings(pmRoot);
222
221
  const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
223
222
  const limit = parseLimit(options.limit);
@@ -399,4 +398,4 @@ function renderAnnotationResult(id, collectionKey, allEntries, limit, includeMet
399
398
  };
400
399
  }
401
400
  //# sourceMappingURL=annotations.js.map
402
- //# debugId=0af9967c-ca72-563a-9518-2e68da0c0fe0
401
+ //# debugId=eac75dc5-80b4-50d2-b615-4f96edca7346
@@ -15,4 +15,4 @@ export { planProfileApplication, type ProfileApplicationPlan, type ProfileChange
15
15
  export { EXTENSION_CAPABILITY_REGISTRATION_SURFACES, collectUsedExtensionCapabilities, reconcileExtensionCapabilityUsage, type CollectUsedExtensionCapabilitiesOptions, type ExtensionCapabilityUsageReconciliation, } from "../core/extensions/capability-usage.js";
16
16
  export { renderExtensionSurfaceMarkdown, type ExtensionSurfaceMarkdownOptions, } from "../core/extensions/activation-summary-markdown.js";
17
17
  export { createExtensionContributionInventory, normalizeExtensionContributionInventory, } from "../core/extensions/contribution-inventory.js";
18
- export type { AfterCommandAffectedItem, AfterCommandHook, AfterCommandHookContext, BeforeCommandHook, BeforeCommandHookContext, BeforeMutationHook, BeforeMutationHookContext, BeforeMutationHookDecision, CommandDefinition, ExtensionCommandArgumentDefinition, CommandHandler, CommandHandlerContext, CommandHandlerResult, ExtensionCommandSdk, CommandOverride, CommandOverrideContext, ExtensionServiceName, Exporter, ExporterArtifactOutputContract, ExporterRegistrationOptions, ExtensionActivationResult, ExtensionApi, ExtensionCommandRegistry, ExtensionDeactivationFailure, ExtensionDeactivationOptions, ExtensionDeactivationResult, ExtensionDiagnostic, ExtensionContributionInventory, ExtensionDiscoveryResult, ExtensionHookRegistry, ExtensionSelfIdentity, ExtensionLoadResult, ExtensionManifest, ExtensionManifestEngines, ExtensionMutationGuardSdk, ExtensionGovernancePolicy, ExtensionPolicyOverride, ExtensionProvenanceMetadata, ExtensionRuntimePermissionDeclaration, ExtensionSearchMode, ExtensionParserRegistry, ExtensionPreflightRegistry, ExtensionRegistrationRegistry, ExtensionRendererRegistry, ExtensionServiceRegistry, FlagValueType, FlagDefinition, ImportExportContext, ImportExportRegistrationOptions, Importer, OnIndexHook, OnIndexHookContext, OnReadHook, OnReadHookContext, OnWriteHook, OnWriteHookContext, OutputRendererFormat, ParserOverride, ParserOverrideContext, ParserOverrideDelta, PreflightOverride, PreflightOverrideContext, PreflightOverrideDelta, PreflightRuntimeDecision, RegisteredExtensionExporter, RegisteredExporterArtifactOutputContract, RegisteredExtensionFlagDefinitions, RegisteredExtensionHook, RegisteredExtensionImporter, RegisteredExtensionProjectProfile, RegisteredExtensionSchemaMigrationDefinition, RegisteredExtensionSearchProvider, RegisteredExtensionServiceOverride, RegisteredExtensionVectorStoreAdapter, RendererOverride, RendererOverrideContext, SchemaFieldDefinition, SchemaItemTypeCommandOptionPolicyDefinition, SchemaItemTypeOptionDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SchemaMigrationRunContext, SchemaMigrationRunner, SearchProviderEmbedBatchContext, SearchProviderEmbedContext, SearchProviderDefinition, SearchProviderHit, SearchProviderQueryContext, SearchProviderQueryResult, ServiceOverride, ServiceOverrideContext, ServiceOverrideDecision, VectorStoreAdapterDefinition, VectorStoreDeleteContext, VectorStoreQueryContext, VectorStoreQueryHit, VectorStoreUpsertContext, VectorStoreUpsertPoint, } from "../core/extensions/loader.js";
18
+ export type { AfterCommandAffectedItem, AfterCommandHook, AfterCommandHookContext, BeforeCommandHook, BeforeCommandHookContext, BeforeMutationHook, BeforeMutationHookContext, BeforeMutationHookDecision, CommandDefinition, ExtensionCommandArgumentDefinition, CommandHandler, CommandHandlerContext, CommandHandlerResult, ExtensionCommandSdk, CommandOverride, CommandOverrideContext, ExtensionServiceName, Exporter, ExporterArtifactOutputContract, ExporterRegistrationOptions, ExtensionActivationResult, ExtensionApi, ExtensionCommandRegistry, ExtensionDeactivationFailure, ExtensionDeactivationOptions, ExtensionDeactivationResult, ExtensionDiagnostic, ExtensionContributionInventory, ExtensionDiscoveryResult, ExtensionHookRegistry, ExtensionSelfIdentity, ExtensionLoadResult, ExtensionManifest, ExtensionManifestEngines, ExtensionMutationGuardSdk, ExtensionGovernancePolicy, ExtensionPolicyOverride, ExtensionProvenanceMetadata, ExtensionRuntimePermissionDeclaration, ExtensionSearchMode, ExtensionParserRegistry, ExtensionPreflightRegistry, ExtensionRegistrationRegistry, ExtensionRendererRegistry, ExtensionServiceRegistry, FlagValueType, FlagDefinition, ImportExportContext, ImportExportRegistrationOptions, Importer, OnIndexHook, OnIndexHookContext, OnReadHook, OnReadHookContext, OnWriteHook, OnWriteHookContext, OutputRendererFormat, ParserOverride, ParserOverrideContext, ParserOverrideDelta, PreflightOverride, PreflightOverrideContext, PreflightOverrideDelta, PreflightRuntimeDecision, RegisteredExtensionExporter, RegisteredExporterArtifactOutputContract, RegisteredExtensionFlagDefinitions, RegisteredExtensionHook, RegisteredExtensionImporter, RegisteredExtensionProjectProfile, RegisteredExtensionSchemaMigrationDefinition, RegisteredExtensionSearchProvider, RegisteredExtensionServiceOverride, RegisteredExtensionVectorStoreAdapter, RendererOverride, RendererOverrideContext, SchemaFieldDefinition, SchemaItemTypeCommandOptionPolicyDefinition, SchemaItemTypeOptionDefinition, SchemaItemTypeDefinition, SchemaMigrationDefinition, SchemaMigrationRunContext, SchemaMigrationRunner, SearchProviderEmbedBatchContext, SearchProviderEmbedContext, SearchProviderDefinition, SearchProviderHit, SearchProviderQueryContext, SearchProviderQueryResult, ServiceOverride, ServiceOverrideContext, ServiceOverrideDecision, ServiceOverrideOwnership, VectorStoreAdapterDefinition, VectorStoreDeleteContext, VectorStoreQueryContext, VectorStoreQueryHit, VectorStoreUpsertContext, VectorStoreUpsertPoint, } from "../core/extensions/loader.js";
@@ -4,7 +4,7 @@
4
4
  * Provides the focused extension and package authoring 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]="6260572c-1496-58ef-9377-0825f4183bc6")}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]="bca95ba2-258c-5be2-8428-dcb8dbc87ef0")}catch(e){}}();
8
8
  export * from "./compose.js";
9
9
  export * from "./define.js";
10
10
  export * from "./extension-contracts.js";
@@ -18,4 +18,4 @@ export { EXTENSION_CAPABILITY_REGISTRATION_SURFACES, collectUsedExtensionCapabil
18
18
  export { renderExtensionSurfaceMarkdown, } from "../core/extensions/activation-summary-markdown.js";
19
19
  export { createExtensionContributionInventory, normalizeExtensionContributionInventory, } from "../core/extensions/contribution-inventory.js";
20
20
  //# sourceMappingURL=authoring.js.map
21
- //# debugId=6260572c-1496-58ef-9377-0825f4183bc6
21
+ //# debugId=bca95ba2-258c-5be2-8428-dcb8dbc87ef0
@@ -6,6 +6,59 @@ export type PmOutputDegradationStep = (typeof PM_OUTPUT_DEGRADATION_STEPS)[numbe
6
6
  export declare const PM_OUTPUT_BUDGET_CLASSES: readonly ["mutation", "read", "discovery", "governance"];
7
7
  /** Restricts command-output budget classes. */
8
8
  export type PmOutputBudgetClass = (typeof PM_OUTPUT_BUDGET_CLASSES)[number];
9
+ /** Stable diagnostic families that require independent output ceilings. */
10
+ export declare const PM_DIAGNOSTIC_OUTPUT_CLASSES: readonly ["error", "warning", "validation_summary", "recovery_bundle"];
11
+ /** Restricts diagnostic budget selection to declared families. */
12
+ export type PmDiagnosticOutputClass = (typeof PM_DIAGNOSTIC_OUTPUT_CLASSES)[number];
13
+ /** Deterministic diagnostic degradation stages, from richest to smallest. */
14
+ export declare const PM_DIAGNOSTIC_DEGRADATION_STEPS: readonly ["full", "omit_explanation", "limit_collections", "compact_recovery", "action_only"];
15
+ /** Restricts diagnostic degradation receipts to declared stages. */
16
+ export type PmDiagnosticDegradationStep = (typeof PM_DIAGNOSTIC_DEGRADATION_STEPS)[number];
17
+ /** Declares one diagnostic family's text and JSON token ceilings. */
18
+ export interface PmDiagnosticOutputBudgetContract {
19
+ /** Diagnostic family governed by this contract. */
20
+ diagnostic_class: PmDiagnosticOutputClass;
21
+ /** Default ceiling by rendered transport. */
22
+ default_max_estimated_tokens_by_format: Readonly<{
23
+ text: number;
24
+ json: number;
25
+ }>;
26
+ /** Smallest explicit ceiling accepted by the projector. */
27
+ minimum_max_estimated_tokens: number;
28
+ /** Ordered degradation policy applied when the ceiling binds. */
29
+ degradation_ladder: readonly PmDiagnosticDegradationStep[];
30
+ /** Paths whose first actionable value must survive degradation. */
31
+ corrective_action_paths: readonly string[];
32
+ /** Stable estimate used by gates and SDK consumers. */
33
+ token_estimate: "ceil(utf8_bytes / 4)";
34
+ }
35
+ /** Machine-readable disclosure attached to a projected diagnostic. */
36
+ export interface PmDiagnosticOutputReceipt {
37
+ /** Diagnostic family whose contract bound the output. */
38
+ diagnostic_class: PmDiagnosticOutputClass;
39
+ /** Rendered transport measured by the projector. */
40
+ format: "json" | "text";
41
+ /** Effective estimated-token ceiling. */
42
+ budget: number;
43
+ /** Whether the caller supplied the ceiling or used the declaration. */
44
+ budget_source: "default" | "explicit";
45
+ /** Estimate before diagnostic degradation. */
46
+ original_estimated_tokens: number;
47
+ /** Exact estimate of the returned projection. */
48
+ estimated_tokens: number;
49
+ /** Whether one or more fields were removed or compacted. */
50
+ truncated: boolean;
51
+ /** Applied stages in contract order. */
52
+ degradation_steps: PmDiagnosticDegradationStep[];
53
+ /** Top-level fields removed from the original diagnostic. */
54
+ omitted_fields: string[];
55
+ /** Additional omitted fields not named individually in a bounded receipt. */
56
+ omitted_fields_overflow_count?: number;
57
+ }
58
+ /** JSON diagnostic after binding it to a declared output contract. */
59
+ export type PmProjectedDiagnostic<TDiagnostic extends object> = Partial<TDiagnostic> & Pick<TDiagnostic, Extract<keyof TDiagnostic, "code" | "required">> & {
60
+ diagnostic_output?: PmDiagnosticOutputReceipt;
61
+ };
9
62
  /** Describes one command's default agent-output budget and degradation policy. */
10
63
  export interface PmCommandOutputBudgetContract {
11
64
  /** Canonical or compatibility command name. */
@@ -26,6 +79,8 @@ export interface PmCommandOutputBudgetContract {
26
79
  /** Stable estimate used by gates and SDK consumers. */
27
80
  token_estimate: "ceil(utf8_bytes / 4)";
28
81
  }
82
+ /** Public default contract for every diagnostic family. */
83
+ export declare const PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS: PmDiagnosticOutputBudgetContract[];
29
84
  /** Infer the conservative workload class for a core or package command. */
30
85
  export declare function inferPmOutputBudgetClass(command: string): PmOutputBudgetClass;
31
86
  /** Build the generated default budget for a core or package command. */
@@ -48,3 +103,25 @@ export declare function resolvePmCommandOutputBudget(command: string, options?:
48
103
  }): PmCommandOutputBudgetContract | null;
49
104
  /** Estimate conservative token usage from UTF-8 output bytes. */
50
105
  export declare function estimatePmOutputTokens(utf8Bytes: number): number;
106
+ /** Resolve the binding output contract for one diagnostic family. */
107
+ export declare function resolvePmDiagnosticOutputBudget(diagnosticClass: PmDiagnosticOutputClass): PmDiagnosticOutputBudgetContract;
108
+ /**
109
+ * Bind a JSON diagnostic to its declared ceiling while preserving the first
110
+ * corrective action and reporting every top-level omission.
111
+ */
112
+ export declare function projectPmDiagnosticOutput<TDiagnostic extends object>(diagnostic: TDiagnostic, options?: {
113
+ diagnosticClass?: PmDiagnosticOutputClass;
114
+ maxEstimatedTokens?: number;
115
+ }): PmProjectedDiagnostic<TDiagnostic>;
116
+ /** Text diagnostic together with the same measured receipt used by JSON. */
117
+ export interface PmProjectedTextDiagnostic {
118
+ /** Rendered action-first diagnostic. */
119
+ output: string;
120
+ /** Binding diagnostic budget receipt. */
121
+ diagnostic_output: PmDiagnosticOutputReceipt;
122
+ }
123
+ /** Bind human-readable diagnostics without ever truncating the corrective action away. */
124
+ export declare function projectPmDiagnosticText(output: string, correctiveAction: string, options?: {
125
+ diagnosticClass?: PmDiagnosticOutputClass;
126
+ maxEstimatedTokens?: number;
127
+ }): PmProjectedTextDiagnostic;