fix: pin Claude ctx_execute cwd to session cwd#765
Conversation
|
Hi @NgoQuocViet2001 1- Let's reproduce the issue. 2- Let's fix them. 3- Let's verified manually. |
741b9c0 to
b050fa1
Compare
|
@mksglu I reproduced and verified this manually with real Claude Code E2E on my Windows machine, then pushed the rebased branch onto E2E setup:
Before ( After this branch: PreToolUse returns Validation:
|
|
Anything I can do to check/test? |
I'll take it when soon. Until that please resolve conflicts. Thank you. |
|
@mksglu Validation completed according to the maintainer review requirements. VerdictThe behavior is valuable and functionally validated, but this PR needs an update before merge because GitHub reports After the conflict is resolved, I would re-run the same 3OS validation before final merge. What this PR meaningfully fixesThis PR pins Claude Code That matters because MCP execution can otherwise run shell commands from the MCP server/plugin process location instead of the user's active project. In context-mode, cwd affects:
The important invariant is that the patch should only fill in a missing cwd. It must not overwrite a deliberate explicit Git archaeology checkedI checked the cwd/project-dir history before accepting the behavior. Relevant history shows prior fixes around project directory resolution, ctx tool cwd behavior, and policy enforcement. The key invariants checked for this PR were:
Validation performedGitHub status:
Targeted tests passed:
The explicit-cwd invariant was also covered: explicit Live Claude Code validationPer maintainer requirements, live validation used Claude Haiku. Linux:
macOS:
Windows:
Remaining update neededThe PR is worth merging after the merge conflict is resolved and the same 3OS live validation is re-run. |
|
Hi @NgoQuocViet2001, thank you for contributing this PR. I validated the change according to the maintainer review requirements. The behavior looks valuable and worth merging: the Claude Code The only blocker I see right now is that the PR has merge conflicts ( Could you please resolve the conflicts? After that, we can re-run the same validation and move this toward merge. |
e18a358 to
2dcf262
Compare
|
Hi @NgoQuocViet2001 resolve conflicts pls |
2dcf262 to
3cd82b0
Compare
Fixes #756.
Reported by @chrisjenx. cc @mksglu
What changed
cwdargument toctx_executeandctx_batch_execute, and pass it through to shell execution.cwd/workspace_roots) instead of staleCLAUDE_PROJECT_DIR.ctx_execute/ctx_batch_executecalls to the active session cwd when no explicitcwdis provided.cwdvalues and keep non-shell languages in their existing temp-dir sandbox.Validation
node_modules/.bin/vitest.CMD run tests/hooks/core-routing.test.ts tests/hooks/integration.test.ts tests/core/server.test.ts -t "MCP execute|MCP batch_execute|runBatchCommands|ctx_execute_file: CONTEXT_MODE_PROJECT_DIR"npm run typechecknpm run bundlenpm run assert-bundle && npm run assert-asymmetric-driftgit diff --check