@unbrained/pm-cli 2026.11.22 → 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 (892) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/after-command-context-usage.js +1 -1
  3. package/dist/cli/argv-utils.js +1 -1
  4. package/dist/cli/bootstrap-args.js +1 -1
  5. package/dist/cli/bundle-integrity.js +2 -2
  6. package/dist/cli/command-namespaces.js +1 -1
  7. package/dist/cli/commander-usage.js +11 -11
  8. package/dist/cli/commands/annotations/comments.js +1 -1
  9. package/dist/cli/commands/annotations/docs.js +1 -1
  10. package/dist/cli/commands/annotations/files.js +1 -1
  11. package/dist/cli/commands/annotations/learnings.js +1 -1
  12. package/dist/cli/commands/annotations/notes.js +1 -1
  13. package/dist/cli/commands/extension/describe.js +1 -1
  14. package/dist/cli/commands/extension/extension.js +1 -1
  15. package/dist/cli/commands/extension/scaffold.js +1 -1
  16. package/dist/cli/commands/extension/shared.js +1 -1
  17. package/dist/cli/commands/governance/gc.js +1 -1
  18. package/dist/cli/commands/governance/health.js +1 -1
  19. package/dist/cli/commands/governance/telemetry.js +1 -1
  20. package/dist/cli/commands/governance/validate.js +1 -1
  21. package/dist/cli/commands/history/activity.js +1 -1
  22. package/dist/cli/commands/history/history-compact.js +1 -1
  23. package/dist/cli/commands/history/history-redact.js +1 -1
  24. package/dist/cli/commands/history/history-repair.js +1 -1
  25. package/dist/cli/commands/history/history.js +1 -1
  26. package/dist/cli/commands/history/restore.js +1 -1
  27. package/dist/cli/commands/lifecycle/append.js +1 -1
  28. package/dist/cli/commands/lifecycle/claim.js +1 -1
  29. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  30. package/dist/cli/commands/lifecycle/close.js +1 -1
  31. package/dist/cli/commands/lifecycle/copy.js +1 -1
  32. package/dist/cli/commands/lifecycle/create.js +1 -1
  33. package/dist/cli/commands/lifecycle/delete.js +1 -1
  34. package/dist/cli/commands/lifecycle/focus.js +1 -1
  35. package/dist/cli/commands/lifecycle/plan.js +1 -1
  36. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  37. package/dist/cli/commands/lifecycle/update.js +1 -1
  38. package/dist/cli/commands/query/aggregate.js +1 -1
  39. package/dist/cli/commands/query/context.js +1 -1
  40. package/dist/cli/commands/query/deps.js +1 -1
  41. package/dist/cli/commands/query/duplicates.js +1 -1
  42. package/dist/cli/commands/query/eval.js +1 -1
  43. package/dist/cli/commands/query/get.js +1 -1
  44. package/dist/cli/commands/query/graph.js +1 -1
  45. package/dist/cli/commands/query/list.js +1 -1
  46. package/dist/cli/commands/query/next.js +1 -1
  47. package/dist/cli/commands/query/search.js +1 -1
  48. package/dist/cli/commands/query/stats.js +1 -1
  49. package/dist/cli/commands/test/test-all.js +1 -1
  50. package/dist/cli/commands/test/test-runs.js +1 -1
  51. package/dist/cli/commands/test/test.js +1 -1
  52. package/dist/cli/commands/workspace/config.js +1 -1
  53. package/dist/cli/commands/workspace/contracts.js +1 -1
  54. package/dist/cli/commands/workspace/init.js +1 -1
  55. package/dist/cli/commands/workspace/merge.js +1 -1
  56. package/dist/cli/commands/workspace/profile.js +1 -1
  57. package/dist/cli/commands/workspace/schema.js +1 -1
  58. package/dist/cli/commands/workspace/upgrade.js +1 -1
  59. package/dist/cli/context-intent-invocation.js +1 -1
  60. package/dist/cli/description-stdin.js +1 -1
  61. package/dist/cli/error-guidance.js +5 -5
  62. package/dist/cli/expected-revisions.js +1 -1
  63. package/dist/cli/extension-command-help.js +6 -6
  64. package/dist/cli/extension-recovery.js +1 -1
  65. package/dist/cli/help-content.js +5 -5
  66. package/dist/cli/help-json-payload.js +7 -7
  67. package/dist/cli/invocation-profile.js +2 -2
  68. package/dist/cli/main.js +5 -5
  69. package/dist/cli/migration-gates.js +1 -1
  70. package/dist/cli/option-values.js +1 -1
  71. package/dist/cli/preflight-warnings.js +3 -3
  72. package/dist/cli/public.js +1 -1
  73. package/dist/cli/register-annotations.js +1 -1
  74. package/dist/cli/register-assurance.js +1 -1
  75. package/dist/cli/register-files-lookup.js +1 -1
  76. package/dist/cli/register-history-activity.js +1 -1
  77. package/dist/cli/register-history-author.js +1 -1
  78. package/dist/cli/register-history-maintenance.js +2 -2
  79. package/dist/cli/register-list-query.js +10 -10
  80. package/dist/cli/register-mutation-options.js +0 -1
  81. package/dist/cli/register-mutation.js +6 -6
  82. package/dist/cli/register-operations.js +1 -1
  83. package/dist/cli/register-setup.js +1 -1
  84. package/dist/cli/register-structured-mutation.js +1 -1
  85. package/dist/cli/registration-helpers.js +1 -1
  86. package/dist/cli/runtime/activation.js +1 -1
  87. package/dist/cli/runtime/annotation-option-retry.js +1 -1
  88. package/dist/cli/runtime/close-fields-retry.js +1 -1
  89. package/dist/cli/runtime/field-route-retry.js +1 -1
  90. package/dist/cli/runtime/invocation-options.js +1 -1
  91. package/dist/cli/runtime/invocation-rewrites.js +1 -1
  92. package/dist/cli/runtime/projection-retry.js +1 -1
  93. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  94. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  95. package/dist/cli/runtime/selection.js +1 -1
  96. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  97. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  98. package/dist/cli/schema/registration.js +15 -15
  99. package/dist/cli/schema-registration-helpers.js +1 -1
  100. package/dist/cli/search-refresh.js +1 -1
  101. package/dist/cli/stats-analytics-json.js +1 -1
  102. package/dist/cli/telemetry-flush.js +1 -1
  103. package/dist/cli-bundle/bundle-manifest.json +1 -1
  104. package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
  105. package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
  106. package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
  107. package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
  108. package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
  109. package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
  110. package/dist/cli-bundle/chunks/{chunk-B76TFRO2.js → chunk-AEOHUSUI.js} +101 -101
  111. package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
  112. package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
  113. package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
  114. package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
  115. package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
  116. package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
  117. package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
  118. package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
  119. package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
  120. package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
  121. package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
  122. package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
  123. package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
  124. package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
  125. package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
  126. package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
  127. package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
  128. package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
  129. package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
  130. package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
  131. package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
  132. package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
  133. package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
  134. package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
  135. package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
  136. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
  137. package/dist/cli-bundle/chunks/{item-revision-4QBMZXKX.js → item-revision-FMD4KWBB.js} +2 -2
  138. package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
  139. package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
  140. package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
  141. package/dist/cli-bundle/chunks/{register-list-query-RR5KACJ3.js → register-list-query-L4IBU64P.js} +11 -11
  142. package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
  143. package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
  144. package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
  145. package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
  146. package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
  147. package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
  148. package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
  149. package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
  150. package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
  151. package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
  152. package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
  153. package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
  154. package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
  155. package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
  156. package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
  157. package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
  158. package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
  159. package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
  160. package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
  161. package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
  162. package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
  163. package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
  164. package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
  165. package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
  166. package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
  167. package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
  168. package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
  169. package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
  170. package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
  171. package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
  172. package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
  173. package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
  174. package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
  175. package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
  176. package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
  177. package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
  178. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
  179. package/dist/cli-bundle/focused-chunks/{item-revision-2O6MLPEX.js → item-revision-YDACCDVY.js} +2 -2
  180. package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
  181. package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
  182. package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
  183. package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
  184. package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
  185. package/dist/cli-bundle/main.js +27 -27
  186. package/dist/cli-bundle/sdk-authoring.js +1 -1
  187. package/dist/cli-bundle/sdk-contracts.js +5 -5
  188. package/dist/cli-bundle/sdk-core.js +1 -1
  189. package/dist/cli-bundle/sdk-governance.js +1 -1
  190. package/dist/cli-bundle/sdk-graph.js +1 -1
  191. package/dist/cli-bundle/sdk-merge.js +66 -66
  192. package/dist/cli-bundle/sdk-query.js +1 -1
  193. package/dist/cli-bundle/sdk-runtime.js +1 -1
  194. package/dist/cli-bundle/sdk-testing.js +1 -1
  195. package/dist/cli-bundle/sdk.js +12 -12
  196. package/dist/cli.js +1 -1
  197. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  198. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  199. package/dist/core/checkpoint/mutation-context.js +1 -1
  200. package/dist/core/config/nested-settings.js +1 -1
  201. package/dist/core/config/positional-value.js +1 -1
  202. package/dist/core/diagnostics/remediation.js +1 -1
  203. package/dist/core/extensions/activation-summary-markdown.js +2 -2
  204. package/dist/core/extensions/activation-summary.js +1 -1
  205. package/dist/core/extensions/activation-transaction.js +1 -1
  206. package/dist/core/extensions/capability-usage.js +1 -1
  207. package/dist/core/extensions/command-hook-context.js +1 -1
  208. package/dist/core/extensions/command-metadata-contract.js +1 -1
  209. package/dist/core/extensions/command-visibility-tier.js +1 -1
  210. package/dist/core/extensions/contribution-inventory.js +1 -1
  211. package/dist/core/extensions/exporter-output-contract.js +1 -1
  212. package/dist/core/extensions/extension-candidate.js +1 -1
  213. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  214. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  215. package/dist/core/extensions/extension-policy.js +1 -1
  216. package/dist/core/extensions/extension-registries.js +1 -1
  217. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  218. package/dist/core/extensions/extension-types.js +1 -1
  219. package/dist/core/extensions/flag-definition-validation.js +1 -1
  220. package/dist/core/extensions/flag-value-types.js +1 -1
  221. package/dist/core/extensions/index.js +1 -1
  222. package/dist/core/extensions/item-field-types.js +1 -1
  223. package/dist/core/extensions/item-fields.js +1 -1
  224. package/dist/core/extensions/loader.js +1 -1
  225. package/dist/core/extensions/manifest-parser.js +1 -1
  226. package/dist/core/extensions/manifest-schema.js +1 -1
  227. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  228. package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
  229. package/dist/core/extensions/mutation-actor.js +1 -1
  230. package/dist/core/extensions/preflight-ownership.js +1 -1
  231. package/dist/core/extensions/read-output-contract.js +1 -1
  232. package/dist/core/extensions/registration-contracts.js +1 -1
  233. package/dist/core/extensions/registration-validation.js +1 -1
  234. package/dist/core/extensions/registration-values.js +1 -1
  235. package/dist/core/extensions/reserved-host-flags.js +1 -1
  236. package/dist/core/extensions/runtime-registrations.js +1 -1
  237. package/dist/core/extensions/service-ownership.js +1 -1
  238. package/dist/core/extensions/version-compat.js +1 -1
  239. package/dist/core/extensions/version-diagnostics.js +1 -1
  240. package/dist/core/fs/atomic-create.js +1 -1
  241. package/dist/core/fs/file-glob.js +1 -1
  242. package/dist/core/fs/fs-utils.js +2 -2
  243. package/dist/core/fs/host-environment-errors.js +1 -1
  244. package/dist/core/fs/index.js +1 -1
  245. package/dist/core/fs/path-utils.js +1 -1
  246. package/dist/core/governance/content-fields.js +1 -1
  247. package/dist/core/governance/issue-codes.js +1 -1
  248. package/dist/core/governance/metadata-coverage.js +1 -1
  249. package/dist/core/history/bridge.js +1 -1
  250. package/dist/core/history/digest.js +1 -1
  251. package/dist/core/history/drift-cache.js +3 -3
  252. package/dist/core/history/drift-scan.js +1 -1
  253. package/dist/core/history/event-classification.js +1 -1
  254. package/dist/core/history/event-index.js +11 -11
  255. package/dist/core/history/history-compact-bulk.js +1 -1
  256. package/dist/core/history/history-diff.js +1 -1
  257. package/dist/core/history/history-rewrite.js +1 -1
  258. package/dist/core/history/history-storage-stats.js +1 -1
  259. package/dist/core/history/history-stream-policy.js +1 -1
  260. package/dist/core/history/history.js +2 -2
  261. package/dist/core/history/identity.js +1 -1
  262. package/dist/core/history/index.js +1 -1
  263. package/dist/core/history/operation-contract.js +1 -1
  264. package/dist/core/history/projection.js +1 -1
  265. package/dist/core/history/read.js +1 -1
  266. package/dist/core/history/replay.js +2 -2
  267. package/dist/core/history/stream-summary.js +2 -2
  268. package/dist/core/history/tombstone.js +1 -1
  269. package/dist/core/history/version-address.js +1 -1
  270. package/dist/core/history/workspace-history.js +2 -2
  271. package/dist/core/io/body-file.js +1 -1
  272. package/dist/core/io/bulk-ids-input.js +2 -2
  273. package/dist/core/item/actionability.js +1 -1
  274. package/dist/core/item/deferred-fields.js +1 -1
  275. package/dist/core/item/dependency-reference.js +1 -1
  276. package/dist/core/item/id.js +1 -1
  277. package/dist/core/item/index.js +1 -1
  278. package/dist/core/item/item-format-version.js +1 -1
  279. package/dist/core/item/item-format.js +7 -7
  280. package/dist/core/item/item-record.js +1 -1
  281. package/dist/core/item/item-type-definition.js +1 -1
  282. package/dist/core/item/literal-mutation-input.js +1 -1
  283. package/dist/core/item/parent-reference-policy.js +1 -1
  284. package/dist/core/item/parse.js +8 -8
  285. package/dist/core/item/plan-lifecycle.js +1 -1
  286. package/dist/core/item/priority.js +1 -1
  287. package/dist/core/item/sprint-release-format.js +1 -1
  288. package/dist/core/item/status-filter.js +1 -1
  289. package/dist/core/item/status.js +1 -1
  290. package/dist/core/item/toon-decode.js +1 -1
  291. package/dist/core/item/type-registry.js +1 -1
  292. package/dist/core/item/type-synonyms.js +1 -1
  293. package/dist/core/lock/index.js +1 -1
  294. package/dist/core/lock/lock-confinement.js +1 -1
  295. package/dist/core/lock/lock-gc.js +1 -1
  296. package/dist/core/lock/lock-owner.js +1 -1
  297. package/dist/core/lock/lock.js +4 -4
  298. package/dist/core/output/linked-test-projection.js +5 -5
  299. package/dist/core/output/mutation-projection.js +1 -1
  300. package/dist/core/output/output-control.js +1 -1
  301. package/dist/core/output/output.js +19 -19
  302. package/dist/core/output/query-summary.js +1 -1
  303. package/dist/core/output/tabular.js +3 -3
  304. package/dist/core/packages/manifest.js +1 -1
  305. package/dist/core/packages/root.js +1 -1
  306. package/dist/core/policy/workflow-policy-schema.js +1 -1
  307. package/dist/core/policy/workflow-policy-store.js +1 -1
  308. package/dist/core/policy/workflow-policy.js +1 -1
  309. package/dist/core/profile/profile-describe.js +1 -1
  310. package/dist/core/profile/profile-lint.d.ts +1 -1
  311. package/dist/core/profile/profile-lint.js +1 -1
  312. package/dist/core/profile/profile-plan.js +1 -1
  313. package/dist/core/profile/profile-presets.js +4 -4
  314. package/dist/core/reproducibility/context.js +1 -1
  315. package/dist/core/schema/fields-file.js +2 -2
  316. package/dist/core/schema/item-types-file.js +2 -2
  317. package/dist/core/schema/runtime-field-filters.js +1 -1
  318. package/dist/core/schema/runtime-field-values.js +1 -1
  319. package/dist/core/schema/runtime-schema.js +2 -2
  320. package/dist/core/schema/status-defs-file.js +2 -2
  321. package/dist/core/schema/status-token.js +1 -1
  322. package/dist/core/schema/type-inference.js +1 -1
  323. package/dist/core/schema/type-presets.js +1 -1
  324. package/dist/core/schema/type-workflows.js +1 -1
  325. package/dist/core/search/background-refresh.js +2 -2
  326. package/dist/core/search/bm25.js +1 -1
  327. package/dist/core/search/cache.js +2 -2
  328. package/dist/core/search/corpus.js +1 -1
  329. package/dist/core/search/embedding-batches.js +1 -1
  330. package/dist/core/search/eval-thresholds.js +1 -1
  331. package/dist/core/search/eval.js +1 -1
  332. package/dist/core/search/http-client.js +1 -1
  333. package/dist/core/search/providers.js +1 -1
  334. package/dist/core/search/relevance.js +1 -1
  335. package/dist/core/search/semantic-defaults.js +1 -1
  336. package/dist/core/search/staleness.js +1 -1
  337. package/dist/core/search/vector-stores.js +2 -2
  338. package/dist/core/search/vectorization-metadata.js +1 -1
  339. package/dist/core/sentry/helpers.js +1 -1
  340. package/dist/core/sentry/instrument.js +1 -1
  341. package/dist/core/sentry/sensitive-assignments.js +1 -1
  342. package/dist/core/session/session-state.js +1 -1
  343. package/dist/core/shared/agent-session-context.js +1 -1
  344. package/dist/core/shared/author.js +5 -5
  345. package/dist/core/shared/command-line.js +1 -1
  346. package/dist/core/shared/command-types.js +0 -1
  347. package/dist/core/shared/conflict-markers.js +1 -1
  348. package/dist/core/shared/constants.js +1 -1
  349. package/dist/core/shared/error-details.js +1 -1
  350. package/dist/core/shared/errors.js +1 -1
  351. package/dist/core/shared/html-entity-decode.js +1 -1
  352. package/dist/core/shared/index.js +1 -1
  353. package/dist/core/shared/item-metadata-contract.js +1 -1
  354. package/dist/core/shared/lazy-module.js +1 -1
  355. package/dist/core/shared/levenshtein.js +1 -1
  356. package/dist/core/shared/memo.js +1 -1
  357. package/dist/core/shared/numeric-parsers.js +1 -1
  358. package/dist/core/shared/option-alias-visibility.js +1 -1
  359. package/dist/core/shared/output-unicode.js +1 -1
  360. package/dist/core/shared/primitives.js +1 -1
  361. package/dist/core/shared/process-tree.js +2 -2
  362. package/dist/core/shared/secret-rules.js +5 -5
  363. package/dist/core/shared/serial-queue.js +1 -1
  364. package/dist/core/shared/serialization.js +1 -1
  365. package/dist/core/shared/split-comma-list.js +1 -1
  366. package/dist/core/shared/text-normalization.js +1 -1
  367. package/dist/core/shared/time.js +2 -2
  368. package/dist/core/shared/url-credentials.js +1 -1
  369. package/dist/core/store/index.js +1 -1
  370. package/dist/core/store/item-format-migration.js +1 -1
  371. package/dist/core/store/item-metadata-cache.js +1 -1
  372. package/dist/core/store/item-metadata-query-index.js +11 -11
  373. package/dist/core/store/item-metadata-read-work.js +1 -1
  374. package/dist/core/store/item-mutation-precondition.js +1 -1
  375. package/dist/core/store/item-store.js +1 -1
  376. package/dist/core/store/paths.js +1 -1
  377. package/dist/core/store/settings-concurrency.js +1 -1
  378. package/dist/core/store/settings-read-cache.js +1 -1
  379. package/dist/core/store/settings-sections.js +2 -2
  380. package/dist/core/store/settings-validator.js +1 -1
  381. package/dist/core/store/settings.d.ts +3 -1
  382. package/dist/core/store/settings.js +6 -6
  383. package/dist/core/store/sqlite-runtime.js +1 -1
  384. package/dist/core/store/tracker-preflight.js +1 -1
  385. package/dist/core/store/transaction-coordinator-scope.js +1 -1
  386. package/dist/core/telemetry/consent.js +3 -3
  387. package/dist/core/telemetry/observability.js +1 -1
  388. package/dist/core/telemetry/policy.js +1 -1
  389. package/dist/core/telemetry/read-sampling.js +2 -2
  390. package/dist/core/telemetry/runtime.js +9 -9
  391. package/dist/core/test/background-runs.js +4 -4
  392. package/dist/core/test/item-test-run-tracking.js +1 -1
  393. package/dist/core/test/run-selectors.js +1 -1
  394. package/dist/core/validate/estimate-defaults.js +1 -1
  395. package/dist/core/validate/fix-planning.js +1 -1
  396. package/dist/core/validate/linked-artifact-reference.js +1 -1
  397. package/dist/core/validate/missing-by-type.js +1 -1
  398. package/dist/core/validate/missing-link-owners.js +1 -1
  399. package/dist/core/validate/stale-file-classification.js +1 -1
  400. package/dist/mcp/http-server.js +5 -5
  401. package/dist/mcp/legacy-adapter.js +1 -1
  402. package/dist/mcp/runtime-capabilities.js +1 -1
  403. package/dist/mcp/server.js +4 -4
  404. package/dist/mcp/tool-definitions.js +1 -1
  405. package/dist/sdk/actionability.js +1 -1
  406. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  407. package/dist/sdk/agent/command-recovery.js +1 -1
  408. package/dist/sdk/agent/command-suggestions.js +1 -1
  409. package/dist/sdk/agent/create-option-policy.js +1 -1
  410. package/dist/sdk/agent/identity-config.js +1 -1
  411. package/dist/sdk/agent/item-addressing.js +1 -1
  412. package/dist/sdk/agent/linked-resource-recovery.js +1 -1
  413. package/dist/sdk/agent/refusal-closure-census.js +2 -2
  414. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  415. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  416. package/dist/sdk/agent-capability-contracts.js +3 -3
  417. package/dist/sdk/agent-session-context.js +1 -1
  418. package/dist/sdk/annotations.js +1 -1
  419. package/dist/sdk/author-attribution.js +1 -1
  420. package/dist/sdk/cli-bootstrap.js +1 -1
  421. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
  422. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  423. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  424. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  425. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  426. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  427. package/dist/sdk/cli-contracts/completeness.js +1 -1
  428. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  429. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  430. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
  431. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  432. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  433. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  434. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  435. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  436. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  437. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  438. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  439. package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
  440. package/dist/sdk/cli-contracts.js +1 -1
  441. package/dist/sdk/cli-program.js +1 -1
  442. package/dist/sdk/command-line.js +1 -1
  443. package/dist/sdk/comments.js +1 -1
  444. package/dist/sdk/compile-cache.js +1 -1
  445. package/dist/sdk/completion/bash.js +2 -2
  446. package/dist/sdk/completion/fish.js +72 -72
  447. package/dist/sdk/completion/shared.js +1 -1
  448. package/dist/sdk/completion/zsh.js +75 -75
  449. package/dist/sdk/completion.js +1 -1
  450. package/dist/sdk/config.js +1 -1
  451. package/dist/sdk/context/recency.js +1 -1
  452. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  453. package/dist/sdk/context/usage-egress.js +1 -1
  454. package/dist/sdk/context/usage-ledger.js +6 -6
  455. package/dist/sdk/context-intent-contracts.js +1 -1
  456. package/dist/sdk/context-intent-runtime.js +1 -1
  457. package/dist/sdk/context-packing.js +1 -1
  458. package/dist/sdk/context-relevance.js +1 -1
  459. package/dist/sdk/context-signal-store.js +2 -2
  460. package/dist/sdk/context-usage.js +1 -1
  461. package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
  462. package/dist/sdk/dependencies.js +1 -1
  463. package/dist/sdk/dependency-flag-validation.js +1 -1
  464. package/dist/sdk/dependency-provenance.js +1 -1
  465. package/dist/sdk/docs.js +1 -1
  466. package/dist/sdk/duplicates.js +1 -1
  467. package/dist/sdk/environment/host-environment-errors.js +1 -1
  468. package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
  469. package/dist/sdk/environment/source-context.js +1 -1
  470. package/dist/sdk/environment/tracker-preflight.js +1 -1
  471. package/dist/sdk/error-code-catalog.js +1 -1
  472. package/dist/sdk/error-runtime.js +1 -1
  473. package/dist/sdk/errors.js +1 -1
  474. package/dist/sdk/eval.js +1 -1
  475. package/dist/sdk/extension/author-manifest.js +1 -1
  476. package/dist/sdk/extension/bundled-catalog.js +1 -1
  477. package/dist/sdk/extension/command-options.js +1 -1
  478. package/dist/sdk/extension/concurrency.js +1 -1
  479. package/dist/sdk/extension/copy-scope.js +1 -1
  480. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  481. package/dist/sdk/extension/describe.js +3 -3
  482. package/dist/sdk/extension/doctor.js +1 -1
  483. package/dist/sdk/extension/install-plan.js +1 -1
  484. package/dist/sdk/extension/install-receipts.js +1 -1
  485. package/dist/sdk/extension/install-runtime.js +3 -3
  486. package/dist/sdk/extension/install-snapshot.js +1 -1
  487. package/dist/sdk/extension/install-sources.js +5 -5
  488. package/dist/sdk/extension/managed-state.js +2 -2
  489. package/dist/sdk/extension/managed-update-status.js +1 -1
  490. package/dist/sdk/extension/migrations.js +2 -2
  491. package/dist/sdk/extension/native-command-options.js +1 -1
  492. package/dist/sdk/extension/output-ownership.js +1 -1
  493. package/dist/sdk/extension/runtime-summary.js +1 -1
  494. package/dist/sdk/extension/scaffold.js +11 -11
  495. package/dist/sdk/extension/shared.js +1 -1
  496. package/dist/sdk/extension/source-resolution.js +1 -1
  497. package/dist/sdk/extension/static-inventory.js +1 -1
  498. package/dist/sdk/extension/update-check.js +1 -1
  499. package/dist/sdk/extension-command-context.js +2 -2
  500. package/dist/sdk/extension-contracts.js +1 -1
  501. package/dist/sdk/extension.js +1 -1
  502. package/dist/sdk/files.js +1 -1
  503. package/dist/sdk/flag-invocation-contracts.js +1 -1
  504. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  505. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  506. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  507. package/dist/sdk/generated-error-code-catalog.js +1 -1
  508. package/dist/sdk/governance/assurance-action-contracts.js +0 -1
  509. package/dist/sdk/governance/assurance-action.js +1 -1
  510. package/dist/sdk/governance/assurance-limits.js +1 -1
  511. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  512. package/dist/sdk/governance/assurance-presets.js +1 -1
  513. package/dist/sdk/governance/assurance-runtime.js +1 -1
  514. package/dist/sdk/governance/assurance.js +4 -4
  515. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  516. package/dist/sdk/governance/closure-timestamps.js +1 -1
  517. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  518. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  519. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  520. package/dist/sdk/governance/defect-recurrence.js +2 -2
  521. package/dist/sdk/governance/extension-host-version.js +1 -1
  522. package/dist/sdk/governance/gc.js +1 -1
  523. package/dist/sdk/governance/health/history-drift-remedies.js +1 -1
  524. package/dist/sdk/governance/health/projection.js +1 -1
  525. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  526. package/dist/sdk/governance/health.js +2 -2
  527. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  528. package/dist/sdk/governance/in-progress-work-health.js +1 -1
  529. package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
  530. package/dist/sdk/governance/linked-file-report.js +1 -1
  531. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  532. package/dist/sdk/governance/provenance-health.js +4 -4
  533. package/dist/sdk/governance/reindex.js +5 -5
  534. package/dist/sdk/governance/stale-work.js +1 -1
  535. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  536. package/dist/sdk/governance/storage-integrity.js +1 -1
  537. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  538. package/dist/sdk/governance/upgrade.js +2 -2
  539. package/dist/sdk/governance/validate-deferred-fields.js +1 -1
  540. package/dist/sdk/governance/validate-history-drift.js +1 -1
  541. package/dist/sdk/governance/validate-item-reader.js +1 -1
  542. package/dist/sdk/governance/validate-normalization.js +1 -1
  543. package/dist/sdk/governance/validate.js +1 -1
  544. package/dist/sdk/governance/workflow-completeness.js +1 -1
  545. package/dist/sdk/governance/workflow-policy.js +3 -3
  546. package/dist/sdk/governance/workspace-position.js +2 -2
  547. package/dist/sdk/graph/analytics.js +1 -1
  548. package/dist/sdk/graph/assembly.js +1 -1
  549. package/dist/sdk/graph/cache.js +1 -1
  550. package/dist/sdk/graph/cardinality-integrity.js +1 -1
  551. package/dist/sdk/graph/centrality.js +1 -1
  552. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  553. package/dist/sdk/graph/durable-cache.js +1 -1
  554. package/dist/sdk/graph/governance-contracts.js +1 -1
  555. package/dist/sdk/graph/governance.js +1 -1
  556. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  557. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  558. package/dist/sdk/graph/mutation-advisory.js +1 -1
  559. package/dist/sdk/graph/query-contracts.js +1 -1
  560. package/dist/sdk/graph/remediation.js +1 -1
  561. package/dist/sdk/graph/run.js +1 -1
  562. package/dist/sdk/graph/scheduling.js +1 -1
  563. package/dist/sdk/graph/traversal.js +1 -1
  564. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  565. package/dist/sdk/guide-topics.js +1 -1
  566. package/dist/sdk/guide.js +7 -7
  567. package/dist/sdk/history/append-only-repair.js +4 -4
  568. package/dist/sdk/history/attestation-command.js +2 -2
  569. package/dist/sdk/history/attestation-contract.js +1 -1
  570. package/dist/sdk/history/attestation-scan.js +1 -1
  571. package/dist/sdk/history/attestation.js +1 -1
  572. package/dist/sdk/history/maintenance.js +1 -1
  573. package/dist/sdk/history/reanchor-refusal.js +1 -1
  574. package/dist/sdk/history/reseed.js +1 -1
  575. package/dist/sdk/history/salvage.js +5 -5
  576. package/dist/sdk/history/subject.js +1 -1
  577. package/dist/sdk/history-analytics.js +1 -1
  578. package/dist/sdk/history-compact.js +1 -1
  579. package/dist/sdk/history-mcp.js +1 -1
  580. package/dist/sdk/history-provenance.js +1 -1
  581. package/dist/sdk/history-read.js +1 -1
  582. package/dist/sdk/history-redact.js +1 -1
  583. package/dist/sdk/history-repair.js +1 -1
  584. package/dist/sdk/improvement-ledger-validation.js +1 -1
  585. package/dist/sdk/improvement-ledger.js +2 -2
  586. package/dist/sdk/init-agent-guidance.js +10 -10
  587. package/dist/sdk/init.js +14 -14
  588. package/dist/sdk/invocation-author.js +1 -1
  589. package/dist/sdk/item-children.js +1 -1
  590. package/dist/sdk/item-metadata-index.js +1 -1
  591. package/dist/sdk/item-schedule.js +1 -1
  592. package/dist/sdk/item-transaction.js +1 -1
  593. package/dist/sdk/learnings.js +1 -1
  594. package/dist/sdk/lifecycle/append.js +3 -3
  595. package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
  596. package/dist/sdk/lifecycle/claim.js +1 -1
  597. package/dist/sdk/lifecycle/cli-input.js +1 -1
  598. package/dist/sdk/lifecycle/close-many.js +1 -1
  599. package/dist/sdk/lifecycle/close.js +1 -1
  600. package/dist/sdk/lifecycle/copy.js +1 -1
  601. package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
  602. package/dist/sdk/lifecycle/core-item-fields.js +1 -1
  603. package/dist/sdk/lifecycle/create-deferrals.js +1 -1
  604. package/dist/sdk/lifecycle/create.js +1 -1
  605. package/dist/sdk/lifecycle/delete.js +1 -1
  606. package/dist/sdk/lifecycle/dependency-removal.js +1 -1
  607. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  608. package/dist/sdk/lifecycle/focus.js +1 -1
  609. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  610. package/dist/sdk/lifecycle/item-revision.js +1 -1
  611. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  612. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  613. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  614. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  615. package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
  616. package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
  617. package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
  618. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  619. package/dist/sdk/lifecycle/plan.js +1 -1
  620. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  621. package/dist/sdk/lifecycle/release-handoff.js +1 -1
  622. package/dist/sdk/lifecycle/reopen.js +1 -1
  623. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
  624. package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
  625. package/dist/sdk/lifecycle/restore.js +1 -1
  626. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  627. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  628. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  629. package/dist/sdk/lifecycle/task-composition.js +1 -1
  630. package/dist/sdk/lifecycle/update-many.js +1 -1
  631. package/dist/sdk/lifecycle/update.js +2 -2
  632. package/dist/sdk/lifecycle/workflow-transition.js +1 -1
  633. package/dist/sdk/lifecycle-completion.js +1 -1
  634. package/dist/sdk/lifecycle-policy.js +1 -1
  635. package/dist/sdk/linked-artifacts.js +2 -2
  636. package/dist/sdk/mcp/apps.js +5 -5
  637. package/dist/sdk/mcp/authorization.js +1 -1
  638. package/dist/sdk/mcp/discovery.js +1 -1
  639. package/dist/sdk/mcp/executable.js +4 -4
  640. package/dist/sdk/mcp/interactions.js +1 -1
  641. package/dist/sdk/mcp/protocol.js +1 -1
  642. package/dist/sdk/mcp/skills.js +3 -3
  643. package/dist/sdk/mcp/subscriptions.js +1 -1
  644. package/dist/sdk/mcp/tasks.js +2 -2
  645. package/dist/sdk/mcp/transport.js +1 -1
  646. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  647. package/dist/sdk/merge/driver.js +7 -7
  648. package/dist/sdk/merge/history-scalar-rebase.js +1 -1
  649. package/dist/sdk/merge/ignored-artifacts.js +1 -1
  650. package/dist/sdk/merge/index.js +1 -1
  651. package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
  652. package/dist/sdk/merge/install.js +6 -6
  653. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  654. package/dist/sdk/merge/receipt-operation.js +1 -1
  655. package/dist/sdk/merge/receipt-schema.js +1 -1
  656. package/dist/sdk/merge/receipts.js +4 -4
  657. package/dist/sdk/merge/reconcile.js +1 -1
  658. package/dist/sdk/merge/settlement-hook.js +4 -4
  659. package/dist/sdk/merge/stage.js +1 -1
  660. package/dist/sdk/merge/three-way.js +9 -9
  661. package/dist/sdk/merge/worktree-config.js +2 -2
  662. package/dist/sdk/merge.js +1 -1
  663. package/dist/sdk/mutation-events.js +1 -1
  664. package/dist/sdk/mutation-guard.js +1 -1
  665. package/dist/sdk/notes.js +1 -1
  666. package/dist/sdk/output/fit-envelope.js +1 -1
  667. package/dist/sdk/output/list-envelope.js +1 -1
  668. package/dist/sdk/output/table-rows.js +1 -1
  669. package/dist/sdk/output-contracts.js +1 -1
  670. package/dist/sdk/output-projection.js +1 -1
  671. package/dist/sdk/output-token-accounting.js +1 -1
  672. package/dist/sdk/output.js +2 -2
  673. package/dist/sdk/ownership-source.js +1 -1
  674. package/dist/sdk/package-import-adapters.js +1 -1
  675. package/dist/sdk/package-migrations.js +1 -1
  676. package/dist/sdk/package-runtime-options.js +1 -1
  677. package/dist/sdk/pagination.js +1 -1
  678. package/dist/sdk/profile.js +5 -5
  679. package/dist/sdk/provenance.js +1 -1
  680. package/dist/sdk/public-surface.json +1 -1
  681. package/dist/sdk/query/activity.js +1 -1
  682. package/dist/sdk/query/aggregate.js +1 -1
  683. package/dist/sdk/query/calendar.js +4 -4
  684. package/dist/sdk/query/complete-list.js +1 -1
  685. package/dist/sdk/query/context.js +2 -2
  686. package/dist/sdk/query/declared-blockers.js +1 -1
  687. package/dist/sdk/query/duplicate-candidates.js +1 -1
  688. package/dist/sdk/query/get-facet-roots.js +1 -1
  689. package/dist/sdk/query/get.js +1 -1
  690. package/dist/sdk/query/history.js +1 -1
  691. package/dist/sdk/query/item-filter-options.js +0 -1
  692. package/dist/sdk/query/light-metadata.js +1 -1
  693. package/dist/sdk/query/list-filter-shared.js +1 -1
  694. package/dist/sdk/query/list.js +1 -1
  695. package/dist/sdk/query/multi-value-filters.js +1 -1
  696. package/dist/sdk/query/next-ranking-policy.js +1 -1
  697. package/dist/sdk/query/next-ready-budget.js +1 -1
  698. package/dist/sdk/query/next.js +2 -2
  699. package/dist/sdk/query/parsers.js +1 -1
  700. package/dist/sdk/query/projection-contracts.js +1 -1
  701. package/dist/sdk/query/search/corpus.js +2 -2
  702. package/dist/sdk/query/search/filters.js +1 -1
  703. package/dist/sdk/query/search/input.js +1 -1
  704. package/dist/sdk/query/search/lexical.js +1 -1
  705. package/dist/sdk/query/search/response.js +1 -1
  706. package/dist/sdk/query/search/semantic.js +3 -3
  707. package/dist/sdk/query/search/types.js +0 -1
  708. package/dist/sdk/query/search-contracts.js +1 -1
  709. package/dist/sdk/query/search-pagination.js +1 -1
  710. package/dist/sdk/query/search-rendering.js +1 -1
  711. package/dist/sdk/query/search.js +1 -1
  712. package/dist/sdk/query/window-pagination.js +1 -1
  713. package/dist/sdk/query/workspace-contracts.js +1 -1
  714. package/dist/sdk/read-output/continuation.js +1 -1
  715. package/dist/sdk/read-output/extension.js +1 -1
  716. package/dist/sdk/read-output/options.js +1 -1
  717. package/dist/sdk/read-output/positional-rows.js +1 -1
  718. package/dist/sdk/read-output/provenance.js +1 -1
  719. package/dist/sdk/read-output/session-result.js +0 -1
  720. package/dist/sdk/read-output/surfaces.js +1 -1
  721. package/dist/sdk/read-output/tail-retention.js +1 -1
  722. package/dist/sdk/read-output-budget.js +1 -1
  723. package/dist/sdk/read-output-contracts.js +1 -1
  724. package/dist/sdk/read-output-rows.js +1 -1
  725. package/dist/sdk/read-output-session.js +1 -1
  726. package/dist/sdk/relationship-analytics.js +1 -1
  727. package/dist/sdk/relationship-context.js +1 -1
  728. package/dist/sdk/relationship-history.js +6 -6
  729. package/dist/sdk/relationship-kinds/contract.js +1 -1
  730. package/dist/sdk/relationships.js +1 -1
  731. package/dist/sdk/reproducibility/process.js +1 -1
  732. package/dist/sdk/runtime/actions.js +1 -1
  733. package/dist/sdk/runtime/context.js +1 -1
  734. package/dist/sdk/runtime/mutation-admission.js +1 -1
  735. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  736. package/dist/sdk/runtime/schema-preview.js +1 -1
  737. package/dist/sdk/runtime/schema.js +1 -1
  738. package/dist/sdk/runtime-action-aliases.js +1 -1
  739. package/dist/sdk/runtime-extended-actions.js +1 -1
  740. package/dist/sdk/runtime-input.d.ts +2 -0
  741. package/dist/sdk/runtime-input.js +1 -1
  742. package/dist/sdk/runtime-primitives.js +1 -1
  743. package/dist/sdk/runtime-public-contracts.js +0 -1
  744. package/dist/sdk/runtime-stats-options.js +1 -1
  745. package/dist/sdk/runtime.d.ts +5 -3
  746. package/dist/sdk/runtime.js +1 -1
  747. package/dist/sdk/scheduling-shortcuts.js +1 -1
  748. package/dist/sdk/schema/field-option-collisions.js +2 -0
  749. package/dist/sdk/schema-migration.js +4 -4
  750. package/dist/sdk/schema.js +7 -7
  751. package/dist/sdk/search-refresh-worker.js +1 -1
  752. package/dist/sdk/similarity-scoring.js +1 -1
  753. package/dist/sdk/similarity.js +1 -1
  754. package/dist/sdk/start-task-status.js +1 -1
  755. package/dist/sdk/stats.js +1 -1
  756. package/dist/sdk/structured-mutations.js +1 -1
  757. package/dist/sdk/telemetry-flush.js +1 -1
  758. package/dist/sdk/telemetry.js +4 -4
  759. package/dist/sdk/templates.js +3 -3
  760. package/dist/sdk/test/batch.js +2 -2
  761. package/dist/sdk/test/command-args.js +1 -1
  762. package/dist/sdk/test/command-resolution.js +2 -2
  763. package/dist/sdk/test/entry.js +2 -2
  764. package/dist/sdk/test/execution-receipts.js +2 -2
  765. package/dist/sdk/test/execution.js +5 -5
  766. package/dist/sdk/test/json-path.js +1 -1
  767. package/dist/sdk/test/linked-command-detection.js +1 -1
  768. package/dist/sdk/test/measurements.js +1 -1
  769. package/dist/sdk/test/parsers.js +1 -1
  770. package/dist/sdk/test/prerequisites.js +1 -1
  771. package/dist/sdk/test/receipt-index-snapshot.js +1 -1
  772. package/dist/sdk/test/run-phases.js +1 -1
  773. package/dist/sdk/test/runs.js +1 -1
  774. package/dist/sdk/test/trust.js +2 -2
  775. package/dist/sdk/test/update.js +1 -1
  776. package/dist/sdk/test/workspace-snapshot.js +1 -1
  777. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  778. package/dist/sdk/traceability/source-traceability.js +2 -2
  779. package/dist/sdk/tracker-root-discovery.js +1 -1
  780. package/dist/sdk/transactions/item-finalization.js +1 -1
  781. package/dist/sdk/workspace-contracts-cache.js +1 -1
  782. package/dist/sdk/workspace-contracts.js +1 -1
  783. package/dist/sdk/workspace-memory.js +2 -2
  784. package/dist/sdk/workspace-snapshot.js +5 -5
  785. package/dist/sdk/workspace-transaction-gc.js +1 -1
  786. package/dist/sdk/workspace-transaction.js +2 -2
  787. package/dist/sdk/workspace.js +6 -6
  788. package/dist/types/index.js +1 -1
  789. package/dist/types.js +1 -1
  790. package/docs/COMMANDS.md +1 -1
  791. package/docs/EXTENSIONS.md +1 -1
  792. package/docs/SDK.md +74 -4
  793. package/marketplace.json +1 -1
  794. package/package.json +2 -1
  795. package/packages/pm-beads/package.json +1 -1
  796. package/packages/pm-calendar/package.json +1 -1
  797. package/packages/pm-command-kit/package.json +1 -1
  798. package/packages/pm-digital-twin/package.json +1 -1
  799. package/packages/pm-governance-audit/package.json +1 -1
  800. package/packages/pm-guide-shell/package.json +1 -1
  801. package/packages/pm-kanban/package.json +1 -1
  802. package/packages/pm-lifecycle-hooks/package.json +1 -1
  803. package/packages/pm-linked-test-adapters/package.json +1 -1
  804. package/packages/pm-search-advanced/package.json +1 -1
  805. package/packages/pm-templates/package.json +1 -1
  806. package/packages/pm-todos/package.json +1 -1
  807. package/packages/pm-vcs/package.json +1 -1
  808. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  809. package/plugins/pm-claude/package.json +1 -1
  810. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  811. package/plugins/pm-codex/package.json +1 -1
  812. package/plugins/pm-codex/plugin.json +1 -1
  813. package/runtime-dependencies.json +1 -1
  814. package/scripts/finalize-build.mjs +63 -24
  815. package/scripts/prepare-build-cache.mjs +28 -1
  816. package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +0 -9
  817. package/dist/cli-bundle/chunks/chunk-4TB5D6HL.js +0 -125
  818. package/dist/cli-bundle/chunks/chunk-5ZMVLWE3.js +0 -2
  819. package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +0 -33
  820. package/dist/cli-bundle/chunks/chunk-AR4NP5HI.js +0 -3
  821. package/dist/cli-bundle/chunks/chunk-B4PPFOPY.js +0 -3
  822. package/dist/cli-bundle/chunks/chunk-CAR2L5NW.js +0 -8
  823. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  824. package/dist/cli-bundle/chunks/chunk-EIGUKEV6.js +0 -2
  825. package/dist/cli-bundle/chunks/chunk-GTPCAJMZ.js +0 -8
  826. package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +0 -2
  827. package/dist/cli-bundle/chunks/chunk-HC2OPETM.js +0 -2
  828. package/dist/cli-bundle/chunks/chunk-HKUV74K3.js +0 -2
  829. package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +0 -115
  830. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
  831. package/dist/cli-bundle/chunks/chunk-J2LABXBL.js +0 -2
  832. package/dist/cli-bundle/chunks/chunk-J52BEBSS.js +0 -2
  833. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
  834. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
  835. package/dist/cli-bundle/chunks/chunk-OJTMGDON.js +0 -31
  836. package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
  837. package/dist/cli-bundle/chunks/chunk-TC6XLIYO.js +0 -2
  838. package/dist/cli-bundle/chunks/chunk-U7EL3AYA.js +0 -3
  839. package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +0 -6
  840. package/dist/cli-bundle/chunks/chunk-X6MIWTTT.js +0 -2
  841. package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +0 -2
  842. package/dist/cli-bundle/chunks/chunk-XFHPKXAE.js +0 -71
  843. package/dist/cli-bundle/chunks/chunk-YHVLVSEZ.js +0 -9
  844. package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
  845. package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
  846. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
  847. package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
  848. package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +0 -2
  849. package/dist/cli-bundle/chunks/mutation-actor-FWLYWJ37.js +0 -2
  850. package/dist/cli-bundle/chunks/mutation-admission-7ZDCK3G2.js +0 -2
  851. package/dist/cli-bundle/chunks/register-mutation-57AJQWFV.js +0 -21
  852. package/dist/cli-bundle/chunks/register-operations-RKWST7CU.js +0 -2
  853. package/dist/cli-bundle/chunks/register-setup-CMI23PC5.js +0 -2
  854. package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
  855. package/dist/cli-bundle/chunks/stage-4KDVXC5Z.js +0 -2
  856. package/dist/cli-bundle/focused-chunks/chunk-2ZD7275J.js +0 -2
  857. package/dist/cli-bundle/focused-chunks/chunk-324AHXJO.js +0 -2
  858. package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
  859. package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
  860. package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +0 -91
  861. package/dist/cli-bundle/focused-chunks/chunk-4JZITIJB.js +0 -2
  862. package/dist/cli-bundle/focused-chunks/chunk-4KTFKSS3.js +0 -2
  863. package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +0 -78
  864. package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +0 -2
  865. package/dist/cli-bundle/focused-chunks/chunk-BRZV7BFV.js +0 -8
  866. package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
  867. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
  868. package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
  869. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
  870. package/dist/cli-bundle/focused-chunks/chunk-HDEKFSOK.js +0 -2
  871. package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
  872. package/dist/cli-bundle/focused-chunks/chunk-IWOXAUDU.js +0 -2
  873. package/dist/cli-bundle/focused-chunks/chunk-ML3JHCC6.js +0 -6
  874. package/dist/cli-bundle/focused-chunks/chunk-OPGOOP25.js +0 -2
  875. package/dist/cli-bundle/focused-chunks/chunk-RE7ZWT7D.js +0 -27
  876. package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +0 -3
  877. package/dist/cli-bundle/focused-chunks/chunk-RQ252B6V.js +0 -8
  878. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
  879. package/dist/cli-bundle/focused-chunks/chunk-URGHTTT3.js +0 -8
  880. package/dist/cli-bundle/focused-chunks/chunk-USPYKWQG.js +0 -13
  881. package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +0 -102
  882. package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +0 -44
  883. package/dist/cli-bundle/focused-chunks/chunk-WZWXGDYY.js +0 -26
  884. package/dist/cli-bundle/focused-chunks/chunk-YKSLZPLT.js +0 -2
  885. package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +0 -2
  886. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
  887. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
  888. package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +0 -2
  889. package/dist/cli-bundle/focused-chunks/mutation-actor-TCYDPUGG.js +0 -2
  890. package/dist/cli-bundle/focused-chunks/mutation-admission-LY73EJWM.js +0 -2
  891. package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
  892. package/dist/cli-bundle/focused-chunks/stage-DQ7RQQ52.js +0 -2
