@mu-agent/mu 0.0.6 → 0.0.7
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/mu.js +1 -1
- package/package.json +1 -1
package/dist/mu.js
CHANGED
|
@@ -240,7 +240,7 @@ ${X}`}function RL($){return $.replaceAll("&","&").replaceAll("<","<").rep
|
|
|
240
240
|
`)}function Rm($){return $.role!=="custom"||$.display===!0||$.customType==="user_shell_command"}function Tm($){if($.role==="user")return km($);if($.role==="assistant")return _m($);if($.role==="toolResult")return Cm($);return gm($)}function IG($,J={}){let Q=$.activePath().filter((V)=>V.type==="message").map((V)=>V.message).filter(Rm),X=J.exportedAt??new Date,U=[J.sessionId?`- Session: \`${J.sessionId}\``:void 0,J.model?`- Model: \`${J.model}\``:void 0,`- Exported: ${X.toISOString()}`].filter((V)=>V!==void 0),z=Q.map(Tm);return{markdown:["# Mu chat transcript","",...U,...z.length>0?["",z.join(`
|
|
241
241
|
|
|
242
242
|
`)]:[],""].join(`
|
|
243
|
-
`),messageCount:Q.length}}var g0={name:"@mu-agent/mu",version:"0.0.
|
|
243
|
+
`),messageCount:Q.length}}var g0={name:"@mu-agent/mu",version:"0.0.7",description:"Mu, a general-purpose extensible AI agent platform for the terminal and TypeScript",type:"module",main:"./dist/index.js",types:"./dist/types/index.d.ts",exports:{".":{types:"./dist/types/index.d.ts",import:"./dist/index.js",default:"./dist/index.js"}},bin:{mu:"./dist/mu.js"},files:["dist/mu.js","dist/index.js","dist/types","README.md","LICENSE","THIRD_PARTY_LICENSES.txt"],scripts:{build:"bun build src/main.ts --target=bun --minify --outfile dist/mu.js && bun build src/sdk.ts --target=bun --minify --external zod --outfile dist/index.js && bun ../../node_modules/typescript/bin/tsc -b ./tsconfig.json --force && bun ../../scripts/prepare-sdk-declarations.ts","verify:sdk":"bun run build && bun ../../node_modules/typescript/bin/tsc --noEmit --strict --allowImportingTsExtensions --target ESNext --module ESNext --moduleResolution bundler --types bun testing/sdk-consumer.ts && bun testing/sdk-consumer.ts",prepack:"bun run build"},keywords:["ai","agent","cli","coding-agent","tui","sdk","typescript"],author:"Spandan Chavan",license:"MIT",repository:{type:"git",url:"git+https://github.com/Spandan7724/mu.git",directory:"packages/cli"},homepage:"https://github.com/Spandan7724/mu#readme",bugs:{url:"https://github.com/Spandan7724/mu/issues"},engines:{bun:">=1.3.0"},dependencies:{zod:"4.4.3"},optionalDependencies:{"@mu-agent/ripgrep-darwin-arm64":"0.0.1","@mu-agent/ripgrep-linux-x64":"0.0.1","@mu-agent/ripgrep-windows-x64":"0.0.1"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},devDependencies:{"@mu/profile-coding":"workspace:*","@mu/tui":"workspace:*",mu:"workspace:*","@mu/core":"workspace:*"}};import{randomUUID as ZD}from"crypto";import{chmod as _l,open as ij,readFile as Cl,rm as $0}from"fs/promises";import{createServer as gl}from"net";import{readFile as Kl}from"fs/promises";import{homedir as Yl}from"os";import{join as ql,resolve as Pj}from"path";import{createHash as Em,randomUUID as fm}from"crypto";import{realpathSync as xm}from"fs";import{chmod as EL,mkdir as a5,readFile as s5,rename as um,rm as e5,stat as hm,writeFile as N7}from"fs/promises";import{homedir as nm}from"os";import{basename as im,dirname as mm,join as R0,relative as a6,resolve as LG}from"path";function uL($=process.platform){return $==="win32"?"NUL":"/dev/null"}var cm=async($,J,Q)=>{let X=Bun.spawn(["git",...$],{cwd:Q,env:{...process.env,...J},stdout:"pipe",stderr:"pipe",stdin:"ignore",windowsHide:!0}),[U,z,V]=await Promise.all([new Response(X.stdout).text(),new Response(X.stderr).text(),X.exited]);return{stdout:U,stderr:z,exitCode:V}};function lm($){let J=[];for(let Q of $.split("\x00")){if(Q.length===0)continue;let X=Q.indexOf("\t"),U=Q.indexOf("\t",X+1);if(X===-1||U===-1)continue;let z=Q.slice(0,X),V=Q.slice(X+1,U),W=Q.slice(U+1);J.push({path:W,added:z==="-"?0:Number(z),removed:V==="-"?0:Number(V),hunks:[]})}return J}function rm($){let J=LG($);try{return xm.native(J)}catch{return J}}function pm($,J){let Q=(J??im($)).replace(/[^A-Za-z0-9._-]+/g,"-")||"workspace",X=Em("sha256").update($).digest("hex").slice(0,16);return`${Q}-${X}`}var dm=new Set([".venv","venv","node_modules","__pycache__",".pytest_cache",".mypy_cache",".ruff_cache",".next",".nuxt",".cache","coverage"]),fL="2",tm=30000,om=1000,AG=".mu";function am($){let J=$.replaceAll("\\","/").replace(/^\.\//,"").replace(/\/+$/,"").split("/"),Q=J.findIndex((X)=>dm.has(X));if(Q===-1)return;return J.slice(0,Q+1).join("/")}function xL($){return`/${$.replaceAll("\\","\\\\").replace(/[?*[#]/g,"\\$&")}/`}class M7{root;shadowDir;run;lockDir;excludedPathspecs;initialized=!1;constructor($){this.root=rm($.root);let J=pm(this.root,$.scope);this.shadowDir=$.shadowDir??R0(nm(),".mu","checkpoints",J),this.lockDir=`${this.shadowDir}.lock`,this.run=$.run??cm;let Q=a6(this.root,this.shadowDir).replaceAll("\\","/"),X=a6(this.root,this.lockDir).replaceAll("\\","/");this.excludedPathspecs=[":(exclude,literal).git",":(exclude,glob).git/**",`:(exclude,literal)${AG}`,`:(exclude,glob)${AG}/**`,...Q.length>0&&!Q.startsWith("..")?[`:(exclude,literal)${Q}`,`:(exclude,glob)${Q}/**`]:[],...X.length>0&&!X.startsWith("..")?[`:(exclude,literal)${X}`,`:(exclude,glob)${X}/**`]:[]]}get directory(){return this.shadowDir}env(){return{GIT_DIR:this.shadowDir,GIT_WORK_TREE:this.root,GIT_AUTHOR_NAME:"mu",GIT_AUTHOR_EMAIL:"mu@localhost",GIT_COMMITTER_NAME:"mu",GIT_COMMITTER_EMAIL:"mu@localhost",GIT_CONFIG_GLOBAL:uL(),GIT_CONFIG_NOSYSTEM:"1"}}async git(...$){return this.run($,this.env(),this.root)}async acquireLock(){await a5(mm(this.lockDir),{recursive:!0});let $=fm(),J=Date.now()+tm;while(!0){try{await a5(this.lockDir,{mode:448});let V=R0(this.lockDir,"owner.json"),W=R0(this.lockDir,`owner.${$}.tmp`);try{await N7(W,`${JSON.stringify({pid:process.pid,token:$,createdAt:Date.now()})}
|
|
244
244
|
`,{encoding:"utf8",mode:384,flag:"wx"}),await um(W,V)}catch(K){throw await e5(this.lockDir,{recursive:!0,force:!0}).catch(()=>{}),K}return async()=>{let K=await s5(V,"utf8").catch(()=>{return});if(!K)return;try{if(JSON.parse(K).token===$)await e5(this.lockDir,{recursive:!0,force:!0})}catch{}}}catch(V){if(V.code!=="EEXIST")throw V}let Q=R0(this.lockDir,"owner.json"),X=await s5(Q,"utf8").catch(()=>{return}),U=!1,z;if(X)try{let V=JSON.parse(X);if(z=typeof V.token==="string"?V.token:void 0,typeof V.pid==="number"&&Number.isSafeInteger(V.pid))try{process.kill(V.pid,0)}catch(W){U=W.code==="ESRCH"}else U=!0}catch{U=!0}else U=await hm(this.lockDir).then((W)=>Date.now()-W.mtimeMs).catch(()=>0)>=om;if(U){let V=await s5(Q,"utf8").catch(()=>{return}),W;try{W=V?JSON.parse(V).token??void 0:void 0}catch{}if(W===z){await e5(this.lockDir,{recursive:!0,force:!0});continue}}if(Date.now()>=J)throw Error(`Timed out waiting for checkpoint lock ${this.lockDir}`);await new Promise((V)=>setTimeout(V,20))}}async locked($){let J=await this.acquireLock();try{return await $()}finally{await J()}}async ensure(){if(this.initialized)return;if(await a5(this.shadowDir,{recursive:!0,mode:448}),process.platform!=="win32")await EL(this.shadowDir,448);let $=R0(this.shadowDir,"mu-worktree"),J=!1;try{let z=(await s5($,"utf8")).trim();if(z!==this.root)throw Error(`Checkpoint store belongs to ${z}, not ${this.root}`);J=!0}catch(z){if(z.code!=="ENOENT")throw z}let Q=R0(this.shadowDir,"mu-checkpoint-version");if(J){if((await s5(Q,"utf8").catch((V)=>{if(V.code==="ENOENT")return;throw V}))?.trim()!==fL){if(await e5(this.shadowDir,{recursive:!0,force:!0}),await a5(this.shadowDir,{recursive:!0,mode:448}),process.platform!=="win32")await EL(this.shadowDir,448)}}if(await N7($,`${this.root}
|
|
245
245
|
`,"utf8"),(await this.git("rev-parse","--git-dir")).exitCode!==0)await this.git("init","--quiet");await N7(Q,`${fL}
|
|
246
246
|
`,"utf8");let U=a6(this.root,this.shadowDir).replaceAll("\\","/");if(U.length>0&&!U.startsWith("..")){let z=a6(this.root,this.lockDir).replaceAll("\\","/");await a5(R0(this.shadowDir,"info"),{recursive:!0}),await N7(R0(this.shadowDir,"info","exclude"),`/${U}/
|