feat: add skills and subagents configuration support#370
Conversation
- Updated .gitignore to include skills directory. - Introduced agent discovery functionality to scan for AGENT.md files in user and project directories. - Added new API endpoint for discovering filesystem agents. - Implemented UI components for managing skills and viewing custom subagents. - Enhanced settings helpers to retrieve skills configuration and custom subagents. - Updated agent service to incorporate skills and subagents in task delegation. These changes enhance the capabilities of the system by allowing users to define and manage skills and custom subagents effectively.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary of ChangesHello @Shironex, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly expands the agent's capabilities by introducing robust support for 'Skills' and 'Custom Subagents'. It enables users to define specialized agents and capabilities through markdown files in designated directories, which are then discovered, configured via settings, and integrated into the agent's task delegation process. The changes span across backend logic for discovery and integration, new API endpoints, and frontend UI for configuration and visualization, providing a more extensible and customizable agent experience. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant new functionality by adding support for Skills and custom Subagents. The changes are comprehensive, covering backend discovery logic, API endpoints, type definitions, and new UI components for configuration. The implementation is solid, with new services for agent discovery and helpers for retrieving settings. The UI additions in the settings view look well-designed and provide a good user experience for managing these new features.
I've identified a few areas for improvement, primarily focused on enhancing code maintainability and robustness. These include refactoring duplicated code in the agent discovery service, adding validation for parsed data, simplifying some logic for better readability, and ensuring UI loading states are handled correctly. Addressing these points will make the new functionality even more solid and easier to build upon in the future.
| async function scanAgentsDirectory( | ||
| baseDir: string, | ||
| source: 'user' | 'project' | ||
| ): Promise<FilesystemAgent[]> { | ||
| const agents: FilesystemAgent[] = []; | ||
| const isSystemPath = source === 'user'; // User directories use systemPaths | ||
|
|
||
| try { | ||
| // Check if directory exists | ||
| const exists = isSystemPath | ||
| ? await systemPaths.systemPathExists(baseDir) | ||
| : await secureFs | ||
| .access(baseDir) | ||
| .then(() => true) | ||
| .catch(() => false); | ||
|
|
||
| if (!exists) { | ||
| logger.debug(`Directory does not exist: ${baseDir}`); | ||
| return agents; | ||
| } | ||
|
|
||
| // Read all entries in the directory | ||
| if (isSystemPath) { | ||
| // For system paths (user directory) | ||
| const entryNames = await systemPaths.systemPathReaddir(baseDir); | ||
| for (const entryName of entryNames) { | ||
| const entryPath = path.join(baseDir, entryName); | ||
| const stat = await systemPaths.systemPathStat(entryPath); | ||
|
|
||
| // Check for flat .md file format (agent-name.md) | ||
| if (stat.isFile() && entryName.endsWith('.md')) { | ||
| const agentName = entryName.slice(0, -3); // Remove .md extension | ||
| const definition = await parseAgentFile(entryPath, true); | ||
| if (definition) { | ||
| agents.push({ | ||
| name: agentName, | ||
| definition, | ||
| source, | ||
| filePath: entryPath, | ||
| }); | ||
| logger.debug(`Discovered ${source} agent (flat): ${agentName}`); | ||
| } | ||
| } | ||
| // Check for subdirectory format (agent-name/AGENT.md) | ||
| else if (stat.isDirectory()) { | ||
| const agentFilePath = path.join(entryPath, 'AGENT.md'); | ||
| const agentFileExists = await systemPaths.systemPathExists(agentFilePath); | ||
|
|
||
| if (agentFileExists) { | ||
| const definition = await parseAgentFile(agentFilePath, true); | ||
| if (definition) { | ||
| agents.push({ | ||
| name: entryName, | ||
| definition, | ||
| source, | ||
| filePath: agentFilePath, | ||
| }); | ||
| logger.debug(`Discovered ${source} agent (subdirectory): ${entryName}`); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| // For project paths (use secureFs) | ||
| const entries = await secureFs.readdir(baseDir, { withFileTypes: true }); | ||
| for (const entry of entries) { | ||
| // Check for flat .md file format (agent-name.md) | ||
| if (entry.isFile() && entry.name.endsWith('.md')) { | ||
| const agentName = entry.name.slice(0, -3); // Remove .md extension | ||
| const agentFilePath = path.join(baseDir, entry.name); | ||
| const definition = await parseAgentFile(agentFilePath, false); | ||
| if (definition) { | ||
| agents.push({ | ||
| name: agentName, | ||
| definition, | ||
| source, | ||
| filePath: agentFilePath, | ||
| }); | ||
| logger.debug(`Discovered ${source} agent (flat): ${agentName}`); | ||
| } | ||
| } | ||
| // Check for subdirectory format (agent-name/AGENT.md) | ||
| else if (entry.isDirectory()) { | ||
| const agentDir = path.join(baseDir, entry.name); | ||
| const agentFilePath = path.join(agentDir, 'AGENT.md'); | ||
|
|
||
| const agentFileExists = await secureFs | ||
| .access(agentFilePath) | ||
| .then(() => true) | ||
| .catch(() => false); | ||
|
|
||
| if (agentFileExists) { | ||
| const definition = await parseAgentFile(agentFilePath, false); | ||
| if (definition) { | ||
| agents.push({ | ||
| name: entry.name, | ||
| definition, | ||
| source, | ||
| filePath: agentFilePath, | ||
| }); | ||
| logger.debug(`Discovered ${source} agent (subdirectory): ${entry.name}`); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } catch (error) { | ||
| logger.error(`Failed to scan agents directory: ${baseDir}`, error); | ||
| } | ||
|
|
||
| return agents; | ||
| } |
There was a problem hiding this comment.
This function has a lot of duplicated code for handling isSystemPath and non-isSystemPath cases. The logic inside the if (isSystemPath) and else blocks is almost identical, which makes the code harder to maintain.
Consider refactoring this to reduce duplication. One approach would be to create a small adapter for systemPaths and secureFs that provides a common interface for reading directories and checking file existence, and then have a single loop that uses this adapter.
For example:
const fsAdapter = isSystemPath
? {
readdir: //... implementation using systemPaths
exists: //... implementation using systemPaths
// ... other needed functions
}
: {
readdir: //... implementation using secureFs
exists: //... implementation using secureFs
// ... other needed functions
};
// Then use a single loop with fsAdapterThis would make the agent scanning logic much cleaner and easier to modify in the future.
|
changes have been made |
- Updated useSkillsSettings and useSubagents hooks to improve state management and error handling. - Added new settings API methods for skills configuration and agent discovery. - Refactored app-store to include enableSkills and skillsSources state management. - Enhanced settings migration to sync skills configuration with the server. These changes streamline the management of skills and subagents, ensuring better integration and user experience.
…uplication - Enhanced model parsing in agent discovery to validate against allowed values and log warnings for invalid models. - Refactored settingSources construction in AgentService to utilize Set for automatic deduplication, simplifying the merging of user and project settings with skills sources. - Updated tests to reflect changes in allowedTools for improved functionality. These changes enhance the robustness of agent configuration and streamline settings management.
- Added a new function to retrieve subagents configuration from settings, allowing users to enable/disable subagents and select sources for loading them. - Updated the AgentService to incorporate subagents configuration, dynamically adding tools based on the settings. - Enhanced the UI components to manage subagents, including a settings section for enabling/disabling and selecting sources. - Introduced a new hook for managing subagents settings state and interactions. These changes improve the flexibility and usability of subagents within the application, enhancing user experience and configuration options.
Resolved conflict in agent-service.ts by keeping both: - agents parameter for custom subagents (from our branch) - thinkingLevel and reasoningEffort parameters (from v0.9.0rc) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses PR feedback to reduce duplicated code in scanAgentsDirectory by introducing an FsAdapter interface that abstracts the differences between systemPaths (user directory) and secureFs (project directory). Changes: - Extract parseAgentContent helper for parsing agent file content - Add FsAdapter interface with exists, readdir, and readFile methods - Create createSystemPathAdapter for user-level paths - Create createSecureFsAdapter for project-level paths - Refactor scanAgentsDirectory to use a single loop with the adapter 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
0baf06a to
e649c4c
Compare
Resolve
TODO
Preview