From 6445d72c8060af10c24400b8e676fd4a01a4e4f7 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Thu, 29 Jan 2026 11:26:40 +0000 Subject: [PATCH] fix: address CodeRabbit PR review issues - Add noopener to rel="noreferrer" for tabnabbing protection - Fix standalone skill path handling in readSkillContent and validateSkill - Derive TOTAL_AGENTS from adapters instead of hardcoded value - Fix duplicate discovery path for droid/factory agents - Create dedicated FactoryAdapter instead of using UniversalAdapter --- docs/fumadocs/src/components/Footer.tsx | 2 +- .../src/components/SkillGenerator.tsx | 4 +- docs/skillkit/App.tsx | 4 +- docs/skillkit/components/Documentation.tsx | 2 +- docs/skillkit/components/Footer.tsx | 2 +- docs/skillkit/components/SkillGenerator.tsx | 6 +- packages/agents/src/factory.ts | 77 +++++++++++++++++++ packages/agents/src/index.ts | 4 +- packages/core/src/agents/types.ts | 3 +- packages/core/src/skills.ts | 9 ++- packages/tui/src/state/agents.ts | 4 +- 11 files changed, 100 insertions(+), 17 deletions(-) create mode 100644 packages/agents/src/factory.ts diff --git a/docs/fumadocs/src/components/Footer.tsx b/docs/fumadocs/src/components/Footer.tsx index 45b500f1..6a8342c1 100644 --- a/docs/fumadocs/src/components/Footer.tsx +++ b/docs/fumadocs/src/components/Footer.tsx @@ -20,7 +20,7 @@ export function Footer(): React.ReactElement { Agent Skills standard diff --git a/docs/fumadocs/src/components/SkillGenerator.tsx b/docs/fumadocs/src/components/SkillGenerator.tsx index cf63c08a..46cef5ff 100644 --- a/docs/fumadocs/src/components/SkillGenerator.tsx +++ b/docs/fumadocs/src/components/SkillGenerator.tsx @@ -469,7 +469,7 @@ ${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' {selectedSkill.sourceUrl && ( <> • - + View on GitHub @@ -503,7 +503,7 @@ ${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' View on GitHub diff --git a/docs/skillkit/App.tsx b/docs/skillkit/App.tsx index de14741c..05992bfd 100644 --- a/docs/skillkit/App.tsx +++ b/docs/skillkit/App.tsx @@ -44,7 +44,7 @@ export default function App(): React.ReactElement { @@ -53,7 +53,7 @@ export default function App(): React.ReactElement { diff --git a/docs/skillkit/components/Documentation.tsx b/docs/skillkit/components/Documentation.tsx index d76359eb..7d716f3b 100644 --- a/docs/skillkit/components/Documentation.tsx +++ b/docs/skillkit/components/Documentation.tsx @@ -451,7 +451,7 @@ export function Documentation(): React.ReactElement { Powered by DeepWiki diff --git a/docs/skillkit/components/Footer.tsx b/docs/skillkit/components/Footer.tsx index 798ada82..6cae8f44 100644 --- a/docs/skillkit/components/Footer.tsx +++ b/docs/skillkit/components/Footer.tsx @@ -20,7 +20,7 @@ export function Footer(): React.ReactElement { Agent Skills standard diff --git a/docs/skillkit/components/SkillGenerator.tsx b/docs/skillkit/components/SkillGenerator.tsx index d5a41ce3..e653b290 100644 --- a/docs/skillkit/components/SkillGenerator.tsx +++ b/docs/skillkit/components/SkillGenerator.tsx @@ -441,7 +441,7 @@ ${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' {selectedSkill.sourceUrl && ( <> • - + View on GitHub @@ -475,7 +475,7 @@ ${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' View on GitHub @@ -634,7 +634,7 @@ ${skillContent.slice(0, 4000)}${skillContent.length > 4000 ? '\n...(truncated)' {ref} diff --git a/packages/agents/src/factory.ts b/packages/agents/src/factory.ts new file mode 100644 index 00000000..692428bf --- /dev/null +++ b/packages/agents/src/factory.ts @@ -0,0 +1,77 @@ +import { existsSync } from 'node:fs'; +import { join } from 'node:path'; +import { homedir } from 'node:os'; +import type { AgentAdapter } from './base.js'; +import { createSkillXml } from './base.js'; +import type { Skill, AgentType } from '@skillkit/core'; +import { AGENT_CONFIG } from '@skillkit/core'; + +const config = AGENT_CONFIG.factory; + +export class FactoryAdapter implements AgentAdapter { + readonly type: AgentType = 'factory'; + readonly name = 'Factory'; + readonly skillsDir = config.skillsDir; + readonly configFile = config.configFile; + + generateConfig(skills: Skill[]): string { + const enabledSkills = skills.filter(s => s.enabled); + + if (enabledSkills.length === 0) { + return ''; + } + + const skillsXml = enabledSkills.map(createSkillXml).join('\n\n'); + + return ` + +## Available Skills + + + +When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge. + +How to use skills: +- Invoke: \`skillkit read \` or \`npx skillkit read \` +- The skill content will load with detailed instructions on how to complete the task +- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/) + +Usage notes: +- Only use skills listed in below +- Do not invoke a skill that is already loaded in your context +- Each skill invocation is stateless + + + + +${skillsXml} + + + + +`; + } + + parseConfig(content: string): string[] { + const skillNames: string[] = []; + const skillRegex = /([^<]+)<\/name>/g; + let match; + + while ((match = skillRegex.exec(content)) !== null) { + skillNames.push(match[1].trim()); + } + + return skillNames; + } + + getInvokeCommand(skillName: string): string { + return `skillkit read ${skillName}`; + } + + async isDetected(): Promise { + const projectFactory = join(process.cwd(), '.factory'); + const globalFactory = join(homedir(), '.factory'); + + return existsSync(projectFactory) || existsSync(globalFactory); + } +} diff --git a/packages/agents/src/index.ts b/packages/agents/src/index.ts index 500b45fc..e75c8edc 100644 --- a/packages/agents/src/index.ts +++ b/packages/agents/src/index.ts @@ -9,6 +9,7 @@ import { AntigravityAdapter } from './antigravity.js'; import { AmpAdapter } from './amp.js'; import { ClawdbotAdapter } from './clawdbot.js'; import { DroidAdapter } from './droid.js'; +import { FactoryAdapter } from './factory.js'; import { GitHubCopilotAdapter } from './github-copilot.js'; import { GooseAdapter } from './goose.js'; import { KiloAdapter } from './kilo.js'; @@ -28,6 +29,7 @@ export * from './antigravity.js'; export * from './amp.js'; export * from './clawdbot.js'; export * from './droid.js'; +export * from './factory.js'; export * from './github-copilot.js'; export * from './goose.js'; export * from './kilo.js'; @@ -63,7 +65,7 @@ const adapters: Record = { commandcode: new UniversalAdapter(), continue: new UniversalAdapter(), crush: new UniversalAdapter(), - factory: new UniversalAdapter(), + factory: new FactoryAdapter(), mcpjam: new UniversalAdapter(), mux: new UniversalAdapter(), neovate: new UniversalAdapter(), diff --git a/packages/core/src/agents/types.ts b/packages/core/src/agents/types.ts index 6468380f..26f41a14 100644 --- a/packages/core/src/agents/types.ts +++ b/packages/core/src/agents/types.ts @@ -222,7 +222,7 @@ export const AGENT_DISCOVERY_PATHS: Record = { 'antigravity': ['.antigravity/agents'], 'amp': ['.amp/agents'], 'clawdbot': ['.clawdbot/agents', 'agents'], - 'droid': ['.factory/agents'], + 'droid': ['.droid/agents'], 'github-copilot': ['.github/agents', '.github/instructions', '.github/custom-agents'], 'goose': ['.goose/agents'], 'kilo': ['.kilocode/agents', '.kilocode/modes'], @@ -266,6 +266,7 @@ export const ALL_AGENT_DISCOVERY_PATHS = [ '.crush/agents', '.cursor/agents', '.cursor/commands', + '.droid/agents', '.factory/agents', '.gemini/agents', '.github/agents', diff --git a/packages/core/src/skills.ts b/packages/core/src/skills.ts index 230cdd25..31d9aaf1 100644 --- a/packages/core/src/skills.ts +++ b/packages/core/src/skills.ts @@ -292,7 +292,9 @@ export function loadMetadata(skillPath: string): SkillMetadata | null { } export function readSkillContent(skillPath: string): string | null { - const skillMdPath = join(skillPath, 'SKILL.md'); + const skillMdPath = skillPath.endsWith('.md') + ? skillPath + : join(skillPath, 'SKILL.md'); if (!existsSync(skillMdPath)) { return null; @@ -343,9 +345,10 @@ export function findAllSkills(searchDirs: string[]): Skill[] { export function validateSkill(skillPath: string): { valid: boolean; errors: string[]; warnings?: string[] } { const errors: string[] = []; const warnings: string[] = []; - const dirName = basename(skillPath); + const isStandalone = skillPath.endsWith('.md'); + const dirName = isStandalone ? basename(skillPath, '.md') : basename(skillPath); + const skillMdPath = isStandalone ? skillPath : join(skillPath, 'SKILL.md'); - const skillMdPath = join(skillPath, 'SKILL.md'); if (!existsSync(skillMdPath)) { errors.push('Missing SKILL.md file'); return { valid: false, errors }; diff --git a/packages/tui/src/state/agents.ts b/packages/tui/src/state/agents.ts index 8a7917bc..cde4fcfd 100644 --- a/packages/tui/src/state/agents.ts +++ b/packages/tui/src/state/agents.ts @@ -92,6 +92,6 @@ export function getAgentAdapter(type: AgentType) { } /** - * Total number of supported agents + * Total number of supported agents (derived from adapters) */ -export const TOTAL_AGENTS = 32; +export const TOTAL_AGENTS = getAllAdapters().length;