@scalequality/cli 0.4.39 → 0.4.40
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/connect.build.json +2 -2
- package/dist/connect.cjs +192 -5
- package/package.json +1 -1
package/dist/connect.build.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"sdkVersion": "0.3.281",
|
|
3
|
-
"sha256": "
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"sha256": "f08a49b9add0dbb93d8b0ebec19fca7203033d5f73322a98181d78a99ef55c4c",
|
|
4
|
+
"sourceCommit": "df2e1fda2a0ad7ff945e84da935be42595390b42"
|
|
5
5
|
}
|
package/dist/connect.cjs
CHANGED
|
@@ -5942,7 +5942,8 @@ function sleep(ms, signal) {
|
|
|
5942
5942
|
}, { once: true });
|
|
5943
5943
|
});
|
|
5944
5944
|
}
|
|
5945
|
-
var
|
|
5945
|
+
var DIAGRAM_FEATURE = "design_diagram_v1";
|
|
5946
|
+
var ENGINE_FEATURES = ["message_queue_v1", DIAGRAM_FEATURE];
|
|
5946
5947
|
function toSessionBootstrap(raw) {
|
|
5947
5948
|
if (raw && raw.repo && !raw.repository) return raw;
|
|
5948
5949
|
const session = raw?.session ?? {};
|
|
@@ -6005,6 +6006,7 @@ function toSessionBootstrap(raw) {
|
|
|
6005
6006
|
// The Design canvas, its versions and the model's question card: offered only when the API says it takes them.
|
|
6006
6007
|
designCanvas: raw?.designCanvas === true,
|
|
6007
6008
|
designVersions: raw?.designVersions === true,
|
|
6009
|
+
designDiagrams: raw?.designDiagrams === true,
|
|
6008
6010
|
askQuestions: raw?.askQuestions === true,
|
|
6009
6011
|
terminalOrigins: Array.isArray(raw?.terminalOrigins) ? raw.terminalOrigins.filter((o) => typeof o === "string" && /^https?:\/\/[^/\s]+$/.test(o)).slice(0, 4) : [],
|
|
6010
6012
|
transcript: transcriptOf(raw?.transcript),
|
|
@@ -13192,15 +13194,16 @@ var DESIGN_MANIFEST = "design.json";
|
|
|
13192
13194
|
var MAX_BOARDS = 12;
|
|
13193
13195
|
var MAX_PICTURES = 6;
|
|
13194
13196
|
var BOARD_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}\.html?$/;
|
|
13197
|
+
var DIAGRAM_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,90}\.diagram\.json$/;
|
|
13195
13198
|
var designManifest = external_exports.object({
|
|
13196
13199
|
title: external_exports.string().trim().min(1).max(120),
|
|
13197
13200
|
boards: external_exports.array(external_exports.object({
|
|
13198
|
-
file: external_exports.string().
|
|
13201
|
+
file: external_exports.string().refine((f) => BOARD_FILE.test(f) || DIAGRAM_FILE.test(f), "a screen is an .html file and a diagram a .diagram.json file"),
|
|
13199
13202
|
title: external_exports.string().trim().min(1).max(80),
|
|
13200
|
-
device: external_exports.enum(["desktop", "tablet", "phone", "slide"]).default("desktop"),
|
|
13203
|
+
device: external_exports.enum(["desktop", "tablet", "phone", "slide", "diagram"]).default("desktop"),
|
|
13201
13204
|
width: external_exports.number().int().min(200).max(2560),
|
|
13202
13205
|
height: external_exports.number().int().min(200).max(4e3)
|
|
13203
|
-
}).strip()).min(1).max(MAX_BOARDS)
|
|
13206
|
+
}).strip().transform((b) => ({ ...b, device: DIAGRAM_FILE.test(b.file) ? "diagram" : b.device === "diagram" ? "desktop" : b.device }))).min(1).max(MAX_BOARDS)
|
|
13204
13207
|
}).strip();
|
|
13205
13208
|
var DesignError = class extends Error {
|
|
13206
13209
|
constructor(code, message) {
|
|
@@ -13230,6 +13233,145 @@ async function readDesign(absManifest) {
|
|
|
13230
13233
|
}
|
|
13231
13234
|
return { folder, manifest: parsed.data };
|
|
13232
13235
|
}
|
|
13236
|
+
var NODE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,39}$/;
|
|
13237
|
+
var coord = external_exports.number().finite().min(0).max(4e3);
|
|
13238
|
+
var designDiagram = external_exports.object({
|
|
13239
|
+
nodes: external_exports.array(external_exports.object({
|
|
13240
|
+
id: external_exports.string().regex(NODE_ID),
|
|
13241
|
+
label: external_exports.string().trim().min(1).max(80),
|
|
13242
|
+
shape: external_exports.enum(["box", "decision"]).default("box"),
|
|
13243
|
+
x: coord,
|
|
13244
|
+
y: coord,
|
|
13245
|
+
width: external_exports.number().finite().min(24).max(1200),
|
|
13246
|
+
height: external_exports.number().finite().min(24).max(800)
|
|
13247
|
+
}).strip()).min(1).max(60),
|
|
13248
|
+
edges: external_exports.array(external_exports.object({
|
|
13249
|
+
from: external_exports.string().regex(NODE_ID),
|
|
13250
|
+
to: external_exports.string().regex(NODE_ID),
|
|
13251
|
+
label: external_exports.string().trim().max(60).optional(),
|
|
13252
|
+
/** The answer a decision's arrow stands for: yes in green, no in amber. */
|
|
13253
|
+
tone: external_exports.enum(["yes", "no"]).optional(),
|
|
13254
|
+
/** Around the boxes, above or below them (a loop back to an earlier box). */
|
|
13255
|
+
route: external_exports.enum(["over", "under"]).optional()
|
|
13256
|
+
}).strip()).max(120).default([])
|
|
13257
|
+
}).strip();
|
|
13258
|
+
var MAX_DIAGRAM_BYTES = 64 * 1024;
|
|
13259
|
+
var TIP_GAP = 3;
|
|
13260
|
+
var LANE = 14;
|
|
13261
|
+
var round = (n) => Math.round(n * 10) / 10;
|
|
13262
|
+
function diagramRoute(a, b, route) {
|
|
13263
|
+
const ac = { x: a.x + a.width / 2, y: a.y + a.height / 2 }, bc = { x: b.x + b.width / 2, y: b.y + b.height / 2 };
|
|
13264
|
+
if (route) {
|
|
13265
|
+
const up = route === "over";
|
|
13266
|
+
const lane = up ? Math.min(a.y, b.y) - LANE : Math.max(a.y + a.height, b.y + b.height) + LANE;
|
|
13267
|
+
return [[ac.x, up ? a.y : a.y + a.height], [ac.x, lane], [bc.x, lane], [bc.x, up ? b.y - TIP_GAP : b.y + b.height + TIP_GAP]];
|
|
13268
|
+
}
|
|
13269
|
+
const within = (v, lo, hi) => v >= lo && v <= hi;
|
|
13270
|
+
const pick = (lo, hi, own, other) => b.shape === "decision" && within(other, lo, hi) ? other : a.shape === "decision" && within(own, lo, hi) ? own : within(own, lo, hi) ? own : within(other, lo, hi) ? other : (lo + hi) / 2;
|
|
13271
|
+
const top = Math.max(a.y, b.y), bottom = Math.min(a.y + a.height, b.y + b.height);
|
|
13272
|
+
if (bottom - top >= 8) {
|
|
13273
|
+
const y = pick(top, bottom, ac.y, bc.y);
|
|
13274
|
+
if (b.x >= a.x + a.width) return [[a.x + a.width, y], [b.x - TIP_GAP, y]];
|
|
13275
|
+
if (b.x + b.width <= a.x) return [[a.x, y], [b.x + b.width + TIP_GAP, y]];
|
|
13276
|
+
}
|
|
13277
|
+
const left = Math.max(a.x, b.x), right = Math.min(a.x + a.width, b.x + b.width);
|
|
13278
|
+
if (right - left >= 8) {
|
|
13279
|
+
const x = pick(left, right, ac.x, bc.x);
|
|
13280
|
+
if (b.y >= a.y + a.height) return [[x, a.y + a.height], [x, b.y - TIP_GAP]];
|
|
13281
|
+
if (b.y + b.height <= a.y) return [[x, a.y], [x, b.y + b.height + TIP_GAP]];
|
|
13282
|
+
}
|
|
13283
|
+
return [[bc.x > ac.x ? a.x + a.width : a.x, ac.y], [bc.x, ac.y], [bc.x, bc.y > ac.y ? b.y - TIP_GAP : b.y + b.height + TIP_GAP]];
|
|
13284
|
+
}
|
|
13285
|
+
function diagramArrow(points) {
|
|
13286
|
+
const [x0, y0] = points[0];
|
|
13287
|
+
let d = `M${round(x0)} ${round(y0)}`;
|
|
13288
|
+
for (let i = 1; i < points.length; i++) {
|
|
13289
|
+
const [px, py] = points[i - 1], [x, y] = points[i];
|
|
13290
|
+
d += y === py ? `h${round(x - px)}` : `v${round(y - py)}`;
|
|
13291
|
+
}
|
|
13292
|
+
const [tx, ty] = points[points.length - 1], [fx, fy] = points[points.length - 2];
|
|
13293
|
+
const t = `${round(tx)} ${round(ty)}`;
|
|
13294
|
+
if (ty === fy) return `${d}M${round(tx + (tx > fx ? -5 : 5))} ${round(ty - 5)}L${t}L${round(tx + (tx > fx ? -5 : 5))} ${round(ty + 5)}`;
|
|
13295
|
+
return `${d}M${round(tx - 5)} ${round(ty + (ty > fy ? -5 : 5))}L${t}L${round(tx + 5)} ${round(ty + (ty > fy ? -5 : 5))}`;
|
|
13296
|
+
}
|
|
13297
|
+
function diagramLabelAt(points) {
|
|
13298
|
+
let best = 0, at = { left: 0, top: 0 };
|
|
13299
|
+
for (let i = 1; i < points.length; i++) {
|
|
13300
|
+
const [px, py] = points[i - 1], [x, y] = points[i];
|
|
13301
|
+
const length = Math.abs(x - px) + Math.abs(y - py);
|
|
13302
|
+
if (length <= best) continue;
|
|
13303
|
+
best = length;
|
|
13304
|
+
at = y === py ? { left: Math.min(x, px) + 6, top: y - 14 >= 2 ? y - 14 : y + 4 } : { left: x + 8, top: Math.min(y, py) + Math.abs(y - py) / 2 - 8 };
|
|
13305
|
+
}
|
|
13306
|
+
return { left: round(at.left), top: round(at.top) };
|
|
13307
|
+
}
|
|
13308
|
+
var escapeHtml = (s) => s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
13309
|
+
function diagramPage(diagram, width, height) {
|
|
13310
|
+
const byId = new Map(diagram.nodes.map((n) => [n.id, n]));
|
|
13311
|
+
const arrows = [], words = [];
|
|
13312
|
+
for (const e of diagram.edges) {
|
|
13313
|
+
const a = byId.get(e.from), b = byId.get(e.to);
|
|
13314
|
+
if (!a || !b || a === b) continue;
|
|
13315
|
+
const points = diagramRoute(a, b, e.route);
|
|
13316
|
+
arrows.push(`<path d="${diagramArrow(points)}"></path>`);
|
|
13317
|
+
if (e.label) {
|
|
13318
|
+
const at = diagramLabelAt(points);
|
|
13319
|
+
words.push(`<span class="e"${e.tone ? ` data-tone="${e.tone}"` : ""} style="left: ${at.left}px; top: ${at.top}px">${escapeHtml(e.label)}</span>`);
|
|
13320
|
+
}
|
|
13321
|
+
}
|
|
13322
|
+
const nodes = diagram.nodes.map((n) => {
|
|
13323
|
+
const box = `left: ${round(n.x)}px; top: ${round(n.y)}px; width: ${round(n.width)}px; height: ${round(n.height)}px`;
|
|
13324
|
+
if (n.shape !== "decision") return `<span class="n" data-node="${n.id}" style="${box}"><span>${escapeHtml(n.label)}</span></span>`;
|
|
13325
|
+
const side = round(Math.min(n.width, n.height) / Math.SQRT2);
|
|
13326
|
+
return `<span class="d" aria-hidden="true" style="left: ${round(n.x + (n.width - side) / 2)}px; top: ${round(n.y + (n.height - side) / 2)}px; width: ${side}px; height: ${side}px"></span><span class="dl" data-node="${n.id}" style="${box}"><span>${escapeHtml(n.label)}</span></span>`;
|
|
13327
|
+
});
|
|
13328
|
+
return `<!doctype html><html><head><meta charset="utf-8"><style>html,body{margin:0;height:100%}body{position:relative;overflow:hidden;background:#FFFFFF;font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:#0F1113}.n{position:absolute;display:grid;place-items:center;border:1.5px solid #0E7A54;border-radius:10px;background:#F0FAF5;font-size:12.5px;text-align:center;line-height:1.3}.n>span,.dl>span{padding:0 8px;overflow-wrap:anywhere}.d{position:absolute;transform:rotate(45deg);border:1.5px solid #8A5A00;background:#FFF7E6}.dl{position:absolute;display:grid;place-items:center;font-size:11px;text-align:center;line-height:1.25}.e{position:absolute;font-size:10.5px;white-space:nowrap;color:#5E6461}.e[data-tone=yes]{color:#0E7A54}.e[data-tone=no]{color:#8A5A00}</style></head><body><svg aria-hidden="true" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" fill="none" stroke="#3D4240" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" style="position: absolute; left: 0; top: 0">` + arrows.join("") + "</svg>" + nodes.join("") + words.join("") + "</body></html>";
|
|
13329
|
+
}
|
|
13330
|
+
function diagramProblems(diagram, width, height) {
|
|
13331
|
+
const out2 = [];
|
|
13332
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13333
|
+
for (const n of diagram.nodes) {
|
|
13334
|
+
if (seen.has(n.id)) out2.push(`two boxes have the id "${n.id}"`);
|
|
13335
|
+
seen.add(n.id);
|
|
13336
|
+
if (n.x + n.width > width || n.y + n.height > height) out2.push(`the box "${n.label}" goes past the board (${width}\xD7${height})`);
|
|
13337
|
+
}
|
|
13338
|
+
for (let i = 0; i < diagram.nodes.length; i++) for (let j = i + 1; j < diagram.nodes.length; j++) {
|
|
13339
|
+
const a = diagram.nodes[i], b = diagram.nodes[j];
|
|
13340
|
+
if (a.x < b.x + b.width && b.x < a.x + a.width && a.y < b.y + b.height && b.y < a.y + a.height) out2.push(`the boxes "${a.label}" and "${b.label}" overlap`);
|
|
13341
|
+
}
|
|
13342
|
+
for (const e of diagram.edges) {
|
|
13343
|
+
for (const end of [e.from, e.to]) if (!seen.has(end)) out2.push(`an arrow goes from "${e.from}" to "${e.to}", but there is no box "${end}"`);
|
|
13344
|
+
if (e.from === e.to) out2.push(`an arrow goes from "${e.from}" to itself`);
|
|
13345
|
+
}
|
|
13346
|
+
return out2.slice(0, 12);
|
|
13347
|
+
}
|
|
13348
|
+
function diagramBoard(source, width, height) {
|
|
13349
|
+
let raw;
|
|
13350
|
+
try {
|
|
13351
|
+
raw = JSON.parse(source);
|
|
13352
|
+
} catch {
|
|
13353
|
+
return { page: diagramPage({ nodes: [], edges: [] }, width, height), problems: ["the diagram is not valid JSON"] };
|
|
13354
|
+
}
|
|
13355
|
+
const parsed = designDiagram.safeParse(raw);
|
|
13356
|
+
if (!parsed.success) {
|
|
13357
|
+
const first = parsed.error.issues[0];
|
|
13358
|
+
return { page: diagramPage({ nodes: [], edges: [] }, width, height), problems: [`the diagram does not follow the format: ${first ? `${first.path.join(".") || "root"}: ${first.message}` : "invalid"}`] };
|
|
13359
|
+
}
|
|
13360
|
+
return { page: diagramPage(parsed.data, width, height), problems: diagramProblems(parsed.data, width, height) };
|
|
13361
|
+
}
|
|
13362
|
+
async function writeDiagramFile(abs, raw) {
|
|
13363
|
+
if (!DIAGRAM_FILE.test((0, import_path10.basename)(abs))) throw new DesignError("NOT_A_DESIGN", "Only a .diagram.json file is written.");
|
|
13364
|
+
const parsed = designDiagram.safeParse(raw);
|
|
13365
|
+
if (!parsed.success) throw new DesignError("MANIFEST_INVALID", "The diagram does not follow the format.");
|
|
13366
|
+
const body = `${JSON.stringify(parsed.data, null, 2)}
|
|
13367
|
+
`;
|
|
13368
|
+
if (Buffer.byteLength(body) > MAX_DIAGRAM_BYTES) throw new DesignError("MANIFEST_INVALID", "The diagram is too large.");
|
|
13369
|
+
const st = await (0, import_promises10.lstat)(abs).catch(() => null);
|
|
13370
|
+
if (!st?.isFile()) throw new DesignError("BOARD_MISSING", "The diagram does not exist.");
|
|
13371
|
+
const { manifest } = await readDesign((0, import_path10.join)((0, import_path10.dirname)(abs), DESIGN_MANIFEST));
|
|
13372
|
+
if (!manifest.boards.some((b) => b.file === (0, import_path10.basename)(abs))) throw new DesignError("BOARD_MISSING", "The diagram is not a board of its design.");
|
|
13373
|
+
await (0, import_promises10.writeFile)(abs, body);
|
|
13374
|
+
}
|
|
13233
13375
|
var CHECKER = `<script>(function(){var errors=[];function push(m){if(errors.length<20)errors.push(String(m).slice(0,240));}
|
|
13234
13376
|
addEventListener("error",function(e){var t=e.target;if(t&&t!==window&&(t.src||t.href))push("Could not load "+(t.src||t.href));else push(e.message||"Script error");},true);
|
|
13235
13377
|
addEventListener("unhandledrejection",function(e){var r=e.reason;push("Unhandled promise rejection: "+(r&&r.message?r.message:r));});
|
|
@@ -13279,7 +13421,9 @@ async function checkDesign(chrome, folder, manifest, opts = {}) {
|
|
|
13279
13421
|
const work = await (0, import_promises10.mkdtemp)((0, import_path10.join)((0, import_os5.tmpdir)(), "sq-design-"));
|
|
13280
13422
|
const one = async (b, i) => {
|
|
13281
13423
|
const page = (0, import_path10.join)(work, `screen-${i}.html`);
|
|
13282
|
-
|
|
13424
|
+
const source = await (0, import_promises10.readFile)((0, import_path10.join)(folder, b.file), "utf8");
|
|
13425
|
+
const diagram = b.device === "diagram" ? diagramBoard(source, b.width, b.height) : null;
|
|
13426
|
+
await (0, import_promises10.writeFile)(page, checkedPage(diagram ? diagram.page : source, folder));
|
|
13283
13427
|
const url = (0, import_url.pathToFileURL)(page).href;
|
|
13284
13428
|
const base = (profile) => [
|
|
13285
13429
|
"--headless=new",
|
|
@@ -13312,6 +13456,7 @@ async function checkDesign(chrome, folder, manifest, opts = {}) {
|
|
|
13312
13456
|
}
|
|
13313
13457
|
})();
|
|
13314
13458
|
await Promise.all([measured, pictured]);
|
|
13459
|
+
if (diagram?.problems.length) check.errors = [...diagram.problems, ...check.errors].slice(0, 20);
|
|
13315
13460
|
return check;
|
|
13316
13461
|
};
|
|
13317
13462
|
try {
|
|
@@ -14703,6 +14848,7 @@ function designLines(c) {
|
|
|
14703
14848
|
"- The canvas shows a screen isolated from the internet: a picture goes in an <img> (or <picture><source>) with a path relative to the screen, never in a CSS url() or from an https address, and fonts are the system's or inlined, or the canvas shows the screen without them.",
|
|
14704
14849
|
"- Make it work: real buttons, inputs, menus and states the user can click through, with plausible content in the user's language that fits the subject (never lorem ipsum, never invented claims about a real company). Accessible as drawn: button, a and input with its label, text contrast at least 4.5:1, touch targets at least 44 px on a phone. A phone screen never scrolls sideways.",
|
|
14705
14850
|
"- Never start a dev server or install packages for a design. Fonts and libraries load only from cdn.jsdelivr.net, cdnjs.cloudflare.com or unpkg.com (fonts through @fontsource on jsDelivr; Google Fonts do not load here); anything else stays inside the file.",
|
|
14851
|
+
...c.designDiagrams ? [`- When a flow, a journey, a process or an architecture helps the user see the design (the steps of an order, what happens after a payment fails), draw it as a diagram: a board of the same design whose file is <name>.diagram.json, listed in design.json like a screen ({"file": "order-flow.diagram.json", "title": "Order flow", "device": "diagram", "width": 470, "height": 320}). The file is {"nodes": [{"id": "cart", "label": "Cart", "shape": "box", "x": 20, "y": 42, "width": 112, "height": 44}, {"id": "approved", "label": "Approved?", "shape": "decision", "x": 305, "y": 19, "width": 90, "height": 90}], "edges": [{"from": "cart", "to": "pay"}, {"from": "approved", "to": "pay", "label": "no: another card", "tone": "no", "route": "over"}, {"from": "approved", "to": "done", "label": "yes", "tone": "yes"}]}, in the board's pixels: boxes in rows or columns with room between them for the arrows, never on top of each other, inside the board; a decision is a "decision" node with "yes"/"no" arrows; "route": "over" or "under" takes an arrow back around the boxes. Labels short, in the user's language. The canvas draws the boxes and arrows, and the user can move, rename or remove them there: when a message says the user changed a diagram, read it again first.`] : [],
|
|
14706
14852
|
"- Then call check_design with the design.json path: it opens every screen in a browser and shows them to you. Fix what it reports and what you see wrong, and call it again until it is clean.",
|
|
14707
14853
|
"- Show it as : the user opens it in the Design canvas. Never paste the design's code in the answer.",
|
|
14708
14854
|
"- When the user's message points at an element of a screen (a selected element), change that element only and leave everything else exactly as it was; to suggest more, say it in one line."
|
|
@@ -15049,6 +15195,7 @@ var FileRequestError = class extends Error {
|
|
|
15049
15195
|
}
|
|
15050
15196
|
code;
|
|
15051
15197
|
};
|
|
15198
|
+
var fencePath = (root, rel, denied = []) => fenced(root, rel, denied);
|
|
15052
15199
|
async function fenced(root, rel, denied) {
|
|
15053
15200
|
const clean = (rel ?? "").replace(/^\/+/, "");
|
|
15054
15201
|
if (clean.split(/[\\/]/).includes("..")) throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
@@ -15631,6 +15778,13 @@ ${marks.join("\n")}
|
|
|
15631
15778
|
Say in one sentence what you understood from the sketch, change the design as it asks (and the same part on the design's other screens), leave the rest as it was, then call check_design again.
|
|
15632
15779
|
</design_sketch>`;
|
|
15633
15780
|
}
|
|
15781
|
+
function diagramEditsBlock(paths) {
|
|
15782
|
+
const data = (value) => value.slice(0, 1e3).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
15783
|
+
return `<diagram_edits>
|
|
15784
|
+
The user changed these diagrams on the canvas (moved, renamed or removed boxes). Read each again before you change it, and keep what the user did unless the message asks otherwise:
|
|
15785
|
+
${paths.slice(0, 12).map((p) => `- ${data(p)}`).join("\n")}
|
|
15786
|
+
</diagram_edits>`;
|
|
15787
|
+
}
|
|
15634
15788
|
var TURN_CAPS = { images: 4, fileBytes: 64 * 1024, filesBytes: 200 * 1024, mentions: 10, contextBytes: 32 * 1024, folderEntries: 200 };
|
|
15635
15789
|
var IMAGE_TYPES = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/gif", "image/webp"]);
|
|
15636
15790
|
var iso2 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -15706,6 +15860,8 @@ var WorkspaceEngine = class {
|
|
|
15706
15860
|
turnWatch = null;
|
|
15707
15861
|
/** The designs this turn checked (their path and folder), kept as a version each when the turn ends; and what was asked. */
|
|
15708
15862
|
designsChecked = /* @__PURE__ */ new Map();
|
|
15863
|
+
/** Diagrams the person changed on the canvas since the last message: the next one tells the model to read them again. */
|
|
15864
|
+
diagramEdits = /* @__PURE__ */ new Set();
|
|
15709
15865
|
turnNote = "";
|
|
15710
15866
|
/** Why the previous turn ended in trouble (null when it did not): SQ Auto takes the hard-task model for the next one. */
|
|
15711
15867
|
previousTrouble = null;
|
|
@@ -16186,6 +16342,9 @@ var WorkspaceEngine = class {
|
|
|
16186
16342
|
case "read_file":
|
|
16187
16343
|
await this.answerFileRequest(c.id, c.kind, p);
|
|
16188
16344
|
return;
|
|
16345
|
+
case "write_diagram":
|
|
16346
|
+
await this.answerDiagramWrite(c.id, p);
|
|
16347
|
+
return;
|
|
16189
16348
|
case "terminal_open":
|
|
16190
16349
|
await this.openTerminal(c.id, p);
|
|
16191
16350
|
return;
|
|
@@ -16431,6 +16590,29 @@ var WorkspaceEngine = class {
|
|
|
16431
16590
|
}
|
|
16432
16591
|
await this.deps.transport.reply(commandId, this.redactor.deep(reply)).catch((e) => this.deps.log.warn("file request not answered", { error: e.message }));
|
|
16433
16592
|
}
|
|
16593
|
+
/**
|
|
16594
|
+
* The person's change to a diagram the model drew (approved prototype RrXQGz7VyPB3s8gYijdHCk), written to its file
|
|
16595
|
+
* where the file viewer reads it: the same folder and the same fence, only a .diagram.json of a design, in its format.
|
|
16596
|
+
*/
|
|
16597
|
+
async answerDiagramWrite(commandId, p) {
|
|
16598
|
+
if (!this.deps.transport.reply) return;
|
|
16599
|
+
let reply;
|
|
16600
|
+
try {
|
|
16601
|
+
const repo2 = this.repos.size === 1 && this.local ? [...this.repos.values()][0] : null;
|
|
16602
|
+
const asked = await insideRelative(typeof p.path === "string" ? p.path : "", [repo2?.fence ?? repo2?.root ?? this.deps.root]);
|
|
16603
|
+
const written = await this.fencedFiles(repo2, asked, async (root, rel) => {
|
|
16604
|
+
const { abs, rel: clean } = await fencePath(root, rel, this.deps.privateDirs ?? []);
|
|
16605
|
+
await writeDiagramFile(abs, p.diagram);
|
|
16606
|
+
return { path: clean };
|
|
16607
|
+
});
|
|
16608
|
+
this.diagramEdits.add(written.path);
|
|
16609
|
+
this.scheduleDiff();
|
|
16610
|
+
reply = { ok: true, result: { path: written.path } };
|
|
16611
|
+
} catch (e) {
|
|
16612
|
+
reply = { ok: false, error: { code: e instanceof FileRequestError ? e.code : e instanceof DesignError ? "INVALID_DIAGRAM" : "FILE_REQUEST_FAILED" } };
|
|
16613
|
+
}
|
|
16614
|
+
await this.deps.transport.reply(commandId, reply).catch((e) => this.deps.log.warn("diagram write not answered", { error: e.message }));
|
|
16615
|
+
}
|
|
16434
16616
|
// ─── turns ───────────────────────────────────────────────────────────────
|
|
16435
16617
|
kickTurns() {
|
|
16436
16618
|
if (this.turnRunning || this.stopping) return;
|
|
@@ -16662,6 +16844,7 @@ ${String(item.content)}` : String(item.content);
|
|
|
16662
16844
|
imageGeneration: !!this.boot?.imageGeneration && !!this.deps.transport.generateImage,
|
|
16663
16845
|
webSearch: !!this.boot?.webSearch && !!this.deps.transport.searchWeb,
|
|
16664
16846
|
designCanvas: !!this.boot?.designCanvas,
|
|
16847
|
+
designDiagrams: !!this.boot?.designCanvas && !!this.boot?.designDiagrams,
|
|
16665
16848
|
askQuestions: !!this.boot?.askQuestions
|
|
16666
16849
|
});
|
|
16667
16850
|
const conventions = await readConventions([...this.repos.values()].filter((r) => !r.dormant).flatMap((r) => {
|
|
@@ -17020,6 +17203,10 @@ ${String(item.content)}` : String(item.content);
|
|
|
17020
17203
|
else this.error("ATTACHMENT_SKIPPED");
|
|
17021
17204
|
}
|
|
17022
17205
|
const blocks = [];
|
|
17206
|
+
if (this.diagramEdits.size) {
|
|
17207
|
+
blocks.push(diagramEditsBlock([...this.diagramEdits]));
|
|
17208
|
+
this.diagramEdits.clear();
|
|
17209
|
+
}
|
|
17023
17210
|
let filesBytes = 0;
|
|
17024
17211
|
for (const raw of (Array.isArray(payload.mentions) ? payload.mentions : []).slice(0, TURN_CAPS.mentions)) {
|
|
17025
17212
|
const m = raw;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalequality/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.40",
|
|
4
4
|
"description": "ScaleQuality CLI. Connect your computer to the ScaleQuality AI Workspace (`scalequality login`), run its coding engine in any folder of your computer, and import your Claude Code and Codex conversations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|