summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md64
-rw-r--r--bun.lock1
-rw-r--r--packages/opencode/config.schema.json139
-rw-r--r--packages/opencode/package.json6
-rwxr-xr-xpackages/opencode/script/schema.ts8
-rw-r--r--packages/opencode/src/cli/cmd/generate.ts1
-rw-r--r--packages/opencode/src/config/config.ts5
-rw-r--r--packages/opencode/src/provider/provider.ts2
8 files changed, 196 insertions, 30 deletions
diff --git a/README.md b/README.md
index 8f455309d..d2ba219e4 100644
--- a/README.md
+++ b/README.md
@@ -2,39 +2,57 @@
AI coding agent, built for the terminal.
-Note: version 0.1.x is a full rewrite and we do not have proper documentation for it yet. Should have this out week of June 17th 2025
+⚠️ **Note:** version 0.1.x is a full rewrite and we do not have proper documentation for it yet. Should have this out week of June 17th 2025 📚
-## Installation
+### Installation
-If you have a previous version of opencode < 0.1.x installed you might have to remove it first.
-
-### Curl
-
-```
+```bash
+# YOLO
curl -fsSL https://opencode.ai/install | bash
+
+# Package managers
+npm i -g opencode-ai@latest # or bun/pnpm/yarn
+brew install sst/tap/opencode # macOS
+paru -S opencode-bin # Arch Linux
```
-### NPM
+> **Note:** Remove previous versions < 0.1.x first if installed
-```
-npm i -g opencode-ai@latest
-bun i -g opencode-ai@latest
-pnpm i -g opencode-ai@latest
-yarn global add opencode-ai@latest
-```
+### Providers
-### Brew
+The recommended approach is to sign up for claude pro or max and do `opencode auth login` and select Anthropic. It is the most cost effective way to use this tool.
-```
-brew install sst/tap/opencode
-```
+Additionally opencode is powered by the provider list at [models.dev](https://models.dev) so you can use `opencode auth login` to configure api keys for any provider you'd like to use. This is stored in `~/.local/share/opencode/auth.json`
-### AUR
+```bash
+$ opencode auth login
+┌ Add credential
+│
+◆ Select provider
+│ ● Anthropic (recommended)
+│ ○ OpenAI
+│ ○ Google
+│ ○ Amazon Bedrock
+│ ○ Azure
+│ ○ DeepSeek
+│ ○ Groq
+│ ...
+└
```
-paru -S opencode-bin
-```
-## Usage
+The models.dev dataset is also used to detect common environment variables like `OPENAI_API_KEY` to autoload that provider.
+
+If there are additional providers you want to use you can submit a PR to the [models.dev repo](https://github.com/sst/models.dev). If configuring just for yourself check out the Config section below
+
+### Project Config
+
+Project configuration is optional. You can place an `opencode.json` file in the root of your repo and it will be loaded.
+
+```json title="opencode.json"
+{
+ "$schema": "https://opencode.ai/schemas/opencode.json"
+}
+```
-We are working on proper keybinds - right now it's the various function keys press F1 to see them
+#### MCP
diff --git a/bun.lock b/bun.lock
index 9ad6009f0..f2547af40 100644
--- a/bun.lock
+++ b/bun.lock
@@ -50,6 +50,7 @@
"@types/turndown": "5.0.5",
"@types/yargs": "17.0.33",
"typescript": "catalog:",
+ "zod-to-json-schema": "3.24.5",
},
},
"packages/web": {
diff --git a/packages/opencode/config.schema.json b/packages/opencode/config.schema.json
new file mode 100644
index 000000000..50f293032
--- /dev/null
+++ b/packages/opencode/config.schema.json
@@ -0,0 +1,139 @@
+{
+ "type": "object",
+ "properties": {
+ "provider": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "env": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "id": {
+ "type": "string"
+ },
+ "models": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "object",
+ "properties": {
+ "name": {
+ "type": "string"
+ },
+ "attachment": {
+ "type": "boolean"
+ },
+ "reasoning": {
+ "type": "boolean"
+ },
+ "temperature": {
+ "type": "boolean"
+ },
+ "cost": {
+ "type": "object",
+ "properties": {
+ "input": {
+ "type": "number"
+ },
+ "output": {
+ "type": "number"
+ },
+ "inputCached": {
+ "type": "number"
+ },
+ "outputCached": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "input",
+ "output",
+ "inputCached",
+ "outputCached"
+ ],
+ "additionalProperties": false
+ },
+ "limit": {
+ "type": "object",
+ "properties": {
+ "context": {
+ "type": "number"
+ },
+ "output": {
+ "type": "number"
+ }
+ },
+ "required": ["context", "output"],
+ "additionalProperties": false
+ },
+ "id": {
+ "type": "string"
+ }
+ },
+ "additionalProperties": false
+ }
+ },
+ "options": {
+ "type": "object",
+ "additionalProperties": {}
+ }
+ },
+ "required": ["models"],
+ "additionalProperties": false
+ }
+ },
+ "mcp": {
+ "type": "object",
+ "additionalProperties": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "local"
+ },
+ "command": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ }
+ },
+ "environment": {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ }
+ },
+ "required": ["type", "command"],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "type": {
+ "type": "string",
+ "const": "remote"
+ },
+ "url": {
+ "type": "string"
+ }
+ },
+ "required": ["type", "url"],
+ "additionalProperties": false
+ }
+ ]
+ }
+ }
+ },
+ "additionalProperties": false,
+ "$schema": "http://json-schema.org/draft-07/schema#"
+}
+
diff --git a/packages/opencode/package.json b/packages/opencode/package.json
index 7f99ad27d..1f732ecb1 100644
--- a/packages/opencode/package.json
+++ b/packages/opencode/package.json
@@ -5,7 +5,8 @@
"type": "module",
"private": true,
"scripts": {
- "typecheck": "tsc --noEmit"
+ "typecheck": "tsc --noEmit",
+ "dev": "bun run ./src/index.ts"
},
"exports": {
"./*": [
@@ -18,7 +19,8 @@
"@types/bun": "latest",
"@types/turndown": "5.0.5",
"@types/yargs": "17.0.33",
- "typescript": "catalog:"
+ "typescript": "catalog:",
+ "zod-to-json-schema": "3.24.5"
},
"dependencies": {
"@clack/prompts": "0.11.0",
diff --git a/packages/opencode/script/schema.ts b/packages/opencode/script/schema.ts
new file mode 100755
index 000000000..1c0067c71
--- /dev/null
+++ b/packages/opencode/script/schema.ts
@@ -0,0 +1,8 @@
+#!/usr/bin/env bun
+
+import "zod-openapi/extend"
+import { Config } from "../src/config/config"
+import { zodToJsonSchema } from "zod-to-json-schema"
+
+const result = zodToJsonSchema(Config.Info)
+await Bun.write("config.schema.json", JSON.stringify(result, null, 2))
diff --git a/packages/opencode/src/cli/cmd/generate.ts b/packages/opencode/src/cli/cmd/generate.ts
index 0cef10772..2e7dcf8df 100644
--- a/packages/opencode/src/cli/cmd/generate.ts
+++ b/packages/opencode/src/cli/cmd/generate.ts
@@ -2,6 +2,7 @@ import { Server } from "../../server/server"
import fs from "fs/promises"
import path from "path"
import type { CommandModule } from "yargs"
+import { Config } from "../../config/config"
export const GenerateCommand = {
command: "generate",
diff --git a/packages/opencode/src/config/config.ts b/packages/opencode/src/config/config.ts
index c0da6ee6c..e4bb310b0 100644
--- a/packages/opencode/src/config/config.ts
+++ b/packages/opencode/src/config/config.ts
@@ -58,11 +58,6 @@ export namespace Config {
}),
)
.optional(),
- tool: z
- .object({
- provider: z.record(z.string(), z.string().array()).optional(),
- })
- .optional(),
mcp: z.record(z.string(), Mcp).optional(),
})
.strict()
diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts
index da6fd8566..3e96571ef 100644
--- a/packages/opencode/src/provider/provider.ts
+++ b/packages/opencode/src/provider/provider.ts
@@ -289,11 +289,13 @@ export namespace Provider {
google: TOOLS,
}
export async function tools(providerID: string) {
+ /*
const cfg = await Config.get()
if (cfg.tool?.provider?.[providerID])
return cfg.tool.provider[providerID].map(
(id) => TOOLS.find((t) => t.id === id)!,
)
+ */
return TOOL_MAPPING[providerID] ?? TOOLS
}