Skip to content

refactor(core): replace project copies with worktrees - #42149

Merged
jlongster merged 14 commits into
v2from
project-copy-api
Aug 13, 2026
Merged

jlongster merged 14 commits into
v2from
project-copy-api

Conversation

@jlongster

@jlongster jlongster commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • replace the V2 ProjectCopy and ProjectDirectories domains with a global Worktree service
  • consolidate project roots and managed worktrees into a dedicated worktree table
  • expose global list, create, remove, and refresh operations through the generated Promise and Effect clients
  • migrate the current V2 TUI and SDK Next surfaces to Worktree terminology and contracts

Architecture

  • keep Worktree service process-global and project-ID based
  • keep only the automatic refresh boot node Location-scoped
  • resolve create sources from any available persisted worktree, including another managed worktree
  • keep Git strategy construction in worktree/git.ts and shared canonical directory validation in worktree/directory.ts
  • preserve V2 project resolution, Mercurial support, Bus projection, and durable session adoption behavior

Storage

  • add the worktree table for project roots and managed worktrees
  • copy every legacy project_directory row without deleting the old table
  • convert legacy git_worktree type and strategy values to the git strategy
  • retain the deprecated ProjectDirectoryTable definition for compatibility

API

  • add global GET, POST, and DELETE /api/experimental/project/:projectID/worktree
  • add POST /api/experimental/project/:projectID/worktree/refresh
  • remove Location query requirements and the old project directories endpoint
  • generate client.worktree.list/create/remove/refresh for Promise and Effect clients

Verification

  • Core typecheck and 77 focused project, session, worktree, schema-identity, and migration tests
  • Schema typecheck and public event-manifest tests
  • Protocol typecheck and generated OpenAPI check
  • Client typecheck and 22 Promise contract tests
  • Server typecheck and live Worktree HTTP integration test
  • CLI typecheck
  • TUI typecheck
  • SDK Next typecheck and contract identity tests
  • no changes under packages/opencode

@jlongster
jlongster changed the base branch from dev to v2 August 12, 2026 21:58
projectID: sync().data.project,
strategy: "git_worktree",
strategy: "git",
from: projectDirectory,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can remove from here right, it defauts to project's dir

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Made from optional and removed it here. Core now defaults to the project table’s primary worktree directory, then performs the same tracked-directory validation as an explicit from. The TUI still passes from explicitly when creating from the current managed worktree. Fixed in 659e6c7.

@jlongster
jlongster merged commit ad8ed9b into v2 Aug 13, 2026
8 checks passed
@jlongster
jlongster deleted the project-copy-api branch August 13, 2026 22:06
jinhuang712 pushed a commit to jinhuang712/opencode that referenced this pull request Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant