xonecas.io
64875
Mc

mini-coder / commit b5609f8

fix: restore global mc entrypoint

xonecas2026-04-07 b5609f8b0d3d1f76da0680c5162373583bff5d97 parent edf6ca8

6 files changed

.npmignore+1−1
@@ -1,4 +1,4 @@
1-src/
1+src/*.test.ts
22 spec.md
33 AGENTS.md
44 TODO.md
AGENTS.md+2−0
@@ -16,6 +16,8 @@
1616 - `bun run check:fix` / `bun run format:fix` — auto-fix.
1717 - Lefthook pre-commit runs all four steps sequentially (`--silent`, `parallel: false`).
1818 - App data directory: `~/.config/mini-coder/`.
19+- Local manual CLI testing on this machine uses `bun add -g /home/xonecas/src/mini-coder`, which links the working tree into `~/.bun/bin/mc` without publishing. Re-run that after changing bin wiring if the global command needs to be refreshed.
20+- The rewrite's published CLI entrypoint is `mc` via the checked-in Bun launcher at `bin/mc.ts` (importing `src/index.ts`). Do not point `package.json#bin` at a `dist/` file unless the publish flow actually generates that artifact.
1921 - All exports should have JSDoc comments (descriptions, `@param`, `@returns`). Interface fields get single-line JSDoc. See `session.ts` for the established pattern.
2022 - Key dependency source code for reference:
2123 - pi-ai: `~/src/pi-mono/packages/ai/` — LLM provider SDK. See `src/types.ts` for core types, `src/stream.ts` for streaming API, `src/utils/oauth/` for OAuth, `src/providers/faux.ts` for test provider.
bin/mc.ts+14−0
@@ -0,0 +1,14 @@
1+#!/usr/bin/env bun
2+
3+/**
4+ * Executable launcher for the mini-coder CLI.
5+ *
6+ * @module
7+ */
8+
9+import { main } from "../src/index.ts";
10+
11+main().catch((err) => {
12+ console.error(err);
13+ process.exit(1);
14+});
package.json+1−1
@@ -5,7 +5,7 @@
55 "module": "src/index.ts",
66 "type": "module",
77 "bin": {
8- "mc": "dist/mc.js"
8+ "mc": "bin/mc.ts"
99 },
1010 "scripts": {
1111 "prepare": "lefthook install",
src/index.ts+8−1
@@ -479,7 +479,14 @@ export {
479479 // Main
480480 // ---------------------------------------------------------------------------
481481
482-async function main(): Promise<void> {
482+/**
483+ * Start the mini-coder CLI.
484+ *
485+ * Initializes application state and launches the TUI.
486+ *
487+ * @returns A promise that resolves once startup is complete.
488+ */
489+export async function main(): Promise<void> {
483490 const state = await init();
484491 const { startUI } = await import("./ui.ts");
485492 startUI(state);
src/package.test.ts+53−0
@@ -0,0 +1,53 @@
1+import { expect, test } from "bun:test";
2+import { join } from "node:path";
3+
4+const REPO_ROOT = join(import.meta.dir, "..");
5+
6+async function packDryRun(): Promise<{
7+ exitCode: number;
8+ stdout: string;
9+ stderr: string;
10+}> {
11+ const proc = Bun.spawn(
12+ [process.execPath, "pm", "pack", "--dry-run", "--ignore-scripts"],
13+ {
14+ cwd: REPO_ROOT,
15+ stdin: "ignore",
16+ stdout: "pipe",
17+ stderr: "pipe",
18+ env: process.env,
19+ },
20+ );
21+
22+ const exitCode = await proc.exited;
23+ const stdout = await new Response(proc.stdout).text();
24+ const stderr = await new Response(proc.stderr).text();
25+
26+ return { exitCode, stdout, stderr };
27+}
28+
29+test("package.json bin points to a checked-in mc launcher", async () => {
30+ const pkg = (await Bun.file(join(REPO_ROOT, "package.json")).json()) as {
31+ bin?: Record<string, string>;
32+ };
33+
34+ expect(pkg.bin).toEqual({ mc: "bin/mc.ts" });
35+
36+ const launcher = pkg.bin?.mc;
37+ expect(launcher).toBe("bin/mc.ts");
38+ if (!launcher) {
39+ throw new Error("package.json bin.mc is missing");
40+ }
41+ expect(Bun.file(join(REPO_ROOT, launcher)).size).toBeGreaterThan(0);
42+});
43+
44+test("pack dry-run includes the mc launcher and runtime entrypoint", async () => {
45+ const result = await packDryRun();
46+
47+ expect(result.exitCode).toBe(0);
48+ expect(result.stderr).toBe("");
49+ expect(result.stdout).toContain("packed ");
50+ expect(result.stdout).toContain("bin/mc.ts");
51+ expect(result.stdout).toContain("src/index.ts");
52+ expect(result.stdout).not.toContain("src/package.test.ts");
53+});