@wix/ditto-codegen-public 1.0.366 → 1.0.367
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.
- package/dist/opencode-tools/batch-write.ts +27 -3
- package/dist/out.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { tool } from "@opencode-ai/plugin";
|
|
2
|
-
import { writeFile, mkdir } from "fs/promises";
|
|
2
|
+
import { writeFile, mkdir, stat } from "fs/promises";
|
|
3
3
|
import { join, dirname, isAbsolute } from "path";
|
|
4
4
|
|
|
5
|
+
// Overwriting a non-trivial existing file re-emits the whole file (slow/costly);
|
|
6
|
+
// such edits must use multi-edit. Smaller files are scaffolding stubs (allowed).
|
|
7
|
+
const EXISTING_FILE_REWRITE_GUARD_BYTES = 2048;
|
|
8
|
+
|
|
9
|
+
// Size of an existing regular file, or null if absent/not a file (a fresh create).
|
|
10
|
+
async function existingFileSize(path: string): Promise<number | null> {
|
|
11
|
+
try {
|
|
12
|
+
const s = await stat(path);
|
|
13
|
+
return s.isFile() ? s.size : null;
|
|
14
|
+
} catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
function unescapeString(str: string): string {
|
|
6
20
|
return str.replace(/\\(n|t|r|"|\\)/g, (_, c: string) => {
|
|
7
21
|
if (c === "n") return "\n";
|
|
@@ -18,8 +32,8 @@ function normalizeToolString(text: string): string {
|
|
|
18
32
|
|
|
19
33
|
export default tool({
|
|
20
34
|
description:
|
|
21
|
-
"Write multiple files
|
|
22
|
-
"
|
|
35
|
+
"Write multiple new files in one call (creates dirs). " +
|
|
36
|
+
"For an existing file, use multi-edit instead; batch-write rejects overwriting a non-trivial existing file.",
|
|
23
37
|
args: {
|
|
24
38
|
files: tool.schema
|
|
25
39
|
.array(
|
|
@@ -39,6 +53,16 @@ export default tool({
|
|
|
39
53
|
? f.path
|
|
40
54
|
: join(context.directory, f.path);
|
|
41
55
|
try {
|
|
56
|
+
const existingSize = await existingFileSize(fullPath);
|
|
57
|
+
if (
|
|
58
|
+
existingSize !== null &&
|
|
59
|
+
existingSize > EXISTING_FILE_REWRITE_GUARD_BYTES
|
|
60
|
+
) {
|
|
61
|
+
results.push(
|
|
62
|
+
`BLOCKED: ${f.path} exists; use multi-edit to change existing files.`,
|
|
63
|
+
);
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
42
66
|
await mkdir(dirname(fullPath), { recursive: true });
|
|
43
67
|
const content =
|
|
44
68
|
typeof f.content === "string"
|
package/dist/out.js
CHANGED
|
@@ -11246,7 +11246,7 @@ ${(0, prompt_utils_1.formatChatHistory)(recentHistory, "CONVERSATION CONTEXT")}
|
|
|
11246
11246
|
INSTRUCTIONS:
|
|
11247
11247
|
1. Read the latest user request carefully
|
|
11248
11248
|
2. If it asks to CREATE something new, create it as a new extension using skills
|
|
11249
|
-
3. If it asks to MODIFY existing code,
|
|
11249
|
+
3. If it asks to MODIFY existing code, edit only what is needed with \`multi-edit\`; never rewrite a whole file.
|
|
11250
11250
|
4. Do NOT ignore the user's request or substitute your own interpretation`;
|
|
11251
11251
|
}
|
|
11252
11252
|
function buildIterationPrompt(chatHistory) {
|
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.367",
|
|
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": "334ea64feb8da31a445017f2c5a350e11334df997c23ffb1fe7984c9"
|
|
33
33
|
}
|