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