@visulima/vis 6.5.4 → 6.6.0

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 (121) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/bin.js +1 -1
  3. package/dist/binx.js +1 -1
  4. package/dist/config/index.d.ts +17 -2
  5. package/dist/packem_chunks/bloom-sync.js +1 -1
  6. package/dist/packem_chunks/catalog.js +1 -1
  7. package/dist/packem_chunks/cli-exec.js +1 -1
  8. package/dist/packem_chunks/cli-main.js +1 -1
  9. package/dist/packem_chunks/fix.js +1 -1
  10. package/dist/packem_chunks/handler10.js +1 -1
  11. package/dist/packem_chunks/handler12.js +1 -1
  12. package/dist/packem_chunks/handler13.js +1 -1
  13. package/dist/packem_chunks/handler14.js +1 -1
  14. package/dist/packem_chunks/handler15.js +1 -1
  15. package/dist/packem_chunks/handler19.js +1 -1
  16. package/dist/packem_chunks/handler2.js +1 -1
  17. package/dist/packem_chunks/handler20.js +1 -1
  18. package/dist/packem_chunks/handler21.js +1 -1
  19. package/dist/packem_chunks/handler23.js +1 -1
  20. package/dist/packem_chunks/handler24.js +1 -1
  21. package/dist/packem_chunks/handler25.js +1 -1
  22. package/dist/packem_chunks/handler26.js +1 -1
  23. package/dist/packem_chunks/handler28.js +1 -1
  24. package/dist/packem_chunks/handler3.js +1 -1
  25. package/dist/packem_chunks/handler4.js +1 -1
  26. package/dist/packem_chunks/handler5.js +1 -1
  27. package/dist/packem_chunks/handler50.js +1 -1
  28. package/dist/packem_chunks/handler51.js +1 -1
  29. package/dist/packem_chunks/handler52.js +1 -1
  30. package/dist/packem_chunks/handler54.js +1 -1
  31. package/dist/packem_chunks/handler55.js +1 -1
  32. package/dist/packem_chunks/handler58.js +1 -1
  33. package/dist/packem_chunks/handler59.js +1 -1
  34. package/dist/packem_chunks/handler6.js +1 -1
  35. package/dist/packem_chunks/handler60.js +1 -1
  36. package/dist/packem_chunks/handler61.js +1 -1
  37. package/dist/packem_chunks/handler62.js +1 -1
  38. package/dist/packem_chunks/handler63.js +1 -1
  39. package/dist/packem_chunks/handler64.js +1 -1
  40. package/dist/packem_chunks/handler65.js +1 -1
  41. package/dist/packem_chunks/handler66.js +1 -1
  42. package/dist/packem_chunks/handler67.js +1 -1
  43. package/dist/packem_chunks/handler68.js +1 -1
  44. package/dist/packem_chunks/handler69.js +1 -1
  45. package/dist/packem_chunks/handler7.js +1 -1
  46. package/dist/packem_chunks/handler70.js +1 -1
  47. package/dist/packem_chunks/handler71.js +1 -1
  48. package/dist/packem_chunks/handler72.js +1 -1
  49. package/dist/packem_chunks/handler73.js +1 -1
  50. package/dist/packem_chunks/handler74.js +1 -1
  51. package/dist/packem_chunks/handler75.js +1 -1
  52. package/dist/packem_chunks/handler76.js +1 -1
  53. package/dist/packem_chunks/handler77.js +10 -10
  54. package/dist/packem_chunks/handler78.js +1 -1
  55. package/dist/packem_chunks/handler79.js +1 -1
  56. package/dist/packem_chunks/handler8.js +1 -1
  57. package/dist/packem_chunks/heal.js +1 -1
  58. package/dist/packem_chunks/help-command.js +1 -1
  59. package/dist/packem_chunks/index7.js +1 -1
  60. package/dist/packem_chunks/keys-refresh.js +1 -1
  61. package/dist/packem_chunks/list.js +1 -1
  62. package/dist/packem_chunks/prune.js +1 -1
  63. package/dist/packem_chunks/status.js +1 -1
  64. package/dist/packem_chunks/sync.js +1 -1
  65. package/dist/packem_chunks/sync2.js +1 -1
  66. package/dist/packem_chunks/tripwire.js +1 -1
  67. package/dist/packem_chunks/verify-lockfile.js +1 -1
  68. package/dist/packem_shared/{advisories-CIk-GN4f.js → advisories-BldM-U4F.js} +1 -1
  69. package/dist/packem_shared/{affected-selection-KJi4PXE2.js → affected-selection-DxKQo2N5.js} +1 -1
  70. package/dist/packem_shared/{ai-analysis-DsN-OIWD.js → ai-analysis-D1Y5a_SZ.js} +1 -1
  71. package/dist/packem_shared/{ai-cache-oP-8Vvho.js → ai-cache-CSmj5gA2.js} +1 -1
  72. package/dist/packem_shared/{ai-fix-BpRmbHRB.js → ai-fix-DVcnNQ0X.js} +1 -1
  73. package/dist/packem_shared/{bin-C6pXyVPL.js → bin-Bw91EYm6.js} +1 -1
  74. package/dist/packem_shared/{build-scripts-AqY7IQy0.js → build-scripts-ETlkUGzC.js} +1 -1
  75. package/dist/packem_shared/{dependency-scan-Blpo9KJB.js → dependency-scan-Dv1kJ-Sn.js} +1 -1
  76. package/dist/packem_shared/{detect-DLTcax9j.js → detect-Bch1mcQe.js} +1 -1
  77. package/dist/packem_shared/{docker-IMan-ReQ.js → docker-DPxeLIQl.js} +1 -1
  78. package/dist/packem_shared/{ecosystem-gate-DYE1xbEA.js → ecosystem-gate-IugL9cei.js} +1 -1
  79. package/dist/packem_shared/{env-B-rXCpnL.js → env-D3wteXlq.js} +1 -1
  80. package/dist/packem_shared/{env-consistency-LGwaZrb4.js → env-consistency-1rRSdrFI.js} +1 -1
  81. package/dist/packem_shared/{failure-log-CqOSmCst.js → failure-log-Dgp-P-SJ.js} +1 -1
  82. package/dist/packem_shared/glob-Cyk1H9ZL-D0MQr5DW.js +1 -0
  83. package/dist/packem_shared/{index-xHwdLedQ.js → index-BTwTRy_a.js} +1 -1
  84. package/dist/packem_shared/{index-Zn2hE0HC.js → index-DojXARzs.js} +1 -1
  85. package/dist/packem_shared/{lifecycle-7cCIImyz.js → lifecycle-C6o0cmOT.js} +1 -1
  86. package/dist/packem_shared/{manifests-Cv-l6E7h.js → manifests-CgiKqpP8.js} +1 -1
  87. package/dist/packem_shared/{min-release-age-CZ3XkoSx.js → min-release-age-RVDHqGu5.js} +1 -1
  88. package/dist/packem_shared/{missing-package-json-KsrtjpfC.js → missing-package-json-Cf7PavlK.js} +1 -1
  89. package/dist/packem_shared/{multi-eco-lockfiles-BUNeBCB3.js → multi-eco-lockfiles-B3591j5D.js} +1 -1
  90. package/dist/packem_shared/{native-config-sync-BpOioKS7.js → native-config-sync-BGLC8n86.js} +1 -1
  91. package/dist/packem_shared/{osv-BrN069IK.js → osv-CI9eaGmG.js} +1 -1
  92. package/dist/packem_shared/{package-version-Ba3NbtCc.js → package-version-COyEFX59.js} +1 -1
  93. package/dist/packem_shared/{packument-D7knSKP-.js → packument-Dij7POVt.js} +1 -1
  94. package/dist/packem_shared/{project-name-filter-B5MeWa0B.js → project-name-filter-B7h62wuR.js} +1 -1
  95. package/dist/packem_shared/{provenance-BhdcS8on.js → provenance-BVFxzkUv.js} +1 -1
  96. package/dist/packem_shared/{registry-Bd3v810N.js → registry-CyYhBUaF.js} +41 -41
  97. package/dist/packem_shared/{registry-keys-ChCCi6gS.js → registry-keys-BwWnVZtb.js} +1 -1
  98. package/dist/packem_shared/{renderToString-DR0zDUjh-bM18Jav2.js → renderToString-DR0zDUjh-CQT5Ebrc.js} +1 -1
  99. package/dist/packem_shared/{resolve-explicit-CR284YhP.js → resolve-explicit-BshyrPRh.js} +1 -1
  100. package/dist/packem_shared/{run-summary-utils-CnHppdTd.js → run-summary-utils-RzgHeC8f.js} +1 -1
  101. package/dist/packem_shared/{runtime-check-ra6RgZPE.js → runtime-check-CpBsIYcl.js} +1 -1
  102. package/dist/packem_shared/{s1ngularity-D16SlxEN.js → s1ngularity-Bb56bc8v.js} +1 -1
  103. package/dist/packem_shared/{scaffold-files-U8MRP9xv.js → scaffold-files-sbf-Y1nQ.js} +1 -1
  104. package/dist/packem_shared/{scan-progress-DXLRdiC0.js → scan-progress-Blrj96LZ.js} +1 -1
  105. package/dist/packem_shared/{selectors-D66zhaRy.js → selectors-DmRRUQsG.js} +1 -1
  106. package/dist/packem_shared/{signatures-Cpzgkrts.js → signatures-DlGMQsHg.js} +1 -1
  107. package/dist/packem_shared/{spinner-rjP357lg.js → spinner-B30I9gQR.js} +1 -1
  108. package/dist/packem_shared/{table-WHMzV10O.js → table-ahQIE6tw.js} +1 -1
  109. package/dist/packem_shared/{tabs-Zg0TBeDz.js → tabs-K9dH5Qdu.js} +1 -1
  110. package/dist/packem_shared/{toolchain-BT5Wf134.js → toolchain-B7PrWDAi.js} +1 -1
  111. package/dist/packem_shared/{typosquats-D23HsChp.js → typosquats-Dn2ahBS1.js} +1 -1
  112. package/dist/packem_shared/{use-measured-height-C074njW2.js → use-measured-height-D5xfIDWl.js} +1 -1
  113. package/dist/packem_shared/{vis-update-app-aXnF7iVf.js → vis-update-app-CPpJkbSs.js} +1 -1
  114. package/dist/packem_shared/{vis-user-error-CyyTUwX4.js → vis-user-error-C3y9hGtw.js} +1 -1
  115. package/dist/packem_shared/{watch-loop--dOgMJ2f.js → watch-loop-DQ6KryuH.js} +1 -1
  116. package/index.js +26 -26
  117. package/package.json +9 -9
  118. package/schemas/project.schema.json +9 -2
  119. package/schemas/vis-config.schema.json +11 -4
  120. package/schemas/vis-release-config.schema.json +2 -2
  121. package/dist/packem_shared/glob-Cyk1H9ZL-D05BMypC.js +0 -1
