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

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.12",
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,155 @@ 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
+ ];
13021
+ const token = candidates.find((candidate) => candidate?.trim());
13022
+ if (!token) {
13023
+ const envHint = options.tokenEnv ? options.tokenEnv : "GITLAB_TOKEN";
13024
+ throw new Error(`GitLab token is required. Set ${envHint}.`);
13025
+ }
13026
+ return token.trim();
13027
+ }
13028
+ async function createGitLabIssue(input, options) {
13029
+ const token = options.token.trim();
13030
+ if (!token) {
13031
+ throw new Error("GitLab token is required.");
13032
+ }
13033
+ const baseUrl = normalizeBaseUrl2(options.baseUrl);
13034
+ const projectPath = gitLabProjectApiPath(options.project);
13035
+ const client = options.client || axios7.create({ baseURL: baseUrl });
13036
+ const headers = AxiosHeaders3.from();
13037
+ headers.set("PRIVATE-TOKEN", token);
13038
+ const response = await client.request({
13039
+ method: "POST",
13040
+ url: `/api/v4/projects/${projectPath}/issues`,
13041
+ headers,
13042
+ data: buildGitLabIssuePayload(input)
13043
+ });
13044
+ return response.data;
13045
+ }
13046
+
13047
+ // src/commands/issue.ts
13048
+ async function readDescription(options) {
13049
+ if (options.descriptionFile && options.description) {
13050
+ throw new Error("Use either --description or --description-file, not both.");
13051
+ }
13052
+ if (!options.descriptionFile) {
13053
+ return options.description;
13054
+ }
13055
+ return readFile12(options.descriptionFile, "utf8");
13056
+ }
13057
+ function parseAssigneeIds(values) {
13058
+ return (values || []).flatMap(
13059
+ (value) => value.split(",").map((part) => {
13060
+ const parsed = Number(part.trim());
13061
+ if (!Number.isInteger(parsed) || parsed <= 0) {
13062
+ throw new Error(`Invalid assignee id: ${part}`);
13063
+ }
13064
+ return parsed;
13065
+ })
13066
+ );
13067
+ }
13068
+ async function buildIssueInput(options) {
13069
+ return {
13070
+ title: options.title,
13071
+ description: await readDescription(options),
13072
+ labels: options.label || [],
13073
+ assigneeIds: parseAssigneeIds(options.assigneeId),
13074
+ confidential: options.confidential
13075
+ };
13076
+ }
13077
+ function prettyCreatedIssue(issue3) {
13078
+ return issue3.web_url;
13079
+ }
13080
+ function registerIssueCommands(program2, deps = {}) {
13081
+ const createIssue = deps.createIssue || createGitLabIssue;
13082
+ const issue3 = program2.command("issue").description("Report bugs and create GitLab issues for bpmax-cli");
13083
+ const registerCreateLike = (name) => {
13084
+ 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) => {
13085
+ const input = await buildIssueInput(options);
13086
+ const payload = buildGitLabIssuePayload(input);
13087
+ const project = options.project || DEFAULT_GITLAB_PROJECT;
13088
+ const gitlabUrl = options.gitlabUrl || DEFAULT_GITLAB_URL;
13089
+ if (options.dryRun) {
13090
+ printResult(options.format, {
13091
+ ok: true,
13092
+ dry_run: true,
13093
+ gitlab_url: gitlabUrl,
13094
+ project,
13095
+ payload
13096
+ });
13097
+ return;
13098
+ }
13099
+ const token = resolveGitLabToken({
13100
+ tokenEnv: options.tokenEnv,
13101
+ env: deps.env
13102
+ });
13103
+ const created = await createIssue(input, {
13104
+ baseUrl: gitlabUrl,
13105
+ project,
13106
+ token
13107
+ });
13108
+ if (options.format === "pretty") {
13109
+ printResult("pretty", prettyCreatedIssue(created));
13110
+ return;
13111
+ }
13112
+ printResult(options.format, {
13113
+ ok: true,
13114
+ issue: created
13115
+ });
13116
+ });
13117
+ };
13118
+ registerCreateLike("create");
13119
+ registerCreateLike("report");
13120
+ }
13121
+
12973
13122
  // src/commands/memory.ts
