@code-yeongyu/senpi 2026.9.29-2 → 2026.9.29-3
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/CHANGELOG.md +14 -0
- package/dist/bundle/chunks/{anthropic-messages-OMTQOHSI.js → anthropic-messages-7WTVWELD.js} +1 -1
- package/dist/bundle/chunks/{app-server-command-ZC6A4C3L.js → app-server-command-5DSRGKFG.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-Z4FAFKPJ.js → azure-openai-responses-XVZ3FMH2.js} +1 -1
- package/dist/bundle/chunks/{chunk-U2SAEU63.js → chunk-27C3ZSZG.js} +1 -1
- package/dist/bundle/chunks/{chunk-YJUO37UX.js → chunk-2POUJCWM.js} +1 -1
- package/dist/bundle/chunks/{chunk-4LVZQRDG.js → chunk-4VWWEMCJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-36ACNYQR.js → chunk-7RVWDN5Z.js} +1 -1
- package/dist/bundle/chunks/{chunk-YS72TY6S.js → chunk-CZNE6LIO.js} +1 -1
- package/dist/bundle/chunks/{chunk-ILELKDDB.js → chunk-DWNYCJ43.js} +1 -1
- package/dist/bundle/chunks/{chunk-OMLHHPMZ.js → chunk-EB3GDOU4.js} +1 -1
- package/dist/bundle/chunks/{chunk-2HWLCW54.js → chunk-EQBN6TVJ.js} +1 -1
- package/dist/bundle/chunks/{chunk-E5F5SVZF.js → chunk-FUGMDU6B.js} +1 -1
- package/dist/bundle/chunks/{chunk-RSPHQOSG.js → chunk-GE32OHDE.js} +7 -7
- package/dist/bundle/chunks/chunk-GKR74EKE.js +3 -0
- package/dist/bundle/chunks/{chunk-UYV2UM6E.js → chunk-ILQTW6KB.js} +1 -1
- package/dist/bundle/chunks/{chunk-TH4XD7AJ.js → chunk-JEWB5XTL.js} +1 -1
- package/dist/bundle/chunks/{chunk-FAV4DX74.js → chunk-K2SHQNAA.js} +1 -1
- package/dist/bundle/chunks/{chunk-NVJUCNHP.js → chunk-K7B7NFOK.js} +1 -1
- package/dist/bundle/chunks/{chunk-TZMNXKL2.js → chunk-KO6GO5ZY.js} +1 -1
- package/dist/bundle/chunks/{chunk-5CGFVKUK.js → chunk-LB2B2Q4P.js} +1 -1
- package/dist/bundle/chunks/{chunk-77OBRAUG.js → chunk-M4AHRI5L.js} +1 -1
- package/dist/bundle/chunks/{chunk-SW4U2HHU.js → chunk-OVDACFW2.js} +1 -1
- package/dist/bundle/chunks/{chunk-BTRONX2A.js → chunk-RUOJQL6B.js} +1 -1
- package/dist/bundle/chunks/{chunk-ASAQQ6VM.js → chunk-SH6VUPE4.js} +1 -1
- package/dist/bundle/chunks/{chunk-TFW6SS3P.js → chunk-SNDTJL2H.js} +1 -1
- package/dist/bundle/chunks/{chunk-Y5A6TKBN.js → chunk-T3HGPHPP.js} +1 -1
- package/dist/bundle/chunks/{chunk-BPZ5KIOS.js → chunk-UK5TE7WR.js} +1 -1
- package/dist/bundle/chunks/{chunk-NDNZU2X7.js → chunk-UNTVGMGW.js} +3 -3
- package/dist/bundle/chunks/{chunk-BQGFWWDC.js → chunk-VLTMFAWQ.js} +1 -1
- package/dist/bundle/chunks/{chunk-XDZ5RSMX.js → chunk-W4AG5TN4.js} +1 -1
- package/dist/bundle/chunks/chunk-WCAKUCN3.js +14 -0
- package/dist/bundle/chunks/{chunk-UEWSEALS.js → chunk-WRPX2M5D.js} +1 -1
- package/dist/bundle/chunks/{chunk-DA4W77J7.js → chunk-XBGO2JZD.js} +1 -1
- package/dist/bundle/chunks/chunk-XVX4M3DZ.js +2 -0
- package/dist/bundle/chunks/chunk-YD32NXKZ.js +8 -0
- package/dist/bundle/chunks/chunk-YOPVJDSU.js +2 -0
- package/dist/bundle/chunks/cli-main-V3T5WOV6.js +3 -0
- package/dist/bundle/chunks/{google-generative-ai-NFSRK6V5.js → google-generative-ai-XO6BUQVD.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-6YEVHEPI.js → google-vertex-SGNV6ZMK.js} +1 -1
- package/dist/bundle/chunks/{help-fast-path-RYMO5ODA.js → help-fast-path-AYPE26W2.js} +1 -1
- package/dist/bundle/chunks/{host-command-BU6XSX4H.js → host-command-ZTMADQIT.js} +1 -1
- package/dist/bundle/chunks/{host-lifecycle-22DRSTVI.js → host-lifecycle-FTH7WAQN.js} +1 -1
- package/dist/bundle/chunks/{interactive-host-runtime-P3FYZWSY.js → interactive-host-runtime-XDRXCEJ3.js} +1 -1
- package/dist/bundle/chunks/{interactive-mode-VCIOGSIZ.js → interactive-mode-6VFVZKKW.js} +1 -1
- package/dist/bundle/chunks/{list-tips-XXZ5PLE3.js → list-tips-ASETMEFS.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-R5PTP4P3.js → mistral-conversations-TVJBIL35.js} +1 -1
- package/dist/bundle/chunks/{multi-session-host-PRY7CJLK.js → multi-session-host-5VFMTPY7.js} +1 -1
- package/dist/bundle/chunks/{native-loader-SU5SGTSW.js → native-loader-WM7NDPEO.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-6B2ZLWTN.js → openai-codex-responses-RUT66DHS.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-5NTZZNVJ.js → openai-completions-THHRTH7B.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-V4JEBGEX.js → openai-responses-ITED6XXB.js} +1 -1
- package/dist/bundle/chunks/{package-manager-cli-RQ2NJAJ3.js → package-manager-cli-RAQRCH5L.js} +3 -3
- package/dist/bundle/chunks/{rg-engine-XHGOVGVG.js → rg-engine-G2YTYL2T.js} +1 -1
- package/dist/bundle/chunks/{rotation-stream-YQLGLRCX.js → rotation-stream-4FQW6IX5.js} +1 -1
- package/dist/bundle/chunks/{rpc-mode-U2EQRVC3.js → rpc-mode-W5P5QMF7.js} +1 -1
- package/dist/bundle/chunks/{schedule-command-DXC3ECXT.js → schedule-command-EFQUSPN4.js} +1 -1
- package/dist/bundle/chunks/{session-picker-KTXLU6MQ.js → session-picker-FF2J4OQA.js} +1 -1
- package/dist/bundle/chunks/session-worker.js +188 -188
- package/dist/bundle/chunks/{state-store-5A2TZ4SG.js → state-store-IIQL55GC.js} +1 -1
- package/dist/bundle/cli.js +2 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/bundle/runtime-manifest.json +1 -0
- package/dist/cli.js +24 -4
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -6
- package/dist/config.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -2
- package/dist/main.js.map +1 -1
- package/dist/package-manager-cli.js +3 -3
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/runtime-snapshot/enter.d.ts +17 -0
- package/dist/runtime-snapshot/enter.d.ts.map +1 -0
- package/dist/runtime-snapshot/enter.js +72 -0
- package/dist/runtime-snapshot/enter.js.map +1 -0
- package/dist/runtime-snapshot/layout.d.ts +15 -0
- package/dist/runtime-snapshot/layout.d.ts.map +1 -0
- package/dist/runtime-snapshot/layout.js +126 -0
- package/dist/runtime-snapshot/layout.js.map +1 -0
- package/dist/runtime-snapshot/marker.d.ts +13 -0
- package/dist/runtime-snapshot/marker.d.ts.map +1 -0
- package/dist/runtime-snapshot/marker.js +40 -0
- package/dist/runtime-snapshot/marker.js.map +1 -0
- package/dist/runtime-snapshot/registry.d.ts +14 -0
- package/dist/runtime-snapshot/registry.d.ts.map +1 -0
- package/dist/runtime-snapshot/registry.js +124 -0
- package/dist/runtime-snapshot/registry.js.map +1 -0
- package/dist/senpi +24 -4
- package/node_modules/@code-yeongyu/senpi-codemode/CHANGELOG.md +12 -0
- package/node_modules/@code-yeongyu/senpi-codemode/package.json +4 -4
- package/node_modules/@earendil-works/pi-agent-core/package.json +3 -3
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js +2 -1
- package/node_modules/@earendil-works/pi-ai/dist/api/lazy.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/.manifest.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/providers/data/openrouter.json +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-failure-description.d.ts +7 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-failure-description.d.ts.map +1 -1
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-failure-description.js +21 -0
- package/node_modules/@earendil-works/pi-ai/dist/utils/provider-failure-description.js.map +1 -1
- package/node_modules/@earendil-works/pi-ai/package.json +2 -2
- package/node_modules/@earendil-works/pi-pty/package.json +1 -1
- package/node_modules/@earendil-works/pi-telemetry/package.json +1 -1
- package/node_modules/@earendil-works/pi-tui/package.json +1 -1
- package/package.json +7 -7
- package/dist/bundle/chunks/chunk-DXU53IPJ.js +0 -8
- package/dist/bundle/chunks/chunk-FILEUW2D.js +0 -3
- package/dist/bundle/chunks/chunk-PBWQK23Z.js +0 -14
- package/dist/bundle/chunks/chunk-TJV2LFKM.js +0 -2
- package/dist/bundle/chunks/chunk-UIOI2SK3.js +0 -2
- package/dist/bundle/chunks/cli-main-RPQFXRJ7.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
2
|
-
import{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth}from"./chunk-
|
|
2
|
+
import{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth}from"./chunk-7RVWDN5Z.js";import"./chunk-7X72IACK.js";import"./chunk-KUPQO7MC.js";import"./chunk-GZVCRV7I.js";import"./chunk-U3VOXCGP.js";import"./chunk-WCAKUCN3.js";import"./chunk-ATQFN5HI.js";import"./chunk-IKOFCODM.js";export{CREDENTIAL_POOL_STATE_FILENAME,CredentialSlotRepository,acquireHalfOpenLease,credentialPoolStatePath,slotHealth};
|
package/dist/bundle/cli.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
3
|
-
import{enableStartupCompileCache}from"./chunks/chunk-F73COJ7R.js";import{getLatestPiRelease,hasInheritedInspectorOption,isNewerPackageVersion,processBunRuntimeOptions,releaseInheritedInspectorForChild,resolveBunReexec}from"./chunks/chunk-
|
|
3
|
+
import{enableStartupCompileCache}from"./chunks/chunk-F73COJ7R.js";import{getLatestPiRelease,hasInheritedInspectorOption,isNewerPackageVersion,processBunRuntimeOptions,releaseInheritedInspectorForChild,resolveBunReexec}from"./chunks/chunk-4VWWEMCJ.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,DISPLAY_VERSION,PACKAGE_NAME,RUNTIME_SNAPSHOT_MARKER,VERSION,brandProfile,findNodePackageDir,getAgentDir,getInstallPackageDir,getSelfUpdateCommand,getSelfUpdateUnavailableInstruction,isBundledNode,readRuntimeSnapshotMarker}from"./chunks/chunk-WCAKUCN3.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-IKOFCODM.js";import{spawn as spawn2,spawnSync}from"node:child_process";import{existsSync as existsSync2,realpathSync as realpathSync3}from"node:fs";import{dirname as dirname3,join as join5}from"node:path";import{fileURLToPath}from"node:url";import{createHash}from"node:crypto";import{readFileSync,realpathSync as realpathSync2}from"node:fs";import{basename as basename2,dirname as dirname2,join as join3,relative}from"node:path";import{pathToFileURL}from"node:url";import{copyFileSync,cpSync,existsSync,lstatSync,mkdirSync,readdirSync,realpathSync,renameSync,rmSync,statSync,symlinkSync,writeFileSync}from"node:fs";import{basename,dirname,join}from"node:path";var RuntimeSnapshotLayoutError=class extends Error{constructor(packageName){super(`runtime snapshot resolves ${packageName} differently from the install`),this.packageName=packageName}};function isMissing(error){return error instanceof Error&&"code"in error&&(error.code==="ENOENT"||error.code==="ENOTDIR")}function occupied(path){try{return lstatSync(path),!0}catch(error){if(isMissing(error))return!1;throw error}}function linkEntry(source,target){let isDirectory;try{isDirectory=statSync(source).isDirectory()}catch(error){if(isMissing(error))return;throw error}if(process.platform==="win32"&&!isDirectory){copyFileSync(source,target);return}symlinkSync(source,target,isDirectory?"junction":"file")}function linkChildren(sourceDir,targetDir,skip){for(let name of readdirSync(sourceDir))skip.has(name)||occupied(join(targetDir,name))||linkEntry(join(sourceDir,name),join(targetDir,name))}function moduleDirectoriesFrom(dir){let directories=[];for(let current=dir;;current=dirname(current)){if(basename(current)!=="node_modules"){let candidate=join(current,"node_modules");existsSync(candidate)&&directories.push(candidate)}if(dirname(current)===current)return directories}}function linkModules(packageDir,target){mkdirSync(target,{recursive:!0});for(let source of moduleDirectoriesFrom(packageDir))for(let name of readdirSync(source)){if(name===".bin")continue;if(!(name.startsWith("@")&&statSync(join(source,name)).isDirectory())){occupied(join(target,name))||linkEntry(join(source,name),join(target,name));continue}mkdirSync(join(target,name),{recursive:!0}),linkChildren(join(source,name),join(target,name),new Set)}}function packageRootFrom(dir,packageName){for(let modules of moduleDirectoriesFrom(dir)){let root=join(modules,packageName);if(existsSync(join(root,"package.json")))return realpathSync(root)}}function verifyExternals(packageDir,snapshotBundleDir,externals){for(let name of externals){let expected=packageRootFrom(packageDir,name);if(expected!==void 0&&packageRootFrom(snapshotBundleDir,name)!==expected)throw new RuntimeSnapshotLayoutError(name)}}function materializeRuntimeSnapshot(packageDir,target,manifest){let staging=join(dirname(target),`.tmp-${basename(target)}-${process.pid}`);rmSync(staging,{recursive:!0,force:!0});try{let snapshotBundleDir=join(staging,"dist","bundle");mkdirSync(join(staging,"dist"),{recursive:!0}),cpSync(join(packageDir,"dist","bundle"),snapshotBundleDir,{recursive:!0}),copyFileSync(join(packageDir,"package.json"),join(staging,"package.json")),linkChildren(packageDir,staging,new Set(["dist","package.json","node_modules"])),linkChildren(join(packageDir,"dist"),join(staging,"dist"),new Set(["bundle"])),linkModules(packageDir,join(staging,"node_modules")),verifyExternals(packageDir,join(snapshotBundleDir,"chunks"),manifest.externals);let marker={buildId:manifest.buildId,installPackageDir:realpathSync(packageDir)};writeFileSync(join(staging,RUNTIME_SNAPSHOT_MARKER),`${JSON.stringify(marker)}
|
|
4
|
+
`),rmSync(target,{recursive:!0,force:!0}),renameSync(staging,target)}catch(error){throw rmSync(staging,{recursive:!0,force:!0}),error}}import{mkdirSync as mkdirSync2,readdirSync as readdirSync2,renameSync as renameSync2,rmSync as rmSync2,statSync as statSync2,unlinkSync,utimesSync,writeFileSync as writeFileSync2}from"node:fs";import{join as join2}from"node:path";var LOCK_NAME=".lock",CLAIMS_DIR="claims",STALE_LOCK_MS=3e4,LOCK_WAIT_MS=5e3,LOCK_RETRY_MS=25,UNUSED_SNAPSHOT_GRACE_MS=10*6e4,LEFTOVER_MS=60*6e4;function errorCode(error){return error instanceof Error&&"code"in error?error.code:void 0}function ageMs(path,now){try{return now-statSync2(path).mtimeMs}catch(error){if(errorCode(error)==="ENOENT")return Number.POSITIVE_INFINITY;throw error}}function sleepSync(ms){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,ms)}function withRuntimeLock(root,task){mkdirSync2(root,{recursive:!0});let lock=join2(root,LOCK_NAME),deadline=Date.now()+LOCK_WAIT_MS;for(;;){try{mkdirSync2(lock);break}catch(error){if(errorCode(error)!=="EEXIST")throw error}if(ageMs(lock,Date.now())>STALE_LOCK_MS)rmSync2(lock,{recursive:!0,force:!0});else{if(Date.now()>deadline)return;sleepSync(LOCK_RETRY_MS)}}try{return task()}finally{rmSync2(lock,{recursive:!0,force:!0})}}function isProcessAlive(pid){try{return process.kill(pid,0),!0}catch(error){return errorCode(error)!=="ESRCH"}}function claimRuntimeSnapshot(snapshotDir,pid){mkdirSync2(join2(snapshotDir,CLAIMS_DIR),{recursive:!0}),writeFileSync2(join2(snapshotDir,CLAIMS_DIR,String(pid)),"");let now=new Date;utimesSync(join2(snapshotDir,RUNTIME_SNAPSHOT_MARKER),now,now)}function reapClaims(snapshotDir,isAlive){let names;try{names=readdirSync2(join2(snapshotDir,CLAIMS_DIR))}catch(error){if(errorCode(error)==="ENOENT")return 0;throw error}let live=0;for(let name of names){let pid=Number(name);Number.isSafeInteger(pid)&&pid>0&&isAlive(pid)?live+=1:unlinkSync(join2(snapshotDir,CLAIMS_DIR,name))}return live}function pruneRuntimeSnapshots(root,keep,now,isAlive=isProcessAlive){reapClaims(join2(root,keep),isAlive);for(let name of readdirSync2(root)){if(name===LOCK_NAME||name===keep)continue;let path=join2(root,name);if(name.startsWith(".")){ageMs(path,now)>LEFTOVER_MS&&rmSync2(path,{recursive:!0,force:!0});continue}if(reapClaims(path,isAlive)>0||ageMs(join2(path,RUNTIME_SNAPSHOT_MARKER),now)<=UNUSED_SNAPSHOT_GRACE_MS)continue;let trash=join2(root,`.trash-${name}-${process.pid}`);renameSync2(path,trash),rmSync2(trash,{recursive:!0,force:!0})}}var RUNTIME_MANIFEST="runtime-manifest.json";function readRuntimeManifest(bundleDir){let parsed;try{parsed=JSON.parse(readFileSync(join3(bundleDir,RUNTIME_MANIFEST),"utf8"))}catch(error){if(error instanceof Error&&"code"in error&&error.code==="ENOENT")return;throw error}if(typeof parsed=="object"&&parsed!==null&&"buildId"in parsed&&typeof parsed.buildId=="string"&&/^[A-Za-z0-9._-]+$/.test(parsed.buildId)&&"externals"in parsed&&Array.isArray(parsed.externals)&&parsed.externals.every(name=>typeof name=="string"))return{buildId:parsed.buildId,externals:parsed.externals}}function prepareRuntimeSnapshot(entryPath,packageDir,agentDir){let bundleDir=dirname2(entryPath),runtimeRoot=join3(agentDir,"runtime");try{if(readRuntimeSnapshotMarker(packageDir))return withRuntimeLock(runtimeRoot,()=>claimRuntimeSnapshot(packageDir,process.pid)),{kind:"run-here"};let manifest=readRuntimeManifest(bundleDir);if(!manifest||relative(packageDir,bundleDir)!==join3("dist","bundle"))return{kind:"run-here"};let installId=createHash("sha256").update(realpathSync2(packageDir)).digest("hex").slice(0,12),snapshotId=`${manifest.buildId}-${installId}`,snapshotDir=join3(runtimeRoot,snapshotId);return withRuntimeLock(runtimeRoot,()=>(readRuntimeSnapshotMarker(snapshotDir)?.buildId!==manifest.buildId&&materializeRuntimeSnapshot(packageDir,snapshotDir,manifest),claimRuntimeSnapshot(snapshotDir,process.pid),pruneRuntimeSnapshots(runtimeRoot,snapshotId,Date.now()),!0))?{kind:"hand-off",entryUrl:pathToFileURL(join3(snapshotDir,"dist","bundle",basename2(entryPath))).href,snapshotDir}:{kind:"run-here"}}catch{return{kind:"run-here"}}}import{spawn}from"node:child_process";import{readFileSync as readFileSync2}from"node:fs";import{join as join4}from"node:path";function parseBootstrapSelfUpdateArgs(args2){let[command,...rest]=args2;if(command!=="update")return;let force=!1,selfFlag=!1,extensionsFlag=!1,extensionFlag=!1,source;for(let index=0;index<rest.length;index++){let arg=rest[index];if(arg==="-h"||arg==="--help")return;if(arg==="--force"){force=!0;continue}if(arg==="--self"){selfFlag=!0;continue}if(arg==="--extensions"){extensionsFlag=!0;continue}if(arg==="--extension"){extensionFlag=!0,index++;continue}if(arg.startsWith("-")||source)return;source=arg}if(extensionFlag)return;let sourceIsSelf=source==="self"||source==="pi"||source===APP_NAME;if(!(source&&!sourceIsSelf)&&!(!selfFlag&&!sourceIsSelf&&extensionsFlag))return{force}}function getObjectProperty(value,key){if(!(!value||typeof value!="object"))return Object.getOwnPropertyDescriptor(value,key)?.value}function readConfiguredNpmCommand(){try{let parsed=JSON.parse(readFileSync2(join4(getAgentDir(),"settings.json"),"utf-8")),npmCommand=getObjectProperty(parsed,"npmCommand");return!Array.isArray(npmCommand)||npmCommand.some(part=>typeof part!="string")?void 0:npmCommand.length>0?npmCommand:void 0}catch{return}}async function runCommand(step){await new Promise((resolve,reject)=>{let child=spawn(step.command,step.args,{stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{code===0?resolve():reject(signal?new Error(`${step.display} terminated by signal ${signal}`):new Error(`${step.display} exited with code ${code??"unknown"}`))})})}async function handleBootstrapSelfUpdate(args2,dependencies={}){let parsed=parseBootstrapSelfUpdateArgs(args2);if(!parsed)return!1;let writeStdout=dependencies.writeStdout??(line=>console.log(line)),writeStderr=dependencies.writeStderr??(line=>console.error(line)),readNpmCommand=dependencies.readNpmCommand??readConfiguredNpmCommand,resolveSelfUpdateCommand=dependencies.getSelfUpdateCommand??getSelfUpdateCommand,resolveUnavailableInstruction=dependencies.getUnavailableInstruction??getSelfUpdateUnavailableInstruction,executeCommand=dependencies.runCommand??runCommand,brandUpdate=brandProfile()?.update;if(brandUpdate)return writeStdout(`${APP_NAME} ships inside ${brandUpdate.packageName}. Update it with: ${brandUpdate.command}`),!0;let loadLatestRelease=dependencies.getLatestRelease??getLatestPiRelease,latestRelease;if(!parsed.force)try{latestRelease=await loadLatestRelease(VERSION)}catch{latestRelease=void 0}let updatePackageName=latestRelease?.packageName??PACKAGE_NAME;if(!(parsed.force||!latestRelease||updatePackageName!==PACKAGE_NAME||isNewerPackageVersion(latestRelease.version,VERSION)))return writeStdout(`${APP_NAME} is already up to date (v${VERSION})`),!0;let npmCommand=readNpmCommand(),selfUpdateCommand=resolveSelfUpdateCommand(PACKAGE_NAME,npmCommand,updatePackageName);if(!selfUpdateCommand)return writeStderr(`error: ${APP_NAME} cannot self-update this installation.`),writeStderr(resolveUnavailableInstruction(PACKAGE_NAME,npmCommand,updatePackageName)),process.argv[1]&&(writeStderr(""),writeStderr(`Location of ${APP_NAME} executable: ${process.argv[1]}`)),process.exitCode=1,!0;latestRelease?.note?.trim()&&(writeStdout(""),writeStdout("Update note"),writeStdout(latestRelease.note.trim()),writeStdout("")),writeStdout(`Updating ${APP_NAME} with ${selfUpdateCommand.display}...`);for(let step of selfUpdateCommand.steps??[selfUpdateCommand])try{await executeCommand(step)}catch(error){let message=error instanceof Error?error.message:"Unknown package command error";return writeStderr(`Error: ${message}`),writeStderr(`If this keeps failing, run this command yourself: ${selfUpdateCommand.display}`),process.exitCode=1,!0}return writeStdout(`Updated ${APP_NAME}`),!0}var __rewriteRelativeImportExtension=function(path,preserveJsx){return typeof path=="string"&&/^\.\.?\//.test(path)?path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(m,tsx,d,ext,cm){return tsx?preserveJsx?".jsx":".js":d&&(!ext||!cm)?m:d+ext+"."+cm.toLowerCase()+"js"}):path};function reexecUnderBunIfNeeded(){let options=processBunRuntimeOptions(existsSync2,realpathSync3),scriptRealPath=process.argv[1]??fileURLToPath(import.meta.url);try{scriptRealPath=realpathSync3(scriptRealPath)}catch{}let decision=resolveBunReexec({scriptRealPath,versions:process.versions,hasInheritedInspectorOption:hasInheritedInspectorOption(),options});if(decision.action==="stay")return!1;let result=spawnSync(decision.bunPath,[scriptRealPath,...process.argv.slice(2)],{stdio:"inherit",windowsHide:!0});return result.signal?(process.kill(process.pid,result.signal),!0):(process.exitCode=result.status??1,!0)}reexecUnderBunIfNeeded()&&process.exit();enableStartupCompileCache();process.title=APP_NAME;process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});var args=process.argv.slice(2),PACKAGE_COMMANDS=new Set(["install","remove","uninstall","update","list","config"]);function isRootCommand(args2){let firstArg=args2[0];return firstArg===void 0||!PACKAGE_COMMANDS.has(firstArg)}function isPackageManagerInstall(packageDir){return packageDir.replace(/\\/g,"/").includes("/node_modules/@code-yeongyu/senpi")}function isMissingBundledWorkspaceDependencies(packageDir){return isPackageManagerInstall(packageDir)?["pi-agent-core","pi-ai","pi-tui"].some(name=>!existsSync2(join5(packageDir,"node_modules","@earendil-works",name,"dist","index.js"))):!1}var ISOLATED_CHILD_ENV="SENPI_CLI_ISOLATED_CHILD";function requiresIsolatedProcess(){return process.env[ISOLATED_CHILD_ENV]==="1"?!1:process.execArgv.length>0||hasInheritedInspectorOption()}async function spawnFullCli(){let extension=import.meta.url.endsWith(".ts")?".ts":".js",fullCliPath=isBundledNode?fileURLToPath(import.meta.url):fileURLToPath(new URL(`./cli-main${extension}`,import.meta.url));releaseInheritedInspectorForChild();let childEnvironment=isBundledNode?{...process.env,[ISOLATED_CHILD_ENV]:"1"}:process.env;return await new Promise((resolve,reject)=>{let child=spawn2(process.execPath,[...process.execArgv,fullCliPath,...args],{env:childEnvironment,stdio:"inherit"});child.on("error",error=>{reject(error)}),child.on("close",(code,signal)=>{if(signal){process.kill(process.pid,signal),resolve(1);return}resolve(code??1)})})}isRootCommand(args)&&(args.includes("--version")||args.includes("-v"))&&(console.log(DISPLAY_VERSION),process.exit());if(isRootCommand(args)&&args.some(arg=>arg==="--help"||arg==="-h")){let{tryPrintHelpWithoutEngine}=await import("./chunks/help-fast-path-AYPE26W2.js");tryPrintHelpWithoutEngine(args)&&process.exit()}isMissingBundledWorkspaceDependencies(getInstallPackageDir())&&await handleBootstrapSelfUpdate(args)&&process.exit();if(requiresIsolatedProcess())process.exitCode=await spawnFullCli();else{let entryPath=fileURLToPath(import.meta.url),snapshot=isBundledNode?prepareRuntimeSnapshot(entryPath,findNodePackageDir(dirname3(entryPath)),getAgentDir()):void 0;snapshot?.kind==="hand-off"?await import(__rewriteRelativeImportExtension(snapshot.entryUrl)):await import("./chunks/cli-main-V3T5WOV6.js")}
|
package/dist/bundle/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
2
|
-
import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,shouldCompact,stripFrontmatter,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-
|
|
2
|
+
import{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DefaultResourceLoader,ExtensionEditorComponent,ExtensionRunner,FooterComponent,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UserMessageComponent,UserMessageSelectorComponent,buildNoticeBox,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,connectWebViewService,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getLastAssistantUsage,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isWriteToolResult,kernelToolsStorage,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,noticeEntryRenderer,noticeMessageRenderer,parseFrontmatter,parseSkillBlock,prepareBranchEntries,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runPrintMode,serializeConversation,shouldCompact,stripFrontmatter,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools}from"./chunks/chunk-GE32OHDE.js";import"./chunks/chunk-K2SHQNAA.js";import{DefaultPackageManager,DynamicBorder,ExtensionInputComponent,ExtensionSelectorComponent,SessionSelectorComponent,keyHint,keyText,rawKeyHint}from"./chunks/chunk-EQBN6TVJ.js";import"./chunks/chunk-2POUJCWM.js";import"./chunks/chunk-VLTMFAWQ.js";import{CURRENT_SESSION_VERSION,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,buildContextEntries,buildSessionContext,convertToLlm,formatSize,getLatestCompactionEntry,isTransportGoneError,migrateSessionEntries,parseSessionEntries,sessionEntryToContextMessages,truncateHead,truncateLine,truncateTail}from"./chunks/chunk-OVDACFW2.js";import"./chunks/chunk-NZRVAZL2.js";import"./chunks/chunk-U5KVIAHJ.js";import{runRpcMode}from"./chunks/chunk-YD32NXKZ.js";import{Theme,getLanguageFromPath,getMarkdownTheme,getSelectListTheme,getSettingsListTheme,highlightCode,initTheme}from"./chunks/chunk-27C3ZSZG.js";import{UnknownCommandError}from"./chunks/chunk-LB2B2Q4P.js";import{SettingsManager}from"./chunks/chunk-K7B7NFOK.js";import{sanitizeTerminalLabel}from"./chunks/chunk-HEKLJWA4.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import{DEFAULT_HOST_LAUNCH_SPEC,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HostLaunchSpecError,loadHostLaunchSpec,parseHostLaunchSpec,readHostStatus,runHostCommand,runHostRequest}from"./chunks/chunk-RUOJQL6B.js";import{GENERATION_HANDOFF_CAPABILITY,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,PINNED_HOST_CLIENT_CAPABILITIES,REQUIRED_HOST_CAPABILITIES,decideHostAction,ensureHost,handoffHost,parseHostProtocolInfo,probeHost,stopHost}from"./chunks/chunk-EB3GDOU4.js";import"./chunks/chunk-SNDTJL2H.js";import{createHostDaemonPaths,daemonDirectoryName,shardKey,shardSocketPath,shardSocketPathForKey}from"./chunks/chunk-UK5TE7WR.js";import{compareEngineOrdinal,engineBuildIdentity,engineBuildIdentityFrom}from"./chunks/chunk-FUGMDU6B.js";import"./chunks/chunk-XBGO2JZD.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-ILQTW6KB.js";import"./chunks/chunk-KO6GO5ZY.js";import{getPowerShellConfig,getShellConfig}from"./chunks/chunk-SH6VUPE4.js";import"./chunks/chunk-7RVWDN5Z.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-CZNE6LIO.js";import{ProjectTrustStore,hasTrustRequiringProjectResources}from"./chunks/chunk-T3HGPHPP.js";import{parseArgs}from"./chunks/chunk-W4AG5TN4.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-UNTVGMGW.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-JEWB5XTL.js";import"./chunks/chunk-4VWWEMCJ.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{CONFIG_DIR_NAME,VERSION,getAgentDir,getDocsPath,getExamplesPath,getPackageDir,getReadmePath}from"./chunks/chunk-WCAKUCN3.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-JRGNL6WM.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-CWLCGRUS.js";import"./chunks/chunk-BJICJY47.js";import"./chunks/chunk-LHYG7TK7.js";import"./chunks/chunk-KRNXUTZJ.js";import"./chunks/chunk-YOPVJDSU.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-BBK6SSYT.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-XVX4M3DZ.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";export{AgentSession,AgentSessionRuntime,ArminComponent,AssistantMessageComponent,BashExecutionComponent,BorderedLoader,BranchSummaryMessageComponent,CONFIG_DIR_NAME,CURRENT_SESSION_VERSION,CompactionSummaryMessageComponent,CredentialSynchronizationError,CustomEditor,CustomMessageComponent,DEFAULT_COMPACTION_SETTINGS,DEFAULT_HOST_LAUNCH_SPEC,DEFAULT_MAX_BYTES,DEFAULT_MAX_LINES,DefaultPackageManager,DefaultResourceLoader,DynamicBorder,ExtensionEditorComponent,ExtensionInputComponent,ExtensionRunner,ExtensionSelectorComponent,FooterComponent,GENERATION_HANDOFF_CAPABILITY,HOST_EXIT_ERROR,HOST_EXIT_FALLBACK,HOST_EXIT_OK,HOST_EXIT_REFUSED,HOST_EXIT_USAGE,HOST_PROTOCOL_VERSION,HostEnsureRefusedError,HostLaunchSpecError,InteractiveMode,LoginDialogComponent,ModelRegistry,ModelRuntime,ModelSelectorComponent,OAuthSelectorComponent,PINNED_HOST_CLIENT_CAPABILITIES,ProjectTrustStore,REQUIRED_HOST_CAPABILITIES,RpcClient,RpcClientOpenInFlightError,RpcTransportGoneError,SessionManager,SessionSelectorComponent,SettingsManager,SettingsSelectorComponent,ShowImagesSelectorComponent,SkillInvocationMessageComponent,Theme,ThemeSelectorComponent,ThinkingSelectorComponent,ToolExecutionComponent,TreeSelectorComponent,UnknownCommandError,UserMessageComponent,UserMessageSelectorComponent,VERSION,buildContextEntries,buildNoticeBox,buildSessionContext,calculateContextTokens,classifyRead,collectEntriesForBranchSummary,collectOrphanedChildren,compact,compareEngineOrdinal,connectWebViewService,convertToLlm,convertToPng,copyToClipboard,createAgentSession,createAgentSessionFromServices,createAgentSessionRuntime,createAgentSessionServices,createBashTool,createBashToolDefinition,createCodingTools,createEditTool,createEditToolDefinition,createEventBus,createExtensionRuntime,createFindTool,createFindToolDefinition,createGrepTool,createGrepToolDefinition,createHostDaemonPaths,createLocalBashOperations,createLsTool,createLsToolDefinition,createPowerShellTool,createReadOnlyTools,createReadTool,createReadToolDefinition,createSyntheticSourceInfo,createWriteTool,createWriteToolDefinition,daemonDirectoryName,decideHostAction,defineTool,detectSupportedImageMimeTypeFromFile,discoverAndLoadExtensions,engineBuildIdentity,engineBuildIdentityFrom,ensureHost,estimateTokens,findCutPoint,findTurnStartIndex,formatDimensionNote,formatSize,formatSkillsForPrompt,generateBranchSummary,generateDiffString,generateSummary,generateSummaryWithUsage,generateUnifiedPatch,getAgentDir,getDocsPath,getExamplesPath,getLanguageFromPath,getLastAssistantUsage,getLatestCompactionEntry,getMarkdownTheme,getPackageDir,getPowerShellConfig,getReadmePath,getSelectListTheme,getSettingsListTheme,getShellConfig,handoffHost,hasTrustRequiringProjectResources,highlightCode,initTheme,isBashToolResult,isEditToolResult,isFindToolResult,isGrepToolResult,isLsToolResult,isPowerShellToolResult,isReadToolResult,isToolCallEventType,isTransportGoneError,isWriteToolResult,kernelToolsStorage,keyHint,keyText,loadHostLaunchSpec,loadProjectContextFiles,loadSkills,loadSkillsFromDir,main,migrateSessionEntries,noticeEntryRenderer,noticeMessageRenderer,parseArgs,parseFrontmatter,parseHostLaunchSpec,parseHostProtocolInfo,parseSessionEntries,parseSkillBlock,prepareBranchEntries,probeHost,rawKeyHint,readHostStatus,readOwnFootprint,readProcessFootprint,readStoredCredential,registerReadClassifier,renderDiff,resizeImage,resolveCliModel,resolveModelScopeWithDiagnostics,runHostCommand,runHostRequest,runPrintMode,runRpcMode,sanitizeTerminalLabel,serializeConversation,sessionEntryToContextMessages,shardKey,shardSocketPath,shardSocketPathForKey,shouldCompact,stopHost,stripFrontmatter,truncateHead,truncateLine,truncateTail,truncateToVisualLines,withFileMutationQueue,wrapRegisteredTool,wrapRegisteredTools};
|
package/dist/bundle/rpc-entry.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } }
|
|
3
|
-
import{main}from"./chunks/chunk-
|
|
3
|
+
import{main}from"./chunks/chunk-GE32OHDE.js";import"./chunks/chunk-K2SHQNAA.js";import"./chunks/chunk-EQBN6TVJ.js";import"./chunks/chunk-2POUJCWM.js";import"./chunks/chunk-VLTMFAWQ.js";import"./chunks/chunk-OVDACFW2.js";import"./chunks/chunk-NZRVAZL2.js";import"./chunks/chunk-U5KVIAHJ.js";import"./chunks/chunk-YD32NXKZ.js";import"./chunks/chunk-27C3ZSZG.js";import"./chunks/chunk-LB2B2Q4P.js";import{configureHttpDispatcher}from"./chunks/chunk-K7B7NFOK.js";import"./chunks/chunk-HEKLJWA4.js";import"./chunks/chunk-YU2P3CAR.js";import"./chunks/chunk-BMX2U22F.js";import"./chunks/chunk-RUOJQL6B.js";import"./chunks/chunk-EB3GDOU4.js";import"./chunks/chunk-SNDTJL2H.js";import"./chunks/chunk-UK5TE7WR.js";import"./chunks/chunk-FUGMDU6B.js";import"./chunks/chunk-XBGO2JZD.js";import"./chunks/chunk-H4QOEVS5.js";import"./chunks/chunk-HB35RBP4.js";import"./chunks/chunk-ILQTW6KB.js";import"./chunks/chunk-KO6GO5ZY.js";import"./chunks/chunk-SH6VUPE4.js";import"./chunks/chunk-7RVWDN5Z.js";import"./chunks/chunk-7X72IACK.js";import"./chunks/chunk-KUPQO7MC.js";import"./chunks/chunk-CZNE6LIO.js";import"./chunks/chunk-T3HGPHPP.js";import"./chunks/chunk-W4AG5TN4.js";import"./chunks/chunk-26UBFF6N.js";import"./chunks/chunk-UNTVGMGW.js";import"./chunks/chunk-GZVCRV7I.js";import"./chunks/chunk-U3VOXCGP.js";import"./chunks/chunk-RFB5CBW7.js";import"./chunks/chunk-2VZJTDUX.js";import"./chunks/chunk-JEWB5XTL.js";import"./chunks/chunk-4VWWEMCJ.js";import"./chunks/chunk-ZOFZRJSL.js";import"./chunks/chunk-2SOVDETB.js";import{APP_NAME,scrubBrandFromEnvironment}from"./chunks/chunk-WCAKUCN3.js";import"./chunks/chunk-ATQFN5HI.js";import"./chunks/chunk-RBCQOIAD.js";import"./chunks/chunk-JRGNL6WM.js";import"./chunks/chunk-X4Q5YSTE.js";import"./chunks/chunk-CWLCGRUS.js";import"./chunks/chunk-BJICJY47.js";import"./chunks/chunk-LHYG7TK7.js";import"./chunks/chunk-KRNXUTZJ.js";import"./chunks/chunk-YOPVJDSU.js";import"./chunks/chunk-45SZOLCU.js";import"./chunks/chunk-WHPDEDCC.js";import"./chunks/chunk-BBK6SSYT.js";import"./chunks/chunk-BPX6QWPD.js";import"./chunks/chunk-XVX4M3DZ.js";import"./chunks/chunk-WDTJ6JKE.js";import"./chunks/chunk-5ROMKDLK.js";import"./chunks/chunk-3W47LTXQ.js";import"./chunks/chunk-DMI55M2N.js";import"./chunks/chunk-BQVVQ2LQ.js";import"./chunks/chunk-IKOFCODM.js";process.title=`${APP_NAME}-rpc`;scrubBrandFromEnvironment();process.env.PI_CODING_AGENT="true";process.env.AI_AGENT=APP_NAME;process.emitWarning=(()=>{});configureHttpDispatcher();main(["--mode","rpc",...process.argv.slice(2)]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"buildId":"b9ccef83abafc59e","externals":["@earendil-works/chord","@earendil-works/pi-pty","@silvia-odwyer/photon-node","bufferutil","canvas","kerberos","supports-color","utf-8-validate"]}
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
3
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
4
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
5
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
return path;
|
|
9
|
+
};
|
|
2
10
|
import "./valid-cwd.js";
|
|
3
11
|
import { spawn, spawnSync } from "node:child_process";
|
|
4
12
|
import { existsSync, realpathSync } from "node:fs";
|
|
5
|
-
import { join } from "node:path";
|
|
13
|
+
import { dirname, join } from "node:path";
|
|
6
14
|
import { fileURLToPath } from "node:url";
|
|
7
15
|
import { processBunRuntimeOptions, resolveBunReexec } from "./bun-runtime.js";
|
|
8
16
|
import { enableStartupCompileCache } from "./compile-cache.js";
|
|
9
|
-
import { APP_NAME, DISPLAY_VERSION,
|
|
17
|
+
import { APP_NAME, DISPLAY_VERSION, findNodePackageDir, getAgentDir, getInstallPackageDir, isBundledNode, } from "./config.js";
|
|
10
18
|
import { hasInheritedInspectorOption, releaseInheritedInspectorForChild } from "./inspector-policy.js";
|
|
19
|
+
import { prepareRuntimeSnapshot } from "./runtime-snapshot/enter.js";
|
|
11
20
|
import { handleBootstrapSelfUpdate } from "./self-update-bootstrap.js";
|
|
12
21
|
// Upstream's `cli/setup.ts` helper is deliberately not used here: this launcher only decides the
|
|
13
22
|
// runtime and process structure, and `cli-main.ts` performs the equivalent process/title/env/http
|
|
@@ -142,7 +151,7 @@ if (isRootCommand(args) && args.some((arg) => arg === "--help" || arg === "-h"))
|
|
|
142
151
|
process.exit();
|
|
143
152
|
}
|
|
144
153
|
}
|
|
145
|
-
if (isMissingBundledWorkspaceDependencies(
|
|
154
|
+
if (isMissingBundledWorkspaceDependencies(getInstallPackageDir())) {
|
|
146
155
|
if (await handleBootstrapSelfUpdate(args)) {
|
|
147
156
|
process.exit();
|
|
148
157
|
}
|
|
@@ -155,6 +164,17 @@ else {
|
|
|
155
164
|
// `process.exitCode` and any `process.exit()` of its own, so importing it here IS the run - there
|
|
156
165
|
// is no result to forward. It has to be a dynamic import: a static one would evaluate the whole
|
|
157
166
|
// engine graph before the `--version` and bootstrap-repair paths above, which answer without it.
|
|
158
|
-
|
|
167
|
+
// A bundled install hands the run to its runtime snapshot's own copy of this entry instead, so
|
|
168
|
+
// an upgrade that rewrites the install cannot remove chunks this session imports later (#2358).
|
|
169
|
+
const entryPath = fileURLToPath(import.meta.url);
|
|
170
|
+
const snapshot = isBundledNode
|
|
171
|
+
? prepareRuntimeSnapshot(entryPath, findNodePackageDir(dirname(entryPath)), getAgentDir())
|
|
172
|
+
: undefined;
|
|
173
|
+
if (snapshot?.kind === "hand-off") {
|
|
174
|
+
await import(__rewriteRelativeImportExtension(snapshot.entryUrl));
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
await import("./cli-main.js");
|
|
178
|
+
}
|
|
159
179
|
}
|
|
160
180
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,gB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,yBAAyB,EAAE,GAAG,MAAM,MAAM,CAAC,yBAAyB,CAAC,CAAC;IAC9E,IAAI,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;AACF,CAAC;AAED,IAAI,qCAAqC,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC;IAC5D,IAAI,MAAM,yBAAyB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;AACF,CAAC;AAED,IAAI,uBAAuB,EAAE,EAAE,CAAC;IAC/B,OAAO,CAAC,QAAQ,GAAG,MAAM,YAAY,EAAE,CAAC;AACzC,CAAC;KAAM,CAAC;IACP,wFAAwF;IACxF,kGAAkG;IAClG,gGAAgG;IAChG,iGAAiG;IACjG,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["#!/usr/bin/env node\nimport \"./valid-cwd.ts\";\nimport { spawn, spawnSync } from \"node:child_process\";\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { processBunRuntimeOptions, resolveBunReexec } from \"./bun-runtime.ts\";\nimport { enableStartupCompileCache } from \"./compile-cache.ts\";\nimport { APP_NAME, DISPLAY_VERSION, getPackageDir, isBundledNode } from \"./config.ts\";\nimport { hasInheritedInspectorOption, releaseInheritedInspectorForChild } from \"./inspector-policy.ts\";\nimport { handleBootstrapSelfUpdate } from \"./self-update-bootstrap.ts\";\n\n// Upstream's `cli/setup.ts` helper is deliberately not used here: this launcher only decides the\n// runtime and process structure, and `cli-main.ts` performs the equivalent process/title/env/http\n// setup for both entry paths (Node launcher and the Bun binary).\n\n/**\n * Hand a Bun-installed CLI to Bun before anything else runs.\n *\n * `bun install -g` links this script into `~/.bun/bin`, but the shebang still starts it on Node,\n * so a user who chose Bun silently gets the Node runtime. Re-exec through the Bun binary when the\n * script really lives in Bun's global tree (or `SENPI_RUNTIME=bun` asks for it). This runs before\n * `enableStartupCompileCache()` on purpose: a re-exec must not pay for Node's compile-cache setup.\n * Node `execArgv` is deliberately dropped — those flags belong to the Node process, not to Bun.\n */\nfunction reexecUnderBunIfNeeded(): boolean {\n\tconst options = processBunRuntimeOptions(existsSync, realpathSync);\n\tlet scriptRealPath = process.argv[1] ?? fileURLToPath(import.meta.url);\n\ttry {\n\t\t// `~/.bun/bin/<name>` is a symlink into the global tree, so the link target is what has\n\t\t// to be classified and re-executed. A path that cannot be resolved is simply used as-is;\n\t\t// runtime selection must never be the reason startup fails.\n\t\tscriptRealPath = realpathSync(scriptRealPath);\n\t} catch {}\n\tconst decision = resolveBunReexec({\n\t\tscriptRealPath,\n\t\tversions: process.versions,\n\t\thasInheritedInspectorOption: hasInheritedInspectorOption(),\n\t\toptions,\n\t});\n\tif (decision.action === \"stay\") {\n\t\treturn false;\n\t}\n\tconst result = spawnSync(decision.bunPath, [scriptRealPath, ...process.argv.slice(2)], {\n\t\tstdio: \"inherit\",\n\t\twindowsHide: true,\n\t});\n\tif (result.signal) {\n\t\tprocess.kill(process.pid, result.signal);\n\t\treturn true;\n\t}\n\tprocess.exitCode = result.status ?? 1;\n\treturn true;\n}\n\nif (reexecUnderBunIfNeeded()) {\n\tprocess.exit();\n}\n\n// Must run before cli-main is loaded, by either path: it caches the engine graph this process\n// imports on the fast path below, and it publishes NODE_COMPILE_CACHE so a spawned cli-main child\n// inherits this process's cache directory instead of resolving and re-filling its own.\nenableStartupCompileCache();\n\nprocess.title = APP_NAME;\nprocess.env.PI_CODING_AGENT = \"true\";\nprocess.env.AI_AGENT = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconst args = process.argv.slice(2);\nconst PACKAGE_COMMANDS = new Set([\"install\", \"remove\", \"uninstall\", \"update\", \"list\", \"config\"]);\n\nfunction isRootCommand(args: readonly string[]): boolean {\n\tconst firstArg = args[0];\n\treturn firstArg === undefined || !PACKAGE_COMMANDS.has(firstArg);\n}\n\nfunction isPackageManagerInstall(packageDir: string): boolean {\n\treturn packageDir.replace(/\\\\/g, \"/\").includes(\"/node_modules/@code-yeongyu/senpi\");\n}\n\nfunction isMissingBundledWorkspaceDependencies(packageDir: string): boolean {\n\tif (!isPackageManagerInstall(packageDir)) {\n\t\treturn false;\n\t}\n\tconst bundledPackages = [\"pi-agent-core\", \"pi-ai\", \"pi-tui\"];\n\treturn bundledPackages.some((name) => {\n\t\treturn !existsSync(join(packageDir, \"node_modules\", \"@earendil-works\", name, \"dist\", \"index.js\"));\n\t});\n}\n\n/** Marks the child a bundled entry spawned for its exec arguments, so it never spawns again. */\nconst ISOLATED_CHILD_ENV = \"SENPI_CLI_ISOLATED_CHILD\";\n\n/**\n * Decide whether the agent needs its own process.\n *\n * Two things justify the extra Node process, and only two. An inherited Inspector option means a\n * debugger socket has to be released here and re-opened over there, which a same-process load\n * cannot do. Custom exec arguments (`--max-old-space-size`, a loader `--import`, ...) were chosen\n * for the process that runs the agent, and they are only applied at process start, so they must be\n * replayed onto a fresh one. Brand scrubbing does NOT justify it: `cli-main` calls\n * `scrubBrandFromEnvironment()` itself, so loading it here scrubs this process's environment before\n * anything the agent spawns can inherit it.\n */\nfunction requiresIsolatedProcess(): boolean {\n\t// The bundled entry re-executes itself rather than a sibling, so the child would otherwise see the\n\t// same exec arguments and spawn again forever. The marker is read before anything else runs.\n\tif (process.env[ISOLATED_CHILD_ENV] === \"1\") return false;\n\treturn process.execArgv.length > 0 || hasInheritedInspectorOption();\n}\n\nasync function spawnFullCli(): Promise<number> {\n\tconst extension = import.meta.url.endsWith(\".ts\") ? \".ts\" : \".js\";\n\t// The bundle inlines `cli-main`, so no sibling module exists next to it: resolving one produced\n\t// `Module not found .../dist/bundle/cli-main.js` for every launch carrying exec arguments. The\n\t// bundled entry therefore replays the arguments onto a copy of itself, marked so the child loads\n\t// the agent in process. An unbundled install keeps spawning its sibling exactly as before.\n\tconst fullCliPath = isBundledNode\n\t\t? fileURLToPath(import.meta.url)\n\t\t: fileURLToPath(new URL(`./cli-main${extension}`, import.meta.url));\n\treleaseInheritedInspectorForChild();\n\tconst childEnvironment = isBundledNode ? { ...process.env, [ISOLATED_CHILD_ENV]: \"1\" } : process.env;\n\treturn await new Promise<number>((resolve, reject) => {\n\t\tconst child = spawn(process.execPath, [...process.execArgv, fullCliPath, ...args], {\n\t\t\tenv: childEnvironment,\n\t\t\tstdio: \"inherit\",\n\t\t});\n\t\tchild.on(\"error\", (error) => {\n\t\t\treject(error);\n\t\t});\n\t\tchild.on(\"close\", (code, signal) => {\n\t\t\tif (signal) {\n\t\t\t\tprocess.kill(process.pid, signal);\n\t\t\t\tresolve(1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(code ?? 1);\n\t\t});\n\t});\n}\n\nif (isRootCommand(args) && (args.includes(\"--version\") || args.includes(\"-v\"))) {\n\tconsole.log(DISPLAY_VERSION);\n\tprocess.exit();\n}\n\n// Help is static text plus the flags extensions registered, so a launch that already knows those\n// flags must not import the engine graph to print them. The import stays dynamic for the same\n// reason `cli-main` is: a static one would evaluate that graph before this answer.\nif (isRootCommand(args) && args.some((arg) => arg === \"--help\" || arg === \"-h\")) {\n\tconst { tryPrintHelpWithoutEngine } = await import(\"./cli/help-fast-path.ts\");\n\tif (tryPrintHelpWithoutEngine(args)) {\n\t\tprocess.exit();\n\t}\n}\n\nif (isMissingBundledWorkspaceDependencies(getPackageDir())) {\n\tif (await handleBootstrapSelfUpdate(args)) {\n\t\tprocess.exit();\n\t}\n}\n\nif (requiresIsolatedProcess()) {\n\tprocess.exitCode = await spawnFullCli();\n} else {\n\t// Entry-point process-structure seam: `cli-main` runs `main()` at module scope and owns\n\t// `process.exitCode` and any `process.exit()` of its own, so importing it here IS the run - there\n\t// is no result to forward. It has to be a dynamic import: a static one would evaluate the whole\n\t// engine graph before the `--version` and bootstrap-repair paths above, which answer without it.\n\tawait import(\"./cli-main.ts\");\n}\n"]}
|
|
1
|
+
{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C;IACb,IAAI,QAAQ,EAAE,IAAI,KAAK,UAAU,EAAE,CAAC;QACnC,MAAM,MAAM,kCAAC,QAAQ,CAAC,QAAQ,EAAC,CAAC;IACjC,CAAC;SAAM,CAAC;QACP,MAAM,MAAM,CAAC,eAAe,CAAC,CAAC;IAC/B,CAAC;AACF,CAAC","sourcesContent":["#!/usr/bin/env node\nimport \"./valid-cwd.ts\";\nimport { spawn, spawnSync } from \"node:child_process\";\nimport { existsSync, realpathSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { processBunRuntimeOptions, resolveBunReexec } from \"./bun-runtime.ts\";\nimport { enableStartupCompileCache } from \"./compile-cache.ts\";\nimport {\n\tAPP_NAME,\n\tDISPLAY_VERSION,\n\tfindNodePackageDir,\n\tgetAgentDir,\n\tgetInstallPackageDir,\n\tisBundledNode,\n} from \"./config.ts\";\nimport { hasInheritedInspectorOption, releaseInheritedInspectorForChild } from \"./inspector-policy.ts\";\nimport { prepareRuntimeSnapshot } from \"./runtime-snapshot/enter.ts\";\nimport { handleBootstrapSelfUpdate } from \"./self-update-bootstrap.ts\";\n\n// Upstream's `cli/setup.ts` helper is deliberately not used here: this launcher only decides the\n// runtime and process structure, and `cli-main.ts` performs the equivalent process/title/env/http\n// setup for both entry paths (Node launcher and the Bun binary).\n\n/**\n * Hand a Bun-installed CLI to Bun before anything else runs.\n *\n * `bun install -g` links this script into `~/.bun/bin`, but the shebang still starts it on Node,\n * so a user who chose Bun silently gets the Node runtime. Re-exec through the Bun binary when the\n * script really lives in Bun's global tree (or `SENPI_RUNTIME=bun` asks for it). This runs before\n * `enableStartupCompileCache()` on purpose: a re-exec must not pay for Node's compile-cache setup.\n * Node `execArgv` is deliberately dropped — those flags belong to the Node process, not to Bun.\n */\nfunction reexecUnderBunIfNeeded(): boolean {\n\tconst options = processBunRuntimeOptions(existsSync, realpathSync);\n\tlet scriptRealPath = process.argv[1] ?? fileURLToPath(import.meta.url);\n\ttry {\n\t\t// `~/.bun/bin/<name>` is a symlink into the global tree, so the link target is what has\n\t\t// to be classified and re-executed. A path that cannot be resolved is simply used as-is;\n\t\t// runtime selection must never be the reason startup fails.\n\t\tscriptRealPath = realpathSync(scriptRealPath);\n\t} catch {}\n\tconst decision = resolveBunReexec({\n\t\tscriptRealPath,\n\t\tversions: process.versions,\n\t\thasInheritedInspectorOption: hasInheritedInspectorOption(),\n\t\toptions,\n\t});\n\tif (decision.action === \"stay\") {\n\t\treturn false;\n\t}\n\tconst result = spawnSync(decision.bunPath, [scriptRealPath, ...process.argv.slice(2)], {\n\t\tstdio: \"inherit\",\n\t\twindowsHide: true,\n\t});\n\tif (result.signal) {\n\t\tprocess.kill(process.pid, result.signal);\n\t\treturn true;\n\t}\n\tprocess.exitCode = result.status ?? 1;\n\treturn true;\n}\n\nif (reexecUnderBunIfNeeded()) {\n\tprocess.exit();\n}\n\n// Must run before cli-main is loaded, by either path: it caches the engine graph this process\n// imports on the fast path below, and it publishes NODE_COMPILE_CACHE so a spawned cli-main child\n// inherits this process's cache directory instead of resolving and re-filling its own.\nenableStartupCompileCache();\n\nprocess.title = APP_NAME;\nprocess.env.PI_CODING_AGENT = \"true\";\nprocess.env.AI_AGENT = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconst args = process.argv.slice(2);\nconst PACKAGE_COMMANDS = new Set([\"install\", \"remove\", \"uninstall\", \"update\", \"list\", \"config\"]);\n\nfunction isRootCommand(args: readonly string[]): boolean {\n\tconst firstArg = args[0];\n\treturn firstArg === undefined || !PACKAGE_COMMANDS.has(firstArg);\n}\n\nfunction isPackageManagerInstall(packageDir: string): boolean {\n\treturn packageDir.replace(/\\\\/g, \"/\").includes(\"/node_modules/@code-yeongyu/senpi\");\n}\n\nfunction isMissingBundledWorkspaceDependencies(packageDir: string): boolean {\n\tif (!isPackageManagerInstall(packageDir)) {\n\t\treturn false;\n\t}\n\tconst bundledPackages = [\"pi-agent-core\", \"pi-ai\", \"pi-tui\"];\n\treturn bundledPackages.some((name) => {\n\t\treturn !existsSync(join(packageDir, \"node_modules\", \"@earendil-works\", name, \"dist\", \"index.js\"));\n\t});\n}\n\n/** Marks the child a bundled entry spawned for its exec arguments, so it never spawns again. */\nconst ISOLATED_CHILD_ENV = \"SENPI_CLI_ISOLATED_CHILD\";\n\n/**\n * Decide whether the agent needs its own process.\n *\n * Two things justify the extra Node process, and only two. An inherited Inspector option means a\n * debugger socket has to be released here and re-opened over there, which a same-process load\n * cannot do. Custom exec arguments (`--max-old-space-size`, a loader `--import`, ...) were chosen\n * for the process that runs the agent, and they are only applied at process start, so they must be\n * replayed onto a fresh one. Brand scrubbing does NOT justify it: `cli-main` calls\n * `scrubBrandFromEnvironment()` itself, so loading it here scrubs this process's environment before\n * anything the agent spawns can inherit it.\n */\nfunction requiresIsolatedProcess(): boolean {\n\t// The bundled entry re-executes itself rather than a sibling, so the child would otherwise see the\n\t// same exec arguments and spawn again forever. The marker is read before anything else runs.\n\tif (process.env[ISOLATED_CHILD_ENV] === \"1\") return false;\n\treturn process.execArgv.length > 0 || hasInheritedInspectorOption();\n}\n\nasync function spawnFullCli(): Promise<number> {\n\tconst extension = import.meta.url.endsWith(\".ts\") ? \".ts\" : \".js\";\n\t// The bundle inlines `cli-main`, so no sibling module exists next to it: resolving one produced\n\t// `Module not found .../dist/bundle/cli-main.js` for every launch carrying exec arguments. The\n\t// bundled entry therefore replays the arguments onto a copy of itself, marked so the child loads\n\t// the agent in process. An unbundled install keeps spawning its sibling exactly as before.\n\tconst fullCliPath = isBundledNode\n\t\t? fileURLToPath(import.meta.url)\n\t\t: fileURLToPath(new URL(`./cli-main${extension}`, import.meta.url));\n\treleaseInheritedInspectorForChild();\n\tconst childEnvironment = isBundledNode ? { ...process.env, [ISOLATED_CHILD_ENV]: \"1\" } : process.env;\n\treturn await new Promise<number>((resolve, reject) => {\n\t\tconst child = spawn(process.execPath, [...process.execArgv, fullCliPath, ...args], {\n\t\t\tenv: childEnvironment,\n\t\t\tstdio: \"inherit\",\n\t\t});\n\t\tchild.on(\"error\", (error) => {\n\t\t\treject(error);\n\t\t});\n\t\tchild.on(\"close\", (code, signal) => {\n\t\t\tif (signal) {\n\t\t\t\tprocess.kill(process.pid, signal);\n\t\t\t\tresolve(1);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tresolve(code ?? 1);\n\t\t});\n\t});\n}\n\nif (isRootCommand(args) && (args.includes(\"--version\") || args.includes(\"-v\"))) {\n\tconsole.log(DISPLAY_VERSION);\n\tprocess.exit();\n}\n\n// Help is static text plus the flags extensions registered, so a launch that already knows those\n// flags must not import the engine graph to print them. The import stays dynamic for the same\n// reason `cli-main` is: a static one would evaluate that graph before this answer.\nif (isRootCommand(args) && args.some((arg) => arg === \"--help\" || arg === \"-h\")) {\n\tconst { tryPrintHelpWithoutEngine } = await import(\"./cli/help-fast-path.ts\");\n\tif (tryPrintHelpWithoutEngine(args)) {\n\t\tprocess.exit();\n\t}\n}\n\nif (isMissingBundledWorkspaceDependencies(getInstallPackageDir())) {\n\tif (await handleBootstrapSelfUpdate(args)) {\n\t\tprocess.exit();\n\t}\n}\n\nif (requiresIsolatedProcess()) {\n\tprocess.exitCode = await spawnFullCli();\n} else {\n\t// Entry-point process-structure seam: `cli-main` runs `main()` at module scope and owns\n\t// `process.exitCode` and any `process.exit()` of its own, so importing it here IS the run - there\n\t// is no result to forward. It has to be a dynamic import: a static one would evaluate the whole\n\t// engine graph before the `--version` and bootstrap-repair paths above, which answer without it.\n\t// A bundled install hands the run to its runtime snapshot's own copy of this entry instead, so\n\t// an upgrade that rewrites the install cannot remove chunks this session imports later (#2358).\n\tconst entryPath = fileURLToPath(import.meta.url);\n\tconst snapshot = isBundledNode\n\t\t? prepareRuntimeSnapshot(entryPath, findNodePackageDir(dirname(entryPath)), getAgentDir())\n\t\t: undefined;\n\tif (snapshot?.kind === \"hand-off\") {\n\t\tawait import(snapshot.entryUrl);\n\t} else {\n\t\tawait import(\"./cli-main.ts\");\n\t}\n}\n"]}
|
package/dist/config.d.ts
CHANGED
|
@@ -32,6 +32,11 @@ export declare function getUpdateInstruction(packageName: string): string;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function findNodePackageDir(startDir: string): string;
|
|
34
34
|
export declare function getPackageDir(): string;
|
|
35
|
+
/**
|
|
36
|
+
* Where the package manager installed this package. Equals `getPackageDir()` except in a process
|
|
37
|
+
* running from its runtime snapshot (`runtime-snapshot/`), whose assets live in the snapshot.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getInstallPackageDir(): string;
|
|
35
40
|
/**
|
|
36
41
|
* Get path to built-in themes directory (shipped with package)
|
|
37
42
|
* - For Bun binary: theme/ next to executable
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,YAAY,EAA0B,MAAM,iBAAiB,CAAC;AAc5E;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAInD,eAAO,MAAM,aAAa,SAA4D,CAAC;AAMvF,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAEvF,UAAU,qBAAqB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC/D,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM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IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC"}
|
package/dist/config.js
CHANGED
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from "url";
|
|
|
5
5
|
import { createBunLauncherRepairCommand } from "./bun-global-launcher.js";
|
|
6
6
|
import { brandProfile, envValue } from "./core/brand.js";
|
|
7
7
|
import { findNearestParentConfigDir } from "./nearest-parent-config.js";
|
|
8
|
+
import { resolveInstallPath } from "./runtime-snapshot/marker.js";
|
|
8
9
|
import { spawnProcessSync } from "./utils/child-process.js";
|
|
9
10
|
import { normalizePath } from "./utils/paths.js";
|
|
10
11
|
import { stripBom } from "./utils/text.js";
|
|
@@ -52,7 +53,8 @@ export function detectInstallMethod() {
|
|
|
52
53
|
if (isBunBinary) {
|
|
53
54
|
return "bun-binary";
|
|
54
55
|
}
|
|
55
|
-
const
|
|
56
|
+
const moduleDir = resolveInstallPath(__dirname, findNodePackageDir(__dirname));
|
|
57
|
+
const resolvedPath = `${moduleDir}\0${process.execPath || ""}`.toLowerCase().replace(/\\/g, "/");
|
|
56
58
|
if (resolvedPath.includes("/pnpm/") || resolvedPath.includes("/.pnpm/")) {
|
|
57
59
|
return "pnpm";
|
|
58
60
|
}
|
|
@@ -68,7 +70,7 @@ export function detectInstallMethod() {
|
|
|
68
70
|
return "unknown";
|
|
69
71
|
}
|
|
70
72
|
function getInferredNpmInstall() {
|
|
71
|
-
const packageDir =
|
|
73
|
+
const packageDir = getInstallPackageDir();
|
|
72
74
|
const path = process.platform === "win32" || packageDir.includes("\\") ? win32 : { basename, dirname };
|
|
73
75
|
const parent = path.dirname(packageDir);
|
|
74
76
|
let root;
|
|
@@ -96,7 +98,7 @@ function getSelfUpdateCommandForMethod(method, installedPackageName, updatePacka
|
|
|
96
98
|
case "pnpm": {
|
|
97
99
|
const match = readCommandOutput("pnpm", ["root", "-g"])
|
|
98
100
|
? undefined
|
|
99
|
-
: /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(
|
|
101
|
+
: /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(getInstallPackageDir());
|
|
100
102
|
const binDirArgs = match
|
|
101
103
|
? [`--config.global-bin-dir=${process.env.PNPM_HOME || dirname(dirname(match[1]))}`]
|
|
102
104
|
: [];
|
|
@@ -190,7 +192,7 @@ function getGlobalPackageRoots(method, _packageName, npmCommand) {
|
|
|
190
192
|
const root = readCommandOutput("pnpm", ["root", "-g"]);
|
|
191
193
|
if (root)
|
|
192
194
|
return [root, dirname(root)];
|
|
193
|
-
const match = /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(
|
|
195
|
+
const match = /^(.*[\\/]global[\\/][^\\/]+)[\\/]\.pnpm[\\/]/.exec(getInstallPackageDir());
|
|
194
196
|
return match ? [match[1]] : [];
|
|
195
197
|
}
|
|
196
198
|
case "yarn": {
|
|
@@ -246,7 +248,7 @@ function getEntrypointPackageDir() {
|
|
|
246
248
|
return undefined;
|
|
247
249
|
}
|
|
248
250
|
function isSelfUpdatePathWritable() {
|
|
249
|
-
const packageDir =
|
|
251
|
+
const packageDir = getInstallPackageDir();
|
|
250
252
|
try {
|
|
251
253
|
accessSync(packageDir, constants.W_OK);
|
|
252
254
|
accessSync(dirname(packageDir), constants.W_OK);
|
|
@@ -257,7 +259,7 @@ function isSelfUpdatePathWritable() {
|
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
261
|
function isManagedByGlobalPackageManager(method, packageName, npmCommand) {
|
|
260
|
-
const packageDirs = [
|
|
262
|
+
const packageDirs = [getInstallPackageDir(), getEntrypointPackageDir()].filter((dir) => !!dir);
|
|
261
263
|
const packageDirCandidates = packageDirs.flatMap((dir) => getPathComparisonCandidates(dir));
|
|
262
264
|
return getGlobalPackageRoots(method, packageName, npmCommand).some((root) => {
|
|
263
265
|
return getPathComparisonCandidates(root).some((normalizedRoot) => {
|
|
@@ -334,6 +336,14 @@ export function getPackageDir() {
|
|
|
334
336
|
}
|
|
335
337
|
return findNodePackageDir(__dirname);
|
|
336
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Where the package manager installed this package. Equals `getPackageDir()` except in a process
|
|
341
|
+
* running from its runtime snapshot (`runtime-snapshot/`), whose assets live in the snapshot.
|
|
342
|
+
*/
|
|
343
|
+
export function getInstallPackageDir() {
|
|
344
|
+
const packageDir = getPackageDir();
|
|
345
|
+
return resolveInstallPath(packageDir, packageDir);
|
|
346
|
+
}
|
|
337
347
|
const THEMES_ASSET = {
|
|
338
348
|
binaryDir: "theme",
|
|
339
349
|
sourceSegments: ["modes", "interactive", "theme"],
|