xonecas.io
64875
Mc

mini-coder / commit a6806db

feat: git consolidation and update where compaction happened

xonecas2026-05-14 a6806db01b0350ede7c565d4df951cf8e2726953 parent 8497839

6 files changed

AGENTS.md+1−7
@@ -1,12 +1,6 @@
11 # Mini coder next
22
3-A new version of mini-coder, written from the ground up.
4-Version `mini-coder@0.5.x` is currently stable and mostly complete, that's our reference implementation.
5-
6-## Dog-fooding
7-
8-if this is in your context window, you are using the current repo's harness `mini-coder`. Be aware of this when
9-debugging and testing live with your user.
3+A barebones, fast coding agent
104
115 ## Core dependencies
126
benchmarks/terminal-bench-suite.sh+4−5
@@ -1,10 +1,9 @@
11 PYTHONPATH="$PWD" harbor run -y \
22 --job-name "terminal-bench-suite-$(date +%F__%H-%M-%S)" \
33 --jobs-dir "$PWD/benchmarks/jobs" \
4- --dataset terminal-bench/terminal-bench-2 \
4+ --dataset terminal-bench@2.0 \
55 --agent-import-path benchmarks.local-harbor-agent:LocalMiniCoderAgent \
6+ -k 5 \
7+ --n-concurrent 1 \
68 --model openai-codex/gpt-5.5 \
7- --n-attempts 1 \
8- --n-concurrent 2 \
9- --max-retries 1 \
10- --mounts-json '[{"type":"bind","source":"/home/xonecas/.config/mini-coder","target":"/root/.config/mini-coder","bind":{"create_host_path":false}}]'
9+ --mounts-json '[{"type":"bind","source":"/home/xonecas/.config/mini-coder","target":"/root/.config/mini-coder","bind":{"create_host_path":false}}]'
src/git.ts+23−0
@@ -0,0 +1,23 @@
1+import simpleGit from "simple-git";
2+
3+const git = simpleGit();
4+
5+export async function getGitStatus() {
6+ try {
7+ const status = await git.status();
8+ return status;
9+ } catch (_) {
10+ return { nogit: "No git repo in this folder." };
11+ } // No git
12+}
13+
14+export async function getBranchLabel() {
15+ try {
16+ const status = await git.status();
17+ const isClean = status.isClean();
18+
19+ return `${status.current}${isClean ? "" : "*"}`;
20+ } catch (_) {
21+ return "No git";
22+ } // No git
23+}
src/index.ts+2−8
@@ -1,6 +1,6 @@
11 import { basename } from "node:path";
2-import simpleGit from "simple-git";
32 import { handleArgv } from "./args.ts";
3+import { getBranchLabel } from "./git.ts";
44 import { streamHeadless } from "./headless.ts";
55 import { initTUI } from "./tui.ts";
66 import type { TUIState } from "./types.ts";
@@ -27,14 +27,8 @@ export async function main(): Promise<void> {
2727 stickToBottom: true,
2828 scrollOffset: 0,
2929 cwd,
30+ gitBranch: await getBranchLabel(),
3031 };
3132
32- const git = simpleGit();
33- try {
34- const gitStatus = (await git.status()).isClean() ? "" : "*";
35- const gitBranch = (await git.branch()).current;
36- state.gitBranch = `${gitBranch}${gitStatus}`;
37- } catch (_) {} // No git
38-
3933 initTUI(state, leave);
4034 }
src/prompt.ts+3−8
@@ -3,7 +3,7 @@ import { readdir } from "node:fs/promises";
33 import { homedir, platform } from "node:os";
44 import { join } from "node:path";
55 import type { Message, ToolResultMessage } from "@earendil-works/pi-ai";
6-import simpleGit, { type StatusResult } from "simple-git";
6+import { getGitStatus } from "./git";
77 import { parseSkillFrontmatter } from "./shared";
88
99 export const MAIN_PROMPT = `You are a coding agent interacting with users via the mini-coder harness. You help users by reading files, executing commands, and editting code.
@@ -36,12 +36,7 @@ async function getDir() {
3636
3737 async function getEnvPrompt() {
3838 // TODO: What else do the agents always check before answering every time?
39- let gitStatus: StatusResult | { nogit: string };
40- try {
41- gitStatus = await simpleGit().status();
42- } catch (_) {
43- gitStatus = { nogit: "No git repo in this folder." };
44- }
39+ const gitStatus = await getGitStatus();
4540 const envKeys = ["PATH", "USER", "LANG", "HOME", "SHELL", "BUN_INSTALL"];
4641 const env: Record<string, string> = {};
4742 for (const key of envKeys) {
@@ -216,7 +211,7 @@ export function insertToolUsageReminder(
216211 for (const c of calls) {
217212 const args = JSON.stringify(c.arguments);
218213 if (seenArgs.has(args)) sameToolCount++;
219- seenArgs.add(args)
214+ seenArgs.add(args);
220215 }
221216 }
222217 }
src/tui.ts+6−14
@@ -1,6 +1,6 @@
11 import { cel, HStack, ProcessTerminal, VStack } from "@cel-tui/core";
2-import simpleGit from "simple-git";
32 import { compactContext, streamAgent } from "./agent";
3+import { getBranchLabel } from "./git";
44 import {
55 buildSystemPrompt,
66 injectEnvReminder,
@@ -26,9 +26,6 @@ import { Editor } from "./tui-editor";
2626 import { mainMenu } from "./tui-overlay";
2727 import type { AgentContex, ToolAndRunner, TUIState } from "./types";
2828
29-// TODO: move all git things to `git.ts`
30-const git = simpleGit();
31-
3229 function clearOrAbort(state: TUIState) {
3330 // Are we mid stream? Abort it.
3431 if (state.streaming) {
@@ -161,6 +158,10 @@ async function streamAgentTUI(state: TUIState) {
161158 });
162159 state.prompt = "";
163160
161+ // Compact at 80k tokens, the dumb zone threshold.
162+ if (estimateTokens(JSON.stringify(state.messages)) > 80000)
163+ compactContext(state.messages);
164+
164165 const systemPrompt = await buildSystemPrompt(MAIN_PROMPT);
165166 const ctx: AgentContex = {
166167 systemPrompt,
@@ -217,16 +218,7 @@ async function streamAgentTUI(state: TUIState) {
217218 // I'm not sure since it we do, there is no trace in logs about compaction
218219 // and that would mean the logs don't repesent the truth. Confusing decision.
219220 await updateSession(state.sessionId, state.messages);
220-
221- // Compact after saving, if the next turn fails because of compaction, the session is recoverable.
222- // Compact at 80k tokens, the dumb zone threshold.
223- if (estimateTokens(JSON.stringify(state.messages)) > 80000)
224- compactContext(state.messages);
225221 }
226222
227- try {
228- const gitStatus = (await git.status()).isClean() ? "" : "*";
229- const gitBranch = (await git.branch()).current;
230- state.gitBranch = `${gitBranch}${gitStatus}`;
231- } catch (_) {}
223+ state.gitBranch = await getBranchLabel();
232224 }