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.
Files changed (156) hide show
  1. package/dist/ask-user/index.cjs +5 -2
  2. package/dist/ask-user/index.d.cts +10 -1
  3. package/dist/ask-user/index.d.ts +10 -1
  4. package/dist/ask-user/index.js +5 -2
  5. package/dist/bash/index.cjs +5 -2
  6. package/dist/bash/index.d.cts +14 -1
  7. package/dist/bash/index.d.ts +14 -1
  8. package/dist/bash/index.js +5 -2
  9. package/dist/{chunk-IEX4NOVN.cjs → chunk-2JBLVFB7.cjs} +30 -4
  10. package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
  11. package/dist/{chunk-UDIG7332.js → chunk-2WSZCOJP.js} +40 -4
  12. package/dist/chunk-3FT4ZPB2.cjs +65 -0
  13. package/dist/{chunk-VLNDEVKS.js → chunk-3LGXZLBH.js} +46 -8
  14. package/dist/{chunk-G3ITTPGX.js → chunk-4MXDQEPA.js} +12 -1
  15. package/dist/{chunk-CGTPF6IS.js → chunk-4UUSERSH.js} +31 -7
  16. package/dist/{chunk-I6KFFQPV.cjs → chunk-5T3SQYI4.cjs} +34 -4
  17. package/dist/chunk-6ULQG2W2.cjs +99 -0
  18. package/dist/chunk-ABXTBB2N.cjs +67 -0
  19. package/dist/{chunk-CAEVLIQB.cjs → chunk-BIAODQ2P.cjs} +17 -1
  20. package/dist/chunk-CJA76MKM.js +59 -0
  21. package/dist/chunk-CM3VRCNX.cjs +59 -0
  22. package/dist/{chunk-SUSAPI5W.cjs → chunk-CXBWF5ON.cjs} +51 -4
  23. package/dist/{chunk-5O55DKOB.cjs → chunk-G6ZVJA4V.cjs} +30 -4
  24. package/dist/{chunk-P6Z5XFDS.js → chunk-GPHCXS2S.js} +41 -15
  25. package/dist/chunk-HG5T47NA.cjs +77 -0
  26. package/dist/chunk-HO4NIRU5.js +65 -0
  27. package/dist/{chunk-HZAQRHBT.js → chunk-IBC4QCGR.js} +27 -2
  28. package/dist/chunk-JYTOARJV.cjs +69 -0
  29. package/dist/chunk-KONXT2SF.cjs +8 -0
  30. package/dist/chunk-KUFZFNPT.cjs +61 -0
  31. package/dist/chunk-L7R4UZSK.js +61 -0
  32. package/dist/{chunk-FV2R5FFQ.cjs → chunk-LNAR3NJQ.cjs} +47 -9
  33. package/dist/chunk-M74OQYNK.js +69 -0
  34. package/dist/{chunk-5TDZF4IM.cjs → chunk-NQIV6LBH.cjs} +42 -6
  35. package/dist/chunk-NTGDU5X3.js +67 -0
  36. package/dist/{chunk-ONBH74ZV.cjs → chunk-OYLTQJXT.cjs} +32 -8
  37. package/dist/{chunk-6PQLFDGT.js → chunk-PWBVB6MN.js} +17 -1
  38. package/dist/{chunk-HNP7JDQC.cjs → chunk-RIGL3JTS.cjs} +41 -5
  39. package/dist/chunk-SFDZRLSX.cjs +91 -0
  40. package/dist/{chunk-ZFQZWXOI.cjs → chunk-T6STO7PS.cjs} +58 -7
  41. package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
  42. package/dist/{chunk-S7IVHOA6.js → chunk-TM5L4HA5.js} +54 -3
  43. package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
  44. package/dist/{chunk-IRRNYFI5.js → chunk-UCA6LURO.js} +28 -2
  45. package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
  46. package/dist/{chunk-E6NBEYZD.js → chunk-VHLY7LQE.js} +7 -5
  47. package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
  48. package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
  49. package/dist/{chunk-L5JH4I77.cjs → chunk-VQSWMGG7.cjs} +8 -6
  50. package/dist/{chunk-4HIATLKI.js → chunk-VZRXTFS4.js} +28 -2
  51. package/dist/chunk-WCR62UZ3.js +67 -0
  52. package/dist/chunk-X6ZY2KFU.js +8 -0
  53. package/dist/chunk-XGDE7S2D.cjs +67 -0
  54. package/dist/chunk-XPTW45XY.js +77 -0
  55. package/dist/{chunk-YPPPGGLA.cjs → chunk-YCWJVQYO.cjs} +28 -3
  56. package/dist/chunk-YGXLT6SS.js +91 -0
  57. package/dist/{chunk-5NW4OGRI.cjs → chunk-YTPZHJDC.cjs} +12 -1
  58. package/dist/{chunk-XAQGZ374.js → chunk-ZHVRP3EH.js} +40 -4
  59. package/dist/context-compaction/index.cjs +5 -2
  60. package/dist/context-compaction/index.d.cts +11 -1
  61. package/dist/context-compaction/index.d.ts +11 -1
  62. package/dist/context-compaction/index.js +5 -2
  63. package/dist/diff/index.cjs +6 -2
  64. package/dist/diff/index.d.cts +12 -2
  65. package/dist/diff/index.d.ts +12 -2
  66. package/dist/diff/index.js +7 -3
  67. package/dist/edit/index.cjs +7 -3
  68. package/dist/edit/index.d.cts +13 -3
  69. package/dist/edit/index.d.ts +13 -3
  70. package/dist/edit/index.js +8 -4
  71. package/dist/glob/index.cjs +5 -2
  72. package/dist/glob/index.d.cts +13 -3
  73. package/dist/glob/index.d.ts +13 -3
  74. package/dist/glob/index.js +5 -2
  75. package/dist/grep/index.cjs +6 -2
  76. package/dist/grep/index.d.cts +13 -3
  77. package/dist/grep/index.d.ts +13 -3
  78. package/dist/grep/index.js +6 -2
  79. package/dist/http-request/index.cjs +5 -2
  80. package/dist/http-request/index.d.cts +11 -1
  81. package/dist/http-request/index.d.ts +11 -1
  82. package/dist/http-request/index.js +5 -2
  83. package/dist/index.cjs +68 -25
  84. package/dist/index.d.cts +21 -21
  85. package/dist/index.d.ts +21 -21
  86. package/dist/index.js +73 -30
  87. package/dist/lsp/index.cjs +6 -2
  88. package/dist/lsp/index.d.cts +10 -1
  89. package/dist/lsp/index.d.ts +10 -1
  90. package/dist/lsp/index.js +6 -2
  91. package/dist/memory/index.cjs +6 -2
  92. package/dist/memory/index.d.cts +10 -1
  93. package/dist/memory/index.d.ts +10 -1
  94. package/dist/memory/index.js +6 -2
  95. package/dist/multi-edit/index.cjs +7 -4
  96. package/dist/multi-edit/index.d.cts +12 -2
  97. package/dist/multi-edit/index.d.ts +12 -2
  98. package/dist/multi-edit/index.js +7 -4
  99. package/dist/read/index.cjs +6 -3
  100. package/dist/read/index.d.cts +11 -1
  101. package/dist/read/index.d.ts +11 -1
  102. package/dist/read/index.js +6 -3
  103. package/dist/sleep/index.cjs +5 -2
  104. package/dist/sleep/index.d.cts +11 -1
  105. package/dist/sleep/index.d.ts +11 -1
  106. package/dist/sleep/index.js +5 -2
  107. package/dist/task-create/index.cjs +7 -3
  108. package/dist/task-create/index.d.cts +10 -1
  109. package/dist/task-create/index.d.ts +10 -1
  110. package/dist/task-create/index.js +7 -3
  111. package/dist/task-get/index.cjs +7 -3
  112. package/dist/task-get/index.d.cts +10 -1
  113. package/dist/task-get/index.d.ts +10 -1
  114. package/dist/task-get/index.js +7 -3
  115. package/dist/task-list/index.cjs +7 -3
  116. package/dist/task-list/index.d.cts +10 -1
  117. package/dist/task-list/index.d.ts +10 -1
  118. package/dist/task-list/index.js +7 -3
  119. package/dist/task-update/index.cjs +7 -3
  120. package/dist/task-update/index.d.cts +12 -3
  121. package/dist/task-update/index.d.ts +12 -3
  122. package/dist/task-update/index.js +7 -3
  123. package/dist/tool-search/index.cjs +5 -2
  124. package/dist/tool-search/index.d.cts +10 -1
  125. package/dist/tool-search/index.d.ts +10 -1
  126. package/dist/tool-search/index.js +5 -2
  127. package/dist/web-fetch/index.cjs +5 -2
  128. package/dist/web-fetch/index.d.cts +11 -1
  129. package/dist/web-fetch/index.d.ts +11 -1
  130. package/dist/web-fetch/index.js +5 -2
  131. package/dist/web-search/index.cjs +5 -2
  132. package/dist/web-search/index.d.cts +10 -1
  133. package/dist/web-search/index.d.ts +10 -1
  134. package/dist/web-search/index.js +5 -2
  135. package/dist/write/index.cjs +6 -3
  136. package/dist/write/index.d.cts +13 -3
  137. package/dist/write/index.d.ts +13 -3
  138. package/dist/write/index.js +6 -3
  139. package/package.json +1 -1
  140. package/dist/chunk-3EPGFWZV.cjs +0 -30
  141. package/dist/chunk-44AFQ2B7.js +0 -30
  142. package/dist/chunk-4HXAKPQH.cjs +0 -36
  143. package/dist/chunk-56CL4JCW.cjs +0 -53
  144. package/dist/chunk-6DJSWTWQ.cjs +0 -40
  145. package/dist/chunk-ACGW44YT.js +0 -47
  146. package/dist/chunk-ECYT46FP.js +0 -40
  147. package/dist/chunk-HDKXSKMO.js +0 -30
  148. package/dist/chunk-HNUL2CID.cjs +0 -34
  149. package/dist/chunk-LK6SQH2G.cjs +0 -30
  150. package/dist/chunk-LTE5NG4D.js +0 -53
  151. package/dist/chunk-MF7CJVIZ.js +0 -40
  152. package/dist/chunk-OM2UFTGS.cjs +0 -47
  153. package/dist/chunk-OXLQ7QVL.cjs +0 -40
  154. package/dist/chunk-TMW3XKKJ.js +0 -34
  155. package/dist/chunk-VXZ4RKJI.js +0 -36
  156. package/dist/chunk-ZBLQV6UO.cjs +0 -73
