Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): align Learn command authorization
xd-bobo9e3e22f6675a
diff --git a/apps/desktop/src/main/learn-host/__tests__/invocationGrant.test.ts b/apps/desktop/src/main/learn-host/__tests__/invocationGrant.test.tsindex e822715775..267dc79b43 100644--- a/apps/desktop/src/main/learn-host/__tests__/invocationGrant.test.ts+++ b/apps/desktop/src/main/learn-host/__tests__/invocationGrant.test.ts@@ -21,7 +21,9 @@ describe('Learn invocation grant', () => {it.each([['/learn', { input: '', sourceKind: 'session' }],+ ['/Learn', { input: '', sourceKind: 'session' }],['/learn release flow', { input: 'release flow', sourceKind: 'freetext' }],+ ['/LEARN Preserve Release Case', { input: 'Preserve Release Case', sourceKind: 'freetext' }],['/skill:learn hub:team:release-notes keep checks',{@@ -31,10 +33,28 @@ describe('Learn invocation grant', () => {hubCatalogScope: 'team',},],+ [+ '/SKILL:LEARN hub:market:release-notes keep checks',+ {+ input: 'keep checks',+ sourceKind: 'hub',+ hubSlug: 'release-notes',+ hubCatalogScope: 'market',+ },+ ],])('parses direct Learn invocation %s', (text, expected) => {expect(parseDirectLearnInvocation(text)).toEqual(expected);});+ it.each([+ '/learner',+ '/learning release flow',+ '/skill:learner release flow',+ 'please inspect /Learn docs',+ ])('rejects text that is not a direct Learn invocation: %s', (text) => {+ expect(parseDirectLearnInvocation(text)).toBeNull();+ });+it('rejects ordinary messages and mismatched tool arguments without consuming the grant', async () => {const readLatest = vi.fn(async () => ({messageId: 'message-1',@@ -66,7 +86,7 @@ describe('Learn invocation grant', () => {it('consumes each persisted user invocation only once', async () => {const consume = createPersistentConsumer(async () => ({messageId: 'message-1',- text: '/learn release flow',+ text: '/Learn release flow',}));const request = {callerSessionId: 'session-1',diff --git a/apps/desktop/src/main/learn-host/invocationGrant.ts b/apps/desktop/src/main/learn-host/invocationGrant.tsindex c4146dac85..c480c068b3 100644--- a/apps/desktop/src/main/learn-host/invocationGrant.ts+++ b/apps/desktop/src/main/learn-host/invocationGrant.ts@@ -39,7 +39,10 @@ function normalizeInput(value: string): string {export function parseDirectLearnInvocation(text: string,): Omit<StartSkillLearningParams, 'callerSessionId'> | null {- const command = /^\/(?:skill:)?learn(?:\s+([\s\S]*))?$/.exec(text.trim());+ // Slash-skill dispatch resolves names case-insensitively. Keep the grant+ // parser on the same rule so an invocation accepted as the Learn Skill is+ // also accepted when that Skill calls the privileged host tool.+ const command = /^\/(?:skill:)?learn(?:\s+([\s\S]*))?$/i.exec(text.trim());if (!command) return null;const arg = (command[1] ?? '').trim();