Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): address follow-up skill review
xd-bobo114208731045
diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/generate_openai_yaml.py b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/generate_openai_yaml.pyindex 47b34309bf..bc1cde829e 100644--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/generate_openai_yaml.py+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/generate_openai_yaml.py@@ -107,7 +107,7 @@ def read_frontmatter_name(skill_dir):if not skill_md.exists():print(f"[ERROR] SKILL.md not found in {skill_dir}")return None- content = skill_md.read_text()+ content = skill_md.read_text(encoding="utf-8")try:frontmatter_text, _body_start = split_frontmatter(content)frontmatter = parse_frontmatter(frontmatter_text)@@ -189,7 +189,7 @@ def write_openai_yaml(skill_dir, skill_name, raw_overrides):agents_dir = Path(skill_dir) / "agents"agents_dir.mkdir(parents=True, exist_ok=True)output_path = agents_dir / "openai.yaml"- output_path.write_text(content)+ output_path.write_text(content, encoding="utf-8")print(f"[OK] Created agents/openai.yaml")return output_pathdiff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/init_skill.py b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/init_skill.pyindex 0d9ea5f242..dde3fafdf0 100644--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/init_skill.py+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/init_skill.py@@ -133,7 +133,9 @@ def create_resource_dirs(if resource == "scripts":if include_examples:example_script = resource_dir / "example.py"- example_script.write_text(EXAMPLE_SCRIPT.format(skill_name=skill_name))+ example_script.write_text(+ EXAMPLE_SCRIPT.format(skill_name=skill_name), encoding="utf-8"+ )example_script.chmod(0o755)print("[OK] Created scripts/example.py")else:@@ -142,7 +144,7 @@ def create_resource_dirs(if include_examples:example_reference = resource_dir / "api_reference.md"example_reference.write_text(- EXAMPLE_REFERENCE.format(skill_title=skill_title)+ EXAMPLE_REFERENCE.format(skill_title=skill_title), encoding="utf-8")print("[OK] Created references/api_reference.md")else:@@ -150,7 +152,7 @@ def create_resource_dirs(elif resource == "assets":if include_examples:example_asset = resource_dir / "example_asset.txt"- example_asset.write_text(EXAMPLE_ASSET)+ example_asset.write_text(EXAMPLE_ASSET, encoding="utf-8")print("[OK] Created assets/example_asset.txt")else:print("[OK] Created assets/")@@ -194,12 +196,12 @@ def init_skill(skill_name, path, resources, include_examples, interface_overrideskill_name=skill_name, skill_title=skill_title)skill_md_path = skill_dir / "SKILL.md"- skill_md_path.write_text(skill_content)+ skill_md_path.write_text(skill_content, encoding="utf-8")print("[OK] Created SKILL.md")agents_dir = skill_dir / "agents"agents_dir.mkdir(parents=True, exist_ok=True)- (agents_dir / "openai.yaml").write_text(interface_content)+ (agents_dir / "openai.yaml").write_text(interface_content, encoding="utf-8")print("[OK] Created agents/openai.yaml")if resources:diff --git a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/quick_validate.py b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/quick_validate.pyindex c9fbaf2bcc..c07c1ba236 100644--- a/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/quick_validate.py+++ b/apps/desktop/resources/system-skills/cindy-skill-creator/scripts/quick_validate.py@@ -20,7 +20,7 @@ def validate_skill(skill_path):if not skill_md.exists():return False, "SKILL.md not found"- content = skill_md.read_text()+ content = skill_md.read_text(encoding="utf-8")if not content.startswith("---"):return False, "No YAML frontmatter found"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.tsindex 088520106b..d28e696439 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@@ -144,6 +144,22 @@ describe('built-in Skills', () => {expect(fs.existsSync(path.join(input.homeDir, '.agents', 'skills', 'cindy-skill-creator'))).toBe(false);});+ it('waits a bounded interval for another profile to finish its projection', async () => {+ const input = fixture();+ let waitMs: number | undefined;+ const result = await prepareBuiltInSkills({+ ...input,+ withSharedMutation: async (_names, operation, options) => {+ waitMs = options?.waitMs;+ return operation();+ },+ });++ expect(waitMs).toBe(5_000);+ expect(result.warnings).toEqual([]);+ expect(fs.existsSync(result.descriptors[0]!.absolutePath)).toBe(true);+ });+it('keeps a user-owned same-name symlink', async () => {const input = fixture();const userSource = path.join(path.dirname(input.homeDir), 'user-skill');diff --git a/apps/desktop/src/main/maker-host/built-in-skills.ts b/apps/desktop/src/main/maker-host/built-in-skills.tsindex 15a6d1cefc..ee0fbd4d88 100644--- a/apps/desktop/src/main/maker-host/built-in-skills.ts+++ b/apps/desktop/src/main/maker-host/built-in-skills.ts@@ -16,6 +16,7 @@ export const BUILT_IN_LEARN_SKILL_NAME = CINDY_LEARN_NAME;const BUILT_IN_SKILL_NAMES = [BUILT_IN_SKILL_CREATOR_NAME, BUILT_IN_LEARN_SKILL_NAME] as const;const MANIFEST_FILE = '.cindy-system-skills.json';+const BUILT_IN_SKILL_MUTATION_WAIT_MS = 5_000;export interface BuiltInSkillDescriptor {name: string;@@ -395,7 +396,7 @@ export async function prepareBuiltInSkills();}return true;- });+ }, { waitMs: BUILT_IN_SKILL_MUTATION_WAIT_MS });if (locked === undefined) {warnings.push('could not prepare built-in Skills because another Skill mutation is in progress');}diff --git a/apps/desktop/src/main/skillhub/__tests__/sharedMutationLease.test.ts b/apps/desktop/src/main/skillhub/__tests__/sharedMutationLease.test.tsindex 641ab42e6f..17f0fbbaad 100644--- a/apps/desktop/src/main/skillhub/__tests__/sharedMutationLease.test.ts+++ b/apps/desktop/src/main/skillhub/__tests__/sharedMutationLease.test.ts@@ -53,6 +53,21 @@ describe('shared Skill mutation lease', () => {} finally { await successor(); }});+ it('honors a bounded wait while another profile releases the same Skill', async () => {+ const first = (await acquireSharedSkillMutationLease(['startup-projection']))!;+ const released = new Promise<void>((resolve) => {+ setTimeout(() => { void first().then(resolve); }, 50);+ });+ const next = await acquireSharedSkillMutationLease(+ ['startup-projection'],+ undefined,+ { waitMs: 500 },+ );+ await released;+ expect(next).not.toBeNull();+ await next!();+ });+it('contains a damaged durable barrier to its own resource name', async () => {const token = randomUUID();const key = createHash('sha256').update('damaged-receipt').digest('hex');diff --git a/apps/desktop/src/main/skillhub/sharedMutationLease.ts b/apps/desktop/src/main/skillhub/sharedMutationLease.tsindex aac5bead8e..720d89b6f7 100644--- a/apps/desktop/src/main/skillhub/sharedMutationLease.ts+++ b/apps/desktop/src/main/skillhub/sharedMutationLease.ts@@ -32,8 +32,17 @@ interface MutationContext {}const mutationContext = new AsyncLocalStorage<MutationContext[]>();+export interface SkillMutationWaitOptions {+ /** Total bounded wait shared across every requested Skill lock. */+ waitMs?: number;+}+/** Nested projections reuse only leases in their own async call chain. */-export async function withSkillMutation<T>(names: readonly string[], operation: () => Promise<T>): Promise<T | undefined> {+export async function withSkillMutation<T>(+ names: readonly string[],+ operation: () => Promise<T>,+ options: SkillMutationWaitOptions = {},+): Promise<T | undefined> {const requested = skillMutationNames(names);const held = (mutationContext.getStore() ?? []).filter((lease) => lease.active()&& requested.some((name) => lease.names.includes(name)));@@ -42,7 +51,7 @@ export async function withSkillMutation<T>(names: readonly string[], operation:// caller starts releasing the lease without awaiting that child.const run = held.reduceRight<() => Promise<T>>((next, lease) => () => lease.run(next), operation);if (!missing.length) return run();- const lease = await acquireSharedSkillMutationLease(missing);+ const lease = await acquireSharedSkillMutationLease(missing, undefined, options);if (!lease) return undefined;try { return await lease.run(run); }finally { await lease(); }@@ -82,6 +91,7 @@ function readPending(root: string, keys: string[]): PendingMutation[] {export async function acquireSharedSkillMutationLease(names: readonly string[],pendingToken?: string,+ options: SkillMutationWaitOptions = {},): Promise<SkillMutationRelease | null> {let root: string;try {@@ -98,6 +108,7 @@ export async function acquireSharedSkillMutationLease(let release!: () => void;const released = new Promise<void>((resolve) => { release = resolve; });let finished: Promise<void>;+ const waitDeadline = Date.now() + Math.max(0, options.waitMs ?? 0);const acquire = async (index: number): Promise<void> => {if (index === keys.length) {const matchesKeys = (record: PendingMutation) =>@@ -164,7 +175,10 @@ export async function acquireSharedSkillMutationLease(}const key = keys[index]!;await withCrossProcessLock(path.join(root, `${key}.lock`),- { label: 'skill-mutation', waitMs: 0 }, async (status) => {+ {+ label: 'skill-mutation',+ waitMs: Math.max(0, waitDeadline - Date.now()),+ }, async (status) => {if (status.held) await acquire(index + 1);});};diff --git a/apps/desktop/src/renderer/components/chat/SystemCard.tsx b/apps/desktop/src/renderer/components/chat/SystemCard.tsxindex e7cac09d7a..f99bedff78 100644--- a/apps/desktop/src/renderer/components/chat/SystemCard.tsx+++ b/apps/desktop/src/renderer/components/chat/SystemCard.tsx@@ -107,13 +107,23 @@ const codeClass = cn(function HelpCard({ data }: { data?: Record<string, unknown> }) {const { t } = useTranslation();const commands =- (data?.commands as Array<{ name: string; description?: string; source: string }>) ?? [];+ (data?.commands as Array<{+ name: string;+ description?: string;+ source: string;+ builtIn?: boolean;+ }>) ?? [];const desktopCmds = commands.filter((c) => c.source === 'desktop');const agentBuiltinCmds = commands.filter((c) => c.source === 'agent-builtin');const projectCmds = commands.filter((c) => c.source === 'user' || c.source === 'skill');const renderCommandRows = (- items: Array<{ name: string; description?: string; source: string }>,+ items: Array<{+ name: string;+ description?: string;+ source: string;+ builtIn?: boolean;+ }>,) => (<div className="flex flex-col gap-[2px]">{items.map((c) => {diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex fc165ba629..8828b81f8e 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -176,6 +176,7 @@ import {useControlledBy,} from '@/features/remote-device/ControlledBanner';import {+ commandsForHelpCard,loadAllCommands,dispatchCommand,leadingSlashInvocation,@@ -2426,12 +2427,7 @@ export function CCAgentSessionView({const insertHelpCard = useCallback(async () => {const commands = await getHelpCommandsSnapshot();insertSystemCard('help', {- commands: commands.map((c) => ({- name: c.name,- description: 'description' in c ? c.description : undefined,- // help 卡用 source 区分类目: agent-skill 透传原 source, 其余按 kind 简化- source: c.kind === 'agent-skill' ? c.source : c.kind,- })),+ commands: commandsForHelpCard(commands),});}, [getHelpCommandsSnapshot, insertSystemCard]);diff --git a/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts b/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.tsindex 7b8697c037..9cb0a00635 100644--- a/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts+++ b/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts@@ -2,6 +2,7 @@ import { describe, expect, it, vi } from 'vitest';import { CINDY_LEARN_SOURCE_DESCRIPTION } from '../../../shared/cindyBuiltInSkills';import {+ commandsForHelpCard,filterSlashCommands,firstAvailableSlashCommandIndex,hasAvailableSlashCommand,@@ -27,6 +28,23 @@ const skill = (overrides: Partial<Extract<UnifiedCommand, { kind: 'agent-skill'...overrides,});+describe('commandsForHelpCard', () => {+ it('preserves only the Main-attested built-in marker needed for localized descriptions', () => {+ expect(commandsForHelpCard([+ skill({ name: 'learn', builtIn: true, description: CINDY_LEARN_SOURCE_DESCRIPTION }),+ skill({ name: 'custom', description: 'Custom description' }),+ ])).toEqual([+ {+ name: 'learn',+ description: CINDY_LEARN_SOURCE_DESCRIPTION,+ source: 'skill',+ builtIn: true,+ },+ { name: 'custom', description: 'Custom description', source: 'skill' },+ ]);+ });+});+describe('rewriteAgentSkillInvocationForDispatch', () => {it('rewrites a directly typed loaded Pi skill alias and preserves its arguments', () => {const loaded = skill({diff --git a/apps/desktop/src/renderer/lib/slashCommands.ts b/apps/desktop/src/renderer/lib/slashCommands.tsindex c5d9f01ed7..e6606ab77e 100644--- a/apps/desktop/src/renderer/lib/slashCommands.ts+++ b/apps/desktop/src/renderer/lib/slashCommands.ts@@ -30,6 +30,23 @@ const shadowedUnavailableSkillsByCommands = new WeakMap<UnifiedCommand[], Set<stexport type { UnifiedCommand } from '@cindy/maker-core';+export interface HelpCardCommand {+ name: string;+ description?: string;+ source: string;+ builtIn?: boolean;+}++/** Preserve Main-attested built-in identity when commands enter a persisted help card. */+export function commandsForHelpCard(commands: readonly UnifiedCommand[]): HelpCardCommand[] {+ return commands.map((command) => ({+ name: command.name,+ description: 'description' in command ? command.description : undefined,+ source: command.kind === 'agent-skill' ? command.source : command.kind,+ ...(command.kind === 'agent-skill' && command.builtIn === true ? { builtIn: true } : {}),+ }));+}+export const PI_RUNTIME_SKILL_RETRY_DELAYS_MS = [100, 250, 500, 1_000, 2_000, 4_000] as const;export function isSlashCommandUnavailable(command: UnifiedCommand): boolean {