@unbrained/pm-cli 2026.8.11 → 2026.8.13

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 (250) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +74 -21
  3. package/dist/cli/commander-usage.js +37 -11
  4. package/dist/cli/error-guidance.d.ts +2 -0
  5. package/dist/cli/error-guidance.js +82 -19
  6. package/dist/cli/main.js +35 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.js +28 -17
  9. package/dist/cli/register-list-query.js +10 -7
  10. package/dist/cli/register-operations.js +16 -6
  11. package/dist/cli-bundle/bundle-manifest.json +163 -163
  12. package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
  14. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
  16. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
  17. package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
  20. package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
  21. package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
  22. package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
  23. package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +42 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -2
  58. package/dist/core/checkpoint/checkpoint-gc.js +7 -12
  59. package/dist/core/extensions/activation-summary-markdown.js +5 -4
  60. package/dist/core/extensions/activation-summary.d.ts +2 -0
  61. package/dist/core/extensions/activation-summary.js +6 -2
  62. package/dist/core/extensions/capability-usage.d.ts +1 -1
  63. package/dist/core/extensions/capability-usage.js +4 -3
  64. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  65. package/dist/core/extensions/contribution-inventory.js +6 -2
  66. package/dist/core/extensions/extension-registries.js +3 -2
  67. package/dist/core/extensions/extension-types.d.ts +83 -1
  68. package/dist/core/extensions/extension-types.js +3 -2
  69. package/dist/core/extensions/loader.d.ts +2 -8
  70. package/dist/core/extensions/loader.js +53 -144
  71. package/dist/core/extensions/registration-values.d.ts +43 -0
  72. package/dist/core/extensions/registration-values.js +210 -0
  73. package/dist/core/extensions/reserved-host-flags.js +3 -2
  74. package/dist/core/extensions/runtime-registrations.d.ts +3 -1
  75. package/dist/core/extensions/runtime-registrations.js +12 -2
  76. package/dist/core/fs/fs-utils.d.ts +2 -0
  77. package/dist/core/fs/fs-utils.js +7 -3
  78. package/dist/core/history/drift-cache.js +4 -3
  79. package/dist/core/history/drift-scan.js +16 -17
  80. package/dist/core/history/history.d.ts +8 -0
  81. package/dist/core/history/history.js +57 -7
  82. package/dist/core/history/replay.d.ts +9 -1
  83. package/dist/core/history/replay.js +48 -13
  84. package/dist/core/lock/lock-gc.js +8 -13
  85. package/dist/core/lock/lock.js +5 -4
  86. package/dist/core/output/output.d.ts +2 -0
  87. package/dist/core/output/output.js +46 -14
  88. package/dist/core/search/vector-stores.js +6 -11
  89. package/dist/core/shared/command-types.d.ts +2 -0
  90. package/dist/core/shared/command-types.js +2 -2
  91. package/dist/core/shared/errors.d.ts +5 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  94. package/dist/core/store/item-metadata-cache.js +16 -9
  95. package/dist/core/telemetry/runtime.d.ts +6 -0
  96. package/dist/core/telemetry/runtime.js +101 -30
  97. package/dist/sdk/agent/command-recovery.d.ts +2 -0
  98. package/dist/sdk/agent/command-recovery.js +10 -2
  99. package/dist/sdk/annotations.js +4 -4
  100. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  101. package/dist/sdk/cli-bootstrap.js +6 -2
  102. package/dist/sdk/cli-contracts/completeness.js +10 -3
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  104. package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
  105. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  106. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  107. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
  108. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
  109. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
  111. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  112. package/dist/sdk/cli-contracts/tool-schema.js +22 -4
  113. package/dist/sdk/cli-program.js +3 -2
  114. package/dist/sdk/comments.js +4 -3
  115. package/dist/sdk/compile-cache.js +4 -3
  116. package/dist/sdk/completion.js +16 -7
  117. package/dist/sdk/compose.d.ts +3 -1
  118. package/dist/sdk/compose.js +16 -2
  119. package/dist/sdk/context-intent-contracts.js +45 -4
  120. package/dist/sdk/context-signal-store.js +4 -3
  121. package/dist/sdk/core.d.ts +1 -0
  122. package/dist/sdk/core.js +3 -2
  123. package/dist/sdk/extension/install-runtime.js +4 -4
  124. package/dist/sdk/extension/managed-state.js +4 -3
  125. package/dist/sdk/extension-contracts.d.ts +1 -1
  126. package/dist/sdk/flag-invocation-contracts.js +5 -6
  127. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  128. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
  129. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  130. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  131. package/dist/sdk/generated-error-code-catalog.js +6 -3140
  132. package/dist/sdk/governance/assurance-action.d.ts +27 -3
  133. package/dist/sdk/governance/assurance-action.js +117 -31
  134. package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
  135. package/dist/sdk/governance/assurance-mutation-error.js +58 -0
  136. package/dist/sdk/governance/assurance-presets.d.ts +54 -0
  137. package/dist/sdk/governance/assurance-presets.js +136 -0
  138. package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
  139. package/dist/sdk/governance/assurance-runtime.js +118 -14
  140. package/dist/sdk/governance/assurance.d.ts +51 -6
  141. package/dist/sdk/governance/assurance.js +321 -67
  142. package/dist/sdk/governance/gc.js +5 -11
  143. package/dist/sdk/governance/health.d.ts +3 -1
  144. package/dist/sdk/governance/health.js +24 -7
  145. package/dist/sdk/governance/validate-item-reader.js +3 -3
  146. package/dist/sdk/governance/validate.d.ts +2 -0
  147. package/dist/sdk/governance/validate.js +15 -5
  148. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  149. package/dist/sdk/graph/durable-cache.js +156 -29
  150. package/dist/sdk/graph/governance-contracts.d.ts +12 -0
  151. package/dist/sdk/graph/governance-contracts.js +27 -0
  152. package/dist/sdk/graph/governance.d.ts +44 -2
  153. package/dist/sdk/graph/governance.js +156 -12
  154. package/dist/sdk/guide.js +4 -4
  155. package/dist/sdk/index.d.ts +3 -2
  156. package/dist/sdk/index.js +5 -4
  157. package/dist/sdk/lifecycle/claim.js +10 -3
  158. package/dist/sdk/linked-artifacts.d.ts +2 -0
  159. package/dist/sdk/linked-artifacts.js +29 -4
  160. package/dist/sdk/merge/driver.d.ts +2 -2
  161. package/dist/sdk/merge/driver.js +3 -3
  162. package/dist/sdk/merge/install.js +5 -4
  163. package/dist/sdk/merge/receipts.d.ts +6 -4
  164. package/dist/sdk/merge/receipts.js +7 -5
  165. package/dist/sdk/merge/three-way.d.ts +2 -2
  166. package/dist/sdk/merge/three-way.js +3 -3
  167. package/dist/sdk/output-projection.d.ts +9 -1
  168. package/dist/sdk/output-projection.js +45 -9
  169. package/dist/sdk/query/activity.d.ts +49 -2
  170. package/dist/sdk/query/activity.js +185 -38
  171. package/dist/sdk/query/get.js +19 -2
  172. package/dist/sdk/read-output-contracts.d.ts +5 -1
  173. package/dist/sdk/read-output-contracts.js +17 -2
  174. package/dist/sdk/read-output-session.d.ts +2 -0
  175. package/dist/sdk/read-output-session.js +12 -5
  176. package/dist/sdk/relationship-history.js +5 -5
  177. package/dist/sdk/runtime-primitives.d.ts +3 -3
  178. package/dist/sdk/runtime-primitives.js +5 -5
  179. package/dist/sdk/runtime-stats-options.js +3 -2
  180. package/dist/sdk/runtime.js +5 -9
  181. package/dist/sdk/schema-migration.js +4 -4
  182. package/dist/sdk/stats.d.ts +36 -3
  183. package/dist/sdk/stats.js +55 -15
  184. package/dist/sdk/test/execution.d.ts +4 -0
  185. package/dist/sdk/test/execution.js +88 -23
  186. package/dist/sdk/workspace-memory.js +4 -4
  187. package/dist/sdk/workspace-snapshot.js +8 -14
  188. package/dist/sdk/workspace-transaction-gc.js +4 -9
  189. package/dist/sdk/workspace-transaction.js +4 -4
  190. package/dist/sdk/workspace.js +4 -3
  191. package/dist/types.d.ts +2 -0
  192. package/dist/types.js +2 -2
  193. package/docs/ASSURANCE.md +170 -14
  194. package/docs/COMMANDS.md +29 -8
  195. package/docs/CONFIGURATION.md +9 -0
  196. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  197. package/docs/EXTENSIONS.md +11 -12
  198. package/docs/MERGE_SAFETY.md +3 -1
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  202. package/docs/RELATIONSHIP_GRAPH.md +15 -0
  203. package/docs/SDK.md +17 -3
  204. package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
  205. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  206. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  207. package/docs/TESTING.md +24 -15
  208. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  209. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  210. package/marketplace.json +2 -2
  211. package/package.json +6 -6
  212. package/packages/pm-beads/package.json +1 -1
  213. package/packages/pm-calendar/package.json +1 -1
  214. package/packages/pm-command-kit/package.json +1 -1
  215. package/packages/pm-digital-twin/package.json +1 -1
  216. package/packages/pm-governance-audit/package.json +1 -1
  217. package/packages/pm-guide-shell/package.json +1 -1
  218. package/packages/pm-kanban/package.json +1 -1
  219. package/packages/pm-lifecycle-hooks/package.json +1 -1
  220. package/packages/pm-linked-test-adapters/package.json +1 -1
  221. package/packages/pm-search-advanced/package.json +1 -1
  222. package/packages/pm-templates/package.json +1 -1
  223. package/packages/pm-todos/package.json +1 -1
  224. package/packages/pm-vcs/package.json +1 -1
  225. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  226. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  227. package/sdk/public-surface.json +384 -83
  228. package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
  230. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
  231. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
  232. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
  235. package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
  236. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
  237. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
  242. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
  244. package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
  245. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
  246. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
  248. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
  249. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
