mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
/agent should behave like a normal session prompt that tells the main model to use the selected Agent tool. The previous forked command path buffered the subagent run behind local command output and forced desktop clients to wait for command completion instead of seeing the normal Agent interaction stream. Constraint: Desktop /agent must preserve ordinary chat/session semantics and still require /agent <agent> <prompt>. Rejected: Keep slash_agent SDK event bridging | it preserves the separate forked execution path instead of fixing the product flow. Confidence: high Scope-risk: moderate Directive: Do not move /agent back to context: fork without proving the desktop normal Agent tool stream still works. Tested: bun test src/commands/agent.test.ts src/utils/processUserInput/processSlashCommand.test.ts src/server/__tests__/ws-memory-events.test.ts Tested: cd desktop && bun run test -- --run src/stores/chatStore.test.ts src/components/chat/MessageList.test.tsx Tested: git diff --check Not-tested: bun run check:server is blocked before source checks by expired quarantine entries: server:cron-scheduler, server:providers-real, server:tasks, server:e2e:business-flow, server:e2e:full-flow
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import agentCommand, { parseAgentCommandArgs } from './agent.js'
|
|
|
|
describe('/agent command', () => {
|
|
test('parses an agent type and prompt', () => {
|
|
expect(parseAgentCommandArgs('debugger fix the failing tests')).toEqual({
|
|
agentType: 'debugger',
|
|
prompt: 'fix the failing tests',
|
|
})
|
|
})
|
|
|
|
test('requires both an agent type and prompt', () => {
|
|
expect(parseAgentCommandArgs('')).toBeNull()
|
|
expect(parseAgentCommandArgs('debugger')).toBeNull()
|
|
})
|
|
|
|
test('instructs the normal chat loop to use the selected agent', async () => {
|
|
await expect(agentCommand.getPromptForCommand('debugger inspect auth', {} as never)).resolves.toEqual([
|
|
{
|
|
type: 'text',
|
|
text: [
|
|
'Use the Agent tool with subagent_type "debugger" to handle this request.',
|
|
'Pass this exact prompt to that agent:',
|
|
'',
|
|
'inspect auth',
|
|
].join('\n'),
|
|
},
|
|
])
|
|
})
|
|
|
|
test('shows usage when building a prompt without an agent prompt', async () => {
|
|
await expect(agentCommand.getPromptForCommand('debugger', {} as never)).rejects.toThrow(
|
|
'Usage: /agent <agent> <prompt>',
|
|
)
|
|
})
|
|
})
|