Skip to content

Commit 4ebf55f

Browse files
committed
feat: add dev update channel
1 parent cc24ede commit 4ebf55f

14 files changed

Lines changed: 378 additions & 123 deletions

‎README.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ clawdbot agent --message "Ship checklist" --thinking high
7171

7272
Upgrading? [Updating guide](https://docs.clawd.bot/install/updating) (and run `clawdbot doctor`).
7373

74+
## Development channels
75+
76+
- **stable**: tagged releases (`vYYYY.M.D` or `vYYYY.M.D-<patch>`), npm dist-tag `latest`.
77+
- **beta**: prerelease tags (`vYYYY.M.D-beta.N`), npm dist-tag `beta` (macOS app may be missing).
78+
- **dev**: moving head of `main`, npm dist-tag `dev` (when published).
79+
80+
Switch channels (git + npm): `clawdbot update --channel stable|beta|dev`.
81+
Details: [Development channels](https://docs.clawd.bot/install/development-channels).
82+
7483
## From source (development)
7584

7685
Prefer `pnpm` for builds from source. Bun is optional for running TypeScript directly.

‎docs/cli/update.md‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ If you installed via **npm/pnpm** (global install, no git metadata), use the pac
1616
```bash
1717
clawdbot update
1818
clawdbot update --channel beta
19+
clawdbot update --channel dev
1920
clawdbot update --tag beta
2021
clawdbot update --restart
2122
clawdbot update --json
@@ -25,7 +26,7 @@ clawdbot --update
2526
## Options
2627

2728
- `--restart`: restart the Gateway daemon after a successful update.
28-
- `--channel <stable|beta>`: set the update channel for npm installs (persisted in config).
29+
- `--channel <stable|beta|dev>`: set the update channel (git + npm; persisted in config).
2930
- `--tag <dist-tag|version>`: override the npm dist-tag or version for this update only.
3031
- `--json`: print machine-readable `UpdateRunResult` JSON.
3132
- `--timeout <seconds>`: per-step timeout (default is 1200s).
@@ -34,13 +35,20 @@ Note: downgrades require confirmation because older versions can break configura
3435

3536
## What it does (git checkout)
3637

38+
Channels:
39+
40+
- `stable`: checkout the latest non-beta tag, then build + doctor.
41+
- `beta`: checkout the latest `-beta` tag, then build + doctor.
42+
- `dev`: checkout `main`, then fetch + rebase.
43+
3744
High-level:
3845

3946
1. Requires a clean worktree (no uncommitted changes).
40-
2. Fetches and rebases against `@{upstream}`.
41-
3. Installs deps (pnpm preferred; npm fallback).
42-
4. Builds + builds the Control UI.
43-
5. Runs `clawdbot doctor` as the final “safe update” check.
47+
2. Switches to the selected channel (tag or branch).
48+
3. Fetches and rebases against `@{upstream}` (dev only).
49+
4. Installs deps (pnpm preferred; npm fallback).
50+
5. Builds + builds the Control UI.
51+
6. Runs `clawdbot doctor` as the final “safe update” check.
4452

4553
## `--update` shorthand
4654

@@ -49,5 +57,6 @@ High-level:
4957
## See also
5058

5159
- `clawdbot doctor` (offers to run update first on git checkouts)
60+
- [Development channels](/install/development-channels)
5261
- [Updating](/install/updating)
5362
- [CLI reference](/cli)

‎docs/docs.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,7 @@
793793
"install/index",
794794
"install/installer",
795795
"install/updating",
796+
"install/development-channels",
796797
"install/uninstall",
797798
"install/ansible",
798799
"install/nix",
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
summary: "Stable, beta, and dev channels: semantics, switching, and tagging"
3+
read_when:
4+
- You want to switch between stable/beta/dev
5+
- You are tagging or publishing prereleases
6+
---
7+
8+
# Development channels
9+
10+
Clawdbot ships three update channels:
11+
12+
- **stable**: tagged releases (`vYYYY.M.D` or `vYYYY.M.D-<patch>`). npm dist-tag: `latest`.
13+
- **beta**: prerelease tags (`vYYYY.M.D-beta.N`). npm dist-tag: `beta`.
14+
- **dev**: moving head of `main` (git). npm dist-tag: `dev` (when published).
15+
16+
## Switching channels
17+
18+
Git checkout:
19+
20+
```bash
21+
clawdbot update --channel stable
22+
clawdbot update --channel beta
23+
clawdbot update --channel dev
24+
```
25+
26+
- `stable`/`beta` check out the latest matching tag.
27+
- `dev` switches to `main` and rebases on the upstream.
28+
29+
npm/pnpm global install:
30+
31+
```bash
32+
clawdbot update --channel stable
33+
clawdbot update --channel beta
34+
clawdbot update --channel dev
35+
```
36+
37+
This updates via the corresponding npm dist-tag (`latest`, `beta`, `dev`).
38+
39+
Tip: if you want stable + dev in parallel, keep two clones and point your gateway at the stable one.
40+
41+
## Tagging best practices
42+
43+
- Stable: tag each release (`vYYYY.M.D` or `vYYYY.M.D-<patch>`).
44+
- Beta: use `vYYYY.M.D-beta.N` (increment `N`).
45+
- Keep tags immutable: never move or reuse a tag.
46+
- Publish dist-tags alongside git tags:
47+
- `latest` → stable
48+
- `beta` → prerelease
49+
- `dev` → main snapshot (optional)
50+
51+
## macOS app availability
52+
53+
Beta and dev builds may **not** include a macOS app release. That’s OK:
54+
55+
- The git tag and npm dist-tag can still be published.
56+
- Call out “no macOS build for this beta” in release notes or changelog.

‎docs/install/updating.md‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,18 @@ pnpm add -g clawdbot@latest
5050
```
5151
We do **not** recommend Bun for the Gateway runtime (WhatsApp/Telegram bugs).
5252

53-
To stay on the beta channel for CLI updates:
53+
To switch update channels (git + npm installs):
5454

5555
```bash
5656
clawdbot update --channel beta
57-
```
58-
59-
Switch back to stable later:
60-
61-
```bash
57+
clawdbot update --channel dev
6258
clawdbot update --channel stable
6359
```
6460

6561
Use `--tag <dist-tag|version>` for a one-off install tag/version.
6662

63+
See [Development channels](/install/development-channels) for channel semantics and release notes.
64+
6765
Note: on npm installs, the gateway logs an update hint on startup (checks the current channel tag). Disable via `update.checkOnStart: false`.
6866

6967
Then:
@@ -88,7 +86,8 @@ clawdbot update --restart
8886

8987
It runs a safe-ish update flow:
9088
- Requires a clean worktree.
91-
- Fetches + rebases against the configured upstream.
89+
- Switches to the selected channel (tag or branch).
90+
- Fetches + rebases against the configured upstream (dev channel).
9291
- Installs deps, builds, builds the Control UI, and runs `clawdbot doctor`.
9392

9493
If you installed via **npm/pnpm** (no git metadata), `clawdbot update` will try to update via your package manager. If it can’t detect the install, use “Update (global install)” instead.

‎src/cli/update-cli.test.ts‎

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ describe("update-cli", () => {
120120
expect(defaultRuntime.log).toHaveBeenCalled();
121121
});
122122

123-
it("defaults to stable channel when unset", async () => {
123+
it("defaults to dev channel for git installs when unset", async () => {
124124
const { runGatewayUpdate } = await import("../infra/update-runner.js");
125125
const { updateCommand } = await import("./update-cli.js");
126126

@@ -134,7 +134,38 @@ describe("update-cli", () => {
134134
await updateCommand({});
135135

136136
const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0];
137-
expect(call?.tag).toBe("latest");
137+
expect(call?.channel).toBe("dev");
138+
});
139+
140+
it("defaults to stable channel for package installs when unset", async () => {
141+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-update-"));
142+
try {
143+
await fs.writeFile(
144+
path.join(tempDir, "package.json"),
145+
JSON.stringify({ name: "clawdbot", version: "1.0.0" }),
146+
"utf-8",
147+
);
148+
149+
const { resolveClawdbotPackageRoot } = await import("../infra/clawdbot-root.js");
150+
const { runGatewayUpdate } = await import("../infra/update-runner.js");
151+
const { updateCommand } = await import("./update-cli.js");
152+
153+
vi.mocked(resolveClawdbotPackageRoot).mockResolvedValue(tempDir);
154+
vi.mocked(runGatewayUpdate).mockResolvedValue({
155+
status: "ok",
156+
mode: "npm",
157+
steps: [],
158+
durationMs: 100,
159+
});
160+
161+
await updateCommand({});
162+
163+
const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0];
164+
expect(call?.channel).toBe("stable");
165+
expect(call?.tag).toBe("latest");
166+
} finally {
167+
await fs.rm(tempDir, { recursive: true, force: true });
168+
}
138169
});
139170

140171
it("uses stored beta channel when configured", async () => {
@@ -156,24 +187,37 @@ describe("update-cli", () => {
156187
await updateCommand({});
157188

158189
const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0];
159-
expect(call?.tag).toBe("beta");
190+
expect(call?.channel).toBe("beta");
160191
});
161192

162193
it("honors --tag override", async () => {
163-
const { runGatewayUpdate } = await import("../infra/update-runner.js");
164-
const { updateCommand } = await import("./update-cli.js");
194+
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "clawdbot-update-"));
195+
try {
196+
await fs.writeFile(
197+
path.join(tempDir, "package.json"),
198+
JSON.stringify({ name: "clawdbot", version: "1.0.0" }),
199+
"utf-8",
200+
);
165201

166-
vi.mocked(runGatewayUpdate).mockResolvedValue({
167-
status: "ok",
168-
mode: "git",
169-
steps: [],
170-
durationMs: 100,
171-
});
202+
const { resolveClawdbotPackageRoot } = await import("../infra/clawdbot-root.js");
203+
const { runGatewayUpdate } = await import("../infra/update-runner.js");
204+
const { updateCommand } = await import("./update-cli.js");
172205

173-
await updateCommand({ tag: "next" });
206+
vi.mocked(resolveClawdbotPackageRoot).mockResolvedValue(tempDir);
207+
vi.mocked(runGatewayUpdate).mockResolvedValue({
208+
status: "ok",
209+
mode: "npm",
210+
steps: [],
211+
durationMs: 100,
212+
});
174213

175-
const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0];
176-
expect(call?.tag).toBe("next");
214+
await updateCommand({ tag: "next" });
215+
216+
const call = vi.mocked(runGatewayUpdate).mock.calls[0]?.[0];
217+
expect(call?.tag).toBe("next");
218+
} finally {
219+
await fs.rm(tempDir, { recursive: true, force: true });
220+
}
177221
});
178222

179223
it("updateCommand outputs JSON when --json is set", async () => {

‎src/cli/update-cli.ts‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ import {
1313
type UpdateStepInfo,
1414
type UpdateStepProgress,
1515
} from "../infra/update-runner.js";
16+
import {
17+
channelToNpmTag,
18+
DEFAULT_GIT_CHANNEL,
19+
DEFAULT_PACKAGE_CHANNEL,
20+
normalizeUpdateChannel,
21+
type UpdateChannel,
22+
} from "../infra/update-channels.js";
1623
import { defaultRuntime } from "../runtime.js";
1724
import { formatDocsLink } from "../terminal/links.js";
1825
import { formatCliCommand } from "./command-format.js";
@@ -40,9 +47,6 @@ const STEP_LABELS: Record<string, string> = {
4047
"global update": "Updating via package manager",
4148
};
4249

43-
type UpdateChannel = "stable" | "beta";
44-
45-
const DEFAULT_UPDATE_CHANNEL: UpdateChannel = "stable";
4650
const UPDATE_QUIPS = [
4751
"Leveled up! New skills unlocked. You're welcome.",
4852
"Fresh code, same lobster. Miss me?",
@@ -66,24 +70,13 @@ const UPDATE_QUIPS = [
6670
"Version bump! Same chaos energy, fewer crashes (probably).",
6771
];
6872

69-
function normalizeChannel(value?: string | null): UpdateChannel | null {
70-
if (!value) return null;
71-
const normalized = value.trim().toLowerCase();
72-
if (normalized === "stable" || normalized === "beta") return normalized;
73-
return null;
74-
}
75-
7673
function normalizeTag(value?: string | null): string | null {
7774
if (!value) return null;
7875
const trimmed = value.trim();
7976
if (!trimmed) return null;
8077
return trimmed.startsWith("clawdbot@") ? trimmed.slice("clawdbot@".length) : trimmed;
8178
}
8279

83-
function channelToTag(channel: UpdateChannel): string {
84-
return channel === "beta" ? "beta" : "latest";
85-
}
86-
8780
function pickUpdateQuip(): string {
8881
return UPDATE_QUIPS[Math.floor(Math.random() * UPDATE_QUIPS.length)] ?? "Update complete.";
8982
}
@@ -263,12 +256,12 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
263256

264257
const configSnapshot = await readConfigFileSnapshot();
265258
const storedChannel = configSnapshot.valid
266-
? normalizeChannel(configSnapshot.config.update?.channel)
259+
? normalizeUpdateChannel(configSnapshot.config.update?.channel)
267260
: null;
268261

269-
const requestedChannel = normalizeChannel(opts.channel);
262+
const requestedChannel = normalizeUpdateChannel(opts.channel);
270263
if (opts.channel && !requestedChannel) {
271-
defaultRuntime.error(`--channel must be "stable" or "beta" (got "${opts.channel}")`);
264+
defaultRuntime.error(`--channel must be "stable", "beta", or "dev" (got "${opts.channel}")`);
272265
defaultRuntime.exit(1);
273266
return;
274267
}
@@ -279,10 +272,10 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
279272
return;
280273
}
281274

282-
const channel = requestedChannel ?? storedChannel ?? DEFAULT_UPDATE_CHANNEL;
283-
const tag = normalizeTag(opts.tag) ?? channelToTag(channel);
284-
285275
const gitCheckout = await isGitCheckout(root);
276+
const defaultChannel = gitCheckout ? DEFAULT_GIT_CHANNEL : DEFAULT_PACKAGE_CHANNEL;
277+
const channel = requestedChannel ?? storedChannel ?? defaultChannel;
278+
const tag = normalizeTag(opts.tag) ?? channelToNpmTag(channel);
286279
if (!gitCheckout) {
287280
const currentVersion = await readPackageVersion(root);
288281
const targetVersion = await resolveTargetVersion(tag, timeoutMs);
@@ -317,9 +310,9 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
317310
return;
318311
}
319312
}
320-
} else if ((opts.channel || opts.tag) && !opts.json) {
313+
} else if (opts.tag && !opts.json) {
321314
defaultRuntime.log(
322-
theme.muted("Note: --channel/--tag apply to npm installs only; git updates ignore them."),
315+
theme.muted("Note: --tag applies to npm installs only; git updates ignore it."),
323316
);
324317
}
325318

@@ -351,6 +344,7 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
351344
argv1: process.argv[1],
352345
timeoutMs,
353346
progress,
347+
channel,
354348
tag,
355349
});
356350