@@ -4,13 +4,13 @@
4
4
  * Implements the pm test 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]="2c0646bf-44d7-521f-aea1-b0683d88a8fa")}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]="76053150-cc55-57e0-80d6-369196284cd0")}catch(e){}}();
8
8
  import { spawn } from "node:child_process";
9
9
  import { cp, mkdir, mkdtemp, open, readdir, rm } from "node:fs/promises";
10
10
  import { tmpdir } from "node:os";
11
11
  import path from "node:path";
12
12
  import { getActiveExtensionRegistrations } from "../../core/extensions/index.js";
13
- import { pathExists } from "../../core/fs/fs-utils.js";
13
+ import { isFileMissingError, pathExists } from "../../core/fs/fs-utils.js";
14
14
  import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
15
15
  import { createStdinTokenResolver, parseCsvKv, parseOptionalNumber, } from "../../core/item/parse.js";
16
16
  import { EXIT_CODE } from "../../core/shared/constants.js";
@@ -507,7 +507,6 @@ function parseAddJsonEntries(raw) {
507
507
  return parsed;
508
508
  });
509
509
  }
510
- /* c8 ignore stop */
511
510
  function parseRemoveEntries(raw) {
512
511
  if (!raw)
513
512
  return [];
@@ -516,19 +515,48 @@ function parseRemoveEntries(raw) {
516
515
  if (!trimmed) {
517
516
  throw new PmCliError("--remove requires command or path value", EXIT_CODE.USAGE);
518
517
  }
519
- if (trimmed.includes("=") ||
520
- /^(?:[-*+]\s+)?(?:path|command)\s*[:=]/i.test(trimmed) ||
518
+ const identityPrefix = /^(command|path)\s*=/i.exec(trimmed);
519
+ if (identityPrefix) {
520
+ const value = trimmed.slice(identityPrefix[0].length).trim();
521
+ if (!value) {
522
+ throw new PmCliError("--remove requires a non-empty command=<value> or path=<value>", EXIT_CODE.USAGE);
523
+ }
524
+ return {
525
+ kind: identityPrefix[1].toLowerCase(),
526
+ value,
527
+ };
528
+ }
529
+ if (/^[A-Za-z_][\w-]*=\S+$/u.test(trimmed)) {
530
+ throw new PmCliError("--remove structured selectors require command=<value> or path=<value>", EXIT_CODE.USAGE);
531
+ }
532
+ if (/^(?:[-*+]\s+)?(?:path|command)\s*:/i.test(trimmed) ||
521
533
  trimmed.startsWith("```")) {
522
534
  const kv = parseCsvKv(trimmed, "--remove");
535
+ const kind = kv.path !== undefined ? "path" : "command";
523
536
  const value = kv.path ?? kv.command;
524
537
  if (!value?.trim()) {
525
538
  throw new PmCliError("--remove requires command=<value> and/or path=<value>", EXIT_CODE.USAGE);
526
539
  }
527
- return value.trim();
540
+ return { kind, value: value.trim() };
528
541
  }
529
- return trimmed;
542
+ return { kind: "either", value: trimmed };
530
543
  });
531
544
  }
