@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
package/dist/sdk/notes.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="be7de7b1-db32-543c-a3ae-c4958ee3b395")}catch{}})();import{EXIT_CODE,PmCliError,parseLimit,stableStringify}from"./runtime-primitives.js";import{limitAnnotationEntries,parseAnnotationTextInput,resolveAnnotationInput,runAnnotationCommand}from"./annotations.js";function parseStructuredEventPayload(raw){if(raw===void 0)return;if(raw.trim().length===0)throw new PmCliError("--add-json must contain a JSON value",EXIT_CODE.USAGE,{code:"structured_event_json_empty"});let parsed;try{parsed=JSON.parse(raw)}catch{throw new PmCliError("--add-json must be valid JSON",EXIT_CODE.USAGE,{code:"structured_event_json_invalid"})}return parsed}function structuredEventType(value){if(typeof value!="object"||value===null||Array.isArray(value))return;const candidate=value.type;return typeof candidate=="string"&&candidate.trim().length>0?candidate.trim():void 0}function parseSinceTimestamp(value){if(value===void 0)return;const timestamp=Date.parse(value);if(!Number.isFinite(timestamp))throw new PmCliError("--since must be a valid ISO timestamp",EXIT_CODE.USAGE,{code:"structured_event_since_invalid"});return timestamp}function storedNoteFields(entry){return Object.prototype.toString.call(entry)==="[object Object]"?entry:{}}async function runNotes(id,options,global2){const structuredPayload=parseStructuredEventPayload(options.addJson),conflictingStructuredInputs=[options.add!==void 0,options.stdin===!0,options.file!==void 0,options.edit!==void 0,options.delete!==void 0].includes(!0);if(structuredPayload!==void 0&&conflictingStructuredInputs)throw new PmCliError("--add-json cannot be combined with text, edit, delete, stdin, or file inputs",EXIT_CODE.USAGE,{code:"structured_event_input_conflict"});const canonicalJson=structuredPayload===void 0?void 0:stableStringify(structuredPayload),filteringEvents=[options.since,options.eventType].some(value=>value!==void 0),sinceTimestamp=parseSinceTimestamp(options.since),limit=parseLimit(options.limit),result=await runAnnotationCommand(id,{...options,...filteringEvents?{limit:void 0}:{},includeMeta:[options.includeMeta===!0,filteringEvents].includes(!0)},global2,{input:await resolveAnnotationInput(canonicalJson===void 0?options:{add:canonicalJson},"note"),collectionKey:"notes",op:"note_add",editOp:"note_edit",deleteOp:"note_delete",parseText:raw=>parseAnnotationTextInput(raw),createEntry:entry=>structuredPayload===void 0?entry:{...entry,format:"json",data:structuredPayload,event_type:structuredEventType(structuredPayload)},bypassOwnershipConflict:!![options.edit===void 0,options.delete===void 0,options.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."]}}),eventType=options.eventType?.trim(),matching=result.notes.filter(entry=>{const note=storedNoteFields(entry),isStructured=[note.format==="json",note.data!==void 0].every(Boolean),matchesSince=[sinceTimestamp===void 0,Date.parse(note.created_at??"")>=(sinceTimestamp??Number.POSITIVE_INFINITY)].includes(!0),matchesType=[!eventType,note.event_type===eventType].includes(!0);return[!filteringEvents,[isStructured,matchesSince,matchesType].every(Boolean)].includes(!0)}),filtered=filteringEvents?limitAnnotationEntries(matching,limit):matching,structuredEventCount=filtered.filter(entry=>storedNoteFields(entry).format==="json").length;return{...result,notes:filtered,count:filtered.length,...filteringEvents?{total_count:matching.length,returned_count:filtered.length,has_more:filtered.length<matching.length,...limit===void 0?{}:{limit},structured_event_count:structuredEventCount}:options.includeMeta===!0?{structured_event_count:structuredEventCount}:{}}}export{runNotes};
1
+ import{EXIT_CODE as a,PmCliError as c,parseLimit as b,stableStringify as E}from"./runtime-primitives.js";import{limitAnnotationEntries as j,parseAnnotationTextInput as A,resolveAnnotationInput as T,runAnnotationCommand as O}from"./annotations.js";function I(t){if(t===void 0)return;if(t.trim().length===0)throw new c("--add-json must contain a JSON value",a.USAGE,{code:"structured_event_json_empty"});let e;try{e=JSON.parse(t)}catch{throw new c("--add-json must be valid JSON",a.USAGE,{code:"structured_event_json_invalid"})}return e}function N(t){if(typeof t!="object"||t===null||Array.isArray(t))return;const e=t.type;return typeof e=="string"&&e.trim().length>0?e.trim():void 0}function x(t){if(t===void 0)return;const e=Date.parse(t);if(!Number.isFinite(e))throw new c("--since must be a valid ISO timestamp",a.USAGE,{code:"structured_event_since_invalid"});return e}function y(t){return Object.prototype.toString.call(t)==="[object Object]"?t:{}}async function F(t,e,_){const r=I(e.addJson),v=[e.add!==void 0,e.stdin===!0,e.file!==void 0,e.edit!==void 0,e.delete!==void 0].includes(!0);if(r!==void 0&&v)throw new c("--add-json cannot be combined with text, edit, delete, stdin, or file inputs",a.USAGE,{code:"structured_event_input_conflict"});const l=r===void 0?void 0:E(r),i=[e.since,e.eventType].some(n=>n!==void 0),f=x(e.since),s=b(e.limit),p=await O(t,{...e,...i?{limit:void 0}:{},includeMeta:[e.includeMeta===!0,i].includes(!0)},_,{input:await T(l===void 0?e:{add:l},"note"),collectionKey:"notes",op:"note_add",editOp:"note_edit",deleteOp:"note_delete",parseText:n=>A(n),createEntry:n=>r===void 0?n:{...n,format:"json",data:r,event_type:N(r)},bypassOwnershipConflict:!![e.edit===void 0,e.delete===void 0,e.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."]}}),m=e.eventType?.trim(),u=p.notes.filter(n=>{const o=y(n),g=[o.format==="json",o.data!==void 0].every(Boolean),w=[f===void 0,Date.parse(o.created_at??"")>=(f??Number.POSITIVE_INFINITY)].includes(!0),S=[!m,o.event_type===m].includes(!0);return[!i,[g,w,S].every(Boolean)].includes(!0)}),d=i?j(u,s):u,h=d.filter(n=>y(n).format==="json").length;return{...p,notes:d,count:d.length,...i?{total_count:u.length,returned_count:d.length,has_more:d.length<u.length,...s===void 0?{}:{limit:s},structured_event_count:h}:e.includeMeta===!0?{structured_event_count:h}:{}}}export{F as runNotes};
2
2
  //# sourceMappingURL=notes.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f698608a-2f39-5972-b24b-93287af6b373")}catch{}})();import{estimatePmOutputTokens}from"../cli-contracts/agent-output-contracts.js";class OutputEnvelopeFitError extends RangeError{code;work;minimum_tokens;constructor(code,work,minimumTokens){super(code),this.name="OutputEnvelopeFitError",this.code=code,this.work=Object.freeze({...work}),this.minimum_tokens=minimumTokens}}function assertPositiveInteger(value,name){if(!Number.isSafeInteger(value)||value<1)throw new RangeError(`${name} must be a positive safe integer`)}function renderEnvelope(envelope,renderers,estimateTokens,work){return renderers.map(([name,render])=>{if(work.render_calls>=work.max_render_calls)throw new OutputEnvelopeFitError("output_envelope_work_limit",work);work.render_calls+=1;const text=render(envelope);if(typeof text!="string")throw new TypeError("Envelope renderers must return strings");const estimatedTokens=estimateTokens(text);if(!Number.isSafeInteger(estimatedTokens)||estimatedTokens<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name,text,bytes:Buffer.byteLength(text,"utf8"),estimated_tokens:estimatedTokens}})}function stabilizeEnvelope(rows,initial,options,work){let receipt=initial;const renderers=Object.entries(options.renderers),estimateTokens=options.estimateTokens??(text=>estimatePmOutputTokens(Buffer.byteLength(text,"utf8")));for(let pass=0;pass<(options.maxStabilizationPasses??16);pass+=1){const frozenReceipt=Object.freeze({...receipt}),envelope={...options.buildEnvelope(rows,frozenReceipt),output_fit:frozenReceipt},renderings=renderEnvelope(envelope,renderers,estimateTokens,work),bytes=Math.max(...renderings.map(rendering=>rendering.bytes)),tokens=Math.max(...renderings.map(rendering=>rendering.estimated_tokens));if(bytes===receipt.output_bytes&&tokens===receipt.estimated_tokens)return{envelope,renderings};receipt={...receipt,output_bytes:bytes,estimated_tokens:tokens}}throw new OutputEnvelopeFitError("output_envelope_unstable",work)}function fitOutputEnvelope(candidates,options){assertPositiveInteger(options.tokenBudget,"tokenBudget"),assertPositiveInteger(options.maxRenderCalls??1e4,"maxRenderCalls"),assertPositiveInteger(options.maxStabilizationPasses??16,"maxStabilizationPasses");const policy=options.policy??"prefix";if(policy!=="prefix"&&policy!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(options.renderers).length===0||Object.entries(options.renderers).some(([name,render])=>!name.trim()||typeof render!="function"))throw new TypeError("Envelope fitting requires named callable renderers");const work={evaluated_candidates:0,render_calls:0,max_render_calls:options.maxRenderCalls??1e4};let rows=[],included=[];const receiptFor=indices=>({version:1,policy,total_candidates:candidates.length,included_indices:Object.freeze([...indices]),omitted_count:candidates.length-indices.length,token_budget:options.tokenBudget,estimated_tokens:0,output_bytes:0});let fitted=stabilizeEnvelope(rows,receiptFor(included),options,work);if(fitted.envelope.output_fit.estimated_tokens>options.tokenBudget)throw new OutputEnvelopeFitError("output_envelope_infeasible",work,fitted.envelope.output_fit.estimated_tokens);for(const[index,candidate]of candidates.entries()){work.evaluated_candidates+=1;const trialRows=[...rows,candidate],trialIndices=[...included,index],trial=stabilizeEnvelope(trialRows,receiptFor(trialIndices),options,work);if(trial.envelope.output_fit.estimated_tokens<=options.tokenBudget)rows=trialRows,included=trialIndices,fitted=trial;else if(policy==="prefix")break}return{rows,...fitted,complete:rows.length===candidates.length,work:Object.freeze({...work})}}export{OutputEnvelopeFitError,fitOutputEnvelope};
1
+ import{estimatePmOutputTokens as g}from"../cli-contracts/agent-output-contracts.js";class p extends RangeError{code;work;minimum_tokens;constructor(e,n,t){super(e),this.name="OutputEnvelopeFitError",this.code=e,this.work=Object.freeze({...n}),this.minimum_tokens=t}}function _(o,e){if(!Number.isSafeInteger(o)||o<1)throw new RangeError(`${e} must be a positive safe integer`)}function k(o,e,n,t){return e.map(([r,l])=>{if(t.render_calls>=t.max_render_calls)throw new p("output_envelope_work_limit",t);t.render_calls+=1;const i=l(o);if(typeof i!="string")throw new TypeError("Envelope renderers must return strings");const s=n(i);if(!Number.isSafeInteger(s)||s<0)throw new RangeError("Envelope token estimates must be non-negative safe integers");return{name:r,text:i,bytes:Buffer.byteLength(i,"utf8"),estimated_tokens:s}})}function b(o,e,n,t){let r=e;const l=Object.entries(n.renderers),i=n.estimateTokens??(s=>g(Buffer.byteLength(s,"utf8")));for(let s=0;s<(n.maxStabilizationPasses??16);s+=1){const a=Object.freeze({...r}),u={...n.buildEnvelope(o,a),output_fit:a},c=k(u,l,i,t),f=Math.max(...c.map(m=>m.bytes)),d=Math.max(...c.map(m=>m.estimated_tokens));if(f===r.output_bytes&&d===r.estimated_tokens)return{envelope:u,renderings:c};r={...r,output_bytes:f,estimated_tokens:d}}throw new p("output_envelope_unstable",t)}function v(o,e){_(e.tokenBudget,"tokenBudget"),_(e.maxRenderCalls??1e4,"maxRenderCalls"),_(e.maxStabilizationPasses??16,"maxStabilizationPasses");const n=e.policy??"prefix";if(n!=="prefix"&&n!=="skip")throw new TypeError("Unknown output envelope fit policy");if(Object.entries(e.renderers).length===0||Object.entries(e.renderers).some(([a,u])=>!a.trim()||typeof u!="function"))throw new TypeError("Envelope fitting requires named callable renderers");const t={evaluated_candidates:0,render_calls:0,max_render_calls:e.maxRenderCalls??1e4};let r=[],l=[];const i=a=>({version:1,policy:n,total_candidates:o.length,included_indices:Object.freeze([...a]),omitted_count:o.length-a.length,token_budget:e.tokenBudget,estimated_tokens:0,output_bytes:0});let s=b(r,i(l),e,t);if(s.envelope.output_fit.estimated_tokens>e.tokenBudget)throw new p("output_envelope_infeasible",t,s.envelope.output_fit.estimated_tokens);for(const[a,u]of o.entries()){t.evaluated_candidates+=1;const c=[...r,u],f=[...l,a],d=b(c,i(f),e,t);if(d.envelope.output_fit.estimated_tokens<=e.tokenBudget)r=c,l=f,s=d;else if(n==="prefix")break}return{rows:r,...s,complete:r.length===o.length,work:Object.freeze({...t})}}export{p as OutputEnvelopeFitError,v as fitOutputEnvelope};
2
2
  //# sourceMappingURL=fit-envelope.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43d2915b-7301-5e96-89e0-51c8e817789e")}catch{}})();function isRecord(value){return value!==null&&typeof value=="object"&&!Array.isArray(value)}const ROW_PROJECTION_MODES=new Set(["brief","compact","fields"]);function isRowProjection(value){if(!isRecord(value))return!1;const fields=value.fields;return ROW_PROJECTION_MODES.has(value.mode)&&Object.keys(value).length===2&&Array.isArray(fields)&&fields.length>0&&fields.every(field=>typeof field=="string"&&field.length>0)}function rowsMatchProjection(items,projection){return items.every(row=>isRecord(row)&&Object.keys(row).length===projection.fields.length&&projection.fields.every(field=>Object.hasOwn(row,field)))}function retainedProjection(projection,rowCount){return projection.mode==="fields"&&rowCount===0?{projection}:{}}function hasStandardPagination(value,count){return typeof value.has_more=="boolean"&&value.truncated===value.has_more&&value.count===count&&typeof value.total=="number"&&Number.isSafeInteger(value.total)&&(value.has_more?value.total>count&&typeof value.next_cursor=="string"&&value.next_cursor.length>0:value.total===count&&value.next_cursor==null)}function hasCompactibleSource(value){return isRecord(value)&&(value.status==="complete"||value.status==="unchecked")&&value.unreadable_item_count===0&&value.unreadable_directory_count===0}function hasDefaultOmissions(value,groupName="full_item_fields"){if(!isRecord(value)||!Array.isArray(value.omitted_field_groups))return!1;const groups=value.omitted_field_groups,group=groups[0];return value.has_omissions===!0&&value.omitted_field_group_count===1&&Object.keys(value).length===3&&groups.length===1&&isRecord(group)&&Object.keys(group).length===2&&group.name===groupName&&group.restore_with==="--full"}function projectPmBriefListEnvelope(value){if(!isRecord(value)||!Array.isArray(value.items)||Object.hasOwn(value,"details")||!isRowProjection(value.projection)||!rowsMatchProjection(value.items,value.projection)||!hasCompactibleSource(value.completeness)||!hasStandardPagination(value,value.items.length)||!hasDefaultOmissions(value.omission_receipt))return value;const{total,has_more:hasMore,truncated:_truncated,next_cursor:nextCursor,completeness,projection,now:_now,omission_receipt:_omissions,sorting,filters,...rest}=value,completed=completeness.status==="complete"&&!hasMore&&Object.keys(completeness).length===3,{unreadable_item_count:_items,unreadable_directory_count:_directories,...source}=completeness;return{...rest,...completed?{}:{total,has_more:hasMore,completeness:source},...hasMore?{next_cursor:nextCursor}:{},...projectDefaultSorting(sorting),...compactEchoedFilters(filters,rest.applied_limit,projection),...retainedProjection(projection,value.items.length),details:"--full"}}function isDefaultSorting(value){return isRecord(value)&&value.sort==="default"&&value.order==="asc"&&Object.keys(value).every(key=>key==="sort"||key==="order"||key==="effective_keys")}function isSortKeyPair(value){return Array.isArray(value)&&value.length===2&&typeof value[0]=="string"&&(value[1]==="asc"||value[1]==="desc")}function projectDefaultSorting(value){if(!isDefaultSorting(value))return{sorting:value};const keys=value.effective_keys;return keys===void 0?{}:!Array.isArray(keys)||!keys.every(isSortKeyPair)?{sorting:value}:{sorting:{effective_keys:keys.map(([key,order])=>`${key} ${order}`).join(", ")}}}function echoesProjectionFields(value,projection){if(typeof value!="string"||projection===void 0)return!1;const requested=value.split(",").map(field=>field.trim()).filter(Boolean);return requested.length===projection.fields.length&&requested.every((field,index)=>field===projection.fields[index])}function compactEchoedFilters(filters,appliedLimit,projection){if(!isRecord(filters))return filters===void 0?{}:{filters};const remaining=Object.fromEntries(Object.entries(filters).filter(([key,value])=>!(key==="limit"&&String(value)===String(appliedLimit))&&!(key==="fields"&&echoesProjectionFields(value,projection))&&!(key==="runtime_filters"&&isRecord(value)&&Object.keys(value).length===0)));return Object.keys(remaining).length===0?{}:{filters:remaining}}function hasTerminalSearchPagination(value,count){return value.count===count&&!Object.hasOwn(value,"has_more")&&!Object.hasOwn(value,"truncated")&&value.next_cursor==null&&(value.total===void 0||value.total===count)}function standardSearchProjection(value){if(!Object.hasOwn(value,"projection"))return hasDefaultOmissions(value.omission_receipt,"projection_metadata")?{}:void 0;const projection=value.projection;return isRowProjection(projection)&&projection.mode==="fields"&&rowsMatchProjection(value.items,projection)&&typeof value.now=="string"&&hasDefaultOmissions(value.omission_receipt)?{projection}:void 0}function projectPmBriefSearchEnvelope(value){if(!isRecord(value)||typeof value.query!="string"||!Array.isArray(value.items)||Object.hasOwn(value,"details")||!(hasStandardPagination(value,value.items.length)||hasTerminalSearchPagination(value,value.items.length)))return value;const standard=standardSearchProjection(value);if(standard===void 0)return value;const{truncated:_truncated,omission_receipt:_omissions,filters,projection:_projection,now:_now,mode_source:modeSource,...rest}=value;return{...rest,...modeSource==="settings"||standard.projection===void 0&&modeSource!==void 0?{mode_source:modeSource}:{},...compactEchoedFilters(filters,rest.applied_limit,standard.projection),...standard.projection?retainedProjection(standard.projection,value.items.length):{},details:"--full"}}export{projectPmBriefListEnvelope,projectPmBriefSearchEnvelope};
1
+ function o(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}const l=new Set(["brief","compact","fields"]);function p(t){if(!o(t))return!1;const e=t.fields;return l.has(t.mode)&&Object.keys(t).length===2&&Array.isArray(e)&&e.length>0&&e.every(r=>typeof r=="string"&&r.length>0)}function h(t,e){return t.every(r=>o(r)&&Object.keys(r).length===e.fields.length&&e.fields.every(n=>Object.hasOwn(r,n)))}function g(t,e){return t.mode==="fields"&&e===0?{projection:t}:{}}function y(t,e){return typeof t.has_more=="boolean"&&t.truncated===t.has_more&&t.count===e&&typeof t.total=="number"&&Number.isSafeInteger(t.total)&&(t.has_more?t.total>e&&typeof t.next_cursor=="string"&&t.next_cursor.length>0:t.total===e&&t.next_cursor==null)}function A(t){return o(t)&&(t.status==="complete"||t.status==="unchecked")&&t.unreadable_item_count===0&&t.unreadable_directory_count===0}function m(t,e="full_item_fields"){if(!o(t)||!Array.isArray(t.omitted_field_groups))return!1;const r=t.omitted_field_groups,n=r[0];return t.has_omissions===!0&&t.omitted_field_group_count===1&&Object.keys(t).length===3&&r.length===1&&o(n)&&Object.keys(n).length===2&&n.name===e&&n.restore_with==="--full"}function B(t){if(!o(t)||!Array.isArray(t.items)||Object.hasOwn(t,"details")||!p(t.projection)||!h(t.items,t.projection)||!A(t.completeness)||!y(t,t.items.length)||!m(t.omission_receipt))return t;const{total:e,has_more:r,truncated:n,next_cursor:i,completeness:s,projection:f,now:c,omission_receipt:d,sorting:u,filters:a,..._}=t,O=s.status==="complete"&&!r&&Object.keys(s).length===3,{unreadable_item_count:D,unreadable_directory_count:R,...b}=s;return{..._,...O?{}:{total:e,has_more:r,completeness:b},...r?{next_cursor:i}:{},...P(u),...j(a,_.applied_limit,f),...g(f,t.items.length),details:"--full"}}function S(t){return o(t)&&t.sort==="default"&&t.order==="asc"&&Object.keys(t).every(e=>e==="sort"||e==="order"||e==="effective_keys")}function w(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&(t[1]==="asc"||t[1]==="desc")}function P(t){if(!S(t))return{sorting:t};const e=t.effective_keys;return e===void 0?{}:!Array.isArray(e)||!e.every(w)?{sorting:t}:{sorting:{effective_keys:e.map(([r,n])=>`${r} ${n}`).join(", ")}}}function k(t,e){if(typeof t!="string"||e===void 0)return!1;const r=t.split(",").map(n=>n.trim()).filter(Boolean);return r.length===e.fields.length&&r.every((n,i)=>n===e.fields[i])}function j(t,e,r){if(!o(t))return t===void 0?{}:{filters:t};const n=Object.fromEntries(Object.entries(t).filter(([i,s])=>!(i==="limit"&&String(s)===String(e))&&!(i==="fields"&&k(s,r))&&!(i==="runtime_filters"&&o(s)&&Object.keys(s).length===0)));return Object.keys(n).length===0?{}:{filters:n}}function x(t,e){return t.count===e&&!Object.hasOwn(t,"has_more")&&!Object.hasOwn(t,"truncated")&&t.next_cursor==null&&(t.total===void 0||t.total===e)}function E(t){if(!Object.hasOwn(t,"projection"))return m(t.omission_receipt,"projection_metadata")?{}:void 0;const e=t.projection;return p(e)&&e.mode==="fields"&&h(t.items,e)&&typeof t.now=="string"&&m(t.omission_receipt)?{projection:e}:void 0}function C(t){if(!o(t)||typeof t.query!="string"||!Array.isArray(t.items)||Object.hasOwn(t,"details")||!(y(t,t.items.length)||x(t,t.items.length)))return t;const e=E(t);if(e===void 0)return t;const{truncated:r,omission_receipt:n,filters:i,projection:s,now:f,mode_source:c,...d}=t;return{...d,...c==="settings"||e.projection===void 0&&c!==void 0?{mode_source:c}:{},...j(i,d.applied_limit,e.projection),...e.projection?g(e.projection,t.items.length):{},details:"--full"}}export{B as projectPmBriefListEnvelope,C as projectPmBriefSearchEnvelope};
2
2
  //# sourceMappingURL=list-envelope.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bafcd4e4-ec0f-5340-89ce-b85d822b2323")}catch{}})();function encodePmTableRows(rows,options={}){const columns=[...new Set(rows.flatMap(row=>Object.keys(row)))],nullColumns=options.compact?columns.filter(column=>rows.every(row=>Object.hasOwn(row,column)&&row[column]===null)):[],listColumns=options.compact?columns.filter(column=>rows.every(row=>{if(!Object.hasOwn(row,column))return!0;const cell=row[column];return Array.isArray(cell)&&cell.every(value=>typeof value=="string"&&value!==""&&!value.includes(";"))})):[],lists=new Set(listColumns),nulls=new Set(nullColumns),jsonColumns=columns.filter(column=>!lists.has(column)&&rows.some(row=>{const cell=row[column];return cell!==null&&typeof cell=="object"})),nested=new Set(jsonColumns),absent=[];return{rows:rows.map((row,index)=>Object.fromEntries(columns.filter(column=>!nulls.has(column)).map(column=>{if(!Object.hasOwn(row,column))return absent.push([index,column]),[column,null];const cell=row[column];return lists.has(column)?[column,cell.join(";")]:[column,nested.has(column)?JSON.stringify(cell):cell]}))),encoding:{json_columns:jsonColumns,absent,...listColumns.length?{list_columns:Object.fromEntries(listColumns.map(column=>[column,";"]))}:{},...nullColumns.length?{null_columns:nullColumns,null_column_index:nullColumns.map(column=>columns.indexOf(column))}:{}}}}function projectPmTableEncodingForToon(encoding){const{json_columns:jsonColumns,absent,...declarations}=encoding,absentRows=new Map;for(const[row,column]of absent){const rows=absentRows.get(column)??[];rows.push(row),absentRows.set(column,rows)}return{...jsonColumns.length>0?{json_columns:jsonColumns}:{},...absentRows.size>0?{absent_rows:Object.fromEntries(absentRows)}:{},...declarations}}function restoreColumnOrder(encodedColumns,encoding){const nullColumns=encoding.null_columns??[],positions=encoding.null_column_index??[],columns=[...encodedColumns],insertions=nullColumns.map((column,index)=>({column,position:positions[index]})).filter(entry=>typeof entry.position=="number").sort((left,right)=>left.position-right.position);for(const{column,position}of insertions)columns.splice(Math.min(position,columns.length),0,column);for(const column of nullColumns)columns.includes(column)||columns.push(column);return columns}function decodePmTableRows(table){const nested=new Set(table.encoding.json_columns??[]),delimiters=new Map(Object.entries(table.encoding.list_columns??{})),absent=new Set([...(table.encoding.absent??[]).map(([row,column])=>JSON.stringify([row,column])),...Object.entries(table.encoding.absent_rows??{}).flatMap(([column,rows])=>rows.map(row=>JSON.stringify([row,column])))]);return table.rows.map((row,index)=>{const cells=new Map(Object.entries(row).flatMap(([column,cell])=>{if(absent.has(JSON.stringify([index,column])))return[];const delimiter=delimiters.get(column),value=delimiter!==void 0?cell===""?[]:String(cell).split(delimiter):nested.has(column)?JSON.parse(String(cell)):cell;return[[column,value]]}));for(const column of table.encoding.null_columns??[])cells.set(column,null);const columns=table.encoding.column_order??restoreColumnOrder(Object.keys(row),table.encoding);return Object.fromEntries(columns.filter(column=>cells.has(column)).map(column=>[column,cells.get(column)]))})}export{decodePmTableRows,encodePmTableRows,projectPmTableEncodingForToon};
1
+ function O(s,u={}){const c=[...new Set(s.flatMap(e=>Object.keys(e)))],f=u.compact?c.filter(e=>s.every(a=>Object.hasOwn(a,e)&&a[e]===null)):[],n=u.compact?c.filter(e=>s.every(a=>{if(!Object.hasOwn(a,e))return!0;const o=a[e];return Array.isArray(o)&&o.every(m=>typeof m=="string"&&m!==""&&!m.includes(";"))})):[],l=new Set(n),t=new Set(f),r=c.filter(e=>!l.has(e)&&s.some(a=>{const o=a[e];return o!==null&&typeof o=="object"})),i=new Set(r),p=[];return{rows:s.map((e,a)=>Object.fromEntries(c.filter(o=>!t.has(o)).map(o=>{if(!Object.hasOwn(e,o))return p.push([a,o]),[o,null];const m=e[o];return l.has(o)?[o,m.join(";")]:[o,i.has(o)?JSON.stringify(m):m]}))),encoding:{json_columns:r,absent:p,...n.length?{list_columns:Object.fromEntries(n.map(e=>[e,";"]))}:{},...f.length?{null_columns:f,null_column_index:f.map(e=>c.indexOf(e))}:{}}}}function j(s){const{json_columns:u,absent:c,...f}=s,n=new Map;for(const[l,t]of c){const r=n.get(t)??[];r.push(l),n.set(t,r)}return{...u.length>0?{json_columns:u}:{},...n.size>0?{absent_rows:Object.fromEntries(n)}:{},...f}}function g(s,u){const c=u.null_columns??[],f=u.null_column_index??[],n=[...s],l=c.map((t,r)=>({column:t,position:f[r]})).filter(t=>typeof t.position=="number").sort((t,r)=>t.position-r.position);for(const{column:t,position:r}of l)n.splice(Math.min(r,n.length),0,t);for(const t of c)n.includes(t)||n.push(t);return n}function h(s){const u=new Set(s.encoding.json_columns??[]),c=new Map(Object.entries(s.encoding.list_columns??{})),f=new Set([...(s.encoding.absent??[]).map(([n,l])=>JSON.stringify([n,l])),...Object.entries(s.encoding.absent_rows??{}).flatMap(([n,l])=>l.map(t=>JSON.stringify([t,n])))]);return s.rows.map((n,l)=>{const t=new Map(Object.entries(n).flatMap(([i,p])=>{if(f.has(JSON.stringify([l,i])))return[];const d=c.get(i),e=d!==void 0?p===""?[]:String(p).split(d):u.has(i)?JSON.parse(String(p)):p;return[[i,e]]}));for(const i of s.encoding.null_columns??[])t.set(i,null);const r=s.encoding.column_order??g(Object.keys(n),s.encoding);return Object.fromEntries(r.filter(i=>t.has(i)).map(i=>[i,t.get(i)]))})}export{h as decodePmTableRows,O as encodePmTableRows,j as projectPmTableEncodingForToon};
2
2
  //# sourceMappingURL=table-rows.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76c420db-b520-5fde-bd43-16a7324feb0a")}catch{}})();import{resolvePmHistoryOperation}from"./cli-contracts/command-aliases.js";import{PM_CORE_COMMAND_NAMES}from"./cli-contracts/enum-contracts.js";const PM_OUTPUT_ENVELOPE_KINDS=["mutation_receipt","entity","collection","diagnostic","stream"],MUTATION_COMMANDS=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),COLLECTION_MUTATION_COMMANDS=new Set(["close-many","update-many"]),COLLECTION_COMMANDS=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),DIAGNOSTIC_COMMANDS=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function definePmCommandOutputEnvelope(contract){if(contract.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!PM_OUTPUT_ENVELOPE_KINDS.includes(contract.kind))throw new TypeError(`Unsupported output envelope kind: ${contract.kind}`);return contract}function createOutputEnvelopeContract(command){const normalizedCommand=command.trim().replace(/\s+/gu," "),[rootCommand=normalizedCommand]=normalizedCommand.split(" ");return COLLECTION_MUTATION_COMMANDS.has(rootCommand)?definePmCommandOutputEnvelope({command:normalizedCommand,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):MUTATION_COMMANDS.has(rootCommand)?definePmCommandOutputEnvelope({command:normalizedCommand,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):COLLECTION_COMMANDS.has(rootCommand)?definePmCommandOutputEnvelope({command:normalizedCommand,kind:"collection",wrapper_key:rootCommand==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):DIAGNOSTIC_COMMANDS.has(rootCommand)?definePmCommandOutputEnvelope({command:normalizedCommand,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):definePmCommandOutputEnvelope({command:normalizedCommand,kind:rootCommand==="get"?"entity":"diagnostic",wrapper_key:rootCommand==="get"?"item":null,cardinality:rootCommand==="get"?"one":"none",format_flag:"--json"})}const PM_COMMAND_OUTPUT_ENVELOPE_CONTRACTS=PM_CORE_COMMAND_NAMES.map(command=>createOutputEnvelopeContract(command)),OUTPUT_ENVELOPE_BY_COMMAND=new Map(PM_COMMAND_OUTPUT_ENVELOPE_CONTRACTS.map(contract=>[contract.command,contract]));function resolvePmCommandOutputEnvelope(command){const normalized=command.trim().replace(/\s+/gu," ");if(normalized.length===0)throw new TypeError("command must be a non-empty command path");const[rootCommand=normalized]=resolvePmHistoryOperation(normalized).split(" "),declared=OUTPUT_ENVELOPE_BY_COMMAND.get(rootCommand);return declared?{...declared,command:normalized}:createOutputEnvelopeContract(normalized)}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function isPmMutationReceipt(value){return isRecord(value)&&typeof value.id=="string"&&value.id.length>0&&typeof value.status=="string"&&value.status.length>0&&Number.isSafeInteger(value.changed_field_count)&&Number(value.changed_field_count)>=0&&(value.close_reason===void 0||typeof value.close_reason=="string")&&(value.deleted===void 0||typeof value.deleted=="boolean")&&(value.previous_status===void 0||typeof value.previous_status=="string")&&(value.warnings===void 0||Array.isArray(value.warnings))}function parseMutationReceipt(input){let value=input;if(typeof input=="string")try{value=JSON.parse(input)}catch(error){throw new TypeError(`Mutation receipt must be valid JSON: ${String(error)}`,{cause:error})}if(!isPmMutationReceipt(value))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:value.id,status:value.status,changedFieldCount:value.changed_field_count,...typeof value.close_reason=="string"?{closeReason:value.close_reason}:{},...typeof value.deleted=="boolean"?{deleted:value.deleted}:{},...typeof value.previous_status=="string"?{previousStatus:value.previous_status}:{},...Array.isArray(value.warnings)?{warnings:value.warnings}:{}}}export{PM_COMMAND_OUTPUT_ENVELOPE_CONTRACTS,PM_OUTPUT_ENVELOPE_KINDS,definePmCommandOutputEnvelope,isPmMutationReceipt,parseMutationReceipt,resolvePmCommandOutputEnvelope};
1
+ import{resolvePmHistoryOperation as s}from"./cli-contracts/command-aliases.js";import{PM_CORE_COMMAND_NAMES as i}from"./cli-contracts/enum-contracts.js";const c=["mutation_receipt","entity","collection","diagnostic","stream"],d=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),p=new Set(["close-many","update-many"]),m=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),l=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function o(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!c.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function a(e){const t=e.trim().replace(/\s+/gu," "),[n=t]=t.split(" ");return p.has(n)?o({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):d.has(n)?o({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):m.has(n)?o({command:t,kind:"collection",wrapper_key:n==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):l.has(n)?o({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):o({command:t,kind:n==="get"?"entity":"diagnostic",wrapper_key:n==="get"?"item":null,cardinality:n==="get"?"one":"none",format_flag:"--json"})}const u=i.map(e=>a(e)),f=new Map(u.map(e=>[e.command,e]));function O(e){const t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");const[n=t]=s(t).split(" "),r=f.get(n);return r?{...r,command:t}:a(t)}function y(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function _(e){return y(e)&&typeof e.id=="string"&&e.id.length>0&&typeof e.status=="string"&&e.status.length>0&&Number.isSafeInteger(e.changed_field_count)&&Number(e.changed_field_count)>=0&&(e.close_reason===void 0||typeof e.close_reason=="string")&&(e.deleted===void 0||typeof e.deleted=="boolean")&&(e.previous_status===void 0||typeof e.previous_status=="string")&&(e.warnings===void 0||Array.isArray(e.warnings))}function w(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(n){throw new TypeError(`Mutation receipt must be valid JSON: ${String(n)}`,{cause:n})}if(!_(t))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:t.id,status:t.status,changedFieldCount:t.changed_field_count,...typeof t.close_reason=="string"?{closeReason:t.close_reason}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.previous_status=="string"?{previousStatus:t.previous_status}:{},...Array.isArray(t.warnings)?{warnings:t.warnings}:{}}}export{u as PM_COMMAND_OUTPUT_ENVELOPE_CONTRACTS,c as PM_OUTPUT_ENVELOPE_KINDS,o as definePmCommandOutputEnvelope,_ as isPmMutationReceipt,w as parseMutationReceipt,O as resolvePmCommandOutputEnvelope};
2
2
  //# sourceMappingURL=output-contracts.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a65d6520-0e6f-5627-a4dd-bd455c2db0fa")}catch{}})();import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";const MATERIAL_FIELD_GROUPS_BY_RESULT=new WeakMap;function registerOutputMaterialFieldGroups(result,fieldGroups){MATERIAL_FIELD_GROUPS_BY_RESULT.set(result,new Set(fieldGroups))}const PM_READ_ROW_JQ_SELECTOR='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',PM_READ_ROW_CONTRACTS={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function assertProjectionModeChoice(compactRequested,fullRequested,compactFlag){if(compactRequested&&fullRequested)throw new PmCliError(`${compactFlag} cannot be combined with --full`,EXIT_CODE.USAGE)}function createOutputOmissionReceipt(declaredGroups,includedGroupNames=new Set){const omittedFieldGroups=declaredGroups.filter(group=>!includedGroupNames.has(group.name)).map(group=>({...group}));return{has_omissions:omittedFieldGroups.length>0,omitted_field_group_count:omittedFieldGroups.length,omitted_field_groups:omittedFieldGroups}}function resolveModePairedOutputOmissionReceipt(command,mode){const contract=PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS.find(candidate=>candidate.command===command);if(contract===void 0)throw new TypeError(`Unknown mode-paired output command: ${command}`);if(mode===contract.complete_mode)return createOutputOmissionReceipt([]);const groups=contract.omissions_by_mode[mode];if(groups===void 0)throw new TypeError(`Unknown ${command} output mode: ${mode}`);return createOutputOmissionReceipt(groups)}const CONTEXT_FIELD_GROUPS=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const READ_ROW_TOON_ENCODINGS=new Set([void 0,"tabular_when_uniform"]),READ_ROW_KINDS=new Set(["collection","none"]),READ_ROW_FIELD_MODES=new Set(["supported","unsupported"]);function isUniqueNonEmptyStringArray(value,allowEmpty){return Array.isArray(value)&&(allowEmpty||value.length>0)&&value.every(entry=>typeof entry=="string"&&entry.length>0)&&new Set(value).size===value.length}function isReadRowContract(value){return isRecord(value)&&typeof value.command=="string"&&value.command.trim().length>0&&READ_ROW_KINDS.has(value.row_kind)&&isUniqueNonEmptyStringArray(value.row_keys,!0)&&(value.continuation_row_keys===void 0||isUniqueNonEmptyStringArray(value.continuation_row_keys,!1))&&READ_ROW_FIELD_MODES.has(value.fields)&&READ_ROW_TOON_ENCODINGS.has(value.toon_encoding)&&(value.row_kind==="collection"?value.row_keys.length>0&&typeof value.jq_selector=="string"&&value.jq_selector.trim().length>0:value.row_keys.length===0&&value.jq_selector===void 0)}const GRAPH_ROW_KEYS={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},READ_RESULT_SENTINEL_KEYS={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function resolveReadRowContract(command,result){const rawRootCommand=command.trim().toLowerCase().split(/\s+/u,1)[0],rootCommand=rawRootCommand?.startsWith("list-")?"list":rawRootCommand;if(rootCommand==="graph"){const subcommand=typeof result.subcommand=="string"?result.subcommand:"";if(subcommand.length===0)return;const rowKeys=GRAPH_ROW_KEYS[subcommand];if(rowKeys===void 0)return;const activeRowKeys=rowKeys.filter(key=>Array.isArray(result[key])||isRecord(result[key]));return{command:"graph",row_kind:activeRowKeys.length>0?"collection":"none",row_keys:activeRowKeys,fields:"unsupported",...activeRowKeys.length>0?{jq_selector:PM_READ_ROW_JQ_SELECTOR}:{},toon_encoding:"tabular_when_uniform"}}const declaration=PM_READ_ROW_CONTRACTS[rootCommand],sentinelKeys=READ_RESULT_SENTINEL_KEYS[rootCommand];return declaration===void 0||sentinelKeys===void 0||!sentinelKeys.some(key=>Object.hasOwn(result,key))?void 0:(()=>{const rowKeys=declaration.row_keys.filter(key=>{const value=key.split(".").reduce((current,segment)=>isRecord(current)?current[segment]:void 0,result);return Array.isArray(value)||isRecord(value)});return{command:rootCommand,row_kind:rowKeys.length>0?"collection":"none",row_keys:rowKeys,fields:declaration.fields,...rowKeys.length>0?{jq_selector:PM_READ_ROW_JQ_SELECTOR}:{},toon_encoding:"tabular_when_uniform"}})()}function resolveDeclaredProjectionReceipt(result){if(!isRecord(result.projection)||typeof result.projection.mode!="string"||result.projection.mode.trim().length===0)return;const declared=result.projection.declared_field_groups,included=result.projection.included_field_groups;if(!Array.isArray(declared)||!Array.isArray(included))return;const declaredGroups=declared.filter(entry=>isRecord(entry)&&typeof entry.name=="string"&&entry.name.trim().length>0&&typeof entry.restore_with=="string"&&entry.restore_with.trim().length>0),includedNames=included.filter(entry=>typeof entry=="string");if(declaredGroups.length!==declared.length||includedNames.length!==included.length)return;const declaredNames=new Set(declaredGroups.map(group=>group.name));if(!(declaredNames.size!==declaredGroups.length||new Set(includedNames).size!==includedNames.length||includedNames.some(name=>!declaredNames.has(name))))return createOutputOmissionReceipt(declaredGroups,new Set(includedNames))}function resolveContextReceipt(result){if(!Array.isArray(result.sections_included))return;const receipt=createOutputOmissionReceipt(CONTEXT_FIELD_GROUPS,new Set(result.sections_included.filter(section=>typeof section=="string")));return isRecord(result.summary)&&result.summary.scope==="matching_items"&&(receipt.summary_scope="matching_items"),receipt}function isGetFieldGroupIncluded(name,owner,result){if(name==="dependency_provenance")return!1;const nested=splitNestedGetGroup(name);if(nested!==void 0){const facet=result[nested.facet];return isRecord(facet)&&Object.hasOwn(facet,nested.member)}return Object.hasOwn(owner,name)||(name==="reminders"||name==="events")&&isRecord(result.schedule)&&Object.hasOwn(result.schedule,name)||["files","tests","docs"].includes(name)&&isRecord(result.linked)&&Array.isArray(result.linked[name])&&result.linked[name].length>0}function splitNestedGetGroup(name){const dot=name.indexOf(".");return dot===-1?void 0:{facet:name.slice(0,dot),member:name.slice(dot+1)}}function resolveGetReceipt(result){if(!isRecord(result.item))return;const item=result.item,itemGroups=["comments","notes","learnings","files","tests","docs","reminders","events"],resultGroups=["body","children","claim_state","linked","schedule"],materialGroups=MATERIAL_FIELD_GROUPS_BY_RESULT.get(result),ownerFor=name=>itemGroups.includes(name)||name==="body"||name==="dependency_provenance"?item:result,groups=["body",...itemGroups,...resultGroups.slice(1),...materialGroups?.has("dependency_provenance")?["dependency_provenance"]:[],...materialGroups?.has("blockers")||Object.hasOwn(result,"blockers")?["blockers"]:[],...[...materialGroups??[]].filter(name=>splitNestedGetGroup(name)!==void 0)].filter(name=>materialGroups===void 0||materialGroups.has(name)||Object.hasOwn(ownerFor(name),name)).map(name=>({name,restore_with:name==="blockers"?"--full":name==="dependency_provenance"?"--fields dependencies":`--fields ${name}`}));return createOutputOmissionReceipt(groups,new Set(groups.flatMap(({name})=>isGetFieldGroupIncluded(name,ownerFor(name),result)?[name]:[])))}function resolveListOrSearchReceipt(result){if(isRecord(result.projection))return createOutputOmissionReceipt([{name:"full_item_fields",restore_with:"--full"}],new Set(result.projection.mode==="full"?["full_item_fields"]:[]))}function resolveHealthReceipt(result){if(!isRecord(result.projection))return createOutputOmissionReceipt([]);if(typeof result.projection.mode=="string")return createOutputOmissionReceipt([{name:"full_check_details",restore_with:"--full"}],new Set(result.projection.mode==="full"?["full_check_details"]:[]))}function resolveContractsReceipt(result){if(!(!isRecord(result.selected)||typeof result.selected.summary!="boolean"))return createOutputOmissionReceipt([{name:"full_contract_catalog",restore_with:"--full"}],new Set(result.selected.summary?[]:["full_contract_catalog"]))}function resolveOutputOmissionReceipt(command,result){const declaredReceipt=resolveDeclaredProjectionReceipt(result);if(declaredReceipt!==void 0)return declaredReceipt;const[rootCommand]=command.split(/\s+/u,1);if(rootCommand==="context")return resolveContextReceipt(result);if(rootCommand==="get")return resolveGetReceipt(result);if(rootCommand==="list"||rootCommand.startsWith("list-"))return resolveListOrSearchReceipt(result);if(rootCommand==="search")return resolveListOrSearchReceipt(result)??createOutputOmissionReceipt([{name:"projection_metadata",restore_with:"--full"}]);if(rootCommand==="health")return resolveHealthReceipt(result);if(rootCommand==="contracts")return resolveContractsReceipt(result)}function attachOutputOmissionReceipt(command,result){if(command===void 0||!isRecord(result))return result;const receipt=resolveOutputOmissionReceipt(command,result),declaredRowContract=result.row_contract,rowContract=isReadRowContract(declaredRowContract)?declaredRowContract:resolveReadRowContract(command,result),disclosedResult=rowContract!==void 0?{...result,row_contract:rowContract}:Object.hasOwn(result,"row_contract")?Object.fromEntries(Object.entries(result).filter(([key])=>key!=="row_contract")):result;return isRecord(disclosedResult.omission_receipt)||receipt===void 0?disclosedResult:{...disclosedResult,omission_receipt:receipt}}export{PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS,PM_READ_ROW_CONTRACTS,PM_READ_ROW_JQ_SELECTOR,assertProjectionModeChoice,attachOutputOmissionReceipt,createOutputOmissionReceipt,isReadRowContract,registerOutputMaterialFieldGroups,resolveModePairedOutputOmissionReceipt,resolveOutputOmissionReceipt,resolveReadRowContract};
1
+ import{EXIT_CODE as w}from"../core/shared/constants.js";import{PmCliError as g}from"../core/shared/errors.js";const _=new WeakMap;function U(e,t){_.set(e,new Set(t))}const f='.row_contract.row_keys[] as $key | getpath($key | split(".")) | if type == "array" then .[] else if type == "object" then to_entries[] else empty end end',k={context:{row_keys:["high_level","low_level"],fields:"supported"},get:{row_keys:["children"],fields:"supported"},list:{row_keys:["items"],fields:"supported"},next:{row_keys:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],fields:"unsupported"},search:{row_keys:["items"],fields:"supported"},activity:{row_keys:["activity_digest","compact_activity","provenance_activity","activity"],fields:"unsupported"},history:{row_keys:["compact_history","provenance_history","history","diff"],fields:"unsupported"},deps:{row_keys:["graph.nodes","graph.edges","context.nodes","context.edges"],fields:"unsupported"},health:{row_keys:["checks"],fields:"unsupported"},aggregate:{row_keys:["groups"],fields:"unsupported"},duplicates:{row_keys:["clusters"],fields:"unsupported"},stats:{row_keys:["by_type","by_status"],fields:"unsupported"},comments:{row_keys:["comments"],fields:"unsupported"},notes:{row_keys:["notes"],fields:"unsupported"},learnings:{row_keys:["learnings"],fields:"unsupported"},files:{row_keys:["files"],fields:"unsupported"},docs:{row_keys:["docs"],fields:"unsupported"},validate:{row_keys:["checks","warnings"],fields:"unsupported"},contracts:{row_keys:["command_summaries","commands"],fields:"unsupported"}},O=[{command:"activity",complete_mode:"full",omissions_by_mode:{digest:[{name:"event_rows",restore_with:"--raw"}],compact:[{name:"provenance",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}},{command:"history",complete_mode:"full",omissions_by_mode:{compact:[{name:"raw_history",restore_with:"--full"}],provenance:[{name:"patch_and_hashes",restore_with:"--full"}]}}];function W(e,t,n){if(e&&t)throw new g(`${n} cannot be combined with --full`,w.USAGE)}function a(e,t=new Set){const n=e.filter(o=>!t.has(o.name)).map(o=>({...o}));return{has_omissions:n.length>0,omitted_field_group_count:n.length,omitted_field_groups:n}}function F(e,t){const n=O.find(s=>s.command===e);if(n===void 0)throw new TypeError(`Unknown mode-paired output command: ${e}`);if(t===n.complete_mode)return a([]);const o=n.omissions_by_mode[t];if(o===void 0)throw new TypeError(`Unknown ${e} output mode: ${t}`);return a(o)}const b=[{name:"hierarchy",restore_with:"--section hierarchy"},{name:"activity",restore_with:"--section activity"},{name:"progress",restore_with:"--section progress"},{name:"blockers",restore_with:"--section blockers"},{name:"recently_created",restore_with:"--section recently_created"},{name:"unparented",restore_with:"--section unparented"},{name:"files",restore_with:"--section files"},{name:"workload",restore_with:"--section workload"},{name:"staleness",restore_with:"--section staleness"},{name:"tests",restore_with:"--section tests"}];function c(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const R=new Set([void 0,"tabular_when_uniform"]),j=new Set(["collection","none"]),E=new Set(["supported","unsupported"]);function u(e,t){return Array.isArray(e)&&(t||e.length>0)&&e.every(n=>typeof n=="string"&&n.length>0)&&new Set(e).size===e.length}function A(e){return c(e)&&typeof e.command=="string"&&e.command.trim().length>0&&j.has(e.row_kind)&&u(e.row_keys,!0)&&(e.continuation_row_keys===void 0||u(e.continuation_row_keys,!1))&&E.has(e.fields)&&R.has(e.toon_encoding)&&(e.row_kind==="collection"?e.row_keys.length>0&&typeof e.jq_selector=="string"&&e.jq_selector.trim().length>0:e.row_keys.length===0&&e.jq_selector===void 0)}const S={ancestors:["ids"],descendants:["ids"],predecessors:["ids"],successors:["ids"],paths:["paths"],impact:["affected"],audit:["findings"],communities:["communities"],redundancy:["redundant"],dominators:["bottlenecks"],slack:["rows"],centrality:["rows"],articulation:["articulation_points","bridges"],plan:["steps"]},v={context:["sections_included","high_level","low_level"],get:["item"],list:["items","projection"],next:["recommended","ready","decision_needed","gate_needed","containers","blocked","held_by_others"],search:["items","projection"],activity:["activity_digest","compact_activity","provenance_activity","activity"],history:["compact_history","provenance_history","history","diff"],deps:["tree","graph","projection"],health:["checks"],aggregate:["groups"],duplicates:["clusters"],stats:["totals","by_type","by_status"],comments:["comments"],notes:["notes"],learnings:["learnings"],files:["files"],docs:["docs"],validate:["checks","warnings"],contracts:["command_summaries","commands","selected"]};function C(e,t){const n=e.trim().toLowerCase().split(/\s+/u,1)[0],o=n?.startsWith("list-")?"list":n;if(o==="graph"){const r=typeof t.subcommand=="string"?t.subcommand:"";if(r.length===0)return;const i=S[r];if(i===void 0)return;const l=i.filter(p=>Array.isArray(t[p])||c(t[p]));return{command:"graph",row_kind:l.length>0?"collection":"none",row_keys:l,fields:"unsupported",...l.length>0?{jq_selector:f}:{},toon_encoding:"tabular_when_uniform"}}const s=k[o],d=v[o];return s===void 0||d===void 0||!d.some(r=>Object.hasOwn(t,r))?void 0:(()=>{const r=s.row_keys.filter(i=>{const l=i.split(".").reduce((p,y)=>c(p)?p[y]:void 0,t);return Array.isArray(l)||c(l)});return{command:o,row_kind:r.length>0?"collection":"none",row_keys:r,fields:s.fields,...r.length>0?{jq_selector:f}:{},toon_encoding:"tabular_when_uniform"}})()}function x(e){if(!c(e.projection)||typeof e.projection.mode!="string"||e.projection.mode.trim().length===0)return;const t=e.projection.declared_field_groups,n=e.projection.included_field_groups;if(!Array.isArray(t)||!Array.isArray(n))return;const o=t.filter(r=>c(r)&&typeof r.name=="string"&&r.name.trim().length>0&&typeof r.restore_with=="string"&&r.restore_with.trim().length>0),s=n.filter(r=>typeof r=="string");if(o.length!==t.length||s.length!==n.length)return;const d=new Set(o.map(r=>r.name));if(!(d.size!==o.length||new Set(s).size!==s.length||s.some(r=>!d.has(r))))return a(o,new Set(s))}function T(e){if(!Array.isArray(e.sections_included))return;const t=a(b,new Set(e.sections_included.filter(n=>typeof n=="string")));return c(e.summary)&&e.summary.scope==="matching_items"&&(t.summary_scope="matching_items"),t}function D(e,t,n){if(e==="dependency_provenance")return!1;const o=m(e);if(o!==void 0){const s=n[o.facet];return c(s)&&Object.hasOwn(s,o.member)}return Object.hasOwn(t,e)||(e==="reminders"||e==="events")&&c(n.schedule)&&Object.hasOwn(n.schedule,e)||["files","tests","docs"].includes(e)&&c(n.linked)&&Array.isArray(n.linked[e])&&n.linked[e].length>0}function m(e){const t=e.indexOf(".");return t===-1?void 0:{facet:e.slice(0,t),member:e.slice(t+1)}}function G(e){if(!c(e.item))return;const t=e.item,n=["comments","notes","learnings","files","tests","docs","reminders","events"],o=["body","children","claim_state","linked","schedule"],s=_.get(e),d=i=>n.includes(i)||i==="body"||i==="dependency_provenance"?t:e,r=["body",...n,...o.slice(1),...s?.has("dependency_provenance")?["dependency_provenance"]:[],...s?.has("blockers")||Object.hasOwn(e,"blockers")?["blockers"]:[],...[...s??[]].filter(i=>m(i)!==void 0)].filter(i=>s===void 0||s.has(i)||Object.hasOwn(d(i),i)).map(i=>({name:i,restore_with:i==="blockers"?"--full":i==="dependency_provenance"?"--fields dependencies":`--fields ${i}`}));return a(r,new Set(r.flatMap(({name:i})=>D(i,d(i),e)?[i]:[])))}function h(e){if(c(e.projection))return a([{name:"full_item_fields",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_item_fields"]:[]))}function N(e){if(!c(e.projection))return a([]);if(typeof e.projection.mode=="string")return a([{name:"full_check_details",restore_with:"--full"}],new Set(e.projection.mode==="full"?["full_check_details"]:[]))}function P(e){if(!(!c(e.selected)||typeof e.selected.summary!="boolean"))return a([{name:"full_contract_catalog",restore_with:"--full"}],new Set(e.selected.summary?[]:["full_contract_catalog"]))}function I(e,t){const n=x(t);if(n!==void 0)return n;const[o]=e.split(/\s+/u,1);if(o==="context")return T(t);if(o==="get")return G(t);if(o==="list"||o.startsWith("list-"))return h(t);if(o==="search")return h(t)??a([{name:"projection_metadata",restore_with:"--full"}]);if(o==="health")return N(t);if(o==="contracts")return P(t)}function K(e,t){if(e===void 0||!c(t))return t;const n=I(e,t),o=t.row_contract,s=A(o)?o:C(e,t),d=s!==void 0?{...t,row_contract:s}:Object.hasOwn(t,"row_contract")?Object.fromEntries(Object.entries(t).filter(([r])=>r!=="row_contract")):t;return c(d.omission_receipt)||n===void 0?d:{...d,omission_receipt:n}}export{O as PM_MODE_PAIRED_OUTPUT_PROJECTION_CONTRACTS,k as PM_READ_ROW_CONTRACTS,f as PM_READ_ROW_JQ_SELECTOR,W as assertProjectionModeChoice,K as attachOutputOmissionReceipt,a as createOutputOmissionReceipt,A as isReadRowContract,U as registerOutputMaterialFieldGroups,F as resolveModePairedOutputOmissionReceipt,I as resolveOutputOmissionReceipt,C as resolveReadRowContract};
2
2
  //# sourceMappingURL=output-projection.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cb1266f3-8375-586f-87c6-356cf7843969")}catch{}})();import{estimatePmOutputTokens}from"./cli-contracts/agent-output-contracts.js";const SECTION_ORDER=["result_rows","envelope","diagnostics","hints"],ROW_KEYS=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,DIAGNOSTIC_KEYS=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,HINT_KEYS=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,MAX_RECEIPT_STABILIZATION_PASSES=8;function utf8Bytes(value){return Buffer.byteLength(value,"utf8")}function canonicalJsonBytes(value){return utf8Bytes(JSON.stringify(value)??"null")}function sectionForEntry(key,value){return DIAGNOSTIC_KEYS.test(key)?"diagnostics":HINT_KEYS.test(key)?"hints":ROW_KEYS.test(key)||Array.isArray(value)?"result_rows":"envelope"}function collectSectionWeights(result){const weights={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof result!="object"||result===null||Array.isArray(result))return weights[Array.isArray(result)?"result_rows":"envelope"]=canonicalJsonBytes(result),weights;for(const[key,value]of Object.entries(result))weights[sectionForEntry(key,value)]+=canonicalJsonBytes({[key]:value});return Object.values(weights).every(weight=>weight===0)&&(weights.envelope=1),weights}function allocateExactBytes(totalBytes,weights){const weightTotal=SECTION_ORDER.reduce((total,section)=>total+weights[section],0),exact=SECTION_ORDER.map(section=>({section,value:totalBytes*weights[section]/weightTotal})),allocated={result_rows:0,envelope:0,diagnostics:0,hints:0};for(const entry of exact)allocated[entry.section]=Math.floor(entry.value);let remainder=totalBytes-SECTION_ORDER.reduce((total,section)=>total+allocated[section],0);for(const entry of[...exact].sort((left,right)=>right.value-Math.floor(right.value)-(left.value-Math.floor(left.value))||SECTION_ORDER.indexOf(left.section)-SECTION_ORDER.indexOf(right.section))){if(remainder===0)break;allocated[entry.section]+=1,remainder-=1}return allocated}function attachReceipt(result,receipt){return typeof result=="object"&&result!==null&&!Array.isArray(result)?{...result,token_accounting:receipt}:{result,token_accounting:receipt}}function attachOutputTokenAccounting(result,render){const originalBytes=utf8Bytes(render(result)),allocatedBytes=allocateExactBytes(originalBytes,collectSectionWeights(result)),sections=Object.fromEntries(SECTION_ORDER.map(section=>[section,{bytes:allocatedBytes[section],estimated_tokens:estimatePmOutputTokens(allocatedBytes[section])}]));let receipt={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:originalBytes,total_estimated_tokens:estimatePmOutputTokens(originalBytes),sections,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},accounted=attachReceipt(result,receipt);for(let pass=0;pass<MAX_RECEIPT_STABILIZATION_PASSES;pass+=1){const measuredReceiptBytes=utf8Bytes(render(accounted))-originalBytes;if(measuredReceiptBytes===receipt.accounting_receipt_bytes)return accounted;receipt={...receipt,accounting_receipt_bytes:measuredReceiptBytes,accounting_receipt_estimated_tokens:estimatePmOutputTokens(measuredReceiptBytes)},accounted=attachReceipt(result,receipt)}return accounted}export{attachOutputTokenAccounting};
1
+ import{estimatePmOutputTokens as l}from"./cli-contracts/agent-output-contracts.js";const u=["result_rows","envelope","diagnostics","hints"],p=/^(?:items|results|rows|ready|blocked|recommended|decision_needed|children|dependencies|events|matches|commands|tools)$/u,y=/^(?:diagnostics|errors?|warnings?|findings|violations|failures?)$/u,m=/^(?:hints?|suggestions?|next_steps?|recovery|remediation|examples?)$/u,g=8;function _(e){return Buffer.byteLength(e,"utf8")}function f(e){return _(JSON.stringify(e)??"null")}function v(e,t){return y.test(e)?"diagnostics":m.test(e)?"hints":p.test(e)||Array.isArray(t)?"result_rows":"envelope"}function b(e){const t={result_rows:0,envelope:0,diagnostics:0,hints:0};if(typeof e!="object"||e===null||Array.isArray(e))return t[Array.isArray(e)?"result_rows":"envelope"]=f(e),t;for(const[s,c]of Object.entries(e))t[v(s,c)]+=f({[s]:c});return Object.values(t).every(s=>s===0)&&(t.envelope=1),t}function A(e,t){const s=u.reduce((n,o)=>n+t[o],0),c=u.map(n=>({section:n,value:e*t[n]/s})),a={result_rows:0,envelope:0,diagnostics:0,hints:0};for(const n of c)a[n.section]=Math.floor(n.value);let i=e-u.reduce((n,o)=>n+a[o],0);for(const n of[...c].sort((o,r)=>r.value-Math.floor(r.value)-(o.value-Math.floor(o.value))||u.indexOf(o.section)-u.indexOf(r.section))){if(i===0)break;a[n.section]+=1,i-=1}return a}function d(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)?{...e,token_accounting:t}:{result:e,token_accounting:t}}function O(e,t){const s=_(t(e)),c=A(s,b(e)),a=Object.fromEntries(u.map(o=>[o,{bytes:c[o],estimated_tokens:l(c[o])}]));let i={version:1,measurement_scope:"output_before_token_accounting",estimator:"ceil(utf8_bytes / 4)",total_bytes:s,total_estimated_tokens:l(s),sections:a,accounting_receipt_bytes:0,accounting_receipt_estimated_tokens:0,excluded_fields:["token_accounting"],section_allocation:"proportional_canonical_json"},n=d(e,i);for(let o=0;o<g;o+=1){const r=_(t(n))-s;if(r===i.accounting_receipt_bytes)return n;i={...i,accounting_receipt_bytes:r,accounting_receipt_estimated_tokens:l(r)},n=d(e,i)}return n}export{O as attachOutputTokenAccounting};
2
2
  //# sourceMappingURL=output-token-accounting.js.map
@@ -1,3 +1,3 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e6c590de-c83e-59ca-9fdb-9a68cc88d545")}catch{}})();import{SUPPRESS_HOST_OUTPUT_MARKER,isHostOutputSuppressed,suppressHostOutput}from"../core/output/output-control.js";import{encodePmTableRows,decodePmTableRows}from"./output/table-rows.js";import{projectPmBriefListEnvelope,projectPmBriefSearchEnvelope}from"./output/list-envelope.js";import{assertWellFormedOutputText,toWellFormedText}from"../core/shared/output-unicode.js";function serializeNdjsonRows(rows){return rows.map((row,index)=>{if(typeof row!="object"||row===null||Array.isArray(row))throw new TypeError(`NDJSON row ${index} must be a non-null object.`);const serialized=JSON.stringify(row);if(serialized===void 0)throw new TypeError(`NDJSON row ${index} must serialize to a non-null object.`);const projected=JSON.parse(serialized);if(typeof projected!="object"||projected===null||Array.isArray(projected))throw new TypeError(`NDJSON row ${index} must serialize to a non-null object.`);return serialized}).join(`
2
- `)}function serializeNdjsonStream(rows,trailer){if(trailer.count!==rows.length)throw new TypeError(`NDJSON trailer count ${trailer.count} does not match ${rows.length} ${rows.length===1?"row":"rows"}.`);for(const[index,row]of rows.entries())if(typeof row=="object"&&row!==null&&!Array.isArray(row)&&Reflect.get(row,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${index} uses reserved record_type pm.stream.trailer`);return serializeNdjsonRows([...rows,{...trailer,record_type:"pm.stream.trailer"}])}export{SUPPRESS_HOST_OUTPUT_MARKER,assertWellFormedOutputText,decodePmTableRows,encodePmTableRows,isHostOutputSuppressed,projectPmBriefListEnvelope,projectPmBriefSearchEnvelope,serializeNdjsonRows,serializeNdjsonStream,suppressHostOutput,toWellFormedText};
1
+ import{SUPPRESS_HOST_OUTPUT_MARKER as a,isHostOutputSuppressed as u,suppressHostOutput as c}from"../core/output/output-control.js";import{encodePmTableRows as f,decodePmTableRows as y}from"./output/table-rows.js";import{projectPmBriefListEnvelope as N,projectPmBriefSearchEnvelope as S}from"./output/list-envelope.js";import{assertWellFormedOutputText as j,toWellFormedText as O}from"../core/shared/output-unicode.js";function s(t){return t.map((e,o)=>{if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError(`NDJSON row ${o} must be a non-null object.`);const r=JSON.stringify(e);if(r===void 0)throw new TypeError(`NDJSON row ${o} must serialize to a non-null object.`);const n=JSON.parse(r);if(typeof n!="object"||n===null||Array.isArray(n))throw new TypeError(`NDJSON row ${o} must serialize to a non-null object.`);return r}).join(`
2
+ `)}function p(t,e){if(e.count!==t.length)throw new TypeError(`NDJSON trailer count ${e.count} does not match ${t.length} ${t.length===1?"row":"rows"}.`);for(const[o,r]of t.entries())if(typeof r=="object"&&r!==null&&!Array.isArray(r)&&Reflect.get(r,"record_type")==="pm.stream.trailer")throw new TypeError(`NDJSON row ${o} uses reserved record_type pm.stream.trailer`);return s([...t,{...e,record_type:"pm.stream.trailer"}])}export{a as SUPPRESS_HOST_OUTPUT_MARKER,j as assertWellFormedOutputText,y as decodePmTableRows,f as encodePmTableRows,u as isHostOutputSuppressed,N as projectPmBriefListEnvelope,S as projectPmBriefSearchEnvelope,s as serializeNdjsonRows,p as serializeNdjsonStream,c as suppressHostOutput,O as toWellFormedText};
3
3
  //# sourceMappingURL=output.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="498066a6-7936-539a-9da1-e3fe53197ae3")}catch{}})();import{readHistoryEntries}from"../core/history/read.js";import{getWorkspaceHistoryPath,WORKSPACE_HISTORY_ID}from"../core/history/workspace-history.js";import{redactIdentityCredentials}from"../core/shared/url-credentials.js";import{getHistoryPath}from"../core/store/paths.js";import{STALE_WORK_THRESHOLD_SETTING,isJudgeableHistoryRecord,isWellFormedHistoryRecord,latestHistoryTimestamp,normalizeStaleWorkThresholdHours,recordedBaselineActivity,resolveLastActivityAt,staleEligibleAt,unprovenClaimActivity,wholeHoursSince}from"./governance/stale-work.js";function evaluateClaimActivity(claimedAt,latestHistoryAt,options){const nowMs=(options.now??new Date).getTime(),thresholdHours=normalizeStaleWorkThresholdHours(options.threshold_hours),lastActivityAt=resolveLastActivityAt(options.updated_at,latestHistoryAt)??null,validClaimedAt=claimedAt!==null&&Number.isFinite(Date.parse(claimedAt))?claimedAt:null,idleHours=lastActivityAt===null?null:wholeHoursSince(lastActivityAt,nowMs),judgeable=lastActivityAt!==null&&options.history_unreadable!==!0&&options.unproven_activity===void 0;return{last_activity_at:lastActivityAt,...options.history_unreadable===!0?{history_unreadable:!0}:{},...options.unproven_activity===void 0?{}:{unproven_activity:options.unproven_activity},claim_age_hours:validClaimedAt===null?null:wholeHoursSince(validClaimedAt,nowMs),idle_hours:idleHours,stale_policy:{setting:STALE_WORK_THRESHOLD_SETTING,threshold_hours:thresholdHours,stale:judgeable&&idleHours>=thresholdHours,eligible_at:judgeable?staleEligibleAt(lastActivityAt,thresholdHours):null}}}function classifyOwnershipSource(operation){return operation===void 0?"unknown":operation==="claim"?"claim":"assignment"}const ASSIGNEE_PATH="/metadata/assignee",CLAIM_PRINCIPAL_PATH="/metadata/claim_principal";function changesOwnership(entry){return entry.patch.some(operation=>operation.path===ASSIGNEE_PATH||entry.op==="claim"&&operation.path===CLAIM_PRINCIPAL_PATH)}function holderNamedAt(history,index){for(let position=index;position>=0;position-=1){const operation=history[position].patch.find(candidate=>candidate.path===ASSIGNEE_PATH);if(operation!==void 0)return typeof operation.value=="string"?operation.value.trim():void 0}}async function readOwnershipEvidence(pmRoot,itemId,assignee){let readable=!0;const history=await Promise.resolve().then(()=>readHistoryEntries(getHistoryPath(pmRoot,itemId),itemId)).then(entries=>entries.every(isJudgeableHistoryRecord)?entries:(readable=!1,[])).catch(()=>(readable=!1,[]));let latestOwnershipIndex=history.length-1;for(;latestOwnershipIndex>=0&&!changesOwnership(history[latestOwnershipIndex]);)latestOwnershipIndex-=1;const latestOwnershipEntry=history[latestOwnershipIndex],evidence=holderNamedAt(history,latestOwnershipIndex)===assignee.trim()?latestOwnershipEntry:void 0,source=classifyOwnershipSource(evidence?.op),holder=redactIdentityCredentials(assignee);return{conflict:{phrase:source==="claim"?`claimed by ${holder}`:`assigned to ${holder}`,holder,source,since:evidence?.ts??null},history,readable,unproven:readable?unprovenClaimActivity(history,evidence===void 0?-1:latestOwnershipIndex):void 0}}function atOrAfter(timestamp,claimedMs){const ms=Date.parse(timestamp);return!Number.isFinite(ms)||ms>=claimedMs}const WORKSPACE_EVIDENCE_REWRITES=new Set(["history_salvage","history_repair","history_redact","merge_reconcile"]);async function workspaceRestoredSince(pmRoot,claimedAt){let entries;try{entries=await readHistoryEntries(getWorkspaceHistoryPath(pmRoot),WORKSPACE_HISTORY_ID)}catch{return!0}const claimedMs=Date.parse(claimedAt);return entries.some(entry=>{if(!isWellFormedHistoryRecord(entry))return!0;if(entry.op==="workspace_snapshot_restore"||WORKSPACE_EVIDENCE_REWRITES.has(entry.op))return atOrAfter(entry.ts,claimedMs);if(entry.op!=="history_compact_baseline")return!1;const bound=recordedBaselineActivity(entry);return bound===void 0||atOrAfter(entry.ts,claimedMs)||bound!==null&&atOrAfter(bound,claimedMs)})}async function resolveItemOwnershipConflict(pmRoot,itemId,assignee){return(await readOwnershipEvidence(pmRoot,itemId,assignee)).conflict}async function resolveItemOwnershipActivity(pmRoot,itemId,assignee,options){const{conflict,history,readable,unproven}=await readOwnershipEvidence(pmRoot,itemId,assignee),judge=reason=>evaluateClaimActivity(conflict.since,latestHistoryTimestamp(history),{...options,...readable?{}:{history_unreadable:!0},...reason===void 0?{}:{unproven_activity:reason}}),activity=judge(unproven);return!activity.stale_policy.stale||!await workspaceRestoredSince(pmRoot,conflict.since)?{...conflict,activity}:{...conflict,activity:judge("workspace_restored")}}async function describeItemOwnershipConflict(pmRoot,itemId,assignee){return(await resolveItemOwnershipConflict(pmRoot,itemId,assignee)).phrase}export{describeItemOwnershipConflict,evaluateClaimActivity,resolveItemOwnershipActivity,resolveItemOwnershipConflict};
1
+ import{readHistoryEntries as h}from"../core/history/read.js";import{getWorkspaceHistoryPath as m,WORKSPACE_HISTORY_ID as y}from"../core/history/workspace-history.js";import{redactIdentityCredentials as v}from"../core/shared/url-credentials.js";import{getHistoryPath as w}from"../core/store/paths.js";import{STALE_WORK_THRESHOLD_SETTING as A,isJudgeableHistoryRecord as g,isWellFormedHistoryRecord as b,latestHistoryTimestamp as E,normalizeStaleWorkThresholdHours as H,recordedBaselineActivity as O,resolveLastActivityAt as S,staleEligibleAt as I,unprovenClaimActivity as C,wholeHoursSince as f}from"./governance/stale-work.js";function T(r,n,e){const a=(e.now??new Date).getTime(),t=H(e.threshold_hours),i=S(e.updated_at,n)??null,c=r!==null&&Number.isFinite(Date.parse(r))?r:null,s=i===null?null:f(i,a),o=i!==null&&e.history_unreadable!==!0&&e.unproven_activity===void 0;return{last_activity_at:i,...e.history_unreadable===!0?{history_unreadable:!0}:{},...e.unproven_activity===void 0?{}:{unproven_activity:e.unproven_activity},claim_age_hours:c===null?null:f(c,a),idle_hours:s,stale_policy:{setting:A,threshold_hours:t,stale:o&&s>=t,eligible_at:o?I(i,t):null}}}function R(r){return r===void 0?"unknown":r==="claim"?"claim":"assignment"}const p="/metadata/assignee",P="/metadata/claim_principal";function D(r){return r.patch.some(n=>n.path===p||r.op==="claim"&&n.path===P)}function N(r,n){for(let e=n;e>=0;e-=1){const a=r[e].patch.find(t=>t.path===p);if(a!==void 0)return typeof a.value=="string"?a.value.trim():void 0}}async function _(r,n,e){let a=!0;const t=await Promise.resolve().then(()=>h(w(r,n),n)).then(u=>u.every(g)?u:(a=!1,[])).catch(()=>(a=!1,[]));let i=t.length-1;for(;i>=0&&!D(t[i]);)i-=1;const c=t[i],s=N(t,i)===e.trim()?c:void 0,o=R(s?.op),l=v(e);return{conflict:{phrase:o==="claim"?`claimed by ${l}`:`assigned to ${l}`,holder:l,source:o,since:s?.ts??null},history:t,readable:a,unproven:a?C(t,s===void 0?-1:i):void 0}}function d(r,n){const e=Date.parse(r);return!Number.isFinite(e)||e>=n}const W=new Set(["history_salvage","history_repair","history_redact","merge_reconcile"]);async function k(r,n){let e;try{e=await h(m(r),y)}catch{return!0}const a=Date.parse(n);return e.some(t=>{if(!b(t))return!0;if(t.op==="workspace_snapshot_restore"||W.has(t.op))return d(t.ts,a);if(t.op!=="history_compact_baseline")return!1;const i=O(t);return i===void 0||d(t.ts,a)||i!==null&&d(i,a)})}async function x(r,n,e){return(await _(r,n,e)).conflict}async function G(r,n,e,a){const{conflict:t,history:i,readable:c,unproven:s}=await _(r,n,e),o=u=>T(t.since,E(i),{...a,...c?{}:{history_unreadable:!0},...u===void 0?{}:{unproven_activity:u}}),l=o(s);return!l.stale_policy.stale||!await k(r,t.since)?{...t,activity:l}:{...t,activity:o("workspace_restored")}}async function $(r,n,e){return(await x(r,n,e)).phrase}export{$ as describeItemOwnershipConflict,T as evaluateClaimActivity,G as resolveItemOwnershipActivity,x as resolveItemOwnershipConflict};
2
2
  //# sourceMappingURL=ownership-source.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="22c58419-a041-5176-a3e1-d8786eb5f994")}catch{}})();import{appendHistoryEntry,createHistoryEntry}from"../core/history/history.js";import{acquireLockLease}from"../core/lock/lock.js";import{enforceWorkflowMutation}from"../core/policy/workflow-policy-store.js";import{parseTags}from"../core/item/parse.js";import{normalizeStatusInput}from"../core/item/status.js";import{canonicalDocument,serializeItemDocument}from"../core/item/item-format.js";import{deferrableItemFieldByKey,normalizeDeferredFields,pruneResolvedDeferredFields}from"../core/item/deferred-fields.js";import{getHistoryPath}from"../core/store/paths.js";import{removeFileIfExists,writeFileAtomic}from"../core/fs/fs-utils.js";import{getActiveExtensionRegistrations,runActiveBeforeMutationHooks,runActiveOnWriteHooks}from"../core/extensions/index.js";import{createMutationGuardSdk,locateItem}from"../core/store/item-store.js";import{resolveItemTypeRegistry}from"../core/item/type-registry.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{assertInitializedTracker}from"./environment/tracker-preflight.js";import{stampRequiredItemFormat}from"./environment/project-runtime-compatibility.js";function toNonEmptyImportString(value){if(typeof value!="string")return;const trimmed=value.trim();return trimmed.length>0?trimmed:void 0}function toEstimatedMinutesValue(value){if(typeof value=="number"&&Number.isFinite(value)&&value>=0)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isFinite(parsed)&&parsed>=0)return parsed}}function toImportPriority(value){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=4)return value;if(typeof value=="string"&&value.trim().length>0){const parsed=Number(value);if(Number.isInteger(parsed)&&parsed>=0&&parsed<=4)return parsed}return 2}function toImportTags(value){if(Array.isArray(value)){const tags=value.filter(entry=>typeof entry=="string").map(entry=>entry.trim().toLowerCase()).filter(entry=>entry.length>0);return Array.from(new Set(tags)).sort((left,right)=>left.localeCompare(right))}return typeof value=="string"?parseTags(value):[]}function toImportStatus(value){const normalized=toNonEmptyImportString(value);if(normalized){const canonical=normalizeStatusInput(normalized);if(canonical)return canonical}return"open"}function toImportInteger(value){if(typeof value=="number"&&Number.isInteger(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isInteger(parsed)?parsed:void 0}function toImportBoolean(value){if(typeof value=="boolean")return value;if(typeof value=="number")return value===1?!0:value===0?!1:void 0;if(typeof value!="string")return;const normalized=value.trim().toLowerCase();return normalized==="true"||normalized==="1"?!0:normalized==="false"||normalized==="0"?!1:void 0}function toImportStringList(value){if(!Array.isArray(value))return;const entries=value.map(entry=>toNonEmptyImportString(entry)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportStringMap(value){return toImportValueMap(value,toNonEmptyImportString)}function toImportNumberMap(value){return toImportValueMap(value,toImportFiniteNumber)}function toImportConfidence(value,allowedTextValues){if(typeof value=="number"&&Number.isInteger(value)&&value>=0&&value<=100)return value;const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;if(allowedTextValues.some(entry=>entry===candidate))return candidate;const parsed=Number(candidate);return Number.isInteger(parsed)&&parsed>=0&&parsed<=100?parsed:void 0}function toImportNormalizedEnum(value,allowed){const normalized=toNonEmptyImportString(value)?.toLowerCase();if(!normalized)return;const candidate=normalized==="med"?"medium":normalized;return allowed.includes(candidate)?candidate:void 0}function toImportLinkScope(value){return toNonEmptyImportString(value)?.toLowerCase()==="global"?"global":"project"}function toImportLogEntries(value,options){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLogEntry(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedFiles(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportLinkedDocs(value,options={}){return toImportLinkedArtifacts(value,options,(pathValue,record)=>({path:pathValue,scope:toImportLinkScope(record?.scope),note:toNonEmptyImportString(record?.note)}))}function toImportDeferredFields(value){const entries=(Array.isArray(value)?value:[]).filter(entry=>typeof entry=="object"&&entry!==null&&!Array.isArray(entry)&&typeof entry.field=="string"&&deferrableItemFieldByKey(entry.field)!==void 0&&typeof entry.reason=="string"&&entry.reason.trim().length>0),byField=new Map(entries.map(entry=>[entry.field,{field:entry.field,reason:entry.reason}]));return normalizeDeferredFields([...byField.values()])}function toImportLinkedTests(value,options={}){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const entries=values.map(entry=>toImportLinkedTest(entry,options)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function selectImportAuthor(explicitAuthor,settingsAuthor){return resolveAuthor(explicitAuthor,settingsAuthor)}function isImportRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function normalizeImportCollection(value,allowScalar){return Array.isArray(value)?value:allowScalar?[value]:void 0}function firstNonEmptyImportString(record,keys){for(const key of keys){const value=toNonEmptyImportString(record[key]);if(value)return value}}function toImportValueMap(value,coerce){if(!isImportRecord(value))return;const entries=Object.entries(value).map(([key,entryValue])=>[key.trim(),coerce(entryValue)]).filter(entry=>entry[0].length>0&&entry[1]!==void 0);return entries.length>0?Object.fromEntries(entries):void 0}function toImportLogEntry(entry,options){if(typeof entry=="string")return toImportLogEntryFromText(entry,options);if(!isImportRecord(entry))return;const text=firstNonEmptyImportString(entry,options.textKeys??["text"]);if(!text)return;const createdAtKey=options.createdAtKey??"created_at",authorKey=options.authorKey??"author";return{created_at:(options.toIsoString?options.toIsoString(entry[createdAtKey]):toNonEmptyImportString(entry[createdAtKey]))??options.fallbackCreatedAt,author:toNonEmptyImportString(entry[authorKey])??options.fallbackAuthor,text}}function toImportLogEntryFromText(entry,options){const text=toNonEmptyImportString(entry);return text?{created_at:options.fallbackCreatedAt,author:options.fallbackAuthor,text}:void 0}function toImportLinkedArtifacts(value,options,build){const values=normalizeImportCollection(value,options.allowScalar===!0);if(!values)return;const pathKeys=options.pathKeys??["path"],entries=values.map(entry=>toImportLinkedArtifact(entry,pathKeys,build)).filter(entry=>entry!==void 0);return entries.length>0?entries:void 0}function toImportLinkedArtifact(entry,pathKeys,build){if(typeof entry=="string"){const pathValue2=toNonEmptyImportString(entry);return pathValue2?build(pathValue2):void 0}if(!isImportRecord(entry))return;const pathValue=firstNonEmptyImportString(entry,pathKeys);return pathValue?build(pathValue,entry):void 0}function toImportLinkedTest(entry,options){if(typeof entry=="string"){const command2=toNonEmptyImportString(entry);return command2?{command:command2,scope:"project"}:void 0}if(!isImportRecord(entry))return;const command=firstNonEmptyImportString(entry,options.commandKeys??["command"]),testPath=firstNonEmptyImportString(entry,options.pathKeys??["path"]);if(!(!command&&(options.requireCommand===!0||!testPath)))return{...command?{command}:{},...testPath?{path:testPath}:{},scope:toImportLinkScope(entry.scope),timeout_seconds:toImportLinkedTestTimeout(entry.timeout_seconds,options),note:toNonEmptyImportString(entry.note),...typeof entry.phase=="string"&&entry.phase.trim().toLowerCase()==="setup"?{phase:"setup"}:{},...options.includeExtendedAssertions===!0?toImportLinkedTestAssertions(entry):{}}}function toImportLinkedTestTimeout(value,options){const parsed=options.integerTimeout===!0?toImportInteger(value):toImportFiniteNumber(value);if(parsed===void 0)return;const minimum=options.timeoutMinimum??0;return options.timeoutExclusiveMinimum===!0?parsed>minimum?parsed:void 0:parsed>=minimum?parsed:void 0}function toImportFiniteNumber(value){if(typeof value=="number"&&Number.isFinite(value))return value;if(typeof value!="string"||value.trim().length===0)return;const parsed=Number(value);return Number.isFinite(parsed)?parsed:void 0}function toImportLinkedTestAssertions(entry){return{pm_context_mode:toImportNormalizedEnum(entry.pm_context_mode,["schema","tracker","auto"]),env_set:toImportStringMap(entry.env_set),env_clear:toImportStringList(entry.env_clear),shared_host_safe:toImportBoolean(entry.shared_host_safe),assert_stdout_contains:toImportStringList(entry.assert_stdout_contains),assert_stdout_regex:toImportStringList(entry.assert_stdout_regex),assert_stderr_contains:toImportStringList(entry.assert_stderr_contains),assert_stderr_regex:toImportStringList(entry.assert_stderr_regex),assert_stdout_min_lines:toImportInteger(entry.assert_stdout_min_lines),assert_json_field_equals:toImportStringMap(entry.assert_json_field_equals),assert_json_field_gte:toImportNumberMap(entry.assert_json_field_gte)}}async function ensureTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function emptyImportedDocument(){return{metadata:{},body:""}}function importedChangedFields(document){return[...Object.entries(document.metadata).filter(([,value])=>value!==void 0).map(([key])=>key),...document.body.length>0?["body"]:[]].sort()}async function commitImportedItem(params){const{pmRoot,id,itemPath,author,message,settings,conflictWarningPrefix}=params,stamped={...params.document,metadata:{...params.document.metadata}};pruneResolvedDeferredFields(stamped.metadata),stampRequiredItemFormat(stamped.metadata,pmRoot);const document=canonicalDocument(stamped),historyPath=getHistoryPath(pmRoot,id),beforeDocument=emptyImportedDocument();let lease;try{lease=await acquireLockLease(pmRoot,id,settings.locks.ttl_seconds,author,!1,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms)}catch(error){if(error instanceof PmCliError&&error.exitCode===EXIT_CODE.CONFLICT)return{committed:!1,conflictWarning:`${conflictWarningPrefix}:${id}`};throw error}try{const typeToFolder=resolveItemTypeRegistry(settings,getActiveExtensionRegistrations()).type_to_folder;if(await locateItem(pmRoot,id,settings.id_prefix,settings.item_format,typeToFolder))return{committed:!1,conflictWarning:`${conflictWarningPrefix}:${id}`};const workflowPolicy=await enforceWorkflowMutation({pmRoot,settings,operation:"import",author,before:null,after:document});return await runActiveBeforeMutationHooks({pm_root:pmRoot,operation:"import",before:null,after:document,changed_fields:importedChangedFields(document),author,sdk:createMutationGuardSdk({pmRoot,settings,typeToFolder})}),await lease.fence(async()=>{await writeFileAtomic(itemPath,serializeItemDocument(document,{format:"toon"}));try{const entry=createHistoryEntry({nowIso:nowIso(),author,op:"import",before:beforeDocument,after:document,message,context:workflowPolicy.decisions.length===0?void 0:{workflow_policies:workflowPolicy.decisions}});await appendHistoryEntry(historyPath,entry)}catch(error){throw await removeFileIfExists(itemPath),error}}),{committed:!0,writeWarnings:[...workflowPolicy.warnings,...await runActiveOnWriteHooks({path:itemPath,scope:"project",op:"import",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]}),...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"import:history",item_id:document.metadata.id,item_type:document.metadata.type,before:beforeDocument,after:document,changed_fields:["imported"]})]}}finally{await lease.release()}}export{commitImportedItem,emptyImportedDocument,ensureTrackerInitialized,selectImportAuthor,toEstimatedMinutesValue,toImportBoolean,toImportConfidence,toImportDeferredFields,toImportInteger,toImportLinkScope,toImportLinkedDocs,toImportLinkedFiles,toImportLinkedTests,toImportLogEntries,toImportNormalizedEnum,toImportNumberMap,toImportPriority,toImportStatus,toImportStringList,toImportStringMap,toImportTags,toNonEmptyImportString};
1
+ import{appendHistoryEntry as F,createHistoryEntry as E}from"../core/history/history.js";import{acquireLockLease as T}from"../core/lock/lock.js";import{enforceWorkflowMutation as S}from"../core/policy/workflow-policy-store.js";import{parseTags as j}from"../core/item/parse.js";import{normalizeStatusInput as z}from"../core/item/status.js";import{canonicalDocument as K,serializeItemDocument as M}from"../core/item/item-format.js";import{deferrableItemFieldByKey as D,normalizeDeferredFields as P,pruneResolvedDeferredFields as W}from"../core/item/deferred-fields.js";import{getHistoryPath as q}from"../core/store/paths.js";import{removeFileIfExists as O,writeFileAtomic as R}from"../core/fs/fs-utils.js";import{getActiveExtensionRegistrations as H,runActiveBeforeMutationHooks as V,runActiveOnWriteHooks as w}from"../core/extensions/index.js";import{createMutationGuardSdk as $,locateItem as B}from"../core/store/item-store.js";import{resolveItemTypeRegistry as G}from"../core/item/type-registry.js";import{EXIT_CODE as X}from"../core/shared/constants.js";import{PmCliError as J}from"../core/shared/errors.js";import{resolveAuthor as Q}from"../core/shared/author.js";import{nowIso as U}from"../core/shared/time.js";import{assertInitializedTracker as Y}from"./environment/tracker-preflight.js";import{stampRequiredItemFormat as Z}from"./environment/project-runtime-compatibility.js";function i(t){if(typeof t!="string")return;const e=t.trim();return e.length>0?e:void 0}function Et(t){if(typeof t=="number"&&Number.isFinite(t)&&t>=0)return t;if(typeof t=="string"&&t.trim().length>0){const e=Number(t);if(Number.isFinite(e)&&e>=0)return e}}function Tt(t){if(typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=4)return t;if(typeof t=="string"&&t.trim().length>0){const e=Number(t);if(Number.isInteger(e)&&e>=0&&e<=4)return e}return 2}function St(t){if(Array.isArray(t)){const e=t.filter(r=>typeof r=="string").map(r=>r.trim().toLowerCase()).filter(r=>r.length>0);return Array.from(new Set(e)).sort((r,n)=>r.localeCompare(n))}return typeof t=="string"?j(t):[]}function jt(t){const e=i(t);if(e){const r=z(e);if(r)return r}return"open"}function A(t){if(typeof t=="number"&&Number.isInteger(t))return t;if(typeof t!="string"||t.trim().length===0)return;const e=Number(t);return Number.isInteger(e)?e:void 0}function v(t){if(typeof t=="boolean")return t;if(typeof t=="number")return t===1?!0:t===0?!1:void 0;if(typeof t!="string")return;const e=t.trim().toLowerCase();return e==="true"||e==="1"?!0:e==="false"||e==="0"?!1:void 0}function m(t){if(!Array.isArray(t))return;const e=t.map(r=>i(r)).filter(r=>r!==void 0);return e.length>0?e:void 0}function k(t){return L(t,i)}function tt(t){return L(t,C)}function zt(t,e){if(typeof t=="number"&&Number.isInteger(t)&&t>=0&&t<=100)return t;const r=i(t)?.toLowerCase();if(!r)return;const n=r==="med"?"medium":r;if(e.some(a=>a===n))return n;const o=Number(n);return Number.isInteger(o)&&o>=0&&o<=100?o:void 0}function et(t,e){const r=i(t)?.toLowerCase();if(!r)return;const n=r==="med"?"medium":r;return e.includes(n)?n:void 0}function I(t){return i(t)?.toLowerCase()==="global"?"global":"project"}function Kt(t,e){const r=b(t,e.allowScalar===!0);if(!r)return;const n=r.map(o=>rt(o,e)).filter(o=>o!==void 0);return n.length>0?n:void 0}function Mt(t,e={}){return N(t,e,(r,n)=>({path:r,scope:I(n?.scope),note:i(n?.note)}))}function Dt(t,e={}){return N(t,e,(r,n)=>({path:r,scope:I(n?.scope),note:i(n?.note)}))}function Pt(t){const e=(Array.isArray(t)?t:[]).filter(n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&typeof n.field=="string"&&D(n.field)!==void 0&&typeof n.reason=="string"&&n.reason.trim().length>0),r=new Map(e.map(n=>[n.field,{field:n.field,reason:n.reason}]));return P([...r.values()])}function Wt(t,e={}){const r=b(t,e.allowScalar===!0);if(!r)return;const n=r.map(o=>it(o,e)).filter(o=>o!==void 0);return n.length>0?n:void 0}function qt(t,e){return Q(t,e)}function u(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function b(t,e){return Array.isArray(t)?t:e?[t]:void 0}function c(t,e){for(const r of e){const n=i(t[r]);if(n)return n}}function L(t,e){if(!u(t))return;const r=Object.entries(t).map(([n,o])=>[n.trim(),e(o)]).filter(n=>n[0].length>0&&n[1]!==void 0);return r.length>0?Object.fromEntries(r):void 0}function rt(t,e){if(typeof t=="string")return nt(t,e);if(!u(t))return;const r=c(t,e.textKeys??["text"]);if(!r)return;const n=e.createdAtKey??"created_at",o=e.authorKey??"author";return{created_at:(e.toIsoString?e.toIsoString(t[n]):i(t[n]))??e.fallbackCreatedAt,author:i(t[o])??e.fallbackAuthor,text:r}}function nt(t,e){const r=i(t);return r?{created_at:e.fallbackCreatedAt,author:e.fallbackAuthor,text:r}:void 0}function N(t,e,r){const n=b(t,e.allowScalar===!0);if(!n)return;const o=e.pathKeys??["path"],a=n.map(s=>ot(s,o,r)).filter(s=>s!==void 0);return a.length>0?a:void 0}function ot(t,e,r){if(typeof t=="string"){const o=i(t);return o?r(o):void 0}if(!u(t))return;const n=c(t,e);return n?r(n,t):void 0}function it(t,e){if(typeof t=="string"){const o=i(t);return o?{command:o,scope:"project"}:void 0}if(!u(t))return;const r=c(t,e.commandKeys??["command"]),n=c(t,e.pathKeys??["path"]);if(!(!r&&(e.requireCommand===!0||!n)))return{...r?{command:r}:{},...n?{path:n}:{},scope:I(t.scope),timeout_seconds:st(t.timeout_seconds,e),note:i(t.note),...typeof t.phase=="string"&&t.phase.trim().toLowerCase()==="setup"?{phase:"setup"}:{},...e.includeExtendedAssertions===!0?ft(t):{}}}function st(t,e){const r=e.integerTimeout===!0?A(t):C(t);if(r===void 0)return;const n=e.timeoutMinimum??0;return e.timeoutExclusiveMinimum===!0?r>n?r:void 0:r>=n?r:void 0}function C(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t!="string"||t.trim().length===0)return;const e=Number(t);return Number.isFinite(e)?e:void 0}function ft(t){return{pm_context_mode:et(t.pm_context_mode,["schema","tracker","auto"]),env_set:k(t.env_set),env_clear:m(t.env_clear),shared_host_safe:v(t.shared_host_safe),assert_stdout_contains:m(t.assert_stdout_contains),assert_stdout_regex:m(t.assert_stdout_regex),assert_stderr_contains:m(t.assert_stderr_contains),assert_stderr_regex:m(t.assert_stderr_regex),assert_stdout_min_lines:A(t.assert_stdout_min_lines),assert_json_field_equals:k(t.assert_json_field_equals),assert_json_field_gte:tt(t.assert_json_field_gte)}}async function Ot(t){await Y(t)}function at(){return{metadata:{},body:""}}function dt(t){return[...Object.entries(t.metadata).filter(([,r])=>r!==void 0).map(([r])=>r),...t.body.length>0?["body"]:[]].sort()}async function Rt(t){const{pmRoot:e,id:r,itemPath:n,author:o,message:a,settings:s,conflictWarningPrefix:y}=t,p={...t.document,metadata:{...t.document.metadata}};W(p.metadata),Z(p.metadata,e);const f=K(p),x=q(e,r),l=at();let g;try{g=await T(e,r,s.locks.ttl_seconds,o,!1,s.governance.force_required_for_stale_lock,s.locks.wait_ms)}catch(d){if(d instanceof J&&d.exitCode===X.CONFLICT)return{committed:!1,conflictWarning:`${y}:${r}`};throw d}try{const d=G(s,H()).type_to_folder;if(await B(e,r,s.id_prefix,s.item_format,d))return{committed:!1,conflictWarning:`${y}:${r}`};const _=await S({pmRoot:e,settings:s,operation:"import",author:o,before:null,after:f});return await V({pm_root:e,operation:"import",before:null,after:f,changed_fields:dt(f),author:o,sdk:$({pmRoot:e,settings:s,typeToFolder:d})}),await g.fence(async()=>{await R(n,M(f,{format:"toon"}));try{const h=E({nowIso:U(),author:o,op:"import",before:l,after:f,message:a,context:_.decisions.length===0?void 0:{workflow_policies:_.decisions}});await F(x,h)}catch(h){throw await O(n),h}}),{committed:!0,writeWarnings:[..._.warnings,...await w({path:n,scope:"project",op:"import",item_id:f.metadata.id,item_type:f.metadata.type,before:l,after:f,changed_fields:["imported"]}),...await w({path:x,scope:"project",op:"import:history",item_id:f.metadata.id,item_type:f.metadata.type,before:l,after:f,changed_fields:["imported"]})]}}finally{await g.release()}}export{Rt as commitImportedItem,at as emptyImportedDocument,Ot as ensureTrackerInitialized,qt as selectImportAuthor,Et as toEstimatedMinutesValue,v as toImportBoolean,zt as toImportConfidence,Pt as toImportDeferredFields,A as toImportInteger,I as toImportLinkScope,Dt as toImportLinkedDocs,Mt as toImportLinkedFiles,Wt as toImportLinkedTests,Kt as toImportLogEntries,et as toImportNormalizedEnum,tt as toImportNumberMap,Tt as toImportPriority,jt as toImportStatus,m as toImportStringList,k as toImportStringMap,St as toImportTags,i as toNonEmptyImportString};
2
2
  //# sourceMappingURL=package-import-adapters.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="68ca9ab1-91e0-5020-859e-fc1f1f6dcc56")}catch{}})();import{PmClient}from"./runtime.js";function extensionMigrate(options={},clientOptions={}){return new PmClient(clientOptions).extension(void 0,{...options,migrate:!0})}function packageMigrate(options={},clientOptions={}){return new PmClient(clientOptions).packageMigrate(options)}export{extensionMigrate,packageMigrate};
1
+ import{PmClient as t}from"./runtime.js";function i(e={},n={}){return new t(n).extension(void 0,{...e,migrate:!0})}function a(e={},n={}){return new t(n).packageMigrate(e)}export{i as extensionMigrate,a as packageMigrate};
2
2
  //# sourceMappingURL=package-migrations.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ba66cac9-25d6-559e-95d1-71db5c404807")}catch{}})();const BOOLEAN_TRUE_VALUES=new Set(["true","1","yes","on"]),BOOLEAN_FALSE_VALUES=new Set(["false","0","no","off"]);function readStringOption(options,key,aliases=[]){const keys=[key,...aliases];for(const candidate of keys){const value=options[candidate];if(typeof value=="string"&&value.trim().length>0)return value.trim()}}function readBooleanOption(options,key,aliases=[]){const keys=[key,...aliases];for(const candidate of keys){const value=options[candidate];if(value!==void 0){if(typeof value=="boolean")return value;if(typeof value=="string"){const normalized=value.trim().toLowerCase();if(BOOLEAN_TRUE_VALUES.has(normalized))return!0;if(BOOLEAN_FALSE_VALUES.has(normalized))return!1}}}}function readCsvListOption(options,key,aliases=[]){for(const candidate of[key,...aliases]){const value=options[candidate],normalized=(typeof value=="string"?value.split(","):Array.isArray(value)?value.flatMap(entry=>typeof entry=="string"?entry.split(","):[]):[]).map(entry=>entry.trim()).filter(entry=>entry.length>0);if(normalized.length>0)return normalized}return[]}export{readBooleanOption,readCsvListOption,readStringOption};
1
+ const a=new Set(["true","1","yes","on"]),c=new Set(["false","0","no","off"]);function u(o,r,i=[]){const s=[r,...i];for(const n of s){const t=o[n];if(typeof t=="string"&&t.trim().length>0)return t.trim()}}function d(o,r,i=[]){const s=[r,...i];for(const n of s){const t=o[n];if(t!==void 0){if(typeof t=="boolean")return t;if(typeof t=="string"){const f=t.trim().toLowerCase();if(a.has(f))return!0;if(c.has(f))return!1}}}}function l(o,r,i=[]){for(const s of[r,...i]){const n=o[s],f=(typeof n=="string"?n.split(","):Array.isArray(n)?n.flatMap(e=>typeof e=="string"?e.split(","):[]):[]).map(e=>e.trim()).filter(e=>e.length>0);if(f.length>0)return f}return[]}export{d as readBooleanOption,l as readCsvListOption,u as readStringOption};
2
2
  //# sourceMappingURL=package-runtime-options.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9c5d8732-3e10-5224-a558-e870397090f2")}catch{}})();import{READ_OUTPUT_DIMENSION_FLAGS,READ_OUTPUT_COMPOSITION_FLAGS}from"./read-output/options.js";import{createHash}from"node:crypto";import{PmCliError}from"../core/shared/errors.js";import{EXIT_CODE}from"../core/shared/constants.js";import{stableStringify}from"../core/shared/serialization.js";import{isCompactedCursorArgument}from"../core/shared/text-normalization.js";import{decodeReadOutputContinuationCursor}from"./read-output/continuation.js";const QUERY_CURSOR_VERSION=1,MAX_CURSOR_LENGTH=4096,BASE64URL_PATTERN=/^[A-Za-z0-9_-]+$/;function optionKeyForFlag(flag){return flag.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(_,character)=>character.toUpperCase())}function selectCursorSemanticOptions(options,contracts){const universalFlags=[...Object.values(READ_OUTPUT_DIMENSION_FLAGS),...READ_OUTPUT_COMPOSITION_FLAGS],presentationKeys=new Set(universalFlags.flatMap(flag=>[optionKeyForFlag(flag),flag.slice(2).replaceAll("-","_")]));for(const contract of contracts)if(contract.cursor_semantics==="presentation"){presentationKeys.add(optionKeyForFlag(contract.flag));for(const alias of contract.aliases??[])presentationKeys.add(optionKeyForFlag(alias))}return Object.fromEntries(Object.entries(options).filter(([key])=>!presentationKeys.has(key)))}function createQueryFingerprint(command,contract){return createHash("sha256").update(command).update("\0").update(stableStringify(contract)).digest("hex").slice(0,24)}function encodeQueryCursor(fingerprint,afterId,afterIndex,snapshot){return Buffer.from(JSON.stringify({version:QUERY_CURSOR_VERSION,fingerprint,after_id:afterId,...afterIndex===void 0?{}:{after_index:afterIndex},...snapshot===void 0?{}:{snapshot}})).toString("base64url")}function invalidCursor(message,cursorFlag){return new PmCliError(message,EXIT_CODE.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${cursorFlag} to obtain a fresh cursor.`]})}function compactedCursor(cursorFlag){return new PmCliError("Query cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",EXIT_CODE.USAGE,{code:"invalid_query_cursor",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the query.",nextSteps:[`Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole next_cursor to ${cursorFlag}.`,`Or repeat the original query without ${cursorFlag} to obtain a fresh cursor.`]})}function isQueryCursorEnvelope(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const envelope=value;return envelope.version===QUERY_CURSOR_VERSION&&typeof envelope.fingerprint=="string"&&typeof envelope.after_id=="string"&&envelope.after_id.length>0&&(envelope.after_index===void 0||Number.isSafeInteger(envelope.after_index)&&envelope.after_index>=0)&&(envelope.snapshot===void 0||typeof envelope.snapshot=="string"&&envelope.snapshot.length>0)}function decodeQueryCursorEnvelope(cursor,cursorFlag="--after"){if(typeof cursor!="string")throw invalidCursor("Query cursor is malformed.",cursorFlag);const normalized=cursor.trim();if(isCompactedCursorArgument(normalized))throw compactedCursor(cursorFlag);if(normalized.length===0||normalized.length>MAX_CURSOR_LENGTH||!BASE64URL_PATTERN.test(normalized))throw invalidCursor("Query cursor is malformed.",cursorFlag);let parsed;try{parsed=JSON.parse(Buffer.from(normalized,"base64url").toString("utf8"))}catch{throw invalidCursor("Query cursor is malformed.",cursorFlag)}if(!isQueryCursorEnvelope(parsed)){let outputCursor=!1;try{decodeReadOutputContinuationCursor(normalized),outputCursor=!0}catch{}throw outputCursor?new PmCliError(`An output cursor must be continued with --output-cursor, not ${cursorFlag}.`,EXIT_CODE.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${cursorFlag} with --output-cursor ${normalized}; retain any producer ${cursorFlag} cursor from the original page.`]}):invalidCursor("Query cursor version or payload is unsupported.",cursorFlag)}return parsed}function decodeQueryCursorState(cursor,expectedFingerprint,cursorFlag="--after"){const envelope=decodeQueryCursorEnvelope(cursor,cursorFlag);if(envelope.fingerprint!==expectedFingerprint)throw invalidCursor(`Query cursor does not match the current filters, sort, or query (${envelope.fingerprint} != ${expectedFingerprint}).`,cursorFlag);return{after_id:envelope.after_id,...envelope.after_index===void 0?{}:{after_index:envelope.after_index},...envelope.snapshot===void 0?{}:{snapshot:envelope.snapshot}}}function decodeQueryCursor(cursor,expectedFingerprint){return decodeQueryCursorState(cursor,expectedFingerprint).after_id}function resolveQueryCursorStart(rows,cursor,fingerprint,readId,cursorFlag="--after"){if(cursor===void 0)return 0;const state=decodeQueryCursorState(cursor,fingerprint,cursorFlag),index=rows.findIndex(row=>readId(row)===state.after_id);if(index<0){if(state.after_index!==void 0)return Math.min(state.after_index,rows.length);throw invalidCursor(`Query cursor item ${state.after_id} is no longer present in this result set.`,cursorFlag)}return index+1}function paginateQueryRows(rows,options){if(options.cursor!==void 0&&decodeQueryCursorState(options.cursor,options.fingerprint).snapshot!==options.snapshot)throw invalidCursor("Query cursor does not match the requested snapshot.","--after");const pageStart=resolveQueryCursorStart(rows,options.cursor,options.fingerprint,options.readId),pageRows=rows.slice(pageStart,pageStart+options.limit),hasMore=pageRows.length>0&&pageStart+pageRows.length<rows.length,lastRow=pageRows.at(-1);return{rows:pageRows,has_more:hasMore,...hasMore&&lastRow!==void 0?{next_cursor:encodeQueryCursor(options.fingerprint,options.readId(lastRow),pageStart+pageRows.length-1,options.snapshot)}:{}}}const QUERY_CURSOR_CONTRACT=Object.freeze({version:QUERY_CURSOR_VERSION,max_length:MAX_CURSOR_LENGTH});export{QUERY_CURSOR_CONTRACT,createQueryFingerprint,decodeQueryCursor,decodeQueryCursorEnvelope,decodeQueryCursorState,encodeQueryCursor,paginateQueryRows,resolveQueryCursorStart,selectCursorSemanticOptions};
1
+ import{READ_OUTPUT_DIMENSION_FLAGS as m,READ_OUTPUT_COMPOSITION_FLAGS as _}from"./read-output/options.js";import{createHash as y}from"node:crypto";import{PmCliError as u}from"../core/shared/errors.js";import{EXIT_CODE as a}from"../core/shared/constants.js";import{stableStringify as g}from"../core/shared/serialization.js";import{isCompactedCursorArgument as S}from"../core/shared/text-normalization.js";import{decodeReadOutputContinuationCursor as x}from"./read-output/continuation.js";const f=1,h=4096,w=/^[A-Za-z0-9_-]+$/;function d(r){return r.replace(/^--/u,"").replace(/[-_]([a-z0-9])/gu,(e,n)=>n.toUpperCase())}function N(r,e){const n=[...Object.values(m),..._],t=new Set(n.flatMap(o=>[d(o),o.slice(2).replaceAll("-","_")]));for(const o of e)if(o.cursor_semantics==="presentation"){t.add(d(o.flag));for(const i of o.aliases??[])t.add(d(i))}return Object.fromEntries(Object.entries(r).filter(([o])=>!t.has(o)))}function I(r,e){return y("sha256").update(r).update("\0").update(g(e)).digest("hex").slice(0,24)}function C(r,e,n,t){return Buffer.from(JSON.stringify({version:f,fingerprint:r,after_id:e,...n===void 0?{}:{after_index:n},...t===void 0?{}:{snapshot:t}})).toString("base64url")}function s(r,e){return new u(r,a.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the original query without ${e} to obtain a fresh cursor.`]})}function O(r){return new u("Query cursor was shortened by output compaction: it contains an ellipsis, which no cursor encoder emits.",a.USAGE,{code:"invalid_query_cursor",reason:"cursor_compacted",required:"Pass the whole cursor the previous page emitted; a shortened cursor cannot resume the query.",nextSteps:[`Re-read the previous page with a larger --output-budget (or --output-budget unbounded) and pass its whole next_cursor to ${r}.`,`Or repeat the original query without ${r} to obtain a fresh cursor.`]})}function R(r){if(typeof r!="object"||r===null||Array.isArray(r))return!1;const e=r;return e.version===f&&typeof e.fingerprint=="string"&&typeof e.after_id=="string"&&e.after_id.length>0&&(e.after_index===void 0||Number.isSafeInteger(e.after_index)&&e.after_index>=0)&&(e.snapshot===void 0||typeof e.snapshot=="string"&&e.snapshot.length>0)}function E(r,e="--after"){if(typeof r!="string")throw s("Query cursor is malformed.",e);const n=r.trim();if(S(n))throw O(e);if(n.length===0||n.length>h||!w.test(n))throw s("Query cursor is malformed.",e);let t;try{t=JSON.parse(Buffer.from(n,"base64url").toString("utf8"))}catch{throw s("Query cursor is malformed.",e)}if(!R(t)){let o=!1;try{x(n),o=!0}catch{}throw o?new u(`An output cursor must be continued with --output-cursor, not ${e}.`,a.USAGE,{code:"invalid_query_cursor",nextSteps:[`Repeat the same query, replacing ${e} with --output-cursor ${n}; retain any producer ${e} cursor from the original page.`]}):s("Query cursor version or payload is unsupported.",e)}return t}function c(r,e,n="--after"){const t=E(r,n);if(t.fingerprint!==e)throw s(`Query cursor does not match the current filters, sort, or query (${t.fingerprint} != ${e}).`,n);return{after_id:t.after_id,...t.after_index===void 0?{}:{after_index:t.after_index},...t.snapshot===void 0?{}:{snapshot:t.snapshot}}}function G(r,e){return c(r,e).after_id}function Q(r,e,n,t,o="--after"){if(e===void 0)return 0;const i=c(e,n,o),p=r.findIndex(l=>t(l)===i.after_id);if(p<0){if(i.after_index!==void 0)return Math.min(i.after_index,r.length);throw s(`Query cursor item ${i.after_id} is no longer present in this result set.`,o)}return p+1}function M(r,e){if(e.cursor!==void 0&&c(e.cursor,e.fingerprint).snapshot!==e.snapshot)throw s("Query cursor does not match the requested snapshot.","--after");const n=Q(r,e.cursor,e.fingerprint,e.readId),t=r.slice(n,n+e.limit),o=t.length>0&&n+t.length<r.length,i=t.at(-1);return{rows:t,has_more:o,...o&&i!==void 0?{next_cursor:C(e.fingerprint,e.readId(i),n+t.length-1,e.snapshot)}:{}}}const P=Object.freeze({version:f,max_length:h});export{P as QUERY_CURSOR_CONTRACT,I as createQueryFingerprint,G as decodeQueryCursor,E as decodeQueryCursorEnvelope,c as decodeQueryCursorState,C as encodeQueryCursor,M as paginateQueryRows,Q as resolveQueryCursorStart,N as selectCursorSemanticOptions};
2
2
  //# sourceMappingURL=pagination.js.map
@@ -1,6 +1,6 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="aa4e2ff3-dc3b-5688-bf40-bdd71c65320b")}catch{}})();import{assertInitializedTracker}from"./environment/tracker-preflight.js";import path from"node:path";import{readFileIfExists}from"../core/fs/fs-utils.js";import{writeWorkspaceJsonWithHistory}from"../core/history/workspace-history.js";import{acquireLock}from"../core/lock/lock.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{resolveAuthor}from"../core/shared/author.js";import{nowIso}from"../core/shared/time.js";import{resolvePmRoot}from"../core/store/paths.js";import{readSettings,resolveGovernanceKnobs,writeSettings}from"../core/store/settings.js";import{DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,filePathForSchemaSection,normalizeRuntimeSchemaSettings}from"../core/schema/runtime-schema.js";import{normalizeAddTypeInput,serializeItemTypesFile}from"../core/schema/item-types-file.js";import{serializeStatusDefsFile}from"../core/schema/status-defs-file.js";import{serializeFieldsFile}from"../core/schema/fields-file.js";import{resolveNestedSettingDescriptor,writeNestedSettingValue}from"../core/config/nested-settings.js";import{getActiveExtensionRegistrations,runActiveOnWriteHooks}from"../core/extensions/index.js";import{resolveProfileCatalog,resolveProfileEntry}from"../core/profile/profile-presets.js";import{describeProfileComposition,describeProjectProfile}from"../core/profile/profile-describe.js";import{lintProjectProfile}from"../core/profile/profile-lint.js";import{planProfileApplication}from"../core/profile/profile-plan.js";import{ensureTypeFolderScaffold}from"./schema.js";import{runTemplatesSave}from"./templates.js";const PROFILE_SUBCOMMANDS=["list","show","apply","lint"],PROFILE_TYPES_LOCK_ID="schema-types",PROFILE_STATUSES_LOCK_ID="schema-statuses",PROFILE_FIELDS_LOCK_ID="schema-fields";function collectExtensionProfileContributions(){const registrations=getActiveExtensionRegistrations();return registrations===null?[]:registrations.profiles.map(entry=>({name:entry.name,profile:entry.profile}))}function runProfileList(){const{profiles,warnings}=resolveProfileCatalog(collectExtensionProfileContributions());return{action:"list",profiles:profiles.map(resolved=>({name:resolved.definition.name,title:resolved.definition.title,summary:resolved.definition.summary,source:resolved.source,...resolved.package!==void 0?{package:resolved.package}:{},composition:describeProfileComposition(resolved.definition)})),warnings,generated_at:nowIso()}}function runProfileShow(name){let entry;try{entry=resolveProfileEntry(name,collectExtensionProfileContributions())}catch(error){throw new PmCliError(error instanceof Error?error.message:String(error),EXIT_CODE.USAGE)}const{resolved}=entry;return{action:"show",...describeProjectProfile(resolved.definition),source:resolved.source,...resolved.package!==void 0?{package:resolved.package}:{},warnings:entry.warnings,generated_at:nowIso()}}function runProfileLint(name){let entry;try{entry=resolveProfileEntry(name,collectExtensionProfileContributions())}catch(error){throw new PmCliError(error instanceof Error?error.message:String(error),EXIT_CODE.USAGE)}const{resolved}=entry,report=lintProjectProfile(resolved.definition);return{action:"lint",name:resolved.definition.name,title:resolved.definition.title,source:resolved.source,...resolved.package!==void 0?{package:resolved.package}:{},ok:report.ok,error_count:report.errorCount,warning_count:report.warningCount,findings:report.findings,warnings:entry.warnings,generated_at:nowIso()}}function templateFilePath(pmRoot,name){return path.join(pmRoot,"templates",`${name}.json`)}async function readStoredTemplateOptions(pmRoot,name){const raw=await readFileIfExists(templateFilePath(pmRoot,name));if(raw!==null)try{const parsed=JSON.parse(raw);if(parsed!==null&&typeof parsed=="object"&&!Array.isArray(parsed)){const options=parsed.options;if(options!==null&&typeof options=="object"&&!Array.isArray(options))return options}}catch{}}async function loadProfileCurrentState(pmRoot,schema,settings,profile){const templates=new Map;for(const template of profile.templates){const stored=await readStoredTemplateOptions(pmRoot,template.name);stored!==void 0&&templates.set(template.name,stored)}return{typesRaw:await readFileIfExists(filePathForSchemaSection(pmRoot,schema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types)),statusesRaw:await readFileIfExists(filePathForSchemaSection(pmRoot,schema.files.statuses,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses)),fieldsRaw:await readFileIfExists(filePathForSchemaSection(pmRoot,schema.files.fields,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields)),workflows:settings.schema.type_workflows??[],settings,templates,installedPackages:new Set}}function dimensionFrom(changes){const added=[],updated=[],unchanged=[];for(const change of changes)(change.status==="add"?added:change.status==="update"?updated:unchanged).push(change.key);return{added,updated,unchanged}}function buildApplyResult(profile,plan,applied,dryRun,warnings){return{action:"apply",name:profile.name,title:profile.title,applied,dry_run:dryRun,changed:plan.changed,types:dimensionFrom(plan.types.changes),statuses:dimensionFrom(plan.statuses.changes),fields:dimensionFrom(plan.fields.changes),workflows:dimensionFrom(plan.workflows.changes.map(change=>({key:change.type,status:change.status}))),config:dimensionFrom(plan.config.changes),templates:dimensionFrom(plan.templates.changes.map(change=>({key:change.name,status:change.status}))),packages:plan.packages,warnings:[...new Set(warnings)].sort((left,right)=>left.localeCompare(right)),generated_at:nowIso()}}async function assertProfileTrackerInitialized(pmRoot){await assertInitializedTracker(pmRoot)}function resolveProfileForCommand(name){try{const entry=resolveProfileEntry(name,collectExtensionProfileContributions());return{profile:entry.resolved.definition,warnings:entry.warnings}}catch(error){throw new PmCliError(error instanceof Error?error.message:String(error),EXIT_CODE.USAGE)}}async function runProfileApply(name,options,global2){const pmRoot=resolvePmRoot(process.cwd(),global2.path);await assertProfileTrackerInitialized(pmRoot);const resolvedProfile=resolveProfileForCommand(name),profile=resolvedProfile.profile,mergeWarnings=resolvedProfile.warnings,dryRun=options.dryRun===!0,settings=await readSettings(pmRoot),schema=normalizeRuntimeSchemaSettings(settings.schema);if(dryRun){const state=await loadProfileCurrentState(pmRoot,schema,settings,profile),plan2=planProfile(profile,state);return buildApplyResult(profile,plan2,!1,!0,[...mergeWarnings])}const author=resolveAuthor(options.author,settings.author_default),governance=resolveGovernanceKnobs(settings),force=!!options.force,warnings=[...mergeWarnings],releasers=[],acquire=async lockId=>{releasers.push(await acquireLock(pmRoot,lockId,settings.locks.ttl_seconds,author,force,governance.force_required_for_stale_lock,settings.locks.wait_ms))};let plan;try{await acquire(PROFILE_TYPES_LOCK_ID),await acquire(PROFILE_STATUSES_LOCK_ID),await acquire(PROFILE_FIELDS_LOCK_ID);const state=await loadProfileCurrentState(pmRoot,schema,settings,profile);if(plan=planProfile(profile,state),plan.types.changed){const typesPath=filePathForSchemaSection(pmRoot,schema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types);await writeWorkspaceJsonWithHistory({pmRoot,filePath:typesPath,raw:serializeItemTypesFile(plan.types.file),op:"profile:apply-types",author,lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms});const stagedNames=new Set(profile.types.map(type=>normalizeAddTypeInput(type).name)),stagedDefinitions=plan.types.file.definitions.filter(definition=>stagedNames.has(definition.name));await ensureTypeFolderScaffold(pmRoot,stagedDefinitions,warnings,"profile:apply-type-folder"),warnings.push(...await runActiveOnWriteHooks({path:typesPath,scope:"project",op:"profile:apply-types"}))}if(plan.statuses.changed){const statusesPath=filePathForSchemaSection(pmRoot,schema.files.statuses,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses);await writeWorkspaceJsonWithHistory({pmRoot,filePath:statusesPath,raw:serializeStatusDefsFile(plan.statuses.file),op:"profile:apply-statuses",author,lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms}),warnings.push(...await runActiveOnWriteHooks({path:statusesPath,scope:"project",op:"profile:apply-statuses"}))}if(plan.fields.changed){const fieldsPath=filePathForSchemaSection(pmRoot,schema.files.fields,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields);await writeWorkspaceJsonWithHistory({pmRoot,filePath:fieldsPath,raw:serializeFieldsFile(plan.fields.file),op:"profile:apply-fields",author,lockTtlSeconds:settings.locks.ttl_seconds,lockWaitMs:settings.locks.wait_ms}),warnings.push(...await runActiveOnWriteHooks({path:fieldsPath,scope:"project",op:"profile:apply-fields"}))}if(plan.config.changed||plan.workflows.changed){for(const change of plan.config.changes){if(change.status==="unchanged")continue;const descriptor=resolveNestedSettingDescriptor(change.key);descriptor!==void 0&&writeNestedSettingValue(settings,descriptor,change.value)}settings.schema.type_workflows=plan.workflows.result,await writeSettings(pmRoot,settings,"profile:apply-config")}for(const change of plan.templates.changes)change.status!=="unchanged"&&await runTemplatesSave(change.name,{...change.options},global2)}finally{for(const release of releasers.reverse())try{await release()}catch{}}return buildApplyResult(profile,plan,plan.changed,!1,warnings)}function planProfile(profile,state){try{return planProfileApplication(profile,state)}catch(error){throw new PmCliError(error instanceof Error?error.message:String(error),EXIT_CODE.USAGE)}}function formatDimensionLine(label,dimension){const segments=[];if(dimension.added.length>0&&segments.push(`+${dimension.added.join(", ")}`),dimension.updated.length>0&&segments.push(`~${dimension.updated.join(", ")}`),segments.length!==0)return` ${label}: ${segments.join(" ")}`}function formatProfileListHuman(result){const lines=["Project profiles:"];for(const profile of result.profiles){const origin=profile.source==="extension"?` [${profile.package??"extension"}]`:"";lines.push(` ${profile.name} \u2014 ${profile.title}: ${profile.summary}${origin}`)}for(const warning of result.warnings)lines.push(` warning: ${warning}`);return lines.join(`
2
- `)}function formatProfileShowHuman(result){const origin=result.source==="extension"?` [${result.package??"extension"}]`:"",lines=[`${result.name} \u2014 ${result.title}${origin}`,result.summary,""];lines.push(`types: ${result.types.join(", ")||"(none)"}`),lines.push(`statuses: ${result.statuses.join(", ")||"(none)"}`),lines.push(`fields: ${result.fields.join(", ")||"(none)"}`),lines.push(`workflows: ${result.workflows.join(", ")||"(none)"}`),lines.push(`config: ${result.config.join(", ")||"(none)"}`),lines.push(`templates: ${result.templates.join(", ")||"(none)"}`),lines.push(`packages: ${result.packages.map(pkg=>pkg.spec).join(", ")||"(none)"}`);for(const warning of result.warnings)lines.push(`warning: ${warning}`);return lines.join(`
3
- `)}function formatProfileLintHuman(result){const origin=result.source==="extension"?` [${result.package??"extension"}]`:"",totalWarningCount=result.warning_count+result.warnings.length,lines=[result.ok?`Profile ${result.name}${origin}: ok (${totalWarningCount} warning${totalWarningCount===1?"":"s"})`:`Profile ${result.name}${origin}: ${result.error_count} error${result.error_count===1?"":"s"}, ${totalWarningCount} warning${totalWarningCount===1?"":"s"}`];for(const finding of result.findings){const target=finding.target!==void 0?` (${finding.target})`:"";lines.push(` ${finding.severity} [${finding.code}] ${finding.dimension}${target}: ${finding.message}`)}for(const warning of result.warnings)lines.push(` warning: ${warning}`);return lines.join(`
4
- `)}function formatProfileApplyHuman(result){const mode=result.dry_run?"dry-run":result.applied?"applied":"no changes",lines=[`Profile ${result.name} (${mode})`];if(!result.changed)lines.push(" already up to date");else for(const[label,dimension]of[["types",result.types],["statuses",result.statuses],["fields",result.fields],["workflows",result.workflows],["config",result.config],["templates",result.templates]]){const line=formatDimensionLine(label,dimension);line!==void 0&&lines.push(line)}const recommended=result.packages.filter(pkg=>pkg.status==="recommended");recommended.length>0&&lines.push(` recommended packages: ${recommended.map(pkg=>pkg.spec).join(", ")}`);for(const warning of result.warnings)lines.push(` warning: ${warning}`);return lines.join(`
5
- `)}export{PROFILE_SUBCOMMANDS,formatProfileApplyHuman,formatProfileLintHuman,formatProfileListHuman,formatProfileShowHuman,runProfileApply,runProfileLint,runProfileList,runProfileShow};
1
+ import{assertInitializedTracker as D}from"./environment/tracker-preflight.js";import z from"node:path";import{readFileIfExists as y}from"../core/fs/fs-utils.js";import{writeWorkspaceJsonWithHistory as j}from"../core/history/workspace-history.js";import{acquireLock as b}from"../core/lock/lock.js";import{EXIT_CODE as k}from"../core/shared/constants.js";import{PmCliError as $}from"../core/shared/errors.js";import{resolveAuthor as H}from"../core/shared/author.js";import{nowIso as P}from"../core/shared/time.js";import{resolvePmRoot as M}from"../core/store/paths.js";import{readSettings as U,resolveGovernanceKnobs as W,writeSettings as N}from"../core/store/settings.js";import{DEFAULT_RUNTIME_SCHEMA_FILE_PATHS as l,filePathForSchemaSection as d,normalizeRuntimeSchemaSettings as G}from"../core/schema/runtime-schema.js";import{normalizeAddTypeInput as K,serializeItemTypesFile as q}from"../core/schema/item-types-file.js";import{serializeStatusDefsFile as B}from"../core/schema/status-defs-file.js";import{normalizeAddFieldInput as J,serializeFieldsFile as V}from"../core/schema/fields-file.js";import{assertFieldOptionsAvailable as X}from"./schema/field-option-collisions.js";import{resolveNestedSettingDescriptor as Y,writeNestedSettingValue as Q}from"../core/config/nested-settings.js";import{getActiveExtensionRegistrations as Z,runActiveOnWriteHooks as A}from"../core/extensions/index.js";import{resolveProfileCatalog as ee,resolveProfileEntry as F}from"../core/profile/profile-presets.js";import{describeProfileComposition as te,describeProjectProfile as ne}from"../core/profile/profile-describe.js";import{lintProjectProfile as oe}from"../core/profile/profile-lint.js";import{planProfileApplication as ie}from"../core/profile/profile-plan.js";import{ensureTypeFolderScaffold as se}from"./schema.js";import{runTemplatesSave as ae}from"./templates.js";const He=["list","show","apply","lint"],re="schema-types",ce="schema-statuses",fe="schema-fields";function _(){const e=Z();return e===null?[]:e.profiles.map(n=>({name:n.name,profile:n.profile}))}function Me(){const{profiles:e,warnings:n}=ee(_());return{action:"list",profiles:e.map(t=>({name:t.definition.name,title:t.definition.title,summary:t.definition.summary,source:t.source,...t.package!==void 0?{package:t.package}:{},composition:te(t.definition)})),warnings:n,generated_at:P()}}function Ue(e){let n;try{n=F(e,_())}catch(o){throw new $(o instanceof Error?o.message:String(o),k.USAGE)}const{resolved:t}=n;return{action:"show",...ne(t.definition),source:t.source,...t.package!==void 0?{package:t.package}:{},warnings:n.warnings,generated_at:P()}}function We(e){let n;try{n=F(e,_())}catch(i){throw new $(i instanceof Error?i.message:String(i),k.USAGE)}const{resolved:t}=n,o=oe(t.definition);return{action:"lint",name:t.definition.name,title:t.definition.title,source:t.source,...t.package!==void 0?{package:t.package}:{},ok:o.ok,error_count:o.errorCount,warning_count:o.warningCount,findings:o.findings,warnings:n.warnings,generated_at:P()}}function pe(e,n){return z.join(e,"templates",`${n}.json`)}async function le(e,n){const t=await y(pe(e,n));if(t!==null)try{const o=JSON.parse(t);if(o!==null&&typeof o=="object"&&!Array.isArray(o)){const i=o.options;if(i!==null&&typeof i=="object"&&!Array.isArray(i))return i}}catch{}}async function I(e,n,t,o){const i=new Map;for(const s of o.templates){const f=await le(e,s.name);f!==void 0&&i.set(s.name,f)}return{typesRaw:await y(d(e,n.files.types,l.types)),statusesRaw:await y(d(e,n.files.statuses,l.statuses)),fieldsRaw:await y(d(e,n.files.fields,l.fields)),workflows:t.schema.type_workflows??[],settings:t,templates:i,installedPackages:new Set}}function m(e){const n=[],t=[],o=[];for(const i of e)(i.status==="add"?n:i.status==="update"?t:o).push(i.key);return{added:n,updated:t,unchanged:o}}function T(e,n,t,o,i){return{action:"apply",name:e.name,title:e.title,applied:t,dry_run:o,changed:n.changed,types:m(n.types.changes),statuses:m(n.statuses.changes),fields:m(n.fields.changes),workflows:m(n.workflows.changes.map(s=>({key:s.type,status:s.status}))),config:m(n.config.changes),templates:m(n.templates.changes.map(s=>({key:s.name,status:s.status}))),packages:n.packages,warnings:[...new Set(i)].sort((s,f)=>s.localeCompare(f)),generated_at:P()}}async function de(e){await D(e)}function me(e){try{const n=F(e,_());return{profile:n.resolved.definition,warnings:n.warnings}}catch(n){throw new $(n instanceof Error?n.message:String(n),k.USAGE)}}async function Ne(e,n,t){const o=M(process.cwd(),t.path);await de(o);const i=me(e),s=i.profile,f=i.warnings;for(const p of s.fields){let a;try{a=J(p)}catch{continue}X(a)}const C=n.dryRun===!0,r=await U(o),u=G(r.schema);if(C){const p=await I(o,u,r,s),a=v(s,p);return T(s,a,!1,!0,[...f])}const w=H(n.author,r.author_default),L=W(r),O=!!n.force,g=[...f],x=[],S=async p=>{x.push(await b(o,p,r.locks.ttl_seconds,w,O,L.force_required_for_stale_lock,r.locks.wait_ms))};let c;try{await S(re),await S(ce),await S(fe);const p=await I(o,u,r,s);if(c=v(s,p),c.types.changed){const a=d(o,u.files.types,l.types);await j({pmRoot:o,filePath:a,raw:q(c.types.file),op:"profile:apply-types",author:w,lockTtlSeconds:r.locks.ttl_seconds,lockWaitMs:r.locks.wait_ms});const h=new Set(s.types.map(E=>K(E).name)),R=c.types.file.definitions.filter(E=>h.has(E.name));await se(o,R,g,"profile:apply-type-folder"),g.push(...await A({path:a,scope:"project",op:"profile:apply-types"}))}if(c.statuses.changed){const a=d(o,u.files.statuses,l.statuses);await j({pmRoot:o,filePath:a,raw:B(c.statuses.file),op:"profile:apply-statuses",author:w,lockTtlSeconds:r.locks.ttl_seconds,lockWaitMs:r.locks.wait_ms}),g.push(...await A({path:a,scope:"project",op:"profile:apply-statuses"}))}if(c.fields.changed){const a=d(o,u.files.fields,l.fields);await j({pmRoot:o,filePath:a,raw:V(c.fields.file),op:"profile:apply-fields",author:w,lockTtlSeconds:r.locks.ttl_seconds,lockWaitMs:r.locks.wait_ms}),g.push(...await A({path:a,scope:"project",op:"profile:apply-fields"}))}if(c.config.changed||c.workflows.changed){for(const a of c.config.changes){if(a.status==="unchanged")continue;const h=Y(a.key);h!==void 0&&Q(r,h,a.value)}r.schema.type_workflows=c.workflows.result,await N(o,r,"profile:apply-config")}for(const a of c.templates.changes)a.status!=="unchanged"&&await ae(a.name,{...a.options},t)}finally{for(const p of x.reverse())try{await p()}catch{}}return T(s,c,c.changed,!1,g)}function v(e,n){try{return ie(e,n)}catch(t){throw new $(t instanceof Error?t.message:String(t),k.USAGE)}}function ue(e,n){const t=[];if(n.added.length>0&&t.push(`+${n.added.join(", ")}`),n.updated.length>0&&t.push(`~${n.updated.join(", ")}`),t.length!==0)return` ${e}: ${t.join(" ")}`}function Ge(e){const n=["Project profiles:"];for(const t of e.profiles){const o=t.source==="extension"?` [${t.package??"extension"}]`:"";n.push(` ${t.name} \u2014 ${t.title}: ${t.summary}${o}`)}for(const t of e.warnings)n.push(` warning: ${t}`);return n.join(`
2
+ `)}function Ke(e){const n=e.source==="extension"?` [${e.package??"extension"}]`:"",t=[`${e.name} \u2014 ${e.title}${n}`,e.summary,""];t.push(`types: ${e.types.join(", ")||"(none)"}`),t.push(`statuses: ${e.statuses.join(", ")||"(none)"}`),t.push(`fields: ${e.fields.join(", ")||"(none)"}`),t.push(`workflows: ${e.workflows.join(", ")||"(none)"}`),t.push(`config: ${e.config.join(", ")||"(none)"}`),t.push(`templates: ${e.templates.join(", ")||"(none)"}`),t.push(`packages: ${e.packages.map(o=>o.spec).join(", ")||"(none)"}`);for(const o of e.warnings)t.push(`warning: ${o}`);return t.join(`
3
+ `)}function qe(e){const n=e.source==="extension"?` [${e.package??"extension"}]`:"",t=e.warning_count+e.warnings.length,i=[e.ok?`Profile ${e.name}${n}: ok (${t} warning${t===1?"":"s"})`:`Profile ${e.name}${n}: ${e.error_count} error${e.error_count===1?"":"s"}, ${t} warning${t===1?"":"s"}`];for(const s of e.findings){const f=s.target!==void 0?` (${s.target})`:"";i.push(` ${s.severity} [${s.code}] ${s.dimension}${f}: ${s.message}`)}for(const s of e.warnings)i.push(` warning: ${s}`);return i.join(`
4
+ `)}function Be(e){const n=e.dry_run?"dry-run":e.applied?"applied":"no changes",t=[`Profile ${e.name} (${n})`];if(!e.changed)t.push(" already up to date");else for(const[i,s]of[["types",e.types],["statuses",e.statuses],["fields",e.fields],["workflows",e.workflows],["config",e.config],["templates",e.templates]]){const f=ue(i,s);f!==void 0&&t.push(f)}const o=e.packages.filter(i=>i.status==="recommended");o.length>0&&t.push(` recommended packages: ${o.map(i=>i.spec).join(", ")}`);for(const i of e.warnings)t.push(` warning: ${i}`);return t.join(`
5
+ `)}export{He as PROFILE_SUBCOMMANDS,Be as formatProfileApplyHuman,qe as formatProfileLintHuman,Ge as formatProfileListHuman,Ke as formatProfileShowHuman,Ne as runProfileApply,We as runProfileLint,Me as runProfileList,Ue as runProfileShow};
6
6
  //# sourceMappingURL=profile.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="28dd16ac-2e3b-55ed-98a6-db5f6786cbd7")}catch{}})();import{AGENT_PROVENANCE_DIMENSIONS,BUILTIN_HARNESS_SIGNAL_DESCRIPTORS}from"../core/shared/author.js";function resolveHistoryEpisodeGroupIdentity(entry){return entry.agent_episode!==void 0?{id:entry.agent_episode.id,source:"declared"}:{id:entry.agent_instance?`inferred:instance:${entry.agent_instance}`:`inferred:author:${entry.author}:${entry.ts.slice(0,13)}`,source:"inferred"}}function episodeParentIsAcyclic(group,parent,declaredGroups){let cursor=parent;const seen=new Set([group.id]);for(;cursor!==void 0&&!seen.has(cursor.id);)seen.add(cursor.id),cursor=cursor.parent_id?declaredGroups.get(cursor.parent_id):void 0;return cursor===void 0}function sortAgentEpisodeForest(roots){const pending=[roots];for(;pending.length>0;){const values=pending.pop();values.sort((left,right)=>left.entries[0].ts.localeCompare(right.entries[0].ts)||left.id.localeCompare(right.id)),pending.push(...values.map(value=>value.children))}}function analyzeAgentProvenanceDescriptorCoverage(descriptors=BUILTIN_HARNESS_SIGNAL_DESCRIPTORS,dimensions=AGENT_PROVENANCE_DIMENSIONS){return dimensions.map(dimension=>{const harnesses=descriptors.filter(descriptor=>((dimension==="model"?descriptor.model_environment_keys:descriptor.provenance_environment_keys?.[dimension])?.length??0)>0||descriptor.provenance_resolvers?.[dimension]!==void 0).map(descriptor=>descriptor.harness).sort();return{dimension,harnesses,covered:harnesses.length>0}})}function summarizeAgentModelProvenance(entries,minimumExplicitSample=1){const byHarness=new Map;for(const entry of entries){if(!entry.agent_harness)continue;const row=byHarness.get(entry.agent_harness)??{harness:entry.agent_harness,entries:0,observed:0,unavailable:0,legacy_missing:0};row.entries+=1,entry.agent_model||entry.agent_provenance?.model&&entry.agent_provenance.model.value.length>0?row.observed+=1:entry.agent_provenance?.model===null?row.unavailable+=1:row.legacy_missing+=1,byHarness.set(entry.agent_harness,row)}return[...byHarness.values()].map(row=>{const explicit=row.observed+row.unavailable;return{...row,coverage:explicit===0?null:row.observed/explicit,inert:explicit>=minimumExplicitSample&&row.observed===0}}).sort((left,right)=>left.harness.localeCompare(right.harness))}function summarizeAgentProvenance(entries,dimensions=AGENT_PROVENANCE_DIMENSIONS,minimumExplicitSample=1){const rows=new Map;for(const entry of entries)if(entry.agent_harness)for(const dimension of dimensions){const key=`${entry.agent_harness}\0${dimension}`,row=rows.get(key)??{harness:entry.agent_harness,dimension,entries:0,observed:0,unavailable:0,legacy_missing:0};row.entries+=1;const observation=entry.agent_provenance?.[dimension];observation!=null&&observation.value.length>0?row.observed+=1:observation===null?row.unavailable+=1:row.legacy_missing+=1,rows.set(key,row)}return[...rows.values()].map(row=>{const explicit=row.observed+row.unavailable;return{...row,coverage:explicit===0?null:row.observed/explicit,inert:explicit>=minimumExplicitSample&&row.observed===0}}).sort((left,right)=>left.harness.localeCompare(right.harness)||left.dimension.localeCompare(right.dimension))}function evaluateSemanticAttributionCoverage(entries,options={}){const minimumCoverage=options.minimumCoverage??.8,minimumEntries=options.minimumEntries??5;if(![Number.isFinite(minimumCoverage),minimumCoverage>=0,minimumCoverage<=1].every(Boolean))throw new RangeError("Semantic attribution minimum coverage must be from 0 to 1.");if(![Number.isSafeInteger(minimumEntries),minimumEntries>=1].every(Boolean))throw new RangeError("Semantic attribution minimum entries must be a positive integer.");const rows=new Map;for(const entry of entries)if(entry.agent_harness)for(const dimension of["role","topic"]){const key=`${entry.agent_harness}\0${dimension}`,row=rows.get(key)??{harness:entry.agent_harness,dimension,entries:0,observed:0,by_source:{},coverage:0};row.entries+=1;const observation=entry.agent_provenance?.[dimension];observation?.value&&(row.observed+=1,row.by_source[observation.source]=(row.by_source[observation.source]??0)+1),rows.set(key,row)}const ordered=[...rows.values()].map(row=>({...row,coverage:row.observed/row.entries,by_source:Object.fromEntries(Object.entries(row.by_source).sort(([left],[right])=>left.localeCompare(right)))})).sort((left,right)=>left.harness.localeCompare(right.harness)||left.dimension.localeCompare(right.dimension)),eligible=ordered.filter(row=>row.entries>=minimumEntries),failures=eligible.filter(row=>row.coverage<minimumCoverage).map(row=>`${row.harness}:${row.dimension}`);return{passed:eligible.length>0&&failures.length===0,minimum_coverage:minimumCoverage,minimum_entries:minimumEntries,rows:ordered,failures}}function groupHistoryByEpisode(entries){const sorted=[...entries].sort((left,right)=>left.ts.localeCompare(right.ts)||left.author.localeCompare(right.author)||left.op.localeCompare(right.op)||left.before_hash.localeCompare(right.before_hash)||left.after_hash.localeCompare(right.after_hash)),groups=new Map,declaredGroups=new Map;for(const entry of sorted){const episode=entry.agent_episode,identity=resolveHistoryEpisodeGroupIdentity(entry),groupKey=`${identity.source}:${identity.id}`,existing=groups.get(groupKey);if(existing){existing.entries.push(entry);continue}const group={id:identity.id,...episode?.label===void 0?{}:{label:episode.label},...episode?.parent_id===void 0?{}:{parent_id:episode.parent_id},source:identity.source,entries:[entry],children:[]};groups.set(groupKey,group),episode!==void 0&&declaredGroups.set(identity.id,group)}const roots=[];for(const group of groups.values()){const parent=group.parent_id?declaredGroups.get(group.parent_id):void 0;parent&&episodeParentIsAcyclic(group,parent,declaredGroups)?parent.children.push(group):roots.push(group)}return sortAgentEpisodeForest(roots),roots}export{analyzeAgentProvenanceDescriptorCoverage,evaluateSemanticAttributionCoverage,groupHistoryByEpisode,resolveHistoryEpisodeGroupIdentity,summarizeAgentModelProvenance,summarizeAgentProvenance};
1
+ import{AGENT_PROVENANCE_DIMENSIONS as p,BUILTIN_HARNESS_SIGNAL_DESCRIPTORS as g}from"../core/shared/author.js";function v(a){return a.agent_episode!==void 0?{id:a.agent_episode.id,source:"declared"}:{id:a.agent_instance?`inferred:instance:${a.agent_instance}`:`inferred:author:${a.author}:${a.ts.slice(0,13)}`,source:"inferred"}}function f(a,i,r){let e=i;const n=new Set([a.id]);for(;e!==void 0&&!n.has(e.id);)n.add(e.id),e=e.parent_id?r.get(e.parent_id):void 0;return e===void 0}function _(a){const i=[a];for(;i.length>0;){const r=i.pop();r.sort((e,n)=>e.entries[0].ts.localeCompare(n.entries[0].ts)||e.id.localeCompare(n.id)),i.push(...r.map(e=>e.children))}}function b(a=g,i=p){return i.map(r=>{const e=a.filter(n=>((r==="model"?n.model_environment_keys:n.provenance_environment_keys?.[r])?.length??0)>0||n.provenance_resolvers?.[r]!==void 0).map(n=>n.harness).sort();return{dimension:r,harnesses:e,covered:e.length>0}})}function y(a,i=1){const r=new Map;for(const e of a){if(!e.agent_harness)continue;const n=r.get(e.agent_harness)??{harness:e.agent_harness,entries:0,observed:0,unavailable:0,legacy_missing:0};n.entries+=1,e.agent_model||e.agent_provenance?.model&&e.agent_provenance.model.value.length>0?n.observed+=1:e.agent_provenance?.model===null?n.unavailable+=1:n.legacy_missing+=1,r.set(e.agent_harness,n)}return[...r.values()].map(e=>{const n=e.observed+e.unavailable;return{...e,coverage:n===0?null:e.observed/n,inert:n>=i&&e.observed===0}}).sort((e,n)=>e.harness.localeCompare(n.harness))}function C(a,i=p,r=1){const e=new Map;for(const n of a)if(n.agent_harness)for(const s of i){const t=`${n.agent_harness}\0${s}`,c=e.get(t)??{harness:n.agent_harness,dimension:s,entries:0,observed:0,unavailable:0,legacy_missing:0};c.entries+=1;const o=n.agent_provenance?.[s];o!=null&&o.value.length>0?c.observed+=1:o===null?c.unavailable+=1:c.legacy_missing+=1,e.set(t,c)}return[...e.values()].map(n=>{const s=n.observed+n.unavailable;return{...n,coverage:s===0?null:n.observed/s,inert:s>=r&&n.observed===0}}).sort((n,s)=>n.harness.localeCompare(s.harness)||n.dimension.localeCompare(s.dimension))}function E(a,i={}){const r=i.minimumCoverage??.8,e=i.minimumEntries??5;if(![Number.isFinite(r),r>=0,r<=1].every(Boolean))throw new RangeError("Semantic attribution minimum coverage must be from 0 to 1.");if(![Number.isSafeInteger(e),e>=1].every(Boolean))throw new RangeError("Semantic attribution minimum entries must be a positive integer.");const n=new Map;for(const o of a)if(o.agent_harness)for(const l of["role","topic"]){const u=`${o.agent_harness}\0${l}`,d=n.get(u)??{harness:o.agent_harness,dimension:l,entries:0,observed:0,by_source:{},coverage:0};d.entries+=1;const m=o.agent_provenance?.[l];m?.value&&(d.observed+=1,d.by_source[m.source]=(d.by_source[m.source]??0)+1),n.set(u,d)}const s=[...n.values()].map(o=>({...o,coverage:o.observed/o.entries,by_source:Object.fromEntries(Object.entries(o.by_source).sort(([l],[u])=>l.localeCompare(u)))})).sort((o,l)=>o.harness.localeCompare(l.harness)||o.dimension.localeCompare(l.dimension)),t=s.filter(o=>o.entries>=e),c=t.filter(o=>o.coverage<r).map(o=>`${o.harness}:${o.dimension}`);return{passed:t.length>0&&c.length===0,minimum_coverage:r,minimum_entries:e,rows:s,failures:c}}function S(a){const i=[...a].sort((s,t)=>s.ts.localeCompare(t.ts)||s.author.localeCompare(t.author)||s.op.localeCompare(t.op)||s.before_hash.localeCompare(t.before_hash)||s.after_hash.localeCompare(t.after_hash)),r=new Map,e=new Map;for(const s of i){const t=s.agent_episode,c=v(s),o=`${c.source}:${c.id}`,l=r.get(o);if(l){l.entries.push(s);continue}const u={id:c.id,...t?.label===void 0?{}:{label:t.label},...t?.parent_id===void 0?{}:{parent_id:t.parent_id},source:c.source,entries:[s],children:[]};r.set(o,u),t!==void 0&&e.set(c.id,u)}const n=[];for(const s of r.values()){const t=s.parent_id?e.get(s.parent_id):void 0;t&&f(s,t,e)?t.children.push(s):n.push(s)}return _(n),n}export{b as analyzeAgentProvenanceDescriptorCoverage,E as evaluateSemanticAttributionCoverage,S as groupHistoryByEpisode,v as resolveHistoryEpisodeGroupIdentity,y as summarizeAgentModelProvenance,C as summarizeAgentProvenance};
2
2
  //# sourceMappingURL=provenance.js.map