fix(router): route casual chat to DeepSeek and reserve Cursor for page tasks
Default unmatched conversation to direct_chat, stop blanket Agent session continuation and generic Agent→Cursor promotion; fix WeChat page retry userPublishDir scope and simplify ChatPanel controls. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
buildCursorExecutorLaunchPlan,
|
||||
cursorExecutorEnabled,
|
||||
resolvePreferredCodeExecutor,
|
||||
} from './cursor-agent-launch.mjs';
|
||||
|
||||
test('cursor executor is disabled unless explicitly enabled', () => {
|
||||
assert.equal(cursorExecutorEnabled({}), false);
|
||||
assert.equal(cursorExecutorEnabled({ MEMIND_CURSOR_EXECUTOR_ENABLED: '1' }), true);
|
||||
});
|
||||
|
||||
test('resolvePreferredCodeExecutor prefers cursor when enabled', () => {
|
||||
assert.equal(resolvePreferredCodeExecutor({}), 'aider');
|
||||
assert.equal(
|
||||
resolvePreferredCodeExecutor({ MEMIND_CURSOR_EXECUTOR_ENABLED: '1' }),
|
||||
'cursor',
|
||||
);
|
||||
assert.equal(
|
||||
resolvePreferredCodeExecutor({
|
||||
MEMIND_CURSOR_EXECUTOR_ENABLED: '1',
|
||||
MEMIND_AIDER_SKILL_USE_CURSOR: '0',
|
||||
}),
|
||||
'aider',
|
||||
);
|
||||
});
|
||||
|
||||
test('buildCursorExecutorLaunchPlan includes workspace and mindspace hints', async () => {
|
||||
const fs = await import('node:fs/promises');
|
||||
const os = await import('node:os');
|
||||
const path = await import('node:path');
|
||||
const agentStub = path.join(await fs.mkdtemp(path.join(os.tmpdir(), 'cursor-agent-')), 'agent');
|
||||
await fs.writeFile(agentStub, '#!/bin/sh\nexit 0\n', { mode: 0o755 });
|
||||
|
||||
const plan = buildCursorExecutorLaunchPlan({
|
||||
cwd: '/tmp/mindspace/user-1',
|
||||
instruction: '写一首春日诗并生成 public/spring-poem.html',
|
||||
env: { MEMIND_CURSOR_EXECUTOR_AGENT_BIN: agentStub },
|
||||
});
|
||||
assert.equal(plan.ok, true);
|
||||
assert.equal(plan.executor, 'cursor');
|
||||
assert.equal(plan.cwd, '/tmp/mindspace/user-1');
|
||||
assert.equal(plan.command, agentStub);
|
||||
assert.ok(plan.args.includes('--workspace'));
|
||||
assert.ok(plan.args.includes('/tmp/mindspace/user-1'));
|
||||
assert.match(plan.args.at(-1) ?? '', /public\/.*\.html/);
|
||||
assert.match(plan.args.at(-1) ?? '', /不要执行 git commit/);
|
||||
assert.match(plan.args.at(-1) ?? '', /不要修改当前工作区之外的文件/);
|
||||
});
|
||||
|
||||
test('buildCursorExecutorLaunchPlan rejects empty instruction', () => {
|
||||
const plan = buildCursorExecutorLaunchPlan({ cwd: '/tmp/work', instruction: ' ' });
|
||||
assert.equal(plan.ok, false);
|
||||
assert.match(plan.message ?? '', /instruction/i);
|
||||
});
|
||||
Reference in New Issue
Block a user