545
+ function parseRemoveIndexes(raw) {
546
+ if (!raw)
547
+ return [];
548
+ return [
549
+ ...new Set(raw.map((value) => {
550
+ const parsed = typeof value === "number" ? value : Number.parseInt(value, 10);
551
+ if (!Number.isInteger(parsed) ||
552
+ parsed < 1 ||
553
+ String(parsed) !== String(value).trim()) {
554
+ throw new PmCliError("--remove-index must be a positive integer", EXIT_CODE.USAGE);
555
+ }
556
+ return parsed;
557
+ })),
558
+ ];
559
+ }
532
560
  function closeLinkedTestStdin(child) {
533
561
  // Force EOF on child stdin so non-interactive runs do not wait on input.
534
562
  try {
@@ -961,7 +989,7 @@ async function copyIntoSandboxIfPresent(sourcePath, targetPath, recursive = fals
961
989
  if (typeof error === "object" &&
962
990
  error !== null &&
963
991
  "code" in error &&
964
- error.code === "ENOENT") {
992
+ isFileMissingError(error)) {
965
993
  return;
966
994
  }
967
995
  throw error;
@@ -1383,7 +1411,10 @@ function resolveLinkedTestPreflightResult(params) {
1383
1411
  }
1384
1412
  function buildLinkedTestExecutionEnv(params) {
1385
1413
  const effectiveDirectives = resolveEffectiveLinkedTestDirectives(params.runtimeDirectives, params.linkedTest);
1386
- const executionEnv = { ...process.env };
1414
+ const executionEnv = {
1415
+ ...process.env,
1416
+ SENTRY_ENVIRONMENT: "test",
1417
+ };
1387
1418
  applyEnvDirectiveStage(executionEnv, params.runtimeDirectives);
1388
1419
  applyEnvDirectiveStage(executionEnv, {
1389
1420
  env_set: params.linkedTest.env_set ?? {},
@@ -1538,6 +1569,7 @@ async function readLinkedTestItem(params) {
1538
1569
  tests: loaded.document.metadata.tests ?? [],
1539
1570
  testRuns: loaded.document.metadata.test_runs ?? [],
1540
1571
  changed: false,
1572
+ removed: 0,
1541
1573
  };
1542
1574
  }
1543
1575
  function linkedTestsHaveSameIdentity(left, right) {
@@ -1555,15 +1587,26 @@ function appendMissingLinkedTests(current, additions) {
1555
1587
  }
1556
1588
  return next;
1557
1589
  }
1558
- function removeLinkedTestsBySelector(current, removals) {
1559
- if (removals.length === 0) {
1560
- return current;
1590
+ function removeLinkedTestsBySelector(current, removals, removeIndexes) {
1591
+ if (removals.length === 0 && removeIndexes.length === 0) {
1592
+ return { tests: current, removed: 0 };
1561
1593
  }
1562
- return current.filter((entry) => !removals.includes(entry.path ?? "") &&
1563
- !removals.includes(entry.command ?? ""));
1594
+ const indexSet = new Set(removeIndexes);
1595
+ const tests = current.filter((entry, index) => {
1596
+ if (indexSet.has(index + 1))
1597
+ return false;
1598
+ return !removals.some((selector) => {
1599
+ if (selector.kind === "command")
1600
+ return entry.command === selector.value;
1601
+ if (selector.kind === "path")
1602
+ return entry.path === selector.value;
1603
+ return entry.command === selector.value || entry.path === selector.value;
1604
+ });
1605
+ });
1606
+ return { tests, removed: current.length - tests.length };
1564
1607
  }
1565
- function applyLinkedTestMutations(previous, adds, removes) {
1566
- return removeLinkedTestsBySelector(appendMissingLinkedTests(previous, adds), removes);
1608
+ function applyLinkedTestMutations(previous, adds, removes, removeIndexes) {
1609
+ return removeLinkedTestsBySelector(appendMissingLinkedTests(previous, adds), removes, removeIndexes);
1567
1610
  }
1568
1611
  function hasTestRuntimeDirectiveFlags(options) {
1569
1612
  return ((options.envSet?.length ?? 0) > 0 ||
@@ -1590,25 +1633,43 @@ function assertTestRunFlagUsage(options) {
1590
1633
  }
1591
1634
  }
1592
1635
  async function resolveLinkedTestItem(params) {
1593
- const { id, options, pmRoot, settings, typeToFolder, adds, removes } = params;
1594
- if (adds.length === 0 && removes.length === 0) {
1636
+ const { id, options, pmRoot, settings, typeToFolder, adds, removes, removeIndexes, } = params;
1637
+ if (adds.length === 0 && removes.length === 0 && removeIndexes.length === 0) {
1595
1638
  return readLinkedTestItem({ id, pmRoot, settings, typeToFolder });
1596
1639
  }
1640
+ let removed = 0;
1597
1641
  const result = await mutateItem({
1598
1642
  pmRoot,
1599
1643
  settings,
1600
1644
  id,
1601
- op: "tests_add",
1645
+ op: adds.length > 0 ? "tests_add" : "tests_remove",
1602
1646
  author: resolveAuthor(options.author, settings.author_default),
1603
1647
  message: options.message,
1604
1648
  force: options.force,
1605
1649
  skipNoop: true,
1606
1650
  mutate(document) {
1607
1651
  const previous = document.metadata.tests ?? [];
1608
- const next = applyLinkedTestMutations(previous, adds, removes);
1609
- document.metadata.tests = next;
1652
+ const mutation = applyLinkedTestMutations(previous, adds, removes, removeIndexes);
1653
+ removed = mutation.removed;
1654
+ if ((removes.length > 0 || removeIndexes.length > 0) && removed === 0) {
1655
+ throw new PmCliError("No linked tests matched the requested removal selector", EXIT_CODE.NOT_FOUND, {
1656
+ code: "linked_test_remove_no_match",
1657
+ unmatched: [
1658
+ ...removes.map((entry) => `${entry.kind}=${entry.value}`),
1659
+ ...removeIndexes.map((index) => `index=${index}`),
1660
+ ],
1661
+ required: "List linked tests and retry with an exact command/path or a current 1-based --remove-index.",
1662
+ examples: [
1663
+ `pm test ${id} --list`,
1664
+ `pm test ${id} --remove-index 1`,
1665
+ ],
1666
+ });
1667
+ }
1668
+ document.metadata.tests = mutation.tests;
1610
1669
  return {
1611
- changedFields: stableValueEquals(previous, next) ? [] : ["tests"],
1670
+ changedFields: stableValueEquals(previous, mutation.tests)
1671
+ ? []
1672
+ : ["tests"],
1612
1673
  };
1613
1674
  },
1614
1675
  });
@@ -1617,6 +1678,7 @@ async function resolveLinkedTestItem(params) {
1617
1678
  tests: result.item.tests ?? [],
1618
1679
  testRuns: result.item.test_runs ?? [],
1619
1680
  changed: result.changedFields.length > 0,
1681
+ removed,
1620
1682
  };
1621
1683
  }
1622
1684
  function resolveTestRunOptions(options, tests) {
@@ -1780,6 +1842,7 @@ export async function runTest(id, options, global) {
1780
1842
  ...parseAddJsonEntries(resolvedAddJsons),
1781
1843
  ];
1782
1844
  const removes = parseRemoveEntries(resolvedRemoves);
1845
+ const removeIndexes = parseRemoveIndexes(options.removeIndex);
1783
1846
  const item = await resolveLinkedTestItem({
1784
1847
  id,
1785
1848
  options,
@@ -1788,6 +1851,7 @@ export async function runTest(id, options, global) {
1788
1851
  typeToFolder: typeRegistry.type_to_folder,
1789
1852
  adds,
1790
1853
  removes,
1854
+ removeIndexes,
1791
1855
  });
1792
1856
  const runOptions = resolveTestRunOptions(options, item.tests);
1793
1857
  const runStartedAt = options.run === true ? nowIso() : undefined;
@@ -1835,6 +1899,7 @@ export async function runTest(id, options, global) {
1835
1899
  warnings: warnings.length > 0 ? warnings : undefined,
1836
1900
  changed: item.changed,
1837
1901
  count: item.tests.length,
1902
+ ...(item.removed > 0 ? { removed: item.removed } : {}),
1838
1903
  ...measurementProjection,
1839
1904
  };
1840
1905
  }
@@ -1874,4 +1939,4 @@ export const _testOnlyTestCommand = {
1874
1939
  summarizeRunResultStatuses,
1875
1940
  };
1876
1941
  //# sourceMappingURL=execution.js.map
1877
- //# debugId=2c0646bf-44d7-521f-aea1-b0683d88a8fa
1942
+ //# debugId=76053150-cc55-57e0-80d6-369196284cd0
@@ -4,10 +4,10 @@
4
4
  * Builds compact, cursor-bound historical rollups for large workspaces.
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]="2e225010-1b53-59e9-8188-dcbe4a4f7eb7")}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]="ad77a79d-54da-55f1-8ac8-935366880d90")}catch(e){}}();
8
8
  import path from "node:path";
9
9
  import { createHash } from "node:crypto";
10
- import { writeFileAtomic } from "../core/fs/fs-utils.js";
10
+ import { isFileAbsentError, writeFileAtomic } from "../core/fs/fs-utils.js";
11
11
  import { normalizeStatusForRegistry } from "../core/item/status.js";
12
12
  import { stableStringify } from "../core/shared/serialization.js";
13
13
  import { readItemMetadataDerivedIndexState } from "../core/store/item-metadata-cache.js";
@@ -194,7 +194,7 @@ async function readPersistedWorkspaceMemory(filePath) {
194
194
  const missing = typeof error === "object" &&
195
195
  error !== null &&
196
196
  "code" in error &&
197
- error.code === "ENOENT";
197
+ isFileAbsentError(error);
198
198
  return { snapshot: null, invalid: !missing };
199
199
  }
200
200
  }
@@ -316,4 +316,4 @@ export function searchWorkspaceMemoryReadResult(memory, query, limit = 5) {
316
316
  };
317
317
  }
318
318
  //# sourceMappingURL=workspace-memory.js.map
319
- //# debugId=2e225010-1b53-59e9-8188-dcbe4a4f7eb7
319
+ //# debugId=ad77a79d-54da-55f1-8ac8-935366880d90
@@ -5,11 +5,11 @@
5
5
  * state while excluding clone-local caches, locks, and recovery journals.
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]="470bb466-4619-5c54-a154-186b7ef4a049")}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]="36aacc71-c5f5-56f1-85f4-28b2be5b02e2")}catch(e){}}();
9
9
  import crypto from "node:crypto";
