@taskless-app/swarm 0.6.79 → 0.6.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +464 -132
- package/dist/overmind.js +1129 -302
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -23,6 +23,11 @@ async function askTty(question) {
|
|
|
23
23
|
async function askYesNo(question) {
|
|
24
24
|
return YES.includes((await askTty(`${question} [y/N]: `)).trim().toLowerCase());
|
|
25
25
|
}
|
|
26
|
+
function readCommandOutcome(result) {
|
|
27
|
+
if (typeof result === "number") return { exitCode: result, output: "" };
|
|
28
|
+
return { exitCode: result.exitCode, output: `${result.stdout ?? ""}
|
|
29
|
+
${result.stderr ?? ""}` };
|
|
30
|
+
}
|
|
26
31
|
async function runQuiet(command, opts = {}) {
|
|
27
32
|
try {
|
|
28
33
|
const res = await execa(command, { shell: true, reject: false, timeout: opts.timeoutMs ?? PROBE_TIMEOUT_MS });
|
|
@@ -35,6 +40,15 @@ async function execLoud(command) {
|
|
|
35
40
|
const res = await execa(command, { shell: true, reject: false, stdio: "inherit" });
|
|
36
41
|
return res.exitCode ?? 1;
|
|
37
42
|
}
|
|
43
|
+
async function execCaptured(command) {
|
|
44
|
+
const res = await execa(command, {
|
|
45
|
+
shell: true,
|
|
46
|
+
reject: false,
|
|
47
|
+
stdout: ["pipe", "inherit"],
|
|
48
|
+
stderr: ["pipe", "inherit"]
|
|
49
|
+
});
|
|
50
|
+
return { exitCode: res.exitCode ?? 1, stdout: res.stdout ?? "", stderr: res.stderr ?? "" };
|
|
51
|
+
}
|
|
38
52
|
var YES, PROBE_TIMEOUT_MS;
|
|
39
53
|
var init_cliIo = __esm({
|
|
40
54
|
"src/cliIo.ts"() {
|
|
@@ -223,12 +237,13 @@ function verifyStatsLine(s) {
|
|
|
223
237
|
const pct = Math.round(s.negativeShare * 100);
|
|
224
238
|
return `\u0432\u0435\u0440\u0434\u0438\u043A\u0442\u043E\u0432 ${s.total} \xB7 \u043E\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0445 ${s.negative} (${pct}%): \u043D\u0435 \u0432\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u043B\u043E\u0441\u044C ${s.notReproduced}, \u043D\u0430\u0448\u043B\u0438 \u0434\u0435\u0444\u0435\u043A\u0442 ${s.foundIssues}`;
|
|
225
239
|
}
|
|
226
|
-
var VERIFY_VERDICTS, VERIFY_VERDICT_SET;
|
|
240
|
+
var VERIFY_VERDICTS, VERIFY_VERDICT_SET, DRONE_COMMENT_SIGNATURE;
|
|
227
241
|
var init_verifyVerdict = __esm({
|
|
228
242
|
"../swarm-core/src/verifyVerdict.ts"() {
|
|
229
243
|
"use strict";
|
|
230
244
|
VERIFY_VERDICTS = ["confirmed", "not_reproduced", "found_issues"];
|
|
231
245
|
VERIFY_VERDICT_SET = new Set(VERIFY_VERDICTS);
|
|
246
|
+
DRONE_COMMENT_SIGNATURE = "\u{1F41D} \u0414\u0440\u043E\u043D";
|
|
232
247
|
}
|
|
233
248
|
});
|
|
234
249
|
|
|
@@ -870,16 +885,30 @@ function sanitizeEventText(text) {
|
|
|
870
885
|
if (!cleaned.length) return null;
|
|
871
886
|
return cleaned.length <= EVENT_TEXT_MAX ? cleaned : clampEventText(cleaned);
|
|
872
887
|
}
|
|
888
|
+
function sanitizeVerdictEventText(text) {
|
|
889
|
+
if (text == null) return null;
|
|
890
|
+
const cleaned = text.replace(ANSI_CSI_RE, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(VERDICT_CONTROL_RE, " ").trim();
|
|
891
|
+
if (!cleaned.length) return null;
|
|
892
|
+
return cleaned.length <= EVENT_TEXT_MAX ? cleaned : clampEventText(cleaned);
|
|
893
|
+
}
|
|
894
|
+
function sanitizeStoredEventText(text) {
|
|
895
|
+
if (typeof text === "string") {
|
|
896
|
+
const head = text.trimStart();
|
|
897
|
+
if (head.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E") || head.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438")) return sanitizeVerdictEventText(text);
|
|
898
|
+
}
|
|
899
|
+
return sanitizeEventText(text);
|
|
900
|
+
}
|
|
873
901
|
function clampEventText(text) {
|
|
874
902
|
const note = ` \u2026 (\u043E\u0431\u0440\u0435\u0437\u0430\u043D\u043E, \u0431\u044B\u043B\u043E ${text.length} \u0441\u0438\u043C\u0432\u043E\u043B\u043E\u0432)`;
|
|
875
903
|
return text.slice(0, Math.max(0, EVENT_TEXT_MAX - note.length)) + note;
|
|
876
904
|
}
|
|
877
|
-
var ANSI_CSI_RE, CONTROL_CHARS_RE, EVENT_TEXT_MAX;
|
|
905
|
+
var ANSI_CSI_RE, CONTROL_CHARS_RE, VERDICT_CONTROL_RE, EVENT_TEXT_MAX;
|
|
878
906
|
var init_text = __esm({
|
|
879
907
|
"../swarm-core/src/text.ts"() {
|
|
880
908
|
"use strict";
|
|
881
909
|
ANSI_CSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
882
910
|
CONTROL_CHARS_RE = /[\x00-\x1f\x7f]/g;
|
|
911
|
+
VERDICT_CONTROL_RE = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
|
|
883
912
|
EVENT_TEXT_MAX = 16e3;
|
|
884
913
|
}
|
|
885
914
|
});
|
|
@@ -3389,6 +3418,33 @@ var init_storm = __esm({
|
|
|
3389
3418
|
}
|
|
3390
3419
|
});
|
|
3391
3420
|
|
|
3421
|
+
// src/slugRetry.ts
|
|
3422
|
+
function unknownArg(text, key) {
|
|
3423
|
+
return text.includes("\u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D") && text.includes("\u0430\u0440\u0433\u0443\u043C\u0435\u043D\u0442") && text.includes(`\xAB${key}\xBB`);
|
|
3424
|
+
}
|
|
3425
|
+
var SLUG_RETRY_MS, SlugUnsupportedAt;
|
|
3426
|
+
var init_slugRetry = __esm({
|
|
3427
|
+
"src/slugRetry.ts"() {
|
|
3428
|
+
"use strict";
|
|
3429
|
+
SLUG_RETRY_MS = 10 * 6e4;
|
|
3430
|
+
SlugUnsupportedAt = class {
|
|
3431
|
+
constructor(now = () => Date.now()) {
|
|
3432
|
+
this.now = now;
|
|
3433
|
+
}
|
|
3434
|
+
now;
|
|
3435
|
+
at = /* @__PURE__ */ new Map();
|
|
3436
|
+
/** Отказ этого тула ещё внутри окна повторной пробы. */
|
|
3437
|
+
within(tool) {
|
|
3438
|
+
const noted = this.at.get(tool);
|
|
3439
|
+
return noted != null && this.now() - noted < SLUG_RETRY_MS;
|
|
3440
|
+
}
|
|
3441
|
+
note(tool) {
|
|
3442
|
+
this.at.set(tool, this.now());
|
|
3443
|
+
}
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
});
|
|
3447
|
+
|
|
3392
3448
|
// src/zoneNotes.ts
|
|
3393
3449
|
function normalizeZoneLabel(zone) {
|
|
3394
3450
|
return (zone ?? "").trim().replace(/^area:/i, "").trim().toLowerCase();
|
|
@@ -3599,6 +3655,7 @@ var init_toolFailure = __esm({
|
|
|
3599
3655
|
});
|
|
3600
3656
|
|
|
3601
3657
|
// src/procList.ts
|
|
3658
|
+
import { readFileSync as readFileSync8 } from "fs";
|
|
3602
3659
|
function parsePsRows(out) {
|
|
3603
3660
|
const rows = [];
|
|
3604
3661
|
for (const line of out.split("\n")) {
|
|
@@ -3881,7 +3938,7 @@ var init_package = __esm({
|
|
|
3881
3938
|
"package.json"() {
|
|
3882
3939
|
package_default = {
|
|
3883
3940
|
name: "@taskless-app/swarm",
|
|
3884
|
-
version: "0.6.
|
|
3941
|
+
version: "0.6.81",
|
|
3885
3942
|
type: "module",
|
|
3886
3943
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
3887
3944
|
keywords: [
|
|
@@ -3933,7 +3990,7 @@ var init_package = __esm({
|
|
|
3933
3990
|
undici: "^7.30.1",
|
|
3934
3991
|
zod: "3.25.76"
|
|
3935
3992
|
},
|
|
3936
|
-
gitHead: "
|
|
3993
|
+
gitHead: "0a4c6ee0b5f07c122a325e3df3bc3361ee01b312"
|
|
3937
3994
|
};
|
|
3938
3995
|
}
|
|
3939
3996
|
});
|
|
@@ -4099,12 +4156,12 @@ var init_netTimeout = __esm({
|
|
|
4099
4156
|
|
|
4100
4157
|
// src/droneChannel.ts
|
|
4101
4158
|
import { createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
4102
|
-
import { chmodSync as chmodSync2, mkdirSync as mkdirSync8, readFileSync as
|
|
4159
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "fs";
|
|
4103
4160
|
import { dirname as dirname3 } from "path";
|
|
4104
4161
|
import { serve } from "@hono/node-server";
|
|
4105
4162
|
function loadChannelSecret(path) {
|
|
4106
4163
|
try {
|
|
4107
|
-
const s =
|
|
4164
|
+
const s = readFileSync10(path, "utf8").trim();
|
|
4108
4165
|
if (s.length >= 32) return s;
|
|
4109
4166
|
} catch {
|
|
4110
4167
|
}
|
|
@@ -4187,7 +4244,7 @@ var init_authState = __esm({
|
|
|
4187
4244
|
|
|
4188
4245
|
// src/oauth.ts
|
|
4189
4246
|
import { createHash, randomBytes as randomBytes2 } from "crypto";
|
|
4190
|
-
import { readFileSync as
|
|
4247
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync9, unlinkSync as unlinkSync3 } from "fs";
|
|
4191
4248
|
import { join as join13 } from "path";
|
|
4192
4249
|
function makePkce() {
|
|
4193
4250
|
const verifier = randomBytes2(48).toString("base64url");
|
|
@@ -4272,7 +4329,7 @@ function toStore(clientId, t, now) {
|
|
|
4272
4329
|
}
|
|
4273
4330
|
function loadStore() {
|
|
4274
4331
|
try {
|
|
4275
|
-
return JSON.parse(
|
|
4332
|
+
return JSON.parse(readFileSync11(STORE_PATH2, "utf8"));
|
|
4276
4333
|
} catch {
|
|
4277
4334
|
return null;
|
|
4278
4335
|
}
|
|
@@ -4288,7 +4345,7 @@ function clearStore() {
|
|
|
4288
4345
|
}
|
|
4289
4346
|
function loadClientId() {
|
|
4290
4347
|
try {
|
|
4291
|
-
return JSON.parse(
|
|
4348
|
+
return JSON.parse(readFileSync11(CLIENT_PATH, "utf8")).clientId;
|
|
4292
4349
|
} catch {
|
|
4293
4350
|
return null;
|
|
4294
4351
|
}
|
|
@@ -4708,11 +4765,11 @@ var init_prodHttp = __esm({
|
|
|
4708
4765
|
});
|
|
4709
4766
|
|
|
4710
4767
|
// src/workspace.ts
|
|
4711
|
-
import { readFileSync as
|
|
4768
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync10, unlinkSync as unlinkSync4 } from "fs";
|
|
4712
4769
|
import { join as join19 } from "path";
|
|
4713
4770
|
function loadWorkspace() {
|
|
4714
4771
|
try {
|
|
4715
|
-
const w = JSON.parse(
|
|
4772
|
+
const w = JSON.parse(readFileSync12(WORKSPACE_PATH, "utf8"));
|
|
4716
4773
|
return w && typeof w.id === "string" && w.id ? w : null;
|
|
4717
4774
|
} catch {
|
|
4718
4775
|
return null;
|
|
@@ -4850,6 +4907,7 @@ var init_taskless = __esm({
|
|
|
4850
4907
|
init_linkFailure();
|
|
4851
4908
|
init_prodHttp();
|
|
4852
4909
|
init_toolFailure();
|
|
4910
|
+
init_slugRetry();
|
|
4853
4911
|
init_authState();
|
|
4854
4912
|
init_workspace();
|
|
4855
4913
|
UNTRUSTED_TASK_INPUT_NOTICE = [
|
|
@@ -5175,14 +5233,14 @@ var init_daemonLink = __esm({
|
|
|
5175
5233
|
});
|
|
5176
5234
|
|
|
5177
5235
|
// src/pauseState.ts
|
|
5178
|
-
import { existsSync as existsSync12, readFileSync as
|
|
5236
|
+
import { existsSync as existsSync12, readFileSync as readFileSync13, renameSync as renameSync5, unlinkSync as unlinkSync5, writeFileSync as writeFileSync11 } from "fs";
|
|
5179
5237
|
import { join as join20 } from "path";
|
|
5180
5238
|
function pauseStatePath(home) {
|
|
5181
5239
|
return join20(home, "pause.json");
|
|
5182
5240
|
}
|
|
5183
5241
|
function loadPauseState(home, io = {}) {
|
|
5184
5242
|
const exists = io.exists ?? existsSync12;
|
|
5185
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
5243
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync13(p, "utf8"));
|
|
5186
5244
|
const path = pauseStatePath(home);
|
|
5187
5245
|
if (!exists(path)) return ACTIVE;
|
|
5188
5246
|
try {
|
|
@@ -5243,10 +5301,10 @@ var init_pauseState = __esm({
|
|
|
5243
5301
|
});
|
|
5244
5302
|
|
|
5245
5303
|
// src/heartbeat.ts
|
|
5246
|
-
import { readFileSync as
|
|
5304
|
+
import { readFileSync as readFileSync14, renameSync as renameSync6, writeFileSync as writeFileSync12 } from "fs";
|
|
5247
5305
|
function readHeartbeat(path) {
|
|
5248
5306
|
try {
|
|
5249
|
-
const ms = Number(
|
|
5307
|
+
const ms = Number(readFileSync14(path, "utf8").trim());
|
|
5250
5308
|
return Number.isFinite(ms) ? ms : null;
|
|
5251
5309
|
} catch {
|
|
5252
5310
|
return null;
|
|
@@ -6094,7 +6152,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
6094
6152
|
}
|
|
6095
6153
|
// --- events (лог/хроника) ---
|
|
6096
6154
|
addEvent(run_id, kind, text, actor = null) {
|
|
6097
|
-
const clean =
|
|
6155
|
+
const clean = sanitizeStoredEventText(text);
|
|
6098
6156
|
const insert = () => this.db.prepare("INSERT INTO events (run_id, kind, text, actor) VALUES (?, ?, ?, ?)").run(run_id, kind, clean, actor);
|
|
6099
6157
|
try {
|
|
6100
6158
|
insert();
|
|
@@ -6257,7 +6315,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
6257
6315
|
});
|
|
6258
6316
|
|
|
6259
6317
|
// src/repoScan.ts
|
|
6260
|
-
import { readdirSync as readdirSync11, readFileSync as
|
|
6318
|
+
import { readdirSync as readdirSync11, readFileSync as readFileSync15, statSync as statSync11 } from "fs";
|
|
6261
6319
|
import { join as join21 } from "path";
|
|
6262
6320
|
var init_repoScan = __esm({
|
|
6263
6321
|
"src/repoScan.ts"() {
|
|
@@ -6268,7 +6326,7 @@ var init_repoScan = __esm({
|
|
|
6268
6326
|
|
|
6269
6327
|
// src/repoDiscovery.ts
|
|
6270
6328
|
import { homedir as homedir6 } from "os";
|
|
6271
|
-
import { readFileSync as
|
|
6329
|
+
import { readFileSync as readFileSync16, renameSync as renameSync7, writeFileSync as writeFileSync13 } from "fs";
|
|
6272
6330
|
import { isAbsolute as isAbsolute3, join as join22, resolve as resolve4 } from "path";
|
|
6273
6331
|
function repoMapLines(rows) {
|
|
6274
6332
|
if (!rows?.length) return [];
|
|
@@ -6284,7 +6342,7 @@ function repoMapLines(rows) {
|
|
|
6284
6342
|
}
|
|
6285
6343
|
function loadRepoMapCache(path) {
|
|
6286
6344
|
try {
|
|
6287
|
-
const raw = JSON.parse(
|
|
6345
|
+
const raw = JSON.parse(readFileSync16(path, "utf8"));
|
|
6288
6346
|
if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
|
|
6289
6347
|
return {
|
|
6290
6348
|
scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
|
|
@@ -6660,11 +6718,11 @@ __export(statusCli_exports, {
|
|
|
6660
6718
|
probeLink: () => probeLink,
|
|
6661
6719
|
runStatusCli: () => runStatusCli
|
|
6662
6720
|
});
|
|
6663
|
-
import { existsSync as existsSync14, readFileSync as
|
|
6721
|
+
import { existsSync as existsSync14, readFileSync as readFileSync17 } from "fs";
|
|
6664
6722
|
function outboxPending(path) {
|
|
6665
6723
|
try {
|
|
6666
6724
|
if (!existsSync14(path)) return 0;
|
|
6667
|
-
return
|
|
6725
|
+
return readFileSync17(path, "utf8").split("\n").filter((l) => l.trim()).length;
|
|
6668
6726
|
} catch {
|
|
6669
6727
|
return null;
|
|
6670
6728
|
}
|
|
@@ -6871,11 +6929,11 @@ var init_prodMergeGate = __esm({
|
|
|
6871
6929
|
});
|
|
6872
6930
|
|
|
6873
6931
|
// src/platform.ts
|
|
6874
|
-
import { existsSync as existsSync15, readFileSync as
|
|
6875
|
-
import { delimiter, join as join23 } from "path";
|
|
6932
|
+
import { accessSync, constants, existsSync as existsSync15, readFileSync as readFileSync18, realpathSync as realpathSync3 } from "fs";
|
|
6933
|
+
import { delimiter, join as join23, posix as posix2, win32 } from "path";
|
|
6876
6934
|
function safeReadText(path) {
|
|
6877
6935
|
try {
|
|
6878
|
-
return
|
|
6936
|
+
return readFileSync18(path, "utf8");
|
|
6879
6937
|
} catch {
|
|
6880
6938
|
return null;
|
|
6881
6939
|
}
|
|
@@ -6957,7 +7015,11 @@ function detectGlobalPm(entry, io = {}) {
|
|
|
6957
7015
|
const has2 = io.hasCommand ?? ((n) => hasCommandInPath(n, env, platform));
|
|
6958
7016
|
return has2("npm") ? "npm" : "unknown";
|
|
6959
7017
|
}
|
|
6960
|
-
function
|
|
7018
|
+
function quotePrefix(prefix, platform) {
|
|
7019
|
+
if (platform === "win32") return `"${prefix}"`;
|
|
7020
|
+
return `'${prefix.replaceAll("'", "'\\''")}'`;
|
|
7021
|
+
}
|
|
7022
|
+
function globalInstallCommand(pm, spec, prefix, platform = process.platform) {
|
|
6961
7023
|
switch (pm) {
|
|
6962
7024
|
case "pnpm":
|
|
6963
7025
|
return `pnpm add -g ${spec}`;
|
|
@@ -6966,13 +7028,93 @@ function globalInstallCommand(pm, spec) {
|
|
|
6966
7028
|
case "yarn":
|
|
6967
7029
|
return `yarn global add ${spec}`;
|
|
6968
7030
|
default:
|
|
6969
|
-
return `npm i -g ${spec}`;
|
|
7031
|
+
return prefix ? `npm i -g --prefix ${quotePrefix(prefix, platform)} ${spec}` : `npm i -g ${spec}`;
|
|
7032
|
+
}
|
|
7033
|
+
}
|
|
7034
|
+
function resolveReal(entry, io) {
|
|
7035
|
+
const realpath = io.realpath ?? realpathSync3;
|
|
7036
|
+
try {
|
|
7037
|
+
return realpath(entry);
|
|
7038
|
+
} catch {
|
|
7039
|
+
return entry;
|
|
7040
|
+
}
|
|
7041
|
+
}
|
|
7042
|
+
function npmInstallLocation(entry, io = {}) {
|
|
7043
|
+
if (!entry) return null;
|
|
7044
|
+
const platform = io.platform ?? process.platform;
|
|
7045
|
+
const real = resolveReal(entry, io);
|
|
7046
|
+
const norm = real.replace(/\\/g, "/");
|
|
7047
|
+
if (norm.includes("/_npx/") && norm.includes("/@taskless-app/swarm")) return { kind: "npx" };
|
|
7048
|
+
const marker = platform === "win32" ? WIN_MARKER : UNIX_MARKER;
|
|
7049
|
+
const at = norm.indexOf(marker);
|
|
7050
|
+
if (at < 0) return null;
|
|
7051
|
+
const next = norm[at + marker.length];
|
|
7052
|
+
if (next !== void 0 && next !== "/") return null;
|
|
7053
|
+
let prefix = real.slice(0, at);
|
|
7054
|
+
if (prefix === "") prefix = platform === "win32" ? "" : "/";
|
|
7055
|
+
if (!prefix) return null;
|
|
7056
|
+
const path = platform === "win32" ? win32 : posix2;
|
|
7057
|
+
const modulesDir = platform === "win32" ? path.join(prefix, "node_modules") : path.join(prefix, "lib", "node_modules");
|
|
7058
|
+
return { kind: "prefix", prefix, modulesDir };
|
|
7059
|
+
}
|
|
7060
|
+
function dirWritable(dir, platform, access) {
|
|
7061
|
+
const path = platform === "win32" ? win32 : posix2;
|
|
7062
|
+
let current = dir;
|
|
7063
|
+
for (; ; ) {
|
|
7064
|
+
try {
|
|
7065
|
+
access(current, constants.W_OK);
|
|
7066
|
+
return true;
|
|
7067
|
+
} catch (e) {
|
|
7068
|
+
const code = e && typeof e === "object" && "code" in e ? e.code : void 0;
|
|
7069
|
+
if (code !== "ENOENT") return false;
|
|
7070
|
+
const parent = path.dirname(current);
|
|
7071
|
+
if (parent === current) return false;
|
|
7072
|
+
current = parent;
|
|
7073
|
+
}
|
|
7074
|
+
}
|
|
7075
|
+
}
|
|
7076
|
+
function npxRefusal() {
|
|
7077
|
+
return `\u0440\u043E\u0439 \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0447\u0435\u0440\u0435\u0437 npx, \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E. \u0427\u0442\u043E\u0431\u044B \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u043B\u0441\u044F \u043A\u043D\u043E\u043F\u043A\u043E\u0439, \u043F\u043E\u0441\u0442\u0430\u0432\u044C \u0435\u0433\u043E \u043F\u043E\u0441\u0442\u043E\u044F\u043D\u043D\u043E: ${LATEST_INSTALL}`;
|
|
7078
|
+
}
|
|
7079
|
+
function unwritableRefusal(modulesDir, prefix, platform = process.platform) {
|
|
7080
|
+
const sudoInstall = `sudo ${globalInstallCommand("npm", `${SWARM_PACKAGE_NAME}@latest`, prefix, platform)}`;
|
|
7081
|
+
return `\u0432 \u043F\u0430\u043F\u043A\u0443 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0438 \u043F\u0438\u0441\u0430\u0442\u044C \u043D\u0435\u043B\u044C\u0437\u044F: ${modulesDir}. npm \u043D\u0435 \u0437\u0430\u043F\u0443\u0441\u043A\u0430\u044E. \u041E\u0434\u0438\u043D \u0440\u0430\u0437: ${sudoInstall}. \u0418\u043B\u0438 \u0441\u0432\u043E\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433: npm config set prefix ~/.npm-global, \u0434\u043E\u0431\u0430\u0432\u044C ~/.npm-global/bin \u0432 PATH \u0438 \u043F\u043E\u0441\u0442\u0430\u0432\u044C \u0437\u0430\u043D\u043E\u0432\u043E.`;
|
|
7082
|
+
}
|
|
7083
|
+
function gatePackageInstall(pm, spec, entry, io = {}) {
|
|
7084
|
+
if (pm === "pnpm" || pm === "bun" || pm === "yarn") {
|
|
7085
|
+
return { action: "run", command: globalInstallCommand(pm, spec) };
|
|
6970
7086
|
}
|
|
7087
|
+
if (pm === "sources") {
|
|
7088
|
+
return { action: "run", command: globalInstallCommand("npm", spec) };
|
|
7089
|
+
}
|
|
7090
|
+
const loc = npmInstallLocation(entry, io);
|
|
7091
|
+
if (loc?.kind === "npx") return { action: "refuse", kind: "npx", message: npxRefusal() };
|
|
7092
|
+
if (loc?.kind === "prefix") {
|
|
7093
|
+
const platform = io.platform ?? process.platform;
|
|
7094
|
+
const access = io.access ?? accessSync;
|
|
7095
|
+
if (!dirWritable(loc.modulesDir, platform, access)) {
|
|
7096
|
+
return { action: "refuse", kind: "unwritable", message: unwritableRefusal(loc.modulesDir, loc.prefix, platform) };
|
|
7097
|
+
}
|
|
7098
|
+
return { action: "run", command: globalInstallCommand("npm", spec, loc.prefix, platform) };
|
|
7099
|
+
}
|
|
7100
|
+
return { action: "run", command: globalInstallCommand("npm", spec) };
|
|
7101
|
+
}
|
|
7102
|
+
function npmFailureCode(output) {
|
|
7103
|
+
const plain = output.replace(/\u001b\[[0-9;]*m/g, "");
|
|
7104
|
+
const tagged = plain.match(/(?:npm ERR!|npm error) code ([A-Z][A-Z0-9_]*)/);
|
|
7105
|
+
if (tagged?.[1]) return tagged[1];
|
|
7106
|
+
const bare = plain.match(/\bError: ([A-Z][A-Z0-9_]*):/);
|
|
7107
|
+
return bare?.[1] ?? null;
|
|
6971
7108
|
}
|
|
6972
|
-
|
|
7109
|
+
function installFailureLabel(exitCode, output) {
|
|
7110
|
+
const code = npmFailureCode(output);
|
|
7111
|
+
return code ? `${code}, \u043A\u043E\u0434 ${exitCode}` : `\u043A\u043E\u0434 ${exitCode}`;
|
|
7112
|
+
}
|
|
7113
|
+
var LINUX_PMS, PLATFORM_LABEL, UNIX_MARKER, WIN_MARKER, LATEST_INSTALL;
|
|
6973
7114
|
var init_platform = __esm({
|
|
6974
7115
|
"src/platform.ts"() {
|
|
6975
7116
|
"use strict";
|
|
7117
|
+
init_src();
|
|
6976
7118
|
LINUX_PMS = [
|
|
6977
7119
|
{ cmd: "apt-get", pm: "apt" },
|
|
6978
7120
|
{ cmd: "dnf", pm: "dnf" },
|
|
@@ -6986,6 +7128,9 @@ var init_platform = __esm({
|
|
|
6986
7128
|
wsl: "WSL2 (Linux \u0432\u043D\u0443\u0442\u0440\u0438 Windows)",
|
|
6987
7129
|
windows: "Windows (\u043D\u0430\u0442\u0438\u0432\u043D\u0430\u044F)"
|
|
6988
7130
|
};
|
|
7131
|
+
UNIX_MARKER = "/lib/node_modules/@taskless-app/swarm";
|
|
7132
|
+
WIN_MARKER = "/node_modules/@taskless-app/swarm";
|
|
7133
|
+
LATEST_INSTALL = `npm i -g ${SWARM_PACKAGE_NAME}@latest`;
|
|
6989
7134
|
}
|
|
6990
7135
|
});
|
|
6991
7136
|
|
|
@@ -7437,12 +7582,12 @@ var init_doctor = __esm({
|
|
|
7437
7582
|
});
|
|
7438
7583
|
|
|
7439
7584
|
// src/repoMemory.ts
|
|
7440
|
-
import { readFileSync as
|
|
7585
|
+
import { readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "fs";
|
|
7441
7586
|
import { join as join26 } from "path";
|
|
7442
7587
|
function loadRememberedRepos(home) {
|
|
7443
7588
|
let raw;
|
|
7444
7589
|
try {
|
|
7445
|
-
raw =
|
|
7590
|
+
raw = readFileSync19(join26(home, FILE), "utf8");
|
|
7446
7591
|
} catch {
|
|
7447
7592
|
return [];
|
|
7448
7593
|
}
|
|
@@ -7713,17 +7858,24 @@ __export(updateCli_exports, {
|
|
|
7713
7858
|
async function runUpdateCli(argv, deps) {
|
|
7714
7859
|
const out = deps.out ?? ((l) => console.log(l));
|
|
7715
7860
|
const err = deps.err ?? ((l) => console.error(l));
|
|
7716
|
-
const
|
|
7717
|
-
const
|
|
7861
|
+
const entry = deps.entry ?? process.argv[1];
|
|
7862
|
+
const pm = deps.globalPm ?? detectGlobalPm(entry);
|
|
7863
|
+
const exec = deps.exec ?? execCaptured;
|
|
7718
7864
|
const latestVersion = deps.latestVersion ?? (() => fetchLatestVersion());
|
|
7719
7865
|
const daemonAlive = deps.daemonAlive ?? (async () => await daemonStatus2() != null);
|
|
7720
7866
|
const force = argv.includes("--force");
|
|
7867
|
+
const launchIO = deps.launchIO;
|
|
7721
7868
|
if (pm === "sources") {
|
|
7722
7869
|
err("\u0442\u044B \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0418\u0417 \u0418\u0421\u0425\u041E\u0414\u041D\u0418\u041A\u041E\u0412 \u043C\u043E\u043D\u043E\u0440\u0435\u043F\u044B, \u0430 \u043D\u0435 \u0438\u0437 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u043D\u043E\u0433\u043E \u043F\u0430\u043A\u0435\u0442\u0430 \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C npm-\u043E\u043C \u0442\u0443\u0442 \u043D\u0435\u0447\u0435\u0433\u043E.");
|
|
7723
7870
|
err(" \u0441\u0432\u0435\u0436\u0438\u0439 \u043A\u043E\u0434 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F: git pull && pnpm install && pnpm --filter @taskless-app/swarm... build");
|
|
7724
7871
|
err(` \u043F\u043E\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0430\u043A\u0435\u0442 \u0440\u044F\u0434\u043E\u043C: ${globalInstallCommand("npm", SWARM_PACKAGE)}`);
|
|
7725
7872
|
return 1;
|
|
7726
7873
|
}
|
|
7874
|
+
const early = gatePackageInstall(pm, `${SWARM_PACKAGE}@latest`, entry, launchIO);
|
|
7875
|
+
if (early.action === "refuse" && early.kind === "npx") {
|
|
7876
|
+
err(early.message);
|
|
7877
|
+
return 1;
|
|
7878
|
+
}
|
|
7727
7879
|
const latest = await latestVersion();
|
|
7728
7880
|
if (latest === null) {
|
|
7729
7881
|
err("\u0434\u043E registry.npmjs.org \u043D\u0435 \u0434\u043E\u0437\u0432\u043E\u043D\u0438\u043B\u0438\u0441\u044C \u2014 \u043A\u0430\u043A\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u0430, \u0443\u0437\u043D\u0430\u0442\u044C \u043D\u0435\u0447\u0435\u043C. \u041F\u0440\u043E\u0432\u0435\u0440\u044C \u0441\u0435\u0442\u044C \u0438 \u043F\u043E\u0432\u0442\u043E\u0440\u0438.");
|
|
@@ -7733,13 +7885,18 @@ async function runUpdateCli(argv, deps) {
|
|
|
7733
7885
|
out(`\u0443\u0436\u0435 \u0441\u0432\u0435\u0436\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F: v${deps.packageVersion} (\u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u0430 v${latest}) \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E.`);
|
|
7734
7886
|
return 0;
|
|
7735
7887
|
}
|
|
7736
|
-
const
|
|
7888
|
+
const decided = gatePackageInstall(pm, `${SWARM_PACKAGE}@${latest}`, entry, launchIO);
|
|
7889
|
+
if (decided.action === "refuse") {
|
|
7890
|
+
err(decided.message);
|
|
7891
|
+
return 1;
|
|
7892
|
+
}
|
|
7893
|
+
const command = decided.command;
|
|
7737
7894
|
out(`\u043E\u0431\u043D\u043E\u0432\u043B\u044F\u044E \u0440\u043E\u0439: v${deps.packageVersion} \u2192 v${latest}`);
|
|
7738
7895
|
out(` $ ${command}`);
|
|
7739
|
-
const
|
|
7740
|
-
if (
|
|
7741
|
-
err(`\u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435 \u043D\u0435 \u043F\u0440\u043E\u0448\u043B\u043E (
|
|
7742
|
-
return
|
|
7896
|
+
const ran = readCommandOutcome(await exec(command));
|
|
7897
|
+
if (ran.exitCode !== 0) {
|
|
7898
|
+
err(`\u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435 \u043D\u0435 \u043F\u0440\u043E\u0448\u043B\u043E (${installFailureLabel(ran.exitCode, ran.output)}). \u0421\u0442\u0440\u043E\u043A\u0430 \u0432\u044B\u0448\u0435 \u2014 \u0442\u0430 \u0441\u0430\u043C\u0430\u044F, \u0447\u0442\u043E \u043D\u0443\u0436\u043D\u0430; \u0432\u044B\u043F\u043E\u043B\u043D\u0438 \u0435\u0451 \u0440\u0443\u043A\u0430\u043C\u0438 \u0438 \u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0438, \u043D\u0430 \u0447\u0451\u043C \u0441\u043F\u043E\u0442\u044B\u043A\u0430\u0435\u0442\u0441\u044F.`);
|
|
7899
|
+
return ran.exitCode;
|
|
7743
7900
|
}
|
|
7744
7901
|
out(`\u0433\u043E\u0442\u043E\u0432\u043E: v${latest}`);
|
|
7745
7902
|
if (await daemonAlive()) {
|
|
@@ -7762,7 +7919,7 @@ var init_updateCli = __esm({
|
|
|
7762
7919
|
// src/cli.ts
|
|
7763
7920
|
init_cliIo();
|
|
7764
7921
|
import { basename as basename6, dirname as dirname5, join as join27 } from "path";
|
|
7765
|
-
import { existsSync as existsSync18, readFileSync as
|
|
7922
|
+
import { existsSync as existsSync18, readFileSync as readFileSync20, writeFileSync as writeFileSync15, mkdirSync as mkdirSync11, readdirSync as readdirSync12, statSync as statSync12, openSync as openSync5, readSync as readSync2, closeSync as closeSync5 } from "fs";
|
|
7766
7923
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
7767
7924
|
|
|
7768
7925
|
// src/swarmClient.ts
|
|
@@ -7798,6 +7955,7 @@ function parsePendingRepoRules(raw) {
|
|
|
7798
7955
|
}
|
|
7799
7956
|
|
|
7800
7957
|
// src/swarmClient.ts
|
|
7958
|
+
init_slugRetry();
|
|
7801
7959
|
init_zoneNotes();
|
|
7802
7960
|
init_store();
|
|
7803
7961
|
init_toolFailure();
|
|
@@ -7838,6 +7996,13 @@ var TAIL_MAX_BYTES_FALLBACK = 64 * 1024;
|
|
|
7838
7996
|
init_src();
|
|
7839
7997
|
var RESOLVER_TERMINAL = /* @__PURE__ */ new Set([...TERMINAL_STATUSES, "stalled"]);
|
|
7840
7998
|
var SLUG_TERMINAL = new Set(TERMINAL_STATUSES);
|
|
7999
|
+
function liveRead(sc, value, absent) {
|
|
8000
|
+
if (sc == null) return null;
|
|
8001
|
+
if (sc.repoAmbiguous) return { value: null, repoAmbiguous: true };
|
|
8002
|
+
const live2 = absent ? { value: null, absent: true, ambiguous: sc.ambiguous === true } : { value, ambiguous: sc.ambiguous === true };
|
|
8003
|
+
if (typeof sc.sharedRepo === "boolean") live2.sharedRepo = sc.sharedRepo;
|
|
8004
|
+
return live2;
|
|
8005
|
+
}
|
|
7841
8006
|
function toolErrorText(res) {
|
|
7842
8007
|
const text = (res?.content ?? []).map((c) => c.text ?? "").join(" ").replace(/\s+/g, " ").trim();
|
|
7843
8008
|
if (!text) return "\u043F\u0440\u043E\u0434 \u043E\u0442\u0432\u0435\u0440\u0433 \u0432\u044B\u0437\u043E\u0432 \u0431\u0435\u0437 \u043E\u0431\u044A\u044F\u0441\u043D\u0435\u043D\u0438\u044F";
|
|
@@ -7974,6 +8139,9 @@ var SwarmClient = class _SwarmClient {
|
|
|
7974
8139
|
// TAS-485: то же для гашения разрешившихся тревог (swarm_notify_resolve) — прод старее
|
|
7975
8140
|
// демона не знает тула; ретраить это каждый тик бессмысленно, см. resolveAnomalies.
|
|
7976
8141
|
notifyResolveUnsupported = false;
|
|
8142
|
+
// TAS-956: момент отказа taskSlug по тулу. Окно и детектор — slugRetry.
|
|
8143
|
+
// Свой экземпляр: отказ этого клиента не общий с makeTasklessClient.
|
|
8144
|
+
slugRetry;
|
|
7977
8145
|
// Корреляция с продом.
|
|
7978
8146
|
keyByLocal = /* @__PURE__ */ new Map();
|
|
7979
8147
|
// local run id → runKey
|
|
@@ -8017,6 +8185,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8017
8185
|
now;
|
|
8018
8186
|
constructor(opts) {
|
|
8019
8187
|
this.now = opts.now ?? Date.now;
|
|
8188
|
+
this.slugRetry = new SlugUnsupportedAt(this.now);
|
|
8020
8189
|
this.call = opts.call;
|
|
8021
8190
|
this.defaultRepo = normalizeRepo(opts.defaultRepo ?? "");
|
|
8022
8191
|
this.autoFlush = opts.autoFlush ?? true;
|
|
@@ -8804,7 +8973,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
8804
8973
|
}
|
|
8805
8974
|
// ── events / хроника ─────────────────────────────────────────────────────────
|
|
8806
8975
|
addEvent(run_id, kind, text, actor = null) {
|
|
8807
|
-
const clean =
|
|
8976
|
+
const clean = sanitizeStoredEventText(text);
|
|
8808
8977
|
const ev = { id: this.nextEventId++, run_id, kind, text: clean, actor: actor ?? null, at: stamp() };
|
|
8809
8978
|
this.eventsLog.push(ev);
|
|
8810
8979
|
if (run_id == null) {
|
|
@@ -9355,17 +9524,12 @@ var SwarmClient = class _SwarmClient {
|
|
|
9355
9524
|
* владельца токена (config=null в ответе) → null: ридер (makeVerifyModeReader) берёт
|
|
9356
9525
|
* env-фолбэк SWARM_VERIFY.
|
|
9357
9526
|
*/
|
|
9358
|
-
async repoVerifyMode(repoFullName) {
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9362
|
-
} catch {
|
|
9363
|
-
return null;
|
|
9364
|
-
}
|
|
9365
|
-
if (res?.isError) return null;
|
|
9366
|
-
const sc = res.structuredContent ?? {};
|
|
9527
|
+
async repoVerifyMode(repoFullName, taskSlug) {
|
|
9528
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9529
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9367
9530
|
const v = sc.config?.verifyMode;
|
|
9368
|
-
|
|
9531
|
+
if (v === "local" || v === "ci") return liveRead(sc, v, false);
|
|
9532
|
+
return liveRead(sc, null, true);
|
|
9369
9533
|
}
|
|
9370
9534
|
/**
|
|
9371
9535
|
* Live БАЗОВАЯ ВЕТКА PR проекта из Taskless (TASWM-285): тот же swarm_repo_config по
|
|
@@ -9374,16 +9538,12 @@ var SwarmClient = class _SwarmClient {
|
|
|
9374
9538
|
* ветку по умолчанию, как раньше. Имя прогоняем через ту же нормализацию, что и прод
|
|
9375
9539
|
* на записи, — мусор из руками-правленого конфига не должен доехать до `git`/`gh`.
|
|
9376
9540
|
*/
|
|
9377
|
-
async repoBaseBranch(repoFullName) {
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
}
|
|
9384
|
-
if (res?.isError) return null;
|
|
9385
|
-
const sc = res.structuredContent ?? {};
|
|
9386
|
-
return normalizeBaseBranch(sc.config?.baseBranch) ?? null;
|
|
9541
|
+
async repoBaseBranch(repoFullName, taskSlug) {
|
|
9542
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9543
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9544
|
+
const branch = normalizeBaseBranch(sc.config?.baseBranch);
|
|
9545
|
+
if (branch) return liveRead(sc, branch, false);
|
|
9546
|
+
return liveRead(sc, null, true);
|
|
9387
9547
|
}
|
|
9388
9548
|
/**
|
|
9389
9549
|
* ПРАВИЛА ОТ ДРОНОВ, ждущие вердикта ревьюера (TASWM-431): их демон кладёт в промпт
|
|
@@ -9394,13 +9554,22 @@ var SwarmClient = class _SwarmClient {
|
|
|
9394
9554
|
* ревью обязано подниматься и без этого блока — правила тут не главное.
|
|
9395
9555
|
*/
|
|
9396
9556
|
async repoPendingRules(repoFullName, taskSlug) {
|
|
9557
|
+
const slug = this.slugFor("swarm_repo_rule_pending", taskSlug);
|
|
9397
9558
|
let res;
|
|
9398
9559
|
try {
|
|
9399
|
-
res = await this.call("swarm_repo_rule_pending", { repoFullName, ...
|
|
9560
|
+
res = await this.call("swarm_repo_rule_pending", { repoFullName, ...slug ? { taskSlug: slug } : {} });
|
|
9400
9561
|
} catch {
|
|
9401
9562
|
return [];
|
|
9402
9563
|
}
|
|
9403
|
-
if (res?.isError)
|
|
9564
|
+
if (res?.isError) {
|
|
9565
|
+
if (!slug) return [];
|
|
9566
|
+
if (!unknownArg(JSON.stringify(res), "taskSlug")) return [];
|
|
9567
|
+
this.slugRetry.note("swarm_repo_rule_pending");
|
|
9568
|
+
console.warn(
|
|
9569
|
+
"[swarm-client] \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0442\u0430\u0440\u0435\u0435 \u0434\u0435\u043C\u043E\u043D\u0430 (swarm_repo_rule_pending \u0431\u0435\u0437 taskSlug) \u2014 \u043F\u0440\u0430\u0432\u0438\u043B\u0430 \u0440\u0435\u0432\u044C\u044E\u0435\u0440\u0430 \u0432\u0440\u0435\u043C\u0435\u043D\u043D\u043E \u0447\u0438\u0442\u0430\u044E\u0442\u0441\u044F \u0431\u0435\u0437 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u0430 \u043F\u0440\u043E\u0433\u043E\u043D\u0430. \u0427\u0435\u0440\u0435\u0437 10 \u043C\u0438\u043D\u0443\u0442 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u044E \u0441\u043B\u0430\u0433 \u0441\u043D\u043E\u0432\u0430."
|
|
9570
|
+
);
|
|
9571
|
+
return this.repoPendingRules(repoFullName);
|
|
9572
|
+
}
|
|
9404
9573
|
const sc = res.structuredContent ?? {};
|
|
9405
9574
|
return parsePendingRepoRules(sc.rules);
|
|
9406
9575
|
}
|
|
@@ -9413,16 +9582,9 @@ var SwarmClient = class _SwarmClient {
|
|
|
9413
9582
|
* Пустая карта — памяти нет / поля в ответе прода нет (прод старее демона) / repo не
|
|
9414
9583
|
* смэплен / прод недоступен. Все четыре случая РАБОЧИЕ: промпт собирается как раньше.
|
|
9415
9584
|
*/
|
|
9416
|
-
async repoZoneMemory(repoFullName) {
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9420
|
-
} catch {
|
|
9421
|
-
return {};
|
|
9422
|
-
}
|
|
9423
|
-
if (res?.isError) return {};
|
|
9424
|
-
const sc = res.structuredContent ?? {};
|
|
9425
|
-
const m = sc.zoneMemory;
|
|
9585
|
+
async repoZoneMemory(repoFullName, taskSlug) {
|
|
9586
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9587
|
+
const m = sc?.zoneMemory;
|
|
9426
9588
|
return m && typeof m === "object" && !Array.isArray(m) ? m : {};
|
|
9427
9589
|
}
|
|
9428
9590
|
/**
|
|
@@ -9433,18 +9595,16 @@ var SwarmClient = class _SwarmClient {
|
|
|
9433
9595
|
* Различаем ТРИ ответа: массив команд (готовить так), ПУСТОЙ массив (осознанное «ничего не
|
|
9434
9596
|
* готовить»), null (настройки нет / прод недоступен / repo не смэплен → демон ищет план сам).
|
|
9435
9597
|
*/
|
|
9436
|
-
async repoPrepare(repoFullName) {
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9440
|
-
} catch {
|
|
9441
|
-
return null;
|
|
9442
|
-
}
|
|
9443
|
-
if (res?.isError) return null;
|
|
9444
|
-
const sc = res.structuredContent ?? {};
|
|
9598
|
+
async repoPrepare(repoFullName, taskSlug) {
|
|
9599
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9600
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9445
9601
|
const prepare = sc.config?.prepare;
|
|
9446
|
-
if (!Array.isArray(prepare)) return null;
|
|
9447
|
-
return
|
|
9602
|
+
if (!Array.isArray(prepare)) return liveRead(sc, null, true);
|
|
9603
|
+
return liveRead(
|
|
9604
|
+
sc,
|
|
9605
|
+
prepare.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()),
|
|
9606
|
+
false
|
|
9607
|
+
);
|
|
9448
9608
|
}
|
|
9449
9609
|
/**
|
|
9450
9610
|
* РАЗМЕТКА репозитория (TASWM-381) из того же swarm_repo_config: зоны, чем поднять
|
|
@@ -9456,16 +9616,9 @@ var SwarmClient = class _SwarmClient {
|
|
|
9456
9616
|
* null — разметки нет (разведка не проходила; РАБОЧЕЕ состояние), репо не смэплено
|
|
9457
9617
|
* на swarm-проект владельца токена или прод недоступен.
|
|
9458
9618
|
*/
|
|
9459
|
-
async repoProfile(repoFullName) {
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9463
|
-
} catch {
|
|
9464
|
-
return null;
|
|
9465
|
-
}
|
|
9466
|
-
if (res?.isError) return null;
|
|
9467
|
-
const sc = res.structuredContent ?? {};
|
|
9468
|
-
const p = sc.profile;
|
|
9619
|
+
async repoProfile(repoFullName, taskSlug) {
|
|
9620
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9621
|
+
const p = sc?.profile;
|
|
9469
9622
|
return p && typeof p === "object" && !Array.isArray(p) ? p : null;
|
|
9470
9623
|
}
|
|
9471
9624
|
// TASWM-441: отправка предложения разведки в прод (`swarm_repo_scout_report`) убрана —
|
|
@@ -9481,18 +9634,16 @@ var SwarmClient = class _SwarmClient {
|
|
|
9481
9634
|
* ПУСТОЙ список (осознанное «ничего не требовать») и null (настройки нет / прод недоступен /
|
|
9482
9635
|
* repo не смэплен → демон берёт детект по репозиторию).
|
|
9483
9636
|
*/
|
|
9484
|
-
async repoRequires(repoFullName) {
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9488
|
-
} catch {
|
|
9489
|
-
return null;
|
|
9490
|
-
}
|
|
9491
|
-
if (res?.isError) return null;
|
|
9492
|
-
const sc = res.structuredContent ?? {};
|
|
9637
|
+
async repoRequires(repoFullName, taskSlug) {
|
|
9638
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9639
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9493
9640
|
const requires = sc.config?.requires;
|
|
9494
|
-
if (!Array.isArray(requires)) return null;
|
|
9495
|
-
return
|
|
9641
|
+
if (!Array.isArray(requires)) return liveRead(sc, null, true);
|
|
9642
|
+
return liveRead(
|
|
9643
|
+
sc,
|
|
9644
|
+
requires.filter((c) => typeof c === "string" && c.trim().length > 0).map((c) => c.trim()),
|
|
9645
|
+
false
|
|
9646
|
+
);
|
|
9496
9647
|
}
|
|
9497
9648
|
/**
|
|
9498
9649
|
* Live ЭКСКЛЮЗИВНОСТЬ прогонов проекта из Taskless (TASWM-314): тот же swarm_repo_config по
|
|
@@ -9502,17 +9653,12 @@ var SwarmClient = class _SwarmClient {
|
|
|
9502
9653
|
* позволял maxDrones. null (прод недоступен / repo не смэплен / поля нет) → ридер
|
|
9503
9654
|
* (makeExclusiveReader) возьмёт false, то есть прежнее поведение.
|
|
9504
9655
|
*/
|
|
9505
|
-
async repoExclusive(repoFullName) {
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9509
|
-
} catch {
|
|
9510
|
-
return null;
|
|
9511
|
-
}
|
|
9512
|
-
if (res?.isError) return null;
|
|
9513
|
-
const sc = res.structuredContent ?? {};
|
|
9656
|
+
async repoExclusive(repoFullName, taskSlug) {
|
|
9657
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9658
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9514
9659
|
const v = sc.config?.exclusive;
|
|
9515
|
-
|
|
9660
|
+
if (typeof v === "boolean") return liveRead(sc, v, false);
|
|
9661
|
+
return liveRead(sc, null, true);
|
|
9516
9662
|
}
|
|
9517
9663
|
/**
|
|
9518
9664
|
* Live КВОТА «дронов на проект» из Taskless (TASWM-365): тот же swarm_repo_config по
|
|
@@ -9522,17 +9668,12 @@ var SwarmClient = class _SwarmClient {
|
|
|
9522
9668
|
* достаёт настройку. null (прод недоступен / repo не смэплен / поля нет / мусор) → ридер
|
|
9523
9669
|
* возьмёт «без ограничения», то есть прежнее поведение.
|
|
9524
9670
|
*/
|
|
9525
|
-
async repoDroneCap(repoFullName) {
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
res = await this.call("swarm_repo_config", { repoFullName });
|
|
9529
|
-
} catch {
|
|
9530
|
-
return null;
|
|
9531
|
-
}
|
|
9532
|
-
if (res?.isError) return null;
|
|
9533
|
-
const sc = res.structuredContent ?? {};
|
|
9671
|
+
async repoDroneCap(repoFullName, taskSlug) {
|
|
9672
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9673
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9534
9674
|
const v = sc.config?.maxDrones;
|
|
9535
|
-
|
|
9675
|
+
if (typeof v === "number" && Number.isFinite(v) && v >= 0) return liveRead(sc, v, false);
|
|
9676
|
+
return liveRead(sc, null, true);
|
|
9536
9677
|
}
|
|
9537
9678
|
/**
|
|
9538
9679
|
* Live АВТОРЕВЬЮ проекта из Taskless (TASWM-355): тот же swarm_repo_config по
|
|
@@ -9543,17 +9684,62 @@ var SwarmClient = class _SwarmClient {
|
|
|
9543
9684
|
* гейту же нужен ответ про КОНКРЕТНЫЙ проект. null (прод недоступен / repo не смэплен /
|
|
9544
9685
|
* поля нет) → ридер (makeAutoReviewReader) возьмёт env, то есть прежнее поведение.
|
|
9545
9686
|
*/
|
|
9546
|
-
async repoAutoReview(repoFullName) {
|
|
9687
|
+
async repoAutoReview(repoFullName, taskSlug) {
|
|
9688
|
+
const sc = await this.repoConfig(repoFullName, taskSlug);
|
|
9689
|
+
if (sc == null || sc.repoAmbiguous) return liveRead(sc, null, false);
|
|
9690
|
+
const v = sc.config?.autoReview;
|
|
9691
|
+
if (typeof v === "boolean") return liveRead(sc, v, false);
|
|
9692
|
+
return liveRead(sc, null, true);
|
|
9693
|
+
}
|
|
9694
|
+
/**
|
|
9695
|
+
* Один вызов swarm_repo_config. taskSlug — пространство прогона; без него прод
|
|
9696
|
+
* при нескольких пространствах отдаёт самое строгое и `ambiguous`. Ошибка
|
|
9697
|
+
* (в том числе repo_ambiguous, если слаг неоднозначен) и недоступность прода
|
|
9698
|
+
* → null: ридер берёт env, как и раньше.
|
|
9699
|
+
*
|
|
9700
|
+
* ОКНО ОТКАТА. Сервер выкатывается первым, но после отката api прод снова
|
|
9701
|
+
* отвергает неизвестный taskSlug целиком (MCP-32) — и рой теряет базовую ветку,
|
|
9702
|
+
* exclusive, prepare, память зон. Такую осечку запоминаем на 10 минут и
|
|
9703
|
+
* повторяем вызов без слага. По истечении окна шлём слаг снова: после обратной
|
|
9704
|
+
* выкатки api второе пространство должно получить свою ветку без рестарта
|
|
9705
|
+
* демона. Обычный отказ (repo_ambiguous) повтором не маскируем.
|
|
9706
|
+
*/
|
|
9707
|
+
async repoConfig(repoFullName, taskSlug) {
|
|
9708
|
+
const slug = this.slugFor("swarm_repo_config", taskSlug);
|
|
9547
9709
|
let res;
|
|
9548
9710
|
try {
|
|
9549
|
-
res = await this.call("swarm_repo_config", {
|
|
9711
|
+
res = await this.call("swarm_repo_config", {
|
|
9712
|
+
repoFullName,
|
|
9713
|
+
...slug ? { taskSlug: slug } : {}
|
|
9714
|
+
});
|
|
9550
9715
|
} catch {
|
|
9551
9716
|
return null;
|
|
9552
9717
|
}
|
|
9553
|
-
if (res?.isError)
|
|
9718
|
+
if (res?.isError) {
|
|
9719
|
+
if (slug && unknownArg(JSON.stringify(res), "taskSlug")) {
|
|
9720
|
+
this.slugRetry.note("swarm_repo_config");
|
|
9721
|
+
console.warn(
|
|
9722
|
+
"[swarm-client] \u0441\u0435\u0440\u0432\u0435\u0440 \u0441\u0442\u0430\u0440\u0435\u0435 \u0434\u0435\u043C\u043E\u043D\u0430 (swarm_repo_config \u0431\u0435\u0437 taskSlug) \u2014 \u043D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438 \u043F\u0440\u043E\u0435\u043A\u0442\u0430 \u0432\u0440\u0435\u043C\u0435\u043D\u043D\u043E \u0447\u0438\u0442\u0430\u044E\u0442\u0441\u044F \u0431\u0435\u0437 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u0430 \u043F\u0440\u043E\u0433\u043E\u043D\u0430. \u0427\u0435\u0440\u0435\u0437 10 \u043C\u0438\u043D\u0443\u0442 \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u044E \u0441\u043B\u0430\u0433 \u0441\u043D\u043E\u0432\u0430."
|
|
9723
|
+
);
|
|
9724
|
+
return this.repoConfig(repoFullName);
|
|
9725
|
+
}
|
|
9726
|
+
if (JSON.stringify(res).includes("repo_ambiguous")) return { repoAmbiguous: true };
|
|
9727
|
+
return null;
|
|
9728
|
+
}
|
|
9554
9729
|
const sc = res.structuredContent ?? {};
|
|
9555
|
-
|
|
9556
|
-
|
|
9730
|
+
if (sc.ambiguous) {
|
|
9731
|
+
console.warn(
|
|
9732
|
+
`[swarm] ${repoFullName}: \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0439 \u0432 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u0438\u0445 \u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u0441\u0442\u0432\u0430\u0445, \u0447\u0438\u0442\u0430\u044E \u0441\u0430\u043C\u043E\u0435 \u0441\u0442\u0440\u043E\u0433\u043E\u0435 (\u043F\u0440\u043E\u0433\u043E\u043D \u0431\u0435\u0437 \u0441\u043B\u0430\u0433\u0430)`
|
|
9733
|
+
);
|
|
9734
|
+
}
|
|
9735
|
+
if (typeof sc.sharedRepo !== "boolean") delete sc.sharedRepo;
|
|
9736
|
+
return sc;
|
|
9737
|
+
}
|
|
9738
|
+
/** Слаг уходит, пока тул его принимает или окно повторной пробы уже вышло. */
|
|
9739
|
+
slugFor(tool, taskSlug) {
|
|
9740
|
+
if (!taskSlug) return void 0;
|
|
9741
|
+
if (this.slugRetry.within(tool)) return void 0;
|
|
9742
|
+
return taskSlug;
|
|
9557
9743
|
}
|
|
9558
9744
|
/**
|
|
9559
9745
|
* TASWM-291: МАШИНЫ роя владельца (swarm_list_hosts) — чтобы `swarm spawn --host
|
|
@@ -10615,7 +10801,7 @@ init_repoRegistry();
|
|
|
10615
10801
|
|
|
10616
10802
|
// src/hostIdentity.ts
|
|
10617
10803
|
import { hostname } from "os";
|
|
10618
|
-
import { existsSync as existsSync9, readFileSync as
|
|
10804
|
+
import { existsSync as existsSync9, readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync7 } from "fs";
|
|
10619
10805
|
import { join as join11 } from "path";
|
|
10620
10806
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
10621
10807
|
function hostIdentityPath(home) {
|
|
@@ -10623,7 +10809,7 @@ function hostIdentityPath(home) {
|
|
|
10623
10809
|
}
|
|
10624
10810
|
function loadHostIdentity(deps) {
|
|
10625
10811
|
const exists = deps.exists ?? existsSync9;
|
|
10626
|
-
const readFile2 = deps.readFile ?? ((p) =>
|
|
10812
|
+
const readFile2 = deps.readFile ?? ((p) => readFileSync9(p, "utf8"));
|
|
10627
10813
|
const writeFile3 = deps.writeFile ?? ((p, data) => {
|
|
10628
10814
|
writeFileSync7(`${p}.tmp`, data);
|
|
10629
10815
|
renameSync4(`${p}.tmp`, p);
|
|
@@ -10953,6 +11139,10 @@ function ghRepoRunner(timeoutMs = GH_CALL_TIMEOUT_MS) {
|
|
|
10953
11139
|
}
|
|
10954
11140
|
var realRunner = ghRunner();
|
|
10955
11141
|
var realRepoRunner = ghRepoRunner();
|
|
11142
|
+
var GH_PR_RE = /^(?:https?:\/\/)?(?:www\.)?github\.com\/[^/\s]+\/[^/\s]+\/pull\/\d+(?:[/?#].*)?$/i;
|
|
11143
|
+
function isGithubPrUrl(url) {
|
|
11144
|
+
return GH_PR_RE.test(url.trim());
|
|
11145
|
+
}
|
|
10956
11146
|
async function openPrsForBranch(branch, repoDir, run = realRepoRunner) {
|
|
10957
11147
|
if (!branch || !repoDir) return [];
|
|
10958
11148
|
try {
|
|
@@ -10963,6 +11153,140 @@ async function openPrsForBranch(branch, repoDir, run = realRepoRunner) {
|
|
|
10963
11153
|
return [];
|
|
10964
11154
|
}
|
|
10965
11155
|
}
|
|
11156
|
+
var FINDING_CATEGORIES = [
|
|
11157
|
+
"correctness",
|
|
11158
|
+
"security",
|
|
11159
|
+
"reuse",
|
|
11160
|
+
"boundaries",
|
|
11161
|
+
"over-abstraction",
|
|
11162
|
+
"duplication",
|
|
11163
|
+
"spine",
|
|
11164
|
+
"tests",
|
|
11165
|
+
"ui-rules"
|
|
11166
|
+
];
|
|
11167
|
+
var FINDING_SEVERITIES = ["blocker", "major", "nit"];
|
|
11168
|
+
var FINDINGS_BLOCK_RE = /```findings[^\n]*\n([\s\S]*?)```/gi;
|
|
11169
|
+
var READ_ONLY_PHRASE_RE = /прогнать не мог|окружения нет/i;
|
|
11170
|
+
var FINDING_WHAT_MAX = 400;
|
|
11171
|
+
var FINDING_PATH_MAX = 300;
|
|
11172
|
+
var FINDINGS_MAX = 50;
|
|
11173
|
+
function oneOf(dict, v) {
|
|
11174
|
+
return typeof v === "string" && dict.includes(v) ? v : null;
|
|
11175
|
+
}
|
|
11176
|
+
function normalizeFinding(raw) {
|
|
11177
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
11178
|
+
const r = raw;
|
|
11179
|
+
const what = typeof r.what === "string" ? r.what.trim().slice(0, FINDING_WHAT_MAX) : "";
|
|
11180
|
+
if (!what) return null;
|
|
11181
|
+
const rawLine = typeof r.line === "number" ? r.line : typeof r.line === "string" && r.line.trim() ? Number(r.line) : NaN;
|
|
11182
|
+
return {
|
|
11183
|
+
category: oneOf(FINDING_CATEGORIES, r.category),
|
|
11184
|
+
severity: oneOf(FINDING_SEVERITIES, r.severity),
|
|
11185
|
+
path: typeof r.path === "string" && r.path.trim() ? r.path.trim().slice(0, FINDING_PATH_MAX) : null,
|
|
11186
|
+
// Номер строки — только целый положительный: «7.5», «-1» и NaN значат, что ревьюер
|
|
11187
|
+
// строку не знал, а не что дефект на строке −1 (по такому числу потом ищут в файле).
|
|
11188
|
+
line: Number.isInteger(rawLine) && rawLine > 0 ? rawLine : null,
|
|
11189
|
+
what
|
|
11190
|
+
};
|
|
11191
|
+
}
|
|
11192
|
+
function parseFindingsBlock(body) {
|
|
11193
|
+
const byPhrase = READ_ONLY_PHRASE_RE.test(body) ? "read" : null;
|
|
11194
|
+
const blocks = [...body.matchAll(FINDINGS_BLOCK_RE)];
|
|
11195
|
+
const last = blocks[blocks.length - 1];
|
|
11196
|
+
if (!last) return { findings: null, mode: byPhrase };
|
|
11197
|
+
let payload;
|
|
11198
|
+
try {
|
|
11199
|
+
payload = JSON.parse(last[1]);
|
|
11200
|
+
} catch {
|
|
11201
|
+
console.warn("[gh] \u0431\u043B\u043E\u043A findings \u0432 \u0432\u0435\u0440\u0434\u0438\u043A\u0442-\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0435 \u043D\u0435 \u0440\u0430\u0437\u043E\u0431\u0440\u0430\u043D (\u0431\u0438\u0442\u044B\u0439 JSON) \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u043D, \u043D\u0430\u0445\u043E\u0434\u043E\u043A \u043D\u0435\u0442");
|
|
11202
|
+
return { findings: null, mode: byPhrase };
|
|
11203
|
+
}
|
|
11204
|
+
const arr = Array.isArray(payload) ? payload : payload && typeof payload === "object" && Array.isArray(payload.findings) ? payload.findings : null;
|
|
11205
|
+
const mode = payload && typeof payload === "object" && !Array.isArray(payload) ? oneOf(["ran", "read"], payload.mode) ?? byPhrase : byPhrase;
|
|
11206
|
+
if (!arr) {
|
|
11207
|
+
console.warn("[gh] \u0431\u043B\u043E\u043A findings \u0432 \u0432\u0435\u0440\u0434\u0438\u043A\u0442-\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0435 \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 \u043C\u0430\u0441\u0441\u0438\u0432\u0430 \u043D\u0430\u0445\u043E\u0434\u043E\u043A \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u043D, \u043D\u0430\u0445\u043E\u0434\u043E\u043A \u043D\u0435\u0442");
|
|
11208
|
+
return { findings: null, mode };
|
|
11209
|
+
}
|
|
11210
|
+
const capped = arr.slice(0, FINDINGS_MAX);
|
|
11211
|
+
if (arr.length > capped.length) {
|
|
11212
|
+
console.warn(`[gh] \u0432 \u0431\u043B\u043E\u043A\u0435 findings ${arr.length} \u0437\u0430\u043F\u0438\u0441\u0435\u0439 \u2014 \u0431\u0435\u0440\u0443 \u043F\u0435\u0440\u0432\u044B\u0435 ${FINDINGS_MAX}, \u043E\u0441\u0442\u0430\u043B\u044C\u043D\u043E\u0435 \u043E\u0442\u0431\u0440\u043E\u0448\u0435\u043D\u043E`);
|
|
11213
|
+
}
|
|
11214
|
+
const findings = capped.map((raw) => normalizeFinding(raw)).filter((f) => f != null);
|
|
11215
|
+
if (findings.length < capped.length) {
|
|
11216
|
+
console.warn("[gh] \u0432 \u0431\u043B\u043E\u043A\u0435 findings \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043E \u0437\u0430\u043F\u0438\u0441\u0435\u0439 \u0431\u0435\u0437 \u0441\u0443\u0442\u0438: " + (capped.length - findings.length));
|
|
11217
|
+
}
|
|
11218
|
+
return { findings, mode };
|
|
11219
|
+
}
|
|
11220
|
+
var realCommentsRunner = (prUrl) => runGh(["pr", "view", prUrl, "--json", "comments"], GH_CALL_TIMEOUT_MS);
|
|
11221
|
+
var CHANGES_FIRST_LINE_RE = new RegExp(
|
|
11222
|
+
[
|
|
11223
|
+
"^#\\d+:\\s*CHANGES\\b",
|
|
11224
|
+
"^#\\d+\\s+\u043A\u0440\u0443\u0433\\s+\\d+\\s*:\\s*CHANGES\\b",
|
|
11225
|
+
"^\u041D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0435 \u0440\u0435\u0432\u044C\u044E\\s*[\u2014\u2013-]\\s*CHANGES\\b",
|
|
11226
|
+
"^(?:\u274C\\s*)?(?:\\*\\*)?REQUEST(?:ED)?\\s+CHANGES(?:\\*\\*)?\\b",
|
|
11227
|
+
"^(?:\\*\\*)?CHANGES(?:\\s+REQUESTED)?(?:\\*\\*)?(?=\\s*(?:$|[:.!(\u2014\u2013-]))",
|
|
11228
|
+
'^[\xAB"]?\u043D\u0443\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u043A\u0438[\xBB"]?(?=\\s*(?:$|[:.!(\u2014\u2013-]))'
|
|
11229
|
+
].join("|"),
|
|
11230
|
+
"iu"
|
|
11231
|
+
);
|
|
11232
|
+
var APPROVE_FIRST_LINE_RE = /^(?:✅\s*)?(?:\*\*)?(?:APPROVED?|LGTM)(?:\*\*)?\b/iu;
|
|
11233
|
+
function firstContentLine(body) {
|
|
11234
|
+
for (const line of body.split(/\r?\n/)) {
|
|
11235
|
+
const trimmed = line.trim();
|
|
11236
|
+
if (trimmed) return trimmed;
|
|
11237
|
+
}
|
|
11238
|
+
return "";
|
|
11239
|
+
}
|
|
11240
|
+
function classifyPrVerdict(body) {
|
|
11241
|
+
const line = firstContentLine(body);
|
|
11242
|
+
if (!line) return null;
|
|
11243
|
+
if (line.includes(DRONE_COMMENT_SIGNATURE)) return null;
|
|
11244
|
+
if (CHANGES_FIRST_LINE_RE.test(line)) return "changes";
|
|
11245
|
+
if (APPROVE_FIRST_LINE_RE.test(line)) return "approve";
|
|
11246
|
+
return null;
|
|
11247
|
+
}
|
|
11248
|
+
async function latestVerdictComment(prUrl, sinceIso, run = realCommentsRunner) {
|
|
11249
|
+
const found = await scanPrComments(prUrl, sinceIso, run, (body) => {
|
|
11250
|
+
const verdict = classifyPrVerdict(body);
|
|
11251
|
+
if (!verdict) return null;
|
|
11252
|
+
const { findings, mode } = parseFindingsBlock(body);
|
|
11253
|
+
return { verdict, findings, reviewMode: mode };
|
|
11254
|
+
});
|
|
11255
|
+
if (!found) return null;
|
|
11256
|
+
return {
|
|
11257
|
+
verdict: found.verdict.verdict,
|
|
11258
|
+
createdAt: found.createdAt,
|
|
11259
|
+
body: found.body,
|
|
11260
|
+
findings: found.verdict.findings,
|
|
11261
|
+
reviewMode: found.verdict.reviewMode
|
|
11262
|
+
};
|
|
11263
|
+
}
|
|
11264
|
+
async function scanPrComments(prUrl, sinceIso, run, pick3) {
|
|
11265
|
+
if (!isGithubPrUrl(prUrl)) return null;
|
|
11266
|
+
let out;
|
|
11267
|
+
try {
|
|
11268
|
+
out = await run(prUrl);
|
|
11269
|
+
} catch {
|
|
11270
|
+
return null;
|
|
11271
|
+
}
|
|
11272
|
+
let j;
|
|
11273
|
+
try {
|
|
11274
|
+
j = JSON.parse(out);
|
|
11275
|
+
} catch {
|
|
11276
|
+
return null;
|
|
11277
|
+
}
|
|
11278
|
+
const comments = Array.isArray(j.comments) ? j.comments : [];
|
|
11279
|
+
const sinceMs = sqliteMs(sinceIso);
|
|
11280
|
+
for (let i = comments.length - 1; i >= 0; i--) {
|
|
11281
|
+
const c = comments[i];
|
|
11282
|
+
if (!c?.body || !c.createdAt) continue;
|
|
11283
|
+
if (Number.isFinite(sinceMs) && Date.parse(c.createdAt) < sinceMs) continue;
|
|
11284
|
+
const verdict = pick3(c.body);
|
|
11285
|
+
if (verdict == null) continue;
|
|
11286
|
+
return { verdict, createdAt: c.createdAt, body: c.body };
|
|
11287
|
+
}
|
|
11288
|
+
return null;
|
|
11289
|
+
}
|
|
10966
11290
|
var NO_CHECKS_STDERR = /no checks reported/i;
|
|
10967
11291
|
var CiAccessDeniedError = class extends Error {
|
|
10968
11292
|
detail;
|
|
@@ -11261,7 +11585,7 @@ function makeMergeGateResolver(deps) {
|
|
|
11261
11585
|
}
|
|
11262
11586
|
function makeMergeGateParts(deps) {
|
|
11263
11587
|
const gateFor = async (run) => {
|
|
11264
|
-
const autoReview = deps.autoReview ? await deps.autoReview(run.repo).catch(() => deps.fallbackAutoReview) : deps.fallbackAutoReview;
|
|
11588
|
+
const autoReview = deps.autoReview ? await deps.autoReview(run.repo, run.task_slug).catch(() => deps.fallbackAutoReview) : deps.fallbackAutoReview;
|
|
11265
11589
|
return computeMergeGate({
|
|
11266
11590
|
hasRun: true,
|
|
11267
11591
|
autoReview,
|
|
@@ -14507,7 +14831,7 @@ async function scoutRepo(repo) {
|
|
|
14507
14831
|
repoFullName,
|
|
14508
14832
|
repoPath: worktree,
|
|
14509
14833
|
name,
|
|
14510
|
-
readFile: (rel) => existsSync18(abs(rel)) ?
|
|
14834
|
+
readFile: (rel) => existsSync18(abs(rel)) ? readFileSync20(abs(rel), "utf8") : null,
|
|
14511
14835
|
writeFile: (rel, text) => {
|
|
14512
14836
|
mkdirSync11(dirname5(abs(rel)), { recursive: true });
|
|
14513
14837
|
writeFileSync15(abs(rel), text);
|
|
@@ -15024,7 +15348,15 @@ switch (cmd) {
|
|
|
15024
15348
|
// иначе побудка codex-прогона при мёртвом демоне теряла продолжаемую сессию.
|
|
15025
15349
|
hasTranscript: (run2) => !!run2.worktree_path && executorForRun(run2, null).session.exists(run2.worktree_path),
|
|
15026
15350
|
respawn: (r, mode, nudge) => respawnRun(
|
|
15027
|
-
{
|
|
15351
|
+
{
|
|
15352
|
+
db,
|
|
15353
|
+
launch,
|
|
15354
|
+
repoFallback: SWARM_REPO,
|
|
15355
|
+
worktreesDir: effectiveWorktreesDir(),
|
|
15356
|
+
getTask: () => Promise.resolve(null),
|
|
15357
|
+
// TASWM-618: тот же фолбэк комментария PR, что у живого демона.
|
|
15358
|
+
verdictComment: (prUrl, sinceIso) => latestVerdictComment(prUrl, sinceIso)
|
|
15359
|
+
},
|
|
15028
15360
|
r,
|
|
15029
15361
|
mode,
|
|
15030
15362
|
nudge
|