typebulb 0.27.0 → 0.27.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/README.md +3 -3
- package/dist/agents/pi/matchu-patchu.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ A `.bulb.md` file bundles code, styles, data, and config in one file.
|
|
|
20
20
|
- **Env files** — `.env` / `.env.local` load from cwd, `.env.local` overriding `.env` (an exported shell var wins over both). `--mode <name>` adds `.env.<name>` to switch environments (local/staging/prod); a startup line reports which keys loaded from where.
|
|
21
21
|
- **Server mode** — `--server` runs only the `**server.ts**` section in Node, skipping the web server. Bulbs with only `**server.ts**` (no `**code.tsx**`) use this mode automatically.
|
|
22
22
|
- **Type-check without running** — `typebulb check <file>` runs `tsc --noEmit` against the bulb: non-zero exit with diagnostics on errors, a one-line all-clear on stderr on success.
|
|
23
|
-
- **Filesystem access** — `tb.fs.read()` (UTF-8 text), `tb.fs.readBytes()` (raw `Uint8Array`), and `tb.fs.write()` (text or bytes)
|
|
23
|
+
- **Filesystem access** — `tb.fs.read()` (UTF-8 text), `tb.fs.readBytes()` (raw `Uint8Array`), and `tb.fs.write()` (text or bytes); relative paths land in the bulb's own data folder. Requires `--trust`.
|
|
24
24
|
- **Hot reload** — Recompiles on save and refreshes the browser (on by default; disable with `--no-watch`)
|
|
25
25
|
- **Package resolution** — Client dependencies are automatically resolved by generating import maps (same resolver as typebulb.com). Server dependencies are automatically installed via npm.
|
|
26
26
|
- **Replace dependency** — `--replace <name>=<path>` replaces a declared dependency with a local *built* package folder (browser-ready ESM, no external bare imports) instead of a CDN, for testing an unpublished build. Supplies both runtime bytes and types; applies to `run` and `check`. Under `--watch` the folder is watched and the browser reloads on rebuild (`--no-watch` freezes it). Dev-only; nothing is written to the bulb.
|
|
@@ -184,7 +184,7 @@ everywhere.
|
|
|
184
184
|
| `tb.hasOwnKeys()` | Whether the user's own AI keys back `tb.ai` — `false` means courtesy model only; always `false` embedded | |
|
|
185
185
|
| `tb.onMessage(cb)` | Receive a value pushed in from the terminal by `typebulb send` — inert when embedded (no sender) | |
|
|
186
186
|
| `tb.fs.read/readBytes/write` | Read and write local files | yes |
|
|
187
|
-
| `tb.dir` | The bulb's data folder (absolute path)
|
|
187
|
+
| `tb.dir` | The bulb's data folder (absolute path), where relative `tb.fs` paths land | |
|
|
188
188
|
| `tb.server.<name>(...)` | Call a function exported from the `server.ts` block | yes |
|
|
189
189
|
| `tb.ai({ messages, … })` | General-purpose AI call (chat, agents) | yes |
|
|
190
190
|
| `tb.ai.stream({ … })` | Streaming AI — `for await` an `AsyncIterable<{ kind, text }>` of deltas | yes |
|
|
@@ -274,7 +274,7 @@ The host owns a bulb's **width**; you own its **height**.
|
|
|
274
274
|
|
|
275
275
|
- **`config.json` `description`** is the bulb's search-result blurb — what makes someone open it, kept short (it truncates past ~160 chars).
|
|
276
276
|
- **The frontmatter `name:` is the bulb's title** — a few words, not a sentence — and the filename should be its slug (`name: Counter` → `counter.bulb.md`), saved in the project's **`typebulbs/`** folder.
|
|
277
|
-
- **A bulb's working files
|
|
277
|
+
- **A bulb's working files land beside it automatically** — relative `tb.fs` paths resolve to the bulb's data folder: `tb.fs.write('run.json')`, no path prefix.
|
|
278
278
|
- **Self-testing a local bulb** — To confirm a bulb works, run it, instrument with `tb.server.log(...)` (prints to the server's stdout, captured in the log — and works **even on a Restricted bulb**), and read it back with `typebulb logs`. That's the loop to verify behaviour without asking the user to copy-paste console output. `tb.fs.write(...)` is handy for dumping large outputs.
|
|
279
279
|
- **Self-testing client code** — to drive the *browser* side, gate the work behind `tb.onMessage(m => { if (m === 'selftest') run() })`, trigger it with `typebulb send <file> selftest --wait`, and read `run()`'s `tb.server.log(...)` back the same way. The client-side counterpart to instrumenting `server.ts`.
|
|
280
280
|
- **Testing a `server.ts` export directly** — `typebulb call <file> <fn> [arg…]` boots `server.ts`, invokes one export, and prints its return as JSON to stdout (logs/errors to stderr, so `… | jq` works). Args after `<fn>` are JSON-or-string; `--args '<json-array>'` (or `--args -` for stdin) escapes tricky quoting. Needs `--trust`.
|
|
@@ -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:
|
|
2220
|
+
var BUILD_TAG = true ? "matchu-patchu-pi 0.2.0, built 2026-07-15 16:35:40" : "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
|
@@ -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.
|
|
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.1";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