feat(agents): wire agent_definitions and opencode.json agents into precedence chain
- Modified agent-config-handler.ts to load and integrate both new agent sources - Added loadAgentDefinitions() and readOpencodeConfigAgents() calls in loading phase - Integrated both sources into agent precedence chains (both Sisyphus-enabled and disabled paths) - Added detailed logging for new agent sources - Added filtering logic to respect disabled_agents configuration - Extended agent-config-handler.test.ts with 7 new integration tests - All tests passing (18/18 integration, 65/65 loader suite) Wave 3 of agent definitions enhancement complete.
This commit is contained in:
committed by
YeonGyu-Kim
parent
5755a90c3b
commit
39bda91bc7
@@ -1,2 +1,5 @@
|
||||
export * from "./types"
|
||||
export * from "./loader"
|
||||
export * from "./agent-definitions-loader"
|
||||
export * from "./opencode-config-agents-reader"
|
||||
export * from "./json-agent-loader"
|
||||
|
||||
@@ -229,6 +229,34 @@ describe("readOpencodeConfigAgents", () => {
|
||||
fs.rmSync(tempDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("supports agent key as fallback when agents key is not present", () => {
|
||||
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-test-"))
|
||||
const opencodeDir = path.join(tempDir, ".opencode")
|
||||
fs.mkdirSync(opencodeDir, { recursive: true })
|
||||
|
||||
const configPath = path.join(opencodeDir, "opencode.json")
|
||||
fs.writeFileSync(
|
||||
configPath,
|
||||
JSON.stringify({
|
||||
agent: {
|
||||
"fallback-agent": {
|
||||
description: "Using agent key",
|
||||
mode: "subagent",
|
||||
prompt: "Fallback prompt",
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
const result = readOpencodeConfigAgents(tempDir)
|
||||
|
||||
expect(result).toHaveProperty("fallback-agent")
|
||||
expect(result["fallback-agent"].description).toBe("(opencode-config) Using agent key")
|
||||
expect(result["fallback-agent"].prompt).toBe("Fallback prompt")
|
||||
|
||||
fs.rmSync(tempDir, { recursive: true })
|
||||
})
|
||||
|
||||
it("prioritizes project-level opencode.json over user-level", () => {
|
||||
const projectDir = fs.mkdtempSync(path.join(os.tmpdir(), "opencode-project-"))
|
||||
const projectOpencodeDir = path.join(projectDir, ".opencode")
|
||||
|
||||
@@ -9,6 +9,7 @@ import type { ClaudeCodeAgentConfig } from "./types"
|
||||
|
||||
interface OpencodeConfigWithAgents {
|
||||
agents?: Record<string, unknown>
|
||||
agent?: Record<string, unknown>
|
||||
agent_definitions?: string | string[]
|
||||
}
|
||||
|
||||
@@ -103,8 +104,10 @@ export function readOpencodeConfigAgents(directory: string): Record<string, Clau
|
||||
|
||||
const configDir = path.dirname(configPath)
|
||||
|
||||
if (parseResult.data.agents && typeof parseResult.data.agents === "object") {
|
||||
for (const [agentName, agentData] of Object.entries(parseResult.data.agents)) {
|
||||
const agentsToLoad = parseResult.data.agents || parseResult.data.agent
|
||||
|
||||
if (agentsToLoad && typeof agentsToLoad === "object") {
|
||||
for (const [agentName, agentData] of Object.entries(agentsToLoad)) {
|
||||
const converted = convertInlineAgent(agentData)
|
||||
if (converted) {
|
||||
result[agentName] = converted
|
||||
|
||||
Reference in New Issue
Block a user