Description
batch passes each repository's staged diff into generateSuggestions(), but generateSuggestions() reads branch and previous-commit context from process.cwd() via getBranchName() and getLastCommitMessage().
When commit-echo batch <directory> --recursive is run from a non-Git parent directory, custom prompt variables {{branch}} and {{message}} therefore resolve to unknown / empty values for every repository. When the caller directory is itself a different Git repository, all batch items can inherit that unrelated repository's context.
Location
src/commands/batch.ts:168-176 — per-repository call to generateSuggestions()
src/llm/client.ts:45-54 — branch/message context is read without a repository path
src/git/diff.ts:299-312 — getBranchName() and getLastCommitMessage() default to process.cwd()
Relevant code
// batch.ts
const result = await generateSuggestions(config, diff, profile, apiKey);
// llm/client.ts
const branch = getBranchName();
const message = getLastCommitMessage();
The per-repo diff is correct because the batch caller explicitly passes repoPath to getStagedDiff(repoPath), but the contextual prompt fields have no equivalent repository parameter.
Steps to Reproduce
- Create two Git repositories under a non-Git directory, each on a distinct branch and with a distinct last commit subject.
- Configure a custom prompt containing
{{branch}} and/or {{message}}.
- Run
commit-echo batch <parent> --recursive.
- Inspect the requests sent to the LLM.
- The branch/previous-message fields do not come from the repository whose diff is being summarized.
Expected Behavior
Every batch request should resolve {{branch}} and {{message}} from the repository currently being processed.
Actual Behavior
Those fields are evaluated from the process working directory rather than the repository being processed.
Suggested Fix
Add an explicit cwd (or repository context object) to generateSuggestions() / prompt-context collection, and pass repoPath from batchCommand(). Add an end-to-end regression test with multiple repositories and distinct branch/message values.
Impact
Custom batch prompt templates can receive unrelated repository context, leading to misleading commit suggestions and incorrect project-specific instructions exactly where the command is supposed to process many repositories independently.
Reviewed against current main at 6c01ad0a853501e9617a3af0a5db3b515dd8ed53.
Description
batchpasses each repository's staged diff intogenerateSuggestions(), butgenerateSuggestions()reads branch and previous-commit context fromprocess.cwd()viagetBranchName()andgetLastCommitMessage().When
commit-echo batch <directory> --recursiveis run from a non-Git parent directory, custom prompt variables{{branch}}and{{message}}therefore resolve tounknown/ empty values for every repository. When the caller directory is itself a different Git repository, all batch items can inherit that unrelated repository's context.Location
src/commands/batch.ts:168-176— per-repository call togenerateSuggestions()src/llm/client.ts:45-54— branch/message context is read without a repository pathsrc/git/diff.ts:299-312—getBranchName()andgetLastCommitMessage()default toprocess.cwd()Relevant code
The per-repo diff is correct because the batch caller explicitly passes
repoPathtogetStagedDiff(repoPath), but the contextual prompt fields have no equivalent repository parameter.Steps to Reproduce
{{branch}}and/or{{message}}.commit-echo batch <parent> --recursive.Expected Behavior
Every batch request should resolve
{{branch}}and{{message}}from the repository currently being processed.Actual Behavior
Those fields are evaluated from the process working directory rather than the repository being processed.
Suggested Fix
Add an explicit
cwd(or repository context object) togenerateSuggestions()/ prompt-context collection, and passrepoPathfrombatchCommand(). Add an end-to-end regression test with multiple repositories and distinct branch/message values.Impact
Custom batch prompt templates can receive unrelated repository context, leading to misleading commit suggestions and incorrect project-specific instructions exactly where the command is supposed to process many repositories independently.
Reviewed against current
mainat6c01ad0a853501e9617a3af0a5db3b515dd8ed53.