[nexus] feat(18-01): implement adapter skill config resolver
- Static ADAPTER_SKILL_CONFIGS array with all 10 adapter types - CONFIG_BY_TYPE Map for O(1) lookup by adapter type string - FALLBACK_CONFIG for unknown types (supportsInstall: false, never throws) - resolveAdapterSkillConfig returns correct config for all known adapters - listAdapterSkillConfigs returns full readonly config array - All 15 unit tests pass, no regressions in full test suite
This commit is contained in:
parent
d7cff53ded
commit
034fa35d5e
1 changed files with 107 additions and 4 deletions
|
|
@ -1,17 +1,120 @@
|
|||
import type { AdapterSkillConfig } from "./types.js";
|
||||
|
||||
/**
|
||||
* Static configuration for all known adapter types.
|
||||
* This is the single source of truth for skill directory paths, formats, and
|
||||
* install capability across the Nexus adapter ecosystem.
|
||||
*/
|
||||
const ADAPTER_SKILL_CONFIGS: readonly AdapterSkillConfig[] = [
|
||||
{
|
||||
adapterType: "claude_local",
|
||||
skillDir: "~/.claude/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "hermes_local",
|
||||
skillDir: "~/.hermes/skills/",
|
||||
nativeSkillDir: "~/.hermes/skills/",
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "openclaw_gateway",
|
||||
skillDir: "~/.openclaw/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "codex_local",
|
||||
skillDir: "~/.agents/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "cursor",
|
||||
skillDir: "~/.cursor/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "opencode_local",
|
||||
skillDir: "~/.config/opencode/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "pi_local",
|
||||
skillDir: "~/.pi/agent/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "gemini_local",
|
||||
skillDir: "~/.gemini/skills/",
|
||||
nativeSkillDir: null,
|
||||
format: "skill-md",
|
||||
supportsInstall: true,
|
||||
unsupportedReason: null,
|
||||
},
|
||||
{
|
||||
adapterType: "process",
|
||||
skillDir: null,
|
||||
nativeSkillDir: null,
|
||||
format: "none",
|
||||
supportsInstall: false,
|
||||
unsupportedReason: "Skills not supported for this adapter type",
|
||||
},
|
||||
{
|
||||
adapterType: "http",
|
||||
skillDir: null,
|
||||
nativeSkillDir: null,
|
||||
format: "none",
|
||||
supportsInstall: false,
|
||||
unsupportedReason: "Skills not supported for this adapter type",
|
||||
},
|
||||
];
|
||||
|
||||
/** Lookup index built from the static config array for O(1) resolution. */
|
||||
const CONFIG_BY_TYPE = new Map<string, AdapterSkillConfig>(
|
||||
ADAPTER_SKILL_CONFIGS.map((cfg) => [cfg.adapterType, cfg]),
|
||||
);
|
||||
|
||||
/** Fallback returned for unknown adapter types — never throws. */
|
||||
const FALLBACK_CONFIG: AdapterSkillConfig = {
|
||||
adapterType: "unknown",
|
||||
skillDir: null,
|
||||
nativeSkillDir: null,
|
||||
format: "none",
|
||||
supportsInstall: false,
|
||||
unsupportedReason: "Unknown adapter type — skills not supported",
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the AdapterSkillConfig for the given adapter type.
|
||||
* Unknown types return a safe fallback config with supportsInstall: false.
|
||||
* Unknown types receive a safe fallback config with supportsInstall: false.
|
||||
* Never throws.
|
||||
*/
|
||||
export function resolveAdapterSkillConfig(_adapterType: string): AdapterSkillConfig {
|
||||
throw new Error("not implemented");
|
||||
export function resolveAdapterSkillConfig(adapterType: string): AdapterSkillConfig {
|
||||
return CONFIG_BY_TYPE.get(adapterType) ?? { ...FALLBACK_CONFIG, adapterType };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered adapter skill configs (one per known adapter type).
|
||||
*/
|
||||
export function listAdapterSkillConfigs(): readonly AdapterSkillConfig[] {
|
||||
throw new Error("not implemented");
|
||||
return ADAPTER_SKILL_CONFIGS;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue