feat(cli): add CLI prompt simulation and testing scripts

- Introduced `simulate-cli-prompt.js` to simulate various prompt formats and display the final content passed to the CLI.
- Added `test-shell-prompt.js` to test actual shell execution of different prompt formats, demonstrating correct vs incorrect multi-line prompt handling.
- Created comprehensive tests in `cli-prompt-parsing.test.ts` to validate prompt parsing, including single-line, multi-line, special characters, and template concatenation.
- Implemented edge case handling for empty lines, long prompts, and Unicode characters.
This commit is contained in:
catlog22
2026-01-18 11:10:05 +08:00
parent 56acc4f19c
commit a34eeb63bf
8 changed files with 1303 additions and 20 deletions

32
ccw/bin/ccw-native.js Normal file
View File

@@ -0,0 +1,32 @@
#!/usr/bin/env node
/**
* CCW Native Wrapper
*
* 替代 npm 生成的 shell wrapper直接用 Node.js 处理参数传递,
* 避免 Git Bash + Windows 的多行参数问题。
*/
import { spawn } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// 目标脚本路径
const targetScript = join(__dirname, 'ccw.js');
// 直接传递所有参数,不经过 shell
const child = spawn(process.execPath, [targetScript, ...process.argv.slice(2)], {
stdio: 'inherit',
shell: false, // 关键:不使用 shell避免参数被 shell 解析
});
child.on('close', (code) => {
process.exit(code || 0);
});
child.on('error', (err) => {
console.error('Failed to start ccw:', err.message);
process.exit(1);
});