From 7767f491b4f32e99800f5e233d76bb9fcf088b52 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 10:08:25 +0000 Subject: [PATCH 1/3] fix(autofix): handle environment wrappers in script delegation --- ...x-environment-wrapper-script-delegation.md | 5 + dist/autofix.mjs | 12 +- .../adapters/javascript/script-adapter.ts | 78 ++++++++----- tests/autofix-architecture.test.ts | 108 ++++++++++++++++++ 4 files changed, 169 insertions(+), 34 deletions(-) create mode 100644 .changeset/fix-environment-wrapper-script-delegation.md diff --git a/.changeset/fix-environment-wrapper-script-delegation.md b/.changeset/fix-environment-wrapper-script-delegation.md new file mode 100644 index 0000000..cd9cdfb --- /dev/null +++ b/.changeset/fix-environment-wrapper-script-delegation.md @@ -0,0 +1,5 @@ +--- +"@area44/workflows": patch +--- + +Handle environment wrappers consistently in script delegation and command verification to prevent duplicate autofix task execution. diff --git a/dist/autofix.mjs b/dist/autofix.mjs index 8418d70..f1453b6 100644 --- a/dist/autofix.mjs +++ b/dist/autofix.mjs @@ -304,10 +304,10 @@ const Vn=[`uv`,`pip`],Hn=[`.git`,`.venv`,`venv`,`env`,`.env`,`virtualenv`,`.virt `:` `,i++;return i=t+1&&e[a]===`\\`;)n++,a--;if(n%2==0)return r+=` `,[r,i+1]}r+=` `,i++}return[r,i]}function dr(e,t,n){let r=` `,i=t+1;for(;i!Un(e))}function mr(e,t){if(!Un(e[`build-system`]))return!1;if(typeof t==`string`){let e=fr(t);return/(?:^|\n)\s*\[\s*build-system\s*\]\s*(?:\n|$)/.test(e)}let n=Object.entries(e[`build-system`]);return n.length===0||n.some(([,e])=>!Un(e))}function hr(e,t){if(pr(e,t)||mr(e,t))return!0;if(Un(e.tool)&&Un(e.tool.uv)){let t=e.tool.uv;return Yn(t.workspace)||Array.isArray(t[`dev-dependencies`])}return!1}function gr(e){return Un(e.tool)&&Un(e.tool.uv)}function _r(e,t){return pr(e,t)||mr(e,t)}function vr(e,t){return p.relative(e,t)||`.`}function yr(e,t){if(!t)throw Error(`Invalid Python project configuration: 'uv.lock' was detected without a valid 'pyproject.toml' project or workspace configuration ('[project]', '[build-system]', or '[tool.uv.workspace]'). 'uv sync' requires a valid 'pyproject.toml' file.`);return{name:`uv`,lockfile:`uv.lock`,configFile:`pyproject.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}}function br(e,t){if(e.hasRequirementsTxt&&e.requirementsDir){let t=vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`));return{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`pip`,`install`,`-r`,t]}],execPrefix:`uv run`}}return t?{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}:null}function xr(e){let t=e.pyprojectToml?.success===!0&&hr(e.pyprojectToml.data,e.pyprojectToml.rawContent),n=e.workspaceRootToml?.success===!0&&hr(e.workspaceRootToml.data,e.workspaceRootToml.rawContent),r=t||n,i=e.uvToml?.success===!0,a=e.pyprojectToml?.success===!0&&gr(e.pyprojectToml.data)||e.workspaceRootToml?.success===!0&&gr(e.workspaceRootToml.data);return e.hasUvLock?yr(e,r):a||i?br(e,r):null}function Sr(e){let t=e.pyprojectToml?.success===!0&&_r(e.pyprojectToml.data,e.pyprojectToml.rawContent);if(!(e.hasRequirementsTxt||e.hasSetupPy||e.hasSetupCfg||t))return null;let n;t?n=`pyproject.toml`:e.hasSetupPy?n=`setup.py`:e.hasSetupCfg&&(n=`setup.cfg`);let r=[],i,a=e.hasSetupPy||e.hasSetupCfg||t,o=e.requirementsDir?vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`)):`requirements.txt`,s=vr(e.cwd,e.projectDir);return e.hasRequirementsTxt&&a?(r=[{executable:`pip`,args:[`install`,`-r`,o]},{executable:`pip`,args:[`install`,`-e`,s]}],i=`requirements.txt`):e.hasRequirementsTxt?(r=[{executable:`pip`,args:[`install`,`-r`,o]}],i=`requirements.txt`):a&&(r=[{executable:`pip`,args:[`install`,`-e`,s]}]),{name:`pip`,lockfile:i,configFile:n,installCommands:r,execPrefix:``}}function Cr(e=process.cwd(),t){if(t?.hasSource??or(e))return!0;let n=t?.ctx??ir(e);if(n.projectDir===n.cwd&&tr(n.cwd)&&(n.pyprojectToml?.success===!0&&hr(n.pyprojectToml.data,n.pyprojectToml.rawContent)||n.hasUvLock||n.hasRequirementsTxt||n.hasSetupPy||n.hasSetupCfg))return!0;if(n.workspaceRootDir&&n.workspaceRootToml?.success===!0){let t=Zn(n.workspaceRootDir);if(t&&Xn(n.workspaceRootDir,p.resolve(e),t.config))return!0}return!1}function wr(e,t){t!=null&&(e.pyprojectToml=t);for(let t of Vn)if(t===`uv`){let t=xr(e);if(t)return t}else if(t===`pip`){let t=Sr(e);if(t)return t}return{name:`pip`,installCommands:[],execPrefix:``,isStandalone:!0}}function Tr(e=process.cwd(),t,n){let r=n?.ctx??ir(e);return n?.isProject??Cr(e,{ctx:r,hasSource:n?.hasSource})?wr(r,t):null}function Er(e){if(!Array.isArray(e))throw Error(`Invalid Python environment: "pmInfo.installCommands" must be an array`);for(let t of e){if(!t||typeof t!=`object`)throw Error(`Invalid Python environment: malformed "installCommands" item`);let e=t;if(typeof e.executable!=`string`||!e.executable.trim()||!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))throw Error(`Invalid Python environment: malformed "installCommands" item`)}}function Dr(e,t=`Invalid Python environment: "pmInfo" must be an object`){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(t);let n=e;if(n.name!==`uv`&&n.name!==`pip`)throw Error(`Invalid Python environment: pmInfo name must be "uv" or "pip"`);return Er(n.installCommands),n}function Or(e){if(!process.argv[1])return!1;try{return l(e)===f.realpathSync(process.argv[1])}catch{return!1}}async function kr(e,t,n=process.platform){let r=p.join(e,`node_modules`,`.bin`),i=/* @__PURE__ */ new Set([`.cmd`,`.bat`,`.exe`]);if(n===`win32`){let e=p.extname(t).toLowerCase();if(e){if(!i.has(e))return;let n=p.join(r,t);if(f.existsSync(n))return n}else for(let e of[`.cmd`,`.bat`,`.exe`,``]){let n=p.join(r,`${t}${e}`);if(f.existsSync(n))return n}}else{let e=p.join(r,t);if(f.existsSync(e))return e}let a=await Vt(t,!1);if(a){if(n===`win32`){let e=p.extname(a).toLowerCase();if(e&&!i.has(e))return}return a}}var Ar=class{platform;constructor(e=process.platform){this.platform=e}async resolveTaskExecutable(e){if(e.toolId===`npm-scripts`)return e.executable;if(e.toolId===`ruff`){if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);return`ruff`}let t=await kr(e.cwd,e.executable,this.platform);if(!t){let t=e.toolName||e.toolId,n=e.requiredPackage||e.executable;throw Error(`Configured tool "${t}" could not run: executable "${e.executable}" is not available in node_modules/.bin or PATH. Please install "${n}" in project dependencies.`)}return t}async executeTasks(e){let t=[];for(let n of e){let e=`${n.executable} ${n.args.join(` `)}`.trim();try{let r=await this.resolveTaskExecutable(n);en(`Executing: ${e}`);let i=n.env?Object.fromEntries(Object.entries({...process.env,...n.env}).filter(e=>e[1]!==void 0)):void 0,a=await Yt(r,n.args,{cwd:n.cwd,env:i,ignoreReturnCode:!0});if(a!==0){let r=n.toolId===`ruff`?`Ruff command "${e}" failed. Check Python and Ruff configuration.`:n.toolId===`npm-scripts`?`Script "${n.args[1]||e}" failed while executing "${e}".`:`Task "${n.id}" (${e}) failed with exit code ${a}.`;t.push({task:n,exitCode:a,error:Error(r)})}else t.push({task:n,exitCode:a})}catch(e){let r=e instanceof Error?e:Error(String(e));t.push({task:n,exitCode:1,error:r})}}return t}};function jr(e,t){return t.has(`autofix`)?!0:e===`autofix`?t.has(`format`)&&t.has(`lint`)&&t.has(`assist`):t.has(e)}function Mr(e,t){let n=[],r=[];for(let i of e)jr(i.capability,t)?r.push(i):n.push(i);return{kept:n,skipped:r}}function Nr(e,t){let n=e.get(t);return n||(n=/* @__PURE__ */ new Set,e.set(t,n)),n}async function Pr(e,t,n,r,i,a,o){for(let s of e){let e=s.adapter,c=Nr(t,s.scope),l=await e.plan(n,r);if(l.length===0)continue;let{kept:u,skipped:d}=Mr(l,c);if(u.length===0)a.push({id:e.id,name:e.name,reason:`all capabilities already covered by higher priority tool`});else{i.push({id:e.id,name:e.name,reason:s.reason});for(let e of u)if(c.add(e.capability),e.capabilities)for(let t of e.capabilities)c.add(t);if(o.push(...u),d.length>0){let t=Array.from(new Set(d.map(e=>e.capability))).join(`, `);a.push({id:e.id,name:e.name,reason:`partially skipped (${t} covered by higher priority tool)`})}}}}async function Fr(e,t,n,r,i,a,o){let s=[];for(let t of e.getStandaloneAdapters()){let e=await t.detect(n),r=t.scope??`standalone:${t.id}`;e.detected?s.push({adapter:t,reason:e.reason,scope:r}):e.reason&&!e.reason.startsWith(`no `)&&a.push({id:t.id,name:t.name,reason:e.reason})}await Pr(s,t,n,r,i,a,o)}function Ir(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e)n.has(r.id)||(n.add(r.id),t.push(r));return t}async function Lr(e,t,n=`fix`){let r=t.hasPythonSource??or(t.cwd),i=t.jsEnv??fn(t.cwd),a={...t,jsEnv:i,hasPythonSource:r},o=[],s=[],c=[],l=e.getProviders(),u=/* @__PURE__ */ new Map;for(let e of l){if(!await e.detect(a))continue;let t=e.getAdapters(a),r=[];for(let n of t){let t=await n.detect(a),i=n.scope??e.id;t.detected?r.push({adapter:n,reason:t.reason,scope:i}):t.reason&&!t.reason.startsWith(`no `)&&s.push({id:n.id,name:n.name,reason:t.reason})}await Pr(r,u,a,n,o,s,c)}await Fr(e,u,a,n,o,s,c);let d=Ir(c);return{tasks:d,selectedTools:o,skippedTools:s,summary:Rr(e,a,o,s,d)}}function Rr(e,t,n,r,i){let a=[];a.push(`Detected environments:`);let o=t.hasPythonSource??!1,s=t.jsEnv?.hasPackageJson??!1;if(a.push(` Python: ${o}`),a.push(` JavaScript: ${s}`),o&&(a.push(``),a.push(`Python toolchain:`),n.filter(e=>e.id===`ruff`).length>0?a.push(` Ruff: default tool`):a.push(` None`)),s){a.push(``),a.push(`JavaScript toolchain:`);let e=n.filter(e=>e.id!==`ruff`);for(let t of e)a.push(` ${t.name}: selected`);let t=r.filter(e=>e.id!==`ruff`);for(let e of t)a.push(` ${e.name}: skipped (${e.reason})`)}if(a.push(``),a.push(`Execution plan:`),i.length===0?a.push(` (no tasks to execute)`):i.forEach((e,t)=>{let n=e.description||`${e.executable} ${e.args.join(` `)}`;a.push(` ${t+1}. ${n}`)}),r.length>0){a.push(``),a.push(`Skipped:`);for(let e of r)a.push(` - ${e.name}: ${e.reason}`)}return a.join(` -`)}function zr(e){for(let t of[`format:write`,`format:fix`,`format`,`fmt`])if(e[t]&&Yi(e[t],e))return t}function Br(e){if(e[`format:check`]&&Ji(e[`format:check`],e)===`read-only`)return`format:check`;if(e[`fmt:check`]&&Ji(e[`fmt:check`],e)===`read-only`)return`fmt:check`}function Vr(e,t){return t===`fix`?zr(e):Br(e)}function Hr(e,t){if(t===`fix`)return e[`lint:fix`]?`lint:fix`:e[`lint:write`]?`lint:write`:void 0;if(e[`lint:check`]&&Ji(e[`lint:check`],e)===`read-only`)return`lint:check`;if(e.lint&&Ji(e.lint,e)===`read-only`)return`lint`}function Ur(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped)return 0;let r=e[t];return r===`;`||r===` +`)}function zr(e){for(let t of[`format:write`,`format:fix`,`format`,`fmt`])if(e[t]&&Xi(e[t],e))return t}function Br(e){if(e[`format:check`]&&Yi(e[`format:check`],e)===`read-only`)return`format:check`;if(e[`fmt:check`]&&Yi(e[`fmt:check`],e)===`read-only`)return`fmt:check`}function Vr(e,t){return t===`fix`?zr(e):Br(e)}function Hr(e,t){if(t===`fix`)return e[`lint:fix`]?`lint:fix`:e[`lint:write`]?`lint:write`:void 0;if(e[`lint:check`]&&Yi(e[`lint:check`],e)===`read-only`)return`lint:check`;if(e.lint&&Yi(e.lint,e)===`read-only`)return`lint`}function Ur(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped)return 0;let r=e[t];return r===`;`||r===` `?1:r===`&`&&e[t+1]===`&`||r===`|`&&e[t+1]===`|`?2:+(r===`|`)}function Wr(e,t){let n=t;for(;nt?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function di(e){return ui(e).invocations}function fi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let i=di(n[e]===void 0?e:n[e]);for(let e of i){if(li(e,t))return!0;let i=Bi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(fi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Vi(e);if(a!==void 0&&fi(a,t,n,r))return!0}return!1}function pi(e,t,n){return!n||n===t?!1:!fi(e[t]||``,n,e)}function mi(e,t,n){return!n||n===t?!1:!fi(e[t]||``,n,e)}function hi(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function gi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function _i(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function vi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function bi(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function xi(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Si(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function wi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ti(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Ei(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function Di(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function Oi(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function ki(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function Ai(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Ei(e)}function ji(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!ki(e)}function Mi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!Di(e)}function Ni(e){let[t]=e;return t===`eslint`&&!Ti(e)}function Pi(e){let[t]=e;return t===`oxlint`&&!Oi(e)}function Fi(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!Di(e)}function Ii(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!Di(e)}function Li(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!ki(e)}function Ri(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!Oi(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Bi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Vi(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2]}function Hi(e){if(e.length===0)return e;let[t]=e;if(t!==`cross-env`&&t!==`cross-env-shell`)return e;let n=1;for(;n{let r=Bi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Yi(e,t,n)}finally{n.delete(r)}}let i=Vi(e);return i===void 0?gi(e)||_i(e)||vi(e)||Ci(e):Yi(i,t,n)})}function Xi(e,t={},n=/* @__PURE__ */ new Set){return di(e).some(e=>{let r=Bi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Vi(e);return i===void 0?yi(e)||bi(e)||xi(e)||wi(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){return di(e).some(e=>{let r=Bi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Vi(e);if(i!==void 0)return Zi(i,t,n);if(Si(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function Qi(e,t,n,r){return t&&fi(e,t,n)?!0:r(e)}function $i(e,t,n,r,i){let a=Qi(t,r,e,t=>Yi(t,e)),o=Qi(t,i,e,t=>Xi(t,e)),s=Zi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ea(e,t){return Yi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ta(e,t){return Xi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t,n){let r=[];return e&&r.push(ea(e,n)),t&&r.push(ta(t,n)),r}function ra(e,t,n,r,i){r&&pi(t,n,r)&&e.push(ea(r,t)),i&&mi(t,n,i)&&e.push(ta(i,t))}function ia(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return na(n,r,e);let i=$i(e,e[t]||``,t,n,r);return ra(i,e,t,n,r),i}function aa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function oa(e,t){return t===`fix`?ia(e):aa(e)}var sa=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=oa(t,`fix`),r=oa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=oa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function ca(e){return e?Object.values(e).some(t=>Ui(t,e)):!1}function la(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function ua(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var da=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=ua(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&ca(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},fa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`@biomejs/biome`),r=ua(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},pa=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`prettier`),r=!!t?.prettier,i=ua(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ma=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`eslint`),r=!!t?.eslintConfig,i=ua(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ha=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`oxlint`),r=ua(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},ga=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`oxfmt`),r=ua(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},_a=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new sa;vitePlusAdapter=new da;biomeAdapter=new fa;prettierAdapter=new pa;eslintAdapter=new ma;oxlintAdapter=new ha;oxfmtAdapter=new ga;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},va=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ya=class{id=`python`;name=`Python`;ruffAdapter=new va;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},ba=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function xa(){let e=new ba;return e.registerProvider(new ya),e.registerProvider(new _a),e}const Sa=xa();async function Ca(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function wa(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Sa,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await Ca(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}}async function Ta(e,t,n=process.cwd()){let r=`${e} ${t.join(` `)}`.trim();if(en(`Executing: ${r}`),await Yt(e,t,{cwd:n,ignoreReturnCode:!0})!==0)throw Error(`Python command "${r}" failed. Check Python environment and dependency configuration.`)}async function Ea(e,t=process.cwd()){Dr(e,`Invalid Python environment: "pmInfo" must be an object`);let n=e.name===`pip`?`pip`:e.name;if(!await Vt(n,!1)&&!e.isStandalone){let e=`Required Python package manager '${n}' is not available in PATH.`;throw Error(e)}if(!e.isStandalone&&e.installCommands.length>0){let n=e.installCommands;en(`Installing Python dependencies: ${n.map(e=>`${e.executable} ${e.args.join(` `)}`).join(` && `)}`);for(let{executable:e,args:r}of n)await Ta(e,r,t)}}async function Da(e=process.cwd(),t,n){if(!(t??or(e)))return;let r;if(n)r=n;else{if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);r=(await Lr(Sa,{cwd:e,hasPythonSource:!0},`fix`)).tasks.filter(e=>e.toolId===`ruff`)}let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}}async function Oa(e,t){if(process.env.JS_SETUP_OUTCOME===`failure`||process.env.NODE_SETUP_OUTCOME===`failure`||process.env.BUN_SETUP_OUTCOME===`failure`||process.env.PNPM_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`JavaScript runtime or package manager setup failed.`);try{if(t){let n=fn(e);if(!n.hasPackageJson)return en(`No package.json found. Skipping scripts.`),null;if(n.packageJsonError)throw Error(n.packageJsonError);if(t.length===0)return en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`),null;await Ca(vn(cn(process.env.PACKAGE_MANAGER||_n(n).name)),e);let r=(await new Ar().executeTasks(t)).filter(e=>e.error);if(r.length>0){let e=r.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}return null}return await wa(e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ka(e,t){if(process.env.PYTHON_SETUP_OUTCOME===`failure`||process.env.UV_SETUP_OUTCOME===`failure`||process.env.PY_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Python runtime or package manager setup failed.`);let n=t&&`pmInfo`in t?t.pmInfo:Tr(e,void 0,{ctx:t?.ctx,hasSource:t?.hasSource});if(!n)return null;try{return await Ea(n,e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Aa(e,t,n){if(process.env.RUFF_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Ruff setup failed.`);try{return await Da(e,t,n),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ja(e,t,n){let r=t??or(e);if(!r)return[];let i=[],a=ir(e),o=await ka(e,{ctx:a,hasSource:!0,pmInfo:Tr(e,void 0,{ctx:a,hasSource:!0,isProject:!0})});o&&i.push(o);let s=await Aa(e,r,n);return s&&i.push(s),i}async function Ma(e=process.cwd()){let t=or(e),n;try{let r=fn(e),i={cwd:e,jsEnv:r,jsPm:cn(process.env.PACKAGE_MANAGER||_n(r).name),hasPythonSource:t};n=await Lr(Sa,i,`fix`),en(n.summary)}catch{}let r=[],i=n?n.tasks.filter(e=>e.toolId!==`ruff`):void 0,a=n?n.tasks.filter(e=>e.toolId===`ruff`):void 0,o=await Oa(e,i);o&&r.push(o);let s=await ja(e,t,a);r.push(...s),r.length>0&&(Zt(`Failed to run scripts: ${r.map(e=>e.message).join(` -`)}`),process.env.NODE_ENV!==`test`&&process.exit(1))}process.env.NODE_ENV!==`test`&&Or(import.meta.url)&&Ma();export{wa as executeJsWorkflow,Ea as executePythonWorkflow,Da as executeRuffAutofix,Ma as run,cn as sanitizePackageManager}; \ No newline at end of file +`;)n++;return n>t?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0;){let e=0;for(;e0&&(t[0]===`cross-env`||t[0]===`cross-env-shell`)){let e=ci(t);if(e===t)break;t=e}else break}return t}function ui(e){return li(e)}function di(e,t){if(e.length===0)return!1;let[n,r,i]=e;return(n===`npm`||n===`pnpm`||n===`yarn`||n===`bun`)&&r===`run`&&i===t||(n===`pnpm`||n===`bun`||n===`yarn`)&&r===t}function fi(e){if(!e)return{invocations:[],hasSyntaxError:!1};let t=Jr(e),n=t.hasSyntaxError,r=[];for(let e of t.commands){let t=ai(e);t.hasSyntaxError&&(n=!0);let i=ui(t.tokens);i.length>0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function pi(e){return fi(e).invocations}function mi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let i=pi(n[e]===void 0?e:n[e]);for(let e of i){if(di(e,t))return!0;let i=Hi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(mi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Ui(e);if(a!==void 0&&mi(a,t,n,r))return!0}return!1}function hi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function gi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function _i(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function vi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function bi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function xi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function Si(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function wi(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ti(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function Ei(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Di(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Oi(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function ki(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function Ai(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function ji(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function Mi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Oi(e)}function Ni(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Pi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!ki(e)}function Fi(e){let[t]=e;return t===`eslint`&&!Di(e)}function Ii(e){let[t]=e;return t===`oxlint`&&!Ai(e)}function Li(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!ki(e)}function Ri(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!ki(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Bi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!Ai(e)}function Vi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Hi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Ui(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2]}function Wi(e,t={},n=/* @__PURE__ */ new Set){if(!e)return!1;let{invocations:r,hasSyntaxError:i}=fi(e);if(i)return!1;for(let e of r){if(e.length===0)continue;if(e[0]===`vp`||(e[0]===`npx`||e[0]===`bunx`)&&e[1]===`vp`||(e[0]===`npm`||e[0]===`pnpm`||e[0]===`yarn`)&&(e[1]===`exec`||e[1]===`dlx`)&&e[2]===`vp`)return!0;let r=Ui(e);if(r!==void 0&&Wi(r,t,n))return!0;let i=Hi(e);if(i&&!n.has(i)&&t[i]){n.add(i);try{if(Wi(t[i],t,n))return!0}finally{n.delete(i)}}}return!1}function Gi(e){return vi(e)||yi(e)||bi(e)||xi(e)||Si(e)||Ci(e)||wi(e)||Ti(e)||Ei(e)}function Ki(e){return Mi(e)||Ni(e)||Pi(e)||Fi(e)||Ii(e)||Li(e)||Ri(e)||zi(e)||Bi(e)||Vi(e)}function qi(e,t,n){if(e.length===0)return`unknown`;if(_i(e))return`write-capable`;let r=Ui(e);if(r!==void 0)return Ji(r,t,n);let i=Hi(e);if(i){if(n.has(i))return`unknown`;let e=t[i];if(!e)return`unknown`;n.add(i);try{return Ji(e,t,n)}finally{n.delete(i)}}return Gi(e)?`write-capable`:Ki(e)?`read-only`:`unknown`}function Ji(e,t,n){let r=Jr(e);if(r.hasSyntaxError)return`unknown`;let{commands:i}=r;if(i.length===0)return`unknown`;let a=!1;for(let e of i){let r=ai(e),i=qi(ui(r.tokens),t,n);if(i===`write-capable`)return`write-capable`;if(r.hasUnsupportedSyntax||i===`unknown`)return`unknown`;i===`read-only`&&(a=!0)}return a?`read-only`:`unknown`}function Yi(e,t={}){return Ji(e,t,/* @__PURE__ */ new Set)}function Xi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?vi(e)||yi(e)||bi(e)||Ti(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?xi(e)||Si(e)||Ci(e)||Ei(e):Zi(i,t,n)})}function Qi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Qi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);if(i!==void 0)return Qi(i,t,n);if(wi(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function $i(e,t,n,r){return t&&mi(e,t,n)?!0:r(e)}function ea(e,t,n,r,i){let a=$i(t,r,e,t=>Xi(t,e)),o=$i(t,i,e,t=>Zi(t,e)),s=Qi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ta(e,t){return Xi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t){return Zi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ra(e,t,n){let r=[];return e&&r.push(ta(e,n)),t&&r.push(na(t,n)),r}function ia(e,t,n,r,i){r&&hi(t,n,r)&&e.push(ta(r,t)),i&&gi(t,n,i)&&e.push(na(i,t))}function aa(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return ra(n,r,e);let i=ea(e,e[t]||``,t,n,r);return ia(i,e,t,n,r),i}function oa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function sa(e,t){return t===`fix`?aa(e):oa(e)}var ca=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=sa(t,`fix`),r=sa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=sa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function la(e){return e?Object.values(e).some(t=>Wi(t,e)):!1}function ua(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function da(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var fa=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=da(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&la(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},pa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`@biomejs/biome`),r=da(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},ma=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`prettier`),r=!!t?.prettier,i=da(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ha=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`eslint`),r=!!t?.eslintConfig,i=da(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ga=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxlint`),r=da(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},_a=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxfmt`),r=da(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},va=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new ca;vitePlusAdapter=new fa;biomeAdapter=new pa;prettierAdapter=new ma;eslintAdapter=new ha;oxlintAdapter=new ga;oxfmtAdapter=new _a;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},ya=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ba=class{id=`python`;name=`Python`;ruffAdapter=new ya;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},xa=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function Sa(){let e=new xa;return e.registerProvider(new ba),e.registerProvider(new va),e}const Ca=Sa();async function wa(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function Ta(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Ca,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await wa(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}}async function Ea(e,t,n=process.cwd()){let r=`${e} ${t.join(` `)}`.trim();if(en(`Executing: ${r}`),await Yt(e,t,{cwd:n,ignoreReturnCode:!0})!==0)throw Error(`Python command "${r}" failed. Check Python environment and dependency configuration.`)}async function Da(e,t=process.cwd()){Dr(e,`Invalid Python environment: "pmInfo" must be an object`);let n=e.name===`pip`?`pip`:e.name;if(!await Vt(n,!1)&&!e.isStandalone){let e=`Required Python package manager '${n}' is not available in PATH.`;throw Error(e)}if(!e.isStandalone&&e.installCommands.length>0){let n=e.installCommands;en(`Installing Python dependencies: ${n.map(e=>`${e.executable} ${e.args.join(` `)}`).join(` && `)}`);for(let{executable:e,args:r}of n)await Ea(e,r,t)}}async function Oa(e=process.cwd(),t,n){if(!(t??or(e)))return;let r;if(n)r=n;else{if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);r=(await Lr(Ca,{cwd:e,hasPythonSource:!0},`fix`)).tasks.filter(e=>e.toolId===`ruff`)}let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}}async function ka(e,t){if(process.env.JS_SETUP_OUTCOME===`failure`||process.env.NODE_SETUP_OUTCOME===`failure`||process.env.BUN_SETUP_OUTCOME===`failure`||process.env.PNPM_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`JavaScript runtime or package manager setup failed.`);try{if(t){let n=fn(e);if(!n.hasPackageJson)return en(`No package.json found. Skipping scripts.`),null;if(n.packageJsonError)throw Error(n.packageJsonError);if(t.length===0)return en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`),null;await wa(vn(cn(process.env.PACKAGE_MANAGER||_n(n).name)),e);let r=(await new Ar().executeTasks(t)).filter(e=>e.error);if(r.length>0){let e=r.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}return null}return await Ta(e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Aa(e,t){if(process.env.PYTHON_SETUP_OUTCOME===`failure`||process.env.UV_SETUP_OUTCOME===`failure`||process.env.PY_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Python runtime or package manager setup failed.`);let n=t&&`pmInfo`in t?t.pmInfo:Tr(e,void 0,{ctx:t?.ctx,hasSource:t?.hasSource});if(!n)return null;try{return await Da(n,e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ja(e,t,n){if(process.env.RUFF_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Ruff setup failed.`);try{return await Oa(e,t,n),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Ma(e,t,n){let r=t??or(e);if(!r)return[];let i=[],a=ir(e),o=await Aa(e,{ctx:a,hasSource:!0,pmInfo:Tr(e,void 0,{ctx:a,hasSource:!0,isProject:!0})});o&&i.push(o);let s=await ja(e,r,n);return s&&i.push(s),i}async function Na(e=process.cwd()){let t=or(e),n;try{let r=fn(e),i={cwd:e,jsEnv:r,jsPm:cn(process.env.PACKAGE_MANAGER||_n(r).name),hasPythonSource:t};n=await Lr(Ca,i,`fix`),en(n.summary)}catch{}let r=[],i=n?n.tasks.filter(e=>e.toolId!==`ruff`):void 0,a=n?n.tasks.filter(e=>e.toolId===`ruff`):void 0,o=await ka(e,i);o&&r.push(o);let s=await Ma(e,t,a);r.push(...s),r.length>0&&(Zt(`Failed to run scripts: ${r.map(e=>e.message).join(` +`)}`),process.env.NODE_ENV!==`test`&&process.exit(1))}process.env.NODE_ENV!==`test`&&Or(import.meta.url)&&Na();export{Ta as executeJsWorkflow,Da as executePythonWorkflow,Oa as executeRuffAutofix,Na as run,cn as sanitizePackageManager}; \ No newline at end of file diff --git a/src/autofix/adapters/javascript/script-adapter.ts b/src/autofix/adapters/javascript/script-adapter.ts index af8581a..852820e 100644 --- a/src/autofix/adapters/javascript/script-adapter.ts +++ b/src/autofix/adapters/javascript/script-adapter.ts @@ -390,12 +390,56 @@ function isEnvAssignment(token: string): boolean { return ENV_ASSIGNMENT_REGEX.test(token); } -function getCommandInvocationTokens(tokens: string[]): string[] { - let startIndex = 0; - while (startIndex < tokens.length && isEnvAssignment(tokens[startIndex])) { - startIndex++; +/** + * Unwraps environment wrapper commands like `cross-env` or `cross-env-shell`, + * stripping initial environment variable assignments to retrieve the target command tokens. + * In accordance with cross-env CLI syntax, cross-env accepts environment variable + * setters (`KEY=val`) followed by the command and its arguments. + */ +export function unwrapEnvironmentWrapper(tokens: string[]): string[] { + if (tokens.length === 0) return tokens; + const [exe] = tokens; + if (exe !== "cross-env" && exe !== "cross-env-shell") { + return tokens; } - return tokens.slice(startIndex); + + let i = 1; + while (i < tokens.length && isEnvAssignment(tokens[i])) { + i++; + } + + return tokens.slice(i); +} + +/** + * Normalizes command invocation tokens by stripping leading inline environment + * variable assignments (e.g. `FOO=bar`) and unwrapping environment wrappers + * (`cross-env`, `cross-env-shell`) along with any subsequent environment variable assignments. + */ +export function normalizeCommandTokens(tokens: string[]): string[] { + let current = tokens; + while (current.length > 0) { + let startIndex = 0; + while (startIndex < current.length && isEnvAssignment(current[startIndex])) { + startIndex++; + } + current = current.slice(startIndex); + + if (current.length > 0 && (current[0] === "cross-env" || current[0] === "cross-env-shell")) { + const unwrapped = unwrapEnvironmentWrapper(current); + if (unwrapped === current) { + break; + } + current = unwrapped; + } else { + break; + } + } + return current; +} + +function getCommandInvocationTokens(tokens: string[]): string[] { + return normalizeCommandTokens(tokens); } function matchesPmDelegation(cmdTokens: string[], targetScriptName: string): boolean { @@ -767,27 +811,6 @@ export function extractShellWrapperScript(tokens: string[]): string | undefined return undefined; } -/** - * Unwraps environment wrapper commands like `cross-env` or `cross-env-shell`, - * stripping initial environment variable assignments to retrieve the target command tokens. - * In accordance with cross-env CLI syntax, cross-env accepts environment variable - * setters (`KEY=val`) followed by the command and its arguments. - */ -export function unwrapEnvironmentWrapper(tokens: string[]): string[] { - if (tokens.length === 0) return tokens; - const [exe] = tokens; - if (exe !== "cross-env" && exe !== "cross-env-shell") { - return tokens; - } - - let i = 1; - while (i < tokens.length && isEnvAssignment(tokens[i])) { - i++; - } - - return tokens.slice(i); -} - /** * Checks whether an invocation (or nested wrapped invocations) executes the `vp` command. * Supports direct invocations, environment wrappers (cross-env), shell wrappers (sh -c, bash -c), @@ -804,8 +827,7 @@ export function hasVitePlusCommand( return false; } - for (const rawTokens of invocations) { - const tokens = unwrapEnvironmentWrapper(rawTokens); + for (const tokens of invocations) { if (tokens.length === 0) continue; if (tokens[0] === "vp") { diff --git a/tests/autofix-architecture.test.ts b/tests/autofix-architecture.test.ts index a6ed04c..9540775 100644 --- a/tests/autofix-architecture.test.ts +++ b/tests/autofix-architecture.test.ts @@ -2669,6 +2669,114 @@ describe("Refactored Autofix Architecture & Tool Adapters", () => { { capability: "lint", scriptName: "lint:fix" }, ]); }); + + it("handles delegation through cross-env environment wrappers", () => { + const scripts = { + fix: "cross-env CI=1 npm run format:write && npm run lint:fix", + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([ + { capability: "format", capabilities: ["format", "lint"], scriptName: "fix" }, + ]); + }); + + it("handles delegation through cross-env-shell environment wrappers", () => { + const scripts = { + fix: "cross-env-shell NODE_ENV=production npm run lint:fix", + "lint:fix": "eslint --fix .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([{ capability: "lint", scriptName: "fix" }]); + }); + + it("handles multiple environment assignments with cross-env and cross-env-shell", () => { + const scripts = { + fix: "cross-env CI=1 NODE_ENV=production DEBUG=false npm run format:write", + "format:write": "prettier --write .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([{ capability: "format", scriptName: "fix" }]); + }); + + it("handles cross-env delegation with no environment assignments", () => { + const scripts = { + fix: "cross-env npm run format:write", + "format:write": "prettier --write .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([{ capability: "format", scriptName: "fix" }]); + }); + + it("handles nested delegation with environment wrappers", () => { + const scripts = { + fix: "cross-env CI=1 npm run all-fix", + "all-fix": "cross-env-shell NODE_ENV=production npm run format:write && npm run lint:fix", + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([ + { capability: "format", capabilities: ["format", "lint"], scriptName: "fix" }, + ]); + }); + + it("handles cyclic delegation safely when wrapped in cross-env", () => { + const scripts = { + fix: "cross-env CI=1 npm run cycle-a", + "cycle-a": "cross-env NODE_ENV=development npm run cycle-b", + "cycle-b": "cross-env npm run cycle-a", + "format:write": "prettier --write .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([ + { capability: "typecheck", capabilities: [], scriptName: "fix" }, + { capability: "format", scriptName: "format:write" }, + ]); + }); + + it("verifies execution planning with cross-env delegation prevents duplicate task scheduling", async () => { + fs.writeFileSync( + path.join(tempDir, "package.json"), + JSON.stringify({ + scripts: { + fix: "cross-env CI=1 npm run format:write && npm run lint:fix", + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }, + }), + ); + + const registry = createDefaultRegistry(); + const plan = await planExecution(registry, { cwd: tempDir }, "fix"); + + expect(plan.tasks.map((t) => t.id)).toEqual(["script-fix"]); + expect(plan.tasks[0].capability).toBe("format"); + expect(plan.tasks[0].capabilities).toEqual(["format", "lint"]); + }); + + it("verifies direct tool verification with cross-env", () => { + const scripts = { + fix: "cross-env CI=1 prettier --write . && cross-env-shell NODE_ENV=production eslint --fix .", + }; + const tasks = resolveScriptTasks(scripts, "fix"); + expect(tasks).toEqual([ + { capability: "format", capabilities: ["format", "lint"], scriptName: "fix" }, + ]); + }); + + it("verifies check mode classification with cross-env", () => { + const checkScripts = { + "format:check": "cross-env CI=1 prettier --check .", + "lint:check": "cross-env-shell NODE_ENV=production eslint .", + }; + const tasks = resolveScriptTasks(checkScripts, "check"); + expect(tasks).toEqual([ + { capability: "format", scriptName: "format:check" }, + { capability: "lint", scriptName: "lint:check" }, + ]); + }); }); describe("Regression: F-02 Read-Only Classifier Audit for File-Writing Options", () => { From e80cb77245a1c1c4e2a244861b6015054953bc8d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 01:50:40 +0000 Subject: [PATCH 2/3] fix(autofix): parse quoted shell commands in cross-env-shell --- dist/autofix.mjs | 3 +- .../adapters/javascript/script-adapter.ts | 14 +++ tests/autofix-architecture.test.ts | 101 ++++++++++++++++++ 3 files changed, 117 insertions(+), 1 deletion(-) diff --git a/dist/autofix.mjs b/dist/autofix.mjs index f1453b6..90d2623 100644 --- a/dist/autofix.mjs +++ b/dist/autofix.mjs @@ -306,7 +306,8 @@ const Vn=[`uv`,`pip`],Hn=[`.git`,`.venv`,`venv`,`env`,`.env`,`virtualenv`,`.virt `&&e[i]!==`\r`;)r+=` `,i++;return i!Un(e))}function mr(e,t){if(!Un(e[`build-system`]))return!1;if(typeof t==`string`){let e=fr(t);return/(?:^|\n)\s*\[\s*build-system\s*\]\s*(?:\n|$)/.test(e)}let n=Object.entries(e[`build-system`]);return n.length===0||n.some(([,e])=>!Un(e))}function hr(e,t){if(pr(e,t)||mr(e,t))return!0;if(Un(e.tool)&&Un(e.tool.uv)){let t=e.tool.uv;return Yn(t.workspace)||Array.isArray(t[`dev-dependencies`])}return!1}function gr(e){return Un(e.tool)&&Un(e.tool.uv)}function _r(e,t){return pr(e,t)||mr(e,t)}function vr(e,t){return p.relative(e,t)||`.`}function yr(e,t){if(!t)throw Error(`Invalid Python project configuration: 'uv.lock' was detected without a valid 'pyproject.toml' project or workspace configuration ('[project]', '[build-system]', or '[tool.uv.workspace]'). 'uv sync' requires a valid 'pyproject.toml' file.`);return{name:`uv`,lockfile:`uv.lock`,configFile:`pyproject.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}}function br(e,t){if(e.hasRequirementsTxt&&e.requirementsDir){let t=vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`));return{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`pip`,`install`,`-r`,t]}],execPrefix:`uv run`}}return t?{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}:null}function xr(e){let t=e.pyprojectToml?.success===!0&&hr(e.pyprojectToml.data,e.pyprojectToml.rawContent),n=e.workspaceRootToml?.success===!0&&hr(e.workspaceRootToml.data,e.workspaceRootToml.rawContent),r=t||n,i=e.uvToml?.success===!0,a=e.pyprojectToml?.success===!0&&gr(e.pyprojectToml.data)||e.workspaceRootToml?.success===!0&&gr(e.workspaceRootToml.data);return e.hasUvLock?yr(e,r):a||i?br(e,r):null}function Sr(e){let t=e.pyprojectToml?.success===!0&&_r(e.pyprojectToml.data,e.pyprojectToml.rawContent);if(!(e.hasRequirementsTxt||e.hasSetupPy||e.hasSetupCfg||t))return null;let n;t?n=`pyproject.toml`:e.hasSetupPy?n=`setup.py`:e.hasSetupCfg&&(n=`setup.cfg`);let r=[],i,a=e.hasSetupPy||e.hasSetupCfg||t,o=e.requirementsDir?vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`)):`requirements.txt`,s=vr(e.cwd,e.projectDir);return e.hasRequirementsTxt&&a?(r=[{executable:`pip`,args:[`install`,`-r`,o]},{executable:`pip`,args:[`install`,`-e`,s]}],i=`requirements.txt`):e.hasRequirementsTxt?(r=[{executable:`pip`,args:[`install`,`-r`,o]}],i=`requirements.txt`):a&&(r=[{executable:`pip`,args:[`install`,`-e`,s]}]),{name:`pip`,lockfile:i,configFile:n,installCommands:r,execPrefix:``}}function Cr(e=process.cwd(),t){if(t?.hasSource??or(e))return!0;let n=t?.ctx??ir(e);if(n.projectDir===n.cwd&&tr(n.cwd)&&(n.pyprojectToml?.success===!0&&hr(n.pyprojectToml.data,n.pyprojectToml.rawContent)||n.hasUvLock||n.hasRequirementsTxt||n.hasSetupPy||n.hasSetupCfg))return!0;if(n.workspaceRootDir&&n.workspaceRootToml?.success===!0){let t=Zn(n.workspaceRootDir);if(t&&Xn(n.workspaceRootDir,p.resolve(e),t.config))return!0}return!1}function wr(e,t){t!=null&&(e.pyprojectToml=t);for(let t of Vn)if(t===`uv`){let t=xr(e);if(t)return t}else if(t===`pip`){let t=Sr(e);if(t)return t}return{name:`pip`,installCommands:[],execPrefix:``,isStandalone:!0}}function Tr(e=process.cwd(),t,n){let r=n?.ctx??ir(e);return n?.isProject??Cr(e,{ctx:r,hasSource:n?.hasSource})?wr(r,t):null}function Er(e){if(!Array.isArray(e))throw Error(`Invalid Python environment: "pmInfo.installCommands" must be an array`);for(let t of e){if(!t||typeof t!=`object`)throw Error(`Invalid Python environment: malformed "installCommands" item`);let e=t;if(typeof e.executable!=`string`||!e.executable.trim()||!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))throw Error(`Invalid Python environment: malformed "installCommands" item`)}}function Dr(e,t=`Invalid Python environment: "pmInfo" must be an object`){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(t);let n=e;if(n.name!==`uv`&&n.name!==`pip`)throw Error(`Invalid Python environment: pmInfo name must be "uv" or "pip"`);return Er(n.installCommands),n}function Or(e){if(!process.argv[1])return!1;try{return l(e)===f.realpathSync(process.argv[1])}catch{return!1}}async function kr(e,t,n=process.platform){let r=p.join(e,`node_modules`,`.bin`),i=/* @__PURE__ */ new Set([`.cmd`,`.bat`,`.exe`]);if(n===`win32`){let e=p.extname(t).toLowerCase();if(e){if(!i.has(e))return;let n=p.join(r,t);if(f.existsSync(n))return n}else for(let e of[`.cmd`,`.bat`,`.exe`,``]){let n=p.join(r,`${t}${e}`);if(f.existsSync(n))return n}}else{let e=p.join(r,t);if(f.existsSync(e))return e}let a=await Vt(t,!1);if(a){if(n===`win32`){let e=p.extname(a).toLowerCase();if(e&&!i.has(e))return}return a}}var Ar=class{platform;constructor(e=process.platform){this.platform=e}async resolveTaskExecutable(e){if(e.toolId===`npm-scripts`)return e.executable;if(e.toolId===`ruff`){if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);return`ruff`}let t=await kr(e.cwd,e.executable,this.platform);if(!t){let t=e.toolName||e.toolId,n=e.requiredPackage||e.executable;throw Error(`Configured tool "${t}" could not run: executable "${e.executable}" is not available in node_modules/.bin or PATH. Please install "${n}" in project dependencies.`)}return t}async executeTasks(e){let t=[];for(let n of e){let e=`${n.executable} ${n.args.join(` `)}`.trim();try{let r=await this.resolveTaskExecutable(n);en(`Executing: ${e}`);let i=n.env?Object.fromEntries(Object.entries({...process.env,...n.env}).filter(e=>e[1]!==void 0)):void 0,a=await Yt(r,n.args,{cwd:n.cwd,env:i,ignoreReturnCode:!0});if(a!==0){let r=n.toolId===`ruff`?`Ruff command "${e}" failed. Check Python and Ruff configuration.`:n.toolId===`npm-scripts`?`Script "${n.args[1]||e}" failed while executing "${e}".`:`Task "${n.id}" (${e}) failed with exit code ${a}.`;t.push({task:n,exitCode:a,error:Error(r)})}else t.push({task:n,exitCode:a})}catch(e){let r=e instanceof Error?e:Error(String(e));t.push({task:n,exitCode:1,error:r})}}return t}};function jr(e,t){return t.has(`autofix`)?!0:e===`autofix`?t.has(`format`)&&t.has(`lint`)&&t.has(`assist`):t.has(e)}function Mr(e,t){let n=[],r=[];for(let i of e)jr(i.capability,t)?r.push(i):n.push(i);return{kept:n,skipped:r}}function Nr(e,t){let n=e.get(t);return n||(n=/* @__PURE__ */ new Set,e.set(t,n)),n}async function Pr(e,t,n,r,i,a,o){for(let s of e){let e=s.adapter,c=Nr(t,s.scope),l=await e.plan(n,r);if(l.length===0)continue;let{kept:u,skipped:d}=Mr(l,c);if(u.length===0)a.push({id:e.id,name:e.name,reason:`all capabilities already covered by higher priority tool`});else{i.push({id:e.id,name:e.name,reason:s.reason});for(let e of u)if(c.add(e.capability),e.capabilities)for(let t of e.capabilities)c.add(t);if(o.push(...u),d.length>0){let t=Array.from(new Set(d.map(e=>e.capability))).join(`, `);a.push({id:e.id,name:e.name,reason:`partially skipped (${t} covered by higher priority tool)`})}}}}async function Fr(e,t,n,r,i,a,o){let s=[];for(let t of e.getStandaloneAdapters()){let e=await t.detect(n),r=t.scope??`standalone:${t.id}`;e.detected?s.push({adapter:t,reason:e.reason,scope:r}):e.reason&&!e.reason.startsWith(`no `)&&a.push({id:t.id,name:t.name,reason:e.reason})}await Pr(s,t,n,r,i,a,o)}function Ir(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e)n.has(r.id)||(n.add(r.id),t.push(r));return t}async function Lr(e,t,n=`fix`){let r=t.hasPythonSource??or(t.cwd),i=t.jsEnv??fn(t.cwd),a={...t,jsEnv:i,hasPythonSource:r},o=[],s=[],c=[],l=e.getProviders(),u=/* @__PURE__ */ new Map;for(let e of l){if(!await e.detect(a))continue;let t=e.getAdapters(a),r=[];for(let n of t){let t=await n.detect(a),i=n.scope??e.id;t.detected?r.push({adapter:n,reason:t.reason,scope:i}):t.reason&&!t.reason.startsWith(`no `)&&s.push({id:n.id,name:n.name,reason:t.reason})}await Pr(r,u,a,n,o,s,c)}await Fr(e,u,a,n,o,s,c);let d=Ir(c);return{tasks:d,selectedTools:o,skippedTools:s,summary:Rr(e,a,o,s,d)}}function Rr(e,t,n,r,i){let a=[];a.push(`Detected environments:`);let o=t.hasPythonSource??!1,s=t.jsEnv?.hasPackageJson??!1;if(a.push(` Python: ${o}`),a.push(` JavaScript: ${s}`),o&&(a.push(``),a.push(`Python toolchain:`),n.filter(e=>e.id===`ruff`).length>0?a.push(` Ruff: default tool`):a.push(` None`)),s){a.push(``),a.push(`JavaScript toolchain:`);let e=n.filter(e=>e.id!==`ruff`);for(let t of e)a.push(` ${t.name}: selected`);let t=r.filter(e=>e.id!==`ruff`);for(let e of t)a.push(` ${e.name}: skipped (${e.reason})`)}if(a.push(``),a.push(`Execution plan:`),i.length===0?a.push(` (no tasks to execute)`):i.forEach((e,t)=>{let n=e.description||`${e.executable} ${e.args.join(` `)}`;a.push(` ${t+1}. ${n}`)}),r.length>0){a.push(``),a.push(`Skipped:`);for(let e of r)a.push(` - ${e.name}: ${e.reason}`)}return a.join(` `)}function zr(e){for(let t of[`format:write`,`format:fix`,`format`,`fmt`])if(e[t]&&Xi(e[t],e))return t}function Br(e){if(e[`format:check`]&&Yi(e[`format:check`],e)===`read-only`)return`format:check`;if(e[`fmt:check`]&&Yi(e[`fmt:check`],e)===`read-only`)return`fmt:check`}function Vr(e,t){return t===`fix`?zr(e):Br(e)}function Hr(e,t){if(t===`fix`)return e[`lint:fix`]?`lint:fix`:e[`lint:write`]?`lint:write`:void 0;if(e[`lint:check`]&&Yi(e[`lint:check`],e)===`read-only`)return`lint:check`;if(e.lint&&Yi(e.lint,e)===`read-only`)return`lint`}function Ur(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped)return 0;let r=e[t];return r===`;`||r===` `?1:r===`&`&&e[t+1]===`&`||r===`|`&&e[t+1]===`|`?2:+(r===`|`)}function Wr(e,t){let n=t;for(;nt?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0;){let e=0;for(;e0&&(t[0]===`cross-env`||t[0]===`cross-env-shell`)){let e=ci(t);if(e===t)break;t=e}else break}return t}function ui(e){return li(e)}function di(e,t){if(e.length===0)return!1;let[n,r,i]=e;return(n===`npm`||n===`pnpm`||n===`yarn`||n===`bun`)&&r===`run`&&i===t||(n===`pnpm`||n===`bun`||n===`yarn`)&&r===t}function fi(e){if(!e)return{invocations:[],hasSyntaxError:!1};let t=Jr(e),n=t.hasSyntaxError,r=[];for(let e of t.commands){let t=ai(e);t.hasSyntaxError&&(n=!0);let i=ui(t.tokens);i.length>0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function pi(e){return fi(e).invocations}function mi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let i=pi(n[e]===void 0?e:n[e]);for(let e of i){if(di(e,t))return!0;let i=Hi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(mi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Ui(e);if(a!==void 0&&mi(a,t,n,r))return!0}return!1}function hi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function gi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function _i(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function vi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function bi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function xi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function Si(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function wi(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ti(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function Ei(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Di(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Oi(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function ki(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function Ai(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function ji(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function Mi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Oi(e)}function Ni(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Pi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!ki(e)}function Fi(e){let[t]=e;return t===`eslint`&&!Di(e)}function Ii(e){let[t]=e;return t===`oxlint`&&!Ai(e)}function Li(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!ki(e)}function Ri(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!ki(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Bi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!Ai(e)}function Vi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Hi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Ui(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2]}function Wi(e,t={},n=/* @__PURE__ */ new Set){if(!e)return!1;let{invocations:r,hasSyntaxError:i}=fi(e);if(i)return!1;for(let e of r){if(e.length===0)continue;if(e[0]===`vp`||(e[0]===`npx`||e[0]===`bunx`)&&e[1]===`vp`||(e[0]===`npm`||e[0]===`pnpm`||e[0]===`yarn`)&&(e[1]===`exec`||e[1]===`dlx`)&&e[2]===`vp`)return!0;let r=Ui(e);if(r!==void 0&&Wi(r,t,n))return!0;let i=Hi(e);if(i&&!n.has(i)&&t[i]){n.add(i);try{if(Wi(t[i],t,n))return!0}finally{n.delete(i)}}}return!1}function Gi(e){return vi(e)||yi(e)||bi(e)||xi(e)||Si(e)||Ci(e)||wi(e)||Ti(e)||Ei(e)}function Ki(e){return Mi(e)||Ni(e)||Pi(e)||Fi(e)||Ii(e)||Li(e)||Ri(e)||zi(e)||Bi(e)||Vi(e)}function qi(e,t,n){if(e.length===0)return`unknown`;if(_i(e))return`write-capable`;let r=Ui(e);if(r!==void 0)return Ji(r,t,n);let i=Hi(e);if(i){if(n.has(i))return`unknown`;let e=t[i];if(!e)return`unknown`;n.add(i);try{return Ji(e,t,n)}finally{n.delete(i)}}return Gi(e)?`write-capable`:Ki(e)?`read-only`:`unknown`}function Ji(e,t,n){let r=Jr(e);if(r.hasSyntaxError)return`unknown`;let{commands:i}=r;if(i.length===0)return`unknown`;let a=!1;for(let e of i){let r=ai(e),i=qi(ui(r.tokens),t,n);if(i===`write-capable`)return`write-capable`;if(r.hasUnsupportedSyntax||i===`unknown`)return`unknown`;i===`read-only`&&(a=!0)}return a?`read-only`:`unknown`}function Yi(e,t={}){return Ji(e,t,/* @__PURE__ */ new Set)}function Xi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?vi(e)||yi(e)||bi(e)||Ti(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?xi(e)||Si(e)||Ci(e)||Ei(e):Zi(i,t,n)})}function Qi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Qi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);if(i!==void 0)return Qi(i,t,n);if(wi(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function $i(e,t,n,r){return t&&mi(e,t,n)?!0:r(e)}function ea(e,t,n,r,i){let a=$i(t,r,e,t=>Xi(t,e)),o=$i(t,i,e,t=>Zi(t,e)),s=Qi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ta(e,t){return Xi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t){return Zi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ra(e,t,n){let r=[];return e&&r.push(ta(e,n)),t&&r.push(na(t,n)),r}function ia(e,t,n,r,i){r&&hi(t,n,r)&&e.push(ta(r,t)),i&&gi(t,n,i)&&e.push(na(i,t))}function aa(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return ra(n,r,e);let i=ea(e,e[t]||``,t,n,r);return ia(i,e,t,n,r),i}function oa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function sa(e,t){return t===`fix`?aa(e):oa(e)}var ca=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=sa(t,`fix`),r=sa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=sa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function la(e){return e?Object.values(e).some(t=>Wi(t,e)):!1}function ua(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function da(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var fa=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=da(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&la(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},pa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`@biomejs/biome`),r=da(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},ma=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`prettier`),r=!!t?.prettier,i=da(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ha=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`eslint`),r=!!t?.eslintConfig,i=da(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ga=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxlint`),r=da(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},_a=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxfmt`),r=da(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},va=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new ca;vitePlusAdapter=new fa;biomeAdapter=new pa;prettierAdapter=new ma;eslintAdapter=new ha;oxlintAdapter=new ga;oxfmtAdapter=new _a;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},ya=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ba=class{id=`python`;name=`Python`;ruffAdapter=new ya;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},xa=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function Sa(){let e=new xa;return e.registerProvider(new ba),e.registerProvider(new va),e}const Ca=Sa();async function wa(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function Ta(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Ca,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await wa(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`;)n++;return n>t?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0;){let e=0;for(;e0&&(t[0]===`cross-env`||t[0]===`cross-env-shell`)){let e=ci(t);if(e===t)break;t=e}else break}return t}function ui(e){return li(e)}function di(e,t){if(e.length===0)return!1;let[n,r,i]=e;return(n===`npm`||n===`pnpm`||n===`yarn`||n===`bun`)&&r===`run`&&i===t||(n===`pnpm`||n===`bun`||n===`yarn`)&&r===t}function fi(e){if(!e)return{invocations:[],hasSyntaxError:!1};let t=Jr(e),n=t.hasSyntaxError,r=[];for(let e of t.commands){let t=ai(e);t.hasSyntaxError&&(n=!0);let i=ui(t.tokens);i.length>0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function pi(e){return fi(e).invocations}function mi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let i=pi(n[e]===void 0?e:n[e]);for(let e of i){if(di(e,t))return!0;let i=Hi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(mi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Ui(e);if(a!==void 0&&mi(a,t,n,r))return!0}return!1}function hi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function gi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function _i(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function vi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function bi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function xi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function Si(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function wi(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ti(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function Ei(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Di(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Oi(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function ki(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function Ai(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function ji(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function Mi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Oi(e)}function Ni(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Pi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!ki(e)}function Fi(e){let[t]=e;return t===`eslint`&&!Di(e)}function Ii(e){let[t]=e;return t===`oxlint`&&!Ai(e)}function Li(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!ki(e)}function Ri(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!ki(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Bi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!Ai(e)}function Vi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Hi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Ui(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2];if(e.length===1&&e[0].trim()!==``&&(e[0].includes(` `)||e[0].includes(` `)||e[0].includes(` +`)||e[0].includes(`;`)||e[0].includes(`&`)||e[0].includes(`|`)))return e[0]}function Wi(e,t={},n=/* @__PURE__ */ new Set){if(!e)return!1;let{invocations:r,hasSyntaxError:i}=fi(e);if(i)return!1;for(let e of r){if(e.length===0)continue;if(e[0]===`vp`||(e[0]===`npx`||e[0]===`bunx`)&&e[1]===`vp`||(e[0]===`npm`||e[0]===`pnpm`||e[0]===`yarn`)&&(e[1]===`exec`||e[1]===`dlx`)&&e[2]===`vp`)return!0;let r=Ui(e);if(r!==void 0&&Wi(r,t,n))return!0;let i=Hi(e);if(i&&!n.has(i)&&t[i]){n.add(i);try{if(Wi(t[i],t,n))return!0}finally{n.delete(i)}}}return!1}function Gi(e){return vi(e)||yi(e)||bi(e)||xi(e)||Si(e)||Ci(e)||wi(e)||Ti(e)||Ei(e)}function Ki(e){return Mi(e)||Ni(e)||Pi(e)||Fi(e)||Ii(e)||Li(e)||Ri(e)||zi(e)||Bi(e)||Vi(e)}function qi(e,t,n){if(e.length===0)return`unknown`;if(_i(e))return`write-capable`;let r=Ui(e);if(r!==void 0)return Ji(r,t,n);let i=Hi(e);if(i){if(n.has(i))return`unknown`;let e=t[i];if(!e)return`unknown`;n.add(i);try{return Ji(e,t,n)}finally{n.delete(i)}}return Gi(e)?`write-capable`:Ki(e)?`read-only`:`unknown`}function Ji(e,t,n){let r=Jr(e);if(r.hasSyntaxError)return`unknown`;let{commands:i}=r;if(i.length===0)return`unknown`;let a=!1;for(let e of i){let r=ai(e),i=qi(ui(r.tokens),t,n);if(i===`write-capable`)return`write-capable`;if(r.hasUnsupportedSyntax||i===`unknown`)return`unknown`;i===`read-only`&&(a=!0)}return a?`read-only`:`unknown`}function Yi(e,t={}){return Ji(e,t,/* @__PURE__ */ new Set)}function Xi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?vi(e)||yi(e)||bi(e)||Ti(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?xi(e)||Si(e)||Ci(e)||Ei(e):Zi(i,t,n)})}function Qi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Qi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);if(i!==void 0)return Qi(i,t,n);if(wi(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function $i(e,t,n,r){return t&&mi(e,t,n)?!0:r(e)}function ea(e,t,n,r,i){let a=$i(t,r,e,t=>Xi(t,e)),o=$i(t,i,e,t=>Zi(t,e)),s=Qi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ta(e,t){return Xi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t){return Zi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ra(e,t,n){let r=[];return e&&r.push(ta(e,n)),t&&r.push(na(t,n)),r}function ia(e,t,n,r,i){r&&hi(t,n,r)&&e.push(ta(r,t)),i&&gi(t,n,i)&&e.push(na(i,t))}function aa(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return ra(n,r,e);let i=ea(e,e[t]||``,t,n,r);return ia(i,e,t,n,r),i}function oa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function sa(e,t){return t===`fix`?aa(e):oa(e)}var ca=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=sa(t,`fix`),r=sa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=sa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function la(e){return e?Object.values(e).some(t=>Wi(t,e)):!1}function ua(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function da(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var fa=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=da(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&la(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},pa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`@biomejs/biome`),r=da(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},ma=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`prettier`),r=!!t?.prettier,i=da(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ha=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`eslint`),r=!!t?.eslintConfig,i=da(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ga=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxlint`),r=da(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},_a=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxfmt`),r=da(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},va=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new ca;vitePlusAdapter=new fa;biomeAdapter=new pa;prettierAdapter=new ma;eslintAdapter=new ha;oxlintAdapter=new ga;oxfmtAdapter=new _a;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},ya=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ba=class{id=`python`;name=`Python`;ruffAdapter=new ya;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},xa=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function Sa(){let e=new xa;return e.registerProvider(new ba),e.registerProvider(new va),e}const Ca=Sa();async function wa(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function Ta(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Ca,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await wa(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` `))}}async function Ea(e,t,n=process.cwd()){let r=`${e} ${t.join(` `)}`.trim();if(en(`Executing: ${r}`),await Yt(e,t,{cwd:n,ignoreReturnCode:!0})!==0)throw Error(`Python command "${r}" failed. Check Python environment and dependency configuration.`)}async function Da(e,t=process.cwd()){Dr(e,`Invalid Python environment: "pmInfo" must be an object`);let n=e.name===`pip`?`pip`:e.name;if(!await Vt(n,!1)&&!e.isStandalone){let e=`Required Python package manager '${n}' is not available in PATH.`;throw Error(e)}if(!e.isStandalone&&e.installCommands.length>0){let n=e.installCommands;en(`Installing Python dependencies: ${n.map(e=>`${e.executable} ${e.args.join(` `)}`).join(` && `)}`);for(let{executable:e,args:r}of n)await Ea(e,r,t)}}async function Oa(e=process.cwd(),t,n){if(!(t??or(e)))return;let r;if(n)r=n;else{if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);r=(await Lr(Ca,{cwd:e,hasPythonSource:!0},`fix`)).tasks.filter(e=>e.toolId===`ruff`)}let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` `))}}async function ka(e,t){if(process.env.JS_SETUP_OUTCOME===`failure`||process.env.NODE_SETUP_OUTCOME===`failure`||process.env.BUN_SETUP_OUTCOME===`failure`||process.env.PNPM_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`JavaScript runtime or package manager setup failed.`);try{if(t){let n=fn(e);if(!n.hasPackageJson)return en(`No package.json found. Skipping scripts.`),null;if(n.packageJsonError)throw Error(n.packageJsonError);if(t.length===0)return en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`),null;await wa(vn(cn(process.env.PACKAGE_MANAGER||_n(n).name)),e);let r=(await new Ar().executeTasks(t)).filter(e=>e.error);if(r.length>0){let e=r.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` `))}return null}return await Ta(e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Aa(e,t){if(process.env.PYTHON_SETUP_OUTCOME===`failure`||process.env.UV_SETUP_OUTCOME===`failure`||process.env.PY_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Python runtime or package manager setup failed.`);let n=t&&`pmInfo`in t?t.pmInfo:Tr(e,void 0,{ctx:t?.ctx,hasSource:t?.hasSource});if(!n)return null;try{return await Da(n,e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ja(e,t,n){if(process.env.RUFF_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Ruff setup failed.`);try{return await Oa(e,t,n),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Ma(e,t,n){let r=t??or(e);if(!r)return[];let i=[],a=ir(e),o=await Aa(e,{ctx:a,hasSource:!0,pmInfo:Tr(e,void 0,{ctx:a,hasSource:!0,isProject:!0})});o&&i.push(o);let s=await ja(e,r,n);return s&&i.push(s),i}async function Na(e=process.cwd()){let t=or(e),n;try{let r=fn(e),i={cwd:e,jsEnv:r,jsPm:cn(process.env.PACKAGE_MANAGER||_n(r).name),hasPythonSource:t};n=await Lr(Ca,i,`fix`),en(n.summary)}catch{}let r=[],i=n?n.tasks.filter(e=>e.toolId!==`ruff`):void 0,a=n?n.tasks.filter(e=>e.toolId===`ruff`):void 0,o=await ka(e,i);o&&r.push(o);let s=await Ma(e,t,a);r.push(...s),r.length>0&&(Zt(`Failed to run scripts: ${r.map(e=>e.message).join(` diff --git a/src/autofix/adapters/javascript/script-adapter.ts b/src/autofix/adapters/javascript/script-adapter.ts index 852820e..d4c09f5 100644 --- a/src/autofix/adapters/javascript/script-adapter.ts +++ b/src/autofix/adapters/javascript/script-adapter.ts @@ -808,6 +808,20 @@ export function extractShellWrapperScript(tokens: string[]): string | undefined if (tokens.length >= 3 && (tokens[0] === "sh" || tokens[0] === "bash") && tokens[1] === "-c") { return tokens[2]; } + // When a command string is passed as a single quoted argument (e.g. from cross-env-shell), + // recognize it as a shell script to be recursively parsed. + if ( + tokens.length === 1 && + tokens[0].trim() !== "" && + (tokens[0].includes(" ") || + tokens[0].includes("\t") || + tokens[0].includes("\n") || + tokens[0].includes(";") || + tokens[0].includes("&") || + tokens[0].includes("|")) + ) { + return tokens[0]; + } return undefined; } diff --git a/tests/autofix-architecture.test.ts b/tests/autofix-architecture.test.ts index 9540775..72a17dd 100644 --- a/tests/autofix-architecture.test.ts +++ b/tests/autofix-architecture.test.ts @@ -2777,6 +2777,107 @@ describe("Refactored Autofix Architecture & Tool Adapters", () => { { capability: "lint", scriptName: "lint:check" }, ]); }); + + it("handles quoted shell commands passed to cross-env-shell", () => { + // A. Quoted shell commands + const scriptsChained = { + fix: 'cross-env-shell CI=1 "npm run format:write && npm run lint:fix"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasksChained = resolveScriptTasks(scriptsChained, "fix"); + expect(tasksChained).toEqual([ + { capability: "format", capabilities: ["format", "lint"], scriptName: "fix" }, + ]); + + const scriptsPrettier = { + "format:write": 'cross-env-shell NODE_ENV=production "prettier --write ."', + }; + const tasksPrettier = resolveScriptTasks(scriptsPrettier, "fix"); + expect(tasksPrettier).toEqual([{ capability: "format", scriptName: "format:write" }]); + + const scriptsEslint = { + "lint:fix": 'cross-env-shell CI=1 "eslint --fix ."', + }; + const tasksEslint = resolveScriptTasks(scriptsEslint, "fix"); + expect(tasksEslint).toEqual([{ capability: "lint", scriptName: "lint:fix" }]); + + // B. Multiple environment assignments + const scriptsMultiEnv = { + fix: 'cross-env-shell CI=1 NODE_ENV=production DEBUG=false "npm run format:write"', + "format:write": "prettier --write .", + }; + const tasksMultiEnv = resolveScriptTasks(scriptsMultiEnv, "fix"); + expect(tasksMultiEnv).toEqual([{ capability: "format", scriptName: "fix" }]); + + // C. Nested delegation + const scriptsNested = { + fix: 'cross-env-shell CI=1 "npm run all-fix"', + "all-fix": 'cross-env-shell NODE_ENV=production "npm run format:write && npm run lint:fix"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasksNested = resolveScriptTasks(scriptsNested, "fix"); + expect(tasksNested).toEqual([ + { capability: "format", capabilities: ["format", "lint"], scriptName: "fix" }, + ]); + + // D. Direct command compatibility + const scriptsDirectCompat = { + fix: "cross-env CI=1 npm run format:write", + "format:write": "cross-env-shell CI=1 prettier --write .", + }; + const tasksDirectCompat = resolveScriptTasks(scriptsDirectCompat, "fix"); + expect(tasksDirectCompat).toEqual([{ capability: "format", scriptName: "fix" }]); + }); + + it("verifies syntax validation and fail-closed handling in cross-env-shell", () => { + // Unterminated quote inside shell script + expect(classifyScript('cross-env-shell CI=1 "prettier --write . \'unterminated"')).toBe( + "unknown", + ); + + // Trailing escape inside shell script + expect(classifyScript('cross-env-shell CI=1 "prettier --write . \\"')).toBe("unknown"); + + // Empty quoted command + expect(classifyScript('cross-env-shell CI=1 ""')).toBe("unknown"); + + // Unsupported shell syntax inside quoted command (redirection or backgrounding) + expect(classifyScript('cross-env-shell CI=1 "prettier --check . > output.txt"')).toBe( + "unknown", + ); + expect(classifyScript('cross-env-shell CI=1 "eslint . &"')).toBe("unknown"); + + // Quoted arguments containing spaces within quoted shell commands + expect(classifyScript('cross-env-shell CI=1 "prettier --write \\"dir with spaces\\""')).toBe( + "write-capable", + ); + + expect(classifyScript('cross-env-shell CI=1 "prettier --check \\"dir with spaces\\""')).toBe( + "read-only", + ); + }); + + it("verifies execution planning with quoted cross-env-shell prevents duplicate task scheduling", async () => { + fs.writeFileSync( + path.join(tempDir, "package.json"), + JSON.stringify({ + scripts: { + fix: 'cross-env-shell CI=1 "npm run format:write && npm run lint:fix"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }, + }), + ); + + const registry = createDefaultRegistry(); + const plan = await planExecution(registry, { cwd: tempDir }, "fix"); + + expect(plan.tasks.map((t) => t.id)).toEqual(["script-fix"]); + expect(plan.tasks[0].capability).toBe("format"); + expect(plan.tasks[0].capabilities).toEqual(["format", "lint"]); + }); }); describe("Regression: F-02 Read-Only Classifier Audit for File-Writing Options", () => { From d160f263407d8d259a94828bdde7b954eae46186 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Nov 2026 09:52:54 +0000 Subject: [PATCH 3/3] fix(autofix): preserve syntax errors in recursive script analysis --- dist/autofix.mjs | 14 ++--- .../adapters/javascript/script-adapter.ts | 21 +++++-- tests/autofix-architecture.test.ts | 58 +++++++++++++++++++ 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/dist/autofix.mjs b/dist/autofix.mjs index 90d2623..2b254bb 100644 --- a/dist/autofix.mjs +++ b/dist/autofix.mjs @@ -304,11 +304,11 @@ const Vn=[`uv`,`pip`],Hn=[`.git`,`.venv`,`venv`,`env`,`.env`,`virtualenv`,`.virt `:` `,i++;return i=t+1&&e[a]===`\\`;)n++,a--;if(n%2==0)return r+=` `,[r,i+1]}r+=` `,i++}return[r,i]}function dr(e,t,n){let r=` `,i=t+1;for(;i!Un(e))}function mr(e,t){if(!Un(e[`build-system`]))return!1;if(typeof t==`string`){let e=fr(t);return/(?:^|\n)\s*\[\s*build-system\s*\]\s*(?:\n|$)/.test(e)}let n=Object.entries(e[`build-system`]);return n.length===0||n.some(([,e])=>!Un(e))}function hr(e,t){if(pr(e,t)||mr(e,t))return!0;if(Un(e.tool)&&Un(e.tool.uv)){let t=e.tool.uv;return Yn(t.workspace)||Array.isArray(t[`dev-dependencies`])}return!1}function gr(e){return Un(e.tool)&&Un(e.tool.uv)}function _r(e,t){return pr(e,t)||mr(e,t)}function vr(e,t){return p.relative(e,t)||`.`}function yr(e,t){if(!t)throw Error(`Invalid Python project configuration: 'uv.lock' was detected without a valid 'pyproject.toml' project or workspace configuration ('[project]', '[build-system]', or '[tool.uv.workspace]'). 'uv sync' requires a valid 'pyproject.toml' file.`);return{name:`uv`,lockfile:`uv.lock`,configFile:`pyproject.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}}function br(e,t){if(e.hasRequirementsTxt&&e.requirementsDir){let t=vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`));return{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`pip`,`install`,`-r`,t]}],execPrefix:`uv run`}}return t?{name:`uv`,configFile:e.pyprojectDir?`pyproject.toml`:`uv.toml`,installCommands:[{executable:`uv`,args:[`sync`]}],lockCommand:`uv lock`,syncCommand:`uv sync`,execPrefix:`uv run`}:null}function xr(e){let t=e.pyprojectToml?.success===!0&&hr(e.pyprojectToml.data,e.pyprojectToml.rawContent),n=e.workspaceRootToml?.success===!0&&hr(e.workspaceRootToml.data,e.workspaceRootToml.rawContent),r=t||n,i=e.uvToml?.success===!0,a=e.pyprojectToml?.success===!0&&gr(e.pyprojectToml.data)||e.workspaceRootToml?.success===!0&&gr(e.workspaceRootToml.data);return e.hasUvLock?yr(e,r):a||i?br(e,r):null}function Sr(e){let t=e.pyprojectToml?.success===!0&&_r(e.pyprojectToml.data,e.pyprojectToml.rawContent);if(!(e.hasRequirementsTxt||e.hasSetupPy||e.hasSetupCfg||t))return null;let n;t?n=`pyproject.toml`:e.hasSetupPy?n=`setup.py`:e.hasSetupCfg&&(n=`setup.cfg`);let r=[],i,a=e.hasSetupPy||e.hasSetupCfg||t,o=e.requirementsDir?vr(e.cwd,p.join(e.requirementsDir,`requirements.txt`)):`requirements.txt`,s=vr(e.cwd,e.projectDir);return e.hasRequirementsTxt&&a?(r=[{executable:`pip`,args:[`install`,`-r`,o]},{executable:`pip`,args:[`install`,`-e`,s]}],i=`requirements.txt`):e.hasRequirementsTxt?(r=[{executable:`pip`,args:[`install`,`-r`,o]}],i=`requirements.txt`):a&&(r=[{executable:`pip`,args:[`install`,`-e`,s]}]),{name:`pip`,lockfile:i,configFile:n,installCommands:r,execPrefix:``}}function Cr(e=process.cwd(),t){if(t?.hasSource??or(e))return!0;let n=t?.ctx??ir(e);if(n.projectDir===n.cwd&&tr(n.cwd)&&(n.pyprojectToml?.success===!0&&hr(n.pyprojectToml.data,n.pyprojectToml.rawContent)||n.hasUvLock||n.hasRequirementsTxt||n.hasSetupPy||n.hasSetupCfg))return!0;if(n.workspaceRootDir&&n.workspaceRootToml?.success===!0){let t=Zn(n.workspaceRootDir);if(t&&Xn(n.workspaceRootDir,p.resolve(e),t.config))return!0}return!1}function wr(e,t){t!=null&&(e.pyprojectToml=t);for(let t of Vn)if(t===`uv`){let t=xr(e);if(t)return t}else if(t===`pip`){let t=Sr(e);if(t)return t}return{name:`pip`,installCommands:[],execPrefix:``,isStandalone:!0}}function Tr(e=process.cwd(),t,n){let r=n?.ctx??ir(e);return n?.isProject??Cr(e,{ctx:r,hasSource:n?.hasSource})?wr(r,t):null}function Er(e){if(!Array.isArray(e))throw Error(`Invalid Python environment: "pmInfo.installCommands" must be an array`);for(let t of e){if(!t||typeof t!=`object`)throw Error(`Invalid Python environment: malformed "installCommands" item`);let e=t;if(typeof e.executable!=`string`||!e.executable.trim()||!Array.isArray(e.args)||!e.args.every(e=>typeof e==`string`))throw Error(`Invalid Python environment: malformed "installCommands" item`)}}function Dr(e,t=`Invalid Python environment: "pmInfo" must be an object`){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(t);let n=e;if(n.name!==`uv`&&n.name!==`pip`)throw Error(`Invalid Python environment: pmInfo name must be "uv" or "pip"`);return Er(n.installCommands),n}function Or(e){if(!process.argv[1])return!1;try{return l(e)===f.realpathSync(process.argv[1])}catch{return!1}}async function kr(e,t,n=process.platform){let r=p.join(e,`node_modules`,`.bin`),i=/* @__PURE__ */ new Set([`.cmd`,`.bat`,`.exe`]);if(n===`win32`){let e=p.extname(t).toLowerCase();if(e){if(!i.has(e))return;let n=p.join(r,t);if(f.existsSync(n))return n}else for(let e of[`.cmd`,`.bat`,`.exe`,``]){let n=p.join(r,`${t}${e}`);if(f.existsSync(n))return n}}else{let e=p.join(r,t);if(f.existsSync(e))return e}let a=await Vt(t,!1);if(a){if(n===`win32`){let e=p.extname(a).toLowerCase();if(e&&!i.has(e))return}return a}}var Ar=class{platform;constructor(e=process.platform){this.platform=e}async resolveTaskExecutable(e){if(e.toolId===`npm-scripts`)return e.executable;if(e.toolId===`ruff`){if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);return`ruff`}let t=await kr(e.cwd,e.executable,this.platform);if(!t){let t=e.toolName||e.toolId,n=e.requiredPackage||e.executable;throw Error(`Configured tool "${t}" could not run: executable "${e.executable}" is not available in node_modules/.bin or PATH. Please install "${n}" in project dependencies.`)}return t}async executeTasks(e){let t=[];for(let n of e){let e=`${n.executable} ${n.args.join(` `)}`.trim();try{let r=await this.resolveTaskExecutable(n);en(`Executing: ${e}`);let i=n.env?Object.fromEntries(Object.entries({...process.env,...n.env}).filter(e=>e[1]!==void 0)):void 0,a=await Yt(r,n.args,{cwd:n.cwd,env:i,ignoreReturnCode:!0});if(a!==0){let r=n.toolId===`ruff`?`Ruff command "${e}" failed. Check Python and Ruff configuration.`:n.toolId===`npm-scripts`?`Script "${n.args[1]||e}" failed while executing "${e}".`:`Task "${n.id}" (${e}) failed with exit code ${a}.`;t.push({task:n,exitCode:a,error:Error(r)})}else t.push({task:n,exitCode:a})}catch(e){let r=e instanceof Error?e:Error(String(e));t.push({task:n,exitCode:1,error:r})}}return t}};function jr(e,t){return t.has(`autofix`)?!0:e===`autofix`?t.has(`format`)&&t.has(`lint`)&&t.has(`assist`):t.has(e)}function Mr(e,t){let n=[],r=[];for(let i of e)jr(i.capability,t)?r.push(i):n.push(i);return{kept:n,skipped:r}}function Nr(e,t){let n=e.get(t);return n||(n=/* @__PURE__ */ new Set,e.set(t,n)),n}async function Pr(e,t,n,r,i,a,o){for(let s of e){let e=s.adapter,c=Nr(t,s.scope),l=await e.plan(n,r);if(l.length===0)continue;let{kept:u,skipped:d}=Mr(l,c);if(u.length===0)a.push({id:e.id,name:e.name,reason:`all capabilities already covered by higher priority tool`});else{i.push({id:e.id,name:e.name,reason:s.reason});for(let e of u)if(c.add(e.capability),e.capabilities)for(let t of e.capabilities)c.add(t);if(o.push(...u),d.length>0){let t=Array.from(new Set(d.map(e=>e.capability))).join(`, `);a.push({id:e.id,name:e.name,reason:`partially skipped (${t} covered by higher priority tool)`})}}}}async function Fr(e,t,n,r,i,a,o){let s=[];for(let t of e.getStandaloneAdapters()){let e=await t.detect(n),r=t.scope??`standalone:${t.id}`;e.detected?s.push({adapter:t,reason:e.reason,scope:r}):e.reason&&!e.reason.startsWith(`no `)&&a.push({id:t.id,name:t.name,reason:e.reason})}await Pr(s,t,n,r,i,a,o)}function Ir(e){let t=[],n=/* @__PURE__ */ new Set;for(let r of e)n.has(r.id)||(n.add(r.id),t.push(r));return t}async function Lr(e,t,n=`fix`){let r=t.hasPythonSource??or(t.cwd),i=t.jsEnv??fn(t.cwd),a={...t,jsEnv:i,hasPythonSource:r},o=[],s=[],c=[],l=e.getProviders(),u=/* @__PURE__ */ new Map;for(let e of l){if(!await e.detect(a))continue;let t=e.getAdapters(a),r=[];for(let n of t){let t=await n.detect(a),i=n.scope??e.id;t.detected?r.push({adapter:n,reason:t.reason,scope:i}):t.reason&&!t.reason.startsWith(`no `)&&s.push({id:n.id,name:n.name,reason:t.reason})}await Pr(r,u,a,n,o,s,c)}await Fr(e,u,a,n,o,s,c);let d=Ir(c);return{tasks:d,selectedTools:o,skippedTools:s,summary:Rr(e,a,o,s,d)}}function Rr(e,t,n,r,i){let a=[];a.push(`Detected environments:`);let o=t.hasPythonSource??!1,s=t.jsEnv?.hasPackageJson??!1;if(a.push(` Python: ${o}`),a.push(` JavaScript: ${s}`),o&&(a.push(``),a.push(`Python toolchain:`),n.filter(e=>e.id===`ruff`).length>0?a.push(` Ruff: default tool`):a.push(` None`)),s){a.push(``),a.push(`JavaScript toolchain:`);let e=n.filter(e=>e.id!==`ruff`);for(let t of e)a.push(` ${t.name}: selected`);let t=r.filter(e=>e.id!==`ruff`);for(let e of t)a.push(` ${e.name}: skipped (${e.reason})`)}if(a.push(``),a.push(`Execution plan:`),i.length===0?a.push(` (no tasks to execute)`):i.forEach((e,t)=>{let n=e.description||`${e.executable} ${e.args.join(` `)}`;a.push(` ${t+1}. ${n}`)}),r.length>0){a.push(``),a.push(`Skipped:`);for(let e of r)a.push(` - ${e.name}: ${e.reason}`)}return a.join(` -`)}function zr(e){for(let t of[`format:write`,`format:fix`,`format`,`fmt`])if(e[t]&&Xi(e[t],e))return t}function Br(e){if(e[`format:check`]&&Yi(e[`format:check`],e)===`read-only`)return`format:check`;if(e[`fmt:check`]&&Yi(e[`fmt:check`],e)===`read-only`)return`fmt:check`}function Vr(e,t){return t===`fix`?zr(e):Br(e)}function Hr(e,t){if(t===`fix`)return e[`lint:fix`]?`lint:fix`:e[`lint:write`]?`lint:write`:void 0;if(e[`lint:check`]&&Yi(e[`lint:check`],e)===`read-only`)return`lint:check`;if(e.lint&&Yi(e.lint,e)===`read-only`)return`lint`}function Ur(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped)return 0;let r=e[t];return r===`;`||r===` +`)}function zr(e){for(let t of[`format:write`,`format:fix`,`format`,`fmt`])if(e[t]&&Yi(e[t],e))return t}function Br(e){if(e[`format:check`]&&Ji(e[`format:check`],e)===`read-only`)return`format:check`;if(e[`fmt:check`]&&Ji(e[`fmt:check`],e)===`read-only`)return`fmt:check`}function Vr(e,t){return t===`fix`?zr(e):Br(e)}function Hr(e,t){if(t===`fix`)return e[`lint:fix`]?`lint:fix`:e[`lint:write`]?`lint:write`:void 0;if(e[`lint:check`]&&Ji(e[`lint:check`],e)===`read-only`)return`lint:check`;if(e.lint&&Ji(e.lint,e)===`read-only`)return`lint`}function Ur(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped)return 0;let r=e[t];return r===`;`||r===` `?1:r===`&`&&e[t+1]===`&`||r===`|`&&e[t+1]===`|`?2:+(r===`|`)}function Wr(e,t){let n=t;for(;nt?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0;){let e=0;for(;e0&&(t[0]===`cross-env`||t[0]===`cross-env-shell`)){let e=ci(t);if(e===t)break;t=e}else break}return t}function ui(e){return li(e)}function di(e,t){if(e.length===0)return!1;let[n,r,i]=e;return(n===`npm`||n===`pnpm`||n===`yarn`||n===`bun`)&&r===`run`&&i===t||(n===`pnpm`||n===`bun`||n===`yarn`)&&r===t}function fi(e){if(!e)return{invocations:[],hasSyntaxError:!1};let t=Jr(e),n=t.hasSyntaxError,r=[];for(let e of t.commands){let t=ai(e);t.hasSyntaxError&&(n=!0);let i=ui(t.tokens);i.length>0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function pi(e){return fi(e).invocations}function mi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let i=pi(n[e]===void 0?e:n[e]);for(let e of i){if(di(e,t))return!0;let i=Hi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(mi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Ui(e);if(a!==void 0&&mi(a,t,n,r))return!0}return!1}function hi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function gi(e,t,n){return!n||n===t?!1:!mi(e[t]||``,n,e)}function _i(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function vi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function bi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function xi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function Si(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function wi(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ti(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function Ei(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Di(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Oi(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function ki(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function Ai(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function ji(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function Mi(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Oi(e)}function Ni(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Pi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!ki(e)}function Fi(e){let[t]=e;return t===`eslint`&&!Di(e)}function Ii(e){let[t]=e;return t===`oxlint`&&!Ai(e)}function Li(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!ki(e)}function Ri(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!ki(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!ji(e)}function Bi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!Ai(e)}function Vi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Hi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Ui(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2];if(e.length===1&&e[0].trim()!==``&&(e[0].includes(` `)||e[0].includes(` `)||e[0].includes(` -`)||e[0].includes(`;`)||e[0].includes(`&`)||e[0].includes(`|`)))return e[0]}function Wi(e,t={},n=/* @__PURE__ */ new Set){if(!e)return!1;let{invocations:r,hasSyntaxError:i}=fi(e);if(i)return!1;for(let e of r){if(e.length===0)continue;if(e[0]===`vp`||(e[0]===`npx`||e[0]===`bunx`)&&e[1]===`vp`||(e[0]===`npm`||e[0]===`pnpm`||e[0]===`yarn`)&&(e[1]===`exec`||e[1]===`dlx`)&&e[2]===`vp`)return!0;let r=Ui(e);if(r!==void 0&&Wi(r,t,n))return!0;let i=Hi(e);if(i&&!n.has(i)&&t[i]){n.add(i);try{if(Wi(t[i],t,n))return!0}finally{n.delete(i)}}}return!1}function Gi(e){return vi(e)||yi(e)||bi(e)||xi(e)||Si(e)||Ci(e)||wi(e)||Ti(e)||Ei(e)}function Ki(e){return Mi(e)||Ni(e)||Pi(e)||Fi(e)||Ii(e)||Li(e)||Ri(e)||zi(e)||Bi(e)||Vi(e)}function qi(e,t,n){if(e.length===0)return`unknown`;if(_i(e))return`write-capable`;let r=Ui(e);if(r!==void 0)return Ji(r,t,n);let i=Hi(e);if(i){if(n.has(i))return`unknown`;let e=t[i];if(!e)return`unknown`;n.add(i);try{return Ji(e,t,n)}finally{n.delete(i)}}return Gi(e)?`write-capable`:Ki(e)?`read-only`:`unknown`}function Ji(e,t,n){let r=Jr(e);if(r.hasSyntaxError)return`unknown`;let{commands:i}=r;if(i.length===0)return`unknown`;let a=!1;for(let e of i){let r=ai(e),i=qi(ui(r.tokens),t,n);if(i===`write-capable`)return`write-capable`;if(r.hasUnsupportedSyntax||i===`unknown`)return`unknown`;i===`read-only`&&(a=!0)}return a?`read-only`:`unknown`}function Yi(e,t={}){return Ji(e,t,/* @__PURE__ */ new Set)}function Xi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?vi(e)||yi(e)||bi(e)||Ti(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);return i===void 0?xi(e)||Si(e)||Ci(e)||Ei(e):Zi(i,t,n)})}function Qi(e,t={},n=/* @__PURE__ */ new Set){return pi(e).some(e=>{let r=Hi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Qi(e,t,n)}finally{n.delete(r)}}let i=Ui(e);if(i!==void 0)return Qi(i,t,n);if(wi(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function $i(e,t,n,r){return t&&mi(e,t,n)?!0:r(e)}function ea(e,t,n,r,i){let a=$i(t,r,e,t=>Xi(t,e)),o=$i(t,i,e,t=>Zi(t,e)),s=Qi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ta(e,t){return Xi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t){return Zi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ra(e,t,n){let r=[];return e&&r.push(ta(e,n)),t&&r.push(na(t,n)),r}function ia(e,t,n,r,i){r&&hi(t,n,r)&&e.push(ta(r,t)),i&&gi(t,n,i)&&e.push(na(i,t))}function aa(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return ra(n,r,e);let i=ea(e,e[t]||``,t,n,r);return ia(i,e,t,n,r),i}function oa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function sa(e,t){return t===`fix`?aa(e):oa(e)}var ca=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=sa(t,`fix`),r=sa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=sa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function la(e){return e?Object.values(e).some(t=>Wi(t,e)):!1}function ua(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function da(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var fa=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=da(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&la(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},pa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`@biomejs/biome`),r=da(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},ma=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`prettier`),r=!!t?.prettier,i=da(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ha=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`eslint`),r=!!t?.eslintConfig,i=da(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ga=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxlint`),r=da(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},_a=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=ua(t,`oxfmt`),r=da(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},va=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new ca;vitePlusAdapter=new fa;biomeAdapter=new pa;prettierAdapter=new ma;eslintAdapter=new ha;oxlintAdapter=new ga;oxfmtAdapter=new _a;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},ya=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ba=class{id=`python`;name=`Python`;ruffAdapter=new ya;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},xa=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function Sa(){let e=new xa;return e.registerProvider(new ba),e.registerProvider(new va),e}const Ca=Sa();async function wa(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function Ta(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Ca,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await wa(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}}async function Ea(e,t,n=process.cwd()){let r=`${e} ${t.join(` `)}`.trim();if(en(`Executing: ${r}`),await Yt(e,t,{cwd:n,ignoreReturnCode:!0})!==0)throw Error(`Python command "${r}" failed. Check Python environment and dependency configuration.`)}async function Da(e,t=process.cwd()){Dr(e,`Invalid Python environment: "pmInfo" must be an object`);let n=e.name===`pip`?`pip`:e.name;if(!await Vt(n,!1)&&!e.isStandalone){let e=`Required Python package manager '${n}' is not available in PATH.`;throw Error(e)}if(!e.isStandalone&&e.installCommands.length>0){let n=e.installCommands;en(`Installing Python dependencies: ${n.map(e=>`${e.executable} ${e.args.join(` `)}`).join(` && `)}`);for(let{executable:e,args:r}of n)await Ea(e,r,t)}}async function Oa(e=process.cwd(),t,n){if(!(t??or(e)))return;let r;if(n)r=n;else{if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);r=(await Lr(Ca,{cwd:e,hasPythonSource:!0},`fix`)).tasks.filter(e=>e.toolId===`ruff`)}let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}}async function ka(e,t){if(process.env.JS_SETUP_OUTCOME===`failure`||process.env.NODE_SETUP_OUTCOME===`failure`||process.env.BUN_SETUP_OUTCOME===`failure`||process.env.PNPM_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`JavaScript runtime or package manager setup failed.`);try{if(t){let n=fn(e);if(!n.hasPackageJson)return en(`No package.json found. Skipping scripts.`),null;if(n.packageJsonError)throw Error(n.packageJsonError);if(t.length===0)return en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`),null;await wa(vn(cn(process.env.PACKAGE_MANAGER||_n(n).name)),e);let r=(await new Ar().executeTasks(t)).filter(e=>e.error);if(r.length>0){let e=r.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` -`))}return null}return await Ta(e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Aa(e,t){if(process.env.PYTHON_SETUP_OUTCOME===`failure`||process.env.UV_SETUP_OUTCOME===`failure`||process.env.PY_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Python runtime or package manager setup failed.`);let n=t&&`pmInfo`in t?t.pmInfo:Tr(e,void 0,{ctx:t?.ctx,hasSource:t?.hasSource});if(!n)return null;try{return await Da(n,e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ja(e,t,n){if(process.env.RUFF_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Ruff setup failed.`);try{return await Oa(e,t,n),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Ma(e,t,n){let r=t??or(e);if(!r)return[];let i=[],a=ir(e),o=await Aa(e,{ctx:a,hasSource:!0,pmInfo:Tr(e,void 0,{ctx:a,hasSource:!0,isProject:!0})});o&&i.push(o);let s=await ja(e,r,n);return s&&i.push(s),i}async function Na(e=process.cwd()){let t=or(e),n;try{let r=fn(e),i={cwd:e,jsEnv:r,jsPm:cn(process.env.PACKAGE_MANAGER||_n(r).name),hasPythonSource:t};n=await Lr(Ca,i,`fix`),en(n.summary)}catch{}let r=[],i=n?n.tasks.filter(e=>e.toolId!==`ruff`):void 0,a=n?n.tasks.filter(e=>e.toolId===`ruff`):void 0,o=await ka(e,i);o&&r.push(o);let s=await Ma(e,t,a);r.push(...s),r.length>0&&(Zt(`Failed to run scripts: ${r.map(e=>e.message).join(` -`)}`),process.env.NODE_ENV!==`test`&&process.exit(1))}process.env.NODE_ENV!==`test`&&Or(import.meta.url)&&Na();export{Ta as executeJsWorkflow,Da as executePythonWorkflow,Oa as executeRuffAutofix,Na as run,cn as sanitizePackageManager}; \ No newline at end of file +`;)n++;return n>t?n-1:t}function Gr(e,t){return t.inSingleQuote||t.inDoubleQuote||t.isEscaped?!1:e.length===0||/\s/.test(e[e.length-1])}function Kr(e,t){return t.isEscaped=!1,{ch:e,advance:!0}}function qr(e,t,n,r){let i=e[t];if(n.isEscaped)return{newCmd:r+Kr(i,n).ch,nextIndex:t,sepLen:0};if(i===`\\`&&!n.inSingleQuote)return n.isEscaped=!0,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`'`&&!n.inDoubleQuote)return n.inSingleQuote=!n.inSingleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`"`&&!n.inSingleQuote)return n.inDoubleQuote=!n.inDoubleQuote,{newCmd:r+i,nextIndex:t,sepLen:0};if(i===`#`&&Gr(r,n))return{newCmd:r,nextIndex:Wr(e,t),sepLen:0};let a=Ur(e,t,n);return{newCmd:r+(a===0?i:``),nextIndex:t,sepLen:a}}function Jr(e){let t=[],n=``,r={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1,hasSyntaxError:!1};for(let i=0;i0?(n.trim()&&t.push(n.trim()),n=``,i+=a.sepLen-1):(n=a.newCmd,i=a.nextIndex)}return(r.inSingleQuote||r.inDoubleQuote||r.isEscaped)&&(r.hasSyntaxError=!0),n.trim()&&t.push(n.trim()),{commands:t,hasSyntaxError:r.hasSyntaxError}}function Yr(e,t,n){return t.isEscaped=!1,n+e}function Xr(e,t){return e===`'`&&!t.inDoubleQuote?(t.inSingleQuote=!t.inSingleQuote,!0):e===`"`&&!t.inSingleQuote&&(t.inDoubleQuote=!t.inDoubleQuote,!0)}const Zr=/* @__PURE__ */ new Set([`@`,`*`,`#`,`?`,`-`,`$`,`!`,`0`]);function Qr(e,t,n){if(n.inSingleQuote||n.isEscaped||e[t]!==`$`||t+1>=e.length)return!1;let r=e[t+1];return!!(r===`{`||Zr.has(r)||r>=`1`&&r<=`9`||r===`_`||r>=`a`&&r<=`z`||r>=`A`&&r<=`Z`)}function $r(e,t,n){if(n.inSingleQuote||n.inDoubleQuote||n.isEscaped||e[t]!==`&`)return!1;let r=t>0?e[t-1]:``,i=t+1`}function ei(e,t,n){if(n.inSingleQuote||n.isEscaped)return!1;let r=e[t];return r==="`"||r===`$`&&t+1`)&&t+1`||r===`<`||r===`&`&&t+1`}function ri(e,t,n){return $r(e,t,n.state)||Qr(e,t,n.state)||ei(e,t,n.state)||ti(e,t,n.state)?(n.inspection.hasUnsupportedSyntax=!0,!0):ni(e,t,n.state)?(n.inspection.hasRedirection=!0,n.inspection.hasUnsupportedSyntax=!0,!0):!1}function ii(e,t,n,r){let i=e[t];return n.state.isEscaped?{word:Yr(i,n.state,r),hasChars:!0,skipped:!1}:i===`\\`&&!n.state.inSingleQuote?(n.state.isEscaped=!0,{word:r,hasChars:!1,skipped:!0}):(ri(e,t,n),Xr(i,n.state)?{word:r,hasChars:!0,skipped:!0}:{word:r+i,hasChars:!0,skipped:!1})}function ai(e){let t={tokens:[],hasUnsupportedSyntax:!1,hasRedirection:!1,hasSyntaxError:!1},n={inSingleQuote:!1,inDoubleQuote:!1,isEscaped:!1},r={inspection:t,state:n},i=``,a=!1;for(let o=0;o0;){let e=0;for(;e0&&(t[0]===`cross-env`||t[0]===`cross-env-shell`)){let e=ci(t);if(e===t)break;t=e}else break}return t}function ui(e){return li(e)}function di(e,t){if(e.length===0)return!1;let[n,r,i]=e;return(n===`npm`||n===`pnpm`||n===`yarn`||n===`bun`)&&r===`run`&&i===t||(n===`pnpm`||n===`bun`||n===`yarn`)&&r===t}function fi(e){if(!e)return{invocations:[],hasSyntaxError:!1};let t=Jr(e),n=t.hasSyntaxError,r=[];for(let e of t.commands){let t=ai(e);t.hasSyntaxError&&(n=!0);let i=ui(t.tokens);i.length>0&&r.push(i)}return{invocations:r,hasSyntaxError:n}}function pi(e,t,n={},r=/* @__PURE__ */ new Set){if(!e||!t)return!1;let{invocations:i,hasSyntaxError:a}=fi(n[e]===void 0?e:n[e]);if(a)return!1;for(let e of i){if(di(e,t))return!0;let i=Vi(e);if(i){if(i===t)return!0;if(!r.has(i)&&n[i]!==void 0){r.add(i);try{if(pi(n[i],t,n,r))return!0}finally{r.delete(i)}}}let a=Hi(e);if(a!==void 0&&pi(a,t,n,r))return!0}return!1}function mi(e,t,n){return!n||n===t?!1:!pi(e[t]||``,n,e)}function hi(e,t,n){return!n||n===t?!1:!pi(e[t]||``,n,e)}function gi(e){let[t]=e;return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||(e===`--fix`||e.startsWith(`--fix=`))&&(t!==`eslint`||e!==`--fix-dry-run`))}function _i(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function vi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function yi(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`))}function bi(e){let[t]=e;return t===`eslint`&&e.some(e=>(e===`--fix`||e.startsWith(`--fix=`))&&e!==`--fix-dry-run`)}function xi(e){let[t]=e;return t===`oxlint`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Si(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function Ci(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`))}function wi(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:!e.some(e=>e===`--check`||e===`-c`)}function Ti(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Ei(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)&&e!==`--fix-dry-run`||e===`-o`||e.startsWith(`-o=`)||e===`--output-file`||e.startsWith(`--output-file=`)||e===`--cache`||e===`--cache-file`||e.startsWith(`--cache-file=`)||e===`--cache-location`||e.startsWith(`--cache-location=`))}function Di(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--cache`||e===`--cache-location`||e.startsWith(`--cache-location=`)||e===`--insert-pragma`)}function Oi(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--fix`||e.startsWith(`--fix=`)||e===`--reporter-file`||e.startsWith(`--reporter-file=`)||e===`--log-file`||e.startsWith(`--log-file=`))}function ki(e){return e.some(e=>e===`--fix`||e.startsWith(`--fix=`)||e===`--fix-suggestions`||e===`--fix-dangerously`||e===`--init`)}function Ai(e){return e.some(e=>e===`-w`||e===`--write`||e.startsWith(`--write=`)||e===`--init`||e===`--migrate`||e.startsWith(`--migrate=`))}function ji(e){let[t]=e;return t===`prettier`&&e.some(e=>e===`--check`||e===`-c`||e===`--list-different`||e===`-l`)&&!Di(e)}function Mi(e){let[t]=e;return t===`oxfmt`&&e.some(e=>e===`--check`||e===`-c`)&&!Ai(e)}function Ni(e){let[t,n]=e;return t!==`biome`||n!==`format`?!1:!Oi(e)}function Pi(e){let[t]=e;return t===`eslint`&&!Ei(e)}function Fi(e){let[t]=e;return t===`oxlint`&&!ki(e)}function Ii(e){let[t,n]=e;return t!==`biome`||n!==`lint`?!1:!Oi(e)}function Li(e){let[t,n]=e;return t!==`biome`||n!==`check`?!1:!Oi(e)}function Ri(e){let[t,n]=e;return t!==`vp`||n!==`fmt`?!1:e.some(e=>e===`--check`||e===`-c`)&&!Ai(e)}function zi(e){let[t,n]=e;return t!==`vp`||n!==`lint`?!1:!ki(e)}function Bi(e){let[t,n]=e;return t!==`vp`||n!==`check`?!1:!e.some(e=>e===`--fix`||e.startsWith(`--fix=`))}function Vi(e){if(e.length===0)return;let[t,n,r]=e;if((t===`npm`||t===`pnpm`||t===`yarn`||t===`bun`)&&n===`run`&&r)return r;if((t===`pnpm`||t===`bun`||t===`yarn`)&&n&&!n.startsWith(`-`))return n}function Hi(e){if(e.length>=3&&(e[0]===`sh`||e[0]===`bash`)&&e[1]===`-c`)return e[2];if(e.length===1&&e[0].trim()!==``&&(e[0].includes(` `)||e[0].includes(` `)||e[0].includes(` +`)||e[0].includes(`;`)||e[0].includes(`&`)||e[0].includes(`|`)))return e[0]}function Ui(e,t={},n=/* @__PURE__ */ new Set){if(!e)return!1;let{invocations:r,hasSyntaxError:i}=fi(e);if(i)return!1;for(let e of r){if(e.length===0)continue;if(e[0]===`vp`||(e[0]===`npx`||e[0]===`bunx`)&&e[1]===`vp`||(e[0]===`npm`||e[0]===`pnpm`||e[0]===`yarn`)&&(e[1]===`exec`||e[1]===`dlx`)&&e[2]===`vp`)return!0;let r=Hi(e);if(r!==void 0&&Ui(r,t,n))return!0;let i=Vi(e);if(i&&!n.has(i)&&t[i]){n.add(i);try{if(Ui(t[i],t,n))return!0}finally{n.delete(i)}}}return!1}function Wi(e){return _i(e)||vi(e)||yi(e)||bi(e)||xi(e)||Si(e)||Ci(e)||wi(e)||Ti(e)}function Gi(e){return ji(e)||Mi(e)||Ni(e)||Pi(e)||Fi(e)||Ii(e)||Li(e)||Ri(e)||zi(e)||Bi(e)}function Ki(e,t,n){if(e.length===0)return`unknown`;if(gi(e))return`write-capable`;let r=Hi(e);if(r!==void 0)return qi(r,t,n);let i=Vi(e);if(i){if(n.has(i))return`unknown`;let e=t[i];if(!e)return`unknown`;n.add(i);try{return qi(e,t,n)}finally{n.delete(i)}}return Wi(e)?`write-capable`:Gi(e)?`read-only`:`unknown`}function qi(e,t,n){let r=Jr(e);if(r.hasSyntaxError)return`unknown`;let{commands:i}=r;if(i.length===0)return`unknown`;let a=!1;for(let e of i){let r=ai(e),i=Ki(ui(r.tokens),t,n);if(i===`write-capable`)return`write-capable`;if(r.hasUnsupportedSyntax||i===`unknown`)return`unknown`;i===`read-only`&&(a=!0)}return a?`read-only`:`unknown`}function Ji(e,t={}){return qi(e,t,/* @__PURE__ */ new Set)}function Yi(e,t={},n=/* @__PURE__ */ new Set){let{invocations:r,hasSyntaxError:i}=fi(e);return!i&&r.some(e=>{let r=Vi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Yi(e,t,n)}finally{n.delete(r)}}let i=Hi(e);return i===void 0?_i(e)||vi(e)||yi(e)||wi(e):Yi(i,t,n)})}function Xi(e,t={},n=/* @__PURE__ */ new Set){let{invocations:r,hasSyntaxError:i}=fi(e);return!i&&r.some(e=>{let r=Vi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Xi(e,t,n)}finally{n.delete(r)}}let i=Hi(e);return i===void 0?bi(e)||xi(e)||Si(e)||Ti(e):Xi(i,t,n)})}function Zi(e,t={},n=/* @__PURE__ */ new Set){let{invocations:r,hasSyntaxError:i}=fi(e);return!i&&r.some(e=>{let r=Vi(e);if(r){if(n.has(r))return!1;let e=t[r];if(!e)return!1;n.add(r);try{return Zi(e,t,n)}finally{n.delete(r)}}let i=Hi(e);if(i!==void 0)return Zi(i,t,n);if(Ci(e))return!0;let[a,o]=e;return a===`vp`&&o===`check`&&e.some(e=>e===`--fix`||e.startsWith(`--fix=`))})}function Qi(e,t,n,r){return t&&pi(e,t,n)?!0:r(e)}function $i(e,t,n,r,i){let a=Qi(t,r,e,t=>Yi(t,e)),o=Qi(t,i,e,t=>Xi(t,e)),s=Zi(t,e);return a&&o?[{capability:`format`,capabilities:[`format`,`lint`],scriptName:n}]:a&&!s?[{capability:`format`,scriptName:n}]:o&&!s?[{capability:`lint`,scriptName:n}]:s?[{capability:`autofix`,scriptName:n}]:[{capability:`typecheck`,capabilities:[],scriptName:n}]}function ea(e,t){return Yi(t[e],t)?{capability:`format`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function ta(e,t){return Xi(t[e],t)?{capability:`lint`,scriptName:e}:{capability:`typecheck`,capabilities:[],scriptName:e}}function na(e,t,n){let r=[];return e&&r.push(ea(e,n)),t&&r.push(ta(t,n)),r}function ra(e,t,n,r,i){r&&mi(t,n,r)&&e.push(ea(r,t)),i&&hi(t,n,i)&&e.push(ta(i,t))}function ia(e){let t=e.fix?`fix`:e[`check:fix`]?`check:fix`:void 0,n=Vr(e,`fix`),r=Hr(e,`fix`);if(!t)return na(n,r,e);let i=$i(e,e[t]||``,t,n,r);return ra(i,e,t,n,r),i}function aa(e){let t=[],n=Vr(e,`check`),r=Hr(e,`check`);return n&&t.push({capability:`format`,scriptName:n}),r&&t.push({capability:`lint`,scriptName:r}),t}function oa(e,t){return t===`fix`?ia(e):aa(e)}var sa=class{id=`npm-scripts`;name=`package.json scripts`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson?.scripts;if(!t||Object.keys(t).length===0)return{detected:!1,reason:`no scripts declared in package.json`};let n=oa(t,`fix`),r=oa(t,`check`),i=[...n,...r];return i.length>0?{detected:!0,reason:`found supported scripts: ${Array.from(new Set(i.map(e=>`"${e.scriptName}"`))).join(`, `)}`}:{detected:!1,reason:`no supported autofix or check scripts found in package.json`}}plan(e,t){let n=oa(e.jsEnv?.packageJson?.scripts||{},t),r=cn(e.jsPm||`npm`);return n.map(n=>({id:`script-${n.scriptName}`,toolId:this.id,capability:n.capability,capabilities:n.capabilities,executable:r,args:[`run`,n.scriptName],cwd:e.cwd,mode:t,description:`package.json script: ${r} run ${n.scriptName}`}))}};function ca(e){return e?Object.values(e).some(t=>Ui(t,e)):!1}function la(e,t){return e?!!(e.dependencies?.[t]||e.devDependencies?.[t]||e.peerDependencies?.[t]||e.optionalDependencies?.[t]):!1}function ua(e,t){for(let n of t)if(f.existsSync(p.join(e,n)))return!0;return!1}var da=class{id=`vite-plus`;name=`Vite+`;capabilities=[`autofix`,`format`,`lint`];detect(e){let t=e.jsEnv?.packageJson,n=sn(t),r=ua(e.cwd,[`vite.config.ts`,`vite.config.js`,`vite.config.mjs`,`vite.config.cjs`]);return n||r&&ca(t?.scripts)?{detected:!0,reason:`Vite+ dependency and/or configuration detected`}:{detected:!1,reason:`no Vite+ dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`vite-plus-fmt`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp fmt`},{id:`vite-plus-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`,`--fix`],cwd:e.cwd,mode:`fix`,description:`Vite+: vp lint --fix`}]:[{id:`vite-plus-fmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`format`,executable:`vp`,args:[`fmt`,`--check`],cwd:e.cwd,mode:`check`,description:`Vite+: vp fmt --check`},{id:`vite-plus-lint`,toolId:this.id,toolName:this.name,requiredPackage:`vite-plus`,capability:`lint`,executable:`vp`,args:[`lint`],cwd:e.cwd,mode:`check`,description:`Vite+: vp lint`}]}},fa=class{id=`biome`;name=`Biome`;capabilities=[`format`,`lint`,`assist`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`@biomejs/biome`),r=ua(e.cwd,[`biome.json`,`biome.jsonc`]);return n&&r?{detected:!0,reason:`Biome dependency and configuration detected`}:r?{detected:!0,reason:`Biome configuration detected`}:n?{detected:!1,reason:`Biome dependency present without configuration file`}:{detected:!1,reason:`no Biome dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`biome-format-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: format --write .`},{id:`biome-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: lint --write .`},{id:`biome-assist-fix`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--write`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`fix`,description:`Biome: safe assist actions (--write)`}]:[{id:`biome-format-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`format`,executable:`biome`,args:[`format`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: format .`},{id:`biome-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`lint`,executable:`biome`,args:[`lint`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: lint .`},{id:`biome-assist-check`,toolId:this.id,toolName:this.name,requiredPackage:`@biomejs/biome`,capability:`assist`,executable:`biome`,args:[`check`,`--formatter-enabled=false`,`--linter-enabled=false`,`.`],cwd:e.cwd,mode:`check`,description:`Biome: check assist actions`}]}},pa=class{id=`prettier`;name=`Prettier`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`prettier`),r=!!t?.prettier,i=ua(e.cwd,[`.prettierrc`,`.prettierrc.json`,`.prettierrc.yml`,`.prettierrc.yaml`,`.prettierrc.json5`,`.prettierrc.js`,`.prettierrc.cjs`,`.prettierrc.mjs`,`prettier.config.js`,`prettier.config.cjs`,`prettier.config.mjs`]);return n&&(r||i)?{detected:!0,reason:`Prettier dependency and configuration detected`}:r||i?{detected:!0,reason:`Prettier configuration detected`}:n?{detected:!1,reason:`Prettier dependency present without configuration`}:{detected:!1,reason:`no Prettier dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`prettier-format`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Prettier: format`}]:[{id:`prettier-check`,toolId:this.id,toolName:this.name,requiredPackage:`prettier`,capability:`format`,executable:`prettier`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Prettier: format check`}]}},ma=class{id=`eslint`;name=`ESLint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`eslint`),r=!!t?.eslintConfig,i=ua(e.cwd,[`eslint.config.js`,`eslint.config.mjs`,`eslint.config.cjs`,`eslint.config.ts`,`.eslintrc`,`.eslintrc.js`,`.eslintrc.cjs`,`.eslintrc.json`,`.eslintrc.yaml`,`.eslintrc.yml`]);return n&&(r||i)?{detected:!0,reason:`ESLint dependency and configuration detected`}:r||i?{detected:!0,reason:`ESLint configuration detected`}:n?{detected:!1,reason:`ESLint dependency present without configuration`}:{detected:!1,reason:`no ESLint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`eslint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`ESLint: lint autofix`}]:[{id:`eslint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`eslint`,capability:`lint`,executable:`eslint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`ESLint: lint check`}]}},ha=class{id=`oxlint`;name=`Oxlint`;capabilities=[`lint`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`oxlint`),r=ua(e.cwd,[`.oxlintrc.json`,`oxlint.json`,`oxlint.config.ts`,`oxlint.config.js`]);return n&&r?{detected:!0,reason:`Oxlint dependency and configuration detected`}:r?{detected:!0,reason:`Oxlint configuration detected`}:n?{detected:!1,reason:`Oxlint dependency present without configuration`}:{detected:!1,reason:`no Oxlint dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxlint-lint-fix`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxlint: lint autofix`}]:[{id:`oxlint-lint-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxlint`,capability:`lint`,executable:`oxlint`,args:[`.`],cwd:e.cwd,mode:`check`,description:`Oxlint: lint check`}]}},ga=class{id=`oxfmt`;name=`Oxfmt`;capabilities=[`format`];detect(e){let t=e.jsEnv?.packageJson,n=la(t,`oxfmt`),r=ua(e.cwd,[`.oxfmtrc.json`,`oxfmt.json`,`oxfmt.config.ts`,`oxfmt.config.js`]);return n&&r?{detected:!0,reason:`Oxfmt dependency and configuration detected`}:r?{detected:!0,reason:`Oxfmt configuration detected`}:n?{detected:!1,reason:`Oxfmt dependency present without configuration`}:{detected:!1,reason:`no Oxfmt dependency or configuration`}}plan(e,t){return t===`fix`?[{id:`oxfmt-format`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--write`,`.`],cwd:e.cwd,mode:`fix`,description:`Oxfmt: format`}]:[{id:`oxfmt-check`,toolId:this.id,toolName:this.name,requiredPackage:`oxfmt`,capability:`format`,executable:`oxfmt`,args:[`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Oxfmt: format check`}]}},_a=class{id=`javascript`;name=`JavaScript/TypeScript`;scriptAdapter=new sa;vitePlusAdapter=new da;biomeAdapter=new fa;prettierAdapter=new pa;eslintAdapter=new ma;oxlintAdapter=new ha;oxfmtAdapter=new ga;detect(e){return!!e.jsEnv?.hasPackageJson}getAdapters(e){return[this.scriptAdapter,this.vitePlusAdapter,this.biomeAdapter,this.oxfmtAdapter,this.prettierAdapter,this.oxlintAdapter,this.eslintAdapter]}},va=class{id=`ruff`;name=`Ruff`;capabilities=[`lint`,`format`];detect(e){return e.hasPythonSource??or(e.cwd)?{detected:!0,reason:`default Python toolchain`}:{detected:!1,reason:`no Python source files detected`}}plan(e,t){let n=[];return t===`fix`?n.push({id:`ruff-lint-fix`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`--fix`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: lint autofix`},{id:`ruff-format`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`.`],cwd:e.cwd,mode:`fix`,description:`Ruff: format`}):n.push({id:`ruff-lint-check`,toolId:this.id,capability:`lint`,executable:`ruff`,args:[`check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: lint check`},{id:`ruff-format-check`,toolId:this.id,capability:`format`,executable:`ruff`,args:[`format`,`--check`,`.`],cwd:e.cwd,mode:`check`,description:`Ruff: format check`}),n}},ya=class{id=`python`;name=`Python`;ruffAdapter=new va;detect(e){return e.hasPythonSource??or(e.cwd)}getAdapters(e){return[this.ruffAdapter]}},ba=class{providers=/* @__PURE__ */ new Map;standaloneAdapters=/* @__PURE__ */ new Map;registerProvider(e){this.providers.set(e.id,e)}getProvider(e){return this.providers.get(e)}getProviders(){return Array.from(this.providers.values())}registerAdapter(e){this.standaloneAdapters.set(e.id,e)}getAdapter(e){return this.standaloneAdapters.get(e)}getStandaloneAdapters(){return Array.from(this.standaloneAdapters.values())}clear(){this.providers.clear(),this.standaloneAdapters.clear()}};function xa(){let e=new ba;return e.registerProvider(new ya),e.registerProvider(new _a),e}const Sa=xa();async function Ca(e,t=process.cwd()){let n=`${e.command} ${e.args.join(` `)}`.trim();if(en(`Installing JS dependencies: ${n}`),await Yt(e.command,e.args,{cwd:t,ignoreReturnCode:!0})!==0)throw Error(`JS dependency installation failed executing "${n}". Check dependency constraints or lockfile compatibility.`)}async function wa(e=process.cwd()){let t=fn(e);if(!t.hasPackageJson){en(`No package.json found. Skipping scripts.`);return}if(t.packageJsonError)throw Error(t.packageJsonError);let n=cn(process.env.PACKAGE_MANAGER||_n(t).name),r=(await Lr(Sa,{cwd:e,jsEnv:t,jsPm:n,hasPythonSource:!1},`fix`)).tasks.filter(e=>e.toolId!==`ruff`);if(r.length===0){en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`);return}await Ca(vn(n),e);let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}}async function Ta(e,t,n=process.cwd()){let r=`${e} ${t.join(` `)}`.trim();if(en(`Executing: ${r}`),await Yt(e,t,{cwd:n,ignoreReturnCode:!0})!==0)throw Error(`Python command "${r}" failed. Check Python environment and dependency configuration.`)}async function Ea(e,t=process.cwd()){Dr(e,`Invalid Python environment: "pmInfo" must be an object`);let n=e.name===`pip`?`pip`:e.name;if(!await Vt(n,!1)&&!e.isStandalone){let e=`Required Python package manager '${n}' is not available in PATH.`;throw Error(e)}if(!e.isStandalone&&e.installCommands.length>0){let n=e.installCommands;en(`Installing Python dependencies: ${n.map(e=>`${e.executable} ${e.args.join(` `)}`).join(` && `)}`);for(let{executable:e,args:r}of n)await Ta(e,r,t)}}async function Da(e=process.cwd(),t,n){if(!(t??or(e)))return;let r;if(n)r=n;else{if(!await Vt(`ruff`,!1))throw Error(`Required Python binary 'ruff' is not available in PATH.`);r=(await Lr(Sa,{cwd:e,hasPythonSource:!0},`fix`)).tasks.filter(e=>e.toolId===`ruff`)}let i=(await new Ar().executeTasks(r)).filter(e=>e.error);if(i.length>0){let e=i.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}}async function Oa(e,t){if(process.env.JS_SETUP_OUTCOME===`failure`||process.env.NODE_SETUP_OUTCOME===`failure`||process.env.BUN_SETUP_OUTCOME===`failure`||process.env.PNPM_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`JavaScript runtime or package manager setup failed.`);try{if(t){let n=fn(e);if(!n.hasPackageJson)return en(`No package.json found. Skipping scripts.`),null;if(n.packageJsonError)throw Error(n.packageJsonError);if(t.length===0)return en(`No matching scripts (fix, format, lint, check, etc.) found in package.json.`),null;await Ca(vn(cn(process.env.PACKAGE_MANAGER||_n(n).name)),e);let r=(await new Ar().executeTasks(t)).filter(e=>e.error);if(r.length>0){let e=r.map(e=>e.error?.message||`Task ${e.task.id} failed`);throw Error(e.join(` +`))}return null}return await wa(e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ka(e,t){if(process.env.PYTHON_SETUP_OUTCOME===`failure`||process.env.UV_SETUP_OUTCOME===`failure`||process.env.PY_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Python runtime or package manager setup failed.`);let n=t&&`pmInfo`in t?t.pmInfo:Tr(e,void 0,{ctx:t?.ctx,hasSource:t?.hasSource});if(!n)return null;try{return await Ea(n,e),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function Aa(e,t,n){if(process.env.RUFF_SETUP_OUTCOME===`failure`)return/* @__PURE__ */ Error(`Ruff setup failed.`);try{return await Da(e,t,n),null}catch(e){return e instanceof Error?e:Error(String(e))}}async function ja(e,t,n){let r=t??or(e);if(!r)return[];let i=[],a=ir(e),o=await ka(e,{ctx:a,hasSource:!0,pmInfo:Tr(e,void 0,{ctx:a,hasSource:!0,isProject:!0})});o&&i.push(o);let s=await Aa(e,r,n);return s&&i.push(s),i}async function Ma(e=process.cwd()){let t=or(e),n;try{let r=fn(e),i={cwd:e,jsEnv:r,jsPm:cn(process.env.PACKAGE_MANAGER||_n(r).name),hasPythonSource:t};n=await Lr(Sa,i,`fix`),en(n.summary)}catch{}let r=[],i=n?n.tasks.filter(e=>e.toolId!==`ruff`):void 0,a=n?n.tasks.filter(e=>e.toolId===`ruff`):void 0,o=await Oa(e,i);o&&r.push(o);let s=await ja(e,t,a);r.push(...s),r.length>0&&(Zt(`Failed to run scripts: ${r.map(e=>e.message).join(` +`)}`),process.env.NODE_ENV!==`test`&&process.exit(1))}process.env.NODE_ENV!==`test`&&Or(import.meta.url)&&Ma();export{wa as executeJsWorkflow,Ea as executePythonWorkflow,Da as executeRuffAutofix,Ma as run,cn as sanitizePackageManager}; \ No newline at end of file diff --git a/src/autofix/adapters/javascript/script-adapter.ts b/src/autofix/adapters/javascript/script-adapter.ts index d4c09f5..15292a3 100644 --- a/src/autofix/adapters/javascript/script-adapter.ts +++ b/src/autofix/adapters/javascript/script-adapter.ts @@ -507,7 +507,11 @@ export function delegatesToScript( const scriptBody = scripts[scriptBodyOrName] !== undefined ? scripts[scriptBodyOrName] : scriptBodyOrName; - const invocations = parseCommandInvocations(scriptBody); + const { invocations, hasSyntaxError } = parseCommandInvocationsDetailed(scriptBody); + if (hasSyntaxError) { + return false; + } + for (const tokens of invocations) { if (matchesPmDelegation(tokens, targetScriptName)) { return true; @@ -1012,7 +1016,10 @@ function hasVerifiedFormattingCommand( scripts: Record = {}, activePath: Set = new Set(), ): boolean { - const invocations = parseCommandInvocations(command); + const { invocations, hasSyntaxError } = parseCommandInvocationsDetailed(command); + if (hasSyntaxError) { + return false; + } return invocations.some((tokens) => { const target = extractDelegatedTarget(tokens); if (target) { @@ -1044,7 +1051,10 @@ function hasVerifiedLintingCommand( scripts: Record = {}, activePath: Set = new Set(), ): boolean { - const invocations = parseCommandInvocations(command); + const { invocations, hasSyntaxError } = parseCommandInvocationsDetailed(command); + if (hasSyntaxError) { + return false; + } return invocations.some((tokens) => { const target = extractDelegatedTarget(tokens); if (target) { @@ -1073,7 +1083,10 @@ function hasVerifiedFullCheckCommand( scripts: Record = {}, activePath: Set = new Set(), ): boolean { - const invocations = parseCommandInvocations(command); + const { invocations, hasSyntaxError } = parseCommandInvocationsDetailed(command); + if (hasSyntaxError) { + return false; + } return invocations.some((tokens) => { const target = extractDelegatedTarget(tokens); if (target) { diff --git a/tests/autofix-architecture.test.ts b/tests/autofix-architecture.test.ts index 72a17dd..65ba40c 100644 --- a/tests/autofix-architecture.test.ts +++ b/tests/autofix-architecture.test.ts @@ -2878,6 +2878,64 @@ describe("Refactored Autofix Architecture & Tool Adapters", () => { expect(plan.tasks[0].capability).toBe("format"); expect(plan.tasks[0].capabilities).toEqual(["format", "lint"]); }); + + it("verifies malformed quoted commands fail closed and do not claim capability coverage or suppress child tasks", async () => { + // A. Malformed quoted command in cross-env-shell + const scriptsCrossEnvShell = { + fix: 'cross-env-shell CI=1 "npm run format:write && npm run lint:fix \'unterminated"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasksCrossEnvShell = resolveScriptTasks(scriptsCrossEnvShell, "fix"); + expect(tasksCrossEnvShell).toEqual([ + { capability: "typecheck", capabilities: [], scriptName: "fix" }, + { capability: "format", scriptName: "format:write" }, + { capability: "lint", scriptName: "lint:fix" }, + ]); + + // B. Malformed nested command in sh -c + const scriptsSh = { + fix: 'sh -c "npm run format:write && npm run lint:fix \\"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasksSh = resolveScriptTasks(scriptsSh, "fix"); + expect(tasksSh).toEqual([ + { capability: "typecheck", capabilities: [], scriptName: "fix" }, + { capability: "format", scriptName: "format:write" }, + { capability: "lint", scriptName: "lint:fix" }, + ]); + + // C. Malformed nested command in bash -c + const scriptsBash = { + fix: 'bash -c "npm run format:write && npm run lint:fix \\"', + "format:write": "prettier --write .", + "lint:fix": "eslint --fix .", + }; + const tasksBash = resolveScriptTasks(scriptsBash, "fix"); + expect(tasksBash).toEqual([ + { capability: "typecheck", capabilities: [], scriptName: "fix" }, + { capability: "format", scriptName: "format:write" }, + { capability: "lint", scriptName: "lint:fix" }, + ]); + + // D. Full planExecution with malformed cross-env-shell preserves child tasks + fs.writeFileSync( + path.join(tempDir, "package.json"), + JSON.stringify({ + scripts: scriptsCrossEnvShell, + }), + ); + + const registry = createDefaultRegistry(); + const plan = await planExecution(registry, { cwd: tempDir }, "fix"); + + expect(plan.tasks.map((t) => t.id)).toEqual([ + "script-fix", + "script-format:write", + "script-lint:fix", + ]); + }); }); describe("Regression: F-02 Read-Only Classifier Audit for File-Writing Options", () => {