Skip to content

Commit 68381a8

Browse files
nexxelnrustybret
authored andcommitted
refactor(flags): migrate external skills flag (anomalyco#27685)
1 parent ef9e5c1 commit 68381a8

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

packages/core/src/flag/flag.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ function truthy(key: string) {
66
}
77

88
const OPENCODE_EXPERIMENTAL = truthy("OPENCODE_EXPERIMENTAL")
9+
const OPENCODE_DISABLE_CLAUDE_CODE = truthy("OPENCODE_DISABLE_CLAUDE_CODE")
910
const copy = process.env["OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT"]
1011

1112
export const Flag = {
@@ -22,14 +23,20 @@ export const Flag = {
2223
OPENCODE_DISABLE_TERMINAL_TITLE: truthy("OPENCODE_DISABLE_TERMINAL_TITLE"),
2324
OPENCODE_SHOW_TTFD: truthy("OPENCODE_SHOW_TTFD"),
2425
OPENCODE_PERMISSION: process.env["OPENCODE_PERMISSION"],
26+
OPENCODE_DISABLE_DEFAULT_PLUGINS: truthy("OPENCODE_DISABLE_DEFAULT_PLUGINS"),
27+
OPENCODE_DISABLE_LSP_DOWNLOAD: truthy("OPENCODE_DISABLE_LSP_DOWNLOAD"),
2528
OPENCODE_DISABLE_AUTOCOMPACT: truthy("OPENCODE_DISABLE_AUTOCOMPACT"),
2629
OPENCODE_DISABLE_MODELS_FETCH: truthy("OPENCODE_DISABLE_MODELS_FETCH"),
2730
OPENCODE_DISABLE_MOUSE: truthy("OPENCODE_DISABLE_MOUSE"),
31+
OPENCODE_DISABLE_CLAUDE_CODE,
32+
OPENCODE_DISABLE_CLAUDE_CODE_PROMPT: OPENCODE_DISABLE_CLAUDE_CODE || truthy("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT"),
2833
OPENCODE_FAKE_VCS: process.env["OPENCODE_FAKE_VCS"],
2934
OPENCODE_SERVER_PASSWORD: process.env["OPENCODE_SERVER_PASSWORD"],
3035
OPENCODE_SERVER_USERNAME: process.env["OPENCODE_SERVER_USERNAME"],
36+
OPENCODE_ENABLE_QUESTION_TOOL: truthy("OPENCODE_ENABLE_QUESTION_TOOL"),
3137

3238
// Experimental
39+
OPENCODE_EXPERIMENTAL,
3340
OPENCODE_EXPERIMENTAL_FILEWATCHER: Config.boolean("OPENCODE_EXPERIMENTAL_FILEWATCHER").pipe(
3441
Config.withDefault(false),
3542
),
@@ -38,12 +45,21 @@ export const Flag = {
3845
),
3946
OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT:
4047
copy === undefined ? process.platform === "win32" : truthy("OPENCODE_EXPERIMENTAL_DISABLE_COPY_ON_SELECT"),
48+
OPENCODE_ENABLE_EXA: truthy("OPENCODE_ENABLE_EXA") || OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_EXA"),
49+
OPENCODE_EXPERIMENTAL_LSP_TOOL: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_LSP_TOOL"),
50+
OPENCODE_EXPERIMENTAL_PLAN_MODE: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_PLAN_MODE"),
51+
OPENCODE_EXPERIMENTAL_SCOUT: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_SCOUT"),
52+
OPENCODE_ENABLE_PARALLEL: truthy("OPENCODE_ENABLE_PARALLEL") || truthy("OPENCODE_EXPERIMENTAL_PARALLEL"),
4153
OPENCODE_MODELS_URL: process.env["OPENCODE_MODELS_URL"],
4254
OPENCODE_MODELS_PATH: process.env["OPENCODE_MODELS_PATH"],
4355
OPENCODE_DB: process.env["OPENCODE_DB"],
56+
OPENCODE_SKIP_MIGRATIONS: truthy("OPENCODE_SKIP_MIGRATIONS"),
57+
OPENCODE_STRICT_CONFIG_DEPS: truthy("OPENCODE_STRICT_CONFIG_DEPS"),
4458

4559
OPENCODE_WORKSPACE_ID: process.env["OPENCODE_WORKSPACE_ID"],
4660
OPENCODE_EXPERIMENTAL_WORKSPACES: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_WORKSPACES"),
61+
OPENCODE_EXPERIMENTAL_EVENT_SYSTEM: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_EVENT_SYSTEM"),
62+
OPENCODE_EXPERIMENTAL_SESSION_SWITCHING: OPENCODE_EXPERIMENTAL || truthy("OPENCODE_EXPERIMENTAL_SESSION_SWITCHING"),
4763

4864
// Evaluated at access time (not module load) because tests, the CLI, and
4965
// external tooling set these env vars at runtime.

packages/opencode/src/skill/index.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { NamedError } from "@opencode-ai/core/util/error"
55
import type { Agent } from "@/agent/agent"
66
import { Bus } from "@/bus"
77
import { InstanceState } from "@/effect/instance-state"
8-
import { Flag } from "@opencode-ai/core/flag/flag"
98
import { Global } from "@opencode-ai/core/global"
109
import { Permission } from "@/permission"
1110
import { AppFileSystem } from "@opencode-ai/core/filesystem"
@@ -14,7 +13,6 @@ import { ConfigMarkdown } from "@/config/markdown"
1413
import { RuntimeFlags } from "@/effect/runtime-flags"
1514
import { Glob } from "@opencode-ai/core/util/glob"
1615
import * as Log from "@opencode-ai/core/util/log"
17-
import { Plugin } from "@/plugin"
1816
import { Discovery } from "./discovery"
1917
import CUSTOMIZE_OPENCODE_SKILL_BODY from "./prompt/customize-opencode.md" with { type: "text" }
2018
import { isRecord } from "@/util/record"
@@ -167,14 +165,15 @@ const discoverSkills = Effect.fnUntraced(function* (
167165
discovery: Discovery.Interface,
168166
fsys: AppFileSystem.Interface,
169167
global: Global.Interface,
168+
disableExternalSkills: boolean,
170169
disableClaudeCodeSkills: boolean,
171170
directory: string,
172171
worktree: string,
173172
) {
174173
const state: ScanState = { matches: new Set(), dirs: new Set() }
175174

176175
const externalDirs: string[] = []
177-
if (!Flag.OPENCODE_DISABLE_EXTERNAL_SKILLS) {
176+
if (!disableExternalSkills) {
178177
if (!disableClaudeCodeSkills) externalDirs.push(CLAUDE_EXTERNAL_DIR)
179178
externalDirs.push(AGENTS_EXTERNAL_DIR)
180179

@@ -242,18 +241,19 @@ export const layer = Layer.effect(
242241
const bus = yield* Bus.Service
243242
const fsys = yield* AppFileSystem.Service
244243
const global = yield* Global.Service
245-
const flags = yield* RuntimeFlags.Service
246-
const discovered = yield* InstanceState.make(
247-
Effect.fn("Skill.discovery")(function* (ctx) {
248-
return yield* discoverSkills(
249-
config,
250-
discovery,
251-
fsys,
252-
global,
253-
flags.disableClaudeCodeSkills,
254-
ctx.directory,
255-
ctx.worktree,
256-
)
244+
const flags = yield* RuntimeFlags.Service
245+
const discovered = yield* InstanceState.make(
246+
Effect.fn("Skill.discovery")(function* (ctx) {
247+
return yield* discoverSkills(
248+
config,
249+
discovery,
250+
fsys,
251+
global,
252+
flags.disableExternalSkills,
253+
flags.disableClaudeCodeSkills,
254+
ctx.directory,
255+
ctx.worktree,
256+
)
257257
}),
258258
)
259259
const state = yield* InstanceState.make(
@@ -299,7 +299,6 @@ const flags = yield* RuntimeFlags.Service
299299

300300
export const defaultLayer = layer.pipe(
301301
Layer.provide(Discovery.defaultLayer),
302-
Layer.provide(Plugin.defaultLayer),
303302
Layer.provide(Config.defaultLayer),
304303
Layer.provide(Bus.layer),
305304
Layer.provide(AppFileSystem.defaultLayer),

0 commit comments

Comments
 (0)