feat(git): extend source control with worktrees, stashes, conflicts and identities

- Create a worktree from a new or existing branch
- Integrate a worktree branch into a target branch by merge commit or cherry-pick, with continue/abort on conflicts
- Delete a worktree with keep, delete-local, or delete-local-and-remote branch options, using safe branch deletion for unmerged branches
- Add a stash tab (list, push, apply, pop, drop) shared across a repository and its worktrees
- Rename and delete branches, optionally deleting the remote branch and updating scheduled base branches
- Detect in-progress merge, rebase, cherry-pick and revert operations and hand conflicts to an agent session
- Generate commit messages from staged changes with the default model
- Add a default git identity and saved per-repository identities written to git config
- Unify git error mapping behind a typed error and one route helper; consolidate git mutations and cache invalidation
- Update repository docs
This commit is contained in:
Chris Scott committed 2026-10-03 21:59:00 -04:00
1 parent 52b6147ed3
commit 53238a6324
89 files changed
+7704 -793

No files matched your search

+43
View File
@@ -9,6 +9,7 @@ import {
compactSession,
createSession,
createSessionWithContext,
createSessionWithPrompt,
deleteSession,
findFiles,
forkSession,
@@ -215,6 +216,48 @@ describe('OpenCode facade', () => {
expect((deleteInit as RequestInit).method).toBe('DELETE')
})
it('creates a session in a directory and sends a prompt', async () => {
fetchMock
.mockResolvedValueOnce(jsonResponse({ data: sessionInfo('ses_new', '/abs/repos/my-repo') }))
.mockResolvedValueOnce(
jsonResponse({
data: {
id: 'msg_1',
sessionID: 'ses_new',
time: { created: 1000 },
type: 'user',
payload: { text: 'Fix conflicts' },
},
}),
)
const session = await createSessionWithPrompt(
{ directory: '/abs/repos/my-repo', title: 'Resolve merge conflicts' },
'Fix conflicts',
)
expect(session.id).toBe('ses_new')
const [createUrl] = fetchMock.mock.calls[0] ?? []
expect(String(createUrl)).toBe('http://localhost/api/opencode/api/session')
const [promptUrl, promptInit] = fetchMock.mock.calls[1] ?? []
expect(String(promptUrl)).toBe('http://localhost/api/opencode/api/session/ses_new/prompt')
expect((promptInit as RequestInit).method).toBe('POST')
expect((promptInit as RequestInit).body).toBe(JSON.stringify({ text: 'Fix conflicts' }))
})
it('deletes the new session when sending the prompt fails', async () => {
fetchMock
.mockResolvedValueOnce(jsonResponse({ data: sessionInfo('ses_new', '/abs/repos/my-repo') }))
.mockResolvedValueOnce(new Response('nope', { status: 400 }))
.mockResolvedValueOnce(new Response(null, { status: 204 }))
await expect(createSessionWithPrompt({ directory: '/abs/repos/my-repo' }, 'Fix conflicts')).rejects.toBeInstanceOf(FetchError)
const [deleteUrl, deleteInit] = fetchMock.mock.calls[2] ?? []
expect(String(deleteUrl)).toBe('http://localhost/api/opencode/api/session/ses_new')
expect((deleteInit as RequestInit).method).toBe('DELETE')
})
it('finds files through the V2 filesystem route and returns paths', async () => {
fetchMock.mockResolvedValue(
jsonResponse({