@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
@@ -68,6 +68,35 @@ function detectTerminalColorLevel() {
68
68
  }
69
69
  return undefined;
70
70
  }
71
+ function detectWindowsColorLevel() {
72
+ if (process.platform !== "win32") {
73
+ return undefined;
74
+ }
75
+ // Windows 10 build 10586 is the first Windows release that supports 256 colors.
76
+ // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
77
+ const osRelease = os.release().split(".");
78
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
79
+ return Number(osRelease[2]) >= 14_931 ? 3 : 2;
80
+ }
81
+ return 1;
82
+ }
83
+ function detectHighColorTerminalLevel() {
84
+ if (env["COLORTERM"] === "truecolor") {
85
+ return 3;
86
+ }
87
+ if (env["TERM"] === "xterm-kitty" || env["TERM"] === "xterm-ghostty") {
88
+ return 3;
89
+ }
90
+ return undefined;
91
+ }
92
+ function detectTeamCityColorLevel() {
93
+ if ("TEAMCITY_VERSION" in env) {
94
+ return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env["TEAMCITY_VERSION"] || "")
95
+ ? 1
96
+ : 0;
97
+ }
98
+ return undefined;
99
+ }
71
100
  function _supportsColor(haveStream, options = {}) {
72
101
  const noFlagForceColor = envForceColor();
73
102
  const forceColor = noFlagForceColor;
@@ -86,32 +115,21 @@ function _supportsColor(haveStream, options = {}) {
86
115
  if (env["TERM"] === "dumb") {
87
116
  return min;
88
117
  }
89
- if (process.platform === "win32") {
90
- // Windows 10 build 10586 is the first Windows release that supports 256 colors.
91
- // Windows 10 build 14931 is the first release that supports 16m/TrueColor.
92
- const osRelease = os.release().split(".");
93
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10_586) {
94
- return Number(osRelease[2]) >= 14_931 ? 3 : 2;
95
- }
96
- return 1;
118
+ const windowsLevel = detectWindowsColorLevel();
119
+ if (windowsLevel !== undefined) {
120
+ return windowsLevel;
97
121
  }
98
122
  const ciLevel = detectCiColorLevel(min);
99
123
  if (ciLevel !== undefined) {
100
124
  return ciLevel;
101
125
  }
102
- if ("TEAMCITY_VERSION" in env) {
103
- return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env["TEAMCITY_VERSION"] || "")
104
- ? 1
105
- : 0;
106
- }
107
- if (env["COLORTERM"] === "truecolor") {
108
- return 3;
126
+ const teamCityLevel = detectTeamCityColorLevel();
127
+ if (teamCityLevel !== undefined) {
128
+ return teamCityLevel;
109
129
  }
110
- if (env["TERM"] === "xterm-kitty") {
111
- return 3;
112
- }
113
- if (env["TERM"] === "xterm-ghostty") {
114
- return 3;
130
+ const highColorLevel = detectHighColorTerminalLevel();
131
+ if (highColorLevel !== undefined) {
132
+ return highColorLevel;
115
133
  }
116
134
  const terminalLevel = detectTerminalColorLevel();
117
135
  if (terminalLevel !== undefined) {
@@ -1,3 +1,6 @@
1
+ export declare function createSupportsHyperlinks(stream: {
2
+ isTty?: boolean;
3
+ }): boolean;
1
4
  export declare const supportsHyperlinks: {
2
5
  stdout: boolean;
3
6
  stderr: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"supports-hyperlinks.d.ts","sourceRoot":"","sources":["../../source/terminal/supports-hyperlinks.ts"],"names":[],"mappings":"AAyIA,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
1
+ {"version":3,"file":"supports-hyperlinks.d.ts","sourceRoot":"","sources":["../../source/terminal/supports-hyperlinks.ts"],"names":[],"mappings":"AA+BA,wBAAgB,wBAAwB,CAAC,MAAM,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CA8E7E;AAmFD,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
@@ -20,7 +20,7 @@ function parseVersion(versionString = "") {
20
20
  patch: versions[2] ?? 0,
21
21
  };
22
22
  }
23
- function createSupportsHyperlinks(stream) {
23
+ export function createSupportsHyperlinks(stream) {
24
24
  const { CI, CURSOR_TRACE_ID, FORCE_HYPERLINK, NETLIFY, TEAMCITY_VERSION, TERM_PROGRAM, TERM_PROGRAM_VERSION, VTE_VERSION, TERM, } = process.env;
25
25
  if (FORCE_HYPERLINK) {
26
26
  return !(FORCE_HYPERLINK.length > 0 && Number.parseInt(FORCE_HYPERLINK, 10) === 0);
@@ -29,6 +29,13 @@ function createSupportsHyperlinks(stream) {
29
29
  if (NETLIFY) {
30
30
  return true;
31
31
  }
32
+ // TERM=dumb means the terminal is incapable of rendering hyperlinks.
33
+ // This is checked independently from supports-color because FORCE_COLOR
34
+ // can make supports-color return truthy even for TERM=dumb, but
35
+ // FORCE_COLOR does not enable hyperlinks on terminals that lack support.
36
+ if (TERM === "dumb") {
37
+ return false;
38
+ }
32
39
  // If they specify no colors, they probably don't want hyperlinks.
33
40
  if (!createSupportsColor(stream)) {
34
41
  return false;
@@ -49,48 +56,82 @@ function createSupportsHyperlinks(stream) {
49
56
  if (TEAMCITY_VERSION) {
50
57
  return false;
51
58
  }
52
- if (TERM_PROGRAM) {
53
- const version = parseVersion(TERM_PROGRAM_VERSION);
54
- switch (TERM_PROGRAM) {
55
- case "iTerm.app": {
56
- if (version.major === 3) {
57
- return version.minor >= 1;
58
- }
59
- return version.major > 3;
60
- }
61
- case "WezTerm": {
62
- return version.major >= 20_200_620;
63
- }
64
- case "vscode": {
65
- // Cursor forked VS Code and supports hyperlinks in 0.x.x
66
- if (CURSOR_TRACE_ID) {
67
- return true;
68
- }
69
- // eslint-disable-next-line no-mixed-operators
70
- return (version.major > 1 || (version.major === 1 && version.minor >= 72));
59
+ const termProgramResult = checkTermProgram(TERM_PROGRAM, TERM_PROGRAM_VERSION, CURSOR_TRACE_ID);
60
+ if (termProgramResult !== undefined) {
61
+ return termProgramResult;
62
+ }
63
+ const vteResult = checkVteVersion(VTE_VERSION);
64
+ if (vteResult !== undefined) {
65
+ return vteResult;
66
+ }
67
+ const termResult = checkTerm(TERM);
68
+ if (termResult !== undefined) {
69
+ return termResult;
70
+ }
71
+ return false;
72
+ }
73
+ /**
74
+ * Check TERM_PROGRAM-based hyperlink support.
75
+ * Returns boolean if a known terminal is matched, undefined otherwise.
76
+ */
77
+ function checkTermProgram(termProgram, versionString, cursorTraceId) {
78
+ if (!termProgram) {
79
+ return undefined;
80
+ }
81
+ const version = parseVersion(versionString);
82
+ switch (termProgram) {
83
+ case "iTerm.app": {
84
+ if (version.major === 3) {
85
+ return version.minor >= 1;
71
86
  }
72
- case "ghostty": {
87
+ return version.major > 3;
88
+ }
89
+ case "WezTerm": {
90
+ return version.major >= 20_200_620;
91
+ }
92
+ case "vscode": {
93
+ // Cursor forked VS Code and supports hyperlinks in 0.x.x
94
+ if (cursorTraceId) {
73
95
  return true;
74
96
  }
75
- // No default
97
+ // eslint-disable-next-line no-mixed-operators
98
+ return version.major > 1 || (version.major === 1 && version.minor >= 72);
76
99
  }
77
- }
78
- if (VTE_VERSION) {
79
- // 0.50.0 was supposed to support hyperlinks, but throws a segfault
80
- if (VTE_VERSION === "0.50.0") {
81
- return false;
100
+ case "ghostty": {
101
+ return true;
82
102
  }
83
- const version = parseVersion(VTE_VERSION);
84
- return version.major > 0 || version.minor >= 50;
103
+ // No default
104
+ }
105
+ return undefined;
106
+ }
107
+ /**
108
+ * Check VTE_VERSION-based hyperlink support.
109
+ * Returns boolean if VTE_VERSION is set, undefined otherwise.
110
+ */
111
+ function checkVteVersion(vteVersion) {
112
+ if (!vteVersion) {
113
+ return undefined;
114
+ }
115
+ // 0.50.0 was supposed to support hyperlinks, but throws a segfault
116
+ if (vteVersion === "0.50.0") {
117
+ return false;
85
118
  }
86
- switch (TERM) {
119
+ const version = parseVersion(vteVersion);
120
+ return version.major > 0 || version.minor >= 50;
121
+ }
122
+ /**
123
+ * Check TERM-based hyperlink support.
124
+ * Returns boolean if a known terminal is matched, undefined otherwise.
125
+ */
126
+ function checkTerm(term) {
127
+ switch (term) {
87
128
  case "alacritty": {
88
129
  // Support added in v0.11 (2022-10-13)
89
130
  return true;
90
131
  }
91
132
  // No default
92
133
  }
93
- return false;
134
+ return undefined;
94
135
  }
95
136
  export const supportsHyperlinks = {
96
137
  stdout: createSupportsHyperlinks({ isTty: process.stdout.isTTY }),
@@ -1,25 +1,5 @@
1
1
  import { Cell } from "./cell.ts";
2
- export declare function layoutTable(table: Cell[][]): void;
3
- export declare function maxWidth(table: Cell[][]): number;
4
- export declare function maxHeight(table: Cell[][]): number;
5
- export declare function cellsConflict(cell1: {
6
- x: number;
7
- y: number;
8
- rowSpan?: number;
9
- colSpan?: number;
10
- }, cell2: {
11
- x: number;
12
- y: number;
13
- rowSpan?: number;
14
- colSpan?: number;
15
- }): boolean;
16
- export declare function conflictExists(rows: Cell[][], x: number, y: number): boolean;
17
- export declare function allBlank(rows: Cell[][], y: number, xMin: number, xMax: number): boolean;
18
- export declare function addRowSpanCells(table: Cell[][]): void;
19
- export declare function addColSpanCells(cellRows: Cell[][]): void;
20
- export declare function insertCell(cell: Cell, row: Cell[]): void;
21
2
  export declare function fillInTable(table: Cell[][]): void;
22
- export declare function generateCells(rows: unknown[]): Cell[][];
23
3
  export declare function makeTableLayout(rows: unknown[]): Cell[][];
24
4
  export declare function makeComputeWidths(colSpan: "colSpan", desiredWidth: "desiredWidth" | "desiredHeight", x: "x" | "y", forcedMin: number): (vals: Array<number | null>, table: Cell[][]) => void;
25
5
  export declare const computeWidths: (vals: Array<number | null>, table: Cell[][]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"layout-manager.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/layout-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA4B,MAAM,WAAW,CAAC;AAe3D,wBAAgB,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAsBjD;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,CAUhD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,CAEjD;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,EACnE,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAClE,OAAO,CAcT;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAsB5E;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,IAAI,EAAE,EAAE,EACd,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAOT;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAcrD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,CAmBxD;AAED,wB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ACZ,SAAS,EAAE,MAAM,GAChB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK,IAAI,CAmBvD;AAED,eAAO,MAAM,aAAa,SArBhB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,IA0BnD,CAAC;AACF,eAAO,MAAM,cAAc,SA3BjB,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,EAAE,KAAK,IAgCnD,CAAC"}
@@ -6,7 +6,7 @@ function next(alloc, col) {
6
6
  }
7
7
  return col;
8
8
  }
9
- export function layoutTable(table) {
9
+ function layoutTable(table) {
10
10
  const alloc = {};
11
11
  table.forEach((row, rowIndex) => {
12
12
  let col = 0;
@@ -30,7 +30,7 @@ export function layoutTable(table) {
30
30
  });
31
31
  });
32
32
  }
33
- export function maxWidth(table) {
33
+ function maxWidth(table) {
34
34
  let mw = 0;
35
35
  table.forEach((row) => {
36
36
  row.forEach((cell) => {
@@ -41,10 +41,10 @@ export function maxWidth(table) {
41
41
  });
42
42
  return mw;
43
43
  }
44
- export function maxHeight(table) {
44
+ function maxHeight(table) {
45
45
  return table.length;
46
46
  }
47
- export function cellsConflict(cell1, cell2) {
47
+ function cellsConflict(cell1, cell2) {
48
48
  const yMin1 = cell1.y;
49
49
  const yMax1 = cell1.y - 1 + (cell1.rowSpan || 1);
50
50
  const yMin2 = cell2.y;
@@ -57,7 +57,7 @@ export function cellsConflict(cell1, cell2) {
57
57
  const xConflict = !(xMin1 > xMax2 || xMin2 > xMax1);
58
58
  return yConflict && xConflict;
59
59
  }
60
- export function conflictExists(rows, x, y) {
60
+ function conflictExists(rows, x, y) {
61
61
  const iMax = Math.min(rows.length - 1, y);
62
62
  const cell = { x: x, y: y };
63
63
  for (let i = 0; i <= iMax; i++) {
@@ -78,7 +78,7 @@ export function conflictExists(rows, x, y) {
78
78
  }
79
79
  return false;
80
80
  }
81
- export function allBlank(rows, y, xMin, xMax) {
81
+ function allBlank(rows, y, xMin, xMax) {
82
82
  for (let x = xMin; x < xMax; x++) {
83
83
  if (conflictExists(rows, x, y)) {
84
84
  return false;
@@ -86,7 +86,7 @@ export function allBlank(rows, y, xMin, xMax) {
86
86
  }
87
87
  return true;
88
88
  }
89
- export function addRowSpanCells(table) {
89
+ function addRowSpanCells(table) {
90
90
  table.forEach((row, rowIndex) => {
91
91
  row.forEach((cell) => {
92
92
  for (let i = 1; i < cell.rowSpan; i++) {
@@ -101,7 +101,7 @@ export function addRowSpanCells(table) {
101
101
  });
102
102
  });
103
103
  }
104
- export function addColSpanCells(cellRows) {
104
+ function addColSpanCells(cellRows) {
105
105
  for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) {
106
106
  const cellColumns = cellRows[rowIndex];
107
107
  for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) {
@@ -117,7 +117,7 @@ export function addColSpanCells(cellRows) {
117
117
  }
118
118
  }
119
119
  }
120
- export function insertCell(cell, row) {
120
+ function insertCell(cell, row) {
121
121
  let x = 0;
122
122
  const cellX = cell.x;
123
123
  while (x < row.length) {
@@ -171,7 +171,7 @@ export function fillInTable(table) {
171
171
  }
172
172
  }
173
173
  }
174
- export function generateCells(rows) {
174
+ function generateCells(rows) {
175
175
  return rows.map((row) => {
176
176
  let processedRow = row;
177
177
  if (!Array.isArray(processedRow)) {
@@ -234,45 +234,69 @@ function applyForcedValues(vals, result) {
234
234
  });
235
235
  }
236
236
  /**
237
- * Processes spanning cells and distributes their widths across columns.
237
+ * Computes the existing width and count of editable columns
238
+ * for a spanning cell by summing up the spanned columns.
238
239
  */
239
- function processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals) {
240
- for (let k = spanners.length - 1; k >= 0; k--) {
241
- const cell = spanners[k];
242
- const span = cell[colSpan];
243
- const col = cell[x];
244
- if (col === null)
245
- continue;
246
- let existingWidth = result[col];
247
- let editableCols = typeof vals[col] === "number" ? 0 : 1;
248
- if (typeof existingWidth === "number") {
249
- for (let i = 1; i < span; i++) {
250
- existingWidth += 1 + result[col + i];
251
- if (typeof vals[col + i] !== "number") {
252
- editableCols++;
253
- }
254
- }
240
+ function computeSpanExistingWidth(span, col, result, vals, initialWidth, initialEditable) {
241
+ let existingWidth = initialWidth;
242
+ let editableCols = initialEditable;
243
+ for (let i = 1; i < span; i++) {
244
+ existingWidth += 1 + result[col + i];
245
+ if (typeof vals[col + i] !== "number") {
246
+ editableCols++;
255
247
  }
256
- else {
257
- existingWidth =
258
- desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
259
- if (!auto[col] || auto[col] < existingWidth) {
260
- auto[col] = existingWidth;
261
- }
248
+ }
249
+ return { existingWidth, editableCols };
250
+ }
251
+ /**
252
+ * Distributes excess desired width across editable columns.
253
+ */
254
+ function distributeSpanExcess(cell, col, desiredWidth, result, vals, startWidth, startEditable) {
255
+ let existingWidth = startWidth;
256
+ let editableCols = startEditable;
257
+ let i = 0;
258
+ while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
259
+ if (typeof vals[col + i] !== "number") {
260
+ const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
261
+ existingWidth += dif;
262
+ result[col + i] += dif;
263
+ editableCols--;
262
264
  }
263
- if (cell[desiredWidth] > existingWidth) {
264
- let i = 0;
265
- while (editableCols > 0 && cell[desiredWidth] > existingWidth) {
266
- if (typeof vals[col + i] !== "number") {
267
- const dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols);
268
- existingWidth += dif;
269
- result[col + i] += dif;
270
- editableCols--;
271
- }
272
- i++;
273
- }
265
+ i++;
266
+ }
267
+ }
268
+ /**
269
+ * Processes a single spanning cell, computing and distributing its width.
270
+ */
271
+ function processSpanner(cell, colSpan, desiredWidth, x, result, auto, vals) {
272
+ const span = cell[colSpan];
273
+ const col = cell[x];
274
+ if (col === null)
275
+ return;
276
+ let existingWidth = result[col];
277
+ let editableCols = typeof vals[col] === "number" ? 0 : 1;
278
+ if (typeof existingWidth === "number") {
279
+ const computed = computeSpanExistingWidth(span, col, result, vals, existingWidth, editableCols);
280
+ existingWidth = computed.existingWidth;
281
+ editableCols = computed.editableCols;
282
+ }
283
+ else {
284
+ existingWidth = desiredWidth === "desiredWidth" ? cell.desiredWidth - 1 : 1;
285
+ if (!auto[col] || auto[col] < existingWidth) {
286
+ auto[col] = existingWidth;
274
287
  }
275
288
  }
289
+ if (cell[desiredWidth] > existingWidth) {
290
+ distributeSpanExcess(cell, col, desiredWidth, result, vals, existingWidth, editableCols);
291
+ }
292
+ }
293
+ /**
294
+ * Processes spanning cells and distributes their widths across columns.
295
+ */
296
+ function processSpanners(colSpan, desiredWidth, x, spanners, result, auto, vals) {
297
+ for (let k = spanners.length - 1; k >= 0; k--) {
298
+ processSpanner(spanners[k], colSpan, desiredWidth, x, result, auto, vals);
299
+ }
276
300
  }
277
301
  export function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
278
302
  return (vals, table) => {
@@ -51,7 +51,6 @@ export declare function strlen(str: string): number;
51
51
  export declare function repeat(str: string, times: number): string;
52
52
  export declare function pad(str: string, len: number, padChar: string, dir: HorizontalAlignment): string;
53
53
  export declare function truncate(str: string, desiredLength: number, truncateChar?: string): string;
54
- export declare function defaultOptions(): TableInstanceOptions;
55
54
  export declare function mergeOptions(options?: Partial<TableConstructorOptions>, defaults?: TableInstanceOptions): TableInstanceOptions;
56
55
  export declare function multiLineWordWrap(maxLength: number, input: string, wrapOnWordBoundary?: boolean): string[];
57
56
  export declare function colorizeLines(input: string[]): string[];
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../source/terminal/table/utils.ts"],"names":[],"mappings":"AAEA,KAAK,QAAQ,GACT,KAAK,GACL,QAAQ,GACR,SAAS,GACT,UAAU,GACV,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,MAAM,GACN,SAAS,GACT,KAAK,GACL,QAA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,CAAC,EAAE,MAAM,EAAE,CAAC;KACnB,CAAC;CACH;AAED,KAAK,IAAI,GAAG,SAAS,GAAG,WAAW,CAAC;AAmBpC,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ1C;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,wBAAgB,GAAG,CACjB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,mBAAmB,GACvB,MAAM,CAuBR;AA6KD,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,EACX,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE,MAAM,GACpB,MAAM,CAmBR;AAuCD,wBAAgB,YAAY,CAC1B,OAAO,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,EAC1C,QAAQ,CAAC,EAAE,oBAAoB,GAC9B,oBAAoB,CAOtB;AAsDD,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,kBAAkB,UAAO,GACxB,MAAM,EAAE,CAQV;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAUvD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAmB3D;AAED,YAAY,EACV,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,GAClB,CAAC"}
@@ -10,9 +10,7 @@ export function strlen(str) {
10
10
  const code = codeRegex(false);
11
11
  const stripped = `${str}`.replace(code, "");
12
12
  const split = stripped.split("\n");
13
- return split.reduce((memo, s) => {
14
- return stringWidth(s) > memo ? stringWidth(s) : memo;
15
- }, 0);
13
+ return split.reduce((memo, s) => Math.max(stringWidth(s), memo), 0);
16
14
  }
17
15
  export function repeat(str, times) {
18
16
  return Array(times + 1).join(str);
@@ -192,7 +190,7 @@ export function truncate(str, desiredLength, truncateChar) {
192
190
  }
193
191
  return ret;
194
192
  }
195
- export function defaultOptions() {
193
+ function defaultOptions() {
196
194
  return {
197
195
  chars: {
198
196
  top: "─",
@@ -8,7 +8,7 @@ declare const inputSchema: z.ZodObject<{
8
8
  patchText: z.ZodString;
9
9
  }, z.core.$strip>;
10
10
  type ApplyPatchInputSchema = z.infer<typeof inputSchema>;
11
- export type Hunk = {
11
+ type Hunk = {
12
12
  type: "add";
13
13
  path: string;
14
14
  contents: string;
@@ -27,7 +27,7 @@ export interface UpdateFileChunk {
27
27
  changeContext?: string;
28
28
  isEndOfFile?: boolean;
29
29
  }
30
- export type ApplyPatchFileChange = {
30
+ type ApplyPatchFileChange = {
31
31
  type: "add";
32
32
  path: string;
33
33
  content: string;
@@ -42,10 +42,12 @@ export type ApplyPatchFileChange = {
42
42
  movePath?: string;
43
43
  newContent: string;
44
44
  };
45
- export interface ParsedApplyPatch {
45
+ interface ParsedApplyPatch {
46
46
  hunks: Hunk[];
47
47
  }
48
48
  export declare function parsePatch(patchText: string): ParsedApplyPatch;
49
+ export declare function computeReplacements(originalLines: string[], filePath: string, chunks: UpdateFileChunk[]): Array<[number, number, string[]]>;
50
+ export declare function applyChanges(changes: ApplyPatchFileChange[], signal?: AbortSignal): Promise<string[]>;
49
51
  export declare const createApplyPatchTool: (options: {
50
52
  workspace: WorkspaceContext;
51
53
  }) => Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"apply-patch.d.ts","sourceRoot":"","sources":["../../source/tools/apply-patch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAOpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,e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