feat: add source file execution and fix function name reference

- Add support for running CLI from TypeScript source when using tsx or similar tools
- Fix outdated happy__change_title reference to hapi__change_title in codex prompt
This commit is contained in:
weishu
2025-12-21 23:13:14 +08:00
parent c1fce7a9cf
commit ab06426773
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -102,6 +102,16 @@ export function getHappyCliCommand(args: string[]): HappyCliCommand {
const isBunRuntime = Boolean((process.versions as Record<string, string | undefined>).bun);
const entrypoint = isBunRuntime ? resolveEntrypointForBun(projectRoot) : distEntrypoint;
const argv1 = process.argv[1] ?? '';
const runningFromSource = argv1.endsWith(join('src', 'index.ts')) || process.execArgv.some((arg) => arg.includes('tsx'));
const srcEntrypoint = join(projectRoot, 'src', 'index.ts');
if (!isBunRuntime && runningFromSource && existsSync(srcEntrypoint)) {
return {
command: process.execPath,
args: [...process.execArgv, srcEntrypoint, ...args]
};
}
const spawnArgs = isBunRuntime ? [entrypoint, ...args] : [
'--no-warnings',
'--no-deprecation',