fix(bash): honor explicit working directories

This commit is contained in:
jb
2026-09-04 16:47:41 -04:00
parent 3d68f7c6bf
commit 328faa03e0
13 changed files with 316 additions and 21 deletions
+16 -15
View File
@@ -3,8 +3,8 @@
## Status
- Status: active
- Current phase: 5. Implement owned slices
- Next safe action: implement and verify the approved optional `cwd` Bash argument.
- Current phase: 6. Verify the integrated worktree
- Next safe action: commit the focused implementation, then run the full repository test suite.
## Request and scope
@@ -22,14 +22,14 @@
## Acceptance criteria
- [ ] `@jbcode/pi-bash-cwd` overrides the built-in `bash` tool with one backward-compatible optional `cwd` argument while preserving the existing command, timeout, output, truncation, cancellation, session-environment, and renderer contracts.
- [ ] Absolute and relative `cwd` values resolve from the live session `ctx.cwd`; omitted `cwd` retains the session directory.
- [ ] The requested directory is validated before delegating command execution.
- [ ] A regression test executes `pwd` from both a disposable hidden worktree root and a nested workspace package directory and observes the requested directory.
- [ ] A missing requested working directory fails before the shell command can create a sentinel side effect.
- [ ] Package inventory, README guidance, and the upstream Pi 0.85.0 packaging blocker TODO are synchronized.
- [x] `@jbcode/pi-bash-cwd` overrides the built-in `bash` tool with one backward-compatible optional `cwd` argument while preserving the existing command, timeout, output, truncation, cancellation, session-environment, and renderer contracts.
- [x] Absolute and relative `cwd` values resolve from the live session `ctx.cwd`; omitted `cwd` retains the session directory.
- [x] The requested directory is validated before delegating command execution.
- [x] A regression test executes `pwd` from both a disposable hidden worktree root and a nested workspace package directory and observes the requested directory.
- [x] A missing requested working directory fails before the shell command can create a sentinel side effect.
- [x] Package inventory, README guidance, and the upstream Pi 0.85.0 packaging blocker TODO are synchronized.
- [ ] Existing repository typecheck and test suites pass.
- [ ] The resolved Bash cwd TODO and temporary workaround language are removed or updated without changing unrelated historical evidence.
- [x] The resolved Bash cwd TODO and temporary workaround language are removed or updated without changing unrelated historical evidence.
## Approved implementation plan and gates
@@ -45,7 +45,7 @@
| --- | --- | --- | --- | --- | --- |
| Workflow setup and research | parent Pi session `01a06e08-8d07-76a7-a116-d7e3baf55b87` | 15 minutes | workflow record only | Before: clean `main` at `7e7cfdb`; after: clean feature worktree at `5f853dc` | Complete |
| Initial dependency-plan implementation | parent Pi session `01a06e08-8d07-76a7-a116-d7e3baf55b87` | 15 minutes | `package.json`, `bun.lock`, focused test, workflow record | Before: clean feature worktree at `9d68d5f`; after: Pi 0.85.0 upgrade restored; focused red test retained unstaged | Paused and replanned after upstream packaging blocker |
| Local override implementation | parent Pi session `01a06e08-8d07-76a7-a116-d7e3baf55b87` | 15 minutes | `extensions/bash-cwd/**`, `scripts/bash-cwd.test.mjs` removal, `package.json`, `scripts/package-workspaces.test.mjs`, `README.md`, `docs/npm-packages.md`, `docs/todos.md`, `docs/workflow/skill-led-development-workflow-plan.md`, workflow record | Before: feature worktree at `f61f197` with inspected product changes | In progress under corrected approval |
| Local override implementation | parent Pi session `01a06e08-8d07-76a7-a116-d7e3baf55b87` | 15 minutes | `extensions/bash-cwd/**`, `scripts/bash-cwd.test.mjs` removal, `package.json`, `scripts/package-workspaces.test.mjs`, `README.md`, `docs/npm-packages.md`, `docs/todos.md`, `docs/workflow/skill-led-development-workflow-plan.md`, workflow record | Before: feature worktree at `3d68f7c` with inspected product changes; after: focused checks pass, product commit pending | Complete |
## Verification matrix
@@ -53,10 +53,11 @@
| --- | --- | --- | --- |
| Source/cache preflight | `git status --short --branch`; `opensrc path ...` | 0 | Clean source; Pi 0.84.4 and 0.85.0 source available locally. |
| Focused cwd reproduction | inline Node harness against Pi 0.84.4 | 0 (asserted buggy outcome) | Both hidden-worktree requests observed the primary checkout; a missing requested cwd still executed a sentinel command. |
| Focused cwd regression | pending repository test | pending | pending |
| Typecheck | `bun run typecheck` | pending | pending |
| Focused cwd regression | `bun run --filter '@jbcode/pi-bash-cwd' test` | 0 | Three tests pass: explicit absolute hidden-worktree cwd, relative nested-package cwd, omitted cwd/session environment, schema compatibility, missing cwd sentinel, and missing context. |
| Package contract | `bun run test:packages`; `bun pm pack --destination /tmp --ignore-scripts --quiet` | 0 | Workspace inventory and package contents pass; package tarball created. |
| Typecheck | `bun run typecheck` | 0 | Repository TypeScript check passes. |
| Full tests | `bun run test` | pending | pending |
| Fresh-process integration | pending | pending | pending |
| Fresh-process integration | focused test's delegated real Bash subprocesses | 0 | Commands execute through Pi 0.84.4's built-in Bash definition with session metadata preserved. |
## Review
@@ -81,6 +82,6 @@
## Checkpoints and blockers
- Last committed valid checkpoint: corrected-plan record commit `PENDING`
- Last committed valid checkpoint: corrected-plan approval commit `3d68f7c`
- Blockers: none.
- Exact next safe action: implement the optional `cwd` schema, path preflight, and explicit-argument regression cases.
- Exact next safe action: checkpoint the focused implementation and run `bun run test`.