agentool 1.1.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/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-IEX4NOVN.cjs → chunk-2JBLVFB7.cjs} +30 -4
- package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
- package/dist/{chunk-UDIG7332.js → chunk-2WSZCOJP.js} +40 -4
- 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-5O55DKOB.cjs → chunk-G6ZVJA4V.cjs} +30 -4
- package/dist/{chunk-P6Z5XFDS.js → chunk-GPHCXS2S.js} +41 -15
- 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-5TDZF4IM.cjs → chunk-NQIV6LBH.cjs} +42 -6
- 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-HNP7JDQC.cjs → chunk-RIGL3JTS.cjs} +41 -5
- package/dist/chunk-SFDZRLSX.cjs +91 -0
- package/dist/{chunk-ZFQZWXOI.cjs → chunk-T6STO7PS.cjs} +58 -7
- package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
- package/dist/{chunk-S7IVHOA6.js → chunk-TM5L4HA5.js} +54 -3
- package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
- package/dist/{chunk-IRRNYFI5.js → chunk-UCA6LURO.js} +28 -2
- package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
- package/dist/{chunk-E6NBEYZD.js → chunk-VHLY7LQE.js} +7 -5
- package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
- package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
- package/dist/{chunk-L5JH4I77.cjs → chunk-VQSWMGG7.cjs} +8 -6
- package/dist/{chunk-4HIATLKI.js → chunk-VZRXTFS4.js} +28 -2
- 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-XAQGZ374.js → chunk-ZHVRP3EH.js} +40 -4
- 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 +13 -3
- package/dist/edit/index.d.ts +13 -3
- 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 +68 -25
- package/dist/index.d.cts +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +73 -30
- package/dist/lsp/index.cjs +6 -2
- package/dist/lsp/index.d.cts +10 -1
- package/dist/lsp/index.d.ts +10 -1
- 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 +7 -3
- package/dist/task-create/index.d.cts +10 -1
- package/dist/task-create/index.d.ts +10 -1
- package/dist/task-create/index.js +7 -3
- package/dist/task-get/index.cjs +7 -3
- package/dist/task-get/index.d.cts +10 -1
- package/dist/task-get/index.d.ts +10 -1
- package/dist/task-get/index.js +7 -3
- package/dist/task-list/index.cjs +7 -3
- package/dist/task-list/index.d.cts +10 -1
- package/dist/task-list/index.d.ts +10 -1
- package/dist/task-list/index.js +7 -3
- package/dist/task-update/index.cjs +7 -3
- package/dist/task-update/index.d.cts +12 -3
- package/dist/task-update/index.d.ts +12 -3
- package/dist/task-update/index.js +7 -3
- package/dist/tool-search/index.cjs +5 -2
- package/dist/tool-search/index.d.cts +10 -1
- package/dist/tool-search/index.d.ts +10 -1
- package/dist/tool-search/index.js +5 -2
- package/dist/web-fetch/index.cjs +5 -2
- package/dist/web-fetch/index.d.cts +11 -1
- package/dist/web-fetch/index.d.ts +11 -1
- package/dist/web-fetch/index.js +5 -2
- package/dist/web-search/index.cjs +5 -2
- package/dist/web-search/index.d.cts +10 -1
- package/dist/web-search/index.d.ts +10 -1
- package/dist/web-search/index.js +5 -2
- 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 +1 -1
- package/dist/chunk-3EPGFWZV.cjs +0 -30
- package/dist/chunk-44AFQ2B7.js +0 -30
- package/dist/chunk-4HXAKPQH.cjs +0 -36
- package/dist/chunk-56CL4JCW.cjs +0 -53
- package/dist/chunk-6DJSWTWQ.cjs +0 -40
- package/dist/chunk-ACGW44YT.js +0 -47
- package/dist/chunk-ECYT46FP.js +0 -40
- package/dist/chunk-HDKXSKMO.js +0 -30
- package/dist/chunk-HNUL2CID.cjs +0 -34
- package/dist/chunk-LK6SQH2G.cjs +0 -30
- package/dist/chunk-LTE5NG4D.js +0 -53
- package/dist/chunk-MF7CJVIZ.js +0 -40
- package/dist/chunk-OM2UFTGS.cjs +0 -47
- package/dist/chunk-OXLQ7QVL.cjs +0 -40
- package/dist/chunk-TMW3XKKJ.js +0 -34
- package/dist/chunk-VXZ4RKJI.js +0 -36
- package/dist/chunk-ZBLQV6UO.cjs +0 -73
package/dist/ask-user/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunk3EPGFWZVcjs = require('../chunk-3EPGFWZV.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkKUFZFNPTcjs = require('../chunk-KUFZFNPT.cjs');
|
|
6
|
+
require('../chunk-KONXT2SF.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.askUser = _chunkKUFZFNPTcjs.askUser; exports.askUserPrompt = _chunkKUFZFNPTcjs.getPrompt; exports.createAskUser = _chunkKUFZFNPTcjs.createAskUser;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the ask-user tool.
|
|
6
|
+
*
|
|
7
|
+
* @returns The full description string for the ask-user tool.
|
|
8
|
+
*/
|
|
9
|
+
declare function getPrompt(): string;
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Configuration for the ask-user tool.
|
|
6
13
|
* Extends {@link BaseToolConfig} with an optional callback for receiving user input.
|
|
@@ -23,6 +30,8 @@ interface AskUserConfig extends BaseToolConfig {
|
|
|
23
30
|
* @returns The user's response string
|
|
24
31
|
*/
|
|
25
32
|
onQuestion?: (question: string, options?: string[]) => Promise<string>;
|
|
33
|
+
/** Override the default tool description. */
|
|
34
|
+
description?: string;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Creates an ask-user tool instance with the given configuration.
|
|
@@ -65,4 +74,4 @@ declare const askUser: ai.Tool<{
|
|
|
65
74
|
options?: string[] | undefined;
|
|
66
75
|
}, string>;
|
|
67
76
|
|
|
68
|
-
export { type AskUserConfig, askUser, createAskUser };
|
|
77
|
+
export { type AskUserConfig, askUser, getPrompt as askUserPrompt, createAskUser };
|
package/dist/ask-user/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the ask-user tool.
|
|
6
|
+
*
|
|
7
|
+
* @returns The full description string for the ask-user tool.
|
|
8
|
+
*/
|
|
9
|
+
declare function getPrompt(): string;
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Configuration for the ask-user tool.
|
|
6
13
|
* Extends {@link BaseToolConfig} with an optional callback for receiving user input.
|
|
@@ -23,6 +30,8 @@ interface AskUserConfig extends BaseToolConfig {
|
|
|
23
30
|
* @returns The user's response string
|
|
24
31
|
*/
|
|
25
32
|
onQuestion?: (question: string, options?: string[]) => Promise<string>;
|
|
33
|
+
/** Override the default tool description. */
|
|
34
|
+
description?: string;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Creates an ask-user tool instance with the given configuration.
|
|
@@ -65,4 +74,4 @@ declare const askUser: ai.Tool<{
|
|
|
65
74
|
options?: string[] | undefined;
|
|
66
75
|
}, string>;
|
|
67
76
|
|
|
68
|
-
export { type AskUserConfig, askUser, createAskUser };
|
|
77
|
+
export { type AskUserConfig, askUser, getPrompt as askUserPrompt, createAskUser };
|
package/dist/ask-user/index.js
CHANGED
package/dist/bash/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkSUSAPI5Wcjs = require('../chunk-SUSAPI5W.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkCXBWF5ONcjs = require('../chunk-CXBWF5ON.cjs');
|
|
6
|
+
require('../chunk-KONXT2SF.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.bash = _chunkCXBWF5ONcjs.bash; exports.bashPrompt = _chunkCXBWF5ONcjs.getPrompt; exports.createBash = _chunkCXBWF5ONcjs.createBash;
|
package/dist/bash/index.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { T as TimeoutConfig } from '../types-3QPDuCXN.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the bash tool based on its configuration.
|
|
6
|
+
*
|
|
7
|
+
* The returned string is used as the tool's `description` field in the
|
|
8
|
+
* Vercel AI SDK tool definition, providing the model with behavioral guidance.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The same config passed to {@link createBash}.
|
|
11
|
+
* @returns The full description string for the bash tool.
|
|
12
|
+
*/
|
|
13
|
+
declare function getPrompt(config?: Pick<BashConfig, 'timeout' | 'shell'>): string;
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Configuration for the bash tool.
|
|
6
17
|
* Extends {@link TimeoutConfig} with an optional shell binary path.
|
|
@@ -14,6 +25,8 @@ import { T as TimeoutConfig } from '../types-3QPDuCXN.cjs';
|
|
|
14
25
|
interface BashConfig extends TimeoutConfig {
|
|
15
26
|
/** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
|
|
16
27
|
shell?: string;
|
|
28
|
+
/** Override the default tool description. */
|
|
29
|
+
description?: string;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Creates a bash tool that executes shell commands via {@link executeShell}.
|
|
@@ -60,4 +73,4 @@ declare const bash: ai.Tool<{
|
|
|
60
73
|
description?: string | undefined;
|
|
61
74
|
}, string>;
|
|
62
75
|
|
|
63
|
-
export { type BashConfig, bash, createBash };
|
|
76
|
+
export { type BashConfig, bash, getPrompt as bashPrompt, createBash };
|
package/dist/bash/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { T as TimeoutConfig } from '../types-3QPDuCXN.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the bash tool based on its configuration.
|
|
6
|
+
*
|
|
7
|
+
* The returned string is used as the tool's `description` field in the
|
|
8
|
+
* Vercel AI SDK tool definition, providing the model with behavioral guidance.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The same config passed to {@link createBash}.
|
|
11
|
+
* @returns The full description string for the bash tool.
|
|
12
|
+
*/
|
|
13
|
+
declare function getPrompt(config?: Pick<BashConfig, 'timeout' | 'shell'>): string;
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Configuration for the bash tool.
|
|
6
17
|
* Extends {@link TimeoutConfig} with an optional shell binary path.
|
|
@@ -14,6 +25,8 @@ import { T as TimeoutConfig } from '../types-3QPDuCXN.js';
|
|
|
14
25
|
interface BashConfig extends TimeoutConfig {
|
|
15
26
|
/** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
|
|
16
27
|
shell?: string;
|
|
28
|
+
/** Override the default tool description. */
|
|
29
|
+
description?: string;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Creates a bash tool that executes shell commands via {@link executeShell}.
|
|
@@ -60,4 +73,4 @@ declare const bash: ai.Tool<{
|
|
|
60
73
|
description?: string | undefined;
|
|
61
74
|
}, string>;
|
|
62
75
|
|
|
63
|
-
export { type BashConfig, bash, createBash };
|
|
76
|
+
export { type BashConfig, bash, getPrompt as bashPrompt, createBash };
|
package/dist/bash/index.js
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
4
|
+
|
|
5
|
+
// src/tool-search/index.ts
|
|
2
6
|
var _ai = require('ai');
|
|
3
7
|
var _zod = require('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
|
|
4
29
|
function createToolSearch(config = {}) {
|
|
5
30
|
return _ai.tool.call(void 0, {
|
|
6
|
-
description:
|
|
31
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
7
32
|
inputSchema: _zod.z.object({
|
|
8
33
|
query: _zod.z.string().describe("Query to find tools by name or keyword"),
|
|
9
34
|
max_results: _zod.z.number().optional().default(5).describe("Max results to return")
|
|
@@ -34,7 +59,7 @@ function createToolSearch(config = {}) {
|
|
|
34
59
|
}
|
|
35
60
|
return scored.map((e) => `${e.name}: ${e.description}`).join("\n");
|
|
36
61
|
} catch (error) {
|
|
37
|
-
const msg =
|
|
62
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
38
63
|
return `Error [tool-search]: ${msg}`;
|
|
39
64
|
}
|
|
40
65
|
}
|
|
@@ -45,4 +70,5 @@ var toolSearch = createToolSearch();
|
|
|
45
70
|
|
|
46
71
|
|
|
47
72
|
|
|
48
|
-
|
|
73
|
+
|
|
74
|
+
exports.getPrompt = getPrompt; exports.createToolSearch = createToolSearch; exports.toolSearch = toolSearch;
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
1
5
|
// src/context-compaction/index.ts
|
|
2
6
|
import { tool, zodSchema } from "ai";
|
|
3
7
|
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/context-compaction/prompt.ts
|
|
10
|
+
function getPrompt(config = {}) {
|
|
11
|
+
const maxTokens = config.maxTokens ?? 4096;
|
|
12
|
+
return `Compact conversation history by summarizing older messages to reduce context size. Target budget: ${maxTokens} tokens.
|
|
13
|
+
|
|
14
|
+
Requires a summarize callback to be configured \u2014 the application provides the summarization implementation.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
- When the conversation is getting long and approaching context limits
|
|
18
|
+
- When earlier messages contain details no longer relevant to the current task
|
|
19
|
+
- To free up context space for new work without losing important context
|
|
20
|
+
|
|
21
|
+
## When NOT to Use
|
|
22
|
+
- When the conversation is still within budget \u2014 the tool returns early if already compact
|
|
23
|
+
- When every message contains critical details that shouldn't be summarized
|
|
24
|
+
- For persisting information long-term \u2014 use the memory tool instead
|
|
25
|
+
|
|
26
|
+
## Usage Guidelines
|
|
27
|
+
- Messages already within the token budget (${maxTokens} tokens, ~${maxTokens * 4} characters) are returned unchanged
|
|
28
|
+
- The summarize callback receives all messages and should return a condensed summary
|
|
29
|
+
- The result replaces the original messages with a single system message containing the summary`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/context-compaction/index.ts
|
|
4
33
|
var parametersSchema = z.object({
|
|
5
34
|
messages: z.array(
|
|
6
35
|
z.object({
|
|
@@ -14,7 +43,7 @@ var parametersSchema = z.object({
|
|
|
14
43
|
});
|
|
15
44
|
function createContextCompaction(config = {}) {
|
|
16
45
|
return tool({
|
|
17
|
-
description:
|
|
46
|
+
description: config.description ?? getPrompt(config),
|
|
18
47
|
inputSchema: zodSchema(parametersSchema),
|
|
19
48
|
execute: async ({
|
|
20
49
|
messages,
|
|
@@ -45,7 +74,7 @@ function createContextCompaction(config = {}) {
|
|
|
45
74
|
originalCount: messages.length
|
|
46
75
|
});
|
|
47
76
|
} catch (error) {
|
|
48
|
-
const msg =
|
|
77
|
+
const msg = extractErrorMessage(error);
|
|
49
78
|
return `Error [context-compaction]: Summarization failed: ${msg}`;
|
|
50
79
|
}
|
|
51
80
|
}
|
|
@@ -54,6 +83,7 @@ function createContextCompaction(config = {}) {
|
|
|
54
83
|
var contextCompaction = createContextCompaction();
|
|
55
84
|
|
|
56
85
|
export {
|
|
86
|
+
getPrompt,
|
|
57
87
|
createContextCompaction,
|
|
58
88
|
contextCompaction
|
|
59
89
|
};
|
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeRipgrep
|
|
3
3
|
} from "./chunk-MJCAXASI.js";
|
|
4
|
+
import {
|
|
5
|
+
getFileStats
|
|
6
|
+
} from "./chunk-PWBVB6MN.js";
|
|
4
7
|
import {
|
|
5
8
|
expandPath,
|
|
6
9
|
toRelativePath
|
|
7
10
|
} from "./chunk-I3ONDY7P.js";
|
|
11
|
+
import {
|
|
12
|
+
extractErrorMessage
|
|
13
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
8
14
|
|
|
9
15
|
// src/grep/index.ts
|
|
10
|
-
import { stat } from "fs/promises";
|
|
11
16
|
import { tool } from "ai";
|
|
12
17
|
import { z } from "zod";
|
|
18
|
+
|
|
19
|
+
// src/grep/prompt.ts
|
|
20
|
+
function getPrompt() {
|
|
21
|
+
return `Search file contents using ripgrep. Supports regex patterns, context lines, and multiple output modes.
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
- To find where a function, variable, string, or pattern is used across files
|
|
25
|
+
- To search for specific code patterns, error messages, or configuration values
|
|
26
|
+
- To count occurrences of a pattern across a codebase
|
|
27
|
+
|
|
28
|
+
## When NOT to Use
|
|
29
|
+
- To find files by name/extension \u2014 use the dedicated file search tool instead
|
|
30
|
+
- To read a specific file \u2014 use the file reading tool instead
|
|
31
|
+
- Don't use shell commands (grep, rg) for content search when this tool is available
|
|
32
|
+
|
|
33
|
+
## Output Modes
|
|
34
|
+
- \`files_with_matches\` (default): Returns file paths containing matches, sorted by modification time. Best for discovering which files contain a pattern.
|
|
35
|
+
- \`content\`: Returns matching lines with optional context. Supports \`-A\` (after), \`-B\` (before), \`-C\` (context) for surrounding lines and \`-n\` for line numbers (default: true).
|
|
36
|
+
- \`count\`: Returns match counts per file with totals.
|
|
37
|
+
|
|
38
|
+
## Usage Guidelines
|
|
39
|
+
- Uses ripgrep regex syntax (not grep). Literal braces need escaping: use \`interface\\{\\}\` to find \`interface{}\`
|
|
40
|
+
- Filter files with the \`glob\` parameter (e.g., "*.js", "*.{ts,tsx}") or \`type\` parameter (e.g., "js", "py")
|
|
41
|
+
- Default head_limit is 250 entries. Pass \`head_limit: 0\` for unlimited (use sparingly \u2014 large results waste context)
|
|
42
|
+
- Use \`offset\` to paginate through large result sets
|
|
43
|
+
- Enable \`multiline: true\` for patterns that span lines (e.g., \`struct \\{[\\s\\S]*?field\`)
|
|
44
|
+
- Use \`-i: true\` for case-insensitive search`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/grep/index.ts
|
|
13
48
|
var VCS_DIRS = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
14
49
|
var DEFAULT_HEAD_LIMIT = 250;
|
|
15
50
|
function applyHeadLimit(items, limit, offset = 0) {
|
|
@@ -48,7 +83,7 @@ function parseGlobPatterns(globFilter) {
|
|
|
48
83
|
function createGrep(config = {}) {
|
|
49
84
|
const cwd = config.cwd ?? process.cwd();
|
|
50
85
|
return tool({
|
|
51
|
-
description:
|
|
86
|
+
description: config.description ?? getPrompt(),
|
|
52
87
|
inputSchema: z.object({
|
|
53
88
|
pattern: z.string().describe("The regular expression pattern to search for in file contents"),
|
|
54
89
|
path: z.string().optional().describe("File or directory to search in (rg PATH). Defaults to current working directory."),
|
|
@@ -132,7 +167,7 @@ function createGrep(config = {}) {
|
|
|
132
167
|
|
|
133
168
|
Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(appliedLimit2, offset);
|
|
134
169
|
}
|
|
135
|
-
const stats = await Promise.allSettled(results.map((f) =>
|
|
170
|
+
const stats = await Promise.allSettled(results.map((f) => getFileStats(f)));
|
|
136
171
|
const sorted = results.map((fp, i) => {
|
|
137
172
|
const r = stats[i];
|
|
138
173
|
const mt = r.status === "fulfilled" ? r.value.mtimeMs ?? 0 : 0;
|
|
@@ -145,7 +180,7 @@ Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(applied
|
|
|
145
180
|
const relative = items.map((f) => toRelativePath(f, cwd));
|
|
146
181
|
return relative.join("\n") + truncationSuffix(appliedLimit, offset);
|
|
147
182
|
} catch (error) {
|
|
148
|
-
const msg =
|
|
183
|
+
const msg = extractErrorMessage(error);
|
|
149
184
|
return `Error [grep]: Failed to search: ${msg}`;
|
|
150
185
|
}
|
|
151
186
|
}
|
|
@@ -154,6 +189,7 @@ Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(applied
|
|
|
154
189
|
var grep = createGrep();
|
|
155
190
|
|
|
156
191
|
export {
|
|
192
|
+
getPrompt,
|
|
157
193
|
createGrep,
|
|
158
194
|
grep
|
|
159
195
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
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 _chunkVQSWMGG7cjs = require('./chunk-VQSWMGG7.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
8
|
+
|
|
9
|
+
// src/task-list/index.ts
|
|
10
|
+
var _ai = require('ai');
|
|
11
|
+
var _zod = require('zod');
|
|
12
|
+
var _path = require('path');
|
|
13
|
+
|
|
14
|
+
// src/task-list/prompt.ts
|
|
15
|
+
function getPrompt() {
|
|
16
|
+
return `List all tasks with their status, owner, and dependencies.
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
- To see what tasks are available to work on (status: pending, not blocked)
|
|
20
|
+
- To check overall progress on the current work
|
|
21
|
+
- To find tasks that are blocked and need dependencies resolved
|
|
22
|
+
- After completing a task \u2014 check for newly unblocked work
|
|
23
|
+
- Before creating new tasks \u2014 check for duplicates
|
|
24
|
+
|
|
25
|
+
## Output Format
|
|
26
|
+
Returns a summary of each non-deleted task:
|
|
27
|
+
- **id**: Task identifier (use with task-get or task-update)
|
|
28
|
+
- **status**: pending, in_progress, or completed
|
|
29
|
+
- **subject**: Brief description of the task
|
|
30
|
+
- **owner**: Who is assigned (if set)
|
|
31
|
+
- **blockedBy**: Tasks that must complete before this one can start
|
|
32
|
+
|
|
33
|
+
## Tips
|
|
34
|
+
- Tasks with non-empty \`blockedBy\` lists cannot be started until their dependencies are resolved
|
|
35
|
+
- Use task-get with a specific ID to see full details including description and metadata
|
|
36
|
+
- After marking a task completed, call this tool to find the next available task`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// src/task-list/index.ts
|
|
40
|
+
function createTaskList(config = {}) {
|
|
41
|
+
const cwd = _nullishCoalesce(config.cwd, () => ( process.cwd()));
|
|
42
|
+
const tasksFile = _nullishCoalesce(config.tasksFile, () => ( _path.join.call(void 0, cwd, ".agentool", "tasks.json")));
|
|
43
|
+
return _ai.tool.call(void 0, {
|
|
44
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
45
|
+
inputSchema: _zod.z.object({}),
|
|
46
|
+
execute: async () => {
|
|
47
|
+
try {
|
|
48
|
+
const tasks = await _chunkVQSWMGG7cjs.loadTasks.call(void 0, tasksFile);
|
|
49
|
+
const visible = tasks.filter((t) => t.status !== "deleted");
|
|
50
|
+
if (visible.length === 0) return "No tasks found.";
|
|
51
|
+
return visible.map(_chunkVQSWMGG7cjs.formatTaskSummary).join("\n");
|
|
52
|
+
} catch (error) {
|
|
53
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
54
|
+
return `Error [task-list]: ${msg}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
var taskList = createTaskList();
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
exports.getPrompt = getPrompt; exports.createTaskList = createTaskList; exports.taskList = taskList;
|
|
@@ -1,12 +1,50 @@
|
|
|
1
|
+
import {
|
|
2
|
+
listDirectory,
|
|
3
|
+
readTextContent,
|
|
4
|
+
removeFile,
|
|
5
|
+
writeTextContent
|
|
6
|
+
} from "./chunk-PWBVB6MN.js";
|
|
1
7
|
import {
|
|
2
8
|
containsPathTraversal
|
|
3
9
|
} from "./chunk-I3ONDY7P.js";
|
|
10
|
+
import {
|
|
11
|
+
extractErrorMessage
|
|
12
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
13
|
|
|
5
14
|
// src/memory/index.ts
|
|
6
15
|
import { tool } from "ai";
|
|
7
16
|
import { z } from "zod";
|
|
8
|
-
import { mkdir, readFile, readdir, unlink, writeFile } from "fs/promises";
|
|
9
17
|
import { join } from "path";
|
|
18
|
+
|
|
19
|
+
// src/memory/prompt.ts
|
|
20
|
+
function getPrompt() {
|
|
21
|
+
return `File-based key-value memory store for persisting notes, context, or any text data across conversations.
|
|
22
|
+
|
|
23
|
+
Entries are stored as individual .md files in the memory directory.
|
|
24
|
+
|
|
25
|
+
## Operations
|
|
26
|
+
- **write**: Store content under a key (creates or overwrites)
|
|
27
|
+
- **read**: Retrieve content by key
|
|
28
|
+
- **list**: List all stored keys
|
|
29
|
+
- **delete**: Remove a key and its content
|
|
30
|
+
|
|
31
|
+
## When to Use
|
|
32
|
+
- To persist information that should survive across conversations or sessions
|
|
33
|
+
- To store user preferences, project notes, or context summaries
|
|
34
|
+
- To keep a running log of decisions, findings, or important details
|
|
35
|
+
|
|
36
|
+
## When NOT to Use
|
|
37
|
+
- For temporary data within a single conversation \u2014 just keep it in context
|
|
38
|
+
- For structured task tracking \u2014 use the task management tools instead
|
|
39
|
+
|
|
40
|
+
## Usage Guidelines
|
|
41
|
+
- Keys are sanitized to prevent path traversal (no ../ allowed)
|
|
42
|
+
- The \`key\` parameter is required for read, write, and delete operations
|
|
43
|
+
- The \`content\` parameter is required for write operations
|
|
44
|
+
- Use descriptive key names for easy discovery (e.g., "user-preferences", "project-architecture")`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/memory/index.ts
|
|
10
48
|
function sanitizeKey(key) {
|
|
11
49
|
if (!key || key.trim() === "") {
|
|
12
50
|
return { err: "Error [memory]: Key must not be empty." };
|
|
@@ -24,7 +62,7 @@ function createMemory(config = {}) {
|
|
|
24
62
|
const cwd = config.cwd ?? process.cwd();
|
|
25
63
|
const memoryDir = config.memoryDir ?? join(cwd, ".agentool", "memory");
|
|
26
64
|
return tool({
|
|
27
|
-
description:
|
|
65
|
+
description: config.description ?? getPrompt(),
|
|
28
66
|
inputSchema: z.object({
|
|
29
67
|
action: z.enum(["read", "write", "list", "delete"]).describe(
|
|
30
68
|
"The operation to perform: read, write, list, or delete"
|
|
@@ -55,7 +93,7 @@ function createMemory(config = {}) {
|
|
|
55
93
|
return `Error [memory]: Unknown action "${String(action)}".`;
|
|
56
94
|
}
|
|
57
95
|
} catch (error) {
|
|
58
|
-
const msg =
|
|
96
|
+
const msg = extractErrorMessage(error);
|
|
59
97
|
return `Error [memory]: ${msg}`;
|
|
60
98
|
}
|
|
61
99
|
}
|
|
@@ -65,20 +103,19 @@ async function writeEntry(dir, key, content) {
|
|
|
65
103
|
if (!content && content !== "") {
|
|
66
104
|
return "Error [memory]: Content is required for write action.";
|
|
67
105
|
}
|
|
68
|
-
await
|
|
69
|
-
await writeFile(join(dir, `${key}.md`), content, "utf-8");
|
|
106
|
+
await writeTextContent(join(dir, `${key}.md`), content);
|
|
70
107
|
return `Saved memory "${key}".`;
|
|
71
108
|
}
|
|
72
109
|
async function readEntry(dir, key) {
|
|
73
110
|
try {
|
|
74
|
-
return await
|
|
111
|
+
return await readTextContent(join(dir, `${key}.md`));
|
|
75
112
|
} catch {
|
|
76
113
|
return `Error [memory]: Key "${key}" not found.`;
|
|
77
114
|
}
|
|
78
115
|
}
|
|
79
116
|
async function listKeys(dir) {
|
|
80
117
|
try {
|
|
81
|
-
const files = await
|
|
118
|
+
const files = await listDirectory(dir);
|
|
82
119
|
const keys = files.filter((f) => f.endsWith(".md")).map((f) => f.slice(0, -3));
|
|
83
120
|
if (keys.length === 0) return "No memory entries found.";
|
|
84
121
|
return keys.join("\n");
|
|
@@ -88,7 +125,7 @@ async function listKeys(dir) {
|
|
|
88
125
|
}
|
|
89
126
|
async function deleteEntry(dir, key) {
|
|
90
127
|
try {
|
|
91
|
-
await
|
|
128
|
+
await removeFile(join(dir, `${key}.md`));
|
|
92
129
|
return `Deleted memory "${key}".`;
|
|
93
130
|
} catch {
|
|
94
131
|
return `Error [memory]: Key "${key}" not found.`;
|
|
@@ -97,6 +134,7 @@ async function deleteEntry(dir, key) {
|
|
|
97
134
|
var memory = createMemory();
|
|
98
135
|
|
|
99
136
|
export {
|
|
137
|
+
getPrompt,
|
|
100
138
|
createMemory,
|
|
101
139
|
memory
|
|
102
140
|
};
|
|
@@ -47,6 +47,16 @@ function applyEditToFile(originalContent, oldString, newString, replaceAll = fal
|
|
|
47
47
|
const stripTrailingNewline = !oldString.endsWith("\n") && originalContent.includes(oldString + "\n");
|
|
48
48
|
return stripTrailingNewline ? f(originalContent, oldString + "\n", newString) : f(originalContent, oldString, newString);
|
|
49
49
|
}
|
|
50
|
+
function countOccurrences(text, search) {
|
|
51
|
+
if (search.length === 0) return 0;
|
|
52
|
+
let count = 0;
|
|
53
|
+
let pos = 0;
|
|
54
|
+
while ((pos = text.indexOf(search, pos)) !== -1) {
|
|
55
|
+
count++;
|
|
56
|
+
pos += search.length;
|
|
57
|
+
}
|
|
58
|
+
return count;
|
|
59
|
+
}
|
|
50
60
|
function isOpeningContext(chars, index) {
|
|
51
61
|
if (index === 0) {
|
|
52
62
|
return true;
|
|
@@ -95,5 +105,6 @@ function applyCurlySingleQuotes(str) {
|
|
|
95
105
|
export {
|
|
96
106
|
findActualString,
|
|
97
107
|
preserveQuoteStyle,
|
|
98
|
-
applyEditToFile
|
|
108
|
+
applyEditToFile,
|
|
109
|
+
countOccurrences
|
|
99
110
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
readTextContent
|
|
3
|
+
} from "./chunk-PWBVB6MN.js";
|
|
1
4
|
import {
|
|
2
5
|
expandPath
|
|
3
6
|
} from "./chunk-I3ONDY7P.js";
|
|
7
|
+
import {
|
|
8
|
+
extractErrorMessage
|
|
9
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
10
|
|
|
5
11
|
// src/diff/index.ts
|
|
6
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
7
12
|
import { tool } from "ai";
|
|
8
13
|
import { z } from "zod";
|
|
9
14
|
|
|
10
15
|
// src/shared/diff.ts
|
|
11
|
-
import { readFile } from "fs/promises";
|
|
12
16
|
import { createTwoFilesPatch } from "diff";
|
|
13
17
|
function diffStrings(oldContent, newContent, options) {
|
|
14
18
|
if (oldContent === newContent) {
|
|
@@ -29,8 +33,8 @@ function diffStrings(oldContent, newContent, options) {
|
|
|
29
33
|
}
|
|
30
34
|
async function diffFiles(oldFilePath, newFilePath, options) {
|
|
31
35
|
const [oldContent, newContent] = await Promise.all([
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
readTextContent(oldFilePath),
|
|
37
|
+
readTextContent(newFilePath)
|
|
34
38
|
]);
|
|
35
39
|
return diffStrings(oldContent, newContent, {
|
|
36
40
|
...options,
|
|
@@ -39,11 +43,30 @@ async function diffFiles(oldFilePath, newFilePath, options) {
|
|
|
39
43
|
});
|
|
40
44
|
}
|
|
41
45
|
|
|
46
|
+
// src/diff/prompt.ts
|
|
47
|
+
function getPrompt() {
|
|
48
|
+
return `Generate a unified diff between two files or two strings.
|
|
49
|
+
|
|
50
|
+
Supports three modes:
|
|
51
|
+
1. **Two file paths**: \`file_path\` + \`other_file_path\` \u2014 compares the contents of both files
|
|
52
|
+
2. **Two strings**: \`old_content\` + \`new_content\` \u2014 compares the provided strings directly
|
|
53
|
+
3. **File + string**: \`file_path\` + \`old_content\` or \`new_content\` \u2014 compares a file against provided content
|
|
54
|
+
|
|
55
|
+
## When to Use
|
|
56
|
+
- To preview what changes would look like before making edits
|
|
57
|
+
- To compare two versions of a file or text
|
|
58
|
+
- To generate a diff for review or documentation purposes
|
|
59
|
+
|
|
60
|
+
## When NOT to Use
|
|
61
|
+
- To actually apply changes to a file \u2014 use the file editing tool instead
|
|
62
|
+
- To read file contents \u2014 use the file reading tool instead`;
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
// src/diff/index.ts
|
|
43
66
|
function createDiff(config = {}) {
|
|
44
67
|
const cwd = config.cwd ?? process.cwd();
|
|
45
68
|
return tool({
|
|
46
|
-
description:
|
|
69
|
+
description: config.description ?? getPrompt(),
|
|
47
70
|
inputSchema: z.object({
|
|
48
71
|
file_path: z.string().optional().describe("Path to the first file (absolute or relative to cwd)"),
|
|
49
72
|
other_file_path: z.string().optional().describe("Path to the second file (absolute or relative to cwd)"),
|
|
@@ -62,7 +85,7 @@ function createDiff(config = {}) {
|
|
|
62
85
|
}
|
|
63
86
|
if (file_path && (old_content !== void 0 || new_content !== void 0)) {
|
|
64
87
|
const resolvedPath = expandPath(file_path, cwd);
|
|
65
|
-
const fileContent = await
|
|
88
|
+
const fileContent = await readTextContent(resolvedPath);
|
|
66
89
|
if (old_content !== void 0) {
|
|
67
90
|
return diffStrings(old_content, fileContent, {
|
|
68
91
|
oldLabel: "provided",
|
|
@@ -76,7 +99,7 @@ function createDiff(config = {}) {
|
|
|
76
99
|
}
|
|
77
100
|
return "Error [diff]: Insufficient parameters. Provide either: (1) file_path + other_file_path, (2) old_content + new_content, or (3) file_path + old_content/new_content.";
|
|
78
101
|
} catch (error) {
|
|
79
|
-
const msg =
|
|
102
|
+
const msg = extractErrorMessage(error);
|
|
80
103
|
return `Error [diff]: ${msg}`;
|
|
81
104
|
}
|
|
82
105
|
}
|
|
@@ -85,6 +108,7 @@ function createDiff(config = {}) {
|
|
|
85
108
|
var diff = createDiff();
|
|
86
109
|
|
|
87
110
|
export {
|
|
111
|
+
getPrompt,
|
|
88
112
|
createDiff,
|
|
89
113
|
diff
|
|
90
114
|
};
|