@unbrained/pm-cli 2026.9.28 → 2026.9.30

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 (118) hide show
  1. package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +7 -6
  2. package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +1 -1
  3. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +26 -3
  4. package/.claude-plugin/marketplace.json +2 -2
  5. package/CHANGELOG.md +26 -0
  6. package/dist/cli/error-guidance.js +1 -1
  7. package/dist/cli/help-json-payload.js +2 -2
  8. package/dist/cli/main.js +2 -2
  9. package/dist/cli/runtime/invocation-options.d.ts +3 -1
  10. package/dist/cli/runtime/invocation-options.js +1 -1
  11. package/dist/cli-bundle/bundle-manifest.json +152 -152
  12. package/dist/cli-bundle/chunks/{chunk-UT7GRGHY.js → chunk-6XTJLOKW.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-VMJLM7P2.js → chunk-6YEET7XI.js} +22 -22
  14. package/dist/cli-bundle/chunks/{chunk-NEUIVBFO.js → chunk-A6NDNRCK.js} +3 -3
  15. package/dist/cli-bundle/chunks/{chunk-GLH2LNRH.js → chunk-BNAT4EYR.js} +9 -9
  16. package/dist/cli-bundle/chunks/{chunk-CPOWTIIS.js → chunk-BTCE36JS.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-35DME35A.js → chunk-BX4LEJX4.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-A2G5OG6W.js → chunk-EGAIIWI3.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-FYTXVVZG.js +2 -0
  20. package/dist/cli-bundle/chunks/{chunk-ZFHJP7YD.js → chunk-O23CQ5T4.js} +31 -29
  21. package/dist/cli-bundle/chunks/{chunk-NBDB3SRC.js → chunk-UIAH7UFK.js} +67 -67
  22. package/dist/cli-bundle/chunks/{chunk-OYCCWPBM.js → chunk-USTAFHIM.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-PR4UAMI5.js → chunk-XRN3JYNN.js} +85 -85
  24. package/dist/cli-bundle/chunks/{chunk-PLNNUAFZ.js → chunk-YM342ELM.js} +2 -2
  25. package/dist/cli-bundle/chunks/{register-list-query-N6RP6PSP.js → register-list-query-SYNBVMNG.js} +2 -2
  26. package/dist/cli-bundle/chunks/{register-mutation-CY7JGQE6.js → register-mutation-4GSUK23D.js} +2 -2
  27. package/dist/cli-bundle/chunks/{register-operations-53HAD3QP.js → register-operations-7FCJUC4Z.js} +2 -2
  28. package/dist/cli-bundle/chunks/{register-setup-NVX6374E.js → register-setup-YTWW2KL5.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/{chunk-BRLXKRI2.js → chunk-3CAZ7Z4R.js} +4 -4
  30. package/dist/cli-bundle/focused-chunks/{chunk-K7GSZ7YZ.js → chunk-4AORVUT4.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-AZA4AEOR.js → chunk-AKB3JN57.js} +33 -33
  32. package/dist/cli-bundle/focused-chunks/{chunk-OVVCXTIE.js → chunk-EFD4ATS7.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-IJXZQE3D.js → chunk-EVMH4SKN.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/{chunk-IWLMQLBO.js → chunk-IDB6E3ZV.js} +28 -28
  35. package/dist/cli-bundle/focused-chunks/{chunk-YZB7IPR6.js → chunk-IQBFYQF2.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-BGWF6CMP.js → chunk-KZULQIAG.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-ZMQTIS3L.js → chunk-MOUCTR72.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/{chunk-6IVQPNYN.js → chunk-OMBDUJWZ.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-DTLRXY77.js → chunk-RIJQQOEZ.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-A5O3VYWV.js → chunk-T4PZJQG4.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{chunk-V7OPZRL6.js → chunk-UPOMLSW7.js} +14 -14
  42. package/dist/cli-bundle/focused-chunks/{chunk-5KJXX2TZ.js → chunk-XB5Q2P7Z.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-ONDNR3VU.js → chunk-XUCXRZZZ.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-Y5Z3XNGY.js → chunk-ZJ3CLTV4.js} +2 -2
  45. package/dist/cli-bundle/main.js +22 -22
  46. package/dist/cli-bundle/sdk-authoring.js +1 -1
  47. package/dist/cli-bundle/sdk-contracts.js +1 -1
  48. package/dist/cli-bundle/sdk-core.js +22 -21
  49. package/dist/cli-bundle/sdk-governance.js +1 -1
  50. package/dist/cli-bundle/sdk-graph.js +1 -1
  51. package/dist/cli-bundle/sdk-merge.js +38 -38
  52. package/dist/cli-bundle/sdk-query.js +1 -1
  53. package/dist/cli-bundle/sdk-runtime.js +1 -1
  54. package/dist/cli-bundle/sdk-testing.js +1 -1
  55. package/dist/cli-bundle/sdk.js +2 -2
  56. package/dist/core/extensions/extension-types.d.ts +13 -0
  57. package/dist/core/extensions/extension-types.js +1 -1
  58. package/dist/core/history/replay.js +1 -1
  59. package/dist/core/history/workspace-history.d.ts +17 -0
  60. package/dist/core/history/workspace-history.js +1 -1
  61. package/dist/core/output/mutation-projection.js +1 -1
  62. package/dist/core/telemetry/runtime.js +2 -2
  63. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  64. package/dist/sdk/extension-command-context.d.ts +1 -7
  65. package/dist/sdk/extension-command-context.js +1 -1
  66. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  67. package/dist/sdk/index.d.ts +1 -0
  68. package/dist/sdk/index.js +1 -1
  69. package/dist/sdk/lifecycle/plan-mutation-receipt.d.ts +53 -0
  70. package/dist/sdk/lifecycle/plan-mutation-receipt.js +2 -0
  71. package/dist/sdk/lifecycle/plan.d.ts +3 -0
  72. package/dist/sdk/lifecycle/plan.js +1 -1
  73. package/dist/sdk/lifecycle/update.d.ts +2 -0
  74. package/dist/sdk/lifecycle/update.js +1 -1
  75. package/dist/sdk/linked-artifacts.js +1 -1
  76. package/dist/sdk/merge/install.js +1 -1
  77. package/dist/sdk/public-surface.json +1 -1
  78. package/dist/sdk/runtime/actions.js +1 -1
  79. package/dist/sdk/runtime-input.d.ts +2 -0
  80. package/dist/sdk/runtime-input.js +1 -1
  81. package/dist/sdk/runtime.js +1 -1
  82. package/dist/sdk/similarity-scoring.js +1 -1
  83. package/dist/sdk/structured-mutations.js +1 -1
  84. package/dist/sdk/telemetry.d.ts +2 -0
  85. package/dist/sdk/telemetry.js +3 -1
  86. package/dist/sdk/testing.js +1 -1
  87. package/docs/CLI_GRAMMAR.md +18 -1
  88. package/docs/ECOSYSTEM_PLANNING_REVIEW.md +270 -0
  89. package/docs/MERGE_SAFETY.md +11 -6
  90. package/docs/README.md +2 -0
  91. package/docs/RELEASE_RELIABILITY.md +26 -4
  92. package/docs/SDK_AUDITED_MUTATIONS.md +52 -0
  93. package/docs/SDK_EVIDENCE_TRACEABILITY.md +34 -0
  94. package/docs/agent-task-token-baseline.json +28 -2
  95. package/docs/agent-task-transcripts.json +137 -14
  96. package/docs/ecosystem-review-2026-09-28.json +3159 -0
  97. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  98. package/marketplace.json +2 -2
  99. package/package.json +1 -1
  100. package/packages/pm-beads/package.json +1 -1
  101. package/packages/pm-calendar/package.json +1 -1
  102. package/packages/pm-command-kit/package.json +1 -1
  103. package/packages/pm-digital-twin/package.json +1 -1
  104. package/packages/pm-governance-audit/package.json +1 -1
  105. package/packages/pm-guide-shell/package.json +1 -1
  106. package/packages/pm-kanban/package.json +1 -1
  107. package/packages/pm-lifecycle-hooks/package.json +1 -1
  108. package/packages/pm-linked-test-adapters/package.json +1 -1
  109. package/packages/pm-search-advanced/package.json +1 -1
  110. package/packages/pm-templates/package.json +1 -1
  111. package/packages/pm-todos/package.json +1 -1
  112. package/packages/pm-vcs/package.json +1 -1
  113. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  114. package/plugins/pm-claude/package.json +2 -2
  115. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  116. package/plugins/pm-codex/package.json +2 -2
  117. package/plugins/pm-codex/plugin.json +1 -1
  118. package/dist/cli-bundle/chunks/chunk-YERBAGQD.js +0 -2
@@ -4,12 +4,12 @@ Tracker: `pm-f05lsg`.
4
4
 
5
5
  Every catalog code is listed. An `uncovered` row is an explicit closure obligation, never an omission or implied approval.
6
6
 
7
- - Catalog error codes: 389
7
+ - Catalog error codes: 390
8
8
  - Executable error codes: 19
9
9
  - Executable-code ratchet floor: 18
10
10
  - Required executable canonical codes: `bulk_ids_input_empty`, `bulk_ids_input_missing_path`, `bulk_ids_input_unreadable`, `invalid_argument_value`, `manifest_unknown_key`, `missing_lifecycle_target`, `missing_required_argument`, `no_version_bounds_declared`, `projection_options_mutually_exclusive`, `tracker_not_initialized`, `tracker_root_missing`, `tracker_root_not_directory`, `tracker_root_unreadable`, `unknown_context_intent`, `unknown_field_projection`, `unknown_option`, `unknown_subcommand`
11
- - Uncovered error codes: 370
12
- - Coverage fraction: 0.048843
11
+ - Uncovered error codes: 371
12
+ - Coverage fraction: 0.048718
13
13
  - Closed-domain probes: 19
14
14
  - Grammar probes: 117
15
15
 
@@ -296,6 +296,7 @@ Every catalog code is listed. An `uncovered` row is an explicit closure obligati
296
296
  | `status_invalid` | `status_invalid` | uncovered | none | 0 |
297
297
  | `status_lifecycle_role_required` | `status_lifecycle_role_required` | uncovered | none | 0 |
298
298
  | `stdin_json_invalid` | `stdin_json_invalid` | uncovered | none | 0 |
299
+ | `stdin_json_persisted_annotation_changed` | `stdin_json_persisted_annotation_changed` | uncovered | none | 0 |
299
300
  | `stdin_json_unknown_key` | `stdin_json_unknown_key` | uncovered | none | 0 |
300
301
  | `structured_event_immutable` | `structured_event_immutable` | uncovered | none | 0 |
301
302
  | `structured_event_input_conflict` | `structured_event_input_conflict` | uncovered | none | 0 |
package/marketplace.json CHANGED
@@ -5,13 +5,13 @@
5
5
  "url": "https://github.com/unbraind/pm-cli"
6
6
  },
7
7
  "description": "Official marketplace for pm CLI — native git-based project management for Claude Code and AI coding agents.",
8
- "version": "2026.9.28",
8
+ "version": "2026.9.30",
9
9
  "plugins": [
10
10
  {
11
11
  "name": "pm-claude",
12
12
  "source": "./plugins/pm-claude",
13
13
  "description": "Native pm CLI integration for Claude Code — 32 MCP tools, 14 workflow skills with slash invocations, 4 subagents, hybrid TUI task tracking, session context injection, and coordination subagents for git-based project management without leaving Claude Code.",
14
- "version": "2026.9.28",
14
+ "version": "2026.9.30",
15
15
  "author": {
16
16
  "name": "unbrained",
17
17
  "url": "https://github.com/unbraind/pm-cli"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-cli",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "description": "Git-native project management CLI for humans and agents.",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.10.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-beads",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for importing Beads JSONL records.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-calendar",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for calendar and agenda views.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-command-kit",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm exemplar package for the commands capability: registerCommand, registerFlags, and registerParser.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-digital-twin",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Beyond-PM exemplar: a temporal production-facility digital twin built entirely on public pm SDK and extension primitives.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-governance-audit",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for governance audit and normalization workflows.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-guide-shell",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for guide and shell completion workflows.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-kanban",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm archetype package: a complete Kanban continuous-flow profile built on public SDK primitives.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-lifecycle-hooks",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package demonstrating safe lifecycle hook registration.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-linked-test-adapters",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for optional linked-test run management adapters and reporters.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-search-advanced",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for semantic, hybrid, and reindex search workflows.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-templates",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for reusable create templates.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-todos",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "First-party pm package for Todo markdown import and export.",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unbrained/pm-vcs-sdk-exemplar",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Beyond-PM exemplar: a VCS-style changeset workflow built entirely on public pm SDK and extension primitives.",
@@ -3,7 +3,7 @@
3
3
  "name": "pm-claude",
4
4
  "displayName": "pm CLI",
5
5
  "description": "Native pm CLI integration for Claude Code — 32 MCP tools, 14 skills with slash invocations, 4 subagents (coordinator, delivery-chain, triage, verification), hybrid TUI task tracking (pm as persistent store + Claude Code task panel as live view), session context injection, and full git-based project management without leaving Claude Code.",
6
- "version": "2026.9.28",
6
+ "version": "2026.9.30",
7
7
  "author": {
8
8
  "name": "unbrained",
9
9
  "url": "https://github.com/unbraind/pm-cli"
@@ -2,8 +2,8 @@
2
2
  "name": "pm-claude-runtime",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "2026.9.28",
5
+ "version": "2026.9.30",
6
6
  "dependencies": {
7
- "@unbrained/pm-cli": "2026.9.28"
7
+ "@unbrained/pm-cli": "2026.9.30"
8
8
  }
9
9
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pm-codex",
3
- "version": "2026.9.28",
3
+ "version": "2026.9.30",
4
4
  "description": "Native Codex integration for pm-cli with bundled MCP tools, skills, commands, and agent workflows.",
5
5
  "author": {
6
6
  "name": "unbrained",
@@ -2,8 +2,8 @@
2
2
  "name": "pm-codex-runtime",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "2026.9.28",
5
+ "version": "2026.9.30",
6
6
  "dependencies": {
7
- "@unbrained/pm-cli": "2026.9.28"
7
+ "@unbrained/pm-cli": "2026.9.30"
8
8
  }
9
9
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "pm-codex",
4
- "version": "2026.9.28",
4
+ "version": "2026.9.30",
5
5
  "description": "Repository-native project context workflows and a version-pinned pm MCP server for Codex.",
6
6
  "author": {
7
7
  "name": "unbrained",
@@ -1,2 +0,0 @@
1
- import{$a as B,Ub as x,Vb as F,Xb as b,_b as J,ac as W,bc as V}from"./chunk-PR4UAMI5.js";import{b as D}from"./chunk-VMJLM7P2.js";import{Rb as $,aa as O,fn as P,gh as N,la as c,ln as L,na as d,ni as C,pi as U,sj as G,tb as k,uj as j,vo as z,yo as K}from"./chunk-NBDB3SRC.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}catch{}})();import ce from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d6ceb51a-6085-5d65-aebe-31d09ea4d1d6")}catch{}})();var R=["op","id","reason","options"],Y=[...R,"ref"],q=["schema_version","mutations"],oe="[a-z][a-z0-9._-]{0,63}",H=new RegExp(`^${oe}$`,"u"),re=new RegExp(`(^|,)id=@(${oe})(?=,|$)`,"gu"),X=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,o)=>o.toUpperCase()),E=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],ne=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),de=new Set([...ne,"completed_at","id"]),_=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...O,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]),Z={create:z.map(e=>e.target),update:K.map(e=>e.target),close:P.map(e=>X(e.flag)).filter(e=>e!=="reason"),release:L.map(e=>X(e.flag))};function St(e){let t={},o=e.createCompensation;if(o!==void 0){if(o!=="close"&&o!=="delete")throw new d("createCompensation must be close or delete.",c.USAGE);t.createCompensation=o}for(let r of["lockTtlSeconds","lockWaitMs"]){let n=e[r];if(n===void 0)continue;let i=typeof n=="number"||typeof n=="string"&&n.trim().length>0?Number(n):Number.NaN;if(!Number.isSafeInteger(i)||i<=0)throw new d(`${r} must be a positive safe integer.`,c.USAGE);t[r]=i}return t}function p(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function g(e,t){let o=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let n of t){let i=k(e,n,o);i!==null&&(r===void 0||i<r.distance)&&(r={key:n,distance:i})}return r?.key}function y(e,t,o){let r=g(t,o);return new d(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${o.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,c.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function I(e,t){try{return JSON.parse(e)}catch(o){let r=o instanceof Error?o.message:String(o);throw new d(`${t} must be valid JSON: ${r}`,c.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function ue(e,t){if(!p(e))throw new d(`Mutation ${t+1} must be an object.`,c.USAGE);for(let o of Object.keys(e))if(!R.includes(o))throw y(`mutation ${t+1}`,o,R);return e}function pe(e,t,o){if(e!==void 0){if(!p(e))throw new d(`Mutation ${o+1} options must be an object.`,c.USAGE);for(let r of Object.keys(e))if(!Z[t].includes(r))throw y(`mutation ${o+1} ${t} options`,r,Z[t]);return e}}function le(e,t){let o=ue(e,t),{op:r,id:n,reason:i}=o;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new d(`Mutation ${t+1} op must be create, update, close, or release.`,c.USAGE);let s=pe(o.options,r,t);if(typeof n!="string"||n.trim().length===0)throw new d(`Mutation ${t+1} requires a non-empty id.`,c.USAGE);let a=n.trim();if(r==="close"){if(typeof i!="string"||i.trim().length===0)throw new d(`Mutation ${t+1} close requires a non-empty reason.`,c.USAGE);return{op:r,id:a,reason:i.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:a,...s===void 0?{}:{options:s}};if(!p(s))throw new d(`Mutation ${t+1} ${r} requires an options object.`,c.USAGE);return{op:r,id:a,options:s}}function ie(e){let t=I(e,"Mutation batch"),o=Array.isArray(t)?t:p(t)&&Array.isArray(t.mutations)?t.mutations:void 0;if(o===void 0||o.length===0)throw new d("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",c.USAGE);return o.map((r,n)=>{let i=le(r,n);return i.options!==void 0&&G(i.options),i})}function me(e,t,o){let r=ce.createHash("sha256").update(e).update("\0").update(t).digest("hex"),n=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${C(o)}${n}`}function Q(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let o=e.slice(1),r=t[o];if(r===void 0)throw new d(`Unknown mutation reference "${e}".`,c.USAGE);return r}function ee(e,t){if(typeof e!="string")return e;let o=e.replace(re,(r,n,i)=>{let s=t[i];if(s===void 0)throw new d(`Unknown mutation reference "@${i}".`,c.USAGE);return`${n}id=${s}`});if(/(^|,)id=@/u.test(o))throw new d(`Malformed mutation reference in dependency "${e}".`,c.USAGE);return o}function fe(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(re)].map(t=>t[1]).filter(t=>t!==void 0)}function ye(e){let t=new Map;for(let i of e){if(i.op!=="create"||typeof i.ref!="string")continue;let s=p(i.options)?i.options:{},a=Array.isArray(s.dep)?s.dep:s.dep===void 0?[]:[s.dep];t.set(i.ref,[s.parent,s.blockedBy,...a].flatMap(fe))}let o=new Set,r=new Set,n=i=>{if(o.has(i))throw new d(`Mutation reference cycle includes "@${i}".`,c.USAGE);if(!r.has(i)){o.add(i);for(let s of t.get(i))t.has(s)&&n(s);o.delete(i),r.add(i)}};for(let i of t.keys())n(i)}function he(e){let t=I(e,"Mutation document"),o=Array.isArray(t)?{schema_version:1,mutations:t}:t;if(!p(o))throw new d("Mutation document must be a JSON array or object.",c.USAGE);for(let r of Object.keys(o))if(!q.includes(r))throw y("mutation document",r,q);if(o.schema_version!==void 0&&o.schema_version!==1)throw new d("Mutation document schema_version must be 1.",c.USAGE);if(!Array.isArray(o.mutations)||o.mutations.length===0)throw new d("Mutation document requires a non-empty mutations array.",c.USAGE);return o.mutations.map((r,n)=>{if(!p(r))throw new d(`Mutation ${n+1} must be an object.`,c.USAGE);for(let i of Object.keys(r))if(!Y.includes(i))throw y(`mutation ${n+1}`,i,Y);return{...r}})}function we(e,t){let o=Object.create(null);for(let[r,n]of e.entries())if(n.ref!==void 0){if(n.op!=="create")throw new d(`Mutation ${r+1} ref is only valid for create operations.`,c.USAGE);if(typeof n.ref!="string"||!H.test(n.ref))throw new d(`Mutation ${r+1} ref must match ${H.source}.`,c.USAGE);if(o[n.ref]!==void 0)throw new d(`Duplicate mutation ref "${n.ref}".`,c.USAGE);o[n.ref]=typeof n.id=="string"&&n.id.trim().length>0?U(n.id,t.idPrefix):me(t.transactionId,n.ref,t.idPrefix)}return o}function bt(e,t){let o=he(e),r=we(o,t);ye(o);let n=o.map(a=>{let u={...a},f=typeof u.ref=="string"?u.ref:void 0;if(delete u.ref,f!==void 0?u.id=r[f]:u.id=Q(u.id,r),p(u.options)){let l={...u.options};for(let w of["parent","blockedBy"])l[w]!==void 0&&(l[w]=Q(l[w],r));Array.isArray(l.dep)?l.dep=l.dep.map(w=>ee(w,r)):l.dep!==void 0&&(l.dep=ee(l.dep,r)),u.options=l}return u}),i=ie(JSON.stringify(n)),s=i.filter(a=>a.op==="create").map(a=>a.id);if(new Set(s).size!==s.length)throw new d("Duplicate resolved create id in mutation document.",c.USAGE);return{schema_version:1,mutations:i,references:r}}function se(e,t){return t.filter(o=>e[o]!==void 0&&e[o]!==null).map(o=>{let r=String(e[o]);return`${o}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function _e(e,t,o){if(e!==void 0){if(!Array.isArray(e)||!e.every(p))throw new d(`${o} must be an array of objects.`,c.USAGE);return e.map(r=>se(r,t))}}function Ee(e,t){return e==="tags"&&Array.isArray(t)&&t.every(o=>typeof o=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function te(e,t,o=!1){let r=[["dependencies","dep",["id","kind","created_at","author","source_kind"]],["comments","comment",["text","created_at","author"]],["notes","note",["text","created_at","author"]],["learnings","learning",["text","created_at","author"]],["files","file",["path","scope","note"]],["tests","test",["command","scope","timeout_seconds"]],["docs","doc",["path","scope","note"]],["reminders","reminder",["at","text","created_at"]],["events","event",["start_at","end_at","title","location"]],["type_options","typeOption",["key","value"]]];for(let[n,i,s]of r){let a=t[n],u=_e(o&&["comments","notes","learnings"].includes(n)&&Array.isArray(a)?a.filter(f=>!p(f)||f.created_at===void 0):a,s,n);u!==void 0&&u.length>0&&(e[i]=u)}}function ge(e,t){for(let o of Object.keys(e)){if(t){if(!E.includes(o))throw y("item envelope",o,E);continue}if(!_.has(o)&&g(o,[..._])===void 0&&g(o,E)==="item")throw y("item envelope",o,E)}}function Ae(e){let t=Object.hasOwn(e,"item");ge(e,t);let o=t?e.item:e;if(!p(o))throw new d("Item document item must be an object.",c.USAGE);return{item:o,...t&&p(e.linked)?{linked:e.linked}:{}}}function Te(e,t,o,r){if(!(r==="update"?de:ne).has(t)){if(!_.has(t)){if(g(t,[..._])!==void 0)throw y("item document",t,[..._]);let s=Array.isArray(e.field)?e.field:[];s.push(se({key:t,value:typeof o=="string"?o:JSON.stringify(o)},["key","value"])),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(i,s)=>s.toUpperCase())]=Ee(t,o))}}function Rt(e,t,o={}){let r=I(e,"Item document");if(!p(r))throw new d("Item document must be a JSON object.",c.USAGE);let{item:n,linked:i}=Ae(r),s={};for(let[a,u]of Object.entries(n))Te(s,a,u,t);return te(s,n,t==="update"),i!==void 0&&te(s,i),{...s,...Object.fromEntries(Object.entries(o).filter(([,a])=>a!==void 0)),stdinJson:void 0}}function It(e){return ie(JSON.stringify(e))}import Se from"node:crypto";import be from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4b7656bd-36a9-5b97-971f-60f717e8e81f")}catch{}})();function A(e,t){let o={...e,...t};return e===void 0?o:j(e,o)}async function m(e,t){try{let r=(await B(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(o){if(o instanceof d&&o.exitCode===c.NOT_FOUND)return;throw o}}function v(e,t){let o=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=Se.createHash("sha256").update($(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${o}-${r}`}function Re(e,t){let o=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${o}`}function h(e,t,o){return`bulk-item-transaction ${e} ${t} ${o}`}async function T(e,t,o,r){let n=await N(be.join(e,"history",`${t}.jsonl`),t),i=h(o,r,"apply"),s=h(o,r,"compensate");for(let a=n.length-1;a>=0;a-=1){let u=n[a].message;if(u===i)return!0;if(u===s)return!1}return!1}async function M(e,t){let o=await m(e,t.id);if(o?.updatedAt===void 0)throw new d(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,c.NOT_FOUND);return{target_updated_at:o.updatedAt}}async function S(e,t,o,r){let n=r!==null&&typeof r=="object"&&!Array.isArray(r)?r.target_updated_at:void 0;typeof n=="string"&&await m(e.pmRoot,t)!==void 0&&await V(t,n,{force:!0,author:e.author,message:h(e.transactionId,o,"compensate")},{pmRoot:e.pmRoot})}function ae(e,t,o){return{id:o,async inspect(){let r=await m(e.pmRoot,t.id);return r===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"create"}}},async apply(){let n=(await x(A(t.options,{author:e.author,id:t.id}),{pmRoot:e.pmRoot})).item;return{id:String(n.id),op:"create"}},async compensate(){let r=await m(e.pmRoot,t.id);if(r!==void 0){if(e.createCompensation==="delete"){await W(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}r.closedAt===void 0&&await b(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function Ie(e,t,o){return{id:o,async inspect(){let r=await m(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await T(e.pmRoot,r.id,e.transactionId,o)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let n=(await F(t.id,A(t.options,{author:e.author,message:h(e.transactionId,o,"apply")}),{pmRoot:e.pmRoot})).item;return{id:String(n.id),op:"update"}},async compensate(r){await S(e,t.id,o,r)}}}function ve(e,t,o){return{id:o,async inspect(){let r=await m(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await T(e.pmRoot,r.id,e.transactionId,o)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let n=(await b(t.id,t.reason,A(t.options,{author:e.author,message:h(e.transactionId,o,"apply")}),{pmRoot:e.pmRoot})).item;return{id:String(n.id),op:"close"}},async compensate(r){await S(e,t.id,o,r)}}}function Me(e,t,o){return{id:o,async inspect(){let r=await m(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await T(e.pmRoot,r.id,e.transactionId,o)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let n=(await J(t.id,A(t.options,{author:e.author,message:h(e.transactionId,o,"apply")}),{pmRoot:e.pmRoot})).item;return{id:String(n.id),op:"release"}},async compensate(r){await S(e,t.id,o,r)}}}function Oe(e,t,o){let r=v(t,o);switch(t.op){case"create":return ae(e,t,r);case"update":return Ie(e,t,r);case"close":return ve(e,t,r);case"release":return Me(e,t,r)}}function ke(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`)}async function $e(e){let t=[...e.mutations];if(t.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");for(let[s,a]of t.entries())ke(a,s);let o=e.createCompensation??"close";if(!["close","delete"].includes(o))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let r={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:o},n=await D({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((s,a)=>Oe(r,s,a)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),i={};for(let[s,a]of t.entries()){let u=v(a,s),f=n.results[u];i[Re(a,s)]=f}return{transactionId:n.transactionId,status:"committed",recovered:n.recovered,results:i}}function Ne(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function jt(e){return $e({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Ne(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Pt={buildCreateStep:ae,bulkHistoryMarker:h,compensateByRestore:S,deriveStepId:v,isUpdateMarkerApplied:T,readItemSnapshot:m};export{St as a,ie as b,bt as c,Rt as d,It as e,$e as f,Ne as g,jt as h,Pt as i};
2
- //# sourceMappingURL=chunk-YERBAGQD.js.map