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.
Files changed (56) hide show
  1. package/README.md +6 -0
  2. package/bin/min-agent.js +2 -2
  3. package/dist/agent.js +566 -0
  4. package/dist/assistant-stream.js +114 -0
  5. package/dist/cli.js +471 -0
  6. package/dist/compaction.js +99 -0
  7. package/dist/config.js +142 -0
  8. package/dist/confirm.js +37 -0
  9. package/dist/instructions.js +115 -0
  10. package/dist/markdown.js +130 -0
  11. package/dist/mcp.js +237 -0
  12. package/dist/memory.js +131 -0
  13. package/dist/output.js +52 -0
  14. package/dist/plugins.js +66 -0
  15. package/dist/provider.js +41 -0
  16. package/dist/serve.js +351 -0
  17. package/dist/sessions.js +74 -0
  18. package/dist/skills.js +127 -0
  19. package/dist/tool-output.js +119 -0
  20. package/dist/tools/bash.js +93 -0
  21. package/dist/tools/edit.js +51 -0
  22. package/dist/tools/glob.js +36 -0
  23. package/dist/tools/grep.js +35 -0
  24. package/dist/tools/index.js +20 -0
  25. package/dist/tools/read.js +36 -0
  26. package/dist/tools/web_fetch.js +83 -0
  27. package/dist/tools/web_search.js +40 -0
  28. package/dist/tools/write.js +32 -0
  29. package/package.json +4 -5
  30. package/src/agent.ts +0 -609
  31. package/src/assistant-stream.ts +0 -128
  32. package/src/cli.ts +0 -494
  33. package/src/compaction.ts +0 -119
  34. package/src/config.ts +0 -172
  35. package/src/confirm.ts +0 -42
  36. package/src/instructions.ts +0 -123
  37. package/src/markdown.ts +0 -140
  38. package/src/mcp.ts +0 -300
  39. package/src/memory.ts +0 -164
  40. package/src/output.ts +0 -58
  41. package/src/plugins.ts +0 -94
  42. package/src/provider.ts +0 -50
  43. package/src/serve.ts +0 -400
  44. package/src/sessions.ts +0 -94
  45. package/src/skills.ts +0 -146
  46. package/src/tool-output.ts +0 -146
  47. package/src/tools/bash.ts +0 -108
  48. package/src/tools/edit.ts +0 -65
  49. package/src/tools/glob.ts +0 -37
  50. package/src/tools/grep.ts +0 -37
  51. package/src/tools/index.ts +0 -21
  52. package/src/tools/read.ts +0 -38
  53. package/src/tools/web_fetch.ts +0 -87
  54. package/src/tools/web_search.ts +0 -42
  55. package/src/tools/write.ts +0 -36
  56. 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.0",
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
- "bun": ">=1.0.0"
11
+ "node": ">=20.0.0"
12
12
  },
13
13
  "files": [
14
14
  "bin",
15
- "src",
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
- "prepublishOnly": "npm run typecheck"
35
+ "prepack": "npm run typecheck && npm run build"
37
36
  },
38
37
  "keywords": [
39
38
  "ai",