bostrat-node 1.13.1 → 1.13.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/bin/bostrat-ship CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- var i=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`,n="[bostrat-ship]";function a(e){let t=/fetch failed|ECONNREFUSED/.test(String(e))?`the bostrat agent isn't reachable at ${i} \u2014 run this from inside a Track box`:e;console.error(`${n} ${t}`),process.exit(1)}var c=process.argv.slice(2),h=c.shift();h!=="offer"&&a("usage: bostrat-ship offer [plan.json | -] (see the header for the plan shape)");var r=c.find(e=>!e.startsWith("--")),p=async()=>{let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString("utf8")},s;try{let e=!r||r==="-"?await p():await(await import("node:fs/promises")).readFile(r,"utf8");s=e.trim()?JSON.parse(e):{}}catch{a("plan must be JSON (a file path, or piped on stdin) \u2014 see the `bostrat-ship` header for the shape")}s.ship||(s={label:s.label,why:s.why,ship:{actions:s.actions,toPr:s.toPr,rebase:s.rebase,base:s.base,repos:s.repos}});s.label=s.label||"Ship";s.trigger="now";Array.isArray(s.ship.actions)||(s.ship.actions=["commit","push","pr"]);try{let e=await fetch(`${i}/api/followups/offer`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cwd:process.cwd(),plan:s})}),t=await e.json().catch(()=>({}));e.ok||a(t.error||`HTTP ${e.status}`);let o=t.result||{};o.skipped?console.log(`${n} ${o.reason} \u2014 no card rendered.`):(console.log(`${n} ship offer posted: ${o.offered.join(" + ")} on ${o.branch}${o.prState==="open"?" (PR already open)":""} \u2014 one-tap controls are in the Track chat.`),o.replaced&&console.log(" This REPLACED the ship offer you already posted this turn (its card is withdrawn). Offer once, as the last thing you do."),console.log(" HOLD HERE: end your turn now. The go-ahead comes back as a chat message naming the steps to run."))}catch(e){a(e.message)}
2
+ var d=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`,i="[bostrat-ship]";function o(e){let a=/fetch failed|ECONNREFUSED/.test(String(e))?`the bostrat agent isn't reachable at ${d} \u2014 run this from inside a Track box`:e;console.error(`${i} ${a}`),process.exit(1)}var n=process.argv.slice(2),h=n.shift();if(h==="updated"){let e=t=>{let r=n.indexOf(t);return r>=0?n[r+1]:void 0},a=e("--pr");a!=null&&!/^\d+$/.test(String(a).replace(/^#/,""))&&o("--pr takes a PR number");try{let t=await fetch(`${d}/api/ship/updated`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cwd:process.cwd(),number:a!=null?Number(String(a).replace(/^#/,"")):null,rebased:n.includes("--rebased"),base:e("--base")??null})}),r=await t.json().catch(()=>({}));t.ok||o(r.error||`HTTP ${t.status}`);let c=r.result||{};c.skipped?console.log(`${i} ${c.reason} \u2014 no new card.`):console.log(`${i} update to #${c.number} reported (${String(c.sha).slice(0,7)}) \u2014 the "Updated PR" card with merge + archive posts below your closing message when this turn ends.`)}catch(t){o(t.message)}process.exit(0)}h!=="offer"&&o("usage: bostrat-ship offer [plan.json | -] | bostrat-ship updated [--pr N] [--rebased] [--base main]");var p=n.find(e=>!e.startsWith("--")),l=async()=>{let e=[];for await(let a of process.stdin)e.push(a);return Buffer.concat(e).toString("utf8")},s;try{let e=!p||p==="-"?await l():await(await import("node:fs/promises")).readFile(p,"utf8");s=e.trim()?JSON.parse(e):{}}catch{o("plan must be JSON (a file path, or piped on stdin) \u2014 see the `bostrat-ship` header for the shape")}s.ship||(s={label:s.label,why:s.why,ship:{actions:s.actions,toPr:s.toPr,rebase:s.rebase,base:s.base,repos:s.repos}});s.label=s.label||"Ship";s.trigger="now";Array.isArray(s.ship.actions)||(s.ship.actions=["commit","push","pr"]);try{let e=await fetch(`${d}/api/followups/offer`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({cwd:process.cwd(),plan:s})}),a=await e.json().catch(()=>({}));e.ok||o(a.error||`HTTP ${e.status}`);let t=a.result||{};t.skipped?console.log(`${i} ${t.reason} \u2014 no card rendered.`):(console.log(`${i} ship offer posted: ${t.offered.join(" + ")} on ${t.branch}${t.prState==="open"?" (PR already open)":""} \u2014 one-tap controls are in the Track chat.`),t.replaced&&console.log(" This REPLACED the ship offer you already posted this turn (its card is withdrawn). Offer once, as the last thing you do."),console.log(" HOLD HERE: end your turn now. The go-ahead comes back as a chat message naming the steps to run."))}catch(e){o(e.message)}