Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ opencode auth login

**除非用户特别要求,否则别乱动模型设置,也别关功能(Agent、Hook、MCP)。**

插件默认配置就是最佳实践。除了推荐开个 `google_auth: true`,其他的没让改就别手贱
该插件默认情况下运行良好。未使用外部 Antigravity 插件时保持 `google_auth: true`;如果按上方说明接入 `opencode-antigravity-auth`,请将 `google_auth` 设为 `false` 并覆盖智能体模型。除此之外,不要在没有明确请求的情况下更改其他设置或关闭功能

### 检查作业

Expand Down Expand Up @@ -545,8 +545,8 @@ OhMyOpenCode 让这些成为可能。

这些工具使 Agent 能够引用之前的对话并保持跨会话的连续性。

#### 上下文就是一切 (Context is all you need)
- **Directory AGENTS.md / README.md 注入器**:读文件时自动把 `AGENTS.md` 和 `README.md` 塞进去。从当前目录一路往上找,路径上**所有** `AGENTS.md` 全都带上。支持嵌套指令
#### 上下文就是一切
- **目录 AGENTS.md / README.md 注入器**:读取文件时自动注入 `AGENTS.md` 和 `README.md`。从文件目录向上遍历到项目根目录,收集路径上的**所有** `AGENTS.md` 文件。支持嵌套的目录特定说明
```
project/
├── AGENTS.md # 项目级规矩
Expand Down
45 changes: 45 additions & 0 deletions assets/oh-my-opencode.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -225,6 +228,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -348,6 +354,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -471,6 +480,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -594,6 +606,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -717,6 +732,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -840,6 +858,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -963,6 +984,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1086,6 +1110,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1209,6 +1236,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1332,6 +1362,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1455,6 +1488,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1578,6 +1614,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1701,6 +1740,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"category": {
"type": "string"
},
Expand Down Expand Up @@ -1831,6 +1873,9 @@
"model": {
"type": "string"
},
"variant": {
"type": "string"
},
"temperature": {
"type": "number",
"minimum": 0,
Expand Down
1 change: 1 addition & 0 deletions src/agents/explore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function createExploreAgent(model: string = DEFAULT_MODEL): AgentConfig {
mode: "subagent" as const,
model,
temperature: 0.1,
max_steps: 25,
...restrictions,
prompt: `You are a codebase search specialist. Your job: find files and code, return actionable results.

Expand Down
3 changes: 2 additions & 1 deletion src/agents/librarian.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export function createLibrarianAgent(model: string = DEFAULT_MODEL): AgentConfig
mode: "subagent" as const,
model,
temperature: 0.1,
tools: { write: false, edit: false, background_task: false },
max_steps: 30,
tools: { write: false, edit: false, background_task: false, task: false, sisyphus_task: false, call_omo_agent: false },
prompt: `# THE LIBRARIAN

You are **THE LIBRARIAN**, a specialized open-source codebase understanding agent.
Expand Down
1 change: 1 addition & 0 deletions src/agents/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export type AgentName = BuiltinAgentName

export type AgentOverrideConfig = Partial<AgentConfig> & {
prompt_append?: string
variant?: string
}

export type AgentOverrides = Partial<Record<OverridableAgentName, AgentOverrideConfig>>
25 changes: 25 additions & 0 deletions src/agents/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,31 @@ describe("buildAgent with category and skills", () => {
expect(agent.temperature).toBe(0.7)
})

test("agent with category inherits variant", () => {
// #given
const source = {
"test-agent": () =>
({
description: "Test agent",
category: "custom-category",
}) as AgentConfig,
}

const categories = {
"custom-category": {
model: "openai/gpt-5.2",
variant: "xhigh",
},
}

// #when
const agent = buildAgent(source["test-agent"], undefined, categories)

// #then
expect(agent.model).toBe("openai/gpt-5.2")
expect(agent.variant).toBe("xhigh")
})

test("agent with skills has content prepended to prompt", () => {
// #given
const source = {
Expand Down
26 changes: 21 additions & 5 deletions src/agents/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AgentConfig } from "@opencode-ai/sdk"
import type { BuiltinAgentName, AgentOverrideConfig, AgentOverrides, AgentFactory, AgentPromptMetadata } from "./types"
import type { CategoriesConfig, CategoryConfig } from "../config/schema"
import { createSisyphusAgent } from "./sisyphus"
import { createOracleAgent, ORACLE_PROMPT_METADATA } from "./oracle"
import { createLibrarianAgent, LIBRARIAN_PROMPT_METADATA } from "./librarian"
Expand Down Expand Up @@ -47,19 +48,29 @@ function isFactory(source: AgentSource): source is AgentFactory {
return typeof source === "function"
}

export function buildAgent(source: AgentSource, model?: string): AgentConfig {
export function buildAgent(
source: AgentSource,
model?: string,
categories?: CategoriesConfig
): AgentConfig {
const base = isFactory(source) ? source(model) : source
const categoryConfigs: Record<string, CategoryConfig> = categories
? { ...DEFAULT_CATEGORIES, ...categories }
: DEFAULT_CATEGORIES

const agentWithCategory = base as AgentConfig & { category?: string; skills?: string[] }
const agentWithCategory = base as AgentConfig & { category?: string; skills?: string[]; variant?: string }
if (agentWithCategory.category) {
const categoryConfig = DEFAULT_CATEGORIES[agentWithCategory.category]
const categoryConfig = categoryConfigs[agentWithCategory.category]
if (categoryConfig) {
if (!base.model) {
base.model = categoryConfig.model
}
if (base.temperature === undefined && categoryConfig.temperature !== undefined) {
base.temperature = categoryConfig.temperature
}
if (base.variant === undefined && categoryConfig.variant !== undefined) {
base.variant = categoryConfig.variant
}
}
}

Expand Down Expand Up @@ -118,11 +129,16 @@ export function createBuiltinAgents(
disabledAgents: BuiltinAgentName[] = [],
agentOverrides: AgentOverrides = {},
directory?: string,
systemDefaultModel?: string
systemDefaultModel?: string,
categories?: CategoriesConfig
): Record<string, AgentConfig> {
const result: Record<string, AgentConfig> = {}
const availableAgents: AvailableAgent[] = []

const mergedCategories = categories
? { ...DEFAULT_CATEGORIES, ...categories }
: DEFAULT_CATEGORIES

for (const [name, source] of Object.entries(agentSources)) {
const agentName = name as BuiltinAgentName

Expand All @@ -133,7 +149,7 @@ export function createBuiltinAgents(
const override = agentOverrides[agentName]
const model = override?.model

let config = buildAgent(source, model)
let config = buildAgent(source, model, mergedCategories)

if (agentName === "librarian" && directory && config.prompt) {
const envContext = createEnvContext()
Expand Down
Loading