Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): expose built-in skills to isolated Claude

xd-bobo74a8c8950df2
diff --git a/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts b/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
index 48e81566da..98abf3bf3e 100644
--- a/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
+++ b/apps/desktop/src/main/maker-host/__tests__/built-in-skills.test.ts
@@ -40,6 +40,9 @@ describe('built-in Skills', () => {
expect(first.changed).toBe(true);
expect(first.warnings).toEqual([]);
expect(fs.realpathSync(link)).toBe(fs.realpathSync(descriptor.absolutePath));
+ expect(fs.realpathSync(descriptor.nativeClaudePath)).toBe(
+ fs.realpathSync(descriptor.absolutePath),
+ );
expect(fs.readFileSync(path.join(descriptor.absolutePath, 'SKILL.md'), 'utf8')).toContain(
'# Creator',
);
@@ -75,6 +78,19 @@ describe('built-in Skills', () => {
expect(result.warnings.join('\n')).toContain('already owned by the user');
});
+ it('keeps a user-owned Skill in the isolated Claude config directory', async () => {
+ const input = fixture();
+ const descriptor = builtInSkillDescriptors(input.userDataDir)[0]!;
+ fs.mkdirSync(descriptor.nativeClaudePath, { recursive: true });
+ fs.writeFileSync(path.join(descriptor.nativeClaudePath, 'SKILL.md'), '# Claude user copy\n');
+
+ const result = await prepareBuiltInSkills(input);
+ expect(fs.readFileSync(path.join(descriptor.nativeClaudePath, 'SKILL.md'), 'utf8')).toBe(
+ '# Claude user copy\n',
+ );
+ expect(result.warnings.join('\n')).toContain('already owned by the user');
+ });
+
it('resolves source and packaged resource roots', () => {
expect(
resolveBundledSystemSkillsRoot({
diff --git a/apps/desktop/src/main/maker-host/built-in-skills.ts b/apps/desktop/src/main/maker-host/built-in-skills.ts
index f66d6ff43e..75ff9d93dd 100644
--- a/apps/desktop/src/main/maker-host/built-in-skills.ts
+++ b/apps/desktop/src/main/maker-host/built-in-skills.ts
@@ -13,6 +13,7 @@ const MANIFEST_FILE = '.cindy-system-skills.json';
export interface BuiltInSkillDescriptor {
name: string;
absolutePath: string;
+ nativeClaudePath: string;
nativeCodexPath: string;
}
@@ -52,6 +53,7 @@ export function builtInSkillDescriptors(userDataDir: string): BuiltInSkillDescri
return BUILT_IN_SKILL_NAMES.map((name) => ({
name,
absolutePath: path.join(root, name),
+ nativeClaudePath: path.join(userDataDir, 'claude-home', 'skills', name),
nativeCodexPath: path.join(userDataDir, 'codex-home', 'skills', '.system', name),
}));
}
@@ -134,13 +136,11 @@ async function materializeSkill(
return true;
}
-async function ensureSharedEntry(
+async function ensureSkillEntry(
descriptor: BuiltInSkillDescriptor,
- homeDir: string,
+ linkPath: string,
): Promise<{ changed: boolean; warning?: string }> {
- const sharedRoot = path.join(homeDir, '.agents', 'skills');
- const linkPath = path.join(sharedRoot, descriptor.name);
- await fsp.mkdir(sharedRoot, { recursive: true });
+ await fsp.mkdir(path.dirname(linkPath), { recursive: true });
try {
const current = await fsp.realpath(linkPath);
@@ -168,9 +168,20 @@ async function ensureSharedEntry(
return { changed: true };
}
+async function ensureSharedEntry(
+ descriptor: BuiltInSkillDescriptor,
+ homeDir: string,
+): Promise<{ changed: boolean; warning?: string }> {
+ return ensureSkillEntry(
+ descriptor,
+ path.join(homeDir, '.agents', 'skills', descriptor.name),
+ );
+}
+
/**
* Materialize Cindy-owned Skill bytes under a stable userData path, then expose
- * them through the shared ~/.agents discovery root without replacing user data.
+ * them through the shared ~/.agents discovery root and Cindy's isolated Claude
+ * config directory without replacing user data.
*/
export async function prepareBuiltInSkills(
options: PrepareBuiltInSkillsOptions,
@@ -210,6 +221,16 @@ export async function prepareBuiltInSkills(
`could not expose built-in Skill ${descriptor.name}: ${error instanceof Error ? error.message : String(error)}`,
);
}
+
+ try {
+ const linked = await ensureSkillEntry(descriptor, descriptor.nativeClaudePath);
+ changed = linked.changed || changed;
+ if (linked.warning) warnings.push(linked.warning);
+ } catch (error) {
+ warnings.push(
+ `could not expose built-in Skill ${descriptor.name} to Claude: ${error instanceof Error ? error.message : String(error)}`,
+ );
+ }
}
try {
diff --git a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
index e69de10214..ddd551cdd3 100644
--- a/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/activationPreferences.test.ts
@@ -45,7 +45,7 @@ describe('Skill activation preferences', () => {
await reloaded.setCindySkillEnabled(b, true);
expect(reloaded.readDisabledSkillPaths()).toEqual([]);
});
- it('also disables Codex native fallback when the Cindy built-in Skill is disabled', async () => {
+ it('also disables native runtime projections when the Cindy built-in Skill is disabled', async () => {
const prefs = await import('../activationPreferences');
const descriptor = (await import('../../maker-host/built-in-skills')).builtInSkillDescriptors(root)[0]!;
fs.mkdirSync(descriptor.absolutePath, { recursive: true });
@@ -53,6 +53,7 @@ describe('Skill activation preferences', () => {
await prefs.setCindySkillEnabled(descriptor.absolutePath, false);
expect(prefs.readDisabledSkillPaths()).toEqual(expect.arrayContaining([
prefs.skillActivationKey(descriptor.absolutePath),
+ descriptor.nativeClaudePath,
descriptor.nativeCodexPath,
]));
await prefs.setCindySkillEnabled(descriptor.absolutePath, true);
diff --git a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts
index a587dd0e9c..01227cee4f 100644
--- a/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/registerIpcUsage.test.ts
@@ -232,6 +232,7 @@ describe('registerSkillhubIpc usage handlers', () => {
getBuiltInSkills: () => [{
name: 'skill-creator',
absolutePath: builtInRoot,
+ nativeClaudePath: '/tmp/claude-home/skills/skill-creator',
nativeCodexPath: '/tmp/codex-home/skills/.system/skill-creator',
}],
getAllowedProjectRoots,
diff --git a/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts b/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts
index 57bc3ec090..00bcf69ce4 100644
--- a/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts
+++ b/apps/desktop/src/main/skillhub/__tests__/scanner.test.ts
@@ -105,6 +105,7 @@ describe('scanAllSkills', () => {
const result = await scanAllSkills({}, maker, [], [{
name: 'skill-creator',
absolutePath: builtIn,
+ nativeClaudePath: path.join(root, 'user-data', 'claude-home', 'skills', 'skill-creator'),
nativeCodexPath: path.join(root, 'user-data', 'codex-home', 'skills', '.system', 'skill-creator'),
}]);
diff --git a/apps/desktop/src/main/skillhub/activationPreferences.ts b/apps/desktop/src/main/skillhub/activationPreferences.ts
index ebe4852e33..a69d78a7f4 100644
--- a/apps/desktop/src/main/skillhub/activationPreferences.ts
+++ b/apps/desktop/src/main/skillhub/activationPreferences.ts
@@ -51,12 +51,12 @@ export function readDisabledSkillPaths(): readonly string[] {
catch { return false; }
}),
]);
- // Cindy's bundled copy normally wins through ~/.agents/skills. If that
- // projection is unavailable, Codex can still expose its own embedded system
- // copy. Mirror the same user preference to that fallback path.
+ // Cindy's bundled copy normally wins through ~/.agents/skills. Claude uses an
+ // isolated config directory in Desktop dev, while Codex can expose its own
+ // embedded system copy. Mirror the same user preference to both runtime paths.
for (const descriptor of builtInSkillDescriptors(app.getPath('userData'))) {
if (value.disabledPaths.includes(skillActivationKey(descriptor.absolutePath))) {
- paths.push(descriptor.nativeCodexPath);
+ paths.push(descriptor.nativeClaudePath, descriptor.nativeCodexPath);
}
}
return [...new Set(paths)];
diff --git a/packages/maker-core/src/agents/claude-code/customization-scanner.test.ts b/packages/maker-core/src/agents/claude-code/customization-scanner.test.ts
new file mode 100644
index 0000000000..5fe30dc0a9
--- /dev/null
+++ b/packages/maker-core/src/agents/claude-code/customization-scanner.test.ts
@@ -0,0 +1,49 @@
+import fs from 'node:fs';
+import os from 'node:os';
+import path from 'node:path';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { scanClaudeRuntimeSkills } from './customization-scanner.js';
+
+const roots: string[] = [];
+
+function writeSkill(root: string, name: string): string {
+ const skillDir = path.join(root, 'skills', name);
+ fs.mkdirSync(skillDir, { recursive: true });
+ fs.writeFileSync(
+ path.join(skillDir, 'SKILL.md'),
+ `---\nname: ${name}\ndescription: ${name}\n---\n`,
+ );
+ return skillDir;
+}
+
+afterEach(() => {
+ vi.restoreAllMocks();
+ for (const root of roots.splice(0)) fs.rmSync(root, { recursive: true, force: true });
+});
+
+describe('scanClaudeRuntimeSkills', () => {
+ it('uses the child runtime config directory for global Skills', async () => {
+ const root = fs.mkdtempSync(path.join(os.tmpdir(), 'claude-runtime-skills-'));
+ roots.push(root);
+ const home = path.join(root, 'home');
+ const isolatedConfig = path.join(root, 'user-data', 'claude-home');
+ const workingDir = path.join(root, 'project');
+ fs.mkdirSync(path.join(workingDir, '.git'), { recursive: true });
+ writeSkill(path.join(home, '.claude'), 'default-home');
+ const isolatedSkill = writeSkill(isolatedConfig, 'isolated-home');
+ const projectSkill = writeSkill(path.join(workingDir, '.claude'), 'project-skill');
+ vi.spyOn(os, 'homedir').mockReturnValue(home);
+
+ const result = await scanClaudeRuntimeSkills(workingDir, isolatedConfig);
+
+ expect(result.items.map((item) => item.name)).toEqual([
+ 'isolated-home',
+ 'project-skill',
+ ]);
+ expect(result.items.map((item) => item.absolutePath)).toEqual([
+ isolatedSkill,
+ fs.realpathSync(projectSkill),
+ ]);
+ });
+});
diff --git a/packages/maker-core/src/agents/claude-code/customization-scanner.ts b/packages/maker-core/src/agents/claude-code/customization-scanner.ts
index 0eba76ecfe..45119f73fb 100644
--- a/packages/maker-core/src/agents/claude-code/customization-scanner.ts
+++ b/packages/maker-core/src/agents/claude-code/customization-scanner.ts
@@ -26,12 +26,14 @@ import { scanCustomizationSources, type SourceDef } from '../shared/customizatio
type Kind = 'skill' | 'command' | 'agent';
type Scope = 'global' | 'project';
-function buildClaudeSources(workingDirs: string[]): SourceDef[] {
- const home = os.homedir();
+function buildClaudeSources(
+ workingDirs: string[],
+ configDir = path.join(os.homedir(), '.claude'),
+): SourceDef[] {
const sources: SourceDef[] = [
- { engine: 'claude-code', kind: 'skill', scope: 'global', dir: path.join(home, '.claude', 'skills') },
- { engine: 'claude-code', kind: 'command', scope: 'global', dir: path.join(home, '.claude', 'commands') },
- { engine: 'claude-code', kind: 'agent', scope: 'global', dir: path.join(home, '.claude', 'agents') },
+ { engine: 'claude-code', kind: 'skill', scope: 'global', dir: path.join(configDir, 'skills') },
+ { engine: 'claude-code', kind: 'command', scope: 'global', dir: path.join(configDir, 'commands') },
+ { engine: 'claude-code', kind: 'agent', scope: 'global', dir: path.join(configDir, 'agents') },
];
for (const wd of workingDirs) {
if (!wd || !path.isAbsolute(wd)) continue;
@@ -59,10 +61,17 @@ const KIND_ORDER: Record<Kind, number> = { skill: 0, command: 1, agent: 2 };
export async function scanClaudeCustomizations(
opts: ListCustomizationsOptions,
): Promise<ListCustomizationsResult> {
+ return scanClaudeCustomizationsAtConfig(opts, path.join(os.homedir(), '.claude'));
+}
+
+function scanClaudeCustomizationsAtConfig(
+ opts: ListCustomizationsOptions,
+ configDir: string,
+): ListCustomizationsResult {
const workingDirs = opts.workingDirs ?? [];
const kindFilter = opts.kinds && opts.kinds.length > 0 ? new Set(opts.kinds) : null;
- const sources = buildClaudeSources(workingDirs);
+ const sources = buildClaudeSources(workingDirs, configDir);
const result = scanCustomizationSources(sources, kindFilter);
result.items.sort((a, b) => {
@@ -82,7 +91,10 @@ export async function scanClaudeCustomizations(
* Keep this runtime view separate from SkillHub's explicitly owned project list.
* Ancestors precede descendants so same-name winner selection keeps the closest source.
*/
-export async function scanClaudeRuntimeSkills(workingDir: string): Promise<ListCustomizationsResult> {
+export async function scanClaudeRuntimeSkills(
+ workingDir: string,
+ configDir = path.join(os.homedir(), '.claude'),
+): Promise<ListCustomizationsResult> {
let current = fs.realpathSync(workingDir);
const workingDirs: string[] = [];
while (true) {
@@ -92,5 +104,8 @@ export async function scanClaudeRuntimeSkills(workingDir: string): Promise<ListC
if (parent === current) break;
current = parent;
}
- return scanClaudeCustomizations({ workingDirs, kinds: ['skill'] });
+ return scanClaudeCustomizationsAtConfig(
+ { workingDirs, kinds: ['skill'] },
+ configDir,
+ );
}
diff --git a/packages/maker-core/src/agents/claude-code/index.ts b/packages/maker-core/src/agents/claude-code/index.ts
index 43602b7c93..76356226b4 100644
--- a/packages/maker-core/src/agents/claude-code/index.ts
+++ b/packages/maker-core/src/agents/claude-code/index.ts
@@ -2400,7 +2400,10 @@ export class ClaudeCodeAgent extends BaseAgent {
const disabledSkillLaunch = snapshotDisabledSkillLaunch(disabledSkillPaths);
const disabledSkillSnapshot = disabledSkillLaunch.identities;
const disabledSkillOverrides = disabledSkillPaths.length > 0
- ? claudeDisabledSkillOverrides((await scanClaudeRuntimeSkills(opts.workingDir)).items, currentDisabledSkillLaunchPaths(disabledSkillLaunch))
+ ? claudeDisabledSkillOverrides(
+ (await scanClaudeRuntimeSkills(opts.workingDir, env.CLAUDE_CONFIG_DIR)).items,
+ currentDisabledSkillLaunchPaths(disabledSkillLaunch),
+ )
: {};
const buildSettings = (): Settings => {
const settings = buildClaudeFlagSettings({