Files
Claude-Code-Workflow/ccw/bin/ccw-native.js
catlog22 a34eeb63bf 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.
2026-01-18 11:10:05 +08:00

33 lines
862 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/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);
});