@tryarcanist/cli 0.1.411 → 0.1.412
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/index.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire as __arcanistCreateRequire } from "node:module";
|
|
3
3
|
const require = __arcanistCreateRequire(import.meta.url);
|
|
4
4
|
var Yy=Object.defineProperty;var Ge=(e,t)=>{for(var r in t)Yy(e,r,{get:t[r],enumerable:!0})};import{Command as wA,Option as $A}from"commander";var Vp=["idle","running","review_starting","waiting_for_input","finalizing","review_listening","completed","superseded","needs_you","blocked","failed","stopped","archived"];var jt=["completed","superseded","needs_you","blocked","failed","stopped","archived"],Xy=new Set(jt),AA=new Set(jt.filter(e=>e!=="completed")),PA=new Set(jt.filter(e=>e!=="stopped")),RA=jt.filter(e=>e!=="archived"&&e!=="needs_you"&&e!=="blocked"&&e!=="stopped");function Gp(e,t){return Xy.has(e)}function qp(e){let t=e.createHelp().visibleGlobalOptions(e).map(Hp);return{...Wp(e),...t.length>0?{globalOptions:t}:{}}}function Wp(e){let t=Qy(e);return{path:Aa(e),description:e.description(),aliases:e.aliases(),arguments:e.registeredArguments.map(r=>({name:r.name(),description:r.description,required:r.required,variadic:r.variadic})),options:e.createHelp().visibleOptions(e).map(Hp),...t?{notes:t}:{},subcommands:e.commands.map(Wp)}}function Hp(e){return{flags:e.flags,description:e.description,required:e.mandatory,...e.defaultValue===void 0?{}:{defaultValue:e.defaultValue}}}function Aa(e){let t=[];for(let r=e;r;r=r.parent)t.unshift(r.name());return t.join(" ")}function Qy(e){let t="";return e.emit("afterHelp",{error:!1,command:e,write:r=>t+=r}),t.trim()}import{existsSync as Rb,mkdirSync as Cb,writeFileSync as Ob}from"node:fs";import{basename as Nb,join as dm,resolve as Db}from"node:path";var eb="en-US";function Kp(e,t){let r=new Intl.DateTimeFormat(eb,{timeZone:t,month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",hour12:!0,timeZoneName:"short"}).formatToParts(e),o=n=>r.find(i=>i.type===n)?.value??"";return`${o("month")} ${o("day")}, ${o("year")}, ${o("hour")}:${o("minute")} ${o("dayPeriod")} ${o("timeZoneName")}`}function Se(e,t=""){return(e instanceof Error?e.message:String(e))||t}function Kr(e){return new Promise(t=>setTimeout(t,e))}function et(e){return e.replace(/\/+$/,"")}var Jp="Setup and reviews are paused for this workspace. Contact team@tryarcanist.com to resume them.";function Yp(e){if(!e||typeof e!="object")return null;let t=e,r=typeof t.code=="string"&&t.code?t.code:null,o=typeof t.message=="string"&&t.message?t.message:null;if(typeof t.error=="string"&&t.error)return{code:r??t.error,message:o??t.error,raw:t.error};if(t.error&&typeof t.error=="object"){let n=t.error,i=typeof n.code=="string"&&n.code?n.code:r,a=typeof n.message=="string"&&n.message?n.message:o;return i||a?{code:i,message:a,raw:t.error}:null}return r||o?{code:r,message:o,raw:e}:null}function Pa(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let r=t,o={...typeof r.repository=="string"?{repository:r.repository}:{},...typeof r.environmentsUrl=="string"?{environmentsUrl:r.environmentsUrl}:{},...typeof r.billingUrl=="string"?{billingUrl:r.billingUrl}:{}},n=Yp(t);return n?typeof n.raw=="string"&&n.raw?{...n.code?{serverCode:n.code}:{},rawError:n.raw,...n.message?{message:n.message}:{},...o}:n.message||n.code?{...n.message?{message:n.message}:{},...n.code?{serverCode:n.code,rawError:n.code}:{},...o}:null:null}catch{return null}}var Oe=130,Ra=5,y=class extends Error{code;exitCode;hint;requestId;data;constructor(t,r,o={}){super(r),this.name="CliError",this.code=t,this.exitCode=o.exitCode??Xp(t),this.hint=o.hint,this.requestId=o.requestId,this.data=o.data}},Mt=class extends y{},ue=class extends y{status;body;constructor(t,r,o,n){let i=Qp(t),a=Pa(r);super(i,nb(t,r,a),{exitCode:tb(t),hint:rb(t,n,a),requestId:o,data:a?.serverCode||a?.repository||a?.environmentsUrl||a?.billingUrl?{...a.serverCode?{serverCode:a.serverCode}:{},...a.repository?{repository:a.repository}:{},...a.environmentsUrl?{environmentsUrl:a.environmentsUrl}:{},...a.billingUrl?{billingUrl:a.billingUrl}:{}}:void 0}),this.name="ApiError",this.status=t,this.body=r}};function Xp(e){switch(e){case"auth":return 2;case"not_found":return 3;case"conflict":return 4;case"server":return 10;default:return 1}}function Qp(e){return e===401||e===403?"auth":e===404?"not_found":e===409?"conflict":e>=500?"server":"user"}function tb(e){return Xp(Qp(e))}function nb(e,t,r=Pa(t)){return r?.message?r.message:r?.serverCode?r.serverCode:t?`API error ${e}: ${t}`:`API error ${e}`}function rb(e,t,r){if(e===401)return"Run `arcanist auth login` or set `ARCANIST_TOKEN`.";if(!(e===403&&r?.message===Jp)){if(e===403)return"This token is not allowed to do that. `arcanist auth whoami --json` shows its tokenScope and your businessRole: a change needs a write-scope token (mint one in Settings > CLI), and a workspace-wide change also needs the admin role.";if(e===404)return t==="repo"?"Check accessible repositories with `arcanist repos list`.":t==="session"?"List sessions with `arcanist sessions list`.":void 0;if(e===409&&r?.repository){if(r.serverCode==="environment_required")return`Run \`arcanist environments prepare ${r.repository} --wait\`, then retry the review.`;if(r.serverCode==="environment_preparing"||r.serverCode==="environment_needs_attention")return`Run \`arcanist environments status ${r.repository} --wait\` for the latest setup state.`}if(e===409)return"Check the current resource state and retry the command when it is ready.";if(e>=500)return"Retry later or check the control-plane logs."}}var ib="Run `arcanist help <command>` for usage, or `arcanist help --json` for the full command tree.";function ob(e){if(!("code"in e)||typeof e.code!="string"||!e.code.startsWith("commander."))return null;let[t="",r]=e.message.replace(/^error: /,"").split(`
|
|
5
|
-
`);return new y("user",t,{hint:r?r.replace(/^\((.*)\)$/,"$1"):ib})}function em(e){if(e instanceof y)return e;if(e instanceof Error){let t=ob(e);if(t)return t}return e instanceof Error?new y("user",e.message):new y("user",String(e))}function Jr(e){return JSON.stringify({error:{code:e.code,message:e.message,...e.hint?{hint:e.hint}:{},...e.requestId?{requestId:e.requestId}:{},...e.data?{data:e.data}:{}}})}var tm={name:"@tryarcanist/cli",version:"0.1.
|
|
5
|
+
`);return new y("user",t,{hint:r?r.replace(/^\((.*)\)$/,"$1"):ib})}function em(e){if(e instanceof y)return e;if(e instanceof Error){let t=ob(e);if(t)return t}return e instanceof Error?new y("user",e.message):new y("user",String(e))}function Jr(e){return JSON.stringify({error:{code:e.code,message:e.message,...e.hint?{hint:e.hint}:{},...e.requestId?{requestId:e.requestId}:{},...e.data?{data:e.data}:{}}})}var tm={name:"@tryarcanist/cli",version:"0.1.412",description:"Command-line interface for Arcanist: inspect sessions, prepare Arcanist environments, and trigger reviews",type:"module",bin:{arcanist:"dist/index.js"},engines:{node:">=22"},files:["dist/index.js"],scripts:{build:"tsup",typecheck:"node ../../node_modules/tsrs/bin/tsrs --noEmit",prepublishOnly:"npm --prefix ../.. run guard:cli-bundle"},publishConfig:{access:"public"},repository:{type:"git",url:"git+https://github.com/tryarcanist/arcanist.git",directory:"apps/cli"},homepage:"https://www.tryarcanist.com",license:"MIT",dependencies:{commander:"^12.1.0","playwright-core":"^1.61.1","proper-lockfile":"4.1.2"},devDependencies:{"@types/proper-lockfile":"^4.1.4",tsup:"^9.0.0",typescript:"^5.9.3"}};var Yr=`${tm.version}`;var sb=`arcanist-cli/${Yr}`,ub=3e4,cb=1e3,lb=6e5,Xr="ARCANIST_HTTP_TIMEOUT_MS";function db(e=process.env){let t=e[Xr];if(!t)return ub;if(!/^\d+$/.test(t))throw new y("user",`${Xr} must be a positive integer between 1000 and 600000.`);let r=Number(t);if(r<cb||r>lb)throw new y("user",`${Xr} must be between 1000 and 600000 milliseconds.`);return r}function Ca(e){return e instanceof DOMException&&e.name==="AbortError"}function pb(e){let t=e instanceof Error?e.cause:null;return t&&typeof t=="object"&&"code"in t&&typeof t.code=="string"?t.code:null}function Oa(e){return new Mt("server",`Network timeout after ${e}ms.`,{hint:`Increase ${Xr} for slow links, or check the API connection.`})}function mb(e){let t=db();if(!e)return{fetchInit:void 0,timeoutMs:t};let{timeoutMs:r,...o}=e;return r===void 0?{fetchInit:o,timeoutMs:t}:!Number.isFinite(r)||r<=0?{fetchInit:o,timeoutMs:1}:{fetchInit:o,timeoutMs:Math.max(1,Math.min(t,r))}}async function Na(e,t,r,o){let{fetchInit:n,timeoutMs:i}=mb(r),a=new AbortController,s=setTimeout(()=>a.abort(),i);try{let u=new Headers(n?.headers);u.set("Content-Type","application/json"),u.set("User-Agent",sb),e.token&&u.set("Authorization",`Bearer ${e.token}`);let c=await fetch(`${et(e.apiUrl)}${t}`,{...n,headers:u,signal:a.signal}).catch(l=>{throw Ca(l)?Oa(i):new Mt("server",`Network error: could not reach ${et(e.apiUrl)} (${pb(l)??Se(l)}).`,{hint:"Check the network and `ARCANIST_API_URL` or `--api-url`, then retry."})});if(!c.ok){let l=await c.text().catch(d=>{if(Ca(d))throw Oa(i);return""});throw new ue(c.status,l,c.headers.get("x-request-id")??void 0,fb(t))}return await o(c)}catch(u){throw u instanceof y?u:Ca(u)?Oa(i):u instanceof TypeError?new Mt("server",`The API response could not be read: ${Se(u)}`):new y("server",`The API response could not be read: ${Se(u)}`)}finally{clearTimeout(s)}}function fb(e){if(e.startsWith("/api/repos"))return"repo";if(e.startsWith("/api/sessions"))return"session"}async function P(e,t,r){return Na(e,t,r,o=>o.json())}async function nm(e,t,r){return Na(e,t,r,o=>o.text())}async function rm(e,t,r){return Na(e,t,r,async o=>new Uint8Array(await o.arrayBuffer()))}function A(e,t={}){return gb(e,t)}function gb(e,t){return e.replace(/:([A-Za-z]+)/g,(r,o)=>{let n=t[o];if(n===void 0)throw new Error(`apiPath(${e}) is missing the ${o} parameter`);return encodeURIComponent(n)})}import{createHash as om}from"node:crypto";import{existsSync as Cn,mkdirSync as bb,readFileSync as Da,statSync as wb}from"node:fs";import{homedir as $b}from"node:os";import{dirname as am,join as vt,resolve as Sb}from"node:path";import{randomUUID as hb}from"node:crypto";import{renameSync as vb,rmSync as _b,writeFileSync as yb}from"node:fs";function ht(e,t){let r=`${e}.${hb()}.tmp`;try{yb(r,JSON.stringify(t,null,2)+`
|
|
6
6
|
`,{mode:384,flag:"wx"}),vb(r,e)}finally{_b(r,{force:!0})}}var sm=vt($b(),".arcanist"),um=vt(sm,"config.json"),tt=".arcanist-cli.json",xb="https://app.tryarcanist.com";function za(){try{return JSON.parse(Da(um,"utf-8"))}catch{return null}}function On(e={}){let t=Ib(e);if(t)return im(t);let r=Ua(),o=La(e,r!==null),n=za(),i=o?.apiUrl??r?.apiUrl??n?.apiUrl,a=r&&n?.apiUrl===r.apiUrl&&n.token&&n.supersededProjectTokenHash===om("sha256").update(r.token).digest("hex")?n.token:r?.token,s=o?.token??a??n?.token;if(!i||!s)return null;let u=im({apiUrl:i,token:s});return r&&!o&&!e.json&&process.stderr.write(`using ${tt} -> ${u.apiUrl}
|
|
7
7
|
`),u}function Qr(e,t){let r=ti(e.apiUrl);if(r)throw new y("user",r);bb(sm,{recursive:!0,mode:448});let o=et(e.apiUrl),n=za(),i=t?om("sha256").update(t).digest("hex"):n?.apiUrl===o?n.supersededProjectTokenHash:void 0,a={...e,apiUrl:o,...i?{supersededProjectTokenHash:i}:{}};ht(um,a)}function ve(e){let t=On(e);if(!t)throw new y("auth","Not logged in.",{hint:"Run `arcanist auth login` or set `ARCANIST_TOKEN`."});return t}function ei(e){let t=e??process.env.ARCANIST_API_URL??za()?.apiUrl??xb,r=ti(t);if(r)throw new y("user",r);return et(t)}function Ua(e=process.cwd()){let t=Eb(e);if(!t)return null;let r=e;for(;;){let o=vt(r,tt);if(Cn(o))return Ab(o);if(r===t)return null;let n=am(r);if(n===r)return null;r=n}}function ti(e){let t;try{t=new URL(e)}catch{return"Invalid URL format"}return t.username||t.password?"API URL must not include embedded credentials. Use --token or ARCANIST_TOKEN to authenticate.":t.protocol!=="https:"&&!cm(t)?"API URL must use HTTPS for non-local hosts":null}function La(e,t){let r=e.apiUrl??process.env.ARCANIST_API_URL,o=e.token??process.env.ARCANIST_TOKEN;if(!t)return!r&&!o?null:{apiUrl:r,token:o};if(r&&!o||!r&&o)throw new y("user",`${tt} is active; set both ARCANIST_API_URL and ARCANIST_TOKEN, pass both --api-url and --token, or set neither.`);return!r||!o?null:{apiUrl:r,token:o}}function Ib(e){let t=e.apiUrl??process.env.ARCANIST_API_URL,r=e.token??process.env.ARCANIST_TOKEN;return!t||!r?null:{apiUrl:t,token:r}}function im(e){let t=ti(e.apiUrl);if(t)throw new y("user",t);return{apiUrl:et(e.apiUrl),token:e.token}}function Eb(e){let t=e;for(;;){if(kb(t))return t;let r=am(t);if(r===t)return null;t=r}}function kb(e){let t=vt(e,".git");if(!Cn(t))return!1;try{let r=wb(t);if(r.isDirectory())return Cn(vt(t,"HEAD"))&&Cn(vt(t,"config"));if(!r.isFile())return!1;let o=Tb(t);return o?Cn(vt(Sb(e,o),"HEAD")):!1}catch{return!1}}function Tb(e){let t=Da(e,"utf-8").split(/\r?\n/).find(o=>o.startsWith("gitdir:"));return t&&t.slice(7).trim()||null}function Ab(e){let t;try{t=JSON.parse(Da(e,"utf-8"))}catch{throw new y("user",`${tt} is not valid JSON.`)}if(!t||typeof t!="object")throw new y("user",`${tt} must contain both apiUrl and token.`);let r=t;if(typeof r.apiUrl!="string"||typeof r.token!="string"||!r.apiUrl||!r.token)throw new y("user",`${tt} must contain both apiUrl and token.`);let o;try{o=new URL(r.apiUrl)}catch{throw new y("user",`${tt} apiUrl must be a valid URL.`)}if(!cm(o))throw new y("user",`${tt} apiUrl must be a loopback host.`);let n=ti(r.apiUrl);if(n)throw new y("user",n);return{apiUrl:et(r.apiUrl),token:r.token}}function cm(e){let t=e.hostname.replace(/^\[|\]$/g,"");return t==="localhost"||t==="127.0.0.1"||t==="::1"}function ee(e,t={}){let o={...e?.optsWithGlobals?.(),...t};return{...o,noColor:o.noColor===!0||o.color===!1}}function xe(e,t={}){return ee(e,t).json===!0}function qe(e){process.stdout.write(`${JSON.stringify(e)}
|
|
8
8
|
`)}function D(e,t,r,o){if(xe(e,t)){qe(r);return}o(r)}function Y(e,t={}){let r=ee(e,t);return{runtime:r,config:ve(r)}}async function Pb(){let e=[];for await(let t of process.stdin)e.push(Buffer.isBuffer(t)?t:Buffer.from(String(t)));return Buffer.concat(e).toString()}async function Nn(){return(await Pb()).trim()}function lm(e){(e.noColor===!0||!process.stdout.isTTY)&&(process.env.NO_COLOR="1")}function j(e){return e.replace(/\u001b\][^\u0007]*(?:\u0007|\u001b\\)/g,"").replace(/\u001b\[[0-?]*[ -\/]*[@-~]/g,"").replace(/[\u0000-\u001f\u007f]/g,"")}function Ne(e){return e.split(/\r?\n/).map(j).join(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryarcanist/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.412",
|
|
4
4
|
"description": "Command-line interface for Arcanist: inspect sessions, prepare Arcanist environments, and trigger reviews",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/proper-lockfile": "^4.1.4",
|
|
37
|
-
"tsup": "^
|
|
37
|
+
"tsup": "^9.0.0",
|
|
38
38
|
"typescript": "^5.9.3"
|
|
39
39
|
}
|
|
40
40
|
}
|