@constellationdev/cli 0.1.4 → 0.1.5

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/index.js +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -122,7 +122,7 @@ CONSTELLATION_EOF
122
122
  `),await _.writeFile(e,n);}async writeAuxiliaryFiles(e){for(let[t,n]of e){let r=w__default.join(this.cwd,t);await this.ensureDirectoryExists(r);let o=n.replace(/\r\n/g,`
123
123
  `);o.endsWith(`
124
124
  `)||(o+=`
125
- `),await _.writeFile(r,o),(t.endsWith(".sh")||o.startsWith("#!"))&&await T__default.chmod(r,493);}}};var z=class{getBuildConfigManager(e,t){return null}getImportResolver(e,t){return null}};var X=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(`${y} 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(`${y} 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();}};Y();Y();var Oe=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?w.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=w.resolve(n,i),c=await this.findEntryPoint(a);c&&(e[r]=c);}return e}async loadFromPackageJsonWorkspaces(){let e={};try{let t=w.join(this.projectRoot,"package.json"),n=await T.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=w.join(this.projectRoot,n);try{let o=await T.readdir(r,{withFileTypes:!0});for(let i of o)i.isDirectory()&&t.push(w.join(r,i.name));}catch{}}else {let n=w.join(this.projectRoot,e);try{(await T.stat(n)).isDirectory()&&t.push(n);}catch{}}return t}async loadWorkspacePackage(e){try{let t=w.join(e,"package.json"),n=await T.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 w.join(e,r);if(typeof r=="object"){let o=r["."]||r["./index"];if(typeof o=="string")return w.join(e,o);if(typeof o=="object"){let i=o.import||o.default||o.require;if(i)return w.join(e,i)}}}if(t.main)return w.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=w.join(e,r);try{if((await T.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=w.join(e,n);try{if((await T.stat(r)).isFile())return r}catch{}}try{if((await T.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")?w.dirname(e):w.dirname(e),r=[w.join(n,t+".ts"),w.join(n,t+".tsx"),w.join(n,t+".js"),w.join(n,t+".jsx"),w.join(n,t+".d.ts"),w.join(n,t,"index.ts"),w.join(n,t,"index.tsx"),w.join(n,t,"index.js"),w.join(n,t,"index.jsx")];for(let o of r)try{if((await T.stat(o)).isFile())return o}catch{}return null}toProjectRelative(e){let t=H(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}};var Z=class{baseUrl=null;paths={};sourceDir;tsconfigDir;projectRoot;extensions;packageImports={};packageJsonDir=null;sourceFilePath;workspaceResolver;constructor(e,t){this.sourceFilePath=e,this.sourceDir=w.dirname(e),this.projectRoot=process.cwd(),this.workspaceResolver=new Oe(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=w.dirname(t.tsconfigFile);let i=t.tsconfig?.compilerOptions;i&&(i.baseUrl&&(this.baseUrl=w.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=w.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=H(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=w.resolve(this.tsconfigDir,o);return await this.findFileWithExtensions(i)}async resolveWithBaseUrl(e){if(!this.baseUrl)return null;let t=w.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=w.join(o,`index${i}`);if(await this.fileExists(a))return await this.resolveSymlink(a)}return null}async fileExists(e){try{return (await T.stat(e)).isFile()}catch{return false}}async resolveSymlink(e){try{return await T.realpath(e)}catch{return e}}async findPackageJson(e){let t=e;for(;t.startsWith(this.projectRoot);){let n=w.join(t,"package.json");try{if((await T.stat(n)).isFile())return n}catch{}let r=w.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 T.readFile(e,"utf-8"),n=JSON.parse(t);this.packageJsonDir=w.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=w.resolve(this.packageJsonDir,n);return await this.findFileWithExtensions(r)}};var Fe=class extends z{language="typescript";extensions=[".ts",".tsx",".d.ts"];getBuildConfigManager(e,t){return new X(e,t)}getImportResolver(e,t){return new Z(e,t)}};var Me=class extends z{language="javascript";extensions=[".js",".jsx",".mjs",".cjs"];getBuildConfigManager(e,t){return new X(e,t)}getImportResolver(e,t){return new Z(e,t)}};je();var De=class{sourceDir;projectRoot;constructor(e,t){this.sourceDir=w.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(w.resolve(this.projectRoot,n));return r?w.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=w.resolve(this.sourceDir,o),a=await this.tryResolveFile(i);return a?w.relative(this.projectRoot,a).replace(/\\/g,"/"):e}async tryResolveFile(e){let t=[`${e}.py`,`${e}.pyi`,`${e}.pyw`,w.join(e,"__init__.py"),w.join(e,"__init__.pyi")];for(let n of t)try{return await Be.promises.access(n,Be.constants.F_OK),n}catch{continue}return null}};var He=class extends z{language="python";extensions=[".py",".pyi",".pyw"];getBuildConfigManager(e,t){return null}getImportResolver(e,t){return new De(e,process.cwd())}};var me={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"]},Ue=class{constructor(e){this.config=e;this.registerPlugin(new Fe),this.registerPlugin(new Me),this.registerPlugin(new He);}plugins=new Map;registerPlugin(e){this.plugins.set(e.language,e);}getPlugin(e){return this.plugins.get(e)}javascript={language:()=>hr,fileExtensions:()=>this.config?.languages.javascript?.fileExtensions??me.javascript};typescript={language:()=>_r.typescript,fileExtensions:()=>this.config?.languages.typescript?.fileExtensions??me.typescript};python={language:()=>yr,fileExtensions:()=>this.config?.languages.python?.fileExtensions??me.python};php;json;java;go;cpp;"c-sharp";c;bash;ruby};var wr={stable:"Code",insiders:"Code - Insiders"};function fn(s,e){let t=Q__default.homedir(),n=process.platform,r=wr[s];switch(n){case "darwin":return w__default.join(t,"Library/Application Support",r,"User/globalStorage",e);case "win32":return w__default.join(process.env.APPDATA||w__default.join(t,"AppData/Roaming"),r,"User/globalStorage",e);default:return w__default.join(t,".config",r,"User/globalStorage",e)}}function hn(){let s="saoudrizwan.claude-dev";return ["stable","insiders"].map(t=>({variant:t,displayName:t==="stable"?"VS Code":"VS Code Insiders",settingsPath:w__default.join(fn(t,s),"settings","cline_mcp_settings.json")}))}function yn(){return w__default.join(fn("stable","saoudrizwan.claude-dev"),"settings","cline_mcp_settings.json")}function yt(){let s=Q__default.homedir();return w__default.join(s,".copilot","mcp-config.json")}function _n(){return [{displayName:"Copilot CLI",settingsPath:yt()}]}var wn={command:"npx",args:["-y","@constellationdev/mcp@latest"]},Cr={extraKnownMarketplaces:{"constellation-marketplace":{source:{source:"github",repo:"ShiftinBits/constellation-claude"}}},enabledPlugins:{"constellation@constellation-plugins":true}},_t=[{id:"claude-code",displayName:"Claude Code",configPath:".mcp.json",format:"json",permissionsConfig:{filePath:".claude/settings.json",allowKeyPath:["permissions","allow"],allowValue:"mcp__plugin_constellation_*"},marketplaceConfig:{filePath:".claude/settings.json",config:Cr},mcpServersKeyPath:["mcpServers"]},{id:"cline",displayName:"Cline",configPath:yn(),isGlobalConfig:true,getGlobalConfigPaths:hn,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:yt(),isGlobalConfig:true,getGlobalConfigPaths:_n,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"]}}];function wt(s){return _t.find(e=>e.id===s)}var Ct=null;async function Cn(){if(!Ct)try{let s=await import('@iarna/toml');Ct={parse:s.parse,stringify:s.stringify};}catch{throw new Error("TOML support requires @iarna/toml package. Install with: npm install @iarna/toml")}return Ct}function xr(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]!==`
125
+ `),await _.writeFile(r,o),(t.endsWith(".sh")||o.startsWith("#!"))&&await T__default.chmod(r,493);}}};var z=class{getBuildConfigManager(e,t){return null}getImportResolver(e,t){return null}};var X=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(`${y} 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(`${y} 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();}};Y();Y();var Oe=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?w.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=w.resolve(n,i),c=await this.findEntryPoint(a);c&&(e[r]=c);}return e}async loadFromPackageJsonWorkspaces(){let e={};try{let t=w.join(this.projectRoot,"package.json"),n=await T.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=w.join(this.projectRoot,n);try{let o=await T.readdir(r,{withFileTypes:!0});for(let i of o)i.isDirectory()&&t.push(w.join(r,i.name));}catch{}}else {let n=w.join(this.projectRoot,e);try{(await T.stat(n)).isDirectory()&&t.push(n);}catch{}}return t}async loadWorkspacePackage(e){try{let t=w.join(e,"package.json"),n=await T.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 w.join(e,r);if(typeof r=="object"){let o=r["."]||r["./index"];if(typeof o=="string")return w.join(e,o);if(typeof o=="object"){let i=o.import||o.default||o.require;if(i)return w.join(e,i)}}}if(t.main)return w.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=w.join(e,r);try{if((await T.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=w.join(e,n);try{if((await T.stat(r)).isFile())return r}catch{}}try{if((await T.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")?w.dirname(e):w.dirname(e),r=[w.join(n,t+".ts"),w.join(n,t+".tsx"),w.join(n,t+".js"),w.join(n,t+".jsx"),w.join(n,t+".d.ts"),w.join(n,t,"index.ts"),w.join(n,t,"index.tsx"),w.join(n,t,"index.js"),w.join(n,t,"index.jsx")];for(let o of r)try{if((await T.stat(o)).isFile())return o}catch{}return null}toProjectRelative(e){let t=H(this.projectRoot,e);return t.startsWith("./")?t:`./${t}`}};var Z=class{baseUrl=null;paths={};sourceDir;tsconfigDir;projectRoot;extensions;packageImports={};packageJsonDir=null;sourceFilePath;workspaceResolver;constructor(e,t){this.sourceFilePath=e,this.sourceDir=w.dirname(e),this.projectRoot=process.cwd(),this.workspaceResolver=new Oe(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=w.dirname(t.tsconfigFile);let i=t.tsconfig?.compilerOptions;i&&(i.baseUrl&&(this.baseUrl=w.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=w.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=H(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=w.resolve(this.tsconfigDir,o);return await this.findFileWithExtensions(i)}async resolveWithBaseUrl(e){if(!this.baseUrl)return null;let t=w.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=w.join(o,`index${i}`);if(await this.fileExists(a))return await this.resolveSymlink(a)}return null}async fileExists(e){try{return (await T.stat(e)).isFile()}catch{return false}}async resolveSymlink(e){try{return await T.realpath(e)}catch{return e}}async findPackageJson(e){let t=e;for(;t.startsWith(this.projectRoot);){let n=w.join(t,"package.json");try{if((await T.stat(n)).isFile())return n}catch{}let r=w.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 T.readFile(e,"utf-8"),n=JSON.parse(t);this.packageJsonDir=w.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=w.resolve(this.packageJsonDir,n);return await this.findFileWithExtensions(r)}};var Fe=class extends z{language="typescript";extensions=[".ts",".tsx",".d.ts"];getBuildConfigManager(e,t){return new X(e,t)}getImportResolver(e,t){return new Z(e,t)}};var Me=class extends z{language="javascript";extensions=[".js",".jsx",".mjs",".cjs"];getBuildConfigManager(e,t){return new X(e,t)}getImportResolver(e,t){return new Z(e,t)}};je();var De=class{sourceDir;projectRoot;constructor(e,t){this.sourceDir=w.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(w.resolve(this.projectRoot,n));return r?w.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=w.resolve(this.sourceDir,o),a=await this.tryResolveFile(i);return a?w.relative(this.projectRoot,a).replace(/\\/g,"/"):e}async tryResolveFile(e){let t=[`${e}.py`,`${e}.pyi`,`${e}.pyw`,w.join(e,"__init__.py"),w.join(e,"__init__.pyi")];for(let n of t)try{return await Be.promises.access(n,Be.constants.F_OK),n}catch{continue}return null}};var He=class extends z{language="python";extensions=[".py",".pyi",".pyw"];getBuildConfigManager(e,t){return null}getImportResolver(e,t){return new De(e,process.cwd())}};var me={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"]},Ue=class{constructor(e){this.config=e;this.registerPlugin(new Fe),this.registerPlugin(new Me),this.registerPlugin(new He);}plugins=new Map;registerPlugin(e){this.plugins.set(e.language,e);}getPlugin(e){return this.plugins.get(e)}javascript={language:()=>hr,fileExtensions:()=>this.config?.languages.javascript?.fileExtensions??me.javascript};typescript={language:()=>_r.typescript,fileExtensions:()=>this.config?.languages.typescript?.fileExtensions??me.typescript};python={language:()=>yr,fileExtensions:()=>this.config?.languages.python?.fileExtensions??me.python};php;json;java;go;cpp;"c-sharp";c;bash;ruby};var wr={stable:"Code",insiders:"Code - Insiders"};function fn(s,e){let t=Q__default.homedir(),n=process.platform,r=wr[s];switch(n){case "darwin":return w__default.join(t,"Library/Application Support",r,"User/globalStorage",e);case "win32":return w__default.join(process.env.APPDATA||w__default.join(t,"AppData/Roaming"),r,"User/globalStorage",e);default:return w__default.join(t,".config",r,"User/globalStorage",e)}}function hn(){let s="saoudrizwan.claude-dev";return ["stable","insiders"].map(t=>({variant:t,displayName:t==="stable"?"VS Code":"VS Code Insiders",settingsPath:w__default.join(fn(t,s),"settings","cline_mcp_settings.json")}))}function yn(){return w__default.join(fn("stable","saoudrizwan.claude-dev"),"settings","cline_mcp_settings.json")}function yt(){let s=Q__default.homedir();return w__default.join(s,".copilot","mcp-config.json")}function _n(){return [{displayName:"Copilot CLI",settingsPath:yt()}]}var wn={command:"npx",args:["-y","@constellationdev/mcp@latest"]},Cr={extraKnownMarketplaces:{"constellation-plugins":{source:{source:"github",repo:"ShiftinBits/constellation-claude"}}},enabledPlugins:{"constellation@constellation-plugins":true}},_t=[{id:"claude-code",displayName:"Claude Code",configPath:".mcp.json",format:"json",permissionsConfig:{filePath:".claude/settings.json",allowKeyPath:["permissions","allow"],allowValue:"mcp__plugin_constellation_*"},marketplaceConfig:{filePath:".claude/settings.json",config:Cr},mcpServersKeyPath:["mcpServers"]},{id:"cline",displayName:"Cline",configPath:yn(),isGlobalConfig:true,getGlobalConfigPaths:hn,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:yt(),isGlobalConfig:true,getGlobalConfigPaths:_n,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"]}}];function wt(s){return _t.find(e=>e.id===s)}var Ct=null;async function Cn(){if(!Ct)try{let s=await import('@iarna/toml');Ct={parse:s.parse,stringify:s.stringify};}catch{throw new Error("TOML support requires @iarna/toml package. Install with: npm install @iarna/toml")}return Ct}function xr(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]!==`
126
126
  `;)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 Ge=class{cwd;constructor(e=process.cwd()){this.cwd=e;}async configureTool(e){try{let t=w__default.join(this.cwd,e.configPath);await this.ensureDirectoryExists(t);let n=await this.readConfig(t,e.format);if(e.configDefaults)for(let[r,o]of Object.entries(e.configDefaults))r in n||(n[r]=o);return e.pluginConfig&&(n=this.addPluginToArray(n,e.pluginConfig)),e.skipMcpServer||(n=this.addConstellationServer(n,e),await this.configureEnvPolicy(n,e)),await this.writeConfig(t,n,e.format),!e.skipMcpServer&&e.permissionsConfig&&await this.configurePermissions(e.permissionsConfig),e.marketplaceConfig&&await this.configureMarketplace(e.marketplaceConfig),{tool:e,success:!0,configuredPath:t}}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=w__default.dirname(e);await T__default.mkdir(t,{recursive:true});}async readConfig(e,t){try{if(!await _.fileIsReadable(e))return {};let r=await _.readFile(e);return t==="json"?JSON.parse(r):t==="jsonc"?JSON.parse(xr(r)):(await Cn()).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??wn,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 Cn()).stringify(t),r=r.replace(/\r\n/g,`
127
127
  `),r.endsWith(`
128
128
  `)||(r+=`
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.1.4",
4
+ "version": "0.1.5",
5
5
  "author": "ShiftinBits Inc",
6
6
  "main": "dist/index.js",
7
7
  "type": "module",