@@ -445,7 +439,7 @@ export function registerUpdateCli(program: Command) {
445439
.description("Update Clawdbot to the latest version")
446440
.option("--json", "Output result as JSON", false)
447441
.option("--restart", "Restart the gateway daemon after a successful update", false)
448-
.option("--channel <stable|beta>", "Persist update channel (npm installs only)")
442+
.option("--channel <stable|beta|dev>", "Persist update channel (git + npm)")
449443
.option("--tag <dist-tag|version>", "Override npm dist-tag or version for this update")
450444
.option("--timeout <seconds>", "Timeout for each update step in seconds (default: 1200)")
451445
.addHelpText(
@@ -454,7 +448,8 @@ export function registerUpdateCli(program: Command) {
454448
`
455449
Examples:
456450
clawdbot update # Update a source checkout (git)
457-
clawdbot update --channel beta # Switch to the beta channel (npm installs)
451+
clawdbot update --channel beta # Switch to beta channel (git + npm)
452+
clawdbot update --channel dev # Switch to dev channel (git + npm)
458453
clawdbot update --tag beta # One-off update to a dist-tag or version
459454
clawdbot update --restart # Update and restart the daemon
460455
clawdbot update --json # Output result as JSON

‎src/config/schema.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ const FIELD_LABELS: Record<string, string> = {
309309
const FIELD_HELP: Record<string, string> = {
310310
"meta.lastTouchedVersion": "Auto-set when Clawdbot writes the config.",
311311
"meta.lastTouchedAt": "ISO timestamp of the last config write (auto-set).",
312-
"update.channel": 'Update channel for npm installs ("stable" or "beta").',
312+
"update.channel": 'Update channel for git + npm installs ("stable", "beta", or "dev").',
313313
"update.checkOnStart": "Check for npm updates when the gateway starts (default: true).",
314314
"gateway.remote.url": "Remote Gateway WebSocket URL (ws:// or wss://).",
315315
"gateway.remote.tlsFingerprint":

0 commit comments

Comments
 (0)