From 7a92f716d991971dbe9b97863ea2405ad6b07d65 Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sun, 15 Feb 2026 03:22:02 +0800 Subject: [PATCH] refactor(skills): remove unused SkillConfig.apiKey/env/primaryEnv (#192) These fields were only checked during eligibility but never injected at runtime via credentialManager.getEnv(). Remove the half-implemented per-skill credential config to reduce confusion. API key configuration remains supported via skills.env.json5 and process.env. Refs: MUL-246, MUL-255 Co-authored-by: Claude Opus 4.6 --- .../core/src/agent/skills/eligibility.test.ts | 50 ------------------- packages/core/src/agent/skills/eligibility.ts | 12 +---- packages/core/src/agent/skills/types.ts | 6 --- 3 files changed, 1 insertion(+), 67 deletions(-) diff --git a/packages/core/src/agent/skills/eligibility.test.ts b/packages/core/src/agent/skills/eligibility.test.ts index 08af1db1..8d888abb 100644 --- a/packages/core/src/agent/skills/eligibility.test.ts +++ b/packages/core/src/agent/skills/eligibility.test.ts @@ -284,56 +284,6 @@ describe("eligibility", () => { expect(result.reasons?.length).toBe(2); }); - it("should be eligible when env var provided via skillConfig", () => { - delete process.env.API_KEY; - - const skill = createSkill("test", { - name: "Test Skill", - metadata: { - requires: { - env: ["API_KEY"], - }, - }, - }); - - const result = checkEligibility(skill, { - platform: "darwin", - config: { - entries: { - test: { - env: { API_KEY: "secret" }, - }, - }, - }, - }); - expect(result.eligible).toBe(true); - }); - - it("should be eligible when env var provided via apiKey + primaryEnv", () => { - delete process.env.GEMINI_API_KEY; - - const skill = createSkill("test", { - name: "Test Skill", - metadata: { - primaryEnv: "GEMINI_API_KEY", - requires: { - env: ["GEMINI_API_KEY"], - }, - }, - }); - - const result = checkEligibility(skill, { - platform: "darwin", - config: { - entries: { - test: { - apiKey: "my-api-key", - }, - }, - }, - }); - expect(result.eligible).toBe(true); - }); }); describe("always flag", () => { diff --git a/packages/core/src/agent/skills/eligibility.ts b/packages/core/src/agent/skills/eligibility.ts index 62d96da5..3e1025fc 100644 --- a/packages/core/src/agent/skills/eligibility.ts +++ b/packages/core/src/agent/skills/eligibility.ts @@ -308,12 +308,6 @@ export function checkEligibilityDetailed( // Check if env var exists if (envExists(envVar)) continue; - // Check if provided via skill config env - if (skillConfig?.env?.[envVar]) continue; - - // Check if provided via apiKey + primaryEnv match - if (skillConfig?.apiKey && metadata?.primaryEnv === envVar) continue; - missingEnvVars.push(envVar); reasons.push(`Required environment variable not set: ${envVar}`); } @@ -443,9 +437,8 @@ function getBinaryInstallHint(binary: string, platform: NodeJS.Platform): string /** * Generate hints for missing environment variables */ -function generateEnvHint(envVars: string[], skill: Skill): string { +function generateEnvHint(envVars: string[], _skill: Skill): string { const hints: string[] = []; - const skillKey = getSkillKey(skill); for (const envVar of envVars) { // Check for well-known API key patterns @@ -463,9 +456,6 @@ function generateEnvHint(envVars: string[], skill: Skill): string { } } - // Also suggest config-based approach - hints.push(`Or configure via: skills.${skillKey}.env.${envVars[0]}`); - return hints.slice(0, 3).join(" OR "); } diff --git a/packages/core/src/agent/skills/types.ts b/packages/core/src/agent/skills/types.ts index a679f039..0369a491 100644 --- a/packages/core/src/agent/skills/types.ts +++ b/packages/core/src/agent/skills/types.ts @@ -66,8 +66,6 @@ export interface SkillMetadata { always?: boolean | undefined; /** Custom key for config lookup (defaults to skill id) */ skillKey?: string | undefined; - /** Primary environment variable for API key injection */ - primaryEnv?: string | undefined; /** Emoji for display (e.g., "📝") */ emoji?: string | undefined; /** Homepage URL for documentation */ @@ -162,10 +160,6 @@ export interface Skill { export interface SkillConfig { /** Explicitly enable/disable this skill */ enabled?: boolean | undefined; - /** API key for skills with primaryEnv set */ - apiKey?: string | undefined; - /** Environment variables to inject */ - env?: Record | undefined; /** Custom per-skill configuration */ config?: Record | undefined; }