xonecas.io
64875
Mc

mini-coder / commit f725f31

fix: align ToolExecResult with image content, remove CLAUDE.md from spec

- ToolExecResult now carries content blocks (TextContent | ImageContent)
  instead of plain text, so readImage results flow through the agent loop
- Remove CLAUDE.md from AGENTS.md discovery spec (proprietary, not a
  community standard)
- Fix ShellOpts JSDoc (said 500, actual default is 1000)
- Clarify ToolResult doc as text-only

xonecas2026-04-05 f725f3190328bc560f4302e0b64d9ce6f89d55fc parent 6349c0e

4 files changed

spec.md+1−1
@@ -102,7 +102,7 @@ There is no formal spec — AGENTS.md is a de facto convention established by Co
102102
103103 Our discovery:
104104
105-- Walk from CWD toward the **scan root**, collecting every `AGENTS.md` (and `CLAUDE.md`) found.
105+- Walk from CWD toward the **scan root**, collecting every `AGENTS.md` found.
106106 - Scan root, in priority order: **git root** (if in a repo) → **home directory** (fallback) → filesystem root (only if `MC_AGENTS_ROOT=/` is set).
107107 - Also check `~/.agents/` for global agent instructions (cross-client convention).
108108 - All files are additive, ordered root-to-leaf (general → specific).
src/agent.test.ts+31−11
@@ -10,14 +10,25 @@ import {
1010 fauxToolCall,
1111 registerFauxProvider,
1212 } from "@mariozechner/pi-ai";
13-import { type AgentEvent, type AgentTool, runAgentLoop } from "./agent.ts";
13+import {
14+ type AgentEvent,
15+ type AgentTool,
16+ runAgentLoop,
17+ type ToolExecResult,
18+} from "./agent.ts";
1419 import {
1520 appendMessage,
1621 createSession,
1722 loadMessages,
1823 openDatabase,
1924 } from "./session.ts";
20-import { editTool, executeEdit, executeShell, shellTool } from "./tools.ts";
25+import {
26+ editTool,
27+ executeEdit,
28+ executeShell,
29+ shellTool,
30+ type ToolResult,
31+} from "./tools.ts";
2132
2233 // ---------------------------------------------------------------------------
2334 // Helpers
@@ -43,24 +54,33 @@ function makeUser(text: string): UserMessage {
4354 return { role: "user", content: text, timestamp: Date.now() };
4455 }
4556
57+/** Wrap a text-only ToolResult into a ToolExecResult with content blocks. */
58+function wrapResult(r: ToolResult): ToolExecResult {
59+ return { content: [{ type: "text", text: r.text }], isError: r.isError };
60+}
61+
4662 /** Create standard built-in tools for tests. */
4763 function builtinTools(): AgentTool[] {
4864 return [
4965 {
5066 definition: shellTool,
51- execute: (args, cwd) =>
52- executeShell({ command: args.command as string }, cwd),
67+ execute: async (args, cwd) =>
68+ wrapResult(
69+ await executeShell({ command: args.command as string }, cwd),
70+ ),
5371 },
5472 {
5573 definition: editTool,
5674 execute: (args, cwd) =>
57- executeEdit(
58- {
59- path: args.path as string,
60- oldText: args.oldText as string,
61- newText: args.newText as string,
62- },
63- cwd,
75+ wrapResult(
76+ executeEdit(
77+ {
78+ path: args.path as string,
79+ oldText: args.oldText as string,
80+ newText: args.newText as string,
81+ },
82+ cwd,
83+ ),
6484 ),
6585 },
6686 ];
src/agent.ts+3−3
@@ -40,8 +40,8 @@ export interface AgentTool {
4040
4141 /** Result from executing a tool. */
4242 export interface ToolExecResult {
43- /** Text result. */
44- text: string;
43+ /** Content blocks for the tool result (text and/or images). */
44+ content: (TextContent | ImageContent)[];
4545 /** Whether the execution encountered an error. */
4646 isError: boolean;
4747 }
@@ -209,7 +209,7 @@ export async function runAgentLoop(
209209 });
210210
211211 const result = await tool.execute(toolCall.arguments, cwd, signal);
212- resultContent = [{ type: "text", text: result.text }];
212+ resultContent = result.content;
213213 isError = result.isError;
214214
215215 onEvent?.({ type: "tool_end", name: toolCall.name, result });
src/tools.ts+2−2
@@ -18,7 +18,7 @@ import { Type } from "@mariozechner/pi-ai";
1818 // Result type
1919 // ---------------------------------------------------------------------------
2020
21-/** Result returned by a tool execution. */
21+/** Result returned by a text-only tool execution. */
2222 export interface ToolResult {
2323 /** Human-readable result text. */
2424 text: string;
@@ -111,7 +111,7 @@ export interface ShellArgs {
111111
112112 /** Options for shell execution. */
113113 export interface ShellOpts {
114- /** Maximum output lines before truncation. Default: 500. */
114+ /** Maximum output lines before truncation. Default: 1000. */
115115 maxLines?: number;
116116 /** Abort signal to cancel the command. */
117117 signal?: AbortSignal;