@wix/ditto-codegen-public 1.0.524 → 1.0.526
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/checks/sdk-runtime-check.ts +1834 -0
- package/dist/out.js +215 -8
- package/package.json +2 -2
package/dist/out.js
CHANGED
|
@@ -12733,12 +12733,17 @@ var require_code_edits_scope = __commonJS({
|
|
|
12733
12733
|
exports2.CODE_EDITS_SCOPE_RULES = void 0;
|
|
12734
12734
|
exports2.CODE_EDITS_SCOPE_RULES = `# Code Edits Scope Rules
|
|
12735
12735
|
|
|
12736
|
-
When the request lists
|
|
12736
|
+
When the request lists extensions (each with a type) alongside a broader description:
|
|
12737
12737
|
|
|
12738
|
-
1. **
|
|
12739
|
-
2. **
|
|
12740
|
-
3. **
|
|
12741
|
-
4. **Report only what you built
|
|
12738
|
+
1. **Generate exactly the listed extensions**, plus any extension a listed one cannot work without (an embedded script needs a dashboard page that calls \`embedScript()\`).
|
|
12739
|
+
2. **The rest of the description is built elsewhere** (for example as native elements). Do not implement it, even if the request reads as if you should.
|
|
12740
|
+
3. **What the user asked of a listed extension is part of its item**, even when the item leaves it out.
|
|
12741
|
+
4. **Report only what you built**, each companion extension and why, and anything asked of a listed extension you did not do.
|
|
12742
|
+
|
|
12743
|
+
When working from an existing extension:
|
|
12744
|
+
|
|
12745
|
+
5. **A variant starts from a copy of the original's code**, including the local files it imports; change only what is asked. Restore a look from the code that had it.
|
|
12746
|
+
6. **Keep what the request does not change.** After changing sizes, spacing or structure, check the code that depends on them, such as size-based animations.`;
|
|
12742
12747
|
}
|
|
12743
12748
|
});
|
|
12744
12749
|
|
|
@@ -14250,7 +14255,8 @@ ${environmentIdentity}`;
|
|
|
14250
14255
|
- Match their technical level: include code/technical detail only if their request was technical; otherwise describe the outcome in plain language (no code, file/type names, or internals).
|
|
14251
14256
|
- List any manual setup the user must still do for the feature to work, as short "next steps" (e.g. installing a dependent app or enabling a dashboard setting).
|
|
14252
14257
|
- Be honest: if you didn't fully build what was asked (e.g. stored data but didn't send it), say so. Keep it short.`;
|
|
14253
|
-
exports2.OUTCOME_MESSAGE_RULES = `- Lead with whether the request succeeded or failed and what changed (e.g. "Added\u2026", "Removed\u2026"). Never report validation, build, or type-check status as the outcome, and re-state the outcome in your last message even if you already said it earlier
|
|
14258
|
+
exports2.OUTCOME_MESSAGE_RULES = `- Lead with whether the request succeeded or failed and what changed (e.g. "Added\u2026", "Removed\u2026"). Never report validation, build, or type-check status as the outcome, and re-state the outcome in your last message even if you already said it earlier.
|
|
14259
|
+
- You cannot see how the result renders: never say a look is restored or visible, say to check it on the page. If you changed a component's default props, say that copies already on the page keep their current values.`;
|
|
14254
14260
|
function buildFileOperationsRules(multiEditContextClause) {
|
|
14255
14261
|
return `- Package dependencies \u2014 \`npm install <pkg>\` any package not already in \`package.json\` BEFORE the first \`validate\` (do NOT wait for \`TS2307\`); install all needed packages in ONE command, except heavy ones: the sandbox has a memory limit and an install that exceeds it kills the machine and loses the whole run, so install those in several smaller commands. Do NOT hand-edit \`package.json\` for deps unless npm cannot be used. Never pass \`--package-lock=false\`.
|
|
14256
14262
|
- File operations \u2014 pick the BATCH tool whenever you have 2+ files; the single-file variants are 5\u201310\xD7 slower:
|
|
@@ -120762,7 +120768,9 @@ var require_write_plugin = __commonJS({
|
|
|
120762
120768
|
"dist/opencode-integration/plugins/write-plugin.js"(exports2) {
|
|
120763
120769
|
"use strict";
|
|
120764
120770
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
120771
|
+
exports2.OPENCODE_CHECKS_DIR = void 0;
|
|
120765
120772
|
exports2.writeGeneratedPlugin = writeGeneratedPlugin;
|
|
120773
|
+
exports2.writeCheckScript = writeCheckScript;
|
|
120766
120774
|
var promises_1 = require("fs/promises");
|
|
120767
120775
|
var os_1 = require("os");
|
|
120768
120776
|
var path_12 = require("path");
|
|
@@ -120773,6 +120781,12 @@ var require_write_plugin = __commonJS({
|
|
|
120773
120781
|
await (0, promises_1.writeFile)((0, path_12.join)(OPENCODE_PLUGIN_DIR, filename), source, "utf-8");
|
|
120774
120782
|
logger_12.logger.info("[OpenCode] Wrote generated plugin", { plugin: filename });
|
|
120775
120783
|
}
|
|
120784
|
+
exports2.OPENCODE_CHECKS_DIR = (0, path_12.join)((0, os_1.homedir)(), ".config", "opencode", "checks");
|
|
120785
|
+
async function writeCheckScript(filename, source) {
|
|
120786
|
+
await (0, promises_1.mkdir)(exports2.OPENCODE_CHECKS_DIR, { recursive: true });
|
|
120787
|
+
await (0, promises_1.writeFile)((0, path_12.join)(exports2.OPENCODE_CHECKS_DIR, filename), source, "utf-8");
|
|
120788
|
+
logger_12.logger.info("[OpenCode] Wrote check script", { script: filename });
|
|
120789
|
+
}
|
|
120776
120790
|
}
|
|
120777
120791
|
});
|
|
120778
120792
|
|
|
@@ -121068,6 +121082,75 @@ var require_skills_override = __commonJS({
|
|
|
121068
121082
|
}
|
|
121069
121083
|
});
|
|
121070
121084
|
|
|
121085
|
+
// dist/validation/sdk-runtime-report.js
|
|
121086
|
+
var require_sdk_runtime_report = __commonJS({
|
|
121087
|
+
"dist/validation/sdk-runtime-report.js"(exports2) {
|
|
121088
|
+
"use strict";
|
|
121089
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121090
|
+
exports2.sdkRuntimeMessage = sdkRuntimeMessage;
|
|
121091
|
+
exports2.sdkRuntimeTelemetry = sdkRuntimeTelemetry;
|
|
121092
|
+
exports2.isSdkRuntimeCheckOn = isSdkRuntimeCheckOn;
|
|
121093
|
+
function sdkRuntimeMessage(report, blocks) {
|
|
121094
|
+
const MAX_BLOCKS = 2;
|
|
121095
|
+
const failing = (Array.isArray(report.failing) ? report.failing : []).filter((finding) => typeof finding?.key === "string" && typeof finding?.text === "string");
|
|
121096
|
+
const notes = (Array.isArray(report.notes) ? report.notes : []).filter((note) => typeof note === "string");
|
|
121097
|
+
const counted = failing.map((finding) => {
|
|
121098
|
+
const count = (blocks.get(finding.key) ?? 0) + 1;
|
|
121099
|
+
blocks.set(finding.key, count);
|
|
121100
|
+
return { ...finding, isBlocking: count <= MAX_BLOCKS };
|
|
121101
|
+
});
|
|
121102
|
+
const blocking = counted.filter((finding) => finding.isBlocking);
|
|
121103
|
+
const noted = [
|
|
121104
|
+
...notes,
|
|
121105
|
+
...counted.filter((finding) => !finding.isBlocking).map((finding) => `${finding.text}
|
|
121106
|
+
(still rejected after ${MAX_BLOCKS} fixes, so it no longer blocks: say in your final message that this call may fail)`)
|
|
121107
|
+
];
|
|
121108
|
+
const line = failing.length > 0 && blocking.length === 0 ? `SDK runtime check: still failing after ${MAX_BLOCKS} attempts, not blocking` : typeof report.line === "string" ? report.line : "";
|
|
121109
|
+
const noteText = noted.length ? [
|
|
121110
|
+
"Also noticed, not failing validate (some come from made-up arguments, so check whether the call itself is wrong):",
|
|
121111
|
+
...noted
|
|
121112
|
+
].join("\n") : "";
|
|
121113
|
+
if (blocking.length === 0)
|
|
121114
|
+
return [line, noteText].filter(Boolean).join("\n") || void 0;
|
|
121115
|
+
return [
|
|
121116
|
+
line,
|
|
121117
|
+
"FAILED at SDK runtime check: this project typechecks but would break when it runs.",
|
|
121118
|
+
"What the check did: it called each exported async function that uses a Wix SDK, and each SDK read inside a component, effect or handler (taken out to be run), with placeholder arguments, against this site. Reads were sent to the real Wix service; writes were answered locally and not sent, except updates and deletes aimed at a made-up id when the opt-in write probe is on. It also read the changed files for SDK use that fails at runtime.",
|
|
121119
|
+
...blocking.map((finding) => finding.text),
|
|
121120
|
+
blocking.some((finding) => finding.missingApp !== true) ? "For a rejected request, look up the method with ReadFullDocsMethodSchema and use the query builder or the shapes it shows. For a host module, use the matching site service. For a bare call in an event handler or service plugin, wrap it in auth.elevate. Then run validate again." : "",
|
|
121121
|
+
blocking.some((finding) => finding.missingApp === true) ? "For a call the site lacks the app for, rewriting the call does not help. Run the wix-site-installed-apps check for the app this feature needs and follow its rule for a missing app: undo the files you added or changed for this feature in this session, path by path, and reply in one short message naming the app the user must install. Then run validate again." : "",
|
|
121122
|
+
noteText
|
|
121123
|
+
].filter(Boolean).join("\n");
|
|
121124
|
+
}
|
|
121125
|
+
function sdkRuntimeTelemetry(report, message, durationMs, reason) {
|
|
121126
|
+
const MAX_FINDINGS = 20;
|
|
121127
|
+
const MAX_TEXT = 500;
|
|
121128
|
+
const line = typeof report?.line === "string" ? report.line : "";
|
|
121129
|
+
if (report && !line)
|
|
121130
|
+
return void 0;
|
|
121131
|
+
const findings = (Array.isArray(report?.failing) ? report.failing : []).filter((finding) => typeof finding?.key === "string" && typeof finding?.text === "string").slice(0, MAX_FINDINGS).map((finding) => ({
|
|
121132
|
+
key: finding.key.slice(0, MAX_TEXT),
|
|
121133
|
+
// The request body can carry literals from the project's components: kept out of the logs.
|
|
121134
|
+
text: finding.text.replace(/\n\s*request body:[^]*?(?=\n\s*\(|$)/, "").slice(0, MAX_TEXT),
|
|
121135
|
+
missingApp: finding.missingApp === true
|
|
121136
|
+
}));
|
|
121137
|
+
const notes = Array.isArray(report?.notes) ? report.notes.length : 0;
|
|
121138
|
+
const status = !report ? "skipped" : /^SDK runtime check: FAILED/.test(line) ? "failed" : /^SDK runtime check: OK/.test(line) ? "ok" : "skipped";
|
|
121139
|
+
return {
|
|
121140
|
+
status,
|
|
121141
|
+
blocked: /^FAILED at SDK runtime check/m.test(message ?? ""),
|
|
121142
|
+
summary: (report ? line : `SDK runtime check: skipped (${reason ?? "no report"})`).slice(0, MAX_TEXT),
|
|
121143
|
+
findings,
|
|
121144
|
+
notes,
|
|
121145
|
+
durationMs: Math.round(durationMs)
|
|
121146
|
+
};
|
|
121147
|
+
}
|
|
121148
|
+
function isSdkRuntimeCheckOn(env) {
|
|
121149
|
+
return env.CODEGEN_ENVIRONMENT === "STUDIO_2";
|
|
121150
|
+
}
|
|
121151
|
+
}
|
|
121152
|
+
});
|
|
121153
|
+
|
|
121071
121154
|
// dist/validation/user-source-port.js
|
|
121072
121155
|
var require_user_source_port = __commonJS({
|
|
121073
121156
|
"dist/validation/user-source-port.js"(exports2) {
|
|
@@ -121110,25 +121193,33 @@ var require_validation_state = __commonJS({
|
|
|
121110
121193
|
"dist/opencode-integration/plugins/validation-state.js"(exports2) {
|
|
121111
121194
|
"use strict";
|
|
121112
121195
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
121113
|
-
exports2.VALIDATION_NUDGE = exports2.USER_SOURCE_SCAN = exports2.USER_ATTACHMENTS_LIST = exports2.VALIDATION_STATE_PLUGIN_FILENAME = exports2.VALIDATION_LOADED_EVENT_TYPE = exports2.VALIDATION_STATE_EVENT_TYPE = void 0;
|
|
121196
|
+
exports2.VALIDATION_NUDGE = exports2.SDK_RUNTIME_CHECK = exports2.USER_SOURCE_SCAN = exports2.USER_ATTACHMENTS_LIST = exports2.VALIDATION_STATE_PLUGIN_FILENAME = exports2.SDK_RUNTIME_EVENT_TYPE = exports2.VALIDATION_LOADED_EVENT_TYPE = exports2.VALIDATION_STATE_EVENT_TYPE = void 0;
|
|
121114
121197
|
exports2.isReadOnlyShellCommand = isReadOnlyShellCommand;
|
|
121115
121198
|
exports2.validationFailureDetail = validationFailureDetail;
|
|
121116
121199
|
exports2.buildValidationStateSource = buildValidationStateSource;
|
|
121117
121200
|
exports2.writeValidationStatePlugin = writeValidationStatePlugin;
|
|
121201
|
+
var promises_1 = require("fs/promises");
|
|
121118
121202
|
var write_plugin_1 = require_write_plugin();
|
|
121203
|
+
var logger_12 = require_logger();
|
|
121119
121204
|
var detect_1 = require_detect();
|
|
121120
121205
|
var prepare_created_by_1 = require_prepare_created_by();
|
|
121121
121206
|
var repository_status_1 = require_repository_status();
|
|
121207
|
+
var path_12 = require("path");
|
|
121208
|
+
var install_manifest_1 = require_install_manifest();
|
|
121122
121209
|
var skills_override_12 = require_skills_override();
|
|
121210
|
+
var sdk_runtime_report_1 = require_sdk_runtime_report();
|
|
121123
121211
|
var user_source_port_1 = require_user_source_port();
|
|
121124
121212
|
function isReadOnlyShellCommand(command) {
|
|
121125
121213
|
return /^(?:ls|pwd|cat|head|tail|wc|grep)(?:[ \t]+[A-Za-z0-9_./:@%+=,-]+)*[ \t]*$/.test(command) || /^git[ \t]+(?:status|diff|log|show)(?:[ \t]+(?!--(?:output|ext-diff|textconv))[A-Za-z0-9_./:@%+=,-]+)*[ \t]*$/.test(command) || /^node[ \t]+(['"]?)\/root\/\.agents\/skills\/wix-app\/scripts\/(?:scan-a11y-(?:review|code|eslint|render)|scan-user-source|render-images)\.cjs\1(?:[ \t]+(?:[A-Za-z0-9_./:@%+=,-]+|'[^'\n]*'|"[^"\n$`\\]*"))*[ \t]*$/.test(command);
|
|
121126
121214
|
}
|
|
121127
121215
|
exports2.VALIDATION_STATE_EVENT_TYPE = "validation_state";
|
|
121128
121216
|
exports2.VALIDATION_LOADED_EVENT_TYPE = "validation_loaded";
|
|
121217
|
+
exports2.SDK_RUNTIME_EVENT_TYPE = "sdk_runtime_check";
|
|
121129
121218
|
exports2.VALIDATION_STATE_PLUGIN_FILENAME = "validation-state.ts";
|
|
121130
121219
|
exports2.USER_ATTACHMENTS_LIST = ".wix/agentInput/userAttachments.json";
|
|
121131
121220
|
exports2.USER_SOURCE_SCAN = `${skills_override_12.SKILLS_DIR}/wix-app/scripts/scan-user-source.cjs`;
|
|
121221
|
+
var SDK_RUNTIME_CHECK_FILENAME = "sdk-runtime-check.mts";
|
|
121222
|
+
exports2.SDK_RUNTIME_CHECK = (0, path_12.join)(write_plugin_1.OPENCODE_CHECKS_DIR, SDK_RUNTIME_CHECK_FILENAME);
|
|
121132
121223
|
exports2.VALIDATION_NUDGE = "Project files need validation. Follow your validation workflow (delegate to codegen-validator if your instructions require it), run validate({ runBuild: true }), and fix any errors before finishing. Your last message is shown to the user: once validation passes, end with a short plain-language summary for them: what changed, and if there is something you could not do, why and what they need to do next. Do not mention validation.";
|
|
121133
121224
|
function validationFailureDetail(output) {
|
|
121134
121225
|
const MAX_FAILURE_DETAIL_CHARS = 1800;
|
|
@@ -121145,6 +121236,7 @@ var require_validation_state = __commonJS({
|
|
|
121145
121236
|
return String.raw`// Generated by @wix/ditto-codegen (validation-state). Do not edit.
|
|
121146
121237
|
const EVENT_TYPE = ${JSON.stringify(exports2.VALIDATION_STATE_EVENT_TYPE)};
|
|
121147
121238
|
const LOADED_EVENT_TYPE = ${JSON.stringify(exports2.VALIDATION_LOADED_EVENT_TYPE)};
|
|
121239
|
+
const SDK_EVENT_TYPE = ${JSON.stringify(exports2.SDK_RUNTIME_EVENT_TYPE)};
|
|
121148
121240
|
const VALIDATION_NUDGE = ${JSON.stringify(exports2.VALIDATION_NUDGE)};
|
|
121149
121241
|
const BUILDERS = ${JSON.stringify(detect_1.BUILDER_EXTENSION_TYPES)};
|
|
121150
121242
|
const injectCreatedBy = ${detect_1.injectCreatedBy.toString()};
|
|
@@ -121158,6 +121250,10 @@ const changedEditorComponents = ${user_source_port_1.changedEditorComponents.toS
|
|
|
121158
121250
|
const copiedComponentFindings = ${user_source_port_1.copiedComponentFindings.toString()};
|
|
121159
121251
|
const portCheckError = ${user_source_port_1.portCheckError.toString()};
|
|
121160
121252
|
const portCheckNote = ${user_source_port_1.portCheckNote.toString()};
|
|
121253
|
+
const SDK_RUNTIME_CHECK = ${JSON.stringify(exports2.SDK_RUNTIME_CHECK)};
|
|
121254
|
+
const sdkRuntimeMessage = ${sdk_runtime_report_1.sdkRuntimeMessage.toString()};
|
|
121255
|
+
const sdkRuntimeTelemetry = ${sdk_runtime_report_1.sdkRuntimeTelemetry.toString()};
|
|
121256
|
+
const isSdkRuntimeCheckOn = ${sdk_runtime_report_1.isSdkRuntimeCheckOn.toString()};
|
|
121161
121257
|
const MUTATING_TOOLS = new Set(["write", "edit", "apply_patch", "batch-write", "multi-edit", "wix-generate", "bash"]);
|
|
121162
121258
|
|
|
121163
121259
|
export const ValidationState = async ({ client, directory, $ }) => {
|
|
@@ -121233,6 +121329,92 @@ export const ValidationState = async ({ client, directory, $ }) => {
|
|
|
121233
121329
|
return undefined;
|
|
121234
121330
|
};
|
|
121235
121331
|
|
|
121332
|
+
// The check runs the project's SDK calls (see opencode-tools/checks/sdk-runtime-check.ts) and
|
|
121333
|
+
// prints one JSON report. Each finding blocks at most twice, which sdkRuntimeMessage counts.
|
|
121334
|
+
const sdkBlocks = new Map();
|
|
121335
|
+
// Content of each file at the last check that came out clean. Only files that differ from it
|
|
121336
|
+
// are checked again: a failing or skipped check leaves it alone, so what failed is checked again.
|
|
121337
|
+
let sdkClean = new Map();
|
|
121338
|
+
// Over the target limit a check runs part of what changed; the targets it ran cleanly wait
|
|
121339
|
+
// their turn while the files stay as they were then (sdkRanHashes).
|
|
121340
|
+
let sdkRan = [];
|
|
121341
|
+
let sdkRanHashes;
|
|
121342
|
+
// A capped check that ran some targets leaves the run not validated, so the agent validates
|
|
121343
|
+
// again and the next check runs the rest.
|
|
121344
|
+
let sdkPending = false;
|
|
121345
|
+
const MAX_SDK_CHANGED = 300;
|
|
121346
|
+
// Any number of them, so they go in a file rather than on the command line, outside the
|
|
121347
|
+
// project so that writing it changes nothing validate sees, and named for this plugin
|
|
121348
|
+
// instance so that runs sharing a machine do not overwrite each other's.
|
|
121349
|
+
const SDK_RAN_FILE = (process.env.TMPDIR || "/tmp").replace(/\/$/, "") +
|
|
121350
|
+
"/codegen-sdk-runtime-ran-" + Date.now().toString(36) + Math.random().toString(36).slice(2) + ".txt";
|
|
121351
|
+
const fileHash = async (path) => {
|
|
121352
|
+
const file = Bun.file(directory + "/" + path);
|
|
121353
|
+
if (!(await file.exists())) return "<deleted>";
|
|
121354
|
+
const hash = new Bun.CryptoHasher("sha256");
|
|
121355
|
+
hash.update(await file.arrayBuffer());
|
|
121356
|
+
return hash.digest("hex");
|
|
121357
|
+
};
|
|
121358
|
+
// One row per check run, which the executor logs (see sdkRuntimeTelemetry).
|
|
121359
|
+
const logSdkRuntime = (sessionID, startedAt, report, message, reason) => {
|
|
121360
|
+
const row = sdkRuntimeTelemetry(report, message, Date.now() - startedAt, reason);
|
|
121361
|
+
if (row) process.stdout.write(JSON.stringify({ type: SDK_EVENT_TYPE, sessionID, ...row }) + "\n");
|
|
121362
|
+
};
|
|
121363
|
+
const checkSdkRuntime = async (sessionID) => {
|
|
121364
|
+
sdkPending = false;
|
|
121365
|
+
if (!isSdkRuntimeCheckOn(process.env) || !(await Bun.file(SDK_RUNTIME_CHECK).exists())) return undefined;
|
|
121366
|
+
const baseline = process.env.CODEGEN_VALIDATION_BASELINE;
|
|
121367
|
+
const candidates = [...new Set([
|
|
121368
|
+
...await git(baseline ? ["diff", "--name-only", "--no-renames", "-z", baseline] : ["ls-files", "--cached", "-z"]),
|
|
121369
|
+
...await git(["ls-files", "--others", "--exclude-standard", "-z"]),
|
|
121370
|
+
])].filter((path) => !path.startsWith(".agents/")).sort();
|
|
121371
|
+
const hashes = new Map();
|
|
121372
|
+
for (const path of candidates) hashes.set(path, await fileHash(path));
|
|
121373
|
+
const changed = [
|
|
121374
|
+
...candidates.filter((path) => sdkClean.get(path) !== hashes.get(path)),
|
|
121375
|
+
// back to its original content since the last check
|
|
121376
|
+
...[...sdkClean.keys()].filter((path) => !hashes.has(path)),
|
|
121377
|
+
];
|
|
121378
|
+
if (changed.length === 0) return undefined;
|
|
121379
|
+
// Too many to pass as arguments: check everything.
|
|
121380
|
+
const only = changed.length <= MAX_SDK_CHANGED;
|
|
121381
|
+
// node before 22.18 only strips the script's types behind this flag, which newer ones accept.
|
|
121382
|
+
const parts = ["node --experimental-strip-types ", ""];
|
|
121383
|
+
const command = Object.assign(parts, { raw: parts });
|
|
121384
|
+
if (sdkRanHashes && JSON.stringify([...sdkRanHashes]) !== JSON.stringify([...hashes])) sdkRan = [];
|
|
121385
|
+
if (sdkRan.length > 0) await Bun.write(SDK_RAN_FILE, sdkRan.join("\n"));
|
|
121386
|
+
const ran = sdkRan.length > 0 ? ["--ran-file", SDK_RAN_FILE] : [];
|
|
121387
|
+
const args = [SDK_RUNTIME_CHECK, directory, ...(only ? ["--changed", ...changed] : []), ...ran];
|
|
121388
|
+
const startedAt = Date.now();
|
|
121389
|
+
const result = await $(command, args).cwd(directory).nothrow().quiet();
|
|
121390
|
+
// A script node cannot run is reported on the validate line, never thrown and never blocking.
|
|
121391
|
+
const skipped = (why) => {
|
|
121392
|
+
logSdkRuntime(sessionID, startedAt, undefined, undefined, "script could not run: " + why);
|
|
121393
|
+
return "SDK runtime check: skipped (script could not run: " + why + ")";
|
|
121394
|
+
};
|
|
121395
|
+
if (result.exitCode !== 0) {
|
|
121396
|
+
const detail = result.stderr.toString().split("\n").map((line) => line.trim()).find(Boolean);
|
|
121397
|
+
return skipped("exit " + result.exitCode + (detail ? ": " + detail.slice(0, 160) : ""));
|
|
121398
|
+
}
|
|
121399
|
+
const lines = result.stdout.toString().trim().split("\n");
|
|
121400
|
+
let report;
|
|
121401
|
+
try { report = JSON.parse(lines[lines.length - 1]); } catch { return skipped("it printed no report"); }
|
|
121402
|
+
const passed = typeof report.line === "string" && report.line.startsWith("SDK runtime check: OK");
|
|
121403
|
+
if (passed && report.capped === true) {
|
|
121404
|
+
const ranNow = Array.isArray(report.ran) ? report.ran.filter((id) => typeof id === "string") : [];
|
|
121405
|
+
sdkRan = [...sdkRan, ...ranNow];
|
|
121406
|
+
sdkRanHashes = hashes;
|
|
121407
|
+
sdkPending = ranNow.length > 0;
|
|
121408
|
+
} else if (passed) {
|
|
121409
|
+
sdkClean = hashes;
|
|
121410
|
+
sdkRan = [];
|
|
121411
|
+
sdkRanHashes = undefined;
|
|
121412
|
+
}
|
|
121413
|
+
const message = sdkRuntimeMessage(report, sdkBlocks);
|
|
121414
|
+
logSdkRuntime(sessionID, startedAt, report, message);
|
|
121415
|
+
return message;
|
|
121416
|
+
};
|
|
121417
|
+
|
|
121236
121418
|
let cleanFingerprint = await snapshot();
|
|
121237
121419
|
let currentFingerprint = cleanFingerprint;
|
|
121238
121420
|
let hasValidationFailure = process.env.CODEGEN_REQUIRE_VALIDATION === "1";
|
|
@@ -121300,6 +121482,14 @@ export const ValidationState = async ({ client, directory, $ }) => {
|
|
|
121300
121482
|
if (input.args?.runBuild === true && typeof output.output === "string" && !/^FAILED at/m.test(output.output)) {
|
|
121301
121483
|
const port = await checkUserSourcePort().catch(() => undefined);
|
|
121302
121484
|
if (port) output.output += "\n" + port;
|
|
121485
|
+
const sdkStartedAt = Date.now();
|
|
121486
|
+
const sdk = await checkSdkRuntime(input.sessionID).catch((error) => {
|
|
121487
|
+
const why = "could not run: " + String(error && error.message || error).slice(0, 160);
|
|
121488
|
+
logSdkRuntime(input.sessionID, sdkStartedAt, undefined, undefined, why);
|
|
121489
|
+
return "SDK runtime check: skipped (" + why + ")";
|
|
121490
|
+
});
|
|
121491
|
+
if (sdk) output.output += "\n" + sdk;
|
|
121492
|
+
if (sdkPending) output.output += "\nRun validate({ runBuild: true }) again: the SDK runtime check has targets left to run.";
|
|
121303
121493
|
}
|
|
121304
121494
|
const epoch = validations.get(key(input));
|
|
121305
121495
|
validations.delete(key(input));
|
|
@@ -121313,7 +121503,7 @@ export const ValidationState = async ({ client, directory, $ }) => {
|
|
|
121313
121503
|
if (epoch === mutationEpoch && activeMutations.size === 0 && validations.size === 0) {
|
|
121314
121504
|
cleanFingerprint = fingerprint;
|
|
121315
121505
|
hasValidationFailure = false;
|
|
121316
|
-
hasUnvalidatedMutation =
|
|
121506
|
+
hasUnvalidatedMutation = sdkPending;
|
|
121317
121507
|
}
|
|
121318
121508
|
}
|
|
121319
121509
|
await refresh(input.sessionID);
|
|
@@ -121341,6 +121531,13 @@ export const ValidationState = async ({ client, directory, $ }) => {
|
|
|
121341
121531
|
}
|
|
121342
121532
|
async function writeValidationStatePlugin() {
|
|
121343
121533
|
await (0, write_plugin_1.writeGeneratedPlugin)(exports2.VALIDATION_STATE_PLUGIN_FILENAME, buildValidationStateSource());
|
|
121534
|
+
try {
|
|
121535
|
+
await (0, write_plugin_1.writeCheckScript)(SDK_RUNTIME_CHECK_FILENAME, await (0, promises_1.readFile)((0, path_12.join)(install_manifest_1.OPENCODE_TOOLS_DIR, "checks", "sdk-runtime-check.ts"), "utf-8"));
|
|
121536
|
+
} catch (error) {
|
|
121537
|
+
logger_12.logger.warn("[OpenCode] Could not write the SDK runtime check script", {
|
|
121538
|
+
error: String(error)
|
|
121539
|
+
});
|
|
121540
|
+
}
|
|
121344
121541
|
}
|
|
121345
121542
|
}
|
|
121346
121543
|
});
|
|
@@ -122200,6 +122397,7 @@ var require_process_handlers = __commonJS({
|
|
|
122200
122397
|
exports2.idleBudgetMs = idleBudgetMs;
|
|
122201
122398
|
exports2.setupIdleWatchdog = setupIdleWatchdog;
|
|
122202
122399
|
exports2.trackTurnProgress = trackTurnProgress;
|
|
122400
|
+
exports2.logSdkRuntimeCheck = logSdkRuntimeCheck;
|
|
122203
122401
|
exports2.setupStdoutHandler = setupStdoutHandler;
|
|
122204
122402
|
exports2.setupStderrHandler = setupStderrHandler;
|
|
122205
122403
|
exports2.setupCloseHandler = setupCloseHandler;
|
|
@@ -122208,6 +122406,7 @@ var require_process_handlers = __commonJS({
|
|
|
122208
122406
|
var config_12 = require_config();
|
|
122209
122407
|
var ditto_codegen_types_12 = require_dist4();
|
|
122210
122408
|
var subagent_tool_logger_1 = require_subagent_tool_logger();
|
|
122409
|
+
var validation_state_1 = require_validation_state();
|
|
122211
122410
|
var process_manager_1 = require_process_manager();
|
|
122212
122411
|
var result_builder_1 = require_result_builder();
|
|
122213
122412
|
var logger_12 = require_logger();
|
|
@@ -122272,6 +122471,13 @@ var require_process_handlers = __commonJS({
|
|
|
122272
122471
|
return;
|
|
122273
122472
|
throw new ditto_codegen_types_12.TimeoutError(`Process stalled - ${process_manager_1.MAX_STARTS_WITHOUT_FINISH} turns started without completing`);
|
|
122274
122473
|
}
|
|
122474
|
+
function logSdkRuntimeCheck(event) {
|
|
122475
|
+
if (event.type !== validation_state_1.SDK_RUNTIME_EVENT_TYPE)
|
|
122476
|
+
return;
|
|
122477
|
+
const fields = { ...event };
|
|
122478
|
+
delete fields.type;
|
|
122479
|
+
logger_12.logger.info("[SDK runtime check]", fields);
|
|
122480
|
+
}
|
|
122275
122481
|
function handleStdoutLine(ctx, line, trackProgress) {
|
|
122276
122482
|
ctx.taskTracker.processLine(line);
|
|
122277
122483
|
if (!line.trim())
|
|
@@ -122285,6 +122491,7 @@ var require_process_handlers = __commonJS({
|
|
|
122285
122491
|
}
|
|
122286
122492
|
if (!event)
|
|
122287
122493
|
return null;
|
|
122494
|
+
logSdkRuntimeCheck(event);
|
|
122288
122495
|
trackToolActivity(ctx.state, event);
|
|
122289
122496
|
if (!trackProgress)
|
|
122290
122497
|
return null;
|
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.526",
|
|
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": "09fd79f1f472d84bc988263d8f79e0bad510d80a5efb69b5faa63f47"
|
|
33
33
|
}
|