GeezerVison is showing github.com — core: remove @effect/language-service plugin and optimize hot path ty… · Level0r0s/opencode@ff55a40
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: bun.lock -3Lines changed: 0 additions & 3 deletions Collapse file Copy file name to clipboardExpand all lines: packages/core/tsconfig.json +1-8Lines changed: 1 addition & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 2 | 2 | "$schema": "https://json.schemastore.org/tsconfig", | 3 | 3 | "extends": "@tsconfig/bun/tsconfig.json", | 4 | 4 | "compilerOptions": { | 5 | | - "noUncheckedIndexedAccess": false, | 6 | | - "plugins": [ | 7 | | - { | 8 | | - "name": "@effect/language-service", | 9 | | - "transform": "@effect/language-service/transform", | 10 | | - "namespaceImportPackages": ["effect", "@effect/*"] | 11 | | - } | 12 | | - ] | | 5 | + "noUncheckedIndexedAccess": false | 13 | 6 | } | 14 | 7 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/package.json -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | "license": "MIT", | 7 | 7 | "private": true, | 8 | 8 | "scripts": { | 9 | | - "prepare": "effect-language-service patch || true", | 10 | 9 | "typecheck": "tsgo --noEmit", | 11 | 10 | "test": "bun test --timeout 30000", | 12 | 11 | "test:ci": "mkdir -p .artifacts/unit && bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml", | | 42 | 41 | }, | 43 | 42 | "devDependencies": { | 44 | 43 | "@babel/core": "7.28.4", | 45 | | - "@effect/language-service": "0.84.2", | 46 | 44 | "@octokit/webhooks-types": "7.6.1", | 47 | 45 | "@opencode-ai/script": "workspace:*", | 48 | 46 | "@opencode-ai/core": "workspace:*", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/config/config.ts +12-9Lines changed: 12 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,7 @@ import path from "path" | 3 | 3 | import { pathToFileURL } from "url" | 4 | 4 | import os from "os" | 5 | 5 | import z from "zod" | 6 | | -import { mergeDeep, pipe } from "remeda" | | 6 | +import { mergeDeep } from "remeda" | 7 | 7 | import { Global } from "@opencode-ai/core/global" | 8 | 8 | import fsNode from "fs/promises" | 9 | 9 | import { NamedError } from "@opencode-ai/core/util/error" | @@ -47,8 +47,13 @@ import { Npm } from "@opencode-ai/core/npm" | 47 | 47 | const log = Log.create({ service: "config" }) | 48 | 48 |
| 49 | 49 | // Custom merge function that concatenates array fields instead of replacing them | | 50 | +// Keep remeda's deep conditional merge type out of hot config-loading paths; TS profiling showed it dominates here. | | 51 | +function mergeConfig(target: Info, source: Info): Info { | | 52 | + return mergeDeep(target, source) as Info | | 53 | +} | | 54 | + | 50 | 55 | function mergeConfigConcatArrays(target: Info, source: Info): Info { | 51 | | - const merged = mergeDeep(target, source) | | 56 | + const merged = mergeConfig(target, source) | 52 | 57 | if (target.instructions && source.instructions) { | 53 | 58 | merged.instructions = Array.from(new Set([...target.instructions, ...source.instructions])) | 54 | 59 | } | @@ -387,12 +392,10 @@ export const layer = Layer.effect( | 387 | 392 | }) | 388 | 393 |
| 389 | 394 | const loadGlobal = Effect.fnUntraced(function* () { | 390 | | - let result: Info = pipe( | 391 | | - {}, | 392 | | - mergeDeep(yield* loadFile(path.join(Global.Path.config, "config.json"))), | 393 | | - mergeDeep(yield* loadFile(path.join(Global.Path.config, "opencode.json"))), | 394 | | - mergeDeep(yield* loadFile(path.join(Global.Path.config, "opencode.jsonc"))), | 395 | | - ) | | 395 | + let result: Info = {} | | 396 | + result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "config.json"))) | | 397 | + result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.json"))) | | 398 | + result = mergeConfig(result, yield* loadFile(path.join(Global.Path.config, "opencode.jsonc"))) | 396 | 399 |
| 397 | 400 | const legacy = path.join(Global.Path.config, "config") | 398 | 401 | if (existsSync(legacy)) { | @@ -402,7 +405,7 @@ export const layer = Layer.effect( | 402 | 405 | const { provider, model, ...rest } = mod.default | 403 | 406 | if (provider && model) result.model = `${provider}/${model}` | 404 | 407 | result["$schema"] = "https://opencode.ai/config.json" | 405 | | - result = mergeDeep(result, rest) | | 408 | + result = mergeConfig(result, rest) | 406 | 409 | await fsNode.writeFile(path.join(Global.Path.config, "config.json"), JSON.stringify(result, null, 2)) | 407 | 410 | await fsNode.unlink(legacy) | 408 | 411 | }) | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/session/llm.ts +8-6Lines changed: 8 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,7 @@ import * as Log from "@opencode-ai/core/util/log" | 3 | 3 | import { Context, Effect, Layer, Record } from "effect" | 4 | 4 | import * as Stream from "effect/Stream" | 5 | 5 | import { streamText, wrapLanguageModel, type ModelMessage, type Tool, tool, jsonSchema } from "ai" | 6 | | -import { mergeDeep, pipe } from "remeda" | | 6 | +import { mergeDeep } from "remeda" | 7 | 7 | import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider" | 8 | 8 | import { ProviderTransform } from "@/provider/transform" | 9 | 9 | import { Config } from "@/config/config" | @@ -29,6 +29,10 @@ const log = Log.create({ service: "llm" }) | 29 | 29 | export const OUTPUT_TOKEN_MAX = ProviderTransform.OUTPUT_TOKEN_MAX | 30 | 30 | type Result = Awaited<ReturnType<typeof streamText>> | 31 | 31 |
| | 32 | +// Avoid re-instantiating remeda's deep merge types in this hot LLM path; the runtime behavior is still mergeDeep. | | 33 | +const mergeOptions = (target: Record<string, any>, source: Record<string, any> | undefined): Record<string, any> => | | 34 | + mergeDeep(target, source ?? {}) as Record<string, any> | | 35 | + | 32 | 36 | export type StreamInput = { | 33 | 37 | user: MessageV2.User | 34 | 38 | sessionID: string | @@ -134,11 +138,9 @@ const live: Layer.Layer< | 134 | 138 | sessionID: input.sessionID, | 135 | 139 | providerOptions: item.options, | 136 | 140 | }) | 137 | | - const options: Record<string, any> = pipe( | 138 | | - base, | 139 | | - mergeDeep(input.model.options), | 140 | | - mergeDeep(input.agent.options), | 141 | | - mergeDeep(variant), | | 141 | + const options = mergeOptions( | | 142 | + mergeOptions(mergeOptions(base, input.model.options), input.agent.options), | | 143 | + variant, | 142 | 144 | ) | 143 | 145 | if (isOpenaiOauth) { | 144 | 146 | options.instructions = system.join("\n") | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/storage/db.ts +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,6 +48,13 @@ type Client = SQLiteBunDatabase | 48 | 48 |
| 49 | 49 | type Journal = { sql: string; timestamp: number; name: string }[] | 50 | 50 |
| | 51 | +// Drizzle's migrate overloads trigger expensive variance checks here; narrow to the journal overload we actually use. | | 52 | +const migrateFromJournal = migrate as unknown as (db: SQLiteBunDatabase, entries: Journal) => void | | 53 | + | | 54 | +function applyMigrations(db: SQLiteBunDatabase, entries: Journal) { | | 55 | + migrateFromJournal(db, entries) | | 56 | +} | | 57 | + | 51 | 58 | function time(tag: string) { | 52 | 59 | const match = /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/.exec(tag) | 53 | 60 | if (!match) return 0 | @@ -108,7 +115,7 @@ export const Client = lazy(() => { | 108 | 115 | item.sql = "select 1;" | 109 | 116 | } | 110 | 117 | } | 111 | | - migrate(db, entries) | | 118 | + applyMigrations(db, entries) | 112 | 119 | } | 113 | 120 |
| 114 | 121 | return db | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/tsconfig.json +1-8Lines changed: 1 addition & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 12 | 12 | "@/*": ["./src/*"], | 13 | 13 | "@tui/*": ["./src/cli/cmd/tui/*"], | 14 | 14 | "@test/*": ["./test/*"] | 15 | | - }, | 16 | | - "plugins": [ | 17 | | - { | 18 | | - "name": "@effect/language-service", | 19 | | - "transform": "@effect/language-service/transform", | 20 | | - "namespaceImportPackages": ["effect", "@effect/*"] | 21 | | - } | 22 | | - ] | | 15 | + } | 23 | 16 | } | 24 | 17 | } |
|