chore: migrate cli distribution from npm to bun executable

Migrate HAPI CLI from npm-based distribution to Bun single-executable format:
- Remove npm bin wrappers (bin/happy.mjs, bin/happy-mcp.mjs)
- Simplify package.json: remove npm publish config (exports, main, module, types, files, publishConfig)
- Update bin entry to point to TypeScript source (src/index.ts)
- Migrate shebang from Node to Bun (#!/usr/bin/env bun)
- Simplify build scripts: remove npm-specific steps (pkgroll, prepublishOnly, release-it)
- Update spawnHappyCLI to support compiled binaries and development TypeScript mode
- Update daemon/doctor diagnostics for new process detection logic
- Production: use `bun build --compile` for single-executable releases
- Development: run TypeScript directly via `bun src/index.ts` or `tsx src/index.ts`
This commit is contained in:
weishu
2025-12-22 16:44:20 +08:00
parent fd94a684dc
commit d057daabfe
11 changed files with 94 additions and 714 deletions
-30
View File
@@ -1,30 +0,0 @@
#!/usr/bin/env node
import { execFileSync } from 'child_process';
import { fileURLToPath } from 'url';
import { runHappyMcpStdioBridge } from '../dist/codex/happyMcpStdioBridge.mjs';
// Ensure Node flags to reduce noisy warnings on stdout (which could interfere with MCP)
const hasNoWarnings = process.execArgv.includes('--no-warnings');
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
if (!hasNoWarnings || !hasNoDeprecation) {
const entrypoint = fileURLToPath(import.meta.url);
try {
execFileSync(process.execPath, [
'--no-warnings',
'--no-deprecation',
entrypoint,
...process.argv.slice(2)
], {
stdio: 'inherit',
env: process.env
});
} catch (error) {
process.exit(error.status || 1);
}
} else {
// Already have desired flags; run bridge directly
await runHappyMcpStdioBridge(process.argv.slice(2));
}
-35
View File
@@ -1,35 +0,0 @@
#!/usr/bin/env node
import { execFileSync } from 'child_process';
import { fileURLToPath } from 'url';
import { join, dirname } from 'path';
// Check if we're already running with the flags
const hasNoWarnings = process.execArgv.includes('--no-warnings');
const hasNoDeprecation = process.execArgv.includes('--no-deprecation');
if (!hasNoWarnings || !hasNoDeprecation) {
// Get path to the actual CLI entrypoint
const projectRoot = dirname(dirname(fileURLToPath(import.meta.url)));
const entrypoint = join(projectRoot, 'dist', 'index.mjs');
// Execute the actual CLI directly with the correct flags
try {
execFileSync(process.execPath, [
'--no-warnings',
'--no-deprecation',
entrypoint,
...process.argv.slice(2)
], {
stdio: 'inherit',
env: process.env
});
} catch (error) {
// execFileSync throws if the process exits with non-zero
process.exit(error.status || 1);
}
} else {
// We're running Node with the flags we wanted, import the CLI entrypoint
// module to avoid creating a new process.
import("../dist/index.mjs");
}