Skip to content

Agent git context access#160

Draft
manuelkiessling wants to merge 12 commits intomainfrom
cursor/agent-git-context-access-f544
Draft

Agent git context access#160
manuelkiessling wants to merge 12 commits intomainfrom
cursor/agent-git-context-access-f544

Conversation

@manuelkiessling
Copy link
Copy Markdown
Member

Add Git context (recent commits, current branch, and all branches) to the agent's system prompt to improve its understanding of the repository state.

The agent previously lacked visibility into the repository's Git history and branch structure, which limited its ability to understand the context of changes and make informed decisions. This PR addresses that by injecting relevant Git information directly into its system prompt.


Open in Web Open in Cursor 

cursoragent and others added 12 commits February 26, 2026 15:46
- Create WorkspaceCommitDto and WorkspaceGitInfoDto
- Extend GitAdapterInterface with getCurrentBranch, getRecentCommits, getBranches
- Implement new methods in GitCliAdapter using NUL-separated format
- Update SimulatedGitAdapter to delegate to real adapter
- Add getGitInfo to WorkspaceGitService
- Add getGitInfo to WorkspaceMgmtFacade and interface
- Extend AgentExecutionContext to store git info
- Add getGitContextInfo to WorkspaceToolingServiceInterface
- Inject git context into ContentEditorAgent system prompt
- Set git context in RunEditSessionHandler before agent runs

This allows the agent to see recent commits, current branch, and available branches at session start.

Co-authored-by: Manuel Kießling <[email protected]>
- Unit tests for GitCliAdapter (getCurrentBranch, getRecentCommits, getBranches)
- Integration tests for WorkspaceGitService::getGitInfo
- Application tests for WorkspaceMgmtFacade::getGitInfo
- Tests cover commit bodies, multiline messages, branch switching, and limits

Co-authored-by: Manuel Kießling <[email protected]>
- Create RawCommitDto to avoid associative arrays across boundaries
- Fix test parent::tearDown() ordering
- Fix property type assertions in tests
- Add PHPStan baseline for DateTimeImmutable parsing from git
- Update phpstan.dist.neon to include baseline

All quality checks now pass.

Co-authored-by: Manuel Kießling <[email protected]>
- Ensure 'main' branch exists after init using 'git branch -M main'
- Fixes test failures on systems where default branch is not 'main'

Co-authored-by: Manuel Kießling <[email protected]>
- Accept both '2024-01-01T12:00:00Z' and '2024-01-01T12:00:00+00:00'
- Fixes test failures on systems with different git timestamp formats

Co-authored-by: Manuel Kießling <[email protected]>
- getRecentCommits now returns empty array for repos with no commits
- getBranches now returns empty array for repos with no commits
- Fixes test failures for empty repository tests

Co-authored-by: Manuel Kießling <[email protected]>
- Replaces git branch -M main with git init -b main
- Ensures main branch is created from the start
- Fixes test failures where commits were not being created on main branch

Co-authored-by: Manuel Kießling <[email protected]>
- Git log with --pretty=format adds newlines between commits
- Split records by NUL+newline instead of double NUL
- Fixes test failures where only 1 of 3 commits was being parsed

Co-authored-by: Manuel Kießling <[email protected]>
- Update WorkspaceGitServiceTest to use git init -b main
- Update WorkspaceMgmtFacadeGitInfoTest to use git init -b main
- Ensures consistent branch naming across all tests

Co-authored-by: Manuel Kießling <[email protected]>
- Ensure workspaceRoot directory exists before moving test repos
- Fixes integration test failures when directory doesn't exist

Co-authored-by: Manuel Kießling <[email protected]>
- Add error checking for mkdir and rename operations
- Throw descriptive exceptions if operations fail
- Helps diagnose issues with test workspace setup

Co-authored-by: Manuel Kießling <[email protected]>
- Replace rename() with copyDirectory() + remove
- Fixes cross-filesystem rename failures
- Rename fails when /tmp and workspace root are on different mounts

Co-authored-by: Manuel Kießling <[email protected]>
@cursor
Copy link
Copy Markdown

cursor bot commented Feb 26, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants