Files
PaperClipAI/cli/src/__tests__/update-notice.test.ts
T
638530f273 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>
2026-12-04 11:30:05 -08:00

31 lines
2.7 KiB
TypeScript

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; 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);
delete process.env.PAPERCLIP_UPDATE_CHECK; const config = path.join(root, "config.json"); fs.writeFileSync(config, JSON.stringify({ updates: { checkEnabled: false } })); expect(isUpdateNoticeEnabled(config)).toBe(false);
});
it("throttles registry checks for 24 hours", async () => {
const cachePath = path.join(root, "cache.json"); const fetchImpl = vi.fn(async () => new Response(JSON.stringify({ "dist-tags": { latest: "99.0.0" } }), { status: 200 }));
expect(await checkForUpdateNotice({ cachePath, now: 1000, fetchImpl })).toBe("99.0.0");
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 });
});
});