Pass dir to dev when activating from subdir (fix #51)#61
Open
gaggle wants to merge 4 commits intopkgxdev:mainfrom
Open
Pass dir to dev when activating from subdir (fix #51)#61gaggle wants to merge 4 commits intopkgxdev:mainfrom
gaggle wants to merge 4 commits intopkgxdev:mainfrom
Conversation
The `chpwd` hook walks up from `$PWD` looking for an activation marker, but when it found one in a parent dir it invoked `dev` with no arguments, making `dev` sniff `$PWD` (the subdir, with no keyfiles) instead of the activated dir. `dev` exited with "no devenv detected" and empty stdout, and the dir intended for `dev` got passed to eval as a positional arg instead, which the shell tried to execute, producing "permission denied: <dir>" on `cd`. This change moves "$dir" inside the command substitution, so `dev` sniffs the activated directory. This also adds an integration test that drives `zsh` end-to-end with a fake `dev` on PATH to verify the hook invokes `dev` with the activated dir as argv[1] and produces no permission-denied error.
shellcode() and datadir() read PATH and XDG_DATA_HOME from Deno.env implicitly at codegen time, which made the integration test for issue pkgxdev#51 noisy: it had to mutate process env, save originals, and restore them so the generated shellcode would point at the test's temp dirs. This change makes env an explicit parameter (defaulting to Deno.env.toObject()) so production callers in app.ts stay unchanged, but tests can pass a clean env per-invocation. Test drops from 130 to 68 lines, without all the save/restore ceremony.
CI Ubuntu runners ship without zsh, so the integration test failed with `NotFound: Failed to spawn 'zsh'`. This changes the new test to rely on bash.
The new chpwd-hook integration test spawns a bash subprocess to drive the generated shellcode end-to-end, so --allow-run` is required. This change also updates AGENTS.md's documented test command to match the change in ci.yml. Scoped to bash so the test suite cannot spawn arbitrary executables.
a3a1bb7 to
0b959fd
Compare
This was referenced May 7, 2026
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
cd-ing directly into a subdirectory of an already-activated devenv failed to activate it and emitted(eval):1: permission denied: <dir>. Also refactoredshellcode()/datadir()to take an explicitenvparameter (defaulted toDeno.env.toObject()) to support an integration test that drives the chpwd hook through a realzshsubprocess.$PWDto find an activation marker, then invokeddevwith no arguments, causingdevto sniff$PWD(the subdirectory, with no keyfiles) instead of the activated parent dir.devexited 1 with empty stdout, and the dir intended fordevwas passed toevalas a positional arg, which the shell tried to execute as a command.AI Intent
dev'd folder where path contains3 from a fresh terminal log, localize the bug insrc/shellcode().ts, write a failing test first (TDD), then ship the fix as atomic commits following the repo's existing commit-message style.envparameter to simplify testing.Risk Assessment
shellcode()output iseval'd in user shells, so a regression here would break shell init for anyone runningdev integrate. Mitigated by the new end-to-end zsh integration test.shellcode()anddatadir()keep their old zero-arg call signatures via default parameters;app.tscallers are unchanged. The shell-side change is one token ("$dir"moved inside the command substitution);dev <path>was already supported byapp.ts's default branch.Rollback Plan
git revertthe commits. The shellcode is regenerated each shell session viaeval "$(dev --shellcode)", so reverting + reinstalling will restore prior behavior for users.Validation
deno fmt --check .deno lint .deno checkdeno test --allow-read --allow-write --allow-env --allow-run=bashInternal/Public Boundary Check