@@ -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: "Execute a shell command and return its output. Runs the command in a bash shell with the configured working directory. Returns stdout, stderr, and exit code. Use this for running build commands, git operations, system administration, and any other shell tasks.",
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 = error instanceof Error ? error.message : String(error);
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
  };
@@ -1,9 +1,34 @@
1
+ import {
2
+ extractErrorMessage
3
+ } from "./chunk-X6ZY2KFU.js";
4
+
1
5
  // src/tool-search/index.ts
2
6
  import { tool } from "ai";
3
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
4
29
  function createToolSearch(config = {}) {
5
30
  return tool({
6
- description: "Search for available tools by name or keyword. Returns matching tool names and descriptions.",
31
+ description: config.description ?? getPrompt(),
7
32
  inputSchema: z.object({
8
33
  query: z.string().describe("Query to find tools by name or keyword"),
9
34
  max_results: 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 = error instanceof Error ? error.message : String(error);
62
+ const msg = extractErrorMessage(error);
38
63
  return `Error [tool-search]: ${msg}`;
39
64
  }
40
65
  }
@@ -43,6 +68,7 @@ function createToolSearch(config = {}) {
43
68
  var toolSearch = createToolSearch();
44
69
 
45
70
  export {
71
+ getPrompt,
46
72
  createToolSearch,
47
73
  toolSearch
48
74
  };
@@ -1,33 +1,52 @@
1
1
  import {
2
2
  applyEditToFile,
3
+ countOccurrences,
3
4
  findActualString,
4
5
  preserveQuoteStyle
5
- } from "./chunk-G3ITTPGX.js";
6
+ } from "./chunk-4MXDQEPA.js";
6
7
  import {
8
+ readTextContent,
7
9
  writeTextContent
8
- } from "./chunk-6PQLFDGT.js";
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
- function countOccurrences(text, search) {
18
- if (search.length === 0) return 0;
19
- let count = 0;
20
- let pos = 0;
21
- while ((pos = text.indexOf(search, pos)) !== -1) {
22
- count++;
23
- pos += search.length;
24
- }
25
- return count;
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: "Atomically apply multiple text edits to a single file. All edits succeed together or none are applied (rollback on failure). Each edit replaces one occurrence of old_string with new_string. Edits are applied sequentially in the order provided.",
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 readFile(resolvedPath, "utf-8");
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 = error instanceof Error ? error.message : String(error);
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
  };
@@ -1,21 +1,23 @@
1
+ import {
2
+ readTextContent,
3
+ writeTextContent
4
+ } from "./chunk-PWBVB6MN.js";
5
+
1
6
  // src/shared/task-store.ts
2
- import { mkdir, readFile, writeFile } from "fs/promises";
3
- import { dirname } from "path";
4
7
  import { randomBytes } from "crypto";
5
8
  function generateId() {
6
9
  return randomBytes(4).toString("hex");
7
10
  }
8
11
  async function loadTasks(filePath) {
9
12
  try {
10
- const data = await readFile(filePath, "utf-8");
13
+ const data = await readTextContent(filePath);
11
14
  return JSON.parse(data);
12
15
  } catch {
13
16
  return [];
14
17
  }
15
18
  }
16
19
  async function saveTasks(filePath, tasks) {
17
- await mkdir(dirname(filePath), { recursive: true });
18
- await writeFile(filePath, JSON.stringify(tasks, null, 2), "utf-8");
20
+ await writeTextContent(filePath, JSON.stringify(tasks, null, 2));
19
21
  }
20
22
  function formatTask(t) {
21
23
  const lines = [
@@ -1,6 +1,35 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/context-compaction/index.ts
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/context-compaction/index.ts
2
6
  var _ai = require('ai');
3
7
  var _zod = require('zod');
8
+
9
+ // src/context-compaction/prompt.ts
10
+ function getPrompt(config = {}) {
11
+ const maxTokens = _nullishCoalesce(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 = _zod.z.object({
5
34
  messages: _zod.z.array(
6
35
  _zod.z.object({
@@ -14,7 +43,7 @@ var parametersSchema = _zod.z.object({
14
43
  });
15
44
  function createContextCompaction(config = {}) {
16
45
  return _ai.tool.call(void 0, {
17
- description: "Compact conversation history by summarizing older messages to reduce context size. Requires a summarize function in config. Returns compacted messages where total chars < maxTokens * 4.",
46
+ description: _nullishCoalesce(config.description, () => ( getPrompt(config))),
18
47
  inputSchema: _ai.zodSchema.call(void 0, 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 = error instanceof Error ? error.message : String(error);
77
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
49
78
  return `Error [context-compaction]: Summarization failed: ${msg}`;
50
79
  }
51
80
  }
@@ -56,4 +85,5 @@ var contextCompaction = createContextCompaction();
56
85
 
57
86
 
58
87
 
59
- exports.createContextCompaction = createContextCompaction; exports.contextCompaction = contextCompaction;
88
+
89
+ exports.getPrompt = getPrompt; exports.createContextCompaction = createContextCompaction; exports.contextCompaction = contextCompaction;
@@ -2,32 +2,51 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk5NW4OGRIcjs = require('./chunk-5NW4OGRI.cjs');
6
5
 
6
+ var _chunkYTPZHJDCcjs = require('./chunk-YTPZHJDC.cjs');
7
7
 
8
- var _chunkCAEVLIQBcjs = require('./chunk-CAEVLIQB.cjs');
8
+
9
+
10
+ var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
9
11
 
10
12
 
11
13
  var _chunkQZ5GS6HWcjs = require('./chunk-QZ5GS6HW.cjs');
12
14
 
15
+
16
+ var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
17
+
13
18
  // src/multi-edit/index.ts
14
- var _promises = require('fs/promises');
15
19
  var _ai = require('ai');
16
20
  var _zod = require('zod');
17
- function countOccurrences(text, search) {
18
- if (search.length === 0) return 0;
19
- let count = 0;
20
- let pos = 0;
21
- while ((pos = text.indexOf(search, pos)) !== -1) {
22
- count++;
23
- pos += search.length;
24
- }
25
- return count;
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 = _nullishCoalesce(config.cwd, () => ( process.cwd()));
29
48
  return _ai.tool.call(void 0, {
30
- description: "Atomically apply multiple text edits to a single file. All edits succeed together or none are applied (rollback on failure). Each edit replaces one occurrence of old_string with new_string. Edits are applied sequentially in the order provided.",
49
+ description: _nullishCoalesce(config.description, () => ( getPrompt())),
31
50
  inputSchema: _zod.z.object({
32
51
  file_path: _zod.z.string().describe("Path to the file to edit (absolute or relative to cwd)"),
33
52
  edits: _zod.z.array(
@@ -43,29 +62,29 @@ function createMultiEdit(config = {}) {
43
62
  return "No edits provided. File unchanged.";
44
63
  }
45
64
  const resolvedPath = _chunkQZ5GS6HWcjs.expandPath.call(void 0, file_path, cwd);
46
- const originalContent = await _promises.readFile.call(void 0, resolvedPath, "utf-8");
65
+ const originalContent = await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, resolvedPath);
47
66
  let content = originalContent;
48
67
  for (let i = 0; i < edits.length; i++) {
49
68
  const edit = edits[i];
50
- const actualOldString = _chunk5NW4OGRIcjs.findActualString.call(void 0, content, edit.old_string);
69
+ const actualOldString = _chunkYTPZHJDCcjs.findActualString.call(void 0, content, edit.old_string);
51
70
  if (actualOldString === null) {
52
71
  return `Error [multi-edit]: Edit ${i + 1}/${edits.length} failed \u2014 old_string not found in file. No edits were applied. File: ${resolvedPath}`;
53
72
  }
54
- const occurrences = countOccurrences(content, actualOldString);
73
+ const occurrences = _chunkYTPZHJDCcjs.countOccurrences.call(void 0, content, actualOldString);
55
74
  if (occurrences > 1) {
56
75
  return `Error [multi-edit]: Edit ${i + 1}/${edits.length} failed \u2014 old_string matches ${occurrences} locations (must be unique). No edits were applied. File: ${resolvedPath}`;
57
76
  }
58
- const styledNewString = _chunk5NW4OGRIcjs.preserveQuoteStyle.call(void 0,
77
+ const styledNewString = _chunkYTPZHJDCcjs.preserveQuoteStyle.call(void 0,
59
78
  edit.old_string,
60
79
  actualOldString,
61
80
  edit.new_string
62
81
  );
63
- content = _chunk5NW4OGRIcjs.applyEditToFile.call(void 0, content, actualOldString, styledNewString);
82
+ content = _chunkYTPZHJDCcjs.applyEditToFile.call(void 0, content, actualOldString, styledNewString);
64
83
  }
65
- await _chunkCAEVLIQBcjs.writeTextContent.call(void 0, resolvedPath, content);
84
+ await _chunkBIAODQ2Pcjs.writeTextContent.call(void 0, resolvedPath, content);
66
85
  return `Successfully applied ${edits.length} edit${edits.length === 1 ? "" : "s"} to ${resolvedPath}`;
67
86
  } catch (error) {
68
- const msg = error instanceof Error ? error.message : String(error);
87
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
69
88
  return `Error [multi-edit]: ${msg}`;
70
89
  }
71
90
  }
@@ -76,4 +95,5 @@ var multiEdit = createMultiEdit();
76
95
 
77
96
 
78
97
 
79
- exports.createMultiEdit = createMultiEdit; exports.multiEdit = multiEdit;
98
+
99
+ exports.getPrompt = getPrompt; exports.createMultiEdit = createMultiEdit; exports.multiEdit = multiEdit;
@@ -1,21 +1,23 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/shared/task-store.ts
2
- var _promises = require('fs/promises');
3
- var _path = require('path');
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+ var _chunkBIAODQ2Pcjs = require('./chunk-BIAODQ2P.cjs');
5
+
6
+ // src/shared/task-store.ts
4
7
  var _crypto = require('crypto');
5
8
  function generateId() {
6
9
  return _crypto.randomBytes.call(void 0, 4).toString("hex");
7
10
  }
8
11
  async function loadTasks(filePath) {
9
12
  try {
10
- const data = await _promises.readFile.call(void 0, filePath, "utf-8");
13
+ const data = await _chunkBIAODQ2Pcjs.readTextContent.call(void 0, filePath);
11
14
  return JSON.parse(data);
12
15
  } catch (e) {
13
16
  return [];
14
17
  }
15
18
  }
16
19
  async function saveTasks(filePath, tasks) {
17
- await _promises.mkdir.call(void 0, _path.dirname.call(void 0, filePath), { recursive: true });
18
- await _promises.writeFile.call(void 0, filePath, JSON.stringify(tasks, null, 2), "utf-8");
20
+ await _chunkBIAODQ2Pcjs.writeTextContent.call(void 0, filePath, JSON.stringify(tasks, null, 2));
19
21
  }
20
22
  function formatTask(t) {
21
23
  const lines = [
@@ -1,3 +1,7 @@
1
+ import {
2
+ extractErrorMessage
3
+ } from "./chunk-X6ZY2KFU.js";
4
+
1
5
  // src/web-fetch/index.ts
2
6
  import { tool } from "ai";
3
7
  import { z } from "zod";
@@ -73,10 +77,31 @@ async function fetchUrl(url, options) {
73
77
  };
74
78
  }
75
79
 
80
+ // src/web-fetch/prompt.ts
81
+ function getPrompt(config = {}) {
82
+ const timeout = config.timeout ?? 3e4;
83
+ return `Fetch a URL and return its content. HTML pages are automatically converted to markdown for easier reading. JSON and other text content is returned as-is.
84
+
85
+ ## When to Use
86
+ - To retrieve and read web page content, documentation, or articles
87
+ - To fetch API responses, JSON data, or raw text from URLs
88
+ - To check what a web page contains
89
+
90
+ ## When NOT to Use
91
+ - For API interactions that need custom HTTP methods (POST, PUT, DELETE) \u2014 use the dedicated HTTP request tool instead
92
+ - For searching the web \u2014 use the dedicated web search tool instead
93
+
94
+ ## Usage Guidelines
95
+ - Content is truncated at 100,000 characters to manage context size
96
+ - The URL must be a fully-formed valid URL (e.g., https://example.com)
97
+ - Timeout: ${timeout}ms
98
+ - This tool is read-only \u2014 it does not modify any files or state`;
99
+ }
100
+
76
101
  // src/web-fetch/index.ts
77
102
  function createWebFetch(config = {}) {
78
103
  return tool({
79
- description: "Fetch a URL and return its content. HTML pages are automatically converted to markdown for easier reading. JSON and other text content is returned as-is. Content is truncated at 100,000 characters to manage context size.",
104
+ description: config.description ?? getPrompt(config),
80
105
  inputSchema: z.object({
81
106
  url: z.string().url().describe("The URL to fetch")
82
107
  }),
@@ -98,7 +123,7 @@ function createWebFetch(config = {}) {
98
123
  parts.push(result.content);
99
124
  return parts.join("\n");
100
125
  } catch (error) {
101
- const msg = error instanceof Error ? error.message : String(error);
126
+ const msg = extractErrorMessage(error);
102
127
  return `Error [web-fetch]: Failed to fetch ${url}: ${msg}`;
103
128
  }
104
129
  }
@@ -107,6 +132,7 @@ function createWebFetch(config = {}) {
107
132
  var webFetch = createWebFetch();
108
133
 
109
134
  export {
135
+ getPrompt,
110
136
  createWebFetch,
111
137
  webFetch
112
138
  };
@@ -0,0 +1,67 @@
1
+ import {
2
+ formatTask,
3
+ loadTasks
4
+ } from "./chunk-VHLY7LQE.js";
5
+ import {
6
+ extractErrorMessage
7
+ } from "./chunk-X6ZY2KFU.js";
8
+
9
+ // src/task-get/index.ts
10
+ import { tool } from "ai";
11
+ import { z } from "zod";
12
+ import { join } from "path";
13
+
14
+ // src/task-get/prompt.ts
15
+ function getPrompt() {
16
+ return `Retrieve a task by its ID to see full details including description, dependencies, and metadata.
17
+
18
+ ## When to Use
19
+ - Before starting work on a task \u2014 read the full description and requirements
20
+ - To check a task's dependencies (what it blocks, what blocks it)
21
+ - To verify a task's current status before updating it
22
+ - When you need more detail than the task list summary provides
23
+
24
+ ## Output
25
+ Returns full task details:
26
+ - **id**, **subject**, **description**, **status**
27
+ - **owner**: Who is assigned (if set)
28
+ - **activeForm**: Present continuous label (if set)
29
+ - **blocks**: Tasks waiting on this one to complete
30
+ - **blockedBy**: Tasks that must complete before this one can start
31
+ - **metadata**: Attached key-value data
32
+ - **createdAt**, **updatedAt**: Timestamps
33
+
34
+ ## Tips
35
+ - Always verify a task's \`blockedBy\` list is empty before beginning work on it
36
+ - Use the task list tool to see all tasks in summary form, then this tool for details on specific ones`;
37
+ }
38
+
39
+ // src/task-get/index.ts
40
+ function createTaskGet(config = {}) {
41
+ const cwd = config.cwd ?? process.cwd();
42
+ const tasksFile = config.tasksFile ?? join(cwd, ".agentool", "tasks.json");
43
+ return tool({
44
+ description: config.description ?? getPrompt(),
45
+ inputSchema: z.object({
46
+ taskId: z.string().describe("The ID of the task to retrieve")
47
+ }),
48
+ execute: async ({ taskId }) => {
49
+ try {
50
+ const tasks = await loadTasks(tasksFile);
51
+ const found = tasks.find((t) => t.id === taskId);
52
+ if (!found) return `Error [task-get]: Task "${taskId}" not found.`;
53
+ return formatTask(found);
54
+ } catch (error) {
55
+ const msg = extractErrorMessage(error);
56
+ return `Error [task-get]: ${msg}`;
57
+ }
58
+ }
59
+ });
60
+ }
61
+ var taskGet = createTaskGet();
62
+
63
+ export {
64
+ getPrompt,
65
+ createTaskGet,
66
+ taskGet
67
+ };
@@ -0,0 +1,8 @@
1
+ // src/shared/errors.ts
2
+ function extractErrorMessage(error) {
3
+ return error instanceof Error ? error.message : String(error);
4
+ }
5
+
6
+ export {
7
+ extractErrorMessage
8
+ };
@@ -0,0 +1,67 @@
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-get/index.ts
10
+ var _ai = require('ai');
11
+ var _zod = require('zod');
12
+ var _path = require('path');
13
+
14
+ // src/task-get/prompt.ts
15
+ function getPrompt() {
16
+ return `Retrieve a task by its ID to see full details including description, dependencies, and metadata.
17
+
18
+ ## When to Use
19
+ - Before starting work on a task \u2014 read the full description and requirements
20
+ - To check a task's dependencies (what it blocks, what blocks it)
21
+ - To verify a task's current status before updating it
22
+ - When you need more detail than the task list summary provides
23
+
24
+ ## Output
25
+ Returns full task details:
26
+ - **id**, **subject**, **description**, **status**
27
+ - **owner**: Who is assigned (if set)
28
+ - **activeForm**: Present continuous label (if set)
29
+ - **blocks**: Tasks waiting on this one to complete
30
+ - **blockedBy**: Tasks that must complete before this one can start
31
+ - **metadata**: Attached key-value data
32
+ - **createdAt**, **updatedAt**: Timestamps
33
+
34
+ ## Tips
35
+ - Always verify a task's \`blockedBy\` list is empty before beginning work on it
36
+ - Use the task list tool to see all tasks in summary form, then this tool for details on specific ones`;
37
+ }
38
+
39
+ // src/task-get/index.ts
40
+ function createTaskGet(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
+ taskId: _zod.z.string().describe("The ID of the task to retrieve")
47
+ }),
48
+ execute: async ({ taskId }) => {
49
+ try {
50
+ const tasks = await _chunkVQSWMGG7cjs.loadTasks.call(void 0, tasksFile);
51
+ const found = tasks.find((t) => t.id === taskId);
52
+ if (!found) return `Error [task-get]: Task "${taskId}" not found.`;
53
+ return _chunkVQSWMGG7cjs.formatTask.call(void 0, found);
54
+ } catch (error) {
55
+ const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
56
+ return `Error [task-get]: ${msg}`;
57
+ }
58
+ }
59
+ });
60
+ }
61
+ var taskGet = createTaskGet();
62
+
63
+
64
+
65
+
66
+
67
+ exports.getPrompt = getPrompt; exports.createTaskGet = createTaskGet; exports.taskGet = taskGet;