10
10
  import { cp, lstat, mkdir, readFile, readdir, rename, rm, writeFile, } from "node:fs/promises";
11
11
  import path from "node:path";
12
- import { writeFileAtomic } from "../core/fs/fs-utils.js";
12
+ import { isFileMissingError, writeFileAtomic } from "../core/fs/fs-utils.js";
13
13
  import { appendWorkspaceAuditEvent } from "../core/history/workspace-history.js";
14
14
  import { acquireLock } from "../core/lock/lock.js";
15
15
  import { getLockPath } from "../core/store/paths.js";
@@ -205,12 +205,6 @@ function validateSnapshotTarget(target) {
205
205
  });
206
206
  }
207
207
  }
208
- function isErrno(error, code) {
209
- return (typeof error === "object" &&
210
- error !== null &&
211
- "code" in error &&
212
- error.code === code);
213
- }
214
208
  /**
215
209
  * Runs a bounded snapshot filesystem stage, converting host environment faults
216
210
  * into declared refusals.
@@ -250,7 +244,7 @@ async function readSnapshotJson(file, target) {
250
244
  return JSON.parse(await readFile(file, "utf8"));
251
245
  }
252
246
  catch (error) {
253
- if (isErrno(error, "ENOENT")) {
247
+ if (isFileMissingError(error)) {
254
248
  throw workspaceSnapshotNotFound(target);
255
249
  }
256
250
  throw error;
@@ -261,7 +255,7 @@ async function removeSnapshotEntry(entry, target, recursive) {
261
255
  await rm(entry, { recursive });
262
256
  }
263
257
  catch (error) {
264
- if (isErrno(error, "ENOENT")) {
258
+ if (isFileMissingError(error)) {
265
259
  throw workspaceSnapshotNotFound(target);
266
260
  }
267
261
  throw error;
@@ -335,7 +329,7 @@ export async function createWorkspaceSnapshot(pmRoot, options = {}) {
335
329
  deduplicated = objectStat.isDirectory();
336
330
  }
337
331
  catch (error) {
338
- if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
332
+ if (!(error instanceof Error && "code" in error && isFileMissingError(error))) {
339
333
  throw error;
340
334
  }
341
335
  }
@@ -392,7 +386,7 @@ export async function listWorkspaceSnapshots(pmRoot) {
392
386
  const objectNames = await readdir(path.join(store, "objects")).catch((error) => {
393
387
  if (error instanceof Error &&
394
388
  "code" in error &&
395
- error.code === "ENOENT") {
389
+ isFileMissingError(error)) {
396
390
  return [];
397
391
  }
398
392
  throw error;
@@ -400,7 +394,7 @@ export async function listWorkspaceSnapshots(pmRoot) {
400
394
  const referenceNames = await readdir(path.join(store, "refs")).catch((error) => {
401
395
  if (error instanceof Error &&
402
396
  "code" in error &&
403
- error.code === "ENOENT") {
397
+ isFileMissingError(error)) {
404
398
  return [];
405
399
  }
406
400
  throw error;
@@ -609,4 +603,4 @@ export async function deleteWorkspaceSnapshot(pmRoot, target) {
609
603
  return { deleted: "object", target };
610
604
  }
611
605
  //# sourceMappingURL=workspace-snapshot.js.map
612
- //# debugId=470bb466-4619-5c54-a154-186b7ef4a049
606
+ //# debugId=36aacc71-c5f5-56f1-85f4-28b2be5b02e2
@@ -13,17 +13,12 @@
13
13
  * never breaks correctness.
14
14
  */