@@ -1,4 +1,4 @@
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]="59d16a38-d6df-5695-96e3-28b6e384f76b")}catch{}})();import{TYPE_PRESET_DEFINITIONS}from"../schema/type-presets.js";const PROFILE_NAMES=["agile","ops","research"],BUILTIN_PROFILES={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:TYPE_PRESET_DEFINITIONS.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
1
+ import{TYPE_PRESET_DEFINITIONS as l}from"../schema/type-presets.js";const r=["agile","ops","research"],p={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:l.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
2
2
 
3
3
  ## I want
4
4
 
@@ -6,7 +6,7 @@
6
6
 
7
7
  ## Acceptance
8
8
  - [ ]
9
- `}}],packages:[{spec:"templates",reason:"Reusable create templates for recurring story shapes."},{spec:"calendar",reason:"Sprint and iteration scheduling views."},{spec:"search-advanced",reason:"Richer retrieval as the backlog grows."}]},ops:{name:"ops",title:"Operations",summary:"Incident/Runbook response with mitigation and monitoring stages, severity, and service fields.",types:TYPE_PRESET_DEFINITIONS.ops,statuses:[{id:"mitigating",roles:["active"],aliases:["mitigation"],description:"Active mitigation is underway to restore service."},{id:"monitoring",roles:["active"],aliases:["observing"],description:"Mitigation applied; monitoring for recurrence before closure."}],fields:[{key:"severity",type:"string",commands:["create","update","list"],description:"Incident severity classification (e.g. sev1, sev2, sev3).",aliases:["sev"]},{key:"service",type:"string",commands:["create","update","list"],description:"Primary affected service or component."}],workflows:[{type:"Incident",allowed_transitions:[["open","mitigating"],["mitigating","monitoring"],["monitoring","mitigating"],["monitoring","closed"],["mitigating","blocked"],["blocked","mitigating"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search for fast incident lookup."},{key:"search_max_results",value:"25",summary:"Wider result cap to surface related incidents and runbooks."}],templates:[{name:"incident",options:{type:"Incident",priority:"1",tags:"incident",acceptanceCriteria:"Service restored, root cause documented, and follow-ups filed.",body:`## Impact
9
+ `}}],packages:[{spec:"templates",reason:"Reusable create templates for recurring story shapes."},{spec:"calendar",reason:"Sprint and iteration scheduling views."},{spec:"search-advanced",reason:"Richer retrieval as the backlog grows."}]},ops:{name:"ops",title:"Operations",summary:"Incident/Runbook response with mitigation and monitoring stages, severity, and service fields.",types:l.ops,statuses:[{id:"mitigating",roles:["active"],aliases:["mitigation"],description:"Active mitigation is underway to restore service."},{id:"monitoring",roles:["active"],aliases:["observing"],description:"Mitigation applied; monitoring for recurrence before closure."}],fields:[{key:"severity",type:"string",commands:["create","update","list"],description:"Incident severity classification (e.g. sev1, sev2, sev3).",aliases:["sev"]},{key:"service",type:"string",commands:["create","update","list"],description:"Primary affected service or component."}],workflows:[{type:"Incident",allowed_transitions:[["open","mitigating"],["mitigating","monitoring"],["monitoring","mitigating"],["monitoring","closed"],["mitigating","blocked"],["blocked","mitigating"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search for fast incident lookup."},{key:"search_max_results",value:"25",summary:"Wider result cap to surface related incidents and runbooks."}],templates:[{name:"incident",options:{type:"Incident",priority:"1",tags:"incident",acceptanceCriteria:"Service restored, root cause documented, and follow-ups filed.",body:`## Impact
10
10
 
11
11
  ## Timeline
12
12
 
@@ -15,12 +15,12 @@
15
15
  ## Mitigation
16
16
 
17
17
  ## Follow-ups
18
- `}}],packages:[{spec:"lifecycle-hooks",reason:"Automate transitions and notifications on incident state changes."},{spec:"governance-audit",reason:"Audit incident metadata completeness and closure quality."},{spec:"calendar",reason:"On-call and follow-up scheduling."}]},research:{name:"research",title:"Research",summary:"Experiment/Hypothesis investigation with an analysis stage, hypothesis, and method fields.",types:TYPE_PRESET_DEFINITIONS.research,statuses:[{id:"analyzing",roles:["active"],aliases:["analysis"],description:"Data collected; analysis and synthesis in progress."}],fields:[{key:"hypothesis",type:"string",commands:["create","update"],description:"The testable claim the experiment evaluates."},{key:"method",type:"string",commands:["create","update","list"],description:"Experimental method or protocol used to evaluate the hypothesis.",aliases:["protocol"]}],workflows:[{type:"Experiment",allowed_transitions:[["open","in_progress"],["in_progress","analyzing"],["analyzing","in_progress"],["analyzing","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search across the research corpus."},{key:"search_max_results",value:"50",summary:"Broader recall cap for literature and prior-experiment discovery."}],templates:[{name:"experiment",options:{type:"Experiment",priority:"2",tags:"experiment",acceptanceCriteria:"Hypothesis is supported, rejected, or refined with recorded evidence.",body:`## Hypothesis
18
+ `}}],packages:[{spec:"lifecycle-hooks",reason:"Automate transitions and notifications on incident state changes."},{spec:"governance-audit",reason:"Audit incident metadata completeness and closure quality."},{spec:"calendar",reason:"On-call and follow-up scheduling."}]},research:{name:"research",title:"Research",summary:"Experiment/Hypothesis investigation with an analysis stage, hypothesis, and method fields.",types:l.research,statuses:[{id:"analyzing",roles:["active"],aliases:["analysis"],description:"Data collected; analysis and synthesis in progress."}],fields:[{key:"hypothesis",type:"string",commands:["create","update"],description:"The testable claim the experiment evaluates."},{key:"method",type:"string",commands:["create","update","list"],description:"Experimental method or protocol used to evaluate the hypothesis.",aliases:["protocol"]}],workflows:[{type:"Experiment",allowed_transitions:[["open","in_progress"],["in_progress","analyzing"],["analyzing","in_progress"],["analyzing","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search across the research corpus."},{key:"search_max_results",value:"50",summary:"Broader recall cap for literature and prior-experiment discovery."}],templates:[{name:"experiment",options:{type:"Experiment",priority:"2",tags:"experiment",acceptanceCriteria:"Hypothesis is supported, rejected, or refined with recorded evidence.",body:`## Hypothesis
19
19
 
20
20
  ## Method
21
21
 
22
22
  ## Results
23
23
 
24
24
  ## Conclusion
25
- `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function normalizeProfileName(rawValue){if(rawValue===void 0)return;const normalized=normalizeProfileLookupKey(rawValue);if(normalized.length===0)throw new Error("Profile name must not be empty.");if(PROFILE_NAMES.includes(normalized))return normalized;throw new Error(`Invalid profile "${rawValue}". Allowed: ${PROFILE_NAMES.join(", ")}.`)}function resolveProfile(rawValue){const name=normalizeProfileName(rawValue);if(name===void 0)throw new Error(`Profile name is required. Allowed: ${PROFILE_NAMES.join(", ")}.`);return BUILTIN_PROFILES[name]}function listProfiles(){return PROFILE_NAMES.map(name=>BUILTIN_PROFILES[name])}function normalizeProfileLookupKey(rawValue){return rawValue.trim().toLowerCase().replaceAll("-","_")}function formatAvailableProfileNames(profiles){return profiles.map(entry=>entry.definition.name).join(", ")}function resolveProfileCatalog(contributions=[]){const profiles=PROFILE_NAMES.map(name=>({definition:BUILTIN_PROFILES[name],source:"builtin"})),builtinKeys=new Set(PROFILE_NAMES.map(name=>normalizeProfileLookupKey(name))),seen=new Set(builtinKeys),warnings=[];for(const contribution of contributions){const key=normalizeProfileLookupKey(contribution.profile.name);if(builtinKeys.has(key)){warnings.push(`Extension "${contribution.name}" profile "${contribution.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(seen.has(key)){warnings.push(`Profile "${contribution.profile.name}" from extension "${contribution.name}" duplicates an already-registered profile and was ignored.`);continue}seen.add(key),profiles.push({definition:contribution.profile,source:"extension",package:contribution.name})}return{profiles,warnings}}function resolveProfileEntry(rawValue,contributions=[]){const{profiles,warnings}=resolveProfileCatalog(contributions);if(typeof rawValue!="string"||rawValue.trim().length===0)throw new Error(`Profile name is required. Allowed: ${formatAvailableProfileNames(profiles)}.`);const key=normalizeProfileLookupKey(rawValue),match=profiles.find(entry=>normalizeProfileLookupKey(entry.definition.name)===key);if(match===void 0)throw new Error(`Invalid profile "${rawValue}". Allowed: ${formatAvailableProfileNames(profiles)}.`);return{resolved:match,warnings}}export{BUILTIN_PROFILES,PROFILE_NAMES,listProfiles,normalizeProfileLookupKey,normalizeProfileName,resolveProfile,resolveProfileCatalog,resolveProfileEntry};
25
+ `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function m(e){if(e===void 0)return;const t=a(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(r.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${r.join(", ")}.`)}function y(e){const t=m(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${r.join(", ")}.`);return p[t]}function g(){return r.map(e=>p[e])}function a(e){return e.trim().toLowerCase().replaceAll("-","_")}function d(e){return e.map(t=>t.definition.name).join(", ")}function u(e=[]){const t=r.map(i=>({definition:p[i],source:"builtin"})),n=new Set(r.map(i=>a(i))),c=new Set(n),s=[];for(const i of e){const o=a(i.profile.name);if(n.has(o)){s.push(`Extension "${i.name}" profile "${i.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(c.has(o)){s.push(`Profile "${i.profile.name}" from extension "${i.name}" duplicates an already-registered profile and was ignored.`);continue}c.add(o),t.push({definition:i.profile,source:"extension",package:i.name})}return{profiles:t,warnings:s}}function h(e,t=[]){const{profiles:n,warnings:c}=u(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${d(n)}.`);const s=a(e),i=n.find(o=>a(o.definition.name)===s);if(i===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${d(n)}.`);return{resolved:i,warnings:c}}export{p as BUILTIN_PROFILES,r as PROFILE_NAMES,g as listProfiles,a as normalizeProfileLookupKey,m as normalizeProfileName,y as resolveProfile,u as resolveProfileCatalog,h as resolveProfileEntry};
26
26
  //# sourceMappingURL=profile-presets.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]="ced47074-06d3-53b9-af75-63586cbd4f6a")}catch{}})();import crypto from"node:crypto";import{AsyncLocalStorage}from"node:async_hooks";const executionStorage=new AsyncLocalStorage,MAX_REPRODUCIBLE_TOKEN_LENGTH=1024;function validateReproducibleExecutionSettings(settings){const clockMs=Date.parse(settings.clock);if(!Number.isFinite(clockMs))throw new Error(`Invalid reproducible workspace clock: ${settings.clock}`);if(!Number.isSafeInteger(settings.tickMs)||settings.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(settings.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...settings,clock:new Date(clockMs).toISOString()}}function createReproducibleExecutionRunner(settings){const state={...validateReproducibleExecutionSettings(settings),clockReads:0,tokenReads:0};return operation=>executionStorage.run(state,operation)}async function runWithReproducibleExecution(settings,operation){return createReproducibleExecutionRunner(settings)(operation)}function nextReproducibleTimestamp(){const state=executionStorage.getStore();if(state===void 0)return;const timestamp=new Date(Date.parse(state.clock)+state.clockReads*state.tickMs).toISOString();return state.clockReads+=1,timestamp}function nextReproducibleToken(length){const state=executionStorage.getStore();if(state===void 0)return;if(!Number.isSafeInteger(length)||length<0||length>MAX_REPRODUCIBLE_TOKEN_LENGTH)throw new Error(`Reproducible token length must be an integer between 0 and ${MAX_REPRODUCIBLE_TOKEN_LENGTH}`);let token="";for(;token.length<length;){const digest=crypto.createHash("sha256").update(`${state.seed}\0${state.tokenReads}`).digest();state.tokenReads+=1;for(const byte of digest)if(token+=(byte%36).toString(36),token.length===length)break}return token}export{createReproducibleExecutionRunner,nextReproducibleTimestamp,nextReproducibleToken,runWithReproducibleExecution,validateReproducibleExecutionSettings};
1
+ import a from"node:crypto";import{AsyncLocalStorage as u}from"node:async_hooks";const n=new u,c=1024;function s(e){const t=Date.parse(e.clock);if(!Number.isFinite(t))throw new Error(`Invalid reproducible workspace clock: ${e.clock}`);if(!Number.isSafeInteger(e.tickMs)||e.tickMs<0)throw new Error("Reproducible workspace tickMs must be a non-negative integer");if(e.seed.trim().length===0)throw new Error("Reproducible workspace seed must not be empty");return{...e,clock:new Date(t).toISOString()}}function d(e){const r={...s(e),clockReads:0,tokenReads:0};return o=>n.run(r,o)}async function k(e,t){return d(e)(t)}function f(){const e=n.getStore();if(e===void 0)return;const t=new Date(Date.parse(e.clock)+e.clockReads*e.tickMs).toISOString();return e.clockReads+=1,t}function b(e){const t=n.getStore();if(t===void 0)return;if(!Number.isSafeInteger(e)||e<0||e>c)throw new Error(`Reproducible token length must be an integer between 0 and ${c}`);let r="";for(;r.length<e;){const o=a.createHash("sha256").update(`${t.seed}\0${t.tokenReads}`).digest();t.tokenReads+=1;for(const i of o)if(r+=(i%36).toString(36),r.length===e)break}return r}export{d as createReproducibleExecutionRunner,f as nextReproducibleTimestamp,b as nextReproducibleToken,k as runWithReproducibleExecution,s as validateReproducibleExecutionSettings};
2
2
  //# sourceMappingURL=context.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]="1abceae0-299e-5fff-aa8c-46c015115571")}catch{}})();import{RUNTIME_FIELD_COMMAND_VALUES,RUNTIME_FIELD_TYPE_VALUES}from"../../types/index.js";import{ITEM_METADATA_KEY_ORDER}from"../shared/constants.js";import{normalizeStatusToken as normalizeFieldKey}from"./status-token.js";import{normalizeStatusToken}from"./status-token.js";const RUNTIME_FIELD_TYPE_SET=new Set(RUNTIME_FIELD_TYPE_VALUES),RUNTIME_FIELD_COMMAND_SET=new Set(RUNTIME_FIELD_COMMAND_VALUES),BUILTIN_FIELD_KEYS=new Set([...ITEM_METADATA_KEY_ORDER.filter(key=>key!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),DEFAULT_FIELD_COMMANDS=["create","update"];function normalizeCliToken(value){if(typeof value!="string")return"";const collapsed=value.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return collapsed.startsWith("--")?collapsed.slice(2):collapsed}function keyToDefaultCliFlag(key){return key.replaceAll("_","-")}function dedupeCliTokens(values,exclude){const seen=new Set;for(const value of values){const token=normalizeCliToken(value);token.length>0&&token!==exclude&&seen.add(token)}return[...seen].sort((left,right)=>left.localeCompare(right))}function dedupeStringList(values){const seen=new Set;for(const value of values??[]){const trimmed=value.trim();trimmed.length>0&&seen.add(trimmed)}return[...seen].sort((left,right)=>left.localeCompare(right))}function normalizeFieldCommands(rawCommands){const seen=new Set,normalized=[];for(const rawCommand of rawCommands??[]){const command=rawCommand.trim().toLowerCase();if(command.length!==0){if(!RUNTIME_FIELD_COMMAND_SET.has(command))throw new Error(`Invalid field command "${rawCommand}". Allowed: ${RUNTIME_FIELD_COMMAND_VALUES.join(", ")}.`);seen.has(command)||(seen.add(command),normalized.push(command))}}return rawCommands===void 0||normalized.length===0?[...DEFAULT_FIELD_COMMANDS]:normalized}function normalizeAddFieldInput(raw){const key=normalizeFieldKey(raw.key);if(key.length===0)throw new Error("Field key must not be empty.");if(key.includes(","))throw new Error(`Field key "${key}" must not contain commas: commas separate field names in list flags such as --unset and --fields.`);if(BUILTIN_FIELD_KEYS.has(key))throw new Error(`Cannot define custom field "${key}": custom schema field "${key}" collides with built-in item metadata "${key}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...BUILTIN_FIELD_KEYS].sort((left,right)=>left.localeCompare(right)).join(", ")}.`);const typeCandidate=typeof raw.type=="string"&&raw.type.trim().length>0?raw.type.trim().toLowerCase():"string";if(!RUNTIME_FIELD_TYPE_SET.has(typeCandidate))throw new Error(`Invalid field type "${raw.type}". Allowed: ${RUNTIME_FIELD_TYPE_VALUES.join(", ")}.`);const type=typeCandidate,commands=normalizeFieldCommands(raw.commands),cliFlagToken=normalizeCliToken(raw.cliFlag),cliFlag=cliFlagToken.length>0&&cliFlagToken!==keyToDefaultCliFlag(key)?cliFlagToken:void 0,effectiveFlag=cliFlag??keyToDefaultCliFlag(key),cliAliases=dedupeCliTokens(raw.aliases??[],effectiveFlag),commaFlag=[effectiveFlag,...cliAliases].find(flag=>flag.includes(","));if(commaFlag!==void 0)throw new Error(`Field flag "${commaFlag}" must not contain commas.`);const description=raw.description?.trim();return{key,type,commands,description:description&&description.length>0?description:void 0,cliFlag,cliAliases,required:raw.required===!0,requiredOnCreate:raw.requiredOnCreate===!0,allowUnset:raw.allowUnset!==!1,requiredTypes:dedupeStringList(raw.requiredTypes)}}function selectFieldsArray(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.fields))return record.fields;if(Array.isArray(record.definitions))return record.definitions}function extractFieldDefinitions(parsed){const candidate=selectFieldsArray(parsed);if(!candidate)return[];const definitions=[];for(const entry of candidate){if(typeof entry!="object"||entry===null||Array.isArray(entry))continue;const record=entry;typeof record.key!="string"||record.key.trim().length===0||definitions.push(record)}return definitions}function parseFieldsFile(raw){if(raw==null||raw.trim().length===0)return{fields:[]};let parsed;try{parsed=JSON.parse(raw)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:extractFieldDefinitions(parsed)}}function serializeFieldsFile(file){return`${JSON.stringify({fields:file.fields},null,2)}
2
- `}function upsertField(file,input){const existing=file.fields.find(definition=>normalizeFieldKey(definition.key)===input.key),replaced=existing!==void 0,fields=file.fields.filter(definition=>normalizeFieldKey(definition.key)!==input.key),next={...existing,key:input.key,type:input.type,commands:[...input.commands]};return applyOptionalString(next,"description",input.description),applyOptionalString(next,"cli_flag",input.cliFlag),input.cliAliases.length>0?next.cli_aliases=[...input.cliAliases]:delete next.cli_aliases,applyBooleanFlag(next,"required",input.required),applyBooleanFlag(next,"required_on_create",input.requiredOnCreate),input.allowUnset===!1?next.allow_unset=!1:delete next.allow_unset,input.requiredTypes.length>0?next.required_types=[...input.requiredTypes]:delete next.required_types,fields.push(next),fields.sort((left,right)=>normalizeFieldKey(left.key).localeCompare(normalizeFieldKey(right.key))),{file:{fields},definition:next,replaced}}function removeField(file,key){const normalizedKey=normalizeFieldKey(key);if(normalizedKey.length===0)throw new Error("Field key must not be empty.");const removed=[],fields=file.fields.filter(definition=>normalizeFieldKey(definition.key)===normalizedKey?(removed.push(definition),!1):!0);return removed.length===0?{file:{fields},removed:!1}:{file:{fields},removed:!0,definition:removed[0]}}function applyOptionalString(definition,key,value){const record=definition;value!==void 0&&value.length>0?record[key]=value:delete record[key]}function applyBooleanFlag(definition,key,value){const record=definition;value?record[key]=!0:delete record[key]}export{BUILTIN_FIELD_KEYS,normalizeAddFieldInput,normalizeStatusToken as normalizeFieldKey,parseFieldsFile,removeField,serializeFieldsFile,upsertField};
1
+ import{RUNTIME_FIELD_COMMAND_VALUES as m,RUNTIME_FIELD_TYPE_VALUES as y}from"../../types/index.js";import{ITEM_METADATA_KEY_ORDER as A}from"../shared/constants.js";import{normalizeStatusToken as l}from"./status-token.js";import{normalizeStatusToken as j}from"./status-token.js";const T=new Set(y),k=new Set(m),p=new Set([...A.filter(t=>t!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),w=["create","update"];function h(t){if(typeof t!="string")return"";const e=t.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return e.startsWith("--")?e.slice(2):e}function g(t){return t.replaceAll("_","-")}function C(t,e){const i=new Set;for(const n of t){const r=h(n);r.length>0&&r!==e&&i.add(r)}return[...i].sort((n,r)=>n.localeCompare(r))}function S(t){const e=new Set;for(const i of t??[]){const n=i.trim();n.length>0&&e.add(n)}return[...e].sort((i,n)=>i.localeCompare(n))}function I(t){const e=new Set,i=[];for(const n of t??[]){const r=n.trim().toLowerCase();if(r.length!==0){if(!k.has(r))throw new Error(`Invalid field command "${n}". Allowed: ${m.join(", ")}.`);e.has(r)||(e.add(r),i.push(r))}}return t===void 0||i.length===0?[...w]:i}function N(t){const e=l(t.key);if(e.length===0)throw new Error("Field key must not be empty.");if(e.includes(","))throw new Error(`Field key "${e}" must not contain commas: commas separate field names in list flags such as --unset and --fields.`);if(p.has(e))throw new Error(`Cannot define custom field "${e}": custom schema field "${e}" collides with built-in item metadata "${e}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...p].sort((a,E)=>a.localeCompare(E)).join(", ")}.`);const i=typeof t.type=="string"&&t.type.trim().length>0?t.type.trim().toLowerCase():"string";if(!T.has(i))throw new Error(`Invalid field type "${t.type}". Allowed: ${y.join(", ")}.`);const n=i,r=I(t.commands),o=h(t.cliFlag),s=o.length>0&&o!==g(e)?o:void 0,d=s??g(e),f=C(t.aliases??[],d),u=[d,...f].find(a=>a.includes(","));if(u!==void 0)throw new Error(`Field flag "${u}" must not contain commas.`);const c=t.description?.trim();return{key:e,type:n,commands:r,description:c&&c.length>0?c:void 0,cliFlag:s,cliAliases:f,required:t.required===!0,requiredOnCreate:t.requiredOnCreate===!0,allowUnset:t.allowUnset!==!1,requiredTypes:S(t.requiredTypes)}}function q(t){if(Array.isArray(t))return t;if(typeof t!="object"||t===null)return;const e=t;if(Array.isArray(e.fields))return e.fields;if(Array.isArray(e.definitions))return e.definitions}function D(t){const e=q(t);if(!e)return[];const i=[];for(const n of e){if(typeof n!="object"||n===null||Array.isArray(n))continue;const r=n;typeof r.key!="string"||r.key.trim().length===0||i.push(r)}return i}function O(t){if(t==null||t.trim().length===0)return{fields:[]};let e;try{e=JSON.parse(t)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:D(e)}}function U(t){return`${JSON.stringify({fields:t.fields},null,2)}
2
+ `}function $(t,e){const i=t.fields.find(s=>l(s.key)===e.key),n=i!==void 0,r=t.fields.filter(s=>l(s.key)!==e.key),o={...i,key:e.key,type:e.type,commands:[...e.commands]};return _(o,"description",e.description),_(o,"cli_flag",e.cliFlag),e.cliAliases.length>0?o.cli_aliases=[...e.cliAliases]:delete o.cli_aliases,F(o,"required",e.required),F(o,"required_on_create",e.requiredOnCreate),e.allowUnset===!1?o.allow_unset=!1:delete o.allow_unset,e.requiredTypes.length>0?o.required_types=[...e.requiredTypes]:delete o.required_types,r.push(o),r.sort((s,d)=>l(s.key).localeCompare(l(d.key))),{file:{fields:r},definition:o,replaced:n}}function v(t,e){const i=l(e);if(i.length===0)throw new Error("Field key must not be empty.");const n=[],r=t.fields.filter(o=>l(o.key)===i?(n.push(o),!1):!0);return n.length===0?{file:{fields:r},removed:!1}:{file:{fields:r},removed:!0,definition:n[0]}}function _(t,e,i){const n=t;i!==void 0&&i.length>0?n[e]=i:delete n[e]}function F(t,e,i){const n=t;i?n[e]=!0:delete n[e]}export{p as BUILTIN_FIELD_KEYS,N as normalizeAddFieldInput,j as normalizeFieldKey,O as parseFieldsFile,v as removeField,U as serializeFieldsFile,$ as upsertField};
3
3
  //# sourceMappingURL=fields-file.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]="158d5065-075c-5355-a65c-f3edc9c5f1f0")}catch{}})();import{BUILTIN_ITEM_TYPE_VALUES}from"../../types/index.js";import{normalizeItemTypeFolder,toDefaultFolder}from"../item/type-registry.js";const BUILTIN_NAME_LOOKUP=new Map(BUILTIN_ITEM_TYPE_VALUES.map(name=>[name.toLowerCase(),name])),TYPE_NAME_TOKEN_PATTERN=/^[A-Za-z][A-Za-z0-9_-]*$/;function assertValidTypeToken(value,label){if(!TYPE_NAME_TOKEN_PATTERN.test(value))throw new Error(`${label} "${value}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function matchBuiltinTypeName(name){return BUILTIN_NAME_LOOKUP.get(name.trim().toLowerCase())}function coerceAliasArray(value){return Array.isArray(value)?value.filter(entry=>typeof entry=="string"):[]}function escapeForDoubleQuotes(value){return value.replace(/[\\"`$]/g,char=>`\\${char}`)}function dedupeAliases(values){const seen=new Map;for(const value of values){const trimmed=value.trim();if(trimmed.length===0)continue;const key=trimmed.toLowerCase();seen.has(key)||seen.set(key,trimmed)}return[...seen.values()].sort((left,right)=>left.localeCompare(right))}function normalizeAddTypeInput(raw){const name=(raw.name??"").trim();if(name.length===0)throw new Error("Type name must not be empty.");assertValidTypeToken(name,"Type name");const builtinMatch=matchBuiltinTypeName(name);if(builtinMatch)throw new Error(`Cannot redefine built-in item type "${builtinMatch}". Built-in types are reserved: ${BUILTIN_ITEM_TYPE_VALUES.join(", ")}.`);const description=raw.description?.trim(),defaultStatus=raw.defaultStatus?.trim(),rawFolder=raw.folder?.trim(),folder=rawFolder&&rawFolder.length>0?normalizeItemTypeFolder(rawFolder):void 0,aliases=dedupeAliases(raw.aliases??[]);for(const alias of aliases){assertValidTypeToken(alias,"Alias");const aliasBuiltin=matchBuiltinTypeName(alias);if(aliasBuiltin)throw new Error(`Alias "${alias}" collides with built-in item type "${aliasBuiltin}". Built-in types are reserved: ${BUILTIN_ITEM_TYPE_VALUES.join(", ")}.`)}return{name,description:description&&description.length>0?description:void 0,defaultStatus:defaultStatus&&defaultStatus.length>0?defaultStatus:void 0,folder,aliases}}function assertAliasesAvailable(input,existing){const selfLower=input.name.toLowerCase(),taken=new Map;for(const definition of existing.definitions){if(typeof definition.name!="string")continue;const definitionName=definition.name.trim();if(!(definitionName.length===0||definitionName.toLowerCase()===selfLower)){taken.set(definitionName.toLowerCase(),definitionName);for(const alias of coerceAliasArray(definition.aliases))alias.trim().length>0&&taken.set(alias.trim().toLowerCase(),definitionName)}}const nameOwner=taken.get(selfLower);if(nameOwner)throw new Error(`Type name "${input.name}" collides with an alias of existing item type "${nameOwner}".`);for(const alias of input.aliases){const owner=taken.get(alias.toLowerCase());if(owner)throw new Error(`Alias "${alias}" already maps to existing item type "${owner}".`)}}function resolveDefinitionFolder(name,folder){return typeof folder=="string"&&folder.trim().length>0?normalizeItemTypeFolder(folder).toLowerCase():toDefaultFolder(name).toLowerCase()}function assertTypeFolderAvailable(input,existing,reservedFolders){const selfLower=input.name.toLowerCase(),inputFolder=resolveDefinitionFolder(input.name,input.folder),fail=ownerName=>{throw new Error(`Item type "${input.name}" would store items in folder "${inputFolder}", which already belongs to existing item type "${ownerName}". Pass a distinct --folder to keep their storage separate.`)};for(const definition of existing.definitions){if(typeof definition.name!="string")continue;const definitionName=definition.name.trim();definitionName.length===0||definitionName.toLowerCase()===selfLower||resolveDefinitionFolder(definitionName,definition.folder)===inputFolder&&fail(definitionName)}const reservedOwner=reservedFolders?.get(inputFolder);reservedOwner!==void 0&&reservedOwner.toLowerCase()!==selfLower&&fail(reservedOwner)}function parseItemTypesFile(raw){if(raw==null||raw.trim().length===0)return{definitions:[]};let parsed;try{parsed=JSON.parse(raw)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:extractDefinitions(parsed)}}function extractDefinitions(parsed){const candidate=selectDefinitionsArray(parsed);if(!candidate)return[];const definitions=[];for(const entry of candidate){if(typeof entry!="object"||entry===null||Array.isArray(entry))continue;const record=entry;typeof record.name!="string"||record.name.trim().length===0||definitions.push(record)}return definitions}function selectDefinitionsArray(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.definitions))return record.definitions;if(typeof record.item_types=="object"&&record.item_types!==null){const nested=record.item_types;if(Array.isArray(nested.definitions))return nested.definitions}}function upsertItemType(file,input){const lowerName=input.name.toLowerCase(),definitions=file.definitions.slice(),existingIndex=definitions.findIndex(definition=>typeof definition.name=="string"&&definition.name.trim().toLowerCase()===lowerName),existing=existingIndex>=0?definitions[existingIndex]:void 0,mergedAliases=dedupeAliases([...coerceAliasArray(existing?.aliases),...input.aliases]),next={...existing,name:input.name};return input.folder!==void 0&&(next.folder=input.folder),mergedAliases.length>0?next.aliases=mergedAliases:next.aliases!==void 0&&delete next.aliases,applyAttribute(next,"description",input.description),applyAttribute(next,"default_status",input.defaultStatus),existingIndex>=0?definitions[existingIndex]=next:definitions.push(next),definitions.sort((left,right)=>left.name.localeCompare(right.name)),{file:{definitions},definition:next,replaced:existingIndex>=0,...existing&&typeof existing.name=="string"?{previousName:existing.name}:{}}}function removeItemType(file,name){const trimmed=(name??"").trim();if(trimmed.length===0)throw new Error("Type name must not be empty.");const builtinMatch=matchBuiltinTypeName(trimmed);if(builtinMatch)throw new Error(`Cannot remove built-in item type "${builtinMatch}". Built-in types are reserved: ${BUILTIN_ITEM_TYPE_VALUES.join(", ")}.`);const lowerName=trimmed.toLowerCase(),definitions=file.definitions.slice(),existingIndex=definitions.findIndex(definition2=>typeof definition2.name=="string"&&definition2.name.trim().toLowerCase()===lowerName);if(existingIndex<0)return{file:{definitions},removed:!1};const[definition]=definitions.splice(existingIndex,1);return{file:{definitions},removed:!0,definition}}function applyAttribute(definition,key,value){const record=definition;value!==void 0&&(record[key]=value)}function serializeItemTypesFile(file){return`${JSON.stringify({definitions:file.definitions},null,2)}
2
- `}function buildInvalidTypeHint(name,typesFilePath){const safeName=name.trim().length>0?name.trim():name,target=typesFilePath?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${escapeForDoubleQuotes(safeName)}" (writes ${target}).`}function buildInvalidTypeError(name,allowedTypes,typesFilePath){return`Invalid type value "${name}". Allowed: ${allowedTypes.join(", ")}. ${buildInvalidTypeHint(name,typesFilePath)}`}export{assertAliasesAvailable,assertTypeFolderAvailable,buildInvalidTypeError,buildInvalidTypeHint,escapeForDoubleQuotes,matchBuiltinTypeName,normalizeAddTypeInput,parseItemTypesFile,removeItemType,serializeItemTypesFile,upsertItemType};
1
+ import{BUILTIN_ITEM_TYPE_VALUES as c}from"../../types/index.js";import{normalizeItemTypeFolder as m,toDefaultFolder as h}from"../item/type-registry.js";const A=new Map(c.map(e=>[e.toLowerCase(),e])),T=/^[A-Za-z][A-Za-z0-9_-]*$/;function u(e,t){if(!T.test(e))throw new Error(`${t} "${e}" is not a valid identifier. Use a single letter-led token of letters, digits, hyphen, or underscore with no spaces or punctuation (e.g. "Spike" or "code-review").`)}function d(e){return A.get(e.trim().toLowerCase())}function p(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function $(e){return e.replace(/[\\"`$]/g,t=>`\\${t}`)}function y(e){const t=new Map;for(const i of e){const n=i.trim();if(n.length===0)continue;const o=n.toLowerCase();t.has(o)||t.set(o,n)}return[...t.values()].sort((i,n)=>i.localeCompare(n))}function v(e){const t=(e.name??"").trim();if(t.length===0)throw new Error("Type name must not be empty.");u(t,"Type name");const i=d(t);if(i)throw new Error(`Cannot redefine built-in item type "${i}". Built-in types are reserved: ${c.join(", ")}.`);const n=e.description?.trim(),o=e.defaultStatus?.trim(),r=e.folder?.trim(),a=r&&r.length>0?m(r):void 0,s=y(e.aliases??[]);for(const f of s){u(f,"Alias");const l=d(f);if(l)throw new Error(`Alias "${f}" collides with built-in item type "${l}". Built-in types are reserved: ${c.join(", ")}.`)}return{name:t,description:n&&n.length>0?n:void 0,defaultStatus:o&&o.length>0?o:void 0,folder:a,aliases:s}}function b(e,t){const i=e.name.toLowerCase(),n=new Map;for(const r of t.definitions){if(typeof r.name!="string")continue;const a=r.name.trim();if(!(a.length===0||a.toLowerCase()===i)){n.set(a.toLowerCase(),a);for(const s of p(r.aliases))s.trim().length>0&&n.set(s.trim().toLowerCase(),a)}}const o=n.get(i);if(o)throw new Error(`Type name "${e.name}" collides with an alias of existing item type "${o}".`);for(const r of e.aliases){const a=n.get(r.toLowerCase());if(a)throw new Error(`Alias "${r}" already maps to existing item type "${a}".`)}}function w(e,t){return typeof t=="string"&&t.trim().length>0?m(t).toLowerCase():h(e).toLowerCase()}function N(e,t,i){const n=e.name.toLowerCase(),o=w(e.name,e.folder),r=s=>{throw new Error(`Item type "${e.name}" would store items in folder "${o}", which already belongs to existing item type "${s}". Pass a distinct --folder to keep their storage separate.`)};for(const s of t.definitions){if(typeof s.name!="string")continue;const f=s.name.trim();f.length===0||f.toLowerCase()===n||w(f,s.folder)===o&&r(f)}const a=i?.get(o);a!==void 0&&a.toLowerCase()!==n&&r(a)}function _(e){if(e==null||e.trim().length===0)return{definitions:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/types.json contains invalid JSON.")}return{definitions:x(t)}}function x(e){const t=L(e);if(!t)return[];const i=[];for(const n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;const o=n;typeof o.name!="string"||o.name.trim().length===0||i.push(o)}return i}function L(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){const i=t.item_types;if(Array.isArray(i.definitions))return i.definitions}}function j(e,t){const i=t.name.toLowerCase(),n=e.definitions.slice(),o=n.findIndex(f=>typeof f.name=="string"&&f.name.trim().toLowerCase()===i),r=o>=0?n[o]:void 0,a=y([...p(r?.aliases),...t.aliases]),s={...r,name:t.name};return t.folder!==void 0&&(s.folder=t.folder),a.length>0?s.aliases=a:s.aliases!==void 0&&delete s.aliases,g(s,"description",t.description),g(s,"default_status",t.defaultStatus),o>=0?n[o]=s:n.push(s),n.sort((f,l)=>f.name.localeCompare(l.name)),{file:{definitions:n},definition:s,replaced:o>=0,...r&&typeof r.name=="string"?{previousName:r.name}:{}}}function F(e,t){const i=(t??"").trim();if(i.length===0)throw new Error("Type name must not be empty.");const n=d(i);if(n)throw new Error(`Cannot remove built-in item type "${n}". Built-in types are reserved: ${c.join(", ")}.`);const o=i.toLowerCase(),r=e.definitions.slice(),a=r.findIndex(f=>typeof f.name=="string"&&f.name.trim().toLowerCase()===o);if(a<0)return{file:{definitions:r},removed:!1};const[s]=r.splice(a,1);return{file:{definitions:r},removed:!0,definition:s}}function g(e,t,i){const n=e;i!==void 0&&(n[t]=i)}function S(e){return`${JSON.stringify({definitions:e.definitions},null,2)}
2
+ `}function C(e,t){const i=e.trim().length>0?e.trim():e,n=t?.trim()||".agents/pm/schema/types.json";return`To register a custom type, run: pm schema add-type "${$(i)}" (writes ${n}).`}function M(e,t,i){return`Invalid type value "${e}". Allowed: ${t.join(", ")}. ${C(e,i)}`}export{b as assertAliasesAvailable,N as assertTypeFolderAvailable,M as buildInvalidTypeError,C as buildInvalidTypeHint,$ as escapeForDoubleQuotes,d as matchBuiltinTypeName,v as normalizeAddTypeInput,_ as parseItemTypesFile,F as removeItemType,S as serializeItemTypesFile,j as upsertItemType};
3
3
  //# sourceMappingURL=item-types-file.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]="4b79bd02-51ae-5c46-be4c-2f41dd8c9486")}catch{}})();import{coerceRuntimeFieldValue,readRuntimeFieldOptionValue}from"./runtime-field-values.js";import{stableValueEquals}from"../shared/serialization.js";function valuesEqual(left,right){return stableValueEquals(left,right)}function collectRuntimeFilterValues(options,fieldRegistry,command){const filters={};for(const definition of fieldRegistry.command_to_fields.get(command)??[]){const rawValue=readRuntimeFieldOptionValue(options,definition);rawValue!==void 0&&(filters[definition.metadata_key]=coerceRuntimeFieldValue(definition,rawValue))}return filters}function matchesRuntimeFilters(item,filters){for(const[fieldKey,expectedValue]of Object.entries(filters)){const actualValue=item[fieldKey];if(Array.isArray(expectedValue)){if(Array.isArray(actualValue)){const normalizedActual=actualValue.map(value=>String(value));if(!expectedValue.map(value=>String(value)).every(value=>normalizedActual.includes(value)))return!1;continue}if(!valuesEqual(actualValue,expectedValue[expectedValue.length-1]))return!1;continue}if(!valuesEqual(actualValue,expectedValue))return!1}return!0}export{collectRuntimeFilterValues,matchesRuntimeFilters};
1
+ import{coerceRuntimeFieldValue as l,readRuntimeFieldOptionValue as c}from"./runtime-field-values.js";import{stableValueEquals as f}from"../shared/serialization.js";function u(n,r){return f(n,r)}function p(n,r,o){const e={};for(const t of r.command_to_fields.get(o)??[]){const a=c(n,t);a!==void 0&&(e[t.metadata_key]=l(t,a))}return e}function y(n,r){for(const[o,e]of Object.entries(r)){const t=n[o];if(Array.isArray(e)){if(Array.isArray(t)){const a=t.map(i=>String(i));if(!e.map(i=>String(i)).every(i=>a.includes(i)))return!1;continue}if(!u(t,e[e.length-1]))return!1;continue}if(!u(t,e))return!1}return!0}export{p as collectRuntimeFilterValues,y as matchesRuntimeFilters};
2
2
  //# sourceMappingURL=runtime-field-filters.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]="9b51a9f9-e57f-5998-837e-c6c442ca1c9b")}catch{}})();import{EXIT_CODE}from"../shared/constants.js";import{PmCliError}from"../shared/errors.js";import{stableStringify}from"../shared/serialization.js";import{isRfc3339DateTime}from"../shared/time.js";import{runtimeFieldOptionTarget}from"./runtime-schema.js";import{assertIdentityFieldsWithoutUrlCredentials}from"../shared/url-credentials.js";const MAX_VALUE_SCHEMA_DEPTH=16;function toCamelToken(value){const segments=value.trim().replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(segment=>segment.length>0).map(segment=>segment.toLowerCase());if(segments.length===0)return value;const[first,...rest]=segments;return`${first}${rest.map(segment=>`${segment.slice(0,1).toUpperCase()}${segment.slice(1)}`).join("")}`}function runtimeFieldSdkOptionName(definition,registry,reservedOptions=new Set,command){if(hasStorageTwin(definition,registry,command))return;const taken=foreignRuntimeFieldOptionNames(definition,registry,reservedOptions,command),readOrder=resolveCandidateOptionKeys(definition);return[toCamelToken(definition.cli_flag),...readOrder].find(name=>!taken.has(name)&&isUnshadowedOptionKey(name,readOrder,taken))}function isUnshadowedOptionKey(key,readOrder,taken){for(const earlier of readOrder){if(earlier===key)break;if(taken.has(earlier))return!1}return!0}function hasStorageTwin(definition,registry,command){return registry.definitions.some(candidate=>candidate!==definition&&candidate.metadata_key===definition.metadata_key&&(command===void 0||candidate.commands.includes(command)))}function foreignRuntimeFieldOptionNames(definition,registry,reservedOptions,command){return new Set([...reservedOptions,...registry.definitions.filter(candidate=>candidate!==definition&&(command===void 0||candidate.commands.includes(command))).flatMap(candidate=>resolveCandidateOptionKeys(candidate))])}function isNegatingFlag(flag){return flag.replace(/^-+/u,"").startsWith("no-")}function runtimeFieldFlagToken(flag){return flag.startsWith("-")?flag:`--${flag}`}function runtimeFieldCliFlagRoute(definition,registry,reserved,command){if(hasStorageTwin(definition,registry,command))return;const taken=foreignRuntimeFieldOptionNames(definition,registry,reserved.options,command),readOrder=resolveCandidateOptionKeys(definition);return[definition.cli_flag,...definition.cli_aliases].find(flag=>{const key=commanderOptionAttribute(flag);return isNegatingFlag(flag)||reserved.flags.has(runtimeFieldFlagToken(flag))||taken.has(key)?!1:isUnshadowedOptionKey(key,readOrder,taken)})}function commanderOptionAttribute(flag){return flag.replace(/^-+/u,"").replace(/^no-/u,"").split("-").reduce((name,word)=>`${name}${word.charAt(0).toUpperCase()}${word.slice(1)}`)}function resolveCandidateOptionKeys(definition){return[...new Set([runtimeFieldOptionTarget(definition),toCamelToken(definition.key),toCamelToken(definition.cli_flag),...definition.cli_aliases.map(alias=>toCamelToken(alias)),...[definition.cli_flag,...definition.cli_aliases].filter(flag=>!isNegatingFlag(flag)).map(flag=>commanderOptionAttribute(flag))])]}function readRuntimeFieldOptionValue(options,definition){for(const candidateKey of resolveCandidateOptionKeys(definition)){if(!Object.hasOwn(options,candidateKey))continue;const value=options[candidateKey];if(value!==void 0)return value}}function normalizeStringArrayValue(value){return Array.isArray(value)?value.flatMap(entry=>normalizeStringArrayValue(entry)).map(entry=>entry.trim()).filter(entry=>entry.length>0):typeof value=="string"?value.split(/[,\n|]/).map(entry=>entry.trim()).filter(entry=>entry.length>0):value==null?[]:[String(value).trim()].filter(entry=>entry.length>0)}function parseBooleanValue(raw,label){if(typeof raw=="boolean")return raw;if(typeof raw=="number"){if(raw===1)return!0;if(raw===0)return!1}if(typeof raw=="string"){const normalized=raw.trim().toLowerCase();if(normalized==="true"||normalized==="1"||normalized==="yes")return!0;if(normalized==="false"||normalized==="0"||normalized==="no")return!1}throw new PmCliError(`${label} must be one of true|false|1|0|yes|no`,EXIT_CODE.USAGE)}function parseNumberValue(raw,label){if(typeof raw=="number"&&Number.isFinite(raw))return raw;const candidate=typeof raw=="string"?raw.trim():String(raw),parsed=Number(candidate);if(!Number.isFinite(parsed))throw new PmCliError(`${label} must be a number`,EXIT_CODE.USAGE);return parsed}function parseJsonContainerValue(raw,label,expectedType){const parsed=typeof raw=="string"?(()=>{try{return JSON.parse(raw)}catch{return}})():raw;if(expectedType==="array"&&Array.isArray(parsed)||expectedType==="object"&&typeof parsed=="object"&&parsed!==null&&!Array.isArray(parsed))return parsed;throw new PmCliError(`${label} must be valid JSON ${expectedType}`,EXIT_CODE.USAGE)}function valueMatchesSchemaType(value,type){return type===void 0?!0:type==="array"?Array.isArray(value):type==="object"?typeof value=="object"&&value!==null&&!Array.isArray(value):typeof value===type}function runtimeFieldPrimitiveSchemaError(value,schema,path){if(schema.const!==void 0&&stableStringify(value)!==stableStringify(schema.const))return`${path} must equal ${stableStringify(schema.const)}`;if(schema.enum!==void 0&&!schema.enum.some(candidate=>stableStringify(candidate)===stableStringify(value)))return`${path} must be one of ${schema.enum.map(entry=>stableStringify(entry)).join("|")}`;if(!valueMatchesSchemaType(value,schema.type))return`${path} must match configured type ${String(schema.type)}`;if(typeof value=="string"){if(schema.min_length!==void 0&&value.length<schema.min_length)return`${path} must contain at least ${schema.min_length} characters`;if(schema.format==="date-time"&&!isRfc3339DateTime(value))return`${path} must be an RFC 3339 date-time`}}function runtimeFieldArraySchemaError(value,schema,path,depth){if(Array.isArray(value)){if(schema.min_items!==void 0&&value.length<schema.min_items)return`${path} must contain at least ${schema.min_items} items`;if(schema.items)for(const[index,entry]of value.entries()){const error=runtimeFieldSchemaError(entry,schema.items,`${path}[${index}]`,depth+1);if(error)return error}}}function runtimeFieldObjectSchemaError(value,schema,path,depth){if(typeof value!="object"||value===null||Array.isArray(value))return;const record=value;for(const key of schema.required??[])if(!Object.hasOwn(record,key))return`${path}.${key} is required`;for(const[key,entry]of Object.entries(record)){const propertySchema=schema.properties?.[key];if(!propertySchema){if(schema.additional_properties===!1)return`${path}.${key} is not allowed`;continue}const error=runtimeFieldSchemaError(entry,propertySchema,`${path}.${key}`,depth+1);if(error)return error}}function runtimeFieldSchemaError(value,schema,path,depth=0){if(depth>MAX_VALUE_SCHEMA_DEPTH)return`${path} value schema exceeds maximum depth`;const directError=runtimeFieldPrimitiveSchemaError(value,schema,path);if(directError)return directError;const arrayError=runtimeFieldArraySchemaError(value,schema,path,depth);if(arrayError)return arrayError;const objectError=runtimeFieldObjectSchemaError(value,schema,path,depth);if(objectError)return objectError;if(!schema.one_of)return;let matches=0;for(const candidate of schema.one_of)if(runtimeFieldSchemaError(value,candidate,path,depth+1)===void 0&&(matches+=1,matches>1))break;return matches===1?void 0:`${path} must match exactly one configured schema variant`}function validateRuntimeFieldValue(definition,value,label){if(!definition.value_schema||value===void 0)return value;const error=runtimeFieldSchemaError(value,definition.value_schema,label);if(error)throw new PmCliError(error,EXIT_CODE.USAGE);return value}function coerceRuntimeContainerValue(definition,rawValue,label,inputKind){const raw=inputKind==="option"&&Array.isArray(rawValue)?rawValue[rawValue.length-1]:rawValue;if(raw!==void 0)return validateRuntimeFieldValue(definition,parseJsonContainerValue(raw,label,definition.type),label)}function coerceRuntimeFieldValue(definition,rawValue,labelOverride,inputKind="option"){const label=labelOverride??`--${definition.cli_flag}`;if(definition.type==="array"||definition.type==="object")return coerceRuntimeContainerValue(definition,rawValue,label,inputKind);if(definition.repeatable||definition.type==="string_array"){const values=normalizeStringArrayValue(rawValue);return definition.type==="number"?validateRuntimeFieldValue(definition,values.map(value=>parseNumberValue(value,label)),label):definition.type==="boolean"?validateRuntimeFieldValue(definition,values.map(value=>parseBooleanValue(value,label)),label):validateRuntimeFieldValue(definition,values,label)}const scalarRaw=Array.isArray(rawValue)?rawValue[rawValue.length-1]:rawValue;if(scalarRaw!==void 0)return definition.type==="number"?validateRuntimeFieldValue(definition,parseNumberValue(scalarRaw,label),label):definition.type==="boolean"?validateRuntimeFieldValue(definition,parseBooleanValue(scalarRaw,label),label):validateRuntimeFieldValue(definition,typeof scalarRaw=="string"?scalarRaw:String(scalarRaw),label)}function shouldRequireFieldOnCreate(definition,itemTypeName){return!definition.required&&!definition.required_on_create?!1:definition.required_types.length===0?!0:itemTypeName?definition.required_types.map(value=>value.toLowerCase()).includes(itemTypeName.trim().toLowerCase()):!1}function collectRuntimeCreateFieldValues(options,fieldRegistry,itemTypeName){const values={},missingRequiredFlags=[];for(const definition of fieldRegistry.command_to_fields.get("create")??[]){const rawValue=readRuntimeFieldOptionValue(options,definition);if(rawValue===void 0){shouldRequireFieldOnCreate(definition,itemTypeName)&&missingRequiredFlags.push(`--${definition.cli_flag}`);continue}values[definition.metadata_key]=coerceRuntimeFieldValue(definition,rawValue)}return{values,missing_required_flags:[...new Set(missingRequiredFlags)].sort((left,right)=>left.localeCompare(right))}}function collectRuntimeUpdateFieldValues(options,fieldRegistry,commands=["update"]){const values={},definitions=(commands??["update"]).flatMap(command=>fieldRegistry.command_to_fields.get(command)??[]),seen=new Set;for(const definition of definitions){const rawValue=readRuntimeFieldOptionValue(options,definition);rawValue!==void 0&&(seen.has(definition.metadata_key)||(seen.add(definition.metadata_key),values[definition.metadata_key]=coerceRuntimeFieldValue(definition,rawValue)))}return assertIdentityFieldsWithoutUrlCredentials(values),values}export{coerceRuntimeFieldValue,collectRuntimeCreateFieldValues,collectRuntimeUpdateFieldValues,commanderOptionAttribute,readRuntimeFieldOptionValue,resolveCandidateOptionKeys,runtimeFieldCliFlagRoute,runtimeFieldFlagToken,runtimeFieldSdkOptionName,shouldRequireFieldOnCreate};
1
+ import{EXIT_CODE as l}from"../shared/constants.js";import{PmCliError as d}from"../shared/errors.js";import{stableStringify as a}from"../shared/serialization.js";import{isRfc3339DateTime as E}from"../shared/time.js";import{runtimeFieldOptionTarget as h}from"./runtime-schema.js";import{assertIdentityFieldsWithoutUrlCredentials as j}from"../shared/url-credentials.js";const R=16;function m(e){const r=e.trim().replaceAll(/[^A-Za-z0-9]+/g," ").split(/\s+/).filter(i=>i.length>0).map(i=>i.toLowerCase());if(r.length===0)return e;const[t,...n]=r;return`${t}${n.map(i=>`${i.slice(0,1).toUpperCase()}${i.slice(1)}`).join("")}`}function P(e,r,t=new Set,n){if(_(e,r,n))return;const i=$(e,r,t,n),o=p(e);return[m(e.cli_flag),...o].find(s=>!i.has(s)&&g(s,o,i))}function g(e,r,t){for(const n of r){if(n===e)break;if(t.has(n))return!1}return!0}function _(e,r,t){return r.definitions.some(n=>n!==e&&n.metadata_key===e.metadata_key&&(t===void 0||n.commands.includes(t)))}function $(e,r,t,n){return new Set([...t,...r.definitions.filter(i=>i!==e&&(n===void 0||i.commands.includes(n))).flatMap(i=>p(i))])}function b(e){return e.replace(/^-+/u,"").startsWith("no-")}function x(e){return e.startsWith("-")?e:`--${e}`}function W(e,r,t,n){if(_(e,r,n))return;const i=$(e,r,t.options,n),o=p(e);return[e.cli_flag,...e.cli_aliases].find(u=>{const s=A(u);return b(u)||t.flags.has(x(u))||i.has(s)?!1:g(s,o,i)})}function A(e){return e.replace(/^-+/u,"").replace(/^no-/u,"").split("-").reduce((r,t)=>`${r}${t.charAt(0).toUpperCase()}${t.slice(1)}`)}function p(e){return[...new Set([h(e),m(e.key),m(e.cli_flag),...e.cli_aliases.map(r=>m(r)),...[e.cli_flag,...e.cli_aliases].filter(r=>!b(r)).map(r=>A(r))])]}function S(e,r){for(const t of p(r)){if(!Object.hasOwn(e,t))continue;const n=e[t];if(n!==void 0)return n}}function F(e){return Array.isArray(e)?e.flatMap(r=>F(r)).map(r=>r.trim()).filter(r=>r.length>0):typeof e=="string"?e.split(/[,\n|]/).map(r=>r.trim()).filter(r=>r.length>0):e==null?[]:[String(e).trim()].filter(r=>r.length>0)}function C(e,r){if(typeof e=="boolean")return e;if(typeof e=="number"){if(e===1)return!0;if(e===0)return!1}if(typeof e=="string"){const t=e.trim().toLowerCase();if(t==="true"||t==="1"||t==="yes")return!0;if(t==="false"||t==="0"||t==="no")return!1}throw new d(`${r} must be one of true|false|1|0|yes|no`,l.USAGE)}function O(e,r){if(typeof e=="number"&&Number.isFinite(e))return e;const t=typeof e=="string"?e.trim():String(e),n=Number(t);if(!Number.isFinite(n))throw new d(`${r} must be a number`,l.USAGE);return n}function q(e,r,t){const n=typeof e=="string"?(()=>{try{return JSON.parse(e)}catch{return}})():e;if(t==="array"&&Array.isArray(n)||t==="object"&&typeof n=="object"&&n!==null&&!Array.isArray(n))return n;throw new d(`${r} must be valid JSON ${t}`,l.USAGE)}function U(e,r){return r===void 0?!0:r==="array"?Array.isArray(e):r==="object"?typeof e=="object"&&e!==null&&!Array.isArray(e):typeof e===r}function N(e,r,t){if(r.const!==void 0&&a(e)!==a(r.const))return`${t} must equal ${a(r.const)}`;if(r.enum!==void 0&&!r.enum.some(n=>a(n)===a(e)))return`${t} must be one of ${r.enum.map(n=>a(n)).join("|")}`;if(!U(e,r.type))return`${t} must match configured type ${String(r.type)}`;if(typeof e=="string"){if(r.min_length!==void 0&&e.length<r.min_length)return`${t} must contain at least ${r.min_length} characters`;if(r.format==="date-time"&&!E(e))return`${t} must be an RFC 3339 date-time`}}function M(e,r,t,n){if(Array.isArray(e)){if(r.min_items!==void 0&&e.length<r.min_items)return`${t} must contain at least ${r.min_items} items`;if(r.items)for(const[i,o]of e.entries()){const u=y(o,r.items,`${t}[${i}]`,n+1);if(u)return u}}}function L(e,r,t,n){if(typeof e!="object"||e===null||Array.isArray(e))return;const i=e;for(const o of r.required??[])if(!Object.hasOwn(i,o))return`${t}.${o} is required`;for(const[o,u]of Object.entries(i)){const s=r.properties?.[o];if(!s){if(r.additional_properties===!1)return`${t}.${o} is not allowed`;continue}const c=y(u,s,`${t}.${o}`,n+1);if(c)return c}}function y(e,r,t,n=0){if(n>R)return`${t} value schema exceeds maximum depth`;const i=N(e,r,t);if(i)return i;const o=M(e,r,t,n);if(o)return o;const u=L(e,r,t,n);if(u)return u;if(!r.one_of)return;let s=0;for(const c of r.one_of)if(y(e,c,t,n+1)===void 0&&(s+=1,s>1))break;return s===1?void 0:`${t} must match exactly one configured schema variant`}function f(e,r,t){if(!e.value_schema||r===void 0)return r;const n=y(r,e.value_schema,t);if(n)throw new d(n,l.USAGE);return r}function T(e,r,t,n){const i=n==="option"&&Array.isArray(r)?r[r.length-1]:r;if(i!==void 0)return f(e,q(i,t,e.type),t)}function k(e,r,t,n="option"){const i=t??`--${e.cli_flag}`;if(e.type==="array"||e.type==="object")return T(e,r,i,n);if(e.repeatable||e.type==="string_array"){const u=F(r);return e.type==="number"?f(e,u.map(s=>O(s,i)),i):e.type==="boolean"?f(e,u.map(s=>C(s,i)),i):f(e,u,i)}const o=Array.isArray(r)?r[r.length-1]:r;if(o!==void 0)return e.type==="number"?f(e,O(o,i),i):e.type==="boolean"?f(e,C(o,i),i):f(e,typeof o=="string"?o:String(o),i)}function V(e,r){return!e.required&&!e.required_on_create?!1:e.required_types.length===0?!0:r?e.required_types.map(t=>t.toLowerCase()).includes(r.trim().toLowerCase()):!1}function H(e,r,t){const n={},i=[];for(const o of r.command_to_fields.get("create")??[]){const u=S(e,o);if(u===void 0){V(o,t)&&i.push(`--${o.cli_flag}`);continue}n[o.metadata_key]=k(o,u)}return{values:n,missing_required_flags:[...new Set(i)].sort((o,u)=>o.localeCompare(u))}}function I(e,r,t=["update"]){const n={},i=(t??["update"]).flatMap(u=>r.command_to_fields.get(u)??[]),o=new Set;for(const u of i){const s=S(e,u);s!==void 0&&(o.has(u.metadata_key)||(o.add(u.metadata_key),n[u.metadata_key]=k(u,s)))}return j(n),n}export{k as coerceRuntimeFieldValue,H as collectRuntimeCreateFieldValues,I as collectRuntimeUpdateFieldValues,A as commanderOptionAttribute,S as readRuntimeFieldOptionValue,p as resolveCandidateOptionKeys,W as runtimeFieldCliFlagRoute,x as runtimeFieldFlagToken,P as runtimeFieldSdkOptionName,V as shouldRequireFieldOnCreate};
2
2
  //# sourceMappingURL=runtime-field-values.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]="6e07b1b6-1757-54dd-8833-9d3f984ccf79")}catch{}})();import path from"node:path";import{pathExists,readFileIfExists}from"../fs/fs-utils.js";import{createFileAtomic}from"../fs/atomic-create.js";import{DEFAULT_STATUS_DEFINITIONS,DEFAULT_WORKFLOW_DEFINITION}from"../shared/constants.js";import{RUNTIME_FIELD_COMMAND_VALUES,RUNTIME_FIELD_TYPE_VALUES,RUNTIME_STATUS_ROLE_VALUES,RUNTIME_UNKNOWN_FIELD_POLICY_VALUES,STATUS_VALUES}from"../../types/index.js";import{normalizeStatusToken}from"./status-token.js";const DEFAULT_RUNTIME_SCHEMA_FILE_PATHS=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),DEFAULT_RUNTIME_WORKFLOW=DEFAULT_WORKFLOW_DEFINITION,DEFAULT_RUNTIME_STATUS_DEFINITIONS=DEFAULT_STATUS_DEFINITIONS,DEFAULT_RUNTIME_FIELD_COMMANDS=["create","update"],RUNTIME_STATUS_ROLE_SET=new Set(RUNTIME_STATUS_ROLE_VALUES),RUNTIME_FIELD_TYPE_SET=new Set(RUNTIME_FIELD_TYPE_VALUES),RUNTIME_FIELD_COMMAND_SET=new Set(RUNTIME_FIELD_COMMAND_VALUES),RUNTIME_UNKNOWN_FIELD_POLICY_SET=new Set(RUNTIME_UNKNOWN_FIELD_POLICY_VALUES),RUNTIME_FIELD_VALUE_TYPE_SET=new Set(["string","number","boolean","array","object"]),MAX_RUNTIME_FIELD_VALUE_SCHEMA_DEPTH=16;function isPlainObject(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}const RUNTIME_FIELD_VALUE_SCHEMA_SHAPE_VALIDATORS=[schema=>schema.type===void 0||typeof schema.type=="string"&&RUNTIME_FIELD_VALUE_TYPE_SET.has(schema.type),schema=>!Object.hasOwn(schema,"const")||isStructuredJsonValue(schema.const),schema=>schema.enum===void 0||Array.isArray(schema.enum)&&schema.enum.every(entry=>isStructuredJsonValue(entry)),schema=>schema.min_length===void 0||Number.isInteger(schema.min_length)&&schema.min_length>=0,schema=>schema.min_items===void 0||Number.isInteger(schema.min_items)&&schema.min_items>=0,schema=>schema.format===void 0||schema.format==="date-time",schema=>schema.required===void 0||Array.isArray(schema.required)&&schema.required.every(entry=>typeof entry=="string"&&entry.length>0),schema=>schema.additional_properties===void 0||typeof schema.additional_properties=="boolean",schema=>schema.properties===void 0||isPlainObject(schema.properties),schema=>schema.one_of===void 0||Array.isArray(schema.one_of)&&schema.one_of.length>0];function isStructuredJsonValue(value,ancestors=new Set){if(value===null||typeof value=="string"||typeof value=="boolean")return!0;if(typeof value=="number")return Number.isFinite(value);if(typeof value!="object"||ancestors.has(value))return!1;ancestors.add(value);const valid=Array.isArray(value)?value.every(entry=>isStructuredJsonValue(entry,ancestors)):Object.values(value).every(entry=>isStructuredJsonValue(entry,ancestors));return ancestors.delete(value),valid}function normalizeRuntimeFieldValueSchema(value,depth=0,ancestors=new Set){if(!isPlainObject(value)||depth>MAX_RUNTIME_FIELD_VALUE_SCHEMA_DEPTH||ancestors.has(value))return;ancestors.add(value);const schema=value,type=schema.type,enumValues=schema.enum,oneOf=schema.one_of,properties=schema.properties,items=schema.items,required=schema.required,minLength=schema.min_length,minItems=schema.min_items,format=schema.format,additionalProperties=schema.additional_properties;if(!RUNTIME_FIELD_VALUE_SCHEMA_SHAPE_VALIDATORS.every(check=>check(schema))){ancestors.delete(value);return}const normalizedProperties=properties===void 0?void 0:Object.fromEntries(Object.entries(properties).map(([key,entry])=>[key,normalizeRuntimeFieldValueSchema(entry,depth+1,ancestors)])),normalizedItems=items===void 0?void 0:normalizeRuntimeFieldValueSchema(items,depth+1,ancestors),normalizedOneOf=oneOf===void 0?void 0:oneOf.map(entry=>normalizeRuntimeFieldValueSchema(entry,depth+1,ancestors));if([...Object.values(normalizedProperties??{}),...items===void 0?[]:[normalizedItems],...normalizedOneOf??[]].some(entry=>entry===void 0)){ancestors.delete(value);return}return ancestors.delete(value),Object.fromEntries(Object.entries({type,const:Object.hasOwn(schema,"const")?schema.const:void 0,enum:enumValues,min_length:minLength,min_items:minItems,format,properties:normalizedProperties,required:required===void 0?void 0:[...new Set(required)],additional_properties:additionalProperties,items:normalizedItems,one_of:normalizedOneOf}).filter(([,entry])=>entry!==void 0))}function normalizeStringList(values){const candidates=Array.isArray(values)?values:[];return[...new Set(candidates.map(value=>typeof value=="string"?value.trim():"").filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right))}function normalizeStatusId(value){if(typeof value!="string"||value.length===0)return;const normalized=normalizeStatusToken(value);return normalized.length>0?normalized:void 0}function stripFlagPrefix(value){return value.startsWith("--")?value.slice(2):value}function normalizeCliToken(value){return typeof value=="string"?stripFlagPrefix(value.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function keyToDefaultCliFlag(value){return value.replaceAll("_","-")}function toCamelCase(input){const segments=input.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(segment=>segment.length>0).map(segment=>segment.toLowerCase());if(segments.length===0)return input;const[first,...rest]=segments;return`${first}${rest.map(segment=>`${segment.slice(0,1).toUpperCase()}${segment.slice(1)}`).join("")}`}function normalizeRuntimeStatusDefinition(definition,fallbackOrder){const id=normalizeStatusId(definition.id);if(!id)return null;const aliases=[...new Set(normalizeStringList(definition.aliases).map(normalizeStatusToken).filter(value=>value.length>0))].sort((left,right)=>left.localeCompare(right)),roles=normalizeStringList(definition.roles).filter(value=>RUNTIME_STATUS_ROLE_SET.has(value)),description=definition.description?.trim(),order=typeof definition.order=="number"&&Number.isFinite(definition.order)?definition.order:fallbackOrder;return{id,aliases,roles,description:description&&description.length>0?description:void 0,order}}function normalizeRuntimeWorkflow(workflow){return{draft_status:normalizeStatusId(workflow?.draft_status),open_status:normalizeStatusId(workflow?.open_status),in_progress_status:normalizeStatusId(workflow?.in_progress_status),blocked_status:normalizeStatusId(workflow?.blocked_status),close_status:normalizeStatusId(workflow?.close_status),canceled_status:normalizeStatusId(workflow?.canceled_status)}}function appendTypeWorkflowPair(record,pair){if(!Array.isArray(pair)||pair.length!==2)return;const from=normalizeStatusToken(pair[0]),to=normalizeStatusToken(pair[1]);from.length===0||to.length===0||record.pairs.some(candidate=>candidate[0]===from&&candidate[1]===to)||record.pairs.push([from,to])}function normalizedTypeWorkflowEntry(entry){const rawType=typeof entry?.type=="string"?entry.type.trim():"";if(rawType.length===0||!Array.isArray(entry?.allowed_transitions))return null;const record={type:rawType,pairs:[],denyAll:entry.allowed_transitions.length===0};for(const pair of entry.allowed_transitions)appendTypeWorkflowPair(record,pair);return{typeKey:rawType.toLowerCase(),record}}function normalizeTypeWorkflowDefinitions(workflows){if(!Array.isArray(workflows)||workflows.length===0)return;const byTypeKey=new Map;for(const entry of workflows){const normalized2=normalizedTypeWorkflowEntry(entry);if(normalized2===null)continue;const record=byTypeKey.get(normalized2.typeKey)??normalized2.record;record.denyAll||=normalized2.record.denyAll;for(const pair of normalized2.record.pairs)appendTypeWorkflowPair(record,pair);byTypeKey.set(normalized2.typeKey,record)}const normalized=[];for(const record of byTypeKey.values())(record.pairs.length>0||record.denyAll)&&normalized.push({type:record.type,allowed_transitions:record.pairs});return normalized.sort((left,right)=>left.type.localeCompare(right.type)),normalized.length>0?normalized:void 0}function normalizeRuntimeFieldDefinition(definition){const key=normalizeStatusToken(definition.key??"");if(!key)return null;const metadataKey=normalizeStatusToken(definition.metadata_key??definition.front_matter_key??key),cliFlag=normalizeCliToken(definition.cli_flag??keyToDefaultCliFlag(key));if(!cliFlag)return null;const cliAliases=normalizeStringList(definition.cli_aliases).map(value=>normalizeCliToken(value)).filter(value=>value.length>0&&value!==cliFlag),typeCandidate=typeof definition.type=="string"?definition.type.trim().toLowerCase():"string",type=RUNTIME_FIELD_TYPE_SET.has(typeCandidate)?typeCandidate:"string",commands=(()=>{const normalized=normalizeStringList(definition.commands).filter(value=>RUNTIME_FIELD_COMMAND_SET.has(value));return normalized.length>0?normalized:[...DEFAULT_RUNTIME_FIELD_COMMANDS]})(),description=definition.description?.trim(),requiredTypes=normalizeStringList(definition.required_types),valueSchema=definition.value_schema===void 0?void 0:normalizeRuntimeFieldValueSchema(definition.value_schema);return definition.value_schema!==void 0&&valueSchema===void 0?null:{key,metadata_key:metadataKey,cli_flag:cliFlag,cli_aliases:cliAliases,description:description&&description.length>0?description:void 0,type,commands,repeatable:[definition.repeatable===!0,type==="string_array"].includes(!0),required:definition.required===!0,required_on_create:definition.required_on_create===!0,required_types:requiredTypes,allow_unset:definition.allow_unset!==!1,value_schema:valueSchema}}function normalizeRuntimeStatusDefinitions(statusesSource){const dedupedById=new Map;for(const[index,definition]of statusesSource.entries()){const normalized=normalizeRuntimeStatusDefinition(definition,index);normalized&&dedupedById.set(normalized.id,normalized)}const values=sortRuntimeStatusDefinitions([...dedupedById.values()]);return values.length>0?values:sortRuntimeStatusDefinitions(DEFAULT_RUNTIME_STATUS_DEFINITIONS.map((definition,index)=>normalizeRuntimeStatusDefinition(definition,index)).filter(definition=>definition!==null))}function sortRuntimeStatusDefinitions(definitions){return definitions.sort((left,right)=>left.order===right.order?left.id.localeCompare(right.id):left.order-right.order)}function normalizeRuntimeFieldDefinitions(fieldsSource){const dedupedByKey=new Map;for(const definition of fieldsSource??[]){const normalized=normalizeRuntimeFieldDefinition(definition);normalized&&dedupedByKey.set(normalized.key,normalized)}return[...dedupedByKey.values()].sort((left,right)=>left.key.localeCompare(right.key))}function serializeRuntimeStatusDefinition(definition){return{id:definition.id,aliases:definition.aliases.length>0?[...definition.aliases]:void 0,roles:definition.roles.length>0?[...definition.roles]:void 0,description:definition.description,order:definition.order}}function serializeRuntimeFieldDefinition(definition){return{key:definition.key,metadata_key:definition.metadata_key!==definition.key?definition.metadata_key:void 0,cli_flag:definition.cli_flag!==keyToDefaultCliFlag(definition.key)?definition.cli_flag:void 0,cli_aliases:definition.cli_aliases.length>0?[...definition.cli_aliases]:void 0,description:definition.description,type:definition.type,commands:[...definition.commands],repeatable:definition.repeatable===!0?!0:void 0,required:definition.required===!0?!0:void 0,required_on_create:definition.required_on_create===!0?!0:void 0,required_types:definition.required_types.length>0?[...definition.required_types]:void 0,allow_unset:definition.allow_unset===!1?!1:void 0,value_schema:definition.value_schema}}function normalizeUnknownFieldPolicy(policy){const candidate=typeof policy=="string"?policy.trim().toLowerCase():"allow";return RUNTIME_UNKNOWN_FIELD_POLICY_SET.has(candidate)?candidate:"allow"}function normalizeRuntimeSchemaSettings(schema){const files={...DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,...schema?.files},statusesSource=schema?.statuses&&schema.statuses.length>0?schema.statuses:DEFAULT_RUNTIME_STATUS_DEFINITIONS,normalizedStatuses=normalizeRuntimeStatusDefinitions(statusesSource),normalizedFields=normalizeRuntimeFieldDefinitions(schema?.fields);return{version:typeof schema?.version=="number"&&Number.isFinite(schema.version)?Math.floor(schema.version):1,files,statuses:normalizedStatuses.map(serializeRuntimeStatusDefinition),fields:normalizedFields.map(serializeRuntimeFieldDefinition),workflow:{...DEFAULT_RUNTIME_WORKFLOW,...normalizeRuntimeWorkflow(schema?.workflow)},type_workflows:normalizeTypeWorkflowDefinitions(schema?.type_workflows),unknown_field_policy:normalizeUnknownFieldPolicy(schema?.unknown_field_policy)}}function parseOptionalJson(raw,warningKey,warnings){try{return JSON.parse(raw)}catch{warnings.push(warningKey);return}}function readTypeDefinitionsFromSchemaFile(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.definitions))return record.definitions;if(typeof record.item_types=="object"&&record.item_types!==null){const itemTypesRecord=record.item_types;if(Array.isArray(itemTypesRecord.definitions))return itemTypesRecord.definitions}}function readStatusesFromSchemaFile(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.statuses))return record.statuses;if(Array.isArray(record.definitions))return record.definitions}function readFieldsFromSchemaFile(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.fields))return record.fields;if(Array.isArray(record.definitions))return record.definitions}function readWorkflowFromSchemaFile(parsed){if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))return;const record=parsed;return typeof record.workflow=="object"&&record.workflow!==null&&!Array.isArray(record.workflow)?record.workflow:typeof record.workflows=="object"&&record.workflows!==null&&!Array.isArray(record.workflows)?record.workflows:record}function readTypeWorkflowsFromSchemaFile(parsed){if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))return;const record=parsed;if(Array.isArray(record.type_workflows))return record.type_workflows}function filePathForSchemaSection(pmRoot,configuredPath,fallbackPath){const normalized=configuredPath?.trim()||fallbackPath;return path.isAbsolute(normalized)?normalized:path.join(pmRoot,normalized)}function resolveItemTypesFilePath(pmRoot,schema){return filePathForSchemaSection(pmRoot,schema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types)}async function ensureRuntimeSchemaFileScaffold(pmRoot,schema){const normalizedSchema=normalizeRuntimeSchemaSettings(schema),specs=[{path:filePathForSchemaSection(pmRoot,normalizedSchema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types),seed:{definitions:[]}},{path:filePathForSchemaSection(pmRoot,normalizedSchema.files.statuses,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses),seed:{statuses:DEFAULT_RUNTIME_STATUS_DEFINITIONS}},{path:filePathForSchemaSection(pmRoot,normalizedSchema.files.fields,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields),seed:{fields:[]}},{path:filePathForSchemaSection(pmRoot,normalizedSchema.files.workflows,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.workflows),seed:{workflow:DEFAULT_RUNTIME_WORKFLOW}}],createdPaths=[];for(const spec of specs)await pathExists(spec.path)||await createFileAtomic(spec.path,`${JSON.stringify(spec.seed,null,2)}
2
- `)&&createdPaths.push(spec.path);return{created_paths:createdPaths}}async function loadRuntimeSchemaFromOptionalFiles(pmRoot,schema){const normalizedSchema=normalizeRuntimeSchemaSettings(schema),warnings=[],typeFilePath=filePathForSchemaSection(pmRoot,normalizedSchema.files.types,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.types),statusFilePath=filePathForSchemaSection(pmRoot,normalizedSchema.files.statuses,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.statuses),fieldsFilePath=filePathForSchemaSection(pmRoot,normalizedSchema.files.fields,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.fields),workflowsFilePath=filePathForSchemaSection(pmRoot,normalizedSchema.files.workflows,DEFAULT_RUNTIME_SCHEMA_FILE_PATHS.workflows);let loadedTypeDefinitions,loadedStatuses,loadedFields,loadedWorkflow,loadedTypeWorkflows;const readAndParse=async(targetPath,warningKey)=>{const raw=await readFileIfExists(targetPath);if(raw!==null)return parseOptionalJson(raw,warningKey,warnings)},parsedTypes=await readAndParse(typeFilePath,"runtime_schema_types_invalid_json");parsedTypes!==void 0&&(loadedTypeDefinitions=readTypeDefinitionsFromSchemaFile(parsedTypes),loadedTypeDefinitions===void 0&&warnings.push("runtime_schema_types_invalid_shape"));const parsedStatuses=await readAndParse(statusFilePath,"runtime_schema_statuses_invalid_json");parsedStatuses!==void 0&&(loadedStatuses=readStatusesFromSchemaFile(parsedStatuses),loadedStatuses===void 0&&warnings.push("runtime_schema_statuses_invalid_shape"));const parsedFields=await readAndParse(fieldsFilePath,"runtime_schema_fields_invalid_json");parsedFields!==void 0&&(loadedFields=readFieldsFromSchemaFile(parsedFields),loadedFields===void 0&&warnings.push("runtime_schema_fields_invalid_shape"));const parsedWorkflow=await readAndParse(workflowsFilePath,"runtime_schema_workflows_invalid_json");return parsedWorkflow!==void 0&&(loadedWorkflow=readWorkflowFromSchemaFile(parsedWorkflow),loadedWorkflow===void 0&&warnings.push("runtime_schema_workflows_invalid_shape"),loadedTypeWorkflows=readTypeWorkflowsFromSchemaFile(parsedWorkflow)),{schema:normalizeRuntimeSchemaSettings({...normalizedSchema,statuses:[...normalizedSchema.statuses,...loadedStatuses??[]],fields:[...normalizedSchema.fields,...loadedFields??[]],workflow:{...normalizedSchema.workflow,...loadedWorkflow},type_workflows:[...normalizedSchema.type_workflows??[],...loadedTypeWorkflows??[]]}),type_definitions_from_file:loadedTypeDefinitions,warnings,created_paths:[]}}function preferredStatusForRole(definitions,role,fallbackValues,fallbackFirst=!1){const fallbackMatch=fallbackValues.map(value=>normalizeStatusId(value)).filter(value=>typeof value=="string").find(normalized=>definitions.some(definition=>definition.id===normalized));if(fallbackFirst&&fallbackMatch!==void 0)return fallbackMatch;const withRole=definitions.find(definition=>definition.roles.includes(role));return withRole!==void 0?withRole.id:fallbackMatch??definitions[0]?.id}function buildRuntimeStatusIndexes(definitions){const aliasToId=new Map,byId=new Map;for(const definition of definitions){byId.set(definition.id,definition),aliasToId.set(definition.id,definition.id),aliasToId.set(definition.id.replaceAll("_","-"),definition.id),aliasToId.set(definition.id.replaceAll("_"," "),definition.id);for(const alias of definition.aliases)aliasToId.set(alias,definition.id),aliasToId.set(alias.replaceAll("_","-"),definition.id),aliasToId.set(alias.replaceAll("_"," "),definition.id)}return{aliasToId,byId}}function buildRuntimeStatusRoleSets(definitions){const result={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(const definition of definitions){const roles=new Set(definition.roles);(roles.has("terminal")||roles.has("terminal_done")||roles.has("terminal_canceled"))&&result.terminalStatuses.add(definition.id),roles.has("terminal_done")&&result.terminalDoneStatuses.add(definition.id),roles.has("terminal_canceled")&&result.terminalCanceledStatuses.add(definition.id),roles.has("active")&&result.activeStatuses.add(definition.id),roles.has("blocked")&&result.blockedStatuses.add(definition.id),roles.has("draft")&&result.draftStatuses.add(definition.id)}return result}function resolveRuntimeStatusRegistry(schema){const normalizedSchema=normalizeRuntimeSchemaSettings(schema),definitions=normalizedSchema.statuses.map((definition,index)=>normalizeRuntimeStatusDefinition(definition,index)).filter(definition=>definition!==null),{aliasToId,byId}=buildRuntimeStatusIndexes(definitions),{activeStatuses,blockedStatuses,draftStatuses,terminalCanceledStatuses,terminalDoneStatuses,terminalStatuses}=buildRuntimeStatusRoleSets(definitions),workflow=normalizedSchema.workflow,openStatus=normalizeStatusId(workflow.open_status)??preferredStatusForRole(definitions,"default_open",["open","in_progress",STATUS_VALUES[0]]),inProgressStatus=normalizeStatusId(workflow.in_progress_status)??preferredStatusForRole(definitions,"active",["in_progress","in-progress",openStatus],!0),blockedStatus=normalizeStatusId(workflow.blocked_status)??preferredStatusForRole(definitions,"blocked",["blocked"]),closeStatus=normalizeStatusId(workflow.close_status)??preferredStatusForRole(definitions,"default_close",["closed","done","complete"]),canceledStatus=normalizeStatusId(workflow.canceled_status)??preferredStatusForRole(definitions,"default_cancel",["canceled","cancelled"]);return{definitions,by_id:byId,alias_to_id:aliasToId,terminal_statuses:terminalStatuses,terminal_done_statuses:terminalDoneStatuses,terminal_canceled_statuses:terminalCanceledStatuses,active_statuses:activeStatuses,blocked_statuses:blockedStatuses,draft_statuses:draftStatuses,open_status:openStatus,in_progress_status:inProgressStatus,blocked_status:blockedStatus,close_status:closeStatus,canceled_status:canceledStatus}}function normalizeStatusInputWithRegistry(value,registry){const normalized=normalizeStatusToken(value);if(normalized)return registry.alias_to_id.get(normalized)}function resolveRuntimeFieldRegistry(schema){const normalizedSchema=normalizeRuntimeSchemaSettings(schema),dedupedByKey=new Map,normalizedFields=normalizedSchema.fields.map(definition=>normalizeRuntimeFieldDefinition(definition)).filter(definition=>definition!==null);for(const normalized of normalizedFields)dedupedByKey.set(normalized.key,normalized);const definitions=[...dedupedByKey.values()].sort((left,right)=>left.key.localeCompare(right.key)),byKey=new Map,byCliToken=new Map,commandToFields=new Map;for(const definition of definitions){byKey.set(definition.key,definition),byCliToken.set(definition.cli_flag,definition);for(const alias of definition.cli_aliases)byCliToken.set(alias,definition);for(const command of definition.commands){const existing=commandToFields.get(command)??[];existing.push(definition),commandToFields.set(command,existing)}}for(const[command,fieldDefinitions]of commandToFields.entries())fieldDefinitions.sort((left,right)=>left.key.localeCompare(right.key)),commandToFields.set(command,fieldDefinitions);return{definitions,by_key:byKey,by_cli_token:byCliToken,command_to_fields:commandToFields}}function runtimeFieldOptionTarget(field){return toCamelCase(field.key)}function statusIsTerminal(status,registry){const normalized=normalizeStatusInputWithRegistry(status,registry);return normalized?registry.terminal_statuses.has(normalized):!1}export{DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,DEFAULT_RUNTIME_STATUS_DEFINITIONS,DEFAULT_RUNTIME_WORKFLOW,ensureRuntimeSchemaFileScaffold,filePathForSchemaSection,loadRuntimeSchemaFromOptionalFiles,normalizeRuntimeSchemaSettings,normalizeStatusInputWithRegistry,resolveItemTypesFilePath,resolveRuntimeFieldRegistry,resolveRuntimeStatusRegistry,runtimeFieldOptionTarget,statusIsTerminal};
1
+ import U from"node:path";import{pathExists as W,readFileIfExists as v}from"../fs/fs-utils.js";import{createFileAtomic as K}from"../fs/atomic-create.js";import{DEFAULT_STATUS_DEFINITIONS as V,DEFAULT_WORKFLOW_DEFINITION as H}from"../shared/constants.js";import{RUNTIME_FIELD_COMMAND_VALUES as Y,RUNTIME_FIELD_TYPE_VALUES as $,RUNTIME_STATUS_ROLE_VALUES as J,RUNTIME_UNKNOWN_FIELD_POLICY_VALUES as B,STATUS_VALUES as X}from"../../types/index.js";import{normalizeStatusToken as k}from"./status-token.js";const m=Object.freeze({types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"}),O=H,D=V,Z=["create","update"],G=new Set(J),Q=new Set($),ee=new Set(Y),te=new Set(B),ne=new Set(["string","number","boolean","array","object"]),re=16;function R(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const se=[e=>e.type===void 0||typeof e.type=="string"&&ne.has(e.type),e=>!Object.hasOwn(e,"const")||E(e.const),e=>e.enum===void 0||Array.isArray(e.enum)&&e.enum.every(t=>E(t)),e=>e.min_length===void 0||Number.isInteger(e.min_length)&&e.min_length>=0,e=>e.min_items===void 0||Number.isInteger(e.min_items)&&e.min_items>=0,e=>e.format===void 0||e.format==="date-time",e=>e.required===void 0||Array.isArray(e.required)&&e.required.every(t=>typeof t=="string"&&t.length>0),e=>e.additional_properties===void 0||typeof e.additional_properties=="boolean",e=>e.properties===void 0||R(e.properties),e=>e.one_of===void 0||Array.isArray(e.one_of)&&e.one_of.length>0];function E(e,t=new Set){if(e===null||typeof e=="string"||typeof e=="boolean")return!0;if(typeof e=="number")return Number.isFinite(e);if(typeof e!="object"||t.has(e))return!1;t.add(e);const n=Array.isArray(e)?e.every(r=>E(r,t)):Object.values(e).every(r=>E(r,t));return t.delete(e),n}function I(e,t=0,n=new Set){if(!R(e)||t>re||n.has(e))return;n.add(e);const r=e,s=r.type,o=r.enum,u=r.one_of,a=r.properties,i=r.items,d=r.required,c=r.min_length,l=r.min_items,p=r.format,w=r.additional_properties;if(!se.every(_=>_(r))){n.delete(e);return}const h=a===void 0?void 0:Object.fromEntries(Object.entries(a).map(([_,z])=>[_,I(z,t+1,n)])),A=i===void 0?void 0:I(i,t+1,n),g=u===void 0?void 0:u.map(_=>I(_,t+1,n));if([...Object.values(h??{}),...i===void 0?[]:[A],...g??[]].some(_=>_===void 0)){n.delete(e);return}return n.delete(e),Object.fromEntries(Object.entries({type:s,const:Object.hasOwn(r,"const")?r.const:void 0,enum:o,min_length:c,min_items:l,format:p,properties:h,required:d===void 0?void 0:[...new Set(d)],additional_properties:w,items:A,one_of:g}).filter(([,_])=>_!==void 0))}function T(e){const t=Array.isArray(e)?e:[];return[...new Set(t.map(n=>typeof n=="string"?n.trim():"").filter(n=>n.length>0))].sort((n,r)=>n.localeCompare(r))}function f(e){if(typeof e!="string"||e.length===0)return;const t=k(e);return t.length>0?t:void 0}function ie(e){return e.startsWith("--")?e.slice(2):e}function M(e){return typeof e=="string"?ie(e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-")):""}function j(e){return e.replaceAll("_","-")}function oe(e){const t=e.replaceAll(/[^A-Za-z0-9]+/g," ").trim().split(/\s+/).filter(s=>s.length>0).map(s=>s.toLowerCase());if(t.length===0)return e;const[n,...r]=t;return`${n}${r.map(s=>`${s.slice(0,1).toUpperCase()}${s.slice(1)}`).join("")}`}function L(e,t){const n=f(e.id);if(!n)return null;const r=[...new Set(T(e.aliases).map(k).filter(a=>a.length>0))].sort((a,i)=>a.localeCompare(i)),s=T(e.roles).filter(a=>G.has(a)),o=e.description?.trim(),u=typeof e.order=="number"&&Number.isFinite(e.order)?e.order:t;return{id:n,aliases:r,roles:s,description:o&&o.length>0?o:void 0,order:u}}function ae(e){return{draft_status:f(e?.draft_status),open_status:f(e?.open_status),in_progress_status:f(e?.in_progress_status),blocked_status:f(e?.blocked_status),close_status:f(e?.close_status),canceled_status:f(e?.canceled_status)}}function C(e,t){if(!Array.isArray(t)||t.length!==2)return;const n=k(t[0]),r=k(t[1]);n.length===0||r.length===0||e.pairs.some(s=>s[0]===n&&s[1]===r)||e.pairs.push([n,r])}function le(e){const t=typeof e?.type=="string"?e.type.trim():"";if(t.length===0||!Array.isArray(e?.allowed_transitions))return null;const n={type:t,pairs:[],denyAll:e.allowed_transitions.length===0};for(const r of e.allowed_transitions)C(n,r);return{typeKey:t.toLowerCase(),record:n}}function ue(e){if(!Array.isArray(e)||e.length===0)return;const t=new Map;for(const r of e){const s=le(r);if(s===null)continue;const o=t.get(s.typeKey)??s.record;o.denyAll||=s.record.denyAll;for(const u of s.record.pairs)C(o,u);t.set(s.typeKey,o)}const n=[];for(const r of t.values())(r.pairs.length>0||r.denyAll)&&n.push({type:r.type,allowed_transitions:r.pairs});return n.sort((r,s)=>r.type.localeCompare(s.type)),n.length>0?n:void 0}function P(e){const t=k(e.key??"");if(!t)return null;const n=k(e.metadata_key??e.front_matter_key??t),r=M(e.cli_flag??j(t));if(!r)return null;const s=T(e.cli_aliases).map(l=>M(l)).filter(l=>l.length>0&&l!==r),o=typeof e.type=="string"?e.type.trim().toLowerCase():"string",u=Q.has(o)?o:"string",a=(()=>{const l=T(e.commands).filter(p=>ee.has(p));return l.length>0?l:[...Z]})(),i=e.description?.trim(),d=T(e.required_types),c=e.value_schema===void 0?void 0:I(e.value_schema);return e.value_schema!==void 0&&c===void 0?null:{key:t,metadata_key:n,cli_flag:r,cli_aliases:s,description:i&&i.length>0?i:void 0,type:u,commands:a,repeatable:[e.repeatable===!0,u==="string_array"].includes(!0),required:e.required===!0,required_on_create:e.required_on_create===!0,required_types:d,allow_unset:e.allow_unset!==!1,value_schema:c}}function de(e){const t=new Map;for(const[r,s]of e.entries()){const o=L(s,r);o&&t.set(o.id,o)}const n=q([...t.values()]);return n.length>0?n:q(D.map((r,s)=>L(r,s)).filter(r=>r!==null))}function q(e){return e.sort((t,n)=>t.order===n.order?t.id.localeCompare(n.id):t.order-n.order)}function ce(e){const t=new Map;for(const n of e??[]){const r=P(n);r&&t.set(r.key,r)}return[...t.values()].sort((n,r)=>n.key.localeCompare(r.key))}function fe(e){return{id:e.id,aliases:e.aliases.length>0?[...e.aliases]:void 0,roles:e.roles.length>0?[...e.roles]:void 0,description:e.description,order:e.order}}function _e(e){return{key:e.key,metadata_key:e.metadata_key!==e.key?e.metadata_key:void 0,cli_flag:e.cli_flag!==j(e.key)?e.cli_flag:void 0,cli_aliases:e.cli_aliases.length>0?[...e.cli_aliases]:void 0,description:e.description,type:e.type,commands:[...e.commands],repeatable:e.repeatable===!0?!0:void 0,required:e.required===!0?!0:void 0,required_on_create:e.required_on_create===!0?!0:void 0,required_types:e.required_types.length>0?[...e.required_types]:void 0,allow_unset:e.allow_unset===!1?!1:void 0,value_schema:e.value_schema}}function me(e){const t=typeof e=="string"?e.trim().toLowerCase():"allow";return te.has(t)?t:"allow"}function F(e){const t={...m,...e?.files},n=e?.statuses&&e.statuses.length>0?e.statuses:D,r=de(n),s=ce(e?.fields);return{version:typeof e?.version=="number"&&Number.isFinite(e.version)?Math.floor(e.version):1,files:t,statuses:r.map(fe),fields:s.map(_e),workflow:{...O,...ae(e?.workflow)},type_workflows:ue(e?.type_workflows),unknown_field_policy:me(e?.unknown_field_policy)}}function pe(e,t,n){try{return JSON.parse(e)}catch{n.push(t);return}}function ye(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.definitions))return t.definitions;if(typeof t.item_types=="object"&&t.item_types!==null){const n=t.item_types;if(Array.isArray(n.definitions))return n.definitions}}function we(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function Se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function he(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;return typeof t.workflow=="object"&&t.workflow!==null&&!Array.isArray(t.workflow)?t.workflow:typeof t.workflows=="object"&&t.workflows!==null&&!Array.isArray(t.workflows)?t.workflows:t}function Ae(e){if(typeof e!="object"||e===null||Array.isArray(e))return;const t=e;if(Array.isArray(t.type_workflows))return t.type_workflows}function y(e,t,n){const r=t?.trim()||n;return U.isAbsolute(r)?r:U.join(e,r)}function Le(e,t){return y(e,t.files.types,m.types)}async function Ne(e,t){const n=F(t),r=[{path:y(e,n.files.types,m.types),seed:{definitions:[]}},{path:y(e,n.files.statuses,m.statuses),seed:{statuses:D}},{path:y(e,n.files.fields,m.fields),seed:{fields:[]}},{path:y(e,n.files.workflows,m.workflows),seed:{workflow:O}}],s=[];for(const o of r)await W(o.path)||await K(o.path,`${JSON.stringify(o.seed,null,2)}
2
+ `)&&s.push(o.path);return{created_paths:s}}async function Ue(e,t){const n=F(t),r=[],s=y(e,n.files.types,m.types),o=y(e,n.files.statuses,m.statuses),u=y(e,n.files.fields,m.fields),a=y(e,n.files.workflows,m.workflows);let i,d,c,l,p;const w=async(z,x)=>{const N=await v(z);if(N!==null)return pe(N,x,r)},h=await w(s,"runtime_schema_types_invalid_json");h!==void 0&&(i=ye(h),i===void 0&&r.push("runtime_schema_types_invalid_shape"));const A=await w(o,"runtime_schema_statuses_invalid_json");A!==void 0&&(d=we(A),d===void 0&&r.push("runtime_schema_statuses_invalid_shape"));const g=await w(u,"runtime_schema_fields_invalid_json");g!==void 0&&(c=Se(g),c===void 0&&r.push("runtime_schema_fields_invalid_shape"));const S=await w(a,"runtime_schema_workflows_invalid_json");return S!==void 0&&(l=he(S),l===void 0&&r.push("runtime_schema_workflows_invalid_shape"),p=Ae(S)),{schema:F({...n,statuses:[...n.statuses,...d??[]],fields:[...n.fields,...c??[]],workflow:{...n.workflow,...l},type_workflows:[...n.type_workflows??[],...p??[]]}),type_definitions_from_file:i,warnings:r,created_paths:[]}}function b(e,t,n,r=!1){const o=n.map(a=>f(a)).filter(a=>typeof a=="string").find(a=>e.some(i=>i.id===a));if(r&&o!==void 0)return o;const u=e.find(a=>a.roles.includes(t));return u!==void 0?u.id:o??e[0]?.id}function ge(e){const t=new Map,n=new Map;for(const r of e){n.set(r.id,r),t.set(r.id,r.id),t.set(r.id.replaceAll("_","-"),r.id),t.set(r.id.replaceAll("_"," "),r.id);for(const s of r.aliases)t.set(s,r.id),t.set(s.replaceAll("_","-"),r.id),t.set(s.replaceAll("_"," "),r.id)}return{aliasToId:t,byId:n}}function ke(e){const t={activeStatuses:new Set,blockedStatuses:new Set,draftStatuses:new Set,terminalCanceledStatuses:new Set,terminalDoneStatuses:new Set,terminalStatuses:new Set};for(const n of e){const r=new Set(n.roles);(r.has("terminal")||r.has("terminal_done")||r.has("terminal_canceled"))&&t.terminalStatuses.add(n.id),r.has("terminal_done")&&t.terminalDoneStatuses.add(n.id),r.has("terminal_canceled")&&t.terminalCanceledStatuses.add(n.id),r.has("active")&&t.activeStatuses.add(n.id),r.has("blocked")&&t.blockedStatuses.add(n.id),r.has("draft")&&t.draftStatuses.add(n.id)}return t}function Oe(e){const t=F(e),n=t.statuses.map((S,_)=>L(S,_)).filter(S=>S!==null),{aliasToId:r,byId:s}=ge(n),{activeStatuses:o,blockedStatuses:u,draftStatuses:a,terminalCanceledStatuses:i,terminalDoneStatuses:d,terminalStatuses:c}=ke(n),l=t.workflow,p=f(l.open_status)??b(n,"default_open",["open","in_progress",X[0]]),w=f(l.in_progress_status)??b(n,"active",["in_progress","in-progress",p],!0),h=f(l.blocked_status)??b(n,"blocked",["blocked"]),A=f(l.close_status)??b(n,"default_close",["closed","done","complete"]),g=f(l.canceled_status)??b(n,"default_cancel",["canceled","cancelled"]);return{definitions:n,by_id:s,alias_to_id:r,terminal_statuses:c,terminal_done_statuses:d,terminal_canceled_statuses:i,active_statuses:o,blocked_statuses:u,draft_statuses:a,open_status:p,in_progress_status:w,blocked_status:h,close_status:A,canceled_status:g}}function Te(e,t){const n=k(e);if(n)return t.alias_to_id.get(n)}function Re(e){const t=F(e),n=new Map,r=t.fields.map(i=>P(i)).filter(i=>i!==null);for(const i of r)n.set(i.key,i);const s=[...n.values()].sort((i,d)=>i.key.localeCompare(d.key)),o=new Map,u=new Map,a=new Map;for(const i of s){o.set(i.key,i),u.set(i.cli_flag,i);for(const d of i.cli_aliases)u.set(d,i);for(const d of i.commands){const c=a.get(d)??[];c.push(i),a.set(d,c)}}for(const[i,d]of a.entries())d.sort((c,l)=>c.key.localeCompare(l.key)),a.set(i,d);return{definitions:s,by_key:o,by_cli_token:u,command_to_fields:a}}function Me(e){return oe(e.key)}function je(e,t){const n=Te(e,t);return n?t.terminal_statuses.has(n):!1}export{m as DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,D as DEFAULT_RUNTIME_STATUS_DEFINITIONS,O as DEFAULT_RUNTIME_WORKFLOW,Ne as ensureRuntimeSchemaFileScaffold,y as filePathForSchemaSection,Ue as loadRuntimeSchemaFromOptionalFiles,F as normalizeRuntimeSchemaSettings,Te as normalizeStatusInputWithRegistry,Le as resolveItemTypesFilePath,Re as resolveRuntimeFieldRegistry,Oe as resolveRuntimeStatusRegistry,Me as runtimeFieldOptionTarget,je as statusIsTerminal};
3
3
  //# sourceMappingURL=runtime-schema.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]="b1e4c04e-0ade-5d24-95e3-b8dca3832c5a")}catch{}})();import{RUNTIME_STATUS_ROLE_VALUES}from"../../types/index.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS}from"./runtime-schema.js";import{normalizeStatusToken}from"./status-token.js";import{normalizeStatusToken as normalizeStatusToken2}from"./status-token.js";const RUNTIME_STATUS_ROLE_SET=new Set(RUNTIME_STATUS_ROLE_VALUES),BUILTIN_STATUS_IDS=new Set(DEFAULT_RUNTIME_STATUS_DEFINITIONS.map(definition=>normalizeStatusToken(definition.id)).filter(id=>id.length>0));function dedupeTokens(values){const seen=new Set;for(const value of values){const token=normalizeStatusToken(value);token.length>0&&seen.add(token)}return[...seen].sort((left,right)=>left.localeCompare(right))}function normalizeAddStatusInput(raw){const id=normalizeStatusToken(raw.id);if(id.length===0)throw new Error("Status id must not be empty.");if(BUILTIN_STATUS_IDS.has(id))throw new Error(`Cannot add-status the built-in status "${id}". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(", ")}.`);let roles;if(raw.roles!==void 0){roles=[];const seenRoles=new Set;for(const rawRole of raw.roles){const role=typeof rawRole=="string"?rawRole.trim().toLowerCase():"";if(role.length!==0){if(!RUNTIME_STATUS_ROLE_SET.has(role))throw new Error(`Invalid status role "${rawRole}". Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(", ")}.`);seenRoles.has(role)||(seenRoles.add(role),roles.push(role))}}if(roles.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(", ")}.`)}const aliases=raw.aliases===void 0?void 0:dedupeTokens(raw.aliases).filter(alias=>alias!==id),description=raw.description?.trim(),order=typeof raw.order=="number"&&Number.isFinite(raw.order)?Math.trunc(raw.order):void 0;return{id,roles,aliases,description:description&&description.length>0?description:void 0,order}}function selectStatusesArray(parsed){if(Array.isArray(parsed))return parsed;if(typeof parsed!="object"||parsed===null)return;const record=parsed;if(Array.isArray(record.statuses))return record.statuses;if(Array.isArray(record.definitions))return record.definitions}function extractStatusDefinitions(parsed){const candidate=selectStatusesArray(parsed);if(!candidate)return[];const definitions=[];for(const entry of candidate){if(typeof entry!="object"||entry===null||Array.isArray(entry))continue;const record=entry;typeof record.id!="string"||record.id.trim().length===0||definitions.push(record)}return definitions}function parseStatusDefsFile(raw){if(raw==null||raw.trim().length===0)return{statuses:[]};let parsed;try{parsed=JSON.parse(raw)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:extractStatusDefinitions(parsed)}}function serializeStatusDefsFile(file){return`${JSON.stringify({statuses:file.statuses},null,2)}
2
- `}function upsertStatusDef(file,input,baseDefinition){const statuses=file.statuses.slice(),existingIndex=statuses.findIndex(definition=>normalizeStatusToken(definition.id)===input.id),existing=existingIndex>=0?statuses[existingIndex]:baseDefinition,next={...existing,id:input.id};return input.roles!==void 0&&(input.roles.length>0?next.roles=[...input.roles]:next.roles!==void 0&&delete next.roles),input.aliases!==void 0&&(input.aliases.length>0?next.aliases=[...input.aliases]:next.aliases!==void 0&&delete next.aliases),input.description!==void 0&&(next.description=input.description),input.order!==void 0&&(next.order=input.order),existingIndex>=0?statuses[existingIndex]=next:statuses.push(next),{file:{statuses},definition:next,replaced:existing!==void 0}}function removeStatusDef(file,id){const normalizedId=normalizeStatusToken(id);if(normalizedId.length===0)throw new Error("Status id must not be empty.");if(BUILTIN_STATUS_IDS.has(normalizedId))throw new Error(`Cannot remove built-in status "${normalizedId}". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(", ")}.`);const statuses=file.statuses.slice(),existingIndex=statuses.findIndex(definition2=>normalizeStatusToken(definition2.id)===normalizedId);if(existingIndex<0)return{file:{statuses},removed:!1};const[definition]=statuses.splice(existingIndex,1);return{file:{statuses},removed:!0,definition}}function assertStatusTokensAvailable(input,resolvedAliasToId){const candidates=[input.id,...input.aliases??[]];for(const candidate of candidates){const token=normalizeStatusToken(candidate);if(token.length===0)continue;const owner=resolvedAliasToId.get(token);if(owner!==void 0&&owner!==input.id)throw new Error(`Status token "${token}" already belongs to status "${owner}". Choose a different id/alias to avoid shadowing it.`)}}export{BUILTIN_STATUS_IDS,assertStatusTokensAvailable,normalizeAddStatusInput,normalizeStatusToken2 as normalizeStatusToken,parseStatusDefsFile,removeStatusDef,serializeStatusDefsFile,upsertStatusDef};
1
+ import{RUNTIME_STATUS_ROLE_VALUES as u}from"../../types/index.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS as c}from"./runtime-schema.js";import{normalizeStatusToken as d}from"./status-token.js";import{normalizeStatusToken as N}from"./status-token.js";const h=new Set(u),l=new Set(c.map(e=>d(e.id)).filter(e=>e.length>0));function S(e){const t=new Set;for(const s of e){const n=d(s);n.length>0&&t.add(n)}return[...t].sort((s,n)=>s.localeCompare(n))}function T(e){const t=d(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(l.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...l].join(", ")}.`);let s;if(e.roles!==void 0){s=[];const o=new Set;for(const a of e.roles){const f=typeof a=="string"?a.trim().toLowerCase():"";if(f.length!==0){if(!h.has(f))throw new Error(`Invalid status role "${a}". Allowed roles: ${u.join(", ")}.`);o.has(f)||(o.add(f),s.push(f))}}if(s.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${u.join(", ")}.`)}const n=e.aliases===void 0?void 0:S(e.aliases).filter(o=>o!==t),i=e.description?.trim(),r=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:s,aliases:n,description:i&&i.length>0?i:void 0,order:r}}function m(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;const t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function g(e){const t=m(e);if(!t)return[];const s=[];for(const n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;const i=n;typeof i.id!="string"||i.id.trim().length===0||s.push(i)}return s}function x(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:g(t)}}function E(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
2
+ `}function I(e,t,s){const n=e.statuses.slice(),i=n.findIndex(a=>d(a.id)===t.id),r=i>=0?n[i]:s,o={...r,id:t.id};return t.roles!==void 0&&(t.roles.length>0?o.roles=[...t.roles]:o.roles!==void 0&&delete o.roles),t.aliases!==void 0&&(t.aliases.length>0?o.aliases=[...t.aliases]:o.aliases!==void 0&&delete o.aliases),t.description!==void 0&&(o.description=t.description),t.order!==void 0&&(o.order=t.order),i>=0?n[i]=o:n.push(o),{file:{statuses:n},definition:o,replaced:r!==void 0}}function w(e,t){const s=d(t);if(s.length===0)throw new Error("Status id must not be empty.");if(l.has(s))throw new Error(`Cannot remove built-in status "${s}". Built-in statuses are reserved: ${[...l].join(", ")}.`);const n=e.statuses.slice(),i=n.findIndex(o=>d(o.id)===s);if(i<0)return{file:{statuses:n},removed:!1};const[r]=n.splice(i,1);return{file:{statuses:n},removed:!0,definition:r}}function v(e,t){const s=[e.id,...e.aliases??[]];for(const n of s){const i=d(n);if(i.length===0)continue;const r=t.get(i);if(r!==void 0&&r!==e.id)throw new Error(`Status token "${i}" already belongs to status "${r}". Choose a different id/alias to avoid shadowing it.`)}}export{l as BUILTIN_STATUS_IDS,v as assertStatusTokensAvailable,T as normalizeAddStatusInput,N as normalizeStatusToken,x as parseStatusDefsFile,w as removeStatusDef,E as serializeStatusDefsFile,I as upsertStatusDef};
3
3
  //# sourceMappingURL=status-defs-file.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]="2075887b-6d4b-582f-9da2-bab13198f9a5")}catch{}})();import{evictOldestMemoEntries}from"../shared/memo.js";const STATUS_TOKEN_MEMO_MAX_ENTRIES=2e3,statusTokenMemo=new Map;function normalizeStatusToken(value){if(typeof value!="string")return"";const memoized=statusTokenMemo.get(value);if(memoized!==void 0)return memoized;const normalized=value.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return statusTokenMemo.size>=STATUS_TOKEN_MEMO_MAX_ENTRIES&&evictOldestMemoEntries(statusTokenMemo),statusTokenMemo.set(value,normalized),normalized}export{normalizeStatusToken};
1
+ import{evictOldestMemoEntries as r}from"../shared/memo.js";const i=2e3,t=new Map;function m(e){if(typeof e!="string")return"";const n=t.get(e);if(n!==void 0)return n;const o=e.trim().toLowerCase().replaceAll(/[\s-]+/g,"_");return t.size>=i&&r(t),t.set(e,o),o}export{m as normalizeStatusToken};
2
2
  //# sourceMappingURL=status-token.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]="4d01ffa0-2cdb-5d22-834e-d23d31403ad6")}catch{}})();import{matchBuiltinTypeName}from"./item-types-file.js";const PREFIX_PATTERN=/^([A-Za-z][A-Za-z0-9_-]*?)\s*[-:]\s+\S/;function extractTitlePrefix(title){const match=PREFIX_PATTERN.exec(title.trim());if(!match)return;const token=match[1];if(!(token.length<2)&&!/^[A-Za-z]\d+$/.test(token))return token.toLowerCase()}function prefixToTypeName(prefix){return prefix.split(/[-_]+/).filter(segment=>segment.length>0).map(segment=>`${segment.slice(0,1).toUpperCase()}${segment.slice(1).toLowerCase()}`).join("")}function inferTypesFromTitles(titles,options={}){const minCount=typeof options.minCount=="number"&&options.minCount>0?Math.trunc(options.minCount):10,maxExamples=typeof options.maxExamples=="number"&&options.maxExamples>0?Math.trunc(options.maxExamples):3,byPrefix=new Map;for(const rawTitle of titles){const title=typeof rawTitle=="string"?rawTitle.trim():"";if(title.length===0)continue;const prefix=extractTitlePrefix(title);if(prefix===void 0)continue;const bucket=byPrefix.get(prefix)??{count:0,examples:[]};bucket.count+=1,bucket.examples.length<maxExamples&&bucket.examples.push(title),byPrefix.set(prefix,bucket)}const candidates=[];for(const[prefix,bucket]of byPrefix.entries()){if(bucket.count<minCount)continue;const name=prefixToTypeName(prefix);candidates.push({name,prefix,count:bucket.count,examples:bucket.examples,shadows_builtin:matchBuiltinTypeName(name)!==void 0})}return candidates.sort((left,right)=>right.count-left.count||left.name.localeCompare(right.name)),candidates}export{extractTitlePrefix,inferTypesFromTitles,prefixToTypeName};
1
+ import{matchBuiltinTypeName as m}from"./item-types-file.js";const f=/^([A-Za-z][A-Za-z0-9_-]*?)\s*[-:]\s+\S/;function p(i){const e=f.exec(i.trim());if(!e)return;const r=e[1];if(!(r.length<2)&&!/^[A-Za-z]\d+$/.test(r))return r.toLowerCase()}function l(i){return i.split(/[-_]+/).filter(e=>e.length>0).map(e=>`${e.slice(0,1).toUpperCase()}${e.slice(1).toLowerCase()}`).join("")}function d(i,e={}){const r=typeof e.minCount=="number"&&e.minCount>0?Math.trunc(e.minCount):10,s=typeof e.maxExamples=="number"&&e.maxExamples>0?Math.trunc(e.maxExamples):3,u=new Map;for(const n of i){const t=typeof n=="string"?n.trim():"";if(t.length===0)continue;const o=p(t);if(o===void 0)continue;const c=u.get(o)??{count:0,examples:[]};c.count+=1,c.examples.length<s&&c.examples.push(t),u.set(o,c)}const a=[];for(const[n,t]of u.entries()){if(t.count<r)continue;const o=l(n);a.push({name:o,prefix:n,count:t.count,examples:t.examples,shadows_builtin:m(o)!==void 0})}return a.sort((n,t)=>t.count-n.count||n.name.localeCompare(t.name)),a}export{p as extractTitlePrefix,d as inferTypesFromTitles,l as prefixToTypeName};
2
2
  //# sourceMappingURL=type-inference.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]="abb182c9-6d6c-5be4-a2ad-c91b00a098d0")}catch{}})();import{normalizeAddTypeInput}from"./item-types-file.js";const TYPE_PRESET_NAMES=["agile","ops","research"],TYPE_PRESET_DEFINITIONS={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function normalizeTypePresetName(rawValue){if(rawValue===void 0)return;const normalized=rawValue.trim().toLowerCase().replaceAll("-","_");if(normalized.length===0)throw new Error("Type preset name must not be empty.");if(normalized==="agile"||normalized==="ops"||normalized==="research")return normalized;throw new Error(`Invalid type preset "${rawValue}". Allowed: ${TYPE_PRESET_NAMES.join(", ")}.`)}function resolveTypePresetDefinitions(preset){return TYPE_PRESET_DEFINITIONS[preset].map(rawDefinition=>normalizeAddTypeInput(rawDefinition))}export{TYPE_PRESET_DEFINITIONS,TYPE_PRESET_NAMES,normalizeTypePresetName,resolveTypePresetDefinitions};
1
+ import{normalizeAddTypeInput as o}from"./item-types-file.js";const r=["agile","ops","research"],i={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function a(t){if(t===void 0)return;const e=t.trim().toLowerCase().replaceAll("-","_");if(e.length===0)throw new Error("Type preset name must not be empty.");if(e==="agile"||e==="ops"||e==="research")return e;throw new Error(`Invalid type preset "${t}". Allowed: ${r.join(", ")}.`)}function n(t){return i[t].map(e=>o(e))}export{i as TYPE_PRESET_DEFINITIONS,r as TYPE_PRESET_NAMES,a as normalizeTypePresetName,n as resolveTypePresetDefinitions};
2
2
  //# sourceMappingURL=type-presets.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]="77a7b77a-907c-541d-ac55-e06174dbbf11")}catch{}})();import{normalizeStatusToken}from"./status-token.js";import{normalizeStatusToken as normalizeStatusToken2}from"./status-token.js";function normalizeTypeName(value){return typeof value=="string"?value.trim().toLowerCase():""}function resolveStatusId(value,statusRegistry){const token=normalizeStatusToken(value);return token.length===0?"":statusRegistry?.alias_to_id?.get(token)??token}function resolveTypeWorkflows(schema){const rawWorkflows=Array.isArray(schema?.type_workflows)?schema.type_workflows:[],byType=new Map;for(const entry of rawWorkflows){const type=normalizeTypeName(entry?.type);if(type.length===0||!Array.isArray(entry?.allowed_transitions))continue;const pairs=entry.allowed_transitions,record=byType.get(type)??{pairs:[],denyAll:!1};pairs.length===0&&(record.denyAll=!0);for(const pair of pairs){if(!Array.isArray(pair)||pair.length!==2)continue;const from=normalizeStatusToken(pair[0]),to=normalizeStatusToken(pair[1]);from.length===0||to.length===0||record.pairs.some(candidate=>candidate[0]===from&&candidate[1]===to)||record.pairs.push([from,to])}byType.set(type,record)}return[...byType.entries()].filter(([,record])=>record.pairs.length>0||record.denyAll).map(([type,record])=>({type,allowed_transitions:record.pairs})).sort((left,right)=>left.type.localeCompare(right.type))}function evaluateTransition(input){const typeName=normalizeTypeName(input.typeName),matched=input.typeWorkflows.find(workflow=>workflow.type===typeName);if(!matched)return{allowed:!0,hasRule:!1,allowedTransitions:[]};const from=resolveStatusId(input.fromStatus,input.statusRegistry),to=resolveStatusId(input.toStatus,input.statusRegistry);return from.length>0&&from===to?{allowed:!0,hasRule:!0,allowedTransitions:matched.allowed_transitions}:{allowed:matched.allowed_transitions.some(pair=>{const ruleFrom=resolveStatusId(pair[0],input.statusRegistry),ruleTo=resolveStatusId(pair[1],input.statusRegistry);return ruleFrom===from&&ruleTo===to}),hasRule:!0,allowedTransitions:matched.allowed_transitions}}function describeAllowedTransitions(allowedTransitions){return allowedTransitions.length===0?"(no transitions allowed)":allowedTransitions.map(pair=>`${pair[0]} -> ${pair[1]}`).join(", ")}export{describeAllowedTransitions,evaluateTransition,normalizeStatusToken2 as normalizeStatusToken,resolveTypeWorkflows};
1
+ import{normalizeStatusToken as y}from"./status-token.js";import{normalizeStatusToken as T}from"./status-token.js";function w(t){return typeof t=="string"?t.trim().toLowerCase():""}function i(t,s){const o=y(t);return o.length===0?"":s?.alias_to_id?.get(o)??o}function d(t){const s=Array.isArray(t?.type_workflows)?t.type_workflows:[],o=new Map;for(const e of s){const r=w(e?.type);if(r.length===0||!Array.isArray(e?.allowed_transitions))continue;const f=e.allowed_transitions,n=o.get(r)??{pairs:[],denyAll:!1};f.length===0&&(n.denyAll=!0);for(const l of f){if(!Array.isArray(l)||l.length!==2)continue;const a=y(l[0]),u=y(l[1]);a.length===0||u.length===0||n.pairs.some(c=>c[0]===a&&c[1]===u)||n.pairs.push([a,u])}o.set(r,n)}return[...o.entries()].filter(([,e])=>e.pairs.length>0||e.denyAll).map(([e,r])=>({type:e,allowed_transitions:r.pairs})).sort((e,r)=>e.type.localeCompare(r.type))}function m(t){const s=w(t.typeName),o=t.typeWorkflows.find(n=>n.type===s);if(!o)return{allowed:!0,hasRule:!1,allowedTransitions:[]};const e=i(t.fromStatus,t.statusRegistry),r=i(t.toStatus,t.statusRegistry);return e.length>0&&e===r?{allowed:!0,hasRule:!0,allowedTransitions:o.allowed_transitions}:{allowed:o.allowed_transitions.some(n=>{const l=i(n[0],t.statusRegistry),a=i(n[1],t.statusRegistry);return l===e&&a===r}),hasRule:!0,allowedTransitions:o.allowed_transitions}}function g(t){return t.length===0?"(no transitions allowed)":t.map(s=>`${s[0]} -> ${s[1]}`).join(", ")}export{g as describeAllowedTransitions,m as evaluateTransition,T as normalizeStatusToken,d as resolveTypeWorkflows};
2
2
  //# sourceMappingURL=type-workflows.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]="9ecff496-8afa-5cfc-9178-2be8bd403978")}catch{}})();import{spawn}from"node:child_process";import{mkdirSync,rmSync,statSync}from"node:fs";import path from"node:path";import{pathExists,readFileIfExists,writeFileAtomic}from"../fs/fs-utils.js";import{acquireLock}from"../lock/lock.js";import{resolvePmPackageRootFromModule}from"../packages/root.js";import{readSettingsWithMetadata}from"../store/settings.js";import{toErrorMessage}from"../shared/primitives.js";import{resolveAuthor}from"../shared/author.js";import{resolveSettingsWithSemanticRuntimeDefaults}from"./semantic-defaults.js";const REINDEX_LOCK_ID="reindex",PENDING_QUEUE_REL_PATH="search/pending-refresh.json",PENDING_QUEUE_GATE_REL_PATH="search/pending-refresh.gate.lock",PENDING_QUEUE_GATE_STALE_MS=3e4,SEARCH_REFRESH_INLINE_ENV="PM_SEARCH_REFRESH_INLINE",SEARCH_REFRESH_CHILD_ENV="PM_SEARCH_REFRESH_CHILD",SEARCH_REFRESH_RETRY_DELAY_MS=3e4;function parseBooleanTrueLike(value){if(typeof value!="string")return!1;const normalized=value.trim().toLowerCase();return normalized==="1"||normalized==="true"||normalized==="yes"||normalized==="on"}function shouldRunSearchRefreshInForeground(){if(parseBooleanTrueLike(process.env[SEARCH_REFRESH_INLINE_ENV])||parseBooleanTrueLike(process.env[SEARCH_REFRESH_CHILD_ENV]))return!0;const nodeEnv=(process.env.NODE_ENV??"").trim().toLowerCase();return typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string"||nodeEnv==="test"}function pendingQueuePath(pmRoot){return path.join(pmRoot,PENDING_QUEUE_REL_PATH)}function pendingQueueGatePath(pmRoot){return path.join(pmRoot,PENDING_QUEUE_GATE_REL_PATH)}function acquireQueueGate(pmRoot){const gatePath=pendingQueueGatePath(pmRoot);try{if(Date.now()-statSync(gatePath).mtimeMs<PENDING_QUEUE_GATE_STALE_MS)return!1;rmSync(gatePath,{recursive:!0,force:!0})}catch{}try{return mkdirSync(path.dirname(gatePath),{recursive:!0}),mkdirSync(gatePath),!0}catch{return!1}}function releaseQueueGate(pmRoot){try{rmSync(pendingQueueGatePath(pmRoot),{recursive:!0,force:!0})}catch{}}async function withQueueGate(pmRoot,fn,fallback){for(let attempt=0;attempt<50;attempt+=1){if(acquireQueueGate(pmRoot))try{return await fn()}finally{releaseQueueGate(pmRoot)}await delay(20)}return fallback}function delay(ms){return new Promise(resolve=>{setTimeout(resolve,ms)})}async function readPendingQueueIds(pmRoot){const raw=await readFileIfExists(pendingQueuePath(pmRoot));if(!raw||raw.trim().length===0)return[];try{const parsed=JSON.parse(raw);return Array.isArray(parsed.ids)?parsed.ids.filter(id=>typeof id=="string"&&id.length>0):[]}catch{return[]}}async function writePendingQueueIds(pmRoot,ids){await writeFileAtomic(pendingQueuePath(pmRoot),`${JSON.stringify({ids})}
