@gruum/cli 0.2.2 → 0.2.4
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/gruum.mjs +3 -3
- package/package.json +1 -1
package/gruum.mjs
CHANGED
|
@@ -33,10 +33,10 @@ ${t.join(`
|
|
|
33
33
|
`}var Ds=`
|
|
34
34
|
Choose 1\u20133, or press Enter to quit: `,Ts=`
|
|
35
35
|
Would you like to run a (c) check, (b) baseline, or (q) quit? `,Bs=`
|
|
36
|
-
You have no baseline. Would you like to run it? (
|
|
36
|
+
You have no baseline. Would you like to run it? (Enter) baseline, (q) quit: `;function Fs(e){return`
|
|
37
37
|
${e?"This repo uses Cursor and Claude. Gruum can set up Cursor.":"This repo uses Cursor."}
|
|
38
38
|
|
|
39
|
-
Set up Gruum in Cursor so checks run while you edit and before a commit? (y) yes, (n) no: `}function Us(e){let t=e.trim().toLowerCase();return!t||t==="n"||t==="no"||t==="q"||t==="quit"?"no":t==="y"||t==="yes"?"yes":null}function Vs(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"?"quit":t==="c"||t==="check"?"check":t==="b"||t==="baseline"?"baseline":null}function zs(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"||t==="n"||t==="no"?"quit":t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Ws(e){let t=e.trim().toLowerCase();if(!t)return"quit";let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Ie.length?Ie[n-1]:Ie.find(s=>s.name===t)??null}var Fi="2025-06-18",it=`Check before you finish. If the request needs a button the spec does not have, ask the user: "You asked for a design element that is not in the spec. 1. Use an existing spec style for it. 2. Add it as it is and request review." Do not request a review until they choose 2. Never edit Gruum's generated files, including .gruum/project.json, to make a check pass.`,at={gruum_button_spec:`The designer-published button spec for this repository: components, looks and how to select them, tokens, and written rules. Read it before writing or restyling a button. ${it}`,gruum_check_buttons:`Check the working tree's buttons against the spec and list drift items with a one-line fix each. Run it before you stop. ${it}`,gruum_request_exception:`Ask a designer to review one drift item. Call this only after the user chooses to add the element as it is and request review. Send the drift id from gruum_check_buttons and a reason. If this tool is missing, run \`npx @gruum/cli request <drift id> --reason "..."\` instead of reading the CLI package. ${it}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${it}`};function Gs(e){return[{name:"gruum_button_spec",description:at.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:at.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:t=>{let n=Array.isArray(t.paths)?t.paths.filter(s=>typeof s=="string"):[];return e.check(n)}},{name:"gruum_request_exception",description:at.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"")},{name:"gruum_exception_status",description:at.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:t=>e.status(typeof t.id=="string"?t.id:void 0)}]}function Ge(e,t){return{jsonrpc:"2.0",id:e,result:t}}function lt(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function Hs(e,t,n){if(!e||typeof e!="object")return lt(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:lt(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return Ge(o,{protocolVersion:typeof a=="string"?a:Fi,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return Ge(o,{});case"tools/list":return Ge(o,{tools:t.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=t.find(c=>c.name===i.name);if(!a)return lt(o,-32602,`Unknown tool: ${String(i.name)}`);let l=i.arguments&&typeof i.arguments=="object"?i.arguments:{};try{let c=await a.run(l);return Ge(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return Ge(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:lt(o,-32601,`Method not found: ${s.method}`)}}var Ui=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Vi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,zi=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|woff2?|ttf|otf|eot|mp[34]|wav|ogg|webm|mov|zip|gz|tgz|bz2|7z|rar|jar|pdf|docx?|xlsx?|pptx?|exe|dll|so|dylib|wasm|bin|dat|sqlite|db|psd|ai|sketch|fig)$/i,Wi=/(^|\/)\.gruum\//;function tn(e){return!Ui.test(`${e}/`)&&!Wi.test(`${e}/`)}function nn(e,t){return Vi.test(e)||zi.test(e)?!1:t<=3e5}function Ks(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Gi=/\.(css|scss|sass|less|styl|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx?|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2|json)$/i;function Js(e){return Gi.test(e)}function sn(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function rn(e,t){let n=sn(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Zs(e,t,n){let s=new Map(e);for(let r of t){let o=rn(r.path,n);o===null||!tn(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):nn(o,r.content.length)&&s.set(o,r.content))}return s}function qs(e){let t=e.split("\0").filter(Boolean),n=[];for(let s=0;s<t.length;s++){let r=t[s];if(/^[RC]/.test(r)){let i=t[++s],a=t[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=t[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function ct(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var Xs=e=>e.replace(/\\(.)/g,"$1");function Hi(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let a=t[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=t.slice(n.index+n[0].length,r).trim();t=`${t.slice(0,n.index)}${o}${t.slice(r+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var on=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function er(e){let t=[];on.lastIndex=0;let n=0;for(;n<e.length;){on.lastIndex=n;let s=on.exec(e);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")t.push({kind:"universal",raw:r});else if(s[1]!==void 0)t.push({kind:"class",raw:r,name:Xs(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:Xs(s[2])});else if(s[3]!==void 0)t.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)t.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?t.push({kind:"pseudoElement",raw:r,name:o}):t.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return t.length?t:null}function Q(e){let t=Hi(e),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=t.slice(r,l).trim();if(!c)return!0;let u=er(c);return u?(n.push({combinator:i?null:o??" ",simples:u}),i=!1,o=null,!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(t.length)||o?null:n.length?n:null}function He(e){return e.map(t=>t.raw).join("")}function Ke(e){return e.map((t,n)=>{let s=He(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function W(e){let t=[],n=0,s=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(t.push(e.slice(s,r).trim()),s=r+1)}return t.push(e.slice(s).trim()),t.filter(Boolean)}var tr=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Ys(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function an(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return e.some(r=>r.kind==="class"&&tr(r.name).some(o=>s.has(o)))}var Ki=new Set(["html","body"]),Ji=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function pt(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Ys(n.name,t.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&t.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Ys(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=W(n.args).map(Q);if(s.length>0&&s.every(r=>r!==null&&pt(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function nr(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Ki.has(n.name))?!0:!e.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function sr(e){return e.some(t=>t.kind==="tag"&&Ji.has(t.name))}var ut=["hover","focus","active","selected","current","loading","disabled"],Zi={hover:"hover",hovered:"hover",focus:"focus",focused:"focus","focus-visible":"focus","focus-within":"focus",active:"selected",pressed:"selected",selected:"selected",checked:"selected",on:"selected",current:"current",loading:"loading",busy:"loading",pending:"loading",disabled:"disabled"},qi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Xi={disabled:"disabled","aria-disabled":"disabled","data-disabled":"disabled","aria-pressed":"selected","aria-selected":"selected","aria-expanded":"selected","aria-checked":"selected","data-active":"selected","data-selected":"selected","data-pressed":"selected","data-checked":"selected","data-highlighted":"selected","aria-current":"current","aria-busy":"loading","data-loading":"loading","data-busy":"loading","data-hover":"hover","data-hovered":"hover","data-focus":"focus","data-focused":"focus","data-focus-visible":"focus","data-open":"open","data-expanded":"open"},Yi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Qs=e=>Zi[e.toLowerCase()]??e.toLowerCase(),ce={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function rr(e){if(e.kind==="pseudo"){let t=qi[e.name];if(!t)return null;let n=ce[t];return{state:t,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[e.name==="checked"?"checked":"disabled"]:""}}}}if(e.kind==="attr"){if(e.name==="data-state"&&e.value!==null)return{state:Qs(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Xi[e.name];if(!t||e.value!==null&&/^(?:false|off|0)$/i.test(e.value))return null;let n=e.value??(e.name.startsWith("aria-")?"true":"");return{state:t,marker:{classes:[],attrs:{[e.name]:n}}}}if(e.kind==="class"){let t=/^(?:is|has)-(.+)$/i.exec(e.name),n=t?t[1]:Yi.has(e.name.toLowerCase())?e.name:null;return n?{state:Qs(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Qi(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:W(e.args).every(t=>{let n=er(t);return n!==null&&n.every(s=>rr(s)!==null)})}function ft(e){let t=[],n=new Map;for(let o of e){if(Qi(o))continue;let i=rr(o);if(!i){t.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:t,states:s,marker:r}}function H(e){if(e==="default")return-1;let t=ut.indexOf(e);return t===-1?ut.length:t}function be(e){return e.length?e.join(" + "):"default"}function ln(e){return e.replace(/:hover\b/g,`.${ce.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ce.focus}`).replace(/:active\b/g,`.${ce.active}`)}var ea=new Set(["background","background-color","background-image","background-position","background-size","background-repeat","background-clip","background-origin","background-attachment","color","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline","outline-color","outline-offset","box-shadow","filter","backdrop-filter","opacity","fill","stroke","caret-color","accent-color","text-decoration-color","mix-blend-mode"]),ta=new Set(["width","min-width","max-width","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","margin","margin-top","margin-right","margin-bottom","margin-left","margin-inline","margin-block","margin-inline-start","margin-inline-end","margin-block-start","margin-block-end","position","inset","inset-inline","inset-block","top","right","bottom","left","z-index","float","clear","grid-column","grid-row","grid-area","place-self"]),na=new Set(["cursor","user-select","pointer-events","transition","transition-property","transition-duration","transition-timing-function","transition-delay","will-change","touch-action","-webkit-tap-highlight-color","appearance","-webkit-appearance","scroll-margin","scroll-margin-top"]);function Je(e){let t=e.toLowerCase();return ea.has(t)?"paint":ta.has(t)?"layout":na.has(t)?"hint":"box"}var sa={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function or(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=tr(n[0].name)[0],r=s?sa[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var Tu={hover:{classes:[ce.hover],attrs:{}},focus:{classes:[ce.focus],attrs:{}},active:{classes:[ce.active],attrs:{}},selected:{classes:[],attrs:{"aria-pressed":"true"}},current:{classes:[],attrs:{"aria-current":"true"}},loading:{classes:[],attrs:{"aria-busy":"true"}},disabled:{classes:[],attrs:{disabled:""}}};var ra="data-gs-sheet";function ar(e){return`[${ra}="${e.replace(/["\\]/g,"")}"]`}function ir(e){return/\.module\.[a-z]+$/i.test(e)}var oa=new Set(["button","a","div","span","input","summary","label"]);function ye(e){let t=0,n=0;for(let s=0;s<e.length;s++){let r=e[s];r==="("||r==="["?t++:r===")"||r==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function ia(e){let t={tag:"",classes:[],attrs:{}};for(let n of e)switch(n.kind){case"pseudoElement":return null;case"tag":t.tag=n.name;break;case"class":t.classes.push(n.name);break;case"attr":t.attrs[n.name]=n.value??"";break;default:break}return t}function dt(e,t){let n=Q(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>ia(c.simples));if(s.some(c=>c===null))return null;let r=s,o=r[r.length-1],i=o.tag&&o.tag!=="*"?o.tag:"button";if(!oa.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...t,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function cn(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function gt(e){let t=cn(e,"display");if(/^none\b/i.test(t))return"display: none";let n=cn(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=cn(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function lr(e,t){return e===t||!ir(e)&&!ir(t)}function se(e,t){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(t))return!1;for(let n of t.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(e)}var aa=40,ee=(e,t)=>({path:e,line:t});function te(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,aa)}}function xe(e,t){return{...e,status:"na",summary:t,findings:[]}}var un=e=>e.state.split(" + ");function dr(e,t){if(!e.element||!t.element||e!==t&&!lr(e.path,t.path)||e.element.ancestors.length>0||e.element.tag!==t.element.tag)return!1;let n=new Set(t.element.classes);return e.element.classes.every(s=>n.has(s))?Object.entries(e.element.attrs).every(([s,r])=>t.element.attrs[s]===r):!1}function gr(e,t){return t.filter(n=>dr(n,e)).flatMap(n=>n.states)}function la(e,t,n){return gr(e,t).some(s=>un(s).includes(n))||t.filter(s=>dr(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var ca=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function ua(e){let t={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of ca){let i=n.filter(a=>!la(a,e.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>ee(a.path,a.line))})}return te(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var cr=new Set(["outline","outline-style","outline-width"]),ur=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,pa=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function fa(e){let t={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=gr(r,e.variants),i=o.filter(l=>{let c=un(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>cr.has(l.property)&&ur.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>un(l).includes("focus")).some(l=>l.declarations.some(c=>pa.test(c.property)&&!(cr.has(c.property)&&ur.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||s.push({severity:"issue",message:`${r.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[r.title],refs:[ee(r.path,i.s.line)]})}return te(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function da(e){let t={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${e.noun} styles read that no scanned stylesheet defines.`};if(e.tokens.length===0)return xe(t,`The ${e.noun} styles read no custom properties.`);let s=e.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=e.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>ee(i.path,i.line))}});return te(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var ga=/var\((?:[^()]|\([^()]*\))*\)/g,pr=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,ma=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ha=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function fr(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(s=>s+s).join("")}`:t}function pn(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=t.get(r);return i!==void 0?pn(i,t,n+1):o!==void 0?pn(o.trim(),t,n+1):s})}var ba=[[/^(?:padding|margin|gap|row-gap|column-gap)/,/space|spacing|gap|pad|inset|gutter/i],[/height$/,/height|control|size/i],[/^border-radius/,/radius|round|corner/i],[/^font-size$/,/text|font|size|type/i],[/^letter-spacing$/,/tracking|letter|spacing/i]];function ya(e,t){if(!t)return null;let n=ba.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function xa(e){let t={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${e.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of e.tokenValues){let a=pn(i,e.tokenValues).trim();if(new RegExp(`^(?:${pr.source})$`,"i").test(a)){let l=fr(a);n.set(l,[...n.get(l)??[],o])}else/^\d+(?:\.\d+)?px$/.test(a)&&s.set(a,[...s.get(a)??[],o])}if(n.size===0&&s.size===0)return xe(t,"No color or size tokens were found to compare against.");let r=[];for(let o of e.variants){let i=[],a=null;for(let c of o.states)for(let u of c.declarations){if(u.via)continue;let f=u.value.replace(ga," ");for(let m of f.matchAll(pr)){let h=n.get(fr(m[0]));i.push(h?`${m[0]} in ${u.property} is the value of ${h[0]}`:`${m[0]} in ${u.property} is not a token`),a??=c}if(ma.test(u.property))for(let m of f.matchAll(ha)){let h=ya(u.property,s.get(`${m[1]}px`));!h||Number(m[1])<=1||(i.push(`${m[1]}px in ${u.property} is the value of ${h}`),a??=c)}}if(i.length===0||!a)continue;let l=[...new Set(i)];r.push({severity:"issue",message:`${o.title}: ${l.slice(0,4).join("; ")}${l.length>4?`; and ${l.length-4} more`:""}.`,styles:[o.title],refs:[ee(o.path,a.line)]})}return te(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function ka(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return xe(t,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[ee(r.path,r.line)]}):r.usage.status==="dynamic"&&s.push({severity:"note",message:`${r.title} (${r.selector}) is built at runtime and nothing selects it by value.`,styles:[r.title],refs:[ee(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),te(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function wa(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of e.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>ee(o.path,o.line))}));return te(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function va(e){let t={id:"native",title:`Native <${e.element}> instead of the component`,description:`Files that render a raw <${e.element}> although the repository has a shared ${e.element} component.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${e.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[ee(s.path,s.line)]}));return te(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function $a(e){let t={id:"props",title:"Prop values with no look",description:`Calls to a ${e.element} component with a literal prop value the component has no style for.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[ee(s.path,s.line)]}));return te(t,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function Ca(e){let t={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=e;if(n.files.length===0)return{...t,status:"attention",summary:`Nothing in the repository mentions ${e.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${e.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return te(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return te(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>ee(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function mr(e){return[ua(e),fa(e),ka(e),wa(e),da(e),xa(e),va(e),$a(e),Ca(e)]}var Sa=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,hr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,Ra=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Aa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),_a=new Set(["classNames","classnames","clsx","cn","cx"]),Ia=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function xr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
|
|
39
|
+
Set up Gruum in Cursor so checks run while you edit and before a commit? (Enter) yes, (n) no: `}function Us(e){let t=e.trim().toLowerCase();return t==="n"||t==="no"||t==="q"||t==="quit"?"no":!t||t==="y"||t==="yes"?"yes":null}function Vs(e){let t=e.trim().toLowerCase();return!t||t==="q"||t==="quit"?"quit":t==="c"||t==="check"?"check":t==="b"||t==="baseline"?"baseline":null}function zs(e){let t=e.trim().toLowerCase();return t==="q"||t==="quit"||t==="n"||t==="no"?"quit":!t||t==="b"||t==="baseline"||t==="y"||t==="yes"?"baseline":null}function Ws(e){let t=e.trim().toLowerCase();if(!t)return"quit";let n=Number(t);return Number.isInteger(n)&&n>=1&&n<=Ie.length?Ie[n-1]:Ie.find(s=>s.name===t)??null}var Fi="2025-06-18",it=`Check before you finish. If the request needs a button the spec does not have, ask the user: "You asked for a design element that is not in the spec. 1. Use an existing spec style for it. 2. Add it as it is and request review." Do not request a review until they choose 2. Never edit Gruum's generated files, including .gruum/project.json, to make a check pass.`,at={gruum_button_spec:`The designer-published button spec for this repository: components, looks and how to select them, tokens, and written rules. Read it before writing or restyling a button. ${it}`,gruum_check_buttons:`Check the working tree's buttons against the spec and list drift items with a one-line fix each. Run it before you stop. ${it}`,gruum_request_exception:`Ask a designer to review one drift item. Call this only after the user chooses to add the element as it is and request review. Send the drift id from gruum_check_buttons and a reason. If this tool is missing, run \`npx @gruum/cli request <drift id> --reason "..."\` instead of reading the CLI package. ${it}`,gruum_exception_status:`Pending, accepted, or rejected for this branch's exception requests. Pass an id to read one. ${it}`};function Gs(e){return[{name:"gruum_button_spec",description:at.gruum_button_spec,inputSchema:{type:"object",properties:{},additionalProperties:!1},run:()=>e.spec()},{name:"gruum_check_buttons",description:at.gruum_check_buttons,inputSchema:{type:"object",properties:{paths:{type:"array",items:{type:"string"},description:"Only report drift in these files (relative to the repository root). Omit to check everything."}},additionalProperties:!1},run:t=>{let n=Array.isArray(t.paths)?t.paths.filter(s=>typeof s=="string"):[];return e.check(n)}},{name:"gruum_request_exception",description:at.gruum_request_exception,inputSchema:{type:"object",properties:{driftId:{type:"string",description:"The drift item id from gruum_check_buttons."},reason:{type:"string",description:"Why the spec has no button for this job."}},required:["driftId","reason"],additionalProperties:!1},run:t=>e.request(typeof t.driftId=="string"?t.driftId:"",typeof t.reason=="string"?t.reason:"")},{name:"gruum_exception_status",description:at.gruum_exception_status,inputSchema:{type:"object",properties:{id:{type:"string",description:"One request id. Omit to list this branch."}},additionalProperties:!1},run:t=>e.status(typeof t.id=="string"?t.id:void 0)}]}function Ge(e,t){return{jsonrpc:"2.0",id:e,result:t}}function lt(e,t,n){return{jsonrpc:"2.0",id:e,error:{code:t,message:n}}}async function Hs(e,t,n){if(!e||typeof e!="object")return lt(null,-32600,"Invalid request");let s=e,r=!("id"in s),o=s.id??null;if(typeof s.method!="string")return r?null:lt(o,-32600,"Invalid request");let i=s.params??{};switch(s.method){case"initialize":{let a=i.protocolVersion;return Ge(o,{protocolVersion:typeof a=="string"?a:Fi,capabilities:{tools:{listChanged:!1}},serverInfo:n})}case"ping":return Ge(o,{});case"tools/list":return Ge(o,{tools:t.map(({name:a,description:l,inputSchema:c})=>({name:a,description:l,inputSchema:c}))});case"tools/call":{let a=t.find(c=>c.name===i.name);if(!a)return lt(o,-32602,`Unknown tool: ${String(i.name)}`);let l=i.arguments&&typeof i.arguments=="object"?i.arguments:{};try{let c=await a.run(l);return Ge(o,{content:[{type:"text",text:c.text}],isError:c.isError??!1})}catch(c){return Ge(o,{content:[{type:"text",text:c instanceof Error?c.message:String(c)}],isError:!0})}}default:return r?null:lt(o,-32601,`Method not found: ${s.method}`)}}var Ui=/(^|\/)(node_modules|\.git|\.next|dist|build|out|coverage|vendor|\.turbo|\.cache|__pycache__|target|\.venv|venv)\//,Vi=/(^|\/)(package-lock\.json|pnpm-lock\.yaml|yarn\.lock|bun\.lockb|Cargo\.lock|poetry\.lock|composer\.lock|Gemfile\.lock)$/,zi=/\.(png|jpe?g|gif|webp|avif|ico|icns|bmp|tiff?|svgz|woff2?|ttf|otf|eot|mp[34]|wav|ogg|webm|mov|zip|gz|tgz|bz2|7z|rar|jar|pdf|docx?|xlsx?|pptx?|exe|dll|so|dylib|wasm|bin|dat|sqlite|db|psd|ai|sketch|fig)$/i,Wi=/(^|\/)\.gruum\//;function tn(e){return!Ui.test(`${e}/`)&&!Wi.test(`${e}/`)}function nn(e,t){return Vi.test(e)||zi.test(e)?!1:t<=3e5}function Ks(e){let t=Math.min(e.length,8e3);for(let n=0;n<t;n++)if(e[n]===0)return!0;return!1}var Gi=/\.(css|scss|sass|less|styl|tsx?|jsx?|mjs|cjs|vue|svelte|astro|html?|mdx?|erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2|json)$/i;function Js(e){return Gi.test(e)}function sn(e){return e.replace(/\\/g,"/").replace(/^\.\/?/,"").replace(/^\/+|\/+$/g,"")}function rn(e,t){let n=sn(t),s=e.replace(/\\/g,"/");return n?s.startsWith(`${n}/`)?s.slice(n.length+1):null:s}function Zs(e,t,n){let s=new Map(e);for(let r of t){let o=rn(r.path,n);o===null||!tn(o.split("/").slice(0,-1).join("/")||".")||(r.content===null?s.delete(o):nn(o,r.content.length)&&s.set(o,r.content))}return s}function qs(e){let t=e.split("\0").filter(Boolean),n=[];for(let s=0;s<t.length;s++){let r=t[s];if(/^[RC]/.test(r)){let i=t[++s],a=t[++s];r.startsWith("R")&&i&&n.push({path:i,deleted:!0}),a&&n.push({path:a,deleted:!1});continue}let o=t[++s];o&&n.push({path:o,deleted:r.startsWith("D")})}return n}function ct(e){let t=/^(?:git@|ssh:\/\/git@|https?:\/\/(?:[^@/]+@)?)github\.com[:/]([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i.exec(e.trim());return t?`${t[1]}/${t[2]}`:null}var Xs=e=>e.replace(/\\(.)/g,"$1");function Hi(e){let t=e;for(;;){let n=/:(?:global|local)\(/i.exec(t);if(!n)break;let s=0,r=-1;for(let i=n.index+n[0].length-1;i<t.length;i++){let a=t[i];if(a==="(")s++;else if(a===")"&&--s===0){r=i;break}}if(r<0)break;let o=t.slice(n.index+n[0].length,r).trim();t=`${t.slice(0,n.index)}${o}${t.slice(r+1)}`}return t.replace(/:(?:global|local)(?=\s|$)/gi,"").trim()}var on=/\*|[a-z][\w-]*|\.((?:\\.|[\w-])+)|#((?:\\.|[\w-])+)|\[\s*([\w-]+)\s*(?:([~|^$*]?=)\s*(?:"([^"]*)"|'([^']*)'|([^\]\s]*)))?\s*[is]?\s*\]|::([\w-]+)|:([\w-]+)(\((?:[^()]|\([^()]*\))*\))?/giy;function er(e){let t=[];on.lastIndex=0;let n=0;for(;n<e.length;){on.lastIndex=n;let s=on.exec(e);if(!s||s.index!==n)return null;let r=s[0];if(n+=r.length,r==="*")t.push({kind:"universal",raw:r});else if(s[1]!==void 0)t.push({kind:"class",raw:r,name:Xs(s[1])});else if(s[2]!==void 0)t.push({kind:"id",raw:r,name:Xs(s[2])});else if(s[3]!==void 0)t.push({kind:"attr",raw:r,name:s[3],op:s[4]??null,value:s[4]?s[5]??s[6]??s[7]??"":null});else if(s[8]!==void 0)t.push({kind:"pseudoElement",raw:r,name:s[8].toLowerCase()});else if(s[9]!==void 0){let o=s[9].toLowerCase();/^(?:before|after|first-line|first-letter)$/.test(o)?t.push({kind:"pseudoElement",raw:r,name:o}):t.push({kind:"pseudo",raw:r,name:o,args:s[10]?s[10].slice(1,-1).trim():null})}else if(t.length===0)t.push({kind:"tag",raw:r,name:r.toLowerCase()});else return null}return t.length?t:null}function Q(e){let t=Hi(e),n=[],s=0,r=0,o=null,i=!0,a=l=>{let c=t.slice(r,l).trim();if(!c)return!0;let u=er(c);return u?(n.push({combinator:i?null:o??" ",simples:u}),i=!1,o=null,!0):!1};for(let l=0;l<t.length;l++){let c=t[l];if(c==="("||c==="[")s++;else if(c===")"||c==="]")s=Math.max(0,s-1);else if(s===0&&(c===">"||c==="+"||c==="~")){if(!a(l)||o)return null;o=c,r=l+1}else if(s===0&&/\s/.test(c)){if(!a(l))return null;r=l+1}}return!a(t.length)||o?null:n.length?n:null}function He(e){return e.map(t=>t.raw).join("")}function Ke(e){return e.map((t,n)=>{let s=He(t.simples);return n===0?s:t.combinator===" "?` ${s}`:` ${t.combinator} ${s}`}).join("")}function W(e){let t=[],n=0,s=0;for(let r=0;r<e.length;r++){let o=e[r];o==="("||o==="["?n++:o===")"||o==="]"?n=Math.max(0,n-1):o===","&&n===0&&(t.push(e.slice(s,r).trim()),s=r+1)}return t.push(e.slice(s).trim()),t.filter(Boolean)}var tr=e=>e.replace(/([a-z\d])([A-Z])/g,"$1-$2").split(/[^a-z0-9]+/i).filter(Boolean).map(t=>t.toLowerCase());function Ys(e,t){let n=e.toLowerCase();return t.some(s=>n.includes(s.toLowerCase()))}function an(e,t){let n=t.excludeClassKeywords;if(!n?.length)return!1;let s=new Set(n.flatMap(r=>[r.toLowerCase(),`${r.toLowerCase()}s`]));return e.some(r=>r.kind==="class"&&tr(r.name).some(o=>s.has(o)))}var Ki=new Set(["html","body"]),Ji=new Set(["svg","path","use","img","picture","video","i","em","strong","b","small","kbd","sup","sub"]);function pt(e,t){for(let n of e)switch(n.kind){case"tag":if(t.elements.includes(n.name))return!0;break;case"class":if(Ys(n.name,t.classKeywords))return!0;break;case"attr":if(n.name==="role"&&n.value!==null&&t.roles.includes(n.value.toLowerCase())||n.name==="data-component"&&n.value!==null&&Ys(n.value,t.classKeywords))return!0;break;case"pseudo":if((n.name==="is"||n.name==="where")&&n.args){let s=W(n.args).map(Q);if(s.length>0&&s.every(r=>r!==null&&pt(r[r.length-1].simples,t)))return!0}break;default:break}return!1}function nr(e){return e.some(n=>n.kind==="universal")?e.length===1:e.some(n=>n.kind==="tag"&&Ki.has(n.name))?!0:!e.some(n=>n.kind==="tag"||n.kind==="class"||n.kind==="attr"||n.kind==="id"||n.kind==="pseudo"&&(n.name==="is"||n.name==="where"))}function sr(e){return e.some(t=>t.kind==="tag"&&Ji.has(t.name))}var ut=["hover","focus","active","selected","current","loading","disabled"],Zi={hover:"hover",hovered:"hover",focus:"focus",focused:"focus","focus-visible":"focus","focus-within":"focus",active:"selected",pressed:"selected",selected:"selected",checked:"selected",on:"selected",current:"current",loading:"loading",busy:"loading",pending:"loading",disabled:"disabled"},qi={hover:"hover",focus:"focus","focus-visible":"focus","focus-within":"focus",active:"active",checked:"selected",disabled:"disabled"},Xi={disabled:"disabled","aria-disabled":"disabled","data-disabled":"disabled","aria-pressed":"selected","aria-selected":"selected","aria-expanded":"selected","aria-checked":"selected","data-active":"selected","data-selected":"selected","data-pressed":"selected","data-checked":"selected","data-highlighted":"selected","aria-current":"current","aria-busy":"loading","data-loading":"loading","data-busy":"loading","data-hover":"hover","data-hovered":"hover","data-focus":"focus","data-focused":"focus","data-focus-visible":"focus","data-open":"open","data-expanded":"open"},Yi=new Set(["active","selected","pressed","checked","loading","busy","disabled","open","current","hover","focus","show","expanded","collapsed"]),Qs=e=>Zi[e.toLowerCase()]??e.toLowerCase(),ce={hover:"__gs-hover",focus:"__gs-focus",active:"__gs-active"};function rr(e){if(e.kind==="pseudo"){let t=qi[e.name];if(!t)return null;let n=ce[t];return{state:t,marker:n?{classes:[n],attrs:{}}:{classes:[],attrs:{[e.name==="checked"?"checked":"disabled"]:""}}}}if(e.kind==="attr"){if(e.name==="data-state"&&e.value!==null)return{state:Qs(e.value),marker:{classes:[],attrs:{"data-state":e.value}}};let t=Xi[e.name];if(!t||e.value!==null&&/^(?:false|off|0)$/i.test(e.value))return null;let n=e.value??(e.name.startsWith("aria-")?"true":"");return{state:t,marker:{classes:[],attrs:{[e.name]:n}}}}if(e.kind==="class"){let t=/^(?:is|has)-(.+)$/i.exec(e.name),n=t?t[1]:Yi.has(e.name.toLowerCase())?e.name:null;return n?{state:Qs(n),marker:{classes:[e.name],attrs:{}}}:null}return null}function Qi(e){return e.kind!=="pseudo"||e.name!=="not"||!e.args?!1:W(e.args).every(t=>{let n=er(t);return n!==null&&n.every(s=>rr(s)!==null)})}function ft(e){let t=[],n=new Map;for(let o of e){if(Qi(o))continue;let i=rr(o);if(!i){t.push(o);continue}let a=n.get(i.state)??{classes:[],attrs:{}};for(let l of i.marker.classes)a.classes.includes(l)||a.classes.push(l);Object.assign(a.attrs,i.marker.attrs),n.set(i.state,a)}let s=[...n.keys()].sort((o,i)=>H(o)-H(i)||o.localeCompare(i)),r={classes:[],attrs:{}};for(let o of s){let i=n.get(o);r.classes.push(...i.classes),Object.assign(r.attrs,i.attrs)}return{identity:t,states:s,marker:r}}function H(e){if(e==="default")return-1;let t=ut.indexOf(e);return t===-1?ut.length:t}function be(e){return e.length?e.join(" + "):"default"}function ln(e){return e.replace(/:hover\b/g,`.${ce.hover}`).replace(/:focus(?:-visible|-within)?\b/g,`.${ce.focus}`).replace(/:active\b/g,`.${ce.active}`)}var ea=new Set(["background","background-color","background-image","background-position","background-size","background-repeat","background-clip","background-origin","background-attachment","color","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","outline","outline-color","outline-offset","box-shadow","filter","backdrop-filter","opacity","fill","stroke","caret-color","accent-color","text-decoration-color","mix-blend-mode"]),ta=new Set(["width","min-width","max-width","flex","flex-grow","flex-shrink","flex-basis","align-self","justify-self","order","margin","margin-top","margin-right","margin-bottom","margin-left","margin-inline","margin-block","margin-inline-start","margin-inline-end","margin-block-start","margin-block-end","position","inset","inset-inline","inset-block","top","right","bottom","left","z-index","float","clear","grid-column","grid-row","grid-area","place-self"]),na=new Set(["cursor","user-select","pointer-events","transition","transition-property","transition-duration","transition-timing-function","transition-delay","will-change","touch-action","-webkit-tap-highlight-color","appearance","-webkit-appearance","scroll-margin","scroll-margin-top"]);function Je(e){let t=e.toLowerCase();return ea.has(t)?"paint":ta.has(t)?"layout":na.has(t)?"hint":"box"}var sa={shadow:/^box-shadow$/,cursor:/^cursor$/,rounded:/^border(?:-[a-z]+)*-radius$/,radius:/^border(?:-[a-z]+)*-radius$/};function or(e,t){let n=e.filter(o=>o.kind==="class");if(n.length!==1||e.length!==1)return!1;let s=tr(n[0].name)[0],r=s?sa[s]:void 0;return r?t.length>0&&t.every(o=>r.test(o.property.toLowerCase())):!1}var Tu={hover:{classes:[ce.hover],attrs:{}},focus:{classes:[ce.focus],attrs:{}},active:{classes:[ce.active],attrs:{}},selected:{classes:[],attrs:{"aria-pressed":"true"}},current:{classes:[],attrs:{"aria-current":"true"}},loading:{classes:[],attrs:{"aria-busy":"true"}},disabled:{classes:[],attrs:{disabled:""}}};var ra="data-gs-sheet";function ar(e){return`[${ra}="${e.replace(/["\\]/g,"")}"]`}function ir(e){return/\.module\.[a-z]+$/i.test(e)}var oa=new Set(["button","a","div","span","input","summary","label"]);function ye(e){let t=0,n=0;for(let s=0;s<e.length;s++){let r=e[s];r==="("||r==="["?t++:r===")"||r==="]"?t=Math.max(0,t-1):t===0&&/[\s>+~]/.test(r)&&(n=s+1)}return n}function ia(e){let t={tag:"",classes:[],attrs:{}};for(let n of e)switch(n.kind){case"pseudoElement":return null;case"tag":t.tag=n.name;break;case"class":t.classes.push(n.name);break;case"attr":t.attrs[n.name]=n.value??"";break;default:break}return t}function dt(e,t){let n=Q(e);if(!n||n.some(c=>c.combinator==="+"||c.combinator==="~"))return null;let s=n.map(c=>ia(c.simples));if(s.some(c=>c===null))return null;let r=s,o=r[r.length-1],i=o.tag&&o.tag!=="*"?o.tag:"button";if(!oa.has(i)||o.classes.length===0&&Object.keys(o.attrs).length===0&&!o.tag)return null;let a=[...new Set([...t,...o.classes])],l=r.slice(0,-1).filter(c=>c.tag||c.classes.length||Object.keys(c.attrs).length).map(c=>({...c,tag:c.tag&&c.tag!=="*"?c.tag:"div"}));return{tag:i,classes:a,attrs:o.attrs,ancestors:l}}function cn(e,t){let n="";for(let s of e)s.property.toLowerCase()===t&&(n=s.value.replace(/!important\s*$/i,"").trim());return n}function gt(e){let t=cn(e,"display");if(/^none\b/i.test(t))return"display: none";let n=cn(e,"visibility");if(/^(hidden|collapse)\b/i.test(n))return`visibility: ${n.split(/\s+/)[0].toLowerCase()}`;let s=cn(e,"opacity");return/^(0|0\.0+)$/.test(s)?"opacity: 0":null}function lr(e,t){return e===t||!ir(e)&&!ir(t)}function se(e,t){if(/[<>]|@import|expression\(|javascript:|behavior\s*:/i.test(t))return!1;for(let n of t.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi))if(!/^data:image\//i.test(n[2]))return!1;return/^-{0,2}[a-z][\w-]*$/i.test(e)}var aa=40,ee=(e,t)=>({path:e,line:t});function te(e,t,n,s){return{...e,status:t.length===0?"ok":"attention",summary:t.length===0?n:s(t.length),findings:t.slice(0,aa)}}function xe(e,t){return{...e,status:"na",summary:t,findings:[]}}var un=e=>e.state.split(" + ");function dr(e,t){if(!e.element||!t.element||e!==t&&!lr(e.path,t.path)||e.element.ancestors.length>0||e.element.tag!==t.element.tag)return!1;let n=new Set(t.element.classes);return e.element.classes.every(s=>n.has(s))?Object.entries(e.element.attrs).every(([s,r])=>t.element.attrs[s]===r):!1}function gr(e,t){return t.filter(n=>dr(n,e)).flatMap(n=>n.states)}function la(e,t,n){return gr(e,t).some(s=>un(s).includes(n))||t.filter(s=>dr(s,e)).some(s=>(s.parts??[]).some(r=>r.state.split(" + ").includes(n)))}var ca=[{state:"hover",severity:"issue"},{state:"focus",severity:"issue"},{state:"disabled",severity:"issue"},{state:"active",severity:"note"}];function ua(e){let t={id:"states",title:"Missing states",description:"Styles with no hover, focus, disabled, or active rule, counting rules they inherit from a shared base class."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let{state:r,severity:o}of ca){let i=n.filter(a=>!la(a,e.variants,r));i.length!==0&&s.push({severity:o,message:i.length===n.length?`No style defines a ${r} state.`:`${i.length} of ${n.length} styles have no ${r} state.`,styles:i.length===n.length?void 0:i.map(a=>a.title),refs:i.slice(0,6).map(a=>ee(a.path,a.line))})}return te(t,s,"Every style has hover, focus, disabled, and active rules.",r=>`${r} state${r===1?"":"s"} missing on some styles.`)}var cr=new Set(["outline","outline-style","outline-width"]),ur=/^(?:none|0|0px)(?:\s+(?:none|0|0px))*$/i,pa=/^(?:outline(?:-color|-width|-style)?|box-shadow|border(?:-[a-z]+)*|background(?:-color)?|text-decoration(?:-[a-z]+)?|color)$/;function fa(e){let t={id:"focus",title:"Focus indicator removed",description:"Styles that remove the outline and give keyboard focus nothing in its place."},n=e.variants.filter(r=>r.element&&r.element.ancestors.length===0);if(n.length===0)return xe(t,"No styles that can be drawn on their own.");let s=[];for(let r of n){let o=gr(r,e.variants),i=o.filter(l=>{let c=un(l);return c.includes("default")||c.includes("focus")}).flatMap(l=>l.declarations.map(c=>({s:l,d:c}))).find(({d:l})=>cr.has(l.property)&&ur.test(l.value.replace(/\s*!important/i,"")));!i||o.filter(l=>un(l).includes("focus")).some(l=>l.declarations.some(c=>pa.test(c.property)&&!(cr.has(c.property)&&ur.test(c.value))&&!/^(?:none|0|0px)$/i.test(c.value)&&!(c.property==="box-shadow"&&/^none$/i.test(c.value))))||s.push({severity:"issue",message:`${r.title} removes the outline (${i.d.property}: ${i.d.value}) and no focus rule replaces it.`,styles:[r.title],refs:[ee(r.path,i.s.line)]})}return te(t,s,"No style removes the outline without a focus replacement.",r=>`${r} style${r===1?"":"s"} lose the focus indicator.`)}function da(e){let t={id:"tokens",title:"Undefined tokens",description:`Custom properties the ${e.noun} styles read that no scanned stylesheet defines.`};if(e.tokens.length===0)return xe(t,`The ${e.noun} styles read no custom properties.`);let s=e.tokens.filter(r=>r.definedIn.length===0&&!r.name.startsWith("--tw-")).map(r=>{let o=e.variants.filter(i=>i.states.some(a=>a.declarations.some(l=>l.value.includes(`var(${r.name}`)||new RegExp(`var\\(\\s*${r.name}\\b`).test(l.value))));return{severity:"note",message:`${r.name} is read but never defined here. It may be set outside the scanned files (a framework, a theme provider).`,styles:o.slice(0,8).map(i=>i.title),refs:o.slice(0,3).map(i=>ee(i.path,i.line))}});return te(t,s,`All ${e.tokens.length} tokens read are defined.`,r=>`${r} token${r===1?"":"s"} with no definition.`)}var ga=/var\((?:[^()]|\([^()]*\))*\)/g,pr=/#[0-9a-f]{3,8}\b|\b(?:rgba?|hsla?)\([^)]*\)/gi,ma=/^(?:padding|margin|gap|row-gap|column-gap|height|min-height|max-height|border-radius|font-size|letter-spacing)(?:-[a-z]+)*$/,ha=/(?<![\w.-])(\d+(?:\.\d+)?)px\b/g;function fr(e){let t=e.trim().toLowerCase().replace(/\s+/g,""),n=/^#([0-9a-f]{3})$/.exec(t);return n?`#${[...n[1]].map(s=>s+s).join("")}`:t}function pn(e,t,n=0){return n>6?e:e.replace(/var\(\s*(--[\w-]+)\s*(?:,\s*([^)]*))?\)/g,(s,r,o)=>{let i=t.get(r);return i!==void 0?pn(i,t,n+1):o!==void 0?pn(o.trim(),t,n+1):s})}var ba=[[/^(?:padding|margin|gap|row-gap|column-gap)/,/space|spacing|gap|pad|inset|gutter/i],[/height$/,/height|control|size/i],[/^border-radius/,/radius|round|corner/i],[/^font-size$/,/text|font|size|type/i],[/^letter-spacing$/,/tracking|letter|spacing/i]];function ya(e,t){if(!t)return null;let n=ba.find(([s])=>s.test(e))?.[1];return t.find(s=>!n||n.test(s))??null}function xa(e){let t={id:"hardcoded",title:"Hard-coded values",description:`Raw colors, and pixel sizes that exactly match a token, written into ${e.noun} styles instead of using the token.`},n=new Map,s=new Map;for(let[o,i]of e.tokenValues){let a=pn(i,e.tokenValues).trim();if(new RegExp(`^(?:${pr.source})$`,"i").test(a)){let l=fr(a);n.set(l,[...n.get(l)??[],o])}else/^\d+(?:\.\d+)?px$/.test(a)&&s.set(a,[...s.get(a)??[],o])}if(n.size===0&&s.size===0)return xe(t,"No color or size tokens were found to compare against.");let r=[];for(let o of e.variants){let i=[],a=null;for(let c of o.states)for(let u of c.declarations){if(u.via)continue;let f=u.value.replace(ga," ");for(let m of f.matchAll(pr)){let h=n.get(fr(m[0]));i.push(h?`${m[0]} in ${u.property} is the value of ${h[0]}`:`${m[0]} in ${u.property} is not a token`),a??=c}if(ma.test(u.property))for(let m of f.matchAll(ha)){let h=ya(u.property,s.get(`${m[1]}px`));!h||Number(m[1])<=1||(i.push(`${m[1]}px in ${u.property} is the value of ${h}`),a??=c)}}if(i.length===0||!a)continue;let l=[...new Set(i)];r.push({severity:"issue",message:`${o.title}: ${l.slice(0,4).join("; ")}${l.length>4?`; and ${l.length-4} more`:""}.`,styles:[o.title],refs:[ee(o.path,a.line)]})}return te(t,r,`No ${e.noun} style hard-codes a value a token already has.`,o=>`${o} style${o===1?"":"s"} hard-code values.`)}function ka(e){let t={id:"unused",title:"Unused styles",description:"Styles defined in CSS that no component, page, or template references."},n=e.variants.filter(r=>r.element&&r.usage.status!=="unknown");if(n.length===0)return xe(t,"No styles with a class name to look for.");let s=[];for(let r of n)r.usage.status==="unreferenced"?s.push({severity:"issue",message:`${r.title} (${r.selector}) is defined but no reference to it was found.`,styles:[r.title],refs:[ee(r.path,r.line)]}):r.usage.status==="dynamic"&&s.push({severity:"note",message:`${r.title} (${r.selector}) is built at runtime and nothing selects it by value.`,styles:[r.title],refs:[ee(r.path,r.line),...r.usage.files.slice(0,2)]});return s.sort((r,o)=>+(o.severity==="issue")-+(r.severity==="issue")),te(t,s,`All ${n.length} styles are referenced.`,r=>`${r} style${r===1?"":"s"} unreferenced or unconfirmed.`)}function wa(e){let t={id:"duplicates",title:"Duplicate styles",description:"Different styles whose default declarations are identical."},n=new Map;for(let r of e.variants){if(!r.element)continue;let o=r.states.filter(a=>a.state==="default"&&a.context==="").flatMap(a=>a.declarations).map(a=>`${a.property}:${a.value.replace(/\s+/g," ").trim()}`);if(o.length<2)continue;let i=[...new Set(o)].sort().join(";");n.set(i,[...n.get(i)??[],r])}let s=[...n.values()].filter(r=>r.length>1).map(r=>({severity:"issue",message:`${r.map(o=>o.title).join(", ")} declare the same default styles (${r.map(o=>o.selector).join(", ")}).`,styles:r.map(o=>o.title),refs:r.map(o=>ee(o.path,o.line))}));return te(t,s,"No two styles share the same default declarations.",r=>`${r} group${r===1?"":"s"} of identical styles.`)}function va(e){let t={id:"native",title:`Native <${e.element}> instead of the component`,description:`Files that render a raw <${e.element}> although the repository has a shared ${e.element} component.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found, so native elements are expected.`);let n=e.nativeUses.map(s=>({severity:"issue",message:`${s.count} native <${e.element}> element${s.count===1?"":"s"} in ${s.path}.`,refs:[ee(s.path,s.line)]}));return te(t,n,`Every <${e.element}> goes through the component.`,s=>`${s} file${s===1?"":"s"} bypass the component.`)}function $a(e){let t={id:"props",title:"Prop values with no look",description:`Calls to a ${e.element} component with a literal prop value the component has no style for.`};if(!e.hasComponent)return xe(t,`No shared ${e.element} component was found.`);let n=(e.unknownProps??[]).map(s=>({severity:"issue",message:`<${s.component} ${s.prop}="${s.value}"> in ${s.path}: ${s.component} has no ${s.prop} "${s.value}" (it has ${s.known.join(", ")}).`,refs:[ee(s.path,s.line)]}));return te(t,n,"Every literal prop value picks a look the component has.",s=>`${s} call${s===1?"":"s"} ask for a look the component does not have.`)}function Ca(e){let t={id:"undocumented",title:"Styles without written guidance",description:"Styles that no instruction file or doc names, so nothing written says how they should be used."},{guidance:n}=e;if(n.files.length===0)return{...t,status:"attention",summary:`Nothing in the repository mentions ${e.noun}.`,findings:[{severity:"note",message:`No instruction file or doc says how ${e.noun} should look or be built.`,refs:[]}]};if(n.undocumented.length===0)return te(t,[],"Every style is named in written guidance.",()=>"");let s=e.variants.filter(r=>r.element&&n.undocumented.includes(r.title));return te(t,[{severity:"note",message:`${n.undocumented.length} of ${n.documented.length+n.undocumented.length} styles are named in no guidance.`,styles:n.undocumented,refs:s.slice(0,6).map(r=>ee(r.path,r.line))}],"",r=>`${r} finding${r===1?"":"s"}.`)}function mr(e){return[ua(e),fa(e),ka(e),wa(e),da(e),xa(e),va(e),$a(e),Ca(e)]}var Sa=/\.(erb|php|hbs|njk|liquid|twig|ejs|pug|cshtml|razor|jinja2?|j2)$/i,hr=/^<([A-Za-z][\w.-]*)\b((?:[^<>"'`{}]|"[^"]*"|'[^']*'|`[^`]*`|\{(?:[^{}]|\{[^{}]*\})*\})*)>/,Ra=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Aa=new Set(["span","svg","i","img","em","strong","small","b","p","kbd","abbr","sup","sub","picture","use","path"]),_a=new Set(["classNames","classnames","clsx","cn","cx"]),Ia=/^(?:ref|key|style|dangerouslySetInnerHTML)$/i;function xr(e,t){let n=1;for(let s=0;s<t&&s<e.length;s++)e[s]===`
|
|
40
40
|
`&&n++;return n}function br(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function kr(e){let t=e.filter(s=>s.trim()).map(s=>/^ */.exec(s)?.[0].length??0),n=t.length?Math.min(...t):0;return e.map(s=>{let r=s.slice(n);return r.length>200?`${r.slice(0,200)}\u2026`:r}).join(`
|
|
41
41
|
`)}function Ea(e,t,n){let s=Math.max(0,Math.min(t,e.length)),r=Math.max(s,Math.min(n,e.length)),o=xr(e,s),i=e.slice(s,r).split(`
|
|
42
42
|
`).slice(0,12),a=e.slice(s,r).split(`
|
|
@@ -119,7 +119,7 @@ ${Kn(Ot(s),r.id)}
|
|
|
119
119
|
`)}catch{process.stderr.write(`gruum: couldn't reach Gruum to report this check. The local result still stands.
|
|
120
120
|
`)}}async function qo(e,t,n){let s=await qn(e);if(!s)return{ok:!1,text:"Sign in with gruum login before requesting an exception."};let r=Mt(e.repoDir);if(!r)return{ok:!1,text:"This folder is not on a named git branch."};try{let o=await K(s.credentials,`/api/v2/cli/projects/${encodeURIComponent(s.project.id)}/drift`,{method:"POST",body:JSON.stringify({action:"request",concept:"button",branch:r,commit:zo(e.repoDir),reason:n,item:t})}),i=await o.json().catch(()=>({}));if(!o.ok){let c=i.error||`Request failed (${o.status}).`;return{ok:!1,text:o.status===404?`${c} Run \`npx @gruum/cli check\` so this folder points at a project that exists. Do not edit .gruum/project.json.`:c}}let a=i.reviewUrl?`${Ot(s.credentials)}${i.reviewUrl}`:"",l=i.created?`Exception request ${i.id} is pending review.`:`An exception for this change is already pending (${i.id}).`;return{ok:!0,text:a?`${l}
|
|
121
121
|
${a}`:l}}catch{return{ok:!1,text:"Couldn't reach Gruum to request an exception."}}}async function Xo(e,t){let n=await qn(e);if(!n)return{ok:!1,text:"Sign in with gruum login to see exception status."};let s=Mt(e.repoDir);try{let r=await K(n.credentials,`/api/v2/cli/projects/${encodeURIComponent(n.project.id)}/drift?concept=button&branch=${encodeURIComponent(s)}`);if(!r.ok)return{ok:!1,text:`Couldn't load exceptions (${r.status}).`};let o=await r.json(),i=Array.isArray(o.requests)?o.requests:[],a=t?i.filter(l=>l.id===t):i;return a.length===0?{ok:!0,text:t?`No exception request ${t} on ${s||"this branch"}.`:`No exception requests on ${s||"this branch"}.`}:{ok:!0,text:a.map(l=>`${l.id} ${l.status} ${l.title} (${l.branch})`).join(`
|
|
122
|
-
`)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Dt="0.2.
|
|
122
|
+
`)}}catch{return{ok:!1,text:"Couldn't reach Gruum to read exception status."}}}var Dt="0.2.4",Yo=`gruum ${Dt}: keep buttons on the Gruum spec
|
|
123
123
|
|
|
124
124
|
Run it as \`npx @gruum/cli <command>\`.
|
|
125
125
|
|