Refactor to support multiple instances inside single opencode process (#2360)

This release has a bunch of minor breaking changes if you are using opencode plugins or sdk

1. storage events have been removed (we might bring this back but had some issues)
2. concept of `app` is gone - there is a new concept called `project` and endpoints to list projects and get the current project
3. plugin receives `directory` which is cwd and `worktree` which is where the root of the project is if it's a git repo
4. the session.chat function has been renamed to session.prompt in sdk. it no longer requires model to be passed in (model is now an object)
5. every endpoint takes an optional `directory` parameter to operate as though opencode is running in that directory
This commit is contained in:
Dax
2025-09-01 17:15:49 -04:00
committed by GitHub
parent e2df3eb44d
commit f993541e0b
112 changed files with 4303 additions and 3159 deletions

View File

@@ -13,8 +13,8 @@ import (
"github.com/sst/opencode-sdk-go/option"
)
func TestTuiAppendPrompt(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiAppendPromptWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -26,7 +26,8 @@ func TestTuiAppendPrompt(t *testing.T) {
option.WithBaseURL(baseURL),
)
_, err := client.Tui.AppendPrompt(context.TODO(), opencode.TuiAppendPromptParams{
Text: opencode.F("text"),
Text: opencode.F("text"),
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
@@ -37,8 +38,8 @@ func TestTuiAppendPrompt(t *testing.T) {
}
}
func TestTuiClearPrompt(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiClearPromptWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -49,7 +50,9 @@ func TestTuiClearPrompt(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.ClearPrompt(context.TODO())
_, err := client.Tui.ClearPrompt(context.TODO(), opencode.TuiClearPromptParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {
@@ -59,8 +62,8 @@ func TestTuiClearPrompt(t *testing.T) {
}
}
func TestTuiExecuteCommand(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiExecuteCommandWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -72,7 +75,8 @@ func TestTuiExecuteCommand(t *testing.T) {
option.WithBaseURL(baseURL),
)
_, err := client.Tui.ExecuteCommand(context.TODO(), opencode.TuiExecuteCommandParams{
Command: opencode.F("command"),
Command: opencode.F("command"),
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
@@ -83,8 +87,8 @@ func TestTuiExecuteCommand(t *testing.T) {
}
}
func TestTuiOpenHelp(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiOpenHelpWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -95,7 +99,9 @@ func TestTuiOpenHelp(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.OpenHelp(context.TODO())
_, err := client.Tui.OpenHelp(context.TODO(), opencode.TuiOpenHelpParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {
@@ -105,8 +111,8 @@ func TestTuiOpenHelp(t *testing.T) {
}
}
func TestTuiOpenModels(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiOpenModelsWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -117,7 +123,9 @@ func TestTuiOpenModels(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.OpenModels(context.TODO())
_, err := client.Tui.OpenModels(context.TODO(), opencode.TuiOpenModelsParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {
@@ -127,8 +135,8 @@ func TestTuiOpenModels(t *testing.T) {
}
}
func TestTuiOpenSessions(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiOpenSessionsWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -139,7 +147,9 @@ func TestTuiOpenSessions(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.OpenSessions(context.TODO())
_, err := client.Tui.OpenSessions(context.TODO(), opencode.TuiOpenSessionsParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {
@@ -149,8 +159,8 @@ func TestTuiOpenSessions(t *testing.T) {
}
}
func TestTuiOpenThemes(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiOpenThemesWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -161,7 +171,9 @@ func TestTuiOpenThemes(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.OpenThemes(context.TODO())
_, err := client.Tui.OpenThemes(context.TODO(), opencode.TuiOpenThemesParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {
@@ -172,7 +184,7 @@ func TestTuiOpenThemes(t *testing.T) {
}
func TestTuiShowToastWithOptionalParams(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -184,9 +196,10 @@ func TestTuiShowToastWithOptionalParams(t *testing.T) {
option.WithBaseURL(baseURL),
)
_, err := client.Tui.ShowToast(context.TODO(), opencode.TuiShowToastParams{
Message: opencode.F("message"),
Variant: opencode.F(opencode.TuiShowToastParamsVariantInfo),
Title: opencode.F("title"),
Message: opencode.F("message"),
Variant: opencode.F(opencode.TuiShowToastParamsVariantInfo),
Directory: opencode.F("directory"),
Title: opencode.F("title"),
})
if err != nil {
var apierr *opencode.Error
@@ -197,8 +210,8 @@ func TestTuiShowToastWithOptionalParams(t *testing.T) {
}
}
func TestTuiSubmitPrompt(t *testing.T) {
t.Skip("skipped: tests are disabled for the time being")
func TestTuiSubmitPromptWithOptionalParams(t *testing.T) {
t.Skip("Prism tests are disabled")
baseURL := "http://localhost:4010"
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
baseURL = envURL
@@ -209,7 +222,9 @@ func TestTuiSubmitPrompt(t *testing.T) {
client := opencode.NewClient(
option.WithBaseURL(baseURL),
)
_, err := client.Tui.SubmitPrompt(context.TODO())
_, err := client.Tui.SubmitPrompt(context.TODO(), opencode.TuiSubmitPromptParams{
Directory: opencode.F("directory"),
})
if err != nil {
var apierr *opencode.Error
if errors.As(err, &apierr) {