Added sharing config with auto/disabled options (#951)

Co-authored-by: opencode-agent[bot] <opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: thdxr <thdxr@users.noreply.github.com>
This commit is contained in:
opencode-agent[bot]
2025-07-13 16:43:58 -04:00
committed by GitHub
parent 177bfed93e
commit 736396fc70
3 changed files with 28 additions and 5 deletions

View File

@@ -117,7 +117,8 @@ export namespace Config {
$schema: z.string().optional().describe("JSON schema reference for configuration validation"),
theme: z.string().optional().describe("Theme name to use for the interface"),
keybinds: Keybinds.optional().describe("Custom keybind configurations"),
autoshare: z.boolean().optional().describe("Share newly created sessions automatically"),
share: z.enum(["auto", "disabled"]).optional().describe("Control sharing behavior: 'auto' enables automatic sharing, 'disabled' disables all sharing"),
autoshare: z.boolean().optional().describe("@deprecated Use 'share' field instead. Share newly created sessions automatically"),
autoupdate: z.boolean().optional().describe("Automatically update to the latest version"),
disabled_providers: z.array(z.string()).optional().describe("Disable providers that are loaded automatically"),
model: z.string().describe("Model to use in the format of provider/model, eg anthropic/claude-2").optional(),
@@ -232,6 +233,11 @@ export namespace Config {
const parsed = Info.safeParse(data)
if (parsed.success) {
// Handle migration from autoshare to share field
if (parsed.data.autoshare === true && !parsed.data.share) {
parsed.data.share = "auto"
}
if (!parsed.data.$schema) {
parsed.data.$schema = "https://opencode.ai/config.json"
await Bun.write(configPath, JSON.stringify(parsed.data, null, 2))
@@ -258,4 +264,6 @@ export namespace Config {
export function get() {
return state()
}
}