typebulb 0.23.0 → 0.23.1
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/dist/agents/pi/matchu-patchu.ts +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -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-09
|
|
2220
|
+
var BUILD_TAG = true ? "matchu-patchu-pi 0.2.0, built 2026-07-09 15:20:10" : "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());
|
package/dist/index.js
CHANGED
|
@@ -1341,7 +1341,7 @@ globalThis.__tbEntryRan = true; /* load-failure backstop \u2014 see embedProtoco
|
|
|
1341
1341
|
</script>`;function NS(r){let e={};for(let[t,n]of Object.entries(r))e[t]=n.startsWith("https://")?"/proxy/"+n:n;return e}import*as Gs from"fs/promises";import*as Ys from"path";import{existsSync as ap,readFileSync as IS}from"fs";import{execFile as LS}from"child_process";import{promisify as $S}from"util";import{satisfies as MS}from"semver";var DS=$S(LS);async function zs(r,e,t){let s=r.map(o=>BS(o,t)).filter(o=>!jS(o,e));if(s.length===0)return;await Gs.mkdir(e,{recursive:!0});let i=Ys.join(e,"package.json");ap(i)||await Gs.writeFile(i,JSON.stringify({name:"typebulb-server",private:!0})),console.log(` Installing: ${s.join(", ")}`),await DS("npm",["install","--no-audit","--no-fund",...s],{cwd:e,shell:!0})}function BS(r,e){if(!e||N.parse(r).version)return r;let t=e[r];return t?`${r}@${t}`:r}function jS(r,e){let{name:t,version:n}=N.parse(r),s=Ys.join(e,"node_modules",t);if(!ap(s))return!1;if(!n)return!0;try{let i=JSON.parse(IS(Ys.join(s,"package.json"),"utf-8")).version;return MS(i,n)}catch{return!1}}function Qs(r){let e=new Set,t=/\bimport\s+(?:[\s\S]*?\s+from\s+)?['"]([^./][^'"]*)['"]/g,n;for(;n=t.exec(r);){let s=n[1];s.includes(":")||e.add(N.rootOf(s))}return[...e]}er();oi();nr();async function hp(r){let e=wt(r.provider,r.model);if(typeof e=="string")throw new Error(e);let t=await vt(e,r);if(!t.ok){let n=await ln(t,e.protocol);throw new Error(n.message)}return{response:t,protocol:e.protocol}}async function VS(r){let{response:e,protocol:t}=await hp(r);return{text:await bt(e,t)}}async function*YS(r){let{response:e,protocol:t}=await hp(r);yield*Zt(e,t)}function gp(){let r=Object.assign(VS,{stream:YS});globalThis.tb=Object.freeze({ai:r,models:()=>Ne(),hasOwnKeys:ii,mode:"local"})}async function yp(r){let t=(await et.readdir(r)).find(n=>n.endsWith(".bulb.md"));return t?ai.join(r,t):null}async function he(r){let e=await et.readFile(r,"utf-8"),t=Ae(e);if(!t)throw new Error("Invalid .bulb.md file format");let n=Ht(t);return{bulb:n,config:Rl(n.config),warnings:El(e)}}async function un(r,e,t,n){let s=ja(r,{serverOnly:!0});if(s.error)throw new Error(`Server compilation error: ${s.error}`);let i=s.code;t&&(i=await gl(i,t));let o=ai.join(e,".typebulb");await et.mkdir(o,{recursive:!0});let a=Qs(i);a.length>0&&await zs(a,o,n);let c=ai.join(o,"server.mjs");return await et.writeFile(c,i,"utf-8"),gp(),await import(`${GS(c).href}?t=${Date.now()}`)}async function cc(r,e,t,n,s){let{bulb:i,config:o}=await he(r),a=Rd(i.data);Id(i.code,o.dependencies??{});let c=ja(i.code,{jsxImportSource:o.ts?.jsxImportSource});c.error&&console.error("Compilation error:",c.error);let{importMap:l}=await Ks.buildImportMap(c.code,o.dependencies??{},n?new Set([n.name]):void 0);n&&(l.imports[n.name]=n.entryUrl);let f=op({name:i.name,code:c.code,css:i.css,html:i.html,data:a,insight:i.insight,importMap:l,watch:e}),u=null;return i.server&&t&&(u=await un(i.server,s,n,o.dependencies)),{html:f,bulb:i,serverExports:u}}Xr();fn();var vp=new Set(["claude","pi"]);function Sp(r){return vp.has(r)}function ir(){return[...vp]}import*as tt from"path";import{spawn as bk,execSync as wk}from"child_process";import{createRequire as vk}from"module";import{existsSync as Sk}from"fs";import*as ee from"fs/promises";import*as X from"path";import*as or from"path";var sk=or.join(Fs,"pkg"),ik=or.join(Fs,"files"),ok=or.join(Fs,"negative.json"),fi=class{pkgMem=new Map;fileMem=new Map;negativeCache=new gt(new Gt(ok));async getCachedDts(e){if(this.pkgMem.has(e))return this.pkgMem.get(e);await q();let t=await _e(kp(e));return this.pkgMem.set(e,t),t}async setCachedDts(e,t,n){let s={content:t,url:n};this.pkgMem.set(e,s),await ui(async()=>{await q(),await oe(kp(e),JSON.stringify(s))})}async getCachedFile(e){if(this.fileMem.has(e))return this.fileMem.get(e);await q();let t=await js(xp(e));return this.fileMem.set(e,t),t}async setCachedFile(e,t){this.fileMem.set(e,t),await ui(async()=>{await q(),await oe(xp(e),t)})}isNegative(e){return this.negativeCache.isNegative(e)}async recordNegative(e){await ui(async()=>{await q(),await this.negativeCache.recordNegative(e)})}clearNegative(e){return ui(()=>this.negativeCache.clearNegative(e))}};async function ui(r){try{await r()}catch{}}function kp(r){return or.join(sk,fe(r)+".json")}function xp(r){return or.join(ik,fe(r)+".txt")}var dc;function ak(){return dc||(dc=new on({cache:new fi,cdnClient:sp,packageService:Ks,versionResolver:np})),dc}var Ep="file:///node_modules/";async function Ap(r){let e=qs(r.emitKey,"typecheck");await q(),await ee.rm(e,{recursive:!0,force:!0}),await ee.mkdir(e,{recursive:!0});let t=fk(r.jsxImportSource,r.dependencies),n=await ak().resolve(r.code,r.dependencies,t),s=r.local?.name,i=s?n.filter(f=>f.pkg!==s):n,o=new Set;for(let f of i)for(let u of f.files){let d=di(u.path);if(!d||o.has(d))continue;o.add(d);let p=X.join(e,"node_modules",d);await ee.mkdir(X.dirname(p),{recursive:!0}),await ee.writeFile(p,u.content,"utf8")}let a={};for(let f of i)for(let u of f.shims){let d=di(u.path);d&&(a[u.module]=[`./node_modules/${d}`])}for(let f of i){if(f.ambient)continue;let u=di(f.mainPath);u&&(a[f.pkg]=[`./node_modules/${u}`])}let c=new Set;for(let f of i)for(let u of f.files){if(!u.ambient)continue;let d=di(u.path);d&&c.add(`node_modules/${d}`)}if(r.local){delete a[r.local.name];let f=await dk(r.local,e);f?a[r.local.name]=[`./node_modules/${r.local.name}/${f}`]:console.warn(` local: '${r.local.name}' ships no type defs; check cannot type against it.`)}let l=ck(r.jsxImportSource,a,[...c]);return await ee.writeFile(X.join(e,"tsconfig.json"),JSON.stringify(l,null,2)+`
|
|
1342
1342
|
`,"utf8"),await ee.writeFile(X.join(e,"code.tsx"),r.code,"utf8"),await ee.writeFile(X.join(e,"tb.d.ts"),Ha,"utf8"),{dir:e}}var pc={target:"es2023",module:"esnext",moduleResolution:"bundler",strict:!0,noEmit:!0,skipLibCheck:!0,esModuleInterop:!0,allowSyntheticDefaultImports:!0,forceConsistentCasingInFileNames:!0};function ck(r,e,t=[]){return{compilerOptions:{...pc,lib:lk([...Ja,...Ka]),jsx:"react-jsx",jsxImportSource:r??"react",paths:e},include:["code.tsx","tb.d.ts",...t]}}function lk(r){return Wa(r).map(e=>uk(e.name))}function uk(r){return r.split(".").map(e=>/^es\d+$/i.test(e)?e.toUpperCase():e==="dom"?"DOM":e==="esnext"?"ESNext":e.charAt(0).toUpperCase()+e.slice(1)).join(".")}function fk(r,e){let t=r??("react"in e?"react":void 0);return t?[`${t}/jsx-runtime`,`${t}/jsx-dev-runtime`]:[]}function di(r){if(!r.startsWith(Ep))return;let e=r.slice(Ep.length),t=e.indexOf("/");if(!(t<0))return e.slice(t+1)}async function dk(r,e){if(!r.typesAbs)return;let t=X.dirname(r.typesAbs),n=X.join(e,"node_modules",r.name);for(let s of await pk(t)){let i=X.join(n,X.relative(t,s));await ee.mkdir(X.dirname(i),{recursive:!0}),await ee.copyFile(s,i)}return X.basename(r.typesAbs)}async function pk(r){let e=[];async function t(n){let s=await ee.readdir(n,{withFileTypes:!0});for(let i of s){let o=X.join(n,i.name);i.isDirectory()?await t(o):/\.d\.ts(\.map)?$/.test(i.name)&&e.push(o)}}return await t(r),e}import*as ae from"fs/promises";import*as Le from"path";import{existsSync as mk}from"fs";var hk="^22";async function Tp(r){let e=qs(r.emitKey,"typecheck-server");await q(),await ae.rm(e,{recursive:!0,force:!0}),await ae.mkdir(e,{recursive:!0});let t=Le.join(r.bulbDir,".typebulb"),n=Qs(r.server).filter(o=>o!==r.local?.name);await zs([`@types/node@${hk}`,...n],t,r.dependencies);let s=Le.join(t,"node_modules"),i=Le.join(e,"node_modules");return await yk(s,i),await ae.writeFile(Le.join(e,"server.ts"),r.server,"utf8"),await ae.writeFile(Le.join(e,"tb.d.ts"),Va,"utf8"),await ae.writeFile(Le.join(e,"tsconfig.json"),JSON.stringify(gk(r.local),null,2)+`
|
|
1343
1343
|
`,"utf8"),{dir:e}}function gk(r){let e={...pc,lib:["ES2023"],types:["node"]};if(r?.typesAbs){let t=i=>i.replace(/\\/g,"/"),n=t(Le.dirname(r.typesAbs)),s=t(r.typesAbs).replace(/\.d\.ts$/,"");e.paths={[r.name]:[s],[`${r.name}/*`]:[`${n}/*`]}}return{compilerOptions:e,include:["server.ts","tb.d.ts"]}}async function yk(r,e){if(!mk(r)){await ae.mkdir(e,{recursive:!0});return}await ae.rm(e,{recursive:!0,force:!0});let t=process.platform==="win32"?"junction":"dir";await ae.symlink(r,e,t)}Os();async function Op(r,e){let{bulb:t,config:n,warnings:s}=await he(r);!t.code&&!t.server&&(console.error("Bulb has neither **code.tsx** nor **server.ts**; nothing to check."),process.exit(1));let i=!1;for(let l of s)console.log(`structure ${l}`);s.length&&(i=!0),t.code&&(i=Pp(Zr(t.code,{target:"client",dependencies:n.dependencies??{}}),"client")||i),t.server&&(i=Pp(Zr(t.server,{target:"server"}),"server")||i);let o=Ek([process.cwd(),tt.dirname(r)]);if(!o){let l=tt.relative(process.cwd(),r)||r;console.error("check: TypeScript not found \u2014 install it once, then re-run:"),console.error(" npm i -g typescript"),console.error(` typebulb check ${l}`),process.exit(2)}let a=[];if(t.code){let{dir:l}=await Ap({code:t.code,dependencies:n.dependencies??{},jsxImportSource:n.ts?.jsxImportSource,emitKey:r,local:e});a.push({role:"client",dir:l})}if(t.server){let{dir:l}=await Tp({server:t.server,bulbDir:tt.dirname(r),emitKey:r,local:e?{name:e.name,typesAbs:e.typesAbs}:void 0,dependencies:n.dependencies});a.push({role:"server",dir:l})}for(let{role:l,dir:f}of a){let{stdout:u,exitCode:d}=await kk(o,f);for(let p of u.split(/\r?\n/))p.trim()&&console.log(`${l} ${p}`);d!==0&&(i=!0)}i&&process.exit(1);let c=[t.code&&"code.tsx",t.server&&"server.ts"].filter(Boolean).join(", ");console.error(`\u2713 no issues (${c})`)}function Pp(r,e){for(let t of r)for(let n of t.message.split(`
|
|
1344
|
-
`))console.log(`${e} ${n}`);return r.length>0}function kk(r,e){return new Promise(t=>{let n=bk(process.execPath,[r,"--noEmit"],{cwd:e}),s="";n.stdout?.on("data",i=>{s+=i.toString()}),n.stderr?.on("data",i=>{s+=i.toString()}),n.on("close",i=>t({stdout:s,exitCode:i??1}))})}var xk=vk(import.meta.url);function Ek(r){let e=n=>{try{let s=xk.resolve("typescript/package.json",{paths:n}),i=tt.join(tt.dirname(s),"lib","tsc.js");return Sk(i)?i:void 0}catch{return}},t=e(r);if(t)return t;try{let n=wk("npm root -g",{encoding:"utf8"}).trim();return e([n])}catch{return}}pi();fn();async function Rp(r,e){let{bulb:t}=await he(r),n=ar(t);if(St(r)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),n&&console.log(` (it uses ${n})`);return}n?(console.log(`This bulb appears to use ${n}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}fn();import*as dn from"path";async function _p(r,e){if(!r){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let n=fc();if(!n.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of n)console.log(` ${s}`);return}let t=dn.resolve(r);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),sr(t,e),console.log(e?`Trusted ${dn.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${dn.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}$e();import*as km from"readline";xi();$c();var yn={claude:()=>new ur,pi:()=>new pr};function wm(){for(let r of Object.values(yn))try{r().ensureHarnessSupport()}catch{}}function bn(){for(let r of Object.keys(yn))try{if(yn[r]().detectsSelf())return r}catch{}}function vm(r){let e=ir(),t=new Map(e.filter(i=>yn[i]).map(i=>[i,yn[i]()]));for(let[i,o]of t)if(o.detectsSelf())return{name:i};let n=[...t].filter(([,i])=>i.
|
|
1344
|
+
`))console.log(`${e} ${n}`);return r.length>0}function kk(r,e){return new Promise(t=>{let n=bk(process.execPath,[r,"--noEmit"],{cwd:e}),s="";n.stdout?.on("data",i=>{s+=i.toString()}),n.stderr?.on("data",i=>{s+=i.toString()}),n.on("close",i=>t({stdout:s,exitCode:i??1}))})}var xk=vk(import.meta.url);function Ek(r){let e=n=>{try{let s=xk.resolve("typescript/package.json",{paths:n}),i=tt.join(tt.dirname(s),"lib","tsc.js");return Sk(i)?i:void 0}catch{return}},t=e(r);if(t)return t;try{let n=wk("npm root -g",{encoding:"utf8"}).trim();return e([n])}catch{return}}pi();fn();async function Rp(r,e){let{bulb:t}=await he(r),n=ar(t);if(St(r)){console.log("remembered-trusted \u2014 runs with filesystem / AI / server.ts automatically (`typebulb untrust` to revoke)."),n&&console.log(` (it uses ${n})`);return}n?(console.log(`This bulb appears to use ${n}; it runs Restricted unless you grant trust:`),console.log(` ${e}`)):console.log("No privileged capability detected \u2014 runs Restricted by default. (A clean scan is a hint, not a guarantee.)")}fn();import*as dn from"path";async function _p(r,e){if(!r){e||(console.error("Usage: typebulb untrust <file.bulb.md>"),process.exit(1));let n=fc();if(!n.length){console.log("No bulbs are remembered as trusted.");return}console.log("Trusted bulbs (run with fs/AI/server.ts without --trust):");for(let s of n)console.log(` ${s}`);return}let t=dn.resolve(r);t.endsWith(".bulb.md")||(console.error("File must have .bulb.md extension"),process.exit(1)),sr(t,e),console.log(e?`Trusted ${dn.basename(t)} \u2014 runs with fs / AI / server.ts (no --trust needed).`:`Untrusted ${dn.basename(t)} \u2014 runs Restricted.`),console.log(` ${t}`)}$e();import*as km from"readline";xi();$c();var yn={claude:()=>new ur,pi:()=>new pr};function wm(){for(let r of Object.values(yn))try{r().ensureHarnessSupport()}catch{}}function bn(){for(let r of Object.keys(yn))try{if(yn[r]().detectsSelf())return r}catch{}}function vm(r){let e=ir(),t=new Map(e.filter(i=>yn[i]).map(i=>[i,yn[i]()]));for(let[i,o]of t)if(o.detectsSelf())return{name:i};let n=[...t].filter(([,i])=>i.detectsInstalled()).map(([i])=>i);if(n.length===0)return{name:e[0]};if(n.length===1)return{name:n[0]};let s=i=>t.get(i).listSessionFiles(r).length>0;return{ambiguous:[...n].sort((i,o)=>Number(s(o))-Number(s(i)))}}Ti();function Mc(r){let e=t=>n=>r?`\x1B[${t}m${n}\x1B[0m`:n;return{lit:e("38;5;70"),litLink:e("4;38;5;70"),brand:e("38;5;135")}}async function xm(r){let e=vm(process.cwd());if("ambiguous"in e){let t=await Qx(r,e.ambiguous);return t?Sm(r,t):Xx(r,e.ambiguous)}return Sm(r,e.name)}async function Sm(r,e){let t,n;try{t=await Up(e)}catch(f){n=f instanceof Error?f.message:String(f)}let{lit:s,litLink:i,brand:o}=Mc(process.stdout.isTTY===!0),a=[" Read the authoring skill before writing a bulb:",` \u2022 ${s("npx typebulb skill")} \u2014 assembles one SKILL.md`," \u2022 or, open its parts:",` ${s(fr())}`,` ${s(At())}`],c=t?[" Agent mirror is live\u{1F4A1}",` ${s("\u25CF")} ${i(t.url)}`," Embedded bulbs render live here."," Agents:",` Reusable app/tool \u2192 write a ${s(".bulb.md")}`," Show something inline \u2192 embed a bulb"," background a wait for its render verdict:",` \u2022 ${s('typebulb wait agent --match "[embed <name>"')}`,...a," End your reply with the mirror link above"," \u2022 easy to miss the link mid-message"]:[` The mirror did not start (${n})`,` \u25CF Start it manually: ${s(`npx typebulb agent:${e}`)}`," Agents:",...a],l=[` ${o(`typebulb v${r}`)}`,...c,""];process.stdout.write(l.join(`
|
|
1345
1345
|
`)+`
|
|
1346
1346
|
`)}async function Qx(r,e){if(!process.stdin.isTTY||!process.stdout.isTTY)return;let{lit:t,brand:n}=Mc(!0),s=[` ${n(`typebulb v${r}`)}`," More than one agent harness is available here.",...e.map((o,a)=>` ${t(String(a+1))}) ${o}`),""];process.stdout.write(s.join(`
|
|
1347
1347
|
`)+`
|
|
@@ -1432,5 +1432,5 @@ Shutting down...`);try{a.shutdownSwitcher?.()}catch{}try{a.shutdownComposer?.()}
|
|
|
1432
1432
|
`),Ot({target:r,onChange:async()=>{try{console.log("Re-running..."),await a()}catch(c){console.error("Error:",c)}}}))}import{Console as ZE}from"node:console";$e();async function Lh(r,e,t,n,s){sA();try{let p=cr(await K(),r)[0];p&&(hi(p.pid,ve(p.pid).offset),console.error(`note: 'call' boots a fresh server.ts instance; the running server (${p.url}) is not contacted \u2014 state shared with it must live on disk.`))}catch{}let i=xe(t),{bulb:o,config:a}=await he(r);o.server||Tn("This bulb has no **server.ts** block; nothing to call."),nt(i,r,o.server);let c;try{c=await un(o.server,s,n,a.dependencies)}catch(p){Tn(p instanceof Error?p.message:String(p))}let l=Ci(c,e.fn);if(!l){let p=[...Object.keys(c).filter(b=>typeof c[b]=="function"),...Object.keys(Uc)];Tn(`Function '${e.fn}' not found. Available: ${p.length?p.join(", "):"(none)"}.`)}let f=await eA(e);if(Ni(l)){try{for await(let p of l(...f))await Ih(JSON.stringify(p,$h)+`
|
|
1433
1433
|
`)}catch(p){Tn(p instanceof Error?p.stack??p.message:String(p))}return Nh(0)}let u;try{u=await l(...f)}catch(p){Tn(p instanceof Error?p.stack??p.message:String(p))}let d=nA(u);d!==void 0&&await Ih(d+`
|
|
1434
1434
|
`),Nh(0)}function Nh(r){process.exitCode=r,setTimeout(()=>process.exit(r),2e3).unref?.()}async function eA(r){if(r.hasArgsFlag){let e=r.argsJson??"";return e==="-"&&(e=await iA()),rA(e)}return tA(r.positional)}function tA(r){return r.map(e=>{try{return JSON.parse(e)}catch{return e}})}function rA(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 nA(r){if(r!==void 0)return JSON.stringify(r,$h,2)}function $h(r,e){return typeof e=="bigint"?e.toString():e}function Tn(r){process.stderr.write(r+`
|
|
1435
|
-
`),process.exit(1)}function sA(){let r=new ZE(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 Ih(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function iA(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var sl="0.23.
|
|
1435
|
+
`),process.exit(1)}function sA(){let r=new ZE(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 Ih(r){return new Promise((e,t)=>{process.stdout.write(r,n=>n?t(n):e())})}async function iA(){let r=[];for await(let e of process.stdin)r.push(e);return Buffer.concat(r).toString("utf-8")}var sl="0.23.1";function Mh(r,e){r||(console.error(`This bulb runs server-side Node code (server.ts), which --trust must authorize:
|
|
1436
1436
|
${e}`),process.exit(1))}async function oA(){let r=yl(process.argv.slice(2));if(r.version&&(console.log(`typebulb ${sl}`),process.exit(0)),r.help&&(bl(),process.exit(0)),wm(),r.subcommand==="logs"){await Rm(r.file||void 0,{follow:r.follow,clear:r.clear,run:r.run,lines:r.lines});return}if(r.subcommand==="wait"){await _m(r.file||void 0,{match:r.match,timeoutSec:r.timeoutSec});return}if(r.subcommand==="stop"){r.stopScope?await Nm(r.stopScope):await Cm(r.file||void 0);return}if(r.subcommand==="send"){await Lm(r.file,r.sendMessage,r.sendWaitMs??0);return}if(r.subcommand==="skill"){await Tm(sl);return}if(r.subcommand==="models"){await Em(r.mode);return}if(r.subcommand==="agent"){await(r.agentTarget?Rh(r):xm(sl));return}if(r.subcommand==="trust"||r.subcommand==="untrust"){await _p(r.file||void 0,r.subcommand==="trust");return}let e;if(!r.file||r.file==="."){let l=await yp(process.cwd());l||(console.error("No .bulb.md file found in current directory"),process.exit(1)),e=l}else e=Be.resolve(r.file);await Dh.access(e).then(()=>!0,()=>!1)||(ir().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:Be.relative(process.cwd(),e)||Be.basename(e),s=`npx typebulb --trust ${n.includes(" ")?`"${n}"`:n}`;if(r.subcommand==="predict"){await Rp(e,s);return}let i=!r.noTrust&&St(e);i&&!r.trust&&console.log("trust: granted from memory (run `typebulb untrust` to revoke)"),r.trust=r.noTrust?!1:r.trust||i;let o;try{o=await he(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(l){console.error(l instanceof Error?l.message:String(l)),process.exit(1)}console.log(`replace: ${a.name} \u2192 ${Be.relative(process.cwd(),a.dir)||"."}`)}if(r.subcommand==="check"){await Op(e,a);return}let c=Be.dirname(e);if(r.subcommand==="call"){Mh(r.trust,s),await Lh(e,{fn:r.fn,positional:r.callArgs,argsJson:r.argsJson,hasArgsFlag:r.hasArgsFlag},r.mode,a,c);return}if(o&&o.bulb.server&&(Ps(o.bulb)||r.server)){Mh(r.trust,s),await Ch(e,r.watch,r.mode,a,c);return}await Fm(e,r,s,a,c)}oA().catch(r=>{console.error("Error:",r.message),process.exit(1)});
|
package/package.json
CHANGED