@travisennis/acai 0.0.11 → 0.0.13

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 (292) hide show
  1. package/README.md +5 -5
  2. package/dist/agent/index.d.ts.map +1 -1
  3. package/dist/agent/index.js +2 -5
  4. package/dist/commands/history/types.d.ts +3 -2
  5. package/dist/commands/history/types.d.ts.map +1 -1
  6. package/dist/commands/init-project/utils.d.ts +0 -1
  7. package/dist/commands/init-project/utils.d.ts.map +1 -1
  8. package/dist/commands/init-project/utils.js +1 -12
  9. package/dist/commands/manager.d.ts.map +1 -1
  10. package/dist/commands/manager.js +6 -19
  11. package/dist/commands/resources/index.d.ts.map +1 -1
  12. package/dist/commands/resources/index.js +4 -1
  13. package/dist/commands/session/index.d.ts.map +1 -1
  14. package/dist/commands/session/index.js +6 -0
  15. package/dist/commands/session/types.d.ts +1 -0
  16. package/dist/commands/session/types.d.ts.map +1 -1
  17. package/dist/commands/share/html-renderer.d.ts.map +1 -1
  18. package/dist/commands/share/html-renderer.js +54 -48
  19. package/dist/commands/tools/index.d.ts +3 -0
  20. package/dist/commands/tools/index.d.ts.map +1 -0
  21. package/dist/commands/tools/index.js +191 -0
  22. package/dist/commands/tools/templates.d.ts +6 -0
  23. package/dist/commands/tools/templates.d.ts.map +1 -0
  24. package/dist/commands/tools/templates.js +97 -0
  25. package/dist/config/index.d.ts +5 -2
  26. package/dist/config/index.d.ts.map +1 -1
  27. package/dist/config/index.js +42 -6
  28. package/dist/index.d.ts +14 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +98 -68
  31. package/dist/models/anthropic-provider.d.ts +1 -1
  32. package/dist/models/deepseek-provider.d.ts +3 -3
  33. package/dist/models/deepseek-provider.js +17 -17
  34. package/dist/models/google-provider.d.ts +2 -4
  35. package/dist/models/google-provider.d.ts.map +1 -1
  36. package/dist/models/google-provider.js +2 -17
  37. package/dist/models/groq-provider.d.ts +2 -4
  38. package/dist/models/groq-provider.d.ts.map +1 -1
  39. package/dist/models/groq-provider.js +3 -21
  40. package/dist/models/manager.d.ts +1 -10
  41. package/dist/models/manager.d.ts.map +1 -1
  42. package/dist/models/manager.js +2 -2
  43. package/dist/models/opencode-go-provider.d.ts +11 -1
  44. package/dist/models/opencode-go-provider.d.ts.map +1 -1
  45. package/dist/models/opencode-go-provider.js +130 -0
  46. package/dist/models/opencode-zen-provider.d.ts +3 -3
  47. package/dist/models/opencode-zen-provider.d.ts.map +1 -1
  48. package/dist/models/opencode-zen-provider.js +26 -32
  49. package/dist/models/openrouter-provider.d.ts +4 -15
  50. package/dist/models/openrouter-provider.d.ts.map +1 -1
  51. package/dist/models/openrouter-provider.js +26 -169
  52. package/dist/models/providers.d.ts +1 -1
  53. package/dist/models/providers.d.ts.map +1 -1
  54. package/dist/models/xai-provider.d.ts +1 -2
  55. package/dist/models/xai-provider.d.ts.map +1 -1
  56. package/dist/models/xai-provider.js +0 -13
  57. package/dist/prompts/manager.d.ts.map +1 -1
  58. package/dist/prompts/manager.js +5 -1
  59. package/dist/prompts/system-prompt.d.ts +1 -2
  60. package/dist/prompts/system-prompt.d.ts.map +1 -1
  61. package/dist/prompts/system-prompt.js +26 -15
  62. package/dist/repl/index.d.ts +28 -13
  63. package/dist/repl/index.d.ts.map +1 -1
  64. package/dist/repl/index.js +242 -305
  65. package/dist/skills/activated-tracker.d.ts +11 -0
  66. package/dist/skills/activated-tracker.d.ts.map +1 -0
  67. package/dist/skills/activated-tracker.js +16 -0
  68. package/dist/skills/index.d.ts +12 -2
  69. package/dist/skills/index.d.ts.map +1 -1
  70. package/dist/skills/index.js +127 -71
  71. package/dist/terminal/control.d.ts +1 -21
  72. package/dist/terminal/control.d.ts.map +1 -1
  73. package/dist/terminal/control.js +1 -32
  74. package/dist/terminal/formatting.d.ts +0 -33
  75. package/dist/terminal/formatting.d.ts.map +1 -1
  76. package/dist/terminal/formatting.js +0 -91
  77. package/dist/terminal/highlight/theme.d.ts +0 -37
  78. package/dist/terminal/highlight/theme.d.ts.map +1 -1
  79. package/dist/terminal/highlight/theme.js +1 -79
  80. package/dist/terminal/keys.d.ts +0 -97
  81. package/dist/terminal/keys.d.ts.map +1 -1
  82. package/dist/terminal/keys.js +0 -194
  83. package/dist/terminal/select-prompt.d.ts.map +1 -1
  84. package/dist/terminal/select-prompt.js +65 -51
  85. package/dist/terminal/style.d.ts +1 -1
  86. package/dist/terminal/style.d.ts.map +1 -1
  87. package/dist/terminal/supports-color.d.ts.map +1 -1
  88. package/dist/terminal/supports-color.js +38 -20
  89. package/dist/terminal/supports-hyperlinks.d.ts +3 -0
  90. package/dist/terminal/supports-hyperlinks.d.ts.map +1 -1
  91. package/dist/terminal/supports-hyperlinks.js +72 -31
  92. package/dist/terminal/table/layout-manager.d.ts +0 -20
  93. package/dist/terminal/table/layout-manager.d.ts.map +1 -1
  94. package/dist/terminal/table/layout-manager.js +68 -44
  95. package/dist/terminal/table/utils.d.ts +0 -1
  96. package/dist/terminal/table/utils.d.ts.map +1 -1
  97. package/dist/terminal/table/utils.js +2 -4
  98. package/dist/tools/apply-patch.d.ts +5 -3
  99. package/dist/tools/apply-patch.d.ts.map +1 -1
  100. package/dist/tools/apply-patch.js +154 -123
  101. package/dist/tools/bash.d.ts +4 -4
  102. package/dist/tools/bash.d.ts.map +1 -1
  103. package/dist/tools/bash.js +27 -13
  104. package/dist/tools/dynamic-tool-loader.d.ts +17 -3
  105. package/dist/tools/dynamic-tool-loader.d.ts.map +1 -1
  106. package/dist/tools/dynamic-tool-loader.js +360 -81
  107. package/dist/tools/edit-file.d.ts +2 -2
  108. package/dist/tools/index.d.ts +27 -151
  109. package/dist/tools/index.d.ts.map +1 -1
  110. package/dist/tools/index.js +16 -21
  111. package/dist/tools/read-file.d.ts +8 -8
  112. package/dist/tools/read-file.d.ts.map +1 -1
  113. package/dist/tools/read-file.js +32 -13
  114. package/dist/tools/save-file.d.ts +4 -4
  115. package/dist/tools/skill.d.ts +2 -1
  116. package/dist/tools/skill.d.ts.map +1 -1
  117. package/dist/tools/skill.js +64 -14
  118. package/dist/tools/types.d.ts +8 -2
  119. package/dist/tools/types.d.ts.map +1 -1
  120. package/dist/tools/web-fetch.d.ts +8 -12
  121. package/dist/tools/web-fetch.d.ts.map +1 -1
  122. package/dist/tools/web-fetch.js +86 -44
  123. package/dist/tools/web-search.d.ts +4 -8
  124. package/dist/tools/web-search.d.ts.map +1 -1
  125. package/dist/tools/web-search.js +41 -33
  126. package/dist/tui/autocomplete/utils.d.ts +0 -15
  127. package/dist/tui/autocomplete/utils.d.ts.map +1 -1
  128. package/dist/tui/autocomplete/utils.js +0 -85
  129. package/dist/tui/autocomplete.d.ts +1 -1
  130. package/dist/tui/autocomplete.d.ts.map +1 -1
  131. package/dist/tui/autocomplete.js +1 -1
  132. package/dist/tui/components/editor.d.ts +12 -0
  133. package/dist/tui/components/editor.d.ts.map +1 -1
  134. package/dist/tui/components/editor.js +181 -195
  135. package/dist/tui/components/footer.d.ts +0 -2
  136. package/dist/tui/components/footer.d.ts.map +1 -1
  137. package/dist/tui/components/footer.js +1 -17
  138. package/dist/tui/components/input.d.ts +4 -0
  139. package/dist/tui/components/input.d.ts.map +1 -1
  140. package/dist/tui/components/input.js +33 -31
  141. package/dist/tui/components/markdown.d.ts +30 -0
  142. package/dist/tui/components/markdown.d.ts.map +1 -1
  143. package/dist/tui/components/markdown.js +274 -242
  144. package/dist/tui/components/modal.d.ts.map +1 -1
  145. package/dist/tui/components/modal.js +11 -11
  146. package/dist/tui/components/select-list.d.ts +5 -0
  147. package/dist/tui/components/select-list.d.ts.map +1 -1
  148. package/dist/tui/components/select-list.js +69 -98
  149. package/dist/tui/components/table.d.ts +6 -0
  150. package/dist/tui/components/table.d.ts.map +1 -1
  151. package/dist/tui/components/table.js +61 -52
  152. package/dist/tui/index.d.ts +1 -8
  153. package/dist/tui/index.d.ts.map +1 -1
  154. package/dist/tui/index.js +0 -8
  155. package/dist/tui/tui.d.ts +9 -0
  156. package/dist/tui/tui.d.ts.map +1 -1
  157. package/dist/tui/tui.js +78 -48
  158. package/dist/tui/utils.d.ts +7 -0
  159. package/dist/tui/utils.d.ts.map +1 -1
  160. package/dist/tui/utils.js +117 -53
  161. package/dist/utils/bash.d.ts.map +1 -1
  162. package/dist/utils/bash.js +121 -104
  163. package/dist/utils/binary-output.d.ts +32 -0
  164. package/dist/utils/binary-output.d.ts.map +1 -0
  165. package/dist/utils/binary-output.js +127 -0
  166. package/dist/utils/command-protection.d.ts +3 -2
  167. package/dist/utils/command-protection.d.ts.map +1 -1
  168. package/dist/utils/command-protection.js +121 -29
  169. package/dist/utils/filesystem/operations.d.ts +0 -15
  170. package/dist/utils/filesystem/operations.d.ts.map +1 -1
  171. package/dist/utils/filesystem/operations.js +1 -38
  172. package/dist/utils/filesystem/security.d.ts.map +1 -1
  173. package/dist/utils/filesystem/security.js +22 -15
  174. package/dist/utils/filetype-detection.d.ts +0 -1
  175. package/dist/utils/filetype-detection.d.ts.map +1 -1
  176. package/dist/utils/filetype-detection.js +0 -12
  177. package/dist/utils/formatting.d.ts +0 -30
  178. package/dist/utils/formatting.d.ts.map +1 -1
  179. package/dist/utils/formatting.js +0 -44
  180. package/dist/utils/git.d.ts +4 -6
  181. package/dist/utils/git.d.ts.map +1 -1
  182. package/dist/utils/git.js +36 -46
  183. package/dist/utils/ignore.d.ts +1 -1
  184. package/dist/utils/ignore.d.ts.map +1 -1
  185. package/dist/utils/ignore.js +1 -1
  186. package/dist/utils/parsing.d.ts +1 -1
  187. package/dist/utils/parsing.d.ts.map +1 -1
  188. package/dist/utils/process.d.ts.map +1 -1
  189. package/dist/utils/process.js +77 -79
  190. package/dist/utils/yaml.d.ts +0 -1
  191. package/dist/utils/yaml.d.ts.map +1 -1
  192. package/dist/utils/yaml.js +80 -89
  193. package/dist/utils/zod.d.ts +0 -3
  194. package/dist/utils/zod.d.ts.map +1 -1
  195. package/dist/utils/zod.js +0 -7
  196. package/package.json +32 -29
  197. package/dist/agent/sub-agent.d.ts +0 -23
  198. package/dist/agent/sub-agent.d.ts.map +0 -1
  199. package/dist/agent/sub-agent.js +0 -109
  200. package/dist/commands/add-directory/index.d.ts +0 -3
  201. package/dist/commands/add-directory/index.d.ts.map +0 -1
  202. package/dist/commands/add-directory/index.js +0 -50
  203. package/dist/commands/add-directory/utils.d.ts +0 -3
  204. package/dist/commands/add-directory/utils.d.ts.map +0 -1
  205. package/dist/commands/add-directory/utils.js +0 -15
  206. package/dist/commands/clear/index.d.ts +0 -3
  207. package/dist/commands/clear/index.d.ts.map +0 -1
  208. package/dist/commands/clear/index.js +0 -13
  209. package/dist/commands/generate-rules/index.d.ts +0 -3
  210. package/dist/commands/generate-rules/index.d.ts.map +0 -1
  211. package/dist/commands/generate-rules/index.js +0 -206
  212. package/dist/commands/generate-rules/service.d.ts +0 -22
  213. package/dist/commands/generate-rules/service.d.ts.map +0 -1
  214. package/dist/commands/generate-rules/service.js +0 -103
  215. package/dist/commands/generate-rules/utils.d.ts +0 -5
  216. package/dist/commands/generate-rules/utils.d.ts.map +0 -1
  217. package/dist/commands/generate-rules/utils.js +0 -25
  218. package/dist/commands/handoff/index.d.ts +0 -3
  219. package/dist/commands/handoff/index.d.ts.map +0 -1
  220. package/dist/commands/handoff/index.js +0 -97
  221. package/dist/commands/handoff/utils.d.ts +0 -4
  222. package/dist/commands/handoff/utils.d.ts.map +0 -1
  223. package/dist/commands/handoff/utils.js +0 -123
  224. package/dist/commands/list-directories/index.d.ts +0 -3
  225. package/dist/commands/list-directories/index.d.ts.map +0 -1
  226. package/dist/commands/list-directories/index.js +0 -35
  227. package/dist/commands/pickup/index.d.ts +0 -3
  228. package/dist/commands/pickup/index.d.ts.map +0 -1
  229. package/dist/commands/pickup/index.js +0 -141
  230. package/dist/commands/pickup/types.d.ts +0 -6
  231. package/dist/commands/pickup/types.d.ts.map +0 -1
  232. package/dist/commands/pickup/types.js +0 -1
  233. package/dist/commands/pickup/utils.d.ts +0 -7
  234. package/dist/commands/pickup/utils.d.ts.map +0 -1
  235. package/dist/commands/pickup/utils.js +0 -56
  236. package/dist/commands/remove-directory/index.d.ts +0 -3
  237. package/dist/commands/remove-directory/index.d.ts.map +0 -1
  238. package/dist/commands/remove-directory/index.js +0 -55
  239. package/dist/commands/review/index.d.ts +0 -3
  240. package/dist/commands/review/index.d.ts.map +0 -1
  241. package/dist/commands/review/index.js +0 -12
  242. package/dist/commands/review/review-panel.d.ts +0 -3
  243. package/dist/commands/review/review-panel.d.ts.map +0 -1
  244. package/dist/commands/review/review-panel.js +0 -186
  245. package/dist/commands/review/utils.d.ts +0 -18
  246. package/dist/commands/review/utils.d.ts.map +0 -1
  247. package/dist/commands/review/utils.js +0 -146
  248. package/dist/commands/shell/index.d.ts +0 -3
  249. package/dist/commands/shell/index.d.ts.map +0 -1
  250. package/dist/commands/shell/index.js +0 -96
  251. package/dist/modes/manager.d.ts +0 -24
  252. package/dist/modes/manager.d.ts.map +0 -1
  253. package/dist/modes/manager.js +0 -77
  254. package/dist/modes/prompts.d.ts +0 -2
  255. package/dist/modes/prompts.d.ts.map +0 -1
  256. package/dist/modes/prompts.js +0 -142
  257. package/dist/subagents/index.d.ts +0 -16
  258. package/dist/subagents/index.d.ts.map +0 -1
  259. package/dist/subagents/index.js +0 -231
  260. package/dist/terminal/index.d.ts +0 -9
  261. package/dist/terminal/index.d.ts.map +0 -1
  262. package/dist/terminal/index.js +0 -8
  263. package/dist/tools/agent.d.ts +0 -27
  264. package/dist/tools/agent.d.ts.map +0 -1
  265. package/dist/tools/agent.js +0 -81
  266. package/dist/tools/directory-tree.d.ts +0 -28
  267. package/dist/tools/directory-tree.d.ts.map +0 -1
  268. package/dist/tools/directory-tree.js +0 -152
  269. package/dist/tools/glob.d.ts +0 -35
  270. package/dist/tools/glob.d.ts.map +0 -1
  271. package/dist/tools/glob.js +0 -159
  272. package/dist/tools/grep.d.ts +0 -100
  273. package/dist/tools/grep.d.ts.map +0 -1
  274. package/dist/tools/grep.js +0 -601
  275. package/dist/tools/ls.d.ts +0 -26
  276. package/dist/tools/ls.d.ts.map +0 -1
  277. package/dist/tools/ls.js +0 -82
  278. package/dist/tui/components/header.d.ts +0 -21
  279. package/dist/tui/components/header.d.ts.map +0 -1
  280. package/dist/tui/components/header.js +0 -63
  281. package/dist/utils/bash/parse.d.ts +0 -19
  282. package/dist/utils/bash/parse.d.ts.map +0 -1
  283. package/dist/utils/bash/parse.js +0 -223
  284. package/dist/utils/bash/quote.d.ts +0 -6
  285. package/dist/utils/bash/quote.d.ts.map +0 -1
  286. package/dist/utils/bash/quote.js +0 -23
  287. package/dist/utils/generators.d.ts +0 -3
  288. package/dist/utils/generators.d.ts.map +0 -1
  289. package/dist/utils/generators.js +0 -25
  290. package/dist/utils/glob.d.ts +0 -52
  291. package/dist/utils/glob.d.ts.map +0 -1
  292. package/dist/utils/glob.js +0 -376
