mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-02-05 01:50:27 +08:00
- 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.
33 lines
862 B
JavaScript
33 lines
862 B
JavaScript
#!/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);
|
||
});
|