12974
13123
  function parseLimit(input, fallback) {
12975
13124
  const value = Number(input ?? fallback);
@@ -13050,7 +13199,7 @@ function registerMemoryCommands(program2) {
13050
13199
  }
13051
13200
 
13052
13201
  // src/commands/matrix.ts
13053
- import { readFile as readFile12 } from "fs/promises";
13202
+ import { readFile as readFile13 } from "fs/promises";
13054
13203
  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
13204
  var UUID_PATH_PATTERN = /uuid'[^'"\s/]+/i;
13056
13205
  async function parseSeedRules(input) {
@@ -13058,7 +13207,7 @@ async function parseSeedRules(input) {
13058
13207
  if (source === "") {
13059
13208
  throw new Error("--rules file path is empty.");
13060
13209
  }
13061
- const raw = source ? await readFile12(source, "utf8") : input;
13210
+ const raw = source ? await readFile13(source, "utf8") : input;
13062
13211
  let parsed;
13063
13212
  try {
13064
13213
  parsed = JSON.parse(raw);
@@ -14371,7 +14520,7 @@ import { spawn as spawn2 } from "child_process";
14371
14520
  import { fileURLToPath as fileURLToPath3 } from "url";
14372
14521
 
14373
14522
  // src/core/recipes.ts
14374
- import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile13, writeFile as writeFile10 } from "fs/promises";
14523
+ import { access, mkdir as mkdir10, readdir as readdir4, readFile as readFile14, writeFile as writeFile10 } from "fs/promises";
14375
14524
  import path11 from "path";
14376
14525
  var RECIPE_NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
14377
14526
  var TEMPLATE_PATTERN = /{{\s*([a-zA-Z0-9_.-]+)\s*}}/g;
@@ -14453,7 +14602,7 @@ function parseRecipeDefinition(input) {
14453
14602
  };
14454
14603
  }
14455
14604
  async function loadRecipe(recipeDir) {
14456
- const raw = await readFile13(path11.join(recipeDir, "recipe.json"), "utf8");
14605
+ const raw = await readFile14(path11.join(recipeDir, "recipe.json"), "utf8");
14457
14606
  return parseRecipeDefinition(JSON.parse(raw));
14458
14607
  }
14459
14608
  async function listRecipes(recipesDir) {
@@ -14552,7 +14701,7 @@ async function renderArgv(options) {
14552
14701
  const rendered = [];
14553
14702
  for (const token of options.recipe.command.argv) {
14554
14703
  if (token.startsWith("@")) {
14555
- const raw = await readFile13(resolveRecipeFile(options.recipeDir, token), "utf8");
14704
+ const raw = await readFile14(resolveRecipeFile(options.recipeDir, token), "utf8");
14556
14705
  rendered.push(renderTemplate(raw, options.variables));
14557
14706
  } else {
14558
14707
  rendered.push(renderTemplate(token, options.variables));
@@ -15010,7 +15159,7 @@ function registerSetupCommand(program2, deps = {}) {
15010
15159
  }
15011
15160
 
15012
15161
  // src/core/taskbook.ts
15013
- import { mkdir as mkdir11, readFile as readFile14, writeFile as writeFile11 } from "fs/promises";
15162
+ import { mkdir as mkdir11, readFile as readFile15, writeFile as writeFile11 } from "fs/promises";
15014
15163
  import path12 from "path";
15015
15164
  var TaskbookError = class extends Error {
15016
15165
  };
@@ -15218,7 +15367,7 @@ function addUuidIssues(text5, issues, path15) {
15218
15367
  }
15219
15368
  }
15220
15369
  async function readTaskbookText(file) {
15221
- const raw = await readFile14(file, "utf8");
15370
+ const raw = await readFile15(file, "utf8");
15222
15371
  try {
15223
15372
  const parsed = JSON.parse(raw);
15224
15373
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
@@ -15868,7 +16017,7 @@ import {
15868
16017
  cp as cp3,
15869
16018
  mkdir as mkdir12,
15870
16019
  readdir as readdir5,
15871
- readFile as readFile15,
16020
+ readFile as readFile16,
15872
16021
  rm as rm4,
15873
16022
  stat as stat6,
15874
16023
  writeFile as writeFile12
@@ -15926,7 +16075,7 @@ var CONFIG_BASIS_ALLOWED_PREFIXES = [
15926
16075
  ".codex/skills/"
15927
16076
  ];
15928
16077
  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:"];
16078
+ var REPORT_EXECUTION_KEYS = ["planned_cases:", "executed_cases:", "precondition_check:", "state_file:", "report_run:", "browser_tool:", "rerun_policy:"];
15930
16079
  var REPORT_REQUIRED_HEADINGS = [
15931
16080
  "## 1. \u6D4B\u8BD5\u8303\u56F4",
15932
16081
  "## 2. \u6267\u884C\u73AF\u5883",
@@ -15964,7 +16113,13 @@ var BROWSER_TOOL_RE = /(Chrome DevTools|DevTools|Playwright|AppleScript|browser_
15964
16113
  var LIVE_DRAFT_RE = /(live|draft|已发布|草稿|发布态|live_draft=)/i;
15965
16114
  var MULTI_ROLE_VALUE_RE = /[,、/]\s*[^,、/\s]+|多角色|跨角色/;
15966
16115
  var RESUME_POLICY_VALUE_RE = /(full_rerun|checkpoint|evidence_only|从头重跑|检查点|仅补证据)/i;
16116
+ var FULL_RERUN_RE = /(full_rerun|重新运行|全量重跑|从头重跑)/i;
16117
+ var PARTIAL_RERUN_RE = /(checkpoint|evidence_only|检查点|仅补证据)/i;
16118
+ var RUN_MARKER_RE = /\b\d{8}(?:-\d{3})?\b/g;
15967
16119
  var NOT_RUN_RE = /(not[_ -]?run|未执行|未跑|跳过)/i;
16120
+ var BLOCKED_RE = /(blocked|阻塞|卡住|无法继续)/i;
16121
+ var PASS_CASE_RE = /\b(pass|passed|success|通过)\b|(^|[||,,;;\s])通过($|[||,,;;\s])/i;
16122
+ var HISTORICAL_EVIDENCE_RE = /(历史|旧报告|旧截图|旧结果|旧状态|复用.*(报告|截图|结果|状态)|historical|old report|old screenshot|old result|reused)/i;
15968
16123
  var PAGE_CONCLUSION_RE = /(页面.*(通过|已验证|真实|可见|不可见)|浏览器回归.*(通过|完成)|完整链路.*通过|真实页面.*通过)/;
15969
16124
  var TestSuiteError = class extends Error {
15970
16125
  code;
@@ -15988,7 +16143,7 @@ async function exists3(filePath) {
15988
16143
  }
15989
16144
  }
15990
16145
  async function readText(filePath) {
15991
- return readFile15(filePath, "utf8");
16146
+ return readFile16(filePath, "utf8");
15992
16147
  }
15993
16148
  function fail(message, options = {}) {
15994
16149
  throw new TestSuiteError(message, options);
@@ -16266,6 +16421,20 @@ function validatePreflightEvidence(filePath, caseId, row, prepTokens) {
16266
16421
  if (!prepTokens.state_file && !prepTokens.report_run) {
16267
16422
  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
16423
  }
16424
+ const policy = prepTokens.resume_policy;
16425
+ if (!policy || !RESUME_POLICY_VALUE_RE.test(policy)) {
16426
+ 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" });
16427
+ }
16428
+ if (policy && PARTIAL_RERUN_RE.test(policy) && !/(边界|范围|局部|检查点|仅补证据|用户确认|只验证|scope|boundary|confirmed)/i.test([row.prep_data, row.steps, row.expected_result, row.evidence_required].join(" "))) {
16429
+ 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" });
16430
+ }
16431
+ for (const [token, value] of Object.entries({ state_file: prepTokens.state_file, report_run: prepTokens.report_run })) {
16432
+ if (!value) continue;
16433
+ const markers = reportRunMarkers(value).filter((marker) => !/<run_id>|<date>|\{run_id\}|\{date\}|\$RUN_ID|\$RUN_DATE/i.test(value));
16434
+ if (markers.length > 0 && !value.includes("<run_id>") && !value.includes("<date>")) {
16435
+ 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" });
16436
+ }
16437
+ }
16269
16438
  }
16270
16439
  function validateErrorCaptureEvidence(filePath, caseId, row) {
16271
16440
  const caseText = [row.type, row.title, row.preconditions, row.steps, row.expected_result, row.tags].join(" ");
@@ -16276,8 +16445,9 @@ function validateErrorCaptureEvidence(filePath, caseId, row) {
16276
16445
  }
16277
16446
  }
16278
16447
  function validateResumePolicy(filePath, caseId, row, prepTokens) {
16448
+ const manualText = [row.preconditions, row.steps, row.expected_result, row.evidence_required, row.tags].join(" ");
16449
+ if (!/(人工介入|手工|补救|续跑|dirty_resumed|局部复核|partial rerun)/i.test(manualText)) return;
16279
16450
  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
16451
  const policy = prepTokens.resume_policy || text5;
16282
16452
  if (!RESUME_POLICY_VALUE_RE.test(policy)) {
16283
16453
  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 +16684,10 @@ async function fileMap(root) {
16514
16684
  return result;
16515
16685
  }
16516
16686
  async function sha256(filePath) {
16517
- return createHash6("sha256").update(await readFile15(filePath)).digest("hex");
16687
+ return createHash6("sha256").update(await readFile16(filePath)).digest("hex");
16518
16688
  }
16519
16689
  async function readForDiff(filePath) {
16520
- const buffer = await readFile15(filePath);
16690
+ const buffer = await readFile16(filePath);
16521
16691
  if (buffer.includes(0)) return [`<binary sha256=${createHash6("sha256").update(buffer).digest("hex")}>
16522
16692
  `];
16523
16693
  return buffer.toString("utf8").split(/(?<=\n)/);
@@ -16819,7 +16989,22 @@ async function nextReportDir(root = DEFAULT_REPORT_ROOT, create = false, today =
16819
16989
  await mkdir12(path13.join(reportDir, "screenshots"), { recursive: true });
16820
16990
  await writeFile12(
16821
16991
  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"),
16992
+ [
16993
+ "# BPMAX E2E \u6D4B\u8BD5\u62A5\u544A\u6C47\u603B",
16994
+ "",
16995
+ `run_id: ${path13.basename(reportDir)}`,
16996
+ "rerun_policy: full_rerun",
16997
+ "status: draft",
16998
+ "",
16999
+ "## \u573A\u666F\u62A5\u544A",
17000
+ "",
17001
+ "## \u622A\u56FE\u76EE\u5F55",
17002
+ "",
17003
+ `screenshots: ${path13.join(path13.basename(reportDir), "screenshots")}`,
17004
+ "",
17005
+ "## \u603B\u7ED3",
17006
+ ""
17007
+ ].join("\n"),
16823
17008
  "utf8"
16824
17009
  );
16825
17010
  }
@@ -16834,6 +17019,55 @@ function reportCaseList(text5, key) {
16834
17019
  const value = reportKeyValue(text5, key);
16835
17020
  return value.split(/[,\s,、;;]+/).map((item) => item.trim()).filter((item) => /^[A-Za-z0-9_-]+$/.test(item));
16836
17021
  }
17022
+ function reportRunDate(runName) {
17023
+ return runName.slice(0, 8);
17024
+ }
17025
+ function reportKeyValues(text5, key) {
17026
+ const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17027
+ return [...text5.matchAll(new RegExp(`^${escaped}\\s*(.+)$`, "gim"))].map((match) => match[1]?.trim() ?? "").filter(Boolean);
17028
+ }
17029
+ function reportRunMarkers(value) {
17030
+ return [...value.matchAll(RUN_MARKER_RE)].map((match) => match[0]);
17031
+ }
17032
+ function reportContainsHistoricalRun(value, runName) {
17033
+ const runDate = reportRunDate(runName);
17034
+ return reportRunMarkers(value).some((marker) => marker !== runName && marker !== runDate);
17035
+ }
17036
+ function parseReportTime(value) {
17037
+ if (!value.trim()) return null;
17038
+ const date = new Date(value.trim());
17039
+ if (Number.isNaN(date.getTime())) return null;
17040
+ return date;
17041
+ }
17042
+ function reportDayWindow(runName) {
17043
+ const date = reportRunDate(runName);
17044
+ const start = /* @__PURE__ */ new Date(`${date.slice(0, 4)}-${date.slice(4, 6)}-${date.slice(6, 8)}T00:00:00+08:00`);
17045
+ const end = new Date(start.getTime() + 24 * 60 * 60 * 1e3);
17046
+ return { start, end };
17047
+ }
17048
+ function reportExecutionWindow(runName, text5) {
17049
+ const fallback = reportDayWindow(runName);
17050
+ const startedAt = parseReportTime(reportKeyValue(text5, "started_at:"));
17051
+ const finishedAt = parseReportTime(reportKeyValue(text5, "finished_at:"));
17052
+ if (!startedAt || !finishedAt || finishedAt < startedAt) return fallback;
17053
+ return { start: startedAt, end: finishedAt };
17054
+ }
17055
+ function isWithinWindow(date, window) {
17056
+ return date >= window.start && date <= window.end;
17057
+ }
17058
+ function caseEvidencePattern(caseId) {
17059
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17060
+ return new RegExp(`\\b${escaped}\\b.*?(screenshots/|\\.ai_test/report/|\\.codex/tmp/e2e|evidence|\u622A\u56FE|\u8BC1\u636E|\u9879\u76EE|project|step)`, "i");
17061
+ }
17062
+ function caseResultPattern(caseId) {
17063
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17064
+ return new RegExp(`\\b${escaped}\\b[^\\n]*(pass|passed|success|\u901A\u8FC7)`, "i");
17065
+ }
17066
+ function linesForCase(text5, caseId) {
17067
+ const escaped = caseId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
17068
+ const pattern = new RegExp(`\\b${escaped}\\b`);
17069
+ return text5.split(/\r?\n/).filter((line) => pattern.test(line));
17070
+ }
16837
17071
  async function lintReport(root = DEFAULT_REPORT_ROOT) {
16838
17072
  if (!await exists3(root)) return [`report root not found: ${root}`];
16839
17073
  const errors = [];
@@ -16850,9 +17084,20 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16850
17084
  for (const reportName of scenarioReports) {
16851
17085
  const reportPath = path13.join(runDir, reportName);
16852
17086
  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}\``);
17087
+ for (const key of REPORT_REQUIRED_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
17088
+ for (const key of REPORT_EXECUTION_KEYS) if (!reportKeyValue(text5, key)) errors.push(`${reportPath}: missing \`${key}\``);
16855
17089
  for (const heading of REPORT_REQUIRED_HEADINGS) if (!text5.includes(heading)) errors.push(`${reportPath}: missing \`${heading}\``);
17090
+ const runId = reportKeyValue(text5, "run_id:");
17091
+ if (runId && runId !== runName) {
17092
+ 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`);
17093
+ }
17094
+ const rerunPolicy = reportKeyValue(text5, "rerun_policy:") || reportKeyValue(text5, "resume_policy:");
17095
+ const isFullRerun = FULL_RERUN_RE.test(rerunPolicy) || /重新运行|全量重跑|从头重跑/.test(text5);
17096
+ const isPartialRerun = PARTIAL_RERUN_RE.test(rerunPolicy);
17097
+ const resultValue = reportKeyValue(text5, "result:").toLowerCase();
17098
+ if (isPartialRerun && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整|对照/.test(resultValue)) {
17099
+ 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`);
17100
+ }
16856
17101
  const plannedCases = reportCaseList(text5, "planned_cases:");
16857
17102
  const executedCases = reportCaseList(text5, "executed_cases:");
16858
17103
  const missingExecuted = plannedCases.filter((caseId) => !executedCases.includes(caseId));
@@ -16863,9 +17108,8 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16863
17108
  if (unexpectedExecuted.length > 0) {
16864
17109
  errors.push(`[test_suite.report.case_reconciliation] ${reportPath}: executed_cases \u5305\u542B\u4E0D\u5728 planned_cases \u4E2D\u7684\u7528\u4F8B: ${unexpectedExecuted.join(", ")}`);
16865
17110
  }
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`);
17111
+ if ((NOT_RUN_RE.test(text5) || BLOCKED_RE.test(text5)) && /pass|passed|complete|success|通过|完整/.test(resultValue) && !/partial|stage|blocked|阶段|局部|不完整/.test(resultValue)) {
17112
+ 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
17113
  }
16870
17114
  if (PAGE_CONCLUSION_RE.test(text5) && !BROWSER_TOOL_RE.test(text5)) {
16871
17115
  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 +17117,24 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16873
17117
  if (/browser[_ -]?blocked|浏览器阻塞|无可用浏览器工具/i.test(text5) && !/browser_status:\s*blocked|页面结论停止|停止页面结论/i.test(text5)) {
16874
17118
  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
17119
  }
16876
- const imageRefs = [...text5.matchAll(IMAGE_RE)].map((match) => match[1]);
16877
- if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
16878
17120
  const screenshotsDir = path13.join(runDir, "screenshots");
16879
17121
  if (!await exists3(screenshotsDir)) errors.push(`${runDir}: missing screenshots directory`);
17122
+ if (isFullRerun) {
17123
+ for (const key of ["state_file:", "precondition_check:", "report_run:"]) {
17124
+ for (const value of reportKeyValues(text5, key)) {
17125
+ const markers = reportRunMarkers(value);
17126
+ const hasCurrentMarker = markers.some((marker) => marker === runName || marker === reportRunDate(runName));
17127
+ if (!hasCurrentMarker || reportContainsHistoricalRun(value, runName)) {
17128
+ 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}`);
17129
+ }
17130
+ }
17131
+ }
17132
+ }
17133
+ const imageMatches = [...text5.matchAll(IMAGE_RE)];
17134
+ const imageRefs = imageMatches.map((match) => match[1]);
17135
+ if (imageRefs.length === 0) errors.push(`${reportPath}: missing embedded screenshot image`);
17136
+ const validCurrentRunImages = [];
17137
+ const window = reportExecutionWindow(runName, text5);
16880
17138
  for (const imageRef of imageRefs) {
16881
17139
  if (imageRef.includes("://")) {
16882
17140
  errors.push(`${reportPath}: screenshot must be a local file under this run's screenshots directory`);
@@ -16888,7 +17146,30 @@ async function lintReport(root = DEFAULT_REPORT_ROOT) {
16888
17146
  errors.push(`${reportPath}: image reference must stay under this run's screenshots directory: ${imageRef}`);
16889
17147
  continue;
16890
17148
  }
16891
- if (!await exists3(imagePath)) errors.push(`${reportPath}: missing image file: ${imageRef}`);
17149
+ if (!await exists3(imagePath)) {
17150
+ errors.push(`${reportPath}: missing image file: ${imageRef}`);
17151
+ continue;
17152
+ }
17153
+ validCurrentRunImages.push(imageRef);
17154
+ if (isFullRerun) {
17155
+ const imageStat = await stat6(imagePath);
17156
+ if (!isWithinWindow(imageStat.mtime, window)) {
17157
+ 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}`);
17158
+ }
17159
+ }
17160
+ }
17161
+ if (isFullRerun) {
17162
+ for (const caseId of executedCases) {
17163
+ const caseLines = linesForCase(text5, caseId);
17164
+ const hasPassResult = caseResultPattern(caseId).test(text5) || caseLines.some((line) => PASS_CASE_RE.test(line));
17165
+ const hasCurrentEvidence = caseEvidencePattern(caseId).test(text5) || validCurrentRunImages.some((imageRef) => imageRef.includes(caseId));
17166
+ if (hasPassResult && caseLines.some((line) => HISTORICAL_EVIDENCE_RE.test(line))) {
17167
+ 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`);
17168
+ }
17169
+ if (hasPassResult && !hasCurrentEvidence) {
17170
+ 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`);
17171
+ }
17172
+ }
16892
17173
  }
16893
17174
  }
16894
17175
  }
@@ -16958,7 +17239,7 @@ function registerTestSuiteCommands(program2) {
16958
17239
  }
16959
17240
 
16960
17241
  // src/core/update.ts
16961
- import { access as access2, mkdir as mkdir13, readFile as readFile16, realpath, writeFile as writeFile13 } from "fs/promises";
17242
+ import { access as access2, mkdir as mkdir13, readFile as readFile17, realpath, writeFile as writeFile13 } from "fs/promises";
16962
17243
  import path14 from "path";
16963
17244
  var DEFAULT_REGISTRY_URL = "https://registry.npmjs.org/";
16964
17245
  var UPDATE_STATE_FILE = "update-state.json";
@@ -17075,7 +17356,7 @@ function updateStatePath(configDir = getConfigDir()) {
17075
17356
  }
17076
17357
  async function readUpdateState(configDir) {
17077
17358
  try {
17078
- const raw = await readFile16(updateStatePath(configDir), "utf8");
17359
+ const raw = await readFile17(updateStatePath(configDir), "utf8");
17079
17360
  const parsed = JSON.parse(raw);
17080
17361
  if (typeof parsed.latest_version !== "string" || typeof parsed.checked_at !== "number") {
17081
17362
  return null;
@@ -17614,6 +17895,7 @@ registerSchemaCommands(program);
17614
17895
  registerUserCommands(program);
17615
17896
  registerEsCommands(program);
17616
17897
  registerFlowCommands(program);
17898
+ registerIssueCommands(program);
17617
17899
  registerMemoryCommands(program);
17618
17900
  registerMatrixCommands(program);
17619
17901
  registerPluginCommands(program);