@kenkaiiii/ggcoder 0.0.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 (263) hide show
  1. package/dist/cli.d.ts +3 -0
  2. package/dist/cli.d.ts.map +1 -0
  3. package/dist/cli.js +220 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/config.d.ts +13 -0
  6. package/dist/config.d.ts.map +1 -0
  7. package/dist/config.js +25 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/core/agent-session.d.ts +63 -0
  10. package/dist/core/agent-session.d.ts.map +1 -0
  11. package/dist/core/agent-session.js +269 -0
  12. package/dist/core/agent-session.js.map +1 -0
  13. package/dist/core/auth-storage.d.ts +29 -0
  14. package/dist/core/auth-storage.d.ts.map +1 -0
  15. package/dist/core/auth-storage.js +89 -0
  16. package/dist/core/auth-storage.js.map +1 -0
  17. package/dist/core/compaction/compactor.d.ts +26 -0
  18. package/dist/core/compaction/compactor.d.ts.map +1 -0
  19. package/dist/core/compaction/compactor.js +87 -0
  20. package/dist/core/compaction/compactor.js.map +1 -0
  21. package/dist/core/compaction/token-estimator.d.ts +5 -0
  22. package/dist/core/compaction/token-estimator.d.ts.map +1 -0
  23. package/dist/core/compaction/token-estimator.js +36 -0
  24. package/dist/core/compaction/token-estimator.js.map +1 -0
  25. package/dist/core/event-bus.d.ts +71 -0
  26. package/dist/core/event-bus.d.ts.map +1 -0
  27. package/dist/core/event-bus.js +72 -0
  28. package/dist/core/event-bus.js.map +1 -0
  29. package/dist/core/extensions/loader.d.ts +8 -0
  30. package/dist/core/extensions/loader.d.ts.map +1 -0
  31. package/dist/core/extensions/loader.js +48 -0
  32. package/dist/core/extensions/loader.js.map +1 -0
  33. package/dist/core/extensions/types.d.ts +19 -0
  34. package/dist/core/extensions/types.d.ts.map +1 -0
  35. package/dist/core/extensions/types.js +2 -0
  36. package/dist/core/extensions/types.js.map +1 -0
  37. package/dist/core/index.d.ts +13 -0
  38. package/dist/core/index.d.ts.map +1 -0
  39. package/dist/core/index.js +12 -0
  40. package/dist/core/index.js.map +1 -0
  41. package/dist/core/model-registry.d.ts +17 -0
  42. package/dist/core/model-registry.d.ts.map +1 -0
  43. package/dist/core/model-registry.js +86 -0
  44. package/dist/core/model-registry.js.map +1 -0
  45. package/dist/core/oauth/anthropic.d.ts +4 -0
  46. package/dist/core/oauth/anthropic.d.ts.map +1 -0
  47. package/dist/core/oauth/anthropic.js +73 -0
  48. package/dist/core/oauth/anthropic.js.map +1 -0
  49. package/dist/core/oauth/openai.d.ts +4 -0
  50. package/dist/core/oauth/openai.d.ts.map +1 -0
  51. package/dist/core/oauth/openai.js +186 -0
  52. package/dist/core/oauth/openai.js.map +1 -0
  53. package/dist/core/oauth/pkce.d.ts +5 -0
  54. package/dist/core/oauth/pkce.d.ts.map +1 -0
  55. package/dist/core/oauth/pkce.js +17 -0
  56. package/dist/core/oauth/pkce.js.map +1 -0
  57. package/dist/core/oauth/types.d.ts +12 -0
  58. package/dist/core/oauth/types.d.ts.map +1 -0
  59. package/dist/core/oauth/types.js +2 -0
  60. package/dist/core/oauth/types.js.map +1 -0
  61. package/dist/core/session-manager.d.ts +74 -0
  62. package/dist/core/session-manager.d.ts.map +1 -0
  63. package/dist/core/session-manager.js +166 -0
  64. package/dist/core/session-manager.js.map +1 -0
  65. package/dist/core/settings-manager.d.ts +38 -0
  66. package/dist/core/settings-manager.d.ts.map +1 -0
  67. package/dist/core/settings-manager.js +62 -0
  68. package/dist/core/settings-manager.js.map +1 -0
  69. package/dist/core/skills.d.ts +23 -0
  70. package/dist/core/skills.d.ts.map +1 -0
  71. package/dist/core/skills.js +89 -0
  72. package/dist/core/skills.js.map +1 -0
  73. package/dist/core/slash-commands.d.ts +31 -0
  74. package/dist/core/slash-commands.d.ts.map +1 -0
  75. package/dist/core/slash-commands.js +161 -0
  76. package/dist/core/slash-commands.js.map +1 -0
  77. package/dist/index.d.ts +11 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +17 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/interactive.d.ts +3 -0
  82. package/dist/interactive.d.ts.map +1 -0
  83. package/dist/interactive.js +153 -0
  84. package/dist/interactive.js.map +1 -0
  85. package/dist/modes/index.d.ts +2 -0
  86. package/dist/modes/index.d.ts.map +1 -0
  87. package/dist/modes/index.js +2 -0
  88. package/dist/modes/index.js.map +1 -0
  89. package/dist/modes/print-mode.d.ts +12 -0
  90. package/dist/modes/print-mode.d.ts.map +1 -0
  91. package/dist/modes/print-mode.js +42 -0
  92. package/dist/modes/print-mode.js.map +1 -0
  93. package/dist/session.d.ts +16 -0
  94. package/dist/session.d.ts.map +1 -0
  95. package/dist/session.js +122 -0
  96. package/dist/session.js.map +1 -0
  97. package/dist/system-prompt.d.ts +6 -0
  98. package/dist/system-prompt.d.ts.map +1 -0
  99. package/dist/system-prompt.js +70 -0
  100. package/dist/system-prompt.js.map +1 -0
  101. package/dist/tools/bash.d.ts +9 -0
  102. package/dist/tools/bash.d.ts.map +1 -0
  103. package/dist/tools/bash.js +81 -0
  104. package/dist/tools/bash.js.map +1 -0
  105. package/dist/tools/edit-diff.d.ts +18 -0
  106. package/dist/tools/edit-diff.d.ts.map +1 -0
  107. package/dist/tools/edit-diff.js +92 -0
  108. package/dist/tools/edit-diff.js.map +1 -0
  109. package/dist/tools/edit.d.ts +10 -0
  110. package/dist/tools/edit.d.ts.map +1 -0
  111. package/dist/tools/edit.js +53 -0
  112. package/dist/tools/edit.js.map +1 -0
  113. package/dist/tools/find.d.ts +9 -0
  114. package/dist/tools/find.d.ts.map +1 -0
  115. package/dist/tools/find.js +59 -0
  116. package/dist/tools/find.js.map +1 -0
  117. package/dist/tools/grep.d.ts +12 -0
  118. package/dist/tools/grep.d.ts.map +1 -0
  119. package/dist/tools/grep.js +107 -0
  120. package/dist/tools/grep.js.map +1 -0
  121. package/dist/tools/index.d.ts +10 -0
  122. package/dist/tools/index.d.ts.map +1 -0
  123. package/dist/tools/index.js +26 -0
  124. package/dist/tools/index.js.map +1 -0
  125. package/dist/tools/ls.d.ts +9 -0
  126. package/dist/tools/ls.d.ts.map +1 -0
  127. package/dist/tools/ls.js +56 -0
  128. package/dist/tools/ls.js.map +1 -0
  129. package/dist/tools/path-utils.d.ts +2 -0
  130. package/dist/tools/path-utils.d.ts.map +1 -0
  131. package/dist/tools/path-utils.js +9 -0
  132. package/dist/tools/path-utils.js.map +1 -0
  133. package/dist/tools/read.d.ts +11 -0
  134. package/dist/tools/read.d.ts.map +1 -0
  135. package/dist/tools/read.js +98 -0
  136. package/dist/tools/read.js.map +1 -0
  137. package/dist/tools/truncate.d.ts +19 -0
  138. package/dist/tools/truncate.d.ts.map +1 -0
  139. package/dist/tools/truncate.js +59 -0
  140. package/dist/tools/truncate.js.map +1 -0
  141. package/dist/tools/write.d.ts +9 -0
  142. package/dist/tools/write.d.ts.map +1 -0
  143. package/dist/tools/write.js +23 -0
  144. package/dist/tools/write.js.map +1 -0
  145. package/dist/types.d.ts +36 -0
  146. package/dist/types.d.ts.map +1 -0
  147. package/dist/types.js +2 -0
  148. package/dist/types.js.map +1 -0
  149. package/dist/ui/App.d.ts +19 -0
  150. package/dist/ui/App.d.ts.map +1 -0
  151. package/dist/ui/App.js +209 -0
  152. package/dist/ui/App.js.map +1 -0
  153. package/dist/ui/components/AssistantMessage.d.ts +8 -0
  154. package/dist/ui/components/AssistantMessage.d.ts.map +1 -0
  155. package/dist/ui/components/AssistantMessage.js +10 -0
  156. package/dist/ui/components/AssistantMessage.js.map +1 -0
  157. package/dist/ui/components/DiffView.d.ts +4 -0
  158. package/dist/ui/components/DiffView.d.ts.map +1 -0
  159. package/dist/ui/components/DiffView.js +20 -0
  160. package/dist/ui/components/DiffView.js.map +1 -0
  161. package/dist/ui/components/Footer.d.ts +9 -0
  162. package/dist/ui/components/Footer.d.ts.map +1 -0
  163. package/dist/ui/components/Footer.js +79 -0
  164. package/dist/ui/components/Footer.js.map +1 -0
  165. package/dist/ui/components/InputArea.d.ts +8 -0
  166. package/dist/ui/components/InputArea.d.ts.map +1 -0
  167. package/dist/ui/components/InputArea.js +143 -0
  168. package/dist/ui/components/InputArea.js.map +1 -0
  169. package/dist/ui/components/Markdown.d.ts +7 -0
  170. package/dist/ui/components/Markdown.d.ts.map +1 -0
  171. package/dist/ui/components/Markdown.js +215 -0
  172. package/dist/ui/components/Markdown.js.map +1 -0
  173. package/dist/ui/components/ModelSelector.d.ts +7 -0
  174. package/dist/ui/components/ModelSelector.d.ts.map +1 -0
  175. package/dist/ui/components/ModelSelector.js +14 -0
  176. package/dist/ui/components/ModelSelector.js.map +1 -0
  177. package/dist/ui/components/Overlay.d.ts +8 -0
  178. package/dist/ui/components/Overlay.d.ts.map +1 -0
  179. package/dist/ui/components/Overlay.js +9 -0
  180. package/dist/ui/components/Overlay.js.map +1 -0
  181. package/dist/ui/components/SelectList.d.ts +13 -0
  182. package/dist/ui/components/SelectList.d.ts.map +1 -0
  183. package/dist/ui/components/SelectList.js +46 -0
  184. package/dist/ui/components/SelectList.js.map +1 -0
  185. package/dist/ui/components/SessionSelector.d.ts +9 -0
  186. package/dist/ui/components/SessionSelector.d.ts.map +1 -0
  187. package/dist/ui/components/SessionSelector.js +13 -0
  188. package/dist/ui/components/SessionSelector.js.map +1 -0
  189. package/dist/ui/components/SettingsSelector.d.ts +9 -0
  190. package/dist/ui/components/SettingsSelector.d.ts.map +1 -0
  191. package/dist/ui/components/SettingsSelector.js +13 -0
  192. package/dist/ui/components/SettingsSelector.js.map +1 -0
  193. package/dist/ui/components/Spinner.d.ts +4 -0
  194. package/dist/ui/components/Spinner.d.ts.map +1 -0
  195. package/dist/ui/components/Spinner.js +17 -0
  196. package/dist/ui/components/Spinner.js.map +1 -0
  197. package/dist/ui/components/StreamingArea.d.ts +12 -0
  198. package/dist/ui/components/StreamingArea.d.ts.map +1 -0
  199. package/dist/ui/components/StreamingArea.js +47 -0
  200. package/dist/ui/components/StreamingArea.js.map +1 -0
  201. package/dist/ui/components/ThinkingIndicator.d.ts +6 -0
  202. package/dist/ui/components/ThinkingIndicator.d.ts.map +1 -0
  203. package/dist/ui/components/ThinkingIndicator.js +171 -0
  204. package/dist/ui/components/ThinkingIndicator.js.map +1 -0
  205. package/dist/ui/components/ToolExecution.d.ts +16 -0
  206. package/dist/ui/components/ToolExecution.d.ts.map +1 -0
  207. package/dist/ui/components/ToolExecution.js +262 -0
  208. package/dist/ui/components/ToolExecution.js.map +1 -0
  209. package/dist/ui/components/UserMessage.d.ts +4 -0
  210. package/dist/ui/components/UserMessage.d.ts.map +1 -0
  211. package/dist/ui/components/UserMessage.js +9 -0
  212. package/dist/ui/components/UserMessage.js.map +1 -0
  213. package/dist/ui/components/index.d.ts +14 -0
  214. package/dist/ui/components/index.d.ts.map +1 -0
  215. package/dist/ui/components/index.js +14 -0
  216. package/dist/ui/components/index.js.map +1 -0
  217. package/dist/ui/hooks/useAgentLoop.d.ts +40 -0
  218. package/dist/ui/hooks/useAgentLoop.d.ts.map +1 -0
  219. package/dist/ui/hooks/useAgentLoop.js +195 -0
  220. package/dist/ui/hooks/useAgentLoop.js.map +1 -0
  221. package/dist/ui/hooks/useSessionManager.d.ts +13 -0
  222. package/dist/ui/hooks/useSessionManager.d.ts.map +1 -0
  223. package/dist/ui/hooks/useSessionManager.js +43 -0
  224. package/dist/ui/hooks/useSessionManager.js.map +1 -0
  225. package/dist/ui/hooks/useSlashCommands.d.ts +7 -0
  226. package/dist/ui/hooks/useSlashCommands.d.ts.map +1 -0
  227. package/dist/ui/hooks/useSlashCommands.js +11 -0
  228. package/dist/ui/hooks/useSlashCommands.js.map +1 -0
  229. package/dist/ui/render.d.ts +20 -0
  230. package/dist/ui/render.d.ts.map +1 -0
  231. package/dist/ui/render.js +24 -0
  232. package/dist/ui/render.js.map +1 -0
  233. package/dist/ui/theme/dark.json +23 -0
  234. package/dist/ui/theme/light.json +23 -0
  235. package/dist/ui/theme/theme.d.ts +28 -0
  236. package/dist/ui/theme/theme.d.ts.map +1 -0
  237. package/dist/ui/theme/theme.js +11 -0
  238. package/dist/ui/theme/theme.js.map +1 -0
  239. package/dist/utils/error-handler.d.ts +5 -0
  240. package/dist/utils/error-handler.d.ts.map +1 -0
  241. package/dist/utils/error-handler.js +97 -0
  242. package/dist/utils/error-handler.js.map +1 -0
  243. package/dist/utils/format.d.ts +21 -0
  244. package/dist/utils/format.d.ts.map +1 -0
  245. package/dist/utils/format.js +120 -0
  246. package/dist/utils/format.js.map +1 -0
  247. package/dist/utils/git.d.ts +2 -0
  248. package/dist/utils/git.d.ts.map +1 -0
  249. package/dist/utils/git.js +13 -0
  250. package/dist/utils/git.js.map +1 -0
  251. package/dist/utils/markdown.d.ts +6 -0
  252. package/dist/utils/markdown.d.ts.map +1 -0
  253. package/dist/utils/markdown.js +25 -0
  254. package/dist/utils/markdown.js.map +1 -0
  255. package/dist/utils/process.d.ts +6 -0
  256. package/dist/utils/process.d.ts.map +1 -0
  257. package/dist/utils/process.js +19 -0
  258. package/dist/utils/process.js.map +1 -0
  259. package/dist/utils/shell.d.ts +3 -0
  260. package/dist/utils/shell.d.ts.map +1 -0
  261. package/dist/utils/shell.js +8 -0
  262. package/dist/utils/shell.js.map +1 -0
  263. package/package.json +51 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-diff.d.ts","sourceRoot":"","sources":["../../src/tools/edit-diff.ts"],"names":[],"mappings":"AAgBA;;GAEG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GACd;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAyC5E;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAmBzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAa7F"}
