bpmax-cli 0.2.1-beta.11 → 0.2.1-beta.14

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/bin.js CHANGED
@@ -469,7 +469,7 @@ function pluginAgentCapabilityForRequest(method, normalizedPath) {
469
469
  // package.json
470
470
  var package_default = {
471
471
  name: "bpmax-cli",
472
- version: "0.2.1-beta.11",
472
+ version: "0.2.1-beta.14",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -12970,6 +12970,156 @@ function registerInitCommand(program2, deps = {}) {
12970
12970
  });
12971
12971
  }
12972
12972
 
12973
+ // src/commands/issue.ts
12974
+ import { readFile as readFile12 } from "fs/promises";
12975
+
12976
+ // src/core/issues.ts
12977
+ import axios7, { AxiosHeaders as AxiosHeaders3 } from "axios";
12978
+ var DEFAULT_GITLAB_URL = "https://gitlab.yitaiyitai.com";
12979
+ var DEFAULT_GITLAB_PROJECT = "bpmax/bpmax-cli";
12980
+ function normalizeBaseUrl2(baseUrl = DEFAULT_GITLAB_URL) {
12981
+ const normalized = baseUrl.trim().replace(/\/+$/g, "");
12982
+ if (!normalized) {
12983
+ throw new Error("GitLab base URL is required.");
12984
+ }
12985
+ return normalized;
12986
+ }
12987
+ function normalizeGitLabProject(project = DEFAULT_GITLAB_PROJECT) {
12988
+ const normalized = project.trim().replace(/^\/+|\/+$/g, "");
12989
+ if (!normalized) {
12990
+ throw new Error("GitLab project is required.");
12991
+ }
12992
+ return normalized;
12993
+ }
12994
+ function gitLabProjectApiPath(project = DEFAULT_GITLAB_PROJECT) {
12995
+ return encodeURIComponent(normalizeGitLabProject(project));
12996
+ }
12997
+ function buildGitLabIssuePayload(input) {
12998
+ const title = input.title.trim();
12999
+ if (!title) {
13000
+ throw new Error("Issue title is required.");
13001
+ }
13002
+ const description = input.description?.trim();
13003
+ const labels = (input.labels || []).map((label) => label.trim()).filter(Boolean);
13004
+ const assigneeIds = (input.assigneeIds || []).filter((id) => Number.isInteger(id) && id > 0);
13005
+ return {
13006
+ title,
13007
+ ...description ? { description } : {},
13008
+ ...labels.length > 0 ? { labels: labels.join(",") } : {},
13009
+ ...assigneeIds.length > 0 ? { assignee_ids: assigneeIds } : {},
13010
+ ...input.confidential !== void 0 ? { confidential: input.confidential } : {}
13011
+ };
13012
+ }
13013
+ function resolveGitLabToken(options) {
13014
+ const env = options.env || process.env;
13015
+ const candidates = [
13016
+ options.tokenEnv ? env[options.tokenEnv] : void 0,
13017
+ env.GITLAB_TOKEN,
13018
+ env.GL_TOKEN,
13019
+ env.PRIVATE_TOKEN,
13020
+ "-1pFevGtvjq4fXSxzZJQ"
13021
+ ];
13022
+ const token = candidates.find((candidate) => candidate?.trim());
13023
+ if (!token) {
13024
+ const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
13025
+ throw new Error(`GitLab token is required. Set ${envHint}.`);
13026
+ }
13027
+ return token.trim();
13028
+ }
13029
+ async function createGitLabIssue(input, options) {
13030
+ const token = options.token.trim();
13031
+ if (!token) {
13032
+ throw new Error("GitLab token is required.");
13033
+ }
13034
+ const baseUrl = normalizeBaseUrl2(options.baseUrl);
13035
+ const projectPath = gitLabProjectApiPath(options.project);
13036
+ const client = options.client || axios7.create({ baseURL: baseUrl });
13037
+ const headers = AxiosHeaders3.from();
13038
+ headers.set("PRIVATE-TOKEN", token);
13039
+ const response = await client.request({
13040
+ method: "POST",
13041
+ url: `/api/v4/projects/${projectPath}/issues`,
13042
+ headers,
13043
+ data: buildGitLabIssuePayload(input)
13044
+ });
13045
+ return response.data;
13046
+ }
13047
+
13048
+ // src/commands/issue.ts
13049
+ async function readDescription(options) {
13050
+ if (options.descriptionFile && options.description) {
13051
+ throw new Error("Use either --description or --description-file, not both.");
13052
+ }
13053
+ if (!options.descriptionFile) {
13054
+ return options.description;
13055
+ }
13056
+ return readFile12(options.descriptionFile, "utf8");
13057
+ }
13058
+ function parseAssigneeIds(values) {
13059
+ return (values || []).flatMap(
13060
+ (value) => value.split(",").map((part) => {
13061
+ const parsed = Number(part.trim());
13062
+ if (!Number.isInteger(parsed) || parsed <= 0) {
13063
+ throw new Error(`Invalid assignee id: ${part}`);
13064
+ }
13065
+ return parsed;
13066
+ })
13067
+ );
13068
+ }
13069
+ async function buildIssueInput(options) {
13070
+ return {
13071
+ title: options.title,
13072
+ description: await readDescription(options),
13073
+ labels: options.label || [],
13074
+ assigneeIds: parseAssigneeIds(options.assigneeId),
13075
+ confidential: options.confidential
13076
+ };
13077
+ }
13078
+ function prettyCreatedIssue(issue3) {
13079
+ return issue3.web_url;
13080
+ }
13081
+ function registerIssueCommands(program2, deps = {}) {
13082
+ const createIssue = deps.createIssue || createGitLabIssue;
13083
+ const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
13084
+ const registerCreateLike = (name) => {
13085
+ issue3.command(name).description(name === "create" ? "Create a GitLab issue" : "Report a bug as a GitLab issue").requiredOption("--title <title>", "Issue title").option("--description <text>", "Issue description").option("--description-file <file>", "Read issue description from a file").option("--label <label>", "Issue label, repeatable", (value, previous = []) => [...previous, value], []).option("--assignee-id <id>", "GitLab assignee id, repeatable or comma-separated", (value, previous = []) => [...previous, value], []).option("--confidential", "Create a confidential issue").option("--gitlab-url <url>", "GitLab base URL", DEFAULT_GITLAB_URL).option("--project <path>", "GitLab project path or id", DEFAULT_GITLAB_PROJECT).option("--token-env <name>", "Environment variable name that contains the GitLab token").option("--dry-run", "Print the GitLab issue payload without submitting").option("--format <format>", "Output format", "pretty").action(async (options) => {
13086
+ const input = await buildIssueInput(options);
13087
+ const payload = buildGitLabIssuePayload(input);
13088
+ const project = options.project || DEFAULT_GITLAB_PROJECT;
13089
+ const gitlabUrl = options.gitlabUrl || DEFAULT_GITLAB_URL;
13090
+ if (options.dryRun) {
13091
+ printResult(options.format, {
13092
+ ok: true,
13093
+ dry_run: true,
13094
+ gitlab_url: gitlabUrl,
13095
+ project,
13096
+ payload
13097
+ });
13098
+ return;
13099
+ }
13100
+ const token = resolveGitLabToken({
13101
+ tokenEnv: options.tokenEnv,
13102
+ env: deps.env
13103
+ });
13104
+ const created = await createIssue(input, {
13105
+ baseUrl: gitlabUrl,
13106
+ project,
13107
+ token
13108
+ });
13109
+ if (options.format === "pretty") {
13110
+ printResult("pretty", prettyCreatedIssue(created));
13111
+ return;
13112
+ }
13113
+ printResult(options.format, {
13114
+ ok: true,
13115
+ issue: created
13116
+ });
13117
+ });
13118
+ };
13119
+ registerCreateLike("create");
13120
+ registerCreateLike("report");
13121
+ }
13122
+
12973
13123
  // src/commands/memory.ts
