xonecas.io
64875
Mc

mini-coder / commit 181bdf1

feat: basic Bun-based self updater

xonecas2026-06-18 181bdf1dc482dff376153bd38f0e7e139d80a9a5 parent fa47818

3 files changed

AGENTS.md+1−1
@@ -49,7 +49,7 @@ Plain text readme file: https://raw.githubusercontent.com/badlogic/pi-mono/refs/
4949 - Format root `*.md` files: `bunx prettier --write *.md`
5050 - Format typescript files: `bunx biome format --write`
5151
52-Then lint with: `bunx biome check` and `tsc --noEmit`.
52+Then lint with: `bunx biome check` and `bunx tsc --noEmit`. (Do not expect to see tsc in PATH).
5353
5454 **Do not use the `package.json` commands/scripts they are for the users.** Use the commands above instead.
5555
src/index.ts+9−1
@@ -4,10 +4,18 @@ import { getBranchLabel } from "./git.ts";
44 import { streamHeadless } from "./headless.ts";
55 import { initTUI } from "./tui.ts";
66 import type { TUIState } from "./types.ts";
7+import { updateMiniCoder } from "./update.ts";
78
89 export async function main(): Promise<void> {
10+ const argv = process.argv.slice(2);
11+
12+ if (argv.includes("--update")) {
13+ await updateMiniCoder();
14+ return;
15+ }
16+
917 const cwd = basename(process.cwd());
10- const options = await handleArgv(process.argv.slice(2));
18+ const options = await handleArgv(argv);
1119
1220 function leave(msg?: string) {
1321 if (msg) console.log(msg);
src/update.ts+15−0
@@ -0,0 +1,15 @@
1+export async function updateMiniCoder(): Promise<void> {
2+ console.log("Updating mini-coder...");
3+
4+ const proc = Bun.spawn(["bun", "add", "-g", "mini-coder@latest"], {
5+ stdout: "inherit",
6+ stderr: "inherit",
7+ });
8+ const exitCode = await proc.exited;
9+
10+ if (exitCode !== 0) {
11+ throw new Error(`Update failed with exit code ${exitCode}`);
12+ }
13+
14+ console.log("mini-coder updated.");
15+}