-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: port memory system + custom agents to desktop architecture #1955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vitorafgomes
wants to merge
3
commits into
AndyMik90:develop
Choose a base branch
from
vitorafgomes:feature/port-memory-agents-to-desktop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7983214
feat: port memory system improvements + custom agents to desktop arch…
vitorfgomes 85d1d26
Merge branch 'develop' into feature/port-memory-agents-to-desktop
AndyMik90 135276c
feat: add AgentAnalysisBanner to show active asset and time report
vitorfgomes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
apps/desktop/src/main/ipc-handlers/claude-agents-handlers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| /** | ||
| * Claude Agents Handlers | ||
| * | ||
| * IPC handlers for reading Claude Code custom agent definitions | ||
| * from ~/.claude/agents/ directory structure. | ||
| */ | ||
|
|
||
| import { ipcMain } from 'electron'; | ||
| import { existsSync, readdirSync } from 'fs'; | ||
| import path from 'path'; | ||
| import { IPC_CHANNELS } from '../../shared/constants/ipc'; | ||
| import type { IPCResult } from '../../shared/types'; | ||
| import type { ClaudeAgentsInfo, ClaudeAgentCategory, ClaudeCustomAgent } from '../../shared/types/integrations'; | ||
| import { getUserConfigDir } from '../claude-code-settings/reader'; | ||
| import { debugLog } from '../../shared/utils/debug-logger'; | ||
|
|
||
| const LOG_PREFIX = '[ClaudeAgents]'; | ||
|
|
||
| /** | ||
| * Convert a category directory name to a human-readable name. | ||
| * Removes the number prefix (e.g. "01-") and capitalizes words. | ||
| */ | ||
| function toCategoryName(dirName: string): string { | ||
| // Remove number prefix (e.g. "01-" from "01-core-development") | ||
| const withoutPrefix = dirName.replace(/^\d+-/, ''); | ||
| return withoutPrefix | ||
| .replace(/[-_]/g, ' ') | ||
| .replace(/\b\w/g, (c) => c.toUpperCase()); | ||
| } | ||
|
|
||
| /** | ||
| * Convert an agent filename to a human-readable name. | ||
| * Removes the .md extension, capitalizes words, replaces hyphens with spaces. | ||
| */ | ||
| function toAgentName(fileName: string): string { | ||
| // Remove .md extension | ||
| const withoutExt = fileName.replace(/\.md$/, ''); | ||
| return withoutExt | ||
| .replace(/[-_]/g, ' ') | ||
| .replace(/\b\w/g, (c) => c.toUpperCase()); | ||
| } | ||
|
|
||
| /** | ||
| * Get the agents directory path (~/.claude/agents/). | ||
| * Respects CLAUDE_CONFIG_DIR environment variable. | ||
| */ | ||
| function getAgentsDir(): string { | ||
| return path.join(getUserConfigDir(), 'agents'); | ||
| } | ||
|
|
||
| /** | ||
| * Register Claude Agents IPC handlers. | ||
| */ | ||
| export function registerClaudeAgentsHandlers(): void { | ||
| ipcMain.handle(IPC_CHANNELS.CLAUDE_AGENTS_GET, async (): Promise<IPCResult<ClaudeAgentsInfo>> => { | ||
| try { | ||
| const agentsDir = getAgentsDir(); | ||
|
|
||
| if (!existsSync(agentsDir)) { | ||
| debugLog(`${LOG_PREFIX} Agents directory not found:`, agentsDir); | ||
| return { success: true, data: { categories: [], totalAgents: 0 } }; | ||
| } | ||
|
|
||
| const categories: ClaudeAgentCategory[] = []; | ||
| let totalAgents = 0; | ||
|
|
||
| const entries = readdirSync(agentsDir, { withFileTypes: true }); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| for (const entry of entries) { | ||
| if (!entry.isDirectory()) continue; | ||
| const entryPath = path.join(agentsDir, entry.name); | ||
|
|
||
| const agents: ClaudeCustomAgent[] = []; | ||
|
|
||
| try { | ||
| const files = readdirSync(entryPath); | ||
| for (const file of files) { | ||
| if (!file.endsWith('.md') || file.toLowerCase() === 'readme.md') continue; | ||
|
|
||
| const agentId = file.replace(/\.md$/, ''); | ||
|
|
||
| // Use relative path (categoryDir/file) instead of absolute filePath | ||
| // to avoid exposing full filesystem paths to the renderer process | ||
| const relativePath = path.join(entry.name, file); | ||
|
|
||
| agents.push({ | ||
| agentId, | ||
| agentName: toAgentName(file), | ||
| categoryDir: entry.name, | ||
| categoryName: toCategoryName(entry.name), | ||
| filePath: relativePath, | ||
| }); | ||
| } | ||
| } catch { | ||
| debugLog(`${LOG_PREFIX} Failed to read category directory:`, entryPath); | ||
| continue; | ||
| } | ||
|
|
||
| if (agents.length > 0) { | ||
| // Sort agents by name within category | ||
| agents.sort((a, b) => a.agentName.localeCompare(b.agentName)); | ||
|
|
||
| categories.push({ | ||
| categoryDir: entry.name, | ||
| categoryName: toCategoryName(entry.name), | ||
| agents, | ||
| }); | ||
| totalAgents += agents.length; | ||
| } | ||
| } | ||
|
|
||
| // Sort categories by directory name (already numbered) | ||
| categories.sort((a, b) => a.categoryDir.localeCompare(b.categoryDir)); | ||
|
|
||
| debugLog(`${LOG_PREFIX} Found ${totalAgents} agent(s) in ${categories.length} categories`); | ||
| return { success: true, data: { categories, totalAgents } }; | ||
| } catch (error) { | ||
| debugLog(`${LOG_PREFIX} Error reading agents:`, error); | ||
| return { | ||
| success: false, | ||
| error: error instanceof Error ? error.message : 'Failed to read custom agents', | ||
| }; | ||
| } | ||
| }); | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block of code for sanitizing
enabledPluginscan be made more concise and declarative by usingObject.fromEntriesandArray.prototype.filter.