@@ -0,0 +1,92 @@
1
+ import { diffLines } from "diff";
2
+ /**
3
+ * Normalize text for fuzzy matching:
4
+ * - Strip trailing whitespace per line
5
+ * - Replace smart quotes with straight quotes
6
+ * - Replace unicode dashes with hyphens
7
+ */
8
+ function normalizeForFuzzyMatch(text) {
9
+ return text
10
+ .replace(/[^\S\n]+$/gm, "") // trailing whitespace per line
11
+ .replace(/[\u2018\u2019]/g, "'") // smart single quotes
12
+ .replace(/[\u201C\u201D]/g, '"') // smart double quotes
13
+ .replace(/[\u2013\u2014]/g, "-"); // en/em dashes
14
+ }
15
+ /**
16
+ * Find text in content, trying exact match first then fuzzy.
17
+ */
18
+ export function fuzzyFindText(content, oldText) {
19
+ // Exact match first
20
+ const exactIndex = content.indexOf(oldText);
21
+ if (exactIndex !== -1) {
22
+ return { found: true, index: exactIndex, matchLength: oldText.length, usedFuzzy: false };
23
+ }
24
+ // Fuzzy match: normalize both sides
25
+ const normalizedContent = normalizeForFuzzyMatch(content);
26
+ const normalizedOld = normalizeForFuzzyMatch(oldText);
27
+ const fuzzyIndex = normalizedContent.indexOf(normalizedOld);
28
+ if (fuzzyIndex !== -1) {
29
+ // Map back to original content: find the actual length in original
30
+ // Since normalization only changes per-character substitutions and trailing whitespace,
31
+ // we need to find the original range.
32
+ // Strategy: match line by line to find the original span.
33
+ const normalizedBefore = normalizedContent.slice(0, fuzzyIndex);
34
+ const linesBefore = normalizedBefore.split("\n").length - 1;
35
+ const normalizedMatch = normalizedContent.slice(fuzzyIndex, fuzzyIndex + normalizedOld.length);
36
+ const matchLineCount = normalizedMatch.split("\n").length;
37
+ const contentLines = content.split("\n");
38
+ const matchLines = contentLines.slice(linesBefore, linesBefore + matchLineCount);
39
+ const originalMatch = matchLines.join("\n");
40
+ // Find actual index of the first match line start
41
+ let actualIndex = 0;
42
+ for (let i = 0; i < linesBefore; i++) {
43
+ actualIndex += contentLines[i].length + 1; // +1 for \n
44
+ }
45
+ return {
46
+ found: true,
47
+ index: actualIndex,
48
+ matchLength: originalMatch.length,
49
+ usedFuzzy: true,
50
+ };
51
+ }
52
+ return { found: false, index: -1, matchLength: 0, usedFuzzy: false };
53
+ }
54
+ /**
55
+ * Count occurrences of oldText in content (exact first, then fuzzy).
56
+ */
57
+ export function countOccurrences(content, oldText) {
58
+ // Try exact first
59
+ let count = 0;
60
+ let pos = 0;
61
+ while ((pos = content.indexOf(oldText, pos)) !== -1) {
62
+ count++;
63
+ pos += oldText.length;
64
+ }
65
+ if (count > 0)
66
+ return count;
67
+ // Fuzzy count
68
+ const normalizedContent = normalizeForFuzzyMatch(content);
69
+ const normalizedOld = normalizeForFuzzyMatch(oldText);
70
+ pos = 0;
71
+ while ((pos = normalizedContent.indexOf(normalizedOld, pos)) !== -1) {
72
+ count++;
73
+ pos += normalizedOld.length;
74
+ }
75
+ return count;
76
+ }
77
+ /**
78
+ * Generate a unified diff string.
79
+ */
80
+ export function generateDiff(oldContent, newContent, filePath) {
81
+ const changes = diffLines(oldContent, newContent);
82
+ const lines = [`--- a/${filePath}`, `+++ b/${filePath}`];
83
+ for (const change of changes) {
84
+ const prefix = change.added ? "+" : change.removed ? "-" : " ";
85
+ const changeLines = change.value.replace(/\n$/, "").split("\n");
86
+ for (const line of changeLines) {
87
+ lines.push(`${prefix}${line}`);
88
+ }
89
+ }
90
+ return lines.join("\n");
91
+ }
92
+ //# sourceMappingURL=edit-diff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit-diff.js","sourceRoot":"","sources":["../../src/tools/edit-diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAEjC;;;;;GAKG;AACH,SAAS,sBAAsB,CAAC,IAAY;IAC1C,OAAO,IAAI;SACR,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC,+BAA+B;SAC1D,OAAO,CAAC,iBAAiB,EAAE,GAAG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C,GAAG,GAAG,iBAAiB,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QACpE,KAAK,EAAE,CAAC;QACR,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC;IAC9B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkB,EAAE,UAAkB,EAAE,QAAgB;IACnF,MAAM,OAAO,GAAG,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAClD,MAAM,KAAK,GAAa,CAAC,SAAS,QAAQ,EAAE,EAAE,SAAS,QAAQ,EAAE,CAAC,CAAC;IAEnE,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/D,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAChE,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;YAC/B,KAAK,CAAC,IAAI,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
3
+ declare const EditParams: z.ZodObject<{
4
+ file_path: z.ZodString;
5
+ old_text: z.ZodString;
6
+ new_text: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export declare function createEditTool(cwd: string): AgentTool<typeof EditParams>;
9
+ export {};
10
+ //# sourceMappingURL=edit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,QAAA,MAAM,UAAU;;;;iBAId,CAAC;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAuDxE"}
@@ -0,0 +1,53 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ import { resolvePath } from "./path-utils.js";
5
+ import { fuzzyFindText, countOccurrences, generateDiff } from "./edit-diff.js";
6
+ const EditParams = z.object({
7
+ file_path: z.string().describe("The file path to edit"),
8
+ old_text: z.string().describe("The exact text to find and replace"),
9
+ new_text: z.string().describe("The replacement text"),
10
+ });
11
+ export function createEditTool(cwd) {
12
+ return {
13
+ name: "edit",
14
+ description: "Replace a specific text string in a file. The old_text must uniquely match " +
15
+ "exactly one location in the file. Returns a unified diff of the change.",
16
+ parameters: EditParams,
17
+ async execute({ file_path, old_text, new_text }) {
18
+ const resolved = resolvePath(cwd, file_path);
19
+ const content = await fs.readFile(resolved, "utf-8");
20
+ // Detect line endings
21
+ const hasCRLF = content.includes("\r\n");
22
+ // Normalize for matching
23
+ const normalized = hasCRLF ? content.replace(/\r\n/g, "\n") : content;
24
+ const normalizedOld = hasCRLF ? old_text.replace(/\r\n/g, "\n") : old_text;
25
+ const normalizedNew = hasCRLF ? new_text.replace(/\r\n/g, "\n") : new_text;
26
+ // Check uniqueness
27
+ const occurrences = countOccurrences(normalized, normalizedOld);
28
+ if (occurrences === 0) {
29
+ throw new Error(`old_text not found in ${path.basename(resolved)}. ` +
30
+ "Make sure the text matches exactly, including whitespace and indentation.");
31
+ }
32
+ if (occurrences > 1) {
33
+ throw new Error(`old_text found ${occurrences} times in ${path.basename(resolved)}. ` +
34
+ "Include more surrounding context to make the match unique.");
35
+ }
36
+ // Find and replace
37
+ const match = fuzzyFindText(normalized, normalizedOld);
38
+ if (!match.found) {
39
+ throw new Error(`old_text not found in ${path.basename(resolved)}.`);
40
+ }
41
+ const newContent = normalized.slice(0, match.index) +
42
+ normalizedNew +
43
+ normalized.slice(match.index + match.matchLength);
44
+ // Restore line endings if needed
45
+ const finalContent = hasCRLF ? newContent.replace(/\n/g, "\r\n") : newContent;
46
+ await fs.writeFile(resolved, finalContent, "utf-8");
47
+ const relPath = path.relative(cwd, resolved);
48
+ const diff = generateDiff(normalized, newContent, relPath);
49
+ return diff;
50
+ },
51
+ };
52
+ }
53
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edit.js","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE/E,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACvD,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;IACnE,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;CACtD,CAAC,CAAC;AAEH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,6EAA6E;YAC7E,yEAAyE;QAC3E,UAAU,EAAE,UAAU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,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,yBAAyB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;YACvE,CAAC;YAED,MAAM,UAAU,GACd,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC;gBAChC,aAAa;gBACb,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;YAEpD,iCAAiC;YACjC,MAAM,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;YAE9E,MAAM,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;YAEpD,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YAC7C,MAAM,IAAI,GAAG,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAC3D,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
3
+ declare const FindParams: z.ZodObject<{
4
+ pattern: z.ZodString;
5
+ path: z.ZodOptional<z.ZodString>;
6
+ }, z.core.$strip>;
7
+ export declare function createFindTool(cwd: string): AgentTool<typeof FindParams>;
8
+ export {};
9
+ //# sourceMappingURL=find.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/tools/find.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,QAAA,MAAM,UAAU;;;iBAGd,CAAC;AAIH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CA2CxE"}
@@ -0,0 +1,59 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ import { resolvePath } from "./path-utils.js";
5
+ const FindParams = z.object({
6
+ pattern: z.string().describe("Glob pattern to match files (e.g. '**/*.ts', 'src/**/*.tsx')"),
7
+ path: z.string().optional().describe("Directory to search in (defaults to cwd)"),
8
+ });
9
+ const MAX_RESULTS = 100;
10
+ export function createFindTool(cwd) {
11
+ return {
12
+ name: "find",
13
+ description: "Find files matching a glob pattern. Respects .gitignore. " +
14
+ "Returns sorted file paths, truncated if more than 100 matches.",
15
+ parameters: FindParams,
16
+ async execute({ pattern, path: searchPath }) {
17
+ const dir = searchPath ? resolvePath(cwd, searchPath) : cwd;
18
+ // Dynamic import for ESM-only fast-glob
19
+ const fg = await import("fast-glob");
20
+ const ignore = await import("ignore");
21
+ // Load .gitignore patterns
22
+ const ignorePatterns = await loadGitignore(dir);
23
+ const ig = ignore.default();
24
+ ig.add(ignorePatterns);
25
+ const entries = await fg.default(pattern, {
26
+ cwd: dir,
27
+ dot: false,
28
+ onlyFiles: true,
29
+ ignore: ["**/node_modules/**", "**/.git/**"],
30
+ });
31
+ // Filter by .gitignore
32
+ const filtered = entries.filter((entry) => !ig.ignores(entry));
33
+ filtered.sort();
34
+ const truncated = filtered.length > MAX_RESULTS;
35
+ const shown = truncated ? filtered.slice(0, MAX_RESULTS) : filtered;
36
+ let output = shown.join("\n");
37
+ if (truncated) {
38
+ output += `\n\n[Truncated: showing ${MAX_RESULTS} of ${filtered.length} matches]`;
39
+ }
40
+ else {
41
+ output += `\n\n${filtered.length} file(s) found`;
42
+ }
43
+ return output;
44
+ },
45
+ };
46
+ }
47
+ async function loadGitignore(dir) {
48
+ try {
49
+ const content = await fs.readFile(path.join(dir, ".gitignore"), "utf-8");
50
+ return content
51
+ .split("\n")
52
+ .map((l) => l.trim())
53
+ .filter((l) => l && !l.startsWith("#"));
54
+ }
55
+ catch {
56
+ return [];
57
+ }
58
+ }
59
+ //# sourceMappingURL=find.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find.js","sourceRoot":"","sources":["../../src/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8DAA8D,CAAC;IAC5F,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,0CAA0C,CAAC;CACjF,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,WAAW,EACT,2DAA2D;YAC3D,gEAAgE;QAClE,UAAU,EAAE,UAAU;QACtB,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;YACzC,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YAE5D,wCAAwC;YACxC,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,CAAC;YAEtC,2BAA2B;YAC3B,MAAM,cAAc,GAAG,MAAM,aAAa,CAAC,GAAG,CAAC,CAAC;YAChD,MAAM,EAAE,GAAG,MAA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C,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { z } from "zod";
2
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
3
+ declare const GrepParams: z.ZodObject<{
4
+ pattern: z.ZodString;
5
+ path: z.ZodOptional<z.ZodString>;
6
+ include: z.ZodOptional<z.ZodString>;
7
+ max_results: z.ZodOptional<z.ZodNumber>;
8
+ case_insensitive: z.ZodOptional<z.ZodBoolean>;
9
+ }, z.core.$strip>;
10
+ export declare function createGrepTool(cwd: string): AgentTool<typeof GrepParams>;
11
+ export {};
12
+ //# sourceMappingURL=grep.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,QAAA,MAAM,UAAU;;;;;;iBAWd,CAAC;AAIH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CAmDxE"}
@@ -0,0 +1,107 @@
1
+ import fs from "node:fs/promises";
2
+ import readline from "node:readline";
3
+ import { createReadStream } from "node:fs";
4
+ import path from "node:path";
5
+ import { z } from "zod";
6
+ import { resolvePath } from "./path-utils.js";
7
+ import { BINARY_EXTENSIONS } from "./read.js";
8
+ const GrepParams = z.object({
9
+ pattern: z.string().describe("Search pattern (regex supported)"),
10
+ path: z.string().optional().describe("File or directory to search (defaults to cwd)"),
11
+ include: z.string().optional().describe("Glob pattern to filter files (e.g. '*.ts')"),
12
+ max_results: z
13
+ .number()
14
+ .int()
15
+ .min(1)
16
+ .optional()
17
+ .describe("Maximum matches to return (default: 50)"),
18
+ case_insensitive: z.boolean().optional().describe("Case-insensitive search"),
19
+ });
20
+ const DEFAULT_MAX_RESULTS = 50;
21
+ export function createGrepTool(cwd) {
22
+ return {
23
+ name: "grep",
24
+ description: "Search file contents using regex. Returns filepath:line_number:content for matches. " +
25
+ "Respects .gitignore. Skips binary files.",
26
+ parameters: GrepParams,
27
+ async execute({ pattern, path: searchPath, include, max_results, case_insensitive }) {
28
+ const dir = searchPath ? resolvePath(cwd, searchPath) : cwd;
29
+ const maxResults = max_results ?? DEFAULT_MAX_RESULTS;
30
+ const flags = case_insensitive ? "gi" : "g";
31
+ let regex;
32
+ try {
33
+ regex = new RegExp(pattern, flags);
34
+ }
35
+ catch (err) {
36
+ throw new Error(`Invalid regex pattern: ${err.message}`, { cause: err });
37
+ }
38
+ // Check if dir is a file
39
+ const stat = await fs.stat(dir);
40
+ if (stat.isFile()) {
41
+ const results = await searchFile(dir, regex, cwd, maxResults);
42
+ return formatResults(results, maxResults);
43
+ }
44
+ // Enumerate files
45
+ const fg = await import("fast-glob");
46
+ const globPattern = include ?? "**/*";
47
+ const entries = await fg.default(globPattern, {
48
+ cwd: dir,
49
+ dot: false,
50
+ onlyFiles: true,
51
+ ignore: ["**/node_modules/**", "**/.git/**"],
52
+ });
53
+ const results = [];
54
+ for (const entry of entries) {
55
+ if (results.length >= maxResults)
56
+ break;
57
+ const ext = path.extname(entry).toLowerCase();
58
+ if (BINARY_EXTENSIONS.has(ext))
59
+ continue;
60
+ const filePath = path.join(dir, entry);
61
+ const fileResults = await searchFile(filePath, regex, cwd, maxResults - results.length);
62
+ results.push(...fileResults);
63
+ }
64
+ return formatResults(results, maxResults);
65
+ },
66
+ };
67
+ }
68
+ async function searchFile(filePath, regex, cwd, maxResults) {
69
+ const results = [];
70
+ const relPath = path.relative(cwd, filePath);
71
+ try {
72
+ const rl = readline.createInterface({
73
+ input: createReadStream(filePath, { encoding: "utf-8" }),
74
+ crlfDelay: Infinity,
75
+ });
76
+ let lineNum = 0;
77
+ for await (const line of rl) {
78
+ lineNum++;
79
+ // Reset lastIndex for global regex
80
+ regex.lastIndex = 0;
81
+ if (regex.test(line)) {
82
+ results.push(`${relPath}:${lineNum}:${line}`);
83
+ if (results.length >= maxResults) {
84
+ rl.close();
85
+ break;
86
+ }
87
+ }
88
+ }
89
+ }
90
+ catch {
91
+ // Skip unreadable files
92
+ }
93
+ return results;
94
+ }
95
+ function formatResults(results, maxResults) {
96
+ if (results.length === 0)
97
+ return "No matches found.";
98
+ let output = results.join("\n");
99
+ if (results.length >= maxResults) {
100
+ output += `\n\n[Truncated at ${maxResults} matches]`;
101
+ }
102
+ else {
103
+ output += `\n\n${results.length} match(es) found`;
104
+ }
105
+ return output;
106
+ }
107
+ //# sourceMappingURL=grep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE9C,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAChE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACrF,OAAO,EAAE,CAAC,CAAC,MAA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kBAAkB,CAAC;IACpD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
2
+ export declare function createTools(cwd: string): AgentTool[];
3
+ export { createReadTool } from "./read.js";
4
+ export { createWriteTool } from "./write.js";
5
+ export { createEditTool } from "./edit.js";
6
+ export { createBashTool } from "./bash.js";
7
+ export { createFindTool } from "./find.js";
8
+ export { createGrepTool } from "./grep.js";
9
+ export { createLsTool } from "./ls.js";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AASrD,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,EAAE,CAUpD;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { createReadTool } from "./read.js";
2
+ import { createWriteTool } from "./write.js";
3
+ import { createEditTool } from "./edit.js";
4
+ import { createBashTool } from "./bash.js";
5
+ import { createFindTool } from "./find.js";
6
+ import { createGrepTool } from "./grep.js";
7
+ import { createLsTool } from "./ls.js";
8
+ export function createTools(cwd) {
9
+ return [
10
+ createReadTool(cwd),
11
+ createWriteTool(cwd),
12
+ createEditTool(cwd),
13
+ createBashTool(cwd),
14
+ createFindTool(cwd),
15
+ createGrepTool(cwd),
16
+ createLsTool(cwd),
17
+ ];
18
+ }
19
+ export { createReadTool } from "./read.js";
20
+ export { createWriteTool } from "./write.js";
21
+ export { createEditTool } from "./edit.js";
22
+ export { createBashTool } from "./bash.js";
23
+ export { createFindTool } from "./find.js";
24
+ export { createGrepTool } from "./grep.js";
25
+ export { createLsTool } from "./ls.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,OAAO;QACL,cAAc,CAAC,GAAG,CAAC;QACnB,eAAe,CAAC,GAAG,CAAC;QACpB,cAAc,CAAC,GAAG,CAAC;QACnB,cAAc,CAAC,GAAG,CAAC;QACnB,cAAc,CAAC,GAAG,CAAC;QACnB,cAAc,CAAC,GAAG,CAAC;QACnB,YAAY,CAAC,GAAG,CAAC;KAClB,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { z } from "zod";
2
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
3
+ declare const LsParams: z.ZodObject<{
4
+ path: z.ZodOptional<z.ZodString>;
5
+ all: z.ZodOptional<z.ZodBoolean>;
6
+ }, z.core.$strip>;
7
+ export declare function createLsTool(cwd: string): AgentTool<typeof LsParams>;
8
+ export {};
9
+ //# sourceMappingURL=ls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ls.d.ts","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,QAAA,MAAM,QAAQ;;;iBAGZ,CAAC;AAEH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,QAAQ,CAAC,CAyCpE"}
@@ -0,0 +1,56 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { z } from "zod";
4
+ import { resolvePath } from "./path-utils.js";
5
+ const LsParams = z.object({
6
+ path: z.string().optional().describe("Directory path (defaults to cwd)"),
7
+ all: z.boolean().optional().describe("Show hidden files (default: false)"),
8
+ });
9
+ export function createLsTool(cwd) {
10
+ return {
11
+ name: "ls",
12
+ description: "List directory contents with file types and sizes. Directories listed first.",
13
+ parameters: LsParams,
14
+ async execute({ path: dirPath, all }) {
15
+ const resolved = dirPath ? resolvePath(cwd, dirPath) : cwd;
16
+ const entries = await fs.readdir(resolved, { withFileTypes: true });
17
+ // Filter hidden files unless --all
18
+ const filtered = all ? entries : entries.filter((e) => !e.name.startsWith("."));
19
+ // Separate dirs and files, then sort each alphabetically
20
+ const dirs = filtered
21
+ .filter((e) => e.isDirectory())
22
+ .sort((a, b) => a.name.localeCompare(b.name));
23
+ const files = filtered
24
+ .filter((e) => !e.isDirectory())
25
+ .sort((a, b) => a.name.localeCompare(b.name));
26
+ const lines = [];
27
+ for (const dir of dirs) {
28
+ lines.push(`d - ${dir.name}/`);
29
+ }
30
+ for (const file of files) {
31
+ try {
32
+ const stat = await fs.stat(path.join(resolved, file.name));
33
+ const size = formatSize(stat.size);
34
+ const type = file.isSymbolicLink() ? "l" : "f";
35
+ lines.push(`${type} ${size.padStart(8)} ${file.name}`);
36
+ }
37
+ catch {
38
+ lines.push(`? - ${file.name}`);
39
+ }
40
+ }
41
+ if (lines.length === 0)
42
+ return "Empty directory.";
43
+ return lines.join("\n");
44
+ },
45
+ };
46
+ }
47
+ function formatSize(bytes) {
48
+ if (bytes < 1024)
49
+ return `${bytes}B`;
50
+ if (bytes < 1024 * 1024)
51
+ return `${(bytes / 1024).toFixed(1)}K`;
52
+ if (bytes < 1024 * 1024 * 1024)
53
+ return `${(bytes / (1024 * 1024)).toFixed(1)}M`;
54
+ return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)}G`;
55
+ }
56
+ //# sourceMappingURL=ls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ls.js","sourceRoot":"","sources":["../../src/tools/ls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IACxB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IACxE,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;CAC3E,CAAC,CAAC;AAEH,MAAM,UAAU,YA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GAAG,CAAC;IAChF,OAAO,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC;AACzD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function resolvePath(cwd: string, filePath: string): string;
2
+ //# sourceMappingURL=path-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.d.ts","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"AAGA,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAKjE"}
@@ -0,0 +1,9 @@
1
+ import path from "node:path";
2
+ import os from "node:os";
3
+ export function resolvePath(cwd, filePath) {
4
+ if (filePath.startsWith("~")) {
5
+ filePath = path.join(os.homedir(), filePath.slice(1));
6
+ }
7
+ return path.resolve(cwd, filePath);
8
+ }
9
+ //# sourceMappingURL=path-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../src/tools/path-utils.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAgB;IACvD,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7B,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { z } from "zod";
2
+ import type { AgentTool } from "@kenkaiiii/gg-agent";
3
+ export declare const BINARY_EXTENSIONS: Set<string>;
4
+ declare const ReadParams: z.ZodObject<{
5
+ file_path: z.ZodString;
6
+ offset: z.ZodOptional<z.ZodNumber>;
7
+ limit: z.ZodOptional<z.ZodNumber>;
8
+ }, z.core.$strip>;
9
+ export declare function createReadTool(cwd: string): AgentTool<typeof ReadParams>;
10
+ export {};
11
+ //# sourceMappingURL=read.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/tools/read.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAIrD,eAAO,MAAM,iBAAiB,aA4C5B,CAAC;AAEH,QAAA,MAAM,UAAU;;;;iBASd,CAAC;AAEH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,UAAU,CAAC,CA2CxE"}