typebulb 0.27.0 → 0.27.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.
@@ -2217,7 +2217,7 @@ var Patcher = class _Patcher {
2217
2217
 
2218
2218
  // cli/agents/pi/server/piPatcherExtension.ts
2219
2219
  var DESCRIPTION = true ? "Apply unified diffs to files \u2014 tolerant of form, strict about intent. Repairs sloppy AI-generated diffs (mangled headers, whitespace drift, missing prefixes; line numbers can be wrong or absent \u2014 hunks anchor by fuzzy-matched context lines) and applies all hunks atomically when the intent is unambiguous; fails with a precise, typed error when it isn't. Use for multi-hunk edits in one step, or when exact string-replacement editing fails on whitespace or invisible characters." : "Apply unified diffs to files.";
2220
- var BUILD_TAG = true ? "matchu-patchu-pi 0.2.0, built 2026-07-15 16:26:17" : "matchu-patchu-pi dev";
2220
+ var BUILD_TAG = true ? "matchu-patchu-pi 0.2.0, built 2026-07-15 19:10:21" : "matchu-patchu-pi dev";
2221
2221
  var errorBlocks = (errors) => {
2222
2222
  const parts = [`Patch failed with ${errors.length} error(s):`];
2223
2223
  for (const e of errors) parts.push("", e.toString());
@@ -821,6 +821,12 @@ a.server-port:hover { text-decoration: underline; }
821
821
  .server-name.remote:hover { text-decoration: none; }
822
822
  .sample-link { color: var(--muted); font-size: .76rem; text-decoration: none; cursor: pointer; flex: none; }
823
823
  .sample-link:hover { color: var(--accent); text-decoration: underline; }
824
+ /* The samples-catalog fold header (bulbsPill.ts groupRow): caret in the button column, muted label
825
+ spanning the remaining tracks. Pitch, hover, and the keyboard highlight inherit from .server-row. */
826
+ .sample-group { cursor: pointer; color: var(--muted); }
827
+ .sample-group:hover, .sample-group.active { color: var(--fg); }
828
+ .sample-group .caret-tri { justify-self: center; }
829
+ .sample-group-label { grid-column: 2 / -1; }
824
830
  /* The 1fr name column: name + (in full-text mode) its hit count read together, the badge
825
831
  right-aligned at the column's end by the name's flex:1 — the session row's preview/hits layout. */
826
832
  .bulb-name-cell { display: flex; align-items: baseline; gap: .6rem; min-width: 0; }
package/dist/index.js CHANGED
@@ -548,7 +548,7 @@ ${r.slice(0,W0)}`}],effort:0,webSearch:!1,signal:e});if(!i.ok)continue;let o=Y0(
548
548
  `).filter(Boolean).map(async w=>{try{return{f:w,m:(await sE(jt(e.cwd,w))).mtimeMs}}catch{return{f:w,m:0}}}))).sort((w,_)=>_.m-w.m).map(w=>w.f)}function Hg(){for(let g of[...t])o(g)}async function Wg(g){return r.createDriver?Fm(e.cwd,g):{ok:!1,error:"not supported"}}async function Vg(g){return qm(e.cwd,String(g??""))}async function Yg(){return r.listSessionFiles(e.cwd).sort((g,v)=>v.mtime-g.mtime).map(({sessionId:g,file:v,mtime:w})=>({sessionId:g,mtime:w,preview:r.readPreview(v)}))}let Ll=new Map;function Gg(g,v){let w=Ll.get(g);if(w&&w.mtime===v)return w.turns;let _=[],M="";try{M=Ui(g,"utf8")}catch{return[]}for(let B of M.split(`
549
549
  `)){if(!B.trim())continue;let L=r.parseEntry(B);if(!L)continue;let J=r.searchText(L);J&&_.push({text:J,lower:J.toLowerCase()})}return Ll.set(g,{mtime:v,turns:_}),_}async function zg(g){let v=g.toLowerCase(),w=[];for(let{sessionId:_,file:M,mtime:B}of r.listSessionFiles(e.cwd).sort((L,J)=>J.mtime-L.mtime)){let{hitCount:L,snippet:J}=Bi(Gg(M,B),v);if(L&&(w.push({sessionId:_,mtime:B,preview:r.readPreview(M),hitCount:L,snippet:J}),w.length>=fE))break}return w}let $l=800,Ml=new Map;function Qg(g,v){let w=Ml.get(g);if(w&&w.mtime===v)return w.text;let _="";try{_=Ui(g,"utf8")}catch{return""}let M="";for(let L of _.split(`
550
550
  `)){if(!L.trim())continue;let J=r.parseEntry(L);if(J)for(let q of r.apply(J,e.sessionStartMs).events)q.type==="assistant"&&q.text.trim()&&(M=q.text.trim())}let B=M.length>$l?M.slice(0,$l).trimEnd()+"\u2026":M;return Ml.set(g,{mtime:v,text:B}),B}async function Xg(g){let v=r.listSessionFiles(e.cwd).find(w=>w.sessionId===g);return{text:v?Qg(v.file,v.mtime):""}}async function Zg(g){let v=e,w=r.listSessionFiles(v.cwd).find(_=>_.sessionId===g);return w?w.file===v.file?{ok:!0}:(C(w),c(),a(),{ok:!0}):{ok:!1,error:"session not found"}}return p(e.cwd),y(e.cwd),b(),{info:N,poll:He,logEmbedStatus:ht,listSessions:Yg,searchSessions:zg,sessionPeek:Xg,attach:Zg,composerSend:jg,composerStop:Ug,composerNew:Jg,composerFiles:Kg,composerUiRespond:Fg,composerRpc:qg,composerPaste:Wg,composerPasteRead:Vg,shutdownComposer:Hg}}var aE,cE,Vm,lE,fE,sl=T(()=>{ut();Im();Di();nl();Um();aE=".typebulb",cE=`${aE}/locks`,Vm=5e3,lE=6e4;fE=50});import{existsSync as ol,mkdirSync as Ym,readFileSync as Gm,writeFileSync as zm}from"fs";import{join as _e,isAbsolute as dE}from"path";async function Qm(r,e){let t=dE(r)?r:_e(K,r);return ol(t)?(Zc(t,e),{ok:!0}):{ok:!1,error:"file not found"}}async function Xm(r){let e=K,t=Xc(r),n=_e(e,"typebulbs");Ym(n,{recursive:!0});let s=Gc(t),i=`${s}.bulb.md`;for(let l=2;ol(_e(n,i))&&Gm(_e(n,i),"utf8")!==t;l++)i=`${s}-${l}.bulb.md`;let o=_e(n,i);ol(o)||zm(o,t);let a=_e("typebulbs",i),c=await Pi(a,{cwd:e,open:!1});return{ok:!0,file:a,pid:c.pid,url:c.url}}async function Zm(){return V(K)}async function eh(r){return await $t(r),{ok:!0}}async function th(){return Ci(K).filter(r=>!r.serverOnly).map(r=>({...r,trusted:Lt(r.path)}))}async function rh(r){let e=r.toLowerCase(),t=[];for(let n of Ci(K).filter(s=>!s.serverOnly).sort((s,i)=>i.mtime-s.mtime)){let s="";try{s=Gm(n.path,"utf8")}catch{continue}let i=[];for(let c of s.split(`
551
- `)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=Bi(i,e);o&&t.push({path:n.path,hitCount:o,snippet:a})}return t}async function nh(r,e){let t=K;e!=null&&mr(r,e);let n=await Pi(r,{cwd:t,open:!1,trust:e});return{ok:!0,file:n.file,pid:n.pid,url:n.url,trust:!!n.trust}}async function sh(r){return{cap:await Qc(r)}}async function ih(r,e){return mr(r,e),{ok:!0}}async function oh(r,e){return Pe(r,e)}async function ch(){return Cn&&Date.now()-Cn.fetchedAt<=pE?Cn.samples:(il??=gE().finally(()=>{il=null}),il)}async function gE(){try{let r=await fetch(`${ah}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(mE)});if(!r.ok)throw new Error(`HTTP ${r.status}`);let t=(await r.json()).filter(n=>n.slug!=="welcome").map(n=>({slug:n.slug,name:n.name,description:iu(n.config)}));return Cn={samples:t,fetchedAt:Date.now()},t}catch{return Cn?.samples??[]}}async function lh(r){if(!/^[a-z0-9][a-z0-9-]*$/.test(r))return{ok:!1,error:"bad slug"};let e;try{let s=await fetch(`${ah}/api/scripts/u/samples/${r}.md`,{signal:AbortSignal.timeout(hE)});if(!s.ok)return{ok:!1,error:`HTTP ${s.status}`};e=await s.text()}catch(s){return{ok:!1,error:s?.message??String(s)}}let t=_e("typebulbs","u","samples");Ym(_e(K,t),{recursive:!0});let n=_e(t,`${r}.bulb.md`);return zm(_e(K,n),e),{ok:!0,file:n}}var ah,pE,mE,hE,Cn,il,al=T(()=>{vr();ut();nl();rt();ah="https://api.typebulb.com",pE=3600*1e3,mE=5e3,hE=15e3,Cn=null,il=null});import{readFileSync as ul,writeFileSync as fh,mkdirSync as yE,appendFileSync as dh,rmSync as uh}from"fs";import{join as Wi,dirname as bE}from"path";import{createServer as wE}from"http";function ft(r){try{return JSON.parse(ul(r,"utf8"))}catch{return null}}function Hi(r,e){yE(bE(r),{recursive:!0}),fh(r,JSON.stringify(e,null,2)+`
551
+ `)){let l=c.replace(/\s+/g," ").trim();l&&i.push({text:l,lower:l.toLowerCase()})}let{hitCount:o,snippet:a}=Bi(i,e);o&&t.push({path:n.path,hitCount:o,snippet:a})}return t}async function nh(r,e){let t=K;e!=null&&mr(r,e);let n=await Pi(r,{cwd:t,open:!1,trust:e});return{ok:!0,file:n.file,pid:n.pid,url:n.url,trust:!!n.trust}}async function sh(r){return{cap:await Qc(r)}}async function ih(r,e){return mr(r,e),{ok:!0}}async function oh(r,e){return Pe(r,e)}async function ch(){return Cn&&Date.now()-Cn.fetchedAt<=pE?Cn.samples:(il??=gE().finally(()=>{il=null}),il)}async function gE(){try{let r=await fetch(`${ah}/api/scripts/u/samples?stubs`,{signal:AbortSignal.timeout(mE)});if(!r.ok)throw new Error(`HTTP ${r.status}`);let e=await r.json(),t=i=>i.order??Number.MAX_SAFE_INTEGER,n=i=>Date.parse(i.createdAt??"")||0,s=e.filter(i=>i.slug!=="welcome").sort((i,o)=>t(i)-t(o)||n(o)-n(i)).map(i=>({slug:i.slug,name:i.name,description:iu(i.config)}));return Cn={samples:s,fetchedAt:Date.now()},s}catch{return Cn?.samples??[]}}async function lh(r){if(!/^[a-z0-9][a-z0-9-]*$/.test(r))return{ok:!1,error:"bad slug"};let e;try{let s=await fetch(`${ah}/api/scripts/u/samples/${r}.md`,{signal:AbortSignal.timeout(hE)});if(!s.ok)return{ok:!1,error:`HTTP ${s.status}`};e=await s.text()}catch(s){return{ok:!1,error:s?.message??String(s)}}let t=_e("typebulbs","u","samples");Ym(_e(K,t),{recursive:!0});let n=_e(t,`${r}.bulb.md`);return zm(_e(K,n),e),{ok:!0,file:n}}var ah,pE,mE,hE,Cn,il,al=T(()=>{vr();ut();nl();rt();ah="https://api.typebulb.com",pE=3600*1e3,mE=5e3,hE=15e3,Cn=null,il=null});import{readFileSync as ul,writeFileSync as fh,mkdirSync as yE,appendFileSync as dh,rmSync as uh}from"fs";import{join as Wi,dirname as bE}from"path";import{createServer as wE}from"http";function ft(r){try{return JSON.parse(ul(r,"utf8"))}catch{return null}}function Hi(r,e){yE(bE(r),{recursive:!0}),fh(r,JSON.stringify(e,null,2)+`
552
552
  `)}function mh(r,e,t){let n=Wi(r,".gitignore"),s="";try{s=ul(n,"utf8")}catch{}let i=new Set(s.split(/\r?\n/).map(c=>c.trim())),o=e.filter(c=>!i.has(c));if(!o.length)return;let a=s&&!s.endsWith(`
553
553
  `)?`
554
554
  `:"";try{dh(n,a+t+`
@@ -1893,5 +1893,5 @@ ${OT}
1893
1893
  `);let a=0,c=Promise.resolve();Jt({target:r,onChange:()=>{let l=++a;c=c.then(async()=>{if(l===a)try{console.log("Re-running..."),await o()}catch(d){console.error("Error:",d)}})}})}}import{Console as IT}from"node:console";Oe();async function $g(r,e,t,n){BT();try{let f=yr(await V(),r)[0];f&&(Ai(f.pid,Pe(f.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${f.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let s=Ne(t),{bulb:i,config:o}=await Se(r);i.server||Un("This bulb has no **server.ts** block; nothing to call."),mt(s,r,i.server);let a;try{a=await xn(i.server,r,n,o.dependencies)}catch(f){Un(f instanceof Error?f.message:String(f))}let c=lo(a,e.fn);if(!c){let f=[...Object.keys(a).filter(p=>typeof a[p]=="function"),...Object.keys(co)];Un(`Function '${e.fn}' not found. Available: ${f.length?f.join(", "):"(none)"}.`)}let l=await LT(e);if(uo(c)){try{for await(let f of c(...l))await Lg(JSON.stringify(f,Mg)+`
1894
1894
  `)}catch(f){Un(f instanceof Error?f.stack??f.message:String(f))}return Ig(0)}let d;try{d=await c(...l)}catch(f){Un(f instanceof Error?f.stack??f.message:String(f))}let u=DT(d);u!==void 0&&await Lg(u+`
1895
1895
  `),Ig(0)}function Ig(r){process.exitCode=r,setTimeout(()=>process.exit(r),2e3).unref?.()}async function LT(r){if(r.hasArgsFlag){let e=r.argsJson??"";return e==="-"&&(e=await jT()),MT(e)}return $T(r.positional)}function $T(r){return r.map(e=>{try{return JSON.parse(e)}catch{return e}})}function MT(r){let e;try{e=JSON.parse(r)}catch(t){throw new Error(`--args must be a JSON array: ${t instanceof Error?t.message:String(t)}`)}if(!Array.isArray(e))throw new Error(`--args must be a JSON array, got ${e===null?"null":typeof e}`);return e}function DT(r){if(r!==void 0)return JSON.stringify(r,Mg,2)}function Mg(r,e){return typeof e=="bigint"?e.toString():e}function Un(r){process.stderr.write(r+`
1896
- `),process.exit(1)}function BT(){let r=new IT(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function Lg(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function jT(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var Nl="0.27.0";function Dg(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
1896
+ `),process.exit(1)}function BT(){let r=new IT(process.stderr,process.stderr);console.log=r.log.bind(r),console.info=r.info.bind(r),console.debug=r.debug.bind(r),console.dir=r.dir.bind(r)}function Lg(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function jT(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var Nl="0.27.2";function Dg(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
1897
1897
  ${e}`),process.exit(1))}async function FT(){let r=Vl(process.argv.slice(2));if(r.version&&(console.log(`typebulb ${Nl}`),process.exit(0)),r.help&&(Yl(),process.exit(0)),ng(),r.subcommand==="logs"){await pg(r.file||void 0,{follow:r.follow,clear:r.clear,run:r.run,lines:r.lines});return}if(r.subcommand==="wait"){await mg(r.file||void 0,{match:r.match,timeoutSec:r.timeoutSec});return}if(r.subcommand==="stop"){r.stopScope?await gg(r.stopScope):await hg(r.file||void 0);return}if(r.subcommand==="send"){await bg(r.file,r.sendMessage,r.sendWaitMs??0);return}if(r.subcommand==="skill"){await ug(Nl);return}if(r.subcommand==="models"){await cg(r.mode);return}if(r.subcommand==="agent"){await(r.agentTarget?_g(r):ag(Nl));return}if(r.subcommand==="trust"||r.subcommand==="untrust"){await rg(r.file||void 0,r.subcommand==="trust");return}let e;if(!r.file||r.file==="."){let c=await qp(process.cwd());c||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=c}else e=Kt.resolve(r.file);await Bg.access(e).then(()=>!0,()=>!1)||(Tr().includes(r.file)&&(console.error(`To open the ${r.file} agent mirror, run: npx typebulb agent:${r.file}`),process.exit(1)),console.error(`File not found: ${e}`),process.exit(1)),e.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1));let n=r.file&&r.file!=="."?r.file:Kt.relative(process.cwd(),e)||Kt.basename(e),s=`npx typebulb --trust ${n.includes(" ")?`"${n}"`:n}`;if(r.subcommand==="predict"){await tg(e,s);return}let i=!r.noTrust&&Lt(e);i&&!r.trust&&console.error("trust: granted from memory (run `typebulb untrust` to revoke)"),r.trust=r.noTrust?!1:r.trust||i;let o;try{o=await Se(e)}catch{}let a;if(r.local){o&&!(r.local.name in(o.config.dependencies??{}))&&(console.error(`--replace: '${r.local.name}' is not a dependency in this bulb's config.json; nothing to replace.`),process.exit(1)),o&&r.subcommand!=="call"&&(!o.bulb.code||r.server)&&console.warn("warning: --replace has no effect in server mode (the override is client-only).");try{a=await Hl(r.local)}catch(c){console.error(c instanceof Error?c.message:String(c)),process.exit(1)}console.error(`replace: ${a.name} \u2192 ${Kt.relative(process.cwd(),a.dir)||"."}`)}if(r.subcommand==="check"){await eg(e,a);return}if(r.subcommand==="call"){Dg(r.trust,s),await $g(e,{fn:r.fn,positional:r.callArgs,argsJson:r.argsJson,hasArgsFlag:r.hasArgsFlag},r.mode,a);return}if(o&&o.bulb.server&&(Hs(o.bulb)||r.server)){Dg(r.trust,s),await Ng(e,r.watch,r.mode,a);return}await Tg(e,r,s,a)}FT().catch(r=>{console.error("Error:",r.message),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "typebulb",
3
- "version": "0.27.0",
3
+ "version": "0.27.2",
4
4
  "description": "Typebulb CLI to run single-file markdown apps called bulbs, either as standalone web apps or embedded in agent responses.",
5
5
  "license": "MIT",
6
6
  "repository": {