15
15
 
16
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a6c0aa24-501a-5e76-a669-91d125634cf1")}catch(e){}}();
16
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7df80849-51e1-5efa-b40a-b44088f941a9")}catch(e){}}();
17
+ import { isFileMissingError } from "../core/fs/fs-utils.js";
17
18
  import fs from "node:fs/promises";
18
19
  import path from "node:path";
19
20
  const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
20
21
  const TERMINAL_JOURNAL_STATUSES = new Set(["committed", "compensated"]);
21
- function isErrno(error, code) {
22
- return (typeof error === "object" &&
23
- error !== null &&
24
- "code" in error &&
25
- error.code === code);
26
- }
27
22
  function readJournalStatusAndTimestamp(raw) {
28
23
  let parsed;
29
24
  try {
@@ -129,7 +124,7 @@ export async function runWorkspaceTransactionGc(pmRoot, options) {
129
124
  .sort((left, right) => left.localeCompare(right));
130
125
  }
131
126
  catch (error) {
132
- if (isErrno(error, "ENOENT")) {
127
+ if (isFileMissingError(error)) {
133
128
  return result;
134
129
  }
135
130
  throw error;
@@ -152,4 +147,4 @@ export async function runWorkspaceTransactionGc(pmRoot, options) {
152
147
  return result;
153
148
  }
154
149
  //# sourceMappingURL=workspace-transaction-gc.js.map
155
- //# debugId=a6c0aa24-501a-5e76-a669-91d125634cf1
150
+ //# debugId=7df80849-51e1-5efa-b40a-b44088f941a9
@@ -5,11 +5,11 @@
5
5
  * mutation primitives without rewriting immutable item or relationship history.
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]="d49ec604-c10c-5706-9d87-510845e55e1a")}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]="6ed4a26f-2ae2-556a-87db-56844108757f")}catch(e){}}();
9
9
  import { mkdir, readFile } from "node:fs/promises";
