@constellationdev/cli 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ ${f} Please run this command from the root directory of a git repository.`);let
|
|
|
137
137
|
${n}`);}}async configureMCPServers(){let{configureMcp:e}=await vn({type:"confirm",name:"configureMcp",message:"Automatically configure Constellation for AI coding assistants?",initial:true});if(!e)return;let t=_t.map(p=>({name:p.displayName,value:p.id})),{selectedTools:n}=await vn({type:"multiselect",name:"selectedTools",message:"Select AI coding assistants to configure:",choices:t,result(p){return p.map(u=>this.choices.find(v=>v.name===u)?.value??u)}});if(n.length===0){console.log(`${f} No tools selected, skipping MCP configuration`);return}let r=new Ge(process.cwd()),o=[];for(let p of n){let u=wt(p);if(u)if(console.log(` ${f} Configuring ${u.displayName}...`),u.isGlobalConfig&&u.getGlobalConfigPaths){let m=await r.configureGlobalTool(u),v=false;for(let P of m)o.push(P),P.success?(v=true,console.log(` ${h} ${P.tool.displayName} configured at ${fe(P.configuredPath,process.cwd())}`)):P.error&&console.log(` ${y} ${P.tool.displayName}: ${P.error}`);if(v){let P=u.id==="cline"?"global VS Code settings":"global settings";console.log(` ${f} Note: ${u.displayName} uses ${P} (not project-level)`);}if(m.length===0){let P=u.id==="cline"?"No VS Code installations found":"Configuration directory not found";console.log(` ${y} ${u.displayName}: ${P}`);}}else {let m=await r.configureTool(u);o.push(m),m.success?(console.log(` ${h} ${u.displayName} configured at ${fe(m.configuredPath,process.cwd())}`),u.permissionsConfig&&console.log(` ${h} ${u.displayName} permissions set in ${u.permissionsConfig.filePath}`)):console.log(` ${y} ${u.displayName}: ${m.error}`);}}if(o.find(p=>p.tool.id==="claude-code"&&p.success)){let p=w__default.join(process.cwd(),".claude/settings.json");try{await this.git.stageFile(p),console.log(` ${h} Added .claude/settings.json to staged changes in git`);}catch{console.log(` ${y} Could not stage .claude/settings.json in git`);}}if(o.find(p=>p.tool.id==="codex-cli"&&p.success)){let p=w__default.join(process.cwd(),".codex/config.toml");try{await this.git.stageFile(p),console.log(` ${h} Added .codex/config.toml to staged changes in git`);}catch{}}if(o.find(p=>p.tool.id==="opencode"&&p.success)){let p=w__default.join(process.cwd(),"opencode.jsonc");try{await this.git.stageFile(p),console.log(` ${h} 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(`
|
|
138
138
|
${h} MCP configuration complete: ${g} configured`),d>0&&console.log(`${y} ${d} tool(s) could not be configured`),await this.configureHooks(n,o),console.log(`
|
|
139
139
|
${f} Some tools may require restart to pick up new configuration.`);}async configureHooks(e,t){let n=new ue(process.cwd()),r=mt(),o=e.map(c=>wt(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(`
|
|
140
|
-
${f} 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?fe(g.configuredPath,process.cwd()):w__default.dirname(d[0]);console.log(` ${h} ${c.displayName} hooks configured at ${p}`);for(let u of d){let m=w__default.isAbsolute(u)?fe(u,process.cwd()):u;try{await this.git.stageFile(u),console.log(` ${h} Added ${m} to staged changes in git`);}catch{console.log(` ${y} Could not stage ${m} in git`);}}}else console.log(` ${h} ${c.displayName} hooks configured`);}else console.log(` ${y} ${c.displayName}: ${g.error}`);}let a=i.filter(c=>c.success).length;a>0&&console.log(`${h} Hooks configuration complete: ${a} configured`);}buildLanguageChoices(e){return [{name:"
|
|
140
|
+
${f} 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?fe(g.configuredPath,process.cwd()):w__default.dirname(d[0]);console.log(` ${h} ${c.displayName} hooks configured at ${p}`);for(let u of d){let m=w__default.isAbsolute(u)?fe(u,process.cwd()):u;try{await this.git.stageFile(u),console.log(` ${h} Added ${m} to staged changes in git`);}catch{console.log(` ${y} Could not stage ${m} in git`);}}}else console.log(` ${h} ${c.displayName} hooks configured`);}else console.log(` ${y} ${c.displayName}: ${g.error}`);}let a=i.filter(c=>c.success).length;a>0&&console.log(`${h} Hooks configuration complete: ${a} configured`);}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 We=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 _.fileIsReadable(e)){let n=await _.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(`${C} 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 Ke=class{getVariable(e){return Promise.resolve(process.env[e])}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(`
|
|
141
141
|
`)||t.includes("\r"))throw new Error("Value cannot contain newline characters")}escapeShellValue(e){return e.replace(/[\\'\"$`]/g,"\\$&")}},Pt=class extends Ke{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.
|
|
142
142
|
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}}},xt=class extends Ke{userConfigFiles;constructor(){super(),this.userConfigFiles=[w.join(Q.homedir(),".zshenv"),w.join(Q.homedir(),".profile")];}async setVariable(e,t){if(this.validateInput(e,t),this.isCI())throw new Error(`Cannot set environment variables in CI/CD environments.
|
|
143
143
|
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 _.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()+`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constellationdev/cli",
|
|
3
|
-
"description": "Code Intelligence Platform for AI Coding
|
|
4
|
-
"version": "0.1.
|
|
3
|
+
"description": "Code Intelligence Platform for AI Coding Agents",
|
|
4
|
+
"version": "0.1.4",
|
|
5
5
|
"author": "ShiftinBits Inc",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"type": "module",
|