bpmax-cli 0.1.44-beta.24 → 0.1.44-beta.26

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.1.44-beta.24",
472
+ version: "0.1.44-beta.26",
473
473
  description: "CLI for BPMAX environments with multi-profile config and local login callback flow",
474
474
  type: "module",
475
475
  bin: {
@@ -4273,9 +4273,23 @@ function looksLikeParseEvalFunctionBody(script) {
4273
4273
  }
4274
4274
  function addCodeModeMessageScriptError(errors, pathName) {
4275
4275
  errors.push(
4276
- `${pathName} is code-mode message content but is not a parseEvalFunction body; wrap literal text as a JS return script, for example: return "\u8BF7\u5904\u7406..."; use return ""; to suppress default message sending.`
4276
+ `${pathName} is code-mode message content but is not a parseEvalFunction body; code-mode scripts must return a complete message object, for example: return { title: "...", content: [...], actions: [...], messageType: "step" }; use return ""; only to suppress outbound messages entirely.`
4277
4277
  );
4278
4278
  }
4279
+ function returnsBareNonEmptyString(script) {
4280
+ if (/\breturn\s+[{(]/.test(script)) {
4281
+ return false;
4282
+ }
4283
+ const matches = script.match(/\breturn\s+"([^"]*)"/);
4284
+ if (matches && matches[1] !== "") {
4285
+ return true;
4286
+ }
4287
+ const singleMatches = script.match(/\breturn\s+'([^']*)'/);
4288
+ if (singleMatches && singleMatches[1] !== "") {
4289
+ return true;
4290
+ }
4291
+ return false;
4292
+ }
4279
4293
  function validateCodeModeMessageScript(errors, pathName, value) {
4280
4294
  if (value === void 0 || value === null || value === "") {
4281
4295
  errors.push(
@@ -4285,6 +4299,12 @@ function validateCodeModeMessageScript(errors, pathName, value) {
4285
4299
  }
4286
4300
  if (typeof value !== "string" || !looksLikeParseEvalFunctionBody(value)) {
4287
4301
  addCodeModeMessageScriptError(errors, pathName);
4302
+ return;
4303
+ }
4304
+ if (returnsBareNonEmptyString(value)) {
4305
+ errors.push(
4306
+ `${pathName} is code-mode message content but returns a bare string; code-mode scripts must return a complete message object { title, content, actions: [{ type: "link", text, url, m_url }], messageType: "step" }. A non-empty bare string is treated as truthy and enters sendMessage but cannot render as a card. Only return ""; suppresses outbound messages.`
4307
+ );
4288
4308
  }
4289
4309
  }
4290
4310
  function validateCodeModeMessageActionUrl(errors, pathName, value) {
@@ -5958,6 +5978,11 @@ function buildNavConfigSubmitPayload(work, raw, options = {}) {
5958
5978
  submitConfigs[type] = payload;
5959
5979
  const rawConfig = isRecord3(rawConfigs[type]) ? rawConfigs[type] : null;
5960
5980
  const rawPayload = rawConfig ? navConfigToSubmitRecord(type, rawConfig) : null;
5981
+ if (rawPayload && navConfigItemCount(rawPayload) > 0 && navConfigItemCount(payload) === 0) {
5982
+ throw new Error(
5983
+ `nav-config ${type} \u9632\u6E05\u7A7A\u95E8\u7981\u5931\u8D25\uFF1A\u8FDC\u7AEF\u539F\u914D\u7F6E\u6709 ${navConfigItemCount(rawPayload)} \u4E2A\u5165\u53E3\uFF0C\u4F46\u672C\u6B21\u63D0\u4EA4\u4F1A\u5199\u6210\u7A7A\u6570\u7EC4\u3002\u8BF7\u91CD\u65B0 export \u5F53\u524D\u8FDC\u7AEF\u914D\u7F6E\u540E\u5408\u5E76\u4FEE\u6539\uFF0C\u4E0D\u8981\u7EE7\u7EED\u63D0\u4EA4\u65E7 payload\u3002`
5984
+ );
5985
+ }
5961
5986
  const changed = options.allRecords || !rawPayload || hashJson(rawPayload) !== hashJson(payload);
5962
5987
  const hasId = payload.id !== void 0 && payload.id !== null && payload.id !== "";
5963
5988
  const operation = {
@@ -13899,11 +13924,19 @@ function hasDomainWriteEvidence(domain, evidenceText, patterns) {
13899
13924
  const shorthand = new RegExp(`bpmax-cli config ${domain} (?:export/)?lint/build/submit/verify`);
13900
13925
  return shorthand.test(evidenceText) || patterns.every((pattern) => pattern.test(evidenceText));
13901
13926
  }
13902
- function uuidErrors(text5, target) {
13903
- const values = [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
13904
- return values.map(
13905
- (value) => `UUID values are not allowed in BPMAX configuration ${target}: ${value}. Use platform-returned numeric ids or flow<number>; use new-flow:<name> before creation.`
13906
- );
13927
+ function uuidValues(text5) {
13928
+ return [...new Set([...text5.matchAll(UUID_PATTERN)].map((match) => match[0]))];
13929
+ }
13930
+ function addUuidIssues(text5, issues, path14) {
13931
+ for (const value of uuidValues(text5)) {
13932
+ addTaskbookIssue(
13933
+ issues,
13934
+ "uuid_not_allowed",
13935
+ "taskbook.config.no_uuid",
13936
+ `BPMAX \u914D\u7F6E\u4EFB\u52A1\u4E0D\u80FD\u4F7F\u7528 UUID\uFF1A${value}\u3002`,
13937
+ { path: path14, suggestion: "\u4F7F\u7528\u5E73\u53F0\u8FD4\u56DE\u7684\u6570\u5B57 ID \u6216 flow<number>\uFF1B\u521B\u5EFA\u524D\u4F7F\u7528 new-flow:<name>\uFF0C\u521B\u5EFA\u540E\u56DE\u586B\u771F\u5B9E flow_type\u3002" }
13938
+ );
13939
+ }
13907
13940
  }
13908
13941
  async function readTaskbookText(file) {
13909
13942
  const raw = await readFile14(file, "utf8");
@@ -13933,17 +13966,35 @@ function findNavigationStrategy(text5) {
13933
13966
  const matches = [...text5.matchAll(/导航入口策略\s*[::]\s*(nav-config:(?:included|skipped:[^\s|,。]+|deferred:[^\s|,。]+))/gi)];
13934
13967
  return matches.at(-1)?.[1] || null;
13935
13968
  }
13936
- function validateNavigationStrategy(text5, errors, prefix = "") {
13969
+ function validateNavigationStrategy(text5, issues, path14, subject) {
13937
13970
  const strategy = findNavigationStrategy(text5);
13938
13971
  if (!strategy) {
13939
- errors.push(`${prefix}missing concrete navigation strategy: use \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included, nav-config:skipped:<reason>, or nav-config:deferred:<reason>`);
13972
+ addTaskbookIssue(
13973
+ issues,
13974
+ "missing_navigation_strategy",
13975
+ "taskbook.nav.strategy",
13976
+ `${subject}\u7F3A\u5C11\u660E\u786E\u7684\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u3002`,
13977
+ { path: path14, suggestion: "\u5199\u660E \u5BFC\u822A\u5165\u53E3\u7B56\u7565\uFF1Anav-config:included\u3001nav-config:skipped:<reason> \u6216 nav-config:deferred:<reason>\u3002" }
13978
+ );
13940
13979
  return null;
13941
13980
  }
13942
13981
  if (/nav-config:(skipped|deferred):$/i.test(strategy)) {
13943
- errors.push(`${prefix}navigation strategy requires a non-empty reason when skipped or deferred.`);
13982
+ addTaskbookIssue(
13983
+ issues,
13984
+ "empty_navigation_strategy_reason",
13985
+ "taskbook.nav.strategy_reason",
13986
+ `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u8DF3\u8FC7\u6216\u5EF6\u540E\u65F6\u5FC5\u987B\u5199\u660E\u539F\u56E0\u3002`,
13987
+ { path: path14, suggestion: "\u4F7F\u7528 nav-config:skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 nav-config:deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
13988
+ );
13944
13989
  }
13945
13990
  if (/(待完成范围确认后回填|待确认|TODO|TBD|占位)/i.test(strategy)) {
13946
- errors.push(`${prefix}navigation strategy is still a placeholder; replace it with included, skipped:<real reason>, or deferred:<real reason>.`);
13991
+ addTaskbookIssue(
13992
+ issues,
13993
+ "placeholder_navigation_strategy",
13994
+ "taskbook.nav.strategy_placeholder",
13995
+ `${subject}\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4ECD\u662F\u5360\u4F4D\u5185\u5BB9\u3002`,
13996
+ { path: path14, suggestion: "\u66FF\u6362\u4E3A included\u3001skipped:<\u771F\u5B9E\u539F\u56E0> \u6216 deferred:<\u771F\u5B9E\u539F\u56E0>\u3002" }
13997
+ );
13947
13998
  }
13948
13999
  return strategy;
13949
14000
  }
@@ -13954,28 +14005,60 @@ function promptObjectLockText(text5) {
13954
14005
  function hasStrongListEvidence(value) {
13955
14006
  return /bpmax-cli config list-template lint/.test(value) && /(真实列表页|浏览器|runtime|E2E|渲染)/i.test(value);
13956
14007
  }
13957
- function validateTaskbookNavigationAndListGates(text5, errors) {
13958
- const strategy = validateNavigationStrategy(text5, errors);
14008
+ function validateTaskbookNavigationAndListGates(text5, issues) {
14009
+ const strategy = validateNavigationStrategy(text5, issues, "navigation_strategy", "\u4EFB\u52A1\u4E66");
13959
14010
  const rows = extractTaskRows(text5);
13960
14011
  const navRows = rows.filter((row) => /bpmax-nav-config-editor/.test(row.required_skills || ""));
13961
14012
  const listRows = rows.filter((row) => /bpmax-list-template-editor/.test(row.required_skills || ""));
13962
14013
  if (strategy === "nav-config:included" && navRows.length === 0) {
13963
- errors.push("navigation strategy is included but AI task table has no bpmax-nav-config-editor task.");
14014
+ addTaskbookIssue(
14015
+ issues,
14016
+ "missing_nav_config_task",
14017
+ "taskbook.nav.required_task",
14018
+ "\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u4E3A included\uFF0C\u4F46\u4EFB\u52A1\u8868\u7F3A\u5C11 bpmax-nav-config-editor \u4EFB\u52A1\u3002",
14019
+ { domain: "nav-config", path: "tasks", suggestion: "\u8865\u5145\u5BFC\u822A\u914D\u7F6E\u4EFB\u52A1\uFF0C\u6216\u628A\u5BFC\u822A\u5165\u53E3\u7B56\u7565\u6539\u4E3A skipped/deferred \u5E76\u5199\u660E\u771F\u5B9E\u539F\u56E0\u3002" }
14020
+ );
13964
14021
  }
13965
14022
  navRows.forEach((row) => {
14023
+ const taskId = row.task_id || "<unknown>";
13966
14024
  if (!/nav-config:[A-Za-z0-9_-]+/.test(row.object_lock || "")) {
13967
- errors.push(`navigation task ${row.task_id || "<unknown>"} must use object_lock nav-config:<workspace>.`);
14025
+ addTaskbookIssue(
14026
+ issues,
14027
+ "invalid_nav_object_lock",
14028
+ "taskbook.nav.object_lock",
14029
+ `\u5BFC\u822A\u4EFB\u52A1 ${taskId} \u5FC5\u987B\u4F7F\u7528 nav-config:<workspace> \u5BF9\u8C61\u9501\u3002`,
14030
+ { domain: "nav-config", path: `tasks.${taskId}.object_lock` }
14031
+ );
13968
14032
  }
13969
14033
  if (!/(入口|导航).*(浏览器|点击|打开|可见|readback|回读)/i.test(row.evidence || "")) {
13970
- errors.push(`navigation task ${row.task_id || "<unknown>"} evidence must include readback and browser navigation-entry proof.`);
14034
+ addTaskbookIssue(
14035
+ issues,
14036
+ "missing_nav_browser_proof",
14037
+ "taskbook.nav.browser_proof",
14038
+ `\u5BFC\u822A\u4EFB\u52A1 ${taskId} \u7F3A\u5C11\u56DE\u8BFB\u548C\u6D4F\u89C8\u5668\u5165\u53E3\u9A8C\u8BC1\u8BC1\u636E\u3002`,
14039
+ { domain: "nav-config", path: `tasks.${taskId}.evidence`, suggestion: "evidence \u5FC5\u987B\u5305\u542B readback/\u56DE\u8BFB\uFF0C\u4EE5\u53CA\u771F\u5B9E\u6D4F\u89C8\u5668\u6253\u5F00\u6216\u70B9\u51FB\u5BFC\u822A\u5165\u53E3\u7684 proof\u3002" }
14040
+ );
13971
14041
  }
13972
14042
  });
13973
14043
  listRows.forEach((row) => {
14044
+ const taskId = row.task_id || "<unknown>";
13974
14045
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(row.object_lock || "")) {
13975
- errors.push(`list-template task ${row.task_id || "<unknown>"} must use object_lock list-template:<id> or list-template:new-<name>.`);
14046
+ addTaskbookIssue(
14047
+ issues,
14048
+ "invalid_list_object_lock",
14049
+ "taskbook.list.object_lock",
14050
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u5FC5\u987B\u4F7F\u7528 list-template:<id> \u6216 list-template:new-<name> \u5BF9\u8C61\u9501\u3002`,
14051
+ { domain: "list-template", path: `tasks.${taskId}.object_lock` }
14052
+ );
13976
14053
  }
13977
14054
  if (!hasStrongListEvidence(row.evidence || "")) {
13978
- errors.push(`list-template task ${row.task_id || "<unknown>"} evidence must include bpmax-cli config list-template lint and real browser list-page verification.`);
14055
+ addTaskbookIssue(
14056
+ issues,
14057
+ "missing_list_runtime_proof",
14058
+ "taskbook.list.runtime_proof",
14059
+ `\u5217\u8868\u6A21\u677F\u4EFB\u52A1 ${taskId} \u7F3A\u5C11 list-template lint \u548C\u771F\u5B9E\u5217\u8868\u9875\u9A8C\u8BC1\u8BC1\u636E\u3002`,
14060
+ { domain: "list-template", path: `tasks.${taskId}.evidence`, suggestion: "evidence \u5FC5\u987B\u5305\u542B bpmax-cli config list-template lint \u548C\u771F\u5B9E\u6D4F\u89C8\u5668\u5217\u8868\u9875 proof\u3002" }
14061
+ );
13979
14062
  }
13980
14063
  });
13981
14064
  }
@@ -13989,13 +14072,32 @@ function rowText(row) {
13989
14072
  row.parallel_type
13990
14073
  ].filter(Boolean).join(" ");
13991
14074
  }
13992
- function validateConfigRuleForTaskRow(row, rule, errors) {
14075
+ function addTaskbookIssue(issues, code, ruleId, message, options = {}) {
14076
+ issues.push({
14077
+ code,
14078
+ rule_id: ruleId,
14079
+ domain: options.domain,
14080
+ path: options.path,
14081
+ message,
14082
+ suggestion: options.suggestion
14083
+ });
14084
+ }
14085
+ function issueMessages(issues) {
14086
+ return issues.map((issue3) => issue3.suggestion ? `${issue3.message} \u5EFA\u8BAE\uFF1A${issue3.suggestion}` : issue3.message);
14087
+ }
14088
+ function validateConfigRuleForTaskRow(row, rule, issues) {
13993
14089
  const taskId = row.task_id || "<unknown>";
13994
14090
  const combined = rowText(row);
13995
14091
  const hasSkill = (row.required_skills || "").includes(rule.skill);
13996
14092
  const mentionsDomain = rule.mentionPattern.test(combined) || rule.lockPattern.test(row.object_lock || "");
13997
14093
  if (mentionsDomain && !hasSkill) {
13998
- errors.push(`${rule.domain} task ${taskId} mentions ${rule.domain} work but missing required skill ${rule.skill}.`);
14094
+ addTaskbookIssue(
14095
+ issues,
14096
+ "missing_required_skill",
14097
+ "taskbook.config.required_skill",
14098
+ `\u4EFB\u52A1 ${taskId} \u63D0\u5230\u4E86 ${rule.domain} \u914D\u7F6E\uFF0C\u4F46\u7F3A\u5C11\u5FC5\u9700 skill\uFF1A${rule.skill}\u3002`,
14099
+ { domain: rule.domain, path: `tasks.${taskId}.required_skills` }
14100
+ );
13999
14101
  return;
14000
14102
  }
14001
14103
  if (!hasSkill) {
@@ -14003,52 +14105,106 @@ function validateConfigRuleForTaskRow(row, rule, errors) {
14003
14105
  }
14004
14106
  const writeMode = isWriteMode(row);
14005
14107
  if (writeMode && !rule.lockPattern.test(row.object_lock || "")) {
14006
- errors.push(`${rule.domain} task ${taskId} must use object_lock matching ${rule.domain}:<id> or its documented lock pattern.`);
14108
+ addTaskbookIssue(
14109
+ issues,
14110
+ "invalid_object_lock",
14111
+ "taskbook.config.object_lock",
14112
+ `\u4EFB\u52A1 ${taskId} \u662F ${rule.domain} \u5199\u4EFB\u52A1\uFF0C\u4F46\u5BF9\u8C61\u9501\u4E0D\u7B26\u5408\u8BE5\u914D\u7F6E\u57DF\u8981\u6C42\u3002`,
14113
+ { domain: rule.domain, path: `tasks.${taskId}.object_lock`, suggestion: `\u4F7F\u7528 ${rule.domain}:<id>\u3001new-* \u6216\u8BE5\u914D\u7F6E\u57DF\u6587\u6863\u6307\u5B9A\u7684\u5BF9\u8C61\u9501\u683C\u5F0F\u3002` }
14114
+ );
14007
14115
  }
14008
14116
  if (!writeMode && !/^readonly:[A-Za-z0-9_-]+/.test(row.object_lock || "") && !rule.lockPattern.test(row.object_lock || "")) {
14009
- errors.push(`${rule.domain} readonly task ${taskId} must use readonly:<scope> or the ${rule.domain} object lock.`);
14117
+ addTaskbookIssue(
14118
+ issues,
14119
+ "invalid_readonly_lock",
14120
+ "taskbook.config.readonly_lock",
14121
+ `\u4EFB\u52A1 ${taskId} \u662F ${rule.domain} \u53EA\u8BFB\u4EFB\u52A1\uFF0C\u4F46\u7F3A\u5C11 readonly:<scope> \u6216\u5BF9\u5E94\u5BF9\u8C61\u9501\u3002`,
14122
+ { domain: rule.domain, path: `tasks.${taskId}.object_lock` }
14123
+ );
14010
14124
  }
14011
14125
  const evidenceText = `${row.evidence || ""} ${row.notes || ""}`;
14012
14126
  const hasRequiredEvidence = writeMode ? hasDomainWriteEvidence(rule.domain, evidenceText, rule.writeEvidence) : rule.readonlyEvidence.some((pattern) => pattern.test(evidenceText));
14013
14127
  if (!hasRequiredEvidence) {
14014
14128
  const expected = writeMode ? `bpmax-cli config ${rule.domain} lint/build/submit/verify evidence` : `bpmax-cli config ${rule.domain} export/readback evidence`;
14015
- errors.push(`${rule.domain} task ${taskId} missing ${expected}.`);
14129
+ addTaskbookIssue(
14130
+ issues,
14131
+ "missing_typed_cli_evidence",
14132
+ "taskbook.config.typed_cli_evidence",
14133
+ `\u4EFB\u52A1 ${taskId} \u7F3A\u5C11 ${rule.domain} \u7684 typed CLI \u8BC1\u636E\u3002`,
14134
+ { domain: rule.domain, path: `tasks.${taskId}.evidence`, suggestion: expected }
14135
+ );
14016
14136
  }
14017
14137
  if (!rule.constraintEvidence.test(evidenceText)) {
14018
- errors.push(`${rule.domain} task ${taskId} missing domain-specific constraints from ${rule.skill}.`);
14138
+ addTaskbookIssue(
14139
+ issues,
14140
+ "missing_domain_constraints",
14141
+ "taskbook.config.domain_constraints",
14142
+ `\u4EFB\u52A1 ${taskId} \u7F3A\u5C11\u6765\u81EA ${rule.skill} \u7684 ${rule.domain} \u4E13\u9879\u7EA6\u675F\u8BF4\u660E\u3002`,
14143
+ { domain: rule.domain, path: `tasks.${taskId}.notes` }
14144
+ );
14019
14145
  }
14020
14146
  if (writeMode && !hasConfigAdaptersEvidence(evidenceText)) {
14021
- errors.push(`${rule.domain} task ${taskId} is write-capable but missing bpmax-cli config adapters --format json capability/adapters evidence.`);
14147
+ addTaskbookIssue(
14148
+ issues,
14149
+ "missing_config_adapters_evidence",
14150
+ "taskbook.config.adapters_evidence",
14151
+ `\u4EFB\u52A1 ${taskId} \u662F\u5199\u4EFB\u52A1\uFF0C\u4F46\u7F3A\u5C11 config adapters/capability \u68C0\u67E5\u8BC1\u636E\u3002`,
14152
+ { domain: rule.domain, path: `tasks.${taskId}.evidence`, suggestion: "\u5199\u4EFB\u52A1\u5FC5\u987B\u5305\u542B bpmax-cli config adapters --format json \u7684\u68C0\u67E5\u7ED3\u679C\u3002" }
14153
+ );
14022
14154
  }
14023
14155
  }
14024
- function validateTaskbookConfigSkillGates(text5, errors) {
14156
+ function validateTaskbookConfigSkillGates(text5, issues) {
14025
14157
  const rows = extractTaskRows(text5);
14026
14158
  for (const row of rows) {
14027
14159
  for (const rule of CONFIG_TASK_RULES) {
14028
- validateConfigRuleForTaskRow(row, rule, errors);
14160
+ validateConfigRuleForTaskRow(row, rule, issues);
14029
14161
  }
14030
14162
  }
14031
14163
  }
14032
- function validatePromptNavigationAndListGates(text5, errors) {
14033
- const strategy = validateNavigationStrategy(text5, errors, "prompt ");
14164
+ function validatePromptNavigationAndListGates(text5, issues) {
14165
+ const strategy = validateNavigationStrategy(text5, issues, "prompt.navigation_strategy", "Prompt ");
14034
14166
  const hasNavSkill = /bpmax-nav-config-editor/.test(text5);
14035
14167
  const objectLock = promptObjectLockText(text5);
14036
14168
  if ((strategy === "nav-config:included" || hasNavSkill) && !/nav-config:[A-Za-z0-9_-]+/.test(objectLock)) {
14037
- errors.push("prompt navigation work must include object lock nav-config:<workspace>.");
14169
+ addTaskbookIssue(
14170
+ issues,
14171
+ "invalid_nav_object_lock",
14172
+ "taskbook.nav.object_lock",
14173
+ "Prompt \u4E2D\u7684\u5BFC\u822A\u914D\u7F6E\u4EFB\u52A1\u5FC5\u987B\u5305\u542B nav-config:<workspace> \u5BF9\u8C61\u9501\u3002",
14174
+ { domain: "nav-config", path: "prompt.object_lock" }
14175
+ );
14038
14176
  }
14039
14177
  if ((strategy === "nav-config:included" || hasNavSkill) && !/(入口|导航).*(浏览器|点击|打开|可见|readback|回读)/i.test(text5)) {
14040
- errors.push("prompt navigation work must require readback and browser navigation-entry proof.");
14178
+ addTaskbookIssue(
14179
+ issues,
14180
+ "missing_nav_browser_proof",
14181
+ "taskbook.nav.browser_proof",
14182
+ "Prompt \u4E2D\u7684\u5BFC\u822A\u914D\u7F6E\u4EFB\u52A1\u5FC5\u987B\u8981\u6C42\u56DE\u8BFB\u548C\u6D4F\u89C8\u5668\u5165\u53E3\u9A8C\u8BC1\u3002",
14183
+ { domain: "nav-config", path: "prompt.evidence", suggestion: "\u5199\u660E readback/\u56DE\u8BFB\uFF0C\u4EE5\u53CA\u771F\u5B9E\u6D4F\u89C8\u5668\u6253\u5F00\u6216\u70B9\u51FB\u5BFC\u822A\u5165\u53E3\u7684 proof\u3002" }
14184
+ );
14041
14185
  }
14042
14186
  if (/bpmax-list-template-editor/.test(text5)) {
14043
14187
  if (!/list-template:(?:\d+|new-[A-Za-z0-9_-]+)/.test(objectLock)) {
14044
- errors.push("prompt list-template work must include object lock list-template:<id> or list-template:new-<name>.");
14188
+ addTaskbookIssue(
14189
+ issues,
14190
+ "invalid_list_object_lock",
14191
+ "taskbook.list.object_lock",
14192
+ "Prompt \u4E2D\u7684\u5217\u8868\u6A21\u677F\u4EFB\u52A1\u5FC5\u987B\u5305\u542B list-template:<id> \u6216 list-template:new-<name> \u5BF9\u8C61\u9501\u3002",
14193
+ { domain: "list-template", path: "prompt.object_lock" }
14194
+ );
14045
14195
  }
14046
14196
  if (!hasStrongListEvidence(text5)) {
14047
- errors.push("prompt list-template work must include bpmax-cli config list-template lint and real browser list-page verification.");
14197
+ addTaskbookIssue(
14198
+ issues,
14199
+ "missing_list_runtime_proof",
14200
+ "taskbook.list.runtime_proof",
14201
+ "Prompt \u4E2D\u7684\u5217\u8868\u6A21\u677F\u4EFB\u52A1\u5FC5\u987B\u8981\u6C42 list-template lint \u548C\u771F\u5B9E\u5217\u8868\u9875\u9A8C\u8BC1\u3002",
14202
+ { domain: "list-template", path: "prompt.evidence", suggestion: "\u5199\u660E bpmax-cli config list-template lint \u548C\u771F\u5B9E\u6D4F\u89C8\u5668\u5217\u8868\u9875 proof\u3002" }
14203
+ );
14048
14204
  }
14049
14205
  }
14050
14206
  }
14051
- function validatePromptConfigSkillGates(text5, errors) {
14207
+ function validatePromptConfigSkillGates(text5, issues) {
14052
14208
  const objectLock = promptObjectLockText(text5);
14053
14209
  const writeMode = isWriteMode(text5);
14054
14210
  const actionableText = text5.split(/\r?\n/).filter((line) => !/^\s*(导航入口策略|列表 lint)\s*[::]/.test(line)).join("\n");
@@ -14056,84 +14212,146 @@ function validatePromptConfigSkillGates(text5, errors) {
14056
14212
  const hasSkill = text5.includes(rule.skill);
14057
14213
  const mentionsDomain = rule.mentionPattern.test(actionableText) || rule.lockPattern.test(objectLock);
14058
14214
  if (mentionsDomain && !hasSkill) {
14059
- errors.push(`prompt mentions ${rule.domain} work but missing required skill ${rule.skill}.`);
14215
+ addTaskbookIssue(
14216
+ issues,
14217
+ "missing_required_skill",
14218
+ "taskbook.config.required_skill",
14219
+ `Prompt \u63D0\u5230\u4E86 ${rule.domain} \u914D\u7F6E\uFF0C\u4F46\u7F3A\u5C11\u5FC5\u9700 skill\uFF1A${rule.skill}\u3002`,
14220
+ { domain: rule.domain, path: "prompt.required_skills" }
14221
+ );
14060
14222
  continue;
14061
14223
  }
14062
14224
  if (!hasSkill) {
14063
14225
  continue;
14064
14226
  }
14065
14227
  if (writeMode && !rule.lockPattern.test(objectLock)) {
14066
- errors.push(`prompt ${rule.domain} work must include object lock matching ${rule.domain}:<id> or its documented lock pattern.`);
14228
+ addTaskbookIssue(
14229
+ issues,
14230
+ "invalid_object_lock",
14231
+ "taskbook.config.object_lock",
14232
+ `Prompt \u662F ${rule.domain} \u5199\u4EFB\u52A1\uFF0C\u4F46\u5BF9\u8C61\u9501\u4E0D\u7B26\u5408\u8BE5\u914D\u7F6E\u57DF\u8981\u6C42\u3002`,
14233
+ { domain: rule.domain, path: "prompt.object_lock", suggestion: `\u4F7F\u7528 ${rule.domain}:<id>\u3001new-* \u6216\u8BE5\u914D\u7F6E\u57DF\u6587\u6863\u6307\u5B9A\u7684\u5BF9\u8C61\u9501\u683C\u5F0F\u3002` }
14234
+ );
14067
14235
  }
14068
14236
  if (!writeMode && !/^readonly:[A-Za-z0-9_-]+/.test(objectLock) && !rule.lockPattern.test(objectLock)) {
14069
- errors.push(`prompt ${rule.domain} readonly work must include readonly:<scope> or the ${rule.domain} object lock.`);
14237
+ addTaskbookIssue(
14238
+ issues,
14239
+ "invalid_readonly_lock",
14240
+ "taskbook.config.readonly_lock",
14241
+ `Prompt \u662F ${rule.domain} \u53EA\u8BFB\u4EFB\u52A1\uFF0C\u4F46\u7F3A\u5C11 readonly:<scope> \u6216\u5BF9\u5E94\u5BF9\u8C61\u9501\u3002`,
14242
+ { domain: rule.domain, path: "prompt.object_lock" }
14243
+ );
14070
14244
  }
14071
14245
  const hasRequiredEvidence = writeMode ? hasDomainWriteEvidence(rule.domain, text5, rule.writeEvidence) : rule.readonlyEvidence.some((pattern) => pattern.test(text5));
14072
14246
  if (!hasRequiredEvidence) {
14073
14247
  const expected = writeMode ? `bpmax-cli config ${rule.domain} lint/build/submit/verify evidence` : `bpmax-cli config ${rule.domain} export/readback evidence`;
14074
- errors.push(`prompt ${rule.domain} work missing ${expected}.`);
14248
+ addTaskbookIssue(
14249
+ issues,
14250
+ "missing_typed_cli_evidence",
14251
+ "taskbook.config.typed_cli_evidence",
14252
+ `Prompt \u7F3A\u5C11 ${rule.domain} \u7684 typed CLI \u8BC1\u636E\u8981\u6C42\u3002`,
14253
+ { domain: rule.domain, path: "prompt.evidence", suggestion: expected }
14254
+ );
14075
14255
  }
14076
14256
  if (!rule.constraintEvidence.test(text5)) {
14077
- errors.push(`prompt ${rule.domain} work missing domain-specific constraints from ${rule.skill}.`);
14257
+ addTaskbookIssue(
14258
+ issues,
14259
+ "missing_domain_constraints",
14260
+ "taskbook.config.domain_constraints",
14261
+ `Prompt \u7F3A\u5C11\u6765\u81EA ${rule.skill} \u7684 ${rule.domain} \u4E13\u9879\u7EA6\u675F\u8BF4\u660E\u3002`,
14262
+ { domain: rule.domain, path: "prompt.notes" }
14263
+ );
14078
14264
  }
14079
14265
  if (writeMode && !hasConfigAdaptersEvidence(text5)) {
14080
- errors.push(`prompt ${rule.domain} write work missing bpmax-cli config adapters --format json capability/adapters evidence.`);
14266
+ addTaskbookIssue(
14267
+ issues,
14268
+ "missing_config_adapters_evidence",
14269
+ "taskbook.config.adapters_evidence",
14270
+ `Prompt \u662F ${rule.domain} \u5199\u4EFB\u52A1\uFF0C\u4F46\u7F3A\u5C11 config adapters/capability \u68C0\u67E5\u8981\u6C42\u3002`,
14271
+ { domain: rule.domain, path: "prompt.evidence", suggestion: "\u5199\u4EFB\u52A1\u5FC5\u987B\u8981\u6C42 bpmax-cli config adapters --format json \u68C0\u67E5\u3002" }
14272
+ );
14081
14273
  }
14082
14274
  }
14083
14275
  }
14084
14276
  async function lintTaskbook(file, options = {}) {
14085
14277
  const text5 = await readTaskbookText(file);
14086
- const errors = [
14087
- ...missingTermErrors(text5, REQUIRED_TASKBOOK_TERMS, "missing required term"),
14088
- ...missingTermErrors(text5, options.requireTerms || [], "missing required term")
14089
- ];
14278
+ const issues = [];
14279
+ for (const message of missingTermErrors(text5, REQUIRED_TASKBOOK_TERMS, "missing required term")) {
14280
+ addTaskbookIssue(issues, "missing_required_term", "taskbook.required_term", `\u4EFB\u52A1\u4E66\u7F3A\u5C11\u5FC5\u9700\u5185\u5BB9\uFF1A${message.replace(/^missing required term: /, "")}\u3002`);
14281
+ }
14282
+ for (const message of missingTermErrors(text5, options.requireTerms || [], "missing required term")) {
14283
+ addTaskbookIssue(issues, "missing_required_term", "taskbook.required_term", `\u4EFB\u52A1\u4E66\u7F3A\u5C11\u5FC5\u9700\u5185\u5BB9\uFF1A${message.replace(/^missing required term: /, "")}\u3002`);
14284
+ }
14090
14285
  for (const term of options.forbidTerms || []) {
14091
14286
  if (term && text5.includes(term)) {
14092
- errors.push(`forbidden term present: ${term}`);
14287
+ addTaskbookIssue(issues, "forbidden_term_present", "taskbook.forbidden_term", `\u4EFB\u52A1\u4E66\u5305\u542B\u7981\u7528\u8BCD\uFF1A${term}\u3002`);
14093
14288
  }
14094
14289
  }
14095
14290
  if (!options.allowGeneratedFlowTypeMissing) {
14096
- errors.push(...missingTermErrors(text5, GENERATED_FLOW_TYPE_TERMS, "missing generated flow_type rule term"));
14291
+ for (const message of missingTermErrors(text5, GENERATED_FLOW_TYPE_TERMS, "missing generated flow_type rule term")) {
14292
+ addTaskbookIssue(issues, "missing_generated_flow_type_rule", "taskbook.generated_flow_type", `\u4EFB\u52A1\u4E66\u7F3A\u5C11\u65B0\u6D41\u7A0B\u771F\u5B9E flow_type \u56DE\u586B\u89C4\u5219\uFF1A${message.replace(/^missing generated flow_type rule term: /, "")}\u3002`);
14293
+ }
14294
+ }
14295
+ addUuidIssues(text5, issues, "taskbook");
14296
+ for (const message of missingTermErrors(text5, SUBAGENT_TERMS, "missing subagent rule term")) {
14297
+ addTaskbookIssue(issues, "missing_subagent_rule", "taskbook.subagent_rule", `\u4EFB\u52A1\u4E66\u7F3A\u5C11 subagent \u89C4\u5219\uFF1A${message.replace(/^missing subagent rule term: /, "")}\u3002`);
14097
14298
  }
14098
- errors.push(...uuidErrors(text5, "taskbooks"));
14099
- errors.push(...missingTermErrors(text5, SUBAGENT_TERMS, "missing subagent rule term"));
14100
- validateTaskbookNavigationAndListGates(text5, errors);
14101
- validateTaskbookConfigSkillGates(text5, errors);
14299
+ validateTaskbookNavigationAndListGates(text5, issues);
14300
+ validateTaskbookConfigSkillGates(text5, issues);
14102
14301
  for (const match of text5.matchAll(FLOW_LOCK_PATTERN)) {
14103
14302
  const value = match[1] || "";
14104
14303
  if (value.startsWith("flow") && /^flow\d+$/.test(value)) {
14105
14304
  continue;
14106
14305
  }
14107
- errors.push(`possible self-defined flow_type object lock: flow:${value}; use new-flow:<name> before creation, then flow:<generated flow_type>`);
14306
+ addTaskbookIssue(
14307
+ issues,
14308
+ "self_defined_flow_type_lock",
14309
+ "taskbook.flow_type.generated_id",
14310
+ `\u5BF9\u8C61\u9501 flow:${value} \u7591\u4F3C\u81EA\u9020 flow_type\u3002`,
14311
+ { path: "object_lock", suggestion: "\u65B0\u6D41\u7A0B\u521B\u5EFA\u524D\u4F7F\u7528 new-flow:<name>\uFF0C\u521B\u5EFA\u540E\u56DE\u586B BPMAX \u751F\u6210\u7684\u771F\u5B9E flow_type\u3002" }
14312
+ );
14108
14313
  }
14314
+ const errors = uniqueErrors(issueMessages(issues));
14109
14315
  return {
14110
14316
  ok: errors.length === 0,
14111
14317
  file,
14112
- errors: uniqueErrors(errors),
14318
+ errors,
14319
+ issues,
14113
14320
  checked_at: (/* @__PURE__ */ new Date()).toISOString()
14114
14321
  };
14115
14322
  }
14116
14323
  async function lintTaskPrompt(file, options = {}) {
14117
14324
  const text5 = await readTaskbookText(file);
14118
- const errors = [
14119
- ...missingTermErrors(text5, PROMPT_REQUIRED_TERMS, "prompt missing required term"),
14120
- ...missingTermErrors(text5, options.requireTerms || [], "prompt missing required term")
14121
- ];
14325
+ const issues = [];
14326
+ for (const message of missingTermErrors(text5, PROMPT_REQUIRED_TERMS, "prompt missing required term")) {
14327
+ addTaskbookIssue(issues, "missing_prompt_required_term", "taskbook.prompt.required_term", `Prompt \u7F3A\u5C11\u5FC5\u9700\u5185\u5BB9\uFF1A${message.replace(/^prompt missing required term: /, "")}\u3002`);
14328
+ }
14329
+ for (const message of missingTermErrors(text5, options.requireTerms || [], "prompt missing required term")) {
14330
+ addTaskbookIssue(issues, "missing_prompt_required_term", "taskbook.prompt.required_term", `Prompt \u7F3A\u5C11\u5FC5\u9700\u5185\u5BB9\uFF1A${message.replace(/^prompt missing required term: /, "")}\u3002`);
14331
+ }
14122
14332
  if (!BPMAX_SKILL_PATTERN.test(text5)) {
14123
- errors.push("prompt missing BPMAX related skill name in required_skills");
14333
+ addTaskbookIssue(
14334
+ issues,
14335
+ "missing_bpmax_skill",
14336
+ "taskbook.prompt.required_skill",
14337
+ "Prompt \u7F3A\u5C11 BPMAX \u76F8\u5173 skill \u540D\u79F0\u3002",
14338
+ { path: "prompt.required_skills", suggestion: "\u5728 required_skills \u4E2D\u5199\u660E\u5BF9\u5E94\u7684 bpmax-* \u914D\u7F6E skill\u3002" }
14339
+ );
14124
14340
  }
14125
- errors.push(...uuidErrors(text5, "task prompts"));
14126
- validatePromptNavigationAndListGates(text5, errors);
14127
- validatePromptConfigSkillGates(text5, errors);
14341
+ addUuidIssues(text5, issues, "prompt");
14342
+ validatePromptNavigationAndListGates(text5, issues);
14343
+ validatePromptConfigSkillGates(text5, issues);
14128
14344
  for (const term of options.forbidTerms || []) {
14129
14345
  if (term && text5.includes(term)) {
14130
- errors.push(`prompt forbidden term present: ${term}`);
14346
+ addTaskbookIssue(issues, "forbidden_term_present", "taskbook.prompt.forbidden_term", `Prompt \u5305\u542B\u7981\u7528\u8BCD\uFF1A${term}\u3002`);
14131
14347
  }
14132
14348
  }
14349
+ const errors = uniqueErrors(issueMessages(issues));
14133
14350
  return {
14134
14351
  ok: errors.length === 0,
14135
14352
  file,
14136
- errors: uniqueErrors(errors),
14353
+ errors,
14354
+ issues,
14137
14355
  checked_at: (/* @__PURE__ */ new Date()).toISOString()
14138
14356
  };
14139
14357
  }
@@ -14459,6 +14677,17 @@ var IDENTITY_MOCK_CASE_RE = /(非处理人|越权|只读|多角色|角色隔离|
14459
14677
  var IDENTITY_MOCK_VALUE_RE = /(mock|模拟).*(unmock|退出模拟|恢复)|bpmax-user-mock-operator/;
14460
14678
  var E2E_REUSABLE_ASSET_RE = /bpmax-cli\s+e2e|record-from-evidence|create-page-submit|step-run|browser-template|scenario\s+plan|data\s+profile|reusable\s+step|复用模板|可复用|首次运行沉淀|沉淀模板/;
14461
14679
  var TestSuiteError = class extends Error {
14680
+ code;
14681
+ rule_id;
14682
+ path;
14683
+ suggestion;
14684
+ constructor(message, options = {}) {
14685
+ super(message);
14686
+ this.code = options.code || "test_suite_lint_failed";
14687
+ this.rule_id = options.rule_id || "test_suite.general";
14688
+ this.path = options.path;
14689
+ this.suggestion = options.suggestion;
14690
+ }
14462
14691
  };
14463
14692
  async function exists3(filePath) {
14464
14693
  try {
@@ -14471,8 +14700,8 @@ async function exists3(filePath) {
14471
14700
  async function readText(filePath) {
14472
14701
  return readFile15(filePath, "utf8");
14473
14702
  }
14474
- function fail(message) {
14475
- throw new TestSuiteError(message);
14703
+ function fail(message, options = {}) {
14704
+ throw new TestSuiteError(message, options);
14476
14705
  }
14477
14706
  function reviewSchemaExample(scenarioId = "example-scenario", latestProof = null) {
14478
14707
  return {
@@ -14524,12 +14753,20 @@ function reviewSchemaExplanation() {
14524
14753
  }
14525
14754
  function reviewFail(reviewPath, message) {
14526
14755
  const scenarioId = path12.basename(path12.dirname(reviewPath));
14527
- fail([
14528
- message,
14529
- `Run \`bpmax-cli test-suite review explain --format json\` for the full schema.`,
14530
- `Run \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path12.dirname(path12.dirname(reviewPath))} --latest-proof <proof.json> --format json\` to fill missing fields.`,
14531
- `Minimal review.json example: ${JSON.stringify(reviewSchemaExample(scenarioId))}`
14532
- ].join("\n"));
14756
+ fail(
14757
+ [
14758
+ message,
14759
+ "\u8FD0\u884C `bpmax-cli test-suite review explain --format json` \u67E5\u770B\u5B8C\u6574 schema\u3002",
14760
+ `\u8FD0\u884C \`bpmax-cli test-suite review repair --scenario ${scenarioId} --draft-root ${path12.dirname(path12.dirname(reviewPath))} --latest-proof <proof.json> --format json\` \u4FEE\u8865\u7F3A\u5931\u5B57\u6BB5\u3002`,
14761
+ `\u6700\u5C0F review.json \u793A\u4F8B\uFF1A${JSON.stringify(reviewSchemaExample(scenarioId))}`
14762
+ ].join("\n"),
14763
+ {
14764
+ code: "invalid_review_json",
14765
+ rule_id: "test_suite.review_schema",
14766
+ path: reviewPath,
14767
+ suggestion: "\u5148\u7528 review init/repair \u751F\u6210\u6216\u4FEE\u590D review.json\uFF0C\u518D\u6267\u884C promote\u3002"
14768
+ }
14769
+ );
14533
14770
  }
14534
14771
  function splitCsvLine(line) {
14535
14772
  const values = [];
@@ -15917,10 +16154,15 @@ function commandEndpointHint(argv) {
15917
16154
  }
15918
16155
  function printCommandError(error) {
15919
16156
  const message = error instanceof Error ? error.message : String(error);
16157
+ const structured = error && typeof error === "object" ? error : {};
15920
16158
  if (formatFromArgv(process.argv) === "json") {
15921
16159
  console.log(JSON.stringify({
15922
16160
  ok: false,
15923
16161
  error: message,
16162
+ ...typeof structured.code === "string" ? { code: structured.code } : {},
16163
+ ...typeof structured.rule_id === "string" ? { rule_id: structured.rule_id } : {},
16164
+ ...typeof structured.path === "string" ? { path: structured.path } : {},
16165
+ ...typeof structured.suggestion === "string" ? { suggestion: structured.suggestion } : {},
15924
16166
  ...commandDomainFromArgv(process.argv) ? { domain: commandDomainFromArgv(process.argv) } : {},
15925
16167
  ...commandEndpointHint(process.argv) ? { endpoint: commandEndpointHint(process.argv) } : {}
15926
16168
  }, null, 2));