feat(skills): load config sources in runtime discovery
This commit is contained in:
@@ -4,6 +4,7 @@ import type { OhMyOpenCodeConfig } from "../config";
|
||||
import { log, migrateAgentConfig } from "../shared";
|
||||
import { AGENT_NAME_MAP } from "../shared/migration";
|
||||
import {
|
||||
discoverConfigSourceSkills,
|
||||
discoverOpencodeGlobalSkills,
|
||||
discoverOpencodeProjectSkills,
|
||||
discoverProjectClaudeSkills,
|
||||
@@ -34,11 +35,16 @@ export async function applyAgentConfig(params: {
|
||||
|
||||
const includeClaudeSkillsForAwareness = params.pluginConfig.claude_code?.skills ?? true;
|
||||
const [
|
||||
discoveredConfigSourceSkills,
|
||||
discoveredUserSkills,
|
||||
discoveredProjectSkills,
|
||||
discoveredOpencodeGlobalSkills,
|
||||
discoveredOpencodeProjectSkills,
|
||||
] = await Promise.all([
|
||||
discoverConfigSourceSkills({
|
||||
config: params.pluginConfig.skills,
|
||||
configDir: params.ctx.directory,
|
||||
}),
|
||||
includeClaudeSkillsForAwareness ? discoverUserClaudeSkills() : Promise.resolve([]),
|
||||
includeClaudeSkillsForAwareness
|
||||
? discoverProjectClaudeSkills()
|
||||
@@ -48,6 +54,7 @@ export async function applyAgentConfig(params: {
|
||||
]);
|
||||
|
||||
const allDiscoveredSkills = [
|
||||
...discoveredConfigSourceSkills,
|
||||
...discoveredOpencodeProjectSkills,
|
||||
...discoveredProjectSkills,
|
||||
...discoveredOpencodeGlobalSkills,
|
||||
|
||||
@@ -7,16 +7,19 @@ import {
|
||||
} from "../features/claude-code-command-loader";
|
||||
import { loadBuiltinCommands } from "../features/builtin-commands";
|
||||
import {
|
||||
discoverConfigSourceSkills,
|
||||
loadUserSkills,
|
||||
loadProjectSkills,
|
||||
loadOpencodeGlobalSkills,
|
||||
loadOpencodeProjectSkills,
|
||||
skillsToCommandDefinitionRecord,
|
||||
} from "../features/opencode-skill-loader";
|
||||
import type { PluginComponents } from "./plugin-components-loader";
|
||||
|
||||
export async function applyCommandConfig(params: {
|
||||
config: Record<string, unknown>;
|
||||
pluginConfig: OhMyOpenCodeConfig;
|
||||
ctx: { directory: string };
|
||||
pluginComponents: PluginComponents;
|
||||
}): Promise<void> {
|
||||
const builtinCommands = loadBuiltinCommands(params.pluginConfig.disabled_commands);
|
||||
@@ -26,6 +29,7 @@ export async function applyCommandConfig(params: {
|
||||
const includeClaudeSkills = params.pluginConfig.claude_code?.skills ?? true;
|
||||
|
||||
const [
|
||||
configSourceSkills,
|
||||
userCommands,
|
||||
projectCommands,
|
||||
opencodeGlobalCommands,
|
||||
@@ -35,6 +39,10 @@ export async function applyCommandConfig(params: {
|
||||
opencodeGlobalSkills,
|
||||
opencodeProjectSkills,
|
||||
] = await Promise.all([
|
||||
discoverConfigSourceSkills({
|
||||
config: params.pluginConfig.skills,
|
||||
configDir: params.ctx.directory,
|
||||
}),
|
||||
includeClaudeCommands ? loadUserCommands() : Promise.resolve({}),
|
||||
includeClaudeCommands ? loadProjectCommands() : Promise.resolve({}),
|
||||
loadOpencodeGlobalCommands(),
|
||||
@@ -47,6 +55,7 @@ export async function applyCommandConfig(params: {
|
||||
|
||||
params.config.command = {
|
||||
...builtinCommands,
|
||||
...skillsToCommandDefinitionRecord(configSourceSkills),
|
||||
...userCommands,
|
||||
...userSkills,
|
||||
...opencodeGlobalCommands,
|
||||
|
||||
@@ -33,7 +33,7 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
|
||||
|
||||
applyToolConfig({ config, pluginConfig, agentResult });
|
||||
await applyMcpConfig({ config, pluginConfig, pluginComponents });
|
||||
await applyCommandConfig({ config, pluginConfig, pluginComponents });
|
||||
await applyCommandConfig({ config, pluginConfig, ctx, pluginComponents });
|
||||
|
||||
log("[config-handler] config handler applied", {
|
||||
agentCount: Object.keys(agentResult).length,
|
||||
|
||||
Reference in New Issue
Block a user