🐛 fix(vscode): 会话终端直接拉起 claude/codex,不再往 shell 里打命令,启动命令不再污染 zsh 历史

新建工单、实施、审查、测试、原型、续聊、冲突解决、会话管理和各种恢复会话,
都改成开终端时直接指定要跑的程序(用户默认 shell 以 -ilc 'exec "$@"' 拉起),
环境变量照常加载,参数原样传入。程序退出时标签页随之关闭。
提示词和配置文件路径里带单引号也不再拒绝执行,相关的转义和拦截全部删掉。
This commit is contained in:
chehongweo committed 2026-09-29 04:40:35 +08:00
1 parent 21000d48e9
commit 3621729367
16 files changed
+232 -330

No files matched your search

+24 -9
View File
@@ -1,23 +1,38 @@
import { describe, expect, it, vi } from 'vitest'
import { buildCcCommand } from '../../src/cc/ccCommand'
import { buildCcArgv } from '../../src/cc/ccCommand'
vi.mock('../../src/cc/claudeBin', () => ({
resolveClaudeBin: () => 'claude',
resolveClaudeBin: () => '/Users/me/My Apps/claude',
}))
describe('buildCcCommand', () => {
const BASE = ['/Users/me/My Apps/claude', '--dangerously-skip-permissions', '--settings', '/p.json']
describe('buildCcArgv', () => {
it('appends the prompt as a positional arg for a fresh session', () => {
expect(buildCcCommand({ profilePath: '/p.json', prompt: 'hello' }))
.toBe('claude --dangerously-skip-permissions --settings \'/p.json\' \'hello\'')
expect(buildCcArgv({ profilePath: '/p.json', prompt: 'hello' }))
.toEqual([...BASE, 'hello'])
})
it('resumes without a prompt when only a session id is given', () => {
expect(buildCcCommand({ profilePath: '/p.json', resumeSessionId: 'abc' }))
.toBe('claude --dangerously-skip-permissions --settings \'/p.json\' --resume abc')
expect(buildCcArgv({ profilePath: '/p.json', resumeSessionId: 'abc' }))
.toEqual([...BASE, '--resume', 'abc'])
})
it('resumes and hands the prompt to the restored session', () => {
expect(buildCcCommand({ profilePath: '/p.json', resumeSessionId: 'abc', prompt: 'go on' }))
.toBe('claude --dangerously-skip-permissions --settings \'/p.json\' --resume abc \'go on\'')
expect(buildCcArgv({ profilePath: '/p.json', resumeSessionId: 'abc', prompt: 'go on' }))
.toEqual([...BASE, '--resume', 'abc', 'go on'])
})
it('puts effort first and keeps quotes / $ / newlines in paths and prompt as-is', () => {
const prompt = 'don\'t $touch\n"this"'
expect(buildCcArgv({ profilePath: '/it\'s/p.json', effort: 'high', prompt })).toEqual([
'/Users/me/My Apps/claude',
'--effort',
'high',
'--dangerously-skip-permissions',
'--settings',
'/it\'s/p.json',
prompt,
])
})
})