min-agent 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/bin/min-agent.js +2 -2
- package/dist/agent.js +566 -0
- package/dist/assistant-stream.js +114 -0
- package/dist/cli.js +471 -0
- package/dist/compaction.js +99 -0
- package/dist/config.js +142 -0
- package/dist/confirm.js +37 -0
- package/dist/instructions.js +115 -0
- package/dist/markdown.js +130 -0
- package/dist/mcp.js +237 -0
- package/dist/memory.js +131 -0
- package/dist/output.js +52 -0
- package/dist/plugins.js +66 -0
- package/dist/provider.js +41 -0
- package/dist/serve.js +351 -0
- package/dist/sessions.js +74 -0
- package/dist/skills.js +127 -0
- package/dist/tool-output.js +119 -0
- package/dist/tools/bash.js +93 -0
- package/dist/tools/edit.js +51 -0
- package/dist/tools/glob.js +36 -0
- package/dist/tools/grep.js +35 -0
- package/dist/tools/index.js +20 -0
- package/dist/tools/read.js +36 -0
- package/dist/tools/web_fetch.js +83 -0
- package/dist/tools/web_search.js +40 -0
- package/dist/tools/write.js +32 -0
- package/package.json +4 -5
- package/src/agent.ts +0 -609
- package/src/assistant-stream.ts +0 -128
- package/src/cli.ts +0 -494
- package/src/compaction.ts +0 -119
- package/src/config.ts +0 -172
- package/src/confirm.ts +0 -42
- package/src/instructions.ts +0 -123
- package/src/markdown.ts +0 -140
- package/src/mcp.ts +0 -300
- package/src/memory.ts +0 -164
- package/src/output.ts +0 -58
- package/src/plugins.ts +0 -94
- package/src/provider.ts +0 -50
- package/src/serve.ts +0 -400
- package/src/sessions.ts +0 -94
- package/src/skills.ts +0 -146
- package/src/tool-output.ts +0 -146
- package/src/tools/bash.ts +0 -108
- package/src/tools/edit.ts +0 -65
- package/src/tools/glob.ts +0 -37
- package/src/tools/grep.ts +0 -37
- package/src/tools/index.ts +0 -21
- package/src/tools/read.ts +0 -38
- package/src/tools/web_fetch.ts +0 -87
- package/src/tools/web_search.ts +0 -42
- package/src/tools/write.ts +0 -36
- package/tsconfig.json +0 -15
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { tool, jsonSchema } from "ai";
|
|
2
|
+
import { truncateToolOutput } from "../tool-output.js";
|
|
3
|
+
const SEARXNG_BASE = "https://searxng.xc.lonae.com";
|
|
4
|
+
export const webSearchTool = tool({
|
|
5
|
+
description: "Search the web for information. Returns search results with titles, URLs, and snippets. Use this when you need current information, news, documentation, or answers that require up-to-date knowledge.",
|
|
6
|
+
inputSchema: jsonSchema({
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
query: { type: "string", description: "The search query" },
|
|
10
|
+
categories: { type: "string", description: "Search categories: general, news, images, science, it (default: general)" },
|
|
11
|
+
},
|
|
12
|
+
required: ["query"],
|
|
13
|
+
}),
|
|
14
|
+
execute: async ({ query, categories }) => {
|
|
15
|
+
try {
|
|
16
|
+
const params = new URLSearchParams({
|
|
17
|
+
q: query,
|
|
18
|
+
format: "json",
|
|
19
|
+
categories: categories ?? "general",
|
|
20
|
+
});
|
|
21
|
+
const response = await fetch(`${SEARXNG_BASE}/search?${params}`, {
|
|
22
|
+
headers: { "Accept": "application/json" },
|
|
23
|
+
signal: AbortSignal.timeout(15000),
|
|
24
|
+
});
|
|
25
|
+
if (!response.ok)
|
|
26
|
+
return `Search error: HTTP ${response.status}`;
|
|
27
|
+
const data = await response.json();
|
|
28
|
+
const results = (data.results ?? []).slice(0, 10);
|
|
29
|
+
if (results.length === 0)
|
|
30
|
+
return "No search results found. Try a different query.";
|
|
31
|
+
const text = results
|
|
32
|
+
.map((r, i) => `${i + 1}. ${r.title}\n ${r.url}\n ${r.content ?? ""}`)
|
|
33
|
+
.join("\n\n");
|
|
34
|
+
return truncateToolOutput(text, { direction: "head" }).content;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
return `Search error: ${err.message}`;
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { tool, jsonSchema } from "ai";
|
|
2
|
+
import { writeFileSync, mkdirSync, existsSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { confirm, isAutoApprove } from "../confirm.js";
|
|
5
|
+
export const writeTool = tool({
|
|
6
|
+
description: "Write content to a file. Creates the file if it doesn't exist, overwrites if it does. Creates parent directories as needed.",
|
|
7
|
+
inputSchema: jsonSchema({
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
filePath: { type: "string", description: "Path to the file to write (relative to cwd or absolute)" },
|
|
11
|
+
content: { type: "string", description: "The content to write to the file" },
|
|
12
|
+
},
|
|
13
|
+
required: ["filePath", "content"],
|
|
14
|
+
}),
|
|
15
|
+
execute: async ({ filePath, content }) => {
|
|
16
|
+
const resolved = path.resolve(process.cwd(), filePath);
|
|
17
|
+
// Confirm overwriting existing files
|
|
18
|
+
if (!isAutoApprove() && existsSync(resolved)) {
|
|
19
|
+
const approved = await confirm(`Overwrite existing file: ${filePath}`);
|
|
20
|
+
if (!approved)
|
|
21
|
+
return "Write rejected by user.";
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
mkdirSync(path.dirname(resolved), { recursive: true });
|
|
25
|
+
writeFileSync(resolved, content, "utf-8");
|
|
26
|
+
return `Written ${content.length} bytes to ${filePath}`;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return `Error writing file: ${err.message}`;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "min-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Minimal AI coding agent with tool use, MCP, and skills support",
|
|
6
6
|
"license": "MIT",
|
|
@@ -8,13 +8,12 @@
|
|
|
8
8
|
"min-agent": "./bin/min-agent.js"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
|
-
"
|
|
11
|
+
"node": ">=20.0.0"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
|
-
"
|
|
15
|
+
"dist",
|
|
16
16
|
"docs",
|
|
17
|
-
"tsconfig.json",
|
|
18
17
|
"README.md",
|
|
19
18
|
"LICENSE"
|
|
20
19
|
],
|
|
@@ -33,7 +32,7 @@
|
|
|
33
32
|
"dev": "bun run src/cli.ts",
|
|
34
33
|
"build": "tsc",
|
|
35
34
|
"typecheck": "tsc --noEmit",
|
|
36
|
-
"
|
|
35
|
+
"prepack": "npm run typecheck && npm run build"
|
|
37
36
|
},
|
|
38
37
|
"keywords": [
|
|
39
38
|
"ai",
|