@plune-ai/cli 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/cli.cjs +695 -147
- package/dist/index.cjs +118 -40
- package/dist/index.d.cts +26 -3
- package/dist/index.d.ts +26 -3
- package/dist/index.js +118 -40
- package/dist/mcp-tools.cjs +50 -12
- package/dist/mcp-tools.d.cts +9 -0
- package/dist/mcp-tools.d.ts +9 -0
- package/dist/mcp-tools.js +50 -12
- package/package.json +2 -1
- package/skills/qa-mission/SKILL.md +160 -0
- package/skills/qa-mission/references/tool-calls.md +117 -0
package/dist/cli.cjs
CHANGED
|
@@ -291,13 +291,13 @@ function reportOutputs(flags2, cwd = process.cwd()) {
|
|
|
291
291
|
const files = outs.map((raw) => {
|
|
292
292
|
const named = /^([a-z][a-z0-9-]*)=(.*)$/s.exec(raw);
|
|
293
293
|
const fileFormat = named === null ? reporter ?? "json" : oneOf("--out", named[1] ?? "", FILE_FORMATS);
|
|
294
|
-
const
|
|
295
|
-
if (
|
|
296
|
-
return { format: fileFormat, path:
|
|
294
|
+
const path24 = named === null ? raw : named[2] ?? "";
|
|
295
|
+
if (path24 === "") throw new UsageError(`--out ${raw}: the file name is missing.`);
|
|
296
|
+
return { format: fileFormat, path: path24, raw };
|
|
297
297
|
});
|
|
298
298
|
const seen = /* @__PURE__ */ new Map();
|
|
299
|
-
for (const { path:
|
|
300
|
-
const full = (0, import_node_path2.resolve)(cwd,
|
|
299
|
+
for (const { path: path24, raw } of files) {
|
|
300
|
+
const full = (0, import_node_path2.resolve)(cwd, path24);
|
|
301
301
|
const key = process.platform === "win32" ? full.toLowerCase() : full;
|
|
302
302
|
const first = seen.get(key);
|
|
303
303
|
if (first !== void 0) throw new UsageError(`--out ${raw}: the same file as --out ${first}.`);
|
|
@@ -305,9 +305,9 @@ function reportOutputs(flags2, cwd = process.cwd()) {
|
|
|
305
305
|
if ((0, import_node_fs.statSync)(full, { throwIfNoEntry: false })?.isDirectory() === true)
|
|
306
306
|
throw new UsageError(`--out ${raw}: a folder, not a file.`);
|
|
307
307
|
if ((0, import_node_fs.statSync)((0, import_node_path2.dirname)(full), { throwIfNoEntry: false })?.isDirectory() !== true)
|
|
308
|
-
throw new UsageError(`--out ${raw}: the folder ${(0, import_node_path2.dirname)(
|
|
308
|
+
throw new UsageError(`--out ${raw}: the folder ${(0, import_node_path2.dirname)(path24)} does not exist.`);
|
|
309
309
|
}
|
|
310
|
-
return { format, files: files.map(({ format: f, path:
|
|
310
|
+
return { format, files: files.map(({ format: f, path: path24 }) => ({ format: f, path: path24 })) };
|
|
311
311
|
}
|
|
312
312
|
var import_node_fs, import_node_path2, STDOUT_FORMATS, FILE_FORMATS, REPORTERS, collect2;
|
|
313
313
|
var init_options2 = __esm({
|
|
@@ -564,7 +564,9 @@ var init_schema = __esm({
|
|
|
564
564
|
max_tokens: import_zod.z.number().int().positive().optional(),
|
|
565
565
|
concurrency: import_zod.z.number().int().positive().optional(),
|
|
566
566
|
timeout: import_zod.z.number().int().positive().optional(),
|
|
567
|
-
max_retries: import_zod.z.number().int().min(0).optional()
|
|
567
|
+
max_retries: import_zod.z.number().int().min(0).optional(),
|
|
568
|
+
// The values the OpenAI SDK's Chat Completions `reasoning_effort` accepts; only `openai` sends it.
|
|
569
|
+
reasoning_effort: import_zod.z.enum(["none", "minimal", "low", "medium", "high", "xhigh"]).optional()
|
|
568
570
|
});
|
|
569
571
|
modelPriceSchema = import_zod.z.object({
|
|
570
572
|
input_per_1k_usd: import_zod.z.number().nonnegative(),
|
|
@@ -641,7 +643,7 @@ var init_schema = __esm({
|
|
|
641
643
|
import_zod.z.object({
|
|
642
644
|
type: import_zod.z.literal("tool-args"),
|
|
643
645
|
tool: toolName,
|
|
644
|
-
args: import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()),
|
|
646
|
+
args: import_zod.z.union([import_zod.z.record(import_zod.z.string(), import_zod.z.unknown()), import_zod.z.array(import_zod.z.record(import_zod.z.string(), import_zod.z.unknown())).min(1)]),
|
|
645
647
|
match: import_zod.z.enum(["partial", "exact", "ignore"]).optional(),
|
|
646
648
|
min_count: count.optional()
|
|
647
649
|
}),
|
|
@@ -766,11 +768,11 @@ var init_schema = __esm({
|
|
|
766
768
|
config.evals.forEach((evalConfig, i) => {
|
|
767
769
|
const server2 = evalConfig.mcp?.server;
|
|
768
770
|
if (server2 === void 0) {
|
|
769
|
-
const misplaced = (assertions,
|
|
771
|
+
const misplaced = (assertions, path24) => assertions.forEach((a, j) => {
|
|
770
772
|
if (TOOL_CALL_TYPES.has(a.type))
|
|
771
773
|
ctx.addIssue({
|
|
772
774
|
code: "custom",
|
|
773
|
-
path: [...
|
|
775
|
+
path: [...path24, j, "type"],
|
|
774
776
|
message: `"${a.type}" reads the tool calls of an eval with mcp, and eval "${evalConfig.id}" has no mcp block`
|
|
775
777
|
});
|
|
776
778
|
});
|
|
@@ -991,7 +993,7 @@ var init_retry = __esm({
|
|
|
991
993
|
"use strict";
|
|
992
994
|
init_cjs_shims();
|
|
993
995
|
init_errors2();
|
|
994
|
-
defaultSleep = (ms) => new Promise((
|
|
996
|
+
defaultSleep = (ms) => new Promise((resolve20) => setTimeout(resolve20, ms));
|
|
995
997
|
}
|
|
996
998
|
});
|
|
997
999
|
|
|
@@ -1069,6 +1071,26 @@ var init_cost = __esm({
|
|
|
1069
1071
|
});
|
|
1070
1072
|
|
|
1071
1073
|
// src/providers/anthropic.ts
|
|
1074
|
+
function temperatureFor(model, temperature) {
|
|
1075
|
+
if (temperature === void 0) return {};
|
|
1076
|
+
if (TAKES_TEMPERATURE.some((prefix) => model.startsWith(prefix))) return { temperature };
|
|
1077
|
+
if (!warnedNoTemperature.has(model)) {
|
|
1078
|
+
warnedNoTemperature.add(model);
|
|
1079
|
+
process.stderr.write(
|
|
1080
|
+
`warning: ${model} does not take a temperature; the configured temperature ${temperature} is not sent
|
|
1081
|
+
`
|
|
1082
|
+
);
|
|
1083
|
+
}
|
|
1084
|
+
return {};
|
|
1085
|
+
}
|
|
1086
|
+
function warnReasoningEffortNotSent(model, effort) {
|
|
1087
|
+
if (effort === void 0 || warnedNoReasoningEffort.has(model)) return;
|
|
1088
|
+
warnedNoReasoningEffort.add(model);
|
|
1089
|
+
process.stderr.write(
|
|
1090
|
+
`warning: ${model} does not take reasoning_effort; the configured value ${effort} is not sent
|
|
1091
|
+
`
|
|
1092
|
+
);
|
|
1093
|
+
}
|
|
1072
1094
|
function toAnthropicMessages(messages) {
|
|
1073
1095
|
return messages.map((m) => {
|
|
1074
1096
|
if (m.role === "user") return { role: "user", content: m.content };
|
|
@@ -1110,6 +1132,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1110
1132
|
...config.timeout !== void 0 ? { timeout: config.timeout } : {}
|
|
1111
1133
|
});
|
|
1112
1134
|
const maxRetries = config.max_retries ?? DEFAULT_MAX_RETRIES;
|
|
1135
|
+
warnReasoningEffortNotSent(config.model, config.reasoning_effort);
|
|
1113
1136
|
return {
|
|
1114
1137
|
async complete(req) {
|
|
1115
1138
|
try {
|
|
@@ -1117,7 +1140,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1117
1140
|
() => client.messages.create({
|
|
1118
1141
|
model: req.model,
|
|
1119
1142
|
max_tokens: req.max_tokens,
|
|
1120
|
-
...req.
|
|
1143
|
+
...temperatureFor(req.model, req.temperature),
|
|
1121
1144
|
messages: [{ role: "user", content: req.prompt_resolved }]
|
|
1122
1145
|
}),
|
|
1123
1146
|
{ max_retries: maxRetries }
|
|
@@ -1141,7 +1164,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1141
1164
|
() => client.messages.create({
|
|
1142
1165
|
model: req.model,
|
|
1143
1166
|
max_tokens: req.max_tokens,
|
|
1144
|
-
...req.
|
|
1167
|
+
...temperatureFor(req.model, req.temperature),
|
|
1145
1168
|
messages: toAnthropicMessages(req.messages),
|
|
1146
1169
|
tools: req.tools.map((t) => ({
|
|
1147
1170
|
name: t.name,
|
|
@@ -1169,7 +1192,7 @@ function makeAnthropicProvider(config, env, pricing) {
|
|
|
1169
1192
|
}
|
|
1170
1193
|
};
|
|
1171
1194
|
}
|
|
1172
|
-
var import_sdk, ENV_VAR, DEFAULT_MAX_RETRIES, STOP, isObject;
|
|
1195
|
+
var import_sdk, ENV_VAR, DEFAULT_MAX_RETRIES, STOP, TAKES_TEMPERATURE, warnedNoTemperature, warnedNoReasoningEffort, isObject;
|
|
1173
1196
|
var init_anthropic = __esm({
|
|
1174
1197
|
"src/providers/anthropic.ts"() {
|
|
1175
1198
|
"use strict";
|
|
@@ -1185,6 +1208,21 @@ var init_anthropic = __esm({
|
|
|
1185
1208
|
end_turn: "stop",
|
|
1186
1209
|
max_tokens: "length"
|
|
1187
1210
|
};
|
|
1211
|
+
TAKES_TEMPERATURE = [
|
|
1212
|
+
"claude-opus-4-6",
|
|
1213
|
+
"claude-sonnet-4-6",
|
|
1214
|
+
"claude-opus-4-5",
|
|
1215
|
+
"claude-sonnet-4-5",
|
|
1216
|
+
"claude-haiku-4-5",
|
|
1217
|
+
"claude-opus-4-1",
|
|
1218
|
+
"claude-opus-4-0",
|
|
1219
|
+
"claude-sonnet-4-0",
|
|
1220
|
+
"claude-opus-4-2025",
|
|
1221
|
+
"claude-sonnet-4-2025",
|
|
1222
|
+
"claude-3"
|
|
1223
|
+
];
|
|
1224
|
+
warnedNoTemperature = /* @__PURE__ */ new Set();
|
|
1225
|
+
warnedNoReasoningEffort = /* @__PURE__ */ new Set();
|
|
1188
1226
|
isObject = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1189
1227
|
}
|
|
1190
1228
|
});
|
|
@@ -1222,7 +1260,8 @@ function parseToolArguments(id2, name, raw) {
|
|
|
1222
1260
|
return { id: id2, name, args: raw, args_invalid: true };
|
|
1223
1261
|
}
|
|
1224
1262
|
function makeOpenAiCompatibleProvider(opts) {
|
|
1225
|
-
const { config, env, pricing, apiKeyEnv, baseURL, reportsCost } = opts;
|
|
1263
|
+
const { config, env, pricing, apiKeyEnv, baseURL, reportsCost, maxCompletionTokens, sendsReasoningEffort } = opts;
|
|
1264
|
+
const reasoning = sendsReasoningEffort && config.reasoning_effort !== void 0 ? { reasoning_effort: config.reasoning_effort } : {};
|
|
1226
1265
|
const apiKey = env[apiKeyEnv];
|
|
1227
1266
|
if (apiKey === void 0 || apiKey.trim() === "") {
|
|
1228
1267
|
throw new AuthError(
|
|
@@ -1245,7 +1284,8 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1245
1284
|
() => client.chat.completions.create({
|
|
1246
1285
|
model: req.model,
|
|
1247
1286
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
1248
|
-
max_tokens: req.max_tokens,
|
|
1287
|
+
...maxCompletionTokens ? { max_completion_tokens: req.max_tokens } : { max_tokens: req.max_tokens },
|
|
1288
|
+
...reasoning,
|
|
1249
1289
|
messages: [{ role: "user", content: req.prompt_resolved }],
|
|
1250
1290
|
// OpenRouter extension: ask it to include the call's actual cost in `usage` (ADR-PRC02).
|
|
1251
1291
|
...reportsCost ? { usage: { include: true } } : {}
|
|
@@ -1274,7 +1314,8 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1274
1314
|
() => client.chat.completions.create({
|
|
1275
1315
|
model: req.model,
|
|
1276
1316
|
...req.temperature !== void 0 ? { temperature: req.temperature } : {},
|
|
1277
|
-
max_tokens: req.max_tokens,
|
|
1317
|
+
...maxCompletionTokens ? { max_completion_tokens: req.max_tokens } : { max_tokens: req.max_tokens },
|
|
1318
|
+
...reasoning,
|
|
1278
1319
|
messages: toOpenAiMessages(req.messages),
|
|
1279
1320
|
tools: req.tools.map((t) => ({
|
|
1280
1321
|
type: "function",
|
|
@@ -1313,7 +1354,14 @@ function makeOpenAiCompatibleProvider(opts) {
|
|
|
1313
1354
|
};
|
|
1314
1355
|
}
|
|
1315
1356
|
function makeOpenAiProvider(config, env, pricing) {
|
|
1316
|
-
return makeOpenAiCompatibleProvider({
|
|
1357
|
+
return makeOpenAiCompatibleProvider({
|
|
1358
|
+
config,
|
|
1359
|
+
env,
|
|
1360
|
+
pricing,
|
|
1361
|
+
apiKeyEnv: "OPENAI_API_KEY",
|
|
1362
|
+
maxCompletionTokens: true,
|
|
1363
|
+
sendsReasoningEffort: true
|
|
1364
|
+
});
|
|
1317
1365
|
}
|
|
1318
1366
|
var import_openai, DEFAULT_MAX_RETRIES2;
|
|
1319
1367
|
var init_openai = __esm({
|
|
@@ -2265,8 +2313,9 @@ function checkNames(type, t, names) {
|
|
|
2265
2313
|
`${type}: no tool "${unknown}" was offered to the model; offered: ${list2}.${AFTER}`
|
|
2266
2314
|
);
|
|
2267
2315
|
}
|
|
2268
|
-
function absence(type, t, what) {
|
|
2269
|
-
if (t.collection === "complete"
|
|
2316
|
+
function absence(type, t, what, reads) {
|
|
2317
|
+
if (t.collection === "complete" || reads === "calls" && t.stop.reason === "complete")
|
|
2318
|
+
return pass;
|
|
2270
2319
|
const why = t.stop.reason === "limit" ? `the loop was stopped by ${t.stop.limit ?? "a limit"}` : "the transcript is partial (a stored excerpt was cut)";
|
|
2271
2320
|
throw unmeasured(
|
|
2272
2321
|
type,
|
|
@@ -2348,7 +2397,7 @@ var init_calls = __esm({
|
|
|
2348
2397
|
const t = transcriptOf("tool-not-called", ctx);
|
|
2349
2398
|
checkNames("tool-not-called", t, [tool2]);
|
|
2350
2399
|
const calls = callsFor(t, tool2);
|
|
2351
|
-
if (calls.length === 0) return absence("tool-not-called", t, `a call to "${tool2}"
|
|
2400
|
+
if (calls.length === 0) return absence("tool-not-called", t, `a call to "${tool2}"`, "calls");
|
|
2352
2401
|
return fail(
|
|
2353
2402
|
`expected "${tool2}" never called; got ${plural(calls.length, "call")}: ${describeCalls(calls)}; check what in the prompt or the tool list led the model to it`
|
|
2354
2403
|
);
|
|
@@ -2358,13 +2407,15 @@ var init_calls = __esm({
|
|
|
2358
2407
|
const { tool: tool2, match = "partial", min_count: min = 1 } = ctx.params;
|
|
2359
2408
|
const t = transcriptOf("tool-args", ctx);
|
|
2360
2409
|
checkNames("tool-args", t, [tool2]);
|
|
2361
|
-
const
|
|
2362
|
-
|
|
2410
|
+
const sets = (Array.isArray(ctx.params.args) ? ctx.params.args : [ctx.params.args]).map(
|
|
2411
|
+
(a) => interpolateDeep(a, ctx)
|
|
2412
|
+
);
|
|
2413
|
+
const matches = (actual) => match === "ignore" || sets.some((args) => match === "exact" ? sameJson(args, actual) : partialMatch(args, actual));
|
|
2363
2414
|
const calls = callsFor(t, tool2);
|
|
2364
2415
|
const hits = calls.filter((c) => matches(c.call.args)).length;
|
|
2365
2416
|
if (hits >= min) return pass;
|
|
2366
2417
|
return fail(
|
|
2367
|
-
`expected a call to "${tool2}" with arguments ${describeArgs(
|
|
2418
|
+
`expected a call to "${tool2}" with arguments ${sets.map(describeArgs).join(" or ")} (${match}) at least ${plural(min, "time")}; got ${hits} of ${plural(calls.length, "call")}: ${describeCalls(calls)}; check the argument names and values against the tool's input schema`
|
|
2368
2419
|
);
|
|
2369
2420
|
});
|
|
2370
2421
|
onlyTools = check((ctx) => {
|
|
@@ -2372,7 +2423,7 @@ var init_calls = __esm({
|
|
|
2372
2423
|
const t = transcriptOf("only-tools", ctx);
|
|
2373
2424
|
checkNames("only-tools", t, tools2);
|
|
2374
2425
|
const off = callsOf(t).filter((c) => !tools2.includes(c.call.name));
|
|
2375
|
-
if (off.length === 0) return absence("only-tools", t, "a call to another tool");
|
|
2426
|
+
if (off.length === 0) return absence("only-tools", t, "a call to another tool", "calls");
|
|
2376
2427
|
const allowed = tools2.length > 0 ? `only ${tools2.join(", ")} called` : "no tool call";
|
|
2377
2428
|
return fail(
|
|
2378
2429
|
`expected ${allowed}; got ${describeCalls(off)}; check whether allowed_tools should leave the others out`
|
|
@@ -2463,7 +2514,7 @@ var init_errors3 = __esm({
|
|
|
2463
2514
|
const t = transcriptOf("no-tool-errors", ctx);
|
|
2464
2515
|
checkNames("no-tool-errors", t, [tool2]);
|
|
2465
2516
|
const errors = callsFor(t, tool2).filter((c) => c.call.is_error);
|
|
2466
|
-
if (errors.length === 0) return absence("no-tool-errors", t, "a call with an error");
|
|
2517
|
+
if (errors.length === 0) return absence("no-tool-errors", t, "a call with an error", "calls");
|
|
2467
2518
|
return fail(
|
|
2468
2519
|
`expected no tool call with an error; got ${describeCalls(errors, (c) => `${describeCall(c)} (${c.call.error_kind ?? "error"})`)}; check the arguments the model sent against the tool's input schema`
|
|
2469
2520
|
);
|
|
@@ -2479,7 +2530,8 @@ var init_errors3 = __esm({
|
|
|
2479
2530
|
const why = riskOf(c.call.name, listed2.get(c.call.name));
|
|
2480
2531
|
if (why !== void 0) risky.push({ c, why });
|
|
2481
2532
|
}
|
|
2482
|
-
if (risky.length === 0)
|
|
2533
|
+
if (risky.length === 0)
|
|
2534
|
+
return absence("no-destructive-tool", t, "a call to a destructive tool", "calls");
|
|
2483
2535
|
return fail(
|
|
2484
2536
|
`expected no call to a tool that may be destructive; got ${failedOn(risky)}; the hints are the server's own claim, so check them on the server`
|
|
2485
2537
|
);
|
|
@@ -2970,30 +3022,49 @@ async function runAgentRow(p) {
|
|
|
2970
3022
|
if (err instanceof LimitStop) throw err;
|
|
2971
3023
|
throw new AgentError("MCP_CONNECT", err.message);
|
|
2972
3024
|
}
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
offered
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
3025
|
+
const open2 = session;
|
|
3026
|
+
let names = wireNames([]);
|
|
3027
|
+
let tools2 = [];
|
|
3028
|
+
let offeredNames = [];
|
|
3029
|
+
const list2 = async () => {
|
|
3030
|
+
let listed2;
|
|
3031
|
+
try {
|
|
3032
|
+
listed2 = listedTools(await bounded2(open2.listTools(limits.tool_timeout_ms)));
|
|
3033
|
+
} catch (err) {
|
|
3034
|
+
if (err instanceof LimitStop) throw err;
|
|
3035
|
+
throw new AgentError("MCP_LIST_TOOLS", `tools/list failed: ${err.message}`);
|
|
3036
|
+
}
|
|
3037
|
+
const offered = listed2.filter(
|
|
3038
|
+
(t) => p.allowedTools === void 0 || p.allowedTools.includes(t.name)
|
|
3039
|
+
);
|
|
3040
|
+
for (const t of listed2) {
|
|
3041
|
+
const isOffered = offered.includes(t);
|
|
3042
|
+
const known = transcript.tools.find((k) => k.name === t.name);
|
|
3043
|
+
if (known !== void 0) known.offered ||= isOffered;
|
|
3044
|
+
else
|
|
3045
|
+
transcript.tools.push({
|
|
3046
|
+
name: t.name,
|
|
3047
|
+
offered: isOffered,
|
|
3048
|
+
...isRecord2(t.annotations) ? { annotations: t.annotations } : {}
|
|
3049
|
+
});
|
|
3050
|
+
}
|
|
3051
|
+
const now = offered.map((t) => t.name);
|
|
3052
|
+
const added2 = now.filter((n) => !offeredNames.includes(n));
|
|
3053
|
+
const removed = offeredNames.filter((n) => !now.includes(n));
|
|
3054
|
+
offeredNames = now;
|
|
3055
|
+
names = wireNames(now);
|
|
3056
|
+
tools2 = offered.map((t) => ({
|
|
3057
|
+
name: names.toWire.get(t.name),
|
|
3058
|
+
...typeof t.description === "string" ? { description: t.description } : {},
|
|
3059
|
+
input_schema: isRecord2(t.inputSchema) ? t.inputSchema : { type: "object" }
|
|
3060
|
+
}));
|
|
3061
|
+
return added2.length + removed.length > 0 ? { added: added2, removed } : void 0;
|
|
3062
|
+
};
|
|
3063
|
+
await list2();
|
|
2994
3064
|
const messages = [{ role: "user", content: prompt5 }];
|
|
2995
3065
|
let calls = 0;
|
|
2996
3066
|
let tokens = 0;
|
|
3067
|
+
let changed;
|
|
2997
3068
|
for (let index = 1; ; index++) {
|
|
2998
3069
|
const res = await bounded2(
|
|
2999
3070
|
respond({
|
|
@@ -3024,8 +3095,10 @@ async function runAgentRow(p) {
|
|
|
3024
3095
|
text: kept.cut(res.text).text,
|
|
3025
3096
|
...res.finish_reason !== void 0 ? { finish_reason: res.finish_reason } : {},
|
|
3026
3097
|
usage: usage4,
|
|
3027
|
-
calls: records2
|
|
3098
|
+
calls: records2,
|
|
3099
|
+
...changed !== void 0 ? { offered_changed: changed } : {}
|
|
3028
3100
|
};
|
|
3101
|
+
changed = void 0;
|
|
3029
3102
|
transcript.steps.push(step);
|
|
3030
3103
|
if (res.finish_reason === "error")
|
|
3031
3104
|
throw new AgentError(
|
|
@@ -3042,6 +3115,7 @@ async function runAgentRow(p) {
|
|
|
3042
3115
|
if (tokens > limits.max_total_tokens) throw new LimitStop("max_total_tokens");
|
|
3043
3116
|
const results2 = [];
|
|
3044
3117
|
const answer = (rec, c, content) => results2.push({ id: c.id, content, is_error: rec.is_error });
|
|
3118
|
+
let succeeded = false;
|
|
3045
3119
|
for (const [i, c] of res.tool_calls.entries()) {
|
|
3046
3120
|
const rec = records2[i];
|
|
3047
3121
|
if (calls >= limits.max_tool_calls) throw new LimitStop("max_tool_calls");
|
|
@@ -3070,6 +3144,7 @@ async function runAgentRow(p) {
|
|
|
3070
3144
|
if (got.kind === "error") Object.assign(rec, { is_error: true, error_kind: "protocol" });
|
|
3071
3145
|
else if (isRecord2(got.result) && got.result.isError === true)
|
|
3072
3146
|
Object.assign(rec, { is_error: true, error_kind: "content" });
|
|
3147
|
+
succeeded ||= !rec.is_error;
|
|
3073
3148
|
rec.result = kept.cut(text4);
|
|
3074
3149
|
answer(rec, c, text4);
|
|
3075
3150
|
}
|
|
@@ -3077,6 +3152,7 @@ async function runAgentRow(p) {
|
|
|
3077
3152
|
{ role: "assistant", text: res.text, tool_calls: res.tool_calls },
|
|
3078
3153
|
{ role: "tool", results: results2 }
|
|
3079
3154
|
);
|
|
3155
|
+
if (succeeded) changed = await list2();
|
|
3080
3156
|
}
|
|
3081
3157
|
} catch (err) {
|
|
3082
3158
|
if (err instanceof LimitStop) transcript.stop = { reason: "limit", limit: err.limit };
|
|
@@ -3725,12 +3801,12 @@ function machineless(raw, repoRoot, home) {
|
|
|
3725
3801
|
if (repoRoot === void 0) text4 = text4.replace(ANY_HOME, "~");
|
|
3726
3802
|
return text4;
|
|
3727
3803
|
}
|
|
3728
|
-
function pathIn(
|
|
3729
|
-
const parts =
|
|
3804
|
+
function pathIn(path24) {
|
|
3805
|
+
const parts = path24.split(/[\\/]+/);
|
|
3730
3806
|
while (parts.length > 1 && parts.at(-1) === "") parts.pop();
|
|
3731
3807
|
if (!parts.some((part) => part !== "" && !/^[A-Za-z]:$/.test(part))) return void 0;
|
|
3732
3808
|
const joined = parts.map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("[\\\\/]+");
|
|
3733
|
-
const escaped = /^\/(?!\/)/.test(
|
|
3809
|
+
const escaped = /^\/(?!\/)/.test(path24) ? joined.replace("[\\\\/]+", "\\\\*\\/") : joined;
|
|
3734
3810
|
const url = "(?:(?:file|webpack|webpack-internal):(?:\\\\*\\/){2,3})?";
|
|
3735
3811
|
return new RegExp(`${url}${escaped}`, /^[A-Za-z]:$/.test(parts[0]) ? "gi" : "g");
|
|
3736
3812
|
}
|
|
@@ -3776,12 +3852,12 @@ function placeOf(error, testFile) {
|
|
|
3776
3852
|
}
|
|
3777
3853
|
function fileOf(raw) {
|
|
3778
3854
|
if (!raw.startsWith("file://")) return raw;
|
|
3779
|
-
let
|
|
3855
|
+
let path24 = raw.slice("file://".length);
|
|
3780
3856
|
try {
|
|
3781
|
-
|
|
3857
|
+
path24 = decodeURIComponent(path24);
|
|
3782
3858
|
} catch {
|
|
3783
3859
|
}
|
|
3784
|
-
return /^\/[A-Za-z]:\//.test(
|
|
3860
|
+
return /^\/[A-Za-z]:\//.test(path24) ? path24.slice(1) : path24;
|
|
3785
3861
|
}
|
|
3786
3862
|
function fromRoot(place, root) {
|
|
3787
3863
|
if (place === void 0 || root === void 0 || !Number.isInteger(place.line) || place.line < 1) return void 0;
|
|
@@ -3821,14 +3897,14 @@ var init_failure_detail = __esm({
|
|
|
3821
3897
|
FRAME = /^\s+at (?:.*? \()?(.+?):(\d+):(\d+)\)?$/;
|
|
3822
3898
|
FRAME_MAX = 8192;
|
|
3823
3899
|
firstLine = (text4) => (0, import_node_util.stripVTControlCharacters)(text4).split("\n").map((line) => line.trim()).find((line) => line !== "");
|
|
3824
|
-
normal = (
|
|
3900
|
+
normal = (path24) => import_node_path3.posix.normalize(path24.replace(/\\/g, "/")).replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`);
|
|
3825
3901
|
}
|
|
3826
3902
|
});
|
|
3827
3903
|
|
|
3828
3904
|
// src/mcp-testing/connect/journal.ts
|
|
3829
|
-
function openJournal(
|
|
3830
|
-
if (
|
|
3831
|
-
const fd = (0, import_node_fs3.openSync)(
|
|
3905
|
+
function openJournal(path24, redact2) {
|
|
3906
|
+
if (path24 === void 0) return NONE;
|
|
3907
|
+
const fd = (0, import_node_fs3.openSync)(path24, "w", 384);
|
|
3832
3908
|
if (process.platform !== "win32") (0, import_node_fs3.fchmodSync)(fd, 384);
|
|
3833
3909
|
const start = import_node_perf_hooks.performance.now();
|
|
3834
3910
|
let closed = false;
|
|
@@ -4291,7 +4367,7 @@ async function openSession(config) {
|
|
|
4291
4367
|
tail.push(clean2(line));
|
|
4292
4368
|
if (tail.length > TAIL_LINES) tail.shift();
|
|
4293
4369
|
});
|
|
4294
|
-
stderrDone = new Promise((
|
|
4370
|
+
stderrDone = new Promise((resolve20) => lines.once("close", resolve20));
|
|
4295
4371
|
watchStdout(transport, journal, seen);
|
|
4296
4372
|
watchOverflow(transport, () => {
|
|
4297
4373
|
if (tooLarge) return;
|
|
@@ -4401,7 +4477,7 @@ async function openSession(config) {
|
|
|
4401
4477
|
const stdin = transport._process?.stdin;
|
|
4402
4478
|
if (stdin === null || stdin === void 0 || stdin.writableEnded)
|
|
4403
4479
|
throw new ConnectError("exited-early", `${LEAD["exited-early"][0]}.`, [...tail]);
|
|
4404
|
-
return new Promise((
|
|
4480
|
+
return new Promise((resolve20, reject) => {
|
|
4405
4481
|
const timer2 = setTimeout(() => {
|
|
4406
4482
|
listeners.delete(listener);
|
|
4407
4483
|
reject(noAnswer());
|
|
@@ -4411,7 +4487,7 @@ async function openSession(config) {
|
|
|
4411
4487
|
if (!answers(frame2, id2)) return;
|
|
4412
4488
|
clearTimeout(timer2);
|
|
4413
4489
|
listeners.delete(listener);
|
|
4414
|
-
|
|
4490
|
+
resolve20({ frame: frame2, text: clean2(line).slice(0, RAW_TEXT) });
|
|
4415
4491
|
};
|
|
4416
4492
|
listeners.add(listener);
|
|
4417
4493
|
stdin.write(`${body}
|
|
@@ -4467,10 +4543,10 @@ async function openSession(config) {
|
|
|
4467
4543
|
const proc = transport._process;
|
|
4468
4544
|
if (proc === void 0) return true;
|
|
4469
4545
|
if (proc.exitCode !== null || proc.signalCode !== null) return true;
|
|
4470
|
-
const exited = new Promise((
|
|
4546
|
+
const exited = new Promise((resolve20) => proc.once("exit", () => resolve20(true)));
|
|
4471
4547
|
proc.stdin?.end();
|
|
4472
4548
|
let timer2;
|
|
4473
|
-
const late = new Promise((
|
|
4549
|
+
const late = new Promise((resolve20) => timer2 = setTimeout(() => resolve20(false), waitMs));
|
|
4474
4550
|
const result2 = await Promise.race([exited, late]);
|
|
4475
4551
|
clearTimeout(timer2);
|
|
4476
4552
|
return result2;
|
|
@@ -5102,7 +5178,7 @@ function parseRetryAfter(raw, now = Date.now()) {
|
|
|
5102
5178
|
return Math.min(Math.max(seconds, 0) * 1e3, RETRY_AFTER_CAP_MS);
|
|
5103
5179
|
}
|
|
5104
5180
|
function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
5105
|
-
return new Promise((
|
|
5181
|
+
return new Promise((resolve20, reject) => {
|
|
5106
5182
|
const target2 = new URL(url);
|
|
5107
5183
|
const send = target2.protocol === "https:" ? import_node_https.request : import_node_http.request;
|
|
5108
5184
|
const agent = POOLS[target2.protocol === "https:" ? "https:" : "http:"];
|
|
@@ -5113,7 +5189,7 @@ function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
|
5113
5189
|
res.on("end", () => {
|
|
5114
5190
|
const status = res.statusCode ?? 0;
|
|
5115
5191
|
const text4 = Buffer.concat(chunks).toString("utf8");
|
|
5116
|
-
|
|
5192
|
+
resolve20({
|
|
5117
5193
|
ok: status >= 200 && status <= 299,
|
|
5118
5194
|
status,
|
|
5119
5195
|
headers: {
|
|
@@ -5132,12 +5208,12 @@ function nodeTransport(url, init, idleMs = IDLE_MS) {
|
|
|
5132
5208
|
});
|
|
5133
5209
|
}
|
|
5134
5210
|
function nodePut(url, headers, source, idleMs) {
|
|
5135
|
-
return new Promise((
|
|
5211
|
+
return new Promise((resolve20, reject) => {
|
|
5136
5212
|
const target2 = new URL(url);
|
|
5137
5213
|
const send = target2.protocol === "https:" ? import_node_https.request : import_node_http.request;
|
|
5138
5214
|
const length = "body" in source ? source.body.length : source.size;
|
|
5139
5215
|
let answered;
|
|
5140
|
-
const settle = (err) => answered !== void 0 ?
|
|
5216
|
+
const settle = (err) => answered !== void 0 ? resolve20(answered) : reject(err);
|
|
5141
5217
|
const req = send(
|
|
5142
5218
|
target2,
|
|
5143
5219
|
{ method: "PUT", headers: { ...withoutLength(headers), "content-length": String(length) } },
|
|
@@ -5146,7 +5222,7 @@ function nodePut(url, headers, source, idleMs) {
|
|
|
5146
5222
|
answered = { status: res.statusCode ?? 0, retryAfter: Array.isArray(retry) ? retry[0] ?? null : retry ?? null };
|
|
5147
5223
|
res.on("error", settle);
|
|
5148
5224
|
res.on("close", () => {
|
|
5149
|
-
|
|
5225
|
+
resolve20(answered);
|
|
5150
5226
|
req.destroy();
|
|
5151
5227
|
});
|
|
5152
5228
|
res.resume();
|
|
@@ -5209,7 +5285,7 @@ function createClient(opts) {
|
|
|
5209
5285
|
}
|
|
5210
5286
|
const base = opts.apiUrl.replace(/\/+$/, "");
|
|
5211
5287
|
const scrub = (text4) => opts.token === "" ? text4 : text4.split(opts.token).join("***");
|
|
5212
|
-
async function send(method,
|
|
5288
|
+
async function send(method, path24, payload, retries = DEFAULT_RETRIES) {
|
|
5213
5289
|
let last = {
|
|
5214
5290
|
kind: "unavailable",
|
|
5215
5291
|
status: null,
|
|
@@ -5220,7 +5296,7 @@ function createClient(opts) {
|
|
|
5220
5296
|
await respectPause(mine);
|
|
5221
5297
|
let res;
|
|
5222
5298
|
try {
|
|
5223
|
-
res = await doFetch(`${base}${
|
|
5299
|
+
res = await doFetch(`${base}${path24}`, {
|
|
5224
5300
|
method,
|
|
5225
5301
|
headers: { "content-type": payload?.type ?? "application/json", authorization: `Bearer ${opts.token}` },
|
|
5226
5302
|
// A DELETE carries none. Sending `"undefined"` as a body is what a naive
|
|
@@ -5259,10 +5335,10 @@ function createClient(opts) {
|
|
|
5259
5335
|
return { ok: false, ...last };
|
|
5260
5336
|
}
|
|
5261
5337
|
return {
|
|
5262
|
-
post: (
|
|
5263
|
-
upload: (
|
|
5264
|
-
del: (
|
|
5265
|
-
get: (
|
|
5338
|
+
post: (path24, body, retries) => send("POST", path24, { body: JSON.stringify(body), type: "application/json" }, retries),
|
|
5339
|
+
upload: (path24, bytes, contentType) => send("POST", path24, { body: bytes, type: contentType }, uploadRetries ?? DEFAULT_RETRIES),
|
|
5340
|
+
del: (path24) => send("DELETE", path24),
|
|
5341
|
+
get: (path24) => send("GET", path24),
|
|
5266
5342
|
async put(url, headers, source) {
|
|
5267
5343
|
const putRetries = uploadRetries ?? 3;
|
|
5268
5344
|
let last = { ok: false, status: null, code: "network" };
|
|
@@ -5497,9 +5573,9 @@ var init_fallback = __esm({
|
|
|
5497
5573
|
});
|
|
5498
5574
|
|
|
5499
5575
|
// src/reporter-core/files-batch.ts
|
|
5500
|
-
async function sha256File(
|
|
5576
|
+
async function sha256File(path24) {
|
|
5501
5577
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
5502
|
-
for await (const part of (0, import_node_fs7.createReadStream)(
|
|
5578
|
+
for await (const part of (0, import_node_fs7.createReadStream)(path24)) hash.update(part);
|
|
5503
5579
|
return hash.digest("hex");
|
|
5504
5580
|
}
|
|
5505
5581
|
var import_node_crypto2, import_node_fs7, FILES_BATCH_MAX, DIRECT_BATCH_BYTES, BATCH_PIPELINES, sha256Bytes, BUCKET_CODES;
|
|
@@ -5926,7 +6002,7 @@ async function startRun(passed2, declared2) {
|
|
|
5926
6002
|
let free = uploadsAtOnce;
|
|
5927
6003
|
const waiting = [];
|
|
5928
6004
|
async function gated(work) {
|
|
5929
|
-
if (free === 0) await new Promise((
|
|
6005
|
+
if (free === 0) await new Promise((resolve20) => waiting.push(resolve20));
|
|
5930
6006
|
else free -= 1;
|
|
5931
6007
|
try {
|
|
5932
6008
|
return await work();
|
|
@@ -6646,14 +6722,14 @@ async function handleRunExec(options) {
|
|
|
6646
6722
|
if (command === void 0) throw new RunCommandError("Nothing to run \u2014 pass a command after `--`.");
|
|
6647
6723
|
const run = await handleRunStart(options);
|
|
6648
6724
|
const spawnImpl = options.spawnImpl ?? import_node_child_process2.spawn;
|
|
6649
|
-
const code = await new Promise((
|
|
6725
|
+
const code = await new Promise((resolve20) => {
|
|
6650
6726
|
const child = spawnImpl(command, args, {
|
|
6651
6727
|
stdio: "inherit",
|
|
6652
6728
|
shell: process.platform === "win32",
|
|
6653
6729
|
env: { ...process.env, PLUNE_RUN: run.externalKey, PLUNE_PROCEED: "1" }
|
|
6654
6730
|
});
|
|
6655
|
-
child.on("close", (exitCode2) =>
|
|
6656
|
-
child.on("error", () =>
|
|
6731
|
+
child.on("close", (exitCode2) => resolve20(exitCode2 ?? 1));
|
|
6732
|
+
child.on("error", () => resolve20(1));
|
|
6657
6733
|
});
|
|
6658
6734
|
return handleRunFinish(run.id, options, code);
|
|
6659
6735
|
}
|
|
@@ -6869,7 +6945,9 @@ var init_run_result_schema = __esm({
|
|
|
6869
6945
|
duration_ms: import_zod3.z.number().optional(),
|
|
6870
6946
|
result: import_zod3.z.object({ text: import_zod3.z.string(), bytes: import_zod3.z.number(), truncated: import_zod3.z.boolean() }).optional()
|
|
6871
6947
|
})
|
|
6872
|
-
)
|
|
6948
|
+
),
|
|
6949
|
+
/** Optional and additive: the step whose request first offered a changed list. */
|
|
6950
|
+
offered_changed: import_zod3.z.object({ added: import_zod3.z.array(import_zod3.z.string()), removed: import_zod3.z.array(import_zod3.z.string()) }).optional()
|
|
6873
6951
|
})
|
|
6874
6952
|
),
|
|
6875
6953
|
stop: import_zod3.z.object({
|
|
@@ -7194,10 +7272,10 @@ function platformGet(deps) {
|
|
|
7194
7272
|
const token = (deps.loadToken ?? loadToken)();
|
|
7195
7273
|
if (token === null) throw new NotLoggedInError();
|
|
7196
7274
|
const doFetch = deps.fetchImpl ?? fetch;
|
|
7197
|
-
return async (
|
|
7275
|
+
return async (path24) => {
|
|
7198
7276
|
let res;
|
|
7199
7277
|
try {
|
|
7200
|
-
res = await doFetch(`${apiUrl}${
|
|
7278
|
+
res = await doFetch(`${apiUrl}${path24}`, { headers: { authorization: `Bearer ${token}` } });
|
|
7201
7279
|
} catch {
|
|
7202
7280
|
throw new SyncNetworkError(apiUrl);
|
|
7203
7281
|
}
|
|
@@ -7552,9 +7630,9 @@ var init_read_file = __esm({
|
|
|
7552
7630
|
});
|
|
7553
7631
|
|
|
7554
7632
|
// src/importers/allure.ts
|
|
7555
|
-
function isFolder(
|
|
7633
|
+
function isFolder(path24) {
|
|
7556
7634
|
try {
|
|
7557
|
-
return fs12.statSync(
|
|
7635
|
+
return fs12.statSync(path24).isDirectory();
|
|
7558
7636
|
} catch {
|
|
7559
7637
|
return false;
|
|
7560
7638
|
}
|
|
@@ -8068,10 +8146,10 @@ function attemptOf(result2, file, ctx) {
|
|
|
8068
8146
|
...typeof at2?.file === "string" && typeof at2.line === "number" ? { location: { file: at2.file, line: at2.line, ...typeof at2.column === "number" ? { column: at2.column } : {} } } : {}
|
|
8069
8147
|
})),
|
|
8070
8148
|
steps: steps(result2.steps),
|
|
8071
|
-
attachments: (result2.attachments ?? []).map(({ name, contentType, path:
|
|
8149
|
+
attachments: (result2.attachments ?? []).map(({ name, contentType, path: path24, body }) => ({
|
|
8072
8150
|
name: name ?? "",
|
|
8073
8151
|
...contentType !== void 0 ? { contentType } : {},
|
|
8074
|
-
...
|
|
8152
|
+
...path24 !== void 0 ? { path: path24 } : {},
|
|
8075
8153
|
// Decoded only where the platform would take it (plune-ai/plune#928): a report of screenshots kept as
|
|
8076
8154
|
// bodies is megabytes of base64 that nothing here will read.
|
|
8077
8155
|
...typeof body === "string" && isTextType(contentType) ? { body: Buffer.from(body, "base64") } : {}
|
|
@@ -8511,7 +8589,7 @@ async function timeoutMessage(limit2, runId, ours, options) {
|
|
|
8511
8589
|
if (!ours) return `${head}; run ${runId} is shared with other jobs and was left open - close it with "plune run finish ${runId}" once they are done, then import this report again.`;
|
|
8512
8590
|
const wait = options.terminateWaitMs ?? 15e3;
|
|
8513
8591
|
let timer;
|
|
8514
|
-
const gaveUp = new Promise((
|
|
8592
|
+
const gaveUp = new Promise((resolve20) => timer = setTimeout(() => resolve20("gaveup"), wait));
|
|
8515
8593
|
const quiet = () => void 0;
|
|
8516
8594
|
const closed = handleRunFinish(runId, { ...options, write: quiet, terminate: true, reason: `import timed out after ${limit2} s` }).then(
|
|
8517
8595
|
() => true,
|
|
@@ -8584,7 +8662,7 @@ async function handleRunImport(options) {
|
|
|
8584
8662
|
else {
|
|
8585
8663
|
sent.catch(() => void 0);
|
|
8586
8664
|
let timer;
|
|
8587
|
-
const late = new Promise((
|
|
8665
|
+
const late = new Promise((resolve20) => timer = setTimeout(() => resolve20("late"), limit2 * 1e3));
|
|
8588
8666
|
const first = await Promise.race([sent, late]).finally(() => clearTimeout(timer));
|
|
8589
8667
|
if (first === "late") {
|
|
8590
8668
|
throw new ImportTimeoutError(await timeoutMessage(limit2, session?.runId ?? null, !env.keepOpen, { ...options, apiUrl, token }));
|
|
@@ -9226,7 +9304,7 @@ var init_logout = __esm({
|
|
|
9226
9304
|
});
|
|
9227
9305
|
|
|
9228
9306
|
// src/mcp-tools/schemas.ts
|
|
9229
|
-
var import_zod4, BATCH_MAX2, isHttp, httpLink, id, dryRun, MISSION_STATES, MISSION_DOCUMENTATION, MISSION_LINK_KINDS, missionName, missionSummary, missionUrl, missionFields, sourceTitle, sourceVersion, linkSource, fileSource, ACCESS_KINDS, questionText, questionInput, STRATEGY_SOURCE_KINDS, TEST_LEVELS, QUALITY_CHARACTERISTICS, TEST_TECHNIQUES, RISK_SCALE, itemFields, strategyItem, items, unique, linkIds, share, strategyContent, SOURCE_REF_KINDS, proposedCase, CASE_GENERATION_TITLE_MAX, CASE_GENERATION_MAX_CASES, CASE_GENERATION_DEFAULT_CASES, CASE_GENERATION_MIN_WORDS, CASE_GENERATION_TEXT_MAX, caseGenerationBody, API_METHODS, proposedEndpoint, REVIEW_STATES, REVIEW_KINDS, REJECTION_CATEGORIES, entity, plannedRequest, writeOutput, batchOutput, bulkPreview;
|
|
9307
|
+
var import_zod4, BATCH_MAX2, isHttp, httpLink, id, dryRun, MISSION_STATES, MISSION_DOCUMENTATION, MISSION_LINK_KINDS, missionName, missionSummary, missionUrl, missionFields, sourceTitle, sourceVersion, linkSource, fileSource, ACCESS_KINDS, questionText, questionInput, STRATEGY_SOURCE_KINDS, TEST_LEVELS, QUALITY_CHARACTERISTICS, TEST_TECHNIQUES, RISK_SCALE, itemFields, strategyItem, items, unique, linkIds, share, strategyContent, SOURCE_REF_KINDS, proposedCase, CASE_GENERATION_TITLE_MAX, CASE_GENERATION_MAX_CASES, CASE_GENERATION_DEFAULT_CASES, CASE_GENERATION_MIN_WORDS, CASE_GENERATION_TEXT_MAX, caseGenerationBody, API_METHODS, proposedEndpoint, REVIEW_STATES, REVIEW_KINDS, REJECTION_CATEGORIES, entity, plannedRequest, writeOutput, strategyOutput, batchOutput, bulkPreview;
|
|
9230
9308
|
var init_schemas = __esm({
|
|
9231
9309
|
"src/mcp-tools/schemas.ts"() {
|
|
9232
9310
|
"use strict";
|
|
@@ -9397,6 +9475,7 @@ var init_schemas = __esm({
|
|
|
9397
9475
|
request: plannedRequest.optional(),
|
|
9398
9476
|
result: entity.optional()
|
|
9399
9477
|
});
|
|
9478
|
+
strategyOutput = writeOutput.extend({ checked: import_zod4.z.boolean().optional(), findings: import_zod4.z.array(import_zod4.z.unknown()).optional() });
|
|
9400
9479
|
batchOutput = import_zod4.z.object({
|
|
9401
9480
|
dryRun: import_zod4.z.boolean(),
|
|
9402
9481
|
requested: import_zod4.z.number().int(),
|
|
@@ -9452,7 +9531,7 @@ var init_contract = __esm({
|
|
|
9452
9531
|
define({
|
|
9453
9532
|
name: "plune_project_context",
|
|
9454
9533
|
title: "Project context",
|
|
9455
|
-
description: "Start here: learn the project you are working in with one call \u2014 its projects, the suite tree, how many test cases it has, its testing missions,
|
|
9534
|
+
description: "Start here: learn the project you are working in with one call \u2014 its projects, the suite tree, how many test cases it has, its testing missions, how much waits in the review queue, and the rules of its memory: what a person accepted for this project, to follow without asking again.",
|
|
9456
9535
|
input: import_zod5.z.strictObject({}),
|
|
9457
9536
|
output: import_zod5.z.object({
|
|
9458
9537
|
projectId: import_zod5.z.string().nullable(),
|
|
@@ -9460,11 +9539,12 @@ var init_contract = __esm({
|
|
|
9460
9539
|
suites: import_zod5.z.array(entity),
|
|
9461
9540
|
cases: import_zod5.z.object({ total: import_zod5.z.number().int() }),
|
|
9462
9541
|
missions: import_zod5.z.array(entity),
|
|
9463
|
-
reviewQueue: import_zod5.z.object({ pending: import_zod5.z.number().int(), more: import_zod5.z.boolean() })
|
|
9542
|
+
reviewQueue: import_zod5.z.object({ pending: import_zod5.z.number().int(), more: import_zod5.z.boolean() }),
|
|
9543
|
+
memoryRules: import_zod5.z.array(import_zod5.z.object({ id: import_zod5.z.string(), text: import_zod5.z.string() })).describe("Rules a person accepted in the review queue and has not retired; a proposed or rejected rule is never here")
|
|
9464
9544
|
}),
|
|
9465
9545
|
write: false,
|
|
9466
9546
|
visibility: "core",
|
|
9467
|
-
endpoints: ["GET /v1/projects", "GET /v1/suites", "GET /v1/test-cases", "GET /v1/missions", "GET /v1/review-items"]
|
|
9547
|
+
endpoints: ["GET /v1/projects", "GET /v1/suites", "GET /v1/test-cases", "GET /v1/missions", "GET /v1/review-items", "GET /v1/memory/rules"]
|
|
9468
9548
|
}),
|
|
9469
9549
|
define({
|
|
9470
9550
|
name: "plune_get",
|
|
@@ -9497,10 +9577,11 @@ var init_contract = __esm({
|
|
|
9497
9577
|
define({
|
|
9498
9578
|
name: "plune_review_list",
|
|
9499
9579
|
title: "Read the review queue",
|
|
9500
|
-
description: "See what waits for a decision in the review queue \u2014 proposed cases, discovered tests, endpoints, strategies, reports \u2014 narrowed by state and
|
|
9580
|
+
description: "See what waits for a decision in the review queue \u2014 proposed cases, discovered tests, endpoints, strategies, reports \u2014 narrowed by state, kind and mission, newest first, one page at a time. The mission filter needs a platform that supports it; an older one returns the whole queue.",
|
|
9501
9581
|
input: import_zod5.z.strictObject({
|
|
9502
9582
|
state: import_zod5.z.enum(REVIEW_STATES).optional(),
|
|
9503
9583
|
kinds: import_zod5.z.array(import_zod5.z.enum(REVIEW_KINDS)).min(1).optional().describe("Questions are read with the question tool"),
|
|
9584
|
+
missionId: import_zod5.z.string().min(1).optional().describe("Only the entries of this mission"),
|
|
9504
9585
|
...listPage
|
|
9505
9586
|
}),
|
|
9506
9587
|
output: import_zod5.z.object({ items: import_zod5.z.array(entity), nextCursor: import_zod5.z.string().nullable() }),
|
|
@@ -9535,10 +9616,11 @@ var init_contract = __esm({
|
|
|
9535
9616
|
description: "Propose up to 100 new test cases for a person to review: they land in the review queue as proposals and become cases only when someone approves them. Nothing is created silently.",
|
|
9536
9617
|
input: import_zod5.z.strictObject({
|
|
9537
9618
|
target: import_zod5.z.string().trim().min(1).max(2048).describe("What the cases test: the product address, or the mission name"),
|
|
9619
|
+
missionId: import_zod5.z.string().min(1).optional().describe("The mission these cases are for: the review queue can then be read by it"),
|
|
9538
9620
|
cases: import_zod5.z.array(proposedCase).min(1).max(BATCH_MAX2),
|
|
9539
9621
|
dry_run: dryRun
|
|
9540
9622
|
}),
|
|
9541
|
-
output: batchOutput,
|
|
9623
|
+
output: batchOutput.extend({ itemIds: import_zod5.z.array(import_zod5.z.string()).optional().describe("The ids of the review-queue entries created, when the platform names them") }),
|
|
9542
9624
|
write: true,
|
|
9543
9625
|
visibility: "core",
|
|
9544
9626
|
endpoints: ["POST /v1/ingest/cairn"]
|
|
@@ -9655,7 +9737,7 @@ var init_contract = __esm({
|
|
|
9655
9737
|
title: "Propose a test strategy",
|
|
9656
9738
|
description: "Propose a test strategy for a mission in ISTQB sections \u2014 objectives, scope in and out, approach, levels and techniques, risks, entry and exit criteria \u2014 for a person to accept.",
|
|
9657
9739
|
input: import_zod5.z.strictObject({ missionId, content: strategyContent, dry_run: dryRun }),
|
|
9658
|
-
output:
|
|
9740
|
+
output: strategyOutput,
|
|
9659
9741
|
write: true,
|
|
9660
9742
|
visibility: "core",
|
|
9661
9743
|
endpoints: ["POST /v1/missions/:id/strategy"]
|
|
@@ -9857,6 +9939,17 @@ var init_client2 = __esm({
|
|
|
9857
9939
|
});
|
|
9858
9940
|
|
|
9859
9941
|
// src/mcp-tools/execute.ts
|
|
9942
|
+
function detailLines(body) {
|
|
9943
|
+
const b = asRecord(body);
|
|
9944
|
+
const lines = [...asArray(b["findings"]), ...asArray(b["details"])].map((d) => {
|
|
9945
|
+
if (typeof d === "string") return `- ${d}`;
|
|
9946
|
+
const f = asRecord(d);
|
|
9947
|
+
const where2 = [f["rule"], f["path"]].filter((x) => typeof x === "string").join(" at ");
|
|
9948
|
+
const said2 = typeof f["message"] === "string" ? f["message"] : where2 === "" ? JSON.stringify(d) : "";
|
|
9949
|
+
return `- ${[where2, said2].filter(Boolean).join(": ")}`;
|
|
9950
|
+
});
|
|
9951
|
+
return lines.length === 0 ? "" : "\n" + lines.join("\n");
|
|
9952
|
+
}
|
|
9860
9953
|
function errorOf(err) {
|
|
9861
9954
|
if (err instanceof PluneApiError) {
|
|
9862
9955
|
if (err.status === 401)
|
|
@@ -9864,7 +9957,7 @@ function errorOf(err) {
|
|
|
9864
9957
|
if (err.status === 403 && err.message === READ_ONLY_REFUSAL)
|
|
9865
9958
|
return { status: 403, code: "read_only_token", message: `Plune refused (403): ${readScopeMessage("it cannot write")}` };
|
|
9866
9959
|
const code = err.code ?? `http_${err.status}`;
|
|
9867
|
-
return { status: err.status, code, message: `Plune refused (${err.status} ${code}): ${err.message}`, details: err.body };
|
|
9960
|
+
return { status: err.status, code, message: `Plune refused (${err.status} ${code}): ${err.message}${detailLines(err.body)}`, details: err.body };
|
|
9868
9961
|
}
|
|
9869
9962
|
if (err instanceof PluneNetworkError) return { code: "network", message: `${err.message}. Check PLUNE_API_URL and the network.` };
|
|
9870
9963
|
throw err;
|
|
@@ -9927,13 +10020,19 @@ function createPluneToolExecutor(opts) {
|
|
|
9927
10020
|
const str2 = (v) => v;
|
|
9928
10021
|
const handlers = {
|
|
9929
10022
|
async plune_project_context() {
|
|
9930
|
-
const [projects, suites, cases, missions, queue] = await Promise.all([
|
|
10023
|
+
const [projects, suites, cases, missions, queue, memory] = await Promise.all([
|
|
9931
10024
|
call2({ method: "GET", path: "/v1/projects" }),
|
|
9932
10025
|
call2({ method: "GET", path: "/v1/suites" }),
|
|
9933
10026
|
call2({ method: "GET", path: "/v1/test-cases", query: { limit: "1", stability: "0" } }),
|
|
9934
10027
|
call2({ method: "GET", path: "/v1/missions" }),
|
|
9935
|
-
call2({ method: "GET", path: "/v1/review-items", query: { state: "pending", limit: "100" } })
|
|
10028
|
+
call2({ method: "GET", path: "/v1/review-items", query: { state: "pending", limit: "100" } }),
|
|
10029
|
+
// A platform that keeps no project memory yet answers 404: no rules, and the rest of the context still stands.
|
|
10030
|
+
call2({ method: "GET", path: "/v1/memory/rules", query: { state: "in_force" } }).catch((err) => {
|
|
10031
|
+
if (err instanceof PluneApiError && err.status === 404) return { status: 404, body: { rules: [] } };
|
|
10032
|
+
throw err;
|
|
10033
|
+
})
|
|
9936
10034
|
]);
|
|
10035
|
+
const memoryRules = asArray(asRecord(memory.body)["rules"]).map(asRecord).filter((r) => r["inForce"] === true && typeof r["id"] === "string" && typeof r["text"] === "string").map((r) => ({ id: str2(r["id"]), text: str2(r["text"]) }));
|
|
9937
10036
|
const projectList = asArray(asRecord(projects.body)["projects"]);
|
|
9938
10037
|
const only = projectList.length === 1 ? asRecord(projectList[0])["id"] : void 0;
|
|
9939
10038
|
const projectId2 = opts.projectId ?? (typeof only === "string" ? only : null);
|
|
@@ -9944,7 +10043,8 @@ function createPluneToolExecutor(opts) {
|
|
|
9944
10043
|
suites: asArray(asRecord(suites.body)["suites"]),
|
|
9945
10044
|
cases: { total: typeof total === "number" ? total : 0 },
|
|
9946
10045
|
missions: asArray(asRecord(missions.body)["missions"]),
|
|
9947
|
-
reviewQueue: { pending: asArray(asRecord(queue.body)["items"]).length, more: cursorOf(asRecord(queue.body)["nextCursor"]) !== null }
|
|
10046
|
+
reviewQueue: { pending: asArray(asRecord(queue.body)["items"]).length, more: cursorOf(asRecord(queue.body)["nextCursor"]) !== null },
|
|
10047
|
+
memoryRules
|
|
9948
10048
|
};
|
|
9949
10049
|
},
|
|
9950
10050
|
async plune_get(i) {
|
|
@@ -9972,6 +10072,7 @@ function createPluneToolExecutor(opts) {
|
|
|
9972
10072
|
const query = withoutUndefined({
|
|
9973
10073
|
state: i["state"],
|
|
9974
10074
|
kind: kinds?.join(","),
|
|
10075
|
+
missionId: i["missionId"],
|
|
9975
10076
|
limit: i["limit"] === void 0 ? void 0 : String(i["limit"]),
|
|
9976
10077
|
cursor: i["cursor"]
|
|
9977
10078
|
});
|
|
@@ -10001,12 +10102,17 @@ function createPluneToolExecutor(opts) {
|
|
|
10001
10102
|
const req = {
|
|
10002
10103
|
method: "POST",
|
|
10003
10104
|
path: "/v1/ingest/cairn",
|
|
10004
|
-
body: {
|
|
10105
|
+
body: {
|
|
10106
|
+
schemaVersion: 1,
|
|
10107
|
+
run: withoutUndefined({ runId: `mcp-${sessionId}-${proposals}`, mode: "design", target: str2(i["target"]), missionId: i["missionId"] }),
|
|
10108
|
+
cases
|
|
10109
|
+
}
|
|
10005
10110
|
};
|
|
10006
10111
|
if (i["dry_run"] === true) return { dryRun: true, requested: cases.length, applied: 0, requests: [planned(req)] };
|
|
10007
10112
|
const summary = asRecord((await call2(req)).body);
|
|
10008
10113
|
const proposed = summary["proposed"];
|
|
10009
|
-
|
|
10114
|
+
const ids = asArray(summary["itemIds"]).filter((x) => typeof x === "string");
|
|
10115
|
+
return { dryRun: false, requested: cases.length, applied: typeof proposed === "number" ? proposed : 0, ...ids.length > 0 ? { itemIds: ids } : {}, report: summary };
|
|
10010
10116
|
},
|
|
10011
10117
|
async plune_cases_generate(i) {
|
|
10012
10118
|
const { dry_run, projectId: projectId2, ...body } = i;
|
|
@@ -10058,6 +10164,16 @@ function createPluneToolExecutor(opts) {
|
|
|
10058
10164
|
return { questions, nextCursor: cursorOf(body["nextCursor"]) };
|
|
10059
10165
|
},
|
|
10060
10166
|
async plune_strategy_propose(i) {
|
|
10167
|
+
const req = { method: "POST", path: path20("/v1/missions/:id/strategy", str2(i["missionId"])), body: i["content"] };
|
|
10168
|
+
if (i["dry_run"] === true) {
|
|
10169
|
+
try {
|
|
10170
|
+
const res = await call2({ ...req, path: `${req.path}/check` });
|
|
10171
|
+
return { dryRun: true, checked: true, findings: asArray(asRecord(res.body)["findings"]), request: planned(req) };
|
|
10172
|
+
} catch (err) {
|
|
10173
|
+
if (!(err instanceof PluneApiError && (err.status === 404 && err.code !== "mission_not_found" || err.status === 403 && err.message === READ_ONLY_REFUSAL))) throw err;
|
|
10174
|
+
return { dryRun: true, checked: false, request: planned(req) };
|
|
10175
|
+
}
|
|
10176
|
+
}
|
|
10061
10177
|
return write({ method: "POST", path: path20("/v1/missions/:id/strategy", str2(i["missionId"])), body: i["content"] }, i["dry_run"]);
|
|
10062
10178
|
},
|
|
10063
10179
|
async plune_report_request(i) {
|
|
@@ -10305,7 +10421,7 @@ function answeringParseErrors(answer) {
|
|
|
10305
10421
|
async function serveMcpStdio(opts) {
|
|
10306
10422
|
const input = process.stdin.pipe(answeringParseErrors((line) => process.stdout.write(line)));
|
|
10307
10423
|
const transport = new import_stdio2.StdioServerTransport(input, process.stdout);
|
|
10308
|
-
await new Promise((
|
|
10424
|
+
await new Promise((resolve20) => {
|
|
10309
10425
|
(0, import_stdio2.serveStdio)((ctx) => createPluneMcpServer(opts, ctx.era), {
|
|
10310
10426
|
transport,
|
|
10311
10427
|
onerror: (error) => {
|
|
@@ -10317,7 +10433,7 @@ async function serveMcpStdio(opts) {
|
|
|
10317
10433
|
const owned = transport.onclose;
|
|
10318
10434
|
transport.onclose = () => {
|
|
10319
10435
|
owned?.();
|
|
10320
|
-
|
|
10436
|
+
resolve20();
|
|
10321
10437
|
};
|
|
10322
10438
|
});
|
|
10323
10439
|
}
|
|
@@ -10432,7 +10548,7 @@ var init_run3 = __esm({
|
|
|
10432
10548
|
now: () => import_node_perf_hooks2.performance.now(),
|
|
10433
10549
|
after(ms) {
|
|
10434
10550
|
let timer;
|
|
10435
|
-
const done = new Promise((
|
|
10551
|
+
const done = new Promise((resolve20) => timer = setTimeout(resolve20, ms));
|
|
10436
10552
|
return { done, cancel: () => clearTimeout(timer) };
|
|
10437
10553
|
}
|
|
10438
10554
|
};
|
|
@@ -11072,8 +11188,8 @@ function sortKeys(value2) {
|
|
|
11072
11188
|
function homePattern(home) {
|
|
11073
11189
|
const trimmed = home?.replace(/[\\/]+$/, "");
|
|
11074
11190
|
if (trimmed === void 0 || trimmed.length < 2) return void 0;
|
|
11075
|
-
const
|
|
11076
|
-
return new RegExp(`(?<![\\w./\\\\-])${
|
|
11191
|
+
const path24 = trimmed.split(/[\\/]/).map(escapeRegExp).join("[\\\\/]");
|
|
11192
|
+
return new RegExp(`(?<![\\w./\\\\-])${path24}(?![\\w-]|\\.\\w)`, /^[A-Za-z]:/.test(trimmed) ? "gi" : "g");
|
|
11077
11193
|
}
|
|
11078
11194
|
function redact(value2, secrets, home) {
|
|
11079
11195
|
if (typeof value2 === "string") {
|
|
@@ -11254,10 +11370,10 @@ function same(a, b) {
|
|
|
11254
11370
|
const ka = Object.keys(a);
|
|
11255
11371
|
return ka.length === Object.keys(b).length && ka.every((k) => Object.hasOwn(b, k) && same(a[k], b[k]));
|
|
11256
11372
|
}
|
|
11257
|
-
function compareSchema(c, side,
|
|
11373
|
+
function compareSchema(c, side, path24, before, after) {
|
|
11258
11374
|
if (same(before, after)) return;
|
|
11259
|
-
const field = `${side}Schema${
|
|
11260
|
-
if (
|
|
11375
|
+
const field = `${side}Schema${path24 === "" ? "" : `.${path24}`}`;
|
|
11376
|
+
if (path24 === "" && (before === void 0 || after === void 0)) {
|
|
11261
11377
|
if (side === "output") {
|
|
11262
11378
|
if (after === void 0) c.add(field, "breaking", "The output schema was removed; a client reading the result loses its shape.", before, after);
|
|
11263
11379
|
else c.add(field, "non-breaking", "An output schema was added.", before, after);
|
|
@@ -11269,10 +11385,10 @@ function compareSchema(c, side, path23, before, after) {
|
|
|
11269
11385
|
return c.add(`${field}`, "breaking", `The type changed from ${show(before["type"])} to ${show(after["type"])}.`, before["type"], after["type"]);
|
|
11270
11386
|
}
|
|
11271
11387
|
if (!same(before["enum"], after["enum"])) compareEnum(c, side, field, before["enum"], after["enum"]);
|
|
11272
|
-
compareProperties(c, side,
|
|
11273
|
-
if (!same(before["items"], after["items"])) compareSchema(c, side, `${
|
|
11388
|
+
compareProperties(c, side, path24, field, before, after);
|
|
11389
|
+
if (!same(before["items"], after["items"])) compareSchema(c, side, `${path24}[]`, before["items"], after["items"]);
|
|
11274
11390
|
if (!same(before["description"], after["description"])) {
|
|
11275
|
-
const what =
|
|
11391
|
+
const what = path24 === "" ? `whole ${side} schema` : side === "input" ? "parameter" : "field";
|
|
11276
11392
|
c.add(field, "informational", `The ${what} description changed: it is what a model reads.`, before["description"], after["description"], {
|
|
11277
11393
|
signal: "security"
|
|
11278
11394
|
});
|
|
@@ -11332,7 +11448,7 @@ function compareEnum(c, side, field, before, after) {
|
|
|
11332
11448
|
if (widened) return c.add(field, "breaking", `The result enum was widened: ${gained}; a client does not know the new value.`, before, after);
|
|
11333
11449
|
c.add(field, "non-breaking", `The result enum was narrowed: ${lost}.`, before, after);
|
|
11334
11450
|
}
|
|
11335
|
-
function compareProperties(c, side,
|
|
11451
|
+
function compareProperties(c, side, path24, field, before, after) {
|
|
11336
11452
|
const bp = isRecord6(before["properties"]) ? before["properties"] : {};
|
|
11337
11453
|
const ap = isRecord6(after["properties"]) ? after["properties"] : {};
|
|
11338
11454
|
const br = stringSet(before["required"]);
|
|
@@ -11345,7 +11461,7 @@ function compareProperties(c, side, path23, field, before, after) {
|
|
|
11345
11461
|
}
|
|
11346
11462
|
const what = side === "input" ? "parameter" : "field";
|
|
11347
11463
|
for (const name of [.../* @__PURE__ */ new Set([...Object.keys(bp), ...Object.keys(ap)])].sort()) {
|
|
11348
|
-
const sub =
|
|
11464
|
+
const sub = path24 === "" ? name : `${path24}.${name}`;
|
|
11349
11465
|
const f = `${side}Schema.${sub}`;
|
|
11350
11466
|
const inBefore = Object.hasOwn(bp, name);
|
|
11351
11467
|
const inAfter = Object.hasOwn(ap, name);
|
|
@@ -11965,25 +12081,25 @@ var init_thresholds = __esm({
|
|
|
11965
12081
|
tooLooseShare: 0.8,
|
|
11966
12082
|
/** Whole tool lists, outputSchema and annotations included. */
|
|
11967
12083
|
lists: {
|
|
11968
|
-
/** 2025 era, write scope, as listed first: 17 tools, measured 8327. */
|
|
11969
|
-
writeFirst:
|
|
11970
|
-
/** 2025 era, write scope, after plune_discover_tools: 22 tools, measured 10739. */
|
|
11971
|
-
writeAll:
|
|
11972
|
-
/** Read scope, either era: 8 tools, measured 2380. */
|
|
11973
|
-
read:
|
|
11974
|
-
/** 2026-07-28 era, write scope: 17 tools, the list does not change after discover; measured 8327. */
|
|
11975
|
-
modernWrite:
|
|
12084
|
+
/** 2025 era, write scope, as listed first: 17 tools, measured 8429 (8327 before the memory rules of plune_project_context). */
|
|
12085
|
+
writeFirst: 9272,
|
|
12086
|
+
/** 2025 era, write scope, after plune_discover_tools: 22 tools, measured 10841 (10739 before the memory rules). */
|
|
12087
|
+
writeAll: 11926,
|
|
12088
|
+
/** Read scope, either era: 8 tools, measured 2482 (2380 before the memory rules). */
|
|
12089
|
+
read: 2731,
|
|
12090
|
+
/** 2026-07-28 era, write scope: 17 tools, the list does not change after discover; measured 8429 (8327 before the memory rules). */
|
|
12091
|
+
modernWrite: 9272
|
|
11976
12092
|
},
|
|
11977
12093
|
/** The biggest single tool, plune_strategy_propose, measured 2177. */
|
|
11978
12094
|
largestTool: 2395,
|
|
11979
12095
|
/**
|
|
11980
12096
|
* The text content of an answer, measured 2026-11-10 on live answers of the beta demo project recorded in
|
|
11981
|
-
* plune-budget.fixtures.ts (cases in Ukrainian): plune_project_context with 3 projects, 3 suites, no missions 543;
|
|
12097
|
+
* plune-budget.fixtures.ts (cases in Ukrainian): plune_project_context with 3 projects, 3 suites, no missions 548 (543 before its empty memoryRules);
|
|
11982
12098
|
* plune_cases_search 10521 for the whole project of 48 cases (a page of 100 is not reached, ~219 per case);
|
|
11983
12099
|
* plune_review_list of 7 pending entries 895. The demo has no missions, so plune_mission_get with 5 sources, 476, is
|
|
11984
12100
|
* measured on a synthetic mission.
|
|
11985
12101
|
*/
|
|
11986
|
-
answers: { plune_project_context:
|
|
12102
|
+
answers: { plune_project_context: 603, plune_cases_search: 11574, plune_review_list: 985, plune_mission_get: 524 }
|
|
11987
12103
|
};
|
|
11988
12104
|
LINT_THRESHOLDS = {
|
|
11989
12105
|
description: {
|
|
@@ -12119,8 +12235,8 @@ function jsonText(value2) {
|
|
|
12119
12235
|
const entries2 = Object.entries(step.value).filter(([, v]) => array || !skipped(v));
|
|
12120
12236
|
const parts = [{ text: array ? "[" : "{" }];
|
|
12121
12237
|
entries2.forEach(([key, v], i) => {
|
|
12122
|
-
const
|
|
12123
|
-
parts.push({ text: array ?
|
|
12238
|
+
const sep3 = i === 0 ? "" : ",";
|
|
12239
|
+
parts.push({ text: array ? sep3 : `${sep3}${JSON.stringify(key)}:` }, { value: v });
|
|
12124
12240
|
});
|
|
12125
12241
|
parts.push({ text: array ? "]" : "}" });
|
|
12126
12242
|
for (const part of parts.reverse()) todo.push(part);
|
|
@@ -12186,10 +12302,10 @@ function schemaNodes(schema) {
|
|
|
12186
12302
|
const children = [];
|
|
12187
12303
|
for (const [name, p] of Object.entries(props(node.schema))) {
|
|
12188
12304
|
if (!isRecord7(p)) continue;
|
|
12189
|
-
const
|
|
12305
|
+
const path24 = node.path === "" ? name : `${node.path}.${name}`;
|
|
12190
12306
|
const depth = node.depth + 1;
|
|
12191
|
-
children.push({ path:
|
|
12192
|
-
if (isRecord7(p.items)) children.push({ path: `${
|
|
12307
|
+
children.push({ path: path24, schema: p, kind: "param", depth });
|
|
12308
|
+
if (isRecord7(p.items)) children.push({ path: `${path24}[]`, schema: p.items, kind: "items", depth: depth + 1 });
|
|
12193
12309
|
}
|
|
12194
12310
|
for (const child of children.reverse()) todo.push(child);
|
|
12195
12311
|
}
|
|
@@ -13967,13 +14083,13 @@ async function lint(flags2, server2, io, rawOut) {
|
|
|
13967
14083
|
}
|
|
13968
14084
|
function readExceptions(flag2, io) {
|
|
13969
14085
|
const name = flag2 ?? DEFAULT_IGNORE_FILE;
|
|
13970
|
-
const
|
|
13971
|
-
if (!(0, import_node_fs11.existsSync)(
|
|
14086
|
+
const path24 = (0, import_node_path7.resolve)(io.cwd, name);
|
|
14087
|
+
if (!(0, import_node_fs11.existsSync)(path24)) {
|
|
13972
14088
|
if (flag2 !== void 0) throw new UsageError(`--ignore-file: ${name} does not exist.`);
|
|
13973
14089
|
return void 0;
|
|
13974
14090
|
}
|
|
13975
14091
|
const today = io.today ?? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
13976
|
-
return { name, ...parseExceptionsFile((0, import_node_fs11.readFileSync)(
|
|
14092
|
+
return { name, ...parseExceptionsFile((0, import_node_fs11.readFileSync)(path24, "utf8"), name, today) };
|
|
13977
14093
|
}
|
|
13978
14094
|
async function listTools(session) {
|
|
13979
14095
|
try {
|
|
@@ -14287,14 +14403,14 @@ async function listAll2(session, method, key) {
|
|
|
14287
14403
|
}
|
|
14288
14404
|
return listing.items;
|
|
14289
14405
|
}
|
|
14290
|
-
function writeAtomically(
|
|
14406
|
+
function writeAtomically(path24, text4, shown2) {
|
|
14291
14407
|
const temporary = (0, import_node_path8.join)(
|
|
14292
|
-
(0, import_node_path8.dirname)(
|
|
14293
|
-
`.${(0, import_node_path8.basename)(
|
|
14408
|
+
(0, import_node_path8.dirname)(path24),
|
|
14409
|
+
`.${(0, import_node_path8.basename)(path24)}.${process.pid}.${(0, import_node_crypto7.randomBytes)(4).toString("hex")}.tmp`
|
|
14294
14410
|
);
|
|
14295
14411
|
try {
|
|
14296
14412
|
(0, import_node_fs12.writeFileSync)(temporary, text4, { flag: "wx" });
|
|
14297
|
-
(0, import_node_fs12.renameSync)(temporary,
|
|
14413
|
+
(0, import_node_fs12.renameSync)(temporary, path24);
|
|
14298
14414
|
} catch (err) {
|
|
14299
14415
|
(0, import_node_fs12.rmSync)(temporary, { force: true });
|
|
14300
14416
|
const code = err.code ?? "an error";
|
|
@@ -15266,13 +15382,13 @@ var mcp_conformance_exports = {};
|
|
|
15266
15382
|
__export(mcp_conformance_exports, {
|
|
15267
15383
|
handleMcpConformance: () => handleMcpConformance
|
|
15268
15384
|
});
|
|
15269
|
-
function loadFixture(
|
|
15385
|
+
function loadFixture(path24) {
|
|
15270
15386
|
let doc;
|
|
15271
15387
|
try {
|
|
15272
|
-
doc = JSON.parse((0, import_node_fs14.readFileSync)(
|
|
15388
|
+
doc = JSON.parse((0, import_node_fs14.readFileSync)(path24, "utf8"));
|
|
15273
15389
|
} catch (err) {
|
|
15274
15390
|
const code = err.code;
|
|
15275
|
-
throw new UsageError(`--fixture: could not read ${
|
|
15391
|
+
throw new UsageError(`--fixture: could not read ${path24} as JSON${code === void 0 ? "" : ` (${code})`}.`);
|
|
15276
15392
|
}
|
|
15277
15393
|
if (!Array.isArray(doc)) throw new UsageError('--fixture must hold a JSON list of { "tool": "<name>", "arguments": { ... } }.');
|
|
15278
15394
|
return doc.map((entry2, i) => {
|
|
@@ -16338,6 +16454,403 @@ var init_verify = __esm({
|
|
|
16338
16454
|
}
|
|
16339
16455
|
});
|
|
16340
16456
|
|
|
16457
|
+
// src/cli/commands/automate.ts
|
|
16458
|
+
var automate_exports = {};
|
|
16459
|
+
__export(automate_exports, {
|
|
16460
|
+
AUTOMATION_FILES_MAX: () => AUTOMATION_FILES_MAX,
|
|
16461
|
+
AUTOMATION_FILE_MAX_BYTES: () => AUTOMATION_FILE_MAX_BYTES,
|
|
16462
|
+
AUTOMATION_PATH_MAX: () => AUTOMATION_PATH_MAX,
|
|
16463
|
+
AUTOMATION_TOTAL_MAX_BYTES: () => AUTOMATION_TOTAL_MAX_BYTES,
|
|
16464
|
+
CairnFailedError: () => CairnFailedError,
|
|
16465
|
+
CairnMissingError: () => CairnMissingError,
|
|
16466
|
+
CairnProducedNothingError: () => CairnProducedNothingError,
|
|
16467
|
+
CaseNotAutomatableError: () => CaseNotAutomatableError,
|
|
16468
|
+
CaseNotFoundError: () => CaseNotFoundError,
|
|
16469
|
+
NoTestCallError: () => NoTestCallError,
|
|
16470
|
+
ProposalBoundsError: () => ProposalBoundsError,
|
|
16471
|
+
ProposalRefusedError: () => ProposalRefusedError,
|
|
16472
|
+
automationProposal: () => automationProposal,
|
|
16473
|
+
cairnEnv: () => cairnEnv,
|
|
16474
|
+
caseToAtcMarkdown: () => caseToAtcMarkdown,
|
|
16475
|
+
filteredDotenv: () => filteredDotenv,
|
|
16476
|
+
findTestCall: () => findTestCall,
|
|
16477
|
+
formatSent: () => formatSent,
|
|
16478
|
+
handleAutomate: () => handleAutomate,
|
|
16479
|
+
newFilesDiff: () => newFilesDiff,
|
|
16480
|
+
reportAutomateFailure: () => reportAutomateFailure,
|
|
16481
|
+
sendAutomation: () => sendAutomation
|
|
16482
|
+
});
|
|
16483
|
+
function caseToAtcMarkdown(c) {
|
|
16484
|
+
const steps = (c.steps ?? []).map((s, i) => `${i + 1}. ${flat3(s.action)}${s.expected ? ` (expected: ${flat3(s.expected)})` : ""}`);
|
|
16485
|
+
const pre = (c.precondition ?? "").split(/\r?\n/).map(flat3).filter((l) => l !== "");
|
|
16486
|
+
const expected = c.expected ? [flat3(c.expected)] : (c.steps ?? []).flatMap((s) => s.expected ? [flat3(s.expected)] : []);
|
|
16487
|
+
return [
|
|
16488
|
+
"---",
|
|
16489
|
+
"id: ATC-PLUNE-001",
|
|
16490
|
+
`stableId: ${c.id}`,
|
|
16491
|
+
`title: "${flat3(c.title).replace(/"/g, "'")}"`,
|
|
16492
|
+
"suite: PLUNE",
|
|
16493
|
+
"execution: auto",
|
|
16494
|
+
"status: \u274C Not implemented",
|
|
16495
|
+
"---",
|
|
16496
|
+
"",
|
|
16497
|
+
`# ATC-PLUNE-001: ${flat3(c.title)}`,
|
|
16498
|
+
"",
|
|
16499
|
+
"## Preconditions",
|
|
16500
|
+
"",
|
|
16501
|
+
...pre.length > 0 ? pre.map((p) => `- ${p}`) : ["- (none)"],
|
|
16502
|
+
"",
|
|
16503
|
+
"## Steps",
|
|
16504
|
+
"",
|
|
16505
|
+
...steps,
|
|
16506
|
+
"",
|
|
16507
|
+
"## Expected Result",
|
|
16508
|
+
"",
|
|
16509
|
+
...expected.map((e) => `- ${e}`),
|
|
16510
|
+
""
|
|
16511
|
+
].join("\n");
|
|
16512
|
+
}
|
|
16513
|
+
function cairnEnv(env, token) {
|
|
16514
|
+
return Object.fromEntries(
|
|
16515
|
+
Object.entries(env).filter(([k, v]) => v !== void 0 && !/^PLUNE_/i.test(k) && (token === "" || !v.includes(token)))
|
|
16516
|
+
);
|
|
16517
|
+
}
|
|
16518
|
+
function filteredDotenv(text4, token) {
|
|
16519
|
+
return text4.split(/\r?\n/).filter((line) => {
|
|
16520
|
+
const key = /^\s*(?:export\s+)?([\w.-]+)\s*[=:]/.exec(line)?.[1];
|
|
16521
|
+
return !(key !== void 0 && /^PLUNE_/i.test(key)) && (token === "" || !line.includes(token));
|
|
16522
|
+
}).join("\n");
|
|
16523
|
+
}
|
|
16524
|
+
function filesUnder(dir) {
|
|
16525
|
+
if (!fs18.existsSync(dir)) return [];
|
|
16526
|
+
return fs18.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((p) => fs18.statSync(path23.join(dir, p)).isFile()).map((p) => p.split(path23.sep).join("/")).sort();
|
|
16527
|
+
}
|
|
16528
|
+
function newFilesDiff(files) {
|
|
16529
|
+
return files.map((f) => {
|
|
16530
|
+
const p = `tests/${f.path}`;
|
|
16531
|
+
const head = [`diff --git a/${p} b/${p}`, "new file mode 100644", "--- /dev/null", `+++ b/${p}`];
|
|
16532
|
+
if (f.content === "") return head.join("\n") + "\n";
|
|
16533
|
+
const lines = f.content.split("\n");
|
|
16534
|
+
const endsWithNewline = lines[lines.length - 1] === "";
|
|
16535
|
+
if (endsWithNewline) lines.pop();
|
|
16536
|
+
const body = lines.map((l) => `+${l}`);
|
|
16537
|
+
if (!endsWithNewline) body.push("\");
|
|
16538
|
+
return [...head, `@@ -0,0 +1,${lines.length} @@`, ...body].join("\n") + "\n";
|
|
16539
|
+
}).join("");
|
|
16540
|
+
}
|
|
16541
|
+
function findExecutable(command, env) {
|
|
16542
|
+
if (command.includes("/") || command.includes("\\")) return fs18.existsSync(command) ? path23.resolve(command) : void 0;
|
|
16543
|
+
const exts = process.platform === "win32" ? (env["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD").split(";") : [""];
|
|
16544
|
+
const dirs = (env["PATH"] ?? env["Path"] ?? "").split(path23.delimiter).filter((d) => d !== "");
|
|
16545
|
+
for (const dir of dirs)
|
|
16546
|
+
for (const ext of exts) {
|
|
16547
|
+
const candidate = path23.join(dir, command + ext);
|
|
16548
|
+
if (fs18.existsSync(candidate) && fs18.statSync(candidate).isFile()) return candidate;
|
|
16549
|
+
}
|
|
16550
|
+
return void 0;
|
|
16551
|
+
}
|
|
16552
|
+
async function handleAutomate(deps) {
|
|
16553
|
+
for (const a of deps.cairnArgs ?? [])
|
|
16554
|
+
if (/^--(run|into-project)(=|$)/.test(a))
|
|
16555
|
+
throw new SyncFileError(`${a} is not passed to Cairn: plune automate owns the run folder and does not write into the repo.`);
|
|
16556
|
+
const repo = path23.resolve(deps.repo ?? process.cwd());
|
|
16557
|
+
if (!fs18.existsSync(repo) || !fs18.statSync(repo).isDirectory()) throw new SyncFileError(`No directory at ${repo} (--repo).`);
|
|
16558
|
+
const env = deps.env ?? process.env;
|
|
16559
|
+
const command = deps.cairn ?? "cairn";
|
|
16560
|
+
const executable = findExecutable(command, env);
|
|
16561
|
+
if (executable === void 0) throw new CairnMissingError(command);
|
|
16562
|
+
const token = (deps.loadToken ?? loadToken)();
|
|
16563
|
+
if (token === null) throw new NotLoggedInError();
|
|
16564
|
+
const get = platformGet({ ...deps, loadToken: () => token });
|
|
16565
|
+
let detail;
|
|
16566
|
+
try {
|
|
16567
|
+
detail = await get(`/v1/test-cases/${encodeURIComponent(deps.caseId)}`);
|
|
16568
|
+
} catch (err) {
|
|
16569
|
+
if (err instanceof SyncHttpError && err.status === 404) throw new CaseNotFoundError(deps.caseId);
|
|
16570
|
+
throw err;
|
|
16571
|
+
}
|
|
16572
|
+
if (!detail.steps?.length) throw new CaseNotAutomatableError(deps.caseId, detail.type);
|
|
16573
|
+
const tmp = fs18.mkdtempSync(path23.join(os.tmpdir(), "plune-automate-"));
|
|
16574
|
+
try {
|
|
16575
|
+
const runDir = path23.join(tmp, "run");
|
|
16576
|
+
fs18.mkdirSync(path23.join(runDir, "testcases"), { recursive: true });
|
|
16577
|
+
fs18.writeFileSync(path23.join(runDir, "report.json"), JSON.stringify({ url: deps.url ?? "", mode: "design" }, null, 2));
|
|
16578
|
+
fs18.writeFileSync(path23.join(runDir, "testcases", "ATC-PLUNE-001.md"), caseToAtcMarkdown(detail));
|
|
16579
|
+
const dotenvSource = env["DOTENV_PATH"] ?? env["DOTENV_CONFIG_PATH"] ?? path23.join(repo, ".env");
|
|
16580
|
+
const dotenvCopy = path23.join(tmp, "cairn.env");
|
|
16581
|
+
fs18.writeFileSync(dotenvCopy, fs18.existsSync(dotenvSource) ? filteredDotenv(fs18.readFileSync(dotenvSource, "utf8"), token) : "");
|
|
16582
|
+
const childEnv = { ...cairnEnv(env, token), DOTENV_PATH: dotenvCopy, DOTENV_CONFIG_PATH: dotenvCopy };
|
|
16583
|
+
const isScript = /\.[cm]?js$/i.test(executable);
|
|
16584
|
+
const viaShell = process.platform === "win32" && /\.(cmd|bat)$/i.test(executable);
|
|
16585
|
+
const quoted = (s) => `"${s.replace(/"/g, '""')}"`;
|
|
16586
|
+
const spawnImpl = deps.spawnImpl ?? import_node_child_process5.spawn;
|
|
16587
|
+
const runCairn = (args, capture) => new Promise((resolve20) => {
|
|
16588
|
+
const opts = { cwd: repo, env: childEnv, stdio: ["ignore", capture ? "pipe" : 2, 2] };
|
|
16589
|
+
const child = isScript ? spawnImpl(process.execPath, [executable, ...args], opts) : viaShell ? spawnImpl([executable, ...args].map(quoted).join(" "), { ...opts, shell: true }) : spawnImpl(executable, args, opts);
|
|
16590
|
+
let out = "";
|
|
16591
|
+
child.stdout?.on("data", (chunk2) => void (out += chunk2.toString("utf8")));
|
|
16592
|
+
child.on("close", (exitCode2) => resolve20({ code: exitCode2 ?? 1, out }));
|
|
16593
|
+
child.on("error", () => resolve20({ code: -1, out }));
|
|
16594
|
+
});
|
|
16595
|
+
const { code } = await runCairn(["automate", "--run", runDir, ...deps.cairnArgs ?? []], false);
|
|
16596
|
+
if (code === -1) throw new CairnMissingError(command);
|
|
16597
|
+
if (code !== 0) throw new CairnFailedError(code);
|
|
16598
|
+
const testsDir = path23.join(runDir, "tests");
|
|
16599
|
+
const files = filesUnder(testsDir).map((p) => ({ path: p, content: fs18.readFileSync(path23.join(testsDir, p), "utf8") }));
|
|
16600
|
+
if (files.length === 0) throw new CairnProducedNothingError();
|
|
16601
|
+
const result2 = { case: detail, files, diff: newFilesDiff(files) };
|
|
16602
|
+
if (!deps.withCairnVersion) return result2;
|
|
16603
|
+
const v = await runCairn(["--version"], true);
|
|
16604
|
+
const cairnVersion = (v.code === 0 ? /\d+\.\d+[\w.+-]*/.exec(v.out)?.[0] : void 0) ?? "unknown";
|
|
16605
|
+
return { ...result2, cairnVersion: cairnVersion.slice(0, AUTOMATION_ORIGIN_MAX) };
|
|
16606
|
+
} finally {
|
|
16607
|
+
fs18.rmSync(tmp, { recursive: true, force: true });
|
|
16608
|
+
}
|
|
16609
|
+
}
|
|
16610
|
+
function skipNonCode(s, i, prev) {
|
|
16611
|
+
const c = s[i];
|
|
16612
|
+
const d = s[i + 1];
|
|
16613
|
+
if (c === "/" && d === "/") {
|
|
16614
|
+
const e = s.indexOf("\n", i);
|
|
16615
|
+
return e === -1 ? s.length : e;
|
|
16616
|
+
}
|
|
16617
|
+
if (c === "/" && d === "*") {
|
|
16618
|
+
const e = s.indexOf("*/", i + 2);
|
|
16619
|
+
return e === -1 ? s.length : e + 2;
|
|
16620
|
+
}
|
|
16621
|
+
if (c === '"' || c === "'") {
|
|
16622
|
+
let j = i + 1;
|
|
16623
|
+
while (j < s.length && s[j] !== c && s[j] !== "\n") j += s[j] === "\\" ? 2 : 1;
|
|
16624
|
+
return j + 1;
|
|
16625
|
+
}
|
|
16626
|
+
if (c === "`") {
|
|
16627
|
+
let j = i + 1;
|
|
16628
|
+
while (j < s.length && s[j] !== "`") {
|
|
16629
|
+
if (s[j] === "\\") j += 2;
|
|
16630
|
+
else if (s[j] === "$" && s[j + 1] === "{") j = closeOf(s, j + 2, "{", "}");
|
|
16631
|
+
else j++;
|
|
16632
|
+
}
|
|
16633
|
+
return j + 1;
|
|
16634
|
+
}
|
|
16635
|
+
if (c === "/" && REGEX_AFTER.has(prev)) {
|
|
16636
|
+
let j = i + 1;
|
|
16637
|
+
let inClass = false;
|
|
16638
|
+
while (j < s.length && s[j] !== "\n" && (s[j] !== "/" || inClass)) {
|
|
16639
|
+
if (s[j] === "\\") j++;
|
|
16640
|
+
else if (s[j] === "[") inClass = true;
|
|
16641
|
+
else if (s[j] === "]") inClass = false;
|
|
16642
|
+
j++;
|
|
16643
|
+
}
|
|
16644
|
+
j++;
|
|
16645
|
+
while (/[a-z]/i.test(s[j] ?? "")) j++;
|
|
16646
|
+
return j;
|
|
16647
|
+
}
|
|
16648
|
+
return i;
|
|
16649
|
+
}
|
|
16650
|
+
function closeOf(s, i, open2, close) {
|
|
16651
|
+
let depth = 1;
|
|
16652
|
+
let prev = open2;
|
|
16653
|
+
while (i < s.length) {
|
|
16654
|
+
const j = skipNonCode(s, i, prev);
|
|
16655
|
+
if (j !== i) {
|
|
16656
|
+
i = j;
|
|
16657
|
+
prev = ")";
|
|
16658
|
+
continue;
|
|
16659
|
+
}
|
|
16660
|
+
const c = s[i];
|
|
16661
|
+
if (c === open2) depth++;
|
|
16662
|
+
else if (c === close && --depth === 0) return i + 1;
|
|
16663
|
+
if (!/\s/.test(c)) prev = c;
|
|
16664
|
+
i++;
|
|
16665
|
+
}
|
|
16666
|
+
return s.length;
|
|
16667
|
+
}
|
|
16668
|
+
function findTestCall(src) {
|
|
16669
|
+
const head = /test(?:\.(?:skip|only|fixme|fail))?\s*\(/y;
|
|
16670
|
+
let prev = "";
|
|
16671
|
+
for (let i = 0; i < src.length; ) {
|
|
16672
|
+
const j = skipNonCode(src, i, prev);
|
|
16673
|
+
if (j !== i) {
|
|
16674
|
+
i = j;
|
|
16675
|
+
prev = ")";
|
|
16676
|
+
continue;
|
|
16677
|
+
}
|
|
16678
|
+
head.lastIndex = i;
|
|
16679
|
+
if (!/[\w$.]/.test(src[i - 1] ?? "") && head.test(src)) {
|
|
16680
|
+
const end = closeOf(src, head.lastIndex, "(", ")");
|
|
16681
|
+
const text4 = src.slice(i, end);
|
|
16682
|
+
if (/\}\s*,?\s*\)$/.test(text4)) return { text: text4, line: src.slice(0, i).split("\n").length };
|
|
16683
|
+
i = end;
|
|
16684
|
+
prev = ")";
|
|
16685
|
+
continue;
|
|
16686
|
+
}
|
|
16687
|
+
if (!/\s/.test(src[i])) prev = src[i];
|
|
16688
|
+
i++;
|
|
16689
|
+
}
|
|
16690
|
+
return void 0;
|
|
16691
|
+
}
|
|
16692
|
+
function automationProposal(out, cliVersion) {
|
|
16693
|
+
const files = out.files.map((f) => ({ path: `tests/${f.path}`, content: f.content }));
|
|
16694
|
+
const problems = [];
|
|
16695
|
+
if (files.length > AUTOMATION_FILES_MAX) problems.push(`${files.length} files, at most ${AUTOMATION_FILES_MAX}`);
|
|
16696
|
+
for (const f of files) {
|
|
16697
|
+
if (f.path.length > AUTOMATION_PATH_MAX) problems.push(`${f.path}: a path of ${f.path.length} characters, at most ${AUTOMATION_PATH_MAX}`);
|
|
16698
|
+
const bytes = bytesOf(f.content);
|
|
16699
|
+
if (bytes > AUTOMATION_FILE_MAX_BYTES) problems.push(`${f.path}: ${bytes} bytes, at most ${AUTOMATION_FILE_MAX_BYTES} a file`);
|
|
16700
|
+
}
|
|
16701
|
+
const total = files.reduce((n, f) => n + bytesOf(f.content), 0);
|
|
16702
|
+
if (total > AUTOMATION_TOTAL_MAX_BYTES) problems.push(`${total} bytes in all, at most ${AUTOMATION_TOTAL_MAX_BYTES}`);
|
|
16703
|
+
const specFirst = [...files].sort((a, b) => Number(isSpec(b.path)) - Number(isSpec(a.path)));
|
|
16704
|
+
let found;
|
|
16705
|
+
for (const f of specFirst) {
|
|
16706
|
+
const call2 = findTestCall(f.content);
|
|
16707
|
+
if (call2 !== void 0) {
|
|
16708
|
+
found = { file: f.path, ...call2 };
|
|
16709
|
+
break;
|
|
16710
|
+
}
|
|
16711
|
+
}
|
|
16712
|
+
if (found === void 0) {
|
|
16713
|
+
if (problems.length > 0) throw new ProposalBoundsError(problems);
|
|
16714
|
+
throw new NoTestCallError();
|
|
16715
|
+
}
|
|
16716
|
+
const specRef = `${found.file}:${found.line}`;
|
|
16717
|
+
if (specRef.length > AUTOMATION_PATH_MAX) problems.push(`specRef ${specRef.slice(0, 40)}\u2026: at most ${AUTOMATION_PATH_MAX} characters`);
|
|
16718
|
+
if (problems.length > 0) throw new ProposalBoundsError(problems);
|
|
16719
|
+
return {
|
|
16720
|
+
testCaseId: out.case.id,
|
|
16721
|
+
caseFile: found.file,
|
|
16722
|
+
snapshot: found.text,
|
|
16723
|
+
specRef,
|
|
16724
|
+
files,
|
|
16725
|
+
...out.case.codeSnapshotHash === void 0 ? {} : { baseHash: out.case.codeSnapshotHash },
|
|
16726
|
+
origin: { tool: "cairn", version: out.cairnVersion ?? "unknown", cliVersion: cliVersion.slice(0, AUTOMATION_ORIGIN_MAX) }
|
|
16727
|
+
};
|
|
16728
|
+
}
|
|
16729
|
+
async function sendAutomation(input, deps = {}) {
|
|
16730
|
+
const apiUrl = resolveApiUrl(deps.apiUrl);
|
|
16731
|
+
const token = (deps.loadToken ?? loadToken)();
|
|
16732
|
+
if (token === null) throw new NotLoggedInError();
|
|
16733
|
+
let res;
|
|
16734
|
+
try {
|
|
16735
|
+
res = await (deps.fetchImpl ?? fetch)(`${apiUrl}/v1/review-items/automations`, {
|
|
16736
|
+
method: "POST",
|
|
16737
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${token}` },
|
|
16738
|
+
body: JSON.stringify(input)
|
|
16739
|
+
});
|
|
16740
|
+
} catch {
|
|
16741
|
+
throw new SyncNetworkError(apiUrl);
|
|
16742
|
+
}
|
|
16743
|
+
const body = await res.json().catch(() => ({}));
|
|
16744
|
+
if (res.status === 401) throw new TokenRejectedError();
|
|
16745
|
+
if (!res.ok) {
|
|
16746
|
+
throw new ProposalRefusedError(
|
|
16747
|
+
res.status,
|
|
16748
|
+
typeof body.code === "string" ? body.code : void 0,
|
|
16749
|
+
typeof body.error === "string" ? body.error : ""
|
|
16750
|
+
);
|
|
16751
|
+
}
|
|
16752
|
+
return { id: String(body.id ?? ""), replaced: res.status === 200, revision: body.revision ?? 1, refused: body.automation?.refused ?? [] };
|
|
16753
|
+
}
|
|
16754
|
+
function formatSent(sent, title) {
|
|
16755
|
+
const head = sent.replaced ? `Replaced the proposal waiting for '${title}': review item ${sent.id}, now revision ${sent.revision}.` : `Queued a new proposal for '${title}': review item ${sent.id}.`;
|
|
16756
|
+
const refused = sent.refused.map((r) => ` not kept by the server: ${r.path} (${r.bytes} bytes, ${r.reason})`);
|
|
16757
|
+
return [head, ...refused].join("\n") + "\n";
|
|
16758
|
+
}
|
|
16759
|
+
function reportAutomateFailure(err, write) {
|
|
16760
|
+
if (err instanceof CairnMissingError || err instanceof CaseNotFoundError || err instanceof CaseNotAutomatableError || err instanceof ProposalBoundsError) {
|
|
16761
|
+
write(err.message + "\n");
|
|
16762
|
+
return 2;
|
|
16763
|
+
}
|
|
16764
|
+
if (err instanceof CairnFailedError || err instanceof CairnProducedNothingError || err instanceof NoTestCallError || err instanceof ProposalRefusedError) {
|
|
16765
|
+
write(err.message + "\n");
|
|
16766
|
+
return 1;
|
|
16767
|
+
}
|
|
16768
|
+
return reportCasesFailure(err, write);
|
|
16769
|
+
}
|
|
16770
|
+
var import_node_child_process5, fs18, os, path23, CairnMissingError, CaseNotFoundError, CaseNotAutomatableError, CairnFailedError, CairnProducedNothingError, AUTOMATION_FILES_MAX, AUTOMATION_FILE_MAX_BYTES, AUTOMATION_TOTAL_MAX_BYTES, AUTOMATION_PATH_MAX, AUTOMATION_ORIGIN_MAX, ProposalBoundsError, NoTestCallError, ProposalRefusedError, flat3, REGEX_AFTER, bytesOf, isSpec;
|
|
16771
|
+
var init_automate = __esm({
|
|
16772
|
+
"src/cli/commands/automate.ts"() {
|
|
16773
|
+
"use strict";
|
|
16774
|
+
init_cjs_shims();
|
|
16775
|
+
import_node_child_process5 = require("child_process");
|
|
16776
|
+
fs18 = __toESM(require("fs"), 1);
|
|
16777
|
+
os = __toESM(require("os"), 1);
|
|
16778
|
+
path23 = __toESM(require("path"), 1);
|
|
16779
|
+
init_api_url();
|
|
16780
|
+
init_credentials();
|
|
16781
|
+
init_plan();
|
|
16782
|
+
init_sync();
|
|
16783
|
+
init_cases();
|
|
16784
|
+
CairnMissingError = class extends Error {
|
|
16785
|
+
constructor(command) {
|
|
16786
|
+
super(
|
|
16787
|
+
`Cairn not found: ${command}. Install Cairn, or pass the path to its executable with --cairn.`
|
|
16788
|
+
);
|
|
16789
|
+
this.name = "CairnMissingError";
|
|
16790
|
+
}
|
|
16791
|
+
};
|
|
16792
|
+
CaseNotFoundError = class extends Error {
|
|
16793
|
+
constructor(id2) {
|
|
16794
|
+
super(`Case '${id2}' not found \u2014 check the id, or whether the token belongs to the case's project.`);
|
|
16795
|
+
this.name = "CaseNotFoundError";
|
|
16796
|
+
}
|
|
16797
|
+
};
|
|
16798
|
+
CaseNotAutomatableError = class extends Error {
|
|
16799
|
+
constructor(id2, type) {
|
|
16800
|
+
super(`Case '${id2}' (${type}) has no steps: Cairn writes code from a case's steps.`);
|
|
16801
|
+
this.name = "CaseNotAutomatableError";
|
|
16802
|
+
}
|
|
16803
|
+
};
|
|
16804
|
+
CairnFailedError = class extends Error {
|
|
16805
|
+
constructor(code) {
|
|
16806
|
+
super(`Cairn exited with code ${code}; its output is above.`);
|
|
16807
|
+
this.name = "CairnFailedError";
|
|
16808
|
+
}
|
|
16809
|
+
};
|
|
16810
|
+
CairnProducedNothingError = class extends Error {
|
|
16811
|
+
constructor() {
|
|
16812
|
+
super("Cairn finished but wrote no test file \u2014 nothing to propose.");
|
|
16813
|
+
this.name = "CairnProducedNothingError";
|
|
16814
|
+
}
|
|
16815
|
+
};
|
|
16816
|
+
AUTOMATION_FILES_MAX = 10;
|
|
16817
|
+
AUTOMATION_FILE_MAX_BYTES = 16384;
|
|
16818
|
+
AUTOMATION_TOTAL_MAX_BYTES = 65536;
|
|
16819
|
+
AUTOMATION_PATH_MAX = 400;
|
|
16820
|
+
AUTOMATION_ORIGIN_MAX = 32;
|
|
16821
|
+
ProposalBoundsError = class extends Error {
|
|
16822
|
+
constructor(problems) {
|
|
16823
|
+
super(`Not sent: the proposal is over the review queue's bounds \u2014
|
|
16824
|
+
${problems.map((p) => ` ${p}`).join("\n")}
|
|
16825
|
+
The diff above is complete; apply it yourself, or have Cairn write less.`);
|
|
16826
|
+
this.problems = problems;
|
|
16827
|
+
this.name = "ProposalBoundsError";
|
|
16828
|
+
}
|
|
16829
|
+
problems;
|
|
16830
|
+
};
|
|
16831
|
+
NoTestCallError = class extends Error {
|
|
16832
|
+
constructor() {
|
|
16833
|
+
super("Not sent: none of Cairn's files has a test() call to name as the case's code.");
|
|
16834
|
+
this.name = "NoTestCallError";
|
|
16835
|
+
}
|
|
16836
|
+
};
|
|
16837
|
+
ProposalRefusedError = class extends Error {
|
|
16838
|
+
constructor(status, code, detail) {
|
|
16839
|
+
super(`The platform refused the proposal \u2014 HTTP ${status}${code ? ` ${code}` : ""}${detail ? `: ${detail}` : ""}.`);
|
|
16840
|
+
this.status = status;
|
|
16841
|
+
this.code = code;
|
|
16842
|
+
this.name = "ProposalRefusedError";
|
|
16843
|
+
}
|
|
16844
|
+
status;
|
|
16845
|
+
code;
|
|
16846
|
+
};
|
|
16847
|
+
flat3 = (s) => s.replace(/\s+/g, " ").trim();
|
|
16848
|
+
REGEX_AFTER = /* @__PURE__ */ new Set(["", "(", ",", "=", ":", "[", "!", "&", "|", "?", "{", "}", ";", "+", "-", "*", "%", "<", ">", "~", "^"]);
|
|
16849
|
+
bytesOf = (s) => Buffer.byteLength(s, "utf8");
|
|
16850
|
+
isSpec = (p) => /\.(spec|test)\.[cm]?[jt]sx?$/.test(p);
|
|
16851
|
+
}
|
|
16852
|
+
});
|
|
16853
|
+
|
|
16341
16854
|
// src/cli/commands/ids.ts
|
|
16342
16855
|
var ids_exports = {};
|
|
16343
16856
|
__export(ids_exports, {
|
|
@@ -16886,10 +17399,10 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
16886
17399
|
const { handleLogin: handleLogin2, reportLoginFailure: reportLoginFailure2 } = await Promise.resolve().then(() => (init_login(), login_exports));
|
|
16887
17400
|
try {
|
|
16888
17401
|
const token = options.token ?? await readTokenFromStdin();
|
|
16889
|
-
const { path:
|
|
17402
|
+
const { path: path24, verified } = await handleLogin2({ token, skipVerify: options.skipVerify });
|
|
16890
17403
|
process.stdout.write(
|
|
16891
|
-
verified ? `Logged in. Token checked against the API and saved to ${
|
|
16892
|
-
` : `Token saved to ${
|
|
17404
|
+
verified ? `Logged in. Token checked against the API and saved to ${path24}
|
|
17405
|
+
` : `Token saved to ${path24} WITHOUT being checked (--skip-verify).
|
|
16893
17406
|
`
|
|
16894
17407
|
);
|
|
16895
17408
|
} catch (err) {
|
|
@@ -16906,9 +17419,9 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
16906
17419
|
const verbose = command.optsWithGlobals().verbose === true;
|
|
16907
17420
|
const { handleLogout: handleLogout2 } = await Promise.resolve().then(() => (init_logout(), logout_exports));
|
|
16908
17421
|
try {
|
|
16909
|
-
const { removed, path:
|
|
17422
|
+
const { removed, path: path24 } = handleLogout2();
|
|
16910
17423
|
process.stdout.write(
|
|
16911
|
-
removed ? `Logged out. Removed ${
|
|
17424
|
+
removed ? `Logged out. Removed ${path24}
|
|
16912
17425
|
` : "Not logged in \u2014 nothing to remove.\n"
|
|
16913
17426
|
);
|
|
16914
17427
|
} catch (err) {
|
|
@@ -17251,6 +17764,41 @@ ${missed.map((m) => ` - ${m}`).join("\n")}
|
|
|
17251
17764
|
}
|
|
17252
17765
|
}
|
|
17253
17766
|
);
|
|
17767
|
+
program.command("automate").argument("<caseId>", "The case to automate: its id in Plune").argument("[cairnArgs...]", "Passed to `cairn automate`, after `--` (for example -- --validate --session myapp)").description(
|
|
17768
|
+
"Run Cairn's `automate` on a case from Plune and print the code it wrote as a diff \u2014 the repo is not touched"
|
|
17769
|
+
).option("--repo <dir>", "Where Cairn runs (its .env, knowledge/ and .auth/); default: the current directory").option("--cairn <path>", "Cairn's executable, or its .js entry point (default: cairn on PATH)").option("--url <url>", "The app's address, which the case does not carry").option("--send", "Also put the code in the review queue as an automation proposal (POST /v1/review-items/automations)", false).action(
|
|
17770
|
+
async (caseId, cairnArgs, options, command) => {
|
|
17771
|
+
const verbose = verboseOf(command);
|
|
17772
|
+
const { handleAutomate: handleAutomate2, reportAutomateFailure: reportAutomateFailure2, automationProposal: automationProposal2, sendAutomation: sendAutomation2, formatSent: formatSent2 } = await Promise.resolve().then(() => (init_automate(), automate_exports));
|
|
17773
|
+
try {
|
|
17774
|
+
const out = await handleAutomate2({
|
|
17775
|
+
caseId,
|
|
17776
|
+
cairnArgs,
|
|
17777
|
+
...options.repo === void 0 ? {} : { repo: options.repo },
|
|
17778
|
+
...options.cairn === void 0 ? {} : { cairn: options.cairn },
|
|
17779
|
+
...options.url === void 0 ? {} : { url: options.url },
|
|
17780
|
+
withCairnVersion: options.send
|
|
17781
|
+
});
|
|
17782
|
+
process.stdout.write(out.diff);
|
|
17783
|
+
process.stderr.write(`${out.files.length} file(s) from Cairn for '${out.case.title}'.
|
|
17784
|
+
`);
|
|
17785
|
+
if (!options.send) {
|
|
17786
|
+
process.stderr.write("Not queued: pass --send to put it in the review queue.\n");
|
|
17787
|
+
return;
|
|
17788
|
+
}
|
|
17789
|
+
const sent = await sendAutomation2(automationProposal2(out, pkg.version));
|
|
17790
|
+
process.stderr.write(formatSent2(sent, out.case.title));
|
|
17791
|
+
} catch (err) {
|
|
17792
|
+
const code = reportAutomateFailure2(err, (s) => process.stderr.write(s));
|
|
17793
|
+
if (code !== null) {
|
|
17794
|
+
maybeStack(err, verbose);
|
|
17795
|
+
process.exitCode = code;
|
|
17796
|
+
return;
|
|
17797
|
+
}
|
|
17798
|
+
failUnexpected(err, verbose);
|
|
17799
|
+
}
|
|
17800
|
+
}
|
|
17801
|
+
);
|
|
17254
17802
|
program.command("ids").description(
|
|
17255
17803
|
"Write the Plune case id of each Playwright test that names none into plune/ids.json (dry run unless --write); test sources are not touched"
|
|
17256
17804
|
).option("--write", "Write the file; without it only shows what would be written", false).option("--file <path>", "The mapfile", "plune/ids.json").option("--from <file>", "A saved `playwright test --list --reporter=json` document instead of running Playwright").option("--playwright-config <path>", "Passed to `playwright test --config`").option("--json", "Print the report as JSON", false).action(
|