@constellationdev/cli 0.6.0 → 0.6.1
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/main.js +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -55,7 +55,7 @@ ${u.whiteBright(" o o")}${u.blueBright("-")}${u.blueBright("o")}
|
|
|
55
55
|
|
|
56
56
|
source ${t}
|
|
57
57
|
|
|
58
|
-
New terminal sessions will load it automatically.`);}};});function Rn(i){return i.replace(/\\/g,"/")}function dt(i){return Rn(i).replace(/^\.?\//,"")}function M(i,e){return Rn(P.relative(i,e))}var pe=h(()=>{});var ta,ra,nr,na,Nn,Tn,mt,$n=h(()=>{
|
|
58
|
+
New terminal sessions will load it automatically.`);}};});function Rn(i){return i.replace(/\\/g,"/")}function dt(i){return Rn(i).replace(/^\.?\//,"")}function M(i,e){return Rn(P.relative(i,e))}var pe=h(()=>{});var ta,ra,nr,na,Nn,Tn,mt,$n=h(()=>{pe();D();ta={function:{hover:true,references:true,callHierarchy:true},method:{hover:true,references:true,callHierarchy:true},class:{hover:false,references:true,callHierarchy:false},interface:{hover:false,references:true,callHierarchy:false},variable:{hover:true,references:true,callHierarchy:false},property:{hover:true,references:true,callHierarchy:false},import:{hover:true,references:false,callHierarchy:false}},ra={hover:true,references:true,callHierarchy:false},nr=1e4,na=1200*1e3,Nn=50,Tn={typescript:"TypeScript",javascript:"JavaScript",python:"Python"},mt=class{constructor(e){this.projectRoot=e;}async enrich(e,t,n){let o=[],s=Date.now(),a={filesUnreadable:0,filesOpenFailed:0,filesNoSymbols:0,symbolQueryErrors:0,discoveryErrors:0,queryRejections:0,symbolsWithNoEnrichment:{},firstFileError:null,firstOpenError:null,firstSymbolError:null,firstDiscoveryError:null};for(let[l,c]of e){let p=n.get(l);if(!p)continue;let d=0,m=c.length;for(let g of c){if(Date.now()-s>na)return console.log(`${v} Enrichment timeout reached. Uploading partial results.`),this.logDiagnostics(a),o;let f=t.get(g)||[];if(f.length===0){let x=P.resolve(this.projectRoot,g),_=pathToFileURL(x).href,S;try{S=ir.readFileSync(x,"utf-8");}catch(L){a.filesUnreadable++,a.firstFileError||(a.firstFileError=`${g}: ${L instanceof Error?L.message:String(L)}`);continue}try{p.sendNotification("textDocument/didOpen",{textDocument:{uri:_,languageId:this.getLanguageId(g),version:1,text:S}});}catch(L){a.filesOpenFailed++,a.firstOpenError||(a.firstOpenError=`${g}: ${L instanceof Error?L.message:String(L)}`);continue}if(f=await this.discoverSymbols(p,g,a),f.length===0){a.filesNoSymbols++;try{p.sendNotification("textDocument/didClose",{textDocument:{uri:_}});}catch{}continue}let I=await this.enrichFile(p,g,f,a,S);if(I.length>0&&o.push({filePath:g,language:l,symbols:I}),d++,d%Nn===0){let L=Math.round(d/m*100);console.log(`${v} ${Tn[l]??l} index enrichment: ${L}% (${d}/${m} files)`);}continue}let y=await this.enrichFile(p,g,f,a);if(y.length>0&&o.push({filePath:g,language:l,symbols:y}),d++,d%Nn===0){let x=Math.round(d/m*100);console.log(`${v} ${Tn[l]??l} index enrichment: ${x}% (${d}/${m} files)`);}}}return this.logDiagnostics(a),o}logDiagnostics(e){let t=[];e.filesUnreadable>0&&t.push(`${e.filesUnreadable} files unreadable`),e.filesOpenFailed>0&&t.push(`${e.filesOpenFailed} files failed to open in language server`),e.discoveryErrors>0&&t.push(`${e.discoveryErrors} symbol discovery failures`),e.symbolQueryErrors>0&&t.push(`${e.symbolQueryErrors} symbol query failures`),e.queryRejections>0&&t.push(`${e.queryRejections} individual LSP query rejections`);let n=Object.entries(e.symbolsWithNoEnrichment).filter(([,o])=>o>0).sort(([,o],[,s])=>s-o);if(n.length>0){let o=n.reduce((a,[,l])=>a+l,0),s=n.map(([a,l])=>`${l} ${a}`).join(", ");t.push(`${o} symbols yielded no enrichment (${s})`);}t.length!==0&&(console.log(`${b} Enrichment issues: ${t.join(", ")}`),e.firstFileError&&console.log(`${b} First file read error: ${e.firstFileError}`),e.firstOpenError&&console.log(`${b} First didOpen error: ${e.firstOpenError}`),e.firstDiscoveryError&&console.log(`${b} First discovery error: ${e.firstDiscoveryError}`),e.firstSymbolError&&console.log(`${b} First symbol query error: ${e.firstSymbolError}`));}async enrichFile(e,t,n,o,s){let a=P.resolve(this.projectRoot,t),l=pathToFileURL(a).href;if(!(s!==void 0)){let d;try{d=ir.readFileSync(a,"utf-8");}catch(m){return o.filesUnreadable++,o.firstFileError||(o.firstFileError=`${t}: ${m instanceof Error?m.message:String(m)}`),[]}try{e.sendNotification("textDocument/didOpen",{textDocument:{uri:l,languageId:this.getLanguageId(t),version:1,text:d}});}catch(m){return o.filesOpenFailed++,o.firstOpenError||(o.firstOpenError=`${t}: ${m instanceof Error?m.message:String(m)}`),[]}}let p=[];for(let d of n)try{let m=await this.querySymbol(e,l,d,o);m&&p.push(m);}catch(m){o.symbolQueryErrors++,o.firstSymbolError||(o.firstSymbolError=`${d.name} in ${t}: ${m instanceof Error?m.message:String(m)}`);}try{e.sendNotification("textDocument/didClose",{textDocument:{uri:l}});}catch{}return p}async querySymbol(e,t,n,o){let s=ta[n.kind.toLowerCase()]||ra,a={line:n.line-1,character:n.column},l={textDocument:{uri:t},position:a},c={name:n.name,line:n.line,column:n.column,kind:n.kind},p=false,[d,m]=await Promise.allSettled([s.hover?e.sendRequest("textDocument/hover",l,nr):null,s.references?e.sendRequest("textDocument/references",{...l,context:{includeDeclaration:false}},nr):null]);for(let g of [d,m])g.status==="rejected"&&o.queryRejections++;if(d.status==="fulfilled"&&d.value?.contents){let g=d.value,f=typeof g.contents=="string"?g.contents:g.contents.value||"";f&&(c.typeInfo={resolvedType:f},p=true);}if(m.status==="fulfilled"&&m.value){let g=m.value;if(g.length>0){let f=g.slice(0,100).map(y=>({filePath:M(this.projectRoot,this.uriToPath(y.uri||"")),line:(y.range?.start?.line??0)+1,column:y.range?.start?.character??0}));c.references={count:g.length,locations:f},p=true;}}if(s.callHierarchy)try{let g=await e.sendRequest("textDocument/prepareCallHierarchy",l,nr);if(g&&g.length>0){let f=g[0],[y,x]=await Promise.all([e.sendRequest("callHierarchy/incomingCalls",{item:f}).catch(()=>[]),e.sendRequest("callHierarchy/outgoingCalls",{item:f}).catch(()=>[])]),_=(y||[]).slice(0,200).map(I=>({name:I.from?.name||"",filePath:M(this.projectRoot,this.uriToPath(I.from?.uri||"")),line:(I.from?.range?.start?.line??0)+1,column:I.from?.selectionRange?.start?.character??I.from?.range?.start?.character??0})),S=(x||[]).slice(0,200).map(I=>({name:I.to?.name||"",filePath:M(this.projectRoot,this.uriToPath(I.to?.uri||"")),line:(I.to?.range?.start?.line??0)+1,column:I.to?.selectionRange?.start?.character??I.to?.range?.start?.character??0}));(_.length>0||S.length>0)&&(c.callHierarchy={incomingCalls:_,outgoingCalls:S},p=!0);}}catch{o.queryRejections++;}if(!p){let g=n.kind.toLowerCase();o.symbolsWithNoEnrichment[g]=(o.symbolsWithNoEnrichment[g]??0)+1;}return p?c:null}async discoverSymbols(e,t,n){let o=P.resolve(this.projectRoot,t),s=pathToFileURL(o).href;try{let a=await e.sendRequest("textDocument/documentSymbol",{textDocument:{uri:s}});return !a||!Array.isArray(a)?[]:this.flattenDocumentSymbols(a)}catch(a){return n.discoveryErrors++,n.firstDiscoveryError||(n.firstDiscoveryError=`${t}: ${a instanceof Error?a.message:String(a)}`),[]}}flattenDocumentSymbols(e){let t=[],n={1:"file",2:"module",3:"namespace",4:"package",5:"class",6:"method",7:"property",8:"field",9:"constructor",10:"enum",11:"interface",12:"function",13:"variable",14:"constant",15:"string",16:"number",17:"boolean",18:"array",19:"object",20:"key",21:"null",22:"enumMember",23:"struct",24:"event",25:"operator",26:"typeParameter"};for(let o of e){let s=n[o.kind]||"variable",a=o.selectionRange||o.range||o.location?.range;a&&t.push({name:o.name,line:(a.start?.line??0)+1,column:a.start?.character??0,kind:s}),o.children&&Array.isArray(o.children)&&t.push(...this.flattenDocumentSymbols(o.children));}return t}uriToPath(e){try{return fileURLToPath(new URL(e))}catch{return e.replace(/^file:\/\//,"")}}getLanguageId(e){let t=P.extname(e).toLowerCase();return {".ts":"typescript",".tsx":"typescriptreact",".js":"javascript",".jsx":"javascriptreact",".py":"python",".pyi":"python"}[t]||"plaintext"}};});function jn(i){return i.map(e=>JSON.stringify(e)).join(`
|
|
59
59
|
`)+`
|
|
60
60
|
`}var kn=h(()=>{});function gt(i){try{return execFileSync(process.platform==="win32"?"where":"which",[i],{stdio:"ignore"}),!0}catch{return false}}var w,J=h(()=>{w={async directoryExists(i){try{return (await B__default.stat(i)).isDirectory()}catch{return false}},async fileIsReadable(i){try{return await B__default.access(i,B__default.constants.R_OK),!0}catch{return false}},async readFile(i,e="utf-8"){let t=await B__default.readFile(i,{encoding:e,flag:B__default.constants.O_RDONLY});return t.charCodeAt(0)===65279&&(t=t.slice(1)),t},async writeFile(i,e,t="utf-8"){let n=Buffer.from(e,t);await B__default.writeFile(i,n,{encoding:t,flag:B__default.constants.O_WRONLY|B__default.constants.O_CREAT|B__default.constants.O_TRUNC});},async getFileStats(i){return await B__default.stat(i)},async getFileHandle(i,e,t){return await B__default.open(i,e,t)}};});var ft,An=h(()=>{ft=class i{constructor(e,t,n=1e4){this.stdin=e;this.stdout=t;this.defaultTimeoutMs=n;this.stdout.on("data",o=>this.handleData(o)),this.stdin.on("error",()=>{});}static HEADER_SEPARATOR=Buffer.from(`\r
|
|
61
61
|
\r
|