Skip to content

Commit a2002c8

Browse files
committed
wip: update sdk
1 parent d8bcf4f commit a2002c8

8 files changed

Lines changed: 62 additions & 45 deletions

File tree

opencode.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"$schema": "https://opencode.ai/config.json",
3-
"username": "testuser",
43
"mcp": {
54
"weather": {
65
"type": "local",

packages/opencode/src/app/app.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export namespace App {
1212

1313
export const Info = z
1414
.object({
15-
user: z.string(),
1615
hostname: z.string(),
1716
git: z.boolean(),
1817
path: z.object({
@@ -69,12 +68,7 @@ export namespace App {
6968

7069
const root = git ?? input.cwd
7170

72-
// Load config to get custom username if set
73-
const { Config } = await import("../config/config")
74-
const config = await Config.global()
75-
7671
const info: Info = {
77-
user: config.username || os.userInfo().username,
7872
hostname: os.hostname(),
7973
time: {
8074
initialized: state.initialized,

packages/opencode/src/config/config.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ export namespace Config {
2121
result = mergeDeep(result, await load(resolved))
2222
}
2323
}
24+
25+
// Handle migration from autoshare to share field
26+
if (result.autoshare === true && !result.share) {
27+
result.share = "auto"
28+
}
29+
30+
if (!result.username) {
31+
const os = await import("os")
32+
result.username = os.userInfo().username
33+
}
34+
2435
log.info("loaded", result)
2536

2637
return result
@@ -117,12 +128,21 @@ export namespace Config {
117128
$schema: z.string().optional().describe("JSON schema reference for configuration validation"),
118129
theme: z.string().optional().describe("Theme name to use for the interface"),
119130
keybinds: Keybinds.optional().describe("Custom keybind configurations"),
120-
share: z.enum(["auto", "disabled"]).optional().describe("Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables all sharing"),
121-
autoshare: z.boolean().optional().describe("@deprecated Use 'share' field instead. Share newly created sessions automatically"),
131+
share: z
132+
.enum(["auto", "disabled"])
133+
.optional()
134+
.describe("Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables all sharing"),
135+
autoshare: z
136+
.boolean()
137+
.optional()
138+
.describe("@deprecated Use 'share' field instead. Share newly created sessions automatically"),
122139
autoupdate: z.boolean().optional().describe("Automatically update to the latest version"),
123140
disabled_providers: z.array(z.string()).optional().describe("Disable providers that are loaded automatically"),
124141
model: z.string().describe("Model to use in the format of provider/model, eg anthropic/claude-2").optional(),
125-
username: z.string().optional().describe("Custom username to display in conversations instead of system username"),
142+
username: z
143+
.string()
144+
.optional()
145+
.describe("Custom username to display in conversations instead of system username"),
126146
mode: z
127147
.object({
128148
build: Mode.optional(),
@@ -234,11 +254,6 @@ export namespace Config {
234254

235255
const parsed = Info.safeParse(data)
236256
if (parsed.success) {
237-
// Handle migration from autoshare to share field
238-
if (parsed.data.autoshare === true && !parsed.data.share) {
239-
parsed.data.share = "auto"
240-
}
241-
242257
if (!parsed.data.$schema) {
243258
parsed.data.$schema = "https://opencode.ai/config.json"
244259
await Bun.write(configPath, JSON.stringify(parsed.data, null, 2))
@@ -265,6 +280,4 @@ export namespace Config {
265280
export function get() {
266281
return state()
267282
}
268-
269-
270283
}

packages/tui/AGENTS.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
# TUI Agent Guidelines
22

3-
## Build/Test Commands
3+
## Style
44

5-
- **Build**: `go build ./cmd/opencode` (builds main binary)
6-
- **Test**: `go test ./...` (runs all tests)
7-
- **Single test**: `go test ./internal/theme -run TestLoadThemesFromJSON` (specific test)
8-
- **Release build**: Uses `.goreleaser.yml` configuration
5+
- prefer single word variable names
6+
- avoid try catch where possible - prefer to let exceptions bubble up
7+
- avoid else statements where possible
8+
- prefer Bun apis
99

10-
## Code Style
10+
## Workflow
1111

12-
- **Language**: Go 1.24+ with standard formatting (`gofmt`)
13-
- **Imports**: Group standard, third-party, local packages with blank lines
14-
- **Naming**: Go conventions - PascalCase exports, camelCase private, ALL_CAPS constants
15-
- **Error handling**: Return errors explicitly, use `fmt.Errorf` for wrapping
16-
- **Structs**: Define clear interfaces, embed when appropriate
17-
- **Testing**: Use table-driven tests, `t.TempDir()` for file operations
18-
19-
## Architecture
20-
21-
- **TUI Framework**: Bubble Tea v2 with Lipgloss v2 for styling
22-
- **Client**: Generated OpenAPI client communicates with TypeScript server
23-
- **Components**: Reusable UI components in `internal/components/`
24-
- **Themes**: JSON-based theming system with override hierarchy
25-
- **State**: Centralized app state with message passing
12+
- you can regenerate the golang sdk by calling ./scripts/stainless.ts
13+
- we use bun for everything

packages/tui/internal/components/chat/messages.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ func (m *messagesComponent) renderView(width int) {
190190
m.app,
191191
message.Info,
192192
part.Text,
193-
m.app.Info.User,
193+
m.app.Config.Username,
194194
m.showToolDetails,
195195
m.partCount == m.selectedPart,
196196
width,

packages/tui/sdk/.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 22
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-352994eb17f76d9472b0f0176efacf77a200a6fab2db28d1cfcd29451b211d7a.yml
3-
openapi_spec_hash: f01cd3de8c7cf0c9fd513896e81986de
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/opencode%2Fopencode-9bdc593eab163d2165321716af6a4c13253792ad409420790ed6196da4178d3a.yml
3+
openapi_spec_hash: c687f53ada739d315e2e7056df93d999
44
config_hash: 3695cfc829cfaae14490850b4a1ed282

packages/tui/sdk/app.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ type App struct {
6868
Hostname string `json:"hostname,required"`
6969
Path AppPath `json:"path,required"`
7070
Time AppTime `json:"time,required"`
71-
User string `json:"user,required"`
7271
JSON appJSON `json:"-"`
7372
}
7473

@@ -78,7 +77,6 @@ type appJSON struct {
7877
Hostname apijson.Field
7978
Path apijson.Field
8079
Time apijson.Field
81-
User apijson.Field
8280
raw string
8381
ExtraFields map[string]apijson.Field
8482
}

packages/tui/sdk/config.go

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ func (r *ConfigService) Providers(ctx context.Context, opts ...option.RequestOpt
5151
type Config struct {
5252
// JSON schema reference for configuration validation
5353
Schema string `json:"$schema"`
54-
// Share newly created sessions automatically
54+
// @deprecated Use 'share' field instead. Share newly created sessions
55+
// automatically
5556
Autoshare bool `json:"autoshare"`
5657
// Automatically update to the latest version
5758
Autoupdate bool `json:"autoupdate"`
@@ -71,9 +72,14 @@ type Config struct {
7172
Model string `json:"model"`
7273
// Custom provider configurations and model overrides
7374
Provider map[string]ConfigProvider `json:"provider"`
75+
// Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
76+
// all sharing
77+
Share ConfigShare `json:"share"`
7478
// Theme name to use for the interface
75-
Theme string `json:"theme"`
76-
JSON configJSON `json:"-"`
79+
Theme string `json:"theme"`
80+
// Custom username to display in conversations instead of system username
81+
Username string `json:"username"`
82+
JSON configJSON `json:"-"`
7783
}
7884

7985
// configJSON contains the JSON metadata for the struct [Config]
@@ -90,7 +96,9 @@ type configJSON struct {
9096
Mode apijson.Field
9197
Model apijson.Field
9298
Provider apijson.Field
99+
Share apijson.Field
93100
Theme apijson.Field
101+
Username apijson.Field
94102
raw string
95103
ExtraFields map[string]apijson.Field
96104
}
@@ -470,6 +478,23 @@ func (r configProviderModelsLimitJSON) RawJSON() string {
470478
return r.raw
471479
}
472480

481+
// Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables
482+
// all sharing
483+
type ConfigShare string
484+
485+
const (
486+
ConfigShareAuto ConfigShare = "auto"
487+
ConfigShareDisabled ConfigShare = "disabled"
488+
)
489+
490+
func (r ConfigShare) IsKnown() bool {
491+
switch r {
492+
case ConfigShareAuto, ConfigShareDisabled:
493+
return true
494+
}
495+
return false
496+
}
497+
473498
type Keybinds struct {
474499
// Exit the application
475500
AppExit string `json:"app_exit,required"`

0 commit comments

Comments
 (0)