agentool 1.0.0 → 1.1.1
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 +132 -21
- package/dist/ask-user/index.cjs +5 -2
- package/dist/ask-user/index.d.cts +10 -1
- package/dist/ask-user/index.d.ts +10 -1
- package/dist/ask-user/index.js +5 -2
- package/dist/bash/index.cjs +5 -2
- package/dist/bash/index.d.cts +14 -1
- package/dist/bash/index.d.ts +14 -1
- package/dist/bash/index.js +5 -2
- package/dist/chunk-2JBLVFB7.cjs +74 -0
- package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
- package/dist/{chunk-XKG2A3EW.js → chunk-2WSZCOJP.js} +54 -18
- package/dist/chunk-3FT4ZPB2.cjs +65 -0
- package/dist/{chunk-VLNDEVKS.js → chunk-3LGXZLBH.js} +46 -8
- package/dist/{chunk-G3ITTPGX.js → chunk-4MXDQEPA.js} +12 -1
- package/dist/{chunk-CGTPF6IS.js → chunk-4UUSERSH.js} +31 -7
- package/dist/{chunk-I6KFFQPV.cjs → chunk-5T3SQYI4.cjs} +34 -4
- package/dist/chunk-6ULQG2W2.cjs +99 -0
- package/dist/chunk-ABXTBB2N.cjs +67 -0
- package/dist/{chunk-CAEVLIQB.cjs → chunk-BIAODQ2P.cjs} +17 -1
- package/dist/chunk-CJA76MKM.js +59 -0
- package/dist/chunk-CM3VRCNX.cjs +59 -0
- package/dist/{chunk-SUSAPI5W.cjs → chunk-CXBWF5ON.cjs} +51 -4
- package/dist/{chunk-U2YMJM25.cjs → chunk-G6ZVJA4V.cjs} +31 -8
- package/dist/chunk-GPHCXS2S.js +99 -0
- package/dist/chunk-HG5T47NA.cjs +77 -0
- package/dist/chunk-HO4NIRU5.js +65 -0
- package/dist/{chunk-HZAQRHBT.js → chunk-IBC4QCGR.js} +27 -2
- package/dist/chunk-JYTOARJV.cjs +69 -0
- package/dist/chunk-KONXT2SF.cjs +8 -0
- package/dist/chunk-KUFZFNPT.cjs +61 -0
- package/dist/chunk-L7R4UZSK.js +61 -0
- package/dist/{chunk-FV2R5FFQ.cjs → chunk-LNAR3NJQ.cjs} +47 -9
- package/dist/chunk-M74OQYNK.js +69 -0
- package/dist/{chunk-IMZQ7ELK.cjs → chunk-NQIV6LBH.cjs} +51 -14
- package/dist/chunk-NTGDU5X3.js +67 -0
- package/dist/{chunk-ONBH74ZV.cjs → chunk-OYLTQJXT.cjs} +32 -8
- package/dist/{chunk-6PQLFDGT.js → chunk-PWBVB6MN.js} +17 -1
- package/dist/{chunk-QEJV2KZ4.cjs → chunk-RIGL3JTS.cjs} +55 -19
- package/dist/chunk-SFDZRLSX.cjs +91 -0
- package/dist/chunk-T6STO7PS.cjs +126 -0
- package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
- package/dist/chunk-TM5L4HA5.js +126 -0
- package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
- package/dist/chunk-UCA6LURO.js +74 -0
- package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
- package/dist/chunk-VHLY7LQE.js +53 -0
- package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
- package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
- package/dist/chunk-VQSWMGG7.cjs +53 -0
- package/dist/{chunk-Y7KOKDFP.js → chunk-VZRXTFS4.js} +29 -6
- package/dist/chunk-WCR62UZ3.js +67 -0
- package/dist/chunk-X6ZY2KFU.js +8 -0
- package/dist/chunk-XGDE7S2D.cjs +67 -0
- package/dist/chunk-XPTW45XY.js +77 -0
- package/dist/{chunk-YPPPGGLA.cjs → chunk-YCWJVQYO.cjs} +28 -3
- package/dist/chunk-YGXLT6SS.js +91 -0
- package/dist/{chunk-5NW4OGRI.cjs → chunk-YTPZHJDC.cjs} +12 -1
- package/dist/{chunk-6MDPYALY.js → chunk-ZHVRP3EH.js} +49 -12
- package/dist/context-compaction/index.cjs +5 -2
- package/dist/context-compaction/index.d.cts +11 -1
- package/dist/context-compaction/index.d.ts +11 -1
- package/dist/context-compaction/index.js +5 -2
- package/dist/diff/index.cjs +6 -2
- package/dist/diff/index.d.cts +12 -2
- package/dist/diff/index.d.ts +12 -2
- package/dist/diff/index.js +7 -3
- package/dist/edit/index.cjs +7 -3
- package/dist/edit/index.d.cts +15 -5
- package/dist/edit/index.d.ts +15 -5
- package/dist/edit/index.js +8 -4
- package/dist/glob/index.cjs +5 -2
- package/dist/glob/index.d.cts +13 -3
- package/dist/glob/index.d.ts +13 -3
- package/dist/glob/index.js +5 -2
- package/dist/grep/index.cjs +6 -2
- package/dist/grep/index.d.cts +13 -3
- package/dist/grep/index.d.ts +13 -3
- package/dist/grep/index.js +6 -2
- package/dist/http-request/index.cjs +5 -2
- package/dist/http-request/index.d.cts +11 -1
- package/dist/http-request/index.d.ts +11 -1
- package/dist/http-request/index.js +5 -2
- package/dist/index.cjs +93 -19
- package/dist/index.d.cts +21 -16
- package/dist/index.d.ts +21 -16
- package/dist/index.js +113 -39
- package/dist/lsp/index.cjs +6 -2
- package/dist/lsp/index.d.cts +16 -10
- package/dist/lsp/index.d.ts +16 -10
- package/dist/lsp/index.js +6 -2
- package/dist/memory/index.cjs +6 -2
- package/dist/memory/index.d.cts +10 -1
- package/dist/memory/index.d.ts +10 -1
- package/dist/memory/index.js +6 -2
- package/dist/multi-edit/index.cjs +7 -4
- package/dist/multi-edit/index.d.cts +12 -2
- package/dist/multi-edit/index.d.ts +12 -2
- package/dist/multi-edit/index.js +7 -4
- package/dist/read/index.cjs +6 -3
- package/dist/read/index.d.cts +11 -1
- package/dist/read/index.d.ts +11 -1
- package/dist/read/index.js +6 -3
- package/dist/sleep/index.cjs +5 -2
- package/dist/sleep/index.d.cts +11 -1
- package/dist/sleep/index.d.ts +11 -1
- package/dist/sleep/index.js +5 -2
- package/dist/task-create/index.cjs +13 -0
- package/dist/task-create/index.d.cts +28 -0
- package/dist/task-create/index.d.ts +28 -0
- package/dist/task-create/index.js +13 -0
- package/dist/task-get/index.cjs +13 -0
- package/dist/task-get/index.d.cts +24 -0
- package/dist/task-get/index.d.ts +24 -0
- package/dist/task-get/index.js +13 -0
- package/dist/task-list/index.cjs +13 -0
- package/dist/task-list/index.d.cts +20 -0
- package/dist/task-list/index.d.ts +20 -0
- package/dist/task-list/index.js +13 -0
- package/dist/task-update/index.cjs +13 -0
- package/dist/task-update/index.d.cts +40 -0
- package/dist/task-update/index.d.ts +40 -0
- package/dist/task-update/index.js +13 -0
- package/dist/tool-search/index.cjs +11 -0
- package/dist/tool-search/index.d.cts +27 -0
- package/dist/tool-search/index.d.ts +27 -0
- package/dist/tool-search/index.js +11 -0
- package/dist/web-fetch/index.cjs +5 -2
- package/dist/web-fetch/index.d.cts +11 -3
- package/dist/web-fetch/index.d.ts +11 -3
- package/dist/web-fetch/index.js +5 -2
- package/dist/web-search/index.cjs +11 -0
- package/dist/web-search/index.d.cts +30 -0
- package/dist/web-search/index.d.ts +30 -0
- package/dist/web-search/index.js +11 -0
- package/dist/write/index.cjs +6 -3
- package/dist/write/index.d.cts +13 -3
- package/dist/write/index.d.ts +13 -3
- package/dist/write/index.js +6 -3
- package/package.json +31 -6
- package/dist/chunk-3EPGFWZV.cjs +0 -30
- package/dist/chunk-7QL4BQCH.js +0 -40
- package/dist/chunk-FAEGCFTO.js +0 -136
- package/dist/chunk-HDKXSKMO.js +0 -30
- package/dist/chunk-JCTBB7H2.cjs +0 -40
- package/dist/chunk-MF7CJVIZ.js +0 -40
- package/dist/chunk-MXFW3XY6.cjs +0 -73
- package/dist/chunk-OXLQ7QVL.cjs +0 -40
- package/dist/chunk-S6QEY7UY.js +0 -73
- package/dist/chunk-TBVHHF3H.cjs +0 -47
- package/dist/chunk-XLD2Y3SS.cjs +0 -136
- package/dist/chunk-ZHCMEQJJ.js +0 -47
- package/dist/task/index.cjs +0 -8
- package/dist/task/index.d.cts +0 -67
- package/dist/task/index.d.ts +0 -67
- package/dist/task/index.js +0 -8
package/dist/chunk-S6QEY7UY.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
applyEditToFile,
|
|
3
|
-
findActualString,
|
|
4
|
-
preserveQuoteStyle
|
|
5
|
-
} from "./chunk-G3ITTPGX.js";
|
|
6
|
-
import {
|
|
7
|
-
expandPath
|
|
8
|
-
} from "./chunk-I3ONDY7P.js";
|
|
9
|
-
|
|
10
|
-
// src/edit/index.ts
|
|
11
|
-
import { readFile, writeFile } from "fs/promises";
|
|
12
|
-
import { tool } from "ai";
|
|
13
|
-
import { z } from "zod";
|
|
14
|
-
function createEdit(config = {}) {
|
|
15
|
-
return tool({
|
|
16
|
-
description: "Perform an exact string replacement in a file. Locates old_string in the file and replaces it with new_string. Supports curly-quote fallback matching. When replace_all is false (default), old_string must appear exactly once.",
|
|
17
|
-
inputSchema: z.object({
|
|
18
|
-
file_path: z.string().describe("Path to the file to edit"),
|
|
19
|
-
old_string: z.string().describe("The exact string to find and replace"),
|
|
20
|
-
new_string: z.string().describe("The replacement string"),
|
|
21
|
-
replace_all: z.boolean().optional().default(false).describe("Replace all occurrences (default: false)")
|
|
22
|
-
}),
|
|
23
|
-
execute: async ({ file_path, old_string, new_string, replace_all }) => {
|
|
24
|
-
try {
|
|
25
|
-
const resolved = expandPath(file_path, config.cwd);
|
|
26
|
-
let content;
|
|
27
|
-
try {
|
|
28
|
-
content = await readFile(resolved, "utf-8");
|
|
29
|
-
} catch (err) {
|
|
30
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
31
|
-
return `Error [edit]: Cannot read file "${resolved}": ${msg}`;
|
|
32
|
-
}
|
|
33
|
-
if (old_string === new_string) {
|
|
34
|
-
return "Error [edit]: old_string and new_string are identical \u2014 nothing to change.";
|
|
35
|
-
}
|
|
36
|
-
const actualOld = findActualString(content, old_string);
|
|
37
|
-
if (actualOld === null) {
|
|
38
|
-
const preview = content.slice(0, 200);
|
|
39
|
-
return `Error [edit]: old_string not found in "${resolved}". File starts with:
|
|
40
|
-
${preview}`;
|
|
41
|
-
}
|
|
42
|
-
if (!replace_all) {
|
|
43
|
-
let count = 0;
|
|
44
|
-
let pos = 0;
|
|
45
|
-
while (pos < content.length) {
|
|
46
|
-
const idx = content.indexOf(actualOld, pos);
|
|
47
|
-
if (idx === -1) break;
|
|
48
|
-
count++;
|
|
49
|
-
pos = idx + 1;
|
|
50
|
-
}
|
|
51
|
-
if (count > 1) {
|
|
52
|
-
return `Error [edit]: old_string appears ${count} times in "${resolved}". Use replace_all to replace every occurrence, or provide a more specific string.`;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const styledNew = preserveQuoteStyle(old_string, actualOld, new_string);
|
|
56
|
-
const updated = applyEditToFile(content, actualOld, styledNew, replace_all);
|
|
57
|
-
await writeFile(resolved, updated, "utf-8");
|
|
58
|
-
const snippet = styledNew.length > 0 ? styledNew.slice(0, 200) : "(deletion)";
|
|
59
|
-
return `Successfully edited "${resolved}". Replacement snippet:
|
|
60
|
-
${snippet}`;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
63
|
-
return `Error [edit]: ${msg}`;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
var edit = createEdit();
|
|
69
|
-
|
|
70
|
-
export {
|
|
71
|
-
createEdit,
|
|
72
|
-
edit
|
|
73
|
-
};
|
package/dist/chunk-TBVHHF3H.cjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkCAEVLIQBcjs = require('./chunk-CAEVLIQB.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
|
|
8
|
-
|
|
9
|
-
// src/read/index.ts
|
|
10
|
-
var _ai = require('ai');
|
|
11
|
-
var _zod = require('zod');
|
|
12
|
-
function createRead(config = {}) {
|
|
13
|
-
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
14
|
-
const defaultMaxLines = _nullishCoalesce(config.maxLines, () => ( 2e3));
|
|
15
|
-
return _ai.tool.call(void 0, {
|
|
16
|
-
description: 'Read a file from the local filesystem and return its contents with line numbers. Supports absolute paths, relative paths (resolved against the working directory), and tilde (~) home directory expansion. Returns numbered lines in "lineNumber\\tcontent" format. Use offset and limit to read specific ranges of large files.',
|
|
17
|
-
inputSchema: _zod.z.object({
|
|
18
|
-
file_path: _zod.z.string().describe("The path to the file to read (absolute, relative, or ~/...)"),
|
|
19
|
-
offset: _zod.z.number().optional().describe("0-indexed line number to start reading from (default: 0)"),
|
|
20
|
-
limit: _zod.z.number().optional().describe("Maximum number of lines to return (default: 2000)")
|
|
21
|
-
}),
|
|
22
|
-
execute: async ({ file_path, offset, limit }) => {
|
|
23
|
-
try {
|
|
24
|
-
const absolutePath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
|
|
25
|
-
const result = await _chunkCAEVLIQBcjs.readFileInRange.call(void 0,
|
|
26
|
-
absolutePath,
|
|
27
|
-
_nullishCoalesce(offset, () => ( 0)),
|
|
28
|
-
_nullishCoalesce(limit, () => ( defaultMaxLines))
|
|
29
|
-
);
|
|
30
|
-
const numbered = _chunkCAEVLIQBcjs.addLineNumbers.call(void 0, {
|
|
31
|
-
content: result.content,
|
|
32
|
-
startLine: (_nullishCoalesce(offset, () => ( 0))) + 1
|
|
33
|
-
});
|
|
34
|
-
return numbered;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
37
|
-
return `Error [read]: ${msg}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
var read = createRead();
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.createRead = createRead; exports.read = read;
|
package/dist/chunk-XLD2Y3SS.cjs
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/task/index.ts
|
|
2
|
-
var _ai = require('ai');
|
|
3
|
-
var _zod = require('zod');
|
|
4
|
-
var _promises = require('fs/promises');
|
|
5
|
-
var _path = require('path');
|
|
6
|
-
var _crypto = require('crypto');
|
|
7
|
-
function generateId() {
|
|
8
|
-
return _crypto.randomBytes.call(void 0, 4).toString("hex");
|
|
9
|
-
}
|
|
10
|
-
async function loadTasks(filePath) {
|
|
11
|
-
try {
|
|
12
|
-
const data = await _promises.readFile.call(void 0, filePath, "utf-8");
|
|
13
|
-
return JSON.parse(data);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
async function saveTasks(filePath, tasks) {
|
|
19
|
-
await _promises.mkdir.call(void 0, _path.dirname.call(void 0, filePath), { recursive: true });
|
|
20
|
-
await _promises.writeFile.call(void 0, filePath, JSON.stringify(tasks, null, 2), "utf-8");
|
|
21
|
-
}
|
|
22
|
-
function formatTask(t) {
|
|
23
|
-
return [
|
|
24
|
-
`ID: ${t.id}`,
|
|
25
|
-
`Subject: ${t.subject}`,
|
|
26
|
-
`Description: ${t.description}`,
|
|
27
|
-
`Status: ${t.status}`,
|
|
28
|
-
`Created: ${t.createdAt}`,
|
|
29
|
-
`Updated: ${t.updatedAt}`
|
|
30
|
-
].join("\n");
|
|
31
|
-
}
|
|
32
|
-
function createTask(config = {}) {
|
|
33
|
-
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
34
|
-
const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
|
|
35
|
-
return _ai.tool.call(void 0, {
|
|
36
|
-
description: "JSON file-based task tracker. Use this to create, get, update, list, and delete tasks. Each task has an id, subject, description, status, and timestamps.",
|
|
37
|
-
inputSchema: _zod.z.object({
|
|
38
|
-
action: _zod.z.enum(["create", "get", "update", "list", "delete"]).describe(
|
|
39
|
-
"The operation to perform"
|
|
40
|
-
),
|
|
41
|
-
id: _zod.z.string().optional().describe(
|
|
42
|
-
"Task id (required for get, update, delete)"
|
|
43
|
-
),
|
|
44
|
-
subject: _zod.z.string().optional().describe(
|
|
45
|
-
"Task subject (required for create, optional for update)"
|
|
46
|
-
),
|
|
47
|
-
description: _zod.z.string().optional().describe(
|
|
48
|
-
"Task description (required for create, optional for update)"
|
|
49
|
-
),
|
|
50
|
-
status: _zod.z.enum(["pending", "in_progress", "completed"]).optional().describe(
|
|
51
|
-
"Task status (optional for create/update, defaults to pending)"
|
|
52
|
-
)
|
|
53
|
-
}),
|
|
54
|
-
execute: async ({ action, id, subject, description, status }) => {
|
|
55
|
-
try {
|
|
56
|
-
switch (action) {
|
|
57
|
-
case "create":
|
|
58
|
-
return await createEntry(tasksFile, subject, description, status);
|
|
59
|
-
case "list":
|
|
60
|
-
return await listEntries(tasksFile);
|
|
61
|
-
case "get":
|
|
62
|
-
return await getEntry(tasksFile, id);
|
|
63
|
-
case "update":
|
|
64
|
-
return await updateEntry(tasksFile, id, subject, description, status);
|
|
65
|
-
case "delete":
|
|
66
|
-
return await deleteEntry(tasksFile, id);
|
|
67
|
-
default:
|
|
68
|
-
return `Error [task]: Unknown action "${String(action)}".`;
|
|
69
|
-
}
|
|
70
|
-
} catch (error) {
|
|
71
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
72
|
-
return `Error [task]: ${msg}`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
async function createEntry(filePath, subject, description, status) {
|
|
78
|
-
if (!subject) return "Error [task]: Subject is required for create action.";
|
|
79
|
-
if (!description) return "Error [task]: Description is required for create action.";
|
|
80
|
-
const tasks = await loadTasks(filePath);
|
|
81
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
82
|
-
const entry = {
|
|
83
|
-
id: generateId(),
|
|
84
|
-
subject,
|
|
85
|
-
description,
|
|
86
|
-
status: _nullishCoalesce(status, () => ( "pending")),
|
|
87
|
-
createdAt: now,
|
|
88
|
-
updatedAt: now
|
|
89
|
-
};
|
|
90
|
-
tasks.push(entry);
|
|
91
|
-
await saveTasks(filePath, tasks);
|
|
92
|
-
return `Created task ${entry.id}.
|
|
93
|
-
${formatTask(entry)}`;
|
|
94
|
-
}
|
|
95
|
-
async function listEntries(filePath) {
|
|
96
|
-
const tasks = await loadTasks(filePath);
|
|
97
|
-
if (tasks.length === 0) return "No tasks found.";
|
|
98
|
-
return tasks.map(formatTask).join("\n---\n");
|
|
99
|
-
}
|
|
100
|
-
async function getEntry(filePath, id) {
|
|
101
|
-
if (!id) return "Error [task]: ID is required for get action.";
|
|
102
|
-
const tasks = await loadTasks(filePath);
|
|
103
|
-
const found = tasks.find((t) => t.id === id);
|
|
104
|
-
if (!found) return `Error [task]: Task "${id}" not found.`;
|
|
105
|
-
return formatTask(found);
|
|
106
|
-
}
|
|
107
|
-
async function updateEntry(filePath, id, subject, description, status) {
|
|
108
|
-
if (!id) return "Error [task]: ID is required for update action.";
|
|
109
|
-
const tasks = await loadTasks(filePath);
|
|
110
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
111
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
112
|
-
const entry = tasks[idx];
|
|
113
|
-
if (subject) entry.subject = subject;
|
|
114
|
-
if (description) entry.description = description;
|
|
115
|
-
if (status) entry.status = status;
|
|
116
|
-
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
117
|
-
tasks[idx] = entry;
|
|
118
|
-
await saveTasks(filePath, tasks);
|
|
119
|
-
return `Updated task ${id}.
|
|
120
|
-
${formatTask(entry)}`;
|
|
121
|
-
}
|
|
122
|
-
async function deleteEntry(filePath, id) {
|
|
123
|
-
if (!id) return "Error [task]: ID is required for delete action.";
|
|
124
|
-
const tasks = await loadTasks(filePath);
|
|
125
|
-
const idx = tasks.findIndex((t) => t.id === id);
|
|
126
|
-
if (idx === -1) return `Error [task]: Task "${id}" not found.`;
|
|
127
|
-
tasks.splice(idx, 1);
|
|
128
|
-
await saveTasks(filePath, tasks);
|
|
129
|
-
return `Deleted task "${id}".`;
|
|
130
|
-
}
|
|
131
|
-
var task = createTask();
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
exports.createTask = createTask; exports.task = task;
|
package/dist/chunk-ZHCMEQJJ.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
addLineNumbers,
|
|
3
|
-
readFileInRange
|
|
4
|
-
} from "./chunk-6PQLFDGT.js";
|
|
5
|
-
import {
|
|
6
|
-
expandPath
|
|
7
|
-
} from "./chunk-I3ONDY7P.js";
|
|
8
|
-
|
|
9
|
-
// src/read/index.ts
|
|
10
|
-
import { tool } from "ai";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
function createRead(config = {}) {
|
|
13
|
-
const cwd = config.cwd ?? process.cwd();
|
|
14
|
-
const defaultMaxLines = config.maxLines ?? 2e3;
|
|
15
|
-
return tool({
|
|
16
|
-
description: 'Read a file from the local filesystem and return its contents with line numbers. Supports absolute paths, relative paths (resolved against the working directory), and tilde (~) home directory expansion. Returns numbered lines in "lineNumber\\tcontent" format. Use offset and limit to read specific ranges of large files.',
|
|
17
|
-
inputSchema: z.object({
|
|
18
|
-
file_path: z.string().describe("The path to the file to read (absolute, relative, or ~/...)"),
|
|
19
|
-
offset: z.number().optional().describe("0-indexed line number to start reading from (default: 0)"),
|
|
20
|
-
limit: z.number().optional().describe("Maximum number of lines to return (default: 2000)")
|
|
21
|
-
}),
|
|
22
|
-
execute: async ({ file_path, offset, limit }) => {
|
|
23
|
-
try {
|
|
24
|
-
const absolutePath = expandPath(file_path, cwd);
|
|
25
|
-
const result = await readFileInRange(
|
|
26
|
-
absolutePath,
|
|
27
|
-
offset ?? 0,
|
|
28
|
-
limit ?? defaultMaxLines
|
|
29
|
-
);
|
|
30
|
-
const numbered = addLineNumbers({
|
|
31
|
-
content: result.content,
|
|
32
|
-
startLine: (offset ?? 0) + 1
|
|
33
|
-
});
|
|
34
|
-
return numbered;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
37
|
-
return `Error [read]: ${msg}`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
var read = createRead();
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
createRead,
|
|
46
|
-
read
|
|
47
|
-
};
|
package/dist/task/index.cjs
DELETED
package/dist/task/index.d.cts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the task tool.
|
|
6
|
-
* Extends {@link BaseToolConfig} with an optional tasks file path.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import type { TaskConfig } from 'agentool/task';
|
|
11
|
-
* const config: TaskConfig = { cwd: '/my/project' };
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
interface TaskConfig extends BaseToolConfig {
|
|
15
|
-
/** Path to the tasks JSON file. Defaults to `<cwd>/.agentool/tasks.json`. */
|
|
16
|
-
tasksFile?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a task tool that provides JSON file-based task tracking.
|
|
20
|
-
*
|
|
21
|
-
* Tasks are stored in a single JSON file with CRUD operations.
|
|
22
|
-
* Each task has an id, subject, description, status, and timestamps.
|
|
23
|
-
* Execute never throws; errors are returned as descriptive strings.
|
|
24
|
-
*
|
|
25
|
-
* @param config - Optional configuration for cwd and tasks file path.
|
|
26
|
-
* @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { createTask } from 'agentool/task';
|
|
31
|
-
*
|
|
32
|
-
* const taskTool = createTask({ cwd: '/my/project' });
|
|
33
|
-
* const result = await taskTool.execute(
|
|
34
|
-
* { action: 'create', subject: 'Fix bug', description: 'Fix the login bug' },
|
|
35
|
-
* { toolCallId: 'id', messages: [] },
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createTask(config?: TaskConfig): ai.Tool<{
|
|
40
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
41
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
id?: string | undefined;
|
|
44
|
-
subject?: string | undefined;
|
|
45
|
-
}, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Default task tool instance using `.agentool/tasks.json` under the current
|
|
48
|
-
* working directory.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { task } from 'agentool/task';
|
|
53
|
-
* const result = await task.execute(
|
|
54
|
-
* { action: 'list' },
|
|
55
|
-
* { toolCallId: 'id', messages: [] },
|
|
56
|
-
* );
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare const task: ai.Tool<{
|
|
60
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
61
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
id?: string | undefined;
|
|
64
|
-
subject?: string | undefined;
|
|
65
|
-
}, string>;
|
|
66
|
-
|
|
67
|
-
export { type TaskConfig, createTask, task };
|
package/dist/task/index.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import * as ai from 'ai';
|
|
2
|
-
import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Configuration for the task tool.
|
|
6
|
-
* Extends {@link BaseToolConfig} with an optional tasks file path.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* import type { TaskConfig } from 'agentool/task';
|
|
11
|
-
* const config: TaskConfig = { cwd: '/my/project' };
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
interface TaskConfig extends BaseToolConfig {
|
|
15
|
-
/** Path to the tasks JSON file. Defaults to `<cwd>/.agentool/tasks.json`. */
|
|
16
|
-
tasksFile?: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a task tool that provides JSON file-based task tracking.
|
|
20
|
-
*
|
|
21
|
-
* Tasks are stored in a single JSON file with CRUD operations.
|
|
22
|
-
* Each task has an id, subject, description, status, and timestamps.
|
|
23
|
-
* Execute never throws; errors are returned as descriptive strings.
|
|
24
|
-
*
|
|
25
|
-
* @param config - Optional configuration for cwd and tasks file path.
|
|
26
|
-
* @returns A Vercel AI SDK tool with `description`, `parameters`, and `execute`.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* import { createTask } from 'agentool/task';
|
|
31
|
-
*
|
|
32
|
-
* const taskTool = createTask({ cwd: '/my/project' });
|
|
33
|
-
* const result = await taskTool.execute(
|
|
34
|
-
* { action: 'create', subject: 'Fix bug', description: 'Fix the login bug' },
|
|
35
|
-
* { toolCallId: 'id', messages: [] },
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function createTask(config?: TaskConfig): ai.Tool<{
|
|
40
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
41
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
42
|
-
description?: string | undefined;
|
|
43
|
-
id?: string | undefined;
|
|
44
|
-
subject?: string | undefined;
|
|
45
|
-
}, string>;
|
|
46
|
-
/**
|
|
47
|
-
* Default task tool instance using `.agentool/tasks.json` under the current
|
|
48
|
-
* working directory.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* ```typescript
|
|
52
|
-
* import { task } from 'agentool/task';
|
|
53
|
-
* const result = await task.execute(
|
|
54
|
-
* { action: 'list' },
|
|
55
|
-
* { toolCallId: 'id', messages: [] },
|
|
56
|
-
* );
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare const task: ai.Tool<{
|
|
60
|
-
action: "list" | "delete" | "create" | "get" | "update";
|
|
61
|
-
status?: "pending" | "in_progress" | "completed" | undefined;
|
|
62
|
-
description?: string | undefined;
|
|
63
|
-
id?: string | undefined;
|
|
64
|
-
subject?: string | undefined;
|
|
65
|
-
}, string>;
|
|
66
|
-
|
|
67
|
-
export { type TaskConfig, createTask, task };
|