grab 0.0.92 → 0.0.93
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/chunk-EPG66EVR.cjs +94 -0
- package/dist/chunk-IJJ2JADU.js +94 -0
- package/dist/cli.cjs +1 -1
- package/dist/core/index.cjs +1 -0
- package/dist/{core.d.ts → core/index.d.cts} +1 -1
- package/dist/{core.d.cts → core/index.d.ts} +1 -1
- package/dist/{core.js → core/index.js} +1 -1
- package/dist/{core-Cb0zhigT.d.cts → index-DOGyzncb.d.cts} +4 -4
- package/dist/{core-Cb0zhigT.d.ts → index-DOGyzncb.d.ts} +4 -4
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.global.js +32 -30
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-LLVFRBHD.cjs +0 -92
- package/dist/chunk-Z3NRWZVJ.js +0 -92
- package/dist/core.cjs +0 -1
package/dist/cli.cjs
CHANGED
|
@@ -327,7 +327,7 @@ Run this command manually before starting your dev server:
|
|
|
327
327
|
)}`,h;a?h=i.replace(a[0],u):h=`${n}
|
|
328
328
|
${u}
|
|
329
329
|
${o}`;let l=t.replace(i,h);return {success:true,filePath:r,message:"Update React Grab options",originalContent:t,newContent:l}},Kw=(t,e,r)=>{let s=t.match(/import\s*\(\s*["']react-grab["']\s*\)/);if(!s)return {success:false,filePath:r,message:"Could not find React Grab import"};let n=`import("react-grab").then((m) => m.init(${fp(e)}))`,o=t.replace(s[0],n);return {success:true,filePath:r,message:"Update React Grab options",originalContent:t,newContent:o}},Yw=(t,e,r)=>{let s=t.match(/import\s*\(\s*["']react-grab["']\s*\)/);if(!s)return {success:false,filePath:r,message:"Could not find React Grab import"};let n=`import("react-grab").then((m) => m.init(${fp(e)}))`,o=t.replace(s[0],n);return {success:true,filePath:r,message:"Update React Grab options",originalContent:t,newContent:o}},Ms=(t,e,r,s)=>{let i=pp(t,e,r);if(!i)return {success:false,filePath:"",message:"Could not find file containing React Grab configuration"};let n=hf.readFileSync(i,"utf-8");if(!lr(n))return {success:false,filePath:i,message:"Could not find React Grab code in the file"};switch(e){case "next":return Ww(n,s,i);case "vite":return Kw(n,s,i);case "webpack":return Yw(n,s,i);default:return {success:false,filePath:i,message:`Unknown framework: ${e}`}}},Bs=t=>ke(t),Jw=(t,e,r)=>{let s=`@react-grab/${e}`;if(!t.includes(s))return {success:true,filePath:r,message:`Agent ${e} is not configured in this file`,noChanges:true};let i=new RegExp(`\\s*\\{process\\.env\\.NODE_ENV === "development" && \\(\\s*<Script[^>]*${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}[^>]*\\/>\\s*\\)\\}`,"gs"),n=new RegExp(`\\s*<Script[^>]*${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}[^>]*\\/>`,"gi"),o=t.replace(i,"");return o===t&&(o=t.replace(n,"")),o===t?{success:false,filePath:r,message:`Could not find agent ${e} script to remove`}:{success:true,filePath:r,message:`Remove ${e} agent`,originalContent:t,newContent:o}},zw=(t,e,r)=>{let s=`@react-grab/${e}`;if(!t.includes(s))return {success:true,filePath:r,message:`Agent ${e} is not configured in this file`,noChanges:true};let i=new RegExp(`\\s*import\\s*\\(\\s*["']${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/client["']\\s*\\);?`,"g"),n=t.replace(i,"");return n===t?{success:false,filePath:r,message:`Could not find agent ${e} import to remove`}:{success:true,filePath:r,message:`Remove ${e} agent`,originalContent:t,newContent:n}},Xw=(t,e,r)=>{let s=`@react-grab/${e}`;if(!t.includes(s))return {success:true,filePath:r,message:`Agent ${e} is not configured in this file`,noChanges:true};let i=new RegExp(`\\s*import\\s*\\(\\s*["']${s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}/client["']\\s*\\);?`,"g"),n=t.replace(i,"");return n===t?{success:false,filePath:r,message:`Could not find agent ${e} import to remove`}:{success:true,filePath:r,message:`Remove ${e} agent`,originalContent:t,newContent:n}},Ht=(t,e,r,s)=>{let i=pp(t,e,r);if(!i)return {success:true,filePath:"",message:"Could not find file containing React Grab configuration",noChanges:true};let n=hf.readFileSync(i,"utf-8");switch(e){case "next":return Jw(n,s,i);case "vite":return zw(n,s,i);case "webpack":return Xw(n,s,i);default:return {success:false,filePath:i,message:`Unknown framework: ${e}`}}},qt=(t,e)=>{let r=kt.join(t,"package.json");if(!hf.existsSync(r))return {success:true,filePath:"",message:"Could not find package.json",noChanges:true};let s=hf.readFileSync(r,"utf-8"),i=ma(e);if(i.length===0)return {success:true,filePath:r,message:`Unknown agent: ${e}`,noChanges:true};if(!i.some(o=>s.includes(o)))return {success:true,filePath:r,message:`Agent ${e} dev script is not configured`,noChanges:true};try{let o=JSON.parse(s);for(let u of Object.keys(o.scripts||{})){let h=o.scripts[u];if(typeof h=="string"){for(let l of i)h.includes(l)&&(h=h.replace(l+" ","").replace(l,""));o.scripts[u]=h;}}let a=JSON.stringify(o,null,2)+`
|
|
330
|
-
`;return {success:!0,filePath:r,message:`Remove ${e} server from dev script`,originalContent:s,newContent:a}}catch{return {success:false,filePath:r,message:"Failed to parse package.json"}}};var Zw="0.0.92",Ae={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp","visual-edit":"Visual Edit"},mp=new Te().name("add").description("add an agent integration").argument("[agent]","agent to add (claude-code, cursor, opencode, codex, gemini, amp, visual-edit)").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async(t,e)=>{console.log(`${Ns.default.magenta("\u273F")} ${Ns.default.bold("React Grab")} ${Ns.default.gray(Zw)}`),console.log();try{let r=e.cwd,s=e.yes,i=M("Preflight checks.").start(),n=await pt(r);n.hasReactGrab||(i.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),i.succeed();let o=["claude-code","cursor","opencode","codex","gemini","amp","visual-edit"],a=o.filter(D=>!n.installedAgents.includes(D));a.length===0&&(p.break(),p.success("All agent integrations are already installed."),p.break(),process.exit(0));let u,h=[];if(t){if(o.includes(t)||(p.break(),p.error(`Invalid agent: ${t}`),p.error("Available agents: claude-code, cursor, opencode, codex, gemini, amp, visual-edit"),p.break(),process.exit(1)),n.installedAgents.includes(t)&&(p.break(),p.warn(`${Ae[t]} is already installed.`),p.break(),process.exit(0)),u=t,n.installedAgents.length>0&&!s){let D=n.installedAgents.map(b=>Ae[b]||b).join(", ");p.break(),p.warn(`${D} is already installed.`);let{action:x}=await(0,qr.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace with ${Ae[u]}`,value:"replace"},{title:`Add ${Ae[u]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!x||x==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),x==="replace"&&(h=[...n.installedAgents]);}}else if(s)p.break(),p.error("Please specify an agent to add."),p.error("Available agents: "+a.join(", ")),p.break(),process.exit(1);else {if(p.break(),n.installedAgents.length>0){let x=n.installedAgents.map(b=>Ae[b]||b).join(", ");p.warn(`Currently installed: ${x}`),p.break();}let{agent:D}=await(0,qr.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to add?`,choices:a.map(x=>({title:Ae[x],value:x}))});if(D||(p.break(),process.exit(1)),u=D,n.installedAgents.length>0){let x=n.installedAgents.map(v=>Ae[v]||v).join(", "),{action:b}=await(0,qr.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${x} with ${Ae[u]}`,value:"replace"},{title:`Add ${Ae[u]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!b||b==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),b==="replace"&&(h=[...n.installedAgents]);}}if(h.length>0){for(let D of h){let x=Ht(n.projectRoot,n.framework,n.nextRouterType,D),b=qt(n.projectRoot,D),v=Mt(D);if(v.length>0){let C=M(`Removing ${v.join(", ")}.`).start();try{It(v,n.packageManager,n.projectRoot),C.succeed();}catch(E){C.fail(),me(E);}}if(x.success&&!x.noChanges&&x.newContent){let C=M(`Removing ${Ae[D]||D} from ${x.filePath}.`).start(),E=ke(x);E.success||(C.fail(),p.break(),p.error(E.error||"Failed to write file."),p.break(),process.exit(1)),C.succeed();}if(b.success&&!b.noChanges&&b.newContent){let C=M(`Removing ${Ae[D]||D} from ${b.filePath}.`).start(),E=Ue(b);E.success||(C.fail(),p.break(),p.error(E.error||"Failed to write file."),p.break(),process.exit(1)),C.succeed();}}n.installedAgents=n.installedAgents.filter(D=>!h.includes(D));}M(`Adding ${Ae[u]}.`).start().succeed();let c=Nr(n.projectRoot,n.framework,n.nextRouterType,u,!0),d=Hr(n.projectRoot,u,n.installedAgents,n.packageManager);c.success||(p.break(),p.error(c.message),p.break(),process.exit(1));let f=!c.noChanges&&c.originalContent&&c.newContent,m=d.success&&!d.noChanges&&d.originalContent&&d.newContent;if((f||m)&&(p.break(),f&&we(c.filePath,c.originalContent,c.newContent),m&&(f&&p.break(),we(d.filePath,d.originalContent,d.newContent)),!s&&h.length===0)){p.break();let{proceed:D}=await(0,qr.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});D||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}let g=nr(u,!1);if(g.length>0){let D=M(`Installing ${g.join(", ")}.`).start();try{ir(g,n.packageManager,n.projectRoot),D.succeed();}catch(x){D.fail(),me(x);}}if(f){let D=M(`Applying changes to ${c.filePath}.`).start(),x=ke(c);x.success||(D.fail(),p.break(),p.error(x.error||"Failed to write file."),p.break(),process.exit(1)),D.succeed();}if(m){let D=M(`Applying changes to ${d.filePath}.`).start(),x=Ue(d);x.success||(D.fail(),p.break(),p.error(x.error||"Failed to write file."),p.break(),process.exit(1)),D.succeed();}p.break(),p.log(`${$.success("Success!")} ${Ae[u]} has been added.`),d.warning?p.warn(d.warning):p.log("Make sure to start the agent server before using it."),p.break();}catch(r){me(r);}});var qs=be(Ot()),gt=be(er());var Qw="0.0.92",Hs={metaKey:process.platform==="darwin"?"\u2318 Command":"\u229E Windows",ctrlKey:"Ctrl",shiftKey:"Shift",altKey:process.platform==="darwin"?"\u2325 Option":"Alt"},ex=t=>{if(!t)return "Default (Option/Alt)";let e=[];return t.metaKey&&e.push(process.platform==="darwin"?"\u2318":"Win"),t.ctrlKey&&e.push("Ctrl"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push(process.platform==="darwin"?"\u2325":"Alt"),t.key&&e.push(t.key.toUpperCase()),e.length>0?e.join(" + "):"Default (Option/Alt)"},gp=new Te().name("configure").alias("config").description("configure React Grab options").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async t=>{console.log(`${qs.default.magenta("\u273F")} ${qs.default.bold("React Grab")} ${qs.default.gray(Qw)}`),console.log();try{let e=t.cwd,r=t.yes,s=M("Preflight checks.").start(),i=await pt(e);i.hasReactGrab||(s.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),s.succeed(),r&&(p.break(),p.error("Configure command requires interactive mode."),p.error("Remove the --yes flag to use interactive prompts."),p.break(),process.exit(1)),p.break(),p.log(`Configure ${$.info("React Grab")} options:`),p.break();let n={},{wantActivationKey:o}=await(0,gt.default)({type:"confirm",name:"wantActivationKey",message:`Configure ${$.info("activation key")}?`,initial:!1});if(o===void 0&&(p.break(),process.exit(1)),o){let{key:d}=await(0,gt.default)({type:"text",name:"key",message:"Enter the activation key (e.g., g, k, space):",initial:""});d===void 0&&(p.break(),process.exit(1));let{modifiers:f}=await(0,gt.default)({type:"multiselect",name:"modifiers",message:"Select modifier keys (space to select, enter to confirm):",choices:[{title:Hs.metaKey,value:"metaKey"},{title:Hs.ctrlKey,value:"ctrlKey"},{title:Hs.shiftKey,value:"shiftKey"},{title:Hs.altKey,value:"altKey",selected:!0}],hint:"- Space to select, Enter to confirm"});f===void 0&&(p.break(),process.exit(1)),n.activationKey={...d&&{key:d.toLowerCase()},...f.includes("metaKey")&&{metaKey:!0},...f.includes("ctrlKey")&&{ctrlKey:!0},...f.includes("shiftKey")&&{shiftKey:!0},...f.includes("altKey")&&{altKey:!0}},p.log(` Activation key: ${$.info(ex(n.activationKey))}`);}let{activationMode:a}=await(0,gt.default)({type:"select",name:"activationMode",message:`Select ${$.info("activation mode")}:`,choices:[{title:"Toggle (press to activate/deactivate)",value:"toggle"},{title:"Hold (hold key to keep active)",value:"hold"}],initial:0});if(a===void 0&&(p.break(),process.exit(1)),n.activationMode=a,a==="hold"){let{keyHoldDuration:d}=await(0,gt.default)({type:"number",name:"keyHoldDuration",message:`Enter ${$.info("key hold duration")} in milliseconds:`,initial:150,min:0,max:2e3});d===void 0&&(p.break(),process.exit(1)),n.keyHoldDuration=d;}let{allowActivationInsideInput:u}=await(0,gt.default)({type:"confirm",name:"allowActivationInsideInput",message:`Allow activation ${$.info("inside input fields")}?`,initial:!0});u===void 0&&(p.break(),process.exit(1)),n.allowActivationInsideInput=u;let{maxContextLines:h}=await(0,gt.default)({type:"number",name:"maxContextLines",message:`Enter ${$.info("max context lines")} to include:`,initial:3,min:0,max:50});h===void 0&&(p.break(),process.exit(1)),n.maxContextLines=h;let l=Ms(i.projectRoot,i.framework,i.nextRouterType,n);if(l.success||(p.break(),p.error(l.message),p.break(),process.exit(1)),!l.noChanges&&l.originalContent&&l.newContent){p.break(),we(l.filePath,l.originalContent,l.newContent),p.break();let{proceed:d}=await(0,gt.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});d||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));let f=M(`Applying changes to ${l.filePath}.`).start(),m=Bs(l);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}else p.break(),p.log("No changes needed.");p.break(),p.log(`${$.success("Success!")} React Grab options have been configured.`),p.break();}catch(e){me(e);}});var Gs=be(Ot()),ce=be(er());var bp="0.0.92",tx="https://react-grab.com/api/report-cli",Ls="https://github.com/aidenybai/react-grab",Dp=async(t,e,r)=>{try{await fetch(tx,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,version:bp,config:e,error:r?{message:r.message,stack:r.stack}:void 0,timestamp:new Date().toISOString()})}).catch(()=>{});}catch{}},ga={next:"Next.js",vite:"Vite",webpack:"Webpack",unknown:"Unknown"},rx={npm:"npm",yarn:"Yarn",pnpm:"pnpm",bun:"Bun"},sx={remix:"Remix",astro:"Astro",sveltekit:"SvelteKit",gatsby:"Gatsby"},de={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp",ami:"Ami","visual-edit":"Visual Edit"},js={metaKey:process.platform==="darwin"?"\u2318 Command":"\u229E Windows",ctrlKey:"Ctrl",shiftKey:"Shift",altKey:process.platform==="darwin"?"\u2325 Option":"Alt"},ix=t=>{if(!t)return "Default (Option/Alt)";let e=[];return t.metaKey&&e.push(process.platform==="darwin"?"\u2318":"Win"),t.ctrlKey&&e.push("Ctrl"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push(process.platform==="darwin"?"\u2325":"Alt"),t.key&&e.push(t.key.toUpperCase()),e.length>0?e.join(" + "):"Default (Option/Alt)"},yp=new Te().name("init").description("initialize React Grab in your project").option("-y, --yes","skip confirmation prompts",false).option("-f, --force","force overwrite existing config",false).option("-a, --agent <agent>","agent integration (claude-code, cursor, opencode, codex, gemini, amp, visual-edit)").option("--skip-install","skip package installation",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async t=>{console.log(`${Gs.default.magenta("\u273F")} ${Gs.default.bold("React Grab")} ${Gs.default.gray(bp)}`),console.log();try{let e=t.cwd,r=t.yes,s=M("Preflight checks.").start(),i=await pt(e);if(i.hasReactGrab&&!t.force){s.succeed(),r&&(p.break(),p.warn("React Grab is already installed."),p.log(`Use ${$.info("--force")} to reconfigure, or remove ${$.info("--yes")} for interactive mode.`),p.break(),process.exit(0)),p.break(),p.success("React Grab is already installed."),p.break();let v=["claude-code","cursor","opencode","codex","gemini","amp","visual-edit"].filter(R=>!i.installedAgents.includes(R));if(i.installedAgents.length>0){let R=i.installedAgents.map(k=>de[k]||k).join(", ");p.log(`Currently installed agents: ${$.info(R)}`),p.break();}let C=!1;if(v.length>0){let{wantAddAgent:R}=await(0,ce.default)({type:"confirm",name:"wantAddAgent",message:`Would you like to add an ${$.info("agent integration")}?`,initial:!0});if(R===void 0&&(p.break(),process.exit(1)),R){let{agent:k}=await(0,ce.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to add?`,choices:v.map(U=>({title:de[U],value:U}))});k===void 0&&(p.break(),process.exit(1));let A=k,T=[];if(i.installedAgents.length>0){let U=i.installedAgents.map(B=>de[B]||B).join(", "),{action:F}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${U} with ${de[A]}`,value:"replace"},{title:`Add ${de[A]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});if(!F||F==="cancel")p.break(),p.log("Agent addition cancelled.");else {if(F==="replace"&&(T=[...i.installedAgents]),T.length>0){for(let w of T){let G=Ht(i.projectRoot,i.framework,i.nextRouterType,w),P=qt(i.projectRoot,w),ne=Mt(w);if(ne.length>0){let ue=M(`Removing ${ne.join(", ")}.`).start();try{It(ne,i.packageManager,i.projectRoot),ue.succeed();}catch(oe){ue.fail(),me(oe);}}if(G.success&&!G.noChanges&&G.newContent){let ue=M(`Removing ${de[w]||w} from ${G.filePath}.`).start(),oe=ke(G);oe.success||(ue.fail(),p.break(),p.error(oe.error||"Failed to write file."),p.break(),process.exit(1)),ue.succeed();}if(P.success&&!P.noChanges&&P.newContent){let ue=M(`Removing ${de[w]||w} from ${P.filePath}.`).start(),oe=Ue(P);oe.success||(ue.fail(),p.break(),p.error(oe.error||"Failed to write file."),p.break(),process.exit(1)),ue.succeed();}}i.installedAgents=i.installedAgents.filter(w=>!T.includes(w));}let B=Nr(i.projectRoot,i.framework,i.nextRouterType,A,!0),I=Hr(i.projectRoot,A,i.installedAgents,i.packageManager);B.success||(p.break(),p.error(B.message),p.break(),process.exit(1));let ee=!B.noChanges&&B.originalContent&&B.newContent,_=I.success&&!I.noChanges&&I.originalContent&&I.newContent;if(ee||_)if(p.break(),ee&&we(B.filePath,B.originalContent,B.newContent),_&&(ee&&p.break(),we(I.filePath,I.originalContent,I.newContent)),T.length===0){p.break();let{proceed:w}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});if(!w)p.break(),p.log("Agent addition cancelled.");else {let G=nr(A,!1);if(G.length>0){let P=M(`Installing ${G.join(", ")}.`).start();try{ir(G,i.packageManager,i.projectRoot),P.succeed();}catch(ne){P.fail(),me(ne);}}if(ee){let P=M(`Applying changes to ${B.filePath}.`).start(),ne=ke(B);ne.success||(P.fail(),p.break(),p.error(ne.error||"Failed to write file."),p.break(),process.exit(1)),P.succeed();}if(_){let P=M(`Applying changes to ${I.filePath}.`).start(),ne=Ue(I);ne.success||(P.fail(),p.break(),p.error(ne.error||"Failed to write file."),p.break(),process.exit(1)),P.succeed();}C=!0,p.break(),p.success(`${de[A]} has been added.`);}}else {let w=nr(A,!1);if(w.length>0){let G=M(`Installing ${w.join(", ")}.`).start();try{ir(w,i.packageManager,i.projectRoot),G.succeed();}catch(P){G.fail(),me(P);}}if(ee){let G=M(`Applying changes to ${B.filePath}.`).start(),P=ke(B);P.success||(G.fail(),p.break(),p.error(P.error||"Failed to write file."),p.break(),process.exit(1)),G.succeed();}if(_){let G=M(`Applying changes to ${I.filePath}.`).start(),P=Ue(I);P.success||(G.fail(),p.break(),p.error(P.error||"Failed to write file."),p.break(),process.exit(1)),G.succeed();}C=!0,p.break(),p.success(`${de[A]} has been added.`);}}}}}else p.log("All agent integrations are already installed.");p.break();let{wantCustomizeOptions:E}=await(0,ce.default)({type:"confirm",name:"wantCustomizeOptions",message:`Would you like to customize ${$.info("options")}?`,initial:!1});if(E===void 0&&(p.break(),process.exit(1)),E){p.break(),p.log(`Configure ${$.info("React Grab")} options:`),p.break();let R={},{wantActivationKey:k}=await(0,ce.default)({type:"confirm",name:"wantActivationKey",message:`Configure ${$.info("activation key")}?`,initial:!1});if(k===void 0&&(p.break(),process.exit(1)),k){let{key:I}=await(0,ce.default)({type:"text",name:"key",message:"Enter the activation key (e.g., g, k, space):",initial:""});I===void 0&&(p.break(),process.exit(1));let{modifiers:ee}=await(0,ce.default)({type:"multiselect",name:"modifiers",message:"Select modifier keys (space to select, enter to confirm):",choices:[{title:js.metaKey,value:"metaKey"},{title:js.ctrlKey,value:"ctrlKey"},{title:js.shiftKey,value:"shiftKey"},{title:js.altKey,value:"altKey",selected:!0}],hint:"- Space to select, Enter to confirm"});ee===void 0&&(p.break(),process.exit(1)),R.activationKey={...I&&{key:I.toLowerCase()},...ee.includes("metaKey")&&{metaKey:!0},...ee.includes("ctrlKey")&&{ctrlKey:!0},...ee.includes("shiftKey")&&{shiftKey:!0},...ee.includes("altKey")&&{altKey:!0}},p.log(` Activation key: ${$.info(ix(R.activationKey))}`);}let{activationMode:A}=await(0,ce.default)({type:"select",name:"activationMode",message:`Select ${$.info("activation mode")}:`,choices:[{title:"Toggle (press to activate/deactivate)",value:"toggle"},{title:"Hold (hold key to keep active)",value:"hold"}],initial:0});if(A===void 0&&(p.break(),process.exit(1)),R.activationMode=A,A==="hold"){let{keyHoldDuration:I}=await(0,ce.default)({type:"number",name:"keyHoldDuration",message:`Enter ${$.info("key hold duration")} in milliseconds:`,initial:150,min:0,max:2e3});I===void 0&&(p.break(),process.exit(1)),R.keyHoldDuration=I;}let{allowActivationInsideInput:T}=await(0,ce.default)({type:"confirm",name:"allowActivationInsideInput",message:`Allow activation ${$.info("inside input fields")}?`,initial:!0});T===void 0&&(p.break(),process.exit(1)),R.allowActivationInsideInput=T;let{maxContextLines:U}=await(0,ce.default)({type:"number",name:"maxContextLines",message:`Enter ${$.info("max context lines")} to include:`,initial:3,min:0,max:50});U===void 0&&(p.break(),process.exit(1)),R.maxContextLines=U;let F=Ms(i.projectRoot,i.framework,i.nextRouterType,R);if(F.success||(p.break(),p.error(F.message),p.break(),process.exit(1)),!F.noChanges&&F.originalContent&&F.newContent){p.break(),we(F.filePath,F.originalContent,F.newContent),p.break();let{proceed:I}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});if(!I)p.break(),p.log("Options configuration cancelled.");else {let ee=M(`Applying changes to ${F.filePath}.`).start(),_=Bs(F);_.success||(ee.fail(),p.break(),p.error(_.error||"Failed to write file."),p.break(),process.exit(1)),ee.succeed(),p.break(),p.success("React Grab options have been configured.");}}else p.break(),p.log("No option changes needed.");}!C&&!E&&(p.break(),p.log("No changes made.")),p.break(),process.exit(0);}s.succeed();let n=M("Verifying framework.").start();if(i.unsupportedFramework){let b=sx[i.unsupportedFramework];n.fail(`Found ${$.info(b)}.`),p.break(),p.log(`${b} is not yet supported by automatic setup.`),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);}if(i.framework==="unknown")if(i.isMonorepo&&!r){n.info("Verifying framework. Found monorepo.");let v=Ef(i.projectRoot).filter(C=>C.hasReact||C.framework!=="unknown");if(v.length>0){p.break();let C=[...v].sort((A,T)=>A.framework==="unknown"&&T.framework!=="unknown"?1:A.framework!=="unknown"&&T.framework==="unknown"?-1:0),{selectedProject:E}=await(0,ce.default)({type:"select",name:"selectedProject",message:"Select a project to install React Grab:",choices:C.map(A=>{let T=A.framework!=="unknown"?` ${$.dim(`(${ga[A.framework]})`)}`:"";return {title:`${A.name}${T}`,value:A.path}})});E||(p.break(),process.exit(1)),process.chdir(E);let R=await pt(E);Object.assign(i,R),M("Verifying framework.").start().succeed(`Verifying framework. Found ${$.info(ga[R.framework])}.`);}else n.fail("Could not detect a supported framework."),p.break(),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);}else n.fail("Could not detect a supported framework."),p.break(),p.log("React Grab supports Next.js, Vite, and Webpack projects."),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);else n.succeed(`Verifying framework. Found ${$.info(ga[i.framework])}.`);i.framework==="next"&&M("Detecting router type.").start().succeed(`Detecting router type. Found ${$.info(i.nextRouterType==="app"?"App Router":"Pages Router")}.`),M("Detecting package manager.").start().succeed(`Detecting package manager. Found ${$.info(rx[i.packageManager])}.`);let a=i.framework,u=i.packageManager,h=i.nextRouterType,l=t.agent||"none",c=[];if(!r&&!t.agent){if(p.break(),t.force&&i.installedAgents.length>0){let v=i.installedAgents.map(C=>de[C]||C).join(", ");p.warn(`Currently installed: ${v}`),p.break();}let{agent:b}=await(0,ce.default)({type:"select",name:"agent",message:`Would you like to add an ${$.info("agent integration")}?`,choices:[{title:"None",value:"none"},{title:"Claude Code",value:"claude-code"},{title:"Cursor",value:"cursor"},{title:"OpenCode",value:"opencode"},{title:"Codex",value:"codex"},{title:"Gemini",value:"gemini"},{title:"Amp",value:"amp"},{title:"Visual Edit",value:"visual-edit"}]});if(b===void 0&&(p.break(),process.exit(1)),l=b,t.force&&i.installedAgents.length>0&&l!=="none"&&!i.installedAgents.includes(l)){let v=i.installedAgents.map(E=>de[E]||E).join(", "),{action:C}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${v} with ${de[l]}`,value:"replace"},{title:`Add ${de[l]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!C||C==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),C==="replace"&&(c=[...i.installedAgents]);}}else if(t.agent&&t.force&&i.installedAgents.length>0&&!i.installedAgents.includes(t.agent)&&!r){let b=i.installedAgents.map(C=>de[C]||C).join(", ");p.break(),p.warn(`Currently installed: ${b}`);let{action:v}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${b} with ${de[l]}`,value:"replace"},{title:`Add ${de[l]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!v||v==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),v==="replace"&&(c=[...i.installedAgents]);}let d=Nr(i.projectRoot,a,h,l,!1),f=Hr(i.projectRoot,l,i.installedAgents,u);d.success||(p.break(),p.error(d.message),p.error(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1));let m=!d.noChanges&&d.originalContent&&d.newContent,g=f.success&&!f.noChanges&&f.originalContent&&f.newContent;if((m||g)&&(p.break(),m&&we(d.filePath,d.originalContent,d.newContent),g&&(m&&p.break(),we(f.filePath,f.originalContent,f.newContent)),p.break(),p.warn("Auto-detection may not be 100% accurate."),p.warn("Please verify the changes before committing."),!r)){p.break();let{proceed:b}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});b||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}if(c.length>0){for(let b of c){let v=Ht(i.projectRoot,i.framework,i.nextRouterType,b),C=qt(i.projectRoot,b),E=Mt(b);if(E.length>0&&!t.skipInstall){let R=M(`Removing ${E.join(", ")}.`).start();try{It(E,u,i.projectRoot),R.succeed();}catch(k){R.fail(),me(k);}}if(v.success&&!v.noChanges&&v.newContent){let R=M(`Removing ${de[b]||b} from ${v.filePath}.`).start(),k=ke(v);k.success||(R.fail(),p.break(),p.error(k.error||"Failed to write file."),p.break(),process.exit(1)),R.succeed();}if(C.success&&!C.noChanges&&C.newContent){let R=M(`Removing ${de[b]||b} from ${C.filePath}.`).start(),k=Ue(C);k.success||(R.fail(),p.break(),p.error(k.error||"Failed to write file."),p.break(),process.exit(1)),R.succeed();}}i.installedAgents=i.installedAgents.filter(b=>!c.includes(b));}let D=!i.hasReactGrab,x=l!=="none"&&!i.installedAgents.includes(l);if(!t.skipInstall&&(D||x)){let b=nr(l,D);if(b.length>0){let v=M(`Installing ${b.join(", ")}.`).start();try{ir(b,u,i.projectRoot),v.succeed();}catch(C){v.fail(),me(C);}}}if(m){let b=M(`Applying changes to ${d.filePath}.`).start(),v=ke(d);v.success||(b.fail(),p.break(),p.error(v.error||"Failed to write file."),p.break(),process.exit(1)),b.succeed();}if(g){let b=M(`Applying changes to ${f.filePath}.`).start(),v=Ue(f);v.success||(b.fail(),p.break(),p.error(v.error||"Failed to write file."),p.break(),process.exit(1)),b.succeed();}p.break(),p.log(`${$.success("Success!")} React Grab has been installed.`),f.warning?(p.break(),p.warn(f.warning),p.break()):p.log("You may now start your development server."),p.break(),await Dp("completed",{framework:a,packageManager:u,router:h,agent:l!=="none"?l:void 0,isMonorepo:i.isMonorepo});}catch(e){me(e),await Dp("error",void 0,e);}});var Us=be(Ot()),Da=be(er());var nx="0.0.92",Vs={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp",ami:"Ami","visual-edit":"Visual Edit"},vp=new Te().name("remove").description("remove an agent integration").argument("[agent]","agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, visual-edit)").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async(t,e)=>{console.log(`${Us.default.magenta("\u273F")} ${Us.default.bold("React Grab")} ${Us.default.gray(nx)}`),console.log();try{let r=e.cwd,s=e.yes,i=M("Preflight checks.").start(),n=await pt(r);n.hasReactGrab||(i.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),n.installedAgents.length===0&&(i.succeed(),p.break(),p.warn("No agent integrations are installed."),p.break(),process.exit(0)),i.succeed();let o;if(t)n.installedAgents.includes(t)||(p.break(),p.error(`Agent ${$.info(t)} is not installed.`),p.log(`Installed agents: ${n.installedAgents.map(f=>Vs[f]||f).join(", ")}`),p.break(),process.exit(1)),o=t;else if(s)p.break(),p.error("Please specify an agent to remove."),p.error("Installed agents: "+n.installedAgents.join(", ")),p.break(),process.exit(1);else {p.break();let{agent:f}=await(0,Da.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to remove?`,choices:n.installedAgents.map(m=>({title:Vs[m]||m,value:m}))});f||(p.break(),process.exit(1)),o=f;}M(`Preparing to remove ${Vs[o]||o}.`).start().succeed();let u=Ht(n.projectRoot,n.framework,n.nextRouterType,o),h=qt(n.projectRoot,o),l=u.success&&!u.noChanges&&u.originalContent&&u.newContent,c=h.success&&!h.noChanges&&h.originalContent&&h.newContent;if((l||c)&&(p.break(),l&&we(u.filePath,u.originalContent,u.newContent),c&&(l&&p.break(),we(h.filePath,h.originalContent,h.newContent)),!s)){p.break();let{proceed:f}=await(0,Da.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});f||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}let d=Mt(o);if(d.length>0){let f=M(`Removing ${d.join(", ")}.`).start();try{It(d,n.packageManager,n.projectRoot),f.succeed();}catch(m){f.fail(),me(m);}}if(l){let f=M(`Applying changes to ${u.filePath}.`).start(),m=ke(u);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}if(c){let f=M(`Applying changes to ${h.filePath}.`).start(),m=Ue(h);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}p.break(),p.log(`${$.success("Success!")} ${Vs[o]||o} has been removed.`),p.break();}catch(r){me(r);}});var Ci=be(Ot()),wi=be(rD()),wu=be(er());var LE="0.0.92",sD=2e3,iD='<script src="https://unpkg.com/react-grab/dist/index.global.js"></script>',jE=t=>`<script src="https://unpkg.com/${t}/dist/client.global.js"></script>`,oD=async(t,e)=>new Promise(r=>{let s=http.createServer();s.listen(t,e,()=>{s.close(()=>r(t));}),s.on("error",()=>{r(oD(t+1,e));});}),GE=t=>t.startsWith("http://")||t.startsWith("https://")?t:`http://${t}`,VE=async t=>{try{return (await fetch(t,{method:"HEAD",redirect:"follow"})).url}catch{return t}},aD=new Te().name("start").alias("proxy").description("start a proxy server for a given URL").argument("[url]","target URL to proxy (e.g., localhost:3000)").option("-p, --port <port>","starting port for the proxy server",String(sD)).option("--host <hostname>","hostname to bind the proxy server to","localhost").option("--provider <package>","provider package to run via npx (e.g., @react-grab/cursor)").action(async(t,e)=>{console.log(`${Ci.default.magenta("\u273F")} ${Ci.default.bold("React Grab")} ${Ci.default.gray(LE)}`),console.log();let r=t,s=e.provider;if(!r){let{targetUrl:b}=await(0, wu.default)({type:"text",name:"targetUrl",message:"Enter the target URL to proxy:",initial:"localhost:3000"});if(b||(p.break(),process.exit(1)),r=b,!s){let{selectedProvider:v}=await(0, wu.default)({type:"select",name:"selectedProvider",message:`Select a ${$.info("provider")} to use:`,choices:[{title:"None",value:""},{title:"Claude Code",value:"@react-grab/claude-code"},{title:"Cursor",value:"@react-grab/cursor"},{title:"OpenCode",value:"@react-grab/opencode"},{title:"Codex",value:"@react-grab/codex"},{title:"Gemini",value:"@react-grab/gemini"},{title:"Amp",value:"@react-grab/amp"},{title:"Visual Edit",value:"@react-grab/visual-edit"}]});v===void 0&&(p.break(),process.exit(1)),s=v||void 0;}p.break();}let i=GE(r),n=await VE(i),o=parseInt(e.port,10),a=e.host||"localhost";(isNaN(o)||o<1||o>65535)&&(p.break(),p.error("Invalid port number. Please provide a port between 1 and 65535."),p.break(),process.exit(1));let u=await oD(o,a),h=s?iD+jE(s):iD,l=b=>{let v=b.indexOf("</head>");if(v!==-1)return b.slice(0,v)+h+b.slice(v);let C=b.indexOf("</body>");return C!==-1?b.slice(0,C)+h+b.slice(C):b+h},c=(0, wi.createProxyMiddleware)({target:n,changeOrigin:true,followRedirects:false,ws:true,selfHandleResponse:true,cookieDomainRewrite:{"*":""},autoRewrite:true,preserveHeaderKeyCase:true,xfwd:true,on:{error:(b,v,C)=>{"writeHead"in C&&!C.headersSent&&(C.writeHead(503,{"Content-Type":"text/plain"}),C.end(`Proxy error: Unable to connect to ${n}`));},proxyReq:b=>{b.removeHeader("accept-encoding");},proxyRes:(0, wi.responseInterceptor)(async(b,v,C,E)=>{if(E.removeHeader("content-security-policy"),E.removeHeader("content-security-policy-report-only"),!(v.headers["content-type"]||"").includes("text/html"))return b;let A=b.toString("utf-8");return l(A)})}}),d=http.createServer((b,v)=>{c(b,v,C=>{C&&(p.error(`Request error: ${C}`),v.writeHead(500),v.end("Internal Server Error"));});});d.on("upgrade",c.upgrade);let f=M("Starting.").start(),m=()=>{f.succeed(`Open in your browser: http://${a}:${u}`);let b=["npx react-grab@latest start",r];e.port!==String(sD)&&b.push(`--port=${e.port}`),a!=="localhost"&&b.push(`--host=${a}`),s&&b.push(`--provider=${s}`),p.break(),p.log($.dim(`$ ${b.join(" ")}`));},g=false,D=!s,x=()=>{g&&D&&m();};if(d.listen(u,a,()=>{g=true,x();}),s){let b=child_process.spawn("npx",[`${s}@latest`],{stdio:"ignore",shell:true,detached:false}),v=()=>{b.killed||b.kill();};process.on("exit",v),process.on("SIGINT",()=>{v(),process.exit(0);}),process.on("SIGTERM",()=>{v(),process.exit(0);}),b.on("error",C=>{f.fail(`Failed to start provider: ${C.message}`);}),b.on("spawn",()=>{D=true,x();}),b.on("close",C=>{C!==0&&C!==null&&p.error(`Provider exited with code ${C}`);});}d.on("error",b=>{p.break(),p.error(`Server error: ${b.message}`),p.break(),process.exit(1);});});process.noDeprecation=true;var UE="0.0.92",WE="https://www.react-grab.com/api/version";process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));try{fetch(`${WE}?source=cli&t=${Date.now()}`).catch(()=>{});}catch{}var br=new Te().name("react-grab").description("add React Grab to your project").version(UE,"-v, --version","display the version number");br.addCommand(yp);br.addCommand(mp);br.addCommand(vp);br.addCommand(gp);br.addCommand(aD);br.parse();
|
|
330
|
+
`;return {success:!0,filePath:r,message:`Remove ${e} server from dev script`,originalContent:s,newContent:a}}catch{return {success:false,filePath:r,message:"Failed to parse package.json"}}};var Zw="0.0.93",Ae={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp","visual-edit":"Visual Edit"},mp=new Te().name("add").description("add an agent integration").argument("[agent]","agent to add (claude-code, cursor, opencode, codex, gemini, amp, visual-edit)").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async(t,e)=>{console.log(`${Ns.default.magenta("\u273F")} ${Ns.default.bold("React Grab")} ${Ns.default.gray(Zw)}`),console.log();try{let r=e.cwd,s=e.yes,i=M("Preflight checks.").start(),n=await pt(r);n.hasReactGrab||(i.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),i.succeed();let o=["claude-code","cursor","opencode","codex","gemini","amp","visual-edit"],a=o.filter(D=>!n.installedAgents.includes(D));a.length===0&&(p.break(),p.success("All agent integrations are already installed."),p.break(),process.exit(0));let u,h=[];if(t){if(o.includes(t)||(p.break(),p.error(`Invalid agent: ${t}`),p.error("Available agents: claude-code, cursor, opencode, codex, gemini, amp, visual-edit"),p.break(),process.exit(1)),n.installedAgents.includes(t)&&(p.break(),p.warn(`${Ae[t]} is already installed.`),p.break(),process.exit(0)),u=t,n.installedAgents.length>0&&!s){let D=n.installedAgents.map(b=>Ae[b]||b).join(", ");p.break(),p.warn(`${D} is already installed.`);let{action:x}=await(0,qr.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace with ${Ae[u]}`,value:"replace"},{title:`Add ${Ae[u]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!x||x==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),x==="replace"&&(h=[...n.installedAgents]);}}else if(s)p.break(),p.error("Please specify an agent to add."),p.error("Available agents: "+a.join(", ")),p.break(),process.exit(1);else {if(p.break(),n.installedAgents.length>0){let x=n.installedAgents.map(b=>Ae[b]||b).join(", ");p.warn(`Currently installed: ${x}`),p.break();}let{agent:D}=await(0,qr.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to add?`,choices:a.map(x=>({title:Ae[x],value:x}))});if(D||(p.break(),process.exit(1)),u=D,n.installedAgents.length>0){let x=n.installedAgents.map(v=>Ae[v]||v).join(", "),{action:b}=await(0,qr.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${x} with ${Ae[u]}`,value:"replace"},{title:`Add ${Ae[u]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!b||b==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),b==="replace"&&(h=[...n.installedAgents]);}}if(h.length>0){for(let D of h){let x=Ht(n.projectRoot,n.framework,n.nextRouterType,D),b=qt(n.projectRoot,D),v=Mt(D);if(v.length>0){let C=M(`Removing ${v.join(", ")}.`).start();try{It(v,n.packageManager,n.projectRoot),C.succeed();}catch(E){C.fail(),me(E);}}if(x.success&&!x.noChanges&&x.newContent){let C=M(`Removing ${Ae[D]||D} from ${x.filePath}.`).start(),E=ke(x);E.success||(C.fail(),p.break(),p.error(E.error||"Failed to write file."),p.break(),process.exit(1)),C.succeed();}if(b.success&&!b.noChanges&&b.newContent){let C=M(`Removing ${Ae[D]||D} from ${b.filePath}.`).start(),E=Ue(b);E.success||(C.fail(),p.break(),p.error(E.error||"Failed to write file."),p.break(),process.exit(1)),C.succeed();}}n.installedAgents=n.installedAgents.filter(D=>!h.includes(D));}M(`Adding ${Ae[u]}.`).start().succeed();let c=Nr(n.projectRoot,n.framework,n.nextRouterType,u,!0),d=Hr(n.projectRoot,u,n.installedAgents,n.packageManager);c.success||(p.break(),p.error(c.message),p.break(),process.exit(1));let f=!c.noChanges&&c.originalContent&&c.newContent,m=d.success&&!d.noChanges&&d.originalContent&&d.newContent;if((f||m)&&(p.break(),f&&we(c.filePath,c.originalContent,c.newContent),m&&(f&&p.break(),we(d.filePath,d.originalContent,d.newContent)),!s&&h.length===0)){p.break();let{proceed:D}=await(0,qr.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});D||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}let g=nr(u,!1);if(g.length>0){let D=M(`Installing ${g.join(", ")}.`).start();try{ir(g,n.packageManager,n.projectRoot),D.succeed();}catch(x){D.fail(),me(x);}}if(f){let D=M(`Applying changes to ${c.filePath}.`).start(),x=ke(c);x.success||(D.fail(),p.break(),p.error(x.error||"Failed to write file."),p.break(),process.exit(1)),D.succeed();}if(m){let D=M(`Applying changes to ${d.filePath}.`).start(),x=Ue(d);x.success||(D.fail(),p.break(),p.error(x.error||"Failed to write file."),p.break(),process.exit(1)),D.succeed();}p.break(),p.log(`${$.success("Success!")} ${Ae[u]} has been added.`),d.warning?p.warn(d.warning):p.log("Make sure to start the agent server before using it."),p.break();}catch(r){me(r);}});var qs=be(Ot()),gt=be(er());var Qw="0.0.93",Hs={metaKey:process.platform==="darwin"?"\u2318 Command":"\u229E Windows",ctrlKey:"Ctrl",shiftKey:"Shift",altKey:process.platform==="darwin"?"\u2325 Option":"Alt"},ex=t=>{if(!t)return "Default (Option/Alt)";let e=[];return t.metaKey&&e.push(process.platform==="darwin"?"\u2318":"Win"),t.ctrlKey&&e.push("Ctrl"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push(process.platform==="darwin"?"\u2325":"Alt"),t.key&&e.push(t.key.toUpperCase()),e.length>0?e.join(" + "):"Default (Option/Alt)"},gp=new Te().name("configure").alias("config").description("configure React Grab options").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async t=>{console.log(`${qs.default.magenta("\u273F")} ${qs.default.bold("React Grab")} ${qs.default.gray(Qw)}`),console.log();try{let e=t.cwd,r=t.yes,s=M("Preflight checks.").start(),i=await pt(e);i.hasReactGrab||(s.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),s.succeed(),r&&(p.break(),p.error("Configure command requires interactive mode."),p.error("Remove the --yes flag to use interactive prompts."),p.break(),process.exit(1)),p.break(),p.log(`Configure ${$.info("React Grab")} options:`),p.break();let n={},{wantActivationKey:o}=await(0,gt.default)({type:"confirm",name:"wantActivationKey",message:`Configure ${$.info("activation key")}?`,initial:!1});if(o===void 0&&(p.break(),process.exit(1)),o){let{key:d}=await(0,gt.default)({type:"text",name:"key",message:"Enter the activation key (e.g., g, k, space):",initial:""});d===void 0&&(p.break(),process.exit(1));let{modifiers:f}=await(0,gt.default)({type:"multiselect",name:"modifiers",message:"Select modifier keys (space to select, enter to confirm):",choices:[{title:Hs.metaKey,value:"metaKey"},{title:Hs.ctrlKey,value:"ctrlKey"},{title:Hs.shiftKey,value:"shiftKey"},{title:Hs.altKey,value:"altKey",selected:!0}],hint:"- Space to select, Enter to confirm"});f===void 0&&(p.break(),process.exit(1)),n.activationKey={...d&&{key:d.toLowerCase()},...f.includes("metaKey")&&{metaKey:!0},...f.includes("ctrlKey")&&{ctrlKey:!0},...f.includes("shiftKey")&&{shiftKey:!0},...f.includes("altKey")&&{altKey:!0}},p.log(` Activation key: ${$.info(ex(n.activationKey))}`);}let{activationMode:a}=await(0,gt.default)({type:"select",name:"activationMode",message:`Select ${$.info("activation mode")}:`,choices:[{title:"Toggle (press to activate/deactivate)",value:"toggle"},{title:"Hold (hold key to keep active)",value:"hold"}],initial:0});if(a===void 0&&(p.break(),process.exit(1)),n.activationMode=a,a==="hold"){let{keyHoldDuration:d}=await(0,gt.default)({type:"number",name:"keyHoldDuration",message:`Enter ${$.info("key hold duration")} in milliseconds:`,initial:150,min:0,max:2e3});d===void 0&&(p.break(),process.exit(1)),n.keyHoldDuration=d;}let{allowActivationInsideInput:u}=await(0,gt.default)({type:"confirm",name:"allowActivationInsideInput",message:`Allow activation ${$.info("inside input fields")}?`,initial:!0});u===void 0&&(p.break(),process.exit(1)),n.allowActivationInsideInput=u;let{maxContextLines:h}=await(0,gt.default)({type:"number",name:"maxContextLines",message:`Enter ${$.info("max context lines")} to include:`,initial:3,min:0,max:50});h===void 0&&(p.break(),process.exit(1)),n.maxContextLines=h;let l=Ms(i.projectRoot,i.framework,i.nextRouterType,n);if(l.success||(p.break(),p.error(l.message),p.break(),process.exit(1)),!l.noChanges&&l.originalContent&&l.newContent){p.break(),we(l.filePath,l.originalContent,l.newContent),p.break();let{proceed:d}=await(0,gt.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});d||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));let f=M(`Applying changes to ${l.filePath}.`).start(),m=Bs(l);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}else p.break(),p.log("No changes needed.");p.break(),p.log(`${$.success("Success!")} React Grab options have been configured.`),p.break();}catch(e){me(e);}});var Gs=be(Ot()),ce=be(er());var bp="0.0.93",tx="https://react-grab.com/api/report-cli",Ls="https://github.com/aidenybai/react-grab",Dp=async(t,e,r)=>{try{await fetch(tx,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:t,version:bp,config:e,error:r?{message:r.message,stack:r.stack}:void 0,timestamp:new Date().toISOString()})}).catch(()=>{});}catch{}},ga={next:"Next.js",vite:"Vite",webpack:"Webpack",unknown:"Unknown"},rx={npm:"npm",yarn:"Yarn",pnpm:"pnpm",bun:"Bun"},sx={remix:"Remix",astro:"Astro",sveltekit:"SvelteKit",gatsby:"Gatsby"},de={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp",ami:"Ami","visual-edit":"Visual Edit"},js={metaKey:process.platform==="darwin"?"\u2318 Command":"\u229E Windows",ctrlKey:"Ctrl",shiftKey:"Shift",altKey:process.platform==="darwin"?"\u2325 Option":"Alt"},ix=t=>{if(!t)return "Default (Option/Alt)";let e=[];return t.metaKey&&e.push(process.platform==="darwin"?"\u2318":"Win"),t.ctrlKey&&e.push("Ctrl"),t.shiftKey&&e.push("Shift"),t.altKey&&e.push(process.platform==="darwin"?"\u2325":"Alt"),t.key&&e.push(t.key.toUpperCase()),e.length>0?e.join(" + "):"Default (Option/Alt)"},yp=new Te().name("init").description("initialize React Grab in your project").option("-y, --yes","skip confirmation prompts",false).option("-f, --force","force overwrite existing config",false).option("-a, --agent <agent>","agent integration (claude-code, cursor, opencode, codex, gemini, amp, visual-edit)").option("--skip-install","skip package installation",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async t=>{console.log(`${Gs.default.magenta("\u273F")} ${Gs.default.bold("React Grab")} ${Gs.default.gray(bp)}`),console.log();try{let e=t.cwd,r=t.yes,s=M("Preflight checks.").start(),i=await pt(e);if(i.hasReactGrab&&!t.force){s.succeed(),r&&(p.break(),p.warn("React Grab is already installed."),p.log(`Use ${$.info("--force")} to reconfigure, or remove ${$.info("--yes")} for interactive mode.`),p.break(),process.exit(0)),p.break(),p.success("React Grab is already installed."),p.break();let v=["claude-code","cursor","opencode","codex","gemini","amp","visual-edit"].filter(R=>!i.installedAgents.includes(R));if(i.installedAgents.length>0){let R=i.installedAgents.map(k=>de[k]||k).join(", ");p.log(`Currently installed agents: ${$.info(R)}`),p.break();}let C=!1;if(v.length>0){let{wantAddAgent:R}=await(0,ce.default)({type:"confirm",name:"wantAddAgent",message:`Would you like to add an ${$.info("agent integration")}?`,initial:!0});if(R===void 0&&(p.break(),process.exit(1)),R){let{agent:k}=await(0,ce.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to add?`,choices:v.map(U=>({title:de[U],value:U}))});k===void 0&&(p.break(),process.exit(1));let A=k,T=[];if(i.installedAgents.length>0){let U=i.installedAgents.map(B=>de[B]||B).join(", "),{action:F}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${U} with ${de[A]}`,value:"replace"},{title:`Add ${de[A]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});if(!F||F==="cancel")p.break(),p.log("Agent addition cancelled.");else {if(F==="replace"&&(T=[...i.installedAgents]),T.length>0){for(let w of T){let G=Ht(i.projectRoot,i.framework,i.nextRouterType,w),P=qt(i.projectRoot,w),ne=Mt(w);if(ne.length>0){let ue=M(`Removing ${ne.join(", ")}.`).start();try{It(ne,i.packageManager,i.projectRoot),ue.succeed();}catch(oe){ue.fail(),me(oe);}}if(G.success&&!G.noChanges&&G.newContent){let ue=M(`Removing ${de[w]||w} from ${G.filePath}.`).start(),oe=ke(G);oe.success||(ue.fail(),p.break(),p.error(oe.error||"Failed to write file."),p.break(),process.exit(1)),ue.succeed();}if(P.success&&!P.noChanges&&P.newContent){let ue=M(`Removing ${de[w]||w} from ${P.filePath}.`).start(),oe=Ue(P);oe.success||(ue.fail(),p.break(),p.error(oe.error||"Failed to write file."),p.break(),process.exit(1)),ue.succeed();}}i.installedAgents=i.installedAgents.filter(w=>!T.includes(w));}let B=Nr(i.projectRoot,i.framework,i.nextRouterType,A,!0),I=Hr(i.projectRoot,A,i.installedAgents,i.packageManager);B.success||(p.break(),p.error(B.message),p.break(),process.exit(1));let ee=!B.noChanges&&B.originalContent&&B.newContent,_=I.success&&!I.noChanges&&I.originalContent&&I.newContent;if(ee||_)if(p.break(),ee&&we(B.filePath,B.originalContent,B.newContent),_&&(ee&&p.break(),we(I.filePath,I.originalContent,I.newContent)),T.length===0){p.break();let{proceed:w}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});if(!w)p.break(),p.log("Agent addition cancelled.");else {let G=nr(A,!1);if(G.length>0){let P=M(`Installing ${G.join(", ")}.`).start();try{ir(G,i.packageManager,i.projectRoot),P.succeed();}catch(ne){P.fail(),me(ne);}}if(ee){let P=M(`Applying changes to ${B.filePath}.`).start(),ne=ke(B);ne.success||(P.fail(),p.break(),p.error(ne.error||"Failed to write file."),p.break(),process.exit(1)),P.succeed();}if(_){let P=M(`Applying changes to ${I.filePath}.`).start(),ne=Ue(I);ne.success||(P.fail(),p.break(),p.error(ne.error||"Failed to write file."),p.break(),process.exit(1)),P.succeed();}C=!0,p.break(),p.success(`${de[A]} has been added.`);}}else {let w=nr(A,!1);if(w.length>0){let G=M(`Installing ${w.join(", ")}.`).start();try{ir(w,i.packageManager,i.projectRoot),G.succeed();}catch(P){G.fail(),me(P);}}if(ee){let G=M(`Applying changes to ${B.filePath}.`).start(),P=ke(B);P.success||(G.fail(),p.break(),p.error(P.error||"Failed to write file."),p.break(),process.exit(1)),G.succeed();}if(_){let G=M(`Applying changes to ${I.filePath}.`).start(),P=Ue(I);P.success||(G.fail(),p.break(),p.error(P.error||"Failed to write file."),p.break(),process.exit(1)),G.succeed();}C=!0,p.break(),p.success(`${de[A]} has been added.`);}}}}}else p.log("All agent integrations are already installed.");p.break();let{wantCustomizeOptions:E}=await(0,ce.default)({type:"confirm",name:"wantCustomizeOptions",message:`Would you like to customize ${$.info("options")}?`,initial:!1});if(E===void 0&&(p.break(),process.exit(1)),E){p.break(),p.log(`Configure ${$.info("React Grab")} options:`),p.break();let R={},{wantActivationKey:k}=await(0,ce.default)({type:"confirm",name:"wantActivationKey",message:`Configure ${$.info("activation key")}?`,initial:!1});if(k===void 0&&(p.break(),process.exit(1)),k){let{key:I}=await(0,ce.default)({type:"text",name:"key",message:"Enter the activation key (e.g., g, k, space):",initial:""});I===void 0&&(p.break(),process.exit(1));let{modifiers:ee}=await(0,ce.default)({type:"multiselect",name:"modifiers",message:"Select modifier keys (space to select, enter to confirm):",choices:[{title:js.metaKey,value:"metaKey"},{title:js.ctrlKey,value:"ctrlKey"},{title:js.shiftKey,value:"shiftKey"},{title:js.altKey,value:"altKey",selected:!0}],hint:"- Space to select, Enter to confirm"});ee===void 0&&(p.break(),process.exit(1)),R.activationKey={...I&&{key:I.toLowerCase()},...ee.includes("metaKey")&&{metaKey:!0},...ee.includes("ctrlKey")&&{ctrlKey:!0},...ee.includes("shiftKey")&&{shiftKey:!0},...ee.includes("altKey")&&{altKey:!0}},p.log(` Activation key: ${$.info(ix(R.activationKey))}`);}let{activationMode:A}=await(0,ce.default)({type:"select",name:"activationMode",message:`Select ${$.info("activation mode")}:`,choices:[{title:"Toggle (press to activate/deactivate)",value:"toggle"},{title:"Hold (hold key to keep active)",value:"hold"}],initial:0});if(A===void 0&&(p.break(),process.exit(1)),R.activationMode=A,A==="hold"){let{keyHoldDuration:I}=await(0,ce.default)({type:"number",name:"keyHoldDuration",message:`Enter ${$.info("key hold duration")} in milliseconds:`,initial:150,min:0,max:2e3});I===void 0&&(p.break(),process.exit(1)),R.keyHoldDuration=I;}let{allowActivationInsideInput:T}=await(0,ce.default)({type:"confirm",name:"allowActivationInsideInput",message:`Allow activation ${$.info("inside input fields")}?`,initial:!0});T===void 0&&(p.break(),process.exit(1)),R.allowActivationInsideInput=T;let{maxContextLines:U}=await(0,ce.default)({type:"number",name:"maxContextLines",message:`Enter ${$.info("max context lines")} to include:`,initial:3,min:0,max:50});U===void 0&&(p.break(),process.exit(1)),R.maxContextLines=U;let F=Ms(i.projectRoot,i.framework,i.nextRouterType,R);if(F.success||(p.break(),p.error(F.message),p.break(),process.exit(1)),!F.noChanges&&F.originalContent&&F.newContent){p.break(),we(F.filePath,F.originalContent,F.newContent),p.break();let{proceed:I}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});if(!I)p.break(),p.log("Options configuration cancelled.");else {let ee=M(`Applying changes to ${F.filePath}.`).start(),_=Bs(F);_.success||(ee.fail(),p.break(),p.error(_.error||"Failed to write file."),p.break(),process.exit(1)),ee.succeed(),p.break(),p.success("React Grab options have been configured.");}}else p.break(),p.log("No option changes needed.");}!C&&!E&&(p.break(),p.log("No changes made.")),p.break(),process.exit(0);}s.succeed();let n=M("Verifying framework.").start();if(i.unsupportedFramework){let b=sx[i.unsupportedFramework];n.fail(`Found ${$.info(b)}.`),p.break(),p.log(`${b} is not yet supported by automatic setup.`),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);}if(i.framework==="unknown")if(i.isMonorepo&&!r){n.info("Verifying framework. Found monorepo.");let v=Ef(i.projectRoot).filter(C=>C.hasReact||C.framework!=="unknown");if(v.length>0){p.break();let C=[...v].sort((A,T)=>A.framework==="unknown"&&T.framework!=="unknown"?1:A.framework!=="unknown"&&T.framework==="unknown"?-1:0),{selectedProject:E}=await(0,ce.default)({type:"select",name:"selectedProject",message:"Select a project to install React Grab:",choices:C.map(A=>{let T=A.framework!=="unknown"?` ${$.dim(`(${ga[A.framework]})`)}`:"";return {title:`${A.name}${T}`,value:A.path}})});E||(p.break(),process.exit(1)),process.chdir(E);let R=await pt(E);Object.assign(i,R),M("Verifying framework.").start().succeed(`Verifying framework. Found ${$.info(ga[R.framework])}.`);}else n.fail("Could not detect a supported framework."),p.break(),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);}else n.fail("Could not detect a supported framework."),p.break(),p.log("React Grab supports Next.js, Vite, and Webpack projects."),p.log(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1);else n.succeed(`Verifying framework. Found ${$.info(ga[i.framework])}.`);i.framework==="next"&&M("Detecting router type.").start().succeed(`Detecting router type. Found ${$.info(i.nextRouterType==="app"?"App Router":"Pages Router")}.`),M("Detecting package manager.").start().succeed(`Detecting package manager. Found ${$.info(rx[i.packageManager])}.`);let a=i.framework,u=i.packageManager,h=i.nextRouterType,l=t.agent||"none",c=[];if(!r&&!t.agent){if(p.break(),t.force&&i.installedAgents.length>0){let v=i.installedAgents.map(C=>de[C]||C).join(", ");p.warn(`Currently installed: ${v}`),p.break();}let{agent:b}=await(0,ce.default)({type:"select",name:"agent",message:`Would you like to add an ${$.info("agent integration")}?`,choices:[{title:"None",value:"none"},{title:"Claude Code",value:"claude-code"},{title:"Cursor",value:"cursor"},{title:"OpenCode",value:"opencode"},{title:"Codex",value:"codex"},{title:"Gemini",value:"gemini"},{title:"Amp",value:"amp"},{title:"Visual Edit",value:"visual-edit"}]});if(b===void 0&&(p.break(),process.exit(1)),l=b,t.force&&i.installedAgents.length>0&&l!=="none"&&!i.installedAgents.includes(l)){let v=i.installedAgents.map(E=>de[E]||E).join(", "),{action:C}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${v} with ${de[l]}`,value:"replace"},{title:`Add ${de[l]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!C||C==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),C==="replace"&&(c=[...i.installedAgents]);}}else if(t.agent&&t.force&&i.installedAgents.length>0&&!i.installedAgents.includes(t.agent)&&!r){let b=i.installedAgents.map(C=>de[C]||C).join(", ");p.break(),p.warn(`Currently installed: ${b}`);let{action:v}=await(0,ce.default)({type:"select",name:"action",message:"How would you like to proceed?",choices:[{title:`Replace ${b} with ${de[l]}`,value:"replace"},{title:`Add ${de[l]} alongside existing`,value:"add"},{title:"Cancel",value:"cancel"}]});(!v||v==="cancel")&&(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0)),v==="replace"&&(c=[...i.installedAgents]);}let d=Nr(i.projectRoot,a,h,l,!1),f=Hr(i.projectRoot,l,i.installedAgents,u);d.success||(p.break(),p.error(d.message),p.error(`Visit ${$.info(Ls)} for manual setup.`),p.break(),process.exit(1));let m=!d.noChanges&&d.originalContent&&d.newContent,g=f.success&&!f.noChanges&&f.originalContent&&f.newContent;if((m||g)&&(p.break(),m&&we(d.filePath,d.originalContent,d.newContent),g&&(m&&p.break(),we(f.filePath,f.originalContent,f.newContent)),p.break(),p.warn("Auto-detection may not be 100% accurate."),p.warn("Please verify the changes before committing."),!r)){p.break();let{proceed:b}=await(0,ce.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});b||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}if(c.length>0){for(let b of c){let v=Ht(i.projectRoot,i.framework,i.nextRouterType,b),C=qt(i.projectRoot,b),E=Mt(b);if(E.length>0&&!t.skipInstall){let R=M(`Removing ${E.join(", ")}.`).start();try{It(E,u,i.projectRoot),R.succeed();}catch(k){R.fail(),me(k);}}if(v.success&&!v.noChanges&&v.newContent){let R=M(`Removing ${de[b]||b} from ${v.filePath}.`).start(),k=ke(v);k.success||(R.fail(),p.break(),p.error(k.error||"Failed to write file."),p.break(),process.exit(1)),R.succeed();}if(C.success&&!C.noChanges&&C.newContent){let R=M(`Removing ${de[b]||b} from ${C.filePath}.`).start(),k=Ue(C);k.success||(R.fail(),p.break(),p.error(k.error||"Failed to write file."),p.break(),process.exit(1)),R.succeed();}}i.installedAgents=i.installedAgents.filter(b=>!c.includes(b));}let D=!i.hasReactGrab,x=l!=="none"&&!i.installedAgents.includes(l);if(!t.skipInstall&&(D||x)){let b=nr(l,D);if(b.length>0){let v=M(`Installing ${b.join(", ")}.`).start();try{ir(b,u,i.projectRoot),v.succeed();}catch(C){v.fail(),me(C);}}}if(m){let b=M(`Applying changes to ${d.filePath}.`).start(),v=ke(d);v.success||(b.fail(),p.break(),p.error(v.error||"Failed to write file."),p.break(),process.exit(1)),b.succeed();}if(g){let b=M(`Applying changes to ${f.filePath}.`).start(),v=Ue(f);v.success||(b.fail(),p.break(),p.error(v.error||"Failed to write file."),p.break(),process.exit(1)),b.succeed();}p.break(),p.log(`${$.success("Success!")} React Grab has been installed.`),f.warning?(p.break(),p.warn(f.warning),p.break()):p.log("You may now start your development server."),p.break(),await Dp("completed",{framework:a,packageManager:u,router:h,agent:l!=="none"?l:void 0,isMonorepo:i.isMonorepo});}catch(e){me(e),await Dp("error",void 0,e);}});var Us=be(Ot()),Da=be(er());var nx="0.0.93",Vs={"claude-code":"Claude Code",cursor:"Cursor",opencode:"OpenCode",codex:"Codex",gemini:"Gemini",amp:"Amp",ami:"Ami","visual-edit":"Visual Edit"},vp=new Te().name("remove").description("remove an agent integration").argument("[agent]","agent to remove (claude-code, cursor, opencode, codex, gemini, amp, ami, visual-edit)").option("-y, --yes","skip confirmation prompts",false).option("-c, --cwd <cwd>","working directory (defaults to current directory)",process.cwd()).action(async(t,e)=>{console.log(`${Us.default.magenta("\u273F")} ${Us.default.bold("React Grab")} ${Us.default.gray(nx)}`),console.log();try{let r=e.cwd,s=e.yes,i=M("Preflight checks.").start(),n=await pt(r);n.hasReactGrab||(i.fail("React Grab is not installed."),p.break(),p.error(`Run ${$.info("react-grab init")} first to install React Grab.`),p.break(),process.exit(1)),n.installedAgents.length===0&&(i.succeed(),p.break(),p.warn("No agent integrations are installed."),p.break(),process.exit(0)),i.succeed();let o;if(t)n.installedAgents.includes(t)||(p.break(),p.error(`Agent ${$.info(t)} is not installed.`),p.log(`Installed agents: ${n.installedAgents.map(f=>Vs[f]||f).join(", ")}`),p.break(),process.exit(1)),o=t;else if(s)p.break(),p.error("Please specify an agent to remove."),p.error("Installed agents: "+n.installedAgents.join(", ")),p.break(),process.exit(1);else {p.break();let{agent:f}=await(0,Da.default)({type:"select",name:"agent",message:`Which ${$.info("agent integration")} would you like to remove?`,choices:n.installedAgents.map(m=>({title:Vs[m]||m,value:m}))});f||(p.break(),process.exit(1)),o=f;}M(`Preparing to remove ${Vs[o]||o}.`).start().succeed();let u=Ht(n.projectRoot,n.framework,n.nextRouterType,o),h=qt(n.projectRoot,o),l=u.success&&!u.noChanges&&u.originalContent&&u.newContent,c=h.success&&!h.noChanges&&h.originalContent&&h.newContent;if((l||c)&&(p.break(),l&&we(u.filePath,u.originalContent,u.newContent),c&&(l&&p.break(),we(h.filePath,h.originalContent,h.newContent)),!s)){p.break();let{proceed:f}=await(0,Da.default)({type:"confirm",name:"proceed",message:"Apply these changes?",initial:!0});f||(p.break(),p.log("Changes cancelled."),p.break(),process.exit(0));}let d=Mt(o);if(d.length>0){let f=M(`Removing ${d.join(", ")}.`).start();try{It(d,n.packageManager,n.projectRoot),f.succeed();}catch(m){f.fail(),me(m);}}if(l){let f=M(`Applying changes to ${u.filePath}.`).start(),m=ke(u);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}if(c){let f=M(`Applying changes to ${h.filePath}.`).start(),m=Ue(h);m.success||(f.fail(),p.break(),p.error(m.error||"Failed to write file."),p.break(),process.exit(1)),f.succeed();}p.break(),p.log(`${$.success("Success!")} ${Vs[o]||o} has been removed.`),p.break();}catch(r){me(r);}});var Ci=be(Ot()),wi=be(rD()),wu=be(er());var LE="0.0.93",sD=2e3,iD='<script src="https://unpkg.com/react-grab/dist/index.global.js"></script>',jE=t=>`<script src="https://unpkg.com/${t}/dist/client.global.js"></script>`,oD=async(t,e)=>new Promise(r=>{let s=http.createServer();s.listen(t,e,()=>{s.close(()=>r(t));}),s.on("error",()=>{r(oD(t+1,e));});}),GE=t=>t.startsWith("http://")||t.startsWith("https://")?t:`http://${t}`,VE=async t=>{try{return (await fetch(t,{method:"HEAD",redirect:"follow"})).url}catch{return t}},aD=new Te().name("start").alias("proxy").description("start a proxy server for a given URL").argument("[url]","target URL to proxy (e.g., localhost:3000)").option("-p, --port <port>","starting port for the proxy server",String(sD)).option("--host <hostname>","hostname to bind the proxy server to","localhost").option("--provider <package>","provider package to run via npx (e.g., @react-grab/cursor)").action(async(t,e)=>{console.log(`${Ci.default.magenta("\u273F")} ${Ci.default.bold("React Grab")} ${Ci.default.gray(LE)}`),console.log();let r=t,s=e.provider;if(!r){let{targetUrl:b}=await(0, wu.default)({type:"text",name:"targetUrl",message:"Enter the target URL to proxy:",initial:"localhost:3000"});if(b||(p.break(),process.exit(1)),r=b,!s){let{selectedProvider:v}=await(0, wu.default)({type:"select",name:"selectedProvider",message:`Select a ${$.info("provider")} to use:`,choices:[{title:"None",value:""},{title:"Claude Code",value:"@react-grab/claude-code"},{title:"Cursor",value:"@react-grab/cursor"},{title:"OpenCode",value:"@react-grab/opencode"},{title:"Codex",value:"@react-grab/codex"},{title:"Gemini",value:"@react-grab/gemini"},{title:"Amp",value:"@react-grab/amp"},{title:"Visual Edit",value:"@react-grab/visual-edit"}]});v===void 0&&(p.break(),process.exit(1)),s=v||void 0;}p.break();}let i=GE(r),n=await VE(i),o=parseInt(e.port,10),a=e.host||"localhost";(isNaN(o)||o<1||o>65535)&&(p.break(),p.error("Invalid port number. Please provide a port between 1 and 65535."),p.break(),process.exit(1));let u=await oD(o,a),h=s?iD+jE(s):iD,l=b=>{let v=b.indexOf("</head>");if(v!==-1)return b.slice(0,v)+h+b.slice(v);let C=b.indexOf("</body>");return C!==-1?b.slice(0,C)+h+b.slice(C):b+h},c=(0, wi.createProxyMiddleware)({target:n,changeOrigin:true,followRedirects:false,ws:true,selfHandleResponse:true,cookieDomainRewrite:{"*":""},autoRewrite:true,preserveHeaderKeyCase:true,xfwd:true,on:{error:(b,v,C)=>{"writeHead"in C&&!C.headersSent&&(C.writeHead(503,{"Content-Type":"text/plain"}),C.end(`Proxy error: Unable to connect to ${n}`));},proxyReq:b=>{b.removeHeader("accept-encoding");},proxyRes:(0, wi.responseInterceptor)(async(b,v,C,E)=>{if(E.removeHeader("content-security-policy"),E.removeHeader("content-security-policy-report-only"),!(v.headers["content-type"]||"").includes("text/html"))return b;let A=b.toString("utf-8");return l(A)})}}),d=http.createServer((b,v)=>{c(b,v,C=>{C&&(p.error(`Request error: ${C}`),v.writeHead(500),v.end("Internal Server Error"));});});d.on("upgrade",c.upgrade);let f=M("Starting.").start(),m=()=>{f.succeed(`Open in your browser: http://${a}:${u}`);let b=["npx react-grab@latest start",r];e.port!==String(sD)&&b.push(`--port=${e.port}`),a!=="localhost"&&b.push(`--host=${a}`),s&&b.push(`--provider=${s}`),p.break(),p.log($.dim(`$ ${b.join(" ")}`));},g=false,D=!s,x=()=>{g&&D&&m();};if(d.listen(u,a,()=>{g=true,x();}),s){let b=child_process.spawn("npx",[`${s}@latest`],{stdio:"ignore",shell:true,detached:false}),v=()=>{b.killed||b.kill();};process.on("exit",v),process.on("SIGINT",()=>{v(),process.exit(0);}),process.on("SIGTERM",()=>{v(),process.exit(0);}),b.on("error",C=>{f.fail(`Failed to start provider: ${C.message}`);}),b.on("spawn",()=>{D=true,x();}),b.on("close",C=>{C!==0&&C!==null&&p.error(`Provider exited with code ${C}`);});}d.on("error",b=>{p.break(),p.error(`Server error: ${b.message}`),p.break(),process.exit(1);});});process.noDeprecation=true;var UE="0.0.93",WE="https://www.react-grab.com/api/version";process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));try{fetch(`${WE}?source=cli&t=${Date.now()}`).catch(()=>{});}catch{}var br=new Te().name("react-grab").description("add React Grab to your project").version(UE,"-v, --version","display the version number");br.addCommand(yp);br.addCommand(mp);br.addCommand(vp);br.addCommand(gp);br.addCommand(aD);br.parse();
|
|
331
331
|
/*! Bundled license information:
|
|
332
332
|
|
|
333
333
|
http-proxy/lib/http-proxy/passes/web-outgoing.js:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkEPG66EVR_cjs=require('../chunk-EPG66EVR.cjs');Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.f}});Object.defineProperty(exports,"copyContent",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.d}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.c}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.e}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.b}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.g}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.a}});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '
|
|
1
|
+
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-DOGyzncb.cjs';
|
|
2
2
|
export { isInstrumentationActive } from 'bippy';
|
|
3
3
|
import 'bippy/source';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '
|
|
1
|
+
export { o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, D as DEFAULT_THEME, O as Options, d as OverlayBounds, R as ReactGrabAPI, q as ReactGrabRendererProps, U as UpdatableOptions, r as copyContent, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from '../index-DOGyzncb.js';
|
|
2
2
|
export { isInstrumentationActive } from 'bippy';
|
|
3
3
|
import 'bippy/source';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{f as DEFAULT_THEME,d as copyContent,c as formatElementInfo,e as generateSnippet,b as getStack,g as init,a as isInstrumentationActive}from'
|
|
1
|
+
export{f as DEFAULT_THEME,d as copyContent,c as formatElementInfo,e as generateSnippet,b as getStack,g as init,a as isInstrumentationActive}from'../chunk-IJJ2JADU.js';
|
|
@@ -66,11 +66,11 @@ interface Theme {
|
|
|
66
66
|
enabled?: boolean;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
* The floating
|
|
69
|
+
* The floating toolbar that allows toggling React Grab activation
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
toolbar?: {
|
|
72
72
|
/**
|
|
73
|
-
* Whether to show the
|
|
73
|
+
* Whether to show the toolbar
|
|
74
74
|
* @default true
|
|
75
75
|
*/
|
|
76
76
|
enabled?: boolean;
|
|
@@ -284,7 +284,7 @@ interface ReactGrabRendererProps {
|
|
|
284
284
|
onNativeSelectionCopy?: () => void;
|
|
285
285
|
onNativeSelectionEnter?: () => void;
|
|
286
286
|
theme?: Required<Theme>;
|
|
287
|
-
|
|
287
|
+
toolbarVisible?: boolean;
|
|
288
288
|
isActive?: boolean;
|
|
289
289
|
onToggleActive?: () => void;
|
|
290
290
|
}
|
|
@@ -66,11 +66,11 @@ interface Theme {
|
|
|
66
66
|
enabled?: boolean;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
* The floating
|
|
69
|
+
* The floating toolbar that allows toggling React Grab activation
|
|
70
70
|
*/
|
|
71
|
-
|
|
71
|
+
toolbar?: {
|
|
72
72
|
/**
|
|
73
|
-
* Whether to show the
|
|
73
|
+
* Whether to show the toolbar
|
|
74
74
|
* @default true
|
|
75
75
|
*/
|
|
76
76
|
enabled?: boolean;
|
|
@@ -284,7 +284,7 @@ interface ReactGrabRendererProps {
|
|
|
284
284
|
onNativeSelectionCopy?: () => void;
|
|
285
285
|
onNativeSelectionEnter?: () => void;
|
|
286
286
|
theme?: Required<Theme>;
|
|
287
|
-
|
|
287
|
+
toolbarVisible?: boolean;
|
|
288
288
|
isActive?: boolean;
|
|
289
289
|
onToggleActive?: () => void;
|
|
290
290
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkEPG66EVR_cjs=require('./chunk-EPG66EVR.cjs');/**
|
|
2
2
|
* @license MIT
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2025 Aiden Bai
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
var e=null,A=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,d=t=>{e=t,typeof window<"u"&&(t?window.__REACT_GRAB__=t:delete window.__REACT_GRAB__);};typeof window<"u"&&(window.__REACT_GRAB__?e=window.__REACT_GRAB__:(e=
|
|
9
|
+
var e=null,A=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,d=t=>{e=t,typeof window<"u"&&(t?window.__REACT_GRAB__=t:delete window.__REACT_GRAB__);};typeof window<"u"&&(window.__REACT_GRAB__?e=window.__REACT_GRAB__:(e=chunkEPG66EVR_cjs.g(),window.__REACT_GRAB__=e,window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e}))));Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.f}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.c}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.e}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.b}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.g}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkEPG66EVR_cjs.a}});exports.getGlobalApi=A;exports.setGlobalApi=d;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './
|
|
2
|
-
export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './
|
|
1
|
+
import { R as ReactGrabAPI } from './index-DOGyzncb.cjs';
|
|
2
|
+
export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-DOGyzncb.cjs';
|
|
3
3
|
export { isInstrumentationActive } from 'bippy';
|
|
4
4
|
import 'bippy/source';
|
|
5
5
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as ReactGrabAPI } from './
|
|
2
|
-
export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './
|
|
1
|
+
import { R as ReactGrabAPI } from './index-DOGyzncb.js';
|
|
2
|
+
export { p as ActivationMode, o as AgentCompleteResult, A as AgentContext, n as AgentOptions, l as AgentProvider, k as AgentSession, m as AgentSessionStorage, C as CrosshairContext, D as DEFAULT_THEME, h as DeepPartial, e as DragRect, j as ElementLabelContext, E as ElementLabelVariant, G as GrabbedBox, I as InputModeContext, O as Options, d as OverlayBounds, c as ReactGrabState, f as Rect, T as Theme, U as UpdatableOptions, a as formatElementInfo, b as generateSnippet, g as getStack, i as init } from './index-DOGyzncb.js';
|
|
3
3
|
export { isInstrumentationActive } from 'bippy';
|
|
4
4
|
import 'bippy/source';
|
|
5
5
|
|