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。

feat(desktop): mark learn as official

xd-boboc1819db9a1bc
diff --git a/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx b/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx
index 9aa5d22633..13730a79cf 100644
--- a/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/SlashCommandPalette.tsx
@@ -22,12 +22,12 @@ import { Tip } from '@/components/ui/tooltip';
import { cn } from '@/lib/utils';
import {
filterSlashCommands,
+ isCindyOfficialSlashCommand,
isSlashCommandUnavailable,
type UnifiedCommand,
} from '@/lib/slashCommands';
import { builtInSkillDescriptionKey } from '@/features/skillhub/lib/builtInSkillPresentation';
import { OfficialSkillBadge } from '@/features/skillhub/components/OfficialSkillBadge';
-import { isCindyBuiltInSkillMetadata } from '@/../shared/cindyBuiltInSkills';
const TOOLTIP_W = 280;
const TOOLTIP_GAP = 8;
@@ -249,7 +249,7 @@ export function SlashCommandPalette({
filtered.map((cmd, idx) => {
const focused = idx === focusedIndex;
const unavailable = isSlashCommandUnavailable(cmd);
- const official = cmd.kind === 'agent-skill' && isCindyBuiltInSkillMetadata(cmd);
+ const official = isCindyOfficialSlashCommand(cmd);
return (
<button
key={cmd.name}
diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx
index 1115cc78f0..f6dac9e004 100644
--- a/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/SlashCommandPalette.test.tsx
@@ -199,4 +199,39 @@ describe('SlashCommandPalette project Skill rows', () => {
expect(screen.queryByText('skillhub.builtIn.skillCreator.description')).toBeNull();
expect(screen.queryByText('skillhub.builtIn.official')).toBeNull();
});
+
+ it('marks Cindy Desktop /learn as official', () => {
+ render(
+ <SlashCommandPalette
+ query=""
+ commands={[{ kind: 'desktop', name: 'learn', description: 'Learn from this task' }]}
+ focusedIndex={0}
+ onFocusedIndexChange={vi.fn()}
+ onSelect={vi.fn()}
+ onClose={vi.fn()}
+ />,
+ );
+
+ expect(screen.getByText('skillhub.builtIn.official')).toBeTruthy();
+ });
+
+ it('does not mark a user Skill named learn as official', () => {
+ render(
+ <SlashCommandPalette
+ query=""
+ commands={[{
+ kind: 'agent-skill',
+ name: 'learn',
+ description: 'My Learn workflow',
+ source: 'skill',
+ }]}
+ focusedIndex={0}
+ onFocusedIndexChange={vi.fn()}
+ onSelect={vi.fn()}
+ onClose={vi.fn()}
+ />,
+ );
+
+ expect(screen.queryByText('skillhub.builtIn.official')).toBeNull();
+ });
});
diff --git a/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts b/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts
index f674709ab6..ac80e837cd 100644
--- a/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts
+++ b/apps/desktop/src/renderer/lib/__tests__/slashCommands.test.ts
@@ -5,6 +5,7 @@ import {
firstAvailableSlashCommandIndex,
hasAvailableSlashCommand,
hasUnavailableProjectSkillPreview,
+ isCindyOfficialSlashCommand,
isSlashCommandUnavailable,
mergeCommands,
nextAvailableSlashCommandIndex,
@@ -116,7 +117,7 @@ describe('rewriteAgentSkillInvocationForDispatch', () => {
});
describe('filterSlashCommands', () => {
- it('places a Cindy built-in Skill before ordinary commands in the initial palette', () => {
+ it('places Cindy official entries before ordinary commands in the initial palette', () => {
const commands = [
{ kind: 'desktop' as const, name: 'help', description: 'Help' },
{
@@ -125,16 +126,32 @@ describe('filterSlashCommands', () => {
description: 'Create or update a Cindy Skill',
source: 'skill' as const,
},
+ { kind: 'desktop' as const, name: 'learn', description: 'Learn' },
{ kind: 'agent-skill' as const, name: 'release-notes', source: 'skill' as const },
];
expect(filterSlashCommands(commands, '').map((command) => command.name)).toEqual([
'cindy-skill-creator',
+ 'learn',
'help',
'release-notes',
]);
});
+ it('recognizes only the Desktop /learn command as official', () => {
+ expect(isCindyOfficialSlashCommand({
+ kind: 'desktop',
+ name: 'learn',
+ description: 'Learn',
+ })).toBe(true);
+ expect(isCindyOfficialSlashCommand({
+ kind: 'agent-skill',
+ name: 'learn',
+ description: 'My Learn workflow',
+ source: 'skill',
+ })).toBe(false);
+ });
+
it('matches command names by case-insensitive containment', () => {
const commands = [
{ kind: 'desktop' as const, name: 'lark-drive', description: 'Drive' },
diff --git a/apps/desktop/src/renderer/lib/slashCommands.ts b/apps/desktop/src/renderer/lib/slashCommands.ts
index b8f0377af9..6544925568 100644
--- a/apps/desktop/src/renderer/lib/slashCommands.ts
+++ b/apps/desktop/src/renderer/lib/slashCommands.ts
@@ -19,7 +19,10 @@
import type { UnifiedCommand, AgentKind } from '@cindy/maker-core';
import { leadingSlashInvocation } from '@cindy/maker-shared';
import type { PiPackageCommandRuntimeStatus } from '@/../shared/piPackages';
-import { isCindyBuiltInSkillMetadata } from '@/../shared/cindyBuiltInSkills';
+import {
+ isCindyBuiltInSkillMetadata,
+ isCindyOfficialDesktopCommandName,
+} from '@/../shared/cindyBuiltInSkills';
export { leadingSlashInvocation };
@@ -41,6 +44,13 @@ export function isSlashCommandUnavailable(command: UnifiedCommand): boolean {
);
}
+export function isCindyOfficialSlashCommand(command: UnifiedCommand): boolean {
+ if (command.kind === 'desktop') {
+ return isCindyOfficialDesktopCommandName(command.name);
+ }
+ return command.kind === 'agent-skill' && isCindyBuiltInSkillMetadata(command);
+}
+
export function hasAvailableSlashCommand(commands: readonly UnifiedCommand[]): boolean {
return commands.some((command) => !isSlashCommandUnavailable(command));
}
@@ -277,8 +287,7 @@ export function filterSlashCommands(
.map((command, index) => {
const name = command.name.toLowerCase();
const rank = q ? (name === q ? 0 : name.startsWith(q) ? 1 : name.includes(q) ? 2 : -1) : 0;
- const officialPriority = command.kind === 'agent-skill'
- && isCindyBuiltInSkillMetadata(command) ? 0 : 1;
+ const officialPriority = isCindyOfficialSlashCommand(command) ? 0 : 1;
return { command, index, rank, officialPriority };
})
.filter((entry) => entry.rank >= 0)
diff --git a/apps/desktop/src/shared/cindyBuiltInSkills.ts b/apps/desktop/src/shared/cindyBuiltInSkills.ts
index 24a4714721..d874a49d49 100644
--- a/apps/desktop/src/shared/cindyBuiltInSkills.ts
+++ b/apps/desktop/src/shared/cindyBuiltInSkills.ts
@@ -1,5 +1,7 @@
export const CINDY_SKILL_CREATOR_NAME = 'cindy-skill-creator';
+const CINDY_OFFICIAL_DESKTOP_COMMAND_NAMES = new Set(['learn']);
+
const CINDY_SKILL_CREATOR_SOURCE_DESCRIPTIONS = new Set([
'Create or update a Cindy Skill',
'Create or update a skill',
@@ -20,3 +22,8 @@ export function isCindyBuiltInSkillMetadata(skill: {
&& CINDY_SKILL_CREATOR_SOURCE_DESCRIPTIONS.has(skill.description.trim()),
);
}
+
+/** Identify Desktop commands owned and shipped by Cindy. */
+export function isCindyOfficialDesktopCommandName(name: string): boolean {
+ return CINDY_OFFICIAL_DESKTOP_COMMAND_NAMES.has(name);
+}