feat(signed-commit): accept an optional cwd so the tool works on any clone#2393
Merged
Conversation
Contributor
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
packages/agent/src/adapters/local-tools/tools/signed-commit.test.ts:41-76
**Prefer parameterised tests for cwd resolution cases**
The three cases testing how `args.cwd` resolves to the final `ctx.cwd` (absent, absolute, relative) share an identical shape — call handler, read `createSignedCommit.mock.calls[0][0].cwd`, assert equality. They could be collapsed into a single `it.each` table to avoid repeating the identical handler call and assertion three times while keeping each resolution case explicit and readable.
Reviews (1): Last reviewed commit: "style: apply biome formatter to signed-c..." | Re-trigger Greptile |
7922010 to
1160f17
Compare
…clone Adds an optional `cwd` arg to git_signed_commit, resolved against the session cwd, so the agent can commit from any clone reachable in the sandbox. Rebased onto latest main, resolving the resolveGithubToken import move into utils/github-token. Generated-By: PostHog Code Task-Id: b3c1f40a-6137-4266-a6e0-a47b734c20d8
Contributor
|
Reviews (2): Last reviewed commit: "feat(signed-commit): accept an optional ..." | Re-trigger Greptile |
tatoalo
approved these changes
Jun 2, 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.
Problem
The
git_signed_commitMCP tool'sctx.cwdis bound once at sessioncreation:
agent-server.tspassesthis.config.repositoryPath ?? "/tmp/workspace"into the new session and the local-tools MCP server captures that as
its
LocalToolCtx.cwd. Every git invocation increateSignedCommitruns against that bound cwd, so a task that clones a second repo (or
works in any checkout outside the original session cwd) can't commit
from it —
git remote get-url originruns from the wrong directoryand fails.
Changes
cwdfield tosignedCommitToolSchema.path.resolve(ctx.cwd, argCwd)(absolute paths pass through, relative paths join the session cwd),
override the ctx, and strip
cwdfrom the input forwarded tocreateSignedCommitso the lower-level API surface is unchanged.cwdand the tool still runsagainst the session cwd.
How did you test this?
pnpm --filter @posthog/agent typecheck— clean.pnpm exec vitest run src/adapters/local-tools src/adapters/claude/mcp/local-toolspasses. New
signed-commit.test.tscovers: default-to-session-cwd,absolute override, relative resolution, that
cwdisn't forwarded asa
SignedCommitInputfield, and the existing no-token error path.Publish to changelog?
no
Created with PostHog Code