@wix/ditto-codegen-public 1.0.482 → 1.0.483
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.
|
@@ -2,27 +2,75 @@ import { tool } from "@opencode-ai/plugin";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { join, isAbsolute } from "path";
|
|
4
4
|
|
|
5
|
+
// opencode cuts any tool output over 2,000 lines or 50 KB and saves the rest to
|
|
6
|
+
// a file the agent rarely reads, so every file after the cut is silently lost.
|
|
7
|
+
// Stay well under both limits and name the files that didn't fit instead.
|
|
8
|
+
export const OUTPUT_LIMIT = { bytes: 40 * 1024, lines: 1500 };
|
|
9
|
+
|
|
10
|
+
const SECTION_SEPARATOR = "\n\n";
|
|
11
|
+
|
|
12
|
+
async function readSection(
|
|
13
|
+
filePath: string,
|
|
14
|
+
directory: string,
|
|
15
|
+
): Promise<string> {
|
|
16
|
+
const fullPath = isAbsolute(filePath) ? filePath : join(directory, filePath);
|
|
17
|
+
try {
|
|
18
|
+
const content = await readFile(fullPath, "utf-8");
|
|
19
|
+
return `--- ${filePath} ---\n${content}`;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
22
|
+
return `--- ${filePath} ---\nERROR: ${msg}`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function notReadSection(paths: string[]): string {
|
|
27
|
+
return (
|
|
28
|
+
`--- NOT READ (output limit) ---\n` +
|
|
29
|
+
`These files were not read, to keep this output under the tool output limit. ` +
|
|
30
|
+
`Read them with another batch-read call:\n` +
|
|
31
|
+
paths.map((path) => `- ${path}`).join("\n")
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
5
35
|
export default tool({
|
|
6
36
|
description:
|
|
7
37
|
"Read multiple files at once and return their contents. " +
|
|
8
|
-
"Use this instead of calling read multiple times sequentially."
|
|
38
|
+
"Use this instead of calling read multiple times sequentially. " +
|
|
39
|
+
`Returns whole files, in order, up to about ${OUTPUT_LIMIT.bytes / 1024} KB and ${OUTPUT_LIMIT.lines} lines per call; ` +
|
|
40
|
+
"any files past that are listed as not read, so read them in another call.",
|
|
9
41
|
args: {
|
|
10
42
|
paths: tool.schema
|
|
11
43
|
.array(tool.schema.string())
|
|
12
44
|
.describe("Array of file paths (relative to project root) to read"),
|
|
13
45
|
},
|
|
14
46
|
async execute(args, context) {
|
|
15
|
-
const
|
|
47
|
+
const sections: string[] = [];
|
|
48
|
+
const notRead: string[] = [];
|
|
49
|
+
let bytes = 0;
|
|
50
|
+
let lines = 0;
|
|
16
51
|
for (const filePath of args.paths) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
52
|
+
if (notRead.length > 0) {
|
|
53
|
+
notRead.push(filePath);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const section = await readSection(filePath, context.directory);
|
|
57
|
+
const sectionBytes =
|
|
58
|
+
Buffer.byteLength(section) + SECTION_SEPARATOR.length;
|
|
59
|
+
const sectionLines = section.split("\n").length + 1;
|
|
60
|
+
// The first file always goes in: alone, it is no worse than a plain read.
|
|
61
|
+
const fits =
|
|
62
|
+
sections.length === 0 ||
|
|
63
|
+
(bytes + sectionBytes <= OUTPUT_LIMIT.bytes &&
|
|
64
|
+
lines + sectionLines <= OUTPUT_LIMIT.lines);
|
|
65
|
+
if (!fits) {
|
|
66
|
+
notRead.push(filePath);
|
|
67
|
+
continue;
|
|
24
68
|
}
|
|
69
|
+
sections.push(section);
|
|
70
|
+
bytes += sectionBytes;
|
|
71
|
+
lines += sectionLines;
|
|
25
72
|
}
|
|
26
|
-
|
|
73
|
+
if (notRead.length > 0) sections.push(notReadSection(notRead));
|
|
74
|
+
return sections.join(SECTION_SEPARATOR);
|
|
27
75
|
},
|
|
28
76
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/ditto-codegen-public",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.483",
|
|
4
4
|
"description": "AI-powered Wix CLI app generator - standalone executable",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "node build.mjs",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"esbuild": "^0.27.2",
|
|
30
30
|
"vitest": "^4.0.16"
|
|
31
31
|
},
|
|
32
|
-
"falconPackageHash": "
|
|
32
|
+
"falconPackageHash": "08e5c0c0beef6a0acb833061c90a5e77d57ad5d9f552a1b4ee922c0b"
|
|
33
33
|
}
|