@@ -1,4 +1,4 @@
1
- import{createRequire as wt}from"node:module";import{a as b,$ as rt,U as yt,v as nt,e as P,q as Tt}from"../packem_shared/index-0dnGN3GP.js";import{j as m,X as $,O as S,l as vt,i as St}from"../packem_shared/registry-Bd3v810N.js";import it from"./index.js";import{x as at}from"../packem_shared/main-CgDAlZkm.js";import{y as G}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{q as $t}from"./cli-main.js";import{l as At}from"../packem_shared/spinner-rjP357lg.js";import{C as ot,D as F,T as ct}from"../packem_shared/symbols-BXDZ_sKt.js";import{b as z,F as E,q as D,X as L,J as It}from"../packem_shared/index.server-Ca_EEVfw.js";import{withEnhancedPath as Mt}from"@visulima/task-runner";let mt;const kt=t=>(mt??=wt(import.meta.url))(t),M=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,B=t=>{if(typeof M<"u"&&M.versions&&M.versions.node){const[e,s]=M.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return M.getBuiltinModule(t)}return kt(t)},{readFileSync:bt,writeFileSync:xt,unlinkSync:Ct}=B("node:fs"),{randomBytes:Et}=B("node:crypto"),{availableParallelism:W}=B("node:os");class I extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class Rt extends I{}class T extends I{}class V extends I{}class j extends I{stderr;constructor(e,s,n){super(e,n),this.stderr=s}}class X extends I{}class A extends I{commandTitle;constructor(e,s,n){super(s,n),this.commandTitle=e}}const dt=t=>t.includes("/"),O=(t,e)=>e?t.toLowerCase():t,jt=(t,e,s,n={})=>{const r=dt(t),i=n.caseInsensitive===!0,c=O(t,i),a=[];for(const o of e){const l=r?b(s,o):rt(o);it(c,O(l,i))&&a.push(o)}return a},_t=(t,e,s,n={})=>{if(!e||e.length===0)return[...t];const r=n.caseInsensitive===!0;return t.filter(i=>{for(const c of e){const a=dt(c)?b(s,i):rt(i),o=O(c,r);if(it(o,O(a,r)))return!1}return!0})},U=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",_=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",Pt=(t,e)=>{const s=b(t,e);return s===""||!s.startsWith("..")&&!nt(s)},Ft=(t,e)=>{let s;for(const n of e)Pt(n,t)&&(s===void 0||n.length>s.length)&&(s=n);return s},Ot=async t=>{let e=0,s=0;const n=()=>(e+=1,`pattern-${e}`),r=()=>(s+=1,`cmd-${s}`),i=(o,l,f,d)=>{if(o.perPackage===!0){const u=t.workspacePackages??[],g=new Map;for(const h of f){const w=Ft(h,u)??t.cwd,k=g.get(w)??[];k.push(b(w,h)),g.set(w,k)}for(const h of[...g.keys()].sort()){const w=b(t.cwd,h)||".";d.push({command:o.command,cwd:h,files:g.get(h)??[],id:r(),source:"string",title:`${o.command} — ${w}`})}return}if(o.cwd!==void 0){const u=yt(t.cwd,o.cwd);d.push({command:o.command,cwd:u,files:f,id:r(),source:"string",title:`${o.command} — ${b(t.cwd,u)||"."}`});return}d.push({command:o.command,files:l,id:r(),source:"string",title:o.command})},c=async(o,l,f,d)=>{if(typeof o=="string"){d.push({command:o,files:l,id:r(),source:"string",title:o});return}if(Array.isArray(o)){for(const u of o)await c(u,l,f,d);return}if(_(o)){i(o,l,f,d);return}if(typeof o=="function"){const u=await o([...l]);if(typeof u=="string"){d.push({command:u,files:l,id:r(),source:"function",title:u,verbatim:!0});return}if(Array.isArray(u)){for(const g of u)if(typeof g=="string")d.push({command:g,files:l,id:r(),source:"function",title:g,verbatim:!0});else if(_(g))i(g,l,f,d);else if(U(g))d.push({files:l,id:r(),run:g.task,source:"custom",title:g.title});else throw new T("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(_(u)){i(u,l,f,d);return}if(U(u)){d.push({files:l,id:r(),run:u.task,source:"custom",title:u.title});return}throw new T("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(U(o)){d.push({files:l,id:r(),run:o.task,source:"custom",title:o.title});return}throw new T("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},a=[];for(const[o,l]of Object.entries(t.config)){const f=jt(o,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(f.length===0)continue;const d=t.relative?f.map(g=>b(t.cwd,g)):f,u=[];await c(l,d,f,u),u.length!==0&&a.push({commands:u,files:d,id:n(),pattern:o,title:`${o} — ${f.length} file${f.length===1?"":"s"}`})}return a},Nt=async t=>{if(t.config!==void 0)return t.config;throw new T(`No staged config provided. Add \`staged\` to your vis.config.ts:
1
+ import{createRequire as Tt}from"node:module";import{a as x,$ as at,U as bt,v as ot,e as N,q as xt}from"../packem_shared/index-0dnGN3GP.js";import{N as L,j as v,X as I,O as C,P as Ct,l as $t,i as Et}from"../packem_shared/registry-CyYhBUaF.js";import ct from"./index.js";import{x as dt}from"../packem_shared/main-CgDAlZkm.js";import{y as W}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{q as jt}from"./cli-main.js";import{l as Ot}from"../packem_shared/spinner-B30I9gQR.js";import{C as lt,D,T as ut}from"../packem_shared/symbols-BXDZ_sKt.js";import{b as V,F as E,q as B,X as U,J as Pt}from"../packem_shared/index.server-Ca_EEVfw.js";import{withEnhancedPath as _t}from"@visulima/task-runner";let vt;const St=t=>(vt??=Tt(import.meta.url))(t),O=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,z=t=>{if(typeof O<"u"&&O.versions&&O.versions.node){const[e,s]=O.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return O.getBuiltinModule(t)}return St(t)},{readFileSync:At,writeFileSync:It,unlinkSync:Mt}=z("node:fs"),{randomBytes:Rt}=z("node:crypto"),{availableParallelism:X}=z("node:os");class R extends Error{constructor(e,s){super(e,s),this.name=this.constructor.name}}class Ft extends R{}class b extends R{}class K extends R{}class _ extends R{stderr;constructor(e,s,n){super(e,n),this.stderr=s}}class J extends R{}class M extends R{commandTitle;constructor(e,s,n){super(s,n),this.commandTitle=e}}const ft=t=>t.includes("/"),q=(t,e)=>e?t.toLowerCase():t,Nt=(t,e,s,n={})=>{const r=ft(t),i=n.caseInsensitive===!0,o=q(t,i),a=[];for(const c of e){const u=r?x(s,c):at(c);ct(o,q(u,i))&&a.push(c)}return a},Dt=(t,e,s,n={})=>{if(!e||e.length===0)return[...t];const r=n.caseInsensitive===!0;return t.filter(i=>{for(const o of e){const a=ft(o)?x(s,i):at(i),c=q(o,r);if(ct(c,q(a,r)))return!1}return!0})},G=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",F=t=>typeof t=="object"&&t!==null&&typeof t.command=="string"&&typeof t.task!="function",qt=(t,e)=>{const s=x(t,e);return s===""||!s.startsWith("..")&&!ot(s)},Y=(t,e)=>{let s;for(const n of e)qt(n,t)&&(s===void 0||n.length>s.length)&&(s=n);return s},ht=t=>{if(t.dependsOn===void 0)return[];if(!Array.isArray(t.dependsOn))throw new b(`\`dependsOn\` of "${t.command}" must be an array such as ["^build"].`);return t.dependsOn.map(e=>{if(typeof e!="string"||!/^\^[^\s^:-][^\s^]*$/.test(e))throw new b(`\`dependsOn\` entry ${JSON.stringify(e)} of "${t.command}" is not supported — staged tasks only take the dependency form "^<target>", e.g. "^build".`);return e.slice(1)})},Lt=(t,e,s,n)=>[...n.map(r=>L(r)),"run",L(`:${t}`),"--if-present","--no-preflight","--skip-toolchain",...e.flatMap(r=>["-F",L(`{${x(s,r)}}^...`)])].join(" "),Bt=async t=>{let e=0,s=0;const n=()=>(e+=1,`pattern-${e}`),r=()=>(s+=1,`cmd-${s}`),i={packages:new Set,targets:new Set},o=(l,d)=>{const h=ht(l);if(h.length!==0){for(const g of h)i.targets.add(g);for(const g of d){const p=Y(g,t.workspacePackages??[]);p!==void 0&&x(t.cwd,p)!==""&&i.packages.add(p)}}},a=(l,d,h,g)=>{if(o(l,h),l.perPackage===!0){const p=t.workspacePackages??[],y=new Map;for(const A of h){const T=Y(A,p)??t.cwd,j=y.get(T)??[];j.push(x(T,A)),y.set(T,j)}for(const A of[...y.keys()].sort()){const T=x(t.cwd,A)||".";g.push({command:l.command,cwd:A,files:y.get(A)??[],id:r(),source:"string",title:`${l.command} — ${T}`})}return}if(l.cwd!==void 0){const p=bt(t.cwd,l.cwd);g.push({command:l.command,cwd:p,files:h,id:r(),source:"string",title:`${l.command} — ${x(t.cwd,p)||"."}`});return}g.push({command:l.command,files:d,id:r(),source:"string",title:l.command})},c=async(l,d,h,g)=>{if(typeof l=="string"){g.push({command:l,files:d,id:r(),source:"string",title:l});return}if(Array.isArray(l)){for(const p of l)await c(p,d,h,g);return}if(F(l)){a(l,d,h,g);return}if(typeof l=="function"){const p=await l([...d]);if(typeof p=="string"){g.push({command:p,files:d,id:r(),source:"function",title:p,verbatim:!0});return}if(Array.isArray(p)){for(const y of p)if(typeof y=="string")g.push({command:y,files:d,id:r(),source:"function",title:y,verbatim:!0});else if(F(y))a(y,d,h,g);else if(G(y))g.push({files:d,id:r(),run:y.task,source:"custom",title:y.title});else throw new b("Task function returned an array with an unsupported entry — expected strings, { command, … }, or { title, task }.");return}if(F(p)){a(p,d,h,g);return}if(G(p)){g.push({files:d,id:r(),run:p.task,source:"custom",title:p.title});return}throw new b("Task function returned an unsupported value — expected string, string[], { command, … }, or { title, task }.")}if(G(l)){g.push({files:d,id:r(),run:l.task,source:"custom",title:l.title});return}throw new b("Unsupported task value — expected string, string[], function, { command, … }, or { title, task }.")},u=[];for(const[l,d]of Object.entries(t.config)){const h=Nt(l,t.files,t.cwd,{caseInsensitive:t.caseInsensitive===!0});if(h.length===0)continue;const g=t.relative?h.map(y=>x(t.cwd,y)):h,p=[];await c(d,g,h,p),p.length!==0&&u.push({commands:p,files:g,id:n(),pattern:l,title:`${l} — ${h.length} file${h.length===1?"":"s"}`})}if(i.targets.size===0||u.length===0)return u;if((t.workspacePackages??[]).length===0)return t.warn?.("`dependsOn` is set, but no workspace packages were found, so their dependencies were not built."),u;if(i.packages.size===0)return u;const{visEntry:m}=t;if(m===void 0)throw new Error("buildTaskGraph needs `visEntry` to build `dependsOn` targets.");const f=[...i.packages].sort(),w=`${f.length} package${f.length===1?"":"s"}`;return[...[...i.targets].map(l=>{const d=`${l} dependencies of ${w}`;return{commands:[{command:Lt(l,f,t.cwd,m),files:[],id:r(),source:"string",title:d,verbatim:!0}],files:[],id:n(),pattern:"dependsOn",prerequisite:!0,title:d}}),...u]},Ut=async t=>{if(t.config!==void 0)return t.config;throw new b(`No staged config provided. Add \`staged\` to your vis.config.ts:
2
2
 
3
3
  import { defineConfig } from "@visulima/vis/config";
4
4
 
@@ -6,16 +6,16 @@ import{createRequire as wt}from"node:module";import{a as b,$ as rt,U as yt,v as
6
6
  staged: { "*.ts": "eslint --fix" },
7
7
  });
8
8
 
9
- Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},K=t=>{if(typeof t!="object"||t===null)throw new T("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new T("Staged config is empty — at least one glob pattern is required.");for(const[s,n]of e){if(!s||s.trim()==="")throw new T("Staged config keys must be non-empty glob patterns.");lt(s,n)}return t},lt=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new T(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new T(`Task array for "${t}" is empty.`);for(const s of e)lt(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new T(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(_(e)){if(e.command.trim()==="")throw new T(`Command task for "${t}" has an empty \`command\`.`);return}if(!Dt(e))throw new T(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Dt=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",Y=2048,p=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),n=await at("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),r=typeof n.exitCode=="number"?n.exitCode:1;if(r!==0&&!e.lenient){const{stderr:i}=n,c=i.length>Y?`${i.slice(0,Y)}…`:i;throw new j(`git ${t.join(" ")} failed with exit code ${r}: ${c.trim()}`,i)}return{exitCode:r,stderr:n.stderr,stdout:n.stdout}},x=async(t,e)=>{const{stdout:s}=await p(t,e);return s.trim()},Lt=async t=>{const e=await p(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},Ut=async t=>x(["rev-parse","--absolute-git-dir"],{cwd:t}),ut=async t=>x(["rev-parse","--show-toplevel"],{cwd:t}),q=async t=>x(["write-tree"],{cwd:t}),qt=async t=>{const e=await p(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},R={major:2,minor:32},Bt=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),n=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(n)?null:{major:s,minor:n}},Ht=async t=>{const e=Bt(await x(["--version"],{cwd:t}));if(e===null)return;if(e.major<R.major||e.major===R.major&&e.minor<R.minor)throw new j(`Git ${R.major}.${R.minor} or newer is required; found ${e.major}.${e.minor}.`)},Gt="ACMR",J=500,zt=async t=>{const{stdout:e}=await p(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(r=>r.length>0),n=[];for(let r=0;r<s.length;r+=1){const i=s[r];if(!i?.startsWith(":"))continue;const c=i.slice(1).split(" "),a=c[3],o=c[4],l=s[r+1];r+=1,o==="A"&&a!==void 0&&/^0+$/.test(a)&&l!==void 0&&n.push(l)}return n},Z=async t=>{const{stdout:e}=await p(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Wt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await p(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Vt=async t=>{const e=t.diffFilter??Gt,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:n}=await p(s,{cwd:t.cwd}),r=n.split("\0").filter(c=>c.length>0);if(r.length===0)return[];const i=t.workTree??await ut(t.cwd);return r.map(c=>nt(c)?c:P(i,c))},Xt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let i=0;i<t.length;i+=J){const c=t.slice(i,i+J),{stdout:a}=await p(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...c],{cwd:e.cwd});a.length>0&&s.push(a)}if(s.length===0)return null;const n=s.join(""),r=n.endsWith(`
9
+ Coming from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`)},Z=t=>{if(typeof t!="object"||t===null)throw new b("Staged config must be an object mapping glob patterns to tasks.");const e=Object.entries(t);if(e.length===0)throw new b("Staged config is empty — at least one glob pattern is required.");for(const[s,n]of e){if(!s||s.trim()==="")throw new b("Staged config keys must be non-empty glob patterns.");gt(s,n)}return t},gt=(t,e)=>{if(typeof e=="string"){if(e.trim()==="")throw new b(`Task for "${t}" is an empty string.`);return}if(Array.isArray(e)){if(e.length===0)throw new b(`Task array for "${t}" is empty.`);for(const s of e)gt(t,s);return}if(typeof e!="function"){if(typeof e=="object"&&e!==null&&typeof e.command=="string"&&typeof e.task=="function")throw new b(`Task for "${t}" sets both \`command\` and \`task\` — use one or the other.`);if(F(e)){if(e.command.trim()==="")throw new b(`Command task for "${t}" has an empty \`command\`.`);ht(e);return}if(!Gt(e))throw new b(`Invalid task for "${t}" — expected string, string[], function, { command, … }, or { title, task } object.`)}},Gt=t=>typeof t=="object"&&t!==null&&typeof t.title=="string"&&typeof t.task=="function",Q=2048,k=async(t,e)=>{const s=e.input===void 0?void 0:typeof e.input=="string"?e.input:e.input.toString("utf8"),n=await dt("git",[...t],{nodeOptions:{cwd:e.cwd,env:e.env?{...process.env,...e.env}:void 0,stdio:s===void 0?["ignore","pipe","pipe"]:["pipe","pipe","pipe"]},stdin:s}),r=typeof n.exitCode=="number"?n.exitCode:1;if(r!==0&&!e.lenient){const{stderr:i}=n,o=i.length>Q?`${i.slice(0,Q)}…`:i;throw new _(`git ${t.join(" ")} failed with exit code ${r}: ${o.trim()}`,i)}return{exitCode:r,stderr:n.stderr,stdout:n.stdout}},$=async(t,e)=>{const{stdout:s}=await k(t,e);return s.trim()},Ht=async t=>{const e=await k(["rev-parse","--is-inside-work-tree"],{cwd:t,lenient:!0});return e.exitCode===0&&e.stdout.trim()==="true"},zt=async t=>$(["rev-parse","--absolute-git-dir"],{cwd:t}),pt=async t=>$(["rev-parse","--show-toplevel"],{cwd:t}),H=async t=>$(["write-tree"],{cwd:t}),Wt=async t=>{const e=await k(["rev-parse","HEAD^{tree}"],{cwd:t,lenient:!0});return e.exitCode===0?e.stdout.trim():""},P={major:2,minor:32},Vt=t=>{const e=/git version (\d+)\.(\d+)/.exec(t);if(!e)return null;const s=Number.parseInt(e[1]??"",10),n=Number.parseInt(e[2]??"",10);return Number.isNaN(s)||Number.isNaN(n)?null:{major:s,minor:n}},Xt=async t=>{const e=Vt(await $(["--version"],{cwd:t}));if(e===null)return;if(e.major<P.major||e.major===P.major&&e.minor<P.minor)throw new _(`Git ${P.major}.${P.minor} or newer is required; found ${e.major}.${e.minor}.`)},Kt="ACMR",tt=500,Jt=async t=>{const{stdout:e}=await k(["diff-files","--raw","-z"],{cwd:t}),s=e.split("\0").filter(r=>r.length>0),n=[];for(let r=0;r<s.length;r+=1){const i=s[r];if(!i?.startsWith(":"))continue;const o=i.slice(1).split(" "),a=o[3],c=o[4],u=s[r+1];r+=1,c==="A"&&a!==void 0&&/^0+$/.test(a)&&u!==void 0&&n.push(u)}return n},et=async t=>{const{stdout:e}=await k(["ls-files","--others","--exclude-standard","-z"],{cwd:t});return e.split("\0").filter(s=>s.length>0)},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await k(["rm","--cached","--quiet","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Zt=async t=>{const e=t.diffFilter??Kt,s=t.diff===void 0?["diff","--name-only","-z",`--diff-filter=${e}`,"--staged"]:["diff","--name-only","-z",`--diff-filter=${e}`,...t.diff.split(/\s+/).filter(Boolean)],{stdout:n}=await k(s,{cwd:t.cwd}),r=n.split("\0").filter(o=>o.length>0);if(r.length===0)return[];const i=t.workTree??await pt(t.cwd);return r.map(o=>ot(o)?o:N(i,o))},Qt=async(t,e)=>{if(t.length===0)return null;const s=[];for(let i=0;i<t.length;i+=tt){const o=t.slice(i,i+tt),{stdout:a}=await k(["diff","--binary","--unified=0","--no-color","--no-ext-diff","--src-prefix=a/","--dst-prefix=b/","--patch","--submodule=short","--",...o],{cwd:e.cwd});a.length>0&&s.push(a)}if(s.length===0)return null;const n=s.join(""),r=n.endsWith(`
10
10
  `)?n:`${n}
11
- `;return Buffer.from(r,"utf8")},Kt=async t=>{const{stdout:e}=await p(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),n=[];for(let r=0;r<s.length;r+=1){const i=s[r];if(i===void 0||i.length<4)continue;const c=i.charAt(0),a=i.charAt(1),o=i.slice(3),l=c==="R"||c==="C"||a==="R"||a==="C";c!==" "&&c!=="?"&&a!==" "&&a!=="?"&&n.push(o),l&&(r+=1)}return n},Yt=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await p(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Jt=async(t,e)=>{if(await p(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await p(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},Zt="vis_staged_automatic_backup",ft=()=>`${Zt}-${process.pid}-${Date.now()}-${Et(3).toString("hex")}`,Qt=async t=>{const e=await x(["stash","create"],{cwd:t});return e.length===0?null:(await p(["stash","store","-m",ft(),e],{cwd:t}),e)},te=async(t,e)=>{const{exitCode:s,stdout:n}=await p(["reflog","--format=%H %gs","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const r of n.split(/\r?\n/)){const i=r.indexOf(" ");if(i!==-1&&r.slice(i+1).includes(e))return r.slice(0,i)}return null},ee=async t=>{const e=ft(),{exitCode:s,stdout:n}=await p(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const r=n.trim();return r.length>0&&/no local changes/i.test(r)?null:te(t,e)},se=async t=>{const e=await x(["stash","create"],{cwd:t});return e.length===0?"":x(["rev-parse",`${e}^{tree}`],{cwd:t})},re=async(t,e)=>{const[s,n]=await Promise.all([x(["rev-parse",`${e}^{tree}`],{cwd:t}),x(["rev-parse",`${e}^2^{tree}`],{cwd:t})]);return{indexTree:n,worktreeTree:s}},ne=async(t,e)=>{const{exitCode:s,stdout:n}=await p(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const r of n.split(/\r?\n/)){const[i,c]=r.split(/\s+/,2);if(i===e&&c!==void 0)return c}return null},ht=async(t,e)=>{const{exitCode:s}=await p(["rev-parse","--verify","--quiet",`${e}^{commit}`],{cwd:t,lenient:!0});return s===0},ie=async(t,e)=>{const s=await ne(t,e);if(s===null)return null;const{exitCode:n,stdout:r}=await p(["rev-parse","--verify","--quiet",s],{cwd:t,lenient:!0});return n===0&&r.trim()===e?s:null},gt=async(t,e)=>{if(e===null)return;const s=await ie(t,e);s!==null&&await p(["stash","drop","--quiet",s],{cwd:t})},ae=async(t,e)=>{if(e===null)throw new V("Backup stash was not found — can't revert working tree.");if(!await ht(t,e))throw new V(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await p(["reset","--hard","HEAD"],{cwd:t}),await p(["stash","apply","--index","--quiet",e],{cwd:t})},oe=async(t,e)=>{e!==null&&await ht(t,e)&&(await p(["stash","apply","--quiet",e],{cwd:t}),await gt(t,e))};class ce{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Lt(this.cwd))throw new j(`Not a git repository: ${this.cwd}`);await Ht(this.cwd),this.workTree=await ut(this.cwd),this.gitDir=await Ut(this.cwd),this.stagedFiles=await Vt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await Kt(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await zt(this.workTree),this.intentToAddPaths.length>0&&await Wt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await Qt(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await ee(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await q(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await qt(this.workTree),this.preTaskUntracked=new Set(await Z(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(n=>b(this.workTree,n));if(await Jt(s,{cwd:this.workTree}),e){const r=(await Z(this.workTree)).filter(i=>!this.preTaskUntracked.has(i));if(r.length>0){const i=`${r.join("\0")}\0`;await p(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:i})}}if(this.intentToAddPaths.length>0)try{await p(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await q(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const{patch:e}=this,s=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let n;try{await p(s,{cwd:this.workTree,input:e}),this.patch=null;return}catch(r){n=r instanceof j?r.stderr:String(r)}try{await p([...s,"--3way"],{cwd:this.workTree,input:e})}catch(r){const i=r instanceof j&&r.stderr?r.stderr:String(r);throw new X(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
11
+ `;return Buffer.from(r,"utf8")},te=async t=>{const{stdout:e}=await k(["status","--porcelain=v1","-z"],{cwd:t}),s=e.split("\0"),n=[];for(let r=0;r<s.length;r+=1){const i=s[r];if(i===void 0||i.length<4)continue;const o=i.charAt(0),a=i.charAt(1),c=i.slice(3),u=o==="R"||o==="C"||a==="R"||a==="C";o!==" "&&o!=="?"&&a!==" "&&a!=="?"&&n.push(c),u&&(r+=1)}return n},ee=async(t,e)=>{if(t.length===0)return;const s=`${t.join("\0")}\0`;await k(["checkout","--force","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},se=async(t,e)=>{if(await k(["update-index","--again"],{cwd:e.cwd,lenient:!0}),t.length===0)return;const s=`${t.join("\0")}\0`;await k(["add","-u","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:e.cwd,input:s})},re="vis_staged_automatic_backup",wt=()=>`${re}-${process.pid}-${Date.now()}-${Rt(3).toString("hex")}`,ne=async t=>{const e=await $(["stash","create"],{cwd:t});return e.length===0?null:(await k(["stash","store","-m",wt(),e],{cwd:t}),e)},ie=async(t,e)=>{const{exitCode:s,stdout:n}=await k(["reflog","--format=%H %gs","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const r of n.split(/\r?\n/)){const i=r.indexOf(" ");if(i!==-1&&r.slice(i+1).includes(e))return r.slice(0,i)}return null},ae=async t=>{const e=wt(),{exitCode:s,stdout:n}=await k(["stash","push","--keep-index","--include-untracked","--quiet","-m",e],{cwd:t,lenient:!0});if(s!==0)return null;const r=n.trim();return r.length>0&&/no local changes/i.test(r)?null:ie(t,e)},oe=async t=>{const e=await $(["stash","create"],{cwd:t});return e.length===0?"":$(["rev-parse",`${e}^{tree}`],{cwd:t})},ce=async(t,e)=>{const[s,n]=await Promise.all([$(["rev-parse",`${e}^{tree}`],{cwd:t}),$(["rev-parse",`${e}^2^{tree}`],{cwd:t})]);return{indexTree:n,worktreeTree:s}},de=async(t,e)=>{const{exitCode:s,stdout:n}=await k(["reflog","--format=%H %gd","refs/stash"],{cwd:t,lenient:!0});if(s!==0)return null;for(const r of n.split(/\r?\n/)){const[i,o]=r.split(/\s+/,2);if(i===e&&o!==void 0)return o}return null},mt=async(t,e)=>{const{exitCode:s}=await k(["rev-parse","--verify","--quiet",`${e}^{commit}`],{cwd:t,lenient:!0});return s===0},le=async(t,e)=>{const s=await de(t,e);if(s===null)return null;const{exitCode:n,stdout:r}=await k(["rev-parse","--verify","--quiet",s],{cwd:t,lenient:!0});return n===0&&r.trim()===e?s:null},kt=async(t,e)=>{if(e===null)return;const s=await le(t,e);s!==null&&await k(["stash","drop","--quiet",s],{cwd:t})},ue=async(t,e)=>{if(e===null)throw new K("Backup stash was not found — can't revert working tree.");if(!await mt(t,e))throw new K(`Backup stash ${e} is no longer reachable — can't revert working tree.`);await k(["reset","--hard","HEAD"],{cwd:t}),await k(["stash","apply","--index","--quiet",e],{cwd:t})},fe=async(t,e)=>{e!==null&&await mt(t,e)&&(await k(["stash","apply","--quiet",e],{cwd:t}),await kt(t,e))};class he{stagedFiles=[];partiallyStaged=[];workTree="";gitDir="";preTaskIndexTree="";postTaskIndexTree="";headTree="";revertApplied=!1;warnings=[];cwd;options;patch=null;backupStashSha=null;merge=[];shouldStash;shouldHidePartial;shouldHideUnstaged;shouldHideAll;hideAllStashSha=null;intentToAddPaths=[];preTaskUntracked=new Set;constructor(e){this.cwd=e.cwd??process.cwd(),this.options=e,this.shouldStash=e.stash!==!1&&e.diff===void 0,this.shouldHidePartial=e.hidePartiallyStaged!==!1,this.shouldHideUnstaged=e.hideUnstaged===!0,this.shouldHideAll=e.hideAll===!0}async prepare(){if(!await Ht(this.cwd))throw new _(`Not a git repository: ${this.cwd}`);await Xt(this.cwd),this.workTree=await pt(this.cwd),this.gitDir=await zt(this.cwd),this.stagedFiles=await Zt({cwd:this.workTree,diff:this.options.diff,diffFilter:this.options.diffFilter,workTree:this.workTree}),this.partiallyStaged=this.stagedFiles.length===0?[]:await te(this.workTree),this.snapshotMergeState(),this.intentToAddPaths=await Jt(this.workTree),this.intentToAddPaths.length>0&&await Yt(this.intentToAddPaths,{cwd:this.workTree}),this.shouldStash?this.backupStashSha=await ne(this.workTree):this.partiallyStaged.length>0&&this.warnings.push("Running with --no-stash on partially-staged files — unstaged deltas will be captured to a patch, but if re-applying the patch fails after tasks run the changes cannot be recovered."),this.shouldHideAll?this.hideAllStashSha=await ae(this.workTree):await this.hideUnstagedChanges(),this.preTaskIndexTree=this.stagedFiles.length===0?"":await H(this.workTree),this.postTaskIndexTree=this.preTaskIndexTree,this.headTree=await Wt(this.workTree),this.preTaskUntracked=new Set(await et(this.workTree))}async applyModifications({autoStage:e=!1}={}){if(this.stagedFiles.length===0)return;const s=this.stagedFiles.map(n=>x(this.workTree,n));if(await se(s,{cwd:this.workTree}),e){const r=(await et(this.workTree)).filter(i=>!this.preTaskUntracked.has(i));if(r.length>0){const i=`${r.join("\0")}\0`;await k(["add","--pathspec-from-file=-","--pathspec-file-nul","--"],{cwd:this.workTree,input:i})}}if(this.intentToAddPaths.length>0)try{await k(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.postTaskIndexTree=await H(this.workTree)}indexTreeChanged(){return this.preTaskIndexTree.length>0&&this.postTaskIndexTree.length>0&&this.preTaskIndexTree!==this.postTaskIndexTree}postTaskIndexMatchesHead(){return this.postTaskIndexTree.length>0&&this.headTree.length>0&&this.postTaskIndexTree===this.headTree}async restoreUnstagedChanges(){if(this.revertApplied||this.patch===null||this.shouldHideAll)return;const{patch:e}=this,s=["apply","--whitespace=nowarn","--recount","--unidiff-zero"];let n;try{await k(s,{cwd:this.workTree,input:e}),this.patch=null;return}catch(r){n=r instanceof _?r.stderr:String(r)}try{await k([...s,"--3way"],{cwd:this.workTree,input:e})}catch(r){const i=r instanceof _&&r.stderr?r.stderr:String(r);throw new J(`Failed to re-apply unstaged changes after running tasks. Original changes remain in the backup stash — recover with \`git stash list\` and \`git stash apply\`.
12
12
  First attempt: ${n??"(no stderr)"}
13
- Second attempt: ${i}`,{cause:r})}this.patch=null}async releaseBackupIfRestored(){if(this.backupStashSha===null)return;const e=await re(this.workTree,this.backupStashSha),s=await se(this.workTree),n=await q(this.workTree);s!==e.worktreeTree||n!==e.indexTree||await this.dropBackup()}async revertForEmptyCommit(){this.shouldHideAll||await this.revert()}async revert(){if(this.backupStashSha!==null){try{await ae(this.workTree,this.backupStashSha)}catch(e){throw new X("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await this.dropBackup(),this.intentToAddPaths.length>0)try{await p(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),!e&&!this.revertApplied&&await this.restoreUnstagedChanges(),this.hideAllStashSha!==null)try{await oe(this.workTree,this.hideAllStashSha)}catch{}if(!this.revertApplied){if(e){await this.dropBackup();return}await this.releaseBackupIfRestored()}}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(n=>b(this.workTree,n))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(n=>e.has(n)):[];s.length!==0&&(this.patch=await Xt(s,{cwd:this.workTree}),this.patch!==null&&await Yt(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=P(this.gitDir,e);return G(s)?{body:bt(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=P(this.gitDir,e.name);try{e.existed&&e.body!==null?xt(s,e.body):G(s)&&Ct(s)}catch{}}}async dropBackup(){await gt(this.workTree,this.backupStashSha),this.backupStashSha=null}}const de=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},Q=t=>{if(t==="running")return m.jsx(At,{type:"dots"});const e=t==="failed"?ot:t==="skipped"?F:t==="success"?ct:F;return m.jsx(S,{color:de(t),children:e})},tt=({state:t,tick:e,verbose:s})=>m.jsxs($,{flexDirection:"column",children:[[...t.patterns.values()].map(n=>m.jsxs($,{flexDirection:"column",children:[m.jsxs($,{children:[Q(n.status),m.jsxs(S,{children:[" ",n.title]})]}),[...n.commands.values()].map(r=>m.jsxs($,{flexDirection:"column",marginLeft:2,children:[m.jsxs($,{children:[Q(r.status),m.jsxs(S,{children:[" ",r.title," "]}),r.status!=="pending"&&r.status!=="running"?m.jsxs(S,{color:"gray",children:["(",r.durationMs,"ms)"]}):null]}),s&&r.output?m.jsx($,{flexDirection:"column",marginLeft:2,children:r.output.split(/\r?\n/).slice(0,20).map((i,c)=>m.jsx(S,{color:"gray",children:i},`${r.id}-line-${c}`))}):null,r.status==="failed"&&r.error?m.jsx($,{marginLeft:2,children:m.jsx(S,{color:"red",children:r.error.message})}):null]},r.id))]},n.id)),t.infoMessages.map((n,r)=>m.jsx(S,{color:"gray",children:n},`info-${r}`)),t.warnMessages.map((n,r)=>m.jsx(S,{color:"yellow",children:n},`warn-${r}`)),t.errorMessages.map(({message:n},r)=>m.jsx(S,{color:"red",children:n},`err-${r}`))]}),le=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let n=0;const r=$t(m.jsx(tt,{state:s,tick:n,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),i=()=>{n+=1,r.rerender(m.jsx(tt,{state:s,tick:n,verbose:e}))};return{commandEnd({commandId:c,durationMs:a,error:o,output:l,patternId:f,status:d}){const u=s.patterns.get(f)?.commands.get(c);u&&(u.status=d,u.durationMs=a,u.output=l,u.error=o,i())},commandStart({commandId:c,patternId:a}){const o=s.patterns.get(a)?.commands.get(c);o&&(o.status="running",i())},error({error:c,message:a}){s.errorMessages.push({error:c,message:a}),i()},info({message:c}){s.infoMessages.push(c),i()},patternEnd({patternId:c,status:a}){const o=s.patterns.get(c);o&&(o.status=a,i())},patternStart({patternId:c}){const a=s.patterns.get(c);a&&(a.status="running",i())},start({patterns:c}){s.started=!0;for(const a of c){const o=new Map;for(const l of a.commands)o.set(l.id,{durationMs:0,id:l.id,status:"pending",title:l.title});s.patterns.set(a.id,{commands:o,id:a.id,status:"pending",title:a.title})}i()},async stop(){r.unmount(),await r.waitUntilExit()},warn({message:c}){s.warnMessages.push(c),i()}}},et=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,n=new Map,r=new Map,i=a=>{e||process.stderr.write(`${a}
14
- `)},c=a=>{switch(a){case"failed":return L(ot);case"running":return D(">");case"skipped":return z(F);case"success":return It(ct);default:return E(F)}};return{commandEnd({commandId:a,durationMs:o,error:l,output:f,status:d}){const u=r.get(a)??a,g=E(`(${o}ms)`);if(i(` ${c(d)} ${u} ${g}`),d==="failed"&&l&&i(E(l.message)),(d==="failed"||s)&&f&&f.trim().length>0)for(const h of f.split(/\r?\n/))i(` ${E(h)}`)},commandStart({commandId:a}){if(!s)return;const o=r.get(a)??a;i(` ${E("…")} ${o}`)},error({error:a,message:o}){e?process.stderr.write(`${L(o)}
15
- `):i(L(o)),a?.stack&&(s||!e)&&process.stderr.write(`${E(a.stack)}
16
- `)},info({message:a}){i(E(a))},patternEnd({patternId:a,status:o}){const l=n.get(a)??a;i(`${c(o)} ${l}`)},patternStart({patternId:a}){const o=n.get(a)??a;i(`${D(">")} ${o}`)},start({patterns:a}){if(a.length===0){i(E("No staged files matched any pattern."));return}const o=new Set(a.flatMap(l=>l.files)).size;i(`${D(">")} Running staged tasks on ${o} file${o===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const l of a){n.set(l.id,l.title);for(const f of l.commands)r.set(f.id,f.title)}},stop(){},warn({message:a}){i(z(a))}}},ue=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return et({quiet:t.quiet,verbose:t.verbose});try{return le({verbose:t.verbose})}catch{return et({quiet:t.quiet,verbose:t.verbose})}},fe=t=>{const e=[];let s="",n=!1,r=!1;for(let i=0;i<t.length;i+=1){const c=t[i];if(c===void 0)break;if(c==="\\"&&!n&&i+1<t.length){const a=t[i+1];if(a!==void 0){r&&a!=='"'&&a!=="\\"&&(s+=c),s+=a,i+=1;continue}}if(c==='"'&&!n){r=!r;continue}if(c==="'"&&!r){n=!n;continue}if(!n&&!r&&/\s/.test(c)){s.length>0&&(e.push(s),s="");continue}s+=c}if(n||r)throw new T(`Unterminated ${n?"single":"double"} quote in command: ${t}`);return s.length>0&&e.push(s),e},pt=process.platform==="win32"?28e3:131072,he=(t,e,s)=>{const n=[];let r=[],i=e;const c=s<=0?pt:s;for(const a of t){const o=Buffer.byteLength(a)+1;r.length>0&&i+o>c&&(n.push(r),r=[],i=e),r.push(a),i+=o}return r.length>0&&n.push(r),n},ge=async(t,e,s)=>{const n=fe(t);if(n.length===0)throw new A(t,"Empty command for staged task.");const[r,...i]=n;if(r===void 0)throw new A(t,"Empty command for staged task.");const c=Buffer.byteLength(r)+i.reduce((f,d)=>f+Buffer.byteLength(d)+1,0),a=s.verbatim===!0?[[]]:he(e,c,s.maxArgLength??pt),o=Date.now(),l=[];for(const f of a){if(s.signal?.aborted===!0)throw new A(t,"Task aborted by earlier failure.");const d=at(r,[...i,...f],{nodeOptions:{cwd:s.cwd,env:pe(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),u=await d,g=[u.stdout,u.stderr].filter(w=>w.length>0).join(`
17
- `);g.length>0&&l.push(g);const h=d.process?.signalCode??null;if(d.aborted||h!==null||u.exitCode===void 0){const w=d.aborted?"Task aborted by earlier failure.":h===null?g.trim()||"Task exited without a numeric status code.":`Task killed by signal ${h}.`;throw new A(t,w)}if(u.exitCode!==0)throw new A(t,g.trim()||`Exit code ${u.exitCode} from ${r}`)}return{durationMs:Date.now()-o,output:l.join(`
18
- `)}},pe=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const n=t?{...s,...t}:s;return Mt(n,e)},we=async(t,e,s)=>{const n=ke(s.concurrent,t.length),r=[],i=new AbortController;let c=!1,a=0;const o=()=>{c||(c=!0,s.continueOnError||i.abort())};s.externalSignal&&(s.externalSignal.aborted?o():s.externalSignal.addEventListener("abort",()=>{o()},{once:!0}));const l=h=>{for(const w of h.commands)e.commandEnd({commandId:w.id,durationMs:0,patternId:h.id,status:"skipped"})},f=async h=>{if(c){l(h),e.patternEnd({patternId:h.id,status:"skipped"});return}e.patternStart({patternId:h.id});let w="success";for(const k of h.commands){if(c){e.commandEnd({commandId:k.id,durationMs:0,patternId:h.id,status:"skipped"}),w=w==="success"?"skipped":w;continue}e.commandStart({commandId:k.id,patternId:h.id});const C=await me(k,s,i.signal),v=C.status==="failed"&&i.signal.aborted?{...C,status:"skipped"}:C;if(e.commandEnd({commandId:k.id,durationMs:v.durationMs,error:v.error,output:v.output,patternId:h.id,status:v.status}),v.status==="failed"){r.push(k.title),w="failed",o();break}if(v.status==="skipped"){w=w==="success"?"skipped":w;break}}e.patternEnd({patternId:h.id,status:w})},d=async()=>{for(;a<t.length;){const h=t[a];a+=1,h&&await f(h)}},u=[];for(let h=0;h<Math.min(n,t.length);h+=1)u.push(d());await Promise.all(u);const g=s.externalSignal?.aborted===!0;return{failedCommands:r,success:r.length===0&&!g}},me=async(t,e,s)=>{const n=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-n,status:"success"};if(t.command){const r=await ge(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s,verbatim:t.verbatim===!0});return{durationMs:r.durationMs,output:e.verbose?r.output:void 0,status:"success"}}return{durationMs:Date.now()-n,error:new A(t.title,"Command has no invocation target."),status:"failed"}}catch(r){const i=r instanceof Error?r:new Error(String(r));return{durationMs:Date.now()-n,error:i,output:i instanceof A?i.message:void 0,status:"failed"}}},ke=(t,e)=>{if(t===!1)return 1;if(t===!0){const n=Math.max(1,typeof W=="function"?W():4);return Math.min(Math.max(1,e),n)}const s=Math.floor(t);return s>0?s:1},ye=!0,Te=t=>{try{return!Tt(t)}catch{return!1}},ve=t=>{try{const e=vt(t);return e?St(t,e).map(s=>P(t,s)):[]}catch{return[]}},Se=async(t={})=>{const e=t.cwd??process.cwd(),s=await ue(t),n=await Nt(t);typeof n!="function"&&K(n);const r=new ce({...t,cwd:e}),i=new AbortController;let c=!1;const a=d=>{if(c){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,d);return}c=!0,s.warn({message:`Received ${d} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()};process.on("SIGINT",a),process.on("SIGTERM",a);let o={failedCommands:[],ranTasks:!1,success:!0},l=!1,f=!1;try{await r.prepare(),l=!0;for(const C of r.warnings)s.warn({message:C});if(r.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const d=Te(e),u=_t(r.stagedFiles,t.ignore,e,{caseInsensitive:d});if(u.length===0&&r.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const g=typeof n=="function"?K(await n([...u])):n,h=await Ot({caseInsensitive:d,config:g,cwd:e,files:u,relative:t.relative,workspacePackages:ve(e)});if(s.start({patterns:h}),h.length===0)return s.info({message:"No staged files matched any pattern."}),f=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:w,success:k}=await we(h,s,{concurrent:t.concurrent??ye,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:i.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(o={failedCommands:w,ranTasks:!0,success:k},k){if(t.diff===void 0&&(await r.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&r.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),o={failedCommands:[...w],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&r.postTaskIndexMatchesHead()))throw await r.revertForEmptyCommit(),new Rt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else t.revert===!0&&(s.info({message:"Reverting working tree from backup stash."}),await r.revert());return await r.restoreUnstagedChanges(),f=o.success,o}catch(d){const u=d instanceof Error?d.message:String(d),g=d instanceof Error?d:new Error(u);if(s.error({error:g,message:u}),d instanceof I)return{failedCommands:o.failedCommands,ranTasks:o.ranTasks,success:!1};throw d}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),l){try{await r.cleanup(f)}catch(u){s.error({error:u,message:"Cleanup failed."})}const d=f?null:r.recoveryHint();d&&s.warn({message:d})}await s.stop()}},be="VIS_STAGED_CONCURRENT",st=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},xe=(t,e)=>{const s={};e!==void 0&&(s.config=e);const n=y=>t[y]===void 0?void 0:!!t[y],r=y=>{const N=t[y];return typeof N=="string"&&N.length>0?N:void 0},i=n("allow-empty");i!==void 0&&(s.allowEmpty=i);const c=n("auto-stage");c!==void 0&&(s.autoStage=c);const a=n("continue-on-error");a!==void 0&&(s.continueOnError=a);const o=n("debug");o!==void 0&&(s.debug=o);const l=n("fail-on-changes");l!==void 0&&(s.failOnChanges=l);const f=n("hide-partially-staged");f!==void 0&&(s.hidePartiallyStaged=f);const d=n("hide-unstaged");d!==void 0&&(s.hideUnstaged=d);const u=n("quiet");u!==void 0&&(s.quiet=u);const g=n("relative");g!==void 0&&(s.relative=g);const h=n("revert");h!==void 0&&(s.revert=h);const w=n("stash");w!==void 0&&(s.stash=w);const k=n("verbose");k!==void 0&&(s.verbose=k);const C=r("cwd");C!==void 0&&(s.cwd=C);const v=r("diff");v!==void 0&&(s.diff=v);const H=r("diff-filter");if(H!==void 0&&(s.diffFilter=H),n("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const y=process.env[be];y!==void 0&&(s.concurrent=st(y.trim()))}else{const{concurrent:y}=t;s.concurrent=st(typeof y=="string"?y:typeof y=="number"||typeof y=="boolean"?String(y):"")}return s},Ne=async({options:t,visConfig:e})=>{const n=(e??{}).staged;if(!n)throw new Error(`No "staged" config found in vis.config.ts. Add one:
13
+ Second attempt: ${i}`,{cause:r})}this.patch=null}async releaseBackupIfRestored(){if(this.backupStashSha===null)return;const e=await ce(this.workTree,this.backupStashSha),s=await oe(this.workTree),n=await H(this.workTree);s!==e.worktreeTree||n!==e.indexTree||await this.dropBackup()}async revertForEmptyCommit(){this.shouldHideAll||await this.revert()}async revert(){if(this.backupStashSha!==null){try{await ue(this.workTree,this.backupStashSha)}catch(e){throw new J("Revert failed while restoring the backup stash. Use `git stash list` to recover manually.",{cause:e})}if(await this.dropBackup(),this.intentToAddPaths.length>0)try{await k(["add","--intent-to-add","--",...this.intentToAddPaths],{cwd:this.workTree})}catch{}this.revertApplied=!0}}async cleanup(e){if(this.restoreMergeState(),!e&&!this.revertApplied&&await this.restoreUnstagedChanges(),this.hideAllStashSha!==null)try{await fe(this.workTree,this.hideAllStashSha)}catch{}if(!this.revertApplied){if(e){await this.dropBackup();return}await this.releaseBackupIfRestored()}}recoveryHint(){return this.backupStashSha===null?null:`Backup stash is preserved (sha ${this.backupStashSha.slice(0,7)}) — restore with: git stash apply --index ${this.backupStashSha}`}async hideUnstagedChanges(){const e=new Set(this.stagedFiles.map(n=>x(this.workTree,n))),s=this.shouldHideUnstaged?[...e]:this.shouldHidePartial?this.partiallyStaged.filter(n=>e.has(n)):[];s.length!==0&&(this.patch=await Qt(s,{cwd:this.workTree}),this.patch!==null&&await ee(s,{cwd:this.workTree}))}snapshotMergeState(){this.gitDir.length!==0&&(this.merge=["MERGE_HEAD","MERGE_MODE","MERGE_MSG"].map(e=>{const s=N(this.gitDir,e);return W(s)?{body:At(s),existed:!0,name:e}:{body:null,existed:!1,name:e}}))}restoreMergeState(){if(!(this.gitDir.length===0||this.merge.length===0))for(const e of this.merge){const s=N(this.gitDir,e.name);try{e.existed&&e.body!==null?It(s,e.body):W(s)&&Mt(s)}catch{}}}async dropBackup(){await kt(this.workTree,this.backupStashSha),this.backupStashSha=null}}const ge=t=>{switch(t){case"failed":return"red";case"running":return"cyan";case"skipped":return"yellow";case"success":return"green";default:return"gray"}},st=t=>{if(t==="running")return v.jsx(Ot,{type:"dots"});const e=t==="failed"?lt:t==="skipped"?D:t==="success"?ut:D;return v.jsx(C,{color:ge(t),children:e})},rt=({state:t,tick:e,verbose:s})=>v.jsxs(I,{flexDirection:"column",children:[[...t.patterns.values()].map(n=>v.jsxs(I,{flexDirection:"column",children:[v.jsxs(I,{children:[st(n.status),v.jsxs(C,{children:[" ",n.title]})]}),[...n.commands.values()].map(r=>v.jsxs(I,{flexDirection:"column",marginLeft:2,children:[v.jsxs(I,{children:[st(r.status),v.jsxs(C,{children:[" ",r.title," "]}),r.status!=="pending"&&r.status!=="running"?v.jsxs(C,{color:"gray",children:["(",r.durationMs,"ms)"]}):null]}),s&&r.output?v.jsx(I,{flexDirection:"column",marginLeft:2,children:r.output.split(/\r?\n/).slice(0,20).map((i,o)=>v.jsx(C,{color:"gray",children:i},`${r.id}-line-${o}`))}):null,r.status==="failed"&&r.error?v.jsx(I,{marginLeft:2,children:v.jsx(C,{color:"red",children:r.error.message})}):null]},r.id))]},n.id)),t.infoMessages.map((n,r)=>v.jsx(C,{color:"gray",children:n},`info-${r}`)),t.warnMessages.map((n,r)=>v.jsx(C,{color:"yellow",children:n},`warn-${r}`)),t.errorMessages.map(({message:n},r)=>v.jsx(C,{color:"red",children:n},`err-${r}`))]}),pe=(t={})=>{const e=t.verbose===!0,s={errorMessages:[],infoMessages:[],patterns:new Map,started:!1,warnMessages:[]};let n=0;const r=jt(v.jsx(rt,{state:s,tick:n,verbose:e}),{exitOnCtrlC:!1,stdout:process.stderr}),i=()=>{n+=1,r.rerender(v.jsx(rt,{state:s,tick:n,verbose:e}))};return{commandEnd({commandId:o,durationMs:a,error:c,output:u,patternId:m,status:f}){const w=s.patterns.get(m)?.commands.get(o);w&&(w.status=f,w.durationMs=a,w.output=u,w.error=c,i())},commandStart({commandId:o,patternId:a}){const c=s.patterns.get(a)?.commands.get(o);c&&(c.status="running",i())},error({error:o,message:a}){s.errorMessages.push({error:o,message:a}),i()},info({message:o}){s.infoMessages.push(o),i()},patternEnd({patternId:o,status:a}){const c=s.patterns.get(o);c&&(c.status=a,i())},patternStart({patternId:o}){const a=s.patterns.get(o);a&&(a.status="running",i())},start({patterns:o}){s.started=!0;for(const a of o){const c=new Map;for(const u of a.commands)c.set(u.id,{durationMs:0,id:u.id,status:"pending",title:u.title});s.patterns.set(a.id,{commands:c,id:a.id,status:"pending",title:a.title})}i()},async stop(){r.unmount(),await r.waitUntilExit()},warn({message:o}){s.warnMessages.push(o),i()}}},nt=(t={})=>{const{quiet:e=!1,verbose:s=!1}=t,n=new Map,r=new Map,i=a=>{e||process.stderr.write(`${a}
14
+ `)},o=a=>{switch(a){case"failed":return U(lt);case"running":return B(">");case"skipped":return V(D);case"success":return Pt(ut);default:return E(D)}};return{commandEnd({commandId:a,durationMs:c,error:u,output:m,status:f}){const w=r.get(a)??a,S=E(`(${c}ms)`);if(i(` ${o(f)} ${w} ${S}`),f==="failed"&&u&&i(E(u.message)),(f==="failed"||s)&&m&&m.trim().length>0)for(const l of m.split(/\r?\n/))i(` ${E(l)}`)},commandStart({commandId:a}){if(!s)return;const c=r.get(a)??a;i(` ${E("…")} ${c}`)},error({error:a,message:c}){e?process.stderr.write(`${U(c)}
15
+ `):i(U(c)),a?.stack&&(s||!e)&&process.stderr.write(`${E(a.stack)}
16
+ `)},info({message:a}){i(E(a))},patternEnd({patternId:a,status:c}){const u=n.get(a)??a;i(`${o(c)} ${u}`)},patternStart({patternId:a}){const c=n.get(a)??a;i(`${B(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(E("No staged files matched any pattern."));return}const c=new Set(a.flatMap(u=>u.files)).size;i(`${B(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const u of a){n.set(u.id,u.title);for(const m of u.commands)r.set(m.id,m.title)}},stop(){},warn({message:a}){i(V(a))}}},we=async t=>{const{env:e}=process;if(t.debug===!0||t.quiet===!0||e.NODE_ENV==="test"||e.TERM==="dumb"||e.CI!==void 0||!process.stderr.isTTY)return nt({quiet:t.quiet,verbose:t.verbose});try{return pe({verbose:t.verbose})}catch{return nt({quiet:t.quiet,verbose:t.verbose})}},me=t=>{try{return Ct(t)}catch(e){throw new b(e.message)}},yt=process.platform==="win32"?28e3:131072,ke=(t,e,s)=>{const n=[];let r=[],i=e;const o=s<=0?yt:s;for(const a of t){const c=Buffer.byteLength(a)+1;r.length>0&&i+c>o&&(n.push(r),r=[],i=e),r.push(a),i+=c}return r.length>0&&n.push(r),n},ye=async(t,e,s)=>{const n=me(t);if(n.length===0)throw new M(t,"Empty command for staged task.");const[r,...i]=n;if(r===void 0)throw new M(t,"Empty command for staged task.");const o=Buffer.byteLength(r)+i.reduce((m,f)=>m+Buffer.byteLength(f)+1,0),a=s.verbatim===!0?[[]]:ke(e,o,s.maxArgLength??yt),c=Date.now(),u=[];for(const m of a){if(s.signal?.aborted===!0)throw new M(t,"Task aborted by earlier failure.");const f=dt(r,[...i,...m],{nodeOptions:{cwd:s.cwd,env:Te(s.env,s.cwd),killSignal:s.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...s.signal===void 0?{}:{signal:s.signal}}),w=await f,S=[w.stdout,w.stderr].filter(d=>d.length>0).join(`
17
+ `);S.length>0&&u.push(S);const l=f.process?.signalCode??null;if(f.aborted||l!==null||w.exitCode===void 0){const d=f.aborted?"Task aborted by earlier failure.":l===null?S.trim()||"Task exited without a numeric status code.":`Task killed by signal ${l}.`;throw new M(t,d)}if(w.exitCode!==0)throw new M(t,S.trim()||`Exit code ${w.exitCode} from ${r}`)}return{durationMs:Date.now()-c,output:u.join(`
18
+ `)}},Te=(t,e)=>{const s={...process.env};process.stderr.isTTY&&s.FORCE_COLOR===void 0&&s.NO_COLOR===void 0&&(s.FORCE_COLOR="1");const n=t?{...s,...t}:s;return _t(n,e)},ve=async(t,e,s)=>{const n=be(s.concurrent,t.length),r=[],i=new AbortController;let o=!1,a=0;const c=()=>{o||(o=!0,s.continueOnError||i.abort())};s.externalSignal&&(s.externalSignal.aborted?c():s.externalSignal.addEventListener("abort",()=>{c()},{once:!0}));const u=d=>{for(const h of d.commands)e.commandEnd({commandId:h.id,durationMs:0,patternId:d.id,status:"skipped"})},m=async d=>{if(o){u(d),e.patternEnd({patternId:d.id,status:"skipped"});return}e.patternStart({patternId:d.id});let h="success";for(const g of d.commands){if(o){e.commandEnd({commandId:g.id,durationMs:0,patternId:d.id,status:"skipped"}),h=h==="success"?"skipped":h;continue}e.commandStart({commandId:g.id,patternId:d.id});const p=await Se(g,s,i.signal),y=p.status==="failed"&&i.signal.aborted?{...p,status:"skipped"}:p;if(e.commandEnd({commandId:g.id,durationMs:y.durationMs,error:y.error,output:y.output,patternId:d.id,status:y.status}),y.status==="failed"){r.push(g.title),h="failed",c();break}if(y.status==="skipped"){h=h==="success"?"skipped":h;break}}e.patternEnd({patternId:d.id,status:h})},f=async()=>{for(;a<t.length;){const d=t[a];a+=1,d&&await m(d)}};for(;a<t.length&&t[a]?.prerequisite===!0;){const d=t[a];a+=1,await m(d)}const w=[],S=Math.min(n,t.length-a);for(let d=0;d<S;d+=1)w.push(f());await Promise.all(w);const l=s.externalSignal?.aborted===!0;return{failedCommands:r,success:r.length===0&&!l}},Se=async(t,e,s)=>{const n=Date.now();try{if(t.source==="custom"&&t.run)return await t.run([...t.files]),{durationMs:Date.now()-n,status:"success"};if(t.command){const r=await ye(t.command,t.files,{cwd:t.cwd??e.cwd,killSignal:e.killSignal,maxArgLength:e.maxArgLength,signal:s,verbatim:t.verbatim===!0});return{durationMs:r.durationMs,output:e.verbose?r.output:void 0,status:"success"}}return{durationMs:Date.now()-n,error:new M(t.title,"Command has no invocation target."),status:"failed"}}catch(r){const i=r instanceof Error?r:new Error(String(r));return{durationMs:Date.now()-n,error:i,output:i instanceof M?i.message:void 0,status:"failed"}}},be=(t,e)=>{if(t===!1)return 1;if(t===!0){const n=Math.max(1,typeof X=="function"?X():4);return Math.min(Math.max(1,e),n)}const s=Math.floor(t);return s>0?s:1},xe=!0,Ce=t=>{try{return!xt(t)}catch{return!1}},$e=t=>{try{const e=$t(t);return e?Et(t,e).map(s=>N(t,s)):[]}catch{return[]}},Ee=async(t={})=>{const e=t.cwd??process.cwd(),s=await we(t),n=await Ut(t);typeof n!="function"&&Z(n);const r=new he({...t,cwd:e}),i=new AbortController;let o=!1;const a=f=>{if(o){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,f);return}o=!0,s.warn({message:`Received ${f} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()};process.on("SIGINT",a),process.on("SIGTERM",a);let c={failedCommands:[],ranTasks:!1,success:!0},u=!1,m=!1;try{await r.prepare(),u=!0;for(const g of r.warnings)s.warn({message:g});if(r.stagedFiles.length===0)return t.allowEmpty!==!0&&s.info({message:"No staged files found."}),m=!0,{failedCommands:[],ranTasks:!1,success:!0};const f=Ce(e),w=Dt(r.stagedFiles,t.ignore,e,{caseInsensitive:f});if(w.length===0&&r.stagedFiles.length>0)return s.info({message:"Every staged file was excluded by the `ignore` list."}),m=!0,{failedCommands:[],ranTasks:!1,success:!0};const S=typeof n=="function"?Z(await n([...w])):n,l=await Bt({caseInsensitive:f,config:S,cwd:e,files:w,relative:t.relative,visEntry:[process.execPath,process.argv[1]??"vis"],warn:g=>{s.warn({message:g})},workspacePackages:$e(e)});if(s.start({patterns:l}),l.length===0)return s.info({message:"No staged files matched any pattern."}),m=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:d,success:h}=await ve(l,s,{concurrent:t.concurrent??xe,continueOnError:t.continueOnError===!0,cwd:e,externalSignal:i.signal,killSignal:t.killSignal,maxArgLength:t.maxArgLength,verbose:t.verbose});if(c={failedCommands:d,ranTasks:!0,success:h},h){if(t.diff===void 0&&(await r.applyModifications({autoStage:t.autoStage===!0}),t.failOnChanges===!0&&r.indexTreeChanged()&&(s.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),c={failedCommands:[...d],ranTasks:!0,success:!1}),t.allowEmpty!==!0&&r.postTaskIndexMatchesHead()))throw await r.revertForEmptyCommit(),new Ft("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else t.revert===!0&&(s.info({message:"Reverting working tree from backup stash."}),await r.revert());return await r.restoreUnstagedChanges(),m=c.success,c}catch(f){const w=f instanceof Error?f.message:String(f),S=f instanceof Error?f:new Error(w);if(s.error({error:S,message:w}),f instanceof R)return{failedCommands:c.failedCommands,ranTasks:c.ranTasks,success:!1};throw f}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),u){try{await r.cleanup(m)}catch(w){s.error({error:w,message:"Cleanup failed."})}const f=m?null:r.recoveryHint();f&&s.warn({message:f})}await s.stop()}},Ae="VIS_STAGED_CONCURRENT",it=t=>{const e=t.trim();if(e==="true"||e==="")return!0;if(e==="false")return!1;const s=Number(e);return Number.isNaN(s)?!0:s},Ie=(t,e)=>{const s={};e!==void 0&&(s.config=e);const n=T=>t[T]===void 0?void 0:!!t[T],r=T=>{const j=t[T];return typeof j=="string"&&j.length>0?j:void 0},i=n("allow-empty");i!==void 0&&(s.allowEmpty=i);const o=n("auto-stage");o!==void 0&&(s.autoStage=o);const a=n("continue-on-error");a!==void 0&&(s.continueOnError=a);const c=n("debug");c!==void 0&&(s.debug=c);const u=n("fail-on-changes");u!==void 0&&(s.failOnChanges=u);const m=n("hide-partially-staged");m!==void 0&&(s.hidePartiallyStaged=m);const f=n("hide-unstaged");f!==void 0&&(s.hideUnstaged=f);const w=n("quiet");w!==void 0&&(s.quiet=w);const S=n("relative");S!==void 0&&(s.relative=S);const l=n("revert");l!==void 0&&(s.revert=l);const d=n("stash");d!==void 0&&(s.stash=d);const h=n("verbose");h!==void 0&&(s.verbose=h);const g=r("cwd");g!==void 0&&(s.cwd=g);const p=r("diff");p!==void 0&&(s.diff=p);const y=r("diff-filter");if(y!==void 0&&(s.diffFilter=y),n("force-kill")===!0&&(s.killSignal="SIGKILL"),t.concurrent===void 0){const T=process.env[Ae];T!==void 0&&(s.concurrent=it(T.trim()))}else{const{concurrent:T}=t;s.concurrent=it(typeof T=="string"?T:typeof T=="number"||typeof T=="boolean"?String(T):"")}return s},Be=async({options:t,visConfig:e})=>{const n=(e??{}).staged;if(!n)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
19
 
20
20
  // vis.config.ts
21
21
  import { defineConfig } from "@visulima/vis/config";
@@ -24,4 +24,4 @@ Second attempt: ${i}`,{cause:r})}this.patch=null}async releaseBackupIfRestored()
24
24
  staged: { '*': 'vis check --fix' },
25
25
  });
26
26
 
27
- Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await Se(xe(t,n))).success||(process.exitCode=1)};export{xe as buildRunOptions,Ne as default};
27
+ Migrating from lint-staged or nano-staged? Run \`vis migrate lint-staged\` (or \`vis migrate nano-staged\`) to move the config in and remove the legacy files.`);(await Ee(Ie(t,n))).success||(process.exitCode=1)};export{Ie as buildRunOptions,Be as default};
@@ -1,3 +1,3 @@
1
- import{createRequire as Ne}from"node:module";import{C as W,M as Ce,L as ze,N as Ge,K as $e,P as We,Q as Ve,q as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{r as p,j as e,X as s,O as o,R as He}from"../packem_shared/registry-Bd3v810N.js";import{d as Ke}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{h as Je,e as le,z as Ye,m as Qe}from"../packem_shared/index-0dnGN3GP.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{h as et}from"../packem_shared/env-B-rXCpnL.js";import{n as tt,a as ot}from"../packem_shared/tabs-Zg0TBeDz.js";let Re;const _e=i=>(Re??=Ne(import.meta.url))(i),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=i=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(i)}return _e(i)},{writeFileSync:qe}=Be("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(Je,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),V=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],nt=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ze(t))return null;const n=Ye(t),c=rt(n),l=c!==n;let r;try{r=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:l}},it=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");et(c),qe(l,`${JSON.stringify(t,null,2)}
1
+ import{createRequire as Ne}from"node:module";import{C as W,M as Ce,L as ze,N as Ge,K as $e,P as We,Q as Ve,q as Ue}from"./cli-main.js";import{i as Xe}from"../packem_shared/index-BjdW45xX.js";import{r as p,j as e,X as s,O as o,R as He}from"../packem_shared/registry-CyYhBUaF.js";import{d as Ke}from"../packem_shared/pm-runner-BXRi4ZM9.js";import{h as Je,e as le,z as Ye,m as Qe}from"../packem_shared/index-0dnGN3GP.js";import{y as Ze}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";import{h as et}from"../packem_shared/env-D3wteXlq.js";import{n as tt,a as ot}from"../packem_shared/tabs-K9dH5Qdu.js";let Re;const _e=i=>(Re??=Ne(import.meta.url))(i),J=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Be=i=>{if(typeof J<"u"&&J.versions&&J.versions.node){const[t,n]=J.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return J.getBuiltinModule(i)}return _e(i)},{writeFileSync:qe}=Be("node:fs"),rt=(i,{whitespace:t=!0}={})=>i.replace(Je,n=>n.startsWith('"')||n[1]==="*"&&!n.endsWith("*/")?n:t?n.replaceAll(/\S/g," "):""),V=[{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js",postCreateCommand:"npm install"},description:"Node.js 22 with Git and GitHub CLI",id:"node",name:"Node.js"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",mounts:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],name:"Node.js + pnpm Monorepo",postCreateCommand:"corepack enable && pnpm install",remoteUser:"node",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js 22 with pnpm, corepack, and optimized volume mounts",id:"node-pnpm",name:"Node.js + pnpm"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",forwardPorts:[3e3,5432],name:"Node.js + PostgreSQL",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js with PostgreSQL via Docker Compose",id:"node-postgres",name:"Node.js + PostgreSQL"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{}},forwardPorts:[3e3],image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"Node.js + Docker",postCreateCommand:"npm install"},description:"Node.js 22 with Docker-in-Docker for container workflows",id:"node-dind",name:"Node.js + Docker-in-Docker"},{config:{customizations:{vscode:{extensions:["dbaeumer.vscode-eslint","esbenp.prettier-vscode","ms-azuretools.vscode-docker"]}},dockerComposeFile:"docker-compose.yml",features:{"ghcr.io/devcontainers/features/docker-in-docker:2":{}},forwardPorts:[3e3,5432,6379],name:"Full Stack",postCreateCommand:"npm install",service:"app",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}"},description:"Node.js + PostgreSQL + Redis + Docker via Compose",id:"fullstack",name:"Full Stack"},{config:{customizations:{vscode:{extensions:["ms-python.python","ms-python.vscode-pylance"],settings:{"editor.formatOnSave":!0,"python.defaultInterpreterPath":"/usr/local/bin/python"}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/github-cli:1":{},"ghcr.io/devcontainers/features/python:1":{version:"3.12"}},forwardPorts:[8e3],image:"mcr.microsoft.com/devcontainers/python:3.12",name:"Python",postCreateCommand:"pip install -r requirements.txt || true"},description:"Python 3.12 with pip and venv",id:"python",name:"Python"},{config:{customizations:{vscode:{extensions:["golang.go"],settings:{"editor.formatOnSave":!0,"go.toolsManagement.autoUpdate":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/go:1":{version:"1.22"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/go:1.22",name:"Go",postCreateCommand:"go mod download || true"},description:"Go 1.22 development environment",id:"go",name:"Go"},{config:{customizations:{vscode:{extensions:["rust-lang.rust-analyzer","tamasfe.even-better-toml"],settings:{"editor.formatOnSave":!0}}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/rust:1":{}},image:"mcr.microsoft.com/devcontainers/rust:latest",name:"Rust",postCreateCommand:"cargo build || true"},description:"Rust development with cargo and rust-analyzer",id:"rust",name:"Rust"},{config:{customizations:{vscode:{extensions:["vscjava.vscode-java-pack","vscjava.vscode-maven"]}},features:{"ghcr.io/devcontainers/features/git:1":{},"ghcr.io/devcontainers/features/java:1":{version:"17"}},forwardPorts:[8080],image:"mcr.microsoft.com/devcontainers/java:17",name:"Java",postCreateCommand:"./mvnw install || ./gradlew build || true"},description:"Java 17 with Maven/Gradle support",id:"java",name:"Java"},{config:{customizations:{vscode:{extensions:["ms-azuretools.vscode-docker","ms-kubernetes-tools.vscode-kubernetes-tools","hashicorp.terraform"]}},features:{"ghcr.io/devcontainers/features/aws-cli:1":{},"ghcr.io/devcontainers/features/azure-cli:1":{},"ghcr.io/devcontainers/features/docker-in-docker:2":{},"ghcr.io/devcontainers/features/kubectl-helm-minikube:1":{},"ghcr.io/devcontainers/features/terraform:1":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"DevOps"},description:"Docker, Kubernetes, Terraform, AWS & Azure CLIs",id:"devops",name:"DevOps"},{config:{features:{"ghcr.io/devcontainers/features/common-utils:2":{}},image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Minimal",remoteUser:"vscode"},description:"Bare Ubuntu with common utilities",id:"minimal",name:"Minimal"},{config:{image:"mcr.microsoft.com/devcontainers/base:ubuntu",name:"Custom"},description:"Minimal Ubuntu base - configure from scratch",id:"custom",name:"Custom (Blank)"}],nt=i=>{const t=le(i,".devcontainer","devcontainer.json");if(!Ze(t))return null;const n=Ye(t),c=rt(n),l=c!==n;let r;try{r=JSON.parse(c)}catch(a){const m=a instanceof Error?a.message:String(a);throw new Error(`Failed to parse ${t}: ${m}`,{cause:a})}return{config:r,hadComments:l}},it=(i,t,n)=>{const c=n?Qe(n):le(i,".devcontainer"),l=n??le(c,"devcontainer.json");et(c),qe(l,`${JSON.stringify(t,null,2)}
2
2
  `,"utf8")},st={bun:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-bun-cache",target:"/home/node/.bun/install/cache",type:"volume"}],npm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-npm-cache",target:"/home/node/.npm",type:"volume"}],pnpm:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-pnpm-store",target:"/home/node/.local/share/pnpm/store",type:"volume"}],yarn:[{source:"${localWorkspaceFolderBasename}-node_modules",target:"${containerWorkspaceFolder}/node_modules",type:"volume"},{source:"${localWorkspaceFolderBasename}-yarn-cache",target:"/home/node/.yarn/cache",type:"volume"}]},ct=[{featureMatch:"docker-in-docker",mounts:[]},{featureMatch:"docker-outside-of-docker",mounts:[{source:"/var/run/docker.sock",target:"/var/run/docker.sock",type:"bind"}]},{featureMatch:"/features/git:",mounts:[{source:"${localWorkspaceFolderBasename}-git-config",target:"/home/node/.gitconfig",type:"volume"}]}],pe=(i,t,n)=>{const c=[],l=new Set(n.map(a=>typeof a=="string"?a:a.target));if(i)for(const a of st[i])l.has(a.target)||c.push(a);const r=Object.keys(t);for(const{featureMatch:a,mounts:m}of ct)if(r.some(g=>g.includes(a)))for(const g of m)l.has(g.target)||c.push(g);return c},_=["general","features","ports","lifecycle","extensions","environment","mounts","compose"],Y=i=>structuredClone(i);class lt{#r=new Set;#e;constructor(t,n,c=null){const l=t===null,r=t??{name:""},a=Y(r);this.#e={config:a,detectedPm:c,extensionSearch:"",featureSearch:"",fieldEditing:!1,fieldIndex:0,hadComments:n,isDirty:!1,mode:l?"create":"edit",originalConfig:l?null:Y(r),section:"general",showTemplateSelector:l,suggestedMounts:pe(c,a.features??{},a.mounts??[]),templateIndex:0}}getSnapshot=()=>this.#e;subscribe=t=>(this.#r.add(t),()=>{this.#r.delete(t)});setSection(t){t!==this.#e.section&&this.#t({...this.#e,fieldEditing:!1,fieldIndex:0,section:t})}nextSection(){const n=(_.indexOf(this.#e.section)+1)%_.length;this.setSection(_[n])}previousSection(){const n=(_.indexOf(this.#e.section)-1+_.length)%_.length;this.setSection(_[n])}setFieldIndex(t){t!==this.#e.fieldIndex&&this.#t({...this.#e,fieldIndex:Math.max(0,t)})}setFieldEditing(t){t!==this.#e.fieldEditing&&this.#t({...this.#e,fieldEditing:t})}setTemplateIndex(t){const n=Math.max(0,Math.min(t,V.length-1));n!==this.#e.templateIndex&&this.#t({...this.#e,templateIndex:n})}applyTemplate(t){const n=V.find(c=>c.id===t);n&&this.#t(this.#o({...this.#e,config:Y(n.config),isDirty:!0,showTemplateSelector:!1}))}dismissTemplateSelector(){this.#t({...this.#e,showTemplateSelector:!1})}updateConfig(t){this.#t({...this.#e,config:{...this.#e.config,...t},isDirty:!0})}toggleFeature(t){const n={...this.#e.config.features};n[t]===void 0?n[t]={}:delete n[t],this.#t(this.#o({...this.#e,config:{...this.#e.config,features:n},isDirty:!0}))}setFeatureSearch(t){this.#t({...this.#e,featureSearch:t,fieldIndex:0})}addPort(t){const n=this.#e.config.forwardPorts??[];if(n.includes(t))return;const c=[...n,t];this.#t({...this.#e,config:{...this.#e.config,forwardPorts:c},isDirty:!0})}removePort(t){const n=[...this.#e.config.forwardPorts??[]];n.splice(t,1),this.#t({...this.#e,config:{...this.#e.config,forwardPorts:n.length>0?n:void 0},isDirty:!0})}toggleExtension(t){const n={...this.#e.config.customizations},c={...n.vscode},l=[...c.extensions??[]],r=l.indexOf(t);r===-1?l.push(t):l.splice(r,1),c.extensions=l.length>0?l:void 0,n.vscode=c.extensions||c.settings?c:void 0,this.#t({...this.#e,config:{...this.#e.config,customizations:n.vscode||n.jetbrains?n:void 0},isDirty:!0})}setExtensionSearch(t){this.#t({...this.#e,extensionSearch:t,fieldIndex:0})}addEnvVar(t,n,c){const l=t==="container"?"containerEnv":"remoteEnv",r={...this.#e.config[l],[n]:c};this.#t({...this.#e,config:{...this.#e.config,[l]:r},isDirty:!0})}removeEnvVar(t,n){const c=t==="container"?"containerEnv":"remoteEnv",l={...this.#e.config[c]};delete l[n],this.#t({...this.#e,config:{...this.#e.config,[c]:Object.keys(l).length>0?l:void 0},isDirty:!0})}addMount(t){const n=[...this.#e.config.mounts??[],t];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n},isDirty:!0}))}removeMount(t){const n=[...this.#e.config.mounts??[]];n.splice(t,1),this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:n.length>0?n:void 0},isDirty:!0}))}applySuggestedMounts(){if(this.#e.suggestedMounts.length===0)return;const t=[...this.#e.config.mounts??[],...this.#e.suggestedMounts];this.#t(this.#o({...this.#e,config:{...this.#e.config,mounts:t},isDirty:!0}))}setLifecycleCommand(t,n){this.#t({...this.#e,config:{...this.#e.config,[t]:n||void 0},isDirty:!0})}markClean(){this.#t({...this.#e,isDirty:!1,originalConfig:Y(this.#e.config)})}getJsonPreview(){return JSON.stringify(this.#n(),null,2)}cleanConfig(){return this.#n()}#n(){const t=Y(this.#e.config);for(const[n,c]of Object.entries(t))(c===""||c===void 0)&&delete t[n];return t.build&&(t.build.dockerfile===""&&delete t.build.dockerfile,t.build.context===""&&delete t.build.context,t.build.args&&Object.keys(t.build.args).length===0&&delete t.build.args,Object.keys(t.build).length===0&&delete t.build),t.forwardPorts?.length===0&&delete t.forwardPorts,t.mounts?.length===0&&delete t.mounts,t.runServices?.length===0&&delete t.runServices,t.capAdd?.length===0&&delete t.capAdd,t.securityOpt?.length===0&&delete t.securityOpt,t.features&&Object.keys(t.features).length===0&&delete t.features,t.customizations?.vscode?.extensions?.length===0&&delete t.customizations.vscode.extensions,t.customizations?.vscode&&Object.keys(t.customizations.vscode).length===0&&delete t.customizations.vscode,t.customizations&&Object.keys(t.customizations).length===0&&delete t.customizations,t.containerEnv&&Object.keys(t.containerEnv).length===0&&delete t.containerEnv,t.remoteEnv&&Object.keys(t.remoteEnv).length===0&&delete t.remoteEnv,t}#o(t){return{...t,suggestedMounts:pe(t.detectedPm,t.config.features??{},t.config.mounts??[])}}#t(t){this.#e=t;for(const n of this.#r)try{n()}catch{}}}const xe=[{category:"linting",description:"Integrates ESLint into the editor",id:"dbaeumer.vscode-eslint",name:"ESLint"},{category:"linting",description:"Stylelint CSS/SCSS linting",id:"stylelint.vscode-stylelint",name:"Stylelint"},{category:"formatting",description:"Opinionated code formatter",id:"esbenp.prettier-vscode",name:"Prettier"},{category:"formatting",description:"EditorConfig file support",id:"editorconfig.editorconfig",name:"EditorConfig"},{category:"formatting",description:"Fast Rust-based formatter and linter",id:"biomejs.biome",name:"Biome"},{category:"language",description:"Rich TypeScript and JavaScript support",id:"ms-vscode.vscode-typescript-next",name:"TypeScript Nightly"},{category:"language",description:"Tailwind CSS IntelliSense",id:"bradlc.vscode-tailwindcss",name:"Tailwind CSS"},{category:"language",description:"YAML language support with schemas",id:"redhat.vscode-yaml",name:"YAML"},{category:"language",description:"TOML language support",id:"tamasfe.even-better-toml",name:"TOML"},{category:"language",description:"Dockerfile and Docker Compose support",id:"ms-azuretools.vscode-docker",name:"Docker"},{category:"language",description:"Python language support with Pylance",id:"ms-python.python",name:"Python"},{category:"language",description:"Go language support",id:"golang.go",name:"Go"},{category:"language",description:"Rust language support via rust-analyzer",id:"rust-lang.rust-analyzer",name:"rust-analyzer"},{category:"git",description:"Git supercharged: blame, history, stash, etc.",id:"eamodio.gitlens",name:"GitLens"},{category:"git",description:"GitHub Pull Requests and Issues",id:"github.vscode-pull-request-github",name:"GitHub PR"},{category:"testing",description:"Vitest test explorer integration",id:"vitest.explorer",name:"Vitest Explorer"},{category:"testing",description:"Jest test runner and assertions",id:"orta.vscode-jest",name:"Jest"},{category:"debugging",description:"REST client for testing APIs",id:"humao.rest-client",name:"REST Client"},{category:"debugging",description:"Error Lens: inline error highlighting",id:"usernamehw.errorlens",name:"Error Lens"},{category:"other",description:"Intelligent code completion with AI",id:"github.copilot",name:"GitHub Copilot"},{category:"other",description:"Path autocompletion for imports",id:"christian-kohler.path-intellisense",name:"Path Intellisense"},{category:"other",description:"Import cost display in editor",id:"wix.vscode-import-cost",name:"Import Cost"},{category:"other",description:"Todo Tree: highlight and list TODOs",id:"gruntfuggly.todo-tree",name:"Todo Tree"}],je=[{category:"language",description:"Node.js runtime via nvm with optional pnpm/yarn",id:"ghcr.io/devcontainers/features/node:1",name:"Node.js"},{category:"language",description:"Python runtime with pip and optional tools",id:"ghcr.io/devcontainers/features/python:1",name:"Python"},{category:"language",description:"Go compiler and tools",id:"ghcr.io/devcontainers/features/go:1",name:"Go"},{category:"language",description:"Rust toolchain via rustup",id:"ghcr.io/devcontainers/features/rust:1",name:"Rust"},{category:"language",description:"Java runtime and JDK via SDKMAN",id:"ghcr.io/devcontainers/features/java:1",name:"Java"},{category:"language",description:".NET SDK and runtime",id:"ghcr.io/devcontainers/features/dotnet:2",name:".NET"},{category:"tool",description:"Common utilities: zsh, Oh My Zsh, git, curl, etc.",id:"ghcr.io/devcontainers/features/common-utils:2",name:"Common Utilities"},{category:"tool",description:"Git version control",id:"ghcr.io/devcontainers/features/git:1",name:"Git"},{category:"tool",description:"Git Large File Storage support",id:"ghcr.io/devcontainers/features/git-lfs:1",name:"Git LFS"},{category:"tool",description:"GitHub CLI for repository management",id:"ghcr.io/devcontainers/features/github-cli:1",name:"GitHub CLI"},{category:"tool",description:"Run Docker containers inside the dev container",id:"ghcr.io/devcontainers/features/docker-in-docker:2",name:"Docker-in-Docker"},{category:"tool",description:"Access host Docker daemon from inside the container",id:"ghcr.io/devcontainers/features/docker-outside-of-docker:1",name:"Docker-from-Docker"},{category:"tool",description:"kubectl, Helm, and Minikube for Kubernetes",id:"ghcr.io/devcontainers/features/kubectl-helm-minikube:1",name:"Kubernetes Tools"},{category:"tool",description:"Infrastructure as code with Terraform",id:"ghcr.io/devcontainers/features/terraform:1",name:"Terraform"},{category:"tool",description:"Nix package manager",id:"ghcr.io/devcontainers/features/nix:1",name:"Nix"},{category:"tool",description:"SSH server for remote connections to the container",id:"ghcr.io/devcontainers/features/sshd:1",name:"SSH Server"},{category:"cloud",description:"Amazon Web Services CLI v2",id:"ghcr.io/devcontainers/features/aws-cli:1",name:"AWS CLI"},{category:"cloud",description:"Microsoft Azure CLI",id:"ghcr.io/devcontainers/features/azure-cli:1",name:"Azure CLI"},{category:"cloud",description:"Google Cloud Platform CLI",id:"ghcr.io/devcontainers/features/gcloud:1",name:"Google Cloud CLI"},{category:"database",description:"PostgreSQL client tools",id:"ghcr.io/devcontainers-extra/features/postgres-client:1",name:"PostgreSQL Client"},{category:"database",description:"Redis client tools",id:"ghcr.io/devcontainers-extra/features/redis-client:1",name:"Redis Client"}],de=i=>{if(!i)return je;const t=i.toLowerCase();return je.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},ue=i=>{if(!i)return xe;const t=i.toLowerCase();return xe.filter(n=>n.name.toLowerCase().includes(t)||n.id.toLowerCase().includes(t)||n.description.toLowerCase().includes(t))},at=/^[a-z]$/i,dt=i=>{const t=i.codePointAt(0);return t!==void 0&&(t<32||t===127)},ut=(i,t)=>i.length===0||dt(i)?!1:t.ctrl&&t.meta?!at.test(i):!(t.ctrl||t.meta),ht=/\S+\s*$/,se=(i,t)=>i.length===0||!t?void 0:t.find(n=>n.startsWith(i))?.slice(i.length)??void 0,ke=-1,mt=(i,t,n,c)=>t.leftArrow?Math.max(0,n-1):t.home||t.ctrl&&i==="a"?0:t.end||t.ctrl&&i==="e"?c:ke,gt=(i,t,n,c)=>{if(t.backspace&&c>0)return[n.slice(0,c-1)+n.slice(c),c-1];if(t.delete&&c<n.length)return[n.slice(0,c)+n.slice(c+1),c];if(t.ctrl&&i==="u")return[n.slice(c),0];if(t.ctrl&&i==="k")return[n.slice(0,c),c];if(t.ctrl&&i==="w"){const l=n.slice(0,c).replace(ht,"");return[l+n.slice(c),l.length]}};function he({defaultValue:i="",isDisabled:t=!1,mask:n=!1,onChange:c,onSubmit:l,placeholder:r,suggestions:a}){const[m,f]=p.useState(i),[g,v]=p.useState(i.length),x=p.useRef(m);x.current=m;const b=p.useRef(g);b.current=g;const y=p.useRef(c);y.current=c;const D=p.useRef(l);D.current=l;const k=se(m,a),M=p.useCallback((T,I)=>{const{current:E}=b,S=x.current;if(I.return){const w=se(S,a),C=w?S+w:S;w&&(f(C),v(C.length),y.current?.(C)),D.current?.(C);return}if(I.escape)return;if(I.rightArrow){const w=se(S,a);if(E===S.length&&w){const C=S+w;f(C),v(C.length),y.current?.(C);return}v(Math.min(S.length,E+1));return}const A=mt(T,I,E,S.length);if(A!==ke){v(A);return}const H=gt(T,I,S,E);if(H){const[w,C]=H;f(w),v(C),y.current?.(w);return}if(ut(T,I)){const w=S.slice(0,E)+T+S.slice(E);f(w),v(E+T.length),y.current?.(w)}},[a]);W(M,{isActive:!t});const F=n?"*".repeat(m.length):m,U=F.slice(0,g),X=F[g],Q=F.slice(g+1);return t?e.jsx(s,{children:e.jsx(o,{dimColor:!0,children:F||r||""})}):m.length===0&&r?e.jsxs(s,{children:[e.jsx(o,{dimColor:!0,inverse:!0,children:r[0]}),e.jsx(o,{dimColor:!0,children:r.slice(1)})]}):e.jsxs(s,{children:[e.jsxs(o,{children:[U,e.jsx(o,{inverse:!0,children:X??" "}),Q]}),k?e.jsx(o,{dimColor:!0,children:k}):void 0]})}const Ee=["dockerComposeFile","service"],ft={dockerComposeFile:"Compose File",service:"Service"},ve={dockerComposeFile:"docker-compose.yml",service:"app"},pt={dockerComposeFile:"Path to Docker Compose file (relative to .devcontainer/)",service:"Which service in the compose file to connect the IDE to"},xt=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>{const l=!!i.dockerComposeFile,r=!!(i.image||i.build);return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Docker Compose Integration"})}),r&&l&&e.jsx(s,{marginBottom:1,children:e.jsx(o,{color:"yellow",children:"Note: When using Docker Compose, the image/build settings in General are ignored."})}),Ee.map((a,m)=>{const f=m===n,g=i[a]??"",v=Array.isArray(i[a])?i[a].join(", "):g;return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:f,color:f?"cyan":"white",children:[f?"❯ ":" ",ft[a],":"]})}),e.jsx(s,{flexGrow:1,children:f&&t?e.jsx(he,{defaultValue:v,onChange:x=>{c({[a]:x||void 0})},placeholder:ve[a]}):e.jsx(o,{color:v?"white":"gray",children:v||ve[a]})})]}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:pt[a]})})]},a)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]})},jt=Ee.length,vt=({config:i,fieldIndex:t})=>{const n=i.containerEnv??{},c=i.remoteEnv??{},l=Object.keys(n),r=Object.keys(c),a=l.length,m=l.length+1,f=m+r.length,g=t<=a,v=t>a;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{borderColor:g?"cyan":"gray",borderStyle:"single",flexDirection:"column",paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:l.length>0?1:0,children:[e.jsx(o,{bold:!0,color:g?"cyan":"white",children:"containerEnv"}),e.jsx(o,{dimColor:!0,children:" — baked into the container image"})]}),l.map((x,b)=>{const y=b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:y?"cyan":void 0,inverse:y,wrap:"truncate",children:[y?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:n[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:l.length>0?1:0,children:e.jsxs(o,{color:t===a?"cyan":"gray",inverse:t===a,children:[" ","+ Add variable..."]})})]}),e.jsxs(s,{borderColor:v?"cyan":"gray",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,paddingY:0,children:[e.jsxs(s,{flexShrink:0,marginBottom:r.length>0?1:0,children:[e.jsx(o,{bold:!0,color:v?"cyan":"white",children:"remoteEnv"}),e.jsx(o,{dimColor:!0,children:" — set at runtime by the IDE"})]}),r.map((x,b)=>{const D=m+b===t;return e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:D?"cyan":void 0,inverse:D,wrap:"truncate",children:[D?" ❯ ":" ",e.jsx(o,{bold:!0,children:x}),e.jsx(o,{dimColor:!0,children:" = "}),e.jsx(o,{children:c[x]})]})},x)}),e.jsx(s,{flexShrink:0,marginTop:r.length>0?1:0,children:e.jsxs(o,{color:t===f?"cyan":"gray",inverse:t===f,children:[" ","+ Add variable..."]})})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[e.jsx(o,{bold:!0,color:"white",children:"a"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","add on + row"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},bt=i=>{const t=Object.keys(i.containerEnv??{}).length,n=Object.keys(i.remoteEnv??{}).length;return t+1+n+1},wt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(i.customizations?.vscode?.extensions),[i.customizations?.vscode?.extensions]),a=p.useMemo(()=>ue(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.id]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No extensions match the search."})})]})},yt=({config:i,fieldIndex:t,scrollOffset:n,searchText:c,viewportHeight:l})=>{const r=p.useMemo(()=>new Set(Object.keys(i.features??{})),[i.features]),a=p.useMemo(()=>de(c),[c]),m=a.length,f=m>l&&l>0;return e.jsxs(s,{flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[r.size," ","selected"]}),c&&e.jsxs(o,{dimColor:!0,children:["— filter:"," ",e.jsx(o,{color:"yellow",children:c})," ","(",a.length," ","results)"]})]}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{flexDirection:"column",flexGrow:1,overflow:"hidden",paddingLeft:1,children:e.jsx(s,{flexDirection:"column",marginTop:-n,children:a.map((g,v)=>{const x=v===t,b=r.has(g.id);return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:x?">":" "}),e.jsxs(o,{color:b?"white":"gray",children:[" ",b?"☑":"☐"," "]}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:x,inverse:x,wrap:"truncate",children:[g.name,e.jsxs(o,{dimColor:!0,children:[" ","-",g.description]})]})})]},g.id)})})}),f&&e.jsx(s,{flexShrink:0,marginLeft:1,marginRight:1,children:e.jsx(Ce,{contentHeight:m,placement:"inset",scrollOffset:n,style:"block",viewportHeight:l})})]}),a.length===0&&e.jsx(s,{paddingX:1,children:e.jsx(o,{dimColor:!0,children:"No features match the search."})})]})},ae=["name","image","workspaceFolder","workspaceMount","remoteUser","containerUser","shutdownAction"],St={containerUser:"Container User",image:"Image",name:"Name",remoteUser:"Remote User",shutdownAction:"Shutdown Action",workspaceFolder:"Workspace Folder",workspaceMount:"Workspace Mount"},be={containerUser:"root",image:"mcr.microsoft.com/devcontainers/javascript-node:22",name:"My Dev Container",remoteUser:"node",shutdownAction:"none | stopContainer",workspaceFolder:"/workspaces/${localWorkspaceFolderBasename}",workspaceMount:"source=${localWorkspaceFolder},target=...,type=bind"},te=["privileged","overrideCommand"],Ct={overrideCommand:"Override Command",privileged:"Privileged"},kt=ae.length+te.length,Et=({config:i,fieldEditing:t,fieldIndex:n,onUpdate:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"General Configuration"})}),ae.map((l,r)=>{const a=r===n,m=i[l]??"";return e.jsxs(s,{marginBottom:1,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",St[l],":"]})}),e.jsx(s,{flexGrow:1,children:a&&t?e.jsx(he,{defaultValue:m,onChange:f=>{c({[l]:f})},placeholder:be[l]}):e.jsx(o,{color:m?"white":"gray",children:m||be[l]})})]},l)}),te.map((l,r)=>{const m=ae.length+r===n,f=i[l]??!1;return e.jsxs(s,{marginBottom:r<te.length-1?1:0,children:[e.jsx(s,{width:20,children:e.jsxs(o,{bold:m,color:m?"cyan":"white",children:[m?"❯ ":" ",Ct[l],":"]})}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{color:f?"green":"gray",children:[f?"yes":"no",m&&e.jsx(o,{dimColor:!0,children:" (Space to toggle)"})]})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit field"," ",e.jsx(o,{bold:!0,color:"white",children:"Space"})," ","toggle"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),Ie=kt,ce=te,De=["postCreateCommand","postStartCommand","postAttachCommand","onCreateCommand"],It={onCreateCommand:"On Create",postAttachCommand:"Post Attach",postCreateCommand:"Post Create",postStartCommand:"Post Start"},Dt={onCreateCommand:"Runs once when the container is first created",postAttachCommand:"Runs each time the IDE attaches",postCreateCommand:"Runs after the container is created and workspace mounted",postStartCommand:"Runs each time the container starts"},Tt=({config:i,fieldEditing:t,fieldIndex:n,onSetCommand:c})=>e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsx(s,{marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Lifecycle Commands"})}),De.map((l,r)=>{const a=r===n,m=i[l],f=Array.isArray(m)?m.join(" && "):m??"";return e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsx(s,{children:e.jsxs(o,{bold:a,color:a?"cyan":"white",children:[a?"❯ ":" ",It[l]]})}),e.jsx(s,{paddingLeft:4,children:e.jsx(o,{dimColor:!0,children:Dt[l]})}),e.jsx(s,{paddingLeft:4,children:a&&t?e.jsx(he,{defaultValue:f,onChange:g=>{c(l,g)},placeholder:"e.g. npm install"}):e.jsx(o,{color:f?"green":"gray",children:f||"(not set)"})})]},l)}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","edit command"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","stop editing"]})})]}),At=De.length,we=i=>typeof i=="string"?i:`[${i.type}] ${i.source} → ${i.target}`,Lt=({addingMount:i,config:t,detectedPm:n,fieldIndex:c,mountPhase:l,mountSource:r,mountTarget:a,mountType:m,suggestedMounts:f})=>{const g=t.mounts??[];return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsxs(o,{bold:!0,color:"cyan",children:[g.length," ","mounts"]}),n&&e.jsxs(o,{dimColor:!0,children:["— detected:"," ",e.jsx(o,{color:"white",children:n})]})]}),f.length>0&&!i&&e.jsxs(s,{borderColor:"yellow",borderStyle:"single",flexDirection:"column",marginBottom:1,marginTop:1,paddingX:1,children:[e.jsxs(s,{flexShrink:0,children:[e.jsx(o,{bold:!0,color:"yellow",children:"Suggested mounts"}),e.jsxs(o,{dimColor:!0,children:[" ","— press"," ",e.jsx(o,{bold:!0,color:"white",children:"A"})," ","to add all"]})]}),f.map((v,x)=>e.jsx(s,{flexShrink:0,children:e.jsxs(o,{dimColor:!0,wrap:"truncate",children:[" + ",we(v)]})},`suggestion-${String(x)}`))]}),g.length>0&&e.jsx(s,{flexDirection:"column",marginBottom:1,children:g.map((v,x)=>{const b=x===c;return e.jsxs(s,{flexShrink:0,height:1,children:[e.jsx(o,{children:b?">":" "}),e.jsx(s,{flexGrow:1,children:e.jsxs(o,{bold:b,inverse:b,wrap:"truncate",children:[" ",we(v)]})})]},`mount-${String(x)}`)})}),!i&&e.jsx(s,{flexShrink:0,children:e.jsxs(o,{color:c===g.length?"cyan":"gray",inverse:c===g.length,children:[" ","+ Add mount..."]})}),i&&e.jsxs(s,{borderColor:"cyan",borderStyle:"single",flexDirection:"column",marginTop:1,paddingX:1,children:[e.jsx(s,{flexShrink:0,marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"New Mount"})}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="source",color:l==="source"?"cyan":"white",children:[l==="source"?"❯ ":" ","Source:"]})}),e.jsx(o,{color:r?"yellow":"gray",children:r||(l==="source"?"_":"(type source, Enter to continue)")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="target",color:l==="target"?"cyan":"white",children:[l==="target"?"❯ ":" ","Target:"]})}),e.jsx(o,{color:a?"yellow":"gray",children:a||(l==="target"?"_":"/container/path")})]}),e.jsxs(s,{flexShrink:0,children:[e.jsx(s,{width:12,children:e.jsxs(o,{bold:l==="type",color:l==="type"?"cyan":"white",children:[l==="type"?"❯ ":" ","Type:"]})}),l==="type"?e.jsxs(o,{children:[e.jsx(o,{bold:m==="volume",color:m==="volume"?"cyan":"gray",children:"[1] volume"})," ",e.jsx(o,{bold:m==="bind",color:m==="bind"?"cyan":"gray",children:"[2] bind"})," ",e.jsx(o,{bold:m==="tmpfs",color:m==="tmpfs"?"cyan":"gray",children:"[3] tmpfs"})]}):e.jsx(o,{color:"gray",children:m})]}),e.jsx(s,{flexShrink:0,marginTop:1,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:l==="type"?"1/2/3 select type, Enter confirm, Esc cancel":"Type text, Enter next step, Esc cancel"})})]}),g.length===0&&!i&&f.length===0&&e.jsx(s,{marginTop:1,children:e.jsx(o,{dimColor:!0,children:"Tip: Use volume mounts for node_modules and caches to improve performance."})})]})},Ft=({addingPort:i,addPortValue:t,config:n,fieldIndex:c})=>{const l=n.forwardPorts??[],r=c===l.length;return e.jsxs(s,{flexDirection:"column",paddingX:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{bold:!0,color:"cyan",children:"Forwarded Ports"}),e.jsxs(o,{dimColor:!0,children:[" ","(",l.length," ","ports)"]})]}),l.map((a,m)=>{const f=m===c;return e.jsx(s,{children:e.jsxs(o,{color:f?"cyan":void 0,inverse:f,children:[" ",String(a)]})},`port-${String(a)}`)}),e.jsx(s,{marginTop:l.length>0?1:0,children:e.jsxs(o,{color:r?"cyan":"gray",inverse:r,children:[" ",r&&i?e.jsxs(o,{children:["Enter port:"," ",e.jsx(o,{color:"yellow",children:t||"_"})]}):"+ Add port..."]})}),e.jsx(s,{marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ",r?"type port number, Enter to confirm":"select"," ",e.jsx(o,{bold:!0,color:"white",children:"d"})," ","remove selected"," ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"]})})]})},Ot=({focused:i,hadComments:t,jsonPreview:n,mode:c,scrollRef:l})=>e.jsxs(s,{borderColor:i?"cyan":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,children:[e.jsxs(s,{flexShrink:0,paddingX:1,children:[e.jsx(o,{bold:!0,color:i?"cyan":"white",children:"Preview"}),e.jsxs(o,{dimColor:!0,children:[" ","(",c==="create"?"new":"edit",")"]})]}),t&&c==="edit"&&e.jsx(s,{flexShrink:0,paddingX:1,children:e.jsx(o,{color:"yellow",children:"Comments will not be preserved."})}),e.jsx(ze,{flexGrow:1,ref:l,scrollbar:!0,scrollbarColor:"gray",children:n.split(`
3
3
  `).map((r,a)=>e.jsx(o,{color:"green",children:r},`line-${String(a)}`))})]}),Pt=i=>{const t=[],n=[],c=[];if(!i.image&&!i.build&&!i.dockerComposeFile&&t.push({field:"image",message:'One of "image", "build", or "dockerComposeFile" is required'}),i.build&&(i.image&&n.push({field:"image",message:'Both "image" and "build" are set; "build" takes precedence'}),i.build.dockerfile||t.push({field:"build.dockerfile",message:'"build" requires a "dockerfile" path'})),i.dockerComposeFile&&!i.service&&t.push({field:"service",message:'"service" is required when using "dockerComposeFile"'}),i.features!==void 0&&(typeof i.features!="object"||Array.isArray(i.features))&&t.push({field:"features",message:'"features" must be an object mapping feature IDs to options'}),i.forwardPorts)if(Array.isArray(i.forwardPorts))for(const[l,r]of i.forwardPorts.entries())typeof r=="number"&&(r<1||r>65535)&&t.push({field:"forwardPorts",message:`Invalid port ${String(r)} at index ${String(l)}`});else t.push({field:"forwardPorts",message:'"forwardPorts" must be an array'});return i.customizations?.vscode?.extensions&&!Array.isArray(i.customizations.vscode.extensions)&&t.push({field:"customizations.vscode.extensions",message:"Extensions must be an array"}),i.customizations?.vscode?.settings&&typeof i.customizations.vscode.settings!="object"&&t.push({field:"customizations.vscode.settings",message:"Settings must be an object"}),i.name||c.push({field:"name",message:"Consider adding a name for better identification"}),(!i.features||Object.keys(i.features).length===0)&&c.push({field:"features",message:"Consider adding features for common tools"}),(!i.customizations?.vscode?.extensions||i.customizations.vscode.extensions.length===0)&&c.push({field:"extensions",message:"Consider adding VS Code extensions for your stack"}),i.privileged&&n.push({field:"privileged",message:"Running in privileged mode is a security risk"}),{errors:t,suggestions:c,valid:t.length===0,warnings:n}},ye=80,Se=15,Mt=120,Te=[{description:"Container name, base image, workspace folder, and user",id:"general",label:"General"},{description:"Installable tools and runtimes (Node, Python, Docker, etc.)",id:"features",label:"Features"},{description:"Ports to forward from the container to your host",id:"ports",label:"Ports"},{description:"Commands to run at different stages of the container lifecycle",id:"lifecycle",label:"Lifecycle"},{description:"VS Code extensions to auto-install in the container",id:"extensions",label:"Extensions"},{description:"Environment variables for the container and IDE",id:"environment",label:"Env"},{description:"Volume and bind mounts for persistent data and caches",id:"mounts",label:"Mounts"},{description:"Docker Compose integration for multi-container setups",id:"compose",label:"Compose"}],Nt=new Map(Te.map(i=>[i.id,i.description])),Rt=(i,t,n,c)=>{switch(i){case"compose":return jt;case"environment":return bt(t);case"extensions":return ue(c).length;case"features":return de(n).length;case"general":return Ie;case"lifecycle":return At;case"mounts":return(t.mounts?.length??0)+1;case"ports":return(t.forwardPorts?.length??0)+1;default:return 0}},_t=({onSave:i,store:t})=>{const{exit:n}=Ge(),{columns:c,rows:l}=$e(),r=p.useSyncExternalStore(t.subscribe,t.getSnapshot),[a,m]=p.useState(!1),[f,g]=p.useState(!1),[v,x]=p.useState(!1),[b,y]=p.useState(null),[D,k]=p.useState("editor"),[M,F]=p.useState(0),[U,X]=p.useState(!1),[Q,T]=p.useState(""),[I,E]=p.useState(null),[S,A]=p.useState(""),[H,w]=p.useState(""),[C,B]=p.useState("key"),[oe,Z]=p.useState(!1),[re,z]=p.useState(""),[ne,G]=p.useState(""),[me,K]=p.useState("volume"),[O,$]=p.useState("source"),ie=p.useRef(null),R=p.useRef(null),N=p.useRef(null),ee=p.useRef(!0);p.useEffect(()=>(ee.current=!0,()=>{ee.current=!1,N.current&&clearTimeout(N.current)}),[]);const ge=Rt(r.section,r.config,r.featureSearch,r.extensionSearch),q=Math.max(1,l-9);p.useEffect(()=>{r.section!=="features"&&r.section!=="extensions"||F(u=>r.fieldIndex>=u+q?r.fieldIndex-q+1:r.fieldIndex<u?r.fieldIndex:u)},[r.fieldIndex,r.section,q]),p.useEffect(()=>{F(0)},[r.section,r.featureSearch,r.extensionSearch]);const Ae=p.useCallback(()=>{const u=t.cleanConfig(),h=Pt(u);if(!h.valid){const j=h.errors[0];y(j?`Error: ${j.message}`:"Validation failed"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},3e3);return}i(u),t.markClean();const d=h.warnings.length;y(d>0?`Saved! (${String(d)} warning${d>1?"s":""})`:"Saved!"),N.current&&clearTimeout(N.current),N.current=setTimeout(()=>{ee.current&&y(null)},2e3)},[i,t]);W((u,h)=>{if(h.downArrow||u==="j")t.setTemplateIndex(r.templateIndex+1);else if(h.upArrow||u==="k")t.setTemplateIndex(r.templateIndex-1);else if(h.return){const d=V[r.templateIndex];d&&t.applyTemplate(d.id)}else h.escape&&t.dismissTemplateSelector()},{isActive:r.showTemplateSelector}),W((u,h)=>{if(h.escape){X(!1),T("");return}if(h.return){const d=Number.parseInt(Q,10);!Number.isNaN(d)&&d>0&&d<=65535&&t.addPort(d),X(!1),T("");return}if(h.backspace){T(d=>d.slice(0,-1));return}u&&/^\d$/u.test(u)&&T(d=>d+u)},{isActive:U}),W((u,h)=>{if(h.escape){E(null),A(""),w(""),B("key");return}if(h.return){if(C==="key"&&S){B("value");return}if(C==="value"&&S){t.addEnvVar(I,S,H),E(null),A(""),w(""),B("key");return}}if(h.backspace){C==="key"?A(d=>d.slice(0,-1)):w(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(C==="key"?A(d=>d+u):w(d=>d+u))},{isActive:I!==null}),W((u,h)=>{if(h.escape){Z(!1),z(""),G(""),$("source");return}if(h.return){if(O==="source"&&re){$("target");return}if(O==="target"&&ne){$("type");return}if(O==="type"){t.addMount({source:re,target:ne,type:me}),Z(!1),z(""),G(""),$("source");return}}if(O==="type"){switch(u){case"1":{K("volume");break}case"2":{K("bind");break}case"3":{K("tmpfs");break}}return}if(h.backspace){O==="source"?z(d=>d.slice(0,-1)):O==="target"&&G(d=>d.slice(0,-1));return}u&&!h.ctrl&&!h.meta&&(O==="source"?z(d=>d+u):O==="target"&&G(d=>d+u))},{isActive:oe}),W((u,h)=>{if(u==="c"&&h.ctrl){n();return}if(!f){if(a){h.escape||u==="?"?m(!1):h.downArrow||u==="j"?ie.current?.scrollBy(1):h.upArrow||u==="k"?ie.current?.scrollBy(-1):u==="q"&&(m(!1),g(!0));return}if(v){if(h.escape){x(!1),r.section==="features"?t.setFeatureSearch(""):t.setExtensionSearch("");return}if(h.return){x(!1);return}if(h.backspace){r.section==="features"?t.setFeatureSearch(r.featureSearch.slice(0,-1)):t.setExtensionSearch(r.extensionSearch.slice(0,-1));return}if(u&&!h.ctrl&&!h.meta){r.section==="features"?t.setFeatureSearch(r.featureSearch+u):t.setExtensionSearch(r.extensionSearch+u);return}return}if(r.fieldEditing){if(h.escape){t.setFieldEditing(!1);return}if(h.return){t.setFieldEditing(!1);return}return}if(u==="?"){m(!0);return}if(u==="q"){r.isDirty?g(!0):n();return}if(u==="s"){Ae();return}if(h.tab){k(d=>d==="editor"?"preview":"editor");return}if(D==="preview"){if(h.downArrow||u==="j"){R.current?.scrollBy(1);return}if(h.upArrow||u==="k"){R.current?.scrollBy(-1);return}if(h.pageDown){R.current?.scrollBy(10);return}if(h.pageUp){R.current?.scrollBy(-10);return}if(h.home){R.current?.scrollToTop();return}if(h.end){R.current?.scrollToBottom();return}h.escape&&k("editor");return}if(h.downArrow||u==="j"){ge>0&&t.setFieldIndex(Math.min(r.fieldIndex+1,ge-1));return}if(h.upArrow||u==="k"){t.setFieldIndex(Math.max(r.fieldIndex-1,0));return}if(h.return){switch(r.section){case"compose":case"general":case"lifecycle":{t.setFieldEditing(!0);break}case"environment":{const d=Object.keys(r.config.containerEnv??{}).length,j=d,P=d+1+Object.keys(r.config.remoteEnv??{}).length;r.fieldIndex===j?(E("container"),A(""),w(""),B("key")):r.fieldIndex===P&&(E("remote"),A(""),w(""),B("key"));break}case"mounts":{const d=r.config.mounts??[];r.fieldIndex===d.length&&(Z(!0),z(""),G(""),K("volume"),$("source"));break}case"ports":{const d=r.config.forwardPorts??[];r.fieldIndex===d.length&&(X(!0),T(""));break}}return}if(u===" "){switch(r.section){case"extensions":{const j=ue(r.extensionSearch)[r.fieldIndex];j&&t.toggleExtension(j.id);break}case"features":{const j=de(r.featureSearch)[r.fieldIndex];j&&t.toggleFeature(j.id);break}case"general":{const d=Ie-ce.length,j=r.fieldIndex-d;if(j>=0&&j<ce.length){const P=ce[j];t.updateConfig({[P]:!r.config[P]})}break}}return}if(u==="/"){(r.section==="features"||r.section==="extensions")&&x(!0);return}if(u==="A"&&r.section==="mounts"){t.applySuggestedMounts();return}if(u==="a"){if(r.section==="environment"){const d=Object.keys(r.config.containerEnv??{}).length,j=r.fieldIndex<=d?"container":"remote";E(j),A(""),w(""),B("key")}else r.section==="mounts"&&(Z(!0),z(""),G(""),K("volume"),$("source"));return}if(u==="d")switch(r.section){case"environment":{const d=Object.keys(r.config.containerEnv??{}),j=Object.keys(r.config.remoteEnv??{});if(r.fieldIndex<d.length)t.removeEnvVar("container",d[r.fieldIndex]),d.length===1||r.fieldIndex>=d.length-1&&t.setFieldIndex(d.length-2);else{const P=r.fieldIndex-d.length-1;P>=0&&P<j.length&&(t.removeEnvVar("remote",j[P]),j.length===1||P>=j.length-1&&t.setFieldIndex(r.fieldIndex-1))}break}case"mounts":{const d=r.config.mounts??[];if(r.fieldIndex<d.length){t.removeMount(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}case"ports":{const d=r.config.forwardPorts??[];if(r.fieldIndex<d.length){t.removePort(r.fieldIndex);const j=d.length-1;r.fieldIndex>=j&&j>0&&t.setFieldIndex(j-1)}break}}}},{isActive:!r.showTemplateSelector&&!U&&I===null&&!oe});const Le=p.useMemo(()=>t.getJsonPreview(),[r.config]);if(c<ye||l<Se)return e.jsx(s,{alignItems:"center",height:l,justifyContent:"center",width:c,children:e.jsxs(o,{color:"yellow",children:["Terminal too small (",c,"x",l,"), need"," ",ye,"x",Se]})});if(r.showTemplateSelector)return e.jsx(s,{alignItems:"center",flexDirection:"column",height:l,justifyContent:"center",width:c,children:e.jsxs(s,{borderColor:"cyan",borderStyle:"round",flexDirection:"column",paddingX:2,paddingY:1,width:60,children:[e.jsx(s,{justifyContent:"center",marginBottom:1,children:e.jsx(o,{bold:!0,color:"cyan",children:"Select a Template"})}),V.map((u,h)=>{const d=h===r.templateIndex;return e.jsx(s,{children:e.jsxs(o,{color:d?"cyan":void 0,inverse:d,children:[d?" ❯ ":" ",e.jsx(o,{bold:d,children:u.name}),e.jsxs(o,{dimColor:!0,children:[" ","-",u.description]})]})},u.id)}),e.jsx(s,{justifyContent:"center",marginTop:1,children:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","navigate"," ",e.jsx(o,{bold:!0,color:"white",children:"Enter"})," ","select"," ",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","blank"]})})]})});let L;switch(r.section){case"compose":{L=e.jsx(xt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"environment":{L=e.jsxs(s,{flexDirection:"column",children:[e.jsx(vt,{config:r.config,fieldIndex:r.fieldIndex}),I!==null&&e.jsx(s,{marginTop:1,paddingX:1,children:e.jsxs(o,{color:"cyan",children:["Add"," ",I," ","env:"," ",C==="key"?e.jsxs(o,{children:["key=",e.jsx(o,{color:"yellow",children:S||"_"})," ","(Enter to set value)"]}):e.jsxs(o,{children:[S,"=",e.jsx(o,{color:"yellow",children:H||"_"})," ","(Enter to confirm, Esc to cancel)"]})]})})]});break}case"extensions":{L=e.jsx(wt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.extensionSearch,viewportHeight:q});break}case"features":{L=e.jsx(yt,{config:r.config,fieldIndex:r.fieldIndex,scrollOffset:M,searchText:r.featureSearch,viewportHeight:q});break}case"general":{L=e.jsx(Et,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onUpdate:u=>{t.updateConfig(u)}});break}case"lifecycle":{L=e.jsx(Tt,{config:r.config,fieldEditing:r.fieldEditing,fieldIndex:r.fieldIndex,onSetCommand:(u,h)=>{t.setLifecycleCommand(u,h)}});break}case"mounts":{L=e.jsx(Lt,{addingMount:oe,config:r.config,detectedPm:r.detectedPm,fieldIndex:r.fieldIndex,mountPhase:O,mountSource:re,mountTarget:ne,mountType:me,suggestedMounts:r.suggestedMounts});break}case"ports":{L=e.jsx(Ft,{addingPort:U,addPortValue:Q,config:r.config,fieldIndex:r.fieldIndex});break}default:L=e.jsx(o,{children:"Unknown section"})}const Fe=e.jsxs(s,{borderBottom:!1,borderColor:"gray",borderLeft:!1,borderRight:!1,borderStyle:"single",flexShrink:0,children:[e.jsxs(s,{flexGrow:1,flexWrap:"wrap",gap:2,paddingX:1,children:[e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:"QUIT"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:"HELP"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),e.jsx(o,{dimColor:!0,children:"NAV"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:"CHECK"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:"TABS"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:"PANEL"})]}),(r.section==="features"||r.section==="extensions")&&e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:"FILTER"})]}),e.jsxs(s,{gap:1,children:[e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:"SAVE"})]})]}),e.jsxs(s,{paddingX:1,children:[b&&e.jsxs(o,{color:b.startsWith("Error")?"red":"green",children:[b," "]}),r.isDirty&&e.jsx(o,{color:"yellow",children:"[modified]"}),!r.isDirty&&!b&&e.jsx(o,{dimColor:!0,children:"[saved]"})]})]}),Oe=e.jsxs(We,{footer:e.jsxs(o,{dimColor:!0,children:[e.jsx(o,{bold:!0,color:"white",children:"↑↓"})," ","scroll"," ",e.jsx(o,{bold:!0,color:"white",children:"?"}),"/",e.jsx(o,{bold:!0,color:"white",children:"Esc"})," ","close"]}),scrollRef:ie,title:"KEYBOARD SHORTCUTS",visible:a,width:56,children:[e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"NAVIGATION"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"←→"}),e.jsx(o,{dimColor:!0,children:" Switch tabs"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"↑↓"}),"/",e.jsx(o,{bold:!0,color:"white",children:"j/k"}),e.jsx(o,{dimColor:!0,children:" Navigate within section"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Tab"}),e.jsx(o,{dimColor:!0,children:" Switch editor/preview panel"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Enter"}),e.jsx(o,{dimColor:!0,children:" Edit selected field"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Esc"}),e.jsx(o,{dimColor:!0,children:" Stop editing / cancel"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"FEATURES / EXTENSIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"Space"}),e.jsx(o,{dimColor:!0,children:" Toggle selection"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"/"}),e.jsx(o,{dimColor:!0,children:" Search / filter"})]})]}),e.jsxs(s,{flexDirection:"column",marginBottom:1,children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"LISTS (Ports, Mounts, Env)"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"a"}),e.jsx(o,{dimColor:!0,children:" Add new entry"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"d"}),e.jsx(o,{dimColor:!0,children:" Delete selected entry"})]})]}),e.jsxs(s,{flexDirection:"column",children:[e.jsxs(s,{marginBottom:1,children:[e.jsx(o,{dimColor:!0,children:"── "}),e.jsx(o,{bold:!0,color:"white",children:"ACTIONS"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"s"}),e.jsx(o,{dimColor:!0,children:" Save configuration"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"q"}),e.jsx(o,{dimColor:!0,children:" Quit"})]}),e.jsxs(o,{children:[" ",e.jsx(o,{bold:!0,color:"white",children:"?"}),e.jsx(o,{dimColor:!0,children:" Toggle help"})]})]})]}),Pe=e.jsx(Ot,{focused:D==="preview",hadComments:r.hadComments,jsonPreview:Le,mode:r.mode,scrollRef:R}),fe=c>=Mt,Me=fe?Math.floor(c*.38):0;return e.jsxs(s,{flexDirection:"column",height:l,width:c,children:[e.jsxs(s,{flexShrink:0,gap:1,paddingX:1,children:[e.jsx(o,{bold:!0,inverse:!0,children:" VIS "}),e.jsxs(o,{wrap:"truncate",children:[r.mode==="create"?"Create":"Edit"," ","devcontainer"]})]}),e.jsx(s,{flexShrink:0,paddingX:1,paddingY:1,children:e.jsx(tt,{defaultValue:r.section,keyMap:{useNumbers:!1,useTab:!1},onChange:u=>{t.setSection(u),k("editor")},showIndex:!1,children:Te.map(({id:u,label:h})=>e.jsx(ot,{name:u,children:h},u))})}),e.jsx(s,{flexShrink:0,paddingRight:2,children:e.jsx(o,{dimColor:!0,wrap:"truncate",children:Nt.get(r.section)??""})}),e.jsxs(s,{flexDirection:"row",flexGrow:1,overflow:"hidden",children:[e.jsx(s,{borderColor:D==="editor"?"white":"gray",borderStyle:"single",flexDirection:"column",flexGrow:1,overflow:"hidden",children:L}),fe&&e.jsx(s,{flexShrink:0,width:Me,children:Pe})]}),Fe,e.jsx(Ve,{autoExitSeconds:3,onCancel:()=>{g(!1)},visible:f}),Oe]})},Kt=async({logger:i,options:t,workspaceRoot:n})=>{if(!n)throw new Error("Could not determine workspace root. Run this command inside a monorepo or project directory.");const c=n,l=t.template,r=t.output,a=!!process.stdout.isTTY&&!Xe;let m=null;try{m=Ke(c).name}catch{}const f=nt(c);let g=f?.config??null;const v=f?.hadComments??!1;if(l&&!f){const k=V.find(M=>M.id===l);if(!k){const M=V.map(F=>F.id).join(", ");throw new Error(`Unknown template "${l}". Valid templates: ${M}`)}g=k.config}if(!a){g?i.info(JSON.stringify(g,null,2)):(i.error("No existing devcontainer.json found. Use --template to generate one in non-TTY mode."),process.exitCode=1);return}process.stdin.isTTY&&typeof process.stdin.setRawMode=="function"&&(process.stdin.setRawMode(!0),process.stdin.ref(),process.stdin.resume());const x=setInterval(()=>{},1e3),b=new lt(g,v,m);l&&!f&&b.dismissTemplateSelector();let y=null;if(await Ue(He.createElement(_t,{onSave:k=>{it(c,k,r),y=k},store:b}),{alternateScreen:!0,exitOnCtrlC:!1,interactive:!0,patchConsole:!0}).waitUntilExit(),clearInterval(x),y){const k=r??".devcontainer/devcontainer.json";i.info(`DevContainer config saved to ${k}`)}};export{Kt as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as ns}from"node:module";import{readLastRunSummary as cs,getLastRunSummaryPath as as,runConcurrently as Ce,TerminalBuffer as He,CompositeLifeCycle as kt,defaultTaskRunner as bt,resolveTurboEnvCompat as ls,pickChildParentEnv as ds,generateRunSummary as Tt,writeChromeTrace as us,expandAffected as fs,getChangedFiles as hs,enforceProjectConstraints as ps,buildEnhancedPath as ms,createLogReporter as gs,writeRunSummary as ws,reverseTaskGraph as vs,splitCompoundTasks as ys,createTaskGraph as xs,expandTokensInString as $t,parsePartition as js,TaskScheduler as Ss}from"@visulima/task-runner";import{L as Ct,N as ks,K as bs,C as Qe,P as Ts,Q as $s,q as Cs,j as Is,ak as Es,al as Rs,am as Ps,an as Ms,r as Fs}from"./cli-main.js";import{r as U,j as c,X as x,O as f,R as X,o as Os,d as As,b as Ls}from"../packem_shared/registry-Bd3v810N.js";import{r as Ds}from"../packem_shared/command-runtime-DG49t2MT.js";import{s as Bs,p as _s,i as Ns}from"../packem_shared/affected-selection-KJi4PXE2.js";import{d as Ie,U as It,a1 as Ws}from"../packem_shared/env-B-rXCpnL.js";import{f as Gs,d as Hs,e as qs,H as Us,i as Vs,r as zs,s as Ys,a as Ks,b as Xs,c as Js}from"../packem_shared/lifecycle-7cCIImyz.js";import{z as Qs,e as ie,m as Et,$ as Zs,a as er}from"../packem_shared/index-0dnGN3GP.js";import{a as Rt,d as Pt,r as qe,s as tr,m as sr,l as rr}from"../packem_shared/target-options-rIthWS4M.js";import{g as ke,r as Te,b as nr,e as ir,A as or,T as cr,d as ar}from"../packem_shared/task-env-Cl4jNMCR.js";import{f as lr}from"../packem_shared/removeSync-g1D5kONg-jOsRSIIv.js";import{O as le}from"../packem_shared/renderToString-DR0zDUjh-bM18Jav2.js";import{T as Mt,C as Ft,D as Oe,E as Ot}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as yr,j as xr,X as Le,F as tt}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as jr,codeFrame as Sr}from"@visulima/error";import{originalPositionFor as kr,sourceContentFor as br,loadSourceMap as Tr}from"@visulima/source-map";import{l as At}from"../packem_shared/spinner-rjP357lg.js";import{i as be}from"../packem_shared/index-BjdW45xX.js";import{d as Cr,r as Ir}from"../packem_shared/lockfile-DEWjBrlY.js";import{y as Lt}from"../packem_shared/index-BisalDCf.js";import{r as Pr}from"../packem_shared/toolchain-BT5Wf134.js";import{F as Mr}from"../packem_shared/failure-log-CqOSmCst.js";import{V as ge}from"../packem_shared/vis-user-error-CyyTUwX4.js";import{c as Dt,s as Fr,p as Or,a as Ar,b as Lr,r as Dr,f as Br}from"../packem_shared/project-name-filter-B5MeWa0B.js";import{r as _r,f as Nr,a as Wr,p as Gr}from"../packem_shared/selectors-D66zhaRy.js";import _e from"./index.js";import{c as st,a as zr,s as rt}from"../packem_shared/watch-C-9-PD2m.js";let is;const os=t=>(is??=ns(import.meta.url))(t),je=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=t=>{if(typeof je<"u"&&je.versions&&je.versions.node){const[e,s]=je.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return je.getBuiltinModule(t)}return os(t)},{existsSync:me,readFileSync:ye,mkdirSync:dr,writeFileSync:Ue,openSync:ur,statSync:Ze,readSync:fr,closeSync:hr,mkdtempSync:pr}=pe("node:fs"),{isAbsolute:mr,resolve:et,dirname:gr,relative:wr}=pe("node:path"),{fileURLToPath:vr}=pe("node:url"),{createHash:$r}=pe("node:crypto"),{createInterface:Er,emitKeypressEvents:Rr}=pe("node:readline"),{mkdir:Hr,appendFile:Ae}=pe("node:fs/promises"),{platform:qr,homedir:Ve,tmpdir:Ur}=pe("node:os"),{spawn:Vr}=pe("node:child_process"),Yr=27,Kr={95:"apc",80:"dcs",94:"pm",88:"sos"},Xr={159:"apc",144:"dcs",158:"pm",152:"sos"},Bt=t=>t===155||t===157||t===144||t===152||t===158||t===159,_t=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Ee=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const n=t.codePointAt(r);if(n===156||s&&n===7)return r;if(n===27&&t.codePointAt(r+1)===92)return r+1}return-1},Jr=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=_t(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Ee(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Ee(t,e+2,!1),n=Kr[s];return r===-1?void 0:{end:r,kind:n}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Qr=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=_t(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Ee(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Ee(t,e+1,!1),n=Xr[s];return r===-1?void 0:{end:r,kind:n}}},Zr=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Bt(t.codePointAt(e)))return!0;return!1},en=t=>{if(!Zr(t))return t;let e="",s=0,r=0;const{length:n}=t;for(;r<n;){const o=t.codePointAt(r);let i;if(o===Yr)i=Jr(t,r);else if(Bt(o))i=Qr(t,r);else{r+=1;continue}const l=i===void 0?n-1:i.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},tn=(t,e,s,r,n,o,i,l,d,h,u,p,a,m)=>{const w={d:r,h:n,m:o,mo:e,ms:l,s:i,w:s,y:t};return w.future=d,w.past=h,w.decimal=u,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},sn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},rn=tn(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",sn,",","_"),nt=new WeakSet,nn=t=>{if(nt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");nt.add(t)},Nt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},it=({unitCount:t,unitName:e},s,r)=>{let{spacer:n}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:s.decimal!==void 0&&(i=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Nt(t,o));const u=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of u)d+=m==="."?i:l[m]}else d=u.replace(".",i);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(n=""),s._numberFirst?a+n+d:d+n+a},on=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,n=e.largest??Number.POSITIVE_INFINITY,o={};let i,l,d,h=t;for(l=0;l<s.length;l++){i=s[l];const p=r[i];d=l===s.length-1?h/p:Math.floor(h/p),o[i]=d,h-=d*p}if(e.round){let p=n;for(l=0;l<s.length;l++)if(i=s[l],d=o[i],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[i]=(o[i]??0)+w*r[m]/r[i],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(i=s[l],d=o[i],d===0)continue;const a=Math.round(d);if(o[i]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[i]/w);if(j)o[m]=(o[m]??0)+j,o[i]=0;else break}}const u=[];for(l=0;l<s.length&&u.length<n;l++){if(i=s[l],d=o[i],d&&!e.round&&u.length===n-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[i])}d+=a,e.maxDecimalPoints!==void 0&&(d=Nt(d,e.maxDecimalPoints))}d&&u.push({unitCount:d,unitName:i})}return u},cn=(t,e,s)=>{const{language:r,units:n}=e;if(t.length===0){const p=n.at(-1);return it({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:i}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>it(p,r,e));let u;return!o||t.length===1?u=h.join(l):t.length===2?u=h.join(o):u=h.slice(0,-1).join(l)+(i?",":"")+o+(h.at(-1)??""),d&&(u=d.replace("%s",u)),u},an=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:rn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};nn(s.language);const r=Math.abs(t),n=on(r,s);return cn(n,s,t)},Re=256*1024;class ln{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
1
+ import{createRequire as ns}from"node:module";import{readLastRunSummary as cs,getLastRunSummaryPath as as,runConcurrently as Ce,TerminalBuffer as He,CompositeLifeCycle as kt,defaultTaskRunner as bt,resolveTurboEnvCompat as ls,pickChildParentEnv as ds,generateRunSummary as Tt,writeChromeTrace as us,expandAffected as fs,getChangedFiles as hs,enforceProjectConstraints as ps,buildEnhancedPath as ms,createLogReporter as gs,writeRunSummary as ws,reverseTaskGraph as vs,splitCompoundTasks as ys,createTaskGraph as xs,expandTokensInString as $t,parsePartition as js,TaskScheduler as Ss}from"@visulima/task-runner";import{L as Ct,N as ks,K as bs,C as Qe,P as Ts,Q as $s,q as Cs,j as Is,ak as Es,al as Rs,am as Ps,an as Ms,r as Fs}from"./cli-main.js";import{r as U,j as c,X as x,O as f,R as X,o as Os,d as As,b as Ls}from"../packem_shared/registry-CyYhBUaF.js";import{r as Ds}from"../packem_shared/command-runtime-DG49t2MT.js";import{s as Bs,p as _s,i as Ns}from"../packem_shared/affected-selection-DxKQo2N5.js";import{d as Ie,U as It,a1 as Ws}from"../packem_shared/env-D3wteXlq.js";import{f as Gs,d as Hs,e as qs,H as Us,i as Vs,r as zs,s as Ys,a as Ks,b as Xs,c as Js}from"../packem_shared/lifecycle-C6o0cmOT.js";import{z as Qs,e as ie,m as Et,$ as Zs,a as er}from"../packem_shared/index-0dnGN3GP.js";import{a as Rt,d as Pt,r as qe,s as tr,m as sr,l as rr}from"../packem_shared/target-options-rIthWS4M.js";import{g as ke,r as Te,b as nr,e as ir,A as or,T as cr,d as ar}from"../packem_shared/task-env-Cl4jNMCR.js";import{f as lr}from"../packem_shared/removeSync-g1D5kONg-jOsRSIIv.js";import{O as le}from"../packem_shared/renderToString-DR0zDUjh-CQT5Ebrc.js";import{T as Mt,C as Ft,D as Oe,E as Ot}from"../packem_shared/symbols-BXDZ_sKt.js";import{q as yr,j as xr,X as Le,F as tt}from"../packem_shared/index.server-Ca_EEVfw.js";import{parseStacktrace as jr,codeFrame as Sr}from"@visulima/error";import{originalPositionFor as kr,sourceContentFor as br,loadSourceMap as Tr}from"@visulima/source-map";import{l as At}from"../packem_shared/spinner-B30I9gQR.js";import{i as be}from"../packem_shared/index-BjdW45xX.js";import{d as Cr,r as Ir}from"../packem_shared/lockfile-DEWjBrlY.js";import{y as Lt}from"../packem_shared/index-BisalDCf.js";import{r as Pr}from"../packem_shared/toolchain-B7PrWDAi.js";import{F as Mr}from"../packem_shared/failure-log-Dgp-P-SJ.js";import{V as ge}from"../packem_shared/vis-user-error-C3y9hGtw.js";import{c as Dt,s as Fr,p as Or,a as Ar,b as Lr,r as Dr,f as Br}from"../packem_shared/project-name-filter-B7h62wuR.js";import{r as _r,f as Nr,a as Wr,p as Gr}from"../packem_shared/selectors-DmRRUQsG.js";import _e from"./index.js";import{c as st,a as zr,s as rt}from"../packem_shared/watch-C-9-PD2m.js";let is;const os=t=>(is??=ns(import.meta.url))(t),je=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pe=t=>{if(typeof je<"u"&&je.versions&&je.versions.node){const[e,s]=je.versions.node.split(".").map(Number);if(e>22||e===22&&s>=3||e===20&&s>=16)return je.getBuiltinModule(t)}return os(t)},{existsSync:me,readFileSync:ye,mkdirSync:dr,writeFileSync:Ue,openSync:ur,statSync:Ze,readSync:fr,closeSync:hr,mkdtempSync:pr}=pe("node:fs"),{isAbsolute:mr,resolve:et,dirname:gr,relative:wr}=pe("node:path"),{fileURLToPath:vr}=pe("node:url"),{createHash:$r}=pe("node:crypto"),{createInterface:Er,emitKeypressEvents:Rr}=pe("node:readline"),{mkdir:Hr,appendFile:Ae}=pe("node:fs/promises"),{platform:qr,homedir:Ve,tmpdir:Ur}=pe("node:os"),{spawn:Vr}=pe("node:child_process"),Yr=27,Kr={95:"apc",80:"dcs",94:"pm",88:"sos"},Xr={159:"apc",144:"dcs",158:"pm",152:"sos"},Bt=t=>t===155||t===157||t===144||t===152||t===158||t===159,_t=(t,e)=>{for(let s=e;s<t.length;s+=1){const r=t.codePointAt(s);if(r>=64&&r<=126)return s}return-1},Ee=(t,e,s)=>{for(let r=e;r<t.length;r+=1){const n=t.codePointAt(r);if(n===156||s&&n===7)return r;if(n===27&&t.codePointAt(r+1)===92)return r+1}return-1},Jr=(t,e)=>{const s=t.codePointAt(e+1);if(s===91){const r=_t(t,e+2);return r===-1?void 0:{end:r,kind:"csi"}}if(s===93){const r=Ee(t,e+2,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===80||s===88||s===94||s===95){const r=Ee(t,e+2,!1),n=Kr[s];return r===-1?void 0:{end:r,kind:n}}return s===void 0?void 0:{end:e+1,kind:"escape"}},Qr=(t,e)=>{const s=t.codePointAt(e);if(s===155){const r=_t(t,e+1);return r===-1?void 0:{end:r,kind:"csi"}}if(s===157){const r=Ee(t,e+1,!0);return r===-1?void 0:{end:r,kind:"osc"}}if(s===144||s===152||s===158||s===159){const r=Ee(t,e+1,!1),n=Xr[s];return r===-1?void 0:{end:r,kind:n}}},Zr=t=>{if(t.includes(String.fromCodePoint(27)))return!0;for(let e=0;e<t.length;e+=1)if(Bt(t.codePointAt(e)))return!0;return!1},en=t=>{if(!Zr(t))return t;let e="",s=0,r=0;const{length:n}=t;for(;r<n;){const o=t.codePointAt(r);let i;if(o===Yr)i=Jr(t,r);else if(Bt(o))i=Qr(t,r);else{r+=1;continue}const l=i===void 0?n-1:i.end;e+=t.slice(s,r),s=l+1,r=l+1}return e+=t.slice(s),e},tn=(t,e,s,r,n,o,i,l,d,h,u,p,a,m)=>{const w={d:r,h:n,m:o,mo:e,ms:l,s:i,w:s,y:t};return w.future=d,w.past=h,w.decimal=u,p!==void 0&&(w.unitMap=p),w.groupSeparator=a,w.placeholderSeparator=m,w},sn={d:"d",day:"d",days:"d",h:"h",hour:"h",hours:"h",hr:"h",hrs:"h",m:"m",millisecond:"ms",milliseconds:"ms",min:"m",mins:"m",minute:"m",minutes:"m",mo:"mo",month:"mo",months:"mo",ms:"ms",s:"s",sec:"s",second:"s",seconds:"s",secs:"s",w:"w",week:"w",weeks:"w",y:"y",year:"y",years:"y",yr:"y",yrs:"y"},rn=tn(t=>`year${t===1?"":"s"}`,t=>`month${t===1?"":"s"}`,t=>`week${t===1?"":"s"}`,t=>`day${t===1?"":"s"}`,t=>`hour${t===1?"":"s"}`,t=>`minute${t===1?"":"s"}`,t=>`second${t===1?"":"s"}`,t=>`millisecond${t===1?"":"s"}`,"in %s","%s ago",".",sn,",","_"),nt=new WeakSet,nn=t=>{if(nt.has(t))return;const e=["y","mo","w","d","h","m","s","ms"];for(const r of e)if(!Object.hasOwn(t,r))throw new TypeError(`Missing required property: ${r}`);if(t.future!==void 0&&typeof t.future!="string")throw new TypeError("Properties future and past must be of type string");if(t.past!==void 0&&typeof t.past!="string")throw new TypeError("Properties future and past must be of type string");const s=["y","mo","w","d","h","m","s","ms"];for(const r of s)if(typeof t[r]!="string"&&typeof t[r]!="function")throw new TypeError(`Property ${r} must be of type string or function`);if(t.decimal&&typeof t.decimal!="string")throw new TypeError("Property decimal must be of type string");if(t.delimiter&&typeof t.delimiter!="string")throw new TypeError("Property delimiter must be of type string");if(t._digitReplacements&&!Array.isArray(t._digitReplacements))throw new TypeError("Property _digitReplacements must be an array");if(t._numberFirst&&typeof t._numberFirst!="boolean")throw new TypeError("Property _numberFirst must be of type boolean");if(t.unitMap&&typeof t.unitMap!="object")throw new TypeError("Property unitMap must be an object");if(t.unitMap&&Object.values(t.unitMap).some(r=>typeof r!="string"))throw new TypeError("All values in unitMap must be of type string");nt.add(t)},Nt=(t,e)=>{if(!Number.isFinite(t)||e<0||Number.isInteger(t))return t;const s=10**e,r=Number((t*s).toPrecision(15));return Math.trunc(r)/s},it=({unitCount:t,unitName:e},s,r)=>{let{spacer:n}=r;const{maxDecimalPoints:o}=r;let i=".";r.decimal!==void 0?i=r.decimal:s.decimal!==void 0&&(i=s.decimal);let l;"digitReplacements"in r?l=r.digitReplacements:"_digitReplacements"in s&&(l=s._digitReplacements);let d,h=t;o!==void 0&&(h=Nt(t,o));const u=h.toString();if(!s._hideCountIf2||t!==2)if(l){d="";for(const m of u)d+=m==="."?i:l[m]}else d=u.replace(".",i);else d="";const p=s[e];let a=p;return typeof p=="function"&&(a=p(t)),s._hideCountIf2&&t===2&&(n=""),s._numberFirst?a+n+d:d+n+a},on=(t,e)=>{const{units:s}=e;if(s.length===0)return[];const{unitMeasures:r}=e,n=e.largest??Number.POSITIVE_INFINITY,o={};let i,l,d,h=t;for(l=0;l<s.length;l++){i=s[l];const p=r[i];d=l===s.length-1?h/p:Math.floor(h/p),o[i]=d,h-=d*p}if(e.round){let p=n;for(l=0;l<s.length;l++)if(i=s[l],d=o[i],d!==0&&(p--,p===0)){for(let a=l+1;a<s.length;a++){const m=s[a],w=o[m];o[i]=(o[i]??0)+w*r[m]/r[i],o[m]=0}break}for(l=s.length-1;l>=0;l--){if(i=s[l],d=o[i],d===0)continue;const a=Math.round(d);if(o[i]=a,l===0)break;const m=s[l-1],w=r[m],j=Math.floor(a*r[i]/w);if(j)o[m]=(o[m]??0)+j,o[i]=0;else break}}const u=[];for(l=0;l<s.length&&u.length<n;l++){if(i=s[l],d=o[i],d&&!e.round&&u.length===n-1){let p,a=0;for(p=l+1,s.length;p<s.length;p++){const m=s[p];a+=o[m]*(e.unitMeasures[m]/e.unitMeasures[i])}d+=a,e.maxDecimalPoints!==void 0&&(d=Nt(d,e.maxDecimalPoints))}d&&u.push({unitCount:d,unitName:i})}return u},cn=(t,e,s)=>{const{language:r,units:n}=e;if(t.length===0){const p=n.at(-1);return it({unitCount:0,unitName:p},r,e)}const{conjunction:o,serialComma:i}=e;let l=", ";e.delimiter!==void 0?l=e.delimiter:r.delimiter!==void 0&&(l=r.delimiter);let d="";e.timeAdverb&&s!==0&&(d=r.future??"",s<0&&(d=r.past??""));const h=t.map(p=>it(p,r,e));let u;return!o||t.length===1?u=h.join(l):t.length===2?u=h.join(o):u=h.slice(0,-1).join(l)+(i?",":"")+o+(h.at(-1)??""),d&&(u=d.replace("%s",u)),u},an=(t,e)=>{if(Number.isNaN(t))throw new TypeError("Expected a valid number");if(typeof t!="number")throw new TypeError("Expected a number for milliseconds input");const s={conjunction:"",language:rn,round:!1,serialComma:!0,spacer:" ",timeAdverb:!1,unitMeasures:{d:864e5,h:36e5,m:6e4,mo:2629746e3,ms:1,s:1e3,w:6048e5,y:31556952e3},units:["w","d","h","m","s"],...e};nn(s.language);const r=Math.abs(t),n=on(r,s);return cn(n,s,t)},Re=256*1024;class ln{#e;#r="";#s=!1;constructor(e){this.#e=e}append(e){this.#r+=e,this.#r.length>this.#e&&(this.#r=this.#r.slice(-this.#e),this.#s=!0)}toString(){return this.#s?`[...output truncated, showing last ${Math.round(this.#e/1024)}KB...]
2
2
  ${this.#r}`:this.#r}}const dn=t=>{if(!t||t.trim().length===0)return;const e=Number.parseFloat(t);return!Number.isFinite(e)||e<=0?{invalid:t}:{value:Math.floor(e)}},un=async(t,e)=>{const s=await cs(t,{dataDirectory:Ie(t)});if(!s){e.warn(`No previous run recorded yet. Run a task at least once to populate ${as(t,{dataDirectory:Ie(t)})}.`);return}const r=(s.duration/1e3).toFixed(2);if(e.info(""),e.info(`Last run — ${s.startTime} (${r}s)`),e.info(""),e.info(` Total: ${String(s.stats.total)}`),e.info(` Succeeded: ${String(s.stats.succeeded)}`),e.info(` Cached: ${String(s.stats.cached)}`),e.info(` Failed: ${String(s.stats.failed)}`),e.info(` Skipped: ${String(s.stats.skipped)}`),e.info(""),s.stats.failed>0){const o=s.tasks.filter(i=>i.exitCode!==void 0&&i.exitCode!==0);e.info("Failed tasks:");for(const i of o){const l=i.duration??0;e.info(` × ${i.taskId} (exit ${String(i.exitCode??-1)}, ${l}ms)`)}e.info("")}const n=[...s.tasks].filter(o=>typeof o.duration=="number").sort((o,i)=>(i.duration??0)-(o.duration??0)).slice(0,5);if(n.length>0){e.info("Slowest tasks:");for(const o of n)e.info(` ${o.taskId.padEnd(40)} ${String(o.duration??0).padStart(6)}ms [${o.cacheStatus}]`);e.info("")}},fn=t=>{if(!(t===void 0||t==="")){if(t!=="read"&&t!=="write"&&t!=="readwrite")throw new Error(`--cache-mode must be one of: read, write, readwrite (received "${t}")`);return t}},hn=t=>{if(!(t===void 0||t==="")){if(t!=="http"&&t!=="reapi")throw new Error(`--cache-backend must be one of: http, reapi (received "${t}")`);return t}},pn=t=>{if(!(t===void 0||t==="")){if(t!=="declared"&&t!=="trace")throw new Error(`--hash-mode must be one of: declared, trace (received "${t}")`);return t}},mn=({interactive:t,taskPty:e,workspacePty:s})=>e===!0?!0:e===!1?!1:t&&s!==!1,gn=t=>`'${t.replaceAll("'",String.raw`'\''`)}'`,ze=t=>process.platform==="win32"?t.length>0&&!/[\s"&|<>^()%!]/.test(t)?t:`"${t.replaceAll('"','""')}"`:gn(t),wn=(t,e,s)=>{if(!e||e.length===0||s===!1||s===void 0)return t;if(s==="args"||s==="both"){const r=e.map(n=>ze(n)).join(" ");return`${t} ${r}`}return t},Wt="visForwardedArgs",vn=(t,e)=>{const s=e.overrides[Wt];if(!Array.isArray(s)||s.length===0)return t;const r=s.map(n=>ze(n)).join(" ");return`${t} ${r}`},Ye=(t,e,s)=>{const r=t.overrides.command;if(!r)return;const n=ke(t),o=t.segment!==void 0&&t.segment.index<t.segment.count,i=o?r:vn(r,t),l=o?i:wn(i,e,n?.affectedFiles),d=Rt(n,s),h=n?.shellArgs,u=h&&h.length>0?h.join(" "):"-c";return d?`${d} ${u} ${ze(l)}`:l},yn=2e3,Gt=async(t,e,s)=>{const{workspaceRoot:r}=e,n=t.map(g=>{const S=Ye(g,e.affectedFiles,Pt());if(!S)return;const F=g.overrides.visOptions,C=qe(r,g.projectRoot,!!F?.runFromWorkspaceRoot),v=mn({interactive:!!s,taskPty:g.pty,workspacePty:F?.pty}),L=Te(e,g);return{command:S,cwd:C,env:L.env,inheritEnv:L.inheritEnv,name:g.id,...v?{ptySize:{cols:process.stdout.columns??80,rows:process.stdout.rows??24},stdin:"pty"}:{}}}).filter(g=>g!==void 0);if(n.length===0)return;if(!s){await Ce(n,{killOthers:["failure"],onEvent:()=>{}});return}const{abortSignal:o,lifeCycle:i,stdinRegistry:l,store:d}=s,h=n.map(g=>t.find(S=>S.id===g.name)).filter(Boolean),u=g=>n[g]?.stdin==="pty",p=new Map,a=g=>{if(!u(g))return;let S=p.get(g);return S||(S=new He(Re),p.set(g,S)),S};d.unmarkDone(),i.startTasks?.(h);const m=new Map,w=new Map;let j;const E=()=>{for(const g of w.values())try{g("SIGTERM")}catch{}j||(j=setTimeout(()=>{for(const g of w.values())try{g("SIGKILL")}catch{}w.clear()},2e3),j.unref?.())};let y;o&&(y=()=>{E()},o.then(()=>{y?.()}).catch(()=>{y?.()}));try{await Ce(n,{killOthers:["failure"],onEvent:g=>{const S=h[g.index];if(S)switch(g.kind){case"close":{const F=m.get(S.id)??Date.now(),C=g.killed||g.exitCode===0?"success":"failure";i.endTasks?.([{code:g.exitCode??0,endTime:Date.now(),startTime:F,status:C,task:S,terminalOutput:d.getSnapshot().outputs.get(S.id)??""}]),w.delete(g.index),l?.delete(S.id);break}case"error":{if(g.message){const F=a(g.index);F?(F.write(`${g.message}
3
3
  `),d.setOutput(S.id,F.toString())):d.addOutput(S.id,`${g.message}
4
4
  `)}break}case"started":{m.set(S.id,Date.now()),g.kill&&w.set(g.index,g.kill),g.write&&l&&l.set(S.id,{kill:g.kill,resize:g.resize,write:g.write});break}case"stderr":case"stdout":{if(g.text){const F=a(g.index);F?(F.write(g.text),d.setOutput(S.id,F.toString())):d.addOutput(S.id,`${g.text}
@@ -1 +1 @@
1
- import{createRequire as v}from"node:module";import{e as m}from"../packem_shared/index-0dnGN3GP.js";import{cleanWorkspace as E}from"#native";import{l as S}from"../packem_shared/missing-package-json-KsrtjpfC.js";import{p as c}from"./cli-main.js";import{e as p}from"../packem_shared/utils-DQFHJn72.js";import{y as P}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";let g;const _=e=>(g??=v(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(e)}return _(e)},{readdirSync:h,lstatSync:$,rmSync:b}=R("node:fs"),j=e=>{const r=[],t=[e];for(;t.length>0;){const o=t.pop();let i;try{i=h(o)}catch{continue}for(const l of i){const s=m(o,l);try{const n=$(s);if(n.isSymbolicLink()||!n.isDirectory())continue}catch{continue}l==="node_modules"?r.push(s):l!==".git"&&l!==".hg"&&t.push(s)}}return r},w=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],D=(e,r,t)=>{let o=0,i=!1;for(const l of w){const s=m(e,l);if(P(s)){t.info(` ${s}`),o++;continue}}return{hadError:i,removed:o}},L=new Set([".cache",".turbo","dist","node_modules"]),k=e=>{for(const r of h(e,{withFileTypes:!0})){const t=m(e,r.name);if(!r.isDirectory())return t;if(!L.has(r.name)){const o=k(t);if(o!==void 0)return o}}},y=(e,r,t)=>{let o=0,i=!1;for(const{packageDir:l}of S(e)){const s=m(e,l);let n;try{n=k(s)}catch(a){c.error(`${s}: ${p(a)}`),i=!0;continue}if(n!==void 0){c.warn(`Skipping ${s}: not empty (contains ${n})`);continue}if(r){t.info(` ${s}`),o++;continue}try{b(s,{force:!0,recursive:!0}),c.success(`Removed empty package ${s}`),o++}catch(a){c.error(`${s}: ${p(a)}`),i=!0}}return{hadError:i,removed:o}},x=async({logger:e,options:r,workspaceRoot:t})=>{const o=t??process.cwd(),i=r.lockfile||!1,l=r.emptyPackages||!1;if(r.dryRun||!1){const f=j(o);if(f.length>0){c.info("Would remove:");for(const d of f)e.info(` ${d}`)}else c.info("No node_modules directories found.");i&&D(o,!0,e),l&&(c.info("Would remove empty packages:"),y(o,!0,e));return}const n=E(o,i);for(const f of n.removed)c.success(`Removed ${f}`);for(const f of n.lockfilesRemoved)c.success(`Removed ${f}`);for(const f of n.errors)c.error(f);n.removed.length===0&&n.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${n.removed.length} node_modules director${n.removed.length===1?"y":"ies"}`);let a=!1;if(l){const{hadError:f,removed:d}=y(o,!1,e);a=f,d>0&&c.info(`Cleaned ${d} empty package director${d===1?"y":"ies"}`)}(n.errors.length>0||a)&&(process.exitCode=1)};export{x as default};
1
+ import{createRequire as v}from"node:module";import{e as m}from"../packem_shared/index-0dnGN3GP.js";import{cleanWorkspace as E}from"#native";import{l as S}from"../packem_shared/missing-package-json-Cf7PavlK.js";import{p as c}from"./cli-main.js";import{e as p}from"../packem_shared/utils-DQFHJn72.js";import{y as P}from"../packem_shared/isAccessibleSync-DYKTrrvc-CBsMZhj-.js";let g;const _=e=>(g??=v(import.meta.url))(e),u=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,R=e=>{if(typeof u<"u"&&u.versions&&u.versions.node){const[r,t]=u.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return u.getBuiltinModule(e)}return _(e)},{readdirSync:h,lstatSync:$,rmSync:b}=R("node:fs"),j=e=>{const r=[],t=[e];for(;t.length>0;){const o=t.pop();let i;try{i=h(o)}catch{continue}for(const l of i){const s=m(o,l);try{const n=$(s);if(n.isSymbolicLink()||!n.isDirectory())continue}catch{continue}l==="node_modules"?r.push(s):l!==".git"&&l!==".hg"&&t.push(s)}}return r},w=["pnpm-lock.yaml","package-lock.json","npm-shrinkwrap.json","yarn.lock","bun.lock","bun.lockb"],D=(e,r,t)=>{let o=0,i=!1;for(const l of w){const s=m(e,l);if(P(s)){t.info(` ${s}`),o++;continue}}return{hadError:i,removed:o}},L=new Set([".cache",".turbo","dist","node_modules"]),k=e=>{for(const r of h(e,{withFileTypes:!0})){const t=m(e,r.name);if(!r.isDirectory())return t;if(!L.has(r.name)){const o=k(t);if(o!==void 0)return o}}},y=(e,r,t)=>{let o=0,i=!1;for(const{packageDir:l}of S(e)){const s=m(e,l);let n;try{n=k(s)}catch(a){c.error(`${s}: ${p(a)}`),i=!0;continue}if(n!==void 0){c.warn(`Skipping ${s}: not empty (contains ${n})`);continue}if(r){t.info(` ${s}`),o++;continue}try{b(s,{force:!0,recursive:!0}),c.success(`Removed empty package ${s}`),o++}catch(a){c.error(`${s}: ${p(a)}`),i=!0}}return{hadError:i,removed:o}},x=async({logger:e,options:r,workspaceRoot:t})=>{const o=t??process.cwd(),i=r.lockfile||!1,l=r.emptyPackages||!1;if(r.dryRun||!1){const f=j(o);if(f.length>0){c.info("Would remove:");for(const d of f)e.info(` ${d}`)}else c.info("No node_modules directories found.");i&&D(o,!0,e),l&&(c.info("Would remove empty packages:"),y(o,!0,e));return}const n=E(o,i);for(const f of n.removed)c.success(`Removed ${f}`);for(const f of n.lockfilesRemoved)c.success(`Removed ${f}`);for(const f of n.errors)c.error(f);n.removed.length===0&&n.lockfilesRemoved.length===0?c.info("No node_modules directories found."):c.info(`Cleaned ${n.removed.length} node_modules director${n.removed.length===1?"y":"ies"}`);let a=!1;if(l){const{hadError:f,removed:d}=y(o,!1,e);a=f,d>0&&c.info(`Cleaned ${d} empty package director${d===1?"y":"ies"}`)}(n.errors.length>0||a)&&(process.exitCode=1)};export{x as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as O}from"../packem_shared/index-0dnGN3GP.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-BpRmbHRB.js";import{p}from"./cli-main.js";import{r as H}from"../packem_shared/run-summary-utils-CnHppdTd.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
1
+ import{createRequire as E}from"node:module";import{b as U,j as x,F as g,X as A,J as L}from"../packem_shared/index.server-Ca_EEVfw.js";import{a as O}from"../packem_shared/index-0dnGN3GP.js";import{readLastRunSummary as G}from"@visulima/task-runner";import{a as j,r as F,b as D,c as K}from"../packem_shared/ai-fix-DVcnNQ0X.js";import{p}from"./cli-main.js";import{r as H}from"../packem_shared/run-summary-utils-RzgHeC8f.js";let B;const P=e=>(B??=E(import.meta.url))(e),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,I=e=>{if(typeof m<"u"&&m.versions&&m.versions.node){const[t,o]=m.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return m.getBuiltinModule(e)}return P(e)},{spawn:h}=I("node:child_process"),{readFile:M}=I("node:fs/promises"),V=e=>{if(!e)return;const t=/^refs\/pull\/(\d+)\//.exec(e);return t?Number.parseInt(t[1],10):void 0},J=async e=>{if(!e)return{prNumber:void 0,sha:void 0};try{const t=await M(e,"utf8"),o=JSON.parse(t),r=o.pull_request?.number??o.issue?.number??o.number,s=o.pull_request?.head?.sha;return{prNumber:r,sha:s}}catch{return{prNumber:void 0,sha:void 0}}},q=async e=>{const t=V(e.GITHUB_REF),{prNumber:o,sha:r}=t===void 0?await J(e.GITHUB_EVENT_PATH):{prNumber:t,sha:void 0};return{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:t??o,provider:"github-actions",repo:e.GITHUB_REPOSITORY,sha:r??e.GITHUB_SHA,token:e.GITHUB_TOKEN}},z=e=>{const t=e.CI_MERGE_REQUEST_IID,o=t!==void 0&&t!==""?Number.parseInt(t,10):void 0,r=e.CI_API_V4_URL,s=e.GITLAB_TOKEN??e.CI_TOKEN;return{apiBaseUrl:r,buildId:void 0,buildNumber:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"gitlab-ci",repo:e.CI_PROJECT_ID??e.CI_PROJECT_PATH,sha:e.CI_COMMIT_SHA,token:s}},X=e=>{const t=e.BUILDKITE_PULL_REQUEST,o=t!==void 0&&t!==""&&t!=="false"?Number.parseInt(t,10):void 0,r=e.BUILDKITE_BUILD_NUMBER,s=r!==void 0&&r!==""?Number.parseInt(r,10):void 0,n=e.BUILDKITE_ORGANIZATION_SLUG,i=e.BUILDKITE_PIPELINE_SLUG,a=n!==void 0&&n!==""&&i!==void 0&&i!==""?`${n}/${i}`:void 0;return{apiBaseUrl:(e.BUILDKITE_API_BASE_URL??"https://api.buildkite.com").replace(/\/+$/,""),buildId:e.BUILDKITE_BUILD_ID,buildNumber:Number.isFinite(s)?s:void 0,prNumber:Number.isFinite(o)?o:void 0,provider:"buildkite",repo:a,sha:e.BUILDKITE_COMMIT,token:e.BUILDKITE_API_TOKEN}},Y=async(e=process.env)=>e.GITHUB_ACTIONS==="true"?await q(e):e.GITLAB_CI==="true"?z(e):e.BUILDKITE==="true"?X(e):{apiBaseUrl:void 0,buildId:void 0,buildNumber:void 0,prNumber:void 0,provider:"unknown",repo:void 0,sha:void 0,token:void 0},Q=(e,t,o,r)=>new Promise(s=>{const n=["pr","comment",String(t),"--body-file","-"];r&&n.push("--repo",r);const i=h(e,n,{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(o)}),Z=async(e,t,o,r,s)=>{const n=`https://api.github.com/repos/${t}/issues/${String(o)}/comments`;try{const i=await e(n,{body:JSON.stringify({body:r}),headers:{Accept:"application/vnd.github+json",Authorization:`Bearer ${s}`,"Content-Type":"application/json","X-GitHub-Api-Version":"2022-11-28"},method:"POST"});if(!i.ok){const a=await i.text().catch(()=>"");return{error:`GitHub REST returned ${String(i.status)}: ${a.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(i){return{error:i instanceof Error?i.message:String(i),ok:!1}}},W=async(e,t,o,r,s,n)=>{const i=encodeURIComponent(o),a=`${t.replace(/\/+$/,"")}/projects/${i}/merge_requests/${String(r)}/notes`;try{const d=await e(a,{body:JSON.stringify({body:s}),headers:{"Content-Type":"application/json","PRIVATE-TOKEN":n},method:"POST"});if(!d.ok){const c=await d.text().catch(()=>"");return{error:`GitLab REST returned ${String(d.status)}: ${c.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(d){return{error:d instanceof Error?d.message:String(d),ok:!1}}},tt=(e,t,o,r)=>new Promise(s=>{const i=h(e,["annotate","--style",o,"--context",r],{stdio:["pipe","ignore","pipe"]});let a="";i.stderr?.setEncoding("utf8"),i.stderr?.on("data",d=>{a+=d}),i.once("error",()=>{s({exitCode:127,stderr:a})}),i.once("close",d=>{s({exitCode:d??-1,stderr:a})}),i.stdin?.on("error",()=>{}),i.stdin?.end(t)}),et=async(e,t,o,r,s,n,i,a)=>{const[d,c]=o.split("/",2);if(!d||!c)return{error:`Buildkite repo identifier \`${o}\` is not in {org}/{pipeline} form.`,ok:!1};const f=`${t}/v2/organizations/${encodeURIComponent(d)}/pipelines/${encodeURIComponent(c)}/builds/${String(r)}/annotations`;try{const u=await e(f,{body:JSON.stringify({body:s,context:i,style:n}),headers:{Authorization:`Bearer ${a}`,"Content-Type":"application/json"},method:"POST"});if(!u.ok){const l=await u.text().catch(()=>"");return{error:`Buildkite REST returned ${String(u.status)}: ${l.slice(0,500)}`,ok:!1}}return{ok:!0}}catch(u){return{error:u instanceof Error?u.message:String(u),ok:!1}}},ot=async(e,t,o,r)=>{const s=t.buildId?`vis-ai-heal-${t.buildId}`:"vis-ai-heal",n="info",i=await tt(o,e,n,s);if(i.exitCode===0)return{method:"buildkite-cli",posted:!0};if(!t.apiBaseUrl||!t.repo||t.buildNumber===void 0||!t.token){const d=[];return t.repo||d.push("BUILDKITE_ORGANIZATION_SLUG / BUILDKITE_PIPELINE_SLUG"),t.buildNumber===void 0&&d.push("BUILDKITE_BUILD_NUMBER"),t.token||d.push("BUILDKITE_API_TOKEN (with `write_build_annotations` scope)"),{error:`buildkite-agent annotate exited ${String(i.exitCode)} (${i.stderr.trim().slice(0,200)}); cannot fall back to REST without ${d.join(", ")}`,method:"buildkite-cli",posted:!1}}const a=await et(r,t.apiBaseUrl,t.repo,t.buildNumber,e,n,s,t.token);return a.ok?{method:"rest",posted:!0}:{error:`buildkite-agent annotate exited ${String(i.exitCode)}; REST fallback also failed: ${a.error??"unknown"}`,method:"rest",posted:!1}},rt=async(e,t,o,r)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};const s=await Q(o,t.prNumber,e,t.repo);if(s.exitCode===0)return{method:"gh-cli",posted:!0};if(!t.repo||!t.token)return{error:`gh exited ${String(s.exitCode)} (${s.stderr.trim().slice(0,200)}); cannot fall back to REST without GITHUB_REPOSITORY + GITHUB_TOKEN`,method:"gh-cli",posted:!1};const n=await Z(r,t.repo,t.prNumber,e,t.token);return n.ok?{method:"rest",posted:!0}:{error:`gh exited ${String(s.exitCode)}; REST fallback also failed: ${n.error??"unknown"}`,method:"rest",posted:!1}},it=async(e,t,o)=>{if(t.prNumber===void 0)return{method:"skipped",posted:!1};if(!t.apiBaseUrl||!t.repo)return{error:"GitLab CI context is missing CI_API_V4_URL or CI_PROJECT_ID; cannot post note.",method:"rest",posted:!1};if(!t.token)return{error:"GitLab CI context has no token. CI_JOB_TOKEN cannot post MR notes — set GITLAB_TOKEN to a personal/project access token with `api` scope.",method:"rest",posted:!1};const r=await W(o,t.apiBaseUrl,t.repo,t.prNumber,e,t.token);return r.ok?{method:"rest",posted:!0}:{error:r.error,method:"rest",posted:!1}},nt=async e=>{const{body:t,buildkiteAgentBin:o="buildkite-agent",context:r,fetchImpl:s=globalThis.fetch,ghBin:n="gh"}=e;return r.provider==="github-actions"?await rt(t,r,n,s):r.provider==="gitlab-ci"?await it(t,r,s):r.provider==="buildkite"?await ot(t,r,o,s):{method:"skipped",posted:!1}},b=e=>{let t=0,o=0;for(const r of e)r.status==="applied"?t+=1:o+=1;return{applied:t,failed:o}},k=(e,t,o)=>{const r=K(e,t,o),s=O(e,r);return s===""||s.startsWith("..")?r:s},st=(e,t,o,r)=>new Promise(s=>{const n=process.argv[1];if(!n){s({exitCode:-1,stderr:"Cannot locate vis bin (process.argv[1] missing).",stdout:""});return}const i=[n,"run",o,"--projects",t,"--no-cache","--summarize","--fail-fast"],a=h(process.execPath,i,{cwd:e,env:{...process.env,NO_COLOR:"1"},stdio:["ignore","pipe","pipe"]});let d="",c="";const f=setTimeout(()=>{a.kill("SIGTERM"),setTimeout(()=>a.kill("SIGKILL"),2e3).unref()},r);a.stdout?.setEncoding("utf8"),a.stdout?.on("data",u=>{d+=u}),a.stderr?.setEncoding("utf8"),a.stderr?.on("data",u=>{c+=u}),a.once("error",u=>{clearTimeout(f),s({exitCode:-1,stderr:u.message,stdout:d})}),a.once("close",u=>{clearTimeout(f),s({exitCode:u??-1,stderr:c,stdout:d})})}),at=6e4,T=e=>{let t=0;const o=e.match(/`{3,}/g);if(o)for(const r of o)t=Math.max(t,r.length);return"`".repeat(Math.max(3,t+1))},_=(e,t,o)=>{if(e.patches.length===0)return"_No patches proposed._";const r=[];for(const[s,n]of e.patches.entries()){const i=k(t,o,n.file),a=[`**[${String(s+1)}] \`${i}\`**`];n.reason&&a.push(`_${n.reason}_`);const d=T(`${n.oldString}
2
2
  ${n.newString}`);a.push(`${d}diff`);for(const c of n.oldString.split(`
3
3
  `))a.push(`- ${c}`);for(const c of n.newString.split(`
4
4
  `))a.push(`+ ${c}`);a.push(d),r.push(a.join(`