acmecode 1.0.0 → 1.0.3

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 (132) hide show
  1. package/bin/acmecode.js +3 -0
  2. package/dist/index.js +16 -4
  3. package/package.json +11 -26
  4. package/tsconfig.json +26 -18
  5. package/.acmecode/config.json +0 -6
  6. package/README.md +0 -124
  7. package/dist/agent/index.js +0 -161
  8. package/dist/cli/bin/acmecode.js +0 -3
  9. package/dist/cli/package.json +0 -25
  10. package/dist/cli/src/index.js +0 -53
  11. package/dist/config/index.js +0 -92
  12. package/dist/context/index.js +0 -30
  13. package/dist/core/src/agent/index.d.ts +0 -52
  14. package/dist/core/src/agent/index.js +0 -476
  15. package/dist/core/src/config/index.d.ts +0 -83
  16. package/dist/core/src/config/index.js +0 -318
  17. package/dist/core/src/context/index.d.ts +0 -1
  18. package/dist/core/src/context/index.js +0 -30
  19. package/dist/core/src/llm/provider.d.ts +0 -27
  20. package/dist/core/src/llm/provider.js +0 -202
  21. package/dist/core/src/llm/vision.d.ts +0 -7
  22. package/dist/core/src/llm/vision.js +0 -37
  23. package/dist/core/src/mcp/index.d.ts +0 -10
  24. package/dist/core/src/mcp/index.js +0 -84
  25. package/dist/core/src/prompt/anthropic.d.ts +0 -1
  26. package/dist/core/src/prompt/anthropic.js +0 -32
  27. package/dist/core/src/prompt/architect.d.ts +0 -1
  28. package/dist/core/src/prompt/architect.js +0 -17
  29. package/dist/core/src/prompt/autopilot.d.ts +0 -1
  30. package/dist/core/src/prompt/autopilot.js +0 -18
  31. package/dist/core/src/prompt/beast.d.ts +0 -1
  32. package/dist/core/src/prompt/beast.js +0 -83
  33. package/dist/core/src/prompt/gemini.d.ts +0 -1
  34. package/dist/core/src/prompt/gemini.js +0 -45
  35. package/dist/core/src/prompt/index.d.ts +0 -18
  36. package/dist/core/src/prompt/index.js +0 -239
  37. package/dist/core/src/prompt/zen.d.ts +0 -1
  38. package/dist/core/src/prompt/zen.js +0 -13
  39. package/dist/core/src/session/index.d.ts +0 -18
  40. package/dist/core/src/session/index.js +0 -97
  41. package/dist/core/src/skills/index.d.ts +0 -6
  42. package/dist/core/src/skills/index.js +0 -72
  43. package/dist/core/src/tools/batch.d.ts +0 -2
  44. package/dist/core/src/tools/batch.js +0 -65
  45. package/dist/core/src/tools/browser.d.ts +0 -7
  46. package/dist/core/src/tools/browser.js +0 -86
  47. package/dist/core/src/tools/edit.d.ts +0 -11
  48. package/dist/core/src/tools/edit.js +0 -312
  49. package/dist/core/src/tools/index.d.ts +0 -13
  50. package/dist/core/src/tools/index.js +0 -980
  51. package/dist/core/src/tools/lsp-client.d.ts +0 -11
  52. package/dist/core/src/tools/lsp-client.js +0 -224
  53. package/dist/llm/provider.js +0 -34
  54. package/dist/mcp/index.js +0 -84
  55. package/dist/session/index.js +0 -74
  56. package/dist/skills/index.js +0 -32
  57. package/dist/tools/index.js +0 -96
  58. package/dist/tui/App.js +0 -297
  59. package/dist/tui/Spinner.js +0 -16
  60. package/dist/tui/TextInput.js +0 -98
  61. package/dist/tui/src/App.d.ts +0 -11
  62. package/dist/tui/src/App.js +0 -1211
  63. package/dist/tui/src/CatLogo.d.ts +0 -10
  64. package/dist/tui/src/CatLogo.js +0 -99
  65. package/dist/tui/src/OptionList.d.ts +0 -15
  66. package/dist/tui/src/OptionList.js +0 -60
  67. package/dist/tui/src/Spinner.d.ts +0 -7
  68. package/dist/tui/src/Spinner.js +0 -18
  69. package/dist/tui/src/TextInput.d.ts +0 -28
  70. package/dist/tui/src/TextInput.js +0 -139
  71. package/dist/tui/src/Tips.d.ts +0 -2
  72. package/dist/tui/src/Tips.js +0 -62
  73. package/dist/tui/src/Toast.d.ts +0 -19
  74. package/dist/tui/src/Toast.js +0 -39
  75. package/dist/tui/src/TodoItem.d.ts +0 -7
  76. package/dist/tui/src/TodoItem.js +0 -21
  77. package/dist/tui/src/i18n.d.ts +0 -172
  78. package/dist/tui/src/i18n.js +0 -189
  79. package/dist/tui/src/markdown.d.ts +0 -6
  80. package/dist/tui/src/markdown.js +0 -356
  81. package/dist/tui/src/theme.d.ts +0 -31
  82. package/dist/tui/src/theme.js +0 -239
  83. package/output.txt +0 -0
  84. package/packages/cli/package.json +0 -25
  85. package/packages/cli/tsconfig.json +0 -26
  86. package/packages/core/package.json +0 -39
  87. package/packages/core/src/agent/index.ts +0 -588
  88. package/packages/core/src/config/index.ts +0 -383
  89. package/packages/core/src/context/index.ts +0 -34
  90. package/packages/core/src/llm/provider.ts +0 -237
  91. package/packages/core/src/llm/vision.ts +0 -43
  92. package/packages/core/src/mcp/index.ts +0 -110
  93. package/packages/core/src/prompt/anthropic.ts +0 -32
  94. package/packages/core/src/prompt/architect.ts +0 -17
  95. package/packages/core/src/prompt/autopilot.ts +0 -18
  96. package/packages/core/src/prompt/beast.ts +0 -83
  97. package/packages/core/src/prompt/gemini.ts +0 -45
  98. package/packages/core/src/prompt/index.ts +0 -267
  99. package/packages/core/src/prompt/zen.ts +0 -13
  100. package/packages/core/src/session/index.ts +0 -129
  101. package/packages/core/src/skills/index.ts +0 -86
  102. package/packages/core/src/tools/batch.ts +0 -73
  103. package/packages/core/src/tools/browser.ts +0 -95
  104. package/packages/core/src/tools/edit.ts +0 -317
  105. package/packages/core/src/tools/index.ts +0 -1112
  106. package/packages/core/src/tools/lsp-client.ts +0 -303
  107. package/packages/core/tsconfig.json +0 -19
  108. package/packages/tui/package.json +0 -24
  109. package/packages/tui/src/App.tsx +0 -1702
  110. package/packages/tui/src/CatLogo.tsx +0 -134
  111. package/packages/tui/src/OptionList.tsx +0 -95
  112. package/packages/tui/src/Spinner.tsx +0 -28
  113. package/packages/tui/src/TextInput.tsx +0 -202
  114. package/packages/tui/src/Tips.tsx +0 -64
  115. package/packages/tui/src/Toast.tsx +0 -60
  116. package/packages/tui/src/TodoItem.tsx +0 -29
  117. package/packages/tui/src/i18n.ts +0 -203
  118. package/packages/tui/src/markdown.ts +0 -403
  119. package/packages/tui/src/theme.ts +0 -287
  120. package/packages/tui/tsconfig.json +0 -24
  121. package/vscode-acmecode/.vscodeignore +0 -11
  122. package/vscode-acmecode/README.md +0 -57
  123. package/vscode-acmecode/esbuild.js +0 -46
  124. package/vscode-acmecode/images/button-dark.svg +0 -5
  125. package/vscode-acmecode/images/button-light.svg +0 -5
  126. package/vscode-acmecode/images/icon.png +0 -1
  127. package/vscode-acmecode/package-lock.json +0 -490
  128. package/vscode-acmecode/package.json +0 -87
  129. package/vscode-acmecode/src/extension.ts +0 -128
  130. package/vscode-acmecode/tsconfig.json +0 -16
  131. /package/dist/{cli/src/index.d.ts → index.d.ts} +0 -0
  132. /package/{packages/cli/src → src}/index.ts +0 -0
@@ -1,317 +0,0 @@
1
- import path from 'path';
2
- import * as fs from 'fs/promises';
3
-
4
- // ── Fuzzy Replacement Logic (Ported from opencode) ──
5
-
6
- export type Replacer = (content: string, find: string) => Generator<string, void, unknown>;
7
-
8
- const SINGLE_CANDIDATE_SIMILARITY_THRESHOLD = 0.0;
9
- const MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD = 0.3;
10
-
11
- function levenshtein(a: string, b: string): number {
12
- if (a === "" || b === "") return Math.max(a.length, b.length);
13
- const matrix = Array.from({ length: a.length + 1 }, (_, i) =>
14
- Array.from({ length: b.length + 1 }, (_, j) => (i === 0 ? j : j === 0 ? i : 0)),
15
- );
16
- for (let i = 1; i <= a.length; i++) {
17
- for (let j = 1; j <= b.length; j++) {
18
- const cost = a[i - 1] === b[j - 1] ? 0 : 1;
19
- matrix[i][j] = Math.min(matrix[i - 1][j] + 1, matrix[i][j - 1] + 1, matrix[i - 1][j - 1] + cost);
20
- }
21
- }
22
- return matrix[a.length][b.length];
23
- }
24
-
25
- export const SimpleReplacer: Replacer = function* (_content, find) {
26
- yield find;
27
- };
28
-
29
- export const LineTrimmedReplacer: Replacer = function* (content, find) {
30
- const originalLines = content.split("\n");
31
- const searchLines = find.split("\n");
32
- if (searchLines[searchLines.length - 1] === "") searchLines.pop();
33
-
34
- for (let i = 0; i <= originalLines.length - searchLines.length; i++) {
35
- let matches = true;
36
- for (let j = 0; j < searchLines.length; j++) {
37
- if (originalLines[i + j].trim() !== searchLines[j].trim()) {
38
- matches = false;
39
- break;
40
- }
41
- }
42
- if (matches) {
43
- let matchStartIndex = 0;
44
- for (let k = 0; k < i; k++) matchStartIndex += originalLines[k].length + 1;
45
- let matchEndIndex = matchStartIndex;
46
- for (let k = 0; k < searchLines.length; k++) {
47
- matchEndIndex += originalLines[i + k].length;
48
- if (k < searchLines.length - 1) matchEndIndex += 1;
49
- }
50
- yield content.substring(matchStartIndex, matchEndIndex);
51
- }
52
- }
53
- };
54
-
55
- export const BlockAnchorReplacer: Replacer = function* (content, find) {
56
- const originalLines = content.split("\n");
57
- const searchLines = find.split("\n");
58
- if (searchLines.length < 3) return;
59
- if (searchLines[searchLines.length - 1] === "") searchLines.pop();
60
-
61
- const firstLineSearch = searchLines[0].trim();
62
- const lastLineSearch = searchLines[searchLines.length - 1].trim();
63
- const searchBlockSize = searchLines.length;
64
-
65
- const candidates: Array<{ startLine: number; endLine: number }> = [];
66
- for (let i = 0; i < originalLines.length; i++) {
67
- if (originalLines[i].trim() !== firstLineSearch) continue;
68
- for (let j = i + 2; j < originalLines.length; j++) {
69
- if (originalLines[j].trim() === lastLineSearch) {
70
- candidates.push({ startLine: i, endLine: j });
71
- break;
72
- }
73
- }
74
- }
75
-
76
- if (candidates.length === 0) return;
77
-
78
- if (candidates.length === 1) {
79
- const { startLine, endLine } = candidates[0];
80
- const actualBlockSize = endLine - startLine + 1;
81
- let similarity = 0;
82
- let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
83
-
84
- if (linesToCheck > 0) {
85
- for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
86
- const originalLine = originalLines[startLine + j].trim();
87
- const searchLine = searchLines[j].trim();
88
- const maxLen = Math.max(originalLine.length, searchLine.length);
89
- if (maxLen === 0) continue;
90
- const distance = levenshtein(originalLine, searchLine);
91
- similarity += (1 - distance / maxLen) / linesToCheck;
92
- if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) break;
93
- }
94
- } else {
95
- similarity = 1.0;
96
- }
97
-
98
- if (similarity >= SINGLE_CANDIDATE_SIMILARITY_THRESHOLD) {
99
- let matchStartIndex = 0;
100
- for (let k = 0; k < startLine; k++) matchStartIndex += originalLines[k].length + 1;
101
- let matchEndIndex = matchStartIndex;
102
- for (let k = startLine; k <= endLine; k++) {
103
- matchEndIndex += originalLines[k].length;
104
- if (k < endLine) matchEndIndex += 1;
105
- }
106
- yield content.substring(matchStartIndex, matchEndIndex);
107
- }
108
- return;
109
- }
110
-
111
- let bestMatch: { startLine: number; endLine: number } | null = null;
112
- let maxSimilarity = -1;
113
-
114
- for (const candidate of candidates) {
115
- const { startLine, endLine } = candidate;
116
- const actualBlockSize = endLine - startLine + 1;
117
- let similarity = 0;
118
- let linesToCheck = Math.min(searchBlockSize - 2, actualBlockSize - 2);
119
-
120
- if (linesToCheck > 0) {
121
- for (let j = 1; j < searchBlockSize - 1 && j < actualBlockSize - 1; j++) {
122
- const originalLine = originalLines[startLine + j].trim();
123
- const searchLine = searchLines[j].trim();
124
- const maxLen = Math.max(originalLine.length, searchLine.length);
125
- if (maxLen === 0) continue;
126
- const distance = levenshtein(originalLine, searchLine);
127
- similarity += 1 - distance / maxLen;
128
- }
129
- similarity /= linesToCheck;
130
- } else {
131
- similarity = 1.0;
132
- }
133
-
134
- if (similarity > maxSimilarity) {
135
- maxSimilarity = similarity;
136
- bestMatch = candidate;
137
- }
138
- }
139
-
140
- if (maxSimilarity >= MULTIPLE_CANDIDATES_SIMILARITY_THRESHOLD && bestMatch) {
141
- const { startLine, endLine } = bestMatch;
142
- let matchStartIndex = 0;
143
- for (let k = 0; k < startLine; k++) matchStartIndex += originalLines[k].length + 1;
144
- let matchEndIndex = matchStartIndex;
145
- for (let k = startLine; k <= endLine; k++) {
146
- matchEndIndex += originalLines[k].length;
147
- if (k < endLine) matchEndIndex += 1;
148
- }
149
- yield content.substring(matchStartIndex, matchEndIndex);
150
- }
151
- };
152
-
153
- export const WhitespaceNormalizedReplacer: Replacer = function* (content, find) {
154
- const normalizeWhitespace = (text: string) => text.replace(/\s+/g, " ").trim();
155
- const normalizedFind = normalizeWhitespace(find);
156
-
157
- const lines = content.split("\n");
158
- for (let i = 0; i < lines.length; i++) {
159
- const line = lines[i];
160
- if (normalizeWhitespace(line) === normalizedFind) {
161
- yield line;
162
- } else {
163
- const normalizedLine = normalizeWhitespace(line);
164
- if (normalizedLine.includes(normalizedFind)) {
165
- const words = find.trim().split(/\s+/);
166
- if (words.length > 0) {
167
- const pattern = words.map((word) => word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("\\s+");
168
- try {
169
- const match = line.match(new RegExp(pattern));
170
- if (match) yield match[0];
171
- } catch { }
172
- }
173
- }
174
- }
175
- }
176
-
177
- const findLines = find.split("\n");
178
- if (findLines.length > 1) {
179
- for (let i = 0; i <= lines.length - findLines.length; i++) {
180
- const block = lines.slice(i, i + findLines.length);
181
- if (normalizeWhitespace(block.join("\n")) === normalizedFind) {
182
- yield block.join("\n");
183
- }
184
- }
185
- }
186
- };
187
-
188
- export const IndentationFlexibleReplacer: Replacer = function* (content, find) {
189
- const removeIndentation = (text: string) => {
190
- const lines = text.split("\n");
191
- const nonEmptyLines = lines.filter((line) => line.trim().length > 0);
192
- if (nonEmptyLines.length === 0) return text;
193
- const minIndent = Math.min(...nonEmptyLines.map(line => line.match(/^(\s*)/)?.[1].length ?? 0));
194
- return lines.map((line) => (line.trim().length === 0 ? line : line.slice(minIndent))).join("\n");
195
- };
196
-
197
- const normalizedFind = removeIndentation(find);
198
- const contentLines = content.split("\n");
199
- const findLines = find.split("\n");
200
-
201
- for (let i = 0; i <= contentLines.length - findLines.length; i++) {
202
- const block = contentLines.slice(i, i + findLines.length).join("\n");
203
- if (removeIndentation(block) === normalizedFind) yield block;
204
- }
205
- };
206
-
207
- export const EscapeNormalizedReplacer: Replacer = function* (content, find) {
208
- const unescapeString = (str: string): string => {
209
- return str.replace(/\\(n|t|r|'|"|`|\\|\n|\$)/g, (match, capturedChar) => {
210
- switch (capturedChar) {
211
- case "n": return "\n";
212
- case "t": return "\t";
213
- case "r": return "\r";
214
- default: return capturedChar === match[1] ? match[1] : match;
215
- }
216
- });
217
- };
218
- const unescapedFind = unescapeString(find);
219
- if (content.includes(unescapedFind)) yield unescapedFind;
220
-
221
- const lines = content.split("\n");
222
- const findLines = unescapedFind.split("\n");
223
- for (let i = 0; i <= lines.length - findLines.length; i++) {
224
- const block = lines.slice(i, i + findLines.length).join("\n");
225
- if (unescapeString(block) === unescapedFind) yield block;
226
- }
227
- };
228
-
229
- export const MultiOccurrenceReplacer: Replacer = function* (content, find) {
230
- let startIndex = 0;
231
- while (true) {
232
- const index = content.indexOf(find, startIndex);
233
- if (index === -1) break;
234
- yield find;
235
- startIndex = index + find.length;
236
- }
237
- };
238
-
239
- export const TrimmedBoundaryReplacer: Replacer = function* (content, find) {
240
- const trimmedFind = find.trim();
241
- if (trimmedFind === find) return;
242
- if (content.includes(trimmedFind)) yield trimmedFind;
243
-
244
- const lines = content.split("\n");
245
- const findLines = find.split("\n");
246
- for (let i = 0; i <= lines.length - findLines.length; i++) {
247
- const block = lines.slice(i, i + findLines.length).join("\n");
248
- if (block.trim() === trimmedFind) yield block;
249
- }
250
- };
251
-
252
- export const ContextAwareReplacer: Replacer = function* (content, find) {
253
- const findLines = find.split("\n");
254
- if (findLines.length < 3) return;
255
- if (findLines[findLines.length - 1] === "") findLines.pop();
256
-
257
- const contentLines = content.split("\n");
258
- const firstLine = findLines[0].trim();
259
- const lastLine = findLines[findLines.length - 1].trim();
260
-
261
- for (let i = 0; i < contentLines.length; i++) {
262
- if (contentLines[i].trim() !== firstLine) continue;
263
- for (let j = i + 2; j < contentLines.length; j++) {
264
- if (contentLines[j].trim() === lastLine) {
265
- const blockLines = contentLines.slice(i, j + 1);
266
- const block = blockLines.join("\n");
267
- if (blockLines.length === findLines.length) {
268
- let matchingLines = 0;
269
- let totalNonEmptyLines = 0;
270
- for (let k = 1; k < blockLines.length - 1; k++) {
271
- const blockLine = blockLines[k].trim();
272
- const findLine = findLines[k].trim();
273
- if (blockLine.length > 0 || findLine.length > 0) {
274
- totalNonEmptyLines++;
275
- if (blockLine === findLine) matchingLines++;
276
- }
277
- }
278
- if (totalNonEmptyLines === 0 || matchingLines / totalNonEmptyLines >= 0.5) {
279
- yield block;
280
- break;
281
- }
282
- }
283
- break;
284
- }
285
- }
286
- }
287
- };
288
-
289
- export function replaceCode(content: string, oldString: string, newString: string, replaceAll = false): string {
290
- if (oldString === newString) throw new Error("No changes to apply: oldString and newString are identical.");
291
- let notFound = true;
292
-
293
- for (const replacer of [
294
- SimpleReplacer,
295
- LineTrimmedReplacer,
296
- BlockAnchorReplacer,
297
- WhitespaceNormalizedReplacer,
298
- IndentationFlexibleReplacer,
299
- EscapeNormalizedReplacer,
300
- TrimmedBoundaryReplacer,
301
- ContextAwareReplacer,
302
- MultiOccurrenceReplacer,
303
- ]) {
304
- for (const search of replacer(content, oldString)) {
305
- const index = content.indexOf(search);
306
- if (index === -1) continue;
307
- notFound = false;
308
- if (replaceAll) return content.replaceAll(search, newString);
309
- const lastIndex = content.lastIndexOf(search);
310
- if (index !== lastIndex) continue;
311
- return content.substring(0, index) + newString + content.substring(index + search.length);
312
- }
313
- }
314
-
315
- if (notFound) throw new Error("Could not find oldString in the file. It must match exactly, including whitespace, indentation, and line endings.");
316
- throw new Error("Found multiple matches for oldString. Provide more surrounding context to make the match unique.");
317
- }