2
- `)}async function enqueuePendingRefreshIds(pmRoot,itemIds){const incoming=itemIds.filter(id=>typeof id=="string"&&id.trim().length>0);if(incoming.length===0)return;const mergeIncoming=async()=>{const existing=await readPendingQueueIds(pmRoot),merged=[...new Set([...existing,...incoming])].sort((left,right)=>left.localeCompare(right));await writePendingQueueIds(pmRoot,merged)};await withQueueGate(pmRoot,async()=>(await mergeIncoming(),!0),!1)||await mergeIncoming()}async function drainPendingRefreshIds(pmRoot){return withQueueGate(pmRoot,async()=>{const ids=await readPendingQueueIds(pmRoot);return ids.length>0&&await writePendingQueueIds(pmRoot,[]),ids},[])}function searchRefreshRunnerPath(){return path.join(resolvePmPackageRootFromModule(import.meta.url,["../../.."]),"dist","cli","search-refresh.js")}function dispatchRefreshChild(pmRoot){try{const child=spawn(process.execPath,[searchRefreshRunnerPath()],{detached:!0,stdio:"ignore",env:{...process.env,PM_PATH:pmRoot,[SEARCH_REFRESH_CHILD_ENV]:"1"}});child.on("error",()=>{}),child.unref()}catch{}}function scheduleDelayedRefreshRetry(pmRoot){setTimeout(()=>dispatchRefreshChild(pmRoot),SEARCH_REFRESH_RETRY_DELAY_MS)}async function scheduleBackgroundSemanticRefresh(pmRoot,itemIds){await enqueuePendingRefreshIds(pmRoot,itemIds),dispatchRefreshChild(pmRoot)}async function runSemanticRefreshWorker(pmRoot,refresh,scheduleRetry=scheduleDelayedRefreshRetry){const warnings=[],processed=[];if(!await pathExists(pmRoot))return{processed,rounds:0,warnings};let settings;try{const settingsRead=await readSettingsWithMetadata(pmRoot),readFailure=settingsRead.warnings.find(warning=>warning.startsWith("settings_read_"));if(readFailure)return scheduleRetry(pmRoot),{processed,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${readFailure}`]};settings=resolveSettingsWithSemanticRuntimeDefaults(settingsRead.settings).settings}catch(error){return scheduleRetry(pmRoot),{processed,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${toErrorMessage(error)}`]}}let release=null;try{release=await acquireLock(pmRoot,REINDEX_LOCK_ID,settings.locks.ttl_seconds,resolveAuthor(void 0,"pm-search-refresh"),!1,settings.governance.force_required_for_stale_lock,settings.locks.wait_ms)}catch{}if(!release)return{processed,rounds:0,warnings};let rounds=0,failed=!1,retryPending=!1;try{for(;;){const ids=await drainPendingRefreshIds(pmRoot);if(ids.length===0)break;rounds+=1;try{const result=await refresh(pmRoot,ids);if(warnings.push(...result.warnings),result.warnings.some(warning=>warning.startsWith("search_semantic_refresh_skipped:settings_read_failed:"))){await enqueuePendingRefreshIds(pmRoot,ids),failed=!0,retryPending=!0;break}processed.push(...result.refreshed)}catch(error){warnings.push(`search_background_refresh_failed:${toErrorMessage(error)}`),await enqueuePendingRefreshIds(pmRoot,ids),failed=!0;break}}}finally{await release?.()}return retryPending&&scheduleRetry(pmRoot),(failed?[]:await readPendingQueueIds(pmRoot)).length>0&&dispatchRefreshChild(pmRoot),{processed:[...new Set(processed)].sort((a,b)=>a.localeCompare(b)),rounds,warnings}}export{REINDEX_LOCK_ID,SEARCH_REFRESH_RETRY_DELAY_MS,drainPendingRefreshIds,enqueuePendingRefreshIds,runSemanticRefreshWorker,scheduleBackgroundSemanticRefresh,shouldRunSearchRefreshInForeground};
1
+ import{spawn as R}from"node:child_process";import{mkdirSync as w,rmSync as m,statSync as A}from"node:fs";import d from"node:path";import{pathExists as H,readFileIfExists as v,writeFileAtomic as T}from"../fs/fs-utils.js";import{acquireLock as C}from"../lock/lock.js";import{resolvePmPackageRootFromModule as D}from"../packages/root.js";import{readSettingsWithMetadata as L}from"../store/settings.js";import{toErrorMessage as y}from"../shared/primitives.js";import{resolveAuthor as x}from"../shared/author.js";import{resolveSettingsWithSemanticRuntimeDefaults as F}from"./semantic-defaults.js";const Q="reindex",G="search/pending-refresh.json",M="search/pending-refresh.gate.lock",b=3e4,U="PM_SEARCH_REFRESH_INLINE",p="PM_SEARCH_REFRESH_CHILD",W=3e4;function S(e){if(typeof e!="string")return!1;const r=e.trim().toLowerCase();return r==="1"||r==="true"||r==="yes"||r==="on"}function ie(){if(S(process.env[U])||S(process.env[p]))return!0;const e=(process.env.NODE_ENV??"").trim().toLowerCase();return typeof process.env.VITEST=="string"||typeof process.env.VITEST_WORKER_ID=="string"||e==="test"}function P(e){return d.join(e,G)}function I(e){return d.join(e,M)}function j(e){const r=I(e);try{if(Date.now()-A(r).mtimeMs<b)return!1;m(r,{recursive:!0,force:!0})}catch{}try{return w(d.dirname(r),{recursive:!0}),w(r),!0}catch{return!1}}function O(e){try{m(I(e),{recursive:!0,force:!0})}catch{}}async function k(e,r,n){for(let t=0;t<50;t+=1){if(j(e))try{return await r()}finally{O(e)}await V(20)}return n}function V(e){return new Promise(r=>{setTimeout(r,e)})}async function l(e){const r=await v(P(e));if(!r||r.trim().length===0)return[];try{const n=JSON.parse(r);return Array.isArray(n.ids)?n.ids.filter(t=>typeof t=="string"&&t.length>0):[]}catch{return[]}}async function N(e,r){await T(P(e),`${JSON.stringify({ids:r})}
2
+ `)}async function _(e,r){const n=r.filter(a=>typeof a=="string"&&a.trim().length>0);if(n.length===0)return;const t=async()=>{const a=await l(e),o=[...new Set([...a,...n])].sort((f,u)=>f.localeCompare(u));await N(e,o)};await k(e,async()=>(await t(),!0),!1)||await t()}async function q(e){return k(e,async()=>{const r=await l(e);return r.length>0&&await N(e,[]),r},[])}function $(){return d.join(D(import.meta.url,["../../.."]),"dist","cli","search-refresh.js")}function g(e){try{const r=R(process.execPath,[$()],{detached:!0,stdio:"ignore",env:{...process.env,PM_PATH:e,[p]:"1"}});r.on("error",()=>{}),r.unref()}catch{}}function B(e){setTimeout(()=>g(e),W)}async function ae(e,r){await _(e,r),g(e)}async function ce(e,r,n=B){const t=[],c=[];if(!await H(e))return{processed:c,rounds:0,warnings:t};let a;try{const s=await L(e),i=s.warnings.find(h=>h.startsWith("settings_read_"));if(i)return n(e),{processed:c,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${i}`]};a=F(s.settings).settings}catch(s){return n(e),{processed:c,rounds:0,warnings:[`search_background_refresh_settings_read_failed:${y(s)}`]}}let o=null;try{o=await C(e,Q,a.locks.ttl_seconds,x(void 0,"pm-search-refresh"),!1,a.governance.force_required_for_stale_lock,a.locks.wait_ms)}catch{}if(!o)return{processed:c,rounds:0,warnings:t};let f=0,u=!1,E=!1;try{for(;;){const s=await q(e);if(s.length===0)break;f+=1;try{const i=await r(e,s);if(t.push(...i.warnings),i.warnings.some(h=>h.startsWith("search_semantic_refresh_skipped:settings_read_failed:"))){await _(e,s),u=!0,E=!0;break}c.push(...i.refreshed)}catch(i){t.push(`search_background_refresh_failed:${y(i)}`),await _(e,s),u=!0;break}}}finally{await o?.()}return E&&n(e),(u?[]:await l(e)).length>0&&g(e),{processed:[...new Set(c)].sort((s,i)=>s.localeCompare(i)),rounds:f,warnings:t}}export{Q as REINDEX_LOCK_ID,W as SEARCH_REFRESH_RETRY_DELAY_MS,q as drainPendingRefreshIds,_ as enqueuePendingRefreshIds,ce as runSemanticRefreshWorker,ae as scheduleBackgroundSemanticRefresh,ie as shouldRunSearchRefreshInForeground};
3
3
  //# sourceMappingURL=background-refresh.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]="0272e482-0dab-5970-b19a-4da286fd112b")}catch{}})();import{tokenizeAlphaNumeric}from"../shared/text-normalization.js";const DEFAULT_BM25_K1=1.2,DEFAULT_BM25_B=.75;function tokenizeBm25(text){return tokenizeAlphaNumeric(text)}function buildTermFrequencies(tokens){const frequencies=new Map;for(const token of tokens)frequencies.set(token,(frequencies.get(token)??0)+1);return frequencies}function buildBm25Index(documents){const stats=[],documentFrequency=new Map;let totalLength=0;for(const document of documents){const tokens=tokenizeBm25(document.text),termFrequencies=buildTermFrequencies(tokens);totalLength+=tokens.length;for(const term of termFrequencies.keys())documentFrequency.set(term,(documentFrequency.get(term)??0)+1);stats.push({id:document.id,termFrequencies,length:tokens.length})}const documentCount=stats.length;return{documents:stats,documentFrequency,documentCount,averageDocumentLength:documentCount>0?totalLength/documentCount:0}}function inverseDocumentFrequency(documentCount,termDocumentFrequency){return Math.log(1+(documentCount-termDocumentFrequency+.5)/(termDocumentFrequency+.5))}function scoreBm25Query(index,queryTokens,params){const scores=new Map;if(index.documentCount===0||index.averageDocumentLength===0)return scores;const distinctQueryTerms=[...new Set(queryTokens.filter(token=>token.length>0))];if(distinctQueryTerms.length===0)return scores;const idfByTerm=new Map;for(const term of distinctQueryTerms){const termDocumentFrequency=index.documentFrequency.get(term);termDocumentFrequency!==void 0&&idfByTerm.set(term,inverseDocumentFrequency(index.documentCount,termDocumentFrequency))}if(idfByTerm.size===0)return scores;for(const document of index.documents){let score=0;for(const[term,idf]of idfByTerm){const termFrequency=document.termFrequencies.get(term);if(termFrequency===void 0)continue;const lengthNormalization=1-params.b+params.b*document.length/index.averageDocumentLength,denominator=termFrequency+params.k1*lengthNormalization;score+=idf*(termFrequency*(params.k1+1)/denominator)}score>0&&scores.set(document.id,score)}return scores}function resolveClampedParam(candidate,fallback,min,max){return typeof candidate!="number"||!Number.isFinite(candidate)?fallback:Math.min(max,Math.max(min,candidate))}function flattenSearchCorpusText(corpus){const collectValueText=value=>typeof value=="string"?[value]:typeof value=="number"?[String(value)]:Array.isArray(value)?value.flatMap(collectValueText):typeof value=="object"&&value!==null?Object.values(value).flatMap(collectValueText):[];return collectValueText(Object.values(corpus)).join(" ")}function resolveBm25Params(settings){const bm25=settings?.search?.bm25;return{k1:resolveClampedParam(bm25?.k1,DEFAULT_BM25_K1,0,1e3),b:resolveClampedParam(bm25?.b,DEFAULT_BM25_B,0,1)}}export{DEFAULT_BM25_B,DEFAULT_BM25_K1,buildBm25Index,flattenSearchCorpusText,resolveBm25Params,scoreBm25Query,tokenizeBm25};
