Skip to content

fix: auto-update tracks installed dist-tag, not hardcoded latest - #330

Merged
ranxianglei merged 3 commits into
masterfrom
2026-08-21_autoupdate-by-tag
Aug 21, 2026
Merged

fix: auto-update tracks installed dist-tag, not hardcoded latest#330
ranxianglei merged 3 commits into
masterfrom
2026-08-21_autoupdate-by-tag

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #328

Problem

The README's canonical install is opencode plugin opencode-acp@stable --global. Two defects made auto-update dead for that install path:

  1. isAutoUpdatableSpec("stable")false — bare dist-tag words (stable, dev, pr-N) matched no allowed form, so auto-update silently never fired for every README install.
  2. fetchLatestVersion hardcoded the latest dist-tag — even past the gate, an @stable install would compare against the latest track; after removing the wrapper, opencode reinstalls @stable, so the update could never land and the toast would claim a version the user can't get.

Root cause evidence

  • opencode v1.18.20 packages/core/src/npm.ts: wrapper dir is named after the user spec (~/.cache/opencode/packages/opencode-acp@stable/), savePrefix: "" pins the exact resolved version in the wrapper package.json, and an existing node_modules/<name> short-circuits re-reify — so removing the wrapper is the only refresh path, and it must track the install tag.
  • Registry: GET /opencode-acp/stable → 1.14.19, GET /opencode-acp/pr-327 → 1.14.22-pr.327.46 (dist-tag resolution on the version endpoint confirmed; the package publishes latest, stable, dev + 25 pr-* tags).

Fix

Auto-update now tracks the dist-tag the user installed from:

Install spec Gate Registry endpoint checked
opencode-acp@stable / @dev / @pr-N /opencode-acp/<tag>
@latest / ^ ranges / * /opencode-acp/latest
exact pins (1.14.22)
file: / github: / bare name
  • specUpdateTag() (new): tag word → itself; */ranges → latest; pins/non-registry → undefined (never update)
  • isAutoUpdatableSpec(): accepts registry dist-tag words (pr-N CI preview installs now auto-updatable)
  • fetchLatestVersion(name, tag): queries /name/<tag> instead of hardcoded /latest
  • updateTarget() returns {removeDir, spec}; updateRemoveDir kept as compat wrapper
  • isDistTag(): charset [A-Za-z0-9._-], rejects exact semver pins and x-ranges

Verification

  • TDD: 5 new tests verified failing on pre-fix code (isAutoUpdatableSpec("stable") === false), then passing after fix
  • tests/update.test.ts: 10/10 pass
  • tsc --noEmit: 0 errors
  • Full suite: 1015 pass / 0 fail (1010 master baseline + 5 new)
  • Docs updated: README.md, README.zh-CN.md, CONFIGURATION.md, CONFIGURATION.zh-CN.md
  • devlog: 2026-08-21_autoupdate-by-tag/ (REQ + WORKLOG)

- isAutoUpdatableSpec now accepts registry dist-tag words (stable, dev, pr-N)
  — previously rejected, so README installs (@stable) never auto-updated
- specUpdateTag maps install spec → dist-tag: tag word → itself, */ranges →
  latest, exact pins/non-registry → undefined (never update)
- fetchLatestVersion queries /name/<tag> so @stable follows the stable track
- updateTarget returns {removeDir, spec}; updateRemoveDir kept as wrapper
- tests: +5 (fail-first verified), docs: autoUpdate tag semantics in 4 files,
  devlog: 2026-08-21_autoupdate-by-tag
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown

📦 Built Plugin Artifact

Branch: 2026-08-21_autoupdate-by-tag (5c70340)

Option A — Install from npm PR tag (recommended)

opencode plugin opencode-acp@pr-330 --global

Each push to this PR publishes a new version under the pr-330 npm tag.

Option B — Install from GitHub

opencode plugin "github:ranxianglei/opencode-acp#2026-08-21_autoupdate-by-tag" --global

Option C — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf opencode-acp-pr330.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
  1. Restart opencode to pick up changes.

This comment is automatically updated on each push.

- same-PR preview increments compare numerically (pr.327.47 > pr.327.46)
- dev track moves forward; release outranks preview per semver
- channel pinning keeps @Pr-N installs compared only against their own tag
@ranxianglei
ranxianglei merged commit 971d9b7 into master Aug 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

auto update by tag not latest

1 participant