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
@@ -14,7 +14,14 @@ import {
|
||||
discoverProjectClaudeSkills,
|
||||
discoverUserClaudeSkills,
|
||||
} from "../features/opencode-skill-loader";
|
||||
import { loadProjectAgents, loadUserAgents, loadOpencodeGlobalAgents, loadOpencodeProjectAgents } from "../features/claude-code-agent-loader";
|
||||
import {
|
||||
loadProjectAgents,
|
||||
loadUserAgents,
|
||||
loadOpencodeGlobalAgents,
|
||||
loadOpencodeProjectAgents,
|
||||
loadAgentDefinitions,
|
||||
readOpencodeConfigAgents,
|
||||
} from "../features/claude-code-agent-loader";
|
||||
import type { PluginComponents } from "./plugin-components-loader";
|
||||
import { reorderAgentsByPriority } from "./agent-priority-order";
|
||||
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper";
|
||||
@@ -33,7 +40,6 @@ type AgentConfigRecord = Record<string, Record<string, unknown> | undefined> & {
|
||||
function getConfiguredDefaultAgent(config: Record<string, unknown>): string | undefined {
|
||||
const defaultAgent = config.default_agent;
|
||||
if (typeof defaultAgent !== "string") return undefined;
|
||||
|
||||
const trimmedDefaultAgent = defaultAgent.trim();
|
||||
return trimmedDefaultAgent.length > 0 ? trimmedDefaultAgent : undefined;
|
||||
}
|
||||
@@ -100,6 +106,11 @@ export async function applyAgentConfig(params: {
|
||||
const opencodeProjectAgents = loadOpencodeProjectAgents(params.ctx.directory);
|
||||
const rawPluginAgents = params.pluginComponents.agents;
|
||||
|
||||
const agentDefinitionAgents = params.pluginConfig.agent_definitions
|
||||
? loadAgentDefinitions(params.pluginConfig.agent_definitions, "definition-file")
|
||||
: {};
|
||||
const opencodeConfigAgents = readOpencodeConfigAgents(params.ctx.directory);
|
||||
|
||||
const pluginAgents = Object.fromEntries(
|
||||
Object.entries(rawPluginAgents).map(([key, value]) => {
|
||||
if (!value) return [key, value];
|
||||
@@ -118,6 +129,8 @@ export async function applyAgentConfig(params: {
|
||||
...Object.entries(opencodeGlobalAgents),
|
||||
...Object.entries(opencodeProjectAgents),
|
||||
...Object.entries(pluginAgents).filter(([, config]) => config !== undefined),
|
||||
...Object.entries(agentDefinitionAgents),
|
||||
...Object.entries(opencodeConfigAgents),
|
||||
]
|
||||
.filter(([, config]) => config != null)
|
||||
.map(([name, config]) => ({
|
||||
@@ -127,6 +140,20 @@ export async function applyAgentConfig(params: {
|
||||
: "",
|
||||
}));
|
||||
|
||||
log(
|
||||
"[agent-config-handler] Agent sources loaded",
|
||||
{
|
||||
user: Object.keys(userAgents).length,
|
||||
project: Object.keys(projectAgents).length,
|
||||
opencodeGlobal: Object.keys(opencodeGlobalAgents).length,
|
||||
opencodeProject: Object.keys(opencodeProjectAgents).length,
|
||||
plugin: Object.keys(pluginAgents).length,
|
||||
agentDefinitions: Object.keys(agentDefinitionAgents).length,
|
||||
opencodeConfig: Object.keys(opencodeConfigAgents).length,
|
||||
config: Object.keys(configAgent ?? {}).length,
|
||||
}
|
||||
);
|
||||
|
||||
const builtinAgents = await createBuiltinAgents(
|
||||
migratedDisabledAgents,
|
||||
params.pluginConfig.agents,
|
||||
@@ -269,6 +296,14 @@ export async function applyAgentConfig(params: {
|
||||
opencodeProjectAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
const filteredAgentDefinitionAgents = filterProtectedAgentOverrides(
|
||||
agentDefinitionAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
const filteredOpencodeConfigAgents = filterProtectedAgentOverrides(
|
||||
opencodeConfigAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
|
||||
params.config.agent = {
|
||||
...agentConfig,
|
||||
@@ -283,6 +318,8 @@ export async function applyAgentConfig(params: {
|
||||
...filterDisabledAgents(filteredOpencodeGlobalAgents),
|
||||
...filterDisabledAgents(filteredProjectAgents),
|
||||
...filterDisabledAgents(filteredOpencodeProjectAgents),
|
||||
...filterDisabledAgents(filteredAgentDefinitionAgents),
|
||||
...filterDisabledAgents(filteredOpencodeConfigAgents),
|
||||
...filteredConfigAgents,
|
||||
build: { ...migratedBuild, mode: "subagent", hidden: true },
|
||||
...(planDemoteConfig ? { plan: planDemoteConfig } : {}),
|
||||
@@ -311,6 +348,14 @@ export async function applyAgentConfig(params: {
|
||||
opencodeProjectAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
const filteredAgentDefinitionAgents = filterProtectedAgentOverrides(
|
||||
agentDefinitionAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
const filteredOpencodeConfigAgents = filterProtectedAgentOverrides(
|
||||
opencodeConfigAgents,
|
||||
protectedBuiltinAgentNames,
|
||||
);
|
||||
|
||||
const defaultedConfigAgents = configAgent
|
||||
? Object.fromEntries(
|
||||
@@ -331,6 +376,8 @@ export async function applyAgentConfig(params: {
|
||||
...filterDisabledAgents(filteredOpencodeGlobalAgents),
|
||||
...filterDisabledAgents(filteredProjectAgents),
|
||||
...filterDisabledAgents(filteredOpencodeProjectAgents),
|
||||
...filterDisabledAgents(filteredAgentDefinitionAgents),
|
||||
...filterDisabledAgents(filteredOpencodeConfigAgents),
|
||||
...defaultedConfigAgents,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user