@scalequality/cli 0.4.41 → 0.4.43
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/README.md +13 -8
- package/dist/connect.build.json +3 -3
- package/dist/connect.cjs +543 -281
- package/package.json +2 -2
package/dist/connect.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @scalequality/cli connect: built from scalequality-ai-governance-service src/main/workspace-connect.ts. Requires @anthropic-ai/claude-agent-sdk@0.3.
|
|
1
|
+
/* @scalequality/cli connect: built from scalequality-ai-governance-service src/main/workspace-connect.ts. Requires @anthropic-ai/claude-agent-sdk@0.3.312. */
|
|
2
2
|
"use strict";
|
|
3
3
|
var __create = Object.create;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -34,9 +34,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
34
|
mod
|
|
35
35
|
));
|
|
36
36
|
|
|
37
|
-
// node_modules/ws/lib/constants.js
|
|
37
|
+
// ../aig-folder-scope/node_modules/ws/lib/constants.js
|
|
38
38
|
var require_constants = __commonJS({
|
|
39
|
-
"node_modules/ws/lib/constants.js"(exports2, module2) {
|
|
39
|
+
"../aig-folder-scope/node_modules/ws/lib/constants.js"(exports2, module2) {
|
|
40
40
|
"use strict";
|
|
41
41
|
var BINARY_TYPES = ["nodebuffer", "arraybuffer", "fragments"];
|
|
42
42
|
var hasBlob = typeof Blob !== "undefined";
|
|
@@ -57,9 +57,9 @@ var require_constants = __commonJS({
|
|
|
57
57
|
}
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
// node_modules/ws/lib/buffer-util.js
|
|
60
|
+
// ../aig-folder-scope/node_modules/ws/lib/buffer-util.js
|
|
61
61
|
var require_buffer_util = __commonJS({
|
|
62
|
-
"node_modules/ws/lib/buffer-util.js"(exports2, module2) {
|
|
62
|
+
"../aig-folder-scope/node_modules/ws/lib/buffer-util.js"(exports2, module2) {
|
|
63
63
|
"use strict";
|
|
64
64
|
var { EMPTY_BUFFER } = require_constants();
|
|
65
65
|
var FastBuffer = Buffer[Symbol.species];
|
|
@@ -132,9 +132,9 @@ var require_buffer_util = __commonJS({
|
|
|
132
132
|
}
|
|
133
133
|
});
|
|
134
134
|
|
|
135
|
-
// node_modules/ws/lib/limiter.js
|
|
135
|
+
// ../aig-folder-scope/node_modules/ws/lib/limiter.js
|
|
136
136
|
var require_limiter = __commonJS({
|
|
137
|
-
"node_modules/ws/lib/limiter.js"(exports2, module2) {
|
|
137
|
+
"../aig-folder-scope/node_modules/ws/lib/limiter.js"(exports2, module2) {
|
|
138
138
|
"use strict";
|
|
139
139
|
var kDone = /* @__PURE__ */ Symbol("kDone");
|
|
140
140
|
var kRun = /* @__PURE__ */ Symbol("kRun");
|
|
@@ -182,9 +182,9 @@ var require_limiter = __commonJS({
|
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
184
|
|
|
185
|
-
// node_modules/ws/lib/permessage-deflate.js
|
|
185
|
+
// ../aig-folder-scope/node_modules/ws/lib/permessage-deflate.js
|
|
186
186
|
var require_permessage_deflate = __commonJS({
|
|
187
|
-
"node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
|
|
187
|
+
"../aig-folder-scope/node_modules/ws/lib/permessage-deflate.js"(exports2, module2) {
|
|
188
188
|
"use strict";
|
|
189
189
|
var zlib = require("zlib");
|
|
190
190
|
var bufferUtil = require_buffer_util();
|
|
@@ -565,9 +565,9 @@ var require_permessage_deflate = __commonJS({
|
|
|
565
565
|
}
|
|
566
566
|
});
|
|
567
567
|
|
|
568
|
-
// node_modules/ws/lib/validation.js
|
|
568
|
+
// ../aig-folder-scope/node_modules/ws/lib/validation.js
|
|
569
569
|
var require_validation = __commonJS({
|
|
570
|
-
"node_modules/ws/lib/validation.js"(exports2, module2) {
|
|
570
|
+
"../aig-folder-scope/node_modules/ws/lib/validation.js"(exports2, module2) {
|
|
571
571
|
"use strict";
|
|
572
572
|
var { isUtf8 } = require("buffer");
|
|
573
573
|
var { hasBlob } = require_constants();
|
|
@@ -766,9 +766,9 @@ var require_validation = __commonJS({
|
|
|
766
766
|
}
|
|
767
767
|
});
|
|
768
768
|
|
|
769
|
-
// node_modules/ws/lib/receiver.js
|
|
769
|
+
// ../aig-folder-scope/node_modules/ws/lib/receiver.js
|
|
770
770
|
var require_receiver = __commonJS({
|
|
771
|
-
"node_modules/ws/lib/receiver.js"(exports2, module2) {
|
|
771
|
+
"../aig-folder-scope/node_modules/ws/lib/receiver.js"(exports2, module2) {
|
|
772
772
|
"use strict";
|
|
773
773
|
var { Writable } = require("stream");
|
|
774
774
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -1389,9 +1389,9 @@ var require_receiver = __commonJS({
|
|
|
1389
1389
|
}
|
|
1390
1390
|
});
|
|
1391
1391
|
|
|
1392
|
-
// node_modules/ws/lib/sender.js
|
|
1392
|
+
// ../aig-folder-scope/node_modules/ws/lib/sender.js
|
|
1393
1393
|
var require_sender = __commonJS({
|
|
1394
|
-
"node_modules/ws/lib/sender.js"(exports2, module2) {
|
|
1394
|
+
"../aig-folder-scope/node_modules/ws/lib/sender.js"(exports2, module2) {
|
|
1395
1395
|
"use strict";
|
|
1396
1396
|
var { Duplex } = require("stream");
|
|
1397
1397
|
var { randomFillSync } = require("crypto");
|
|
@@ -1882,9 +1882,9 @@ var require_sender = __commonJS({
|
|
|
1882
1882
|
}
|
|
1883
1883
|
});
|
|
1884
1884
|
|
|
1885
|
-
// node_modules/ws/lib/event-target.js
|
|
1885
|
+
// ../aig-folder-scope/node_modules/ws/lib/event-target.js
|
|
1886
1886
|
var require_event_target = __commonJS({
|
|
1887
|
-
"node_modules/ws/lib/event-target.js"(exports2, module2) {
|
|
1887
|
+
"../aig-folder-scope/node_modules/ws/lib/event-target.js"(exports2, module2) {
|
|
1888
1888
|
"use strict";
|
|
1889
1889
|
var { kForOnEventAttribute, kListener } = require_constants();
|
|
1890
1890
|
var kCode = /* @__PURE__ */ Symbol("kCode");
|
|
@@ -2111,9 +2111,9 @@ var require_event_target = __commonJS({
|
|
|
2111
2111
|
}
|
|
2112
2112
|
});
|
|
2113
2113
|
|
|
2114
|
-
// node_modules/ws/lib/extension.js
|
|
2114
|
+
// ../aig-folder-scope/node_modules/ws/lib/extension.js
|
|
2115
2115
|
var require_extension = __commonJS({
|
|
2116
|
-
"node_modules/ws/lib/extension.js"(exports2, module2) {
|
|
2116
|
+
"../aig-folder-scope/node_modules/ws/lib/extension.js"(exports2, module2) {
|
|
2117
2117
|
"use strict";
|
|
2118
2118
|
var { tokenChars } = require_validation();
|
|
2119
2119
|
function push(dest, name, elem) {
|
|
@@ -2264,9 +2264,9 @@ var require_extension = __commonJS({
|
|
|
2264
2264
|
}
|
|
2265
2265
|
});
|
|
2266
2266
|
|
|
2267
|
-
// node_modules/ws/lib/websocket.js
|
|
2267
|
+
// ../aig-folder-scope/node_modules/ws/lib/websocket.js
|
|
2268
2268
|
var require_websocket = __commonJS({
|
|
2269
|
-
"node_modules/ws/lib/websocket.js"(exports2, module2) {
|
|
2269
|
+
"../aig-folder-scope/node_modules/ws/lib/websocket.js"(exports2, module2) {
|
|
2270
2270
|
"use strict";
|
|
2271
2271
|
var EventEmitter = require("events");
|
|
2272
2272
|
var https = require("https");
|
|
@@ -3160,9 +3160,9 @@ var require_websocket = __commonJS({
|
|
|
3160
3160
|
}
|
|
3161
3161
|
});
|
|
3162
3162
|
|
|
3163
|
-
// node_modules/ws/lib/stream.js
|
|
3163
|
+
// ../aig-folder-scope/node_modules/ws/lib/stream.js
|
|
3164
3164
|
var require_stream = __commonJS({
|
|
3165
|
-
"node_modules/ws/lib/stream.js"(exports2, module2) {
|
|
3165
|
+
"../aig-folder-scope/node_modules/ws/lib/stream.js"(exports2, module2) {
|
|
3166
3166
|
"use strict";
|
|
3167
3167
|
var WebSocket2 = require_websocket();
|
|
3168
3168
|
var { Duplex } = require("stream");
|
|
@@ -3258,9 +3258,9 @@ var require_stream = __commonJS({
|
|
|
3258
3258
|
}
|
|
3259
3259
|
});
|
|
3260
3260
|
|
|
3261
|
-
// node_modules/ws/lib/subprotocol.js
|
|
3261
|
+
// ../aig-folder-scope/node_modules/ws/lib/subprotocol.js
|
|
3262
3262
|
var require_subprotocol = __commonJS({
|
|
3263
|
-
"node_modules/ws/lib/subprotocol.js"(exports2, module2) {
|
|
3263
|
+
"../aig-folder-scope/node_modules/ws/lib/subprotocol.js"(exports2, module2) {
|
|
3264
3264
|
"use strict";
|
|
3265
3265
|
var { tokenChars } = require_validation();
|
|
3266
3266
|
function parse2(header) {
|
|
@@ -3303,9 +3303,9 @@ var require_subprotocol = __commonJS({
|
|
|
3303
3303
|
}
|
|
3304
3304
|
});
|
|
3305
3305
|
|
|
3306
|
-
// node_modules/ws/lib/websocket-server.js
|
|
3306
|
+
// ../aig-folder-scope/node_modules/ws/lib/websocket-server.js
|
|
3307
3307
|
var require_websocket_server = __commonJS({
|
|
3308
|
-
"node_modules/ws/lib/websocket-server.js"(exports2, module2) {
|
|
3308
|
+
"../aig-folder-scope/node_modules/ws/lib/websocket-server.js"(exports2, module2) {
|
|
3309
3309
|
"use strict";
|
|
3310
3310
|
var EventEmitter = require("events");
|
|
3311
3311
|
var http = require("http");
|
|
@@ -3705,9 +3705,9 @@ var require_websocket_server = __commonJS({
|
|
|
3705
3705
|
});
|
|
3706
3706
|
|
|
3707
3707
|
// src/main/workspace-connect.ts
|
|
3708
|
-
var
|
|
3708
|
+
var import_fs14 = require("fs");
|
|
3709
3709
|
var import_os7 = require("os");
|
|
3710
|
-
var
|
|
3710
|
+
var import_path20 = require("path");
|
|
3711
3711
|
var import_url2 = require("url");
|
|
3712
3712
|
|
|
3713
3713
|
// src/application/services/workspaceSandbox/importers.ts
|
|
@@ -3732,6 +3732,22 @@ function formatUserCode(code) {
|
|
|
3732
3732
|
var MAX_MACHINE_FOLDERS = 50;
|
|
3733
3733
|
var MAX_PATH_LENGTH = 1024;
|
|
3734
3734
|
var WINDOWS_ABS = /^[A-Za-z]:[\\/]/;
|
|
3735
|
+
var WINDOWS_SYSTEM_FOLDERS = /* @__PURE__ */ new Set([
|
|
3736
|
+
"windows",
|
|
3737
|
+
"program files",
|
|
3738
|
+
"program files (x86)",
|
|
3739
|
+
"programdata",
|
|
3740
|
+
"recovery",
|
|
3741
|
+
"perflogs",
|
|
3742
|
+
"boot",
|
|
3743
|
+
"documents and settings",
|
|
3744
|
+
"system volume information",
|
|
3745
|
+
"$recycle.bin",
|
|
3746
|
+
"$windows.~bt",
|
|
3747
|
+
"$windows.~ws",
|
|
3748
|
+
"config.msi",
|
|
3749
|
+
"msocache"
|
|
3750
|
+
]);
|
|
3735
3751
|
function segments(path) {
|
|
3736
3752
|
return path.replace(/^[A-Za-z]:/, "").split(/[\\/]+/).filter(Boolean);
|
|
3737
3753
|
}
|
|
@@ -3748,12 +3764,24 @@ function folderPathProblem(path, home) {
|
|
|
3748
3764
|
if (!homeParts.length) return "HOME_UNKNOWN";
|
|
3749
3765
|
const same = (a, b) => windows ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
3750
3766
|
if (windows !== WINDOWS_ABS.test(home)) return "PATH_OUTSIDE_HOME";
|
|
3751
|
-
|
|
3752
|
-
if (parts.length
|
|
3753
|
-
return parts.length === homeParts.length
|
|
3767
|
+
const sameDrive = !windows || path[0].toLowerCase() === home[0].toLowerCase();
|
|
3768
|
+
if (sameDrive && parts.length >= homeParts.length && homeParts.every((h, i) => same(h, parts[i]))) {
|
|
3769
|
+
return parts.length === homeParts.length ? "PATH_IS_HOME" : null;
|
|
3754
3770
|
}
|
|
3771
|
+
if (!windows) return "PATH_OUTSIDE_HOME";
|
|
3772
|
+
if (WINDOWS_SYSTEM_FOLDERS.has(parts[0].toLowerCase())) return "PATH_IS_SYSTEM";
|
|
3773
|
+
if (sameDrive && parts.every((p, i) => same(homeParts[i], p))) return "PATH_CONTAINS_HOME";
|
|
3755
3774
|
return null;
|
|
3756
3775
|
}
|
|
3776
|
+
function folderBrowseProblem(path, home) {
|
|
3777
|
+
const problem = folderPathProblem(path, home);
|
|
3778
|
+
if (problem === "PATH_IS_HOME" || problem === "PATH_CONTAINS_HOME") return null;
|
|
3779
|
+
if (problem === "PATH_IS_ROOT" && typeof path === "string" && WINDOWS_ABS.test(path) && typeof home === "string" && WINDOWS_ABS.test(home) && segments(home).length) return null;
|
|
3780
|
+
return problem;
|
|
3781
|
+
}
|
|
3782
|
+
function chosenRealPath(chosen, real) {
|
|
3783
|
+
return WINDOWS_ABS.test(chosen) && real.startsWith("\\\\") ? chosen : real;
|
|
3784
|
+
}
|
|
3757
3785
|
function folderDisplayName(path) {
|
|
3758
3786
|
const parts = segments(path);
|
|
3759
3787
|
return parts[parts.length - 1] ?? path;
|
|
@@ -3809,7 +3837,7 @@ var RULES = [
|
|
|
3809
3837
|
{ kind: "PRIVATE_KEY", re: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----[\s\S]*?(?:-----END [A-Z0-9 ]*PRIVATE KEY(?: BLOCK)?-----|$)/g },
|
|
3810
3838
|
{ kind: "CONNECTION_STRING", re: /\b([a-z][a-z0-9+.-]{1,30}:\/\/)([^\s:@/'"]{1,200}):([^\s@/'"]{1,300})@/gi, replace: (_m, scheme, user) => `${scheme}${user}:${R("PASSWORD")}@` },
|
|
3811
3839
|
{ kind: "AWS_ACCESS_KEY", re: /\b(?:AKIA|ASIA|AGPA|AIDA|AROA|ANPA|ANVA|AIPA|ABIA|ACCA)[A-Z0-9]{16}\b/g },
|
|
3812
|
-
{ kind: "AWS_SECRET_KEY", re: /\b(aws_?secret_?access_?key|aws_?secret|secretAccessKey)(["']?\s*[:=]\s*["']?)([A-Za-z0-9/+=]{40})\b/gi, replace: (_m, k,
|
|
3840
|
+
{ kind: "AWS_SECRET_KEY", re: /\b(aws_?secret_?access_?key|aws_?secret|secretAccessKey)(["']?\s*[:=]\s*["']?)([A-Za-z0-9/+=]{40})\b/gi, replace: (_m, k, sep13) => `${k}${sep13}${R("AWS_SECRET_KEY")}` },
|
|
3813
3841
|
{ kind: "ANTHROPIC_KEY", re: /\bsk-ant-[a-z]{2,10}\d{0,3}-[A-Za-z0-9_-]{20,}/g },
|
|
3814
3842
|
{ kind: "OPENAI_KEY", re: /\bsk-(?:proj-|svcacct-|admin-|None-)?[A-Za-z0-9_-]{20,}/g },
|
|
3815
3843
|
{ kind: "GITHUB_TOKEN", re: /\b(?:gh[pousr]_[A-Za-z0-9]{30,255}|github_pat_[A-Za-z0-9_]{22,255})\b/g },
|
|
@@ -3825,7 +3853,7 @@ var RULES = [
|
|
|
3825
3853
|
kind: "ASSIGNED_SECRET",
|
|
3826
3854
|
// password=..., "api_key": "...", SECRET_TOKEN: ..., --token ... (key names that say "secret").
|
|
3827
3855
|
re: /\b([A-Za-z0-9_.-]*(?:passw(?:or)?d|pwd|secret|token|api[_-]?key|apikey|access[_-]?key|private[_-]?key|client[_-]?secret|credential|auth[_-]?key)[A-Za-z0-9_-]*)(["']?\s*(?:=|:|\s)\s*)(["']?)([^\s"'`,;)}\]]{8,500})\3/gi,
|
|
3828
|
-
replace: (_m, key,
|
|
3856
|
+
replace: (_m, key, sep13, quote, value) => looksLikeSecretValue(value) ? `${key}${sep13}${quote}${R("SECRET")}${quote}` : null
|
|
3829
3857
|
}
|
|
3830
3858
|
];
|
|
3831
3859
|
function scrubSecrets(input) {
|
|
@@ -4384,6 +4412,7 @@ var import_path2 = require("path");
|
|
|
4384
4412
|
// src/application/services/workspaceSandbox/checkpointMap.ts
|
|
4385
4413
|
var CHECKPOINT_MAP_VERSION = 2;
|
|
4386
4414
|
var LOCAL_FOLDER_KEY = ".";
|
|
4415
|
+
var WORKSPACE_FILES_KEY = "/";
|
|
4387
4416
|
function parseCheckpoints(raw, legacyRepo) {
|
|
4388
4417
|
const out2 = /* @__PURE__ */ new Map();
|
|
4389
4418
|
if (!raw) return out2;
|
|
@@ -4814,7 +4843,24 @@ async function webFetchDenial(raw, resolve8 = defaultLookup) {
|
|
|
4814
4843
|
// src/application/services/workspaceSandbox/toolPolicy.ts
|
|
4815
4844
|
var SQ_MCP_SERVER = "scalequality";
|
|
4816
4845
|
var SQ_MCP_PREFIX = `mcp__${SQ_MCP_SERVER}__`;
|
|
4817
|
-
var DENIED_TOOLS = [
|
|
4846
|
+
var DENIED_TOOLS = [
|
|
4847
|
+
"WebSearch",
|
|
4848
|
+
"RemoteTrigger",
|
|
4849
|
+
"CronCreate",
|
|
4850
|
+
"CronDelete",
|
|
4851
|
+
"CronList",
|
|
4852
|
+
"ScheduleWakeup",
|
|
4853
|
+
"PushNotification",
|
|
4854
|
+
"EnterWorktree",
|
|
4855
|
+
"ExitWorktree",
|
|
4856
|
+
"Artifact",
|
|
4857
|
+
"Workflow",
|
|
4858
|
+
"SendFeedback",
|
|
4859
|
+
"ClaudeDesign",
|
|
4860
|
+
"Projects",
|
|
4861
|
+
// Claude Code 2.1.312 (Agent SDK 0.3.312) adds it to the tools; this policy has no rule for it, so it never reaches the model.
|
|
4862
|
+
"Monitor"
|
|
4863
|
+
];
|
|
4818
4864
|
var READ_TOOLS = { Read: "file_path", Glob: "path", Grep: "path", LS: "path" };
|
|
4819
4865
|
var WRITE_TOOLS = { Write: "file_path", Edit: "file_path", MultiEdit: "file_path", NotebookEdit: "notebook_path" };
|
|
4820
4866
|
var IMAGE_TOOL = "generate_image";
|
|
@@ -5813,6 +5859,12 @@ var HttpSessionTransport = class {
|
|
|
5813
5859
|
async saveDesignVersion(v) {
|
|
5814
5860
|
await this.post("/design-versions", v, this.opts.requestTimeoutMs ?? 6e4);
|
|
5815
5861
|
}
|
|
5862
|
+
async keptDesign(path) {
|
|
5863
|
+
const raw = await this.get(`/design-versions/kept?path=${encodeURIComponent(path)}`, this.opts.requestTimeoutMs ?? 6e4);
|
|
5864
|
+
if (!Number.isInteger(raw?.n) || !Array.isArray(raw?.files)) return null;
|
|
5865
|
+
const files = raw.files.filter((f) => typeof f?.name === "string" && typeof f?.data === "string");
|
|
5866
|
+
return { n: raw.n, files };
|
|
5867
|
+
}
|
|
5816
5868
|
async reply(commandId, reply) {
|
|
5817
5869
|
if (!/^[A-Za-z0-9-]{1,80}$/.test(commandId)) throw new TransportError("invalid command id", null, false);
|
|
5818
5870
|
await this.post(`/replies/${commandId}`, reply, this.opts.requestTimeoutMs ?? 3e4);
|
|
@@ -6007,6 +6059,7 @@ function toSessionBootstrap(raw) {
|
|
|
6007
6059
|
designCanvas: raw?.designCanvas === true,
|
|
6008
6060
|
designVersions: raw?.designVersions === true,
|
|
6009
6061
|
designDiagrams: raw?.designDiagrams === true,
|
|
6062
|
+
keptDesigns: Array.isArray(raw?.keptDesigns) ? raw.keptDesigns.filter((d) => typeof d?.path === "string" && Number.isInteger(d?.n)).map((d) => ({ path: d.path, n: d.n })) : [],
|
|
6010
6063
|
askQuestions: raw?.askQuestions === true,
|
|
6011
6064
|
terminalOrigins: Array.isArray(raw?.terminalOrigins) ? raw.terminalOrigins.filter((o) => typeof o === "string" && /^https?:\/\/[^/\s]+$/.test(o)).slice(0, 4) : [],
|
|
6012
6065
|
transcript: transcriptOf(raw?.transcript),
|
|
@@ -6450,7 +6503,8 @@ async function enclosingRepository(root) {
|
|
|
6450
6503
|
const inHead = (await git(["ls-tree", "-d", "--name-only", "HEAD", "--", prefix], { cwd: realTop, env }).catch(() => "")).trim().length > 0;
|
|
6451
6504
|
if (inHead) return { top: realTop, prefix };
|
|
6452
6505
|
const home = await (0, import_promises6.realpath)((0, import_os3.homedir)()).catch(() => (0, import_os3.homedir)());
|
|
6453
|
-
|
|
6506
|
+
const toHome = (0, import_path5.relative)(realTop, home);
|
|
6507
|
+
if (realTop === home || !(0, import_path5.isAbsolute)(toHome) && toHome.split(import_path5.sep)[0] !== "..") return null;
|
|
6454
6508
|
const ignored = await git(["check-ignore", "-q", "--", prefix], { cwd: realTop, env }).then(() => true, () => false);
|
|
6455
6509
|
return ignored ? null : { top: realTop, prefix };
|
|
6456
6510
|
}
|
|
@@ -7222,8 +7276,10 @@ var MACHINE_USAGE = {
|
|
|
7222
7276
|
"Usage: scalequality add [PATH] [--api URL]",
|
|
7223
7277
|
"",
|
|
7224
7278
|
"Adds a folder (default: the current one) to the folders the AI Workspace",
|
|
7225
|
-
"can use on this computer: any folder, a git repository or not.
|
|
7226
|
-
"inside your home folder
|
|
7279
|
+
"can use on this computer: any folder, a git repository or not. On macOS",
|
|
7280
|
+
"and Linux it must be inside your home folder; on Windows it can be on any",
|
|
7281
|
+
"drive. Never the home folder itself, the root of a disk or a folder of",
|
|
7282
|
+
"Windows itself."
|
|
7227
7283
|
].join("\n"),
|
|
7228
7284
|
logout: [
|
|
7229
7285
|
"Usage: scalequality logout [--api URL]",
|
|
@@ -7863,7 +7919,7 @@ var import_crypto5 = require("crypto");
|
|
|
7863
7919
|
var import_fs6 = require("fs");
|
|
7864
7920
|
var import_http = require("http");
|
|
7865
7921
|
|
|
7866
|
-
// node_modules/ws/wrapper.mjs
|
|
7922
|
+
// ../aig-folder-scope/node_modules/ws/wrapper.mjs
|
|
7867
7923
|
var import_stream = __toESM(require_stream(), 1);
|
|
7868
7924
|
var import_extension = __toESM(require_extension(), 1);
|
|
7869
7925
|
var import_permessage_deflate = __toESM(require_permessage_deflate(), 1);
|
|
@@ -8184,7 +8240,10 @@ var SUGGEST_DEPTH = 3;
|
|
|
8184
8240
|
var MAX_REMOTE = 1024;
|
|
8185
8241
|
var MAX_ANSWER_BYTES = 900 * 1024;
|
|
8186
8242
|
var CONCURRENCY = 24;
|
|
8187
|
-
var DEV_ROOTS = ["GIT", "git", "code", "Code", "projects", "Projects", "dev", "src", "workspace", "repos", "Developer", "Documents/GitHub", "go/src"];
|
|
8243
|
+
var DEV_ROOTS = ["GIT", "git", "code", "Code", "projects", "Projects", "dev", "src", "workspace", "repos", "Developer", "Documents/GitHub", "go/src", "source/repos"];
|
|
8244
|
+
var DRIVE_DEV_ROOTS = ["dev", "git", "code", "projects", "projetos", "proyectos", "repos", "repositorios", "src", "source", "workspace", "work", "www"];
|
|
8245
|
+
var DRIVE_PROBE_MS = 1500;
|
|
8246
|
+
var DRIVES_TTL_MS = 3e4;
|
|
8188
8247
|
var SKIP_ANYWHERE = /* @__PURE__ */ new Set(["node_modules", "bower_components", "jspm_packages", "__pycache__", "Caches", "CachedData", "DerivedData", "Pods"]);
|
|
8189
8248
|
var SKIP_AT_HOME = /* @__PURE__ */ new Set([
|
|
8190
8249
|
"Library",
|
|
@@ -8213,21 +8272,46 @@ var FolderBrowseError = class extends Error {
|
|
|
8213
8272
|
code;
|
|
8214
8273
|
};
|
|
8215
8274
|
var hidden = (name) => name.startsWith(".") || name.startsWith("$");
|
|
8216
|
-
var skipped = (name,
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
return
|
|
8275
|
+
var skipped = (name, level) => hidden(name) || SKIP_ANYWHERE.has(name) || level === "home" && SKIP_AT_HOME.has(name) || level === "drive" && WINDOWS_SYSTEM_FOLDERS.has(name.toLowerCase());
|
|
8276
|
+
var isDriveRoot = (path) => /^[A-Za-z]:[\\/]*$/.test(path);
|
|
8277
|
+
function browsable(path, home) {
|
|
8278
|
+
return folderBrowseProblem(path, home) === null;
|
|
8220
8279
|
}
|
|
8221
8280
|
function logical(home, real) {
|
|
8222
8281
|
if (home.logical === home.real) return real;
|
|
8223
8282
|
const rel = (0, import_path7.relative)(home.real, real);
|
|
8283
|
+
if (rel.startsWith("..") || (0, import_path7.isAbsolute)(rel)) return real;
|
|
8224
8284
|
return rel ? (0, import_path7.join)(home.logical, rel) : home.logical;
|
|
8225
8285
|
}
|
|
8226
|
-
async function
|
|
8227
|
-
const
|
|
8228
|
-
|
|
8286
|
+
async function realBrowsable(home, path) {
|
|
8287
|
+
const found = await (0, import_promises7.realpath)(path).catch(() => null);
|
|
8288
|
+
const real = found && chosenRealPath(path, found);
|
|
8289
|
+
if (!real || !browsable(real, home.real)) return null;
|
|
8229
8290
|
return real;
|
|
8230
8291
|
}
|
|
8292
|
+
async function realConnectable(home, path) {
|
|
8293
|
+
const real = await realBrowsable(home, path);
|
|
8294
|
+
return real && folderPathProblem(real, home.real) === null ? real : null;
|
|
8295
|
+
}
|
|
8296
|
+
var windowsHome = (home) => /^[A-Za-z]:[\\/]/.test(home.logical);
|
|
8297
|
+
var drivesCache = null;
|
|
8298
|
+
var probing = /* @__PURE__ */ new Map();
|
|
8299
|
+
async function windowsDrives(probe = async (root) => !!(await (0, import_promises7.stat)(root).catch(() => null))?.isDirectory()) {
|
|
8300
|
+
if (drivesCache && Date.now() - drivesCache.at < DRIVES_TTL_MS) return drivesCache.drives;
|
|
8301
|
+
const letters = "CDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
8302
|
+
const answers = await Promise.all(letters.map((letter) => {
|
|
8303
|
+
const root = `${letter}:\\`;
|
|
8304
|
+
let pending = probing.get(root);
|
|
8305
|
+
if (!pending) {
|
|
8306
|
+
pending = probe(root).catch(() => false).finally(() => probing.delete(root));
|
|
8307
|
+
probing.set(root, pending);
|
|
8308
|
+
}
|
|
8309
|
+
return Promise.race([pending, new Promise((done) => setTimeout(done, DRIVE_PROBE_MS, false).unref?.())]);
|
|
8310
|
+
}));
|
|
8311
|
+
const drives = letters.map((letter) => `${letter}:\\`).filter((_, i) => answers[i]);
|
|
8312
|
+
drivesCache = { at: Date.now(), drives };
|
|
8313
|
+
return drives;
|
|
8314
|
+
}
|
|
8231
8315
|
async function resolveBrowsePath(raw, home) {
|
|
8232
8316
|
if (raw !== void 0 && raw !== null && typeof raw !== "string") throw new FolderBrowseError("INVALID_PATH");
|
|
8233
8317
|
const text3 = (raw ?? "").trim();
|
|
@@ -8239,12 +8323,16 @@ async function resolveBrowsePath(raw, home) {
|
|
|
8239
8323
|
const rest = text3.startsWith("~/") || text3.startsWith("~\\") ? text3.slice(2) : text3;
|
|
8240
8324
|
if (rest.split(/[\\/]+/).some((part) => part === ".." || part === ".")) throw new FolderBrowseError("INVALID_PATH");
|
|
8241
8325
|
target = (0, import_path7.isAbsolute)(rest) && rest === text3 ? rest : (0, import_path7.resolve)(home.logical, rest);
|
|
8242
|
-
|
|
8326
|
+
const problem2 = folderBrowseProblem(target, home.logical);
|
|
8327
|
+
if (problem2) throw new FolderBrowseError(problem2);
|
|
8243
8328
|
}
|
|
8244
8329
|
const st = await (0, import_promises7.stat)(target).catch(() => null);
|
|
8245
8330
|
if (!st?.isDirectory()) throw new FolderBrowseError("FOLDER_NOT_FOUND");
|
|
8246
|
-
const
|
|
8247
|
-
if (!
|
|
8331
|
+
const found = await (0, import_promises7.realpath)(target).catch(() => null);
|
|
8332
|
+
if (!found) throw new FolderBrowseError("FOLDER_NOT_FOUND");
|
|
8333
|
+
const real = chosenRealPath(target, found);
|
|
8334
|
+
const problem = folderBrowseProblem(real, home.real);
|
|
8335
|
+
if (problem) throw new FolderBrowseError(problem === "PATH_IS_SYSTEM" ? problem : "PATH_OUTSIDE_HOME");
|
|
8248
8336
|
return real;
|
|
8249
8337
|
}
|
|
8250
8338
|
async function originRemote(repo2) {
|
|
@@ -8291,7 +8379,7 @@ async function hasVisibleChild(dir) {
|
|
|
8291
8379
|
try {
|
|
8292
8380
|
for await (const d of handle) {
|
|
8293
8381
|
if (++seen > CHILD_PROBE) return false;
|
|
8294
|
-
if ((d.isDirectory() || d.isSymbolicLink()) && !skipped(d.name,
|
|
8382
|
+
if ((d.isDirectory() || d.isSymbolicLink()) && !skipped(d.name, isDriveRoot(dir) ? "drive" : null)) return true;
|
|
8295
8383
|
}
|
|
8296
8384
|
return false;
|
|
8297
8385
|
} catch {
|
|
@@ -8300,7 +8388,7 @@ async function hasVisibleChild(dir) {
|
|
|
8300
8388
|
await handle.close().catch(() => void 0);
|
|
8301
8389
|
}
|
|
8302
8390
|
}
|
|
8303
|
-
async function subfolderNames(dir,
|
|
8391
|
+
async function subfolderNames(dir, level) {
|
|
8304
8392
|
const names = [];
|
|
8305
8393
|
let handle;
|
|
8306
8394
|
try {
|
|
@@ -8315,7 +8403,7 @@ async function subfolderNames(dir, atHome) {
|
|
|
8315
8403
|
cut = true;
|
|
8316
8404
|
break;
|
|
8317
8405
|
}
|
|
8318
|
-
if (skipped(d.name,
|
|
8406
|
+
if (skipped(d.name, level)) continue;
|
|
8319
8407
|
if (d.isDirectory()) names.push({ name: d.name, link: false });
|
|
8320
8408
|
else if (d.isSymbolicLink()) names.push({ name: d.name, link: true });
|
|
8321
8409
|
}
|
|
@@ -8349,7 +8437,7 @@ async function listFolders(homePath, rawPath, opts = {}) {
|
|
|
8349
8437
|
const home = await homeOf(homePath);
|
|
8350
8438
|
const real = await resolveBrowsePath(rawPath, home);
|
|
8351
8439
|
const atHome = real === home.real;
|
|
8352
|
-
const { names, cut } = await subfolderNames(real, atHome);
|
|
8440
|
+
const { names, cut } = await subfolderNames(real, atHome ? "home" : isDriveRoot(real) ? "drive" : null);
|
|
8353
8441
|
let truncated = cut;
|
|
8354
8442
|
const found = [];
|
|
8355
8443
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -8358,7 +8446,7 @@ async function listFolders(homePath, rawPath, opts = {}) {
|
|
|
8358
8446
|
if (link) {
|
|
8359
8447
|
const st = await (0, import_promises7.stat)(target).catch(() => null);
|
|
8360
8448
|
if (!st?.isDirectory()) return;
|
|
8361
|
-
const inside3 = await
|
|
8449
|
+
const inside3 = await realBrowsable(home, target);
|
|
8362
8450
|
if (!inside3 || inside3 === home.real) return;
|
|
8363
8451
|
target = inside3;
|
|
8364
8452
|
}
|
|
@@ -8376,9 +8464,11 @@ async function listFolders(homePath, rawPath, opts = {}) {
|
|
|
8376
8464
|
}) || truncated;
|
|
8377
8465
|
const path = logical(home, real);
|
|
8378
8466
|
const rel = (0, import_path7.relative)(home.logical, path);
|
|
8379
|
-
const parentReal =
|
|
8380
|
-
const parent = parentReal &&
|
|
8381
|
-
|
|
8467
|
+
const parentReal = (0, import_path7.resolve)(real, "..");
|
|
8468
|
+
const parent = parentReal !== real && browsable(parentReal, home.real) ? logical(home, parentReal) : null;
|
|
8469
|
+
const inHome = !rel.startsWith("..") && !(0, import_path7.isAbsolute)(rel);
|
|
8470
|
+
const drives = windowsHome(home) ? { drives: await windowsDrives() } : {};
|
|
8471
|
+
return fit({ home: "~", homePath: home.logical, path, relative: inHome ? rel.split(import_path7.sep).join("/") : null, parent, entries: entries.filter((e) => !!e), truncated, ...drives });
|
|
8382
8472
|
}
|
|
8383
8473
|
async function suggestFolders(homePath, sources, opts = {}) {
|
|
8384
8474
|
const started = Date.now();
|
|
@@ -8405,8 +8495,8 @@ async function suggestFolders(homePath, sources, opts = {}) {
|
|
|
8405
8495
|
break;
|
|
8406
8496
|
}
|
|
8407
8497
|
if (typeof folder !== "string" || folderPathProblem(folder, home.logical) && folderPathProblem(folder, home.real)) continue;
|
|
8408
|
-
let dir = await
|
|
8409
|
-
while (dir && dir
|
|
8498
|
+
let dir = await realConnectable(home, folder);
|
|
8499
|
+
while (dir && folderPathProblem(dir, home.real) === null) {
|
|
8410
8500
|
if (await isGitRepo(dir)) {
|
|
8411
8501
|
add(dir, "CONVERSATION");
|
|
8412
8502
|
break;
|
|
@@ -8417,10 +8507,16 @@ async function suggestFolders(homePath, sources, opts = {}) {
|
|
|
8417
8507
|
}
|
|
8418
8508
|
}
|
|
8419
8509
|
const roots = [];
|
|
8420
|
-
|
|
8421
|
-
|
|
8510
|
+
const candidates = DEV_ROOTS.map((root) => (0, import_path7.join)(home.logical, root));
|
|
8511
|
+
if (windowsHome(home)) for (const drive of await windowsDrives()) for (const root of DRIVE_DEV_ROOTS) candidates.push(drive + root);
|
|
8512
|
+
for (const candidate of candidates) {
|
|
8513
|
+
if (Date.now() > deadline) {
|
|
8514
|
+
truncated = true;
|
|
8515
|
+
break;
|
|
8516
|
+
}
|
|
8517
|
+
const real = await realConnectable(home, candidate);
|
|
8422
8518
|
const st = real ? await (0, import_promises7.stat)(real).catch(() => null) : null;
|
|
8423
|
-
if (real &&
|
|
8519
|
+
if (real && st?.isDirectory() && !roots.includes(real)) roots.push(real);
|
|
8424
8520
|
}
|
|
8425
8521
|
const devFound = [];
|
|
8426
8522
|
let level = [];
|
|
@@ -8431,11 +8527,11 @@ async function suggestFolders(homePath, sources, opts = {}) {
|
|
|
8431
8527
|
for (let depth = 1; depth <= SUGGEST_DEPTH && level.length && !truncated; depth++) {
|
|
8432
8528
|
const next = [];
|
|
8433
8529
|
const finished = await eachUntil(level, deadline, async (dir) => {
|
|
8434
|
-
const { names } = await subfolderNames(dir,
|
|
8530
|
+
const { names } = await subfolderNames(dir, null);
|
|
8435
8531
|
for (const { name, link } of names) {
|
|
8436
8532
|
const child = (0, import_path7.join)(dir, name);
|
|
8437
|
-
const real = link ? await
|
|
8438
|
-
if (!real
|
|
8533
|
+
const real = link ? await realConnectable(home, child) : child;
|
|
8534
|
+
if (!real) continue;
|
|
8439
8535
|
if (await isGitRepo(real)) devFound.push(real);
|
|
8440
8536
|
else if (depth < SUGGEST_DEPTH) next.push(real);
|
|
8441
8537
|
}
|
|
@@ -8447,7 +8543,7 @@ async function suggestFolders(homePath, sources, opts = {}) {
|
|
|
8447
8543
|
}
|
|
8448
8544
|
level = next;
|
|
8449
8545
|
}
|
|
8450
|
-
devFound.sort((a, b) => (
|
|
8546
|
+
devFound.sort((a, b) => logical(home, a).localeCompare(logical(home, b), void 0, { sensitivity: "base", numeric: true }));
|
|
8451
8547
|
for (const real of devFound) add(real, "DEV_ROOT");
|
|
8452
8548
|
const entries = out2.map(() => null);
|
|
8453
8549
|
const done = await eachUntil(out2.map((f, i) => ({ f, i })), deadline + 1e3, async ({ f, i }) => {
|
|
@@ -8615,6 +8711,8 @@ var FOLDER_MESSAGES = {
|
|
|
8615
8711
|
PATH_IS_ROOT: "The root of the disk cannot be connected.",
|
|
8616
8712
|
PATH_IS_HOME: "Your whole home folder cannot be connected. Choose a project folder inside it.",
|
|
8617
8713
|
PATH_OUTSIDE_HOME: "Only folders inside your home folder can be connected.",
|
|
8714
|
+
PATH_IS_SYSTEM: "A folder of Windows itself cannot be connected.",
|
|
8715
|
+
PATH_CONTAINS_HOME: "This folder holds your home folder and cannot be connected. Choose a project folder.",
|
|
8618
8716
|
INVALID_PATH: "That folder path is not valid.",
|
|
8619
8717
|
HOME_UNKNOWN: "Your home folder could not be determined.",
|
|
8620
8718
|
FOLDER_NOT_FOUND: "That folder does not exist.",
|
|
@@ -8625,7 +8723,7 @@ async function checkFolder(path, home) {
|
|
|
8625
8723
|
if (shape) throw new FolderError(shape, FOLDER_MESSAGES[shape] ?? "That folder cannot be connected.");
|
|
8626
8724
|
const st = await (0, import_promises8.stat)(path).catch(() => null);
|
|
8627
8725
|
if (!st?.isDirectory()) throw new FolderError("FOLDER_NOT_FOUND", FOLDER_MESSAGES.FOLDER_NOT_FOUND);
|
|
8628
|
-
const real = await (0, import_promises8.realpath)(path);
|
|
8726
|
+
const real = chosenRealPath(path, await (0, import_promises8.realpath)(path));
|
|
8629
8727
|
const realHome = await (0, import_promises8.realpath)(home).catch(() => home);
|
|
8630
8728
|
const problem = folderPathProblem(real, realHome);
|
|
8631
8729
|
if (problem) throw new FolderError(problem, FOLDER_MESSAGES[problem] ?? "That folder cannot be connected.");
|
|
@@ -8956,11 +9054,11 @@ async function addFolder(credentials2, api, path, home) {
|
|
|
8956
9054
|
|
|
8957
9055
|
// src/application/services/workspaceSandbox/WorkspaceEngine.ts
|
|
8958
9056
|
var import_child_process5 = require("child_process");
|
|
8959
|
-
var
|
|
8960
|
-
var
|
|
9057
|
+
var import_promises17 = require("fs/promises");
|
|
9058
|
+
var import_fs12 = require("fs");
|
|
8961
9059
|
var import_os6 = require("os");
|
|
8962
9060
|
var import_crypto9 = require("crypto");
|
|
8963
|
-
var
|
|
9061
|
+
var import_path18 = require("path");
|
|
8964
9062
|
|
|
8965
9063
|
// src/application/services/execution/LanguageAdapter.ts
|
|
8966
9064
|
var import_async_hooks = require("async_hooks");
|
|
@@ -9148,7 +9246,7 @@ var import_os5 = require("os");
|
|
|
9148
9246
|
var import_path10 = require("path");
|
|
9149
9247
|
var import_url = require("url");
|
|
9150
9248
|
|
|
9151
|
-
// node_modules/zod/v3/external.js
|
|
9249
|
+
// ../aig-folder-scope/node_modules/zod/v3/external.js
|
|
9152
9250
|
var external_exports = {};
|
|
9153
9251
|
__export(external_exports, {
|
|
9154
9252
|
BRAND: () => BRAND,
|
|
@@ -9260,7 +9358,7 @@ __export(external_exports, {
|
|
|
9260
9358
|
void: () => voidType
|
|
9261
9359
|
});
|
|
9262
9360
|
|
|
9263
|
-
// node_modules/zod/v3/helpers/util.js
|
|
9361
|
+
// ../aig-folder-scope/node_modules/zod/v3/helpers/util.js
|
|
9264
9362
|
var util;
|
|
9265
9363
|
(function(util2) {
|
|
9266
9364
|
util2.assertEqual = (_) => {
|
|
@@ -9394,7 +9492,7 @@ var getParsedType = (data) => {
|
|
|
9394
9492
|
}
|
|
9395
9493
|
};
|
|
9396
9494
|
|
|
9397
|
-
// node_modules/zod/v3/ZodError.js
|
|
9495
|
+
// ../aig-folder-scope/node_modules/zod/v3/ZodError.js
|
|
9398
9496
|
var ZodIssueCode = util.arrayToEnum([
|
|
9399
9497
|
"invalid_type",
|
|
9400
9498
|
"invalid_literal",
|
|
@@ -9512,7 +9610,7 @@ ZodError.create = (issues) => {
|
|
|
9512
9610
|
return error;
|
|
9513
9611
|
};
|
|
9514
9612
|
|
|
9515
|
-
// node_modules/zod/v3/locales/en.js
|
|
9613
|
+
// ../aig-folder-scope/node_modules/zod/v3/locales/en.js
|
|
9516
9614
|
var errorMap = (issue, _ctx) => {
|
|
9517
9615
|
let message;
|
|
9518
9616
|
switch (issue.code) {
|
|
@@ -9615,7 +9713,7 @@ var errorMap = (issue, _ctx) => {
|
|
|
9615
9713
|
};
|
|
9616
9714
|
var en_default = errorMap;
|
|
9617
9715
|
|
|
9618
|
-
// node_modules/zod/v3/errors.js
|
|
9716
|
+
// ../aig-folder-scope/node_modules/zod/v3/errors.js
|
|
9619
9717
|
var overrideErrorMap = en_default;
|
|
9620
9718
|
function setErrorMap(map) {
|
|
9621
9719
|
overrideErrorMap = map;
|
|
@@ -9624,7 +9722,7 @@ function getErrorMap() {
|
|
|
9624
9722
|
return overrideErrorMap;
|
|
9625
9723
|
}
|
|
9626
9724
|
|
|
9627
|
-
// node_modules/zod/v3/helpers/parseUtil.js
|
|
9725
|
+
// ../aig-folder-scope/node_modules/zod/v3/helpers/parseUtil.js
|
|
9628
9726
|
var makeIssue = (params) => {
|
|
9629
9727
|
const { data, path, errorMaps, issueData } = params;
|
|
9630
9728
|
const fullPath = [...path, ...issueData.path || []];
|
|
@@ -9734,14 +9832,14 @@ var isDirty = (x) => x.status === "dirty";
|
|
|
9734
9832
|
var isValid = (x) => x.status === "valid";
|
|
9735
9833
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
9736
9834
|
|
|
9737
|
-
// node_modules/zod/v3/helpers/errorUtil.js
|
|
9835
|
+
// ../aig-folder-scope/node_modules/zod/v3/helpers/errorUtil.js
|
|
9738
9836
|
var errorUtil;
|
|
9739
9837
|
(function(errorUtil2) {
|
|
9740
9838
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
9741
9839
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
9742
9840
|
})(errorUtil || (errorUtil = {}));
|
|
9743
9841
|
|
|
9744
|
-
// node_modules/zod/v3/types.js
|
|
9842
|
+
// ../aig-folder-scope/node_modules/zod/v3/types.js
|
|
9745
9843
|
var ParseInputLazyPath = class {
|
|
9746
9844
|
constructor(parent, value, path, key) {
|
|
9747
9845
|
this._cachedPath = [];
|
|
@@ -13496,6 +13594,115 @@ function designReport(path, manifest, checks) {
|
|
|
13496
13594
|
}
|
|
13497
13595
|
var designPath = (root, absManifest) => (0, import_path10.relative)(root, absManifest).split(import_path10.sep).join("/");
|
|
13498
13596
|
|
|
13597
|
+
// src/application/services/workspaceSandbox/rootFiles.ts
|
|
13598
|
+
var import_promises11 = require("fs/promises");
|
|
13599
|
+
var import_fs9 = require("fs");
|
|
13600
|
+
var import_path11 = require("path");
|
|
13601
|
+
var ROOT_FILE_MAX_BYTES = 5 * 1024 * 1024;
|
|
13602
|
+
var ROOT_FILES_MAX_BYTES = 24 * 1024 * 1024;
|
|
13603
|
+
var ROOT_FILES_MAX_COUNT = 2e3;
|
|
13604
|
+
var ROOT_FILES_SCAN_MAX = 2e4;
|
|
13605
|
+
var posix3 = (p) => p.split(import_path11.sep).join("/");
|
|
13606
|
+
async function listRootFiles(root, excluded) {
|
|
13607
|
+
const skip = new Set(excluded.map((d) => d.replace(/[\\/]+$/, "")));
|
|
13608
|
+
const found = [];
|
|
13609
|
+
const walk = async (dir) => {
|
|
13610
|
+
const handle = await (0, import_promises11.opendir)(dir).catch(() => null);
|
|
13611
|
+
if (!handle) return;
|
|
13612
|
+
for await (const entry of handle) {
|
|
13613
|
+
if (found.length >= ROOT_FILES_SCAN_MAX) break;
|
|
13614
|
+
const abs = (0, import_path11.join)(dir, entry.name);
|
|
13615
|
+
if (entry.isSymbolicLink()) continue;
|
|
13616
|
+
if (entry.isDirectory()) {
|
|
13617
|
+
if (entry.name.startsWith(".") || DISCOVERY_SKIP.has(entry.name) || skip.has(abs)) continue;
|
|
13618
|
+
if ((0, import_fs9.existsSync)((0, import_path11.join)(abs, ".git"))) continue;
|
|
13619
|
+
await walk(abs);
|
|
13620
|
+
} else if (entry.isFile()) {
|
|
13621
|
+
const st = await (0, import_promises11.lstat)(abs).catch(() => null);
|
|
13622
|
+
if (st?.isFile()) found.push({ path: posix3((0, import_path11.relative)(root, abs)), size: st.size, mtimeMs: st.mtimeMs });
|
|
13623
|
+
}
|
|
13624
|
+
}
|
|
13625
|
+
};
|
|
13626
|
+
await walk(root);
|
|
13627
|
+
found.sort((a, b) => b.mtimeMs - a.mtimeMs || a.path.localeCompare(b.path));
|
|
13628
|
+
const files = [];
|
|
13629
|
+
let total = 0;
|
|
13630
|
+
for (const f of found) {
|
|
13631
|
+
if (f.size > ROOT_FILE_MAX_BYTES || total + f.size > ROOT_FILES_MAX_BYTES || files.length >= ROOT_FILES_MAX_COUNT) continue;
|
|
13632
|
+
files.push(f);
|
|
13633
|
+
total += f.size;
|
|
13634
|
+
}
|
|
13635
|
+
return { files: files.sort((a, b) => a.path.localeCompare(b.path)), leftOut: found.length - files.length };
|
|
13636
|
+
}
|
|
13637
|
+
async function withScratchGit(scratch, workTree, fn) {
|
|
13638
|
+
await (0, import_promises11.mkdir)(scratch, { recursive: true });
|
|
13639
|
+
const gitDir = await (0, import_promises11.mkdtemp)((0, import_path11.join)(scratch, "root-files-"));
|
|
13640
|
+
try {
|
|
13641
|
+
await git(["init", "-q", "--bare", gitDir], { cwd: scratch });
|
|
13642
|
+
for (const [k, v] of [["core.bare", "false"], ["core.autocrlf", "false"], ["core.safecrlf", "false"], ["gc.auto", "0"]]) {
|
|
13643
|
+
await git(["config", k, v], { cwd: scratch, env: { GIT_DIR: gitDir } });
|
|
13644
|
+
}
|
|
13645
|
+
return await fn({ GIT_DIR: gitDir, GIT_WORK_TREE: workTree });
|
|
13646
|
+
} finally {
|
|
13647
|
+
await (0, import_promises11.rm)(gitDir, { recursive: true, force: true }).catch(() => void 0);
|
|
13648
|
+
}
|
|
13649
|
+
}
|
|
13650
|
+
async function rootFilesCheckpoint(root, scratch, files) {
|
|
13651
|
+
if (!files.length) return "";
|
|
13652
|
+
return withScratchGit(scratch, root, (env) => checkpointPatch(root, EMPTY_TREE.sha1, { env, index: null, paths: files.map((f) => f.path) }));
|
|
13653
|
+
}
|
|
13654
|
+
async function restoreRootFiles(root, scratch, patch) {
|
|
13655
|
+
if (!patch.includes("diff --git ")) return { restored: 0, kept: 0 };
|
|
13656
|
+
await (0, import_promises11.mkdir)(scratch, { recursive: true });
|
|
13657
|
+
const out2 = await (0, import_promises11.mkdtemp)((0, import_path11.join)(scratch, "root-restore-"));
|
|
13658
|
+
try {
|
|
13659
|
+
const patchFile = (0, import_path11.join)(scratch, `${Date.now().toString(36)}-root-files.patch`);
|
|
13660
|
+
await (0, import_promises11.writeFile)(patchFile, patch, "utf8");
|
|
13661
|
+
try {
|
|
13662
|
+
await withScratchGit(scratch, out2, (env) => git(["apply", "--binary", "--whitespace=nowarn", patchFile], { cwd: out2, env, timeoutMs: 5 * 6e4 }));
|
|
13663
|
+
} finally {
|
|
13664
|
+
await (0, import_promises11.rm)(patchFile, { force: true }).catch(() => void 0);
|
|
13665
|
+
}
|
|
13666
|
+
const { files } = await listRootFiles(out2, []);
|
|
13667
|
+
let restored = 0;
|
|
13668
|
+
let kept = 0;
|
|
13669
|
+
for (const f of files) {
|
|
13670
|
+
const target = await resolveInside(root, f.path);
|
|
13671
|
+
if (!target) continue;
|
|
13672
|
+
if ((0, import_fs9.existsSync)(target)) {
|
|
13673
|
+
kept++;
|
|
13674
|
+
continue;
|
|
13675
|
+
}
|
|
13676
|
+
await (0, import_promises11.mkdir)((0, import_path11.dirname)(target), { recursive: true });
|
|
13677
|
+
const from = (0, import_path11.join)(out2, f.path);
|
|
13678
|
+
await (0, import_promises11.copyFile)(from, target);
|
|
13679
|
+
const mode = (await (0, import_promises11.stat)(from)).mode & 511;
|
|
13680
|
+
await (0, import_promises11.chmod)(target, mode).catch(() => void 0);
|
|
13681
|
+
restored++;
|
|
13682
|
+
}
|
|
13683
|
+
return { restored, kept };
|
|
13684
|
+
} finally {
|
|
13685
|
+
await (0, import_promises11.rm)(out2, { recursive: true, force: true }).catch(() => void 0);
|
|
13686
|
+
}
|
|
13687
|
+
}
|
|
13688
|
+
var DESIGN_FILE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}(\/[A-Za-z0-9][A-Za-z0-9._-]{0,99})?$/;
|
|
13689
|
+
async function restoreKeptDesign(root, path, files) {
|
|
13690
|
+
if (!/(^|\/)design\.json$/.test(path) || !files.some((f) => f.name === "design.json")) return 0;
|
|
13691
|
+
const folder = path.replace(/design\.json$/, "");
|
|
13692
|
+
const manifest = await resolveInside(root, `${folder}design.json`);
|
|
13693
|
+
if (!manifest || (0, import_fs9.existsSync)(manifest)) return 0;
|
|
13694
|
+
let written = 0;
|
|
13695
|
+
for (const f of files) {
|
|
13696
|
+
if (!DESIGN_FILE.test(f.name) || typeof f.data !== "string") continue;
|
|
13697
|
+
const target = await resolveInside(root, `${folder}${f.name}`);
|
|
13698
|
+
if (!target || (0, import_fs9.existsSync)(target)) continue;
|
|
13699
|
+
await (0, import_promises11.mkdir)((0, import_path11.dirname)(target), { recursive: true });
|
|
13700
|
+
await (0, import_promises11.writeFile)(target, Buffer.from(f.data, "base64"));
|
|
13701
|
+
written++;
|
|
13702
|
+
}
|
|
13703
|
+
return written;
|
|
13704
|
+
}
|
|
13705
|
+
|
|
13499
13706
|
// src/application/services/workspaceSandbox/engineMessages.ts
|
|
13500
13707
|
var ENGINE_MESSAGES = {
|
|
13501
13708
|
// Start and preparation.
|
|
@@ -13534,6 +13741,9 @@ var ENGINE_MESSAGES = {
|
|
|
13534
13741
|
// The AI Workspace's own credit (gateway BUDGET codes): said as credit, not as a budget the organization set.
|
|
13535
13742
|
MANAGED_ALLOWANCE_EXHAUSTED: "The AI Workspace credit ran out ({code}).",
|
|
13536
13743
|
MANAGED_PREPAID_REQUIRED: "This model uses purchased credit, and the purchased credit ran out ({code}).",
|
|
13744
|
+
// The person's own usage limit: waiting for the reset, or purchased credit, continues it.
|
|
13745
|
+
PERSON_LIMIT_REACHED: "You reached your usage limit for this period ({code}).",
|
|
13746
|
+
PERSON_LIMIT_CREDITS_REQUIRED: "You reached your usage limit, and continuing needs purchased credit ({code}).",
|
|
13537
13747
|
// Files, rewind and hunks.
|
|
13538
13748
|
DISCARD_FAILED: "The change to that file could not be discarded.",
|
|
13539
13749
|
DISCARD_REPOSITORY_REQUIRED: "Say which repository the file belongs to.",
|
|
@@ -13596,6 +13806,10 @@ var GATEWAY_CODE_CATEGORIES = Object.freeze({
|
|
|
13596
13806
|
"MANAGED_PREPAID_REQUIRED"
|
|
13597
13807
|
].map((c) => [c, "BUDGET"])),
|
|
13598
13808
|
PERSON_BUDGET_EXHAUSTED: "PERSON_BUDGET",
|
|
13809
|
+
// The person's usage limit (runtime gateway, migration 069): 402 with no rule in CODE_ERROR_RULES, so the code is the
|
|
13810
|
+
// only thing that says it. Without these the screen told a person past their limit to "send again" (MODEL_UNKNOWN).
|
|
13811
|
+
PERSON_LIMIT_REACHED: "PERSON_BUDGET",
|
|
13812
|
+
PERSON_LIMIT_CREDITS_REQUIRED: "PERSON_BUDGET",
|
|
13599
13813
|
CONCURRENCY_LIMIT: "CONCURRENCY",
|
|
13600
13814
|
ORGANIZATION_CONCURRENCY_LIMIT: "CONCURRENCY",
|
|
13601
13815
|
...Object.fromEntries([
|
|
@@ -13993,24 +14207,24 @@ function buildScaleQualityServer(sdk, host) {
|
|
|
13993
14207
|
}
|
|
13994
14208
|
|
|
13995
14209
|
// src/application/services/workspaceSandbox/projectConventions.ts
|
|
13996
|
-
var
|
|
13997
|
-
var
|
|
14210
|
+
var import_promises12 = require("fs/promises");
|
|
14211
|
+
var import_path12 = require("path");
|
|
13998
14212
|
var CONVENTION_FILES = ["CLAUDE.md", "AGENTS.md", ".claude/CLAUDE.md"];
|
|
13999
14213
|
var CONVENTION_CAPS = { perFileBytes: 24 * 1024, totalBytes: 64 * 1024 };
|
|
14000
14214
|
async function readConventions(repos, caps = CONVENTION_CAPS) {
|
|
14001
14215
|
const out2 = [];
|
|
14002
14216
|
let total = 0;
|
|
14003
14217
|
for (const repo2 of repos) {
|
|
14004
|
-
const realRoot = await (0,
|
|
14218
|
+
const realRoot = await (0, import_promises12.realpath)(repo2.root).catch(() => null);
|
|
14005
14219
|
if (!realRoot) continue;
|
|
14006
14220
|
for (const name of CONVENTION_FILES) {
|
|
14007
14221
|
if (total >= caps.totalBytes) return out2;
|
|
14008
|
-
const abs = (0,
|
|
14009
|
-
const st = await (0,
|
|
14222
|
+
const abs = (0, import_path12.join)(repo2.root, name);
|
|
14223
|
+
const st = await (0, import_promises12.lstat)(abs).catch(() => null);
|
|
14010
14224
|
if (!st?.isFile()) continue;
|
|
14011
|
-
const real = await (0,
|
|
14012
|
-
if (!real || (0,
|
|
14013
|
-
const buf = await (0,
|
|
14225
|
+
const real = await (0, import_promises12.realpath)(abs).catch(() => null);
|
|
14226
|
+
if (!real || (0, import_path12.relative)(realRoot, real).startsWith("..") || (0, import_path12.relative)(realRoot, real).split(import_path12.sep).includes("..")) continue;
|
|
14227
|
+
const buf = await (0, import_promises12.readFile)(abs).catch(() => null);
|
|
14014
14228
|
if (!buf || buf.includes(0)) continue;
|
|
14015
14229
|
const room = Math.min(caps.perFileBytes, caps.totalBytes - total);
|
|
14016
14230
|
let text3 = buf.toString("utf8");
|
|
@@ -14036,7 +14250,7 @@ ${f.text.replace(/<\/project_conventions>/g, "")}
|
|
|
14036
14250
|
}
|
|
14037
14251
|
|
|
14038
14252
|
// src/application/services/workspaceSandbox/sdkEventMapper.ts
|
|
14039
|
-
var
|
|
14253
|
+
var import_path13 = require("path");
|
|
14040
14254
|
var TERMINAL_TAIL_BYTES = 64 * 1024;
|
|
14041
14255
|
var FILE_CHANGING = /* @__PURE__ */ new Set(["Edit", "MultiEdit", "Write", "NotebookEdit", "Bash", "Agent", "Task"]);
|
|
14042
14256
|
var SUBAGENT_NAMES = /* @__PURE__ */ new Set(["Agent", "Task"]);
|
|
@@ -14457,8 +14671,8 @@ function describeTool(name, input, root) {
|
|
|
14457
14671
|
const s = (k) => typeof input[k] === "string" ? input[k] : "";
|
|
14458
14672
|
const rel = (p) => {
|
|
14459
14673
|
if (!p) return "";
|
|
14460
|
-
if (!(0,
|
|
14461
|
-
const r = (0,
|
|
14674
|
+
if (!(0, import_path13.isAbsolute)(p)) return p;
|
|
14675
|
+
const r = (0, import_path13.relative)(root, p);
|
|
14462
14676
|
return r && !r.startsWith("..") ? r : p;
|
|
14463
14677
|
};
|
|
14464
14678
|
switch (name) {
|
|
@@ -14472,10 +14686,10 @@ function describeTool(name, input, root) {
|
|
|
14472
14686
|
return { kind: "search", label: `Searching for "${clip(s("pattern"), 80)}"`, detail: s("pattern"), code: "STEP_SEARCH", params: { pattern: clip(s("pattern"), 80) } };
|
|
14473
14687
|
case "Edit":
|
|
14474
14688
|
case "MultiEdit":
|
|
14475
|
-
if (/[\\/]plans[\\/][^\\/]+\.md$/.test(s("file_path")) && (0,
|
|
14689
|
+
if (/[\\/]plans[\\/][^\\/]+\.md$/.test(s("file_path")) && (0, import_path13.isAbsolute)(rel(s("file_path")))) return { kind: "think", label: "Writing the plan", code: "STEP_PLAN_WRITE" };
|
|
14476
14690
|
return { kind: "edit", label: `Editing ${rel(s("file_path"))}`, detail: rel(s("file_path")), code: "STEP_EDIT", params: { path: rel(s("file_path")) } };
|
|
14477
14691
|
case "Write":
|
|
14478
|
-
if (/[\\/]plans[\\/][^\\/]+\.md$/.test(s("file_path")) && (0,
|
|
14692
|
+
if (/[\\/]plans[\\/][^\\/]+\.md$/.test(s("file_path")) && (0, import_path13.isAbsolute)(rel(s("file_path")))) return { kind: "think", label: "Writing the plan", code: "STEP_PLAN_WRITE" };
|
|
14479
14693
|
return { kind: "edit", label: `Writing ${rel(s("file_path"))}`, detail: rel(s("file_path")), code: "STEP_WRITE", params: { path: rel(s("file_path")) } };
|
|
14480
14694
|
case "NotebookEdit":
|
|
14481
14695
|
return { kind: "edit", label: `Editing ${rel(s("notebook_path"))}`, detail: rel(s("notebook_path")), code: "STEP_EDIT", params: { path: rel(s("notebook_path")) } };
|
|
@@ -14932,9 +15146,9 @@ function buildSystemAppend(c) {
|
|
|
14932
15146
|
}
|
|
14933
15147
|
|
|
14934
15148
|
// src/application/services/workspaceSandbox/testCommand.ts
|
|
14935
|
-
var
|
|
14936
|
-
var
|
|
14937
|
-
var
|
|
15149
|
+
var import_fs10 = require("fs");
|
|
15150
|
+
var import_promises13 = require("fs/promises");
|
|
15151
|
+
var import_path14 = require("path");
|
|
14938
15152
|
function commandForFramework(framework, dir, pkgTestScript) {
|
|
14939
15153
|
switch (framework) {
|
|
14940
15154
|
case "jest":
|
|
@@ -14946,13 +15160,13 @@ function commandForFramework(framework, dir, pkgTestScript) {
|
|
|
14946
15160
|
case "go-test":
|
|
14947
15161
|
return "go test ./...";
|
|
14948
15162
|
case "junit":
|
|
14949
|
-
return (0,
|
|
15163
|
+
return (0, import_fs10.existsSync)((0, import_path14.join)(dir, "gradlew")) ? "./gradlew test" : (0, import_fs10.existsSync)((0, import_path14.join)(dir, "build.gradle")) || (0, import_fs10.existsSync)((0, import_path14.join)(dir, "build.gradle.kts")) ? "gradle test" : "mvn -q test";
|
|
14950
15164
|
case "xunit":
|
|
14951
15165
|
case "nunit":
|
|
14952
15166
|
case "mstest":
|
|
14953
15167
|
return "dotnet test";
|
|
14954
15168
|
case "phpunit":
|
|
14955
|
-
return (0,
|
|
15169
|
+
return (0, import_fs10.existsSync)((0, import_path14.join)(dir, "vendor", "bin", "phpunit")) ? "vendor/bin/phpunit" : "phpunit";
|
|
14956
15170
|
case "rspec":
|
|
14957
15171
|
return "bundle exec rspec";
|
|
14958
15172
|
case "cargo-test":
|
|
@@ -14960,7 +15174,7 @@ function commandForFramework(framework, dir, pkgTestScript) {
|
|
|
14960
15174
|
case "exunit":
|
|
14961
15175
|
return "mix test";
|
|
14962
15176
|
case "dart-test":
|
|
14963
|
-
return (0,
|
|
15177
|
+
return (0, import_fs10.existsSync)((0, import_path14.join)(dir, "pubspec.yaml")) && /flutter:/.test(safeRead((0, import_path14.join)(dir, "pubspec.yaml"))) ? "flutter test" : "dart test";
|
|
14964
15178
|
case "xctest":
|
|
14965
15179
|
return "swift test";
|
|
14966
15180
|
case "scalatest":
|
|
@@ -14973,13 +15187,13 @@ function commandForFramework(framework, dir, pkgTestScript) {
|
|
|
14973
15187
|
}
|
|
14974
15188
|
function safeRead(p) {
|
|
14975
15189
|
try {
|
|
14976
|
-
return (0,
|
|
15190
|
+
return (0, import_fs10.readFileSync)(p, "utf8");
|
|
14977
15191
|
} catch {
|
|
14978
15192
|
return "";
|
|
14979
15193
|
}
|
|
14980
15194
|
}
|
|
14981
15195
|
async function hasTestScript(dir) {
|
|
14982
|
-
const raw = await (0,
|
|
15196
|
+
const raw = await (0, import_promises13.readFile)((0, import_path14.join)(dir, "package.json"), "utf8").catch(() => null);
|
|
14983
15197
|
if (!raw) return false;
|
|
14984
15198
|
try {
|
|
14985
15199
|
const script = JSON.parse(raw).scripts?.test;
|
|
@@ -14989,7 +15203,7 @@ async function hasTestScript(dir) {
|
|
|
14989
15203
|
}
|
|
14990
15204
|
}
|
|
14991
15205
|
async function detectTestCommandFromManifests(dir) {
|
|
14992
|
-
const has = (f) => (0,
|
|
15206
|
+
const has = (f) => (0, import_fs10.existsSync)((0, import_path14.join)(dir, f));
|
|
14993
15207
|
const pkgScript = await hasTestScript(dir);
|
|
14994
15208
|
if (pkgScript) return { command: "npm test --silent", framework: "npm-script", source: "manifest" };
|
|
14995
15209
|
const checks = [
|
|
@@ -15014,9 +15228,9 @@ async function detectTestCommandFromManifests(dir) {
|
|
|
15014
15228
|
|
|
15015
15229
|
// src/application/services/workspaceSandbox/transcript.ts
|
|
15016
15230
|
var import_crypto8 = require("crypto");
|
|
15017
|
-
var
|
|
15018
|
-
var
|
|
15019
|
-
var
|
|
15231
|
+
var import_fs11 = require("fs");
|
|
15232
|
+
var import_promises14 = require("fs/promises");
|
|
15233
|
+
var import_path15 = require("path");
|
|
15020
15234
|
var import_zlib2 = require("zlib");
|
|
15021
15235
|
var TRANSCRIPT_CAPS = { maxRawBytes: 64 * 1024 * 1024, maxCompressedBytes: 4 * 1024 * 1024 };
|
|
15022
15236
|
function engineProjectDir(cwd) {
|
|
@@ -15025,10 +15239,10 @@ function engineProjectDir(cwd) {
|
|
|
15025
15239
|
var SESSION_ID = /^[A-Za-z0-9-]{8,80}$/;
|
|
15026
15240
|
async function findTranscript(configDir, sessionId) {
|
|
15027
15241
|
if (!SESSION_ID.test(sessionId)) return null;
|
|
15028
|
-
const projects = (0,
|
|
15029
|
-
for (const dir of await (0,
|
|
15030
|
-
const file = (0,
|
|
15031
|
-
const st = await (0,
|
|
15242
|
+
const projects = (0, import_path15.join)(configDir, "projects");
|
|
15243
|
+
for (const dir of await (0, import_promises14.readdir)(projects).catch(() => [])) {
|
|
15244
|
+
const file = (0, import_path15.join)(projects, dir, `${sessionId}.jsonl`);
|
|
15245
|
+
const st = await (0, import_promises14.stat)(file).catch(() => null);
|
|
15032
15246
|
if (st?.isFile()) return file;
|
|
15033
15247
|
}
|
|
15034
15248
|
return null;
|
|
@@ -15036,9 +15250,9 @@ async function findTranscript(configDir, sessionId) {
|
|
|
15036
15250
|
async function packTranscript(configDir, sessionId, redactor, caps = TRANSCRIPT_CAPS) {
|
|
15037
15251
|
const file = await findTranscript(configDir, sessionId);
|
|
15038
15252
|
if (!file) return null;
|
|
15039
|
-
const st = await (0,
|
|
15253
|
+
const st = await (0, import_promises14.stat)(file);
|
|
15040
15254
|
if (st.size > caps.maxRawBytes) return { tooLarge: true, bytes: st.size };
|
|
15041
|
-
const raw = await (0,
|
|
15255
|
+
const raw = await (0, import_promises14.readFile)(file, "utf8");
|
|
15042
15256
|
let removed = 0;
|
|
15043
15257
|
const lines2 = [];
|
|
15044
15258
|
for (const line of raw.split("\n")) {
|
|
@@ -15073,19 +15287,19 @@ async function restoreTranscript(configDir, cwd, t) {
|
|
|
15073
15287
|
return false;
|
|
15074
15288
|
}
|
|
15075
15289
|
if (t.sha256 && (0, import_crypto8.createHash)("sha256").update(text3).digest("hex") !== t.sha256) return false;
|
|
15076
|
-
const dir = (0,
|
|
15077
|
-
await (0,
|
|
15078
|
-
const target = (0,
|
|
15290
|
+
const dir = (0, import_path15.join)(configDir, "projects", engineProjectDir(cwd));
|
|
15291
|
+
await (0, import_promises14.mkdir)(dir, { recursive: true, mode: 448 });
|
|
15292
|
+
const target = (0, import_path15.join)(dir, `${t.sdkSessionId}.jsonl`);
|
|
15079
15293
|
const partial = `${target}.${process.pid}.partial`;
|
|
15080
15294
|
try {
|
|
15081
|
-
await (0,
|
|
15082
|
-
await (0,
|
|
15083
|
-
await (0,
|
|
15295
|
+
await (0, import_promises14.writeFile)(partial, text3, { mode: 384 });
|
|
15296
|
+
await (0, import_promises14.chmod)(partial, 384).catch(() => void 0);
|
|
15297
|
+
await (0, import_promises14.rename)(partial, target);
|
|
15084
15298
|
} catch {
|
|
15085
|
-
await (0,
|
|
15299
|
+
await (0, import_promises14.rm)(partial, { force: true }).catch(() => void 0);
|
|
15086
15300
|
return false;
|
|
15087
15301
|
}
|
|
15088
|
-
return (0,
|
|
15302
|
+
return (0, import_fs11.existsSync)(target);
|
|
15089
15303
|
}
|
|
15090
15304
|
|
|
15091
15305
|
// src/application/services/workspaceSandbox/askQuestion.ts
|
|
@@ -15185,8 +15399,8 @@ function questionResult(o, input) {
|
|
|
15185
15399
|
}
|
|
15186
15400
|
|
|
15187
15401
|
// src/application/services/workspaceSandbox/workspaceFiles.ts
|
|
15188
|
-
var
|
|
15189
|
-
var
|
|
15402
|
+
var import_promises15 = require("fs/promises");
|
|
15403
|
+
var import_path16 = require("path");
|
|
15190
15404
|
var FILE_CAPS = { maxEntries: 500, maxReadBytes: 256 * 1024, maxFileBytes: 20 * 1024 * 1024, maxLines: 5e3, maxImageBytes: 6 * 1024 * 1024 };
|
|
15191
15405
|
var FileRequestError = class extends Error {
|
|
15192
15406
|
constructor(code) {
|
|
@@ -15201,36 +15415,36 @@ async function fenced(root, rel, denied) {
|
|
|
15201
15415
|
if (clean.split(/[\\/]/).includes("..")) throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
15202
15416
|
const abs = await resolveInside(root, clean || ".");
|
|
15203
15417
|
if (!abs) throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
15204
|
-
const realRoot = await (0,
|
|
15205
|
-
const r = (0,
|
|
15206
|
-
if (r.split(
|
|
15418
|
+
const realRoot = await (0, import_promises15.realpath)(root).catch(() => (0, import_path16.resolve)(root));
|
|
15419
|
+
const r = (0, import_path16.relative)(realRoot, abs);
|
|
15420
|
+
if (r.split(import_path16.sep).includes(".git")) throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
15207
15421
|
for (const d of denied) {
|
|
15208
|
-
const realDenied = await (0,
|
|
15209
|
-
if (abs === realDenied || abs.startsWith(realDenied +
|
|
15422
|
+
const realDenied = await (0, import_promises15.realpath)(d).catch(() => (0, import_path16.resolve)(d));
|
|
15423
|
+
if (abs === realDenied || abs.startsWith(realDenied + import_path16.sep)) throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
15210
15424
|
}
|
|
15211
|
-
return { abs, rel: r.split(
|
|
15425
|
+
return { abs, rel: r.split(import_path16.sep).join("/") };
|
|
15212
15426
|
}
|
|
15213
15427
|
async function listFiles(root, rel, denied = []) {
|
|
15214
15428
|
const { abs, rel: clean } = await fenced(root, rel, denied);
|
|
15215
|
-
const st = await (0,
|
|
15429
|
+
const st = await (0, import_promises15.stat)(abs).catch(() => null);
|
|
15216
15430
|
if (!st) throw new FileRequestError("NOT_FOUND");
|
|
15217
15431
|
if (!st.isDirectory()) throw new FileRequestError("NOT_A_DIRECTORY");
|
|
15218
|
-
const deniedReal = await Promise.all(denied.map((d) => (0,
|
|
15219
|
-
const dirents = await (0,
|
|
15432
|
+
const deniedReal = await Promise.all(denied.map((d) => (0, import_promises15.realpath)(d).catch(() => (0, import_path16.resolve)(d))));
|
|
15433
|
+
const dirents = await (0, import_promises15.readdir)(abs, { withFileTypes: true });
|
|
15220
15434
|
const entries = [];
|
|
15221
15435
|
for (const d of dirents) {
|
|
15222
15436
|
if (d.name === ".git") continue;
|
|
15223
|
-
const child = (0,
|
|
15224
|
-
if (deniedReal.some((x) => child === x || child.startsWith(x +
|
|
15437
|
+
const child = (0, import_path16.join)(abs, d.name);
|
|
15438
|
+
if (deniedReal.some((x) => child === x || child.startsWith(x + import_path16.sep))) continue;
|
|
15225
15439
|
let type = d.isDirectory() ? "dir" : d.isFile() ? "file" : null;
|
|
15226
15440
|
let size2;
|
|
15227
15441
|
if (d.isSymbolicLink()) {
|
|
15228
|
-
const inside3 = await resolveInside(root, (0,
|
|
15229
|
-
const target = inside3 ? await (0,
|
|
15442
|
+
const inside3 = await resolveInside(root, (0, import_path16.relative)(root, child)).catch(() => null);
|
|
15443
|
+
const target = inside3 ? await (0, import_promises15.stat)(child).catch(() => null) : null;
|
|
15230
15444
|
type = target?.isDirectory() ? "dir" : target?.isFile() ? "file" : null;
|
|
15231
15445
|
size2 = target?.isFile() ? target.size : void 0;
|
|
15232
15446
|
} else if (type === "file") {
|
|
15233
|
-
size2 = (await (0,
|
|
15447
|
+
size2 = (await (0, import_promises15.stat)(child).catch(() => null))?.size;
|
|
15234
15448
|
}
|
|
15235
15449
|
if (!type) continue;
|
|
15236
15450
|
entries.push({ name: d.name, path: clean ? `${clean}/${d.name}` : d.name, type, ...size2 !== void 0 ? { size: size2 } : {} });
|
|
@@ -15240,11 +15454,11 @@ async function listFiles(root, rel, denied = []) {
|
|
|
15240
15454
|
}
|
|
15241
15455
|
async function readTextFile(root, rel, range = {}, denied = []) {
|
|
15242
15456
|
const { abs, rel: clean } = await fenced(root, rel, denied);
|
|
15243
|
-
const st = await (0,
|
|
15457
|
+
const st = await (0, import_promises15.stat)(abs).catch(() => null);
|
|
15244
15458
|
if (!st) throw new FileRequestError("NOT_FOUND");
|
|
15245
15459
|
if (!st.isFile()) throw new FileRequestError("NOT_A_FILE");
|
|
15246
15460
|
if (st.size > FILE_CAPS.maxFileBytes) throw new FileRequestError("FILE_TOO_LARGE");
|
|
15247
|
-
const fh = await (0,
|
|
15461
|
+
const fh = await (0, import_promises15.open)(abs, "r");
|
|
15248
15462
|
let buf;
|
|
15249
15463
|
try {
|
|
15250
15464
|
buf = Buffer.alloc(st.size);
|
|
@@ -15283,23 +15497,23 @@ function imageMime(buf) {
|
|
|
15283
15497
|
}
|
|
15284
15498
|
async function insideRelative(path, bases) {
|
|
15285
15499
|
const clean = (path ?? "").trim().replace(/^file:\/\//i, "");
|
|
15286
|
-
if (!(0,
|
|
15500
|
+
if (!(0, import_path16.isAbsolute)(clean)) return clean.replace(/^\.\//, "");
|
|
15287
15501
|
for (const base of bases) {
|
|
15288
|
-
for (const root of [(0,
|
|
15289
|
-
const rel = (0,
|
|
15502
|
+
for (const root of [(0, import_path16.resolve)(base), await (0, import_promises15.realpath)(base).catch(() => (0, import_path16.resolve)(base))]) {
|
|
15503
|
+
const rel = (0, import_path16.relative)(root, (0, import_path16.resolve)(clean));
|
|
15290
15504
|
if (!rel) return "";
|
|
15291
|
-
if (rel !== ".." && !rel.startsWith(`..${
|
|
15505
|
+
if (rel !== ".." && !rel.startsWith(`..${import_path16.sep}`) && !(0, import_path16.isAbsolute)(rel)) return rel.split(import_path16.sep).join("/");
|
|
15292
15506
|
}
|
|
15293
15507
|
}
|
|
15294
15508
|
throw new FileRequestError("PATH_OUTSIDE_WORKSPACE");
|
|
15295
15509
|
}
|
|
15296
15510
|
async function readWholeFile(root, rel, denied = []) {
|
|
15297
15511
|
const { abs, rel: clean } = await fenced(root, rel, denied);
|
|
15298
|
-
const st = await (0,
|
|
15512
|
+
const st = await (0, import_promises15.stat)(abs).catch(() => null);
|
|
15299
15513
|
if (!st) throw new FileRequestError("NOT_FOUND");
|
|
15300
15514
|
if (!st.isFile()) throw new FileRequestError("NOT_A_FILE");
|
|
15301
15515
|
if (st.size > FILE_CAPS.maxImageBytes) throw new FileRequestError("FILE_TOO_LARGE");
|
|
15302
|
-
const fh = await (0,
|
|
15516
|
+
const fh = await (0, import_promises15.open)(abs, "r");
|
|
15303
15517
|
try {
|
|
15304
15518
|
const buf = Buffer.alloc(st.size);
|
|
15305
15519
|
await fh.read(buf, 0, st.size, 0);
|
|
@@ -15310,11 +15524,11 @@ async function readWholeFile(root, rel, denied = []) {
|
|
|
15310
15524
|
}
|
|
15311
15525
|
async function readImageFile(root, rel, denied = []) {
|
|
15312
15526
|
const { abs, rel: clean } = await fenced(root, rel, denied);
|
|
15313
|
-
const st = await (0,
|
|
15527
|
+
const st = await (0, import_promises15.stat)(abs).catch(() => null);
|
|
15314
15528
|
if (!st) throw new FileRequestError("NOT_FOUND");
|
|
15315
15529
|
if (!st.isFile()) throw new FileRequestError("NOT_A_FILE");
|
|
15316
15530
|
if (st.size > FILE_CAPS.maxImageBytes) throw new FileRequestError("FILE_TOO_LARGE");
|
|
15317
|
-
const fh = await (0,
|
|
15531
|
+
const fh = await (0, import_promises15.open)(abs, "r");
|
|
15318
15532
|
let buf;
|
|
15319
15533
|
try {
|
|
15320
15534
|
buf = Buffer.alloc(st.size);
|
|
@@ -15394,8 +15608,8 @@ async function callOrgTool(host, server, tool, args) {
|
|
|
15394
15608
|
}
|
|
15395
15609
|
|
|
15396
15610
|
// src/application/services/workspaceSandbox/workspaceSkills.ts
|
|
15397
|
-
var
|
|
15398
|
-
var
|
|
15611
|
+
var import_promises16 = require("fs/promises");
|
|
15612
|
+
var import_path17 = require("path");
|
|
15399
15613
|
var SKILLS_PLUGIN = "sq";
|
|
15400
15614
|
var BUILTIN_SKILLS = ["code-review", "simplify", "debug", "verify"];
|
|
15401
15615
|
var SKILL_CAPS = { fileBytes: 256 * 1024, skillBytes: 2 * 1024 * 1024, skillFiles: 200, totalBytes: 16 * 1024 * 1024, skills: 200 };
|
|
@@ -15439,29 +15653,29 @@ ${lines2.join("\n")}
|
|
|
15439
15653
|
${neutralize(body)}`;
|
|
15440
15654
|
}
|
|
15441
15655
|
async function regularFile(abs, realRoot) {
|
|
15442
|
-
const st = await (0,
|
|
15656
|
+
const st = await (0, import_promises16.lstat)(abs).catch(() => null);
|
|
15443
15657
|
if (!st?.isFile()) return false;
|
|
15444
|
-
const real = await (0,
|
|
15445
|
-
return !!real && !(0,
|
|
15658
|
+
const real = await (0, import_promises16.realpath)(abs).catch(() => null);
|
|
15659
|
+
return !!real && !(0, import_path17.relative)(realRoot, real).split(import_path17.sep).includes("..");
|
|
15446
15660
|
}
|
|
15447
15661
|
async function copySkillDir(src, dest, realRoot, budget) {
|
|
15448
15662
|
let files = 0, bytes = 0;
|
|
15449
15663
|
const walk = async (rel) => {
|
|
15450
|
-
const entries = await (0,
|
|
15664
|
+
const entries = await (0, import_promises16.readdir)((0, import_path17.join)(src, rel), { withFileTypes: true }).catch(() => []);
|
|
15451
15665
|
for (const e of entries) {
|
|
15452
15666
|
if (files >= SKILL_CAPS.skillFiles || bytes >= SKILL_CAPS.skillBytes) return;
|
|
15453
|
-
const r = rel ? (0,
|
|
15667
|
+
const r = rel ? (0, import_path17.join)(rel, e.name) : e.name;
|
|
15454
15668
|
if (e.isDirectory()) {
|
|
15455
15669
|
if (!SKIP_DIRS.has(e.name)) await walk(r);
|
|
15456
15670
|
continue;
|
|
15457
15671
|
}
|
|
15458
15672
|
if (!e.isFile() || r === "SKILL.md") continue;
|
|
15459
|
-
const abs = (0,
|
|
15673
|
+
const abs = (0, import_path17.join)(src, r);
|
|
15460
15674
|
if (!await regularFile(abs, realRoot)) continue;
|
|
15461
|
-
const buf = await (0,
|
|
15675
|
+
const buf = await (0, import_promises16.readFile)(abs).catch(() => null);
|
|
15462
15676
|
if (!buf || buf.length > SKILL_CAPS.fileBytes || bytes + buf.length > SKILL_CAPS.skillBytes || budget.bytes < buf.length) continue;
|
|
15463
|
-
await (0,
|
|
15464
|
-
await (0,
|
|
15677
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(dest, rel), { recursive: true });
|
|
15678
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(dest, r), buf, { mode: 384 });
|
|
15465
15679
|
files++;
|
|
15466
15680
|
bytes += buf.length;
|
|
15467
15681
|
budget.bytes -= buf.length;
|
|
@@ -15470,9 +15684,9 @@ async function copySkillDir(src, dest, realRoot, budget) {
|
|
|
15470
15684
|
await walk("");
|
|
15471
15685
|
}
|
|
15472
15686
|
async function buildSkillsPlugin(opts) {
|
|
15473
|
-
await (0,
|
|
15474
|
-
await (0,
|
|
15475
|
-
await (0,
|
|
15687
|
+
await (0, import_promises16.rm)(opts.dir, { recursive: true, force: true });
|
|
15688
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(opts.dir, ".claude-plugin"), { recursive: true, mode: 448 });
|
|
15689
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(opts.dir, ".claude-plugin", "plugin.json"), JSON.stringify({ name: SKILLS_PLUGIN, description: "Skills and commands of this ScaleQuality workspace" }));
|
|
15476
15690
|
const out2 = [];
|
|
15477
15691
|
const taken = new Set(BUILTIN_SKILLS);
|
|
15478
15692
|
const budget = { bytes: SKILL_CAPS.totalBytes };
|
|
@@ -15483,31 +15697,31 @@ async function buildSkillsPlugin(opts) {
|
|
|
15483
15697
|
const meta = { description: s.description ?? "", ...s.argumentHint ? { "argument-hint": s.argumentHint } : {} };
|
|
15484
15698
|
const text3 = rebuild(meta, name, s.body);
|
|
15485
15699
|
if (Buffer.byteLength(text3) > SKILL_CAPS.fileBytes) continue;
|
|
15486
|
-
await (0,
|
|
15487
|
-
await (0,
|
|
15700
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(opts.dir, "skills", name), { recursive: true });
|
|
15701
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(opts.dir, "skills", name, "SKILL.md"), text3, { mode: 384 });
|
|
15488
15702
|
budget.bytes -= Buffer.byteLength(text3);
|
|
15489
15703
|
taken.add(name);
|
|
15490
15704
|
out2.push({ name, description: meta.description.slice(0, 300), kind: "skill", source: "organization", ...s.argumentHint ? { argumentHint: s.argumentHint.slice(0, 120) } : {} });
|
|
15491
15705
|
}
|
|
15492
15706
|
for (const repo2 of opts.repos) {
|
|
15493
|
-
const realRoot = await (0,
|
|
15707
|
+
const realRoot = await (0, import_promises16.realpath)(repo2.root).catch(() => null);
|
|
15494
15708
|
if (!realRoot) continue;
|
|
15495
|
-
const skillsDir = (0,
|
|
15496
|
-
for (const e of (await (0,
|
|
15709
|
+
const skillsDir = (0, import_path17.join)(repo2.root, ".claude", "skills");
|
|
15710
|
+
for (const e of (await (0, import_promises16.readdir)(skillsDir, { withFileTypes: true }).catch(() => [])).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
15497
15711
|
if (!room() || !e.isDirectory()) continue;
|
|
15498
|
-
const file = (0,
|
|
15712
|
+
const file = (0, import_path17.join)(skillsDir, e.name, "SKILL.md");
|
|
15499
15713
|
if (!await regularFile(file, realRoot)) continue;
|
|
15500
|
-
const buf = await (0,
|
|
15714
|
+
const buf = await (0, import_promises16.readFile)(file).catch(() => null);
|
|
15501
15715
|
if (!buf || buf.length > SKILL_CAPS.fileBytes || buf.includes(0)) continue;
|
|
15502
15716
|
const { meta, body } = parseSkillFile(buf.toString("utf8"));
|
|
15503
15717
|
const name = (meta.name || e.name).toLowerCase();
|
|
15504
15718
|
if (!NAME.test(name) || taken.has(name)) continue;
|
|
15505
|
-
const dest = (0,
|
|
15506
|
-
await (0,
|
|
15719
|
+
const dest = (0, import_path17.join)(opts.dir, "skills", name);
|
|
15720
|
+
await (0, import_promises16.mkdir)(dest, { recursive: true });
|
|
15507
15721
|
const text3 = rebuild(meta, name, body);
|
|
15508
|
-
await (0,
|
|
15722
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(dest, "SKILL.md"), text3, { mode: 384 });
|
|
15509
15723
|
budget.bytes -= Buffer.byteLength(text3);
|
|
15510
|
-
await copySkillDir((0,
|
|
15724
|
+
await copySkillDir((0, import_path17.join)(skillsDir, e.name), dest, realRoot, budget);
|
|
15511
15725
|
taken.add(name);
|
|
15512
15726
|
out2.push({
|
|
15513
15727
|
name,
|
|
@@ -15518,12 +15732,12 @@ async function buildSkillsPlugin(opts) {
|
|
|
15518
15732
|
...meta["argument-hint"] ? { argumentHint: meta["argument-hint"].slice(0, 120) } : {}
|
|
15519
15733
|
});
|
|
15520
15734
|
}
|
|
15521
|
-
const commandsDir = (0,
|
|
15522
|
-
for (const e of (await (0,
|
|
15735
|
+
const commandsDir = (0, import_path17.join)(repo2.root, ".claude", "commands");
|
|
15736
|
+
for (const e of (await (0, import_promises16.readdir)(commandsDir, { withFileTypes: true }).catch(() => [])).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
15523
15737
|
if (!room() || !e.isFile() || !e.name.endsWith(".md")) continue;
|
|
15524
|
-
const file = (0,
|
|
15738
|
+
const file = (0, import_path17.join)(commandsDir, e.name);
|
|
15525
15739
|
if (!await regularFile(file, realRoot)) continue;
|
|
15526
|
-
const buf = await (0,
|
|
15740
|
+
const buf = await (0, import_promises16.readFile)(file).catch(() => null);
|
|
15527
15741
|
if (!buf || buf.length > SKILL_CAPS.fileBytes || buf.includes(0)) continue;
|
|
15528
15742
|
const name = e.name.slice(0, -3).toLowerCase();
|
|
15529
15743
|
if (!NAME.test(name) || taken.has(name)) continue;
|
|
@@ -15534,8 +15748,8 @@ ${lines2.join("\n")}
|
|
|
15534
15748
|
---
|
|
15535
15749
|
|
|
15536
15750
|
` : ""}${neutralize(body)}`;
|
|
15537
|
-
await (0,
|
|
15538
|
-
await (0,
|
|
15751
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(opts.dir, "commands"), { recursive: true });
|
|
15752
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(opts.dir, "commands", `${name}.md`), text3, { mode: 384 });
|
|
15539
15753
|
budget.bytes -= Buffer.byteLength(text3);
|
|
15540
15754
|
taken.add(name);
|
|
15541
15755
|
out2.push({
|
|
@@ -15574,19 +15788,19 @@ ${lines2.join("\n")}
|
|
|
15574
15788
|
${neutralize(body)}`;
|
|
15575
15789
|
}
|
|
15576
15790
|
async function buildOrganizationPlugins(opts) {
|
|
15577
|
-
await (0,
|
|
15791
|
+
await (0, import_promises16.rm)(opts.dir, { recursive: true, force: true });
|
|
15578
15792
|
const entries = [], dirs = [];
|
|
15579
15793
|
for (const p of opts.plugins) {
|
|
15580
15794
|
const plugin = p.name.toLowerCase();
|
|
15581
15795
|
if (!/^[a-z0-9][a-z0-9-]{0,39}$/.test(plugin) || plugin === SKILLS_PLUGIN || dirs.some((d) => d.endsWith(`/${plugin}`))) continue;
|
|
15582
|
-
const root = (0,
|
|
15583
|
-
await (0,
|
|
15584
|
-
await (0,
|
|
15796
|
+
const root = (0, import_path17.join)(opts.dir, plugin);
|
|
15797
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(root, ".claude-plugin"), { recursive: true, mode: 448 });
|
|
15798
|
+
await (0, import_promises16.writeFile)((0, import_path17.join)(root, ".claude-plugin", "plugin.json"), JSON.stringify({ name: plugin }));
|
|
15585
15799
|
const write = async (rel, text3) => {
|
|
15586
|
-
const abs = (0,
|
|
15587
|
-
if ((0,
|
|
15588
|
-
await (0,
|
|
15589
|
-
await (0,
|
|
15800
|
+
const abs = (0, import_path17.join)(root, rel);
|
|
15801
|
+
if ((0, import_path17.relative)(root, abs).split(import_path17.sep).includes("..")) return;
|
|
15802
|
+
await (0, import_promises16.mkdir)((0, import_path17.join)(abs, ".."), { recursive: true });
|
|
15803
|
+
await (0, import_promises16.writeFile)(abs, text3, { mode: 384 });
|
|
15590
15804
|
};
|
|
15591
15805
|
for (const f of p.files) {
|
|
15592
15806
|
if (typeof f?.path !== "string" || typeof f.content !== "string" || f.path.split("/").some((x) => x === ".." || x === "")) continue;
|
|
@@ -15713,7 +15927,7 @@ function turnOffering(raw, loaded) {
|
|
|
15713
15927
|
mcpCatalog: loaded.catalog ? { ...loaded.catalog, servers: loaded.catalog.servers.filter((sv) => !connectors.has(sv.server.toLowerCase())) } : null,
|
|
15714
15928
|
mcpServers: Object.fromEntries(Object.entries(loaded.servers).filter(([key]) => !connectors.has(key.slice(ORG_MCP_PREFIX.length).toLowerCase()))),
|
|
15715
15929
|
skillEntries: loaded.skillEntries.filter((e) => !(e.source === "plugin" && e.plugin && plugins.has(e.plugin))),
|
|
15716
|
-
pluginDirs: loaded.pluginDirs.filter((d) => !plugins.has((0,
|
|
15930
|
+
pluginDirs: loaded.pluginDirs.filter((d) => !plugins.has((0, import_path18.basename)(d).toLowerCase()))
|
|
15717
15931
|
};
|
|
15718
15932
|
}
|
|
15719
15933
|
function sameModel(a, b) {
|
|
@@ -15836,6 +16050,11 @@ var WorkspaceEngine = class {
|
|
|
15836
16050
|
opening = /* @__PURE__ */ new Map();
|
|
15837
16051
|
/** Saved changes of repositories not open in this run: never dropped from the checkpoint. */
|
|
15838
16052
|
pendingCheckpoints = /* @__PURE__ */ new Map();
|
|
16053
|
+
/**
|
|
16054
|
+
* The cloud workspace's own files go in the checkpoint (rootFiles.ts). Off on a computer (its folder keeps them),
|
|
16055
|
+
* and while the saved ones could not be put back on this machine: they are then kept as saved.
|
|
16056
|
+
*/
|
|
16057
|
+
workspaceFiles = false;
|
|
15839
16058
|
sdk = null;
|
|
15840
16059
|
mcpServer = null;
|
|
15841
16060
|
sdkSessionId = null;
|
|
@@ -16076,7 +16295,7 @@ var WorkspaceEngine = class {
|
|
|
16076
16295
|
}
|
|
16077
16296
|
if (this.deps.clone && !this.local) {
|
|
16078
16297
|
for (const name of [...this.pendingCheckpoints.keys()]) {
|
|
16079
|
-
if (name === LOCAL_FOLDER_KEY || !this.inScope(name) || this.repoNamed(name)) continue;
|
|
16298
|
+
if (name === LOCAL_FOLDER_KEY || name === WORKSPACE_FILES_KEY || !this.inScope(name) || this.repoNamed(name)) continue;
|
|
16080
16299
|
const r = await this.openRepository(name);
|
|
16081
16300
|
if (r.isError) this.error("REPOSITORY_CHECKPOINT_NOT_RESTORED", { repoFullName: name });
|
|
16082
16301
|
}
|
|
@@ -16087,6 +16306,7 @@ var WorkspaceEngine = class {
|
|
|
16087
16306
|
if (opened.isError) this.deps.log.warn("scope repository not opened at start", { repo: r.repoFullName });
|
|
16088
16307
|
}
|
|
16089
16308
|
}
|
|
16309
|
+
await this.restoreWorkspaceFiles(boot);
|
|
16090
16310
|
}
|
|
16091
16311
|
this.phase("ENGINE");
|
|
16092
16312
|
try {
|
|
@@ -16105,7 +16325,7 @@ var WorkspaceEngine = class {
|
|
|
16105
16325
|
}
|
|
16106
16326
|
await this.backgroundOutputDir();
|
|
16107
16327
|
if (boot.plugins?.length) {
|
|
16108
|
-
this.orgPlugins = await buildOrganizationPlugins({ dir: (0,
|
|
16328
|
+
this.orgPlugins = await buildOrganizationPlugins({ dir: (0, import_path18.join)(this.deps.configDir, "sq-org-plugins"), plugins: boot.plugins }).catch((e) => {
|
|
16109
16329
|
this.deps.log.warn("organization plugins unavailable", { error: this.redactor.text(e.message) });
|
|
16110
16330
|
return { entries: [], dirs: [] };
|
|
16111
16331
|
});
|
|
@@ -16132,8 +16352,8 @@ var WorkspaceEngine = class {
|
|
|
16132
16352
|
}
|
|
16133
16353
|
/** Where a background command writes its output: inside the config dir, which Read may read. */
|
|
16134
16354
|
async backgroundOutputDir() {
|
|
16135
|
-
await (0,
|
|
16136
|
-
await (0,
|
|
16355
|
+
await (0, import_promises17.mkdir)((0, import_path18.join)(this.deps.configDir, "tmp"), { recursive: true, mode: 448 }).catch(() => void 0);
|
|
16356
|
+
await (0, import_promises17.mkdir)((0, import_path18.join)(this.deps.configDir, "plans"), { recursive: true, mode: 448 }).catch(() => void 0);
|
|
16137
16357
|
}
|
|
16138
16358
|
/** Runs until shutdown. */
|
|
16139
16359
|
async run() {
|
|
@@ -16162,7 +16382,7 @@ var WorkspaceEngine = class {
|
|
|
16162
16382
|
const repo2 = {
|
|
16163
16383
|
...r,
|
|
16164
16384
|
tracker: r.tracker ?? gitTracker(r.root, r.prepared.baseRevision, r.prefix),
|
|
16165
|
-
measurer: this.deps.createMeasurer && !this.local ? this.deps.createMeasurer(r.repoFullName ?? (0,
|
|
16385
|
+
measurer: this.deps.createMeasurer && !this.local ? this.deps.createMeasurer(r.repoFullName ?? (0, import_path18.basename)(r.root), r.root, this.baseStore(r.repoFullName), r.repoFullName) : null,
|
|
16166
16386
|
lastDiff: null
|
|
16167
16387
|
};
|
|
16168
16388
|
this.repos.set(r.root, repo2);
|
|
@@ -16191,14 +16411,14 @@ var WorkspaceEngine = class {
|
|
|
16191
16411
|
const short = folderName(lastSegment(repoFullName));
|
|
16192
16412
|
const full = folderName(repoFullName.split("/").filter(Boolean).join("__"));
|
|
16193
16413
|
const clash = this.scope.repos.some((r) => r.repoFullName !== repoFullName && folderName(lastSegment(r.repoFullName)) === short);
|
|
16194
|
-
const privateDirs = (this.deps.privateDirs ?? []).map((d) => (0,
|
|
16414
|
+
const privateDirs = (this.deps.privateDirs ?? []).map((d) => (0, import_path18.resolve)(d));
|
|
16195
16415
|
const taken = (name2) => {
|
|
16196
|
-
const dir = (0,
|
|
16197
|
-
return this.repos.has(dir) || privateDirs.includes(dir) || (0,
|
|
16416
|
+
const dir = (0, import_path18.resolve)(this.deps.root, name2);
|
|
16417
|
+
return this.repos.has(dir) || privateDirs.includes(dir) || (0, import_fs12.existsSync)(dir);
|
|
16198
16418
|
};
|
|
16199
16419
|
let name = clash || taken(short) ? full : short;
|
|
16200
16420
|
for (let n = 2; taken(name); n++) name = `${full}-${n}`;
|
|
16201
|
-
return (0,
|
|
16421
|
+
return (0, import_path18.join)(this.deps.root, name);
|
|
16202
16422
|
}
|
|
16203
16423
|
/** Clones one repository into its folder and registers it. The token is dropped either way. */
|
|
16204
16424
|
async cloneInto(access, onStep) {
|
|
@@ -16208,7 +16428,7 @@ var WorkspaceEngine = class {
|
|
|
16208
16428
|
try {
|
|
16209
16429
|
prepared = await this.deps.clone(access, dir, saved, onStep);
|
|
16210
16430
|
} catch (e) {
|
|
16211
|
-
await (0,
|
|
16431
|
+
await (0, import_promises17.rm)(dir, { recursive: true, force: true }).catch(() => void 0);
|
|
16212
16432
|
throw e;
|
|
16213
16433
|
} finally {
|
|
16214
16434
|
access.token = "";
|
|
@@ -16245,7 +16465,7 @@ var WorkspaceEngine = class {
|
|
|
16245
16465
|
}
|
|
16246
16466
|
if (open2.length === 1) return { repo: open2[0] };
|
|
16247
16467
|
if (!open2.length) return { error: "No repository is open in this workspace. Call list_repositories, then open_repository." };
|
|
16248
|
-
return { error: `Several repositories are open (${open2.map((o) => o.repoFullName ?? (0,
|
|
16468
|
+
return { error: `Several repositories are open (${open2.map((o) => o.repoFullName ?? (0, import_path18.basename)(o.root)).join(", ")}). Pass repoFullName.` };
|
|
16249
16469
|
}
|
|
16250
16470
|
notInScope(repo2, target) {
|
|
16251
16471
|
const loose = repo2.localId === LOOSE_REPO_ID;
|
|
@@ -16518,7 +16738,7 @@ var WorkspaceEngine = class {
|
|
|
16518
16738
|
PUB_CACHE: ".pub-cache",
|
|
16519
16739
|
BUNDLE_PATH: ".bundle"
|
|
16520
16740
|
};
|
|
16521
|
-
for (const [k, rel] of Object.entries(caches)) if (env[k] !== void 0) env[k] = (0,
|
|
16741
|
+
for (const [k, rel] of Object.entries(caches)) if (env[k] !== void 0) env[k] = (0, import_path18.join)(user.home, rel);
|
|
16522
16742
|
return {
|
|
16523
16743
|
file: user.shell,
|
|
16524
16744
|
args: ["-l"],
|
|
@@ -16533,9 +16753,9 @@ var WorkspaceEngine = class {
|
|
|
16533
16753
|
* (default ACL), never the engine's own folders (its state and transcripts stay root's, 0700).
|
|
16534
16754
|
*/
|
|
16535
16755
|
async shareWithTerminal(uid) {
|
|
16536
|
-
const root = (0,
|
|
16537
|
-
const own = new Set((this.deps.privateDirs ?? []).map((d) => (0,
|
|
16538
|
-
for (const dir of own) await (0,
|
|
16756
|
+
const root = (0, import_path18.resolve)(this.deps.root);
|
|
16757
|
+
const own = new Set((this.deps.privateDirs ?? []).map((d) => (0, import_path18.resolve)(d)));
|
|
16758
|
+
for (const dir of own) await (0, import_promises17.chmod)(dir, 448).catch(() => void 0);
|
|
16539
16759
|
const acl = (args) => new Promise((done) => {
|
|
16540
16760
|
const child = (0, import_child_process5.spawn)("setfacl", args, { stdio: "ignore" });
|
|
16541
16761
|
child.on("error", () => done(false));
|
|
@@ -16545,9 +16765,9 @@ var WorkspaceEngine = class {
|
|
|
16545
16765
|
if (!await acl(["-m", `u:${uid}:rwx`, "-m", `d:u:${uid}:rwX`, root])) this.deps.log.warn("terminal: the workspace folder could not be shared with its user");
|
|
16546
16766
|
this.terminalShared.add(root);
|
|
16547
16767
|
}
|
|
16548
|
-
const sweep = Promise.all((await (0,
|
|
16549
|
-
const path = (0,
|
|
16550
|
-
if (this.terminalShared.has(path) || own.has(path) || [...own].some((d) => d.startsWith(path +
|
|
16768
|
+
const sweep = Promise.all((await (0, import_promises17.readdir)(root).catch(() => [])).map(async (name) => {
|
|
16769
|
+
const path = (0, import_path18.join)(root, name);
|
|
16770
|
+
if (this.terminalShared.has(path) || own.has(path) || [...own].some((d) => d.startsWith(path + import_path18.sep))) return;
|
|
16551
16771
|
if (await acl(["-R", "-m", `u:${uid}:rwX`, "-m", `d:u:${uid}:rwX`, path])) this.terminalShared.add(path);
|
|
16552
16772
|
}));
|
|
16553
16773
|
await Promise.race([sweep, new Promise((r) => setTimeout(r, TERMINAL_SHARE_WAIT_MS).unref?.())]);
|
|
@@ -16864,7 +17084,7 @@ ${String(item.content)}` : String(item.content);
|
|
|
16864
17084
|
askQuestions: !!this.boot?.askQuestions
|
|
16865
17085
|
});
|
|
16866
17086
|
const conventions = await readConventions([...this.repos.values()].filter((r) => !r.dormant).flatMap((r) => {
|
|
16867
|
-
const label = r.repoFullName ?? r.localId ?? (0,
|
|
17087
|
+
const label = r.repoFullName ?? r.localId ?? (0, import_path18.basename)(r.root);
|
|
16868
17088
|
return r.fence && r.fence !== r.root ? [{ label, root: r.root }, { label: `${label} (${r.prefix})`, root: r.fence }] : [{ label, root: r.root }];
|
|
16869
17089
|
})).catch(() => []);
|
|
16870
17090
|
return base + conventionsSection(conventions);
|
|
@@ -16958,7 +17178,7 @@ ${String(item.content)}` : String(item.content);
|
|
|
16958
17178
|
return {
|
|
16959
17179
|
registry: this.registry,
|
|
16960
17180
|
currentBranch: async () => (await git(["rev-parse", "--abbrev-ref", "HEAD"], { cwd: this.deps.root, timeoutMs: 3e3 })).trim() || null,
|
|
16961
|
-
installedLocally: (name) => [this.deps.root, ...[...this.repos.values()].map((r) => r.root)].some((dir) => (0,
|
|
17181
|
+
installedLocally: (name) => [this.deps.root, ...[...this.repos.values()].map((r) => r.root)].some((dir) => (0, import_fs12.existsSync)((0, import_path18.join)(dir, "node_modules", name, "package.json")) || (0, import_fs12.existsSync)((0, import_path18.join)(dir, "node_modules", ".bin", name)))
|
|
16962
17182
|
};
|
|
16963
17183
|
}
|
|
16964
17184
|
/**
|
|
@@ -17065,7 +17285,7 @@ ${String(item.content)}` : String(item.content);
|
|
|
17065
17285
|
for (const repo2 of this.repos.values()) {
|
|
17066
17286
|
const tree = cp.trees.get(repo2.root);
|
|
17067
17287
|
if (!tree) {
|
|
17068
|
-
if (!repo2.dormant) untouched.push(repo2.repoFullName ?? repo2.localId ?? (0,
|
|
17288
|
+
if (!repo2.dormant) untouched.push(repo2.repoFullName ?? repo2.localId ?? (0, import_path18.basename)(repo2.root));
|
|
17069
17289
|
continue;
|
|
17070
17290
|
}
|
|
17071
17291
|
try {
|
|
@@ -17101,7 +17321,7 @@ ${String(item.content)}` : String(item.content);
|
|
|
17101
17321
|
return;
|
|
17102
17322
|
}
|
|
17103
17323
|
const repo2 = picked.repo;
|
|
17104
|
-
const label = repo2.repoFullName ?? repo2.localId ?? (0,
|
|
17324
|
+
const label = repo2.repoFullName ?? repo2.localId ?? (0, import_path18.basename)(repo2.root);
|
|
17105
17325
|
const cwd = repo2.fence ?? repo2.root;
|
|
17106
17326
|
const detected = (this.deps.detectTests ? await this.deps.detectTests(cwd).catch(() => null) : null) ?? await detectTestCommandFromManifests(cwd).catch(() => null);
|
|
17107
17327
|
if (!detected) {
|
|
@@ -17198,10 +17418,10 @@ ${String(item.content)}` : String(item.content);
|
|
|
17198
17418
|
}
|
|
17199
17419
|
/** A file the person attached, saved whole in the engine's own folder (the file tools read there, nothing writes there). */
|
|
17200
17420
|
async saveAttachment(name, bytes) {
|
|
17201
|
-
const dir = (0,
|
|
17202
|
-
await (0,
|
|
17203
|
-
const path = (0,
|
|
17204
|
-
await (0,
|
|
17421
|
+
const dir = (0, import_path18.join)(this.deps.configDir, "attachments", (0, import_crypto9.randomUUID)());
|
|
17422
|
+
await (0, import_promises17.mkdir)(dir, { recursive: true });
|
|
17423
|
+
const path = (0, import_path18.join)(dir, (0, import_path18.basename)(name ?? "").replace(/[\u0000-\u001f\\/:]/g, "_").replace(/^\.+/, "") || "attachment");
|
|
17424
|
+
await (0, import_promises17.writeFile)(path, bytes);
|
|
17205
17425
|
return path;
|
|
17206
17426
|
}
|
|
17207
17427
|
/**
|
|
@@ -17339,7 +17559,7 @@ ${json}
|
|
|
17339
17559
|
}
|
|
17340
17560
|
/** The plugin with the repositories' and the organization's skills, rebuilt; the list goes to the screen when it changed. */
|
|
17341
17561
|
async refreshSkills() {
|
|
17342
|
-
const repos = [...this.repos.values()].filter((r) => !r.dormant).map((r) => ({ label: r.repoFullName ?? r.localId ?? (0,
|
|
17562
|
+
const repos = [...this.repos.values()].filter((r) => !r.dormant).map((r) => ({ label: r.repoFullName ?? r.localId ?? (0, import_path18.basename)(r.root), root: r.fence ?? r.root }));
|
|
17343
17563
|
try {
|
|
17344
17564
|
this.skillEntries = [...await buildSkillsPlugin({ dir: this.skillsDir(), repos, organization: this.boot?.skills ?? [] }), ...this.orgPlugins.entries];
|
|
17345
17565
|
} catch (e) {
|
|
@@ -17352,7 +17572,7 @@ ${json}
|
|
|
17352
17572
|
this.emit({ type: "skills", data: { skills: this.skillEntries } });
|
|
17353
17573
|
}
|
|
17354
17574
|
skillsDir() {
|
|
17355
|
-
return (0,
|
|
17575
|
+
return (0, import_path18.join)(this.deps.configDir, "sq-plugin");
|
|
17356
17576
|
}
|
|
17357
17577
|
/**
|
|
17358
17578
|
* The organization's MCP servers (their tools, from the API): one in-process server each, forwarding calls to
|
|
@@ -17403,7 +17623,7 @@ ${json}
|
|
|
17403
17623
|
}
|
|
17404
17624
|
}
|
|
17405
17625
|
async runEnvSetup(repo2, command, secrets) {
|
|
17406
|
-
const label = repo2.repoFullName ?? (0,
|
|
17626
|
+
const label = repo2.repoFullName ?? (0, import_path18.basename)(repo2.root);
|
|
17407
17627
|
const step = this.ownStep("setup", "command", `Preparing the environment of ${label}`, "STEP_ENV_SETUP", { repoFullName: label }, this.redactor.text(command));
|
|
17408
17628
|
const started = Date.now();
|
|
17409
17629
|
const { exitCode, output } = await this.runStreaming(command, repo2.fence ?? repo2.root, step.id, this.envAbort.signal, secrets);
|
|
@@ -17910,7 +18130,7 @@ ${text3}`;
|
|
|
17910
18130
|
deniedRoots: this.deps.privateDirs,
|
|
17911
18131
|
local: this.local,
|
|
17912
18132
|
plan: t.planMode,
|
|
17913
|
-
planDir: (0,
|
|
18133
|
+
planDir: (0, import_path18.join)(this.deps.configDir, "plans"),
|
|
17914
18134
|
orgMcpTools: orgMcpToolNames(org ? t.off.mcpCatalog : null)
|
|
17915
18135
|
},
|
|
17916
18136
|
plan: t.planMode,
|
|
@@ -18101,6 +18321,34 @@ ${text3}`;
|
|
|
18101
18321
|
});
|
|
18102
18322
|
return this.diffChain;
|
|
18103
18323
|
}
|
|
18324
|
+
/**
|
|
18325
|
+
* The workspace's own files back on this machine before the conversation goes on (rootFiles.ts), then the designs
|
|
18326
|
+
* the API kept that are still missing (a session saved before its files went in the checkpoint): its newest version.
|
|
18327
|
+
* A design inside a repository comes back with the repository's own change.
|
|
18328
|
+
*/
|
|
18329
|
+
async restoreWorkspaceFiles(boot) {
|
|
18330
|
+
const saved = this.pendingCheckpoints.get(WORKSPACE_FILES_KEY) ?? null;
|
|
18331
|
+
try {
|
|
18332
|
+
if (saved) this.deps.log.info("workspace files restored", await restoreRootFiles(this.deps.root, this.deps.scratch, saved));
|
|
18333
|
+
this.pendingCheckpoints.delete(WORKSPACE_FILES_KEY);
|
|
18334
|
+
this.workspaceFiles = true;
|
|
18335
|
+
} catch (e) {
|
|
18336
|
+
this.deps.log.warn("workspace files not restored", { error: this.redactor.text(e.message) });
|
|
18337
|
+
}
|
|
18338
|
+
const keptDesign = this.deps.transport.keptDesign?.bind(this.deps.transport);
|
|
18339
|
+
if (!keptDesign) return;
|
|
18340
|
+
for (const d of boot.keptDesigns ?? []) {
|
|
18341
|
+
if (!/^design\/[^/]+\/design\.json$/.test(d.path) || this.repos.has((0, import_path18.join)(this.deps.root, "design"))) continue;
|
|
18342
|
+
if ((0, import_fs12.existsSync)((0, import_path18.join)(this.deps.root, d.path))) continue;
|
|
18343
|
+
try {
|
|
18344
|
+
const kept = await keptDesign(d.path);
|
|
18345
|
+
const written = kept ? await restoreKeptDesign(this.deps.root, d.path, kept.files) : 0;
|
|
18346
|
+
if (written) this.deps.log.info("design restored from its kept version", { path: d.path, n: kept?.n, files: written });
|
|
18347
|
+
} catch (e) {
|
|
18348
|
+
this.deps.log.warn("kept design not restored", { path: d.path, error: this.redactor.text(e.message) });
|
|
18349
|
+
}
|
|
18350
|
+
}
|
|
18351
|
+
}
|
|
18104
18352
|
/**
|
|
18105
18353
|
* The checkpoint: every open repository's change against its base, plus the
|
|
18106
18354
|
* saved changes of repositories not open in this run, as one map. In the
|
|
@@ -18118,6 +18366,14 @@ ${text3}`;
|
|
|
18118
18366
|
}
|
|
18119
18367
|
async saveChange() {
|
|
18120
18368
|
const map = new Map(this.pendingCheckpoints);
|
|
18369
|
+
if (this.workspaceFiles) {
|
|
18370
|
+
const excluded = [...[...this.repos.values()].map((r) => r.root), ...this.deps.privateDirs ?? [], this.deps.scratch, this.deps.configDir];
|
|
18371
|
+
const { files, leftOut } = await listRootFiles(this.deps.root, excluded);
|
|
18372
|
+
if (leftOut) this.deps.log.warn("workspace files left out of the checkpoint", { kept: files.length, leftOut });
|
|
18373
|
+
const patch2 = await rootFilesCheckpoint(this.deps.root, this.deps.scratch, files);
|
|
18374
|
+
if (patch2) map.set(WORKSPACE_FILES_KEY, patch2);
|
|
18375
|
+
else map.delete(WORKSPACE_FILES_KEY);
|
|
18376
|
+
}
|
|
18121
18377
|
for (const repo2 of this.repos.values()) {
|
|
18122
18378
|
const key2 = repo2.repoFullName ?? repo2.localId ?? LOCAL_FOLDER_KEY;
|
|
18123
18379
|
if (repo2.dormant) {
|
|
@@ -18223,7 +18479,7 @@ ${patch}`;
|
|
|
18223
18479
|
this.pendingCheckpoints.delete(repo2.localId);
|
|
18224
18480
|
repo2.dormant = !repo2.unsaved;
|
|
18225
18481
|
}
|
|
18226
|
-
const stateDir = this.deps.stateDir ?? (0,
|
|
18482
|
+
const stateDir = this.deps.stateDir ?? (0, import_path18.join)(this.deps.scratch, `folder-${(0, import_crypto9.createHash)("sha256").update(local.root).digest("hex").slice(0, 16)}`);
|
|
18227
18483
|
const tracker = new LooseFileTracker({ root: local.root, stateDir, excluded: () => local.repos.map((r) => r.root) });
|
|
18228
18484
|
const tracked = local.gitAvailable && await tracker.init().then(() => true, (e) => {
|
|
18229
18485
|
this.deps.log.warn("loose files not tracked", { error: e.message });
|
|
@@ -18275,7 +18531,7 @@ ${patch}`;
|
|
|
18275
18531
|
let owner = null;
|
|
18276
18532
|
for (const r of this.repos.values()) {
|
|
18277
18533
|
if (r.localId === LOOSE_REPO_ID) continue;
|
|
18278
|
-
if ((abs === r.root || abs.startsWith(r.root +
|
|
18534
|
+
if ((abs === r.root || abs.startsWith(r.root + import_path18.sep)) && (!owner || r.root.length > owner.root.length)) owner = r;
|
|
18279
18535
|
}
|
|
18280
18536
|
if (owner) {
|
|
18281
18537
|
if (owner.dormant) await this.wake(owner, true);
|
|
@@ -18314,7 +18570,7 @@ ${patch}`;
|
|
|
18314
18570
|
if (!f || f.kind === "repo") return void 0;
|
|
18315
18571
|
if (f.kind === "subfolder") return { kind: "subfolder", repoRoot: f.repoRoot ?? "", prefix: f.prefix };
|
|
18316
18572
|
const repos = [...this.repos.values()].filter((r) => r.localId && r.localId !== LOOSE_REPO_ID).map((r) => ({
|
|
18317
|
-
path: (0,
|
|
18573
|
+
path: (0, import_path18.relative)(f.root, r.root).split(import_path18.sep).join("/"),
|
|
18318
18574
|
id: r.repoFullName ?? r.localId,
|
|
18319
18575
|
repoFullName: r.repoFullName,
|
|
18320
18576
|
projectId: r.repoFullName ? this.scope.repos.find((x) => x.repoFullName === r.repoFullName)?.projectId ?? null : null,
|
|
@@ -18390,14 +18646,14 @@ ${patch}`;
|
|
|
18390
18646
|
const files = [];
|
|
18391
18647
|
let bytes = 0;
|
|
18392
18648
|
const NAME2 = /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/;
|
|
18393
|
-
const top = await (0,
|
|
18394
|
-
const nested = await Promise.all(top.filter((e) => e.isDirectory() && NAME2.test(e.name)).slice(0, 10).map(async (d) => (await (0,
|
|
18649
|
+
const top = await (0, import_promises17.readdir)(folder, { withFileTypes: true }).catch(() => []);
|
|
18650
|
+
const nested = await Promise.all(top.filter((e) => e.isDirectory() && NAME2.test(e.name)).slice(0, 10).map(async (d) => (await (0, import_promises17.readdir)((0, import_path18.join)(folder, d.name), { withFileTypes: true }).catch(() => [])).filter((e) => e.isFile() && NAME2.test(e.name)).map((e) => `${d.name}/${e.name}`)));
|
|
18395
18651
|
const rank = (n) => n === "design.json" ? 0 : n.includes("/") ? 2 : 1;
|
|
18396
18652
|
const names = [...top.filter((e) => e.isFile() && NAME2.test(e.name)).map((e) => e.name), ...nested.flat()].sort((a, b) => rank(a) - rank(b) || a.localeCompare(b)).slice(0, 60);
|
|
18397
18653
|
for (const name of names) {
|
|
18398
|
-
const st = await (0,
|
|
18654
|
+
const st = await (0, import_promises17.stat)((0, import_path18.join)(folder, name)).catch(() => null);
|
|
18399
18655
|
if (!st || st.size > 4 * 1024 * 1024 || bytes + st.size > 6 * 1024 * 1024) continue;
|
|
18400
|
-
const data = await (0,
|
|
18656
|
+
const data = await (0, import_promises17.readFile)((0, import_path18.join)(folder, name)).catch(() => null);
|
|
18401
18657
|
if (!data) continue;
|
|
18402
18658
|
bytes += data.length;
|
|
18403
18659
|
files.push({ name, data: data.toString("base64") });
|
|
@@ -18424,7 +18680,7 @@ ${patch}`;
|
|
|
18424
18680
|
const chrome = findChrome();
|
|
18425
18681
|
if (!chrome) return text("No Chrome or Chromium is installed here, so the screens could not be opened in a browser. Review them by reading the files, and tell the user in one sentence that they were not checked in a browser.", true);
|
|
18426
18682
|
const checks = await checkDesign(chrome, design.folder, design.manifest);
|
|
18427
|
-
const rel = designPath(await (0,
|
|
18683
|
+
const rel = designPath(await (0, import_promises17.realpath)(this.deps.root).catch(() => this.deps.root), abs);
|
|
18428
18684
|
this.designsChecked.set(rel, design.folder);
|
|
18429
18685
|
this.emit({ type: "design", data: { path: rel, title: design.manifest.title, ...designSummary(checks), checkedAt: (/* @__PURE__ */ new Date()).toISOString() } });
|
|
18430
18686
|
const content = [{ type: "text", text: designReport(rel, design.manifest, checks) }];
|
|
@@ -18447,14 +18703,14 @@ ${patch}`;
|
|
|
18447
18703
|
const chrome = findChrome();
|
|
18448
18704
|
if (!chrome) return text("No Chrome or Chromium is installed here, so no screenshot was taken. The user sees the app in the conversation when you write ; say so in one sentence.", true);
|
|
18449
18705
|
try {
|
|
18450
|
-
await (0,
|
|
18706
|
+
await (0, import_promises17.mkdir)((0, import_path18.dirname)(target), { recursive: true });
|
|
18451
18707
|
await screenshotPage(chrome, args.url, target, { width: args.width ?? 1280, height: args.height ?? 800 });
|
|
18452
18708
|
} catch (e) {
|
|
18453
18709
|
this.deps.log.warn("app screenshot failed", { error: this.redactor.text(e.message) });
|
|
18454
18710
|
return text(`The screenshot of ${args.url} failed: is the app running there? Start it in the background and try again.`, true);
|
|
18455
18711
|
}
|
|
18456
18712
|
this.scheduleDiff();
|
|
18457
|
-
const rel = (0,
|
|
18713
|
+
const rel = (0, import_path18.relative)(await (0, import_promises17.realpath)(this.deps.root).catch(() => this.deps.root), target).split(import_path18.sep).join("/");
|
|
18458
18714
|
return text(`Saved the screenshot to ${rel}. Read it to see the app, and show it as  when it helps the user.`);
|
|
18459
18715
|
}
|
|
18460
18716
|
async searchWeb(query) {
|
|
@@ -18492,7 +18748,7 @@ ${sources}` : ""}`);
|
|
|
18492
18748
|
try {
|
|
18493
18749
|
const image = await readImageFile(root, await insideRelative(args.editPath, [root]), this.deps.privateDirs ?? []);
|
|
18494
18750
|
if (!["image/png", "image/jpeg", "image/webp"].includes(image.mime)) return text(`${args.editPath} is not a PNG, JPEG or WebP image, so it cannot be changed. Nothing was created.`, true);
|
|
18495
|
-
reference = { name: (0,
|
|
18751
|
+
reference = { name: (0, import_path18.basename)(image.path), mimeType: image.mime, sizeBytes: image.size, dataBase64: image.data };
|
|
18496
18752
|
} catch (e) {
|
|
18497
18753
|
return text(`Could not read ${args.editPath} to change it (${e instanceof FileRequestError ? e.code : "UNREADABLE"}). Nothing was created.`, true);
|
|
18498
18754
|
}
|
|
@@ -18507,10 +18763,10 @@ ${sources}` : ""}`);
|
|
|
18507
18763
|
if ("refused" in created) return text(`The image could not be created (${created.refused}). Tell the user plainly in one sentence; do not claim an image was made and do not offer a prompt for another tool instead.`, true);
|
|
18508
18764
|
const bytes = Buffer.from(created.dataBase64, "base64");
|
|
18509
18765
|
if (!bytes.length || !imageMime(bytes)) return text("The image model returned something that is not an image. Nothing was saved.", true);
|
|
18510
|
-
await (0,
|
|
18511
|
-
await (0,
|
|
18766
|
+
await (0, import_promises17.mkdir)((0, import_path18.dirname)(target), { recursive: true });
|
|
18767
|
+
await (0, import_promises17.writeFile)(target, bytes);
|
|
18512
18768
|
this.scheduleDiff();
|
|
18513
|
-
const rel = (0,
|
|
18769
|
+
const rel = (0, import_path18.relative)(await (0, import_promises17.realpath)(root).catch(() => root), target).split(import_path18.sep).join("/");
|
|
18514
18770
|
return text(`Saved the image to ${rel}. Show it to the user in your answer as  and say in one or two sentences what you made.`);
|
|
18515
18771
|
}
|
|
18516
18772
|
listRepositories() {
|
|
@@ -18589,7 +18845,7 @@ ${JSON.stringify(data, null, 1)}`);
|
|
|
18589
18845
|
const repo2 = picked.repo;
|
|
18590
18846
|
const refused = this.notInScope(repo2);
|
|
18591
18847
|
if (refused) {
|
|
18592
|
-
say2("REPOSITORY_NOT_IN_SCOPE", { repoFullName: repo2.repoFullName ?? (0,
|
|
18848
|
+
say2("REPOSITORY_NOT_IN_SCOPE", { repoFullName: repo2.repoFullName ?? (0, import_path18.basename)(repo2.root) });
|
|
18593
18849
|
return text(refused, true);
|
|
18594
18850
|
}
|
|
18595
18851
|
if (!repo2.measurer) {
|
|
@@ -18610,7 +18866,7 @@ ${JSON.stringify(data, null, 1)}`);
|
|
|
18610
18866
|
return text("The measurement did not finish in time. Say it was not measured; do not estimate.", true);
|
|
18611
18867
|
}
|
|
18612
18868
|
if ("empty" in r) {
|
|
18613
|
-
say2("NOTHING_TO_MEASURE", { repoFullName: repo2.repoFullName ?? (0,
|
|
18869
|
+
say2("NOTHING_TO_MEASURE", { repoFullName: repo2.repoFullName ?? (0, import_path18.basename)(repo2.root) });
|
|
18614
18870
|
return text(`There is no change in ${repo2.repoFullName} to measure.`);
|
|
18615
18871
|
}
|
|
18616
18872
|
this.emit({ type: "measurement", data: { ...r.data, ...repo2.repoFullName ? { repoFullName: repo2.repoFullName } : {} } });
|
|
@@ -18832,13 +19088,19 @@ function buildEngineEnv(boot, configDir, model, opts = {}) {
|
|
|
18832
19088
|
Object.assign(env, {
|
|
18833
19089
|
CLAUDE_CONFIG_DIR: configDir,
|
|
18834
19090
|
// Background command output lands here, inside the config dir the policy lets Read read.
|
|
18835
|
-
CLAUDE_CODE_TMPDIR: (0,
|
|
19091
|
+
CLAUDE_CODE_TMPDIR: (0, import_path18.join)(configDir, "tmp"),
|
|
18836
19092
|
CLAUDE_AGENT_SDK_CLIENT_APP: opts.local ? "scalequality-cli-connect/1.0" : "scalequality-workspace/1.0",
|
|
18837
19093
|
DISABLE_TELEMETRY: "1",
|
|
18838
19094
|
DISABLE_ERROR_REPORTING: "1",
|
|
18839
19095
|
DISABLE_AUTOUPDATER: "1",
|
|
18840
19096
|
DISABLE_GROWTHBOOK: "1",
|
|
18841
19097
|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC: "1",
|
|
19098
|
+
// Claude Code 2.1.312 (Agent SDK 0.3.312) announces betas the gateway refuses (advanced-tool-use with `defer_loading`
|
|
19099
|
+
// on the tools, thinking-display-updates) unless this is set. With it the request is a subset of what 2.1.281
|
|
19100
|
+
// sent: the betas claude-code, interleaved-thinking and effort, and no `context_management` (probed 14/11/2026,
|
|
19101
|
+
// the real CLI against a local Messages API). The version matters to the provider: Anthropic refuses Claude
|
|
19102
|
+
// Fable 5.2 to a client older than 2.1.290 (400 claude_code_version_too_old, production 12 and 13/11/2026).
|
|
19103
|
+
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS: "1",
|
|
18842
19104
|
// The task list. Claude Code 2.1.281 replaces TodoWrite with TaskCreate/TaskUpdate unless this is off, and then
|
|
18843
19105
|
// drops TodoWrite from `tools` without a word (probed 15/10/2026: the model had no list at all). TodoWrite sends
|
|
18844
19106
|
// the whole list in one call, the list the screen shows.
|
|
@@ -18868,7 +19130,7 @@ function buildQueryOptions(o) {
|
|
|
18868
19130
|
const dir = o.policy.planDir;
|
|
18869
19131
|
if (!file || !dir || !file.endsWith(".md")) return "";
|
|
18870
19132
|
const abs = await resolveInside(dir, file);
|
|
18871
|
-
return abs ? (0,
|
|
19133
|
+
return abs ? (0, import_promises17.readFile)(abs, "utf8").catch(() => "") : "";
|
|
18872
19134
|
};
|
|
18873
19135
|
const preToolUse = async (input) => {
|
|
18874
19136
|
if (input.hook_event_name !== "PreToolUse") return {};
|
|
@@ -18933,7 +19195,7 @@ function buildQueryOptions(o) {
|
|
|
18933
19195
|
const changes = !o.plan && toolName in WRITE_TOOL_PATHS;
|
|
18934
19196
|
const changePath = () => {
|
|
18935
19197
|
const field = WRITE_TOOL_PATHS[toolName];
|
|
18936
|
-
return typeof d.updatedInput[field] === "string" ? (0,
|
|
19198
|
+
return typeof d.updatedInput[field] === "string" ? (0, import_path18.relative)(o.root, d.updatedInput[field]) || String(d.updatedInput[field]) : "";
|
|
18937
19199
|
};
|
|
18938
19200
|
if (changes && protections.toolApproval) {
|
|
18939
19201
|
const path = changePath(), askEdit = o.protection?.approver?.askEdit;
|
|
@@ -19010,15 +19272,15 @@ function timedGate(gate, took) {
|
|
|
19010
19272
|
}
|
|
19011
19273
|
async function hasLocalTranscript(configDir, sessionId) {
|
|
19012
19274
|
if (!/^[A-Za-z0-9-]{8,80}$/.test(sessionId)) return false;
|
|
19013
|
-
const projects = (0,
|
|
19014
|
-
const dirs = await (0,
|
|
19015
|
-
return dirs.some((d) => (0,
|
|
19275
|
+
const projects = (0, import_path18.join)(configDir, "projects");
|
|
19276
|
+
const dirs = await (0, import_promises17.readdir)(projects).catch(() => []);
|
|
19277
|
+
return dirs.some((d) => (0, import_fs12.existsSync)((0, import_path18.join)(projects, d, `${sessionId}.jsonl`)));
|
|
19016
19278
|
}
|
|
19017
19279
|
|
|
19018
19280
|
// src/application/services/workspaceSandbox/selfUpdate.ts
|
|
19019
19281
|
var import_crypto10 = require("crypto");
|
|
19020
|
-
var
|
|
19021
|
-
var
|
|
19282
|
+
var import_fs13 = require("fs");
|
|
19283
|
+
var import_path19 = require("path");
|
|
19022
19284
|
var REGISTRY_LATEST = "https://registry.npmjs.org/@scalequality%2fcli/latest";
|
|
19023
19285
|
var UPDATE_FIRST_CHECK_MS = 2 * 6e4;
|
|
19024
19286
|
var UPDATE_INTERVAL_MS = 6 * 36e5;
|
|
@@ -19027,10 +19289,10 @@ var UPDATE_RETRY_MS = 15 * 6e4;
|
|
|
19027
19289
|
var CONFIRM_AFTER_MS = 9e4;
|
|
19028
19290
|
var RESTART_EXIT_CODE = 75;
|
|
19029
19291
|
var MAX_START_ATTEMPTS = 3;
|
|
19030
|
-
var cliDir = (home) => (0,
|
|
19031
|
-
var launcherPath = (home) => (0,
|
|
19032
|
-
var currentPath = (home) => (0,
|
|
19033
|
-
var autoUpdateOffPath = (home) => (0,
|
|
19292
|
+
var cliDir = (home) => (0, import_path19.join)(sqHome(home), "cli");
|
|
19293
|
+
var launcherPath = (home) => (0, import_path19.join)(cliDir(home), "launcher.mjs");
|
|
19294
|
+
var currentPath = (home) => (0, import_path19.join)(cliDir(home), "current.json");
|
|
19295
|
+
var autoUpdateOffPath = (home) => (0, import_path19.join)(cliDir(home), "auto-update-off");
|
|
19034
19296
|
var VERSION = /^(\d{1,5})\.(\d{1,5})\.(\d{1,5})$/;
|
|
19035
19297
|
function isNewer(candidate, current) {
|
|
19036
19298
|
const a = VERSION.exec(candidate), b = VERSION.exec(current);
|
|
@@ -19043,18 +19305,18 @@ function isNewer(candidate, current) {
|
|
|
19043
19305
|
}
|
|
19044
19306
|
function readJson2(file) {
|
|
19045
19307
|
try {
|
|
19046
|
-
const v = JSON.parse((0,
|
|
19308
|
+
const v = JSON.parse((0, import_fs13.readFileSync)(file, "utf8"));
|
|
19047
19309
|
return v && typeof v === "object" ? v : null;
|
|
19048
19310
|
} catch {
|
|
19049
19311
|
return null;
|
|
19050
19312
|
}
|
|
19051
19313
|
}
|
|
19052
19314
|
function writeJsonAtomic(file, value) {
|
|
19053
|
-
(0,
|
|
19315
|
+
(0, import_fs13.mkdirSync)((0, import_path19.dirname)(file), { recursive: true, mode: 448 });
|
|
19054
19316
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
19055
|
-
(0,
|
|
19317
|
+
(0, import_fs13.writeFileSync)(tmp, `${JSON.stringify(value, null, 2)}
|
|
19056
19318
|
`, { mode: 384 });
|
|
19057
|
-
(0,
|
|
19319
|
+
(0, import_fs13.renameSync)(tmp, file);
|
|
19058
19320
|
}
|
|
19059
19321
|
var installed = (v) => {
|
|
19060
19322
|
const r = v;
|
|
@@ -19110,8 +19372,8 @@ function installLauncher(home, copy) {
|
|
|
19110
19372
|
writeJsonAtomic(currentPath(home), { version: copy.version, bin: copy.bin, previous: null, pending: false, attempts: 0, rejected: current?.rejected ?? [] });
|
|
19111
19373
|
const file = launcherPath(home);
|
|
19112
19374
|
const tmp = `${file}.${process.pid}.tmp`;
|
|
19113
|
-
(0,
|
|
19114
|
-
(0,
|
|
19375
|
+
(0, import_fs13.writeFileSync)(tmp, launcherSource(copy.bin), { mode: 420 });
|
|
19376
|
+
(0, import_fs13.renameSync)(tmp, file);
|
|
19115
19377
|
return file;
|
|
19116
19378
|
}
|
|
19117
19379
|
function confirmCurrent(home, version) {
|
|
@@ -19123,17 +19385,17 @@ function confirmCurrent(home, version) {
|
|
|
19123
19385
|
}
|
|
19124
19386
|
function behindCurrent(home, version) {
|
|
19125
19387
|
const current = readCurrent(home);
|
|
19126
|
-
if (!current || current.pending || current.version === version || !isNewer(current.version, version) || !(0,
|
|
19388
|
+
if (!current || current.pending || current.version === version || !isNewer(current.version, version) || !(0, import_fs13.existsSync)(current.bin)) return null;
|
|
19127
19389
|
return current.version;
|
|
19128
19390
|
}
|
|
19129
19391
|
function autoUpdateEnabled(home, env) {
|
|
19130
|
-
return env.SCALEQUALITY_NO_AUTO_UPDATE !== "1" && !(0,
|
|
19392
|
+
return env.SCALEQUALITY_NO_AUTO_UPDATE !== "1" && !(0, import_fs13.existsSync)(autoUpdateOffPath(home));
|
|
19131
19393
|
}
|
|
19132
19394
|
function setAutoUpdate(home, on) {
|
|
19133
|
-
if (on) (0,
|
|
19395
|
+
if (on) (0, import_fs13.rmSync)(autoUpdateOffPath(home), { force: true });
|
|
19134
19396
|
else {
|
|
19135
|
-
(0,
|
|
19136
|
-
(0,
|
|
19397
|
+
(0, import_fs13.mkdirSync)(cliDir(home), { recursive: true, mode: 448 });
|
|
19398
|
+
(0, import_fs13.writeFileSync)(autoUpdateOffPath(home), `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
19137
19399
|
`, { mode: 384 });
|
|
19138
19400
|
}
|
|
19139
19401
|
}
|
|
@@ -19147,20 +19409,20 @@ async function latestVersion(fetchImpl = fetch) {
|
|
|
19147
19409
|
return null;
|
|
19148
19410
|
}
|
|
19149
19411
|
}
|
|
19150
|
-
function npmCli(nodePath, exists =
|
|
19151
|
-
const dir = (0,
|
|
19412
|
+
function npmCli(nodePath, exists = import_fs13.existsSync, resolve8 = realOrNull, pathEnv = process.env.PATH ?? "") {
|
|
19413
|
+
const dir = (0, import_path19.dirname)(nodePath);
|
|
19152
19414
|
const script = (p) => p && /npm-cli\.js$/.test(p) && exists(p) ? p : null;
|
|
19153
19415
|
const linked = (p) => exists(p) ? script(resolve8(p)) : null;
|
|
19154
19416
|
const layouts = [
|
|
19155
|
-
(0,
|
|
19156
|
-
(0,
|
|
19157
|
-
(0,
|
|
19417
|
+
(0, import_path19.join)(dir, "node_modules", "npm", "bin", "npm-cli.js"),
|
|
19418
|
+
(0, import_path19.join)(dir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"),
|
|
19419
|
+
(0, import_path19.join)(dir, "..", "libexec", "lib", "node_modules", "npm", "bin", "npm-cli.js")
|
|
19158
19420
|
];
|
|
19159
|
-
return linked((0,
|
|
19421
|
+
return linked((0, import_path19.join)(dir, "npm")) ?? layouts.map(script).find(Boolean) ?? pathEnv.split(import_path19.delimiter).filter(Boolean).map((d) => linked((0, import_path19.join)(d, "npm"))).find(Boolean) ?? null;
|
|
19160
19422
|
}
|
|
19161
19423
|
function realOrNull(p) {
|
|
19162
19424
|
try {
|
|
19163
|
-
return (0,
|
|
19425
|
+
return (0, import_fs13.realpathSync)(p);
|
|
19164
19426
|
} catch {
|
|
19165
19427
|
return null;
|
|
19166
19428
|
}
|
|
@@ -19180,11 +19442,11 @@ function npmReason(output) {
|
|
|
19180
19442
|
async function installVersion(o) {
|
|
19181
19443
|
const npm = o.npm === void 0 ? npmCli(o.nodePath) : o.npm;
|
|
19182
19444
|
if (!npm) throw new UpdateError("NPM_NOT_FOUND", `npm was not found next to ${o.nodePath}.`);
|
|
19183
|
-
const staging = (0,
|
|
19184
|
-
(0,
|
|
19185
|
-
(0,
|
|
19445
|
+
const staging = (0, import_path19.join)(cliDir(o.home), `.update-${o.version}`);
|
|
19446
|
+
(0, import_fs13.rmSync)(staging, { recursive: true, force: true });
|
|
19447
|
+
(0, import_fs13.mkdirSync)(staging, { recursive: true, mode: 448 });
|
|
19186
19448
|
try {
|
|
19187
|
-
(0,
|
|
19449
|
+
(0, import_fs13.writeFileSync)((0, import_path19.join)(staging, "package.json"), '{ "private": true }\n');
|
|
19188
19450
|
const r = await o.run(o.nodePath, [
|
|
19189
19451
|
npm,
|
|
19190
19452
|
"install",
|
|
@@ -19199,12 +19461,12 @@ async function installVersion(o) {
|
|
|
19199
19461
|
`@scalequality/cli@${o.version}`
|
|
19200
19462
|
]);
|
|
19201
19463
|
if (r.code !== 0) throw new UpdateError("NPM_INSTALL_FAILED", `npm could not install @scalequality/cli@${o.version}: ${npmReason(`${r.stderr || r.stdout}`) || r.code}`);
|
|
19202
|
-
const root = (0,
|
|
19203
|
-
const pkg = readJson2((0,
|
|
19464
|
+
const root = (0, import_path19.join)(staging, "node_modules", "@scalequality", "cli");
|
|
19465
|
+
const pkg = readJson2((0, import_path19.join)(root, "package.json"));
|
|
19204
19466
|
if (pkg?.name !== "@scalequality/cli" || pkg?.version !== o.version) throw new UpdateError("WRONG_PACKAGE", `npm installed ${String(pkg?.name)}@${String(pkg?.version)} instead of ${o.version}.`);
|
|
19205
|
-
const build = readJson2((0,
|
|
19206
|
-
const bundle = (0,
|
|
19207
|
-
const sha = (0,
|
|
19467
|
+
const build = readJson2((0, import_path19.join)(root, "dist", "connect.build.json"));
|
|
19468
|
+
const bundle = (0, import_path19.join)(root, "dist", "connect.cjs");
|
|
19469
|
+
const sha = (0, import_fs13.existsSync)(bundle) ? (0, import_crypto10.createHash)("sha256").update((0, import_fs13.readFileSync)(bundle)).digest("hex") : null;
|
|
19208
19470
|
if (!sha || typeof build?.sha256 !== "string" || build.sha256 !== sha) throw new UpdateError("BUNDLE_MISMATCH", `The engine of ${o.version} does not match the sha256 it declares.`);
|
|
19209
19471
|
let copy;
|
|
19210
19472
|
try {
|
|
@@ -19214,7 +19476,7 @@ async function installVersion(o) {
|
|
|
19214
19476
|
}
|
|
19215
19477
|
return { version: copy.version, bin: copy.bin };
|
|
19216
19478
|
} finally {
|
|
19217
|
-
(0,
|
|
19479
|
+
(0, import_fs13.rmSync)(staging, { recursive: true, force: true });
|
|
19218
19480
|
}
|
|
19219
19481
|
}
|
|
19220
19482
|
function stageVersion(home, next, running) {
|
|
@@ -19261,9 +19523,9 @@ var say = (line = "") => {
|
|
|
19261
19523
|
var cliVersion = process.env.SCALEQUALITY_CLI_VERSION || "dev";
|
|
19262
19524
|
var userAgent = (mode) => `scalequality-cli/${cliVersion} (${mode}; node ${process.versions.node}; ${process.platform})`;
|
|
19263
19525
|
var HOME = (0, import_os7.homedir)();
|
|
19264
|
-
var SQ_HOME = (0,
|
|
19265
|
-
var ENGINE_HOME = (0,
|
|
19266
|
-
var credentials = new CredentialStore((0,
|
|
19526
|
+
var SQ_HOME = (0, import_path20.join)(HOME, ".scalequality");
|
|
19527
|
+
var ENGINE_HOME = (0, import_path20.join)(SQ_HOME, "workspace");
|
|
19528
|
+
var credentials = new CredentialStore((0, import_path20.join)(SQ_HOME, "credentials.json"));
|
|
19267
19529
|
function startFailure(e, api) {
|
|
19268
19530
|
if (e instanceof NotLocalSessionError) return 'This code belongs to a cloud workspace session. In the AI Workspace, choose "Use a folder on your computer" to get a code for this command.';
|
|
19269
19531
|
if (e instanceof SessionGoneError) {
|
|
@@ -19276,16 +19538,16 @@ function startFailure(e, api) {
|
|
|
19276
19538
|
return "ScaleQuality could not start this session. Try again in a moment, or get a new code from the AI Workspace.";
|
|
19277
19539
|
}
|
|
19278
19540
|
function engineDirs() {
|
|
19279
|
-
const configDir = (0,
|
|
19280
|
-
const scratch = (0,
|
|
19281
|
-
(0,
|
|
19282
|
-
(0,
|
|
19541
|
+
const configDir = (0, import_path20.join)(ENGINE_HOME, "claude-home");
|
|
19542
|
+
const scratch = (0, import_path20.join)(ENGINE_HOME, "tmp");
|
|
19543
|
+
(0, import_fs14.mkdirSync)(configDir, { recursive: true, mode: 448 });
|
|
19544
|
+
(0, import_fs14.mkdirSync)(scratch, { recursive: true, mode: 448 });
|
|
19283
19545
|
return { configDir, scratch };
|
|
19284
19546
|
}
|
|
19285
19547
|
function createLocalEngine(o) {
|
|
19286
19548
|
const { configDir, scratch } = engineDirs();
|
|
19287
|
-
const sessions = (0,
|
|
19288
|
-
const stateDir = (0,
|
|
19549
|
+
const sessions = (0, import_path20.join)(ENGINE_HOME, "sessions");
|
|
19550
|
+
const stateDir = (0, import_path20.join)(sessions, o.sessionId);
|
|
19289
19551
|
void pruneSessionStates(sessions, stateDir).catch(() => void 0);
|
|
19290
19552
|
const log = {
|
|
19291
19553
|
info: (msg, ctx) => {
|
|
@@ -19588,7 +19850,7 @@ async function upMain(api, verbose, service) {
|
|
|
19588
19850
|
let shuttingDown = false;
|
|
19589
19851
|
let agent;
|
|
19590
19852
|
const startSession = ({ sessionId, secret, root }) => {
|
|
19591
|
-
const label = (0,
|
|
19853
|
+
const label = (0, import_path20.basename)(root);
|
|
19592
19854
|
const prefix = style.dim(`[${label}] `);
|
|
19593
19855
|
const consoleLog = new ConsoleLog(style);
|
|
19594
19856
|
let resolveDone = () => void 0;
|
|
@@ -19732,7 +19994,7 @@ function startSelfUpdate(api, busy, restart) {
|
|
|
19732
19994
|
}
|
|
19733
19995
|
async function addMain(api, path) {
|
|
19734
19996
|
try {
|
|
19735
|
-
const real = await addFolder(credentials, api, (0,
|
|
19997
|
+
const real = await addFolder(credentials, api, (0, import_path20.resolve)(path ?? process.cwd()), HOME);
|
|
19736
19998
|
say(style.green(`Added ${real}.`));
|
|
19737
19999
|
const credential = credentials.get(api);
|
|
19738
20000
|
const client = new MachineClient(api, { token: credential.machineToken, userAgent: userAgent("add") });
|