The open source coding agent.
TypeScript
more
Dax Raad4767276a0e35
diff --git a/js/CONTEXT.md b/js/CONTEXT.mddeleted file mode 100644index 53a9fd46d92..00000000000--- a/js/CONTEXT.md+++ /dev/null@@ -1,27 +0,0 @@-# OpenCode Context--## Build/Test Commands--- `bun install` - Install dependencies-- `bun run index.ts` - Run the application-- `bun build src/index.ts --compile --outfile ./dist/opencode` - Build executable-- `bun test` - Run all tests-- `bun test <pattern>` - Run specific test files-- `bun test --test-name-pattern <regex>` - Run tests matching pattern--## Code Style & Conventions--- TypeScript with Bun runtime-- ES modules (`"type": "module"`)-- Namespace-based organization (e.g., `Tool.define`, `App.provide`)-- Zod for schema validation and type safety-- Async/await patterns throughout-- Structured logging with service-based loggers (`Log.create({ service: "name" })`)-- Tool pattern: define tools with `Tool.define()` wrapper for metadata/timing-- Context pattern: use `Context.create()` for dependency injection-- Import style: Node.js built-ins with `node:` prefix, relative imports with explicit extensions-- Error handling: try/catch with structured logging-- File organization: group by feature in `src/` with index files for exports-- Test files: co-located in `test/` directory, use Bun's built-in test runner-- Naming: camelCase for variables/functions, PascalCase for namespaces/types-diff --git a/js/OpenCode.md b/js/OpenCode.mddeleted file mode 100644index 7def6f8c736..00000000000--- a/js/OpenCode.md+++ /dev/null@@ -1,27 +0,0 @@-# OpenCode Context--## Build/Test Commands--- `bun install` - Install dependencies-- `bun run index.ts` - Run the application-- `bun build src/index.ts --compile --outfile ./dist/opencode` - Build executable-- `bun test` - Run all tests-- `bun test <pattern>` - Run specific test files-- `bun test --test-name-pattern <regex>` - Run tests matching pattern--## Code Style & Conventions--- TypeScript with Bun runtime-- ES modules (`"type": "module"`)-- Namespace-based organization (e.g., `Tool.define`, `App.provide`)-- Zod for schema validation and type safety-- Async/await patterns throughout-- Structured logging with service-based loggers (`Log.create({ service: "name" })`)-- Tool pattern: define tools with `Tool.define()` wrapper for metadata/timing-- Context pattern: use `Context.create()` for dependency injection-- Import style: Node.js built-ins with `node:` prefix, relative imports with explicit extensions-- Error handling: try/catch with structured logging-- File organization: group by feature in `src/` with index files for exports-- Test files: co-located in `test/` directory, use Bun's built-in test runner-- Naming: camelCase for variables/functions, PascalCase for namespaces/types-- **Variable declarations: Prefer `const` over `let` unless reassignment is necessary**\ No newline at end of filediff --git a/js/src/app/config.ts b/js/src/app/config.tsindex a3edbf889c2..3ebb8734bda 100644--- a/js/src/app/config.ts+++ b/js/src/app/config.ts@@ -15,8 +15,9 @@ export namespace Config {outputCached: z.number(),}),contextWindow: z.number(),- maxTokens: z.number(),+ maxTokens: z.number().optional(),attachment: z.boolean(),+ reasoning: z.boolean().optional(),});export type Model = z.output<typeof Model>;diff --git a/js/src/bun/index.ts b/js/src/bun/index.tsindex e921c825a8e..6eb6e1bdeba 100644--- a/js/src/bun/index.ts+++ b/js/src/bun/index.ts@@ -7,7 +7,10 @@ export namespace BunProc {cmd: string[],options?: Bun.SpawnOptions.OptionsObject<any, any, any>,) {- const root = path.resolve(process.cwd(), process.argv0);+ const root =+ process.argv0 !== "bun"+ ? path.resolve(process.cwd(), process.argv0)+ : process.argv0;log.info("running", {cmd: [root, ...cmd],options,diff --git a/js/src/index.ts b/js/src/index.tsindex 3758ad71877..1977f7c7d0a 100644--- a/js/src/index.ts+++ b/js/src/index.ts@@ -94,6 +94,7 @@ cliconst providers = await LLM.providers();const providerID = Object.keys(providers)[0];const modelID = Object.keys(providers[providerID].info.models!)[0];+ console.log("using", providerID, modelID);const result = await Session.chat({sessionID: session.id,providerID,diff --git a/js/src/llm/llm.ts b/js/src/llm/llm.tsindex e34030c507c..1f8f085673e 100644--- a/js/src/llm/llm.ts+++ b/js/src/llm/llm.ts@@ -35,10 +35,45 @@ export namespace LLM {},},},+ openai: {+ models: {+ "codex-mini-latest": {+ name: "Codex Mini",+ cost: {+ input: 1.5 / 1_000_000,+ inputCached: 0.375 / 1_000_000,+ output: 6.0 / 1_000_000,+ outputCached: 0.0 / 1_000_000,+ },+ contextWindow: 200000,+ maxTokens: 100000,+ attachment: true,+ reasoning: true,+ },+ },+ },+ google: {+ models: {+ "gemini-2.5-pro-preview-03-25": {+ name: "Gemini 2.5 Pro",+ cost: {+ input: 1.25 / 1_000_000,+ inputCached: 0 / 1_000_000,+ output: 10 / 1_000_000,+ outputCached: 0 / 1_000_000,+ },+ contextWindow: 1000000,+ maxTokens: 50000,+ attachment: true,+ },+ },+ },};const AUTODETECT: Record<string, string[]> = {anthropic: ["ANTHROPIC_API_KEY"],+ openai: ["OPENAI_API_KEY"],+ google: ["GOOGLE_GENERATIVE_AI_API_KEY"],};const state = App.state("llm", async (app) => {