bostrat-node 1.6.6 → 1.7.0
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-decision +2 -0
- package/dist/index.js +170 -154
- package/package.json +2 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var u=process.env.BOSTRAT_AGENT_URL||`http://127.0.0.1:${process.env.BOSTRAT_AGENT_PORT||3362}`;async function a(i,c,t){let n=await fetch(`${u}${c}`,{method:i,headers:t?{"content-type":"application/json"}:void 0,body:t?JSON.stringify(t):void 0}),e=await n.json().catch(()=>({}));if(!n.ok)throw new Error(e.error||`HTTP ${n.status}`);return e}function d(i){console.error(`[bostrat-decision] ${i}`),process.exit(1)}var o=process.argv.slice(2),l=o.shift();if(l==="record"){let i=null,c="",t=null,n=[],e=[];for(let s=0;s<o.length;s++)o[s]==="--title"?i=o[++s]:o[s]==="--context"?c=o[++s]:o[s]==="--alt"?n.push(o[++s]):o[s]==="--supersedes"?t=o[++s]:e.push(o[s]);let r=e.join(" ").trim();(!i||!r)&&d('usage: bostrat-decision record --title "\u2026" [--context "\u2026"] [--alt "rejected option"]\u2026 [--supersedes <id>] "<what was decided>"');try{await a("POST","/api/decisions/record",{cwd:process.cwd(),title:i,context:c,decision:r,alternatives:n,supersedesId:t}),console.log(`[bostrat-decision] recorded \u201C${i}\u201D${t?` (supersedes ${t})`:""}`),console.log(" It joins this Track's circuit decision log; records are immutable \u2014 supersede to change one.")}catch(s){d(s.message)}}else if(l==="ls"){let i=o.includes("--all");try{let{decisions:c,counts:t}=await a("GET",`/api/decisions?cwd=${encodeURIComponent(process.cwd())}`),n=i?c:c.filter(e=>e.status!=="dismissed");n.length||console.log("[bostrat-decision] nothing recorded on this Track yet");for(let e of n){let r=e.status==="active"?" ":e.status==="superseded"?"~":"\xD7";console.log(`${r} ${e.decisionId.padEnd(18)} ${(e.source==="fork-card"?"[card]":"[rec] ").padEnd(7)} ${e.title}`),e.decision&&console.log(` \u2192 ${e.decision}`),e.alternatives?.length&&console.log(` rejected: ${e.alternatives.map(s=>s.label).join(", ")}`)}t&&console.log(` (${t.active} active \xB7 ${t.superseded} superseded \xB7 ${t.dismissed} dismissed \xB7 ${t.forkCard} from answered cards)`)}catch(c){d(c.message)}}else d("usage: bostrat-decision <record|ls> \u2026");
|