@maind-dev/cli 0.135.1 → 0.135.2
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/build/index.js +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -265,7 +265,7 @@ maind: and re-run \`maind launch claude\`. (Or launch without routing: \`maind l
|
|
|
265
265
|
`,stderr:""}}let n=["maind: dry-run \u2014 nothing installed, written, or spawned.",`maind: config ${e.configPath} (${e.configSource})`,`maind: switchyard detected: ${e.switchyardDetected?"yes":"no"}`,`maind: would run: ${e.argv.join(" ")}`].join(`
|
|
266
266
|
`);return{stdout:e.toml??`(using existing config: ${e.configPath})
|
|
267
267
|
`,stderr:n+`
|
|
268
|
-
`}}a(nS,"renderDryRun");import{createRequire as XF}from"node:module";function JF(){return"0.135.
|
|
268
|
+
`}}a(nS,"renderDryRun");import{createRequire as XF}from"node:module";function JF(){return"0.135.2";try{return XF(import.meta.url)("../package.json").version}catch{return"0.0.0-unknown"}}a(JF,"resolveVersion");var me=JF();var s1=5e3;function at(e){process.stderr.write(`maind: ${e}
|
|
269
269
|
`)}a(at,"err");function a1(e){return e instanceof Error?e.message:String(e)}a(a1,"msg");var l1=new Set(["--config","--route","--mcp-url"]);function oS(e){let t=a(o=>{let i=e.indexOf(o);if(!(i===-1||i+1>=e.length))return e[i+1]},"get"),n=a(o=>e.includes(o),"has"),r=null;for(let o=0;o<e.length;o++){let i=e[o];if(i.startsWith("-")){l1.has(i)&&o++;continue}r=i;break}return{agent:r,dryRun:n("--dry-run"),config:t("--config")??null,route:t("--route")??Hx,direct:n("--direct"),noFallback:n("--no-fallback"),noInstall:n("--no-install"),json:n("--json"),mcpUrl:t("--mcp-url")??null}}a(oS,"parseLaunchArgs");var c1={probe(e,t){let n=rS(e,t,{stdio:["ignore","pipe","pipe"],encoding:"utf8",timeout:1e4}),r=n.status===0&&!n.error,o=typeof n.stdout=="string"?n.stdout.trim():"";return{ok:r,stdout:o.length>0?o:null}},install(e){return rS("uv",[...e],{stdio:["ignore","inherit","inherit"]}).status},spawnInteractive(e){let t=Date.now();return new Promise(n=>{let r=!1,o=ZF(e[0],e.slice(1),{stdio:"inherit",env:process.env}),i=a(()=>{},"onSigint"),s=a(d=>()=>{try{o.kill(d)}catch{}},"makeForward"),l=s("SIGTERM"),c=s("SIGHUP");process.on("SIGINT",i),process.on("SIGTERM",l),process.on("SIGHUP",c);let u=a(()=>{process.removeListener("SIGINT",i),process.removeListener("SIGTERM",l),process.removeListener("SIGHUP",c)},"cleanup");o.on("error",d=>{r||(r=!0,u(),n({code:null,signal:null,elapsedMs:Date.now()-t,spawnError:d.message}))}),o.on("exit",(d,f)=>{r||(r=!0,u(),n({code:d,signal:f,elapsedMs:Date.now()-t,spawnError:null}))})})},async fetchTemplate(e,t){let n;try{n=ke()}catch(r){if(r instanceof Re)return null;throw r}try{let r=new Ee({apiKey:n.apiKey,deviceId:n.deviceId,clientVersion:me,mcpUrl:e??void 0,projectKey:t}),o=new Promise(s=>{setTimeout(()=>s(null),s1).unref()}),i=r.callTool("get_template",{template_id:Gx}).then(s=>typeof s.template_body=="string"&&s.template_body.trim().length>0?s.template_body:null).catch(()=>null);return await Promise.race([i,o])}catch{return null}},writeConfig(e,t){let n=i1(e);n&&n!=="."&&t1(n,{recursive:!0}),r1(e,t,"utf8")},readFile(e){try{return n1(e,"utf8")}catch{return null}},fileExists(e){return e1(e)},repoRoot(){try{let e=QF("git",["rev-parse","--show-toplevel"],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:5e3}).trim();return e.length>0?e:null}catch{return null}},projectKey(){return Ye().projectKey},userConfigDir(){return Fr()},homeDir(){return o1()},env:process.env,platform:process.platform};function u1(e,t){return e!==null?kp(e,".maind",fp):kp(t,fp)}a(u1,"resolveRoutesPath");async function iS(e,t=c1){let n=Vx(e.agent);if(n.kind==="unknown")return at(`usage: maind launch <agent> [--dry-run] [--config <path>] [--route <name>] [--direct] [--no-fallback] [--no-install] \u2014 supported: ${pp.join(", ")}`),2;if(n.kind==="planned")return at(`agent '${n.agent}' is planned but not yet supported \u2014 v1 supports: ${pp.join(", ")}.`),2;if(e.json&&!e.dryRun)return at("--json is only valid together with --dry-run (stdout belongs to the agent session)."),2;let r=n.agent;if(e.direct)return at(tS()),sS(t,yp(r));let o=qx(t.env);o.warning!==null&&at(o.warning);let i,s,l;if(e.config!==null){if(!t.fileExists(e.config))return at(`config not found: ${e.config}`),2;let f=t.readFile(e.config);if(f===null||Yx(f,e.route)===null)return at(`config ${e.config} is not valid routes TOML with a [routes.${e.route}] entry.`),2;i=e.config,s=null,l="flag"}else{let f=await t.fetchTemplate(e.mcpUrl,t.projectKey()),p=f===null?null:zx(f,e.route);if(s=Wx(e.route,o,p),p!==null)l="template";else{l="builtin";let m=f===null?"no curated template (offline, unauthenticated, or not published)":`curated template unusable (missing route '${e.route}', or it pins its own targets)`;at(`using builtin routing policy (${m}).`)}i=u1(t.repoRoot(),t.userConfigDir())}let c=il,u=t.probe(il,["--version"]).ok;if(e.dryRun){let f={agent:r,configPath:i,configSource:l,toml:s,argv:gp(c,r,e.route,i),backendKind:o.kind,switchyardDetected:u},p=nS(f,e.json);return p.stderr.length>0&&process.stderr.write(p.stderr),process.stdout.write(p.stdout),0}if(!u){if(e.noInstall)return at(`switchyard not found (--no-install). Install it with:
|
|
270
270
|
maind: ${sl}`),1;if(!t.probe("uv",["--version"]).ok)return at(Zx()),1;if(at(Jx()),t.install(Kx),t.probe(il,["--version"]).ok)u=!0;else{let f=kp(t.homeDir(),".local","bin",t.platform==="win32"?"switchyard.exe":"switchyard");t.probe(f,["--version"]).ok&&(c=f,u=!0)}if(!u)return _p(t,e,r,Qx())}if(l!=="flag"&&s!==null)try{t.writeConfig(i,s)}catch(f){return at(`could not write ${i}: ${a1(f)}`),1}let d=await t.spawnInteractive(gp(c,r,e.route,i));return d.spawnError!==null?_p(t,e,r,`could not start switchyard (${d.spawnError})`):Xx(d.code,d.signal,d.elapsedMs)==="fallback-eligible"?_p(t,e,r,`switchyard exited with code ${d.code} after ${(d.elapsedMs/1e3).toFixed(1)}s`):bp(d.code,d.signal)}a(iS,"runLaunch");async function _p(e,t,n,r){return t.noFallback?(at(`${r} (--no-fallback set \u2014 not degrading to a direct spawn).`),1):(process.stderr.write(eS(r)+`
|
|
271
271
|
`),sS(e,yp(n)))}a(_p,"degradeOrFail");async function sS(e,t){let n=await e.spawnInteractive(t);return n.spawnError!==null?(at(`'${t[0]}' not found on PATH \u2014 install the agent CLI first (${n.spawnError}).`),1):bp(n.code,n.signal)}a(sS,"spawnAndPropagate");import{execFileSync as Cr}from"node:child_process";import{cpSync as IK,existsSync as tc,mkdirSync as NK,mkdtempSync as Pm,readdirSync as nT,readFileSync as rT,realpathSync as DK,rmSync as oT,statSync as jK,writeFileSync as Ji}from"node:fs";import{homedir as PK,tmpdir as Mm}from"node:os";import{basename as MK,dirname as Hm,join as lt,resolve as Gm}from"node:path";function aS(e,t,n=()=>null){if(e!==null)return e.trim()==="0"?{kind:"none",reason:"no required checks"}:{kind:"watch"};let r=t();if(r===null)return{kind:"unknown",reason:"neither query could be answered"};if(r.trim()==="0")return{kind:"none",reason:"no checks at all"};let o=n();return o!==null&&o.trim()==="0"?{kind:"none",reason:"checks exist, none required",checks:Number.parseInt(r.trim(),10)}:{kind:"unknown",reason:`${r.trim()} check(s) exist, but the required-query failed`}}a(aS,"classifyCheckCount");function lS(e){switch(e.kind){case"watch":return"";case"none":return e.reason==="no checks at all"?"this repository reports NO checks at all \u2014 the merge rests on the local gate alone.":e.reason==="checks exist, none required"?`${e.checks??"some"} check(s) run on this PR, but none is required (no branch protection) \u2014 they are not waited for; the merge rests on the local gate.`:"no required checks are configured \u2014 nothing to wait for.";case"unknown":return`could not establish the required checks: ${e.reason}.`}}a(lS,"checkCountLine");function cS(e,t){let n=new Set(t);return e.filter(r=>!n.has(r))}a(cS,"missingRequiredChecks");function uS(e){if(e===null)return null;try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let o=r;if(o?.type!=="required_status_checks")continue;let i=o.parameters?.required_status_checks;if(Array.isArray(i))for(let s of i){let l=s?.context;typeof l=="string"&&!n.includes(l)&&n.push(l)}}return n}catch{return null}}a(uS,"requiredContextsFromRules");import{execFileSync as d1}from"node:child_process";function f1(e,t){if(e===0)return{kind:"clean"};if(e!==1)return{kind:"unknown",reason:e===129?"this git does not know `merge-tree --write-tree` (needs git 2.38+)":`git merge-tree failed (exit ${e??"signal"})`};let n=t.split(`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maind-dev/cli",
|
|
3
|
-
"version": "0.135.
|
|
3
|
+
"version": "0.135.2",
|
|
4
4
|
"description": "Headless maind CLI — pull stack-relevant lessons into CI runners, report CI outcomes, brief agents on local git state (branch, PRs, peers), and launch coding agents behind a local NVIDIA NeMo Switchyard routing proxy. No device flow; authenticates from MAIND_API_KEY.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|