fix(cli): support all release channels in update (#11795)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The managed CLI lets operators follow a release channel during
updates
> - Paperclip publishes stable, beta, nightly, and canary channels
> - The update command only let users select stable or canary
> - A default update also changed recorded beta and nightly installs to
stable
> - This pull request adds all four channels to the update command and
update notice
> - The benefit is that each managed install stays on the channel that
the operator selected

## Linked Issues or Issue Description

**What happened?**

`paperclipai update` only accepted `--latest` and `--canary`. It did not
accept `--beta` or `--nightly`. A default update mapped every recorded
channel except canary to `latest`. The update notice used the same
two-channel rule.

**Expected behavior**

The command must accept all four published channel selectors. A default
update must use the moving channel in the install manifest. The update
notice must check the same channel.

**Steps to reproduce**

1. Record `beta` or `nightly` as the managed install channel.
2. Run `paperclipai update` without a channel flag.
3. Observe that the command resolves `paperclipai@latest` instead of the
recorded channel.

**Paperclip version or commit**

Commit `e1ce7a553c280ef3d2b9ed99e0149afc23b14275`.

**Deployment mode**

This bug is not specific to a deployment mode.

**Installation method**

Managed CLI install.

**Additional context**

The managed update workflow was added in #10045. I found no duplicate
issue or pull request for this channel gap.

## What Changed

- Added `--beta` and `--nightly` to `paperclipai update` and
`paperclipai upgrade`.
- Expanded the install manifest channel type and kept the recorded
moving channel during a default update.
- Made update notices use the recorded channel and made the notice cache
channel-aware.
- Added regression tests and updated the channel, CLI, and installation
documents.

## Verification

- `pnpm exec vitest run cli/src/__tests__/update-command.test.ts
cli/src/__tests__/update-notice.test.ts` — 2 files and 18 tests passed.
- `pnpm --filter paperclipai typecheck` passed.
- `pnpm --filter paperclipai build` passed.
- `pnpm paperclipai update --help` showed `--latest`, `--beta`,
`--nightly`, and `--canary`.

## Risks

- Low risk. The change adds accepted manifest values and command flags.
Existing latest, canary, and pinned installs keep their current
behavior.
- Old notice cache files have no channel field. They remain valid for
the latest channel and refresh for other channels.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- OpenAI Codex, GPT-5 family. The runtime does not expose the exact
deployment ID or context window. The agent used reasoning, repository
tools, shell execution, and test execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Dev Agent <dev@paperclip.ing>
Co-authored-by: Paperclip <noreply@paperclip.ing>
Co-authored-by: commitperclip[bot] <284812584+commitperclip[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-12-04 11:30:05 -08:00
1 parent f4baaa4f48
commit 638530f273
9 files changed
+52 -21

No files matched your search

+8 -3
View File
@@ -10,7 +10,7 @@ let root: string;
let previousHome: string | undefined;
let previousPaperclipHome: string | undefined;
function record(payloadPath: string, version: string, channel: "latest" | "canary" | "pinned" = "latest"): InstallRecord {
function record(payloadPath: string, version: string, channel: "latest" | "beta" | "nightly" | "canary" | "pinned" = "latest"): InstallRecord {
return { source: "npm", version, channel, payloadPath, installedAt: `2026-07-22T00:00:0${version}.000Z` };
}
function createPayload(payloadPath: string, version: string): string {
@@ -104,11 +104,16 @@ describe("update command", () => {
expect(detectInstallMode(path.join(source, "cli", "src", "index.ts"), paths)).toBe("source");
});
it("resolves channels and keeps pinned installs pinned by default", () => {
it("resolves every channel and preserves the recorded channel by default", () => {
const manifest = { channel: "pinned", version: "1.2.3" } as InstallManifest;
expect(resolveUpdateRequest(manifest, {})).toEqual({ spec: "1.2.3", channel: "pinned", explicit: false });
expect(resolveUpdateRequest(manifest, { latest: true })).toEqual({ spec: "latest", channel: "latest", explicit: true });
expect(() => resolveUpdateRequest(manifest, { latest: true, canary: true })).toThrow("only one");
expect(resolveUpdateRequest(manifest, { beta: true })).toEqual({ spec: "beta", channel: "beta", explicit: true });
expect(resolveUpdateRequest(manifest, { nightly: true })).toEqual({ spec: "nightly", channel: "nightly", explicit: true });
expect(resolveUpdateRequest(manifest, { canary: true })).toEqual({ spec: "canary", channel: "canary", explicit: true });
expect(resolveUpdateRequest({ ...manifest, channel: "beta" }, {})).toEqual({ spec: "beta", channel: "beta", explicit: false });
expect(resolveUpdateRequest({ ...manifest, channel: "nightly" }, {})).toEqual({ spec: "nightly", channel: "nightly", explicit: false });
expect(() => resolveUpdateRequest(manifest, { latest: true, beta: true })).toThrow("only one");
});
it("re-resolves a moving git branch and activates the new SHA payload", async () => {
+13 -3
View File
@@ -2,10 +2,11 @@ import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { resolveInstallStorePaths, writeInstallManifestAtomic } from "../install-store.js";
import { checkForUpdateNotice, isUpdateNoticeEnabled } from "../update-notice.js";
let root: string; let previous: string | undefined;
beforeEach(() => { root = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-notice-")); previous = process.env.PAPERCLIP_UPDATE_CHECK; delete process.env.PAPERCLIP_UPDATE_CHECK; });
afterEach(() => { if (previous === undefined) delete process.env.PAPERCLIP_UPDATE_CHECK; else process.env.PAPERCLIP_UPDATE_CHECK = previous; fs.rmSync(root, { recursive: true, force: true }); });
let root: string; let previous: string | undefined; let previousPaperclipHome: string | undefined;
beforeEach(() => { root = fs.mkdtempSync(path.join(os.tmpdir(), "paperclip-notice-")); previous = process.env.PAPERCLIP_UPDATE_CHECK; previousPaperclipHome = process.env.PAPERCLIP_HOME; delete process.env.PAPERCLIP_UPDATE_CHECK; process.env.PAPERCLIP_HOME = path.join(root, "paperclip"); });
afterEach(() => { if (previous === undefined) delete process.env.PAPERCLIP_UPDATE_CHECK; else process.env.PAPERCLIP_UPDATE_CHECK = previous; if (previousPaperclipHome === undefined) delete process.env.PAPERCLIP_HOME; else process.env.PAPERCLIP_HOME = previousPaperclipHome; fs.rmSync(root, { recursive: true, force: true }); });
describe("update notice", () => {
it("honors the environment and config kill switches", () => {
process.env.PAPERCLIP_UPDATE_CHECK = "0"; expect(isUpdateNoticeEnabled(path.join(root, "missing.json"))).toBe(false);
@@ -17,4 +18,13 @@ describe("update notice", () => {
expect(await checkForUpdateNotice({ cachePath, now: 2000, fetchImpl })).toBe("99.0.0");
expect(fetchImpl).toHaveBeenCalledOnce();
});
it.each(["beta", "nightly"] as const)("checks the recorded %s channel", async (channel) => {
const paths = resolveInstallStorePaths();
writeInstallManifestAtomic({ schemaVersion: 1, source: "npm", version: `1.0.0-${channel}.0`, channel, payloadPath: path.join(root, "payload"), installedAt: "2026-08-20T00:00:00.000Z", previous: [] }, paths);
const cachePath = path.join(root, "cache.json");
const target = `99.0.0-${channel}.1`;
const fetchImpl = vi.fn(async () => new Response(JSON.stringify({ "dist-tags": { latest: "0.3.1", beta: "99.0.0-beta.1", nightly: "99.0.0-nightly.1" } }), { status: 200 }));
expect(await checkForUpdateNotice({ cachePath, now: 1000, fetchImpl })).toBe(target);
expect(JSON.parse(fs.readFileSync(cachePath, "utf8"))).toMatchObject({ latest: target, tag: channel });
});
});
+8 -6
View File
@@ -16,7 +16,7 @@ import { packageVersion } from "../version.js";
const execFileAsync = promisify(execFile);
export type InstallMode = "managed" | "global-npm" | "npx" | "source" | "unknown";
export type UpdateOptions = { canary?: boolean; latest?: boolean; version?: string; rollback?: boolean; check?: boolean; dryRun?: boolean; json?: boolean; yes?: boolean; backup?: boolean };
export type UpdateOptions = { latest?: boolean; beta?: boolean; nightly?: boolean; canary?: boolean; version?: string; rollback?: boolean; check?: boolean; dryRun?: boolean; json?: boolean; yes?: boolean; backup?: boolean };
type Dependencies = { executablePath: string; runCommand: CommandRunner; backup: () => Promise<void>; confirm: (message: string) => Promise<boolean>; now: () => Date; paths: InstallStorePaths; restartActiveService: (expectedVersion: string) => Promise<boolean>; hasInstanceData: () => boolean };
const DATABASE_UNREACHABLE_CODES = new Set(["ECONNREFUSED", "EHOSTUNREACH", "ENETUNREACH", "ETIMEDOUT"]);
@@ -114,14 +114,16 @@ export function compareVersions(left: string, right: string): number {
return 0;
}
export function resolveUpdateRequest(manifest: InstallManifest | null, options: Pick<UpdateOptions, "canary" | "latest" | "version">): { spec: string; channel: InstallChannel; explicit: boolean } {
const selected = Number(Boolean(options.canary)) + Number(Boolean(options.latest)) + Number(Boolean(options.version));
if (selected > 1) throw new Error("Choose only one of --latest, --canary, or --version.");
export function resolveUpdateRequest(manifest: InstallManifest | null, options: Pick<UpdateOptions, "latest" | "beta" | "nightly" | "canary" | "version">): { spec: string; channel: InstallChannel; explicit: boolean } {
const selected = Number(Boolean(options.latest)) + Number(Boolean(options.beta)) + Number(Boolean(options.nightly)) + Number(Boolean(options.canary)) + Number(Boolean(options.version));
if (selected > 1) throw new Error("Choose only one of --latest, --beta, --nightly, --canary, or --version.");
if (options.version) return { spec: options.version.trim(), channel: "pinned", explicit: true };
if (options.canary) return { spec: "canary", channel: "canary", explicit: true };
if (options.latest) return { spec: "latest", channel: "latest", explicit: true };
if (options.beta) return { spec: "beta", channel: "beta", explicit: true };
if (options.nightly) return { spec: "nightly", channel: "nightly", explicit: true };
if (options.canary) return { spec: "canary", channel: "canary", explicit: true };
if (manifest?.channel === "pinned") return { spec: manifest.version, channel: "pinned", explicit: false };
const channel = manifest?.channel === "canary" ? "canary" : "latest";
const channel = manifest?.channel ?? "latest";
return { spec: channel, channel, explicit: false };
}
+2
View File
@@ -97,6 +97,8 @@ program
.alias("upgrade")
.description("Check, update, or roll back the Paperclip CLI")
.option("--latest", "Switch to the latest stable channel")
.option("--beta", "Switch to the beta channel")
.option("--nightly", "Switch to the nightly channel")
.option("--canary", "Switch to the canary channel")
.option("--version <version>", "Install an exact published version")
.option("--rollback", "Flip back to the retained previous managed payload")
+1 -1
View File
@@ -9,7 +9,7 @@ export const PATH_BLOCK_START = "# >>> paperclipai managed PATH >>>";
export const PATH_BLOCK_END = "# <<< paperclipai managed PATH <<<";
export type InstallSource = "npm" | "git";
export type InstallChannel = "latest" | "canary" | "pinned";
export type InstallChannel = "latest" | "beta" | "nightly" | "canary" | "pinned";
export type InstallRecord = {
source: InstallSource;
+4 -3
View File
@@ -12,8 +12,9 @@ export function isUpdateNoticeEnabled(configPath?: string): boolean {
export async function checkForUpdateNotice(options: { configPath?: string; now?: number; fetchImpl?: typeof fetch; cachePath?: string } = {}): Promise<string | null> {
if (!isUpdateNoticeEnabled(options.configPath)) return null;
const paths = resolveInstallStorePaths(); const cachePath = options.cachePath ?? path.join(paths.cliRoot, "update-check.json"); const now = options.now ?? Date.now();
try { const cache = JSON.parse(fs.readFileSync(cachePath, "utf8")) as { checkedAt?: number; latest?: string }; if (cache.checkedAt && now - cache.checkedAt < NOTICE_INTERVAL_MS) return cache.latest && compareVersions(cache.latest, packageVersion) > 0 ? cache.latest : null; } catch {}
const tag = readInstallManifest(paths)?.channel === "canary" ? "canary" : "latest";
try { const response = await (options.fetchImpl ?? fetch)("https://registry.npmjs.org/paperclipai", { signal: AbortSignal.timeout(2500) }); if (!response.ok) return null; const body = await response.json() as { ["dist-tags"]?: Record<string, string> }; const latest = body["dist-tags"]?.[tag]; fs.mkdirSync(path.dirname(cachePath), { recursive: true, mode: 0o700 }); fs.writeFileSync(cachePath, JSON.stringify({ checkedAt: now, latest: latest ?? null }) + "\n", { mode: 0o600 }); return latest && compareVersions(latest, packageVersion) > 0 ? latest : null; } catch { return null; }
const manifestChannel = readInstallManifest(paths)?.channel;
const tag = manifestChannel && manifestChannel !== "pinned" ? manifestChannel : "latest";
try { const cache = JSON.parse(fs.readFileSync(cachePath, "utf8")) as { checkedAt?: number; latest?: string; tag?: string }; if ((cache.tag ?? "latest") === tag && cache.checkedAt && now - cache.checkedAt < NOTICE_INTERVAL_MS) return cache.latest && compareVersions(cache.latest, packageVersion) > 0 ? cache.latest : null; } catch {}
try { const response = await (options.fetchImpl ?? fetch)("https://registry.npmjs.org/paperclipai", { signal: AbortSignal.timeout(2500) }); if (!response.ok) return null; const body = await response.json() as { ["dist-tags"]?: Record<string, string> }; const latest = body["dist-tags"]?.[tag]; fs.mkdirSync(path.dirname(cachePath), { recursive: true, mode: 0o700 }); fs.writeFileSync(cachePath, JSON.stringify({ checkedAt: now, latest: latest ?? null, tag }) + "\n", { mode: 0o600 }); return latest && compareVersions(latest, packageVersion) > 0 ? latest : null; } catch { return null; }
}
export async function printUpdateNotice(configPath?: string): Promise<void> { const latest = await checkForUpdateNotice({ configPath }); if (latest) console.log(`Update available: ${latest} — run \`paperclipai update\``); }
+9 -4
View File
@@ -68,10 +68,15 @@ scripting).
## Switching channels
Channel choice is per-install: install from a different tag and you're on that
channel. Moving forward (stable → nightly) is always safe. Moving backward
(nightly → stable) can mean running an older schema than your data was created
with — treat a downgrade like a restore and keep a backup of your data
For a managed CLI install, use `paperclipai update` with `--latest`, `--beta`,
`--nightly`, or `--canary` to switch to any published channel. Later updates
without a channel flag stay on the recorded channel. Exact versions selected
with `--version` remain pinned.
For an ephemeral npm / npx install, channel choice comes from the dist-tag in
the install command. Moving forward (stable → nightly) is always safe. Moving
backward (nightly → stable) can mean running an older schema than your data was
created with — treat a downgrade like a restore and keep a backup of your data
directory before switching down.
## Reading version strings
+1 -1
View File
@@ -286,7 +286,7 @@ paperclipai install --canary
paperclipai install --version <version>
paperclipai install --ref <branch|tag|sha> [--repo owner/repo]
paperclipai update
paperclipai update --latest|--canary|--version <version>
paperclipai update --latest|--beta|--nightly|--canary|--version <version>
paperclipai update --rollback
paperclipai upgrade
paperclipai uninstall
+6
View File
@@ -220,10 +220,16 @@ Select a different release source explicitly:
```sh
paperclipai update --latest
paperclipai update --beta
paperclipai update --nightly
paperclipai update --canary
paperclipai update --version 2026.720.0
```
`--latest`, `--beta`, `--nightly`, and `--canary` follow the corresponding npm
dist-tag. A later `paperclipai update` with no channel flag stays on the channel
recorded in the install manifest. `--version` pins that exact version instead.
Managed updates create a database backup before switching payloads, verify the
new CLI, atomically flip `current`, and restart an installed service. A failed
install or verification leaves the previous payload active.