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。

过滤插件内置技能

DavidShena4dbd2c969a8
diff --git a/packages/maker-core/src/agents/codex/index.test.ts b/packages/maker-core/src/agents/codex/index.test.ts
index c7728ce888..2559c608bb 100644
--- a/packages/maker-core/src/agents/codex/index.test.ts
+++ b/packages/maker-core/src/agents/codex/index.test.ts
@@ -2709,14 +2709,61 @@ describe('CodexAgent MCP thread context hooks', () => {
});
it('uses the home directory to list global skills for a new conversation without a cwd', async () => {
+ const home = os.homedir();
+ MockCodexTransport.onCreate = (transport) => {
+ transport.setMockResponse(Method.SkillsList, {
+ result: {
+ data: [{
+ cwd: home,
+ skills: [
+ {
+ name: 'pr-watch',
+ description: 'Watch PR feedback',
+ path: path.join(home, '.agents', 'skills', 'pr-watch', 'SKILL.md'),
+ scope: 'user',
+ enabled: true,
+ },
+ {
+ name: 'openai-templates:artifact-template-report',
+ description: 'Plugin-internal template',
+ path: path.join(
+ home,
+ '.codex',
+ 'plugins',
+ 'cache',
+ 'openai-curated-remote',
+ 'openai-templates',
+ '0.1.0',
+ 'skills',
+ 'artifact-template-report',
+ 'SKILL.md',
+ ),
+ scope: 'user',
+ enabled: true,
+ },
+ {
+ name: 'skill-creator',
+ description: 'System skill',
+ path: path.join(home, '.codex', 'skills', '.system', 'skill-creator', 'SKILL.md'),
+ scope: 'system',
+ enabled: true,
+ },
+ ],
+ errors: [],
+ }],
+ },
+ });
+ };
const agent = new CodexAgent(createDeps());
- await expect(agent.listAgentSkills({})).resolves.toMatchObject({ skills: [] });
+ await expect(agent.listAgentSkills({})).resolves.toMatchObject({
+ skills: [expect.objectContaining({ name: 'pr-watch', scope: 'user' })],
+ });
const request = createdTransports[0].lines
.map((line) => JSON.parse(line) as { method?: string; params?: unknown })
.find((line) => line.method === Method.SkillsList);
- expect(request?.params).toMatchObject({ cwds: [os.homedir()] });
+ expect(request?.params).toMatchObject({ cwds: [home] });
await agent.dispose();
});
diff --git a/packages/maker-core/src/agents/codex/index.ts b/packages/maker-core/src/agents/codex/index.ts
index 9e62458270..6bb1b61fd7 100644
--- a/packages/maker-core/src/agents/codex/index.ts
+++ b/packages/maker-core/src/agents/codex/index.ts
@@ -653,6 +653,16 @@ function skillDescription(skill: SkillMetadata): string | undefined {
);
}
+function isPaletteVisibleCodexSkill(skill: SkillMetadata): boolean {
+ if (!skill.enabled || skill.scope === 'system' || skill.scope === 'admin') return false;
+
+ // Codex plugins can contribute internal skills and currently report them as scope=user.
+ // They remain available to Codex's own dispatch, but Cindy's slash palette should only
+ // expose installed user/repo skills instead of every plugin implementation detail.
+ const normalizedPath = skill.path.replace(/\\/g, '/');
+ return !/\/plugins\/cache\/[^/]+\/[^/]+\/[^/]+\/skills\//i.test(normalizedPath);
+}
+
function parseLeadingSlashToken(text: string): { name: string; rest: string } | null {
const match = text.match(/^\/([^\s/]+)(?:\s+([\s\S]*))?$/);
if (!match?.[1]) return null;
@@ -1167,7 +1177,7 @@ export class CodexAgent extends BaseAgent {
const { skills, errors } = await this.listSkillsForCwd(workingDir, opts.forceReload ?? false);
const out: ListAgentSkillsResult = {
skills: skills
- .filter((skill) => skill.enabled)
+ .filter(isPaletteVisibleCodexSkill)
.map((skill) => ({
kind: 'agent-skill' as const,
name: skill.name,