2026-04-02 09:51:48 +08:00
|
|
|
#!/usr/bin/env bun
|
|
|
|
|
/**
|
|
|
|
|
* Dev entrypoint — launches cli.tsx with MACRO.* defines injected
|
|
|
|
|
* via Bun's -d flag (bunfig.toml [define] doesn't propagate to
|
|
|
|
|
* dynamically imported modules at runtime).
|
|
|
|
|
*/
|
|
|
|
|
import { getMacroDefines } from "./defines.ts";
|
|
|
|
|
|
|
|
|
|
const defines = getMacroDefines();
|
|
|
|
|
|
|
|
|
|
const defineArgs = Object.entries(defines).flatMap(([k, v]) => [
|
|
|
|
|
"-d",
|
|
|
|
|
`${k}:${v}`,
|
|
|
|
|
]);
|
|
|
|
|
|
2026-04-02 21:18:39 +08:00
|
|
|
// Bun --feature flags: enable feature() gates at runtime.
|
2026-04-02 21:48:50 +08:00
|
|
|
// Default features enabled in dev mode.
|
|
|
|
|
const DEFAULT_FEATURES = ["BUDDY", "TRANSCRIPT_CLASSIFIER"];
|
|
|
|
|
|
|
|
|
|
// Any env var matching FEATURE_<NAME>=1 will also enable that feature.
|
|
|
|
|
// e.g. FEATURE_PROACTIVE=1 bun run dev
|
|
|
|
|
const envFeatures = Object.entries(process.env)
|
2026-04-02 21:18:39 +08:00
|
|
|
.filter(([k]) => k.startsWith("FEATURE_"))
|
2026-04-02 21:48:50 +08:00
|
|
|
.map(([k]) => k.replace("FEATURE_", ""));
|
|
|
|
|
|
|
|
|
|
const allFeatures = [...new Set([...DEFAULT_FEATURES, ...envFeatures])];
|
|
|
|
|
const featureArgs = allFeatures.flatMap((name) => ["--feature", name]);
|
2026-04-02 21:18:39 +08:00
|
|
|
|
2026-04-02 09:51:48 +08:00
|
|
|
const result = Bun.spawnSync(
|
2026-04-02 21:18:39 +08:00
|
|
|
["bun", "run", ...defineArgs, ...featureArgs, "src/entrypoints/cli.tsx", ...process.argv.slice(2)],
|
2026-04-02 09:51:48 +08:00
|
|
|
{ stdio: ["inherit", "inherit", "inherit"] },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
process.exit(result.exitCode ?? 0);
|