@unbrained/pm-cli 2026.11.23 → 2026.11.25

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 (209) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/error-guidance.js +5 -5
  3. package/dist/cli/main.js +5 -5
  4. package/dist/cli/register-annotations.js +1 -1
  5. package/dist/cli/runtime/invocation-options.js +1 -1
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +2 -0
  8. package/dist/cli-bundle/chunks/{chunk-YYT3MIRF.js → chunk-6OIHST4I.js} +1 -1
  9. package/dist/cli-bundle/chunks/chunk-7EPYCU7U.js +9 -0
  10. package/dist/cli-bundle/chunks/{chunk-AEOHUSUI.js → chunk-BVJMVU4Z.js} +68 -68
  11. package/dist/cli-bundle/chunks/{chunk-2UQU7HRR.js → chunk-C4KIZQHW.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-CNUFU454.js +113 -0
  13. package/dist/cli-bundle/chunks/chunk-CONBVY2O.js +2 -0
  14. package/dist/cli-bundle/chunks/{chunk-BSRIVYTM.js → chunk-CZEMEPPQ.js} +3 -3
  15. package/dist/cli-bundle/chunks/chunk-DF6A7C32.js +2 -0
  16. package/dist/cli-bundle/chunks/chunk-FHLOGAGA.js +8 -0
  17. package/dist/cli-bundle/chunks/chunk-FVY7U3SU.js +125 -0
  18. package/dist/cli-bundle/chunks/{chunk-F2Z6XLZB.js → chunk-GBVF2ZB3.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +2 -0
  21. package/dist/cli-bundle/chunks/chunk-K34FR5CO.js +3 -0
  22. package/dist/cli-bundle/chunks/{chunk-D6PDUKUG.js → chunk-KHFUHGL3.js} +2 -2
  23. package/dist/cli-bundle/chunks/chunk-L6VS7F3R.js +2 -0
  24. package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +2 -0
  25. package/dist/cli-bundle/chunks/{chunk-H7JEXRIN.js → chunk-LPW7S5KA.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-5DUP4AZA.js → chunk-MGJMQSN4.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-OS5W4ZG2.js +31 -0
  28. package/dist/cli-bundle/chunks/{chunk-O7JHS64G.js → chunk-OWK2JL4I.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-SCIPT7WF.js +2 -0
  30. package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +3 -0
  31. package/dist/cli-bundle/chunks/{chunk-CFWLQFJM.js → chunk-VA4T37Q4.js} +50 -51
  32. package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +2 -0
  33. package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +3 -0
  34. package/dist/cli-bundle/chunks/{chunk-J2PDAVBC.js → chunk-XKWJONAO.js} +2 -2
  35. package/dist/cli-bundle/chunks/chunk-YIGBEY7K.js +2 -0
  36. package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +33 -0
  37. package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +3 -0
  38. package/dist/cli-bundle/chunks/field-option-collisions-QE65APSD.js +2 -0
  39. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-BPYKN5Q7.js → indexed-receipt-blobs-H3MMNXXG.js} +2 -2
  40. package/dist/cli-bundle/{focused-chunks/item-revision-YDACCDVY.js → chunks/item-revision-INDHJV6X.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +2 -0
  42. package/dist/cli-bundle/chunks/mutation-actor-KU7BMLUN.js +2 -0
  43. package/dist/cli-bundle/chunks/mutation-admission-3OMCTQD4.js +2 -0
  44. package/dist/cli-bundle/chunks/{register-list-query-L4IBU64P.js → register-list-query-3GV3LBOT.js} +2 -2
  45. package/dist/cli-bundle/chunks/register-mutation-GZLF47SX.js +21 -0
  46. package/dist/cli-bundle/chunks/register-operations-PBJZGCAL.js +2 -0
  47. package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +2 -0
  48. package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +2 -0
  49. package/dist/cli-bundle/chunks/{settlement-hook-6MR32OOC.js → settlement-hook-ESAAEBRM.js} +2 -2
  50. package/dist/cli-bundle/chunks/stage-3WIZBD4N.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-3Y5PTQ2F.js +27 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-Y2ESLKCF.js → chunk-4LQL4EO6.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-RIE3SJSE.js → chunk-4SX2BN4V.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-ZHWPCVQL.js → chunk-5RBC4WSE.js} +39 -39
  55. package/dist/cli-bundle/focused-chunks/chunk-7SSGTGZO.js +91 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +2 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-BOIMP2AR.js +5 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-BYQK5DGH.js +2 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-C3FEDTSD.js +44 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/chunk-JOKRDFMQ.js +2 -0
  62. package/dist/cli-bundle/focused-chunks/chunk-MB56Y4M6.js +8 -0
  63. package/dist/cli-bundle/focused-chunks/{chunk-A6VEMCRR.js → chunk-NGFDPEP7.js} +1 -1
  64. package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +3 -0
  65. package/dist/cli-bundle/focused-chunks/chunk-PKX2EHE3.js +26 -0
  66. package/dist/cli-bundle/focused-chunks/chunk-SXC2EO3E.js +3 -0
  67. package/dist/cli-bundle/focused-chunks/chunk-TQIKDFOD.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/chunk-TRL4JDWX.js +8 -0
  69. package/dist/cli-bundle/focused-chunks/{chunk-IROZDIDX.js → chunk-UWWAVXG4.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +13 -0
  71. package/dist/cli-bundle/focused-chunks/chunk-VU2PH4PF.js +2 -0
  72. package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +2 -0
  73. package/dist/cli-bundle/focused-chunks/chunk-WVA5KOXF.js +3 -0
  74. package/dist/cli-bundle/focused-chunks/{chunk-QQIIMMFU.js → chunk-X4EWD6TL.js} +2 -2
  75. package/dist/cli-bundle/focused-chunks/chunk-XKLBTDJ7.js +100 -0
  76. package/dist/cli-bundle/focused-chunks/chunk-YYEWIKNI.js +2 -0
  77. package/dist/cli-bundle/focused-chunks/chunk-ZLRRII55.js +2 -0
  78. package/dist/cli-bundle/focused-chunks/field-option-collisions-5ROXGUME.js +2 -0
  79. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-EGEJMG3G.js → indexed-receipt-blobs-PG2VJ3MB.js} +2 -2
  80. package/dist/cli-bundle/focused-chunks/item-revision-KYMSQVZE.js +2 -0
  81. package/dist/cli-bundle/focused-chunks/item-transaction-I4HLVHEJ.js +2 -0
  82. package/dist/cli-bundle/focused-chunks/mutation-actor-GGOQKAE6.js +2 -0
  83. package/dist/cli-bundle/focused-chunks/mutation-admission-OS36ZCMH.js +2 -0
  84. package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +2 -0
  85. package/dist/cli-bundle/focused-chunks/{settlement-hook-FMLGKG7J.js → settlement-hook-4MGRERCT.js} +2 -2
  86. package/dist/cli-bundle/focused-chunks/stage-4ZFWJUKO.js +2 -0
  87. package/dist/cli-bundle/main.js +26 -26
  88. package/dist/cli-bundle/sdk-authoring.js +1 -1
  89. package/dist/cli-bundle/sdk-contracts.js +4 -4
  90. package/dist/cli-bundle/sdk-core.js +1 -1
  91. package/dist/cli-bundle/sdk-governance.js +1 -1
  92. package/dist/cli-bundle/sdk-graph.js +1 -1
  93. package/dist/cli-bundle/sdk-merge.js +63 -63
  94. package/dist/cli-bundle/sdk-query.js +1 -1
  95. package/dist/cli-bundle/sdk-runtime.js +1 -1
  96. package/dist/cli-bundle/sdk-testing.js +1 -1
  97. package/dist/cli-bundle/sdk.js +12 -12
  98. package/dist/core/profile/profile-lint.d.ts +1 -1
  99. package/dist/core/profile/profile-lint.js +1 -1
  100. package/dist/core/schema/fields-file.js +2 -2
  101. package/dist/core/schema/runtime-field-values.js +1 -1
  102. package/dist/core/schema/runtime-schema.d.ts +2 -0
  103. package/dist/core/schema/runtime-schema.js +1 -1
  104. package/dist/core/shared/command-line.d.ts +54 -4
  105. package/dist/core/shared/command-line.js +1 -1
  106. package/dist/core/shared/errors.d.ts +9 -0
  107. package/dist/core/shared/secret-rules.js +5 -5
  108. package/dist/core/shared/url-credentials.d.ts +16 -3
  109. package/dist/core/shared/url-credentials.js +1 -1
  110. package/dist/core/store/item-store.d.ts +26 -4
  111. package/dist/core/store/item-store.js +1 -1
  112. package/dist/sdk/command-line.d.ts +1 -1
  113. package/dist/sdk/command-line.js +1 -1
  114. package/dist/sdk/context-intent-contracts.js +1 -1
  115. package/dist/sdk/extension/command-options.d.ts +26 -1
  116. package/dist/sdk/extension/command-options.js +1 -1
  117. package/dist/sdk/extension-command-context.js +2 -2
  118. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  119. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  120. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  121. package/dist/sdk/index.d.ts +1 -1
  122. package/dist/sdk/lifecycle/claim.d.ts +21 -1
  123. package/dist/sdk/lifecycle/claim.js +1 -1
  124. package/dist/sdk/lifecycle/task-composition.js +1 -1
  125. package/dist/sdk/ownership-source.d.ts +15 -1
  126. package/dist/sdk/ownership-source.js +1 -1
  127. package/dist/sdk/public-surface.json +1 -1
  128. package/dist/sdk/read-output-contracts.d.ts +11 -0
  129. package/dist/sdk/read-output-contracts.js +1 -1
  130. package/dist/sdk/runtime-primitives.d.ts +1 -1
  131. package/dist/sdk/schema/field-flag-spelling.d.ts +22 -0
  132. package/dist/sdk/schema/field-flag-spelling.js +2 -0
  133. package/dist/sdk/schema/field-option-collisions.js +1 -1
  134. package/docs/AGENT_GUIDE.md +2 -2
  135. package/docs/COMMANDS.md +1 -1
  136. package/docs/CONFIGURATION.md +1 -0
  137. package/docs/EXTENSIONS.md +1 -1
  138. package/docs/MUTATION_INTEGRITY.md +97 -8
  139. package/docs/READ_OUTPUT_CONTRACTS.md +2 -0
  140. package/docs/SDK.md +60 -4
  141. package/docs/SDK_AUDITED_MUTATIONS.md +11 -0
  142. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +17 -4
  143. package/marketplace.json +1 -1
  144. package/package.json +1 -1
  145. package/packages/pm-beads/package.json +1 -1
  146. package/packages/pm-calendar/package.json +1 -1
  147. package/packages/pm-command-kit/package.json +1 -1
  148. package/packages/pm-digital-twin/package.json +1 -1
  149. package/packages/pm-governance-audit/package.json +1 -1
  150. package/packages/pm-guide-shell/package.json +1 -1
  151. package/packages/pm-kanban/package.json +1 -1
  152. package/packages/pm-lifecycle-hooks/package.json +1 -1
  153. package/packages/pm-linked-test-adapters/package.json +1 -1
  154. package/packages/pm-search-advanced/package.json +1 -1
  155. package/packages/pm-templates/package.json +1 -1
  156. package/packages/pm-todos/package.json +1 -1
  157. package/packages/pm-vcs/package.json +1 -1
  158. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  159. package/plugins/pm-claude/package.json +1 -1
  160. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  161. package/plugins/pm-codex/package.json +1 -1
  162. package/plugins/pm-codex/plugin.json +1 -1
  163. package/runtime-dependencies.json +1 -1
  164. package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +0 -3
  165. package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +0 -2
  166. package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +0 -31
  167. package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +0 -2
  168. package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +0 -2
  169. package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +0 -2
  170. package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +0 -33
  171. package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +0 -115
  172. package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +0 -2
  173. package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +0 -2
  174. package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +0 -2
  175. package/dist/cli-bundle/chunks/chunk-OPJF254V.js +0 -9
  176. package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +0 -2
  177. package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +0 -2
  178. package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +0 -125
  179. package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +0 -8
  180. package/dist/cli-bundle/chunks/item-revision-FMD4KWBB.js +0 -2
  181. package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +0 -2
  182. package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +0 -2
  183. package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +0 -2
  184. package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +0 -21
  185. package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +0 -2
  186. package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +0 -2
  187. package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +0 -2
  188. package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +0 -6
  189. package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +0 -2
  190. package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +0 -8
  191. package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +0 -2
  192. package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +0 -2
  193. package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +0 -2
  194. package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +0 -26
  195. package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +0 -13
  196. package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +0 -2
  197. package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +0 -91
  198. package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +0 -2
  199. package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +0 -2
  200. package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +0 -8
  201. package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +0 -27
  202. package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +0 -44
  203. package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +0 -2
  204. package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +0 -2
  205. package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +0 -102
  206. package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +0 -2
  207. package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +0 -2
  208. package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +0 -2
  209. package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +0 -2
@@ -6,7 +6,7 @@ export declare const PROFILE_LINT_DIMENSIONS:readonly["profile","types","statuse
6
6
  /** Restricts profile lint dimension values accepted by command, SDK, and storage contracts. */
7
7
  export type ProfileLintDimension=(typeof PROFILE_LINT_DIMENSIONS)[number];
8
8
  /** Stable machine-readable codes every {@link ProjectProfileLintFinding} carries. */
9
- export declare const PROFILE_LINT_CODES:readonly["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"];
9
+ export declare const PROFILE_LINT_CODES:readonly["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","field_flag_invalid","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"];
10
10
  /** Restricts profile lint code values accepted by command, SDK, and storage contracts. */
11
11
  export type ProfileLintCode=(typeof PROFILE_LINT_CODES)[number];
12
12
  /** A single graded consistency finding produced by {@link lintProjectProfile}. */
@@ -1,2 +1,2 @@
1
- import{BUILTIN_ITEM_TYPE_VALUES as _}from"../../types/index.js";import{parseNestedSettingValue as g,resolveNestedSettingDescriptor as k}from"../config/nested-settings.js";import{normalizeAddFieldInput as v}from"../schema/fields-file.js";import{normalizeAddStatusInput as S}from"../schema/status-defs-file.js";import{normalizeAddTypeInput as $}from"../schema/item-types-file.js";import{normalizeStatusToken as d}from"../schema/type-workflows.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS as T}from"../schema/runtime-schema.js";import{toErrorMessage as m}from"../shared/primitives.js";import{resolvePmToolCustomFieldCollision as I}from"../../sdk/cli-contracts/tool-schema.js";import{describeFieldOptionCollision as b,resolveAddFieldOptionCollisions as C}from"../../sdk/schema/field-option-collisions.js";import{normalizeProfileLookupKey as w}from"./profile-presets.js";const G=["profile","types","statuses","fields","workflows","config","templates","packages"],H=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],P=new Set(T.flatMap(e=>[d(e.id),...(e.aliases??[]).map(t=>d(t))]).filter(e=>e.length>0)),h=new Set(_.map(e=>e.toLowerCase()));function E(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==w(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${w(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function L(e,t){const r=new Set,s=new Set;for(const[i,o]of e.types.entries()){let n;try{n=$(o).name}catch(l){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${i}`,message:m(l)});continue}const a=n.toLowerCase();if(s.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:n,message:`Item type "${n}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(a),r.add(a)}return r}function N(e,t){const r=new Set,s=new Set;for(const[i,o]of e.statuses.entries()){let n;try{n=S(o)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${i}`,message:m(a)});continue}if(s.has(n.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:n.id,message:`Status "${n.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(n.id),r.add(n.id);for(const a of n.aliases??[])r.add(d(a))}return r}function F(e,t){const r=new Set;for(const[s,i]of e.fields.entries()){let o,n;try{n=v(i),o=n.key}catch(p){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof i.key=="string"?i.key:`#${s}`,message:m(p)});continue}if(r.has(o)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(o);const a=C(n);a.length>0&&t.push({severity:"error",code:"field_option_collision",dimension:"fields",target:o,message:`Field "${o}" would disable a built-in option: ${a.map(b).join("; ")}. Rename the field or narrow its commands.`});const l=I(o);l&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${l.property}" owned by ${l.owner}; callers must pass the custom value through ${l.nested_path}.`})}}function z(e,t,r,s){const i=new Set;for(const[o,n]of e.workflows.entries()){const a=n.type.trim().toLowerCase();if(a.length===0){s.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}const l=i.has(a);i.add(a),l?s.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:n.type,message:`Workflow type "${n.type}" is declared more than once; the later transition set wins.`}):!h.has(a)&&!t.has(a)&&s.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:n.type,message:`Workflow governs type "${n.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});const p=new Set;for(const f of n.allowed_transitions){const u=d(f[0]),y=d(f[1]);if(u.length===0||y.length===0){s.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:n.type,message:`Workflow "${n.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(const c of[u,y])P.has(c)||r.has(c)||p.has(c)||(p.add(c),s.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:c,message:`Workflow "${n.type}" references status "${c}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function x(e,t){const r=new Set;for(const s of e.config){const i=k(s.key);if(i===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:s.key,message:`Config knob "${s.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}r.has(i.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:i.key,message:`Config knob "${i.key}" is set more than once; the later value silently overwrites the earlier one.`}):r.add(i.key);const o=g(i,s.value);o.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:s.key,message:o.error.message})}}function O(e,t,r){for(const s of e.templates){const i=s.options.type;if(typeof i!="string"||i.trim().length===0)continue;const o=i.trim().toLowerCase();!h.has(o)&&!t.has(o)&&r.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:s.name,message:`Template "${s.name}" creates type "${i}" which is neither a built-in type nor declared by this profile.`})}}function U(e,t){for(const[r,s]of e.packages.entries())s.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${r}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function J(e){const t=[];E(e,t);const r=L(e,t),s=N(e,t);F(e,t),z(e,r,s,t),x(e,t),O(e,r,t),U(e,t);const i=t.filter(n=>n.severity==="error").length,o=t.length-i;return{profile:e.name,ok:i===0,findings:t,errorCount:i,warningCount:o}}export{H as PROFILE_LINT_CODES,G as PROFILE_LINT_DIMENSIONS,J as lintProjectProfile};
1
+ import{BUILTIN_ITEM_TYPE_VALUES as _}from"../../types/index.js";import{parseNestedSettingValue as g,resolveNestedSettingDescriptor as k}from"../config/nested-settings.js";import{normalizeAddFieldInput as v}from"../schema/fields-file.js";import{normalizeAddStatusInput as S}from"../schema/status-defs-file.js";import{normalizeAddTypeInput as $}from"../schema/item-types-file.js";import{normalizeStatusToken as p}from"../schema/type-workflows.js";import{DEFAULT_RUNTIME_STATUS_DEFINITIONS as T}from"../schema/runtime-schema.js";import{toErrorMessage as f}from"../shared/primitives.js";import{resolvePmToolCustomFieldCollision as I}from"../../sdk/cli-contracts/tool-schema.js";import{describeFieldFlagSpellingDefectLine as b,describeFieldOptionCollision as F,resolveAddFieldFlagSpellingDefects as P,resolveAddFieldOptionCollisions as C}from"../../sdk/schema/field-option-collisions.js";import{normalizeProfileLookupKey as h}from"./profile-presets.js";const J=["profile","types","statuses","fields","workflows","config","templates","packages"],Q=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","field_option_collision","field_flag_invalid","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],L=new Set(T.flatMap(t=>[p(t.id),...(t.aliases??[]).map(e=>p(e))]).filter(t=>t.length>0)),w=new Set(_.map(t=>t.toLowerCase()));function E(t,e){t.name.trim().length===0?e.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):t.name!==h(t.name)&&e.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:t.name,message:`Profile name "${t.name}" is not in canonical form; resolution folds it to "${h(t.name)}" (lowercase, hyphens as underscores).`}),t.title.trim().length===0&&e.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),t.summary.trim().length===0&&e.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function N(t,e){const r=new Set,i=new Set;for(const[s,o]of t.types.entries()){let n;try{n=$(o).name}catch(d){e.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${s}`,message:f(d)});continue}const a=n.toLowerCase();if(i.has(a)){e.push({severity:"error",code:"type_duplicate",dimension:"types",target:n,message:`Item type "${n}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(a),r.add(a)}return r}function z(t,e){const r=new Set,i=new Set;for(const[s,o]of t.statuses.entries()){let n;try{n=S(o)}catch(a){e.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${s}`,message:f(a)});continue}if(i.has(n.id)){e.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:n.id,message:`Status "${n.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}i.add(n.id),r.add(n.id);for(const a of n.aliases??[])r.add(p(a))}return r}function x(t,e){const r=new Set;for(const[i,s]of t.fields.entries()){let o,n;try{n=v(s),o=n.key}catch(m){e.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof s.key=="string"?s.key:`#${i}`,message:f(m)});continue}if(r.has(o)){e.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}r.add(o);const a=P(n);a.length>0&&e.push({severity:"error",code:"field_flag_invalid",dimension:"fields",target:o,message:`Field "${o}" declares a flag that is not one option spelling: ${a.map(b).join("; ")}. Pass one spelling per alias.`});const d=C(n);d.length>0&&e.push({severity:"error",code:"field_option_collision",dimension:"fields",target:o,message:`Field "${o}" would disable a built-in option: ${d.map(F).join("; ")}. Rename the field or narrow its commands.`});const l=I(o);l&&e.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${l.property}" owned by ${l.owner}; callers must pass the custom value through ${l.nested_path}.`})}}function A(t,e,r,i){const s=new Set;for(const[o,n]of t.workflows.entries()){const a=n.type.trim().toLowerCase();if(a.length===0){i.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}const d=s.has(a);s.add(a),d?i.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:n.type,message:`Workflow type "${n.type}" is declared more than once; the later transition set wins.`}):!w.has(a)&&!e.has(a)&&i.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:n.type,message:`Workflow governs type "${n.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});const l=new Set;for(const m of n.allowed_transitions){const u=p(m[0]),y=p(m[1]);if(u.length===0||y.length===0){i.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:n.type,message:`Workflow "${n.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(const c of[u,y])L.has(c)||r.has(c)||l.has(c)||(l.add(c),i.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:c,message:`Workflow "${n.type}" references status "${c}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function O(t,e){const r=new Set;for(const i of t.config){const s=k(i.key);if(s===void 0){e.push({severity:"error",code:"config_key_unknown",dimension:"config",target:i.key,message:`Config knob "${i.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}r.has(s.key)?e.push({severity:"error",code:"config_duplicate",dimension:"config",target:s.key,message:`Config knob "${s.key}" is set more than once; the later value silently overwrites the earlier one.`}):r.add(s.key);const o=g(s,i.value);o.ok||e.push({severity:"error",code:"config_value_invalid",dimension:"config",target:i.key,message:o.error.message})}}function U(t,e,r){for(const i of t.templates){const s=i.options.type;if(typeof s!="string"||s.trim().length===0)continue;const o=s.trim().toLowerCase();!w.has(o)&&!e.has(o)&&r.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:i.name,message:`Template "${i.name}" creates type "${s}" which is neither a built-in type nor declared by this profile.`})}}function D(t,e){for(const[r,i]of t.packages.entries())i.spec.trim().length===0&&e.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${r}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function X(t){const e=[];E(t,e);const r=N(t,e),i=z(t,e);x(t,e),A(t,r,i,e),O(t,e),U(t,r,e),D(t,e);const s=e.filter(n=>n.severity==="error").length,o=e.length-s;return{profile:t.name,ok:s===0,findings:e,errorCount:s,warningCount:o}}export{Q as PROFILE_LINT_CODES,J as PROFILE_LINT_DIMENSIONS,X as lintProjectProfile};
2
2
  //# sourceMappingURL=profile-lint.js.map
@@ -1,3 +1,3 @@
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};
1
+ import{RUNTIME_FIELD_COMMAND_VALUES as a,RUNTIME_FIELD_TYPE_VALUES as f}from"../../types/index.js";import{ITEM_METADATA_KEY_ORDER as F}from"../shared/constants.js";import{normalizeStatusToken as l}from"./status-token.js";import{normalizeStatusToken as R}from"./status-token.js";const A=new Set(f),T=new Set(a),u=new Set([...F.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"]),k=["create","update"];function m(t){if(typeof t!="string")return"";const e=t.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return e.startsWith("--")?e.slice(2):e}function y(t){return t.replaceAll("_","-")}function C(t,e){const i=new Set;for(const n of t){const r=m(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 w(t){const e=new Set,i=[];for(const n of t??[]){const r=n.trim().toLowerCase();if(r.length!==0){if(!T.has(r))throw new Error(`Invalid field command "${n}". Allowed: ${a.join(", ")}.`);e.has(r)||(e.add(r),i.push(r))}}return t===void 0||i.length===0?[...k]:i}function M(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(u.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: ${[...u].sort((_,E)=>_.localeCompare(E)).join(", ")}.`);const i=typeof t.type=="string"&&t.type.trim().length>0?t.type.trim().toLowerCase():"string";if(!A.has(i))throw new Error(`Invalid field type "${t.type}". Allowed: ${f.join(", ")}.`);const n=i,r=w(t.commands),o=m(t.cliFlag),s=o.length>0&&o!==y(e)?o:void 0,d=s??y(e),g=C(t.aliases??[],d),c=t.description?.trim();return{key:e,type:n,commands:r,description:c&&c.length>0?c:void 0,cliFlag:s,cliAliases:g,required:t.required===!0,requiredOnCreate:t.requiredOnCreate===!0,allowUnset:t.allowUnset!==!1,requiredTypes:S(t.requiredTypes)}}function I(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 q(t){const e=I(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 N(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:q(e)}}function O(t){return`${JSON.stringify({fields:t.fields},null,2)}
2
+ `}function U(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 p(o,"description",e.description),p(o,"cli_flag",e.cliFlag),e.cliAliases.length>0?o.cli_aliases=[...e.cliAliases]:delete o.cli_aliases,h(o,"required",e.required),h(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 p(t,e,i){const n=t;i!==void 0&&i.length>0?n[e]=i:delete n[e]}function h(t,e,i){const n=t;i?n[e]=!0:delete n[e]}export{u as BUILTIN_FIELD_KEYS,M as normalizeAddFieldInput,R as normalizeFieldKey,N as parseFieldsFile,v as removeField,O as serializeFieldsFile,U as upsertField};
3
3
  //# sourceMappingURL=fields-file.js.map
@@ -1,2 +1,2 @@
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};
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 R}from"./runtime-schema.js";import{assertIdentityFieldsWithoutUrlCredentials as h}from"../shared/url-credentials.js";import{isRegistrableFieldFlagSpelling as j}from"../../sdk/schema/field-flag-spelling.js";const x=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 H(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 q(e){return e.startsWith("-")?e:`--${e}`}function I(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=>{if(!j(u))return!1;const s=A(u);return b(u)||t.flags.has(q(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([R(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 U(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 N(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 M(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(!N(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 L(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 T(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>x)return`${t} value schema exceeds maximum depth`;const i=M(e,r,t);if(i)return i;const o=L(e,r,t,n);if(o)return o;const u=T(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 V(e,r,t,n){const i=n==="option"&&Array.isArray(r)?r[r.length-1]:r;if(i!==void 0)return f(e,U(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 V(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 w(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 X(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){w(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 B(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 h(n),n}export{k as coerceRuntimeFieldValue,X as collectRuntimeCreateFieldValues,B as collectRuntimeUpdateFieldValues,A as commanderOptionAttribute,S as readRuntimeFieldOptionValue,p as resolveCandidateOptionKeys,I as runtimeFieldCliFlagRoute,q as runtimeFieldFlagToken,H as runtimeFieldSdkOptionName,w as shouldRequireFieldOnCreate};
2
2
  //# sourceMappingURL=runtime-field-values.js.map
@@ -99,6 +99,8 @@ type_definitions_from_file:ItemTypeDefinition[]|undefined;
99
99
  warnings:string[];
100
100
  /** Value that configures or reports created paths for this contract. */
101
101
  created_paths:string[];}
102
+ /** Normalize a stored field flag token as the registry reads it: trimmed, lower-cased, separators as hyphens, leading dashes removed. */
103
+ export declare function normalizeCliToken(value:unknown):string;
102
104
  /** Implements normalize runtime schema settings for the public runtime surface of this module. */
103
105
  export declare function normalizeRuntimeSchemaSettings(schema:Partial<RuntimeSchemaSettings>|undefined):RuntimeSchemaSettings;
104
106
  /** Implements file path for schema section for the public runtime surface of this module. */
@@ -1,3 +1,3 @@
1
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};
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,M as normalizeCliToken,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,10 +1,60 @@
1
1
  /**
2
2
  * @module core/shared/command-line
3
- * Quotes tokenized recovery commands for the current platform shell.
3
+ * Quotes tokenized recovery commands for a declared shell dialect.
4
+ *
5
+ * Every rendered pm command (recovery `suggested_retry`, `restore_with`,
6
+ * next-step hints) is written for one shell. `posix` is the default outside
7
+ * Windows; on Windows the default is `cmd`, the cmd.exe / CreateProcess
8
+ * dialect settled in pm-b24b, and `PM_COMMAND_SHELL=powershell` switches to
9
+ * PowerShell literal quoting (pm-kjoudp, GH-1774).
4
10
  */
11
+ /** Shell a rendered pm command is quoted for. */
12
+ export type CommandShellDialect="posix"|"cmd"|"powershell";
13
+ /** Environment variable that declares the shell rendered pm commands are pasted into. */
14
+ export declare const COMMAND_SHELL_ENV="PM_COMMAND_SHELL";
15
+ /**
16
+ * The shell dialect rendered commands use: a recognized `PM_COMMAND_SHELL`
17
+ * value wins, otherwise `cmd` on Windows and `posix` elsewhere. An empty or
18
+ * unrecognized value keeps the platform default, so a typo never yields a
19
+ * dialect the caller did not choose.
20
+ */
21
+ export declare const resolveCommandShellDialect:(platform?:NodeJS.Platform,env?:Readonly<Record<string,string|undefined>>)=> CommandShellDialect;
5
22
  /** Quote one Windows argument with the linear CommandLineToArgvW escaping algorithm. */
6
23
  export declare const quoteWindowsCommandArg:(arg:string)=> string;
7
- /** Quote one command argument only when platform shell-significant characters require it. */
8
- export declare const quoteCommandArg:(arg:string,platform?:NodeJS.Platform)=> string;
24
+ /**
25
+ * Caret-escape a CommandLineToArgvW-quoted argument for cmd.exe. Every quote
26
+ * is escaped, so cmd.exe never enters a quoted region and removes each caret
27
+ * exactly once, handing CreateProcess the exact CommandLineToArgvW spelling.
28
+ * Every `%` is immediately followed by a caret (its own, or the one escaping
29
+ * the next metacharacter), so each text cmd.exe could read as a `%name%` or
30
+ * `%name:modifier%` reference names a variable starting with `^`, which no
31
+ * defined variable does; interactive and `cmd /c` percent expansion then
32
+ * leaves it intact.
33
+ */
34
+ export declare const escapeCmdMetacharacters:(quoted:string)=> string;
35
+ /**
36
+ * Quote one argument for cmd.exe: CommandLineToArgvW quoting, caret-escaped
37
+ * when cmd.exe would otherwise expand or split it. cmd.exe ends a command at
38
+ * a line break and no escape carries one, so each line break is rendered as
39
+ * a space: a pasted retry can never run the text after the break as another
40
+ * command (GH-1774).
41
+ */
42
+ export declare const quoteCmdCommandArg:(arg:string)=> string;
43
+ /** Double every single quote, including the typographic ones PowerShell also accepts, for a single-quoted PowerShell string. */
44
+ export declare const escapePowerShellSingleQuotes:(text:string)=> string;
45
+ /**
46
+ * Quote one argument as a PowerShell literal (single-quoted) string, where
47
+ * `$`, `$(...)`, backticks and `%` never expand.
48
+ */
49
+ export declare const quotePowerShellCommandArg:(arg:string)=> string;
50
+ /** Quote one command argument for `dialect` (default: the declared shell for `platform`) only when its shell-significant characters require it. */
51
+ export declare const quoteCommandArg:(arg:string,platform?:NodeJS.Platform,dialect?:CommandShellDialect)=> string;
52
+ /**
53
+ * Quote one argument for a POSIX shell. Double quotes with `"`, `\`, `$` and
54
+ * backticks escaped are exact for `sh -c` and scripts; an argument holding
55
+ * `!` is single-quoted instead, because interactive bash and zsh
56
+ * history-expand `!` inside double quotes (pm-oq893h).
57
+ */
58
+ export declare const quotePosixCommandArg:(arg:string)=> string;
9
59
  /** Render a complete pm command from already-tokenized arguments. */
10
- export declare const renderPmCommand:(argv:string[],platform?:NodeJS.Platform)=> string;
60
+ export declare const renderPmCommand:(argv:string[],platform?:NodeJS.Platform,dialect?:CommandShellDialect)=> string;
@@ -1,2 +1,2 @@
1
- const o=t=>{let n='"',e=0;for(const r of t){if(r==="\\"){e+=1;continue}n+="\\".repeat(r==='"'?e*2+1:e),n+=r,e=0}return`${n}${"\\".repeat(e*2)}"`},s=(t,n=process.platform)=>(n==="win32"?/^[A-Za-z0-9._:/\\@=-]+$/:/^[A-Za-z0-9._:/@=-]+$/).test(t)?t:n==="win32"?o(t):`"${t.replace(/(["\\$`])/g,"\\$1")}"`,a=(t,n=process.platform)=>{const e=t.map(r=>s(r,n)).join(" ");return e.length>0?`pm ${e}`:"pm"};export{s as quoteCommandArg,o as quoteWindowsCommandArg,a as renderPmCommand};
1
+ const l="PM_COMMAND_SHELL",a=new Map([["posix","posix"],["sh","posix"],["bash","posix"],["zsh","posix"],["cmd","cmd"],["cmd.exe","cmd"],["powershell","powershell"],["pwsh","powershell"]]),r=(e=process.platform,t=process.env)=>{const o=t[l]?.trim().toLowerCase(),n=o===void 0?void 0:a.get(o);return n!==void 0?n:e==="win32"?"cmd":"posix"},d=e=>{let t='"',o=0;for(const n of e){if(n==="\\"){o+=1;continue}t+="\\".repeat(n==='"'?o*2+1:o),t+=n,o=0}return`${t}${"\\".repeat(o*2)}"`},c=new Set(["(",")","!","^",'"',"<",">","&","|"]),i=e=>{let t="";for(let o=0;o<e.length;o+=1){const n=e[o];if(c.has(n)){t+=`^${n}`;continue}t+=n,n==="%"&&!c.has(e.charAt(o+1))&&(t+="^")}return t},u=/["%]/u,m=/\r\n|[\r\n]/gu,h=e=>{const t=e.replace(m," "),o=d(t);return u.test(t)?i(o):o},A=/['\u2018\u2019\u201A\u201B]/gu,_=e=>e.replace(A,"$&$&"),x=e=>`'${_(e)}'`,E={posix:/^(?!=)[A-Za-z0-9._:/@=-]+$/u,cmd:/^[A-Za-z0-9._:/\\@=-]+$/u,powershell:/^(?!--$)[A-Za-z0-9._:/\\=-][A-Za-z0-9._:/\\@=-]*$/u},C=(e,t=process.platform,o)=>{const n=o??r(t);return E[n].test(e)?e:n==="cmd"?h(e):n==="powershell"?x(e):f(e)},f=e=>e.includes("!")?`'${e.replaceAll("'","'\\''")}'`:`"${e.replace(/(["\\$`])/g,"\\$1")}"`,S=(e,t=process.platform,o)=>{const n=o??r(t),s=e.map(p=>C(p,t,n)).join(" ");return s.length>0?`pm ${s}`:"pm"};export{l as COMMAND_SHELL_ENV,i as escapeCmdMetacharacters,_ as escapePowerShellSingleQuotes,h as quoteCmdCommandArg,C as quoteCommandArg,f as quotePosixCommandArg,x as quotePowerShellCommandArg,d as quoteWindowsCommandArg,S as renderPmCommand,r as resolveCommandShellDialect};
2
2
  //# sourceMappingURL=command-line.js.map
@@ -280,6 +280,15 @@ last_activity_at:string|null;
280
280
  history_unreadable?:true;
281
281
  /** Present when the readable stream cannot prove the holder's idleness: no original record sets the holder, or after it a salvage discarded, a repair, redaction or merge reconcile rewrote, or a workspace restore replaced records. The claim is then never judged stale. */
282
282
  unproven_activity?:"claim_record_unavailable"|"discarded_history_tail"|"rewritten_history"|"workspace_restored";
283
+ /**
284
+ * Holder activity under the stale-work policy: `stale` when idleness is
285
+ * proven past the threshold, `active` when recorded activity is recent,
286
+ * and `unknown` when the history is unreadable, cannot prove idleness, or
287
+ * no valid activity time is recorded (GH-1774). pm always sets it;
288
+ * evidence built by an older producer may omit it, and readers then
289
+ * derive it from the other fields.
290
+ */
291
+ state?:"active"|"stale"|"unknown";
283
292
  /** Whole hours since `claimed_at`, or null when the claim time is unknown. */
284
293
  claim_age_hours:number|null;
285
294
  /** Whole hours since `last_activity_at`, or null when the activity time is unknown. */
@@ -1,6 +1,6 @@
1
- const A=`[^\\s/\\\\<>"'\\x60()\\[\\]{},;?=:#*]+`,d="[/\\\\]+",Ae="[\\p{L}\\p{N}._@-]+",R=Ae+"(?:"+d+A+")*",w="(?:(?:home|users)"+d+R+"|root"+d+R+")",Re="[/\\\\]"+w,$e="[/\\\\]{2,}"+w,me="/?[a-z]:"+d+"users"+d+R,he=A+"(?: +"+A+")*",x="(?:"+he+d+")?users"+d+R,we="[/\\\\]{2,}"+A+d+x,Se="(?:[a-z]:|volume\\{[a-f0-9-]+\\}|"+A+")",P="[/\\\\]{2}[?.]"+d+"(?:unc"+d+A+d+x+"|"+Se+d+"users"+d+R+")",ye="file:(?:"+P+"|(?:[/\\\\](?![/\\\\])|[/\\\\]{3,}|[/\\\\]{2}localhost"+d+")(?:"+w+"|[a-z]:"+d+"users"+d+R+")|[/\\\\]{2}(?:[a-z]:"+d+"users"+d+R+"|"+A+d+"(?:"+w+"|"+x+")))",Ne=new RegExp("(?:^|[^\\p{L}\\p{N}_./\\\\~])(?:"+Re+"|"+me+"|"+ye+")|(?:^|[^\\p{L}\\p{N}_:./\\\\~])(?:"+$e+"|"+we+"|"+P+")","giu"),Z=4,xe=/%[a-f0-9]{2}|\\(?:u[a-f0-9]{4}|x[a-f0-9]{2}|\/)/iu,Ie=new TextDecoder("utf-8");function Le(e){return e.replace(/(?:%[a-f0-9]{2})+/giu,n=>Ie.decode(Uint8Array.from(n.matchAll(/%([a-f0-9]{2})/giu),t=>Number.parseInt(t[1],16)))).replace(/%(?![a-f0-9]{2})[a-z0-9]{0,2}/giu,"\uFFFD")}function be(e){return e.replace(/\\+(?:u([a-f0-9]{4})|x([a-f0-9]{2})|(\/))?/giu,(n,t,r,s)=>{const i=t??r;return i===void 0?s??n:String.fromCharCode(Number.parseInt(i,16))})}function Te(e){return e.normalize("NFKC").replace(/[\p{Bidi_Control}\u200b-\u200f\u2060-\u206f\ufeff]/gu,"").replace(/[\u2215\u2044]/gu,"/").replace(/[\u043e\u041e]/gu,"o").replace(/[\u0455\u0405]/gu,"s")}function Oe(e,n){for(const[t,r]of[["percent_decode",Le],["json_unescape",be],["unicode_fold",Te]]){const s=r(e);s!==e&&!n.includes(t)&&n.push(t),e=s}return e}function*ke(e,n,t){let r=e;const s=[];for(let i=0;i<Z;i+=1){const o=r;if(r=Oe(r,s),!t){n.lastIndex=0;for(const a of r.matchAll(n))t=!0,yield{index:0,normalizations:[...s]}}if(r===o)break;i===Z-1&&xe.test(r)&&(yield{index:0,normalizations:[...s],normalization_incomplete:!0})}}function*Ce(e,n){let t=0;for(const r of e.split(`
2
- `)){n.lastIndex=0;let s=!1;for(const i of r.matchAll(n))s=!0,yield{index:t+i.index};for(const i of ke(r,n,s))yield{...i,index:t};t+=r.length+1}}const M="password|passphrase",S=4,g=4096,m=e=>`${e}+(?!${e})`,D=String.raw`'[^'\r\n]*'|"[^"\\\r\n]*(?:\\.[^"\\\r\n]*){0,${g}}"`,ze=String.raw`\$\{(?:${m(String.raw`[^{}$'"\\\r\n]`)}|\\[^\r\n]|${D}|\$(?!\{)|\$\{[^{}\r\n]*\}){0,${g}}\}`+String.raw`|\$\((?:${m(String.raw`[^()$'"\\\r\n]`)}|\\[^\r\n]|${D}|\$(?!\()|\$\([^()\r\n]*\)){0,${g}}\)`,U=String.raw`${ze}|<[^<>\r\n]*>|${m(String.raw`[A-Za-z0-9!@#%^&*._+\-=]`)}|\$(?![{(])`,Pe=String.raw`"[^"]*"|'[^']*'`,v=String.raw`(?:"[^"\s]*"|'[^'\s]*')(?:${U}){0,${g}}`,V=new RegExp(String.raw`(?!config\.auth\.password\s*(?:\|\|\s*(?:''|"")|\?\s*unescape\(encodeURIComponent\(config\.auth\.password\)\)\s*:\s*(?:''|""))(?=[ \t]*(?:\/\*(?:[^*]|\*(?!\/))*\*\/[ \t]*)*(?:;|$|\/\/[^\r\n\u2028\u2029]*(?:\r\n)?$)))`+`((?:${U}){1,${g}}(?:${v}){0,${S}}|(?:${v}){1,${S}}|${Pe})`),Ze=8,F="token|secret|password|passwd|api[_-]?key",I="(?<![a-z0-9_]|[a-z0-9_]-)(?:(?:[a-z0-9]+_)+(?:password|passphrase)|(?:[a-z0-9]+[_-])*(?:secret|token|(?:api|secret|private|access)[_-]?key|client[_-]?secret|passwd|pwd))",E=4096,H=String.raw`"(?=[^"\s]{8}[^"\s]*")|'(?=[^'\s]{8}[^'\s]*')|(?!["'])`,B=String.raw`(?![<[$/]|~\/|\.\.?\/|[A-Za-z][\w+.-]*:\/\/|%[A-Za-z_]\w*%|[A-Za-z]:[\\/]|(?<=")(?:(?:[A-Za-z_]\w*\.){1,${E}}[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+){0,${E}}|(?:[\w.-]+\/){1,${E}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})"|(?<=')(?:(?:[A-Za-z_]\w*\.){1,${E}}[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+){0,${E}}|(?:[\w.-]+\/){1,${E}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})'|(?<!["'])[A-Za-z]+(?:-[A-Za-z]+){0,${E}}(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[A-Za-z_]\w*\.){1,${E}}[A-Za-z_]\w*(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[\w.-]+\/){1,${E}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4}(?=[\s,;)}\]]|$)|(?<!["'])[\w$.]+\()(?:(?<=")[^\s"]{8}[^\s"]*|(?<=')[^\s']{8}[^\s']*|(?<==)[A-Za-z0-9!@#$%^&*._+\-=/~?:|]{8,}|(?<!["'=])[A-Za-z0-9!@#$%^&*._+\-=/~]{8,})`,L=new RegExp(`(?:${H})(${B})`,"iy"),Me=8,De=String.raw`[A-Za-z0-9!@#%^*._+\-=/~]`,q=String.raw`&(?!&)`,Ue=64,W=String.raw`'[^'\s]*'|"[^"\\\s]*(?:\\\S[^"\\\s]*){0,${g}}"`,K=String.raw`\$\{(?:${m(String.raw`[^{}$'"\\\s]`)}|\\\S|${W}|\$(?!\{)|\$\{[^{}\s]*\}){0,${g}}\}`+String.raw`|\$\((?:${m(String.raw`[^()$'"\\\s]`)}|\\\S|${W}|\$(?!\()|\$\([^()\s]*\)){0,${g}}\)`+String.raw`|<[^<>\s]*>|\$[A-Za-z_]\w*(?!\w)`,j=e=>String.raw`${K}|${m(e)}|${q}|\$(?![{(A-Za-z_])`,Q=e=>String.raw`(?:"[^"\s]*"|'[^'\s]*')(?:${j(e)}){0,${g}}`,ve=e=>String.raw`(?:(?:${e}|${q}){1,${Ue}}(?=[$<]))?(?:${K})`+String.raw`(?:${j(e)}){0,${g}}(?:${Q(e)}){0,${S}}`,Ve=e=>String.raw`(?:${Q(e)}){1,${S}}`,G=e=>String.raw`(?<!["'])(?:${e(De)})`,Y=String.raw`(?:[\w@#~]|!(?![.+\-*/%=^!(]))`,Fe=String.raw`(?=(?:"[^"\s]*"|'[^'\s]*')[$<"']`+String.raw`|"(?=[^"\s]*[$<])[^"\s]*"${Y}|'(?=[^'\s]*[$<])[^'\s]*'${Y})`,He=String.raw`(?<=")(?=[^"\s]*[$<])[^"\s]+|(?<=')(?=[^'\s]*[$<])[^'\s]+`,X=new RegExp(`(?:${Fe}|${H})((?=["'])(?:${G(Ve)})|${He}|${G(ve)}|${B})`),J=/["']?([A-Za-z0-9+/=_-]{24,})/,tt=[{name:"private-key",mutationRule:"private_key",category:"credential",regex:/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/g},{name:"github-token",mutationRule:"github_token",category:"credential",regex:/\b(?:gh[opsru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g},{name:"npm-token",mutationRule:"npm_token",category:"credential",regex:/\bnpm_[A-Za-z0-9]{20,}\b/g},{name:"aws-access-key",mutationRule:"aws_access_key",category:"credential",regex:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"google-api-key",mutationRule:"google_api_key",category:"credential",regex:/\bAIza[0-9A-Za-z_-]{35}\b/g},{name:"slack-token",mutationRule:"slack_token",category:"credential",regex:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g},{name:"anthropic-api-key",mutationRule:"anthropic_api_key",category:"credential",regex:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/g},{name:"openai-api-key",mutationRule:"openai_api_key",category:"credential",regex:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}\b/g},{name:"gitlab-token",mutationRule:"gitlab_token",category:"credential",regex:/\bglpat-[A-Za-z0-9_.-]{20,}\b/g},{name:"jwt-like-token",mutationRule:"jwt_like_token",category:"credential",regex:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g},{name:"npm-auth-token-assignment",mutationRule:"npm_auth_token_assignment",category:"credential",regex:/_authToken\s*=\s*\S+/g},{name:"sentry-user-token",mutationRule:"sentry_user_token",category:"credential",regex:/\bsntryu_[A-Za-z0-9]{20,}\b/g},{name:"sentry-org-token",mutationRule:"sentry_org_token",category:"credential",regex:/\bsntrys_[A-Za-z0-9_-]{20,}\b/g},{name:"private-ip",mutationRule:"private_ip",category:"network",regex:/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"private-ssh-target",mutationRule:"private_ssh_target",category:"network",regex:/\b(?:ssh|scp|rsync)\s+[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"sshpass-inline-password",mutationRule:"sshpass_inline_password",category:"credential",regex:/\bsshpass\s+-p\s+["'][^"']{6,}["']/g},{name:"password-assignment",mutationRule:"password_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${M})\s*[:=]\s*`+V.source,"gi"),structured:{keys:M,value:V.source,element:!0},minimumLiteralLength:Ze},{name:"absolute-home-path",mutationRule:"absolute_home_path",category:"path",regex:Ne,excludeFiles:/^(?:tests\/|examples\/)/},{name:"user-at-private-host",mutationRule:"user_at_private_host",category:"network",regex:/(?<![A-Za-z0-9._-])[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,excludeFiles:/^(?:tests\/|examples\/)/},{name:"high-entropy-assignment",mutationRule:"high_entropy_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${F})\s*[:=]\s*`+J.source,"gi"),structured:{keys:F,value:J.source},mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5},{name:"credential-key-assignment",mutationRule:"credential_key_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${I})\s*[:=]\s*`+X.source,"gi"),structured:{keys:I,value:X.source,element:!0,elementValue:!0},mutationOnlyReason:"Key-named assignments in source code and test fixtures are identifiers and synthetic data; repository scans keep the token-format rules, which recognize real credentials there.",minimumEntropy:3,minimumLiteralLength:Me,literalValue:L,baseline:{regex:new RegExp(String.raw`\b(?:${I})\s*[:=]\s*`+L.source,"gi"),value:L.source},rejectValue:/^(?:[\w.-]+\/)*id_(?:rsa|dsa|ecdsa|ed25519)(?:_sk)?(?:\.pub)?$/u,rejectStatementReference:/^[A-Z]+(?:_[A-Z]+)+$/u}];function*rt(e,n){if(e.mutationRule==="absolute_home_path"){yield*Ce(n,e.regex);return}for(const t of ne(e))yield*Ge(t,n),t.structured&&(yield*Pn(t,t.structured,n))}const ee=new WeakMap;function ne(e){const n=e.baseline;if(n===void 0)return[e];let t=ee.get(e);return t===void 0&&(t={...e,regex:n.regex,minimumLiteralLength:void 0,literalValue:void 0,baseline:void 0},e.structured&&(t.structured={...e.structured,value:n.value}),ee.set(e,t)),[e,t]}function Be(e,n){const t=e[n-1]==="#"||e[n-1]==="!"?n-1:n;return e[t-1]==="{"&&e[t-2]==="$"}const b=new WeakSet,te=new WeakMap,qe=4096;function We(e,n,t){const r=[],s=[],i=n+t.length;return re(e,n,i,s,r),re(e,i,Math.min(e.length,i+qe),s),r}function re(e,n,t,r,s){for(let i=n;i<t&&(s!==void 0||r.length>0);i+=1){const o=r.at(-1);if(e[i]==="$"&&(e[i+1]==="{"||e[i+1]==="(")&&o?.quoted!=="'"){const a={open:i,close:t,command:e[i+1]==="(",quoted:[]};s?.push(a),r.push({span:a,closer:e[i+1]==="{"?"}":")"}),i+=1}else o!==void 0&&(i=Ke(e,i,r))}}function Ke(e,n,t){const r=t.at(-1),s=e[n];return s==="\\"&&r.quoted!=="'"?n+1:(r.quoted!==void 0?s===r.quoted&&(r.span.quoted.push([r.quoteStart,n]),r.quoted=void 0):s==="'"||s==='"'?(r.quoted=s,r.quoteStart=n):s===r.closer&&(t.pop().span.close=n),n)}function je(e){const n=[];let t=0;return r=>{for(;t<e.length&&e[t].open<r;t+=1){for(;n.length>0&&n.at(-1).close<e[t].open;)n.pop();n.push(e[t])}for(;n.length>0&&n.at(-1).close<r;)n.pop();return n.at(-1)}}function Qe(e,n){let t=0,r=e.quoted.length-1;for(;t<=r;){const s=t+r>>1,[i,o]=e.quoted[s];if(n<i)r=s-1;else if(n>o)t=s+1;else return!0}return!1}const se=/\$[({A-Za-z_]|</u;function*Ge(e,n){const t=e.regex;t.lastIndex=0;const r=Ye(e);let s;for(const i of n.matchAll(t))N(e,i)?yield{index:i.index}:r!==void 0&&se.test(i[1])&&(s??=new RegExp(t),yield*Xe(e,s,n,i,r==="deep"))}function Ye(e){return e.minimumLiteralLength===void 0?void 0:e.minimumEntropy===void 0&&e.literalValue===void 0&&e.rejectValue===void 0?"deep":"shallow"}function*Xe(e,n,t,r,s){const i=r.index+r[0].length;n.lastIndex=i-r[1].length;let o;for(let a=n.exec(t);a!==null&&a.index<i;a=n.exec(t)){if(Be(t,a.index)){n.lastIndex=a.index+1;continue}o??=je(We(t,i-r[1].length,r[1]));const u=o(a.index);u!==void 0&&(te.set(a,u.close),u.command&&!Qe(u,a.index)&&b.add(a)),N(e,a)?yield{index:a.index}:s&&se.test(a[1])&&(n.lastIndex=a.index+a[0].length-a[1].length)}}const ie=new Map,oe=/[\r\n\u2028\u2029]/u;function T(e){const n=`${e.keys}\0${e.value}\0${e.element===!0}`;let t=ie.get(n);return t||(t={key:new RegExp(String.raw`\b(?:${e.keys})(["']?)\s*[:=]\s*`,"gi"),value:new RegExp(e.value,"iyd"),...e.element?{element:{open:new RegExp(String.raw`<(?:${e.keys})(?:\s[^<>]*)?>`,"gi"),close:new RegExp(String.raw`<\/(?:${e.keys})\s*>`,"iy"),span:new RegExp(String.raw`<(?!\/?(?:${e.keys})\b)[^<>]*>`,"iy")}}:{}},ie.set(n,t)),t}function ae(e,n){const t=e[n];for(let r=n+1;r<e.length;r+=1){const s=e[r];if(s==="\\")r+=1;else if(s===t)return{end:r+1,terminated:!0}}return{end:e.length,terminated:!1}}function Je(e,n){return ae(e,n).end}function en(e,n,t){return e.at(-1)==="}"?t:n}function nn(e,n,t,r=t){const s=[];let i=!1;for(let o=n;o<e.length;o+=1){const a=e[o];switch(a){case"[":case"{":s.push(a==="["?"]":"}"),i=a==="{";break;case"]":case"}":if(s.pop()!==a||s.length===0)return{found:!1,end:o+1};i=!1;break;case",":i=s.at(-1)==="}";break;case":":i=!1;break;case'"':case"'":if(!i&&en(s,t,r)(o))return{found:!0,end:o};o=Je(e,o)-1;break;default:break}}return{found:!1,end:e.length}}const tn=/\\(?:U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[0-7]{1,3}|[\s\S])/gu,rn={n:`
3
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"};function sn(e,n){const t=e[0],r=e.slice(1,n?-1:void 0).replaceAll(tn,o=>{const a=o[1];if((a==="u"||a==="x")&&o.length>2)return String.fromCharCode(Number.parseInt(o.slice(2),16));if(/^[0-7]$/u.test(a))return String.fromCharCode(Number.parseInt(o.slice(1),8));if(a==="U"&&o.length===10){const u=Number.parseInt(o.slice(2),16);return u<=1114111?String.fromCodePoint(u):"\uFFFD"}return rn[a]??a}),s=r.replaceAll(t,t==='"'?"'":'"').replaceAll(/[\r\n\u2028\u2029]/gu," "),i=n?t:"";return{reading:`${t}${s}${i}`,...ue(`${t}${r}${i}`,n)}}function ue(e,n){return{original:e,bodyStart:1,bodyEnd:e.length-(n?1:0)}}const on=64;function ce(e,n,t){const r=e[n-1];if(!t)return r!==void 0&&/[\p{L}\p{N}_.-]/u.test(r)?"prefixed":"exact";if(r===t)return"exact";const s=Math.max(0,n-on);for(let i=n-1;i>=s;i-=1){const o=e[i];if(o===t)return"prefixed";if(o===`
4
- `||o==="\r"||o==='"'||o==="'")return"malformed"}return"malformed"}function le(e,n,t,r=!1){const s=(a,u,c)=>{n.lastIndex=u;const l=n.exec(a);if(l===null||oe.test(l[0]))return null;const f=l.indices?.[1];return c!==void 0&&f!==void 0&&(l[1]=c.original.slice(Math.max(f[0],c.bodyStart),Math.min(f[1],c.bodyEnd)),O.add(l)),N(e,l)?l:null},i=a=>{if(t[a]!=='"'&&t[a]!=="'")return;const{end:u,terminated:c}=ae(t,a),l=t.slice(a,u);if(!r&&!l.includes("\\"))return;if(oe.test(l))return[];const f=sn(l,c);return(t[a]==="'"?[f,{reading:l,...ue(l,c)}]:[f]).map(_=>s(_.reading,0,_)).filter(_=>_!==null)},o=a=>{const u=i(a);if(u!==void 0)return u;const c=s(t,a);return c===null?[]:[c]};return{direct:a=>s(t,a)!==null,escaped:a=>(i(a)?.length??0)>0,accepts:a=>u=>o(u).some(c=>!(a&&/\s/u.test(an(e,c))))}}function an(e,n){return e.minimumLiteralLength===void 0?n[0]:de(n)}const O=new WeakSet;function de(e){const n=b.has(e)&&!$(h(e))?un(e[1]):void 0,t=n??e[1],r=n!==void 0||ln(e);return O.has(e)||$(h(e))?_e(t,r):nt(t,r)}function un(e){for(let n=0;n<e.length;n+=1){const t=e[n];if(t==="'"||t==='"')n=ge(e,n);else if(t==="$"&&(e[n+1]==="{"||e[n+1]==="("))n=Math.max(n,k(e,n)-1);else if(/[|&;<>]/u.test(t))return e.slice(0,n)}}const cn=/^[;,)}\]]{0,64}/u;function ln(e){const n=e.input,t=e.index+e[0].length,r=$(h(e))&&$(n[t])?t+1:$(e[0].at(-1))?t:-1,s=r===-1?t:r,i=cn.exec(n.slice(s,s+An))[0].length,o=s+i;if(o===n.length||/\s/u.test(n[o])||te.get(e)===s||b.has(e)&&/[|&;<>]/u.test(n[s]))return!0;if(r===-1||i===0)return!1;const a=dn(e,r===t+1),u=n.slice(o,o+40),c=/[}\]]/u.test(n.slice(s,o));return a!==void 0&&(pn.test(u)||(a==="element"||c)&&_n.test(u))}function dn(e,n){const t=e.input,r=e.index+e[0].length-e[1].length-(n?1:0),s=t.slice(Math.max(0,r-fn),r);return En.test(s)?"element":gn.test(s)?"key":void 0}const fn=512,gn=/[{,]\s*(["'])[^"'\r\n]{1,256}\1\s*[:=]\s*$/u,En=/[[,]\s*$/u,pn=/^(?:["'`]|[{[](?:[\s"'`{[\]}]|$|(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)[\s,\]}]))/u,_n=/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)[\s,\]}]/u,An=64,Rn=/^\s{0,16}\(/u,$n=/(?<![=!<>])=[ \t]{0,16}$/u;function h(e){return e.input[e.index+e[0].length-e[1].length-1]}function $(e){return e==='"'||e==="'"}const mn=/[$<"']/u;function hn(e){if(O.has(e)||$(h(e))||!/^[$<]/u.test(e[1]))return!1;const n=e.index+e[0].length,t=n-e[1].length,r=e.input.slice(n,n+18);if(e[1][0]==="<"&&(In(e[1])||$n.test(e.input.slice(Math.max(0,t-18),t))||bn.test(r)))return!0;const s=fe(e[1]),i=e[1][s]==="!"?e[1][s+1]:e[1][s];return Ln.test(i??"")||Rn.test(r)}function fe(e){let n=0;for(let t=k(e,n);t!==-1;t=k(e,n))n=t;return n}function k(e,n){const t=e[n];if(t==="<")return wn(e,n);if(t!=="$")return-1;const r=e[n+1];if(r==="{"||r==="(")return Sn(e,n+1,r);y.lastIndex=n;const s=y.exec(e)?.[0];return s===void 0?-1:n+s.length}function wn(e,n){const t=e.indexOf(">",n+1),r=e.indexOf("<",n+1);return t!==-1&&(r===-1||t<r)?t+1:-1}function Sn(e,n,t){const r=t==="{"?"}":")";let s=0;for(let i=n;i<e.length;i+=1){const o=e[i];if(o==="\\")i+=1;else if(o==="'"||o==='"')i=ge(e,i);else if(o===t)s+=1;else if(o===r&&--s===0)return i+1}return-1}function ge(e,n){const t=e[n];for(let r=n+1;r<e.length;r+=1){if(e[r]===t)return r;t==='"'&&e[r]==="\\"&&(r+=1)}return e.length}const yn=/^[\w$.[\]|&,{}:;?]+$/u,Nn=/^(?:"[^"]*"|'[^']*'|-?\d+(?:\.\d+)?)(?:\|(?:"[^"]*"|'[^']*'|-?\d+(?:\.\d+)?|[A-Za-z_$][\w$.]*))*$/u,xn=/\b(?:string|number|boolean|bigint|symbol|any|unknown|object|never|void|undefined|null)\b/u;function In(e){const n=e.slice(1,e.indexOf(">"));return Nn.test(n)?!0:yn.test(n)?xn.test(n)||/[.|&[{]/u.test(n)||/^[A-Z][\w$]*$/u.test(n)&&(n.length===1||/[a-z]/u.test(n)):!1}const Ln=/[.+\-*/%=^&]/u,bn=/^\s{0,16}(?:\?\.|\?\?|\|\||&&|[([])/u;function Tn(e,n,t){if(t)return!1;const r=n.replaceAll('"',"'");return e.lastIndex=0,e.exec(`"${r}"`)?.[1]===r}function st(e,n){if(!e.structured)return;const t=`${JSON.stringify(n)}:`,r=T(e.structured).key;r.lastIndex=0;for(let s=r.exec(t);s;s=r.exec(t)){if(s.index+s[0].length!==t.length)continue;const i=ce(t,s.index,s[1]);if(i!=="malformed")return i}}function it(e,n,t){if(!e.structured)return!1;const r=JSON.stringify(n).replaceAll("\u2028","\\u2028").replaceAll("\u2029","\\u2029");return ne(e).some(s=>le(s,T(s.structured).value,r,!0).accepts(t)(0))}function*On(e,n,t){const r=new RegExp(e.open);for(let s=r.exec(n);s;s=r.exec(n)){const i=s.index+s[0].length,o=kn(e,n,i);if(o===void 0){r.lastIndex=s.index+1;continue}t(n.slice(i,o.start).trim())&&(yield{index:s.index}),r.lastIndex=o.end}}function kn(e,n,t){for(let r=n.indexOf("<",t);r!==-1;){e.close.lastIndex=r;const s=e.close.exec(n);if(s!==null)return{start:r,end:r+s[0].length};e.span.lastIndex=r;const i=e.span.exec(n);if(i===null)return;r=n.indexOf("<",r+i[0].length)}}function Cn(e,n,t){return n<e.exact||t&&n<e.compact}function zn(e,n,t,r){return(t||e.escaped(r)&&!e.direct(r))&&n(r)}function*Pn(e,n,t){const r=T(n),s=le(e,r.value,t),i=new RegExp(r.key),o={exact:0,compact:0};for(let a=i.exec(t);a;a=i.exec(t)){const u=a[1],c=ce(t,a.index,u);if(c==="malformed")continue;const l=c==="prefixed",f=s.accepts(l),p=a.index+a[0].length,_=t[p];if(_==="["||_==="{"){if(Cn(o,p,l))continue;const z=nn(t,p,f,s.accepts(!0));o[l?"compact":"exact"]=z.end,z.found&&(yield{index:a.index})}else zn(s,f,u,p)&&(yield{index:a.index})}r.element&&(yield*On(r.element,t,Mn(e,n,r)))}const Zn=8;function Mn(e,n,t){if(!n.elementValue){const r=e.minimumLiteralLength??Zn;return s=>_e(s).length>=r}return r=>{const s=r.replaceAll('"',"'");t.value.lastIndex=0;const i=t.value.exec(`"${s}"`);return i===null||i[1]!==s?!1:(i[1]=r,N(e,i))}}function Dn(e,n,t){const r=n.index+n[0].length;return/^[ \t]*;/u.test(n.input.slice(r,r+64))&&!$(h(n))&&e.test(t)}function Un(e,n){for(let t=n+1;t<e.length;t+=1){if(e[t]===">")return t;if(e[t]==="<")return-1}return-1}function C(e,n){e.raw+=n,e.literal+=n}function vn(e,n,t){const r=e[n+1];if(e[n]!=="$"||r!=="{"&&r!=="(")return-1;const s=r==="{"?e.slice(n+2,n+2+jn(e,n+2)):"",i=t[0],o=t.length===1&&i.quote!==void 0&&i.literal.length===i.pieceStart;return t.push({close:r==="{"?"}":")",keep:s!=="",raw:`$${r}${s}`,literal:"",opensPiece:o}),n+2+s.length}const Vn=/[A-Za-z_]/u,Fn=/\w/u,Hn=/[{(A-Za-z_]/u,y=/\$[A-Za-z_]\w*/y,Bn=/^_*[A-Z][A-Z0-9_]*$/u,qn=/^\$[A-Za-z_]\w*$/u,Wn=/^(["'])\$[A-Za-z_]\w*\1$/u;function Kn(e,n,t){y.lastIndex=n;const r=y.exec(e)?.[0];return r===void 0?-1:(t.literal===""&&Bn.test(r.slice(1))?t.raw+=r:C(t,r),n+r.length)}function jn(e,n){if(!Vn.test(e[n]??""))return 0;let t=n+1;for(;t<e.length&&Fn.test(e[t]);)t+=1;e[t]===":"&&(t+=1);const r=e[t];return r==="-"||r==="="||r==="+"?t+1-n:0}function Qn(e,n){const t=e.pop(),r=e.at(-1);r.raw+=`${t.raw}${n}`,t.keep&&(r.literal+=t.literal)}const Ee=/[^$<"'\\})]+/y,Gn='$`"\\\n';function Yn(e,n){return e===`
5
- `?"":n==='"'&&!Gn.includes(e)?`\\${e}`:e}function Xn(e,n,t){const r=e[n],s=t.quote;if(s==='"'&&r==="$"&&Hn.test(e[n+1]??""))return-1;let i=1,o=r;if(r==="\\"&&s!=="'"&&n+1<e.length)i=2,o=Yn(e[n+1],s);else if(s===void 0){if(r!=='"'&&r!=="'")return-1;t.quote=r,o=""}else r===s&&(t.quote=void 0,o="");return t.raw+=e.slice(n,n+i),t.keep&&(t.literal+=o),n+i}function Jn(e,n,t,r,s){const i=t.at(-1);Ee.lastIndex=n;const o=Ee.exec(e)?.[0];if(o!==void 0)return C(i,o),n+o.length;if(t.length>1){const p=Xn(e,n,i);if(p!==-1)return p}else if(r&&et(e[n],i))return n+1;const a=vn(e,n,t);if(a!==-1)return a;const u=t.at(-1),c=e[n],l=s&&c==="$"?Kn(e,n,u):-1;if(l!==-1)return l;if(t.length>1&&c===u.close)return Qn(t,c),n+1;const f=c==="<"?Un(e,n):-1;return f!==-1?(u.raw+=e.slice(n,f+1),f+1):(C(u,c),n+1)}function et(e,n){return e!=='"'&&e!=="'"?!1:n.quote===void 0?(n.quote=e,n.pieceStart=n.literal.length,!0):e!==n.quote?!1:(n.quote=void 0,!0)}function pe(e,n,t){if(t&&(qn.test(e)||n&&Wn.test(e)))return"";const r={close:"}",keep:!0,raw:"",literal:""},s=[r];for(let i=0;i<e.length;)i=Jn(e,i,s,n,t);for(let i=s.length-1;i>0;i-=1){const o=s[i],a=s[i-1];a.raw+=o.raw,n&&i===1&&o.opensPiece===!0||(a.literal+=o.raw)}return r.literal}function _e(e,n=!0){return pe(e,!1,n)}function nt(e,n=!0){return pe(e,!0,n)}function N(e,n){const t=e.minimumLiteralLength===void 0?n[1]:de(n);if(e.minimumLiteralLength!==void 0&&t.length<e.minimumLiteralLength||e.literalValue&&mn.test(n[1])&&!Tn(e.literalValue,t,hn(n))||e.rejectValue?.test(t)===!0||e.rejectStatementReference&&Dn(e.rejectStatementReference,n,t))return!1;if(e.minimumEntropy===void 0)return!0;const r=[...t],s=new Map;for(const o of r)s.set(o,(s.get(o)??0)+1);let i=0;for(const o of s.values()){const a=o/r.length;i-=a*Math.log2(a)}return i>=e.minimumEntropy}const ot={leadingReferencesEnd:fe};export{Ne as PRIVATE_HOME_PATH_PATTERN,tt as SECRET_RULES,ot as _testOnly,N as acceptsSecretMatch,it as acceptsStructuredValue,_e as expandRuntimeReferences,Ce as findPrivateHomePathMatches,rt as findSecretRuleMatches,nt as literalAfterReferences,st as structuredKeyShape};
1
+ const R=`[^\\s/\\\\<>"'\\x60()\\[\\]{},;?=:#*]+`,d="[/\\\\]+",xe="[\\p{L}\\p{N}._@-]+",h=xe+"(?:"+d+R+")*",m="(?:(?:home|users)"+d+h+"|root"+d+h+")",Ie="[/\\\\]"+m,Ce="[/\\\\]{2,}"+m,be="/?[a-z]:"+d+"users"+d+h,ke=R+"(?: +"+R+")*",x="(?:"+ke+d+")?users"+d+h,ze="[/\\\\]{2,}"+R+d+x,Me="(?:[a-z]:|volume\\{[a-f0-9-]+\\}|"+R+")",U="[/\\\\]{2}[?.]"+d+"(?:unc"+d+R+d+x+"|"+Me+d+"users"+d+h+")",De="file:(?:"+U+"|(?:[/\\\\](?![/\\\\])|[/\\\\]{3,}|[/\\\\]{2}localhost"+d+")(?:"+m+"|[a-z]:"+d+"users"+d+h+")|[/\\\\]{2}(?:[a-z]:"+d+"users"+d+h+"|"+R+d+"(?:"+m+"|"+x+")))",Pe=new RegExp("(?:^|[^\\p{L}\\p{N}_./\\\\~])(?:"+Ie+"|"+be+"|"+De+")|(?:^|[^\\p{L}\\p{N}_:./\\\\~])(?:"+Ce+"|"+ze+"|"+U+")","giu"),v=4,Ze=/%[a-f0-9]{2}|\\(?:u[a-f0-9]{4}|x[a-f0-9]{2}|\/)/iu,Ue=new TextDecoder("utf-8");function ve(e){return e.replace(/(?:%[a-f0-9]{2})+/giu,n=>Ue.decode(Uint8Array.from(n.matchAll(/%([a-f0-9]{2})/giu),t=>Number.parseInt(t[1],16)))).replace(/%(?![a-f0-9]{2})[a-z0-9]{0,2}/giu,"\uFFFD")}function Ve(e){return e.replace(/\\+(?:u([a-f0-9]{4})|x([a-f0-9]{2})|(\/))?/giu,(n,t,r,s)=>{const i=t??r;return i===void 0?s??n:String.fromCharCode(Number.parseInt(i,16))})}function Fe(e){return e.normalize("NFKC").replace(/[\p{Bidi_Control}\u200b-\u200f\u2060-\u206f\ufeff]/gu,"").replace(/[\u2215\u2044]/gu,"/").replace(/[\u043e\u041e]/gu,"o").replace(/[\u0455\u0405]/gu,"s")}function Be(e,n){for(const[t,r]of[["percent_decode",ve],["json_unescape",Ve],["unicode_fold",Fe]]){const s=r(e);s!==e&&!n.includes(t)&&n.push(t),e=s}return e}function*He(e,n,t){let r=e;const s=[];for(let i=0;i<v;i+=1){const u=r;if(r=Be(r,s),!t){n.lastIndex=0;for(const o of r.matchAll(n))t=!0,yield{index:0,normalizations:[...s]}}if(r===u)break;i===v-1&&Ze.test(r)&&(yield{index:0,normalizations:[...s],normalization_incomplete:!0})}}function*We(e,n){let t=0;for(const r of e.split(`
2
+ `)){n.lastIndex=0;let s=!1;for(const i of r.matchAll(n))s=!0,yield{index:t+i.index};for(const i of He(r,n,s))yield{...i,index:t};t+=r.length+1}}const V="password|passphrase",N=4,g=4096,$=e=>`${e}+(?!${e})`,F=String.raw`'[^'\r\n]*'|"[^"\\\r\n]*(?:\\.[^"\\\r\n]*){0,${g}}"`,qe=String.raw`\$\{(?:${$(String.raw`[^{}$'"\\\r\n]`)}|\\[^\r\n]|${F}|\$(?!\{)|\$\{[^{}\r\n]*\}){0,${g}}\}`+String.raw`|\$\((?:${$(String.raw`[^()$'"\\\r\n]`)}|\\[^\r\n]|${F}|\$(?!\()|\$\([^()\r\n]*\)){0,${g}}\)`,B=String.raw`${qe}|<[^<>\r\n]*>|${$(String.raw`[A-Za-z0-9!@#%^&*._+\-=]`)}|\$(?![{(])`,Ge=String.raw`"[^"]*"|'[^']*'`,H=String.raw`(?:"[^"\s]*"|'[^'\s]*')(?:${B}){0,${g}}`,W=new RegExp(String.raw`(?!config\.auth\.password\s*(?:\|\|\s*(?:''|"")|\?\s*unescape\(encodeURIComponent\(config\.auth\.password\)\)\s*:\s*(?:''|""))(?=[ \t]*(?:\/\*(?:[^*]|\*(?!\/))*\*\/[ \t]*)*(?:;|$|\/\/[^\r\n\u2028\u2029]*(?:\r\n)?$)))`+`((?:${B}){1,${g}}(?:${H}){0,${N}}|(?:${H}){1,${N}}|${Ge})`),Ke=8,q="token|secret|password|passwd|api[_-]?key",I="(?<![a-z0-9_]|[a-z0-9_]-)(?:(?:[a-z0-9]+_)+(?:password|passphrase)|(?:[a-z0-9]+[_-])*(?:secret|token|(?:api|secret|private|access)[_-]?key|client[_-]?secret|passwd|pwd))",p=4096,G=String.raw`"(?=[^"\s]{8}[^"\s]*")|'(?=[^'\s]{8}[^'\s]*')|(?!["'])`,K=String.raw`(?![<[$/]|~\/|\.\.?\/|[A-Za-z][\w+.-]*:\/\/|%[A-Za-z_]\w*%(?=$|[\s"',;)}\]<>&|\\])|[A-Za-z]:[\\/]|(?<=")(?:(?:[A-Za-z_]\w*\.){1,${p}}[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+){0,${p}}|(?:[\w.-]+\/){1,${p}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})"|(?<=')(?:(?:[A-Za-z_]\w*\.){1,${p}}[A-Za-z_]\w*|[A-Za-z]+(?:-[A-Za-z]+){0,${p}}|(?:[\w.-]+\/){1,${p}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4})'|(?<!["'])[A-Za-z]+(?:-[A-Za-z]+){0,${p}}(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[A-Za-z_]\w*\.){1,${p}}[A-Za-z_]\w*(?![\w!@#$%^&*.+\-=/~])|(?<!["'])(?:[\w.-]+\/){1,${p}}[\w.-]+\.[A-Za-z][A-Za-z0-9]{0,4}(?=[\s,;)}\]]|$)|(?<!["'])[\w$.]+\()(?:(?<=")[^\s"]{8}[^\s"]*|(?<=')[^\s']{8}[^\s']*|(?<==)[A-Za-z0-9!@#$%^&*._+\-=/~?:|]{8,}|(?<!["'=])[A-Za-z0-9!@#$%^&*._+\-=/~]{8,})`,C=new RegExp(`(?:${G})(${K})`,"iy"),Qe=8,je=String.raw`[A-Za-z0-9!@#%^*._+\-=/~]`,Q=String.raw`&(?!&)`,Ye=64,j=String.raw`'[^'\s]*'|"[^"\\\s]*(?:\\\S[^"\\\s]*){0,${g}}"`,Y=String.raw`\$\{(?:${$(String.raw`[^{}$'"\\\s]`)}|\\\S|${j}|\$(?!\{)|\$\{[^{}\s]*\}){0,${g}}\}`+String.raw`|\$\((?:${$(String.raw`[^()$'"\\\s]`)}|\\\S|${j}|\$(?!\()|\$\([^()\s]*\)){0,${g}}\)`+String.raw`|<[^<>\s]*>|\$[A-Za-z_]\w*(?!\w)`,X=e=>String.raw`${Y}|${$(e)}|${Q}|\$(?![{(A-Za-z_])`,J=e=>String.raw`(?:"[^"\s]*"|'[^'\s]*')(?:${X(e)}){0,${g}}`,Xe=e=>String.raw`(?:(?:${e}|${Q}){1,${Ye}}(?=[$<]))?(?:${Y})`+String.raw`(?:${X(e)}){0,${g}}(?:${J(e)}){0,${N}}`,Je=e=>String.raw`(?:${J(e)}){1,${N}}`,ee=e=>String.raw`(?<!["'])(?:${e(je)})`,ne=String.raw`(?:[\w@#~]|!(?![.+\-*/%=^!(]))`,en=String.raw`(?=(?:"[^"\s]*"|'[^'\s]*')[$<"']`+String.raw`|"(?=[^"\s]*[$<])[^"\s]*"${ne}|'(?=[^'\s]*[$<])[^'\s]*'${ne})`,nn=String.raw`(?<=")(?=[^"\s]*[$<])[^"\s]+|(?<=')(?=[^'\s]*[$<])[^'\s]+`,te=new RegExp(`(?:${en}|${G})((?=["'])(?:${ee(Je)})|${nn}|${ee(Xe)}|${K})`),re=/["']?([A-Za-z0-9+/=_-]{24,})/,zt=[{name:"private-key",mutationRule:"private_key",category:"credential",regex:/-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----/g},{name:"github-token",mutationRule:"github_token",category:"credential",regex:/\b(?:gh[opsru]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/g},{name:"npm-token",mutationRule:"npm_token",category:"credential",regex:/\bnpm_[A-Za-z0-9]{20,}\b/g},{name:"aws-access-key",mutationRule:"aws_access_key",category:"credential",regex:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g},{name:"google-api-key",mutationRule:"google_api_key",category:"credential",regex:/\bAIza[0-9A-Za-z_-]{35}\b/g},{name:"slack-token",mutationRule:"slack_token",category:"credential",regex:/\bxox[baprs]-[A-Za-z0-9-]{10,}\b/g},{name:"anthropic-api-key",mutationRule:"anthropic_api_key",category:"credential",regex:/\bsk-ant-[A-Za-z0-9_-]{20,}\b/g},{name:"openai-api-key",mutationRule:"openai_api_key",category:"credential",regex:/\bsk-(?!ant-)[A-Za-z0-9_-]{20,}\b/g},{name:"gitlab-token",mutationRule:"gitlab_token",category:"credential",regex:/\bglpat-[A-Za-z0-9_.-]{20,}\b/g},{name:"jwt-like-token",mutationRule:"jwt_like_token",category:"credential",regex:/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g},{name:"npm-auth-token-assignment",mutationRule:"npm_auth_token_assignment",category:"credential",regex:/_authToken\s*=\s*\S+/g},{name:"sentry-user-token",mutationRule:"sentry_user_token",category:"credential",regex:/\bsntryu_[A-Za-z0-9]{20,}\b/g},{name:"sentry-org-token",mutationRule:"sentry_org_token",category:"credential",regex:/\bsntrys_[A-Za-z0-9_-]{20,}\b/g},{name:"private-ip",mutationRule:"private_ip",category:"network",regex:/\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"private-ssh-target",mutationRule:"private_ssh_target",category:"network",regex:/\b(?:ssh|scp|rsync)\s+[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g},{name:"sshpass-inline-password",mutationRule:"sshpass_inline_password",category:"credential",regex:/\bsshpass\s+-p\s+["'][^"']{6,}["']/g},{name:"password-assignment",mutationRule:"password_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${V})\s*[:=]\s*`+W.source,"gi"),structured:{keys:V,value:W.source,element:!0},minimumLiteralLength:Ke},{name:"absolute-home-path",mutationRule:"absolute_home_path",category:"path",regex:Pe,excludeFiles:/^(?:tests\/|examples\/)/},{name:"user-at-private-host",mutationRule:"user_at_private_host",category:"network",regex:/(?<![A-Za-z0-9._-])[A-Za-z0-9._-]+@(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g,excludeFiles:/^(?:tests\/|examples\/)/},{name:"high-entropy-assignment",mutationRule:"high_entropy_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${q})\s*[:=]\s*`+re.source,"gi"),structured:{keys:q,value:re.source},mutationOnlyReason:"Generic assignments in source code are not credentials; preserve the existing mutation heuristic without treating source identifiers as secrets.",minimumEntropy:3.5},{name:"credential-key-assignment",mutationRule:"credential_key_assignment",category:"credential",regex:new RegExp(String.raw`\b(?:${I})\s*[:=]\s*`+te.source,"gi"),structured:{keys:I,value:te.source,element:!0,elementValue:!0},mutationOnlyReason:"Key-named assignments in source code and test fixtures are identifiers and synthetic data; repository scans keep the token-format rules, which recognize real credentials there.",minimumEntropy:3,minimumLiteralLength:Qe,literalValue:C,baseline:{regex:new RegExp(String.raw`\b(?:${I})\s*[:=]\s*`+C.source,"gi"),value:C.source},rejectValue:/^(?:[\w.-]+\/)*id_(?:rsa|dsa|ecdsa|ed25519)(?:_sk)?(?:\.pub)?$/u,rejectStatementReference:/^[A-Z]+(?:_[A-Z]+)+$/u}];function*Mt(e,n){if(e.mutationRule==="absolute_home_path"){yield*We(n,e.regex);return}for(const t of ie(e))yield*cn(t,n),t.structured&&(yield*gt(t,t.structured,n))}const se=new WeakMap;function ie(e){const n=e.baseline;if(n===void 0)return[e];let t=se.get(e);return t===void 0&&(t={...e,regex:n.regex,minimumLiteralLength:void 0,literalValue:void 0,baseline:void 0},e.structured&&(t.structured={...e.structured,value:n.value}),se.set(e,t)),[e,t]}function tn(e,n){const t=e[n-1]==="#"||e[n-1]==="!"?n-1:n;return e[t-1]==="{"&&e[t-2]==="$"}const b=new WeakSet,ue=new WeakMap,rn=4096;function sn(e,n,t){const r=[],s=[],i=n+t.length;return oe(e,n,i,s,r),oe(e,i,Math.min(e.length,i+rn),s),r}function oe(e,n,t,r,s){for(let i=n;i<t&&(s!==void 0||r.length>0);i+=1){const u=r.at(-1);if(e[i]==="$"&&(e[i+1]==="{"||e[i+1]==="(")&&u?.quoted!=="'"){const o={open:i,close:t,command:e[i+1]==="(",quoted:[]};s?.push(o),r.push({span:o,closer:e[i+1]==="{"?"}":")"}),i+=1}else u!==void 0&&(i=un(e,i,r))}}function un(e,n,t){const r=t.at(-1),s=e[n];return s==="\\"&&r.quoted!=="'"?n+1:(r.quoted!==void 0?s===r.quoted&&(r.span.quoted.push([r.quoteStart,n]),r.quoted=void 0):s==="'"||s==='"'?(r.quoted=s,r.quoteStart=n):s===r.closer&&(t.pop().span.close=n),n)}function on(e){const n=[];let t=0;return r=>{for(;t<e.length&&e[t].open<r;t+=1){for(;n.length>0&&n.at(-1).close<e[t].open;)n.pop();n.push(e[t])}for(;n.length>0&&n.at(-1).close<r;)n.pop();return n.at(-1)}}function an(e,n){let t=0,r=e.quoted.length-1;for(;t<=r;){const s=t+r>>1,[i,u]=e.quoted[s];if(n<i)r=s-1;else if(n>u)t=s+1;else return!0}return!1}const ae=/\$[({A-Za-z_]|</u,k=new WeakMap;function*cn(e,n){const t=new RegExp(e.regex),r=ln(e);let s,i;for(let u=t.exec(n);u!==null;u=t.exec(n)){let o=u;if(e.minimumLiteralLength!==void 0){i??=bn(n);const a=u.index+u[0].length,c=a-u[1].length,l=Bn(i,c,a);l>c&&(l<a&&(o=Qn(u,l),t.lastIndex=l),k.set(o,l))}L(e,o)?yield{index:o.index}:r!==void 0&&ae.test(o[1])&&(s??=new RegExp(t),yield*dn(e,s,n,o,r==="deep"))}}function ln(e){return e.minimumLiteralLength===void 0?void 0:e.minimumEntropy===void 0&&e.literalValue===void 0&&e.rejectValue===void 0?"deep":"shallow"}function*dn(e,n,t,r,s){const i=r.index+r[0].length;n.lastIndex=i-r[1].length;let u;for(let o=n.exec(t);o!==null&&o.index<i;o=n.exec(t)){if(tn(t,o.index)){n.lastIndex=o.index+1;continue}u??=on(sn(t,i-r[1].length,r[1]));const a=u(o.index);a!==void 0&&(ue.set(o,a.close),a.command&&!an(a,o.index)&&b.add(o)),L(e,o)?yield{index:o.index}:s&&ae.test(o[1])&&(n.lastIndex=o.index+o[0].length-o[1].length)}}const ce=new Map,y=/[\r\n\u2028\u2029]/u;function z(e){const n=`${e.keys}\0${e.value}\0${e.element===!0}`;let t=ce.get(n);return t||(t={key:new RegExp(String.raw`\b(?:${e.keys})(["']?)\s*[:=]\s*`,"gi"),value:new RegExp(e.value,"iyd"),...e.element?{element:{open:new RegExp(String.raw`<(?:${e.keys})(?:\s[^<>]*)?>`,"gi"),close:new RegExp(String.raw`<\/(?:${e.keys})\s*>`,"iy"),span:new RegExp(String.raw`<(?!\/?(?:${e.keys})\b)[^<>]*>`,"iy")}}:{}},ce.set(n,t)),t}function le(e,n){const t=e[n];for(let r=n+1;r<e.length;r+=1){const s=e[r];if(s==="\\")r+=1;else if(s===t)return{end:r+1,terminated:!0}}return{end:e.length,terminated:!1}}function fn(e,n){return le(e,n).end}function gn(e,n,t){return e.at(-1)==="}"?t:n}function pn(e,n,t,r=t){const s=[];let i=!1;for(let u=n;u<e.length;u+=1){const o=e[u];switch(o){case"[":case"{":s.push(o==="["?"]":"}"),i=o==="{";break;case"]":case"}":if(s.pop()!==o||s.length===0)return{found:!1,end:u+1};i=!1;break;case",":i=s.at(-1)==="}";break;case":":i=!1;break;case'"':case"'":if(!i&&gn(s,t,r)(u))return{found:!0,end:u};u=fn(e,u)-1;break;default:break}}return{found:!1,end:e.length}}const En=/\\(?:U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{2}|[0-7]{1,3}|[\s\S])/gu,_n={n:`
3
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"};function An(e,n){const t=e[0],r=e.slice(1,n?-1:void 0).replaceAll(En,u=>{const o=u[1];if((o==="u"||o==="x")&&u.length>2)return String.fromCharCode(Number.parseInt(u.slice(2),16));if(/^[0-7]$/u.test(o))return String.fromCharCode(Number.parseInt(u.slice(1),8));if(o==="U"&&u.length===10){const a=Number.parseInt(u.slice(2),16);return a<=1114111?String.fromCodePoint(a):"\uFFFD"}return _n[o]??o}),s=r.replaceAll(t,t==='"'?"'":'"').replaceAll(/[\r\n\u2028\u2029]/gu," "),i=n?t:"";return{reading:`${t}${s}${i}`,...de(`${t}${r}${i}`,n)}}function de(e,n){return{original:e,bodyStart:1,bodyEnd:e.length-(n?1:0)}}const Rn=64;function fe(e,n,t){const r=e[n-1];if(!t)return r!==void 0&&/[\p{L}\p{N}_.-]/u.test(r)?"prefixed":"exact";if(r===t)return"exact";const s=Math.max(0,n-Rn);for(let i=n-1;i>=s;i-=1){const u=e[i];if(u===t)return"prefixed";if(u===`
4
+ `||u==="\r"||u==='"'||u==="'")return"malformed"}return"malformed"}function ge(e,n,t,r=!1){const s=(o,a,c)=>{n.lastIndex=a;const l=n.exec(o);if(l===null||y.test(l[0]))return null;const f=l.indices?.[1];return c!==void 0&&f!==void 0&&(l[1]=c.original.slice(Math.max(f[0],c.bodyStart),Math.min(f[1],c.bodyEnd)),O.add(l)),L(e,l)?l:null},i=o=>{if(t[o]!=='"'&&t[o]!=="'")return;const{end:a,terminated:c}=le(t,o),l=t.slice(o,a);if(!r&&!l.includes("\\"))return;if(y.test(l))return[];const f=An(l,c);return(t[o]==="'"?[f,{reading:l,...de(l,c)}]:[f]).map(A=>s(A.reading,0,A)).filter(A=>A!==null)},u=o=>{const a=i(o);if(a!==void 0)return a;const c=s(t,o);return c===null?[]:[c]};return{direct:o=>s(t,o)!==null,escaped:o=>(i(o)?.length??0)>0,accepts:o=>a=>u(a).some(c=>!(o&&/\s/u.test(hn(e,c))))}}function hn(e,n){return e.minimumLiteralLength===void 0?n[0]:pe(n)}const O=new WeakSet;function pe(e){const n=b.has(e)&&!_(w(e))?yn(e[1]):void 0,t=n??e[1];if(n===void 0&&wn(e,t))return"";const r=n!==void 0||Tn(e);return O.has(e)||_(w(e))?Le(t,r):kt(t,r)}const $n=/^%[A-Za-z_]\w*%$/u,Sn=/^(["']?)%[A-Za-z_]\w*%\1$/u;function wn(e,n){if(!Sn.test(n))return!1;if(O.has(e))return!0;const t=e.input,r=e.index+e[0].length;if(k.get(e)===r)return!0;let s=r;for(;s<t.length&&(t[s]===" "||t[s]===" ");)s+=1;return s===t.length||y.test(t[s])?!0:_(n[0])&&/[,;)}\]]/u.test(t[s])&&Nn(e)}const mn=/(?:^|[\s{,[])(["'])[^"'\r\n]{1,256}\1\s*[:=]\s*$/u;function Nn(e){if(Ee(e,!1)!==void 0)return!0;const n=e.input,t=e.index+e[0].length-e[1].length,r=n.slice(Math.max(0,t-_e),t);return mn.test(r)||/:[ \t]*$/u.test(r)}function yn(e){for(let n=0;n<e.length;n+=1){const t=e[n];if(t==="'"||t==='"')n=ye(e,n);else if(t==="$"&&(e[n+1]==="{"||e[n+1]==="("))n=Math.max(n,D(e,n)-1);else if(/[|&;<>]/u.test(t))return e.slice(0,n)}}const On=/^[;,)}\]]{0,64}/u;function Tn(e){const n=e.input,t=e.index+e[0].length,r=_(w(e))&&_(n[t])?t+1:_(e[0].at(-1))?t:-1,s=r===-1?t:r,i=On.exec(n.slice(s,s+he))[0].length,u=s+i;if(u===n.length||/\s/u.test(n[u])||Ln(e,s,t))return!0;if(r===-1||i===0)return!1;const o=Ee(e,r===t+1),a=n.slice(u,u+40),c=/[}\]]/u.test(n.slice(s,u));return o!==void 0&&(Ae.test(a)||(o==="element"||c)&&Re.test(a))}function Ln(e,n,t){return ue.get(e)===n||b.has(e)&&/[|&;<>]/u.test(e.input[n])?!0:k.get(e)===t}function Ee(e,n){const t=e.input,r=e.index+e[0].length-e[1].length-(n?1:0),s=t.slice(Math.max(0,r-_e),r);return In.test(s)?"element":xn.test(s)?"key":void 0}const _e=512,xn=/[{,]\s*(["'])[^"'\r\n]{1,256}\1\s*[:=]\s*$/u,In=/[[,]\s*$/u,Ae=/^(?:["'`]|[{[](?:[\s"'`{[\]}]|$|(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)[\s,\]}]))/u,Re=/^(?:-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?|true|false|null)[\s,\]}]/u,he=64,S=0,M=1,Cn=2,$e=/[\p{L}\p{N}_]/u;function Se(e){return e===10||e===13}function bn(e){return{content:e,index:0,state:S,opener:-1,escapes:!0}}function we(e){const{content:n}=e,t=e.index,r=n.charCodeAt(t);if(e.index=t+1,Se(r))return e.state=S,-1;if(r===92)return e.escapes&&t+1<n.length&&!Se(n.charCodeAt(t+1))&&(e.index=t+2),-1;if(r!==34&&r!==39)return-1;const s=r===34?M:Cn;return e.state===s?(e.state=S,t):(e.state===S&&!(t>0&&$e.test(n[t-1]))&&(e.state=s,e.opener=t,e.escapes=s===M||Mn(n,t)),-1)}function kn(e,n){for(;e.index<n;)we(e)}function zn(e,n){const t=me(e,n),r=e[t];return{inContainer:r!==void 0&&/[[{,:]/u.test(r),attribute:r==="="&&Pn(e,t)}}function me(e,n){let t=n-1;for(;t>=0&&/\s/u.test(e[t]);)t-=1;return t}function Mn(e,n){return/[[{,:]/u.test(e.charAt(me(e,n)))}const Dn=8192;function Pn(e,n){const t=Math.max(0,n-Dn);for(let r=n-1;r>=t;r-=1){const s=e[r];if(s===">")return!1;if(s==="<")return/[A-Za-z]/u.test(e.charAt(r+1));if(s==='"'||s==="'"){const i=e.lastIndexOf(s,r-1);if(i<t)return!1;r=i}}return!1}const Zn=/[,:;)}\]]/u;function Un(e,n,t){let r=n+1;if(vn(e,r,t))return!0;const s=Math.min(e.length,r+he);for(;r<s&&Zn.test(e[r]);)r+=1;if(r===n+1)return!1;for(;r<e.length&&(e[r]===" "||e[r]===" ");)r+=1;if(r===e.length||y.test(e[r]))return!0;if(!t.inContainer)return!1;const i=e.slice(r,r+Vn);return Ae.test(i)||Re.test(i)||Fn.test(i)}function vn(e,n,t){return n===e.length||/\s/u.test(e[n])?!0:t.attribute&&(e[n]===">"||e.startsWith("/>",n))}const Vn=512,Fn=/^[A-Za-z_][\w.-]{0,480}:(?:\s|$)/u;function Bn(e,n,t){kn(e,n);const r=e.state;if(r===S)return-1;const{content:s}=e,i=e.opener,u=r===M?"'":'"',o={open:!1,placeholder:!1,references:[]},a=Math.min(t,s.length-1);for(;e.index<=a;){qn(o,s,e.index,u);const c=we(e);if(c!==-1){const l=o.open||o.placeholder||o.references.length>0;return Kn(s,c,t,l)&&Un(s,c,zn(s,i))?c:-1}if(e.state!==r)return-1}return-1}const Hn=/^<[^<>\s]{0,254}>/u,Wn=256;function qn(e,n,t,r){const s=n[t];e.open?s===r&&(e.open=!1):e.placeholder?s===">"&&(e.placeholder=!1):s==="$"&&(n[t+1]==="{"||n[t+1]==="(")?e.references.push(n[t+1]==="{"?"}":")"):s===e.references.at(-1)?e.references.pop():s==="<"&&Hn.test(n.slice(t,t+Wn))?e.placeholder=!0:s===r&&(e.open=Gn(n,t))}function Gn(e,n){return e[n]==='"'||!$e.test(e[n-1])}function Kn(e,n,t,r){return n>=t||!(r||/\s/u.test(e.charAt(n+1)))}function Qn(e,n){const t=e.index+e[0].length-e[1].length,r=[e.input.slice(e.index,n),e.input.slice(t,n)];return Object.assign(r,{index:e.index,input:e.input,groups:void 0})}const jn=/^\s{0,16}\(/u,Yn=/(?<![=!<>])=[ \t]{0,16}$/u;function w(e){return e.input[e.index+e[0].length-e[1].length-1]}function _(e){return e==='"'||e==="'"}const Xn=/[$<"']/u;function Jn(e){if(O.has(e)||_(w(e))||!/^[$<]/u.test(e[1]))return!1;const n=e.index+e[0].length,t=n-e[1].length,r=e.input.slice(n,n+18);if(e[1][0]==="<"&&(it(e[1])||Yn.test(e.input.slice(Math.max(0,t-18),t))||ot.test(r)))return!0;const s=Ne(e[1]),i=e[1][s]==="!"?e[1][s+1]:e[1][s];return ut.test(i??"")||jn.test(r)}function Ne(e){let n=0;for(let t=D(e,n);t!==-1;t=D(e,n))n=t;return n}function D(e,n){const t=e[n];if(t==="<")return et(e,n);if(t!=="$")return-1;const r=e[n+1];if(r==="{"||r==="(")return nt(e,n+1,r);T.lastIndex=n;const s=T.exec(e)?.[0];return s===void 0?-1:n+s.length}function et(e,n){const t=e.indexOf(">",n+1),r=e.indexOf("<",n+1);return t!==-1&&(r===-1||t<r)?t+1:-1}function nt(e,n,t){const r=t==="{"?"}":")";let s=0;for(let i=n;i<e.length;i+=1){const u=e[i];if(u==="\\")i+=1;else if(u==="'"||u==='"')i=ye(e,i);else if(u===t)s+=1;else if(u===r&&--s===0)return i+1}return-1}function ye(e,n){const t=e[n];for(let r=n+1;r<e.length;r+=1){if(e[r]===t)return r;t==='"'&&e[r]==="\\"&&(r+=1)}return e.length}const tt=/^[\w$.[\]|&,{}:;?]+$/u,rt=/^(?:"[^"]*"|'[^']*'|-?\d+(?:\.\d+)?)(?:\|(?:"[^"]*"|'[^']*'|-?\d+(?:\.\d+)?|[A-Za-z_$][\w$.]*))*$/u,st=/\b(?:string|number|boolean|bigint|symbol|any|unknown|object|never|void|undefined|null)\b/u;function it(e){const n=e.slice(1,e.indexOf(">"));return rt.test(n)?!0:tt.test(n)?st.test(n)||/[.|&[{]/u.test(n)||/^[A-Z][\w$]*$/u.test(n)&&(n.length===1||/[a-z]/u.test(n)):!1}const ut=/[.+\-*/%=^&]/u,ot=/^\s{0,16}(?:\?\.|\?\?|\|\||&&|[([])/u;function at(e,n,t){if(t)return!1;const r=n.replaceAll('"',"'");return e.lastIndex=0,e.exec(`"${r}"`)?.[1]===r}function Dt(e,n){if(!e.structured)return;const t=`${JSON.stringify(n)}:`,r=z(e.structured).key;r.lastIndex=0;for(let s=r.exec(t);s;s=r.exec(t)){if(s.index+s[0].length!==t.length)continue;const i=fe(t,s.index,s[1]);if(i!=="malformed")return i}}function Pt(e,n,t){if(!e.structured)return!1;const r=JSON.stringify(n).replaceAll("\u2028","\\u2028").replaceAll("\u2029","\\u2029");return ie(e).some(s=>ge(s,z(s.structured).value,r,!0).accepts(t)(0))}function*ct(e,n,t){const r=new RegExp(e.open);for(let s=r.exec(n);s;s=r.exec(n)){const i=s.index+s[0].length,u=lt(e,n,i);if(u===void 0){r.lastIndex=s.index+1;continue}t(n.slice(i,u.start).trim())&&(yield{index:s.index}),r.lastIndex=u.end}}function lt(e,n,t){for(let r=n.indexOf("<",t);r!==-1;){e.close.lastIndex=r;const s=e.close.exec(n);if(s!==null)return{start:r,end:r+s[0].length};e.span.lastIndex=r;const i=e.span.exec(n);if(i===null)return;r=n.indexOf("<",r+i[0].length)}}function dt(e,n,t){return n<e.exact||t&&n<e.compact}function ft(e,n,t,r){return(t||e.escaped(r)&&!e.direct(r))&&n(r)}function*gt(e,n,t){const r=z(n),s=ge(e,r.value,t),i=new RegExp(r.key),u={exact:0,compact:0};for(let o=i.exec(t);o;o=i.exec(t)){const a=o[1],c=fe(t,o.index,a);if(c==="malformed")continue;const l=c==="prefixed",f=s.accepts(l),E=o.index+o[0].length,A=t[E];if(A==="["||A==="{"){if(dt(u,E,l))continue;const Z=pn(t,E,f,s.accepts(!0));u[l?"compact":"exact"]=Z.end,Z.found&&(yield{index:o.index})}else ft(s,f,a,E)&&(yield{index:o.index})}r.element&&(yield*ct(r.element,t,Et(e,n,r)))}const pt=8;function Et(e,n,t){if(!n.elementValue){const r=e.minimumLiteralLength??pt;return s=>!$n.test(s.trim())&&Le(s).length>=r}return r=>{const s=r.replaceAll('"',"'");t.value.lastIndex=0;const i=t.value.exec(`"${s}"`);return i===null||i[1]!==s?!1:(i[1]=r,L(e,i))}}function _t(e,n,t){const r=n.index+n[0].length;return/^[ \t]*;/u.test(n.input.slice(r,r+64))&&!_(w(n))&&e.test(t)}function At(e,n){for(let t=n+1;t<e.length;t+=1){if(e[t]===">")return t;if(e[t]==="<")return-1}return-1}function P(e,n){e.raw+=n,e.literal+=n}function Rt(e,n,t){const r=e[n+1];if(e[n]!=="$"||r!=="{"&&r!=="(")return-1;const s=r==="{"?e.slice(n+2,n+2+Ot(e,n+2)):"",i=t[0],u=t.length===1&&i.quote!==void 0&&i.literal.length===i.pieceStart;return t.push({close:r==="{"?"}":")",keep:s!=="",raw:`$${r}${s}`,literal:"",opensPiece:u}),n+2+s.length}const ht=/[A-Za-z_]/u,$t=/\w/u,St=/[{(A-Za-z_]/u,T=/\$[A-Za-z_]\w*/y,wt=/^_*[A-Z][A-Z0-9_]*$/u,mt=/^\$[A-Za-z_]\w*$/u,Nt=/^(["'])\$[A-Za-z_]\w*\1$/u;function yt(e,n,t){T.lastIndex=n;const r=T.exec(e)?.[0];return r===void 0?-1:(t.literal===""&&wt.test(r.slice(1))?t.raw+=r:P(t,r),n+r.length)}function Ot(e,n){if(!ht.test(e[n]??""))return 0;let t=n+1;for(;t<e.length&&$t.test(e[t]);)t+=1;e[t]===":"&&(t+=1);const r=e[t];return r==="-"||r==="="||r==="+"?t+1-n:0}function Tt(e,n){const t=e.pop(),r=e.at(-1);r.raw+=`${t.raw}${n}`,t.keep&&(r.literal+=t.literal)}const Oe=/[^$<"'\\})]+/y,Lt='$`"\\\n';function xt(e,n){return e===`
5
+ `?"":n==='"'&&!Lt.includes(e)?`\\${e}`:e}function It(e,n,t){const r=e[n],s=t.quote;if(s==='"'&&r==="$"&&St.test(e[n+1]??""))return-1;let i=1,u=r;if(r==="\\"&&s!=="'"&&n+1<e.length)i=2,u=xt(e[n+1],s);else if(s===void 0){if(r!=='"'&&r!=="'")return-1;t.quote=r,u=""}else r===s&&(t.quote=void 0,u="");return t.raw+=e.slice(n,n+i),t.keep&&(t.literal+=u),n+i}function Ct(e,n,t,r,s){const i=t.at(-1);Oe.lastIndex=n;const u=Oe.exec(e)?.[0];if(u!==void 0)return P(i,u),n+u.length;if(t.length>1){const E=It(e,n,i);if(E!==-1)return E}else if(r&&bt(e[n],i))return n+1;const o=Rt(e,n,t);if(o!==-1)return o;const a=t.at(-1),c=e[n],l=s&&c==="$"?yt(e,n,a):-1;if(l!==-1)return l;if(t.length>1&&c===a.close)return Tt(t,c),n+1;const f=c==="<"?At(e,n):-1;return f!==-1?(a.raw+=e.slice(n,f+1),f+1):(P(a,c),n+1)}function bt(e,n){return e!=='"'&&e!=="'"?!1:n.quote===void 0?(n.quote=e,n.pieceStart=n.literal.length,!0):e!==n.quote?!1:(n.quote=void 0,!0)}function Te(e,n,t){if(t&&(mt.test(e)||n&&Nt.test(e)))return"";const r={close:"}",keep:!0,raw:"",literal:""},s=[r];for(let i=0;i<e.length;)i=Ct(e,i,s,n,t);for(let i=s.length-1;i>0;i-=1){const u=s[i],o=s[i-1];o.raw+=u.raw,n&&i===1&&u.opensPiece===!0||(o.literal+=u.raw)}return r.literal}function Le(e,n=!0){return Te(e,!1,n)}function kt(e,n=!0){return Te(e,!0,n)}function L(e,n){const t=e.minimumLiteralLength===void 0?n[1]:pe(n);if(e.minimumLiteralLength!==void 0&&t.length<e.minimumLiteralLength||e.literalValue&&Xn.test(n[1])&&!at(e.literalValue,t,Jn(n))||e.rejectValue?.test(t)===!0||e.rejectStatementReference&&_t(e.rejectStatementReference,n,t))return!1;if(e.minimumEntropy===void 0)return!0;const r=[...t],s=new Map;for(const u of r)s.set(u,(s.get(u)??0)+1);let i=0;for(const u of s.values()){const o=u/r.length;i-=o*Math.log2(o)}return i>=e.minimumEntropy}const Zt={leadingReferencesEnd:Ne};export{Pe as PRIVATE_HOME_PATH_PATTERN,zt as SECRET_RULES,Zt as _testOnly,L as acceptsSecretMatch,Pt as acceptsStructuredValue,Le as expandRuntimeReferences,We as findPrivateHomePathMatches,Mt as findSecretRuleMatches,kt as literalAfterReferences,Dt as structuredKeyShape};
6
6
  //# sourceMappingURL=secret-rules.js.map
@@ -57,9 +57,22 @@ export declare function redactOptionalIdentityCredentials<T>(value:T):T;
57
57
  export declare function runWithUrlCredentialInvocation<T>(argv:readonly string[],run:()=> T):T;
58
58
  /** Whether the running invocation carried any possible URL userinfo. */
59
59
  export declare function invocationCarriesUrlCredentials():boolean;
60
+ /**
61
+ * Authority text with every escaped quote of the opening's kind replaced by
62
+ * neutral characters (GH-1774): inside a URL opened by `'`, POSIX's escaped
63
+ * apostrophe (`'\\''`, or `'\\\\''` in JSON); inside one opened by `'` or `"`,
64
+ * a quote an odd run of backslashes escapes (`\\"`, cmd's caret form `\\^"`,
65
+ * or either as JSON encodes it). Their backslashes
66
+ * are then not read as a special scheme's path delimiter, nor their quotes
67
+ * as the closer. Positions are kept, so every index read from the result
68
+ * fits the original.
69
+ */
70
+ declare function neutralizeEscapedQuotes(text:string,closer:string|undefined):string;
60
71
  /**
61
72
  * Apply {@link redactUrlCredentialsInToken} to every whitespace-delimited word
62
- * of free text, after removing the running invocation's registered
63
- * fragments.
73
+ * of free text, after removing the running invocation's registered fragments
74
+ * and joining each URL userinfo that holds blanks into one word.
64
75
  */
65
- export declare function redactUrlCredentialsInText(text:string):string;
76
+ export declare function redactUrlCredentialsInText(text:string):string;
77
+ /** Test-only access to the position-keeping escape neutralization (GH-1774). */
78
+ export declare const urlCredentialsTestOnly:{neutralizeEscapedQuotes:typeof neutralizeEscapedQuotes;};export{};
@@ -1,2 +1,2 @@
1
- import{AsyncLocalStorage as x}from"node:async_hooks";import{quoteWindowsCommandArg as A}from"./command-line.js";import{EXIT_CODE as C}from"./constants.js";import{PmCliError as T}from"./errors.js";const p="[redacted]";function L(t,e){if(/[\t\n\r]/u.test(t)||!/(?:^|[^A-Za-z0-9+.-])(?:https?|wss?|ftp)$/iu.test(t.slice(0,e)))return!1;let n=e+1;for(;t[n]==="/"||t[n]==="\\";)n+=1;const r=t.indexOf("/",n)-n;if(r<0)return!1;const i=n+r;return!/[:@%]/u.test(t.slice(n,i))&&!/[:%]|[/\\][/\\]/u.test(t.slice(i))}function u(t){const e=Math.max(t.lastIndexOf("@"),t.toLowerCase().lastIndexOf("%40")),n=t.indexOf(":");if(e<0||n<0||n>e)return;let r=n+1;for(;r<e&&r<n+3&&(t[r]==="/"||t[r]==="\\");)r+=1;return r===e||L(t,n)?void 0:[r,e]}function m(t){const e=u(t);return e?`${t.slice(0,e[0])}${p}${t.slice(e[1])}`:t}function y(t){return m(t)}const I=["author","assignee","claim_principal"];function j(t){const e={...t};for(const n of I)typeof e[n]=="string"&&(e[n]=y(e[n]));return e}function E(t,e){if(!(typeof t!="string"||u(t.trim())===void 0))throw new T(`${e} must not carry URL credentials: an identity is a name, never a credential.`,C.USAGE,{code:"invalid_argument_value",field:e,required:`Set ${e} to a plain name such as agent-a, with no URL userinfo (no user, password or token before the host).`,nextSteps:[`Rerun with ${e} set to a plain name.`],url_credentials_rejected:{source:e}})}function G(t,e){return E(t,e),t}const O=[["comments","author"],["notes","author"],["learnings","author"],["dependencies","author"],["plan_decisions","author"],["plan_discoveries","author"],["plan_steps","owner"],["tests","provenance","author"],["tests","updated_by"]],U=4;function h(t,e,n=0){if(typeof t=="string"){E(t,e);return}if(!(n>=U||typeof t!="object"||t===null))for(const r of Object.values(t))h(r,e,n+1)}function N(t,e){let n=t;for(const r of e){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[r]}return n}function H(t){const e=t;for(const n of I)h(e[n],n);for(const[n,...r]of O){const i=e[n];Array.isArray(i)&&i.forEach((a,l)=>{h(N(a,r),`${n}[${l}].${r.join(".")}`)})}}function q(t){return typeof t=="string"?y(t):t}const d=6,$=65536,w={carried:!1,fragments:new Set,fragmentLength:d,shortSpellings:[]},g=new x;function S(t){const e=t.toLowerCase();if(e.length===t.length)return e;let n="";for(const r of t){const i=r.toLowerCase();n+=i.length===r.length?i:r}return n}function R(t){return[t,t.replaceAll(/(["\\$`])/gu,"\\$1"),A(`${t}@`).slice(1,-2),JSON.stringify(t).slice(1,-1)]}function D(t){const e=t.indexOf(":");return e>=0&&e<t.length-1?t.slice(e+1):t}function b(t){const e=new Set;let n=!1;for(const s of t){const c=u(s);if(c){n=!0;for(const _ of R(D(s.slice(c[0],c[1]))))e.add(S(_))}}const r=[...e],i=r.reduce((s,c)=>s+Math.max(0,c.length-d+1)+1,0),a=Math.max(1,Math.ceil(i/$)),l=Math.max(d,a),o=new Set,f=new Set;for(const s of r){if(s.length<l){(s.length>=d||/\s/u.test(s))&&f.add(s);continue}for(let c=0;c+l<=s.length;c+=a)o.add(s.slice(c,c+l));o.add(s.slice(-l))}return{carried:n,fragments:o,fragmentLength:l,shortSpellings:[...f]}}function M(t,e){const n=S(t),r=new Uint8Array(t.length);let i=!1;const a=e.fragmentLength;for(let o=0;o+a<=n.length;o+=1)e.fragments.has(n.slice(o,o+a))&&(r.fill(1,o,o+a),i=!0);for(const o of e.shortSpellings)for(let f=n.indexOf(o);f>=0;f=n.indexOf(o,f+1))r.fill(1,f,f+o.length),i=!0;if(!i)return t;let l="";for(let o=0;o<t.length;o+=1)r[o]?(o===0||!r[o-1])&&(l+=p):l+=t[o];return l}function V(t,e){return g.run(b(t),e)}function Y(){return(g.getStore()??w).carried}function X(t){const e=g.getStore()??w,n=e.carried?M(t,e):t;return/@|%40/iu.test(n)?n.replaceAll(/\S+/gu,m):n}export{p as URL_CREDENTIAL_PLACEHOLDER,H as assertIdentityFieldsWithoutUrlCredentials,E as assertIdentityWithoutUrlCredentials,Y as invocationCarriesUrlCredentials,G as parseIdentityOption,y as redactIdentityCredentials,j as redactIdentityFields,q as redactOptionalIdentityCredentials,X as redactUrlCredentialsInText,m as redactUrlCredentialsInToken,V as runWithUrlCredentialInvocation};
1
+ import{AsyncLocalStorage as H}from"node:async_hooks";import{escapeCmdMetacharacters as F,escapePowerShellSingleQuotes as j,quoteWindowsCommandArg as z}from"./command-line.js";import{EXIT_CODE as B}from"./constants.js";import{PmCliError as G}from"./errors.js";const y="[redacted]",X=/%\^?40/giu,g=/@|%\^?40/iu;function C(e,t=e.length){let n=-1;for(const r of e.matchAll(X)){if(r.index>t)break;n=r.index}return n}function v(e,t){if(/[\t\n\r]/u.test(e)||!/(?:^|[^A-Za-z0-9+.-])(?:https?|wss?|ftp)$/iu.test(e.slice(0,t)))return!1;let n=t+1;for(;e[n]==="/"||e[n]==="\\";)n+=1;const r=e.indexOf("/",n)-n;if(r<0)return!1;const s=n+r;return!/[:@%]/u.test(e.slice(n,s))&&!/[:%]|[/\\][/\\]/u.test(e.slice(s))}function S(e){const t=Math.max(e.lastIndexOf("@"),C(e)),n=e.indexOf(":");if(t<0||n<0||n>t)return;let r=n+1;for(;r<t&&r<n+3&&(e[r]==="/"||e[r]==="\\");)r+=1;return r===t||v(e,n)?void 0:[r,t]}function _(e){const t=S(e);return t?`${e.slice(0,t[0])}${y}${e.slice(t[1])}`:e}function I(e){return _(e)}const T=["author","assignee","claim_principal"];function ye(e){const t={...e};for(const n of T)typeof t[n]=="string"&&(t[n]=I(t[n]));return t}function w(e,t){if(!(typeof e!="string"||S(e.trim())===void 0))throw new G(`${t} must not carry URL credentials: an identity is a name, never a credential.`,B.USAGE,{code:"invalid_argument_value",field:t,required:`Set ${t} to a plain name such as agent-a, with no URL userinfo (no user, password or token before the host).`,nextSteps:[`Rerun with ${t} set to a plain name.`],url_credentials_rejected:{source:t}})}function Ce(e,t){return w(e,t),e}const Z=[["comments","author"],["notes","author"],["learnings","author"],["dependencies","author"],["plan_decisions","author"],["plan_discoveries","author"],["plan_steps","owner"],["tests","provenance","author"],["tests","updated_by"]],x=4;function m(e,t,n=0){if(typeof e=="string"){w(e,t);return}if(!(n>=x||typeof e!="object"||e===null))for(const r of Object.values(e))m(r,t,n+1)}function Q(e,t){let n=e;for(const r of t){if(typeof n!="object"||n===null||Array.isArray(n))return;n=n[r]}return n}function Ie(e){const t=e;for(const n of T)m(t[n],n);for(const[n,...r]of Z){const s=t[n];Array.isArray(s)&&s.forEach((i,o)=>{m(Q(i,r),`${n}[${o}].${r.join(".")}`)})}}function Te(e){return typeof e=="string"?I(e):e}const h=6,q=65536,P={carried:!1,fragments:new Set,fragmentLength:h,shortSpellings:[]},A=new H;function R(e){const t=e.toLowerCase();if(t.length===e.length)return t;let n="";for(const r of e){const s=r.toLowerCase();n+=s.length===r.length?s:r}return n}function k(e){const t=z(`${e}@`),n=[e,e.replaceAll(/(["\\$`])/gu,"\\$1"),e.replaceAll("'","'\\''"),t.slice(1,-2),F(t).slice(2,-3),j(e)];return[...n,...n.map(r=>JSON.stringify(r).slice(1,-1))]}function V(e){const t=e.indexOf(":");return t>=0&&t<e.length-1?e.slice(t+1):e}function Y(e){const t=new Set;let n=!1;for(const u of e){const c=S(u);if(c){n=!0;for(const f of k(V(u.slice(c[0],c[1]))))t.add(R(f))}}const r=[...t],s=r.reduce((u,c)=>u+Math.max(0,c.length-h+1)+1,0),i=Math.max(1,Math.ceil(s/q)),o=Math.max(h,i),l=new Set,a=new Set;for(const u of r){if(u.length<o){(u.length>=h||/\s/u.test(u))&&a.add(u);continue}for(let c=0;c+o<=u.length;c+=i)l.add(u.slice(c,c+o));l.add(u.slice(-o))}return{carried:n,fragments:l,fragmentLength:o,shortSpellings:[...a]}}function J(e,t){const n=R(e),r=new Uint8Array(e.length);let s=!1;const i=t.fragmentLength;for(let l=0;l+i<=n.length;l+=1)t.fragments.has(n.slice(l,l+i))&&(r.fill(1,l,l+i),s=!0);for(const l of t.shortSpellings)for(let a=n.indexOf(l);a>=0;a=n.indexOf(l,a+1))r.fill(1,a,a+l.length),s=!0;if(!s)return e;let o="";for(let l=0;l<e.length;l+=1)r[l]?(l===0||!r[l-1])&&(o+=y):o+=e[l];return o}function we(e,t){return A.run(Y(e),t)}function Pe(){return(A.getStore()??P).carried}const K=16,U=512,ee=/^(?:(?:[A-Za-z0-9-]+\.)+[A-Za-z0-9-]+|localhost):\d+$/iu,ne=260,te={'"':'"',"'":"'","`":"`","<":">","(":")","[":"]"},re=new Set(["http","https","ws","wss","ftp","file"]);function $(e,t=!1){const n=ae(e);if(n<0)return;const r=O(e,n);if(n-r<2)return;const s=te[e[r-1]??""],i=re.has(e.slice(r,n).toLowerCase());let o=n+1;for(;o<e.length&&(e[o]==="/"||e[o]==="\\");)o+=1;if(o===e.length)return{kind:"pending",closer:s,special:i};const l=p(e.slice(o),s);if(l.startsWith("[")||i&&/[/\\?#]/u.test(l)||E(l,s)>=0)return;const a=ue(l,t);return a===void 0?void 0:{kind:a,closer:s,special:i}}const se=new Set([")","]"]),ie="'\\''",oe="'\\\\''";function p(e,t){return t==="'"?D(e.replaceAll(oe,"_____").replaceAll(ie,"____")):t==='"'?D(e):e}function L(e,t){let n=t;for(;e[n]==="\\";)n+=1;return n}function le(e,t,n){const r=(n-t)%2===1;if(e[n]==='"')return r?n:-1;if(e[n]!=="^")return-1;if(e[n+1]==='"')return r?n+1:-1;const s=L(e,n+1);return e[s]==='"'&&(s-n-1)%2===1?s:-1}function D(e){const t=[];let n=0;for(let r=e.indexOf("\\");r>=0;r=e.indexOf("\\",r)){const s=L(e,r),i=le(e,r,s);i>=0&&(t.push(e.slice(n,r),"_".repeat(i+1-r)),n=i+1),r=i>=0?i+1:s}return n===0?e:`${t.join("")}${e.slice(n)}`}function E(e,t){if(t===void 0)return-1;if(!se.has(t))return ce(e,t);let n=e.length;for(;n>0&&/[.,;:!?*_~`]/u.test(e[n-1]);)n-=1;return n>0&&e[n-1]===t?n-1:-1}function ce(e,t){for(let n=e.indexOf(t);n>=0;n=e.indexOf(t,n+1)){if(t==="'"&&e[n+1]==="'"){n+=1;continue}let r=0;for(;n-r>0&&e[n-r-1]==="\\";)r+=1;if(r%2===0)return n}return-1}function ae(e){let t=-1;for(let n=e.length-2;n>=0;n-=1){if(e[n]!==":"||e[n+1]!=="/"&&e[n+1]!=="\\")continue;const r=O(e,n);if(r===0||/[=?&#"'`(<[{,]/u.test(e[r-1]))return n;t=n}return t}function O(e,t){let n=t;for(;n>0&&/[A-Za-z0-9+.-]/u.test(e[n-1]);)n-=1;return n}function ue(e,t){return e.includes(":")?!t&&e.length<=ne&&ee.test(e)?void 0:"user":g.test(e)?void 0:"label"}function fe(e,t,n,r=-1){const s=Math.min(e.length,t+U);let i=t,o=r,l=n.kind==="user",a=!1;for(let u=0;u<K&&i<s;u+=1){const c=M(e,i,s);if(c===void 0)break;const f=pe(e.slice(c[0],Math.min(c[1],s+3)),s-c[0],n);if(f.startsUrl)break;de(f,l,a)&&(o=c[1]);const d=/[\t\r\n]/u.test(e[c[1]]??"");if(l||=f.colon||f.trailingColon&&d,a||=f.trailingColon,f.endsAuthority)break;i=c[1]}return o}function de(e,t,n){return e.separator?t||e.colonBeforeSeparator||n&&(e.hasPath||e.closedByOpener):!1}function M(e,t,n){let r=t;for(;r<n&&/\s/u.test(e[r]);)r+=1;if(r===n)return;let s=r;for(;s<e.length&&!/\s/u.test(e[s]);)s+=1;return[r,s]}function N(e){const t=e.indexOf(":");return t>=0&&t<e.length-1&&!he.test(e)}const he=/^\d{1,2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[AaPp][Mm])?[.,;:!?)]*$/u;function pe(e,t,n){const r=p(e,n.closer),s=n.special?r.search(/[/\\?#]/u):-1,i=s<0?r:r.slice(0,s),o=E(i,n.closer),l=r.search(/:[/\\]/u),a=o<0?i:i.slice(0,o),u=Math.min(a.length,t)-1,c=u<0?-1:Math.max(a.lastIndexOf("@",u),C(a,u));return{startsUrl:l>=0&&o<0&&ge(r.slice(0,l+1)),separator:c>=0,colonBeforeSeparator:c>0&&(N(a.slice(0,c))||a[c-1]===":"),colon:N(a),trailingColon:a.endsWith(":"),hasPath:o<0&&c>=0&&/[/\\]/u.test(r.slice(c+1)),closedByOpener:o>=0,endsAuthority:s>=0||o>=0}}function ge(e){const t=O(e,e.length-1);return t<e.length-2&&/[A-Za-z]/u.test(e[t])&&(t===0||t===1&&/["'`(<[]/u.test(e[0]))}function Se(e,t,n){const r=$(t,/[\t\r\n]/u.test(e.charAt(n)));if(r?.kind!=="pending")return r===void 0?void 0:{opening:r,from:n,seed:-1,final:!1};const s=M(e,n,Math.min(e.length,n+U));if(s===void 0)return;const i=p(e.slice(s[0],s[1]),r.closer),o=/^[/\\]*/u.exec(i)[0],l=i.slice(o.length),a=r.special?l.split(/[/\\?#]/u,1)[0]:l,u=E(a,r.closer),c=`${o}${u<0?a:a.slice(0,u)}`,f=g.test(c),d=f?{...r,kind:"user"}:$(`${t}${c}`);if(d===void 0||d.kind==="pending")return;const W=f?s[1]:-1;return{opening:d,from:s[1],seed:W,final:c.length<i.length}}function _e(e){if(!/:[/\\]/u.test(e))return e;const t=/\S+/gu;let n="",r=0;for(let s=t.exec(e);s!==null;s=t.exec(e)){const i=Se(e,s[0],s.index+s[0].length);if(i===void 0)continue;const o=i.final?i.seed:fe(e,i.from,i.opening,i.seed);o!==-1&&(n+=`${e.slice(r,s.index)}${_(e.slice(s.index,o))}`,r=o,t.lastIndex=o)}return r===0?e:`${n}${e.slice(r)}`}function Re(e){const t=A.getStore()??P,n=b(e);return t.carried?b(J(n,t)):n}function b(e){return g.test(e)?_e(e).replaceAll(/\S+/gu,_):e}const Ue={neutralizeEscapedQuotes:p};export{y as URL_CREDENTIAL_PLACEHOLDER,Ie as assertIdentityFieldsWithoutUrlCredentials,w as assertIdentityWithoutUrlCredentials,Pe as invocationCarriesUrlCredentials,Ce as parseIdentityOption,I as redactIdentityCredentials,ye as redactIdentityFields,Te as redactOptionalIdentityCredentials,Re as redactUrlCredentialsInText,_ as redactUrlCredentialsInToken,we as runWithUrlCredentialInvocation,Ue as urlCredentialsTestOnly};
2
2
  //# sourceMappingURL=url-credentials.js.map
@@ -47,20 +47,42 @@ export interface ItemMutationLocation{
47
47
  * `document.metadata.id` (for example in case on a case-sensitive
48
48
  * filesystem), so any read of this item's history inside the mutation must use it.
49
49
  */
50
- storageId:string;}
50
+ storageId:string;
51
+ /**
52
+ * True when another principal holds the item and the mutation's
53
+ * `callerClaimScope` scoped it to the caller's own ended claim: the
54
+ * callback must leave the holder's ownership unchanged. A scoped mutation
55
+ * that changes nothing writes nothing.
56
+ */
57
+ callerClaimScoped?:true;}
58
+ /**
59
+ * Decide, under the item lock, whether a mutation by a caller who does not
60
+ * hold the item acts only on the caller's own ended claim. When it resolves
61
+ * true the assignee-conflict policy and `--force` do not apply, and the
62
+ * callback receives `callerClaimScoped`.
63
+ */
64
+ export type CallerClaimScope=(input:{
65
+ /** The item as read under the lock. */
66
+ document:ItemDocument;
67
+ /** Storage id that keys the item's lock and history stream. */
68
+ storageId:string;
69
+ /** The caller's claim principal, compared exactly as the ownership guard compares it. */
70
+ callerPrincipal:string;})=> Promise<boolean>;
51
71
  /** The locked edit a single-item mutation applies; it receives the document and where the lock acts. */
52
72
  export type ItemMutationCallback=(document:ItemDocument,mutation:ItemMutationLocation)=>{changedFields:string[];warnings?:string[];}|Promise<{changedFields:string[];warnings?:string[];}>;interface ItemMutationResult{item:ItemMetadata;body:string;changedFields:string[];warnings:string[];}
53
73
  interface ItemMutationParams{pmRoot:string;settings:PmSettings;id:string;op:string;author:string;message?:string;
54
74
  /** Structured immutable context attached to the appended history entry. */
55
- historyContext?:Record<string,unknown>;force?:boolean;bypassAssigneeConflict?:boolean;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}
75
+ historyContext?:Record<string,unknown>;force?:boolean;bypassAssigneeConflict?:boolean;
76
+ /** Scope a non-holder's mutation to its own ended claim; see {@link CallerClaimScope}. */
77
+ callerClaimScope?:CallerClaimScope;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}
56
78
  /** Mutate one item while attaching structured context to its immutable history event. */
57
79
  export declare function mutateItemWithHistoryContext(params:{pmRoot:string;settings:PmSettings;id:string;op:string;author:string;message?:string;
58
80
  /** Structured immutable context attached to the appended history entry. */
59
- historyContext?:Record<string,unknown>;force?:boolean;bypassAssigneeConflict?:boolean;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}):Promise<{item:ItemMetadata;body:string;changedFields:string[];warnings:string[];}>;
81
+ historyContext?:Record<string,unknown>;force?:boolean;bypassAssigneeConflict?:boolean;callerClaimScope?:CallerClaimScope;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}):Promise<{item:ItemMetadata;body:string;changedFields:string[];warnings:string[];}>;
60
82
  /** Mutate one item while resolving structured history context after its locked mutation. */
61
83
  export declare function mutateItemWithHistoryContextResolver(params:Omit<ItemMutationParams,"historyContext">&{resolveHistoryContext:()=> Record<string,unknown>|undefined;}):Promise<ItemMutationResult>;
62
84
  /** Implements mutate item for the public runtime surface of this module. */
63
- export declare function mutateItem(params:{pmRoot:string;settings:PmSettings;id:string;op:string;author:string;message?:string;force?:boolean;bypassAssigneeConflict?:boolean;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}):Promise<{item:ItemMetadata;body:string;changedFields:string[];warnings:string[];}>;
85
+ export declare function mutateItem(params:{pmRoot:string;settings:PmSettings;id:string;op:string;author:string;message?:string;force?:boolean;bypassAssigneeConflict?:boolean;callerClaimScope?:CallerClaimScope;skipNoop?:boolean;extensionFieldNames?:readonly string[];typeToFolder?:Record<string,string>;mutate:ItemMutationCallback;}):Promise<{item:ItemMetadata;body:string;changedFields:string[];warnings:string[];}>;
64
86
  /** Public contract for item store test only, shared by SDK and presentation-layer consumers. */
65
87
  export declare const itemStoreTestOnly:{appendWarning:typeof appendWarning;bypassesAssigneeConflict:typeof bypassesAssigneeConflict;buildDidYouMeanSuggestions:typeof buildDidYouMeanSuggestions;isErrno:typeof isErrno;};
66
88
  /** Implements delete item for the public runtime surface of this module. */