forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Summary
This feature implements a comprehensive project management API that allows a single instance of Opencode to run sessions for multiple projects and different worktrees per project.
Context
The current Opencode instance manages sessions for a single project directory. This spec defines a new API structure to support multiple projects with multiple worktrees each, providing proper isolation and management capabilities.
Note: Some aspects are partially covered by issue anomalyco#1877 which proposes root folder aggregation and cwd metadata for sessions.
Requirements
API Implementation
Implement the following REST API endpoints:
GET /project -> Project[]
POST /project/init -> Project
GET /project/:projectID/session -> Session[]
GET /project/:projectID/session/:sessionID -> Session
POST /project/:projectID/session -> Session
{
id?: string
parentID?: string
directory: string
}
DELETE /project/:projectID/session/:sessionID
POST /project/:projectID/session/:sessionID/init
POST /project/:projectID/session/:sessionID/abort
POST /project/:projectID/session/:sessionID/share
DELETE /project/:projectID/session/:sessionID/share
POST /project/:projectID/session/:sessionID/compact
GET /project/:projectID/session/:sessionID/message -> { info: Message, parts: Part[] }[]
GET /project/:projectID/session/:sessionID/message/:messageID -> { info: Message, parts: Part[] }
POST /project/:projectID/session/:sessionID/message -> { info: Message, parts: Part[] }
POST /project/:projectID/session/:sessionID/revert -> Session
POST /project/:projectID/session/:sessionID/unrevert -> Session
POST /project/:projectID/session/:sessionID/permission/:permissionID -> Session
GET /project/:projectID/session/:sessionID/find/file -> string[]
GET /project/:projectID/session/:sessionID/file -> { type: "raw" | "patch", content: string }
GET /project/:projectID/session/:sessionID/file/status -> File[]
POST /log
// Provider and config endpoints with directory resolution
GET /provider?directory=<resolve path> -> Provider
GET /config?directory=<resolve path> -> Config
GET /project/:projectID/agent?directory=<resolve path> -> Agent
GET /project/:projectID/find/file?directory=<resolve path> -> File
Key Features
- Project Isolation: Each project maintains its own session namespace and configuration
- Worktree Support: Sessions can be created for different working directories within a project
- Session Management: Full CRUD operations for sessions within each project context
- File Operations: File access and status operations scoped to project/session contexts
- Directory Resolution: Provider, config, and agent endpoints support directory-based resolution
Definition of Done
- All API endpoints implemented with proper request/response validation
- Project and session data models implemented with appropriate persistence layer
- Directory resolution logic handles cross-project path references correctly
- Session isolation between projects is maintained
- Integration with existing Opencode CLI and TUI interfaces
- Comprehensive test coverage for all endpoints and edge cases
- Documentation for API usage and migration from single-project setup
Related Issues
- Partial overlap with Support a root folder for aggregating sessions across subdirectories in Opencode anomalyco/opencode#1877 (root folder aggregation and cwd metadata)
Metadata
Metadata
Assignees
Labels
No labels