pando-ai 0.3.8 → 0.5.0
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/cli.js +171 -171
- package/dist/watcher-process.js +282 -283
- package/dist/workers/chunk-JWVMGEXN.mjs +4 -0
- package/dist/workers/{chunk-UR7GYDRA.mjs → chunk-KXR6VCP4.mjs} +1 -1
- package/dist/workers/{chunk-Z5RGEDVQ.mjs → chunk-MKW3R262.mjs} +1 -1
- package/dist/workers/{chunk-AYCBSZ56.mjs → chunk-RRIZV7YJ.mjs} +1 -1
- package/dist/workers/indexer-worker.mjs +1 -1
- package/dist/workers/query-db-worker.mjs +1 -1
- package/dist/workers/snapshot-worker.mjs +1 -1
- package/dist/workers/sqlite-writer-worker.mjs +1 -1
- package/package.json +1 -1
- package/resources/tools/generated_pando-tools.json +51 -5
- package/tools/clojure-editor/lib/pando-clojure-editor-standalone.jar +0 -0
- package/tools/clojure-indexer/lib/pando-clojure-indexer-standalone.jar +0 -0
- package/dist/workers/chunk-P74AMJJF.mjs +0 -5
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{b as E}from"./chunk-RRIZV7YJ.mjs";import s from"path";import w from"os";import l from"fs";import x from"crypto";function D(){return process.env.PANDO_DATA_DIR||s.join(w.homedir(),h)}function N(n){let t=n,r=s.parse(t);for(;t.length>r.root.length&&/[\\/]+$/.test(t);)t=t.replace(/[\\/]+$/,"");return t}function g(n){let t=s.resolve(n),r=t;try{let e=l.realpathSync.native;r=typeof e=="function"?e(t):l.realpathSync(t)}catch{}return N(r)}function v(n){let t=n.trim().replace(/\.git$/,"");if(!t)return null;let r=t.match(/^git@([^:]+):(.+)$/);if(r){let e=r[1],i=r[2].replace(/^\/+/,"").split("/");if(i.length>=2)return`${e}/${i[0]}/${i[1]}`}try{let e=new URL(t),o=e.hostname,c=e.pathname.replace(/^\/+/,"").split("/");if(o&&c.length>=2)return`${o}/${c[0]}/${c[1]}`}catch{}return null}function m(n){return x.createHash("sha1").update(n).digest("hex").slice(0,12)}function G(n){return n.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").slice(0,64).replace(/^[-._]+|[-._]+$/g,"")||"workspace"}function C(n,t){let r=s.basename(N(n));return`${G(r)}-${t}`}function P(){return s.join(D(),"workspace-registry.json")}function p(n){try{return l.readFileSync(n,"utf8").trim()}catch{return null}}function O(n){let t=s.join(n,".git");try{let r=l.statSync(t);if(r.isDirectory())return t;if(r.isFile()){let o=p(t)?.match(/^gitdir:\s*(.+)$/i);if(o){let i=o[1].trim();return s.isAbsolute(i)?i:s.resolve(n,i)}}}catch{return null}return null}function L(n){let t=s.join(n,"commondir"),r=p(t);if(!r)return g(n);let e=s.isAbsolute(r)?r:s.resolve(n,r);return g(e)}function T(n){return g(s.join(n,"objects"))}function W(n){let t=g(n);for(;;){let r=s.join(t,".git");if(l.existsSync(r))return t;let e=s.dirname(t);if(e===t)break;t=e}return null}function M(n){let t=g(n),r=W(t);return r?g(r):null}function H(n){let t=s.join(n,"config"),r=p(t);if(!r)return null;let e=r.split(/\r?\n/),o=!1,i=null;for(let c of e){if(c.match(/^\s*\[remote\s+"([^"]+)"\]\s*$/)){o=!0;continue}if(c.startsWith("[")&&(o=!1),o){let a=c.match(/^\s*url\s*=\s*(.+)$/);if(a&&(i=a[1].trim(),i))return i}}return i}function F(n){let t=s.join(n,"HEAD"),r=p(t);if(!r)return{branch:null,commit:null};if(r.startsWith("ref:")){let e=r.replace("ref:","").trim(),o=e.split("/").slice(-1)[0]||null,i=s.join(n,e),c=p(i);if(!c){let u=p(s.join(n,"packed-refs"));if(u){let a=u.split(/\r?\n/).find(f=>f.endsWith(` ${e}`));a&&(c=a.split(" ")[0])}}return{branch:o,commit:c||null}}return{branch:"HEAD",commit:r||null}}function z(){try{let n=l.readFileSync(P(),"utf8"),t=JSON.parse(n);if(t&&t.version===1&&t.entries&&typeof t.entries=="object")return{version:1,entries:t.entries}}catch{}return{version:1,entries:{}}}function J(n){let t=P(),r=s.dirname(t);l.mkdirSync(r,{recursive:!0});let e=`${t}.${process.pid}.${Date.now()}.tmp`;l.writeFileSync(e,`${JSON.stringify(n,null,2)}
|
|
2
|
+
`,"utf8"),l.renameSync(e,t)}function U(n,t){if(!t)return{canonicalRepoRoot:n,gitCommonDir:null,gitObjectDir:null,fingerprint:`non-git:path:${n}`};let r=O(t),e=r?L(r):null,o=e?T(e):null;return{canonicalRepoRoot:t,gitCommonDir:e,gitObjectDir:o,fingerprint:["git",`root:${t}`,`common:${e??""}`,`objects:${o??""}`].join("|")}}function B(n){try{let t=z();t.entries[n.storageRoot]={workspaceId:n.id,workspaceDirName:n.dirName,locationId:n.locationId,incarnationId:n.incarnationId,canonicalProjectRoot:n.canonicalProjectRoot,canonicalRepoRoot:n.canonicalRepoRoot,storageRoot:n.storageRoot,repoIdentity:n.repoIdentity??null,gitCommonDir:n.gitCommonDir??null,gitObjectDir:n.gitObjectDir??null,remote:n.remote??null,branch:n.branch??null,commit:n.commit??null,updatedAt:new Date().toISOString()},J(t)}catch{}}function X(n){let t=g(n),r=M(t),e=r??t,o=r,i=m(e),c=U(e,o),u=m(c.fingerprint),a=`ws-${m(`${i}:${u}`)}`,f=C(e,a);if(!o)return{id:a,dirName:f,locationId:i,incarnationId:u,canonicalProjectRoot:t,canonicalRepoRoot:e,storageRoot:e,gitCommonDir:c.gitCommonDir,gitObjectDir:c.gitObjectDir,repoIdentity:null,remote:null,branch:null,commit:null};let d=O(o),b=d?H(d):null,$=b?v(b):null,_=d?F(d):{branch:null,commit:null};return{id:a,dirName:f,locationId:i,incarnationId:u,canonicalProjectRoot:t,canonicalRepoRoot:o,storageRoot:e,gitCommonDir:c.gitCommonDir,gitObjectDir:c.gitObjectDir,repoIdentity:$??`local:${m(e)}`,remote:b,branch:_.branch,commit:_.commit}}function K(n){let t=X(n);return B(t),s.join(D(),"workspaces",t.dirName)}function mn(n){return s.join(K(n),".pando-snapshots.db")}var h,k=E(()=>{"use strict";h=".pando-data"});k();import j from"fs";import S from"os";import R from"path";import{inspect as V}from"util";function A(){let n=process.env.PANDO_LOG_DIR||process.env.PANDO_WORKSPACE_DATA_DIR;if(n)return n;try{return D()}catch{let r=typeof S.homedir=="function"?S.homedir():process.env.HOME;if(r)return R.join(r,h)}let t=process.env.HOME||process.cwd();return R.join(t,h)}function q(){return R.join(A(),"pando.log")}var I=n=>{if(n==null)return!1;let t=n.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="off"&&t!=="no"},Q=I(process.env.PANDO_LOG_DISABLED),y=!Q&&(process.env.PANDO_DEBUG==null||I(process.env.PANDO_DEBUG)),Z=y&&(process.env.PANDO_INDEX_HOT_LOG==null||I(process.env.PANDO_INDEX_HOT_LOG)),Y=y&&(process.env.PANDO_INDEX_TIMING==null||I(process.env.PANDO_INDEX_TIMING)),nn=new Set(["BatchAnalysisScheduler","ClojureIndex","ClojureIndexer","ThreadedIndexer"]),tn=new Set(["IndexTiming"]);function rn(){try{j.mkdirSync(A(),{recursive:!0})}catch{}}function en(n){if(n!==void 0)try{return typeof n=="string"?n:V(n,{depth:null,breakLength:1/0,maxArrayLength:1/0})}catch{try{return JSON.stringify(n)}catch{return String(n)}}}var on=!1;function _n(){return y}function sn(n){return y?tn.has(n)?Y:!(!Z&&nn.has(n)):!1}function Nn(n,t,r){if(!sn(n))return;let e=new Date().toISOString(),o=en(r),i=o?`[${e}] [${n}] ${t} :: ${o}`:`[${e}] [${n}] ${t}`;if(!on&&!process.env.PANDO_QUIET)try{process.stderr.write(i+`
|
|
3
|
+
`)}catch{}try{rn(),j.appendFileSync(q(),i+`
|
|
4
|
+
`,"utf8")}catch{}}import{createHash as cn}from"crypto";var an=/^-?\d+$/,ln=(1n<<63n)-1n;function un(n){let t=cn("sha1").update(n).digest(),r=0n;for(let e=0;e<8;e+=1)r=r<<8n|BigInt(t[e]);return r&ln}function kn(n){if(n==null)return null;if(typeof n=="bigint")return n;if(typeof n=="number"&&Number.isFinite(n))return BigInt(Math.trunc(n));if(typeof n=="string"){let t=n.trim();if(!t)return null;if(an.test(t))try{return BigInt(t)}catch{return null}return un(t)}return null}export{K as a,mn as b,k as c,_n as d,Nn as e,kn as f};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as gn,d as oe,e as B,f as dt}from"./chunk-P74AMJJF.mjs";import{a as fn}from"./chunk-AYCBSZ56.mjs";var Z={getAbbrev(n,e="ts"){return n},getKindFromAbbrev(n,e="ts"){return n}};function Re(n){let e=`${n.sourceFile}#${n.sourceStart}-${n.sourceEnd}`,t=n.refKind??"",r=n.refName??"",i=n.targetFile??"",s=n.targetStart!=null&&n.targetEnd!=null?`#${n.targetStart}-${n.targetEnd}`:"",o=n.targetNodeId??"",l=`${e}:REF:${t}:${r}|${i}${s}|${o}`;return dt(l)}function pt(n){let e=[],t=new Set,r=i=>{!i?.name||t.has(i.name)||(t.add(i.name),e.push(i))};for(let i of n.exports??[])r(i);for(let i of n.explicitExports??[])r({name:i});for(let i of n.modulePublic??[])r({name:i});return e}function he(n,e,t){let r=new Date().toISOString();return{payload:{lang:n,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,t?.mtime??null,t?.size??null,"failed",r],fts:null,fullyIndexed:!1},fileSize:t?.size,mtime:t?.mtime}}function ye(n){let{lang:e,fileRel:t,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:l,exportKind:c,fullyIndexed:u}=n,m=[],p=o.nodes??[],C=p.map(a=>{let f=`${t}#${a.start}-${a.end}:${Z.getAbbrev(a.kind,e)}`;return(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&a.name?`${f}:${a.name}`:f});for(let a=0;a<p.length;a+=1){let f=p[a],h=f.rawKind??f.kind,N=f.rawKindSource??"cli",g=f.containerRawKind??f.containerKind??null,y=f.containerRawKindSource??(g?"cli":null),E=f.scopeChain??null,P=Array.isArray(E)?JSON.stringify(E):typeof E=="string"?E:null,j=C[a],S=typeof f.parentIndex=="number"?C[f.parentIndex]??null:f.parentNodeId??null,x=f.metadata&&Object.keys(f.metadata).length?JSON.stringify(f.metadata):null;m.push([j,f.name,f.kind,h,N,f.semanticKind??null,f.start,f.end,typeof f.isExported=="number"?f.isExported:0,f.containerKind??null,g,y,typeof f.paramCount=="number"?f.paramCount:null,f.qualifiedName??null,P,f.symbolKey??null,x,S,f.role??null,typeof f.indexInParent=="number"?f.indexInParent:null,typeof f.depth=="number"?f.depth:0,typeof f.bodyStart=="number"?f.bodyStart:null,typeof f.bodyEnd=="number"?f.bodyEnd:null])}let I=[],K=new Set;for(let a of pt(o)){if(!a.name||K.has(a.name))continue;K.add(a.name);let f=a.nodeId??(l?l(a.name):null);I.push([t,a.name,f??null,a.isReexport?1:0,a.reexportFrom??null,a.reexportName??null,a.exportKind??c??"cli",a.targetSymbolKey??null])}let R=[],F=[],O=new Map,U=new Map;for(let a of m){let f=a[0]!=null?String(a[0]):null,h=a[13]!=null?String(a[13]):null,N=a[15]!=null?String(a[15]):null;f&&(h&&!O.has(h)&&O.set(h,f),N&&!U.has(N)&&U.set(N,f))}if(oe()&&e==="clojure"&&(o.references??[]).length>0){let a=Array.from(O.keys()).slice(0,10),f=Array.from(U.keys()).slice(0,10),h=(o.references??[]).slice(0,10).map(g=>g.containerQualifiedName),N={file:t,nodeCount:m.length,refCount:(o.references??[]).length,nodeQualifiedNames:a,nodeSymbolKeys:f,refContainers:h,qualifiedNameMapSize:O.size,symbolKeyMapSize:U.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",N)}catch{}}for(let a of o.references??[]){let f=a.targetNodeId??(l&&a.refName?l(a.refName):null),h=a.targetFile??(f?t:null),N=a.sourceNodeId??(a.containerQualifiedName?O.get(a.containerQualifiedName)??null:null)??(a.containerQualifiedName?U.get(a.containerQualifiedName)??null:null),g=Re({sourceFile:t,sourceStart:a.sourceStart,sourceEnd:a.sourceEnd,refKind:a.refKind,refName:a.refName,targetFile:h??null,targetStart:a.targetStart??null,targetEnd:a.targetEnd??null,targetNodeId:f??a.targetNodeId??null}),y=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;R.push([g,t,N,a.refName??null,a.refKind,a.sourceStart,a.sourceEnd,f??a.targetNodeId??null,h??null,f||a.targetNodeId||a.targetFile?"resolved":"unresolved",a.receiverName??null,typeof a.arity=="number"?a.arity:null,a.containerQualifiedName??null,a.targetSymbolKey??null,a.confidence??null,y])}for(let a of o.symbolMentions??[]){let f=typeof a?.name=="string"?a.name.trim():"";if(!f)continue;let h=typeof a?.mentionKind=="string"&&a.mentionKind.trim().length>0?a.mentionKind.trim():"reference",N=typeof a?.count=="number"&&Number.isFinite(a.count)&&a.count>0?Math.floor(a.count):1;F.push([f,h,a.targetSymbolKey??null,a.containerQualifiedName??null,N])}if(oe()&&e==="clojure"&&R.length>0){let a=R.reduce((h,N)=>h+(N?.[2]!=null?1:0),0),f=R.reduce((h,N)=>h+(N?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:t,refs:R.length,sourceNodeCount:a,containerCount:f,sample:R.slice(0,5).map(h=>({sourceNodeId:h[2]==null?null:String(h[2]),refName:h[3],refKind:h[4],containerQualifiedName:h[12]}))})}catch{}}let z=[];for(let a of o.imports??[])z.push([t,a.module??null,a.isTypeOnly??0]);let V=[];for(let a of o.importBindings??[])V.push([t,a.module??null,a.kind,a.localName,a.importedName,a.isTypeOnly??0]);let fe=new Date().toISOString(),H=[t,i?.mtime??null,i?.size??null,"completed",fe,u?1:0];return{payload:{lang:e,fileRel:t,preDeleted:!!s,exportRows:I,nodeRows:m,referenceRows:R,symbolMentionRows:F,importRows:z,importBindingRows:V,fileRow:H,fts:typeof r=="string"?{blobOid:t,content:r}:null,fullyIndexed:!!u},fileSize:i?.size,mtime:i?.mtime}}var be=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function Be(n){return typeof n=="string"&&be.includes(n)}gn();function mt(){let n=process.env.PANDO_ENABLED_LANGUAGES;if(n&&n.trim().length>0){let t=n.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(Be);if(t.length>0)return ft(t)}return[...be]}function ft(n){let e=new Set;for(let t of n)Be(t)&&e.add(t);return be.filter(t=>e.has(t))}function gt(n){let e=new Set(ft(n)),t={};for(let r of be){if(e.has(r)){t[r]={enabled:!0,source:"embedded"};continue}t[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:t}}import Je from"path";import Nn from"fs";import{Project as Pn,Node as Q}from"ts-morph";import{Node as d,SyntaxKind as ae}from"ts-morph";import*as X from"typescript";import{SyntaxKind as xe}from"ts-morph";var $e={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:xe.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:xe.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:xe.MultiLineCommentTrivia}};function ht(n,e){return n===xe.SingleLineCommentTrivia?$e.LINE_COMMENT:n===xe.MultiLineCommentTrivia&&e.startsWith("/**")?$e.JSDOC_COMMENT:$e.BLOCK_COMMENT}import{Node as T}from"ts-morph";var yt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},bt=(n,e)=>T.isFunctionDeclaration(n)||T.isFunctionExpression(n)||T.isArrowFunction(n)?{kind:"Function",semanticKind:"function"}:T.isGetAccessorDeclaration(n)||T.isSetAccessorDeclaration(n)?{kind:"Method",semanticKind:"property"}:T.isMethodDeclaration(n)||T.isMethodSignature(n)||T.isConstructorDeclaration(n)?{kind:"Method",semanticKind:"method"}:T.isClassDeclaration(n)||T.isClassExpression(n)?{kind:"Class",semanticKind:"class"}:T.isInterfaceDeclaration(n)?{kind:"Interface",semanticKind:"interface"}:T.isEnumDeclaration(n)?{kind:"Enum",semanticKind:"enum"}:T.isEnumMember(n)?{kind:"EnumMember",semanticKind:"enum"}:T.isTypeAliasDeclaration(n)?{kind:"TypeAlias",semanticKind:"type"}:T.isModuleDeclaration(n)?{kind:"Namespace",semanticKind:"namespace"}:T.isPropertyDeclaration(n)||T.isPropertySignature(n)?{kind:"Field",semanticKind:"property"}:T.isVariableDeclaration(n)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function xt(n){try{let e=n.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function Ie(n){let e=xt(n),t=bt(n,e);return{kind:t.kind,semanticKind:t.semanticKind,rawKind:e,rawKindSource:yt.TS_MORPH}}function St(n){let e=xt(n);return{kind:bt(n,e).kind,rawKind:e,rawKindSource:yt.TS_MORPH}}function Ae(n,e){if(!n.kind||!n.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!n.rawKind||!n.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!n.rawKindSource||!String(n.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function hn(n){if(n.kind==="local"){let r=n.isDefault?"default":n.name;return r?{name:r,priority:n.isDefault?4:3}:null}if(n.kind==="alias")return n.exported?{name:n.exported,priority:2}:null;let e=n.isNamespace??!1,t=n.alias||n.name||(e?"*":null);return t?{name:t,priority:e?0:1}:null}function yn(n){if(n.length<2)return n;let e=new Map;for(let t of n){let r=hn(t);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:t,priority:r.priority})}return Array.from(e.values()).map(t=>t.record)}function Se(n){try{if(n&&typeof n.getName=="function"){let e=n.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function bn(n){try{let e=n?.getBody?.();if(!e||typeof e.getStart!="function"||typeof e.getEnd!="function")return null;let t=typeof e.getKindName=="function"?String(e.getKindName()):"",r=t==="Block"||t==="ModuleBlock",i=e.getStart(),s=e.getEnd(),o=r?i+1:i,l=r?s-1:s;return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}catch{return null}}function xn(n){let e=n.getParent?.();if(!e)return null;try{if(d.isIfStatement(e)){if(e.getExpression()===n)return"condition";if(e.getThenStatement()===n)return"then";if(e.getElseStatement()===n)return"else"}if(d.isReturnStatement(e)&&e.getExpression?.()===n)return"value";if(d.isVariableDeclaration(e)){if(e.getNameNode?.()===n)return"name";if(e.getInitializer?.()===n)return"initializer"}if(d.isCallExpression(e)||d.isNewExpression(e)){if(e.getExpression?.()===n)return"callee";if((e.getArguments?.()??[]).indexOf(n)>=0)return"argument"}if(d.isPropertyAccessExpression(e)){if(e.getExpression()===n)return"object";if(e.getNameNode()===n)return"property"}}catch{return null}return null}function ze(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}function Sn(n){try{if(d.isFunctionDeclaration(n)||d.isMethodDeclaration(n)||d.isConstructorDeclaration(n)||d.isFunctionExpression(n)||d.isArrowFunction(n)){let e=n.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Cn(n){try{return d.isIdentifier(n)?n.getSymbol():d.isPropertyAccessExpression(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol?.()}catch{return}}function ke(n,e){try{return typeof n?.hasModifier=="function"&&n.hasModifier(e)}catch{return!1}}function Ct(n){try{return n.getModuleSpecifierValue?.()??null}catch{try{return n.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function vn(n,e,t){if(!d.isImportDeclaration(n))return;let i={moduleSpecifier:Ct(n),isTypeOnly:n.isTypeOnly(),namedImports:[]};try{let s=n.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,t(o,s)}}catch{}try{let s=n.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,t(o,s)}}catch{}try{n.getNamedImports().forEach(s=>{try{let o=s.getName(),l=s.getAliasNode(),c=l?l.getText():void 0;o&&(i.namedImports.push({name:o,alias:c||void 0}),t(c||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function En(n,e){if(d.isExportDeclaration(n)){let t=Ct(n);if(t){if(n.getNamedExports().length>0)try{n.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:t,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(n.isNamespaceExport())try{let i=n.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:t,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0});return}try{n.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(d.isExportAssignment(n))try{let t=n.getExpression();if(t&&d.isIdentifier(t)){let r=t.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function wn(n,e,t,r){if(!ke(n,ae.ExportKeyword))return;let i=ke(n,ae.DefaultKeyword);if(d.isVariableStatement(n)){try{let s=n.getDeclarationList().getDeclarations();for(let o of s){let l=Se(o)??o.getName?.()??null;if(l){t(l,o);let c=r(o);c&&e.push({kind:"local",name:l,isDefault:i,nodeId:c})}}}catch{}return}if(d.isFunctionDeclaration(n)||d.isClassDeclaration(n)||d.isInterfaceDeclaration(n)||d.isEnumDeclaration(n)||d.isTypeAliasDeclaration(n)||d.isModuleDeclaration(n)){let s=Se(n)||(i?"default":null),o=r(n);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function vt(n,e,t,r){let i=[],s=[],o=[],l=new Set,c=new Map,u=[],m=[],C=(r?.emitMode??"light")==="full",I=new Map,K=new Map,R=new Map,F=[{node:n,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],O=a=>{if(!a)return null;try{return e(a)}catch{return null}},U=a=>{let f=a.getParent?.();for(;f;){let h=I.get(f);if(h)return h;f=f.getParent?.()}return null},z=(a,f)=>{if(a&&(l.has(a)||l.add(a),f&&!c.has(a))){let h=O(f);h&&c.set(a,h)}},V=a=>d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isInterfaceDeclaration(a)||d.isEnumDeclaration(a)||d.isEnumMember(a)||d.isTypeAliasDeclaration(a)||d.isModuleDeclaration(a)||d.isMethodDeclaration(a)||d.isMethodSignature(a)||d.isPropertyDeclaration(a)||d.isPropertySignature(a)||d.isGetAccessorDeclaration(a)||d.isSetAccessorDeclaration(a)||d.isConstructorDeclaration(a)||d.isVariableDeclaration(a),fe=a=>d.isSourceFile(a)||d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isMethodDeclaration(a)||d.isConstructorDeclaration(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isModuleDeclaration(a),H=a=>{let f=Se(a);if(f)return f;if(d.isConstructorDeclaration(a))return"constructor";if(d.isArrowFunction(a)||d.isFunctionExpression(a)){let h=a.getParent();try{if(d.isVariableDeclaration(h))return h.getName();if(d.isPropertyAssignment(h)||d.isPropertyDeclaration(h)||d.isPropertySignature(h))return h.getName?.()??null;if(d.isShorthandPropertyAssignment(h))return h.getNameNode()?.getText()??null;if(d.isExportAssignment(h))return"default"}catch{}}if(d.isEnumMember(a))try{return a.getName()}catch{return null}if(d.isVariableDeclaration(a))try{return a.getName()}catch{return null}return null},Y=a=>{let f=F[F.length-1],h=f?.id??null,N=f?.kind??"module",g=f?.name??null;if(d.isImportDeclaration(a))vn(a,u,z);else if(d.isImportEqualsDeclaration(a))try{let S=a.getModuleReference();if(S&&d.isExternalModuleReference(S)){let x=S.getExpression(),v;if(x&&d.isStringLiteral(x))v=x.getLiteralText();else if(x){let w=x.getText();v=typeof w=="string"?w.replace(/^['"]|['"]$/g,""):void 0}if(v){let M=a.getNameNode()?.getText(),_={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};M&&(_.defaultImport=M,z(M,a)),u.push(_)}}}catch{}(d.isExportDeclaration(a)||d.isExportAssignment(a))&&En(a,m),wn(a,m,z,O);let y=V(a),E=C||y,P=y?H(a):null;if(E){let S=e(a);y&&s.push({nodeId:S,node:a});let x=U(a),v=x==null?null:K.get(x)??0;x!=null&&v!=null&&K.set(x,v+1),I.set(a,S);let w=x?(R.get(x)??-1)+1:0;R.set(S,w);let M=ke(a,ae.ExportKeyword)||f?.isExported||!1,_=y?a.getNameNode?.()?.getText?.()??null:null,D=P??(y?Se(a)??_:Se(a));P?z(P,a):D&&z(D,a);let A=ze(a),L=Sn(a),k=Ie(a);Ae(k,{source:"ts-node-collector",file:n.getFilePath(),name:D??null});let J=bn(a);i.push({nodeId:S,nodeName:D??null,containerId:h,containerKind:N,containerRawKind:f?.rawKind??null,containerRawKindSource:f?.rawKindSource??null,containerName:g,isExported:M,kind:k.kind,rawKind:k.rawKind,rawKindSource:k.rawKindSource,semanticKind:k.semanticKind??null,start:A.start,end:A.end,paramCount:L,metadata:null,parentNodeId:x,role:xn(a),indexInParent:v,depth:w,bodyStart:J?.start??null,bodyEnd:J?.end??null})}if(d.isCallExpression(a)||d.isNewExpression(a)){let S=a.getExpression(),x=null,v,w;try{if(w=Cn(S),d.isIdentifier(S))x=S.getText();else if(d.isPropertyAccessExpression(S)){x=S.getName();let D=S.getExpression();d.isIdentifier(D)&&(v=D.getText())}}catch{}let M="";try{M=S.getText()}catch{}let _=ze(a);if(o.push({name:x,kind:d.isNewExpression(a)?"new":"call",containerId:h,containerKind:N,containerName:g,expression:M,objectName:v,symbol:w,start:_.start,end:_.end}),d.isCallExpression(a))try{if(d.isIdentifier(S)&&S.getText()==="require"){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}if(L){let k={moduleSpecifier:L,isTypeOnly:!1,namedImports:[]},J=a.getParent();if(J&&d.isVariableDeclaration(J)){let Pe=J.getNameNode();try{if(d.isIdentifier(Pe)){let ge=Pe.getText();ge&&(k.defaultImport=ge,z(ge,J))}}catch{}}u.push(k)}}else if(S?.getKind?.()===ae.ImportKeyword){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}L&&u.push({moduleSpecifier:L,isTypeOnly:!1,namedImports:[]})}}catch{}}if(d.isCallExpression(a)){let S=a.getExpression();try{if(d.isIdentifier(S)&&S.getText()==="require"){let x=a.getParent();if(!(x&&d.isExternalModuleReference(x))){let w=a.getArguments()[0],M;if(w&&(d.isStringLiteral(w)||d.isNoSubstitutionTemplateLiteral(w)))try{M=w.getLiteralText()}catch{M=w.getText().replace(/^['"]|['"]$/g,"")}if(M){let _={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};if(x&&d.isVariableDeclaration(x)){let D=x.getNameNode();try{if(d.isIdentifier(D)){let A=D.getText();A&&(_.defaultImport=A,z(A,x))}}catch{}}u.push(_)}}}else if(S?.getKind?.()===ae.ImportKeyword){let v=a.getArguments()[0],w;if(v&&(d.isStringLiteral(v)||d.isNoSubstitutionTemplateLiteral(v)))try{w=v.getLiteralText()}catch{w=v.getText().replace(/^['"]|['"]$/g,"")}w&&u.push({moduleSpecifier:w,isTypeOnly:!1,namedImports:[]})}}catch{}}let j=!1;if(fe(a)){let S=O(a)??e(a),x=St(a);F.push({node:a,id:S,kind:x.kind,rawKind:x.rawKind,rawKindSource:x.rawKindSource,name:P??g,isExported:ke(a,ae.ExportKeyword)||f?.isExported||!1}),j=!0}a.forEachChild(Y),j&&F.pop()};if(C){let a=e(n);I.set(n,a),R.set(a,0);let f=ze(n);i.push({nodeId:a,nodeName:n.getBaseName?.()??null,containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:"SourceFile",rawKind:"SourceFile",rawKindSource:"ts-morph",semanticKind:"file",start:f.start,end:f.end,paramCount:null,metadata:null,parentNodeId:null,role:null,indexInParent:null,depth:0,bodyStart:f.start,bodyEnd:f.end})}if(n.forEachChild(Y),r?.includeComments===!0||C||process.env.AST_INDEX_COMMENTS==="1")try{let a=n.getFullText(),f=X.createScanner(X.ScriptTarget.Latest,!1,X.LanguageVariant.Standard,a),h=new Set;for(let N=f.scan();N!==X.SyntaxKind.EndOfFileToken;N=f.scan()){if(N!==X.SyntaxKind.SingleLineCommentTrivia&&N!==X.SyntaxKind.MultiLineCommentTrivia)continue;let g=f.getTokenPos(),y=f.getTextPos(),E=`${g}-${y}`;if(h.has(E)||(h.add(E),t.has(E)))continue;t.add(E);let P=a.substring(g,y),j=ht(N,P),x=e({getKindName:()=>j.name,getKind:()=>j.kind,getPos:()=>g,getEnd:()=>y,getStart:()=>g,getFullStart:()=>g,getText:()=>P,getSourceFile:()=>n,getParent:()=>n,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM"),v=I.get(n)??null,w=C&&v!=null?K.get(v)??0:null;C&&v!=null&&w!=null&&K.set(v,w+1),i.push({nodeId:x,nodeName:P.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:j.name,rawKind:j.name,rawKindSource:"ts-morph",semanticKind:null,start:g,end:y,paramCount:null,metadata:null,parentNodeId:v,role:"comment",indexInParent:w,depth:C?1:0,bodyStart:null,bodyEnd:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:l,localDeclarations:c,imports:u,exports:yn(m)}}function Et(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}var Rn=100;function In(n,e,t,r){let{start:i,end:s}=Et(e),o=Ie(e);Ae(o,{source:"ts-node-id",file:n,kind:o.kind});let l=r||Z.getAbbrev(o.kind,t);return`${n}#${i}-${s}:${l}`}function An(n,e){return Je.relative(n,e).replace(/\\/g,"/")}function wt(n,e){if(!n)return null;let t=n;try{let m=n.getAliasedSymbol();m&&(t=m)}catch{}let r=[];try{r=t.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((m,p)=>{let C=m.getSourceFile().getFilePath(),I=p.getSourceFile().getFilePath();if(C!==I)return C.localeCompare(I);let K=m.getStart(!1),R=p.getStart(!1);return K!==R?K-R:m.getEnd()-p.getEnd()})[0],o=An(e,s.getSourceFile().getFilePath()),l=s.getStart(!1),c=s.getEnd(),u="";try{u=t.getEscapedName()}catch{try{u=t.getName()}catch{u=""}}return`${o}#${l}-${c}:${u}`}function kn(n){try{return Q.isVariableDeclaration(n)||Q.isEnumMember(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol()}catch{return}}function Mn(n,e){let t=n.getDescendantAtPos(e);if(!t)return;let r=t;if(!Q.isCallExpression(r)&&!Q.isNewExpression(r)&&(r=t.getFirstAncestor(s=>Q.isCallExpression(s)||Q.isNewExpression(s))??void 0),!r||!Q.isCallExpression(r)&&!Q.isNewExpression(r))return;let i=r.getExpression();try{return Q.isIdentifier(i)?i.getSymbol():Q.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function Dn(n){let{sf:e,fileRel:t,content:r,preDeleted:i,meta:s,projectRoot:o,lang:l}=n,c=n.emitMode??"light",m=vt(e,(g,y)=>In(t,g,l,y),new Set,{includeComments:c==="full",emitMode:c}),p=new Map;for(let{nodeId:g,node:y}of m.symbolCandidateNodes){let E=wt(kn(y),o);E&&(p.has(g)||p.set(g,E))}let C=[],I=new Map,K=m.exports.filter(g=>g.kind!=="reexport"),R=m.exports.filter(g=>g.kind==="reexport");for(let g of K)if(g.kind==="local"){let y=g.isDefault?"default":g.name;if(!y||I.has(y))continue;let E=g.nodeId;C.push([t,y,E,0,null,null,g.isDefault?"default":"named"]),I.set(y,E)}else if(g.kind==="alias"){let y=g.exported;if(!y||I.has(y))continue;C.push([t,y,null,0,null,g.local,"alias"]),I.set(y,"alias")}for(let g of R){let y=g.moduleSpecifier;if(!y)continue;let E=y;if(g.isNamespace){let P=g.alias||"*";if(I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_star"]),I.set(P,"reexport")}else{let P=g.alias||g.name;if(!P||I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_named"]),I.set(P,"reexport")}}let F=[],O=typeof r=="string"?r:null;if(O==null)try{let g=e.getFullText();O=typeof g=="string"?g:null}catch{O=null}for(let g of m.nodes){let{nodeId:y,nodeName:E,containerKind:P,containerRawKind:j,containerRawKindSource:S,isExported:x,kind:v,rawKind:w,rawKindSource:M,semanticKind:_,start:D,end:A,paramCount:L,metadata:k,parentNodeId:J,role:Pe,indexInParent:ge,depth:cn,bodyStart:un,bodyEnd:dn}=g,pn=k&&Object.keys(k).length?JSON.stringify(k):null,mn=p.get(y)??null;F.push([y,E??null,v,w??v,M??null,_??null,D,A,x?1:0,P??"module",j??P??"module",S??null,L,null,null,mn,pn,J??null,Pe??null,ge??null,cn??0,un??null,dn??null])}let U=[];for(let g of m.references){let{name:y,kind:E,containerId:P,containerName:j,expression:S,objectName:x,start:v,end:w}=g,M=null,_=null,D=wt(g.symbol??Mn(e,v),o),A=y?m.localDeclarations.get(y):void 0;A&&(M=A,_=t,D||(D=p.get(A)??null));let L=Re({sourceFile:t,sourceStart:v,sourceEnd:w,refKind:E,refName:y,targetFile:_,targetNodeId:M}),k={};S&&(k.expression=S),x&&(k.objectName=x),j&&(k.containerName=j);let J=Object.keys(k).length?JSON.stringify(k):null;U.push([L,t,P,y,E,v,w,M,_,M?"resolved":"unresolved",x??null,null,null,D,J])}let z=[],V=[];for(let g of m.imports){let y=g.moduleSpecifier??null;z.push([t,y,g.isTypeOnly?1:0]),g.defaultImport&&V.push([t,y,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&V.push([t,y,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let E of g.namedImports){let P=E.alias||E.name;V.push([t,y,"named",P,E.name,g.isTypeOnly?1:0])}}let fe=Je.join(o,t),H=s?.size,Y=s?.mtime;if(H===void 0||Y===void 0)try{let g=Nn.statSync(fe);H=g.size,Y=Math.floor(g.mtimeMs)}catch{}let a=new Date().toISOString(),f=c==="full",h=[t,Y??null,H??null,"completed",a,f?1:0],N=null;if(typeof O=="string")N={blobOid:t,content:O};else try{let g=e.getFullText?.();typeof g=="string"&&(N={blobOid:t,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${t}:`,g?.message??g)}return{payload:{lang:l,fileRel:t,preDeleted:i,exportRows:C,nodeRows:F,referenceRows:U,importRows:z,importBindingRows:V,fileRow:h,fts:N,fullyIndexed:f},fileSize:H,mtime:Y}}var qe=class{constructor(e,t){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=t}getProject(){return this.project||(this.project=new Pn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let t=this.getProject(),r;try{let i=t.createSourceFile(Je.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await Dn({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang,emitMode:e.emitMode??"light"})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=Rn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function Tn(n){return n==="ts"?[".ts",".tsx",".mts",".cts"]:n==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function We(n){return{id:n,extensions:Tn(n),indexingMode:"worker",createIndexer:e=>new qe(e,n)}}import De from"fs";import ee from"path";import{spawn as Ln}from"child_process";import Kn from"fs";var le=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,t){let r=this.cache.get(e);if(!r)return null;let i=t?.mtime??null,s=t?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,t,r){let i=t?.mtime??null,s=t?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Ue=class{constructor(e,t,r,i){this.projectRoot=e;this.lang=t;this.parse=r;this.exportKind=i;this.cache=new le}async process(e){let t=e.meta?.mtime,r=e.meta?.size;if(t==null||r==null)try{let o=Kn.statSync(e.absPath);t=Math.floor(o.mtimeMs),r=o.size}catch{}let i=e.emitMode==="full"?null:this.cache.get(e.absPath,{mtime:t,size:r});if(i)return ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Nt(e.relPath,i,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:t,size:r},projectRoot:this.projectRoot,lang:this.lang,emitMode:e.emitMode??"light"})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return he(this.lang,e.relPath,{mtime:t,size:r})}return!s||s.error?he(this.lang,e.relPath,{mtime:t,size:r}):(e.emitMode!=="full"&&this.cache.set(e.absPath,{mtime:t,size:r},s),ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Nt(e.relPath,s,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"}))}};function Nt(n,e,t){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${n}#${i.start}-${i.end}:${Z.getAbbrev(i.kind,t)}`;r.set(i.name,s)}return i=>r.get(i)??null}function G(n){return{id:n.id,extensions:n.extensions,indexingMode:"worker",createIndexer:e=>new Ue(e,n.id,n.parse,n.exportKind),resolveSpan:n.resolve?async(e,t,r)=>n.resolve({projectRoot:e,absPath:t,nodePath:r,lang:n.id}):void 0}}import _n from"fs";import Me from"path";var Xe=null;function On(n){for(let e of n)if(_n.existsSync(e))return e;return null}function q(n){let e=Xe?.toolsRoot??process.env.PANDO_TOOLS_ROOT,t=Xe?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=Xe?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?Me.join(e,n):null,t?Me.join(t,"tools",n):null,r?Me.join(r,"tools",n):null,Me.resolve(process.cwd(),"tools",n)].filter(s=>!!s);return On(i)}function W(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
|
|
1
|
+
import{c as gn,d as oe,e as B,f as dt}from"./chunk-JWVMGEXN.mjs";import{a as fn}from"./chunk-RRIZV7YJ.mjs";var Z={getAbbrev(n,e="ts"){return n},getKindFromAbbrev(n,e="ts"){return n}};function Re(n){let e=`${n.sourceFile}#${n.sourceStart}-${n.sourceEnd}`,t=n.refKind??"",r=n.refName??"",i=n.targetFile??"",s=n.targetStart!=null&&n.targetEnd!=null?`#${n.targetStart}-${n.targetEnd}`:"",o=n.targetNodeId??"",l=`${e}:REF:${t}:${r}|${i}${s}|${o}`;return dt(l)}function pt(n){let e=[],t=new Set,r=i=>{!i?.name||t.has(i.name)||(t.add(i.name),e.push(i))};for(let i of n.exports??[])r(i);for(let i of n.explicitExports??[])r({name:i});for(let i of n.modulePublic??[])r({name:i});return e}function he(n,e,t){let r=new Date().toISOString();return{payload:{lang:n,fileRel:e,preDeleted:!1,exportRows:[],nodeRows:[],referenceRows:[],symbolMentionRows:[],importRows:[],importBindingRows:[],fileRow:[e,t?.mtime??null,t?.size??null,"failed",r],fts:null,fullyIndexed:!1},fileSize:t?.size,mtime:t?.mtime}}function ye(n){let{lang:e,fileRel:t,content:r,meta:i,preDeleted:s,parsed:o,resolveNodeId:l,exportKind:c,fullyIndexed:u}=n,m=[],p=o.nodes??[],C=p.map(a=>{let f=`${t}#${a.start}-${a.end}:${Z.getAbbrev(a.kind,e)}`;return(e==="c"||e==="cpp"||e==="java"||e==="clojure")&&a.name?`${f}:${a.name}`:f});for(let a=0;a<p.length;a+=1){let f=p[a],h=f.rawKind??f.kind,N=f.rawKindSource??"cli",g=f.containerRawKind??f.containerKind??null,y=f.containerRawKindSource??(g?"cli":null),E=f.scopeChain??null,P=Array.isArray(E)?JSON.stringify(E):typeof E=="string"?E:null,j=C[a],S=typeof f.parentIndex=="number"?C[f.parentIndex]??null:f.parentNodeId??null,x=f.metadata&&Object.keys(f.metadata).length?JSON.stringify(f.metadata):null;m.push([j,f.name,f.kind,h,N,f.semanticKind??null,f.start,f.end,typeof f.isExported=="number"?f.isExported:0,f.containerKind??null,g,y,typeof f.paramCount=="number"?f.paramCount:null,f.qualifiedName??null,P,f.symbolKey??null,x,S,f.role??null,typeof f.indexInParent=="number"?f.indexInParent:null,typeof f.depth=="number"?f.depth:0,typeof f.bodyStart=="number"?f.bodyStart:null,typeof f.bodyEnd=="number"?f.bodyEnd:null])}let I=[],K=new Set;for(let a of pt(o)){if(!a.name||K.has(a.name))continue;K.add(a.name);let f=a.nodeId??(l?l(a.name):null);I.push([t,a.name,f??null,a.isReexport?1:0,a.reexportFrom??null,a.reexportName??null,a.exportKind??c??"cli",a.targetSymbolKey??null])}let R=[],F=[],O=new Map,U=new Map;for(let a of m){let f=a[0]!=null?String(a[0]):null,h=a[13]!=null?String(a[13]):null,N=a[15]!=null?String(a[15]):null;f&&(h&&!O.has(h)&&O.set(h,f),N&&!U.has(N)&&U.set(N,f))}if(oe()&&e==="clojure"&&(o.references??[]).length>0){let a=Array.from(O.keys()).slice(0,10),f=Array.from(U.keys()).slice(0,10),h=(o.references??[]).slice(0,10).map(g=>g.containerQualifiedName),N={file:t,nodeCount:m.length,refCount:(o.references??[]).length,nodeQualifiedNames:a,nodeSymbolKeys:f,refContainers:h,qualifiedNameMapSize:O.size,symbolKeyMapSize:U.size};try{console.error("[CliPayload][CLOJURE-DEBUG] source_node_id lookup context",N)}catch{}}for(let a of o.references??[]){let f=a.targetNodeId??(l&&a.refName?l(a.refName):null),h=a.targetFile??(f?t:null),N=a.sourceNodeId??(a.containerQualifiedName?O.get(a.containerQualifiedName)??null:null)??(a.containerQualifiedName?U.get(a.containerQualifiedName)??null:null),g=Re({sourceFile:t,sourceStart:a.sourceStart,sourceEnd:a.sourceEnd,refKind:a.refKind,refName:a.refName,targetFile:h??null,targetStart:a.targetStart??null,targetEnd:a.targetEnd??null,targetNodeId:f??a.targetNodeId??null}),y=a.metadata&&Object.keys(a.metadata).length?JSON.stringify(a.metadata):null;R.push([g,t,N,a.refName??null,a.refKind,a.sourceStart,a.sourceEnd,f??a.targetNodeId??null,h??null,f||a.targetNodeId||a.targetFile?"resolved":"unresolved",a.receiverName??null,typeof a.arity=="number"?a.arity:null,a.containerQualifiedName??null,a.targetSymbolKey??null,a.confidence??null,y])}for(let a of o.symbolMentions??[]){let f=typeof a?.name=="string"?a.name.trim():"";if(!f)continue;let h=typeof a?.mentionKind=="string"&&a.mentionKind.trim().length>0?a.mentionKind.trim():"reference",N=typeof a?.count=="number"&&Number.isFinite(a.count)&&a.count>0?Math.floor(a.count):1;F.push([f,h,a.targetSymbolKey??null,a.containerQualifiedName??null,N])}if(oe()&&e==="clojure"&&R.length>0){let a=R.reduce((h,N)=>h+(N?.[2]!=null?1:0),0),f=R.reduce((h,N)=>h+(N?.[12]!=null?1:0),0);try{console.error("[CliPayload] clojure source-node summary",{file:t,refs:R.length,sourceNodeCount:a,containerCount:f,sample:R.slice(0,5).map(h=>({sourceNodeId:h[2]==null?null:String(h[2]),refName:h[3],refKind:h[4],containerQualifiedName:h[12]}))})}catch{}}let z=[];for(let a of o.imports??[])z.push([t,a.module??null,a.isTypeOnly??0]);let V=[];for(let a of o.importBindings??[])V.push([t,a.module??null,a.kind,a.localName,a.importedName,a.isTypeOnly??0]);let fe=new Date().toISOString(),H=[t,i?.mtime??null,i?.size??null,"completed",fe,u?1:0];return{payload:{lang:e,fileRel:t,preDeleted:!!s,exportRows:I,nodeRows:m,referenceRows:R,symbolMentionRows:F,importRows:z,importBindingRows:V,fileRow:H,fts:typeof r=="string"?{blobOid:t,content:r}:null,fullyIndexed:!!u},fileSize:i?.size,mtime:i?.mtime}}var be=["ts","js","python","c","cpp","csharp","dart","java","clojure"];function Be(n){return typeof n=="string"&&be.includes(n)}gn();function mt(){let n=process.env.PANDO_ENABLED_LANGUAGES;if(n&&n.trim().length>0){let t=n.split(",").map(r=>r.trim()).filter(r=>r.length>0).filter(Be);if(t.length>0)return ft(t)}return[...be]}function ft(n){let e=new Set;for(let t of n)Be(t)&&e.add(t);return be.filter(t=>e.has(t))}function gt(n){let e=new Set(ft(n)),t={};for(let r of be){if(e.has(r)){t[r]={enabled:!0,source:"embedded"};continue}t[r]={enabled:!1,source:"none",reason:"disabled by language support config"}}return{byLanguage:t}}import Je from"path";import Nn from"fs";import{Project as Pn,Node as Q}from"ts-morph";import{Node as d,SyntaxKind as ae}from"ts-morph";import*as X from"typescript";import{SyntaxKind as xe}from"ts-morph";var $e={LINE_COMMENT:{kind:9001,name:"LineComment",triviaKind:xe.SingleLineCommentTrivia},BLOCK_COMMENT:{kind:9002,name:"BlockComment",triviaKind:xe.MultiLineCommentTrivia},JSDOC_COMMENT:{kind:9003,name:"JSDocComment",triviaKind:xe.MultiLineCommentTrivia}};function ht(n,e){return n===xe.SingleLineCommentTrivia?$e.LINE_COMMENT:n===xe.MultiLineCommentTrivia&&e.startsWith("/**")?$e.JSDOC_COMMENT:$e.BLOCK_COMMENT}import{Node as T}from"ts-morph";var yt={TS_MORPH:"ts-morph",PYTHON_AST:"python-ast",CLANG:"clang",ROSLYN:"roslyn",JAVA_AST:"java-ast",CLI:"cli",UNKNOWN:"unknown"},bt=(n,e)=>T.isFunctionDeclaration(n)||T.isFunctionExpression(n)||T.isArrowFunction(n)?{kind:"Function",semanticKind:"function"}:T.isGetAccessorDeclaration(n)||T.isSetAccessorDeclaration(n)?{kind:"Method",semanticKind:"property"}:T.isMethodDeclaration(n)||T.isMethodSignature(n)||T.isConstructorDeclaration(n)?{kind:"Method",semanticKind:"method"}:T.isClassDeclaration(n)||T.isClassExpression(n)?{kind:"Class",semanticKind:"class"}:T.isInterfaceDeclaration(n)?{kind:"Interface",semanticKind:"interface"}:T.isEnumDeclaration(n)?{kind:"Enum",semanticKind:"enum"}:T.isEnumMember(n)?{kind:"EnumMember",semanticKind:"enum"}:T.isTypeAliasDeclaration(n)?{kind:"TypeAlias",semanticKind:"type"}:T.isModuleDeclaration(n)?{kind:"Namespace",semanticKind:"namespace"}:T.isPropertyDeclaration(n)||T.isPropertySignature(n)?{kind:"Field",semanticKind:"property"}:T.isVariableDeclaration(n)?{kind:"Variable",semanticKind:"variable"}:{kind:e,semanticKind:null};function xt(n){try{let e=n.getKindName?.();if(typeof e=="string"&&e.trim())return e}catch{}return"Unknown"}function Ie(n){let e=xt(n),t=bt(n,e);return{kind:t.kind,semanticKind:t.semanticKind,rawKind:e,rawKindSource:yt.TS_MORPH}}function St(n){let e=xt(n);return{kind:bt(n,e).kind,rawKind:e,rawKindSource:yt.TS_MORPH}}function Ae(n,e){if(!n.kind||!n.kind.trim())throw new Error(`Invalid normalized kind: missing kind ${e?JSON.stringify(e):""}`);if(!n.rawKind||!n.rawKind.trim())throw new Error(`Invalid normalized kind: missing rawKind ${e?JSON.stringify(e):""}`);if(!n.rawKindSource||!String(n.rawKindSource).trim())throw new Error(`Invalid normalized kind: missing rawKindSource ${e?JSON.stringify(e):""}`)}function hn(n){if(n.kind==="local"){let r=n.isDefault?"default":n.name;return r?{name:r,priority:n.isDefault?4:3}:null}if(n.kind==="alias")return n.exported?{name:n.exported,priority:2}:null;let e=n.isNamespace??!1,t=n.alias||n.name||(e?"*":null);return t?{name:t,priority:e?0:1}:null}function yn(n){if(n.length<2)return n;let e=new Map;for(let t of n){let r=hn(t);if(!r)continue;let i=e.get(r.name);(!i||r.priority>i.priority)&&e.set(r.name,{record:t,priority:r.priority})}return Array.from(e.values()).map(t=>t.record)}function Se(n){try{if(n&&typeof n.getName=="function"){let e=n.getName();if(typeof e=="string"&&e.length>0)return e}}catch{}return null}function bn(n){try{let e=n?.getBody?.();if(!e||typeof e.getStart!="function"||typeof e.getEnd!="function")return null;let t=typeof e.getKindName=="function"?String(e.getKindName()):"",r=t==="Block"||t==="ModuleBlock",i=e.getStart(),s=e.getEnd(),o=r?i+1:i,l=r?s-1:s;return!Number.isFinite(o)||!Number.isFinite(l)||l<o?null:{start:o,end:l}}catch{return null}}function xn(n){let e=n.getParent?.();if(!e)return null;try{if(d.isIfStatement(e)){if(e.getExpression()===n)return"condition";if(e.getThenStatement()===n)return"then";if(e.getElseStatement()===n)return"else"}if(d.isReturnStatement(e)&&e.getExpression?.()===n)return"value";if(d.isVariableDeclaration(e)){if(e.getNameNode?.()===n)return"name";if(e.getInitializer?.()===n)return"initializer"}if(d.isCallExpression(e)||d.isNewExpression(e)){if(e.getExpression?.()===n)return"callee";if((e.getArguments?.()??[]).indexOf(n)>=0)return"argument"}if(d.isPropertyAccessExpression(e)){if(e.getExpression()===n)return"object";if(e.getNameNode()===n)return"property"}}catch{return null}return null}function ze(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}function Sn(n){try{if(d.isFunctionDeclaration(n)||d.isMethodDeclaration(n)||d.isConstructorDeclaration(n)||d.isFunctionExpression(n)||d.isArrowFunction(n)){let e=n.getParameters?.();if(Array.isArray(e))return e.length}}catch{}return null}function Cn(n){try{return d.isIdentifier(n)?n.getSymbol():d.isPropertyAccessExpression(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol?.()}catch{return}}function ke(n,e){try{return typeof n?.hasModifier=="function"&&n.hasModifier(e)}catch{return!1}}function Ct(n){try{return n.getModuleSpecifierValue?.()??null}catch{try{return n.getModuleSpecifier?.()?.getLiteralText?.()??null}catch{return null}}}function vn(n,e,t){if(!d.isImportDeclaration(n))return;let i={moduleSpecifier:Ct(n),isTypeOnly:n.isTypeOnly(),namedImports:[]};try{let s=n.getDefaultImport();if(s){let o=s.getText();i.defaultImport=o,t(o,s)}}catch{}try{let s=n.getNamespaceImport();if(s){let o=s.getText();i.namespaceImport=o,t(o,s)}}catch{}try{n.getNamedImports().forEach(s=>{try{let o=s.getName(),l=s.getAliasNode(),c=l?l.getText():void 0;o&&(i.namedImports.push({name:o,alias:c||void 0}),t(c||o,s.getNameNode()))}catch{}})}catch{}e.push(i)}function En(n,e){if(d.isExportDeclaration(n)){let t=Ct(n);if(t){if(n.getNamedExports().length>0)try{n.getNamedExports().forEach(r=>{try{let i=r.getName(),s=r.getAliasNode(),o=s?s.getText():void 0;e.push({kind:"reexport",moduleSpecifier:t,name:i||void 0,alias:o||void 0,isNamespace:!1})}catch{}})}catch{}else if(n.isNamespaceExport())try{let i=n.getNamespaceExport()?.getName();e.push({kind:"reexport",moduleSpecifier:t,name:i||"*",alias:i||void 0,isNamespace:!0})}catch{e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0})}else e.push({kind:"reexport",moduleSpecifier:t,name:"*",isNamespace:!0});return}try{n.getNamedExports().forEach(r=>{try{let i=r.getName();if(!i)return;let s=r.getAliasNode(),o=s?s.getText():i;e.push({kind:"alias",local:i,exported:o})}catch{}})}catch{}return}if(d.isExportAssignment(n))try{let t=n.getExpression();if(t&&d.isIdentifier(t)){let r=t.getText();e.push({kind:"alias",local:r,exported:"default"})}}catch{}}function wn(n,e,t,r){if(!ke(n,ae.ExportKeyword))return;let i=ke(n,ae.DefaultKeyword);if(d.isVariableStatement(n)){try{let s=n.getDeclarationList().getDeclarations();for(let o of s){let l=Se(o)??o.getName?.()??null;if(l){t(l,o);let c=r(o);c&&e.push({kind:"local",name:l,isDefault:i,nodeId:c})}}}catch{}return}if(d.isFunctionDeclaration(n)||d.isClassDeclaration(n)||d.isInterfaceDeclaration(n)||d.isEnumDeclaration(n)||d.isTypeAliasDeclaration(n)||d.isModuleDeclaration(n)){let s=Se(n)||(i?"default":null),o=r(n);o&&e.push({kind:"local",name:s??"default",isDefault:i,nodeId:o})}}function vt(n,e,t,r){let i=[],s=[],o=[],l=new Set,c=new Map,u=[],m=[],C=(r?.emitMode??"light")==="full",I=new Map,K=new Map,R=new Map,F=[{node:n,id:null,kind:"module",rawKind:"SourceFile",rawKindSource:"ts-morph",name:null,isExported:!1}],O=a=>{if(!a)return null;try{return e(a)}catch{return null}},U=a=>{let f=a.getParent?.();for(;f;){let h=I.get(f);if(h)return h;f=f.getParent?.()}return null},z=(a,f)=>{if(a&&(l.has(a)||l.add(a),f&&!c.has(a))){let h=O(f);h&&c.set(a,h)}},V=a=>d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isInterfaceDeclaration(a)||d.isEnumDeclaration(a)||d.isEnumMember(a)||d.isTypeAliasDeclaration(a)||d.isModuleDeclaration(a)||d.isMethodDeclaration(a)||d.isMethodSignature(a)||d.isPropertyDeclaration(a)||d.isPropertySignature(a)||d.isGetAccessorDeclaration(a)||d.isSetAccessorDeclaration(a)||d.isConstructorDeclaration(a)||d.isVariableDeclaration(a),fe=a=>d.isSourceFile(a)||d.isFunctionDeclaration(a)||d.isFunctionExpression(a)||d.isArrowFunction(a)||d.isMethodDeclaration(a)||d.isConstructorDeclaration(a)||d.isClassDeclaration(a)||d.isClassExpression(a)||d.isModuleDeclaration(a),H=a=>{let f=Se(a);if(f)return f;if(d.isConstructorDeclaration(a))return"constructor";if(d.isArrowFunction(a)||d.isFunctionExpression(a)){let h=a.getParent();try{if(d.isVariableDeclaration(h))return h.getName();if(d.isPropertyAssignment(h)||d.isPropertyDeclaration(h)||d.isPropertySignature(h))return h.getName?.()??null;if(d.isShorthandPropertyAssignment(h))return h.getNameNode()?.getText()??null;if(d.isExportAssignment(h))return"default"}catch{}}if(d.isEnumMember(a))try{return a.getName()}catch{return null}if(d.isVariableDeclaration(a))try{return a.getName()}catch{return null}return null},Y=a=>{let f=F[F.length-1],h=f?.id??null,N=f?.kind??"module",g=f?.name??null;if(d.isImportDeclaration(a))vn(a,u,z);else if(d.isImportEqualsDeclaration(a))try{let S=a.getModuleReference();if(S&&d.isExternalModuleReference(S)){let x=S.getExpression(),v;if(x&&d.isStringLiteral(x))v=x.getLiteralText();else if(x){let w=x.getText();v=typeof w=="string"?w.replace(/^['"]|['"]$/g,""):void 0}if(v){let M=a.getNameNode()?.getText(),_={moduleSpecifier:v,isTypeOnly:!1,namedImports:[]};M&&(_.defaultImport=M,z(M,a)),u.push(_)}}}catch{}(d.isExportDeclaration(a)||d.isExportAssignment(a))&&En(a,m),wn(a,m,z,O);let y=V(a),E=C||y,P=y?H(a):null;if(E){let S=e(a);y&&s.push({nodeId:S,node:a});let x=U(a),v=x==null?null:K.get(x)??0;x!=null&&v!=null&&K.set(x,v+1),I.set(a,S);let w=x?(R.get(x)??-1)+1:0;R.set(S,w);let M=ke(a,ae.ExportKeyword)||f?.isExported||!1,_=y?a.getNameNode?.()?.getText?.()??null:null,D=P??(y?Se(a)??_:Se(a));P?z(P,a):D&&z(D,a);let A=ze(a),L=Sn(a),k=Ie(a);Ae(k,{source:"ts-node-collector",file:n.getFilePath(),name:D??null});let J=bn(a);i.push({nodeId:S,nodeName:D??null,containerId:h,containerKind:N,containerRawKind:f?.rawKind??null,containerRawKindSource:f?.rawKindSource??null,containerName:g,isExported:M,kind:k.kind,rawKind:k.rawKind,rawKindSource:k.rawKindSource,semanticKind:k.semanticKind??null,start:A.start,end:A.end,paramCount:L,metadata:null,parentNodeId:x,role:xn(a),indexInParent:v,depth:w,bodyStart:J?.start??null,bodyEnd:J?.end??null})}if(d.isCallExpression(a)||d.isNewExpression(a)){let S=a.getExpression(),x=null,v,w;try{if(w=Cn(S),d.isIdentifier(S))x=S.getText();else if(d.isPropertyAccessExpression(S)){x=S.getName();let D=S.getExpression();d.isIdentifier(D)&&(v=D.getText())}}catch{}let M="";try{M=S.getText()}catch{}let _=ze(a);if(o.push({name:x,kind:d.isNewExpression(a)?"new":"call",containerId:h,containerKind:N,containerName:g,expression:M,objectName:v,symbol:w,start:_.start,end:_.end}),d.isCallExpression(a))try{if(d.isIdentifier(S)&&S.getText()==="require"){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}if(L){let k={moduleSpecifier:L,isTypeOnly:!1,namedImports:[]},J=a.getParent();if(J&&d.isVariableDeclaration(J)){let Pe=J.getNameNode();try{if(d.isIdentifier(Pe)){let ge=Pe.getText();ge&&(k.defaultImport=ge,z(ge,J))}}catch{}}u.push(k)}}else if(S?.getKind?.()===ae.ImportKeyword){let A=a.getArguments()[0],L;if(A&&(d.isStringLiteral(A)||d.isNoSubstitutionTemplateLiteral(A)))try{L=A.getLiteralText()}catch{let k=A.getText();L=typeof k=="string"?k.replace(/^['"]|['"]$/g,""):void 0}L&&u.push({moduleSpecifier:L,isTypeOnly:!1,namedImports:[]})}}catch{}}if(d.isCallExpression(a)){let S=a.getExpression();try{if(d.isIdentifier(S)&&S.getText()==="require"){let x=a.getParent();if(!(x&&d.isExternalModuleReference(x))){let w=a.getArguments()[0],M;if(w&&(d.isStringLiteral(w)||d.isNoSubstitutionTemplateLiteral(w)))try{M=w.getLiteralText()}catch{M=w.getText().replace(/^['"]|['"]$/g,"")}if(M){let _={moduleSpecifier:M,isTypeOnly:!1,namedImports:[]};if(x&&d.isVariableDeclaration(x)){let D=x.getNameNode();try{if(d.isIdentifier(D)){let A=D.getText();A&&(_.defaultImport=A,z(A,x))}}catch{}}u.push(_)}}}else if(S?.getKind?.()===ae.ImportKeyword){let v=a.getArguments()[0],w;if(v&&(d.isStringLiteral(v)||d.isNoSubstitutionTemplateLiteral(v)))try{w=v.getLiteralText()}catch{w=v.getText().replace(/^['"]|['"]$/g,"")}w&&u.push({moduleSpecifier:w,isTypeOnly:!1,namedImports:[]})}}catch{}}let j=!1;if(fe(a)){let S=O(a)??e(a),x=St(a);F.push({node:a,id:S,kind:x.kind,rawKind:x.rawKind,rawKindSource:x.rawKindSource,name:P??g,isExported:ke(a,ae.ExportKeyword)||f?.isExported||!1}),j=!0}a.forEachChild(Y),j&&F.pop()};if(C){let a=e(n);I.set(n,a),R.set(a,0);let f=ze(n);i.push({nodeId:a,nodeName:n.getBaseName?.()??null,containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:"SourceFile",rawKind:"SourceFile",rawKindSource:"ts-morph",semanticKind:"file",start:f.start,end:f.end,paramCount:null,metadata:null,parentNodeId:null,role:null,indexInParent:null,depth:0,bodyStart:f.start,bodyEnd:f.end})}if(n.forEachChild(Y),r?.includeComments===!0||C||process.env.AST_INDEX_COMMENTS==="1")try{let a=n.getFullText(),f=X.createScanner(X.ScriptTarget.Latest,!1,X.LanguageVariant.Standard,a),h=new Set;for(let N=f.scan();N!==X.SyntaxKind.EndOfFileToken;N=f.scan()){if(N!==X.SyntaxKind.SingleLineCommentTrivia&&N!==X.SyntaxKind.MultiLineCommentTrivia)continue;let g=f.getTokenPos(),y=f.getTextPos(),E=`${g}-${y}`;if(h.has(E)||(h.add(E),t.has(E)))continue;t.add(E);let P=a.substring(g,y),j=ht(N,P),x=e({getKindName:()=>j.name,getKind:()=>j.kind,getPos:()=>g,getEnd:()=>y,getStart:()=>g,getFullStart:()=>g,getText:()=>P,getSourceFile:()=>n,getParent:()=>n,__isComment:!0,__commentPosition:"standalone",__attachedTo:null},"COM"),v=I.get(n)??null,w=C&&v!=null?K.get(v)??0:null;C&&v!=null&&w!=null&&K.set(v,w+1),i.push({nodeId:x,nodeName:P.substring(0,100),containerId:null,containerKind:"module",containerRawKind:"SourceFile",containerRawKindSource:"ts-morph",containerName:null,isExported:!1,kind:j.name,rawKind:j.name,rawKindSource:"ts-morph",semanticKind:null,start:g,end:y,paramCount:null,metadata:null,parentNodeId:v,role:"comment",indexInParent:w,depth:C?1:0,bodyStart:null,bodyEnd:null})}}catch{}return{nodes:i,symbolCandidateNodes:s,references:o,declaredNames:l,localDeclarations:c,imports:u,exports:yn(m)}}function Et(n){let e;try{let r=n.getStart?.(!1);typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}if(e===void 0)try{let r=n.getFullStart?.();typeof r=="number"&&Number.isFinite(r)&&(e=r)}catch{}e===void 0&&(e=0);let t;try{let r=n.getEnd?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}if(t===void 0)try{let r=n.getStart?.();typeof r=="number"&&Number.isFinite(r)&&(t=r)}catch{}return t===void 0&&(t=e),t<e&&(t=e),{start:e,end:t}}var Rn=100;function In(n,e,t,r){let{start:i,end:s}=Et(e),o=Ie(e);Ae(o,{source:"ts-node-id",file:n,kind:o.kind});let l=r||Z.getAbbrev(o.kind,t);return`${n}#${i}-${s}:${l}`}function An(n,e){return Je.relative(n,e).replace(/\\/g,"/")}function wt(n,e){if(!n)return null;let t=n;try{let m=n.getAliasedSymbol();m&&(t=m)}catch{}let r=[];try{r=t.getDeclarations()??[]}catch{r=[]}if(!r.length)return null;let s=r.slice().sort((m,p)=>{let C=m.getSourceFile().getFilePath(),I=p.getSourceFile().getFilePath();if(C!==I)return C.localeCompare(I);let K=m.getStart(!1),R=p.getStart(!1);return K!==R?K-R:m.getEnd()-p.getEnd()})[0],o=An(e,s.getSourceFile().getFilePath()),l=s.getStart(!1),c=s.getEnd(),u="";try{u=t.getEscapedName()}catch{try{u=t.getName()}catch{u=""}}return`${o}#${l}-${c}:${u}`}function kn(n){try{return Q.isVariableDeclaration(n)||Q.isEnumMember(n)?n.getNameNode().getSymbol()??n.getSymbol():n.getSymbol()}catch{return}}function Mn(n,e){let t=n.getDescendantAtPos(e);if(!t)return;let r=t;if(!Q.isCallExpression(r)&&!Q.isNewExpression(r)&&(r=t.getFirstAncestor(s=>Q.isCallExpression(s)||Q.isNewExpression(s))??void 0),!r||!Q.isCallExpression(r)&&!Q.isNewExpression(r))return;let i=r.getExpression();try{return Q.isIdentifier(i)?i.getSymbol():Q.isPropertyAccessExpression(i)?i.getNameNode().getSymbol()??i.getSymbol():i.getSymbol()}catch{return}}async function Dn(n){let{sf:e,fileRel:t,content:r,preDeleted:i,meta:s,projectRoot:o,lang:l}=n,c=n.emitMode??"light",m=vt(e,(g,y)=>In(t,g,l,y),new Set,{includeComments:c==="full",emitMode:c}),p=new Map;for(let{nodeId:g,node:y}of m.symbolCandidateNodes){let E=wt(kn(y),o);E&&(p.has(g)||p.set(g,E))}let C=[],I=new Map,K=m.exports.filter(g=>g.kind!=="reexport"),R=m.exports.filter(g=>g.kind==="reexport");for(let g of K)if(g.kind==="local"){let y=g.isDefault?"default":g.name;if(!y||I.has(y))continue;let E=g.nodeId;C.push([t,y,E,0,null,null,g.isDefault?"default":"named"]),I.set(y,E)}else if(g.kind==="alias"){let y=g.exported;if(!y||I.has(y))continue;C.push([t,y,null,0,null,g.local,"alias"]),I.set(y,"alias")}for(let g of R){let y=g.moduleSpecifier;if(!y)continue;let E=y;if(g.isNamespace){let P=g.alias||"*";if(I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_star"]),I.set(P,"reexport")}else{let P=g.alias||g.name;if(!P||I.has(P))continue;C.push([t,P,null,1,E,g.name||P,"reexport_named"]),I.set(P,"reexport")}}let F=[],O=typeof r=="string"?r:null;if(O==null)try{let g=e.getFullText();O=typeof g=="string"?g:null}catch{O=null}for(let g of m.nodes){let{nodeId:y,nodeName:E,containerKind:P,containerRawKind:j,containerRawKindSource:S,isExported:x,kind:v,rawKind:w,rawKindSource:M,semanticKind:_,start:D,end:A,paramCount:L,metadata:k,parentNodeId:J,role:Pe,indexInParent:ge,depth:cn,bodyStart:un,bodyEnd:dn}=g,pn=k&&Object.keys(k).length?JSON.stringify(k):null,mn=p.get(y)??null;F.push([y,E??null,v,w??v,M??null,_??null,D,A,x?1:0,P??"module",j??P??"module",S??null,L,null,null,mn,pn,J??null,Pe??null,ge??null,cn??0,un??null,dn??null])}let U=[];for(let g of m.references){let{name:y,kind:E,containerId:P,containerName:j,expression:S,objectName:x,start:v,end:w}=g,M=null,_=null,D=wt(g.symbol??Mn(e,v),o),A=y?m.localDeclarations.get(y):void 0;A&&(M=A,_=t,D||(D=p.get(A)??null));let L=Re({sourceFile:t,sourceStart:v,sourceEnd:w,refKind:E,refName:y,targetFile:_,targetNodeId:M}),k={};S&&(k.expression=S),x&&(k.objectName=x),j&&(k.containerName=j);let J=Object.keys(k).length?JSON.stringify(k):null;U.push([L,t,P,y,E,v,w,M,_,M?"resolved":"unresolved",x??null,null,null,D,J])}let z=[],V=[];for(let g of m.imports){let y=g.moduleSpecifier??null;z.push([t,y,g.isTypeOnly?1:0]),g.defaultImport&&V.push([t,y,"default",g.defaultImport,"default",g.isTypeOnly?1:0]),g.namespaceImport&&V.push([t,y,"namespace",g.namespaceImport,"*",g.isTypeOnly?1:0]);for(let E of g.namedImports){let P=E.alias||E.name;V.push([t,y,"named",P,E.name,g.isTypeOnly?1:0])}}let fe=Je.join(o,t),H=s?.size,Y=s?.mtime;if(H===void 0||Y===void 0)try{let g=Nn.statSync(fe);H=g.size,Y=Math.floor(g.mtimeMs)}catch{}let a=new Date().toISOString(),f=c==="full",h=[t,Y??null,H??null,"completed",a,f?1:0],N=null;if(typeof O=="string")N={blobOid:t,content:O};else try{let g=e.getFullText?.();typeof g=="string"&&(N={blobOid:t,content:g})}catch(g){console.log(`[TypescriptIndexer] Failed to compute FTS payload for ${t}:`,g?.message??g)}return{payload:{lang:l,fileRel:t,preDeleted:i,exportRows:C,nodeRows:F,referenceRows:U,importRows:z,importBindingRows:V,fileRow:h,fts:N,fullyIndexed:f},fileSize:H,mtime:Y}}var qe=class{constructor(e,t){this.project=null;this.filesProcessed=0;this.projectRoot=e,this.lang=t}getProject(){return this.project||(this.project=new Pn({useInMemoryFileSystem:!0,skipAddingFilesFromTsConfig:!0})),this.project}disposeProject(){if(this.project){try{let e=this.project.getLanguageService().compilerObject;typeof e?.dispose=="function"&&e.dispose()}catch{}this.project=null}}async process(e){let t=this.getProject(),r;try{let i=t.createSourceFile(Je.join(this.projectRoot,e.relPath),e.content,{overwrite:!0});r=await Dn({sf:i,fileRel:e.relPath,content:e.content,preDeleted:!!e.preDeleted,meta:e.meta,projectRoot:this.projectRoot,lang:e.lang,emitMode:e.emitMode??"light"})}catch(i){this.disposeProject(),this.filesProcessed=0;let s=i?.message||String(i);throw new Error(`TypeScript parser failed for ${e.relPath}: ${s}`)}return this.filesProcessed++,this.filesProcessed>=Rn&&(this.disposeProject(),this.filesProcessed=0),{payload:r.payload,fileSize:r.fileSize,mtime:r.mtime}}};function Tn(n){return n==="ts"?[".ts",".tsx",".mts",".cts"]:n==="js"?[".js",".jsx",".mjs",".cjs"]:[]}function We(n){return{id:n,extensions:Tn(n),indexingMode:"worker",createIndexer:e=>new qe(e,n)}}import De from"fs";import ee from"path";import{spawn as Ln}from"child_process";import Kn from"fs";var le=class{constructor(e=5e3){this.maxEntries=e;this.cache=new Map}get(e,t){let r=this.cache.get(e);if(!r)return null;let i=t?.mtime??null,s=t?.size??null;return i!=null&&s!=null&&r.mtime===i&&r.size===s?r.result:null}set(e,t,r){let i=t?.mtime??null,s=t?.size??null;this.cache.set(e,{mtime:i,size:s,result:r}),this.cache.size>this.maxEntries&&this.cache.clear()}};var Ue=class{constructor(e,t,r,i){this.projectRoot=e;this.lang=t;this.parse=r;this.exportKind=i;this.cache=new le}async process(e){let t=e.meta?.mtime,r=e.meta?.size;if(t==null||r==null)try{let o=Kn.statSync(e.absPath);t=Math.floor(o.mtimeMs),r=o.size}catch{}let i=e.emitMode==="full"?null:this.cache.get(e.absPath,{mtime:t,size:r});if(i)return ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:i,resolveNodeId:Nt(e.relPath,i,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"});let s=null;try{s=await this.parse({absPath:e.absPath,relPath:e.relPath,content:e.content,meta:{mtime:t,size:r},projectRoot:this.projectRoot,lang:this.lang,emitMode:e.emitMode??"light"})}catch(o){try{console.log(`[CliContract:${this.lang}] parse threw for ${e.relPath}: ${o?.message||String(o)}`)}catch{}return he(this.lang,e.relPath,{mtime:t,size:r})}return!s||s.error?he(this.lang,e.relPath,{mtime:t,size:r}):(e.emitMode!=="full"&&this.cache.set(e.absPath,{mtime:t,size:r},s),ye({lang:this.lang,fileRel:e.relPath,content:e.content,meta:{mtime:t,size:r},preDeleted:e.preDeleted,parsed:s,resolveNodeId:Nt(e.relPath,s,this.lang),exportKind:this.exportKind??"cli",fullyIndexed:e.emitMode==="full"}))}};function Nt(n,e,t){let r=new Map;for(let i of e.nodes??[]){if(!i.name||r.has(i.name))continue;let s=`${n}#${i.start}-${i.end}:${Z.getAbbrev(i.kind,t)}`;r.set(i.name,s)}return i=>r.get(i)??null}function G(n){return{id:n.id,extensions:n.extensions,indexingMode:"worker",createIndexer:e=>new Ue(e,n.id,n.parse,n.exportKind),resolveSpan:n.resolve?async(e,t,r)=>n.resolve({projectRoot:e,absPath:t,nodePath:r,lang:n.id}):void 0}}import _n from"fs";import Me from"path";var Xe=null;function On(n){for(let e of n)if(_n.existsSync(e))return e;return null}function q(n){let e=Xe?.toolsRoot??process.env.PANDO_TOOLS_ROOT,t=Xe?.runtimeRoot??process.env.PANDO_RUNTIME_ROOT,r=Xe?.resourcesRoot??process.env.PANDO_RESOURCES_ROOT,i=[e?Me.join(e,n):null,t?Me.join(t,"tools",n):null,r?Me.join(r,"tools",n):null,Me.resolve(process.cwd(),"tools",n)].filter(s=>!!s);return On(i)}function W(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
|
|
2
2
|
`)}catch{}}var Fn=Number(process.env.PANDO_PYTHON_WORKER_PARSE_TIMEOUT_MS||18e4),jn=Number(process.env.PANDO_PYTHON_WORKER_RESOLVE_TIMEOUT_MS||6e4),de=class extends Error{constructor(t,r){super(t);this.fatal=r;this.name="PythonWorkerRequestError"}},Te=class{constructor(e,t){this.interpreter=e;this.scriptPath=t;this.buffer=Buffer.alloc(0);this.pending=new Map;this.requestQueue=Promise.resolve();this.seq=1;this.closed=!1;if(this.proc=Ln(this.interpreter,["-u",this.scriptPath],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw new Error("python worker stdio unavailable");this.proc.stdout.on("data",r=>this.onData(r)),this.proc.stderr.on("data",r=>{W(`[PythonWorker] ${r.toString("utf8").trim()}`)}),this.proc.stdin.on("error",r=>this.handleError(r)),this.proc.on("error",r=>this.handleError(r)),this.proc.on("exit",r=>this.handleError(new Error(`python worker exited with code ${r}`))),this.ready=this.ping()}handleError(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.summary&&W("[PythonCliAdapter] worker error",{interpreter:this.interpreter,error:e.message,...t.summary}),t.reject(e);this.pending.clear();try{this.proc.stdin?.end()}catch{}try{this.proc.kill()}catch{}}}onData(e){for(this.buffer=Buffer.concat([this.buffer,e]);this.buffer.length>=4;){let t=this.buffer.readUInt32BE(0);if(this.buffer.length<4+t)return;let r=this.buffer.slice(4,4+t);this.buffer=this.buffer.slice(4+t);let i=null;try{i=JSON.parse(r.toString("utf8"))}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),s.timeout&&clearTimeout(s.timeout),i.ok?s.resolve(i):s.reject(new de(i.error||"python worker error",!1)))}}sendMessage(e){if(this.closed)throw new Error("python worker is closed");let t=Buffer.from(JSON.stringify(e),"utf8"),r=Buffer.alloc(4);r.writeUInt32BE(t.length,0),this.proc.stdin.write(r),this.proc.stdin.write(t)}async requestRaw(e,t,r=1e4){let i=this.seq++,s={id:i,op:e,...t},o={op:e,id:i};return typeof t?.path=="string"&&(o.path=t.path),typeof t?.nodePath=="string"&&(o.nodePath=t.nodePath),typeof t?.content_b64=="string"&&(o.contentBytes=t.content_b64.length),new Promise((l,c)=>{let u=setTimeout(()=>{this.pending.delete(i);let m=new de(`python worker timeout (${e})`,!0);W("[PythonCliAdapter] worker timeout",{op:e,id:i,timeoutMs:r,pending:this.pending.size,interpreter:this.interpreter,...o}),c(m),this.handleError(m)},r);this.pending.set(i,{resolve:l,reject:c,timeout:u,summary:o}),this.pending.size%200===0&&W("[PythonCliAdapter] worker pending",{op:e,pending:this.pending.size,interpreter:this.interpreter});try{this.sendMessage(s)}catch(m){clearTimeout(u),this.pending.delete(i),c(m)}})}async enqueueRequest(e){let t=this.requestQueue.catch(()=>{}),r,i=new Promise(s=>{r=s});this.requestQueue=t.then(()=>i),await t;try{return await e()}finally{r()}}async request(e,t,r=1e4){await this.ready;let i=Date.now();return this.enqueueRequest(async()=>{let s=Date.now()-i,o=Date.now();s>2e3&&W("[PythonCliAdapter] worker queued",{op:e,queueMs:s,interpreter:this.interpreter,path:t?.path});let l=await this.requestRaw(e,t,r),c=Date.now()-o;return c>2e3&&W("[PythonCliAdapter] worker slow",{op:e,ms:c,queueMs:s,pending:this.pending.size,interpreter:this.interpreter,path:t?.path}),l})}async ping(){await this.requestRaw("ping",{},5e3)}async parse(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("parse",{path:e.path,content_b64:t,encoding:e.encoding,emit_mode:e.emitMode??"light"},Fn);return r.nodes?r:null}async resolve(e){let t=Buffer.from(e.content,"utf8").toString("base64"),r=await this.request("resolve",{path:e.path,nodePath:e.nodePath,content_b64:t,encoding:e.encoding},jn);return typeof r.start=="number"&&typeof r.end=="number"?r:null}close(){if(this.closed)return;this.closed=!0;for(let[,t]of this.pending)t.timeout&&clearTimeout(t.timeout),t.reject(new Error("python worker client closed"));this.pending.clear();let e=this.proc;try{e.stdin?.end()}catch{}try{e.kill()}catch{}}};function Pt(n){let e=ee.resolve(n,"tools/python-indexer/pando_python_worker.py");if(De.existsSync(e))return e;let t=q("python-indexer/pando_python_worker.py");if(t)return t;let r=ee.resolve(__dirname,"../../../../../tools/python-indexer/pando_python_worker.py");return De.existsSync(r)?r:null}var ue=new Map;function ce(n){try{return De.readFileSync(n,"utf8")}catch{return null}}function Ce(n){if(!n)return null;let e=n.match(/(\d+)\.(\d+)/);return e?{major:Number(e[1]),minor:Number(e[2])}:null}function Bn(n){let e=ce(ee.join(n,"pyproject.toml"));if(e){let l=e.match(/requires-python\s*=\s*"([^"]+)"/i),c=Ce(l?.[1]??null);if(c)return c}let t=ce(ee.join(n,"setup.cfg"));if(t){let l=t.match(/python_requires\s*=\s*([\w\d\.<>~=\s]+)/i),c=Ce(l?.[1]??null);if(c)return c}let r=ce(ee.join(n,"setup.py"));if(r){let l=r.match(/python_requires\s*=\s*['\"]([^'\"]+)['\"]/i),c=Ce(l?.[1]??null);if(c)return c}let i=ce(ee.join(n,"tox.ini"));if(i){let l=i.match(/envlist\s*=\s*([^\n]+)/i);if(l&&l[1]){let c=l[1].split(/[,\s]+/).filter(Boolean);for(let u of c){let m=u.match(/py(\d)(\d)/i);if(m)return{major:Number(m[1]),minor:Number(m[2])}}}}let s=ce(ee.join(n,".python-version"));if(s){let l=Ce(s.trim());if(l)return l}let o=ce(ee.join(n,"runtime.txt"));if(o){let l=o.match(/python-(\d+\.\d+)/i),c=Ce(l?.[1]??null);if(c)return c}return null}function Rt(n){return Bn(n)?.major===2?["python2","python","python3"]:["python3","python","python2"]}async function $n(n,e,t,r){let i=Pt(n);if(!i)return null;let s=Rt(n);for(let o of s){let l=`${o}::${i}`,c=ue.get(l);if(!c)try{c=new Te(o,i),ue.set(l,c)}catch{continue}try{let u=await c.parse({path:e,content:t,encoding:"utf-8",emitMode:r});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof de?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker parse error",{file:e,interpreter:o,script:i,fatal:p,error:m}),p&&ue.delete(l)}}return null}async function zn(n,e,t,r){let i=Pt(n);if(!i)return null;let s=Rt(n);for(let o of s){let l=`${o}::${i}`,c=ue.get(l);if(!c)try{c=new Te(o,i),ue.set(l,c)}catch{continue}try{let u=await c.resolve({path:e,nodePath:r,content:t,encoding:"utf-8"});if(u)return u}catch(u){let m=u?.message||String(u),p=u instanceof de?u.fatal:/timeout|closed|exited|EPIPE|ENOENT|spawn/i.test(m);W("[PythonCliAdapter] worker resolve error",{file:e,interpreter:o,nodePath:r,script:i,fatal:p,error:m}),p&&ue.delete(l)}}return null}async function qn(n){let e=Date.now(),t=!1,r=null;try{r=await $n(n.projectRoot,n.absPath,n.content,n.emitMode??"light"),t=!!r}catch{}if(!r){W(`[PythonCliAdapter] parse failed for ${n.relPath} via python worker`);let o=Date.now()-e;return o>2e3&&W("[PythonCliAdapter] parse slow (failed)",{file:n.relPath,ms:o}),null}let i=[];for(let o of r.references||[]){let l={};o.expression&&(l.expression=o.expression),o.objectName&&(l.objectName=o.objectName),o.containerName&&(l.containerName=o.containerName),o.containerKind&&(l.containerKind=o.containerKind),i.push({sourceStart:o.start,sourceEnd:o.end,refKind:o.kind,refName:o.name,receiverName:o.receiverName??o.objectName??null,arity:typeof o.arity=="number"?o.arity:null,containerQualifiedName:o.containerQualifiedName??null,targetSymbolKey:o.targetSymbolKey??null,metadata:Object.keys(l).length?l:null})}let s=Date.now()-e;return s>2e3&&W("[PythonCliAdapter] parse slow",{file:n.relPath,ms:s,usedWorker:t}),{nodes:r.nodes,imports:r.imports,importBindings:r.importBindings,references:i,modulePublic:r.modulePublic??void 0,explicitExports:r.explicitExports??void 0}}function It(){return G({id:"python",extensions:[".py",".pyw",".pyi"],exportKind:"named",parse:({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i})=>qn({absPath:n,relPath:e,projectRoot:t,content:r,emitMode:i}),resolve:async({absPath:n,nodePath:e,projectRoot:t})=>{try{let r=De.readFileSync(n,"utf8"),i=await zn(t,n,r,e);if(i)return i}catch{}return null}})}import At from"fs";import kt from"path";import{spawn as Jn,spawnSync as Wi}from"child_process";var Wn=256e3,Un=32;function ne(...n){try{let e=n.map(t=>{if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return String(t)}}).join(" ");process.stderr.write(e+`
|
|
3
3
|
`)}catch{}}var Qe=class{constructor(e){this.cmd=e;this.proc=null;this.buffer="";this.pending=new Map;this.seq=1;this.closed=!1;this.ensureProcess()}ensureProcess(){if(!(this.proc&&!this.closed)){if(this.closed=!1,this.proc=Jn(this.cmd,["--server"],{stdio:["pipe","pipe","pipe"]}),!this.proc.stdout||!this.proc.stderr||!this.proc.stdin)throw this.closed=!0,new Error("csharp indexer stdio unavailable");this.proc.stdout.on("data",e=>this.onData(e)),this.proc.stderr.on("data",e=>{ne(`[CSharpIndexer] ${e.toString("utf8").trim()}`)}),this.proc.stdin.on("error",e=>this.handleExit(e)),this.proc.on("error",e=>this.handleExit(e)),this.proc.on("exit",e=>this.handleExit(new Error(`csharp indexer exited with code ${e}`)))}}handleExit(e){if(!this.closed){this.closed=!0;for(let[,t]of this.pending)t.reject(e);this.pending.clear()}}onData(e){for(this.buffer+=e.toString("utf8");;){let t=this.buffer.indexOf(`
|
|
4
4
|
`);if(t<0)break;let r=this.buffer.slice(0,t).trim();if(this.buffer=this.buffer.slice(t+1),!r)continue;let i=null;try{i=JSON.parse(r)}catch{continue}let s=this.pending.get(i.id);s&&(this.pending.delete(i.id),i.ok?s.resolve(i):s.reject(new Error(i.error||"csharp server error")))}}async request(e,t=1){this.ensureProcess();let r=this.seq++;return new Promise((i,s)=>{let o={id:r,...e};this.pending.set(r,{resolve:i,reject:s});try{this.proc.stdin.write(`${JSON.stringify(o)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as i}from"./chunk-
|
|
1
|
+
import{b as i}from"./chunk-RRIZV7YJ.mjs";import{DatabaseSync as u}from"node:sqlite";var r,s,p,l=i(()=>{"use strict";r=class{constructor(t){this.statement=t}run(...t){let e=this.statement.run(...t);return{changes:e.changes,lastInsertRowid:e.lastInsertRowid}}get(...t){let e=this.statement.get(...t);return e??void 0}all(...t){return this.statement.all(...t)}iterate(...t){return this.statement.iterate(...t)}setAllowBareNamedParameters(t){return this.statement.setAllowBareNamedParameters(t),this}setReadBigInts(t){return this.statement.setReadBigInts(t),this}},s=class o{constructor(t,e){this.file=t;this.transactionDepth=0;let n=e??{},a=!!(n.readOnly??n.readonly);this.connectionId=o.nextId++,this.database=new u(t,{readOnly:a,fileMustExist:!!n.fileMustExist,timeout:typeof n.timeout=="number"?Math.max(0,Math.floor(n.timeout)):void 0})}static{this.nextId=1}prepare(t){return new r(this.database.prepare(t))}exec(t){this.database.exec(t)}close(){this.database.close()}getConnectionId(){return this.connectionId}pragma(t){return this.database.prepare(`PRAGMA ${t}`).all()}transaction(t){return(...e)=>{this.transactionDepth+=1;let n=this.transactionDepth;n===1&&this.database.exec("BEGIN");try{let a=t(...e);if(a instanceof Promise)throw new TypeError("SQLite transactions must be synchronous. Received a Promise.");return n===1&&this.database.exec("COMMIT"),a}catch(a){if(n===1)try{this.database.exec("ROLLBACK")}catch{}throw a}finally{this.transactionDepth=Math.max(0,this.transactionDepth-1)}}}loadExtension(){throw new Error("loadExtension is not supported by the embedded SQLite runtime")}},p=s});export{p as a,l as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var t=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,
|
|
1
|
+
var t=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,r)=>(typeof require<"u"?require:n)[r]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var c=(o,n,r)=>()=>{if(r)throw r[0];try{return o&&(n=o(o=0)),n}catch(e){throw r=[e],e}};function s(){let o=(...n)=>{try{let r=n.map(e=>{if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}).join(" ");process.stderr.write(r+`
|
|
2
2
|
`)}catch{}};console.log=(...n)=>o(...n),console.info=(...n)=>o(...n),console.debug=(...n)=>o(...n),console.warn=(...n)=>o(...n),console.error=(...n)=>o(...n)}export{t as a,c as b,s as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as B,b as L,c as q,d as R,e as C,f as z,i as F,j as N}from"./chunk-
|
|
1
|
+
import{a as B,b as L,c as q,d as R,e as C,f as z,i as F,j as N}from"./chunk-KXR6VCP4.mjs";import"./chunk-JWVMGEXN.mjs";import{c as X}from"./chunk-RRIZV7YJ.mjs";import{parentPort as l,threadId as ne}from"worker_threads";import K from"fs";import _ from"path";import{promises as G}from"fs";import H from"ignore";import{createHash as se}from"crypto";var te=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_FILES||"64")),re=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_BYTES||`${1024*1024}`)),ce=Math.max(1,Number(process.env.PANDO_BATCH_INDEX_MAX_WAIT_MS||"15")),le=Math.max(te,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_FILES||"256")),he=Math.max(re,Number(process.env.PANDO_BATCH_INDEX_MAX_PENDING_BYTES||`${8*1024*1024}`));var be=1*1024*1024,Me=Math.max(3e4,Number(process.env.PANDO_WORKER_INIT_TIMEOUT_MS||12e4)),ie=Math.max(1e3,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_LOG_MS||1e4)),We=Math.max(ie,Number(process.env.PANDO_ACTIVE_CONTEXT_STALL_FAIL_MS||6e5)),Be=q();function U(e,t){return Buffer.from(e).toString(t)}function D(e,t,o,r,d,u){let m=Buffer.from(e),n=se("sha1").update(m).digest("hex"),i=u??m.toString(d),c=i?i.split(/\r?\n/).length:0;return{relPath:t,size:o,mtime:r,objectId:n,lineCount:c,encoding:d}}if(!l)throw new Error("Indexer worker must be spawned as a worker thread");X();function h(e,t){try{if(t===void 0){console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e}`);return}console.error(`[${new Date().toISOString()}] [IndexerWorker] ${e} ${JSON.stringify({pid:process.pid,threadId:ne,...t&&typeof t=="object"&&!Array.isArray(t)?t:{details:t}})}`)}catch{}}h("module loaded",{cwd:process.cwd(),hasParentPort:!!l,envWorkerRoot:process.env.PANDO_WORKER_SCRIPT_DIR??null,envRuntimeRoot:process.env.PANDO_RUNTIME_ROOT??null});var J=new Map,E="",T="index",b=new Map,v=new Set;function Y(e,t){return _.relative(e,t).replace(/\\/g,"/")}function ae(e,t){let o=(t||[]).map(r=>typeof r=="string"?r.trim():"").filter(Boolean).map(r=>r.replace(/^[\\/]+/,"").replace(/[\\/]+$/,"")).map(r=>r.endsWith("/")?r:`${r}/`);return o.length?r=>{let d=Y(e,r);if(!d||d.startsWith(".."))return!1;let u=d.endsWith("/")?d:`${d}/`;return o.some(m=>u.startsWith(m))}:null}async function oe(e){await new Promise(t=>{b.set(e,t)})}l.on("message",async e=>{if(e.cmd==="scan-ack"){let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="scan-cancel"){v.add(e.requestId);let t=b.get(e.requestId);if(t){b.delete(e.requestId);try{t()}catch{}}return}if(e.cmd==="init"){try{h("init received",{mode:e.mode??"index",projectRoot:typeof e.projectRoot=="string"?e.projectRoot:null}),typeof e.projectRoot=="string"&&(E=e.projectRoot),T=e.mode??"index",h("init completed",{mode:T,projectRoot:E}),l.postMessage({type:"ready"})}catch(t){h("init failed",{error:t?.message||String(t),stack:t?.stack??null}),l.postMessage({type:"error",message:`init failed: ${t?.message||t}`,stack:t?.stack})}return}if(e.cmd==="scan"){let t=e.requestId,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(h("scan received",{requestId:t,projectRoot:o||null,batchSize:e.batchSize??null,maxFileBytes:e.maxFileBytes??null,excludeDirs:Array.isArray(e.excludeDirs)?e.excludeDirs.slice(0,20):[]}),!o){l.postMessage({type:"error",requestId:t,message:"worker not initialized"});return}let r=Math.max(1,Math.min(500,Number(e.batchSize||100))),d=Math.max(1,Number(e.maxFileBytes||1*1024*1024)),u=e.languageSupport,m=z(u),n=ae(o,e.excludeDirs??[]),i=N(o),c=new Set(["node_modules",".git",".pando-data"]),S=a=>a.replace(/\\/g,"/"),w=await F(o,""),g=H().add(w),f=[{dir:o,relDir:"",rules:w,ig:g}],y=0,s=0,p=[],x=async()=>{p.length&&(l.postMessage({type:"scan:batch",requestId:t,files:p}),p=[],await oe(t))};try{for(;f.length&&!v.has(t);){let a=f.pop(),$=[];try{$=await G.readdir(a.dir,{withFileTypes:!0})}catch{s+=1;continue}for(let k of $){if(v.has(t))break;let I=_.join(a.dir,k.name);if(k.isSymbolicLink?.()){s+=1;continue}if(k.isDirectory()){if(c.has(k.name)){s+=1;continue}if(n?.(I)){s+=1;continue}let Q=a.relDir?`${a.relDir}/${k.name}`:k.name,W=S(Q);if(a.ig.ignores(W)&&!i?.hasDescendant(W)){s+=1;continue}let A=a.rules.slice(),j=await F(I,W);j.length&&A.push(...j);let Z=H().add(A);f.push({dir:I,relDir:W,rules:A,ig:Z});continue}if(!k.isFile()){s+=1;continue}if(n?.(I)){s+=1;continue}let P=Y(o,I);if(!P||P.startsWith("..")){s+=1;continue}if(a.ig.ignores(P)&&!i?.hasFile(P)){s+=1;continue}let V=_.extname(k.name).toLowerCase();if(!m.has(V)){s+=1;continue}let O=R(P);if(!O){s+=1;continue}let M;try{M=await G.stat(I)}catch{s+=1;continue}if(M.size>d){s+=1;continue}p.push({relPath:P,absPath:I,mtimeMs:Math.floor(M.mtimeMs),size:M.size,lang:O}),y+=1,p.length>=r&&await x()}}v.has(t)||await x(),l.postMessage({type:"scan:done",requestId:t,discovered:y,skipped:s,cancelled:v.has(t)}),h("scan complete",{requestId:t,discovered:y,skipped:s,cancelled:v.has(t)})}catch(a){h("scan failed",{requestId:t,error:a?.message||String(a),stack:a?.stack??null}),l.postMessage({type:"error",requestId:t,message:a?.message||String(a),stack:a?.stack})}finally{v.delete(t),b.delete(t)}return}if(e.cmd==="process"){let t=e.role??T,o=typeof e.projectRoot=="string"?e.projectRoot:E;if(!o){l.postMessage({type:"error",requestId:e.requestId,message:"worker not initialized"});return}let{file:r}=e,d=r.encoding??"utf8",u=r.sharedBuffer,m={size:r.size,mtime:r.mtime};try{let n=r.lang??"ts",i,c,S=()=>{if(c&&typeof i=="string")return{content:i,sharedBuffer:c};if(u instanceof SharedArrayBuffer)return c=u,i=U(u,d),{content:i,sharedBuffer:c};if(u instanceof ArrayBuffer){let x=Buffer.from(u),a=new SharedArrayBuffer(x.byteLength);return new Uint8Array(a).set(x),c=a,i=x.toString(d),{content:i,sharedBuffer:c}}let s=K.readFileSync(r.absPath),p=new SharedArrayBuffer(s.byteLength);return new Uint8Array(p).set(s),c=p,i=s.toString(d),{content:i,sharedBuffer:c}},w=()=>{let s=B(n,r.relPath,m),p=S();l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:s.payload,meta:{size:s.fileSize,mtime:s.mtime},snapshotSummary:D(p.sharedBuffer,r.relPath,r.size,r.mtime,d,p.content)}})},g=`${o}:${n}`,f=J.get(g);if(!f)try{h("creating language indexer",{role:t,requestId:e.requestId,lang:n,projectRoot:o});let s=C(n);if(!L(s))throw new Error(`${n} is not a worker-indexed language`);f=s.createIndexer(o),J.set(g,f),h("language indexer ready",{role:t,requestId:e.requestId,lang:n,projectRoot:o})}catch(s){h("language indexer create failed",{role:t,requestId:e.requestId,lang:n,error:s?.message||String(s),stack:s?.stack??null}),w();return}({content:i,sharedBuffer:c}=S());let y;try{y=await f.process({absPath:r.absPath,relPath:r.relPath,content:i,meta:m,preDeleted:!!r.preDeleted,lang:n,emitMode:r.emitMode})}catch(s){h("process failed",{role:t,requestId:e.requestId,lang:n,relPath:r.relPath,error:s?.message||String(s),stack:s?.stack??null}),w();return}l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:y.payload,meta:{size:y.fileSize,mtime:y.mtime},snapshotSummary:D(c,r.relPath,r.size,r.mtime,d,i)}})}catch(n){h("process wrapper failed",{role:t,requestId:e.requestId,relPath:r.relPath,error:n?.message||String(n),stack:n?.stack??null});try{let i=r.lang??"ts",c=K.readFileSync(r.absPath),S=new SharedArrayBuffer(c.byteLength);new Uint8Array(S).set(c);let w=c.toString(d),g=B(i,r.relPath,m);l.postMessage({type:"result",requestId:e.requestId,role:"index",relPath:r.relPath,result:{payload:g.payload,meta:{size:g.fileSize,mtime:g.mtime},snapshotSummary:D(S,r.relPath,r.size,r.mtime,d,w)}})}catch(i){l.postMessage({type:"error",requestId:e.requestId,message:i?.message||n?.message||String(i??n),stack:i?.stack??n?.stack})}}return}e.cmd==="close"&&l.postMessage({type:"closed"})});process.on("uncaughtException",e=>{try{l.postMessage({type:"error",message:e?.message||String(e),stack:e?.stack})}catch{}});process.on("unhandledRejection",e=>{try{l.postMessage({type:"error",message:String(e)})}catch{}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as n}from"./chunk-
|
|
1
|
+
import{a as o,b as n}from"./chunk-MKW3R262.mjs";import{c as s}from"./chunk-RRIZV7YJ.mjs";n();import{parentPort as e,workerData as c}from"worker_threads";if(!e)throw new Error("query-db worker must be spawned as a worker thread");s();var{dbPath:i,sql:y}=c;try{let r=new o(i,{readonly:!0});try{let a=r.prepare(y).setReadBigInts(!0).all();e.postMessage({type:"success",rows:a})}finally{r.close()}}catch(r){let t=r instanceof Error?r.message:String(r);e.postMessage({type:"error",message:t})}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{g as P,h as J,j as ot}from"./chunk-
|
|
1
|
+
import{g as P,h as J,j as ot}from"./chunk-KXR6VCP4.mjs";import{a as V,b as st,c as K,e as R}from"./chunk-JWVMGEXN.mjs";import{a as Q,b as xt}from"./chunk-MKW3R262.mjs";import{a as Et,c as at}from"./chunk-RRIZV7YJ.mjs";import{parentPort as $}from"worker_threads";import it from"path";import*as o from"fs";import*as I from"path";import*as g from"isomorphic-git";function Pt(){return new Date().toISOString()}function U(r,t,e){let i=`[${Pt()}] [${r.toUpperCase()}] ${t}`;if(!e)return i;try{return i+" "+JSON.stringify(e)}catch{return i}}var B={debug:(r,t)=>{try{process.stderr.write(U("debug",r,t)+`
|
|
2
2
|
`)}catch{}},info:(r,t)=>{try{process.stderr.write(U("info",r,t)+`
|
|
3
3
|
`)}catch{}},warn:(r,t)=>{try{process.stderr.write(U("warn",r,t)+`
|
|
4
4
|
`)}catch{}},error:(r,t)=>{try{process.stderr.write(U("error",r,t)+`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as pe,e as ie,f as F}from"./chunk-
|
|
1
|
+
import{d as pe,e as ie,f as F}from"./chunk-JWVMGEXN.mjs";import{a as se,b as Ue}from"./chunk-MKW3R262.mjs";import{c as Re}from"./chunk-RRIZV7YJ.mjs";Ue();import{parentPort as S,threadId as Ae}from"worker_threads";import K from"path";import ce from"fs";import{inspect as Be}from"util";import Pe from"os";function Ge(e){e.exec(`
|
|
2
2
|
PRAGMA journal_mode=WAL;
|
|
3
3
|
PRAGMA synchronous=OFF;
|
|
4
4
|
PRAGMA temp_store=MEMORY;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pando-ai",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "AI coding firewall for Codex and Claude Code: supervised launchers, Pando MCP, policy enforcement, Claude hooks, and local provider gateway.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pando-ai": "bin/pando-ai.js"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"replace-body(path, expectedHash, with, forceReplaceWillBreakSyntax)",
|
|
48
48
|
"change-signature(path, expectedHash, parameters, returnType, makeAsync, makeSyncFromAsync, forceChangeWillBreakSyntax, boundary, batchSaves)",
|
|
49
49
|
"filter-map-reduce(query, transforms, apply)",
|
|
50
|
+
"shell-command(command, reason, timeoutMs, shell, maxOutputBytes)",
|
|
50
51
|
"list-snapshots(offset, limit)",
|
|
51
52
|
"diff-snapshots(head, base, page)",
|
|
52
53
|
"get-snapshot-trailers(snapshotId, keys)",
|
|
@@ -1376,7 +1377,7 @@
|
|
|
1376
1377
|
"name": "delete",
|
|
1377
1378
|
"category": "pando",
|
|
1378
1379
|
"signature": "delete(path, expectedHashes, forceDeleteReferencesMayBreakSyntax)",
|
|
1379
|
-
"description": "Delete code targets and their references. If a target file is not fully indexed yet, Pando materializes and persists its full AST on demand before resolving/editing the node; no separate indexing step is needed. expectedHashes must align with path list and omit '@'. Requires forceDeleteReferencesMayBreakSyntax=true. Example: { path:'src/app.ts#FD:0', expectedHashes:['p123:c456'], forceDeleteReferencesMayBreakSyntax:true }",
|
|
1380
|
+
"description": "Delete code targets and their references. path is a single target or an array of up to 10 targets. Bare file paths are not accepted. For TS/JS whole-file deletion, target the SourceFile handle returned as file# with its file hash. For cross-language file deletion, delete the file's span-bearing top-level code node(s); if the file becomes empty/comment-only, Pando deletes the file and reports it in details.deletedFiles. If a target file is not fully indexed yet, Pando materializes and persists its full AST on demand before resolving/editing the node; no separate indexing step is needed. expectedHashes must align with path list and omit '@'. Requires forceDeleteReferencesMayBreakSyntax=true. Example: { path:'src/app.ts#FD:0', expectedHashes:['p123:c456'], forceDeleteReferencesMayBreakSyntax:true }",
|
|
1380
1381
|
"parameters": {
|
|
1381
1382
|
"type": "object",
|
|
1382
1383
|
"properties": {
|
|
@@ -1387,18 +1388,21 @@
|
|
|
1387
1388
|
},
|
|
1388
1389
|
{
|
|
1389
1390
|
"type": "array",
|
|
1391
|
+
"maxItems": 10,
|
|
1390
1392
|
"items": {
|
|
1391
1393
|
"type": "string"
|
|
1392
1394
|
}
|
|
1393
1395
|
}
|
|
1394
|
-
]
|
|
1396
|
+
],
|
|
1397
|
+
"description": "Single target or array of up to 10 targets. Bare file paths are not valid delete targets. TS/JS whole-file deletion uses the SourceFile handle form file#. Cross-language file removal is done by deleting top-level span-bearing node(s) until the file is empty/comment-only."
|
|
1395
1398
|
},
|
|
1396
1399
|
"expectedHashes": {
|
|
1397
1400
|
"type": "array",
|
|
1401
|
+
"maxItems": 10,
|
|
1398
1402
|
"items": {
|
|
1399
1403
|
"type": "string"
|
|
1400
1404
|
},
|
|
1401
|
-
"description": "Hash-only entries (no @),
|
|
1405
|
+
"description": "Hash-only entries (no @), exactly one per path."
|
|
1402
1406
|
},
|
|
1403
1407
|
"forceDeleteReferencesMayBreakSyntax": {
|
|
1404
1408
|
"type": "boolean",
|
|
@@ -1426,7 +1430,7 @@
|
|
|
1426
1430
|
"name": "insert",
|
|
1427
1431
|
"category": "pando",
|
|
1428
1432
|
"signature": "insert(to, code, replaceExistingNodeAtPath, expectedHash, createFileIfMissing, newFileInitialContent, forceInsertWillBreakSyntax)",
|
|
1429
|
-
"description": "Insert raw code at an explicit anchor. to can be a node path or anchor object (exactly one of before/after/start/end/bodyStartOf/bodyEndOf). If the anchor file is not fully indexed yet, Pando materializes and persists its full AST on demand before resolving/editing the node; no separate indexing step is needed. replaceExistingNodeAtPath is required. expectedHash (no @) is required unless createFileIfMissing=true with a single file anchor. Example: { to:{ bodyEndOf:'src/a.ts#FD:0' }, code:'\\nreturn 1;', replaceExistingNodeAtPath:false, expectedHash:'p123:c456' }",
|
|
1433
|
+
"description": "Insert raw code at an explicit anchor. This is the Pando writer that can create new files: set createFileIfMissing=true with a single file anchor such as { end:'src/new-file.ts' }. replace and replace-body edit existing nodes only. to can be a node path or anchor object (exactly one of before/after/start/end/bodyStartOf/bodyEndOf). If the anchor file is not fully indexed yet, Pando materializes and persists its full AST on demand before resolving/editing the node; no separate indexing step is needed. replaceExistingNodeAtPath is required. expectedHash (no @) is required unless createFileIfMissing=true with a single file anchor. Example: { to:{ bodyEndOf:'src/a.ts#FD:0' }, code:'\\nreturn 1;', replaceExistingNodeAtPath:false, expectedHash:'p123:c456' }",
|
|
1430
1434
|
"parameters": {
|
|
1431
1435
|
"type": "object",
|
|
1432
1436
|
"properties": {
|
|
@@ -1476,7 +1480,7 @@
|
|
|
1476
1480
|
},
|
|
1477
1481
|
"createFileIfMissing": {
|
|
1478
1482
|
"type": "boolean",
|
|
1479
|
-
"description": "Create file when using a single file anchor."
|
|
1483
|
+
"description": "Create a new file when using a single file anchor, for example to:{end:'src/new-file.ts'}. Not valid with node anchors."
|
|
1480
1484
|
},
|
|
1481
1485
|
"newFileInitialContent": {
|
|
1482
1486
|
"type": "string",
|
|
@@ -2013,6 +2017,48 @@
|
|
|
2013
2017
|
}
|
|
2014
2018
|
]
|
|
2015
2019
|
},
|
|
2020
|
+
{
|
|
2021
|
+
"name": "shell-command",
|
|
2022
|
+
"category": "pando",
|
|
2023
|
+
"signature": "shell-command(command, reason, timeoutMs, shell, maxOutputBytes)",
|
|
2024
|
+
"description": "Run a shell command with cwd fixed to the selected Pando project root, then synchronously snapshot any worktree changes before another modifying Pando operation can run. The project-root confinement is also enforced by the host environment. reason is required and is written into the snapshot receipt/trailers for auditability. Command failures are returned to the agent with exit code, stdout, stderr, timeout state, and snapshot metadata. Example: { command:'npm test', reason:'Verify the current change.' }",
|
|
2025
|
+
"parameters": {
|
|
2026
|
+
"type": "object",
|
|
2027
|
+
"properties": {
|
|
2028
|
+
"command": {
|
|
2029
|
+
"type": "string",
|
|
2030
|
+
"description": "Shell command to execute. It always runs with cwd set to the selected project root."
|
|
2031
|
+
},
|
|
2032
|
+
"reason": {
|
|
2033
|
+
"type": "string",
|
|
2034
|
+
"description": "Required audit reason for running this command. This is persisted in the snapshot metadata."
|
|
2035
|
+
},
|
|
2036
|
+
"timeoutMs": {
|
|
2037
|
+
"type": "number",
|
|
2038
|
+
"description": "Optional timeout in milliseconds. Must be 1000..600000. Defaults to 120000."
|
|
2039
|
+
},
|
|
2040
|
+
"shell": {
|
|
2041
|
+
"type": "string",
|
|
2042
|
+
"description": "Optional shell executable. Defaults to the platform shell."
|
|
2043
|
+
},
|
|
2044
|
+
"maxOutputBytes": {
|
|
2045
|
+
"type": "number",
|
|
2046
|
+
"description": "Optional combined stdout/stderr output cap in bytes. Must be 1024..1000000. Defaults to 200000."
|
|
2047
|
+
}
|
|
2048
|
+
},
|
|
2049
|
+
"required": [
|
|
2050
|
+
"command",
|
|
2051
|
+
"reason"
|
|
2052
|
+
],
|
|
2053
|
+
"additionalProperties": false
|
|
2054
|
+
},
|
|
2055
|
+
"examples": [
|
|
2056
|
+
{
|
|
2057
|
+
"command": "npm test",
|
|
2058
|
+
"reason": "Verify the current change."
|
|
2059
|
+
}
|
|
2060
|
+
]
|
|
2061
|
+
},
|
|
2016
2062
|
{
|
|
2017
2063
|
"name": "list-snapshots",
|
|
2018
2064
|
"category": "pando",
|
|
Binary file
|
|
Binary file
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{b as G}from"./chunk-AYCBSZ56.mjs";import s from"path";import v from"os";import l from"fs";import x from"crypto";function D(){return process.env.PANDO_DATA_DIR||s.join(v.homedir(),h)}function _(n){let t=n,r=s.parse(t);for(;t.length>r.root.length&&/[\\/]+$/.test(t);)t=t.replace(/[\\/]+$/,"");return t}function g(n){let t=s.resolve(n),r=t;try{let e=l.realpathSync.native;r=typeof e=="function"?e(t):l.realpathSync(t)}catch{}return _(r)}function w(n){let t=n.trim().replace(/\.git$/,"");if(!t)return null;let r=t.match(/^git@([^:]+):(.+)$/);if(r){let e=r[1],i=r[2].replace(/^\/+/,"").split("/");if(i.length>=2)return`${e}/${i[0]}/${i[1]}`}try{let e=new URL(t),o=e.hostname,c=e.pathname.replace(/^\/+/,"").split("/");if(o&&c.length>=2)return`${o}/${c[0]}/${c[1]}`}catch{}return null}function d(n){return x.createHash("sha1").update(n).digest("hex").slice(0,12)}function T(n){return n.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^A-Za-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^[-._]+|[-._]+$/g,"").slice(0,64).replace(/^[-._]+|[-._]+$/g,"")||"workspace"}function L(n,t){let r=s.basename(_(n));return`${T(r)}-${t}`}function j(){return s.join(D(),"workspace-registry.json")}function p(n){try{return l.readFileSync(n,"utf8").trim()}catch{return null}}function A(n){let t=s.join(n,".git");try{let r=l.statSync(t);if(r.isDirectory())return t;if(r.isFile()){let o=p(t)?.match(/^gitdir:\s*(.+)$/i);if(o){let i=o[1].trim();return s.isAbsolute(i)?i:s.resolve(n,i)}}}catch{return null}return null}function C(n){let t=s.join(n,"commondir"),r=p(t);if(!r)return g(n);let e=s.isAbsolute(r)?r:s.resolve(n,r);return g(e)}function W(n){return g(s.join(n,"objects"))}function H(n){let t=g(n);for(;;){let r=s.join(t,".git");if(l.existsSync(r))return t;let e=s.dirname(t);if(e===t)break;t=e}return null}function M(n){let t=g(n),r=H(t);return r?g(r):null}function z(n){let t=s.join(n,"config"),r=p(t);if(!r)return null;let e=r.split(/\r?\n/),o=!1,i=null;for(let c of e){if(c.match(/^\s*\[remote\s+"([^"]+)"\]\s*$/)){o=!0;continue}if(c.startsWith("[")&&(o=!1),o){let a=c.match(/^\s*url\s*=\s*(.+)$/);if(a&&(i=a[1].trim(),i))return i}}return i}function F(n){let t=s.join(n,"HEAD"),r=p(t);if(!r)return{branch:null,commit:null};if(r.startsWith("ref:")){let e=r.replace("ref:","").trim(),o=e.split("/").slice(-1)[0]||null,i=s.join(n,e),c=p(i);if(!c){let u=p(s.join(n,"packed-refs"));if(u){let a=u.split(/\r?\n/).find(m=>m.endsWith(` ${e}`));a&&(c=a.split(" ")[0])}}return{branch:o,commit:c||null}}return{branch:"HEAD",commit:r||null}}function B(){try{let n=l.readFileSync(j(),"utf8"),t=JSON.parse(n);if(t&&t.version===1&&t.entries&&typeof t.entries=="object")return{version:1,entries:t.entries}}catch{}return{version:1,entries:{}}}function U(n){let t=j(),r=s.dirname(t);l.mkdirSync(r,{recursive:!0});let e=`${t}.${process.pid}.${Date.now()}.tmp`;l.writeFileSync(e,`${JSON.stringify(n,null,2)}
|
|
2
|
-
`,"utf8"),l.renameSync(e,t)}function X(n,t){if(!t)return{canonicalRepoRoot:n,gitCommonDir:null,gitObjectDir:null,fingerprint:`non-git:path:${n}`};let r=A(t),e=r?C(r):null,o=e?W(e):null;return{canonicalRepoRoot:t,gitCommonDir:e,gitObjectDir:o,fingerprint:["git",`root:${t}`,`common:${e??""}`,`objects:${o??""}`].join("|")}}function J(n){try{let t=B();t.entries[n.storageRoot]={workspaceId:n.id,workspaceDirName:n.dirName,locationId:n.locationId,incarnationId:n.incarnationId,canonicalProjectRoot:n.canonicalProjectRoot,canonicalRepoRoot:n.canonicalRepoRoot,storageRoot:n.storageRoot,repoIdentity:n.repoIdentity??null,gitCommonDir:n.gitCommonDir??null,gitObjectDir:n.gitObjectDir??null,remote:n.remote??null,branch:n.branch??null,commit:n.commit??null,updatedAt:new Date().toISOString()},U(t)}catch{}}function K(n){let t=g(n),r=M(t),e=r??t,o=r,i=d(e),c=X(e,o),u=d(c.fingerprint),a=`ws-${d(`${i}:${u}`)}`,m=L(e,a);if(!o)return{id:a,dirName:m,locationId:i,incarnationId:u,canonicalProjectRoot:t,canonicalRepoRoot:e,storageRoot:e,gitCommonDir:c.gitCommonDir,gitObjectDir:c.gitObjectDir,repoIdentity:null,remote:null,branch:null,commit:null};let f=A(o),y=f?z(f):null,E=y?w(y):null,P=f?F(f):{branch:null,commit:null};return{id:a,dirName:m,locationId:i,incarnationId:u,canonicalProjectRoot:t,canonicalRepoRoot:o,storageRoot:e,gitCommonDir:c.gitCommonDir,gitObjectDir:c.gitObjectDir,repoIdentity:E??`local:${d(e)}`,remote:y,branch:P.branch,commit:P.commit}}function q(n){let t=K(n);return J(t),s.join(D(),"workspaces",t.dirName)}function hn(n){return s.join(q(n),".pando-snapshots.db")}var h,$=G(()=>{"use strict";h=".pando-data"});$();import N from"fs";import k from"os";import I from"path";import{inspect as Q}from"util";var O=(()=>{let n=process.env.PANDO_LOG_DIR||process.env.PANDO_WORKSPACE_DATA_DIR;if(n)return n;try{return D()}catch{let r=typeof k.homedir=="function"?k.homedir():process.env.HOME;if(r)return I.join(r,h)}let t=process.env.HOME||process.cwd();return I.join(t,h)})(),V=I.join(O,"pando.log"),Z=I.join(O,"pando.jsonl"),b=n=>{if(n==null)return!1;let t=n.trim().toLowerCase();return t!=="0"&&t!=="false"&&t!=="off"&&t!=="no"},Y=b(process.env.PANDO_LOG_DISABLED),R=!Y&&(process.env.PANDO_DEBUG==null||b(process.env.PANDO_DEBUG)),nn=R&&(process.env.PANDO_INDEX_HOT_LOG==null||b(process.env.PANDO_INDEX_HOT_LOG)),tn=R&&(process.env.PANDO_INDEX_TIMING==null||b(process.env.PANDO_INDEX_TIMING)),rn=new Set(["BatchAnalysisScheduler","ClojureIndex","ClojureIndexer","ThreadedIndexer"]),en=new Set(["IndexTiming"]);function S(){try{N.mkdirSync(O,{recursive:!0})}catch{}}function on(n){if(n!==void 0)try{return typeof n=="string"?n:Q(n,{depth:null,breakLength:1/0,maxArrayLength:1/0})}catch{try{return JSON.stringify(n)}catch{return String(n)}}}var sn=!1;function On(){return R}function cn(n){return R?en.has(n)?tn:!(!nn&&rn.has(n)):!1}function Pn(n,t,r){if(!cn(n))return;let e=new Date().toISOString(),o=on(r),i=o?`[${e}] [${n}] ${t} :: ${o}`:`[${e}] [${n}] ${t}`;if(!sn&&!process.env.PANDO_QUIET)try{process.stderr.write(i+`
|
|
3
|
-
`)}catch{}try{S(),N.appendFileSync(V,i+`
|
|
4
|
-
`,"utf8")}catch{}try{S();let c=JSON.stringify({ts:e,component:n,message:t,...r!==void 0?{data:r}:{}});N.appendFileSync(Z,c+`
|
|
5
|
-
`,"utf8")}catch{}}import{createHash as an}from"crypto";var ln=/^-?\d+$/,un=(1n<<63n)-1n;function gn(n){let t=an("sha1").update(n).digest(),r=0n;for(let e=0;e<8;e+=1)r=r<<8n|BigInt(t[e]);return r&un}function An(n){if(n==null)return null;if(typeof n=="bigint")return n;if(typeof n=="number"&&Number.isFinite(n))return BigInt(Math.trunc(n));if(typeof n=="string"){let t=n.trim();if(!t)return null;if(ln.test(t))try{return BigInt(t)}catch{return null}return gn(t)}return null}export{q as a,hn as b,$ as c,On as d,Pn as e,An as f};
|