1
+ import{tokenizeAlphaNumeric as h}from"../shared/text-normalization.js";const p=1.2,d=.75;function b(t){return h(t)}function y(t){const n=new Map;for(const e of t)n.set(e,(n.get(e)??0)+1);return n}function k(t){const n=[],e=new Map;let r=0;for(const s of t){const o=b(s.text),c=y(o);r+=o.length;for(const i of c.keys())e.set(i,(e.get(i)??0)+1);n.push({id:s.id,termFrequencies:c,length:o.length})}const u=n.length;return{documents:n,documentFrequency:e,documentCount:u,averageDocumentLength:u>0?r/u:0}}function M(t,n){return Math.log(1+(t-n+.5)/(n+.5))}function q(t,n,e){const r=new Map;if(t.documentCount===0||t.averageDocumentLength===0)return r;const u=[...new Set(n.filter(o=>o.length>0))];if(u.length===0)return r;const s=new Map;for(const o of u){const c=t.documentFrequency.get(o);c!==void 0&&s.set(o,M(t.documentCount,c))}if(s.size===0)return r;for(const o of t.documents){let c=0;for(const[i,g]of s){const f=o.termFrequencies.get(i);if(f===void 0)continue;const l=1-e.b+e.b*o.length/t.averageDocumentLength,a=f+e.k1*l;c+=g*(f*(e.k1+1)/a)}c>0&&r.set(o.id,c)}return r}function m(t,n,e,r){return typeof t!="number"||!Number.isFinite(t)?n:Math.min(r,Math.max(e,t))}function B(t){const n=e=>typeof e=="string"?[e]:typeof e=="number"?[String(e)]:Array.isArray(e)?e.flatMap(n):typeof e=="object"&&e!==null?Object.values(e).flatMap(n):[];return n(Object.values(t)).join(" ")}function x(t){const n=t?.search?.bm25;return{k1:m(n?.k1,p,0,1e3),b:m(n?.b,d,0,1)}}export{d as DEFAULT_BM25_B,p as DEFAULT_BM25_K1,k as buildBm25Index,B as flattenSearchCorpusText,x as resolveBm25Params,q as scoreBm25Query,b as tokenizeBm25};
2
2
  //# sourceMappingURL=bm25.js.map