@visulima/vis 1.0.0-alpha.17 → 1.0.0-alpha.19

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.
@@ -1,25 +1,24 @@
1
- var he=Object.defineProperty;var D=(e,s)=>he(e,"name",{value:s,configurable:!0});import{createRequire as ke}from"node:module";import{aK as re,aL as ee,a9 as E,aG as Pe,aF as L,aI as G,aM as ve,S as te,b6 as oe,c as w,j as v,E as u,q as R,e as x,d as b,af as we,R as De,b7 as be,b8 as xe,b9 as Ne,ba as Je}from"./bin.js";import{M,a as I,n as W,$ as Te,B as Se,w as C,C as K,z as P}from"./config.js";import{o as ie}from"../packem_shared/index-DH-5hsrC.js";const ye=ke(import.meta.url),z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,$e=D(e=>{if(typeof z<"u"&&z.versions&&z.versions.node){const[s,o]=z.versions.node.split(".").map(Number);if(s>22||s===22&&o>=3||s===20&&o>=16)return z.getBuiltinModule(e)}return ye(e)},"__cjs_getBuiltinModule"),{readFileSync:pe,writeFileSync:se}=$e("node:fs");var Re=Object.defineProperty,O=D((e,s)=>Re(e,"name",{value:s,configurable:!0}),"r$3");const Me=O(e=>/[*?[\]{}!]/.test(e),"isGlob"),We=O(e=>typeof e=="string"?e:e.reason,"ruleReason"),je=O(e=>typeof e=="string"?void 0:e.replacement,"ruleReplacement"),ae=O((e,s)=>e.some(o=>ie(o,s)),"matchesAnyGlob"),ne=O((e,s)=>{if(typeof e=="string")return!0;const o=Array.isArray(e.packages)&&e.packages.length>0,t=Array.isArray(e.paths)&&e.paths.length>0;return!!(!o&&!t||o&&s.packageName!==void 0&&ae(e.packages,s.packageName)||t&&ae(e.paths,s.packageDir))},"ruleAppliesToInstance"),Fe=O((e,s)=>{const o=s[e.depName];if(o!==void 0&&ne(o,e))return{pattern:e.depName,rule:o};for(const[t,r]of Object.entries(s))if(Me(t)&&ie(t,e.depName)&&ne(r,e))return{pattern:t,rule:r}},"findMatchingRule"),Ie=O((e,s)=>{if(Object.keys(s).length===0)return[];const o=[];for(const t of e){if(t.isInternal)continue;const r=Fe(t,s);r&&o.push({depName:t.depName,depType:t.depType,matchedPattern:r.pattern,packageDir:t.packageDir,packageJsonPath:t.packageJsonPath,packageName:t.packageName,reason:We(r.rule),replacement:je(r.rule),specifier:t.specifier})}return o},"lintBannedDeps");var Ee=Object.defineProperty,_=D((e,s)=>Ee(e,"name",{value:s,configurable:!0}),"m");const Ce=new Set(["dependencies","devDependencies","peerDependencies"]),Ve=_(e=>e.startsWith("catalog:"),"isCatalogReference"),Ae=_(e=>e.startsWith("workspace:"),"isWorkspaceReference"),Oe=_((e,s)=>{if(!e)return!1;for(const o of e.values())if(o.has(s))return!0;return!1},"isPinnedInAnyCatalog"),He=_((e,s={})=>{const o=s.min??3,t=new Set(s.ignoreDeps),r=e.filter(i=>i.isInternal||!Ce.has(i.depType)||Ae(i.specifier)||s.dep!==void 0&&i.depName!==s.dep?!1:!t.has(i.depName)),n=new Map;for(const i of r){const p=n.get(i.depName);p?p.push(i):n.set(i.depName,[i])}const a=[];for(const[i,p]of n){if(Oe(s.catalogs,i)||p.some(m=>Ve(m.specifier)))continue;const c=new Map;for(const m of p){let d=c.get(m.specifier);d||(d=new Set,c.set(m.specifier,d)),d.add(m.packageJsonPath)}const f=[...c.entries()].sort((m,d)=>m[1].size!==d[1].size?d[1].size-m[1].size:m[0].localeCompare(d[0]))[0];!f||f[1].size<o||a.push({catalogName:"default",depName:i,instanceCount:f[1].size,specifier:f[0]})}return a.sort((i,p)=>i.depName.localeCompare(p.depName))},"proposeCatalogAdditions"),_e=_((e,s)=>{if(s.length===0)return;const o=M(e,"pnpm-workspace.yaml"),t=I(o)?pe(o,"utf8"):"",r=t.includes(`\r
2
- `)?`\r
3
- `:`
4
- `,n=s.filter(d=>d.catalogName==="default").sort((d,g)=>d.depName.localeCompare(g.depName));if(n.length===0)return;const a=t.length>0?t.split(r):[],i=a.findIndex(d=>/^catalog\s*:\s*$/.test(d));if(i===-1){const d=["catalog:"];for(const $ of n)d.push(` ${$.depName}: "${$.specifier}"`);let g=0;for(;g<a.length&&(a[g]??"").trim().length===0;)g+=1;const h=[...a.slice(0,g),...d,"",...a.slice(g)].join(r);return se(o,h.endsWith(r)?h:`${h}${r}`),o}let p=a.length;const c=new Set;for(let d=i+1;d<a.length;d+=1){const g=a[d]??"",h=g.trimStart();if(g.length===0)continue;if(g.length-h.length===0&&h.length>0&&!h.startsWith("#")){p=d;break}const $=/^([\w./@-]+)\s*:/.exec(h);$?.[1]&&c.add($[1])}const f=[];for(const d of n)c.has(d.depName)||f.push(` ${d.depName}: "${d.specifier}"`);if(f.length===0)return;const m=[...a.slice(0,p),...f,...a.slice(p)].join(r);return se(o,m.endsWith(r)?m:`${m}${r}`),o},"applyCatalogProposals"),ze=_((e,s)=>{if(s.length===0)return"";const o=M(e,"pnpm-workspace.yaml"),t=I(o)?pe(o,"utf8"):"",r=[...s].sort((i,p)=>i.depName.localeCompare(p.depName)),n=["--- pnpm-workspace.yaml","+++ pnpm-workspace.yaml"],a=t.includes(`\r
5
- `)?`\r
6
- `:`
7
- `;if((t.length>0?t.split(a):[]).findIndex(i=>/^catalog\s*:\s*$/.test(i))===-1){n.push("@@ +1 @@","+catalog:");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}else{n.push("@@ catalog: @@");for(const i of r)n.push(`+ ${i.depName}: "${i.specifier}"`)}return n.join(a)},"renderCatalogProposalsDiff");var Be=Object.defineProperty,ce=D((e,s)=>Be(e,"name",{value:s,configurable:!0}),"l");const Le=ce(e=>{const s=[],o=re(e);if(o){const r=M(e,"pnpm-workspace.yaml");for(const n of o)n.startsWith("!")||ee(e,[n]).length===0&&s.push({pattern:n,source:"pnpm-workspace.yaml",sourcePath:r})}const t=M(e,"package.json");if(I(t)){const r=W(t).workspaces,n=Array.isArray(r)?r:r?.packages;if(n)for(const a of n)typeof a!="string"||a.startsWith("!")||ee(e,[a]).length===0&&s.push({pattern:a,source:"package.json",sourcePath:t})}return s},"lintDeadWorkspacePatterns"),qe=ce((e,s={})=>{const{useEditorconfig:o}=s,t=new Map;for(const n of e){const a=t.get(n.sourcePath);a?a.push(n):t.set(n.sourcePath,[n])}const r=[];for(const[n,a]of t){const i=new Set(a.map(f=>f.pattern));if(n.endsWith(".yaml")||n.endsWith(".yml")){const f=Te(n).split(`
8
- `).filter(m=>{const d=m.trim();if(!d.startsWith("- "))return!0;const g=d.slice(2).replaceAll(/^['"]|['"]$/g,"");return!i.has(g)}).join(`
9
- `);Se(n,f,{overwrite:!0}),r.push(n);continue}const p=W(n),c=p.workspaces;Array.isArray(c)?p.workspaces=c.filter(f=>typeof f!="string"||!i.has(f)):c&&Array.isArray(c.packages)&&(c.packages=c.packages.filter(f=>typeof f!="string"||!i.has(f))),C(n,p,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},"applyDeadWorkspacePatternFixes");var Ue=Object.defineProperty,fe=D((e,s)=>Ue(e,"name",{value:s,configurable:!0}),"f$2");const Ge=["dependencies","devDependencies","peerDependencies","optionalDependencies"],Ke=fe((e,s={})=>{const o=new Set(s.ignoreBlocks),t=Pe(e),r=[];for(const n of t){const a=M(e,n,"package.json"),i=L(a);if(!i)continue;const p=typeof i.name=="string"?i.name:void 0;for(const c of Ge){if(o.has(c))continue;const f=i[c];typeof f=="object"&&f!==null&&!Array.isArray(f)&&Object.keys(f).length===0&&r.push({depType:c,packageDir:n,packageJsonPath:a,packageName:p})}}return r},"lintEmptyDeps"),Qe=fe((e,s={})=>{const{useEditorconfig:o}=s,t=new Map;for(const n of e){const a=t.get(n.packageJsonPath);a?a.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,a]of t){const i=W(n);for(const p of a){const c=i[p.depType];typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.keys(c).length===0&&Reflect.deleteProperty(i,p.depType)}C(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},"applyEmptyDepsFixes");var Xe=Object.defineProperty,le=D((e,s)=>Xe(e,"name",{value:s,configurable:!0}),"o");const Ye=/\/+$/,Q=/node_modules/,X=/\.git/,Ze=/[$()+.?[\\\]^{|}]/g,et=/\/\*\*$|\/\*\/\*$/,tt=le((e,s)=>{const o=s.replace(Ye,"");if(o.startsWith("!"))return[];const t=[];if(o.endsWith("/*")){const n=o.slice(0,-2),a=K(e,n);if(!I(a))return[];for(const i of G(a,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[Q,X]}))i.path===a||i.name.startsWith(".")||t.push(M(n,i.name));return t}if(o.endsWith("/**")||o.endsWith("/*/*")){const n=o.replace(et,""),a=K(e,n);if(!I(a))return[];for(const i of G(a,{includeFiles:!1,includeSymlinks:!1,skip:[Q,X]})){if(i.path===a)continue;const p=i.path.slice(a.length+1);t.push(`${n}/${p}`)}return t}if(!o.includes("/")&&o.includes("*")){const n=o.replaceAll(Ze,"\\$&").replaceAll("*",".*"),a=new RegExp(`^${n}$`);for(const i of G(e,{includeFiles:!1,includeSymlinks:!1,maxDepth:1,skip:[Q,X]}))i.path!==e&&a.test(i.name)&&t.push(i.name);return t}const r=K(e,o);return I(r)&&t.push(o),t},"collectPatternMatches"),ot=le(e=>{const s=re(e)??ve(e)??[],o=new Set,t=[];for(const r of s)for(const n of tt(e,r))n==="."||o.has(n)||(o.add(n),I(M(e,n,"package.json"))||t.push({packageDir:n}));return t},"lintMissingPackageJson");var st=Object.defineProperty,at=D((e,s)=>st(e,"name",{value:s,configurable:!0}),"r$2");const nt=["dependencies","devDependencies","optionalDependencies","peerDependencies"],rt=at((e,s={})=>{const o=new Set(s.depTypes??nt),t=new Set(s.ignoreDeps),r=new Map;for(const a of e)a.packageDir!=="."||!o.has(a.depType)||r.set(a.depName,{depType:a.depType,specifier:a.specifier});if(r.size===0)return[];const n=[];for(const a of e){if(a.packageDir==="."||!o.has(a.depType)||t.has(a.depName))continue;const i=r.get(a.depName);i&&n.push({childSpecifier:a.specifier,depName:a.depName,depType:a.depType,packageDir:a.packageDir,packageJsonPath:a.packageJsonPath,packageName:a.packageName,rootDepType:i.depType,rootSpecifier:i.specifier})}return n},"lintRedefineRoot");var it=Object.defineProperty,ge=D((e,s)=>it(e,"name",{value:s,configurable:!0}),"a$1");const pt=ge((e,s)=>{if(!s)return[];const o=M(e,"package.json"),t=L(o);if(!t)return[];if(t.private!==!0)return[];const r=t.dependencies;if(typeof r!="object"||r===null||Array.isArray(r))return[];const n=Object.keys(r);return n.length===0?[]:[{depNames:n,packageJsonPath:o}]},"lintRootDeps"),ct=ge((e,s={})=>{const{useEditorconfig:o}=s,t=[];for(const r of e){const n=W(r.packageJsonPath),a=n.dependencies;if(typeof a!="object"||a===null)continue;const i=a;n.devDependencies??={};const p=n.devDependencies;for(const c of r.depNames){const f=i[c];typeof f=="string"&&(c in p||(p[c]=f),Reflect.deleteProperty(i,c))}Object.keys(i).length===0&&Reflect.deleteProperty(n,"dependencies"),C(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},"applyRootDepsFixes");var ft=Object.defineProperty,de=D((e,s)=>ft(e,"name",{value:s,configurable:!0}),"r$1");const lt=/^[a-z][\w-]*@\S+$/i,gt=de((e,s,o={})=>{if(!s)return[];const t=M(e,"package.json"),r=L(t);if(!r)return[];const n=r.packageManager;return typeof n=="string"&&lt.test(n)?[]:[{packageJsonPath:t,suggested:o.suggested}]},"lintRootPackageManager"),dt=de((e,s={})=>{const{useEditorconfig:o}=s,t=[];for(const r of e){if(!r.suggested)continue;const n=W(r.packageJsonPath);n.packageManager=r.suggested,C(r.packageJsonPath,n,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},"applyRootPackageManagerFixes");var ut=Object.defineProperty,ue=D((e,s)=>ut(e,"name",{value:s,configurable:!0}),"a");const mt=ue((e,s)=>{if(!s)return[];const o=M(e,"package.json"),t=L(o);return t?t.private===!0?[]:[{packageJsonPath:o,rawValue:t.private}]:[]},"lintRootPrivate"),ht=ue((e,s={})=>{const{useEditorconfig:o}=s,t=[];for(const r of e){const n=W(r.packageJsonPath);let a=n;if("private"in n)n.private=!0;else{const{name:i,version:p,...c}=n,f={};i!==void 0&&(f.name=i),p!==void 0&&(f.version=p),f.private=!0;for(const[m,d]of Object.entries(c))f[m]=d;a=f}C(r.packageJsonPath,a,{indent:E(r.packageJsonPath,{useEditorconfig:o}),overwrite:!0}),t.push(r.packageJsonPath)}return t},"applyRootPrivateFixes");var kt=Object.defineProperty,Z=D((e,s)=>kt(e,"name",{value:s,configurable:!0}),"p$1");const yt=[{id:"react",label:"React",members:["react","react-dom","react-test-renderer"]},{id:"next",label:"Next.js",members:["next","@next/font","@next/bundle-analyzer","@next/mdx","@next/third-parties","@next/eslint-plugin-next","eslint-config-next"]},{id:"babel",label:"Babel",prefixes:["@babel/"]},{id:"storybook",label:"Storybook",members:["storybook","sb"],prefixes:["@storybook/"]},{id:"vitest",label:"Vitest",members:["vitest"],prefixes:["@vitest/"]},{id:"playwright",label:"Playwright",members:["playwright","@playwright/test"]},{id:"trpc",label:"tRPC",prefixes:["@trpc/"]},{id:"prisma",label:"Prisma",members:["prisma"],prefixes:["@prisma/"]},{id:"turborepo",label:"Turborepo",members:["turbo","turbo-ignore","@turbo/gen","eslint-config-turbo","eslint-plugin-turbo"]},{id:"typescript-eslint",label:"typescript-eslint",members:["typescript-eslint"],prefixes:["@typescript-eslint/"]},{id:"eslint-stylistic",label:"ESLint Stylistic",prefixes:["@stylistic/"]},{id:"lexical",label:"Lexical",members:["lexical"],prefixes:["@lexical/"]},{id:"nx",label:"Nx",prefixes:["@nx/","@nrwl/"]}],$t=new Set(["dependencies","devDependencies","peerDependencies"]),Pt=Z((e,s)=>{for(const o of e)if(o.members?.includes(s)||o.prefixes?.some(t=>s.startsWith(t)))return o},"familyForDep"),vt=Z(e=>e.startsWith("workspace:")||e.startsWith("catalog:"),"isWorkspaceOrCatalogReference"),wt=Z((e,s={})=>{const o=new Set(s.ignoreFamilies),t=new Map;for(const i of yt)t.set(i.id,i);for(const i of s.extraFamilies??[])t.set(i.id,i);const r=[...t.values()],n=new Map;for(const i of e){if(i.isInternal||!$t.has(i.depType)||vt(i.specifier))continue;const p=Pt(r,i.depName);if(!p||o.has(p.id))continue;const c=n.get(p.id),f={depName:i.depName,depType:i.depType,packageDir:i.packageDir,packageJsonPath:i.packageJsonPath,packageName:i.packageName,specifier:i.specifier};c?c.push(f):n.set(p.id,[f])}const a=[];for(const[i,p]of n){const c=[...new Set(p.map(m=>m.specifier))];if(c.length<2)continue;const f=t.get(i);f&&a.push({family:i,familyLabel:f.label??i,members:p,specifiers:c})}return a},"lintSimilarDeps");var Dt=Object.defineProperty,B=D((e,s)=>Dt(e,"name",{value:s,configurable:!0}),"r");const bt=B(e=>e.startsWith("@types/"),"isTypesPackage"),xt=B((e,s={})=>{const o=new Set(s.ignoreDeps),t=new Map,r=B(a=>{const i=t.get(a);if(i!==void 0)return i;try{const p=W(a).private===!0;return t.set(a,p),p}catch{return t.set(a,!1),!1}},"isPrivate"),n=[];for(const a of e)a.depType==="dependencies"&&bt(a.depName)&&(o.has(a.depName)||r(a.packageJsonPath)&&n.push({childSpecifier:a.specifier,depName:a.depName,packageDir:a.packageDir,packageJsonPath:a.packageJsonPath,packageName:a.packageName}));return n},"lintTypesInDeps"),Nt=B((e,s={})=>{const{useEditorconfig:o}=s,t=new Map;for(const n of e){const a=t.get(n.packageJsonPath);a?a.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,a]of t){const i=W(n),p=i.dependencies;if(typeof p!="object"||p===null)continue;const c=p;i.devDependencies??={};const f=i.devDependencies;for(const m of a){const d=c[m.depName];typeof d=="string"&&(m.depName in f||(f[m.depName]=d),Reflect.deleteProperty(c,m.depName))}Object.keys(c).length===0&&Reflect.deleteProperty(i,"dependencies"),C(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},"applyTypesInDepsFixes");var Jt=Object.defineProperty,q=D((e,s)=>Jt(e,"name",{value:s,configurable:!0}),"f");const Tt=q(e=>e.startsWith("workspace:"),"isWorkspaceSpecifier"),St=q((e,s={})=>{const o=s.fixSpecifier??"workspace:*",t=[];for(const r of e)r.isInternal&&(Tt(r.specifier)||t.push({depName:r.depName,depType:r.depType,fix:o,packageDir:r.packageDir,packageJsonPath:r.packageJsonPath,packageName:r.packageName,specifier:r.specifier}));return t},"lintWorkspaceProtocol"),Rt=q((e,s,o,t)=>{const r=s.split(".");let n=e;for(let p=0;p<r.length-1;p+=1){const c=r[p],f=n[c];(typeof f!="object"||f===null)&&(n[c]={}),n=n[c]}const a=r.at(-1);let i=n[a];(typeof i!="object"||i===null)&&(i={},n[a]=i),i[o]=t},"setNestedField"),Mt=q((e,s={})=>{const{useEditorconfig:o}=s,t=new Map;for(const n of e){const a=t.get(n.packageJsonPath);a?a.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,a]of t){const i=W(n);for(const p of a)if(p.depType.includes("."))Rt(i,p.depType,p.depName,p.fix);else{const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}C(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},"applyWorkspaceProtocolFixes");var Wt=Object.defineProperty,V=D((e,s)=>Wt(e,"name",{value:s,configurable:!0}),"p");const jt=new Set(["dependencies","devDependencies","peerDependencies"]),Ft=V(e=>e.startsWith("catalog:"),"isCatalogReference"),It=V(e=>e.startsWith("workspace:"),"isWorkspaceReference"),Et=V(e=>{if(!e.startsWith("catalog:"))return;const s=e.slice(8);return s===""?"default":s},"catalogNameOf"),Ct=V((e,s)=>{if(e.get("default")?.has(s))return"default";const o=[...e.keys()].filter(t=>t!=="default").sort();for(const t of o)if(e.get(t)?.has(s))return t},"findCatalogPinning"),Vt=V(e=>e==="default"?"catalog:":`catalog:${e}`,"buildCatalogSpecifier"),At=V((e,s)=>{const o=[...e].sort((r,n)=>(r.packageName??r.packageDir).localeCompare(n.packageName??n.packageDir));let t;for(const r of o){const n=te(r.specifier);if(!n)continue;if(!t){t=r;continue}const a=te(t.specifier);if(!a){t=r;continue}const i=oe(a,n),p=oe(n,a);(s==="highest"&&i||s==="lowest"&&p)&&(t=r)}if(t)return{canonical:t,canonicalSource:t.packageName??t.packageDir}},"pickCanonicalBySemver"),Ot=V((e,s={})=>{const o=s.resolve??"highest",t=new Set(s.ignoreDeps),r=[],n=e.filter(i=>i.isInternal||!jt.has(i.depType)||It(i.specifier)||s.dep!==void 0&&i.depName!==s.dep?!1:!t.has(i.depName)),a=new Map;for(const i of n){const p=a.get(i.depName);p?p.push(i):a.set(i.depName,[i])}for(const[i,p]of a){const c=s.pinned?.get(i);if(c!==void 0){for(const g of p)g.specifier!==c&&r.push({canonicalSource:"cli:--pin",depName:i,depType:g.depType,fix:c,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier});continue}if(o==="catalog"){const{catalogs:g}=s;if(!g)continue;const h=Ct(g,i);if(!h)continue;const $=Vt(h);for(const T of p)Et(T.specifier)!==h&&r.push({canonicalSource:`catalog:${h}`,depName:i,depType:T.depType,fix:$,packageDir:T.packageDir,packageJsonPath:T.packageJsonPath,packageName:T.packageName,specifier:T.specifier});continue}const f=p.filter(g=>!Ft(g.specifier));if(f.length<2||new Set(f.map(g=>g.specifier)).size<=1)continue;const m=At(f,o);if(!m)continue;const d=m.canonical.specifier;for(const g of f)g.specifier!==d&&r.push({canonicalSource:m.canonicalSource,depName:i,depType:g.depType,fix:d,packageDir:g.packageDir,packageJsonPath:g.packageJsonPath,packageName:g.packageName,specifier:g.specifier})}return r},"lintWorkspaceVersions"),Ht=V((e,s={})=>{const{useEditorconfig:o}=s,t=new Map;for(const n of e){const a=t.get(n.packageJsonPath);a?a.push(n):t.set(n.packageJsonPath,[n])}const r=[];for(const[n,a]of t){const i=W(n);for(const p of a){const c=i[p.depType];typeof c=="object"&&c!==null&&(c[p.depName]=p.fix)}C(n,i,{indent:E(n,{useEditorconfig:o}),overwrite:!0}),r.push(n)}return r},"applyWorkspaceVersionsFixes");var _t=Object.defineProperty,y=D((e,s)=>_t(e,"name",{value:s,configurable:!0}),"u");const zt=y(e=>{if(I(M(e,"pnpm-workspace.yaml")))return!0;const s=M(e,"package.json");if(!I(s))return!1;try{return W(s).workspaces!==void 0}catch{return!1}},"detectWorkspaceConfig"),A=y((e,s)=>{const o=new Map;for(const t of e){const r=s(t),n=o.get(r);n?n.push(t):o.set(r,[t])}return o},"groupBy"),Bt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ workspace-protocol: no violations"));return}const r=o?"Fixed":"Found",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} workspace-protocol violation${e.length===1?"":"s"}`)));for(const[a,i]of A(e,p=>p.packageName??p.packageJsonPath)){const p=P(s,i[0].packageJsonPath);t.info(` ${v(a)} ${u(`(${p})`)}`);for(const c of i){const f=o?R("→"):x("→");t.info(` ${u(c.depType)} ${c.depName}: ${b(c.specifier)} ${f} ${w(c.fix)}`)}}o||t.info(u(" Run with --fix to rewrite specifiers in place."))},"printWorkspaceProtocolHuman"),Lt=y((e,s,o)=>{if(e.length===0){o.info(w("✓ redefine-root: no violations"));return}o.info(x(v(`Found ${String(e.length)} dep${e.length===1?"":"s"} re-declared from root`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=P(s,r[0].packageJsonPath);o.info(` ${v(t)} ${u(`(${n})`)}`);for(const a of r)o.info(` ${u(a.depType)} ${a.depName}: ${b(a.childSpecifier)} ${u(`(root ${a.rootDepType}: ${a.rootSpecifier})`)}`)}o.info(u(" Remove these from child package.json files — root pin will resolve."))},"printRedefineRootHuman"),qt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ workspace-versions: no drift"));return}const r=o?"Fixed":"Found",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} workspace-version drift${e.length===1?"":"s"}`)));for(const[a,i]of A(e,p=>p.depName)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${v(a)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=P(s,f.packageJsonPath),d=f.packageName??m,g=o?R("→"):x("→");t.info(` ${d} ${u(`(${m})`)} ${u(f.depType)}: ${b(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align drifting specifiers."))},"printWorkspaceVersionsHuman"),Ut=y((e,s,o)=>{if(e.length===0){o.info(w("✓ banned-deps: no violations"));return}o.info(b(v(`Found ${String(e.length)} banned dep${e.length===1?"":"s"}`)));for(const[t,r]of A(e,n=>n.packageName??n.packageJsonPath)){const n=P(s,r[0].packageJsonPath);o.info(` ${v(t)} ${u(`(${n})`)}`);for(const a of r){const i=a.replacement?` ${u("→")} ${w(a.replacement)}`:"";o.info(` ${u(a.depType)} ${b(a.depName)}${i}`),o.info(` ${u(a.reason)}`)}}},"printBannedDepsHuman"),Gt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ catalog-proposals: nothing worth promoting"));return}const r=o?"Added":"Would add",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} catalog entr${e.length===1?"y":"ies"}`)));for(const a of e)t.info(` ${v(a.depName)}: ${w(a.specifier)} ${u(`(${String(a.instanceCount)} packages agree)`)}`);if(!o){const a=ze(s,e);if(a){t.info(""),t.info(u("Proposed pnpm-workspace.yaml changes:"));for(const i of a.split(`
10
- `))i.startsWith("+")?t.info(w(i)):i.startsWith("-")?t.info(b(i)):t.info(u(i))}t.info(u(" Run with --fix to write these entries to pnpm-workspace.yaml."))}},"printCatalogProposalsHuman"),Kt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ custom-types: no engines / packageManager / volta drift"));return}const r=o?"Fixed":"Found",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} custom-type drift${e.length===1?"":"s"}`)));for(const[a,i]of A(e,p=>`${p.customType} ${p.depName}`)){const p=i[0].fix,c=i[0].canonicalSource;t.info(` ${v(a)} ${u(`canonical: ${p} (from ${c})`)}`);for(const f of i){const m=P(s,f.packageJsonPath),d=f.packageName??m,g=o?R("→"):x("→");t.info(` ${d} ${u(`(${m})`)}: ${b(f.specifier)} ${g} ${w(f.fix)}`)}}o||t.info(u(" Run with --fix to align engines/packageManager/volta versions."))},"printCustomTypesHuman"),Qt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ empty-deps: no empty dependency blocks"));return}const r=o?"Removed":"Found",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} empty dependency block${e.length===1?"":"s"}`)));for(const[a,i]of A(e,p=>p.packageName??p.packageJsonPath)){const p=P(s,i[0].packageJsonPath);t.info(` ${v(a)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${u(c.depType)}: ${b("{}")}`)}o||t.info(u(" Run with --fix to drop empty blocks."))},"printEmptyDepsHuman"),Xt=y((e,s,o,t)=>{if(e.length===0){t.info(w('✓ root-private: root package.json is "private": true'));return}const r=o?"Set":"Missing",n=o?R:b;for(const a of e){const i=P(s,a.packageJsonPath);if(t.info(n(v(`${r} "private": true on root ${u(`(${i})`)}`))),!o){const p=a.rawValue===void 0?"absent":JSON.stringify(a.rawValue);t.info(` ${u("current:")} ${b(p)}`)}}o||t.info(u(' Run with --fix to set "private": true.'))},"printRootPrivateHuman"),Yt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ root-package-manager: packageManager field present"));return}const r=o?"Set":"Missing",n=o?R:b;for(const a of e){const i=P(s,a.packageJsonPath);t.info(n(v(`${r} packageManager on root ${u(`(${i})`)}`))),!o&&!a.suggested&&t.info(u(" no canonical specifier configured (set policy.rootPackageManager.suggested to enable --fix)"))}o||t.info(u(' e.g. "packageManager": "pnpm@10.32.1"'))},"printRootPackageManagerHuman"),Zt=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ root-deps: no runtime dependencies on private root"));return}const r=o?"Moved":"Found",n=o?R:x;for(const a of e){const i=P(s,a.packageJsonPath);t.info(n(v(`${r} ${String(a.depNames.length)} runtime dep${a.depNames.length===1?"":"s"} on private root ${u(`(${i})`)}`)));for(const p of a.depNames)t.info(` ${b(p)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},"printRootDepsHuman"),eo=y((e,s)=>{if(e.length===0){s.info(w("✓ missing-package-json: every workspace dir has a package.json"));return}s.info(x(v(`Found ${String(e.length)} workspace dir${e.length===1?"":"s"} without a package.json`)));for(const o of e)s.info(` ${b(o.packageDir)}`);s.info(u(" Either delete the directory or scaffold a package.json (vis create)."))},"printMissingPackageJsonHuman"),to=y((e,s,o)=>{if(e.length===0){o.info(w("✓ dead-workspace-pattern: every workspace pattern matches at least one package"));return}const t=s?"Removed":"Found",r=s?R:x;o.info(r(v(`${t} ${String(e.length)} unmatched workspace pattern${e.length===1?"":"s"}`)));for(const[n,a]of A(e,i=>i.source)){o.info(` ${v(n)}`);for(const i of a)o.info(` ${b(i.pattern)}`)}s||o.info(u(" Run with --fix to drop dead patterns."))},"printDeadWorkspacePatternsHuman"),oo=y((e,s,o,t)=>{if(e.length===0){t.info(w("✓ types-in-deps: no @types/* in dependencies of private packages"));return}const r=o?"Moved":"Found",n=o?R:x;t.info(n(v(`${r} ${String(e.length)} @types/* dep${e.length===1?"":"s"} in dependencies`)));for(const[a,i]of A(e,p=>p.packageName??p.packageJsonPath)){const p=P(s,i[0].packageJsonPath);t.info(` ${v(a)} ${u(`(${p})`)}`);for(const c of i)t.info(` ${b(c.depName)} ${u(c.childSpecifier)}`)}o||t.info(u(" Run with --fix to move them to devDependencies."))},"printTypesInDepsHuman"),so=y((e,s,o)=>{if(e.length===0){o.info(w("✓ similar-deps: every related dep family is in sync"));return}o.info(x(v(`Found ${String(e.length)} family${e.length===1?"":" families"} with version drift`)));for(const t of e){o.info(` ${v(t.familyLabel)} ${u(`(${t.specifiers.join(", ")})`)}`);for(const r of t.members){const n=P(s,r.packageJsonPath),a=r.packageName??n;o.info(` ${a} ${u(`(${n})`)} ${u(r.depType)}: ${b(r.depName)}@${x(r.specifier)}`)}}o.info(u(" Pick a single specifier per family and align by hand — auto-fix is unsafe across name boundaries."))},"printSimilarDepsHuman"),ao=y((e,s,o,t,r)=>{let n=!0;const a=y(i=>{n||r.info(""),n=!1,i()},"section");t.workspaceProtocol&&a(()=>{Bt(e.workspaceProtocol??[],s,o.workspaceProtocol,r)}),t.redefineRoot&&a(()=>{Lt(e.redefineRoot??[],s,r)}),t.workspaceVersions&&a(()=>{qt(e.workspaceVersions??[],s,o.workspaceVersions,r)}),t.customTypes&&a(()=>{Kt(e.customTypes??[],s,o.customTypes,r)}),e.catalogProposals!==void 0&&a(()=>{Gt(e.catalogProposals??[],s,o.catalogProposals,r)}),t.bannedDeps&&a(()=>{Ut(e.bannedDeps??[],s,r)}),t.emptyDeps&&a(()=>{Qt(e.emptyDeps??[],s,o.emptyDeps,r)}),t.rootPrivate&&a(()=>{Xt(e.rootPrivate??[],s,o.rootPrivate,r)}),t.rootPackageManager&&a(()=>{Yt(e.rootPackageManager??[],s,o.rootPackageManager,r)}),t.rootDeps&&a(()=>{Zt(e.rootDeps??[],s,o.rootDeps,r)}),t.missingPackageJson&&a(()=>{eo(e.missingPackageJson??[],r)}),t.deadWorkspacePatterns&&a(()=>{to(e.deadWorkspacePatterns??[],o.deadWorkspacePatterns,r)}),t.typesInDeps&&a(()=>{oo(e.typesInDeps??[],s,o.typesInDeps,r)}),t.similarDeps&&a(()=>{so(e.similarDeps??[],s,r)})},"printHuman"),no=y((e,s)=>{for(const o of e.workspaceProtocol??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`workspace-protocol ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
11
- `)}for(const o of e.redefineRoot??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`redefine-root ${t} ${o.depType} ${o.depName} ${o.childSpecifier}
12
- `)}for(const o of e.workspaceVersions??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`workspace-versions ${t} ${o.depType} ${o.depName} ${o.specifier} → ${o.fix}
13
- `)}for(const o of e.customTypes??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`custom-types ${t} ${o.customType} ${o.depName} ${o.specifier} ${o.fix}
14
- `)}for(const o of e.bannedDeps??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`banned-deps ${t} ${o.depType} ${o.depName} ${o.reason}
15
- `)}for(const o of e.catalogProposals??[])process.stdout.write(`catalog-proposal ${o.catalogName} ${o.depName} ${o.specifier} ${String(o.instanceCount)}
16
- `);for(const o of e.emptyDeps??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`empty-deps ${t} ${o.depType}
17
- `)}for(const o of e.rootPrivate??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`root-private ${t}
18
- `)}for(const o of e.rootPackageManager??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`root-package-manager ${t} ${o.suggested??""}
19
- `)}for(const o of e.rootDeps??[]){const t=P(s,o.packageJsonPath);for(const r of o.depNames)process.stdout.write(`root-deps ${t} ${r}
20
- `)}for(const o of e.missingPackageJson??[])process.stdout.write(`missing-package-json ${o.packageDir}
21
- `);for(const o of e.deadWorkspacePatterns??[])process.stdout.write(`dead-workspace-pattern ${o.source} ${o.pattern}
22
- `);for(const o of e.typesInDeps??[]){const t=P(s,o.packageJsonPath);process.stdout.write(`types-in-deps ${t} ${o.depName} ${o.childSpecifier}
23
- `)}for(const o of e.similarDeps??[])for(const t of o.members){const r=P(s,t.packageJsonPath);process.stdout.write(`similar-deps ${o.family} ${r} ${t.depType} ${t.depName} ${t.specifier}
24
- `)}},"printMinimal"),ro=y((e,s,o,t)=>{const r=y(a=>({...a,packageJsonPath:P(s,a.packageJsonPath)}),"relativize"),n={fixed:o};if(t.workspaceProtocol){const a=(e.workspaceProtocol??[]).map(i=>r(i));n.workspaceProtocol={issues:a,total:a.length}}if(t.redefineRoot){const a=(e.redefineRoot??[]).map(i=>r(i));n.redefineRoot={issues:a,total:a.length}}if(t.workspaceVersions){const a=(e.workspaceVersions??[]).map(i=>r(i));n.workspaceVersions={issues:a,total:a.length}}if(t.customTypes){const a=(e.customTypes??[]).map(i=>r(i));n.customTypes={issues:a,total:a.length}}if(t.bannedDeps){const a=(e.bannedDeps??[]).map(i=>r(i));n.bannedDeps={issues:a,total:a.length}}if(e.catalogProposals!==void 0){const a=e.catalogProposals;n.catalogProposals={proposals:a,total:a.length}}if(t.emptyDeps){const a=(e.emptyDeps??[]).map(i=>r(i));n.emptyDeps={issues:a,total:a.length}}if(t.rootPrivate){const a=(e.rootPrivate??[]).map(i=>r(i));n.rootPrivate={issues:a,total:a.length}}if(t.rootPackageManager){const a=(e.rootPackageManager??[]).map(i=>r(i));n.rootPackageManager={issues:a,total:a.length}}if(t.rootDeps){const a=(e.rootDeps??[]).map(i=>r(i));n.rootDeps={issues:a,total:a.length}}if(t.missingPackageJson){const a=e.missingPackageJson??[];n.missingPackageJson={issues:a,total:a.length}}if(t.deadWorkspacePatterns){const a=e.deadWorkspacePatterns??[];n.deadWorkspacePatterns={issues:a,total:a.length}}if(t.typesInDeps){const a=(e.typesInDeps??[]).map(i=>r(i));n.typesInDeps={issues:a,total:a.length}}if(t.similarDeps){const a=(e.similarDeps??[]).map(i=>({...i,members:i.members.map(p=>({...p,packageJsonPath:P(s,p.packageJsonPath)}))}));n.similarDeps={issues:a,total:a.length}}process.stdout.write(`${JSON.stringify(n,void 0,2)}
25
- `)},"printJson"),S=y((e,s,o)=>{const t=e[s];return typeof t=="boolean"?t:e[o]===!0},"flag"),io=y(e=>{const s=e,o=(e.ban?.length??0)>0,t=(e.pin?.length??0)>0,r=S(s,"workspaceProtocol","workspace-protocol"),n=S(s,"redefineRoot","redefine-root"),a=S(s,"bannedDeps","banned-deps"),i=S(s,"workspaceVersions","workspace-versions"),p=S(s,"customTypes","custom-types"),c=S(s,"emptyDeps","empty-deps"),f=S(s,"rootPrivate","root-private"),m=S(s,"rootPackageManager","root-package-manager"),d=S(s,"rootDeps","root-deps"),g=S(s,"missingPackageJson","missing-package-json"),h=S(s,"deadWorkspacePatterns","dead-workspace-patterns"),$=S(s,"typesInDeps","types-in-deps"),T=S(s,"similarDeps","similar-deps");return r||n||a||i||p||c||f||m||d||g||h||$||T||o||t?{bannedDeps:a||o,customTypes:p,deadWorkspacePatterns:h,emptyDeps:c,missingPackageJson:g,redefineRoot:n,rootDeps:d,rootPackageManager:m,rootPrivate:f,similarDeps:T,typesInDeps:$,workspaceProtocol:r,workspaceVersions:i||t}:{bannedDeps:!0,customTypes:!0,deadWorkspacePatterns:!0,emptyDeps:!0,missingPackageJson:!0,redefineRoot:!0,rootDeps:!0,rootPackageManager:!0,rootPrivate:!0,similarDeps:!0,typesInDeps:!0,workspaceProtocol:!0,workspaceVersions:!0}},"resolveSelection"),po=y(e=>{const s=new Map;for(const o of e??[]){const t=o.lastIndexOf("@");if(t<=0||t===o.length-1)throw new Error(`Invalid --pin "${o}". Use: name@<specifier> (e.g. react@^18.2.0).`);const r=o.slice(0,t),n=o.slice(t+1);s.set(r,n)}return s},"parsePinFlags"),co=new Set(["catalog","highest","lowest"]),fo=y(e=>{if(e===void 0)return"highest";if(!co.has(e))throw new Error(`Invalid --resolve "${e}". Use: highest, lowest, or catalog.`);return e},"parseResolveStrategy"),F=y((e,s)=>e?s===void 0||s===!0:!1,"isAutofixAllowed"),lo={"custom-types":"policy.customTypes.autofix","workspace-protocol":"policy.workspaceProtocol.autofix","workspace-versions":"policy.workspaceVersions.autofix"},Y=y((e,s,o,t)=>{const r=lo[s],n=o==="prompt"?`${r} = "prompt" (interactive mode not yet implemented; report-only)`:`${r} = false`,a=`Set "${r}": true (or remove it) to enable rewrites.`;e.warn(`${s}: ${String(t)} issue${t===1?"":"s"} not rewritten — ${n}. ${a}`)},"warnAutofixDenied"),yo=y(async({logger:e,options:s,visConfig:o,workspaceRoot:t})=>{if(!t)throw new Error("Could not determine workspace root. Run this command inside a monorepo.");const r=t,n=s.fix??!1,a=s.format??"human",i=s.quiet??!1;if(!["human","json","minimal"].includes(a))throw new Error(`Invalid --format "${a}". Use: human, json, or minimal.`);const p=io(s),c=o?.policy??{},f=o?.editorconfig??!0,m=po(s.pin),d=s.ban??[];(s.dep!==void 0||s.resolve!==void 0)&&!p.workspaceVersions&&!i&&e.warn("--dep / --resolve only apply to --workspace-versions; ignored.");const g=we(r),h={},$={catalogProposals:!1,customTypes:!1,deadWorkspacePatterns:!1,emptyDeps:!1,rootDeps:!1,rootPackageManager:!1,rootPrivate:!1,typesInDeps:!1,workspaceProtocol:!1,workspaceVersions:!1},T=zt(r);let N=0;if(p.workspaceProtocol){const l=St(g,{fixSpecifier:s.fixSpecifier}),k=F(n,c.workspaceProtocol?.autofix);k&&l.length>0&&(Mt(l,{useEditorconfig:f}),$.workspaceProtocol=!0),h.workspaceProtocol=l,k||(N+=l.length),n&&!k&&l.length>0&&!i&&Y(e,"workspace-protocol",c.workspaceProtocol?.autofix,l.length)}if(p.redefineRoot){const l=rt(g,{ignoreDeps:c.redefineRoot?.ignore});h.redefineRoot=l,N+=l.length}if(p.workspaceVersions){const l=fo(s.resolve??c.workspaceVersions?.resolve),k=l==="catalog"?De(r):void 0;l==="catalog"&&(!k||k.size===0)&&!i&&e.warn("--resolve catalog: no catalog found in pnpm-workspace.yaml or root package.json — nothing to align.");const J=Ot(g,{catalogs:k,dep:s.dep,ignoreDeps:c.workspaceVersions?.ignore,pinned:m.size>0?m:void 0,resolve:l}),H=F(n,c.workspaceVersions?.autofix);if(H&&J.length>0&&(Ht(J,{useEditorconfig:f}),$.workspaceVersions=!0),h.workspaceVersions=J,H||(N+=J.length),n&&!H&&J.length>0&&!i&&Y(e,"workspace-versions",c.workspaceVersions?.autofix,J.length),s.proposeMin!==void 0){if(l!=="catalog"&&!i)e.warn("--propose-min only runs under --resolve catalog; ignored.");else if(l==="catalog"){const j=He(g,{catalogs:k,ignoreDeps:c.workspaceVersions?.ignore,min:s.proposeMin});H&&j.length>0&&(_e(r,j),$.catalogProposals=!0),h.catalogProposals=j}}}if(p.customTypes){const l=c.customTypes?.extraTypes,k=be(l);if(k.length>0){for(const me of k)e.error(`policy.customTypes.${me}`);process.exitCode=1;return}const J=xe(r,l),H=(s.resolve??c.customTypes?.resolve)==="lowest"?"lowest":"highest",j=Ne(J,{dep:s.dep,ignoreDeps:c.customTypes?.ignore,resolve:H}),U=F(n,c.customTypes?.autofix);U&&j.length>0&&(Je(j,{useEditorconfig:f}),$.customTypes=!0),h.customTypes=j,U||(N+=j.length),n&&!U&&j.length>0&&!i&&Y(e,"custom-types",c.customTypes?.autofix,j.length)}if(p.bannedDeps){const l={...c.bannedDeps};for(const J of d)l[J]={reason:"banned via --ban CLI flag"};Object.keys(l).length===0&&s.bannedDeps&&!i&&e.warn("--banned-deps: no policy.bannedDeps in vis config, nothing to check.");const k=Ie(g,l);h.bannedDeps=k,N+=k.length}if(p.emptyDeps){const l=Ke(r,{ignoreBlocks:c.emptyDeps?.ignoreBlocks}),k=F(n,c.emptyDeps?.autofix);k&&l.length>0&&(Qe(l,{useEditorconfig:f}),$.emptyDeps=!0),h.emptyDeps=l,k||(N+=l.length)}if(p.rootPrivate){const l=mt(r,T),k=F(n,c.rootPrivate?.autofix);k&&l.length>0&&(ht(l,{useEditorconfig:f}),$.rootPrivate=!0),h.rootPrivate=l,k||(N+=l.length)}if(p.rootPackageManager){const l=gt(r,T,{suggested:c.rootPackageManager?.suggested}),k=F(n,c.rootPackageManager?.autofix);k&&l.some(J=>J.suggested!==void 0)&&(dt(l,{useEditorconfig:f}),$.rootPackageManager=!0),h.rootPackageManager=l,(!k||!$.rootPackageManager)&&(N+=l.filter(J=>J.suggested===void 0||!$.rootPackageManager).length)}if(p.rootDeps){const l=pt(r,T),k=F(n,c.rootDeps?.autofix);k&&l.length>0&&(ct(l,{useEditorconfig:f}),$.rootDeps=!0),h.rootDeps=l,k||(N+=l.length)}if(p.missingPackageJson){const l=ot(r);h.missingPackageJson=l,N+=l.length}if(p.deadWorkspacePatterns){const l=Le(r),k=F(n,c.deadWorkspacePatterns?.autofix);k&&l.length>0&&(qe(l,{useEditorconfig:f}),$.deadWorkspacePatterns=!0),h.deadWorkspacePatterns=l,k||(N+=l.length)}if(p.typesInDeps){const l=xt(g,{ignoreDeps:c.typesInDeps?.ignore}),k=F(n,c.typesInDeps?.autofix);k&&l.length>0&&(Nt(l,{useEditorconfig:f}),$.typesInDeps=!0),h.typesInDeps=l,k||(N+=l.length)}if(p.similarDeps){const l=wt(g,{extraFamilies:c.similarDeps?.extraFamilies,ignoreFamilies:c.similarDeps?.ignoreFamilies});h.similarDeps=l,N+=l.length}i||(a==="json"?ro(h,r,$,p):a==="minimal"?no(h,r):ao(h,r,$,p,e)),N>0&&(process.exitCode=1)},"execute");export{yo as default};
1
+ var Fe=Object.defineProperty;var k=(e,t)=>Fe(e,"name",{value:t,configurable:!0});import{createRequire as Ae}from"node:module";import{M as g,a as S,$ as M,h as pe}from"./config.js";import{b0 as he,b1 as X,b2 as Be,b3 as Me,b4 as Z,b5 as Ne,b6 as He,b7 as De,a$ as We,b8 as me,b9 as $e,ba as ye}from"./bin.js";import{d as Le}from"../packem_shared/readTomlSync-1fKo0R52-DtxWULlF.js";import{NATIVE_BINDING_VERSION as ie,allKnownTags as qe,tagsFromPath as Ge,tagsFromPaths as Je,parseShebang as Ke}from"#native";const _e=Ae(import.meta.url),I=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,V=k(e=>{if(typeof I<"u"&&I.versions&&I.versions.node){const[t,o]=I.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return I.getBuiltinModule(e)}return _e(e)},"__cjs_getBuiltinModule"),{readdirSync:de,statSync:z,readFileSync:N,existsSync:H,writeFileSync:x,unlinkSync:Pe,rmSync:Te,chmodSync:Ce}=V("node:fs"),{cwd:B}=I,{createInterface:Ie}=V("node:readline"),{spawnSync:R}=V("node:child_process"),{basename:Ve}=V("node:path");var Ue=Object.defineProperty,q=k((e,t)=>Ue(e,"name",{value:t,configurable:!0}),"c$6");const ze=/^# ([^:\s]\S*)(?::\s+(.+))?$/,Ye=q(e=>{const t=[],o=e.split(`
2
+ `);let r;for(const s of o){if(s.startsWith("#!")||s.startsWith("# Generated by")||s.startsWith("# NOTE:")||s==="set -e"||s==="")continue;const n=ze.exec(s);if(n){r&&t.push(r),r={command:"",id:n[1]??"",...n[2]?{name:n[2]}:{}};continue}r?r.command=r.command.length>0?`${r.command}
3
+ ${s}`:s:r={command:s,id:"(custom)"}}return r&&t.push(r),t},"parseStageScript"),Qe=q((e,t)=>{const o=g(e,t),r=[],s=new Set(he);if(S(o))for(const n of de(o)){if(n.startsWith(".")||n==="_"||!s.has(n))continue;const i=g(o,n);if(!z(i).isFile())continue;const a=M(i),c=Ye(a);r.push({blocks:c,rawLineCount:a.split(`
4
+ `).length,stage:n})}return r.sort((n,i)=>n.stage.localeCompare(i.stage)),{hooksDirectory:t,stages:r}},"listHooks"),Xe=q(e=>{const t=[];if(e.stages.length===0)return t.push(`No hooks installed in ${e.hooksDirectory}/.`),t;t.push(`Hooks in ${e.hooksDirectory}/:`);for(const o of e.stages)if(t.push("",`${o.stage} (${o.rawLineCount} lines)`),o.blocks.length===0)t.push(" (empty)");else for(const r of o.blocks){const s=r.name?`${r.id} ${r.name}`:r.id;t.push(` - ${s}`);const n=r.command.split(`
5
+ `).find(i=>i.trim()!=="");if(n){const i=n.length>120?`${n.slice(0,117)}...`:n;t.push(` ${i}`)}}return t},"formatListResult"),Ze=q((e,t)=>{const o=Qe(B(),e);for(const r of Xe(o))t.info(r)},"runList");var et=Object.defineProperty,O=k((e,t)=>et(e,"name",{value:t,configurable:!0}),"o$2");const ae=3;if(ie!==ae)throw new Error(`vis native binding ABI mismatch: expected ${ae}, got ${ie}. Rebuild via \`pnpm --filter @visulima/vis run build:native\` or reinstall the platform binding package.`);const ke={".releaserc":["release-config","vis-config"],".releaserc.json":["release-config","vis-config"],"nx.json":["nx-workspace","vis-config"],"packem.config.js":["packem-config","vis-config"],"packem.config.mjs":["packem-config","vis-config"],"packem.config.ts":["packem-config","vis-config"],"pnpm-workspace.yaml":["pnpm-workspace","vis-config"],"project.json":["nx-project","vis-config"],"turbo.json":["turbo-config","vis-config"],"vis.config.js":["vis-config"],"vis.config.ts":["vis-config"]},ve=[[".releaserc.json",["release-config","vis-config"]]],we=O(e=>{const t=new Set,o=Ve(e),r=ke[o];if(r)for(const n of r)t.add(n);const s=o.toLowerCase();for(const[n,i]of ve)if(s.endsWith(n))for(const a of i)t.add(a);return t},"classifyVis"),be=new Set([...Object.values(ke).flat(),...ve.flatMap(([,e])=>e)]);let K;const xe=O(()=>(K||(K=new Set(qe())),K),"getPrekUniverse");O(e=>{const t=new Set(Ge(e)),o=we(e);return{all:new Set([...t,...o]),prek:t,vis:o}},"classify");const tt=O(e=>{const t=Je([...e]),o=new Map;for(const[r,s]of e.entries()){const n=new Set(t[r]),i=we(s),a=new Set([...n,...i]);o.set(s,{all:a,prek:n,vis:i})}return o},"classifyMany");O(e=>Ke(e),"parseShebang");const ot=O(e=>xe().has(e)||be.has(e),"isKnownTag");O(e=>xe().has(e),"isPrekTag");O(e=>be.has(e),"isVisTag");const rt=O((e,t)=>{const{all:o}=e;if(t.types&&t.types.length>0){for(const r of t.types)if(!o.has(r))return!1}if(t.typesOr&&t.typesOr.length>0){let r=!1;for(const s of t.typesOr)if(o.has(s)){r=!0;break}if(!r)return!1}if(t.excludeTypes&&t.excludeTypes.length>0){for(const r of t.excludeTypes)if(o.has(r))return!1}return!0},"matchesFilter");var nt=Object.defineProperty,_=k((e,t)=>nt(e,"name",{value:t,configurable:!0}),"s$2");const st=_(e=>{let t=0;const o=e.length,r=_(()=>{for(;t<o&&/\s/.test(e[t]);)t+=1},"skipWs"),s=_(()=>{if(e[t]!=='"')throw new Error(`expected string at ${t}`);t+=1;const c=t;for(;t<o&&e[t]!=='"';)e[t]==="\\"?t+=2:t+=1;const l=e.slice(c,t);return t+=1,JSON.parse(`"${l}"`)},"parseString"),n=_(()=>{r();const c=e[t];if(c==="{")a();else if(c==="[")i();else if(c==='"')s();else for(;t<o&&",}]".indexOf(e[t])===-1&&!/\s/.test(e[t]);)t+=1},"parseValue"),i=_(()=>{if(t+=1,r(),e[t]==="]"){t+=1;return}for(;t<o;)if(n(),r(),e[t]===",")t+=1,r();else if(e[t]==="]"){t+=1;return}},"parseArray"),a=_(()=>{t+=1,r();const c=new Set;if(e[t]==="}"){t+=1;return}for(;t<o;){r();const l=s();if(c.has(l))throw new Error(`Duplicate key: ${l}`);if(c.add(l),r(),e[t]!==":")throw new Error(`expected colon at ${t}`);if(t+=1,n(),r(),e[t]===",")t+=1,r();else if(e[t]==="}"){t+=1;return}}},"parseObject");r(),n()},"detectDuplicateJsonKeys"),it=_((e,t,o)=>{let r=0;for(const s of e){const n=N(g(o.root,s),"utf8");try{JSON.parse(n),st(n)}catch(i){const a=i instanceof Error?i.message:String(i);o.logger.info(`${s}: Failed to json decode (${a})`),r=1}}return r},"runCheckJson");var at=Object.defineProperty,Ee=k((e,t)=>at(e,"name",{value:t,configurable:!0}),"c$5");const ct=Ee(e=>{const t=R("git",["rev-parse","--git-dir"],{cwd:e,encoding:"utf8"});if(t.status!==0)return!1;const o=t.stdout.trim(),r=o.startsWith("/")?o:g(e,o);return H(g(r,"MERGE_MSG"))?H(g(r,"MERGE_HEAD"))||H(g(r,"rebase-apply"))||H(g(r,"rebase-merge")):!1},"isInMerge"),ft=["<<<<<<< ","======= ",`=======\r
6
+ `,`=======
7
+ `,">>>>>>> "],lt=Ee((e,t,o)=>{if(!t.includes("--assume-in-merge")&&!ct(o.root))return 0;let r=0;for(const s of e){const n=N(g(o.root,s),"utf8").split(`
8
+ `);for(let i=0;i<n.length;i+=1){const a=n[i]+(i<n.length-1?`
9
+ `:"");for(const c of ft)a.startsWith(c)&&(o.logger.info(`${s}:${i+1}: Merge conflict string ${JSON.stringify(c.trim())} found`),r=1)}}return r},"runCheckMergeConflict");var ut=Object.defineProperty,gt=k((e,t)=>ut(e,"name",{value:t,configurable:!0}),"c$4");const dt=gt((e,t,o)=>{let r=0;for(const s of e){const n=g(o.root,s),i=N(n);if(i.length===0)continue;let a=i.length;const c=i[a-1];if(c!==10&&c!==13){x(n,Buffer.concat([i,Buffer.from([10])])),o.logger.info(`Fixing ${s}`),r=1;continue}for(;a>0&&(i[a-1]===10||i[a-1]===13);)a-=1;if(a===0){x(n,Buffer.alloc(0)),o.logger.info(`Fixing ${s}`),r=1;continue}const l=i.subarray(a);let d;l[0]===13&&l[1]===10?d=Buffer.from([13,10]):l[0]===13?d=Buffer.from([13]):d=Buffer.from([10]),!l.equals(d)&&(x(n,Buffer.concat([i.subarray(0,a),d])),o.logger.info(`Fixing ${s}`),r=1)}return r},"runEndOfFileFixer");var pt=Object.defineProperty,ce=k((e,t)=>pt(e,"name",{value:t,configurable:!0}),"h$3");const ht={cr:Buffer.from([13]),crlf:Buffer.from([13,10]),lf:Buffer.from([10])},mt=new Set(["auto","cr","crlf","lf","no"]),$t=ce((e,t,o)=>{let r="auto";for(let n=0;n<t.length;n+=1){const i=t[n];if(i==="-f"||i==="--fix"){n+=1;const a=t[n];if(a===void 0)return o.logger.error(`mixed-line-ending: ${i} requires a value (auto|no|lf|crlf|cr)`),2;r=a}else i.startsWith("--fix=")&&(r=i.slice(6))}if(!mt.has(r))return o.logger.error(`mixed-line-ending: invalid --fix value ${r}`),2;let s=0;for(const n of e){const i=g(o.root,n),a=N(i),c=[],l=ce(f=>{const p=c.find(b=>b.kind===f);p?p.count+=1:c.push({count:1,kind:f})},"bumpCount"),d=[];let u=0;for(let f=0;f<a.length;f+=1){const p=a[f];p===13&&a[f+1]===10?(d.push({content:a.subarray(u,f),ending:"crlf"}),l("crlf"),f+=1,u=f+1):p===13?(d.push({content:a.subarray(u,f),ending:"cr"}),l("cr"),u=f+1):p===10&&(d.push({content:a.subarray(u,f),ending:"lf"}),l("lf"),u=f+1)}u<a.length&&d.push({content:a.subarray(u),ending:null});const m=c.length>1;if(r==="no"){m&&(o.logger.info(`${n}: mixed line endings`),s=1);continue}let $;if(r==="auto"){if(!m)continue;let f;for(const p of c)(!f||p.count>f.count)&&(f=p);$=f?.kind}else if($=r,!c.some(f=>f.kind!==$&&f.count>0))continue;const w=ht[$],h=[];for(const f of d)h.push(f.content),f.ending!==null&&h.push(w);x(i,Buffer.concat(h)),o.logger.info(`${n}: fixed mixed line endings`),s=1}return s},"runMixedLineEnding");var yt=Object.defineProperty,kt=k((e,t)=>yt(e,"name",{value:t,configurable:!0}),"g$3");const fe=new Set([32,9,11,12,13]),vt=/\.(md|markdown|mdown|mdx)$/i,wt=kt((e,t,o)=>{let r=0;for(const s of e){const n=vt.test(s),i=g(o.root,s),a=N(i),c=[];let l=0;for(;l<=a.length;){let u=l;for(;u<a.length&&a[u]!==10;)u+=1;const m=u<a.length&&a[u]===10;let $=u,w=!1;m&&u>l&&a[u-1]===13&&(w=!0,$=u-1);const h=a.subarray(l,$);let f=h.length;for(;f>0&&fe.has(h[f-1]);)f-=1;const p=h.some(b=>!fe.has(b));if(n&&h.length>=2&&h[h.length-1]===32&&h[h.length-2]===32&&p&&(f=Math.min(f+2,h.length)),c.push(h.subarray(0,f)),w&&c.push(Buffer.from([13])),m&&c.push(Buffer.from([10])),!m)break;l=u+1}const d=Buffer.concat(c);d.equals(a)||(x(i,d),o.logger.info(`Fixing ${s}`),r=1)}return r},"runTrailingWhitespace");var bt=Object.defineProperty,Se=k((e,t)=>bt(e,"name",{value:t,configurable:!0}),"t");const ee={"check-json":it,"check-merge-conflict":lt,"end-of-file-fixer":dt,"mixed-line-ending":$t,"trailing-whitespace":wt},xt=Object.keys(ee).sort();Se(e=>Object.hasOwn(ee,e),"isBuiltin");const Et=Se(e=>ee[e],"getBuiltin");var St=Object.defineProperty,j=k((e,t)=>St(e,"name",{value:t,configurable:!0}),"i$3");const F="config.json",W=1,Rt=new Set(["alwaysRun","args","builtin","entry","exclude","excludeTypes","fail","files","id","name","passFilenames","types","typesOr","verbose"]),Ot=new Set(["failFast","stages","version"]),jt=["args","exclude","excludeTypes","files","passFilenames","types","typesOr"],Re=j((e,t)=>g(e,t,F),"configPath"),Y=j(e=>e!==null&&typeof e=="object"&&!Array.isArray(e),"isStringRecord"),D=j(e=>{if(!Array.isArray(e))return;const t=[];for(const o of e){if(typeof o!="string")return;t.push(o)}return t},"asStringArray"),L=j(e=>typeof e=="boolean"?e:void 0,"asBoolean"),C=j(e=>typeof e=="string"&&e.length>0?e:void 0,"asNonEmptyString"),Ft=j((e,t,o)=>{if(!Y(e))throw new TypeError("hook entry must be an object");if(typeof e.id!="string"||e.id.length===0)throw new TypeError("hook entry is missing `id`");const r={id:e.id},s=L(e.alwaysRun);s!==void 0&&(r.alwaysRun=s);const n=D(e.args);n&&(r.args=n);const i=C(e.builtin);i&&(r.builtin=i);const a=C(e.entry);a&&(r.entry=a);const c=C(e.exclude);c&&(r.exclude=c);const l=D(e.excludeTypes);l&&(r.excludeTypes=l);const d=C(e.fail);d&&(r.fail=d);const u=C(e.files);u&&(r.files=u);const m=C(e.name);m&&(r.name=m);const $=L(e.passFilenames);$!==void 0&&(r.passFilenames=$);const w=D(e.types);w&&(r.types=w);const h=D(e.typesOr);h&&(r.typesOr=h);const f=L(e.verbose);if(f!==void 0&&(r.verbose=f),[r.builtin,r.entry,r.fail].filter(p=>p!==void 0).length!==1)throw new TypeError(`hook "${r.id}" must set exactly one of \`builtin\`, \`entry\`, \`fail\``);if(r.fail!==void 0){const p=jt.filter(b=>r[b]!==void 0);if(p.length>0)throw new TypeError(`hook "${r.id}" is a \`fail\` entry — remove ${p.join(", ")} (filters do not apply)`)}for(const p of Object.keys(e))Rt.has(p)||t.push({hookId:r.id,message:`unknown field "${p}" ignored`,stage:o});return r},"parseEntry"),At=j((e,t)=>{if(!Y(e))throw new TypeError("hook config must be an object");if(e.version!==W)throw new TypeError(`unsupported hook config version: expected ${W}, got ${String(e.version)}`);if(!Y(e.stages))throw new TypeError("hook config is missing `stages` map");const o={};for(const[n,i]of Object.entries(e.stages)){if(!Array.isArray(i))throw new TypeError(`hook config: stage "${n}" must be an array`);o[n]=i.map(a=>Ft(a,t,n))}const r={stages:o,version:W},s=L(e.failFast);s!==void 0&&(r.failFast=s);for(const n of Object.keys(e))Ot.has(n)||t.push({message:`unknown top-level field "${n}" ignored`});return r},"parseConfig"),Oe=j((e,t=X,o)=>{const r=Re(e,t);if(!S(r))return;const s=M(r);let n;try{n=JSON.parse(s)}catch(i){const a=i instanceof Error?i.message:String(i);throw new TypeError(`failed to parse ${r}: ${a}`)}return At(n,o??[])},"loadHookConfig"),_t=j((e,t,o)=>{const r=Re(e,t);x(r,`${JSON.stringify(o,void 0,4)}
10
+ `,"utf8")},"writeHookConfig");var Pt=Object.defineProperty,v=k((e,t)=>Pt(e,"name",{value:t,configurable:!0}),"d");const Tt=new Map([["pre-commit/pre-commit-hooks#check-json","check-json"],["pre-commit/pre-commit-hooks#check-merge-conflict","check-merge-conflict"],["pre-commit/pre-commit-hooks#end-of-file-fixer","end-of-file-fixer"],["pre-commit/pre-commit-hooks#mixed-line-ending","mixed-line-ending"],["pre-commit/pre-commit-hooks#trailing-whitespace","trailing-whitespace"]]),Ct=/[<>=!~]=/,It=/github\.com[/:]([^/\s]+\/[^/\s.]+)/i,Bt="# Generated by `vis hook migrate` from prek",Mt=v(e=>`#!/usr/bin/env sh
11
+ ${Bt}
12
+ exec vis hook run ${e} "$@"
13
+ `,"stageScriptBody"),te=v(e=>{for(const t of Be)if(S(g(e,t)))return t},"detectPrekConfig"),Nt=v(e=>Me[e]??e,"mapPrekStage"),Ht=v(e=>It.exec(e)?.[1]??e,"normalizeRepoKey"),Dt=v(e=>{if(Ct.test(e))return;if(e.startsWith("@")){const r=e.indexOf("@",1);if(r===-1)return{name:e,version:"latest"};const s=e.slice(r+1).trim();return{name:e.slice(0,r),version:s||"latest"}}const t=e.indexOf("@");if(t===-1)return{name:e,version:"latest"};const o=e.slice(t+1).trim();return{name:e.slice(0,t),version:o||"latest"}},"parseAdditionalDep"),Wt=v(e=>{const t=[];for(const o of[e.types,e.types_or,e.exclude_types])for(const r of o??[])ot(r)||t.push(r);return t},"unknownTypes"),Lt=v((e,t)=>(e.stages&&e.stages.length>0?e.stages:t??["pre-commit"]).map(o=>Nt(o)),"resolveStages"),Vt=v((e,t,o)=>{const r=e.id??"<unknown>",s=Z.has(t),n={id:r};return e.name&&(n.name=e.name),e.language==="fail"?(n.fail=e.entry??e.name??r,n):(o?n.builtin=o:e.entry&&(n.entry=e.entry),Array.isArray(e.args)&&e.args.length>0&&(n.args=[...e.args]),s||(e.files&&(n.files=e.files),e.exclude&&(n.exclude=e.exclude),e.types&&e.types.length>0&&(n.types=[...e.types]),e.types_or&&e.types_or.length>0&&(n.typesOr=[...e.types_or]),e.exclude_types&&e.exclude_types.length>0&&(n.excludeTypes=[...e.exclude_types])),(e.pass_filenames===!1||s)&&(n.passFilenames=!1),(e.always_run||s)&&(n.alwaysRun=!0),e.verbose&&(n.verbose=!0),n)},"buildHookEntry"),qt=v((e,t,o,r)=>{if(Array.isArray(e.additional_dependencies))for(const s of e.additional_dependencies){const n=Dt(s);if(!n){r.push(`"${t}": additional_dependency "${s}" uses a pip-style pin and cannot be added to package.json — install manually.`);continue}o.push({hookId:t,name:n.name,raw:s,version:n.version})}},"collectAdditionalDeps"),Gt=v(e=>{const t={},o=[],r=[],s=[],n=[];(e.files||e.exclude)&&r.push("top-level files/exclude filter dropped — apply it per hook if needed");for(const a of e.repos??[]){const c=a.repo??"<unknown>",l=c==="local",d=l?void 0:Ht(c);for(const u of a.hooks??[]){const m=u.id??"<unknown>";let $;if(l){const f=u.language??"system";if(!Ne.has(f)){o.push({hookId:m,reason:`language "${f}" needs an isolated toolchain — run via prek or reimplement as a system command`,repo:c});continue}if(f!=="fail"&&!u.entry){o.push({hookId:m,reason:"missing `entry`",repo:c});continue}}else if(d&&($=Tt.get(`${d}#${m}`)),!$){o.push({hookId:m,reason:`remote repo "${c}"@${a.rev??"?"} has no bundled equivalent — run via prek or replace with a system command`,repo:c});continue}qt(u,m,n,s);const w=Wt(u);w.length>0&&r.push(`hook "${m}": unsupported types ${w.join(", ")} — those entries are ignored by the dispatcher`);const h=Lt(u,e.default_stages);for(const f of h){if(f==="manual")continue;if(!He.has(f)){o.push({hookId:m,reason:`unsupported stage "${f}"`,repo:c});continue}const p=Vt(u,f,$),b=t[f];b?b.push(p):t[f]=[p]}}}const i={stages:t,version:W};return e.fail_fast&&(i.failFast=!0),{additionalDeps:n,config:i,droppedFilters:r,manualSteps:s,skippedHooks:o}},"convertPrekConfig"),Jt=v(e=>{const t=De(e);if(t&&typeof t=="object")return t},"parsePrekConfig"),Kt=v(e=>{if(e.endsWith(".toml")){const o=Le(e);return o&&typeof o=="object"?o:void 0}const t=M(e);return Jt(t)},"loadPrekConfig"),Ut=v((e,t,o)=>{const r=g(e,"package.json"),s=[],n=[];if(!S(r)||t.length===0)return{added:s,skipped:n};const i=M(r),a=JSON.parse(i),c=a.devDependencies??{},l=a.dependencies??{};for(const u of t){if(u.name in c||u.name in l){n.push(u.name);continue}c[u.name]=u.version,s.push(u.name)}if(s.length===0)return{added:s,skipped:n};a.devDependencies=c;const d=We(r,i,{defaultIndent:" ",useEditorconfig:o});return x(r,`${JSON.stringify(a,void 0,d)}
14
+ `,"utf8"),{added:s,skipped:n}},"mergeAdditionalDependencies"),zt=v((e,t)=>{const o=g(e,t);pe(o),x(g(o,"README.md"),["# Vis hook config","","`config.json` is the single source of truth for what each stage","script runs. Auto-generated by `vis hook migrate`. Edit by hand","or re-run the migrator after updating your prek config.","",`Bundled builtins: ${xt.join(", ")}`,""].join(`
15
+ `),"utf8")},"writeConfigReadme"),Yt=v((e,t)=>{R("prek",["--version"],{cwd:e,encoding:"utf8"}).status===0?R("prek",["uninstall"],{cwd:e,encoding:"utf8"}).status===0?t.info("Detached prek via `prek uninstall`."):t.info("`prek uninstall` did not exit cleanly — continuing. You may need to run it manually."):t.info("prek binary not found on PATH — skipping `prek uninstall`. Run it manually if prek is installed elsewhere.")},"detachPrek"),je=v((e,t,o,r={})=>{const s=te(e),n=r.dryRun===!0;if(!s)return{isError:!0,message:"No prek configuration found (.pre-commit-config.yaml, .pre-commit-config.yml, or prek.toml)"};o.info(`Found prek config at ${s}`);const i=g(e,s),a=M(i),c=Kt(i);if(!c)return{isError:!0,message:`Could not parse ${s}`};const{additionalDeps:l,config:d,droppedFilters:u,manualSteps:m,skippedHooks:$}=Gt(c),w=Object.keys(d.stages);if(w.length===0&&$.length===0)return{isError:!0,message:`${s} has no hooks to migrate`};if(!n){const y=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(y.status===0){const J=y.stdout?.toString().trim();J&&(J.includes(".prek")||J.includes("prek-hooks"))&&R("git",["config","--local","--unset","core.hooksPath"],{cwd:e})}const T=me(t);if(T.isError)return T;T.message&&o.info(T.message)}const h=g(e,t);n||pe(h),n?o.info(` (would write) ${t}/${F}`):(_t(e,t,d),zt(e,t),o.info(` Wrote ${t}/${F}`));let f=0;for(const y of w){const T=Mt(y);n?o.info(` (would write) ${t}/${y}`):(x(g(h,y),T,{mode:493}),o.info(` Wrote ${t}/${y}`)),f+=1}const{added:p,skipped:b}=n?{added:l.map(y=>y.name),skipped:[]}:Ut(e,l,r.useEditorconfig);if(p.length>0){const y=n?"would add":"Added";o.info(`${y} ${p.length} package${p.length===1?"":"s"} to devDependencies: ${p.join(", ")}`),n||o.info("Run your package manager's install (e.g. `pnpm install`) to pick up the new devDependencies.")}b.length>0&&o.info(`Skipped ${b.length} already-declared package${b.length===1?"":"s"}: ${b.join(", ")}`),n||Yt(e,o);const se=`${i}.bak`;if(n?o.info(` (would remove) ${s} and back it up to ${s}.bak`):(S(se)||x(se,a,"utf8"),Pe(i),o.info(`Removed ${s} (backup at ${s}.bak)`)),$.length>0){o.warn(`Skipped ${$.length} hook${$.length===1?"":"s"} that cannot run without prek:`);for(const y of $)o.warn(` - ${y.repo}::${y.hookId} — ${y.reason}`)}if(u.length>0){o.warn("Partial filter translations:");for(const y of u)o.warn(` - ${y}`)}if(m.length>0){o.warn("Manual follow-up required:");for(const y of m)o.warn(` - ${y}`)}return{isError:!1,message:`${n?"would migrate":"Migration complete:"} ${f} stage script${f===1?"":"s"} ${n?"into":"written to"} ${t}/`}},"migrateFromPrek");var Qt=Object.defineProperty,oe=k((e,t)=>Qt(e,"name",{value:t,configurable:!0}),"i$2");const le=oe((e,t)=>{try{return new RegExp(e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new Error(`invalid ${t} regex ${JSON.stringify(e)}: ${r}`)}},"compileRegex"),Xt=oe(e=>e.types&&e.types.length>0||e.typesOr&&e.typesOr.length>0||e.excludeTypes&&e.excludeTypes.length>0||!1,"hasTagFilters"),Zt=oe((e,t)=>{let o=e;if(t.files){const n=le(t.files,"files");o=o.filter(i=>n.test(i))}if(t.exclude){const n=le(t.exclude,"exclude");o=o.filter(i=>!n.test(i))}if(!Xt(t))return[...o];const r=tt(o),s={excludeTypes:t.excludeTypes,types:t.types,typesOr:t.typesOr};return o.filter(n=>{const i=r.get(n);return i?rt(i,s):!1})},"applyHookFilter");var eo=Object.defineProperty,A=k((e,t)=>eo(e,"name",{value:t,configurable:!0}),"u$2");const to=32*1024,oo=A((e,t)=>{const o=[],r=Math.max(1024,to-t);let s=[],n=0;for(const i of e){const a=Buffer.byteLength(i,"utf8")+8;n+a>r&&s.length>0&&(o.push(s),s=[],n=0),s.push(i),n+=a}return s.length>0&&o.push(s),o},"chunkFiles"),ro=A(e=>({error:A(t=>e.error(t),"error"),info:A(t=>e.info(t),"info")}),"builtinLoggerFor"),ue=A((e,t,o)=>o?o.message:t?`terminated by signal ${t}`:`exited with status ${String(e)}`,"describeSpawnFailure"),no=A((e,t,o,r,s)=>{const n=r?s.extraArgs:[];if(!o||t.length===0){const c=R("sh",["-c",e,"sh",...n],{cwd:s.root,stdio:"inherit"});return c.status===null?(s.logger.error(`hook command failed: ${ue(c.status,c.signal,c.error)}`),1):c.status}const i=Buffer.byteLength(e,"utf8")+Buffer.byteLength("sh","utf8")+Buffer.byteLength("-c","utf8")+n.reduce((c,l)=>c+Buffer.byteLength(l,"utf8")+8,0)+64;let a=0;for(const c of oo(t,i)){const l=R("sh",["-c",`${e} "$@"`,"sh",...n,...c],{cwd:s.root,stdio:"inherit"});l.status===null?(s.logger.error(`hook command failed: ${ue(l.status,l.signal,l.error)}`),a|=1):a|=l.status}return a},"runShellCommand"),so=A((e,t,o)=>{if(e.fail!==void 0)return o.logger.info(e.fail),1;const r=Z.has(o.stage);let s;try{s=Zt(t,e)}catch(c){const l=c instanceof Error?c.message:String(c);return o.logger.error(`hook "${e.id}": ${l}`),2}if(s.length===0&&e.alwaysRun!==!0&&!r)return 0;const n=e.passFilenames!==!1;if(e.verbose){const c=e.name??e.id;o.logger.info(`+ ${c}`)}if(e.builtin){const c=Et(e.builtin);if(!c)return o.logger.error(`unknown builtin "${e.builtin}" referenced by hook "${e.id}"`),2;const l={logger:ro(o.logger),root:o.root};try{return c(s,e.args??[],l)}catch(d){const u=d instanceof Error?d.message:String(d);return o.logger.error(`builtin "${e.builtin}" crashed: ${u}`),1}}if(e.entry===void 0)return o.logger.error(`hook "${e.id}" has no \`entry\`, \`builtin\`, or \`fail\` to run`),2;const i=(e.args??[]).map(c=>`'${c.replaceAll("'",String.raw`'\''`)}'`).join(" "),a=i?`${e.entry} ${i}`:e.entry;return no(a,s,n,r,o)},"runHookEntry"),io=A((e,t,o,r)=>{const s=e.stages[t];if(!s||s.length===0)return 0;let n=0;for(const i of s){const a=so(i,o,r);if(a!==0&&(n|=a,e.failFast))return n}return n},"runStage");var ao=Object.defineProperty,re=k((e,t)=>ao(e,"name",{value:t,configurable:!0}),"i$1");const co=re(e=>{const t=[];let o=0;for(let r=0;r<e.length;r+=1)e[r]===0&&(r>o&&t.push(e.subarray(o,r).toString("utf8")),o=r+1);return o<e.length&&t.push(e.subarray(o).toString("utf8")),t},"splitNulBuffer"),U=re((e,t,o)=>{const r=R("git",[...e],{cwd:o,encoding:"buffer"});if(r.status!==0){const s=r.stderr?r.stderr.toString():"";throw new Error(`git ${t} failed${s?`: ${s.trim()}`:""}`)}return r.stdout.length===0?[]:co(r.stdout)},"gitListFiles"),fo=re((e,t)=>{switch(e.kind){case"all":return U(["ls-files","-z"],"ls-files",t);case"range":return U(["diff","--name-only","--diff-filter=ACM","-z",e.fromRef,e.toRef],"diff --from-ref/--to-ref",t);case"staged":return U(["diff","--cached","--name-only","--diff-filter=ACM","-z"],"diff --cached",t);default:{const o=e;throw new Error(`unknown discover mode: ${JSON.stringify(o)}`)}}},"discoverFiles");var lo=Object.defineProperty,ne=k((e,t)=>lo(e,"name",{value:t,configurable:!0}),"s");const uo="pre-commit",go=ne(e=>{if(e.lastCommit&&(e.fromRef||e.toRef))throw new Error("--last-commit cannot be combined with --from-ref or --to-ref");const t=e.lastCommit?"HEAD~1":e.fromRef,o=e.lastCommit?"HEAD":e.toRef;if(t&&!o||o&&!t)throw new Error("--from-ref and --to-ref must be specified together");return t&&o?{fromRef:t,kind:"range",toRef:o}:e.allFiles?{kind:"all"}:{kind:"staged"}},"resolveDiscoverMode"),po=ne((e,t,o,r)=>{const s=o.stage??uo,n=Oe(e,t);if(!n)throw new Error(`No hook config found at ${t}/config.json. Install or migrate hooks first.`);const i=n.stages[s];if(!i||i.length===0)return r.info(`No hooks configured for stage "${s}".`),0;const a=Z.has(s)?void 0:go(o),c=a?.kind==="all"?" (--all-files)":a?.kind==="range"?` (${a.fromRef}..${a.toRef})`:"";r.info(`Running ${s}${c}`);const l=a?fo(a,e):[],d={extraArgs:o.extraArgs??[],logger:r,root:e,stage:s};return io(n,s,l,d)},"runHookStage"),ho=ne((e,t,o)=>{const r=po(B(),e,t,o);if(r!==0)throw new Error(`Hook stage exited with code ${r}`)},"runRun");var mo=Object.defineProperty,$o=k((e,t)=>mo(e,"name",{value:t,configurable:!0}),"e");const yo=$o((e=X)=>{if(R("git",["config","--local","core.hooksPath"]).status!==0)return{isError:!1,message:"No custom hooks path configured"};const{status:t,stderr:o}=R("git",["config","--local","--unset","core.hooksPath"]);if(t===null)return{isError:!0,message:"git command not found"};if(t&&t!==5)return{isError:!0,message:String(o)};const r=g(e,"_");return S(r)&&Te(r,{force:!0,recursive:!0}),{isError:!1,message:""}},"uninstallHooks");var ko=Object.defineProperty,G=k((e,t)=>ko(e,"name",{value:t,configurable:!0}),"u");const vo=new Set(he),wo=G(e=>{const t=R("sh",["-n",e],{encoding:"utf8"});if(t.status===null)return`failed to run "sh -n" (${t.error?.message??"unknown error"})`;if(t.status!==0)return t.stderr.trim()||`sh -n exited with ${t.status}`},"runSyntaxCheck"),bo=G((e,t)=>{const o=[],r=g(e,t),s=R("git",["config","--local","core.hooksPath"],{cwd:e,encoding:"utf8"});if(s.status===0){const i=s.stdout.trim(),a=`${t}/_`;i&&i!==a&&o.push({kind:"warning",message:`core.hooksPath is "${i}" — expected "${a}". Re-run \`vis hook install\` to fix.`})}else o.push({kind:"warning",message:"core.hooksPath is not set — run `vis hook install`."});if(S(g(r,"_"))||o.push({kind:"error",message:`Dispatcher directory ${t}/_ is missing. Run \`vis hook install\`.`}),!S(r))return o.push({kind:"error",message:`Hooks directory ${t}/ is missing.`}),{issues:o,ok:!1};let n=!1;for(const i of de(r)){if(i.startsWith(".")||i==="_"||i===F||i==="README.md")continue;if(!vo.has(i)){o.push({kind:"warning",message:`Unknown hook "${i}" — not a standard git hook.`,path:g(t,i)});continue}const a=g(r,i);if(!z(a).isFile())continue;n=!0;const c=z(a).mode&511;(c&64)===0&&o.push({kind:"warning",message:`Script is not owner-executable (mode ${c.toString(8)}).`,path:g(t,i)});const l=wo(a);l&&o.push({kind:"error",message:`Shell syntax error: ${l}`,path:g(t,i)})}if(n){const i=g(r,F);if(!S(i))o.push({kind:"error",message:`Stage scripts are present but ${t}/${F} is missing. Re-run \`vis hook migrate\`.`});else try{Oe(e,t)}catch(a){o.push({kind:"error",message:`${F} is malformed: ${a instanceof Error?a.message:String(a)}`,path:g(t,F)})}}return{issues:o,ok:!o.some(i=>i.kind==="error")}},"validateHooks"),xo=G((e,t)=>{if(e.issues.length===0)return[`Hook directory ${t}/ looks good.`];const o=[];for(const r of e.issues){const s=r.kind==="error"?"ERROR":"WARN ",n=r.path?` (${r.path})`:"";o.push(`${s} ${r.message}${n}`)}return o.push("",e.ok?"No errors — warnings only.":`${e.issues.filter(r=>r.kind==="error").length} error(s).`),o},"formatValidationResult"),Eo=G((e,t)=>{const o=bo(B(),e),r=xo(o,e);for(const s of r)s.startsWith("ERROR")||s.startsWith("WARN")?t.warn(s):t.info(s);if(!o.ok)throw new Error("Hook validation failed")},"runValidate");var So=Object.defineProperty,E=k((e,t)=>So(e,"name",{value:t,configurable:!0}),"i");const P=E(e=>e.hooksDir??X,"resolveHooksDirectory"),ge=E(e=>new Promise(t=>{const o=Ie({input:process.stdin,output:process.stdout});o.question(`${e} (y/N) `,r=>{o.close();const s=r.trim().toLowerCase();t(s==="y"||s==="yes")})}),"confirmPrompt"),Ro=E(async(e,t,o)=>{const r=B(),s=$e(r),n=te(r);if(s&&n)throw new Error(`Found both husky (${s}/) and prek (${n}). Remove or migrate one before running \`vis hook install\`.`);if(s){if(t.info(`Existing husky installation found at ${s}/`),await ge("Would you like to migrate your husky hooks to vis?")){const a=ye(r,e,t,{useEditorconfig:o});if(a.isError)throw new Error(a.message);a.message&&t.info(a.message);return}t.info("Aborting install. Remove husky first or run 'vis hook migrate' to migrate.");return}if(n){if(t.info(`Existing prek configuration found at ${n}`),await ge("Would you like to migrate your prek hooks to vis?")){const a=je(r,e,t,{useEditorconfig:o});if(a.isError)throw new Error(a.message);a.message&&t.info(a.message);return}t.info("Aborting install. Remove the prek config first or run 'vis hook migrate' to migrate.");return}t.info(`Installing git hooks in ${e}/...`);const i=me(e);if(i.message){if(i.isError)throw new Error(i.message);t.info(i.message);return}S(g(r,e,"pre-commit"))||x(g(r,e,"pre-commit"),`#!/usr/bin/env sh
16
+ `,{mode:493}),t.info("Git hooks installed successfully.")},"executeInstall"),Oo=E((e,t,o,r)=>{const s=B(),n=$e(s),i=te(s);if(n&&i)throw new Error(`Found both husky (${n}/) and prek (${i}). Migrate one at a time — rename or remove one before retrying.`);if(!n&&!i)throw new Error("No husky (.husky/) or prek (.pre-commit-config.yaml / prek.toml) configuration found to migrate.");t&&o.info("(dry-run) no files will be written");const a=n?ye(s,e,o,{dryRun:t,useEditorconfig:r}):je(s,e,o,{dryRun:t,useEditorconfig:r});if(a.isError)throw new Error(a.message);a.message&&o.info(a.message)},"executeMigrate"),Q="# vis:secrets-hook",jo=`#!/usr/bin/env sh
17
+ ${Q}
18
+ # Scan staged files for secrets before each commit. Remove this block or the whole file to disable.
19
+ pnpm exec vis secrets --staged --quiet || exit 1
20
+ `,Fo=E((e,t,o)=>{if(e!=="secrets")throw new Error(`Unknown hook add target "${String(e)}". Currently supported: "secrets".`);const r=B(),s=g(r,t,"pre-commit");if(!S(g(r,t)))throw new Error(`Hooks directory ${t}/ does not exist. Run \`vis hook install\` first.`);if(S(s)){const n=M(s);if(n.includes(Q)){o.info(`Secrets hook already present in ${s}.`);return}if(/\bvis secrets\b/.test(n)){o.warn(`Found a \`vis secrets\` invocation in ${s} without the managed marker — leaving it untouched.`);return}const i=`${n.trimEnd()}
21
+
22
+ ${Q}
23
+ pnpm exec vis secrets --staged --quiet || exit 1
24
+ `;x(s,i),Ce(s,493),o.info(`Appended secrets scan to ${s}.`);return}x(s,jo,{mode:493}),o.info(`Created ${s} with a secrets-scan pre-commit check.`)},"executeAdd"),Ao=E((e,t)=>{t.info("Removing git hooks...");const o=yo(e);if(o.message){if(o.isError)throw new Error(o.message);t.info(o.message);return}t.info("Git hooks removed successfully.")},"executeUninstall"),_o=E(async({logger:e,options:t,visConfig:o})=>{await Ro(P(t),e,o?.editorconfig??!0)},"hookInstallImpl"),Po=E(({logger:e,options:t})=>{Ao(P(t),e)},"hookUninstallImpl"),To=E(({logger:e,options:t,visConfig:o})=>{Oo(P(t),!!t.dryRun,e,o?.editorconfig??!0)},"hookMigrateImpl"),Co=E(({logger:e,options:t})=>{Ze(P(t),e)},"hookListImpl"),Io=E(({logger:e,options:t})=>{Eo(P(t),e)},"hookValidateImpl"),Bo=E(({argument:e,logger:t,options:o})=>{ho(P(o),{allFiles:!!o.allFiles,extraArgs:e.slice(1),fromRef:o.fromRef,lastCommit:!!o.lastCommit,stage:e[0],toRef:o.toRef},t)},"hookRunImpl"),Mo=E(({argument:e,logger:t,options:o})=>{Fo(e[0],P(o),t)},"hookAddImpl"),qo=_o,Go=Po,Jo=To,Ko=Co,Uo=Io,zo=Bo,Yo=Mo;export{Yo as hookAddExecute,qo as hookInstallExecute,Ko as hookListExecute,Jo as hookMigrateExecute,zo as hookRunExecute,Go as hookUninstallExecute,Uo as hookValidateExecute};
@@ -14,7 +14,7 @@ Second attempt: ${n}`,{cause:s})}}async revert(){if(this.backupStashSha!==null){
14
14
  `)},"print"),o=ee(a=>{switch(a){case"failed":return X(Ce);case"running":return J(">");case"skipped":return ce(q);case"success":return Ve(Ie);default:return I(q)}},"iconFor");return{commandEnd({commandId:a,durationMs:c,error:d,output:u,status:l}){const p=n.get(a)??a,w=I(`(${c}ms)`);if(i(` ${o(l)} ${p} ${w}`),l==="failed"&&d&&i(I(d.message)),(l==="failed"||r)&&u&&u.trim().length>0)for(const h of u.split(/\r?\n/))i(` ${I(h)}`)},commandStart({commandId:a}){if(!r)return;const c=n.get(a)??a;i(` ${I("…")} ${c}`)},error({error:a,message:c}){t?process.stderr.write(`${X(c)}
15
15
  `):i(X(c)),a?.stack&&(r||!t)&&process.stderr.write(`${I(a.stack)}
16
16
  `)},info({message:a}){i(I(a))},patternEnd({patternId:a,status:c}){const d=s.get(a)??a;i(`${o(c)} ${d}`)},patternStart({patternId:a}){const c=s.get(a)??a;i(`${J(">")} ${c}`)},start({patterns:a}){if(a.length===0){i(I("No staged files matched any pattern."));return}const c=new Set(a.flatMap(d=>d.files)).size;i(`${J(">")} Running staged tasks on ${c} file${c===1?"":"s"} across ${a.length} pattern${a.length===1?"":"s"}`);for(const d of a){s.set(d.id,d.title);for(const u of d.commands)n.set(u.id,u.title)}},stop(){},warn({message:a}){i(ce(a))}}},"createPlainRenderer");var er=Object.defineProperty,tr=f((e,t)=>er(e,"name",{value:t,configurable:!0}),"t");const rr=tr(async e=>{const{env:t}=process;if(e.debug===!0||e.quiet===!0||t.NODE_ENV==="test"||t.TERM==="dumb"||t.CI!==void 0||!process.stderr.isTTY)return be({quiet:e.quiet,verbose:e.verbose});try{return Xt({verbose:e.verbose})}catch{return be({quiet:e.quiet,verbose:e.verbose})}},"pickRenderer");var sr=Object.defineProperty,_=f((e,t)=>sr(e,"name",{value:t,configurable:!0}),"a");const te=_(e=>typeof e=="object"&&e!==null&&typeof e.title=="string"&&typeof e.task=="function","isCustomTask"),nr=_(async e=>{let t=0,r=0;const s=_(()=>(t+=1,`pattern-${t}`),"nextPatternId"),n=_(()=>(r+=1,`cmd-${r}`),"nextCommandId"),i=_(async(a,c,d)=>{if(typeof a=="string"){d.push({command:a,files:c,id:n(),source:"string",title:a});return}if(Array.isArray(a)){for(const u of a)await i(u,c,d);return}if(typeof a=="function"){const u=await a([...c]);if(typeof u=="string"){d.push({command:u,files:c,id:n(),source:"function",title:u});return}if(Array.isArray(u)){for(const l of u)if(typeof l=="string")d.push({command:l,files:c,id:n(),source:"function",title:l});else if(te(l))d.push({files:c,id:n(),run:l.task,source:"custom",title:l.title});else throw new S("Task function returned an array with an unsupported entry — expected strings or { title, task }.");return}if(te(u)){d.push({files:c,id:n(),run:u.task,source:"custom",title:u.title});return}throw new S("Task function returned an unsupported value — expected string, string[], or { title, task }.")}if(te(a)){d.push({files:c,id:n(),run:a.task,source:"custom",title:a.title});return}throw new S("Unsupported task value — expected string, string[], function, or { title, task }.")},"expandTask"),o=[];for(const[a,c]of Object.entries(e.config)){const d=Kt(a,e.files,e.cwd,{caseInsensitive:e.caseInsensitive===!0});if(d.length===0)continue;const u=e.relative?d.map(p=>B(e.cwd,p)):d,l=[];await i(c,u,l),l.length!==0&&o.push({commands:l,files:u,id:s(),pattern:a,title:`${a} — ${d.length} file${d.length===1?"":"s"}`})}return o},"buildTaskGraph");var ar=Object.defineProperty,Y=f((e,t)=>ar(e,"name",{value:t,configurable:!0}),"g");const ir=Y(e=>{const t=[];let r="",s=!1,n=!1;for(let i=0;i<e.length;i+=1){const o=e[i];if(o===void 0)break;if(o==="\\"&&!s&&i+1<e.length){const a=e[i+1];if(a!==void 0){n&&a!=='"'&&a!=="\\"&&(r+=o),r+=a,i+=1;continue}}if(o==='"'&&!s){n=!n;continue}if(o==="'"&&!n){s=!s;continue}if(!s&&!n&&/\s/.test(o)){r.length>0&&(t.push(r),r="");continue}r+=o}if(s||n)throw new S(`Unterminated ${s?"single":"double"} quote in command: ${e}`);return r.length>0&&t.push(r),t},"parseCommandString"),Re=process.platform==="win32"?28e3:131072,or=Y((e,t,r)=>{const s=[];let n=[],i=t;const o=r<=0?Re:r;for(const a of e){const c=Buffer.byteLength(a)+1;n.length>0&&i+c>o&&(s.push(n),n=[],i=t),n.push(a),i+=c}return n.length>0&&s.push(n),s},"chunkFiles"),cr=Y(async(e,t,r)=>{const s=ir(e);if(s.length===0)throw new O(e,"Empty command for staged task.");const[n,...i]=s;if(n===void 0)throw new O(e,"Empty command for staged task.");const o=Buffer.byteLength(n)+i.reduce((u,l)=>u+Buffer.byteLength(l)+1,0),a=or(t,o,r.maxArgLength??Re),c=Date.now(),d=[];for(const u of a){if(r.signal?.aborted===!0)throw new O(e,"Task aborted by earlier failure.");const l=$e(n,[...i,...u],{nodeOptions:{cwd:r.cwd,env:dr(r.env),killSignal:r.killSignal??"SIGTERM",stdio:["ignore","pipe","pipe"]},...r.signal===void 0?{}:{signal:r.signal}}),p=await l,w=[p.stdout,p.stderr].filter(m=>m.length>0).join(`
17
- `);w.length>0&&d.push(w);const h=l.process?.signalCode??null;if(l.aborted||h!==null||p.exitCode===void 0){const m=l.aborted?"Task aborted by earlier failure.":h!==null?`Task killed by signal ${h}.`:w.trim()||"Task exited without a numeric status code.";throw new O(e,m)}if(p.exitCode!==0)throw new O(e,w.trim()||`Exit code ${p.exitCode} from ${n}`)}return{durationMs:Date.now()-c,output:d.join(`
17
+ `);w.length>0&&d.push(w);const h=l.process?.signalCode??null;if(l.aborted||h!==null||p.exitCode===void 0){const m=l.aborted?"Task aborted by earlier failure.":h===null?w.trim()||"Task exited without a numeric status code.":`Task killed by signal ${h}.`;throw new O(e,m)}if(p.exitCode!==0)throw new O(e,w.trim()||`Exit code ${p.exitCode} from ${n}`)}return{durationMs:Date.now()-c,output:d.join(`
18
18
  `)}},"execCommand"),dr=Y(e=>{const t={...process.env};return process.stderr.isTTY&&t.FORCE_COLOR===void 0&&t.NO_COLOR===void 0&&(t.FORCE_COLOR="1"),e?{...t,...e}:t},"buildTaskEnv");var lr=Object.defineProperty,j=f((e,t)=>lr(e,"name",{value:t,configurable:!0}),"o");const ur=j(async(e,t,r)=>{const s=hr(r.concurrent,e.length),n=[],i=new AbortController;let o=!1,a=0;const c=j(()=>{o||(o=!0,r.continueOnError||i.abort())},"cancel");r.externalSignal&&(r.externalSignal.aborted?c():r.externalSignal.addEventListener("abort",()=>{c()},{once:!0}));const d=j(h=>{for(const m of h.commands)t.commandEnd({commandId:m.id,durationMs:0,patternId:h.id,status:"skipped"})},"emitSkippedCommands"),u=j(async h=>{if(o){d(h),t.patternEnd({patternId:h.id,status:"skipped"});return}t.patternStart({patternId:h.id});let m="success";for(const y of h.commands){if(o){t.commandEnd({commandId:y.id,durationMs:0,patternId:h.id,status:"skipped"}),m=m==="success"?"skipped":m;continue}t.commandStart({commandId:y.id,patternId:h.id});const k=await fr(y,r,i.signal),T=k.status==="failed"&&i.signal.aborted?{...k,status:"skipped"}:k;if(t.commandEnd({commandId:y.id,durationMs:T.durationMs,error:T.error,output:T.output,patternId:h.id,status:T.status}),T.status==="failed"){n.push(y.title),m="failed",c();break}if(T.status==="skipped"){m=m==="success"?"skipped":m;break}}t.patternEnd({patternId:h.id,status:m})},"runOne"),l=j(async()=>{for(;a<e.length;){const h=e[a];a+=1,h&&await u(h)}},"pickNext"),p=[];for(let h=0;h<Math.min(s,e.length);h+=1)p.push(l());await Promise.all(p);const w=r.externalSignal?.aborted===!0;return{failedCommands:n,success:n.length===0&&!w}},"runTasks"),fr=j(async(e,t,r)=>{const s=Date.now();try{if(e.source==="custom"&&e.run)return await e.run([...e.files]),{durationMs:Date.now()-s,status:"success"};if(e.command){const n=await cr(e.command,e.files,{cwd:t.cwd,killSignal:t.killSignal,maxArgLength:t.maxArgLength,signal:r});return{durationMs:n.durationMs,output:t.verbose?n.output:void 0,status:"success"}}return{durationMs:Date.now()-s,error:new O(e.title,"Command has no invocation target."),status:"failed"}}catch(n){const i=n instanceof Error?n:new Error(String(n));return{durationMs:Date.now()-s,error:i,output:i instanceof O?i.message:void 0,status:"failed"}}},"runCommand"),hr=j((e,t)=>{if(e===!1)return 1;if(e===!0){const s=Math.max(1,typeof de=="function"?de():4);return Math.min(Math.max(1,t),s)}const r=Math.floor(e);return r>0?r:1},"concurrencyLimit");var pr=Object.defineProperty,se=f((e,t)=>pr(e,"name",{value:t,configurable:!0}),"u");const gr=!0,mr=se(e=>{try{return!nt(e)}catch{return!1}},"detectCaseInsensitive"),wr=se(async(e={})=>{const t=e.cwd??process.cwd(),r=await rr(e),s=await bt(e);typeof s!="function"&&he(s);const n=new Vt({...e,cwd:t}),i=new AbortController;let o=!1;const a=se(l=>{if(o){process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),process.kill(process.pid,l);return}o=!0,r.warn({message:`Received ${l} — cancelling staged tasks and restoring state. Press Ctrl+C again to abort.`}),i.abort()},"onInterrupt");process.on("SIGINT",a),process.on("SIGTERM",a);let c={failedCommands:[],ranTasks:!1,success:!0},d=!1,u=!1;try{await n.prepare(),d=!0;for(const k of n.warnings)r.warn({message:k});if(n.stagedFiles.length===0)return e.allowEmpty!==!0&&r.info({message:"No staged files found."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const l=mr(t),p=Yt(n.stagedFiles,e.ignore,t,{caseInsensitive:l});if(p.length===0&&n.stagedFiles.length>0)return r.info({message:"Every staged file was excluded by the `ignore` list."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const w=typeof s=="function"?he(await s([...p])):s,h=await nr({caseInsensitive:l,config:w,cwd:t,files:p,relative:e.relative});if(r.start({patterns:h}),h.length===0)return r.info({message:"No staged files matched any pattern."}),u=!0,{failedCommands:[],ranTasks:!1,success:!0};const{failedCommands:m,success:y}=await ur(h,r,{concurrent:e.concurrent??gr,continueOnError:e.continueOnError===!0,cwd:t,externalSignal:i.signal,killSignal:e.killSignal,maxArgLength:e.maxArgLength,verbose:e.verbose});if(c={failedCommands:m,ranTasks:!0,success:y},y){if(e.diff===void 0&&(await n.applyModifications({autoStage:e.autoStage===!0}),e.failOnChanges===!0&&n.indexTreeChanged()&&(r.warn({message:"Tasks modified staged content — failing because --fail-on-changes is set."}),c={failedCommands:[...m],ranTasks:!0,success:!1}),e.allowEmpty!==!0&&n.postTaskIndexMatchesHead()))throw new dt("All staged changes were reverted by tasks. Re-stage changes or rerun with --allow-empty.")}else if(e.revert===!0)r.info({message:"Reverting working tree from backup stash."}),await n.revert();else{const k=n.recoveryHint();k&&r.warn({message:k})}return await n.restoreUnstagedChanges(),u=c.success,c}catch(l){const p=l instanceof Error?l.message:String(l),w=l instanceof Error?l:new Error(p);if(r.error({error:w,message:p}),l instanceof A)return{failedCommands:c.failedCommands,ranTasks:c.ranTasks,success:!1};throw l}finally{if(process.removeListener("SIGINT",a),process.removeListener("SIGTERM",a),d)try{await n.cleanup(u)}catch(l){r.error({error:l,message:"Cleanup failed."})}await r.stop()}},"runStaged");var vr=Object.defineProperty,yr=f((e,t)=>vr(e,"name",{value:t,configurable:!0}),"n");const kr="VIS_STAGED_CONCURRENT",Se=yr(e=>{const t=e.trim();if(t==="true"||t==="")return!0;if(t==="false")return!1;const r=Number(t);return Number.isNaN(r)?!0:r},"parseConcurrent");var br=Object.defineProperty,H=f((e,t)=>br(e,"name",{value:t,configurable:!0}),"d");const Sr=H((e,t)=>{const r={};t!==void 0&&(r.config=t);const s=H(v=>e[v]===void 0?void 0:!!e[v],"readBool"),n=H(v=>{const Q=e[v];return typeof Q=="string"&&Q.length>0?Q:void 0},"readString"),i=s("allow-empty");i!==void 0&&(r.allowEmpty=i);const o=s("auto-stage");o!==void 0&&(r.autoStage=o);const a=s("continue-on-error");a!==void 0&&(r.continueOnError=a);const c=s("debug");c!==void 0&&(r.debug=c);const d=s("fail-on-changes");d!==void 0&&(r.failOnChanges=d);const u=s("hide-partially-staged");u!==void 0&&(r.hidePartiallyStaged=u);const l=s("hide-unstaged");l!==void 0&&(r.hideUnstaged=l);const p=s("quiet");p!==void 0&&(r.quiet=p);const w=s("relative");w!==void 0&&(r.relative=w);const h=s("revert");h!==void 0&&(r.revert=h);const m=s("stash");m!==void 0&&(r.stash=m);const y=s("verbose");y!==void 0&&(r.verbose=y);const k=n("cwd");k!==void 0&&(r.cwd=k);const T=n("diff");T!==void 0&&(r.diff=T);const ie=n("diff-filter");if(ie!==void 0&&(r.diffFilter=ie),s("force-kill")===!0&&(r.killSignal="SIGKILL"),e.concurrent===void 0){const v=process.env[kr];v!==void 0&&(r.concurrent=Se(v.trim()))}else{const{concurrent:v}=e;r.concurrent=Se(typeof v=="string"?v:typeof v=="number"||typeof v=="boolean"?String(v):"")}return r},"buildRunOptions"),Fr=H(async({options:e,visConfig:t})=>{const r=(t??{}).staged;if(!r)throw new Error(`No "staged" config found in vis.config.ts. Add one:
19
19
 
20
20
  // vis.config.ts