10
10
  import path from "node:path";
11
11
  import { acquireLock } from "../core/lock/lock.js";
12
- import { writeFileAtomic } from "../core/fs/fs-utils.js";
12
+ import { isFileMissingError, writeFileAtomic } from "../core/fs/fs-utils.js";
13
13
  import { nowIso } from "../core/shared/time.js";
14
14
  /**
15
15
  * Deliberate process-boundary interruption used by deterministic crash tests.
@@ -244,7 +244,7 @@ async function loadJournal(pmRoot, transactionId, stepIds) {
244
244
  if (error !== null &&
245
245
  typeof error === "object" &&
246
246
  "code" in error &&
247
- error.code === "ENOENT")
247
+ isFileMissingError(error))
248
248
  return undefined;
249
249
  throw error;
250
250
  }
@@ -361,4 +361,4 @@ export async function commitWorkspaceTransaction(options) {
361
361
  }
362
362
  }
363
363
  //# sourceMappingURL=workspace-transaction.js.map
364
- //# debugId=d49ec604-c10c-5706-9d87-510845e55e1a
364
+ //# debugId=6ed4a26f-2ae2-556a-87db-56844108757f
@@ -4,7 +4,8 @@
4
4
  * Maintains repository-scaffold contracts shared by the public SDK and CLI.
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]="bbfa5b19-d801-582a-98e8-0c4925dd57c0")}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]="89261a49-97e5-5ffc-a81c-2409f0b529cf")}catch(e){}}();
8
+ import { isFileMissingError } from "../core/fs/fs-utils.js";
8
9
  import { readFile, writeFile } from "node:fs/promises";
9
10
  import path from "node:path";
10
11
  import { EXIT_CODE } from "../core/shared/constants.js";
@@ -107,7 +108,7 @@ export async function ensurePmGitignore(workspaceRoot, options = {}) {
107
108
  current = await withGitignorePermissionRecovery(() => readFile(gitignorePath, "utf8"));
108
109
  }
109
110
  catch (error) {
110
- if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) {
111
+ if (!(error instanceof Error && "code" in error && isFileMissingError(error))) {
111
112
  throw error;
112
113
  }
113
114
  }
@@ -125,4 +126,4 @@ export async function ensurePmGitignore(workspaceRoot, options = {}) {
125
126
  return { path: gitignorePath, changed: true };
126
127
  }
127
128
  //# sourceMappingURL=workspace.js.map
128
- //# debugId=bbfa5b19-d801-582a-98e8-0c4925dd57c0
129
+ //# debugId=89261a49-97e5-5ffc-a81c-2409f0b529cf
package/dist/types.d.ts CHANGED
@@ -776,6 +776,8 @@ export interface HistoryEntry {
776
776
  before_hash: string;
777
777
  /** Value that configures or reports after hash for this contract. */
778
778
  after_hash: string;
779
+ /** Version of the item canonicalization used by before_hash and after_hash. Absent on legacy streams. */
780
+ item_hash_version?: number;
779
781
  /** Human-readable explanation suitable for logs and agent-facing output. */
780
782
  message?: string;
781
783
  /** Structured audit metadata that does not alter replayed item state. */
package/dist/types.js CHANGED
@@ -5,7 +5,7 @@
5
5
  */
6
6
  /** Supported values accepted by the builtin item type contract. */
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]="605cf12e-6106-563a-abc0-38d648d4aa43")}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]="8b39bc01-0325-5dc6-8492-585c98608076")}catch(e){}}();
9
9
  export const BUILTIN_ITEM_TYPE_VALUES = [
10
10
  "Epic",
11
11
  "Feature",
@@ -241,4 +241,4 @@ export const CONTEXT_SECTION_VALUES = [
241
241
  "tests",
242
242
  ];
243
243
  //# sourceMappingURL=types.js.map
244
- //# debugId=605cf12e-6106-563a-abc0-38d648d4aa43
244
+ //# debugId=8b39bc01-0325-5dc6-8492-585c98608076