typebulb 0.37.2 → 0.38.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 +10 -9
- package/dist/agents/claude/client.js +49 -49
- package/dist/agents/claude/styles.css +19 -4
- package/dist/agents/pi/client.js +50 -50
- package/dist/agents/pi/matchu-patchu.ts +1 -1
- package/dist/agents/pi/styles.css +19 -4
- package/dist/ai/providers/anthropic.d.ts +7 -2
- package/dist/ai/providers/anthropic.d.ts.map +1 -1
- package/dist/ai/providers/anthropic.js +11 -6
- package/dist/ai/providers/anthropic.js.map +1 -1
- package/dist/dts/tbTypings.d.ts +2 -2
- package/dist/dts/tbTypings.d.ts.map +1 -1
- package/dist/dts/tbTypings.js +1 -1
- package/dist/index.js +211 -219
- package/dist/servers.js +87 -87
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# typebulb
|
|
2
2
|
|
|
3
|
-
**Typebulb** runs apps in markdown files called **bulbs**.
|
|
3
|
+
**Typebulb** runs apps in markdown files called **bulbs**. Perfect for tools, visualizations & experiments. A bulb is a single self-contained file, so an agent can embed a working app right in its reply, and the same file can be published as a stand-alone web app. The *"markdown with code blocks"* format is one LLMs find natural to write.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* `npx typebulb agent`. When you want to view agent conversations with embedded bulbs in the agent messages, also providing a finder/launcher for your local bulbs. Supports Claude Code and Pi agent harnesses; tell your agent to run it.
|
|
7
|
-
* **[typebulb.com](https://typebulb.com)**. When you want to share tools, visualizations, experiments etc. See [FAQ](https://typebulb.com/faq).
|
|
5
|
+
Two ways to create and run bulbs:
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
* **typebulb CLI**: Lets a coding agent (Claude Code or Pi) build and run bulbs locally. Local bulbs can also call Node.js via a secure bridge.
|
|
8
|
+
* **typebulb.com**: Share and publish bulbs. Also the quickest way to test AI models (BYOK) with zero setup. See [FAQ](https://typebulb.com/faq).
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
One API runs everywhere: the same bulb works locally and in typebulb.com's sandbox, and can call AI models at runtime.
|
|
11
|
+
|
|
12
|
+
This document is dedicated to the typebulb CLI. At its core, it compiles and serves hot-reloadable bulbs locally. A `.bulb.md` file bundles code, styles, data, and config in one file.
|
|
12
13
|
|
|
13
14
|
>This document doubles as a skill: it is written so an LLM agent can read it and successfully write and run bulbs with the typebulb CLI.
|
|
14
15
|
|
|
@@ -20,7 +21,7 @@ A `.bulb.md` file bundles code, styles, data, and config in one file.
|
|
|
20
21
|
- **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
22
|
- **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
23
|
- **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); relative paths land in the bulb's own folder (`--
|
|
24
|
+
- **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 folder (`--batch <name>` scopes a run to `batches/<name>` inside it). Requires `--trust`.
|
|
24
25
|
- **Hot reload** — Recompiles on save and refreshes the browser (on by default; disable with `--no-watch`)
|
|
25
26
|
- **Package resolution** — Client dependencies are automatically resolved by generating import maps (same resolver as typebulb.com). Server dependencies are automatically installed via npm.
|
|
26
27
|
- **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.
|
|
@@ -61,7 +62,7 @@ typebulb --no-watch <file> Disable hot reload
|
|
|
61
62
|
typebulb --port 3333 <file> Custom port
|
|
62
63
|
typebulb --no-open <file> Don't auto-open browser
|
|
63
64
|
typebulb --mode <name> <file> Also load .env.<name> on top of .env / .env.local
|
|
64
|
-
typebulb --
|
|
65
|
+
typebulb --batch <name> <file> Scope tb.dir + relative tb.fs paths to <bulb-folder>/batches/<name> (batch runs)
|
|
65
66
|
typebulb --trust <file> Grant filesystem + AI + server.ts for this run (default: Restricted)
|
|
66
67
|
typebulb --no-trust <file> Force Restricted even if the bulb is remembered-trusted
|
|
67
68
|
typebulb --server <file> Run server.ts only, no web server (needs --trust)
|
|
@@ -286,7 +287,7 @@ The host owns a bulb's **width**; you own its **height**.
|
|
|
286
287
|
- **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.
|
|
287
288
|
- **A bulb's working files land beside it automatically** — relative `tb.fs` paths resolve to the bulb's folder, in `code.tsx` and `server.ts` alike: `tb.fs.write('run.json')`, no path prefix, no mkdir.
|
|
288
289
|
- **Images & media: an `assets/` subfolder of the bulb's folder** (`birds.bulb.md` → `birds/assets/robin.png`) — `<img src="assets/robin.png">` just works (always that relative form, never `/assets/…`), every tier except embedded.
|
|
289
|
-
- **Batch runs: scope with `--
|
|
290
|
+
- **Batch runs: scope with `--batch`, don't hand-roll plumbing** — `--batch pilot` on a run or `call` lands `tb.dir` and relative `tb.fs` paths in `<bulb-folder>/batches/pilot/`; the bulb's code stays batch-unaware, an unscoped run sees `batches/` as an ordinary subfolder, and the agent mirror lists a bulb's batches on its launcher row (play opens the newest).
|
|
290
291
|
- **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.
|
|
291
292
|
- **Self-testing client code** — gate checks behind `tb.onMessage(m => { if (m === 'selftest') return run() })`, trigger with `typebulb send <file> selftest --wait`, and assert on the JSON reply — see [Interrogating the live page](#interrogating-the-live-page).
|
|
292
293
|
- **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`.
|