typebulb 0.4.0 → 0.4.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 +58 -15
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
# typebulb
|
|
2
2
|
|
|
3
|
-
Run single-file
|
|
3
|
+
Run single-file apps from markdown. A `.bulb.md` file bundles code, styles, data, and config in one file. `typebulb` compiles and serves it locally with hot reload.
|
|
4
4
|
|
|
5
|
-
Create bulbs on [typebulb.com](https://typebulb.com) and export, or generate `.bulb.md` files with any AI coding tool.
|
|
5
|
+
Create bulbs on [typebulb.com](https://typebulb.com) and export, or generate `.bulb.md` files with any AI coding tool. See the [FAQ](https://typebulb.com/faq) for the bulb format and `tb.*` API reference.
|
|
6
6
|
|
|
7
7
|
## Quick Start
|
|
8
8
|
|
|
9
|
+
A bulb is a markdown file with named code blocks:
|
|
10
|
+
|
|
11
|
+
````markdown
|
|
12
|
+
---
|
|
13
|
+
format: typebulb/v1
|
|
14
|
+
name: My App
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
**code.tsx**
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
document.getElementById("root")!.textContent = "Hello from a bulb!";
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**index.html**
|
|
24
|
+
|
|
25
|
+
```html
|
|
26
|
+
<div id="root"></div>
|
|
9
27
|
```
|
|
10
|
-
|
|
28
|
+
````
|
|
29
|
+
|
|
30
|
+
Run it:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
npx typebulb my-app.bulb.md
|
|
11
34
|
```
|
|
12
35
|
|
|
13
36
|
Or install globally:
|
|
@@ -31,34 +54,54 @@ typebulb --version Show version
|
|
|
31
54
|
|
|
32
55
|
## Features
|
|
33
56
|
|
|
34
|
-
- **Hot reload** — Recompiles on save and refreshes the browser (on by default; disable with `--no-watch`)
|
|
35
|
-
- **Filesystem access** — `tb.fs.read()` and `tb.fs.write()` for local files
|
|
36
|
-
- **Env files** — `.env` and `.env.local` auto-loaded from cwd
|
|
37
|
-
- **AI calls** — `tb.ai()` for general-purpose AI (chatbots, agents, experiments). Set API keys in `.env` (see below).
|
|
38
57
|
- **Server-side code** — Add a `**server.ts**` section; exported functions become callable from the browser via `tb.server.<name>()` (e.g., `export async function query(...)` → `await tb.server.query(...)`)
|
|
39
58
|
- **CLI logging** — `tb.server.log(...)` prints to the CLI's stdout
|
|
59
|
+
- **Env files** — `.env` and `.env.local` auto-loaded from cwd
|
|
40
60
|
- **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.
|
|
61
|
+
- **Filesystem access** — `tb.fs.read()` and `tb.fs.write()` for local files
|
|
62
|
+
- **Hot reload** — Recompiles on save and refreshes the browser (on by default; disable with `--no-watch`)
|
|
41
63
|
- **Package resolution** — Client dependencies are automatically resolved by generating import maps (same resolver as typebulb.com). Server dependencies are automatically installed via npm.
|
|
64
|
+
- **AI calls** — `tb.ai()` for general-purpose AI (chatbots, agents, experiments). `tb.models()` lists available models. Set API keys in `.env` (see below).
|
|
42
65
|
|
|
43
66
|
## AI Setup
|
|
44
67
|
|
|
45
68
|
Bulbs can call AI providers via `tb.ai()`. Add API keys to your `.env` file:
|
|
46
69
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
| Provider name | API key env var |
|
|
71
|
+
|---------------|-----------------|
|
|
72
|
+
| `anthropic` | `ANTHROPIC_API_KEY` |
|
|
73
|
+
| `openai` | `OPENAI_API_KEY` |
|
|
74
|
+
| `gemini` | `GOOGLE_API_KEY` |
|
|
75
|
+
| `openrouter` | `OPENROUTER_API_KEY` |
|
|
53
76
|
|
|
54
|
-
Set your provider and model:
|
|
77
|
+
Set your default provider and model:
|
|
55
78
|
|
|
56
79
|
```
|
|
57
80
|
TB_AI_PROVIDER=anthropic
|
|
58
81
|
TB_AI_MODEL=claude-haiku-4-5-20251001
|
|
59
82
|
```
|
|
60
83
|
|
|
61
|
-
Both
|
|
84
|
+
Both can be overridden per-call: `tb.ai({ provider: "gemini", model: "gemini-2.5-flash", ... })`.
|
|
85
|
+
|
|
86
|
+
### Reasoning
|
|
87
|
+
|
|
88
|
+
`tb.ai()` accepts an optional `reasoning` parameter (0–3) that hints at how much extended thinking the model should use:
|
|
89
|
+
|
|
90
|
+
| Level | Label | Effect |
|
|
91
|
+
|-------|-------|--------|
|
|
92
|
+
| 0 | Min | No extended reasoning (default) |
|
|
93
|
+
| 1 | Low | Light reasoning |
|
|
94
|
+
| 2 | Med | Moderate reasoning |
|
|
95
|
+
| 3 | Max | Maximum reasoning |
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
const { text } = await tb.ai({
|
|
99
|
+
messages: [{ role: "user", content: "Explain quantum tunneling" }],
|
|
100
|
+
reasoning: 2,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Provider support varies — the level is mapped to provider-specific parameters (e.g. Anthropic's adaptive thinking, OpenAI's reasoning effort).
|
|
62
105
|
|
|
63
106
|
## Limitations
|
|
64
107
|
|
package/dist/index.js
CHANGED
|
@@ -231,6 +231,8 @@ AI API:
|
|
|
231
231
|
TB_AI_PROVIDER=anthropic
|
|
232
232
|
TB_AI_MODEL=claude-haiku-4-5-20251001
|
|
233
233
|
Both can be overridden per-call: tb.ai({ provider: "openai", model: "gpt-4o", ... })
|
|
234
|
+
Optional reasoning depth (0=min, 1=low, 2=med, 3=max):
|
|
235
|
+
tb.ai({ ..., reasoning: 2 })
|
|
234
236
|
|
|
235
237
|
Examples:
|
|
236
238
|
typebulb my-editor.bulb.md
|