@arcforge/axon 2.0.31 → 2.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcforge/axon",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "description": "coding agent cli",
5
5
  "type": "module",
6
6
  "bin": {
package/update-helper.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- import{mkdir as f,rename as w,writeFile as b}from"fs/promises";import{dirname as A}from"path";var l=4;async function x(t,e={}){let o=e.run??$,n=e.wait??y,a=e.sleep??Bun.sleep;await n(t.parent),await p(t.state,{status:"running",from:t.from,to:t.to,updatedAt:new Date().toISOString()}),process.stdout.write(`
3
- Updating Axon ${t.from} \u2192 ${t.to}\u2026
4
- `);let i={code:1,stdout:""};for(let r=1;r<=l;r++){if(i=await o([t.bun,"add","-g",`@arcforge/axon@${t.to}`]),i.code===0)break;if(r<l){let u=1000*2**(r-1);process.stderr.write(`Axon ${t.to} is not available from this npm edge yet; retrying in ${u/1000}s\u2026
5
- `),await a(u)}}if(i.code===0){let r=await o([t.axon,"--version"]);if(r.code===0&&r.stdout.trim()===t.to)return await p(t.state,{status:"complete",from:t.from,to:t.to,updatedAt:new Date().toISOString()}),process.stdout.write(`\u2713 Axon ${t.to} installed. Run axon to continue.
2
+ import{mkdir as Z,rename as $,writeFile as B}from"fs/promises";import{dirname as C}from"path";var X=4;async function U(j,q={}){let z=q.run??M,G=q.wait??H,K=q.sleep??Bun.sleep;await G(j.parent),await W(j.state,{status:"running",from:j.from,to:j.to,updatedAt:new Date().toISOString()}),process.stdout.write(`
3
+ Updating Axon ${j.from} \u2192 ${j.to}\u2026
4
+ `);let D={code:1,stdout:""};for(let J=1;J<=X;J++){if(D=await z([j.bun,"add","-g",`@arcforge/axon@${j.to}`]),D.code===0)break;if(J<X){let V=1000*2**(J-1);process.stderr.write(`Axon ${j.to} is not available from this npm edge yet; retrying in ${V/1000}s\u2026
5
+ `),await K(V)}}if(D.code===0){let J=await z([j.axon,"--version"]);if(J.code===0&&J.stdout.trim()===j.to)return await W(j.state,{status:"complete",from:j.from,to:j.to,updatedAt:new Date().toISOString()}),process.stdout.write(`\u2713 Axon ${j.to} installed. Run axon to continue.
6
6
 
7
7
  `),0}process.stderr.write(`Axon update failed verification; restoring the previous version\u2026
8
- `);let c=await o([t.bun,"add","-g",`@arcforge/axon@${t.from}`]),d=c.code===0?`update to ${t.to} failed verification; restored ${t.from}`:`update to ${t.to} failed and rollback to ${t.from} also failed`;await p(t.state,{status:c.code===0?"rolled-back":"failed",from:t.from,to:t.to,updatedAt:new Date().toISOString(),error:d});let s=process.platform==="win32"?"irm https://axon.arclabs.it/install.ps1 | iex":"curl -fsSL https://axon.arclabs.it/install | bash";return process.stderr.write(`${d}. Run ${s} to recover.
8
+ `);let Q=await z([j.bun,"add","-g",`@arcforge/axon@${j.from}`]),R=Q.code===0?`update to ${j.to} failed verification; restored ${j.from}`:`update to ${j.to} failed and rollback to ${j.from} also failed`;await W(j.state,{status:Q.code===0?"rolled-back":"failed",from:j.from,to:j.to,updatedAt:new Date().toISOString(),error:R});let O=process.platform==="win32"?"irm https://axon.arclabs.it/install.ps1 | iex":"curl -fsSL https://axon.arclabs.it/install | bash";return process.stderr.write(`${R}. Run ${O} to recover.
9
9
 
10
- `),1}function v(t){let e=new Map;for(let s=0;s<t.length;s+=2){let r=t[s],u=t[s+1];if(!r?.startsWith("--")||u===void 0)throw Error("UPDATE_HELPER_ARGS_INVALID");e.set(r.slice(2),u)}let o=Number(e.get("parent")),n=e.get("from"),a=e.get("to"),i=e.get("bun"),c=e.get("axon"),d=e.get("state");if(!Number.isSafeInteger(o)||o<=0||!n||!a||!i||!c||!d)throw Error("UPDATE_HELPER_ARGS_INVALID");if(!m(n)||!m(a))throw Error("UPDATE_HELPER_VERSION_INVALID");return{parent:o,from:n,to:a,bun:i,axon:c,state:d}}async function y(t){while(g(t))await Bun.sleep(100)}function g(t){try{return process.kill(t,0),!0}catch{return!1}}async function $(t){let e=Bun.spawn(t,{stdin:"ignore",stdout:"pipe",stderr:"inherit",env:process.env}),[o,n]=await Promise.all([e.exited,new Response(e.stdout).text()]);return{code:o,stdout:n}}async function p(t,e){await f(A(t),{recursive:!0});let o=`${t}.${process.pid}.tmp`;await b(o,JSON.stringify(e,null,2)+`
11
- `,"utf-8"),await w(o,t)}function m(t){return/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(t)}if(import.meta.main)try{process.exitCode=await x(v(process.argv.slice(2)))}catch(t){process.stderr.write(`Axon updater failed: ${t instanceof Error?t.message:String(t)}
12
- `),process.exitCode=1}export{v as parseHelperArgs,x as applyUpdate};
10
+ `),1}function F(j){let q=new Map;for(let O=0;O<j.length;O+=2){let J=j[O],V=j[O+1];if(!J?.startsWith("--")||V===void 0)throw Error("UPDATE_HELPER_ARGS_INVALID");q.set(J.slice(2),V)}let z=Number(q.get("parent")),G=q.get("from"),K=q.get("to"),D=q.get("bun"),Q=q.get("axon"),R=q.get("state");if(!Number.isSafeInteger(z)||z<=0||!G||!K||!D||!Q||!R)throw Error("UPDATE_HELPER_ARGS_INVALID");if(!Y(G)||!Y(K))throw Error("UPDATE_HELPER_VERSION_INVALID");return{parent:z,from:G,to:K,bun:D,axon:Q,state:R}}async function H(j){while(I(j))await Bun.sleep(100)}function I(j){try{return process.kill(j,0),!0}catch{return!1}}async function M(j){let q=Bun.spawn(j,{stdin:"ignore",stdout:"pipe",stderr:"inherit",env:process.env}),[z,G]=await Promise.all([q.exited,new Response(q.stdout).text()]);return{code:z,stdout:G}}async function W(j,q){await Z(C(j),{recursive:!0});let z=`${j}.${process.pid}.tmp`;await B(z,JSON.stringify(q,null,2)+`
11
+ `,"utf-8"),await $(z,j)}function Y(j){return/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(j)}async function N(j,q={}){let z=q.apply??U,G=q.exit??((D)=>process.exit(D)),K=q.report??((D)=>process.stderr.write(D));try{G(await z(F(j)))}catch(D){K(`Axon updater failed: ${D instanceof Error?D.message:String(D)}
12
+ `),G(1)}}if(import.meta.main)N(process.argv.slice(2));export{N as runHelper,F as parseHelperArgs,U as applyUpdate};