From ad69f829aebb5feae6b85035e0c9752ffb641d83 Mon Sep 17 00:00:00 2001 From: Mikkel Georgsen Date: Wed, 1 Apr 2026 10:57:31 +0200 Subject: [PATCH] [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 --- .../adapter-utils/src/adapter-skill-config.ts | 111 +++++++++++++++++- 1 file changed, 107 insertions(+), 4 deletions(-) diff --git a/packages/adapter-utils/src/adapter-skill-config.ts b/packages/adapter-utils/src/adapter-skill-config.ts index 051f835e..b83f7b67 100644 --- a/packages/adapter-utils/src/adapter-skill-config.ts +++ b/packages/adapter-utils/src/adapter-skill-config.ts @@ -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( + 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; }