@@ -1,152 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- import { z } from "zod";
4
- import style from "../terminal/style.js";
5
- import { toDisplayPath } from "../utils/filesystem/path-display.js";
6
- import { joinWorkingDir, validatePath } from "../utils/filesystem/security.js";
7
- import ignore from "../utils/ignore.js";
8
- import { convertNullString } from "../utils/zod.js";
9
- const DEFAULT_ITEM_LIMIT = 500;
10
- const DEFAULT_DEPTH_LIMIT = 10;
11
- export const DirectoryTreeTool = {
12
- name: "DirectoryTree",
13
- };
14
- const inputSchema = z.object({
15
- path: z.string().describe("The path"),
16
- maxResults: z
17
- .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
18
- .describe(`Maximum number of items (files + directories) to return. Set to 0 for no limit. (default: ${DEFAULT_ITEM_LIMIT})`),
19
- maxDepth: z
20
- .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
21
- .describe(`Maximum recursion depth. Set to 0 for no limit. (default: ${DEFAULT_DEPTH_LIMIT})`),
22
- });
23
- export const createDirectoryTreeTool = async (options) => {
24
- const { primaryDir, allowedDirs } = options.workspace;
25
- const allowedDirectory = allowedDirs ?? [primaryDir];
26
- return {
27
- toolDef: {
28
- description: "Show directory structure as a recursive tree. Use this to explore nested directories and understand the overall project structure. For a simple flat list of a single directory, use LS instead.",
29
- inputSchema,
30
- },
31
- display({ path, maxDepth, maxResults }) {
32
- const displayPath = toDisplayPath(path);
33
- let display = `${style.cyan(displayPath)}`;
34
- if (maxDepth || maxResults) {
35
- const parts = [];
36
- if (maxDepth)
37
- parts.push(`depth: ${maxDepth}`);
38
- if (maxResults)
39
- parts.push(`max: ${maxResults}`);
40
- display += ` (${parts.join(", ")})`;
41
- }
42
- return display;
43
- },
44
- async execute({ path, maxResults, maxDepth }, { abortSignal }) {
45
- if (abortSignal?.aborted) {
46
- throw new Error("Directory tree listing aborted");
47
- }
48
- const validPath = await validatePath(joinWorkingDir(path, primaryDir), allowedDirectory, { abortSignal });
49
- if (abortSignal?.aborted) {
50
- throw new Error("Directory tree listing aborted before tree generation");
51
- }
52
- const treeResult = await directoryTree(validPath, {
53
- maxResults: maxResults ?? DEFAULT_ITEM_LIMIT,
54
- maxDepth: maxDepth ?? DEFAULT_DEPTH_LIMIT,
55
- });
56
- return treeResult.tree;
57
- },
58
- };
59
- };
60
- /**
61
- * Generates the indentation string for a given level in the directory tree.
62
- * @param level - The current level in the directory tree.
63
- * @param isLast - Indicates if the current item is the last in its parent directory.
64
- * @returns The indentation string for the current level.
65
- */
66
- function getIndent(level, isLast) {
67
- const indent = "│ ".repeat(Math.max(level - 1, 0));
68
- return level === 0 ? "" : `${indent}${isLast ? "└── " : "├── "}`;
69
- }
70
- /**
71
- * Recursively generates a string representation of a directory tree.
72
- * @param dirPath - The path of the directory to generate the tree for.
73
- * @param ig - The ignore instance for filtering files.
74
- * @param level - The current level in the directory tree (default: 0).
75
- * @param options - Options for limiting results.
76
- * @returns A Promise that resolves to a string representation of the directory tree with counts.
77
- * @throws Will log an error if there's an issue reading the directory.
78
- */
79
- async function generateDirectoryTree(dirPath, ig, level = 0, options = {}) {
80
- const name = path.basename(dirPath);
81
- let output = `${getIndent(level, false)}${name}\n`;
82
- let fileCount = 0;
83
- let directoryCount = 1; // Count the current directory
84
- let totalCount = 1; // Count the current directory
85
- let isTruncated = false;
86
- // Check maxDepth limit - when maxDepth is reached, we should indicate truncation
87
- if (options.maxDepth !== null &&
88
- options.maxDepth !== undefined &&
89
- options.maxDepth > 0 &&
90
- level >= options.maxDepth) {
91
- // When maxDepth is reached, return with truncation flag set
92
- return {
93
- tree: output,
94
- fileCount: 0,
95
- directoryCount: 1, // Count the current directory
96
- totalCount: 1, // Count the current directory
97
- isTruncated: true, // Set truncation flag when depth limit is reached
98
- };
99
- }
100
- const items = await fs.readdir(dirPath);
101
- const filteredItems = ig.filter(items);
102
- for (let i = 0; i < filteredItems.length; i++) {
103
- // Check maxResults limit BEFORE processing each item to ensure strict adherence to limits
104
- if (options.maxResults !== null &&
105
- options.maxResults !== undefined &&
106
- options.maxResults > 0 &&
107
- totalCount >= options.maxResults) {
108
- isTruncated = true;
109
- break;
110
- }
111
- const item = filteredItems[i] ?? "";
112
- const itemPath = path.join(dirPath, item);
113
- const isLast = i === filteredItems.length - 1;
114
- const stats = await fs.stat(itemPath);
115
- if (stats.isDirectory()) {
116
- const subTreeResult = await generateDirectoryTree(itemPath, ig, level + 1, options);
117
- output += subTreeResult.tree;
118
- fileCount += subTreeResult.fileCount;
119
- directoryCount += subTreeResult.directoryCount;
120
- totalCount += subTreeResult.totalCount;
121
- // Propagate truncation from subtree results
122
- if (subTreeResult.isTruncated) {
123
- isTruncated = true;
124
- }
125
- }
126
- else {
127
- output += `${getIndent(level + 1, isLast)}${item}\n`;
128
- fileCount += 1;
129
- totalCount += 1;
130
- }
131
- }
132
- return { tree: output, fileCount, directoryCount, totalCount, isTruncated };
133
- }
134
- async function directoryTree(dirPath, options = {}) {
135
- let ig;
136
- try {
137
- const ignoreFile = await fs.readFile(path.join(process.cwd(), ".gitignore"));
138
- ig = ignore().add(ignoreFile.toString()).add(".git");
139
- }
140
- catch (_error) {
141
- // If .gitignore doesn't exist, create basic ignore with just .git
142
- ig = ignore().add(".git");
143
- }
144
- const result = await generateDirectoryTree(dirPath, ig, 0, options);
145
- return {
146
- tree: result.tree.trim(),
147
- fileCount: result.fileCount,
148
- directoryCount: result.directoryCount,
149
- totalCount: result.totalCount,
150
- isTruncated: result.isTruncated,
151
- };
152
- }
@@ -1,35 +0,0 @@
1
- import { z } from "zod";
2
- import type { ToolExecutionOptions } from "./types.ts";
3
- export declare const GlobTool: {
4
- name: "Glob";
5
- };
6
- export declare const inputSchema: z.ZodObject<{
7
- patterns: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
8
- path: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodString>;
9
- gitignore: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
10
- recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
11
- expandDirectories: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
12
- ignoreFiles: z.ZodPipe<z.ZodTransform<{} | null | undefined, unknown>, z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
13
- cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
14
- maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
15
- }, z.core.$strip>;
16
- type GlobInputSchema = z.infer<typeof inputSchema>;
17
- export declare const createGlobTool: () => {
18
- toolDef: {
19
- description: string;
20
- inputSchema: z.ZodObject<{
21
- patterns: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
22
- path: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodString>;
23
- gitignore: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
24
- recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
25
- expandDirectories: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
26
- ignoreFiles: z.ZodPipe<z.ZodTransform<{} | null | undefined, unknown>, z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
27
- cwd: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
28
- maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
29
- }, z.core.$strip>;
30
- };
31
- display({ patterns, path }: GlobInputSchema): string;
32
- execute({ patterns, path, gitignore, recursive, expandDirectories, ignoreFiles, cwd, maxResults, }: GlobInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
33
- };
34
- export {};
35
- //# sourceMappingURL=glob.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../source/tools/glob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA6EvD,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;iBA0EtB,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;gCAMK,eAAe;wGAmBtC,eAAe,mBACD,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;CAuCrB,CAAC"}
@@ -1,159 +0,0 @@
1
- import * as fs from "node:fs";
2
- import * as nodePath from "node:path";
3
- import { z } from "zod";
4
- import style from "../terminal/style.js";
5
- import { toDisplayPath } from "../utils/filesystem/path-display.js";
6
- import { glob } from "../utils/glob.js";
7
- import { convertNullString } from "../utils/zod.js";
8
- const DEFAULT_MAX_RESULTS = 100;
9
- const MAX_STAT_FILES = 1000;
10
- async function getFileWithStats(filePath, effectivePath) {
11
- const fullPath = nodePath.join(effectivePath, filePath);
12
- try {
13
- const stats = await fs.promises.stat(fullPath);
14
- return {
15
- path: filePath,
16
- mtime: stats.mtime.getTime(),
17
- };
18
- }
19
- catch {
20
- return {
21
- path: filePath,
22
- mtime: 0,
23
- };
24
- }
25
- }
26
- function sortFilesByMtime(files) {
27
- return files
28
- .sort((a, b) => {
29
- if (b.mtime !== a.mtime) {
30
- return b.mtime - a.mtime;
31
- }
32
- return a.path.localeCompare(b.path);
33
- })
34
- .map((file) => file.path);
35
- }
36
- function formatResult(sortedFiles) {
37
- return sortedFiles.length > 0
38
- ? sortedFiles.join("\n")
39
- : "No files found matching the specified patterns.";
40
- }
41
- function normalizePatternArray(patterns) {
42
- return Array.isArray(patterns) ? patterns : [patterns];
43
- }
44
- function buildGlobOptions(effectivePath, gitignore, recursive, expandDirectories, ignoreFiles, cwd) {
45
- return {
46
- cwd: cwd || effectivePath,
47
- ...(gitignore !== null && { gitignore }),
48
- ...(recursive !== null && { recursive }),
49
- ...(expandDirectories !== null && { expandDirectories }),
50
- ...(ignoreFiles !== null && { ignoreFiles }),
51
- };
52
- }
53
- function limitResults(sortedFiles, effectiveMaxResults) {
54
- if (effectiveMaxResults > 0 && sortedFiles.length > effectiveMaxResults) {
55
- return sortedFiles.slice(0, effectiveMaxResults);
56
- }
57
- return sortedFiles;
58
- }
59
- export const GlobTool = {
60
- name: "Glob",
61
- };
62
- export const inputSchema = z.object({
63
- patterns: z
64
- .preprocess((val) => {
65
- if (val === null || val === undefined) {
66
- return "**/*";
67
- }
68
- if (typeof val === "string") {
69
- const trimmed = val.trim();
70
- if (trimmed.startsWith("[")) {
71
- try {
72
- const parsed = JSON.parse(trimmed);
73
- if (Array.isArray(parsed)) {
74
- return parsed;
75
- }
76
- }
77
- catch {
78
- // Not valid JSON, treat as a plain glob string
79
- }
80
- }
81
- }
82
- return val;
83
- }, z.union([z.string(), z.array(z.string())]))
84
- .describe("Glob patterns to search for (e.g., '*.ts', '**/*.test.ts', 'src/**/*.js')"),
85
- path: z
86
- .preprocess((val) => (val === null || val === undefined ? process.cwd() : val), z.string())
87
- .describe("Base directory to search in"),
88
- gitignore: z
89
- .preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
90
- .describe("Respect ignore patterns in .gitignore files. (default: true)"),
91
- recursive: z
92
- .preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
93
- .describe("Search recursively. (default: true)"),
94
- expandDirectories: z
95
- .preprocess((val) => convertNullString(val), z.coerce.boolean().nullable())
96
- .describe("Automatically expand directories to files. (default: true)"),
97
- ignoreFiles: z
98
- .preprocess((val) => {
99
- const converted = convertNullString(val);
100
- if (converted === null) {
101
- return null;
102
- }
103
- if (typeof converted === "string") {
104
- const trimmed = converted.trim();
105
- if (trimmed.startsWith("[")) {
106
- try {
107
- const parsed = JSON.parse(trimmed);
108
- if (Array.isArray(parsed)) {
109
- return parsed;
110
- }
111
- }
112
- catch {
113
- // Not valid JSON, treat as a plain string
114
- }
115
- }
116
- }
117
- return converted;
118
- }, z.union([z.string(), z.array(z.string())]).nullable())
119
- .describe("Glob patterns to look for ignore files (e.g., '.gitignore'). Pass null to use default behavior."),
120
- cwd: z
121
- .preprocess((val) => convertNullString(val), z.coerce.string().nullable())
122
- .describe("Current working directory override. (default: process.cwd())"),
123
- maxResults: z
124
- .preprocess((val) => convertNullString(val), z.coerce.number().nullable())
125
- .describe("Maximum number of files to return. Set to 0 for no limit. (Default: 100)"),
126
- });
127
- export const createGlobTool = () => {
128
- return {
129
- toolDef: {
130
- description: "Find files by name pattern (e.g., *.ts).",
131
- inputSchema,
132
- },
133
- display({ patterns, path }) {
134
- const patternArray = Array.isArray(patterns) ? patterns : [patterns];
135
- const patternStr = patternArray.length === 1
136
- ? patternArray[0]
137
- : JSON.stringify(patternArray);
138
- const displayPath = toDisplayPath(path);
139
- return `${style.cyan(patternStr)} in ${style.cyan(displayPath)}`;
140
- },
141
- async execute({ patterns, path, gitignore, recursive, expandDirectories, ignoreFiles, cwd, maxResults, }, { abortSignal }) {
142
- if (abortSignal?.aborted) {
143
- throw new Error("Glob search aborted");
144
- }
145
- const effectivePath = typeof path === "string" && path.trim() !== "" ? path : process.cwd();
146
- const patternArray = normalizePatternArray(patterns);
147
- const effectiveMaxResults = maxResults ?? DEFAULT_MAX_RESULTS;
148
- const globOptions = buildGlobOptions(effectivePath, gitignore, recursive, expandDirectories, ignoreFiles, cwd);
149
- const matchingFiles = await glob(patternArray, globOptions);
150
- const filesToStat = matchingFiles.length > MAX_STAT_FILES
151
- ? matchingFiles.slice(0, MAX_STAT_FILES)
152
- : matchingFiles;
153
- const filesWithStats = await Promise.all(filesToStat.map((filePath) => getFileWithStats(filePath, effectivePath)));
154
- const sortedFiles = sortFilesByMtime(filesWithStats);
155
- const result = limitResults(sortedFiles, effectiveMaxResults);
156
- return formatResult(result);
157
- },
158
- };
159
- };
@@ -1,100 +0,0 @@
1
- import { z } from "zod";
2
- import type { ToolExecutionOptions } from "./types.ts";
3
- export declare const GrepTool: {
4
- name: "Grep";
5
- };
6
- declare const inputSchema: z.ZodObject<{
7
- pattern: z.ZodString;
8
- path: z.ZodString;
9
- recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
10
- ignoreCase: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
11
- filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
12
- contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
13
- searchIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
14
- literal: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
15
- maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
16
- }, z.core.$strip>;
17
- type GrepInputSchema = z.infer<typeof inputSchema>;
18
- export declare const createGrepTool: () => {
19
- toolDef: {
20
- description: string;
21
- inputSchema: z.ZodObject<{
22
- pattern: z.ZodString;
23
- path: z.ZodString;
24
- recursive: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
25
- ignoreCase: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
26
- filePattern: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedString<unknown>>>;
27
- contextLines: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
28
- searchIgnored: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
29
- literal: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedBoolean<unknown>>>;
30
- maxResults: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodNullable<z.ZodCoercedNumber<unknown>>>;
31
- }, z.core.$strip>;
32
- };
33
- display({ pattern, path, filePattern, recursive, ignoreCase, contextLines, }: GrepInputSchema): string;
34
- execute({ pattern, path, recursive, ignoreCase, filePattern, contextLines, searchIgnored, literal, maxResults, }: GrepInputSchema, { abortSignal }: ToolExecutionOptions): Promise<string>;
35
- };
36
- interface GrepOptions {
37
- recursive?: boolean | null;
38
- ignoreCase?: boolean | null;
39
- filePattern?: string | null;
40
- contextLines?: number | null;
41
- searchIgnored?: boolean | null;
42
- literal?: boolean | null;
43
- maxResults?: number | null;
44
- likelyUnbalanced?: boolean;
45
- }
46
- export declare function likelyUnbalancedRegex(pattern: string): boolean;
47
- /**
48
- * Build grep command args array directly
49
- *
50
- * @param pattern - The regex pattern to search for
51
- * @param path - The path to search in
52
- * @param options - Additional options for the grep command
53
- * @returns The args array for the grep command
54
- */
55
- export declare function buildGrepArgs(pattern: string, path: string, options?: GrepOptions): string[];
56
- export interface ParsedMatch {
57
- file?: string;
58
- line: number;
59
- content: string;
60
- isMatch: boolean;
61
- isContext?: boolean;
62
- lineNumber?: number;
63
- absolutePath?: string;
64
- submatches?: Array<{
65
- start: number;
66
- end: number;
67
- text: string;
68
- }>;
69
- }
70
- interface GrepResult {
71
- rawOutput: string;
72
- parsedMatches: ParsedMatch[];
73
- matchCount: number;
74
- displayedCount?: number;
75
- contextCount: number;
76
- hasMatches: boolean;
77
- isTruncated?: boolean;
78
- }
79
- /**
80
- * Parse ripgrep JSON output and extract structured match information
81
- */
82
- export declare function parseRipgrepJsonOutput(content: string): ParsedMatch[];
83
- /**
84
- * Count actual matches (excluding context lines)
85
- */
86
- export declare function countActualMatches(parsed: ParsedMatch[]): number;
87
- /**
88
- * Count context lines
89
- */
90
- export declare function countContextLines(parsed: ParsedMatch[]): number;
91
- /**
92
- * Truncate matches to a maximum number of results, preserving context lines for kept matches
93
- */
94
- export declare function truncateMatches(matches: ParsedMatch[], maxResults: number | null | undefined): {
95
- truncated: ParsedMatch[];
96
- isTruncated: boolean;
97
- };
98
- export declare function grepFilesStructured(pattern: string, path: string, options?: GrepOptions, abortSignal?: AbortSignal | null): Promise<GrepResult>;
99
- export {};
100
- //# sourceMappingURL=grep.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../source/tools/grep.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAKvD,eAAO,MAAM,QAAQ;;CAEpB,CAAC;AAEF,QAAA,MAAM,WAAW;;;;;;;;;;iBAoCf,CAAC;AAEH,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEnD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;kFAapB,eAAe;sHAoCb,eAAe,mBACD,oBAAoB,GACpC,OAAO,CAAC,MAAM,CAAC;CAkErB,CAAC;AAEF,UAAU,WAAW;IACnB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAuMD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CA8B9D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,GACxB,MAAM,EAAE,CAgEV;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,KAAK,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;AAED,UAAU,UAAU;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,WAAW,EAAE,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,EAAE,CAqDrE;AA8BD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAEhE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAE/D;AAyBD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,WAAW,EAAE,EACtB,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACpC;IAAE,SAAS,EAAE,WAAW,EAAE,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAoDpD;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,WAAgB,EACzB,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,GAC/B,OAAO,CAAC,UAAU,CAAC,CAgGrB"}