feat(cli): add hunk update self-update command - #788
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThe PR adds an install-aware
Confidence Score: 3/5The PR should not merge until local source builds are classified correctly and explicit update targets are restricted to valid Hunk versions. The production self-update path can falsely report an untagged source build as current, while the unvalidated positional argument can cause npm to install targets outside the documented Hunk-version contract. Files Needing Attention: src/core/selfUpdate.ts, src/core/cli.ts, src/core/installSource.ts Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI[hunk update version/options] --> Parse[parseUpdateCommand]
Parse --> Plan[self-update StartupPlan]
Plan --> Run[runSelfUpdateCommand]
Run --> Detect[detectInstallSource]
Detect -->|npm| Registry[npm dist-tags]
Detect -->|Homebrew| Formula[Homebrew formula API]
Detect -->|Nix/mise/dev| Guidance[Print owner-specific guidance]
Registry --> Spawn[npm/bun/pnpm global install]
Formula --> Brew[brew upgrade hunk]
Prompt To Fix All With AI### Issue 1
src/core/selfUpdate.ts:162-164
**Untagged builds misclassified as npm**
When an untagged local build outside the recognized development install directory runs `hunk update` or `hunk update --check`, this detector omits `installedVersion` and falls back to npm, causing `0.0.0-unknown` to be reported as already up to date instead of showing the local-build update guidance.
```suggestion
const installSource =
input.method ??
(io.resolveInstallSource ??
(() => detectInstallSource({ env, executablePath, version: installedVersion })))();
```
### Issue 2
src/core/cli.ts:1667-1670
**Version accepts arbitrary npm specs**
When an npm-installed user supplies an npm alias, local path, repository, range, or tag as `[version]`, the unvalidated value is embedded in `hunkdiff@${targetVersion}`, causing the command to install a target outside the documented normalized Hunk-version contract.
### Issue 3
src/core/selfUpdate.ts:158
**Environment bypasses validated configuration**
The production self-update path defaults directly to `process.env`, bypassing the repository's required validated environment-access convention and making invalid install-source configuration harder to detect consistently.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "wip: checkpoint hunk update self-update ..." | Re-trigger Greptile |
Add an opencode-style self-update flow: detect how Hunk was installed (npm, Homebrew, Nix, mise, or a local source build) from env and executable path, query that channel's own registry for the latest version, and delegate the upgrade to the channel's package manager. Nix, mise, and dev installs get guidance instead of a spawned upgrade. The startup update notice now shares the same detector and points users at hunk update; Homebrew installs are compared against the brew formula version instead of npm dist-tags, so they are no longer notified about versions brew cannot install yet. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sf2y1jWD9fgx7aAKYbLQC6
Pass the installed version into install-source detection so untagged local builds outside the recognized install directory get source-build guidance instead of falling back to npm, and validate the update version argument as an exact release version so arbitrary npm specs (tags, ranges, paths, aliases) never reach the package-manager spec. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sf2y1jWD9fgx7aAKYbLQC6
0bd23e5 to
689ce4d
Compare
hunk update self-update command
Adds an opencode-style self-update flow.
What it does
hunk update [version] [--method npm|brew] [--check]detects how Hunk was installed and delegates the upgrade to the package manager that owns the install:npm install --global hunkdiff@<version>(or the owning client;.cmdshims on Windows)brew upgrade hunkyour Nix config/mise up hunk/bun run install:bin) instead of acting behind the user's backsrc/core/process/installSource.ts) readsHUNK_INSTALL_SOURCE, the/nix/store/prefix, mise'sinstallslayout, Homebrew prefixes (requiring the hunk artifact name, so a Homebrew-installed Bun running from source doesn't misclassify), theinstall:bintarget directory, and the untagged-version sentinel.src/core/process/latestRelease.ts) asks each channel's own registry: npm dist-tags for npm installs,formulae.brew.shfor Homebrew. This also fixes the startup notice bug where Homebrew installs were compared against npm dist-tags and could be told about versions brew can't install yet.hunk update.[version]argument is validated as an exact release version; npm specs (tags, ranges, paths, aliases) are rejected.Notes
src/core/process/per the post-Organize src/core into real modules #795 layout;bun run deps:checkpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_01Sf2y1jWD9fgx7aAKYbLQC6