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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkVQSWMGG7cjs = require('./chunk-VQSWMGG7.cjs');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
10
|
+
|
|
11
|
+
// src/task-create/index.ts
|
|
12
|
+
var _ai = require('ai');
|
|
13
|
+
var _zod = require('zod');
|
|
14
|
+
var _path = require('path');
|
|
15
|
+
|
|
16
|
+
// src/task-create/prompt.ts
|
|
17
|
+
function getPrompt() {
|
|
18
|
+
return `Create a new task to track work. Tasks are stored as JSON and support status tracking, dependencies, and metadata.
|
|
19
|
+
|
|
20
|
+
## When to Use
|
|
21
|
+
- Complex multi-step tasks requiring 3 or more distinct steps
|
|
22
|
+
- Non-trivial work that benefits from progress tracking
|
|
23
|
+
- When the user provides a list of things to be done
|
|
24
|
+
- After receiving new instructions \u2014 capture requirements as tasks immediately
|
|
25
|
+
- When planning mode is active \u2014 create a task list to track the plan
|
|
26
|
+
|
|
27
|
+
## When NOT to Use
|
|
28
|
+
- Single, straightforward tasks that need no tracking
|
|
29
|
+
- Trivial work completable in fewer than 3 simple steps
|
|
30
|
+
- Purely conversational or informational requests
|
|
31
|
+
If there is only one simple task, just do it directly instead of creating a task for it.
|
|
32
|
+
|
|
33
|
+
## Task Fields
|
|
34
|
+
- **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
|
|
35
|
+
- **description**: Detailed explanation of what needs to be done
|
|
36
|
+
- **metadata** (optional): Arbitrary key-value pairs to attach to the task
|
|
37
|
+
|
|
38
|
+
All tasks are created with status \`pending\`, empty \`blocks\` and \`blockedBy\` arrays.
|
|
39
|
+
|
|
40
|
+
## Tips
|
|
41
|
+
- Create tasks with clear, specific subjects that describe the desired outcome
|
|
42
|
+
- After creating tasks, set up dependencies (blocks/blockedBy) if tasks must run in order
|
|
43
|
+
- Check the task list first to avoid creating duplicate tasks
|
|
44
|
+
- When starting work on a task, update its status to \`in_progress\` before beginning
|
|
45
|
+
- After completing a task, mark it \`completed\` and check for newly unblocked tasks`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/task-create/index.ts
|
|
49
|
+
function createTaskCreate(config = {}) {
|
|
50
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
51
|
+
const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
|
|
52
|
+
return _ai.tool.call(void 0, {
|
|
53
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
54
|
+
inputSchema: _zod.z.object({
|
|
55
|
+
subject: _zod.z.string().describe("A brief title for the task"),
|
|
56
|
+
description: _zod.z.string().describe("What needs to be done"),
|
|
57
|
+
metadata: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional().describe("Arbitrary metadata to attach to the task")
|
|
58
|
+
}),
|
|
59
|
+
execute: async ({ subject, description, metadata }) => {
|
|
60
|
+
try {
|
|
61
|
+
const tasks = await _chunkVQSWMGG7cjs.loadTasks.call(void 0, tasksFile);
|
|
62
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
63
|
+
const entry = {
|
|
64
|
+
id: _chunkVQSWMGG7cjs.generateId.call(void 0, ),
|
|
65
|
+
subject,
|
|
66
|
+
description,
|
|
67
|
+
status: "pending",
|
|
68
|
+
blocks: [],
|
|
69
|
+
blockedBy: [],
|
|
70
|
+
metadata,
|
|
71
|
+
createdAt: now,
|
|
72
|
+
updatedAt: now
|
|
73
|
+
};
|
|
74
|
+
tasks.push(entry);
|
|
75
|
+
await _chunkVQSWMGG7cjs.saveTasks.call(void 0, tasksFile, tasks);
|
|
76
|
+
return `Created task ${entry.id}.
|
|
77
|
+
${_chunkVQSWMGG7cjs.formatTask.call(void 0, entry)}`;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
80
|
+
return `Error [task-create]: ${msg}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
var taskCreate = createTaskCreate();
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
exports.getPrompt = getPrompt; exports.createTaskCreate = createTaskCreate; exports.taskCreate = taskCreate;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var _chunkVQSWMGG7cjs = require('./chunk-VQSWMGG7.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
9
|
+
|
|
10
|
+
// src/task-update/index.ts
|
|
11
|
+
var _ai = require('ai');
|
|
12
|
+
var _zod = require('zod');
|
|
13
|
+
var _path = require('path');
|
|
14
|
+
|
|
15
|
+
// src/task-update/prompt.ts
|
|
16
|
+
function getPrompt() {
|
|
17
|
+
return `Update a task by its ID. Can change status, subject, description, owner, metadata, and dependency relationships.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
**Marking tasks as completed:**
|
|
22
|
+
- When you have fully completed the work described in a task
|
|
23
|
+
- ONLY mark a task as completed when the work is truly done
|
|
24
|
+
- If you encounter errors or blockers, keep the task as \`in_progress\`
|
|
25
|
+
- Never mark a task as completed if:
|
|
26
|
+
- Tests are failing
|
|
27
|
+
- Implementation is partial
|
|
28
|
+
- You encountered unresolved errors
|
|
29
|
+
|
|
30
|
+
**Marking tasks as in progress:**
|
|
31
|
+
- When you begin working on a task, set it to \`in_progress\` immediately
|
|
32
|
+
|
|
33
|
+
**Deleting tasks:**
|
|
34
|
+
- When a task is no longer relevant or was created in error
|
|
35
|
+
- Setting status to \`deleted\` permanently removes the task from the list
|
|
36
|
+
|
|
37
|
+
**Updating details:**
|
|
38
|
+
- When requirements change or become clearer
|
|
39
|
+
- When establishing dependencies between tasks
|
|
40
|
+
|
|
41
|
+
## Status Workflow
|
|
42
|
+
Status progresses: \`pending\` \u2192 \`in_progress\` \u2192 \`completed\`
|
|
43
|
+
Use \`deleted\` to remove a task permanently.
|
|
44
|
+
|
|
45
|
+
## Fields You Can Update
|
|
46
|
+
- **status**: pending, in_progress, completed, or deleted
|
|
47
|
+
- **subject**: Change the task title
|
|
48
|
+
- **description**: Change the task description
|
|
49
|
+
- **owner**: Assign or reassign the task
|
|
50
|
+
- **activeForm**: Present continuous form shown when in_progress (e.g., "Running tests")
|
|
51
|
+
- **addBlocks**: Add task IDs that cannot start until this task completes
|
|
52
|
+
- **addBlockedBy**: Add task IDs that must complete before this task can start
|
|
53
|
+
- **metadata**: Merge key-value pairs into the task (set a key to null to delete it)
|
|
54
|
+
|
|
55
|
+
## Tips
|
|
56
|
+
- After completing a task, check the task list for newly unblocked work
|
|
57
|
+
- Use dependencies (blocks/blockedBy) to enforce execution order when tasks depend on each other`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/task-update/index.ts
|
|
61
|
+
function createTaskUpdate(config = {}) {
|
|
62
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
63
|
+
const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
|
|
64
|
+
return _ai.tool.call(void 0, {
|
|
65
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
66
|
+
inputSchema: _zod.z.object({
|
|
67
|
+
taskId: _zod.z.string().describe("The ID of the task to update"),
|
|
68
|
+
subject: _zod.z.string().optional().describe("New subject for the task"),
|
|
69
|
+
description: _zod.z.string().optional().describe("New description"),
|
|
70
|
+
status: _zod.z.enum(["pending", "in_progress", "completed", "deleted"]).optional().describe("New status for the task"),
|
|
71
|
+
owner: _zod.z.string().optional().describe("New owner for the task"),
|
|
72
|
+
activeForm: _zod.z.string().optional().describe("Present continuous form shown in spinner when in_progress"),
|
|
73
|
+
addBlocks: _zod.z.array(_zod.z.string()).optional().describe("Task IDs that this task blocks"),
|
|
74
|
+
addBlockedBy: _zod.z.array(_zod.z.string()).optional().describe("Task IDs that block this task"),
|
|
75
|
+
metadata: _zod.z.record(_zod.z.string(), _zod.z.unknown()).optional().describe("Metadata keys to merge. Set key to null to delete.")
|
|
76
|
+
}),
|
|
77
|
+
execute: async (input) => {
|
|
78
|
+
try {
|
|
79
|
+
const tasks = await _chunkVQSWMGG7cjs.loadTasks.call(void 0, tasksFile);
|
|
80
|
+
const idx = tasks.findIndex((t) => t.id === input.taskId);
|
|
81
|
+
if (idx === -1) return `Error [task-update]: Task "${input.taskId}" not found.`;
|
|
82
|
+
const entry = tasks[idx];
|
|
83
|
+
if (input.subject !== void 0) entry.subject = input.subject;
|
|
84
|
+
if (input.description !== void 0) entry.description = input.description;
|
|
85
|
+
if (input.status !== void 0) entry.status = input.status;
|
|
86
|
+
if (input.owner !== void 0) entry.owner = input.owner;
|
|
87
|
+
if (input.activeForm !== void 0) entry.activeForm = input.activeForm;
|
|
88
|
+
if (input.addBlocks) {
|
|
89
|
+
for (const id of input.addBlocks) {
|
|
90
|
+
if (!entry.blocks.includes(id)) entry.blocks.push(id);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (input.addBlockedBy) {
|
|
94
|
+
for (const id of input.addBlockedBy) {
|
|
95
|
+
if (!entry.blockedBy.includes(id)) entry.blockedBy.push(id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (input.metadata) {
|
|
99
|
+
if (!entry.metadata) entry.metadata = {};
|
|
100
|
+
for (const [key, value] of Object.entries(input.metadata)) {
|
|
101
|
+
if (value === null) {
|
|
102
|
+
delete entry.metadata[key];
|
|
103
|
+
} else {
|
|
104
|
+
entry.metadata[key] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
109
|
+
tasks[idx] = entry;
|
|
110
|
+
await _chunkVQSWMGG7cjs.saveTasks.call(void 0, tasksFile, tasks);
|
|
111
|
+
return `Updated task ${input.taskId}.
|
|
112
|
+
${_chunkVQSWMGG7cjs.formatTask.call(void 0, entry)}`;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
115
|
+
return `Error [task-update]: ${msg}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var taskUpdate = createTaskUpdate();
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
exports.getPrompt = getPrompt; exports.createTaskUpdate = createTaskUpdate; exports.taskUpdate = taskUpdate;
|
|
@@ -1,9 +1,38 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
1
5
|
// src/http-request/index.ts
|
|
2
6
|
import { tool } from "ai";
|
|
3
7
|
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/http-request/prompt.ts
|
|
10
|
+
function getPrompt(config = {}) {
|
|
11
|
+
const timeout = config.timeout ?? 3e4;
|
|
12
|
+
return `Make an HTTP request to a URL. Returns the raw response status, headers, and body as JSON.
|
|
13
|
+
|
|
14
|
+
Supports GET, POST, PUT, PATCH, DELETE, and HEAD methods.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
- For API interactions: REST calls, webhook triggers, service health checks
|
|
18
|
+
- When you need full control over HTTP method, headers, and request body
|
|
19
|
+
- When you need the raw response (status codes, headers) not just content
|
|
20
|
+
|
|
21
|
+
## When NOT to Use
|
|
22
|
+
- To read a web page for its content \u2014 use the web fetch tool instead (it converts HTML to markdown)
|
|
23
|
+
- To search the web \u2014 use the web search tool instead
|
|
24
|
+
|
|
25
|
+
## Usage Guidelines
|
|
26
|
+
- Default timeout: ${timeout}ms. Override with the timeout parameter.
|
|
27
|
+
- Request body is sent for POST, PUT, and PATCH methods
|
|
28
|
+
- Response is returned as JSON with status, statusText, headers, and body fields
|
|
29
|
+
- Default headers from config are merged with per-request headers (per-request takes precedence)`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/http-request/index.ts
|
|
4
33
|
function createHttpRequest(config = {}) {
|
|
5
34
|
return tool({
|
|
6
|
-
description:
|
|
35
|
+
description: config.description ?? getPrompt(config),
|
|
7
36
|
inputSchema: z.object({
|
|
8
37
|
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]).describe("HTTP method"),
|
|
9
38
|
url: z.string().describe("The URL to send the request to"),
|
|
@@ -44,7 +73,7 @@ function createHttpRequest(config = {}) {
|
|
|
44
73
|
if (error instanceof Error && error.name === "AbortError") {
|
|
45
74
|
return `Error [http-request]: Request timed out after ${effectiveTimeout}ms for ${method} ${url}. Try increasing the timeout or verify the server is responsive.`;
|
|
46
75
|
}
|
|
47
|
-
const msg =
|
|
76
|
+
const msg = extractErrorMessage(error);
|
|
48
77
|
return `Error [http-request]: ${method} ${url} failed: ${msg}. Verify the URL is correct and the server is reachable.`;
|
|
49
78
|
}
|
|
50
79
|
}
|
|
@@ -53,6 +82,7 @@ function createHttpRequest(config = {}) {
|
|
|
53
82
|
var httpRequest = createHttpRequest();
|
|
54
83
|
|
|
55
84
|
export {
|
|
85
|
+
getPrompt,
|
|
56
86
|
createHttpRequest,
|
|
57
87
|
httpRequest
|
|
58
88
|
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatTask,
|
|
3
|
+
loadTasks,
|
|
4
|
+
saveTasks
|
|
5
|
+
} from "./chunk-VHLY7LQE.js";
|
|
6
|
+
import {
|
|
7
|
+
extractErrorMessage
|
|
8
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
9
|
+
|
|
10
|
+
// src/task-update/index.ts
|
|
11
|
+
import { tool } from "ai";
|
|
12
|
+
import { z } from "zod";
|
|
13
|
+
import { join } from "path";
|
|
14
|
+
|
|
15
|
+
// src/task-update/prompt.ts
|
|
16
|
+
function getPrompt() {
|
|
17
|
+
return `Update a task by its ID. Can change status, subject, description, owner, metadata, and dependency relationships.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
**Marking tasks as completed:**
|
|
22
|
+
- When you have fully completed the work described in a task
|
|
23
|
+
- ONLY mark a task as completed when the work is truly done
|
|
24
|
+
- If you encounter errors or blockers, keep the task as \`in_progress\`
|
|
25
|
+
- Never mark a task as completed if:
|
|
26
|
+
- Tests are failing
|
|
27
|
+
- Implementation is partial
|
|
28
|
+
- You encountered unresolved errors
|
|
29
|
+
|
|
30
|
+
**Marking tasks as in progress:**
|
|
31
|
+
- When you begin working on a task, set it to \`in_progress\` immediately
|
|
32
|
+
|
|
33
|
+
**Deleting tasks:**
|
|
34
|
+
- When a task is no longer relevant or was created in error
|
|
35
|
+
- Setting status to \`deleted\` permanently removes the task from the list
|
|
36
|
+
|
|
37
|
+
**Updating details:**
|
|
38
|
+
- When requirements change or become clearer
|
|
39
|
+
- When establishing dependencies between tasks
|
|
40
|
+
|
|
41
|
+
## Status Workflow
|
|
42
|
+
Status progresses: \`pending\` \u2192 \`in_progress\` \u2192 \`completed\`
|
|
43
|
+
Use \`deleted\` to remove a task permanently.
|
|
44
|
+
|
|
45
|
+
## Fields You Can Update
|
|
46
|
+
- **status**: pending, in_progress, completed, or deleted
|
|
47
|
+
- **subject**: Change the task title
|
|
48
|
+
- **description**: Change the task description
|
|
49
|
+
- **owner**: Assign or reassign the task
|
|
50
|
+
- **activeForm**: Present continuous form shown when in_progress (e.g., "Running tests")
|
|
51
|
+
- **addBlocks**: Add task IDs that cannot start until this task completes
|
|
52
|
+
- **addBlockedBy**: Add task IDs that must complete before this task can start
|
|
53
|
+
- **metadata**: Merge key-value pairs into the task (set a key to null to delete it)
|
|
54
|
+
|
|
55
|
+
## Tips
|
|
56
|
+
- After completing a task, check the task list for newly unblocked work
|
|
57
|
+
- Use dependencies (blocks/blockedBy) to enforce execution order when tasks depend on each other`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/task-update/index.ts
|
|
61
|
+
function createTaskUpdate(config = {}) {
|
|
62
|
+
const cwd = config.cwd ?? process.cwd();
|
|
63
|
+
const tasksFile = config.tasksFile ?? join(cwd, ".agentool", "tasks.json");
|
|
64
|
+
return tool({
|
|
65
|
+
description: config.description ?? getPrompt(),
|
|
66
|
+
inputSchema: z.object({
|
|
67
|
+
taskId: z.string().describe("The ID of the task to update"),
|
|
68
|
+
subject: z.string().optional().describe("New subject for the task"),
|
|
69
|
+
description: z.string().optional().describe("New description"),
|
|
70
|
+
status: z.enum(["pending", "in_progress", "completed", "deleted"]).optional().describe("New status for the task"),
|
|
71
|
+
owner: z.string().optional().describe("New owner for the task"),
|
|
72
|
+
activeForm: z.string().optional().describe("Present continuous form shown in spinner when in_progress"),
|
|
73
|
+
addBlocks: z.array(z.string()).optional().describe("Task IDs that this task blocks"),
|
|
74
|
+
addBlockedBy: z.array(z.string()).optional().describe("Task IDs that block this task"),
|
|
75
|
+
metadata: z.record(z.string(), z.unknown()).optional().describe("Metadata keys to merge. Set key to null to delete.")
|
|
76
|
+
}),
|
|
77
|
+
execute: async (input) => {
|
|
78
|
+
try {
|
|
79
|
+
const tasks = await loadTasks(tasksFile);
|
|
80
|
+
const idx = tasks.findIndex((t) => t.id === input.taskId);
|
|
81
|
+
if (idx === -1) return `Error [task-update]: Task "${input.taskId}" not found.`;
|
|
82
|
+
const entry = tasks[idx];
|
|
83
|
+
if (input.subject !== void 0) entry.subject = input.subject;
|
|
84
|
+
if (input.description !== void 0) entry.description = input.description;
|
|
85
|
+
if (input.status !== void 0) entry.status = input.status;
|
|
86
|
+
if (input.owner !== void 0) entry.owner = input.owner;
|
|
87
|
+
if (input.activeForm !== void 0) entry.activeForm = input.activeForm;
|
|
88
|
+
if (input.addBlocks) {
|
|
89
|
+
for (const id of input.addBlocks) {
|
|
90
|
+
if (!entry.blocks.includes(id)) entry.blocks.push(id);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (input.addBlockedBy) {
|
|
94
|
+
for (const id of input.addBlockedBy) {
|
|
95
|
+
if (!entry.blockedBy.includes(id)) entry.blockedBy.push(id);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (input.metadata) {
|
|
99
|
+
if (!entry.metadata) entry.metadata = {};
|
|
100
|
+
for (const [key, value] of Object.entries(input.metadata)) {
|
|
101
|
+
if (value === null) {
|
|
102
|
+
delete entry.metadata[key];
|
|
103
|
+
} else {
|
|
104
|
+
entry.metadata[key] = value;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
entry.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
109
|
+
tasks[idx] = entry;
|
|
110
|
+
await saveTasks(tasksFile, tasks);
|
|
111
|
+
return `Updated task ${input.taskId}.
|
|
112
|
+
${formatTask(entry)}`;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
const msg = extractErrorMessage(error);
|
|
115
|
+
return `Error [task-update]: ${msg}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
var taskUpdate = createTaskUpdate();
|
|
121
|
+
|
|
122
|
+
export {
|
|
123
|
+
getPrompt,
|
|
124
|
+
createTaskUpdate,
|
|
125
|
+
taskUpdate
|
|
126
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
1
5
|
// src/bash/index.ts
|
|
2
6
|
import { tool } from "ai";
|
|
3
7
|
import { z } from "zod";
|
|
@@ -103,12 +107,54 @@ async function executeShell(command, options) {
|
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
|
|
110
|
+
// src/bash/prompt.ts
|
|
111
|
+
function getPrompt(config = {}) {
|
|
112
|
+
const timeout = config.timeout ?? 12e4;
|
|
113
|
+
const timeoutMin = timeout / 6e4;
|
|
114
|
+
const shell = config.shell ?? "$SHELL or /bin/bash";
|
|
115
|
+
return `Execute a shell command and return its output (stdout, stderr, exit code).
|
|
116
|
+
|
|
117
|
+
Runs the command in ${shell} with \`-c\`. The working directory persists between calls.
|
|
118
|
+
|
|
119
|
+
## When to Use
|
|
120
|
+
- Build commands, git operations, system administration, installing packages
|
|
121
|
+
- Running scripts, compiling code, process management
|
|
122
|
+
- Any shell task that doesn't have a dedicated tool available
|
|
123
|
+
|
|
124
|
+
## When NOT to Use
|
|
125
|
+
- Reading file contents \u2014 use the dedicated file reading tool instead
|
|
126
|
+
- Searching file contents \u2014 use the dedicated content search tool instead
|
|
127
|
+
- Finding files by name/pattern \u2014 use the dedicated file search tool instead
|
|
128
|
+
- Editing files \u2014 use the dedicated file editing tool instead
|
|
129
|
+
- Writing new files \u2014 use the dedicated file writing tool instead
|
|
130
|
+
Prefer dedicated tools over shell equivalents (e.g., don't use cat, head, tail, sed, awk, grep, find, or echo when a dedicated tool exists). Dedicated tools provide better output formatting and permission handling.
|
|
131
|
+
|
|
132
|
+
## Usage Guidelines
|
|
133
|
+
- Default timeout: ${timeout}ms (${timeoutMin} minutes). Override with the timeout parameter.
|
|
134
|
+
- Timeout escalation: SIGTERM first, then SIGKILL after 5-second grace period.
|
|
135
|
+
- Output is capped at 10 MB per stream (stdout/stderr).
|
|
136
|
+
- Always quote file paths containing spaces with double quotes.
|
|
137
|
+
- When issuing multiple commands:
|
|
138
|
+
- Independent commands: make separate tool calls in parallel.
|
|
139
|
+
- Sequential with dependency: chain with \`&&\`.
|
|
140
|
+
- Sequential ignoring failures: chain with \`;\`.
|
|
141
|
+
- Do NOT use newlines to separate commands.
|
|
142
|
+
- Avoid unnecessary \`sleep\` commands:
|
|
143
|
+
- Don't sleep between commands that can run immediately.
|
|
144
|
+
- Don't retry failing commands in a sleep loop \u2014 diagnose the root cause.
|
|
145
|
+
- If you must sleep, keep it short (1-5 seconds).
|
|
146
|
+
- For git commands:
|
|
147
|
+
- Prefer creating new commits rather than amending existing ones.
|
|
148
|
+
- Never skip hooks (--no-verify) unless the user explicitly requests it.
|
|
149
|
+
- Before destructive operations (reset --hard, push --force), consider safer alternatives.`;
|
|
150
|
+
}
|
|
151
|
+
|
|
106
152
|
// src/bash/index.ts
|
|
107
153
|
function createBash(config = {}) {
|
|
108
154
|
const cwd = config.cwd ?? process.cwd();
|
|
109
155
|
const timeout = config.timeout ?? 12e4;
|
|
110
156
|
return tool({
|
|
111
|
-
description:
|
|
157
|
+
description: config.description ?? getPrompt(config),
|
|
112
158
|
inputSchema: z.object({
|
|
113
159
|
command: z.string().describe("The shell command to execute"),
|
|
114
160
|
timeout: z.number().optional().describe("Timeout in milliseconds (default: 120000)"),
|
|
@@ -128,7 +174,7 @@ ${result.stderr}`);
|
|
|
128
174
|
if (result.exitCode !== 0) parts.push(`Exit code: ${result.exitCode}`);
|
|
129
175
|
return parts.length > 0 ? parts.join("\n") : `Command completed with exit code ${result.exitCode}`;
|
|
130
176
|
} catch (error) {
|
|
131
|
-
const msg =
|
|
177
|
+
const msg = extractErrorMessage(error);
|
|
132
178
|
return `Error [bash]: Failed to execute command: ${msg}`;
|
|
133
179
|
}
|
|
134
180
|
}
|
|
@@ -137,6 +183,7 @@ ${result.stderr}`);
|
|
|
137
183
|
var bash = createBash();
|
|
138
184
|
|
|
139
185
|
export {
|
|
186
|
+
getPrompt,
|
|
140
187
|
createBash,
|
|
141
188
|
bash
|
|
142
189
|
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
5
|
+
// src/tool-search/index.ts
|
|
6
|
+
import { tool } from "ai";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/tool-search/prompt.ts
|
|
10
|
+
function getPrompt() {
|
|
11
|
+
return `Search for available tools by name or keyword. Returns matching tool names and their descriptions.
|
|
12
|
+
|
|
13
|
+
Uses fuzzy matching \u2014 scores results by name and description relevance.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
- To discover what tools are available when you're unsure which tool to use
|
|
17
|
+
- To find the right tool for a specific task by searching with keywords
|
|
18
|
+
|
|
19
|
+
## When NOT to Use
|
|
20
|
+
- When you already know the tool name \u2014 just use it directly
|
|
21
|
+
|
|
22
|
+
## Usage Guidelines
|
|
23
|
+
- Requires a tools registry to be configured via createToolSearch({ tools: { ... } })
|
|
24
|
+
- Returns up to \`max_results\` matches (default: 5), sorted by relevance
|
|
25
|
+
- Matches against both tool names and descriptions`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/tool-search/index.ts
|
|
29
|
+
function createToolSearch(config = {}) {
|
|
30
|
+
return tool({
|
|
31
|
+
description: config.description ?? getPrompt(),
|
|
32
|
+
inputSchema: z.object({
|
|
33
|
+
query: z.string().describe("Query to find tools by name or keyword"),
|
|
34
|
+
max_results: z.number().optional().default(5).describe("Max results to return")
|
|
35
|
+
}),
|
|
36
|
+
execute: async ({ query, max_results }) => {
|
|
37
|
+
try {
|
|
38
|
+
const registry = config.tools ?? {};
|
|
39
|
+
const entries = Object.entries(registry);
|
|
40
|
+
if (entries.length === 0) {
|
|
41
|
+
return "No tools registered. Provide a tools registry via createToolSearch({ tools: { ... } })";
|
|
42
|
+
}
|
|
43
|
+
const lower = query.toLowerCase();
|
|
44
|
+
const scored = entries.map(([name, { description }]) => {
|
|
45
|
+
let score = 0;
|
|
46
|
+
const nameLower = name.toLowerCase();
|
|
47
|
+
const descLower = description.toLowerCase();
|
|
48
|
+
if (nameLower === lower) score += 10;
|
|
49
|
+
else if (nameLower.includes(lower)) score += 5;
|
|
50
|
+
if (descLower.includes(lower)) score += 3;
|
|
51
|
+
for (const word of lower.split(/\s+/)) {
|
|
52
|
+
if (nameLower.includes(word)) score += 2;
|
|
53
|
+
if (descLower.includes(word)) score += 1;
|
|
54
|
+
}
|
|
55
|
+
return { name, description, score };
|
|
56
|
+
}).filter((e) => e.score > 0).sort((a, b) => b.score - a.score).slice(0, max_results);
|
|
57
|
+
if (scored.length === 0) {
|
|
58
|
+
return `No tools matched query "${query}".`;
|
|
59
|
+
}
|
|
60
|
+
return scored.map((e) => `${e.name}: ${e.description}`).join("\n");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const msg = extractErrorMessage(error);
|
|
63
|
+
return `Error [tool-search]: ${msg}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var toolSearch = createToolSearch();
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
getPrompt,
|
|
72
|
+
createToolSearch,
|
|
73
|
+
toolSearch
|
|
74
|
+
};
|
|
@@ -1,33 +1,52 @@
|
|
|
1
1
|
import {
|
|
2
2
|
applyEditToFile,
|
|
3
|
+
countOccurrences,
|
|
3
4
|
findActualString,
|
|
4
5
|
preserveQuoteStyle
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4MXDQEPA.js";
|
|
6
7
|
import {
|
|
8
|
+
readTextContent,
|
|
7
9
|
writeTextContent
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-PWBVB6MN.js";
|
|
9
11
|
import {
|
|
10
12
|
expandPath
|
|
11
13
|
} from "./chunk-I3ONDY7P.js";
|
|
14
|
+
import {
|
|
15
|
+
extractErrorMessage
|
|
16
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
12
17
|
|
|
13
18
|
// src/multi-edit/index.ts
|
|
14
|
-
import { readFile } from "fs/promises";
|
|
15
19
|
import { tool } from "ai";
|
|
16
20
|
import { z } from "zod";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
|
|
22
|
+
// src/multi-edit/prompt.ts
|
|
23
|
+
function getPrompt() {
|
|
24
|
+
return `Atomically apply multiple text edits to a single file. All edits succeed together or none are applied.
|
|
25
|
+
|
|
26
|
+
Each edit replaces one occurrence of old_string with new_string. Edits are applied sequentially in the order provided.
|
|
27
|
+
|
|
28
|
+
## When to Use
|
|
29
|
+
- When you need to make several related changes to the same file in one operation
|
|
30
|
+
- When changes depend on each other and partial application would leave the file in a broken state
|
|
31
|
+
- To rename a variable in multiple locations within the same file
|
|
32
|
+
|
|
33
|
+
## When NOT to Use
|
|
34
|
+
- For a single edit \u2014 use the regular file editing tool instead (simpler)
|
|
35
|
+
- For changes across multiple files \u2014 make separate edit calls per file
|
|
36
|
+
- For creating new files \u2014 use the file writing tool instead
|
|
37
|
+
|
|
38
|
+
## Usage Guidelines
|
|
39
|
+
- If any edit fails (old_string not found or not unique), the entire batch is rolled back \u2014 the file stays unchanged
|
|
40
|
+
- Each old_string must appear exactly once in the file at the time that edit is applied
|
|
41
|
+
- Edits are applied in order, so later edits see the result of earlier ones
|
|
42
|
+
- Supports curly-quote fallback matching and quote-style preservation`;
|
|
26
43
|
}
|
|
44
|
+
|
|
45
|
+
// src/multi-edit/index.ts
|
|
27
46
|
function createMultiEdit(config = {}) {
|
|
28
47
|
const cwd = config.cwd ?? process.cwd();
|
|
29
48
|
return tool({
|
|
30
|
-
description:
|
|
49
|
+
description: config.description ?? getPrompt(),
|
|
31
50
|
inputSchema: z.object({
|
|
32
51
|
file_path: z.string().describe("Path to the file to edit (absolute or relative to cwd)"),
|
|
33
52
|
edits: z.array(
|
|
@@ -43,7 +62,7 @@ function createMultiEdit(config = {}) {
|
|
|
43
62
|
return "No edits provided. File unchanged.";
|
|
44
63
|
}
|
|
45
64
|
const resolvedPath = expandPath(file_path, cwd);
|
|
46
|
-
const originalContent = await
|
|
65
|
+
const originalContent = await readTextContent(resolvedPath);
|
|
47
66
|
let content = originalContent;
|
|
48
67
|
for (let i = 0; i < edits.length; i++) {
|
|
49
68
|
const edit = edits[i];
|
|
@@ -65,7 +84,7 @@ function createMultiEdit(config = {}) {
|
|
|
65
84
|
await writeTextContent(resolvedPath, content);
|
|
66
85
|
return `Successfully applied ${edits.length} edit${edits.length === 1 ? "" : "s"} to ${resolvedPath}`;
|
|
67
86
|
} catch (error) {
|
|
68
|
-
const msg =
|
|
87
|
+
const msg = extractErrorMessage(error);
|
|
69
88
|
return `Error [multi-edit]: ${msg}`;
|
|
70
89
|
}
|
|
71
90
|
}
|
|
@@ -74,6 +93,7 @@ function createMultiEdit(config = {}) {
|
|
|
74
93
|
var multiEdit = createMultiEdit();
|
|
75
94
|
|
|
76
95
|
export {
|
|
96
|
+
getPrompt,
|
|
77
97
|
createMultiEdit,
|
|
78
98
|
multiEdit
|
|
79
99
|
};
|