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
+1 -1
View File
@@ -623,7 +623,7 @@ export async function runCodex(opts: {
if (!wasCreated) {
const startConfig: CodexSessionConfig = {
prompt: first ? message.message + '\n\n' + trimIdent(`Based on this message, call functions.happy__change_title to change chat session title that would represent the current task. If chat idea would change dramatically - call this function again to update the title.`) : message.message,
prompt: first ? message.message + '\n\n' + trimIdent(`Based on this message, call functions.hapi__change_title to change chat session title that would represent the current task. If chat idea would change dramatically - call this function again to update the title.`) : message.message,
sandbox,
'approval-policy': approvalPolicy,
config: { mcp_servers: mcpServers }
+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',