@vietor/easy-agent 0.3.1 → 0.4.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 +31 -22
- package/dist/cli.js +0 -0
- package/dist/cmds/builtin.js +17 -56
- package/dist/config.js +1 -1
- package/dist/main.js +26 -44
- package/dist/tui/App.js +29 -18
- package/dist/tui/AppHeader.js +4 -3
- package/dist/tui/LogList.js +9 -0
- package/dist/tui/PromptOrCommandInput.js +8 -6
- package/dist/tui/TodoView.js +19 -0
- package/dist/util/package.js +2 -3
- package/package.json +18 -21
- package/dist/cmds/registry.js +0 -30
- package/dist/cmds/types.js +0 -1
- package/dist/core/agent.js +0 -134
- package/dist/core/conversation.js +0 -82
- package/dist/core/logstore.js +0 -49
- package/dist/core/session.js +0 -181
- package/dist/llm/client.js +0 -80
- package/dist/llm/types.js +0 -1
- package/dist/mcp/client.js +0 -81
- package/dist/mcp/server.js +0 -124
- package/dist/skills/loader.js +0 -43
- package/dist/skills/types.js +0 -1
- package/dist/tools/ask_user.js +0 -24
- package/dist/tools/file_edit.js +0 -47
- package/dist/tools/file_read.js +0 -43
- package/dist/tools/file_write.js +0 -22
- package/dist/tools/glob.js +0 -29
- package/dist/tools/grep.js +0 -73
- package/dist/tools/registry.js +0 -52
- package/dist/tools/shell.js +0 -34
- package/dist/tools/types.js +0 -1
- package/dist/tools/web_fetch.js +0 -141
- package/dist/util/async.js +0 -58
- package/dist/util/fs.js +0 -17
- package/dist/util/process.js +0 -43
- package/dist/util/ripgrep.js +0 -17
package/dist/util/async.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
export async function withRetry(fn, opts) {
|
|
2
|
-
for (let attempt = 0;; attempt++) {
|
|
3
|
-
try {
|
|
4
|
-
return await fn();
|
|
5
|
-
}
|
|
6
|
-
catch (e) {
|
|
7
|
-
if (attempt < opts.retries && opts.retryable(e)) {
|
|
8
|
-
opts.onRetry?.(attempt + 1, opts.retries);
|
|
9
|
-
await trySleep(opts.backoff(attempt), opts.signal);
|
|
10
|
-
continue;
|
|
11
|
-
}
|
|
12
|
-
throw e;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function trySleep(ms, signal) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
if (signal?.aborted) {
|
|
19
|
-
reject(new Error("aborted"));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const onAbort = () => {
|
|
23
|
-
clearTimeout(timer);
|
|
24
|
-
reject(new Error("aborted"));
|
|
25
|
-
};
|
|
26
|
-
const timer = setTimeout(() => {
|
|
27
|
-
signal?.removeEventListener("abort", onAbort);
|
|
28
|
-
resolve();
|
|
29
|
-
}, ms);
|
|
30
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
export async function withAbort(fn, opts) {
|
|
34
|
-
const onAbort = () => opts.onAbort?.();
|
|
35
|
-
if (opts.signal?.aborted)
|
|
36
|
-
onAbort();
|
|
37
|
-
else
|
|
38
|
-
opts.signal?.addEventListener("abort", onAbort, { once: true });
|
|
39
|
-
try {
|
|
40
|
-
return await fn(() => !!opts.signal?.aborted);
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
opts.signal?.removeEventListener("abort", onAbort);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export function withTimeout(p, ms) {
|
|
47
|
-
let timer;
|
|
48
|
-
const timed = new Promise((_, reject) => {
|
|
49
|
-
timer = setTimeout(() => reject(new Error(`timeout after ${ms}ms`)), ms);
|
|
50
|
-
});
|
|
51
|
-
return Promise.race([
|
|
52
|
-
p.finally(() => {
|
|
53
|
-
if (timer)
|
|
54
|
-
clearTimeout(timer);
|
|
55
|
-
}),
|
|
56
|
-
timed,
|
|
57
|
-
]);
|
|
58
|
-
}
|
package/dist/util/fs.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
export function tryReadFileText(path) {
|
|
3
|
-
if (existsSync(path)) {
|
|
4
|
-
const content = readFileSync(path, "utf-8").trim();
|
|
5
|
-
if (content)
|
|
6
|
-
return content;
|
|
7
|
-
}
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
export function readFirstFileContent(paths, fn) {
|
|
11
|
-
for (const p of paths) {
|
|
12
|
-
const content = fn(p);
|
|
13
|
-
if (content)
|
|
14
|
-
return content;
|
|
15
|
-
}
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
package/dist/util/process.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
const MAX_BUFFER = 10 * 1024 * 1024;
|
|
3
|
-
export function runProcess(cmd, args, opts = {}, signal) {
|
|
4
|
-
return new Promise((resolve) => {
|
|
5
|
-
const child = spawn(cmd, args, {
|
|
6
|
-
cwd: opts.cwd,
|
|
7
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
8
|
-
});
|
|
9
|
-
const onAbort = () => child.kill();
|
|
10
|
-
if (signal) {
|
|
11
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
12
|
-
if (signal.aborted)
|
|
13
|
-
onAbort();
|
|
14
|
-
}
|
|
15
|
-
const outChunks = [];
|
|
16
|
-
const errChunks = [];
|
|
17
|
-
let size = 0;
|
|
18
|
-
let overflow = false;
|
|
19
|
-
child.stdout?.on("data", (c) => {
|
|
20
|
-
outChunks.push(c);
|
|
21
|
-
size += c.length;
|
|
22
|
-
if (size > MAX_BUFFER) {
|
|
23
|
-
overflow = true;
|
|
24
|
-
child.kill();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
child.stderr?.on("data", (c) => {
|
|
28
|
-
errChunks.push(c);
|
|
29
|
-
});
|
|
30
|
-
child.on("error", (error) => {
|
|
31
|
-
signal?.removeEventListener("abort", onAbort);
|
|
32
|
-
resolve({ stdout: "", stderr: "", status: null, error });
|
|
33
|
-
});
|
|
34
|
-
child.on("close", (status) => {
|
|
35
|
-
signal?.removeEventListener("abort", onAbort);
|
|
36
|
-
const stdout = Buffer.concat(outChunks).toString("utf-8");
|
|
37
|
-
const stderr = Buffer.concat(errChunks).toString("utf-8");
|
|
38
|
-
resolve(overflow
|
|
39
|
-
? { stdout, stderr, status, error: new Error("output exceeded maxBuffer") }
|
|
40
|
-
: { stdout, stderr, status });
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
package/dist/util/ripgrep.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, join } from "node:path";
|
|
2
|
-
import { rgPath } from "@vscode/ripgrep";
|
|
3
|
-
import { runProcess } from "./process.js";
|
|
4
|
-
export function resolveCwd(path) {
|
|
5
|
-
const root = path || ".";
|
|
6
|
-
return isAbsolute(root) ? root : join(process.cwd(), root);
|
|
7
|
-
}
|
|
8
|
-
export async function runRgLines(args, cwd, signal) {
|
|
9
|
-
const rgArgs = ["--hidden", "--path-separator", "/", "-g", "!.git/**", "-g", "!node_modules/**", ...args];
|
|
10
|
-
const r = await runProcess(rgPath, rgArgs, { cwd }, signal);
|
|
11
|
-
if (r.error)
|
|
12
|
-
throw r.error;
|
|
13
|
-
if (r.status !== 0 && r.status !== 1) {
|
|
14
|
-
throw new Error((r.stderr || "").trim() || `ripgrep exited with ${r.status}`);
|
|
15
|
-
}
|
|
16
|
-
return r.stdout.split("\n").filter(Boolean).map((f) => f.replace(/^\.\//, ""));
|
|
17
|
-
}
|