@unbrained/pm-cli 2026.11.21 → 2026.11.23

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 (943) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/dist/cli/after-command-context-usage.js +1 -1
  4. package/dist/cli/argv-utils.js +1 -1
  5. package/dist/cli/bootstrap-args.js +1 -1
  6. package/dist/cli/bundle-integrity.js +2 -2
  7. package/dist/cli/command-namespaces.js +1 -1
  8. package/dist/cli/commander-usage.js +11 -11
  9. package/dist/cli/commands/annotations/comments.js +1 -1
  10. package/dist/cli/commands/annotations/docs.js +1 -1
  11. package/dist/cli/commands/annotations/files.js +1 -1
  12. package/dist/cli/commands/annotations/learnings.js +1 -1
  13. package/dist/cli/commands/annotations/notes.js +1 -1
  14. package/dist/cli/commands/extension/describe.js +1 -1
  15. package/dist/cli/commands/extension/extension.js +1 -1
  16. package/dist/cli/commands/extension/scaffold.js +1 -1
  17. package/dist/cli/commands/extension/shared.js +1 -1
  18. package/dist/cli/commands/governance/gc.js +1 -1
  19. package/dist/cli/commands/governance/health.js +1 -1
  20. package/dist/cli/commands/governance/telemetry.js +1 -1
  21. package/dist/cli/commands/governance/validate.js +1 -1
  22. package/dist/cli/commands/history/activity.js +1 -1
  23. package/dist/cli/commands/history/history-compact.js +1 -1
  24. package/dist/cli/commands/history/history-redact.js +1 -1
  25. package/dist/cli/commands/history/history-repair.js +1 -1
  26. package/dist/cli/commands/history/history.js +1 -1
  27. package/dist/cli/commands/history/restore.js +1 -1
  28. package/dist/cli/commands/lifecycle/append.js +1 -1
  29. package/dist/cli/commands/lifecycle/claim.js +1 -1
  30. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  31. package/dist/cli/commands/lifecycle/close.js +1 -1
  32. package/dist/cli/commands/lifecycle/copy.js +1 -1
  33. package/dist/cli/commands/lifecycle/create.js +1 -1
  34. package/dist/cli/commands/lifecycle/delete.js +1 -1
  35. package/dist/cli/commands/lifecycle/focus.js +1 -1
  36. package/dist/cli/commands/lifecycle/plan.js +1 -1
  37. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  38. package/dist/cli/commands/lifecycle/update.js +1 -1
  39. package/dist/cli/commands/query/aggregate.js +1 -1
  40. package/dist/cli/commands/query/context.js +1 -1
  41. package/dist/cli/commands/query/deps.js +1 -1
  42. package/dist/cli/commands/query/duplicates.js +1 -1
  43. package/dist/cli/commands/query/eval.js +1 -1
  44. package/dist/cli/commands/query/get.js +1 -1
  45. package/dist/cli/commands/query/graph.js +1 -1
  46. package/dist/cli/commands/query/list.js +1 -1
  47. package/dist/cli/commands/query/next.js +1 -1
  48. package/dist/cli/commands/query/search.js +1 -1
  49. package/dist/cli/commands/query/stats.js +1 -1
  50. package/dist/cli/commands/test/test-all.js +1 -1
  51. package/dist/cli/commands/test/test-runs.js +1 -1
  52. package/dist/cli/commands/test/test.js +1 -1
  53. package/dist/cli/commands/workspace/config.js +1 -1
  54. package/dist/cli/commands/workspace/contracts.js +1 -1
  55. package/dist/cli/commands/workspace/init.js +1 -1
  56. package/dist/cli/commands/workspace/merge.js +1 -1
  57. package/dist/cli/commands/workspace/profile.js +1 -1
  58. package/dist/cli/commands/workspace/schema.js +1 -1
  59. package/dist/cli/commands/workspace/upgrade.js +1 -1
  60. package/dist/cli/context-intent-invocation.js +1 -1
  61. package/dist/cli/description-stdin.js +1 -1
  62. package/dist/cli/error-guidance.js +5 -5
  63. package/dist/cli/expected-revisions.js +1 -1
  64. package/dist/cli/extension-command-help.js +6 -6
  65. package/dist/cli/extension-recovery.js +1 -1
  66. package/dist/cli/help-content.js +5 -5
  67. package/dist/cli/help-json-payload.js +7 -7
  68. package/dist/cli/invocation-profile.js +2 -2
  69. package/dist/cli/main.js +5 -5
  70. package/dist/cli/migration-gates.js +1 -1
  71. package/dist/cli/option-values.js +1 -1
  72. package/dist/cli/preflight-warnings.js +3 -3
  73. package/dist/cli/public.js +1 -1
  74. package/dist/cli/register-annotations.js +1 -1
  75. package/dist/cli/register-assurance.js +1 -1
  76. package/dist/cli/register-files-lookup.js +1 -1
  77. package/dist/cli/register-history-activity.js +1 -1
  78. package/dist/cli/register-history-author.js +1 -1
  79. package/dist/cli/register-history-maintenance.js +2 -2
  80. package/dist/cli/register-list-query.js +10 -10
  81. package/dist/cli/register-mutation-options.js +0 -1
  82. package/dist/cli/register-mutation.js +6 -6
  83. package/dist/cli/register-operations.js +1 -1
  84. package/dist/cli/register-setup.js +1 -1
  85. package/dist/cli/register-structured-mutation.js +1 -1
  86. package/dist/cli/registration-helpers.js +1 -1
  87. package/dist/cli/runtime/activation.js +1 -1
  88. package/dist/cli/runtime/annotation-option-retry.js +1 -1
  89. package/dist/cli/runtime/close-fields-retry.js +1 -1
  90. package/dist/cli/runtime/field-route-retry.js +1 -1
  91. package/dist/cli/runtime/invocation-options.js +1 -1
  92. package/dist/cli/runtime/invocation-rewrites.js +1 -1
  93. package/dist/cli/runtime/projection-retry.js +1 -1
  94. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  95. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  96. package/dist/cli/runtime/selection.js +1 -1
  97. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  98. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  99. package/dist/cli/schema/registration.js +15 -15
  100. package/dist/cli/schema-registration-helpers.js +1 -1
  101. package/dist/cli/search-refresh.js +1 -1
  102. package/dist/cli/stats-analytics-json.js +1 -1
  103. package/dist/cli/telemetry-flush.js +1 -1
  104. package/dist/cli-bundle/bundle-manifest.json +1 -1
  105. package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
  106. package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
  107. package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
  108. package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
  109. package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
  110. package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
  111. package/dist/cli-bundle/chunks/chunk-AEOHUSUI.js +2289 -0
  112. package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
  113. package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
  114. package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
  115. package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
  116. package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
  117. package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
  118. package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
  119. package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
  120. package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
  121. package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
  122. package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
  123. package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
  124. package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
  125. package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
  126. package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
  127. package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
  128. package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
  129. package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
  130. package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
  131. package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
  132. package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
  133. package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
  134. package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
  135. package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
  136. package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
  137. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
  138. package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-FMD4KWBB.js} +2 -2
  139. package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
  140. package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
  141. package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
  142. package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-L4IBU64P.js} +11 -11
  143. package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
  144. package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
  145. package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
  146. package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
  147. package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
  148. package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
  149. package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
  150. package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
  151. package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
  152. package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
  153. package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
  154. package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
  155. package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
  156. package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
  157. package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
  158. package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
  159. package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
  160. package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
  161. package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
  162. package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
  163. package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
  164. package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
  165. package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
  166. package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
  167. package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
  168. package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
  169. package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
  170. package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
  171. package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
  172. package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
  173. package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
  174. package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
  175. package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
  176. package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
  177. package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
  178. package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
  179. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
  180. package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-YDACCDVY.js} +2 -2
  181. package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
  182. package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
  183. package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
  184. package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
  185. package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
  186. package/dist/cli-bundle/main.js +27 -27
  187. package/dist/cli-bundle/sdk-authoring.js +1 -1
  188. package/dist/cli-bundle/sdk-contracts.js +5 -5
  189. package/dist/cli-bundle/sdk-core.js +1 -1
  190. package/dist/cli-bundle/sdk-governance.js +1 -1
  191. package/dist/cli-bundle/sdk-graph.js +1 -1
  192. package/dist/cli-bundle/sdk-merge.js +72 -60
  193. package/dist/cli-bundle/sdk-query.js +1 -1
  194. package/dist/cli-bundle/sdk-runtime.js +1 -1
  195. package/dist/cli-bundle/sdk-testing.js +1 -1
  196. package/dist/cli-bundle/sdk.js +13 -13
  197. package/dist/cli.js +1 -1
  198. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  199. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  200. package/dist/core/checkpoint/mutation-context.js +1 -1
  201. package/dist/core/config/nested-settings.js +1 -1
  202. package/dist/core/config/positional-value.js +1 -1
  203. package/dist/core/diagnostics/remediation.js +1 -1
  204. package/dist/core/extensions/activation-summary-markdown.js +2 -2
  205. package/dist/core/extensions/activation-summary.js +1 -1
  206. package/dist/core/extensions/activation-transaction.js +1 -1
  207. package/dist/core/extensions/capability-usage.js +1 -1
  208. package/dist/core/extensions/command-hook-context.js +1 -1
  209. package/dist/core/extensions/command-metadata-contract.js +1 -1
  210. package/dist/core/extensions/command-visibility-tier.js +1 -1
  211. package/dist/core/extensions/contribution-inventory.js +1 -1
  212. package/dist/core/extensions/exporter-output-contract.js +1 -1
  213. package/dist/core/extensions/extension-candidate.js +1 -1
  214. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  215. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  216. package/dist/core/extensions/extension-policy.js +1 -1
  217. package/dist/core/extensions/extension-registries.js +1 -1
  218. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  219. package/dist/core/extensions/extension-types.js +1 -1
  220. package/dist/core/extensions/flag-definition-validation.js +1 -1
  221. package/dist/core/extensions/flag-value-types.js +1 -1
  222. package/dist/core/extensions/index.js +1 -1
  223. package/dist/core/extensions/item-field-types.js +1 -1
  224. package/dist/core/extensions/item-fields.js +1 -1
  225. package/dist/core/extensions/loader.js +1 -1
  226. package/dist/core/extensions/manifest-parser.js +1 -1
  227. package/dist/core/extensions/manifest-schema.js +1 -1
  228. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  229. package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
  230. package/dist/core/extensions/mutation-actor.js +1 -1
  231. package/dist/core/extensions/preflight-ownership.js +1 -1
  232. package/dist/core/extensions/read-output-contract.js +1 -1
  233. package/dist/core/extensions/registration-contracts.js +1 -1
  234. package/dist/core/extensions/registration-validation.js +1 -1
  235. package/dist/core/extensions/registration-values.js +1 -1
  236. package/dist/core/extensions/reserved-host-flags.js +1 -1
  237. package/dist/core/extensions/runtime-registrations.js +1 -1
  238. package/dist/core/extensions/service-ownership.js +1 -1
  239. package/dist/core/extensions/version-compat.js +1 -1
  240. package/dist/core/extensions/version-diagnostics.js +1 -1
  241. package/dist/core/fs/atomic-create.js +1 -1
  242. package/dist/core/fs/file-glob.js +1 -1
  243. package/dist/core/fs/fs-utils.js +2 -2
  244. package/dist/core/fs/host-environment-errors.js +1 -1
  245. package/dist/core/fs/index.js +1 -1
  246. package/dist/core/fs/path-utils.js +1 -1
  247. package/dist/core/governance/content-fields.js +1 -1
  248. package/dist/core/governance/issue-codes.js +1 -1
  249. package/dist/core/governance/metadata-coverage.js +1 -1
  250. package/dist/core/history/bridge.js +2 -0
  251. package/dist/core/history/digest.js +1 -1
  252. package/dist/core/history/drift-cache.js +3 -3
  253. package/dist/core/history/drift-scan.js +1 -1
  254. package/dist/core/history/event-classification.js +1 -1
  255. package/dist/core/history/event-index.js +11 -11
  256. package/dist/core/history/history-compact-bulk.js +1 -1
  257. package/dist/core/history/history-diff.js +1 -1
  258. package/dist/core/history/history-rewrite.js +1 -1
  259. package/dist/core/history/history-storage-stats.js +1 -1
  260. package/dist/core/history/history-stream-policy.js +1 -1
  261. package/dist/core/history/history.d.ts +12 -0
  262. package/dist/core/history/history.js +2 -2
  263. package/dist/core/history/identity.js +1 -1
  264. package/dist/core/history/index.js +1 -1
  265. package/dist/core/history/operation-contract.js +1 -1
  266. package/dist/core/history/projection.js +1 -1
  267. package/dist/core/history/read.d.ts +9 -0
  268. package/dist/core/history/read.js +1 -1
  269. package/dist/core/history/replay.d.ts +46 -5
  270. package/dist/core/history/replay.js +2 -2
  271. package/dist/core/history/stream-summary.js +2 -2
  272. package/dist/core/history/tombstone.js +1 -1
  273. package/dist/core/history/version-address.js +1 -1
  274. package/dist/core/history/workspace-history.js +2 -2
  275. package/dist/core/io/body-file.js +1 -1
  276. package/dist/core/io/bulk-ids-input.js +2 -2
  277. package/dist/core/item/actionability.js +1 -1
  278. package/dist/core/item/deferred-fields.js +1 -1
  279. package/dist/core/item/dependency-reference.js +1 -1
  280. package/dist/core/item/id.js +1 -1
  281. package/dist/core/item/index.js +1 -1
  282. package/dist/core/item/item-format-version.js +1 -1
  283. package/dist/core/item/item-format.js +7 -7
  284. package/dist/core/item/item-record.js +1 -1
  285. package/dist/core/item/item-type-definition.js +1 -1
  286. package/dist/core/item/literal-mutation-input.js +1 -1
  287. package/dist/core/item/parent-reference-policy.js +1 -1
  288. package/dist/core/item/parse.js +8 -8
  289. package/dist/core/item/plan-lifecycle.js +1 -1
  290. package/dist/core/item/priority.js +1 -1
  291. package/dist/core/item/sprint-release-format.js +1 -1
  292. package/dist/core/item/status-filter.js +1 -1
  293. package/dist/core/item/status.js +1 -1
  294. package/dist/core/item/toon-decode.js +1 -1
  295. package/dist/core/item/type-registry.js +1 -1
  296. package/dist/core/item/type-synonyms.js +1 -1
  297. package/dist/core/lock/index.js +1 -1
  298. package/dist/core/lock/lock-confinement.js +1 -1
  299. package/dist/core/lock/lock-gc.js +1 -1
  300. package/dist/core/lock/lock-owner.js +1 -1
  301. package/dist/core/lock/lock.js +4 -4
  302. package/dist/core/output/linked-test-projection.js +5 -5
  303. package/dist/core/output/mutation-projection.js +1 -1
  304. package/dist/core/output/output-control.js +1 -1
  305. package/dist/core/output/output.js +19 -19
  306. package/dist/core/output/query-summary.js +1 -1
  307. package/dist/core/output/tabular.js +3 -3
  308. package/dist/core/packages/manifest.js +1 -1
  309. package/dist/core/packages/root.js +1 -1
  310. package/dist/core/policy/workflow-policy-schema.js +1 -1
  311. package/dist/core/policy/workflow-policy-store.js +1 -1
  312. package/dist/core/policy/workflow-policy.js +1 -1
  313. package/dist/core/profile/profile-describe.js +1 -1
  314. package/dist/core/profile/profile-lint.d.ts +1 -1
  315. package/dist/core/profile/profile-lint.js +1 -1
  316. package/dist/core/profile/profile-plan.js +1 -1
  317. package/dist/core/profile/profile-presets.js +4 -4
  318. package/dist/core/reproducibility/context.js +1 -1
  319. package/dist/core/schema/fields-file.js +2 -2
  320. package/dist/core/schema/item-types-file.js +2 -2
  321. package/dist/core/schema/runtime-field-filters.js +1 -1
  322. package/dist/core/schema/runtime-field-values.js +1 -1
  323. package/dist/core/schema/runtime-schema.js +2 -2
  324. package/dist/core/schema/status-defs-file.js +2 -2
  325. package/dist/core/schema/status-token.js +1 -1
  326. package/dist/core/schema/type-inference.js +1 -1
  327. package/dist/core/schema/type-presets.js +1 -1
  328. package/dist/core/schema/type-workflows.js +1 -1
  329. package/dist/core/search/background-refresh.js +2 -2
  330. package/dist/core/search/bm25.js +1 -1
  331. package/dist/core/search/cache.js +2 -2
  332. package/dist/core/search/corpus.js +1 -1
  333. package/dist/core/search/embedding-batches.js +1 -1
  334. package/dist/core/search/eval-thresholds.js +1 -1
  335. package/dist/core/search/eval.js +1 -1
  336. package/dist/core/search/http-client.js +1 -1
  337. package/dist/core/search/providers.js +1 -1
  338. package/dist/core/search/relevance.js +1 -1
  339. package/dist/core/search/semantic-defaults.js +1 -1
  340. package/dist/core/search/staleness.js +1 -1
  341. package/dist/core/search/vector-stores.js +2 -2
  342. package/dist/core/search/vectorization-metadata.js +1 -1
  343. package/dist/core/sentry/helpers.js +1 -1
  344. package/dist/core/sentry/instrument.js +1 -1
  345. package/dist/core/sentry/sensitive-assignments.js +1 -1
  346. package/dist/core/session/session-state.js +1 -1
  347. package/dist/core/shared/agent-session-context.js +1 -1
  348. package/dist/core/shared/author.js +5 -5
  349. package/dist/core/shared/command-line.js +1 -1
  350. package/dist/core/shared/command-types.js +0 -1
  351. package/dist/core/shared/conflict-markers.js +1 -1
  352. package/dist/core/shared/constants.js +1 -1
  353. package/dist/core/shared/error-details.js +1 -1
  354. package/dist/core/shared/errors.js +1 -1
  355. package/dist/core/shared/html-entity-decode.js +1 -1
  356. package/dist/core/shared/index.js +1 -1
  357. package/dist/core/shared/item-metadata-contract.js +1 -1
  358. package/dist/core/shared/lazy-module.js +1 -1
  359. package/dist/core/shared/levenshtein.js +1 -1
  360. package/dist/core/shared/memo.js +1 -1
  361. package/dist/core/shared/numeric-parsers.js +1 -1
  362. package/dist/core/shared/option-alias-visibility.js +1 -1
  363. package/dist/core/shared/output-unicode.js +1 -1
  364. package/dist/core/shared/primitives.js +1 -1
  365. package/dist/core/shared/process-tree.js +2 -2
  366. package/dist/core/shared/secret-rules.js +5 -5
  367. package/dist/core/shared/serial-queue.js +1 -1
  368. package/dist/core/shared/serialization.js +1 -1
  369. package/dist/core/shared/split-comma-list.js +1 -1
  370. package/dist/core/shared/text-normalization.js +1 -1
  371. package/dist/core/shared/time.js +2 -2
  372. package/dist/core/shared/url-credentials.js +1 -1
  373. package/dist/core/store/index.js +1 -1
  374. package/dist/core/store/item-format-migration.js +1 -1
  375. package/dist/core/store/item-metadata-cache.js +1 -1
  376. package/dist/core/store/item-metadata-query-index.js +11 -11
  377. package/dist/core/store/item-metadata-read-work.js +1 -1
  378. package/dist/core/store/item-mutation-precondition.js +1 -1
  379. package/dist/core/store/item-store.js +1 -1
  380. package/dist/core/store/paths.js +1 -1
  381. package/dist/core/store/settings-concurrency.js +1 -1
  382. package/dist/core/store/settings-read-cache.js +1 -1
  383. package/dist/core/store/settings-sections.js +2 -2
  384. package/dist/core/store/settings-validator.js +1 -1
  385. package/dist/core/store/settings.d.ts +3 -1
  386. package/dist/core/store/settings.js +6 -6
  387. package/dist/core/store/sqlite-runtime.js +1 -1
  388. package/dist/core/store/tracker-preflight.js +1 -1
  389. package/dist/core/store/transaction-coordinator-scope.js +1 -1
  390. package/dist/core/telemetry/consent.js +3 -3
  391. package/dist/core/telemetry/observability.js +1 -1
  392. package/dist/core/telemetry/policy.js +1 -1
  393. package/dist/core/telemetry/read-sampling.js +2 -2
  394. package/dist/core/telemetry/runtime.js +9 -9
  395. package/dist/core/test/background-runs.js +4 -4
  396. package/dist/core/test/item-test-run-tracking.js +1 -1
  397. package/dist/core/test/run-selectors.js +1 -1
  398. package/dist/core/validate/estimate-defaults.js +1 -1
  399. package/dist/core/validate/fix-planning.js +1 -1
  400. package/dist/core/validate/linked-artifact-reference.js +1 -1
  401. package/dist/core/validate/missing-by-type.js +1 -1
  402. package/dist/core/validate/missing-link-owners.js +1 -1
  403. package/dist/core/validate/stale-file-classification.js +1 -1
  404. package/dist/mcp/http-server.js +5 -5
  405. package/dist/mcp/legacy-adapter.js +1 -1
  406. package/dist/mcp/runtime-capabilities.js +1 -1
  407. package/dist/mcp/server.js +4 -4
  408. package/dist/mcp/tool-definitions.js +1 -1
  409. package/dist/sdk/actionability.js +1 -1
  410. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  411. package/dist/sdk/agent/command-recovery.js +1 -1
  412. package/dist/sdk/agent/command-suggestions.js +1 -1
  413. package/dist/sdk/agent/create-option-policy.js +1 -1
  414. package/dist/sdk/agent/identity-config.js +1 -1
  415. package/dist/sdk/agent/item-addressing.js +1 -1
  416. package/dist/sdk/agent/linked-resource-recovery.js +1 -1
  417. package/dist/sdk/agent/refusal-closure-census.js +2 -2
  418. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  419. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  420. package/dist/sdk/agent-capability-contracts.js +3 -3
  421. package/dist/sdk/agent-session-context.js +1 -1
  422. package/dist/sdk/annotations.js +1 -1
  423. package/dist/sdk/author-attribution.js +1 -1
  424. package/dist/sdk/cli-bootstrap.js +1 -1
  425. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
  426. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  427. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  428. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  429. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  430. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  431. package/dist/sdk/cli-contracts/completeness.js +1 -1
  432. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  433. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  434. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
  435. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  436. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  437. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  438. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  439. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  440. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  441. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  442. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  443. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
  444. package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
  445. package/dist/sdk/cli-contracts.js +1 -1
  446. package/dist/sdk/cli-program.js +1 -1
  447. package/dist/sdk/command-line.js +1 -1
  448. package/dist/sdk/comments.js +1 -1
  449. package/dist/sdk/compile-cache.js +1 -1
  450. package/dist/sdk/completion/bash.js +2 -2
  451. package/dist/sdk/completion/fish.js +74 -73
  452. package/dist/sdk/completion/shared.js +1 -1
  453. package/dist/sdk/completion/zsh.js +77 -76
  454. package/dist/sdk/completion.js +1 -1
  455. package/dist/sdk/config.js +1 -1
  456. package/dist/sdk/context/recency.js +1 -1
  457. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  458. package/dist/sdk/context/usage-egress.js +1 -1
  459. package/dist/sdk/context/usage-ledger.js +6 -6
  460. package/dist/sdk/context-intent-contracts.js +1 -1
  461. package/dist/sdk/context-intent-runtime.js +1 -1
  462. package/dist/sdk/context-packing.js +1 -1
  463. package/dist/sdk/context-relevance.js +1 -1
  464. package/dist/sdk/context-signal-store.js +2 -2
  465. package/dist/sdk/context-usage.js +1 -1
  466. package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
  467. package/dist/sdk/dependencies.js +1 -1
  468. package/dist/sdk/dependency-flag-validation.js +1 -1
  469. package/dist/sdk/dependency-provenance.js +1 -1
  470. package/dist/sdk/docs.js +1 -1
  471. package/dist/sdk/duplicates.js +1 -1
  472. package/dist/sdk/environment/host-environment-errors.js +1 -1
  473. package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
  474. package/dist/sdk/environment/source-context.js +1 -1
  475. package/dist/sdk/environment/tracker-preflight.js +1 -1
  476. package/dist/sdk/error-code-catalog.js +1 -1
  477. package/dist/sdk/error-runtime.js +1 -1
  478. package/dist/sdk/errors.js +1 -1
  479. package/dist/sdk/eval.js +1 -1
  480. package/dist/sdk/extension/author-manifest.js +1 -1
  481. package/dist/sdk/extension/bundled-catalog.js +1 -1
  482. package/dist/sdk/extension/command-options.js +1 -1
  483. package/dist/sdk/extension/concurrency.js +1 -1
  484. package/dist/sdk/extension/copy-scope.js +1 -1
  485. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  486. package/dist/sdk/extension/describe.js +3 -3
  487. package/dist/sdk/extension/doctor.js +1 -1
  488. package/dist/sdk/extension/install-plan.js +1 -1
  489. package/dist/sdk/extension/install-receipts.js +1 -1
  490. package/dist/sdk/extension/install-runtime.js +3 -3
  491. package/dist/sdk/extension/install-snapshot.js +1 -1
  492. package/dist/sdk/extension/install-sources.js +5 -5
  493. package/dist/sdk/extension/managed-state.js +2 -2
  494. package/dist/sdk/extension/managed-update-status.js +1 -1
  495. package/dist/sdk/extension/migrations.js +2 -2
  496. package/dist/sdk/extension/native-command-options.js +1 -1
  497. package/dist/sdk/extension/output-ownership.js +1 -1
  498. package/dist/sdk/extension/runtime-summary.js +1 -1
  499. package/dist/sdk/extension/scaffold.js +11 -11
  500. package/dist/sdk/extension/shared.js +1 -1
  501. package/dist/sdk/extension/source-resolution.js +1 -1
  502. package/dist/sdk/extension/static-inventory.js +1 -1
  503. package/dist/sdk/extension/update-check.js +1 -1
  504. package/dist/sdk/extension-command-context.js +2 -2
  505. package/dist/sdk/extension-contracts.js +1 -1
  506. package/dist/sdk/extension.js +1 -1
  507. package/dist/sdk/files.js +1 -1
  508. package/dist/sdk/flag-invocation-contracts.js +1 -1
  509. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  510. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  511. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  512. package/dist/sdk/generated-error-code-catalog.js +1 -1
  513. package/dist/sdk/governance/assurance-action-contracts.js +0 -1
  514. package/dist/sdk/governance/assurance-action.js +1 -1
  515. package/dist/sdk/governance/assurance-limits.js +1 -1
  516. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  517. package/dist/sdk/governance/assurance-presets.js +1 -1
  518. package/dist/sdk/governance/assurance-runtime.js +1 -1
  519. package/dist/sdk/governance/assurance.js +4 -4
  520. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  521. package/dist/sdk/governance/closure-timestamps.js +1 -1
  522. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  523. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  524. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  525. package/dist/sdk/governance/defect-recurrence.js +2 -2
  526. package/dist/sdk/governance/extension-host-version.js +1 -1
  527. package/dist/sdk/governance/gc.js +1 -1
  528. package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
  529. package/dist/sdk/governance/health/projection.js +1 -1
  530. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  531. package/dist/sdk/governance/health.js +2 -2
  532. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  533. package/dist/sdk/governance/in-progress-work-health.js +1 -1
  534. package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
  535. package/dist/sdk/governance/linked-file-report.js +1 -1
  536. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  537. package/dist/sdk/governance/provenance-health.js +4 -4
  538. package/dist/sdk/governance/reindex.js +5 -5
  539. package/dist/sdk/governance/stale-work.js +1 -1
  540. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  541. package/dist/sdk/governance/storage-integrity.js +1 -1
  542. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  543. package/dist/sdk/governance/upgrade.js +2 -2
  544. package/dist/sdk/governance/validate-deferred-fields.js +1 -1
  545. package/dist/sdk/governance/validate-history-drift.js +1 -1
  546. package/dist/sdk/governance/validate-item-reader.js +1 -1
  547. package/dist/sdk/governance/validate-normalization.js +1 -1
  548. package/dist/sdk/governance/validate.js +1 -1
  549. package/dist/sdk/governance/workflow-completeness.js +1 -1
  550. package/dist/sdk/governance/workflow-policy.js +3 -3
  551. package/dist/sdk/governance/workspace-position.js +2 -2
  552. package/dist/sdk/graph/analytics.js +1 -1
  553. package/dist/sdk/graph/assembly.js +1 -1
  554. package/dist/sdk/graph/cache.js +1 -1
  555. package/dist/sdk/graph/cardinality-integrity.js +1 -1
  556. package/dist/sdk/graph/centrality.js +1 -1
  557. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  558. package/dist/sdk/graph/durable-cache.js +1 -1
  559. package/dist/sdk/graph/governance-contracts.js +1 -1
  560. package/dist/sdk/graph/governance.js +1 -1
  561. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  562. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  563. package/dist/sdk/graph/mutation-advisory.js +1 -1
  564. package/dist/sdk/graph/query-contracts.js +1 -1
  565. package/dist/sdk/graph/remediation.js +1 -1
  566. package/dist/sdk/graph/run.js +1 -1
  567. package/dist/sdk/graph/scheduling.js +1 -1
  568. package/dist/sdk/graph/traversal.js +1 -1
  569. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  570. package/dist/sdk/guide-topics.js +1 -1
  571. package/dist/sdk/guide.js +7 -7
  572. package/dist/sdk/history/append-only-repair.d.ts +30 -0
  573. package/dist/sdk/history/append-only-repair.js +6 -0
  574. package/dist/sdk/history/attestation-command.js +2 -2
  575. package/dist/sdk/history/attestation-contract.js +1 -1
  576. package/dist/sdk/history/attestation-scan.js +1 -1
  577. package/dist/sdk/history/attestation.js +1 -1
  578. package/dist/sdk/history/maintenance.d.ts +8 -2
  579. package/dist/sdk/history/maintenance.js +1 -1
  580. package/dist/sdk/history/reanchor-refusal.js +2 -0
  581. package/dist/sdk/history/reseed.d.ts +15 -0
  582. package/dist/sdk/history/reseed.js +2 -0
  583. package/dist/sdk/history/salvage.d.ts +19 -8
  584. package/dist/sdk/history/salvage.js +5 -3
  585. package/dist/sdk/history/subject.js +1 -1
  586. package/dist/sdk/history-analytics.js +1 -1
  587. package/dist/sdk/history-compact.js +1 -1
  588. package/dist/sdk/history-mcp.js +1 -1
  589. package/dist/sdk/history-provenance.js +1 -1
  590. package/dist/sdk/history-read.js +1 -1
  591. package/dist/sdk/history-redact.js +1 -1
  592. package/dist/sdk/history-repair.d.ts +8 -2
  593. package/dist/sdk/history-repair.js +1 -1
  594. package/dist/sdk/improvement-ledger-validation.js +1 -1
  595. package/dist/sdk/improvement-ledger.js +2 -2
  596. package/dist/sdk/index.d.ts +1 -1
  597. package/dist/sdk/init-agent-guidance.js +10 -10
  598. package/dist/sdk/init.js +14 -14
  599. package/dist/sdk/invocation-author.js +1 -1
  600. package/dist/sdk/item-children.js +1 -1
  601. package/dist/sdk/item-metadata-index.js +1 -1
  602. package/dist/sdk/item-schedule.js +1 -1
  603. package/dist/sdk/item-transaction.d.ts +33 -1
  604. package/dist/sdk/item-transaction.js +1 -1
  605. package/dist/sdk/learnings.js +1 -1
  606. package/dist/sdk/lifecycle/append.js +3 -3
  607. package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
  608. package/dist/sdk/lifecycle/claim.js +1 -1
  609. package/dist/sdk/lifecycle/cli-input.js +1 -1
  610. package/dist/sdk/lifecycle/close-many.js +1 -1
  611. package/dist/sdk/lifecycle/close.js +1 -1
  612. package/dist/sdk/lifecycle/copy.js +1 -1
  613. package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
  614. package/dist/sdk/lifecycle/core-item-fields.js +1 -1
  615. package/dist/sdk/lifecycle/create-deferrals.js +1 -1
  616. package/dist/sdk/lifecycle/create.js +1 -1
  617. package/dist/sdk/lifecycle/delete.js +1 -1
  618. package/dist/sdk/lifecycle/dependency-removal.js +1 -1
  619. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  620. package/dist/sdk/lifecycle/focus.js +1 -1
  621. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  622. package/dist/sdk/lifecycle/item-revision.js +1 -1
  623. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  624. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  625. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  626. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  627. package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
  628. package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
  629. package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
  630. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  631. package/dist/sdk/lifecycle/plan.js +1 -1
  632. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  633. package/dist/sdk/lifecycle/release-handoff.js +1 -1
  634. package/dist/sdk/lifecycle/reopen.js +1 -1
  635. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
  636. package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
  637. package/dist/sdk/lifecycle/restore.js +1 -1
  638. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  639. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  640. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  641. package/dist/sdk/lifecycle/task-composition.js +1 -1
  642. package/dist/sdk/lifecycle/update-many.js +1 -1
  643. package/dist/sdk/lifecycle/update.js +2 -2
  644. package/dist/sdk/lifecycle/workflow-transition.js +1 -1
  645. package/dist/sdk/lifecycle-completion.js +1 -1
  646. package/dist/sdk/lifecycle-policy.js +1 -1
  647. package/dist/sdk/linked-artifacts.js +2 -2
  648. package/dist/sdk/mcp/apps.js +5 -5
  649. package/dist/sdk/mcp/authorization.js +1 -1
  650. package/dist/sdk/mcp/discovery.js +1 -1
  651. package/dist/sdk/mcp/executable.js +4 -4
  652. package/dist/sdk/mcp/interactions.js +1 -1
  653. package/dist/sdk/mcp/protocol.js +1 -1
  654. package/dist/sdk/mcp/skills.js +3 -3
  655. package/dist/sdk/mcp/subscriptions.js +1 -1
  656. package/dist/sdk/mcp/tasks.js +2 -2
  657. package/dist/sdk/mcp/transport.js +1 -1
  658. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  659. package/dist/sdk/merge/driver.js +7 -7
  660. package/dist/sdk/merge/history-scalar-rebase.js +1 -1
  661. package/dist/sdk/merge/ignored-artifacts.js +1 -1
  662. package/dist/sdk/merge/index.js +1 -1
  663. package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
  664. package/dist/sdk/merge/install.js +6 -6
  665. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  666. package/dist/sdk/merge/receipt-operation.js +1 -1
  667. package/dist/sdk/merge/receipt-schema.js +1 -1
  668. package/dist/sdk/merge/receipts.js +4 -4
  669. package/dist/sdk/merge/reconcile.js +1 -1
  670. package/dist/sdk/merge/settlement-hook.js +4 -4
  671. package/dist/sdk/merge/stage.js +1 -1
  672. package/dist/sdk/merge/three-way.d.ts +22 -3
  673. package/dist/sdk/merge/three-way.js +9 -3
  674. package/dist/sdk/merge/worktree-config.js +2 -2
  675. package/dist/sdk/merge.js +1 -1
  676. package/dist/sdk/mutation-events.js +1 -1
  677. package/dist/sdk/mutation-guard.js +1 -1
  678. package/dist/sdk/notes.js +1 -1
  679. package/dist/sdk/output/fit-envelope.js +1 -1
  680. package/dist/sdk/output/list-envelope.js +1 -1
  681. package/dist/sdk/output/table-rows.js +1 -1
  682. package/dist/sdk/output-contracts.js +1 -1
  683. package/dist/sdk/output-projection.js +1 -1
  684. package/dist/sdk/output-token-accounting.js +1 -1
  685. package/dist/sdk/output.js +2 -2
  686. package/dist/sdk/ownership-source.js +1 -1
  687. package/dist/sdk/package-import-adapters.js +1 -1
  688. package/dist/sdk/package-migrations.js +1 -1
  689. package/dist/sdk/package-runtime-options.js +1 -1
  690. package/dist/sdk/pagination.js +1 -1
  691. package/dist/sdk/profile.js +5 -5
  692. package/dist/sdk/provenance.js +1 -1
  693. package/dist/sdk/public-surface.json +1 -1
  694. package/dist/sdk/query/activity.js +1 -1
  695. package/dist/sdk/query/aggregate.js +1 -1
  696. package/dist/sdk/query/calendar.js +4 -4
  697. package/dist/sdk/query/complete-list.js +1 -1
  698. package/dist/sdk/query/context.js +2 -2
  699. package/dist/sdk/query/declared-blockers.js +1 -1
  700. package/dist/sdk/query/duplicate-candidates.js +1 -1
  701. package/dist/sdk/query/get-facet-roots.js +1 -1
  702. package/dist/sdk/query/get.js +1 -1
  703. package/dist/sdk/query/history.js +1 -1
  704. package/dist/sdk/query/item-filter-options.js +0 -1
  705. package/dist/sdk/query/light-metadata.js +1 -1
  706. package/dist/sdk/query/list-filter-shared.js +1 -1
  707. package/dist/sdk/query/list.js +1 -1
  708. package/dist/sdk/query/multi-value-filters.js +1 -1
  709. package/dist/sdk/query/next-ranking-policy.js +1 -1
  710. package/dist/sdk/query/next-ready-budget.js +1 -1
  711. package/dist/sdk/query/next.js +2 -2
  712. package/dist/sdk/query/parsers.js +1 -1
  713. package/dist/sdk/query/projection-contracts.js +1 -1
  714. package/dist/sdk/query/search/corpus.js +2 -2
  715. package/dist/sdk/query/search/filters.js +1 -1
  716. package/dist/sdk/query/search/input.js +1 -1
  717. package/dist/sdk/query/search/lexical.js +1 -1
  718. package/dist/sdk/query/search/response.js +1 -1
  719. package/dist/sdk/query/search/semantic.js +3 -3
  720. package/dist/sdk/query/search/types.js +0 -1
  721. package/dist/sdk/query/search-contracts.js +1 -1
  722. package/dist/sdk/query/search-pagination.js +1 -1
  723. package/dist/sdk/query/search-rendering.js +1 -1
  724. package/dist/sdk/query/search.js +1 -1
  725. package/dist/sdk/query/window-pagination.js +1 -1
  726. package/dist/sdk/query/workspace-contracts.js +1 -1
  727. package/dist/sdk/read-output/continuation.js +1 -1
  728. package/dist/sdk/read-output/extension.js +1 -1
  729. package/dist/sdk/read-output/options.js +1 -1
  730. package/dist/sdk/read-output/positional-rows.js +1 -1
  731. package/dist/sdk/read-output/provenance.js +1 -1
  732. package/dist/sdk/read-output/session-result.js +0 -1
  733. package/dist/sdk/read-output/surfaces.js +1 -1
  734. package/dist/sdk/read-output/tail-retention.js +1 -1
  735. package/dist/sdk/read-output-budget.js +1 -1
  736. package/dist/sdk/read-output-contracts.js +1 -1
  737. package/dist/sdk/read-output-rows.js +1 -1
  738. package/dist/sdk/read-output-session.js +1 -1
  739. package/dist/sdk/relationship-analytics.js +1 -1
  740. package/dist/sdk/relationship-context.js +1 -1
  741. package/dist/sdk/relationship-history.js +6 -6
  742. package/dist/sdk/relationship-kinds/contract.js +1 -1
  743. package/dist/sdk/relationships.js +1 -1
  744. package/dist/sdk/reproducibility/process.js +1 -1
  745. package/dist/sdk/runtime/actions.js +1 -1
  746. package/dist/sdk/runtime/context.js +1 -1
  747. package/dist/sdk/runtime/mutation-admission.js +1 -1
  748. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  749. package/dist/sdk/runtime/schema-preview.js +1 -1
  750. package/dist/sdk/runtime/schema.js +1 -1
  751. package/dist/sdk/runtime-action-aliases.js +1 -1
  752. package/dist/sdk/runtime-extended-actions.js +1 -1
  753. package/dist/sdk/runtime-input.d.ts +8 -2
  754. package/dist/sdk/runtime-input.js +1 -1
  755. package/dist/sdk/runtime-primitives.d.ts +1 -1
  756. package/dist/sdk/runtime-primitives.js +1 -1
  757. package/dist/sdk/runtime-public-contracts.js +0 -1
  758. package/dist/sdk/runtime-stats-options.js +1 -1
  759. package/dist/sdk/runtime.d.ts +9 -0
  760. package/dist/sdk/runtime.js +1 -1
  761. package/dist/sdk/scheduling-shortcuts.js +1 -1
  762. package/dist/sdk/schema/field-option-collisions.js +2 -0
  763. package/dist/sdk/schema-migration.js +4 -4
  764. package/dist/sdk/schema.js +7 -7
  765. package/dist/sdk/search-refresh-worker.js +1 -1
  766. package/dist/sdk/similarity-scoring.js +1 -1
  767. package/dist/sdk/similarity.js +1 -1
  768. package/dist/sdk/start-task-status.js +1 -1
  769. package/dist/sdk/stats.js +1 -1
  770. package/dist/sdk/structured-mutations.d.ts +5 -5
  771. package/dist/sdk/structured-mutations.js +1 -1
  772. package/dist/sdk/telemetry-flush.js +1 -1
  773. package/dist/sdk/telemetry.js +4 -4
  774. package/dist/sdk/templates.js +3 -3
  775. package/dist/sdk/test/batch.js +2 -2
  776. package/dist/sdk/test/command-args.js +1 -1
  777. package/dist/sdk/test/command-resolution.js +2 -2
  778. package/dist/sdk/test/entry.js +2 -2
  779. package/dist/sdk/test/execution-receipts.js +2 -2
  780. package/dist/sdk/test/execution.js +5 -5
  781. package/dist/sdk/test/json-path.js +1 -1
  782. package/dist/sdk/test/linked-command-detection.js +1 -1
  783. package/dist/sdk/test/measurements.js +1 -1
  784. package/dist/sdk/test/parsers.js +1 -1
  785. package/dist/sdk/test/prerequisites.js +1 -1
  786. package/dist/sdk/test/receipt-index-snapshot.js +1 -1
  787. package/dist/sdk/test/run-phases.js +1 -1
  788. package/dist/sdk/test/runs.js +1 -1
  789. package/dist/sdk/test/trust.js +2 -2
  790. package/dist/sdk/test/update.js +1 -1
  791. package/dist/sdk/test/workspace-snapshot.js +1 -1
  792. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  793. package/dist/sdk/traceability/source-traceability.js +2 -2
  794. package/dist/sdk/tracker-root-discovery.js +1 -1
  795. package/dist/sdk/transactions/item-finalization.js +2 -0
  796. package/dist/sdk/workspace-contracts-cache.js +1 -1
  797. package/dist/sdk/workspace-contracts.js +1 -1
  798. package/dist/sdk/workspace-memory.js +2 -2
  799. package/dist/sdk/workspace-snapshot.js +5 -5
  800. package/dist/sdk/workspace-transaction-gc.js +1 -1
  801. package/dist/sdk/workspace-transaction.js +2 -2
  802. package/dist/sdk/workspace.js +6 -6
  803. package/dist/types/index.js +1 -1
  804. package/dist/types.d.ts +20 -0
  805. package/dist/types.js +1 -1
  806. package/docs/AGENT_GUIDE.md +1 -1
  807. package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
  808. package/docs/COMMANDS.md +7 -3
  809. package/docs/EXTENSIONS.md +1 -1
  810. package/docs/HISTORY_RECOVERY.md +229 -5
  811. package/docs/README.md +2 -2
  812. package/docs/SDK.md +174 -5
  813. package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
  814. package/marketplace.json +1 -1
  815. package/node_modules/tar/package.json +2 -3
  816. package/package.json +31 -2
  817. package/packages/pm-beads/package.json +1 -1
  818. package/packages/pm-calendar/package.json +1 -1
  819. package/packages/pm-command-kit/package.json +1 -1
  820. package/packages/pm-digital-twin/package.json +1 -1
  821. package/packages/pm-governance-audit/package.json +1 -1
  822. package/packages/pm-guide-shell/package.json +1 -1
  823. package/packages/pm-kanban/package.json +1 -1
  824. package/packages/pm-lifecycle-hooks/package.json +1 -1
  825. package/packages/pm-linked-test-adapters/package.json +1 -1
  826. package/packages/pm-search-advanced/package.json +1 -1
  827. package/packages/pm-templates/package.json +1 -1
  828. package/packages/pm-todos/package.json +1 -1
  829. package/packages/pm-vcs/package.json +1 -1
  830. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  831. package/plugins/pm-claude/package.json +1 -1
  832. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  833. package/plugins/pm-codex/package.json +1 -1
  834. package/plugins/pm-codex/plugin.json +1 -1
  835. package/runtime-dependencies.json +1 -1
  836. package/scripts/finalize-build.mjs +63 -24
  837. package/scripts/prepare-build-cache.mjs +28 -1
  838. package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
  839. package/dist/cli-bundle/chunks/chunk-5647LU3A.js +0 -2287
  840. package/dist/cli-bundle/chunks/chunk-6QLEXRUG.js +0 -9
  841. package/dist/cli-bundle/chunks/chunk-AHQB7W2H.js +0 -3
  842. package/dist/cli-bundle/chunks/chunk-BKSVHOWI.js +0 -2
  843. package/dist/cli-bundle/chunks/chunk-CASX6SFI.js +0 -2
  844. package/dist/cli-bundle/chunks/chunk-CIKGG34F.js +0 -2
  845. package/dist/cli-bundle/chunks/chunk-D6ILFXZY.js +0 -2
  846. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  847. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
  848. package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
  849. package/dist/cli-bundle/chunks/chunk-JVGRFU5H.js +0 -3
  850. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
  851. package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
  852. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
  853. package/dist/cli-bundle/chunks/chunk-NCFCBKIP.js +0 -2
  854. package/dist/cli-bundle/chunks/chunk-NT5AKFE5.js +0 -31
  855. package/dist/cli-bundle/chunks/chunk-PJXKA4QU.js +0 -125
  856. package/dist/cli-bundle/chunks/chunk-RMIRNYRG.js +0 -71
  857. package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
  858. package/dist/cli-bundle/chunks/chunk-S6HB3WL2.js +0 -2
  859. package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
  860. package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
  861. package/dist/cli-bundle/chunks/chunk-SRVTCYAU.js +0 -2
  862. package/dist/cli-bundle/chunks/chunk-WELSVDPU.js +0 -2
  863. package/dist/cli-bundle/chunks/chunk-XHJ3H5PL.js +0 -3
  864. package/dist/cli-bundle/chunks/chunk-XWHJIRNV.js +0 -8
  865. package/dist/cli-bundle/chunks/chunk-YJEBK7HU.js +0 -8
  866. package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
  867. package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
  868. package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
  869. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
  870. package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
  871. package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
  872. package/dist/cli-bundle/chunks/mutation-actor-3TG636XG.js +0 -2
  873. package/dist/cli-bundle/chunks/mutation-admission-LICSDNNO.js +0 -2
  874. package/dist/cli-bundle/chunks/register-mutation-WWVECKFQ.js +0 -21
  875. package/dist/cli-bundle/chunks/register-operations-L6HFJNWD.js +0 -2
  876. package/dist/cli-bundle/chunks/register-setup-K7UFG5TD.js +0 -2
  877. package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
  878. package/dist/cli-bundle/chunks/stage-57KH3KAC.js +0 -2
  879. package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
  880. package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
  881. package/dist/cli-bundle/focused-chunks/chunk-532WZV65.js +0 -2
  882. package/dist/cli-bundle/focused-chunks/chunk-7A4QWNZX.js +0 -8
  883. package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
  884. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
  885. package/dist/cli-bundle/focused-chunks/chunk-CU2BRAOX.js +0 -2
  886. package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
  887. package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
  888. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
  889. package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
  890. package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
  891. package/dist/cli-bundle/focused-chunks/chunk-IQK5NPMG.js +0 -13
  892. package/dist/cli-bundle/focused-chunks/chunk-J63D6QST.js +0 -6
  893. package/dist/cli-bundle/focused-chunks/chunk-JMQJBZQ5.js +0 -2
  894. package/dist/cli-bundle/focused-chunks/chunk-LNHUE4VV.js +0 -2
  895. package/dist/cli-bundle/focused-chunks/chunk-MKM5NKD7.js +0 -8
  896. package/dist/cli-bundle/focused-chunks/chunk-NP72ZDXE.js +0 -2
  897. package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
  898. package/dist/cli-bundle/focused-chunks/chunk-QGKLRXP7.js +0 -2
  899. package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
  900. package/dist/cli-bundle/focused-chunks/chunk-RPE6IX26.js +0 -2
  901. package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
  902. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
  903. package/dist/cli-bundle/focused-chunks/chunk-UOC6257J.js +0 -26
  904. package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
  905. package/dist/cli-bundle/focused-chunks/chunk-WXMI4AV5.js +0 -8
  906. package/dist/cli-bundle/focused-chunks/chunk-XCJSHNXK.js +0 -27
  907. package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
  908. package/dist/cli-bundle/focused-chunks/chunk-YOAYY3HE.js +0 -2
  909. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
  910. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
  911. package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
  912. package/dist/cli-bundle/focused-chunks/mutation-actor-62HKR5IO.js +0 -2
  913. package/dist/cli-bundle/focused-chunks/mutation-admission-X4PF2SG3.js +0 -2
  914. package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
  915. package/dist/cli-bundle/focused-chunks/stage-O7T7CXBB.js +0 -2
  916. package/dist/sdk/agent/refusal-closure.js +0 -2
  917. package/dist/sdk/agent/refusal-reachability.js +0 -4
  918. package/dist/sdk/agent/task-transcript-contracts.js +0 -2
  919. package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
  920. package/dist/sdk/authoring.js +0 -2
  921. package/dist/sdk/compose.js +0 -2
  922. package/dist/sdk/contracts.js +0 -2
  923. package/dist/sdk/core-governance.js +0 -2
  924. package/dist/sdk/core.js +0 -2
  925. package/dist/sdk/corpus-shape.js +0 -2
  926. package/dist/sdk/define.js +0 -2
  927. package/dist/sdk/environment/agent-environment.js +0 -2
  928. package/dist/sdk/governance/artifact-ledgers.js +0 -2
  929. package/dist/sdk/governance/coverage-assurance.js +0 -2
  930. package/dist/sdk/governance/reliability.js +0 -2
  931. package/dist/sdk/governance.js +0 -2
  932. package/dist/sdk/graph/adapter.js +0 -2
  933. package/dist/sdk/graph/conformance.js +0 -2
  934. package/dist/sdk/graph/index.js +0 -2
  935. package/dist/sdk/graph.js +0 -2
  936. package/dist/sdk/index.js +0 -2
  937. package/dist/sdk/query.js +0 -2
  938. package/dist/sdk/relationship-migration.js +0 -2
  939. package/dist/sdk/testing.js +0 -8
  940. package/dist/sdk/workspace-recipe.js +0 -2
  941. package/docs/AGENT_PROVENANCE_ADR.md +0 -206
  942. package/docs/DEFECT_RECURRENCE.md +0 -257
  943. package/docs/PERFORMANCE.md +0 -204
@@ -0,0 +1,2289 @@
1
+ import{a as ct,b as Hn,c as yl,d as bl,g as wl,i as Hl}from"./chunk-5WZZ5XEN.js";import{L as Ar,U as ad,a as Bl,c as Wl,d as Vl,e as Kl,k as Jl,l as Jt,m as vr,n as kr,u as Sr,w as sd}from"./chunk-H7JEXRIN.js";import{$c as Ql,Da as qc,Db as Dl,Ea as jn,F as jc,G as Gc,Gb as jl,Hb as Gl,I as Uc,Ma as gl,Mb as Vt,Nc as pr,Nd as xr,Qc as Ce,Qd as hd,Rc as Yl,Wc as fr,Xc as _r,Yc as Xl,Yd as gd,Zc as Zl,Zd as yd,_c as lt,b as nr,cc as Vn,cd as nd,d as Me,dd as od,e as wc,ea as je,ed as rd,fd as id,g as rt,gb as kl,gd as yr,h as vc,hb as Sl,hd as br,i as or,id as wr,j as Nn,jc as ql,lc as zl,ld,mb as cr,md as dd,nb as lr,nd as md,o as it,ob as dr,od as pd,pd as ud,qb as Al,rb as xl,rc as Kn,rd as fd,sb as mr,sd as _d,tc as Kt,x as Mc,y as Dc}from"./chunk-ENKXRSFZ.js";import{A as Bt,B as Tc,C as Oc,D as ir,E as Wt,F as Ln,G as De,H as $c,I as sr,J as U,K as ar,L as j,M as Fc,N as Pc,O as Mn,Q as Nc,R as Dn,S as Lc,n as Ht,o as Ac,p as xc,q as Ic,s as rr,t as st,u as h,v as Ec,w as Cc,y as Y,z as Rc}from"./chunk-FJOEL75F.js";import{F as Zc,I as Qc,Ia as zn,K as el,L as tl,M as nl,Ma as _l,N as ol,O as rl,P as il,Pa as hl,Q as sl,R as al,S as cl,T as ll,U as dl,V as ml,W as pl,X as ul,Y as fl,d as Da,m as Gn,o as Ge,p as Bc,q as Un,r as Wc,s as _e,t as Vc,u as qn,v as Kc,va as at,w as Jc,x as Yc,z as Xc}from"./chunk-CFWLQFJM.js";import{i as zc,o as Hc}from"./chunk-BSRIVYTM.js";import{$a as Ue,Ha as Il,Ic as hr,Kb as ed,Lb as td,Nc as gr,Qc as cd,Ra as El,Sa as Cl,Ta as Rl,U as fe,Wa as Tl,Xa as Ol,Ya as $l,Za as Fl,aa as vl,ab as Pl,b as Ma,bb as Nl,db as Ll,fb as Bn,hb as Ml,lb as Ee,mb as Ul,nb as Wn,rb as ur}from"./chunk-KZHIBEJL.js";import{a as Na,b as La}from"./chunk-S32NGRQM.js";import{$ as Ka,$a as pc,B as Ga,Ba as Za,Da as Qa,E as Ua,F as Fn,G as qa,Ja as ec,Ka as tc,La as nc,M as za,Oa as oc,Q as Ha,Sa as rc,Ta as ic,Ua as sc,V as Ba,Va as ac,W as Wa,Wa as cc,Y as Va,Ya as lc,Za as dc,_a as mc,ab as uc,bb as fc,eb as _c,fb as Pn,gb as hc,hb as gc,i as tr,lb as Ie,lc as Sc,mb as E,nb as yc,ob as bc,pa as Ja,s as ja,sa as Ya,ta as Xa,yb as kc}from"./chunk-OPJF254V.js";import{r as ot}from"./chunk-6MYJLOSG.js";import{A as pn,Ab as qt,Ba as oa,Bb as ya,C as ss,Db as Ko,Ea as ue,Fb as Jo,Ha as ra,Ia as ia,Jb as ba,Ka as In,Kb as wa,L as _n,La as sa,Lb as va,M as hn,Mb as ka,N as gn,Nb as Sa,O as yn,P as fs,Pb as Aa,Qb as xa,R as ae,Ra as da,Rb as Ia,Sa as ma,Sb as zt,T as pe,Tb as Ea,Ub as $n,Vb as Ca,Vc as $a,Wb as Yo,X as Ys,Xb as Xo,Yb as Ra,Z as Xs,Za as Vo,_ as Zs,a as Xi,aa as Qs,ba as ea,eb as Cn,gb as Rn,i as $t,j as Zi,k as Qi,ka as zo,l as es,la as Ho,m as ts,mb as ua,ob as fa,od as Qo,pb as _a,pc as Zo,qb as ne,qd as er,ra as xn,rb as xe,s as ns,t as Ao,tc as Ta,td as Fa,u as os,ub as Ut,uc as Oa,ud as Pa,v as le,wb as Tn,x as rs,xa as na,xb as On,y as is,yb as ga}from"./chunk-TZY5MVJF.js";import{C as pa,H as ha,I as P,f as ta,g as tt,k as En,m as aa,n as nt,p as ca,s as Bo,t as Wo,v as I,w as la}from"./chunk-2UQU7HRR.js";import{$c as Ze,Aa as To,Ac as gs,Ad as Le,Aj as G,Bd as Dt,Bg as Fs,Dc as W,Dj as An,Fc as Xe,Fh as jt,Gc as ys,Gf as Es,Gh as Gt,Hj as Ks,Id as Ss,Ig as Ps,Ij as Js,Jb as ms,Jd as As,K as Ki,Ka as F,Kd as xs,L as Ji,La as un,Mb as Ae,O as Yi,Pb as $o,Rc as bs,Rg as Ns,Sa as x,Sb as Nt,Ue as H,Ug as Qe,Va as Se,Wa as Oo,Y as mn,Ya as me,Yb as S,Yg as Ls,Yi as vn,Zc as Ne,Zi as kn,_f as Cs,_i as Sn,a as Ot,ac as ps,ae as Fo,aj as Bs,b as ie,be as C,bi as wn,ca as Pt,cc as us,cd as ws,e as dn,ea as Io,fd as vs,gd as ks,ge as Is,gg as Rs,gi as et,gj as No,ij as Lo,jg as Ts,jj as Mo,kb as as,ki as Ms,kj as Do,lb as fn,lj as jo,mj as Go,nd as bn,nj as Uo,od as Lt,oj as qo,pd as Mt,pj as T,rb as cs,re as Po,si as Ds,t as J,ti as js,ui as Gs,v as So,vc as Ye,vg as Os,vi as Us,wc as Fe,wi as qs,wj as Ws,x as Vi,xa as Eo,xb as ls,xc as _s,xi as zs,xj as Vs,ya as Co,yb as ds,yc as hs,yg as $s,yi as Hs,za as Ro,zc as Pe}from"./chunk-NGJ5ERBF.js";import{A as u,C as p,E as ke,F as Je,G as xo,H as de,K as se,M as Ft,a as Ui,e as qi,f as zi,g as Hi,i as Bi,m as Wi}from"./chunk-YYT3MIRF.js";import{AsyncLocalStorage as Zy}from"node:async_hooks";import{realpathSync as Qy}from"node:fs";import Mi from"node:path";import{readFile as vu}from"node:fs/promises";import ku from"node:path";var Ir="context-intents.json";function Jn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Su(e,t,n){if(!Jn(e))throw new TypeError(`${t} context intent at index ${String(n)} must be an object`);let o=e.included_field_groups;if(typeof e.command!="string"||typeof e.intent!="string"||typeof e.description!="string"||!Array.isArray(o)||!o.every(r=>typeof r=="string")||typeof e.token_budget!="number")throw new TypeError(`${t} context intent at index ${String(n)} has an invalid contract shape`);return{command:e.command,intent:e.intent,description:e.description,included_field_groups:o,token_budget:e.token_budget}}function bd(e,t){let n=Array.isArray(e)?e:Jn(e)&&Array.isArray(e.intents)?e.intents:void 0;if(!n)throw new TypeError(`${t} context intents must be an array or an object with an intents array`);return n.map((o,r)=>Su(o,t,r))}async function Au(e){let t=ku.join(e,Ir),n;try{n=await vu(t,"utf8")}catch(r){if(Je(r))return[];throw await ha(e),r}let o;try{o=JSON.parse(n)}catch(r){let i=r instanceof Error?r.message:String(r);throw new TypeError(`Invalid ${Ir}: ${i}`,{cause:r})}return bd(o,Ir)}function xu(e){if(!Jn(e))return;let t=e.contextIntents??e.context_intents;if(t!==void 0)return t;let n=e.default;return Jn(n)?n.contextIntents??n.context_intents:void 0}function Iu(e){return e.flatMap(t=>{let n=xu(t.module);return n===void 0?[]:bd(n,`package ${t.name}`)})}async function Eu(e){let t=await Au(e.pmRoot),n=Iu(e.packages??[]);return{workspaceContracts:t,packageContracts:n}}async function Er(e,t){let n=await Eu(e);return await Ns(n,t)}async function wd(e,t,n=Ps){try{await n({pmRoot:e,result:t})}catch{if(typeof t=="object"&&t!==null&&!Array.isArray(t)){let o=t,r=Array.isArray(o.warnings)?o.warnings.filter(i=>typeof i=="string"):[];o.warnings=[...new Set([...r,"context_usage_feedback_write_failed"])].sort()}}}import{createHash as Lu}from"node:crypto";var Yt=class extends RangeError{code;work;minimum_tokens;constructor(t,n,o){super(t),this.name="OutputEnvelopeFitError",this.code=t,this.work=Object.freeze({...n}),this.minimum_tokens=o}};function Cr(e,t){if(!Number.isSafeInteger(e)||e<1)throw new RangeError(`${t} must be a positive safe integer`)}function Cu(e,t,n,o){return t.map(([r,i])=>{if(o.render_calls>=o.max_render_calls)throw new Yt("output_envelope_work_limit",o);o.render_calls+=1;let s=i(e);if(typeof s!="string")throw new TypeError("Envelope renderers must return strings");let a=n(s);if(!Number.isSafeInteger(a)||a<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:r,text:s,bytes:Buffer.byteLength(s,"utf8"),estimated_tokens:a}})}function vd(e,t,n,o){let r=t,i=Object.entries(n.renderers),s=n.estimateTokens??(a=>Es(Buffer.byteLength(a,"utf8")));for(let a=0;a<(n.maxStabilizationPasses??16);a+=1){let c=Object.freeze({...r}),l={...n.buildEnvelope(e,c),output_fit:c},d=Cu(l,i,s,o),m=Math.max(...d.map(b=>b.bytes)),f=Math.max(...d.map(b=>b.estimated_tokens));if(m===r.output_bytes&&f===r.estimated_tokens)return{envelope:l,renderings:d};r={...r,output_bytes:m,estimated_tokens:f}}throw new Yt("output_envelope_unstable",o)}function kd(e,t){Cr(t.tokenBudget,"tokenBudget"),Cr(t.maxRenderCalls??1e4,"maxRenderCalls"),Cr(t.maxStabilizationPasses??16,"maxStabilizationPasses");let n=t.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(t.renderers).length===0||Object.entries(t.renderers).some(([c,l])=>!c.trim()||typeof l!="function"))throw new TypeError("Envelope fitting requires named callable renderers");let o={evaluated_candidates:0,render_calls:0,max_render_calls:t.maxRenderCalls??1e4},r=[],i=[],s=c=>({version:1,policy:n,total_candidates:e.length,included_indices:Object.freeze([...c]),omitted_count:e.length-c.length,token_budget:t.tokenBudget,estimated_tokens:0,output_bytes:0}),a=vd(r,s(i),t,o);if(a.envelope.output_fit.estimated_tokens>t.tokenBudget)throw new Yt("output_envelope_infeasible",o,a.envelope.output_fit.estimated_tokens);for(let[c,l]of e.entries()){o.evaluated_candidates+=1;let d=[...r,l],m=[...i,c],f=vd(d,s(m),t,o);if(f.envelope.output_fit.estimated_tokens<=t.tokenBudget)r=d,i=m,a=f;else if(n==="prefix")break}return{rows:r,...a,complete:r.length===e.length,work:Object.freeze({...o})}}import{constants as Xt}from"node:fs";import{lstat as Sd,mkdir as Tr,open as Ad}from"node:fs/promises";import he from"node:path";function Rr(e,t){if(typeof e!="string"||e.trim().length===0)throw new TypeError(`Relationship event ${t} must be non-empty`);return e.trim()}function Or(e,t){let n=t.require(e.kind),o=n.direction==="undirected"?[e.source,e.target].sort().join("\0"):`${e.source}\0${e.target}`;return`${n.kind}\0${o}`}function Ru(e){return Object.freeze({...e,...e.payload===void 0?{}:{payload:Object.freeze(structuredClone(e.payload))}})}function Tu(e,t,n,o){let r=n.require(e.kind),i=o.outgoingOne.get(`${r.kind}\0${e.source}`);if(i!==void 0&&i!==t)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=o.incomingOne.get(`${r.kind}\0${e.target}`);if(s!==void 0&&s!==t)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let a=Or(e,n),c=o.identities.get(a);if(c!==void 0&&c!==t)throw new TypeError(`Relationship edge already active: ${a}`)}function Ou(e){let t=new Map;for(let n of e)n.action==="remove"?t.delete(n.relationshipId):t.set(n.relationshipId,n.edge);return t}function $u(e,t,n){if(e.expectedVersion!==void 0&&e.expectedVersion!==t)throw new TypeError(`Relationship event version conflict: expected ${e.expectedVersion}, current ${t}`);let o=Rr(e.eventId,"eventId");if(n.has(o))throw new TypeError(`Relationship event already exists: ${o}`);if(e.action!=="add"&&e.action!=="remove"&&e.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${e.action}`);if(!Number.isFinite(Date.parse(e.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:o,relationshipId:Rr(e.relationshipId,"relationshipId"),author:Rr(e.author,"author"),timestamp:new Date(e.timestamp).toISOString()}}function Fu(e,t,n,o,r,i){let s=n.has(t);if(e.action==="add"&&s)throw new TypeError(`Relationship is already active: ${t}`);if(e.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${t}`);if(e.action==="remove")return;if(!e.edge)throw new TypeError(`Relationship ${e.action} event requires an edge`);let a=typeof e.edge.source=="string"?e.edge.source.trim():"",c=typeof e.edge.target=="string"?e.edge.target.trim():"";if(!o.has(a)||!o.has(c))throw new TypeError(`Relationship endpoint not found: ${a} -> ${c}`);let l=new et([a,c],[e.edge],r).edges()[0];return Tu(l,t,r,i),Ru(l)}var Zt=class{#t;#n;#o=[];#i=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(t,n={}){this.#t=new Set([...t].filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean)),this.#n=n.registry??wn()}get version(){return this.#o.length}events(){return Object.freeze([...this.#o])}*stream(t={}){let n=t.fromVersion??1,o=t.toVersion??this.version,r=t.batchSize??100;if(!Number.isInteger(n)||n<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${o}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(n>o+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let i=n-1;i<o;i+=r)yield Object.freeze(this.#o.slice(i,Math.min(i+r,o)))}project(t,n,o={}){if(typeof n!="function")throw new TypeError("Relationship event projection requires a reducer");let r=t,i=0,s;for(let a of this.stream({...o,batchSize:256}))for(let c of a)r=n(r,c),i+=1,s=c;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(o.fromVersion??1)-1),processed:i,...s===void 0?{}:{asOf:s.timestamp}})}#s(t,n){let o=this.#n.require(n.kind);this.#r.identities.set(Or(n,this.#n),t),o.outgoing==="one"&&this.#r.outgoingOne.set(`${o.kind}\0${n.source}`,t),o.incoming==="one"&&this.#r.incomingOne.set(`${o.kind}\0${n.target}`,t)}#a(t){let n=this.#n.require(t.kind);this.#r.identities.delete(Or(t,this.#n)),n.outgoing==="one"&&this.#r.outgoingOne.delete(`${n.kind}\0${t.source}`),n.incoming==="one"&&this.#r.incomingOne.delete(`${n.kind}\0${t.target}`)}append(t){let n=$u(t,this.version,this.#i),o=this.#e.get(n.relationshipId),r=Fu(t,n.relationshipId,this.#e,this.#t,this.#n,this.#r),i=Object.freeze({eventId:n.eventId,relationshipId:n.relationshipId,action:t.action,...r===void 0?{}:{edge:r},author:n.author,timestamp:n.timestamp,...t.reason?.trim()?{reason:t.reason.trim()}:{},sequence:this.version+1});return this.#o.push(i),this.#i.add(n.eventId),o&&this.#a(o),t.action==="remove"?this.#e.delete(n.relationshipId):(this.#e.set(n.relationshipId,r),this.#s(n.relationshipId,r)),i}snapshot(t={}){if(t.atVersion!==void 0&&t.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let n;if(t.atTimestamp!==void 0){let i=Date.parse(t.atTimestamp);if(!Number.isFinite(i))throw new TypeError("Relationship snapshot timestamp must be valid");n=this.#o.filter(s=>Date.parse(s.timestamp)<=i)}else{let i=t.atVersion??this.version;if(!Number.isInteger(i)||i<0||i>this.version)throw new TypeError(`Relationship snapshot version out of range: ${i}`);n=this.#o.slice(0,i)}let o=Ou(n),r=new et(this.#t,o.values(),this.#n);return Object.freeze({version:n.at(-1)?.sequence??0,...n.at(-1)?{asOf:n.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(t){if(!Number.isInteger(t.limit)||t.limit<1)throw new TypeError("Relationship event page limit must be positive");let n=Os("relationship-events",{order:"append-sequence"}),o=t.cursor===void 0?this.version:Number($s(t.cursor,n).snapshot);if(!Number.isSafeInteger(o)||o<0||o>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=Fs(this.#o.slice(0,o),{cursor:t.cursor,fingerprint:n,limit:t.limit,readId:i=>i.eventId,snapshot:String(o)});return{version:o,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Pu="relationship-event-store",xd=Xt.O_NOFOLLOW;function Yn(e){return Le(e,Pu,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function qe(e,t="relationships/events.jsonl"){let n=he.resolve(e),o=he.resolve(n,t),r=he.relative(n,o);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${he.sep}`)||he.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await Tr(n,{recursive:!0}),(await Sd(n)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=n;for(let a of r.split(he.sep)){s=he.join(s,a);try{if((await Sd(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(c){if(xo(c))break;throw c}}return o}async function Xn(e,t,n){let o=new Zt(t,{registry:n}),r,i;try{i=await Ad(e,Xt.O_RDONLY|xd),r=await i.readFile("utf8")}catch(a){if(xo(a))return{log:o,raw:""};throw a}finally{await i?.close()}let s=r.split(`
2
+ `);for(let a=0;a<s.length;a+=1){let c=s[a].trim();if(!c)continue;let l;try{l=JSON.parse(c)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${a+1}`)}if(l.sequence!==o.version+1)throw new TypeError(`Invalid relationship event sequence at line ${a+1}`);o.append({eventId:l.eventId,relationshipId:l.relationshipId,action:l.action,...l.edge===void 0?{}:{edge:l.edge},author:l.author,timestamp:l.timestamp,...l.reason===void 0?{}:{reason:l.reason},expectedVersion:o.version})}return{log:o,raw:r}}function Nu(e,t,n,o){let r=Date.parse(t.timestamp),i;return t.action!=="remove"&&t.edge!==void 0&&(i=new et(n,[t.edge],o).edges()[0]),e.eventId===t.eventId.trim()&&e.relationshipId===t.relationshipId.trim()&&e.action===t.action&&e.author===t.author.trim()&&Number.isFinite(r)&&e.timestamp===new Date(r).toISOString()&&e.reason===(t.reason?.trim()||void 0)&&Ot(e.edge)===Ot(i)}var Zn=class e{#t;#n;#o;#i;#e;constructor(t,n,o,r){this.#t=t.pmRoot,this.#n=n,this.#o=t.registry,this.#i=o,this.#e=r}static async open(t){let n=Object.freeze([...t.nodes]),o=await qe(t.pmRoot,t.relativePath),r=await Yn(t.pmRoot);try{await qe(t.pmRoot,o);let{log:i}=await Xn(o,n,t.registry);return new e(t,n,o,i)}finally{await r()}}get path(){return this.#i}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(t){let n=await Yn(this.#t);try{let o=await qe(this.#t,this.#i),{log:r}=await Xn(o,this.#n,this.#o),i=r.append(t);await Tr(he.dirname(o),{recursive:!0}),await qe(this.#t,o);let s=await Ad(o,Xt.O_APPEND|Xt.O_CREAT|Xt.O_WRONLY|xd);try{await s.appendFile(`${JSON.stringify(i)}
3
+ `,"utf8")}finally{await s.close()}return this.#e=r,i}finally{await n()}}async appendBatch(t,n={}){let o=await Yn(this.#t);try{let r=await qe(this.#t,this.#i),{log:i,raw:s}=await Xn(r,this.#n,this.#o),a=i.version,c=new Map(i.events().map(m=>[m.eventId,m])),l=[],d=[];for(let m of t){let f=m.eventId.trim(),b=c.get(f);if(b!==void 0){if(n.existingEventPolicy==="skip_identical"&&Nu(b,m,this.#n,this.#o)){d.push(b.eventId);continue}if(n.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${f}`)}let g=i.append(m);c.set(g.eventId,g),l.push(g)}if(l.length>0){let m=s.length===0||s.endsWith(`
4
+ `)?s:`${s}
5
+ `;await Tr(he.dirname(r),{recursive:!0}),await qe(this.#t,r),await se(r,`${m}${l.map(f=>JSON.stringify(f)).join(`
6
+ `)}
7
+ `)}return this.#e=i,Object.freeze({version_before:a,version_after:i.version,appended:Object.freeze(l),skipped_event_ids:Object.freeze(d)})}finally{await o()}}async snapshot(t={}){return this.#e=await this.#r(),this.#e.snapshot(t)}async page(t){return this.#e=await this.#r(),this.#e.page(t)}async*stream(t={}){this.#e=await this.#r(),yield*this.#e.stream(t)}async project(t,n,o={}){return this.#e=await this.#r(),this.#e.project(t,n,o)}async#r(){let t=await Yn(this.#t);try{let n=await qe(this.#t,this.#i);return(await Xn(n,this.#n,this.#o)).log}finally{await t()}}};function $r(e){let t=wn();for(let n of e)t.register(n);return t}function Mu(e,t,n=[]){if(n.length===0)return e;let o=JSON.parse(e),r=JSON.parse(Wo(t));for(let i of n){let s=i.split("."),a=r;for(let d of s){let m=$o(a);if(!/^[a-zA-Z][a-zA-Z0-9_]*$/u.test(d)||["constructor","prototype","__proto__"].includes(d)||m===null||!Object.hasOwn(m,d))throw new p(`Invalid owned settings subtree: ${i}. Select a declared inline object path.`,u.USAGE);a=m[d]}if($o(a)===null)throw new p(`Invalid owned settings subtree: ${i}. Select a declared inline object path.`,u.USAGE);let c=o,l=r;for(let d of s.slice(0,-1)){let m=c[d];l=l[d],m===void 0&&Object.defineProperty(c,d,{value:structuredClone(l),enumerable:!0,writable:!0,configurable:!0}),c=c[d]}Object.defineProperty(c,s.at(-1),{value:a,enumerable:!0,writable:!0,configurable:!0})}return ie(o,JSON.parse(e))?e:`${JSON.stringify(o,null,2)}
8
+ `}function Id(e,t,n,o){return{fitOutputEnvelope:kd,client:t,isItemNotFoundError:r=>Zo(r)&&r.exitCode===u.NOT_FOUND,getItemAt:(r,i)=>La(r,i,{pmRoot:e}),readSettingsSection:(r,i)=>Fa(e,r,i),writeSettingsSection:(r,i,s)=>Pa(e,r,i,{author:n,...s}),openRelationshipEventStore:r=>Zn.open({pmRoot:e,nodes:r.nodes,registry:$r(r.definitions),...r.relativePath===void 0?{}:{relativePath:r.relativePath}}),createRelationshipGraph:r=>new et(r.nodes,r.edges,$r(r.definitions)),analyzeRelationshipImpact:(r,i,s)=>Ma(r,i,s),validateRelationshipEvents:r=>{let i=new Zt(r.nodes,{registry:$r(r.definitions)});return r.events.map(s=>i.append({...s,expectedVersion:i.version}))},commitWorkspaceTransaction:r=>Da({...r,pmRoot:e}),mutateWorkspaceSettings:async r=>{if(!/^[a-zA-Z0-9._-]{1,128}$/u.test(r.operationId))throw new p("Workspace settings operationId must be 1-128 letters, digits, dots, underscores, or hyphens.",u.USAGE);let i=r.dryRun===!0?await nt(e,()=>I(e)):await I(e);try{let s=await ta({pmRoot:e,filePath:Se(e),op:"extension:pm:settings",idempotencyKey:o===void 0?r.operationId:`${Lu("sha256").update(o).digest("hex").slice(0,16)}:${r.operationId}`,author:C(n,i.author_default),lockTtlSeconds:i.locks.ttl_seconds,lockWaitMs:i.locks.wait_ms,recordCreation:!1,dryRun:r.dryRun===!0,mutate:async a=>{let c=a===null?null:JSON.parse(a),l=En(c);if(!l.success)throw new p("Workspace settings mutation requires a valid initialized settings.json.",u.USAGE);let d=Bo(l.data),m=await r.mutate(structuredClone(d));if(!En(m).success)throw new p("Workspace settings mutation returned invalid settings.json.",u.USAGE);let f=ie(d,m)?a:Wo(m,{source:{raw:c,validated:l.data}});f=Mu(f,m,r.replaceSubtrees);let b=En(JSON.parse(f));if(!b.success)throw new p("Workspace settings mutation serialized invalid settings.json.",u.USAGE);return{raw:f,result:r.includePreview===!0?Bo(b.data):void 0}}});return s.changed&&r.dryRun!==!0&&await G({path:Se(e),scope:"project",op:"extension:pm:settings"}),{changed:s.changed,dry_run:r.dryRun===!0,replayed:s.replayed===!0,...s.result===void 0?{}:{preview:s.result}}}finally{aa(e)}}}}function Ed(e){return{undeclaredKeys:qc(e)?"pass":"refuse"}}var Du=["invalid_envelope","source_incomplete","source_unchecked","filtered_corpus","terminal_items_excluded","strict_read_unproven","page_incomplete","count_mismatch","projection_incomplete","field_omission","omission_receipt_missing","omission_receipt_invalid","read_output_missing","read_output_invalid","read_output_dimensions_incomplete","budget_compaction","budget_omission","session_projection","invalid_item_id","duplicate_item_id"],Qn=class extends Error{receipt;constructor(t,n={}){super(`Complete-list certification failed: ${t.map(r=>r.code).join(", ")}.`),this.name="PmCompleteListValidationError";let o=n.includeBody===!0;this.receipt={contract_version:1,contract:"complete_list",findings:t,recovery:{suggested_retry:`pm list --all --output-include full --strict-read --no-truncate --output-budget unbounded --output-limit unbounded${o?" --include-body":""} --json`,sdk:o?"await client.listAllComplete({ includeBody: true })":"await client.listAllComplete()"}}}};function Fr(e={}){return Cs({excludeTerminal:!1,full:!0,...e.includeBody===void 0?{}:{includeBody:e.includeBody},noTruncate:!0,outputBudget:"unbounded",outputLimit:"unbounded",strictRead:!0},["full"])}function oe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function M(e,t,n,o){t&&e.push({code:n,message:o})}function ju(e,t){let n=oe(e.completeness)?e.completeness:{};M(t,n.status==="partial","source_incomplete","The source scan reported unreadable tracker artifacts."),M(t,n.status!=="complete"&&n.status!=="partial","source_unchecked","The source scan did not prove completeness.");let o=n.unreadable_item_count,r=n.unreadable_directory_count;M(t,n.status==="complete"&&(o!==0||r!==0)&&Number.isSafeInteger(o)&&Number.isSafeInteger(r),"source_incomplete","The source scan reports unreadable tracker artifacts despite a complete status."),M(t,n.status==="complete"&&(!Number.isSafeInteger(o)||!Number.isSafeInteger(r)||Number(o)<0||Number(r)<0),"source_unchecked","The source scan did not report safe non-negative unreadable counts.");let i=oe(e.filters)?e.filters:{},s=oe(i.runtime_filters)?i.runtime_filters:{},a=new Set(["exclude_terminal","include_body","no_truncate","runtime_filters","status","strict_read"]);return M(t,i.status!=="all"||Object.keys(s).length>0||Object.keys(i).some(c=>!a.has(c)),"filtered_corpus","The list did not explicitly select every lifecycle status."),M(t,i.exclude_terminal===!0,"terminal_items_excluded","Terminal lifecycle states were explicitly excluded."),M(t,i.strict_read!==!0,"strict_read_unproven","The result does not echo strict source-read enforcement."),i}function Gu(e,t,n){M(n,e.has_more!==!1||e.next_cursor!==null||e.truncated!==!1||e.applied_limit!==void 0||t.no_truncate!==!0,"page_incomplete","Pagination or a row ceiling may have withheld items."),M(n,e.count!==e.items.length||e.total!==e.items.length,"count_mismatch","Envelope counts do not equal the returned item count.");let o=oe(e.projection)?e.projection:{};M(n,o.mode!=="full"||o.fields!==null,"projection_incomplete","The result is not the full metadata projection.");let r=oe(e.omission_receipt)?e.omission_receipt:void 0;M(n,r===void 0,"omission_receipt_missing","The result carries no field-omission receipt."),M(n,r!==void 0&&(r.has_omissions!==!1||r.omitted_field_group_count!==0||!Number.isSafeInteger(r.omitted_field_group_count)||!Array.isArray(r.omitted_field_groups)||r.omitted_field_groups.length!==0),"omission_receipt_invalid","The field-omission receipt is malformed or contradicts its no-omission claim."),M(n,r?.has_omissions===!0,"field_omission","The omission receipt reports withheld field groups.")}function Uu(e){return e.contract_version!==1||e.command!=="list"||e.within_budget!==!0||e.strings_compacted!==!1||e.rows_compacted!==!1||e.result_omitted!==!1}function qu(e){if(!Array.isArray(e.requested_dimensions))return!1;let t=new Set(e.requested_dimensions);return["include","amount","cost"].every(n=>t.has(n))}function zu(e,t){let n=oe(e.read_output)?e.read_output:void 0;M(t,n===void 0,"read_output_missing","The result carries no universal read-output receipt."),M(t,n!==void 0&&Uu(n),"read_output_invalid","The universal read-output receipt does not prove an intact list result."),M(t,n!==void 0&&!qu(n),"read_output_dimensions_incomplete","The universal read-output receipt does not prove full, unbounded include, amount, and cost dimensions."),M(t,n?.strings_compacted===!0||n?.rows_compacted===!0||e.output_budget_truncation!==void 0,"budget_compaction","Universal output shaping compacted the result.");let o=oe(e.output_budget_exceeded)?e.output_budget_exceeded:void 0;M(t,n?.result_omitted===!0||o?.omitted_result===!0,"budget_omission","Universal output shaping omitted the useful result."),M(t,e.read_session!==void 0,"session_projection","A cross-call read session can suppress previously served facts.")}function Hu(e,t){let n=e.map(o=>oe(o)&&typeof o.id=="string"?o.id.trim():"");M(t,n.some(o=>o.length===0),"invalid_item_id","Every full item row must carry a non-empty string id."),M(t,new Set(n).size!==n.length,"duplicate_item_id","Every item id must occur exactly once.")}function Cd(e){if(!oe(e)||!Array.isArray(e.items))return{ok:!1,findings:[{code:Du[0],message:"The result must be an object with an items array."}]};let t=e,n=[],o=ju(t,n);return Gu(t,o,n),zu(t,n),Hu(t.items,n),{ok:n.length===0,findings:n}}function Bu(e,t){return t.includeBody!==void 0?t.includeBody:oe(e)&&oe(e.filters)&&e.filters.include_body===!0}function eo(e,t={}){let n=Cd(e);if(!n.ok)throw new Qn(n.findings,{includeBody:Bu(e,t)});let o=e;return{...o,complete_list:{contract_version:1,item_count:o.items.length,unique_item_id_count:new Set(o.items.map(r=>r.id)).size,terminal_items_included:!0,source_complete:!0,full_projection:!0,no_omissions:!0,unbounded:!0}}}function Wu(e,t={}){eo(e,t)}async function Rd(e,t){let n=x(t??process.cwd(),e),o=await I(n);return Ut(n,o.item_format,F(o,null).type_to_folder,void 0,o.schema)}var Vu={"list-all":{action:"list",options:{excludeTerminal:!1}},"list-draft":{action:"list",options:{status:"draft",excludeTerminal:!1}},"list-open":{action:"list",options:{status:"open",excludeTerminal:!1}},"list-in-progress":{action:"list",options:{status:"in_progress",excludeTerminal:!1}},"list-blocked":{action:"list",options:{status:"blocked",excludeTerminal:!1}},"list-closed":{action:"list",options:{status:"closed",excludeTerminal:!1}},"list-canceled":{action:"list",options:{status:"canceled",excludeTerminal:!1}}};function Td(e){return Object.fromEntries(Ki.map(t=>[`${e}-${t}`,{action:e,options:{[t==="adopt-all"?"adoptAll":t]:!0,...e==="package"?{vocabulary:"package"}:{}}}]))}var Pr={ctx:{action:"context"},...Vu,...Td("extension"),...Td("package"),...Object.fromEntries(Ji.map(e=>[`package-${e}`,{action:e}]))};function Od(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ku(e){return e.brief===!0?"brief":typeof e.fields=="string"&&e.fields.trim().length>0||Array.isArray(e.fields)&&e.fields.length>0?"fields":e.compact===!0?"compact":"full"}function Nr(e,t){let n=Ku(t),o=n==="brief"?n:Od(e.projection)&&typeof e.projection.mode=="string"?e.projection.mode:n;return{...e,query_summary:{filters:Od(e.filters)?e.filters:{},projection:o}}}import{readFile as Ju}from"node:fs/promises";async function Lr(e,t){let n=e.add!==void 0,o=e.stdin===!0,r=typeof e.file=="string",i=Number(n)+Number(o)+Number(r);if(i===0)return;if(i>1)throw new p("Specify comment text using only one input source: --add, --stdin, or --file",u.USAGE);if(n)return{value:await t.resolveValue(e.add,"--add",rs(e))??"",emptyFlag:"--add"};if(o)return or(e,"--stdin"),{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};let s=e.file.trim();if(!s)throw new p("--file path cannot be empty",u.USAGE);if(s==="-")return or(e,"--file -"),{value:await t.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await Ju(s,"utf8"),emptyFlag:"--file"}}catch(a){if(vc(a)&&Je(a))throw new p(`--file path not found: ${s}. Use --file - to read stdin.`,u.USAGE);let c=a instanceof Error?a.message:String(a);throw new p(`Failed to read --file path "${s}": ${c}. Use --file - to read stdin.`,u.USAGE)}}async function Yu(e,t){let n=e.edit,o=e.delete,r=n!==void 0,i=o!==void 0;if(r&&i)throw new p("Specify only one of --edit or --delete",u.USAGE);if(n!==void 0&&(!Number.isInteger(n)||n<1))throw new p("--edit must be a positive integer",u.USAGE);if(o!==void 0&&(!Number.isInteger(o)||o<1))throw new p("--delete must be a positive integer",u.USAGE);if(i){if(await Lr(e,t)!==void 0)throw new p("--delete does not take comment text",u.USAGE);return{mode:"delete",index:o}}if(r){let c=await Lr(e,t);if(c===void 0)throw new p("--edit requires replacement text via positional [text], --add, --stdin, or --file",u.USAGE);return{mode:"edit",index:n,value:c.value,emptyFlag:c.emptyFlag}}let s=await Lr(e,t);return s===void 0?{mode:"list"}:{mode:s.emptyFlag==="--add"?"add":s.emptyFlag==="--stdin"?"stdin":"file",value:s.value,emptyFlag:s.emptyFlag}}async function $d(e,t,n){let o=pn(),r=await Yu(t,o),i=r.mode==="add"||r.mode==="edit",s=r.value??"";return it(e,t,n,{input:{...r,rawValue:t.add??s,value:i?rt(s,{stripPlainTextPrefix:!0}):s},collectionKey:"comments",op:"comment_add",editOp:"comment_edit",deleteOp:"comment_delete",parseText:a=>a,createEntry:a=>a,bypassOwnershipConflict:!!(r.mode==="add"&&t.ownershipAppendBypass),conflictGuidance:{required:"Strict ownership also protects annotations. Ask the current owner to run pm release <id>, then run pm claim <id>; use --force only for an explicitly approved override.",examples:["pm claim <id>"],nextSteps:["For an approved append without reassignment: pm package install governance-audit --project; then pm comments --help lists the package-owned append bypass. Edit/delete still require ownership.","For a non-terminal handoff, the current owner runs pm release <id>; then you run pm claim <id> before retrying. Claim refuses work still held by another owner; --force requires an explicitly approved override."]}})}function Fd(e){let t=e.options.all===!0,n=e.id??h(e.options,"id");return Ul(n,t),t?Wn(e.options,e.global):Ee(n,e.options,e.global)}function Pd(e){let t=e.options.ids,n=ea(t);if(t!==void 0&&n==="")throw new p("history-compact ids requires at least one valid item ID.",u.USAGE,{code:"bulk_ids_input_empty",required:"Provide one or more string or finite numeric IDs; non-finite and unsupported selector values are rejected."});let o=n===void 0?void 0:Qs(n),r=Y(e.options.allOver??e.options.all_over,"history-compact allOver"),i=Y(e.options.minEntries??e.options.min_entries,"history-compact minEntries"),s=h(e.options,"scope"),a=[];e.options.closed===!0&&a.push("closed"),(e.options.allStreams===!0||e.options.all_streams===!0)&&a.push("all-streams"),(s==="closed"||s==="all-streams")&&a.push(s);let c=[...new Set(a)];if(c.length>1)throw new p("history-compact: closed and all-streams scopes are mutually exclusive.",u.USAGE);let l=c[0];return Wl(e.id,{ids:o,allOver:r,scope:l}),e.id!==void 0?Bl(e.id,{before:h(e.options,"before"),dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:h(e.options,"author"),message:h(e.options,"message"),force:e.force},e.global):Vl({ids:o,scope:l,allOver:r,minEntries:i,dryRun:e.options.dryRun===!0||e.options.dry_run===!0,author:h(e.options,"author"),message:h(e.options,"message"),force:e.force},e.global)}async function Nd(e,t,n){return it(e,t,n,{input:await Nn(t,"learning"),collectionKey:"learnings",op:"learning_add",editOp:"learning_edit",deleteOp:"learning_delete",parseText:o=>rt(o),createEntry:o=>o,bypassOwnershipConflict:!!(t.edit===void 0&&t.delete===void 0&&t.ownershipAppendBypass),conflictGuidance:{required:"Strict ownership also protects annotations. Ask the current owner to run pm release <id>, then run pm claim <id>; use --force only for an explicitly approved override.",examples:["pm claim <id>"],nextSteps:["For an approved append without reassignment: pm package install governance-audit --project; then pm learnings --help lists the package-owned append bypass. Edit/delete still require ownership.","For a non-terminal handoff, the current owner runs pm release <id>; then you run pm claim <id> before retrying. Claim refuses work still held by another owner; --force requires an explicitly approved override."]}})}async function Md(e,t,n){if(xc(t),Ht(e,"append","id"),t=ns(t),t.body===void 0)throw new p("Missing required --body text",u.USAGE);let o=pn(),r=x(process.cwd(),n.path);await P(r);let i=await I(r),s=C(t.author,i.author_default),c=(await o.resolveValue(t.body,"--body",is(t,"body"))).trim();if(c.length===0)throw new p("--body text cannot be empty; append requires non-blank content and empty appends would only rewrite updated_at.",u.USAGE,{code:"append_empty_body",required:"Provide non-empty body text positionally, via --body, or with - for stdin.",examples:['pm append pm-a1b2 --body "Progress note"',"pm append pm-a1b2 --body -"]});let l=await qt({pmRoot:r,settings:i,id:e,op:"append",author:s,message:t.message,force:t.force,mutate(d){let m=d.body.trim().length>0?`
9
+
10
+ `:"";return d.body=`${d.body.trimEnd()}${m}${c}
11
+ `,{changedFields:["body"]}}});return{item:l.item,appended:c,changed_fields:l.changedFields}}function Xu(e,t,n){let o={...t.metadata,body:t.body},r={...n.metadata,body:n.body};for(let i of new Set([...Object.keys(o),...Object.keys(r)])){if(i==="updated_at"||i==="pm_format_version")continue;let s=o[i],a=r[i];if(ie(s,a))continue;let c=e.get(i);if(c&&!ie(c.after,s))throw new p(`Rollback conflict on ${i}: the batch effects contain an intervening edit. Inspect pm history before resolving it.`,u.CONFLICT);e.set(i,{field:i,before:c?c.before:s,after:a})}}function Zu(e,t,n){let o=new Map;for(let[r,i]of e.entries()){if(i.context?.bulk_checkpoint!==t)continue;let s=Po(Vo(e,r-1),{schema:n}),a=Po(Vo(e,r),{schema:n});Xu(o,s,a)}return[...o.values()].filter(r=>!ie(r.before,r.after))}function Qu(e,t){let n={...e.metadata,body:e.body},o=t.filter(r=>!ie(n[r.field],r.after));if(o.length>0)throw new p(`Rollback conflict on ${o.map(r=>r.field).join(", ")}: a later edit changed a batch field. Inspect pm get/history and reconcile it explicitly before retrying.`,u.CONFLICT);for(let r of t)r.field==="body"?e.body=r.before:r.before===void 0?delete e.metadata[r.field]:e.metadata[r.field]=structuredClone(r.before);return t.map(r=>r.field)}async function to(e,t,n){if(t.record.rollback_strategy!=="guarded_inverse")throw new p("This legacy checkpoint has no attributable inverse effects. Inspect pm history and use an explicit pm restore only after reviewing later edits.",u.CONFLICT);let o=await I(e),r=new Map,i=await fs(t.items,async a=>{try{return await ef(e,o,t,a,n)}catch(c){throw r.set(a,c),c}}),s=[];for(let a of i.rows)s.push(a.status==="failed"?{...a,...await ot(r.get(a.id),e)}:a);return{...i,rows:s}}async function ef(e,t,n,o,r){let i=await ga({pmRoot:e,settings:t,id:o,op:"restore",author:C(r.author,t.author_default),message:r.message,force:r.force,skipNoop:!0,historyContext:{bulk_rollback:n.id},async mutate(s){let a=await Is(me(e,o),o);if(!Na(a,s).ok)throw new p(`Cannot safely roll back ${o}: item/history verification failed. Inspect pm history --verify before recovery.`,u.CONFLICT);return a.some(l=>l.context?.bulk_rollback===n.id)?{changedFields:[]}:{changedFields:Qu(s,Zu(a,n.id,t.schema))}}});return{changed_fields:i.changedFields,warnings:i.warnings,skipped:i.changedFields.length===0}}var jd=2,Mr="close-many",tf=["--filter-status","--filter-type","--filter-tag","--filter-priority","--filter-sprint","--filter-release","--filter-parent","--filter-assignee","--filter-updated-before","--ids"].join(", ");function nf(e,t){return Jt(e,t,{includePagination:!1})}function of(e,t){return Jt(e,t)}function rf(e){if(e?.ids!=null&&String(e.ids).trim().length===0)throw new p("--ids requires at least one non-empty item ID",u.USAGE)}function sf(e){let t={};if(!e)return t;for(let[n,o]of Object.entries(e))o==null||typeof o=="string"&&!o.split(",").some(r=>r.trim().length>0)||(t[n]=o);return t}function af(e,t){let n=String(e??"").trim();if(n.length>0)return n;if(t)throw new p("pm close-many requires a shared close reason via --reason because governance.require_close_reason is enabled.",u.USAGE,{code:"close_reason_required",required:"Provide a shared closing summary via --reason for the whole batch.",why:"governance.require_close_reason is enabled, so every close must record why the items are done.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met"','pm close-many --ids pm-a,pm-b --reason "Superseded by redesign"'],nextSteps:["Re-run with --reason describing the shared outcome.","To stop requiring reasons, run: pm config set governance-require-close-reason --policy disabled"]})}async function cf(e,t){let n=W(t.schema),o=F(t,T()),r=await Ut(e,t.item_format,o.type_to_folder,void 0,t.schema),i=new Map,s=new Map;for(let a of r){if(typeof a.parent!="string"||a.parent.length===0||(s.set(a.id,a.parent),Ze(a.status,n)))continue;let c=i.get(a.parent);c?c.push(a.id):i.set(a.parent,[a.id])}for(let a of i.values())a.sort((c,l)=>c.localeCompare(l));return{childrenByParent:i,parentByChild:s}}function Dd(e,t,n){let o=n?.get(e);if(o!==void 0)return o;let r=0,i=t.get(e),s=[],a=new Set,c=!1;for(;i!==void 0&&!a.has(i);){let l=n?.get(i);if(l!==void 0){r+=l+1;break}a.add(i),s.push(i),r+=1,i=t.get(i)}if(i!==void 0&&a.has(i)&&(c=!0),!c){n?.set(e,r);for(let[l,d]of s.entries())n?.set(d,r-l-1)}return r}async function lf(e){let t=await yn(e.pmRoot,Mr,e.rollbackId,jd),n=e.options.message??`Rollback close-many checkpoint ${t.id}`,o=await to(e.pmRoot,t,{author:e.options.author,message:n,force:e.options.force}),r=o.rows.filter(i=>i.status==="skipped").length;return{...je({applied:o.restored_ids.length,skipped:r,failed:o.failed_count,unmatched:0}),mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm close-many --rollback ${t.id}`},restored_count:o.restored_ids.length,skipped_count:r,failed_count:o.failed_count,rows:o.rows,ids:o.restored_ids}}function df(e,t,n,o,r){return e.map(i=>{let s=(t.get(i.id)??[]).filter(c=>!n.has(c)),a=!Gd(i,o,r);return{id:i.id,title:typeof i.title=="string"?i.title:"",status:i.status,action:a?"skip":"close",...a?{skip_reason:"already_terminal"}:{},...s.length>0?{active_child_ids:s}:{}}})}async function mf(e){let t=await gn(e.pmRoot,Mr,e.checkpointId,{schema_version:jd,rollback_strategy:"guarded_inverse",id:e.checkpointId,created_at:e.nowValue,author:C(e.options.author,"unknown"),...e.reason!==void 0?{reason:e.reason}:{},filters:e.filters,items:e.checkpointItems});return{id:e.checkpointId,created_at:e.nowValue,path:t,rollback_command:`pm close-many --rollback ${e.checkpointId}`}}async function pf(e){let t=[],n=[];for(let o of e.matched){if(!e.closableIds.has(o.id)){t.push({id:o.id,status:"skipped",skip_reason:"already_terminal"});continue}try{let r=await Rn({pmRoot:e.pmRoot,itemId:o.id,checkpointId:e.checkpointId},()=>Kt(o.id,e.reason,e.closeOptions,e.global));t.push({id:o.id,status:"closed",completion:r.completion,changed_fields:r.changed_fields,...r.warnings&&r.warnings.length>0?{warnings:r.warnings}:{}}),n.push(o.id)}catch(r){let i=await Kn(r,o.id,e.pmRoot);if(i!==void 0){t.push({id:o.id,status:"closed",...i}),n.push(o.id);continue}t.push({id:o.id,status:"failed",error:Ae(r),...await ot(r,e.pmRoot)})}}return{rows:t,closedIds:n}}function uf(e){return _n(e.rollback)}function ff(e){if(e.dryRun===!0)throw new p("--dry-run cannot be combined with --rollback",u.USAGE);if(of(e.list,e.status))throw new p("Rollback mode does not accept filter options",u.USAGE)}function _f(e){if(!nf(e.list,e.status))throw new p(`close-many requires at least one filter to scope the close (for example: ${tf}). Refusing to match every item.`,u.USAGE)}function hf(e,t){let n=new Map;return[...e].sort((o,r)=>{let i=Dd(r.id,t,n)-Dd(o.id,t,n);return i!==0?i:o.id.localeCompare(r.id)})}function Gd(e,t,n){return n||!Ze(e.status,t)}function gf(e,t,n){return new Set(e.filter(o=>Gd(o,t,n)).map(o=>o.id))}async function yf(e){_f(e.options);let t=W(e.settings.schema),n=af(e.options.reason,e.settings.governance.require_close_reason),o=e.options.force===!0,r=await fe(e.options.status,sf(e.options.list),e.global),{childrenByParent:i,parentByChild:s}=await cf(e.pmRoot,e.settings),a=hf(r.items,s),c=[...new Set(String(e.options.list?.ids??"").split(",").map(f=>f.trim()).filter(f=>f.length>0))],l=c.length===0?[]:(await fe(void 0,{ids:c.join(","),noTruncate:!0,full:!0},e.global)).items,d=new Set(l.map(f=>f.id)),m=gf(a,t,o);return{pmRoot:e.pmRoot,settings:e.settings,statusRegistry:t,reason:n,validateCloseMode:e.options.validateClose,force:o,listed:r,matched:a,unmatchedIds:c.length===0?void 0:c.filter(f=>!d.has(f)),planRows:df(a,i,m,t,o)}}function bf(e){return{outcome:"effect",exit_code:u.SUCCESS,mode:"dry_run",matched_count:e.matched.length,dry_run:!0,...e.reason!==void 0?{reason:e.reason}:{},filters:e.listed.filters,...e.validateCloseMode?{validate_close:e.validateCloseMode}:{},item_plans:e.planRows,ids:[],...e.unmatchedIds!==void 0?{unmatched_ids:e.unmatchedIds,unmatched_count:e.unmatchedIds.length}:{}}}async function wf(e){if(e.options.checkpoint===!1||e.closableIds.size===0)return;let t=e.context.matched.filter(n=>e.closableIds.has(n.id)).map(n=>({id:n.id,target_updated_at:n.updated_at}));return mf({pmRoot:e.context.pmRoot,checkpointId:e.checkpointId,nowValue:e.nowValue,options:e.options,reason:e.context.reason,filters:e.context.listed.filters,checkpointItems:t})}async function Ud(e,t){let n=uf(e),o=x(process.cwd(),t.path);await P(o);let r=await I(o),i=e.dryRun===!0;if(rf(e.list),n!==void 0)return ff(e),lf({pmRoot:o,rollbackId:n,options:e,global:t});let s=await yf({pmRoot:o,settings:r,options:e,global:t});if(i)return bf(s);let a=new Set(s.planRows.filter(v=>v.action==="close").map(v=>v.id)),c=S(),l=hn(Mr,c),d=await wf({context:s,options:e,closableIds:a,checkpointId:l,nowValue:c}),m={author:e.author,message:e.message??`close-many apply ${l}`,completedAt:e.completedAt,validateClose:s.validateCloseMode,force:s.force,resolution:e.resolution,expectedResult:e.expectedResult,actualResult:e.actualResult},{rows:f,closedIds:b}=await pf({pmRoot:o,checkpointId:l,matched:s.matched,closableIds:a,reason:s.reason,closeOptions:m,global:t}),g=f.filter(v=>v.status==="closed").length,k=f.filter(v=>v.status==="skipped").length,y=f.filter(v=>v.status==="failed").length;return{...je({applied:g,skipped:k,failed:y,unmatched:s.unmatchedIds?.length??0}),mode:"apply",matched_count:s.matched.length,dry_run:!1,...s.reason!==void 0?{reason:s.reason}:{},filters:s.listed.filters,...s.validateCloseMode?{validate_close:s.validateCloseMode}:{},...d?{checkpoint:d}:{},closed_count:g,skipped_count:k,failed_count:y,rows:f,ids:b,...s.unmatchedIds!==void 0?{unmatched_ids:s.unmatchedIds,unmatched_count:s.unmatchedIds.length}:{}}}function vf(e,t){return[...new Set([...Wi.filter(o=>e[o]!==void 0),...Object.keys(e).filter(o=>e[o]!==void 0),...t.length>0?["body"]:[]])].sort((o,r)=>o.localeCompare(r))}function kf(e,t){let n=`copied_from=${e}`;if(!t)return n;let o=t.trim();return o.length>0?`${o} | ${n}`:n}async function Dr(e,t,n){let o=x(process.cwd(),n.path);await P(o);let r=await I(o),i=F(r,T()),s=await ne(o,e,r.id_prefix,r.item_format,i.type_to_folder);if(!s)throw await On(o,e,r.id_prefix,i.type_to_folder);let a=await xe(s,{schema:r.schema}),c=a.document.metadata,l=S(),d=C(t.author,r.author_default),m=await Ho(o,r.id_prefix,{tokenLength:r.ids.token_length,typeToFolder:i.type_to_folder,probeExisting:!1}),f=W(r.schema),b=t.title?.trim();if(b!==void 0&&b.length===0)throw new p("Copy --title must not be empty",u.USAGE);let g={...c,id:m,title:b??c.title,status:f.open_status,created_at:l,updated_at:l};delete g.closed_at,delete g.completed_at,delete g.close_reason,delete g.test_runs;let k=pe(T()),y=Mt({metadata:g,body:a.document.body},{schema:r.schema,extensionFieldNames:k}),v=await cr({title:y.metadata.title,description:y.metadata.description,body:y.body,excludeIds:[s.id]},{pmRoot:o,mode:r.governance.duplicate_detection_mode==="strict"&&t.allowDuplicate!==!0?"off":r.governance.duplicate_detection_mode,threshold:r.governance.duplicate_detection_threshold,limit:r.governance.duplicate_detection_limit,allowDuplicate:t.allowDuplicate}),_=vf(y.metadata,y.body),A=Oo(o,y.metadata.type,m,r.item_format,i.type_to_folder),N=me(o,m),O=await Dt(o,m,r.locks.ttl_seconds,d,!1,r.governance.force_required_for_stale_lock,r.locks.wait_ms),B={metadata:{},body:""},$,R,re;try{let Tt=await ua(o,d,{required:r.governance.duplicate_detection_mode==="strict"&&t.allowDuplicate!==!0});try{r.governance.duplicate_detection_mode==="strict"&&t.allowDuplicate!==!0&&await cr({title:y.metadata.title,description:y.metadata.description,body:y.body,excludeIds:[s.id]},{pmRoot:o,mode:"strict",threshold:r.governance.duplicate_detection_threshold,limit:r.governance.duplicate_detection_limit,allowDuplicate:!1});let te=await ne(o,m,r.id_prefix,r.item_format,i.type_to_folder);if(te)throw new p(`Cannot copy to ${m}: an item with that id already exists at ${te.itemPath}. Retry the copy to allocate a new id.`,u.CONFLICT,{code:"item_id_collision",why:`Allocated id ${m} already exists at ${te.itemPath}.`,recovery:{suggested_retry:`pm copy ${s.id}`}});let Ve=await Cn({pmRoot:o,settings:r,operation:"create",author:d,before:null,after:y});re=Ve.warnings,await An({pm_root:o,operation:"create",before:null,after:y,changed_fields:_,author:d,sdk:Tn({pmRoot:o,settings:r,typeToFolder:i.type_to_folder})}),await O.fence(async()=>{await se(A,Lt(y,{format:r.item_format,schema:r.schema,extensionFieldNames:k}));try{let Ke=jt({nowIso:l,author:d,op:"create",before:B,after:y,message:kf(s.id,t.message),context:Ve.decisions.length===0?void 0:{workflow_policies:Ve.decisions}});await Gt(N,Ke)}catch(Ke){throw await Ft(A),Ke}}),R=await fa({pmRoot:o,preferredFormat:r.item_format,typeToFolder:i.type_to_folder,schema:r.schema,itemPath:A,document:y})}finally{await Tt()}$=[...await G({path:A,scope:"project",op:"create",item_id:y.metadata.id,item_type:y.metadata.type,before:B,after:y,changed_fields:_}),...await G({path:N,scope:"project",op:"create:history",item_id:y.metadata.id,item_type:y.metadata.type,before:B,after:y,changed_fields:_})],Ws({id:y.metadata.id,op:"create",item_type:y.metadata.type,status:y.metadata.status,current:Vs(y.metadata,_),changed_fields:_})}finally{await O.release()}return{source_id:s.id,item:structuredClone(y.metadata),changed_fields:_,warnings:[...Sl(v),...re,...R,...$],...v===void 0?{}:{similarity_advisory:v}}}import no from"node:path";async function jr(e,t,n){let o=x(process.cwd(),n.path);await P(o);let r=await I(o),i=C(t.author,r.author_default),s=await ya({pmRoot:o,settings:r,id:e,author:i,message:t.message,force:t.force,dryRun:t.dryRun}),a=s.targetPath?no.relative(o,s.targetPath).split(no.sep).join("/"):void 0;return{item:s.item,changed_fields:s.changedFields,dry_run:t.dryRun===!0,deleted:t.dryRun!==!0,outcome:t.dryRun===!0?"would_delete":"deleted",previous_status:s.item.status,...a?{target_path:a}:{},history_retained:no.relative(o,me(o,s.item.id)).split(no.sep).join("/"),tombstone_retention:"retain_append_only",warnings:s.warnings}}async function Sf(e){await P(e)}async function Gr(e,t,n){let o=x(process.cwd(),n.path);if(await Sf(o),t.clear===!0){if(e!==void 0)throw new p("pm focus --clear does not take an item id. Use 'pm focus --clear' to clear focus or 'pm focus <id>' to set it.",u.USAGE);let m=await I(o),f=Fo(C(void 0,m.author_default));return await xs(o),await ur({pmRoot:o,settings:m,principal:f}),{action:"clear",focused_item:null,title:null,message:"Focus cleared. New items will not inherit a default parent."}}if(e===void 0){let m=await Ss(o);if(m===void 0)return{action:"show",focused_item:null,title:null,message:"No focus set. Use 'pm focus <id>' to set a default parent for new items."};let f=await Af(o,m);return{action:"show",focused_item:m,title:f,message:`Focused on ${m}${f?` (${f})`:""}. New items default --parent to it.`}}let i=await I(o),s=F(i,T()),a=await ne(o,e,i.id_prefix,i.item_format,s.type_to_folder);if(!a)throw await On(o,e,i.id_prefix,s.type_to_folder);let c=zo(a.id,i.id_prefix),l=await xe(a,{schema:i.schema}),d=qd(l.document.metadata.title);return await As(o,c),await ur({pmRoot:o,settings:i,principal:Fo(C(void 0,i.author_default)),itemId:c}),{action:"set",focused_item:c,title:d,message:`Focused on ${c}${d?` (${d})`:""}. New items default --parent to it (override with --parent or clear via 'pm focus --clear').`}}async function Af(e,t){let n=await I(e),o=F(n,T()),r=await ne(e,t,n.id_prefix,n.item_format,o.type_to_folder);if(!r)return null;let i=await xe(r,{schema:n.schema});return qd(i.document.metadata.title)}function qd(e){return e.trim().length>0?e:null}async function Ur(e,t,n,o){Ht(e,"reopen","id"),Ht(t,"reopen","reason"),Ic(n);let r=t.trim();if(r.length===0)throw new p("pm item reopen requires a non-empty recurrence reason.",u.USAGE,{code:"reopen_reason_required",required:"Describe why the terminal work became active again.",recovery:{suggested_retry:`pm item reopen ${e} "<recurrence reason>"`,suggested_retry_args:["item","reopen",e,"<recurrence reason>"]}});let i=x(process.cwd(),o.path),s=n.expectedResult?.trim();if(s!==void 0&&s.length===0)throw new p("Reopen expected result must describe the current active outcome.",u.USAGE);let a=W((await I(i)).schema),c=a.open_status,l=Yl(a),d=n.status??c,m=Ne(d,a)??d;if(m!==c&&m!==l)throw new p(`Reopen target status must be ${c} or ${l}; received ${d}.`,u.USAGE,{code:"reopen_target_status_invalid",required:"Choose the workspace open or in-progress lifecycle status.",recovery:{allowed_values:[...new Set([c,l])],suggested_retry:`pm item reopen ${e} "${r}" --status ${c}`,suggested_retry_args:["item","reopen",e,r,"--status",c]}});let f=await Ql(e,{status:m,expectedResult:s,unset:["close-reason","resolution",...s===void 0?["expected-result"]:[],"actual-result","fixed-version"],author:n.author,message:n.message,force:n.force},o,r);return{item:f.item,changed_fields:f.changed_fields,warnings:f.warnings,recurrence:f.lifecycle_transition,...s===void 0?{recovery:{missing:["expected_result"],suggested_retry_args:["--pm-path",i,"update",e,"--expected-result","<current expected outcome>"],suggested_retry:fn(["--pm-path",i,"update",e,"--expected-result","<current expected outcome>"])}}:{}}}async function zd(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options),r=e.force===!0||o.force===!0,i={...e.args,...o},s=o.next===!0,a=e.id??h(o,"id");if(i.start===!0){if(a)return ze(e,"start_task");od(a,s,!0)}let c=s?await rd(r,e.global,i,i):await nd(Qt(e,o),r,e.global,i);return H(c,{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function Qt(e,t){let n=e.id??h(t,"id");if(!n)throw new p("Missing required argument: id",64);return n}function qr(e,t){return h(e.args,"reason")??h(e.args,"text")??h(t,"reason")??h(t,"text")}async function Hd(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options);return o.releaseAssignment===!0?ze(e,"close_task"):H(await Kt(Qt(e,o),qr(e,o),{...o,force:e.force===!0||o.force===!0},e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function ze(e,t){let{changedFields:n,idOnly:o,runnerOptions:r}=j(e.args,e.options),i=Qt(e,r),s=st(r,{force:e.force===!0||r.force===!0}),a=t==="start_task"?await yr(i,s,e.global):t==="pause_task"?await br(i,s,e.global):await wr(i,qr(e,r),s,e.global);return H(a,{changedFields:n,idOnly:o,compactEnvelope:n==="compact"&&!o})}async function Bd(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options),r=st(o,{message:h(Object.hasOwn(o,"message")?o:e.args,"message")});if(r.pause===!0)return ze({...e,options:r},"pause_task");let i=await id(Qt(e,r),e.force===!0||r.force===!0,e.global,r);return H(i,{changedFields:t,idOnly:n,compactEnvelope:t==="compact"&&!n})}async function Wd(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options);return H(await Ur(Qt(e,o),qr(e,o)??"",{...o,force:e.force===!0||o.force===!0},e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function oo(e,t){let n=fn(["plan","show",e.plan.id,"--depth","deep",...t===void 0?[]:["--pm-path",t]]);return{kind:"plan_mutation",action:e.action,id:e.plan.id,status:e.plan.status,mode:e.plan.mode,steps_summary:e.plan.steps_summary,...e.step===void 0?{}:{step:{id:e.step.id,order:e.step.order,status:e.step.status}},materialized_count:e.materialized?.length??0,skipped_count:e.materialize_skipped?.length??0,warning_count:e.warnings.length,warnings:e.warnings.slice(0,3).map(o=>o.slice(0,160)),warnings_truncated:e.warnings.length>3||e.warnings.some(o=>o.length>160),next_action:e.next_actions?.[0]===void 0?n:t===void 0?e.next_actions[0]:`${e.next_actions[0]} --pm-path ${as(t)}`,inspection_command:n,omission_receipt:{has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"plan_detail",restore_with:n}]}}}var xf=["create","show","add-step","update-step","complete-step","block-step","reorder-step","remove-step","link","unlink","decision","discovery","validation","resume","approve","materialize"];var Jd="plan-step-",Kr="draft",Vr=["bug-investigation","feature-implementation","refactoring-sprint"],Vd={"bug-investigation":[{title:"Reproduce the bug",body:"Capture exact steps, inputs, and the observed vs expected behavior."},{title:"Locate the root cause",body:"Trace the failure to the responsible code path with evidence."},{title:"Write a failing test",body:"Add a regression test that fails for the current bug."},{title:"Implement the fix",body:"Apply the minimal change that makes the failing test pass."},{title:"Verify and document",body:"Run the full suite and record the resolution and verification."}],"feature-implementation":[{title:"Clarify requirements & acceptance criteria",body:"Confirm scope, edge cases, and done-conditions."},{title:"Design the approach",body:"Decide the data model, interfaces, and integration points."},{title:"Implement the change",body:"Build the feature behind the agreed design."},{title:"Add tests",body:"Cover the new behavior and its edge cases."},{title:"Update docs & changelog",body:"Document the feature and surface it to users."}],"refactoring-sprint":[{title:"Map the current structure & risks",body:"Inventory the code to change and its blast radius."},{title:"Add characterization tests",body:"Lock in current behavior before refactoring."},{title:"Refactor incrementally",body:"Apply small, reversible steps keeping tests green."},{title:"Verify behavior is unchanged",body:"Run the full suite and compare against the baseline."},{title:"Clean up & document",body:"Remove dead code and record the new structure."}]};function If(e){let t=e.trim().toLowerCase(),n=Object.prototype.hasOwnProperty.call(Vd,t)?Vd[t]:void 0;if(!n)throw new p(`Unknown plan template "${e}". Allowed: ${Vr.join(", ")}`,u.USAGE,{code:"unknown_plan_template",examples:[`pm plan create --title "Fix login crash" --template ${Vr[0]}`]});return n.map(o=>({...o}))}function Ef(e,t){return t>0?Math.round(e/t*100):0}function Yd(e){return(Array.isArray(e)?e:e==null?[]:[e]).filter(n=>n!=null).map(n=>(typeof n=="string"?n:String(n)).trim()).filter(n=>n.length>0)}function ee(e){return Array.isArray(e)?e.flatMap(t=>Qo(t,{unique:!1})):typeof e=="string"&&e.trim().length>0?Qo(e,{unique:!1}):[]}function V(e){return Array.isArray(e)?e.map(t=>t.trim()).filter(Boolean):typeof e=="string"&&e.trim().length>0?[e.trim()]:[]}function Xd(e,t=Kr){if(e===void 0)return t;let n=e.trim().toLowerCase(),o=Eo.find(r=>r===n);if(!o)throw new p(`Invalid plan mode "${e}". Allowed: ${Eo.join(", ")}`,u.USAGE);return o}function Jr(e,t="pending"){if(e===void 0)return t;let n=e.trim().toLowerCase(),o=Co.find(r=>r===n);if(!o)throw new p(`Invalid step status "${e}". Allowed: ${Co.join(", ")}`,u.USAGE);return o}function Zd(e,t="related"){if(e===void 0)return t;let n=e.trim().toLowerCase(),o=To.find(r=>r===n);if(!o)throw new p(`Invalid step link kind "${e}". Allowed: ${To.join(", ")}`,u.USAGE);return o}function Cf(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(t.length===0)return;let n=Ro.find(o=>o===t);if(!n)throw new p(`Invalid plan harness "${e}". Allowed: ${Ro.join(", ")}`,u.USAGE);return n}function Rf(e){if(e===void 0)return"brief";let t=e.trim().toLowerCase(),n=tr.find(o=>o===t);if(!n)throw new p(`Invalid --depth "${e}". Allowed: ${tr.join(", ")}`,u.USAGE);return n}function Tf(e){if(e===void 0)return null;let t=e.split(",").map(n=>n.trim()).filter(n=>n.length>0);if(t.length===0)throw new p("Plan --fields requires a comma-separated list of plan field names",u.USAGE);return t}var zr=new Set(["id","title","status","mode","scope","harness","parent","resume_context","steps_summary","current_step","blocked_steps","steps","decisions","discoveries","validation","linked_items"]);function Of(e,t){let n=e,o={},r=[];for(let i of t){let s=i.startsWith("plan.")?i.slice(5):i;if(s.length!==0){if(!zr.has(s)){r.push(i);continue}Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])}}if(r.length>0)throw new p(`Unknown Plan --fields value(s): ${r.join(", ")}`,u.USAGE,{nextSteps:[`Use --fields ${[...zr].join(",")}`,"Run pm plan show <id> --depth brief for compact default fields."],recovery:{provided_fields:r,suggested_retry:`pm plan show <id> --fields ${[...zr].join(",")}`}});return o}function Yr(e,t){let n={};for(let o of e.split(",")){let r=o.trim();if(r.length===0)continue;let i=r.indexOf("=");if(i<=0)throw new p(`Invalid ${t} entry "${r}"; expected key=value`,u.USAGE,{code:"malformed_plan_step_evidence",required:`${t} entries must use comma-separated key=value fields.`,why:"Structured Plan evidence must be validated before it is persisted.",examples:['--file "path=src/index.ts,scope=project,note=implementation"','--test "command=pnpm test,note=regression"','--doc "path=docs/PLAN.md,scope=project"']});n[r.slice(0,i).trim().toLowerCase()]=r.slice(i+1).trim()}return n}function Xr(e){let t=Yr(e,"--file");if(!t.path)throw new p("--file requires path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--file requires a non-empty path field.",why:"Plan file evidence needs a stable path for later verification."});let n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function Zr(e){let t=Yr(e,"--test");if(!t.command&&!t.path)throw new p("--test requires at least command=<value> or path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--test requires a command or path field.",why:"Plan test evidence must identify something runnable or inspectable."});let n={};return t.command&&(n.command=t.command),t.path&&(n.path=t.path),t.note&&(n.note=t.note),n}function Qr(e){let t=Yr(e,"--doc");if(!t.path)throw new p("--doc requires path=<value>",u.USAGE,{code:"malformed_plan_step_evidence",required:"--doc requires a non-empty path field.",why:"Plan documentation evidence needs a stable path for later verification."});let n={path:t.path};return(t.scope==="global"||t.scope==="project")&&(n.scope=t.scope),t.note&&(n.note=t.note),n}function $f(e){let t={total:e.length,pending:0,in_progress:0,blocked:0,completed:0,skipped:0,superseded:0,completion_pct:0};for(let n of e)t[n.status]+=1;return t.completion_pct=Ef(t.completed,t.total),t}function Ff(e){let t=new Set(e.map(n=>n.id));for(let n=e.length+1;n<e.length+1024;n+=1){let o=`${Jd}${String(n).padStart(3,"0")}`;if(!t.has(o))return o}throw new p("Could not allocate step id (limit reached)",u.GENERIC_FAILURE)}function dt(e,t){let n=t.trim();if(n.length===0)throw new p("Step reference cannot be empty",u.USAGE);let o=e.find(r=>r.id===n);if(o)return o;if(/^\d+$/.test(n)){let r=Number.parseInt(n,10),i=e.find(s=>s.order===r);if(i)return i}throw new p(`Step "${t}" not found in plan`,u.NOT_FOUND)}function Kd(e){if(e.status==="completed")return{reason:"already_completed"};let t=(e.linked_items??[]).find(n=>n.kind==="implements");if(t)return{reason:"already_materialized",existing_id:t.id}}function Pf(e,t){let n=t.filter(s=>s.trim().toLowerCase()==="all"),o=[],r=[];if(n.length>0){if(t.length>n.length)throw new p("pm plan materialize --steps all cannot be combined with other step refs",u.USAGE);for(let s of e.slice().sort((a,c)=>a.order-c.order)){let a=Kd(s);if(a){r.push({from_step:s.id,...a});continue}o.push(s)}return{targets:o,skipped:r}}let i=new Set;for(let s of t){let a=dt(e,s);if(i.has(a.id))continue;i.add(a.id);let c=Kd(a);if(c){r.push({from_step:a.id,...c});continue}o.push(a)}return{targets:o,skipped:r}}function Nf(e,t){let n=e==="decision"?t.decisionText:e==="discovery"?t.discoveryText:t.validationText,o=e==="decision"?t.decision:e==="discovery"?t.discovery:t.validation;return n?.trim()||o?.trim()||void 0}function Lf(e){return e.find(t=>t.status==="in_progress")??e.find(t=>t.status==="pending")}function Mf(e){return e.filter(t=>t.status==="blocked").map(t=>({id:t.id,order:t.order,title:t.title,blocked_reason:t.blocked_reason}))}function X(e,t="brief"){let n=(e.plan_steps??[]).slice().sort((s,a)=>s.order-a.order),o=$f(n),r=Lf(n),i={id:e.id,title:e.title,status:e.status,mode:e.plan_mode??Kr,scope:e.plan_scope,harness:e.plan_harness,parent:e.parent,resume_context:e.plan_resume_context,steps_summary:o,current_step:r?{id:r.id,order:r.order,title:r.title,status:r.status}:void 0,blocked_steps:Mf(n),linked_items:(e.dependencies??[]).map(s=>({id:s.id,kind:s.kind}))};return(t==="standard"||t==="deep")&&(i.steps=n),t==="deep"&&(i.decisions=e.plan_decisions??[],i.discoveries=e.plan_discoveries??[],i.validation=e.plan_validation??[]),i}function Z(e,t){let n=[];return t.steps_summary.total===0&&n.push(`pm plan add-step ${e} --step-title "First step"`),t.current_step&&n.push(`pm plan update-step ${e} ${t.current_step.id} --step-status in_progress`,`pm plan complete-step ${e} ${t.current_step.id} --step-evidence "..."`),t.steps_summary.blocked>0&&n.push(`pm plan show ${e} --depth standard`),(t.mode==="draft"||t.mode==="research")&&n.push(`pm plan approve ${e} --message "ready to execute"`),t.steps_summary.completed===t.steps_summary.total&&t.steps_summary.total>0&&!er(t.mode)&&t.status!=="closed"&&t.status!=="canceled"&&n.push(`pm close ${e} "plan complete"`),n}function Qd(e){if((e.type??"").trim().toLowerCase()!=="plan")throw new p(`Item ${e.id} is type ${e.type}; pm plan commands require type=Plan. Use pm plan create or pm create --type Plan first.`,u.USAGE,{code:"wrong_item_type",required:"Use pm plan commands only with items whose type is Plan.",why:"Plan commands read and mutate Plan-specific step, decision, discovery, and validation fields.",examples:[`pm get ${e.id} --depth brief`,'pm plan create --title "Execution plan" --scope "<goal>"']})}async function Df(e){let t=x(process.cwd(),e.path);await P(t);let n=await I(t);return{pmRoot:t,settings:n}}async function em(e,t){let n=F(e.settings,T()),o=await ne(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,n.type_to_folder);if(!o)throw new p(`Plan ${t} not found`,u.NOT_FOUND);let r=await xe(o,{schema:e.settings.schema});return Qd(r.document.metadata),{document:r.document,itemId:o.id}}function jf(e){let t=[];for(let n of ee(e.related))t.push(`id=${n},kind=related`);for(let n of ee(e.blocks))t.push(`id=${n},kind=blocks`);for(let n of ee(e.blockedBy))t.push(`id=${n},kind=blocked_by`);return t.length>0?t:void 0}function Gf(e){let t=e.validationText?.trim(),n=e.validationCommand?.trim(),o=e.validationExpected?.trim();if(!(!t&&!n&&!o))return{text:t||n||"Validation check",command:n||void 0,expected:o||void 0}}function Uf(e){return!!e.stepBody?.trim()||!!e.stepOwner?.trim()||!!e.stepStatus?.trim()||!!e.stepEvidence?.trim()||!!e.stepBlockedReason?.trim()||!!e.stepReplacement?.trim()||ee(e.dependsOn).length>0||ee(e.link).length>0}function qf(e){let t=e.stepTitle?.trim()||void 0,n=Yd(e.step),o=e.template?.trim()?If(e.template):[];return{repeatedStepTitles:n,stepTitleFlag:t,stepTitles:[...t?[t]:[],...n,...o.map(r=>r.title)],templateSteps:o}}function zf(e,t){if((e.stepTitleFlag||e.repeatedStepTitles.length>0)&&e.templateSteps.length>0)throw new p("pm plan create --template cannot be combined with --step-title or --step; choose one step seeding source",u.USAGE,{code:"ambiguous_option_combination",examples:[`pm plan create --title "Fix login crash" --template ${Vr[0]}`,'pm plan create --title "Custom plan" --step "Read the code" --step "Write the fix"']});if(e.stepTitles.length>1&&t)throw new p("pm plan create per-step options apply to a single initial step; with multiple --step values create the plan first, then refine steps individually",u.USAGE,{code:"ambiguous_option_combination",examples:['pm plan create --title "Execution plan" --step "Read the code" --step "Write the fix"','pm plan update-step <plan-id> plan-step-001 --step-body "Inspect retry path"']})}function Hf(e,t){let n=Jr(e.stepStatus,"pending"),o=ei(e,"depends_on"),r=V(e.file).map(Xr),i=V(e.test).map(Zr),s=V(e.doc).map(Qr),a=S();return{id:"plan-step-001",order:1,title:t,body:e.stepBody?.trim()||void 0,status:n,owner:ti(e.stepOwner),evidence:e.stepEvidence?.trim()||void 0,blocked_reason:n==="blocked"?e.stepBlockedReason?.trim()||"":void 0,linked_items:o.length>0?o:void 0,files:r.length>0?r:void 0,tests:i.length>0?i:void 0,docs:s.length>0?s:void 0,created_at:a,updated_at:a,completed_at:n==="completed"?a:void 0}}function Bf(e){let t=qf(e),n=Uf(e);if(zf(t,n),t.stepTitles.length===0)return{steps:[],hasPerStepDetailOptions:n};if(t.stepTitles.length===1)return{steps:[Hf(e,t.stepTitles[0])],hasPerStepDetailOptions:n};let o=S();return{steps:t.stepTitles.map((r,i)=>({id:`${Jd}${String(i+1).padStart(3,"0")}`,order:i+1,title:r,body:t.templateSteps[i]?.body,status:"pending",created_at:o,updated_at:o})),hasPerStepDetailOptions:n}}function tm(e,t,n=[]){le(e,t),n.length>0&&os(t,n)}async function Wf(e,t,n){let o=e.title?.trim();if(!o)throw new p("pm plan create requires --title",u.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Refactor lock retry" --scope pm-a1b2']});let r=Xd(e.mode,Kr),i=Cf(e.harness),s=e.fromSearch?.trim(),a=Gf(e),{steps:c,hasPerStepDetailOptions:l}=Bf(e);if(c.length===0&&l)throw new p("pm plan create step options require --step-title (or a single --step)",u.USAGE,{code:"missing_required_option",examples:['pm plan create --title "Execution plan" --step-title "Read the code"']});let d=e.description?.trim()??e.scope?.trim()??o,m=e.claim?C(e.author,n.settings.author_default):e.assignee?.trim()||void 0,f={...e,title:o,description:d,type:"Plan",template:void 0,file:V(e.file),test:V(e.test),doc:V(e.doc),field:V(e.field),assignee:C(e.author,n.settings.author_default),blockedBy:void 0,dep:jf(e),message:e.message??(s?`plan create (search: ${s})`:"plan create")};tm(e,f);let b=await Ce(f,t),g=await qt({pmRoot:n.pmRoot,settings:n.settings,id:b.item.id,op:"plan_create_metadata",author:C(e.author,n.settings.author_default),message:"seed plan metadata",mutate(y){let v=["plan_mode"];y.metadata.plan_mode=r,i&&(y.metadata.plan_harness=i,v.push("plan_harness"));let _=e.scope?.trim();_&&(y.metadata.plan_scope=_,v.push("plan_scope"));let A=e.resumeContext?.trim();return A&&(y.metadata.plan_resume_context=A,v.push("plan_resume_context")),y.metadata.plan_steps=c,v.push("plan_steps"),a&&(y.metadata.plan_validation=[...y.metadata.plan_validation??[],a],v.push("plan_validation")),m&&(y.metadata.assignee=m,v.push("assignee")),{changedFields:v}}}),k=X(g.item,"brief");return{action:"create",plan:k,step:c[0],next_actions:Z(b.item.id,k),warnings:[...b.warnings],generated_at:S()}}async function Vf(e,t,n){let o=Rf(t.depth),r=Tf(t.fields),{document:i,itemId:s}=await em(n,e),a=X(i.metadata,r===null?o:"deep");return{action:"show",plan:r===null?a:Of(a,r),next_actions:Z(s,a),warnings:[],generated_at:S()}}function Kf(e,t){let n=new Map(Object.entries(t).filter(([o])=>o.startsWith("plan_")).map(([o,r])=>[o,JSON.stringify(r)]));return[...new Set([...e.keys(),...n.keys()])].filter(o=>e.get(o)!==n.get(o))}async function ce(e){let t=C(e.options.author,e.ctx.settings.author_default),n,o=await qt({pmRoot:e.ctx.pmRoot,settings:e.ctx.settings,id:e.id,op:e.op,author:t,message:e.options.message??e.message,force:e.options.force,mutate(r){Qd(r.metadata);let i=W(e.ctx.settings.schema);if(Ze(r.metadata.status,i)||er(r.metadata.plan_mode))throw new p(`Plan ${r.metadata.id} is terminal (status=${r.metadata.status}, plan_mode=${r.metadata.plan_mode??"unset"}) and cannot be mutated.`,u.CONFLICT,{code:"terminal_plan_mutation",required:"Create or reopen a non-terminal Plan before changing its execution context or steps.",why:"Terminal Plan history is immutable execution evidence."});let s=(r.metadata.plan_steps??[]).slice(),a=new Map(Object.entries(r.metadata).filter(([m])=>m.startsWith("plan_")).map(([m,f])=>[m,JSON.stringify(f)])),c=e.mutator(s,r);n=c.resultStep;let l=s.slice().sort((m,f)=>m.order-f.order).map((m,f)=>({...m,order:f+1}));r.metadata.plan_steps=l;let d=Kf(a,r.metadata);return d.length===0&&c.changedSteps.length===0?{changedFields:[]}:{changedFields:d.length>0?d:["plan_steps"]}}});return{document:{metadata:o.item,body:o.body},resultStep:n,itemId:o.item.id}}async function Jf(e,t,n){let o=t.stepTitle?.trim();if(!o)throw new p("pm plan add-step requires --step-title",u.USAGE);let r=Jr(t.stepStatus,"pending"),i=t.allowMultipleActive===!0,{document:s,resultStep:a,itemId:c}=await ce({id:e,options:t,ctx:n,op:"plan_add_step",message:`plan add-step "${o}"`,mutator(d){let m=d.length+1;nm(d,void 0,r,i);let f=Yf(d,t,{order:m,title:o,status:r});return d.push(f),{changedSteps:[f.id],resultStep:f}}}),l=X(s.metadata,"standard");return{action:"add-step",plan:l,step:a,next_actions:Z(c,l),warnings:[],generated_at:S()}}function nm(e,t,n,o){if(n!=="in_progress"||o)return;let r=e.find(i=>i.id!==t&&i.status==="in_progress");if(r)throw new p(`Plan already has step ${r.id} in_progress. Pass --allow-multiple-active or update that step first.`,u.CONFLICT)}function Yf(e,t,n){let o=ei(t,"depends_on"),r=V(t.file).map(Xr),i=V(t.test).map(Zr),s=V(t.doc).map(Qr),a=S();return{id:Ff(e),order:n.order,title:n.title,body:t.stepBody?.trim()||void 0,status:n.status,owner:ti(t.stepOwner),evidence:t.stepEvidence?.trim()||void 0,blocked_reason:n.status==="blocked"?t.stepBlockedReason?.trim()||"":void 0,linked_items:o.length>0?o:void 0,files:r.length>0?r:void 0,tests:i.length>0?i:void 0,docs:s.length>0?s:void 0,created_at:a,updated_at:a,completed_at:n.status==="completed"?a:void 0}}function ei(e,t){let n=ee(e.dependsOn).map(d=>({id:d,kind:t})),o=ee(e.related).map(d=>({id:d,kind:"related"})),r=ee(e.blocks).map(d=>({id:d,kind:"blocks"})),i=ee(e.blockedBy).map(d=>({id:d,kind:"blocked_by"})),s=ee(e.link),a=Zd(e.linkKind,t),c=e.linkNote?.trim(),l=s.map(d=>{let m={id:d,kind:a};return c&&(m.note=c),m});return[...n,...o,...r,...i,...l]}async function Hr(e,t,n,o){let{document:r,resultStep:i,itemId:s}=await ce({id:e,options:t,ctx:n,op:o.op,message:t.message??`${o.op} ${o.stepRef}`,mutator(c,l){let d=dt(c,o.stepRef),m=S(),f=o.finalStatus??Jr(t.stepStatus,d.status),b=t.allowMultipleActive===!0||o.allowMultipleActive===!0;return nm(c,d.status==="in_progress"?d.id:void 0,f,b),Xf(d,t,f,m),l.metadata.updated_at=m,{changedSteps:[d.id],resultStep:d}}}),a=X(r.metadata,"standard");return{action:o.op==="plan_complete_step"?"complete-step":o.op==="plan_block_step"?"block-step":"update-step",plan:a,step:i,next_actions:Z(s,a),warnings:[],generated_at:S()}}function ti(e){return cs(e?.trim(),"--step-owner")||void 0}function Xf(e,t,n,o){Zf(e,t,n),Qf(e,t),e.status=n,e.updated_at=o,e_(e,n,o)}function Zf(e,t,n){if(!(n!=="blocked"||t.stepBlockedReason?.trim()||e.blocked_reason))throw new p("Blocking a step requires --step-blocked-reason or an already-recorded blocked_reason.",u.USAGE)}function Qf(e,t){let n=t.stepTitle?.trim();n&&(e.title=n),t.stepBody!==void 0&&(e.body=t.stepBody.trim()||void 0),t.stepOwner!==void 0&&(e.owner=ti(t.stepOwner)),t.stepEvidence!==void 0&&(e.evidence=t.stepEvidence.trim()||void 0),t.stepBlockedReason!==void 0&&(e.blocked_reason=t.stepBlockedReason.trim()||void 0),t.stepReplacement!==void 0&&(e.superseded_by=t.stepReplacement.trim()||void 0);let o=V(t.file).map(Xr),r=V(t.test).map(Zr),i=V(t.doc).map(Qr);o.length>0&&(e.files=Br(e.files,o)),r.length>0&&(e.tests=Br(e.tests,r)),i.length>0&&(e.docs=Br(e.docs,i))}function Br(e,t){let n=[...e??[]],o=new Set(n.map(r=>JSON.stringify(r)));for(let r of t){let i=JSON.stringify(r);o.has(i)||(o.add(i),n.push(r))}return n}function e_(e,t,n){if(t==="completed"&&!e.completed_at){e.completed_at=n;return}t!=="completed"&&(e.completed_at=void 0)}async function t_(e,t,n,o,r){let{document:i,itemId:s,resultStep:a}=await ce({id:e,options:t,ctx:n,op:"plan_reorder_step",message:t.message??`plan reorder-step ${o} -> ${r}`,mutator(l){let d=dt(l,o),m=l.filter(b=>b.id!==d.id),f=Math.max(1,Math.min(r,m.length+1));return m.splice(f-1,0,d),m.forEach((b,g)=>{b.order=g+1,b.updated_at=S()}),l.length=0,l.push(...m),{changedSteps:[d.id],resultStep:d}}}),c=X(i.metadata,"standard");return{action:"reorder-step",plan:c,step:a,next_actions:Z(s,c),warnings:[],generated_at:S()}}async function n_(e,t,n,o){let{document:r,itemId:i,resultStep:s}=await ce({id:e,options:t,ctx:n,op:"plan_remove_step",message:t.message??`plan remove-step ${o}`,mutator(c){let l=dt(c,o),d=c.filter(m=>m.id!==l.id);return d.forEach((m,f)=>{m.order=f+1}),c.length=0,c.push(...d),{changedSteps:[l.id],resultStep:l}}}),a=X(r.metadata,"standard");return{action:"remove-step",plan:a,step:s,next_actions:Z(i,a),warnings:[],generated_at:S()}}async function o_(e,t,n,o){let r=ei(t,Zd(t.linkKind,"related"));if(r.length===0)throw new p("pm plan link requires at least one --link/--related/--blocks/--blocked-by/--depends-on id",u.USAGE);let i=t.promoteToItemDep===!0,{document:s,itemId:a,resultStep:c}=await ce({id:e,options:t,ctx:n,op:"plan_link_step",message:t.message??`plan link ${o}`,mutator(d,m){let f=dt(d,o),b=f.linked_items??[],g=y=>`${y.kind}:${y.id}`,k=new Set(b.map(g));for(let y of r){let v=g(y);k.has(v)||(b.push(y),k.add(v))}if(f.linked_items=b,f.updated_at=S(),i){let y=m.metadata.dependencies??[],v=A=>`${A.kind}:${A.id}`,_=new Set(y.map(v));for(let A of r){let N=A.kind==="depends_on"?"blocked_by":A.kind,O={id:A.id,kind:N,created_at:S(),author:C(t.author,n.settings.author_default)};_.has(v(O))||(y.push(O),_.add(v(O)))}m.metadata.dependencies=y}return{changedSteps:[f.id],resultStep:f}}}),l=X(s.metadata,"standard");return{action:"link",plan:l,step:c,next_actions:Z(a,l),warnings:[],generated_at:S()}}async function r_(e,t,n,o){let r=ee(t.link);if(r.length===0)throw new p("pm plan unlink requires --link <id> to remove",u.USAGE);let{document:i,itemId:s,resultStep:a}=await ce({id:e,options:t,ctx:n,op:"plan_unlink_step",message:t.message??`plan unlink ${o}`,mutator(l){let d=dt(l,o),m=(d.linked_items??[]).filter(f=>!r.includes(f.id));return d.linked_items=m.length>0?m:void 0,d.updated_at=S(),{changedSteps:[d.id],resultStep:d}}}),c=X(i.metadata,"standard");return{action:"unlink",plan:c,step:a,next_actions:Z(s,c),warnings:[],generated_at:S()}}async function Wr(e,t,n,o){let r=Nf(o,t);if(!r){let l=`--${o}-text`,d=`--${o}`;throw new p(`pm plan ${o} requires ${l}`,u.USAGE,{code:"missing_required_option",examples:[`pm plan ${o} <plan-id> ${l} "..."`,`pm plan ${o} <plan-id> ${d} "..."`],recovery:{suggested_retry:`pm plan ${o} <plan-id> ${l} <value>`}})}let i=C(t.author,n.settings.author_default),{document:s,itemId:a}=await ce({id:e,options:t,ctx:n,op:`plan_append_${o}`,message:t.message??`plan ${o} append`,mutator(l,d){let m=S();if(o==="decision"){let b=d.metadata.plan_decisions??[];return b.push({ts:m,author:i,decision:r,rationale:t.decisionRationale?.trim()||void 0,evidence:t.decisionEvidence?.trim()||void 0}),d.metadata.plan_decisions=b,{changedSteps:[]}}if(o==="discovery"){let b=d.metadata.plan_discoveries??[];return b.push({ts:m,author:i,text:r}),d.metadata.plan_discoveries=b,{changedSteps:[]}}let f=d.metadata.plan_validation??[];return f.push({text:r,command:t.validationCommand?.trim()||void 0,expected:t.validationExpected?.trim()||void 0}),d.metadata.plan_validation=f,{changedSteps:[]}}}),c=X(s.metadata,"deep");return{action:o,plan:c,next_actions:Z(a,c),warnings:[],generated_at:S()}}async function i_(e,t,n){let o=t.resumeContext?.trim();if(!o)throw new p("pm plan resume requires --resume-context <text>",u.USAGE);let{document:r,itemId:i}=await ce({id:e,options:t,ctx:n,op:"plan_resume",message:t.message??"plan resume context update",mutator(a,c){c.metadata.plan_resume_context=o;let l=t.scope?.trim();return l&&(c.metadata.plan_scope=l),{changedSteps:[]}}}),s=X(r.metadata,"brief");return{action:"resume",plan:s,next_actions:Z(i,s),warnings:[],generated_at:S()}}async function s_(e,t,n){let o=Xd(t.mode??"approved","approved"),{document:r,itemId:i}=await ce({id:e,options:t,ctx:n,op:"plan_approve",message:t.message??`plan approve mode=${o}`,mutator(a,c){c.metadata.plan_mode=o;let l=t.scope?.trim();return l&&(c.metadata.plan_scope=l),{changedSteps:[]}}}),s=X(r.metadata,"brief");return{action:"approve",plan:s,next_actions:Z(i,s),warnings:[],generated_at:S()}}function om(e){return e.map(t=>`plan_materialize_skipped:${t.from_step}:${t.reason}${t.existing_id?`:${t.existing_id}`:""}`)}function a_(e,t){let n=X(e.document.metadata,"standard");return{action:"materialize",plan:n,materialized:[],materialize_skipped:t,next_actions:Z(e.itemId,n),warnings:om(t),generated_at:S()}}function c_(e,t,n){let o=[`id=${e},kind=parent`,`id=${t},kind=discovered_from`];for(let r of n.linked_items??[]){let i=r.kind==="blocked_by"||r.kind==="blocks"||r.kind==="related"||r.kind==="discovered_from"?r.kind:"related";o.push(`id=${r.id},kind=${i}`)}return o}async function l_(e){let t=[],n={},o=new Set(["title","description","type","parent","tags","author","message","dep"]);for(let r of V(e.options.field)){let i=r.indexOf("=");if(i<=0)throw new p(`Invalid --field entry "${r}"; expected name=value`,u.USAGE);let s=r.slice(0,i).trim(),a=r.slice(i+1).trim();if(s.length===0)throw new p(`Invalid --field entry "${r}"; expected name=value`,u.USAGE);let c=s.trim().replaceAll(/([a-z0-9])([A-Z])/g,"$1 $2").replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(Boolean).map(f=>f.toLowerCase());if(c.length===0)throw new p(`Invalid --field entry "${r}"; expected name=value`,u.USAGE);let[l,...d]=c,m=`${l}${d.map(f=>`${f.slice(0,1).toUpperCase()}${f.slice(1)}`).join("")}`;if(o.has(m))throw new p(`Invalid --field entry "${r}"; "${m}" is reserved by materialize and cannot be overridden`,u.USAGE);n[m]=a}for(let r of e.targets){let i={...n,title:r.title,description:r.body?.trim()||r.title,type:e.resolvedTypeName,parent:e.parent,tags:e.tags,author:e.options.author,message:e.options.message??`materialized from plan ${e.planItemId} step ${r.id}`,dep:c_(e.parent,e.planItemId,r)};tm(e.options,i,["description",...Object.keys(n)]);let s=await Ce(i,{path:e.pmRoot});t.push({id:s.item.id,title:s.item.title,type:e.resolvedTypeName,parent:s.item.parent,tags:s.item.tags??[],from_step:r.id})}return t}function d_(e,t,n){for(let o of t){let r=n.find(a=>a.from_step===o.id);if(!r)continue;let i=e.find(a=>a.id===o.id);if(!i)continue;let s=i.linked_items??[];s.push({id:r.id,kind:"implements",note:`materialized as ${r.type}`}),i.linked_items=s,i.updated_at=S()}}async function m_(e,t,n){let o=ee(t.steps);if(o.length===0)throw new p("pm plan materialize requires --steps <ids|orders|all>",u.USAGE);let r=t.materializeType?.trim()||"Task",i=F(n.settings,T()),s=un(r,i);if(!s)throw new p(`Invalid --materialize-type "${r}"`,u.USAGE);let a=t.materializeParent?.trim()||e,c=t.materializeTags,l=await em(n,e),d=(l.document.metadata.plan_steps??[]).slice(),{targets:m,skipped:f}=Pf(d,o);if(m.length===0){if(f.length>0)return a_(l,f);throw new p("No matching plan steps found for --steps",u.NOT_FOUND)}let b=await l_({targets:m,parent:a,planItemId:l.itemId,resolvedTypeName:s,tags:c,options:t,pmRoot:n.pmRoot}),{document:g,itemId:k}=await ce({id:e,options:t,ctx:n,op:"plan_materialize",message:t.message??`plan materialize ${o.join(",")}`,mutator(v){return d_(v,m,b),{changedSteps:m.map(_=>_.id)}}}),y=X(g.metadata,"standard");return{action:"materialize",plan:y,materialized:b,...f.length>0?{materialize_skipped:f}:{},next_actions:Z(k,y),warnings:om(f),generated_at:S()}}function p_(e){if(e.subcommand==="create")return e;let t=Yd(e.options.step);if(t.length>1)throw new p(`pm plan ${e.subcommand} accepts a single --step/--step-title value (repeated --step seeds ordered steps only on pm plan create)`,u.USAGE);return t.length===1&&!e.options.stepTitle?.trim()?{...e,options:le(e.options,{...e.options,stepTitle:t[0]})}:e}function ge(e,t){if(!e.id)throw new p(`pm plan ${t} requires a plan id`,u.USAGE);return e.id}function He(e,t){let n=ge(e,t);if(!e.stepRef)throw new p(`pm plan ${t} requires <plan-id> <step>`,u.USAGE);return{id:n,stepRef:e.stepRef}}function u_(e){let t=He(e,"reorder-step");if(e.reorderTo===void 0)throw new p("pm plan reorder-step requires <plan-id> <step> <new-order>",u.USAGE);return{...t,reorderTo:e.reorderTo}}var f_={create:(e,t)=>Wf(e.options,e.global,t),show:(e,t)=>Vf(ge(e,"show"),e.options,t),"add-step":(e,t)=>Jf(ge(e,"add-step"),e.options,t),"update-step":(e,t)=>{let n=He(e,"update-step");return Hr(n.id,e.options,t,{stepRef:n.stepRef,op:"plan_update_step"})},"complete-step":(e,t)=>{let n=He(e,"complete-step");return Hr(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"completed",op:"plan_complete_step"})},"block-step":(e,t)=>{let n=He(e,"block-step");return Hr(n.id,e.options,t,{stepRef:n.stepRef,finalStatus:"blocked",op:"plan_block_step"})},"reorder-step":(e,t)=>{let n=u_(e);return t_(n.id,e.options,t,n.stepRef,n.reorderTo)},"remove-step":(e,t)=>{let n=He(e,"remove-step");return n_(n.id,e.options,t,n.stepRef)},link:(e,t)=>{let n=He(e,"link");return o_(n.id,e.options,t,n.stepRef)},unlink:(e,t)=>{let n=He(e,"unlink");return r_(n.id,e.options,t,n.stepRef)},decision:(e,t)=>Wr(ge(e,"decision"),e.options,t,"decision"),discovery:(e,t)=>Wr(ge(e,"discovery"),e.options,t,"discovery"),validation:(e,t)=>Wr(ge(e,"validation"),e.options,t,"validation"),resume:(e,t)=>i_(ge(e,"resume"),e.options,t),approve:(e,t)=>s_(ge(e,"approve"),e.options,t),materialize:(e,t)=>m_(ge(e,"materialize"),e.options,t)};function __(e){let t=f_[e];if(!t)throw ae({command_path:"plan",token:e,allowed:xf});return t}async function rm(e){let t=await Df(e.global),n=p_(e),o=await __(n.subcommand)(n,t);return o.action==="show"?o:{...o,mutation_receipt:oo(o,t.pmRoot)}}var sm=2,oi="update-many",h_=new Set(["author","message","force","ownershipMetadataBypass","ownershipDependencyBypass","allowUnresolvedDeps"]),g_=["--status","--priority","--type","--tags","--description","--body","--deadline","--estimate","--assignee","--dep","--dep-remove","--comment","--note","--learning","--file","--test","--doc","--replace-deps","--replace-tests","--replace-files","--replace-docs","--unset","--clear-*"].join(", "),y_={title:"title",description:"description",body:"body",status:"status",closeReason:"close_reason",priority:"priority",type:"type",deadline:"deadline",estimatedMinutes:"estimated_minutes",acceptanceCriteria:"acceptance_criteria",definitionOfReady:"definition_of_ready",order:"order",goal:"goal",objective:"objective",value:"value",impact:"impact",outcome:"outcome",whyNow:"why_now",assignee:"assignee",parent:"parent",reviewer:"reviewer",risk:"risk",confidence:"confidence",sprint:"sprint",release:"release",blockedBy:"blocked_by",blockedReason:"blocked_reason",unblockNote:"unblock_note",reporter:"reporter",severity:"severity",environment:"environment",reproSteps:"repro_steps",resolution:"resolution",expectedResult:"expected_result",actualResult:"actual_result",affectedVersion:"affected_version",fixedVersion:"fixed_version",component:"component",regression:"regression",customerImpact:"customer_impact"},b_=[{field:"dependencies",addKey:"dep",removeKey:"depRemove",clearKey:"clearDeps",replaceKey:"replaceDeps"},{field:"comments",addKey:"comment",clearKey:"clearComments"},{field:"notes",addKey:"note",clearKey:"clearNotes"},{field:"learnings",addKey:"learning",clearKey:"clearLearnings"},{field:"files",addKey:"file",clearKey:"clearFiles",replaceKey:"replaceFiles"},{field:"tests",addKey:"test",clearKey:"clearTests",replaceKey:"replaceTests"},{field:"docs",addKey:"doc",clearKey:"clearDocs",replaceKey:"replaceDocs"},{field:"reminders",addKey:"reminder",clearKey:"clearReminders"},{field:"events",addKey:"event",clearKey:"clearEvents"},{field:"type_options",addKey:"typeOption",clearKey:"clearTypeOptions"}],am=e=>{let t={};for(let[n,o]of Object.entries(e))h_.has(n)||o!==void 0&&(t[n]=o);return t},w_=e=>Object.keys(am(e)).length>0,cm=e=>typeof e=="string"?e.trim():e,v_=e=>{let t=String(e).trim(),n=Number(t);return Number.isInteger(n)?n:t},ni=e=>{let t=String(e).trim(),n=Number(t);return Number.isFinite(n)?n:t},k_=e=>{let t=String(e).trim().toLowerCase();return new Map([["true",!0],["1",!0],["false",!1],["0",!1]]).get(t)??cm(e)},S_={priority:v_,estimatedMinutes:ni,order:ni,rank:ni,regression:k_},A_=(e,t)=>{if(t!==void 0)return(S_[e]??cm)(t)},ro=(e,t)=>ie(e,t),x_=(e,t)=>t!==void 0?t:e==="type_options"?{}:[],I_=(e,t)=>Array.isArray(t)?t.length:e==="type_options"&&t&&typeof t=="object"?Object.keys(t).length:0,E_=e=>e.replace?"replace":e.clear?"clear_or_reset":e.removeCount>0?"merge_remove":"append",im=(e,t)=>t===void 0?void 0:e[t],mt=e=>Array.isArray(e)?e.length:0,C_=(e,t,n)=>{let o=n[e.addKey],r=im(n,e.removeKey),i=mt(o),s=mt(r),a=n[e.clearKey]===!0,c=im(n,e.replaceKey)===!0;if(![a,c,i>0,s>0].includes(!0))return;let l=x_(e.field,t[e.field]);return{field:e.field,before:l,after:{operation:E_({replace:c,clear:a,removeCount:s}),clear:a,replace:c,add_count:i,remove_count:s,before_count:I_(e.field,l)}}},R_=(e,t)=>{let n=[];for(let o of b_){let r=C_(o,e,t);r!==void 0&&n.push(r)}return n},T_=e=>Array.isArray(e)?e.filter(t=>typeof t=="string"):[],O_=(e,t)=>{if(![t.tags!==void 0,mt(t.addTags)>0,mt(t.removeTags)>0].includes(!0))return;let n=T_(e.tags),o=t.tags===void 0?n:$t(t.tags),r=es(o,t.addTags),i=ts(r,t.removeTags).slice().sort((a,c)=>a.localeCompare(c)),s=n.slice().sort((a,c)=>a.localeCompare(c));if(!ro(s,i))return{field:"tags",before:n,after:i}},$_=(e,t)=>{let n=e.acceptance_criteria,o=Qi(Zi(n),t.addAc,t.removeAc);if(o.unmatchedRemovals.length>0)throw new p(`Acceptance criteria removal did not match: ${o.unmatchedRemovals.join(", ")}`,u.NOT_FOUND,{code:"acceptance_criteria_remove_unmatched",reason:"exact_match_not_found",field:"acceptance_criteria",unmatched:o.unmatchedRemovals});let r=o.criteria.join("; ");if(!ro(typeof n=="string"?n:"",r))return{field:"acceptance_criteria",before:n,after:r}},F_=(e,t,n)=>{for(let[o,r]of Object.entries(y_)){let i=n[o];if(i===void 0)continue;let s=t[r],a=A_(o,i);ro(s,a)||e.push({field:r,before:s,after:a})}},P_=(e,t,n,o)=>{let r=bs(n,o,["update_many"]);for(let[i,s]of Object.entries(r)){let a=t[i];ro(a,s)||e.push({field:i,before:a,after:s})}},N_=(e,t,n,o)=>{if(n===void 0||n.length===0)return;let r=fr(n,o,pe(T()),["update_many"]);for(let i of r){let s=t[i];s!==void 0&&e.push({field:i,before:s,after:null})}},L_=(e,t,n={})=>{let o=e,r=[],i=O_(o,n);if(i&&r.push(i),F_(r,o,n),mt(n.addAc)>0||mt(n.removeAc)>0){let s=$_(o,n);s!==void 0&&r.push(s)}return r.push(...R_(o,n)),P_(r,o,n,t),N_(r,o,n.unset,t),{id:e.id,changes:r}},M_=(e,t)=>na(e,t,{strict:!0,flagLabel:"--filter-status"}),D_=e=>{if(e?.ids!=null&&String(e.ids).trim().length===0)throw new p("--ids requires at least one non-empty item ID",u.USAGE)},j_=[({update:e})=>{e.priority!==void 0&&xn(e.priority)},({update:e,settings:t})=>{e.unset!==void 0&&e.unset.length>0&&fr(e.unset,Xe(t.schema),pe(T()),["update_many"])},({update:e,settings:t,pmRoot:n})=>{if(e.type===void 0)return;let o=F(t,T());if(!un(e.type,o))throw new p(sa(e.type,o.types,gs(n,t.schema)),u.USAGE)},({update:e,statusRegistry:t})=>{if(e.status!==void 0&&!Ne(e.status,t)){let n=t.definitions.map(o=>o.id);throw new p(`Invalid status value "${e.status}". Allowed: ${n.join(", ")}`,u.USAGE,{code:"invalid_argument_value",field:"status",value:e.status,allowed:n})}},({update:e})=>{e.deadline!==void 0&&us(e.deadline,new Date,"deadline")},({update:e})=>{e.estimatedMinutes!==void 0&&ss(e.estimatedMinutes,"estimated-minutes")}],G_=(e,t,n,o)=>{let r={update:e,settings:t,statusRegistry:n,pmRoot:o};for(let i of j_)i(r)},U_=async e=>{let t=await yn(e.pmRoot,oi,e.rollbackId,sm),n=e.options.update?.message??`Rollback update-many checkpoint ${t.id}`,o=await to(e.pmRoot,t,{author:e.options.update?.author,message:n,force:e.options.update?.force}),r=o.rows.filter(i=>i.status==="skipped").length;return{...je({applied:o.restored_ids.length,skipped:r,failed:o.failed_count,unmatched:0}),mode:"rollback",matched_count:t.items.length,dry_run:!1,rollback_checkpoint_id:t.id,checkpoint:{id:t.id,created_at:t.created_at,path:t.path,rollback_command:`pm update-many --rollback ${t.id}`},restored_count:o.restored_ids.length,skipped_count:r,failed_count:o.failed_count,rows:o.rows,ids:o.restored_ids}},q_=async e=>{let t={schema_version:sm,rollback_strategy:"guarded_inverse",id:e.checkpointId,created_at:e.nowValue,author:C(e.options.update?.author,"unknown"),status_filter:e.statusFilter??null,list_filters:e.filters,update_options:e.updateSummary,items:e.checkpointItems},n=await gn(e.pmRoot,oi,e.checkpointId,t);return{id:e.checkpointId,created_at:e.nowValue,path:n,rollback_command:`pm update-many --rollback ${e.checkpointId}`}},z_=(e,t)=>{if(e==null)return;let n=[...new Set(String(e).split(",").map(r=>r.trim()).filter(r=>r.length>0))],o=new Set(t.map(r=>r.id));return n.filter(r=>!o.has(r))},ri=e=>e.unmatchedIds===void 0?{}:{unmatched_ids:e.unmatchedIds,unmatched_count:e.unmatchedIds.length},H_=async e=>{let t=x(process.cwd(),e.path);await P(t);let n=await I(t);return{pmRoot:t,settings:n,statusRegistry:W(n.schema),runtimeFieldRegistry:Xe(n.schema)}},B_=e=>{if(e.options.dryRun===!0)throw new p("--dry-run cannot be combined with --rollback",u.USAGE);if(Jt(e.options.list,e.options.status))throw new p("Rollback mode does not accept filter options",u.USAGE);if(Object.keys(e.updateSummary).length>0)throw new p("Rollback mode does not accept update mutation flags",u.USAGE);return U_({pmRoot:e.runtime.pmRoot,rollbackId:e.rollbackId,options:e.options,global:e.global})},W_=async e=>{M_(e.options.status,e.runtime.statusRegistry);let t=await fe(void 0,{...e.options.list,status:e.options.status,compact:void 0,brief:void 0,fields:void 0,includeBody:!0,full:!0},e.global),n=t.items.map(r=>{let i=L_(r,e.runtime.runtimeFieldRegistry,e.options.update);return e.dependencyWarnings.length===0?i:{...i,warnings:[...e.dependencyWarnings]}}),o=e.options.list?.ids==null?[]:(await fe(void 0,{ids:e.options.list.ids,noTruncate:!0,full:!0},e.global)).items;return{listed:t,planned:n,actionable:n.filter(r=>r.changes.length>0),updateSummary:e.updateSummary,unmatchedIds:z_(e.options.list?.ids,o)}},V_=e=>({outcome:"effect",exit_code:u.SUCCESS,mode:"dry_run",matched_count:e.listed.items.length,dry_run:!0,filters:e.listed.filters,planned_update_options:e.updateSummary,item_plans:e.planned,ids:[],...ri(e)}),K_=e=>({...je({applied:0,skipped:e.listed.items.length,failed:0,unmatched:e.unmatchedIds?.length??0}),mode:"apply",matched_count:e.listed.items.length,dry_run:!1,filters:e.listed.filters,planned_update_options:e.updateSummary,updated_count:0,skipped_count:e.listed.items.length,failed_count:0,rows:e.planned.map(t=>({id:t.id,status:"skipped"})),ids:[],...ri(e)}),J_=async e=>{let t=[],n=[],o=e.options.update.message??`update-many apply ${e.checkpointId}`,r=new Set(e.plans.filter(i=>i.changes.length>0).map(i=>i.id));for(let i of e.items){if(!r.has(i.id)){t.push({id:i.id,status:"skipped"});continue}try{let s=Ao(le(e.options.update,{...e.options.update,message:o,runtimeFieldCommands:["update_many"]})),a=await Rn({pmRoot:e.pmRoot,itemId:i.id,checkpointId:e.checkpointId},()=>lt(i.id,s,e.global));t.push({id:i.id,status:"updated",changed_fields:a.changed_fields,warnings:a.warnings}),n.push(i.id)}catch(s){let a=await Kn(s,i.id,e.pmRoot);if(a!==void 0){t.push({id:i.id,status:"updated",...a}),n.push(i.id);continue}t.push({id:i.id,status:"failed",error:Ae(s),...await ot(s,e.pmRoot)})}}return{rows:t,updatedIds:n}},Y_=async e=>{if(e.plan.actionable.length===0)return K_(e.plan);let t=S(),n=hn(oi,t),o=new Set(e.plan.actionable.map(m=>m.id)),r=e.plan.listed.items.filter(m=>o.has(m.id)).map(m=>({id:m.id,target_updated_at:m.updated_at})),i=e.options.checkpoint===!1?void 0:await q_({pmRoot:e.runtime.pmRoot,checkpointId:n,nowValue:t,options:e.options,statusFilter:e.options.status,filters:e.plan.listed.filters,updateSummary:e.plan.updateSummary,checkpointItems:r}),s=await J_({pmRoot:e.runtime.pmRoot,items:e.plan.listed.items,plans:e.plan.planned,options:e.options,global:e.global,checkpointId:n}),a=m=>s.rows.filter(f=>f.status===m).length,c=a("updated"),l=a("skipped"),d=a("failed");return{...je({applied:c,skipped:l,failed:d,unmatched:e.plan.unmatchedIds?.length??0}),mode:"apply",matched_count:e.plan.listed.items.length,dry_run:!1,filters:e.plan.listed.filters,planned_update_options:e.plan.updateSummary,...i?{checkpoint:i}:{},updated_count:c,skipped_count:l,failed_count:d,rows:s.rows,ids:s.updatedIds,...ri(e.plan)}},lm=async(e,t)=>{let n=_n(e.rollback),o=await H_(t);n===void 0&&(e={...e,update:Ao(await Xl(e.update))});let r=am(e.update);if(D_(e.list),n!==void 0)return B_({runtime:o,rollbackId:n,options:e,global:t,updateSummary:r});if(!w_(e.update)&&e.dryRun!==!0)throw new p(`No update-many mutation flags provided. Add at least one mutation flag (for example: ${g_}), or pass --dry-run for a filter-only preview.`,u.USAGE);G_(e.update,o.settings,o.statusRegistry,o.pmRoot),Zl(e.update);let i=await pr({pmRoot:o.pmRoot,dependencies:_r(e.update.dep,o.settings.id_prefix,S(),C(e.update.author,o.settings.author_default)).additions,idPrefix:o.settings.id_prefix,itemFormat:o.settings.item_format,typeToFolder:F(o.settings,T()).type_to_folder,allowUnresolved:e.update.allowUnresolvedDeps}),s=await W_({options:e,global:t,runtime:o,updateSummary:r,dependencyWarnings:i});return await pr({pmRoot:o.pmRoot,dependencies:_r(e.update.dep,o.settings.id_prefix,S(),C(e.update.author,o.settings.author_default)).additions,idPrefix:o.settings.id_prefix,itemFormat:o.settings.item_format,typeToFolder:F(o.settings,T()).type_to_folder,allowUnresolved:e.update.allowUnresolvedDeps,holders:s.listed.items.map(a=>({id:a.id,createdAt:a.created_at})),schema:o.settings.schema}),e.dryRun===!0?V_(s):Y_({runtime:o,options:e,global:t,plan:s})};function X_(e){if(e===void 0)return;if(e.trim().length===0)throw new p("--add-json must contain a JSON value",u.USAGE,{code:"structured_event_json_empty"});let t;try{t=JSON.parse(e)}catch{throw new p("--add-json must be valid JSON",u.USAGE,{code:"structured_event_json_invalid"})}return t}function Z_(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e.type;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}function Q_(e){if(e===void 0)return;let t=Date.parse(e);if(!Number.isFinite(t))throw new p("--since must be a valid ISO timestamp",u.USAGE,{code:"structured_event_since_invalid"});return t}function dm(e){return Object.prototype.toString.call(e)==="[object Object]"?e:{}}async function mm(e,t,n){let o=X_(t.addJson),r=[t.add!==void 0,t.stdin===!0,t.file!==void 0,t.edit!==void 0,t.delete!==void 0].includes(!0);if(o!==void 0&&r)throw new p("--add-json cannot be combined with text, edit, delete, stdin, or file inputs",u.USAGE,{code:"structured_event_input_conflict"});let i=o===void 0?void 0:Ot(o),s=[t.since,t.eventType].some(g=>g!==void 0),a=Q_(t.since),c=oa(t.limit),l=await it(e,{...t,...s?{limit:void 0}:{},includeMeta:[t.includeMeta===!0,s].includes(!0)},n,{input:await Nn(i===void 0?t:{add:i},"note"),collectionKey:"notes",op:"note_add",editOp:"note_edit",deleteOp:"note_delete",parseText:g=>rt(g),createEntry:g=>o===void 0?g:{...g,format:"json",data:o,event_type:Z_(o)},bypassOwnershipConflict:!![t.edit===void 0,t.delete===void 0,t.ownershipAppendBypass===!0].every(Boolean),conflictGuidance:{required:"Strict ownership also protects annotations. Ask the current owner to run pm release <id>, then run pm claim <id>; use --force only for an explicitly approved override.",examples:["pm claim <id>"],nextSteps:["For an approved append without reassignment: pm package install governance-audit --project; then pm notes --help lists the package-owned append bypass. Edit/delete still require ownership.","For a non-terminal handoff, the current owner runs pm release <id>; then you run pm claim <id> before retrying. Claim refuses work still held by another owner; --force requires an explicitly approved override."]}}),d=t.eventType?.trim(),m=l.notes.filter(g=>{let k=dm(g),y=[k.format==="json",k.data!==void 0].every(Boolean),v=[a===void 0,Date.parse(k.created_at??"")>=(a??Number.POSITIVE_INFINITY)].includes(!0),_=[!d,k.event_type===d].includes(!0);return[!s,[y,v,_].every(Boolean)].includes(!0)}),f=s?wc(m,c):m,b=f.filter(g=>dm(g).format==="json").length;return{...l,notes:f,count:f.length,...s?{total_count:m.length,returned_count:f.length,has_more:f.length<m.length,...c===void 0?{}:{limit:c},structured_event_count:b}:t.includeMeta===!0?{structured_event_count:b}:{}}}import vh from"node:path";var pt=["agile","ops","research"],ii={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:Gn.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
12
+
13
+ ## I want
14
+
15
+ ## So that
16
+
17
+ ## Acceptance
18
+ - [ ]
19
+ `}}],packages:[{spec:"templates",reason:"Reusable create templates for recurring story shapes."},{spec:"calendar",reason:"Sprint and iteration scheduling views."},{spec:"search-advanced",reason:"Richer retrieval as the backlog grows."}]},ops:{name:"ops",title:"Operations",summary:"Incident/Runbook response with mitigation and monitoring stages, severity, and service fields.",types:Gn.ops,statuses:[{id:"mitigating",roles:["active"],aliases:["mitigation"],description:"Active mitigation is underway to restore service."},{id:"monitoring",roles:["active"],aliases:["observing"],description:"Mitigation applied; monitoring for recurrence before closure."}],fields:[{key:"severity",type:"string",commands:["create","update","list"],description:"Incident severity classification (e.g. sev1, sev2, sev3).",aliases:["sev"]},{key:"service",type:"string",commands:["create","update","list"],description:"Primary affected service or component."}],workflows:[{type:"Incident",allowed_transitions:[["open","mitigating"],["mitigating","monitoring"],["monitoring","mitigating"],["monitoring","closed"],["mitigating","blocked"],["blocked","mitigating"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search for fast incident lookup."},{key:"search_max_results",value:"25",summary:"Wider result cap to surface related incidents and runbooks."}],templates:[{name:"incident",options:{type:"Incident",priority:"1",tags:"incident",acceptanceCriteria:"Service restored, root cause documented, and follow-ups filed.",body:`## Impact
20
+
21
+ ## Timeline
22
+
23
+ ## Root cause
24
+
25
+ ## Mitigation
26
+
27
+ ## Follow-ups
28
+ `}}],packages:[{spec:"lifecycle-hooks",reason:"Automate transitions and notifications on incident state changes."},{spec:"governance-audit",reason:"Audit incident metadata completeness and closure quality."},{spec:"calendar",reason:"On-call and follow-up scheduling."}]},research:{name:"research",title:"Research",summary:"Experiment/Hypothesis investigation with an analysis stage, hypothesis, and method fields.",types:Gn.research,statuses:[{id:"analyzing",roles:["active"],aliases:["analysis"],description:"Data collected; analysis and synthesis in progress."}],fields:[{key:"hypothesis",type:"string",commands:["create","update"],description:"The testable claim the experiment evaluates."},{key:"method",type:"string",commands:["create","update","list"],description:"Experimental method or protocol used to evaluate the hypothesis.",aliases:["protocol"]}],workflows:[{type:"Experiment",allowed_transitions:[["open","in_progress"],["in_progress","analyzing"],["analyzing","in_progress"],["analyzing","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search across the research corpus."},{key:"search_max_results",value:"50",summary:"Broader recall cap for literature and prior-experiment discovery."}],templates:[{name:"experiment",options:{type:"Experiment",priority:"2",tags:"experiment",acceptanceCriteria:"Hypothesis is supported, rejected, or refined with recorded evidence.",body:`## Hypothesis
29
+
30
+ ## Method
31
+
32
+ ## Results
33
+
34
+ ## Conclusion
35
+ `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function eh(e){if(e===void 0)return;let t=Re(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(pt.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${pt.join(", ")}.`)}function ok(e){let t=eh(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${pt.join(", ")}.`);return ii[t]}function rk(){return pt.map(e=>ii[e])}function Re(e){return e.trim().toLowerCase().replaceAll("-","_")}function pm(e){return e.map(t=>t.definition.name).join(", ")}function si(e=[]){let t=pt.map(i=>({definition:ii[i],source:"builtin"})),n=new Set(pt.map(i=>Re(i))),o=new Set(n),r=[];for(let i of e){let s=Re(i.profile.name);if(n.has(s)){r.push(`Extension "${i.name}" profile "${i.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(o.has(s)){r.push(`Profile "${i.profile.name}" from extension "${i.name}" duplicates an already-registered profile and was ignored.`);continue}o.add(s),t.push({definition:i.profile,source:"extension",package:i.name})}return{profiles:t,warnings:r}}function io(e,t=[]){let{profiles:n,warnings:o}=si(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${pm(n)}.`);let r=Re(e),i=n.find(s=>Re(s.definition.name)===r);if(i===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${pm(n)}.`);return{resolved:i,warnings:o}}function ci(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function um(e){return{name:e.name,title:e.title,summary:e.summary,composition:ci(e),types:e.types.map(t=>ai(()=>ue(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>ai(()=>Ge(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>ai(()=>_e(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function ai(e,t){try{return e()}catch{return t()}}var vk=["profile","types","statuses","fields","workflows","config","templates","packages"],kk=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],th=new Set(_s.flatMap(e=>[Ye(e.id),...(e.aliases??[]).map(t=>Ye(t))]).filter(e=>e.length>0)),fm=new Set(Pt.map(e=>e.toLowerCase()));function nh(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==Re(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${Re(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function oh(e,t){let n=new Set,o=new Set;for(let[r,i]of e.types.entries()){let s;try{s=ue(i).name}catch(c){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof i.name=="string"?i.name:`#${r}`,message:Ae(c)});continue}let a=s.toLowerCase();if(o.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:s,message:`Item type "${s}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(a),n.add(a)}return n}function rh(e,t){let n=new Set,o=new Set;for(let[r,i]of e.statuses.entries()){let s;try{s=Ge(i)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof i.id=="string"?i.id:`#${r}`,message:Ae(a)});continue}if(o.has(s.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:s.id,message:`Status "${s.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}o.add(s.id),n.add(s.id);for(let a of s.aliases??[])n.add(Ye(a))}return n}function ih(e,t){let n=new Set;for(let[o,r]of e.fields.entries()){let i,s;try{s=_e(r),i=s.key}catch(l){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${o}`,message:Ae(l)});continue}if(n.has(i)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:i,message:`Field "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(i);let a=Jc(s);a.length>0&&t.push({severity:"error",code:"field_option_collision",dimension:"fields",target:i,message:`Field "${i}" would disable a built-in option: ${a.map(Yc).join("; ")}. Rename the field or narrow its commands.`});let c=Sc(i);c&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:i,message:`Field "${i}" collides with canonical MCP property "${c.property}" owned by ${c.owner}; callers must pass the custom value through ${c.nested_path}.`})}}function sh(e,t,n,o){let r=new Set;for(let[i,s]of e.workflows.entries()){let a=s.type.trim().toLowerCase();if(a.length===0){o.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${i}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let c=r.has(a);r.add(a),c?o.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:s.type,message:`Workflow type "${s.type}" is declared more than once; the later transition set wins.`}):!fm.has(a)&&!t.has(a)&&o.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:s.type,message:`Workflow governs type "${s.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let l=new Set;for(let d of s.allowed_transitions){let m=Ye(d[0]),f=Ye(d[1]);if(m.length===0||f.length===0){o.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:s.type,message:`Workflow "${s.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let b of[m,f])th.has(b)||n.has(b)||l.has(b)||(l.add(b),o.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:b,message:`Workflow "${s.type}" references status "${b}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function ah(e,t){let n=new Set;for(let o of e.config){let r=ct(o.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:o.key,message:`Config knob "${o.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let i=Hn(r,o.value);i.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:o.key,message:i.error.message})}}function ch(e,t,n){for(let o of e.templates){let r=o.options.type;if(typeof r!="string"||r.trim().length===0)continue;let i=r.trim().toLowerCase();!fm.has(i)&&!t.has(i)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:o.name,message:`Template "${o.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function lh(e,t){for(let[n,o]of e.packages.entries())o.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function _m(e){let t=[];nh(e,t);let n=oh(e,t),o=rh(e,t);ih(e,t),sh(e,n,o,t),ah(e,t),ch(e,n,t),lh(e,t);let r=t.filter(s=>s.severity==="error").length,i=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount:i}}function li(e,t,n,o,r){let i=e,s=[];for(let a of t){let c=o(i),l=r(i,a),d=o(l.file);i=l.file;let m=c===d?"unchanged":l.replaced?"update":"add";s.push({key:n(a),status:m})}return{file:i,changes:s,changed:s.some(a=>a.status!=="unchanged")}}function hm(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function dh(e,t){let n=e.map(r=>({...r})),o=[];for(let r of t){let i=n.findIndex(a=>a.type===r.type),s={type:r.type,allowed_transitions:r.allowed_transitions};i<0?(n.push(s),o.push({type:r.type,status:"add"})):hm(n[i].allowed_transitions)===hm(r.allowed_transitions)?o.push({type:r.type,status:"unchanged"}):(n[i]=s,o.push({type:r.type,status:"update"}))}return{changes:o,result:n,changed:o.some(r=>r.status!=="unchanged")}}function mh(e,t){let n=[];for(let o of e.config){let r=ct(o.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${o.key}".`);let i=Hn(r,o.value);if(!i.ok)throw new Error(`Profile "${e.name}" config ${o.key}: ${i.error.message}`);let s=yl(t,r),a=s===null?"add":s===i.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:i.parsed.value,status:a})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function gm(e){let t=Object.entries(e).sort(([n],[o])=>n.localeCompare(o));return JSON.stringify(t)}function ph(e,t){let n=[];for(let o of e.templates){let r=t.get(o.name),i;r===void 0?i="add":gm(r)===gm(o.options)?i="unchanged":i="update",n.push({name:o.name,options:o.options,status:i})}return{changes:n,changed:n.some(o=>o.status!=="unchanged")}}function ym(e,t){let n=li(ra(t.typesRaw),e.types,d=>ue(d).name,In,(d,m)=>ia(d,ue(m))),o=li(Bc(t.statusesRaw),e.statuses,d=>Ge(d).id,Un,(d,m)=>Wc(d,Ge(m))),r=li(Vc(t.fieldsRaw),e.fields,d=>_e(d).key,qn,(d,m)=>Kc(d,_e(m))),i=dh(t.workflows,e.workflows),s=mh(e,t.settings),a=ph(e,t.templates),c=e.packages.map(d=>({spec:d.spec,reason:d.reason,status:t.installedPackages.has(d.spec)?"installed":"recommended"})),l=n.changed||o.changed||r.changed||i.changed||s.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:o,fields:r,workflows:i,config:s,templates:a,packages:c,changed:l}}import wm from"node:fs/promises";import vm from"node:path";var uh="templates",di=".json",km=/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/,fh=kc.map(e=>e.target).filter(e=>e!=="acceptanceCriteria"),_h=new Set(fh),bm="1970-01-01T00:00:00.000Z",Sm={bug:{type:"Issue",priority:"1",tags:"bug",acceptanceCriteria:"Bug no longer reproduces with the steps below and a regression test guards it.",expectedResult:"Describe the correct behavior.",actualResult:"Describe the observed (buggy) behavior.",body:`## Repro steps
36
+ 1.
37
+ 2.
38
+ 3.
39
+
40
+ ## Expected
41
+
42
+ ## Actual
43
+ `},feature:{type:"Feature",priority:"2",tags:"feature",acceptanceCriteria:"Feature is shipped behind agreed scope with tests and docs updated.",whyNow:"Explain why this is worth doing now (impact / urgency).",body:`## Goal
44
+
45
+ ## Why now
46
+
47
+ ## Out of scope
48
+ `},spike:{type:"Task",priority:"2",tags:"spike",estimatedMinutes:"120",acceptanceCriteria:"Timeboxed investigation complete; findings and a recommendation are recorded.",body:`## Question to answer
49
+
50
+ ## Timebox
51
+ 2h
52
+
53
+ ## Findings
54
+
55
+ ## Recommendation
56
+ `},chore:{type:"Chore",priority:"3",tags:"chore",acceptanceCriteria:"Maintenance task done with no behavior change and green checks.",body:`## What
57
+
58
+ ## Why
59
+ `}},qk={normalizeTemplateName:so,extractTemplateOptions:Am,parseStoredTemplateDocument:fi,builtinTemplateDocument:xm,readStoredTemplateDocument:Em};function so(e){let t=e.trim();if(!km.test(t))throw new p(`Invalid template name "${e}". Expected 1-64 characters matching [A-Za-z0-9][A-Za-z0-9._-]*.`,u.USAGE);return t}function mi(e){return vm.join(e,uh)}function ao(e,t){return vm.join(mi(e),`${t}${di}`)}async function pi(e){await P(e)}function ui(e){return Object.fromEntries(Object.entries(e).sort(([t],[n])=>t.localeCompare(n)))}function Am(e){let t={};for(let[n,o]of Object.entries(e))if(o!==void 0){if(n==="priority"){t[n]=String(xn(o));continue}if(_h.has(n)){if(typeof o=="string"){t[n]=[o];continue}if(!Array.isArray(o))continue;let r=o.filter(i=>typeof i=="string");r.length>0&&(t[n]=r);continue}if(typeof o=="string"){t[n]=o;continue}Array.isArray(o)&&o.every(r=>typeof r=="string")&&(t[n]=[...o])}return ui(t)}function hh(e,t){if(typeof e!="object"||e===null||Array.isArray(e))throw new p(`Template "${t}" has invalid options payload.`,u.GENERIC_FAILURE);let n=e,o={};for(let[r,i]of Object.entries(n)){let s=r.trim();if(s.length===0)throw new p(`Template "${t}" contains an empty option key.`,u.GENERIC_FAILURE);if(typeof i=="string"){o[s]=i;continue}if(Array.isArray(i)&&i.every(a=>typeof a=="string")){o[s]=[...i];continue}throw new p(`Template "${t}" contains invalid value for option "${s}".`,u.GENERIC_FAILURE)}return ui(o)}function fi(e,t){let n;try{n=JSON.parse(e)}catch{throw new p(`Template "${t}" contains invalid JSON.`,u.GENERIC_FAILURE)}if(typeof n!="object"||n===null||Array.isArray(n))throw new p(`Template "${t}" has invalid document shape.`,u.GENERIC_FAILURE);let o=n,r=hh(o.options,t),i=S();return{name:typeof o.name=="string"&&o.name.trim().length>0?o.name.trim():t,created_at:typeof o.created_at=="string"?o.created_at:i,updated_at:typeof o.updated_at=="string"?o.updated_at:i,options:r}}function xm(e){let t=Sm[e];return t?{name:e,created_at:bm,updated_at:bm,options:ui({...t})}:null}async function Im(e,t){let n=await de(ao(e,t));if(n!==null)return{document:fi(n,t),source:"user"};let o=xm(t);if(o)return{document:o,source:"builtin"};throw new p(`Template "${t}" not found`,u.NOT_FOUND)}async function Em(e,t){let n=await de(ao(e,t));if(n===null)throw new p(`Template "${t}" not found`,u.NOT_FOUND);return fi(n,t)}async function gh(e,t){let n=so(t),{document:o}=await Im(e,n);return o.options}async function _i(e,t,n){let o=x(process.cwd(),n.path);await pi(o);let r=so(e),i=Am(t);if(Object.keys(i).length===0)throw new p("templates save requires at least one create option flag",u.USAGE);let s=S(),a=ao(o,r),c=s;await ke(a)&&(c=(await Em(o,r)).created_at);let l={name:r,created_at:c,updated_at:s,options:i},d=await I(o);return await wm.mkdir(mi(o),{recursive:!0}),await tt({pmRoot:o,filePath:a,raw:`${JSON.stringify(l,null,2)}
60
+ `,op:"templates:save",author:C(void 0,d.author_default),lockTtlSeconds:d.locks.ttl_seconds,lockWaitMs:d.locks.wait_ms}),{name:l.name,created_at:l.created_at,updated_at:l.updated_at,path:a,options:l.options}}async function yh(e){let t=mi(e);return await ke(t)?(await wm.readdir(t)).filter(o=>o.toLowerCase().endsWith(di)).map(o=>o.slice(0,-di.length)).filter(o=>km.test(o)):[]}async function bh(e){let t=x(process.cwd(),e.path);await pi(t);let n=await yh(t),o=new Set(n),r=Object.keys(Sm).filter(c=>!o.has(c)),i=[...n].sort((c,l)=>c.localeCompare(l)),s=[...r].sort((c,l)=>c.localeCompare(l)),a=[...new Set([...i,...s])].sort((c,l)=>c.localeCompare(l));return{templates:a,count:a.length,builtin_templates:s,user_templates:i}}async function wh(e,t){let n=x(process.cwd(),t.path);await pi(n);let o=so(e),{document:r,source:i}=await Im(n,o);return{name:r.name,source:i,created_at:r.created_at,updated_at:r.updated_at,path:i==="builtin"?`builtin:${o}`:ao(n,o),options:r.options}}var Om=["list","show","apply","lint"],kh="schema-types",Sh="schema-statuses",Ah="schema-fields";function co(){let e=T();return e===null?[]:e.profiles.map(t=>({name:t.name,profile:t.profile}))}function $m(){let{profiles:e,warnings:t}=si(co());return{action:"list",profiles:e.map(n=>({name:n.definition.name,title:n.definition.title,summary:n.definition.summary,source:n.source,...n.package!==void 0?{package:n.package}:{},composition:ci(n.definition)})),warnings:t,generated_at:S()}}function Fm(e){let t;try{t=io(e,co())}catch(o){throw new p(o instanceof Error?o.message:String(o),u.USAGE)}let{resolved:n}=t;return{action:"show",...um(n.definition),source:n.source,...n.package!==void 0?{package:n.package}:{},warnings:t.warnings,generated_at:S()}}function Pm(e){let t;try{t=io(e,co())}catch(r){throw new p(r instanceof Error?r.message:String(r),u.USAGE)}let{resolved:n}=t,o=_m(n.definition);return{action:"lint",name:n.definition.name,title:n.definition.title,source:n.source,...n.package!==void 0?{package:n.package}:{},ok:o.ok,error_count:o.errorCount,warning_count:o.warningCount,findings:o.findings,warnings:t.warnings,generated_at:S()}}function xh(e,t){return vh.join(e,"templates",`${t}.json`)}async function Ih(e,t){let n=await de(xh(e,t));if(n!==null)try{let o=JSON.parse(n);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){let r=o.options;if(r!==null&&typeof r=="object"&&!Array.isArray(r))return r}}catch{}}async function Cm(e,t,n,o){let r=new Map;for(let i of o.templates){let s=await Ih(e,i.name);s!==void 0&&r.set(i.name,s)}return{typesRaw:await de(Pe(e,t.files.types,Fe.types)),statusesRaw:await de(Pe(e,t.files.statuses,Fe.statuses)),fieldsRaw:await de(Pe(e,t.files.fields,Fe.fields)),workflows:n.schema.type_workflows??[],settings:n,templates:r,installedPackages:new Set}}function ut(e){let t=[],n=[],o=[];for(let r of e)(r.status==="add"?t:r.status==="update"?n:o).push(r.key);return{added:t,updated:n,unchanged:o}}function Rm(e,t,n,o,r){return{action:"apply",name:e.name,title:e.title,applied:n,dry_run:o,changed:t.changed,types:ut(t.types.changes),statuses:ut(t.statuses.changes),fields:ut(t.fields.changes),workflows:ut(t.workflows.changes.map(i=>({key:i.type,status:i.status}))),config:ut(t.config.changes),templates:ut(t.templates.changes.map(i=>({key:i.name,status:i.status}))),packages:t.packages,warnings:[...new Set(r)].sort((i,s)=>i.localeCompare(s)),generated_at:S()}}async function Eh(e){await P(e)}function Ch(e){try{let t=io(e,co());return{profile:t.resolved.definition,warnings:t.warnings}}catch(t){throw new p(t instanceof Error?t.message:String(t),u.USAGE)}}async function Nm(e,t,n){let o=x(process.cwd(),n.path);await Eh(o);let r=Ch(e),i=r.profile,s=r.warnings;for(let v of i.fields){let _;try{_=_e(v)}catch{continue}Xc(_)}let a=t.dryRun===!0,c=await I(o),l=hs(c.schema);if(a){let v=await Cm(o,l,c,i),_=Tm(i,v);return Rm(i,_,!1,!0,[...s])}let d=C(t.author,c.author_default),m=ca(c),f=!!t.force,b=[...s],g=[],k=async v=>{g.push(await Le(o,v,c.locks.ttl_seconds,d,f,m.force_required_for_stale_lock,c.locks.wait_ms))},y;try{await k(kh),await k(Sh),await k(Ah);let v=await Cm(o,l,c,i);if(y=Tm(i,v),y.types.changed){let _=Pe(o,l.files.types,Fe.types);await tt({pmRoot:o,filePath:_,raw:In(y.types.file),op:"profile:apply-types",author:d,lockTtlSeconds:c.locks.ttl_seconds,lockWaitMs:c.locks.wait_ms});let A=new Set(i.types.map(O=>ue(O).name)),N=y.types.file.definitions.filter(O=>A.has(O.name));await ol(o,N,b,"profile:apply-type-folder"),b.push(...await G({path:_,scope:"project",op:"profile:apply-types"}))}if(y.statuses.changed){let _=Pe(o,l.files.statuses,Fe.statuses);await tt({pmRoot:o,filePath:_,raw:Un(y.statuses.file),op:"profile:apply-statuses",author:d,lockTtlSeconds:c.locks.ttl_seconds,lockWaitMs:c.locks.wait_ms}),b.push(...await G({path:_,scope:"project",op:"profile:apply-statuses"}))}if(y.fields.changed){let _=Pe(o,l.files.fields,Fe.fields);await tt({pmRoot:o,filePath:_,raw:qn(y.fields.file),op:"profile:apply-fields",author:d,lockTtlSeconds:c.locks.ttl_seconds,lockWaitMs:c.locks.wait_ms}),b.push(...await G({path:_,scope:"project",op:"profile:apply-fields"}))}if(y.config.changed||y.workflows.changed){for(let _ of y.config.changes){if(_.status==="unchanged")continue;let A=ct(_.key);A!==void 0&&bl(c,A,_.value)}c.schema.type_workflows=y.workflows.result,await la(o,c,"profile:apply-config")}for(let _ of y.templates.changes)_.status!=="unchanged"&&await _i(_.name,{..._.options},n)}finally{for(let v of g.reverse())try{await v()}catch{}}return Rm(i,y,y.changed,!1,b)}function Tm(e,t){try{return ym(e,t)}catch(n){throw new p(n instanceof Error?n.message:String(n),u.USAGE)}}function Rh(e,t){let n=[];if(t.added.length>0&&n.push(`+${t.added.join(", ")}`),t.updated.length>0&&n.push(`~${t.updated.join(", ")}`),n.length!==0)return` ${e}: ${n.join(" ")}`}function fS(e){let t=["Project profiles:"];for(let n of e.profiles){let o=n.source==="extension"?` [${n.package??"extension"}]`:"";t.push(` ${n.name} \u2014 ${n.title}: ${n.summary}${o}`)}for(let n of e.warnings)t.push(` warning: ${n}`);return t.join(`
61
+ `)}function _S(e){let t=e.source==="extension"?` [${e.package??"extension"}]`:"",n=[`${e.name} \u2014 ${e.title}${t}`,e.summary,""];n.push(`types: ${e.types.join(", ")||"(none)"}`),n.push(`statuses: ${e.statuses.join(", ")||"(none)"}`),n.push(`fields: ${e.fields.join(", ")||"(none)"}`),n.push(`workflows: ${e.workflows.join(", ")||"(none)"}`),n.push(`config: ${e.config.join(", ")||"(none)"}`),n.push(`templates: ${e.templates.join(", ")||"(none)"}`),n.push(`packages: ${e.packages.map(o=>o.spec).join(", ")||"(none)"}`);for(let o of e.warnings)n.push(`warning: ${o}`);return n.join(`
62
+ `)}function hS(e){let t=e.source==="extension"?` [${e.package??"extension"}]`:"",n=e.warning_count+e.warnings.length,r=[e.ok?`Profile ${e.name}${t}: ok (${n} warning${n===1?"":"s"})`:`Profile ${e.name}${t}: ${e.error_count} error${e.error_count===1?"":"s"}, ${n} warning${n===1?"":"s"}`];for(let i of e.findings){let s=i.target!==void 0?` (${i.target})`:"";r.push(` ${i.severity} [${i.code}] ${i.dimension}${s}: ${i.message}`)}for(let i of e.warnings)r.push(` warning: ${i}`);return r.join(`
63
+ `)}function gS(e){let t=e.dry_run?"dry-run":e.applied?"applied":"no changes",n=[`Profile ${e.name} (${t})`];if(!e.changed)n.push(" already up to date");else for(let[r,i]of[["types",e.types],["statuses",e.statuses],["fields",e.fields],["workflows",e.workflows],["config",e.config],["templates",e.templates]]){let s=Rh(r,i);s!==void 0&&n.push(s)}let o=e.packages.filter(r=>r.status==="recommended");o.length>0&&n.push(` recommended packages: ${o.map(r=>r.spec).join(", ")}`);for(let r of e.warnings)n.push(` warning: ${r}`);return n.join(`
64
+ `)}import{readFile as Th,writeFile as Dm}from"node:fs/promises";import Oh from"node:path";var Lm=["item","history","relationship","json"];function $h(e){let t=e.trim().toLowerCase();if(Lm.includes(t))return t;throw new p(`Unknown merge artifact "${e}". Supported values: ${Lm.join(", ")}.`,u.USAGE)}function Fh(e){if(e===void 0)return"ours";let t=e.trim().toLowerCase();if(t==="ours"||t==="theirs")return t;throw new p(`Unknown --prefer value "${e}". Supported values: ours, theirs.`,u.USAGE)}async function hi(e,t){try{return await Th(e,"utf8")}catch{throw new p(`Cannot read merge ${t} file at ${e}.`,u.NOT_FOUND)}}async function Ph(e){let t=x(process.cwd(),e.path);return await ke(Se(t))?I(t):null}function Nh(e,t){return e.endsWith(".md")?"json_markdown":e.endsWith(".toon")?"toon":t?.item_format??"toon"}async function Mm(e,t){try{return e()}catch(n){if(n instanceof p&&n.context?.code==="item_identity_conflict"){let o=r=>r.endsWith(`
65
+ `)?r:`${r}
66
+ `;throw await Dm(t.outputPath,`<<<<<<< pm ours
67
+ ${o(t.oursRaw)}||||||| pm base
68
+ ${o(t.baseRaw)}=======
69
+ ${o(t.theirsRaw)}>>>>>>> pm theirs
70
+ `,"utf8"),new p(`Unresolved identity for ${t.itemPath}: both snapshots remain in conflict markers. ${n.message}`,n.exitCode,{...n.context,recovery:{suggested_retry:"git status --short"},nextSteps:["Preserve both source snapshots and establish item identity before resolving. Do not stage conflict markers as a completed merge; pm health and storage validation reject them."]})}throw n}}async function jm(e,t){let n=$h(e.artifact),o=Fh(e.prefer),r=Oh.resolve(e.outputPath??e.oursPath),[i,s,a]=await Promise.all([hi(e.basePath,"base"),hi(e.oursPath,"ours"),hi(e.theirsPath,"theirs")]),c,l,d=[],m={},f={baseRaw:i,oursRaw:s,theirsRaw:a,outputPath:r,itemPath:e.itemPath??r};if(n==="history"){let g=await Mm(()=>Cl(i,s,a),f);c=g.merged,m.history={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="relationship"){let g=Rl(i,s,a);c=g.merged,m.relationship={strategy:g.strategy,common_entries:g.common_entries,entries_from_ours:g.entries_from_ours,entries_from_theirs:g.entries_from_theirs,entries_total:g.entries_total,reanchored:g.reanchored}}else if(n==="item"){let g=await Ph(t),k=Nh(e.itemPath??r,g),y=pe(T()),v=await Mm(()=>Tl(i,s,a,{format:k,schema:g?.schema,extensionFieldNames:y,preferred:o,conflictResolution:"latest_document_update"}),f);if(c=v.merged,d.push(...v.conflict_fields),m.item={fields_from_theirs:v.fields_from_theirs,union_fields:v.union_fields,conflict_resolution:"latest_document_update",requested_preference_applied:!1},e.itemPath!==void 0){let _=bn(c,{format:k,schema:g?.schema,extensionFieldNames:y}),A=_.metadata,N=[...new Set([...v.fields_from_theirs,...v.union_fields,...v.conflict_decisions.map(O=>O.field)])];l={cwd:process.cwd(),itemPath:e.itemPath,preferred:o,conflictResolution:"latest_document_update",fieldsFromTheirs:v.fields_from_theirs,unionFields:v.union_fields,mergedFieldHashes:Object.fromEntries(N.map(O=>[O,El(O==="body"?_.body:A[O])])),decisions:v.conflict_decisions,operation:await $l(process.cwd(),e.itemPath,s)}}}else{let g=Ol(i,s,a,{preferred:o});c=g.merged,d.push(...g.conflict_paths),m.json={paths_from_theirs:g.paths_from_theirs}}if(await Dm(r,c,"utf8"),l!==void 0){let g=await Pl(l);g!==null&&(m.receipt=Ue(g))}let b=[];if(d.length>0){let g=m.receipt===void 0?'Run "pm merge report" to inspect clone-local merge evidence.':`Run "pm merge report" and correlate receipt ${m.receipt.receipt_id} with item ${m.receipt.item_id}; clone-local discarded values are never copied into this result.`;b.push(`Both branches changed ${d.join(", ")}; the item driver kept the value from the later document update, with stable value order only as an equal-timestamp tie-break. --prefer does not apply to convergent item scalar conflicts. ${g} Review the merged file, re-apply the discarded change if needed, then "git add" it.`)}return n==="history"&&m.history?.reanchored&&b.push('The merged history chain was re-anchored. Run "pm merge reconcile --dry-run" to inspect the complete post-merge repair, then "pm merge reconcile" to apply it; use --force only after explicitly accepting reported discards.'),{ok:d.length===0,artifact:n,output_path:r,requested_preference:o,conflicts:d,...m,guidance:b,generated_at:S()}}async function Gm(e){if(e.cwd===null)return[];let t=[];for(let n of e.receipts){if(n.operation===void 0||!await Fl(e.cwd,n.item_path,n.operation))continue;let o={gitWorkspaceRoot:e.cwd,receipt:n};await Ee(n.item_id,{dryRun:!0,mergeAbandonmentProof:o},e.global),e.dryRun||(await Ee(n.item_id,{author:e.author??e.global.author,mergeAbandonmentProof:o,message:e.message??`Settle ${n.operation.kind} receipt after exact original Git state restoration`,auditOperation:"merge_reconcile",forceAuditEntry:!0,auditContext:{merge:{abandoned_receipts:[{...Ue(n),reason:"original_git_state_restored",operation:n.operation}]}}},e.global),await Bn(e.cwd,n,{requireExisting:!0,settlement:"original_git_state_restored"})),t.push(n.id)}return t}import{readFile as Lh}from"node:fs/promises";import Mh from"node:path";var Dh=4;function Um(e){let t=e.checks.find(a=>a.name==="integrity"),n=t?.details.counts,o=typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof n.missing_merge_receipt_history_references=="number"?n.missing_merge_receipt_history_references:0,r=t?.details.missing_merge_receipt_history_reference_details,i=t?.details.missing_merge_receipt_history_reference_details_truncated===!0,s=Array.isArray(r)?r.flatMap(a=>{if(typeof a!="object"||a===null||Array.isArray(a))return[];let c=a;return typeof c.item_id=="string"&&typeof c.history_line=="number"&&Number.isSafeInteger(c.history_line)&&typeof c.receipt_id=="string"?[{item_id:c.item_id,history_line:c.history_line,receipt_id:c.receipt_id}]:[]}):[];return{count:o,truncated:i,coordinates:s}}async function jh(e,t){let n=[];for(let o of t){let r;try{r=await Lh(Mh.join(e,"history",`${o.item_id}.jsonl`),"utf8")}catch{continue}let i=r.split(/\r?\n/)[o.history_line-1];if(i===void 0||i.trim().length===0)continue;let s;try{s=JSON.parse(i)}catch{continue}let a=Gl(s,o.item_id).find(c=>c.receiptId===o.receipt_id);a===void 0||!jl(a)||a.eventTimestamp===void 0||ps(a.eventTimestamp,Dl)>=0||n.push({...o,original_event_ts:a.eventTimestamp})}return n}async function Gh(e){if(e.options.dryRun===!0||e.options.force!==!0||e.candidates.length===0)return 0;let t=new Map;for(let n of e.candidates){let o=t.get(n.item_id)??[];o.push(n),t.set(n.item_id,o)}for(let[n,o]of t)await Ee(n,{author:e.options.author??e.global.author,message:e.options.message??"accept unrecoverable pre-durable merge receipt references",force:!0,auditOperation:"merge_reconcile",forceAuditEntry:!0,auditContext:{merge:{missing_receipt_dispositions:o.map(r=>({receipt_id:r.receipt_id,original_history_line:r.history_line,original_event_ts:r.original_event_ts,reason:"legacy_clone_local_only"}))}}},e.global);return e.candidates.length}async function Uh(e){try{return{status:"fulfilled",value:await Ee(e.id,{dryRun:e.dryRun,author:e.options.author??e.global.author,message:e.options.message??"record field-aware branch merge provenance",force:e.options.force,auditOperation:"merge_reconcile",auditContext:e.auditContext,forceAuditEntry:!0,mergeReceiptProof:e.mergeReceiptProof},e.global)}}catch(t){return{status:"rejected",reason:t}}}function qh(e){e.results.forEach((t,n)=>{let o=e.receiptOnlyIds[n];if(t.status==="fulfilled"){let r=t.value.changed?"repaired":"skipped_clean";e.repair.streams.push({id:o,outcome:r,entries_rehashed:t.value.history.entries_rehashed,entries_patch_repaired:t.value.history.entries_patch_repaired,reconciled_with_item:t.value.history.reconciled_with_item,...t.value.merge_receipt_proof?{merge_receipt_proof:t.value.merge_receipt_proof}:{},warnings:t.value.warnings}),e.repair.totals[r]+=1;return}e.repair.streams.push({id:o,outcome:"failed",error:t.reason instanceof Error?t.reason.message:String(t.reason)}),e.repair.totals.failed+=1})}async function zh(e){if(e.dryRun||e.repair.totals.failed>0)return 0;let t=new Set(e.repair.streams.flatMap(o=>o.merge_receipt_proof?.trusted?o.merge_receipt_proof.receipt_ids:[])),n=e.pendingReceipts.filter(o=>t.has(o.id));return await Promise.all(n.map(o=>Bn(e.receiptWorkspaceRoot,o,{requireExisting:!0}))),n.length}function Hh(e,t){if(!(e===0||t))return'If receipt proof is unavailable or competing values were discarded, first review receipts.summaries and repair.streams and re-apply intended values. Only with explicit authority to accept that review, run pm merge reconcile --force --message "<reviewed receipt disposition and rationale>". This appends an audit event; it does not restore missing evidence or discarded values.'}async function Bh(e,t){if(e.force===!0)throw new p("Automatic staging cannot accept forced reconciliation.",u.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"}});let n={...e,stage:!1},{stageLosslessMergeReconciliation:o,resolveMergeSettlementGlobal:r}=await import("./stage-PQ7AB63N.js"),i=await r(t),s=await lo({...n,dryRun:!0},i);return o({preview:s,dryRun:e.dryRun===!0,global:i,apply:()=>lo({...n,dryRun:!1},i)})}async function lo(e,t){return e.stage===!0?Bh(e,t):Wh(e,t)}async function Wh(e,t){let n=e.dryRun===!0,o=x(process.cwd(),t.path),r=await Vt(t,{checkOnly:!0,full:!0,skipVectors:!0,skipDrift:!0}),i=Um(r),s=await jh(o,i.coordinates),a=await zc(o),c=a??o,l=await Nl(c,{includeLossless:!0,pmRoot:o});if(l.invalid_evidence_count>0)throw new p(`Merge reconciliation refused ${l.invalid_evidence_count} invalid receipt evidence file(s).`,u.CONFLICT,{code:"merge_receipt_evidence_invalid",required:"Every clone-local and durable receipt candidate must pass bounded-file, schema, and identity validation.",recovery:{suggested_retry:"pm health --check-only --full"}});Ll(l.receipts.map(L=>L.id),l,n);let d=await Gh({candidates:s,options:e,global:t}),m=l.receipts,f=await Gm({cwd:a,receipts:m,dryRun:n,author:e.author,message:e.message,global:t}),b=new Set(f),g=new Map;for(let L of m.filter(ve=>!b.has(ve.id))){let ve=g.get(L.item_id)??[];ve.push(L),g.set(L.item_id,ve)}let k=Object.fromEntries([...g].map(([L,ve])=>[L,{merge:{receipts:ve.map(Ue)}}])),y=Object.fromEntries([...g].map(([L,ve])=>[L,{gitWorkspaceRoot:a,receipts:ve}])),v=await Wn({dryRun:n,author:e.author??t.author,message:e.message??"post-merge reconciliation of field-aware tracker history",force:e.force,auditOperation:"merge_reconcile",auditContextById:k,...m.length>0?{mergeReceiptProofById:y}:{}},t),_=new Set(v.streams.map(L=>L.id)),A=[...g.keys()].filter(L=>!_.has(L)),N=await $a(A,Dh,L=>Uh({id:L,dryRun:n,options:e,global:t,auditContext:k[L],mergeReceiptProof:y[L]}));qh({receiptOnlyIds:A,results:N,repair:v});let O=await zh({dryRun:n,pendingReceipts:m,repair:v,receiptWorkspaceRoot:c}),B=await Vn({checkHistoryDrift:!0,checkStorageIntegrity:!0},t),$=d===0?r:await Vt(t,{checkOnly:!0,full:!0,skipVectors:!0,skipDrift:!0}),R=Um($),re=B.checks.every(L=>L.status==="ok"),Tt=n?m.length===0:O+f.length===m.length,te=[v.totals.failed===0,re,Tt,R.count===0,!R.truncated].every(Boolean),Ve=i.truncated||R.truncated?"Missing receipt coordinates exceed the bounded detail response; each reviewed --force pass can disposition only the reported eligible batch. Repeat dry-run and --force passes until receipts.missing_history_references_after=0 and pm merge reconcile returns ok=true.":void 0,Ke=Hh(m.length,te),wu=(n?["Review repair.streams, then rerun pm merge reconcile without --dry-run to apply audited repairs.",Ve,Ke,"No Git hook is installed automatically; invoke this command from an explicit post-merge hook only when your repository policy opts in."]:te?["Reconciliation is complete; commit changed history streams with the merge result.","Rerun pm merge reconcile --dry-run after future tracker-data merges as a non-mutating integrity check."]:["Reconciliation remains incomplete; inspect repair failures and non-green validation checks before retrying.",Ve,Ke,...s.length>0&&d===0?["Pre-durable clone-local-only receipt references are eligible for an audited disposition; rerun with --force after reviewing receipts.legacy_disposition_eligible."]:[],"Do not commit repaired history streams as reconciled until pm merge reconcile returns ok=true."]).filter(L=>L!==void 0);return{ok:te,dry_run:n,repair:v,receipts:{pending_before:m.length,reconciled:O,abandoned:f.length,summaries:m.map(Ue),unstaged_durable_receipt_ids:l.unstaged_durable_receipt_ids,missing_history_references_before:i.count,legacy_disposition_eligible:s.length,legacy_disposition_recorded:d,missing_history_references_after:R.count},validation:B,guidance:wu,generated_at:B.generated_at}}var Vh="1h",Kh="now",Jh="+1d";function Te(e,t,n){n!==void 0&&e.push(`${t}="${n.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`)}function qm(e,t,n){let o={type:e,title:t,schedulePreset:"lightweight",parent:n.parent,inheritFocus:n.inheritFocus,allowMissingParent:n.allowMissingParent,tags:n.tags,priority:n.priority,body:n.body,description:n.description,author:n.author,message:n.message};return le(n,o)}async function zm(e,t,n,o){let r=qm(e,t,n),i=[];return Te(i,"start",n.start??Kh),n.end!==void 0?Te(i,"end",n.end):Te(i,"duration",n.duration??Vh),Te(i,"location",n.location),Te(i,"timezone",n.timezone),n.allDay===!0&&Te(i,"all_day","true"),r.event=[i.join(",")],Ce(r,o)}function Hm(e,t,n){return zm("Meeting",e,t,n)}function Bm(e,t,n){return zm("Event",e,t,n)}function Wm(e,t,n){let o=qm("Reminder",e,t),r=[];return Te(r,"at",t.at??Jh),Te(r,"text",t.text??e),o.reminder=[r.join(",")],Ce(o,n)}function en(e){let t={...e.args,...e.options};return le(e.options,t)}function ye(e,t){let n=h(e,t);if(n!==void 0)return n;throw new p(`Missing required parameter: ${t}`,u.USAGE)}function ft(e){return typeof e=="string"?[e]:U(e)}function Vm(e){return ad(en(e),e.global)}function Km(e){let t=en(e),n=t.cursorMode;if(n!==void 0&&n!=="batch"&&n!=="row")throw new p("Mutation event cursor mode must be batch or row.",u.USAGE,{code:"invalid_event_cursor_mode"});let o=n;return cd({cwd:h(t,"cwd"),pmRoot:h(t,"path"),since:h(t,"since"),type:ft(t.type),author:ft(t.author),item:ft(t.item),limit:t.limit===void 0?void 0:Y(t.limit,"limit"),full:t.full===!0,...t.verify===!0?{verify:!0}:{},...o===void 0?{}:{cursorMode:o},...t.provenance===void 0?{}:{provenance:t.provenance===!0},...t.provenanceSummary===void 0?{}:{provenanceSummary:t.provenanceSummary===!0},...t.harness===void 0?{}:{harness:ft(t.harness)},...t.agentInstance===void 0?{}:{agentInstance:ft(t.agentInstance)},...t.provenanceFilter===void 0?{}:{provenanceFilter:ft(t.provenanceFilter)}})}function Jm(e){let t=en(e),n=ye(t,"subcommand");if(n==="install")return Hc({dryRun:t.dryRun===!0,preCommitHook:t.preCommitHook===!0},e.global);if(n==="reconcile")return lo({dryRun:t.dryRun===!0,author:h(t,"author"),message:h(t,"message"),force:t.force===!0,stage:t.stage===!0},e.global);if(n==="report")return Ml({includeReconciled:t.includeReconciled===!0,cwd:h(t,"cwd")});if(n==="driver")return jm({artifact:ye(t,"artifact"),basePath:ye(t,"basePath"),oursPath:ye(t,"oursPath"),theirsPath:ye(t,"theirsPath"),outputPath:h(t,"outputPath")??h(t,"output"),itemPath:h(t,"itemPath"),prefer:h(t,"prefer")},e.global);throw ae({command_path:"merge",token:n,allowed:["install","reconcile","report","driver"],display_name:"merge"})}function Ym(e){let t=en(e),n=ye(t,"subcommand");if(n==="position")return _d(e.global);if(n!=="snapshot")throw ae({command_path:"workspace",token:n,allowed:["position","snapshot"],display_name:"workspace"});let o=h(t,"snapshotAction")??ye(t,"snapshot_action"),r=x(process.cwd(),e.global.path);if(o==="create")return ld(r,{name:h(t,"name")});if(o==="list")return md(r);let i=ye(t,"target");if(o==="inspect")return dd(r,i);if(o==="delete")return fd(r,i);if(o==="restore")return t.dryRun===!0?pd(r,i):ud(r,i,{force:t.force===!0,author:h(t,"author"),message:h(t,"message"),lockTtlSeconds:Y(t.lockTtlSeconds,"lockTtlSeconds"),lockWaitMs:Y(t.lockWaitMs,"lockWaitMs")});throw ae({command_path:"workspace snapshot",token:o,allowed:["create","list","inspect","restore","delete"],display_name:"workspace snapshot",token_kind:"action"})}function mo(e){let t=en(e),n=ye(t,"title");return e.action==="meet"?Hm(n,t,e.global):e.action==="event"?Bm(n,t,e.global):Wm(n,t,e.global)}function Xm(e){return{includeEmpty:e.includeEmpty===!0,storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,fieldUtilization:e.fieldUtilization===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:typeof e.tagPrefix=="string"?e.tagPrefix:void 0,measurements:e.measurements===!0,metric:h(e,"metric"),measurementLimit:typeof e.measurementLimit=="number"?e.measurementLimit:void 0,observe:U(e.observe),direction:typeof e.improvementDirection=="string"?e.improvementDirection:void 0,measurementSource:h(e,"measurementSource"),measurementItem:h(e,"measurementItem"),measurementRevision:h(e,"measurementRevision"),author:h(e,"author"),message:h(e,"message"),provenanceCoverage:e.provenanceCoverage===!0,fleetAttribution:e.fleetAttribution===!0,since:h(e,"since"),eventLimit:typeof e.eventLimit=="number"?e.eventLimit:void 0,minimumSample:typeof e.minimumSample=="number"?e.minimumSample:void 0}}function Zm(e,t,n){let o;if(typeof e.lines=="string")o=dr(e.lines);else if(e.lineRange!==void 0){if(e.lineRange===null||typeof e.lineRange!="object"||Array.isArray(e.lineRange))throw new RangeError("Source line range must be an object with numeric start and end values.");o=dr(`${String(Reflect.get(e.lineRange,"start"))}:${String(Reflect.get(e.lineRange,"end"))}`)}return{paths:t,scope:e.scope==="project"||e.scope==="global"?e.scope:void 0,limit:n(e.limit,"files lookup limit"),offset:n(e.offset,"files lookup offset"),noTruncate:e.noTruncate===!0,strictRead:e.strictRead===!0,explain:e.explain===!0,lineRange:o,decisionDepth:n(e.decisionDepth,"files lookup decision depth")}}function K(e,t){let n=h(e,t);if(!n)throw new p(`Missing required argument: ${t}`,64);return n}function be(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function Yh(e){let t=h(e.args,"subcommand")??K(e.options,"subcommand"),n=e.args.alias??e.options.alias;return{ctx:e,subcommand:t.trim().toLowerCase(),name:h(e.args,"name")??h(e.options,"name"),author:h(e.args,"author")??h(e.options,"author"),force:e.args.force===!0||e.options.force===!0,aliases:n===void 0?void 0:U(n)}}function Xh(e){let{ctx:t,subcommand:n,name:o,author:r,force:i}=e,a=be({list:()=>sl(t.global),show:()=>al(o,t.global),"show-status":()=>cl(o,t.global),"list-fields":()=>ml(t.global),"show-field":()=>pl(o,t.global),"remove-type":()=>nl(o,{author:r,force:i},t.global),"remove-field":()=>dl(o,{author:r,force:i},t.global),"remove-status":()=>il(o,{author:r,force:i},t.global),"apply-preset":()=>ul(h(t.args,"typePreset")??h(t.options,"typePreset"),{author:r,force:i},t.global)},n);return a?a():null}function Zh(e){let{ctx:t,name:n,author:o,force:r,aliases:i}=e,s=t.args.commands??t.options.commands,a=t.args.requiredTypes??t.options.requiredTypes;return ll(n,{type:h(t.args,"fieldType")??h(t.options,"fieldType"),commands:s===void 0?void 0:U(s),description:h(t.args,"description")??h(t.options,"description"),cliFlag:h(t.args,"cliFlag")??h(t.options,"cliFlag"),alias:i,required:t.args.required===!0||t.options.required===!0,requiredOnCreate:t.args.requiredOnCreate===!0||t.options.requiredOnCreate===!0,allowUnset:!(t.args.allowUnset===!1||t.options.allowUnset===!1),requiredTypes:a===void 0?void 0:U(a),author:o,force:r},t.global)}function Qh(e){let{ctx:t,name:n,author:o,force:r,aliases:i}=e,s=t.args.role??t.options.role;return rl(n,{role:s===void 0?void 0:U(s),alias:i,description:h(t.args,"description")??h(t.options,"description"),order:Y(t.args.order??t.options.order,"schema add-status order"),author:o,force:r},t.global)}function eg(e){let{ctx:t,name:n,author:o,force:r,aliases:i}=e;return tl(n,{description:h(t.args,"description")??h(t.options,"description"),defaultStatus:h(t.args,"defaultStatus")??h(t.args,"default_status")??h(t.options,"defaultStatus")??h(t.options,"default_status"),folder:h(t.args,"folder")??h(t.options,"folder"),alias:i,author:o,force:r},t.global)}function tg(e){let{ctx:t,subcommand:n,name:o,author:r,force:i}=e,s=h(t.args,"to")??K(t.options,"to"),a=h(t.args,"migrationId")??h(t.args,"migration_id")??h(t.options,"migrationId")??h(t.options,"migration_id"),c=h(t.args,"fieldTypeScope")??h(t.options,"fieldTypeScope")??h(t.args,"type")??h(t.options,"type"),l=n==="rename-type"?{kind:"rename-type",from:o??"",to:s}:n==="rename-field"?{kind:"rename-field",from:o??"",to:s,...c===void 0?{}:{type:c}}:{kind:"remap-status",from:o??"",to:s};return Qc(l,{migrationId:a,dryRun:t.args.dryRun===!0||t.options.dryRun===!0,author:r,force:i},t.global)}function Qm(e){let t=Yh(e);Xi(t.subcommand,e.args.dryRun===!0||e.options.dryRun===!0);let n=dn.find(r=>r===t.subcommand);if(n)return Zc(n,t.name,{definition:e.args.definition??e.options.definition,policy:h(e.args,"policy")??h(e.options,"policy"),message:h(e.args,"message")??h(e.options,"message"),author:t.author,dryRun:e.args.dryRun===!0||e.options.dryRun===!0},e.global);let o=Xh(t);if(o!==null)return o;if(["rename-type","rename-field","remap-status"].includes(t.subcommand))return tg(t);if(t.subcommand==="add-field")return Zh(t);if(t.subcommand==="add-status")return Qh(t);if(t.subcommand==="add-type")return e.args.infer===!0||e.options.infer===!0?fl({minCount:Y(e.args.minCount??e.options.minCount,"schema infer minCount"),apply:e.args.apply===!0||e.options.apply===!0,author:t.author,force:t.force},e.global):eg(t);throw ae({command_path:"schema",token:t.subcommand,allowed:el,exit_code:64})}function po(e){return h(e.args,"target")??h(e.options,"target")}function q(e,t=e.options){return e.id??K(t,"id")}async function ng(e){let t=Qe("list",e.options);return t.compact===void 0&&t.brief===void 0&&t.full===void 0&&t.fields===void 0&&t.includeBody===void 0&&(t.compact=!0),Nr(await fe(h(e.args,"status")??h(t,"status"),t,e.global),t)}async function og(e){let t=h(e.args,"query")??h(e.args,"keywords")??K(e.args,"query"),n=Qe("search",e.options,[t]);return n.compact===void 0&&n.full===void 0&&n.fields===void 0&&(n.compact=!0),Nr(await Ar(t,n,e.global),n)}async function rg(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options);return H(await Ce(o,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function ig(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options),r={...o,...o.title===void 0&&typeof e.args.title=="string"?{title:e.args.title}:{},...o.message===void 0&&typeof e.args.message=="string"?{message:e.args.message}:{}};return H(await Dr(q(e,r),r,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function sg(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options);return H(await lt(q(e,o),o,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function ag(e){let t=Me(e.options);return t.add===void 0&&t.stdin===void 0&&t.file===void 0&&t.edit===void 0&&t.delete===void 0&&(t.includeMeta=!0),$d(q(e),t,e.global)}function ep(e,t){return xl(Zm(e.options,t,Y),e.global)}function cg(e){let t=U(e.options.lookupPath);if(t&&t.length>0)return ep(e,t);let n=q(e);return e.options.discover===!0?mr(n,Ln(e.options),e.global):Al(n,Wt(Me(e.options)),e.global)}function lg(e){return hd({subcommand:h(e.args,"subcommand")??h(e.options,"subcommand"),limit:Rc(e.args,e.options)},e.global)}function dg(e){let t={...e.options};return t.brief===void 0&&t.summary===void 0&&t.full===void 0&&(t.summary=!0),Vt(e.global,t)}function mg(e){let t=h(e.args,"configAction")??h(e.options,"configAction")??h(e.options,"action");if(t===void 0)throw new p("Missing required argument: configAction",64);let n=h(e.args,"value")??h(e.options,"value"),o=h(e.options,"policy")!==void 0&&n!==void 0?{...e.options,value:n}:e.options,r=h(e.args,"key")??h(e.options,"key");return wl(h(e.args,"scope")??h(e.options,"scope")??Ys(r),t,r,o,e.global,h(e.options,"policy")===void 0?n:void 0)}function pg(e){let t=e.options;return td(ed(t),e.global)}function ug(e,t){if(typeof e=="number"){if(!Number.isFinite(e)||!Number.isInteger(e))throw new p(`${t} must be a finite integer.`,64);return e}if(typeof e=="string"&&e.trim().length>0){let n=e.trim();if(!/^[+-]?\d+(?:st|nd|rd|th)?$/i.test(n))throw new p(`${t} must be a finite integer.`,64);let o=Number.parseInt(n,10);if(!Number.isInteger(o))throw new p(`${t} must be a finite integer.`,64);return o}}async function fg(e){let t=h(e.args,"subcommand")??K(e.options,"subcommand"),n=e.options,{changedFields:o,idOnly:r}=j(e.args,e.options),i=await rm({subcommand:t,id:typeof e.id=="string"?e.id:typeof n.id=="string"?n.id:void 0,stepRef:_g(e),reorderTo:ug(n.reorderTo??e.args.reorderTo,"plan reorderTo"),options:e.options,global:e.global});return t!=="show"&&rr(e.args)&&(i.mutation_receipt=oo(i,void 0)),t==="show"?i:H(i,{changedFields:o,idOnly:r,compactEnvelope:o==="compact"&&!r})}function _g(e){return typeof e.options.stepRef=="string"?e.options.stepRef:typeof e.args.stepRef=="string"?e.args.stepRef:void 0}function hg(e){let t=h(e.args,"subcommand")??K(e.options,"subcommand"),n=t.trim().toLowerCase(),o=h(e.args,"name")??h(e.options,"name"),i=be({list:()=>$m(),show:()=>Fm(o),lint:()=>Pm(o),apply:()=>Nm(o,{dryRun:e.args.dryRun===!0||e.options.dryRun===!0,author:h(e.args,"author")??h(e.options,"author"),force:e.args.force===!0||e.options.force===!0},e.global)},n);if(!i)throw ae({command_path:"profile",token:t,allowed:Om,exit_code:64});return i()}async function gg(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options);return H(await Md(q(e,o),o,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}async function yg(e){let{changedFields:t,runnerOptions:n}=j(e.args,e.options);return H(await lm(Dn(n,!rr(e.args)),e.global),{changedFields:t})}async function bg(e){let{changedFields:t,runnerOptions:n}=j(e.args,e.options),o=h(e.args,"reason"),r=o!==void 0&&n.reason===void 0?{...n,reason:o}:{...n};return e.force&&r.force===void 0&&(r.force=!0),H(await Ud(Mn(r),e.global),{changedFields:t})}async function wg(e){let{changedFields:t,idOnly:n,runnerOptions:o}=j(e.args,e.options),r=h(o,"target")??K(e.args,"target");return H(await vr(q(e,o),r,o,e.global),{changedFields:t,compactEnvelope:t==="compact"&&!n,idOnly:n})}function vg(e){let t={...e.args,...e.options};return Il(K(t,"subcommand"),h(t,"id")??e.id,h(t,"target"),Pc(t),e.global)}function kg(e){return gl(x(process.cwd(),e.global.path),{...e.args,...e.options})}var gi={init:e=>hl(h(e.args,"prefix"),e.global,e.options),context:e=>hr(Qe("context",e.options),e.global),next:e=>gr(Qe("next",e.options),e.global),eval:Vm,events:Km,merge:Jm,workspace:Ym,meet:mo,event:mo,remind:mo,list:ng,get:e=>{let t=q(e);return Sr(t,e.global,Qe("get",e.options,[t]))},search:og,duplicates:e=>{let t=typeof e.options.status=="string"?[e.options.status]:U(e.options.status);return lr(e.global,{exhaustive:e.options.exhaustive===!0,...t.length===0?{}:{status:t},since:h(e.options,"since"),threshold:typeof e.options.threshold=="number"?e.options.threshold:void 0,limit:e.options.limit==="default"?void 0:Y(e.options.limit,"limit")})},create:rg,copy:ig,focus:e=>Gr(e.id,{clear:e.options.clear===!0||e.args.clear===!0},e.global),update:sg,"item-reopen":Wd,restore:wg,claim:zd,release:Bd,"start-task":e=>ze(e,"start_task"),"pause-task":e=>ze(e,"pause_task"),"close-task":e=>ze(e,"close_task"),close:Hd,comments:ag,notes:e=>mm(q(e),Me(e.options),e.global),learnings:e=>Nd(q(e),Me(e.options),e.global),files:cg,docs:e=>kl(q(e),Wt(Me(e.options)),e.global),test:e=>gd(q(e),Me(e.options),e.global),"test-all":e=>yd(e.options,e.global),telemetry:lg,validate:e=>Vn(e.options,e.global,{runUpdate:(t,n,o)=>lt(t,n,o)}),health:dg,assurance:e=>ql(e.args,e.options,e.global),contracts:e=>jn(e.options,e.global),config:mg,activity:pg,aggregate:e=>kr(e.options,e.global),extension:e=>zn(po(e),e.options,e.global),package:e=>zn(po(e),e.options,e.global),install:e=>zn(po(e),{...e.options,install:!0},e.global),upgrade:e=>Hl(po(e),e.options,e.global),delete:e=>jr(q(e),e.options,e.global),deps:e=>vl(q(e),e.options,e.global),graph:vg,"files-discover":e=>mr(q(e),e.options,e.global),"files-lookup":e=>ep(e,U(e.options.paths)),history:e=>sd(q(e),{...e.options,compact:e.options.full===!0||e.options.provenance===!0?!1:e.options.compact!==!1},e.global),"history-redact":e=>Kl(q(e),e.options,e.global),"history-repair":Fd,"history-compact":Pd,"history-attest":e=>Jl(e.options,e.global),"history-author-acknowledge":kg,plan:fg,schema:Qm,profile:hg,stats:e=>xr(e.global,Xm(e.options)),append:gg,"update-many":yg,"close-many":bg,gc:e=>zl(e.global,e.options)};var Oe=new Map;function yi(){Oe.clear()}function tp(e,t){let n=Oe.get(e);if(n!==void 0)return n;if(Oe.size>=50){let r=Oe.keys().next().value;Oe.delete(r)}let o=t().catch(r=>{throw Oe.get(e)===o&&Oe.delete(e),r});return Oe.set(e,o),o}var Wx=Ui,Vx=qi,Kx=Bi,Jx=zi,Yx=Hi;function np(e,t,n,o){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(s,a)=>a.toUpperCase()),i=n.has(r);return{long:t,...o?{short:o}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:i?"string":"boolean",...i?{value_name:e.value_name??"value"}:{}}}function op(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),o=[];for(let r of Ga(e.map(i=>({...i})))){o.push(np(r,r.flag,n,r.short));for(let i of r.aliases??[])o.push(np(r,i,n))}return o}var Xx=op(Fn,yc),Sg=op(Pn,bc);import sp from"node:path";function rp(e){return e.map(t=>({key:t.key,optionName:ys(t),metadataKey:t.metadata_key,type:t.type,commands:[...t.commands],repeatable:t.repeatable,requiredOnCreate:t.required_on_create,...t.description?{description:t.description}:{}}))}function ip(e){return e.map(t=>({command:t.command,action:t.action,arguments:t.arguments.map(n=>({name:n.name,required:n.required===!0,variadic:n.variadic===!0,description:n.description})),description:t.description,tier:t.tier??"standard",family:t.family??"extensions"}))}function Ag(e,t,n){return JSON.stringify([sp.resolve(e),sp.resolve(n??process.cwd()),t.extensions.enabled,t.extensions.disabled,t.extensions.policy])}async function xg(e,t,n){let o=Ag(e,t,n);return tp(o,()=>Eg(e,t,n))}async function Ig(e,t={}){let n=await I(e),o=t.extensionRegistrations??(t.noExtensions===!0?null:await xg(e,n,t.cwd)),r=F(n,o),i=W(n.schema),s=Xe(n.schema);return{types:[...r.types],statuses:i.definitions.map(a=>a.id),openStatus:i.open_status,closeStatus:i.close_status,canceledStatus:i.canceled_status,fields:rp(s.definitions),extensionCommands:ip(o?.commands??[])}}async function Eg(e,t,n){let o=await vn({pmRoot:e,settings:t,cwd:n??process.cwd(),noExtensions:!1}),r=await Sn(o);try{return r.registrations}finally{try{await kn(o,r)}catch{}}}var Cg=new Set(["true","1","yes","on"]),Rg=new Set(["false","0","no","off"]);function Tg(e,t,n=[]){let o=[t,...n];for(let r of o){let i=e[r];if(typeof i=="string"&&i.trim().length>0)return i.trim()}}function Og(e,t,n=[]){let o=[t,...n];for(let r of o){let i=e[r];if(i!==void 0){if(typeof i=="boolean")return i;if(typeof i=="string"){let s=i.trim().toLowerCase();if(Cg.has(s))return!0;if(Rg.has(s))return!1}}}}function $g(e,t,n=[]){for(let o of[t,...n]){let r=e[o],s=(typeof r=="string"?r.split(","):Array.isArray(r)?r.flatMap(a=>typeof a=="string"?a.split(","):[]):[]).map(a=>a.trim()).filter(a=>a.length>0);if(s.length>0)return s}return[]}function z(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function Fg(e){if(typeof e=="number"&&Number.isFinite(e)&&e>=0)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isFinite(t)&&t>=0)return t}}function Pg(e){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=4)return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);if(Number.isInteger(t)&&t>=0&&t<=4)return t}return 2}function Ng(e){if(Array.isArray(e)){let t=e.filter(n=>typeof n=="string").map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(t)).sort((n,o)=>n.localeCompare(o))}return typeof e=="string"?$t(e):[]}function Lg(e){let t=z(e);if(t){let n=Ne(t);if(n)return n}return"open"}function wi(e){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isInteger(t)?t:void 0}function ap(e){if(typeof e=="boolean")return e;if(typeof e=="number")return e===1?!0:e===0?!1:void 0;if(typeof e!="string")return;let t=e.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:void 0}function _t(e){if(!Array.isArray(e))return;let t=e.map(n=>z(n)).filter(n=>n!==void 0);return t.length>0?t:void 0}function bi(e){return dp(e,z)}function cp(e){return dp(e,pp)}function Mg(e,t){if(typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=100)return e;let n=z(e)?.toLowerCase();if(!n)return;let o=n==="med"?"medium":n;if(t.some(i=>i===o))return o;let r=Number(o);return Number.isInteger(r)&&r>=0&&r<=100?r:void 0}function lp(e,t){let n=z(e)?.toLowerCase();if(!n)return;let o=n==="med"?"medium":n;return t.includes(o)?o:void 0}function vi(e){return z(e)?.toLowerCase()==="global"?"global":"project"}function Dg(e,t){let n=ki(e,t.allowScalar===!0);if(!n)return;let o=n.map(r=>Hg(r,t)).filter(r=>r!==void 0);return o.length>0?o:void 0}function jg(e,t={}){return mp(e,t,(n,o)=>({path:n,scope:vi(o?.scope),note:z(o?.note)}))}function Gg(e,t={}){return mp(e,t,(n,o)=>({path:n,scope:vi(o?.scope),note:z(o?.note)}))}function Ug(e){let t=(Array.isArray(e)?e:[]).filter(o=>typeof o=="object"&&o!==null&&!Array.isArray(o)&&typeof o.field=="string"&&ws(o.field)!==void 0&&typeof o.reason=="string"&&o.reason.trim().length>0),n=new Map(t.map(o=>[o.field,{field:o.field,reason:o.reason}]));return ks([...n.values()])}function qg(e,t={}){let n=ki(e,t.allowScalar===!0);if(!n)return;let o=n.map(r=>Vg(r,t)).filter(r=>r!==void 0);return o.length>0?o:void 0}function zg(e,t){return C(e,t)}function fo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ki(e,t){return Array.isArray(e)?e:t?[e]:void 0}function uo(e,t){for(let n of t){let o=z(e[n]);if(o)return o}}function dp(e,t){if(!fo(e))return;let n=Object.entries(e).map(([o,r])=>[o.trim(),t(r)]).filter(o=>o[0].length>0&&o[1]!==void 0);return n.length>0?Object.fromEntries(n):void 0}function Hg(e,t){if(typeof e=="string")return Bg(e,t);if(!fo(e))return;let n=uo(e,t.textKeys??["text"]);if(!n)return;let o=t.createdAtKey??"created_at",r=t.authorKey??"author";return{created_at:(t.toIsoString?t.toIsoString(e[o]):z(e[o]))??t.fallbackCreatedAt,author:z(e[r])??t.fallbackAuthor,text:n}}function Bg(e,t){let n=z(e);return n?{created_at:t.fallbackCreatedAt,author:t.fallbackAuthor,text:n}:void 0}function mp(e,t,n){let o=ki(e,t.allowScalar===!0);if(!o)return;let r=t.pathKeys??["path"],i=o.map(s=>Wg(s,r,n)).filter(s=>s!==void 0);return i.length>0?i:void 0}function Wg(e,t,n){if(typeof e=="string"){let r=z(e);return r?n(r):void 0}if(!fo(e))return;let o=uo(e,t);return o?n(o,e):void 0}function Vg(e,t){if(typeof e=="string"){let r=z(e);return r?{command:r,scope:"project"}:void 0}if(!fo(e))return;let n=uo(e,t.commandKeys??["command"]),o=uo(e,t.pathKeys??["path"]);if(!(!n&&(t.requireCommand===!0||!o)))return{...n?{command:n}:{},...o?{path:o}:{},scope:vi(e.scope),timeout_seconds:Kg(e.timeout_seconds,t),note:z(e.note),...typeof e.phase=="string"&&e.phase.trim().toLowerCase()==="setup"?{phase:"setup"}:{},...t.includeExtendedAssertions===!0?Jg(e):{}}}function Kg(e,t){let n=t.integerTimeout===!0?wi(e):pp(e);if(n===void 0)return;let o=t.timeoutMinimum??0;return t.timeoutExclusiveMinimum===!0?n>o?n:void 0:n>=o?n:void 0}function pp(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||e.trim().length===0)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function Jg(e){return{pm_context_mode:lp(e.pm_context_mode,["schema","tracker","auto"]),env_set:bi(e.env_set),env_clear:_t(e.env_clear),shared_host_safe:ap(e.shared_host_safe),assert_stdout_contains:_t(e.assert_stdout_contains),assert_stdout_regex:_t(e.assert_stdout_regex),assert_stderr_contains:_t(e.assert_stderr_contains),assert_stderr_regex:_t(e.assert_stderr_regex),assert_stdout_min_lines:wi(e.assert_stdout_min_lines),assert_json_field_equals:bi(e.assert_json_field_equals),assert_json_field_gte:cp(e.assert_json_field_gte)}}async function Yg(e){await P(e)}function up(){return{metadata:{},body:""}}function Xg(e){return[...Object.entries(e.metadata).filter(([,n])=>n!==void 0).map(([n])=>n),...e.body.length>0?["body"]:[]].sort()}async function Zg(e){let{pmRoot:t,id:n,itemPath:o,author:r,message:i,settings:s,conflictWarningPrefix:a}=e,c={...e.document,metadata:{...e.document.metadata}};vs(c.metadata),pa(c.metadata,t);let l=Mt(c),d=me(t,n),m=up(),f;try{f=await Dt(t,n,s.locks.ttl_seconds,r,!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(b){if(b instanceof p&&b.exitCode===u.CONFLICT)return{committed:!1,conflictWarning:`${a}:${n}`};throw b}try{let b=F(s,T()).type_to_folder;if(await ne(t,n,s.id_prefix,s.item_format,b))return{committed:!1,conflictWarning:`${a}:${n}`};let g=await Cn({pmRoot:t,settings:s,operation:"import",author:r,before:null,after:l});return await An({pm_root:t,operation:"import",before:null,after:l,changed_fields:Xg(l),author:r,sdk:Tn({pmRoot:t,settings:s,typeToFolder:b})}),await f.fence(async()=>{await se(o,Lt(l,{format:"toon"}));try{let y=jt({nowIso:S(),author:r,op:"import",before:m,after:l,message:i,context:g.decisions.length===0?void 0:{workflow_policies:g.decisions}});await Gt(d,y)}catch(y){throw await Ft(o),y}}),{committed:!0,writeWarnings:[...g.warnings,...await G({path:o,scope:"project",op:"import",item_id:l.metadata.id,item_type:l.metadata.type,before:m,after:l,changed_fields:["imported"]}),...await G({path:d,scope:"project",op:"import:history",item_id:l.metadata.id,item_type:l.metadata.type,before:m,after:l,changed_fields:["imported"]})]}}finally{await f.release()}}import{readFile as ey}from"node:fs/promises";import ty from"node:path";function Qg(e){return e.trim().toLowerCase().replaceAll("_","-")}var Ai=[{id:"capabilities",aliases:["capability-map","families","routing"],title:"Generated Capability Routing",summary:"Route work through command families generated from the canonical agent capability contract.",intent:"Use this as the drift-free entrypoint when selecting a CLI, MCP, completion, documentation, or extension command surface.",commands:Uc().flatMap(({commands:e})=>e.map(t=>`pm ${t}`)),workflows:[],docs:[{path:"docs/generated/AGENT_CAPABILITY_ROUTING.md",purpose:"Generated command-to-family routing table."},{path:"docs/generated/AGENT_COMMAND_SURFACE.md",purpose:"Generated visibility-tier and family table."}],related:["commands","workflows","extensions"]},{id:"quickstart",aliases:["start","getting-started","bootstrap"],title:"Quickstart",summary:"Initialize a tracker and run the shortest safe plan -> execute -> close loop.",intent:"Use this when a human or agent needs to start productive work quickly with minimal context load.",commands:["pm workspace init","pm workspace config --help","pm workspace schema --help","pm workspace profile --help","pm context --limit 10","pm list --status open --limit 20",'pm create --create-mode progressive --title "..." --description "..." --type Task',"pm claim <ID>","pm update <ID> --status in_progress",'pm close <ID> "<reason>" --resolution "<change>" --expected "<expected outcome>" --actual "<observed outcome>" --validate-close warn'],workflows:[{name:"Start Session Safely",goal:"Bootstrap without mutating unrelated state.",prompt:"You are bootstrapping pm work. Use a token-efficient context snapshot first, then select one open item, claim it, and only then mutate.",commands:["pm context --limit 10","pm list --status open --limit 20","pm claim <ID>"]}],docs:[{path:"README.md",purpose:"High-level project and install entrypoint."},{path:"docs/QUICKSTART.md",purpose:"Short setup and first-command walkthrough."},{path:"docs/COMMANDS.md",purpose:"Task-oriented command recipes."}],related:["commands","workflows","release"]},{id:"commands",aliases:["cli","operations","reference"],title:"CLI Command Routing",summary:"Find the right command family quickly and use command-scoped help/contracts output.",intent:"Use this when selecting command paths, flags, and output formats for implementation or automation.",commands:["pm --help","pm <command> --help","pm <command> --help --explain","pm contracts --command <command> --flags-only","pm contracts --command <command> --availability-only --runtime-only","pm completion <bash|zsh|fish>"],workflows:[{name:"Flag Discovery",goal:"Resolve command flags deterministically before mutations.",prompt:"You are preparing to run a command. Use help and contracts surfaces to verify required/optional flags before execution.",commands:["pm <command> --help --explain","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/COMMANDS.md",purpose:"Command grouping and examples."},{path:"docs/CONFIGURATION.md",purpose:"Project/global settings and policy controls."},{path:"docs/TESTING.md",purpose:"Linked-test orchestration and safety guidance."}],related:["quickstart","workflows","sdk","extensions"]},{id:"workflows",aliases:["developer","maintainer","agent"],title:"Developer and Agent Workflows",summary:"Apply canonical claim -> execute -> verify -> close workflows with append-only evidence.",intent:"Use this for day-to-day coding-agent execution loops and handoff-safe updates.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add ...","pm test <ID> --add ...",'pm comments <ID> "..."',"pm validate --check-resolution --check-history-drift","pm release <ID>"],workflows:[{name:"Execution Loop",goal:"Keep code, tests, and tracker evidence synchronized.",prompt:"You are implementing a scoped change. Claim first, link files/tests/docs as you go, append evidence comments, and close only after validation.",commands:["pm claim <ID>","pm update <ID> --status in_progress","pm files <ID> --add path=<file>,scope=project","pm test <ID> --run --progress",'pm close <ID> "<reason>" --resolution "<change>" --expected "<expected outcome>" --actual "<observed outcome>" --validate-close warn']}],docs:[{path:"AGENTS.md",purpose:"Repository operating rules and required workflow."},{path:"docs/AGENT_GUIDE.md",purpose:"Agent-oriented usage and context strategy."},{path:"docs/TESTING.md",purpose:"Sandbox-safe test execution rules."}],related:["quickstart","commands","skills"]},{id:"sdk",aliases:["api","typescript-sdk"],title:"SDK and Integrations",summary:"Use the published SDK surface for extension authoring and contract-safe integrations.",intent:"Use this when building or reviewing programmatic integrations against @unbrained/pm-cli/sdk.",commands:["pm contracts --schema-only","pm contracts --command extension --flags-only","pm contracts --runtime-only --availability-only"],workflows:[{name:"Integration Contract Check",goal:"Confirm action schemas and runtime availability before coding.",prompt:"You are wiring an integration. Capture schema + runtime availability first, then map your adapter payload fields to contract keys.",commands:["pm contracts --schema-only","pm contracts --availability-only --runtime-only","pm contracts --command <command> --flags-only"]}],docs:[{path:"docs/SDK.md",purpose:"Public SDK exports and extension authoring references."},{path:"docs/ARCHITECTURE.md",purpose:"Core runtime composition and extension load flow."}],related:["extensions","commands"]},{id:"extensions",aliases:["plugins","extension-authoring","packages","package-authoring"],title:"Packages and Extensions",summary:"Install, author, and diagnose packages/extensions with deterministic lifecycle controls.",intent:"Use this for package management, extension capability registration, and runtime diagnostics.",commands:["pm package install <target> --project","pm package upgrade --dry-run","pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm package activate <target> --project","pm package deactivate <target> --project"],workflows:[{name:"Lifecycle Triage",goal:"Diagnose extension state before forceful lifecycle actions.",prompt:"You are debugging package behavior. Inspect managed state first, then run doctor diagnostics, then apply install/adopt/activate actions.",commands:["pm package explore --project","pm package manage --detail summary","pm package doctor --detail deep","pm package upgrade --packages-only --dry-run"]}],docs:[{path:"docs/EXTENSIONS.md",purpose:"Capability model and lifecycle command usage."},{path:"docs/examples/starter-extension/README.md",purpose:"Starter extension scaffold and local development path."},{path:"docs/SDK.md",purpose:"SDK contracts used by extension implementations."}],related:["sdk","commands","skills"]},{id:"skills",aliases:["agent-skills","agentskills"],title:"Agent Skills",summary:"Skill bundles for developer, user, extensions, and sdk workflows aligned to the current CLI.",intent:"Use this when an agent needs reproducible prompts/workflows with strict compatibility metadata.",commands:["pm guide skills --depth deep","pm contracts --command guide --flags-only","pm validate --check-command-references"],workflows:[{name:"Skill Selection",goal:"Pick the narrowest compatible skill first to minimize context usage.",prompt:"Select a pm skill based on the task intent, then execute only the workflow section needed for the current change.",commands:["pm guide skills","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent-first usage and context model."},{path:"docs/README.md",purpose:"Documentation routing with progressive disclosure."},{path:".agents/skills/README.md",purpose:"Agent skills index and routing overview."},{path:".agents/skills/pm-developer/SKILL.md",purpose:"Developer-oriented pm skill workflow."},{path:".agents/skills/pm-user/SKILL.md",purpose:"User/operator pm skill workflow."},{path:".agents/skills/pm-extensions/SKILL.md",purpose:"Extension-focused pm skill workflow."},{path:".agents/skills/pm-sdk/SKILL.md",purpose:"SDK integration pm skill workflow."}],related:["workflows","harnesses","commands"]},{id:"harnesses",aliases:["compatibility","agent-compatibility"],title:"Agent Harness Compatibility",summary:"Cross-harness compatibility guidance for docs routing.",intent:"Use this when adapting pm docs and SDK contracts for an external automation harness.",commands:["pm guide skills","pm guide commands","pm contracts --runtime-only --availability-only"],workflows:[{name:"Harness Mapping",goal:"Route each harness to the same canonical skill/docs sources.",prompt:"Map harness-specific entrypoints to the same pm guide topics and .agents/skills workflows without adding runtime harness-specific code.",commands:["pm guide harnesses --depth standard","pm guide skills --depth deep"]}],docs:[{path:"docs/AGENT_GUIDE.md",purpose:"Agent context and output-mode conventions."},{path:"docs/README.md",purpose:"Single-source documentation routing entrypoint."},{path:".agents/skills/HARNESS_COMPATIBILITY.md",purpose:"Harness compatibility matrix and usage notes."}],related:["skills","workflows"]},{id:"release",aliases:["gates","ship","release-readiness"],title:"Release and Staleness Gates",summary:"Run release gates and docs/skills freshness checks before publishing.",intent:"Use this when validating release readiness and preventing docs/skills drift.",commands:["pnpm build","pnpm test:coverage","pnpm quality:static","node scripts/release/run-gates.mjs --telemetry-mode best-effort","pnpm security:scan"],workflows:[{name:"Pre-Release Gate Sweep",goal:"Ensure code, docs, and skills are all green before publish.",prompt:"Run release gates in deterministic order and treat docs/skills freshness failures as release blockers.",commands:["pnpm build","pnpm test:coverage","node scripts/release/run-gates.mjs --telemetry-mode best-effort"]}],docs:[{path:"docs/RELEASING.md",purpose:"Release flow and safety checks (repository checkout only; excluded from the npm package).",optional:!0},{path:"CHANGELOG.md",purpose:"Versioned release history and unreleased notes (repository checkout only; excluded from the npm package).",optional:!0},{path:"scripts/release/run-gates.mjs",purpose:"Source of truth for release gate ordering (repository checkout only; not in the npm package).",optional:!0}],related:["commands","skills","workflows"]},{id:"tokens",aliases:["output","budget","context-cost","projections"],title:"Read Output and Token Budgets",summary:"Bound what a read costs before it is emitted, and resume the part a budget withheld.",intent:"Use this when an agent must keep context small: every read declares a token ceiling, degrades deterministically, and reports what it omitted.",commands:["pm contracts --summary --json","pm list --status open --output-limit 20","pm get <ID> --output-include id,title,status,dependencies","pm context --limit 10 --token-accounting","pm notes <ID> --output-cursor <cursor>","pm list --status closed --output-budget unbounded"],workflows:[{name:"Bound A Read Before Emitting It",goal:"Never pay for rows the task does not need.",prompt:"Choose the narrowest projection first, then a row limit, then a token budget. Read the omission receipt before concluding the result is complete.",commands:["pm contracts --command list --flags-only --json","pm list --status open --output-limit 20 --output-format toon","pm list --status open --token-accounting"]},{name:"Recover A Truncated Read",goal:"Continue a bounded read instead of re-running it unbounded.",prompt:"When output_budget_truncation appears, prefer the declared continuation cursor. Only widen the budget when the response declares no cursor.",commands:["pm notes <ID> --output-cursor <cursor>","pm get <ID> --output-budget 20000"]}],docs:[{path:"docs/READ_OUTPUT_CONTRACTS.md",purpose:"Budget, truncation, continuation, and omission receipts."},{path:"docs/OUTPUT_PROJECTION_CONTRACTS.md",purpose:"Field and section projection grammar for every read."},{path:"docs/OUTPUT_TOKEN_ACCOUNTING.md",purpose:"Per-section token cost receipts."},{path:"docs/ITEM_READ_PROJECTIONS.md",purpose:"Item-level projection defaults and restore hints."}],related:["commands","workflows","quickstart"]},{id:"graph",aliases:["relationships","deps","dependencies","analytics"],title:"Relationship Graph and Planning Analytics",summary:"Type the relationships between items, then read the project as a graph rather than as a list.",intent:"Use this when the question is about lineage, ordering, blast radius, bottlenecks, or which work reaches a declared outcome.",commands:["pm deps <ID>",'pm update <ID> --dep "id=<other>,kind=implements"',"pm graph analyze","pm graph impact <ID> --direction downstream","pm graph paths <ID> <ID>","pm graph audit"],workflows:[{name:"Place New Work In The Ladder",goal:"Every item resolves to an outcome through a typed, explainable path.",prompt:"Set parent lineage first, then add typed edges that cite durable evidence. Never add an edge to satisfy a count.",commands:['pm search "<topic>" --limit 10','pm update <ID> --dep "id=<parent-goal>,kind=implements"',"pm graph ancestors <ID>"]},{name:"Assess Blast Radius Before Changing Something",goal:"Know what derives from an item before touching it.",prompt:"Walk the directed graph downstream from the item, then check whether any bottleneck node sits on the path.",commands:["pm graph impact <ID> --direction downstream","pm graph dominators <ID>","pm graph articulation"]}],docs:[{path:"docs/RELATIONSHIP_GRAPH.md",purpose:"Graph model, traversal verbs, and analytics surface."},{path:"docs/DEPENDENCY_KIND_CONTRACT.md",purpose:"Every typed edge kind, its direction, and its semantics."}],related:["commands","workflows","assurance"]},{id:"assurance",aliases:["gates","invariants","measurements","quality"],title:"Declared Invariants and Gates",summary:"Express a project's own quality rules as tracked data the SDK evaluates, instead of as scripts.",intent:"Use this when a rule must hold over the record itself \u2014 a floor, a ceiling, or a monotone property \u2014 and must fail closed in CI.",commands:["pm assurance list","pm assurance run <gate-id> --trigger ci --dry-run","pm validate --check-resolution --check-history-drift","pm health --summary"],workflows:[{name:"Add An Invariant Rather Than A Script",goal:"A new enforcement gap becomes declared data, not a new bespoke gate script.",prompt:"Define the measurement, bind an assertion with an explicit bound and polarity, prove a negative control, then attach it to a trigger.",commands:["pm assurance list --json","pm assurance run <gate-id> --trigger ci --dry-run --json"]},{name:"Read A Verdict Before Believing It",goal:"Know which population a passing assertion speaks for.",prompt:"Read population_size and scope on every assertion. A gate that cannot fail for the reason it exists is not evidence.",commands:["pm assurance run <gate-id> --trigger ci --dry-run --json --output-budget unbounded"]}],docs:[{path:"docs/ASSURANCE.md",purpose:"Measurement, assertion, gate, and trigger vocabulary."},{path:"docs/MUTATION_INTEGRITY.md",purpose:"What every mutation must record to remain provable."}],related:["release","graph","workflows"]},{id:"merge",aliases:["branches","concurrency","multi-agent","fleet"],title:"Branching, Merging, and Concurrent Agents",summary:"Keep tracker data and history conflict-free while many agents work on separate branches.",intent:"Use this when more than one agent or worktree mutates the same tracker and the results must merge without hand resolution.",commands:["pm merge install","pm merge report","pm merge reconcile --dry-run","pm claim <ID>","pm release <ID>","pm validate --check-history-drift","pm health --check-only"],workflows:[{name:"Prepare A Clone For Field-Aware Merges",goal:"The committed merge fence needs clone-local driver configuration once.",prompt:"Run the merge installer in every fresh clone or worktree before the first branch merge of tracker data.",commands:["pm merge install","pm health --check-only"]},{name:"Settle A Merge Before Trusting Health",goal:"A lossless merge still leaves pending receipts that strict health reports until they are reconciled.",prompt:"After any branch merge that touched tracker data, read the merge report, preview the reconciliation, then apply it; only then treat a health verdict as a statement about the data.",commands:["pm merge report","pm merge reconcile --dry-run",'pm merge reconcile --message "Post-merge history reconciliation"',"pm health --check-only"]},{name:"Hand Work Between Agents Safely",goal:"Ownership and evidence survive the handoff.",prompt:"Claim before substantial edits, record evidence as comments, and release the claim when pausing, handing off, closing, or canceling.",commands:["pm claim <ID>",'pm comments <ID> "Handoff: <state and next step>"',"pm release <ID>"]}],docs:[{path:"docs/MERGE_SAFETY.md",purpose:"Merge driver, field-aware resolution, and clone setup."},{path:"docs/SDK_CONTEXT_COORDINATION.md",purpose:"Coordination primitives for concurrent agents."}],related:["workflows","assurance","commands"]},{id:"evidence",aliases:["record","annotations","learnings","history-maintenance"],title:"Evidence, Durable Knowledge, and Record Maintenance",summary:"Append comments, notes, learnings, files, docs, and tests to items, and maintain the immutable history those records live in.",intent:"Use this when work must be explained to the next agent, when a durable lesson should outlive the item, or when a history stream needs verification, repair, redaction, compaction, or author attribution.",commands:['pm comments <ID> "<progress or verification evidence>"','pm notes <ID> --add "<rationale that belongs on the item>"','pm learnings <ID> --add "<lesson that should outlive the item>"',"pm append <ID> --body -","pm files <ID> --add path=<path>,scope=project,note=<why>","pm history <ID> --verify --strict-exit","pm history-repair --all --dry-run","pm history-redact <ID> --literal <secret> --dry-run","pm history-compact <ID> --dry-run","pm history-author-acknowledge --all-actionable --dry-run","pm close-many --ids <ID>,<ID> --reason <text> --dry-run","pm test-all --status open --limit 10 --progress"],workflows:[{name:"Record While Working, Not After",goal:"Another agent can rebuild the full situation from the item alone.",prompt:"Add a comment for each verified step, a note for each rationale the item body does not carry, and a learning for each lesson that applies beyond this item. Prefer appending over rewriting.",commands:['pm comments <ID> "Evidence: <what changed and what passed>"','pm notes <ID> --add "Decision log: <why this shape>"','pm learnings <ID> --add "<durable lesson>"',"pm learnings <ID> --limit 5"]},{name:"Verify And Repair A History Stream",goal:"Every mutation stays provable and the chain re-anchors after drift.",prompt:"Verify the chain with a strict exit before trusting a stream, preview any repair, and record why the repair was needed in the audit message.",commands:["pm history <ID> --verify --strict-exit","pm history-repair --all --dry-run",'pm history-repair --all --message "<why the chain drifted>"',"pm validate --check-history-drift"]},{name:"Redact, Compact, Or Attribute Without Losing Proof",goal:"Sensitive text, stream length, and unknown authors are handled through audited rewrites.",prompt:"Preview every history rewrite with --dry-run, read the receipt, then apply. Compaction renumbers ordinal versions, so record the checkpoint it created.",commands:["pm history-redact <ID> --literal <secret> --dry-run","pm history-compact <ID> --dry-run","pm history-author-acknowledge --all-actionable --dry-run"]}],docs:[{path:"docs/COMMANDS.md",purpose:"Annotation, bulk, and history-and-recovery command families."},{path:"docs/MUTATION_INTEGRITY.md",purpose:"Provenance and content-safety policy every mutation shares."},{path:"docs/AGENT_GUIDE.md",purpose:"Evidence expectations in the agent loop and self-repair remediation."}],related:["workflows","assurance","merge","graph"]},{id:"automation",aliases:["calendar","reminders","meetings","events"],title:"Reminders, Events, and Meetings",summary:"Attach time to items so context and agenda views can surface deadlines, meetings, and reminders when they matter.",intent:"Use this when an item needs a due signal, a scheduled event, or a meeting record that later context reads should surface.",commands:["pm package install calendar --project","pm calendar remind <title> --at <when> --parent <ID>","pm calendar event <title> --start <when> --parent <ID>","pm calendar meet <title> --start <when> --duration 30min --parent <ID>","pm context --limit 10"],workflows:[{name:"Put A Deadline Where Context Will Find It",goal:"Time-bound work surfaces in the agenda section of context reads.",prompt:"Install calendar, then record the reminder or event under its owning item and confirm it in context. Use explicit min or mo for durations; bare m is ambiguous.",commands:["pm package install calendar --project","pm calendar remind <title> --at <when> --parent <ID>","pm context --limit 10"]}],docs:[{path:"docs/COMMANDS.md",purpose:"Calendar and context command family."},{path:"packages/pm-calendar/README.md",purpose:"Package commands, duration units, and compatibility aliases."}],related:["workflows","quickstart","extensions"]}],Si=new Map;for(let e of Ai){Si.set(e.id,e);for(let t of e.aliases)Si.set(t,e)}function fp(){return Ai.map(e=>({...e,aliases:[...e.aliases],commands:[...e.commands],workflows:e.workflows.map(t=>({...t,commands:[...t.commands]})),docs:e.docs.map(t=>({...t})),related:[...e.related]}))}function _o(){return Ai.map(e=>e.id)}function _p(e){if(!e)return null;let t=Qg(e);return t?Si.get(t)??null:null}var ny=["markdown","toon","json"],oy=["brief","standard","deep"];function ry(e){if(!e)return;let t=e.trim().toLowerCase();if(!ny.includes(t))throw new p("Guide format must be one of markdown|toon|json",u.USAGE);return t}function iy(e,t){let n=ry(e.format);if(t.json&&n&&n!=="json")throw new p("Cannot combine --json with --format markdown|toon",u.USAGE);return t.json?"json":n??"toon"}function sy(e){if(!e)return"brief";let t=e.trim().toLowerCase();if(!oy.includes(t))throw new p("Guide depth must be one of brief|standard|deep",u.USAGE);return t}function ay(){return Ms(process.env,"PM_CLI_PACKAGE_ROOT",import.meta.url,["..","..",".."])}function hp(e){return e.replaceAll(`\r
71
+ `,`
72
+ `)}function cy(e,t,n){let r=hp(e).split(`
73
+ `),s=r.slice(0,t).join(`
74
+ `),a=r.length>t;return s.length>n&&(s=s.slice(0,n),a=!0),{excerpt:s.trimEnd(),truncated:a,lineCount:r.length}}async function ly(e,t,n){let o=t!=="brief",r=o?t==="deep"?"full":"excerpt":"none",i=[];for(let s of e.docs){let a=ty.resolve(n,s.path);if(!o){i.push({path:s.path,purpose:s.purpose,optional:s.optional===!0,exists:!0,line_count:null,content_mode:"none",content:null,truncated:!1});continue}try{let c=await ey(a,"utf8");if(t==="deep"){let l=hp(c).trimEnd();i.push({path:s.path,purpose:s.purpose,optional:s.optional===!0,exists:!0,line_count:l.length===0?0:l.split(`
75
+ `).length,content_mode:"full",content:l,truncated:!1})}else{let l=cy(c,120,12e3);i.push({path:s.path,purpose:s.purpose,optional:s.optional===!0,exists:!0,line_count:l.lineCount,content_mode:r,content:l.excerpt,truncated:l.truncated})}}catch(c){let l=Je(c);if(i.push({path:s.path,purpose:s.purpose,optional:s.optional===!0,exists:!1,line_count:null,content_mode:"none",content:null,truncated:!1}),!l)throw new p(`Failed to read guide document "${s.path}".`,u.GENERIC_FAILURE)}}return i}function dy(e){let t=fp().map(n=>({id:n.id,aliases:n.aliases,title:n.title,summary:n.summary,intent:n.intent,quick_commands:e==="brief"?n.commands.slice(0,3):n.commands.slice(0,6),docs:n.docs.map(o=>({path:o.path,purpose:o.purpose})),related:n.related}));return{output_default:"toon",mode:"index",depth:e,topics:t,suggested_next_steps:["pm guide <topic>","pm guide <topic> --depth standard","pm guide <topic> --depth deep --format markdown","pm guide <topic> --json"]}}function my(e){let t=_p(e);if(t)return t;let n=_o().join(", ");throw new p(`Unknown guide topic "${e}". Available topics: ${n}. Use "pm guide --list" to browse.`,u.USAGE)}async function py(e,t){let n=sy(typeof e.depth=="string"?e.depth:void 0),o=e.list===!0,r=typeof e.topic=="string"?e.topic:void 0;if(o||!r)return dy(n);let i=my(r),s=ay(),a=await ly(i,n,s),c=a.filter(l=>!l.exists&&!l.optional).map(l=>`Missing required guide document: ${l.path}`);return{output_default:"toon",mode:"topic",depth:n,requested_topic:r,topic:i,docs:a,warnings:c}}function uy(e){return e.replaceAll("```","``\\`")}function fy(e){if(e.mode==="index"){let n=["# pm guide","","Token-efficient local documentation index for agent and maintainer workflows.","","## Topics"];for(let o of e.topics)n.push(`- \`${o.id}\` - ${o.summary}`),e.depth!=="brief"&&(n.push(` - intent: ${o.intent}`),n.push(` - docs: ${o.docs.map(r=>`\`${r.path}\``).join(", ")}`));n.push("","## Next steps");for(let o of e.suggested_next_steps)n.push(`- \`${o}\``);return n.join(`
76
+ `)}let t=[`# pm guide ${e.topic.id}`,"",e.topic.summary,"","## Intent",e.topic.intent,"","## Key commands",...e.topic.commands.map(n=>`- \`${n}\``),"","## Workflow prompts"];for(let n of e.topic.workflows)t.push(`### ${n.name}`),t.push(`goal: ${n.goal}`),t.push(`prompt: ${n.prompt}`),t.push("commands:"),t.push(...n.commands.map(o=>`- \`${o}\``)),t.push("");t.push("## Documents");for(let n of e.docs){let o=n.exists?"available":n.optional?"missing (optional)":"missing (required)";t.push(`- \`${n.path}\` - ${n.purpose} (${o})`),n.exists&&n.content_mode!=="none"&&n.content&&(t.push(""),t.push(`### Excerpt: \`${n.path}\``),n.truncated&&t.push("_truncated for context efficiency_"),t.push("```markdown"),t.push(uy(n.content)),t.push("```"))}return e.topic.related.length>0&&(t.push("","## Related topics"),t.push(...e.topic.related.map(n=>`- \`${n}\``))),e.warnings.length>0&&(t.push("","## Warnings"),t.push(...e.warnings.map(n=>`- ${n}`))),t.join(`
77
+ `)}var _y=[...Pt],hy=[...Io],tn=new Set(Vi.filter(e=>e.hidden).map(e=>e.alias)),nn=Gc("full").filter(e=>!e.includes(" ")&&!tn.has(e)),gp=E(Fn),yp=E(qa),bp=E(Xa),wp=E(rc),ho=nr("restore",Ie("restore")),go=nr("history-attest",Ie("history-attest")),vp=E(ic),kp=E(Za),Sp=E(Qa),Ap=E(oc),xp=E(mc),Ip=E(sc),Ep=E(ac),Cp=E(Ya),ht=[...new Set(J.map(e=>e.canonical_argv[0]))],on=[...new Set(J.flatMap(e=>e.canonical_argv.slice(0,-1).map((t,n)=>e.canonical_argv.slice(0,n+1).join(" "))))],gy=new Set(ja.filter(e=>e.disposition==="package_owned").map(e=>So(e.command))),Rp=J.filter(e=>e.canonical_argv[0]==="history"),Tp=Rp.map(e=>e.canonical_argv[1]).join(" ");function gt(e){let t=new Set((e.namespace_commands??[]).map(So)),n=J.filter(o=>jc(o.canonical)!=="internal"&&(!gy.has(o.alias)||t.has(o.alias)));return Object.fromEntries(on.map(o=>[o,[...new Set(n.filter(r=>r.canonical.startsWith(`${o} `)).map(r=>r.canonical_argv[o.split(" ").length]))].join(" ")]))}var Op=Rp.map(e=>({...e,flags:E(Ie(e.alias))})),xi=E(za),$p=E(Ha,!1),Fp=E(lc),Pp=E(cc),Np=E(dc),Lp=E(_c),Mp=E(uc),Dp=E(tc),jp=E(fc),Gp=E(pc),Up=E(Pn),qp=E(ec),zp=E(nc),Hp=E(Wa),Bp=E(hc),Wp=E(Ba),yt=`${dn.join(" ")} list show show-status add-type remove-type add-status remove-status add-field remove-field list-fields show-field apply-preset rename-type rename-field remap-status`,Vp="create show add-step update-step complete-step block-step reorder-step remove-step link unlink decision discovery validation resume approve materialize",yy=E(gc),Kp=`${yy} bash zsh fish`,bt=we(_o()),Be="init scaffold install uninstall explore manage describe reload doctor catalog adopt adopt-all activate deactivate migrate",wt=`${Be} upgrade`,Jp=E(Va),Yp=E(Ka),Xp=E(Ja),Ii="--author --message --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",Zp="--dry-run --author --message --force --json --quiet --no-changed-fields --id-only --pm-path --path --no-extensions --no-pager --profile --help",Qp=E(Ie("close")),eu=E(Ie("close-task")),tu=E(Ie("release")),nu=E(Ie("claim")),yo=[["workspace","Workspace initialization, customization, state and snapshots"],["init","Initialize pm storage for the current workspace"],["config","Read or update pm settings"],["package","Manage package lifecycle operations"],["packages","Alias for package"],["create","Create a new project management item"],["item","Manage item evidence, links, tests, and duplication"],["copy","Copy an existing item to a new ID"],["focus","Set/clear/show the session focused parent for new items"],["list","List active items with optional filters"],["aggregate","Aggregate grouped item counts and numeric stats for governance queries"],["duplicates","Find bounded duplicate clusters across lifecycle statuses"],["guide","Browse local progressive-disclosure guides"],["calendar","Show calendar views for deadlines and reminders"],["cal","Alias for calendar"],["context","Show a token-efficient project context snapshot"],["ctx","Alias for context"],["get","Show item details by ID"],["next","Recommend the next actionable (unblocked, ready) work item"],["search","Search items with keyword, semantic, or hybrid modes"],["reindex","Rebuild search artifacts"],["history","Show item history entries"],["history-compact","Compact history streams into a synthetic baseline + retained tail"],["history-redact","Redact and reseal item history."],["history-repair","Re-anchor a drifted history chain so pm health/validate report ok"],["schema","Manage custom item types and statuses in .agents/pm/schema/*.json"],["profile","List, show, apply, and lint project profiles (archetype schema/config/template/package bundles)"],["plan","Agent-optimized Plan item workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"],["activity","Show recent activity across items"],["restore","Restore an item to an earlier state"],["update","Update item fields and metadata"],["update-many","Bulk-update matched items with dry-run and rollback checkpoints"],["close","Close an item (reason requirement follows governance settings)"],["close-many","Bulk-close matched items with an optional shared reason and rollback checkpoint"],["delete","Delete an item and record the change"],["append","Append text to an item body"],["comments","List or add comments for an item"],["notes","List or add notes for an item"],["learnings","List or add learnings for an item"],["files","Manage linked files"],["docs","Manage linked docs"],["deps","Show dependency relationships for an item"],["graph","Bounded graph traversal, analytics, and governance-audit queries"],["test","Manage linked tests and optionally run them"],["test-all","Run linked tests across matching items"],["test-runs","Manage background linked-test runs"],["stats","Show project tracker statistics"],["health","Show project tracker health checks"],["validate","Run standalone validation checks"],["gc","Clean optional cache artifacts"],["contracts","Show machine-readable command and schema contracts"],["claim","Claim an item for active work"],["release","Release the active claim for an item"],["start-task","Lifecycle alias to claim and set in_progress"],["pause-task","Lifecycle alias to reopen and release claim"],["close-task","Lifecycle alias to close and release claim"],["meet","Shortcut to create a Meeting with scheduling defaults"],["event","Shortcut to create an Event with scheduling defaults"],["remind","Shortcut to create a Reminder from a point in time"],["templates","Manage reusable create templates"],["completion","Generate shell completion"],["help","Display help for a command"]],bo=Ua.flatMap(e=>[e.short,e.flag,...e.aliases??[]]).filter(e=>!!e).join(" "),vt=[...mn].join("|"),kt=[...mn].map(e=>`${e}=*`).join("|"),St=[...bo.split(" ").filter(e=>!mn.has(e)),"-h","-V"].join("|");function we(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n)).join(" ")}function by(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].join(" ")}function rn(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"').replaceAll("$","\\$").replaceAll("`","\\`")}function At(e,t){return by(e.length>0?e:t.item_types??_y)}function xt(e){return we(e.statuses??hy)}function $e(e,t){let n=[...e.split(/\s+/u).filter(o=>o.length>0),...t??[]];return we(n)}function wo(e){let t=(e??[]).map(n=>n.trim()).filter(n=>n.startsWith("--")&&n.length>2).map(n=>`--${n.slice(2).replaceAll("_","-")}`);return[...new Set(t)].sort((n,o)=>n.localeCompare(o))}function ou(e,t,n){let o=e.toUpperCase(),r=`PM_COMPLETION_${o}_CACHE`,i=`PM_COMPLETION_${o}_CACHE_TS`,s=`PM_COMPLETION_${o}_TTL`,a=rn(n);return[`_pm_completion_${e}_choices() {`," local now ttl cache_ts resolved",' now="$(date +%s 2>/dev/null || echo 0)"',` ttl="\${${s}:-120}"`,` cache_ts="\${${i}:-0}"`,` if [[ -n "\${${r}:-}" && "$now" -ne 0 && $((now - cache_ts)) -lt "$ttl" ]]; then`,` printf '%s\\n' "$${r}"`," return 0"," fi",` resolved="$(pm ${t} 2>/dev/null)"`,' if [[ -z "$resolved" ]]; then',` resolved="${a}"`," fi",` ${r}="$resolved"`,` ${i}="$now"`,` printf '%s\\n' "$${r}"`,"}"]}function Ei(e=[],t=[],n=!1,o={}){let r=gt(o),i=nn.join(" "),s=e.length===0,a=At(e,o),c=xt(o),l=we(t),d=$e(gp,o.command_flags?.list),m=$e(Ap,o.command_flags?.create),f=$e(Ip,o.command_flags?.update),b=$e(Ep,o.command_flags?.["update-many"]),g=$e(Up,o.command_flags?.search),k=$e(Pp,o.command_flags?.calendar),y=$e(Np,o.command_flags?.context),v=n||t.length>0,_=A=>`_pm_completion_add_matches "${rn(A)}"`;return["# bash completion for pm",`# Source this file or add 'eval "$(pm completion bash)"' to ~/.bashrc`,"",...s?[...ou("type","completion-types",a),""]:[],...ou("status","completion-statuses",c),"","# Treat choices as data: no eval, compgen expansion, or filename globbing.","_pm_completion_add_matches() {"," local line value quoted parse_char parse_index"," local -a values"," while IFS= read -r line; do",' read -r -a values <<< "$line"',' for value in "${values[@]}"; do',' [[ "$value" == "$cur"* ]] || continue',' case "$quote_mode" in'," single)"," quoted=${value//\\'/\\'\\\\\\'\\'}",` COMPREPLY+=("$quoted'")`," ;;"," double)"," quoted="," for (( parse_index=0; parse_index<${#value}; parse_index++ )); do",' parse_char="${value:parse_index:1}"',' case "$parse_char" in'," '\"'|'\\'|'$'|'`') quoted=\"${quoted}\\\\${parse_char}\" ;;",` '!') quoted="\${quoted}\\"'!'\\"" ;;`,' *) quoted="${quoted}${parse_char}" ;;'," esac"," done",' COMPREPLY+=("$quoted\\"")'," ;;"," *)",' case "$value" in'," *[!a-zA-Z0-9_.,:/@%+=-]*)"," quoted=${value//\\'/\\'\\\\\\'\\'}",` COMPREPLY+=("'$quoted'")`," ;;",' *) COMPREPLY+=("$value") ;;'," esac"," ;;"," esac"," done",' done <<< "$1"',"}","","_pm_completion() {"," local cur prev words cword raw_prefix quote_mode parse_char next_char parse_index quote_start escaped"," COMPREPLY=()",' raw_prefix="${COMP_WORDS[COMP_CWORD]}"'," _init_completion 2>/dev/null || {",' cur="${COMP_WORDS[COMP_CWORD]}"',' prev="${COMP_WORDS[COMP_CWORD-1]}"'," cword=$COMP_CWORD"," }"," # Decode only the current Readline word. Never evaluate or expand it."," quote_mode=plain escaped=0 quote_start=0 cur="," for (( parse_index=0; parse_index<${#raw_prefix}; parse_index++ )); do",' parse_char="${raw_prefix:parse_index:1}"',' if (( escaped )); then cur="${cur}${parse_char}"; escaped=0; continue; fi',' case "$quote_mode" in'," single)",' if [[ "$parse_char" == "\'" ]]; then quote_mode=plain; else cur="${cur}${parse_char}"; fi'," ;;"," double)",' case "$parse_char" in',` '"') quote_mode=plain ;;`," '\\')",' next_char="${raw_prefix:parse_index+1:1}"',' case "$next_char" in'," '\"'|'\\'|'$'|'`') escaped=1 ;;",' *) cur="${cur}\\\\" ;;'," esac"," ;;"," '`') return 0 ;;",' *) cur="${cur}${parse_char}" ;;'," esac"," ;;"," *)",' case "$parse_char" in',` "'") quote_mode=single; quote_start=$parse_index ;;`,` '"') quote_mode=double; quote_start=$parse_index ;;`," '\\') escaped=1 ;;"," '`') return 0 ;;",' *) cur="${cur}${parse_char}" ;;'," esac"," ;;"," esac"," done"," # A mixed quoted segment has a different replacement span; keep it conservative.",' [[ "$quote_mode" != plain && $quote_start -ne 0 ]] && return 0',""," if [[ $cword -eq 1 ]]; then",` ${_(i)}`," return 0"," fi","",' if [[ "$prev" == "--type" ]]; then',s?' _pm_completion_add_matches "$(_pm_completion_type_choices)"':` ${_(a)}`," return 0"," fi","",' if [[ "$prev" == "--status" ]]; then',' _pm_completion_add_matches "$(_pm_completion_status_choices)"'," return 0"," fi","",...v?[' if [[ ( "$prev" == "--tag" || "$prev" == "--tags" ) && ! ( ( "${COMP_WORDS[1]}" == "package" || "${COMP_WORDS[1]}" == "packages" ) && "${COMP_WORDS[2]}" == "upgrade" ) ]]; then',` ${_(l)}`," return 0"," fi"]:[' if [[ ( "$prev" == "--tag" || "$prev" == "--tags" ) && ! ( ( "${COMP_WORDS[1]}" == "package" || "${COMP_WORDS[1]}" == "packages" ) && "${COMP_WORDS[2]}" == "upgrade" ) ]]; then'," local now ttl cache_ts tag_values",' now="$(date +%s 2>/dev/null || echo 0)"',' ttl="${PM_COMPLETION_TAG_TTL:-120}"',' cache_ts="${PM_COMPLETION_TAG_CACHE_TS:-0}"',' tag_values="${PM_COMPLETION_TAG_CACHE:-}"',' if [[ -z "$tag_values" || "$now" -eq 0 || $((now - cache_ts)) -ge "$ttl" ]]; then',' tag_values="$(pm completion-tags 2>/dev/null)"',' PM_COMPLETION_TAG_CACHE="$tag_values"',' PM_COMPLETION_TAG_CACHE_TS="$now"'," fi",' _pm_completion_add_matches "$tag_values"'," return 0"," fi"],"",' if [[ "$prev" == "--tag" && ( ( "${COMP_WORDS[1]}" == "package" || "${COMP_WORDS[1]}" == "packages" ) && "${COMP_WORDS[2]}" == "upgrade" ) ]]; then'," COMPREPLY=()"," return 0"," fi","",' local cmd="" command_path="" word_index=1 word'," while (( word_index < cword )); do",' word="${COMP_WORDS[word_index]}"',' case "${word//_/-}" in',` ${vt}) (( word_index += 2 )); continue ;;`,` ${kt}|${St}) (( word_index++ )); continue ;;`," --) break ;;"," esac",' if [[ -z "$cmd" ]]; then',' cmd="$word"',' [[ "$cmd" == "ctx" ]] && cmd="context"',' command_path="$cmd"',` case "$cmd" in ${ht.join("|")}) ;; *) break ;; esac`," else",' case "$command_path $word" in',...J.map(A=>` "${A.canonical}") cmd="${A.alias}"; command_path="${A.canonical}" ;;`)," *) break ;;"," esac",` case "$command_path" in ${on.map(A=>`"${A}"`).join("|")}) ;; *) (( word_index++ )); break ;; esac`," fi"," (( word_index++ ))"," done",' case "$cmd" in',...Op.flatMap(A=>[` ${A.alias})`,` ${_(A.flags)}`," return 0"," ;;"])," list)",` ${_(d)}`," ;;"," aggregate)",` ${_(yp)}`," ;;"," duplicates)",` ${_(Dp)}`," ;;"," create)",` ${_(m)}`," ;;"," copy)",` ${_(wp)}`," ;;"," focus)",` ${_(vp)}`," ;;"," update)",` ${_(f)}`," if [[ $word_index -eq $cword ]]; then",` ${_(r.update)}`," fi"," ;;"," update-many)",` ${_(b)}`," ;;"," calendar|cal)",` ${_(k)}`," ;;"," context|ctx)",` ${_(y)}`," if [[ $word_index -eq $cword ]]; then",` ${_(r.context)}`," fi"," ;;"," ops)",` ${_(`${bo} ${r.ops}`)}`," ;;"," next)",` ${_(Lp)}`," ;;"," guide)",` ${_(`${Gp} ${bt}`)}`," ;;"," search)",` ${_(g)}`," ;;"," reindex)",` ${_("--mode --progress --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," init)",` ${_(`${Hp} --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help`)}`," ;;"," config)",` ${_("--criterion --clear-criteria --format --policy --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," extension)",` ${_(`${Be} ${Jp}`)}`," ;;"," package|packages)",` ${_(`${wt} ${Yp} ${Xp}`)}`," ;;"," comments)",` ${_("--add --body --stdin --file --edit --delete --expect-at --limit --full-history --if-absent --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," notes)",` ${_("--add --add-json --stdin --file --edit --delete --expect-at --limit --since --event-type --include-meta --full-history --if-absent --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," learnings)",` ${_("--add --stdin --file --edit --delete --expect-at --limit --full-history --if-absent --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," files)",` ${_("discover lookup --add --add-glob --remove --migrate --list --apply --note --note-conflict --append-stable --validate-paths --full-history --scope --limit --offset --no-truncate --strict-read --explain --lines --decision-depth --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," docs)",` ${_("--add --add-glob --remove --migrate --note --note-conflict --validate-paths --full-history --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," append)",` ${_(bp)}`," ;;"," deps)",` ${_(Mp)}`," ;;"," graph)",` ${_(`ancestors descendants predecessors successors paths impact analyze audit communities redundancy dominators slack centrality articulation plan index ${jp}`)}`," ;;"," test)",` ${_("--add --add-json --remove --remove-index --list --run --match --only-index --only-last --full-history --background --timeout --progress --env-set --env-clear --shared-host-safe --pm-context --override-linked-pm-context --fail-on-context-mismatch --fail-on-skipped --fail-on-empty-test-run --require-assertions-for-pm --check-context --full-output --auto-pm-context --author --message --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," test-all)",` ${_("--status --limit --offset --background --timeout --progress --env-set --env-clear --shared-host-safe --pm-context --override-linked-pm-context --fail-on-context-mismatch --fail-on-skipped --fail-on-empty-test-run --require-assertions-for-pm --check-context --full-output --auto-pm-context --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," test-runs)",` ${_("list status logs stop resume --status --limit --stream --tail --force --author --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," validate)",` ${_("--check-completeness --check-metadata --metadata-profile --check-resolution --check-lifecycle --check-stale-blockers --dependency-cycle-severity --parent-cycle-severity --check-files --scan-mode --include-pm-internals --verbose-file-lists --verbose-diagnostics --all-affected-ids --strict-exit --fail-on-warn --fix-hints --auto-fix --dry-run --fix-scope --prune-missing --check-history-drift --check-command-references --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," health)",` ${_(zp)}`," ;;"," history)"," if [[ $word_index -eq $cword ]]; then",` ${_(`${xi} ${Tp}`)}`," else",` ${_(xi)}`," fi"," ;;"," events)",` ${_(Fp)}`," ;;"," history-author-acknowledge)",` ${_(`${$p} --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help`)}`," ;;"," get)",` ${_(xp)}`," ;;"," schema)",' if [[ "$prev" == "policy-mode" ]]; then',` ${_("advise refuse")}`," return"," fi",` ${_(`${yt} --definition --policy --message --description --default-status --folder --alias --role --order --type --commands --cli-flag --required --required-on-create --no-allow-unset --required-types --infer --min-count --apply --to --migration-id --dry-run --author --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help`)}`," ;;"," profile)",` ${_("list show apply lint agile ops research --dry-run --author --force --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," plan)",` ${_(`${Vp} ${Wp}`)}`," ;;"," contracts)",` ${_(Bp)}`," ;;"," gc)",` ${_("--dry-run --scope --json --quiet --no-changed-fields --pm-path --path --no-extensions --no-pager --profile --help")}`," ;;"," stats)",` ${_(qp)}`," ;;"," close-task)",` ${_(eu)}`," ;;"," close)",` ${_(Qp)}`,' if [[ "$cmd" == "close" && $word_index -eq $cword ]]; then',` ${_(r.close)}`," fi"," ;;"," close-many)",` ${_(Cp)}`," ;;"," release)",` ${_(tu)}`," ;;"," delete)",` ${_(Zp)}`," ;;"," claim)",` ${_(nu)}`," ;;"," start-task)",` ${_(`${Ii} --takeover-stale`)}`," ;;"," pause-task)",` ${_(Ii)}`," ;;"," meet|event)",` ${_(kp)}`," ;;"," remind)",` ${_(Sp)}`," ;;"," completion)",` ${_(Kp)}`," ;;"," templates)",` ${_("save list show")}`," ;;"," *)",` ${_(bo)}`," ;;"," esac"," if [[ $word_index -eq $cword ]]; then",' case "$command_path" in',...Object.entries(r).filter(([A])=>["item","workspace","search"].includes(A.split(" ")[0])).map(([A,N])=>` "${A}") ${_(N)} ;;`)," esac"," fi",' if [[ "$cmd" == "comments" || "$cmd" == "notes" || "$cmd" == "learnings" ]]; then',` ${_("--text")}`," fi"," return 0","}","","complete -F _pm_completion pm"].join(`
78
+ `)}function Ci(e){return e.replaceAll("\\","\\\\").replaceAll("'","\\'")}function ru(e){return Ci(e.replace(/([^a-zA-Z0-9_:./\s-])/gu,"\\$1"))}var wy=new Map([["calendar","Show deadline/reminder calendar views"],["schema","Inspect and manage runtime schema"],["profile","List, show, apply, and lint project profiles (archetype bundles)"],["plan","Agent-optimized Plan workflow (create/show/add-step/update-step/complete-step/link/approve/materialize)"],["start-task","Lifecycle alias to claim and set in-progress"]]);function vy(){return[...yo,["ops","Workspace maintenance and diagnostics"]].filter(([e])=>e!=="help"&&!tn.has(e)).map(([e,t])=>{let n=wy.get(e)??t;return`complete -c pm -n __pm_no_subcommand -a ${e.padEnd(16)} -d '${n}'`}).join(`
79
+ `)}function We(e,t){let n=wo(t).map(r=>r.slice(2));if(e.length===0||n.length===0)return"";let o=[];for(let r of e){let i=ht.includes(r)||J.some(s=>s.alias===r)?"__pm_history_operation":"__fish_seen_subcommand_from";for(let s of n)o.push(`complete -c pm -n '${i} ${r}' -l '${Ci(s)}' -d 'Runtime schema field flag' -r`)}return`${o.join(`
80
+ `)}
81
+ `}function iu(e,t,n){let o=e.toUpperCase(),r=Ci(n);return`
82
+ function __pm_${e}_choices
83
+ set -l now (date +%s 2>/dev/null)
84
+ if test -z "$now"
85
+ set now 0
86
+ end
87
+ set -l ttl 120
88
+ if set -q PM_COMPLETION_${o}_TTL
89
+ set ttl $PM_COMPLETION_${o}_TTL
90
+ end
91
+ if set -q PM_COMPLETION_${o}_CACHE; and set -q PM_COMPLETION_${o}_CACHE_TS
92
+ set -l age (math "$now - $PM_COMPLETION_${o}_CACHE_TS")
93
+ if test $age -lt $ttl
94
+ printf '%s\\n' $PM_COMPLETION_${o}_CACHE
95
+ return
96
+ end
97
+ end
98
+ set -l resolved (pm ${t} 2>/dev/null)
99
+ if test (count $resolved) -eq 0
100
+ set resolved '${r}'
101
+ end
102
+ set -gx PM_COMPLETION_${o}_CACHE $resolved
103
+ set -gx PM_COMPLETION_${o}_CACHE_TS $now
104
+ printf '%s\\n' $resolved
105
+ end
106
+ `}function ky(e){return e?"":`
107
+ function __pm_tag_choices
108
+ set -l now (date +%s 2>/dev/null)
109
+ if test -z "$now"
110
+ set now 0
111
+ end
112
+ set -l ttl 120
113
+ if set -q PM_COMPLETION_TAG_TTL
114
+ set ttl $PM_COMPLETION_TAG_TTL
115
+ end
116
+ if set -q PM_COMPLETION_TAG_CACHE; and set -q PM_COMPLETION_TAG_CACHE_TS
117
+ set -l age (math "$now - $PM_COMPLETION_TAG_CACHE_TS")
118
+ if test $age -lt $ttl
119
+ printf '%s
120
+ ' $PM_COMPLETION_TAG_CACHE
121
+ return
122
+ end
123
+ end
124
+ set -l resolved (pm completion-tags 2>/dev/null)
125
+ set -gx PM_COMPLETION_TAG_CACHE $resolved
126
+ set -gx PM_COMPLETION_TAG_CACHE_TS $now
127
+ printf '%s
128
+ ' $resolved
129
+ end
130
+ `}function Ri(e=[],t=[],n=!1,o={}){let r=gt(o),i=nn.filter(R=>R==="list"||R.startsWith("list-")),s=i.join(" "),a=nn.join(" "),c=e.length===0,l=At(e,o),d=xt(o),m=c?"(__pm_type_choices)":ru(l),f="(__pm_status_choices)",b=bt,g=we(t),k=n||t.length>0,y=k?`'${ru(g)}'`:"'(__pm_tag_choices)'",v=We(i,o.command_flags?.list),_=We(["create"],o.command_flags?.create),A=We(["update"],o.command_flags?.update),N=We(["update-many"],o.command_flags?.["update-many"]),O=We(["search"],o.command_flags?.search),B=We(["calendar","cal"],o.command_flags?.calendar),$=We(["context"],o.command_flags?.context);return`# Fish shell completion for pm
131
+ # Save to ~/.config/fish/completions/pm.fish
132
+ # or run: pm completion fish > ~/.config/fish/completions/pm.fish
133
+
134
+ # Disable file completion by default
135
+ complete -c pm -f
136
+
137
+ # Global flags (available for all subcommands)
138
+ complete -c pm -l json -d 'Output JSON instead of TOON'
139
+ complete -c pm -l all -d 'Reveal every public command and compatibility alias'
140
+ complete -c pm -l quiet -d 'Suppress stdout output'
141
+ complete -c pm -l output-include -d 'Retain comma-separated read fields or sections' -r
142
+ complete -c pm -l output-limit -d 'Set the universal read row ceiling' -r
143
+ complete -c pm -l output-budget -d 'Set the universal estimated-token ceiling' -r
144
+ complete -c pm -l output-format -d 'Select the universal read encoding' -r -a 'toon json'
145
+ complete -c pm -l output-session -d 'Carry cross-call read budget and served-item state' -r
146
+ complete -c pm -l output-row-contract -d 'Include row schema metadata in read output'
147
+ complete -c pm -l no-changed-fields -d 'Omit changed_fields array from mutation output'
148
+ complete -c pm -l id-only -d 'Print only id and status for single-item mutation output'
149
+ complete -c pm -l pm-path -d 'Explicit tracker storage path for this command' -r
150
+ complete -c pm -l path -d 'Override PM path for this command' -r
151
+ complete -c pm -l no-extensions -d 'Disable extension loading'
152
+ complete -c pm -l profile -d 'Print deterministic timing diagnostics'
153
+ complete -c pm -s V -l version -d 'Output the version number'
154
+ complete -c pm -s h -l help -d 'Display help'
155
+
156
+ # Helper: true when no subcommand has been given yet
157
+ function __pm_no_subcommand
158
+ not __fish_seen_subcommand_from ${a}
159
+ end
160
+ ${ky(k)}
161
+ ${c?iu("type","completion-types",l):""}
162
+ ${iu("status","completion-statuses",d)}
163
+
164
+ # Subcommands
165
+ ${vy()}
166
+
167
+ # list* flags
168
+ for list_cmd in ${s}
169
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l status -d 'Filter by status' -r -a '${f}'
170
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l all -d 'Include every lifecycle status'
171
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l type -d 'Filter by item type' -r -a '${m}'
172
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l tag -d 'Filter by tag' -r -a ${y}
173
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l tags -d 'Alias for --tag' -r -a ${y}
174
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
175
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l assignee -d 'Filter by assignee' -r
176
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
177
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l sprint -d 'Filter by sprint' -r
178
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l release -d 'Filter by release' -r
179
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l limit -d 'Limit returned item count' -r
180
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l offset -d 'Skip the first n matching rows before limit' -r
181
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-truncate -d 'Return every matched row, overriding --limit'
182
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l include-body -d 'Include item body in each returned list row'
183
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l compact -d 'Render compact list projection fields'
184
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l fields -d 'Render custom comma-separated list fields' -r
185
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l tree -d 'Render hierarchical subtree output rooted at --parent or top-level parents'
186
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l tree-depth -d 'Cap recursion depth for --tree (0 = root only)' -r
187
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l sort -d 'Sort field' -r -a 'priority deadline updated_at created_at title parent'
188
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l order -d 'Sort order (requires --sort)' -r -a 'asc desc'
189
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l stream -d 'Emit line-delimited JSON rows (requires --json)'
190
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l deadline-before -d 'Filter by deadline upper bound (ISO/date string or relative)' -r
191
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l deadline-after -d 'Filter by deadline lower bound (ISO/date string or relative)' -r
192
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l today -d 'Filter to items updated since local midnight today'
193
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l recent -d 'Filter to items updated in the last 7 days'
194
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l updated-after -d 'Filter by updated_at lower bound (ISO/relative)' -r
195
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l updated-before -d 'Filter by updated_at upper bound (ISO/relative)' -r
196
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l created-after -d 'Filter by created_at lower bound (ISO/relative)' -r
197
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l created-before -d 'Filter by created_at upper bound (ISO/relative)' -r
198
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-reviewer-missing -d 'Select only items missing reviewer'
199
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-risk-missing -d 'Select only items missing risk'
200
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-confidence-missing -d 'Select only items missing confidence'
201
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-sprint-missing -d 'Select only items missing sprint'
202
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-release-missing -d 'Select only items missing release'
203
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-notes -d 'Select only items that have notes'
204
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-notes -d 'Select only items with no notes'
205
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-learnings -d 'Select only items that have learnings'
206
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-learnings -d 'Select only items with no learnings'
207
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-files -d 'Select only items that have linked files'
208
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-files -d 'Select only items with no linked files'
209
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-files-missing -d 'Alias for --no-files'
210
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-docs -d 'Select only items that have linked docs'
211
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-docs -d 'Select only items with no linked docs'
212
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l filter-docs-missing -d 'Alias for --no-docs'
213
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-tests -d 'Select only items that have linked tests'
214
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-tests -d 'Select only items with no linked tests'
215
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-comments -d 'Select only items that have comments'
216
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-comments -d 'Select only items with no comments'
217
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-deps -d 'Select only items that have dependencies'
218
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-deps -d 'Select only items with no dependencies'
219
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-body -d 'Select only items with non-empty body'
220
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l empty-body -d 'Select only items with empty body'
221
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l has-linked-command -d 'Select only items that have a linked command'
222
+ complete -c pm -n "__fish_seen_subcommand_from $list_cmd" -l no-linked-command -d 'Select only items with no linked command'
223
+ end
224
+ ${v}
225
+
226
+ # aggregate flags
227
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l group-by -d 'Comma-separated group-by fields (supported: parent,type,priority,status,assignee,tags,sprint,release)' -r
228
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l count -d 'Return grouped counts'
229
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l completion -d 'Add completion counts and percentage per group'
230
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l sum -d 'Numeric field to sum per group' -r
231
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l avg -d 'Numeric field to average per group' -r
232
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l include-unparented -d 'Include unparented rows when grouping by parent'
233
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l status -d 'Filter by status' -r -a '${f}'
234
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l type -d 'Filter by item type' -r -a '${m}'
235
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l tag -d 'Filter by tag' -r -a ${y}
236
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
237
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l deadline-before -d 'Filter by deadline upper bound (ISO/date string or relative)' -r
238
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l deadline-after -d 'Filter by deadline lower bound (ISO/date string or relative)' -r
239
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l assignee -d 'Filter by assignee' -r
240
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
241
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l parent -d 'Filter by parent item ID' -r
242
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l sprint -d 'Filter by sprint' -r
243
+ complete -c pm -n '__fish_seen_subcommand_from aggregate' -l release -d 'Filter by release' -r
244
+
245
+
246
+ # create flags
247
+ complete -c pm -n '__fish_seen_subcommand_from create' -s t -l title -d 'Item title' -r
248
+ complete -c pm -n '__fish_seen_subcommand_from create' -s d -l description -d 'Item description' -r
249
+ complete -c pm -n '__fish_seen_subcommand_from create' -l type -d 'Item type' -r -a '${m}'
250
+ complete -c pm -n '__fish_seen_subcommand_from create' -l create-mode -d 'Create required-option policy mode' -r -a 'strict progressive'
251
+ complete -c pm -n '__fish_seen_subcommand_from create' -l defer -d 'Defer a strict-required field as not known yet' -r -a 'deadline assignee acceptance-criteria estimate'
252
+ complete -c pm -n '__fish_seen_subcommand_from create' -l defer-reason -d 'Why the deferred values are not known yet' -r
253
+ complete -c pm -n '__fish_seen_subcommand_from create' -l schedule-preset -d 'Scheduling preset for Reminder/Meeting/Event' -r -a 'lightweight'
254
+ complete -c pm -n '__fish_seen_subcommand_from create' -s s -l status -d 'Item status' -r -a '${f}'
255
+ complete -c pm -n '__fish_seen_subcommand_from create' -s p -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
256
+ complete -c pm -n '__fish_seen_subcommand_from create' -l tags -d 'Comma-separated tags' -r
257
+ complete -c pm -n '__fish_seen_subcommand_from create' -l add-tags -d 'Add tags additively without replacing existing' -r
258
+ complete -c pm -n '__fish_seen_subcommand_from create' -s b -l body -d 'Item body' -r
259
+ complete -c pm -n '__fish_seen_subcommand_from create' -l body-file -d 'Load the item body from a file' -r -F
260
+ complete -c pm -n '__fish_seen_subcommand_from create' -l deadline -d 'Deadline (ISO/date string or relative +6h/+1d/+2w/+6m)' -r
261
+ complete -c pm -n '__fish_seen_subcommand_from create' -l estimate -d 'Estimated minutes' -r
262
+ complete -c pm -n '__fish_seen_subcommand_from create' -l acceptance-criteria -d 'Acceptance criteria' -r
263
+ complete -c pm -n '__fish_seen_subcommand_from create' -l reminder -d 'Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>' -r
264
+ complete -c pm -n '__fish_seen_subcommand_from create' -l event -d 'Event entry start=<iso|relative>,end=<iso|relative>,recur_*' -r
265
+ complete -c pm -n '__fish_seen_subcommand_from create' -l type-option -d 'Type option key=value or key=<name>,value=<value>' -r
266
+ complete -c pm -n '__fish_seen_subcommand_from create' -l author -d 'Mutation author' -r
267
+ complete -c pm -n '__fish_seen_subcommand_from create' -l message -d 'History message' -r
268
+ complete -c pm -n '__fish_seen_subcommand_from create' -l assignee -d 'Assignee' -r
269
+ complete -c pm -n '__fish_seen_subcommand_from create' -l unset -d 'Clear scalar fields by name (repeatable or csv)' -r
270
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-deps -d 'Clear dependency entries'
271
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-comments -d 'Clear comments'
272
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-notes -d 'Clear notes'
273
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-learnings -d 'Clear learnings'
274
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-files -d 'Clear linked files'
275
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-tests -d 'Clear linked tests'
276
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-docs -d 'Clear linked docs'
277
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-reminders -d 'Clear reminders'
278
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-events -d 'Clear events'
279
+ complete -c pm -n '__fish_seen_subcommand_from create' -l clear-type-options -d 'Clear type options'
280
+ ${_}
281
+
282
+ # copy flags
283
+ complete -c pm -n '__fish_seen_subcommand_from copy' -l title -d 'Override copied title' -r
284
+ complete -c pm -n '__fish_seen_subcommand_from copy' -l author -d 'Mutation author' -r
285
+ complete -c pm -n '__fish_seen_subcommand_from copy' -l message -d 'History message' -r
286
+ complete -c pm -n '__fish_seen_subcommand_from copy' -l force -d 'Force ownership override'
287
+
288
+ # focus flags
289
+ complete -c pm -n '__pm_history_operation focus' -l clear -d 'Clear the focused item'
290
+
291
+ # update flags
292
+ complete -c pm -n '__pm_history_operation update' -s t -l title -d 'Item title' -r
293
+ complete -c pm -n '__pm_history_operation update' -s d -l description -d 'Item description' -r
294
+ complete -c pm -n '__pm_history_operation update' -s b -l body -d 'Item body' -r
295
+ complete -c pm -n '__pm_history_operation update' -l body-file -d 'Load the item body from a file' -r -F
296
+ complete -c pm -n '__pm_history_operation update' -s s -l status -d 'Item status' -r -a '${f}'
297
+ complete -c pm -n '__pm_history_operation update' -l close-reason -d 'Set close reason' -r
298
+ complete -c pm -n '__pm_history_operation update' -s p -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
299
+ complete -c pm -n '__pm_history_operation update' -l type -d 'Item type' -r -a '${m}'
300
+ complete -c pm -n '__pm_history_operation update' -l add-tags -d 'Add tags additively without replacing existing' -r
301
+ complete -c pm -n '__pm_history_operation update' -l remove-tags -d 'Remove tags from the existing list' -r
302
+ complete -c pm -n '__pm_history_operation update' -l add-ac -d 'Add one acceptance criterion without replacing existing' -r
303
+ complete -c pm -n '__pm_history_operation update' -l remove-ac -d 'Remove one acceptance criterion by exact text' -r
304
+ complete -c pm -n '__pm_history_operation update' -l expected -d 'Short alias for --expected-result' -r
305
+ complete -c pm -n '__pm_history_operation update' -l actual -d 'Short alias for --actual-result' -r
306
+ complete -c pm -n '__pm_history_operation update' -l comment -d 'Comment seed author=<value>,created_at=<iso|now>,text=<value>' -r
307
+ complete -c pm -n '__pm_history_operation update' -l note -d 'Note seed author=<value>,created_at=<iso|now>,text=<value>' -r
308
+ complete -c pm -n '__pm_history_operation update' -l learning -d 'Learning seed author=<value>,created_at=<iso|now>,text=<value>' -r
309
+ complete -c pm -n '__pm_history_operation update' -l file -d 'Linked file path=<value>,scope=<project|global>,note=<text>' -r
310
+ complete -c pm -n '__pm_history_operation update' -l test -d 'Linked test command=<value>,path=<value>,scope=<project|global>' -r
311
+ complete -c pm -n '__pm_history_operation update' -l doc -d 'Linked doc path=<value>,scope=<project|global>,note=<text>' -r
312
+ complete -c pm -n '__pm_history_operation update' -l reminder -d 'Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>' -r
313
+ complete -c pm -n '__pm_history_operation update' -l event -d 'Event entry start=<iso|relative>,end=<iso|relative>,recur_*' -r
314
+ complete -c pm -n '__pm_history_operation update' -l type-option -d 'Type option key=value or key=<name>,value=<value>' -r
315
+ complete -c pm -n '__pm_history_operation update' -l unset -d 'Clear scalar fields by name (repeatable or csv)' -r
316
+ complete -c pm -n '__pm_history_operation update' -l replace-deps -d 'Atomically replace dependencies with provided --dep values'
317
+ complete -c pm -n '__pm_history_operation update' -l replace-tests -d 'Atomically replace linked tests with provided --test values'
318
+ complete -c pm -n '__pm_history_operation update' -l replace-files -d 'Atomically replace linked files with provided --file values'
319
+ complete -c pm -n '__pm_history_operation update' -l replace-docs -d 'Atomically replace linked docs with provided --doc values'
320
+ complete -c pm -n '__pm_history_operation update' -l clear-deps -d 'Clear dependency entries'
321
+ complete -c pm -n '__pm_history_operation update' -l clear-comments -d 'Clear comments'
322
+ complete -c pm -n '__pm_history_operation update' -l clear-notes -d 'Clear notes'
323
+ complete -c pm -n '__pm_history_operation update' -l clear-learnings -d 'Clear learnings'
324
+ complete -c pm -n '__pm_history_operation update' -l clear-files -d 'Clear linked files'
325
+ complete -c pm -n '__pm_history_operation update' -l clear-tests -d 'Clear linked tests'
326
+ complete -c pm -n '__pm_history_operation update' -l clear-docs -d 'Clear linked docs'
327
+ complete -c pm -n '__pm_history_operation update' -l clear-reminders -d 'Clear reminders'
328
+ complete -c pm -n '__pm_history_operation update' -l clear-events -d 'Clear events'
329
+ complete -c pm -n '__pm_history_operation update' -l clear-type-options -d 'Clear type options'
330
+ complete -c pm -n '__pm_history_operation update' -l author -d 'Mutation author' -r
331
+ complete -c pm -n '__pm_history_operation update' -l message -d 'History message' -r
332
+ complete -c pm -n '__pm_history_operation update' -l force -d 'Force override'
333
+ ${A}
334
+
335
+ # update-many flags
336
+ complete -c pm -n '__pm_history_operation update-many' -l filter-status -d 'Filter by status before applying updates' -r -a '${f}'
337
+ complete -c pm -n '__pm_history_operation update-many' -l filter-type -d 'Filter by type before applying updates' -r -a '${m}'
338
+ complete -c pm -n '__pm_history_operation update-many' -l filter-tag -d 'Filter by tag before applying updates' -r -a ${y}
339
+ complete -c pm -n '__pm_history_operation update-many' -l filter-priority -d 'Filter by priority before applying updates' -r -a '0 1 2 3 4'
340
+ complete -c pm -n '__pm_history_operation update-many' -l filter-deadline-before -d 'Filter by deadline upper bound' -r
341
+ complete -c pm -n '__pm_history_operation update-many' -l filter-deadline-after -d 'Filter by deadline lower bound' -r
342
+ complete -c pm -n '__pm_history_operation update-many' -l filter-updated-after -d 'Filter by updated_at lower bound (ISO/relative)' -r
343
+ complete -c pm -n '__pm_history_operation update-many' -l filter-updated-before -d 'Filter by updated_at upper bound (ISO/relative)' -r
344
+ complete -c pm -n '__pm_history_operation update-many' -l filter-created-after -d 'Filter by created_at lower bound (ISO/relative)' -r
345
+ complete -c pm -n '__pm_history_operation update-many' -l filter-created-before -d 'Filter by created_at upper bound (ISO/relative)' -r
346
+ complete -c pm -n '__pm_history_operation update-many' -l filter-assignee -d 'Filter by assignee before applying updates' -r
347
+ complete -c pm -n '__pm_history_operation update-many' -l filter-assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
348
+ complete -c pm -n '__pm_history_operation update-many' -l filter-parent -d 'Filter by parent item ID' -r
349
+ complete -c pm -n '__pm_history_operation update-many' -l filter-sprint -d 'Filter by sprint before applying updates' -r
350
+ complete -c pm -n '__pm_history_operation update-many' -l filter-release -d 'Filter by release before applying updates' -r
351
+ complete -c pm -n '__pm_history_operation update-many' -l filter-ac-missing -d 'Select only items missing acceptance_criteria'
352
+ complete -c pm -n '__pm_history_operation update-many' -l filter-estimates-missing -d 'Select only items missing estimated_minutes'
353
+ complete -c pm -n '__pm_history_operation update-many' -l filter-resolution-missing -d 'Select only terminal items missing resolution'
354
+ complete -c pm -n '__pm_history_operation update-many' -l filter-metadata-missing -d 'Select only items missing any tracked metadata'
355
+ complete -c pm -n '__pm_history_operation update-many' -l filter-reviewer-missing -d 'Select only items missing reviewer'
356
+ complete -c pm -n '__pm_history_operation update-many' -l filter-risk-missing -d 'Select only items missing risk'
357
+ complete -c pm -n '__pm_history_operation update-many' -l filter-confidence-missing -d 'Select only items missing confidence'
358
+ complete -c pm -n '__pm_history_operation update-many' -l filter-sprint-missing -d 'Select only items missing sprint'
359
+ complete -c pm -n '__pm_history_operation update-many' -l filter-release-missing -d 'Select only items missing release'
360
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-notes -d 'Select only items that have notes'
361
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-notes -d 'Select only items with no notes'
362
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-learnings -d 'Select only items that have learnings'
363
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-learnings -d 'Select only items with no learnings'
364
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-files -d 'Select only items that have linked files'
365
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-files -d 'Select only items with no linked files'
366
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-docs -d 'Select only items that have linked docs'
367
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-docs -d 'Select only items with no linked docs'
368
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-tests -d 'Select only items that have linked tests'
369
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-tests -d 'Select only items with no linked tests'
370
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-comments -d 'Select only items that have comments'
371
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-comments -d 'Select only items with no comments'
372
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-deps -d 'Select only items that have dependencies'
373
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-deps -d 'Select only items with no dependencies'
374
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-body -d 'Select only items with non-empty body'
375
+ complete -c pm -n '__pm_history_operation update-many' -l filter-empty-body -d 'Select only items with empty body'
376
+ complete -c pm -n '__pm_history_operation update-many' -l filter-has-linked-command -d 'Select only items that have a linked command'
377
+ complete -c pm -n '__pm_history_operation update-many' -l filter-no-linked-command -d 'Select only items with no linked command'
378
+ complete -c pm -n '__pm_history_operation update-many' -l ids -d 'Explicit comma-separated ID allowlist' -r
379
+ complete -c pm -n '__pm_history_operation update-many' -l limit -d 'Limit matched item count' -r
380
+ complete -c pm -n '__pm_history_operation update-many' -l offset -d 'Skip first n matched rows' -r
381
+ complete -c pm -n '__pm_history_operation update-many' -l dry-run -d 'Preview updates without mutating'
382
+ complete -c pm -n '__pm_history_operation update-many' -l rollback -d 'Rollback checkpoint ID' -r
383
+ complete -c pm -n '__pm_history_operation update-many' -l no-checkpoint -d 'Disable checkpoint creation during apply mode'
384
+ complete -c pm -n '__pm_history_operation update-many' -s t -l title -d 'Item title' -r
385
+ complete -c pm -n '__pm_history_operation update-many' -s d -l description -d 'Item description' -r
386
+ complete -c pm -n '__pm_history_operation update-many' -s b -l body -d 'Item body' -r
387
+ complete -c pm -n '__pm_history_operation update-many' -s p -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
388
+ complete -c pm -n '__pm_history_operation update-many' -l type -d 'Item type' -r -a '${m}'
389
+ complete -c pm -n '__pm_history_operation update-many' -l tags -d 'Comma-separated tags' -r
390
+ complete -c pm -n '__pm_history_operation update-many' -l add-tags -d 'Add tags additively without replacing existing' -r
391
+ complete -c pm -n '__pm_history_operation update-many' -l remove-tags -d 'Remove tags from the existing list' -r
392
+ complete -c pm -n '__pm_history_operation update-many' -l deadline -d 'Deadline (ISO/date string or relative)' -r
393
+ complete -c pm -n '__pm_history_operation update-many' -l estimate -d 'Estimated minutes' -r
394
+ complete -c pm -n '__pm_history_operation update-many' -l acceptance-criteria -d 'Acceptance criteria' -r
395
+ complete -c pm -n '__pm_history_operation update-many' -l add-ac -d 'Add one acceptance criterion without replacing existing' -r
396
+ complete -c pm -n '__pm_history_operation update-many' -l remove-ac -d 'Remove one acceptance criterion by exact text' -r
397
+ complete -c pm -n '__pm_history_operation update-many' -l definition-of-ready -d 'Definition of ready' -r
398
+ complete -c pm -n '__pm_history_operation update-many' -l order -d 'Planning order/rank' -r
399
+ complete -c pm -n '__pm_history_operation update-many' -l goal -d 'Goal identifier' -r
400
+ complete -c pm -n '__pm_history_operation update-many' -l objective -d 'Objective identifier' -r
401
+ complete -c pm -n '__pm_history_operation update-many' -l value -d 'Business value summary' -r
402
+ complete -c pm -n '__pm_history_operation update-many' -l impact -d 'Business impact summary' -r
403
+ complete -c pm -n '__pm_history_operation update-many' -l outcome -d 'Expected outcome summary' -r
404
+ complete -c pm -n '__pm_history_operation update-many' -l why-now -d 'Why-now rationale' -r
405
+ complete -c pm -n '__pm_history_operation update-many' -l reviewer -d 'Reviewer' -r
406
+ complete -c pm -n '__pm_history_operation update-many' -l risk -d 'Risk level' -r
407
+ complete -c pm -n '__pm_history_operation update-many' -l confidence -d 'Confidence level' -r
408
+ complete -c pm -n '__pm_history_operation update-many' -l sprint -d 'Sprint identifier' -r
409
+ complete -c pm -n '__pm_history_operation update-many' -l release -d 'Release identifier' -r
410
+ complete -c pm -n '__pm_history_operation update-many' -l reporter -d 'Issue reporter' -r
411
+ complete -c pm -n '__pm_history_operation update-many' -l severity -d 'Issue severity' -r
412
+ complete -c pm -n '__pm_history_operation update-many' -l environment -d 'Issue environment context' -r
413
+ complete -c pm -n '__pm_history_operation update-many' -l repro-steps -d 'Issue reproduction steps' -r
414
+ complete -c pm -n '__pm_history_operation update-many' -l resolution -d 'Issue resolution summary' -r
415
+ complete -c pm -n '__pm_history_operation update-many' -l expected-result -d 'Issue expected behavior' -r
416
+ complete -c pm -n '__pm_history_operation update-many' -l actual-result -d 'Issue observed behavior' -r
417
+ complete -c pm -n '__pm_history_operation update-many' -l expected -d 'Short alias for --expected-result' -r
418
+ complete -c pm -n '__pm_history_operation update-many' -l actual -d 'Short alias for --actual-result' -r
419
+ complete -c pm -n '__pm_history_operation update-many' -l affected-version -d 'Affected version identifier' -r
420
+ complete -c pm -n '__pm_history_operation update-many' -l fixed-version -d 'Fixed version identifier' -r
421
+ complete -c pm -n '__pm_history_operation update-many' -l component -d 'Issue component ownership' -r
422
+ complete -c pm -n '__pm_history_operation update-many' -l regression -d 'Regression marker true|false|1|0' -r
423
+ complete -c pm -n '__pm_history_operation update-many' -l customer-impact -d 'Customer impact summary' -r
424
+ complete -c pm -n '__pm_history_operation update-many' -l dep -d 'Dependency seed id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>' -r
425
+ complete -c pm -n '__pm_history_operation update-many' -l dep-remove -d 'Dependency removal selector id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>' -r
426
+ complete -c pm -n '__pm_history_operation update-many' -l replace-deps -d 'Atomically replace dependencies with provided --dep values'
427
+ complete -c pm -n '__pm_history_operation update-many' -l replace-tests -d 'Atomically replace linked tests with provided --test values'
428
+ complete -c pm -n '__pm_history_operation update-many' -l replace-files -d 'Atomically replace linked files with provided --file values'
429
+ complete -c pm -n '__pm_history_operation update-many' -l replace-docs -d 'Atomically replace linked docs with provided --doc values'
430
+ complete -c pm -n '__pm_history_operation update-many' -l comment -d 'Comment seed author=<value>,created_at=<iso|now>,text=<value>' -r
431
+ complete -c pm -n '__pm_history_operation update-many' -l note -d 'Note seed author=<value>,created_at=<iso|now>,text=<value>' -r
432
+ complete -c pm -n '__pm_history_operation update-many' -l learning -d 'Learning seed author=<value>,created_at=<iso|now>,text=<value>' -r
433
+ complete -c pm -n '__pm_history_operation update-many' -l file -d 'Linked file path=<value>,scope=<project|global>,note=<text>' -r
434
+ complete -c pm -n '__pm_history_operation update-many' -l test -d 'Linked test command=<value>,path=<value>,scope=<project|global>' -r
435
+ complete -c pm -n '__pm_history_operation update-many' -l doc -d 'Linked doc path=<value>,scope=<project|global>,note=<text>' -r
436
+ complete -c pm -n '__pm_history_operation update-many' -l reminder -d 'Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>' -r
437
+ complete -c pm -n '__pm_history_operation update-many' -l event -d 'Event entry start=<iso|relative>,end=<iso|relative>,recur_*' -r
438
+ complete -c pm -n '__pm_history_operation update-many' -l type-option -d 'Type option key=value or key=<name>,value=<value>' -r
439
+ complete -c pm -n '__pm_history_operation update-many' -l unset -d 'Clear scalar fields by name (repeatable or csv)' -r
440
+ complete -c pm -n '__pm_history_operation update-many' -l clear-deps -d 'Clear dependency entries'
441
+ complete -c pm -n '__pm_history_operation update-many' -l clear-comments -d 'Clear comments'
442
+ complete -c pm -n '__pm_history_operation update-many' -l clear-notes -d 'Clear notes'
443
+ complete -c pm -n '__pm_history_operation update-many' -l clear-learnings -d 'Clear learnings'
444
+ complete -c pm -n '__pm_history_operation update-many' -l clear-files -d 'Clear linked files'
445
+ complete -c pm -n '__pm_history_operation update-many' -l clear-tests -d 'Clear linked tests'
446
+ complete -c pm -n '__pm_history_operation update-many' -l clear-docs -d 'Clear linked docs'
447
+ complete -c pm -n '__pm_history_operation update-many' -l clear-reminders -d 'Clear reminders'
448
+ complete -c pm -n '__pm_history_operation update-many' -l clear-events -d 'Clear events'
449
+ complete -c pm -n '__pm_history_operation update-many' -l clear-type-options -d 'Clear type options'
450
+ complete -c pm -n '__pm_history_operation update-many' -l author -d 'Mutation author' -r
451
+ complete -c pm -n '__pm_history_operation update-many' -l message -d 'History message' -r
452
+ complete -c pm -n '__pm_history_operation update-many' -l force -d 'Force override'
453
+ ${N}
454
+
455
+ # files flags
456
+ complete -c pm -n '__fish_seen_subcommand_from files' -a 'discover lookup' -d 'Linked-file subcommand'
457
+ complete -c pm -n '__fish_seen_subcommand_from files' -l add -d 'Add a linked file' -r
458
+ complete -c pm -n '__fish_seen_subcommand_from files' -l add-glob -d 'Add linked files matching a glob' -r
459
+ complete -c pm -n '__fish_seen_subcommand_from files' -l remove -d 'Remove a linked file' -r
460
+ complete -c pm -n '__fish_seen_subcommand_from files' -l migrate -d 'Migrate linked-file metadata'
461
+ complete -c pm -n '__fish_seen_subcommand_from files' -l list -d 'List linked files'
462
+ complete -c pm -n '__fish_seen_subcommand_from files' -l apply -d 'Apply discovered linked files'
463
+ complete -c pm -n '__fish_seen_subcommand_from files' -l note -d 'Linked-file note' -r
464
+ complete -c pm -n '__fish_seen_subcommand_from files' -l note-conflict -d 'Treatment of an existing different note' -r -a 'refuse replace append'
465
+ complete -c pm -n '__fish_seen_subcommand_from files' -l append-stable -d 'Preserve stable append ordering'
466
+ complete -c pm -n '__fish_seen_subcommand_from files' -l validate-paths -d 'Validate linked-file paths'
467
+ complete -c pm -n '__fish_seen_subcommand_from files' -l full-history -d 'Return every linked file after a write'
468
+ complete -c pm -n '__fish_seen_subcommand_from files' -l scope -d 'Filter lookup by evidence scope' -r -a 'project global'
469
+ complete -c pm -n '__fish_seen_subcommand_from files' -l limit -d 'Maximum lookup matches' -r
470
+ complete -c pm -n '__fish_seen_subcommand_from files' -l offset -d 'Skip the first lookup matches' -r
471
+ complete -c pm -n '__fish_seen_subcommand_from files' -l no-truncate -d 'Return every lookup match'
472
+ complete -c pm -n '__fish_seen_subcommand_from files' -l strict-read -d 'Require authoritative source reads'
473
+ complete -c pm -n '__fish_seen_subcommand_from files' -l explain -d 'Include ranked source-to-work rationale'
474
+ complete -c pm -n '__fish_seen_subcommand_from files' -l lines -d 'Attribute an inclusive source line range' -r
475
+ complete -c pm -n '__fish_seen_subcommand_from files' -l decision-depth -d 'Maximum governing-decision relationship depth' -r
476
+
477
+
478
+ # search flags
479
+ complete -c pm -n '__fish_seen_subcommand_from search' -l mode -d 'Search mode' -r -a 'keyword semantic hybrid'
480
+ complete -c pm -n '__fish_seen_subcommand_from search' -l match-mode -d 'Token match mode' -r -a 'and or exact'
481
+ complete -c pm -n '__fish_seen_subcommand_from search' -l min-score -d 'Per-query minimum score threshold' -r
482
+ complete -c pm -n '__fish_seen_subcommand_from search' -l count -d 'Return only the match count'
483
+ complete -c pm -n '__fish_seen_subcommand_from search' -l include-linked -d 'Include linked content in scoring'
484
+ complete -c pm -n '__fish_seen_subcommand_from search' -l highlight -d 'Emit per-field matched-text snippets on each hit'
485
+ complete -c pm -n '__fish_seen_subcommand_from search' -l limit -d 'Max results' -r
486
+ complete -c pm -n '__fish_seen_subcommand_from search' -l status -d 'Filter by status (open/closed/canceled, csv)' -r -a '${f}'
487
+ complete -c pm -n '__fish_seen_subcommand_from search' -l type -d 'Filter by type' -r -a '${m}'
488
+ complete -c pm -n '__fish_seen_subcommand_from search' -l tag -d 'Filter by tag' -r -a ${y}
489
+ complete -c pm -n '__fish_seen_subcommand_from search' -l tags -d 'Alias for --tag' -r -a ${y}
490
+ complete -c pm -n '__fish_seen_subcommand_from search' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
491
+ complete -c pm -n '__fish_seen_subcommand_from search' -l updated-after -d 'Filter by updated_at lower bound' -r
492
+ complete -c pm -n '__fish_seen_subcommand_from search' -l updated-before -d 'Filter by updated_at upper bound' -r
493
+ complete -c pm -n '__fish_seen_subcommand_from search' -l created-after -d 'Filter by created_at lower bound' -r
494
+ complete -c pm -n '__fish_seen_subcommand_from search' -l created-before -d 'Filter by created_at upper bound' -r
495
+ complete -c pm -n '__fish_seen_subcommand_from search' -l assignee -d 'Filter by assignee' -r
496
+ complete -c pm -n '__fish_seen_subcommand_from search' -l sprint -d 'Filter by sprint' -r
497
+ complete -c pm -n '__fish_seen_subcommand_from search' -l release -d 'Filter by release' -r
498
+ complete -c pm -n '__fish_seen_subcommand_from search' -l parent -d 'Filter by parent item ID' -r
499
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-reviewer-missing -d 'Select only items missing reviewer'
500
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-risk-missing -d 'Select only items missing risk'
501
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-confidence-missing -d 'Select only items missing confidence'
502
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-sprint-missing -d 'Select only items missing sprint'
503
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-release-missing -d 'Select only items missing release'
504
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-notes -d 'Select only items that have notes'
505
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-notes -d 'Select only items with no notes'
506
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-learnings -d 'Select only items that have learnings'
507
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-learnings -d 'Select only items with no learnings'
508
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-files -d 'Select only items that have linked files'
509
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-files -d 'Select only items with no linked files'
510
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-files-missing -d 'Alias for --no-files'
511
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-docs -d 'Select only items that have linked docs'
512
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-docs -d 'Select only items with no linked docs'
513
+ complete -c pm -n '__fish_seen_subcommand_from search' -l filter-docs-missing -d 'Alias for --no-docs'
514
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-tests -d 'Select only items that have linked tests'
515
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-tests -d 'Select only items with no linked tests'
516
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-comments -d 'Select only items that have comments'
517
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-comments -d 'Select only items with no comments'
518
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-deps -d 'Select only items that have dependencies'
519
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-deps -d 'Select only items with no dependencies'
520
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-body -d 'Select only items with non-empty body'
521
+ complete -c pm -n '__fish_seen_subcommand_from search' -l empty-body -d 'Select only items with empty body'
522
+ complete -c pm -n '__fish_seen_subcommand_from search' -l has-linked-command -d 'Select only items that have a linked command'
523
+ complete -c pm -n '__fish_seen_subcommand_from search' -l no-linked-command -d 'Select only items with no linked command'
524
+ ${O}
525
+
526
+ # calendar flags
527
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l view -d 'Calendar view' -r -a 'agenda day week month'
528
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l date -d 'Anchor date/time (ISO/date string or relative)' -r
529
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l from -d 'Agenda lower bound (ISO/date string or relative)' -r
530
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l to -d 'Agenda upper bound (ISO/date string or relative)' -r
531
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l past -d 'Include past entries'
532
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l full-period -d 'Include full anchored day/week/month period'
533
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l type -d 'Filter by type' -r -a '${m}'
534
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l tag -d 'Filter by tag' -r -a ${y}
535
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
536
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l status -d 'Filter by status' -r -a '${f}'
537
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l assignee -d 'Filter by assignee' -r
538
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
539
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l sprint -d 'Filter by sprint' -r
540
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l release -d 'Filter by release' -r
541
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l include -d 'Include event sources' -r -a 'all deadlines reminders events scheduled'
542
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l recurrence-lookahead-days -d 'Bound open-ended recurrence lookahead' -r
543
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l recurrence-lookback-days -d 'Bound open-ended recurrence lookback' -r
544
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l occurrence-limit -d 'Cap occurrences per recurring event' -r
545
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l after -d 'Continue a fixed-window calendar page' -r
546
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l limit -d 'Limit returned events' -r
547
+ complete -c pm -n '__fish_seen_subcommand_from calendar cal' -l format -d 'Output override' -r -a 'markdown toon json'
548
+ ${B}
549
+
550
+ # context flags
551
+ complete -c pm -n '__pm_history_operation context' -l date -d 'Anchor date/time (ISO/date string or relative)' -r
552
+ complete -c pm -n '__pm_history_operation context' -l from -d 'Agenda lower bound (ISO/date string or relative)' -r
553
+ complete -c pm -n '__pm_history_operation context' -l to -d 'Agenda upper bound (ISO/date string or relative)' -r
554
+ complete -c pm -n '__pm_history_operation context' -l past -d 'Include past entries in bounded windows'
555
+ complete -c pm -n '__pm_history_operation context' -l type -d 'Filter by type' -r -a '${m}'
556
+ complete -c pm -n '__pm_history_operation context' -l tag -d 'Filter by tag' -r -a ${y}
557
+ complete -c pm -n '__pm_history_operation context' -l priority -d 'Filter by priority' -r -a '0 1 2 3 4'
558
+ complete -c pm -n '__pm_history_operation context' -l assignee -d 'Filter by assignee' -r
559
+ complete -c pm -n '__pm_history_operation context' -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
560
+ complete -c pm -n '__pm_history_operation context' -l sprint -d 'Filter by sprint' -r
561
+ complete -c pm -n '__pm_history_operation context' -l release -d 'Filter by release' -r
562
+ complete -c pm -n '__pm_history_operation context' -l parent -d 'Scope snapshot to one item subtree' -r
563
+ complete -c pm -n '__pm_history_operation context' -l limit -d 'Limit focus and agenda rows per section' -r
564
+ complete -c pm -n '__pm_history_operation context' -l depth -d 'Context depth' -r -a 'brief standard deep full'
565
+ complete -c pm -n '__pm_history_operation context' -l format -d 'Output override' -r -a 'markdown toon json'
566
+ ${$}
567
+
568
+ # next flags
569
+ complete -c pm -n '__pm_history_operation next' -l type -d 'Filter candidates by type' -r -a '${m}'
570
+ complete -c pm -n '__pm_history_operation next' -l tag -d 'Filter candidates by tag' -r -a ${y}
571
+ complete -c pm -n '__pm_history_operation next' -l priority -d 'Filter candidates by priority' -r -a '0 1 2 3 4'
572
+ complete -c pm -n '__pm_history_operation next' -l assignee -d 'Filter candidates by assignee' -r
573
+ complete -c pm -n '__pm_history_operation next' -l assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
574
+ complete -c pm -n '__pm_history_operation next' -l sprint -d 'Filter candidates by sprint' -r
575
+ complete -c pm -n '__pm_history_operation next' -l release -d 'Filter candidates by release' -r
576
+ complete -c pm -n '__pm_history_operation next' -l parent -d 'Scope to one item subtree' -r
577
+ complete -c pm -n '__pm_history_operation next' -l limit -d 'Limit ready rows' -r
578
+ complete -c pm -n '__pm_history_operation next' -l blocked-limit -d 'Limit blocked rows' -r
579
+ complete -c pm -n '__pm_history_operation next' -l ready-only -d 'Omit the blocked companion list'
580
+ complete -c pm -n '__pm_history_operation next' -l format -d 'Output override' -r -a 'markdown toon json'
581
+
582
+ # guide flags
583
+ complete -c pm -n '__fish_seen_subcommand_from guide' -l list -d 'Show guide topic index'
584
+ complete -c pm -n '__fish_seen_subcommand_from guide' -l format -d 'Output override' -r -a 'markdown toon json'
585
+ complete -c pm -n '__fish_seen_subcommand_from guide' -l depth -d 'Guide detail depth' -r -a 'brief standard deep'
586
+ complete -c pm -n '__fish_seen_subcommand_from guide' -a '${b}' -d 'Guide topic'
587
+
588
+ # reindex flags
589
+ complete -c pm -n '__pm_history_operation reindex' -l mode -d 'Reindex mode' -r -a 'keyword semantic hybrid'
590
+ complete -c pm -n '__pm_history_operation reindex' -l progress -d 'Emit progress updates to stderr'
591
+
592
+ # get flags
593
+ complete -c pm -n '__fish_seen_subcommand_from get' -l depth -d 'Detail depth' -r -a 'brief standard deep full'
594
+ complete -c pm -n '__fish_seen_subcommand_from get' -l full -d 'Explicit full item read'
595
+ complete -c pm -n '__fish_seen_subcommand_from get' -l fields -d 'Render custom comma-separated item fields' -r
596
+ complete -c pm -n '__fish_seen_subcommand_from get' -l tree -d 'Include descendant subtree in result payload'
597
+ complete -c pm -n '__fish_seen_subcommand_from get' -l tree-depth -d 'Cap subtree depth for --tree (0 = root only)' -r
598
+
599
+ # Read the first command positions after consuming recognized global options.
600
+ function __pm_history_tokens
601
+ set -l tokens (commandline -opc)
602
+ set -l skip_value 0
603
+ set -l positions 0
604
+ set -l command_path
605
+ for token in $tokens[2..-1]
606
+ if test $skip_value -eq 1
607
+ set skip_value 0
608
+ continue
609
+ end
610
+ switch (string replace -a _ - -- "$token")
611
+ case ${vt.replaceAll("|"," ")}
612
+ set skip_value 1
613
+ continue
614
+ case ${kt.split("|").map(R=>`'${R}'`).join(" ")} ${St.replaceAll("|"," ")}
615
+ continue
616
+ case --
617
+ printf '%s\\n' --
618
+ return
619
+ end
620
+ if test $positions -eq 0; and test "$token" = ctx
621
+ set token context
622
+ end
623
+ printf '%s\\n' "$token"
624
+ set positions (math $positions + 1)
625
+ set -a command_path "$token"
626
+ if not contains -- (string join ' ' -- $command_path) ${on.map(R=>`'${R}'`).join(" ")}
627
+ return
628
+ end
629
+ end
630
+ if test $skip_value -eq 1
631
+ printf '%s\\n' --value
632
+ end
633
+ end
634
+
635
+ # Match only the command positions, keeping item history separate from maintenance.
636
+ function __pm_history_operation
637
+ set -l tokens (__pm_history_tokens)
638
+ switch (string join ' ' -- $tokens)
639
+ ${[...J].sort((R,re)=>re.canonical_argv.length-R.canonical_argv.length).map(R=>` case '${R.canonical}' '${R.canonical} *'
640
+ contains -- '${R.alias}' $argv
641
+ return`).join(`
642
+ `)}
643
+ end
644
+ contains -- "$tokens[1]" $argv
645
+ end
646
+ ${Object.entries(r).map(([R,re])=>`complete -c pm -n 'test (string join " " -- (__pm_history_tokens)) = "${R}"' -a '${re}' -d '${R} operation'`).join(`
647
+ `)}
648
+ ${ho.map(R=>`complete -c pm -n '__pm_history_operation restore restore' -l ${R.flag.slice(2)}${R.takes_value?" -r":""}`).join(`
649
+ `)}
650
+
651
+ ${go.map(R=>`complete -c pm -n '__pm_history_operation history-attest' -l ${R.flag.slice(2)}${R.takes_value?" -r":""}`).join(`
652
+ `)}
653
+
654
+ # history / activity flags
655
+ complete -c pm -n '__pm_history_operation history' -l limit -d 'Max history entries' -r
656
+ complete -c pm -n '__pm_history_operation history' -l compact -d 'Condensed history projection'
657
+ complete -c pm -n '__pm_history_operation history' -l full -d 'Show full history entries'
658
+ complete -c pm -n '__pm_history_operation history' -l provenance -d 'Patch-free identity and agent provenance projection'
659
+ complete -c pm -n '__pm_history_operation history' -l provenance-summary -d 'Include bounded provenance completeness counts'
660
+ complete -c pm -n '__pm_history_operation history' -l harness -d 'Filter by recorded or vocabulary-resolved harness' -r
661
+ complete -c pm -n '__pm_history_operation history' -l agent-instance -d 'Filter by privacy-safe agent instance' -r
662
+ complete -c pm -n '__pm_history_operation history' -l provenance-filter -d 'Filter by exact declared provenance value' -r
663
+ complete -c pm -n '__pm_history_operation history' -l diff -d 'Include per-entry field-level before/after value diffs'
664
+ complete -c pm -n '__pm_history_operation history' -l field -d 'With --diff, show only entries that changed this field' -r
665
+ complete -c pm -n '__pm_history_operation history' -l verify -d 'Verify history hash chain and replay integrity'
666
+ complete -c pm -n '__pm_history_operation events' -l since -d 'Resume after a cursor or from an ISO timestamp' -r
667
+ complete -c pm -n '__pm_history_operation events' -l type -d 'Filter by mutation operation' -r
668
+ complete -c pm -n '__pm_history_operation events' -l author -d 'Filter by mutation author' -r
669
+ complete -c pm -n '__pm_history_operation events' -l item -d 'Filter by item or workspace stream' -r
670
+ complete -c pm -n '__pm_history_operation events' -l limit -d 'Maximum events, up to 1000' -r
671
+ complete -c pm -n '__pm_history_operation events' -l full -d 'Include complete authoritative history entries'
672
+ complete -c pm -n '__pm_history_operation events' -l provenance -d 'Include patch-free identity and agent provenance'
673
+ complete -c pm -n '__pm_history_operation events' -l provenance-summary -d 'Include bounded provenance completeness counts'
674
+ complete -c pm -n '__pm_history_operation events' -l harness -d 'Filter by recorded or vocabulary-resolved harness' -r
675
+ complete -c pm -n '__pm_history_operation events' -l agent-instance -d 'Filter by privacy-safe agent instance' -r
676
+ complete -c pm -n '__pm_history_operation events' -l provenance-filter -d 'Filter by exact declared provenance value' -r
677
+ complete -c pm -n '__pm_history_operation events' -l follow -d 'Continue emitting committed events'
678
+ complete -c pm -n '__pm_history_operation events' -l interval-ms -d 'Empty-read delay while following' -r
679
+ complete -c pm -n '__pm_history_operation history-compact compact' -l before -d 'Compact entries strictly before this version number or ISO timestamp' -r
680
+ complete -c pm -n '__pm_history_operation history-compact compact' -l id -d 'Item ID (alternative to positional ID)' -r
681
+ complete -c pm -n '__pm_history_operation history-compact compact' -l ids -d 'Bulk: compact an explicit comma-separated list of item ids' -r
682
+ complete -c pm -n '__pm_history_operation history-compact compact' -l all-over -d 'Bulk: compact every stream with more than N entries' -r
683
+ complete -c pm -n '__pm_history_operation history-compact compact' -l closed -d 'Bulk: compact only closed (terminal) items streams'
684
+ complete -c pm -n '__pm_history_operation history-compact compact' -l all-streams -d 'Bulk: compact every history stream regardless of lifecycle state'
685
+ complete -c pm -n '__pm_history_operation history-compact compact' -l min-entries -d 'Bulk: skip streams with at most N entries' -r
686
+ complete -c pm -n '__pm_history_operation history-compact compact' -l dry-run -d 'Preview compaction impact without writing the history file'
687
+ complete -c pm -n '__pm_history_operation history-compact compact' -l author -d 'Mutation author' -r
688
+ complete -c pm -n '__pm_history_operation history-compact compact' -l message -d 'Audit history message' -r
689
+ complete -c pm -n '__pm_history_operation history-compact compact' -l force -d 'Force ownership/lock override'
690
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l event -d 'Actionable unknown-author event' -r
691
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l all-actionable -d 'Select every currently actionable event'
692
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l dry-run -d 'Preview a deterministic source-bound plan'
693
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l plan-fingerprint -d 'Apply the exact dry-run plan' -r
694
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l limit -d 'Maximum coordinate rows returned in the plan' -r
695
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l attributed-author -d 'Principal attributed by maintainer review' -r
696
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l reviewer -d 'Reviewer recording the disposition' -r
697
+ complete -c pm -n '__fish_seen_subcommand_from history-author-acknowledge' -l reason -d 'Evidence-backed review rationale' -r
698
+ complete -c pm -n '__pm_history_operation history-redact redact' -l literal -d 'Literal string matcher to redact from history/item payloads' -r
699
+ complete -c pm -n '__pm_history_operation history-redact redact' -l id -d 'Item ID (alternative to positional ID)' -r
700
+ complete -c pm -n '__pm_history_operation history-redact redact' -l regex -d 'Regex matcher to redact (/pattern/flags or raw pattern)' -r
701
+ complete -c pm -n '__pm_history_operation history-redact redact' -l replacement -d 'Replacement text (defaults to [redacted])' -r
702
+ complete -c pm -n '__pm_history_operation history-redact redact' -l dry-run -d 'Preview redaction impact without writing files'
703
+ complete -c pm -n '__pm_history_operation history-redact redact' -l author -d 'Mutation author' -r
704
+ complete -c pm -n '__pm_history_operation history-redact redact' -l message -d 'Audit history message' -r
705
+ complete -c pm -n '__pm_history_operation history-redact redact' -l force -d 'Force ownership/lock override'
706
+ complete -c pm -n '__pm_history_operation history-repair repair' -l salvage-tail -d 'Remove JSON null, boolean and number lines and an invalid suffix after a verified prefix'
707
+ complete -c pm -n '__pm_history_operation history-repair repair' -l append-only -d 'Bridge chain breaks with one appended record'
708
+ complete -c pm -n '__pm_history_operation history-repair repair' -l id -d 'Item ID (alternative to positional ID)' -r
709
+ complete -c pm -n '__pm_history_operation history-repair repair' -l normalize-provenance -d 'Remove invalid provenance with aggregate evidence'
710
+ complete -c pm -n '__pm_history_operation history-repair repair' -l all -d 'Repair every drifted stream in one audited pass'
711
+ complete -c pm -n '__pm_history_operation history-repair repair' -l dry-run -d 'Preview the re-anchor impact without writing the history file'
712
+ complete -c pm -n '__pm_history_operation history-repair repair' -l author -d 'Mutation author' -r
713
+ complete -c pm -n '__pm_history_operation history-repair repair' -l message -d 'Audit history message' -r
714
+ complete -c pm -n '__pm_history_operation history-repair repair' -l force -d 'Force ownership/lock override'
715
+ complete -c pm -n '__fish_seen_subcommand_from schema' -a '${yt}' -d 'Schema subcommand'
716
+ complete -c pm -n '__fish_seen_subcommand_from schema; and __fish_seen_subcommand_from policy-mode' -a 'advise refuse' -d 'Policy enforcement'
717
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l definition -d 'Policy definition or proposed fields JSON' -r
718
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l policy -d 'Approval policy id' -r
719
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l message -d 'History rationale' -r
720
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l dry-run -d 'Preview schema changes'
721
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l description -d 'Human description for the custom item type, status, or field' -r
722
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l default-status -d 'Default status hint for the custom item type' -r
723
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l folder -d 'Storage folder for items of this custom type' -r
724
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l alias -d 'Alias for the custom type, status, or field flag (repeatable)' -r
725
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l role -d 'Lifecycle role for a custom status (repeatable)' -r
726
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l order -d 'Display/sort order for a custom status' -r
727
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l type -d 'Value type for a custom field' -r -a 'string number boolean string_array array object'
728
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l commands -d 'Commands a custom field is wired onto (repeatable)' -r
729
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l cli-flag -d 'Override the auto-derived CLI flag for a custom field' -r
730
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l required -d 'Mark a custom field as always required'
731
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l required-on-create -d 'Mark a custom field as required at create time'
732
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l no-allow-unset -d 'Disallow clearing a custom field via --unset'
733
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l required-types -d 'Restrict a custom field requirement to specific item types (repeatable)' -r
734
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l infer -d 'Infer item types from title-prefix conventions (add-type)'
735
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l min-count -d 'Minimum items sharing a prefix for --infer' -r
736
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l apply -d 'Register inferred types (with --infer)'
737
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l author -d 'Mutation author' -r
738
+ complete -c pm -n '__fish_seen_subcommand_from schema' -l force -d 'Force ownership/lock override'
739
+ complete -c pm -n '__fish_seen_subcommand_from profile' -a 'list show apply lint' -d 'Profile subcommand'
740
+ complete -c pm -n '__fish_seen_subcommand_from profile' -a 'agile ops research' -d 'Profile name'
741
+ complete -c pm -n '__fish_seen_subcommand_from profile' -l dry-run -d 'Preview the apply diff without writing any files'
742
+ complete -c pm -n '__fish_seen_subcommand_from profile' -l author -d 'Mutation author' -r
743
+ complete -c pm -n '__fish_seen_subcommand_from profile' -l force -d 'Force ownership/lock override'
744
+ complete -c pm -n '__fish_seen_subcommand_from plan' -a 'create show add-step update-step complete-step block-step reorder-step remove-step link unlink decision discovery validation resume approve materialize' -d 'Plan subcommand'
745
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l title -d 'Plan title' -r
746
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l scope -d 'Plan scope statement' -r
747
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l harness -d 'Plan harness provenance' -r -a 'codex claude-code cursor generic'
748
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l mode -d 'Plan mode' -r -a 'draft research review approved executing paused completed superseded'
749
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l resume-context -d 'Resume context summary' -r
750
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l step-title -d 'Step title' -r
751
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l step -d 'Step title (repeatable on create)' -r
752
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l step-status -d 'Step status' -r -a 'pending in_progress completed blocked skipped superseded'
753
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l step-evidence -d 'Step evidence' -r
754
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l depends-on -d 'Pm item id step depends on' -r
755
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l link -d 'Pm item id to link' -r
756
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l link-kind -d 'Link kind' -r -a 'related blocks blocked_by depends_on discovered_from implements verifies supersedes'
757
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l depth -d 'Show depth' -r -a 'brief standard deep'
758
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l steps -d 'Step ids/orders for materialize' -r
759
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l materialize-type -d 'Item type for materialized steps' -r
760
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l allow-multiple-active -d 'Allow multiple in_progress steps'
761
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l promote-to-item-dep -d 'Also add link as item dependency'
762
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l author -d 'Mutation author' -r
763
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l message -d 'Mutation message' -r
764
+ complete -c pm -n '__fish_seen_subcommand_from plan' -l force -d 'Force ownership override'
765
+ complete -c pm -n '__pm_history_operation activity activity' -l id -d 'Filter by item ID' -r
766
+ complete -c pm -n '__pm_history_operation activity activity' -l op -d 'Filter by history operation' -r
767
+ complete -c pm -n '__pm_history_operation activity activity' -l author -d 'Filter by history author' -r
768
+ complete -c pm -n '__pm_history_operation activity activity' -l from -d 'Lower timestamp bound (ISO/date string or relative)' -r
769
+ complete -c pm -n '__pm_history_operation activity activity' -l to -d 'Upper timestamp bound (ISO/date string or relative)' -r
770
+ complete -c pm -n '__pm_history_operation activity activity' -l after -d 'Continue a fixed-window activity page' -r
771
+ complete -c pm -n '__pm_history_operation activity activity' -l limit -d 'Max activity entries' -r
772
+ complete -c pm -n '__pm_history_operation activity activity' -l unbounded -d 'Return every matching activity entry'
773
+ complete -c pm -n '__pm_history_operation activity activity' -l compact -d 'Condensed activity projection'
774
+ complete -c pm -n '__pm_history_operation activity activity' -l raw -d 'Emit raw compact per-event activity output'
775
+ complete -c pm -n '__pm_history_operation activity activity' -l full -d 'Show full activity entries'
776
+ complete -c pm -n '__pm_history_operation activity activity' -l provenance -d 'Patch-free identity and agent provenance projection'
777
+ complete -c pm -n '__pm_history_operation activity activity' -l provenance-summary -d 'Include bounded provenance completeness counts'
778
+ complete -c pm -n '__pm_history_operation activity activity' -l harness -d 'Filter by recorded or vocabulary-resolved harness' -r
779
+ complete -c pm -n '__pm_history_operation activity activity' -l agent-instance -d 'Filter by privacy-safe agent instance' -r
780
+ complete -c pm -n '__pm_history_operation activity activity' -l provenance-filter -d 'Filter by exact declared provenance value' -r
781
+ complete -c pm -n '__pm_history_operation activity activity' -l stream -d 'Emit line-delimited JSON rows (requires --json)'
782
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l action -d 'Filter schema by tool action' -r
783
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l command -d 'Scope output to one command (narrow-by-default)' -r
784
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l summary -d 'Return compact command intent summary'
785
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l schema-only -d 'Return schema-only payload'
786
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l flags-only -d 'Return command flag contracts only'
787
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l availability-only -d 'Return action availability only'
788
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l runtime-only -d 'Include only actions invocable in the current runtime'
789
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l active-only -d 'Alias for --runtime-only'
790
+ complete -c pm -n '__fish_seen_subcommand_from contracts' -l full -d 'Include complete command and schema contract details'
791
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l format -d 'Output format' -r -a 'tree graph context'
792
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l max-depth -d 'Maximum traversal depth (0 keeps root only)' -r
793
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l collapse -d 'Collapse mode' -r -a 'none repeated'
794
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l summary -d 'Return counts only without tree/graph payload'
795
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l node-limit -d 'Maximum nodes in context output' -r
796
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l edge-limit -d 'Maximum edges in context output' -r
797
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l token-budget -d 'Maximum estimated tokens in context output' -r
798
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l cursor -d 'Continue an equivalent context query' -r
799
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l direction -d 'Context traversal direction' -r -a 'outgoing incoming both'
800
+ complete -c pm -n '__fish_seen_subcommand_from deps' -l kind -d 'Restrict context traversal to relationship kinds' -r
801
+ complete -c pm -n '__fish_seen_subcommand_from graph' -a 'ancestors descendants predecessors successors paths impact analyze audit communities redundancy dominators slack centrality articulation plan index' -d 'Graph query'
802
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l kind -d 'Restrict traversal to registered relationship kinds' -r
803
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l max-depth -d 'Maximum traversal depth' -r
804
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l limit -d 'Maximum returned rows per bounded collection' -r
805
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l after -d 'Resume a traversal after this node id' -r
806
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l direction -d 'Edge orientation for paths/impact' -r -a 'outgoing incoming both'
807
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l max-paths -d 'Maximum enumerated paths' -r
808
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l sample -d 'Maximum evidence sample entries per audit finding' -r
809
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l exempt-isolate -d 'Item ids treated as explicitly valid isolates' -r
810
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l exempt-isolate-type -d 'Item types whose active isolates are policy-valid' -r
811
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l save-baseline -d 'Persist the audit census as the comparison baseline'
812
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l rebuild -d 'Rebuild and warm the durable graph index'
813
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l clear -d 'Delete the durable graph index'
814
+ complete -c pm -n '__fish_seen_subcommand_from graph' -l summary -d 'Return counts-first envelopes without row collections'
815
+
816
+ # comments / notes / learnings flags
817
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l add -d 'Add one entry (text=<value> or plain text)' -r
818
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l text -d 'Alias for --add' -r
819
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l add-json -d 'Append one validated JSON context event' -r
820
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l since -d 'Return structured events at or after an ISO timestamp' -r
821
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l event-type -d 'Return structured events with this top-level type' -r
822
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l include-meta -d 'Include result counts and truncation metadata'
823
+ complete -c pm -n '__fish_seen_subcommand_from comments' -l stdin -d 'Read comment text from stdin (supports multiline markdown)'
824
+ complete -c pm -n '__fish_seen_subcommand_from comments' -l file -d 'Read comment text from file (supports multiline markdown)' -r
825
+ complete -c pm -n '__fish_seen_subcommand_from comments' -l edit -d 'Replace the comment at 1-based index (text from positional/--add/--stdin/--file)' -r
826
+ complete -c pm -n '__fish_seen_subcommand_from comments' -l delete -d 'Delete the comment at 1-based index' -r
827
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l if-absent -d 'Append only when the resolved author and text are absent'
828
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l stdin -d 'Read entry text from stdin'
829
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l file -d 'Read entry text from file' -r
830
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l edit -d 'Replace the entry at a 1-based index' -r
831
+ complete -c pm -n '__fish_seen_subcommand_from notes' -l delete -d 'Delete the entry at a 1-based index' -r
832
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l limit -d 'Return only latest n entries' -r
833
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l expect-at -d 'Edit/delete only if the entry created_at matches' -r
834
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l full-history -d 'Return complete post-mutation history'
835
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l author -d 'Entry author' -r
836
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l message -d 'History message' -r
837
+ complete -c pm -n '__fish_seen_subcommand_from comments notes learnings' -l force -d 'Force override'
838
+
839
+ # test flags
840
+ complete -c pm -n '__fish_seen_subcommand_from test' -l add -d 'Add linked test entry' -r
841
+ complete -c pm -n '__fish_seen_subcommand_from test' -l add-json -d 'Add linked test entry from JSON object/array' -r
842
+ complete -c pm -n '__fish_seen_subcommand_from test' -l remove -d 'Remove linked test entry' -r
843
+ complete -c pm -n '__fish_seen_subcommand_from test' -l remove-index -d 'Remove linked test entry by 1-based index' -r
844
+ complete -c pm -n '__fish_seen_subcommand_from test' -l list -d 'List linked tests without mutating'
845
+ complete -c pm -n '__fish_seen_subcommand_from test' -l run -d 'Run linked tests'
846
+ complete -c pm -n '__fish_seen_subcommand_from test' -l match -d 'Run linked tests whose command/path contains substring' -r
847
+ complete -c pm -n '__fish_seen_subcommand_from test' -l only-index -d 'Run one linked test by 1-based index' -r
848
+ complete -c pm -n '__fish_seen_subcommand_from test' -l only-last -d 'Run the most recently added linked test'
849
+ complete -c pm -n '__fish_seen_subcommand_from test' -l full-history -d 'Return every linked test after a write'
850
+ complete -c pm -n '__fish_seen_subcommand_from test' -l background -d 'Run linked tests in managed background mode'
851
+ complete -c pm -n '__fish_seen_subcommand_from test' -l timeout -d 'Default timeout seconds' -r
852
+ complete -c pm -n '__fish_seen_subcommand_from test' -l progress -d 'Emit linked-test progress to stderr'
853
+ complete -c pm -n '__fish_seen_subcommand_from test' -l env-set -d 'Set linked-test runtime environment values' -r
854
+ complete -c pm -n '__fish_seen_subcommand_from test' -l env-clear -d 'Clear linked-test runtime environment values' -r
855
+ complete -c pm -n '__fish_seen_subcommand_from test' -l shared-host-safe -d 'Apply shared-host-safe runtime defaults'
856
+ complete -c pm -n '__fish_seen_subcommand_from test' -l pm-context -d 'PM linked-test context mode' -r -a 'schema tracker auto none'
857
+ complete -c pm -n '__fish_seen_subcommand_from test' -l override-linked-pm-context -d 'Force run-level --pm-context over per-linked-test metadata'
858
+ complete -c pm -n '__fish_seen_subcommand_from test' -l fail-on-context-mismatch -d 'Fail when context item counts mismatch'
859
+ complete -c pm -n '__fish_seen_subcommand_from test' -l fail-on-skipped -d 'Treat skipped linked tests as dependency failures'
860
+ complete -c pm -n '__fish_seen_subcommand_from test' -l fail-on-empty-test-run -d 'Treat empty linked-test selections as failures'
861
+ complete -c pm -n '__fish_seen_subcommand_from test' -l require-assertions-for-pm -d 'Require assertions for linked PM command tests'
862
+ complete -c pm -n '__fish_seen_subcommand_from test' -l check-context -d 'Preflight linked PM command context diagnostics before execution'
863
+ complete -c pm -n '__fish_seen_subcommand_from test' -l full-output -d 'Report full stdout/stderr of passing rows'
864
+ complete -c pm -n '__fish_seen_subcommand_from test' -l auto-pm-context -d 'Auto-remediate tracker-read context mismatches using tracker context'
865
+ complete -c pm -n '__fish_seen_subcommand_from test' -l author -d 'Mutation author' -r
866
+ complete -c pm -n '__fish_seen_subcommand_from test' -l message -d 'History message' -r
867
+ complete -c pm -n '__fish_seen_subcommand_from test' -l force -d 'Force override'
868
+
869
+ # test-all flags
870
+ complete -c pm -n '__pm_history_operation test-all' -l status -d 'Filter by status' -r -a 'open in_progress'
871
+ complete -c pm -n '__pm_history_operation test-all' -l limit -d 'Limit matching items before running linked tests' -r
872
+ complete -c pm -n '__pm_history_operation test-all' -l offset -d 'Skip matching items before running linked tests' -r
873
+ complete -c pm -n '__pm_history_operation test-all' -l background -d 'Run linked tests in managed background mode'
874
+ complete -c pm -n '__pm_history_operation test-all' -l timeout -d 'Default timeout seconds' -r
875
+ complete -c pm -n '__pm_history_operation test-all' -l progress -d 'Emit linked-test progress to stderr'
876
+ complete -c pm -n '__pm_history_operation test-all' -l env-set -d 'Set linked-test runtime environment values' -r
877
+ complete -c pm -n '__pm_history_operation test-all' -l env-clear -d 'Clear linked-test runtime environment values' -r
878
+ complete -c pm -n '__pm_history_operation test-all' -l shared-host-safe -d 'Apply shared-host-safe runtime defaults'
879
+ complete -c pm -n '__pm_history_operation test-all' -l pm-context -d 'PM linked-test context mode' -r -a 'schema tracker auto none'
880
+ complete -c pm -n '__pm_history_operation test-all' -l override-linked-pm-context -d 'Force run-level --pm-context over per-linked-test metadata'
881
+ complete -c pm -n '__pm_history_operation test-all' -l fail-on-context-mismatch -d 'Fail when context item counts mismatch'
882
+ complete -c pm -n '__pm_history_operation test-all' -l fail-on-skipped -d 'Treat skipped linked tests as dependency failures'
883
+ complete -c pm -n '__pm_history_operation test-all' -l fail-on-empty-test-run -d 'Treat empty linked-test selections as failures'
884
+ complete -c pm -n '__pm_history_operation test-all' -l require-assertions-for-pm -d 'Require assertions for linked PM command tests'
885
+ complete -c pm -n '__pm_history_operation test-all' -l check-context -d 'Preflight linked PM command context diagnostics before execution'
886
+ complete -c pm -n '__pm_history_operation test-all' -l full-output -d 'Report full stdout/stderr of passing rows'
887
+ complete -c pm -n '__pm_history_operation test-all' -l auto-pm-context -d 'Auto-remediate tracker-read context mismatches using tracker context'
888
+
889
+ # test-runs flags
890
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -a 'list status logs stop resume' -d 'test-runs subcommand'
891
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l status -d 'Filter background runs by status' -r -a 'queued running passed failed stopped canceled'
892
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l limit -d 'Limit returned runs' -r
893
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l stream -d 'Background log stream selector' -r -a 'stdout stderr both'
894
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l tail -d 'Tail number of lines from logs' -r
895
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l force -d 'Force-stop run with SIGKILL'
896
+ complete -c pm -n '__fish_seen_subcommand_from test-runs' -l author -d 'Resume author' -r
897
+
898
+ # gc flags
899
+ complete -c pm -n '__pm_history_operation gc' -l dry-run -d 'Preview cleanup targets without deleting files'
900
+ complete -c pm -n '__pm_history_operation gc' -l scope -d 'Limit cleanup to index/embeddings/runtime/locks scopes' -r
901
+
902
+ # stats flags
903
+ complete -c pm -n '__pm_history_operation stats' -l include-empty -d 'Include registered zero-count type and status buckets'
904
+ complete -c pm -n '__pm_history_operation stats' -l storage -d 'Include aggregate history-stream storage metrics'
905
+ complete -c pm -n '__pm_history_operation stats' -l metadata-coverage -d 'Include metadata coverage percentages overall and by type'
906
+ complete -c pm -n '__pm_history_operation stats' -l field-utilization -d 'Include content-field utilization rates across all items'
907
+ complete -c pm -n '__pm_history_operation stats' -l by-assignee -d 'Lifecycle-bucketed breakdown grouped by assignee'
908
+ complete -c pm -n '__pm_history_operation stats' -l by-tag -d 'Lifecycle-bucketed breakdown grouped by tag'
909
+ complete -c pm -n '__pm_history_operation stats' -l by-priority -d 'Lifecycle-bucketed breakdown grouped by priority'
910
+ complete -c pm -n '__pm_history_operation stats' -l tag-prefix -d 'With --by-tag: only count tags with this prefix' -r
911
+ complete -c pm -n '__pm_history_operation stats' -l analytics -d 'Improvement ledger/history analytics JSON' -r
912
+
913
+ # append flags
914
+ complete -c pm -n '__fish_seen_subcommand_from append' -s b -l body -d 'Item body' -r
915
+ complete -c pm -n '__fish_seen_subcommand_from append' -l author -d 'Mutation author' -r
916
+ complete -c pm -n '__fish_seen_subcommand_from append' -l message -d 'History message' -r
917
+ complete -c pm -n '__fish_seen_subcommand_from append' -l force -d 'Force override'
918
+
919
+ # close flags
920
+ complete -c pm -n '__pm_history_operation close' -l release-assignment -d 'Close and release assignment'
921
+ complete -c pm -n '__pm_history_operation release' -l pause -d 'Return to open and release ownership'
922
+ complete -c pm -n '__pm_history_operation claim' -l start -d 'Claim and start work'
923
+ complete -c pm -n '__pm_history_operation claim release start-task pause-task close close-task delete' -l author -d 'Mutation author' -r
924
+ complete -c pm -n '__pm_history_operation claim release start-task pause-task close close-task delete' -l message -d 'History message' -r
925
+ complete -c pm -n '__pm_history_operation claim release start-task pause-task close close-task delete' -l force -d 'Force override'
926
+ complete -c pm -n '__fish_seen_subcommand_from claim' -l if-available -d 'Skip work held by another author'
927
+ complete -c pm -n '__fish_seen_subcommand_from claim start-task' -l takeover-stale -d 'Take over a claim idle past the stale-work threshold'
928
+ complete -c pm -n '__fish_seen_subcommand_from claim' -l next -d 'Atomically claim the next actionable item'
929
+ complete -c pm -n '__fish_seen_subcommand_from claim' -l token-budget -d 'Bound ranked candidate tokens' -r
930
+ complete -c pm -n '__fish_seen_subcommand_from claim' -l explain-ranking -d 'Include ranking provenance'
931
+ complete -c pm -n '__pm_history_operation close close-task' -l validate-close -d 'Validate closure metadata mode' -r -a 'off warn strict'
932
+ complete -c pm -n '__pm_history_operation close' -l reason -d 'Closure reason' -r
933
+ complete -c pm -n '__pm_history_operation close' -l close-reason -d 'Alias for --reason' -r
934
+ complete -c pm -n '__pm_history_operation close' -l resolution -d 'Closure resolution summary' -r
935
+ complete -c pm -n '__pm_history_operation close' -l expected-result -d 'Expected behavior note' -r
936
+ complete -c pm -n '__pm_history_operation close' -l actual-result -d 'Observed behavior note' -r
937
+ complete -c pm -n '__pm_history_operation close' -l expected -d 'Short alias for --expected-result' -r
938
+ complete -c pm -n '__pm_history_operation close' -l actual -d 'Short alias for --actual-result' -r
939
+ complete -c pm -n '__pm_history_operation delete' -l dry-run -d 'Preview the item file that would be deleted without mutating'
940
+
941
+ # scheduling shortcut flags (meet/event/remind)
942
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l start -d 'Start time (ISO, now, or relative)' -r
943
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l duration -d 'Duration from start (default 1h)' -r
944
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l end -d 'End time (overrides --duration)' -r
945
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l location -d 'Location' -r
946
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l timezone -d 'IANA timezone' -r
947
+ complete -c pm -n '__fish_seen_subcommand_from meet event' -l all-day -d 'Mark as an all-day event'
948
+ complete -c pm -n '__fish_seen_subcommand_from remind' -l at -d 'Reminder time (default +1d)' -r
949
+ complete -c pm -n '__fish_seen_subcommand_from remind' -l text -d 'Reminder text (defaults to title)' -r
950
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l parent -d 'Parent item id' -r
951
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l allow-missing-parent -d 'Permit a parent id that does not exist yet'
952
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l tags -d 'Comma-separated tags' -r
953
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l priority -d 'Priority (0-4)' -r -a '0 1 2 3 4'
954
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l body -d 'Item body' -r
955
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l description -d 'Short description' -r
956
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l author -d 'Mutation author' -r
957
+ complete -c pm -n '__fish_seen_subcommand_from meet event remind' -l message -d 'History message' -r
958
+
959
+ # close-many flags
960
+ complete -c pm -n '__pm_history_operation close-many' -l filter-status -d 'Filter by status before closing' -r -a '${f}'
961
+ complete -c pm -n '__pm_history_operation close-many' -l filter-type -d 'Filter by type before closing' -r -a '${m}'
962
+ complete -c pm -n '__pm_history_operation close-many' -l filter-tag -d 'Filter by tag before closing' -r -a ${y}
963
+ complete -c pm -n '__pm_history_operation close-many' -l filter-priority -d 'Filter by priority before closing' -r -a '0 1 2 3 4'
964
+ complete -c pm -n '__pm_history_operation close-many' -l filter-deadline-before -d 'Filter by deadline upper bound' -r
965
+ complete -c pm -n '__pm_history_operation close-many' -l filter-deadline-after -d 'Filter by deadline lower bound' -r
966
+ complete -c pm -n '__pm_history_operation close-many' -l filter-updated-after -d 'Filter by updated_at lower bound (ISO/relative)' -r
967
+ complete -c pm -n '__pm_history_operation close-many' -l filter-updated-before -d 'Filter by updated_at upper bound (ISO/relative)' -r
968
+ complete -c pm -n '__pm_history_operation close-many' -l filter-created-after -d 'Filter by created_at lower bound (ISO/relative)' -r
969
+ complete -c pm -n '__pm_history_operation close-many' -l filter-created-before -d 'Filter by created_at upper bound (ISO/relative)' -r
970
+ complete -c pm -n '__pm_history_operation close-many' -l filter-assignee -d 'Filter by assignee before closing' -r
971
+ complete -c pm -n '__pm_history_operation close-many' -l filter-assignee-filter -d 'Filter assignee presence' -r -a 'assigned unassigned'
972
+ complete -c pm -n '__pm_history_operation close-many' -l filter-parent -d 'Filter by parent item ID' -r
973
+ complete -c pm -n '__pm_history_operation close-many' -l filter-sprint -d 'Filter by sprint before closing' -r
974
+ complete -c pm -n '__pm_history_operation close-many' -l filter-release -d 'Filter by release before closing' -r
975
+ complete -c pm -n '__pm_history_operation close-many' -l filter-reviewer-missing -d 'Select only items missing reviewer'
976
+ complete -c pm -n '__pm_history_operation close-many' -l filter-risk-missing -d 'Select only items missing risk'
977
+ complete -c pm -n '__pm_history_operation close-many' -l filter-confidence-missing -d 'Select only items missing confidence'
978
+ complete -c pm -n '__pm_history_operation close-many' -l filter-sprint-missing -d 'Select only items missing sprint'
979
+ complete -c pm -n '__pm_history_operation close-many' -l filter-release-missing -d 'Select only items missing release'
980
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-notes -d 'Select only items that have notes'
981
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-notes -d 'Select only items with no notes'
982
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-learnings -d 'Select only items that have learnings'
983
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-learnings -d 'Select only items with no learnings'
984
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-files -d 'Select only items that have linked files'
985
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-files -d 'Select only items with no linked files'
986
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-docs -d 'Select only items that have linked docs'
987
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-docs -d 'Select only items with no linked docs'
988
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-tests -d 'Select only items that have linked tests'
989
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-tests -d 'Select only items with no linked tests'
990
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-comments -d 'Select only items that have comments'
991
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-comments -d 'Select only items with no comments'
992
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-deps -d 'Select only items that have dependencies'
993
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-deps -d 'Select only items with no dependencies'
994
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-body -d 'Select only items with non-empty body'
995
+ complete -c pm -n '__pm_history_operation close-many' -l filter-empty-body -d 'Select only items with empty body'
996
+ complete -c pm -n '__pm_history_operation close-many' -l filter-has-linked-command -d 'Select only items that have a linked command'
997
+ complete -c pm -n '__pm_history_operation close-many' -l filter-no-linked-command -d 'Select only items with no linked command'
998
+ complete -c pm -n '__pm_history_operation close-many' -l ids -d 'Explicit comma-separated ID allowlist' -r
999
+ complete -c pm -n '__pm_history_operation close-many' -l limit -d 'Limit matched item count' -r
1000
+ complete -c pm -n '__pm_history_operation close-many' -l offset -d 'Skip first n matched rows' -r
1001
+ complete -c pm -n '__pm_history_operation close-many' -l reason -d 'Optional shared close reason applied to every matched item' -r
1002
+ complete -c pm -n '__pm_history_operation close-many' -l resolution -d 'Shared closure resolution' -r
1003
+ complete -c pm -n '__pm_history_operation close-many' -l expected-result -d 'Shared expected-result note' -r
1004
+ complete -c pm -n '__pm_history_operation close-many' -l actual-result -d 'Shared actual-result note' -r
1005
+ complete -c pm -n '__pm_history_operation close-many' -l expected -d 'Short alias for --expected-result' -r
1006
+ complete -c pm -n '__pm_history_operation close-many' -l actual -d 'Short alias for --actual-result' -r
1007
+ complete -c pm -n '__pm_history_operation close-many' -l validate-close -d 'Validate closure metadata per item' -r -a 'off warn strict'
1008
+ complete -c pm -n '__pm_history_operation close-many' -l author -d 'Mutation author' -r
1009
+ complete -c pm -n '__pm_history_operation close-many' -l message -d 'History message' -r
1010
+ complete -c pm -n '__pm_history_operation close-many' -l force -d 'Re-close terminal matches and override ownership'
1011
+ complete -c pm -n '__pm_history_operation close-many' -l dry-run -d 'Preview matched items without mutating'
1012
+ complete -c pm -n '__pm_history_operation close-many' -l rollback -d 'Rollback checkpoint ID' -r
1013
+ complete -c pm -n '__pm_history_operation close-many' -l no-checkpoint -d 'Disable checkpoint creation during apply mode'
1014
+
1015
+ # validate flags
1016
+ complete -c pm -n '__pm_history_operation validate' -l check-completeness -d 'Check declarative required fields'
1017
+ complete -c pm -n '__pm_history_operation validate' -l check-metadata -d 'Run metadata completeness checks'
1018
+ complete -c pm -n '__pm_history_operation validate' -l metadata-profile -d 'Select metadata validation profile for --check-metadata' -r -a 'core strict custom'
1019
+ complete -c pm -n '__pm_history_operation validate' -l check-resolution -d 'Run closed-item resolution metadata checks'
1020
+ complete -c pm -n '__pm_history_operation validate' -l check-lifecycle -d 'Run active-item lifecycle governance drift checks'
1021
+ complete -c pm -n '__pm_history_operation validate' -l check-stale-blockers -d 'Include stale blocker-pattern diagnostics in lifecycle checks'
1022
+ complete -c pm -n '__pm_history_operation validate' -l dependency-cycle-severity -d 'Set dependency-cycle warning policy for lifecycle checks' -r -a 'off warn error'
1023
+ complete -c pm -n '__pm_history_operation validate' -l parent-cycle-severity -d 'Set parent-hierarchy cycle warning policy for lifecycle checks' -r -a 'off warn error'
1024
+ complete -c pm -n '__pm_history_operation validate' -l check-files -d 'Run linked-file and orphaned-file checks'
1025
+ complete -c pm -n '__pm_history_operation validate' -l scan-mode -d 'Select file candidate scan mode for --check-files' -r -a 'default tracked-all tracked-all-strict'
1026
+ complete -c pm -n '__pm_history_operation validate' -l include-pm-internals -d 'Include PM storage internals in tracked-all candidate scans'
1027
+ complete -c pm -n '__pm_history_operation validate' -l verbose-file-lists -d 'Include full file-path lists for validate --check-files details'
1028
+ complete -c pm -n '__pm_history_operation validate' -l verbose-diagnostics -d 'Include full validate diagnostic ID lists instead of compact summaries'
1029
+ complete -c pm -n '__pm_history_operation validate' -l all-affected-ids -d 'Emit complete missing_* affected-ID lists with no truncation (implied by --json)'
1030
+ complete -c pm -n '__pm_history_operation validate' -l strict-exit -d 'Return non-zero exit when validation warnings are present'
1031
+ complete -c pm -n '__pm_history_operation validate' -l fail-on-warn -d 'Alias for --strict-exit'
1032
+ complete -c pm -n '__pm_history_operation validate' -l fix-hints -d 'Add a machine-executable fix_hints[] of pm commands to each failing check'
1033
+ complete -c pm -n '__pm_history_operation validate' -l auto-fix -d 'Apply the safe, deterministic subset of fix-hint remediations automatically'
1034
+ complete -c pm -n '__pm_history_operation validate' -l dry-run -d 'Preview planned --auto-fix/--prune-missing fixes without applying them'
1035
+ complete -c pm -n '__pm_history_operation validate' -l fix-scope -d 'Grant --auto-fix scopes (estimates/timestamps/lifecycle require opt-in)' -r -a 'metadata resolution estimates timestamps lifecycle'
1036
+ complete -c pm -n '__pm_history_operation validate' -l prune-missing -d 'Remove stale linked-file/doc links classified as deleted'
1037
+ complete -c pm -n '__pm_history_operation validate' -l check-history-drift -d 'Run item/history hash drift checks'
1038
+ complete -c pm -n '__pm_history_operation validate' -l check-command-references -d 'Run linked-command PM-ID reference checks'
1039
+ complete -c pm -n '__fish_seen_subcommand_from init' -l preset -d 'Governance preset for new setups' -r -a 'minimal default strict'
1040
+ complete -c pm -n '__fish_seen_subcommand_from init' -l id-prefix -d 'Set the item ID prefix' -r
1041
+ complete -c pm -n '__fish_seen_subcommand_from init' -l prefix -d 'Alias for --id-prefix' -r
1042
+ complete -c pm -n '__fish_seen_subcommand_from init' -l defaults -d 'Use non-interactive setup defaults'
1043
+ complete -c pm -n '__fish_seen_subcommand_from init' -s y -l yes -d 'Alias for --defaults'
1044
+ complete -c pm -n '__fish_seen_subcommand_from init' -l author -d 'Set the default mutation author for this project' -r
1045
+ complete -c pm -n '__fish_seen_subcommand_from init' -l agent-guidance -d 'Agent guidance mode' -r -a 'ask add skip status'
1046
+ complete -c pm -n '__fish_seen_subcommand_from init' -l type-preset -d 'Register domain item types' -r -a 'agile ops research'
1047
+ complete -c pm -n '__fish_seen_subcommand_from init' -l with-packages -d 'Install bundled first-party packages during initialization'
1048
+ complete -c pm -n '__fish_seen_subcommand_from init' -l verbose -d 'Include the full resolved settings tree in init output'
1049
+ complete -c pm -n '__fish_seen_subcommand_from config' -l criterion -d 'Criteria value for definition-of-done metadata-required-fields or lifecycle pattern keys (repeatable for set)' -r
1050
+ complete -c pm -n '__fish_seen_subcommand_from config' -l clear-criteria -d 'Clear config criteria-list key values'
1051
+ complete -c pm -n '__fish_seen_subcommand_from config' -l format -d 'Item format for item-format key' -r -a 'toon'
1052
+ complete -c pm -n '__fish_seen_subcommand_from config' -l policy -d 'Policy value for supported policy keys' -r
1053
+ complete -c pm -n '__pm_history_operation health' -l strict-directories -d 'Treat optional item-type directories as required failures'
1054
+ complete -c pm -n '__pm_history_operation health' -l check-only -d 'Run read-only health diagnostics without refreshing vectors'
1055
+ complete -c pm -n '__pm_history_operation health' -l no-refresh -d 'Disable automatic vector refresh attempts during health checks'
1056
+ complete -c pm -n '__pm_history_operation health' -l refresh-vectors -d 'Explicitly enable vector refresh attempts during health checks'
1057
+ complete -c pm -n '__pm_history_operation health' -l verbose-stale-items -d 'Include full stale vectorization ID lists in health output'
1058
+ complete -c pm -n '__pm_history_operation health' -l verbose-author-events -d 'Include complete actionable unknown-author coordinates'
1059
+ complete -c pm -n '__pm_history_operation health' -l brief -d 'Emit compact health details for low-token agent checks'
1060
+ complete -c pm -n '__pm_history_operation health' -l summary -d 'Emit one-line-style health status with check names and warning count'
1061
+ complete -c pm -n '__pm_history_operation health' -l strict-exit -d 'Return non-zero exit when health warnings are present'
1062
+ complete -c pm -n '__pm_history_operation health' -l fail-on-warn -d 'Alias for --strict-exit'
1063
+
1064
+ # completion shell argument
1065
+ complete -c pm -n '__fish_seen_subcommand_from completion' -l eager-tags -d 'Embed current tracker tags directly in script output'
1066
+ complete -c pm -n '__fish_seen_subcommand_from completion' -a 'bash zsh fish' -d 'Shell type'
1067
+
1068
+ # templates subcommands
1069
+ complete -c pm -n '__fish_seen_subcommand_from templates' -a 'save list show' -d 'Templates command'
1070
+
1071
+ # extension lifecycle flags
1072
+ complete -c pm -n '__fish_seen_subcommand_from extension' -a '${Be}' -d 'Extension action subcommand'
1073
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l init -d 'Generate starter extension scaffold'
1074
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l scaffold -d 'Alias for --init'
1075
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l capability -d 'Capability the init scaffold targets' -r -a '${at.join(" ")}'
1076
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l install -d 'Install extension from local path or GitHub source'
1077
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l uninstall -d 'Uninstall extension by name'
1078
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l explore -d 'List discovered extensions for selected scope'
1079
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l manage -d 'List managed extensions with update metadata'
1080
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l describe -d 'Map every surface a loaded extension registers'
1081
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l markdown -d 'Render describe output as a Markdown reference document'
1082
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l output -d 'Write describe Markdown to a file' -r
1083
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l reload -d 'Reload extensions with cache-busted module imports'
1084
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l watch -d 'Enable watch mode with --reload'
1085
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l doctor -d 'Run consolidated extension diagnostics'
1086
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l catalog -d 'List bundled first-party package catalog entries'
1087
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l adopt -d 'Adopt an unmanaged extension into managed metadata'
1088
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l adopt-all -d 'Adopt all unmanaged extensions into managed metadata'
1089
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l activate -d 'Activate extension in selected scope settings'
1090
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l deactivate -d 'Deactivate extension in selected scope settings'
1091
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l project -d 'Use project extension scope'
1092
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l local -d 'Alias for --project'
1093
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l global -d 'Use global extension scope'
1094
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l gh -d 'GitHub shorthand owner/repo/path' -r
1095
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l github -d 'Alias for --gh' -r
1096
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l ref -d 'Git ref/branch/tag for GitHub source' -r
1097
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l detail -d 'Detail mode for extension diagnostics' -r -a 'summary deep'
1098
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l trace -d 'Include registration traces in doctor deep diagnostics'
1099
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l runtime-probe -d 'Opt-in runtime activation probe for manage output'
1100
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l fix-managed-state -d 'Adopt unmanaged extensions before diagnostics/update checks'
1101
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l isolated -d 'Run doctor against project-scope extensions only'
1102
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l ignore-global -d 'Alias for --isolated'
1103
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l strict-exit -d 'Return non-zero exit when doctor warnings are present'
1104
+ complete -c pm -n '__fish_seen_subcommand_from extension' -l fail-on-warn -d 'Alias for --strict-exit (doctor)'
1105
+
1106
+ # package lifecycle flags
1107
+ for package_cmd in package packages
1108
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -a '${wt}' -d 'Package action subcommand'
1109
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l init -d 'Generate starter package scaffold'
1110
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l scaffold -d 'Alias for --init'
1111
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l capability -d 'Capability the init scaffold targets' -r -a '${at.join(" ")}'
1112
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l declarative -d 'Generate a composeExtension blueprint starter'
1113
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l install -d 'Install package from local path, GitHub source, npm source, or bundled alias'
1114
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l uninstall -d 'Uninstall package by name'
1115
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l explore -d 'List discovered packages for selected scope'
1116
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l manage -d 'List managed packages with update metadata'
1117
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l describe -d 'Map every surface a loaded package registers'
1118
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l markdown -d 'Render describe output as a Markdown reference document'
1119
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l output -d 'Write describe Markdown to a file' -r
1120
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l reload -d 'Reload packages with cache-busted module imports'
1121
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l watch -d 'Enable watch mode with --reload'
1122
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l doctor -d 'Run consolidated package diagnostics'
1123
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l catalog -d 'List bundled first-party package catalog entries'
1124
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l adopt -d 'Adopt an unmanaged package into managed metadata'
1125
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l adopt-all -d 'Adopt all unmanaged packages into managed metadata'
1126
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l activate -d 'Activate package in selected scope settings'
1127
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l deactivate -d 'Deactivate package in selected scope settings'
1128
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l project -d 'Use project package scope'
1129
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l local -d 'Alias for --project'
1130
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l global -d 'Use global package scope'
1131
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l gh -d 'GitHub shorthand owner/repo/path' -r
1132
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l github -d 'Alias for --gh' -r
1133
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l ref -d 'Git ref/branch/tag for GitHub source' -r
1134
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l detail -d 'Detail mode for package diagnostics' -r -a 'summary deep'
1135
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l trace -d 'Include registration traces in doctor deep diagnostics'
1136
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l runtime-probe -d 'Opt-in runtime activation probe for manage output'
1137
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l fix-managed-state -d 'Adopt unmanaged packages before diagnostics/update checks'
1138
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l isolated -d 'Run doctor against project-scope packages only'
1139
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l ignore-global -d 'Alias for --isolated'
1140
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l strict-exit -d 'Return non-zero exit when doctor warnings are present'
1141
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l fail-on-warn -d 'Alias for --strict-exit (doctor)'
1142
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l dry-run -d 'Plan upgrades without mutating'
1143
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l cli-only -d 'Upgrade only the pm CLI/SDK npm package'
1144
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l packages-only -d 'Upgrade only managed pm packages'
1145
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l repair -d 'Force npm global reinstall for the CLI/SDK'
1146
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l tag -d 'npm version or dist-tag for upgrades' -r
1147
+ complete -c pm -n "__fish_seen_subcommand_from $package_cmd" -l package-name -d 'Override the CLI package name' -r
1148
+ end`}function Ti(e){return e.replace(/([^a-zA-Z0-9_./\s-])/gu,"\\$1").replaceAll("'","'\\''")}function sn(e){let t=wo(e);return t.length===0?"":`${t.map(n=>` '${Ti(n)}[Runtime schema field flag]:value' \\`).join(`
1149
+ `)}
1150
+ `}function It(e,t={}){let n=t.trailingContinuation??!0,o=e.length-1;return e.map((r,i)=>` ${r}${n||i!==o?" \\":""}`).join(`
1151
+ `)}function Sy(){return[...yo,["ops","Workspace maintenance and diagnostics"]].filter(([e])=>!tn.has(e)).map(([e,t])=>` '${e}:${t}'`).join(`
1152
+ `)}function su(e){let t=["reviewer-missing[Select only items missing reviewer]","risk-missing[Select only items missing risk]","confidence-missing[Select only items missing confidence]","sprint-missing[Select only items missing sprint]","release-missing[Select only items missing release]"],n=e.includeContentMissingAliases===!0?["files-missing[Alias for --no-files]","docs-missing[Alias for --no-docs]"]:[],o=[["has-notes[Select only items that have notes]","no-notes[Select only items with no notes]"],["has-learnings[Select only items that have learnings]","no-learnings[Select only items with no learnings]"],["has-files[Select only items that have linked files]","no-files[Select only items with no linked files]"],["has-docs[Select only items that have linked docs]","no-docs[Select only items with no linked docs]"],["has-tests[Select only items that have linked tests]","no-tests[Select only items with no linked tests]"],["has-comments[Select only items that have comments]","no-comments[Select only items with no comments]"],["has-deps[Select only items that have dependencies]","no-deps[Select only items with no dependencies]"],["has-body[Select only items with non-empty body]","empty-body[Select only items with empty body]"],["has-linked-command[Select only items that have a linked command]","no-linked-command[Select only items with no linked command]"]];return It([...[...t,...n].map(r=>`'--${e.missingPrefix}${r}'`),...o.flatMap(([r,i])=>[`'--${e.pairedPrefix}${r}'`,`'--${e.pairedPrefix}${i}'`])])}var Ay=["'--comment[Comment seed author=<value>,created_at=<iso|now>,text=<value>]:comment'","'--note[Note seed author=<value>,created_at=<iso|now>,text=<value>]:note'","'--learning[Learning seed author=<value>,created_at=<iso|now>,text=<value>]:learning'","'--file[Linked file path=<value>,scope=<project|global>,note=<text>]:file'","'--test[Linked test command=<value>,path=<value>,scope=<project|global>]:test'","'--doc[Linked doc path=<value>,scope=<project|global>,note=<text>]:doc'","'--reminder[Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>]:reminder'","'--event[Event entry start=<iso|relative>,end=<iso|relative>,recur_*]:event'","'--type-option[Type option key=value or key=<name>,value=<value>]:type_option'","'--unset[Clear scalar fields by name (repeatable or csv)]:field'","'--replace-files[Atomically replace linked files with provided --file values]'","'--replace-docs[Atomically replace linked docs with provided --doc values]'","'--clear-deps[Clear dependency entries]'","'--clear-comments[Clear comments]'","'--clear-notes[Clear notes]'","'--clear-learnings[Clear learnings]'","'--clear-files[Clear linked files]'","'--clear-tests[Clear linked tests]'","'--clear-docs[Clear linked docs]'","'--clear-reminders[Clear reminders]'","'--clear-events[Clear events]'","'--clear-type-options[Clear type options]'"];function au(e){return It([...e==="reminder"?["'--at[Reminder time (default +1d)]:at'","'--text[Reminder text (defaults to title)]:text'"]:["'--start[Start time (ISO, now, or relative)]:start'","'--duration[Duration from start (default 1h)]:duration'","'--end[End time (overrides --duration)]:end'","'--location[Location]:location'","'--timezone[IANA timezone]:timezone'","'--all-day[Mark as an all-day event]'"],"'--parent[Parent item id]:parent'","'--allow-missing-parent[Permit a parent id that does not exist yet]'","'--tags[Comma-separated tags]:tags'","'(-p --priority)'{-p,--priority}'[Priority (0-4)]:(0 1 2 3 4)'","'(-b --body)'{-b,--body}'[Item body]:body'","'(-d --description)'{-d,--description}'[Short description]:description'","'--author[Mutation author]:author'","'--message[History message]:message'","'--json[Output JSON]'","'--quiet[Suppress stdout]'"],{trailingContinuation:!1})}function cu(e,t,n,o){return It([`'--filter-status[Filter by status before ${e}]:(${t})'`,`'--filter-type[Filter by type before ${e}]:(${n})'`,`'--filter-tag[Filter by tag before ${e}]:(${o})'`,`'--filter-priority[Filter by priority before ${e}]:(0 1 2 3 4)'`,"'--filter-deadline-before[Filter by deadline upper bound]:deadline'","'--filter-deadline-after[Filter by deadline lower bound]:deadline'","'--filter-updated-after[Filter by updated_at lower bound (ISO/relative)]:timestamp'","'--filter-updated-before[Filter by updated_at upper bound (ISO/relative)]:timestamp'","'--filter-created-after[Filter by created_at lower bound (ISO/relative)]:timestamp'","'--filter-created-before[Filter by created_at upper bound (ISO/relative)]:timestamp'",`'--filter-assignee[Filter by assignee before ${e}]:assignee'`,"'--filter-assignee-filter[Filter assignee presence]:(assigned unassigned)'","'--filter-parent[Filter by parent item ID]:parent'","'--filter-sprint[Filter by sprint]:sprint'","'--filter-release[Filter by release]:release'"])}function lu(e,t,n){let o=e.toUpperCase(),r=`PM_COMPLETION_${o}_CACHE`,i=`PM_COMPLETION_${o}_CACHE_TS`,s=`PM_COMPLETION_${o}_TTL`,a=rn(n);return`
1153
+ _pm_${e}_choices() {
1154
+ local now ttl cache_ts resolved
1155
+ now=\${EPOCHSECONDS:-0}
1156
+ ttl=\${${s}:-120}
1157
+ cache_ts=\${${i}:-0}
1158
+ if [[ -n "\${${r}:-}" && "$now" -ne 0 && $((now - cache_ts)) -lt "$ttl" ]]; then
1159
+ print -r -- "$${r}"
1160
+ return
1161
+ fi
1162
+ resolved="$(pm ${t} 2>/dev/null)"
1163
+ if [[ -z "$resolved" ]]; then
1164
+ resolved="${a}"
1165
+ fi
1166
+ ${r}="$resolved"
1167
+ ${i}="$now"
1168
+ print -r -- "$${r}"
1169
+ }
1170
+ `}function Oi(e=[],t=[],n=!1,o={}){let r=gt(o),i=e.length===0,s=At(e,o),a=xt(o),c=i?'${(f)"$(_pm_type_choices)"}':Ti(s),l='${(f)"$(_pm_status_choices)"}',d=bt,m=we(t),f=n||t.length>0,b=f?Ti(m):'${(f)"$(_pm_tag_choices)"}',g=sn(o.command_flags?.list),k=sn(o.command_flags?.create),y=sn(o.command_flags?.search),v=sn(o.command_flags?.calendar),_=sn(o.command_flags?.context),A=su({missingPrefix:"filter-",pairedPrefix:"",includeContentMissingAliases:!0}),N=su({missingPrefix:"filter-",pairedPrefix:"filter-"}),O=It(Ay),B=f?"":`
1171
+ _pm_tag_choices() {
1172
+ local now ttl cache_ts
1173
+ now=\${EPOCHSECONDS:-0}
1174
+ ttl=\${PM_COMPLETION_TAG_TTL:-120}
1175
+ cache_ts=\${PM_COMPLETION_TAG_CACHE_TS:-0}
1176
+ if [[ -n "\${PM_COMPLETION_TAG_CACHE:-}" && "$now" -ne 0 && $((now - cache_ts)) -lt "$ttl" ]]; then
1177
+ print -r -- "$PM_COMPLETION_TAG_CACHE"
1178
+ return
1179
+ fi
1180
+ PM_COMPLETION_TAG_CACHE="$(pm completion-tags 2>/dev/null)"
1181
+ PM_COMPLETION_TAG_CACHE_TS="$now"
1182
+ print -r -- "$PM_COMPLETION_TAG_CACHE"
1183
+ }
1184
+ `;return`#compdef pm
1185
+ # zsh completion for pm
1186
+ # Source this file or add 'eval "$(pm completion zsh)"' to ~/.zshrc
1187
+
1188
+ _pm_commands() {
1189
+ local -a commands
1190
+ commands=(
1191
+ ${Sy()}
1192
+ )
1193
+ _describe 'command' commands
1194
+ }
1195
+ ${B}
1196
+ ${i?lu("type","completion-types",s):""}
1197
+ ${lu("status","completion-statuses",a)}
1198
+
1199
+ _pm() {
1200
+ local context state line
1201
+ local -a words=("$words[@]")
1202
+ local CURRENT=$CURRENT
1203
+ local word_index=2 namespace_noun="" operation_path="" operation_index=0 word
1204
+ while (( word_index < CURRENT )); do
1205
+ word="$words[word_index]"
1206
+ case "\${word//_/-}" in
1207
+ ${vt}) (( word_index += 2 )); continue ;;
1208
+ ${kt}|${St}) (( word_index++ )); continue ;;
1209
+ --) break ;;
1210
+ esac
1211
+ if [[ -z "$namespace_noun" ]]; then
1212
+ [[ "$word" == "ctx" ]] && word="context"
1213
+ case "$word" in ${ht.join("|")}) ;; *) break ;; esac
1214
+ namespace_noun="$word"
1215
+ else
1216
+ case "$namespace_noun $word" in
1217
+ ${J.map($=>` "${$.canonical}") namespace_noun="${$.canonical}"; operation_path="$namespace_noun"; operation_index=$word_index ;;`).join(`
1218
+ `)}
1219
+ *) break ;;
1220
+ esac
1221
+ fi
1222
+ (( word_index++ ))
1223
+ done
1224
+ if [[ -n "$namespace_noun" ]] && (( word_index == CURRENT )) && [[ "$words[CURRENT]" != -* ]]; then
1225
+ local -a history_commands
1226
+ case "$namespace_noun" in
1227
+ ${Object.entries(r).map(([$,R])=>` "${$}") history_commands=(${R}) ;;`).join(`
1228
+ `)}
1229
+ esac
1230
+ if (( \${#history_commands} > 0 )); then
1231
+ _describe 'command operation' history_commands
1232
+ return
1233
+ fi
1234
+ fi
1235
+ if (( operation_index > 0 )); then
1236
+ case "$operation_path" in
1237
+ ${J.map($=>` "${$.canonical}") words=("$words[1]" "${$.alias}" "\${words[@]:$operation_index}"); (( CURRENT -= operation_index - 2 )) ;;`).join(`
1238
+ `)}
1239
+ esac
1240
+ fi
1241
+ _arguments -C \\
1242
+ '--json[Output JSON instead of TOON]' \\
1243
+ '--all[Reveal every public command and compatibility alias]' \\
1244
+ '--quiet[Suppress stdout output]' \\
1245
+ '--output-include[Retain comma-separated read fields or sections]:selectors' \\
1246
+ '--output-limit[Set the universal read row ceiling]:limit' \\
1247
+ '--output-budget[Set the universal estimated-token ceiling]:tokens' \\
1248
+ '--output-format[Select the universal read encoding]:(toon json)' \\
1249
+ '--output-session[Carry cross-call read budget and served-item state]:state' \\
1250
+ '--output-row-contract[Include row schema metadata in read output]' \\
1251
+ '--no-changed-fields[Omit changed_fields array from mutation output]' \\
1252
+ '--pm-path[Explicit tracker storage path for this command]:path:_files -/' \\
1253
+ '--path[Compatibility alias for --pm-path]:path:_files -/' \\
1254
+ '--no-extensions[Disable extension loading]' \\
1255
+ '--no-pager[Disable pager integration for help and long output]' \\
1256
+ '--profile[Print deterministic timing diagnostics]' \\
1257
+ '(-V --version)--version[Output the version number]' \\
1258
+ '(-h --help)--help[Display help]' \\
1259
+ '1: :_pm_commands' \\
1260
+ '*:: :->args' && return 0
1261
+
1262
+ case $state in
1263
+ args)
1264
+ case $line[1] in
1265
+ list)
1266
+ _arguments \\
1267
+ '*--status[Filter by status; repeatable, comma-separated, or all]:(${l})' \\
1268
+ '--all[Include every lifecycle status]' \\
1269
+ '--type[Filter by item type]:(${c})' \\
1270
+ '--tag[Filter by tag]:(${b})' \\
1271
+ '--tags[Alias for --tag]:(${b})' \\
1272
+ '--priority[Filter by priority]:(0 1 2 3 4)' \\
1273
+ '--deadline-before[Filter by deadline upper bound (ISO/date string or relative)]:date' \\
1274
+ '--deadline-after[Filter by deadline lower bound (ISO/date string or relative)]:date' \\
1275
+ '--today[Filter to items updated since local midnight today]' \\
1276
+ '--recent[Filter to items updated in the last 7 days]' \\
1277
+ '--updated-after[Filter by updated_at lower bound (ISO/relative)]:timestamp' \\
1278
+ '--updated-before[Filter by updated_at upper bound (ISO/relative)]:timestamp' \\
1279
+ '--created-after[Filter by created_at lower bound (ISO/relative)]:timestamp' \\
1280
+ '--created-before[Filter by created_at upper bound (ISO/relative)]:timestamp' \\
1281
+ '--assignee[Filter by assignee]:assignee' \\
1282
+ '--assignee-filter[Filter assignee presence]:(assigned unassigned)' \\
1283
+ '--sprint[Filter by sprint]:sprint' \\
1284
+ '--release[Filter by release]:release' \\
1285
+ ${A}
1286
+ '--limit[Limit returned item count]:number' \\
1287
+ '--offset[Skip the first n matching rows before limit]:number' \\
1288
+ '--no-truncate[Return every matched row, overriding --limit]' \\
1289
+ '--include-body[Include item body in each returned list row]' \\
1290
+ '--compact[Render compact list projection fields]' \\
1291
+ '--fields[Render custom comma-separated list fields]:fields' \\
1292
+ '--tree[Render hierarchical subtree output rooted at --parent or top-level parents]' \\
1293
+ '--tree-depth[Cap recursion depth for --tree (0 = root only)]:number' \\
1294
+ '--sort[Sort field]:(priority deadline updated_at created_at title parent)' \\
1295
+ '--order[Sort order (requires --sort)]:(asc desc)' \\
1296
+ '--stream[Emit line-delimited JSON rows (requires --json)]' \\
1297
+ ${g} '--json[Output JSON]' \\
1298
+ '--quiet[Suppress stdout]' \\
1299
+ '--pm-path[Explicit tracker storage path]:path:_files -/' \\
1300
+ '--path[Compatibility alias for --pm-path]:path:_files -/'
1301
+ ;;
1302
+ aggregate)
1303
+ _arguments \\
1304
+ '--group-by[Comma-separated group-by fields (supported: parent,type,priority,status,assignee,tags,sprint,release)]:fields' \\
1305
+ '--count[Return grouped counts]' \\
1306
+ '--completion[Add open/in_progress/closed/other counts and completion percentage]' \\
1307
+ '--sum[Numeric field to sum per group]:field' \\
1308
+ '--avg[Numeric field to average per group]:field' \\
1309
+ '--include-unparented[Include unparented rows when grouping by parent]' \\
1310
+ '--status[Filter by status]:(${l})' \\
1311
+ '--type[Filter by item type]:(${c})' \\
1312
+ '--tag[Filter by tag]:(${b})' \\
1313
+ '--priority[Filter by priority]:(0 1 2 3 4)' \\
1314
+ '--deadline-before[Filter by deadline upper bound (ISO/date string or relative)]:date' \\
1315
+ '--deadline-after[Filter by deadline lower bound (ISO/date string or relative)]:date' \\
1316
+ '--assignee[Filter by assignee]:assignee' \\
1317
+ '--assignee-filter[Filter assignee presence]:(assigned unassigned)' \\
1318
+ '--parent[Filter by parent item ID]:parent_id' \\
1319
+ '--sprint[Filter by sprint]:sprint' \\
1320
+ '--release[Filter by release]:release' \\
1321
+ '--json[Output JSON]' \\
1322
+ '--quiet[Suppress stdout]'
1323
+ ;;
1324
+ duplicates)
1325
+ _arguments \\
1326
+ '*--status[Include lifecycle status (repeatable)]:(${l})' \\
1327
+ '--since[Only inspect items created at or after this ISO timestamp]:timestamp' \\
1328
+ '--threshold[Minimum similarity score from zero through one]:number' \\
1329
+ '--limit[Maximum duplicate clusters]:number'
1330
+ ;;
1331
+ create)
1332
+ _arguments \\
1333
+ '(-t --title)'{-t,--title}'[Item title]:title' \\
1334
+ '(-d --description)'{-d,--description}'[Item description]:description' \\
1335
+ '--type[Item type]:(${c})' \\
1336
+ '--create-mode[Create required-option policy mode]:(strict progressive)' \\
1337
+ '*--defer[Defer a strict-required field as not known yet]:field:(deadline assignee acceptance-criteria estimate)' \\
1338
+ '--defer-reason[Why the deferred values are not known yet]:reason' \\
1339
+ '--schedule-preset[Scheduling preset for Reminder/Meeting/Event]:(lightweight)' \\
1340
+ '(-s --status)'{-s,--status}'[Item status]:(${l})' \\
1341
+ '(-p --priority)'{-p,--priority}'[Priority (0-4)]:(0 1 2 3 4)' \\
1342
+ '--tags[Comma-separated tags]:tags' \\
1343
+ '--add-tags[Add tags additively without replacing existing]:tags' \\
1344
+ '(-b --body)'{-b,--body}'[Item body]:body' \\
1345
+ '--body-file[Load the item body from a file]:body_file:_files' \\
1346
+ '--deadline[Deadline (ISO/date string or relative +6h/+1d/+2w/+6m)]:deadline' \\
1347
+ '--estimate[Estimated minutes]:minutes' \\
1348
+ '--acceptance-criteria[Acceptance criteria]:criteria' \\
1349
+ '--reminder[Reminder entry at=<iso|relative>|date=<iso|relative>,text=<text>|title=<text>]:reminder' \\
1350
+ '--event[Event entry start=<iso|relative>,end=<iso|relative>,recur_*]:event' \\
1351
+ '--type-option[Type option key=value or key=<name>,value=<value>]:type_option' \\
1352
+ '--unset[Clear scalar fields by name (repeatable or csv)]:field' \\
1353
+ '--replace-deps[Atomically replace dependencies with provided --dep values]' \\
1354
+ '--replace-tests[Atomically replace linked tests with provided --test values]' \\
1355
+ '--clear-deps[Clear dependency entries]' \\
1356
+ '--clear-comments[Clear comments]' \\
1357
+ '--clear-notes[Clear notes]' \\
1358
+ '--clear-learnings[Clear learnings]' \\
1359
+ '--clear-files[Clear linked files]' \\
1360
+ '--clear-tests[Clear linked tests]' \\
1361
+ '--clear-docs[Clear linked docs]' \\
1362
+ '--clear-reminders[Clear reminders]' \\
1363
+ '--clear-events[Clear events]' \\
1364
+ '--clear-type-options[Clear type options]' \\
1365
+ '--author[Mutation author]:author' \\
1366
+ '--message[History message]:message' \\
1367
+ '--assignee[Assignee]:assignee' \\
1368
+ ${k} '--json[Output JSON]' \\
1369
+ '--quiet[Suppress stdout]'
1370
+ ;;
1371
+ copy)
1372
+ _arguments \\
1373
+ '--title[Override copied title]:title' \\
1374
+ '--author[Mutation author]:author' \\
1375
+ '--message[History message]:message' \\
1376
+ '--force[Force ownership override]' \\
1377
+ '--json[Output JSON]' \\
1378
+ '--quiet[Suppress stdout]'
1379
+ ;;
1380
+ focus)
1381
+ _arguments \\
1382
+ '--clear[Clear the focused item]' \\
1383
+ '--json[Output JSON]' \\
1384
+ '--quiet[Suppress stdout]'
1385
+ ;;
1386
+ meet|event)
1387
+ _arguments \\
1388
+ ${au("event")}
1389
+ ;;
1390
+ remind)
1391
+ _arguments \\
1392
+ ${au("reminder")}
1393
+ ;;
1394
+ update)
1395
+ _arguments \\
1396
+ '(-t --title)'{-t,--title}'[Item title]:title' \\
1397
+ '(-d --description)'{-d,--description}'[Item description]:description' \\
1398
+ '(-b --body)'{-b,--body}'[Item body]:body' \\
1399
+ '--body-file[Load the item body from a file]:body_file:_files' \\
1400
+ '(-s --status)'{-s,--status}'[Item status]:(${l})' \\
1401
+ '--close-reason[Set close reason]:close_reason' \\
1402
+ '(-p --priority)'{-p,--priority}'[Priority (0-4)]:(0 1 2 3 4)' \\
1403
+ '--type[Item type]:(${c})' \\
1404
+ '--tags[Comma-separated tags]:tags' \\
1405
+ '--add-tags[Add tags additively without replacing existing]:tags' \\
1406
+ '--remove-tags[Remove tags from the existing list]:tags' \\
1407
+ '--add-ac[Add one acceptance criterion without replacing existing]:criteria' \\
1408
+ '--remove-ac[Remove one acceptance criterion by exact text]:criteria' \\
1409
+ '--expected[Short alias for --expected-result]:expected_result' \\
1410
+ '--actual[Short alias for --actual-result]:actual_result' \\
1411
+ ${O}
1412
+ '--author[Mutation author]:author' \\
1413
+ '--message[History message]:message' \\
1414
+ '--force[Force override]' \\
1415
+ '--json[Output JSON]' \\
1416
+ '--quiet[Suppress stdout]'
1417
+ ;;
1418
+ update-many)
1419
+ _arguments \\
1420
+ ${cu("applying updates",l,c,b)}
1421
+ '--filter-ac-missing[Select only items missing acceptance_criteria]' \\
1422
+ '--filter-estimates-missing[Select only items missing estimated_minutes]' \\
1423
+ '--filter-resolution-missing[Select only terminal items missing resolution]' \\
1424
+ '--filter-metadata-missing[Select only items missing any tracked metadata]' \\
1425
+ ${N}
1426
+ '--ids[Explicit comma-separated ID allowlist]:ids' \\
1427
+ '--limit[Limit matched item count]:number' \\
1428
+ '--offset[Skip first n matched rows]:number' \\
1429
+ '--dry-run[Preview updates without mutating]' \\
1430
+ '--rollback[Rollback checkpoint ID]:checkpoint_id' \\
1431
+ '--no-checkpoint[Disable checkpoint creation during apply mode]' \\
1432
+ '(-t --title)'{-t,--title}'[Item title]:title' \\
1433
+ '(-d --description)'{-d,--description}'[Item description]:description' \\
1434
+ '(-b --body)'{-b,--body}'[Item body]:body' \\
1435
+ '(-p --priority)'{-p,--priority}'[Priority (0-4)]:(0 1 2 3 4)' \\
1436
+ '--type[Item type]:(${c})' \\
1437
+ '--tags[Comma-separated tags]:tags' \\
1438
+ '--add-tags[Add tags additively without replacing existing]:tags' \\
1439
+ '--remove-tags[Remove tags from the existing list]:tags' \\
1440
+ '--deadline[Deadline (ISO/date string or relative +6h/+1d/+2w/+6m)]:deadline' \\
1441
+ '--estimate[Estimated minutes]:minutes' \\
1442
+ '--acceptance-criteria[Acceptance criteria]:criteria' \\
1443
+ '--add-ac[Add one acceptance criterion without replacing existing]:criteria' \\
1444
+ '--remove-ac[Remove one acceptance criterion by exact text]:criteria' \\
1445
+ '--definition-of-ready[Definition of ready]:definition_of_ready' \\
1446
+ '--order[Planning order/rank]:order' \\
1447
+ '--goal[Goal identifier]:goal' \\
1448
+ '--objective[Objective identifier]:objective' \\
1449
+ '--value[Business value summary]:value' \\
1450
+ '--impact[Business impact summary]:impact' \\
1451
+ '--outcome[Expected outcome summary]:outcome' \\
1452
+ '--why-now[Why-now rationale]:why_now' \\
1453
+ '--reviewer[Reviewer]:reviewer' \\
1454
+ '--risk[Risk level]:risk' \\
1455
+ '--confidence[Confidence level]:confidence' \\
1456
+ '--sprint[Sprint identifier]:sprint' \\
1457
+ '--release[Release identifier]:release' \\
1458
+ '--reporter[Issue reporter]:reporter' \\
1459
+ '--severity[Issue severity]:severity' \\
1460
+ '--environment[Issue environment context]:environment' \\
1461
+ '--repro-steps[Issue reproduction steps]:repro_steps' \\
1462
+ '--resolution[Issue resolution summary]:resolution' \\
1463
+ '--expected-result[Issue expected behavior]:expected_result' \\
1464
+ '--actual-result[Issue observed behavior]:actual_result' \\
1465
+ '--expected[Short alias for --expected-result]:expected_result' \\
1466
+ '--actual[Short alias for --actual-result]:actual_result' \\
1467
+ '--affected-version[Affected version identifier]:affected_version' \\
1468
+ '--fixed-version[Fixed version identifier]:fixed_version' \\
1469
+ '--component[Issue component ownership]:component' \\
1470
+ '--regression[Regression marker true|false|1|0]:regression' \\
1471
+ '--customer-impact[Customer impact summary]:customer_impact' \\
1472
+ '--dep[Dependency seed id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>]:dep' \\
1473
+ '--dep-remove[Dependency removal selector id=<id>,kind=<kind>,author=<author>,created_at=<timestamp>]:dep_remove' \\
1474
+ '--replace-deps[Atomically replace dependencies with provided --dep values]' \\
1475
+ '--replace-tests[Atomically replace linked tests with provided --test values]' \\
1476
+ ${O}
1477
+ '--author[Mutation author]:author' \\
1478
+ '--message[History message]:message' \\
1479
+ '--force[Force override]' \\
1480
+ '--json[Output JSON]' \\
1481
+ '--quiet[Suppress stdout]'
1482
+ ;;
1483
+ close-many)
1484
+ _arguments \\
1485
+ ${cu("closing",l,c,b)}
1486
+ ${N}
1487
+ '--ids[Explicit comma-separated ID allowlist]:ids' \\
1488
+ '--limit[Limit matched item count]:number' \\
1489
+ '--offset[Skip first n matched rows]:number' \\
1490
+ '--reason[Optional shared close reason applied to every matched item]:reason' \\
1491
+ '--resolution[Shared closure resolution]:resolution' \\
1492
+ '--expected-result[Shared expected-result note]:expected_result' \\
1493
+ '--actual-result[Shared actual-result note]:actual_result' \\
1494
+ '--expected[Short alias for --expected-result]:expected_result' \\
1495
+ '--actual[Short alias for --actual-result]:actual_result' \\
1496
+ '--validate-close[Validate closure metadata per item]:(off warn strict)' \\
1497
+ '--author[Mutation author]:author' \\
1498
+ '--message[History message]:message' \\
1499
+ '--force[Re-close terminal matches and override ownership]' \\
1500
+ '--dry-run[Preview matched items without mutating]' \\
1501
+ '--rollback[Rollback checkpoint ID]:checkpoint_id' \\
1502
+ '--no-checkpoint[Disable checkpoint creation during apply mode]' \\
1503
+ '--json[Output JSON]' \\
1504
+ '--quiet[Suppress stdout]'
1505
+ ;;
1506
+ calendar|cal)
1507
+ _arguments \\
1508
+ '--view[Calendar view]:(agenda day week month)' \\
1509
+ '--date[Anchor date/time (ISO/date string or relative)]:date' \\
1510
+ '--from[Agenda lower bound (ISO/date string or relative)]:date' \\
1511
+ '--to[Agenda upper bound (ISO/date string or relative)]:date' \\
1512
+ '--past[Include past entries]' \\
1513
+ '--full-period[Include full anchored day/week/month period]' \\
1514
+ '--type[Filter by type]:(${c})' \\
1515
+ '--tag[Filter by tag]:(${b})' \\
1516
+ '--priority[Filter by priority]:(0 1 2 3 4)' \\
1517
+ '--status[Filter by status]:(${l})' \\
1518
+ '--assignee[Filter by assignee]:assignee' \\
1519
+ '--assignee-filter[Filter assignee presence]:(assigned unassigned)' \\
1520
+ '--sprint[Filter by sprint]:sprint' \\
1521
+ '--release[Filter by release]:release' \\
1522
+ ${v} '--include[Include event sources]:(all deadlines reminders events scheduled)' \\
1523
+ '--recurrence-lookahead-days[Bound open-ended recurrence lookahead]:days' \\
1524
+ '--recurrence-lookback-days[Bound open-ended recurrence lookback]:days' \\
1525
+ '--occurrence-limit[Cap occurrences per recurring event]:number' \\
1526
+ '--after[Continue a fixed-window calendar page]:cursor' \\
1527
+ '--limit[Limit returned events]:number' \\
1528
+ '--format[Output override]:(markdown toon json)' \\
1529
+ '--json[Output JSON]' \\
1530
+ '--quiet[Suppress stdout]'
1531
+ ;;
1532
+ context|ctx)
1533
+ _arguments \\
1534
+ '--date[Anchor date/time (ISO/date string or relative)]:date' \\
1535
+ '--from[Agenda lower bound (ISO/date string or relative)]:date' \\
1536
+ '--to[Agenda upper bound (ISO/date string or relative)]:date' \\
1537
+ '--past[Include past entries in bounded windows]' \\
1538
+ '--type[Filter by type]:(${c})' \\
1539
+ '--tag[Filter by tag]:(${b})' \\
1540
+ '--priority[Filter by priority]:(0 1 2 3 4)' \\
1541
+ '--assignee[Filter by assignee]:assignee' \\
1542
+ '--assignee-filter[Filter assignee presence]:(assigned unassigned)' \\
1543
+ '--sprint[Filter by sprint]:sprint' \\
1544
+ '--release[Filter by release]:release' \\
1545
+ '--parent[Scope snapshot to one item subtree]:id' \\
1546
+ '--limit[Limit focus and agenda rows per section]:number' \\
1547
+ '--depth[Context depth]:(brief standard deep full)' \\
1548
+ '--format[Output override]:(markdown toon json)' \\
1549
+ ${_} '--json[Output JSON]' \\
1550
+ '--quiet[Suppress stdout]'
1551
+ ;;
1552
+ next)
1553
+ _arguments \\
1554
+ '--type[Filter candidates by type]:(${c})' \\
1555
+ '--tag[Filter candidates by tag]:(${b})' \\
1556
+ '--priority[Filter candidates by priority]:(0 1 2 3 4)' \\
1557
+ '--assignee[Filter candidates by assignee]:assignee' \\
1558
+ '--assignee-filter[Filter assignee presence]:(assigned unassigned)' \\
1559
+ '--sprint[Filter candidates by sprint]:sprint' \\
1560
+ '--release[Filter candidates by release]:release' \\
1561
+ '--parent[Scope to one item subtree]:id' \\
1562
+ '--limit[Limit ready rows]:number' \\
1563
+ '--blocked-limit[Limit blocked rows]:number' \\
1564
+ '--ready-only[Omit the blocked companion list]' \\
1565
+ '--format[Output override]:(markdown toon json)' \\
1566
+ '--json[Output JSON]' \\
1567
+ '--quiet[Suppress stdout]'
1568
+ ;;
1569
+ guide)
1570
+ _arguments \\
1571
+ '1:topic:(${d})' \\
1572
+ '--list[Show guide topic index]' \\
1573
+ '--format[Output override]:(markdown toon json)' \\
1574
+ '--depth[Guide detail depth]:(brief standard deep)' \\
1575
+ '--json[Output JSON]' \\
1576
+ '--quiet[Suppress stdout]'
1577
+ ;;
1578
+ search)
1579
+ _arguments \\
1580
+ '--mode[Search mode]:(keyword semantic hybrid)' \\
1581
+ '--match-mode[Token match mode]:(and or exact)' \\
1582
+ '--min-score[Per-query minimum score threshold]:number' \\
1583
+ '--count[Return only the match count]' \\
1584
+ '--include-linked[Include linked content in scoring]' \\
1585
+ '--highlight[Emit per-field matched-text snippets on each hit]' \\
1586
+ '--limit[Max results]:number' \\
1587
+ '--status[Filter by status (open/closed/canceled, csv)]:(${l})' \\
1588
+ '--type[Filter by type]:(${c})' \\
1589
+ '--tag[Filter by tag]:(${b})' \\
1590
+ '--tags[Alias for --tag]:(${b})' \\
1591
+ '--priority[Filter by priority]:(0 1 2 3 4)' \\
1592
+ '--updated-after[Filter by updated_at lower bound]:value' \\
1593
+ '--updated-before[Filter by updated_at upper bound]:value' \\
1594
+ '--created-after[Filter by created_at lower bound]:value' \\
1595
+ '--created-before[Filter by created_at upper bound]:value' \\
1596
+ '--assignee[Filter by assignee]:value' \\
1597
+ '--sprint[Filter by sprint]:value' \\
1598
+ '--release[Filter by release]:value' \\
1599
+ '--parent[Filter by parent item ID]:value' \\
1600
+ ${A}
1601
+ ${y} '--json[Output JSON]' \\
1602
+ '--quiet[Suppress stdout]'
1603
+ ;;
1604
+ reindex)
1605
+ _arguments \\
1606
+ '--mode[Reindex mode]:(keyword semantic hybrid)' \\
1607
+ '--progress[Emit progress updates to stderr]' \\
1608
+ '--json[Output JSON]' \\
1609
+ '--quiet[Suppress stdout]'
1610
+ ;;
1611
+ history)
1612
+ _arguments \\
1613
+ '--limit[Max entries]:number' \\
1614
+ '--compact[Condensed history projection]' \\
1615
+ '--full[Show full history entries]' \\
1616
+ '--provenance[Patch-free identity and agent provenance projection]' \\
1617
+ '--provenance-summary[Include bounded provenance completeness counts]' \\
1618
+ '*--harness[Filter by recorded or vocabulary-resolved harness]:harness' \\
1619
+ '*--agent-instance[Filter by privacy-safe agent instance]:instance' \\
1620
+ '*--provenance-filter[Filter by exact declared provenance value]:dimension=value' \\
1621
+ '--diff[Include per-entry field-level before/after value diffs]' \\
1622
+ '--field[With --diff, show only entries that changed this field]:field' \\
1623
+ '--verify[Verify history hash chain and replay integrity]' \\
1624
+ '--json[Output JSON]' \\
1625
+ '--quiet[Suppress stdout]'
1626
+ ;;
1627
+ events)
1628
+ _arguments \\
1629
+ '--since[Resume after a cursor or from an ISO timestamp]:cursor_or_timestamp' \\
1630
+ '*--type[Filter by mutation operation]:operation' \\
1631
+ '*--author[Filter by mutation author]:author' \\
1632
+ '*--item[Filter by item or workspace stream]:item' \\
1633
+ '--limit[Maximum events, up to 1000]:number' \\
1634
+ '--full[Include complete authoritative history entries]' \\
1635
+ '--provenance[Include patch-free identity and agent provenance]' \\
1636
+ '--provenance-summary[Include bounded provenance completeness counts]' \\
1637
+ '*--harness[Filter by recorded or vocabulary-resolved harness]:harness' \\
1638
+ '*--agent-instance[Filter by privacy-safe agent instance]:instance' \\
1639
+ '*--provenance-filter[Filter by exact declared provenance value]:dimension=value' \\
1640
+ '--follow[Continue emitting committed events]' \\
1641
+ '--interval-ms[Empty-read delay while following]:milliseconds' \\
1642
+ '--json[Output JSON]' \\
1643
+ '--quiet[Suppress stdout]'
1644
+ ;;
1645
+ history-attest)
1646
+ _arguments \\
1647
+ ${It(go.map($=>`'${$.flag}[${$.description}]${$.takes_value?":value":""}'`),{trailingContinuation:!1})}
1648
+ ;;
1649
+ history-compact)
1650
+ _arguments \\
1651
+ '--id[Item ID (alternative to positional ID)]:id' \\
1652
+ '--before[Compact entries strictly before this version number or ISO timestamp]:before' \\
1653
+ '--ids[Bulk: compact an explicit comma-separated list of item ids]:ids' \\
1654
+ '--all-over[Bulk: compact every stream with more than N entries]:all-over' \\
1655
+ '--closed[Bulk: compact only closed (terminal) items streams]' \\
1656
+ '--all-streams[Bulk: compact every history stream regardless of lifecycle state]' \\
1657
+ '--min-entries[Bulk: skip streams with at most N entries]:min-entries' \\
1658
+ '--dry-run[Preview compaction impact without writing the history file]' \\
1659
+ '--author[Mutation author]:author' \\
1660
+ '--message[Audit history message]:message' \\
1661
+ '--force[Force ownership/lock override]' \\
1662
+ '--json[Output JSON]' \\
1663
+ '--quiet[Suppress stdout]'
1664
+ ;;
1665
+ history-author-acknowledge)
1666
+ _arguments \\
1667
+ '*--event[Actionable unknown-author event]:item_and_line' \\
1668
+ '--all-actionable[Select every currently actionable event]' \\
1669
+ '--dry-run[Preview a deterministic source-bound plan]' \\
1670
+ '--plan-fingerprint[Apply the exact dry-run plan]:sha256' \\
1671
+ '--limit[Maximum coordinate rows returned in the plan]:number' \\
1672
+ '--attributed-author[Principal attributed by maintainer review]:author' \\
1673
+ '--reviewer[Reviewer recording the disposition]:reviewer' \\
1674
+ '--reason[Evidence-backed review rationale]:reason' \\
1675
+ '--json[Output JSON]' \\
1676
+ '--quiet[Suppress stdout]'
1677
+ ;;
1678
+ get)
1679
+ _arguments \\
1680
+ '--depth[Detail depth]:(brief standard deep full)' \\
1681
+ '--full[Explicit full item read]' \\
1682
+ '--fields[Render custom comma-separated item fields]:fields' \\
1683
+ '--tree[Include descendant subtree in result payload]' \\
1684
+ '--tree-depth[Cap subtree depth for --tree (0 = root only)]:number' \\
1685
+ '--json[Output JSON]' \\
1686
+ '--quiet[Suppress stdout]'
1687
+ ;;
1688
+ history-redact)
1689
+ _arguments \\
1690
+ '--id[Item ID (alternative to positional ID)]:id' \\
1691
+ '--literal[Literal string matcher to redact from history/item payloads]:literal' \\
1692
+ '--regex[Regex matcher to redact (/pattern/flags or raw pattern)]:regex' \\
1693
+ '--replacement[Replacement text (defaults to [redacted])]:replacement' \\
1694
+ '--dry-run[Preview redaction impact without writing files]' \\
1695
+ '--author[Mutation author]:author' \\
1696
+ '--message[Audit history message]:message' \\
1697
+ '--force[Force ownership/lock override]' \\
1698
+ '--json[Output JSON]' \\
1699
+ '--quiet[Suppress stdout]'
1700
+ ;;
1701
+ history-repair)
1702
+ _arguments \\
1703
+ '--id[Item ID (alternative to positional ID)]:id' \\
1704
+ '--salvage-tail[Remove JSON null, boolean and number lines and an invalid suffix after a verified prefix]' \\
1705
+ '--append-only[Bridge chain breaks with one appended record]' \\
1706
+ '--normalize-provenance[Remove invalid provenance with aggregate evidence]' \\
1707
+ '--all[Repair every drifted stream in one audited pass]' \\
1708
+ '--dry-run[Preview the re-anchor impact without writing the history file]' \\
1709
+ '--author[Mutation author]:author' \\
1710
+ '--message[Audit history message]:message' \\
1711
+ '--force[Force ownership/lock override]' \\
1712
+ '--json[Output JSON]' \\
1713
+ '--quiet[Suppress stdout]'
1714
+ ;;
1715
+ schema)
1716
+ if [[ "\${words[CURRENT-1]}" == policy-mode ]]; then
1717
+ compadd advise refuse
1718
+ return
1719
+ fi
1720
+ _arguments \\
1721
+ '1:subcommand:(${yt})' \\
1722
+ '--definition[Policy definition or proposed fields JSON]:json' \\
1723
+ '--policy[Approval policy id]:id' \\
1724
+ '--message[History rationale]:text' \\
1725
+ '--dry-run[Preview schema changes]' \\
1726
+ '--description[Human description for the custom item type, status, or field]:text' \\
1727
+ '--default-status[Default status hint for the custom item type]:status' \\
1728
+ '--folder[Storage folder for items of this custom type]:dir' \\
1729
+ '--alias[Alias for the custom type, status, or field flag (repeatable)]:name' \\
1730
+ '--role[Lifecycle role for a custom status (repeatable)]:role' \\
1731
+ '--order[Display/sort order for a custom status]:n' \\
1732
+ '--type[Value type for a custom field]:type:(string number boolean string_array array object)' \\
1733
+ '--commands[Commands a custom field is wired onto (repeatable)]:commands' \\
1734
+ '--cli-flag[Override the auto-derived CLI flag for a custom field]:flag' \\
1735
+ '--required[Mark a custom field as always required]' \\
1736
+ '--required-on-create[Mark a custom field as required at create time]' \\
1737
+ '--no-allow-unset[Disallow clearing a custom field via --unset]' \\
1738
+ '--required-types[Restrict a custom field requirement to specific item types (repeatable)]:types' \\
1739
+ '--infer[Infer item types from title-prefix conventions (add-type)]' \\
1740
+ '--min-count[Minimum items sharing a prefix for --infer]:n' \\
1741
+ '--apply[Register inferred types (with --infer)]' \\
1742
+ '--author[Mutation author]:author' \\
1743
+ '--force[Force ownership/lock override]' \\
1744
+ '--json[Output JSON]' \\
1745
+ '--quiet[Suppress stdout]'
1746
+ ;;
1747
+ profile)
1748
+ _arguments \\
1749
+ '1:subcommand:(list show apply lint)' \\
1750
+ '2:name:(agile ops research)' \\
1751
+ '--dry-run[Preview the apply diff without writing any files]' \\
1752
+ '--author[Mutation author]:author' \\
1753
+ '--force[Force ownership/lock override]' \\
1754
+ '--json[Output JSON]' \\
1755
+ '--quiet[Suppress stdout]'
1756
+ ;;
1757
+ plan)
1758
+ _arguments \\
1759
+ '1:subcommand:(create show add-step update-step complete-step block-step reorder-step remove-step link unlink decision discovery validation resume approve materialize)' \\
1760
+ '--title[Plan title]:title' \\
1761
+ '--scope[Plan scope statement]:scope' \\
1762
+ '--harness[Plan harness provenance]:harness:(codex claude-code cursor generic)' \\
1763
+ '--mode[Plan mode]:mode:(draft research review approved executing paused completed superseded)' \\
1764
+ '--resume-context[Resume context summary]:text' \\
1765
+ '--step-title[Step title]:title' \\
1766
+ '*--step[Step title (repeatable on create)]:title' \\
1767
+ '--step-status[Step status]:status:(pending in_progress completed blocked skipped superseded)' \\
1768
+ '--step-evidence[Step evidence]:text' \\
1769
+ '--depends-on[Pm item id step depends on]:id' \\
1770
+ '--link[Pm item id to link]:id' \\
1771
+ '--link-kind[Link kind]:kind:(related blocks blocked_by depends_on discovered_from implements verifies supersedes)' \\
1772
+ '--depth[Show depth]:depth:(brief standard deep)' \\
1773
+ '--steps[Step ids/orders for materialize]:steps' \\
1774
+ '--materialize-type[Item type for materialized steps]:type' \\
1775
+ '--allow-multiple-active[Allow multiple in_progress steps]' \\
1776
+ '--promote-to-item-dep[Also add link as top-level item dependency]' \\
1777
+ '--author[Mutation author]:author' \\
1778
+ '--message[Mutation message]:message' \\
1779
+ '--force[Force ownership override]' \\
1780
+ '--json[Output JSON]' \\
1781
+ '--quiet[Suppress stdout]'
1782
+ ;;
1783
+ activity)
1784
+ _arguments \\
1785
+ '--id[Filter by item ID]:id' \\
1786
+ '--op[Filter by history operation]:op' \\
1787
+ '--author[Filter by history author]:author' \\
1788
+ '--from[Lower timestamp bound (ISO/date string or relative)]:date' \\
1789
+ '--to[Upper timestamp bound (ISO/date string or relative)]:date' \\
1790
+ '--after[Continue a fixed-window activity page]:cursor' \\
1791
+ '--limit[Max entries]:number' \\
1792
+ '--unbounded[Return every matching activity entry]' \\
1793
+ '--compact[Condensed activity projection]' \\
1794
+ '--raw[Emit raw compact per-event activity output]' \\
1795
+ '--full[Show full activity entries]' \\
1796
+ '--provenance[Patch-free identity and agent provenance projection]' \\
1797
+ '--provenance-summary[Include bounded provenance completeness counts]' \\
1798
+ '*--harness[Filter by recorded or vocabulary-resolved harness]:harness' \\
1799
+ '*--agent-instance[Filter by privacy-safe agent instance]:instance' \\
1800
+ '*--provenance-filter[Filter by exact declared provenance value]:dimension=value' \\
1801
+ '--stream[Emit line-delimited JSON rows (requires --json)]::mode:(rows ndjson jsonl)' \\
1802
+ '--json[Output JSON]' \\
1803
+ '--quiet[Suppress stdout]'
1804
+ ;;
1805
+ contracts)
1806
+ _arguments \\
1807
+ '--action[Filter schema by tool action]:action' \\
1808
+ '--command[Scope output to one command (narrow-by-default)]:command' \\
1809
+ '--summary[Return compact command intent summary]' \\
1810
+ '--schema-only[Return schema-only payload]' \\
1811
+ '--flags-only[Return command flag contracts only]' \\
1812
+ '--availability-only[Return action availability only]' \\
1813
+ '--runtime-only[Include only actions invocable in the current runtime]' \\
1814
+ '--active-only[Alias for --runtime-only]' \\
1815
+ '--full[Include complete command and schema contract details]' \\
1816
+ '--json[Output JSON]' \\
1817
+ '--quiet[Suppress stdout]'
1818
+ ;;
1819
+ gc)
1820
+ _arguments \\
1821
+ '--dry-run[Preview cleanup targets without deleting files]' \\
1822
+ '--scope[Limit cleanup to one or more scopes: index, embeddings, runtime, locks, checkpoints, transactions]:scope' \\
1823
+ '--json[Output JSON]' \\
1824
+ '--quiet[Suppress stdout]'
1825
+ ;;
1826
+ stats)
1827
+ _arguments \\
1828
+ '--include-empty[Include registered zero-count type and status buckets]' \\
1829
+ '--storage[Include aggregate history-stream storage metrics]' \\
1830
+ '--metadata-coverage[Include metadata coverage percentages overall and by type]' \\
1831
+ '--field-utilization[Include content-field utilization rates across all items]' \\
1832
+ '--by-assignee[Lifecycle-bucketed breakdown grouped by assignee]' \\
1833
+ '--by-tag[Lifecycle-bucketed breakdown grouped by tag]' \\
1834
+ '--by-priority[Lifecycle-bucketed breakdown grouped by priority]' \\
1835
+ '--tag-prefix[With --by-tag: only count tags with this prefix]:prefix' \\
1836
+ '--json[Output JSON]' \\
1837
+ '--quiet[Suppress stdout]'
1838
+ ;;
1839
+ comments)
1840
+ _arguments \\
1841
+ '--add[Add one entry (plain text, text=<value>, markdown pairs, or - for stdin)]:text' \\
1842
+ '--text[Alias for --add]:text' \\
1843
+ '--stdin[Read comment text from stdin (supports multiline markdown)]' \\
1844
+ '--file[Read comment text from file (supports multiline markdown)]:path' \\
1845
+ '--edit[Replace the comment at 1-based index (text from positional/--add/--stdin/--file)]:index' \\
1846
+ '--delete[Delete the comment at 1-based index]:index' \\
1847
+ '--limit[Return only latest n entries]:number' \\
1848
+ '--expect-at[Edit/delete only if the entry created_at matches]:timestamp' \\
1849
+ '--full-history[Return complete post-mutation history]' \\
1850
+ '--if-absent[Append only when the resolved author and text are absent]' \\
1851
+ '--author[Entry author (falls back to PM_AUTHOR/settings)]:author' \\
1852
+ '--message[History message]:message' \\
1853
+ '--force[Force override]' \\
1854
+ '--json[Output JSON]' \\
1855
+ '--quiet[Suppress stdout]'
1856
+ ;;
1857
+ notes)
1858
+ _arguments \\
1859
+ '--add[Add one entry (plain text, text=<value>, markdown pairs, or - for stdin)]:text' \\
1860
+ '--text[Alias for --add]:text' \\
1861
+ '--add-json[Append one validated JSON context event]:json' \\
1862
+ '--stdin[Read entry text from stdin]' \\
1863
+ '--file[Read entry text from file]:path' \\
1864
+ '--edit[Replace the entry at a 1-based index]:index' \\
1865
+ '--delete[Delete the entry at a 1-based index]:index' \\
1866
+ '--limit[Return only latest n entries]:number' \\
1867
+ '--since[Return structured events at or after an ISO timestamp]:timestamp' \\
1868
+ '--event-type[Return structured events with this top-level type]:event_type' \\
1869
+ '--include-meta[Include result counts and truncation metadata]' \\
1870
+ '--expect-at[Edit/delete only if the entry created_at matches]:timestamp' \\
1871
+ '--full-history[Return complete post-mutation history]' \\
1872
+ '--if-absent[Append only when the resolved author and text are absent]' \\
1873
+ '--author[Entry author (falls back to PM_AUTHOR/settings)]:author' \\
1874
+ '--message[History message]:message' \\
1875
+ '--force[Force override]' \\
1876
+ '--json[Output JSON]' \\
1877
+ '--quiet[Suppress stdout]'
1878
+ ;;
1879
+ learnings)
1880
+ _arguments \\
1881
+ '--add[Add one entry (plain text, text=<value>, markdown pairs, or - for stdin)]:text' \\
1882
+ '--text[Alias for --add]:text' \\
1883
+ '--stdin[Read entry text from stdin]' \\
1884
+ '--file[Read entry text from file]:path' \\
1885
+ '--edit[Replace the entry at a 1-based index]:index' \\
1886
+ '--delete[Delete the entry at a 1-based index]:index' \\
1887
+ '--limit[Return only latest n entries]:number' \\
1888
+ '--expect-at[Edit/delete only if the entry created_at matches]:timestamp' \\
1889
+ '--full-history[Return complete post-mutation history]' \\
1890
+ '--if-absent[Append only when the resolved author and text are absent]' \\
1891
+ '--author[Entry author (falls back to PM_AUTHOR/settings)]:author' \\
1892
+ '--message[History message]:message' \\
1893
+ '--force[Force override]' \\
1894
+ '--json[Output JSON]' \\
1895
+ '--quiet[Suppress stdout]'
1896
+ ;;
1897
+ files)
1898
+ _arguments \\
1899
+ '1:subcommand:(discover lookup)' \\
1900
+ '--add[Add a linked file]:file' \\
1901
+ '--add-glob[Add linked files matching a glob]:glob' \\
1902
+ '--remove[Remove a linked file]:file' \\
1903
+ '--migrate[Migrate linked-file metadata]' \\
1904
+ '--list[List linked files]' \\
1905
+ '--apply[Apply discovered linked files]' \\
1906
+ '--note[Linked-file note]:note' \\
1907
+ '--note-conflict[Treatment of an existing different note]:(refuse replace append)' \\
1908
+ '--append-stable[Preserve stable append ordering]' \\
1909
+ '--validate-paths[Validate linked-file paths]' \\
1910
+ '--full-history[Return every linked file after a write]' \\
1911
+ '--scope[Filter lookup by evidence scope]:(project global)' \\
1912
+ '--limit[Maximum lookup matches]:number' \\
1913
+ '--offset[Skip the first lookup matches]:number' \\
1914
+ '--no-truncate[Return every lookup match]' \\
1915
+ '--strict-read[Require authoritative source reads]' \\
1916
+ '--explain[Include ranked source-to-work rationale]' \\
1917
+ '--lines[Attribute an inclusive source line range]:start_end' \\
1918
+ '--decision-depth[Maximum governing-decision relationship depth]:number' \\
1919
+ '--author[Mutation author]:author' \\
1920
+ '--message[History message]:message' \\
1921
+ '--force[Force override]' \\
1922
+ '--json[Output JSON]' \\
1923
+ '--quiet[Suppress stdout]'
1924
+ ;;
1925
+ deps)
1926
+ _arguments \\
1927
+ '--format[Output format]:(tree graph context)' \\
1928
+ '--max-depth[Maximum traversal depth (0 keeps root only)]:depth' \\
1929
+ '--collapse[Collapse mode]:(none repeated)' \\
1930
+ '--summary[Return counts only without tree/graph payload]' \\
1931
+ '--node-limit[Maximum nodes in context output]:number' \\
1932
+ '--edge-limit[Maximum edges in context output]:number' \\
1933
+ '--token-budget[Maximum estimated tokens in context output]:number' \\
1934
+ '--cursor[Continue an equivalent context query]:cursor' \\
1935
+ '--direction[Context traversal direction]:(outgoing incoming both)' \\
1936
+ '--kind[Restrict context traversal to relationship kinds]:kind' \\
1937
+ '--json[Output JSON]' \\
1938
+ '--quiet[Suppress stdout]'
1939
+ ;;
1940
+ graph)
1941
+ _arguments \\
1942
+ '1:subcommand:(ancestors descendants predecessors successors paths impact analyze audit communities redundancy dominators slack centrality articulation plan index)' \\
1943
+ '--kind[Restrict traversal to registered relationship kinds]:kind' \\
1944
+ '--max-depth[Maximum traversal depth]:depth' \\
1945
+ '--limit[Maximum returned rows per bounded collection]:number' \\
1946
+ '--after[Resume a traversal after this node id]:id' \\
1947
+ '--direction[Edge orientation for paths/impact]:(outgoing incoming both)' \\
1948
+ '--max-paths[Maximum enumerated paths]:number' \\
1949
+ '--sample[Maximum evidence sample entries per audit finding]:number' \\
1950
+ '--exempt-isolate[Item ids treated as explicitly valid isolates]:id' \\
1951
+ '--exempt-isolate-type[Item types whose active isolates are policy-valid]:type' \\
1952
+ '--save-baseline[Persist the audit census as the comparison baseline]' \\
1953
+ '--rebuild[Rebuild and warm the durable graph index]' \\
1954
+ '--clear[Delete the durable graph index]' \\
1955
+ '--summary[Return counts-first envelopes without row collections]' \\
1956
+ '--json[Output JSON]' \\
1957
+ '--quiet[Suppress stdout]'
1958
+ ;;
1959
+ test)
1960
+ _arguments \\
1961
+ '--add[Add linked test entry]:entry' \\
1962
+ '--add-json[Add linked test entry from JSON object/array]:json' \\
1963
+ '--remove[Remove linked test entry by command/path]:entry' \\
1964
+ '--remove-index[Remove linked test entry by 1-based index]:index' \\
1965
+ '--list[List linked tests without mutating]' \\
1966
+ '--run[Run linked tests]' \\
1967
+ '--match[Run linked tests whose command/path contains substring]:substring' \\
1968
+ '--only-index[Run one linked test by 1-based index]:number' \\
1969
+ '--only-last[Run the most recently added linked test]' \\
1970
+ '--full-history[Return every linked test after a write]' \\
1971
+ '--background[Run linked tests in managed background mode]' \\
1972
+ '--timeout[Default timeout seconds]:seconds' \\
1973
+ '--progress[Emit linked-test progress to stderr]' \\
1974
+ '--env-set[Set linked-test runtime environment values]:entry' \\
1975
+ '--env-clear[Clear linked-test runtime environment values]:name' \\
1976
+ '--shared-host-safe[Apply shared-host-safe runtime defaults]' \\
1977
+ '--pm-context[PM linked-test context mode]:(schema tracker auto none)' \\
1978
+ '--override-linked-pm-context[Force run-level --pm-context over per-linked-test pm_context_mode metadata]' \\
1979
+ '--fail-on-context-mismatch[Fail when context item counts mismatch]' \\
1980
+ '--fail-on-skipped[Treat skipped linked tests as dependency failures]' \\
1981
+ '--fail-on-empty-test-run[Treat empty linked-test selections as failures]' \\
1982
+ '--require-assertions-for-pm[Require assertions for linked PM command tests]' \\
1983
+ '--check-context[Preflight linked PM command context diagnostics before execution]' \\
1984
+ '--full-output[Report full stdout/stderr of passing rows]' \\
1985
+ '--auto-pm-context[Auto-remediate tracker-read context mismatches using tracker context]' \\
1986
+ '--author[Mutation author]:author' \\
1987
+ '--message[History message]:message' \\
1988
+ '--force[Force override]' \\
1989
+ '--json[Output JSON]' \\
1990
+ '--quiet[Suppress stdout]'
1991
+ ;;
1992
+ test-all)
1993
+ _arguments \\
1994
+ '--status[Filter by status]:(open in_progress)' \\
1995
+ '--limit[Limit matching items before running linked tests]:number' \\
1996
+ '--offset[Skip matching items before running linked tests]:number' \\
1997
+ '--background[Run linked tests in managed background mode]' \\
1998
+ '--timeout[Default timeout seconds]:seconds' \\
1999
+ '--progress[Emit linked-test progress to stderr]' \\
2000
+ '--env-set[Set linked-test runtime environment values]:entry' \\
2001
+ '--env-clear[Clear linked-test runtime environment values]:name' \\
2002
+ '--shared-host-safe[Apply shared-host-safe runtime defaults]' \\
2003
+ '--pm-context[PM linked-test context mode]:(schema tracker auto none)' \\
2004
+ '--override-linked-pm-context[Force run-level --pm-context over per-linked-test pm_context_mode metadata]' \\
2005
+ '--fail-on-context-mismatch[Fail when context item counts mismatch]' \\
2006
+ '--fail-on-skipped[Treat skipped linked tests as dependency failures]' \\
2007
+ '--fail-on-empty-test-run[Treat empty linked-test selections as failures]' \\
2008
+ '--require-assertions-for-pm[Require assertions for linked PM command tests]' \\
2009
+ '--check-context[Preflight linked PM command context diagnostics before execution]' \\
2010
+ '--full-output[Report full stdout/stderr of passing rows]' \\
2011
+ '--auto-pm-context[Auto-remediate tracker-read context mismatches using tracker context]' \\
2012
+ '--json[Output JSON]' \\
2013
+ '--quiet[Suppress stdout]'
2014
+ ;;
2015
+ test-runs)
2016
+ _arguments \\
2017
+ '1:subcommand:(list status logs stop resume)' \\
2018
+ '--status[Filter by background run status]:status:(queued running passed failed stopped canceled)' \\
2019
+ '--limit[Limit returned runs]:number' \\
2020
+ '--stream[Background log stream]:stream:(stdout stderr both)' \\
2021
+ '--tail[Tail number of lines]:number' \\
2022
+ '--force[Force stop with SIGKILL]' \\
2023
+ '--author[Resume author]:author' \\
2024
+ '--json[Output JSON]' \\
2025
+ '--quiet[Suppress stdout]'
2026
+ ;;
2027
+ init)
2028
+ _arguments \\
2029
+ '(1)--id-prefix[Set the item ID prefix]:prefix' \\
2030
+ '(1)--prefix[Alias for --id-prefix]:prefix' \\
2031
+ '1:optional id prefix or tracker path' \\
2032
+ '--preset[Governance preset for new setups]:preset:(minimal default strict)' \\
2033
+ '--defaults[Use non-interactive setup defaults]' \\
2034
+ '-y[Alias for --defaults]' \\
2035
+ '--yes[Alias for --defaults]' \\
2036
+ '--author[Set the default mutation author for this project]:author' \\
2037
+ '--agent-guidance[Agent guidance mode]:mode:(ask add skip status)' \\
2038
+ '--type-preset[Register domain item types]:type-preset:(agile ops research)' \\
2039
+ '--with-packages[Install bundled first-party packages during initialization]' \\
2040
+ '--verbose[Include the full resolved settings tree in init output]' \\
2041
+ '--json[Output JSON]' \\
2042
+ '--quiet[Suppress stdout]'
2043
+ ;;
2044
+ config)
2045
+ _arguments \\
2046
+ '--criterion[Criteria value for definition-of-done metadata-required-fields or lifecycle pattern keys (repeatable for set)]:criterion' \\
2047
+ '--clear-criteria[Clear config criteria-list key values]' \\
2048
+ '--format[Item format for item-format key]:format:(toon)' \\
2049
+ '--policy[Policy value for supported policy keys]:policy' \\
2050
+ '--json[Output JSON]' \\
2051
+ '--quiet[Suppress stdout]'
2052
+ ;;
2053
+ close)
2054
+ _arguments \\
2055
+ '--release-assignment[Close and release assignment]' \\
2056
+ '--reason[Closure reason]:reason' \\
2057
+ '--close-reason[Alias for --reason]:close_reason' \\
2058
+ '--author[Mutation author]:author' \\
2059
+ '--message[History message]:message' \\
2060
+ '--validate-close[Validate closure metadata mode]:(off warn strict)' \\
2061
+ '--resolution[Closure resolution summary]:resolution' \\
2062
+ '--expected-result[Expected behavior note]:expected_result' \\
2063
+ '--actual-result[Observed behavior note]:actual_result' \\
2064
+ '--expected[Short alias for --expected-result]:expected_result' \\
2065
+ '--actual[Short alias for --actual-result]:actual_result' \\
2066
+ '--force[Force override]' \\
2067
+ '--json[Output JSON]' \\
2068
+ '--quiet[Suppress stdout]'
2069
+ ;;
2070
+ claim)
2071
+ _arguments \\
2072
+ '--start[Claim and start work]' \\
2073
+ '--author[Mutation author]:author' \\
2074
+ '--message[History message]:message' \\
2075
+ '--force[Force override]' \\
2076
+ '--if-available[Skip work held by another author]' \\
2077
+ '--takeover-stale[Take over a claim idle past the stale-work threshold]' \\
2078
+ '--next[Atomically claim the next actionable item]' \\
2079
+ '--type[Filter --next candidates by type]:(${c})' \\
2080
+ '--tag[Filter --next candidates by tag]:(${b})' \\
2081
+ '--priority[Filter --next candidates by priority]:(0 1 2 3 4)' \\
2082
+ '--assignee-filter[Filter --next candidates by ownership]:assignee_filter:(assigned unassigned)' \\
2083
+ '--parent[Scope --next candidates to a subtree]:parent' \\
2084
+ '--sprint[Filter --next candidates by sprint]:sprint' \\
2085
+ '--release[Filter --next candidates by release]:release' \\
2086
+ '--max-attempts[Bound the --next candidate walk]:max_attempts' \\
2087
+ '--include-decisions[Allow human-gated Decision candidates]' \\
2088
+ '--token-budget[Bound ranked candidate tokens]:token_budget' \\
2089
+ '--explain-ranking[Include ranking provenance]' \\
2090
+ '--json[Output JSON]' \\
2091
+ '--quiet[Suppress stdout]'
2092
+ ;;
2093
+ release)
2094
+ _arguments \\
2095
+ '--pause[Return to open and release ownership]' \\
2096
+ '--author[Mutation author]:author' \\
2097
+ '--message[History message]:message' \\
2098
+ '--force[Force override]' \\
2099
+ '--json[Output JSON]' \\
2100
+ '--quiet[Suppress stdout]'
2101
+ ;;
2102
+ delete)
2103
+ _arguments \\
2104
+ '--dry-run[Preview the item file that would be deleted without mutating]' \\
2105
+ '--author[Mutation author]:author' \\
2106
+ '--message[History message]:message' \\
2107
+ '--force[Force override]' \\
2108
+ '--json[Output JSON]' \\
2109
+ '--quiet[Suppress stdout]'
2110
+ ;;
2111
+ restore)
2112
+ _arguments \\
2113
+ ${It(ho.map($=>`'${$.flag}[${$.description}]${$.takes_value?":value":""}'`),{trailingContinuation:!1})}
2114
+ ;;
2115
+ start-task)
2116
+ _arguments \\
2117
+ '--author[Mutation author]:author' \\
2118
+ '--message[History message]:message' \\
2119
+ '--force[Force override]' \\
2120
+ '--takeover-stale[Take over a claim idle past the stale-work threshold]' \\
2121
+ '--json[Output JSON]' \\
2122
+ '--quiet[Suppress stdout]'
2123
+ ;;
2124
+ pause-task)
2125
+ _arguments \\
2126
+ '--author[Mutation author]:author' \\
2127
+ '--message[History message]:message' \\
2128
+ '--force[Force override]' \\
2129
+ '--json[Output JSON]' \\
2130
+ '--quiet[Suppress stdout]'
2131
+ ;;
2132
+ close-task)
2133
+ _arguments \\
2134
+ '--author[Mutation author]:author' \\
2135
+ '--message[History message]:message' \\
2136
+ '--validate-close[Validate closure metadata mode]:(off warn strict)' \\
2137
+ '--force[Force override]' \\
2138
+ '--json[Output JSON]' \\
2139
+ '--quiet[Suppress stdout]'
2140
+ ;;
2141
+ validate)
2142
+ _arguments \\
2143
+ '--check-completeness[Check declarative required fields]' \\
2144
+ '--check-metadata[Run metadata completeness checks]' \\
2145
+ '--metadata-profile[Select metadata validation profile for --check-metadata]:(core strict custom)' \\
2146
+ '--check-resolution[Run closed-item resolution metadata checks]' \\
2147
+ '--check-lifecycle[Run active-item lifecycle governance drift checks]' \\
2148
+ '--check-stale-blockers[Include stale blocker-pattern diagnostics in lifecycle checks]' \\
2149
+ '--dependency-cycle-severity[Set dependency-cycle warning policy for lifecycle checks]:(off warn error)' \\
2150
+ '--parent-cycle-severity[Set parent-hierarchy cycle warning policy for lifecycle checks]:(off warn error)' \\
2151
+ '--check-files[Run linked-file and orphaned-file checks]' \\
2152
+ '--scan-mode[Select file candidate scan mode for --check-files]:(default tracked-all tracked-all-strict)' \\
2153
+ '--include-pm-internals[Include PM storage internals in tracked-all candidate scans]' \\
2154
+ '--verbose-file-lists[Include full file-path lists for validate --check-files details]' \\
2155
+ '--verbose-diagnostics[Include full validate diagnostic ID lists instead of compact summaries]' \\
2156
+ '--all-affected-ids[Emit complete missing_* affected-ID lists with no truncation (implied by --json)]' \\
2157
+ '--strict-exit[Return non-zero exit when validation warnings are present]' \\
2158
+ '--fail-on-warn[Alias for --strict-exit]' \\
2159
+ '--fix-hints[Add a machine-executable fix_hints[] of pm commands to each failing check]' \\
2160
+ '--auto-fix[Apply the safe, deterministic subset of fix-hint remediations automatically]' \\
2161
+ '--dry-run[Preview planned --auto-fix/--prune-missing fixes without applying them]' \\
2162
+ '--fix-scope[Grant --auto-fix scopes (estimates/timestamps/lifecycle require opt-in)]:(metadata resolution estimates timestamps lifecycle)' \\
2163
+ '--prune-missing[Remove stale linked-file/doc links classified as deleted]' \\
2164
+ '--check-history-drift[Run item/history hash drift checks]' \\
2165
+ '--check-command-references[Run linked-command PM-ID reference checks]' \\
2166
+ '--json[Output JSON]' \\
2167
+ '--quiet[Suppress stdout]'
2168
+ ;;
2169
+ health)
2170
+ _arguments \\
2171
+ '--strict-directories[Treat optional item-type directories as required failures]' \\
2172
+ '--check-only[Run read-only health diagnostics without refreshing vectors]' \\
2173
+ '--no-refresh[Disable automatic vector refresh attempts during health checks]' \\
2174
+ '--refresh-vectors[Explicitly enable vector refresh attempts during health checks]' \\
2175
+ '--verbose-stale-items[Include full stale vectorization ID lists in health output]' \\
2176
+ '--verbose-author-events[Include complete actionable unknown-author coordinates]' \\
2177
+ '--brief[Emit compact health details for low-token agent checks]' \\
2178
+ '--summary[Emit one-line-style health status with check names and warning count]' \\
2179
+ '--strict-exit[Return non-zero exit when health warnings are present]' \\
2180
+ '--fail-on-warn[Alias for --strict-exit]' \\
2181
+ '--json[Output JSON]' \\
2182
+ '--quiet[Suppress stdout]'
2183
+ ;;
2184
+ extension)
2185
+ _arguments \\
2186
+ '1:extension_action:(${Be})' \\
2187
+ '--init[Generate a starter extension scaffold at target path]' \\
2188
+ '--scaffold[Alias for --init]' \\
2189
+ '--capability[Capability the init scaffold targets]:capability:(${at.join(" ")})' \\
2190
+ '--install[Install extension from local path or GitHub source]' \\
2191
+ '--uninstall[Uninstall extension by name]' \\
2192
+ '--explore[List discovered extensions for selected scope]' \\
2193
+ '--manage[List managed extensions with update metadata]' \\
2194
+ '--describe[Map every surface a loaded extension registers]' \\
2195
+ '--markdown[Render describe output as a Markdown reference document]' \\
2196
+ '--output[Write describe Markdown to a file]:path:_files' \\
2197
+ '--reload[Reload extensions with cache-busted module imports]' \\
2198
+ '--watch[Enable watch mode with --reload]' \\
2199
+ '--doctor[Run consolidated extension diagnostics (summary/deep)]' \\
2200
+ '--catalog[List bundled first-party package catalog entries]' \\
2201
+ '--adopt[Adopt an unmanaged extension into managed metadata]' \\
2202
+ '--adopt-all[Adopt all unmanaged extensions into managed metadata]' \\
2203
+ '--activate[Activate extension in selected scope settings]' \\
2204
+ '--deactivate[Deactivate extension in selected scope settings]' \\
2205
+ '--project[Use project extension scope (default)]' \\
2206
+ '--local[Alias for --project]' \\
2207
+ '--global[Use global extension scope]' \\
2208
+ '--gh[Install from GitHub shorthand owner/repo/path]:github_spec' \\
2209
+ '--github[Alias for --gh]:github_spec' \\
2210
+ '--ref[Git ref/branch/tag for GitHub source]:git_ref' \\
2211
+ '--detail[Detail mode for extension diagnostics]:detail_mode:(summary deep)' \\
2212
+ '--trace[Include registration traces in doctor deep diagnostics]' \\
2213
+ '--runtime-probe[Opt-in runtime activation probe for manage output]' \\
2214
+ '--fix-managed-state[Adopt unmanaged extensions before diagnostics/update checks]' \\
2215
+ '--isolated[Run doctor against project-scope extensions only]' \\
2216
+ '--ignore-global[Alias for --isolated]' \\
2217
+ '--strict-exit[Return non-zero exit when doctor warnings are present]' \\
2218
+ '--fail-on-warn[Alias for --strict-exit (doctor)]' \\
2219
+ '--json[Output JSON]' \\
2220
+ '--quiet[Suppress stdout]' \\
2221
+ '*:target_or_name:_files -/'
2222
+ ;;
2223
+ package|packages)
2224
+ _arguments \\
2225
+ '1:package_action:(${wt})' \\
2226
+ '--init[Generate a starter package scaffold at target path]' \\
2227
+ '--scaffold[Alias for --init]' \\
2228
+ '--capability[Capability the init scaffold targets]:capability:(${at.join(" ")})' \\
2229
+ '--declarative[Generate a composeExtension blueprint starter]' \\
2230
+ '--install[Install package from local path, GitHub source, npm source, or bundled alias]' \\
2231
+ '--uninstall[Uninstall package by name]' \\
2232
+ '--explore[List discovered packages for selected scope]' \\
2233
+ '--manage[List managed packages with update metadata]' \\
2234
+ '--describe[Map every surface a loaded package registers]' \\
2235
+ '--markdown[Render describe output as a Markdown reference document]' \\
2236
+ '--output[Write describe Markdown to a file]:path:_files' \\
2237
+ '--reload[Reload packages with cache-busted module imports]' \\
2238
+ '--watch[Enable watch mode with --reload]' \\
2239
+ '--doctor[Run consolidated package diagnostics (summary/deep)]' \\
2240
+ '--catalog[List bundled first-party package catalog entries]' \\
2241
+ '--adopt[Adopt an unmanaged package into managed metadata]' \\
2242
+ '--adopt-all[Adopt all unmanaged packages into managed metadata]' \\
2243
+ '--activate[Activate package in selected scope settings]' \\
2244
+ '--deactivate[Deactivate package in selected scope settings]' \\
2245
+ '--project[Use project package scope (default)]' \\
2246
+ '--local[Alias for --project]' \\
2247
+ '--global[Use global package scope]' \\
2248
+ '--gh[Install from GitHub shorthand owner/repo/path]:github_spec' \\
2249
+ '--github[Alias for --gh]:github_spec' \\
2250
+ '--ref[Git ref/branch/tag for GitHub source]:git_ref' \\
2251
+ '--detail[Detail mode for package diagnostics]:detail_mode:(summary deep)' \\
2252
+ '--trace[Include registration traces in doctor deep diagnostics]' \\
2253
+ '--runtime-probe[Opt-in runtime activation probe for manage output]' \\
2254
+ '--fix-managed-state[Adopt unmanaged packages before diagnostics/update checks]' \\
2255
+ '--isolated[Run doctor against project-scope packages only]' \\
2256
+ '--ignore-global[Alias for --isolated]' \\
2257
+ '--strict-exit[Return non-zero exit when doctor warnings are present]' \\
2258
+ '--fail-on-warn[Alias for --strict-exit (doctor)]' \\
2259
+ '--dry-run[Plan upgrades without mutating]' \\
2260
+ '--cli-only[Upgrade only the pm CLI/SDK npm package]' \\
2261
+ '--packages-only[Upgrade only managed pm packages]' \\
2262
+ '--repair[Force npm global reinstall for the CLI/SDK]' \\
2263
+ '--tag[npm version or dist-tag for upgrades]:tag' \\
2264
+ '--package-name[Override the CLI package name]:package_name' \\
2265
+ '--json[Output JSON]' \\
2266
+ '--quiet[Suppress stdout]' \\
2267
+ '*:target_or_name:_files -/'
2268
+ ;;
2269
+ completion)
2270
+ _arguments \\
2271
+ '--eager-tags[Embed current tracker tags directly in script output]' \\
2272
+ '1:shell:(bash zsh fish)'
2273
+ ;;
2274
+ templates)
2275
+ local -a templates_cmds
2276
+ templates_cmds=('save:Save or update a create template' 'list:List saved create templates' 'show:Show saved template details')
2277
+ _describe 'templates command' templates_cmds
2278
+ ;;
2279
+ esac
2280
+ ;;
2281
+ esac
2282
+ }
2283
+
2284
+ compdef _pm pm`}var du=["bash","zsh","fish"],xy={bash:'Add to ~/.bashrc or ~/.bash_profile: eval "$(pm completion bash)"',zsh:'Add to ~/.zshrc: eval "$(pm completion zsh)"',fish:"Run: pm completion fish > ~/.config/fish/completions/pm.fish"};function Iy(e,t=[],n=[],o=!1,r={}){let i=e.trim().toLowerCase();if(!du.includes(i))throw new p(`Unknown shell: "${e}". Supported shells: ${du.join(", ")}.`,u.USAGE);let s=i,a;return s==="bash"?a=Ei(t,n,o,r):s==="zsh"?a=Oi(t,n,o,r):a=Ri(t,n,o,r),{shell:s,script:a,setup_hint:xy[s]}}import Ey from"node:fs/promises";import an from"node:path";var $i="index/manifest.json",Fi="search/embeddings.jsonl",Cy="Provider or model has changed since last index. Run pm reindex --mode semantic to rebuild.";function Ry(e){return e.progress===!0||process.stderr.isTTY===!0}function D(e,t){if(e)try{process.stderr.write(`[pm reindex] ${t}
2285
+ `)}catch{}}function Ty(e){let t=(e??"keyword").trim().toLowerCase();if(t==="keyword")return"keyword";if(t==="semantic"||t==="hybrid")return t;throw new p("Reindex mode must be one of keyword|semantic|hybrid",u.USAGE)}async function Oy(e,t,n,o){let r=[];return{candidates:await _a(e,t,n,r,o),warnings:r}}async function Ni(e,t,n,o,r){let i=pe(T()),s=[];for(let a of t)if(!(r&&!r.has(a.metadata.id))){if(typeof a.body=="string"){s.push({metadata:a.metadata,body:a.body});continue}try{let c=await Ey.readFile(a.item_path,"utf8"),l=bn(c,{format:a.item_format,schema:n,extensionFieldNames:i,onWarning:d=>o.push(d)});s.push({metadata:a.metadata,body:l.body})}catch{o.push(`item_list_item_read_failed:${an.relative(e,a.item_path)}`),s.push({metadata:a.metadata,body:""})}}return s}function $y(e,t,n){let o=e.metadata;return{id:o.id,mode:t,updated_at:o.updated_at,corpus:ba(e,{fields:n})}}var Et=ms;function Fy(e){let t=T(),n=Et(e.search?.provider);if(!n)return null;let o=Xs(t,n);if(!o)return null;let r=o.runtime_definition??o.definition,i=Et(r.name)??Et(o.definition.name);if(!i)return null;let s=r.embedBatch,a=r.embed_batch,c=r.embed,l=typeof s=="function"?s:typeof a=="function"?a:void 0,d=typeof c=="function"?c:void 0;return!l&&!d?null:{name:i,embedBatch:l,embed:d}}function Py(e){let t=T(),n=Et(e.vector_store?.adapter);if(!n)return null;let o=Zs(t,n);if(!o)return null;let r=o.runtime_definition??o.definition,i=Et(r.name)??Et(o.definition.name);if(!i)return null;let s=r.upsert,a=r.delete;return{adapterName:i,...typeof s=="function"?{upsert:s}:{},...typeof a=="function"?{delete:a}:{}}}function Pi(e,t){if(!Array.isArray(e)||e.some(n=>typeof n!="number"||!Number.isFinite(n)))throw new p(`Invalid vector returned by ${t}`,u.GENERIC_FAILURE);return e}async function Ny(e,t,n){let o=t.search?.embedding_model?.trim()||"text-embedding-3-small";if(e.embedBatch){let i=await Promise.resolve(e.embedBatch({inputs:n,settings:t,model:o}));if(!Array.isArray(i))throw new p(`Extension search provider "${e.name}" embedBatch must return an array of vectors`,u.GENERIC_FAILURE);return i.map((s,a)=>Pi(s,`extension search provider "${e.name}" embedBatch output at index ${a}`))}if(!e.embed)throw new p(`Extension search provider "${e.name}" does not implement embed/embedBatch`,u.GENERIC_FAILURE);let r=[];for(let[i,s]of n.entries()){let a=await Promise.resolve(e.embed({input:s,settings:t,model:o}));r.push(Pi(a,`extension search provider "${e.name}" embed output at index ${i}`))}return r}function mu(e){return e.search?.embedding_model?.trim()||"text-embedding-3-small"}function pu(e,t,n){let o=n?zt(n.name,mu(e)):t?zt(t.name,t.model):null;if(!o)throw new p("No embedding identity available for semantic reindex mode",u.USAGE);return o}function Ly(e,t){return Object.keys(e).filter(n=>!t.has(n)).sort((n,o)=>n.localeCompare(o))}async function uu(e,t,n,o,r,i,s,a){let c=o?.name??n?.name,l=wa(c,e.search.embedding_corpus_max_characters).maxCharacters,d=Jo(e),m=r.map(g=>va(g,{providerName:c,maxCharacters:l,fields:d})),f=[],b=null;if(o)try{f=await Ny(o,e,m),b=zt(o.name,mu(e))}catch(g){if(!n)throw new p(`Extension search provider "${o.name}" failed to generate embeddings: ${g instanceof Error?g.message:String(g)}`,u.GENERIC_FAILURE);i.push(`Extension search provider "${o.name}" failed; falling back to built-in provider (${g instanceof Error?g.message:String(g)})`)}if(f.length===0){if(!n)throw new p(`No embedding executor available for reindex mode '${t}'`,u.USAGE);let g=await ka(n,e,m,{onProgress:k=>{k.phase==="complete"&&(s.batches_completed=k.batch_index),D(a,`embedding_batch_${k.phase} batch=${k.batch_index}/${k.batch_total} size=${k.batch_size} completed_inputs=${k.completed_inputs}/${k.total_inputs}`)}});i.push(...g.warnings),s.batching=g.receipt,f=g.vectors,b=zt(n.name,n.model)}if(D(a,`embedding_complete vectors=${f.length}`),f.length!==r.length)throw new p(`Embedding output size mismatch (expected ${r.length}, received ${f.length})`,u.GENERIC_FAILURE);if(!b)throw new p(`No embedding identity available for reindex mode '${t}'`,u.USAGE);return{vectors:f,embeddingIdentity:b}}async function My(e,t,n,o,r,i){let s=Object.keys(n);if(t){if(s.length>0&&t.delete)try{await Promise.resolve(t.delete({ids:s.sort((a,c)=>a.localeCompare(c)),settings:o}))}catch(a){throw new p(`Extension vector adapter "${t.adapterName}" failed to delete vectors during reindex reset: ${a instanceof Error?a.message:String(a)}`,u.GENERIC_FAILURE)}else s.length>0&&r.push(`search_semantic_reindex_reset_skipped:adapter=${t.adapterName}:known_ids=${s.length}`);if(!e)return}e&&await Ia(e,s,{},i)}async function fu(e,t,n,o,r){if(n.length!==0){if(t){if(t.delete)try{await Promise.resolve(t.delete({ids:n,settings:o}))}catch(i){throw new p(`Extension vector adapter "${t.adapterName}" failed to delete orphan vectors during reindex: ${i instanceof Error?i.message:String(i)}`,u.GENERIC_FAILURE)}else r.push(`search_semantic_reindex_orphan_prune_skipped:adapter=${t.adapterName}:count=${n.length}`);if(!e)return}e&&await xa(e,n)}}function Dy(e){return{enabled:e!=="keyword",stale_items:0,unchanged_items:0,embedded_items:0,vector_upserted:0,batches_completed:0}}function jy(e,t,n){return{version:1,mode:e,generated_at:t,total_items:n.length,items:n.map(o=>({id:o.metadata.id,type:o.metadata.type,status:o.metadata.status,priority:o.metadata.priority,updated_at:o.metadata.updated_at}))}}function Gy(e){if(e.requestedMode==="keyword")return{activeEmbeddingProvider:null,activeVectorStore:null};let t=Ko(e.settings);if(!t.active&&!e.extensionEmbedding)throw new p(`Reindex mode '${e.requestedMode}' requires a configured embedding provider in settings.providers.openai/settings.providers.ollama or an extension provider selected by settings.search.provider`,u.USAGE);let n=Sa(e.settings,e.pmRoot);if(!n.active&&!e.extensionVectorAdapter)throw new p(`Reindex mode '${e.requestedMode}' requires a configured vector store in settings.vector_store.qdrant/settings.vector_store.lancedb or an extension adapter selected by settings.vector_store.adapter`,u.USAGE);return{activeEmbeddingProvider:t.active,activeVectorStore:n.active}}async function Uy(e){let t=F(e.settings,T()),n=await Oy(e.pmRoot,e.settings.item_format,t.type_to_folder,e.settings.schema);return{documentCandidates:n.candidates,warnings:[...n.warnings],metadataDocuments:n.candidates.map(o=>({metadata:o.metadata,body:typeof o.body=="string"?o.body:""}))}}async function qy(e){let t=await Xo(e.pmRoot);if(e.reindexWarnings.push(...t.warnings),e.forceFullSemantic&&e.reindexWarnings.push("search_semantic_reindex_full_ignored:mode_keyword"),!t.embedding)return;let n=(()=>{try{return pu(e.settings,Ko(e.settings).active,e.extensionEmbedding)}catch{return null}})();n&&$n(t.embedding,n)&&(e.reindexWarnings.push("search_semantic_reindex_requires_rebuild:embedding_identity_changed"),e.reindexWarnings.push(Cy))}async function zy(e){let t=await Xo(e.pmRoot);e.semanticWarnings.push(...t.warnings);let n=pu(e.settings,e.activeEmbeddingProvider,e.extensionEmbedding),o=new Set(e.metadataDocuments.map(l=>l.metadata.id)),r=Ly(t.entries,o),i=$n(t.embedding,n);e.forceFullSemantic&&!i&&e.semanticWarnings.push("search_semantic_reindex_full_rebuild_forced");let s=e.forceFullSemantic||i?e.metadataDocuments:e.metadataDocuments.filter(l=>t.entries[l.metadata.id]!==l.metadata.updated_at),a=new Set(s.map(l=>l.metadata.id)),c=a.size>0?await Ni(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,a):[];return{ledgerEntries:t.entries,ledgerEmbedding:t.embedding,orphanIds:r,resetRequired:i,staleDocuments:c,freshDocuments:e.metadataDocuments.length-c.length}}async function Hy(e){let t=new Set(e.metadataDocuments.map(r=>r.metadata.id)),n=await Ni(e.pmRoot,e.documentCandidates,e.settings.schema,e.reindexWarnings,t);e.semanticSummary.stale_items=n.length,e.semanticSummary.unchanged_items=0,D(e.progressEnabled,`embedding_dimension_changed reset_items=${n.length}`);let o=await uu(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,n,e.semanticWarnings,e.semanticSummary,e.progressEnabled);return{...o,staleDocuments:n,vectorDimension:Yo(o.vectors,"Reindex embeddings")}}async function By(e){let t=await uu(e.settings,e.requestedMode,e.activeEmbeddingProvider,e.extensionEmbedding,e.staleDocuments,e.semanticWarnings,e.semanticSummary,e.progressEnabled),n=t.vectors,o=t.embeddingIdentity,r=Yo(n,"Reindex embeddings");if(!(!e.resetRequired&&($n(e.ledgerEmbedding,o)||Ca(e.ledgerEmbedding,r))))return{vectors:n,embeddingIdentity:o,staleDocuments:e.staleDocuments,vectorDimension:r,resetRequired:e.resetRequired};let s=await Hy(e);return n=s.vectors,o=s.embeddingIdentity,r=s.vectorDimension,{vectors:n,embeddingIdentity:o,staleDocuments:s.staleDocuments,vectorDimension:r,resetRequired:!0}}async function Wy(e){if(e.extensionVectorAdapter)try{let t=e.extensionVectorAdapter.adapterName;if(D(e.progressEnabled,`vector_upsert_start adapter=${t} points=${e.points.length}`),typeof e.extensionVectorAdapter.upsert!="function")throw new p(`Extension vector adapter "${t}" does not support upserting vectors.`,u.USAGE);await Promise.resolve(e.extensionVectorAdapter.upsert({points:e.points,settings:e.settings})),e.semanticSummary.vector_upserted=e.points.length,D(e.progressEnabled,`vector_upsert_complete adapter=${t}`);return}catch(t){if(t instanceof p)throw t;if(!e.activeVectorStore)throw new p(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed to upsert vectors: ${t instanceof Error?t.message:String(t)}`,u.GENERIC_FAILURE);e.semanticWarnings.push(`Extension vector adapter "${e.extensionVectorAdapter.adapterName}" failed; falling back to built-in vector store (${t instanceof Error?t.message:String(t)})`),D(e.progressEnabled,"vector_upsert_fallback built_in_store")}if(e.activeVectorStore){D(e.progressEnabled,`vector_upsert_start adapter=${e.activeVectorStore.name} points=${e.points.length}`),await Aa(e.activeVectorStore,e.points),e.semanticSummary.vector_upserted=e.points.length,D(e.progressEnabled,`vector_upsert_complete adapter=${e.activeVectorStore.name}`);return}throw new p(`No vector upsert executor available for reindex mode '${e.requestedMode}'`,u.USAGE)}function Vy(e,t){return e.map((n,o)=>({id:n.metadata.id,vector:Pi(t[o],`reindex embeddings output at index ${o}`),payload:{id:n.metadata.id,type:n.metadata.type,status:n.metadata.status,priority:n.metadata.priority,updated_at:n.metadata.updated_at}}))}async function Ky(e){D(e.progressEnabled,`embedding_start items=${e.plan.staleDocuments.length} unchanged_items=${e.plan.freshDocuments}`);let t=await By({pmRoot:e.pmRoot,settings:e.settings,requestedMode:e.requestedMode,activeEmbeddingProvider:e.activeEmbeddingProvider,extensionEmbedding:e.extensionEmbedding,documentCandidates:e.documentCandidates,metadataDocuments:e.metadataDocuments,staleDocuments:e.plan.staleDocuments,ledgerEmbedding:e.plan.ledgerEmbedding,resetRequired:e.plan.resetRequired,semanticWarnings:e.semanticWarnings,reindexWarnings:e.reindexWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled});t.resetRequired?(D(e.progressEnabled,"vector_reset_start"),await My(e.activeVectorStore,e.extensionVectorAdapter,e.plan.ledgerEntries,e.settings,e.semanticWarnings,e.plan.ledgerEmbedding?t.vectorDimension:void 0),D(e.progressEnabled,"vector_reset_complete")):await fu(e.activeVectorStore,e.extensionVectorAdapter,e.plan.orphanIds,e.settings,e.semanticWarnings);let n=Vy(t.staleDocuments,t.vectors);return e.semanticSummary.embedded_items=t.vectors.length,await Wy({requestedMode:e.requestedMode,activeVectorStore:e.activeVectorStore,extensionVectorAdapter:e.extensionVectorAdapter,settings:e.settings,points:n,semanticWarnings:e.semanticWarnings,semanticSummary:e.semanticSummary,progressEnabled:e.progressEnabled}),{staleDocuments:t.staleDocuments,embeddingMetadata:Ea(t.embeddingIdentity,t.vectorDimension)}}async function Jy(e){let t=await zy(e);e.semanticSummary.stale_items=t.staleDocuments.length,e.semanticSummary.unchanged_items=t.freshDocuments;let n=Object.fromEntries(e.metadataDocuments.map(i=>[i.metadata.id,i.metadata.updated_at]));if(D(e.progressEnabled,`semantic_stale_items stale=${t.staleDocuments.length} total=${e.metadataDocuments.length} unchanged=${t.freshDocuments} full=${e.forceFullSemantic||t.resetRequired}`),t.staleDocuments.length===0)return D(e.progressEnabled,`embedding_skipped unchanged_items=${t.freshDocuments}`),e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`),await fu(e.activeVectorStore,e.extensionVectorAdapter,t.orphanIds,e.settings,e.semanticWarnings),{documentsForKeywordArtifacts:e.documentsForKeywordArtifacts,vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:t.ledgerEmbedding};let o=await Ky({...e,plan:t});t.freshDocuments>0&&e.semanticWarnings.push(`search_semantic_reindex_skipped_unchanged:count=${t.freshDocuments}`);let r=new Map(o.staleDocuments.map(i=>[i.metadata.id,i]));return{documentsForKeywordArtifacts:e.metadataDocuments.map(i=>r.get(i.metadata.id)??i),vectorizationLedgerEntries:n,vectorizationEmbeddingMetadata:o.embeddingMetadata}}async function Yy(e){let t=an.join(e.pmRoot,$i),n=an.join(e.pmRoot,Fi),o=Jo(e.settings),r=e.documentsForKeywordArtifacts.map(s=>JSON.stringify($y(s,e.mode,o))).join(`
2286
+ `);D(e.progressEnabled,"writing keyword artifacts"),await se(t,`${JSON.stringify(e.manifest,null,2)}
2287
+ `),await se(n,`${r}
2288
+ `);let i=[];if(e.mode!=="keyword")try{D(e.progressEnabled,"writing vectorization status ledger"),await Ra(e.pmRoot,e.vectorizationLedgerEntries,e.vectorizationEmbeddingMetadata)}catch(s){i.push(`search_vectorization_status_ledger_write_failed:${s instanceof Error?s.message:String(s)}`)}return i}async function Xy(e,t){let n=Ty(e.mode),o=Ry(e),r=e.full===!0;D(o,`start mode=${n}`);let i=x(process.cwd(),t.path);await P(i);let s=da(await I(i)).settings,a=null;try{a=await Le(i,ma,s.locks.ttl_seconds,C(void 0,"pm-reindex"),!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(c){throw c instanceof p&&c.exitCode===u.CONFLICT?new p("Another pm reindex run is already active for this project. Wait for it to finish before starting a new keyword, semantic, or hybrid reindex.",u.CONFLICT,{code:"reindex_already_running",type:"urn:pm-cli:error:reindex_already_running",why:"Semantic reindex can be expensive and duplicate runs compete for the same local embedding model and vector store.",nextSteps:["Check active pm reindex processes before starting another reindex.","Rerun with --progress when you need non-interactive visibility."]}):c}try{let c=Fy(s),l=Py(s),d=Gy({requestedMode:n,pmRoot:i,settings:s,extensionEmbedding:c,extensionVectorAdapter:l}),m=n;D(o,"loading item corpus");let f=await Uy({pmRoot:i,settings:s}),b=f.warnings,{documentCandidates:g,metadataDocuments:k}=f;D(o,`loaded_items=${k.length}`);let y=S(),v=jy(m,y,k),_=an.join(i,$i),A=an.join(i,Fi),N=m==="keyword"?await Ni(i,g,s.schema,b):k,O=[],B={},$=null,R=Dy(m);if(m==="keyword"&&await qy({pmRoot:i,settings:s,forceFullSemantic:r,extensionEmbedding:c,reindexWarnings:b}),m!=="keyword"){let te=await Jy({pmRoot:i,settings:s,requestedMode:n,activeEmbeddingProvider:d.activeEmbeddingProvider,activeVectorStore:d.activeVectorStore,extensionEmbedding:c,extensionVectorAdapter:l,documentCandidates:g,metadataDocuments:k,documentsForKeywordArtifacts:N,forceFullSemantic:r,reindexWarnings:b,semanticWarnings:O,semanticSummary:R,progressEnabled:o});N=te.documentsForKeywordArtifacts,B=te.vectorizationLedgerEntries,$=te.vectorizationEmbeddingMetadata}let re=await Yy({pmRoot:i,mode:m,manifest:v,documentsForKeywordArtifacts:N,settings:s,vectorizationLedgerEntries:B,vectorizationEmbeddingMetadata:$,progressEnabled:o}),Tt=[...await G({path:_,scope:"project",op:"reindex:manifest"}),...await G({path:A,scope:"project",op:"reindex:embeddings"}),...await Ks({mode:m,total_items:k.length})];return D(o,"done"),{ok:!0,mode:m,total_items:k.length,semantic:R,artifacts:{manifest:$i,embeddings:Fi},warnings:[...b,...O,...re,...Tt],generated_at:y}}finally{await a?.()}}var cn=Symbol("pm.active-extension-host-context");function Q(e){return{fullChangedFields:!0,options:e}}var w=class e{defaults;constructor(t={}){this.defaults={...t.pmRoot===void 0?{}:{path:t.pmRoot},...t.cwd===void 0?{}:{cwd:t.cwd},...t.author===void 0?{}:{author:t.author},...t.noExtensions===void 0?{}:{noExtensions:t.noExtensions}}}static forActiveExtensionHost(t){let n=new e({...t,noExtensions:!0});return n.defaults[cn]=!0,n}run(t,n={}){return ib({...this.defaults,...n,action:t})}runTyped(t,n={}){return this.run(t,n)}async withItemTransactionContext(t,n=!1){let o=x(this.defaults.cwd??process.cwd(),this.defaults.path),r=async()=>{let c=await nt(o,()=>I(o));return t({pmRoot:o,author:C(this.defaults.author,c.author_default)})};if(this.defaults[cn]===!0){let c=process.cwd(),l=()=>gu(o,Bt({path:o}),void 0,c,r);return n?nt(o,l):l()}let i=Rt()!==void 0;i&&Di(this.defaults.cwd);let s=i?void 0:this.defaults.cwd,a=()=>yu({...this.defaults,cwd:s,path:o},r);return n?nt(o,a):a()}previewItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-SEHTH7N2.js")).previewItemMutations({...t,...n}),!0)}commitItemMutations(t){return this.withItemTransactionContext(async n=>(await import("./item-transaction-SEHTH7N2.js")).commitItemMutations({...t,...n}))}get itemTransactions(){let t=(n,o)=>this.withItemTransactionContext(async r=>(await import("./item-transaction-SEHTH7N2.js")).abandonItemTransaction({...o,...r,transactionId:n}));return{status:n=>this.withItemTransactionContext(async o=>(await import("./item-transaction-SEHTH7N2.js")).readItemTransaction(o.pmRoot,n),!0),abandon:t,supersede:(n,o,r)=>t(n,{...r,supersededBy:o})}}readItemRevision(t){return this.withItemTransactionContext(async({pmRoot:n})=>(await import("./item-revision-FMD4KWBB.js")).readItemRevision(t,{pmRoot:n}))}async withExpectedItemRevisions(t,n){let o=await import("./item-revision-FMD4KWBB.js"),r="",i=await this.withItemTransactionContext(({pmRoot:a})=>(r=a,o.bindExpectedItemRevisions(t,{pmRoot:a}))),s=this.defaults.noExtensions===!0&&this.defaults[cn]!==!0;return o.runWithBoundItemRevisionScope(i,n,{scopeArgs:["--pm-path",r,...s?["--no-extensions"]:[]]})}context(t={}){return this.runTyped("context",{options:t})}listAllItemMetadataLight(){return Rd(this.defaults.path,this.defaults.cwd)}list(t={}){return this.runTyped("list",{options:t})}async listAllComplete(t={}){return eo(await this.list(Fr(t)),t)}search(t,n={}){return this.runTyped("search",{query:t,options:n})}get(t,n={}){return this.runTyped("get",{id:t,options:n})}next(t={}){return this.runTyped("next",{options:t})}aggregate(t={}){return this.runTyped("aggregate",{options:t})}stats(t={}){return this.runTyped("stats",{options:t})}duplicates(t={}){return this.runTyped("duplicates",{options:t})}comments(t,n={}){return this.runTyped("comments",{id:t,options:n})}notes(t,n={}){return this.runTyped("notes",{id:t,options:n})}learnings(t,n={}){return this.runTyped("learnings",{id:t,options:n})}files(t,n={}){return this.runTyped("files",{id:t,options:n})}filesDiscover(t,n={}){return this.runTyped("files-discover",{id:t,options:n})}filesLookup(t){return this.runTyped("files-lookup",{options:t})}docs(t,n={}){return this.runTyped("docs",{id:t,options:n})}deps(t,n={}){return this.runTyped("deps",{id:t,options:n})}graph(t,n={},o={}){return this.runTyped("graph",{subcommand:t,...n,options:o})}async append(t,n,o={}){return Ac(o,"append"),await this.runTyped("append",{id:t,...Q(st(o,{body:n}))})}init(t,n={}){return this.runTyped("init",{...t===void 0?{}:{prefix:t},options:n})}config(t,n,o,r,i={}){return this.runTyped("config",{scope:t,configAction:n,...o===void 0?{}:{key:o},...r===void 0?{}:{value:r},options:i})}schema(t,n={}){return this.runTyped("schema",{options:{...n,subcommand:t}})}workflowPolicy(t,n,o={}){return this.runTyped("schema",{name:n,options:{...o,subcommand:t}})}schemaList(){return this.runTyped("schema",{options:{subcommand:"list"}})}schemaShow(t){return this.runTyped("schema",{name:t,options:{subcommand:"show"}})}schemaAddType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-type"}})}schemaRemoveType(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-type"}})}schemaAddStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"add-status"}})}schemaRemoveStatus(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-status"}})}schemaAddField(t,n={}){let{type:o,...r}=n;return this.runTyped("schema",{name:t,options:{...r,fieldType:o,subcommand:"add-field"}})}schemaRemoveField(t,n={}){return this.runTyped("schema",{name:t,options:{...n,subcommand:"remove-field"}})}schemaListFields(){return this.runTyped("schema",{options:{subcommand:"list-fields"}})}schemaShowField(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-field"}})}schemaApplyPreset(t,n={}){return this.runTyped("schema",{typePreset:t,options:{...n,subcommand:"apply-preset"}})}schemaInferTypes(t={}){return this.runTyped("schema",{options:{...t,subcommand:"add-type",infer:!0}})}schemaRenameType(t,n,o){return this.runTyped("schema",{name:t,options:{...o,subcommand:"rename-type",to:n}})}schemaRenameField(t,n,o,r){return this.runTyped("schema",{name:t,options:{...o,subcommand:"rename-field",to:n,...r?{fieldTypeScope:r}:{}}})}schemaRemapStatus(t,n,o){return this.runTyped("schema",{name:t,options:{...o,subcommand:"remap-status",to:n}})}schemaShowStatus(t){return this.runTyped("schema",{name:t,options:{subcommand:"show-status"}})}profile(t,n={}){return this.runTyped("profile",{options:{...n,subcommand:t}})}profileList(){return this.runTyped("profile",{options:{subcommand:"list"}})}profileShow(t){return this.runTyped("profile",{name:t,options:{subcommand:"show"}})}profileApply(t,n={}){return this.runTyped("profile",{name:t,options:{...n,subcommand:"apply"}})}profileLint(t){return this.runTyped("profile",{name:t,options:{subcommand:"lint"}})}validate(t={}){return this.runTyped("validate",{options:t})}health(t={}){return this.runTyped("health",{options:t})}gc(t={}){return this.runTyped("gc",{options:t})}assurance(t){return this.runTyped("assurance",{options:{...t,subcommand:t.action}})}historyRedact(t,n){return this.runTyped("history-redact",{id:t,options:n})}historyRepair(t,n={}){return this.runTyped("history-repair",{id:t,options:n})}historyRepairAll(t={}){return this.runTyped("history-repair",{options:{...t,all:!0}})}historyAttest(t={}){return this.runTyped("history-attest",{options:t})}historyCompact(t,n={}){return this.runTyped("history-compact",{id:t,options:n})}historyCompactBulk(t){return this.runTyped("history-compact",{options:t})}historyAuthorAcknowledge(t){return this.runTyped("history-author-acknowledge",{historyEvent:(t.events??[]).map(n=>`${n.item_id}:${String(n.line)}`),allActionable:t.all_actionable===!0,dryRun:t.dry_run===!0,planFingerprint:t.plan_fingerprint,limit:t.coordinate_limit,attributedAuthor:t.attributed_author,reviewer:t.reviewer,reason:t.reason})}plan(t,n,o={},r,i){return this.runTyped("plan",{fullChangedFields:!0,...n===void 0?{}:{id:n},...r===void 0?{}:{stepRef:r},...i===void 0?{}:{reorderTo:i},options:st(o,{subcommand:t})})}planCreate(t){return this.plan("create",void 0,t)}planShow(t,n={}){return this.plan("show",t,n)}planAddStep(t,n){return this.plan("add-step",t,n)}planUpdateStep(t,n,o){return this.plan("update-step",t,o,n)}planCompleteStep(t,n,o={}){return this.plan("complete-step",t,o,n)}planBlockStep(t,n,o){return this.plan("block-step",t,o,n)}planReorderStep(t,n,o,r={}){return this.plan("reorder-step",t,r,n,o)}planRemoveStep(t,n,o={}){return this.plan("remove-step",t,o,n)}planLink(t,n,o){return this.plan("link",t,o,n)}planUnlink(t,n,o){return this.plan("unlink",t,o,n)}planDecision(t,n){return this.plan("decision",t,n)}planDiscovery(t,n){return this.plan("discovery",t,n)}planValidation(t,n){return this.plan("validation",t,n)}planResume(t,n){return this.plan("resume",t,n)}planApprove(t,n={}){return this.plan("approve",t,n)}planMaterialize(t,n){return this.plan("materialize",t,n)}create(t={}){return this.runTyped("create",Q(t))}update(t,n={}){return this.runTyped("update",{id:t,...Q(n)})}reopen(t,n,o={}){return this.runTyped("item-reopen",{id:t,reason:n,fullChangedFields:!0,options:o})}close(t,n,o={}){return this.runTyped("close",{id:t,reason:n,...Q(o)})}claim(t,n={}){return this.runTyped("claim",{id:t,...Q(n)})}claimNext(t={}){return this.runTyped("claim",{next:!0,...Q(t)})}release(t,n={}){return this.runTyped("release",{id:t,...Q(n)})}copy(t,n={}){return this.runTyped("copy",{id:t,...Q(n)})}delete(t,n={}){return this.runTyped("delete",{id:t,...Q(n)})}restore(t,n,o={}){return this.runTyped("restore",{fullChangedFields:!0,id:t,options:{...o,target:n}})}focus(t,n={}){return this.runTyped("focus",{...t===void 0?{}:{id:t},...Q(n)})}startTask(t,n={}){return this.runTyped("start-task",{id:t,...Q(n)})}pauseTask(t,n={}){return this.runTyped("pause-task",{id:t,...Q(n)})}closeTask(t,n,o={}){return this.runTyped("close-task",{id:t,reason:n,...Q(o)})}extension(t,n={}){return this.runTyped("extension",{...t===void 0?{}:{target:t},options:n})}extensionList(t={}){return this.extension("list",t)}extensionActivate(t,n={}){return this.runTyped("extension-activate",{target:t,options:n})}extensionDeactivate(t,n={}){return this.runTyped("extension-deactivate",{target:t,options:n})}package(t,n={}){return this.runTyped("package",{...t===void 0?{}:{target:t},options:{...n,vocabulary:"package"}})}packageList(t={}){return this.package("list",t)}packageInstall(t,n={}){return this.runTyped("package-install",{target:t,options:n})}packageUninstall(t,n={}){return this.runTyped("package-uninstall",{target:t,options:n})}packageDoctor(t={}){return this.runTyped("package-doctor",{options:t})}packageManage(t,n={}){return this.runTyped("package-manage",{...t===void 0?{}:{target:t},options:n})}packageDescribe(t,n={}){return this.runTyped("package-describe",{...t===void 0?{}:{target:t},options:n})}packageReload(t={}){return this.runTyped("package-reload",{options:t})}packageCatalog(t={}){return this.runTyped("package-catalog",{options:t})}packageActivate(t,n={}){return this.runTyped("package-activate",{target:t,options:n})}packageDeactivate(t,n={}){return this.runTyped("package-deactivate",{target:t,options:n})}packageMigrate(t={}){return this.package(void 0,{...t,migrate:!0})}upgrade(t,n={}){return this.runTyped("upgrade",{...t===void 0?{}:{target:t},options:n})}};function XC(e={},t={}){return new w(t).context(e)}function ZC(e={},t={}){return new w(t).list(e)}function QC(e={},t={}){return new w(t).listAllComplete(e)}function eR(e,t={},n={}){return new w(n).search(e,t)}function tR(e,t={},n={}){return new w(n).get(e,t)}function nR(e={},t={}){return new w(t).next(e)}function oR(e={},t={}){return new w(t).aggregate(e)}function rR(e={},t={}){return new w(t).stats(e)}function iR(e={},t={}){return new w(t).duplicates(e)}function sR(e,t={},n={}){return new w(n).comments(e,t)}function aR(e,t={},n={}){return new w(n).notes(e,t)}function cR(e,t={},n={}){return new w(n).learnings(e,t)}function lR(e,t={},n={}){return new w(n).files(e,t)}function dR(e,t={},n={}){return new w(n).filesDiscover(e,t)}function mR(e,t={}){return new w(t).filesLookup(e)}function pR(e,t={},n={}){return new w(n).docs(e,t)}function uR(e,t={},n={}){return new w(n).deps(e,t)}function fR(e,t={},n={},o={}){return new w(o).graph(e,t,n)}function _R(e,t,n={},o={}){return new w(o).append(e,t,n)}function hR(e,t={},n={}){return new w(n).init(e,t)}function gR(e,t,n,o,r={},i={}){return new w(i).config(e,t,n,o,r)}function yR(e,t={},n={}){return new w(n).schema(e,t)}function bR(e={}){return new w(e).schemaList()}function wR(e,t={}){return new w(t).schemaShow(e)}function vR(e,t={},n={}){return new w(n).schemaAddType(e,t)}function kR(e,t={},n={}){return new w(n).schemaRemoveType(e,t)}function SR(e,t={},n={}){return new w(n).schemaAddStatus(e,t)}function AR(e,t={},n={}){return new w(n).schemaRemoveStatus(e,t)}function xR(e,t={},n={}){return new w(n).schemaAddField(e,t)}function IR(e,t={},n={}){return new w(n).schemaRemoveField(e,t)}function ER(e={}){return new w(e).schemaListFields()}function CR(e,t={}){return new w(t).schemaShowField(e)}function RR(e,t={},n={}){return new w(n).schemaApplyPreset(e,t)}function TR(e={},t={}){return new w(t).schemaInferTypes(e)}function OR(e,t,n,o={}){return new w(o).schemaRenameType(e,t,n)}function $R(e,t,n,o,r={}){return new w(r).schemaRenameField(e,t,n,o)}function FR(e,t,n,o={}){return new w(o).schemaRemapStatus(e,t,n)}function PR(e,t={}){return new w(t).schemaShowStatus(e)}function NR(e,t={},n={}){return new w(n).profile(e,t)}function LR(e={}){return new w(e).profileList()}function MR(e,t={}){return new w(t).profileShow(e)}function DR(e,t={},n={}){return new w(n).profileApply(e,t)}function jR(e,t={}){return new w(t).profileLint(e)}function GR(e={},t={}){return new w(t).validate(e)}function UR(e={},t={}){return new w(t).health(e)}function qR(e={},t={}){return new w(t).gc(e)}function zR(e,t,n={}){return new w(n).historyRedact(e,t)}function HR(e,t={},n={}){return new w(n).historyRepair(e,t)}function BR(e={},t={}){return new w(t).historyRepairAll(e)}function WR(e,t={},n={}){return new w(n).historyCompact(e,t)}function VR(e,t={}){return new w(t).historyCompactBulk(e)}function KR(e={},t={}){return new w(t).create(e)}function JR(e,t={},n={}){return new w(n).update(e,t)}function YR(e,t,n={},o={}){return new w(o).reopen(e,t,n)}function XR(e,t,n={},o={}){return new w(o).close(e,t,n)}function ZR(e,t={},n={}){return new w(n).claim(e,t)}function QR(e={},t={}){return new w(t).claimNext(e)}function eT(e,t={},n={}){return new w(n).release(e,t)}function tT(e,t={},n={}){return new w(n).copy(e,t)}function nT(e,t={},n={}){return new w(n).delete(e,t)}function oT(e,t,n={},o={}){return new w(o).restore(e,t,n)}function rT(e,t={},n={}){return new w(n).focus(e,t)}function iT(e,t={},n={}){return new w(n).startTask(e,t)}function sT(e,t={},n={}){return new w(n).pauseTask(e,t)}function aT(e,t,n={},o={}){return new w(o).closeTask(e,t,n)}function cT(e,t={},n={}){return new w(n).extension(e,t)}function lT(e={},t={}){return new w(t).extensionList(e)}function dT(e,t={},n={}){return new w(n).extensionActivate(e,t)}function mT(e,t={},n={}){return new w(n).extensionDeactivate(e,t)}function pT(e,t={},n={}){return new w(n).package(e,t)}function uT(e={},t={}){return new w(t).packageList(e)}function fT(e,t={},n={}){return new w(n).packageInstall(e,t)}function _T(e,t={},n={}){return new w(n).packageUninstall(e,t)}function hT(e={},t={}){return new w(t).packageDoctor(e)}function gT(e,t={},n={}){return new w(n).packageManage(e,t)}function yT(e,t={},n={}){return new w(n).packageDescribe(e,t)}function bT(e={},t={}){return new w(t).packageReload(e)}function wT(e={},t={}){return new w(t).packageCatalog(e)}function vT(e,t={},n={}){return new w(n).packageActivate(e,t)}function kT(e,t={},n={}){return new w(n).packageDeactivate(e,t)}function ST(e,t={},n={}){return new w(n).upgrade(e,t)}async function AT(e,t={}){let n=typeof e=="string"?{...t,pmRoot:e}:e??t,o={json:!0,quiet:n.quiet??!0,noExtensions:n.noExtensions??!1,noPager:!0,profile:n.profile??!1,path:n.pmRoot};return jn(n,o)}var _u=Bs(),ko=new Zy;function ln(e){try{return Qy(e)}catch{return Mi.resolve(e)}}function Rt(){let e=ko.getStore();for(;e!==void 0&&!e.live;)e=e.parent;return e}async function Ct(e,t,n,o=!0){let r={root:ln(e),active:t,live:!0,parent:Rt(),ready:o};try{return await ko.run(r,n)}finally{r.live=!1}}function Di(e){if(e===void 0||ln(e)===ln(process.cwd()))return;let t="Omit cwd inside an open extension scope and address the tracker with path, or make the call outside the scope.";throw new p(`A nested SDK call cannot change the working directory to "${e}" while its caller's extension scope is open. ${t}`,u.USAGE,{code:"invalid_argument_value",reason:"nested_cwd_unavailable",changed:!1,field:"cwd",required:t,nextSteps:[t]})}function ji(e,t,n,o){let r=Rt();if(r===void 0)return;let i=r===ko.getStore(),s=r.root===ln(e);if(s&&!r.ready){let a="Do the work from a command or hook handler, after the tracker's extensions have activated.";throw new p(`An extension lifecycle callback cannot run SDK work for tracker ${r.root} while its extensions activate or deactivate. ${a}`,u.USAGE,{code:"invalid_argument_value",reason:"extension_scope_not_ready",changed:!1,required:a,nextSteps:[a]})}return i&&s&&t.noExtensions!==!0?o(r.active):No(()=>Ct(e,null,()=>Li(t,n,a=>Ct(e,a,()=>o(a))),!1))}function gu(e,t,n,o,r){let i=ko.getStore();if(i===void 0)return r(null);let s=Rt(),a={...t,noExtensions:!1};return s===void 0?Ct(e,null,()=>Gi(a,n===void 0?void 0:o,o,c=>Ct(e,c,()=>r(c))),!1):s===i&&s.ready&&s.root===ln(e)?r(null):ji(e,a,o,r)}function vo(){Lo(Ds()),Mo(js()),Do(Gs()),jo(Us()),Go(qs()),Uo(zs()),qo(Hs())}async function Gi(e,t,n,o){return No(()=>t===void 0?_u.read(()=>Li(e,n,o)):_u.write(()=>nb(t,()=>Li(e,n,o))))}async function yu(e,t){let n=e.cwd,o=n===void 0?process.cwd():Mi.resolve(n),r=x(o,e.path),i=Bt({path:r,noExtensions:e.noExtensions});Rt()!==void 0&&Di(n);let s=ji(r,i,o,()=>t());return s!==void 0?s:Gi(i,n===void 0?void 0:o,o,a=>Ct(r,a,t))}function xT(e,t){return yu({path:e},t)}function eb(e){try{let t=e instanceof Error?e.stack:void 0,n=typeof t=="string"?t:Oa(e);return typeof n=="string"?n:"Unknown failure"}catch{return"Unknown failure"}}async function Li(e,t,n){let o=x(t,e.path);if(e.noExtensions)return vo(),Er({pmRoot:o},()=>n(null));if(!await ke(Se(o)))return vo(),n(null);let r=null,i;try{let s=await I(o),a=await vn({pmRoot:o,settings:s,cwd:t,noExtensions:!1}),c=await Sn({...a,loaded:a.loaded});i={loadResult:a,activationResult:c},Lo(c.hooks),Mo(c.commands),Do(c.parsers),jo(c.preflight),Go(c.services),Uo(c.renderers),qo(c.registrations),r={registrations:c.registrations,commands:c.commands,pmRoot:o,packages:a.loaded}}catch(s){vo(),console.error("[pm-sdk] extension activation failed; continuing without active extensions:",eb(s))}try{return await Er({pmRoot:o,packages:r?.packages},()=>n(r))}finally{vo(),i&&await kn(i.loadResult,i.activationResult).catch(()=>{})}}function bu(e,t){let n=De(e);return t?.registrations.commands.find(o=>De(o.action)===n)?.command??t?.commands.handlers.find(o=>De(o.command)===n)?.command}async function tb(e,t,n,o,r){if(!r)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let i=bu(e,r);if(!i)throw new p(`Unsupported native pm action: ${e}`,u.USAGE);let s=typeof n.author=="string"?n.author:o.author,a=sr(i),c=Dc(ar(t,n),Mc(r.registrations,a),a,Ed(a)),l=await Js({command:a,args:U(n.args??t.args),options:c,global:{...o,author:s},pm_root:r.pmRoot,sdk:Id(r.pmRoot,w.forActiveExtensionHost({pmRoot:r.pmRoot,author:s}),s,a)});if(!l.handled){if(Object.hasOwn(l,"cause"))throw Ta(i,l);let d=l.warnings.length>0?` (${l.warnings.join(", ")})`:"";throw new p(`Unsupported native pm action: ${e}${d}`,u.USAGE)}return l.result}async function nb(e,t){let n=process.cwd();process.chdir(e);try{return await t()}finally{process.chdir(n)}}function ob(e){let t=K(e,"action"),n=De(t),o=be(Pr,n),r=o?.action??n,i={...e,action:r};return o?.options!==void 0&&(i.options={...o.options,...Nt(e.options)}),r==="package"&&(i.options={...Nt(i.options),vocabulary:"package"}),{action:r,args:i}}function rb(e,t,n,o){let r=e[cn]===!0,i=t.noExtensions===!0&&!r?["--no-extensions"]:[];if(n!==void 0)return["--pm-path",x(o,t.path),...i];let s=ds(t,o);return[...t.noExtensions===!0?s.slice(0,-1):s,...i]}async function ib(e){let t=ob(e),n=Bt(t.args);ls(n);let o=$c(t.action),r=h(t.args,"cwd"),i=r===void 0?process.cwd():Mi.resolve(r);t.action==="init"&&(n[_l]=i),(t.action!=="init"||n.path!==void 0||(process.env.PM_PATH?.trim().length??0)>0)&&(n.path=x(i,n.path));let{expectHash:s,dispatchArgs:a}=Lc(t.args),c=async l=>{if(s===void 0)return hu(t.action,a,n,l);let{dispatchWithExpectedItemRevisions:d}=await import("./item-revision-FMD4KWBB.js");return d({action:t.action,expectHash:s,defaultId:h(a,"id")??h(Nt(a.options),"id"),options:Nt(a.options),background:a.background,pmRoot:x(i,n.path),invocation:{scopeArgs:rb(e,n,r,i),...n.outputFormat===void 0?{}:{outputArgs:["--output-format",n.outputFormat]}},run:()=>hu(t.action,a,n,l)})};try{if(t.action==="history-attest")return await c(null);let l=x(i,n.path);if(Rt()!==void 0&&Di(r),e[cn]===!0)return await gu(l,n,r,i,c);let d=ji(l,n,i,c);return d!==void 0?await d:await Gi(n,r===void 0?void 0:i,i,m=>Ct(l,m,()=>c(m)))}finally{o&&yi()}}function IT(e=Yi){return e.map(t=>{let n=De(t),o=be(Pr,n),r=o?.action??n,i=be(gi,r)!==void 0;return{action:t,resolved_action:r,covered:i,route:i?o?"alias":"native":"missing"}})}async function hu(e,t,n,o){let r=be(gi,e),i=ir(t,e,{nativeAction:r!==void 0});if(e==="create"||e==="update"){let{assertNativeMutationOptions:d}=await import("./mutation-admission-57LBSKQI.js");await d(e,t,i,n.path,Tc[e])}if(e==="update-many"){let{assertNativeUpdateManyOptions:d}=await import("./mutation-admission-57LBSKQI.js");await d(t,i,n.path)}let s=r?void 0:bu(e,o),a=s===void 0?e:`extension:${s}`;Rs(a,i),Ts(a,i);let c={action:e,args:t,options:i,id:h(t,"id"),force:t.force===!0||i.force===!0,global:n,activeExtensions:o},l=r?await r(c):await tb(e,t,i,n,o);if(e==="history-attest")return l;{let d=Ls(a,i,l);return await wd(x(process.cwd(),n.path),d),d}}var sb={closeManyOptionsFromFlat:Mn,extensionOptionsFromArgs:ar,globalOptions:Bt,mutationListOptions:Fc,normalizeActionName:De,normalizeCommandPath:sr,normalizeMcpUpdateOptions:Nc,normalizeMcpOptionsArrays:Oc,optionsWithAuthor:ir,readRequiredString:K,readScalarString:Ec,readScalarStringAllowBlank:Cc,readStringArray:U,updateManyOptionsFromFlat:Dn,withAddNoteOption:Wt,withFilesDiscoveryOptions:Ln,withMutationCompaction:j};(process.env.NODE_ENV==="test"||process.env.VITEST!==void 0||process.env.VITEST_WORKER_ID!==void 0)&&(globalThis.__pmCliActionRunnerTestHooks=sb);export{Ir as a,bd as b,Au as c,Iu as d,Eu as e,Er as f,Yt as g,kd as h,Zt as i,Zn as j,Id as k,$d as l,Nd as m,mm as n,Ed as o,Du as p,Qn as q,Fr as r,Cd as s,eo as t,Wu as u,Md as v,Ud as w,Dr as x,jr as y,Gr as z,Ur as A,xf as B,Vr as C,rm as D,lm as E,pt as F,ii as G,eh as H,ok as I,rk as J,ci as K,um as L,vk as M,kk as N,_m as O,ym as P,qk as Q,gh as R,_i as S,bh as T,wh as U,Om as V,$m as W,Fm as X,Pm as Y,Nm as Z,fS as _,_S as $,hS as aa,gS as ba,Lm as ca,jm as da,lo as ea,Hm as fa,Bm as ga,Wm as ha,K as ia,yi as ja,Wx as ka,Vx as la,Kx as ma,Jx as na,Yx as oa,op as pa,Xx as qa,Sg as ra,Ig as sa,Tg as ta,Og as ua,$g as va,z as wa,Fg as xa,Pg as ya,Ng as za,Lg as Aa,wi as Ba,ap as Ca,_t as Da,bi as Ea,cp as Fa,Mg as Ga,lp as Ha,Dg as Ia,jg as Ja,Gg as Ka,Ug as La,qg as Ma,zg as Na,Yg as Oa,up as Pa,Zg as Qa,iy as Ra,py as Sa,fy as Ta,Iy as Ua,Xy as Va,w as Wa,XC as Xa,ZC as Ya,QC as Za,eR as _a,tR as $a,nR as ab,oR as bb,rR as cb,iR as db,sR as eb,aR as fb,cR as gb,lR as hb,dR as ib,mR as jb,pR as kb,uR as lb,fR as mb,_R as nb,hR as ob,gR as pb,yR as qb,bR as rb,wR as sb,vR as tb,kR as ub,SR as vb,AR as wb,xR as xb,IR as yb,ER as zb,CR as Ab,RR as Bb,TR as Cb,OR as Db,$R as Eb,FR as Fb,PR as Gb,NR as Hb,LR as Ib,MR as Jb,DR as Kb,jR as Lb,GR as Mb,UR as Nb,qR as Ob,zR as Pb,HR as Qb,BR as Rb,WR as Sb,VR as Tb,KR as Ub,JR as Vb,YR as Wb,XR as Xb,ZR as Yb,QR as Zb,eT as _b,tT as $b,nT as ac,oT as bc,rT as cc,iT as dc,sT as ec,aT as fc,cT as gc,lT as hc,dT as ic,mT as jc,pT as kc,uT as lc,fT as mc,_T as nc,hT as oc,gT as pc,yT as qc,bT as rc,wT as sc,vT as tc,kT as uc,ST as vc,AT as wc,yu as xc,xT as yc,ib as zc,IT as Ac};
2289
+ //# sourceMappingURL=chunk-AEOHUSUI.js.map