@constellationdev/cli 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/dist/main.js +67 -67
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -1,35 +1,35 @@
1
1
  #!/usr/bin/env node
2
- import {base32}from'@scure/base';import {Readable}from'stream';import c from'ansi-colors';import*as ie from'os';import ie__default from'os';import {Agent,fetch as fetch$1}from'undici';import {execFile,spawn}from'child_process';import {promisify}from'util';import {createServer}from'http';import {randomBytes}from'crypto';import Sr from'enquirer';import*as N from'fs/promises';import N__default from'fs/promises';import*as qe from'fs';import {readFileSync}from'fs';import uo from'tree-sitter';import*as v from'path';import v__default,{dirname,join}from'path';import Sn from'ignore';import {z as z$1}from'zod';import mt from'zlib';import {pipeline}from'stream/promises';import {PYTHON_STDLIB_MODULES}from'@constellationdev/types';import {performance}from'perf_hooks';import {findAll,parse}from'tsconfck';import Oo from'tree-sitter-javascript';import Fo from'tree-sitter-python';import Mo from'tree-sitter-typescript';import {parseDocument,isMap,isSeq}from'yaml';import {simpleGit}from'simple-git';import {fileURLToPath}from'url';import {Command}from'commander';var Dr=Object.defineProperty;var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var sn=(s,e)=>{for(var t in e)Dr(s,t,{get:e[t],enumerable:true});};var Te,lt=m(()=>{Te=["help","--help","-h","--version","-V","-v"];});function cn(s){return base32.encode(Buffer.from(s))}var ln=m(()=>{});function pn(s,e,t){let n=`${s}:${e}${t?`:${t}`:""}`;return cn(n)}var gn=m(()=>{ln();});var Ne,dn=m(()=>{Ne=class extends Readable{dataSource;sourceIterator;reading=false;constructor(e){super(),this.dataSource=e,this.sourceIterator=this.dataSource[Symbol.asyncIterator]();}async _read(){if(!this.reading){this.reading=true;try{for(;;){let{value:e,done:t}=await this.sourceIterator.next();if(t){this.push(null);break}let n=JSON.stringify(e)+`
3
- `,r=Buffer.from(n,"utf8");if(!this.push(r))break}}catch(e){this.destroy(e);}finally{this.reading=false;}}}_destroy(e,t){this.dataSource.return?this.dataSource.return(null).then(()=>t(e),n=>t(e||n)):t(e);}};});function Gr(){return process.env.CONSTELLATION_ASCII_MODE==="1"?false:process.env.CI?true:ie.platform()==="win32"?!!(process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM_PROGRAM==="Hyper"||process.env.TERM&&process.env.TERM!=="cygwin"&&process.env.TERM!=="dumb"):true}var Wr,zr,Kr,Vr,Jr,Yr,qr,Xr,Zr,Qr,pe,C,P,w,y,D,k=m(()=>{Wr="\u2714",zr="\u2717",Kr="\u26A0",Vr="\u2139",Jr="\u26A1",Yr="[OK]",qr="[ERR]",Xr="[WARN]",Zr="[INFO]",Qr="[>>]",pe=Gr(),C=c.green(pe?Wr:Yr),P=c.red(pe?zr:qr),w=c.yellow(pe?Kr:Xr),y=c.blue(pe?Vr:Zr),D=c.yellow(pe?Jr:Qr);});var Re,Ae,E,B,T,X,pt=m(()=>{gn();dn();k();Re=class{constructor(e,t){this.config=e;this.accessKey=t;}apiVersion="intel/v1";async getProjectState(){let e={"Content-Type":"application/x-ndjson; charset=utf-8","x-project-id":this.config.projectId,"x-branch-name":this.config.branch,Authorization:`Bearer ${this.accessKey}`},t=await this.sendRequest("project",void 0,"GET",e);return t&&!t.ok&&await this.handleProjectStateError(t),t.json()}async handleProjectStateError(e){try{let t=await e.json(),n=t?.code;switch(n){case "PROJECT_NOT_REGISTERED":throw new T(t?.message||"Project not registered",n,this.config.projectId);case "PROJECT_INACTIVE":throw new T(t?.message||"Project is inactive",n,this.config.projectId);case "INVALID_PROJECT_ID":throw new T(t?.message||"Invalid project ID format",n,this.config.projectId);case "PROJECT_NOT_FOUND":throw new B("Project not found - no previous index exists");default:throw e.status===404?new B("Project not found - no previous index exists"):new Error(`Unexpected API response (${e.status}): ${t?.message||e.statusText}`)}}catch(t){throw t instanceof T||t instanceof B?t:e.status===404?new B("Project not found - no previous index exists"):new Error(`Unexpected API response (${e.status})`)}}async getIndexStatus(e,t){let n=new URLSearchParams({branch:e});t&&n.set("commit",t);let r=`projects/${encodeURIComponent(this.config.projectId)}/index-status?${n.toString()}`;try{let o=await this.sendRequest(r,null,"GET");return !o||!o.ok?null:await o.json()}catch(o){if(o instanceof E)throw o;return null}}async deleteFiles(e){for(let t of e){let n=pn(this.config.projectId,this.config.branch,t);await this.delete(`/ast/${n}`);}}retryableStatusCodes=[500,502,503,504];async streamToApi(e,t,n,r,o,i){try{let{Readable:a}=await import('stream'),l=new Ne(e),g=a.toWeb(l),d=new Agent({headersTimeout:0,bodyTimeout:0}),p=await fetch$1(`${this.config.apiUrl}/${this.apiVersion}/${t}`,{method:"POST",headers:{"Content-Type":"application/x-ndjson; charset=utf-8","x-project-id":n,"x-branch-name":r,"x-constellation-index":o?"incremental":"full",Authorization:`Bearer ${this.accessKey}`,...i&&{"x-commit-hash":i}},body:g,duplex:"half",dispatcher:d});if(p.status===401)throw new E("Authentication failed");if(p.status===409){let f="Indexing already in progress",b;try{let _=await p.json();f=_?.message||f,b=_?.details?.branchName;}catch{}throw new X(f,b)}if(p.status===200)try{let f=await p.json();if(f?.status==="current")return console.log(`${C} Index already up to date for ${r} at commit ${f.commitHash||"unknown"}`),!0}catch{}if(p.ok||p.status===202)return !0;let u=`Server returned ${p.status}`;try{let f=await p.json();f?.message&&(u=Array.isArray(f.message)?f.message.join("; "):f.message);}catch{}throw new Error(u)}catch(a){if(a instanceof E||a instanceof X)throw a;let l=a instanceof Error?a:new Error(String(a)),g="";if(l.message==="fetch failed"||a.code){let p=[],u=a.code||a.cause?.code;if(a.code&&p.push(`Error Code: ${a.code}`),a.cause){let f=a.cause;f.code&&p.push(`Cause Code: ${f.code}`),f.errno&&p.push(`Errno: ${f.errno}`),f.syscall&&p.push(`System Call: ${f.syscall}`),f.address&&p.push(`Address: ${f.address}`),f.port&&p.push(`Port: ${f.port}`);}u==="ERR_INVALID_ARG_VALUE"?g="Invalid argument value - check stream/body format and duplex option":u==="ECONNREFUSED"?g="Connection refused - service may be down or unreachable":u==="ENOTFOUND"?g="DNS lookup failed - check service URL":u==="ETIMEDOUT"?g="Connection timeout - service not responding":u==="ECONNRESET"?g="Connection reset by server":u==="EHOSTUNREACH"?g="Host unreachable - check network connectivity":g="Network failure",p.length>0&&(g+=` (${p.join(", ")})`);}else g=l.message;let d=new Error(`Failed to upload data to Constellation Service: ${g}`);throw d.cause=l,d.stack=`${d.stack}
4
- Caused by: ${l.stack}`,d}}async sendRequest(e,t,n,r={},o=0,i=3,a=1e3,l=250){for(let g=1;g<=i;g++)try{let d=new AbortController,p;o>0&&(p=setTimeout(()=>d.abort(),o));let u={...r,"Content-Type":"application/json; charset=utf-8",Accepts:"application/json; charset=utf-8",Authorization:`Bearer ${this.accessKey}`},f=await fetch(`${this.config.apiUrl}/${this.apiVersion}/${e}`,{method:n,headers:u,body:t?JSON.stringify(t):void 0,signal:d.signal});if(p&&clearTimeout(p),f.status===401)throw new E("Authentication failed");if(!f.ok&&this.retryableStatusCodes.includes(f.status))throw new Ae(`${f.statusText} (${f.status})`);return f}catch(d){if(!(d instanceof E)){let p=d instanceof Error?`${d.message}${d.cause?` (Cause: ${d.cause})`:""}`:String(d);console.log(`HTTP request attempt ${g}/${i} failed: ${p}`);}if(g<i&&d instanceof Ae){let p=a+Math.floor(Math.random()*l);await new Promise(u=>setTimeout(u,p));}else throw d}}async delete(e){let t={"x-project-id":this.config.projectId,"x-branch-name":this.config.branch},n=await this.sendRequest(e,void 0,"DELETE",t);if(n&&!n.ok)throw new Error(`Failed sending HTTP DELETE to ${e}`)}},Ae=class extends Error{constructor(e){super(e),this.name="RetryableError";}},E=class extends Error{constructor(e){super(e),this.name="AuthenticationError";}},B=class extends Error{constructor(e){super(e),this.name="NotFoundError";}},T=class extends Error{constructor(t,n,r){super(t);this.code=n;this.projectId=r;this.name="ProjectValidationError";}},X=class extends Error{constructor(t,n){super(t);this.branchName=n;this.name="IndexingInProgressError";}};});async function mn(s){if(!s.startsWith("http://")&&!s.startsWith("https://"))return false;try{switch(process.platform){case "darwin":return await gt("open",[s]),!0;case "linux":return await gt("xdg-open",[s]),!0;case "win32":return await gt("cmd",["/c","start","",s]),!0;default:return !1}}catch{return false}}var gt,fn=m(()=>{gt=promisify(execFile);});function hn(){return new Promise((s,e)=>{let t=createServer(),n,r=false;t.listen(0,"127.0.0.1",()=>{let o=t.address();if(!o||typeof o=="string"){t.close(),e(new Error("Failed to bind callback server"));return}s({port:o.port,close(){n&&(clearTimeout(n),n=void 0),t.close();},waitForCallback(i,a=3e5){return new Promise((l,g)=>{n=setTimeout(()=>{n=void 0,r=true,t.close(),g(new Error("Authentication timed out"));},a),t.on("request",(d,p)=>{let u=new URL(d.url??"/",`http://127.0.0.1:${o.port}`);if(u.pathname!=="/callback"){p.writeHead(404,{"Content-Type":"text/plain"}),p.end("Not found");return}let f=u.searchParams.get("key");if(u.searchParams.get("state")!==i){p.writeHead(400,{"Content-Type":"text/plain"}),p.end("Invalid state parameter");return}if(!f||!io.test(f)){p.writeHead(400,{"Content-Type":"text/plain"}),p.end("Invalid key format");return}if(r)return;r=true;let _=u.searchParams.get("return_url");_?(p.writeHead(302,{Location:_}),p.end()):(p.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),p.end(so)),n&&(clearTimeout(n),n=void 0),t.close(),l(f);});})}});}),t.on("error",o=>{e(o);});})}var io,so,yn=m(()=>{io=/^ak:[0-9a-f]{32}$/i,so=`<!DOCTYPE html>
2
+ import {base32}from'@scure/base';import {Readable}from'stream';import l from'ansi-colors';import*as ie from'os';import ie__default from'os';import {Agent,fetch as fetch$1}from'undici';import {execFile,spawn}from'child_process';import {promisify}from'util';import {createServer}from'http';import {randomBytes}from'crypto';import Sr from'enquirer';import*as N from'fs/promises';import N__default from'fs/promises';import*as Ye from'fs';import {readFileSync}from'fs';import go from'tree-sitter';import*as v from'path';import v__default,{dirname,join}from'path';import Sn from'ignore';import {z as z$1}from'zod';import ut from'zlib';import {pipeline}from'stream/promises';import {PYTHON_STDLIB_MODULES}from'@constellationdev/types';import {performance}from'perf_hooks';import {findAll,find,parse}from'tsconfck';import Fo from'tree-sitter-javascript';import Mo from'tree-sitter-python';import Do from'tree-sitter-typescript';import {parseDocument,isMap,isSeq}from'yaml';import {simpleGit}from'simple-git';import {fileURLToPath}from'url';import {Command}from'commander';var Mr=Object.defineProperty;var m=(s,e)=>()=>(s&&(e=s(s=0)),e);var on=(s,e)=>{for(var t in e)Mr(s,t,{get:e[t],enumerable:true});};var Te,lt=m(()=>{Te=["help","--help","-h","--version","-V","-v"];});function an(s){return base32.encode(Buffer.from(s))}var ln=m(()=>{});function cn(s,e,t){let n=`${s}:${e}${t?`:${t}`:""}`;return an(n)}var pn=m(()=>{ln();});var Ne,gn=m(()=>{Ne=class extends Readable{dataSource;sourceIterator;reading=false;constructor(e){super(),this.dataSource=e,this.sourceIterator=this.dataSource[Symbol.asyncIterator]();}async _read(){if(!this.reading){this.reading=true;try{for(;;){let{value:e,done:t}=await this.sourceIterator.next();if(t){this.push(null);break}let n=JSON.stringify(e)+`
3
+ `,r=Buffer.from(n,"utf8");if(!this.push(r))break}}catch(e){this.destroy(e);}finally{this.reading=false;}}}_destroy(e,t){this.dataSource.return?this.dataSource.return(null).then(()=>t(e),n=>t(e||n)):t(e);}};});function Ur(){return process.env.CONSTELLATION_ASCII_MODE==="1"?false:process.env.CI?true:ie.platform()==="win32"?!!(process.env.WT_SESSION||process.env.TERM_PROGRAM==="vscode"||process.env.TERM_PROGRAM==="Hyper"||process.env.TERM&&process.env.TERM!=="cygwin"&&process.env.TERM!=="dumb"):true}var Gr,Wr,zr,Kr,Vr,Jr,Yr,qr,Xr,Zr,pe,w,P,C,y,D,k=m(()=>{Gr="\u2714",Wr="\u2717",zr="\u26A0",Kr="\u2139",Vr="\u26A1",Jr="[OK]",Yr="[ERR]",qr="[WARN]",Xr="[INFO]",Zr="[>>]",pe=Ur(),w=l.green(pe?Gr:Jr),P=l.red(pe?Wr:Yr),C=l.yellow(pe?zr:qr),y=l.blue(pe?Kr:Xr),D=l.yellow(pe?Vr:Zr);});var Re,Ae,E,B,T,X,ct=m(()=>{pn();gn();k();Re=class{constructor(e,t){this.config=e;this.accessKey=t;}apiVersion="intel/v1";async getProjectState(){let e={"Content-Type":"application/x-ndjson; charset=utf-8","x-project-id":this.config.projectId,"x-branch-name":this.config.branch,Authorization:`Bearer ${this.accessKey}`},t=await this.sendRequest("project",void 0,"GET",e);return t&&!t.ok&&await this.handleProjectStateError(t),t.json()}async handleProjectStateError(e){try{let t=await e.json(),n=t?.code;switch(n){case "PROJECT_NOT_REGISTERED":throw new T(t?.message||"Project not registered",n,this.config.projectId);case "PROJECT_INACTIVE":throw new T(t?.message||"Project is inactive",n,this.config.projectId);case "INVALID_PROJECT_ID":throw new T(t?.message||"Invalid project ID format",n,this.config.projectId);case "PROJECT_NOT_FOUND":throw new B("Project not found - no previous index exists");default:throw e.status===404?new B("Project not found - no previous index exists"):new Error(`Unexpected API response (${e.status}): ${t?.message||e.statusText}`)}}catch(t){throw t instanceof T||t instanceof B?t:e.status===404?new B("Project not found - no previous index exists"):new Error(`Unexpected API response (${e.status})`)}}async getIndexStatus(e,t){let n=new URLSearchParams({branch:e});t&&n.set("commit",t);let r=`projects/${encodeURIComponent(this.config.projectId)}/index-status?${n.toString()}`;try{let o=await this.sendRequest(r,null,"GET");return !o||!o.ok?null:await o.json()}catch(o){if(o instanceof E)throw o;return null}}async deleteFiles(e){for(let t of e){let n=cn(this.config.projectId,this.config.branch,t);await this.delete(`/ast/${n}`);}}retryableStatusCodes=[500,502,503,504];async streamToApi(e,t,n,r,o,i){try{let{Readable:a}=await import('stream'),c=new Ne(e),g=a.toWeb(c),d=new Agent({headersTimeout:0,bodyTimeout:0}),p=await fetch$1(`${this.config.apiUrl}/${this.apiVersion}/${t}`,{method:"POST",headers:{"Content-Type":"application/x-ndjson; charset=utf-8","x-project-id":n,"x-branch-name":r,"x-constellation-index":o?"incremental":"full",Authorization:`Bearer ${this.accessKey}`,...i&&{"x-commit-hash":i}},body:g,duplex:"half",dispatcher:d});if(p.status===401)throw new E("Authentication failed");if(p.status===409){let u="Indexing already in progress",b;try{let _=await p.json();u=_?.message||u,b=_?.details?.branchName;}catch{}throw new X(u,b)}if(p.status===200)try{let u=await p.json();if(u?.status==="current")return console.log(`${w} Index already up to date for ${r} at commit ${u.commitHash||"unknown"}`),!0}catch{}if(p.ok||p.status===202)return !0;let f=`Server returned ${p.status}`;try{let u=await p.json();u?.message&&(f=Array.isArray(u.message)?u.message.join("; "):u.message);}catch{}throw new Error(f)}catch(a){if(a instanceof E||a instanceof X)throw a;let c=a instanceof Error?a:new Error(String(a)),g="";if(c.message==="fetch failed"||a.code){let p=[],f=a.code||a.cause?.code;if(a.code&&p.push(`Error Code: ${a.code}`),a.cause){let u=a.cause;u.code&&p.push(`Cause Code: ${u.code}`),u.errno&&p.push(`Errno: ${u.errno}`),u.syscall&&p.push(`System Call: ${u.syscall}`),u.address&&p.push(`Address: ${u.address}`),u.port&&p.push(`Port: ${u.port}`);}f==="ERR_INVALID_ARG_VALUE"?g="Invalid argument value - check stream/body format and duplex option":f==="ECONNREFUSED"?g="Connection refused - service may be down or unreachable":f==="ENOTFOUND"?g="DNS lookup failed - check service URL":f==="ETIMEDOUT"?g="Connection timeout - service not responding":f==="ECONNRESET"?g="Connection reset by server":f==="EHOSTUNREACH"?g="Host unreachable - check network connectivity":g="Network failure",p.length>0&&(g+=` (${p.join(", ")})`);}else g=c.message;let d=new Error(`Failed to upload data to Constellation Service: ${g}`);throw d.cause=c,d.stack=`${d.stack}
4
+ Caused by: ${c.stack}`,d}}async sendRequest(e,t,n,r={},o=0,i=3,a=1e3,c=250){for(let g=1;g<=i;g++)try{let d=new AbortController,p;o>0&&(p=setTimeout(()=>d.abort(),o));let f={...r,"Content-Type":"application/json; charset=utf-8",Accepts:"application/json; charset=utf-8",Authorization:`Bearer ${this.accessKey}`},u=await fetch(`${this.config.apiUrl}/${this.apiVersion}/${e}`,{method:n,headers:f,body:t?JSON.stringify(t):void 0,signal:d.signal});if(p&&clearTimeout(p),u.status===401)throw new E("Authentication failed");if(!u.ok&&this.retryableStatusCodes.includes(u.status))throw new Ae(`${u.statusText} (${u.status})`);return u}catch(d){if(!(d instanceof E)){let p=d instanceof Error?`${d.message}${d.cause?` (Cause: ${d.cause})`:""}`:String(d);console.log(`HTTP request attempt ${g}/${i} failed: ${p}`);}if(g<i&&d instanceof Ae){let p=a+Math.floor(Math.random()*c);await new Promise(f=>setTimeout(f,p));}else throw d}}async delete(e){let t={"x-project-id":this.config.projectId,"x-branch-name":this.config.branch},n=await this.sendRequest(e,void 0,"DELETE",t);if(n&&!n.ok)throw new Error(`Failed sending HTTP DELETE to ${e}`)}},Ae=class extends Error{constructor(e){super(e),this.name="RetryableError";}},E=class extends Error{constructor(e){super(e),this.name="AuthenticationError";}},B=class extends Error{constructor(e){super(e),this.name="NotFoundError";}},T=class extends Error{constructor(t,n,r){super(t);this.code=n;this.projectId=r;this.name="ProjectValidationError";}},X=class extends Error{constructor(t,n){super(t);this.branchName=n;this.name="IndexingInProgressError";}};});async function un(s){if(!s.startsWith("http://")&&!s.startsWith("https://"))return false;try{switch(process.platform){case "darwin":return await pt("open",[s]),!0;case "linux":return await pt("xdg-open",[s]),!0;case "win32":return await pt("cmd",["/c","start","",s]),!0;default:return !1}}catch{return false}}var pt,fn=m(()=>{pt=promisify(execFile);});function mn(){return new Promise((s,e)=>{let t=createServer(),n,r=false;t.listen(0,"127.0.0.1",()=>{let o=t.address();if(!o||typeof o=="string"){t.close(),e(new Error("Failed to bind callback server"));return}s({port:o.port,close(){n&&(clearTimeout(n),n=void 0),t.close();},waitForCallback(i,a=3e5){return new Promise((c,g)=>{n=setTimeout(()=>{n=void 0,r=true,t.close(),g(new Error("Authentication timed out"));},a),t.on("request",(d,p)=>{let f=new URL(d.url??"/",`http://127.0.0.1:${o.port}`);if(f.pathname!=="/callback"){p.writeHead(404,{"Content-Type":"text/plain"}),p.end("Not found");return}let u=f.searchParams.get("key");if(f.searchParams.get("state")!==i){p.writeHead(400,{"Content-Type":"text/plain"}),p.end("Invalid state parameter");return}if(!u||!oo.test(u)){p.writeHead(400,{"Content-Type":"text/plain"}),p.end("Invalid key format");return}if(r)return;r=true;let _=f.searchParams.get("return_url");_?(p.writeHead(302,{Location:_}),p.end()):(p.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),p.end(io)),n&&(clearTimeout(n),n=void 0),t.close(),c(u);});})}});}),t.on("error",o=>{e(o);});})}var oo,io,hn=m(()=>{oo=/^ak:[0-9a-f]{32}$/i,io=`<!DOCTYPE html>
5
5
  <html><head><title>Authentication Successful</title></head>
6
- <body><h1>Authentication successful! You can close this tab.</h1></body></html>`;});function dt(s){console.log(`\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E
7
- \u2502 ${c.gray("'")} ${c.blueBright(".")} ${c.dim("`")} ${c.yellowBright("'")} ${c.blueBright("+")} ${c.whiteBright(".")} ${c.gray(".")} ${c.yellowBright("'")} ${c.yellowBright("*")} ${c.whiteBright("'")} ${c.blueBright("+")} ${c.gray(".")} ${c.yellowBright("*")} ${c.whiteBright(",")} ${c.gray.dim(".")}\u2502
8
- \u2502 _____ ${c.yellowBright("*")} ${c.dim("`")} __${c.whiteBright(".")} ${c.whiteBright("'")} ____ ${c.dim(".")} __ _ ${c.gray("`")} . . ${c.yellowBright("o")} ${c.blueBright("+")} \u2502
9
- \u2502 ${c.blueBright(".")} / ___/__ ___ ___ / /____ / / /__ _/ /_(_)__ ___ ${c.gray(".")} ${c.yellowBright("'")} ${c.gray("+")} ${c.gray("\\")} ${c.gray("`")} \u2502
10
- \u2502 / /__/ _ \\/ _ \\(_-</ __/ -_) / / _ \`/ __/ / _ \\/ _ \\ ${c.gray("'")} ${c.blueBright("o")}${c.gray("\u2014\u2014\u2014\u2014")}${c.yellowBright("o")} ${c.whiteBright("o")} ${c.whiteBright(".")} \u2502
11
- \u2502 \\___/\\___/_//_/___/\\__/\\__/_/_/\\_,_/\\__/_/\\___/_//_/ ${c.gray(".")} ${c.whiteBright("*")} ${c.gray(" \\ \\ ")}${c.gray("/")} \u2502
12
- \u2502 ${c.whiteBright("'")} ${c.blueBright(".")} ${c.gray("'")} ${c.whiteBright(".")} ${c.blueBright(".")} ${c.gray(".")} ${c.yellowBright("*")} ${c.blueBright.dim("+")} ${c.whiteBright("o o")}${c.gray("\u2014")}${c.blueBright("o")} ${c.yellowBright("*")} \u2502
13
- \u2502${c.yellowBright("'")} ${c.whiteBright("*")} ${c.blueBright("+")} ${c.yellowBright("*")} ${c.gray(",")} ${c.whiteBright("'")} + ${c.whiteBright("constellationdev.io")} ${c.whiteBright("' .")} ${c.gray(",")} ${c.blueBright("*")} ${c.yellowBright(".")} ${c.whiteBright("+")} \u2502`),s&&s.length>0?console.log(`\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${"\u2500".repeat(s.length)}\u2500\u252C${"\u2500".repeat(59-s.length)}\u256F
14
- \u2502 ${c.bold(`constellation \u203A ${s}`)} \u2502
6
+ <body><h1>Authentication successful! You can close this tab.</h1></body></html>`;});function gt(s){console.log(`\u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E
7
+ \u2502 ${l.gray("'")} ${l.blueBright(".")} ${l.dim("`")} ${l.yellowBright("'")} ${l.blueBright("+")} ${l.whiteBright(".")} ${l.gray(".")} ${l.yellowBright("'")} ${l.yellowBright("*")} ${l.whiteBright("'")} ${l.blueBright("+")} ${l.gray(".")} ${l.yellowBright("*")} ${l.whiteBright(",")} ${l.gray.dim(".")}\u2502
8
+ \u2502 _____ ${l.yellowBright("*")} ${l.dim("`")} __${l.whiteBright(".")} ${l.whiteBright("'")} ____ ${l.dim(".")} __ _ ${l.gray("`")} . . ${l.yellowBright("o")} ${l.blueBright("+")} \u2502
9
+ \u2502 ${l.blueBright(".")} / ___/__ ___ ___ / /____ / / /__ _/ /_(_)__ ___ ${l.gray(".")} ${l.yellowBright("'")} ${l.gray("+")} ${l.gray("\\")} ${l.gray("`")} \u2502
10
+ \u2502 / /__/ _ \\/ _ \\(_-</ __/ -_) / / _ \`/ __/ / _ \\/ _ \\ ${l.gray("'")} ${l.blueBright("o")}${l.gray("\u2014\u2014\u2014\u2014")}${l.yellowBright("o")} ${l.whiteBright("o")} ${l.whiteBright(".")} \u2502
11
+ \u2502 \\___/\\___/_//_/___/\\__/\\__/_/_/\\_,_/\\__/_/\\___/_//_/ ${l.gray(".")} ${l.whiteBright("*")} ${l.gray(" \\ \\ ")}${l.gray("/")} \u2502
12
+ \u2502 ${l.whiteBright("'")} ${l.blueBright(".")} ${l.gray("'")} ${l.whiteBright(".")} ${l.blueBright(".")} ${l.gray(".")} ${l.yellowBright("*")} ${l.blueBright.dim("+")} ${l.whiteBright("o o")}${l.gray("\u2014")}${l.blueBright("o")} ${l.yellowBright("*")} \u2502
13
+ \u2502${l.yellowBright("'")} ${l.whiteBright("*")} ${l.blueBright("+")} ${l.yellowBright("*")} ${l.gray(",")} ${l.whiteBright("'")} + ${l.whiteBright("constellationdev.io")} ${l.whiteBright("' .")} ${l.gray(",")} ${l.blueBright("*")} ${l.yellowBright(".")} ${l.whiteBright("+")} \u2502`),s&&s.length>0?console.log(`\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${"\u2500".repeat(s.length)}\u2500\u252C${"\u2500".repeat(59-s.length)}\u256F
14
+ \u2502 ${l.bold(`constellation \u203A ${s}`)} \u2502
15
15
  \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500${"\u2500".repeat(s.length)}\u2500\u256F
16
- `):console.log("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");}var H,Cn,je=m(()=>{`
16
+ `):console.log("\u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F");}var H,yn,je=m(()=>{`
17
17
  \u256D\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256E
18
- \u2502 ${c.gray("'")} ${c.blueBright(".")} ${c.dim("`")} ${c.yellowBright("'")} ${c.blueBright("+")} ${c.whiteBright(".")} ${c.gray(".")} ${c.yellowBright("'")} ${c.yellowBright("*")} ${c.whiteBright("'")} ${c.blueBright("+")} ${c.gray(".")} ${c.yellowBright("*")} ${c.whiteBright(",")} ${c.gray.dim(".")}\u2502
19
- \u2502 _____ ${c.yellowBright("*")} ${c.dim("`")} __${c.whiteBright(".")} ${c.whiteBright("'")} ____ ${c.dim(".")} __ _ ${c.gray("`")} . . ${c.yellowBright("o")} ${c.blueBright("+")} \u2502
20
- \u2502 ${c.blueBright(".")} / ___/__ ___ ___ / /____ / / /__ _/ /_(_)__ ___ ${c.gray(".")} ${c.yellowBright("'")} ${c.gray("+")} ${c.gray("\\")} ${c.gray("`")} \u2502
21
- \u2502 / /__/ _ \\/ _ \\(_-</ __/ -_) / / _ \`/ __/ / _ \\/ _ \\ ${c.gray("'")} ${c.blueBright("o")}${c.gray("\u2014\u2014\u2014\u2014")}${c.yellowBright("o")} ${c.whiteBright("o")} ${c.whiteBright(".")} \u2502
22
- \u2502 \\___/\\___/_//_/___/\\__/\\__/_/_/\\_,_/\\__/_/\\___/_//_/ ${c.gray(".")} ${c.whiteBright("*")} ${c.gray(" \\ \\ ")}${c.gray("/")} \u2502
23
- \u2502 ${c.whiteBright("'")} ${c.blueBright(".")} ${c.gray("'")} ${c.whiteBright(".")} ${c.blueBright(".")} ${c.gray(".")} ${c.yellowBright("*")} ${c.blueBright.dim("+")} ${c.whiteBright("o o")}${c.gray("\u2014")}${c.blueBright("o")} ${c.yellowBright("*")} \u2502
24
- \u2502${c.yellowBright("'")} ${c.whiteBright("*")} ${c.blueBright("+")} ${c.yellowBright("*")} ${c.gray(",")} ${c.whiteBright("'")} + ${c.whiteBright("constellationdev.io")} ${c.whiteBright("' .")} ${c.gray(",")} ${c.blueBright("*")} ${c.yellowBright(".")} ${c.whiteBright("+")} \u2502
18
+ \u2502 ${l.gray("'")} ${l.blueBright(".")} ${l.dim("`")} ${l.yellowBright("'")} ${l.blueBright("+")} ${l.whiteBright(".")} ${l.gray(".")} ${l.yellowBright("'")} ${l.yellowBright("*")} ${l.whiteBright("'")} ${l.blueBright("+")} ${l.gray(".")} ${l.yellowBright("*")} ${l.whiteBright(",")} ${l.gray.dim(".")}\u2502
19
+ \u2502 _____ ${l.yellowBright("*")} ${l.dim("`")} __${l.whiteBright(".")} ${l.whiteBright("'")} ____ ${l.dim(".")} __ _ ${l.gray("`")} . . ${l.yellowBright("o")} ${l.blueBright("+")} \u2502
20
+ \u2502 ${l.blueBright(".")} / ___/__ ___ ___ / /____ / / /__ _/ /_(_)__ ___ ${l.gray(".")} ${l.yellowBright("'")} ${l.gray("+")} ${l.gray("\\")} ${l.gray("`")} \u2502
21
+ \u2502 / /__/ _ \\/ _ \\(_-</ __/ -_) / / _ \`/ __/ / _ \\/ _ \\ ${l.gray("'")} ${l.blueBright("o")}${l.gray("\u2014\u2014\u2014\u2014")}${l.yellowBright("o")} ${l.whiteBright("o")} ${l.whiteBright(".")} \u2502
22
+ \u2502 \\___/\\___/_//_/___/\\__/\\__/_/_/\\_,_/\\__/_/\\___/_//_/ ${l.gray(".")} ${l.whiteBright("*")} ${l.gray(" \\ \\ ")}${l.gray("/")} \u2502
23
+ \u2502 ${l.whiteBright("'")} ${l.blueBright(".")} ${l.gray("'")} ${l.whiteBright(".")} ${l.blueBright(".")} ${l.gray(".")} ${l.yellowBright("*")} ${l.blueBright.dim("+")} ${l.whiteBright("o o")}${l.gray("\u2014")}${l.blueBright("o")} ${l.yellowBright("*")} \u2502
24
+ \u2502${l.yellowBright("'")} ${l.whiteBright("*")} ${l.blueBright("+")} ${l.yellowBright("*")} ${l.gray(",")} ${l.whiteBright("'")} + ${l.whiteBright("constellationdev.io")} ${l.whiteBright("' .")} ${l.gray(",")} ${l.blueBright("*")} ${l.yellowBright(".")} ${l.whiteBright("+")} \u2502
25
25
  \u2570\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u256F
26
26
  `,`
27
- ${c.yellowBright(" o")}
28
- ${c.gray(" \\")}
29
- ${c.blueBright(" o")}${c.blueBright("----")}${c.yellowBright("o")} ${c.gray("o")}
30
- ${c.gray(" \\ \\ ")}${c.blueBright("/")}
31
- ${c.whiteBright(" o o")}${c.blueBright("-")}${c.blueBright("o")}
32
- `,H="CONSTELLATION_ACCESS_KEY",Cn="CONSTELLATION_WEB_URL";});var U,Le=m(()=>{U=class{git;config;langRegistry;env;constructor(e){this.git=e.GitClient,this.config=e.Config,this.langRegistry=e.LanguageRegistry,this.env=e.Environment;}};});function po(s){return lo.test(s)}function go(s){return s.replace(/ak:[0-9a-f]{32}/gi,"[REDACTED]")}var wn,lo,ge,_n=m(()=>{fn();yn();je();k();Le();(({prompt:wn}=Sr)),lo=/^ak:[0-9a-f]{32}$/i;ge=class extends U{async run(e){try{if(!this.env)throw new Error("Environment manager not initialized");if(console.log(`${D}Configuring access key authentication...
27
+ ${l.yellowBright(" o")}
28
+ ${l.gray(" \\")}
29
+ ${l.blueBright(" o")}${l.blueBright("----")}${l.yellowBright("o")} ${l.gray("o")}
30
+ ${l.gray(" \\ \\ ")}${l.blueBright("/")}
31
+ ${l.whiteBright(" o o")}${l.blueBright("-")}${l.blueBright("o")}
32
+ `,H="CONSTELLATION_ACCESS_KEY",yn="CONSTELLATION_WEB_URL";});var U,Le=m(()=>{U=class{git;config;langRegistry;env;constructor(e){this.git=e.GitClient,this.config=e.Config,this.langRegistry=e.LanguageRegistry,this.env=e.Environment;}};});function co(s){return lo.test(s)}function po(s){return s.replace(/ak:[0-9a-f]{32}/gi,"[REDACTED]")}var Cn,lo,ge,wn=m(()=>{fn();hn();je();k();Le();(({prompt:Cn}=Sr)),lo=/^ak:[0-9a-f]{32}$/i;ge=class extends U{async run(e){try{if(!this.env)throw new Error("Environment manager not initialized");if(console.log(`${D}Configuring access key authentication...
33
33
  `),this.env.isCI()){console.error(`${P} Cannot configure authentication in CI/CD environments
34
34
 
35
35
  The ${H} environment variable must be configured
@@ -40,29 +40,29 @@ ${c.whiteBright(" o o")}${c.blueBright("-")}${c.blueBright("o")}
40
40
  - Azure DevOps: Pipelines -> Library -> Variable groups
41
41
  - Jenkins: Manage Jenkins -> Credentials
42
42
  - CircleCI: Project Settings -> Environment Variables
43
- `);return}if(await this.env.getKey(H)){let{replaceKey:n}=await wn({message:"Replace existing Constellation access key?",name:"replaceKey",type:"confirm",initial:!1});if(!n){console.log(`${C} Keeping existing Constellation access key`);return}}e?await this.manualAuthFlow():await this.browserAuthFlow();}catch(t){if(t==="")return;let n=t.message??"An unexpected error occurred",r=go(n);console.error(`${P} Failed to store Constellation access key
44
- ${r}`);}}async manualAuthFlow(){let e,t=0,n=3;for(;t<n;){if(e=(await wn({message:"Constellation Access Key:",name:"accessKey",type:"password",required:true})).accessKey.trim(),!e){console.log(`${w} Access key cannot be empty.
45
- `),t++;continue}if(!po(e)){if(t++,t<n)console.log(`${w} Invalid access key format. Expected format: ak:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
43
+ `);return}if(await this.env.getKey(H)){let{replaceKey:n}=await Cn({message:"Replace existing Constellation access key?",name:"replaceKey",type:"confirm",initial:!1});if(!n){console.log(`${w} Keeping existing Constellation access key`);return}}e?await this.manualAuthFlow():await this.browserAuthFlow();}catch(t){if(t==="")return;let n=t.message??"An unexpected error occurred",r=po(n);console.error(`${P} Failed to store Constellation access key
44
+ ${r}`);}}async manualAuthFlow(){let e,t=0,n=3;for(;t<n;){if(e=(await Cn({message:"Constellation Access Key:",name:"accessKey",type:"password",required:true})).accessKey.trim(),!e){console.log(`${C} Access key cannot be empty.
45
+ `),t++;continue}if(!co(e)){if(t++,t<n)console.log(`${C} Invalid access key format. Expected format: ak:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
46
46
  Attempts remaining: ${n-t}
47
47
  `);else {console.error(`${P} Invalid access key format after ${n} attempts.
48
- Please verify your access key and try again.`);return}continue}break}await this.storeKey(e);}async browserAuthFlow(){let e=randomBytes(16).toString("hex"),{port:t,waitForCallback:n}=await hn(),o=`${process.env[Cn]||"https://app.constellationdev.io"}/auth/cli?callback_port=${t}&state=${e}`;console.log(`${y} Opening browser for authentication...`),await mn(o)||console.log(`${w} Could not open browser automatically.
48
+ Please verify your access key and try again.`);return}continue}break}await this.storeKey(e);}async browserAuthFlow(){let e=randomBytes(16).toString("hex"),{port:t,waitForCallback:n}=await mn(),o=`${process.env[yn]||"https://app.constellationdev.io"}/auth/cli?callback_port=${t}&state=${e}`;console.log(`${y} Opening browser for authentication...`),await un(o)||console.log(`${C} Could not open browser automatically.
49
49
  Please open this URL manually:
50
50
 
51
51
  ${o}
52
52
  `),console.log(`${y} Waiting for authentication... (press Ctrl+C to cancel)
53
53
  `);try{let a=await n(e);await this.storeKey(a);}catch{console.error(`${P} Authentication timed out.
54
- Try again or use \`constellation auth --manual\` to paste your key directly.`);}}async storeKey(e){await this.env.setKey(H,e),console.log(`${C} Stored access key in ${H} user environment variable`);let t=this.env.getSourceFile();t&&console.log(`${y} To activate in this session, run:
54
+ Try again or use \`constellation auth --manual\` to paste your key directly.`);}}async storeKey(e){await this.env.setKey(H,e),console.log(`${w} Stored access key in ${H} user environment variable`);let t=this.env.getSourceFile();t&&console.log(`${y} To activate in this session, run:
55
55
 
56
56
  source ${t}
57
57
 
58
- New terminal sessions will load it automatically.`);}};});var h,F=m(()=>{h={async directoryExists(s){try{return (await N__default.stat(s)).isDirectory()}catch{return false}},async fileIsReadable(s){try{return await N__default.access(s,N__default.constants.R_OK),!0}catch{return false}},async readFile(s,e="utf-8"){let t=await N__default.readFile(s,{encoding:e,flag:N__default.constants.O_RDONLY});return t.charCodeAt(0)===65279&&(t=t.slice(1)),t},async writeFile(s,e,t="utf-8"){let n=Buffer.from(e,t);await N__default.writeFile(s,n,{encoding:t,flag:N__default.constants.O_WRONLY|N__default.constants.O_CREAT|N__default.constants.O_TRUNC});},async getFileStats(s){return await N__default.stat(s)},async getFileHandle(s,e,t){return await N__default.open(s,e,t)}};});var Oe,bn=m(()=>{F();Oe=class{constructor(e){this.langRegistry=e;}async parseFile(e,t){let n=this.langRegistry[t]?.language;if(!n)throw new Error(`Unsupported language: ${t}`);let r=await n();if(!r)throw new Error(`Failed to load language: ${t}`);let o=new uo;o.setLanguage(r);let i=await h.getFileStats(e),a=10*1024*1024;if(i.size<=a){let l=await h.readFile(e),g={bufferSize:1024*1024};return o.parse(l,void 0,g)}else return this.parseWithStream(o,e,i.size)}async parseWithStream(e,t,n){let r=null;try{r=await N.open(t,"r");let o=r.fd,i=64*1024,a=Buffer.alloc(i),l=0;return e.parse(d=>{if(n>50*1024*1024){let u=Math.round(d/n*100);u>l+10&&(console.log(` Parsing large file: ${u}%...`),l=u);}let p=qe.readSync(o,a,0,i,d);return p===0?null:a.subarray(0,p).toString("utf-8")})}catch(o){if(r)try{await r.close();}catch(i){console.error(`Warning: Failed to close file handle for ${t}:`,i);}throw o}finally{if(r)try{await r.close();}catch{}}}};});function xn(s){return s.replace(/\\/g,"/")}function Fe(s){return xn(s).replace(/^\.?\//,"")}function G(s,e){return xn(v.relative(s,e))}var Z=m(()=>{});var Me,En=m(()=>{F();Z();k();Me=class{rootPath;constructor(e){this.rootPath=e||process.cwd();}async scanFiles(e){let t=Sn();return await this.loadGitignoreRules(t,this.rootPath),e.exclude&&e.exclude.length>0&&t.add(e.exclude),(await this.walkDirectory(this.rootPath)).filter(o=>!t.ignores(o.relativePath)&&this.matchesLanguageExtension(o,e.languages))}async scanSpecificFiles(e,t){let n=[],r=null;t.exclude&&t.exclude.length>0&&(r=Sn().add(t.exclude));let o=await N__default.realpath(this.rootPath);for(let i of e)try{let a=v__default.isAbsolute(i)?i:v__default.join(this.rootPath,i),l=await N__default.lstat(a);if(l.isSymbolicLink()){let g=await N__default.realpath(a);if(!g.startsWith(o+v__default.sep)&&g!==o){console.warn(`${w} Skipping symlink pointing outside project: ${i} -> ${g}`);continue}let d=await N__default.stat(a);if(!d.isFile())continue;let p=G(this.rootPath,a);if(r&&r.ignores(p))continue;let u=this.detectLanguage(p,t.languages);if(!u)continue;n.push({path:a,relativePath:p,language:u,size:d.size});}else if(l.isFile()){let g=G(this.rootPath,a);if(r&&r.ignores(g))continue;let d=this.detectLanguage(g,t.languages);if(!d)continue;n.push({path:a,relativePath:g,language:d,size:l.size});}}catch{console.warn(`${w} Skipping inaccessible file: ${i}`);}return n}async loadGitignoreRules(e,t){let n=[],r=t;for(;;){let o=v__default.join(r,".gitignore");await h.fileIsReadable(o)&&n.unshift(o);let i=v__default.dirname(r);if(i===r)break;r=i;let a=v__default.join(r,".git");if(await h.directoryExists(a)){let l=v__default.join(r,".gitignore");await h.fileIsReadable(l)&&!n.includes(l)&&n.unshift(l);break}}for(let o of n)try{let i=await h.readFile(o);e.add(i);}catch{console.warn(`${w} Failed to load .gitignore: ${o}`);}e.add(".git");}async walkDirectory(e,t,n){let r=[],o=t||e,i=n||await N__default.realpath(this.rootPath);try{let a=await N__default.readdir(e,{withFileTypes:!0});for(let l of a){let g=v__default.join(e,l.name),d=G(o,g);if(l.isDirectory()){if(l.name.startsWith("."))continue;let p=await this.walkDirectory(g,o,i);r.push(...p);}else if(l.isFile()){let p=await N__default.stat(g);r.push({path:g,relativePath:d,language:"",size:p.size});}else if(l.isSymbolicLink())try{let p=await N__default.realpath(g);if(!p.startsWith(i+v__default.sep)&&p!==i){console.warn(`${w} Skipping symlink pointing outside project: ${g} -> ${p}`);continue}let u=await N__default.stat(g);if(u.isDirectory()){if(l.name.startsWith("."))continue;let f=await this.walkDirectory(g,o,i);r.push(...f);}else u.isFile()&&r.push({path:g,relativePath:d,language:"",size:u.size});}catch{console.warn(`${w} Skipping invalid symlink: ${g}`);}}}catch(a){console.error(`${P} Error walking directory ${e}:`,a);}return r}matchesLanguageExtension(e,t){let n=v__default.extname(e.path).toLowerCase();for(let[r,o]of Object.entries(t))if(o.fileExtensions.includes(n))return e.language=r,true;return false}detectLanguage(e,t){let n=v__default.extname(e).toLowerCase();for(let[r,o]of Object.entries(t))if(o.fileExtensions.includes(n))return r;return null}};});var mo,fo,In,$n=m(()=>{mo=z$1.object({source:z$1.string().min(1,"Import source cannot be empty"),resolvedPath:z$1.string().optional(),isExternal:z$1.boolean(),importType:z$1.enum(["relative","workspace","alias","external","builtin"])}),fo=z$1.record(z$1.string(),mo),In=z$1.object({file:z$1.string().min(1,"File path cannot be empty").max(1e3,"File path too long"),language:z$1.string().regex(/^(bash|c|c-sharp|cpp|go|java|javascript|json|php|python|ruby|typescript)$/,"Invalid language identifier"),commit:z$1.string().regex(/^[a-f0-9]{40}$/,"Invalid git commit hash"),timestamp:z$1.string().datetime({message:"Invalid ISO timestamp"}),ast:z$1.string().min(1,"AST data cannot be empty").max(1e7,"AST data exceeds 10MB limit"),importResolutions:fo.optional()});});var yo,De,Nn=m(()=>{yo=promisify(mt.gunzip),De=class{*serializeASTChunks(e){if(yield "{",yield `"type":"${e.type}"`,yield `,"startPosition":${JSON.stringify(e.startPosition)}`,yield `,"endPosition":${JSON.stringify(e.endPosition)}`,e.fieldName!==void 0&&(yield `,"fieldName":"${e.fieldName}"`),e.text!==void 0&&(yield `,"text":${JSON.stringify(e.text)}`),e.children&&e.children.length>0){yield ',"children":[';for(let t=0;t<e.children.length;t++)t>0&&(yield ","),yield*this.serializeASTChunks(e.children[t]);yield "]";}yield "}";}async compressStream(e){let t=[],n=mt.createGzip();n.on("data",i=>t.push(i));let r=new Promise((i,a)=>{n.on("end",i),n.on("error",a);}),o=Readable.from(e);return await pipeline(o,n),await r,Buffer.concat(t).toString("base64")}async compress(e){let t=[],n=mt.createGzip();n.on("data",i=>t.push(i));let r=new Promise((i,a)=>{n.on("end",i),n.on("error",a);}),o=Readable.from(this.serializeASTChunks(e));return await pipeline(o,n),await r,Buffer.concat(t).toString("base64")}async decompress(e){let t=Buffer.from(e,"base64"),n=await yo(t);return JSON.parse(n.toString("utf-8"))}};});var Be,Rn=m(()=>{Be=class{constructor(e=10){this.concurrency=e;if(e<1)throw new Error("Concurrency must be at least 1")}async*run(e,t){if(e.length===0)return;let n=new Map,r=0,o=0;for(;o<e.length&&n.size<this.concurrency;){let i=r++,a=this.processItem(e[o],o,t).then(l=>({result:l!==null?l.result:null,promiseId:i}));n.set(i,a),o++;}for(;n.size>0;){let i=await Promise.race(n.values());if(n.delete(i.promiseId),i.result!==null&&(yield i.result),o<e.length){let a=r++,l=this.processItem(e[o],o,t).then(g=>({result:g!==null?g.result:null,promiseId:a}));n.set(a,l),o++;}}}async processItem(e,t,n){try{return {result:await n(e,t),index:t}}catch{return null}}};});async function W(s,e,t,n,r){let o=await t.resolve(s),i=An(s,o),a=r(s,o,i),l=i?void 0:Fe(o);n[e.toString()]={source:s,resolvedPath:l,isExternal:i,importType:a};}function An(s,e){return s===e?true:!(!e.startsWith(".")&&!e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))}var ft,de=m(()=>{Z();ft=(s,e,t)=>t?s.startsWith("node:")?"builtin":"external":s.startsWith("./")||s.startsWith("../")?"relative":s.startsWith("@")?"workspace":"alias";});async function Co(s,e,t,n){let r=s.childForFieldName("source");if(!r)return;let o=r.startPosition.row,i=r.text.replace(/['"]/g,"");await W(i,o,e,t,n);}async function wo(s,e,t,n){let r=s.childForFieldName("source");if(!r)return;let o=r.startPosition.row,i=r.text.replace(/['"]/g,"");await W(i,o,e,t,n);}function He(){return {language:"javascript",handlers:new Map([["import_statement",Co],["export_statement",wo]])}}function ht(){return {...He(),language:"typescript"}}var yt=m(()=>{de();});async function Po(s,e,t,n){let r=s.childForFieldName("name");if(!r)return;let o;if(r.type==="aliased_import"){let i=r.childForFieldName("name");o=i?i.text:r.text;}else o=r.text;await W(o,s.startPosition.row,e,t,n);}async function bo(s,e,t,n){let r,o=s.childForFieldName("module_name");if(o)r=o.text;else {let i="";for(let a=0;a<s.childCount;a++){let l=s.child(a);if(l){if(l.type==="relative_import"){i=l.text;break}(l.type==="."||l.type==="import_prefix")&&(i+=l.text);}}r=i||".";}await W(r,s.startPosition.row,e,t,n);}async function xo(s,e,t,n){await W("__future__",s.startPosition.row,e,t,n);}function Ct(){return {language:"python",handlers:new Map([["import_statement",Po],["import_from_statement",bo],["future_import_statement",xo]]),classifyImportType:vo}}var vo,Ue=m(()=>{de();vo=(s,e,t)=>{if(t)return "external";if(/^\.+/.test(s))return "relative";let n=s.split(".")[0];return PYTHON_STDLIB_MODULES.has(n)?"builtin":"alias"};});var Ln,On=m(()=>{yt();Ue();de();yt();Ue();Ln=[He(),ht(),Ct()];});var Fn={};sn(Fn,{ImportExtractor:()=>wt});var wt,Mn=m(()=>{On();de();wt=class{languageHandlers;classifiers;constructor(e){this.languageHandlers=new Map,this.classifiers=new Map;for(let t of e??Ln)this.languageHandlers.set(t.language,t.handlers),t.classifyImportType&&this.classifiers.set(t.language,t.classifyImportType);}async extractImportResolutions(e,t,n,r){if(!r)return {};let o=this.languageHandlers.get(n);if(!o)return {};let i=this.classifiers.get(n)??ft,a={};return await this.walkAST(e.rootNode,async l=>{let g=o.get(l.type);g&&await g(l,r,a,i);}),a}async walkAST(e,t){await t(e);for(let n=0;n<e.childCount;n++){let r=e.child(n);r&&await this.walkAST(r,t);}}};});var ue,Dn,_t,Bn,Hn,Ge=m(()=>{ue=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","string","string_literal","template_string","number","import_specifier","export_specifier","accessibility_modifier","readonly","static","async","await","const","let","var","decorator","=","=>","...","?","!","string_content"]),Dn=new Set(["true","false","null","undefined","predefined_type","type_predicate","type_predicate_annotation","type_alias","type_annotation","return_type","type_arguments","type_parameters","array_type","union_type","intersection_type","generic_type","tuple_type","function_type","object_type","mapped_type","conditional_type","infer_type"]),_t={function_declaration:["name","parameters","body","return_type","type_parameters"],function_expression:["name","parameters","body","return_type","type_parameters"],arrow_function:["parameters","body","return_type","type_parameters"],method_definition:["name","parameters","body","return_type","type_parameters"],method_signature:["name","parameters","return_type","type_parameters"],function_signature:["name","parameters","return_type","type_parameters"],type_predicate:["name","type"],class_declaration:["name","body","type_parameters","heritage"],interface_declaration:["name","body","type_parameters"],type_alias_declaration:["name","type_parameters","value"],property_signature:["name","type"],field_definition:["name","type","value"],public_field_definition:["name","type","value"],private_field_definition:["name","type","value"],required_parameter:["pattern","type","value"],optional_parameter:["pattern","type","value"],rest_parameter:["pattern","type"],variable_declarator:["name","type","value"],lexical_declaration:["kind"],call_expression:["function","arguments","type_arguments"],new_expression:["constructor","arguments","type_arguments"],member_expression:["object","property"],assignment_expression:["left","right"],binary_expression:["left","right","operator"],unary_expression:["operator","argument"],ternary_expression:["condition","consequence","alternative"],import_statement:["source","import"],import_specifier:["name","alias"],export_specifier:["name","alias"],export_statement:["source","declaration","value"],if_statement:["condition","consequence","alternative"],for_statement:["init","condition","update","body"],for_in_statement:["left","right","body"],while_statement:["condition","body"],do_statement:["body","condition"],switch_statement:["value","body"],try_statement:["body","handler","finalizer"],catch_clause:["parameter","body"],return_statement:["value"],throw_statement:["value"],type_annotation:["type"],type_parameter:["name","constraint","default"],generic_type:["name","type_arguments"]},Bn={language:"javascript",textIncludedTypes:Dn,fieldNames:_t},Hn={language:"typescript",textIncludedTypes:Dn,fieldNames:_t};});var So,Un,Gn,vt=m(()=>{So=new Set(["true","false","none","None","True","False","yield","pass","continue","break","ellipsis","dotted_name","aliased_import","not_operator","boolean_operator","comparison_operator","type","subscript","attribute","list","tuple","binary_operator","union_type","generic_type"]),Un={function_definition:["name","parameters","return_type","body","type_parameters"],async_function_definition:["name","parameters","return_type","body","type_parameters"],class_definition:["name","superclasses","body","type_parameters"],decorated_definition:["definition"],lambda:["parameters","body"],import_statement:["name"],import_from_statement:["module_name","name"],aliased_import:["name","alias"],assignment:["left","right","type"],augmented_assignment:["left","right"],type_alias_statement:["name","type_parameters","value"],annotated_assignment:["left","right","type"],except_clause:["cause"],except_group_clause:["cause"],return_statement:["value"],assert_statement:["condition","message"],delete_statement:["target"],global_statement:["name"],nonlocal_statement:["name"],typed_parameter:["name","type"],default_parameter:["name","value"],typed_default_parameter:["name","type","value"],list_splat_pattern:[],dictionary_splat_pattern:[],call:["function","arguments"],attribute:["object","attribute"],binary_operator:["left","right"],unary_operator:["argument"],not_operator:["argument"],boolean_operator:["left","right"],comparison_operator:["operators"],named_expression:["name","value"],conditional_expression:["condition","consequence","alternative"],keyword_argument:["name","value"],if_statement:["condition","consequence","alternative"],while_statement:["condition","body","alternative"],for_statement:["left","right","body"],try_statement:["body"],with_statement:["body"],with_item:["value"],finally_clause:["body"],else_clause:["body"],match_statement:["subject","body"],case_clause:["pattern","guard"],raise_statement:["cause"],list_comprehension:["body"],dictionary_comprehension:["body","key","value"],set_comprehension:["body"],generator_expression:["body"],for_in_clause:["left","right"],if_clause:["condition"],pair:["key","value"],subscript:["value","subscript"],slice:["start","stop","step"]},Gn={language:"python",textIncludedTypes:So,fieldNames:Un,shouldIncludeText:s=>{if(s.type==="string"&&s.childCount>0)return false}};});function Wn(s){return me.get(s)}function zn(s){if(!s)return ue;let e=me.get(s);if(!e)return ue;let t=new Set(ue);for(let n of e.textIncludedTypes)t.add(n);return t}function Pt(s){if(!s){let t=Array.from(me.values()).map(n=>n.fieldNames);return fe(...t)}let e=me.get(s);if(!e){let t=Array.from(me.values()).map(n=>n.fieldNames);return fe(...t)}return e.fieldNames}var me,Kn=m(()=>{bt();Ge();vt();Ge();Ge();vt();me=new Map([["javascript",Bn],["typescript",Hn],["python",Gn]]);});var Xn={};sn(Xn,{COMMON_FIELD_NAMES:()=>Et,JS_TS_FIELD_NAMES:()=>Yn,PYTHON_FIELD_NAMES:()=>qn,TEXT_INCLUDED_TYPES:()=>Vn,mergeFieldMaps:()=>fe,serializeAST:()=>Io,serializeASTStream:()=>Eo});function*Eo(s,e,t){yield*St(s,e,t);}function*St(s,e,t){if(yield "{",yield `"type":${JSON.stringify(s.type)}`,yield `,"startPosition":${JSON.stringify({row:s.startPosition.row,column:s.startPosition.column})}`,yield `,"endPosition":${JSON.stringify({row:s.endPosition.row,column:s.endPosition.column})}`,e&&(yield `,"fieldName":${JSON.stringify(e)}`),Jn(s,t)&&(yield `,"text":${JSON.stringify(s.text)}`),s.childCount>0){yield ',"children":[';let r=(t?Pt(t):Et)[s.type]||[],o=new Set,i=true;for(let a of r){let l=s.childForFieldName(a);l&&(i||(yield ","),i=false,o.add(l),yield*St(l,a,t));}for(let a=0;a<s.childCount;a++){let l=s.child(a);l&&!o.has(l)&&(i||(yield ","),i=false,yield*St(l,void 0,t));}yield "]";}yield "}";}async function Io(s,e,t){let n=xt(s,e,t),r=t?Pt(t):Et,o=[{treeNode:s,serializedNode:n,fieldName:e,childIndex:0,fieldChildren:new Set}];for(;o.length>0;){let i=o[o.length-1];if(i.childIndex===0&&i.treeNode.childCount>0){let a=r[i.treeNode.type]||[];for(let l of a){let g=i.treeNode.childForFieldName(l);if(g){i.fieldChildren.add(g);let d=xt(g,l,t);i.serializedNode.children||(i.serializedNode.children=[]),i.serializedNode.children.push(d),o.push({treeNode:g,serializedNode:d,fieldName:l,childIndex:0,fieldChildren:new Set});}}}if(i.childIndex<i.treeNode.childCount){let a=i.treeNode.child(i.childIndex);if(i.childIndex++,a&&!i.fieldChildren.has(a)){let l=xt(a,void 0,t);i.serializedNode.children||(i.serializedNode.children=[]),i.serializedNode.children.push(l),o.push({treeNode:a,serializedNode:l,childIndex:0,fieldChildren:new Set});}}else o.pop();}return n}function xt(s,e,t){let n={type:s.type,startPosition:{row:s.startPosition.row,column:s.startPosition.column},endPosition:{row:s.endPosition.row,column:s.endPosition.column},...e&&{fieldName:e}};return Jn(s,t)&&(n.text=s.text),n}function Jn(s,e){if(e){let n=Wn(e);if(n?.shouldIncludeText){let o=n.shouldIncludeText(s);if(o===false)return false;if(o===true)return true}return zn(e).has(s.type)||s.type.endsWith("_keyword")||s.type.endsWith("_operator")}return s.type==="string"&&s.childCount>0?false:Vn.has(s.type)||s.type.endsWith("_keyword")||s.type.endsWith("_operator")}function fe(...s){let e={};for(let t of s)for(let[n,r]of Object.entries(t)){let i=[...e[n]||[]];for(let a of r)i.includes(a)||i.push(a);e[n]=i;}return e}var Vn,Yn,qn,Et,bt=m(()=>{Kn();Vn=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","string","string_literal","template_string","number","true","false","null","undefined","import_specifier","export_specifier","predefined_type","type_predicate","type_predicate_annotation","type_alias","type_annotation","return_type","type_arguments","type_parameters","array_type","union_type","intersection_type","generic_type","tuple_type","function_type","object_type","mapped_type","conditional_type","infer_type","accessibility_modifier","readonly","static","async","await","const","let","var","decorator","=","=>","...","?","!","dotted_name","aliased_import","not_operator","boolean_operator","comparison_operator","yield","pass","continue","break","None","none","True","False","ellipsis","type","string_content"]);Yn={function_declaration:["name","parameters","body","return_type","type_parameters"],function_expression:["name","parameters","body","return_type","type_parameters"],arrow_function:["parameters","body","return_type","type_parameters"],method_definition:["name","parameters","body","return_type","type_parameters"],method_signature:["name","parameters","return_type","type_parameters"],function_signature:["name","parameters","return_type","type_parameters"],type_predicate:["name","type"],class_declaration:["name","body","type_parameters","heritage"],interface_declaration:["name","body","type_parameters"],type_alias_declaration:["name","type_parameters","value"],property_signature:["name","type"],field_definition:["name","type","value"],public_field_definition:["name","type","value"],private_field_definition:["name","type","value"],required_parameter:["pattern","type","value"],optional_parameter:["pattern","type","value"],rest_parameter:["pattern","type"],variable_declarator:["name","type","value"],lexical_declaration:["kind"],call_expression:["function","arguments","type_arguments"],new_expression:["constructor","arguments","type_arguments"],member_expression:["object","property"],assignment_expression:["left","right"],binary_expression:["left","right","operator"],unary_expression:["operator","argument"],ternary_expression:["condition","consequence","alternative"],import_statement:["source","import"],import_specifier:["name","alias"],export_specifier:["name","alias"],export_statement:["source","declaration","value"],if_statement:["condition","consequence","alternative"],for_statement:["init","condition","update","body"],for_in_statement:["left","right","body"],while_statement:["condition","body"],do_statement:["body","condition"],switch_statement:["value","body"],try_statement:["body","handler","finalizer"],catch_clause:["parameter","body"],return_statement:["value"],throw_statement:["value"],type_annotation:["type"],type_parameter:["name","constraint","default"],generic_type:["name","type_arguments"]},qn={function_definition:["name","parameters","return_type","body","type_parameters"],async_function_definition:["name","parameters","return_type","body","type_parameters"],class_definition:["name","superclasses","body","type_parameters"],decorated_definition:["definition"],lambda:["parameters","body"],import_statement:["name"],import_from_statement:["module_name","name"],aliased_import:["name","alias"],assignment:["left","right","type"],augmented_assignment:["left","right"],type_alias_statement:["name","type_parameters","value"],annotated_assignment:["left","right","type"],except_clause:["cause"],except_group_clause:["cause"],return_statement:["value"],assert_statement:["condition","message"],delete_statement:["target"],global_statement:["name"],nonlocal_statement:["name"],typed_parameter:["name","type"],default_parameter:["name","value"],typed_default_parameter:["name","type","value"],call:["function","arguments"],attribute:["object","attribute"],binary_operator:["left","right"],unary_operator:["argument"],not_operator:["argument"],boolean_operator:["left","right"],comparison_operator:["operators"],named_expression:["name","value"],conditional_expression:["condition","consequence","alternative"],keyword_argument:["name","value"],if_statement:["condition","consequence","alternative"],while_statement:["condition","body","alternative"],for_statement:["left","right","body"],try_statement:["body"],with_statement:["body"],with_item:["value"],finally_clause:["body"],else_clause:["body"],match_statement:["subject","body"],case_clause:["pattern","guard"],raise_statement:["cause"],list_comprehension:["body"],dictionary_comprehension:["body","key","value"],set_comprehension:["body"],generator_expression:["body"],for_in_clause:["left","right"],if_clause:["condition"],pair:["key","value"],subscript:["value","subscript"],slice:["start","stop","step"]};Et=fe(Yn,qn);});var he,Qn=m(()=>{pt();bn();En();$n();Nn();je();Rn();Z();k();Le();he=class extends U{scanner;parser;apiClient;compressor;buildConfigManagers=new Map;constructor(e){if(super(e),!this.config||!this.langRegistry)throw new Error("index command requires a valid configuration");this.scanner=new Me(process.cwd()),this.parser=new Oe(this.langRegistry),this.compressor=new De;for(let t of Object.keys(this.config.languages)){let n=this.langRegistry.getPlugin(t);if(n?.getBuildConfigManager){let r=n.getBuildConfigManager(process.cwd(),this.config.languages);r&&this.buildConfigManagers.set(t,r);}}}async run(e=false,t=false){try{let n=await this.getAccessKey();this.apiClient=new Re(this.config,n),await this.validateProject(),console.log(`${D}Starting indexing procedure...
59
- `);let r=performance.now();if(t?console.log(`${w} Skipping git branch validation`):await this.validateGitBranch(),t?console.log(`${w} Skipping git status validation`):await this.validateGitStatus(),t?console.log(`${w} Skipping repository synchronization`):await this.synchronizeChanges(),this.buildConfigManagers.size>0){console.log(`${y} Discovering language build configurations...`);let x=0;for(let[ke,ce]of this.buildConfigManagers.entries()){let S=await ce.initialize();x+=S.length;}x>0&&console.log(`${C} Found ${x} configuration file(s)`);}let o=await this.determineIndexScope(e),i=await this.git.getLatestCommitHash();if(o.upToDate){console.log(`
60
- ${C} Index is already up-to-date for ${this.config.projectId} on ${this.config.branch} commit ${i.substring(0,8)}`);return}if(o.isIncremental&&i){let x=await this.apiClient.getIndexStatus(this.config.branch,i);if(x?.status==="current"||x?.status==="processing"&&x?.commitHash===i){console.log(`${C} Index already up to date for branch ${this.config.branch} at commit ${i.substring(0,8)}`);return}}let a=await this.discoverFiles(o.isIncremental),l=!1,g=()=>{l||console.log(`${y} Uploading metadata, processing, and indexing...`);},d=this.generateASTs(a,g);try{await this.uploadToAPI(d,o.isIncremental,i),l=!0;}catch(x){throw l=!0,x}let f=(performance.now()-r)/1e3,b=Math.floor(f/60),_=(f%60).toFixed(3),ae=b>0?`${b}m ${_}s`:`${_}s`;console.log(`
61
- ${C} Upload completed in ${ae}! Server indexing in progress.`);}catch(n){if(n instanceof T)throw n;if(n instanceof X)throw console.error(`${P} Indexing failed: Another indexing operation is currently in progress for branch ${n.branchName||this.config?.branch||"unknown"}.`),console.log(" Your index may be out of date. Re-run this command after the current operation completes."),n;if(n instanceof E)throw console.error(`
58
+ New terminal sessions will load it automatically.`);}};});var h,F=m(()=>{h={async directoryExists(s){try{return (await N__default.stat(s)).isDirectory()}catch{return false}},async fileIsReadable(s){try{return await N__default.access(s,N__default.constants.R_OK),!0}catch{return false}},async readFile(s,e="utf-8"){let t=await N__default.readFile(s,{encoding:e,flag:N__default.constants.O_RDONLY});return t.charCodeAt(0)===65279&&(t=t.slice(1)),t},async writeFile(s,e,t="utf-8"){let n=Buffer.from(e,t);await N__default.writeFile(s,n,{encoding:t,flag:N__default.constants.O_WRONLY|N__default.constants.O_CREAT|N__default.constants.O_TRUNC});},async getFileStats(s){return await N__default.stat(s)},async getFileHandle(s,e,t){return await N__default.open(s,e,t)}};});var Oe,Pn=m(()=>{F();Oe=class{constructor(e){this.langRegistry=e;}async parseFile(e,t){let n=this.langRegistry[t]?.language;if(!n)throw new Error(`Unsupported language: ${t}`);let r=await n();if(!r)throw new Error(`Failed to load language: ${t}`);let o=new go;o.setLanguage(r);let i=await h.getFileStats(e),a=10*1024*1024;if(i.size<=a){let c=await h.readFile(e),g={bufferSize:1024*1024};return o.parse(c,void 0,g)}else return this.parseWithStream(o,e,i.size)}async parseWithStream(e,t,n){let r=null;try{r=await N.open(t,"r");let o=r.fd,i=64*1024,a=Buffer.alloc(i),c=0;return e.parse(d=>{if(n>50*1024*1024){let f=Math.round(d/n*100);f>c+10&&(console.log(` Parsing large file: ${f}%...`),c=f);}let p=Ye.readSync(o,a,0,i,d);return p===0?null:a.subarray(0,p).toString("utf-8")})}catch(o){if(r)try{await r.close();}catch(i){console.error(`Warning: Failed to close file handle for ${t}:`,i);}throw o}finally{if(r)try{await r.close();}catch{}}}};});function bn(s){return s.replace(/\\/g,"/")}function Fe(s){return bn(s).replace(/^\.?\//,"")}function G(s,e){return bn(v.relative(s,e))}var Z=m(()=>{});var Me,xn=m(()=>{F();Z();k();Me=class{rootPath;constructor(e){this.rootPath=e||process.cwd();}async scanFiles(e){let t=Sn();return await this.loadGitignoreRules(t,this.rootPath),e.exclude&&e.exclude.length>0&&t.add(e.exclude),(await this.walkDirectory(this.rootPath)).filter(o=>!t.ignores(o.relativePath)&&this.matchesLanguageExtension(o,e.languages))}async scanSpecificFiles(e,t){let n=[],r=null;t.exclude&&t.exclude.length>0&&(r=Sn().add(t.exclude));let o=await N__default.realpath(this.rootPath);for(let i of e)try{let a=v__default.isAbsolute(i)?i:v__default.join(this.rootPath,i),c=await N__default.lstat(a);if(c.isSymbolicLink()){let g=await N__default.realpath(a);if(!g.startsWith(o+v__default.sep)&&g!==o){console.warn(`${C} Skipping symlink pointing outside project: ${i} -> ${g}`);continue}let d=await N__default.stat(a);if(!d.isFile())continue;let p=G(this.rootPath,a);if(r&&r.ignores(p))continue;let f=this.detectLanguage(p,t.languages);if(!f)continue;n.push({path:a,relativePath:p,language:f,size:d.size});}else if(c.isFile()){let g=G(this.rootPath,a);if(r&&r.ignores(g))continue;let d=this.detectLanguage(g,t.languages);if(!d)continue;n.push({path:a,relativePath:g,language:d,size:c.size});}}catch{console.warn(`${C} Skipping inaccessible file: ${i}`);}return n}async loadGitignoreRules(e,t){let n=[],r=t;for(;;){let o=v__default.join(r,".gitignore");await h.fileIsReadable(o)&&n.unshift(o);let i=v__default.dirname(r);if(i===r)break;r=i;let a=v__default.join(r,".git");if(await h.directoryExists(a)){let c=v__default.join(r,".gitignore");await h.fileIsReadable(c)&&!n.includes(c)&&n.unshift(c);break}}for(let o of n)try{let i=await h.readFile(o);e.add(i);}catch{console.warn(`${C} Failed to load .gitignore: ${o}`);}e.add(".git");}async walkDirectory(e,t,n,r){let o=[],i=t||e,a=n||await N__default.realpath(this.rootPath),c=r||new Set([a]);try{let g=await N__default.readdir(e,{withFileTypes:!0});for(let d of g){let p=v__default.join(e,d.name),f=G(i,p);if(d.isDirectory()){if(d.name.startsWith("."))continue;let u=await this.walkDirectory(p,i,a,c);o.push(...u);}else if(d.isFile()){let u=await N__default.stat(p);o.push({path:p,relativePath:f,language:"",size:u.size});}else if(d.isSymbolicLink())try{let u=await N__default.realpath(p);if(!u.startsWith(a+v__default.sep)&&u!==a){console.warn(`${C} Skipping symlink pointing outside project: ${p} -> ${u}`);continue}let b=await N__default.stat(p);if(b.isDirectory()){if(d.name.startsWith(".")||c.has(u))continue;c.add(u);let _=await this.walkDirectory(p,i,a,c);o.push(..._);}else b.isFile()&&o.push({path:p,relativePath:f,language:"",size:b.size});}catch{console.warn(`${C} Skipping invalid symlink: ${p}`);}}}catch(g){console.error(`${P} Error walking directory ${e}:`,g);}return o}matchesLanguageExtension(e,t){let n=v__default.extname(e.path).toLowerCase();for(let[r,o]of Object.entries(t))if(o.fileExtensions.includes(n))return e.language=r,true;return false}detectLanguage(e,t){let n=v__default.extname(e).toLowerCase();for(let[r,o]of Object.entries(t))if(o.fileExtensions.includes(n))return r;return null}};});var uo,fo,En,In=m(()=>{uo=z$1.object({source:z$1.string().min(1,"Import source cannot be empty"),resolvedPath:z$1.string().optional(),isExternal:z$1.boolean(),importType:z$1.enum(["relative","workspace","alias","external","builtin"])}),fo=z$1.record(z$1.string(),uo),En=z$1.object({file:z$1.string().min(1,"File path cannot be empty").max(1e3,"File path too long"),language:z$1.string().regex(/^(bash|c|c-sharp|cpp|go|java|javascript|json|php|python|ruby|typescript)$/,"Invalid language identifier"),commit:z$1.string().regex(/^[a-f0-9]{40}$/,"Invalid git commit hash"),timestamp:z$1.string().datetime({message:"Invalid ISO timestamp"}),ast:z$1.string().min(1,"AST data cannot be empty").max(1e7,"AST data exceeds 10MB limit"),importResolutions:fo.optional()});});var ho,De,Tn=m(()=>{ho=promisify(ut.gunzip),De=class{*serializeASTChunks(e){if(yield "{",yield `"type":"${e.type}"`,yield `,"startPosition":${JSON.stringify(e.startPosition)}`,yield `,"endPosition":${JSON.stringify(e.endPosition)}`,e.fieldName!==void 0&&(yield `,"fieldName":"${e.fieldName}"`),e.text!==void 0&&(yield `,"text":${JSON.stringify(e.text)}`),e.children&&e.children.length>0){yield ',"children":[';for(let t=0;t<e.children.length;t++)t>0&&(yield ","),yield*this.serializeASTChunks(e.children[t]);yield "]";}yield "}";}async compressStream(e){let t=[],n=ut.createGzip();n.on("data",i=>t.push(i));let r=new Promise((i,a)=>{n.on("end",i),n.on("error",a);}),o=Readable.from(e);return await pipeline(o,n),await r,Buffer.concat(t).toString("base64")}async compress(e){let t=[],n=ut.createGzip();n.on("data",i=>t.push(i));let r=new Promise((i,a)=>{n.on("end",i),n.on("error",a);}),o=Readable.from(this.serializeASTChunks(e));return await pipeline(o,n),await r,Buffer.concat(t).toString("base64")}async decompress(e){let t=Buffer.from(e,"base64"),n=await ho(t);return JSON.parse(n.toString("utf-8"))}};});var Be,Nn=m(()=>{Be=class{constructor(e=10){this.concurrency=e;if(e<1)throw new Error("Concurrency must be at least 1")}async*run(e,t){if(e.length===0)return;let n=new Map,r=0,o=0;for(;o<e.length&&n.size<this.concurrency;){let i=r++,a=this.processItem(e[o],o,t).then(c=>({result:c!==null?c.result:null,promiseId:i}));n.set(i,a),o++;}for(;n.size>0;){let i=await Promise.race(n.values());if(n.delete(i.promiseId),i.result!==null&&(yield i.result),o<e.length){let a=r++,c=this.processItem(e[o],o,t).then(g=>({result:g!==null?g.result:null,promiseId:a}));n.set(a,c),o++;}}}async processItem(e,t,n){try{return {result:await n(e,t),index:t}}catch{return null}}};});async function W(s,e,t,n,r){let o=await t.resolve(s),i=Rn(s,o),a=r(s,o,i),c=i?void 0:Fe(o);n[e.toString()]={source:s,resolvedPath:c,isExternal:i,importType:a};}function Rn(s,e){return s===e?true:!(!e.startsWith(".")&&!e.startsWith("/")||e.startsWith("./")||e.startsWith("../"))}var ft,de=m(()=>{Z();ft=(s,e,t)=>t?s.startsWith("node:")?"builtin":"external":s.startsWith("./")||s.startsWith("../")?"relative":s.startsWith("@")?"workspace":"alias";});async function yo(s,e,t,n){let r=s.childForFieldName("source");if(!r)return;let o=r.startPosition.row,i=r.text.replace(/['"]/g,"");await W(i,o,e,t,n);}async function Co(s,e,t,n){let r=s.childForFieldName("source");if(!r)return;let o=r.startPosition.row,i=r.text.replace(/['"]/g,"");await W(i,o,e,t,n);}function He(){return {language:"javascript",handlers:new Map([["import_statement",yo],["export_statement",Co]])}}function mt(){return {...He(),language:"typescript"}}var ht=m(()=>{de();});async function vo(s,e,t,n){let r=s.childForFieldName("name");if(!r)return;let o;if(r.type==="aliased_import"){let i=r.childForFieldName("name");o=i?i.text:r.text;}else o=r.text;await W(o,s.startPosition.row,e,t,n);}async function Po(s,e,t,n){let r,o=s.childForFieldName("module_name");if(o)r=o.text;else {let i="";for(let a=0;a<s.childCount;a++){let c=s.child(a);if(c){if(c.type==="relative_import"){i=c.text;break}(c.type==="."||c.type==="import_prefix")&&(i+=c.text);}}r=i||".";}await W(r,s.startPosition.row,e,t,n);}async function bo(s,e,t,n){await W("__future__",s.startPosition.row,e,t,n);}function yt(){return {language:"python",handlers:new Map([["import_statement",vo],["import_from_statement",Po],["future_import_statement",bo]]),classifyImportType:_o}}var _o,Ue=m(()=>{de();_o=(s,e,t)=>{if(t)return "external";if(/^\.+/.test(s))return "relative";let n=s.split(".")[0];return PYTHON_STDLIB_MODULES.has(n)?"builtin":"alias"};});var jn,Ln=m(()=>{ht();Ue();de();ht();Ue();jn=[He(),mt(),yt()];});var On={};on(On,{ImportExtractor:()=>Ct});var Ct,Fn=m(()=>{Ln();de();Ct=class{languageHandlers;classifiers;constructor(e){this.languageHandlers=new Map,this.classifiers=new Map;for(let t of e??jn)this.languageHandlers.set(t.language,t.handlers),t.classifyImportType&&this.classifiers.set(t.language,t.classifyImportType);}async extractImportResolutions(e,t,n,r){if(!r)return {};let o=this.languageHandlers.get(n);if(!o)return {};let i=this.classifiers.get(n)??ft,a={};return await this.walkAST(e.rootNode,async c=>{let g=o.get(c.type);g&&await g(c,r,a,i);}),a}async walkAST(e,t){await t(e);for(let n=0;n<e.childCount;n++){let r=e.child(n);r&&await this.walkAST(r,t);}}};});var ue,Mn,wt,Dn,Bn,Ge=m(()=>{ue=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","string","string_literal","template_string","number","import_specifier","export_specifier","accessibility_modifier","readonly","static","async","await","const","let","var","decorator","=","=>","...","?","!","string_content"]),Mn=new Set(["true","false","null","undefined","predefined_type","type_predicate","type_predicate_annotation","type_alias","type_annotation","return_type","type_arguments","type_parameters","array_type","union_type","intersection_type","generic_type","tuple_type","function_type","object_type","mapped_type","conditional_type","infer_type"]),wt={function_declaration:["name","parameters","body","return_type","type_parameters"],function_expression:["name","parameters","body","return_type","type_parameters"],arrow_function:["parameters","body","return_type","type_parameters"],method_definition:["name","parameters","body","return_type","type_parameters"],method_signature:["name","parameters","return_type","type_parameters"],function_signature:["name","parameters","return_type","type_parameters"],type_predicate:["name","type"],class_declaration:["name","body","type_parameters","heritage"],interface_declaration:["name","body","type_parameters"],type_alias_declaration:["name","type_parameters","value"],property_signature:["name","type"],field_definition:["name","type","value"],public_field_definition:["name","type","value"],private_field_definition:["name","type","value"],required_parameter:["pattern","type","value"],optional_parameter:["pattern","type","value"],rest_parameter:["pattern","type"],variable_declarator:["name","type","value"],lexical_declaration:["kind"],call_expression:["function","arguments","type_arguments"],new_expression:["constructor","arguments","type_arguments"],member_expression:["object","property"],assignment_expression:["left","right"],binary_expression:["left","right","operator"],unary_expression:["operator","argument"],ternary_expression:["condition","consequence","alternative"],import_statement:["source","import"],import_specifier:["name","alias"],export_specifier:["name","alias"],export_statement:["source","declaration","value"],if_statement:["condition","consequence","alternative"],for_statement:["init","condition","update","body"],for_in_statement:["left","right","body"],while_statement:["condition","body"],do_statement:["body","condition"],switch_statement:["value","body"],try_statement:["body","handler","finalizer"],catch_clause:["parameter","body"],return_statement:["value"],throw_statement:["value"],type_annotation:["type"],type_parameter:["name","constraint","default"],generic_type:["name","type_arguments"]},Dn={language:"javascript",textIncludedTypes:Mn,fieldNames:wt},Bn={language:"typescript",textIncludedTypes:Mn,fieldNames:wt};});var So,Hn,Un,_t=m(()=>{So=new Set(["true","false","none","None","True","False","yield","pass","continue","break","ellipsis","dotted_name","aliased_import","not_operator","boolean_operator","comparison_operator","type","subscript","attribute","list","tuple","binary_operator","union_type","generic_type"]),Hn={function_definition:["name","parameters","return_type","body","type_parameters"],async_function_definition:["name","parameters","return_type","body","type_parameters"],class_definition:["name","superclasses","body","type_parameters"],decorated_definition:["definition"],lambda:["parameters","body"],import_statement:["name"],import_from_statement:["module_name","name"],aliased_import:["name","alias"],assignment:["left","right","type"],augmented_assignment:["left","right"],type_alias_statement:["name","type_parameters","value"],annotated_assignment:["left","right","type"],except_clause:["cause"],except_group_clause:["cause"],return_statement:["value"],assert_statement:["condition","message"],delete_statement:["target"],global_statement:["name"],nonlocal_statement:["name"],typed_parameter:["name","type"],default_parameter:["name","value"],typed_default_parameter:["name","type","value"],list_splat_pattern:[],dictionary_splat_pattern:[],call:["function","arguments"],attribute:["object","attribute"],binary_operator:["left","right"],unary_operator:["argument"],not_operator:["argument"],boolean_operator:["left","right"],comparison_operator:["operators"],named_expression:["name","value"],conditional_expression:["condition","consequence","alternative"],keyword_argument:["name","value"],if_statement:["condition","consequence","alternative"],while_statement:["condition","body","alternative"],for_statement:["left","right","body"],try_statement:["body"],with_statement:["body"],with_item:["value"],finally_clause:["body"],else_clause:["body"],match_statement:["subject","body"],case_clause:["pattern","guard"],raise_statement:["cause"],list_comprehension:["body"],dictionary_comprehension:["body","key","value"],set_comprehension:["body"],generator_expression:["body"],for_in_clause:["left","right"],if_clause:["condition"],pair:["key","value"],subscript:["value","subscript"],slice:["start","stop","step"]},Un={language:"python",textIncludedTypes:So,fieldNames:Hn,shouldIncludeText:s=>{if(s.type==="string"&&s.childCount>0)return false}};});function Gn(s){return fe.get(s)}function Wn(s){if(!s)return ue;let e=fe.get(s);if(!e)return ue;let t=new Set(ue);for(let n of e.textIncludedTypes)t.add(n);return t}function vt(s){if(!s){let t=Array.from(fe.values()).map(n=>n.fieldNames);return me(...t)}let e=fe.get(s);if(!e){let t=Array.from(fe.values()).map(n=>n.fieldNames);return me(...t)}return e.fieldNames}var fe,zn=m(()=>{Pt();Ge();_t();Ge();Ge();_t();fe=new Map([["javascript",Dn],["typescript",Bn],["python",Un]]);});var qn={};on(qn,{COMMON_FIELD_NAMES:()=>xt,JS_TS_FIELD_NAMES:()=>Jn,PYTHON_FIELD_NAMES:()=>Yn,TEXT_INCLUDED_TYPES:()=>Kn,mergeFieldMaps:()=>me,serializeAST:()=>Eo,serializeASTStream:()=>xo});function*xo(s,e,t){yield*St(s,e,t);}function*St(s,e,t){if(yield "{",yield `"type":${JSON.stringify(s.type)}`,yield `,"startPosition":${JSON.stringify({row:s.startPosition.row,column:s.startPosition.column})}`,yield `,"endPosition":${JSON.stringify({row:s.endPosition.row,column:s.endPosition.column})}`,e&&(yield `,"fieldName":${JSON.stringify(e)}`),Vn(s,t)&&(yield `,"text":${JSON.stringify(s.text)}`),s.childCount>0){yield ',"children":[';let r=(t?vt(t):xt)[s.type]||[],o=new Set,i=true;for(let a of r){let c=s.childForFieldName(a);c&&(i||(yield ","),i=false,o.add(c),yield*St(c,a,t));}for(let a=0;a<s.childCount;a++){let c=s.child(a);c&&!o.has(c)&&(i||(yield ","),i=false,yield*St(c,void 0,t));}yield "]";}yield "}";}async function Eo(s,e,t){let n=bt(s,e,t),r=t?vt(t):xt,o=[{treeNode:s,serializedNode:n,fieldName:e,childIndex:0,fieldChildren:new Set}];for(;o.length>0;){let i=o[o.length-1];if(i.childIndex===0&&i.treeNode.childCount>0){let a=r[i.treeNode.type]||[];for(let c of a){let g=i.treeNode.childForFieldName(c);if(g){i.fieldChildren.add(g);let d=bt(g,c,t);i.serializedNode.children||(i.serializedNode.children=[]),i.serializedNode.children.push(d),o.push({treeNode:g,serializedNode:d,fieldName:c,childIndex:0,fieldChildren:new Set});}}}if(i.childIndex<i.treeNode.childCount){let a=i.treeNode.child(i.childIndex);if(i.childIndex++,a&&!i.fieldChildren.has(a)){let c=bt(a,void 0,t);i.serializedNode.children||(i.serializedNode.children=[]),i.serializedNode.children.push(c),o.push({treeNode:a,serializedNode:c,childIndex:0,fieldChildren:new Set});}}else o.pop();}return n}function bt(s,e,t){let n={type:s.type,startPosition:{row:s.startPosition.row,column:s.startPosition.column},endPosition:{row:s.endPosition.row,column:s.endPosition.column},...e&&{fieldName:e}};return Vn(s,t)&&(n.text=s.text),n}function Vn(s,e){if(e){let n=Gn(e);if(n?.shouldIncludeText){let o=n.shouldIncludeText(s);if(o===false)return false;if(o===true)return true}return Wn(e).has(s.type)||s.type.endsWith("_keyword")||s.type.endsWith("_operator")}return s.type==="string"&&s.childCount>0?false:Kn.has(s.type)||s.type.endsWith("_keyword")||s.type.endsWith("_operator")}function me(...s){let e={};for(let t of s)for(let[n,r]of Object.entries(t)){let i=[...e[n]||[]];for(let a of r)i.includes(a)||i.push(a);e[n]=i;}return e}var Kn,Jn,Yn,xt,Pt=m(()=>{zn();Kn=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","string","string_literal","template_string","number","true","false","null","undefined","import_specifier","export_specifier","predefined_type","type_predicate","type_predicate_annotation","type_alias","type_annotation","return_type","type_arguments","type_parameters","array_type","union_type","intersection_type","generic_type","tuple_type","function_type","object_type","mapped_type","conditional_type","infer_type","accessibility_modifier","readonly","static","async","await","const","let","var","decorator","=","=>","...","?","!","dotted_name","aliased_import","not_operator","boolean_operator","comparison_operator","yield","pass","continue","break","None","none","True","False","ellipsis","type","string_content"]);Jn={function_declaration:["name","parameters","body","return_type","type_parameters"],function_expression:["name","parameters","body","return_type","type_parameters"],arrow_function:["parameters","body","return_type","type_parameters"],method_definition:["name","parameters","body","return_type","type_parameters"],method_signature:["name","parameters","return_type","type_parameters"],function_signature:["name","parameters","return_type","type_parameters"],type_predicate:["name","type"],class_declaration:["name","body","type_parameters","heritage"],interface_declaration:["name","body","type_parameters"],type_alias_declaration:["name","type_parameters","value"],property_signature:["name","type"],field_definition:["name","type","value"],public_field_definition:["name","type","value"],private_field_definition:["name","type","value"],required_parameter:["pattern","type","value"],optional_parameter:["pattern","type","value"],rest_parameter:["pattern","type"],variable_declarator:["name","type","value"],lexical_declaration:["kind"],call_expression:["function","arguments","type_arguments"],new_expression:["constructor","arguments","type_arguments"],member_expression:["object","property"],assignment_expression:["left","right"],binary_expression:["left","right","operator"],unary_expression:["operator","argument"],ternary_expression:["condition","consequence","alternative"],import_statement:["source","import"],import_specifier:["name","alias"],export_specifier:["name","alias"],export_statement:["source","declaration","value"],if_statement:["condition","consequence","alternative"],for_statement:["init","condition","update","body"],for_in_statement:["left","right","body"],while_statement:["condition","body"],do_statement:["body","condition"],switch_statement:["value","body"],try_statement:["body","handler","finalizer"],catch_clause:["parameter","body"],return_statement:["value"],throw_statement:["value"],type_annotation:["type"],type_parameter:["name","constraint","default"],generic_type:["name","type_arguments"]},Yn={function_definition:["name","parameters","return_type","body","type_parameters"],async_function_definition:["name","parameters","return_type","body","type_parameters"],class_definition:["name","superclasses","body","type_parameters"],decorated_definition:["definition"],lambda:["parameters","body"],import_statement:["name"],import_from_statement:["module_name","name"],aliased_import:["name","alias"],assignment:["left","right","type"],augmented_assignment:["left","right"],type_alias_statement:["name","type_parameters","value"],annotated_assignment:["left","right","type"],except_clause:["cause"],except_group_clause:["cause"],return_statement:["value"],assert_statement:["condition","message"],delete_statement:["target"],global_statement:["name"],nonlocal_statement:["name"],typed_parameter:["name","type"],default_parameter:["name","value"],typed_default_parameter:["name","type","value"],call:["function","arguments"],attribute:["object","attribute"],binary_operator:["left","right"],unary_operator:["argument"],not_operator:["argument"],boolean_operator:["left","right"],comparison_operator:["operators"],named_expression:["name","value"],conditional_expression:["condition","consequence","alternative"],keyword_argument:["name","value"],if_statement:["condition","consequence","alternative"],while_statement:["condition","body","alternative"],for_statement:["left","right","body"],try_statement:["body"],with_statement:["body"],with_item:["value"],finally_clause:["body"],else_clause:["body"],match_statement:["subject","body"],case_clause:["pattern","guard"],raise_statement:["cause"],list_comprehension:["body"],dictionary_comprehension:["body","key","value"],set_comprehension:["body"],generator_expression:["body"],for_in_clause:["left","right"],if_clause:["condition"],pair:["key","value"],subscript:["value","subscript"],slice:["start","stop","step"]};xt=me(Jn,Yn);});var he,Zn=m(()=>{ct();Pn();xn();In();Tn();je();Nn();Z();k();Le();he=class extends U{scanner;parser;apiClient;compressor;buildConfigManagers=new Map;constructor(e){if(super(e),!this.config||!this.langRegistry)throw new Error("index command requires a valid configuration");this.scanner=new Me(process.cwd()),this.parser=new Oe(this.langRegistry),this.compressor=new De;for(let t of Object.keys(this.config.languages)){let n=this.langRegistry.getPlugin(t);if(n?.getBuildConfigManager){let r=n.getBuildConfigManager(process.cwd(),this.config.languages);r&&this.buildConfigManagers.set(t,r);}}}async run(e=false,t=false){try{let n=await this.getAccessKey();this.apiClient=new Re(this.config,n),await this.validateProject(),console.log(`${D}Starting indexing procedure...
59
+ `);let r=performance.now();if(t?console.log(`${C} Skipping git branch validation`):await this.validateGitBranch(),t?console.log(`${C} Skipping git status validation`):await this.validateGitStatus(),t?console.log(`${C} Skipping repository synchronization`):await this.synchronizeChanges(),this.buildConfigManagers.size>0){console.log(`${y} Discovering language build configurations...`);let S=0;for(let[ke,le]of this.buildConfigManagers.entries()){let x=await le.initialize();S+=x.length;}S>0&&console.log(`${w} Found ${S} configuration file(s)`);}let o=await this.determineIndexScope(e),i=await this.git.getLatestCommitHash();if(o.upToDate){console.log(`
60
+ ${w} Index is already up-to-date for ${this.config.projectId} on ${this.config.branch} commit ${i.substring(0,8)}`);return}if(o.isIncremental&&i){let S=await this.apiClient.getIndexStatus(this.config.branch,i);if(S?.status==="current"||S?.status==="processing"&&S?.commitHash===i){console.log(`${w} Index already up to date for branch ${this.config.branch} at commit ${i.substring(0,8)}`);return}}let a=await this.discoverFiles(o.isIncremental),c=!1,g=()=>{c||console.log(`${y} Uploading metadata, processing, and indexing...`);},d=this.generateASTs(a,g);try{await this.uploadToAPI(d,o.isIncremental,i),c=!0;}catch(S){throw c=!0,S}let u=(performance.now()-r)/1e3,b=Math.floor(u/60),_=(u%60).toFixed(3),ae=b>0?`${b}m ${_}s`:`${_}s`;console.log(`
61
+ ${w} Upload completed in ${ae}! Server indexing in progress.`);}catch(n){if(n instanceof T)throw n;if(n instanceof X)throw console.error(`${P} Indexing failed: Another indexing operation is currently in progress for branch ${n.branchName||this.config?.branch||"unknown"}.`),console.log(" Your index may be out of date. Re-run this command after the current operation completes."),n;if(n instanceof E)throw console.error(`
62
62
  ${P} Authentication failed.`),console.log(`${y} Your access key may be invalid or expired. Run 'constellation auth'
63
63
  to set or update your access key.`),n;if(n instanceof Error&&n.message==="Access key not configured")throw n;let r=n instanceof Error?n.message:"An unexpected error occurred";throw console.error(`${P} Indexing failed: ${r}`),n}}async getAccessKey(){let e=await this.env.getKey(H);if(!e)throw console.error(`
64
64
  ${P} Access key not found.`),console.log(`${y} Set the ${H} environment variable or run
65
- 'constellation auth' to configure your access key.`),new Error("Access key not configured");return e}async validateProject(){console.log(`${y} Validating project access...`);try{await this.apiClient.getProjectState(),console.log(`${C} Project validated successfully`);}catch(e){if(e instanceof T)throw this.displayProjectValidationError(e),e;if(e instanceof B){console.log(`${C} Project validated (first index)`);return}if(e instanceof E)throw e;let t=e instanceof Error?e.message:String(e);throw t==="fetch failed"||t.includes("ECONNREFUSED")||t.includes("ENOTFOUND")||t.includes("ETIMEDOUT")||t.includes("EHOSTUNREACH")||t.includes("ECONNRESET")?new Error(`Unable to connect to the Constellation service.
65
+ 'constellation auth' to configure your access key.`),new Error("Access key not configured");return e}async validateProject(){console.log(`${y} Validating project access...`);try{await this.apiClient.getProjectState(),console.log(`${w} Project validated successfully`);}catch(e){if(e instanceof T)throw this.displayProjectValidationError(e),e;if(e instanceof B){console.log(`${w} Project validated (first index)`);return}if(e instanceof E)throw e;let t=e instanceof Error?e.message:String(e);throw t==="fetch failed"||t.includes("ECONNREFUSED")||t.includes("ENOTFOUND")||t.includes("ETIMEDOUT")||t.includes("EHOSTUNREACH")||t.includes("ECONNRESET")?new Error(`Unable to connect to the Constellation service.
66
66
  Verify your network connection and that the API URL is correct.`):e}}displayProjectValidationError(e){let t=e.projectId||this.config.projectId,n=t.length>40?t.substring(0,37)+"...":t;switch(e.code){case "PROJECT_NOT_REGISTERED":console.error(`
67
67
  ${P} Project not registered
68
68
  `),console.error(` The project ID "${n}" in constellation.json`),console.error(` is not associated with your Constellation account.
@@ -77,8 +77,8 @@ ${P} Invalid project ID
77
77
  `),console.error(" To resolve this:"),console.error(" 1. Get your project ID from https://app.constellationdev.io"),console.error(" 2. Update the projectId field in constellation.json"),console.error(` 3. Run 'constellation index' again
78
78
  `);break;default:console.error(`
79
79
  ${P} Project validation failed: ${e.message}
80
- `);}}async validateGitBranch(){console.log(`${y} Validating Git repository and branch...`);let t=(await this.git.status()).currentBranch;this.config.validateBranch(t),console.log(`${C} Current branch "${t}" is configured for indexing`);}async validateGitStatus(){if(console.log(`${y} Validating Git status...`),!(await this.git.status()).clean)throw new Error(`Outstanding changes detected.
81
- Commit or stash changes first to ensure consistent indexing.`);console.log(`${C} Working tree clean`);}async synchronizeChanges(){console.log(`${y} Synchronizing latest changes...`);try{await this.git.pull()&&console.log(`${C} Repository synchronized successfully`);}catch(e){throw console.error(`${P} Failed to synchronize repository`),e instanceof Error&&(e.message.includes("uncommitted changes")?(console.error(`
80
+ `);}}async validateGitBranch(){console.log(`${y} Validating Git repository and branch...`);let t=(await this.git.status()).currentBranch;this.config.validateBranch(t),console.log(`${w} Current branch "${t}" is configured for indexing`);}async validateGitStatus(){if(console.log(`${y} Validating Git status...`),!(await this.git.status()).clean)throw new Error(`Outstanding changes detected.
81
+ Commit or stash changes first to ensure consistent indexing.`);console.log(`${w} Working tree clean`);}async synchronizeChanges(){console.log(`${y} Synchronizing latest changes...`);try{await this.git.pull()&&console.log(`${w} Repository synchronized successfully`);}catch(e){throw console.error(`${P} Failed to synchronize repository`),e instanceof Error&&(e.message.includes("uncommitted changes")?(console.error(`
82
82
  To resolve:`),console.error(' 1. Commit your changes: git add . && git commit -m "your message"'),console.error(" 2. Or stash them: git stash"),console.error(` 3. Then run the index command again
83
83
  `)):e.message.includes("merge conflicts")?(console.error(`
84
84
  To resolve:`),console.error(" 1. Fix the conflicted files manually"),console.error(" 2. Stage the resolved files: git add <resolved-files>"),console.error(" 3. Complete the merge: git commit"),console.error(` 4. Then run the index command again
@@ -86,7 +86,7 @@ To resolve:`),console.error(" 1. Fix the conflicted files manually"),console.er
86
86
  Please check your internet connection and try again
87
87
  `):e.message.includes("Authentication")&&console.error(`
88
88
  Please check your git credentials and try again
89
- `)),e}}async determineIndexScope(e){if(e)return {isIncremental:false,upToDate:false};console.log(`${y} Determining index scope...`);try{let n=(await this.apiClient.getProjectState())?.latestCommit;if(!n)return console.log(`${y} No previous index found - performing full index`),{isIncremental:!1,upToDate:!1};let r=await this.git.getLatestCommitHash();return n===r?(console.log(`${C} Already up to date`),{isIncremental:!0,upToDate:!0}):(console.log(`${y} Last indexed commit: ${n.substring(0,8)}`),console.log(`${y} Current commit: ${r.substring(0,8)}`),console.log(`${y} Performing incremental index starting from commit ${n.substring(0,8)}`),{isIncremental:!0,upToDate:!1})}catch(t){if(t instanceof E)throw t;return console.log(`${w} Could not determine last index - performing full index`),{isIncremental:false,upToDate:false}}}async discoverFiles(e){console.log(`${y} Analyzing codebase...`);let t;if(e)try{let n=await this.apiClient.getProjectState();if(!n?.latestCommit)console.log(`${w} Cannot determine changes - falling back to full scan`),t=await this.scanner.scanFiles(this.config);else {let r=await this.git.getChangedFiles(n.latestCommit),o=[...r.added,...r.modified,...r.renamed.map(a=>a.to)];console.log(`${y} Found ${o.length} changed files`),t=await this.scanner.scanSpecificFiles(o,this.config);let i=[...r.deleted,...r.renamed.map(a=>a.from)];if(i.length>0){let a=r.deleted.length,l=r.renamed.length,g=l>0?`${y} Removing ${a} deleted file(s) and ${l} renamed file(s) from graph`:`${y} Removing ${a} deleted file(s) from graph`;console.log(g),await this.apiClient.deleteFiles(i);}}}catch(n){if(n instanceof E)throw n;console.log(`${w} Cannot determine changes - falling back to full scan`),t=await this.scanner.scanFiles(this.config);}else console.log(`${y} Scanning all project files...`),t=await this.scanner.scanFiles(this.config);return console.log(`${C} Found ${t.length} files to index`),t}async*generateASTs(e,t){let n=new Date().toISOString(),r=e.length,o=0,i=0;console.log(`${y} Processing ${r} files...`);let a=await this.git.getLatestCommitHash(),l=r>1e4?5:r>5e3?7:10;l<10&&console.log(`${y} Large project detected - using concurrency of ${l} to optimize memory usage`);let d=new Be(l).run(e,async(p,u)=>{let f=Math.round((u+1)/r*100);console.log(`${y} Analyzing file ${p.path.replace(process.cwd()+"/","")} (${f}%)...`);try{let b=await this.parser.parseFile(p.path,p.language),_=this.langRegistry.getPlugin(p.language),ae;if(_?.getImportResolver){let at=this.buildConfigManagers.get(p.language),ct=at?await at.getConfigForFile(p.path):null,on=_.getImportResolver(p.path,ct);if(on){let{ImportExtractor:Mr}=await Promise.resolve().then(()=>(Mn(),Fn));ae=await new Mr().extractImportResolutions(b,p.path,p.language,on);}}let{serializeASTStream:x}=await Promise.resolve().then(()=>(bt(),Xn)),ke=x(b.rootNode,void 0,p.language),ce=await this.compressor.compressStream(ke),S={file:this.normalizePathToCanonical(p.relativePath),language:p.language,commit:a,timestamp:n,ast:ce,importResolutions:ae},O=In.safeParse(S);if(!O.success)throw new Error(`AST validation failed: ${O.error.issues[0].message}`);return o++,O.data}catch(b){throw i++,console.error(` ${w} Failed to parse ${p.relativePath}: ${b.message}`,b),b}});for await(let p of d)yield p;i>0?console.log(`${w} Completed parsing with ${i} parsing errors`):console.log(`${C} All files analyzed successfully`),t&&t();}async uploadToAPI(e,t,n){if(!await this.apiClient.streamToApi(e,"ast",this.config.projectId,this.config.branch,t,n))throw new Error("Failed to upload data to Constellation Service");console.log(`${C} Data uploaded to Constellation Service, indexing in progress`);}normalizePathToCanonical(e){return Fe(e)}};});function It(){return er}var er,tr=m(()=>{er=[{event:"SessionStart",type:"prompt",content:`You have Constellation access. \`{MCP_TOOL_NAME}\` is your PRIMARY tool for understanding this codebase\u2014not an alternative, not a fallback, THE DEFAULT.
89
+ `)),e}}async determineIndexScope(e){if(e)return {isIncremental:false,upToDate:false};console.log(`${y} Determining index scope...`);try{let n=(await this.apiClient.getProjectState())?.latestCommit;if(!n)return console.log(`${y} No previous index found - performing full index`),{isIncremental:!1,upToDate:!1};let r=await this.git.getLatestCommitHash();return n===r?(console.log(`${w} Already up to date`),{isIncremental:!0,upToDate:!0}):(console.log(`${y} Last indexed commit: ${n.substring(0,8)}`),console.log(`${y} Current commit: ${r.substring(0,8)}`),console.log(`${y} Performing incremental index starting from commit ${n.substring(0,8)}`),{isIncremental:!0,upToDate:!1})}catch(t){if(t instanceof E)throw t;return console.log(`${C} Could not determine last index - performing full index`),{isIncremental:false,upToDate:false}}}async discoverFiles(e){console.log(`${y} Analyzing codebase...`);let t;if(e)try{let n=await this.apiClient.getProjectState();if(!n?.latestCommit)console.log(`${C} Cannot determine changes - falling back to full scan`),t=await this.scanner.scanFiles(this.config);else {let r=await this.git.getChangedFiles(n.latestCommit),o=[...r.added,...r.modified,...r.renamed.map(a=>a.to)];console.log(`${y} Found ${o.length} changed files`),t=await this.scanner.scanSpecificFiles(o,this.config);let i=[...r.deleted,...r.renamed.map(a=>a.from)];if(i.length>0){let a=r.deleted.length,c=r.renamed.length,g=c>0?`${y} Removing ${a} deleted file(s) and ${c} renamed file(s) from graph`:`${y} Removing ${a} deleted file(s) from graph`;console.log(g),await this.apiClient.deleteFiles(i);}}}catch(n){if(n instanceof E)throw n;console.log(`${C} Cannot determine changes - falling back to full scan`),t=await this.scanner.scanFiles(this.config);}else console.log(`${y} Scanning all project files...`),t=await this.scanner.scanFiles(this.config);return console.log(`${w} Found ${t.length} files to index`),t}async*generateASTs(e,t){let n=new Date().toISOString(),r=e.length,o=0,i=0;console.log(`${y} Processing ${r} files...`);let a=await this.git.getLatestCommitHash(),c=r>1e4?5:r>5e3?7:10;c<10&&console.log(`${y} Large project detected - using concurrency of ${c} to optimize memory usage`);let d=new Be(c).run(e,async(p,f)=>{let u=Math.round((f+1)/r*100);console.log(`${y} Analyzing file ${p.path.replace(process.cwd()+"/","")} (${u}%)...`);try{let b=await this.parser.parseFile(p.path,p.language),_=this.langRegistry.getPlugin(p.language),ae;if(_?.getImportResolver){let st=this.buildConfigManagers.get(p.language),at=st?await st.getConfigForFile(p.path):null,rn=_.getImportResolver(p.path,at);if(rn){let{ImportExtractor:Fr}=await Promise.resolve().then(()=>(Fn(),On));ae=await new Fr().extractImportResolutions(b,p.path,p.language,rn);}}let{serializeASTStream:S}=await Promise.resolve().then(()=>(Pt(),qn)),ke=S(b.rootNode,void 0,p.language),le=await this.compressor.compressStream(ke),x={file:this.normalizePathToCanonical(p.relativePath),language:p.language,commit:a,timestamp:n,ast:le,importResolutions:ae},O=En.safeParse(x);if(!O.success)throw new Error(`AST validation failed: ${O.error.issues[0].message}`);return o++,O.data}catch(b){throw i++,console.error(` ${C} Failed to parse ${p.relativePath}: ${b.message}`,b),b}});for await(let p of d)yield p;i>0?console.log(`${C} Completed parsing with ${i} parsing errors`):console.log(`${w} All files analyzed successfully`),t&&t();}async uploadToAPI(e,t,n){if(!await this.apiClient.streamToApi(e,"ast",this.config.projectId,this.config.branch,t,n))throw new Error("Failed to upload data to Constellation Service");console.log(`${w} Data uploaded to Constellation Service, indexing in progress`);}normalizePathToCanonical(e){return Fe(e)}};});function Et(){return Qn}var Qn,er=m(()=>{Qn=[{event:"SessionStart",type:"prompt",content:`You have Constellation access. \`{MCP_TOOL_NAME}\` is your PRIMARY tool for understanding this codebase\u2014not an alternative, not a fallback, THE DEFAULT.
90
90
 
91
91
  Mental model:
92
92
  - "Where is X defined?" \u2192 {MCP_TOOL_NAME}
@@ -94,7 +94,7 @@ Mental model:
94
94
  - "What would break?" \u2192 {MCP_TOOL_NAME}
95
95
  - "Find the string 'ERROR_CODE_123'" \u2192 Grep
96
96
 
97
- Grep is for literal text. Everything else starts with {MCP_TOOL_NAME}.`,matcher:".*"},{event:"SubagentStart",type:"prompt",content:"You have access to Constellation's {MCP_TOOL_NAME} MCP tool. For structural code questions\u2014symbol definitions, callers/callees, dependencies, dependents, impact analysis, architecture overview\u2014use {MCP_TOOL_NAME} instead of Grep/Glob. It answers in one call what would take 3-5 text searches. Use Grep/Glob only for literal string search, config values, or when the tool is unavailable.",matcher:"Explore|Plan|explore|shell"},{event:"PreCompact",type:"prompt",content:"Preserve: (1) The instruction that {MCP_TOOL_NAME} is the PRIMARY tool for code understanding\u2014Grep is only for literal text, (2) Any architectural insights, dependency relationships, or impact analysis results discovered via Constellation.",matcher:".*"}];});function ko(s){return nr[s]}var nr,$o,ye,$t=m(()=>{nr={SessionStart:"TaskStart",SubagentStart:void 0,PreCompact:void 0,PreToolUse:"PreToolUse",PostToolUse:"PostToolUse",SessionEnd:"TaskComplete"},$o="code_intel";ye=class{id="cline";displayName="Cline";mapEventName(e){return nr[e]}generateConfig(e){return {}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,$o)}generateAuxiliaryFiles(e){let t=new Map;for(let n of e){let r=ko(n.event);if(!r)continue;let o=`.clinerules/hooks/${r}`,i=this.generateScript(n);t.set(o,i);}return t.size>0?t:void 0}generateScript(e){let n=this.customizePrompt(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n");return `#!/bin/bash
97
+ Grep is for literal text. Everything else starts with {MCP_TOOL_NAME}.`,matcher:".*"},{event:"SubagentStart",type:"prompt",content:"You have access to Constellation's {MCP_TOOL_NAME} MCP tool. For structural code questions\u2014symbol definitions, callers/callees, dependencies, dependents, impact analysis, architecture overview\u2014use {MCP_TOOL_NAME} instead of Grep/Glob. It answers in one call what would take 3-5 text searches. Use Grep/Glob only for literal string search, config values, or when the tool is unavailable.",matcher:"Explore|Plan|explore|shell"},{event:"PreCompact",type:"prompt",content:"Preserve: (1) The instruction that {MCP_TOOL_NAME} is the PRIMARY tool for code understanding\u2014Grep is only for literal text, (2) Any architectural insights, dependency relationships, or impact analysis results discovered via Constellation.",matcher:".*"}];});function $o(s){return tr[s]}var tr,Io,ye,It=m(()=>{tr={SessionStart:"TaskStart",SubagentStart:void 0,PreCompact:void 0,PreToolUse:"PreToolUse",PostToolUse:"PostToolUse",SessionEnd:"TaskComplete"},Io="code_intel";ye=class{id="cline";displayName="Cline";mapEventName(e){return tr[e]}generateConfig(e){return {}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,Io)}generateAuxiliaryFiles(e){let t=new Map;for(let n of e){let r=$o(n.event);if(!r)continue;let o=`.clinerules/hooks/${r}`,i=this.generateScript(n);t.set(o,i);}return t.size>0?t:void 0}generateScript(e){let n=this.customizePrompt(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n");return `#!/bin/bash
98
98
  # Constellation ${e.event} Hook for Cline
99
99
  # Generated by constellation-cli - DO NOT EDIT
100
100
  #
@@ -107,7 +107,7 @@ cat << 'CONSTELLATION_EOF'
107
107
  "contextModification": "${n}"
108
108
  }
109
109
  CONSTELLATION_EOF
110
- `}};});var To,No,Q,kt=m(()=>{To={SessionStart:"sessionStart",SubagentStart:"subagentStart",PreCompact:"preCompact",PreToolUse:"preToolUse",PostToolUse:"postToolUse",SessionEnd:"sessionEnd"},No="constellation__code_intel",Q=class{id="cursor";displayName="Cursor";mapEventName(e){return To[e]}generateConfig(e){let t={};for(let n of e){let r=this.mapEventName(n.event);if(!r)continue;t[r]||(t[r]=[]);let o={type:n.type};n.type==="prompt"&&(o.prompt=this.customizePrompt(n)),n.matcher&&(o.matcher=n.matcher),t[r].push(o);}return {version:1,hooks:t}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,No)}};});function rr(s){return `constellation-${{SessionStart:"session-start",SubagentStart:"before-agent",PreCompact:"pre-compress",PreToolUse:"before-tool",PostToolUse:"after-tool",SessionEnd:"session-end"}[s]}.sh`}var Ro,Ao,jo,Ce,Tt=m(()=>{Ro={SessionStart:"SessionStart",SubagentStart:"BeforeAgent",PreCompact:"PreCompress",PreToolUse:"BeforeTool",PostToolUse:"AfterTool",SessionEnd:"SessionEnd"},Ao={SessionStart:"startup",SubagentStart:"",PreCompact:""},jo="code_intel";Ce=class{id="gemini";displayName="Gemini CLI";mapEventName(e){return Ro[e]}generateConfig(e){let t={};for(let n of e){let r=this.mapEventName(n.event);if(!r)continue;t[r]||(t[r]=[]);let o=Ao[n.event]??"",i=rr(n.event),a=t[r].find(l=>l.matcher===o);a||(a={matcher:o,hooks:[]},t[r].push(a)),a.hooks.push({name:`constellation-${n.event.toLowerCase()}`,type:"command",command:`$GEMINI_PROJECT_DIR/.gemini/hooks/${i}`,timeout:5e3,description:`Constellation: ${this.getHookDescription(n.event)}`});}return {hooks:t}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,jo)}generateAuxiliaryFiles(e){let t=new Map;for(let n of e){if(!this.mapEventName(n.event))continue;let i=`.gemini/hooks/${rr(n.event)}`,a=this.generateScript(n);t.set(i,a);}return t.size>0?t:void 0}generateScript(e){let n=this.customizePrompt(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n");return e.event==="PreCompact"?`#!/bin/bash
110
+ `}};});var ko,To,Q,$t=m(()=>{ko={SessionStart:"sessionStart",SubagentStart:"subagentStart",PreCompact:"preCompact",PreToolUse:"preToolUse",PostToolUse:"postToolUse",SessionEnd:"sessionEnd"},To="constellation__code_intel",Q=class{id="cursor";displayName="Cursor";mapEventName(e){return ko[e]}generateConfig(e){let t={};for(let n of e){let r=this.mapEventName(n.event);if(!r)continue;t[r]||(t[r]=[]);let o={type:n.type};n.type==="prompt"&&(o.prompt=this.customizePrompt(n)),n.matcher&&(o.matcher=n.matcher),t[r].push(o);}return {version:1,hooks:t}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,To)}};});function nr(s){return `constellation-${{SessionStart:"session-start",SubagentStart:"before-agent",PreCompact:"pre-compress",PreToolUse:"before-tool",PostToolUse:"after-tool",SessionEnd:"session-end"}[s]}.sh`}var No,Ro,Ao,Ce,kt=m(()=>{No={SessionStart:"SessionStart",SubagentStart:"BeforeAgent",PreCompact:"PreCompress",PreToolUse:"BeforeTool",PostToolUse:"AfterTool",SessionEnd:"SessionEnd"},Ro={SessionStart:"startup",SubagentStart:"",PreCompact:""},Ao="code_intel";Ce=class{id="gemini";displayName="Gemini CLI";mapEventName(e){return No[e]}generateConfig(e){let t={};for(let n of e){let r=this.mapEventName(n.event);if(!r)continue;t[r]||(t[r]=[]);let o=Ro[n.event]??"",i=nr(n.event),a=t[r].find(c=>c.matcher===o);a||(a={matcher:o,hooks:[]},t[r].push(a)),a.hooks.push({name:`constellation-${n.event.toLowerCase()}`,type:"command",command:`$GEMINI_PROJECT_DIR/.gemini/hooks/${i}`,timeout:5e3,description:`Constellation: ${this.getHookDescription(n.event)}`});}return {hooks:t}}customizePrompt(e){return e.content.replace(/\{MCP_TOOL_NAME\}/g,Ao)}generateAuxiliaryFiles(e){let t=new Map;for(let n of e){if(!this.mapEventName(n.event))continue;let i=`.gemini/hooks/${nr(n.event)}`,a=this.generateScript(n);t.set(i,a);}return t.size>0?t:void 0}generateScript(e){let n=this.customizePrompt(e).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n");return e.event==="PreCompact"?`#!/bin/bash
111
111
  # Constellation ${e.event} Hook for Gemini CLI
112
112
  # Generated by constellation-cli - DO NOT EDIT
113
113
  #
@@ -130,19 +130,19 @@ cat << 'CONSTELLATION_EOF'
130
130
  }
131
131
  }
132
132
  CONSTELLATION_EOF
133
- `}getHookDescription(e){return {SessionStart:"Inject code intelligence guidance at session start",SubagentStart:"Inject guidance for agent planning",PreCompact:"Context preservation reminder",PreToolUse:"Pre-tool execution hook",PostToolUse:"Post-tool execution hook",SessionEnd:"Session end hook"}[e]}};});function Nt(s){return Lo.get(s)}var Lo,Rt=m(()=>{$t();kt();Tt();$t();kt();Tt();Lo=new Map([["cline",new ye],["cursor",new Q],["gemini",new Ce]]);});var we,ir=m(()=>{F();Rt();we=class{cwd;constructor(e=process.cwd()){this.cwd=e;}async configureHooks(e,t){if(!e.hooksConfig)return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:"Tool does not support hooks configuration"};let n=Nt(e.hooksConfig.adapterId);if(!n)return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:`Unknown adapter: ${e.hooksConfig.adapterId}`};try{let r=v__default.join(this.cwd,e.hooksConfig.filePath),o=n.generateConfig(t),i=Object.keys(o).some(l=>{let g=o[l];return g!=null&&(typeof g!="object"||Object.keys(g).length>0)});if(i){await this.ensureDirectoryExists(r);let l=await this.readConfig(r),g=this.mergeHooksConfig(l,o);await this.writeConfig(r,g);}let a;if(n.generateAuxiliaryFiles){let l=n.generateAuxiliaryFiles(t);l&&(await this.writeAuxiliaryFiles(l),a=Array.from(l.keys()));}return {toolId:e.id,toolDisplayName:e.displayName,success:!0,configuredPath:i?r:void 0,auxiliaryPaths:a}}catch(r){return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:r instanceof Error?r.message:String(r)}}}async ensureDirectoryExists(e){let t=v__default.dirname(e);await N__default.mkdir(t,{recursive:true});}async readConfig(e){try{if(!await h.fileIsReadable(e))return {};let n=await h.readFile(e);return JSON.parse(n)}catch{return {}}}mergeHooksConfig(e,t){if(Object.keys(e).length===0)return t;let n=e.hooks??{},r=t.hooks??{},o={...n,...r},i={...e,hooks:o};return t.version!==void 0&&(i.version=t.version),i}async writeConfig(e,t){let n=JSON.stringify(t,null," ");n=n.replace(/\r\n/g,`
133
+ `}getHookDescription(e){return {SessionStart:"Inject code intelligence guidance at session start",SubagentStart:"Inject guidance for agent planning",PreCompact:"Context preservation reminder",PreToolUse:"Pre-tool execution hook",PostToolUse:"Post-tool execution hook",SessionEnd:"Session end hook"}[e]}};});function Tt(s){return jo.get(s)}var jo,Nt=m(()=>{It();$t();kt();It();$t();kt();jo=new Map([["cline",new ye],["cursor",new Q],["gemini",new Ce]]);});var we,or=m(()=>{F();Nt();we=class{cwd;constructor(e=process.cwd()){this.cwd=e;}async configureHooks(e,t){if(!e.hooksConfig)return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:"Tool does not support hooks configuration"};let n=Tt(e.hooksConfig.adapterId);if(!n)return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:`Unknown adapter: ${e.hooksConfig.adapterId}`};try{let r=v__default.join(this.cwd,e.hooksConfig.filePath),o=n.generateConfig(t),i=Object.keys(o).some(c=>{let g=o[c];return g!=null&&(typeof g!="object"||Object.keys(g).length>0)});if(i){await this.ensureDirectoryExists(r);let c=await this.readConfig(r),g=this.mergeHooksConfig(c,o);await this.writeConfig(r,g);}let a;if(n.generateAuxiliaryFiles){let c=n.generateAuxiliaryFiles(t);c&&(await this.writeAuxiliaryFiles(c),a=Array.from(c.keys()));}return {toolId:e.id,toolDisplayName:e.displayName,success:!0,configuredPath:i?r:void 0,auxiliaryPaths:a}}catch(r){return {toolId:e.id,toolDisplayName:e.displayName,success:false,error:r instanceof Error?r.message:String(r)}}}async ensureDirectoryExists(e){let t=v__default.dirname(e);await N__default.mkdir(t,{recursive:true});}async readConfig(e){try{if(!await h.fileIsReadable(e))return {};let n=await h.readFile(e);return JSON.parse(n)}catch{return {}}}mergeHooksConfig(e,t){if(Object.keys(e).length===0)return t;let n=e.hooks??{},r=t.hooks??{},o={...n,...r},i={...e,hooks:o};return t.version!==void 0&&(i.version=t.version),i}async writeConfig(e,t){let n=JSON.stringify(t,null," ");n=n.replace(/\r\n/g,`
134
134
  `),n.endsWith(`
135
135
  `)||(n+=`
136
136
  `),await h.writeFile(e,n);}async writeAuxiliaryFiles(e){for(let[t,n]of e){let r=v__default.join(this.cwd,t);await this.ensureDirectoryExists(r);let o=n.replace(/\r\n/g,`
137
137
  `);o.endsWith(`
138
138
  `)||(o+=`
139
- `),await h.writeFile(r,o),(t.endsWith(".sh")||o.startsWith("#!"))&&await N__default.chmod(r,493);}}};});var sr=m(()=>{tr();ir();Rt();});var z,We=m(()=>{z=class{getBuildConfigManager(e,t){return null}getImportResolver(e,t){return null}};});var ee,jt=m(()=>{k();ee=class{configPaths=[];parseCache=new Map;initialized=false;isTypeScriptEnabled;isJavaScriptEnabled;isPathResolutionEnabled;projectRoot;constructor(e,t){this.projectRoot=e,this.isTypeScriptEnabled="typescript"in t,this.isJavaScriptEnabled="javascript"in t,this.isPathResolutionEnabled=this.isTypeScriptEnabled||this.isJavaScriptEnabled;}async initialize(){if(this.initialized)return this.configPaths;if(this.initialized=true,!this.isPathResolutionEnabled)return [];try{let e=[];if(this.isTypeScriptEnabled){let t=await findAll(this.projectRoot,{skip:n=>n==="node_modules"||n===".git",configNames:["tsconfig.json"]});e.push(...t);}if(this.isJavaScriptEnabled){let t=await findAll(this.projectRoot,{skip:n=>n==="node_modules"||n===".git",configNames:["jsconfig.json"]});e.push(...t);}return this.configPaths=e,this.configPaths}catch(e){return console.warn(`${w} Failed to discover config files:`,e),[]}}async getConfigForFile(e){if(this.parseCache.has(e))return this.parseCache.get(e);if(!this.isPathResolutionEnabled)return this.parseCache.set(e,null),null;try{let t=e.endsWith(".ts")||e.endsWith(".tsx")||e.endsWith(".d.ts"),n=e.endsWith(".js")||e.endsWith(".jsx")||e.endsWith(".mjs");if(t&&this.isTypeScriptEnabled){let r=await parse(e,{root:this.projectRoot,configName:"tsconfig.json"});return this.parseCache.set(e,r),r}if(n){if(this.isJavaScriptEnabled)try{let r=await parse(e,{root:this.projectRoot,configName:"jsconfig.json"});return this.parseCache.set(e,r),r}catch(r){if(this.isTypeScriptEnabled){let o=await parse(e,{root:this.projectRoot,configName:"tsconfig.json"});return this.parseCache.set(e,o),o}throw r}if(this.isTypeScriptEnabled){let r=await parse(e,{root:this.projectRoot,configName:"tsconfig.json"});return this.parseCache.set(e,r),r}}return this.parseCache.set(e,null),null}catch(t){return console.warn(`${w} Failed to parse config for ${e}:`,t),this.parseCache.set(e,null),null}}isEnabled(){return this.isPathResolutionEnabled}getConfigPaths(){return [...this.configPaths]}getTsconfigPaths(){return this.getConfigPaths()}clearCache(){this.parseCache.clear();}};});var Ke,cr=m(()=>{Z();Ke=class{constructor(e,t){this.projectRoot=e;this.tsconfigResult=t;}workspacePackages={};initialized=false;async initialize(){if(this.initialized)return;this.initialized=true;let e={},t=await this.loadFromPackageJsonWorkspaces();Object.assign(e,t);let n=await this.loadFromTsConfig();Object.assign(e,n),this.workspacePackages=e;}async resolve(e){if(await this.initialize(),this.workspacePackages[e])return this.toProjectRelative(this.workspacePackages[e]);for(let[t,n]of Object.entries(this.workspacePackages))if(e.startsWith(t+"/")){let r=e.substring(t.length+1),o=await this.resolveSubPath(n,r);if(o)return this.toProjectRelative(o)}return null}async isWorkspacePackage(e){return await this.resolve(e)!==null}async loadFromTsConfig(){let e={};if(!this.tsconfigResult?.tsconfig?.compilerOptions?.paths)return e;let t=this.tsconfigResult.tsconfig.compilerOptions.paths,n=this.tsconfigResult.tsconfigFile?v.dirname(this.tsconfigResult.tsconfigFile):this.projectRoot;for(let[r,o]of Object.entries(t)){if(r.includes("*")||!Array.isArray(o))continue;let i=o[0];if(!i)continue;let a=v.resolve(n,i),l=await this.findEntryPoint(a);l&&(e[r]=l);}return e}async loadFromPackageJsonWorkspaces(){let e={};try{let t=v.join(this.projectRoot,"package.json"),n=await N.readFile(t,"utf-8"),o=JSON.parse(n).workspaces;if(!o)return e;let i=Array.isArray(o)?o:o.packages||[];for(let a of i){let l=await this.findWorkspaceDirs(a);for(let g of l){let d=await this.loadWorkspacePackage(g);d&&Object.assign(e,d);}}}catch{}return e}async findWorkspaceDirs(e){let t=[];if(e.endsWith("/*")){let n=e.slice(0,-2),r=v.join(this.projectRoot,n);try{let o=await N.readdir(r,{withFileTypes:!0});for(let i of o)i.isDirectory()&&t.push(v.join(r,i.name));}catch{}}else {let n=v.join(this.projectRoot,e);try{(await N.stat(n)).isDirectory()&&t.push(n);}catch{}}return t}async loadWorkspacePackage(e){try{let t=v.join(e,"package.json"),n=await N.readFile(t,"utf-8"),r=JSON.parse(n),o=r.name;if(!o)return null;let i=await this.findPackageEntryPoint(e,r);return i?{[o]:i}:null}catch{return null}}async findPackageEntryPoint(e,t){if(t.exports){let r=t.exports;if(typeof r=="string")return v.join(e,r);if(typeof r=="object"){let o=r["."]||r["./index"];if(typeof o=="string")return v.join(e,o);if(typeof o=="object"){let i=o.import||o.default||o.require;if(i)return v.join(e,i)}}}if(t.main)return v.join(e,t.main);let n=["src/index.ts","src/index.tsx","src/index.js","src/index.jsx","index.ts","index.tsx","index.js","index.jsx"];for(let r of n){let o=v.join(e,r);try{if((await N.stat(o)).isFile())return o}catch{}}return null}async findEntryPoint(e){let t=["index.ts","index.tsx","index.js","index.jsx","index.d.ts"];for(let n of t){let r=v.join(e,n);try{if((await N.stat(r)).isFile())return r}catch{}}try{if((await N.stat(e)).isFile())return e}catch{}return null}async resolveSubPath(e,t){let n=e.endsWith("index.ts")||e.endsWith("index.tsx")||e.endsWith("index.js")||e.endsWith("index.jsx")?v.dirname(e):v.dirname(e),r=[v.join(n,t+".ts"),v.join(n,t+".tsx"),v.join(n,t+".js"),v.join(n,t+".jsx"),v.join(n,t+".d.ts"),v.join(n,t,"index.ts"),v.join(n,t,"index.tsx"),v.join(n,t,"index.js"),v.join(n,t,"index.jsx")];for(let o of r)try{if((await N.stat(o)).isFile())return o}catch{}return null}toProjectRelative(e){let t=G(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}};});var te,Lt=m(()=>{Z();cr();te=class{baseUrl=null;paths={};sourceDir;tsconfigDir;projectRoot;extensions;packageImports={};packageJsonDir=null;sourceFilePath;workspaceResolver;constructor(e,t){this.sourceFilePath=e,this.sourceDir=v.dirname(e),this.projectRoot=process.cwd(),this.workspaceResolver=new Ke(this.projectRoot,t);let n=e.toLowerCase(),r=n.endsWith(".ts")||n.endsWith(".tsx")||n.endsWith(".d.ts"),o=n.endsWith(".js")||n.endsWith(".jsx")||n.endsWith(".mjs")||n.endsWith(".cjs");if(r?this.extensions=[".ts",".tsx",".d.ts"]:o?this.extensions=[".js",".jsx",".mjs",".cjs"]:this.extensions=[".ts",".tsx",".d.ts"],!t?.tsconfigFile){this.tsconfigDir=this.sourceDir;return}this.tsconfigDir=v.dirname(t.tsconfigFile);let i=t.tsconfig?.compilerOptions;i&&(i.baseUrl&&(this.baseUrl=v.resolve(this.tsconfigDir,i.baseUrl)),i.paths&&typeof i.paths=="object"&&(this.paths=i.paths));}async resolve(e){if(e.startsWith("./")||e.startsWith("../")){let n=v.resolve(this.sourceDir,e),r=await this.findFileWithExtensions(n);return r?this.toProjectRelative(r):e}if(e.startsWith("#")){let n=await this.resolveWithPackageImports(e);return n?this.toProjectRelative(n):e}let t=await this.workspaceResolver.resolve(e);if(t)return t;if(!e.startsWith("@")&&!e.startsWith("~")&&(!e.includes("/")||!this.baseUrl))return e;if(Object.keys(this.paths).length>0){let n=await this.resolveWithPaths(e);if(n)return this.toProjectRelative(n)}if(this.baseUrl){let n=await this.resolveWithBaseUrl(e);if(n)return this.toProjectRelative(n)}return e}toProjectRelative(e){let t=G(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}async resolveWithPaths(e){for(let[t,n]of Object.entries(this.paths)){let r=this.matchPathPattern(e,t);if(r!==null)for(let o of n){let i=await this.trySubstitution(e,t,o,r);if(i)return i}}return null}matchPathPattern(e,t){if(!t.includes("*"))return e===t?"":null;let[n,r]=t.split("*");if(!e.startsWith(n)||r&&!e.endsWith(r))return null;let o=n.length,i=r?e.length-r.length:e.length;return e.substring(o,i)}async trySubstitution(e,t,n,r){let o=n.replaceAll("*",r),i=v.resolve(this.tsconfigDir,o);return await this.findFileWithExtensions(i)}async resolveWithBaseUrl(e){if(!this.baseUrl)return null;let t=v.resolve(this.baseUrl,e);return await this.findFileWithExtensions(t)}async findFileWithExtensions(e){let t=this.extensions.some(i=>e.endsWith(i));if(t&&await this.fileExists(e))return await this.resolveSymlink(e);let n=[".js",".jsx",".mjs",".cjs"],r=n.some(i=>e.endsWith(i)),o=e;if(r&&!t){for(let i of n)if(e.endsWith(i)){o=e.slice(0,-i.length);break}}if(!t)for(let i of this.extensions){let a=o+i;if(await this.fileExists(a))return await this.resolveSymlink(a)}for(let i of this.extensions){let a=v.join(o,`index${i}`);if(await this.fileExists(a))return await this.resolveSymlink(a)}return null}async fileExists(e){try{return (await N.stat(e)).isFile()}catch{return false}}async resolveSymlink(e){try{return await N.realpath(e)}catch{return e}}async findPackageJson(e){let t=e;for(;t.startsWith(this.projectRoot);){let n=v.join(t,"package.json");try{if((await N.stat(n)).isFile())return n}catch{}let r=v.dirname(t);if(r===t)break;t=r;}return null}async loadPackageImports(){if(this.packageJsonDir!==null)return;let e=await this.findPackageJson(this.sourceDir);if(!e){this.packageJsonDir="";return}try{let t=await N.readFile(e,"utf-8"),n=JSON.parse(t);this.packageJsonDir=v.dirname(e),n.imports&&typeof n.imports=="object"&&(this.packageImports=n.imports);}catch{this.packageJsonDir="";}}async resolveWithPackageImports(e){if(await this.loadPackageImports(),!this.packageJsonDir||Object.keys(this.packageImports).length===0)return null;for(let[t,n]of Object.entries(this.packageImports)){let r=this.matchPathPattern(e,t);if(r!==null){if(typeof n=="string"){let o=await this.tryPackageImportSubstitution(n,r);if(o)return o}if(Array.isArray(n)){for(let o of n)if(typeof o=="string"){let i=await this.tryPackageImportSubstitution(o,r);if(i)return i}}}}return null}async tryPackageImportSubstitution(e,t){if(!this.packageJsonDir)return null;let n=e.replaceAll("*",t),r=v.resolve(this.packageJsonDir,n);return await this.findFileWithExtensions(r)}};});var Ve,lr=m(()=>{We();jt();Lt();Ve=class extends z{language="typescript";extensions=[".ts",".tsx",".d.ts"];getBuildConfigManager(e,t){return new ee(e,t)}getImportResolver(e,t){return new te(e,t)}};});var Je,pr=m(()=>{We();jt();Lt();Je=class extends z{language="javascript";extensions=[".js",".jsx",".mjs",".cjs"];getBuildConfigManager(e,t){return new ee(e,t)}getImportResolver(e,t){return new te(e,t)}};});var Ye,gr=m(()=>{Ue();Ye=class{sourceDir;projectRoot;constructor(e,t){this.sourceDir=v.dirname(e),this.projectRoot=t;}async resolve(e){let t=e.split(".")[0];if(PYTHON_STDLIB_MODULES.has(t))return e;if(e.startsWith("."))return this.resolveRelative(e);let n=e.replace(/\./g,"/"),r=await this.tryResolveFile(v.resolve(this.projectRoot,n));return r?v.relative(this.projectRoot,r).replace(/\\/g,"/"):e}async resolveRelative(e){let t=0;for(;t<e.length&&e[t]===".";)t++;let n=e.slice(t),r=t<=1?"":"../".repeat(t-1),o=n?r+n.replace(/\./g,"/"):r.slice(0,-1)||".",i=v.resolve(this.sourceDir,o),a=await this.tryResolveFile(i);return a?v.relative(this.projectRoot,a).replace(/\\/g,"/"):e}async tryResolveFile(e){let t=[`${e}.py`,`${e}.pyi`,`${e}.pyw`,v.join(e,"__init__.py"),v.join(e,"__init__.pyi")];for(let n of t)try{return await qe.promises.access(n,qe.constants.F_OK),n}catch{continue}return null}};});var Xe,dr=m(()=>{We();gr();Xe=class extends z{language="python";extensions=[".py",".pyi",".pyw"];getBuildConfigManager(e,t){return null}getImportResolver(e,t){return new Ye(e,process.cwd())}};});var _e,Ze,Ot=m(()=>{lr();pr();dr();_e={bash:[".sh",".bash"],c:[".c",".h"],"c-sharp":[".cs"],cpp:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],go:[".go"],java:[".java"],javascript:[".js",".jsx"],json:[".json"],php:[".php"],python:[".py",".pyi",".pyw"],ruby:[".rb"],typescript:[".ts",".tsx"]},Ze=class{constructor(e){this.config=e;this.registerPlugin(new Ve),this.registerPlugin(new Je),this.registerPlugin(new Xe);}plugins=new Map;registerPlugin(e){this.plugins.set(e.language,e);}getPlugin(e){return this.plugins.get(e)}javascript={language:()=>Oo,fileExtensions:()=>this.config?.languages.javascript?.fileExtensions??_e.javascript};typescript={language:()=>Mo.typescript,fileExtensions:()=>this.config?.languages.typescript?.fileExtensions??_e.typescript};python={language:()=>Fo,fileExtensions:()=>this.config?.languages.python?.fileExtensions??_e.python};php;json;java;go;cpp;"c-sharp";c;bash;ruby};});function mr(s,e){let t=ie__default.homedir(),n=process.platform,r=Do[s];switch(n){case "darwin":return v__default.join(t,"Library/Application Support",r,"User/globalStorage",e);case "win32":return v__default.join(process.env.APPDATA||v__default.join(t,"AppData/Roaming"),r,"User/globalStorage",e);default:return v__default.join(t,".config",r,"User/globalStorage",e)}}function fr(){let s="saoudrizwan.claude-dev";return ["stable","insiders"].map(t=>({variant:t,displayName:t==="stable"?"VS Code":"VS Code Insiders",settingsPath:v__default.join(mr(t,s),"settings","cline_mcp_settings.json")}))}function hr(){return v__default.join(mr("stable","saoudrizwan.claude-dev"),"settings","cline_mcp_settings.json")}function Ft(){let s=ie__default.homedir();return v__default.join(s,".copilot","mcp-config.json")}function yr(){return [{displayName:"Copilot CLI",settingsPath:Ft()}]}var Do,Cr=m(()=>{Do={stable:"Code",insiders:"Code - Insiders"};});function Dt(s){return Mt.find(e=>e.id===s)}var wr,Bo,Mt,Bt=m(()=>{Cr();wr={command:"npx",args:["-y","@constellationdev/mcp@latest"]},Bo={extraKnownMarketplaces:{"constellation-plugins":{source:{source:"github",repo:"ShiftinBits/constellation-claude"}}},enabledPlugins:{"constellation@constellation-plugins":true}},Mt=[{id:"claude-code",displayName:"Claude Code",configPath:".mcp.json",format:"json",skipMcpServer:true,permissionsConfig:{filePath:".claude/settings.json",allowKeyPath:["permissions","allow"],allowValue:"mcp__plugin_constellation_*"},marketplaceConfig:{filePath:".claude/settings.json",config:Bo},mcpServersKeyPath:["mcpServers"]},{id:"cline",displayName:"Cline",configPath:hr(),isGlobalConfig:true,getGlobalConfigPaths:fr,format:"json",mcpServersKeyPath:["mcpServers"],mcpServerExtras:{alwaysAllow:["code_intel"],disabled:false},hooksConfig:{filePath:".clinerules/hooks/placeholder",schemaVersion:1,adapterId:"cline"}},{id:"codex-cli",displayName:"Codex CLI",configPath:".codex/config.toml",format:"toml",mcpServersKeyPath:["mcp_servers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"$CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{enabled_tools:["code_intel"]},envPolicyConfig:{includeOnlyKeyPath:["shell_environment_policy","include_only"],envVarsToAllow:["CONSTELLATION_ACCESS_KEY"],globalConfigPath:"~/.codex/config.toml"}},{id:"copilot-cli",displayName:"Copilot CLI",configPath:Ft(),isGlobalConfig:true,getGlobalConfigPaths:yr,format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${CONSTELLATION_ACCESS_KEY}"},mcpServerExtras:{tools:["code_intel"],type:"local"}},{id:"cursor",displayName:"Cursor",configPath:".cursor/mcp.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${env:CONSTELLATION_ACCESS_KEY}"},hooksConfig:{filePath:".cursor/hooks.json",schemaVersion:1,adapterId:"cursor"}},{id:"gemini-cli",displayName:"Gemini CLI",configPath:".gemini/settings.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${CONSTELLATION_ACCESS_KEY}"},mcpServerExtras:{trust:true},hooksConfig:{filePath:".gemini/settings.json",schemaVersion:1,adapterId:"gemini"}},{id:"jetbrains-ai",displayName:"JetBrains",configPath:".ai/mcp/mcp.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{tools:["code_intel"]}},{id:"kilo-code",displayName:"Kilo Code",configPath:".kilocode/mcp.json",format:"json",permissionsConfig:{filePath:".kilocode/mcp.json",allowKeyPath:["mcpServers","constellation","alwaysAllow"],allowValue:"code_intel"},mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${env:CONSTELLATION_ACCESS_KEY}"}},{id:"opencode",displayName:"OpenCode",configPath:"opencode.jsonc",format:"jsonc",mcpServersKeyPath:["mcp"],skipMcpServer:true,pluginConfig:{pluginKeyPath:["plugin"],pluginValue:"@constellationdev/opencode"},configDefaults:{$schema:"https://opencode.ai/config.json"}},{id:"tabnine",displayName:"Tabnine",configPath:".tabnine/mcp_servers.json",format:"json",mcpServersKeyPath:["mcpServers"]},{id:"vscode-copilot",displayName:"VSCode",configPath:".vscode/mcp.json",format:"json",mcpServersKeyPath:["servers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{tools:["code_intel"]}}];});async function _r(){if(!Ht)try{let s=await import('@iarna/toml');Ht={parse:s.parse,stringify:s.stringify};}catch{throw new Error("TOML support requires @iarna/toml package. Install with: npm install @iarna/toml")}return Ht}function Go(s){let e="",t=0,n=s.length;for(;t<n;)if(s[t]==='"'){for(e+='"',t++;t<n&&s[t]!=='"';)s[t]==="\\"?(e+=s[t++],t<n&&(e+=s[t++])):e+=s[t++];t<n&&(e+=s[t++]);}else if(s[t]==="/"&&t+1<n&&s[t+1]==="/")for(t+=2;t<n&&s[t]!==`
140
- `;)t++;else if(s[t]==="/"&&t+1<n&&s[t+1]==="*"){for(t+=2;t<n&&!(s[t]==="*"&&t+1<n&&s[t+1]==="/");)t++;t<n&&(t+=2);}else e+=s[t++];return e.replace(/,(\s*[}\]])/g,"$1")}var Ht,Qe,vr=m(()=>{F();Bt();Ht=null;Qe=class{cwd;constructor(e=process.cwd()){this.cwd=e;}async configureTool(e){try{let t=v__default.join(this.cwd,e.configPath),n=!e.skipMcpServer||!!e.pluginConfig||!!e.configDefaults;if(n){await this.ensureDirectoryExists(t);let o=await this.readConfig(t,e.format);if(e.configDefaults)for(let[i,a]of Object.entries(e.configDefaults))i in o||(o[i]=a);e.pluginConfig&&(o=this.addPluginToArray(o,e.pluginConfig)),e.skipMcpServer||(o=this.addConstellationServer(o,e),await this.configureEnvPolicy(o,e)),await this.writeConfig(t,o,e.format);}e.permissionsConfig&&await this.configurePermissions(e.permissionsConfig),e.marketplaceConfig&&await this.configureMarketplace(e.marketplaceConfig);let r;return n?r=t:e.permissionsConfig?r=v__default.join(this.cwd,e.permissionsConfig.filePath):e.marketplaceConfig?r=v__default.join(this.cwd,e.marketplaceConfig.filePath):r=t,{tool:e,success:!0,configuredPath:r}}catch(t){return {tool:e,success:false,error:t instanceof Error?t.message:String(t)}}}async configureGlobalTool(e){if(!e.getGlobalConfigPaths)return [{tool:e,success:false,error:"No global config paths defined"}];let t=e.getGlobalConfigPaths(),n=[];for(let{displayName:r,settingsPath:o}of t)try{await this.ensureDirectoryExists(o);let i=await this.readConfig(o,e.format);i=this.addConstellationServer(i,e),await this.writeConfig(o,i,e.format),n.push({tool:{...e,displayName:`${e.displayName} (${r})`},success:!0,configuredPath:o});}catch(i){let a=i instanceof Error?i.message:String(i);a.includes("ENOENT")||a.includes("no such file")||n.push({tool:{...e,displayName:`${e.displayName} (${r})`},success:false,error:a});}return n}async ensureDirectoryExists(e){let t=v__default.dirname(e);await N__default.mkdir(t,{recursive:true});}async readConfig(e,t){try{if(!await h.fileIsReadable(e))return {};let r=await h.readFile(e);return t==="json"?JSON.parse(r):t==="jsonc"?JSON.parse(Go(r)):(await _r()).parse(r)}catch{return {}}}addConstellationServer(e,t){let n=e;for(let i=0;i<t.mcpServersKeyPath.length-1;i++){let a=t.mcpServersKeyPath[i];(!n[a]||typeof n[a]!="object")&&(n[a]={}),n=n[a];}let r=t.mcpServersKeyPath[t.mcpServersKeyPath.length-1];(!n[r]||typeof n[r]!="object")&&(n[r]={});let o=n[r];if(!o.constellation){let i=t.mcpServerConfigOverride??wr,a={...i};if(t.mcpServerExtras&&Object.assign(a,t.mcpServerExtras),t.mcpEnv){let l=t.mcpEnvKey??"env",g=i[l];a[l]={...g,...t.mcpEnv};}o.constellation=a;}return e}async writeConfig(e,t,n){let r;n==="json"||n==="jsonc"?r=JSON.stringify(t,null,2):r=(await _r()).stringify(t),r=r.replace(/\r\n/g,`
139
+ `),await h.writeFile(r,o),(t.endsWith(".sh")||o.startsWith("#!"))&&await N__default.chmod(r,493);}}};});var ir=m(()=>{er();or();Nt();});var z,We=m(()=>{z=class{getBuildConfigManager(e,t){return null}getImportResolver(e,t){return null}};});var ee,At=m(()=>{k();ee=class{configPaths=[];parseCache=new Map;failedConfigFiles=new Set;initialized=false;isTypeScriptEnabled;isJavaScriptEnabled;isPathResolutionEnabled;projectRoot;constructor(e,t){this.projectRoot=e,this.isTypeScriptEnabled="typescript"in t,this.isJavaScriptEnabled="javascript"in t,this.isPathResolutionEnabled=this.isTypeScriptEnabled||this.isJavaScriptEnabled;}async initialize(){if(this.initialized)return this.configPaths;if(this.initialized=true,!this.isPathResolutionEnabled)return [];try{let e=[];if(this.isTypeScriptEnabled){let t=await findAll(this.projectRoot,{skip:n=>n==="node_modules"||n===".git",configNames:["tsconfig.json"]});e.push(...t);}if(this.isJavaScriptEnabled){let t=await findAll(this.projectRoot,{skip:n=>n==="node_modules"||n===".git",configNames:["jsconfig.json"]});e.push(...t);}return this.configPaths=e,this.configPaths}catch(e){return console.warn(`${C} Failed to discover config files:`,e),[]}}async getConfigForFile(e){if(this.parseCache.has(e))return this.parseCache.get(e);if(!this.isPathResolutionEnabled)return this.parseCache.set(e,null),null;try{let t=e.endsWith(".ts")||e.endsWith(".tsx")||e.endsWith(".d.ts"),n=e.endsWith(".js")||e.endsWith(".jsx")||e.endsWith(".mjs");if(t&&this.isTypeScriptEnabled){let r=await this.findAndParse(e,"tsconfig.json");return this.parseCache.set(e,r),r}if(n){if(this.isJavaScriptEnabled)try{let r=await this.findAndParse(e,"jsconfig.json");return this.parseCache.set(e,r),r}catch(r){if(this.isTypeScriptEnabled){let o=await this.findAndParse(e,"tsconfig.json");return this.parseCache.set(e,o),o}throw r}if(this.isTypeScriptEnabled){let r=await this.findAndParse(e,"tsconfig.json");return this.parseCache.set(e,r),r}}return this.parseCache.set(e,null),null}catch(t){return this.handleConfigError(e,t),this.parseCache.set(e,null),null}}isEnabled(){return this.isPathResolutionEnabled}getConfigPaths(){return [...this.configPaths]}getTsconfigPaths(){return this.getConfigPaths()}clearCache(){this.parseCache.clear(),this.failedConfigFiles.clear();}async findAndParse(e,t){let n=await find(e,{root:this.projectRoot,configName:t});return !n||this.failedConfigFiles.has(n)?null:parse(e,{root:this.projectRoot,configName:t})}handleConfigError(e,t){let n=t&&typeof t=="object"&&"tsconfigFile"in t?t.tsconfigFile:null;if(n&&!this.failedConfigFiles.has(n)){this.failedConfigFiles.add(n);let r=t instanceof Error?t.message:String(t);console.warn(`${C} Failed to parse ${n}: ${r}`),console.warn(`${C} Path alias resolution will be skipped for files using this config`);}else n||console.warn(`${C} Failed to parse config for ${e}:`,t instanceof Error?t.message:t);}};});var ze,ar=m(()=>{Z();ze=class{constructor(e,t){this.projectRoot=e;this.tsconfigResult=t;}workspacePackages={};initialized=false;async initialize(){if(this.initialized)return;this.initialized=true;let e={},t=await this.loadFromPackageJsonWorkspaces();Object.assign(e,t);let n=await this.loadFromTsConfig();Object.assign(e,n),this.workspacePackages=e;}async resolve(e){if(await this.initialize(),this.workspacePackages[e])return this.toProjectRelative(this.workspacePackages[e]);for(let[t,n]of Object.entries(this.workspacePackages))if(e.startsWith(t+"/")){let r=e.substring(t.length+1),o=await this.resolveSubPath(n,r);if(o)return this.toProjectRelative(o)}return null}async isWorkspacePackage(e){return await this.resolve(e)!==null}async loadFromTsConfig(){let e={};if(!this.tsconfigResult?.tsconfig?.compilerOptions?.paths)return e;let t=this.tsconfigResult.tsconfig.compilerOptions.paths,n=this.tsconfigResult.tsconfigFile?v.dirname(this.tsconfigResult.tsconfigFile):this.projectRoot;for(let[r,o]of Object.entries(t)){if(r.includes("*")||!Array.isArray(o))continue;let i=o[0];if(!i)continue;let a=v.resolve(n,i),c=await this.findEntryPoint(a);c&&(e[r]=c);}return e}async loadFromPackageJsonWorkspaces(){let e={};try{let t=v.join(this.projectRoot,"package.json"),n=await N.readFile(t,"utf-8"),o=JSON.parse(n).workspaces;if(!o)return e;let i=Array.isArray(o)?o:o.packages||[];for(let a of i){let c=await this.findWorkspaceDirs(a);for(let g of c){let d=await this.loadWorkspacePackage(g);d&&Object.assign(e,d);}}}catch{}return e}async findWorkspaceDirs(e){let t=[];if(e.endsWith("/*")){let n=e.slice(0,-2),r=v.join(this.projectRoot,n);try{let o=await N.readdir(r,{withFileTypes:!0});for(let i of o)i.isDirectory()&&t.push(v.join(r,i.name));}catch{}}else {let n=v.join(this.projectRoot,e);try{(await N.stat(n)).isDirectory()&&t.push(n);}catch{}}return t}async loadWorkspacePackage(e){try{let t=v.join(e,"package.json"),n=await N.readFile(t,"utf-8"),r=JSON.parse(n),o=r.name;if(!o)return null;let i=await this.findPackageEntryPoint(e,r);return i?{[o]:i}:null}catch{return null}}async findPackageEntryPoint(e,t){if(t.exports){let r=t.exports;if(typeof r=="string")return v.join(e,r);if(typeof r=="object"){let o=r["."]||r["./index"];if(typeof o=="string")return v.join(e,o);if(typeof o=="object"){let i=o.import||o.default||o.require;if(i)return v.join(e,i)}}}if(t.main)return v.join(e,t.main);let n=["src/index.ts","src/index.tsx","src/index.js","src/index.jsx","index.ts","index.tsx","index.js","index.jsx"];for(let r of n){let o=v.join(e,r);try{if((await N.stat(o)).isFile())return o}catch{}}return null}async findEntryPoint(e){let t=["index.ts","index.tsx","index.js","index.jsx","index.d.ts"];for(let n of t){let r=v.join(e,n);try{if((await N.stat(r)).isFile())return r}catch{}}try{if((await N.stat(e)).isFile())return e}catch{}return null}async resolveSubPath(e,t){let n=e.endsWith("index.ts")||e.endsWith("index.tsx")||e.endsWith("index.js")||e.endsWith("index.jsx")?v.dirname(e):v.dirname(e),r=[v.join(n,t+".ts"),v.join(n,t+".tsx"),v.join(n,t+".js"),v.join(n,t+".jsx"),v.join(n,t+".d.ts"),v.join(n,t,"index.ts"),v.join(n,t,"index.tsx"),v.join(n,t,"index.js"),v.join(n,t,"index.jsx")];for(let o of r)try{if((await N.stat(o)).isFile())return o}catch{}return null}toProjectRelative(e){let t=G(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}};});var te,jt=m(()=>{Z();ar();te=class{baseUrl=null;paths={};sourceDir;tsconfigDir;projectRoot;extensions;packageImports={};packageJsonDir=null;sourceFilePath;workspaceResolver;constructor(e,t){this.sourceFilePath=e,this.sourceDir=v.dirname(e),this.projectRoot=process.cwd(),this.workspaceResolver=new ze(this.projectRoot,t);let n=e.toLowerCase(),r=n.endsWith(".ts")||n.endsWith(".tsx")||n.endsWith(".d.ts"),o=n.endsWith(".js")||n.endsWith(".jsx")||n.endsWith(".mjs")||n.endsWith(".cjs");if(r?this.extensions=[".ts",".tsx",".d.ts"]:o?this.extensions=[".js",".jsx",".mjs",".cjs"]:this.extensions=[".ts",".tsx",".d.ts"],!t?.tsconfigFile){this.tsconfigDir=this.sourceDir;return}this.tsconfigDir=v.dirname(t.tsconfigFile);let i=t.tsconfig?.compilerOptions;i&&(i.baseUrl&&(this.baseUrl=v.resolve(this.tsconfigDir,i.baseUrl)),i.paths&&typeof i.paths=="object"&&(this.paths=i.paths));}async resolve(e){if(e.startsWith("./")||e.startsWith("../")){let n=v.resolve(this.sourceDir,e),r=await this.findFileWithExtensions(n);return r?this.toProjectRelative(r):e}if(e.startsWith("#")){let n=await this.resolveWithPackageImports(e);return n?this.toProjectRelative(n):e}let t=await this.workspaceResolver.resolve(e);if(t)return t;if(!e.startsWith("@")&&!e.startsWith("~")&&(!e.includes("/")||!this.baseUrl))return e;if(Object.keys(this.paths).length>0){let n=await this.resolveWithPaths(e);if(n)return this.toProjectRelative(n)}if(this.baseUrl){let n=await this.resolveWithBaseUrl(e);if(n)return this.toProjectRelative(n)}return e}toProjectRelative(e){let t=G(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}async resolveWithPaths(e){for(let[t,n]of Object.entries(this.paths)){let r=this.matchPathPattern(e,t);if(r!==null)for(let o of n){let i=await this.trySubstitution(e,t,o,r);if(i)return i}}return null}matchPathPattern(e,t){if(!t.includes("*"))return e===t?"":null;let[n,r]=t.split("*");if(!e.startsWith(n)||r&&!e.endsWith(r))return null;let o=n.length,i=r?e.length-r.length:e.length;return e.substring(o,i)}async trySubstitution(e,t,n,r){let o=n.replaceAll("*",r),i=v.resolve(this.tsconfigDir,o);return await this.findFileWithExtensions(i)}async resolveWithBaseUrl(e){if(!this.baseUrl)return null;let t=v.resolve(this.baseUrl,e);return await this.findFileWithExtensions(t)}async findFileWithExtensions(e){let t=this.extensions.some(i=>e.endsWith(i));if(t&&await this.fileExists(e))return await this.resolveSymlink(e);let n=[".js",".jsx",".mjs",".cjs"],r=n.some(i=>e.endsWith(i)),o=e;if(r&&!t){for(let i of n)if(e.endsWith(i)){o=e.slice(0,-i.length);break}}if(!t)for(let i of this.extensions){let a=o+i;if(await this.fileExists(a))return await this.resolveSymlink(a)}for(let i of this.extensions){let a=v.join(o,`index${i}`);if(await this.fileExists(a))return await this.resolveSymlink(a)}return null}async fileExists(e){try{return (await N.stat(e)).isFile()}catch{return false}}async resolveSymlink(e){try{return await N.realpath(e)}catch{return e}}async findPackageJson(e){let t=e;for(;t.startsWith(this.projectRoot);){let n=v.join(t,"package.json");try{if((await N.stat(n)).isFile())return n}catch{}let r=v.dirname(t);if(r===t)break;t=r;}return null}async loadPackageImports(){if(this.packageJsonDir!==null)return;let e=await this.findPackageJson(this.sourceDir);if(!e){this.packageJsonDir="";return}try{let t=await N.readFile(e,"utf-8"),n=JSON.parse(t);this.packageJsonDir=v.dirname(e),n.imports&&typeof n.imports=="object"&&(this.packageImports=n.imports);}catch{this.packageJsonDir="";}}async resolveWithPackageImports(e){if(await this.loadPackageImports(),!this.packageJsonDir||Object.keys(this.packageImports).length===0)return null;for(let[t,n]of Object.entries(this.packageImports)){let r=this.matchPathPattern(e,t);if(r!==null){if(typeof n=="string"){let o=await this.tryPackageImportSubstitution(n,r);if(o)return o}if(Array.isArray(n)){for(let o of n)if(typeof o=="string"){let i=await this.tryPackageImportSubstitution(o,r);if(i)return i}}}}return null}async tryPackageImportSubstitution(e,t){if(!this.packageJsonDir)return null;let n=e.replaceAll("*",t),r=v.resolve(this.packageJsonDir,n);return await this.findFileWithExtensions(r)}};});var Ke,lr=m(()=>{We();At();jt();Ke=class extends z{language="typescript";extensions=[".ts",".tsx",".d.ts"];getBuildConfigManager(e,t){return new ee(e,t)}getImportResolver(e,t){return new te(e,t)}};});var Ve,cr=m(()=>{We();At();jt();Ve=class extends z{language="javascript";extensions=[".js",".jsx",".mjs",".cjs"];getBuildConfigManager(e,t){return new ee(e,t)}getImportResolver(e,t){return new te(e,t)}};});var Je,pr=m(()=>{Ue();Je=class{sourceDir;projectRoot;constructor(e,t){this.sourceDir=v.dirname(e),this.projectRoot=t;}async resolve(e){let t=e.split(".")[0];if(PYTHON_STDLIB_MODULES.has(t))return e;if(e.startsWith("."))return this.resolveRelative(e);let n=e.replace(/\./g,"/"),r=await this.tryResolveFile(v.resolve(this.projectRoot,n));return r?v.relative(this.projectRoot,r).replace(/\\/g,"/"):e}async resolveRelative(e){let t=0;for(;t<e.length&&e[t]===".";)t++;let n=e.slice(t),r=t<=1?"":"../".repeat(t-1),o=n?r+n.replace(/\./g,"/"):r.slice(0,-1)||".",i=v.resolve(this.sourceDir,o),a=await this.tryResolveFile(i);return a?v.relative(this.projectRoot,a).replace(/\\/g,"/"):e}async tryResolveFile(e){let t=[`${e}.py`,`${e}.pyi`,`${e}.pyw`,v.join(e,"__init__.py"),v.join(e,"__init__.pyi")];for(let n of t)try{return await Ye.promises.access(n,Ye.constants.F_OK),n}catch{continue}return null}};});var qe,gr=m(()=>{We();pr();qe=class extends z{language="python";extensions=[".py",".pyi",".pyw"];getBuildConfigManager(e,t){return null}getImportResolver(e,t){return new Je(e,process.cwd())}};});var _e,Xe,Lt=m(()=>{lr();cr();gr();_e={bash:[".sh",".bash"],c:[".c",".h"],"c-sharp":[".cs"],cpp:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],go:[".go"],java:[".java"],javascript:[".js",".jsx"],json:[".json"],php:[".php"],python:[".py",".pyi",".pyw"],ruby:[".rb"],typescript:[".ts",".tsx"]},Xe=class{constructor(e){this.config=e;this.registerPlugin(new Ke),this.registerPlugin(new Ve),this.registerPlugin(new qe);}plugins=new Map;registerPlugin(e){this.plugins.set(e.language,e);}getPlugin(e){return this.plugins.get(e)}javascript={language:()=>Fo,fileExtensions:()=>this.config?.languages.javascript?.fileExtensions??_e.javascript};typescript={language:()=>Do.typescript,fileExtensions:()=>this.config?.languages.typescript?.fileExtensions??_e.typescript};python={language:()=>Mo,fileExtensions:()=>this.config?.languages.python?.fileExtensions??_e.python};php;json;java;go;cpp;"c-sharp";c;bash;ruby};});function ur(s,e){let t=ie__default.homedir(),n=process.platform,r=Bo[s];switch(n){case "darwin":return v__default.join(t,"Library/Application Support",r,"User/globalStorage",e);case "win32":return v__default.join(process.env.APPDATA||v__default.join(t,"AppData/Roaming"),r,"User/globalStorage",e);default:return v__default.join(t,".config",r,"User/globalStorage",e)}}function fr(){let s="saoudrizwan.claude-dev";return ["stable","insiders"].map(t=>({variant:t,displayName:t==="stable"?"VS Code":"VS Code Insiders",settingsPath:v__default.join(ur(t,s),"settings","cline_mcp_settings.json")}))}function mr(){return v__default.join(ur("stable","saoudrizwan.claude-dev"),"settings","cline_mcp_settings.json")}function Ot(){let s=ie__default.homedir();return v__default.join(s,".copilot","mcp-config.json")}function hr(){return [{displayName:"Copilot CLI",settingsPath:Ot()}]}var Bo,yr=m(()=>{Bo={stable:"Code",insiders:"Code - Insiders"};});function Mt(s){return Ft.find(e=>e.id===s)}var Cr,Ho,Ft,Dt=m(()=>{yr();Cr={command:"npx",args:["-y","@constellationdev/mcp@latest"]},Ho={extraKnownMarketplaces:{"constellation-plugins":{source:{source:"github",repo:"ShiftinBits/constellation-claude"}}},enabledPlugins:{"constellation@constellation-plugins":true}},Ft=[{id:"claude-code",displayName:"Claude Code",configPath:".mcp.json",format:"json",skipMcpServer:true,permissionsConfig:{filePath:".claude/settings.json",allowKeyPath:["permissions","allow"],allowValue:"mcp__plugin_constellation_*"},marketplaceConfig:{filePath:".claude/settings.json",config:Ho},mcpServersKeyPath:["mcpServers"]},{id:"cline",displayName:"Cline",configPath:mr(),isGlobalConfig:true,getGlobalConfigPaths:fr,format:"json",mcpServersKeyPath:["mcpServers"],mcpServerExtras:{alwaysAllow:["code_intel"],disabled:false},hooksConfig:{filePath:".clinerules/hooks/placeholder",schemaVersion:1,adapterId:"cline"}},{id:"codex-cli",displayName:"Codex CLI",configPath:".codex/config.toml",format:"toml",mcpServersKeyPath:["mcp_servers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"$CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{enabled_tools:["code_intel"]},envPolicyConfig:{includeOnlyKeyPath:["shell_environment_policy","include_only"],envVarsToAllow:["CONSTELLATION_ACCESS_KEY"],globalConfigPath:"~/.codex/config.toml"}},{id:"copilot-cli",displayName:"Copilot CLI",configPath:Ot(),isGlobalConfig:true,getGlobalConfigPaths:hr,format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${CONSTELLATION_ACCESS_KEY}"},mcpServerExtras:{tools:["code_intel"],type:"local"}},{id:"cursor",displayName:"Cursor",configPath:".cursor/mcp.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${env:CONSTELLATION_ACCESS_KEY}"},hooksConfig:{filePath:".cursor/hooks.json",schemaVersion:1,adapterId:"cursor"}},{id:"gemini-cli",displayName:"Gemini CLI",configPath:".gemini/settings.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${CONSTELLATION_ACCESS_KEY}"},mcpServerExtras:{trust:true},hooksConfig:{filePath:".gemini/settings.json",schemaVersion:1,adapterId:"gemini"}},{id:"jetbrains-ai",displayName:"JetBrains",configPath:".ai/mcp/mcp.json",format:"json",mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{tools:["code_intel"]}},{id:"kilo-code",displayName:"Kilo Code",configPath:".kilocode/mcp.json",format:"json",permissionsConfig:{filePath:".kilocode/mcp.json",allowKeyPath:["mcpServers","constellation","alwaysAllow"],allowValue:"code_intel"},mcpServersKeyPath:["mcpServers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"${env:CONSTELLATION_ACCESS_KEY}"}},{id:"opencode",displayName:"OpenCode",configPath:"opencode.jsonc",format:"jsonc",mcpServersKeyPath:["mcp"],skipMcpServer:true,pluginConfig:{pluginKeyPath:["plugin"],pluginValue:"@constellationdev/opencode"},configDefaults:{$schema:"https://opencode.ai/config.json"}},{id:"tabnine",displayName:"Tabnine",configPath:".tabnine/mcp_servers.json",format:"json",mcpServersKeyPath:["mcpServers"]},{id:"vscode-copilot",displayName:"VSCode",configPath:".vscode/mcp.json",format:"json",mcpServersKeyPath:["servers"],mcpEnv:{CONSTELLATION_ACCESS_KEY:"CONSTELLATION_ACCESS_KEY"},mcpServerExtras:{tools:["code_intel"]}}];});async function wr(){if(!Bt)try{let s=await import('@iarna/toml');Bt={parse:s.parse,stringify:s.stringify};}catch{throw new Error("TOML support requires @iarna/toml package. Install with: npm install @iarna/toml")}return Bt}function Wo(s){let e="",t=0,n=s.length;for(;t<n;)if(s[t]==='"'){for(e+='"',t++;t<n&&s[t]!=='"';)s[t]==="\\"?(e+=s[t++],t<n&&(e+=s[t++])):e+=s[t++];t<n&&(e+=s[t++]);}else if(s[t]==="/"&&t+1<n&&s[t+1]==="/")for(t+=2;t<n&&s[t]!==`
140
+ `;)t++;else if(s[t]==="/"&&t+1<n&&s[t+1]==="*"){for(t+=2;t<n&&!(s[t]==="*"&&t+1<n&&s[t+1]==="/");)t++;t<n&&(t+=2);}else e+=s[t++];return e.replace(/,(\s*[}\]])/g,"$1")}var Bt,Ze,_r=m(()=>{F();Dt();Bt=null;Ze=class{cwd;constructor(e=process.cwd()){this.cwd=e;}async configureTool(e){try{let t=v__default.join(this.cwd,e.configPath),n=!e.skipMcpServer||!!e.pluginConfig||!!e.configDefaults;if(n){await this.ensureDirectoryExists(t);let o=await this.readConfig(t,e.format);if(e.configDefaults)for(let[i,a]of Object.entries(e.configDefaults))i in o||(o[i]=a);e.pluginConfig&&(o=this.addPluginToArray(o,e.pluginConfig)),e.skipMcpServer||(o=this.addConstellationServer(o,e),await this.configureEnvPolicy(o,e)),await this.writeConfig(t,o,e.format);}e.permissionsConfig&&await this.configurePermissions(e.permissionsConfig),e.marketplaceConfig&&await this.configureMarketplace(e.marketplaceConfig);let r;return n?r=t:e.permissionsConfig?r=v__default.join(this.cwd,e.permissionsConfig.filePath):e.marketplaceConfig?r=v__default.join(this.cwd,e.marketplaceConfig.filePath):r=t,{tool:e,success:!0,configuredPath:r}}catch(t){return {tool:e,success:false,error:t instanceof Error?t.message:String(t)}}}async configureGlobalTool(e){if(!e.getGlobalConfigPaths)return [{tool:e,success:false,error:"No global config paths defined"}];let t=e.getGlobalConfigPaths(),n=[];for(let{displayName:r,settingsPath:o}of t)try{await this.ensureDirectoryExists(o);let i=await this.readConfig(o,e.format);i=this.addConstellationServer(i,e),await this.writeConfig(o,i,e.format),n.push({tool:{...e,displayName:`${e.displayName} (${r})`},success:!0,configuredPath:o});}catch(i){let a=i instanceof Error?i.message:String(i);a.includes("ENOENT")||a.includes("no such file")||n.push({tool:{...e,displayName:`${e.displayName} (${r})`},success:false,error:a});}return n}async ensureDirectoryExists(e){let t=v__default.dirname(e);await N__default.mkdir(t,{recursive:true});}async readConfig(e,t){try{if(!await h.fileIsReadable(e))return {};let r=await h.readFile(e);return t==="json"?JSON.parse(r):t==="jsonc"?JSON.parse(Wo(r)):(await wr()).parse(r)}catch{return {}}}addConstellationServer(e,t){let n=e;for(let i=0;i<t.mcpServersKeyPath.length-1;i++){let a=t.mcpServersKeyPath[i];(!n[a]||typeof n[a]!="object")&&(n[a]={}),n=n[a];}let r=t.mcpServersKeyPath[t.mcpServersKeyPath.length-1];(!n[r]||typeof n[r]!="object")&&(n[r]={});let o=n[r];if(!o.constellation){let i=t.mcpServerConfigOverride??Cr,a={...i};if(t.mcpServerExtras&&Object.assign(a,t.mcpServerExtras),t.mcpEnv){let c=t.mcpEnvKey??"env",g=i[c];a[c]={...g,...t.mcpEnv};}o.constellation=a;}return e}async writeConfig(e,t,n){let r;n==="json"||n==="jsonc"?r=JSON.stringify(t,null,2):r=(await wr()).stringify(t),r=r.replace(/\r\n/g,`
141
141
  `),r.endsWith(`
142
142
  `)||(r+=`
143
- `),await h.writeFile(e,r);}async configurePermissions(e){let t=v__default.join(this.cwd,e.filePath);await this.ensureDirectoryExists(t);let n={};try{if(await h.fileIsReadable(t)){let l=await h.readFile(t);n=JSON.parse(l);}}catch{}let r=n;for(let a=0;a<e.allowKeyPath.length-1;a++){let l=e.allowKeyPath[a];(!r[l]||typeof r[l]!="object")&&(r[l]={}),r=r[l];}let o=e.allowKeyPath[e.allowKeyPath.length-1];Array.isArray(r[o])||(r[o]=[]);let i=r[o];i.includes(e.allowValue)||i.push(e.allowValue),await h.writeFile(t,JSON.stringify(n,null," ")+`
143
+ `),await h.writeFile(e,r);}async configurePermissions(e){let t=v__default.join(this.cwd,e.filePath);await this.ensureDirectoryExists(t);let n={};try{if(await h.fileIsReadable(t)){let c=await h.readFile(t);n=JSON.parse(c);}}catch{}let r=n;for(let a=0;a<e.allowKeyPath.length-1;a++){let c=e.allowKeyPath[a];(!r[c]||typeof r[c]!="object")&&(r[c]={}),r=r[c];}let o=e.allowKeyPath[e.allowKeyPath.length-1];Array.isArray(r[o])||(r[o]=[]);let i=r[o];i.includes(e.allowValue)||i.push(e.allowValue),await h.writeFile(t,JSON.stringify(n,null," ")+`
144
144
  `);}async configureMarketplace(e){let t=v__default.join(this.cwd,e.filePath);await this.ensureDirectoryExists(t);let n={};try{if(await h.fileIsReadable(t)){let o=await h.readFile(t);n=JSON.parse(o);}}catch{}n=this.deepMerge(n,e.config),await h.writeFile(t,JSON.stringify(n,null," ")+`
145
- `);}deepMerge(e,t){let n={...e};for(let r of Object.keys(t)){let o=t[r],i=e[r];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?n[r]=this.deepMerge(i,o):n[r]=o;}return n}addPluginToArray(e,t){let n=e;for(let i=0;i<t.pluginKeyPath.length-1;i++){let a=t.pluginKeyPath[i];(!n[a]||typeof n[a]!="object")&&(n[a]={}),n=n[a];}let r=t.pluginKeyPath[t.pluginKeyPath.length-1];Array.isArray(n[r])||(n[r]=[]);let o=n[r];return o.includes(t.pluginValue)||o.push(t.pluginValue),e}async configureEnvPolicy(e,t){if(!t.envPolicyConfig)return;let{includeOnlyKeyPath:n,envVarsToAllow:r,globalConfigPath:o}=t.envPolicyConfig;this.addToEnvPolicyWhitelist(e,n,r),o&&await this.updateGlobalEnvPolicy(o,n,r,t.format);}addToEnvPolicyWhitelist(e,t,n){let r=e;for(let a=0;a<t.length-1;a++){let l=t[a];if(!r[l]||typeof r[l]!="object")return;r=r[l];}let o=t[t.length-1];if(!Array.isArray(r[o]))return;let i=r[o];for(let a of n)i.includes(a)||i.push(a);}async updateGlobalEnvPolicy(e,t,n,r){let o=e.replace(/^~/,ie__default.homedir()),i=await this.readConfig(o,r);if(Object.keys(i).length===0)return;let a=JSON.stringify(i);this.addToEnvPolicyWhitelist(i,t,n);let l=JSON.stringify(i);a!==l&&await this.writeConfig(o,i,r);}};});function Ut(s){return `name: Constellation Index
145
+ `);}deepMerge(e,t){let n={...e};for(let r of Object.keys(t)){let o=t[r],i=e[r];o&&typeof o=="object"&&!Array.isArray(o)&&i&&typeof i=="object"&&!Array.isArray(i)?n[r]=this.deepMerge(i,o):n[r]=o;}return n}addPluginToArray(e,t){let n=e;for(let i=0;i<t.pluginKeyPath.length-1;i++){let a=t.pluginKeyPath[i];(!n[a]||typeof n[a]!="object")&&(n[a]={}),n=n[a];}let r=t.pluginKeyPath[t.pluginKeyPath.length-1];Array.isArray(n[r])||(n[r]=[]);let o=n[r];return o.includes(t.pluginValue)||o.push(t.pluginValue),e}async configureEnvPolicy(e,t){if(!t.envPolicyConfig)return;let{includeOnlyKeyPath:n,envVarsToAllow:r,globalConfigPath:o}=t.envPolicyConfig;this.addToEnvPolicyWhitelist(e,n,r),o&&await this.updateGlobalEnvPolicy(o,n,r,t.format);}addToEnvPolicyWhitelist(e,t,n){let r=e;for(let a=0;a<t.length-1;a++){let c=t[a];if(!r[c]||typeof r[c]!="object")return;r=r[c];}let o=t[t.length-1];if(!Array.isArray(r[o]))return;let i=r[o];for(let a of n)i.includes(a)||i.push(a);}async updateGlobalEnvPolicy(e,t,n,r){let o=e.replace(/^~/,ie__default.homedir()),i=await this.readConfig(o,r);if(Object.keys(i).length===0)return;let a=JSON.stringify(i);this.addToEnvPolicyWhitelist(i,t,n);let c=JSON.stringify(i);a!==c&&await this.writeConfig(o,i,r);}};});function Ht(s){return `name: Constellation Index
146
146
 
147
147
  on:
148
148
  push:
@@ -160,7 +160,7 @@ jobs:
160
160
  - uses: ShiftinBits/constellation-github@v1
161
161
  with:
162
162
  access-key: \${{ secrets.CONSTELLATION_ACCESS_KEY }}
163
- `}function Gt(s){return {includeEntry:{component:"gitlab.com/shiftinbits/constellation-gitlab/constellation-index@1",inputs:{access_key:"$CONSTELLATION_ACCESS_KEY"}},job:{rules:[{if:`$CI_COMMIT_BRANCH == "${s}"`}]}}}function et(s){return `include:
163
+ `}function Ut(s){return {includeEntry:{component:"gitlab.com/shiftinbits/constellation-gitlab/constellation-index@1",inputs:{access_key:"$CONSTELLATION_ACCESS_KEY"}},job:{rules:[{if:`$CI_COMMIT_BRANCH == "${s}"`}]}}}function Qe(s){return `include:
164
164
  - component: gitlab.com/shiftinbits/constellation-gitlab/constellation-index@1
165
165
  inputs:
166
166
  access_key: $CONSTELLATION_ACCESS_KEY
@@ -168,26 +168,26 @@ jobs:
168
168
  constellation-index:
169
169
  rules:
170
170
  - if: $CI_COMMIT_BRANCH == "${s}"
171
- `}var Wt=m(()=>{});var ve,br=m(()=>{F();Wt();ve=class{constructor(e){this.gitRoot=e;}async detectPlatforms(){let e=[],[t,n]=await Promise.all([h.directoryExists(v__default.join(this.gitRoot,".github","workflows")),h.fileIsReadable(v__default.join(this.gitRoot,".gitlab-ci.yml"))]);return t&&e.push("github"),n&&e.push("gitlab"),e}async githubWorkflowExists(){return h.fileIsReadable(v__default.join(this.gitRoot,".github","workflows","constellation-index.yml"))}async gitlabJobExists(){let e=v__default.join(this.gitRoot,".gitlab-ci.yml");if(!await h.fileIsReadable(e))return false;try{let n=await h.readFile(e),o=parseDocument(n).contents;return isMap(o)&&o.has("constellation-index")}catch{return false}}async createGitHubWorkflow(e){let t=v__default.join(this.gitRoot,".github","workflows");await N__default.mkdir(t,{recursive:true});let n=v__default.join(t,"constellation-index.yml");return await h.writeFile(n,Ut(e)),n}async createOrMergeGitLabCI(e){let t=v__default.join(this.gitRoot,".gitlab-ci.yml");if(!await h.fileIsReadable(t))return await h.writeFile(t,et(e)),t;let r=await h.readFile(t),o=parseDocument(r);if(!isMap(o.contents))return await h.writeFile(t,et(e)),t;let{includeEntry:i,job:a}=Gt(e);return this.mergeIncludeEntry(o,i),o.set("constellation-index",a),await h.writeFile(t,o.toString()),t}mergeIncludeEntry(e,t){let n=e.get("include");if(!n){e.set("include",[t]);return}if(isSeq(n)){let r=n.items.filter(o=>{if(isMap(o)){let i=o.get("component");return typeof i!="string"||!i.includes("constellation-gitlab")}return true});n.items=r,n.items.push(e.createNode(t));return}e.set("include",[n,t]);}};});var xr=m(()=>{br();Wt();});function oe(s,e){let t=v__default.normalize(s),n=v__default.normalize(e);return t.startsWith(n+v__default.sep)?v__default.relative(e,s):s}var re,Pe,Er=m(()=>{sr();Ot();vr();Bt();F();k();xr();Le();({prompt:re}=Sr);Pe=class extends U{async run(e={}){try{if(console.log(`${D}Initializing project configuration...
172
- `),!await this.git.isGitAvailable())throw new Error(`${w} Could not find git client installation.
173
- ${y} Constellation requires git, please install git and try again (https://git-scm.com/downloads).`);let n=v__default.join(process.cwd(),"constellation.json"),r=null,o=await h.fileIsReadable(n);if(o)try{let S=await h.readFile(n);r=JSON.parse(S),console.log(`${y} Found existing constellation.json, current values will be used as defaults.
174
- `);}catch{console.log(`${w} Existing constellation.json is invalid, starting fresh.
175
- `);}if(!await this.git.isGitRepository())throw new Error(`${w} Current directory is not a git repository.
176
- ${y} Please run this command from the root directory of a git repository.`);let a=await this.git.getRootDir(),[l,g]=await Promise.all([this.git.status(),this.git.listBranches()]),{currentBranch:d}=l,p=g.filter(S=>S!==d),u=d?[d,...p]:p,f=this.getBranchInitialIndex(u,r?.branch),b=this.getInitialLanguages(r),_=[{message:"Constellation Project ID:",name:"projectId",type:"input",initial:r?.projectId??"",validate:S=>S.trim().length>0||"Project ID is required"},{choices:u,initial:f,limit:10,maxChoices:1,message:"Branch to index:",name:"branch",scroll:!0,type:"select"},{type:"multiselect",name:"languages",multiple:!0,message:"Select Language(s):",choices:this.buildLanguageChoices(r),initial:b,result(S){return S.map(O=>this.choices.find(ct=>ct.name===O)?.value??O)}}],x=await new Sr().prompt(_),ke={projectId:x.projectId.trim(),branch:x.branch,languages:{...x.languages.reduce((S,O)=>(S[O]={fileExtensions:_e[O]||[]},S),{})}},ce=JSON.stringify(ke,void 0,2);await h.writeFile(n,ce),console.log(`${C} ${o?"Updated":"Initialized"} configuration file at ${oe(n,process.cwd())}`),await this.git.stageFile(n),console.log(`${C} Added constellation.json to staged changes in git`),e.skipMcp||await this.configureMCPServers(),!e.skipCi&&a&&await this.configureCICD(x.branch,a);}catch(t){if(t==="")return;let n=t.message??"An unexpected error occurred";console.error(`${P} Failed to initialize configuration file.
177
- ${n}`);}}async configureMCPServers(){let{configureMcp:e}=await re({type:"confirm",name:"configureMcp",message:"Automatically configure Constellation for AI coding assistants?",initial:true});if(!e)return;let t=Mt.map(p=>({name:p.displayName,value:p.id})),{selectedTools:n}=await re({type:"multiselect",name:"selectedTools",message:"Select AI coding assistants to configure:",choices:t,result(p){return p.map(u=>this.choices.find(b=>b.name===u)?.value??u)}});if(n.length===0){console.log(`${y} No tools selected, skipping MCP configuration`);return}let r=new Qe(process.cwd()),o=[];for(let p of n){let u=Dt(p);if(u)if(console.log(` ${y} Configuring ${u.displayName}...`),u.isGlobalConfig&&u.getGlobalConfigPaths){let f=await r.configureGlobalTool(u),b=false;for(let _ of f)o.push(_),_.success?(b=true,console.log(` ${C} ${_.tool.displayName} configured at ${oe(_.configuredPath,process.cwd())}`)):_.error&&console.log(` ${w} ${_.tool.displayName}: ${_.error}`);if(b){let _=u.id==="cline"?"global VS Code settings":"global settings";console.log(` ${y} Note: ${u.displayName} uses ${_} (not project-level)`);}if(f.length===0){let _=u.id==="cline"?"No VS Code installations found":"Configuration directory not found";console.log(` ${w} ${u.displayName}: ${_}`);}}else {let f=await r.configureTool(u);o.push(f),f.success?(console.log(` ${C} ${u.displayName} configured at ${oe(f.configuredPath,process.cwd())}`),u.permissionsConfig&&console.log(` ${C} ${u.displayName} permissions set in ${u.permissionsConfig.filePath}`)):console.log(` ${w} ${u.displayName}: ${f.error}`);}}if(o.find(p=>p.tool.id==="claude-code"&&p.success)){let p=v__default.join(process.cwd(),".claude/settings.json");try{await this.git.stageFile(p),console.log(` ${C} Added .claude/settings.json to staged changes in git`);}catch{console.log(` ${w} Could not stage .claude/settings.json in git`);}}if(o.find(p=>p.tool.id==="codex-cli"&&p.success)){let p=v__default.join(process.cwd(),".codex/config.toml");try{await this.git.stageFile(p),console.log(` ${C} Added .codex/config.toml to staged changes in git`);}catch{}}if(o.find(p=>p.tool.id==="opencode"&&p.success)){let p=v__default.join(process.cwd(),"opencode.jsonc");try{await this.git.stageFile(p),console.log(` ${C} Added opencode.jsonc to staged changes in git`);}catch{}}let g=o.filter(p=>p.success).length,d=o.filter(p=>!p.success).length;console.log(`
178
- ${C} MCP configuration complete: ${g} configured`),d>0&&console.log(`${w} ${d} tool(s) could not be configured`),await this.configureHooks(n,o),console.log(`
179
- ${y} Some tools may require restart to pick up new configuration.`);}async configureHooks(e,t){let n=new we(process.cwd()),r=It(),o=e.map(l=>Dt(l)).filter(l=>l!==void 0&&l.hooksConfig!==void 0&&t.some(g=>g.tool.id===l.id&&g.success));if(o.length===0)return;console.log(`
180
- ${y} Configuring AI hooks...`);let i=[];for(let l of o){let g=await n.configureHooks(l,r);if(i.push(g),g.success){let d=g.configuredPath?[g.configuredPath]:g.auxiliaryPaths??[];if(d.length>0){let p=g.configuredPath?oe(g.configuredPath,process.cwd()):v__default.dirname(d[0]);console.log(` ${C} ${l.displayName} hooks configured at ${p}`);for(let u of d){let f=v__default.isAbsolute(u)?oe(u,process.cwd()):u;try{await this.git.stageFile(u),console.log(` ${C} Added ${f} to staged changes in git`);}catch{console.log(` ${w} Could not stage ${f} in git`);}}}else console.log(` ${C} ${l.displayName} hooks configured`);}else console.log(` ${w} ${l.displayName}: ${g.error}`);}let a=i.filter(l=>l.success).length;a>0&&console.log(`${C} Hooks configuration complete: ${a} configured`);}async configureCICD(e,t){let{setupCicd:n}=await re({type:"confirm",name:"setupCicd",message:"Set up a CI/CD pipeline to automatically index your project?",initial:true});if(!n)return;let r=new ve(t),o=await r.detectPlatforms(),i;if(o.length===1){let d=o[0]==="github"?"GitHub Actions":"GitLab CI",{useDetected:p}=await re({type:"confirm",name:"useDetected",message:`Detected ${d}. Configure Constellation CI/CD for this platform?`,initial:true});if(!p)return;i=o[0];}else {let d=[{name:"GitHub Actions",value:"github"},{name:"GitLab CI",value:"gitlab"}],{platform:p}=await re({type:"select",name:"platform",message:"Select CI/CD platform:",choices:d,result(u){let f=Array.isArray(u)?u[0]:u;return this.choices.find(_=>_.name===f)?.value??f}});i=p;}let a=i==="github"?await r.githubWorkflowExists():await r.gitlabJobExists();if(a){let{overwrite:d}=await re({type:"confirm",name:"overwrite",message:"Constellation CI/CD configuration already exists. Overwrite?",initial:false});if(!d){console.log(`${y} Skipping CI/CD configuration`);return}}let l;try{l=i==="github"?await r.createGitHubWorkflow(e):await r.createOrMergeGitLabCI(e);}catch(d){console.log(`${w} Failed to configure CI/CD pipeline: ${d.message}`);return}let g=oe(l,process.cwd());console.log(i==="github"?`${C} Created ${g}`:`${C} ${a?"Updated":"Created"} ${g} with Constellation indexing`);try{await this.git.stageFile(l),console.log(`${C} Added ${g} to staged changes in git`);}catch{console.log(`${w} Could not stage ${g} in git`);}i==="github"?(console.log(`${y} Add your access key as a repository secret:`),console.log(" Settings \u2192 Secrets and variables \u2192 Actions \u2192 New repository secret"),console.log(" Name: CONSTELLATION_ACCESS_KEY")):(console.log(`${y} Add your access key as a CI/CD variable:`),console.log(" Settings \u2192 CI/CD \u2192 Variables \u2192 Add variable"),console.log(" Key: CONSTELLATION_ACCESS_KEY"));}buildLanguageChoices(e){return [{name:"JavaScript",value:"javascript"},{name:"Python",value:"python"},{name:"TypeScript",value:"typescript"}]}getInitialLanguages(e){if(!e?.languages)return [];let t={c:"C","c-sharp":"C#",cpp:"C++",go:"Go",json:"JSON",java:"Java",javascript:"JavaScript",php:"PHP",python:"Python",ruby:"Ruby",bash:"Shell (Bash)",typescript:"TypeScript"};return Object.keys(e.languages).filter(n=>e.languages[n]!==void 0).map(n=>t[n]).filter(n=>n!==void 0)}getBranchInitialIndex(e,t){if(t){let n=e.indexOf(t);if(n!==-1)return n}return 0}};});var tt,Ir=m(()=>{F();k();tt=class s{constructor(e,t,n,r){this.branch=e;this.languages=t;this.projectId=n;this.exclude=r;this.apiUrl=process.env.CONSTELLATION_API_URL||"https://api.constellationdev.io";}apiUrl;static async loadFromFile(e){if(await h.fileIsReadable(e)){let n=await h.readFile(e),r=JSON.parse(n),o=new s(r.branch,r.languages,r.projectId,r.exclude);return o.validate(),o}else throw new Error(`${P} Unable to find constellation config at ${e}`)}validate(){if(!this.apiUrl)throw new Error("Invalid configuration: apiUrl is missing");if(!this.branch)throw new Error("Invalid configuration: branch is missing");if(!this.languages||Object.keys(this.languages).length===0)throw new Error("Invalid configuration: no languages configured");if(!this.projectId)throw new Error("Invalid configuration: projectId is missing");try{new URL(this.apiUrl);}catch{throw new Error(`Invalid configuration: apiUrl "${this.apiUrl}" is not a valid URL`)}for(let[e,t]of Object.entries(this.languages)){if(!t.fileExtensions||t.fileExtensions.length===0)throw new Error(`Invalid configuration: language "${e}" has no file extensions`);for(let n of t.fileExtensions)if(!n.startsWith("."))throw new Error(`Invalid configuration: file extension "${n}" for language "${e}" must start with a dot`)}if(this.exclude&&this.exclude.length>0){if(!Array.isArray(this.exclude))throw new Error("Invalid configuration: exclude must be an array of strings");for(let e of this.exclude)if(typeof e!="string")throw new Error("Invalid configuration: exclude patterns must be strings")}}validateBranch(e){if(!e)throw new Error("Not on a Git branch (detached HEAD state)");if(this.branch!==e)throw new Error(`Current branch "${e}" does not match configured branch "${this.branch}". Update constellation.json or switch to "${this.branch}" branch.`)}};});var nt,Vt,Jt,Yt,rt,kr=m(()=>{F();nt=class{getVariable(e){return Promise.resolve(process.env[e])}getSourceFile(){}isCIEnvironment(){return this.isCI()}isCI(){return !!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.JENKINS_URL||process.env.CIRCLECI||process.env.TRAVIS||process.env.BUILDKITE||process.env.DRONE||process.env.TF_BUILD||process.env.BITBUCKET_BUILD_NUMBER||process.env.TEAMCITY_VERSION||process.env.CODEBUILD_BUILD_ID)}validateInput(e,t){if(!e||typeof e!="string")throw new Error("Invalid key provided");if(t==null)throw new Error("Invalid value provided");if(!/^[A-Z_][A-Z0-9_]*$/i.test(e))throw new Error("Environment variable name must contain only letters, numbers, and underscores");if(t.includes("\0"))throw new Error("Value contains invalid characters");if(t.includes(`
181
- `)||t.includes("\r"))throw new Error("Value cannot contain newline characters")}escapeShellValue(e){return e.replace(/[\\'\"$`]/g,"\\$&")}},Vt=class extends nt{async getVariable(e){try{let t=await this.queryRegistry("HKCU\\Environment",e);if(t)return process.env[e]=t,t;delete process.env[e];return}catch{return}}async setVariable(e,t){if(this.validateInput(e,t),this.isCI())throw new Error(`Cannot set environment variables in CI/CD environments.
182
- Configure CONSTELLATION_ACCESS_KEY directly in your pipeline settings.`);try{await new Promise((n,r)=>{let o=spawn("setx",[e,t],{shell:!1,windowsHide:!0}),i="";o.stderr?.on("data",a=>{i+=a.toString();}),o.on("close",a=>{a===0?n():r(new Error(`setx failed with code ${a}: ${i}`));}),o.on("error",a=>{r(a);});}),process.env[e]=t;}catch(n){throw new Error(`Failed to set environment variable ${e}: ${n}`)}}async queryRegistry(e,t){try{let r=(await new Promise((o,i)=>{let a=spawn("reg",["query",e,"/v",t],{shell:!1,windowsHide:!0}),l="",g="";a.stdout?.on("data",d=>{l+=d.toString();}),a.stderr?.on("data",d=>{g+=d.toString();}),a.on("close",d=>{d===0?o(l):i(new Error(`reg query failed: ${g}`));}),a.on("error",d=>{i(d);});})).match(/REG_(?:SZ|EXPAND_SZ)\s+(.+?)(?:\r?\n|$)/);return r?r[1].trim():void 0}catch{return}}},Jt=class extends nt{userConfigFiles;constructor(){super(),this.userConfigFiles=[v.join(ie.homedir(),".zshenv"),v.join(ie.homedir(),".profile")];}getSourceFile(){let e=process.env.SHELL??"";return e.endsWith("/zsh")||e.endsWith("/zsh5")?this.userConfigFiles.find(t=>t.endsWith(".zshenv")):this.userConfigFiles.find(t=>t.endsWith(".profile"))}async setVariable(e,t){if(this.validateInput(e,t),this.isCI())throw new Error(`Cannot set environment variables in CI/CD environments.
171
+ `}var Gt=m(()=>{});var ve,Pr=m(()=>{F();Gt();ve=class{constructor(e){this.gitRoot=e;}async detectPlatforms(){let e=[],[t,n]=await Promise.all([h.directoryExists(v__default.join(this.gitRoot,".github","workflows")),h.fileIsReadable(v__default.join(this.gitRoot,".gitlab-ci.yml"))]);return t&&e.push("github"),n&&e.push("gitlab"),e}async githubWorkflowExists(){return h.fileIsReadable(v__default.join(this.gitRoot,".github","workflows","constellation-index.yml"))}async gitlabJobExists(){let e=v__default.join(this.gitRoot,".gitlab-ci.yml");if(!await h.fileIsReadable(e))return false;try{let n=await h.readFile(e),o=parseDocument(n).contents;return isMap(o)&&o.has("constellation-index")}catch{return false}}async createGitHubWorkflow(e){let t=v__default.join(this.gitRoot,".github","workflows");await N__default.mkdir(t,{recursive:true});let n=v__default.join(t,"constellation-index.yml");return await h.writeFile(n,Ht(e)),n}async createOrMergeGitLabCI(e){let t=v__default.join(this.gitRoot,".gitlab-ci.yml");if(!await h.fileIsReadable(t))return await h.writeFile(t,Qe(e)),t;let r=await h.readFile(t),o=parseDocument(r);if(!isMap(o.contents))return await h.writeFile(t,Qe(e)),t;let{includeEntry:i,job:a}=Ut(e);return this.mergeIncludeEntry(o,i),o.set("constellation-index",a),await h.writeFile(t,o.toString()),t}mergeIncludeEntry(e,t){let n=e.get("include");if(!n){e.set("include",[t]);return}if(isSeq(n)){let r=n.items.filter(o=>{if(isMap(o)){let i=o.get("component");return typeof i!="string"||!i.includes("constellation-gitlab")}return true});n.items=r,n.items.push(e.createNode(t));return}e.set("include",[n,t]);}};});var br=m(()=>{Pr();Gt();});function oe(s,e){let t=v__default.normalize(s),n=v__default.normalize(e);return t.startsWith(n+v__default.sep)?v__default.relative(e,s):s}var re,Pe,xr=m(()=>{ir();Lt();_r();Dt();F();k();br();Le();({prompt:re}=Sr);Pe=class extends U{async run(e={}){try{if(console.log(`${D}Initializing project configuration...
172
+ `),!await this.git.isGitAvailable())throw new Error(`${C} Could not find git client installation.
173
+ ${y} Constellation requires git, please install git and try again (https://git-scm.com/downloads).`);let n=v__default.join(process.cwd(),"constellation.json"),r=null,o=await h.fileIsReadable(n);if(o)try{let x=await h.readFile(n);r=JSON.parse(x),console.log(`${y} Found existing constellation.json, current values will be used as defaults.
174
+ `);}catch{console.log(`${C} Existing constellation.json is invalid, starting fresh.
175
+ `);}if(!await this.git.isGitRepository())throw new Error(`${C} Current directory is not a git repository.
176
+ ${y} Please run this command from the root directory of a git repository.`);let a=await this.git.getRootDir(),[c,g]=await Promise.all([this.git.status(),this.git.listBranches()]),{currentBranch:d}=c,p=g.filter(x=>x!==d),f=d?[d,...p]:p,u=this.getBranchInitialIndex(f,r?.branch),b=this.getInitialLanguages(r),_=[{message:"Constellation Project ID:",name:"projectId",type:"input",initial:r?.projectId??"",validate:x=>x.trim().length>0||"Project ID is required"},{choices:f,initial:u,limit:10,maxChoices:1,message:"Branch to index:",name:"branch",scroll:!0,type:"select"},{type:"multiselect",name:"languages",multiple:!0,message:"Select Language(s):",choices:this.buildLanguageChoices(r),initial:b,result(x){return x.map(O=>this.choices.find(at=>at.name===O)?.value??O)}}],S=await new Sr().prompt(_),ke={projectId:S.projectId.trim(),branch:S.branch,languages:{...S.languages.reduce((x,O)=>(x[O]={fileExtensions:_e[O]||[]},x),{})}},le=JSON.stringify(ke,void 0,2);await h.writeFile(n,le),console.log(`${w} ${o?"Updated":"Initialized"} configuration file at ${oe(n,process.cwd())}`),await this.git.stageFile(n),console.log(`${w} Added constellation.json to staged changes in git`),e.skipMcp||await this.configureMCPServers(),!e.skipCi&&a&&await this.configureCICD(S.branch,a);}catch(t){if(t==="")return;let n=t.message??"An unexpected error occurred";console.error(`${P} Failed to initialize configuration file.
177
+ ${n}`);}}async configureMCPServers(){let{configureMcp:e}=await re({type:"confirm",name:"configureMcp",message:"Automatically configure Constellation for AI coding assistants?",initial:true});if(!e)return;let t=Ft.map(p=>({name:p.displayName,value:p.id})),{selectedTools:n}=await re({type:"multiselect",name:"selectedTools",message:"Select AI coding assistants to configure:",choices:t,result(p){return p.map(f=>this.choices.find(b=>b.name===f)?.value??f)}});if(n.length===0){console.log(`${y} No tools selected, skipping MCP configuration`);return}let r=new Ze(process.cwd()),o=[];for(let p of n){let f=Mt(p);if(f)if(console.log(` ${y} Configuring ${f.displayName}...`),f.isGlobalConfig&&f.getGlobalConfigPaths){let u=await r.configureGlobalTool(f),b=false;for(let _ of u)o.push(_),_.success?(b=true,console.log(` ${w} ${_.tool.displayName} configured at ${oe(_.configuredPath,process.cwd())}`)):_.error&&console.log(` ${C} ${_.tool.displayName}: ${_.error}`);if(b){let _=f.id==="cline"?"global VS Code settings":"global settings";console.log(` ${y} Note: ${f.displayName} uses ${_} (not project-level)`);}if(u.length===0){let _=f.id==="cline"?"No VS Code installations found":"Configuration directory not found";console.log(` ${C} ${f.displayName}: ${_}`);}}else {let u=await r.configureTool(f);o.push(u),u.success?(console.log(` ${w} ${f.displayName} configured at ${oe(u.configuredPath,process.cwd())}`),f.permissionsConfig&&console.log(` ${w} ${f.displayName} permissions set in ${f.permissionsConfig.filePath}`)):console.log(` ${C} ${f.displayName}: ${u.error}`);}}if(o.find(p=>p.tool.id==="claude-code"&&p.success)){let p=v__default.join(process.cwd(),".claude/settings.json");try{await this.git.stageFile(p),console.log(` ${w} Added .claude/settings.json to staged changes in git`);}catch{console.log(` ${C} Could not stage .claude/settings.json in git`);}}if(o.find(p=>p.tool.id==="codex-cli"&&p.success)){let p=v__default.join(process.cwd(),".codex/config.toml");try{await this.git.stageFile(p),console.log(` ${w} Added .codex/config.toml to staged changes in git`);}catch{}}if(o.find(p=>p.tool.id==="opencode"&&p.success)){let p=v__default.join(process.cwd(),"opencode.jsonc");try{await this.git.stageFile(p),console.log(` ${w} Added opencode.jsonc to staged changes in git`);}catch{}}let g=o.filter(p=>p.success).length,d=o.filter(p=>!p.success).length;console.log(`
178
+ ${w} MCP configuration complete: ${g} configured`),d>0&&console.log(`${C} ${d} tool(s) could not be configured`),await this.configureHooks(n,o),console.log(`
179
+ ${y} Some tools may require restart to pick up new configuration.`);}async configureHooks(e,t){let n=new we(process.cwd()),r=Et(),o=e.map(c=>Mt(c)).filter(c=>c!==void 0&&c.hooksConfig!==void 0&&t.some(g=>g.tool.id===c.id&&g.success));if(o.length===0)return;console.log(`
180
+ ${y} Configuring AI hooks...`);let i=[];for(let c of o){let g=await n.configureHooks(c,r);if(i.push(g),g.success){let d=g.configuredPath?[g.configuredPath]:g.auxiliaryPaths??[];if(d.length>0){let p=g.configuredPath?oe(g.configuredPath,process.cwd()):v__default.dirname(d[0]);console.log(` ${w} ${c.displayName} hooks configured at ${p}`);for(let f of d){let u=v__default.isAbsolute(f)?oe(f,process.cwd()):f;try{await this.git.stageFile(f),console.log(` ${w} Added ${u} to staged changes in git`);}catch{console.log(` ${C} Could not stage ${u} in git`);}}}else console.log(` ${w} ${c.displayName} hooks configured`);}else console.log(` ${C} ${c.displayName}: ${g.error}`);}let a=i.filter(c=>c.success).length;a>0&&console.log(`${w} Hooks configuration complete: ${a} configured`);}async configureCICD(e,t){let{setupCicd:n}=await re({type:"confirm",name:"setupCicd",message:"Set up a CI/CD pipeline to automatically index your project?",initial:true});if(!n)return;let r=new ve(t),o=await r.detectPlatforms(),i;if(o.length===1){let d=o[0]==="github"?"GitHub Actions":"GitLab CI",{useDetected:p}=await re({type:"confirm",name:"useDetected",message:`Detected ${d}. Configure Constellation CI/CD for this platform?`,initial:true});if(!p)return;i=o[0];}else {let d=[{name:"GitHub Actions",value:"github"},{name:"GitLab CI",value:"gitlab"}],{platform:p}=await re({type:"select",name:"platform",message:"Select CI/CD platform:",choices:d,result(f){let u=Array.isArray(f)?f[0]:f;return this.choices.find(_=>_.name===u)?.value??u}});i=p;}let a=i==="github"?await r.githubWorkflowExists():await r.gitlabJobExists();if(a){let{overwrite:d}=await re({type:"confirm",name:"overwrite",message:"Constellation CI/CD configuration already exists. Overwrite?",initial:false});if(!d){console.log(`${y} Skipping CI/CD configuration`);return}}let c;try{c=i==="github"?await r.createGitHubWorkflow(e):await r.createOrMergeGitLabCI(e);}catch(d){console.log(`${C} Failed to configure CI/CD pipeline: ${d.message}`);return}let g=oe(c,process.cwd());console.log(i==="github"?`${w} Created ${g}`:`${w} ${a?"Updated":"Created"} ${g} with Constellation indexing`);try{await this.git.stageFile(c),console.log(`${w} Added ${g} to staged changes in git`);}catch{console.log(`${C} Could not stage ${g} in git`);}i==="github"?(console.log(`${y} Add your access key as a repository secret:`),console.log(" Settings \u2192 Secrets and variables \u2192 Actions \u2192 New repository secret"),console.log(" Name: CONSTELLATION_ACCESS_KEY")):(console.log(`${y} Add your access key as a CI/CD variable:`),console.log(" Settings \u2192 CI/CD \u2192 Variables \u2192 Add variable"),console.log(" Key: CONSTELLATION_ACCESS_KEY"));}buildLanguageChoices(e){return [{name:"JavaScript",value:"javascript"},{name:"Python",value:"python"},{name:"TypeScript",value:"typescript"}]}getInitialLanguages(e){if(!e?.languages)return [];let t={c:"C","c-sharp":"C#",cpp:"C++",go:"Go",json:"JSON",java:"Java",javascript:"JavaScript",php:"PHP",python:"Python",ruby:"Ruby",bash:"Shell (Bash)",typescript:"TypeScript"};return Object.keys(e.languages).filter(n=>e.languages[n]!==void 0).map(n=>t[n]).filter(n=>n!==void 0)}getBranchInitialIndex(e,t){if(t){let n=e.indexOf(t);if(n!==-1)return n}return 0}};});var et,Er=m(()=>{F();k();et=class s{constructor(e,t,n,r){this.branch=e;this.languages=t;this.projectId=n;this.exclude=r;this.apiUrl=process.env.CONSTELLATION_API_URL||"https://api.constellationdev.io";}apiUrl;static async loadFromFile(e){if(await h.fileIsReadable(e)){let n=await h.readFile(e),r=JSON.parse(n),o=new s(r.branch,r.languages,r.projectId,r.exclude);return o.validate(),o}else throw new Error(`${P} Unable to find constellation config at ${e}`)}validate(){if(!this.apiUrl)throw new Error("Invalid configuration: apiUrl is missing");if(!this.branch)throw new Error("Invalid configuration: branch is missing");if(!this.languages||Object.keys(this.languages).length===0)throw new Error("Invalid configuration: no languages configured");if(!this.projectId)throw new Error("Invalid configuration: projectId is missing");try{new URL(this.apiUrl);}catch{throw new Error(`Invalid configuration: apiUrl "${this.apiUrl}" is not a valid URL`)}for(let[e,t]of Object.entries(this.languages)){if(!t.fileExtensions||t.fileExtensions.length===0)throw new Error(`Invalid configuration: language "${e}" has no file extensions`);for(let n of t.fileExtensions)if(!n.startsWith("."))throw new Error(`Invalid configuration: file extension "${n}" for language "${e}" must start with a dot`)}if(this.exclude&&this.exclude.length>0){if(!Array.isArray(this.exclude))throw new Error("Invalid configuration: exclude must be an array of strings");for(let e of this.exclude)if(typeof e!="string")throw new Error("Invalid configuration: exclude patterns must be strings")}}validateBranch(e){if(!e)throw new Error("Not on a Git branch (detached HEAD state)");if(this.branch!==e)throw new Error(`Current branch "${e}" does not match configured branch "${this.branch}". Update constellation.json or switch to "${this.branch}" branch.`)}};});var tt,Kt,Vt,Jt,nt,$r=m(()=>{F();tt=class{getVariable(e){return Promise.resolve(process.env[e])}getSourceFile(){}isCIEnvironment(){return this.isCI()}isCI(){return !!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.GITLAB_CI||process.env.JENKINS_URL||process.env.CIRCLECI||process.env.TRAVIS||process.env.BUILDKITE||process.env.DRONE||process.env.TF_BUILD||process.env.BITBUCKET_BUILD_NUMBER||process.env.TEAMCITY_VERSION||process.env.CODEBUILD_BUILD_ID)}validateInput(e,t){if(!e||typeof e!="string")throw new Error("Invalid key provided");if(t==null)throw new Error("Invalid value provided");if(!/^[A-Z_][A-Z0-9_]*$/i.test(e))throw new Error("Environment variable name must contain only letters, numbers, and underscores");if(t.includes("\0"))throw new Error("Value contains invalid characters");if(t.includes(`
181
+ `)||t.includes("\r"))throw new Error("Value cannot contain newline characters")}escapeShellValue(e){return e.replace(/[\\'\"$`]/g,"\\$&")}},Kt=class extends tt{async getVariable(e){try{let t=await this.queryRegistry("HKCU\\Environment",e);if(t)return process.env[e]=t,t;delete process.env[e];return}catch{return}}async setVariable(e,t){if(this.validateInput(e,t),this.isCI())throw new Error(`Cannot set environment variables in CI/CD environments.
182
+ Configure CONSTELLATION_ACCESS_KEY directly in your pipeline settings.`);try{await new Promise((n,r)=>{let o=spawn("setx",[e,t],{shell:!1,windowsHide:!0}),i="";o.stderr?.on("data",a=>{i+=a.toString();}),o.on("close",a=>{a===0?n():r(new Error(`setx failed with code ${a}: ${i}`));}),o.on("error",a=>{r(a);});}),process.env[e]=t;}catch(n){throw new Error(`Failed to set environment variable ${e}: ${n}`)}}async queryRegistry(e,t){try{let r=(await new Promise((o,i)=>{let a=spawn("reg",["query",e,"/v",t],{shell:!1,windowsHide:!0}),c="",g="";a.stdout?.on("data",d=>{c+=d.toString();}),a.stderr?.on("data",d=>{g+=d.toString();}),a.on("close",d=>{d===0?o(c):i(new Error(`reg query failed: ${g}`));}),a.on("error",d=>{i(d);});})).match(/REG_(?:SZ|EXPAND_SZ)\s+(.+?)(?:\r?\n|$)/);return r?r[1].trim():void 0}catch{return}}},Vt=class extends tt{userConfigFiles;constructor(){super(),this.userConfigFiles=[v.join(ie.homedir(),".zshenv"),v.join(ie.homedir(),".profile")];}getSourceFile(){let e=process.env.SHELL??"";return e.endsWith("/zsh")||e.endsWith("/zsh5")?this.userConfigFiles.find(t=>t.endsWith(".zshenv")):this.userConfigFiles.find(t=>t.endsWith(".profile"))}async setVariable(e,t){if(this.validateInput(e,t),this.isCI())throw new Error(`Cannot set environment variables in CI/CD environments.
183
183
  Configure CONSTELLATION_ACCESS_KEY directly in your pipeline settings.`);let n=this.escapeShellValue(t),r=`export ${e}="${n}"`;try{for(let o of this.userConfigFiles)await this.writeToConfigFile(o,e,r);process.env[e]=t;}catch(o){throw new Error(`Failed to set environment variable ${e}: ${o}`)}}async writeToConfigFile(e,t,n){let r="";try{r=await h.readFile(e,"utf-8");}catch{}let o=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`^export ${o}=.*$`,"gm");i.test(r)?r=r.replace(i,n):r=r.trimEnd()+`
184
184
  `+n+`
185
- `,await h.writeFile(e,r);}},Yt=class{static create(){let e=ie.platform();switch(e){case "win32":return new Vt;case "darwin":case "linux":return new Jt;default:throw new Error(`Unsupported platform: ${e}`)}}},rt=class{manager;constructor(){this.manager=Yt.create();}async setKey(e,t){await this.manager.setVariable(e.toUpperCase(),t);}async getKey(e){return this.manager.getVariable(e.toUpperCase())}isCI(){return this.manager.isCIEnvironment()}getSourceFile(){return this.manager.getSourceFile()}};});var ot,Tr=m(()=>{ot=class{extensionToLanguageMap;constructor(e){this.extensionToLanguageMap=new Map;for(let[t,n]of Object.entries(e.languages))for(let r of n.fileExtensions)this.extensionToLanguageMap.set(r,t);}detectLanguage(e){let t=v__default.extname(e).toLowerCase();return this.extensionToLanguageMap.get(t)||null}};});function Vo(){let s=ie.platform();if(s==="darwin")return v.join(ie.homedir(),"Library","Caches","constellation");if(s==="win32"){let e=process.env.LOCALAPPDATA||v.join(ie.homedir(),"AppData","Local");return v.join(e,"constellation","cache")}else {let e=process.env.XDG_CACHE_HOME||v.join(ie.homedir(),".cache");return v.join(e,"constellation")}}var Jo,Yo,qo,xe,qt=m(()=>{Jo=Vo(),Yo="update-state.json",qo=1440*60*1e3,xe=class{state=null;stateDir;stateFile;constructor(e){this.stateDir=e??Jo,this.stateFile=v.join(this.stateDir,Yo);}async load(){if(this.state)return this.state;try{let e=await N.readFile(this.stateFile,"utf-8");return this.state=JSON.parse(e),this.state}catch{return {lastCheckTimestamp:0}}}async save(e){try{await N.mkdir(this.stateDir,{recursive:!0}),await N.writeFile(this.stateFile,JSON.stringify(e,null,2)),this.state=e;}catch{}}async shouldCheck(){let e=await this.load();return Date.now()-e.lastCheckTimestamp>qo}async recordCheck(){let e=await this.load();e.lastCheckTimestamp=Date.now(),await this.save(e);}async recordDecline(e){let t=await this.load();t.lastDeclinedVersion=e,t.lastDeclinedTimestamp=Date.now(),await this.save(t);}async wasVersionDeclined(e){return (await this.load()).lastDeclinedVersion===e}async clear(){try{await N.unlink(this.stateFile),this.state=null;}catch{}}};});var Se,Xt=m(()=>{Se=class{detectedManager=null;detect(){if(this.detectedManager)return this.detectedManager;let e=process.env.npm_config_user_agent;return e?e.startsWith("yarn")?this.detectedManager="yarn":e.startsWith("pnpm")?this.detectedManager="pnpm":e.startsWith("bun")?this.detectedManager="bun":this.detectedManager="npm":this.detectedManager="npm",this.detectedManager}getUpdateCommand(e){switch(this.detect()){case "yarn":return ["yarn","global","add",`${e}@latest`];case "pnpm":return ["pnpm","add","-g",`${e}@latest`];case "bun":return ["bun","add","-g",`${e}@latest`];default:return ["npm","install","-g",`${e}@latest`]}}getUpdateCommandString(e){return this.getUpdateCommand(e).join(" ")}async executeUpdate(e){let[t,...n]=this.getUpdateCommand(e);return new Promise(r=>{let o=spawn(t,n,{stdio:"inherit",shell:process.platform==="win32"});o.on("close",i=>{r(i===0);}),o.on("error",()=>{r(false);});})}};});var Qo,Ee,Zt=m(()=>{k();(({prompt:Qo}=Sr)),Ee=class{async promptForUpdate(e,t,n){console.log(""),console.log(c.cyan("\u2501".repeat(60))),console.log(`${D} ${c.bold("Update Available!")}`),console.log(""),console.log(` Current version: ${c.dim(e)}`),console.log(` Latest version: ${c.green.bold(t)}`),console.log(""),console.log(` ${c.dim(`Package manager: ${n}`)}`),console.log(c.cyan("\u2501".repeat(60))),console.log("");try{let{shouldUpdate:r}=await Qo({type:"confirm",name:"shouldUpdate",message:"Would you like to update now?",initial:!0});return r}catch{return false}}};});async function Qt(s){return new st().check(s)}var ei,it,ti,st,Nr=m(()=>{k();qt();Xt();Zt();ei="https://registry.npmjs.org",it="@constellationdev/cli",ti=5e3,st=class{cache;packageManager;prompter;constructor(){this.cache=new xe,this.packageManager=new Se,this.prompter=new Ee;}async check(e){if(!await this.cache.shouldCheck())return false;try{let t=await this.fetchLatestVersion(e);return await this.cache.recordCheck(),!t.hasUpdate||await this.cache.wasVersionDeclined(t.latest)?!1:await this.prompter.promptForUpdate(t.current,t.latest,this.packageManager.detect())?await this.performUpdate():(await this.cache.recordDecline(t.latest),!1)}catch{return false}}async fetchLatestVersion(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ti);try{let r=await fetch(`${ei}/${it}/latest`,{signal:t.signal,headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Registry returned ${r.status}`);let i=(await r.json()).version;return {current:e,latest:i,hasUpdate:this.isNewerVersion(i,e)}}finally{clearTimeout(n);}}isNewerVersion(e,t){let n=i=>i.split("-")[0],r=n(e).split(".").map(Number),o=n(t).split(".").map(Number);for(let i=0;i<3;i++){let a=r[i]||0,l=o[i]||0;if(a>l)return true;if(a<l)return false}return false}async performUpdate(){return console.log(`
186
- ${y} Updating ${it}...
187
- `),await this.packageManager.executeUpdate(it)?(console.log(`
188
- ${C} Update complete! Please re-run your command.
185
+ `,await h.writeFile(e,r);}},Jt=class{static create(){let e=ie.platform();switch(e){case "win32":return new Kt;case "darwin":case "linux":return new Vt;default:throw new Error(`Unsupported platform: ${e}`)}}},nt=class{manager;constructor(){this.manager=Jt.create();}async setKey(e,t){await this.manager.setVariable(e.toUpperCase(),t);}async getKey(e){return this.manager.getVariable(e.toUpperCase())}isCI(){return this.manager.isCIEnvironment()}getSourceFile(){return this.manager.getSourceFile()}};});var rt,kr=m(()=>{rt=class{extensionToLanguageMap;constructor(e){this.extensionToLanguageMap=new Map;for(let[t,n]of Object.entries(e.languages))for(let r of n.fileExtensions)this.extensionToLanguageMap.set(r,t);}detectLanguage(e){let t=v__default.extname(e).toLowerCase();return this.extensionToLanguageMap.get(t)||null}};});function Jo(){let s=ie.platform();if(s==="darwin")return v.join(ie.homedir(),"Library","Caches","constellation");if(s==="win32"){let e=process.env.LOCALAPPDATA||v.join(ie.homedir(),"AppData","Local");return v.join(e,"constellation","cache")}else {let e=process.env.XDG_CACHE_HOME||v.join(ie.homedir(),".cache");return v.join(e,"constellation")}}var Yo,qo,Xo,Se,Yt=m(()=>{Yo=Jo(),qo="update-state.json",Xo=1440*60*1e3,Se=class{state=null;stateDir;stateFile;constructor(e){this.stateDir=e??Yo,this.stateFile=v.join(this.stateDir,qo);}async load(){if(this.state)return this.state;try{let e=await N.readFile(this.stateFile,"utf-8");return this.state=JSON.parse(e),this.state}catch{return {lastCheckTimestamp:0}}}async save(e){try{await N.mkdir(this.stateDir,{recursive:!0}),await N.writeFile(this.stateFile,JSON.stringify(e,null,2)),this.state=e;}catch{}}async shouldCheck(){let e=await this.load();return Date.now()-e.lastCheckTimestamp>Xo}async recordCheck(){let e=await this.load();e.lastCheckTimestamp=Date.now(),await this.save(e);}async recordDecline(e){let t=await this.load();t.lastDeclinedVersion=e,t.lastDeclinedTimestamp=Date.now(),await this.save(t);}async wasVersionDeclined(e){return (await this.load()).lastDeclinedVersion===e}async clear(){try{await N.unlink(this.stateFile),this.state=null;}catch{}}};});var xe,qt=m(()=>{xe=class{detectedManager=null;detect(){if(this.detectedManager)return this.detectedManager;let e=process.env.npm_config_user_agent;return e?e.startsWith("yarn")?this.detectedManager="yarn":e.startsWith("pnpm")?this.detectedManager="pnpm":e.startsWith("bun")?this.detectedManager="bun":this.detectedManager="npm":this.detectedManager="npm",this.detectedManager}getUpdateCommand(e){switch(this.detect()){case "yarn":return ["yarn","global","add",`${e}@latest`];case "pnpm":return ["pnpm","add","-g",`${e}@latest`];case "bun":return ["bun","add","-g",`${e}@latest`];default:return ["npm","install","-g",`${e}@latest`]}}getUpdateCommandString(e){return this.getUpdateCommand(e).join(" ")}async executeUpdate(e){let[t,...n]=this.getUpdateCommand(e);return new Promise(r=>{let o=spawn(t,n,{stdio:"inherit",shell:process.platform==="win32"});o.on("close",i=>{r(i===0);}),o.on("error",()=>{r(false);});})}};});var ei,Ee,Xt=m(()=>{k();(({prompt:ei}=Sr)),Ee=class{async promptForUpdate(e,t,n){console.log(""),console.log(l.cyan("\u2501".repeat(60))),console.log(`${D} ${l.bold("Update Available!")}`),console.log(""),console.log(` Current version: ${l.dim(e)}`),console.log(` Latest version: ${l.green.bold(t)}`),console.log(""),console.log(` ${l.dim(`Package manager: ${n}`)}`),console.log(l.cyan("\u2501".repeat(60))),console.log("");try{let{shouldUpdate:r}=await ei({type:"confirm",name:"shouldUpdate",message:"Would you like to update now?",initial:!0});return r}catch{return false}}};});async function Zt(s){return new it().check(s)}var ti,ot,ni,it,Tr=m(()=>{k();Yt();qt();Xt();ti="https://registry.npmjs.org",ot="@constellationdev/cli",ni=5e3,it=class{cache;packageManager;prompter;constructor(){this.cache=new Se,this.packageManager=new xe,this.prompter=new Ee;}async check(e){if(!await this.cache.shouldCheck())return false;try{let t=await this.fetchLatestVersion(e);return await this.cache.recordCheck(),!t.hasUpdate||await this.cache.wasVersionDeclined(t.latest)?!1:await this.prompter.promptForUpdate(t.current,t.latest,this.packageManager.detect())?await this.performUpdate():(await this.cache.recordDecline(t.latest),!1)}catch{return false}}async fetchLatestVersion(e){let t=new AbortController,n=setTimeout(()=>t.abort(),ni);try{let r=await fetch(`${ti}/${ot}/latest`,{signal:t.signal,headers:{Accept:"application/json"}});if(!r.ok)throw new Error(`Registry returned ${r.status}`);let i=(await r.json()).version;return {current:e,latest:i,hasUpdate:this.isNewerVersion(i,e)}}finally{clearTimeout(n);}}isNewerVersion(e,t){let n=i=>i.split("-")[0],r=n(e).split(".").map(Number),o=n(t).split(".").map(Number);for(let i=0;i<3;i++){let a=r[i]||0,c=o[i]||0;if(a>c)return true;if(a<c)return false}return false}async performUpdate(){return console.log(`
186
+ ${y} Updating ${ot}...
187
+ `),await this.packageManager.executeUpdate(ot)?(console.log(`
188
+ ${w} Update complete! Please re-run your command.
189
189
  `),true):(console.log(`
190
- ${w} Update failed. You can try updating manually:`),console.log(` ${this.packageManager.getUpdateCommandString(it)}
191
- `),false)}};});var Rr=m(()=>{qt();Xt();Zt();Nr();});function ri(){return ni.some(s=>!!process.env[s])}function oi(){return !!process.stdout.isTTY}function Ar(){return !ri()&&oi()}var ni,jr=m(()=>{ni=["CI","GITHUB_ACTIONS","GITLAB_CI","JENKINS_URL","CIRCLECI","TRAVIS","BUILDKITE","DRONE"];});var Ie,Lr=m(()=>{Ie=class{git;constructor(e){let t={baseDir:e,maxConcurrentProcesses:6};this.git=simpleGit(t);}async getLatestCommitHash(){let e=await this.git.log({maxCount:1});if(!e.latest)throw new Error("No commits found in repository");return e.latest.hash}async getChangedFiles(e){let t=await this.git.diff(["--name-status",e,"HEAD"]),n={added:[],modified:[],deleted:[],renamed:[]},r=t.split(/\r?\n/).map(o=>o.trim()).filter(Boolean);for(let o of r){let i=o.split(" ");if(i.length<2)continue;let a=i[0];a==="A"?n.added.push(i[1]):a==="M"?n.modified.push(i[1]):a==="D"?n.deleted.push(i[1]):a.startsWith("R")&&i.length>=3&&n.renamed.push({from:i[1],to:i[2]});}return n}async getRemoteOriginUrl(){let t=(await this.git.getRemotes(true)).find(n=>n.name==="origin");if(!t||!t.refs.fetch)throw new Error("Remote origin URL not found or has no fetch URL");return t.refs.fetch}async getRootDir(){try{return (await this.git.revparse(["--show-toplevel"])).trim()}catch{return null}}async isGitAvailable(){try{return await this.git.version(),!0}catch{return false}}async isGitRepository(){try{return await this.git.checkIsRepo()}catch{return false}}async listBranches(){return (await this.git.branchLocal()).all}async stageFile(e){await this.git.add(e);}async status(){let e=await this.git.status(),t=e.files?.length===0,n=e.current;return {clean:t,currentBranch:n}}async pull(){try{let e=await this.git.status();if(!e.isClean()){let r={modified:e.modified.length,created:e.created.length,deleted:e.deleted.length,conflicted:e.conflicted.length,staged:e.staged.length};throw console.error("\u274C Cannot pull: Working directory has uncommitted changes"),console.error(" Details:",JSON.stringify(r,null,2)),e.conflicted.length>0&&console.error(" \u26A0\uFE0F Conflicted files:",e.conflicted.join(", ")),new Error(`Cannot pull with uncommitted changes. Please commit or stash your changes first.
192
- Modified: ${r.modified}, Created: ${r.created}, Deleted: ${r.deleted}, Conflicted: ${r.conflicted}, Staged: ${r.staged}`)}let t=await this.git.pull();if(t.summary.changes===0&&t.summary.insertions===0&&t.summary.deletions===0){let r=await this.git.status();if(r.conflicted.length>0)throw console.error("\u274C Pull failed: Merge conflicts detected"),console.error(" Conflicted files:",r.conflicted.join(", ")),console.error(" Please resolve conflicts manually and commit the result"),new Error(`Pull resulted in merge conflicts in ${r.conflicted.length} file(s): ${r.conflicted.join(", ")}`)}t.summary.changes>0&&console.log(`\u2705 Pull successful: ${t.summary.changes} files changed, ${t.summary.insertions} insertions(+), ${t.summary.deletions} deletions(-)`);let n=await this.git.status();if(n.conflicted.length>0)throw console.error("\u274C Unexpected conflicts after pull:"),console.error(" Conflicted files:",n.conflicted.join(", ")),new Error(`Unexpected merge conflicts detected after pull: ${n.conflicted.join(", ")}`);return !0}catch(e){throw e instanceof Error?(e.message.includes("CONFLICT")?(console.error("\u274C Pull failed due to merge conflicts"),console.error(' Run "git status" to see conflicted files'),console.error(' Resolve conflicts, then run "git add" and "git commit"')):e.message.includes("not a git repository")?console.error("\u274C Pull failed: Not in a git repository"):e.message.includes("Could not resolve host")||e.message.includes("unable to access")?console.error("\u274C Pull failed: Network error - unable to reach remote repository"):e.message.includes("Authentication failed")?console.error("\u274C Pull failed: Authentication error - check your credentials"):e.message.includes("uncommitted changes")&&console.error("\u274C Pull failed: Uncommitted changes in working directory"),new Error(`Git pull operation failed: ${e.message}`,{cause:e})):new Error(`Git pull operation failed: ${String(e)}`)}}};});var li={};var Or,tn,nn,$e,Fr=m(async()=>{pt();_n();Qn();Er();Ir();kr();Tr();Ot();Rr();lt();je();jr();Lr();k();process.on("uncaughtException",s=>{s instanceof Error&&s.code==="ERR_USE_AFTER_CLOSE"&&process.exit(0),console.error(`${P} An unexpected error occurred during the index attempt:
193
- ${s?.message??String(s)}`),process.exit(1);});Or=globalThis.__constellationVersion??(()=>{let s=v__default.dirname(fileURLToPath(import.meta.url)),e=v__default.join(s,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version})();if(Ar()){let s=process.argv[2];["auth","help","init","index"].includes(s)?dt(s):dt(),Te.includes(s)||await Qt(Or)&&process.exit(0);}tn=process.cwd(),nn=new rt,$e=new Command;$e.name("constellation").description("Connecting stars in your code into intelligent patterns").version(Or);$e.command("init").description("Initialize a new constellation project configuration").option("--skip-mcp","Skip MCP server configuration for AI coding tools").option("--skip-ci","Skip CI/CD pipeline configuration").action(async s=>{try{let t={GitClient:new Ie(tn)};await new Pe(t).run({skipMcp:s.skipMcp,skipCi:s.skipCi});}catch(e){console.error(`${P} Failed to initialize project: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.command("auth").description("Configure authentication for the Constellation CLI").option("--manual","Use manual access key entry instead of browser-based authentication").action(async s=>{try{let e={Environment:nn};await new ge(e).run(s.manual);}catch(e){console.error(`${P} Failed to configure authentication: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.command("index").description("Create or update the Constellation data indices for the current project").option("--full","Conduct a full project re-index").option("--incremental","Conduct an incremental project index update").option("--dirty","Skip git validation checks (branch and working tree status)").action(async s=>{try{let e=await tt.loadFromFile(v__default.join(tn,"constellation.json")),t=new Ie(tn),n=new Ze(e),r=new ot(e),o={GitClient:t,Config:e,LanguageRegistry:n,LanguageDetector:r,Environment:nn},i=nn.isCI(),a=s.full||!s.incremental&&i,l=s.dirty||!1;!s.full&&!s.incremental&&i&&console.log(`${y} CI environment detected \u2014 defaulting to full index. Use --incremental to override.`),await new he(o).run(a,l);}catch(e){!(e instanceof E)&&!(e instanceof T)&&console.error(`${P} Failed to run index command: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.parse();});var Br=/^>=\s*\d+\.\d+\.\d+$/;function an(s,e=process.version){if(!Br.test(s))return {compatible:true,current:e,required:s};let t=s.replace(/^>=\s*/,""),n=e.replace(/^v/,""),r=t.split(".").map(Number),o=n.split(".").map(Number),i=true;for(let a=0;a<3;a++){let l=r[a]||0,g=o[a]||0;if(g>l)break;if(g<l){i=false;break}}return {compatible:i,current:e,required:s}}lt();var mi=dirname(fileURLToPath(import.meta.url)),fi=join(mi,"..","package.json"),rn=JSON.parse(readFileSync(fi,"utf-8")),hi=process.argv[2];if(!Te.includes(hi)&&rn.engines?.node){let s=an(rn.engines.node);s.compatible||(console.error(`Error: Constellation CLI requires Node.js ${s.required} (current: ${s.current})`),console.error(" Please upgrade to the latest LTS version: https://nodejs.org"),process.exit(1));}globalThis.__constellationVersion=rn.version;await Fr().then(()=>li);
190
+ ${C} Update failed. You can try updating manually:`),console.log(` ${this.packageManager.getUpdateCommandString(ot)}
191
+ `),false)}};});var Nr=m(()=>{Yt();qt();Xt();Tr();});function oi(){return ri.some(s=>!!process.env[s])}function ii(){return !!process.stdout.isTTY}function Rr(){return !oi()&&ii()}var ri,Ar=m(()=>{ri=["CI","GITHUB_ACTIONS","GITLAB_CI","JENKINS_URL","CIRCLECI","TRAVIS","BUILDKITE","DRONE"];});var Ie,jr=m(()=>{Ie=class{git;constructor(e){let t={baseDir:e,maxConcurrentProcesses:6};this.git=simpleGit(t);}async getLatestCommitHash(){let e=await this.git.log({maxCount:1});if(!e.latest)throw new Error("No commits found in repository");return e.latest.hash}async getChangedFiles(e){let t=await this.git.diff(["--name-status",e,"HEAD"]),n={added:[],modified:[],deleted:[],renamed:[]},r=t.split(/\r?\n/).map(o=>o.trim()).filter(Boolean);for(let o of r){let i=o.split(" ");if(i.length<2)continue;let a=i[0];a==="A"?n.added.push(i[1]):a==="M"?n.modified.push(i[1]):a==="D"?n.deleted.push(i[1]):a.startsWith("R")&&i.length>=3&&n.renamed.push({from:i[1],to:i[2]});}return n}async getRemoteOriginUrl(){let t=(await this.git.getRemotes(true)).find(n=>n.name==="origin");if(!t||!t.refs.fetch)throw new Error("Remote origin URL not found or has no fetch URL");return t.refs.fetch}async getRootDir(){try{return (await this.git.revparse(["--show-toplevel"])).trim()}catch{return null}}async isGitAvailable(){try{return await this.git.version(),!0}catch{return false}}async isGitRepository(){try{return await this.git.checkIsRepo()}catch{return false}}async listBranches(){return (await this.git.branchLocal()).all}async stageFile(e){await this.git.add(e);}async status(){let e=await this.git.status(),t=e.files?.length===0,n=e.current;return {clean:t,currentBranch:n}}async pull(){try{let e=await this.git.status();if(!e.isClean()){let r={modified:e.modified.length,created:e.created.length,deleted:e.deleted.length,conflicted:e.conflicted.length,staged:e.staged.length};throw console.error("\u274C Cannot pull: Working directory has uncommitted changes"),console.error(" Details:",JSON.stringify(r,null,2)),e.conflicted.length>0&&console.error(" \u26A0\uFE0F Conflicted files:",e.conflicted.join(", ")),new Error(`Cannot pull with uncommitted changes. Please commit or stash your changes first.
192
+ Modified: ${r.modified}, Created: ${r.created}, Deleted: ${r.deleted}, Conflicted: ${r.conflicted}, Staged: ${r.staged}`)}let t=await this.git.pull();if(t.summary.changes===0&&t.summary.insertions===0&&t.summary.deletions===0){let r=await this.git.status();if(r.conflicted.length>0)throw console.error("\u274C Pull failed: Merge conflicts detected"),console.error(" Conflicted files:",r.conflicted.join(", ")),console.error(" Please resolve conflicts manually and commit the result"),new Error(`Pull resulted in merge conflicts in ${r.conflicted.length} file(s): ${r.conflicted.join(", ")}`)}t.summary.changes>0&&console.log(`\u2705 Pull successful: ${t.summary.changes} files changed, ${t.summary.insertions} insertions(+), ${t.summary.deletions} deletions(-)`);let n=await this.git.status();if(n.conflicted.length>0)throw console.error("\u274C Unexpected conflicts after pull:"),console.error(" Conflicted files:",n.conflicted.join(", ")),new Error(`Unexpected merge conflicts detected after pull: ${n.conflicted.join(", ")}`);return !0}catch(e){throw e instanceof Error?(e.message.includes("CONFLICT")?(console.error("\u274C Pull failed due to merge conflicts"),console.error(' Run "git status" to see conflicted files'),console.error(' Resolve conflicts, then run "git add" and "git commit"')):e.message.includes("not a git repository")?console.error("\u274C Pull failed: Not in a git repository"):e.message.includes("Could not resolve host")||e.message.includes("unable to access")?console.error("\u274C Pull failed: Network error - unable to reach remote repository"):e.message.includes("Authentication failed")?console.error("\u274C Pull failed: Authentication error - check your credentials"):e.message.includes("uncommitted changes")&&console.error("\u274C Pull failed: Uncommitted changes in working directory"),new Error(`Git pull operation failed: ${e.message}`,{cause:e})):new Error(`Git pull operation failed: ${String(e)}`)}}};});var pi={};var Lr,en,tn,$e,Or=m(async()=>{ct();wn();Zn();xr();Er();$r();kr();Lt();Nr();lt();je();Ar();jr();k();process.on("uncaughtException",s=>{s instanceof Error&&s.code==="ERR_USE_AFTER_CLOSE"&&process.exit(0),console.error(`${P} An unexpected error occurred during the index attempt:
193
+ ${s?.message??String(s)}`),process.exit(1);});Lr=globalThis.__constellationVersion??(()=>{let s=v__default.dirname(fileURLToPath(import.meta.url)),e=v__default.join(s,"..","package.json");return JSON.parse(readFileSync(e,"utf-8")).version})();if(Rr()){let s=process.argv[2];["auth","help","init","index"].includes(s)?gt(s):gt(),Te.includes(s)||await Zt(Lr)&&process.exit(0);}en=process.cwd(),tn=new nt,$e=new Command;$e.name("constellation").description("Connecting stars in your code into intelligent patterns").version(Lr);$e.command("init").description("Initialize a new constellation project configuration").option("--skip-mcp","Skip MCP server configuration for AI coding tools").option("--skip-ci","Skip CI/CD pipeline configuration").action(async s=>{try{let t={GitClient:new Ie(en)};await new Pe(t).run({skipMcp:s.skipMcp,skipCi:s.skipCi});}catch(e){console.error(`${P} Failed to initialize project: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.command("auth").description("Configure authentication for the Constellation CLI").option("--manual","Use manual access key entry instead of browser-based authentication").action(async s=>{try{let e={Environment:tn};await new ge(e).run(s.manual);}catch(e){console.error(`${P} Failed to configure authentication: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.command("index").description("Create or update the Constellation data indices for the current project").option("--full","Conduct a full project re-index").option("--incremental","Conduct an incremental project index update").option("--dirty","Skip git validation checks (branch and working tree status)").action(async s=>{try{let e=await et.loadFromFile(v__default.join(en,"constellation.json")),t=new Ie(en),n=new Xe(e),r=new rt(e),o={GitClient:t,Config:e,LanguageRegistry:n,LanguageDetector:r,Environment:tn},i=tn.isCI(),a=s.full||!s.incremental&&i,c=s.dirty||!1;!s.full&&!s.incremental&&i&&console.log(`${y} CI environment detected \u2014 defaulting to full index. Use --incremental to override.`),await new he(o).run(a,c);}catch(e){!(e instanceof E)&&!(e instanceof T)&&console.error(`${P} Failed to run index command: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}});$e.parse();});var Dr=/^>=\s*\d+\.\d+\.\d+$/;function sn(s,e=process.version){if(!Dr.test(s))return {compatible:true,current:e,required:s};let t=s.replace(/^>=\s*/,""),n=e.replace(/^v/,""),r=t.split(".").map(Number),o=n.split(".").map(Number),i=true;for(let a=0;a<3;a++){let c=r[a]||0,g=o[a]||0;if(g>c)break;if(g<c){i=false;break}}return {compatible:i,current:e,required:s}}lt();var mi=dirname(fileURLToPath(import.meta.url)),hi=join(mi,"..","package.json"),nn=JSON.parse(readFileSync(hi,"utf-8")),yi=process.argv[2];if(!Te.includes(yi)&&nn.engines?.node){let s=sn(nn.engines.node);s.compatible||(console.error(`Error: Constellation CLI requires Node.js ${s.required} (current: ${s.current})`),console.error(" Please upgrade to the latest LTS version: https://nodejs.org"),process.exit(1));}globalThis.__constellationVersion=nn.version;await Or().then(()=>pi);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@constellationdev/cli",
3
3
  "description": "Code Intelligence Platform for AI Coding Agents",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "author": "ShiftinBits Inc",
6
6
  "main": "dist/main.js",
7
7
  "type": "module",