mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-12 02:37:45 +08:00
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:
32
ccw/bin/ccw-native.js
Normal file
32
ccw/bin/ccw-native.js
Normal 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);
|
||||
});
|
||||
Reference in New Issue
Block a user