@taskless-app/swarm 0.6.80 → 0.6.82
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 +653 -183
- package/dist/overmind.js +1245 -388
- package/package.json +2 -2
package/dist/overmind.js
CHANGED
|
@@ -156,6 +156,7 @@ function verifyVerdictLabel(v) {
|
|
|
156
156
|
function parseVerifyVerdictComment(text) {
|
|
157
157
|
const line = (text ?? "").split("\n").find((l) => l.trim().length > 0);
|
|
158
158
|
if (!line) return null;
|
|
159
|
+
if (line.includes(DRONE_COMMENT_SIGNATURE)) return null;
|
|
159
160
|
let best = null;
|
|
160
161
|
for (const [verdict, marks] of VERDICT_MARKS) {
|
|
161
162
|
for (const mark of marks) {
|
|
@@ -166,7 +167,7 @@ function parseVerifyVerdictComment(text) {
|
|
|
166
167
|
}
|
|
167
168
|
return best?.verdict ?? null;
|
|
168
169
|
}
|
|
169
|
-
var VERIFY_VERDICTS, VERIFY_VERDICT_SET, VERDICT_MARKS;
|
|
170
|
+
var VERIFY_VERDICTS, VERIFY_VERDICT_SET, VERDICT_MARKS, DRONE_COMMENT_SIGNATURE;
|
|
170
171
|
var init_verifyVerdict = __esm({
|
|
171
172
|
"../swarm-core/src/verifyVerdict.ts"() {
|
|
172
173
|
"use strict";
|
|
@@ -177,6 +178,7 @@ var init_verifyVerdict = __esm({
|
|
|
177
178
|
["found_issues", ["\u041D\u0410\u0428\u0401\u041B", "\u041D\u0410\u0428\u0415\u041B", "FOUND"]],
|
|
178
179
|
["confirmed", ["\u041F\u041E\u0414\u0422\u0412\u0415\u0420\u0416\u0414\u0410\u042E", "CONFIRMED"]]
|
|
179
180
|
];
|
|
181
|
+
DRONE_COMMENT_SIGNATURE = "\u{1F41D} \u0414\u0440\u043E\u043D";
|
|
180
182
|
}
|
|
181
183
|
});
|
|
182
184
|
|
|
@@ -720,6 +722,25 @@ var init_modelPolicy = __esm({
|
|
|
720
722
|
roles: { executor: "grok-4.7", review: "grok-4.7-build-fast" },
|
|
721
723
|
models: ["grok-4.7", "grok-4.7-build-fast", "grok-4.6", "grok-4.5"]
|
|
722
724
|
},
|
|
725
|
+
// Kimi Code CLI (Moonshot). Каталог — все 5 моделей из конфига владельца (09.11.2026),
|
|
726
|
+
// полные алиасы как в дефолтном config.toml любого kimi-code: ссылки вида
|
|
727
|
+
// `kimi/kimi-code/k3.1-pro` — parseModelRef режет по первому слэшу, моделью уходит
|
|
728
|
+
// `kimi-code/k3.1-pro` (второй слэш — часть имени). Тарифа нет: подписка, CLI цену не
|
|
729
|
+
// сообщает — честный ноль (costUsd=0 с предупреждением) живёт в адаптере (TASWM-630).
|
|
730
|
+
{
|
|
731
|
+
id: "kimi",
|
|
732
|
+
label: "Kimi (Moonshot)",
|
|
733
|
+
executorId: "kimi",
|
|
734
|
+
selectable: true,
|
|
735
|
+
roles: { executor: "kimi-code/k3.1-pro", review: "kimi-code/k3" },
|
|
736
|
+
models: [
|
|
737
|
+
"kimi-code/kimi-for-coding",
|
|
738
|
+
"kimi-code/k3",
|
|
739
|
+
"kimi-code/k3-256k",
|
|
740
|
+
"kimi-code/k3.1-pro",
|
|
741
|
+
"kimi-code/k3.1-pro-highspeed"
|
|
742
|
+
]
|
|
743
|
+
},
|
|
723
744
|
// TASWM-565 · шаг 1 из четырёх: провайдер в реестре ЕСТЬ, выбрать его ещё нельзя.
|
|
724
745
|
// Имён моделей здесь нет СОЗНАТЕЛЬНО: у владельца подписка, состав моделей в ней нам
|
|
725
746
|
// неизвестен, а выдуманное имя хуже маркера «решает Codex».
|
|
@@ -900,16 +921,30 @@ function sanitizeEventText(text) {
|
|
|
900
921
|
if (!cleaned.length) return null;
|
|
901
922
|
return cleaned.length <= EVENT_TEXT_MAX ? cleaned : clampEventText(cleaned);
|
|
902
923
|
}
|
|
924
|
+
function sanitizeVerdictEventText(text) {
|
|
925
|
+
if (text == null) return null;
|
|
926
|
+
const cleaned = text.replace(ANSI_CSI_RE, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(VERDICT_CONTROL_RE, " ").trim();
|
|
927
|
+
if (!cleaned.length) return null;
|
|
928
|
+
return cleaned.length <= EVENT_TEXT_MAX ? cleaned : clampEventText(cleaned);
|
|
929
|
+
}
|
|
930
|
+
function sanitizeStoredEventText(text) {
|
|
931
|
+
if (typeof text === "string") {
|
|
932
|
+
const head = text.trimStart();
|
|
933
|
+
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);
|
|
934
|
+
}
|
|
935
|
+
return sanitizeEventText(text);
|
|
936
|
+
}
|
|
903
937
|
function clampEventText(text) {
|
|
904
938
|
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)`;
|
|
905
939
|
return text.slice(0, Math.max(0, EVENT_TEXT_MAX - note.length)) + note;
|
|
906
940
|
}
|
|
907
|
-
var ANSI_CSI_RE, CONTROL_CHARS_RE, EVENT_TEXT_MAX;
|
|
941
|
+
var ANSI_CSI_RE, CONTROL_CHARS_RE, VERDICT_CONTROL_RE, EVENT_TEXT_MAX;
|
|
908
942
|
var init_text = __esm({
|
|
909
943
|
"../swarm-core/src/text.ts"() {
|
|
910
944
|
"use strict";
|
|
911
945
|
ANSI_CSI_RE = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
912
946
|
CONTROL_CHARS_RE = /[\x00-\x1f\x7f]/g;
|
|
947
|
+
VERDICT_CONTROL_RE = /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g;
|
|
913
948
|
EVENT_TEXT_MAX = 16e3;
|
|
914
949
|
}
|
|
915
950
|
});
|
|
@@ -3068,6 +3103,179 @@ ${notice}` : spec.prompt;
|
|
|
3068
3103
|
}
|
|
3069
3104
|
});
|
|
3070
3105
|
|
|
3106
|
+
// src/executors/kimi.ts
|
|
3107
|
+
import { copyFileSync as copyFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync6, readFileSync as readFileSync4, statSync as statSync5, symlinkSync as symlinkSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
3108
|
+
import { join as join8 } from "path";
|
|
3109
|
+
function resolveKimiBin(env = process.env) {
|
|
3110
|
+
return (env.SWARM_KIMI_BIN ?? "").trim() || "kimi";
|
|
3111
|
+
}
|
|
3112
|
+
function kimiHomePath(worktree, swarmHome = SWARM_HOME) {
|
|
3113
|
+
const key = worktree.replace(/[^A-Za-z0-9]+/g, "-").replace(/^-|-$/g, "") || "worktree";
|
|
3114
|
+
return join8(swarmHome, "executor-state", "kimi", key);
|
|
3115
|
+
}
|
|
3116
|
+
function kimiSessionRoot(worktree, swarmHome = SWARM_HOME) {
|
|
3117
|
+
return join8(kimiHomePath(worktree, swarmHome), "sessions");
|
|
3118
|
+
}
|
|
3119
|
+
function newestKimiSessionMtime(dir, depth = 4) {
|
|
3120
|
+
let entries;
|
|
3121
|
+
try {
|
|
3122
|
+
entries = readdirSync6(dir, { withFileTypes: true });
|
|
3123
|
+
} catch {
|
|
3124
|
+
return null;
|
|
3125
|
+
}
|
|
3126
|
+
let latest = null;
|
|
3127
|
+
for (const entry of entries) {
|
|
3128
|
+
const full = join8(dir, entry.name);
|
|
3129
|
+
try {
|
|
3130
|
+
if (entry.isDirectory()) {
|
|
3131
|
+
if (depth <= 0) continue;
|
|
3132
|
+
const nested = newestKimiSessionMtime(full, depth - 1);
|
|
3133
|
+
if (nested != null && (latest == null || nested > latest)) latest = nested;
|
|
3134
|
+
} else if (entry.isFile()) {
|
|
3135
|
+
const mtime2 = statSync5(full).mtimeMs;
|
|
3136
|
+
if (latest == null || mtime2 > latest) latest = mtime2;
|
|
3137
|
+
}
|
|
3138
|
+
} catch {
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
return latest;
|
|
3142
|
+
}
|
|
3143
|
+
function extractModelsBlocks(config) {
|
|
3144
|
+
const lines = config.split(/\r?\n/);
|
|
3145
|
+
const blocks = [];
|
|
3146
|
+
let current = null;
|
|
3147
|
+
for (const line of lines) {
|
|
3148
|
+
if (/^\s*\[/.test(line)) {
|
|
3149
|
+
if (current) blocks.push(current);
|
|
3150
|
+
current = /^\s*\[models\./.test(line) ? [line] : null;
|
|
3151
|
+
continue;
|
|
3152
|
+
}
|
|
3153
|
+
if (current) current.push(line);
|
|
3154
|
+
}
|
|
3155
|
+
if (current) blocks.push(current);
|
|
3156
|
+
return blocks.map((b) => b.join("\n").trimEnd()).filter((b) => b.trim() !== "");
|
|
3157
|
+
}
|
|
3158
|
+
function kimiMcpJson(spec) {
|
|
3159
|
+
return JSON.stringify(
|
|
3160
|
+
{ mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
|
|
3161
|
+
null,
|
|
3162
|
+
2
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
function ensureKimiHome(worktree, realHome, env = process.env, swarmHome = SWARM_HOME) {
|
|
3166
|
+
const home = kimiHomePath(worktree, swarmHome);
|
|
3167
|
+
mkdirSync5(home, { recursive: true });
|
|
3168
|
+
const realCreds = join8((env.KIMI_CODE_HOME ?? "").trim() || join8(realHome, ".kimi-code"), "credentials");
|
|
3169
|
+
const link2 = join8(home, "credentials");
|
|
3170
|
+
if (existsSync6(realCreds) && !existsSync6(link2)) {
|
|
3171
|
+
try {
|
|
3172
|
+
symlinkSync3(realCreds, link2, "junction");
|
|
3173
|
+
} catch {
|
|
3174
|
+
try {
|
|
3175
|
+
mkdirSync5(link2, { recursive: true });
|
|
3176
|
+
for (const f of readdirSync6(realCreds)) copyFileSync4(join8(realCreds, f), join8(link2, f));
|
|
3177
|
+
} catch {
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
const realConfig = join8((env.KIMI_CODE_HOME ?? "").trim() || join8(realHome, ".kimi-code"), "config.toml");
|
|
3182
|
+
try {
|
|
3183
|
+
const blocks = extractModelsBlocks(readFileSync4(realConfig, "utf8"));
|
|
3184
|
+
if (blocks.length > 0) writeFileSync5(join8(home, "config.toml"), `${blocks.join("\n\n")}
|
|
3185
|
+
`);
|
|
3186
|
+
} catch {
|
|
3187
|
+
}
|
|
3188
|
+
return home;
|
|
3189
|
+
}
|
|
3190
|
+
function modelArgs2(model) {
|
|
3191
|
+
if (!model || isHarnessDefaultModel(model)) return [];
|
|
3192
|
+
return ["-m", model];
|
|
3193
|
+
}
|
|
3194
|
+
function parseKimiResult(raw) {
|
|
3195
|
+
const trimmed = raw.trim();
|
|
3196
|
+
if (!trimmed) return null;
|
|
3197
|
+
let lastAssistant = null;
|
|
3198
|
+
let sawEvent = false;
|
|
3199
|
+
for (const line of trimmed.split(/\r?\n/)) {
|
|
3200
|
+
const s = line.trim();
|
|
3201
|
+
if (!s) continue;
|
|
3202
|
+
let parsed;
|
|
3203
|
+
try {
|
|
3204
|
+
parsed = JSON.parse(s);
|
|
3205
|
+
} catch {
|
|
3206
|
+
continue;
|
|
3207
|
+
}
|
|
3208
|
+
if (typeof parsed !== "object" || parsed === null) continue;
|
|
3209
|
+
sawEvent = true;
|
|
3210
|
+
const rec = parsed;
|
|
3211
|
+
if (rec.role === "assistant" && typeof rec.content === "string") lastAssistant = rec.content;
|
|
3212
|
+
}
|
|
3213
|
+
if (!sawEvent || lastAssistant === null) return null;
|
|
3214
|
+
return {
|
|
3215
|
+
costUsd: 0,
|
|
3216
|
+
warning: "kimi: CLI \u0441\u0442\u043E\u0438\u043C\u043E\u0441\u0442\u044C \u043D\u0435 \u0441\u043E\u043E\u0431\u0449\u0430\u0435\u0442 (\u043F\u043E\u0434\u043F\u0438\u0441\u043A\u0430) \u2014 \u044D\u0442\u043E \u043D\u0435 \u043D\u043E\u043B\u044C \u0432 \u0441\u043C\u044B\u0441\u043B\u0435 \u0431\u0435\u0441\u043F\u043B\u0430\u0442\u043D\u043E"
|
|
3217
|
+
};
|
|
3218
|
+
}
|
|
3219
|
+
var kimiExecutor;
|
|
3220
|
+
var init_kimi = __esm({
|
|
3221
|
+
"src/executors/kimi.ts"() {
|
|
3222
|
+
"use strict";
|
|
3223
|
+
init_src();
|
|
3224
|
+
init_swarmHome();
|
|
3225
|
+
init_swarmFiles();
|
|
3226
|
+
kimiExecutor = {
|
|
3227
|
+
id: "kimi",
|
|
3228
|
+
title: "Kimi Code CLI (kimi)",
|
|
3229
|
+
binEnv: "SWARM_KIMI_BIN",
|
|
3230
|
+
install: {
|
|
3231
|
+
what: "Kimi Code CLI (Moonshot). \u041E\u0444\u0438\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u0449\u0438\u043A \u0441 code.kimi.com \u2014 \u041D\u0415 npm-\u043F\u0430\u043A\u0435\u0442 kimi-code (\u044D\u0442\u043E \u0447\u0443\u0436\u043E\u0439 \u043F\u0440\u043E\u043A\u0441\u0438-\u0432\u0440\u0430\u043F\u043F\u0435\u0440).",
|
|
3232
|
+
pkg: "kimi-code",
|
|
3233
|
+
command: "curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash",
|
|
3234
|
+
windowsCommand: "irm https://code.kimi.com/kimi-code/install.ps1 | iex"
|
|
3235
|
+
},
|
|
3236
|
+
resolveBin: (env) => resolveKimiBin(env ?? process.env),
|
|
3237
|
+
plan: (spec) => {
|
|
3238
|
+
const home = ensureKimiHome(spec.worktree, spec.realHome);
|
|
3239
|
+
writeFileSync5(join8(home, "mcp.json"), kimiMcpJson(spec));
|
|
3240
|
+
writeFileSync5(
|
|
3241
|
+
join8(spec.worktree, SWARM_MCP_CONFIG_FILE),
|
|
3242
|
+
JSON.stringify(
|
|
3243
|
+
{ mcpServers: { [spec.mcp.name]: { command: spec.mcp.command, args: spec.mcp.args, env: spec.mcp.env } } },
|
|
3244
|
+
null,
|
|
3245
|
+
2
|
|
3246
|
+
)
|
|
3247
|
+
);
|
|
3248
|
+
const args = [
|
|
3249
|
+
// `--add-dir` стоит первым: настоящий флаг kimi, по нему реконсайл узнаёт
|
|
3250
|
+
// worktree живого процесса после рестарта демона (worktreeFromKimiCmd).
|
|
3251
|
+
"--add-dir",
|
|
3252
|
+
spec.worktree,
|
|
3253
|
+
"--output-format",
|
|
3254
|
+
"stream-json",
|
|
3255
|
+
...spec.skillDirs.flatMap((dir) => ["--skills-dir", dir]),
|
|
3256
|
+
...spec.continueSession ? ["--continue"] : [],
|
|
3257
|
+
...modelArgs2(spec.model),
|
|
3258
|
+
"-p",
|
|
3259
|
+
spec.prompt
|
|
3260
|
+
];
|
|
3261
|
+
return { bin: resolveKimiBin(), args, env: { KIMI_CODE_HOME: home } };
|
|
3262
|
+
},
|
|
3263
|
+
parseResult(raw) {
|
|
3264
|
+
return parseKimiResult(raw);
|
|
3265
|
+
},
|
|
3266
|
+
session: {
|
|
3267
|
+
exists: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree)) !== null,
|
|
3268
|
+
mtimeMs: (worktree) => newestKimiSessionMtime(kimiSessionRoot(worktree))
|
|
3269
|
+
},
|
|
3270
|
+
probe: {
|
|
3271
|
+
args: ["-p", "ok", "--output-format", "stream-json"],
|
|
3272
|
+
limitPattern: /usage limit|quota|rate.limit|too many requests/i,
|
|
3273
|
+
authPattern: /use \/login to sign in|not logged in|unauthorized|\b401\b|authentication required/i
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
}
|
|
3277
|
+
});
|
|
3278
|
+
|
|
3071
3279
|
// src/liveModels.ts
|
|
3072
3280
|
import { execFile } from "child_process";
|
|
3073
3281
|
function parseGrokDefaultModel(out) {
|
|
@@ -3195,16 +3403,19 @@ var init_executors = __esm({
|
|
|
3195
3403
|
init_claudeCode();
|
|
3196
3404
|
init_codex();
|
|
3197
3405
|
init_grok();
|
|
3406
|
+
init_kimi();
|
|
3198
3407
|
init_swarmModels();
|
|
3199
3408
|
init_types2();
|
|
3200
3409
|
init_claudeCode();
|
|
3201
3410
|
init_codex();
|
|
3202
3411
|
init_grok();
|
|
3412
|
+
init_kimi();
|
|
3203
3413
|
DEFAULT_EXECUTOR_ID = "claude-code";
|
|
3204
3414
|
EXECUTORS = {
|
|
3205
3415
|
[claudeCodeExecutor.id]: claudeCodeExecutor,
|
|
3206
3416
|
[codexExecutor.id]: codexExecutor,
|
|
3207
|
-
[grokExecutor.id]: grokExecutor
|
|
3417
|
+
[grokExecutor.id]: grokExecutor,
|
|
3418
|
+
[kimiExecutor.id]: kimiExecutor
|
|
3208
3419
|
};
|
|
3209
3420
|
}
|
|
3210
3421
|
});
|
|
@@ -3311,8 +3522,8 @@ __export(config_exports, {
|
|
|
3311
3522
|
restEndpoint: () => restEndpoint,
|
|
3312
3523
|
reviewCutoffAt: () => reviewCutoffAt
|
|
3313
3524
|
});
|
|
3314
|
-
import { basename, join as
|
|
3315
|
-
import { readFileSync as
|
|
3525
|
+
import { basename, join as join9, resolve } from "path";
|
|
3526
|
+
import { readFileSync as readFileSync5, realpathSync, renameSync as renameSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
3316
3527
|
function normalizeRepo(repo) {
|
|
3317
3528
|
const r = (repo ?? "").trim();
|
|
3318
3529
|
if (!r) return "";
|
|
@@ -3326,10 +3537,10 @@ function effectiveRepoOf(repo, fallback) {
|
|
|
3326
3537
|
return normalizeRepo(repo || fallback || "");
|
|
3327
3538
|
}
|
|
3328
3539
|
function droneWorktreePath(worktreesDir, repo, slug) {
|
|
3329
|
-
return
|
|
3540
|
+
return join9(droneWorktreeRoot(worktreesDir, repo), slug);
|
|
3330
3541
|
}
|
|
3331
3542
|
function droneWorktreeRoot(worktreesDir, repo) {
|
|
3332
|
-
return
|
|
3543
|
+
return join9(worktreesDir, basename(normalizeRepo(repo)));
|
|
3333
3544
|
}
|
|
3334
3545
|
function resolveEffectiveWorktreesDir(deps) {
|
|
3335
3546
|
if (deps.envOverride) return deps.envOverride;
|
|
@@ -3377,21 +3588,21 @@ function mcpEndpoint(api, path = TASKLESS_MCP_PATH) {
|
|
|
3377
3588
|
}
|
|
3378
3589
|
function tokenFromFile() {
|
|
3379
3590
|
try {
|
|
3380
|
-
return
|
|
3591
|
+
return readFileSync5(join9(SWARM_HOME, "token"), "utf8").trim();
|
|
3381
3592
|
} catch {
|
|
3382
3593
|
return "";
|
|
3383
3594
|
}
|
|
3384
3595
|
}
|
|
3385
3596
|
function reviewCutoffAt() {
|
|
3386
3597
|
try {
|
|
3387
|
-
const raw = JSON.parse(
|
|
3598
|
+
const raw = JSON.parse(readFileSync5(REVIEW_CUTOFF_PATH, "utf8"));
|
|
3388
3599
|
if (raw.at) return raw.at;
|
|
3389
3600
|
} catch {
|
|
3390
3601
|
}
|
|
3391
3602
|
const at = stamp();
|
|
3392
3603
|
try {
|
|
3393
3604
|
const tmp = `${REVIEW_CUTOFF_PATH}.tmp`;
|
|
3394
|
-
|
|
3605
|
+
writeFileSync6(tmp, JSON.stringify({ at }));
|
|
3395
3606
|
renameSync2(tmp, REVIEW_CUTOFF_PATH);
|
|
3396
3607
|
} catch {
|
|
3397
3608
|
}
|
|
@@ -3405,25 +3616,25 @@ var init_config = __esm({
|
|
|
3405
3616
|
init_executors();
|
|
3406
3617
|
init_swarmHome();
|
|
3407
3618
|
init_swarmHome();
|
|
3408
|
-
DB_PATH = process.env.SWARM_DB ||
|
|
3619
|
+
DB_PATH = process.env.SWARM_DB || join9(SWARM_HOME, "swarm.db");
|
|
3409
3620
|
EXECUTOR = resolveExecutor(process.env.SWARM_EXECUTOR);
|
|
3410
|
-
DRONE_HOME = process.env.SWARM_DRONE_HOME ||
|
|
3621
|
+
DRONE_HOME = process.env.SWARM_DRONE_HOME || join9(SWARM_HOME, "drone-home");
|
|
3411
3622
|
DRONE_HOME_ISOLATION = process.env.SWARM_DRONE_ISOLATE_HOME !== "0" && process.platform !== "win32";
|
|
3412
3623
|
DRONE_ISOLATION = DRONE_HOME_ISOLATION ? { home: DRONE_HOME, swarmHome: SWARM_HOME } : void 0;
|
|
3413
|
-
WORKTREES_NOINDEX_DIR =
|
|
3414
|
-
WORKTREES_LEGACY_DIR =
|
|
3624
|
+
WORKTREES_NOINDEX_DIR = join9(SWARM_HOME, "worktrees.noindex");
|
|
3625
|
+
WORKTREES_LEGACY_DIR = join9(SWARM_HOME, "worktrees");
|
|
3415
3626
|
WORKTREES_DIR = process.env.SWARM_WORKTREES || WORKTREES_NOINDEX_DIR;
|
|
3416
|
-
RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS ||
|
|
3417
|
-
DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG ||
|
|
3627
|
+
RUN_LOGS_DIR = process.env.SWARM_RUN_LOGS || join9(SWARM_HOME, "run-logs");
|
|
3628
|
+
DAEMON_LOG_PATH = process.env.SWARM_DAEMON_LOG || join9(SWARM_HOME, "overmind.log");
|
|
3418
3629
|
DAEMON_LOG_MAX_BYTES = envNum("SWARM_DAEMON_LOG_MAX_BYTES", 16 * 1024 * 1024);
|
|
3419
3630
|
DAEMON_LOG_KEEP = envNum("SWARM_DAEMON_LOG_KEEP", 2);
|
|
3420
3631
|
DAEMON_LOG_CHECK_MS = envNum("SWARM_DAEMON_LOG_CHECK_MS", 6e4);
|
|
3421
3632
|
DIST_BUILD = true;
|
|
3422
3633
|
SWARM_BACKEND = process.env.SWARM_BACKEND === "client" ? "client" : process.env.SWARM_BACKEND === "sqlite" ? "sqlite" : DIST_BUILD ? "client" : "sqlite";
|
|
3423
|
-
SWARM_OUTBOX = process.env.SWARM_OUTBOX ||
|
|
3634
|
+
SWARM_OUTBOX = process.env.SWARM_OUTBOX || join9(SWARM_HOME, "outbox.jsonl");
|
|
3424
3635
|
SWARM_MAX_IN_FLIGHT = Math.trunc(envNum("SWARM_MAX_IN_FLIGHT", 3));
|
|
3425
3636
|
SWARM_CLAIM_INTERVAL_MS = envNum("SWARM_CLAIM_INTERVAL_MS", 6e4);
|
|
3426
|
-
ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR ||
|
|
3637
|
+
ENV_CACHE_DIR = process.env.SWARM_ENV_CACHE_DIR || join9(SWARM_HOME, "env-cache");
|
|
3427
3638
|
ENV_CACHE_ENABLED = process.env.SWARM_ENV_CACHE !== "0";
|
|
3428
3639
|
ENV_CACHE_KEEP = Math.trunc(envNum("SWARM_ENV_CACHE_KEEP", 4));
|
|
3429
3640
|
SWARM_MAX_LOAD_FACTOR = envNum("SWARM_MAX_LOAD_FACTOR", 0.9);
|
|
@@ -3453,15 +3664,15 @@ var init_config = __esm({
|
|
|
3453
3664
|
DRONE_CHANNEL_ENABLED = process.env.SWARM_DRONE_CHANNEL !== "0";
|
|
3454
3665
|
DRONE_CHANNEL_PORT = Number(process.env.SWARM_DRONE_CHANNEL_PORT) || 7421;
|
|
3455
3666
|
DRONE_CHANNEL_URL = process.env.SWARM_DRONE_CHANNEL_URL || `http://127.0.0.1:${DRONE_CHANNEL_PORT}`;
|
|
3456
|
-
DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET ||
|
|
3667
|
+
DRONE_CHANNEL_SECRET_PATH = process.env.SWARM_DRONE_CHANNEL_SECRET || join9(SWARM_HOME, "drone-channel.key");
|
|
3457
3668
|
DRONE_CHANNEL_GRACE_MS = envNum("SWARM_DRONE_CHANNEL_GRACE_MS", 12e4);
|
|
3458
|
-
HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT ||
|
|
3669
|
+
HEARTBEAT_PATH = process.env.SWARM_HEARTBEAT || join9(SWARM_HOME, "overmind.heartbeat");
|
|
3459
3670
|
HEARTBEAT_STALE_MS = Number(process.env.SWARM_HEARTBEAT_STALE_MS) || 3e4;
|
|
3460
3671
|
SWARM_REPO = process.env.SWARM_REPO || "";
|
|
3461
3672
|
SWARM_SCAN_DEPTH = Number(process.env.SWARM_SCAN_DEPTH) || 3;
|
|
3462
3673
|
SWARM_REPO_PATHS = (process.env.SWARM_REPOS || SWARM_REPO).split(",").map((s) => s.trim()).filter(Boolean);
|
|
3463
3674
|
SWARM_SCAN_ROOTS_RAW = process.env.SWARM_SCAN_ROOTS || "";
|
|
3464
|
-
REPO_MAP_PATH = process.env.SWARM_REPO_MAP ||
|
|
3675
|
+
REPO_MAP_PATH = process.env.SWARM_REPO_MAP || join9(SWARM_HOME, "repo-map.json");
|
|
3465
3676
|
SWARM_REPO_MAP_MS = envNum("SWARM_REPO_MAP_MS", 15 * 6e4);
|
|
3466
3677
|
SWARM_REPO_SCAN_TTL_MS = envNum("SWARM_REPO_SCAN_TTL_MS", 24 * 60 * 6e4);
|
|
3467
3678
|
TASKLESS_API = process.env.TASKLESS_API || "https://taskless.ru";
|
|
@@ -3476,7 +3687,7 @@ var init_config = __esm({
|
|
|
3476
3687
|
SWARM_AUTO_REVIEW = process.env.SWARM_AUTO_REVIEW !== "0";
|
|
3477
3688
|
SWARM_AUTO_VERIFY = process.env.SWARM_AUTO_VERIFY !== "0";
|
|
3478
3689
|
SWARM_MERGE_QUEUE = process.env.SWARM_MERGE_QUEUE !== "0";
|
|
3479
|
-
REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF ||
|
|
3690
|
+
REVIEW_CUTOFF_PATH = process.env.SWARM_REVIEW_CUTOFF || join9(SWARM_HOME, "review-cutoff.json");
|
|
3480
3691
|
SWARM_REVIEW_CAP = Math.trunc(envNum("SWARM_REVIEW_CAP", 1));
|
|
3481
3692
|
SWARM_STORM_URL = process.env.SWARM_STORM_URL || "";
|
|
3482
3693
|
WEB_PORT = Number(process.env.SWARM_WEB_PORT) || 7420;
|
|
@@ -3516,7 +3727,7 @@ var init_quietExec = __esm({
|
|
|
3516
3727
|
|
|
3517
3728
|
// src/resources.ts
|
|
3518
3729
|
import os from "os";
|
|
3519
|
-
import { readFileSync as
|
|
3730
|
+
import { readFileSync as readFileSync6, statfsSync } from "fs";
|
|
3520
3731
|
function isTransientResourceError(e) {
|
|
3521
3732
|
const code = e?.code;
|
|
3522
3733
|
return code === "ENFILE" || code === "EMFILE" || code === "EAGAIN";
|
|
@@ -3574,7 +3785,7 @@ function fileDescriptorLoadRatio() {
|
|
|
3574
3785
|
}
|
|
3575
3786
|
if (process.platform === "linux") {
|
|
3576
3787
|
try {
|
|
3577
|
-
const [allocated, , max] =
|
|
3788
|
+
const [allocated, , max] = readFileSync6("/proc/sys/fs/file-nr", "utf8").trim().split(/\s+/).map(Number);
|
|
3578
3789
|
if (Number.isFinite(allocated ?? NaN) && Number.isFinite(max ?? NaN) && max) return allocated / max;
|
|
3579
3790
|
} catch {
|
|
3580
3791
|
}
|
|
@@ -4027,11 +4238,11 @@ var init_store = __esm({
|
|
|
4027
4238
|
});
|
|
4028
4239
|
|
|
4029
4240
|
// src/agentToken.ts
|
|
4030
|
-
import { readFileSync as
|
|
4031
|
-
import { join as
|
|
4241
|
+
import { readFileSync as readFileSync7, writeFileSync as writeFileSync7, unlinkSync as unlinkSync2 } from "fs";
|
|
4242
|
+
import { join as join10 } from "path";
|
|
4032
4243
|
function loadAgentToken() {
|
|
4033
4244
|
try {
|
|
4034
|
-
const s = JSON.parse(
|
|
4245
|
+
const s = JSON.parse(readFileSync7(STORE_PATH, "utf8"));
|
|
4035
4246
|
return s.token ? s : null;
|
|
4036
4247
|
} catch {
|
|
4037
4248
|
return null;
|
|
@@ -4084,7 +4295,7 @@ var init_agentToken = __esm({
|
|
|
4084
4295
|
"src/agentToken.ts"() {
|
|
4085
4296
|
"use strict";
|
|
4086
4297
|
init_config();
|
|
4087
|
-
STORE_PATH =
|
|
4298
|
+
STORE_PATH = join10(SWARM_HOME, "agent.json");
|
|
4088
4299
|
base = (api) => api.replace(/\/$/, "");
|
|
4089
4300
|
TOKEN_PROBE_TIMEOUT_MS = 8e3;
|
|
4090
4301
|
}
|
|
@@ -4198,15 +4409,15 @@ var init_toolFailure = __esm({
|
|
|
4198
4409
|
});
|
|
4199
4410
|
|
|
4200
4411
|
// src/heartbeat.ts
|
|
4201
|
-
import { readFileSync as
|
|
4412
|
+
import { readFileSync as readFileSync9, renameSync as renameSync4, writeFileSync as writeFileSync9 } from "fs";
|
|
4202
4413
|
function writeHeartbeat(path, now) {
|
|
4203
4414
|
const tmp = `${path}.tmp`;
|
|
4204
|
-
|
|
4415
|
+
writeFileSync9(tmp, String(now));
|
|
4205
4416
|
renameSync4(tmp, path);
|
|
4206
4417
|
}
|
|
4207
4418
|
function readHeartbeat(path) {
|
|
4208
4419
|
try {
|
|
4209
|
-
const ms = Number(
|
|
4420
|
+
const ms = Number(readFileSync9(path, "utf8").trim());
|
|
4210
4421
|
return Number.isFinite(ms) ? ms : null;
|
|
4211
4422
|
} catch {
|
|
4212
4423
|
return null;
|
|
@@ -4374,6 +4585,7 @@ var init_netTimeout = __esm({
|
|
|
4374
4585
|
});
|
|
4375
4586
|
|
|
4376
4587
|
// src/procList.ts
|
|
4588
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
4377
4589
|
function parsePsRows(out) {
|
|
4378
4590
|
const rows = [];
|
|
4379
4591
|
for (const line of out.split("\n")) {
|
|
@@ -4462,13 +4674,56 @@ function taskkillTree(pid, opts = {}) {
|
|
|
4462
4674
|
return false;
|
|
4463
4675
|
}
|
|
4464
4676
|
}
|
|
4465
|
-
|
|
4677
|
+
function realClkTck() {
|
|
4678
|
+
if (cachedClkTck != null) return cachedClkTck;
|
|
4679
|
+
let tck = 100;
|
|
4680
|
+
try {
|
|
4681
|
+
const n = Number(execQuiet("getconf", ["CLK_TCK"]).trim());
|
|
4682
|
+
if (Number.isInteger(n) && n > 0) tck = n;
|
|
4683
|
+
} catch {
|
|
4684
|
+
}
|
|
4685
|
+
cachedClkTck = tck;
|
|
4686
|
+
return tck;
|
|
4687
|
+
}
|
|
4688
|
+
function parseEtimeSec(out) {
|
|
4689
|
+
const m = /^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/.exec(out.trim());
|
|
4690
|
+
if (!m) return null;
|
|
4691
|
+
const [, d, h, min, s] = m;
|
|
4692
|
+
return Number(d ?? 0) * 86400 + Number(h ?? 0) * 3600 + Number(min) * 60 + Number(s);
|
|
4693
|
+
}
|
|
4694
|
+
function processStartedAt(pid, opts = {}) {
|
|
4695
|
+
const platform = opts.platform ?? process.platform;
|
|
4696
|
+
if (!Number.isInteger(pid) || pid <= 0 || platform === "win32") return null;
|
|
4697
|
+
if (platform === "linux") {
|
|
4698
|
+
const readFile2 = opts.readFile ?? ((p) => readFileSync16(p, "utf8"));
|
|
4699
|
+
try {
|
|
4700
|
+
const stat2 = readFile2(`/proc/${pid}/stat`);
|
|
4701
|
+
const ticks = Number(stat2.slice(stat2.lastIndexOf(")") + 1).trim().split(/\s+/)[19]);
|
|
4702
|
+
const btime = Number(/^btime\s+(\d+)$/m.exec(readFile2("/proc/stat"))?.[1]);
|
|
4703
|
+
const tck = (opts.clkTck ?? realClkTck)();
|
|
4704
|
+
if (!Number.isFinite(ticks) || !Number.isFinite(btime) || !(tck > 0)) return null;
|
|
4705
|
+
return Math.round((btime + ticks / tck) * 1e3);
|
|
4706
|
+
} catch {
|
|
4707
|
+
return null;
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4710
|
+
const exec = opts.exec ?? ((file, args) => execQuiet(file, args));
|
|
4711
|
+
try {
|
|
4712
|
+
const sec = parseEtimeSec(exec("ps", ["-o", "etime=", "-p", String(pid)]));
|
|
4713
|
+
if (sec == null) return null;
|
|
4714
|
+
return (opts.now ?? Date.now)() - sec * 1e3;
|
|
4715
|
+
} catch {
|
|
4716
|
+
return null;
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
var WIN_PS_COMMAND, cachedClkTck;
|
|
4466
4720
|
var init_procList = __esm({
|
|
4467
4721
|
"src/procList.ts"() {
|
|
4468
4722
|
"use strict";
|
|
4469
4723
|
init_quietExec();
|
|
4470
4724
|
init_resources();
|
|
4471
4725
|
WIN_PS_COMMAND = "Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine | ConvertTo-Json -Depth 2 -Compress";
|
|
4726
|
+
cachedClkTck = null;
|
|
4472
4727
|
}
|
|
4473
4728
|
});
|
|
4474
4729
|
|
|
@@ -4692,9 +4947,9 @@ var init_procCleanup = __esm({
|
|
|
4692
4947
|
});
|
|
4693
4948
|
|
|
4694
4949
|
// src/git.ts
|
|
4695
|
-
import { existsSync as
|
|
4950
|
+
import { existsSync as existsSync14, readdirSync as readdirSync14, realpathSync as realpathSync2, statSync as statSync12 } from "fs";
|
|
4696
4951
|
import { appendFile, chmod, mkdir, readFile, rename, rm, writeFile } from "fs/promises";
|
|
4697
|
-
import { isAbsolute as isAbsolute3, join as
|
|
4952
|
+
import { isAbsolute as isAbsolute3, join as join23, resolve as resolve3, sep as sep2 } from "path";
|
|
4698
4953
|
import { $ as $2 } from "execa";
|
|
4699
4954
|
function gitNet(repo, args, timeoutMs) {
|
|
4700
4955
|
return withHardTimeout(
|
|
@@ -4716,14 +4971,14 @@ async function reclaimStaleWorktree(repo, worktree) {
|
|
|
4716
4971
|
await detachWorktree(repo, worktree);
|
|
4717
4972
|
}
|
|
4718
4973
|
async function inspectWorktreePath(path) {
|
|
4719
|
-
if (!
|
|
4974
|
+
if (!existsSync14(path)) return "free";
|
|
4720
4975
|
try {
|
|
4721
|
-
if (
|
|
4976
|
+
if (readdirSync14(path).length === 0) return "free";
|
|
4722
4977
|
} catch {
|
|
4723
4978
|
return "orphan";
|
|
4724
4979
|
}
|
|
4725
4980
|
try {
|
|
4726
|
-
if (
|
|
4981
|
+
if (statSync12(join23(path, ".git")).isDirectory()) return "main-checkout";
|
|
4727
4982
|
} catch {
|
|
4728
4983
|
}
|
|
4729
4984
|
const top = await $2({ reject: false })`git -C ${path} rev-parse --show-toplevel`;
|
|
@@ -4762,7 +5017,7 @@ async function clearWorktreePath(repo, path, branch, opts = {}) {
|
|
|
4762
5017
|
await detachWorktree(repo, path);
|
|
4763
5018
|
opts.onStaleReclaim?.(path);
|
|
4764
5019
|
}
|
|
4765
|
-
if (!
|
|
5020
|
+
if (!existsSync14(path)) return;
|
|
4766
5021
|
await parkOrphanDir(repo, path, branch);
|
|
4767
5022
|
}
|
|
4768
5023
|
async function parkOrphanDir(repo, path, branch) {
|
|
@@ -4783,7 +5038,7 @@ async function parkOrphanDir(repo, path, branch) {
|
|
|
4783
5038
|
}
|
|
4784
5039
|
function isLinkedWorktree(dir) {
|
|
4785
5040
|
try {
|
|
4786
|
-
return
|
|
5041
|
+
return statSync12(join23(dir, ".git")).isFile();
|
|
4787
5042
|
} catch {
|
|
4788
5043
|
return false;
|
|
4789
5044
|
}
|
|
@@ -4795,7 +5050,7 @@ async function detachWorktree(repo, worktree) {
|
|
|
4795
5050
|
}
|
|
4796
5051
|
}
|
|
4797
5052
|
async function ensureWorktreeDirGone(worktree) {
|
|
4798
|
-
if (!
|
|
5053
|
+
if (!existsSync14(worktree)) return false;
|
|
4799
5054
|
if (!isLinkedWorktree(worktree)) {
|
|
4800
5055
|
console.error(
|
|
4801
5056
|
`[git] ${worktree} \u2014 \u043D\u0435 \u043F\u0440\u0438\u0441\u0442\u0451\u0433\u043D\u0443\u0442\u044B\u0439 worktree (.git \u043D\u0435 \u0444\u0430\u0439\u043B): \u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u041D\u0415 \u0442\u0440\u043E\u0433\u0430\u044E. \u0415\u0441\u043B\u0438 \u044D\u0442\u043E \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E worktree \u0434\u0440\u043E\u043D\u0430 \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0435\u0433\u043E \u0440\u0443\u043A\u0430\u043C\u0438; \u0435\u0441\u043B\u0438 \u044D\u0442\u043E \u043E\u0441\u043D\u043E\u0432\u043D\u043E\u0439 \u0447\u0435\u043A\u0430\u0443\u0442, \u0437\u043D\u0430\u0447\u0438\u0442 \u0432\u0435\u0442\u043A\u0430 \u0441\u043B\u0430\u0433\u0430 \u0447\u0435\u043A\u043D\u0443\u0442\u0430 \u0432 \u043D\u0451\u043C (git checkout <slug>) \u2014 \u043F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u0435 \u0435\u0433\u043E \u043D\u0430 \u0434\u0440\u0443\u0433\u0443\u044E \u0432\u0435\u0442\u043A\u0443.`
|
|
@@ -4810,7 +5065,7 @@ async function ensureWorktreeDirGone(worktree) {
|
|
|
4810
5065
|
);
|
|
4811
5066
|
return true;
|
|
4812
5067
|
}
|
|
4813
|
-
if (
|
|
5068
|
+
if (existsSync14(worktree)) {
|
|
4814
5069
|
console.error(`[git] \u043A\u0430\u0442\u0430\u043B\u043E\u0433 worktree ${worktree} \u043F\u0435\u0440\u0435\u0436\u0438\u043B rm \u2014 \u0443\u0431\u0435\u0440\u0438\u0442\u0435 \u0440\u0443\u043A\u0430\u043C\u0438, \u0438\u043D\u0430\u0447\u0435 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439 \u0441\u043F\u0430\u0432\u043D \u0441\u043B\u0430\u0433\u0430 \u0432\u0441\u0442\u0430\u043D\u0435\u0442.`);
|
|
4815
5070
|
}
|
|
4816
5071
|
return true;
|
|
@@ -4859,7 +5114,7 @@ async function checkoutWorktree(repo, path, branch, opts) {
|
|
|
4859
5114
|
}
|
|
4860
5115
|
const busyAt = await worktreeForBranch(repo, branch);
|
|
4861
5116
|
if (busyAt) {
|
|
4862
|
-
const exists =
|
|
5117
|
+
const exists = existsSync14(busyAt);
|
|
4863
5118
|
const live2 = exists && (opts.isWorktreeHeldLive ? await opts.isWorktreeHeldLive(busyAt) : true);
|
|
4864
5119
|
if (live2) throw new WorktreeBusyError(branch, busyAt);
|
|
4865
5120
|
if (exists && await worktreeDirty(busyAt)) throw new WorktreeBusyError(branch, busyAt);
|
|
@@ -4895,8 +5150,8 @@ async function ensureGitExcluded(worktree, pattern) {
|
|
|
4895
5150
|
try {
|
|
4896
5151
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
4897
5152
|
if (!commonDir) return false;
|
|
4898
|
-
const infoDir =
|
|
4899
|
-
const excludeFile =
|
|
5153
|
+
const infoDir = join23(commonDir, "info");
|
|
5154
|
+
const excludeFile = join23(infoDir, "exclude");
|
|
4900
5155
|
let current = "";
|
|
4901
5156
|
try {
|
|
4902
5157
|
current = await readFile(excludeFile, "utf8");
|
|
@@ -4916,7 +5171,7 @@ async function gitPath(worktree, flag) {
|
|
|
4916
5171
|
const out = await $2({ reject: false })`git -C ${worktree} rev-parse ${flag}`;
|
|
4917
5172
|
const raw = out.stdout.trim();
|
|
4918
5173
|
if (out.exitCode !== 0 || !raw) return null;
|
|
4919
|
-
return isAbsolute3(raw) ? raw :
|
|
5174
|
+
return isAbsolute3(raw) ? raw : join23(worktree, raw);
|
|
4920
5175
|
}
|
|
4921
5176
|
async function ensureWorktreeHygiene(worktree) {
|
|
4922
5177
|
for (const pattern of SWARM_EXCLUDE_PATTERNS) await ensureGitExcluded(worktree, pattern);
|
|
@@ -4926,12 +5181,12 @@ async function installGuardHooks(worktree) {
|
|
|
4926
5181
|
try {
|
|
4927
5182
|
const gitDir = await gitPath(worktree, "--git-dir");
|
|
4928
5183
|
if (!gitDir) return false;
|
|
4929
|
-
const hooksDir =
|
|
5184
|
+
const hooksDir = join23(gitDir, "swarm-hooks");
|
|
4930
5185
|
const prev = await previousHooksPath(worktree);
|
|
4931
5186
|
await mkdir(hooksDir, { recursive: true });
|
|
4932
5187
|
for (const hook of GUARD_HOOKS) {
|
|
4933
|
-
await writeFile(
|
|
4934
|
-
await chmod(
|
|
5188
|
+
await writeFile(join23(hooksDir, hook), guardHookScript(hook, prev ? `${posix(prev)}/${hook}` : null));
|
|
5189
|
+
await chmod(join23(hooksDir, hook), 493);
|
|
4935
5190
|
}
|
|
4936
5191
|
await $2`git -C ${worktree} config extensions.worktreeConfig true`;
|
|
4937
5192
|
await $2`git -C ${worktree} config --worktree core.hooksPath ${posix(hooksDir)}`;
|
|
@@ -4950,7 +5205,7 @@ async function previousHooksPath(worktree) {
|
|
|
4950
5205
|
if (out.exitCode === 0 && value) return value;
|
|
4951
5206
|
}
|
|
4952
5207
|
const commonDir = await gitPath(worktree, "--git-common-dir");
|
|
4953
|
-
return commonDir ?
|
|
5208
|
+
return commonDir ? join23(commonDir, "hooks") : null;
|
|
4954
5209
|
}
|
|
4955
5210
|
async function removeWorktree(repo, path) {
|
|
4956
5211
|
const branch = (await $2({ reject: false })`git -C ${path} symbolic-ref --quiet --short HEAD`).stdout.trim();
|
|
@@ -4975,7 +5230,7 @@ async function worktreeDirty(path) {
|
|
|
4975
5230
|
async function repairMovedWorktrees(targetDir) {
|
|
4976
5231
|
const subdirs = (dir) => {
|
|
4977
5232
|
try {
|
|
4978
|
-
return
|
|
5233
|
+
return readdirSync14(dir, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => join23(dir, d.name));
|
|
4979
5234
|
} catch {
|
|
4980
5235
|
return [];
|
|
4981
5236
|
}
|
|
@@ -5112,18 +5367,18 @@ __export(droneChannel_exports, {
|
|
|
5112
5367
|
verifyLocalCliToken: () => verifyLocalCliToken
|
|
5113
5368
|
});
|
|
5114
5369
|
import { createHmac, randomBytes, timingSafeEqual } from "crypto";
|
|
5115
|
-
import { chmodSync as chmodSync2, mkdirSync as
|
|
5370
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync14 } from "fs";
|
|
5116
5371
|
import { dirname as dirname5 } from "path";
|
|
5117
5372
|
import { serve } from "@hono/node-server";
|
|
5118
5373
|
function loadChannelSecret(path) {
|
|
5119
5374
|
try {
|
|
5120
|
-
const s =
|
|
5375
|
+
const s = readFileSync21(path, "utf8").trim();
|
|
5121
5376
|
if (s.length >= 32) return s;
|
|
5122
5377
|
} catch {
|
|
5123
5378
|
}
|
|
5124
5379
|
const secret = randomBytes(32).toString("hex");
|
|
5125
|
-
|
|
5126
|
-
|
|
5380
|
+
mkdirSync12(dirname5(path), { recursive: true });
|
|
5381
|
+
writeFileSync14(path, secret, { mode: 384 });
|
|
5127
5382
|
try {
|
|
5128
5383
|
chmodSync2(path, 384);
|
|
5129
5384
|
} catch {
|
|
@@ -5513,7 +5768,7 @@ var init_droneChannel = __esm({
|
|
|
5513
5768
|
|
|
5514
5769
|
// src/attachments.ts
|
|
5515
5770
|
import { mkdir as mkdir3, rm as rm3, writeFile as writeFile3 } from "fs/promises";
|
|
5516
|
-
import { join as
|
|
5771
|
+
import { join as join28 } from "path";
|
|
5517
5772
|
function attachmentsFromDoc(doc, origin) {
|
|
5518
5773
|
const out = [];
|
|
5519
5774
|
const walk2 = (node) => {
|
|
@@ -5604,7 +5859,7 @@ async function materializeAttachments(opts) {
|
|
|
5604
5859
|
};
|
|
5605
5860
|
const result = { files: [], skipped: [] };
|
|
5606
5861
|
if (opts.refs.length === 0) return result;
|
|
5607
|
-
const dir =
|
|
5862
|
+
const dir = join28(opts.worktree, ATTACHMENTS_DIR);
|
|
5608
5863
|
await io.removeDir(dir);
|
|
5609
5864
|
let dirReady = false;
|
|
5610
5865
|
let total = 0;
|
|
@@ -5650,7 +5905,7 @@ async function materializeAttachments(opts) {
|
|
|
5650
5905
|
await io.mkdir(dir);
|
|
5651
5906
|
dirReady = true;
|
|
5652
5907
|
}
|
|
5653
|
-
await io.writeFile(
|
|
5908
|
+
await io.writeFile(join28(dir, name), file.bytes);
|
|
5654
5909
|
} catch (e) {
|
|
5655
5910
|
result.skipped.push(`${label2} \u2014 \u043D\u0435 \u0437\u0430\u043F\u0438\u0441\u0430\u043B\u043E\u0441\u044C \u043D\u0430 \u0434\u0438\u0441\u043A (${errText2(e)})`);
|
|
5656
5911
|
continue;
|
|
@@ -5803,7 +6058,7 @@ var init_attachments = __esm({
|
|
|
5803
6058
|
|
|
5804
6059
|
// src/shotUpload.ts
|
|
5805
6060
|
import { readFile as fsReadFile } from "fs/promises";
|
|
5806
|
-
import { basename as basename4, isAbsolute as isAbsolute4, join as
|
|
6061
|
+
import { basename as basename4, isAbsolute as isAbsolute4, join as join29 } from "path";
|
|
5807
6062
|
function shotMimetype(path) {
|
|
5808
6063
|
const dot = path.lastIndexOf(".");
|
|
5809
6064
|
if (dot < 0) return null;
|
|
@@ -5829,7 +6084,7 @@ async function readShots(paths, opts) {
|
|
|
5829
6084
|
}
|
|
5830
6085
|
let bytes;
|
|
5831
6086
|
try {
|
|
5832
|
-
bytes = await read(isAbsolute4(path) ? path :
|
|
6087
|
+
bytes = await read(isAbsolute4(path) ? path : join29(opts.worktree, path));
|
|
5833
6088
|
} catch (e) {
|
|
5834
6089
|
skipped.push({ path, reason: `\u043D\u0435 \u043F\u0440\u043E\u0447\u0438\u0442\u0430\u043D: ${e instanceof Error ? e.message : String(e)}` });
|
|
5835
6090
|
continue;
|
|
@@ -5910,8 +6165,8 @@ var init_shotUpload = __esm({
|
|
|
5910
6165
|
|
|
5911
6166
|
// src/oauth.ts
|
|
5912
6167
|
import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
|
|
5913
|
-
import { readFileSync as
|
|
5914
|
-
import { join as
|
|
6168
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync15, unlinkSync as unlinkSync4 } from "fs";
|
|
6169
|
+
import { join as join30 } from "path";
|
|
5915
6170
|
function makePkce() {
|
|
5916
6171
|
const verifier = randomBytes2(48).toString("base64url");
|
|
5917
6172
|
const challenge = createHash3("sha256").update(verifier).digest("base64url");
|
|
@@ -5995,13 +6250,13 @@ function toStore(clientId, t, now) {
|
|
|
5995
6250
|
}
|
|
5996
6251
|
function loadStore() {
|
|
5997
6252
|
try {
|
|
5998
|
-
return JSON.parse(
|
|
6253
|
+
return JSON.parse(readFileSync22(STORE_PATH2, "utf8"));
|
|
5999
6254
|
} catch {
|
|
6000
6255
|
return null;
|
|
6001
6256
|
}
|
|
6002
6257
|
}
|
|
6003
6258
|
function saveStore(s) {
|
|
6004
|
-
|
|
6259
|
+
writeFileSync15(STORE_PATH2, JSON.stringify(s, null, 2), { mode: 384 });
|
|
6005
6260
|
}
|
|
6006
6261
|
function clearStore() {
|
|
6007
6262
|
try {
|
|
@@ -6011,7 +6266,7 @@ function clearStore() {
|
|
|
6011
6266
|
}
|
|
6012
6267
|
function loadClientId() {
|
|
6013
6268
|
try {
|
|
6014
|
-
return JSON.parse(
|
|
6269
|
+
return JSON.parse(readFileSync22(CLIENT_PATH, "utf8")).clientId;
|
|
6015
6270
|
} catch {
|
|
6016
6271
|
return null;
|
|
6017
6272
|
}
|
|
@@ -6020,7 +6275,7 @@ async function ensureClientId(api, redirectUri, fetchFn = fetch) {
|
|
|
6020
6275
|
const existing = loadClientId();
|
|
6021
6276
|
if (existing) return existing;
|
|
6022
6277
|
const clientId = await registerClient({ api, redirectUri }, fetchFn);
|
|
6023
|
-
|
|
6278
|
+
writeFileSync15(CLIENT_PATH, JSON.stringify({ clientId }, null, 2), { mode: 384 });
|
|
6024
6279
|
return clientId;
|
|
6025
6280
|
}
|
|
6026
6281
|
async function ensureAccess(store, opts = {}) {
|
|
@@ -6046,8 +6301,8 @@ var init_oauth = __esm({
|
|
|
6046
6301
|
AUTHORIZE = "/api/oauth/authorize";
|
|
6047
6302
|
TOKEN = "/api/oauth/token";
|
|
6048
6303
|
SCOPE = "openid profile email taskless:full";
|
|
6049
|
-
STORE_PATH2 =
|
|
6050
|
-
CLIENT_PATH =
|
|
6304
|
+
STORE_PATH2 = join30(SWARM_HOME, "oauth.json");
|
|
6305
|
+
CLIENT_PATH = join30(SWARM_HOME, "oauth-client.json");
|
|
6051
6306
|
base2 = (api) => api.replace(/\/$/, "");
|
|
6052
6307
|
}
|
|
6053
6308
|
});
|
|
@@ -6134,11 +6389,11 @@ var init_authState = __esm({
|
|
|
6134
6389
|
});
|
|
6135
6390
|
|
|
6136
6391
|
// src/workspace.ts
|
|
6137
|
-
import { readFileSync as
|
|
6138
|
-
import { join as
|
|
6392
|
+
import { readFileSync as readFileSync23, writeFileSync as writeFileSync16, unlinkSync as unlinkSync5 } from "fs";
|
|
6393
|
+
import { join as join31 } from "path";
|
|
6139
6394
|
function loadWorkspace() {
|
|
6140
6395
|
try {
|
|
6141
|
-
const w = JSON.parse(
|
|
6396
|
+
const w = JSON.parse(readFileSync23(WORKSPACE_PATH, "utf8"));
|
|
6142
6397
|
return w && typeof w.id === "string" && w.id ? w : null;
|
|
6143
6398
|
} catch {
|
|
6144
6399
|
return null;
|
|
@@ -6152,7 +6407,7 @@ var init_workspace = __esm({
|
|
|
6152
6407
|
"src/workspace.ts"() {
|
|
6153
6408
|
"use strict";
|
|
6154
6409
|
init_config();
|
|
6155
|
-
WORKSPACE_PATH =
|
|
6410
|
+
WORKSPACE_PATH = join31(SWARM_HOME, "workspace.json");
|
|
6156
6411
|
}
|
|
6157
6412
|
});
|
|
6158
6413
|
|
|
@@ -6792,7 +7047,7 @@ __export(db_exports, {
|
|
|
6792
7047
|
});
|
|
6793
7048
|
import { createRequire as createRequire2 } from "module";
|
|
6794
7049
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
6795
|
-
import { existsSync as
|
|
7050
|
+
import { existsSync as existsSync18 } from "fs";
|
|
6796
7051
|
import { resolve as resolve4 } from "path";
|
|
6797
7052
|
function rowToQuestion(row) {
|
|
6798
7053
|
return {
|
|
@@ -7456,7 +7711,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
7456
7711
|
const repoN = normalizeRepo(repo);
|
|
7457
7712
|
const already = this.db.prepare("SELECT run_count FROM imports WHERE source = ?").get(abs);
|
|
7458
7713
|
if (already) return { imported: false, runs: already.run_count };
|
|
7459
|
-
if (!
|
|
7714
|
+
if (!existsSync18(abs)) throw new Error(`import-db: \u0444\u0430\u0439\u043B\u0430 \u043D\u0435\u0442: ${abs}`);
|
|
7460
7715
|
const src = new this.databaseCtor(abs);
|
|
7461
7716
|
try {
|
|
7462
7717
|
const runs = src.prepare("SELECT * FROM runs ORDER BY id").all();
|
|
@@ -7621,7 +7876,7 @@ CREATE TABLE IF NOT EXISTS imports (
|
|
|
7621
7876
|
}
|
|
7622
7877
|
// --- events (лог/хроника) ---
|
|
7623
7878
|
addEvent(run_id, kind, text, actor = null) {
|
|
7624
|
-
const clean =
|
|
7879
|
+
const clean = sanitizeStoredEventText(text);
|
|
7625
7880
|
const insert = () => this.db.prepare("INSERT INTO events (run_id, kind, text, actor) VALUES (?, ?, ?, ?)").run(run_id, kind, clean, actor);
|
|
7626
7881
|
try {
|
|
7627
7882
|
insert();
|
|
@@ -7826,8 +8081,8 @@ var init_droneStore = __esm({
|
|
|
7826
8081
|
|
|
7827
8082
|
// src/overmind.ts
|
|
7828
8083
|
import { homedir as homedir7 } from "os";
|
|
7829
|
-
import { existsSync as
|
|
7830
|
-
import { basename as basename6, dirname as dirname6, join as
|
|
8084
|
+
import { existsSync as existsSync23, readFileSync as readFileSync27, readdirSync as readdirSync16, renameSync as renameSync12, statSync as statSync15 } from "fs";
|
|
8085
|
+
import { basename as basename6, dirname as dirname6, join as join38 } from "path";
|
|
7831
8086
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
7832
8087
|
import { spawn as spawn4 } from "child_process";
|
|
7833
8088
|
|
|
@@ -7907,7 +8162,7 @@ init_config();
|
|
|
7907
8162
|
init_resources();
|
|
7908
8163
|
init_names2();
|
|
7909
8164
|
init_storm();
|
|
7910
|
-
import { appendFileSync, existsSync as
|
|
8165
|
+
import { appendFileSync, existsSync as existsSync9, mkdirSync as mkdirSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "fs";
|
|
7911
8166
|
import { dirname as dirname2 } from "path";
|
|
7912
8167
|
import { randomUUID } from "crypto";
|
|
7913
8168
|
|
|
@@ -7966,12 +8221,12 @@ init_store();
|
|
|
7966
8221
|
init_toolFailure();
|
|
7967
8222
|
|
|
7968
8223
|
// src/logTail.ts
|
|
7969
|
-
import { closeSync, existsSync as
|
|
7970
|
-
import { join as
|
|
8224
|
+
import { closeSync, existsSync as existsSync8, openSync, readSync, readdirSync as readdirSync8, statSync as statSync7 } from "fs";
|
|
8225
|
+
import { join as join12 } from "path";
|
|
7971
8226
|
|
|
7972
8227
|
// src/runLogDir.ts
|
|
7973
|
-
import { existsSync as
|
|
7974
|
-
import { join as
|
|
8228
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync7, readdirSync as readdirSync7, renameSync as renameSync3, statSync as statSync6 } from "fs";
|
|
8229
|
+
import { join as join11 } from "path";
|
|
7975
8230
|
var LEGACY_RUN_LOGS_SUBDIR = "legacy";
|
|
7976
8231
|
function runLogDirName(runLogKey) {
|
|
7977
8232
|
const safe2 = runLogKey.replace(/[^A-Za-z0-9_-]+/g, "-").replace(/^[-_]+|[-_]+$/g, "");
|
|
@@ -7979,12 +8234,12 @@ function runLogDirName(runLogKey) {
|
|
|
7979
8234
|
return /^\d+$/.test(safe2) ? `k-${safe2}` : safe2;
|
|
7980
8235
|
}
|
|
7981
8236
|
function runLogDirPath(runLogsDir, runLogKey) {
|
|
7982
|
-
return
|
|
8237
|
+
return join11(runLogsDir, runLogDirName(runLogKey));
|
|
7983
8238
|
}
|
|
7984
8239
|
function findRunLogDir(runLogsDir, keys) {
|
|
7985
8240
|
for (const key of keys) {
|
|
7986
8241
|
const dir = runLogDirPath(runLogsDir, key);
|
|
7987
|
-
if (
|
|
8242
|
+
if (existsSync7(dir)) return dir;
|
|
7988
8243
|
}
|
|
7989
8244
|
return null;
|
|
7990
8245
|
}
|
|
@@ -7994,10 +8249,10 @@ function runLogDirForWrite(runLogsDir, keys) {
|
|
|
7994
8249
|
return findRunLogDir(runLogsDir, keys) ?? runLogDirPath(runLogsDir, canonical);
|
|
7995
8250
|
}
|
|
7996
8251
|
function sweepLegacyRunLogs(runLogsDir) {
|
|
7997
|
-
const legacyDir =
|
|
8252
|
+
const legacyDir = join11(runLogsDir, LEGACY_RUN_LOGS_SUBDIR);
|
|
7998
8253
|
let entries;
|
|
7999
8254
|
try {
|
|
8000
|
-
entries =
|
|
8255
|
+
entries = readdirSync7(runLogsDir);
|
|
8001
8256
|
} catch {
|
|
8002
8257
|
return { moved: 0, failed: 0, legacyDir };
|
|
8003
8258
|
}
|
|
@@ -8005,12 +8260,12 @@ function sweepLegacyRunLogs(runLogsDir) {
|
|
|
8005
8260
|
let failed = 0;
|
|
8006
8261
|
for (const name of entries) {
|
|
8007
8262
|
if (!/^\d+$/.test(name)) continue;
|
|
8008
|
-
const from =
|
|
8263
|
+
const from = join11(runLogsDir, name);
|
|
8009
8264
|
try {
|
|
8010
|
-
if (!
|
|
8011
|
-
|
|
8012
|
-
let to =
|
|
8013
|
-
for (let n = 2;
|
|
8265
|
+
if (!statSync6(from).isDirectory()) continue;
|
|
8266
|
+
mkdirSync7(legacyDir, { recursive: true });
|
|
8267
|
+
let to = join11(legacyDir, name);
|
|
8268
|
+
for (let n = 2; existsSync7(to) && n < 100; n++) to = join11(legacyDir, `${name}-${n}`);
|
|
8014
8269
|
renameSync3(from, to);
|
|
8015
8270
|
moved++;
|
|
8016
8271
|
} catch {
|
|
@@ -8030,7 +8285,7 @@ function fileHeader(name, size, shown) {
|
|
|
8030
8285
|
function readTail(path, opts) {
|
|
8031
8286
|
let size;
|
|
8032
8287
|
try {
|
|
8033
|
-
size =
|
|
8288
|
+
size = statSync7(path).size;
|
|
8034
8289
|
} catch {
|
|
8035
8290
|
return null;
|
|
8036
8291
|
}
|
|
@@ -8065,7 +8320,7 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
|
|
|
8065
8320
|
if (!dir) return null;
|
|
8066
8321
|
let files;
|
|
8067
8322
|
try {
|
|
8068
|
-
files =
|
|
8323
|
+
files = readdirSync8(dir);
|
|
8069
8324
|
} catch {
|
|
8070
8325
|
return null;
|
|
8071
8326
|
}
|
|
@@ -8076,8 +8331,8 @@ function latestRunLaunch(runLogsDir, runLogKeys) {
|
|
|
8076
8331
|
}
|
|
8077
8332
|
if (indexes.size === 0) return null;
|
|
8078
8333
|
const index = Math.max(...indexes);
|
|
8079
|
-
const out = [
|
|
8080
|
-
const err =
|
|
8334
|
+
const out = [join12(dir, `${index}.json`), join12(dir, `${index}.json.done`)].find((p) => existsSync8(p)) ?? null;
|
|
8335
|
+
const err = existsSync8(join12(dir, `${index}.err.log`)) ? join12(dir, `${index}.err.log`) : null;
|
|
8081
8336
|
return { index, total: indexes.size, out, err };
|
|
8082
8337
|
}
|
|
8083
8338
|
function runLogTail(runLogsDir, runLogKeys, opts) {
|
|
@@ -8358,26 +8613,26 @@ var SwarmClient = class _SwarmClient {
|
|
|
8358
8613
|
this.repoFullNames = registry.map((e) => e.repoFullName);
|
|
8359
8614
|
this.repoPathByFullName = new Map(registry.map((e) => [e.repoFullName, normalizeRepo(e.path)]));
|
|
8360
8615
|
this.host = opts.host ?? null;
|
|
8361
|
-
this.repoExists = opts.repoExists ??
|
|
8616
|
+
this.repoExists = opts.repoExists ?? existsSync9;
|
|
8362
8617
|
this.questionSyncMs = opts.questionSyncMs ?? 3e3;
|
|
8363
8618
|
this.executorId = opts.executorId ?? EXECUTOR.id;
|
|
8364
8619
|
this.outboxPath = opts.outboxPath;
|
|
8365
8620
|
this.mapPath = `${opts.outboxPath}.prodmap.json`;
|
|
8366
8621
|
this.stormPath = `${opts.outboxPath}.storm.jsonl`;
|
|
8367
|
-
|
|
8622
|
+
mkdirSync8(dirname2(this.outboxPath), { recursive: true });
|
|
8368
8623
|
this.recover();
|
|
8369
8624
|
}
|
|
8370
8625
|
// ── рестарт: поднять outbox (незаписанные операции) и карту runKey→prodId ─────
|
|
8371
8626
|
recover() {
|
|
8372
|
-
if (
|
|
8627
|
+
if (existsSync9(this.mapPath)) {
|
|
8373
8628
|
try {
|
|
8374
|
-
const obj = JSON.parse(
|
|
8629
|
+
const obj = JSON.parse(readFileSync8(this.mapPath, "utf8"));
|
|
8375
8630
|
for (const [k, v] of Object.entries(obj)) this.prodIdByKey.set(k, v);
|
|
8376
8631
|
} catch {
|
|
8377
8632
|
}
|
|
8378
8633
|
}
|
|
8379
|
-
if (
|
|
8380
|
-
const txt =
|
|
8634
|
+
if (existsSync9(this.outboxPath)) {
|
|
8635
|
+
const txt = readFileSync8(this.outboxPath, "utf8");
|
|
8381
8636
|
for (const line of txt.split("\n")) {
|
|
8382
8637
|
const s = line.trim();
|
|
8383
8638
|
if (!s) continue;
|
|
@@ -8397,10 +8652,10 @@ var SwarmClient = class _SwarmClient {
|
|
|
8397
8652
|
// eventsLog ПЕРВЫМИ (до hydrate), в порядке файла (= хронологический); id
|
|
8398
8653
|
// переприсваиваем локально (id событий — только порядок, не корреляция с продом).
|
|
8399
8654
|
replayGlobalEvents() {
|
|
8400
|
-
if (!
|
|
8655
|
+
if (!existsSync9(this.stormPath)) return;
|
|
8401
8656
|
let txt;
|
|
8402
8657
|
try {
|
|
8403
|
-
txt =
|
|
8658
|
+
txt = readFileSync8(this.stormPath, "utf8");
|
|
8404
8659
|
} catch {
|
|
8405
8660
|
return;
|
|
8406
8661
|
}
|
|
@@ -9136,7 +9391,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
9136
9391
|
}
|
|
9137
9392
|
// ── events / хроника ─────────────────────────────────────────────────────────
|
|
9138
9393
|
addEvent(run_id, kind, text, actor = null) {
|
|
9139
|
-
const clean =
|
|
9394
|
+
const clean = sanitizeStoredEventText(text);
|
|
9140
9395
|
const ev = { id: this.nextEventId++, run_id, kind, text: clean, actor: actor ?? null, at: stamp() };
|
|
9141
9396
|
this.eventsLog.push(ev);
|
|
9142
9397
|
if (run_id == null) {
|
|
@@ -9397,7 +9652,7 @@ var SwarmClient = class _SwarmClient {
|
|
|
9397
9652
|
* транзиентным сбоем ОС, который этот PR должен переживать, а не превращать в мор.
|
|
9398
9653
|
*/
|
|
9399
9654
|
reconcileRuntime(opts) {
|
|
9400
|
-
const wtExists = opts.worktreeExists ??
|
|
9655
|
+
const wtExists = opts.worktreeExists ?? existsSync9;
|
|
9401
9656
|
const pidByWorktree = /* @__PURE__ */ new Map();
|
|
9402
9657
|
try {
|
|
9403
9658
|
for (const p of opts.listProcesses()) if (p.worktree) pidByWorktree.set(p.worktree, p.pid);
|
|
@@ -10665,13 +10920,13 @@ var SwarmClient = class _SwarmClient {
|
|
|
10665
10920
|
}
|
|
10666
10921
|
persistPending() {
|
|
10667
10922
|
try {
|
|
10668
|
-
|
|
10923
|
+
writeFileSync8(this.outboxPath, this.pending.map((e) => JSON.stringify(e)).join("\n") + (this.pending.length ? "\n" : ""));
|
|
10669
10924
|
} catch {
|
|
10670
10925
|
}
|
|
10671
10926
|
}
|
|
10672
10927
|
persistMap() {
|
|
10673
10928
|
try {
|
|
10674
|
-
|
|
10929
|
+
writeFileSync8(this.mapPath, JSON.stringify(Object.fromEntries(this.prodIdByKey)));
|
|
10675
10930
|
} catch {
|
|
10676
10931
|
}
|
|
10677
10932
|
}
|
|
@@ -10773,20 +11028,20 @@ function slowPassLine(seq, done, thresholdMs = SLOW_PASS_MS) {
|
|
|
10773
11028
|
}
|
|
10774
11029
|
|
|
10775
11030
|
// src/logRotate.ts
|
|
10776
|
-
import { copyFileSync as
|
|
11031
|
+
import { copyFileSync as copyFileSync5, renameSync as renameSync5, statSync as statSync8, fstatSync, truncateSync, unlinkSync as unlinkSync3, existsSync as existsSync10, openSync as openSync2, writeSync, closeSync as closeSync2 } from "fs";
|
|
10777
11032
|
var realIo = {
|
|
10778
11033
|
size: (path) => {
|
|
10779
11034
|
try {
|
|
10780
|
-
return
|
|
11035
|
+
return statSync8(path).size;
|
|
10781
11036
|
} catch {
|
|
10782
11037
|
return null;
|
|
10783
11038
|
}
|
|
10784
11039
|
},
|
|
10785
|
-
copy:
|
|
11040
|
+
copy: copyFileSync5,
|
|
10786
11041
|
rename: renameSync5,
|
|
10787
11042
|
truncate: (path) => truncateSync(path, 0),
|
|
10788
11043
|
unlink: unlinkSync3,
|
|
10789
|
-
exists:
|
|
11044
|
+
exists: existsSync10
|
|
10790
11045
|
};
|
|
10791
11046
|
var realOwnerIo = {
|
|
10792
11047
|
statFd: (fd) => {
|
|
@@ -10799,7 +11054,7 @@ var realOwnerIo = {
|
|
|
10799
11054
|
},
|
|
10800
11055
|
statPath: (path) => {
|
|
10801
11056
|
try {
|
|
10802
|
-
const s =
|
|
11057
|
+
const s = statSync8(path);
|
|
10803
11058
|
return { dev: s.dev, ino: s.ino };
|
|
10804
11059
|
} catch {
|
|
10805
11060
|
return null;
|
|
@@ -10835,7 +11090,7 @@ function rotateDaemonLog(path, opts, io = realIo) {
|
|
|
10835
11090
|
var teedTo = null;
|
|
10836
11091
|
|
|
10837
11092
|
// src/daemonLaunch.ts
|
|
10838
|
-
import { openSync as openSync3, closeSync as closeSync3, readFileSync as
|
|
11093
|
+
import { openSync as openSync3, closeSync as closeSync3, readFileSync as readFileSync10 } from "fs";
|
|
10839
11094
|
import { spawn } from "child_process";
|
|
10840
11095
|
var realRespawnIo = {
|
|
10841
11096
|
isTty: () => process.stdout.isTTY === true,
|
|
@@ -10935,13 +11190,13 @@ async function buildRepoRegistry(paths) {
|
|
|
10935
11190
|
}
|
|
10936
11191
|
|
|
10937
11192
|
// src/repoMemory.ts
|
|
10938
|
-
import { readFileSync as
|
|
10939
|
-
import { join as
|
|
11193
|
+
import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
|
|
11194
|
+
import { join as join13 } from "path";
|
|
10940
11195
|
var FILE = "repos.json";
|
|
10941
11196
|
function loadRememberedRepos(home) {
|
|
10942
11197
|
let raw;
|
|
10943
11198
|
try {
|
|
10944
|
-
raw =
|
|
11199
|
+
raw = readFileSync11(join13(home, FILE), "utf8");
|
|
10945
11200
|
} catch {
|
|
10946
11201
|
return [];
|
|
10947
11202
|
}
|
|
@@ -10956,7 +11211,7 @@ function loadRememberedRepos(home) {
|
|
|
10956
11211
|
function rememberRepos(home, paths, now = () => /* @__PURE__ */ new Date()) {
|
|
10957
11212
|
const clean = paths.filter((p) => p.trim().length > 0);
|
|
10958
11213
|
if (clean.length === 0) return;
|
|
10959
|
-
|
|
11214
|
+
writeFileSync10(join13(home, FILE), `${JSON.stringify({ paths: clean, at: now().toISOString() }, null, 2)}
|
|
10960
11215
|
`);
|
|
10961
11216
|
}
|
|
10962
11217
|
function pickRepoPaths(args) {
|
|
@@ -10971,12 +11226,12 @@ init_src();
|
|
|
10971
11226
|
init_config();
|
|
10972
11227
|
init_linkFailure();
|
|
10973
11228
|
import { homedir as homedir5 } from "os";
|
|
10974
|
-
import { readFileSync as
|
|
10975
|
-
import { isAbsolute, join as
|
|
11229
|
+
import { readFileSync as readFileSync13, renameSync as renameSync6, writeFileSync as writeFileSync11 } from "fs";
|
|
11230
|
+
import { isAbsolute, join as join15, resolve as resolve2 } from "path";
|
|
10976
11231
|
|
|
10977
11232
|
// src/repoScan.ts
|
|
10978
|
-
import { readdirSync as
|
|
10979
|
-
import { join as
|
|
11233
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync12, statSync as statSync9 } from "fs";
|
|
11234
|
+
import { join as join14 } from "path";
|
|
10980
11235
|
var SKIP = /* @__PURE__ */ new Set([
|
|
10981
11236
|
"node_modules",
|
|
10982
11237
|
"vendor",
|
|
@@ -11006,7 +11261,7 @@ function parseOriginFromGitConfig(text) {
|
|
|
11006
11261
|
}
|
|
11007
11262
|
function originOf(dir) {
|
|
11008
11263
|
try {
|
|
11009
|
-
return parseOriginFromGitConfig(
|
|
11264
|
+
return parseOriginFromGitConfig(readFileSync12(join14(dir, ".git", "config"), "utf8"));
|
|
11010
11265
|
} catch {
|
|
11011
11266
|
return null;
|
|
11012
11267
|
}
|
|
@@ -11035,15 +11290,15 @@ function walk(dir, depth, maxDepth, found) {
|
|
|
11035
11290
|
}
|
|
11036
11291
|
let entries;
|
|
11037
11292
|
try {
|
|
11038
|
-
entries =
|
|
11293
|
+
entries = readdirSync9(dir);
|
|
11039
11294
|
} catch {
|
|
11040
11295
|
return;
|
|
11041
11296
|
}
|
|
11042
11297
|
for (const name of entries) {
|
|
11043
11298
|
if (name.startsWith(".") || SKIP.has(name)) continue;
|
|
11044
|
-
const child =
|
|
11299
|
+
const child = join14(dir, name);
|
|
11045
11300
|
try {
|
|
11046
|
-
if (!
|
|
11301
|
+
if (!statSync9(child).isDirectory()) continue;
|
|
11047
11302
|
} catch {
|
|
11048
11303
|
continue;
|
|
11049
11304
|
}
|
|
@@ -11063,7 +11318,7 @@ function defaultScanRoots(home, knownPaths = []) {
|
|
|
11063
11318
|
if (parent && parent !== p) add(parent);
|
|
11064
11319
|
}
|
|
11065
11320
|
for (const name of ["projects", "code", "src", "dev", "work", "repos", "git", "Projects", "Code", "Developer", "Documents/GitHub", "go/src"]) {
|
|
11066
|
-
add(
|
|
11321
|
+
add(join14(home, name));
|
|
11067
11322
|
}
|
|
11068
11323
|
return out;
|
|
11069
11324
|
}
|
|
@@ -11077,7 +11332,7 @@ function resolveScanRoots(raw, home = homedir5(), knownPaths = []) {
|
|
|
11077
11332
|
for (const part of v.split(",")) {
|
|
11078
11333
|
const p = part.trim();
|
|
11079
11334
|
if (!p) continue;
|
|
11080
|
-
const abs = p === "~" ? home : p.startsWith("~/") ?
|
|
11335
|
+
const abs = p === "~" ? home : p.startsWith("~/") ? join15(home, p.slice(2)) : isAbsolute(p) ? p : resolve2(home, p);
|
|
11081
11336
|
if (!out.includes(abs)) out.push(abs);
|
|
11082
11337
|
}
|
|
11083
11338
|
return out;
|
|
@@ -11291,7 +11546,7 @@ function repoMapRows(state) {
|
|
|
11291
11546
|
}
|
|
11292
11547
|
function loadRepoMapCache(path) {
|
|
11293
11548
|
try {
|
|
11294
|
-
const raw = JSON.parse(
|
|
11549
|
+
const raw = JSON.parse(readFileSync13(path, "utf8"));
|
|
11295
11550
|
if (!Array.isArray(raw?.entries)) return { scannedAt: null, entries: [] };
|
|
11296
11551
|
return {
|
|
11297
11552
|
scannedAt: typeof raw.scannedAt === "string" && raw.scannedAt ? raw.scannedAt : null,
|
|
@@ -11306,7 +11561,7 @@ function loadRepoMapCache(path) {
|
|
|
11306
11561
|
function writeRepoMapCache(path, entries, scannedAt = stamp()) {
|
|
11307
11562
|
try {
|
|
11308
11563
|
const tmp = `${path}.tmp`;
|
|
11309
|
-
|
|
11564
|
+
writeFileSync11(tmp, JSON.stringify({ at: stamp(), scannedAt, entries }, null, 2));
|
|
11310
11565
|
renameSync6(tmp, path);
|
|
11311
11566
|
} catch {
|
|
11312
11567
|
}
|
|
@@ -11314,17 +11569,17 @@ function writeRepoMapCache(path, entries, scannedAt = stamp()) {
|
|
|
11314
11569
|
|
|
11315
11570
|
// src/hostIdentity.ts
|
|
11316
11571
|
import { hostname } from "os";
|
|
11317
|
-
import { existsSync as
|
|
11318
|
-
import { join as
|
|
11572
|
+
import { existsSync as existsSync11, readFileSync as readFileSync14, renameSync as renameSync7, writeFileSync as writeFileSync12 } from "fs";
|
|
11573
|
+
import { join as join16 } from "path";
|
|
11319
11574
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
11320
11575
|
function hostIdentityPath(home) {
|
|
11321
|
-
return
|
|
11576
|
+
return join16(home, "host.json");
|
|
11322
11577
|
}
|
|
11323
11578
|
function loadHostIdentity(deps) {
|
|
11324
|
-
const exists = deps.exists ??
|
|
11325
|
-
const readFile2 = deps.readFile ?? ((p) =>
|
|
11579
|
+
const exists = deps.exists ?? existsSync11;
|
|
11580
|
+
const readFile2 = deps.readFile ?? ((p) => readFileSync14(p, "utf8"));
|
|
11326
11581
|
const writeFile4 = deps.writeFile ?? ((p, data) => {
|
|
11327
|
-
|
|
11582
|
+
writeFileSync12(`${p}.tmp`, data);
|
|
11328
11583
|
renameSync7(`${p}.tmp`, p);
|
|
11329
11584
|
});
|
|
11330
11585
|
const host = deps.hostname ?? hostname;
|
|
@@ -11417,8 +11672,8 @@ function pickResumeCandidate(pausedForRelief) {
|
|
|
11417
11672
|
}
|
|
11418
11673
|
|
|
11419
11674
|
// src/reliefLoop.ts
|
|
11420
|
-
import { existsSync as
|
|
11421
|
-
import { join as
|
|
11675
|
+
import { existsSync as existsSync12, readFileSync as readFileSync15, renameSync as renameSync8, writeFileSync as writeFileSync13 } from "fs";
|
|
11676
|
+
import { join as join17 } from "path";
|
|
11422
11677
|
var numEnv3 = (name, def) => {
|
|
11423
11678
|
const v = Number(process.env[name]);
|
|
11424
11679
|
return Number.isFinite(v) && v > 0 ? v : def;
|
|
@@ -11453,11 +11708,11 @@ function reliefLoopTripped(entry, cfg = DEFAULT_RELIEF_LOOP_CONFIG) {
|
|
|
11453
11708
|
return !!entry && entry.pauses >= cfg.limit;
|
|
11454
11709
|
}
|
|
11455
11710
|
function reliefLoopStatePath(home) {
|
|
11456
|
-
return
|
|
11711
|
+
return join17(home, "relief-loop.json");
|
|
11457
11712
|
}
|
|
11458
11713
|
function loadReliefLoopState(home, now = Date.now(), io = {}, cfg = DEFAULT_RELIEF_LOOP_CONFIG) {
|
|
11459
|
-
const exists = io.exists ??
|
|
11460
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
11714
|
+
const exists = io.exists ?? existsSync12;
|
|
11715
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync15(p, "utf8"));
|
|
11461
11716
|
const path = reliefLoopStatePath(home);
|
|
11462
11717
|
if (!exists(path)) return {};
|
|
11463
11718
|
try {
|
|
@@ -11479,7 +11734,7 @@ function loadReliefLoopState(home, now = Date.now(), io = {}, cfg = DEFAULT_RELI
|
|
|
11479
11734
|
function saveReliefLoopState(home, state, io = {}) {
|
|
11480
11735
|
const path = reliefLoopStatePath(home);
|
|
11481
11736
|
const writeFile4 = io.writeFile ?? ((p, data) => {
|
|
11482
|
-
|
|
11737
|
+
writeFileSync13(`${p}.tmp`, data);
|
|
11483
11738
|
renameSync8(`${p}.tmp`, p);
|
|
11484
11739
|
});
|
|
11485
11740
|
writeFile4(path, JSON.stringify(state, null, 2));
|
|
@@ -11641,15 +11896,15 @@ function buildReliefCostCandidates(cost, t, sustainMs, build) {
|
|
|
11641
11896
|
|
|
11642
11897
|
// src/launcher.ts
|
|
11643
11898
|
import { spawn as spawn2 } from "child_process";
|
|
11644
|
-
import { closeSync as closeSync4, existsSync as
|
|
11899
|
+
import { closeSync as closeSync4, existsSync as existsSync13, mkdirSync as mkdirSync10, openSync as openSync4, readdirSync as readdirSync11 } from "fs";
|
|
11645
11900
|
import { createRequire } from "module";
|
|
11646
11901
|
import { homedir as homedir6 } from "os";
|
|
11647
|
-
import { dirname as dirname3, join as
|
|
11902
|
+
import { dirname as dirname3, join as join19 } from "path";
|
|
11648
11903
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
11649
11904
|
|
|
11650
11905
|
// src/droneHome.ts
|
|
11651
|
-
import { lstatSync, mkdirSync as
|
|
11652
|
-
import { join as
|
|
11906
|
+
import { lstatSync, mkdirSync as mkdirSync9, readdirSync as readdirSync10, rmSync, statSync as statSync10, symlinkSync as symlinkSync4 } from "fs";
|
|
11907
|
+
import { join as join18, relative, sep } from "path";
|
|
11653
11908
|
var DRONE_HOME_DENY_DEFAULT = [".taskless-swarm", ".bash_history", ".zsh_history"];
|
|
11654
11909
|
function droneHomeDeny(env = process.env) {
|
|
11655
11910
|
const extra = (env.SWARM_DRONE_HOME_DENY || "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
@@ -11667,34 +11922,34 @@ function buildDroneHome(opts) {
|
|
|
11667
11922
|
const { realHome, droneHome } = opts;
|
|
11668
11923
|
const deny = opts.deny ?? droneHomeDeny();
|
|
11669
11924
|
const platform = opts.platform ?? process.platform;
|
|
11670
|
-
|
|
11671
|
-
const wanted = new Set(mirroredEntries(
|
|
11925
|
+
mkdirSync9(droneHome, { recursive: true, mode: 448 });
|
|
11926
|
+
const wanted = new Set(mirroredEntries(readdirSync10(realHome), deny, platform));
|
|
11672
11927
|
const rel = relative(realHome, droneHome);
|
|
11673
11928
|
if (rel && !rel.startsWith("..") && !rel.includes(sep)) wanted.delete(rel);
|
|
11674
|
-
for (const existing of
|
|
11929
|
+
for (const existing of readdirSync10(droneHome)) {
|
|
11675
11930
|
if (wanted.has(existing)) continue;
|
|
11676
|
-
const p =
|
|
11931
|
+
const p = join18(droneHome, existing);
|
|
11677
11932
|
try {
|
|
11678
11933
|
if (lstatSync(p).isSymbolicLink()) rmSync(p);
|
|
11679
11934
|
} catch {
|
|
11680
11935
|
}
|
|
11681
11936
|
}
|
|
11682
11937
|
for (const name of wanted) {
|
|
11683
|
-
const link2 =
|
|
11938
|
+
const link2 = join18(droneHome, name);
|
|
11684
11939
|
try {
|
|
11685
11940
|
lstatSync(link2);
|
|
11686
11941
|
continue;
|
|
11687
11942
|
} catch {
|
|
11688
11943
|
}
|
|
11689
|
-
const target =
|
|
11944
|
+
const target = join18(realHome, name);
|
|
11690
11945
|
let isDir;
|
|
11691
11946
|
try {
|
|
11692
|
-
isDir =
|
|
11947
|
+
isDir = statSync10(target).isDirectory();
|
|
11693
11948
|
} catch {
|
|
11694
11949
|
continue;
|
|
11695
11950
|
}
|
|
11696
11951
|
try {
|
|
11697
|
-
|
|
11952
|
+
symlinkSync4(target, link2, isDir ? "junction" : "file");
|
|
11698
11953
|
} catch (e) {
|
|
11699
11954
|
if (e.code !== "EEXIST") throw e;
|
|
11700
11955
|
}
|
|
@@ -11707,7 +11962,7 @@ var REAL_PATH_ENV_PINS = [
|
|
|
11707
11962
|
{ env: "YARN_GLOBAL_FOLDER", segments: [".yarn", "berry"] }
|
|
11708
11963
|
];
|
|
11709
11964
|
function realPathEnvPins(realHome) {
|
|
11710
|
-
return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env,
|
|
11965
|
+
return Object.fromEntries(REAL_PATH_ENV_PINS.map(({ env, segments }) => [env, join18(realHome, ...segments)]));
|
|
11711
11966
|
}
|
|
11712
11967
|
function dronePrivatePaths(realHome, swarmHome) {
|
|
11713
11968
|
return [
|
|
@@ -11791,7 +12046,7 @@ function droneEnv(worktree, base3 = process.env, isolation, droneCap = null) {
|
|
|
11791
12046
|
const env = { ...base3 };
|
|
11792
12047
|
const isolate = base3.SWARM_TURBO_ISOLATE !== "0";
|
|
11793
12048
|
if (isolate && !base3.TURBO_CACHE_DIR) {
|
|
11794
|
-
env.TURBO_CACHE_DIR =
|
|
12049
|
+
env.TURBO_CACHE_DIR = join19(worktree, ".turbo", "cache");
|
|
11795
12050
|
}
|
|
11796
12051
|
Object.assign(env, droneTestEnv(droneCap, base3));
|
|
11797
12052
|
for (const key of DAEMON_STATE_ENV) delete env[key];
|
|
@@ -11822,21 +12077,21 @@ var DAEMON_STATE_ENV = [
|
|
|
11822
12077
|
...PROVIDER_TOKEN_ENV
|
|
11823
12078
|
];
|
|
11824
12079
|
function bundledRoleDir(kind) {
|
|
11825
|
-
return
|
|
12080
|
+
return join19(dirname3(fileURLToPath2(import.meta.url)), "..", "roles", kind);
|
|
11826
12081
|
}
|
|
11827
12082
|
function roleDir(worktree, kind) {
|
|
11828
|
-
return
|
|
12083
|
+
return join19(worktree, ".claude", "roles", kind);
|
|
11829
12084
|
}
|
|
11830
12085
|
function roleDirs(worktree, kind) {
|
|
11831
|
-
return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) =>
|
|
12086
|
+
return [bundledRoleDir(kind), roleDir(worktree, kind)].filter((dir) => existsSync13(dir));
|
|
11832
12087
|
}
|
|
11833
12088
|
function nextRunLogPath(runLogsDir, runLogKeys) {
|
|
11834
12089
|
const dir = runLogDirForWrite(runLogsDir, runLogKeys);
|
|
11835
12090
|
if (!dir) throw new Error("\u043D\u0435\u0447\u0435\u043C \u0430\u0434\u0440\u0435\u0441\u043E\u0432\u0430\u0442\u044C \u043A\u0430\u0442\u0430\u043B\u043E\u0433 run-log'\u043E\u0432: \u0443 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 \u043D\u0435\u0442 \u0441\u0442\u0430\u0431\u0438\u043B\u044C\u043D\u043E\u0433\u043E \u043A\u043B\u044E\u0447\u0430 (SwarmStore.runLogKeys)");
|
|
11836
|
-
|
|
12091
|
+
mkdirSync10(dir, { recursive: true });
|
|
11837
12092
|
let files = [];
|
|
11838
12093
|
try {
|
|
11839
|
-
files =
|
|
12094
|
+
files = readdirSync11(dir);
|
|
11840
12095
|
} catch {
|
|
11841
12096
|
}
|
|
11842
12097
|
let next = 0;
|
|
@@ -11844,7 +12099,7 @@ function nextRunLogPath(runLogsDir, runLogKeys) {
|
|
|
11844
12099
|
const m = /^(\d+)\.json/.exec(f);
|
|
11845
12100
|
if (m) next = Math.max(next, Number(m[1]) + 1);
|
|
11846
12101
|
}
|
|
11847
|
-
return
|
|
12102
|
+
return join19(dir, `${next}.json`);
|
|
11848
12103
|
}
|
|
11849
12104
|
function openNextRunLog(runLogsDir, runLogKeys) {
|
|
11850
12105
|
for (let attempt = 0; attempt < 50; attempt++) {
|
|
@@ -11936,9 +12191,9 @@ function makeLauncher(cfg) {
|
|
|
11936
12191
|
}
|
|
11937
12192
|
const realHome = cfg.droneIsolation?.realHome ?? homedir6();
|
|
11938
12193
|
const home = cfg.droneIsolation ? buildDroneHome({ realHome, droneHome: cfg.droneIsolation.home }) : void 0;
|
|
11939
|
-
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !
|
|
12194
|
+
if (cfg.droneIsolation && process.env.TASKLESS_TOKEN && !existsSync13(join19(cfg.droneIsolation.swarmHome, "token"))) {
|
|
11940
12195
|
console.error(
|
|
11941
|
-
`[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${
|
|
12196
|
+
`[launcher] TASKLESS_TOKEN \u0437\u0430\u0434\u0430\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0432 env \u0434\u0435\u043C\u043E\u043D\u0430 \u2014 \u0434\u0440\u043E\u043D\u0443 \u043E\u043D \u043D\u0435 \u043D\u0430\u0441\u043B\u0435\u0434\u0443\u0435\u0442\u0441\u044F (TASWM-289), \u0430 \u0444\u0430\u0439\u043B\u0430 ${join19(cfg.droneIsolation.swarmHome, "token")} \u043D\u0435\u0442. read_task \u0434\u0440\u043E\u043D\u0430 \u0431\u0443\u0434\u0435\u0442 slug-only. \u041F\u043E\u0447\u0438\u043D\u0438: \`swarm login\` (oauth.json) \u0438\u043B\u0438 \u043F\u043E\u043B\u043E\u0436\u0438 \u0442\u043E\u043A\u0435\u043D \u0432 \u044D\u0442\u043E\u0442 \u0444\u0430\u0439\u043B.`
|
|
11942
12197
|
);
|
|
11943
12198
|
}
|
|
11944
12199
|
const executor = cfg.executor ?? executorForRun(run2, cfg.swarmModels?.() ?? null);
|
|
@@ -12000,8 +12255,8 @@ function makeLauncher(cfg) {
|
|
|
12000
12255
|
init_procCleanup();
|
|
12001
12256
|
|
|
12002
12257
|
// src/cost.ts
|
|
12003
|
-
import { readFileSync as
|
|
12004
|
-
import { join as
|
|
12258
|
+
import { readFileSync as readFileSync17, readdirSync as readdirSync12, renameSync as renameSync9, statSync as statSync11 } from "fs";
|
|
12259
|
+
import { join as join20 } from "path";
|
|
12005
12260
|
init_executors();
|
|
12006
12261
|
init_swarmModels();
|
|
12007
12262
|
var UNPROCESSED_LOG_RE = /^\d+\.json$/;
|
|
@@ -12009,7 +12264,7 @@ var SEGMENT_LOG_RE = /^(\d+)\.json(\.done)?$/;
|
|
|
12009
12264
|
var RESCUE_OPEN_WINDOW_MAX_MS = 12 * 60 * 60 * 1e3;
|
|
12010
12265
|
function unprocessedLogFiles(dir) {
|
|
12011
12266
|
try {
|
|
12012
|
-
return
|
|
12267
|
+
return readdirSync12(dir).filter((f) => UNPROCESSED_LOG_RE.test(f));
|
|
12013
12268
|
} catch {
|
|
12014
12269
|
return [];
|
|
12015
12270
|
}
|
|
@@ -12018,7 +12273,7 @@ function segmentStarts(dir) {
|
|
|
12018
12273
|
const starts = /* @__PURE__ */ new Map();
|
|
12019
12274
|
let entries;
|
|
12020
12275
|
try {
|
|
12021
|
-
entries =
|
|
12276
|
+
entries = readdirSync12(dir);
|
|
12022
12277
|
} catch {
|
|
12023
12278
|
return starts;
|
|
12024
12279
|
}
|
|
@@ -12026,7 +12281,7 @@ function segmentStarts(dir) {
|
|
|
12026
12281
|
const m = SEGMENT_LOG_RE.exec(f);
|
|
12027
12282
|
if (!m) continue;
|
|
12028
12283
|
try {
|
|
12029
|
-
const st =
|
|
12284
|
+
const st = statSync11(join20(dir, f));
|
|
12030
12285
|
starts.set(Number(m[1]), st.birthtimeMs > 0 ? st.birthtimeMs : st.ctimeMs);
|
|
12031
12286
|
} catch {
|
|
12032
12287
|
}
|
|
@@ -12079,10 +12334,10 @@ function accountRunCost(deps, run2) {
|
|
|
12079
12334
|
let unmeasured = 0;
|
|
12080
12335
|
const processed = [];
|
|
12081
12336
|
for (const f of files) {
|
|
12082
|
-
const full =
|
|
12337
|
+
const full = join20(dir, f);
|
|
12083
12338
|
let raw = null;
|
|
12084
12339
|
try {
|
|
12085
|
-
raw =
|
|
12340
|
+
raw = readFileSync17(full, "utf8");
|
|
12086
12341
|
} catch {
|
|
12087
12342
|
continue;
|
|
12088
12343
|
}
|
|
@@ -12136,8 +12391,8 @@ function makeCostSweeper(deps) {
|
|
|
12136
12391
|
}
|
|
12137
12392
|
|
|
12138
12393
|
// src/runOutcome.ts
|
|
12139
|
-
import { readdirSync as
|
|
12140
|
-
import { join as
|
|
12394
|
+
import { readdirSync as readdirSync13, readFileSync as readFileSync18 } from "fs";
|
|
12395
|
+
import { join as join21 } from "path";
|
|
12141
12396
|
init_executors();
|
|
12142
12397
|
function endedItself(outcome) {
|
|
12143
12398
|
return outcome === "graceful" || outcome === "budget" || outcome === "aborted";
|
|
@@ -12151,7 +12406,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
|
|
|
12151
12406
|
if (!dir) return null;
|
|
12152
12407
|
let files;
|
|
12153
12408
|
try {
|
|
12154
|
-
files =
|
|
12409
|
+
files = readdirSync13(dir);
|
|
12155
12410
|
} catch {
|
|
12156
12411
|
return null;
|
|
12157
12412
|
}
|
|
@@ -12164,7 +12419,7 @@ function readLatestResultRaw(runLogsDir, runLogKeys) {
|
|
|
12164
12419
|
}
|
|
12165
12420
|
if (!latest) return null;
|
|
12166
12421
|
try {
|
|
12167
|
-
return
|
|
12422
|
+
return readFileSync18(join21(dir, latest.name), "utf8");
|
|
12168
12423
|
} catch {
|
|
12169
12424
|
return null;
|
|
12170
12425
|
}
|
|
@@ -12201,7 +12456,7 @@ init_src();
|
|
|
12201
12456
|
init_swarmModels();
|
|
12202
12457
|
init_executors();
|
|
12203
12458
|
import { accessSync, constants } from "fs";
|
|
12204
|
-
import { delimiter, join as
|
|
12459
|
+
import { delimiter, join as join22 } from "path";
|
|
12205
12460
|
function binRunnable(bin, env) {
|
|
12206
12461
|
if (!bin) return false;
|
|
12207
12462
|
if (bin.includes("/") || bin.includes("\\")) {
|
|
@@ -12217,7 +12472,7 @@ function binRunnable(bin, env) {
|
|
|
12217
12472
|
if (!dir) continue;
|
|
12218
12473
|
for (const ext of exts) {
|
|
12219
12474
|
try {
|
|
12220
|
-
accessSync(
|
|
12475
|
+
accessSync(join22(dir, bin + ext), constants.X_OK);
|
|
12221
12476
|
return true;
|
|
12222
12477
|
} catch {
|
|
12223
12478
|
}
|
|
@@ -12264,20 +12519,20 @@ init_src();
|
|
|
12264
12519
|
init_git();
|
|
12265
12520
|
|
|
12266
12521
|
// src/deps.ts
|
|
12267
|
-
import { existsSync as
|
|
12268
|
-
import { join as
|
|
12522
|
+
import { existsSync as existsSync16, readdirSync as readdirSync15, readFileSync as readFileSync20 } from "fs";
|
|
12523
|
+
import { join as join26 } from "path";
|
|
12269
12524
|
import { execa } from "execa";
|
|
12270
12525
|
|
|
12271
12526
|
// src/prepareLock.ts
|
|
12272
12527
|
import { createHash } from "crypto";
|
|
12273
|
-
import { closeSync as closeSync5, openSync as openSync5, rmSync as rmSync2, statSync as
|
|
12274
|
-
import { join as
|
|
12528
|
+
import { closeSync as closeSync5, openSync as openSync5, rmSync as rmSync2, statSync as statSync13, writeSync as writeSync2 } from "fs";
|
|
12529
|
+
import { join as join24 } from "path";
|
|
12275
12530
|
import { tmpdir } from "os";
|
|
12276
12531
|
var WAIT_TIMEOUT_MS = 5 * 6e4;
|
|
12277
12532
|
var POLL_MS = 300;
|
|
12278
12533
|
var STALE_MS = 20 * 6e4;
|
|
12279
12534
|
function machineLockPath(key, dir = tmpdir()) {
|
|
12280
|
-
return
|
|
12535
|
+
return join24(dir, `swarm-prepare-${createHash("sha1").update(key).digest("hex").slice(0, 16)}.lock`);
|
|
12281
12536
|
}
|
|
12282
12537
|
function defaultTryCreate(path, content) {
|
|
12283
12538
|
try {
|
|
@@ -12294,7 +12549,7 @@ function defaultTryCreate(path, content) {
|
|
|
12294
12549
|
}
|
|
12295
12550
|
function defaultAgeMs(path) {
|
|
12296
12551
|
try {
|
|
12297
|
-
return Date.now() -
|
|
12552
|
+
return Date.now() - statSync13(path).mtimeMs;
|
|
12298
12553
|
} catch {
|
|
12299
12554
|
return null;
|
|
12300
12555
|
}
|
|
@@ -12338,8 +12593,8 @@ init_config();
|
|
|
12338
12593
|
init_config();
|
|
12339
12594
|
import { createHash as createHash2 } from "crypto";
|
|
12340
12595
|
import { cp, link, lstat, mkdir as mkdir2, readdir, readlink, rename as rename2, rm as rm2, stat, symlink, utimes, writeFile as writeFile2 } from "fs/promises";
|
|
12341
|
-
import { existsSync as
|
|
12342
|
-
import { join as
|
|
12596
|
+
import { existsSync as existsSync15, readFileSync as readFileSync19 } from "fs";
|
|
12597
|
+
import { join as join25 } from "path";
|
|
12343
12598
|
function fingerprint(parts) {
|
|
12344
12599
|
const h = createHash2("sha256");
|
|
12345
12600
|
for (const p of parts) {
|
|
@@ -12353,8 +12608,8 @@ async function cloneTree(src, dst) {
|
|
|
12353
12608
|
const entries = await readdir(src, { withFileTypes: true });
|
|
12354
12609
|
await Promise.all(
|
|
12355
12610
|
entries.map(async (e) => {
|
|
12356
|
-
const from =
|
|
12357
|
-
const to =
|
|
12611
|
+
const from = join25(src, e.name);
|
|
12612
|
+
const to = join25(dst, e.name);
|
|
12358
12613
|
if (e.isDirectory()) return cloneTree(from, to);
|
|
12359
12614
|
if (e.isSymbolicLink()) {
|
|
12360
12615
|
return symlink(await readlink(from), to).catch(() => cp(from, to, { recursive: true, verbatimSymlinks: true }));
|
|
@@ -12367,11 +12622,11 @@ function cacheRoot(io) {
|
|
|
12367
12622
|
return io.root ?? ENV_CACHE_DIR;
|
|
12368
12623
|
}
|
|
12369
12624
|
function snapshotDir(io, key) {
|
|
12370
|
-
return
|
|
12625
|
+
return join25(cacheRoot(io), key);
|
|
12371
12626
|
}
|
|
12372
12627
|
function readManifest(dir) {
|
|
12373
12628
|
try {
|
|
12374
|
-
const parsed = JSON.parse(
|
|
12629
|
+
const parsed = JSON.parse(readFileSync19(join25(dir, "manifest.json"), "utf8"));
|
|
12375
12630
|
if (!parsed || typeof parsed !== "object") return null;
|
|
12376
12631
|
const m = parsed;
|
|
12377
12632
|
if (typeof m.key !== "string" || !Array.isArray(m.dirs)) return null;
|
|
@@ -12383,11 +12638,11 @@ function readManifest(dir) {
|
|
|
12383
12638
|
}
|
|
12384
12639
|
}
|
|
12385
12640
|
function hasEnvSnapshot(key, io = {}) {
|
|
12386
|
-
const exists = io.exists ??
|
|
12387
|
-
return exists(
|
|
12641
|
+
const exists = io.exists ?? existsSync15;
|
|
12642
|
+
return exists(join25(snapshotDir(io, key), "manifest.json"));
|
|
12388
12643
|
}
|
|
12389
12644
|
async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
12390
|
-
const exists = io.exists ??
|
|
12645
|
+
const exists = io.exists ?? existsSync15;
|
|
12391
12646
|
const clone = io.clone ?? cloneTree;
|
|
12392
12647
|
const dir = snapshotDir(io, key);
|
|
12393
12648
|
const manifest = readManifest(dir);
|
|
@@ -12396,13 +12651,13 @@ async function restoreEnvSnapshot(worktree, key, io = {}) {
|
|
|
12396
12651
|
try {
|
|
12397
12652
|
for (let i = 0; i < manifest.dirs.length; i++) {
|
|
12398
12653
|
const rel = manifest.dirs[i] ?? "";
|
|
12399
|
-
const target =
|
|
12654
|
+
const target = join25(worktree, rel);
|
|
12400
12655
|
if (exists(target)) continue;
|
|
12401
|
-
await clone(
|
|
12656
|
+
await clone(join25(dir, "trees", String(i)), target);
|
|
12402
12657
|
made.push(rel);
|
|
12403
12658
|
}
|
|
12404
12659
|
} catch {
|
|
12405
|
-
for (const rel of made) await rm2(
|
|
12660
|
+
for (const rel of made) await rm2(join25(worktree, rel), { recursive: true, force: true }).catch(() => {
|
|
12406
12661
|
});
|
|
12407
12662
|
return null;
|
|
12408
12663
|
}
|
|
@@ -12415,19 +12670,19 @@ async function touch(dir) {
|
|
|
12415
12670
|
});
|
|
12416
12671
|
}
|
|
12417
12672
|
async function saveEnvSnapshot(worktree, key, dirs, io = {}) {
|
|
12418
|
-
const exists = io.exists ??
|
|
12673
|
+
const exists = io.exists ?? existsSync15;
|
|
12419
12674
|
const clone = io.clone ?? cloneTree;
|
|
12420
12675
|
if (hasEnvSnapshot(key, io)) return true;
|
|
12421
|
-
const present = dirs.filter((rel) => exists(
|
|
12676
|
+
const present = dirs.filter((rel) => exists(join25(worktree, rel)));
|
|
12422
12677
|
if (!present.length) return false;
|
|
12423
12678
|
const root = cacheRoot(io);
|
|
12424
|
-
const tmp =
|
|
12679
|
+
const tmp = join25(root, `.tmp-${key}-${process.pid}`);
|
|
12425
12680
|
try {
|
|
12426
12681
|
await rm2(tmp, { recursive: true, force: true });
|
|
12427
|
-
await mkdir2(
|
|
12428
|
-
for (let i = 0; i < present.length; i++) await clone(
|
|
12682
|
+
await mkdir2(join25(tmp, "trees"), { recursive: true });
|
|
12683
|
+
for (let i = 0; i < present.length; i++) await clone(join25(worktree, present[i] ?? ""), join25(tmp, "trees", String(i)));
|
|
12429
12684
|
const manifest = { key, dirs: present, createdAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
12430
|
-
await writeFile2(
|
|
12685
|
+
await writeFile2(join25(tmp, "manifest.json"), JSON.stringify(manifest, null, 2));
|
|
12431
12686
|
await rename2(tmp, snapshotDir(io, key));
|
|
12432
12687
|
return true;
|
|
12433
12688
|
} catch {
|
|
@@ -12447,13 +12702,13 @@ async function pruneEnvSnapshots(io = {}) {
|
|
|
12447
12702
|
}
|
|
12448
12703
|
const withTime = [];
|
|
12449
12704
|
for (const name of names) {
|
|
12450
|
-
const s = await stat(
|
|
12705
|
+
const s = await stat(join25(root, name)).catch(() => null);
|
|
12451
12706
|
if (s) withTime.push({ name, mtime: s.mtimeMs });
|
|
12452
12707
|
}
|
|
12453
12708
|
withTime.sort((a, b) => b.mtime - a.mtime);
|
|
12454
12709
|
let removed = 0;
|
|
12455
12710
|
for (const { name } of withTime.slice(Math.max(0, keep))) {
|
|
12456
|
-
await rm2(
|
|
12711
|
+
await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
|
|
12457
12712
|
});
|
|
12458
12713
|
removed++;
|
|
12459
12714
|
}
|
|
@@ -12469,9 +12724,9 @@ async function sweepEnvCacheTemp(io = {}) {
|
|
|
12469
12724
|
}
|
|
12470
12725
|
let removed = 0;
|
|
12471
12726
|
for (const name of names) {
|
|
12472
|
-
const s = await lstat(
|
|
12727
|
+
const s = await lstat(join25(root, name)).catch(() => null);
|
|
12473
12728
|
if (!s || Date.now() - s.mtimeMs < 60 * 6e4) continue;
|
|
12474
|
-
await rm2(
|
|
12729
|
+
await rm2(join25(root, name), { recursive: true, force: true }).catch(() => {
|
|
12475
12730
|
});
|
|
12476
12731
|
removed++;
|
|
12477
12732
|
}
|
|
@@ -12498,21 +12753,21 @@ async function runCommand(cmd, worktree) {
|
|
|
12498
12753
|
}
|
|
12499
12754
|
function safeReadText(p) {
|
|
12500
12755
|
try {
|
|
12501
|
-
return
|
|
12756
|
+
return readFileSync20(p, "utf8");
|
|
12502
12757
|
} catch {
|
|
12503
12758
|
return null;
|
|
12504
12759
|
}
|
|
12505
12760
|
}
|
|
12506
12761
|
function safeListDirs(p) {
|
|
12507
12762
|
try {
|
|
12508
|
-
return
|
|
12763
|
+
return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
12509
12764
|
} catch {
|
|
12510
12765
|
return [];
|
|
12511
12766
|
}
|
|
12512
12767
|
}
|
|
12513
12768
|
function safeListFiles(p) {
|
|
12514
12769
|
try {
|
|
12515
|
-
return
|
|
12770
|
+
return readdirSync15(p, { withFileTypes: true }).filter((e) => e.isFile()).map((e) => e.name);
|
|
12516
12771
|
} catch {
|
|
12517
12772
|
return [];
|
|
12518
12773
|
}
|
|
@@ -12538,21 +12793,21 @@ function overridePlan(override) {
|
|
|
12538
12793
|
};
|
|
12539
12794
|
}
|
|
12540
12795
|
function detectPackageManager(worktree, io = {}) {
|
|
12541
|
-
const exists = io.exists ??
|
|
12796
|
+
const exists = io.exists ?? existsSync16;
|
|
12542
12797
|
const readText = io.readText ?? safeReadText;
|
|
12543
|
-
const hasPkgJson = exists(
|
|
12798
|
+
const hasPkgJson = exists(join26(worktree, "package.json"));
|
|
12544
12799
|
if (!hasPkgJson) {
|
|
12545
|
-
if (exists(
|
|
12800
|
+
if (exists(join26(worktree, "deno.json")) || exists(join26(worktree, "deno.jsonc")) || exists(join26(worktree, "deno.lock"))) return "deno";
|
|
12546
12801
|
return null;
|
|
12547
12802
|
}
|
|
12548
|
-
const pkg = readJson(readText,
|
|
12803
|
+
const pkg = readJson(readText, join26(worktree, "package.json"));
|
|
12549
12804
|
const declared = typeof pkg?.packageManager === "string" ? pkg.packageManager.split("@")[0] : void 0;
|
|
12550
12805
|
if (declared === "pnpm" || declared === "bun" || declared === "npm" || declared === "yarn") return declared;
|
|
12551
|
-
if (exists(
|
|
12552
|
-
if (exists(
|
|
12553
|
-
if (exists(
|
|
12554
|
-
if (exists(
|
|
12555
|
-
if (exists(
|
|
12806
|
+
if (exists(join26(worktree, "bun.lock")) || exists(join26(worktree, "bun.lockb"))) return "bun";
|
|
12807
|
+
if (exists(join26(worktree, "pnpm-lock.yaml"))) return "pnpm";
|
|
12808
|
+
if (exists(join26(worktree, "yarn.lock"))) return "yarn";
|
|
12809
|
+
if (exists(join26(worktree, "package-lock.json"))) return "npm";
|
|
12810
|
+
if (exists(join26(worktree, "deno.lock"))) return "deno";
|
|
12556
12811
|
return "npm";
|
|
12557
12812
|
}
|
|
12558
12813
|
function jsInstallCommand(pm) {
|
|
@@ -12608,7 +12863,7 @@ var ECOSYSTEM_MARKERS = [
|
|
|
12608
12863
|
// конфигурация — дело сборки, не подготовки
|
|
12609
12864
|
];
|
|
12610
12865
|
function detectPlan(worktree, io) {
|
|
12611
|
-
const exists = io.exists ??
|
|
12866
|
+
const exists = io.exists ?? existsSync16;
|
|
12612
12867
|
const listFiles = io.listFiles ?? safeListFiles;
|
|
12613
12868
|
const pm = detectPackageManager(worktree, io);
|
|
12614
12869
|
if (pm) {
|
|
@@ -12616,7 +12871,7 @@ function detectPlan(worktree, io) {
|
|
|
12616
12871
|
// node_modules на месте — установку пропускаем (быстрый путь переиспользованного worktree).
|
|
12617
12872
|
// У deno каталога может не быть вовсе (кэш в DENO_DIR) — тогда `deno install` отработает
|
|
12618
12873
|
// заново, но он дешёвый: тянет из того же общего кэша.
|
|
12619
|
-
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists:
|
|
12874
|
+
{ label: `${pm} install`, run: jsInstallCommand(pm), skipIfExists: join26(worktree, "node_modules"), source: "detect" }
|
|
12620
12875
|
];
|
|
12621
12876
|
for (const target of workspaceBuildTargets(worktree, io)) {
|
|
12622
12877
|
commands.push({ label: `\u0441\u0431\u043E\u0440\u043A\u0430 ${target.name}`, run: jsRunScript(pm, "build"), cwd: target.dir, source: "detect" });
|
|
@@ -12625,12 +12880,12 @@ function detectPlan(worktree, io) {
|
|
|
12625
12880
|
return { source: "detect", ecosystem: `node/${pm}`, commands };
|
|
12626
12881
|
}
|
|
12627
12882
|
for (const marker of ECOSYSTEM_MARKERS) {
|
|
12628
|
-
const hit = marker.files.some((f) => exists(
|
|
12883
|
+
const hit = marker.files.some((f) => exists(join26(worktree, f))) || marker.ext !== void 0 && listFiles(worktree).some((n) => n.endsWith(marker.ext));
|
|
12629
12884
|
if (!hit) continue;
|
|
12630
12885
|
let ecosystem = marker.ecosystem;
|
|
12631
12886
|
let command = marker.command;
|
|
12632
12887
|
for (const refine of marker.refine ?? []) {
|
|
12633
|
-
if (!exists(
|
|
12888
|
+
if (!exists(join26(worktree, refine.file))) continue;
|
|
12634
12889
|
ecosystem = refine.ecosystem;
|
|
12635
12890
|
command = refine.command;
|
|
12636
12891
|
break;
|
|
@@ -12687,12 +12942,12 @@ var CI_INSTALL_PATTERNS = [
|
|
|
12687
12942
|
function ciWorkflowPlan(worktree, io) {
|
|
12688
12943
|
const readText = io.readText ?? safeReadText;
|
|
12689
12944
|
const listFiles = io.listFiles ?? safeListFiles;
|
|
12690
|
-
const dir =
|
|
12945
|
+
const dir = join26(worktree, ".github", "workflows");
|
|
12691
12946
|
const files = listFiles(dir).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml"));
|
|
12692
12947
|
const seen = /* @__PURE__ */ new Set();
|
|
12693
12948
|
const commands = [];
|
|
12694
12949
|
for (const name of files.sort()) {
|
|
12695
|
-
const yaml = readText(
|
|
12950
|
+
const yaml = readText(join26(dir, name));
|
|
12696
12951
|
if (yaml === null) continue;
|
|
12697
12952
|
for (const raw of workflowRunLines(yaml)) {
|
|
12698
12953
|
const line = raw.replace(/\s+/g, " ").trim();
|
|
@@ -12707,7 +12962,7 @@ function ciWorkflowPlan(worktree, io) {
|
|
|
12707
12962
|
return commands.length ? { source: "ci-workflow", ecosystem: "ci-\u043A\u043E\u043D\u0444\u0438\u0433", commands } : null;
|
|
12708
12963
|
}
|
|
12709
12964
|
function workspaceGlobs(worktree, readText) {
|
|
12710
|
-
const yaml = readText(
|
|
12965
|
+
const yaml = readText(join26(worktree, "pnpm-workspace.yaml"));
|
|
12711
12966
|
if (yaml !== null) {
|
|
12712
12967
|
const globs = [];
|
|
12713
12968
|
let inPackages = false;
|
|
@@ -12727,7 +12982,7 @@ function workspaceGlobs(worktree, readText) {
|
|
|
12727
12982
|
}
|
|
12728
12983
|
if (globs.length) return globs;
|
|
12729
12984
|
}
|
|
12730
|
-
const pkg = readJson(readText,
|
|
12985
|
+
const pkg = readJson(readText, join26(worktree, "package.json"));
|
|
12731
12986
|
const ws = pkg?.workspaces;
|
|
12732
12987
|
const list = Array.isArray(ws) ? ws : Array.isArray(ws?.packages) ? ws.packages : [];
|
|
12733
12988
|
return list.filter((g) => typeof g === "string");
|
|
@@ -12738,14 +12993,14 @@ function workspaceDirs(worktree, globs, io) {
|
|
|
12738
12993
|
if (glob.startsWith("!")) continue;
|
|
12739
12994
|
const star = glob.indexOf("*");
|
|
12740
12995
|
if (star === -1) {
|
|
12741
|
-
const dir =
|
|
12742
|
-
if (io.exists(
|
|
12996
|
+
const dir = join26(worktree, glob);
|
|
12997
|
+
if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
|
|
12743
12998
|
continue;
|
|
12744
12999
|
}
|
|
12745
|
-
const base3 =
|
|
13000
|
+
const base3 = join26(worktree, glob.slice(0, star).replace(/\/$/, ""));
|
|
12746
13001
|
for (const name of io.listDirs(base3)) {
|
|
12747
|
-
const dir =
|
|
12748
|
-
if (io.exists(
|
|
13002
|
+
const dir = join26(base3, name);
|
|
13003
|
+
if (io.exists(join26(dir, "package.json"))) dirs.add(dir);
|
|
12749
13004
|
}
|
|
12750
13005
|
}
|
|
12751
13006
|
return [...dirs];
|
|
@@ -12766,18 +13021,18 @@ function entryPaths(pkg) {
|
|
|
12766
13021
|
return out;
|
|
12767
13022
|
}
|
|
12768
13023
|
function workspaceBuildTargets(worktree, io = {}) {
|
|
12769
|
-
const exists = io.exists ??
|
|
13024
|
+
const exists = io.exists ?? existsSync16;
|
|
12770
13025
|
const readText = io.readText ?? safeReadText;
|
|
12771
13026
|
const listDirs = io.listDirs ?? safeListDirs;
|
|
12772
13027
|
const globs = workspaceGlobs(worktree, readText);
|
|
12773
13028
|
if (!globs.length) return [];
|
|
12774
13029
|
const pkgs = [];
|
|
12775
13030
|
for (const dir of workspaceDirs(worktree, globs, { exists, listDirs })) {
|
|
12776
|
-
const pkg = readJson(readText,
|
|
13031
|
+
const pkg = readJson(readText, join26(dir, "package.json"));
|
|
12777
13032
|
if (!pkg || typeof pkg.name !== "string") continue;
|
|
12778
13033
|
const scripts = pkg.scripts ?? {};
|
|
12779
13034
|
const entries = entryPaths(pkg);
|
|
12780
|
-
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(
|
|
13035
|
+
const needsBuild = typeof scripts.build === "string" && entries.length > 0 && entries.some((e) => !exists(join26(dir, e)));
|
|
12781
13036
|
const deps = Object.keys({ ...pkg.dependencies ?? {}, ...pkg.devDependencies ?? {} });
|
|
12782
13037
|
pkgs.push({ name: pkg.name, dir, deps, needsBuild });
|
|
12783
13038
|
}
|
|
@@ -12805,7 +13060,7 @@ function devDatabaseUrl(worktree, io = {}) {
|
|
|
12805
13060
|
const fromEnv = (io.env ?? process.env).DATABASE_URL;
|
|
12806
13061
|
if (fromEnv && fromEnv.trim()) return fromEnv.trim();
|
|
12807
13062
|
for (const file of [".env", ".env.example"]) {
|
|
12808
|
-
const raw = readText(
|
|
13063
|
+
const raw = readText(join26(worktree, file));
|
|
12809
13064
|
if (raw === null) continue;
|
|
12810
13065
|
const m = /^\s*(?:export\s+)?DATABASE_URL\s*=\s*(.*)$/m.exec(raw);
|
|
12811
13066
|
const value = (m?.[1] ?? "").trim().replace(/^['"]|['"]$/g, "");
|
|
@@ -12821,11 +13076,11 @@ function isLocalDatabase(url) {
|
|
|
12821
13076
|
}
|
|
12822
13077
|
}
|
|
12823
13078
|
function prismaPackages(worktree, io) {
|
|
12824
|
-
const exists = io.exists ??
|
|
13079
|
+
const exists = io.exists ?? existsSync16;
|
|
12825
13080
|
const readText = io.readText ?? safeReadText;
|
|
12826
13081
|
const listDirs = io.listDirs ?? safeListDirs;
|
|
12827
13082
|
const dirs = [worktree, ...workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs })];
|
|
12828
|
-
return dirs.filter((dir) => exists(
|
|
13083
|
+
return dirs.filter((dir) => exists(join26(dir, "prisma", "schema.prisma")) && listDirs(join26(dir, "prisma", "migrations")).length > 0);
|
|
12829
13084
|
}
|
|
12830
13085
|
function jsExecBin(pm, command) {
|
|
12831
13086
|
switch (pm) {
|
|
@@ -12855,25 +13110,25 @@ function migrateCommands(worktree, pm, io) {
|
|
|
12855
13110
|
var ENV_DEFINING_FILES = ["pnpm-lock.yaml", "package-lock.json", "yarn.lock", "bun.lock", "bun.lockb", "deno.lock", "pnpm-workspace.yaml"];
|
|
12856
13111
|
function envCachePlan(worktree, io = {}) {
|
|
12857
13112
|
if (!ENV_CACHE_ENABLED) return null;
|
|
12858
|
-
const exists = io.exists ??
|
|
13113
|
+
const exists = io.exists ?? existsSync16;
|
|
12859
13114
|
const readText = io.readText ?? safeReadText;
|
|
12860
13115
|
const listDirs = io.listDirs ?? safeListDirs;
|
|
12861
13116
|
const pm = detectPackageManager(worktree, io);
|
|
12862
13117
|
if (!pm) return null;
|
|
12863
13118
|
const parts = [`pm:${pm}`];
|
|
12864
13119
|
for (const name of ENV_DEFINING_FILES) {
|
|
12865
|
-
const raw = readText(
|
|
13120
|
+
const raw = readText(join26(worktree, name));
|
|
12866
13121
|
if (raw !== null) parts.push(`${name}
|
|
12867
13122
|
${raw}`);
|
|
12868
13123
|
}
|
|
12869
13124
|
const pkgDirs = workspaceDirs(worktree, workspaceGlobs(worktree, readText), { exists, listDirs });
|
|
12870
13125
|
const rels = pkgDirs.map((dir) => dir.slice(worktree.length + 1)).sort();
|
|
12871
13126
|
for (const rel of ["", ...rels]) {
|
|
12872
|
-
const raw = readText(
|
|
13127
|
+
const raw = readText(join26(worktree, rel, "package.json"));
|
|
12873
13128
|
if (raw !== null) parts.push(`${rel}/package.json
|
|
12874
13129
|
${raw}`);
|
|
12875
13130
|
}
|
|
12876
|
-
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) =>
|
|
13131
|
+
return { key: fingerprint(parts), dirs: ["node_modules", ...rels.map((rel) => join26(rel, "node_modules"))] };
|
|
12877
13132
|
}
|
|
12878
13133
|
function planPrepare(worktree, io = {}) {
|
|
12879
13134
|
const plan = overridePlan(io.override) ?? detectPlan(worktree, io) ?? ciWorkflowPlan(worktree, io);
|
|
@@ -12881,7 +13136,7 @@ function planPrepare(worktree, io = {}) {
|
|
|
12881
13136
|
return { ...plan, commands: plan.commands.slice(0, MAX_PLAN_COMMANDS) };
|
|
12882
13137
|
}
|
|
12883
13138
|
async function ensureWorktreeDeps(worktree, io = {}) {
|
|
12884
|
-
const exists = io.exists ??
|
|
13139
|
+
const exists = io.exists ?? existsSync16;
|
|
12885
13140
|
const exec = io.exec ?? ((cmd) => runCommand(cmd, worktree));
|
|
12886
13141
|
const approve = io.approve ?? (() => true);
|
|
12887
13142
|
const cachePlan = envCachePlan(worktree, io);
|
|
@@ -12898,7 +13153,7 @@ async function ensureWorktreeDeps(worktree, io = {}) {
|
|
|
12898
13153
|
restored: [],
|
|
12899
13154
|
cached: false
|
|
12900
13155
|
};
|
|
12901
|
-
if (cachePlan && !exists(
|
|
13156
|
+
if (cachePlan && !exists(join26(worktree, "node_modules"))) {
|
|
12902
13157
|
report.restored = await restoreEnvSnapshot(worktree, cachePlan.key, cacheIO) ?? [];
|
|
12903
13158
|
}
|
|
12904
13159
|
const plan = planPrepare(worktree, io);
|
|
@@ -12985,10 +13240,17 @@ function depsPromptNotice(report) {
|
|
|
12985
13240
|
|
|
12986
13241
|
// src/orchestrator.ts
|
|
12987
13242
|
init_config();
|
|
12988
|
-
import { existsSync as
|
|
12989
|
-
import { join as
|
|
13243
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync11, rmSync as rmSync3 } from "fs";
|
|
13244
|
+
import { join as join27, dirname as dirname4 } from "path";
|
|
13245
|
+
function droneLaunchedText(workdir, pid) {
|
|
13246
|
+
return `\u0434\u0440\u043E\u043D \u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0432 ${workdir} (pid ${pid})`;
|
|
13247
|
+
}
|
|
13248
|
+
function droneLaunchedPid(text) {
|
|
13249
|
+
const m = /^дрон запущен в .* \(pid (\d+)\)$/.exec(text ?? "");
|
|
13250
|
+
return m ? Number(m[1]) : null;
|
|
13251
|
+
}
|
|
12990
13252
|
function repolessRunDir(worktreesDir, taskSlug) {
|
|
12991
|
-
return
|
|
13253
|
+
return join27(dirname4(worktreesDir), "runs", taskSlug);
|
|
12992
13254
|
}
|
|
12993
13255
|
var WORKTREE_HELD_STATUSES = /* @__PURE__ */ new Set(["running", "blocked", "review", "paused", "storm_dead"]);
|
|
12994
13256
|
function worktreePathHeldLive(db, path, exceptRunId) {
|
|
@@ -13045,17 +13307,17 @@ function healTaskSlug(db, run2, task) {
|
|
|
13045
13307
|
async function spawnDrone(deps, run2) {
|
|
13046
13308
|
if (run2.repoless) {
|
|
13047
13309
|
const workdir = repolessRunDir(deps.worktreesDir, run2.task_slug);
|
|
13048
|
-
if (
|
|
13310
|
+
if (existsSync17(workdir)) {
|
|
13049
13311
|
rmSync3(workdir, { recursive: true, force: true });
|
|
13050
13312
|
deps.db.addEvent(run2.id, "step", `\u0440\u0435\u043A\u043B\u0435\u0439\u043C \u043E\u0441\u0438\u0440\u043E\u0442\u0435\u0432\u0448\u0435\u0433\u043E \u0441\u043A\u0440\u0430\u0442\u0447-\u043A\u0430\u0442\u0430\u043B\u043E\u0433\u0430 ${workdir} (\u0434\u0435\u0440\u0436\u0430\u043B \u043C\u0451\u0440\u0442\u0432\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D)`);
|
|
13051
13313
|
}
|
|
13052
|
-
|
|
13314
|
+
mkdirSync11(workdir, { recursive: true });
|
|
13053
13315
|
if (run2.area && deps.db.runningAreas("").includes(run2.area)) throw new AreaBusyError(run2.area);
|
|
13054
13316
|
deps.db.addEvent(run2.id, "step", `repoless-\u043F\u0440\u043E\u0433\u043E\u043D: \u0441\u043A\u0440\u0430\u0442\u0447-\u043A\u0430\u0442\u0430\u043B\u043E\u0433 ${workdir} (\u0431\u0435\u0437 worktree/\u0432\u0435\u0442\u043A\u0438/PR \u2014 TASWM-595)`);
|
|
13055
13317
|
const built2 = await deps.buildPrompt(run2, workdir);
|
|
13056
13318
|
assertStillWanted(deps.db, run2.id);
|
|
13057
13319
|
const pid2 = deps.launch({ worktree: workdir, run: run2, prompt: built2 });
|
|
13058
|
-
deps.db.addEvent(run2.id, "step",
|
|
13320
|
+
deps.db.addEvent(run2.id, "step", droneLaunchedText(workdir, pid2));
|
|
13059
13321
|
return deps.db.updateRun(run2.id, {
|
|
13060
13322
|
status: "running",
|
|
13061
13323
|
worktree_path: workdir,
|
|
@@ -13091,7 +13353,7 @@ async function spawnDrone(deps, run2) {
|
|
|
13091
13353
|
${notice}` : built;
|
|
13092
13354
|
assertStillWanted(deps.db, run2.id);
|
|
13093
13355
|
const pid = deps.launch({ worktree, run: run2, prompt });
|
|
13094
|
-
deps.db.addEvent(run2.id, "step",
|
|
13356
|
+
deps.db.addEvent(run2.id, "step", droneLaunchedText(worktree, pid));
|
|
13095
13357
|
return deps.db.updateRun(run2.id, {
|
|
13096
13358
|
status: "running",
|
|
13097
13359
|
repo,
|
|
@@ -13266,7 +13528,7 @@ function parkReasonUnretriable(reason) {
|
|
|
13266
13528
|
// package.json
|
|
13267
13529
|
var package_default = {
|
|
13268
13530
|
name: "@taskless-app/swarm",
|
|
13269
|
-
version: "0.6.
|
|
13531
|
+
version: "0.6.82",
|
|
13270
13532
|
type: "module",
|
|
13271
13533
|
description: "Local control plane for a fleet of AI coding agents (drones), coordinating through Taskless. The overmind runs the swarm.",
|
|
13272
13534
|
keywords: [
|
|
@@ -13318,7 +13580,7 @@ var package_default = {
|
|
|
13318
13580
|
undici: "^7.30.1",
|
|
13319
13581
|
zod: "3.25.76"
|
|
13320
13582
|
},
|
|
13321
|
-
gitHead: "
|
|
13583
|
+
gitHead: "1ca25b5c37db968ab99a966201fd4a1dd35a2ac1"
|
|
13322
13584
|
};
|
|
13323
13585
|
|
|
13324
13586
|
// src/version.ts
|
|
@@ -13789,21 +14051,51 @@ function parseFindingsBlock(body) {
|
|
|
13789
14051
|
return { findings, mode };
|
|
13790
14052
|
}
|
|
13791
14053
|
var realCommentsRunner = (prUrl) => runGh(["pr", "view", prUrl, "--json", "comments"], GH_CALL_TIMEOUT_MS);
|
|
13792
|
-
var
|
|
13793
|
-
|
|
14054
|
+
var CHANGES_FIRST_LINE_RE = new RegExp(
|
|
14055
|
+
[
|
|
14056
|
+
"^#\\d+:\\s*CHANGES\\b",
|
|
14057
|
+
"^#\\d+\\s+\u043A\u0440\u0443\u0433\\s+\\d+\\s*:\\s*CHANGES\\b",
|
|
14058
|
+
"^\u041D\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0435 \u0440\u0435\u0432\u044C\u044E\\s*[\u2014\u2013-]\\s*CHANGES\\b",
|
|
14059
|
+
"^(?:\u274C\\s*)?(?:\\*\\*)?REQUEST(?:ED)?\\s+CHANGES(?:\\*\\*)?\\b",
|
|
14060
|
+
"^(?:\\*\\*)?CHANGES(?:\\s+REQUESTED)?(?:\\*\\*)?(?=\\s*(?:$|[:.!(\u2014\u2013-]))",
|
|
14061
|
+
'^[\xAB"]?\u043D\u0443\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u043A\u0438[\xBB"]?(?=\\s*(?:$|[:.!(\u2014\u2013-]))'
|
|
14062
|
+
].join("|"),
|
|
14063
|
+
"iu"
|
|
14064
|
+
);
|
|
14065
|
+
var APPROVE_FIRST_LINE_RE = /^(?:✅\s*)?(?:\*\*)?(?:APPROVED?|LGTM)(?:\*\*)?\b/iu;
|
|
14066
|
+
function firstContentLine(body) {
|
|
14067
|
+
for (const line of body.split(/\r?\n/)) {
|
|
14068
|
+
const trimmed = line.trim();
|
|
14069
|
+
if (trimmed) return trimmed;
|
|
14070
|
+
}
|
|
14071
|
+
return "";
|
|
14072
|
+
}
|
|
14073
|
+
function classifyPrVerdict(body) {
|
|
14074
|
+
const line = firstContentLine(body);
|
|
14075
|
+
if (!line) return null;
|
|
14076
|
+
if (line.includes(DRONE_COMMENT_SIGNATURE)) return null;
|
|
14077
|
+
if (CHANGES_FIRST_LINE_RE.test(line)) return "changes";
|
|
14078
|
+
if (APPROVE_FIRST_LINE_RE.test(line)) return "approve";
|
|
14079
|
+
return null;
|
|
14080
|
+
}
|
|
13794
14081
|
function verdictLabel(verdict) {
|
|
13795
14082
|
return verdict === "approve" ? "\u2705 APPROVE" : "\u274C REQUEST CHANGES";
|
|
13796
14083
|
}
|
|
13797
14084
|
async function latestVerdictComment(prUrl, sinceIso, run2 = realCommentsRunner) {
|
|
13798
14085
|
const found = await scanPrComments(prUrl, sinceIso, run2, (body) => {
|
|
13799
|
-
const
|
|
13800
|
-
if (!
|
|
13801
|
-
const verdict = APPROVE_RE.test(m[1]) ? "approve" : "changes";
|
|
14086
|
+
const verdict = classifyPrVerdict(body);
|
|
14087
|
+
if (!verdict) return null;
|
|
13802
14088
|
const { findings, mode } = parseFindingsBlock(body);
|
|
13803
14089
|
return { verdict, findings, reviewMode: mode };
|
|
13804
14090
|
});
|
|
13805
14091
|
if (!found) return null;
|
|
13806
|
-
return {
|
|
14092
|
+
return {
|
|
14093
|
+
verdict: found.verdict.verdict,
|
|
14094
|
+
createdAt: found.createdAt,
|
|
14095
|
+
body: found.body,
|
|
14096
|
+
findings: found.verdict.findings,
|
|
14097
|
+
reviewMode: found.verdict.reviewMode
|
|
14098
|
+
};
|
|
13807
14099
|
}
|
|
13808
14100
|
async function scanPrComments(prUrl, sinceIso, run2, pick4) {
|
|
13809
14101
|
if (!isGithubPrUrl(prUrl)) return null;
|
|
@@ -13827,12 +14119,14 @@ async function scanPrComments(prUrl, sinceIso, run2, pick4) {
|
|
|
13827
14119
|
if (Number.isFinite(sinceMs) && Date.parse(c.createdAt) < sinceMs) continue;
|
|
13828
14120
|
const verdict = pick4(c.body);
|
|
13829
14121
|
if (verdict == null) continue;
|
|
13830
|
-
return { verdict, createdAt: c.createdAt };
|
|
14122
|
+
return { verdict, createdAt: c.createdAt, body: c.body };
|
|
13831
14123
|
}
|
|
13832
14124
|
return null;
|
|
13833
14125
|
}
|
|
13834
14126
|
async function latestVerifyVerdictComment(prUrl, sinceIso, run2 = realCommentsRunner) {
|
|
13835
|
-
|
|
14127
|
+
const found = await scanPrComments(prUrl, sinceIso, run2, (body) => parseVerifyVerdictComment(body));
|
|
14128
|
+
if (!found) return null;
|
|
14129
|
+
return { verdict: found.verdict, createdAt: found.createdAt, body: found.body };
|
|
13836
14130
|
}
|
|
13837
14131
|
var realPrCommitsRunner = (prUrl) => runGh(["pr", "view", prUrl, "--json", "commits"], GH_CALL_TIMEOUT_MS);
|
|
13838
14132
|
async function prHasCommitsSince(prUrl, sinceIso, run2 = realPrCommitsRunner) {
|
|
@@ -14106,8 +14400,8 @@ import { z } from "zod";
|
|
|
14106
14400
|
init_git();
|
|
14107
14401
|
|
|
14108
14402
|
// src/diff.ts
|
|
14109
|
-
import { statSync as
|
|
14110
|
-
import { join as
|
|
14403
|
+
import { statSync as statSync14 } from "fs";
|
|
14404
|
+
import { join as join32 } from "path";
|
|
14111
14405
|
import { $ as $4 } from "execa";
|
|
14112
14406
|
var MAX_FILES = 200;
|
|
14113
14407
|
var MAX_LINES_PER_FILE = 1500;
|
|
@@ -14250,7 +14544,7 @@ async function resolveBase(wt, baseBranch) {
|
|
|
14250
14544
|
}
|
|
14251
14545
|
function mtime(path) {
|
|
14252
14546
|
try {
|
|
14253
|
-
return
|
|
14547
|
+
return statSync14(path).mtimeMs;
|
|
14254
14548
|
} catch {
|
|
14255
14549
|
return 0;
|
|
14256
14550
|
}
|
|
@@ -14275,7 +14569,7 @@ async function collectRunDiff(worktree, opts = {}) {
|
|
|
14275
14569
|
files.push(pf);
|
|
14276
14570
|
}
|
|
14277
14571
|
}
|
|
14278
|
-
files.sort((a, b) => mtime(
|
|
14572
|
+
files.sort((a, b) => mtime(join32(worktree, b.path)) - mtime(join32(worktree, a.path)));
|
|
14279
14573
|
const truncatedFiles = files.length > MAX_FILES;
|
|
14280
14574
|
if (truncatedFiles) files = files.slice(0, MAX_FILES);
|
|
14281
14575
|
const added = files.reduce((s, f) => s + f.added, 0);
|
|
@@ -15660,7 +15954,9 @@ function buildAnomalyCandidates(db, now, thresholds, opts) {
|
|
|
15660
15954
|
runId: run2.id,
|
|
15661
15955
|
level: repeat ? "decision" : "feed",
|
|
15662
15956
|
title: runTitle(run2, "\u0434\u0440\u043E\u043D \u0437\u0430\u0432\u0438\u0441"),
|
|
15663
|
-
|
|
15957
|
+
// Причина остановки (если есть) — как у spawn_parked ниже: без неё человек видит «дрон
|
|
15958
|
+
// завис» и не знает, что фикс-дрон умер, не сдав коммитов (TASWM-620).
|
|
15959
|
+
body: `${droneOf(run2)}: \u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0435 \u0438\u0441\u0447\u0435\u0440\u043F\u0430\u043D\u043E, \u043F\u0440\u043E\u0433\u043E\u043D \u0441\u0442\u043E\u0438\u0442.${run2.stop_reason ? ` \u041F\u0440\u0438\u0447\u0438\u043D\u0430: ${run2.stop_reason}.` : ""}${repeat ? " \u041F\u043E \u044D\u0442\u043E\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u044D\u0442\u043E \u0443\u0436\u0435 \u0432\u0442\u043E\u0440\u043E\u0439 \u0437\u0430\u0445\u043E\u0434 \u2014 \u0441\u0430\u043C \u043F\u043E \u0441\u0435\u0431\u0435 \u043E\u043D \u043D\u0435 \u0440\u0430\u0437\u043E\u0439\u0434\u0451\u0442\u0441\u044F, \u043D\u0443\u0436\u0435\u043D \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440." : ""}`,
|
|
15664
15960
|
...hrefOf(run2.task_url)
|
|
15665
15961
|
})
|
|
15666
15962
|
});
|
|
@@ -16691,22 +16987,23 @@ async function prodClearMergeIntent(runId, deps = {}) {
|
|
|
16691
16987
|
}
|
|
16692
16988
|
|
|
16693
16989
|
// src/envGate.ts
|
|
16694
|
-
import { existsSync as
|
|
16695
|
-
import { join as
|
|
16990
|
+
import { existsSync as existsSync20 } from "fs";
|
|
16991
|
+
import { join as join34 } from "path";
|
|
16696
16992
|
import { createConnection } from "net";
|
|
16697
16993
|
import { execa as execa2 } from "execa";
|
|
16698
16994
|
|
|
16699
16995
|
// src/platform.ts
|
|
16700
|
-
|
|
16701
|
-
import {
|
|
16996
|
+
init_src();
|
|
16997
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync19, readFileSync as readFileSync24, realpathSync as realpathSync3 } from "fs";
|
|
16998
|
+
import { delimiter as delimiter2, join as join33, posix as posix2, win32 } from "path";
|
|
16702
16999
|
function resolveCommandPath(name, env = process.env, platform = process.platform) {
|
|
16703
|
-
if (name.includes("/") || name.includes("\\")) return
|
|
17000
|
+
if (name.includes("/") || name.includes("\\")) return existsSync19(name) ? name : null;
|
|
16704
17001
|
const dirs = (env.PATH ?? env.Path ?? "").split(delimiter2).filter(Boolean);
|
|
16705
17002
|
const exts = platform === "win32" ? (env.PATHEXT ?? ".EXE;.CMD;.BAT").split(";").filter(Boolean) : [""];
|
|
16706
17003
|
for (const dir of dirs) {
|
|
16707
17004
|
for (const ext of exts) {
|
|
16708
|
-
const candidate =
|
|
16709
|
-
if (
|
|
17005
|
+
const candidate = join33(dir, name + ext);
|
|
17006
|
+
if (existsSync19(candidate)) return candidate;
|
|
16710
17007
|
}
|
|
16711
17008
|
}
|
|
16712
17009
|
return null;
|
|
@@ -16727,7 +17024,11 @@ function detectGlobalPm(entry, io = {}) {
|
|
|
16727
17024
|
const has2 = io.hasCommand ?? ((n) => hasCommandInPath(n, env, platform));
|
|
16728
17025
|
return has2("npm") ? "npm" : "unknown";
|
|
16729
17026
|
}
|
|
16730
|
-
function
|
|
17027
|
+
function quotePrefix(prefix, platform) {
|
|
17028
|
+
if (platform === "win32") return `"${prefix}"`;
|
|
17029
|
+
return `'${prefix.replaceAll("'", "'\\''")}'`;
|
|
17030
|
+
}
|
|
17031
|
+
function globalInstallCommand(pm, spec, prefix, platform = process.platform) {
|
|
16731
17032
|
switch (pm) {
|
|
16732
17033
|
case "pnpm":
|
|
16733
17034
|
return `pnpm add -g ${spec}`;
|
|
@@ -16736,8 +17037,90 @@ function globalInstallCommand(pm, spec) {
|
|
|
16736
17037
|
case "yarn":
|
|
16737
17038
|
return `yarn global add ${spec}`;
|
|
16738
17039
|
default:
|
|
16739
|
-
return `npm i -g ${spec}`;
|
|
17040
|
+
return prefix ? `npm i -g --prefix ${quotePrefix(prefix, platform)} ${spec}` : `npm i -g ${spec}`;
|
|
17041
|
+
}
|
|
17042
|
+
}
|
|
17043
|
+
var UNIX_MARKER = "/lib/node_modules/@taskless-app/swarm";
|
|
17044
|
+
var WIN_MARKER = "/node_modules/@taskless-app/swarm";
|
|
17045
|
+
function resolveReal(entry, io) {
|
|
17046
|
+
const realpath = io.realpath ?? realpathSync3;
|
|
17047
|
+
try {
|
|
17048
|
+
return realpath(entry);
|
|
17049
|
+
} catch {
|
|
17050
|
+
return entry;
|
|
17051
|
+
}
|
|
17052
|
+
}
|
|
17053
|
+
function npmInstallLocation(entry, io = {}) {
|
|
17054
|
+
if (!entry) return null;
|
|
17055
|
+
const platform = io.platform ?? process.platform;
|
|
17056
|
+
const real = resolveReal(entry, io);
|
|
17057
|
+
const norm = real.replace(/\\/g, "/");
|
|
17058
|
+
if (norm.includes("/_npx/") && norm.includes("/@taskless-app/swarm")) return { kind: "npx" };
|
|
17059
|
+
const marker = platform === "win32" ? WIN_MARKER : UNIX_MARKER;
|
|
17060
|
+
const at = norm.indexOf(marker);
|
|
17061
|
+
if (at < 0) return null;
|
|
17062
|
+
const next = norm[at + marker.length];
|
|
17063
|
+
if (next !== void 0 && next !== "/") return null;
|
|
17064
|
+
let prefix = real.slice(0, at);
|
|
17065
|
+
if (prefix === "") prefix = platform === "win32" ? "" : "/";
|
|
17066
|
+
if (!prefix) return null;
|
|
17067
|
+
const path = platform === "win32" ? win32 : posix2;
|
|
17068
|
+
const modulesDir = platform === "win32" ? path.join(prefix, "node_modules") : path.join(prefix, "lib", "node_modules");
|
|
17069
|
+
return { kind: "prefix", prefix, modulesDir };
|
|
17070
|
+
}
|
|
17071
|
+
function dirWritable(dir, platform, access) {
|
|
17072
|
+
const path = platform === "win32" ? win32 : posix2;
|
|
17073
|
+
let current = dir;
|
|
17074
|
+
for (; ; ) {
|
|
17075
|
+
try {
|
|
17076
|
+
access(current, constants2.W_OK);
|
|
17077
|
+
return true;
|
|
17078
|
+
} catch (e) {
|
|
17079
|
+
const code = e && typeof e === "object" && "code" in e ? e.code : void 0;
|
|
17080
|
+
if (code !== "ENOENT") return false;
|
|
17081
|
+
const parent = path.dirname(current);
|
|
17082
|
+
if (parent === current) return false;
|
|
17083
|
+
current = parent;
|
|
17084
|
+
}
|
|
17085
|
+
}
|
|
17086
|
+
}
|
|
17087
|
+
var LATEST_INSTALL = `npm i -g ${SWARM_PACKAGE_NAME}@latest`;
|
|
17088
|
+
function npxRefusal() {
|
|
17089
|
+
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}`;
|
|
17090
|
+
}
|
|
17091
|
+
function unwritableRefusal(modulesDir, prefix, platform = process.platform) {
|
|
17092
|
+
const sudoInstall = `sudo ${globalInstallCommand("npm", `${SWARM_PACKAGE_NAME}@latest`, prefix, platform)}`;
|
|
17093
|
+
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.`;
|
|
17094
|
+
}
|
|
17095
|
+
function gatePackageInstall(pm, spec, entry, io = {}) {
|
|
17096
|
+
if (pm === "pnpm" || pm === "bun" || pm === "yarn") {
|
|
17097
|
+
return { action: "run", command: globalInstallCommand(pm, spec) };
|
|
17098
|
+
}
|
|
17099
|
+
if (pm === "sources") {
|
|
17100
|
+
return { action: "run", command: globalInstallCommand("npm", spec) };
|
|
17101
|
+
}
|
|
17102
|
+
const loc = npmInstallLocation(entry, io);
|
|
17103
|
+
if (loc?.kind === "npx") return { action: "refuse", kind: "npx", message: npxRefusal() };
|
|
17104
|
+
if (loc?.kind === "prefix") {
|
|
17105
|
+
const platform = io.platform ?? process.platform;
|
|
17106
|
+
const access = io.access ?? accessSync2;
|
|
17107
|
+
if (!dirWritable(loc.modulesDir, platform, access)) {
|
|
17108
|
+
return { action: "refuse", kind: "unwritable", message: unwritableRefusal(loc.modulesDir, loc.prefix, platform) };
|
|
17109
|
+
}
|
|
17110
|
+
return { action: "run", command: globalInstallCommand("npm", spec, loc.prefix, platform) };
|
|
16740
17111
|
}
|
|
17112
|
+
return { action: "run", command: globalInstallCommand("npm", spec) };
|
|
17113
|
+
}
|
|
17114
|
+
function npmFailureCode(output) {
|
|
17115
|
+
const plain = output.replace(/\u001b\[[0-9;]*m/g, "");
|
|
17116
|
+
const tagged = plain.match(/(?:npm ERR!|npm error) code ([A-Z][A-Z0-9_]*)/);
|
|
17117
|
+
if (tagged?.[1]) return tagged[1];
|
|
17118
|
+
const bare = plain.match(/\bError: ([A-Z][A-Z0-9_]*):/);
|
|
17119
|
+
return bare?.[1] ?? null;
|
|
17120
|
+
}
|
|
17121
|
+
function installFailureLabel(exitCode, output) {
|
|
17122
|
+
const code = npmFailureCode(output);
|
|
17123
|
+
return code ? `${code}, \u043A\u043E\u0434 ${exitCode}` : `\u043A\u043E\u0434 ${exitCode}`;
|
|
16741
17124
|
}
|
|
16742
17125
|
|
|
16743
17126
|
// src/envGate.ts
|
|
@@ -16789,8 +17172,8 @@ var COMPOSE_MARKERS = [
|
|
|
16789
17172
|
"compose.yaml"
|
|
16790
17173
|
];
|
|
16791
17174
|
function detectRequirements(repo, io = {}) {
|
|
16792
|
-
const exists = io.exists ??
|
|
16793
|
-
const marker = COMPOSE_MARKERS.find((f) => exists(
|
|
17175
|
+
const exists = io.exists ?? existsSync20;
|
|
17176
|
+
const marker = COMPOSE_MARKERS.find((f) => exists(join34(repo, f)));
|
|
16794
17177
|
return marker ? [{ kind: "docker", raw: `docker (\u0434\u0435\u0442\u0435\u043A\u0442: ${marker})` }] : [];
|
|
16795
17178
|
}
|
|
16796
17179
|
function resolveRequirements(repo, declared, io = {}) {
|
|
@@ -18546,21 +18929,21 @@ function closeWebServer(server) {
|
|
|
18546
18929
|
|
|
18547
18930
|
// src/hostCommands.ts
|
|
18548
18931
|
init_src();
|
|
18549
|
-
import { readFileSync as
|
|
18550
|
-
import { join as
|
|
18932
|
+
import { readFileSync as readFileSync25, renameSync as renameSync10, writeFileSync as writeFileSync17 } from "fs";
|
|
18933
|
+
import { join as join35 } from "path";
|
|
18551
18934
|
function hostCommandStatePath(home) {
|
|
18552
|
-
return
|
|
18935
|
+
return join35(home, "host-command.json");
|
|
18553
18936
|
}
|
|
18554
18937
|
function readState(path) {
|
|
18555
18938
|
try {
|
|
18556
|
-
return JSON.parse(
|
|
18939
|
+
return JSON.parse(readFileSync25(path, "utf8"));
|
|
18557
18940
|
} catch {
|
|
18558
18941
|
return {};
|
|
18559
18942
|
}
|
|
18560
18943
|
}
|
|
18561
18944
|
function writeState(path, state) {
|
|
18562
18945
|
try {
|
|
18563
|
-
|
|
18946
|
+
writeFileSync17(`${path}.tmp`, JSON.stringify(state));
|
|
18564
18947
|
renameSync10(`${path}.tmp`, path);
|
|
18565
18948
|
} catch {
|
|
18566
18949
|
}
|
|
@@ -18723,9 +19106,29 @@ async function doRestart(cmd, opts, note) {
|
|
|
18723
19106
|
|
|
18724
19107
|
// src/selfUpdate.ts
|
|
18725
19108
|
init_git();
|
|
18726
|
-
import { existsSync as
|
|
18727
|
-
import { join as
|
|
19109
|
+
import { existsSync as existsSync21 } from "fs";
|
|
19110
|
+
import { join as join36 } from "path";
|
|
18728
19111
|
import { $ as $5 } from "execa";
|
|
19112
|
+
|
|
19113
|
+
// src/cliIo.ts
|
|
19114
|
+
import { createInterface } from "readline/promises";
|
|
19115
|
+
import { execa as execa3 } from "execa";
|
|
19116
|
+
function readCommandOutcome(result) {
|
|
19117
|
+
if (typeof result === "number") return { exitCode: result, output: "" };
|
|
19118
|
+
return { exitCode: result.exitCode, output: `${result.stdout ?? ""}
|
|
19119
|
+
${result.stderr ?? ""}` };
|
|
19120
|
+
}
|
|
19121
|
+
async function execCaptured(command) {
|
|
19122
|
+
const res = await execa3(command, {
|
|
19123
|
+
shell: true,
|
|
19124
|
+
reject: false,
|
|
19125
|
+
stdout: ["pipe", "inherit"],
|
|
19126
|
+
stderr: ["pipe", "inherit"]
|
|
19127
|
+
});
|
|
19128
|
+
return { exitCode: res.exitCode ?? 1, stdout: res.stdout ?? "", stderr: res.stderr ?? "" };
|
|
19129
|
+
}
|
|
19130
|
+
|
|
19131
|
+
// src/selfUpdate.ts
|
|
18729
19132
|
var DAEMON_PACKAGE = "@taskless-app/swarm";
|
|
18730
19133
|
var defaultRun = async (cmd, args, cwd) => {
|
|
18731
19134
|
const res = await $5({ reject: false, cwd })(cmd, args);
|
|
@@ -18737,7 +19140,7 @@ function tail(text, max = 400) {
|
|
|
18737
19140
|
}
|
|
18738
19141
|
async function runSelfUpdate(io) {
|
|
18739
19142
|
const run2 = io.run ?? defaultRun;
|
|
18740
|
-
const exists = io.exists ??
|
|
19143
|
+
const exists = io.exists ?? existsSync21;
|
|
18741
19144
|
const repo = io.repo;
|
|
18742
19145
|
await io.onStep("fetch", "\u0442\u044F\u043D\u0443 \u0441\u0432\u0435\u0436\u0438\u0439 \u043A\u043E\u0434");
|
|
18743
19146
|
const fetched = await run2("git", ["-C", repo, "fetch", "--quiet", "origin"], repo);
|
|
@@ -18766,7 +19169,7 @@ async function runSelfUpdate(io) {
|
|
|
18766
19169
|
};
|
|
18767
19170
|
}
|
|
18768
19171
|
await io.onStep("install", "\u0441\u0442\u0430\u0432\u043B\u044E \u0437\u0430\u0432\u0438\u0441\u0438\u043C\u043E\u0441\u0442\u0438");
|
|
18769
|
-
if (!exists(
|
|
19172
|
+
if (!exists(join36(repo, "pnpm-lock.yaml"))) {
|
|
18770
19173
|
return { ok: false, step: "install", message: "\u0432 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0438 \u0434\u0435\u043C\u043E\u043D\u0430 \u043D\u0435\u0442 pnpm-lock.yaml \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u044F\u0442\u044C \u0435\u0433\u043E \u044D\u0442\u0438\u043C \u043F\u0443\u0442\u0451\u043C \u043D\u0435 \u0431\u0435\u0440\u0443\u0441\u044C" };
|
|
18771
19174
|
}
|
|
18772
19175
|
const installed2 = await run2("pnpm", ["install", "--frozen-lockfile"], repo);
|
|
@@ -18786,6 +19189,11 @@ function defaultSelfUpdateIO(repo, onStep) {
|
|
|
18786
19189
|
return { repo, run: defaultRun, mainRef: remoteMainRef, onStep };
|
|
18787
19190
|
}
|
|
18788
19191
|
async function runPackageSelfUpdate(io) {
|
|
19192
|
+
const early = io.gate(`${SWARM_PACKAGE}@latest`);
|
|
19193
|
+
if (early.action === "refuse" && early.kind === "npx") {
|
|
19194
|
+
await io.onStep("install", "\u0437\u0430\u043F\u0443\u0449\u0435\u043D \u0447\u0435\u0440\u0435\u0437 npx");
|
|
19195
|
+
return { ok: false, step: "install", message: early.message };
|
|
19196
|
+
}
|
|
18789
19197
|
await io.onStep("fetch", "\u0441\u043C\u043E\u0442\u0440\u044E, \u0447\u0442\u043E \u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u043E");
|
|
18790
19198
|
const latest = await io.latest();
|
|
18791
19199
|
if (!latest) {
|
|
@@ -18795,22 +19203,23 @@ async function runPackageSelfUpdate(io) {
|
|
|
18795
19203
|
return { ok: true, restart: false, step: "install", message: `\u0443\u0436\u0435 \u0441\u0432\u0435\u0436\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F: v${io.currentVersion} (\u043E\u043F\u0443\u0431\u043B\u0438\u043A\u043E\u0432\u0430\u043D\u0430 v${latest})` };
|
|
18796
19204
|
}
|
|
18797
19205
|
await io.onStep("install", `\u0441\u0442\u0430\u0432\u043B\u044E v${latest}`);
|
|
18798
|
-
const
|
|
18799
|
-
const
|
|
18800
|
-
if (
|
|
18801
|
-
return { ok: false, step: "install", message:
|
|
19206
|
+
const spec = `${SWARM_PACKAGE}@${latest}`;
|
|
19207
|
+
const decided = io.gate(spec);
|
|
19208
|
+
if (decided.action === "refuse") {
|
|
19209
|
+
return { ok: false, step: "install", message: decided.message };
|
|
19210
|
+
}
|
|
19211
|
+
const command = decided.command;
|
|
19212
|
+
const ran = readCommandOutcome(await io.exec(command));
|
|
19213
|
+
if (ran.exitCode !== 0) {
|
|
19214
|
+
return {
|
|
19215
|
+
ok: false,
|
|
19216
|
+
step: "install",
|
|
19217
|
+
message: `\u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043A\u0430 \u043D\u0435 \u043F\u0440\u043E\u0448\u043B\u0430 (${installFailureLabel(ran.exitCode, ran.output)}): ${command} \u2014 \u0432\u044B\u043F\u043E\u043B\u043D\u0438 \u044D\u0442\u0443 \u0441\u0442\u0440\u043E\u043A\u0443 \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`
|
|
19218
|
+
};
|
|
18802
19219
|
}
|
|
18803
19220
|
return { ok: true, step: "install", message: `\u043E\u0431\u043D\u043E\u0432\u0438\u043B\u0441\u044F \u0434\u043E v${latest} (\u0431\u044B\u043B\u043E v${io.currentVersion})` };
|
|
18804
19221
|
}
|
|
18805
19222
|
|
|
18806
|
-
// src/cliIo.ts
|
|
18807
|
-
import { createInterface } from "readline/promises";
|
|
18808
|
-
import { execa as execa3 } from "execa";
|
|
18809
|
-
async function execLoud(command) {
|
|
18810
|
-
const res = await execa3(command, { shell: true, reject: false, stdio: "inherit" });
|
|
18811
|
-
return res.exitCode ?? 1;
|
|
18812
|
-
}
|
|
18813
|
-
|
|
18814
19223
|
// src/narration.ts
|
|
18815
19224
|
var RING_LIMIT = 20;
|
|
18816
19225
|
function makeOvermindNarrator() {
|
|
@@ -18931,19 +19340,19 @@ async function fetchExternalStorm(url, opts = {}) {
|
|
|
18931
19340
|
}
|
|
18932
19341
|
|
|
18933
19342
|
// src/anomalyState.ts
|
|
18934
|
-
import { existsSync as
|
|
18935
|
-
import { join as
|
|
19343
|
+
import { existsSync as existsSync22, readFileSync as readFileSync26, renameSync as renameSync11, writeFileSync as writeFileSync18 } from "fs";
|
|
19344
|
+
import { join as join37 } from "path";
|
|
18936
19345
|
var KEY_TTL_MS = 7 * 24 * 60 * 6e4;
|
|
18937
19346
|
var MAX_RESOLVED = 200;
|
|
18938
19347
|
function emptyState() {
|
|
18939
19348
|
return { since: {}, lastFiredAt: {}, fires: {}, resolved: [], stopQuiet: null };
|
|
18940
19349
|
}
|
|
18941
19350
|
function anomalyStatePath(home) {
|
|
18942
|
-
return
|
|
19351
|
+
return join37(home, "anomaly-state.json");
|
|
18943
19352
|
}
|
|
18944
19353
|
function loadAnomalyState(home, now = Date.now(), io = {}) {
|
|
18945
|
-
const exists = io.exists ??
|
|
18946
|
-
const readFile2 = io.readFile ?? ((p) =>
|
|
19354
|
+
const exists = io.exists ?? existsSync22;
|
|
19355
|
+
const readFile2 = io.readFile ?? ((p) => readFileSync26(p, "utf8"));
|
|
18947
19356
|
const path = anomalyStatePath(home);
|
|
18948
19357
|
if (!exists(path)) return emptyState();
|
|
18949
19358
|
try {
|
|
@@ -18973,7 +19382,7 @@ function loadAnomalyState(home, now = Date.now(), io = {}) {
|
|
|
18973
19382
|
function saveAnomalyState(home, state, io = {}) {
|
|
18974
19383
|
const path = anomalyStatePath(home);
|
|
18975
19384
|
const writeFile4 = io.writeFile ?? ((p, data) => {
|
|
18976
|
-
|
|
19385
|
+
writeFileSync18(`${p}.tmp`, data);
|
|
18977
19386
|
renameSync11(`${p}.tmp`, p);
|
|
18978
19387
|
});
|
|
18979
19388
|
writeFile4(path, JSON.stringify(state, null, 2));
|
|
@@ -19563,6 +19972,15 @@ var CHANGES_FRESH_WAKE_AFTER_MS = Number(process.env.SWARM_CHANGES_FRESH_WAKE_AF
|
|
|
19563
19972
|
var CHANGES_WAKE_MARK = "\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F \u043F\u043E \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0443 \xAB\u043D\u0443\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u043A\u0438\xBB";
|
|
19564
19973
|
var CHANGES_FIX_COST_MARK = "\u0442\u0440\u0430\u0442\u044B \u0434\u043E \u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438";
|
|
19565
19974
|
var CHANGES_WAKE_FAILED_MARK = "\u043F\u043E\u0431\u0443\u0434\u043A\u0430 \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C";
|
|
19975
|
+
var AUTHOR_LINGER_DEFAULT_MS = 5 * 60 * 1e3;
|
|
19976
|
+
var AUTHOR_LINGER_MIN_MS = 60 * 1e3;
|
|
19977
|
+
function authorLingerAfterPrMs(raw) {
|
|
19978
|
+
const n = Number(raw);
|
|
19979
|
+
if (!raw?.trim() || !Number.isFinite(n) || n <= 0) return AUTHOR_LINGER_DEFAULT_MS;
|
|
19980
|
+
return Math.max(AUTHOR_LINGER_MIN_MS, n);
|
|
19981
|
+
}
|
|
19982
|
+
var AUTHOR_LINGER_AFTER_PR_MS = authorLingerAfterPrMs(process.env.SWARM_AUTHOR_LINGER_AFTER_PR_MS);
|
|
19983
|
+
var AUTHOR_LINGER_MARK = "\u0430\u0432\u0442\u043E\u0440 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B \u0447\u0435\u0440\u0435\u0437";
|
|
19566
19984
|
var BUDGET_STOP_REASON = "\u043D\u0435 \u0443\u043B\u043E\u0436\u0438\u043B\u0441\u044F \u0432 \u043F\u043E\u0442\u043E\u043B\u043E\u043A \u0442\u0440\u0430\u0442: \u0441\u0435\u0441\u0441\u0438\u044E \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u043B \u0431\u044E\u0434\u0436\u0435\u0442 \u043F\u0440\u043E\u0433\u043E\u043D\u0430";
|
|
19567
19985
|
var NO_AUTO_WAKE_REASONS = [EXITED_NO_DONE_REASON, BUDGET_STOP_REASON, ABORTED_STOP_REASON, AWAITING_BUDGET_REASON, CYCLE_CAP_STOP_REASON];
|
|
19568
19986
|
var REVIEW_NO_VERDICT_REASON = "\u0440\u0435\u0432\u044C\u044E \u0437\u0430\u043A\u043E\u043D\u0447\u0438\u043B\u043E\u0441\u044C \u0431\u0435\u0437 \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0430: \u043D\u0438 approve, \u043D\u0438 changes \u2014 \u0437\u0430\u0441\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E, \u043D\u0443\u0436\u0435\u043D \u043D\u043E\u0432\u044B\u0439 \u0437\u0430\u0445\u043E\u0434 (TASWM-375)";
|
|
@@ -19582,7 +20000,15 @@ function worktreeFromCmd(args) {
|
|
|
19582
20000
|
const bare = quoted ? null : args.match(/--mcp-config\s+(\S+[/\\]\.swarm-mcp\.json)/);
|
|
19583
20001
|
const path = quoted?.[1] ?? bare?.[1];
|
|
19584
20002
|
if (path) return path.replace(/[/\\]\.swarm-mcp\.json$/, "");
|
|
19585
|
-
return worktreeFromGrokCwd(args);
|
|
20003
|
+
return worktreeFromGrokCwd(args) ?? worktreeFromKimiCmd(args);
|
|
20004
|
+
}
|
|
20005
|
+
function worktreeFromKimiCmd(args) {
|
|
20006
|
+
const trimmed = args.trim();
|
|
20007
|
+
const first = trimmed.startsWith('"') ? trimmed.slice(1, trimmed.indexOf('"', 1)) : trimmed.split(/\s/)[0] ?? "";
|
|
20008
|
+
if (!/(?:^|[\\/])kimi(?:\.exe)?$/i.test(first)) return null;
|
|
20009
|
+
const quoted = args.match(/--add-dir\s+"([^"]+)"/);
|
|
20010
|
+
const bare = quoted ? null : args.match(/--add-dir\s+(\S+)/);
|
|
20011
|
+
return quoted?.[1] ?? bare?.[1] ?? null;
|
|
19586
20012
|
}
|
|
19587
20013
|
function worktreeFromGrokCwd(args) {
|
|
19588
20014
|
const trimmed = args.trim();
|
|
@@ -19907,10 +20333,15 @@ async function prGateForReviewer(deps, run2, prUrl, when) {
|
|
|
19907
20333
|
return { kind: "wait" };
|
|
19908
20334
|
}
|
|
19909
20335
|
default:
|
|
19910
|
-
if (st.conflicting
|
|
20336
|
+
if (st.conflicting) {
|
|
19911
20337
|
deps.db.addEvent(run2.id, "step", `PR \u0441\u0442\u0430\u043B \u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442\u0443\u044E\u0449\u0438\u043C/\u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\u043E\u043C, ${when} \u2014 \u0441\u043F\u0430\u0432\u043D \u043E\u0442\u043B\u043E\u0436\u0435\u043D \u0434\u043E \u0441\u043B\u0435\u0434. \u0442\u0438\u043A\u0430`);
|
|
19912
20338
|
return { kind: "wait" };
|
|
19913
20339
|
}
|
|
20340
|
+
if (st.isDraft) {
|
|
20341
|
+
deps.db.addEvent(run2.id, "step", `PR \u0441\u0442\u0430\u043B \u043A\u043E\u043D\u0444\u043B\u0438\u043A\u0442\u0443\u044E\u0449\u0438\u043C/\u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\u043E\u043C, ${when} \u2014 \u0441\u043F\u0430\u0432\u043D \u043E\u0442\u043B\u043E\u0436\u0435\u043D \u0434\u043E \u0441\u043B\u0435\u0434. \u0442\u0438\u043A\u0430`);
|
|
20342
|
+
noteDraftHold(run2);
|
|
20343
|
+
return { kind: "wait" };
|
|
20344
|
+
}
|
|
19914
20345
|
return { kind: "spawn", st };
|
|
19915
20346
|
}
|
|
19916
20347
|
}
|
|
@@ -20116,6 +20547,12 @@ var VERIFY_SPAWN_LIMIT = Number(process.env.SWARM_VERIFY_SPAWN_LIMIT) || 2;
|
|
|
20116
20547
|
function countActiveVerifiers(db) {
|
|
20117
20548
|
return db.listRuns().filter((r) => r.kind === "verifier" && ACTIVE_DRONE_STATUSES.has(r.status)).length;
|
|
20118
20549
|
}
|
|
20550
|
+
async function rejectedHeadAllowsVerifier(deps, run2) {
|
|
20551
|
+
if (run2.review_verdict !== "changes") return true;
|
|
20552
|
+
const verdictAt = changesVerdictAt(deps.db, run2, deps.now ? deps.now() : Date.now());
|
|
20553
|
+
if (!verdictAt || !run2.pr_url || !deps.commitsSince) return false;
|
|
20554
|
+
return deps.commitsSince(run2.pr_url, verdictAt).catch(() => false);
|
|
20555
|
+
}
|
|
20119
20556
|
async function spawnVerifiersForOpenPrs(deps, stormActive) {
|
|
20120
20557
|
if (!deps.spawnVerifier) return;
|
|
20121
20558
|
if (stormActive) return;
|
|
@@ -20143,7 +20580,12 @@ async function spawnVerifiersForOpenPrs(deps, stormActive) {
|
|
|
20143
20580
|
if (!await projectWantsChecks(deps, run2)) continue;
|
|
20144
20581
|
const st = await deps.prStatus(run2.pr_url).catch(() => null);
|
|
20145
20582
|
if (prLiveness(st) !== "open") continue;
|
|
20146
|
-
if (st?.
|
|
20583
|
+
if (st?.conflicting) continue;
|
|
20584
|
+
if (!await rejectedHeadAllowsVerifier(deps, run2)) continue;
|
|
20585
|
+
if (st?.isDraft) {
|
|
20586
|
+
noteDraftHold(run2);
|
|
20587
|
+
continue;
|
|
20588
|
+
}
|
|
20147
20589
|
await deps.spawnVerifier(run2, st?.files ?? []);
|
|
20148
20590
|
narrate(deps, `PR ${droneLabel(run2)} \u043E\u0442\u043A\u0440\u044B\u0442 \u2014 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u044E \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430: \u043F\u0443\u0441\u0442\u044C \u043F\u043E\u043F\u0440\u043E\u0431\u0443\u0435\u0442 \u043E\u043F\u0440\u043E\u0432\u0435\u0440\u0433\u043D\u0443\u0442\u044C \u0437\u0430\u044F\u0432\u043B\u0435\u043D\u043D\u043E\u0435.`);
|
|
20149
20591
|
} catch (e) {
|
|
@@ -20204,6 +20646,7 @@ function buildCiReadyNudge(prUrl, over) {
|
|
|
20204
20646
|
"\u0412\u043E\u043F\u0440\u043E\u0441\u043E\u0432 \u0432 stdout \u043D\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0439 \u2014 \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0435\u0440\u0435\u0437 MCP-\u0442\u0443\u043B ask."
|
|
20205
20647
|
].join("\n");
|
|
20206
20648
|
}
|
|
20649
|
+
var SUBMISSION_REVIEW_STEP = "2. `/code-review --fix` \u2014 \u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u0440\u0435\u0432\u044C\u044E \u0441\u0432\u043E\u0435\u0433\u043E \u0434\u0438\u0444\u0444\u0430, \u043A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 \u2014 \u0432 skill `swarm-drone:taskless-review`; \u043F\u0440\u0438\u043C\u0435\u043D\u0451\u043D\u043D\u044B\u0435 \u043F\u0440\u0430\u0432\u043A\u0438 \u043F\u0435\u0440\u0435\u0447\u0438\u0442\u0430\u0439 \u0438 \u043F\u0435\u0440\u0435\u0443\u0431\u0435\u0434\u0438\u0441\u044C, \u0447\u0442\u043E \u043D\u0435 \u0441\u043B\u043E\u043C\u0430\u043B \u0444\u0438\u0447\u0443.";
|
|
20207
20650
|
function buildChangesFixPrompt(args) {
|
|
20208
20651
|
const { prUrl, slug, branch, base: base3, worktree, verdict } = args;
|
|
20209
20652
|
const baseRef = base3 ? `origin/${base3}` : "origin/HEAD";
|
|
@@ -20224,7 +20667,11 @@ function buildChangesFixPrompt(args) {
|
|
|
20224
20667
|
`\u0412\u0435\u0442\u043A\u0430: ${branch} (\u0431\u0430\u0437\u0430 ${baseRef}) \xB7 PR: ${prUrl}`,
|
|
20225
20668
|
`\u041A\u0430\u0442\u0430\u043B\u043E\u0433: ${worktree}`,
|
|
20226
20669
|
"",
|
|
20227
|
-
"## \
|
|
20670
|
+
"## \u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0435 \u043F\u0443\u043D\u043A\u0442\u044B",
|
|
20671
|
+
"\u041A\u0430\u0436\u0434\u044B\u0439 \u043F\u0443\u043D\u043A\u0442 \u0437\u0430\u043A\u0440\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u043C \u0438 \u0442\u0435\u0441\u0442\u043E\u043C \u043B\u0438\u0431\u043E \u044F\u0432\u043D\u044B\u043C \u043D\u0435\u0441\u043E\u0433\u043B\u0430\u0441\u0438\u0435\u043C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u043C \u0432 PR, \u0441 \u0434\u043E\u0432\u043E\u0434\u043E\u043C.",
|
|
20672
|
+
"\u041C\u043E\u043B\u0447\u0430 \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D\u043D\u044B\u0439 \u043F\u0443\u043D\u043A\u0442 \u2014 \u043D\u0435 \u0441\u0434\u0430\u043D\u043E.",
|
|
20673
|
+
"\u0415\u0441\u043B\u0438 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0434\u0430\u0451\u0442 \u0433\u043E\u0442\u043E\u0432\u043E\u0435 \u0440\u0435\u0448\u0435\u043D\u0438\u0435 (\xAB\u0441\u0434\u0435\u043B\u0430\u0439 \u0442\u0430\u043A\xBB), \u0432\u044B\u043F\u043E\u043B\u043D\u0438 \u0435\u0433\u043E \u043A\u0430\u043A \u043D\u0430\u043F\u0438\u0441\u0430\u043D\u043E, \u0430 \u043D\u0435 \u043F\u043E-\u0441\u0432\u043E\u0435\u043C\u0443.",
|
|
20674
|
+
"",
|
|
20228
20675
|
verdict ?? "\u0412\u0435\u0440\u0434\u0438\u043A\u0442 \u043D\u0435 \u0441\u043E\u0445\u0440\u0430\u043D\u0438\u043B\u0441\u044F \u0432 \u043B\u0435\u043D\u0442\u0435 \u2014 \u0447\u0438\u0442\u0430\u0439 \u0435\u0433\u043E \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C \u0432 PR (\u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043D\u0438\u0436\u0435).",
|
|
20229
20676
|
"",
|
|
20230
20677
|
"## \u0412\u0432\u0435\u0434\u0438 \u0441\u0435\u0431\u044F \u0432 \u043A\u0443\u0440\u0441 \u0421\u0410\u041C \u2014 \u043F\u0430\u043C\u044F\u0442\u0438 \u043F\u0440\u043E\u0448\u043B\u043E\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0443 \u0442\u0435\u0431\u044F \u043D\u0435\u0442",
|
|
@@ -20243,16 +20690,22 @@ function buildChangesFixPrompt(args) {
|
|
|
20243
20690
|
"`report_weight(note)` \u2014 \u0441\u043A\u0430\u0436\u0438, \u0447\u0442\u043E \u0440\u0430\u0431\u043E\u0442\u0430 \u0442\u044F\u0436\u0435\u043B\u0435\u0435 \u043E\u0436\u0438\u0434\u0430\u043D\u0438\u0439, \u0415\u0421\u041B\u0418 \u0441\u0436\u0451\u0433 \u0431\u043E\u043B\u044C\u0448\u0435 \u043F\u043E\u043B\u043E\u0432\u0438\u043D\u044B \u0431\u044E\u0434\u0436\u0435\u0442\u0430, \u0430 \u0434\u043E \u0441\u0434\u0430\u0447\u0438 \u0434\u0430\u043B\u0435\u043A\u043E: \u0434\u0435\u043C\u043E\u043D \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442 \u043F\u043E\u0442\u043E\u043B\u043E\u043A \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0445 \u043F\u0440\u0435\u0434\u0435\u043B\u0430\u0445. \u0417\u043E\u0432\u0438 \u041F\u041E \u0425\u041E\u0414\u0423 \u2014 \u043F\u043E\u0441\u0442\u0444\u0430\u043A\u0442\u0443\u043C \u043E\u0431\u0441\u043B\u0443\u0436\u0438\u0432\u0430\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E.",
|
|
20244
20691
|
"",
|
|
20245
20692
|
"## \u041F\u043E\u0440\u044F\u0434\u043E\u043A",
|
|
20246
|
-
"\u041F\u043E\u0447\u0438\u043D\u0438 \
|
|
20693
|
+
"\u041F\u043E\u0447\u0438\u043D\u0438 \u043A\u0430\u0436\u0434\u044B\u0439 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B\u0439 \u043F\u0443\u043D\u043A\u0442 \u2192 \u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438. \u041F\u0435\u0440\u0435\u0434 done() \u2014 \u0440\u0435\u0432\u044C\u044E \u0441\u0432\u043E\u0435\u0433\u043E \u0434\u0438\u0444\u0444\u0430, \u0442\u043E\u0442 \u0436\u0435 \u0448\u0430\u0433 2 \u043F\u0440\u043E\u0442\u043E\u043A\u043E\u043B\u0430 \u0441\u0434\u0430\u0447\u0438:",
|
|
20694
|
+
SUBMISSION_REVIEW_STEP,
|
|
20695
|
+
"\u041C\u0435\u043D\u044F\u043B \u0432\u0438\u0434\u0438\u043C\u044B\u0439 UI \u2014 \u0441\u043D\u0438\u043C\u0438 \u0441\u043A\u0440\u0438\u043D\u044B \u2192 \u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0442\u044C \u0438 \u0437\u0430\u043F\u0443\u0448\u044C \u0432 \u0422\u0423 \u0416\u0415 \u0432\u0435\u0442\u043A\u0443 (\u043F\u0435\u0440\u0435\u0437\u0430\u043F\u0438\u0441\u044C \u0438\u0441\u0442\u043E\u0440\u0438\u0438 \u0438 force-push \u0437\u0430\u043F\u0440\u0435\u0449\u0435\u043D\u044B) \u2192 \u041E\u0411\u042F\u0417\u0410\u0422\u0415\u041B\u042C\u041D\u041E \u0432\u044B\u0437\u043E\u0432\u0438 done(pr_url) \u0441 \u0442\u043E\u0439 \u0436\u0435 \u0441\u0441\u044B\u043B\u043A\u043E\u0439.",
|
|
20696
|
+
"summary \u0432 done() \u043D\u0430\u0447\u0438\u043D\u0430\u0435\u0442\u0441\u044F \u0441 \u0442\u0430\u0431\u043B\u0438\u0446\u044B \xAB\u043F\u0443\u043D\u043A\u0442 \u2192 \u043A\u043E\u043C\u043C\u0438\u0442 \u2192 \u0442\u0435\u0441\u0442 \u2192 \u0442\u0435\u0441\u0442 \u043A\u0440\u0430\u0441\u043D\u0435\u043B \u0431\u0435\u0437 \u043F\u0440\u0430\u0432\u043A\u0438: \u0434\u0430/\u043D\u0435\u0442\xBB.",
|
|
20697
|
+
`\u0422\u0443 \u0436\u0435 \u0442\u0430\u0431\u043B\u0438\u0446\u0443 \u0434\u043E\u043F\u0438\u0448\u0438 \u0432 \`journal/${slug}.md\`.`,
|
|
20247
20698
|
`\u{1F4B8} \u0411\u044E\u0434\u0436\u0435\u0442 \u044D\u0442\u043E\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u2014 \u041E\u0421\u0422\u0410\u0422\u041E\u041A \u043F\u043E\u0442\u043E\u043B\u043A\u0430 \u043F\u0440\u043E\u0433\u043E\u043D\u0430, \u0430 \u043D\u0435 \u043F\u043E\u043B\u043D\u044B\u0439 \u043F\u043E\u0442\u043E\u043B\u043E\u043A: \u0438\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0437\u0430\u0445\u043E\u0434 \u0443\u0436\u0435 \u043F\u043E\u0442\u0440\u0430\u0442\u0438\u043B \u0447\u0430\u0441\u0442\u044C, \u0438 \u0442\u0435\u0431\u0435 \u0434\u043E\u0441\u0442\u0430\u043B\u043E\u0441\u044C \u0442\u043E, \u0447\u0442\u043E \u043E\u0441\u0442\u0430\u043B\u043E\u0441\u044C. \u041F\u043E\u044D\u0442\u043E\u043C\u0443 \u043A\u043E\u043C\u043C\u0438\u0442\u044C \u0438 \u043F\u0443\u0448\u044C \u041F\u041E \u0425\u041E\u0414\u0423, \u043F\u043E\u0441\u043B\u0435 \u043A\u0430\u0436\u0434\u043E\u0433\u043E \u0437\u043D\u0430\u0447\u0438\u043C\u043E\u0433\u043E \u0448\u0430\u0433\u0430, \u0430 \u043D\u0435 \u043E\u0434\u043D\u0438\u043C \u043A\u0443\u0441\u043A\u043E\u043C \u0432 \u043A\u043E\u043D\u0446\u0435: \u043D\u0435\u0437\u0430\u043F\u0443\u0448\u0435\u043D\u043D\u043E\u0435 \u0443\u043C\u0438\u0440\u0430\u0435\u0442 \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u0441\u0435\u0441\u0441\u0438\u0435\u0439. \u0421\u043B\u0430\u0433 ${slug} \u2014 \u0432 \u041A\u0410\u0416\u0414\u041E\u041C commit-\u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0438 (\u043F\u043E \u0441\u043B\u0430\u0433\u0430\u043C \u0441\u043E\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044F \u0440\u0435\u043B\u0438\u0437, \u0438 \u043F\u0440\u043E\u0434\u0443\u043A\u0442 \u043F\u0440\u043E\u0432\u0435\u0440\u044F\u0435\u0442 \u044D\u0442\u043E \u0441\u0430\u043C).`,
|
|
20248
20699
|
"\u0418\u043C\u0435\u043D\u043D\u043E \u043F\u043E\u0432\u0442\u043E\u0440\u043D\u044B\u0439 done() \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u0435\u0442 \u0440\u0435-\u0440\u0435\u0432\u044C\u044E\u0435\u0440\u0430. \u0411\u0435\u0437 \u043D\u0435\u0433\u043E \u043F\u0440\u0430\u0432\u043A\u0430 \u043D\u0435 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044F, \u0430 \u0442\u0432\u043E\u0439 \u0432\u044B\u0445\u043E\u0434 \u0440\u043E\u0439 \u043F\u0440\u0438\u043C\u0435\u0442 \u0437\u0430 \u0441\u043C\u0435\u0440\u0442\u044C.",
|
|
20249
20700
|
...args.verifyMode === "ci" ? ["\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: \u0440\u0435\u0436\u0438\u043C `ci` \u2014 \u0431\u044B\u0441\u0442\u0440\u044B\u0439 typecheck \u0438 \u0442\u0435\u0441\u0442\u044B \u043F\u043E \u0441\u0432\u043E\u0435\u0439 \u043F\u0440\u0430\u0432\u043A\u0435, \u0442\u044F\u0436\u0451\u043B\u043E\u0435 \u0434\u043E\u0441\u0447\u0438\u0442\u0430\u0435\u0442 CI \u043D\u0430 PR."] : ["\u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0438: \u0440\u0435\u0436\u0438\u043C `local` \u2014 \u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u0442\u043E, \u0447\u0442\u043E \u043F\u043E\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u043F\u0440\u0430\u0432\u043A\u0443, \u0438 \u0441\u044C\u044E\u0442 \u0441\u0432\u043E\u0435\u0433\u043E \u043F\u0430\u043A\u0435\u0442\u0430 \u043F\u0435\u0440\u0435\u0434 \u0441\u0434\u0430\u0447\u0435\u0439."],
|
|
20250
20701
|
`\u0422\u0440\u043E\u043D\u0443\u043B \u0432\u0438\u0434\u0438\u043C\u044B\u0439 UI \u2014 \u0441\u043A\u0440\u0438\u043D\u044B \u041E\u0411\u042F\u0417\u0410\u0422\u0415\u041B\u042C\u041D\u042B \u0438 \u0438\u0434\u0443\u0442 \u0412 \u0417\u0410\u0414\u0410\u0427\u0423: \`swarm shot <url> <out-prefix>\` (\u0441\u0430\u043C \u0441\u043D\u0438\u043C\u0430\u0435\u0442 mobile+desktop), \u043F\u0443\u0442\u0438 \u043F\u0435\u0440\u0435\u0434\u0430\u0439 \u0432 done(pr_url, summary, screenshots: [...]). \u0425\u0430\u0440\u0434-\u043B\u0438\u043C\u0438\u0442 \u043D\u0430 \u0448\u0430\u0433 \u2014 5 \u043C\u0438\u043D\u0443\u0442: \u043D\u0435 \u0443\u043B\u043E\u0436\u0438\u043B\u0441\u044F \u2014 \u043D\u0430\u043F\u0438\u0448\u0438 \u044D\u0442\u043E \u0432 PR \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043D\u043E \u0437\u043E\u0432\u0438 done(). \u0417\u0430\u0434\u0430\u0447\u0430 \u0431\u0435\u0437 \u0441\u043A\u0440\u0438\u043D\u043E\u0432 \u043F\u0440\u0438\u0451\u043C\u043A\u0443 \u043D\u0435 \u043F\u0440\u043E\u0445\u043E\u0434\u0438\u0442.`,
|
|
20251
|
-
`\u0414\u043E\u043F\u0438\u0448\u0438 \u0432 \`journal/${slug}.md\` \u043A\u043E\u0440\u043E\u0442\u043A\u0438\u0439 \u0431\u043B\u043E\u043A \u043F\u0440\u043E \u044D\u0442\u043E\u0442 \u0437\u0430\u0445\u043E\u0434 \u2014 \u0447\u0442\u043E \u043F\u0440\u043E\u0441\u0438\u043B\u0438 \u0438 \u043A\u0430\u043A \u0437\u0430\u043A\u0440\u044B\u043B \u2014 \u0438 \u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0442\u044C \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u043F\u0440\u0430\u0432\u043A\u043E\u0439. \u042D\u0442\u043E \u0445\u0440\u043E\u043D\u0438\u043A\u0430 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u043D\u0435 \u043E\u0442\u0447\u0451\u0442: \u043E\
|
|
20702
|
+
`\u0414\u043E\u043F\u0438\u0448\u0438 \u0432 \`journal/${slug}.md\` \u043A\u043E\u0440\u043E\u0442\u043A\u0438\u0439 \u0431\u043B\u043E\u043A \u043F\u0440\u043E \u044D\u0442\u043E\u0442 \u0437\u0430\u0445\u043E\u0434 \u2014 \u0447\u0442\u043E \u043F\u0440\u043E\u0441\u0438\u043B\u0438 \u0438 \u043A\u0430\u043A \u0437\u0430\u043A\u0440\u044B\u043B \u2014 \u0438 \u0437\u0430\u043A\u043E\u043C\u043C\u0438\u0442\u044C \u0432\u043C\u0435\u0441\u0442\u0435 \u0441 \u043F\u0440\u0430\u0432\u043A\u043E\u0439. \u0422\u0430\u0431\u043B\u0438\u0446\u0430 \u043F\u0443\u043D\u043A\u0442\u043E\u0432 (\u0442\u0430 \u0436\u0435, \u0447\u0442\u043E \u0432 summary \u0443 done()) \u2014 \u0432 \u044D\u0442\u043E\u043C \u0431\u043B\u043E\u043A\u0435. \u042D\u0442\u043E \u0445\u0440\u043E\u043D\u0438\u043A\u0430 \u0437\u0430\u0434\u0430\u0447\u0438, \u0430 \u043D\u0435 \u043E\u0442\u0447\u0451\u0442: \u043E\u0442\u0447\u0451\u0442 \u0438\u0434\u0451\u0442 \u0432 summary \u0443 done().`,
|
|
20252
20703
|
"",
|
|
20253
20704
|
"## \u0413\u0440\u0430\u043D\u0438\u0446\u044B",
|
|
20254
|
-
"\u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 \u043F\u0440\u043E \
|
|
20255
|
-
"\
|
|
20705
|
+
"\u0417\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435 \u043F\u0440\u043E \u0438\u043D\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0443, \u043A\u043E\u0442\u043E\u0440\u043E\u0439 \u041D\u0415\u0422 \u0432 \u0434\u0438\u0444\u0444\u0435 \u044D\u0442\u043E\u0433\u043E PR (\u043D\u0435\u0442 CI, \u0447\u0443\u0436\u043E\u0439 \u043A\u0440\u0430\u0441\u043D\u044B\u0439 \u0447\u0435\u043A, \u043E\u043A\u0440\u0443\u0436\u0435\u043D\u0438\u0435 \u043C\u0430\u0448\u0438\u043D\u044B), \u2014 \u043D\u0435 \u0447\u0438\u043D\u0438 \u0438 workflow \u043D\u0435 \u0437\u0430\u0432\u043E\u0434\u0438: \u044D\u0442\u043E \u0440\u0435\u0448\u0435\u043D\u0438\u0435 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430. \u0412\u044B\u0437\u043E\u0432\u0438 note(text), \u043E\u0431\u044A\u044F\u0441\u043D\u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C \u0432 PR \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043D\u043E \u043F\u043E\u0437\u043E\u0432\u0438 done() \u0441 \u0442\u043E\u0439 \u0436\u0435 \u0441\u0441\u044B\u043B\u043A\u043E\u0439.",
|
|
20706
|
+
"\u0424\u0430\u0439\u043B\u044B, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u043C\u0435\u043D\u044F\u0435\u0442 \u0441\u0430\u043C PR (`.github/workflows/*`, `deploy/*`, \u0441\u043A\u0440\u0438\u043F\u0442\u044B \u0432\u044B\u043A\u0430\u0442\u043A\u0438), \u2014 \u043E\u0431\u044B\u0447\u043D\u044B\u0439 \u043A\u043E\u0434 \u044D\u0442\u043E\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041F\u0443\u043D\u043A\u0442\u044B \u0440\u0435\u0432\u044C\u044E \u043F\u043E \u043D\u0438\u043C \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u044B.",
|
|
20707
|
+
"\u041D\u0435 \u0441\u043E\u0433\u043B\u0430\u0441\u0435\u043D \u0441 \u0437\u0430\u043C\u0435\u0447\u0430\u043D\u0438\u0435\u043C \u2014 \u043D\u0435 \u043C\u043E\u043B\u0447\u0438 \u0438 \u043D\u0435 \u0438\u0433\u043D\u043E\u0440\u0438\u0440\u0443\u0439: \u043E\u0431\u044A\u044F\u0441\u043D\u0438 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C \u0432 PR, \u0441 \u0434\u043E\u0432\u043E\u0434\u043E\u043C, \u0438 \u0432\u0441\u0451 \u0440\u0430\u0432\u043D\u043E \u043F\u043E\u0437\u043E\u0432\u0438 done().",
|
|
20708
|
+
"\u0412\u043E\u043F\u0440\u043E\u0441 \xAB\u044D\u0442\u043E \u0440\u0430\u0431\u043E\u0442\u0430 \u044D\u0442\u043E\u0433\u043E \u043F\u0440\u043E\u0433\u043E\u043D\u0430?\xBB \u043D\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0439: PR \u043E\u0442\u043A\u0440\u044B\u0442 \u0438 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \xAB\u043D\u0443\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u043A\u0438\xBB \u2014 \u044D\u0442\u043E \u0438 \u0435\u0441\u0442\u044C \u0440\u0430\u0431\u043E\u0442\u0430. \u0411\u0435\u0440\u0438\u0441\u044C \u0437\u0430 \u043F\u0443\u043D\u043A\u0442\u044B \u0441\u0440\u0430\u0437\u0443."
|
|
20256
20709
|
].join("\n");
|
|
20257
20710
|
}
|
|
20258
20711
|
var HERO_CONTINUE_NUDGE = "\u0422\u0435\u0431\u044F \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B\u0438, \u0413\u0435\u0440\u043E\u0439: \u0432 \u043E\u0442\u0440\u044F\u0434\u0435 \u0447\u0442\u043E-\u0442\u043E \u043F\u0440\u043E\u0438\u0437\u043E\u0448\u043B\u043E (\u0434\u0440\u043E\u043D \u0437\u0430\u0434\u0430\u043B \u0432\u043E\u043F\u0440\u043E\u0441, \u0441\u0434\u0430\u043B PR \u0438\u043B\u0438 \u0443\u043C\u0435\u0440) \u2014 \u043B\u0438\u0431\u043E \u0442\u0435\u0431\u044F \u043F\u043E\u0437\u0432\u0430\u043B \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440. \u0422\u044B headless, \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0435\u0448\u044C \u0422\u041E\u0422 \u0416\u0415 \u044D\u043F\u0438\u043A: \u0443\u0441\u0442\u0430\u0432 \u0438 \u0442\u0435\u043B\u043E \u044D\u043F\u0438\u043A\u0430 \u0443\u0436\u0435 \u0432 \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442\u0435 \u043F\u0440\u043E\u0448\u043B\u043E\u0439 \u0441\u0435\u0441\u0441\u0438\u0438. \u0413\u043B\u044F\u043D\u044C \u0441\u043E\u0441\u0442\u043E\u044F\u043D\u0438\u0435 \u043E\u0442\u0440\u044F\u0434\u0430 (squad_status) \u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0438\u0441\u044C, \u0447\u0442\u043E \u0438\u0437\u043C\u0435\u043D\u0438\u043B\u043E\u0441\u044C: \u0442\u0435\u0445\u043D\u0438\u0447\u0435\u0441\u043A\u0438\u0435 \u0432\u043E\u043F\u0440\u043E\u0441\u044B \u0434\u0440\u043E\u043D\u043E\u0432 \u0437\u0430\u043A\u0440\u044B\u0432\u0430\u0439 answer_drone; \u043F\u0440\u043E\u0434\u0443\u043A\u0442\u043E\u0432\u043E\u0435/\u0434\u0438\u0437\u0430\u0439\u043D/scope \u2014 \u044D\u0441\u043A\u0430\u043B\u0438\u0440\u0443\u0439 \u0447\u0435\u0440\u0435\u0437 ask. \u041A\u043E\u0434 \u043D\u0435 \u043F\u0438\u0448\u0438, PR \u043D\u0435 \u043C\u0435\u0440\u0436\u0438, done \u041D\u0415 \u0437\u043E\u0432\u0438. \u0420\u0430\u0437\u043E\u0431\u0440\u0430\u043B\u0441\u044F \u0441 \u0440\u044B\u0432\u043A\u043E\u043C \u2014 \u0441\u043D\u043E\u0432\u0430 \u0437\u043E\u0432\u0438 rest(summary) \u0438 \u0437\u0430\u043C\u0440\u0438. \u0412\u043E\u043F\u0440\u043E\u0441\u043E\u0432 \u0432 stdout \u043D\u0435 \u0437\u0430\u0434\u0430\u0432\u0430\u0439 \u2014 \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0435\u0440\u0435\u0437 ask.";
|
|
@@ -20353,7 +20806,7 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
20353
20806
|
"0. \u041F\u0435\u0440\u0435\u0437\u0432\u043E\u043D\u0438 read_task() \u2014 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u043C\u043E\u0433 \u0434\u043E\u043F\u0438\u0441\u0430\u0442\u044C \u0442\u0440\u0435\u0431\u043E\u0432\u0430\u043D\u0438\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C \u0438\u043B\u0438 \u0432 \u043E\u043F\u0438\u0441\u0430\u043D\u0438\u0435 \u0443\u0436\u0435 \u041F\u041E\u0421\u041B\u0415 \u0442\u0432\u043E\u0435\u0433\u043E \u0441\u0442\u0430\u0440\u0442\u0430 (\u0441\u0442\u0430\u0440\u0442\u043E\u0432\u044B\u0439 \u043F\u0440\u043E\u043C\u043F\u0442 \u044D\u0442\u043E\u0433\u043E \u043D\u0435 \u0432\u0438\u0434\u0438\u0442, \u043E\u043D \u0441\u043D\u044F\u0442 \u043E\u0434\u0438\u043D \u0440\u0430\u0437 \u043F\u0440\u0438 \u0441\u043F\u0430\u0432\u043D\u0435). \u0421\u0432\u0435\u0440\u044C\u0441\u044F \u0441 \u0442\u0435\u043C, \u0447\u0442\u043E \u0432\u0435\u0440\u043D\u0443\u043B read_task, \u043F\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043C \u0441\u0434\u0430\u0432\u0430\u0442\u044C.",
|
|
20354
20807
|
verifyMode === "ci" ? "1. CI-\u0440\u0435\u0436\u0438\u043C (SWARM_VERIFY=ci): \u0433\u043E\u043D\u044F\u0439 \u0442\u043E\u043B\u044C\u043A\u043E \u0431\u044B\u0441\u0442\u0440\u0443\u044E \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u0443\u044E \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0443 \u0442\u0438\u043F\u043E\u0432 \u0442\u043E\u0433\u043E, \u0447\u0442\u043E \u0442\u0440\u043E\u0433\u0430\u043B (\u0434\u0451\u0448\u0435\u0432\u043E, \u043B\u043E\u0432\u0438\u0442 \u0442\u0443\u043F\u044B\u0435 \u043E\u0448\u0438\u0431\u043A\u0438 \u0434\u043E \u0442\u0440\u0430\u0442\u044B CI-\u043F\u0440\u043E\u0433\u043E\u043D\u0430; \u0447\u0435\u043C \u043E\u043D\u0430 \u0434\u0435\u043B\u0430\u0435\u0442\u0441\u044F \u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u2014 \u0432 \u0435\u0433\u043E \u0441\u043A\u0438\u043B\u043B\u0430\u0445/README) \u2014 \u043A\u0440\u0430\u0441\u043D\u043E\u0435 \u0447\u0438\u043D\u0438. \u0422\u044F\u0436\u0451\u043B\u0443\u044E \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044E (\u043F\u043E\u043B\u043D\u044B\u0439 \u0442\u0435\u0441\u0442-\u0441\u044C\u044E\u0442, e2e, \u0441\u0431\u043E\u0440\u043A\u0443 \u043E\u0431\u0440\u0430\u0437\u043E\u0432) \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u043E \u041D\u0415 \u0433\u043E\u043D\u044F\u0439, CI \u043F\u0440\u043E\u0433\u043E\u043D\u0438\u0442 \u0435\u0451 \u0441\u0430\u043C \u043F\u043E\u0441\u043B\u0435 push; \u043F\u043E\u043B\u0430\u0433\u0430\u0439\u0441\u044F \u043D\u0430 \u043D\u0435\u0451, \u0430 \u043D\u0435 \u0434\u043E\u0434\u0443\u043C\u044B\u0432\u0430\u0439 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442." : "1. \u0417\u0435\u043B\u0451\u043D\u044B\u0439 \u043B\u043E\u043A\u0430\u043B\u044C\u043D\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u043F\u0440\u043E\u0432\u0435\u0440\u043E\u043A \u0442\u043E\u0433\u043E, \u0447\u0442\u043E \u0442\u044B \u0442\u0440\u043E\u0433\u0430\u043B: \u0442\u0438\u043F\u044B + \u0442\u0435\u0441\u0442\u044B (\u043A\u0430\u043A\u0438\u043C\u0438 \u043A\u043E\u043C\u0430\u043D\u0434\u0430\u043C\u0438 \u2014 \u0432 \u0441\u043A\u0438\u043B\u043B\u0430\u0445/README \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F, \u0447\u0442\u043E \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044F \u0437\u0435\u043B\u0451\u043D\u044B\u043C \u2014 swarm-drone:swarm-verify-green). \u041A\u0440\u0430\u0441\u043D\u043E\u0435 \u2014 \u041D\u0415 \u0441\u0434\u0430\u0432\u0430\u0439, \u0447\u0438\u043D\u0438.",
|
|
20355
20808
|
"1b. \u0417\u0415\u041B\u0401\u041D\u042B\u0419 \u2260 \u041F\u0420\u041E\u0412\u0415\u0420\u0415\u041D\u041E (TASWM-232). \u0421\u0431\u043E\u0440\u043E\u0447\u043D\u044B\u0435 \u0441\u0438\u0441\u0442\u0435\u043C\u044B \u0441 \u043A\u0435\u0448\u0435\u043C \u043E\u0442\u0434\u0430\u044E\u0442 \u041F\u0420\u041E\u0428\u041B\u042B\u0419 \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442, \u0435\u0441\u043B\u0438 \u0445\u0435\u0448 \u0432\u0445\u043E\u0434\u043E\u0432 \u043D\u0435 \u043F\u043E\u043C\u0435\u043D\u044F\u043B\u0441\u044F, \u0438 \u043F\u0438\u0448\u0443\u0442 \u044D\u0442\u043E \u0432 \u0432\u044B\u0432\u043E\u0434 (`cache hit`, `up-to-date`, \xABreplayed\xBB). \u0417\u0435\u043B\u0451\u043D\u043E\u0435 \u0438\u0437 \u043A\u0435\u0448\u0430 \u043F\u043E \u0442\u043E\u043C\u0443, \u0447\u0442\u043E \u0442\u044B \u041F\u0420\u0410\u0412\u0418\u041B, \u0437\u043D\u0430\u0447\u0438\u0442, \u0447\u0442\u043E \u043F\u0440\u043E\u0432\u0435\u0440\u043A\u0438 \u0434\u0435-\u0444\u0430\u043A\u0442\u043E \u043D\u0435 \u0431\u044B\u043B\u043E: \u043F\u0435\u0440\u0435\u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u043F\u0440\u0438\u043D\u0443\u0434\u0438\u0442\u0435\u043B\u044C\u043D\u043E (\u0444\u043B\u0430\u0433 \u0432\u0438\u0434\u0430 `--force`/`--no-cache`) \u0438 \u0432 \u043E\u0442\u0447\u0451\u0442\u0435 \u043E \u0441\u0434\u0430\u0447\u0435 \u043F\u043E\u043A\u0430\u0436\u0438 \u0441\u0442\u0440\u043E\u043A\u0443, \u0433\u0434\u0435 \u0432\u0438\u0434\u043D\u043E \u0420\u0415\u0410\u041B\u042C\u041D\u042B\u0419 \u043F\u0440\u043E\u0433\u043E\u043D, \u0430 \u043D\u0435 \u043E\u0442\u044B\u0433\u0440\u0430\u043D\u043D\u044B\u0439.",
|
|
20356
|
-
|
|
20809
|
+
SUBMISSION_REVIEW_STEP,
|
|
20357
20810
|
"3. \u041F\u0440\u043E\u0432\u0435\u0440\u043A\u0430 \u0437\u0430\u043F\u0443\u0441\u043A\u043E\u043C \u043F\u043E skill `swarm-drone:taskless-check` \u2014 \u0422\u041E\u041B\u042C\u041A\u041E \u0435\u0441\u043B\u0438 \u043C\u0435\u043D\u044F\u043B \u0432\u0438\u0434\u0438\u043C\u044B\u0439 UI/\u0432\u0438\u0437\u0443\u0430\u043B: \u043F\u0440\u043E\u0433\u043E\u043D\u0438 \u0444\u0438\u0447\u0443 \u043D\u0430 \u0436\u0438\u0432\u043E\u043C \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438 (\u043A\u0430\u043A \u0435\u0433\u043E \u043F\u043E\u0434\u043D\u044F\u0442\u044C \u2014 \u0432 \u0441\u043A\u0438\u043B\u043B\u0430\u0445 \u0440\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u044F) \u0438 \u043F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438 \u043F\u043E\u0432\u0435\u0434\u0435\u043D\u0438\u0435, \u043D\u0435 \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u043E \u043A\u043E\u043C\u043F\u0438\u043B\u0438\u0440\u0443\u0435\u0442\u0441\u044F.",
|
|
20358
20811
|
`4. \u0421\u043A\u0440\u0438\u043D\u044B mobile+desktop \u2014 \u0422\u041E\u041B\u042C\u041A\u041E \u0435\u0441\u043B\u0438 \u043C\u0435\u043D\u044F\u043B \u0432\u0438\u0434\u0438\u043C\u044B\u0439 UI/\u0432\u0438\u0437\u0443\u0430\u043B, \u041E\u0414\u041D\u041E\u0419 \u043A\u043E\u043C\u0430\u043D\u0434\u043E\u0439: \`swarm shot <url> <out-prefix>\` (headless Chromium \u0441\u0430\u043C \u043E\u0442\u043A\u0440\u044B\u0432\u0430\u0435\u0442 \u043E\u0431\u0430 \u0432\u044C\u044E\u043F\u043E\u0440\u0442\u0430, \u0441\u043D\u0438\u043C\u0430\u0435\u0442 \u0438 \u0432\u044B\u0445\u043E\u0434\u0438\u0442 \u2014 \u043D\u0435 \u0434\u0435\u0440\u0436\u0438\u0442 \u0431\u0440\u0430\u0443\u0437\u0435\u0440 \u043E\u0442\u043A\u0440\u044B\u0442\u044B\u043C). \u041F\u043E\u043B\u0443\u0447\u0438\u043B\u043E\u0441\u044C \u2014 \u043E\u0431\u0430 \u0444\u0430\u0439\u043B\u0430 \u0418\u0414\u0423\u0422 \u0412 \u0417\u0410\u0414\u0410\u0427\u0423: \u043F\u0435\u0440\u0435\u0434\u0430\u0439 \u0438\u0445 \u043F\u0443\u0442\u0438 \u0432 \`done(pr_url, summary, screenshots: ["\u2026-desktop.png", "\u2026-mobile.png"])\`, \u0434\u0435\u043C\u043E\u043D \u043F\u0440\u0438\u043B\u043E\u0436\u0438\u0442 \u0438\u0445 \u0432\u043B\u043E\u0436\u0435\u043D\u0438\u044F\u043C\u0438 \u043A \u0442\u0432\u043E\u0435\u043C\u0443 \u043E\u0442\u0447\u0451\u0442\u0443 (TASWM-294). \u0427\u0435\u043B\u043E\u0432\u0435\u043A \u0441\u043C\u043E\u0442\u0440\u0438\u0442 \u0442\u0440\u0435\u043A\u0435\u0440, \u0430 \u043D\u0435 \u0433\u0438\u0442\u0445\u0430\u0431: \u0437\u0430\u0434\u0430\u0447\u0430 \u0431\u0435\u0437 \u0441\u043A\u0440\u0438\u043D\u043E\u0432 = \u043D\u0435\u0434\u043E\u043A\u0430\u0437\u0430\u043D\u043D\u0430\u044F \u0440\u0430\u0431\u043E\u0442\u0430. \u0412 PR \u2014 \u0414\u041E\u041F\u041E\u041B\u041D\u0418\u0422\u0415\u041B\u042C\u041D\u041E, \u043F\u043E \u0436\u0435\u043B\u0430\u043D\u0438\u044E; \u0432\u043C\u0435\u0441\u0442\u043E \u0437\u0430\u0434\u0430\u0447\u0438 \u2014 \u043D\u0435\u0442. \u23F1 \u0425\u0430\u0440\u0434-\u043B\u0438\u043C\u0438\u0442 \u043D\u0430 \u0432\u0435\u0441\u044C \u0448\u0430\u0433 \u0441\u043A\u0440\u0438\u043D\u043E\u0432 \u2014 5 \u043C\u0438\u043D\u0443\u0442. \u041D\u0415 \u0433\u043E\u043D\u044F\u0439 Playwright/\u0441\u0438\u0441\u0442\u0435\u043C\u043D\u044B\u0439 Chrome \u0432\u0440\u0443\u0447\u043D\u0443\u044E \u043F\u043E \u0448\u0430\u0433\u0430\u043C (\u043E\u0442\u043A\u0440\u044B\u043B\u2192\u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u043B\u2192\u043A\u043B\u0438\u043A\u043D\u0443\u043B\u2192\u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u043B\u2026) \u2014 \u0442\u0430\u043A \u0434\u0440\u043E\u043D \u0414\u0412\u0410\u0416\u0414\u042B \u0437\u0430\u043B\u0438\u043F\u0430\u043B \u043D\u0430 \u044D\u0442\u043E\u043C (TASWM-30, >30 \u043C\u0438\u043D stall \u0431\u0435\u0437 \u0435\u0434\u0438\u043D\u043E\u0433\u043E \u043A\u043E\u043C\u043C\u0438\u0442\u0430 \u0434\u0430\u043B\u044C\u0448\u0435) \u0432\u043C\u0435\u0441\u0442\u043E \u0442\u043E\u0433\u043E \u0447\u0442\u043E\u0431\u044B \u0441\u0434\u0430\u0442\u044C \u0433\u043E\u0442\u043E\u0432\u0443\u044E \u0440\u0430\u0431\u043E\u0442\u0443. \u041D\u0435 \u0443\u043B\u043E\u0436\u0438\u043B\u0441\u044F \u0432 \u043B\u0438\u043C\u0438\u0442 \u0438\u043B\u0438 \u043A\u043E\u043C\u0430\u043D\u0434\u0430 \u043D\u0435 \u0438\u0434\u0451\u0442 \u2014 \u043F\u0440\u0438\u043B\u043E\u0436\u0438 \u0447\u0442\u043E \u0443\u0436\u0435 \u0441\u043D\u044F\u043B, \u0438\u043B\u0438 \u043F\u0440\u044F\u043C\u043E \u043D\u0430\u043F\u0438\u0448\u0438 \u0432 PR/\u0437\u0430\u0434\u0430\u0447\u0435 \xAB\u0441\u043A\u0440\u0438\u043D\u044B \u043E\u0442\u0434\u0435\u043B\u044C\u043D\u043E\xBB \u0438 \u0421\u0420\u0410\u0417\u0423 \u0432\u044B\u0437\u043E\u0432\u0438 done(pr_url) \u2014 \u043D\u0435 \u043F\u0435\u0440\u0435\u0438\u0433\u0440\u044B\u0432\u0430\u0439 \u043F\u043E\u043F\u044B\u0442\u043A\u0438 \u043F\u043E \u043A\u0440\u0443\u0433\u0443.`,
|
|
20359
20812
|
"4a. \u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u0417\u0410 \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u0435\u0439 \u0431\u0435\u0437 \u0433\u043E\u0442\u043E\u0432\u043E\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0434\u0430\u0451\u0442 \u044D\u043A\u0440\u0430\u043D \u043B\u043E\u0433\u0438\u043D\u0430, \u0430 \u043D\u0435 \u0446\u0435\u043B\u0435\u0432\u043E\u0439 \u044D\u043A\u0440\u0430\u043D \u2014 \u0441\u043D\u0438\u043C\u0430\u0442\u044C \u0435\u0451 \u043D\u0443\u0436\u043D\u043E \u0441 `--storage-state <\u0444\u0430\u0439\u043B>` (\u043A\u0430\u043A \u0437\u0430\u0432\u0435\u0441\u0442\u0438 \u0442\u0430\u043A\u043E\u0439 \u0444\u0430\u0439\u043B \u0432 \u044D\u0442\u043E\u043C \u043F\u0440\u043E\u0435\u043A\u0442\u0435 \u2014 \u0432 \u0435\u0433\u043E \u0441\u043A\u0438\u043B\u043B\u0430\u0445). \u041F\u043E\u0440\u044F\u0434\u043E\u043A \u0430\u0440\u0433\u0443\u043C\u0435\u043D\u0442\u043E\u0432 \u0432\u0430\u0436\u0435\u043D: `--storage-state` \u0411\u0415\u0417 \u043F\u0440\u0435\u0434\u0448\u0435\u0441\u0442\u0432\u0443\u044E\u0449\u0435\u0433\u043E `<out-prefix>` \u043C\u043E\u043B\u0447\u0430 \u0441\u044A\u0435\u0434\u0430\u0435\u0442 \u0435\u0433\u043E \u043C\u0435\u0441\u0442\u043E, \u0438 \u0444\u043B\u0430\u0433 \u043D\u0438\u043A\u043E\u0433\u0434\u0430 \u043D\u0435 \u043F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u0441\u044F (\u0441\u043C. shotCli.ts parseShotArgs) \u2014 \u0435\u0441\u043B\u0438 \u043D\u0430 \u0441\u043D\u0438\u043C\u043A\u0435 \u044D\u043A\u0440\u0430\u043D \u043B\u043E\u0433\u0438\u043D\u0430 \u0432\u043C\u0435\u0441\u0442\u043E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u044F, \u043F\u0440\u043E\u0432\u0435\u0440\u044C \u0441\u043D\u0430\u0447\u0430\u043B\u0430 \u044D\u0442\u043E.",
|
|
@@ -20380,10 +20833,10 @@ ${task.description}` : `\u0417\u0430\u0434\u0430\u0447\u0430 ${run2.task_slug} (
|
|
|
20380
20833
|
}
|
|
20381
20834
|
return parts.join("\n");
|
|
20382
20835
|
}
|
|
20383
|
-
var HERO_CHARTER_PATH =
|
|
20836
|
+
var HERO_CHARTER_PATH = join38(dirname6(THIS_FILE), "..", "docs", "HERO.md");
|
|
20384
20837
|
function buildHeroPrompt(task, run2, taskContext, attachmentsBlock) {
|
|
20385
20838
|
const name = run2.name || `#${run2.id}`;
|
|
20386
|
-
const charter =
|
|
20839
|
+
const charter = readFileSync27(HERO_CHARTER_PATH, "utf8");
|
|
20387
20840
|
const head = task ? `\u042D\u041F\u0418\u041A ${run2.task_slug}: ${task.title}
|
|
20388
20841
|
|
|
20389
20842
|
${task.description}` : `\u042D\u041F\u0418\u041A ${run2.task_slug} (\u0442\u0435\u043B\u043E \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u043E \u2014 \u0440\u0430\u0431\u043E\u0442\u0430\u0439 \u043F\u043E slug \u0438 \u0437\u0434\u0440\u0430\u0432\u043E\u043C\u0443 \u0441\u043C\u044B\u0441\u043B\u0443).`;
|
|
@@ -20443,9 +20896,9 @@ function ciTrustLine(prUrl, verifyMode, ciClosed = null) {
|
|
|
20443
20896
|
}
|
|
20444
20897
|
return `\u041D\u0435 \u043F\u0435\u0440\u0435\u0433\u043E\u043D\u044F\u0439 \u0442\u0435\u0441\u0442-\u0441\u044C\u044E\u0442/typecheck \u0437\u0430\u043D\u043E\u0432\u043E \u2014 \u044D\u0442\u043E \u0443\u0436\u0435 \u0441\u0434\u0435\u043B\u0430\u043B CI \u043D\u0430 \u044D\u0442\u043E\u043C \u0436\u0435 \u043A\u043E\u043C\u043C\u0438\u0442\u0435 (\u0434\u0432\u043E\u0439\u043D\u043E\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u043D\u0430 \u043C\u0430\u0448\u0438\u043D\u0435 \u0432\u043B\u0430\u0434\u0435\u043B\u044C\u0446\u0430 \u043E\u0442\u043C\u0435\u043D\u0451\u043D, TASWM-249). \u041F\u0440\u043E\u0447\u0438\u0442\u0430\u0439 \u0435\u0433\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442 \u0441\u0430\u043C: ${readChecks}. \u0414\u0430\u043B\u044C\u0448\u0435 \u0442\u0440\u0438 \u0440\u0430\u0437\u043D\u044B\u0445 \u0441\u043B\u0443\u0447\u0430\u044F: \u2460 \u0445\u043E\u0442\u044C \u043E\u0434\u0438\u043D \u0447\u0435\u043A \u0435\u0449\u0451 PENDING \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u043E\u043E\u0431\u0449\u0435 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438: \u043D\u0435 \u043F\u043E\u0441\u0442\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E \u043A\u0430\u043A \u0435\u0441\u0442\u044C \u2014 \u0440\u043E\u0439 \u0441\u0430\u043C \u0437\u0430\u043C\u0435\u0442\u0438\u0442, \u0447\u0442\u043E \u0442\u044B \u0436\u0434\u0451\u0448\u044C CI, \u0438 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442 \u0434\u043E\u0434\u0435\u043B\u0430\u0442\u044C \u0440\u0435\u0432\u044C\u044E, \u043A\u043E\u0433\u0434\u0430 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F (\u044D\u0442\u043E \u0448\u0442\u0430\u0442\u043D\u044B\u0439 \u043F\u0443\u0442\u044C, \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430 \u0437\u0432\u0430\u0442\u044C \u043D\u0435 \u043D\u0443\u0436\u043D\u043E). \u2461 \u0432\u0441\u0435 \u0447\u0435\u043A\u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043B\u0438\u0441\u044C \u0438 \u0435\u0441\u0442\u044C FAIL \u2014 REQUEST CHANGES, \u043D\u0430\u0437\u043E\u0432\u0438 \u043F\u043E\u0438\u043C\u0451\u043D\u043D\u043E, \u0447\u0442\u043E \u0443\u043F\u0430\u043B\u043E. \u2462 \u043D\u0430 \u044D\u0442\u043E\u043C \u043A\u043E\u043C\u043C\u0438\u0442\u0435 \u0447\u0435\u043A\u043E\u0432 \u043D\u0435\u0442 \u0432\u043E\u0432\u0441\u0435 \u2014 \u0442\u043E \u0436\u0435, \u0447\u0442\u043E \u2460: \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u043D\u0435 \u0432\u044B\u043D\u043E\u0441\u0438, \u043D\u0435 \u043F\u0438\u0448\u0438 REQUEST CHANGES, \u043D\u0435 \u0437\u043E\u0432\u0438 done(), \u043F\u0440\u043E\u0441\u0442\u043E \u0437\u0430\u0432\u0435\u0440\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u044E. \u0427\u0435\u043A\u043E\u0432 \u043C\u043E\u0436\u0435\u0442 \u043D\u0435 \u0431\u044B\u0442\u044C, \u043F\u043E\u0442\u043E\u043C\u0443 \u0447\u0442\u043E \u0441\u0442\u0430\u0440\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D \u0442\u043E\u043B\u044C\u043A\u043E \u0447\u0442\u043E \u043E\u0442\u043C\u0435\u043D\u0451\u043D \u043D\u043E\u0432\u044B\u043C \u043F\u0443\u0448\u0435\u043C \u0438\u043B\u0438 \u0440\u0430\u043D\u043D\u0435\u0440\u044B \u0437\u0430\u043D\u044F\u0442\u044B. \u0420\u043E\u0439 \u0441\u0430\u043C \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u0442, \u043A\u043E\u0433\u0434\u0430 \u0447\u0435\u043A\u0438 \u043F\u043E\u044F\u0432\u044F\u0442\u0441\u044F \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0442\u0441\u044F, \u0438\u043B\u0438 \u0441\u043A\u0430\u0436\u0435\u0442, \u0447\u0442\u043E \u0438\u0445 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442. ${dontTrustAuthor}`;
|
|
20445
20898
|
}
|
|
20446
|
-
var REVIEW_SKILL_PATH =
|
|
20899
|
+
var REVIEW_SKILL_PATH = join38(bundledRoleDir("drone"), "skills", "taskless-review", "SKILL.md");
|
|
20447
20900
|
function reviewDefectClasses(skillPath = REVIEW_SKILL_PATH) {
|
|
20448
|
-
const text =
|
|
20901
|
+
const text = readFileSync27(skillPath, "utf8");
|
|
20449
20902
|
const m = /^## Классы дефектов\n([\s\S]*?)(?=^## |(?![\s\S]))/m.exec(text);
|
|
20450
20903
|
if (!m) throw new Error(`${skillPath}: \u043D\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043B\u0430 \xAB## \u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432\xBB \u2014 \u0444\u043E\u0440\u043C\u0430\u0442 skill taskless-review \u043F\u043E\u043C\u0435\u043D\u044F\u043B\u0441\u044F?`);
|
|
20451
20904
|
return `\u041A\u043B\u0430\u0441\u0441\u044B \u0434\u0435\u0444\u0435\u043A\u0442\u043E\u0432 (skill taskless-review):
|
|
@@ -20492,18 +20945,24 @@ ${priorReview}` : "",
|
|
|
20492
20945
|
"- [ ] \u0415\u0441\u043B\u0438 \u043F\u0440\u0430\u0432\u0438\u0442\u0441\u044F router.tsx \u2014 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0430 per-page meta \u0434\u043B\u044F \u0430\u0433\u0435\u043D\u0442\u0441\u043A\u043E\u0433\u043E \u043A\u043E\u043D\u0442\u0440\u043E\u043B\u0430 (\u0438\u043D\u0430\u0447\u0435 NL-\u043D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F \u043C\u043E\u043B\u0447\u0430 \u043B\u043E\u043C\u0430\u0435\u0442\u0441\u044F)."
|
|
20493
20946
|
].join("\n");
|
|
20494
20947
|
}
|
|
20495
|
-
var
|
|
20948
|
+
var OPERATOR_VERDICT_PREFIX = "\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043E\u0442 \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440\u0430";
|
|
20949
|
+
var VERDICT_EVENT_PREFIXES = [OPERATOR_VERDICT_PREFIX, "\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043E\u0442", "\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043F\u043E\u0434\u0445\u0432\u0430\u0447\u0435\u043D \u0438\u0437 PR-\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430"];
|
|
20950
|
+
function isVerdictEventText(text) {
|
|
20951
|
+
if (text.startsWith(OPERATOR_VERDICT_PREFIX)) return VERDICT_EVENT_PREFIXES.includes(OPERATOR_VERDICT_PREFIX);
|
|
20952
|
+
return VERDICT_EVENT_PREFIXES.some((p) => p !== OPERATOR_VERDICT_PREFIX && text.startsWith(p));
|
|
20953
|
+
}
|
|
20496
20954
|
function lastVerdictEvent(db, reviewRunId) {
|
|
20497
20955
|
const events = db.events(reviewRunId);
|
|
20498
20956
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
20499
|
-
if (
|
|
20957
|
+
if (isVerdictEventText(events[i].text ?? "")) return events[i];
|
|
20500
20958
|
}
|
|
20501
20959
|
return null;
|
|
20502
20960
|
}
|
|
20503
20961
|
function lastChangesSummary(db, reviewRunId) {
|
|
20504
20962
|
return lastVerdictEvent(db, reviewRunId)?.text ?? null;
|
|
20505
20963
|
}
|
|
20506
|
-
var
|
|
20964
|
+
var VERIFY_PICKUP_EVENT_PREFIX = "\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 \u043F\u043E\u0434\u0445\u0432\u0430\u0447\u0435\u043D \u0438\u0437 PR-\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430";
|
|
20965
|
+
var VERIFY_EVENT_PREFIXES = ["\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 \u043E\u0442", VERIFY_PICKUP_EVENT_PREFIX];
|
|
20507
20966
|
function lastVerifySummary(db, runId) {
|
|
20508
20967
|
const events = db.events(runId);
|
|
20509
20968
|
for (let i = events.length - 1; i >= 0; i--) {
|
|
@@ -20512,9 +20971,26 @@ function lastVerifySummary(db, runId) {
|
|
|
20512
20971
|
}
|
|
20513
20972
|
return null;
|
|
20514
20973
|
}
|
|
20515
|
-
function changesVerdictAt(db,
|
|
20516
|
-
|
|
20517
|
-
|
|
20974
|
+
function changesVerdictAt(db, run2, now) {
|
|
20975
|
+
const events = db.events(run2.id);
|
|
20976
|
+
let verdictAt = null;
|
|
20977
|
+
let submittedAt = null;
|
|
20978
|
+
for (let i = events.length - 1; i >= 0 && (verdictAt == null || submittedAt == null); i--) {
|
|
20979
|
+
const e = events[i];
|
|
20980
|
+
const text = e.text ?? "";
|
|
20981
|
+
if (verdictAt == null && (isVerdictEventText(text) || VERIFY_EVENT_PREFIXES.some((p) => text.startsWith(p)))) verdictAt = e.at;
|
|
20982
|
+
if (submittedAt == null && (e.kind === "pr_opened" || e.kind === "done")) submittedAt = e.at;
|
|
20983
|
+
}
|
|
20984
|
+
const submittedMs = submittedAt ? sqliteMs(submittedAt) : NaN;
|
|
20985
|
+
if (verdictAt && !(submittedMs > sqliteMs(verdictAt))) return verdictAt;
|
|
20986
|
+
if (!run2.review_verdict && !run2.verify_verdict) return null;
|
|
20987
|
+
const key = `${run2.task_slug}|${run2.created_at}|${run2.review_verdict ?? ""}|${run2.verify_verdict ?? ""}`;
|
|
20988
|
+
const seen = verdictFieldSeenAt.get(run2.id);
|
|
20989
|
+
if (seen && seen.key === key && !(submittedMs > seen.ms)) return stamp(new Date(seen.ms));
|
|
20990
|
+
verdictFieldSeenAt.set(run2.id, { key, ms: now });
|
|
20991
|
+
return stamp(new Date(now));
|
|
20992
|
+
}
|
|
20993
|
+
var verdictFieldSeenAt = /* @__PURE__ */ new Map();
|
|
20518
20994
|
var REVIEW_SCOPE_BLOCK = [
|
|
20519
20995
|
"\u{1F4B8} \u041A\u041E\u041D\u0422\u0423\u0420 \u0420\u0415\u0412\u042C\u042E (\u0436\u0451\u0441\u0442\u043A\u043E). \u0422\u0432\u043E\u044F \u0441\u0435\u0441\u0441\u0438\u044F \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0435\u043D\u0430 \u0431\u044E\u0434\u0436\u0435\u0442\u043E\u043C \u043F\u0440\u043E\u0433\u043E\u043D\u0430, \u0438 \u043E\u043D \u0441\u0440\u0435\u0436\u0435\u0442 \u0435\u0451 \u0411\u0415\u0417 \u043F\u0440\u0435\u0434\u0443\u043F\u0440\u0435\u0436\u0434\u0435\u043D\u0438\u044F: \u0443\u043F\u0440\u0451\u0448\u044C\u0441\u044F \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0430 \u043D\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u043E\u0432\u0441\u0435, \u0430 PR \u0443\u0439\u0434\u0451\u0442 \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0443. \u041F\u043E\u044D\u0442\u043E\u043C\u0443:",
|
|
20520
20996
|
"\u2022 \u0427\u0438\u0442\u0430\u0439 \u0414\u0418\u0424\u0424 \u0438 \u0442\u043E\u043B\u044C\u043A\u043E \u0442\u043E, \u0447\u0435\u0433\u043E \u043E\u043D \u043A\u0430\u0441\u0430\u0435\u0442\u0441\u044F: \u0441\u0430\u043C\u0438 \u0438\u0437\u043C\u0435\u043D\u0451\u043D\u043D\u044B\u0435 \u0444\u0430\u0439\u043B\u044B + \u043C\u0435\u0441\u0442\u0430, \u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u0438\u043C\u0438 \u043B\u043E\u043C\u0430\u044E\u0442\u0441\u044F. \u0420\u0435\u043F\u043E\u0437\u0438\u0442\u043E\u0440\u0438\u0439 \xAB\u0434\u043B\u044F \u043E\u0431\u0449\u0435\u0433\u043E \u043F\u043E\u043D\u0438\u043C\u0430\u043D\u0438\u044F\xBB \u043D\u0435 \u0441\u043A\u0430\u043D\u0438\u0440\u0443\u0439 \u2014 \u043D\u0430 \u044D\u0442\u043E \u0443\u0445\u043E\u0434\u0438\u0442 \u0432\u0435\u0441\u044C \u0431\u044E\u0434\u0436\u0435\u0442 \u0438 \u043D\u0435 \u043D\u0430\u0445\u043E\u0434\u0438\u0442\u0441\u044F \u043D\u0438\u0447\u0435\u0433\u043E.",
|
|
@@ -20718,13 +21194,148 @@ async function resurrectStormDead(deps, worktreeExists, hasTranscript, opts) {
|
|
|
20718
21194
|
}
|
|
20719
21195
|
return resurrected;
|
|
20720
21196
|
}
|
|
21197
|
+
function processStopDeps(executor, group = killProcessGroup) {
|
|
21198
|
+
const stop = (pid, signal) => executor.stop ? executor.stop(pid, signal) : group(pid, signal);
|
|
21199
|
+
return {
|
|
21200
|
+
kill: (pid) => stop(pid, "SIGTERM"),
|
|
21201
|
+
hardKill: (pid) => stop(pid, "SIGKILL"),
|
|
21202
|
+
processStartedAt: (pid) => processStartedAt(pid)
|
|
21203
|
+
};
|
|
21204
|
+
}
|
|
21205
|
+
function isAuthorRun(run2) {
|
|
21206
|
+
if (run2.reviews_run_id != null || run2.verifies_run_id != null || run2.resolves_run_id != null) return false;
|
|
21207
|
+
return (run2.kind ?? "drone") === "drone";
|
|
21208
|
+
}
|
|
21209
|
+
function serviceRoleName(run2) {
|
|
21210
|
+
if (run2.resolves_run_id != null) return "\u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440";
|
|
21211
|
+
if (run2.reviews_run_id != null || run2.kind === "reviewer") return "\u0440\u0435\u0432\u044C\u044E\u0435\u0440";
|
|
21212
|
+
if (run2.verifies_run_id != null || run2.kind === "verifier") return "\u043F\u0440\u043E\u0432\u0435\u0440\u044F\u044E\u0449\u0438\u0439";
|
|
21213
|
+
if (run2.kind === "hero") return "\u0433\u0435\u0440\u043E\u0439";
|
|
21214
|
+
return "\u0441\u043B\u0443\u0436\u0435\u0431\u043D\u044B\u0439 \u043F\u0440\u043E\u0433\u043E\u043D";
|
|
21215
|
+
}
|
|
21216
|
+
function sinceLastPrOpened(events) {
|
|
21217
|
+
let from = -1;
|
|
21218
|
+
events.forEach((e, i) => {
|
|
21219
|
+
if (e.kind === "pr_opened") from = i;
|
|
21220
|
+
});
|
|
21221
|
+
return events.slice(from + 1);
|
|
21222
|
+
}
|
|
21223
|
+
var isLingerStep = (e) => e.kind === "step" && (e.text ?? "").startsWith(AUTHOR_LINGER_MARK);
|
|
21224
|
+
function lingerKillEvent(events, pid) {
|
|
21225
|
+
return sinceLastPrOpened(events).find((e) => isLingerStep(e) && (e.text ?? "").endsWith(`\u0433\u0430\u0448\u0443 pid ${pid}`));
|
|
21226
|
+
}
|
|
21227
|
+
function lingerSkipEvent(events, pid) {
|
|
21228
|
+
return sinceLastPrOpened(events).find((e) => isLingerStep(e) && (e.text ?? "").includes(`pid ${pid} \u043D\u0435 \u0433\u0430\u0448\u0443:`));
|
|
21229
|
+
}
|
|
21230
|
+
var LAUNCH_START_SLACK_MS = 5e3;
|
|
21231
|
+
function launchedAtMs(events, pid) {
|
|
21232
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
21233
|
+
const e = events[i];
|
|
21234
|
+
if (e.kind !== "step" || droneLaunchedPid(e.text) !== pid) continue;
|
|
21235
|
+
const ms = sqliteMs(e.at);
|
|
21236
|
+
return Number.isFinite(ms) ? ms : null;
|
|
21237
|
+
}
|
|
21238
|
+
return null;
|
|
21239
|
+
}
|
|
21240
|
+
function submitterCheck(deps, events, pid, openedAt) {
|
|
21241
|
+
const launchedAt = launchedAtMs(events, pid);
|
|
21242
|
+
if (launchedAt == null) return { kind: "unknown", why: "\u0432 \u043B\u0435\u043D\u0442\u0435 \u043D\u0435\u0442 \u0437\u0430\u043F\u0438\u0441\u0438 \u043E \u0437\u0430\u043F\u0443\u0441\u043A\u0435 \u044D\u0442\u043E\u0433\u043E pid" };
|
|
21243
|
+
const startedAt = deps.processStartedAt?.(pid) ?? null;
|
|
21244
|
+
if (startedAt == null) return { kind: "unknown", why: "\u043D\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044F \u0432\u0440\u0435\u043C\u044F \u0441\u0442\u0430\u0440\u0442\u0430 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u0430" };
|
|
21245
|
+
if (startedAt > launchedAt + LAUNCH_START_SLACK_MS || startedAt >= openedAt) return { kind: "other" };
|
|
21246
|
+
return { kind: "own" };
|
|
21247
|
+
}
|
|
21248
|
+
function reapLingeringAuthors(deps, now) {
|
|
21249
|
+
const kill = deps.kill;
|
|
21250
|
+
if (!kill) return;
|
|
21251
|
+
for (const run2 of deps.db.listRuns("review")) {
|
|
21252
|
+
if (run2.pid == null || !isAuthorRun(run2)) continue;
|
|
21253
|
+
const pid = run2.pid;
|
|
21254
|
+
if (!deps.isAlive(pid)) {
|
|
21255
|
+
if (lingerKillEvent(deps.db.events(run2.id), pid)) {
|
|
21256
|
+
deps.db.updateRun(run2.id, { pid: null });
|
|
21257
|
+
console.log(`[overmind] ${droneLabel(run2)} (#${run2.id}): \u043F\u043E\u0433\u0430\u0448\u0435\u043D\u043D\u044B\u0439 \u0430\u0432\u0442\u043E\u0440 \u0432\u044B\u0448\u0435\u043B \u2014 \u0441\u043D\u0438\u043C\u0430\u044E pid ${pid} \u0441 \u043F\u0440\u043E\u0433\u043E\u043D\u0430`);
|
|
21258
|
+
}
|
|
21259
|
+
continue;
|
|
21260
|
+
}
|
|
21261
|
+
const events = deps.db.events(run2.id);
|
|
21262
|
+
const openedAt = prOpenedAtMs(events);
|
|
21263
|
+
if (openedAt == null || now - openedAt < AUTHOR_LINGER_AFTER_PR_MS) continue;
|
|
21264
|
+
const sent = lingerKillEvent(events, pid);
|
|
21265
|
+
if (sent && now - sqliteMs(sent.at) < STOP_TERM_GRACE_MS) continue;
|
|
21266
|
+
const check = submitterCheck(deps, events, pid, openedAt);
|
|
21267
|
+
if (check.kind === "other") continue;
|
|
21268
|
+
const mins = Math.floor((now - openedAt) / 6e4);
|
|
21269
|
+
if (check.kind === "unknown") {
|
|
21270
|
+
if (sent || lingerSkipEvent(events, pid)) continue;
|
|
21271
|
+
deps.db.addEvent(
|
|
21272
|
+
run2.id,
|
|
21273
|
+
"step",
|
|
21274
|
+
`${AUTHOR_LINGER_MARK} ${mins} \u043C\u0438\u043D \u043F\u043E\u0441\u043B\u0435 \u0441\u0434\u0430\u0447\u0438, \u043D\u043E pid ${pid} \u043D\u0435 \u0433\u0430\u0448\u0443: ${check.why}, \u043D\u0435 \u043C\u043E\u0433\u0443 \u0443\u0431\u0435\u0434\u0438\u0442\u044C\u0441\u044F, \u0447\u0442\u043E \u043E\u043D \u043D\u0430\u0448 \u2014 \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438 \u043F\u0440\u043E\u0433\u043E\u043D \u0432\u0440\u0443\u0447\u043D\u0443\u044E`
|
|
21275
|
+
);
|
|
21276
|
+
console.log(`[overmind] ${droneLabel(run2)} (#${run2.id}): \u0430\u0432\u0442\u043E\u0440 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B \u043F\u043E\u0441\u043B\u0435 \u0441\u0434\u0430\u0447\u0438, \u043D\u043E pid ${pid} \u043D\u0435 \u0433\u0430\u0448\u0443 \u2014 ${check.why}`);
|
|
21277
|
+
continue;
|
|
21278
|
+
}
|
|
21279
|
+
if (sent) {
|
|
21280
|
+
console.log(`[overmind] ${droneLabel(run2)} (#${run2.id}): pid ${pid} \u043F\u0435\u0440\u0435\u0436\u0438\u043B \u043C\u044F\u0433\u043A\u0438\u0439 \u0441\u0438\u0433\u043D\u0430\u043B \u2014 \u0434\u043E\u0431\u0438\u0432\u0430\u044E SIGKILL`);
|
|
21281
|
+
try {
|
|
21282
|
+
(deps.hardKill ?? kill)(pid);
|
|
21283
|
+
} catch {
|
|
21284
|
+
}
|
|
21285
|
+
continue;
|
|
21286
|
+
}
|
|
21287
|
+
deps.db.addEvent(run2.id, "step", `${AUTHOR_LINGER_MARK} ${mins} \u043C\u0438\u043D \u043F\u043E\u0441\u043B\u0435 \u0441\u0434\u0430\u0447\u0438 \u2014 \u0433\u0430\u0448\u0443 pid ${pid}`);
|
|
21288
|
+
console.log(`[overmind] ${droneLabel(run2)}: \u0430\u0432\u0442\u043E\u0440 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B \u0447\u0435\u0440\u0435\u0437 ${mins} \u043C\u0438\u043D \u043F\u043E\u0441\u043B\u0435 \u0441\u0434\u0430\u0447\u0438 PR \u2014 \u0433\u0430\u0448\u0443 pid ${pid}`);
|
|
21289
|
+
try {
|
|
21290
|
+
kill(pid);
|
|
21291
|
+
} catch {
|
|
21292
|
+
}
|
|
21293
|
+
}
|
|
21294
|
+
}
|
|
21295
|
+
function lingeringSubmitterWhy(run2, events, now) {
|
|
21296
|
+
const head = `\u043F\u0440\u043E\u0433\u043E\u043D #${run2.id}`;
|
|
21297
|
+
const pid = run2.pid;
|
|
21298
|
+
const openedAt = prOpenedAtMs(events);
|
|
21299
|
+
const elapsed = openedAt == null ? null : Math.max(0, now - openedAt);
|
|
21300
|
+
const ago = elapsed == null ? "" : ` ${Math.floor(elapsed / 6e4)} \u043C\u0438\u043D \u043D\u0430\u0437\u0430\u0434`;
|
|
21301
|
+
if (!isAuthorRun(run2)) return `${head}: ${serviceRoleName(run2)} \u0441\u0434\u0430\u043B \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442${ago}, \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0435\u0449\u0451 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B (pid ${pid}) \u2014 \u0431\u0443\u0434\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E`;
|
|
21302
|
+
if (elapsed == null) {
|
|
21303
|
+
return `${head}: \u0430\u0432\u0442\u043E\u0440 \u0441\u0434\u0430\u043B PR (\u0432\u0440\u0435\u043C\u044F \u0441\u0434\u0430\u0447\u0438 \u0432 \u043B\u0435\u043D\u0442\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E), \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0435\u0449\u0451 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B (pid ${pid}) \u2014 \u0441\u0430\u043C \u0434\u0435\u043C\u043E\u043D \u0435\u0433\u043E \u043D\u0435 \u043F\u043E\u0433\u0430\u0441\u0438\u0442, \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438 \u043F\u0440\u043E\u0433\u043E\u043D \u0432\u0440\u0443\u0447\u043D\u0443\u044E`;
|
|
21304
|
+
}
|
|
21305
|
+
if (lingerSkipEvent(events, pid)) {
|
|
21306
|
+
return `${head}: \u0430\u0432\u0442\u043E\u0440 \u0441\u0434\u0430\u043B PR${ago}, \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0435\u0449\u0451 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B (pid ${pid}) \u2014 \u0434\u0435\u043C\u043E\u043D \u0435\u0433\u043E \u043D\u0435 \u0433\u0430\u0441\u0438\u0442, \u043F\u0440\u0438\u0447\u0438\u043D\u0430 \u0432 \u043B\u0435\u043D\u0442\u0435 \u043F\u0440\u043E\u0433\u043E\u043D\u0430; \u043E\u0441\u0442\u0430\u043D\u043E\u0432\u0438 \u043F\u0440\u043E\u0433\u043E\u043D \u0432\u0440\u0443\u0447\u043D\u0443\u044E`;
|
|
21307
|
+
}
|
|
21308
|
+
const left = AUTHOR_LINGER_AFTER_PR_MS - elapsed;
|
|
21309
|
+
const next = left > 0 ? `\u0435\u0441\u043B\u0438 \u043D\u0435 \u0432\u044B\u0439\u0434\u0435\u0442 \u0441\u0430\u043C, \u0434\u0435\u043C\u043E\u043D \u043F\u043E\u0433\u0430\u0441\u0438\u0442 \u0435\u0433\u043E \u0447\u0435\u0440\u0435\u0437 ${Math.ceil(left / 6e4)} \u043C\u0438\u043D` : "\u0434\u0435\u043C\u043E\u043D \u0433\u0430\u0441\u0438\u0442 \u0435\u0433\u043E \u043D\u0430 \u0431\u043B\u0438\u0436\u0430\u0439\u0448\u0435\u043C \u0442\u0438\u043A\u0435";
|
|
21310
|
+
return `${head}: \u0430\u0432\u0442\u043E\u0440 \u0441\u0434\u0430\u043B PR${ago}, \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0435\u0449\u0451 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B (pid ${pid}) \u2014 ${next}, \u043F\u043E\u0441\u043B\u0435 \u044D\u0442\u043E\u0433\u043E \u0431\u0443\u0434\u0438\u0442\u044C \u043C\u043E\u0436\u043D\u043E`;
|
|
21311
|
+
}
|
|
21312
|
+
function fixIterationSessionOpen(db, runId) {
|
|
21313
|
+
const events = db.events(runId);
|
|
21314
|
+
let verdictIdx = -1;
|
|
21315
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
21316
|
+
if (isVerdictEventText(events[i].text ?? "")) {
|
|
21317
|
+
verdictIdx = i;
|
|
21318
|
+
break;
|
|
21319
|
+
}
|
|
21320
|
+
}
|
|
21321
|
+
for (let i = events.length - 1; i > verdictIdx; i--) {
|
|
21322
|
+
const text = events[i].text ?? "";
|
|
21323
|
+
if (events[i].kind !== "resumed" || !text.includes("\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F")) continue;
|
|
21324
|
+
if (text.includes(CHANGES_WAKE_FAILED_MARK)) continue;
|
|
21325
|
+
return true;
|
|
21326
|
+
}
|
|
21327
|
+
return false;
|
|
21328
|
+
}
|
|
20721
21329
|
async function wakeRun(deps, runId, opts = {}) {
|
|
20722
21330
|
const run2 = deps.db.getRun(runId);
|
|
20723
21331
|
if (!run2) return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D \u0432 \u0437\u0435\u0440\u043A\u0430\u043B\u0435 \u0440\u043E\u044F` };
|
|
20724
21332
|
if (isAwaitingBudget(run2.status, run2.stop_reason) && !opts.budgetApproved) {
|
|
20725
21333
|
return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u0436\u0434\u0451\u0442 \u043E\u0442\u0432\u0435\u0442\u0430 \u043D\u0430 \u0432\u043E\u043F\u0440\u043E\u0441 \u043E \u0431\u044E\u0434\u0436\u0435\u0442\u0435 \u2014 \u043E\u0442\u0432\u0435\u0442\u044C \u043D\u0430 \u043D\u0435\u0433\u043E \xAB\u0434\u0430\xBB \u0438\u043B\u0438 \xAB\u043D\u0435\u0442\xBB, \u043F\u043E\u0431\u0443\u0434\u043A\u0430 \u0431\u0435\u0437 \u043E\u0442\u0432\u0435\u0442\u0430 \u043F\u043E\u043B\u0443\u0447\u0438\u043B\u0430 \u0431\u044B \u043E\u0433\u0440\u044B\u0437\u043E\u043A \u0431\u044E\u0434\u0436\u0435\u0442\u0430` };
|
|
20726
21334
|
}
|
|
20727
|
-
if (run2.pid != null && deps.isAlive(run2.pid))
|
|
21335
|
+
if (run2.pid != null && deps.isAlive(run2.pid)) {
|
|
21336
|
+
if (run2.status === "review") return { ok: false, why: lingeringSubmitterWhy(run2, deps.db.events(run2.id), (deps.now ?? Date.now)()) };
|
|
21337
|
+
return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u0443\u0436\u0435 \u0440\u0430\u0431\u043E\u0442\u0430\u0435\u0442 (pid ${run2.pid}) \u2014 \u0431\u0443\u0434\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E` };
|
|
21338
|
+
}
|
|
20728
21339
|
if (isTerminalStatus(run2.status)) return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u0442\u0435\u0440\u043C\u0438\u043D\u0430\u043B\u0435\u043D (${run2.status}) \u2014 \u0431\u0443\u0434\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E` };
|
|
20729
21340
|
const capHolder = cycleCapHolder(deps.db, run2);
|
|
20730
21341
|
if (capHolder) {
|
|
@@ -20740,7 +21351,7 @@ async function wakeRun(deps, runId, opts = {}) {
|
|
|
20740
21351
|
if (run2.status === "review" && run2.pr_url && !needsFixIteration(run2) && !stoppedForHuman) {
|
|
20741
21352
|
return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u0443\u0436\u0435 \u0441\u0434\u0430\u043D \u043D\u0430 \u0440\u0435\u0432\u044C\u044E (${run2.pr_url}) \u2014 \u0431\u0443\u0434\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u0433\u043E; \u043F\u0440\u0430\u0432\u043A\u0438 \u043F\u043E\u0434\u043D\u0438\u043C\u0435\u0442 \u0440\u043E\u0439 \u043F\u043E \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0443` };
|
|
20742
21353
|
}
|
|
20743
|
-
const worktreeExists = deps.worktreeExists ??
|
|
21354
|
+
const worktreeExists = deps.worktreeExists ?? existsSync23;
|
|
20744
21355
|
const hasTranscript = deps.hasTranscript ?? executorHasSession;
|
|
20745
21356
|
const wt = run2.worktree_path;
|
|
20746
21357
|
const canContinue = !!wt && worktreeExists(wt) && hasTranscript(run2);
|
|
@@ -20748,23 +21359,26 @@ async function wakeRun(deps, runId, opts = {}) {
|
|
|
20748
21359
|
if (!canContinue && isService) {
|
|
20749
21360
|
return { ok: false, why: `\u043F\u0440\u043E\u0433\u043E\u043D #${runId} \u2014 \u0441\u043B\u0443\u0436\u0435\u0431\u043D\u044B\u0439 (\u0440\u0435\u0432\u044C\u044E\u0435\u0440/\u0440\u0435\u0437\u043E\u043B\u0432\u0435\u0440), \u0430 \u0441\u0435\u0441\u0441\u0438\u044E \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C \u043D\u0435\u0447\u0435\u043C: fresh \u043F\u043E\u0442\u0435\u0440\u044F\u043B \u0431\u044B \u0435\u0433\u043E \u043A\u043E\u043D\u0442\u0435\u043A\u0441\u0442` };
|
|
20750
21361
|
}
|
|
20751
|
-
const
|
|
21362
|
+
const reviewChanges = run2.review_verdict === "changes";
|
|
21363
|
+
const liveFix = reviewChanges && canContinue && fixIterationSessionOpen(deps.db, run2.id);
|
|
21364
|
+
const needsFix = run2.kind !== "hero" && !isSubrun(run2) && !!run2.pr_url && reviewChanges && !liveFix;
|
|
21365
|
+
const mode = needsFix ? "fix" : canContinue ? "continue" : "fresh";
|
|
20752
21366
|
const verifySummary = lastVerifySummary(deps.db, run2.id);
|
|
20753
21367
|
const reviewSummary = lastChangesSummary(deps.db, run2.id);
|
|
20754
|
-
const nudge = mode === "continue" && !isSubrun(run2) && run2.kind !== "hero" && run2.pr_url && (needsFixIteration(run2) || verifySummary || reviewSummary) ? buildSubmittedContinueNudge({ prUrl: run2.pr_url, verifySummary, reviewSummary }) : void 0;
|
|
21368
|
+
const nudge = mode === "continue" && !liveFix && !isSubrun(run2) && run2.kind !== "hero" && run2.pr_url && (needsFixIteration(run2) || verifySummary || reviewSummary) ? buildSubmittedContinueNudge({ prUrl: run2.pr_url, verifySummary, reviewSummary }) : void 0;
|
|
20755
21369
|
try {
|
|
20756
21370
|
await deps.respawn(run2, mode, nudge);
|
|
20757
21371
|
} catch (e) {
|
|
20758
21372
|
return { ok: false, why: `\u043F\u043E\u0431\u0443\u0434\u043A\u0430 \u043F\u0440\u043E\u0433\u043E\u043D\u0430 #${runId} \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C: ${String(e)}` };
|
|
20759
21373
|
}
|
|
20760
21374
|
if (run2.stop_reason != null) deps.db.updateRun(run2.id, { stop_reason: null });
|
|
20761
|
-
|
|
20762
|
-
|
|
20763
|
-
|
|
20764
|
-
|
|
21375
|
+
const how = mode === "continue" ? "\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B \u0432\u0440\u0443\u0447\u043D\u0443\u044E (--continue)" : mode === "fix" ? "\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B \u0432\u0440\u0443\u0447\u043D\u0443\u044E (\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F \u043F\u043E \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0443 \xAB\u043D\u0443\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u043A\u0438\xBB)" : "\u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B \u0432\u0440\u0443\u0447\u043D\u0443\u044E (\u0441\u0442\u0430\u0440\u0442 \u0437\u0430\u043D\u043E\u0432\u043E \u2014 \u0441\u0435\u0441\u0441\u0438\u044F/worktree \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u043D\u044B)";
|
|
21376
|
+
deps.db.addEvent(run2.id, "resumed", how);
|
|
21377
|
+
deps.narrate?.(
|
|
21378
|
+
`\u041E\u043F\u0435\u0440\u0430\u0442\u043E\u0440 \u0440\u0430\u0437\u0431\u0443\u0434\u0438\u043B ${droneLabel(run2)} \u0432\u0440\u0443\u0447\u043D\u0443\u044E (${mode === "continue" ? "--continue" : mode === "fix" ? "\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F" : "\u0441 \u043D\u0443\u043B\u044F"}).`
|
|
20765
21379
|
);
|
|
20766
|
-
|
|
20767
|
-
return { ok: true, why: `\u0440\u0430\u0437\u0431\u0443\u0436\u0435\u043D (${
|
|
21380
|
+
const howShort = mode === "continue" ? "--continue" : mode === "fix" ? "\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F" : "fresh";
|
|
21381
|
+
return { ok: true, why: `\u0440\u0430\u0437\u0431\u0443\u0436\u0435\u043D (${howShort}): #${run2.id} ${run2.name} ${run2.task_slug}` };
|
|
20768
21382
|
}
|
|
20769
21383
|
function reviveStuck(deps) {
|
|
20770
21384
|
const stormCleared = deps.db.stormActive();
|
|
@@ -20868,9 +21482,9 @@ function repoHasCi(deps, run2) {
|
|
|
20868
21482
|
function repoHasCiWorkflows(worktreePath, repo) {
|
|
20869
21483
|
for (const base3 of [worktreePath, repo]) {
|
|
20870
21484
|
if (!base3) continue;
|
|
20871
|
-
const dir =
|
|
21485
|
+
const dir = join38(base3, ".github", "workflows");
|
|
20872
21486
|
try {
|
|
20873
|
-
if (
|
|
21487
|
+
if (readdirSync16(dir).some((f) => f.endsWith(".yml") || f.endsWith(".yaml"))) return true;
|
|
20874
21488
|
} catch {
|
|
20875
21489
|
}
|
|
20876
21490
|
}
|
|
@@ -21092,7 +21706,7 @@ async function wakeReviewerOnCiReady(deps, run2, over) {
|
|
|
21092
21706
|
return true;
|
|
21093
21707
|
}
|
|
21094
21708
|
function worktreeAndTranscriptAlive(deps, run2) {
|
|
21095
|
-
const exists = deps.worktreeExists ??
|
|
21709
|
+
const exists = deps.worktreeExists ?? existsSync23;
|
|
21096
21710
|
const transcript = deps.hasTranscript ?? executorHasSession;
|
|
21097
21711
|
const wt = run2.worktree_path;
|
|
21098
21712
|
return !!wt && exists(wt) && transcript(run2);
|
|
@@ -21125,17 +21739,101 @@ async function spawnFreshReviewerAfterStall(deps, run2, why) {
|
|
|
21125
21739
|
deps.db.addEvent(run2.id, "step", `\u0441\u0432\u0435\u0436\u0438\u0439 \u0440\u0435\u0432\u044C\u044E\u0435\u0440 \u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u0442\u0435\u0440\u0438 \u0441\u0435\u0441\u0441\u0438\u0438 \u043D\u0435 \u043F\u043E\u0434\u043D\u044F\u043B\u0441\u044F: ${String(e)}`);
|
|
21126
21740
|
}
|
|
21127
21741
|
}
|
|
21742
|
+
var fixBlockedThisTick = /* @__PURE__ */ new Map();
|
|
21743
|
+
var draftHeldThisTick = /* @__PURE__ */ new Map();
|
|
21744
|
+
var FIX_BLOCK_REASON_MAX = 300;
|
|
21745
|
+
var ANOMALY_BODY_MAX = 2e3;
|
|
21746
|
+
function clipChars(text, max) {
|
|
21747
|
+
if (text.length <= max) return text;
|
|
21748
|
+
let end = max - 1;
|
|
21749
|
+
if (end > 0) {
|
|
21750
|
+
const last = text.charCodeAt(end - 1);
|
|
21751
|
+
if (last >= 55296 && last <= 56319) end -= 1;
|
|
21752
|
+
}
|
|
21753
|
+
return `${text.slice(0, end)}\u2026`;
|
|
21754
|
+
}
|
|
21755
|
+
function blockFix(run2, reason) {
|
|
21756
|
+
fixBlockedThisTick.set(run2.id, { run: run2, reason: clipChars(reason, FIX_BLOCK_REASON_MAX) });
|
|
21757
|
+
return false;
|
|
21758
|
+
}
|
|
21759
|
+
function noteDraftHold(run2) {
|
|
21760
|
+
draftHeldThisTick.set(run2.id, run2);
|
|
21761
|
+
}
|
|
21762
|
+
function draftHoldBody(prUrl) {
|
|
21763
|
+
const n = prUrl?.match(/\/pull\/(\d+)/)?.[1];
|
|
21764
|
+
return `PR ${n ? `#${n}` : prUrl ?? "?"} \u0432 \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\u0435 \u2014 \u0440\u043E\u0439 \u0436\u0434\u0451\u0442, \u0432\u0435\u0440\u043D\u0438\u0442\u0435 \u0432 ready`;
|
|
21765
|
+
}
|
|
21766
|
+
function tickSuppressesAnomaly(key) {
|
|
21767
|
+
for (const id of draftHeldThisTick.keys()) if (key === `pr_no_reviewer:${id}`) return true;
|
|
21768
|
+
for (const id of fixBlockedThisTick.keys()) if (key === `pr_stuck_changes:${id}`) return true;
|
|
21769
|
+
return false;
|
|
21770
|
+
}
|
|
21771
|
+
function tickAnomalyCandidates(autoReviewSnapshot) {
|
|
21772
|
+
const out = [];
|
|
21773
|
+
for (const run2 of draftHeldThisTick.values()) {
|
|
21774
|
+
if (autoReviewSnapshot?.get(run2.repo) === false) continue;
|
|
21775
|
+
out.push({
|
|
21776
|
+
key: `pr_draft_hold:${run2.id}`,
|
|
21777
|
+
minDurationMs: SWARM_ANOMALY_PR_NO_REVIEWER_MS,
|
|
21778
|
+
build: () => ({
|
|
21779
|
+
runId: run2.id,
|
|
21780
|
+
level: "decision",
|
|
21781
|
+
title: signalTitle(run2, "PR \u0432 \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\u0435"),
|
|
21782
|
+
body: draftHoldBody(run2.pr_url),
|
|
21783
|
+
...hrefOf(run2.task_url)
|
|
21784
|
+
})
|
|
21785
|
+
});
|
|
21786
|
+
}
|
|
21787
|
+
for (const { run: run2, reason } of fixBlockedThisTick.values()) {
|
|
21788
|
+
out.push({
|
|
21789
|
+
key: `fix_stalled:${run2.id}`,
|
|
21790
|
+
minDurationMs: CHANGES_FRESH_WAKE_AFTER_MS,
|
|
21791
|
+
build: () => ({
|
|
21792
|
+
runId: run2.id,
|
|
21793
|
+
level: "decision",
|
|
21794
|
+
// Текст НЕ содержит CHANGES_WAKE_ESCALATION_MARK («фикс-итерация не поднялась»):
|
|
21795
|
+
// веха anomaly пишется этим же body, и следующий тик прочитал бы её как эскалацию
|
|
21796
|
+
// needs_human — второе уведомление на ту же причину.
|
|
21797
|
+
title: signalTitle(run2, "\u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F \u0441\u0442\u043E\u0438\u0442"),
|
|
21798
|
+
body: `${run2.task_slug}: \u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044F \u0441\u0442\u043E\u0438\u0442 \u2014 ${reason}.`,
|
|
21799
|
+
...hrefOf(run2.task_url)
|
|
21800
|
+
})
|
|
21801
|
+
});
|
|
21802
|
+
}
|
|
21803
|
+
return out.map((c) => ({
|
|
21804
|
+
...c,
|
|
21805
|
+
build: () => {
|
|
21806
|
+
const signal = c.build();
|
|
21807
|
+
return signal.body == null ? signal : { ...signal, body: clipChars(signal.body, ANOMALY_BODY_MAX) };
|
|
21808
|
+
}
|
|
21809
|
+
}));
|
|
21810
|
+
}
|
|
21811
|
+
var DAEMON_CODE_FIX_HOLD_REASON = "PR \u0442\u0440\u043E\u0433\u0430\u0435\u0442 \u043A\u043E\u0434 \u0434\u0435\u043C\u043E\u043D\u0430 (TASWM-270) \u2014 \u043D\u0430\u0445\u043E\u0434\u043A\u0438 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430 \u0436\u0434\u0443\u0442 \u0440\u0435\u0448\u0435\u043D\u0438\u044F \u0447\u0435\u043B\u043E\u0432\u0435\u043A\u0430: \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u0438\u043B\u0438 wake_run";
|
|
21812
|
+
async function liftFixIterationStep(deps, snapshot, st, stormActive, now, droneCap) {
|
|
21813
|
+
const run2 = deps.db.getRun(snapshot.id) ?? snapshot;
|
|
21814
|
+
if (run2.status !== "review") return null;
|
|
21815
|
+
if (needsFixIteration(run2) && !stormActive && !st.conflicting && !deps.db.activeResolverFor(run2.id)) {
|
|
21816
|
+
const capFull = countActiveDrones(deps.db) >= droneCap;
|
|
21817
|
+
if (await wakeAuthorOnChanges(deps, run2, now, droneCap)) {
|
|
21818
|
+
deps.returners?.delete(run2.id);
|
|
21819
|
+
return null;
|
|
21820
|
+
}
|
|
21821
|
+
if (deps.db.getRun(run2.id)?.status !== "review") return null;
|
|
21822
|
+
if (capFull) noteReturner(deps, run2, now, { kind: "changes", since: now });
|
|
21823
|
+
}
|
|
21824
|
+
return run2;
|
|
21825
|
+
}
|
|
21128
21826
|
async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
|
|
21129
21827
|
if (!deps.respawn) return false;
|
|
21130
21828
|
const run2 = deps.db.getRun(snapshot.id);
|
|
21131
21829
|
if (!run2 || isAwaitingBudget(run2.status, run2.stop_reason)) return false;
|
|
21132
21830
|
if (run2.pid != null && deps.isAlive(run2.pid)) return false;
|
|
21133
21831
|
if (deps.db.activeReviewersFor(run2.id).some((r) => r.status !== "stalled" && !isAwaitingCi(r.status, r.stop_reason))) {
|
|
21134
|
-
return
|
|
21832
|
+
return blockFix(run2, "\u0440\u0435\u0432\u044C\u044E\u0435\u0440 \u0435\u0449\u0451 \u0432 \u0440\u0430\u0431\u043E\u0442\u0435");
|
|
21135
21833
|
}
|
|
21136
|
-
if (deps.resourcesOk && !deps.resourcesOk()) return
|
|
21137
|
-
if (countActiveDrones(deps.db) >= droneCap) return
|
|
21138
|
-
if (!await projectQuotaGateAllows(deps, run2)) return
|
|
21834
|
+
if (deps.resourcesOk && !deps.resourcesOk()) return blockFix(run2, "\u043C\u0430\u0448\u0438\u043D\u0430 \u043F\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043D\u0430");
|
|
21835
|
+
if (countActiveDrones(deps.db) >= droneCap) return blockFix(run2, "\u043D\u0435\u0442 \u0441\u0432\u043E\u0431\u043E\u0434\u043D\u043E\u0433\u043E \u0441\u043B\u043E\u0442\u0430 \u0434\u0440\u043E\u043D\u0430");
|
|
21836
|
+
if (!await projectQuotaGateAllows(deps, run2)) return blockFix(run2, "\u043F\u0440\u043E\u0435\u043A\u0442 \u0437\u0430\u043D\u044F\u0442 \u2014 \u0436\u0434\u0451\u043C \u043E\u0441\u0432\u043E\u0431\u043E\u0436\u0434\u0435\u043D\u0438\u044F");
|
|
21139
21837
|
if (reviewCyclesExhausted(run2)) {
|
|
21140
21838
|
await noteReviewCyclesExhausted(deps, run2);
|
|
21141
21839
|
return false;
|
|
@@ -21160,7 +21858,9 @@ async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
|
|
|
21160
21858
|
if (alreadyEscalated) return false;
|
|
21161
21859
|
const attempts = events.filter((e) => e.kind === "resumed" && (e.text ?? "").includes(CHANGES_WAKE_MARK));
|
|
21162
21860
|
const lastAttemptMs = attempts.length ? sqliteMs(attempts[attempts.length - 1].at) : null;
|
|
21163
|
-
if (lastAttemptMs != null && now - lastAttemptMs < CHANGES_WAKE_COOLDOWN_MS)
|
|
21861
|
+
if (lastAttemptMs != null && now - lastAttemptMs < CHANGES_WAKE_COOLDOWN_MS) {
|
|
21862
|
+
return blockFix(run2, "\u043C\u0435\u0436\u0434\u0443 \u043F\u043E\u0431\u0443\u0434\u043A\u0430\u043C\u0438 \u0435\u0449\u0451 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B cooldown");
|
|
21863
|
+
}
|
|
21164
21864
|
const wakes = attempts.filter((e) => !(e.text ?? "").includes(CHANGES_WAKE_FAILED_MARK));
|
|
21165
21865
|
if (wakes.length >= CHANGES_WAKE_LIMIT) {
|
|
21166
21866
|
const streakStart = wakes[wakes.length - CHANGES_WAKE_LIMIT].at;
|
|
@@ -21196,10 +21896,14 @@ async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
|
|
|
21196
21896
|
}
|
|
21197
21897
|
const wt = run2.worktree_path;
|
|
21198
21898
|
const wtPath = wt || (deps.worktreesDir ? droneWorktreePath(deps.worktreesDir, normalizeRepo(run2.repo || deps.repoFallback || ""), run2.task_slug) : null);
|
|
21199
|
-
const worktreeReady = !!wtPath && (deps.worktreeExists ??
|
|
21200
|
-
if (!worktreeReady
|
|
21899
|
+
const worktreeReady = !!wtPath && (deps.worktreeExists ?? existsSync23)(wtPath);
|
|
21900
|
+
if (!worktreeReady) {
|
|
21901
|
+
const why = await freshChangesWakeBlock(deps, run2, prUrl, now);
|
|
21902
|
+
if (why) return blockFix(run2, why);
|
|
21903
|
+
}
|
|
21201
21904
|
try {
|
|
21202
21905
|
await deps.respawn(run2, "fix");
|
|
21906
|
+
fixBlockedThisTick.delete(run2.id);
|
|
21203
21907
|
deps.db.addEvent(run2.id, "step", `${CHANGES_FIX_COST_MARK}: $${(run2.cost_usd ?? 0).toFixed(2)}`);
|
|
21204
21908
|
if (run2.stop_reason != null) deps.db.updateRun(run2.id, { stop_reason: null });
|
|
21205
21909
|
const how = worktreeReady ? "\u0441\u0432\u0435\u0436\u0438\u0439 \u0434\u0440\u043E\u043D \u0441 \u0431\u0440\u0438\u0444\u043E\u043C \u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438 \u0432 \u0442\u043E\u043C \u0436\u0435 worktree" : "\u0441\u0432\u0435\u0436\u0438\u0439 \u0434\u0440\u043E\u043D \u0441 \u0431\u0440\u0438\u0444\u043E\u043C \u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, worktree \u043F\u0435\u0440\u0435-\u0441\u043E\u0437\u0434\u0430\u0451\u0442\u0441\u044F \u0441 origin";
|
|
@@ -21209,20 +21913,24 @@ async function wakeAuthorOnChanges(deps, snapshot, now, droneCap) {
|
|
|
21209
21913
|
} catch (e) {
|
|
21210
21914
|
deps.db.addEvent(run2.id, "resumed", `${CHANGES_WAKE_MARK}: ${CHANGES_WAKE_FAILED_MARK} \u2014 ${String(e)}`);
|
|
21211
21915
|
narrate(deps, `\u043F\u043E\u0431\u0443\u0434\u043A\u0430 ${droneLabel(run2)} \u043D\u0430 \u0444\u0438\u043A\u0441-\u0438\u0442\u0435\u0440\u0430\u0446\u0438\u044E \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C.`);
|
|
21212
|
-
return
|
|
21916
|
+
return blockFix(run2, `\u043F\u043E\u0431\u0443\u0434\u043A\u0430 \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C: ${String(e)}`);
|
|
21213
21917
|
}
|
|
21214
21918
|
}
|
|
21215
21919
|
var freshWakeProbeAt = /* @__PURE__ */ new Map();
|
|
21216
|
-
async function
|
|
21217
|
-
const verdictAt = changesVerdictAt(deps.db, run2
|
|
21218
|
-
|
|
21219
|
-
|
|
21220
|
-
if (
|
|
21221
|
-
|
|
21222
|
-
|
|
21223
|
-
|
|
21224
|
-
const
|
|
21225
|
-
|
|
21920
|
+
async function freshChangesWakeBlock(deps, run2, prUrl, now) {
|
|
21921
|
+
const verdictAt = changesVerdictAt(deps.db, run2, now);
|
|
21922
|
+
if (!verdictAt) return null;
|
|
21923
|
+
const verdictMs = sqliteMs(verdictAt);
|
|
21924
|
+
if (Number.isFinite(verdictMs) && now - verdictMs < CHANGES_FRESH_WAKE_AFTER_MS) {
|
|
21925
|
+
return "\u043A\u0430\u0442\u0430\u043B\u043E\u0433 \u043F\u043E\u0442\u0435\u0440\u044F\u043D, \u0430 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0435\u0449\u0451 \u043D\u0435 \u043E\u0442\u043B\u0435\u0436\u0430\u043B\u0441\u044F \u2014 \u0432\u0442\u043E\u0440\u043E\u0439 \u0434\u0440\u043E\u043D \u043D\u0430 \u0432\u0435\u0442\u043A\u0443 \u0440\u0430\u043D\u043E";
|
|
21926
|
+
}
|
|
21927
|
+
if (!deps.commitsSince) return null;
|
|
21928
|
+
const probeKey = `${run2.task_slug}|${run2.created_at}`;
|
|
21929
|
+
const probe = freshWakeProbeAt.get(run2.id);
|
|
21930
|
+
if (probe && probe.key === probeKey && now - probe.ms < CHANGES_WAKE_COOLDOWN_MS) return "\u0441\u0432\u0435\u0436\u0438\u0439 \u043E\u043F\u0440\u043E\u0441 \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u0432 \u0431\u044B\u043B \u043D\u0435\u0434\u0430\u0432\u043D\u043E \u2014 \u0436\u0434\u0451\u043C";
|
|
21931
|
+
freshWakeProbeAt.set(run2.id, { key: probeKey, ms: now });
|
|
21932
|
+
const moved = await deps.commitsSince(prUrl, verdictAt).catch(() => true);
|
|
21933
|
+
return moved ? "\u0432 \u0432\u0435\u0442\u043A\u0435 \u043F\u043E\u0441\u043B\u0435 \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0430 \u0435\u0441\u0442\u044C \u043A\u043E\u043C\u043C\u0438\u0442\u044B \u2014 \u043D\u0430 \u043D\u0435\u0451 \u043D\u0435 \u043B\u0435\u0437\u0435\u043C" : null;
|
|
21226
21934
|
}
|
|
21227
21935
|
async function prodOverrideReason(deps, run2, allowed) {
|
|
21228
21936
|
if (!deps.db.refreshRun) return null;
|
|
@@ -21279,7 +21987,7 @@ async function zoneConflictFor(db, models, activeFiles, run2, repo, repoFallback
|
|
|
21279
21987
|
activeFiles.prune(holders.map((r) => r.id));
|
|
21280
21988
|
const fileExists = (p) => {
|
|
21281
21989
|
try {
|
|
21282
|
-
return
|
|
21990
|
+
return statSync15(join38(repo, p), { throwIfNoEntry: false })?.isFile() ?? false;
|
|
21283
21991
|
} catch {
|
|
21284
21992
|
return false;
|
|
21285
21993
|
}
|
|
@@ -21717,7 +22425,7 @@ async function liftReturners(deps, returners, now, droneCap) {
|
|
|
21717
22425
|
deps.returners?.delete(run2.id);
|
|
21718
22426
|
continue;
|
|
21719
22427
|
}
|
|
21720
|
-
lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ??
|
|
22428
|
+
lifted = await wakeAuthorOnRedCi(deps, run2, now, entry.ci, deps.worktreeExists ?? existsSync23, deps.hasTranscript ?? executorHasSession, droneCap);
|
|
21721
22429
|
}
|
|
21722
22430
|
if (lifted) deps.returners?.delete(run2.id);
|
|
21723
22431
|
}
|
|
@@ -21741,7 +22449,7 @@ async function resumeWatchdogParked(deps, droneCap) {
|
|
|
21741
22449
|
await handOffAtCycleCap(deps, candidate, capHolder, "\u0432\u043E\u0437\u0432\u0440\u0430\u0442 \u0438\u0437 \u043F\u0430\u0440\u043A\u043E\u0432\u043A\u0438 \u0441\u0442\u043E\u0440\u043E\u0436\u0430");
|
|
21742
22450
|
return;
|
|
21743
22451
|
}
|
|
21744
|
-
const worktreeExists = deps.worktreeExists ??
|
|
22452
|
+
const worktreeExists = deps.worktreeExists ?? existsSync23;
|
|
21745
22453
|
const hasTranscript = deps.hasTranscript ?? executorHasSession;
|
|
21746
22454
|
const wt = candidate.worktree_path;
|
|
21747
22455
|
const canContinue = !!wt && worktreeExists(wt) && hasTranscript(candidate);
|
|
@@ -22193,17 +22901,30 @@ async function workFate(deps, run2) {
|
|
|
22193
22901
|
if (exists === false) return `${EXIT_WORK_LOST} (\u0432\u0435\u0442\u043A\u0438 ${branch} \u043D\u0430 origin \u043D\u0435\u0442)`;
|
|
22194
22902
|
return EXIT_WORK_UNKNOWN;
|
|
22195
22903
|
}
|
|
22904
|
+
var FIX_DIED_NO_COMMITS_TEXT = "\u0444\u0438\u043A\u0441-\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440 \u0431\u0435\u0437 \u043D\u043E\u0432\u044B\u0445 \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u0432 \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D";
|
|
22196
22905
|
async function deliveredPrUrl(deps, run2) {
|
|
22906
|
+
if (!isSubrun(run2) && needsFixIteration(run2)) {
|
|
22907
|
+
const prUrl2 = run2.pr_url ?? await openPrOfBranch(deps, run2);
|
|
22908
|
+
if (!prUrl2) return null;
|
|
22909
|
+
if (!deps.commitsSince) return prUrl2;
|
|
22910
|
+
const since = changesVerdictAt(deps.db, run2, deps.now ? deps.now() : Date.now());
|
|
22911
|
+
if (since && await deps.commitsSince(prUrl2, since).catch(() => false)) return prUrl2;
|
|
22912
|
+
deps.db.addEvent(run2.id, "step", `${FIX_DIED_NO_COMMITS_TEXT}: \u0432 ${prUrl2} \u043D\u0435\u0442 \u043A\u043E\u043C\u043C\u0438\u0442\u043E\u0432 \u043F\u043E\u0441\u043B\u0435 \u0432\u0435\u0440\u0434\u0438\u043A\u0442\u0430${since ? ` (${since})` : ""}`);
|
|
22913
|
+
return null;
|
|
22914
|
+
}
|
|
22197
22915
|
if (run2.pr_url) return run2.pr_url;
|
|
22198
|
-
|
|
22199
|
-
const prs = await deps.openPrsForBranch(run2.branch || run2.task_slug, run2.repo).catch(() => []);
|
|
22200
|
-
const prUrl = prs[0] ?? null;
|
|
22916
|
+
const prUrl = await openPrOfBranch(deps, run2);
|
|
22201
22917
|
if (!prUrl) return null;
|
|
22202
22918
|
if (deps.commitsSince && !await deps.commitsSince(prUrl, run2.created_at).catch(() => false)) {
|
|
22203
22919
|
return null;
|
|
22204
22920
|
}
|
|
22205
22921
|
return prUrl;
|
|
22206
22922
|
}
|
|
22923
|
+
async function openPrOfBranch(deps, run2) {
|
|
22924
|
+
if (!deps.openPrsForBranch) return null;
|
|
22925
|
+
const prs = await deps.openPrsForBranch(run2.branch || run2.task_slug, run2.repo).catch(() => []);
|
|
22926
|
+
return prs[0] ?? null;
|
|
22927
|
+
}
|
|
22207
22928
|
async function postAdoptionReport(deps, run2, prUrl, cycle) {
|
|
22208
22929
|
if (!deps.reportComment) return;
|
|
22209
22930
|
const [titles, journal] = await Promise.all([
|
|
@@ -22267,6 +22988,58 @@ async function recordReviewFindingsFromPr(deps, rv) {
|
|
|
22267
22988
|
} catch {
|
|
22268
22989
|
}
|
|
22269
22990
|
}
|
|
22991
|
+
var PICKUP_BODY_MAX = 4e3;
|
|
22992
|
+
var PICKUP_TAIL_KEEP = 600;
|
|
22993
|
+
var PICKUP_EVENT_PREFIX = "\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043F\u043E\u0434\u0445\u0432\u0430\u0447\u0435\u043D \u0438\u0437 PR-\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430";
|
|
22994
|
+
var PICKUP_CLIP_MARK = "(\u043E\u0431\u0440\u0435\u0437\u0430\u043D\u043E, \u043B\u0438\u043C\u0438\u0442";
|
|
22995
|
+
var PICKUP_HEADER_LABELS = /* @__PURE__ */ new Set(["\u274C REQUEST CHANGES", "REQUEST CHANGES", "\u2705 APPROVE", "APPROVE", "CHANGES"]);
|
|
22996
|
+
function clipPickupBody(body) {
|
|
22997
|
+
if (body.length <= PICKUP_BODY_MAX) return body;
|
|
22998
|
+
const note = `
|
|
22999
|
+
\u2026 ${PICKUP_CLIP_MARK} ${PICKUP_BODY_MAX}, \u0431\u044B\u043B\u043E ${body.length} \u0437\u043D\u0430\u043A\u043E\u0432)
|
|
23000
|
+
`;
|
|
23001
|
+
const tail2 = body.slice(-PICKUP_TAIL_KEEP);
|
|
23002
|
+
const headLen = Math.max(0, PICKUP_BODY_MAX - note.length - tail2.length);
|
|
23003
|
+
return body.slice(0, headLen) + note + tail2;
|
|
23004
|
+
}
|
|
23005
|
+
function pickedVerdictEventText(how, verdict, body, mark) {
|
|
23006
|
+
const review = verdict === "approve" || verdict === "changes";
|
|
23007
|
+
const prefix = review ? PICKUP_EVENT_PREFIX : VERIFY_PICKUP_EVENT_PREFIX;
|
|
23008
|
+
const label2 = review ? verdictLabel(verdict) : verifyVerdictLabel(verdict);
|
|
23009
|
+
const trimmed = body?.trim() ?? "";
|
|
23010
|
+
const payload = trimmed ? clipPickupBody(trimmed) : label2;
|
|
23011
|
+
const tail2 = mark ? ` [${mark}]` : "";
|
|
23012
|
+
return `${prefix} (${how}): ${payload}${tail2}`;
|
|
23013
|
+
}
|
|
23014
|
+
function verdictEventPayload(text) {
|
|
23015
|
+
const sep3 = text.startsWith(PICKUP_EVENT_PREFIX) ? "): " : ": ";
|
|
23016
|
+
const at = text.indexOf(sep3);
|
|
23017
|
+
if (at < 0) return "";
|
|
23018
|
+
return text.slice(at + sep3.length).trim().replace(/\s+\[[^\]]*\]\s*$/, "").trim();
|
|
23019
|
+
}
|
|
23020
|
+
function isHeaderOnlyVerdict(text) {
|
|
23021
|
+
if (!text.startsWith(PICKUP_EVENT_PREFIX) && !text.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0440\u0435\u0432\u044C\u044E \u043E\u0442")) return false;
|
|
23022
|
+
const rest = verdictEventPayload(text);
|
|
23023
|
+
return rest.length === 0 || PICKUP_HEADER_LABELS.has(rest);
|
|
23024
|
+
}
|
|
23025
|
+
var VERIFY_HEADER_LABELS = /* @__PURE__ */ new Set(["\u041D\u0410\u0428\u0401\u041B", "\u041D\u0410\u0428\u0415\u041B", "\u041F\u041E\u0414\u0422\u0412\u0415\u0420\u0416\u0414\u0410\u042E", "\u041D\u0415 \u0412\u041E\u0421\u041F\u0420\u041E\u0418\u0417\u0412\u041E\u0414\u0418\u0422\u0421\u042F"]);
|
|
23026
|
+
function isVerifyHeaderOnly(text) {
|
|
23027
|
+
const pickup = text.startsWith(VERIFY_PICKUP_EVENT_PREFIX);
|
|
23028
|
+
if (!pickup && !text.startsWith("\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 \u043E\u0442")) return false;
|
|
23029
|
+
const sep3 = pickup ? "): " : ": ";
|
|
23030
|
+
const at = text.indexOf(sep3);
|
|
23031
|
+
if (at < 0) return true;
|
|
23032
|
+
const rest = text.slice(at + sep3.length).trim().replace(/\s+\[[^\]]*\]\s*$/, "").trim();
|
|
23033
|
+
return rest.length === 0 || VERIFY_HEADER_LABELS.has(rest);
|
|
23034
|
+
}
|
|
23035
|
+
function isClippedPickup(text) {
|
|
23036
|
+
if (!text.startsWith(PICKUP_EVENT_PREFIX) && !text.startsWith(VERIFY_PICKUP_EVENT_PREFIX)) return false;
|
|
23037
|
+
return text.includes(PICKUP_CLIP_MARK);
|
|
23038
|
+
}
|
|
23039
|
+
function verdictEventIsApprove(text) {
|
|
23040
|
+
const first = verdictEventPayload(text).split("\n")[0]?.trim() ?? "";
|
|
23041
|
+
return classifyPrVerdict(first) === "approve";
|
|
23042
|
+
}
|
|
22270
23043
|
async function salvageVerdictFromPrComment(deps, rv, reviewsRunId, since, ctx) {
|
|
22271
23044
|
if (!deps.verdictComment || !rv.pr_url) return false;
|
|
22272
23045
|
const found = await deps.verdictComment(rv.pr_url, since).catch(() => null);
|
|
@@ -22274,7 +23047,7 @@ async function salvageVerdictFromPrComment(deps, rv, reviewsRunId, since, ctx) {
|
|
|
22274
23047
|
const verdictText = verdictLabel(found.verdict);
|
|
22275
23048
|
deps.db.updateRun(reviewsRunId, { review_verdict: found.verdict });
|
|
22276
23049
|
recordReviewFindings(deps, rv, found);
|
|
22277
|
-
deps.db.addEvent(reviewsRunId, "step",
|
|
23050
|
+
deps.db.addEvent(reviewsRunId, "step", pickedVerdictEventText(ctx.how, found.verdict, found.body));
|
|
22278
23051
|
await closeReviewerRun(
|
|
22279
23052
|
deps,
|
|
22280
23053
|
rv,
|
|
@@ -22296,7 +23069,7 @@ async function salvageVerifyVerdictFromPrComment(deps, vr, verifiesRunId, since,
|
|
|
22296
23069
|
if (!found) return false;
|
|
22297
23070
|
const verdictText = verifyVerdictLabel(found.verdict);
|
|
22298
23071
|
deps.db.updateRun(verifiesRunId, { verify_verdict: found.verdict });
|
|
22299
|
-
deps.db.addEvent(verifiesRunId, "step",
|
|
23072
|
+
deps.db.addEvent(verifiesRunId, "step", pickedVerdictEventText(how, found.verdict, found.body));
|
|
22300
23073
|
await closeReviewerRun(deps, vr, `\u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u044B\u043D\u0435\u0441\u0435\u043D \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C (${verdictText}), ${how} \u2014 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u044F \u0437\u0430\u043A\u0440\u044B\u0442\u0430 \u0431\u0435\u0437 \u0441\u043F\u0430\u0432\u043D\u0430 \u0432\u0442\u043E\u0440\u043E\u0433\u043E \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430`);
|
|
22301
23074
|
narrate(deps, `${droneLabel(vr)} \u043E\u0441\u0442\u0430\u0432\u0438\u043B \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0446\u0438\u0438 (${verdictText}) \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u043E\u043C \u2014 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u043B, \u0432\u0442\u043E\u0440\u043E\u0433\u043E \u0432\u0435\u0440\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440\u0430 \u043D\u0435 \u043F\u043E\u0434\u043D\u0438\u043C\u0430\u044E.`);
|
|
22302
23075
|
return true;
|
|
@@ -22545,7 +23318,9 @@ function buildEscalationCandidates(db) {
|
|
|
22545
23318
|
}
|
|
22546
23319
|
async function tickOnce(deps) {
|
|
22547
23320
|
const now = deps.now ? deps.now() : Date.now();
|
|
22548
|
-
|
|
23321
|
+
draftHeldThisTick.clear();
|
|
23322
|
+
fixBlockedThisTick.clear();
|
|
23323
|
+
const worktreeExists = deps.worktreeExists ?? existsSync23;
|
|
22549
23324
|
const hasTranscript = deps.hasTranscript ?? executorHasSession;
|
|
22550
23325
|
deps.stepClock?.mark("0 \u0437\u0430\u043C\u0435\u0440 \u0445\u043E\u0441\u0442\u0430");
|
|
22551
23326
|
deps.sampleHost?.();
|
|
@@ -22622,6 +23397,8 @@ async function tickOnce(deps) {
|
|
|
22622
23397
|
});
|
|
22623
23398
|
}
|
|
22624
23399
|
}
|
|
23400
|
+
deps.stepClock?.mark("0b1 \u0430\u0432\u0442\u043E\u0440 \u043D\u0435 \u0432\u044B\u0448\u0435\u043B \u043F\u043E\u0441\u043B\u0435 \u0441\u0434\u0430\u0447\u0438");
|
|
23401
|
+
reapLingeringAuthors(deps, now);
|
|
22625
23402
|
deps.stepClock?.mark("0c \u0437\u0430\u0449\u0438\u0442\u043D\u044B\u0439 sweep \u043E\u0441\u0438\u0440\u043E\u0442\u0435\u0432\u0448\u0438\u0445 \u043F\u0440\u043E\u0446\u0435\u0441\u0441\u043E\u0432/doc");
|
|
22626
23403
|
if (deps.sweep) {
|
|
22627
23404
|
const sw = deps.sweep;
|
|
@@ -22797,6 +23574,12 @@ async function tickOnce(deps) {
|
|
|
22797
23574
|
);
|
|
22798
23575
|
}
|
|
22799
23576
|
}
|
|
23577
|
+
const selfRefRun = deps.db.getRun(run2.id) ?? run2;
|
|
23578
|
+
if (selfRefRun.review_verdict === "changes") {
|
|
23579
|
+
await liftFixIterationStep(deps, selfRefRun, st, stormActive, now, droneCap);
|
|
23580
|
+
} else if (needsFixIteration(selfRefRun)) {
|
|
23581
|
+
blockFix(selfRefRun, DAEMON_CODE_FIX_HOLD_REASON);
|
|
23582
|
+
}
|
|
22800
23583
|
continue;
|
|
22801
23584
|
}
|
|
22802
23585
|
await retireOutdatedReviewers(deps, run2);
|
|
@@ -22871,16 +23654,10 @@ async function tickOnce(deps) {
|
|
|
22871
23654
|
} else if (!st.conflicting && deps.ci && deps.respawn && !stormActive) {
|
|
22872
23655
|
await handleCi(deps, run2, now, worktreeExists, hasTranscript, droneCap);
|
|
22873
23656
|
}
|
|
22874
|
-
|
|
22875
|
-
|
|
22876
|
-
|
|
22877
|
-
|
|
22878
|
-
continue;
|
|
22879
|
-
}
|
|
22880
|
-
if (deps.db.getRun(run2.id)?.status !== "review") continue;
|
|
22881
|
-
if (capFull) noteReturner(deps, run2, now, { kind: "changes", since: now });
|
|
22882
|
-
}
|
|
22883
|
-
const reviewerGatesOk = !st.conflicting && !st.isDraft && !!deps.spawnReviewer && !stormActive && (!deps.reviewCutoffAt || run2.updated_at >= deps.reviewCutoffAt) && deps.db.reviewerCountFor(run2.id) === 0 && // ГЕЙТ ПЕРВЫМ: живой/успешный ревьюер уже есть — ни капа, ни спавна не трогаем
|
|
23657
|
+
const afterFix = await liftFixIterationStep(deps, run2, st, stormActive, now, droneCap);
|
|
23658
|
+
if (!afterFix) continue;
|
|
23659
|
+
run2 = afterFix;
|
|
23660
|
+
const reviewerReadyExceptDraft = !st.conflicting && !!deps.spawnReviewer && !stormActive && (!deps.reviewCutoffAt || run2.updated_at >= deps.reviewCutoffAt) && deps.db.reviewerCountFor(run2.id) === 0 && // ГЕЙТ ПЕРВЫМ: живой/успешный ревьюер уже есть — ни капа, ни спавна не трогаем
|
|
22884
23661
|
// …и НИ ОДНОГО живого/ждущего ревьюера ЛЮБОГО цикла (TASWM-299). reviewerCountFor
|
|
22885
23662
|
// выше скоупится по review_cycle, поэтому сама по себе она не инвариант «один
|
|
22886
23663
|
// ревьюер на PR», а лишь идемпотентность внутри круга: фикс-итерация бампит цикл, и
|
|
@@ -22889,6 +23666,10 @@ async function tickOnce(deps) {
|
|
|
22889
23666
|
// не порядком веток в 900-строчной функции: увидели живого — значит закрывать его
|
|
22890
23667
|
// рано, спавнить второго нельзя.
|
|
22891
23668
|
liveOrWaitingReviewers(deps.db, run2.id).length === 0;
|
|
23669
|
+
const reviewerGatesOk = reviewerReadyExceptDraft && !st.isDraft;
|
|
23670
|
+
if (st.isDraft && reviewerReadyExceptDraft && !needsFixIteration(run2)) {
|
|
23671
|
+
noteDraftHold(run2);
|
|
23672
|
+
}
|
|
22892
23673
|
if (reviewerGatesOk && deps.spawnReviewer && await projectWantsChecks(deps, run2)) {
|
|
22893
23674
|
if (reviewCyclesExhausted(run2)) {
|
|
22894
23675
|
await noteReviewCyclesExhausted(deps, run2);
|
|
@@ -22911,7 +23692,11 @@ async function tickOnce(deps) {
|
|
|
22911
23692
|
if (!alreadyProcessed) {
|
|
22912
23693
|
const verdictText = verdictLabel(verdictFromComment.verdict);
|
|
22913
23694
|
deps.db.updateRun(run2.id, { review_verdict: verdictFromComment.verdict });
|
|
22914
|
-
deps.db.addEvent(
|
|
23695
|
+
deps.db.addEvent(
|
|
23696
|
+
run2.id,
|
|
23697
|
+
"step",
|
|
23698
|
+
pickedVerdictEventText("done() \u0431\u044B\u043B \u043D\u0435\u0434\u043E\u0441\u0442\u0443\u043F\u0435\u043D \u0440\u0435\u0432\u044C\u044E\u0435\u0440\u0443", verdictFromComment.verdict, verdictFromComment.body, mark)
|
|
23699
|
+
);
|
|
22915
23700
|
narrate(deps, `\u0420\u0435\u0432\u044C\u044E ${droneLabel(run2)} \u2014 \u0432\u0435\u0440\u0434\u0438\u043A\u0442 \u043D\u0430\u0448\u0451\u043B\u0441\u044F \u0432 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0445 PR (${verdictText}), \u0440\u0435\u0441\u043F\u0430\u0432\u043D \u043D\u0435 \u043D\u0443\u0436\u0435\u043D.`);
|
|
22916
23701
|
await postScrapedVerdictReport(deps, run2.id, run2.task_slug, verdictFromComment.verdict, lastAttempt?.name || "(\u0438\u043C\u044F \u043D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u043E)", run2.workspace_id, run2.review_cycle ?? 0);
|
|
22917
23702
|
if (verdictFromComment.verdict === "changes" && !stormActive && !st.conflicting && !deps.db.activeResolverFor(run2.id)) {
|
|
@@ -23204,9 +23989,15 @@ async function tickOnce(deps) {
|
|
|
23204
23989
|
continue;
|
|
23205
23990
|
}
|
|
23206
23991
|
let reason = null;
|
|
23992
|
+
let stalledStopReason = null;
|
|
23207
23993
|
if (!alive) {
|
|
23208
23994
|
const how = outcome === "graceful" ? "\u0434\u0440\u043E\u043D \u0432\u044B\u0448\u0435\u043B \u0441\u0430\u043C (\u0441\u0435\u0441\u0441\u0438\u044F \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u0430 \u0448\u0442\u0430\u0442\u043D\u043E), \u043D\u043E done() \u043D\u0435 \u043F\u043E\u0437\u0432\u0430\u043B, \u0430 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C \u0441\u0435\u0441\u0441\u0438\u044E \u043D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C" : `\u0434\u0440\u043E\u043D \u0443\u043C\u0435\u0440: ${outcome === "crash" ? "\u0443\u0431\u0438\u0442 \u043D\u0430 \u043F\u043E\u043B\u043F\u0443\u0442\u0438 (\u043D\u0435\u0442 result-\u0444\u0430\u0439\u043B\u0430 \u2014 \u043E\u0431\u043E\u0440\u0432\u0430\u043B\u0441\u044F \u0434\u043E \u0437\u0430\u043F\u0438\u0441\u0438 \u0438\u0442\u043E\u0433\u0430: OOM/\u043F\u0430\u043D\u0438\u043A\u0430/kill)" : "pid \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442"}`;
|
|
23209
23995
|
reason = run2.respawns >= RESPAWN_LIMIT ? `${how} \u2014 \u0438\u0441\u0447\u0435\u0440\u043F\u0430\u043D \u043B\u0438\u043C\u0438\u0442 \u0430\u0432\u0442\u043E-\u043E\u0436\u0438\u0432\u043B\u0435\u043D\u0438\u0439 (${RESPAWN_LIMIT})` : how;
|
|
23996
|
+
if (run2.respawns >= RESPAWN_LIMIT && !isSubrun(run2) && needsFixIteration(run2) && run2.pr_url) {
|
|
23997
|
+
reason = `${FIX_DIED_NO_COMMITS_TEXT}; ${reason}`;
|
|
23998
|
+
stalledStopReason = FIX_DIED_NO_COMMITS_TEXT;
|
|
23999
|
+
blockFix(run2, FIX_DIED_NO_COMMITS_TEXT);
|
|
24000
|
+
}
|
|
23210
24001
|
narrate(
|
|
23211
24002
|
deps,
|
|
23212
24003
|
outcome === "graceful" ? `${droneLabel(run2)} \u0437\u0430\u043A\u043E\u043D\u0447\u0438\u043B \u0445\u043E\u0434 \u0441\u0430\u043C, \u043D\u043E \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0438\u0442\u044C \u0435\u0433\u043E \u0441\u0435\u0441\u0441\u0438\u044E \u043D\u0435\u0447\u0435\u043C \u2014 \u0434\u0430\u043B\u044C\u0448\u0435 \u043D\u0443\u0436\u0435\u043D \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440.` : `${droneLabel(run2)} \u043D\u0435 \u043F\u0440\u0438\u0445\u043E\u0434\u0438\u0442 \u0432 \u0441\u0435\u0431\u044F \u2014 \u0441\u0434\u0430\u044E\u0441\u044C, \u0434\u0430\u043B\u044C\u0448\u0435 \u043D\u0443\u0436\u0435\u043D \u043E\u043F\u0435\u0440\u0430\u0442\u043E\u0440.`
|
|
@@ -23216,7 +24007,7 @@ async function tickOnce(deps) {
|
|
|
23216
24007
|
narrate(deps, `${droneLabel(run2)} \u0437\u0430\u0442\u0438\u0445 \u0434\u043E\u043B\u044C\u0448\u0435 ${Math.round(STALL_MS / 6e4)} \u043C\u0438\u043D \u2014 \u043F\u043E\u043C\u0435\u0447\u0430\u044E \u0437\u0430\u0432\u0438\u0441\u0448\u0438\u043C, \u0433\u043B\u044F\u043D\u0443, \u0447\u0442\u043E \u0442\u0430\u043C.`);
|
|
23217
24008
|
}
|
|
23218
24009
|
if (!reason) continue;
|
|
23219
|
-
deps.db.updateRun(run2.id, { status: "stalled" });
|
|
24010
|
+
deps.db.updateRun(run2.id, stalledStopReason ? { status: "stalled", stop_reason: stalledStopReason } : { status: "stalled" });
|
|
23220
24011
|
deps.db.addEvent(run2.id, "stalled", reason);
|
|
23221
24012
|
if (!alive && run2.worktree_path) {
|
|
23222
24013
|
const dirty = deps.isDirty ? await deps.isDirty(run2.worktree_path).catch(() => true) : true;
|
|
@@ -23305,7 +24096,7 @@ async function tickOnce(deps) {
|
|
|
23305
24096
|
autoReviewSnapshot.set(r.repo, await projectWantsChecks(deps, r));
|
|
23306
24097
|
}
|
|
23307
24098
|
}
|
|
23308
|
-
const
|
|
24099
|
+
const detected = [
|
|
23309
24100
|
...buildAnomalyCandidates(deps.db, now, az.thresholds, {
|
|
23310
24101
|
// Машинный ответ, уточнённый проектом (TASWM-396): нет снимка — как раньше.
|
|
23311
24102
|
autoReviewEnabled: (repo) => az.autoReviewEnabled && (autoReviewSnapshot.get(repo) ?? true),
|
|
@@ -23322,6 +24113,10 @@ async function tickOnce(deps) {
|
|
|
23322
24113
|
// труба, тот же дедуп «один раз на эпизод». Пустой список при нормальной работе.
|
|
23323
24114
|
...await buildReliefCostCandidatesFor(deps, now, droneCap)
|
|
23324
24115
|
];
|
|
24116
|
+
const candidates = [
|
|
24117
|
+
...detected.filter((c) => !tickSuppressesAnomaly(c.key)),
|
|
24118
|
+
...tickAnomalyCandidates(autoReviewSnapshot)
|
|
24119
|
+
];
|
|
23325
24120
|
ready = collapseSignals(az.tracker.eligible(now, candidates));
|
|
23326
24121
|
} catch (e) {
|
|
23327
24122
|
console.error("[overmind] \u043D\u0430\u0434\u0437\u043E\u0440: \u0434\u0435\u0442\u0435\u043A\u0442 \u0430\u043D\u043E\u043C\u0430\u043B\u0438\u0439 \u0441\u043E\u0440\u0432\u0430\u043B\u0441\u044F:", e);
|
|
@@ -23493,7 +24288,7 @@ async function resolveConflict(deps, reviewRun) {
|
|
|
23493
24288
|
model: reviewRun.model,
|
|
23494
24289
|
review_model: reviewRun.review_model
|
|
23495
24290
|
});
|
|
23496
|
-
const wt =
|
|
24291
|
+
const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-resolve-${resolver.id}`);
|
|
23497
24292
|
try {
|
|
23498
24293
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
23499
24294
|
await deps.git.setWorktreeIdentity(wt, resolver.name);
|
|
@@ -23574,7 +24369,7 @@ async function spawnReviewer(deps, reviewRun, files) {
|
|
|
23574
24369
|
// (своей у ревьюера нет, TASWM-204), и коммент с вердиктом должен уехать именно туда.
|
|
23575
24370
|
workspace_id: reviewRun.workspace_id
|
|
23576
24371
|
});
|
|
23577
|
-
const wt =
|
|
24372
|
+
const wt = join38(deps.worktreesDir, basename6(repo), `${reviewRun.task_slug}-review-${reviewer.id}`);
|
|
23578
24373
|
try {
|
|
23579
24374
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
23580
24375
|
await deps.git.setWorktreeIdentity(wt, reviewer.name);
|
|
@@ -23655,7 +24450,7 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
23655
24450
|
// штамп цикла: фикс-итерацию проверяет свежий верификатор
|
|
23656
24451
|
workspace_id: verifiedRun.workspace_id
|
|
23657
24452
|
});
|
|
23658
|
-
const wt =
|
|
24453
|
+
const wt = join38(deps.worktreesDir, basename6(repo), `${verifiedRun.task_slug}-verify-${verifier.id}`);
|
|
23659
24454
|
try {
|
|
23660
24455
|
await deps.git.prepareDetachedWorktree(repo, branch, wt);
|
|
23661
24456
|
await deps.git.setWorktreeIdentity(wt, verifier.name);
|
|
@@ -23678,6 +24473,48 @@ async function spawnVerifier(deps, verifiedRun, files) {
|
|
|
23678
24473
|
throw e;
|
|
23679
24474
|
}
|
|
23680
24475
|
}
|
|
24476
|
+
function lastSubmissionSince(db, run2) {
|
|
24477
|
+
const events = db.events(run2.id);
|
|
24478
|
+
for (let i = events.length - 1; i >= 0; i--) {
|
|
24479
|
+
const kind = events[i].kind;
|
|
24480
|
+
if (kind === "pr_opened" || kind === "done") return events[i].at;
|
|
24481
|
+
}
|
|
24482
|
+
return run2.created_at;
|
|
24483
|
+
}
|
|
24484
|
+
async function verdictTextForFixBrief(deps, run2) {
|
|
24485
|
+
const fromFeed = lastChangesSummary(deps.db, run2.id);
|
|
24486
|
+
const feedBlocked = !!fromFeed && (isHeaderOnlyVerdict(fromFeed) || verdictEventIsApprove(fromFeed));
|
|
24487
|
+
if (fromFeed && !feedBlocked) {
|
|
24488
|
+
if (!isClippedPickup(fromFeed)) return fromFeed;
|
|
24489
|
+
return await fullReviewComment(deps, run2) ?? fromFeed;
|
|
24490
|
+
}
|
|
24491
|
+
if (run2.review_verdict !== "changes") {
|
|
24492
|
+
const verify = lastVerifySummary(deps.db, run2.id);
|
|
24493
|
+
if (verify) {
|
|
24494
|
+
const headerOnly = isVerifyHeaderOnly(verify);
|
|
24495
|
+
if (headerOnly || isClippedPickup(verify)) {
|
|
24496
|
+
const fromVerify = await fullVerifyComment(deps, run2);
|
|
24497
|
+
if (fromVerify) return fromVerify;
|
|
24498
|
+
}
|
|
24499
|
+
if (!headerOnly) return verify;
|
|
24500
|
+
}
|
|
24501
|
+
}
|
|
24502
|
+
return fullReviewComment(deps, run2);
|
|
24503
|
+
}
|
|
24504
|
+
async function fullReviewComment(deps, run2) {
|
|
24505
|
+
if (!deps.verdictComment || !run2.pr_url) return null;
|
|
24506
|
+
const found = await deps.verdictComment(run2.pr_url, lastSubmissionSince(deps.db, run2)).catch(() => null);
|
|
24507
|
+
if (!found || found.verdict !== "changes") return null;
|
|
24508
|
+
const body = found.body?.trim();
|
|
24509
|
+
return body || null;
|
|
24510
|
+
}
|
|
24511
|
+
async function fullVerifyComment(deps, run2) {
|
|
24512
|
+
if (!deps.verifyVerdictComment || !run2.pr_url) return null;
|
|
24513
|
+
const found = await deps.verifyVerdictComment(run2.pr_url, lastSubmissionSince(deps.db, run2)).catch(() => null);
|
|
24514
|
+
if (!found || found.verdict === "confirmed") return null;
|
|
24515
|
+
const body = found.body?.trim();
|
|
24516
|
+
return body || null;
|
|
24517
|
+
}
|
|
23681
24518
|
function spawnBaseBranch(reader, repo, run2) {
|
|
23682
24519
|
return reader ? reader(repo, run2.task_slug) : Promise.resolve("");
|
|
23683
24520
|
}
|
|
@@ -23691,6 +24528,7 @@ async function respawnRun(deps, run2, mode, nudge) {
|
|
|
23691
24528
|
if (mode === "continue") {
|
|
23692
24529
|
const prompt2 = nudge ?? (run2.kind === "hero" ? HERO_CONTINUE_NUDGE : CONTINUE_NUDGE);
|
|
23693
24530
|
const pid2 = deps.launch({ worktree: wt, run: run2, prompt: prompt2, continueSession: true });
|
|
24531
|
+
deps.db.addEvent(run2.id, "step", droneLaunchedText(wt, pid2));
|
|
23694
24532
|
deps.db.updateRun(run2.id, { status: "running", pid: pid2, ...worktreePathPatch(run2, wt) });
|
|
23695
24533
|
return;
|
|
23696
24534
|
}
|
|
@@ -23706,7 +24544,7 @@ async function respawnRun(deps, run2, mode, nudge) {
|
|
|
23706
24544
|
]);
|
|
23707
24545
|
const base3 = effectiveBaseBranch(run2.base_branch, projectBase);
|
|
23708
24546
|
const runToSpawn = base3 && run2.base_branch !== base3 ? deps.db.updateRun(run2.id, { base_branch: base3 }) ?? run2 : run2;
|
|
23709
|
-
if (!
|
|
24547
|
+
if (!existsSync23(wt)) {
|
|
23710
24548
|
const branch = runToSpawn.branch || runToSpawn.task_slug;
|
|
23711
24549
|
const source = await addWorktree(repo, wt, branch, {
|
|
23712
24550
|
...base3 ? { base: await remoteBaseRef(repo, base3) } : {},
|
|
@@ -23732,7 +24570,7 @@ async function respawnRun(deps, run2, mode, nudge) {
|
|
|
23732
24570
|
branch: runToSpawn.branch || runToSpawn.task_slug,
|
|
23733
24571
|
base: base3 || "",
|
|
23734
24572
|
worktree: wt,
|
|
23735
|
-
verdict:
|
|
24573
|
+
verdict: await verdictTextForFixBrief(deps, runToSpawn),
|
|
23736
24574
|
name: runToSpawn.name,
|
|
23737
24575
|
taskTitle: task?.title ?? null,
|
|
23738
24576
|
taskUrl: task?.url ?? null,
|
|
@@ -23741,13 +24579,14 @@ async function respawnRun(deps, run2, mode, nudge) {
|
|
|
23741
24579
|
const notice = depsPromptNotice(depsReport);
|
|
23742
24580
|
const prompt = [freshPrompt, notice, nudge].filter(Boolean).join("\n\n");
|
|
23743
24581
|
const pid = deps.launch({ worktree: wt, run: runToSpawn, prompt });
|
|
24582
|
+
deps.db.addEvent(run2.id, "step", droneLaunchedText(wt, pid));
|
|
23744
24583
|
deps.db.updateRun(run2.id, { status: "running", pid, ...worktreePathPatch(run2, wt) });
|
|
23745
24584
|
}
|
|
23746
24585
|
function worktreePathPatch(run2, wt) {
|
|
23747
24586
|
return run2.worktree_path === wt ? {} : { worktree_path: wt };
|
|
23748
24587
|
}
|
|
23749
24588
|
async function syncCrashedOnStartup(deps) {
|
|
23750
|
-
const worktreeExists = deps.worktreeExists ??
|
|
24589
|
+
const worktreeExists = deps.worktreeExists ?? existsSync23;
|
|
23751
24590
|
let orphaned = 0;
|
|
23752
24591
|
let merged = 0;
|
|
23753
24592
|
let requeued = 0;
|
|
@@ -23905,10 +24744,10 @@ async function migrateWorktreesAtStartup() {
|
|
|
23905
24744
|
legacyDir: WORKTREES_LEGACY_DIR,
|
|
23906
24745
|
targetDir: WORKTREES_DIR,
|
|
23907
24746
|
envOverride: process.env.SWARM_WORKTREES || "",
|
|
23908
|
-
exists: (d) =>
|
|
24747
|
+
exists: (d) => existsSync23(d),
|
|
23909
24748
|
isNonEmptyDir: (d) => {
|
|
23910
24749
|
try {
|
|
23911
|
-
return
|
|
24750
|
+
return readdirSync16(d).length > 0;
|
|
23912
24751
|
} catch {
|
|
23913
24752
|
return false;
|
|
23914
24753
|
}
|
|
@@ -23920,7 +24759,7 @@ async function migrateWorktreesAtStartup() {
|
|
|
23920
24759
|
});
|
|
23921
24760
|
} catch (e) {
|
|
23922
24761
|
console.error("[migrate] \u043C\u0438\u0433\u0440\u0430\u0446\u0438\u044F worktrees \u0441\u043E\u0440\u0432\u0430\u043B\u0430\u0441\u044C \u2014 \u0444\u043E\u043B\u0431\u044D\u043A:", e);
|
|
23923
|
-
return
|
|
24762
|
+
return existsSync23(WORKTREES_DIR) ? WORKTREES_DIR : WORKTREES_LEGACY_DIR;
|
|
23924
24763
|
}
|
|
23925
24764
|
}
|
|
23926
24765
|
async function reportWorkspaceAccess(tl, db) {
|
|
@@ -24574,7 +25413,9 @@ async function runDaemon(opts) {
|
|
|
24574
25413
|
// POST /swarm/kill → stopped в проде → overmind гасит живой pid на реконсайле).
|
|
24575
25414
|
// TASWM-349: свой способ остановки — за адаптером; не задан (оба сегодняшних) → общий
|
|
24576
25415
|
// групповой SIGTERM.
|
|
24577
|
-
|
|
25416
|
+
// TASWM-624: и добить автора, пережившего SIGTERM после сдачи PR, тем же путём, и узнать,
|
|
25417
|
+
// свой ли процесс под pid. Сборка вынесена в processStopDeps, чтобы тест видел её целиком.
|
|
25418
|
+
...processStopDeps(EXECUTOR),
|
|
24578
25419
|
// Реклейм worktree паузнутого/возвращаемого дрона (TASWM-228): тот же cwd-скан, что и
|
|
24579
25420
|
// очистка перед сносом worktree, но БЕЗ сноса каталога — worktree остаётся под
|
|
24580
25421
|
// --continue. Гасит тяжёлую работу дрона, ушедшую из его process group (Bash-тул
|
|
@@ -24620,7 +25461,7 @@ async function runDaemon(opts) {
|
|
|
24620
25461
|
isDirty: (p) => worktreeDirty(p),
|
|
24621
25462
|
releaseWorktree: (repo, p) => releaseWorktree(repo || opts.repo, p),
|
|
24622
25463
|
pruneWorktrees: (repo) => pruneWorktrees(repo || opts.repo),
|
|
24623
|
-
worktreeExists:
|
|
25464
|
+
worktreeExists: existsSync23,
|
|
24624
25465
|
liveWorktrees: () => new Set(listDroneProcesses().map((p) => p.worktree)),
|
|
24625
25466
|
narrate: narrator.narrate
|
|
24626
25467
|
});
|
|
@@ -24749,13 +25590,19 @@ async function runDaemon(opts) {
|
|
|
24749
25590
|
const client = tlFor(ws);
|
|
24750
25591
|
return client ? fetchTaskContext(client, task) : Promise.resolve(void 0);
|
|
24751
25592
|
},
|
|
24752
|
-
...tl?.fetchFile ? { fetchFile: tl.fetchFile.bind(tl) } : {}
|
|
25593
|
+
...tl?.fetchFile ? { fetchFile: tl.fetchFile.bind(tl) } : {},
|
|
25594
|
+
// TASWM-618: нет события-вердикта в ленте — бриф берёт полный текст комментария PR.
|
|
25595
|
+
// Тот же ридер, что у подхвата вердикта; не завязан на SWARM_AUTO_REVIEW, потому что
|
|
25596
|
+
// вердикт «нужны правки» ставит и оператор, когда авто-ревью выключено.
|
|
25597
|
+
verdictComment: (prUrl, sinceIso) => latestVerdictComment(prUrl, sinceIso),
|
|
25598
|
+
// Ярлык «НАШЁЛ» в ленте — бриф берёт полный комментарий проверяющего.
|
|
25599
|
+
...verifyVerdictCommentFn ? { verifyVerdictComment: verifyVerdictCommentFn } : {}
|
|
24753
25600
|
},
|
|
24754
25601
|
run2,
|
|
24755
25602
|
mode,
|
|
24756
25603
|
nudge
|
|
24757
25604
|
),
|
|
24758
|
-
worktreeExists: (p) =>
|
|
25605
|
+
worktreeExists: (p) => existsSync23(p),
|
|
24759
25606
|
// TASWM-514: с этого момента считаем попытки спавна — счётчик живёт ровно одну жизнь
|
|
24760
25607
|
// процесса демона и рестарт не переживает (см. preStartAttempts).
|
|
24761
25608
|
startedAt: Date.now(),
|
|
@@ -24967,13 +25814,16 @@ async function runDaemon(opts) {
|
|
|
24967
25814
|
);
|
|
24968
25815
|
},
|
|
24969
25816
|
update: async (onStep) => {
|
|
24970
|
-
const
|
|
25817
|
+
const entry = process.argv[1];
|
|
25818
|
+
const pm = detectGlobalPm(entry);
|
|
24971
25819
|
if (pm !== "sources") {
|
|
24972
25820
|
return runPackageSelfUpdate({
|
|
24973
25821
|
currentVersion: PACKAGE_VERSION,
|
|
24974
|
-
|
|
25822
|
+
// Решение «куда и можно ли» — в gate, том же, что у `swarm update`
|
|
25823
|
+
// (TASWM-622): --prefix, npx, нет прав. Поле обязательное: без него tsc красный.
|
|
25824
|
+
gate: (spec) => gatePackageInstall(pm, spec, entry),
|
|
24975
25825
|
latest: () => fetchLatestVersion(),
|
|
24976
|
-
exec:
|
|
25826
|
+
exec: execCaptured,
|
|
24977
25827
|
onStep
|
|
24978
25828
|
});
|
|
24979
25829
|
}
|
|
@@ -25238,6 +26088,8 @@ export {
|
|
|
25238
26088
|
ABORTED_CONTINUE_NUDGE,
|
|
25239
26089
|
ABORTED_STOP_REASON,
|
|
25240
26090
|
ABORT_TEXT,
|
|
26091
|
+
AUTHOR_LINGER_AFTER_PR_MS,
|
|
26092
|
+
AUTHOR_LINGER_MARK,
|
|
25241
26093
|
AWAITING_CI_REASON,
|
|
25242
26094
|
BUDGET_STOP_REASON,
|
|
25243
26095
|
CHANGES_FIX_COST_MARK,
|
|
@@ -25271,6 +26123,7 @@ export {
|
|
|
25271
26123
|
EXIT_WORK_LOST,
|
|
25272
26124
|
EXIT_WORK_PUSHED,
|
|
25273
26125
|
EXIT_WORK_UNKNOWN,
|
|
26126
|
+
FIX_DIED_NO_COMMITS_TEXT,
|
|
25274
26127
|
GATE_LOG_HEARTBEAT_TICKS,
|
|
25275
26128
|
HEADLESS_BLOCK,
|
|
25276
26129
|
HERO_CONTINUE_NUDGE,
|
|
@@ -25296,12 +26149,14 @@ export {
|
|
|
25296
26149
|
STALL_FLOOR_MS,
|
|
25297
26150
|
STALL_MS,
|
|
25298
26151
|
STORM_DEAD_LIMIT,
|
|
26152
|
+
SUBMISSION_REVIEW_STEP,
|
|
25299
26153
|
SUBMITTED_EXIT_TEXT,
|
|
25300
26154
|
SUBRUN_EXITED_TEXT,
|
|
25301
26155
|
VERIFY_ESCALATION_MARK,
|
|
25302
26156
|
VERIFY_SPAWN_LIMIT,
|
|
25303
26157
|
WATCHDOG_PARK_REASON,
|
|
25304
26158
|
abortReason,
|
|
26159
|
+
authorLingerAfterPrMs,
|
|
25305
26160
|
budgetAnswer,
|
|
25306
26161
|
buildChangesFixPrompt,
|
|
25307
26162
|
buildCiReadyNudge,
|
|
@@ -25317,6 +26172,7 @@ export {
|
|
|
25317
26172
|
cancelRun,
|
|
25318
26173
|
capacityProvenance,
|
|
25319
26174
|
ciWaitOverHead,
|
|
26175
|
+
clipChars,
|
|
25320
26176
|
configureReviewCycleLimit,
|
|
25321
26177
|
cycleCapHolder,
|
|
25322
26178
|
effectiveReviewCycleLimit,
|
|
@@ -25328,6 +26184,7 @@ export {
|
|
|
25328
26184
|
listDroneProcesses,
|
|
25329
26185
|
livePpids,
|
|
25330
26186
|
makeCheckerAttachmentsReader,
|
|
26187
|
+
processStopDeps,
|
|
25331
26188
|
replayDecision,
|
|
25332
26189
|
repoHasCiWorkflows,
|
|
25333
26190
|
resolveConflict,
|