12974
13124
  function parseLimit(input, fallback) {
12975
13125
  const value = Number(input ?? fallback);
@@ -13050,7 +13200,7 @@ function registerMemoryCommands(program2) {
13050
13200
  }
13051
13201
 
13052
13202
  // src/commands/matrix.ts
13053
- import { readFile as readFile12 } from "fs/promises";
13203
+ import { readFile as readFile13 } from "fs/promises";
13054
13204
  var UUID_VALUE_PATTERN2 = /\b[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\b/i;
13055
13205
  var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
13056
13206
  async function parseSeedRules(input) {
@@ -13058,7 +13208,7 @@ async function parseSeedRules(input) {
13058
13208
  if (source === "") {
13059
13209
  throw new Error("--rules file path is empty.");
13060
13210
  }
13061
- const raw = source ? await readFile12(source, "utf8") : input;
13211
+ const raw = source ? await readFile13(source, "utf8") : input;
13062
13212
  let parsed;
13063
13213
  try {
13064
13214
  parsed = JSON.parse(raw);
@@ -14371,7 +14521,7 @@ import { spawn as spawn2 } from "child_process";
14371
14521
  import { fileURLToPath as fileURLToPath3 } from "url";
14372
14522
 
14373
14523
  // src/core/recipes.ts
14374
- import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
14524
+ import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
14375
14525
  import path11 from "path";
14376
14526
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
14377
14527
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
@@ -14453,7 +14603,7 @@ function parseRecipeDefinition(input) {
14453
14603
  };
14454
14604
  }
14455
14605
  async function loadRecipe(recipeDir) {
14456
- const raw = await readFile13(path11.join(recipeDir, "recipe.json"), "utf8");
14606
+ const raw = await readFile14(path11.join(recipeDir, "recipe.json"), "utf8");
14457
14607
  return parseRecipeDefinition(JSON.parse(raw));
14458
14608
  }
14459
14609
  async function listRecipes(recipesDir) {
@@ -14552,7 +14702,7 @@ async function renderArgv(options) {
14552
14702
  const rendered = [];
14553
14703
  for (const token of options.recipe.command.argv) {
14554
14704
  if (token.startsWith("@")) {
14555
- const raw = await readFile13(resolveRecipeFile(options.recipeDir, token), "utf8");
14705
+ const raw = await readFile14(resolveRecipeFile(options.recipeDir, token), "utf8");
14556
14706
  rendered.push(renderTemplate(raw, options.variables));
14557
14707
  } else {
14558
14708
  rendered.push(renderTemplate(token, options.variables));
@@ -15010,7 +15160,7 @@ function registerSetupCommand(program2, deps = {}) {
15010
15160
  }
15011
15161
 
15012
15162
  // src/core/taskbook.ts
15013
- import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
15163
+ import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
15014
15164
  import path12 from "path";
15015
15165
  var TaskbookError = class extends Error {
15016
15166
  };
@@ -15218,7 +15368,7 @@ function addUuidIssues(text5, issues, path15) {
15218
15368
  }
15219
15369
  }
15220
15370
  async function readTaskbookText(file) {
15221
- const raw = await readFile14(file, "utf8");
15371
+ const raw = await readFile15(file, "utf8");
15222
15372
  try {
15223
15373
  const parsed = JSON.parse(raw);
15224
15374
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -15868,7 +16018,7 @@ import {
15868
16018
  cp as cp3,
15869
16019
  mkdir as mkdir12,
15870
16020
  readdir as readdir5,
15871
- readFile as readFile15,
16021
+ readFile as readFile16,
15872
16022
  rm as rm4,
15873
16023
  stat as stat6,
15874
16024
  writeFile as writeFile12
@@ -15926,7 +16076,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
15926
16076
  ".codex/skills/"
15927
16077
  ];
15928
16078
  var REPORT_REQUIRED_KEYS = ["run_id:", "scenario_id:", "source_suite:", "result:"];
15929
- var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "browser_tool:"];
16079
+ var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "report_run:", "browser_tool:", "rerun_policy:"];
15930
16080
  var REPORT_REQUIRED_HEADINGS = [
15931
16081
  "## 1. \u6D4B\u8BD5\u8303\u56F4",
15932
16082
  "## 2. \u6267\u884C\u73AF\u5883",
@@ -15964,7 +16114,13 @@ var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript|browser_
15964
16114
  var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
15965
16115
  var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
15966
16116
  var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
16117
+ var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
16118
+ var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
16119
+ var RUN_MARKER_RE = /\b\d{8}(?:-\d{3})?\b/g;
15967
16120
  var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
16121
+ var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
16122
+ var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
16123
+ var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
15968
16124
  var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
15969
16125
  var TestSuiteError = class extends Error {
15970
16126
  code;
@@ -15988,7 +16144,7 @@ async function exists3(filePath) {
15988
16144
  }
15989
16145
  }
15990
16146
  async function readText(filePath) {
15991
- return readFile15(filePath, "utf8");
16147
+ return readFile16(filePath, "utf8");
15992
16148
  }
15993
16149
  function fail(message, options = {}) {
15994
16150
  throw new TestSuiteError(message, options);
@@ -16266,6 +16422,20 @@ function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
16266
16422
  if (!prepTokens.state_file && !prepTokens.report_run) {
16267
16423
  fail(`${filePath}:${caseId}: E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E .codex/tmp/e2e_states \u72B6\u6001\u6587\u4EF6\u6216 .ai_test/report/<run> \u62A5\u544A\u8BC1\u636E\u8DEF\u5F84`, { rule_id: "test_suite.case.state_file" });
16268
16424
  }
16425
+ const policy = prepTokens.resume_policy;
16426
+ if (!policy || !RESUME_POLICY_VALUE_RE.test(policy)) {
16427
+ fail(`${filePath}:${caseId}: \u6B63\u5F0F E2E \u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\`\uFF1B\u9ED8\u8BA4\u91CD\u65B0\u8FD0\u884C\u5FC5\u987B\u4F7F\u7528 full_rerun`, { rule_id: "test_suite.case.resume_policy_required" });
16428
+ }
16429
+ if (policy && PARTIAL_RERUN_RE.test(policy) && !/(边界|范围|局部|检查点|仅补证据|用户确认|只验证|scope|boundary|confirmed)/i.test([row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" "))) {
16430
+ fail(`${filePath}:${caseId}: checkpoint/evidence_only \u5FC5\u987B\u5199\u6E05\u5C40\u90E8\u8FB9\u754C\uFF0C\u5386\u53F2\u8BC1\u636E\u4E0D\u5F97\u4F5C\u4E3A\u672C\u8F6E\u901A\u8FC7\u7ED3\u8BBA`, { rule_id: "test_suite.case.resume_policy_boundary" });
16431
+ }
16432
+ for (const [token, value] of Object.entries({ state_file: prepTokens.state_file, report_run: prepTokens.report_run })) {
16433
+ if (!value) continue;
16434
+ const markers = reportRunMarkers(value).filter((marker) => !/<run_id>|<date>|\{run_id\}|\{date\}|\$RUN_ID|\$RUN_DATE/i.test(value));
16435
+ if (markers.length > 0 && !value.includes("<run_id>") && !value.includes("<date>")) {
16436
+ fail(`${filePath}:${caseId}: \`${token}=\` \u4E0D\u5F97\u5199\u6B7B\u5386\u53F2 run/date\uFF1B\u8BF7\u4F7F\u7528\u672C\u8F6E <run_id>/<date> \u6A21\u677F\u6216\u6267\u884C\u65F6\u751F\u6210\u7684\u65B0\u8DEF\u5F84`, { rule_id: "test_suite.case.current_run_template" });
16437
+ }
16438
+ }
16269
16439
  }
16270
16440
  function validateErrorCaptureEvidence(filePath, caseId, row) {
16271
16441
  const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
@@ -16276,8 +16446,9 @@ function validateErrorCaptureEvidence(filePath, caseId, row) {
16276
16446
  }
16277
16447
  }
16278
16448
  function validateResumePolicy(filePath, caseId, row, prepTokens) {
16449
+ const manualText = [row.preconditions, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
16450
+ if (!/(人工介入|手工|补救|续跑|dirty_resumed|局部复核|partial rerun)/i.test(manualText)) return;
16279
16451
  const text5 = [row.preconditions, row.prep_data, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
16280
- if (!/(人工介入|手工|补救|续跑|dirty_resumed|resume|局部复核|partial rerun)/i.test(text5)) return;
16281
16452
  const policy = prepTokens.resume_policy || text5;
16282
16453
  if (!RESUME_POLICY_VALUE_RE.test(policy)) {
16283
16454
  fail(`${filePath}:${caseId}: \u4EBA\u5DE5\u4ECB\u5165\u6216\u7EED\u8DD1\u7528\u4F8B\u5FC5\u987B\u58F0\u660E \`resume_policy=full_rerun|checkpoint|evidence_only\``, { rule_id: "test_suite.case.resume_policy" });
@@ -16514,10 +16685,10 @@ async function fileMap(root) {
16514
16685
  return result;
16515
16686
  }
16516
16687
  async function sha256(filePath) {
16517
- return createHash6("sha256").update(await readFile15(filePath)).digest("hex");
16688
+ return createHash6("sha256").update(await readFile16(filePath)).digest("hex");
16518
16689
  }
16519
16690
  async function readForDiff(filePath) {
16520
- const buffer = await readFile15(filePath);
16691
+ const buffer = await readFile16(filePath);
16521
16692
  if (buffer.includes(0)) return [`<binary sha256=${createHash6("sha256").update(buffer).digest("hex")}>
16522
16693
  `];
16523
16694
  return buffer.toString("utf8").split(/(?<=\n)/);
@@ -16819,7 +16990,22 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
16819
16990
  await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
16820
16991
  await writeFile12(
16821
16992
  path13.join(reportDir, "summary.md"),
16822
- ["# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B", "", `run_id: ${path13.basename(reportDir)}`, "status: draft", "", "## \u573A\u666F\u62A5\u544A", "", "## \u603B\u7ED3", ""].join("\n"),
16993
+ [
16994
+ "# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
16995
+ "",
16996
+ `run_id: ${path13.basename(reportDir)}`,
16997
+ "rerun_policy: full_rerun",
16998
+ "status: draft",
16999
+ "",
17000
+ "## \u573A\u666F\u62A5\u544A",
17001
+ "",
17002
+ "## \u622A\u56FE\u76EE\u5F55",
17003
+ "",
17004
+ `screenshots: ${path13.join(path13.basename(reportDir), "screenshots")}`,
17005
+ "",
17006
+ "## \u603B\u7ED3",
17007
+ ""
17008
+ ].join("\n"),
16823
17009
  "utf8"
16824
17010
  );
16825
17011
  }
@@ -16834,6 +17020,55 @@ function reportCaseList(text5, key) {
16834
17020
  const value = reportKeyValue(text5, key);
16835
17021
  return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
16836
17022
  }
17023
+ function reportRunDate(runName) {
17024
+ return runName.slice(0, 8);
17025
+ }
17026
+ function reportKeyValues(text5, key) {
17027
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17028
+ return [...text5.matchAll(new RegExp(`^${escaped}\\s*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
17029
+ }
17030
+ function reportRunMarkers(value) {
17031
+ return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
17032
+ }
17033
+ function reportContainsHistoricalRun(value, runName) {
17034
+ const runDate = reportRunDate(runName);
17035
+ return reportRunMarkers(value).some((marker) => marker !== runName && marker !== runDate);
17036
+ }
17037
+ function parseReportTime(value) {
17038
+ if (!value.trim()) return null;
17039
+ const date = new Date(value.trim());
17040
+ if (Number.isNaN(date.getTime())) return null;
17041
+ return date;
17042
+ }
17043
+ function reportDayWindow(runName) {
17044
+ const date = reportRunDate(runName);
17045
+ const start = /* @__PURE__ */ new Date(`${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}T00:00:00+08:00`);
17046
+ const end = new Date(start.getTime() + 24 * 60 * 60 * 1e3);
17047
+ return { start, end };
17048
+ }
17049
+ function reportExecutionWindow(runName, text5) {
17050
+ const fallback = reportDayWindow(runName);
17051
+ const startedAt = parseReportTime(reportKeyValue(text5, "started_at:"));
17052
+ const finishedAt = parseReportTime(reportKeyValue(text5, "finished_at:"));
17053
+ if (!startedAt || !finishedAt || finishedAt < startedAt) return fallback;
17054
+ return { start: startedAt, end: finishedAt };
17055
+ }
17056
+ function isWithinWindow(date, window) {
17057
+ return date >= window.start && date <= window.end;
17058
+ }
17059
+ function caseEvidencePattern(caseId) {
17060
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17061
+ return new RegExp(`\\b${escaped}\\b.*?(screenshots/|\\.ai_test/report/|\\.codex/tmp/e2e|evidence|\u622A\u56FE|\u8BC1\u636E|\u9879\u76EE|project|step)`, "i");
17062
+ }
17063
+ function caseResultPattern(caseId) {
17064
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17065
+ return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
17066
+ }
17067
+ function linesForCase(text5, caseId) {
17068
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17069
+ const pattern = new RegExp(`\\b${escaped}\\b`);
17070
+ return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17071
+ }
16837
17072
  async function lintReport(root = DEFAULT_REPORT_ROOT) {
16838
17073
  if (!await exists3(root)) return [`report root not found: ${root}`];
16839
17074
  const errors = [];
@@ -16850,9 +17085,20 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16850
17085
  for (const reportName of scenarioReports) {
16851
17086
  const reportPath = path13.join(runDir, reportName);
16852
17087
  const text5 = await readText(reportPath);
16853
- for (const key of REPORT_REQUIRED_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
16854
- for (const key of REPORT_EXECUTION_KEYS) if (!text5.includes(key)) errors.push(`${reportPath}: missing \`${key}\``);
17088
+ for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
17089
+ for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
16855
17090
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
17091
+ const runId = reportKeyValue(text5, "run_id:");
17092
+ if (runId && runId !== runName) {
17093
+ errors.push(`[test_suite.report.run_id_current] ${reportPath}: run_id \u5FC5\u987B\u7B49\u4E8E\u62A5\u544A\u76EE\u5F55\u540D ${runName}\uFF0C\u4E0D\u80FD\u590D\u7528\u5176\u4ED6 run \u7684\u62A5\u544A\u5934`);
17094
+ }
17095
+ const rerunPolicy = reportKeyValue(text5, "rerun_policy:") || reportKeyValue(text5, "resume_policy:");
17096
+ const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
17097
+ const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
17098
+ const resultValue = reportKeyValue(text5, "result:").toLowerCase();
17099
+ if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
17100
+ errors.push(`[test_suite.report.partial_policy_result] ${reportPath}: checkpoint/evidence_only \u53EA\u80FD\u7ED9\u5C40\u90E8\u6216\u5BF9\u7167\u7ED3\u8BBA\uFF0C\u4E0D\u80FD\u58F0\u660E\u5B8C\u6574\u91CD\u65B0\u8FD0\u884C\u901A\u8FC7`);
17101
+ }
16856
17102
  const plannedCases = reportCaseList(text5, "planned_cases:");
16857
17103
  const executedCases = reportCaseList(text5, "executed_cases:");
16858
17104
  const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
@@ -16863,9 +17109,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16863
17109
  if (unexpectedExecuted.length > 0) {
16864
17110
  errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
16865
17111
  }
16866
- const resultValue = reportKeyValue(text5, "result:").toLowerCase();
16867
- if (NOT_RUN_RE.test(text5) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
16868
- errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage \u6216\u8BF4\u660E\u7528\u6237\u786E\u8BA4\u7F29\u5C0F\u8303\u56F4`);
17112
+ if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
17113
+ errors.push(`[test_suite.report.not_run_downgrade] ${reportPath}: \u62A5\u544A\u5B58\u5728 blocked/not-run/\u672A\u6267\u884C\u7528\u4F8B\u4F46 result \u662F\u5B8C\u6574\u7ED3\u8BBA\uFF1B\u5FC5\u987B\u964D\u7EA7\u4E3A partial/stage/blocked`);
16869
17114
  }
16870
17115
  if (PAGE_CONCLUSION_RE.test(text5) && !BROWSER_TOOL_RE.test(text5)) {
16871
17116
  errors.push(`[test_suite.report.page_conclusion_browser] ${reportPath}: \u9875\u9762/\u6D4F\u89C8\u5668\u7ED3\u8BBA\u5FC5\u987B\u5305\u542B browser_tool \u8BC1\u636E\uFF1BAPI/readback \u4E0D\u80FD\u5192\u5145\u9875\u9762\u9A8C\u8BC1`);
@@ -16873,10 +17118,24 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16873
17118
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
16874
17119
  errors.push(`[test_suite.report.browser_blocked] ${reportPath}: \u6D4F\u89C8\u5668\u963B\u585E\u62A5\u544A\u5FC5\u987B\u4F7F\u7528 browser_status: blocked \u6A21\u677F\uFF0C\u5E76\u505C\u6B62\u9875\u9762\u7ED3\u8BBA`);
16875
17120
  }
16876
- const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
16877
- if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
16878
17121
  const screenshotsDir = path13.join(runDir, "screenshots");
16879
17122
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
17123
+ if (isFullRerun) {
17124
+ for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
17125
+ for (const value of reportKeyValues(text5, key)) {
17126
+ const markers = reportRunMarkers(value);
17127
+ const hasCurrentMarker = markers.some((marker) => marker === runName || marker === reportRunDate(runName));
17128
+ if (!hasCurrentMarker || reportContainsHistoricalRun(value, runName)) {
17129
+ errors.push(`[test_suite.report.current_run_state] ${reportPath}: full_rerun \u7684 ${key} \u5FC5\u987B\u6307\u5411\u672C\u8F6E ${runName} \u6216\u672C\u8F6E\u65E5\u671F ${reportRunDate(runName)}\uFF0C\u4E0D\u80FD\u5F15\u7528\u5386\u53F2\u6216\u65E0 run \u6807\u8BB0\u7684\u72B6\u6001/\u62A5\u544A: ${value}`);
17130
+ }
17131
+ }
17132
+ }
17133
+ }
17134
+ const imageMatches = [...text5.matchAll(IMAGE_RE)];
17135
+ const imageRefs = imageMatches.map((match) => match[1]);
17136
+ if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
17137
+ const validCurrentRunImages = [];
17138
+ const window = reportExecutionWindow(runName, text5);
16880
17139
  for (const imageRef of imageRefs) {
16881
17140
  if (imageRef.includes("://")) {
16882
17141
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
@@ -16888,7 +17147,30 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16888
17147
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
16889
17148
  continue;
16890
17149
  }
16891
- if (!await exists3(imagePath)) errors.push(`${reportPath}: missing image file: ${imageRef}`);
17150
+ if (!await exists3(imagePath)) {
17151
+ errors.push(`${reportPath}: missing image file: ${imageRef}`);
17152
+ continue;
17153
+ }
17154
+ validCurrentRunImages.push(imageRef);
17155
+ if (isFullRerun) {
17156
+ const imageStat = await stat6(imagePath);
17157
+ if (!isWithinWindow(imageStat.mtime, window)) {
17158
+ errors.push(`[test_suite.report.current_run_screenshot] ${reportPath}: full_rerun \u622A\u56FE\u5FC5\u987B\u5728\u672C\u8F6E\u6267\u884C\u65F6\u95F4\u5185\u751F\u6210\uFF0C\u4E0D\u80FD\u590D\u7528\u5386\u53F2\u622A\u56FE: ${imageRef}`);
17159
+ }
17160
+ }
17161
+ }
17162
+ if (isFullRerun) {
17163
+ for (const caseId of executedCases) {
17164
+ const caseLines = linesForCase(text5, caseId);
17165
+ const hasPassResult = caseResultPattern(caseId).test(text5) || caseLines.some((line) => PASS_CASE_RE.test(line));
17166
+ const hasCurrentEvidence = caseEvidencePattern(caseId).test(text5) || validCurrentRunImages.some((imageRef) => imageRef.includes(caseId));
17167
+ if (hasPassResult && caseLines.some((line) => HISTORICAL_EVIDENCE_RE.test(line))) {
17168
+ errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u4E0D\u80FD\u4F7F\u7528\u5386\u53F2/\u65E7\u62A5\u544A/\u65E7\u622A\u56FE\u4F5C\u4E3A\u672C\u8F6E\u8BC1\u636E`);
17169
+ }
17170
+ if (hasPassResult && !hasCurrentEvidence) {
17171
+ errors.push(`[test_suite.report.case_evidence_current_run] ${reportPath}: full_rerun \u4E2D ${caseId} \u7684\u901A\u8FC7\u7ED3\u8BBA\u5FC5\u987B\u6709\u672C\u8F6E\u622A\u56FE\u3001\u9879\u76EE/step \u6216\u8BC1\u636E\u8DEF\u5F84\uFF0C\u4E0D\u80FD\u590D\u7528\u65E7\u7ED3\u679C`);
17172
+ }
17173
+ }
16892
17174
  }
16893
17175
  }
16894
17176
  }
@@ -16958,7 +17240,7 @@ function registerTestSuiteCommands(program2) {
16958
17240
  }
16959
17241
 
16960
17242
  // src/core/update.ts
16961
- import { access as access2, mkdir as mkdir13, readFile as readFile16, realpath, writeFile as writeFile13 } from "fs/promises";
17243
+ import { access as access2, mkdir as mkdir13, readFile as readFile17, realpath, writeFile as writeFile13 } from "fs/promises";
16962
17244
  import path14 from "path";
16963
17245
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
16964
17246
  var UPDATE_STATE_FILE = "update-state.json";
@@ -17075,7 +17357,7 @@ function updateStatePath(configDir = getConfigDir()) {
17075
17357
  }
17076
17358
  async function readUpdateState(configDir) {
17077
17359
  try {
17078
- const raw = await readFile16(updateStatePath(configDir), "utf8");
17360
+ const raw = await readFile17(updateStatePath(configDir), "utf8");
17079
17361
  const parsed = JSON.parse(raw);
17080
17362
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
17081
17363
  return null;
@@ -17614,6 +17896,7 @@ registerSchemaCommands(program);
17614
17896
  registerUserCommands(program);
17615
17897
  registerEsCommands(program);
17616
17898
  registerFlowCommands(program);
17899
+ registerIssueCommands(program);
17617
17900
  registerMemoryCommands(program);
17618
17901
  registerMatrixCommands(program);
17619
17902
  registerPluginCommands(program);