xonecas.io
64875
Mc

mini-coder / commit 2b3582c

chore: release v0.1.0

Sean2026-02-25 2b3582c27b5f11b5e27e8badfa873a21491e1e3e parent c7b8f6c

4 files changed

.agents/commands/release.md+16−0
@@ -0,0 +1,16 @@
1+---
2+description: Create a new tagged npm release (patch/minor/major)
3+---
4+
5+Create a new npm release for this repo. The bump type is: $1 (default to "patch" if not provided).
6+
7+Steps to follow exactly:
8+1. Run `bun run typecheck && bun run format && bun run lint && bun test` — stop and report any failures before proceeding.
9+2. Read `package.json` and determine the current version.
10+3. Compute the next version by bumping the $1 part of the semver (patch/minor/major). Default to "patch" if $1 is empty.
11+4. Update the `version` field in `package.json` to the new version.
12+5. Run `bun run build` to produce a fresh `dist/mc.js`.
13+6. Commit all staged and unstaged changes with the message: `chore: release v<new-version>`.
14+7. Create a git tag `v<new-version>` on that commit.
15+8. Push the commit and the tag: `git push && git push --tags`.
16+9. Ask the user to run `npm publish` to publish to npm to complete the push with passkey auth.
TODO.md+123−0
@@ -1,5 +1,128 @@
11 # TODO
22
3+# Zod/Schema error:
4+
5+likely fixed by https://github.com/sacenox/mini-coder/commit/d27dccbf6ca2ced4f05d493701da9d8fe809e05d
6+
7+A user reported this issue, seems like we are trying to use a wrong type? Please see what you can find in the code
8+
9+```
10+gpt-5.3-codex mm2h8qwl ~/code/personal/mini-coder ⎇ main
11+▶ right now I can use opt+left/right to navigate between words. I'd like to do the same for delete. Eg: opt+delete to delete single words.
12+ ? glob **/*
13+ · src/session/manager.ts
14+ · src/session/db.ts
15+ · src/llm-api/types.ts
16+ · src/mcp/client.ts
17+ · src/tools/subagent.ts
18+ · src/llm-api/providers.ts
19+ · src/llm-api/turn.ts
20+ · src/cli/output.ts
21+ · src/cli/skills.test.ts
22+ · src/cli/skills.ts
23+ · src/cli/commands.ts
24+ · src/cli/input.ts
25+ +51 more
26+⠼ thinking333 | }) {
27+334 | var _a15, _b15, _c;
28+335 | if (_TypeValidationError.isInstance(cause) && cause.value === value && ((_a15 = cause.context) == null ? void 0 : _a15.field) === (context == null ? void 0 : context.field) && ((_b15 = cause.context) == null ? void 0 : _b15.entityName) === (context == null ? void 0 : context.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context == null ? void 0 : context.entityId)) {
29+336 | return cause;
30+337 | }
31+338 | return new _TypeValidationError({ value, cause, context });
32+ ^
33+AI_TypeValidationError: Type validation failed: Value: {"type":"ping","cost":"0.00387975"}.
34+Error message: [
35+ {
36+ "code": "invalid_union",
37+ "errors": [
38+ [
39+ {
40+ "expected": "array",
41+ "code": "invalid_type",
42+ "path": [
43+ "choices"
44+ ],
45+ "message": "Invalid input: expected array, received undefined"
46+ }
47+ ],
48+ [
49+ {
50+ "expected": "object",
51+ "code": "invalid_type",
52+ "path": [
53+ "error"
54+ ],
55+ "message": "Invalid input: expected object, received undefined"
56+ }
57+ ]
58+ ],
59+ "path": [],
60+ "message": "Invalid input"
61+ }
62+]
63+ value: {
64+ type: "ping",
65+ cost: "0.00387975",
66+},
67+ context: undefined,
68+ vercel.ai.error: true,
69+ vercel.ai.error.AI_TypeValidationError: true,
70+
71+ at wrap (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider/dist/index.mjs:338:12)
72+ at safeValidateTypes (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2115:35)
73+ at async safeParseJSON (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2154:18)
74+ at async transform (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2186:34)
75+
76+25 | class Definition extends Parent {
77+26 | }
78+27 | Object.defineProperty(Definition, "name", { value: name });
79+28 | function _(def) {
80+29 | var _a;
81+30 | const inst = params?.Parent ? new Definition() : this;
82+ ^
83+ZodError: [
84+ {
85+ "code": "invalid_union",
86+ "errors": [
87+ [
88+ {
89+ "expected": "array",
90+ "code": "invalid_type",
91+ "path": [
92+ "choices"
93+ ],
94+ "message": "Invalid input: expected array, received undefined"
95+ }
96+ ],
97+ [
98+ {
99+ "expected": "object",
100+ "code": "invalid_type",
101+ "path": [
102+ "error"
103+ ],
104+ "message": "Invalid input: expected object, received undefined"
105+ }
106+ ]
107+ ],
108+ "path": [],
109+ "message": "Invalid input"
110+ }
111+]
112+ at new ZodError (/Users/ericskram/.bun/install/global/node_modules/zod/v4/core/core.js:30:39)
113+ at <anonymous> (/Users/ericskram/.bun/install/global/node_modules/zod/v4/core/parse.js:53:20)
114+ at <anonymous> (/Users/ericskram/.bun/install/global/node_modules/zod/v4/core/parse.js:45:49)
115+ at <anonymous> (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2070:33)
116+ at validate (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2069:24)
117+ at safeValidateTypes (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2109:39)
118+ at safeValidateTypes (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2099:33)
119+ at safeParseJSON (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2154:18)
120+ at safeParseJSON (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2145:29)
121+ at transform (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2186:34)
122+ at transform (/Users/ericskram/.bun/install/global/node_modules/@ai-sdk/provider-utils/dist/index.mjs:2182:25)
123+```
124+
125+
3126 ## Streaming subagent activity
4127
5128 I'd like to have the subgent output/activity to be streamed to the main output. Right now we wait for the subagent to be complete to print all at once
better-errors.md+96−0
@@ -0,0 +1,96 @@
1+# Better Errors — Implementation Plan
2+
3+## Overview
4+
5+Add structured error logging to file and friendly error parsing for display. Three concerns: (1) log full error details to `~/.config/mini-coder/errors.log`, (2) map known AI SDK errors to terse user-facing messages, (3) wire both into existing error surfaces.
6+
7+---
8+
9+## Files to Create
10+
11+| File | Purpose |
12+|---|---|
13+| `src/cli/error-log.ts` | `initErrorLog()`, `logError()` |
14+| `src/cli/error-parse.ts` | `parseAppError()` |
15+
16+## Files to Modify
17+
18+| File | Change |
19+|---|---|
20+| `src/index.ts` | Call `initErrorLog()` at startup; use `logError` + `parseAppError` in top-level catch and `main().catch()` |
21+| `src/cli/output.ts` | Update `renderError(err: unknown)` to call log + parse; update `turn-error` branch in `renderTurn()` |
22+| `src/agent/agent.ts` | Pass `unknown` to `renderError()` — no logic change needed if signature widens correctly |
23+
24+---
25+
26+## Implementation Steps
27+
28+1. **Create `src/cli/error-log.ts`**
29+ - Module-level `let writer: ReturnType<ReturnType<typeof Bun.file>['writer']> | null = null`
30+ - `initErrorLog()`: if `writer` is not null, return early (idempotency). Otherwise resolve path `~/.config/mini-coder/errors.log`, open with `Bun.file(path).writer()` (truncates on open), assign to `writer`. Register `process.on('uncaughtException', (err) => { logError(err, 'uncaught'); process.exit(1) })`.
31+ - `logError(err: unknown, context?: string)`: if `writer` is null, return. Build log entry string (see Log Format), call `writer.write(entry)`. Keep sync-ish by not awaiting — `write()` on a Bun file writer is buffered; call `writer.flush()` after each write so data lands before a crash.
32+ - Extract error fields via type-narrowing helpers (not exported): `isObject(err)`, read `.name`, `.message`, `.stack`, `.statusCode`, `.url`, `.isRetryable` defensively.
33+
34+2. **Create `src/cli/error-parse.ts`**
35+ - Import AI SDK error classes: `APICallError`, `RetryError`, `NoContentGeneratedError`, `LoadAPIKeyError`, `NoSuchModelError` from `ai`.
36+ - Export `parseAppError(err: unknown): { headline: string; hint?: string }`.
37+ - Implement as a chain of `instanceof` checks (see Error Parse Table). For `RetryError`, recurse on `.lastError` and prepend `"Retries exhausted: "` to `headline`.
38+ - Fallback: extract first non-empty line of `(err as any)?.message ?? String(err)`, no hint.
39+ - Network check: before the fallback, check if `(err as any)?.code === 'ECONNREFUSED'` or message includes `'ECONNREFUSED'`.
40+
41+3. **Update `src/cli/output.ts`**
42+ - Change `renderError` signature from `(msg: string)` to `(err: unknown)`. Inside: call `logError(err, 'render')`, call `parseAppError(err)`, print `✖ red(headline)`, if `hint` print a dim indented hint line (e.g. ` dim(hint)`).
43+ - In `renderTurn()` `turn-error` branch (non-abort path): replace raw `event.error.message` display with `logError(event.error, 'turn')` then `parseAppError(event.error)` → print `✖ red(headline)`, optional dim hint. Keep the abort quiet-note branch unchanged.
44+ - All callers of `renderError` that currently pass a string (e.g. in `agent.ts`) — check each call site; if passing a plain string, wrap in `new Error(string)` or let `parseAppError` fallback handle a string gracefully (add string branch at top of `parseAppError`: `if (typeof err === 'string') return { headline: err }`).
45+
46+4. **Update `src/index.ts`**
47+ - After `registerTerminalCleanup()` (or equivalent startup call), add `initErrorLog()`.
48+ - Top-level `catch` around `runAgent()`: replace any raw print with `logError(err, 'agent')` + `parseAppError(err)` → print `✖ red(headline)` + dim hint, then `process.exit(1)`.
49+ - `main().catch()`: same pattern — `logError(err, 'main')` + parse + print + `process.exit(1)`. Remove bare `console.error(err)`.
50+
51+5. **Tests (`src/cli/error-parse.test.ts`)**
52+ - Test `parseAppError` for each mapped error type.
53+ - Construct real instances where possible (e.g. `new APICallError({ ... })`); check `headline` and `hint` values.
54+ - Test `RetryError` unwrapping.
55+ - Test fallback for plain `Error` and plain string.
56+ - No mocks, no file I/O, no server calls.
57+
58+---
59+
60+## Error Parse Table
61+
62+| Condition | `headline` | `hint` |
63+|---|---|---|
64+| `APICallError` with `statusCode === 429` | `"Rate limit hit"` | `"Wait a moment and retry, or switch model with /model"` |
65+| `APICallError` with `statusCode === 401 \|\| 403` | `"Auth failed"` | `"Check the relevant provider API key env var"` |
66+| `APICallError` other | `"API error \${statusCode}"` | `url` if present |
67+| `RetryError` | `"Retries exhausted: \${inner.headline}"` | inner `hint` |
68+| `NoContentGeneratedError` | `"Model returned empty response"` | `"Try rephrasing or switching model with /model"` |
69+| `LoadAPIKeyError` | `"API key not found"` | `"Set the relevant provider env var"` |
70+| `NoSuchModelError` | `"Model not found"` | `"Use /model to pick a valid model"` |
71+| `code === 'ECONNREFUSED'` or message contains `'ECONNREFUSED'` | `"Connection failed"` | `"Check network or local server"` |
72+| `string` input | string value | — |
73+| fallback | first line of `err.message` | — |
74+
75+> `AbortError` is never passed to `parseAppError` — abort is handled at the call sites before reaching these functions.
76+
77+---
78+
79+## Log Format
80+
81+```
82+[2026-02-25T22:38:53.123Z] context=turn
83+ name: APICallError
84+ message: 429 Too Many Requests
85+ statusCode: 429
86+ url: https://api.anthropic.com/v1/messages
87+ isRetryable: true
88+ stack: APICallError: 429 Too Many Requests
89+ at ...
90+---
91+```
92+
93+- Each entry ends with `---\n`.
94+- Extra fields (`statusCode`, `url`, `isRetryable`) are only emitted if present on the error object.
95+- Stack is indented two spaces per line.
96+- File is truncated on each app start (writer opened without append flag).
package.json+1−1
@@ -1,6 +1,6 @@
11 {
22 "name": "mini-coder",
3- "version": "0.0.5",
3+ "version": "0.1.0",
44 "description": "A small, fast CLI coding agent",
55 "module": "src/index.ts",
66 "type": "module",