feat(cli): self update preserves install scope (local vs global)#1132
Merged
feat(cli): self update preserves install scope (local vs global)#1132
Conversation
Detect whether agentv was invoked from a local project dependency (process.argv[1] contains node_modules) versus a global install, and run the package manager install command with matching scope: - Global (default): `npm install -g agentv@latest` / `bun add -g agentv@latest` - Local: `npm install agentv@latest` / `bun add agentv@latest` The `self update` command surfaces the detected scope in its console output so users can see where the update is being applied. Closes #1127
Deploying agentv with
|
| Latest commit: |
6793914
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3b840ad3.agentv.pages.dev |
| Branch Preview URL: | https://feat-1127-self-update-local.agentv.pages.dev |
Address review feedback: - Match `/node_modules/` (POSIX) or `\node_modules\` (Windows) as an actual path segment so paths that merely embed the substring (e.g. `/opt/my_node_modules_tool/`) aren't misclassified as local. - Export `getInstallArgs` and assert the `-g` flag is present for global and absent for local, for both npm and bun. - Add a Windows path case for `detectInstallScopeFromPath`. - Reword the scope label in the console log to avoid nested parens.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
agentv self updatenow detects whether agentv was invoked from a local project dependency (process.argv[1]containsnode_modules) or a global install, and runs the package manager with the matching scope:npm install -g agentv@latest/bun add -g agentv@latestnpm install agentv@latest/bun add agentv@latest(no-g)Updating agentv using npm (local (project))...).Implementation
apps/cli/src/self-update.tsdetectInstallScopeFromPath(scriptPath)anddetectInstallScope().getInstallArgs()takes ascopeparameter and emits['install', pkg]/['add', pkg]without-gfor local.performSelfUpdate()accepts an optionalscopeoverride (defaults to auto-detect) and returns the resolved scope alongside the existing fields.apps/cli/src/commands/self/index.ts— passes the detected scope through toperformSelfUpdate()and surfaces it in theUpdating agentv using …log line.apps/cli/test/self-update.test.ts— adds coverage fordetectInstallScopeFromPath(local node_modules, npx cache,/usr/local/bin,.bun/bin, nvm, empty string).Red/Green UAT
To exercise the spawn without actually installing anything,
npmandbunwere shadowed with fake shims that echo their received args;bunwas invoked via an absolute path so PATH override only affects child processes.Red (on
main): RunningperformSelfUpdatefrom a script path undernode_modules:→
-gis used even though the invocation came from a local install — the reported bug.Green (this branch):
node_modules/):node_modules):Both cases behave as specified in the issue: local installs no longer get the
-gflag, global installs still do.Test plan
apps/cli/test/self-update.test.tspass (incl. 6 new cases coveringdetectInstallScopeFromPath)Related
studio/serve).Closes #1127