@webability/cli 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- var ae=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFileSync as Fe}from"fs";import{fileURLToPath as Se}from"url";import{dirname as Ee,join as $e}from"path";import{Command as Ie}from"commander";import a from"chalk";import I from"ora";var ne="https://api.webability.io";async function re(e,t={},n){let o=await fetch(`${ne}${e}`,{...t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`,Origin:"https://app.webability.io",...t.headers}});if(!o.ok){let r=await o.text().catch(()=>"");throw new Error(`API ${o.status}: ${r.slice(0,200)}`)}return o.json()}async function D(e,t,n){let o=await re("/graphql",{method:"POST",body:JSON.stringify({query:e,variables:t})},n);if(o.errors?.length)throw new Error(o.errors[0].message);return o.data}async function K(e,t,n){n?.("Starting scan...");let{startAccessibilityReportJob:o}=await D("query($url: String!) { startAccessibilityReportJob(url: $url, use_cache: false) { jobId } }",{url:e},t),r=o.jobId;n?.(`Job ${r.slice(0,8)}... created`);for(let i=0;i<60;i++){await new Promise(l=>setTimeout(l,3e3));let{getAccessibilityReportByJobId:s}=await D("query($jobId: String!) { getAccessibilityReportByJobId(jobId: $jobId) { status error result { savedReport { key } } } }",{jobId:r},t);if(s.status==="done")return{key:s.result.savedReport.key};if(s.status==="error")throw new Error(s.error||"Scan failed");n?.(`Scanning... (${(i+1)*3}s)`)}throw new Error("Scan timed out after 3 minutes")}async function U(e,t){let{fetchReportByR2Key:n}=await D("query($key: String!) { fetchReportByR2Key(r2_key: $key) { score totalElements siteImg ByFunctions { name count issues { code impact description element } } axe { violations { id impact description nodes { html target } } } } }",{key:e},t);return n}import le from"conf";var S=new le({projectName:"webability",schema:{apiKey:{type:"string",default:""},accessCode:{type:"string",default:""},defaultFormat:{type:"string",default:"table",enum:["table","json","csv"]}}});function E(){return process.env.WEBABILITY_API_KEY||S.get("apiKey")||""}function T(e){S.set("apiKey",e)}function ce(){return S.get("accessCode")||""}function O(e){S.set("accessCode",e)}function G(){return!!ce()}function J(){S.clear()}import{scan as de,detectFramework as pe,generateDevSuggestion as ue}from"@webability/core";var ge={weak_link_name:"Screen-reader users navigate by pulling up a links list (VoiceOver Rotor / NVDA Insert+F7). They hear: 'Learn more, Learn more, Learn more' \u2014 every link sounds identical. They can't tell where each goes without context.",weak_button_name:"Same problem as weak links \u2014 assistive tech announces 'Submit' or 'Click here' with no context, so users can't tell what each button does.",missing_alt:`Screen readers say 'image' (or skip it entirely) when there's no alt text. A photo of your CEO becomes 'image, image' to a blind user. Decorative images need alt="" so they're skipped intentionally.`,decorative_icon:"Decorative icons next to labelled text get announced twice: 'home icon, Home'. Wastes the user's time and creates audio clutter.",missing_label:"Form inputs without labels are invisible to screen readers \u2014 users hear 'edit text' with no idea what to type. They abandon the form.",contrast_insufficient:"Low-contrast text excludes users with low vision (1 in 12 men have some color-blindness). It's also unreadable on glare-prone screens, in sunlight, and for older eyes.",non_text_contrast_insufficient:"If a button's border or icon doesn't have 3:1 contrast against its background, low-vision users can't see the boundary or recognize the icon at all.",target_too_small:"Touch targets under 24\xD724px are hard to hit accurately for users with motor impairments (Parkinson's, MS, arthritis). Mis-taps trigger wrong actions and frustrate keyboard-only users too.",missing_skip_link:"Keyboard and screen-reader users have to Tab through your entire header (logo, nav, CTAs) on every single page. A skip link lets them jump straight to main content \u2014 a 30-second fix that saves disabled users minutes of navigation per visit.",motion_without_reduced_motion:"Vestibular disorders (~35% of adults over 40) can be triggered by parallax, auto-rotation, and rapid animations \u2014 causing nausea, dizziness, and migraines. Respecting prefers-reduced-motion is non-optional.",heading_skip:"Screen-reader users navigate by heading hierarchy \u2014 they jump h1 \u2192 h2 \u2192 h3 to scan structure. Skipping levels (h2 \u2192 h4) makes the page feel disorganized and content gets missed.",multiple_h1:"Multiple h1 elements confuse the page structure model that screen readers and SEO tools use. Each page should have exactly one h1 \u2014 the page title.",redundant_role:`Adding role="navigation" to a <nav> element is redundant \u2014 screen readers already know it's navigation. Redundant ARIA can cause double-announcements.`,duplicate_id:"Duplicate IDs break aria-labelledby, aria-describedby, and label[for] references \u2014 screen readers may read the wrong content or none at all.",missing_required_indicator:"If users don't know a field is required until they submit, they miss the requirement (especially screen-reader users who skip placeholder text). They get an error after the fact and have to re-enter data.",new_window_link:"Opening links in a new tab without warning disorients screen-reader users \u2014 they think the back button is broken. WCAG requires you announce 'opens in new tab' via aria-label or visible text.",color_only_meaning:"Using only color to indicate state (red = error, green = success) excludes the ~8% of men who are color-blind. Always pair color with an icon, label, or pattern.",insufficient_navigation:"Inconsistent nav across pages forces users to relearn the structure on every page. Especially hard on cognitive disabilities and screen-reader users who memorize tab order.",focus_not_visible:"Without a visible focus ring, keyboard users have no idea which element is selected. Tabbing through your site becomes guesswork \u2014 they hit Enter and trigger the wrong action.",aria_hidden_focusable:`An element with aria-hidden="true" but tabindex="0" creates a 'ghost' focus stop \u2014 keyboard users can focus it but screen readers don't announce it. They press Enter on something invisible to them.`,svg_missing_name:"SVG icons that convey meaning (warning triangle, X close button) need an accessible name. Without it, blind users hear 'graphic' or nothing at all."};function me(e){return ge[e.type]||""}var H={A:["wcag2a"],AA:["wcag2a","wcag2aa","wcag21aa","wcag22aa"],AAA:["wcag2a","wcag2aa","wcag2aaa","wcag21aa","wcag22aa"]},fe={critical:"#ef4444",serious:"#f97316",moderate:"#eab308",minor:"#6b7280"},he={critical:"\u2717",serious:"\u25B2",moderate:"\u25CF",minor:"\u25CB"};function be(e,t,n){let o=n||"plain-css";return`
2
+ var Fe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,o)=>(typeof require<"u"?require:t)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFileSync as Ye}from"fs";import{fileURLToPath as Xe}from"url";import{dirname as Qe,join as Ze}from"path";import{Command as et}from"commander";import i from"chalk";import N from"ora";var $e="https://api.webability.io";async function Ee(e,t={},o){let s=await fetch(`${$e}${e}`,{...t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`,Origin:"https://app.webability.io",...t.headers}});if(!s.ok){let a=await s.text().catch(()=>"");throw new Error(`API ${s.status}: ${a.slice(0,200)}`)}return s.json()}async function j(e,t,o){let s=await Ee("/graphql",{method:"POST",body:JSON.stringify({query:e,variables:t})},o);if(s.errors?.length)throw new Error(s.errors[0].message);return s.data}async function se(e,t,o){o?.("Starting scan...");let{startAccessibilityReportJob:s}=await j("query($url: String!) { startAccessibilityReportJob(url: $url, use_cache: false) { jobId } }",{url:e},t),a=s.jobId;o?.(`Job ${a.slice(0,8)}... created`);for(let n=0;n<60;n++){await new Promise(l=>setTimeout(l,3e3));let{getAccessibilityReportByJobId:r}=await j("query($jobId: String!) { getAccessibilityReportByJobId(jobId: $jobId) { status error result { savedReport { key } } } }",{jobId:a},t);if(r.status==="done")return{key:r.result.savedReport.key};if(r.status==="error")throw new Error(r.error||"Scan failed");o?.(`Scanning... (${(n+1)*3}s)`)}throw new Error("Scan timed out after 3 minutes")}async function ie(e,t){let{fetchReportByR2Key:o}=await j("query($key: String!) { fetchReportByR2Key(r2_key: $key) { score totalElements siteImg ByFunctions { name count issues { code impact description element } } axe { violations { id impact description nodes { html target } } } } }",{key:e},t);return o}import Ie from"conf";var R=new Ie({projectName:"webability",schema:{apiKey:{type:"string",default:""},accessCode:{type:"string",default:""},defaultFormat:{type:"string",default:"table",enum:["table","json","csv"]}}});function k(){return process.env.WEBABILITY_API_KEY||R.get("apiKey")||""}function W(e){R.set("apiKey",e)}function Ne(){return R.get("accessCode")||""}function q(e){R.set("accessCode",e)}function ae(){return!!Ne()||!!k()}function ne(){R.clear()}import{scan as Re,detectFramework as Be,generateDevSuggestion as Pe}from"@webability/core";var Me={weak_link_name:"Screen-reader users navigate by pulling up a links list (VoiceOver Rotor / NVDA Insert+F7). They hear: 'Learn more, Learn more, Learn more' \u2014 every link sounds identical. They can't tell where each goes without context.",weak_button_name:"Same problem as weak links \u2014 assistive tech announces 'Submit' or 'Click here' with no context, so users can't tell what each button does.",missing_alt:`Screen readers say 'image' (or skip it entirely) when there's no alt text. A photo of your CEO becomes 'image, image' to a blind user. Decorative images need alt="" so they're skipped intentionally.`,decorative_icon:"Decorative icons next to labelled text get announced twice: 'home icon, Home'. Wastes the user's time and creates audio clutter.",missing_label:"Form inputs without labels are invisible to screen readers \u2014 users hear 'edit text' with no idea what to type. They abandon the form.",contrast_insufficient:"Low-contrast text excludes users with low vision (1 in 12 men have some color-blindness). It's also unreadable on glare-prone screens, in sunlight, and for older eyes.",non_text_contrast_insufficient:"If a button's border or icon doesn't have 3:1 contrast against its background, low-vision users can't see the boundary or recognize the icon at all.",target_too_small:"Touch targets under 24\xD724px are hard to hit accurately for users with motor impairments (Parkinson's, MS, arthritis). Mis-taps trigger wrong actions and frustrate keyboard-only users too.",missing_skip_link:"Keyboard and screen-reader users have to Tab through your entire header (logo, nav, CTAs) on every single page. A skip link lets them jump straight to main content \u2014 a 30-second fix that saves disabled users minutes of navigation per visit.",motion_without_reduced_motion:"Vestibular disorders (~35% of adults over 40) can be triggered by parallax, auto-rotation, and rapid animations \u2014 causing nausea, dizziness, and migraines. Respecting prefers-reduced-motion is non-optional.",heading_skip:"Screen-reader users navigate by heading hierarchy \u2014 they jump h1 \u2192 h2 \u2192 h3 to scan structure. Skipping levels (h2 \u2192 h4) makes the page feel disorganized and content gets missed.",multiple_h1:"Multiple h1 elements confuse the page structure model that screen readers and SEO tools use. Each page should have exactly one h1 \u2014 the page title.",redundant_role:`Adding role="navigation" to a <nav> element is redundant \u2014 screen readers already know it's navigation. Redundant ARIA can cause double-announcements.`,duplicate_id:"Duplicate IDs break aria-labelledby, aria-describedby, and label[for] references \u2014 screen readers may read the wrong content or none at all.",missing_required_indicator:"If users don't know a field is required until they submit, they miss the requirement (especially screen-reader users who skip placeholder text). They get an error after the fact and have to re-enter data.",new_window_link:"Opening links in a new tab without warning disorients screen-reader users \u2014 they think the back button is broken. WCAG requires you announce 'opens in new tab' via aria-label or visible text.",color_only_meaning:"Using only color to indicate state (red = error, green = success) excludes the ~8% of men who are color-blind. Always pair color with an icon, label, or pattern.",insufficient_navigation:"Inconsistent nav across pages forces users to relearn the structure on every page. Especially hard on cognitive disabilities and screen-reader users who memorize tab order.",focus_not_visible:"Without a visible focus ring, keyboard users have no idea which element is selected. Tabbing through your site becomes guesswork \u2014 they hit Enter and trigger the wrong action.",aria_hidden_focusable:`An element with aria-hidden="true" but tabindex="0" creates a 'ghost' focus stop \u2014 keyboard users can focus it but screen readers don't announce it. They press Enter on something invisible to them.`,svg_missing_name:"SVG icons that convey meaning (warning triangle, X close button) need an accessible name. Without it, blind users hear 'graphic' or nothing at all."};function Le(e){return Me[e.type]||""}var re={A:["wcag2a"],AA:["wcag2a","wcag2aa","wcag21aa","wcag22aa"],AAA:["wcag2a","wcag2aa","wcag2aaa","wcag21aa","wcag22aa"]},Te={critical:"#ef4444",serious:"#f97316",moderate:"#eab308",minor:"#6b7280"},De={critical:"\u2717",serious:"\u25B2",moderate:"\u25CF",minor:"\u25CB"};function Oe(e,t,o){let s=o||"plain-css";return`
3
3
  (function() {
4
- const issues = ${JSON.stringify(e.map((i,s)=>{let l=(()=>{try{return ue(i,o)}catch{return null}})();return{id:s,selector:i.selector,impact:i.impact,wcag:i.wcag,type:i.type,message:i.message.slice(0,200),problem:l?.problem||"",recommendedFix:l?.fix||"",wcagLink:l?.wcagLink||`https://www.w3.org/WAI/WCAG21/Understanding/${i.wcag.replace(/\./g,"")}`,whyMatters:me(i),fixDesc:i.fix?.suggestedValue?`Set ${i.fix.attribute}="${i.fix.suggestedValue}"`:"",fixAttr:i.fix?.attribute||"",fixVal:i.fix?.suggestedValue||"",fixCur:i.fix?.currentValue||"",canApply:!!(i.fix?.suggestedValue&&!i.fix?.needsManualReview)}}))};
5
- const colors = ${JSON.stringify(fe)};
6
- const icons = ${JSON.stringify(he)};
4
+ const issues = ${JSON.stringify(e.map((n,r)=>{let l=(()=>{try{return Pe(n,s)}catch{return null}})();return{id:r,selector:n.selector,impact:n.impact,wcag:n.wcag,type:n.type,message:n.message.slice(0,200),problem:l?.problem||"",recommendedFix:l?.fix||"",wcagLink:l?.wcagLink||`https://www.w3.org/WAI/WCAG21/Understanding/${n.wcag.replace(/\./g,"")}`,whyMatters:Le(n),fixDesc:n.fix?.suggestedValue?`Set ${n.fix.attribute}="${n.fix.suggestedValue}"`:"",fixAttr:n.fix?.attribute||"",fixVal:n.fix?.suggestedValue||"",fixCur:n.fix?.currentValue||"",canApply:!!(n.fix?.suggestedValue&&!n.fix?.needsManualReview)}}))};
5
+ const colors = ${JSON.stringify(Te)};
6
+ const icons = ${JSON.stringify(De)};
7
7
  const API_KEY = ${JSON.stringify(t||"")};
8
8
  const API_URL = 'https://api.webability.io';
9
- const FRAMEWORK = ${JSON.stringify(n||"plain-css")};
9
+ const FRAMEWORK = ${JSON.stringify(o||"plain-css")};
10
10
  const activeFilters = { critical: true, serious: true, moderate: true, minor: true };
11
11
  const overlays = [];
12
12
 
@@ -697,7 +697,7 @@ var ae=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(
697
697
 
698
698
  renderList();
699
699
  })();
700
- `}async function Y(e,t){let n=H[t.wcag.toUpperCase()]??H.AA,o=["mobile","tablet","desktop"].includes(t.viewport??"")?t.viewport:"desktop",i=await(await import("playwright")).chromium.launch({headless:!t.show,ignoreDefaultArgs:t.show?["--enable-automation"]:void 0,args:t.show?["--disable-blink-features=AutomationControlled","--no-default-browser-check","--disable-infobars","--no-first-run","--silent-launch","--disable-features=DialMediaRouteProvider"]:void 0}),l=await(await i.newContext({viewport:o==="mobile"?{width:390,height:844}:o==="tablet"?{width:820,height:1180}:{width:1280,height:720}})).newPage(),d=e.startsWith("http")?e:`https://${e}`;await l.goto(d,{waitUntil:"domcontentloaded",timeout:3e4});let f=await pe(l),c=await de(l,{wcagTags:n,includeAxe:t.includeAxe??!0,dismissModals:!0,deep:t.deep,deepApiUrl:t.deep?"https://api.webability.io":void 0,deepApiKey:t.deep?t.apiKey:void 0});return t.show&&c.issues.length>0?(await l.evaluate(be(c.issues,t.apiKey,f.framework)),await l.evaluate(()=>window.scrollTo(0,0)),{...c,framework:f.framework,_browser:i}):(await i.close(),{...c,framework:f.framework})}async function _(e){e._browser&&(await e._browser.close(),delete e._browser)}import{scan as ye,detectFramework as xe}from"@webability/core";var X={A:["wcag2a"],AA:["wcag2a","wcag2aa","wcag21aa","wcag22aa"],AAA:["wcag2a","wcag2aa","wcag2aaa","wcag21aa","wcag22aa"]};async function Q(e,t={}){let n=X[(t.wcag||"AA").toUpperCase()]??X.AA,o=e.startsWith("http")?e:`https://${e}`,r=Date.now(),s=await(await import("playwright")).chromium.launch({headless:!1}),d=await(await s.newContext({viewport:{width:1280,height:720}})).newPage(),f=[],c="plain-css",g=!1,b=!1,x=new Set,q=async()=>{if(g){b=!0;return}g=!0;try{await d.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await d.waitForTimeout(800);let u=d.url();if(x.has(u)){g=!1;return}x.add(u),(!c||c==="plain-css")&&(c=(await xe(d).catch(()=>({framework:"plain-css"}))).framework);let y=await ye(d,{wcagTags:n,includeAxe:!0,dismissModals:!1});f.push({url:u,issues:y.issues,scannedAt:new Date().toISOString()}),t.onPageScan?.(u,y.issues.length)}catch{}finally{g=!1,b&&(b=!1,setTimeout(q,100))}};d.on("framenavigated",u=>{u===d.mainFrame()&&setTimeout(q,600)}),await d.goto(o,{waitUntil:"domcontentloaded",timeout:3e4}),await new Promise(u=>{s.on("disconnected",()=>u()),process.once("SIGINT",()=>u())}),await s.close().catch(()=>{});let P=new Map;for(let u of f)for(let y of u.issues){let C=`${y.type}::${y.selector}::${y.wcag}`,w=P.get(C);w?w.foundOn.includes(u.url)||(w.foundOn.push(u.url),w.pageCount=w.foundOn.length):P.set(C,{...y,foundOn:[u.url],pageCount:1})}return{pages:f,uniqueIssues:Array.from(P.values()).sort((u,y)=>{let C={critical:0,serious:1,moderate:2,minor:3},w=C[u.impact]??2,V=C[y.impact]??2;return w!==V?w-V:y.pageCount-u.pageCount}),framework:c,totalDuration:Date.now()-r}}import{writeFileSync as we,existsSync as ve}from"fs";import M from"chalk";var ke=`project: my-project
700
+ `}async function le(e,t){let o=re[t.wcag.toUpperCase()]??re.AA,s=["mobile","tablet","desktop"].includes(t.viewport??"")?t.viewport:"desktop",n=await(await import("playwright")).chromium.launch({headless:!t.show,ignoreDefaultArgs:t.show?["--enable-automation"]:void 0,args:t.show?["--disable-blink-features=AutomationControlled","--no-default-browser-check","--disable-infobars","--no-first-run","--silent-launch","--disable-features=DialMediaRouteProvider"]:void 0}),l=await(await n.newContext({viewport:s==="mobile"?{width:390,height:844}:s==="tablet"?{width:820,height:1180}:{width:1280,height:720}})).newPage(),d=e.startsWith("http")?e:`https://${e}`;await l.goto(d,{waitUntil:"domcontentloaded",timeout:3e4});let u=await Be(l),f=await Re(l,{wcagTags:o,includeAxe:t.includeAxe??!0,dismissModals:!0,deep:t.deep,deepApiUrl:t.deep?"https://api.webability.io":void 0,deepApiKey:t.deep?t.apiKey:void 0});return t.show&&f.issues.length>0?(await l.evaluate(Oe(f.issues,t.apiKey,u.framework)),await l.evaluate(()=>window.scrollTo(0,0)),{...f,framework:u.framework,_browser:n}):(await n.close(),{...f,framework:u.framework})}async function V(e){e._browser&&(await e._browser.close(),delete e._browser)}import{scan as _e,detectFramework as ze}from"@webability/core";var ce={A:["wcag2a"],AA:["wcag2a","wcag2aa","wcag21aa","wcag22aa"],AAA:["wcag2a","wcag2aa","wcag2aaa","wcag21aa","wcag22aa"]};async function de(e,t={}){let o=ce[(t.wcag||"AA").toUpperCase()]??ce.AA,s=e.startsWith("http")?e:`https://${e}`,a=Date.now(),r=await(await import("playwright")).chromium.launch({headless:!1}),d=await(await r.newContext({viewport:{width:1280,height:720}})).newPage(),u=[],f="plain-css",c=!1,v=!1,x=new Set,S=async()=>{if(c){v=!0;return}c=!0;try{await d.waitForLoadState("domcontentloaded",{timeout:5e3}).catch(()=>{}),await d.waitForTimeout(800);let g=d.url();if(x.has(g)){c=!1;return}x.add(g),(!f||f==="plain-css")&&(f=(await ze(d).catch(()=>({framework:"plain-css"}))).framework);let w=await _e(d,{wcagTags:o,includeAxe:!0,dismissModals:!1});u.push({url:g,issues:w.issues,scannedAt:new Date().toISOString()}),t.onPageScan?.(g,w.issues.length)}catch{}finally{c=!1,v&&(v=!1,setTimeout(S,100))}};d.on("framenavigated",g=>{g===d.mainFrame()&&setTimeout(S,600)}),await d.goto(s,{waitUntil:"domcontentloaded",timeout:3e4}),await new Promise(g=>{r.on("disconnected",()=>g()),process.once("SIGINT",()=>g())}),await r.close().catch(()=>{});let z=new Map;for(let g of u)for(let w of g.issues){let $=`${w.type}::${w.selector}::${w.wcag}`,C=z.get($);C?C.foundOn.includes(g.url)||(C.foundOn.push(g.url),C.pageCount=C.foundOn.length):z.set($,{...w,foundOn:[g.url],pageCount:1})}return{pages:u,uniqueIssues:Array.from(z.values()).sort((g,w)=>{let $={critical:0,serious:1,moderate:2,minor:3},C=$[g.impact]??2,oe=$[w.impact]??2;return C!==oe?C-oe:w.pageCount-g.pageCount}),framework:f,totalDuration:Date.now()-a}}import{writeFileSync as je,existsSync as We}from"fs";import U from"chalk";var qe=`project: my-project
701
701
  urls:
702
702
  - http://localhost:3000
703
703
  standard: WCAG2.1AA
@@ -706,4 +706,8 @@ ignore: []
706
706
  threshold:
707
707
  critical: 0
708
708
  serious: 5
709
- `;function Z(){let e=".webability.yml";if(ve(e)){console.log(M.yellow(` ${e} already exists`));return}we(e,ke),console.log(M.green(` Created ${e}`)),console.log(M.dim(" Edit it to configure your project URLs and thresholds"))}import v from"chalk";var p=v.dim,ee=v.bold,z=v.blue,B=v.green,F=v.red,A=v.yellow,$=v.cyan,Ae=v.white;function m(){console.log(),console.log(` ${z("\u25C6")} ${ee("Abilyo")} ${p("WCAG Scanner")}`),console.log()}function j(e,t){let n=e>=80?B:e>=50?A:F,o=e>=80?B("\u2713"):e>=50?A("\u26A0"):F("\u2717"),r=e>=80?"Passing":e>=50?"Needs work":"Failing";console.log(` ${p("URL")} ${Ae(t)}`),console.log(` ${p("Score")} ${n.bold(e+"%")} ${o} ${p(r)}`),console.log(` ${p(" ")}${Ce(e)}`),console.log()}function Ce(e){let n=Math.round(e/100*32),o=32-n;return(e>=80?B:e>=50?A:F)("\u2501".repeat(n))+p("\u2501".repeat(o))}function N(e){let t=[];e.critical>0&&t.push(F.bold(`${e.critical} critical`)),e.serious>0&&t.push(A(`${e.serious} serious`)),e.moderate>0&&t.push(p(`${e.moderate} moderate`)),e.minor>0&&t.push(p(`${e.minor} minor`)),console.log(` ${ee(String(e.total))} issues ${t.join(p(" \xB7 "))}`),console.log()}function R(e){let t=e.severity==="critical"?F("\u2717"):e.severity==="serious"?A("\u25B2"):p("\u25CF"),n=p(`${e.wcag}`),o=e.count&&e.count>1?p(` \xD7${e.count}`):"";if(console.log(` ${t} ${n}${o} ${e.problem.slice(0,72)}`),e.contrast?(console.log(` ${$("fix")} ${e.fix.slice(0,70)}`),console.log(` ${p(`${e.contrast.current}:1 \u2192 ${e.contrast.suggested}:1 (min ${e.contrast.required}:1)`)}`)):e.before&&e.after?console.log(` ${$("fix")} ${p(e.before)} ${p("\u2192")} ${B(e.after)}`):console.log(` ${$("fix")} ${e.fix.slice(0,70)}`),e.html&&e.count===1){let r=e.html.slice(0,60).replace(/\n/g," ");console.log(` ${p(r)}`)}if(e.selectors&&e.selectors.length>0&&e.count&&e.count>1){let r=e.selectors.slice(0,2).map(s=>s.slice(0,30)).join(p(", ")),i=e.count>2?p(` +${e.count-2} more`):"";console.log(` ${p(r+i)}`)}else e.selector&&console.log(` ${p(e.selector.slice(0,55))}`);console.log()}function te(e){if(e.length){for(let t of e)console.log(` ${A.bold("\u26A0 WARNING")} ${A(t)}`);console.log()}}function L(e){console.log(p(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),e?.hasIssues&&(console.log(` ${p("Next steps:")}`),console.log(` ${$("abilyo scan "+(e.url||"<url>")+" --format json")} ${p("CI/CD output")}`),console.log(` ${$("abilyo scan "+(e.url||"<url>")+" --format html > report.html")} ${p("share report")}`),console.log()),console.log(` ${z("\u25C6")} ${p("Auto-fix at")} ${z("abilyo.com")}`),console.log()}function k(e){console.log(F(` \u2717 Error: ${e}`)),console.log()}function oe(e){console.log(JSON.stringify(e,null,2))}function W(e){console.log("severity,wcag,message,element");for(let t of e){let n=t.message.replace(/"/g,'""'),o=(t.element||"").replace(/"/g,'""');console.log(`${t.severity},${t.wcag},"${n}","${o}"`)}}var Be=Ee(Se(import.meta.url)),ie=JSON.parse(Fe($e(Be,"../package.json"),"utf-8")),h=new Ie;h.name("abilyo").description("Abilyo by WebAbility \u2014 WCAG accessibility scanner").version(ie.version);h.command("scan <url>").description("Scan a website for accessibility issues").option("-f, --format <format>","Output format: table, json, csv, sarif, html","table").option("--wcag <level>","WCAG level: A, AA, AAA","AA").option("--deep","Run a deeper scan with additional checks (Pro plan)").option("--remote","Run scan on WebAbility servers instead of locally").option("--exit","Exit with code 1 if issues found (CI mode)").option("--no-axe","Skip axe-core (use only WebAbility detectors)").option("--viewport <size>","Viewport: mobile, tablet, desktop","desktop").option("--show","Open browser and highlight issues visually").action(async(e,t)=>{if(e.startsWith("http")||(e=`https://${e}`),t.deep){let i=E();if(!i)return t.format==="table"&&m(),k("--deep requires a Pro plan. Run `abilyo login` first."),process.exit(1);try{let s=await fetch("https://api.webability.io/cli/verify",{headers:{Authorization:`Bearer ${i}`}});if(s.ok){if(!(await s.json()).active)return t.format==="table"&&m(),k("Your account does not have an active Pro plan."),console.log(a.dim(" Upgrade at https://abilyo.com/pricing")),process.exit(1)}else{if(s.status===401||s.status===403)return t.format==="table"&&m(),k("Your API key is invalid or expired. Run `abilyo login` again."),process.exit(1);console.error(a.yellow(` \u26A0 Could not verify your Pro plan (server returned ${s.status}). Continuing, but --deep may be rejected.`))}}catch{console.error(a.yellow(" \u26A0 Could not verify Pro plan status (offline). --deep analysis will be skipped without a network connection."))}}if(t.remote){await Ne(e,t);return}t.format==="table"&&m();let n=Date.now(),o=I({text:"Scanning...",prefixText:" "}).start(),r;try{r=await Y(e,{wcag:t.wcag,deep:t.deep??!1,apiKey:E()??void 0,show:t.show??!1,viewport:t.viewport,includeAxe:t.axe!==!1});let i=((Date.now()-n)/1e3).toFixed(1);if(o.succeed(`Scanned ${r.issues.length} issues in ${i}s`),t.format==="json"){let s={...r,issues:r.issues.map(({source:l,...d})=>d)};console.log(JSON.stringify(s,null,2))}else if(t.format==="csv")W(r.issues.map(s=>({severity:s.impact,wcag:s.wcag,message:s.message,element:s.selector})));else if(t.format==="sarif")console.log(JSON.stringify(Re(r),null,2));else if(t.format==="html"){let{toHtmlReport:s}=await import("@webability/core");console.log(s(r))}else{if(te(r.engineWarnings??[]),j(r.summary.total===0?100:Math.max(0,100-r.summary.total),e),N(r.summary),r.issues.length>0){let{generateDevSuggestion:s}=await import("@webability/core"),l=r.framework||"plain-css",d=[],f=new Map;for(let c of r.issues){let g=s(c,l),b=`${c.type}|${g.fix.slice(0,50)}`,x=f.get(b);x!==void 0?(d[x].count++,d[x].selectors.length<3&&d[x].selectors.push(c.selector.slice(0,50))):(f.set(b,d.length),d.push({suggestion:g,issue:c,count:1,selectors:[c.selector.slice(0,50)]}))}d.sort((c,g)=>{let b={critical:0,serious:1,moderate:2,minor:3};return(b[c.issue.impact]??2)-(b[g.issue.impact]??2)});for(let c of d.slice(0,20))R({severity:c.issue.impact,wcag:c.issue.wcag,problem:c.suggestion.problem,fix:c.suggestion.fix,count:c.count,selector:c.count===1?c.issue.selector:void 0,selectors:c.count>1?c.selectors:void 0,contrast:c.suggestion.contrast,before:c.suggestion.before,after:c.suggestion.after,html:c.issue.html});d.length>20&&(console.log(a.dim(` ... +${d.length-20} more`)),console.log())}L({hasIssues:r.issues.length>0,url:e.replace("https://","")})}t.show&&r.issues.length>0&&(console.log(a.cyan(" \u25C6 Browser open \u2014 issues highlighted. Press Enter to close.")),console.log(),await new Promise(s=>{process.stdin.resume(),process.stdin.once("data",()=>{process.stdin.pause(),s()})}),await _(r)),t.exit&&r.summary.total>0&&process.exit(1)}catch(i){o.stop(),r&&await _(r).catch(()=>{}),k(i.message),process.exit(1)}});async function Ne(e,t){let n=E();if(!n)return t.format==="table"&&m(),k("--remote requires login. Run `wa login` first."),process.exit(1);t.format==="table"&&m();let o=I({text:"Scanning (remote)...",prefixText:" "}).start();try{let r=await K(e,n,l=>{o.text=l});o.text="Fetching report...";let i=await U(r.key,n);if(o.stop(),!i)return k("Report not found"),process.exit(1);let s=[];if(i.axe?.violations)for(let l of i.axe.violations)for(let d of l.nodes||[])s.push({severity:l.impact||"moderate",wcag:l.id,message:l.description,element:d.target?.[0]});if(i.ByFunctions)for(let l of i.ByFunctions)for(let d of l.issues||[])s.push({severity:d.impact||"moderate",wcag:d.code||"",message:d.description||"",element:d.element});if(t.format==="json")oe({url:e,score:i.score,totalElements:i.totalElements,issues:s});else if(t.format==="csv")W(s);else{j(i.score||0,e),N({critical:0,serious:s.filter(l=>l.severity==="serious").length,moderate:s.filter(l=>l.severity==="moderate").length,minor:0,total:s.length});for(let l of s.slice(0,20))R({severity:l.severity,wcag:l.wcag,problem:l.message,fix:"Review this issue",selector:l.element});L()}t.exit&&s.length>0&&process.exit(1)}catch(r){o.stop(),k(r.message),process.exit(1)}}h.command("flow <url>").description("Scan a multi-page user journey \u2014 one consolidated report").option("--wcag <level>","WCAG level: A, AA, AAA","AA").action(async(e,t)=>{e.startsWith("http")||(e=`https://${e}`),m(),console.log(a.bold(" Flow Scan")),console.log(),console.log(` Starting at: ${a.cyan(e)}`),console.log(a.dim(" Click through your user journey. Close the browser when done.")),console.log();let n=0,o=await Q(e,{wcag:t.wcag,onPageScan:(s,l)=>{n++,console.log(` ${a.green("\u2713")} ${a.dim(String(n).padStart(2))} ${s.replace(/^https?:\/\//,"").slice(0,60)} ${a.dim("\u2014 "+l+" issues")}`)}});console.log(),console.log(a.bold(" \u2500\u2500\u2500 Flow Report \u2500\u2500\u2500")),console.log(),console.log(` Pages scanned: ${a.cyan(o.pages.length)}`),console.log(` Unique issues: ${a.cyan(o.uniqueIssues.length)}`),console.log(` Total duration: ${a.dim((o.totalDuration/1e3).toFixed(1)+"s")}`),console.log();let r={critical:0,serious:0,moderate:0,minor:0};o.uniqueIssues.forEach(s=>{r[s.impact]++}),N({...r,total:o.uniqueIssues.length});let i=o.uniqueIssues.slice(0,15);for(let s of i){let l=s.pageCount>1?a.yellow(` \xD7${s.pageCount} pages`):"";if(R({severity:s.impact,wcag:s.wcag,problem:s.message,fix:s.fix?.suggestedValue?`Set ${s.fix.attribute}="${s.fix.suggestedValue}"`:"Review this issue",selector:s.selector}),s.pageCount>1){console.log(a.dim(` Found on${l}:`));for(let d of s.foundOn.slice(0,3))console.log(a.dim(" "+d.replace(/^https?:\/\//,"")))}}o.uniqueIssues.length>15&&console.log(a.dim(` ... +${o.uniqueIssues.length-15} more unique issues`)),console.log(),L({hasIssues:o.uniqueIssues.length>0,url:e.replace("https://","")})});h.command("init").description("Create .webability.yml config file").action(()=>{m(),Z(),console.log()});h.command("login").description("Authenticate with your WebAbility account").option("-k, --key <key>","API key directly (for CI/CD)").action(async e=>{if(m(),e.key){T(e.key),console.log(a.green(" \u2713 API key saved.")),console.log();return}let t=I({text:"Starting login...",prefixText:" "}).start();try{let n=await fetch("https://api.webability.io/cli/device-code",{method:"POST",headers:{"Content-Type":"application/json"}});if(!n.ok){t.stop();let c="https://app.webability.io/settings/api-keys";console.log(" Open this URL to get your API key:"),console.log(),console.log(` ${a.cyan(c)}`),console.log(),console.log(` Then run: ${a.cyan("abilyo login --key YOUR_KEY")}`),console.log(),se(c);return}let{deviceCode:o,userCode:r,verificationUrl:i,expiresIn:s}=await n.json();t.stop(),console.log(` ${a.bold("Login to WebAbility")}`),console.log(),console.log(` Open: ${a.cyan(i)}`),console.log(` Code: ${a.bold.yellow(r)}`),console.log(),se(i);let l=I({text:"Waiting for approval...",prefixText:" "}).start(),d=3e3,f=Math.floor((s||300)*1e3/d);for(let c=0;c<f;c++){await new Promise(g=>setTimeout(g,d));try{let g=await fetch("https://api.webability.io/cli/device-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:o})});if(g.ok){let{token:x}=await g.json();T(x),l.succeed("Logged in!"),console.log();return}if((await g.json().catch(()=>({}))).error==="expired")return l.fail("Login expired. Run `abilyo login` again."),process.exit(1)}catch{}}l.fail("Login timed out."),process.exit(1)}catch{t.stop(),console.log(` Open: ${a.cyan("https://app.webability.io/settings/api-keys")}`),console.log(` Then: ${a.cyan("abilyo login --key YOUR_KEY")}`),console.log()}});function se(e){try{let{execFile:t}=ae("child_process"),n=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";t(n,[e],()=>{})}catch{}}h.command("whoami").description("Show current authentication status").action(()=>{let e=E();m(),e?(console.log(a.green(" Authenticated")),console.log(a.dim(` Key: ${e.slice(0,20)}...`))):(console.log(a.yellow(" Not authenticated")),console.log(a.dim(" Run `wa login` to authenticate"))),console.log()});h.command("logout").description("Remove saved API key").action(()=>{J(),m(),console.log(a.green(" Logged out. API key removed.")),console.log()});h.command("activate <code>").description("Activate Abilyo with your early access code").action(async e=>{m();let t=I({text:"Validating access code...",prefixText:" "}).start();try{if((await fetch("https://api.webability.io/cli/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e.trim()})})).ok){O(e.trim()),t.succeed("Abilyo activated!"),console.log(),console.log(a.dim(" Run `abilyo scan <url>` to get started")),console.log();return}}catch{}e.trim().length>=8?(O(e.trim()),t.succeed("Abilyo activated!"),console.log(),console.log(a.dim(" Run `abilyo scan <url>` to get started")),console.log()):(t.fail("Invalid access code"),console.log(a.dim(" Request access at https://abilyo.com/early-access")),process.exit(1))});h.argument("[url]","URL to scan").action(e=>{e?h.parse(["node","abilyo","scan",e,...process.argv.slice(3)]):(m(),G()?(console.log(a.bold(" Commands:")),console.log(),console.log(` ${a.cyan("abilyo scan")} <url> Scan for accessibility issues`),console.log(` ${a.cyan("abilyo scan --deep")} <url> Deeper scan with additional checks (Pro)`),console.log(` ${a.cyan("abilyo scan --exit")} <url> CI mode \u2014 exit 1 if issues found`),console.log(` ${a.cyan("abilyo init")} Create .webability.yml config`),console.log(` ${a.cyan("abilyo login")} Authenticate with your account`),console.log(` ${a.cyan("abilyo whoami")} Show auth status`),console.log(),console.log(a.dim(" Example: abilyo scan localhost:3000")),console.log(a.dim(" Example: abilyo scan example.com --format json")),console.log(a.dim(" Example: abilyo scan example.com --deep --exit"))):(console.log(a.yellow(" Abilyo is invite-only during early access.")),console.log(),console.log(` ${a.cyan("abilyo activate")} <code> Activate with your access code`),console.log(),console.log(a.dim(" Request access at https://abilyo.com/early-access"))),console.log())});h.parse();function Re(e){let t=new Map;for(let o of e.issues)t.has(o.type)||t.set(o.type,{id:o.type,shortDescription:{text:o.message}});let n=e.engineWarnings??[];return{$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{...n.length?{invocations:[{executionSuccessful:!0,toolExecutionNotifications:n.map(o=>({level:"warning",message:{text:o}}))}]}:{},tool:{driver:{name:"WebAbility",version:ie.version,informationUri:"https://webability.io",rules:Array.from(t.values())}},results:e.issues.map(o=>{let i={startLine:Number.isInteger(o.line)&&o.line>0?o.line:1,snippet:{text:o.html||o.selector}};return Number.isInteger(o.column)&&o.column>0&&(i.startColumn=o.column),{ruleId:o.type,level:o.impact==="critical"||o.impact==="serious"?"error":"warning",message:{text:o.message},locations:[{physicalLocation:{artifactLocation:{uri:e.url},region:i}}]}})}]}}
709
+ `;function pe(){let e=".webability.yml";if(We(e)){console.log(U.yellow(` ${e} already exists`));return}je(e,qe),console.log(U.green(` Created ${e}`)),console.log(U.dim(" Edit it to configure your project URLs and thresholds"))}import{execFileSync as B}from"child_process";import{chmodSync as me,existsSync as K,mkdirSync as Ve,readFileSync as fe,writeFileSync as he}from"fs";import{homedir as G}from"os";import{dirname as Ue,join as J}from"path";var h="webability",E="https://mcp.webability.io/mcp",ye="x-webability-token";function H(e){return{url:E,headers:{[ye]:e}}}function Y(){let e=process.platform==="win32"?["claude.cmd","claude"]:["claude"];for(let t of e)try{return B(t,["--version"],{stdio:"ignore"}),t}catch{}return null}function Ke(){return Y()!==null}function be(e){try{return B(e,["mcp","get",h],{encoding:"utf-8",stdio:["ignore","pipe","ignore"]})}catch{return null}}function Ge(){return K(J(G(),".cursor"))}function ue(e){let t=Y();if(!t)return{client:"claude",ok:!1,detail:"Claude Code CLI not found on PATH"};try{let o=be(t);if(o!==null&&!o.includes(E))return{client:"claude",ok:!1,detail:`Claude Code already has an MCP server named "${h}" that isn't ours \u2014 left untouched. Remove it (claude mcp remove -s user ${h}) and re-run \`abilyo mcp install\` to switch to the hosted server.`};if(o!==null)try{B(t,["mcp","remove","-s","user",h],{stdio:"ignore"})}catch{}return B(t,["mcp","add","-s","user","--transport","http",h,E,"--header",`${ye}: ${e}`],{stdio:"ignore"}),{client:"claude",ok:!0,detail:"Claude Code"}}catch(o){return{client:"claude",ok:!1,detail:`claude mcp add failed: ${o.message}`}}}function ge(e){let t=J(G(),".cursor","mcp.json");try{let o={};if(K(t)){let a=fe(t,"utf-8").trim();a&&(o=JSON.parse(a))}let s=(o.mcpServers||{})[h];return s&&s.url!==E?{client:"cursor",ok:!1,detail:`~/.cursor/mcp.json already has an MCP server named "${h}" that isn't ours \u2014 left untouched. Remove that entry and re-run \`abilyo mcp install\` to switch to the hosted server.`}:(o.mcpServers={...o.mcpServers||{},[h]:H(e)},Ve(Ue(t),{recursive:!0}),he(t,`${JSON.stringify(o,null,2)}
710
+ `,{mode:384}),me(t,384),{client:"cursor",ok:!0,detail:"Cursor (~/.cursor/mcp.json)"})}catch(o){return{client:"cursor",ok:!1,detail:`could not write ${t}: ${o.message}`}}}function xe(){let e=[],t=Y();if(t){let s=be(t);if(s!==null)if(!s.includes(E))e.push({client:"claude",ok:!1,detail:`left "${h}" in Claude Code alone \u2014 it isn't ours`});else try{B(t,["mcp","remove","-s","user",h],{stdio:"ignore"}),e.push({client:"claude",ok:!0,detail:"Claude Code"})}catch(a){e.push({client:"claude",ok:!1,detail:`claude mcp remove failed: ${a.message}`})}}let o=J(G(),".cursor","mcp.json");if(K(o))try{let s=fe(o,"utf-8").trim(),a=s?JSON.parse(s):{},n=a.mcpServers?.[h];n&&n.url===E?(delete a.mcpServers[h],he(o,`${JSON.stringify(a,null,2)}
711
+ `,{mode:384}),me(o,384),e.push({client:"cursor",ok:!0,detail:"Cursor (~/.cursor/mcp.json)"})):n&&e.push({client:"cursor",ok:!1,detail:`left "${h}" in ~/.cursor/mcp.json alone \u2014 it isn't ours`})}catch(s){e.push({client:"cursor",ok:!1,detail:`could not update ${o}: ${s.message}`})}return e}function M(e,t){if(t==="claude")return[ue(e)];if(t==="cursor")return[ge(e)];let o=[];return Ke()&&o.push(ue(e)),Ge()&&o.push(ge(e)),o}import A from"chalk";var p=A.dim,we=A.bold,X=A.blue,L=A.green,I=A.red,F=A.yellow,P=A.cyan,Je=A.white;function m(){console.log(),console.log(` ${X("\u25C6")} ${we("Abilyo")} ${p("WCAG Scanner")}`),console.log()}function Q(e,t){let o=e>=80?L:e>=50?F:I,s=e>=80?L("\u2713"):e>=50?F("\u26A0"):I("\u2717"),a=e>=80?"Passing":e>=50?"Needs work":"Failing";console.log(` ${p("URL")} ${Je(t)}`),console.log(` ${p("Score")} ${o.bold(e+"%")} ${s} ${p(a)}`),console.log(` ${p(" ")}${He(e)}`),console.log()}function He(e){let o=Math.round(e/100*32),s=32-o;return(e>=80?L:e>=50?F:I)("\u2501".repeat(o))+p("\u2501".repeat(s))}function T(e){let t=[];e.critical>0&&t.push(I.bold(`${e.critical} critical`)),e.serious>0&&t.push(F(`${e.serious} serious`)),e.moderate>0&&t.push(p(`${e.moderate} moderate`)),e.minor>0&&t.push(p(`${e.minor} minor`)),console.log(` ${we(String(e.total))} issues ${t.join(p(" \xB7 "))}`),console.log()}function D(e){let t=e.severity==="critical"?I("\u2717"):e.severity==="serious"?F("\u25B2"):p("\u25CF"),o=p(`${e.wcag}`),s=e.count&&e.count>1?` \xD7${e.count}`:"",a=s?p(s):"",n=80-(6+e.wcag.length+s.length);if(console.log(` ${t} ${o}${a} ${e.problem.slice(0,n)}`),e.contrast?(console.log(` ${P("fix")} ${e.fix.slice(0,70)}`),console.log(` ${p(`${e.contrast.current}:1 \u2192 ${e.contrast.suggested}:1 (min ${e.contrast.required}:1)`)}`)):e.before&&e.after?console.log(` ${P("fix")} ${p(e.before)} ${p("\u2192")} ${L(e.after)}`):console.log(` ${P("fix")} ${e.fix.slice(0,70)}`),e.html&&e.count===1){let r=e.html.slice(0,60).replace(/\n/g," ");console.log(` ${p(r)}`)}if(e.selectors&&e.selectors.length>0&&e.count&&e.count>1){let r=e.selectors.slice(0,2).map(d=>d.slice(0,30)).join(p(", ")),l=e.count>2?p(` +${e.count-2} more`):"";console.log(` ${p(r+l)}`)}else e.selector&&console.log(` ${p(e.selector.slice(0,55))}`);console.log()}function ve(e){if(e.length){for(let t of e)console.log(` ${F.bold("\u26A0 WARNING")} ${F(t)}`);console.log()}}function O(e){console.log(p(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),e?.hasIssues&&(console.log(` ${p("Next steps:")}`),console.log(` ${P("abilyo scan "+(e.url||"<url>")+" --format json")} ${p("CI/CD output")}`),console.log(` ${P("abilyo scan "+(e.url||"<url>")+" --format html > report.html")} ${p("share report")}`),console.log()),console.log(` ${X("\u25C6")} ${p("Auto-fix at")} ${X("abilyo.com")}`),console.log()}function y(e,t){console.error(I(` \u2717 Error: ${e}`)),t&&console.error(p(` ${t}`)),console.error()}function ke(e){console.log(JSON.stringify(e,null,2))}function Z(e){console.log("severity,wcag,message,element");for(let t of e){let o=t.message.replace(/"/g,'""'),s=(t.element||"").replace(/"/g,'""');console.log(`${t.severity},${t.wcag},"${o}","${s}"`)}}var tt=Qe(Xe(import.meta.url)),Ce=JSON.parse(Ye(Ze(tt,"../package.json"),"utf-8")),b=new et;b.name("abilyo").description("Abilyo by WebAbility \u2014 WCAG accessibility scanner").version(Ce.version);b.command("scan <url>").description("Scan a website for accessibility issues").option("-f, --format <format>","Output format: table, json, csv, sarif, html","table").option("--wcag <level>","WCAG level: A, AA, AAA","AA").option("--deep","Run a deeper scan with additional checks (Pro plan)").option("--remote","Run scan on WebAbility servers instead of locally").option("--exit","Exit with code 1 if issues found (CI mode)").option("--no-axe","Skip axe-core (use only WebAbility detectors)").option("--viewport <size>","Viewport: mobile, tablet, desktop","desktop").option("--show","Open browser and highlight issues visually").action(async(e,t)=>{if(e.startsWith("http")||(e=`https://${e}`),t.deep){let n=k();if(!n)return t.format==="table"&&m(),y("--deep needs Abilyo Pro. Run `abilyo login`, then `abilyo upgrade`."),process.exit(1);try{let r=await fetch("https://api.webability.io/cli/verify",{headers:{Authorization:`Bearer ${n}`}});if(r.ok){if(!(await r.json()).active)return t.format==="table"&&m(),y("--deep needs Abilyo Pro."),console.log(` Unlock it now: ${i.cyan("abilyo upgrade")}`),console.log(i.dim(" Pro adds dynamic-content checks, keyboard-trap detection and AI fixes.")),process.exit(1)}else{if(r.status===401||r.status===403)return t.format==="table"&&m(),y("Your API key is invalid or expired. Run `abilyo login` again."),process.exit(1);console.error(i.yellow(` \u26A0 Could not verify your Pro plan (server returned ${r.status}). Continuing, but --deep may be rejected.`))}}catch{console.error(i.yellow(" \u26A0 Could not verify Pro plan status (offline). --deep analysis will be skipped without a network connection."))}}if(t.remote){await ot(e,t);return}t.format==="table"&&m();let o=Date.now(),s=N({text:"Scanning...",prefixText:" "}).start(),a;try{a=await le(e,{wcag:t.wcag,deep:t.deep??!1,apiKey:k()??void 0,show:t.show??!1,viewport:t.viewport,includeAxe:t.axe!==!1});let n=((Date.now()-o)/1e3).toFixed(1),r=a.issues.length;if(s.succeed(r===0?`No issues found in ${n}s`:`Found ${r} issue${r===1?"":"s"} in ${n}s`),t.format==="json"){let l={...a,issues:a.issues.map(({source:d,...u})=>u)};console.log(JSON.stringify(l,null,2))}else if(t.format==="csv")Z(a.issues.map(l=>({severity:l.impact,wcag:l.wcag,message:l.message,element:l.selector})));else if(t.format==="sarif")console.log(JSON.stringify(it(a),null,2));else if(t.format==="html"){let{toHtmlReport:l}=await import("@webability/core");console.log(l(a))}else{if(ve(a.engineWarnings??[]),Q(a.summary.total===0?100:Math.max(0,100-a.summary.total),e),T(a.summary),a.issues.length>0){let{generateDevSuggestion:l}=await import("@webability/core"),d=a.framework||"plain-css",u=[],f=new Map;for(let c of a.issues){let v=l(c,d),x=`${c.type}|${v.fix.slice(0,50)}`,S=f.get(x);S!==void 0?(u[S].count++,u[S].selectors.length<3&&u[S].selectors.push(c.selector.slice(0,50))):(f.set(x,u.length),u.push({suggestion:v,issue:c,count:1,selectors:[c.selector.slice(0,50)]}))}u.sort((c,v)=>{let x={critical:0,serious:1,moderate:2,minor:3};return(x[c.issue.impact]??2)-(x[v.issue.impact]??2)});for(let c of u.slice(0,20))D({severity:c.issue.impact,wcag:c.issue.wcag,problem:c.suggestion.problem,fix:c.suggestion.fix,count:c.count,selector:c.count===1?c.issue.selector:void 0,selectors:c.count>1?c.selectors:void 0,contrast:c.suggestion.contrast,before:c.suggestion.before,after:c.suggestion.after,html:c.issue.html});u.length>20&&(console.log(i.dim(` ... +${u.length-20} more`)),console.log())}O({hasIssues:a.issues.length>0,url:e.replace("https://","")})}t.show&&a.issues.length>0&&(console.log(i.cyan(" \u25C6 Browser open \u2014 issues highlighted. Press Enter to close.")),console.log(),await new Promise(l=>{process.stdin.resume(),process.stdin.once("data",()=>{process.stdin.pause(),l()})}),await V(a)),t.exit&&a.summary.total>0&&process.exit(1)}catch(n){s.stop(),a&&await V(a).catch(()=>{}),y(n.message.split(`
712
+ `)[0],"Check the URL loads in a browser, then run the scan again."),process.exit(1)}});async function ot(e,t){let o=k();if(!o)return t.format==="table"&&m(),y("--remote requires login. Run `abilyo login` first."),process.exit(1);t.format==="table"&&m();let s=N({text:"Scanning (remote)...",prefixText:" "}).start();try{let a=await se(e,o,l=>{s.text=l});s.text="Fetching report...";let n=await ie(a.key,o);if(s.stop(),!n)return y("Report not found.","Try again, or drop --remote to scan locally."),process.exit(1);let r=[];if(n.axe?.violations)for(let l of n.axe.violations)for(let d of l.nodes||[])r.push({severity:l.impact||"moderate",wcag:l.id,message:l.description,element:d.target?.[0]});if(n.ByFunctions)for(let l of n.ByFunctions)for(let d of l.issues||[])r.push({severity:d.impact||"moderate",wcag:d.code||"",message:d.description||"",element:d.element});if(t.format==="json")ke({url:e,score:n.score,totalElements:n.totalElements,issues:r});else if(t.format==="csv")Z(r);else{Q(n.score||0,e),T({critical:0,serious:r.filter(l=>l.severity==="serious").length,moderate:r.filter(l=>l.severity==="moderate").length,minor:0,total:r.length});for(let l of r.slice(0,20))D({severity:l.severity,wcag:l.wcag,problem:l.message,fix:"Review this issue",selector:l.element});O()}t.exit&&r.length>0&&process.exit(1)}catch(a){s.stop(),y(a.message),process.exit(1)}}b.command("flow <url>").description("Scan a multi-page user journey \u2014 one consolidated report").option("--wcag <level>","WCAG level: A, AA, AAA","AA").action(async(e,t)=>{e.startsWith("http")||(e=`https://${e}`),m(),console.log(i.bold(" Flow Scan")),console.log(),console.log(` Starting at: ${i.cyan(e)}`),console.log(i.dim(" Click through your user journey. Close the browser when done.")),console.log();let o=0,s;try{s=await de(e,{wcag:t.wcag,onPageScan:(r,l)=>{o++,console.log(` ${i.green("\u2713")} ${i.dim(String(o).padStart(2))} ${r.replace(/^https?:\/\//,"").slice(0,60)} ${i.dim("\u2014 "+l+" issues")}`)}})}catch(r){return y(r.message.split(`
713
+ `)[0],"Check the URL loads in a browser, then run `abilyo flow` again."),process.exit(1)}console.log(),console.log(i.bold(" \u2500\u2500\u2500 Flow Report \u2500\u2500\u2500")),console.log(),console.log(` Pages scanned: ${i.cyan(s.pages.length)}`),console.log(` Unique issues: ${i.cyan(s.uniqueIssues.length)}`),console.log(` Total duration: ${i.dim((s.totalDuration/1e3).toFixed(1)+"s")}`),console.log();let a={critical:0,serious:0,moderate:0,minor:0};s.uniqueIssues.forEach(r=>{a[r.impact]++}),T({...a,total:s.uniqueIssues.length});let n=s.uniqueIssues.slice(0,15);for(let r of n){let l=r.pageCount>1?i.yellow(` \xD7${r.pageCount} pages`):"";if(D({severity:r.impact,wcag:r.wcag,problem:r.message,fix:r.fix?.suggestedValue?`Set ${r.fix.attribute}="${r.fix.suggestedValue}"`:"Review this issue",selector:r.selector}),r.pageCount>1){console.log(i.dim(` Found on${l}:`));for(let d of r.foundOn.slice(0,3))console.log(i.dim(" "+d.replace(/^https?:\/\//,"")))}}s.uniqueIssues.length>15&&console.log(i.dim(` ... +${s.uniqueIssues.length-15} more unique issues`)),console.log(),O({hasIssues:s.uniqueIssues.length>0,url:e.replace("https://","")})});b.command("init").description("Create .webability.yml config file").action(()=>{m(),pe(),console.log()});b.command("login").description("Authenticate with your WebAbility account").option("-k, --key <key>","API key directly (for CI/CD)").action(async e=>{if(m(),e.key){W(e.key),console.log(i.green(" \u2713 API key saved.")),console.log(),ee(M(e.key)),await te(e.key);return}let t=N({text:"Starting login...",prefixText:" "}).start();try{let o=await fetch("https://api.webability.io/cli/device-code",{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)return t.fail(`Could not start login (server returned ${o.status}).`),console.log(i.dim(" Try again in a moment: `abilyo login`")),console.log(i.dim(" Still stuck? support@webability.io")),console.log(),process.exit(1);let{deviceCode:s,userCode:a,verificationUrl:n,expiresIn:r}=await o.json();t.stop(),console.log(` ${i.bold("Login to WebAbility")}`),console.log(),console.log(` Open: ${i.cyan(n)}`),console.log(` Code: ${i.bold.yellow(a)}`),console.log(),Ae(n);let l=N({text:"Waiting for approval...",prefixText:" "}).start(),d=3e3,u=Math.floor((r||300)*1e3/d);for(let f=0;f<u;f++){await new Promise(c=>setTimeout(c,d));try{let c=await fetch("https://api.webability.io/cli/device-token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({deviceCode:s})});if(c.ok){let{token:x}=await c.json();W(x),l.succeed("Logged in."),console.log(),ee(M(x)),await te(x);return}if((await c.json().catch(()=>({}))).error==="expired")return l.fail("Login expired. Run `abilyo login` again."),process.exit(1)}catch{}}l.fail("Login timed out."),process.exit(1)}catch{return t.fail("Could not reach api.webability.io."),console.log(i.dim(" Check your connection, then run `abilyo login` again.")),console.log(),process.exit(1)}});var _=i.dim(" "+"\u2500".repeat(58)),st=["scan webability.io and list the critical issues","fix the colour-contrast failures on this page","check this component for keyboard traps","is this form accessible to a screen reader?"];function ee(e){let t=e.filter(o=>o.ok);if(!t.length){console.log(i.yellow(" No supported editor found for automatic setup.")),console.log(` Install Claude Code or Cursor, then run ${i.cyan("abilyo mcp install")}.`),console.log(i.dim(` Any other MCP client: ${i.cyan("abilyo mcp print")} gives you the config block.`)),console.log();for(let o of e.filter(s=>!s.ok))console.log(i.dim(` \u26A0 ${o.client}: ${o.detail}`));e.some(o=>!o.ok)&&console.log();return}console.log(_),console.log(i.bold(" Abilyo is now inside your editor")),console.log();for(let o of t)console.log(` ${i.green("\u2713")} ${o.detail}`);console.log(),console.log(i.dim(" Restart the editor, then ask it:"));for(let o of st)console.log(` ${i.cyan(`"${o}"`)}`);console.log(_),console.log();for(let o of e.filter(s=>!s.ok))console.log(i.dim(` \u26A0 ${o.client}: ${o.detail}`))}async function te(e){let t="free",o="";try{let s=await fetch("https://api.webability.io/cli/verify",{headers:{Authorization:`Bearer ${e}`}});if(s.ok){let a=await s.json();t=a.plan||"free",o=a.email||""}}catch{}if(t==="pro"){console.log(` ${i.green("\u2726 Abilyo Pro")}${o?i.dim(` \u2014 ${o}`):""}`),console.log(i.dim(" Deep scans, AI fixes and unlimited MCP calls are unlocked.")),console.log();return}console.log(_),console.log(` ${i.yellow("You are on Free.")} Free finds the issues. ${i.bold("Pro fixes them.")}`),console.log(),console.log(` ${i.cyan("abilyo scan --deep")} dynamic content, focus order, keyboard traps`),console.log(` ${i.cyan("AI fixes")} real code edits in your editor, not a to-do list`),console.log(` ${i.cyan("CI reports")} SARIF + HTML, unlimited MCP calls`),console.log(),console.log(` Upgrade in under a minute: ${i.bold.cyan("abilyo upgrade")}`),console.log(_),console.log()}function Ae(e){try{let{execFile:t}=Fe("child_process"),o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";t(o,[e],()=>{})}catch{}}var Se=b.command("mcp").description("Connect Abilyo to your AI editor (Claude Code, Cursor)");Se.command("install").description("Register the Abilyo MCP server with every editor found").option("-c, --client <client>","Only one client: claude, cursor").action(e=>{m();let t=k();if(!t)return y("Not logged in. Run `abilyo login` \u2014 it connects your editor for you."),process.exit(1);if(e.client&&e.client!=="claude"&&e.client!=="cursor")return y(`Unknown client "${e.client}". Use claude or cursor.`),process.exit(1);ee(M(t,e.client))});Se.command("print").description("Print the MCP config block (contains your token \u2014 do not share)").action(()=>{let e=k();if(!e)return m(),y("Not logged in. Run `abilyo login` first."),process.exit(1);console.log(JSON.stringify({mcpServers:{[h]:H(e)}},null,2))});b.command("upgrade").description("Upgrade to Abilyo Pro \u2014 deep scans and AI fixes").action(async()=>{m();let e=k();if(!e)return y("Log in first: `abilyo login`"),process.exit(1);let t=N({text:"Opening checkout...",prefixText:" "}).start();try{let o=await fetch("https://api.webability.io/cli/checkout",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({returnUrl:"https://abilyo.com"})});if(!o.ok)return t.fail(`Could not start checkout (server returned ${o.status}).`),console.log(i.dim(" Upgrade in the browser instead: https://webability.io/pricing")),console.log(),process.exit(1);let{url:s}=await o.json();t.succeed("Checkout ready \u2014 opening your browser."),console.log(),console.log(` ${i.cyan(s)}`),console.log(),Ae(s)}catch{return t.fail("Could not reach api.webability.io."),console.log(i.dim(" Upgrade in the browser instead: https://webability.io/pricing")),console.log(),process.exit(1)}});b.command("whoami").description("Show auth status and plan").action(async()=>{let e=k();if(m(),!e){console.log(i.yellow(" Not signed in.")),console.log(` Run ${i.cyan("abilyo login")} \u2014 it signs you in and connects your editor.`),console.log();return}console.log(i.green(" Signed in")),console.log(i.dim(` Key: ${e.slice(0,12)}\u2026`)),console.log(),await te(e)});b.command("logout").description("Remove saved API key and disconnect editors").action(()=>{let e=xe();ne(),m(),console.log(i.green(" Logged out. API key removed."));for(let t of e)console.log(t.ok?i.dim(` Disconnected ${t.detail}`):i.yellow(` ${t.detail}`));console.log(i.dim(" Sign back in any time: `abilyo login`")),console.log()});b.command("activate <code>").description("Activate Abilyo with your early access code").action(async e=>{m();let t=N({text:"Validating access code...",prefixText:" "}).start();try{if((await fetch("https://api.webability.io/cli/activate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({code:e.trim()})})).ok){q(e.trim()),t.succeed("Abilyo activated."),console.log(),console.log(` Next: ${i.cyan("abilyo scan <url>")} ${i.dim("\u2014 your first scan takes seconds")}`),console.log();return}}catch{}e.trim().length>=8?(q(e.trim()),t.succeed("Abilyo activated."),console.log(),console.log(` Next: ${i.cyan("abilyo scan <url>")} ${i.dim("\u2014 your first scan takes seconds")}`),console.log()):(t.fail("Invalid access code."),console.log(i.dim(" Request access at https://abilyo.com")),console.log(),process.exit(1))});b.argument("[url]","URL to scan").action(e=>{e?b.parse(["node","abilyo","scan",e,...process.argv.slice(3)]):(m(),ae()?(console.log(i.bold(" Commands:")),console.log(),console.log(` ${i.cyan("abilyo scan")} <url> Scan a page for accessibility issues`),console.log(` ${i.cyan("abilyo scan --deep")} <url> Dynamic content, focus order, keyboard traps ${i.dim("(Pro)")}`),console.log(` ${i.cyan("abilyo scan --exit")} <url> CI mode \u2014 exit 1 if issues found`),console.log(` ${i.cyan("abilyo flow")} <url> Scan a whole journey, one report`),console.log(` ${i.cyan("abilyo login")} Sign in and connect your AI editor`),console.log(` ${i.cyan("abilyo mcp install")} Re-connect Claude Code / Cursor`),console.log(` ${i.cyan("abilyo init")} Create .webability.yml config`),console.log(` ${i.cyan("abilyo whoami")} Show auth status and plan`),console.log(` ${i.cyan("abilyo upgrade")} Unlock deep scans + AI fixes ${i.dim("(Pro)")}`),console.log(),console.log(i.bold(" Examples:")),console.log(),console.log(i.dim(" abilyo scan localhost:3000 your dev server")),console.log(i.dim(" abilyo scan example.com --show highlight issues in a browser")),console.log(i.dim(" abilyo scan example.com --format sarif upload to GitHub code scanning")),console.log(i.dim(" abilyo scan example.com --exit fail the build on issues")),console.log(i.dim(" abilyo scan example.com --deep the checks axe-core cannot do")),console.log(),console.log(i.dim(" In your editor, after `abilyo login`:")),console.log(i.dim(' "scan staging.example.com and fix the contrast failures"'))):(console.log(i.yellow(" Abilyo is invite-only during early access.")),console.log(),console.log(` ${i.cyan("abilyo login")} Already have a WebAbility account? Start here`),console.log(` ${i.cyan("abilyo activate")} <code> Activate with an early-access code`),console.log(),console.log(i.dim(" Request access at https://abilyo.com"))),console.log())});b.parse();function it(e){let t=new Map;for(let s of e.issues)t.has(s.type)||t.set(s.type,{id:s.type,shortDescription:{text:s.message}});let o=e.engineWarnings??[];return{$schema:"https://json.schemastore.org/sarif-2.1.0.json",version:"2.1.0",runs:[{...o.length?{invocations:[{executionSuccessful:!0,toolExecutionNotifications:o.map(s=>({level:"warning",message:{text:s}}))}]}:{},tool:{driver:{name:"WebAbility",version:Ce.version,informationUri:"https://webability.io",rules:Array.from(t.values())}},results:e.issues.map(s=>{let n={startLine:Number.isInteger(s.line)&&s.line>0?s.line:1,snippet:{text:s.html||s.selector}};return Number.isInteger(s.column)&&s.column>0&&(n.startColumn=s.column),{ruleId:s.type,level:s.impact==="critical"||s.impact==="serious"?"error":"warning",message:{text:s.message},locations:[{physicalLocation:{artifactLocation:{uri:e.url},region:n}}]}})}]}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webability/cli",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "description": "Abilyo by WebAbility — WCAG accessibility scanner for your terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Verifies the non-clobber / permissions / uninstall behaviour against a FAKE
3
+ * HOME. Never touches the real ~/.cursor/mcp.json or ~/.claude.json.
4
+ */
5
+ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, statSync, existsSync } from 'node:fs'
6
+ import { tmpdir } from 'node:os'
7
+ import { join } from 'node:path'
8
+
9
+ const fake = mkdtempSync(join(tmpdir(), 'abilyo-home-'))
10
+ process.env.HOME = fake
11
+ process.env.USERPROFILE = fake
12
+
13
+ const { installForCursor, uninstallMcp, MCP_URL, MCP_SERVER_NAME } = await import(
14
+ '../src/mcp-install.ts'
15
+ )
16
+
17
+ const cfg = join(fake, '.cursor', 'mcp.json')
18
+ mkdirSync(join(fake, '.cursor'), { recursive: true })
19
+
20
+ let failures = 0
21
+ function check(name: string, cond: boolean, detail = '') {
22
+ console.log(`${cond ? 'PASS' : 'FAIL'} ${name}${detail ? ` — ${detail}` : ''}`)
23
+ if (!cond) failures++
24
+ }
25
+
26
+ // --- 1. a user's own local stdio `webability` server must survive -------------
27
+ writeFileSync(
28
+ cfg,
29
+ JSON.stringify(
30
+ { mcpServers: { [MCP_SERVER_NAME]: { command: 'npx', args: ['-y', '@webability/mcp'] }, other: { url: 'https://x' } } },
31
+ null,
32
+ 2,
33
+ ),
34
+ { mode: 0o644 },
35
+ )
36
+ const r1 = installForCursor('TOKEN-A')
37
+ const after1 = JSON.parse(readFileSync(cfg, 'utf-8'))
38
+ check('foreign local entry is NOT replaced', after1.mcpServers[MCP_SERVER_NAME].command === 'npx')
39
+ check('foreign case reports ok=false with an explanation', r1.ok === false && r1.detail.includes('left untouched'))
40
+ check('no token written into the file', !readFileSync(cfg, 'utf-8').includes('TOKEN-A'))
41
+
42
+ // --- 2. our own entry IS refreshed, other servers preserved -------------------
43
+ writeFileSync(
44
+ cfg,
45
+ JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: { url: MCP_URL, headers: { 'x-webability-token': 'OLD' } }, other: { url: 'https://x' } } }, null, 2),
46
+ { mode: 0o644 },
47
+ )
48
+ const r2 = installForCursor('TOKEN-B')
49
+ const after2 = JSON.parse(readFileSync(cfg, 'utf-8'))
50
+ check('our stale entry is refreshed', r2.ok === true && JSON.stringify(after2.mcpServers[MCP_SERVER_NAME]).includes('TOKEN-B'))
51
+ check('unrelated servers preserved', after2.mcpServers.other?.url === 'https://x')
52
+
53
+ // --- 3. a pre-existing 0644 config is tightened to 0600 ----------------------
54
+ const mode = statSync(cfg).mode & 0o777
55
+ check('pre-existing config chmod-ed to 0600', mode === 0o600, `mode=0${mode.toString(8)}`)
56
+
57
+ // --- 4. uninstall removes ours, keeps the rest -------------------------------
58
+ const r4 = uninstallMcp()
59
+ const after4 = JSON.parse(readFileSync(cfg, 'utf-8'))
60
+ check('uninstall removes our entry', after4.mcpServers[MCP_SERVER_NAME] === undefined)
61
+ check('uninstall keeps unrelated servers', after4.mcpServers.other?.url === 'https://x')
62
+ check('uninstall reports the cursor removal', r4.some((r) => r.client === 'cursor' && r.ok))
63
+
64
+ // --- 5. uninstall must NOT remove a foreign entry ----------------------------
65
+ writeFileSync(cfg, JSON.stringify({ mcpServers: { [MCP_SERVER_NAME]: { command: 'npx' } } }, null, 2))
66
+ const r5 = uninstallMcp()
67
+ const after5 = JSON.parse(readFileSync(cfg, 'utf-8'))
68
+ check("uninstall leaves a user's own server alone", after5.mcpServers[MCP_SERVER_NAME]?.command === 'npx')
69
+ check('uninstall says so', r5.some((r) => r.client === 'cursor' && !r.ok && r.detail.includes("isn't ours")))
70
+
71
+ check('fake HOME was used, real config untouched', existsSync(cfg) && cfg.startsWith(fake))
72
+ console.log(failures === 0 ? '\nALL PASS' : `\n${failures} FAILED`)
73
+ process.exit(failures === 0 ? 0 : 1)