bostrat-node 1.6.1 → 1.6.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-blueprint +2 -0
- package/bin/bostrat-loop +3 -3
- package/dist/index.js +178 -149
- package/package.json +1 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var d=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`;async function l(e,n,r){let o=await fetch(`${d}${n}`,{method:e,headers:r?{"content-type":"application/json"}:void 0,body:r?JSON.stringify(r):void 0}),t=await o.json().catch(()=>({}));if(!o.ok)throw new Error(t.error||`HTTP ${o.status}`);return t}function c(e){console.error(`[bostrat-blueprint] ${e}`),process.exit(1)}function u(e){if(e){console.log(` parsed: ${e.sections.recognized} recognized section(s), ${e.items.total} item(s) (${e.items.bindable} bindable)`);for(let n of e.issues??[])console.log(` \u26A0 ${n.message}`)}}var i=process.argv.slice(2),s=i.shift();if(s==="add"||s==="update"){let e=null,n=null,r=null,o=null;for(let t=0;t<i.length;t++)i[t]==="--circuit"?e=i[++t]:i[t]==="--new-circuit"?n=i[++t]:i[t]==="--name"?r=i[++t]:o=i[t];o||c(`usage: bostrat-blueprint ${s} [--circuit <name-or-id>] [--new-circuit "<name>"] [--name "<title>"] <file.md>`);try{let t=await(await import("node:fs/promises")).readFile(o,"utf8"),a=await l("POST","/api/blueprints/publish",{cwd:process.cwd(),circuit:e,newCircuit:n,name:r,markdown:t});console.log(`[bostrat-blueprint] published \u201C${a.blueprint.name}\u201D v${a.blueprint.version} on circuit \u201C${a.circuit.name}\u201D`),u(a.report),a.blueprint.version===1&&console.log(" The circuit page now carries this blueprint; PR titles/branches mentioning BP ids auto-tick on merge.")}catch(t){c(t.message)}}else if(s==="show"||s==="report")try{let e=await l("GET",`/api/blueprints/show?cwd=${encodeURIComponent(process.cwd())}${i[0]?`&circuit=${encodeURIComponent(i[0])}`:""}`);if(console.log(`[bostrat-blueprint] \u201C${e.blueprint.name}\u201D v${e.blueprint.version} (circuit ${e.blueprint.circuitId})`),u(e.report),s==="show")for(let n of e.items)console.log(` ${n.bindable?n.itemId.padEnd(8):"(no id)".padEnd(8)} ${n.sectionKind.padEnd(14)} ${n.text}`)}catch(e){c(e.message)}else if(s==="tag"){i.length||c("usage: bostrat-blueprint tag <BP-id> [<BP-id>\u2026]");try{let e=await l("POST","/api/blueprints/tag",{cwd:process.cwd(),itemIds:i});console.log(`[bostrat-blueprint] tagged this Track onto ${e.itemIds.join(", ")}`),console.log(" (association + cost attribution \u2014 completion still comes from merged PRs or a manual tick)")}catch(e){c(e.message)}}else c("usage: bostrat-blueprint <add|update|show|report|tag> \u2026 (add [--circuit <ref>] <file.md>)");
|
package/bin/bostrat-loop
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var d=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`;function
|
|
3
|
-
${String(
|
|
2
|
+
var d=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`;function n(o){console.error(`[bostrat-loop] ${o}`),process.exit(1)}async function p(){let o=await fetch(`${d}/api/loops`),e=await o.json().catch(()=>({}));if(!o.ok)throw new Error(e.error||`HTTP ${o.status}`);return e.source==="unconfigured"&&n("this node isn't linked to a plane \u2014 loops live in the plane"),e.source==="unreachable"&&n(`plane unreachable (${e.error||"no detail"}) \u2014 try again shortly`),e.loops||[]}var a=o=>o?new Date(o).toISOString().slice(0,16).replace("T"," ")+"Z":"\u2014",h=o=>o.error?`FAILED (${o.error})`:o.outcome==="attention"?`ATTENTION${o.note?` (${o.note})`:""}`:o.outcome==="unreported"?"UNREPORTED (settled with no report \u2014 held for the operator)":o.outcome==="acted"?`acted${o.note?` (${o.note})`:""}`:o.outcome==="ok"?"ok":"running/unreported",u=o=>{let e=(o.runs||[])[o.runs.length-1];return e?`last ${a(e.firedAt)} \u2014 ${h(e)}`:"never ran"},c=process.argv.slice(2),i=c.shift();if(i==="ls")try{let o=await p();o.length||console.log("no loops defined");for(let e of o){let t=e.enabled?"\u25CF":"\u25CB",r=e.enabled?`next ${a(e.nextFireAt)}`:"disabled";console.log(`${t} ${e.name} [${e.schedule} UTC] ${r} ${u(e)} (loop:${e.id})`)}}catch(o){n(o.message)}else if(i==="show"){let o=c.find(e=>!e.startsWith("--"));o||n("usage: bostrat-loop show <name|id>");try{let t=(await p()).find(s=>s.id===o||s.name===o);t||n(`no loop matching "${o}" \u2014 use \`bostrat-loop ls\``);let r=typeof t.assignment=="object"&&t.assignment?t.assignment.provider||JSON.stringify(t.assignment):t.assignment||"\u2014";console.log(`${t.name} (loop:${t.id})`),console.log(` schedule: ${t.schedule} UTC ${t.enabled?`(next ${a(t.nextFireAt)})`:"(disabled)"}`),console.log(` provider: ${r}${t.repo?` repo: ${t.repo}`:""}`),t.trackId&&console.log(` track: ${t.trackId} (the loop's persistent "\u21BB" Track)`),t.expectation&&console.log(` expected: ${t.expectation}`),console.log(` prompt:
|
|
3
|
+
${String(t.prompt||"").split(`
|
|
4
4
|
`).map(s=>` ${s}`).join(`
|
|
5
|
-
`)}`);let l=(
|
|
5
|
+
`)}`);let l=(t.runs||[]).slice(-5);console.log(` recent runs:${l.length?"":" none"}`);for(let s of l)console.log(` ${a(s.firedAt)} ${h(s)}${s.trackId?` (track ${s.trackId})`:""}`);console.log("Loops are operator-managed (Loops tab) \u2014 to change one, describe the change in chat."),console.log('On a loop\'s own run Track, end every run with `bostrat-loop report ok|acted|attention "<note>"`.')}catch(e){n(e.message)}}else if(i==="report"){let o=c[0],e=c[1]||null;["ok","acted","attention"].includes(o)||n('usage: bostrat-loop report <ok|acted|attention> ["<note>"]'),o==="attention"&&!e&&n('an attention report needs a note \u2014 bostrat-loop report attention "<why the operator is needed>"');try{let t=await fetch(`${d}/api/loops/report`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({outcome:o,note:e,cwd:process.cwd()})}),r=await t.json().catch(()=>({}));t.ok||n(r.error||`HTTP ${t.status}`),console.log(`reported "${o}" on loop "${r.loop?.name}"${e?` \u2014 ${e}`:""}`),console.log(o==="attention"?"This Track stays visible on the Tracks page until the operator acknowledges it.":"The settle sweep will archive this Track once the run goes idle.")}catch(t){n(t.message)}}else n("usage: bostrat-loop <ls|show|report> \u2026 (report is the one write; loops are otherwise operator-managed from the Loops tab)");
|