@hcmai/cli 0.24.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1643 -935
- package/dist/index.js.map +1 -1
- package/dist/skills/manifest.json +4 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -7237,23 +7237,38 @@ async function inspectJira(opts = {}) {
|
|
|
7237
7237
|
});
|
|
7238
7238
|
return res;
|
|
7239
7239
|
};
|
|
7240
|
+
const unreachable2 = (e) => ({ ok: false, code: "JIRA_UNREACHABLE", from: src.from, reason: `\u8FDE\u4E0D\u4E0A ${JIRA_BASE}\uFF1A${e.message}` });
|
|
7241
|
+
let me;
|
|
7240
7242
|
try {
|
|
7241
|
-
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
|
|
7247
|
-
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7252
|
-
|
|
7253
|
-
}
|
|
7243
|
+
me = await call("/rest/api/2/myself");
|
|
7244
|
+
} catch (e) {
|
|
7245
|
+
return unreachable2(e);
|
|
7246
|
+
}
|
|
7247
|
+
if (me.status === 401) return { ok: false, code: "JIRA_TOKEN_REJECTED", from: src.from, reason: "\u4EE4\u724C\u65E0\u6548\u6216\u5DF2\u8FC7\u671F\uFF0C\u91CD\u5EFA PAT \u540E\u91CD\u65B0\u5B58\u4E00\u6B21" };
|
|
7248
|
+
if (!me.ok) return { ok: false, code: "JIRA_SERVER_ERROR", from: src.from, reason: `\u8FDE\u5F97\u4E0A\u4F46 /myself \u8FD4\u56DE ${me.status}` };
|
|
7249
|
+
let who2;
|
|
7250
|
+
try {
|
|
7251
|
+
who2 = (await me.json()).displayName ?? "";
|
|
7252
|
+
} catch (e) {
|
|
7253
|
+
if (e.name === "TimeoutError" || e.name === "AbortError") {
|
|
7254
|
+
return { ok: false, code: "JIRA_UNREACHABLE", from: src.from, reason: `\u8FDE\u4E0A\u4E86 ${JIRA_BASE}\uFF0C\u4F46\u8BFB /myself \u7684\u6B63\u6587\u8D85\u65F6\uFF08\u7F51\u7EDC\u6216\u4EE3\u7406\u4E2D\u9014\u65AD\u4E86\uFF09\uFF1A${e.message}` };
|
|
7255
|
+
}
|
|
7256
|
+
return { ok: false, code: "JIRA_SERVER_ERROR", from: src.from, reason: `\u8FDE\u5F97\u4E0A\uFF0C/myself \u8FD4\u56DE ${me.status} \u4F46\u6B63\u6587\u8BFB\u4E0D\u6210 JSON\uFF08\u591A\u534A\u662F\u4EE3\u7406\u6216\u5355\u70B9\u767B\u5F55\u9875\uFF09\uFF1A${e.message}` };
|
|
7257
|
+
}
|
|
7258
|
+
let project2;
|
|
7259
|
+
try {
|
|
7260
|
+
project2 = await call(`/rest/api/2/project/${JIRA_PROJECT}`);
|
|
7254
7261
|
} catch (e) {
|
|
7255
|
-
return
|
|
7262
|
+
return unreachable2(e);
|
|
7256
7263
|
}
|
|
7264
|
+
return {
|
|
7265
|
+
ok: project2.ok,
|
|
7266
|
+
code: project2.ok ? void 0 : [403, 404].includes(project2.status) ? "JIRA_PROJECT_INVISIBLE" : "JIRA_SERVER_ERROR",
|
|
7267
|
+
from: src.from,
|
|
7268
|
+
who: who2,
|
|
7269
|
+
projectVisible: project2.ok,
|
|
7270
|
+
reason: project2.ok ? void 0 : [403, 404].includes(project2.status) ? `\u770B\u4E0D\u5230\u9879\u76EE ${JIRA_PROJECT}\uFF08${project2.status}\uFF09\uFF0C\u627E Jira \u7BA1\u7406\u5458\u5F00\u6743\u9650` : `\u9879\u76EE\u63A5\u53E3\u8FD4\u56DE ${project2.status}\uFF0C\u68C0\u67E5 Jira \u670D\u52A1\u540E\u91CD\u8BD5`
|
|
7271
|
+
};
|
|
7257
7272
|
}
|
|
7258
7273
|
|
|
7259
7274
|
// src/commands/skills-bundled.ts
|
|
@@ -7591,6 +7606,20 @@ async function chironClient(args) {
|
|
|
7591
7606
|
});
|
|
7592
7607
|
return { http, endpoint, base: await resolveChironBase(http) };
|
|
7593
7608
|
}
|
|
7609
|
+
async function beforeAnyWrite(step2) {
|
|
7610
|
+
try {
|
|
7611
|
+
return await step2;
|
|
7612
|
+
} catch (e) {
|
|
7613
|
+
if (e instanceof CliError21 && e.code === CliErrorCode22.SKILL_CATALOG_UNAVAILABLE) {
|
|
7614
|
+
throw new CliError21({
|
|
7615
|
+
code: e.code,
|
|
7616
|
+
message: e.message,
|
|
7617
|
+
context: { ...e.context, note: "\u53D6\u76EE\u5F55\u8FD9\u4E00\u6B65\u5C31\u505C\u4E86\uFF0C\u540E\u9762\u7684\u5199\u5165\u4E0E\u6E05\u7406\u90FD\u6CA1\u6709\u6267\u884C\uFF1A\u5DF2\u88C5\u6280\u80FD\u4E00\u4EFD\u6CA1\u5220\u3001\u4E00\u4EFD\u6CA1\u6539\u3002" }
|
|
7618
|
+
});
|
|
7619
|
+
}
|
|
7620
|
+
throw e;
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7594
7623
|
function fail6(e, args) {
|
|
7595
7624
|
const err = e;
|
|
7596
7625
|
if (err?.response?.status === 404) {
|
|
@@ -7911,11 +7940,11 @@ async function skillsInstallCommand(id, args) {
|
|
|
7911
7940
|
}),
|
|
7912
7941
|
recorded: (await readSkillsState(layout.baseDir))?.endpoint
|
|
7913
7942
|
});
|
|
7914
|
-
const client3 = await chironClient({ ...args, endpoint: tracked });
|
|
7943
|
+
const client3 = await beforeAnyWrite(chironClient({ ...args, endpoint: tracked }));
|
|
7915
7944
|
endpoint = client3.endpoint;
|
|
7916
7945
|
base = client3.base;
|
|
7917
7946
|
http = client3.http;
|
|
7918
|
-
manifest2 = await fetchSkillCatalog(http, base);
|
|
7947
|
+
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http, base));
|
|
7919
7948
|
}
|
|
7920
7949
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
7921
7950
|
const conflicts = detectIdConflicts(catalog);
|
|
@@ -8150,12 +8179,41 @@ async function ensureLocalSlot(localDir) {
|
|
|
8150
8179
|
await fsp2.mkdir(localDir, { recursive: true });
|
|
8151
8180
|
await fsp2.writeFile(keep, "# \u4F60\u81EA\u5DF1\u5199\u7684\u6280\u80FD\u653E\u8FD9\u513F\u3002hcm chiron skills sync \u53EA\u7BA1\u9694\u58C1 sync/\uFF0C\u4E00\u4E2A\u5B57\u8282\u90FD\u4E0D\u78B0\u8FD9\u91CC\u3002\n", "utf8");
|
|
8152
8181
|
}
|
|
8153
|
-
|
|
8182
|
+
var isNotFound = (e) => ["ENOENT", "ENOTDIR"].includes(String(e?.code));
|
|
8183
|
+
var SkillsDirUnreadable = class extends Error {
|
|
8184
|
+
constructor(side, dir, id, cause) {
|
|
8185
|
+
const where = id ? path8.join(dir, id, "SKILL.md") : dir, detail = cause instanceof Error ? cause.message : String(cause);
|
|
8186
|
+
super(`${where}\uFF1A${detail}`);
|
|
8187
|
+
this.side = side;
|
|
8188
|
+
this.id = id;
|
|
8189
|
+
this.name = "SkillsDirUnreadable";
|
|
8190
|
+
this.where = where;
|
|
8191
|
+
this.detail = detail;
|
|
8192
|
+
this.code = typeof cause?.code === "string" ? cause.code : void 0;
|
|
8193
|
+
}
|
|
8194
|
+
side;
|
|
8195
|
+
id;
|
|
8196
|
+
/** 读不了的那个路径(目录本身,或 <dir>/<id>/SKILL.md)。 */
|
|
8197
|
+
where;
|
|
8198
|
+
/** 原始报错。 */
|
|
8199
|
+
detail;
|
|
8200
|
+
/** errno(ELOOP / EISDIR / EACCES…):下一步按它说该怎么修。 */
|
|
8201
|
+
code;
|
|
8202
|
+
};
|
|
8203
|
+
function unreadableFix(code2, detail) {
|
|
8204
|
+
if (code2 === "ELOOP") return "\u8FD9\u6761\u8DEF\u5F84\u662F\u6307\u5411\u81EA\u5DF1\uFF08\u6216\u6210\u73AF\uFF09\u7684\u7B26\u53F7\u94FE\u63A5\uFF0C\u5220\u6389\u6216\u6539\u6307\u5411\u771F\u5B9E\u7684\u6280\u80FD\u76EE\u5F55 / SKILL.md \u6587\u4EF6";
|
|
8205
|
+
if (code2 === "EISDIR") return "\u5B83\u7684 SKILL.md \u662F\u4E2A\u76EE\u5F55\uFF0C\u6539\u56DE\u6587\u4EF6";
|
|
8206
|
+
if (code2 === "EACCES" || code2 === "EPERM") return "\u6CA1\u6709\u8BFB\u53D6\u6743\u9650\uFF0C\u4FEE\u597D\u6743\u9650";
|
|
8207
|
+
return `\u8BFB\u53D6\u62A5 ${code2 ?? (detail || "\u672A\u77E5\u9519\u8BEF")}\uFF0C\u6309\u8FD9\u4E2A\u62A5\u9519\u4FEE\u597D`;
|
|
8208
|
+
}
|
|
8209
|
+
var describeUnreadable = (list) => list.map((u) => `${u.id ?? path8.basename(u.where)}\uFF08${unreadableFix(u.code, u.detail)}\uFF09`).join("\u3001");
|
|
8210
|
+
async function readLocalSkills(localDir, { strict = false } = {}) {
|
|
8154
8211
|
if (!localDir) return [];
|
|
8155
8212
|
let names;
|
|
8156
8213
|
try {
|
|
8157
8214
|
names = (await fsp2.readdir(localDir, { withFileTypes: true })).filter((e) => e.isDirectory() && !e.name.startsWith(".")).map((e) => e.name);
|
|
8158
|
-
} catch {
|
|
8215
|
+
} catch (e) {
|
|
8216
|
+
if (strict && !isNotFound(e)) throw new SkillsDirUnreadable("local", localDir, void 0, e);
|
|
8159
8217
|
return [];
|
|
8160
8218
|
}
|
|
8161
8219
|
const out = [];
|
|
@@ -8164,7 +8222,8 @@ async function readLocalSkills(localDir) {
|
|
|
8164
8222
|
let markdown;
|
|
8165
8223
|
try {
|
|
8166
8224
|
markdown = await fsp2.readFile(absolute, "utf8");
|
|
8167
|
-
} catch {
|
|
8225
|
+
} catch (e) {
|
|
8226
|
+
if (strict && !isNotFound(e)) throw new SkillsDirUnreadable("local", localDir, id, e);
|
|
8168
8227
|
continue;
|
|
8169
8228
|
}
|
|
8170
8229
|
let title = id;
|
|
@@ -8177,10 +8236,72 @@ async function readLocalSkills(localDir) {
|
|
|
8177
8236
|
}
|
|
8178
8237
|
} catch {
|
|
8179
8238
|
}
|
|
8180
|
-
out.push({ id, title, description, absolute });
|
|
8239
|
+
out.push({ id, title, description, absolute, firstLine: firstMeaningfulLine(description, markdown) });
|
|
8181
8240
|
}
|
|
8182
8241
|
return out;
|
|
8183
8242
|
}
|
|
8243
|
+
function firstMeaningfulLine(description, markdown) {
|
|
8244
|
+
const fromDescription = description.split(/\r?\n/).map((l) => l.trim()).find(Boolean);
|
|
8245
|
+
if (fromDescription) return fromDescription;
|
|
8246
|
+
const body = markdown.replace(/^---\r?\n[\s\S]*?\r?\n---\r?\n?/, "");
|
|
8247
|
+
return body.split(/\r?\n/).map((l) => l.replace(/^#+\s*/, "").trim()).find((l) => l && !/^-{3,}$/.test(l)) ?? "\u6CA1\u6709\u8BF4\u660E";
|
|
8248
|
+
}
|
|
8249
|
+
async function listShadowedSkills(layout) {
|
|
8250
|
+
const locals = await readLocalSkills(layout.localDir, { strict: true });
|
|
8251
|
+
const isProduct = async (id) => {
|
|
8252
|
+
try {
|
|
8253
|
+
await fsp2.stat(path8.join(layout.baseDir, id, "SKILL.md"));
|
|
8254
|
+
return true;
|
|
8255
|
+
} catch (e) {
|
|
8256
|
+
if (!isNotFound(e)) throw new SkillsDirUnreadable("sync", layout.baseDir, id, e);
|
|
8257
|
+
return false;
|
|
8258
|
+
}
|
|
8259
|
+
};
|
|
8260
|
+
let names = [];
|
|
8261
|
+
try {
|
|
8262
|
+
names = (await fsp2.readdir(layout.baseDir)).filter((n) => !n.startsWith("."));
|
|
8263
|
+
} catch (e) {
|
|
8264
|
+
if (!isNotFound(e)) throw new SkillsDirUnreadable("sync", layout.baseDir, void 0, e);
|
|
8265
|
+
}
|
|
8266
|
+
const unreadable = [];
|
|
8267
|
+
let product = 0;
|
|
8268
|
+
for (const n of names) {
|
|
8269
|
+
try {
|
|
8270
|
+
if (await isProduct(n)) product++;
|
|
8271
|
+
} catch (e) {
|
|
8272
|
+
if (!(e instanceof SkillsDirUnreadable)) throw e;
|
|
8273
|
+
unreadable.push(e);
|
|
8274
|
+
}
|
|
8275
|
+
}
|
|
8276
|
+
const shadowed = [];
|
|
8277
|
+
for (const s of locals) {
|
|
8278
|
+
if (await isProduct(s.id)) shadowed.push({ id: s.id, local: s.absolute, product: path8.join(layout.baseDir, s.id, "SKILL.md"), note: s.firstLine });
|
|
8279
|
+
}
|
|
8280
|
+
return { local: locals.length, product, shadowed, unreadable };
|
|
8281
|
+
}
|
|
8282
|
+
var SHADOW_HINT = `\u906E\u853D\u672C\u8EAB\u5408\u6CD5\uFF0C\u4F46\u540C\u540D\u65F6\u751F\u6548\u7684\u662F ${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u90A3\u4EFD\uFF0C\u4EA7\u54C1\u7248\u7684\u66F4\u65B0\u5230\u4E0D\u4E86\u8FD9\u91CC\u3002\u8FD9\u662F\u7ED5\u8FC7\u4EA7\u54C1\u7F3A\u53E3\u7684\u529E\u6CD5\u5417\uFF1F\u662F\u5C31\u63D0\u7F3A\u53E3\uFF1Ahcm chiron gap submit --file <\u7F3A\u53E3.json>\uFF0C\u8F7D\u8377\u91CC\u5199 local_workaround\uFF08local/ \u90A3\u4EFD\u6539\u4E86\u4EC0\u4E48\uFF09\uFF1B\u4EA7\u54C1\u4FEE\u597D\u540E\u5220\u6389 local/ \u90A3\u4EFD\u3002`;
|
|
8283
|
+
var describeShadows = (shadowed) => shadowed.map((s) => `${s.id}\uFF08${s.note}\uFF09`).join("\u3001");
|
|
8284
|
+
async function reportLocalShadows(args) {
|
|
8285
|
+
const layout = await resolveInstallLayout(args).catch(() => null);
|
|
8286
|
+
if (!layout?.localDir) return;
|
|
8287
|
+
try {
|
|
8288
|
+
const { shadowed, unreadable } = await listShadowedSkills(layout);
|
|
8289
|
+
if (unreadable.length) {
|
|
8290
|
+
process.stderr.write(`\u26A0\uFE0F ${SKILLS_DIR}/sync/ \u91CC\u6709 ${unreadable.length} \u6761\u8BFB\u4E0D\u4E86\uFF0C\u6CA1\u7B97\u8FDB\u4EA7\u54C1\u6280\u80FD\uFF08\u4E0E local/ \u65E0\u5173\uFF0C\u4E0D\u5F71\u54CD\u906E\u853D\u5224\u65AD\uFF09\uFF1A${describeUnreadable(unreadable)}
|
|
8291
|
+
`);
|
|
8292
|
+
}
|
|
8293
|
+
if (!shadowed.length) return;
|
|
8294
|
+
process.stderr.write(`\u26A0\uFE0F ${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u853D\u4E86 ${shadowed.length} \u4EFD\u4EA7\u54C1\u6280\u80FD\uFF1A${describeShadows(shadowed)}
|
|
8295
|
+
${SHADOW_HINT}
|
|
8296
|
+
`);
|
|
8297
|
+
} catch (e) {
|
|
8298
|
+
const u = e instanceof SkillsDirUnreadable ? e : void 0;
|
|
8299
|
+
const side = `${u?.side === "sync" ? `${SKILLS_DIR}/sync/` : `${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/`}${u?.id ? ` \u91CC\u7684 ${u.id}` : ""}`;
|
|
8300
|
+
const index = u?.side === "sync" ? "" : u?.id ? "\uFF1BAGENTS.md \u7684\u6280\u80FD\u7D22\u5F15\u8FD9\u6B21\u7F3A\u4E86\u5B83\uFF08\u53EF\u80FD\u4E0D\u6B62\u8FD9\u4E00\u4EFD\uFF09\uFF0Csync/ \u91CC\u6709\u540C\u540D\u7684\u5C31\u6307\u56DE\u4E86\u4EA7\u54C1\u7248" : "\uFF1BAGENTS.md \u7684\u6280\u80FD\u7D22\u5F15\u8FD9\u6B21\u4E00\u4EFD local/ \u6280\u80FD\u90FD\u6CA1\u5217\u8FDB\u53BB\uFF0C\u4E0E sync/ \u540C\u540D\u7684\u90FD\u6307\u56DE\u4E86\u4EA7\u54C1\u7248";
|
|
8301
|
+
process.stderr.write(`\u26A0\uFE0F ${side} \u8BFB\u4E0D\u4E86\uFF0C\u6CA1\u6CD5\u5217\u51FA\u88AB local/ \u906E\u853D\u7684\u4EA7\u54C1\u6280\u80FD${index}\uFF1A${e.message}${u ? `\uFF1B${unreadableFix(u.code, u.detail)}` : ""}
|
|
8302
|
+
`);
|
|
8303
|
+
}
|
|
8304
|
+
}
|
|
8184
8305
|
async function resolveSkillPath(layout, id) {
|
|
8185
8306
|
assertSafeSkillId(id);
|
|
8186
8307
|
const at = async (dir) => {
|
|
@@ -8943,10 +9064,10 @@ async function skillsUpdateCommand(args) {
|
|
|
8943
9064
|
let base;
|
|
8944
9065
|
let http;
|
|
8945
9066
|
if (source !== "cli") {
|
|
8946
|
-
const client3 = await chironClient({ ...args, endpoint });
|
|
9067
|
+
const client3 = await beforeAnyWrite(chironClient({ ...args, endpoint }));
|
|
8947
9068
|
http = client3.http;
|
|
8948
9069
|
base = client3.base;
|
|
8949
|
-
manifest2 = await fetchSkillCatalog(http, base);
|
|
9070
|
+
manifest2 = await beforeAnyWrite(fetchSkillCatalog(http, base));
|
|
8950
9071
|
}
|
|
8951
9072
|
const bundled = source === "chiron" ? void 0 : listBundledSkills();
|
|
8952
9073
|
const catalog = buildUnifiedCatalog({ source, chironManifest: manifest2, bundled, cliVersion: CLI_VERSION });
|
|
@@ -9219,10 +9340,12 @@ async function skillsSyncCommand(args, deps = defaultSkillsSyncDeps) {
|
|
|
9219
9340
|
await deps.install(id, { ...args, all: false });
|
|
9220
9341
|
if (process.exitCode && process.exitCode !== 0) return;
|
|
9221
9342
|
}
|
|
9222
|
-
|
|
9343
|
+
} else if (await deps.managed(args)) {
|
|
9344
|
+
await deps.reconcile({ ...args, all: true });
|
|
9345
|
+
} else {
|
|
9346
|
+
await deps.install(void 0, { ...args, all: true });
|
|
9223
9347
|
}
|
|
9224
|
-
if (
|
|
9225
|
-
return deps.install(void 0, { ...args, all: true });
|
|
9348
|
+
if (!process.exitCode) await (deps.shadows ?? reportLocalShadows)(args);
|
|
9226
9349
|
}
|
|
9227
9350
|
|
|
9228
9351
|
// src/commands/tenant.ts
|
|
@@ -12455,7 +12578,7 @@ async function chironInitCommand(args, deps) {
|
|
|
12455
12578
|
// src/commands/gap.ts
|
|
12456
12579
|
import { readFileSync as readFileSync6 } from "fs";
|
|
12457
12580
|
import {
|
|
12458
|
-
CliErrorCode as
|
|
12581
|
+
CliErrorCode as CliErrorCode32,
|
|
12459
12582
|
createHttpClient as createHttpClient4,
|
|
12460
12583
|
formatObject as formatObject27,
|
|
12461
12584
|
loadGlobalConfig as loadGlobalConfig10,
|
|
@@ -12467,802 +12590,1167 @@ init_exit();
|
|
|
12467
12590
|
import { createJiraClient } from "@hcmai/sdk";
|
|
12468
12591
|
|
|
12469
12592
|
// src/jira/gaps.ts
|
|
12470
|
-
import { CASES_REPO_SLUG as
|
|
12471
|
-
import { linkedRepoRefs, parseRef } from "@hcmai/sdk";
|
|
12472
|
-
|
|
12473
|
-
|
|
12474
|
-
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
|
|
12478
|
-
|
|
12479
|
-
|
|
12480
|
-
|
|
12481
|
-
|
|
12482
|
-
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12491
|
-
|
|
12492
|
-
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
|
|
12496
|
-
if (
|
|
12497
|
-
|
|
12498
|
-
|
|
12593
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError30, CliErrorCode as CliErrorCode31, describeNonBmpHits, findNonBmpChars, firstLine as firstLine3, repoIssueUrl } from "@hcmai/sdk";
|
|
12594
|
+
import { linkedRepoRefs, parseRef as parseRef2 } from "@hcmai/sdk";
|
|
12595
|
+
|
|
12596
|
+
// src/jira/gap-verify.ts
|
|
12597
|
+
import {
|
|
12598
|
+
CASES_REPO_SLUG as CASES_REPO_SLUG2,
|
|
12599
|
+
CliError as CliError29,
|
|
12600
|
+
CliErrorCode as CliErrorCode30,
|
|
12601
|
+
JiraHttpError,
|
|
12602
|
+
JiraNonBmpContentError,
|
|
12603
|
+
NON_BMP_RULE_NOTE,
|
|
12604
|
+
firstLine as firstLine2,
|
|
12605
|
+
nonBmpHitLines,
|
|
12606
|
+
parseRef
|
|
12607
|
+
} from "@hcmai/sdk";
|
|
12608
|
+
var VERIFY_RESULTS = ["pass", "fail", "partial"];
|
|
12609
|
+
var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
|
|
12610
|
+
var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
|
|
12611
|
+
var CLOSED_STATUS = "CLOSE";
|
|
12612
|
+
var DUPLICATE_STATUS = "\u91CD\u590D\u95EE\u9898";
|
|
12613
|
+
var DONE_RESOLUTION = "\u5B8C\u6210";
|
|
12614
|
+
var DUPLICATE_RESOLUTION = "\u91CD\u590D\u63D0\u4EA4";
|
|
12615
|
+
var isDuplicateGap = (s) => s.status === DUPLICATE_STATUS || s.resolution === DUPLICATE_RESOLUTION;
|
|
12616
|
+
var DUPLICATE_ADVICE = "\u8FD9\u5F20\u88AB\u5224\u4E3A\u91CD\u590D\u5355\u3002\u53BB\u5B83\u8BC4\u8BBA\u91CC\u6307\u5411\u7684\u539F\u5355\u770B\u8FDB\u5EA6\u3001\u5728\u539F\u5355\u4E0A\u8FFD\u52A0\uFF0C\u4E0D\u5F80\u8FD9\u5F20\u5199";
|
|
12617
|
+
var DUPLICATE_PASS_ADVICE = "\u590D\u9A8C\u7ED3\u8BBA\u8981\u843D\u5728\u539F\u5355\u4E0A\uFF1A\u53BB\u5B83\u8BC4\u8BBA\u91CC\u6307\u5411\u7684\u539F\u5355\u770B\u8FDB\u5EA6\uFF0C\u539F\u5355\u5230\u300C\u5DF2\u4FEE\u590D\u300D\u540E\u7531\u539F\u5355\u63D0\u5355\u4EBA\u8DD1 `hcm chiron gap verify <\u539F\u5355> --result pass --body <\u8BC1\u636E>`\uFF1B\u4F60\u8FD9\u8FB9\u6CA1\u6709\u65B0\u73B0\u573A\u5C31\u4E0D\u5FC5\u8FFD\u52A0";
|
|
12618
|
+
function terminalGapHint(s) {
|
|
12619
|
+
if (isDuplicateGap(s)) return DUPLICATE_ADVICE;
|
|
12620
|
+
return s.status === CLOSED_STATUS ? closedGapHint(s) : void 0;
|
|
12621
|
+
}
|
|
12622
|
+
function closedGapHint(s) {
|
|
12623
|
+
if (s.resolution === DUPLICATE_RESOLUTION) return DUPLICATE_ADVICE;
|
|
12624
|
+
return s.resolution === DONE_RESOLUTION ? `\u8FD9\u5F20\u5DF2\u590D\u9A8C\u5173\u95ED\uFF0C\u4E0D\u80FD\u8FFD\u52A0\uFF1A\u4F60\u7684\u73AF\u5883\u65E9\u4E8E\u4FEE\u590D\u5C31\u5347\u7EA7\u540E\u518D\u770B\uFF1B\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\u5C31 \`hcm chiron gap submit --new\` \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${s.key}\uFF08submit \u4F1A\u6309\u4F60\u7684\u73AF\u5883\u7248\u672C\u8BF4\u6E05\u662F\u54EA\u79CD\uFF09` : `\u8FD9\u5F20\u6CA1\u4FEE\u5C31\u5173\u4E86\uFF08${s.resolution ?? "\u65E0 resolution"}\uFF09\uFF0C\u4E0D\u80FD\u8FFD\u52A0\uFF1A\u75C7\u72B6\u8FD8\u5728\u5C31 \`hcm chiron gap submit --new\` \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${s.key}`;
|
|
12625
|
+
}
|
|
12626
|
+
var EVIDENCE_MIN = 10;
|
|
12627
|
+
var VERIFY_PLAN = {
|
|
12628
|
+
pass: { header: "\u987E\u95EE\u590D\u9A8C\u901A\u8FC7", transition: { name: "\u786E\u8BA4\u5173\u95ED", to: CLOSED_STATUS }, outcome: "closed" },
|
|
12629
|
+
fail: { header: "\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE", transition: { name: "\u672A\u89E3\u51B3", to: "OPEN" }, outcome: "returned" },
|
|
12630
|
+
partial: { header: "\u987E\u95EE\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\uFF0C\u4E0D\u5173\u5355", outcome: "recorded" }
|
|
12631
|
+
};
|
|
12632
|
+
function parseVerifyResult(raw) {
|
|
12633
|
+
const v = String(raw ?? "").trim().toLowerCase();
|
|
12634
|
+
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12635
|
+
throw new CliError29({
|
|
12636
|
+
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12637
|
+
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12638
|
+
context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
|
|
12639
|
+
});
|
|
12640
|
+
}
|
|
12641
|
+
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12642
|
+
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12643
|
+
}
|
|
12644
|
+
function who(u) {
|
|
12645
|
+
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
12646
|
+
const shown = u.displayName ?? u.name ?? u.key ?? "?";
|
|
12647
|
+
return u.name && u.name !== shown ? `${shown}\uFF08${u.name}\uFF09` : shown;
|
|
12648
|
+
}
|
|
12649
|
+
function sameUser(a, b) {
|
|
12650
|
+
if (!a || !b) return false;
|
|
12651
|
+
if (a.key || b.key) return !!a.key && !!b.key && a.key === b.key;
|
|
12652
|
+
if (a.name && b.name) return a.name === b.name;
|
|
12653
|
+
return false;
|
|
12654
|
+
}
|
|
12655
|
+
var isEmptyValue = (v) => v === void 0 || v === null || typeof v === "string" && !v.trim() || Array.isArray(v) && v.length === 0;
|
|
12656
|
+
var fieldLabel = ([id, f]) => `${f.name ?? id}(${id})`;
|
|
12657
|
+
function checkRequiredFields(t, issue) {
|
|
12658
|
+
if (!t.fields) return null;
|
|
12659
|
+
const required2 = Object.entries(t.fields).filter(([, f]) => f.required === true);
|
|
12660
|
+
return {
|
|
12661
|
+
checked: required2.map(fieldLabel),
|
|
12662
|
+
missing: required2.filter(([id]) => isEmptyValue(issue.fields[id])).map(fieldLabel)
|
|
12663
|
+
};
|
|
12499
12664
|
}
|
|
12500
|
-
|
|
12501
|
-
var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${g.title} ${gapKeyTag(g)}`;
|
|
12502
|
-
function renderGapDescription(g, fingerprintText2) {
|
|
12665
|
+
function renderVerifyComment(result, evidence, fp, reporter, versionComparison) {
|
|
12503
12666
|
return [
|
|
12504
|
-
|
|
12505
|
-
|
|
12506
|
-
|
|
12507
|
-
"
|
|
12508
|
-
|
|
12509
|
-
g.repro,
|
|
12510
|
-
"{code}",
|
|
12511
|
-
"",
|
|
12512
|
-
"h2. \u671F\u671B",
|
|
12513
|
-
g.expected,
|
|
12514
|
-
"",
|
|
12515
|
-
"h2. \u73AF\u5883\u6307\u7EB9",
|
|
12516
|
-
fingerprintText2,
|
|
12517
|
-
"",
|
|
12518
|
-
"h2. \u66FF\u4EE3\u6CD5",
|
|
12519
|
-
g.alternative,
|
|
12520
|
-
"",
|
|
12521
|
-
"h2. \u4E25\u91CD\u5EA6",
|
|
12522
|
-
`${g.severity}\uFF08\u987E\u95EE\u4FA7\u5224\u5B9A\uFF1A\u963B\u65AD=\u4EA4\u4ED8\u505C\u4E0B / \u6709\u66FF\u4EE3\u6CD5=\u80FD\u7ED5 / \u63AA\u8F9E\u7EA7=\u8F93\u51FA\u5DF2\u7ED9\u8DEF\u6807\uFF09`,
|
|
12523
|
-
"",
|
|
12524
|
-
"h2. \u4E09\u95EE\u81EA\u7B54",
|
|
12525
|
-
`# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
|
|
12526
|
-
`# \u5386\u53F2\uFF1A${g.q_history}`,
|
|
12527
|
-
`# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
|
|
12528
|
-
"",
|
|
12529
|
-
"h2. \u5173\u952E\u8BCD",
|
|
12530
|
-
[g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
|
|
12667
|
+
VERIFY_PLAN[result].header,
|
|
12668
|
+
`\u73AF\u5883\uFF1A${fp.text}${fp.source === "given" ? "\uFF08\u8C03\u7528\u65B9\u7ED9\u7684\uFF0C\u672A\u73B0\u67E5\uFF09" : ""}`,
|
|
12669
|
+
...versionComparison ? [`${versionComparison.text}`] : [],
|
|
12670
|
+
"\u9A8C\u6536\u8BF4\u660E\uFF1A",
|
|
12671
|
+
evidence.trim(),
|
|
12531
12672
|
"",
|
|
12532
|
-
|
|
12673
|
+
`_\u7531\u63D0\u5355\u4EBA ${reporter} \u7ECF \`hcm chiron gap verify\` \u63D0\u4EA4\u3002_`
|
|
12533
12674
|
].join("\n");
|
|
12534
12675
|
}
|
|
12535
|
-
function
|
|
12536
|
-
const
|
|
12537
|
-
const
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
};
|
|
12542
|
-
|
|
12543
|
-
const A = bigrams(a);
|
|
12544
|
-
const B = bigrams(b);
|
|
12545
|
-
if (!A.size || !B.size) return 0;
|
|
12546
|
-
let n = 0;
|
|
12547
|
-
for (const s of A) if (B.has(s)) n++;
|
|
12548
|
-
return n / Math.min(A.size, B.size);
|
|
12549
|
-
};
|
|
12550
|
-
for (const i of open) {
|
|
12551
|
-
const t = i.fields.summary ?? "";
|
|
12552
|
-
if (keyTag !== "\u3014-\u3015" && t.includes(keyTag)) return i;
|
|
12553
|
-
if (sim(t, summary) >= 0.6) return i;
|
|
12554
|
-
}
|
|
12555
|
-
return null;
|
|
12676
|
+
function fixRevisionFromComments(comments) {
|
|
12677
|
+
const evidence = [...comments].reverse().find((c2) => {
|
|
12678
|
+
const body = c2.body ?? "";
|
|
12679
|
+
return /已修复|代码库已关闭/.test(body) && /hcm(?:\/|_)hcm[_-]?nx[_-]?core|hcm_nx_core/.test(body) || /hcm_nx_core(?:#\d+)?[^\n]{0,180}revision\s+r\d+/i.test(body);
|
|
12680
|
+
});
|
|
12681
|
+
if (!evidence) return void 0;
|
|
12682
|
+
const revisions = [...(evidence.body ?? "").matchAll(/(?:hcm\/)?hcm_nx_core(?:#\d+)?[^\n]{0,180}?revision\s+r(\d+)/gi)].map((m) => Number(m[1])).filter((n) => Number.isSafeInteger(n));
|
|
12683
|
+
return revisions.length ? Math.max(...revisions) : void 0;
|
|
12556
12684
|
}
|
|
12557
|
-
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
\u6709\u66FF\u4EE3\u6CD5: ["Medium", "\u4E2D", "\u4E00\u822C", "High"],
|
|
12562
|
-
\u63AA\u8F9E\u7EA7: ["Low", "\u4F4E", "Lowest"]
|
|
12563
|
-
};
|
|
12564
|
-
var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
|
|
12565
|
-
function buildGapFields(g, ctx) {
|
|
12566
|
-
const wanted = KIND_TO_TYPE[g.kind] ?? [];
|
|
12567
|
-
const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
|
|
12568
|
-
if (!type) {
|
|
12569
|
-
throw new Error(`\u9879\u76EE ${ctx.project} \u91CC\u6CA1\u6709\u300C${wanted.join(" / ")}\u300D\u8FD9\u7C7B issuetype\uFF0C\u5B9E\u9645\u6709\uFF1A${ctx.types.map((t) => t.name).join(" / ")}`);
|
|
12685
|
+
function notFixedNextStep(key2, s, result) {
|
|
12686
|
+
const { status } = s;
|
|
12687
|
+
if (status === CLOSED_STATUS) {
|
|
12688
|
+
return `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u80FD\u518D${result === "fail" ? "\u9000\u56DE" : "\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7"}\u3002${closedGapHint({ key: key2, resolution: s.resolution })}\u3002`;
|
|
12570
12689
|
}
|
|
12571
|
-
|
|
12572
|
-
|
|
12573
|
-
|
|
12574
|
-
\u6982\u8981: gapSummary(g),
|
|
12575
|
-
\u63CF\u8FF0: renderGapDescription(g, ctx.fingerprintText),
|
|
12576
|
-
\u95EE\u9898\u7C7B\u522B: KIND_TO_CATEGORY[g.kind],
|
|
12577
|
-
\u95EE\u9898\u6A21\u5757: module,
|
|
12578
|
-
\u4F18\u5148\u7EA7: SEVERITY_TO_PRIORITY[g.severity],
|
|
12579
|
-
\u62A5\u544A\u4EBA: ctx.me,
|
|
12580
|
-
\u7ECF\u529E\u4EBA: ctx.assignee,
|
|
12581
|
-
Bug\u53D1\u73B0\u4EBA: "\u987E\u95EE",
|
|
12582
|
-
Bug\u91CD\u73B0\u64CD\u4F5C\u6B65\u9AA4: g.repro,
|
|
12583
|
-
Bug\u9519\u8BEF\u53F7: g.error_code || "\u65E0\u9519\u8BEF\u7801\uFF08\u73B0\u8C61\u89C1\u63CF\u8FF0\uFF09"
|
|
12584
|
-
};
|
|
12585
|
-
const fields = { project: { key: ctx.project }, issuetype: { id: type.id } };
|
|
12586
|
-
const unfilled = [];
|
|
12587
|
-
const values = (f) => (f.allowedValues ?? []).map((v) => v.value ?? v.name).join("|");
|
|
12588
|
-
for (const f of type.fields ?? []) {
|
|
12589
|
-
if (["project", "issuetype"].includes(f.fieldId)) continue;
|
|
12590
|
-
const want = byName[f.name];
|
|
12591
|
-
if (want === void 0) {
|
|
12592
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId})${f.allowedValues ? `=[${values(f)}]` : ""}`);
|
|
12593
|
-
continue;
|
|
12594
|
-
}
|
|
12595
|
-
if (f.schema?.type === "option-with-child") {
|
|
12596
|
-
const parent = (f.allowedValues ?? []).find((v) => (v.value ?? v.name) === want);
|
|
12597
|
-
if (!parent) {
|
|
12598
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
12599
|
-
continue;
|
|
12600
|
-
}
|
|
12601
|
-
const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
|
|
12602
|
-
const child = (parent.children ?? []).find((c2) => (c2.value ?? c2.name) === childName);
|
|
12603
|
-
if (!child && (parent.children ?? []).length) {
|
|
12604
|
-
unfilled.push(`${f.name}(${f.fieldId}) \u7684\u4E8C\u7EA7\u9879\u300C${childName}\u300D\u4E0D\u5728 [${(parent.children ?? []).map((c2) => c2.value ?? c2.name).join("|")}] \u91CC`);
|
|
12605
|
-
continue;
|
|
12606
|
-
}
|
|
12607
|
-
fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
|
|
12608
|
-
continue;
|
|
12609
|
-
}
|
|
12610
|
-
if (f.allowedValues) {
|
|
12611
|
-
const candidates = Array.isArray(want) ? want : [want];
|
|
12612
|
-
const hit = candidates.map((c2) => f.allowedValues.find((v) => (v.name ?? v.value) === c2)).find(Boolean);
|
|
12613
|
-
if (!hit) {
|
|
12614
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${candidates.join("/")}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
12615
|
-
continue;
|
|
12616
|
-
}
|
|
12617
|
-
fields[f.fieldId] = hit.id ? { id: hit.id } : { name: hit.name ?? hit.value };
|
|
12618
|
-
} else if (f.schema?.type === "user") {
|
|
12619
|
-
if (!want) {
|
|
12620
|
-
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
|
|
12621
|
-
continue;
|
|
12622
|
-
}
|
|
12623
|
-
fields[f.fieldId] = { name: Array.isArray(want) ? want[0] : want };
|
|
12624
|
-
} else {
|
|
12625
|
-
fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
|
|
12626
|
-
}
|
|
12690
|
+
if (status === "\u91CD\u590D\u95EE\u9898") return `\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C\u91CD\u590D\u95EE\u9898\u300D\uFF0C\u6CA1\u6709\u4FEE\u590D\u53EF\u9A8C\u3002${result === "pass" ? DUPLICATE_PASS_ADVICE : DUPLICATE_ADVICE}\u3002`;
|
|
12691
|
+
if (status === "\u4E0D\u5904\u7406" || status === "\u7EB3\u5165\u89C4\u5212") {
|
|
12692
|
+
return `\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C${status}\u300D\uFF0C\u6CA1\u6709\u4FEE\u590D\u53EF\u9A8C\u3002\u7406\u7531\u770B \`hcm chiron gap status ${key2}\`\uFF1B\u4E0D\u8BA4\u540C\u5C31\u5728 Jira \u90A3\u5355\u4E0B\u8BF4\u660E\u4E1A\u52A1\u5F71\u54CD\u3002`;
|
|
12627
12693
|
}
|
|
12628
|
-
if (
|
|
12629
|
-
|
|
12630
|
-
fields.labels = ["chiron-gap", `severity-${sev}`];
|
|
12694
|
+
if (status === "\u8865\u5145\u8BF4\u660E") {
|
|
12695
|
+
return `\u7403\u5728\u4F60\u8FD9\u8FB9\uFF1A\u8FD9\u5355\u88AB\u6253\u56DE\u8865\u5145\u8BF4\u660E\uFF0C\u8FD8\u6CA1\u4FEE\u3002\u7167 \`hcm chiron gap status ${key2}\` \u7ED9\u7684\u4E0B\u4E00\u6B65\u8865\u4FE1\u606F\u3002`;
|
|
12631
12696
|
}
|
|
12632
|
-
|
|
12633
|
-
throw new Error(
|
|
12634
|
-
`\u8FD9\u53F0 Jira \u7684\u300C${type.name}\u300D\u6709\u6211\u586B\u4E0D\u4E0A\u7684\u5FC5\u586B\u5B57\u6BB5\uFF0C\u6CA1\u6709\u5EFA\u5355\uFF08\u4E0D\u66FF\u4F60\u731C\uFF09\uFF1A
|
|
12635
|
-
${unfilled.join("\n ")}
|
|
12636
|
-
next_step=\u8BA9 Jira \u7BA1\u7406\u5458\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u975E\u5FC5\u586B\uFF0C\u6216\u544A\u8BC9\u6211\u8BE5\u586B\u4EC0\u4E48\u3001\u6211\u52A0\u8FDB\u6620\u5C04\u3002\u53F0\u8D26\u5DF2\u7ECF\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u4E0D\u4F1A\u4E22\u3002`
|
|
12637
|
-
);
|
|
12638
|
-
}
|
|
12639
|
-
return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
|
|
12697
|
+
return `\u8FD9\u5355\u8FD8\u6CA1\u4FEE\u590D\uFF08${status ?? "?"}\uFF09\uFF0C\u6CA1\u6709\u4E1C\u897F\u53EF\u9A8C\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u8FDB\u5C55\u770B \`hcm chiron gap status ${key2}\`\uFF0C\u7B49\u5B83\u5230\u300C${FIXED_STATUS}\u300D\u5E76\u90E8\u7F72\u5230\u4F60\u7684\u73AF\u5883\u540E\u518D\u9A8C\u3002`;
|
|
12640
12698
|
}
|
|
12641
|
-
|
|
12642
|
-
const
|
|
12643
|
-
|
|
12644
|
-
|
|
12645
|
-
|
|
12646
|
-
|
|
12647
|
-
|
|
12648
|
-
|
|
12649
|
-
|
|
12650
|
-
|
|
12651
|
-
|
|
12652
|
-
{code}
|
|
12653
|
-
${g.repro}
|
|
12654
|
-
{code}
|
|
12655
|
-
|
|
12656
|
-
**\u66FF\u4EE3\u6CD5**\uFF1A${g.alternative}
|
|
12657
|
-
\u4E25\u91CD\u5EA6\uFF1A${g.severity}`;
|
|
12658
|
-
await client3.addComment(dup.key, body);
|
|
12659
|
-
return { outcome: "appended", key: dup.key, url: client3.browseUrl(dup.key), summary: dup.fields.summary ?? "", alternative: g.alternative };
|
|
12699
|
+
function doneNextStep(key2, outcome, found2) {
|
|
12700
|
+
const link = found2 === false ? `\u8BC4\u8BBA\u94FE\u63A5\u6CA1\u53D6\u5230\uFF0C\u5148\u7528 \`hcm chiron gap comments ${key2}\` \u627E\u5230\u90A3\u6761\u518D\u5199\u8FDB\u62A5\u544A` : "\u9644\u4E0A\u9762\u7684\u8BC4\u8BBA\u94FE\u63A5";
|
|
12701
|
+
switch (outcome) {
|
|
12702
|
+
case "closed":
|
|
12703
|
+
return `\u5DF2\u5173\u5355\u3002\u62A5\u544A\u91CC\u5199\u300C\u5DF2\u9A8C\u6536\u5173\u95ED ${key2}\u300D\uFF0C${link}\u3002`;
|
|
12704
|
+
case "returned":
|
|
12705
|
+
return `\u5DF2\u9000\u56DE\uFF0C\u7403\u56DE\u5230\u4EA7\u54C1\u4FA7\uFF1A\u4EE3\u7801\u5E93\u6761\u76EE\u8981\u7531\u4EA7\u54C1\u4FA7\u91CD\u5F00\uFF08\u987E\u95EE\u4FA7\u6539\u4E0D\u4E86\uFF09\u3002\u4F60\u8FD9\u8FB9\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF0C\u8FDB\u5C55\u770B \`hcm chiron gap status ${key2}\`\u3002`;
|
|
12706
|
+
case "recorded":
|
|
12707
|
+
return `\u5DF2\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7\uFF0C\u5355\u5B50\u4ECD\u5728\u300C${FIXED_STATUS}\u300D\u3002\u9A8C\u8FC7\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF0C\u6CA1\u9A8C\u5230\u7684\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\u518D\u8DD1 \`hcm chiron gap verify ${key2} --result pass\`\uFF0C\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\u5C31\u7528 \`--result fail\`\u3002`;
|
|
12708
|
+
case "already-closed":
|
|
12709
|
+
return "\u8FD9\u5355\u5DF2\u7ECF\u662F CLOSE\uFF0C\u6CA1\u6709\u91CD\u590D\u5199\u3002";
|
|
12660
12710
|
}
|
|
12661
|
-
const [types, me, project2] = await Promise.all([client3.createMeta(), client3.myself(), client3.projectInfo()]);
|
|
12662
|
-
const built = buildGapFields(g, {
|
|
12663
|
-
types,
|
|
12664
|
-
me: me.name ?? me.key ?? "",
|
|
12665
|
-
assignee: assigneeOverride || project2.lead?.name || project2.lead?.key,
|
|
12666
|
-
project: client3.project,
|
|
12667
|
-
fingerprintText: fingerprintText2,
|
|
12668
|
-
issuetypeOverride
|
|
12669
|
-
});
|
|
12670
|
-
const created = await client3.createIssue(built.fields);
|
|
12671
|
-
return { outcome: "created", key: created.key, url: client3.browseUrl(created.key), summary: built.summary, type: built.type.name, module: built.module, alternative: g.alternative };
|
|
12672
12711
|
}
|
|
12673
|
-
|
|
12674
|
-
|
|
12675
|
-
|
|
12676
|
-
try {
|
|
12677
|
-
for (const kw of keywords) {
|
|
12678
|
-
const safe = kw.replace(/["\\]/g, " ").trim();
|
|
12679
|
-
const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
|
|
12680
|
-
for (const i of await client3.search(jql, { max: 15 })) {
|
|
12681
|
-
rows2.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, resolution: i.fields.resolution?.name, url: client3.browseUrl(i.key) });
|
|
12682
|
-
}
|
|
12683
|
-
}
|
|
12684
|
-
if (!rows2.length) {
|
|
12685
|
-
const open = await client3.search(`project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`, { max: 100 });
|
|
12686
|
-
for (const i of open) {
|
|
12687
|
-
if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
|
|
12688
|
-
rows2.push({ where: "Jira", id: i.key, title: i.fields.summary ?? "", state: i.fields.status?.name, url: client3.browseUrl(i.key) });
|
|
12689
|
-
}
|
|
12690
|
-
}
|
|
12691
|
-
}
|
|
12692
|
-
} catch (e) {
|
|
12693
|
-
jiraError = e.message;
|
|
12712
|
+
function rejectNextStep(status, key2) {
|
|
12713
|
+
if (status === 401) {
|
|
12714
|
+
return "\u4EE4\u724C\u65E0\u6548\u6216\u8FC7\u671F\uFF1A\u5728 Jira \u53F3\u4E0A\u89D2\u5934\u50CF \u2192 \u4E2A\u4EBA\u8BBE\u7F6E \u2192 Personal Access Tokens \u91CD\u5EFA\u4E00\u4E2A\uFF0C\u6309\u539F\u6765\u7684\u5B58\u6CD5\uFF08\u73AF\u5883\u53D8\u91CF / ~/.config/hcm/jira-token / \u94A5\u5319\u4E32\uFF09\u91CD\u65B0\u5B58\uFF0C\u518D\u91CD\u8DD1\u3002";
|
|
12694
12715
|
}
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
var PRODUCT_HANDLING_KEYWORDS = /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/;
|
|
12699
|
-
var HEADLINE_MAX = 300;
|
|
12700
|
-
function commentWhen(created) {
|
|
12701
|
-
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(created ?? "");
|
|
12702
|
-
return m ? `${m[1]} ${m[2]}` : created ?? "?";
|
|
12703
|
-
}
|
|
12704
|
-
function commentHeadline(body) {
|
|
12705
|
-
const lines = (body ?? "").split("\n").map((l) => l.trim()).filter(Boolean);
|
|
12706
|
-
const first = lines[0] ?? "";
|
|
12707
|
-
const cut = first.length > HEADLINE_MAX;
|
|
12708
|
-
return { headline: cut ? first.slice(0, HEADLINE_MAX) + "\u2026" : first, truncated: cut || lines.length > 1 };
|
|
12709
|
-
}
|
|
12710
|
-
function classifyFollowUp(headline) {
|
|
12711
|
-
if (/阻塞|阻断|未通过|不通过|没通过|没过|退回|失败|(仍|还是|依旧)(然)?(能|可)?复现/.test(headline)) return "blocked";
|
|
12712
|
-
if (/部分(通过|验证|复验|验收|可用)|只(验证|验|测)了/.test(headline)) return "partial";
|
|
12713
|
-
if (/(?<![等待])(复验|验收|验证|复测|回归)(已)?通过(?!\s*(才|后|再))|验证无误/.test(headline)) return "passed";
|
|
12714
|
-
if (/已(经)?(部署|发布|上线|跑)|(部署|发布)(完成|好了)|升级到|更新到/.test(headline)) return "deployed";
|
|
12715
|
-
return void 0;
|
|
12716
|
+
if (status === 403) return `\u4EE4\u724C\u6709\u6548\uFF0C\u4F46\u4F60\u7684\u8D26\u53F7\u6CA1\u6709 ${key2} \u7684\u8FD9\u6761\u6D41\u8F6C\u6216\u8BC4\u8BBA\u6743\u9650\uFF1A\u627E Jira \u7BA1\u7406\u5458\u5F00\u9879\u76EE\u6743\u9650\uFF0C\u522B\u6362\u522B\u4EBA\u7684\u4EE4\u724C\u3002`;
|
|
12717
|
+
if (status === 404) return `Jira \u8BF4\u627E\u4E0D\u5230 ${key2}\uFF08\u6216\u4F60\u770B\u4E0D\u5230\u5B83\uFF09\uFF1A\u6838\u5BF9\u5355\u53F7\uFF1B\u662F\u4F60\u81EA\u5DF1\u63D0\u7684\u5355\u5374\u770B\u4E0D\u5230\uFF0C\u627E Jira \u7BA1\u7406\u5458\u3002`;
|
|
12718
|
+
return "\u6309\u300C\u8BE6\u60C5\u300D\u91CC Jira \u7684\u539F\u8BDD\u5904\u7406\uFF1A\u591A\u534A\u662F\u6D41\u8F6C\u521A\u88AB\u6539\u8FC7\u6216\u754C\u9762\u5B57\u6BB5\u53D8\u4E86\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u6539\u95EE\u9898\u7C7B\u578B\uFF0C\u4E5F\u522B\u81EA\u5DF1\u62FC HTTP \u7ED5\u8FC7\u3002";
|
|
12716
12719
|
}
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
const
|
|
12721
|
-
|
|
12720
|
+
function unconfirmedWhy(e) {
|
|
12721
|
+
if (e instanceof JiraHttpError) return `Jira ${e.status}`;
|
|
12722
|
+
if (e instanceof SyntaxError) return "Jira \u56DE\u4E86 2xx \u4F46\u5E94\u7B54\u8BFB\u4E0D\u61C2\uFF0C\u591A\u534A\u5DF2\u5199\u5165";
|
|
12723
|
+
const name = e instanceof Error ? e.name : typeof e;
|
|
12724
|
+
if (name === "TimeoutError" || name === "AbortError") return "\u8D85\u65F6";
|
|
12725
|
+
if (e instanceof TypeError) return "\u8FDE\u63A5\u5931\u8D25";
|
|
12726
|
+
return name;
|
|
12722
12727
|
}
|
|
12723
|
-
function
|
|
12724
|
-
|
|
12728
|
+
function writeFailure(e, key2, what) {
|
|
12729
|
+
if (e instanceof JiraNonBmpContentError) {
|
|
12730
|
+
return verifyFailure(
|
|
12731
|
+
"non-bmp-content",
|
|
12732
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12733
|
+
"no",
|
|
12734
|
+
`\u8FD9\u6B21${what}\u4E00\u4E2A\u5B57\u90FD\u6CA1\u53D1\u51FA\u53BB\uFF1A\u6B63\u6587\u91CC\u6709 ${e.hits.length} \u5904 Jira \u5B58\u4E0D\u4E0B\u7684\u5B57\u7B26`,
|
|
12735
|
+
// 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
|
|
12736
|
+
// 三处命中就会把「该怎么改」整段截掉——那正是顾问唯一需要的那段。
|
|
12737
|
+
`\u6362\u6389\u4E0B\u9762\u8FD9\u4E9B\u5B57\u7B26\u518D\u91CD\u8DD1\uFF08${NON_BMP_RULE_NOTE}\uFF09\uFF1A
|
|
12738
|
+
${nonBmpHitLines(e.hits)}`,
|
|
12739
|
+
{ key: key2, hits: e.hits }
|
|
12740
|
+
);
|
|
12741
|
+
}
|
|
12742
|
+
if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
|
|
12743
|
+
return verifyFailure("write-rejected", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
|
|
12744
|
+
key: key2,
|
|
12745
|
+
status: e.status,
|
|
12746
|
+
details: e.message
|
|
12747
|
+
});
|
|
12748
|
+
}
|
|
12749
|
+
return verifyFailure(
|
|
12750
|
+
"write-unconfirmed",
|
|
12751
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12752
|
+
"unknown",
|
|
12753
|
+
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12754
|
+
`\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
|
|
12755
|
+
{ key: key2, ...e instanceof JiraHttpError ? { status: e.status } : {} },
|
|
12756
|
+
e
|
|
12757
|
+
);
|
|
12725
12758
|
}
|
|
12726
|
-
function
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
id:
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
truncated,
|
|
12735
|
-
url: c2.id ? client3.commentUrl(key2, c2.id) : void 0
|
|
12736
|
-
};
|
|
12759
|
+
async function claimTransitionComment(client3, key2, me, header, body, beforeIds) {
|
|
12760
|
+
try {
|
|
12761
|
+
const hit = (await client3.comments(key2)).filter((c2) => !beforeIds.has(c2.id) && sameUser(c2.author, me) && firstLine2(c2.body ?? "") === header).at(-1);
|
|
12762
|
+
return hit?.id ? { body, found: true, id: hit.id, url: client3.commentUrl(key2, hit.id) } : { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u6CA1\u8BA4\u9886\u5230\u8FD9\u4E00\u6761\uFF08\u63A5\u53E3\u4E0D\u56DE\u8BC4\u8BBA id\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
|
|
12763
|
+
} catch (e) {
|
|
12764
|
+
const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
12765
|
+
return { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u5931\u8D25\uFF08${why}\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
|
|
12766
|
+
}
|
|
12737
12767
|
}
|
|
12738
|
-
|
|
12768
|
+
var snapshotOf = (i) => ({ status: i.fields.status?.name, resolution: i.fields.resolution?.name ?? null });
|
|
12769
|
+
async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLUG2) {
|
|
12739
12770
|
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
12740
|
-
if (!parsed
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12771
|
+
if (!parsed || parsed.kind !== "jira") {
|
|
12772
|
+
throw verifyFailure(
|
|
12773
|
+
"not-jira-key",
|
|
12774
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12775
|
+
"no",
|
|
12776
|
+
parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
|
|
12777
|
+
"\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
|
|
12744
12778
|
);
|
|
12745
12779
|
}
|
|
12746
|
-
const
|
|
12747
|
-
const
|
|
12748
|
-
const
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12780
|
+
const key2 = parsed.key;
|
|
12781
|
+
const inProject = (k) => k.startsWith(`${client3.project}-`);
|
|
12782
|
+
const wrongProject = (k) => verifyFailure(
|
|
12783
|
+
"wrong-project",
|
|
12784
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12785
|
+
"no",
|
|
12786
|
+
`${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
|
|
12787
|
+
`\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\`hcm chiron gap submit\` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\uFF09\u3002\u522B\u7684\u9879\u76EE\u7684\u5355\u8FD9\u6761\u547D\u4EE4\u4E0D\u78B0\u2014\u2014\u90A3\u91CC\u7684\u72B6\u6001\u540D\u4E0E\u6D41\u8F6C\u540D\u548C ${client3.project} \u540C\u5F62\uFF0C\u5199\u9519\u4E86\u4F1A\u628A\u522B\u5904\u7684\u5355\u5173\u6389\u3002`,
|
|
12788
|
+
{ key: k, project: client3.project }
|
|
12789
|
+
);
|
|
12790
|
+
if (!inProject(key2)) throw wrongProject(key2);
|
|
12791
|
+
const evidence = o.evidence.trim();
|
|
12792
|
+
if (evidence.length < EVIDENCE_MIN) {
|
|
12793
|
+
throw verifyFailure(
|
|
12794
|
+
"evidence-too-short",
|
|
12795
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12796
|
+
"no",
|
|
12797
|
+
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
12798
|
+
"\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
|
|
12799
|
+
{ key: key2 }
|
|
12800
|
+
);
|
|
12765
12801
|
}
|
|
12766
|
-
|
|
12767
|
-
|
|
12768
|
-
|
|
12769
|
-
|
|
12802
|
+
const [issue, me] = await Promise.all([client3.issue(key2), client3.myself()]);
|
|
12803
|
+
if (!inProject(issue.key)) throw wrongProject(issue.key);
|
|
12804
|
+
const before = snapshotOf(issue);
|
|
12805
|
+
const status = before.status;
|
|
12806
|
+
const reporter = issue.fields.reporter;
|
|
12807
|
+
const base = {
|
|
12808
|
+
key: key2,
|
|
12809
|
+
url: client3.browseUrl(key2),
|
|
12810
|
+
summary: issue.fields.summary ?? "",
|
|
12811
|
+
result: o.result,
|
|
12812
|
+
reporter: who(reporter),
|
|
12813
|
+
me: who(me),
|
|
12814
|
+
before,
|
|
12815
|
+
dryRun: o.dryRun === true,
|
|
12816
|
+
fingerprint: o.fingerprint
|
|
12817
|
+
};
|
|
12818
|
+
if (!sameUser(reporter, me)) {
|
|
12819
|
+
throw verifyFailure(
|
|
12820
|
+
"not-reporter",
|
|
12821
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12822
|
+
"no",
|
|
12823
|
+
`\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
|
|
12824
|
+
// 重复单上的 pass:提单人跑了也一个字不写(见下面 ②),叫人去找提单人是一跳死路
|
|
12825
|
+
o.result === "pass" && isDuplicateGap(before) ? `\u8FD9\u662F\u91CD\u590D\u5355\uFF0C\u8C01\u8DD1\u90FD\u4E0D\u4F1A\u5728\u8FD9\u5F20\u4E0A\u5199\u3002${DUPLICATE_PASS_ADVICE}\u3002` : `\u8BF7\u63D0\u5355\u4EBA\u590D\u9A8C\u540E\u81EA\u5DF1\u8DD1\u8FD9\u6761\u547D\u4EE4\u3002\u4F60\u624B\u4E0A\u7684\u65B0\u73B0\u573A\uFF1A${terminalGapHint({ key: key2, ...before }) ?? `\u7528 \`hcm chiron gap submit --append-to ${key2}\` \u8FFD\u52A0\uFF08submit \u4F1A\u6309\u4F60\u7684\u73AF\u5883\u7248\u672C\u5224\u80FD\u4E0D\u80FD\u8FFD\u52A0\uFF09`}\uFF1B\u7ECF\u529E\u4EBA\u3001\u641C\u7D22\u547D\u4E2D\u3001\u5728\u522B\u4EBA\u7684\u5355\u4E0B\u8FFD\u52A0\u8FC7\u73B0\u573A\u90FD\u4E0D\u6784\u6210\u9A8C\u6536\u8D44\u683C\u3002`,
|
|
12826
|
+
{ key: key2, status, resolution: before.resolution, reporter: reporter?.key ?? reporter?.name ?? null, me: me.key ?? me.name ?? null }
|
|
12827
|
+
);
|
|
12770
12828
|
}
|
|
12771
|
-
|
|
12772
|
-
|
|
12773
|
-
|
|
12774
|
-
} else {
|
|
12775
|
-
if (latestProductComment) lines.push(...render2(`\u4EA7\u54C1\u4FA7\u5904\u7406\uFF08${hit}\uFF1B${stamp(latestProductComment)}\uFF09`, latestProductComment));
|
|
12776
|
-
else if (latestComment) lines.push(" \u8FD8\u6CA1\u6709\u4EA7\u54C1\u4FA7\u5904\u7406\u8BC4\u8BBA\uFF08\u5206\u8BCA / \u5DF2\u8F6C / \u5408\u5165 / \u4EE3\u7801\u5E93\u5DF2\u5173\u95ED \u8FD9\u7C7B\u5173\u952E\u8BCD\u4E00\u6761\u90FD\u6CA1\u547D\u4E2D\uFF09");
|
|
12777
|
-
if (latestComment) lines.push(...render2(`\u6700\u65B0\u8BC4\u8BBA\uFF08${stamp(latestComment)}\uFF09`, latestComment));
|
|
12829
|
+
if (o.result === "pass" && status === CLOSED_STATUS) {
|
|
12830
|
+
const nextStep = before.resolution === DONE_RESOLUTION ? doneNextStep(key2, "already-closed", void 0) : before.resolution === DUPLICATE_RESOLUTION ? `\u8FD9\u5355\u5224\u91CD\u540E\u5173\u4E86\uFF08CLOSE\xB7${DUPLICATE_RESOLUTION}\uFF09\u3002${DUPLICATE_PASS_ADVICE}\u3002` : `\u8FD9\u5355\u662F\u6CA1\u4FEE\u5C31\u5173\u7684\uFF08CLOSE\xB7${before.resolution ?? "\u6CA1\u6709 resolution"}\uFF09\uFF0C\u4F60\u7684\u590D\u9A8C\u7ED3\u8BBA\u6CA1\u5199\u8FDB\u53BB\u3002${closedGapHint({ key: key2, resolution: before.resolution })}\u3002`;
|
|
12831
|
+
return { ...base, outcome: "already-closed", written: "no", requiredFields: "not-applicable", nextStep };
|
|
12778
12832
|
}
|
|
12779
|
-
if (
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
if (
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
switch (latestComment.signal) {
|
|
12813
|
-
case "passed":
|
|
12814
|
-
nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u590D\u9A8C\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002` + (canVerify ? `Jira \u72B6\u6001\u8FD8\u505C\u5728\u300C\u5DF2\u4FEE\u590D\u300D\u53EA\u8BF4\u660E\u8FD8\u6CA1\u8D70\u5173\u5355\u6D41\u8F6C\uFF0C\u4E0D\u4EE3\u8868\u8FD8\u6CA1\u90E8\u7F72\uFF1A\u63D0\u5355\u4EBA\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u4E0D\u662F\u63D0\u5355\u4EBA\u5C31\u7B49\u63D0\u5355\u4EBA\u6216\u4EA7\u54C1\u4FA7\u5173\uFF09\u3002` : `Jira \u72B6\u6001\u8FD8\u5728\u300C${status ?? "?"}\u300D\uFF1A${waitFixed}\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`) + `\u8DD1 \`hcm chiron skills sync\` \u540E\u6309\u6280\u80FD\u76F4\u63A5\u7528\uFF0C\u4E0D\u5FC5\u518D\u7B49\u90E8\u7F72\u590D\u9A8C\u3002`;
|
|
12815
|
-
break;
|
|
12816
|
-
case "deployed":
|
|
12817
|
-
nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u2014\u2014${cite}${tail}\u3002\u8DD1 \`hcm chiron skills sync\`\uFF0C\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\uFF0C` + (canVerify ? `\u518D\u7531\u63D0\u5355\u4EBA\u7528 ${verifyCmd} \u56DE\u5199\u7ED3\u8BBA\u3002` : `\u7ED3\u679C\u5148\u8BB0\u5728\u4F60\u7684\u53F0\u8D26\u91CC\uFF1B${waitFixed}\uFF0C\u518D\u7528 ${verifyCmd} \u56DE\u5199\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
|
|
12818
|
-
break;
|
|
12819
|
-
case "partial":
|
|
12820
|
-
nextStep = `\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002\u9A8C\u8FC7\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF1B\u6CA1\u9A8C\u5230\u7684\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B` + (canVerify ? `\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\u540E\u63D0\u5355\u4EBA\u518D\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass\`\uFF0C\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\u5C31\u7528 \`--result fail\`\u3002` : `${waitFixed}\u3001\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
|
|
12821
|
-
break;
|
|
12822
|
-
case "blocked":
|
|
12823
|
-
nextStep = `\u590D\u9A8C\u6CA1\u8FC7 / \u88AB\u963B\u585E\u2014\u2014${cite}${tail}\u3002\u7403\u56DE\u5230\u4EA7\u54C1\u4FA7\uFF1A\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF0C\u8FDB\u5C55\u770B\u8FD9\u5355\u540E\u7EED\u8BC4\u8BBA\u3002`;
|
|
12824
|
-
break;
|
|
12825
|
-
default:
|
|
12826
|
-
if (!sameAsProduct) nextStep += ` \u53E6\uFF1A\u6709\u4E00\u6761\u6BD4\u4EA7\u54C1\u4FA7\u5904\u7406\u66F4\u65B0\u7684\u8BC4\u8BBA\u2014\u2014${cite}${tail}\uFF0C\u5148\u770B\u5B83\u3002`;
|
|
12833
|
+
if (status !== FIXED_STATUS) {
|
|
12834
|
+
throw verifyFailure(
|
|
12835
|
+
"status-not-fixed",
|
|
12836
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12837
|
+
"no",
|
|
12838
|
+
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
12839
|
+
notFixedNextStep(key2, before, o.result),
|
|
12840
|
+
{ key: key2, status, resolution: before.resolution }
|
|
12841
|
+
);
|
|
12842
|
+
}
|
|
12843
|
+
let versionComparison;
|
|
12844
|
+
if (o.result !== "pass") {
|
|
12845
|
+
let comments;
|
|
12846
|
+
let readReason;
|
|
12847
|
+
try {
|
|
12848
|
+
comments = await client3.comments(key2);
|
|
12849
|
+
} catch (e) {
|
|
12850
|
+
readReason = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
12851
|
+
}
|
|
12852
|
+
const fixRevision = comments ? fixRevisionFromComments(comments) : void 0;
|
|
12853
|
+
if (fixRevision === void 0) {
|
|
12854
|
+
const reason = readReason ? `\u8BFB\u53D6\u4EA7\u54C1\u4FA7\u5DF2\u4FEE\u590D\u8BC1\u636E\u5931\u8D25\uFF1A${readReason}` : "\u8BC4\u8BBA\u4E2D\u6CA1\u6709 hcm_nx_core \u7684 revision \u8BC1\u636E";
|
|
12855
|
+
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, reason };
|
|
12856
|
+
} else if (!Number.isSafeInteger(o.fingerprint.revision)) {
|
|
12857
|
+
const reason = o.fingerprint.revisionError ?? "\u73AF\u5883\u7248\u672C\u63A5\u53E3\u6CA1\u6709 revision \u5B57\u6BB5\uFF08\u53EF\u80FD\u662F\u65E7\u540E\u7AEF\uFF09";
|
|
12858
|
+
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, fixRevision, reason };
|
|
12859
|
+
} else if (o.fingerprint.revision < fixRevision) {
|
|
12860
|
+
const environmentRevision = o.fingerprint.revision;
|
|
12861
|
+
const message = `\u73AF\u5883\u5C1A\u672A\u5305\u542B\u4FEE\u590D\uFF08\u5F53\u524D r${environmentRevision} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u8BF7\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF1B\u81EA\u67E5 curl <env>/api/version/backend`;
|
|
12862
|
+
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
12863
|
+
} else {
|
|
12864
|
+
const environmentRevision = o.fingerprint.revision;
|
|
12865
|
+
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
12827
12866
|
}
|
|
12828
12867
|
}
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
if (
|
|
12834
|
-
|
|
12835
|
-
|
|
12868
|
+
const plan = VERIFY_PLAN[o.result];
|
|
12869
|
+
let transition;
|
|
12870
|
+
let requiredFields = "not-applicable";
|
|
12871
|
+
let requiredChecked;
|
|
12872
|
+
if (plan.transition) {
|
|
12873
|
+
const want = plan.transition;
|
|
12874
|
+
const list = await client3.transitions(key2);
|
|
12875
|
+
transition = list.find((t) => t.name === want.name && t.to?.name === want.to);
|
|
12876
|
+
if (!transition) {
|
|
12877
|
+
const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
|
|
12878
|
+
throw verifyFailure(
|
|
12879
|
+
"transition-unavailable",
|
|
12880
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12881
|
+
"no",
|
|
12882
|
+
`${key2} \u4E0A\u670D\u52A1\u7AEF\u6B64\u523B\u4E0D\u7ED9\u300C${want.name}\u2192${want.to}\u300D\u8FD9\u6761\u6D41\u8F6C\uFF08\u53EF\u7528\uFF1A${available.join(" / ") || "\uFF08\u65E0\uFF09"}\uFF09`,
|
|
12883
|
+
"\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF0C\u6216\u4F60\u7684\u8D26\u53F7\u5728\u8FD9\u4E2A\u9879\u76EE\u4E0A\u6CA1\u6709\u8FD9\u6761\u6D41\u8F6C\u7684\u6743\u9650\u3002\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u81EA\u5DF1\u62FC HTTP\uFF0C\u4E5F\u522B\u6539\u95EE\u9898\u7C7B\u578B\u7ED5\u8FC7\u3002",
|
|
12884
|
+
{ key: key2, status, available }
|
|
12885
|
+
);
|
|
12886
|
+
}
|
|
12887
|
+
const req = checkRequiredFields(transition, issue);
|
|
12888
|
+
if (!req) requiredFields = "no-metadata";
|
|
12889
|
+
else if (req.missing.length) {
|
|
12890
|
+
throw verifyFailure(
|
|
12891
|
+
"required-fields-missing",
|
|
12892
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12893
|
+
"no",
|
|
12894
|
+
`\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
|
|
12895
|
+
"\u8FD9\u4E9B\u5B57\u6BB5\u7531\u4EA7\u54C1\u4FA7\u7EF4\u62A4\uFF0C\u8BF7\u5206\u8BCA\u4EBA\u8865\u9F50\u540E\u518D\u8DD1\uFF1BCLI \u4E0D\u4EE3\u586B\uFF0C\u4E5F\u522B\u628A\u7ECF\u529E\u4EBA\u6216\u4FEE\u590D\u4EBA\u731C\u6210 Bug\u5F15\u5165\u4EBA\u3002",
|
|
12896
|
+
{ key: key2, status, missing: req.missing, checked: req.checked }
|
|
12897
|
+
);
|
|
12898
|
+
} else {
|
|
12899
|
+
requiredFields = "checked";
|
|
12900
|
+
requiredChecked = req.checked;
|
|
12901
|
+
}
|
|
12836
12902
|
}
|
|
12837
|
-
|
|
12838
|
-
const
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
|
|
12844
|
-
|
|
12845
|
-
|
|
12846
|
-
|
|
12847
|
-
|
|
12848
|
-
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
url: c2.id ? client3.commentUrl(parsed.key, c2.id) : void 0
|
|
12853
|
-
}))
|
|
12854
|
-
};
|
|
12855
|
-
}
|
|
12856
|
-
|
|
12857
|
-
// src/jira/gap-verify.ts
|
|
12858
|
-
import {
|
|
12859
|
-
CASES_REPO_SLUG as CASES_REPO_SLUG3,
|
|
12860
|
-
CliError as CliError29,
|
|
12861
|
-
CliErrorCode as CliErrorCode30,
|
|
12862
|
-
JiraHttpError,
|
|
12863
|
-
JiraNonBmpContentError,
|
|
12864
|
-
NON_BMP_RULE_NOTE,
|
|
12865
|
-
firstLine as firstLine2,
|
|
12866
|
-
nonBmpHitLines,
|
|
12867
|
-
parseRef as parseRef2
|
|
12868
|
-
} from "@hcmai/sdk";
|
|
12869
|
-
var VERIFY_RESULTS = ["pass", "fail", "partial"];
|
|
12870
|
-
var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
|
|
12871
|
-
var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
|
|
12872
|
-
var CLOSED_STATUS = "CLOSE";
|
|
12873
|
-
var EVIDENCE_MIN = 10;
|
|
12874
|
-
var VERIFY_PLAN = {
|
|
12875
|
-
pass: { header: "\u987E\u95EE\u590D\u9A8C\u901A\u8FC7", transition: { name: "\u786E\u8BA4\u5173\u95ED", to: CLOSED_STATUS }, outcome: "closed" },
|
|
12876
|
-
fail: { header: "\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE", transition: { name: "\u672A\u89E3\u51B3", to: "OPEN" }, outcome: "returned" },
|
|
12877
|
-
partial: { header: "\u987E\u95EE\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\uFF0C\u4E0D\u5173\u5355", outcome: "recorded" }
|
|
12878
|
-
};
|
|
12879
|
-
function parseVerifyResult(raw) {
|
|
12880
|
-
const v = String(raw ?? "").trim().toLowerCase();
|
|
12881
|
-
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12882
|
-
throw new CliError29({
|
|
12883
|
-
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12884
|
-
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12885
|
-
context: { nextStep: "pass = \u539F\u6545\u969C\u5728\u76EE\u6807\u73AF\u5883\u4E0D\u518D\u51FA\u73B0\uFF1Bfail = \u4ECD\u7136\u590D\u73B0\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF1Bpartial = \u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF08\u4E0D\u5173\u5355\uFF09\u3002" }
|
|
12886
|
-
});
|
|
12887
|
-
}
|
|
12888
|
-
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12889
|
-
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12890
|
-
}
|
|
12891
|
-
function who(u) {
|
|
12892
|
-
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
12893
|
-
const shown = u.displayName ?? u.name ?? u.key ?? "?";
|
|
12894
|
-
return u.name && u.name !== shown ? `${shown}\uFF08${u.name}\uFF09` : shown;
|
|
12895
|
-
}
|
|
12896
|
-
function sameUser(a, b) {
|
|
12897
|
-
if (!a || !b) return false;
|
|
12898
|
-
if (a.key || b.key) return !!a.key && !!b.key && a.key === b.key;
|
|
12899
|
-
if (a.name && b.name) return a.name === b.name;
|
|
12900
|
-
return false;
|
|
12901
|
-
}
|
|
12902
|
-
var isEmptyValue = (v) => v === void 0 || v === null || typeof v === "string" && !v.trim() || Array.isArray(v) && v.length === 0;
|
|
12903
|
-
var fieldLabel = ([id, f]) => `${f.name ?? id}(${id})`;
|
|
12904
|
-
function checkRequiredFields(t, issue) {
|
|
12905
|
-
if (!t.fields) return null;
|
|
12906
|
-
const required2 = Object.entries(t.fields).filter(([, f]) => f.required === true);
|
|
12907
|
-
return {
|
|
12908
|
-
checked: required2.map(fieldLabel),
|
|
12909
|
-
missing: required2.filter(([id]) => isEmptyValue(issue.fields[id])).map(fieldLabel)
|
|
12910
|
-
};
|
|
12911
|
-
}
|
|
12912
|
-
function renderVerifyComment(result, evidence, fp, reporter, versionComparison) {
|
|
12913
|
-
return [
|
|
12914
|
-
VERIFY_PLAN[result].header,
|
|
12915
|
-
`\u73AF\u5883\uFF1A${fp.text}${fp.source === "given" ? "\uFF08\u8C03\u7528\u65B9\u7ED9\u7684\uFF0C\u672A\u73B0\u67E5\uFF09" : ""}`,
|
|
12916
|
-
...versionComparison ? [`${versionComparison.text}`] : [],
|
|
12917
|
-
"\u9A8C\u6536\u8BF4\u660E\uFF1A",
|
|
12918
|
-
evidence.trim(),
|
|
12919
|
-
"",
|
|
12920
|
-
`_\u7531\u63D0\u5355\u4EBA ${reporter} \u7ECF \`hcm chiron gap verify\` \u63D0\u4EA4\u3002_`
|
|
12921
|
-
].join("\n");
|
|
12922
|
-
}
|
|
12923
|
-
function fixRevisionFromComments(comments) {
|
|
12924
|
-
const evidence = [...comments].reverse().find((c2) => {
|
|
12925
|
-
const body = c2.body ?? "";
|
|
12926
|
-
return /已修复|代码库已关闭/.test(body) && /hcm(?:\/|_)hcm[_-]?nx[_-]?core|hcm_nx_core/.test(body) || /hcm_nx_core(?:#\d+)?[^\n]{0,180}revision\s+r\d+/i.test(body);
|
|
12927
|
-
});
|
|
12928
|
-
if (!evidence) return void 0;
|
|
12929
|
-
const revisions = [...(evidence.body ?? "").matchAll(/(?:hcm\/)?hcm_nx_core(?:#\d+)?[^\n]{0,180}?revision\s+r(\d+)/gi)].map((m) => Number(m[1])).filter((n) => Number.isSafeInteger(n));
|
|
12930
|
-
return revisions.length ? Math.max(...revisions) : void 0;
|
|
12931
|
-
}
|
|
12932
|
-
function notFixedNextStep(key2, status, result) {
|
|
12933
|
-
if (status === CLOSED_STATUS) {
|
|
12934
|
-
return `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u80FD\u518D${result === "fail" ? "\u9000\u56DE" : "\u8BB0\u5F55\u90E8\u5206\u901A\u8FC7"}\u3002\u75C7\u72B6\u53C8\u51FA\u73B0\u5C31\u7528 \`hcm chiron gap submit\` \u91CD\u63D0\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u672C\u5355\u53F7 ${key2}\u3002`;
|
|
12903
|
+
const body = renderVerifyComment(o.result, evidence, o.fingerprint, who(reporter), versionComparison);
|
|
12904
|
+
const move = transition ? { id: transition.id, name: transition.name, to: transition.to?.name } : void 0;
|
|
12905
|
+
if (o.dryRun) {
|
|
12906
|
+
return {
|
|
12907
|
+
...base,
|
|
12908
|
+
outcome: "planned",
|
|
12909
|
+
planned: plan.outcome,
|
|
12910
|
+
written: "no",
|
|
12911
|
+
transition: move,
|
|
12912
|
+
comment: { body },
|
|
12913
|
+
requiredFields,
|
|
12914
|
+
requiredChecked,
|
|
12915
|
+
versionComparison,
|
|
12916
|
+
nextStep: "\u8BA1\u5212\u5982\u4E0A\uFF0C\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u6267\u884C\u3002"
|
|
12917
|
+
};
|
|
12935
12918
|
}
|
|
12936
|
-
if (
|
|
12937
|
-
|
|
12919
|
+
if (transition) {
|
|
12920
|
+
const what = `\u6D41\u8F6C\u300C${transition.name}\u300D\u4E0E\u8BC4\u8BBA`;
|
|
12921
|
+
const beforeIds = new Set((await client3.comments(key2)).map((c2) => c2.id));
|
|
12922
|
+
try {
|
|
12923
|
+
await client3.transitionById(key2, transition.id, body);
|
|
12924
|
+
} catch (e) {
|
|
12925
|
+
throw writeFailure(e, key2, what);
|
|
12926
|
+
}
|
|
12927
|
+
const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
|
|
12928
|
+
let after2;
|
|
12929
|
+
try {
|
|
12930
|
+
after2 = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
|
|
12931
|
+
} catch (e) {
|
|
12932
|
+
throw verifyFailure(
|
|
12933
|
+
"readback-failed",
|
|
12934
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12935
|
+
"yes",
|
|
12936
|
+
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
12937
|
+
`\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
|
|
12938
|
+
{ key: key2, comment: comment2.id ?? null },
|
|
12939
|
+
e
|
|
12940
|
+
);
|
|
12941
|
+
}
|
|
12942
|
+
const expected = transition.to?.name ?? "?";
|
|
12943
|
+
const resolutionStuck = o.result === "fail" && !!after2.resolution;
|
|
12944
|
+
if (after2.status !== expected || resolutionStuck) {
|
|
12945
|
+
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
12946
|
+
throw verifyFailure(
|
|
12947
|
+
"readback-mismatch",
|
|
12948
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12949
|
+
"yes",
|
|
12950
|
+
after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
|
|
12951
|
+
after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
|
|
12952
|
+
{ key: key2, before, after: after2, expected, comment: comment2.id ?? null }
|
|
12953
|
+
);
|
|
12954
|
+
}
|
|
12955
|
+
return {
|
|
12956
|
+
...base,
|
|
12957
|
+
outcome: plan.outcome,
|
|
12958
|
+
written: "yes",
|
|
12959
|
+
after: after2,
|
|
12960
|
+
transition: move,
|
|
12961
|
+
comment: comment2,
|
|
12962
|
+
requiredFields,
|
|
12963
|
+
requiredChecked,
|
|
12964
|
+
versionComparison,
|
|
12965
|
+
nextStep: doneNextStep(key2, plan.outcome, comment2.found)
|
|
12966
|
+
};
|
|
12967
|
+
}
|
|
12968
|
+
let written;
|
|
12969
|
+
try {
|
|
12970
|
+
written = await client3.addComment(key2, body);
|
|
12971
|
+
} catch (e) {
|
|
12972
|
+
throw writeFailure(e, key2, "\u8BC4\u8BBA");
|
|
12973
|
+
}
|
|
12974
|
+
let listed;
|
|
12975
|
+
try {
|
|
12976
|
+
listed = await client3.comments(key2);
|
|
12977
|
+
} catch (e) {
|
|
12978
|
+
throw verifyFailure(
|
|
12979
|
+
"readback-failed",
|
|
12980
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12981
|
+
"yes",
|
|
12982
|
+
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
12983
|
+
`\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
|
|
12984
|
+
{ key: key2, comment: written.id ?? null },
|
|
12985
|
+
e
|
|
12986
|
+
);
|
|
12987
|
+
}
|
|
12988
|
+
let comment;
|
|
12989
|
+
if (!written.id) {
|
|
12990
|
+
comment = { body, found: false, note: `Jira \u6CA1\u56DE\u8BC4\u8BBA id\uFF0C\u6CA1\u6CD5\u6309 id \u6838\u5BF9\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
|
|
12991
|
+
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
12992
|
+
throw verifyFailure(
|
|
12993
|
+
"readback-mismatch",
|
|
12994
|
+
CliErrorCode30.SERVER_ERROR,
|
|
12995
|
+
"yes",
|
|
12996
|
+
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
12997
|
+
`\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
|
|
12998
|
+
{ key: key2, comment: written.id }
|
|
12999
|
+
);
|
|
13000
|
+
} else {
|
|
13001
|
+
comment = { body, found: true, id: written.id, url: client3.commentUrl(key2, written.id) };
|
|
12938
13002
|
}
|
|
12939
|
-
|
|
12940
|
-
|
|
13003
|
+
let after;
|
|
13004
|
+
let aside = "";
|
|
13005
|
+
try {
|
|
13006
|
+
after = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
|
|
13007
|
+
if (after.status !== FIXED_STATUS) aside = `\uFF08\u56DE\u8BFB\u65F6\u5355\u5B50\u5DF2\u662F\u300C${after.status ?? "?"}\u300D\u2014\u2014\u8BC4\u8BBA\u5199\u8FDB\u53BB\u4E4B\u540E\u6709\u4EBA\u52A8\u8FC7\u5B83\uFF0C\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\u3002\uFF09`;
|
|
13008
|
+
} catch (e) {
|
|
13009
|
+
const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
13010
|
+
aside = `\uFF08\u56DE\u8BFB\u5355\u5B50\u72B6\u6001\u5931\u8D25\uFF1A${why}\uFF1B\u8BC4\u8BBA\u5DF2\u6838\u5728\u3002\uFF09`;
|
|
12941
13011
|
}
|
|
12942
|
-
return
|
|
13012
|
+
return {
|
|
13013
|
+
...base,
|
|
13014
|
+
outcome: "recorded",
|
|
13015
|
+
written: "yes",
|
|
13016
|
+
after,
|
|
13017
|
+
comment,
|
|
13018
|
+
requiredFields,
|
|
13019
|
+
requiredChecked,
|
|
13020
|
+
versionComparison,
|
|
13021
|
+
nextStep: `${doneNextStep(key2, "recorded", comment.found)}${aside}`
|
|
13022
|
+
};
|
|
12943
13023
|
}
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
13024
|
+
|
|
13025
|
+
// src/jira/gaps.ts
|
|
13026
|
+
var MIN_LEN = [
|
|
13027
|
+
["title", 8],
|
|
13028
|
+
["phenomenon", 20],
|
|
13029
|
+
["repro", 10],
|
|
13030
|
+
["expected", 10],
|
|
13031
|
+
["alternative", 5],
|
|
13032
|
+
["q_mechanism", 10],
|
|
13033
|
+
["q_history", 10],
|
|
13034
|
+
["q_skill", 10]
|
|
13035
|
+
];
|
|
13036
|
+
function validateGapInput(x) {
|
|
13037
|
+
if (!x || typeof x !== "object") throw new Error("\u7F3A\u53E3\u8F7D\u8377\u5FC5\u987B\u662F\u4E00\u4E2A JSON \u5BF9\u8C61");
|
|
13038
|
+
const g = x;
|
|
13039
|
+
const problems = [];
|
|
13040
|
+
for (const [k, min] of MIN_LEN) {
|
|
13041
|
+
const v = k === "title" && typeof g[k] === "string" ? normalizeGapTitle(g[k]) : g[k];
|
|
13042
|
+
if (typeof v !== "string" || v.trim().length < min) problems.push(`${k} \u81F3\u5C11 ${min} \u4E2A\u5B57${k === "title" ? "\uFF08\u4E0D\u542B\u300C\u7F3A\u53E3\uFF1A\u300D\u524D\u7F00\u4E0E\u3014\u7B7E\u540D\u3015\uFF09" : ""}`);
|
|
12955
13043
|
}
|
|
13044
|
+
if (typeof g.title === "string" && normalizeGapTitle(g.title).length > 80) problems.push("title \u4E0D\u8D85\u8FC7 80 \u4E2A\u5B57\uFF08\u4E0D\u542B\u300C\u7F3A\u53E3\uFF1A\u300D\u524D\u7F00\u4E0E\u3014\u7B7E\u540D\u3015\uFF0C\u8FD9\u4E24\u6837 CLI \u4F1A\u81EA\u5DF1\u62FC\uFF09");
|
|
13045
|
+
if (!["\u963B\u65AD", "\u6709\u66FF\u4EE3\u6CD5", "\u63AA\u8F9E\u7EA7"].includes(String(g.severity))) problems.push("severity \u53EA\u80FD\u662F \u963B\u65AD / \u6709\u66FF\u4EE3\u6CD5 / \u63AA\u8F9E\u7EA7");
|
|
13046
|
+
if (!["\u7F3A\u9677", "\u7F3A\u80FD\u529B"].includes(String(g.kind))) problems.push("kind \u53EA\u80FD\u662F \u7F3A\u9677\uFF08\u6545\u969C\uFF09/ \u7F3A\u80FD\u529B\uFF08\u9700\u6C42\uFF09");
|
|
13047
|
+
if (g.module !== void 0 && !["HCM-Core", "HCM-Cloud", "\u4EA7\u54C1\u652F\u6301"].includes(String(g.module))) problems.push("module \u53EA\u80FD\u662F HCM-Core / HCM-Cloud / \u4EA7\u54C1\u652F\u6301");
|
|
13048
|
+
if (g.localWorkaround !== void 0) problems.push("\u672C\u5730\u7ED5\u6CD5\u7684\u5B57\u6BB5\u53EB local_workaround\uFF08\u4E0B\u5212\u7EBF\uFF0C\u4E0E\u5176\u4ED6\u5B57\u6BB5\u540C\u4E00\u5199\u6CD5\uFF09\uFF0C\u4E0D\u662F localWorkaround");
|
|
13049
|
+
if (g.local_workaround !== void 0 && typeof g.local_workaround !== "string") problems.push("local_workaround \u8981\u662F\u4E00\u6BB5\u6587\u5B57\uFF08\u6CA1\u6709\u7ED5\u6CD5\u5C31\u4E0D\u5199\u6216\u5199 none\uFF09");
|
|
13050
|
+
const nonBmp = findNonBmpChars(g);
|
|
13051
|
+
if (nonBmp.length) problems.push(describeNonBmpHits(nonBmp).split("\n").join("\n "));
|
|
13052
|
+
if (problems.length) throw new Error(`\u7F3A\u53E3\u8F7D\u8377\u4E0D\u5408\u683C\uFF0C\u6CA1\u6709\u63D0\uFF1A
|
|
13053
|
+
${problems.join("\n ")}`);
|
|
13054
|
+
return g;
|
|
12956
13055
|
}
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
13056
|
+
var NO_ERROR_CODE = "\u65E0\u9519\u8BEF\u7801";
|
|
13057
|
+
var isMissingCode = (code2) => !code2 || code2 === "-" || code2.startsWith(NO_ERROR_CODE);
|
|
13058
|
+
var gapKeyTag = (g) => `\u3014${[g.model, g.action, isMissingCode(g.error_code) ? NO_ERROR_CODE : g.error_code].filter(Boolean).join("\xB7")}\u3015`;
|
|
13059
|
+
function normalizeGapTitle(title) {
|
|
13060
|
+
let t = (title ?? "").trim();
|
|
13061
|
+
for (; ; ) {
|
|
13062
|
+
const next = t.replace(/^缺口\s*[::]\s*/, "").replace(/\s*〔[^〔〕]*〕\s*$/, "").trim();
|
|
13063
|
+
if (next === t) return t;
|
|
13064
|
+
t = next;
|
|
12960
13065
|
}
|
|
12961
|
-
if (status === 403) return `\u4EE4\u724C\u6709\u6548\uFF0C\u4F46\u4F60\u7684\u8D26\u53F7\u6CA1\u6709 ${key2} \u7684\u8FD9\u6761\u6D41\u8F6C\u6216\u8BC4\u8BBA\u6743\u9650\uFF1A\u627E Jira \u7BA1\u7406\u5458\u5F00\u9879\u76EE\u6743\u9650\uFF0C\u522B\u6362\u522B\u4EBA\u7684\u4EE4\u724C\u3002`;
|
|
12962
|
-
if (status === 404) return `Jira \u8BF4\u627E\u4E0D\u5230 ${key2}\uFF08\u6216\u4F60\u770B\u4E0D\u5230\u5B83\uFF09\uFF1A\u6838\u5BF9\u5355\u53F7\uFF1B\u662F\u4F60\u81EA\u5DF1\u63D0\u7684\u5355\u5374\u770B\u4E0D\u5230\uFF0C\u627E Jira \u7BA1\u7406\u5458\u3002`;
|
|
12963
|
-
return "\u6309\u300C\u8BE6\u60C5\u300D\u91CC Jira \u7684\u539F\u8BDD\u5904\u7406\uFF1A\u591A\u534A\u662F\u6D41\u8F6C\u521A\u88AB\u6539\u8FC7\u6216\u754C\u9762\u5B57\u6BB5\u53D8\u4E86\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\uFF1B\u522B\u6539\u95EE\u9898\u7C7B\u578B\uFF0C\u4E5F\u522B\u81EA\u5DF1\u62FC HTTP \u7ED5\u8FC7\u3002";
|
|
12964
13066
|
}
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
if (e instanceof TypeError) return "\u8FDE\u63A5\u5931\u8D25";
|
|
12971
|
-
return name;
|
|
13067
|
+
var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${normalizeGapTitle(g.title)} ${gapKeyTag(g)}`;
|
|
13068
|
+
function parseKeyTag(summary) {
|
|
13069
|
+
const m = /〔([^〔〕]*)〕\s*$/.exec(summary ?? "");
|
|
13070
|
+
if (!m) return [];
|
|
13071
|
+
return m[1].split("\xB7").map((s) => s.trim()).filter((s) => s && !isMissingCode(s));
|
|
12972
13072
|
}
|
|
12973
|
-
function
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
13073
|
+
function titleSimilarity(a, b) {
|
|
13074
|
+
const bigrams = (t) => {
|
|
13075
|
+
const x = normalizeGapTitle(t).replace(/[\s,。::、()()「」]/g, "");
|
|
13076
|
+
const out = /* @__PURE__ */ new Set();
|
|
13077
|
+
for (let i = 0; i + 1 < x.length; i++) out.add(x.slice(i, i + 2));
|
|
13078
|
+
return out;
|
|
13079
|
+
};
|
|
13080
|
+
const A = bigrams(a);
|
|
13081
|
+
const B = bigrams(b);
|
|
13082
|
+
if (!A.size || !B.size) return 0;
|
|
13083
|
+
let n = 0;
|
|
13084
|
+
for (const s of A) if (B.has(s)) n++;
|
|
13085
|
+
return n / Math.min(A.size, B.size);
|
|
13086
|
+
}
|
|
13087
|
+
var SIMILARITY_THRESHOLD = 0.6;
|
|
13088
|
+
var MAX_CANDIDATES = 5;
|
|
13089
|
+
var APPEND_REFUSED = /* @__PURE__ */ new Set(["duplicate", "closed-unfixed", "likely-regression"]);
|
|
13090
|
+
var appendRefused = (c2) => c2.status === CLOSED_STATUS || c2.situation !== void 0 && APPEND_REFUSED.has(c2.situation);
|
|
13091
|
+
var VERSION_COMPARED = /* @__PURE__ */ new Set(["fixed-not-deployed", "closed-env-older", "likely-regression", "cannot-compare"]);
|
|
13092
|
+
var comparesVersions = (s) => s !== void 0 && VERSION_COMPARED.has(s);
|
|
13093
|
+
var isFixedCandidate = (c2) => c2.status === FIXED_STATUS || c2.status === CLOSED_STATUS && c2.resolution === DONE_RESOLUTION;
|
|
13094
|
+
function regressionStep(key2, who2) {
|
|
13095
|
+
const both2 = `\u662F ${key2} \u7684\u63D0\u5355\u4EBA\u5C31\u9000\u56DE\u539F\u5355\u3001\u4E0D\u65B0\u5F00\uFF1A${verifyCommand(key2, "fail")}\uFF1B\u4E0D\u662F\u63D0\u5355\u4EBA\u5C31\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${key2}`;
|
|
13096
|
+
if (!who2) return `\u4F60${both2}`;
|
|
13097
|
+
if (who2.reportedByYou === null) return `\u6CA1\u8BA4\u51FA\u4F60\u662F\u4E0D\u662F ${key2} \u7684\u63D0\u5355\u4EBA\uFF08${who2.why}\uFF09\u3002${both2}`;
|
|
13098
|
+
const basis = who2.basis ? `\uFF08${who2.basis}\uFF09` : "";
|
|
13099
|
+
return who2.reportedByYou ? `\u4F60\u662F ${key2} \u7684\u63D0\u5355\u4EBA${basis}\uFF1A\u9000\u56DE\u539F\u5355\u3001\u4E0D\u65B0\u5F00\uFF1A${verifyCommand(key2, "fail")}` : `\u4F60\u4E0D\u662F ${key2} \u7684\u63D0\u5355\u4EBA${basis}\u3001\u9000\u4E0D\u4E86\u539F\u5355\uFF1A\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${key2}`;
|
|
13100
|
+
}
|
|
13101
|
+
var reporterFields = (who2) => !who2 ? {} : who2.reportedByYou === null ? { reportedByYou: null, reportedByYouUnknown: who2.why } : { reportedByYou: who2.reportedByYou, ...who2.basis ? { reportedByYouBasis: who2.basis } : {} };
|
|
13102
|
+
var reporterCheckOf = (c2) => c2.reportedByYou === void 0 ? void 0 : c2.reportedByYou === null ? { reportedByYou: null, why: c2.reportedByYouUnknown ?? "\u539F\u56E0\u672A\u77E5" } : { reportedByYou: c2.reportedByYou, ...c2.reportedByYouBasis ? { basis: c2.reportedByYouBasis } : {} };
|
|
13103
|
+
var gapDedupeJql = (project2) => `project = ${project2} AND (resolution = Unresolved OR status = "${FIXED_STATUS}" OR (status = "${CLOSED_STATUS}" AND resolved >= -90d)) ORDER BY created DESC`;
|
|
13104
|
+
var GAP_DEDUPE_SCOPE = "\u672A\u89E3\u51B3 + \u5DF2\u4FEE\u590D + \u8FD1 90 \u5929 CLOSE";
|
|
13105
|
+
function findGapCandidates(issues, g, client3) {
|
|
13106
|
+
const summary = gapSummary(g);
|
|
13107
|
+
const code2 = isMissingCode(g.error_code) ? void 0 : g.error_code;
|
|
13108
|
+
const out = [];
|
|
13109
|
+
for (const i of issues) {
|
|
13110
|
+
const t = i.fields.summary ?? "";
|
|
13111
|
+
const parts = parseKeyTag(t);
|
|
13112
|
+
const has = (x) => !x || parts.includes(x);
|
|
13113
|
+
let reason;
|
|
13114
|
+
let score;
|
|
13115
|
+
if (code2 && parts.includes(code2) && has(g.model) && has(g.action)) reason = "signature";
|
|
13116
|
+
else if (g.model && g.action && parts.includes(g.model) && parts.includes(g.action)) reason = "same-target";
|
|
13117
|
+
else {
|
|
13118
|
+
const s = titleSimilarity(t, summary);
|
|
13119
|
+
if (s >= SIMILARITY_THRESHOLD) {
|
|
13120
|
+
reason = "similar";
|
|
13121
|
+
score = Math.round(s * 100) / 100;
|
|
13122
|
+
}
|
|
13123
|
+
}
|
|
13124
|
+
if (!reason) continue;
|
|
13125
|
+
out.push({
|
|
13126
|
+
key: i.key,
|
|
13127
|
+
summary: t,
|
|
13128
|
+
status: i.fields.status?.name,
|
|
13129
|
+
resolution: i.fields.resolution?.name,
|
|
13130
|
+
url: client3.browseUrl(i.key),
|
|
13131
|
+
reason,
|
|
13132
|
+
...score !== void 0 ? { score } : {}
|
|
12992
13133
|
});
|
|
12993
13134
|
}
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
CliErrorCode30.NETWORK_ERROR,
|
|
12997
|
-
"unknown",
|
|
12998
|
-
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12999
|
-
`\u5148\u7528 \`hcm chiron gap status ${key2}\` \u4E0E \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\u5199\u8FDB\u53BB\u6CA1\u6709\uFF0C\u518D\u51B3\u5B9A\u8981\u4E0D\u8981\u91CD\u8DD1\u2014\u2014partial \u91CD\u8DD1\u4F1A\u591A\u4E00\u6761\u8BC4\u8BBA\u3002`,
|
|
13000
|
-
{ key: key2, ...e instanceof JiraHttpError ? { status: e.status } : {} },
|
|
13001
|
-
e
|
|
13002
|
-
);
|
|
13135
|
+
const rank = { signature: 0, "same-target": 1, similar: 2, named: 3 };
|
|
13136
|
+
return out.sort((a, b) => rank[a.reason] - rank[b.reason] || (b.score ?? 0) - (a.score ?? 0));
|
|
13003
13137
|
}
|
|
13004
|
-
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
|
|
13008
|
-
|
|
13009
|
-
const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
13010
|
-
return { body, found: false, note: `\u6D41\u8F6C\u5DF2\u63D0\u4EA4\uFF0C\u4F46\u56DE\u8BFB\u8BC4\u8BBA\u5931\u8D25\uFF08${why}\uFF09\uFF1B\u4EE5 \`hcm chiron gap comments ${key2}\` \u4E3A\u51C6\u3002` };
|
|
13138
|
+
function classifyCandidate(c2, fixRevision, fingerprint, readError, who2) {
|
|
13139
|
+
const fixed = c2.status === FIXED_STATUS;
|
|
13140
|
+
if (isDuplicateGap(c2)) return { situation: "duplicate", advice: DUPLICATE_ADVICE };
|
|
13141
|
+
if (c2.status === CLOSED_STATUS && c2.resolution !== DONE_RESOLUTION) {
|
|
13142
|
+
return { situation: "closed-unfixed", advice: `\u539F\u5355\u6CA1\u4FEE\u5C31\u5173\u4E86\uFF08${c2.resolution ?? "\u65E0 resolution"}\uFF09\u3002\u75C7\u72B6\u8FD8\u5728\u5C31\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${c2.key}` };
|
|
13011
13143
|
}
|
|
13012
|
-
|
|
13013
|
-
|
|
13014
|
-
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
throw verifyFailure(
|
|
13018
|
-
"not-jira-key",
|
|
13019
|
-
CliErrorCode30.INVALID_ARGUMENT,
|
|
13020
|
-
"no",
|
|
13021
|
-
parsed && parsed.kind === "repo" ? `${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u9A8C\u6536\u8981\u843D\u5728 Jira \u5355\u4E0A` : `\u770B\u4E0D\u61C2 ${ref}`,
|
|
13022
|
-
"\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u2014\u2014\u5C31\u662F `hcm chiron gap submit` \u56DE\u6267\u91CC\u7684\u90A3\u4E2A\u7F16\u53F7\u3002"
|
|
13023
|
-
);
|
|
13144
|
+
if (!isFixedCandidate(c2)) {
|
|
13145
|
+
if (c2.status === "\u7EB3\u5165\u89C4\u5212") return { situation: "planned", advice: `\u5DF2\u6392\u671F\u3002\u786E\u8BA4\u662F\u540C\u4E00\u4E2A\u7F3A\u53E3\u5C31\u52A0 --append-to ${c2.key} \u8FFD\u52A0\u73B0\u573A\uFF0C\u4F5C\u4E3A\u4F18\u5148\u7EA7\u4F9D\u636E\uFF0C\u4E0D\u65B0\u5F00` };
|
|
13146
|
+
if (c2.status === "\u4E0D\u5904\u7406") return { situation: "declined", advice: `\u4EA7\u54C1\u4FA7\u5224\u4E86\u4E0D\u5904\u7406\uFF0C\u5148\u770B\u90A3\u5355\u7684\u7406\u7531\u4E0E\u66FF\u4EE3\u6CD5\uFF1B\u540C\u4E00\u7F3A\u53E3\u4E14\u4E0D\u8BA4\u540C\uFF0C\u5C31\u52A0 --append-to ${c2.key} \u5199\u6E05\u4E3A\u4EC0\u4E48\uFF0C\u5B83\u8FD8\u80FD\u88AB\u91CD\u5F00` };
|
|
13147
|
+
if (c2.status === "\u8865\u5145\u8BF4\u660E") return { situation: "open", advice: `\u88AB\u6253\u56DE\u8865\u5145\u8BF4\u660E\uFF0C\u7403\u5728\u63D0\u5355\u4EBA\u624B\u4E0A\u3002\u786E\u8BA4\u662F\u540C\u4E00\u4E2A\u7F3A\u53E3\u5C31\u52A0 --append-to ${c2.key} \u628A\u7F3A\u7684\u4FE1\u606F\u8865\u8FDB\u53BB\uFF0C\u4E0D\u65B0\u5F00` };
|
|
13148
|
+
return { situation: "open", advice: `\u8FD8\u5728\u5904\u7406\u4E2D\u3002\u786E\u8BA4\u662F\u540C\u4E00\u4E2A\u7F3A\u53E3\u5C31\u52A0 --append-to ${c2.key} \u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00` };
|
|
13024
13149
|
}
|
|
13025
|
-
const
|
|
13026
|
-
|
|
13027
|
-
|
|
13028
|
-
|
|
13029
|
-
|
|
13030
|
-
|
|
13031
|
-
|
|
13032
|
-
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
if (!inProject(key2)) throw wrongProject(key2);
|
|
13036
|
-
const evidence = o.evidence.trim();
|
|
13037
|
-
if (evidence.length < EVIDENCE_MIN) {
|
|
13038
|
-
throw verifyFailure(
|
|
13039
|
-
"evidence-too-short",
|
|
13040
|
-
CliErrorCode30.INVALID_ARGUMENT,
|
|
13041
|
-
"no",
|
|
13042
|
-
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
13043
|
-
"\u5199\u6E05\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\uFF08`hcm version`\uFF09\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\uFF1B\u8BC1\u636E\u6587\u4EF6\u653E\u5728 evidence/ \u4E0B\u5E76\u5199\u4E0A\u8DEF\u5F84\u3002",
|
|
13044
|
-
{ key: key2 }
|
|
13045
|
-
);
|
|
13150
|
+
const env2 = Number.isSafeInteger(fingerprint.revision) ? fingerprint.revision : void 0;
|
|
13151
|
+
if (fixRevision === void 0 || env2 === void 0) {
|
|
13152
|
+
const missing = fixRevision === void 0 ? `\u4FEE\u590D\u7248\u672C\u672A\u77E5\uFF1A${readError ? `\u8BFB\u539F\u5355\u8BC4\u8BBA\u5931\u8D25\uFF08${readError}\uFF09` : "\u539F\u5355\u8BC4\u8BBA\u91CC\u6CA1\u6709 hcm_nx_core \u7684\u4FEE\u590D revision"}` : `\u73AF\u5883\u7248\u672C\u672A\u77E5\uFF1A${fingerprint.revisionError ?? "\u73AF\u5883\u7248\u672C\u63A5\u53E3\u6CA1\u6709 revision"}`;
|
|
13153
|
+
return {
|
|
13154
|
+
situation: "cannot-compare",
|
|
13155
|
+
...fixRevision !== void 0 ? { fixRevision } : {},
|
|
13156
|
+
...env2 !== void 0 ? { environmentRevision: env2 } : {},
|
|
13157
|
+
// 已修复与已关闭分开说:已关闭的单复验不了(gap verify 在 CLOSE 上不写或拒绝)
|
|
13158
|
+
advice: fixed ? `\u6BD4\u4E0D\u4E86\u4F60\u7684\u73AF\u5883\u6709\u6CA1\u6709\u8FD9\u6B21\u4FEE\u590D\uFF08${missing}\uFF09\u3002${envFirst(env2)}\u5230 ${c2.key} \u4E0B\u5BF9\u7167\u4FEE\u590D\u8BF4\u660E\uFF1A\u8FD8\u6CA1\u90E8\u7F72\u5230\u5C31\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\u539F\u5355\uFF08${verifyCommand(c2.key)}\uFF09\uFF1B\u5DF2\u90E8\u7F72\u4ECD\u590D\u73B0\uFF1A${regressionStep(c2.key, who2)}` : `\u539F\u5355\u5DF2\u590D\u9A8C\u5173\u95ED\uFF0C\u6BD4\u4E0D\u4E86\u4F60\u7684\u73AF\u5883\u6709\u6CA1\u6709\u8FD9\u6B21\u4FEE\u590D\uFF08${missing}\uFF09\u3002${envFirst(env2)}\u5230 ${c2.key} \u4E0B\u5BF9\u7167\u4FEE\u590D\u8BF4\u660E\uFF1A\u73AF\u5883\u65E9\u4E8E\u4FEE\u590D\u5C31\u5347\u7EA7\u540E\u518D\u770B\uFF1B\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\u5C31\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${c2.key}`
|
|
13159
|
+
};
|
|
13046
13160
|
}
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13161
|
+
if (env2 < fixRevision) {
|
|
13162
|
+
return fixed ? { situation: "fixed-not-deployed", fixRevision, environmentRevision: env2, advice: `\u4FEE\u590D\u5DF2\u5408\u5165\u4F46\u8FD8\u6CA1\u90E8\u7F72\u5230\u4F60\u7684\u73AF\u5883\uFF08r${env2} < \u4FEE\u590D r${fixRevision}\uFF09\u3002\u4E0D\u65B0\u5F00\uFF1B\u90E8\u7F72\u540E\u6309 ${c2.key} \u590D\u9A8C\uFF1A${verifyCommand(c2.key)}` } : { situation: "closed-env-older", fixRevision, environmentRevision: env2, advice: `\u539F\u5355\u5DF2\u590D\u9A8C\u5173\u95ED\uFF0C\u4F60\u7684\u73AF\u5883\u7248\u672C\u65E9\u4E8E\u4FEE\u590D\uFF08r${env2} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u662F\u65E7\u7248\u672C\u91CD\u649E\u3002\u4E0D\u65B0\u5F00\uFF1B\u5347\u7EA7\u73AF\u5883\u540E\u518D\u770B` };
|
|
13163
|
+
}
|
|
13164
|
+
return fixed ? { situation: "likely-regression", fixRevision, environmentRevision: env2, advice: `\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\uFF08r${env2} \u2265 \u4FEE\u590D r${fixRevision}\uFF09\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\u3002${regressionStep(c2.key, who2)}` } : { situation: "likely-regression", fixRevision, environmentRevision: env2, advice: `\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\uFF08r${env2} \u2265 \u4FEE\u590D r${fixRevision}\uFF09\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\u3002\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A ${c2.key}` };
|
|
13165
|
+
}
|
|
13166
|
+
function localWorkaroundText(g) {
|
|
13167
|
+
const v = (g.local_workaround ?? "").trim().replace(/\s*\r?\n\s*/g, " / ");
|
|
13168
|
+
const bare = v.replace(/^[\s。..!!,,、;;::]+|[\s。..!!,,、;;::]+$/g, "").toLowerCase();
|
|
13169
|
+
return !bare || NO_WORKAROUND.has(bare) ? "none" : v;
|
|
13170
|
+
}
|
|
13171
|
+
var NO_WORKAROUND = /* @__PURE__ */ new Set(["none", "n/a", "na", "-", "\u65E0", "\u6CA1\u6709", "\u65E0\u7ED5\u6CD5", "\u6CA1\u6709\u7ED5\u6CD5", "\u65E0\u672C\u5730\u7ED5\u6CD5", "\u6CA1\u6709\u672C\u5730\u7ED5\u6CD5"]);
|
|
13172
|
+
function renderGapDescription(g, fingerprintText) {
|
|
13173
|
+
return [
|
|
13174
|
+
"h2. \u73B0\u8C61",
|
|
13175
|
+
g.phenomenon,
|
|
13176
|
+
"",
|
|
13177
|
+
"h2. \u590D\u73B0",
|
|
13178
|
+
"{code}",
|
|
13179
|
+
g.repro,
|
|
13180
|
+
"{code}",
|
|
13181
|
+
"",
|
|
13182
|
+
"h2. \u671F\u671B",
|
|
13183
|
+
g.expected,
|
|
13184
|
+
"",
|
|
13185
|
+
"h2. \u73AF\u5883\u6307\u7EB9",
|
|
13186
|
+
fingerprintText,
|
|
13187
|
+
"",
|
|
13188
|
+
"h2. \u66FF\u4EE3\u6CD5",
|
|
13189
|
+
g.alternative,
|
|
13190
|
+
"",
|
|
13191
|
+
"h2. \u672C\u5730\u7ED5\u6CD5",
|
|
13192
|
+
`localWorkaround: ${localWorkaroundText(g)}`,
|
|
13193
|
+
"",
|
|
13194
|
+
"h2. \u4E25\u91CD\u5EA6",
|
|
13195
|
+
`${g.severity}\uFF08\u987E\u95EE\u4FA7\u5224\u5B9A\uFF1A\u963B\u65AD=\u4EA4\u4ED8\u505C\u4E0B / \u6709\u66FF\u4EE3\u6CD5=\u80FD\u7ED5 / \u63AA\u8F9E\u7EA7=\u8F93\u51FA\u5DF2\u7ED9\u8DEF\u6807\uFF09`,
|
|
13196
|
+
"",
|
|
13197
|
+
"h2. \u4E09\u95EE\u81EA\u7B54",
|
|
13198
|
+
`# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
|
|
13199
|
+
`# \u5386\u53F2\uFF1A${g.q_history}`,
|
|
13200
|
+
`# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
|
|
13201
|
+
"",
|
|
13202
|
+
"h2. \u5173\u952E\u8BCD",
|
|
13203
|
+
[g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
|
|
13204
|
+
"",
|
|
13205
|
+
"_\u7531\u987E\u95EE agent \u7ECF `hcm chiron gap submit` \u63D0\u4EA4\u3002\u5206\u8BCA\u4E09\u53BB\u5411\uFF1A\u8F6C\u4EA7\u54C1\u4ED3 issue \u5E76\u56DE\u94FE / \u6539\u6280\u80FD\u5E76\u56DE\u590D / \u5408\u5E76\u8BA1\u6570\u3002\u5904\u7406\u529E\u6CD5\u89C1\u4EA7\u54C1\u4ED3\u6280\u80FD jira-triage\u3002_"
|
|
13206
|
+
].join("\n");
|
|
13207
|
+
}
|
|
13208
|
+
var KIND_TO_TYPE = { \u7F3A\u9677: ["\u6545\u969C", "Bug", "\u7F3A\u9677"], \u7F3A\u80FD\u529B: ["\u9700\u6C42", "Story", "New Feature"] };
|
|
13209
|
+
var KIND_TO_CATEGORY = { \u7F3A\u9677: "\u7A0B\u5E8FBug", \u7F3A\u80FD\u529B: "\u9700\u6C42" };
|
|
13210
|
+
var SEVERITY_TO_PRIORITY = {
|
|
13211
|
+
\u963B\u65AD: ["\u7D27\u6025", "Highest", "High", "\u9AD8"],
|
|
13212
|
+
\u6709\u66FF\u4EE3\u6CD5: ["Medium", "\u4E2D", "\u4E00\u822C", "High"],
|
|
13213
|
+
\u63AA\u8F9E\u7EA7: ["Low", "\u4F4E", "Lowest"]
|
|
13214
|
+
};
|
|
13215
|
+
var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
|
|
13216
|
+
function buildGapFields(g, ctx) {
|
|
13217
|
+
const wanted = KIND_TO_TYPE[g.kind] ?? [];
|
|
13218
|
+
const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
|
|
13219
|
+
if (!type) {
|
|
13220
|
+
throw new Error(`\u9879\u76EE ${ctx.project} \u91CC\u6CA1\u6709\u300C${wanted.join(" / ")}\u300D\u8FD9\u7C7B issuetype\uFF0C\u5B9E\u9645\u6709\uFF1A${ctx.types.map((t) => t.name).join(" / ")}`);
|
|
13221
|
+
}
|
|
13222
|
+
const module = g.module ?? "HCM-Core";
|
|
13223
|
+
const keyTag = gapKeyTag(g);
|
|
13224
|
+
const byName = {
|
|
13225
|
+
\u6982\u8981: gapSummary(g),
|
|
13226
|
+
\u63CF\u8FF0: renderGapDescription(g, ctx.fingerprintText) + (ctx.dedupeNote ? `
|
|
13227
|
+
|
|
13228
|
+
${ctx.dedupeNote}` : ""),
|
|
13229
|
+
\u95EE\u9898\u7C7B\u522B: KIND_TO_CATEGORY[g.kind],
|
|
13230
|
+
\u95EE\u9898\u6A21\u5757: module,
|
|
13231
|
+
\u4F18\u5148\u7EA7: SEVERITY_TO_PRIORITY[g.severity],
|
|
13232
|
+
\u62A5\u544A\u4EBA: ctx.me,
|
|
13233
|
+
\u7ECF\u529E\u4EBA: ctx.assignee,
|
|
13234
|
+
Bug\u53D1\u73B0\u4EBA: "\u987E\u95EE",
|
|
13235
|
+
Bug\u91CD\u73B0\u64CD\u4F5C\u6B65\u9AA4: g.repro,
|
|
13236
|
+
Bug\u9519\u8BEF\u53F7: g.error_code || "\u65E0\u9519\u8BEF\u7801\uFF08\u73B0\u8C61\u89C1\u63CF\u8FF0\uFF09"
|
|
13062
13237
|
};
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13238
|
+
const fields = { project: { key: ctx.project }, issuetype: { id: type.id } };
|
|
13239
|
+
const unfilled = [];
|
|
13240
|
+
const values = (f) => (f.allowedValues ?? []).map((v) => v.value ?? v.name).join("|");
|
|
13241
|
+
for (const f of type.fields ?? []) {
|
|
13242
|
+
if (["project", "issuetype"].includes(f.fieldId)) continue;
|
|
13243
|
+
const want = byName[f.name];
|
|
13244
|
+
if (want === void 0) {
|
|
13245
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId})${f.allowedValues ? `=[${values(f)}]` : ""}`);
|
|
13246
|
+
continue;
|
|
13247
|
+
}
|
|
13248
|
+
if (f.schema?.type === "option-with-child") {
|
|
13249
|
+
const parent = (f.allowedValues ?? []).find((v) => (v.value ?? v.name) === want);
|
|
13250
|
+
if (!parent) {
|
|
13251
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
13252
|
+
continue;
|
|
13253
|
+
}
|
|
13254
|
+
const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
|
|
13255
|
+
const child = (parent.children ?? []).find((c2) => (c2.value ?? c2.name) === childName);
|
|
13256
|
+
if (!child && (parent.children ?? []).length) {
|
|
13257
|
+
unfilled.push(`${f.name}(${f.fieldId}) \u7684\u4E8C\u7EA7\u9879\u300C${childName}\u300D\u4E0D\u5728 [${(parent.children ?? []).map((c2) => c2.value ?? c2.name).join("|")}] \u91CC`);
|
|
13258
|
+
continue;
|
|
13259
|
+
}
|
|
13260
|
+
fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
|
|
13261
|
+
continue;
|
|
13262
|
+
}
|
|
13263
|
+
if (f.allowedValues) {
|
|
13264
|
+
const candidates = Array.isArray(want) ? want : [want];
|
|
13265
|
+
const hit = candidates.map((c2) => f.allowedValues.find((v) => (v.name ?? v.value) === c2)).find(Boolean);
|
|
13266
|
+
if (!hit) {
|
|
13267
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${candidates.join("/")}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
13268
|
+
continue;
|
|
13269
|
+
}
|
|
13270
|
+
fields[f.fieldId] = hit.id ? { id: hit.id } : { name: hit.name ?? hit.value };
|
|
13271
|
+
} else if (f.schema?.type === "user") {
|
|
13272
|
+
if (!want) {
|
|
13273
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
|
|
13274
|
+
continue;
|
|
13275
|
+
}
|
|
13276
|
+
fields[f.fieldId] = { name: Array.isArray(want) ? want[0] : want };
|
|
13277
|
+
} else {
|
|
13278
|
+
fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
|
|
13279
|
+
}
|
|
13072
13280
|
}
|
|
13073
|
-
if (
|
|
13074
|
-
const
|
|
13075
|
-
|
|
13281
|
+
if ((type.fields ?? []).some((f) => f.fieldId === "labels")) {
|
|
13282
|
+
const sev = { \u963B\u65AD: "blocking", \u6709\u66FF\u4EE3\u6CD5: "workaround", \u63AA\u8F9E\u7EA7: "wording" }[g.severity];
|
|
13283
|
+
fields.labels = ["chiron-gap", `severity-${sev}`];
|
|
13076
13284
|
}
|
|
13077
|
-
if (
|
|
13078
|
-
throw
|
|
13079
|
-
|
|
13080
|
-
|
|
13081
|
-
|
|
13082
|
-
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
13083
|
-
notFixedNextStep(key2, status, o.result),
|
|
13084
|
-
{ key: key2, status }
|
|
13285
|
+
if (unfilled.length) {
|
|
13286
|
+
throw new Error(
|
|
13287
|
+
`\u8FD9\u53F0 Jira \u7684\u300C${type.name}\u300D\u6709\u6211\u586B\u4E0D\u4E0A\u7684\u5FC5\u586B\u5B57\u6BB5\uFF0C\u6CA1\u6709\u5EFA\u5355\uFF08\u4E0D\u66FF\u4F60\u731C\uFF09\uFF1A
|
|
13288
|
+
${unfilled.join("\n ")}
|
|
13289
|
+
next_step=\u8BA9 Jira \u7BA1\u7406\u5458\u628A\u8FD9\u4E9B\u5B57\u6BB5\u6539\u6210\u975E\u5FC5\u586B\uFF0C\u6216\u544A\u8BC9\u6211\u8BE5\u586B\u4EC0\u4E48\u3001\u6211\u52A0\u8FDB\u6620\u5C04\u3002\u53F0\u8D26\u5DF2\u7ECF\u5728\u9879\u76EE\u4ED3\u91CC\uFF0C\u4E0D\u4F1A\u4E22\u3002`
|
|
13085
13290
|
);
|
|
13086
13291
|
}
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13292
|
+
return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
|
|
13293
|
+
}
|
|
13294
|
+
async function withSituation(client3, c2, fingerprint, reporter) {
|
|
13295
|
+
if (!isFixedCandidate(c2)) return { ...c2, ...classifyCandidate(c2, void 0, fingerprint) };
|
|
13296
|
+
const who2 = c2.status === FIXED_STATUS ? await reporter() : void 0;
|
|
13297
|
+
try {
|
|
13298
|
+
return { ...c2, ...classifyCandidate(c2, fixRevisionFromComments(await client3.comments(c2.key)), fingerprint, void 0, who2), ...reporterFields(who2) };
|
|
13299
|
+
} catch (e) {
|
|
13300
|
+
return { ...c2, ...classifyCandidate(c2, void 0, fingerprint, firstLine3(String(e.message ?? e)), who2), ...reporterFields(who2) };
|
|
13301
|
+
}
|
|
13302
|
+
}
|
|
13303
|
+
function reporterChecker(client3) {
|
|
13304
|
+
let me;
|
|
13305
|
+
const myself = () => me ??= client3.myself();
|
|
13306
|
+
const check = async (reporter) => {
|
|
13307
|
+
let you;
|
|
13091
13308
|
try {
|
|
13092
|
-
|
|
13309
|
+
you = await myself();
|
|
13093
13310
|
} catch (e) {
|
|
13094
|
-
|
|
13095
|
-
}
|
|
13096
|
-
const fixRevision = comments ? fixRevisionFromComments(comments) : void 0;
|
|
13097
|
-
if (fixRevision === void 0) {
|
|
13098
|
-
const reason = readReason ? `\u8BFB\u53D6\u4EA7\u54C1\u4FA7\u5DF2\u4FEE\u590D\u8BC1\u636E\u5931\u8D25\uFF1A${readReason}` : "\u8BC4\u8BBA\u4E2D\u6CA1\u6709 hcm_nx_core \u7684 revision \u8BC1\u636E";
|
|
13099
|
-
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, reason };
|
|
13100
|
-
} else if (!Number.isSafeInteger(o.fingerprint.revision)) {
|
|
13101
|
-
const reason = o.fingerprint.revisionError ?? "\u73AF\u5883\u7248\u672C\u63A5\u53E3\u6CA1\u6709 revision \u5B57\u6BB5\uFF08\u53EF\u80FD\u662F\u65E7\u540E\u7AEF\uFF09";
|
|
13102
|
-
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, fixRevision, reason };
|
|
13103
|
-
} else if (o.fingerprint.revision < fixRevision) {
|
|
13104
|
-
const environmentRevision = o.fingerprint.revision;
|
|
13105
|
-
const message = `\u73AF\u5883\u5C1A\u672A\u5305\u542B\u4FEE\u590D\uFF08\u5F53\u524D r${environmentRevision} < \u4FEE\u590D r${fixRevision}\uFF09\uFF0C\u8BF7\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF1B\u81EA\u67E5 curl <env>/api/version/backend`;
|
|
13106
|
-
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
13107
|
-
} else {
|
|
13108
|
-
const environmentRevision = o.fingerprint.revision;
|
|
13109
|
-
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
13311
|
+
return { reportedByYou: null, why: `\u8BFB Jira \u5F53\u524D\u8EAB\u4EFD\u5931\u8D25\uFF1A${firstLine3(String(e.message ?? e))}` };
|
|
13110
13312
|
}
|
|
13313
|
+
if (!you) return { reportedByYou: null, why: "\u8BFB Jira \u5F53\u524D\u8EAB\u4EFD\u5931\u8D25\uFF1A/myself \u56DE\u4E86\u7A7A\u6B63\u6587" };
|
|
13314
|
+
if (!reporter) return { reportedByYou: null, why: "\u539F\u5355\u6CA1\u5E26\u63D0\u5355\u4EBA" };
|
|
13315
|
+
const comparable = reporter.key || you.key ? Boolean(reporter.key && you.key) : Boolean(reporter.name && you.name);
|
|
13316
|
+
if (!comparable) return { reportedByYou: null, why: "\u63D0\u5355\u4EBA\u4E0E\u5F53\u524D\u8EAB\u4EFD\u6CA1\u6709\u53EF\u6BD4\u7684\u7528\u6237\u952E\u6216\u767B\u5F55\u540D" };
|
|
13317
|
+
return { reportedByYou: sameUser(reporter, you), basis: `\u63D0\u5355\u4EBA ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD ${who(you)}` };
|
|
13318
|
+
};
|
|
13319
|
+
return { myself, check };
|
|
13320
|
+
}
|
|
13321
|
+
var reasonText = (c2) => c2.reason === "signature" ? "\u9519\u8BEF\u7801\u4E00\u81F4" : c2.reason === "same-target" ? "Model \u4E0E Action \u4E00\u81F4" : c2.reason === "named" ? "\u4F60\u70B9\u540D\u7684\u5355\uFF08\u6CA1\u7B97\u76F8\u4F3C\u5EA6\uFF09" : `\u6807\u9898\u76F8\u4F3C ${c2.score}`;
|
|
13322
|
+
var describeCandidate = (c2) => `${c2.key} [${c2.status ?? "?"}${c2.resolution ? "\xB7" + c2.resolution : ""}] ${reasonText(c2)}\uFF1A${c2.summary}`;
|
|
13323
|
+
function renderDedupeNote(candidates, total = candidates.length) {
|
|
13324
|
+
if (!candidates.length) return "";
|
|
13325
|
+
return [
|
|
13326
|
+
"h2. \u67E5\u91CD",
|
|
13327
|
+
"\u63D0\u4EA4\u4EBA\u770B\u8FC7\u4EE5\u4E0B\u76F8\u4F3C\u5355\u540E\u65B0\u5F00\u672C\u5355\uFF08\u6BCF\u5F20\u4E0E\u672C\u5355\u7684\u5173\u7CFB\u89C1\u62EC\u53F7\u91CC\u7684\u5224\u65AD\uFF1B\u5DF2\u5173\u95ED\u7684\u5355\u4E0D\u80FD\u8FFD\u52A0\uFF0C\u540C\u4E00\u7F3A\u53E3\u65F6\u8BE5\u53BB\u539F\u5355\u3001\u5347\u7EA7\u8FD8\u662F\u65B0\u5F00\uFF0C\u770B\u6BCF\u5F20\u62EC\u53F7\u91CC\u7684\u5224\u65AD\uFF09\uFF1A",
|
|
13328
|
+
...candidates.map((c2) => `# ${describeCandidate(c2)}${c2.advice ? `\uFF08${c2.advice}\uFF09` : ""}`),
|
|
13329
|
+
...total > candidates.length ? [`\u53E6\u6709 ${total - candidates.length} \u5F20\u76F8\u4F3C\u5355\u672A\u5217\uFF08\u53EA\u5217\u524D ${candidates.length} \u5F20\uFF09\u3002`] : []
|
|
13330
|
+
].join("\n");
|
|
13331
|
+
}
|
|
13332
|
+
var envFirst = (env2) => env2 !== void 0 ? `\u4F60\u7684\u73AF\u5883\u662F r${env2}\uFF0C` : "\u5148\u8DD1 hcm version \u770B\u73AF\u5883\u7248\u672C\u3001";
|
|
13333
|
+
function appendedNextStep(t, alternative) {
|
|
13334
|
+
const keep = `\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${alternative}\u300D\u7EE7\u7EED\u4EA4\u4ED8`;
|
|
13335
|
+
switch (t.situation) {
|
|
13336
|
+
case "fixed-not-deployed":
|
|
13337
|
+
return `${t.key} \u5DF2\u4FEE\u590D\uFF0C\u8FD8\u6CA1\u90E8\u7F72\u5230\u4F60\u7684\u73AF\u5883\uFF08\u4FEE\u590D r${t.fixRevision}\uFF09\u3002${keep}\uFF1B\u90E8\u7F72\u540E\u6309\u6280\u80FD\u590D\u9A8C\uFF0C\u518D\u7531\u63D0\u5355\u4EBA\u8DD1 ${verifyCommand(t.key)} \u56DE\u5199\u3002`;
|
|
13338
|
+
case "cannot-compare":
|
|
13339
|
+
return `${t.key} \u5DF2\u4FEE\u590D\uFF0C\u4F46\u6BD4\u4E0D\u4E86\u4F60\u7684\u73AF\u5883\u6709\u6CA1\u6709\u8FD9\u6B21\u4FEE\u590D\u3002${keep}\uFF1B${envFirst(t.environmentRevision)}\u5230 ${t.key} \u4E0B\u5BF9\u7167\u4FEE\u590D\u8BF4\u660E\uFF1A\u6CA1\u90E8\u7F72\u5230\u5C31\u7B49\u90E8\u7F72\u540E\u590D\u9A8C\uFF08${verifyCommand(t.key)}\uFF09\uFF1B\u5DF2\u90E8\u7F72\u4ECD\u590D\u73B0\uFF1A${regressionStep(t.key, reporterCheckOf(t))}\u3002`;
|
|
13340
|
+
case "planned":
|
|
13341
|
+
return `${t.key} \u5DF2\u6392\u671F\uFF1B\u8FD9\u6761\u73B0\u573A\u8BB0\u5728\u90A3\u5355\u7684\u8BC4\u8BBA\u91CC\uFF0C\u5206\u8BCA\u6392\u671F\u65F6\u770B\u5F97\u5230\u3002${keep}\uFF0C\u8981\u63D0\u524D\u5C31\u5728\u5355\u4E0B\u8BF4\u660E\u4E1A\u52A1\u5F71\u54CD\u3002`;
|
|
13342
|
+
case "declined":
|
|
13343
|
+
return `${t.key} \u88AB\u5224\u4E86\u4E0D\u5904\u7406\uFF0C\u8FD9\u6761\u73B0\u573A\u4E0D\u4F1A\u8BA9\u5B83\u81EA\u5DF1\u56DE\u5230\u5206\u8BCA\u961F\u5217\u3002${keep}\uFF1B\u4E0D\u8BA4\u540C\u5C31\u5728\u5355\u4E0B\u5199\u6E05\u4E1A\u52A1\u5F71\u54CD\uFF0C\u8BF7\u4EA7\u54C1\u91CD\u65B0\u8BC4\u4F30\u3002`;
|
|
13344
|
+
default:
|
|
13345
|
+
return t.status === "\u8865\u5145\u8BF4\u660E" ? `${t.key} \u5728\u7B49\u8865\u5145\u8BF4\u660E\uFF1A\u8865\u5168\u540E\u8BA9\u5206\u8BCA\u4EBA\u63A8\u300C\u91CD\u65B0\u63D0\u4EA4\u300D\uFF0C\u4E0D\u63A8\u8FD9\u5355\u4E0D\u4F1A\u5F80\u524D\u8D70\u3002${keep}\u3002` : `\u8FD9\u4E2A\u95EE\u9898\u5DF2\u7ECF\u5728\u4EA7\u54C1\u90A3\u8FB9\u6392\u7740\uFF0C\u7F16\u53F7 ${t.key}\uFF1B${keep}\uFF0C\u5206\u8BCA\u7ED3\u8BBA\u4F1A\u56DE\u5230\u90A3\u5355\u91CC\u3002`;
|
|
13111
13346
|
}
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13347
|
+
}
|
|
13348
|
+
var appendBody = (g, fingerprintText, target) => `\u53C8\u4E00\u4E2A\u73B0\u573A\uFF08${fingerprintText}\uFF09
|
|
13349
|
+
|
|
13350
|
+
**\u73B0\u8C61**\uFF1A${g.phenomenon}
|
|
13351
|
+
|
|
13352
|
+
**\u590D\u73B0**\uFF1A
|
|
13353
|
+
{code}
|
|
13354
|
+
${g.repro}
|
|
13355
|
+
{code}
|
|
13356
|
+
|
|
13357
|
+
**\u66FF\u4EE3\u6CD5**\uFF1A${g.alternative}
|
|
13358
|
+
localWorkaround: ${localWorkaroundText(g)}
|
|
13359
|
+
\u4E25\u91CD\u5EA6\uFF1A${g.severity}` + (target?.advice && comparesVersions(target.situation) ? `
|
|
13360
|
+
|
|
13361
|
+
\u7248\u672C\u5224\u65AD\uFF1A${target.advice}` : "");
|
|
13362
|
+
async function gapSubmit({ client: client3 }, g, opts) {
|
|
13363
|
+
const summary = gapSummary(g);
|
|
13364
|
+
const scope = await client3.searchAll(gapDedupeJql(client3.project), { fields: ["summary", "status", "resolution", "reporter"] });
|
|
13365
|
+
const scanned = { scope: GAP_DEDUPE_SCOPE, count: scope.issues.length, total: scope.total, truncated: scope.truncated };
|
|
13366
|
+
const raw = findGapCandidates(scope.issues, g, client3);
|
|
13367
|
+
const reporters = new Map(scope.issues.map((i) => [i.key, i.fields.reporter]));
|
|
13368
|
+
const who2 = reporterChecker(client3);
|
|
13369
|
+
const candidates = [];
|
|
13370
|
+
for (const c2 of raw.slice(0, MAX_CANDIDATES)) {
|
|
13371
|
+
const judged = await withSituation(client3, c2, opts.fingerprint, () => who2.check(reporters.get(c2.key)));
|
|
13372
|
+
candidates.push({ ...judged, appendable: !appendRefused(judged) });
|
|
13373
|
+
}
|
|
13374
|
+
const base = {
|
|
13375
|
+
summary,
|
|
13376
|
+
alternative: g.alternative,
|
|
13377
|
+
candidates,
|
|
13378
|
+
candidateTotal: raw.length,
|
|
13379
|
+
scanned,
|
|
13380
|
+
localWorkaround: localWorkaroundText(g),
|
|
13381
|
+
localWorkaroundStated: Boolean(g.local_workaround?.trim())
|
|
13382
|
+
};
|
|
13383
|
+
if (opts.appendTo) {
|
|
13384
|
+
const parsed = parseRef2(opts.appendTo, client3.project);
|
|
13385
|
+
if (!parsed || parsed.kind !== "jira" || !parsed.key.startsWith(`${client3.project}-`)) {
|
|
13386
|
+
throw new CliError30({ code: CliErrorCode31.INVALID_ARGUMENT, message: `--append-to \u8981\u7ED9 ${client3.project} \u7684\u5355\u53F7\uFF08\u5982 ${client3.project}-5\uFF09\uFF0C\u6536\u5230\u300C${opts.appendTo}\u300D` });
|
|
13387
|
+
}
|
|
13388
|
+
const issue = await client3.issue(parsed.key, ["summary", "status", "resolution", "reporter"]);
|
|
13389
|
+
const target = await withSituation(client3, {
|
|
13390
|
+
key: parsed.key,
|
|
13391
|
+
summary: issue.fields.summary ?? "",
|
|
13392
|
+
status: issue.fields.status?.name,
|
|
13393
|
+
resolution: issue.fields.resolution?.name,
|
|
13394
|
+
url: client3.browseUrl(parsed.key),
|
|
13395
|
+
...(() => {
|
|
13396
|
+
const hit = raw.find((c2) => c2.key === parsed.key);
|
|
13397
|
+
return hit ? { reason: hit.reason, ...hit.score !== void 0 ? { score: hit.score } : {} } : { reason: "named" };
|
|
13398
|
+
})()
|
|
13399
|
+
}, opts.fingerprint, () => who2.check(issue.fields.reporter));
|
|
13400
|
+
if (appendRefused(target)) {
|
|
13401
|
+
const why = target.status === CLOSED_STATUS ? "\u8FD9\u5355\u5DF2\u5173\u95ED\uFF08\u7EC8\u6001\uFF09\uFF0C\u8FFD\u52A0\u7684\u73B0\u573A\u5206\u8BCA\u770B\u4E0D\u5230" : target.situation === "duplicate" ? "\u8FD9\u5F20\u88AB\u5224\u4E3A\u91CD\u590D\u5355\uFF0C\u73B0\u573A\u8BE5\u8BB0\u5728\u5B83\u6307\u5411\u7684\u539F\u5355\u4E0A" : target.status !== FIXED_STATUS ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF0C\u8981\u65B0\u5F00\u5E76\u5F15\u7528\u539F\u5355" : target.reportedByYou === true ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u539F\u5355\u8FD8\u505C\u5728\u300C\u5DF2\u4FEE\u590D\u300D\uFF0C\u4F60\u662F\u63D0\u5355\u4EBA\uFF0C\u590D\u9A8C\u7ED3\u8BBA\u8BE5\u9000\u56DE\u539F\u5355" : target.reportedByYou === false ? "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u4F60\u4E0D\u662F\u539F\u5355\u63D0\u5355\u4EBA\u3001\u9000\u4E0D\u4E86\u539F\u5355\uFF0C\u8981\u65B0\u5F00\u5E76\u5F15\u7528\u539F\u5355" : "\u4F60\u7684\u73AF\u5883\u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF0C\u7591\u4F3C\u56DE\u5F52\uFF1B\u6309\u4E0B\u4E00\u6B65\u8D70\uFF08\u539F\u5355\u63D0\u5355\u4EBA\u9000\u56DE\u539F\u5355\uFF0C\u4E0D\u662F\u63D0\u5355\u4EBA\u624D\u65B0\u5F00\uFF09";
|
|
13402
|
+
throw new CliError30({
|
|
13403
|
+
code: CliErrorCode31.BUSINESS_RULE_VIOLATION,
|
|
13404
|
+
message: `\u6CA1\u6709\u5F80 ${parsed.key} \u8FFD\u52A0\uFF1A${why}`,
|
|
13405
|
+
context: {
|
|
13406
|
+
reasonCode: "append-refused",
|
|
13407
|
+
key: parsed.key,
|
|
13408
|
+
status: target.status ?? null,
|
|
13409
|
+
resolution: target.resolution ?? null,
|
|
13410
|
+
situation: target.situation ?? null,
|
|
13411
|
+
...reporterFields(reporterCheckOf(target)),
|
|
13412
|
+
nextStep: target.advice ?? "\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u539F\u5355\u53F7"
|
|
13413
|
+
}
|
|
13414
|
+
});
|
|
13130
13415
|
}
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
"
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
);
|
|
13142
|
-
} else {
|
|
13143
|
-
requiredFields = "checked";
|
|
13144
|
-
requiredChecked = req.checked;
|
|
13416
|
+
if (opts.dryRun) {
|
|
13417
|
+
return {
|
|
13418
|
+
...base,
|
|
13419
|
+
outcome: "dry-run",
|
|
13420
|
+
planned: "append",
|
|
13421
|
+
key: parsed.key,
|
|
13422
|
+
url: target.url,
|
|
13423
|
+
target,
|
|
13424
|
+
nextStep: `\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u5C31\u4F1A\u5F80 ${parsed.key} \u8FFD\u52A0\u8FD9\u4E00\u6BB5\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\u3002`
|
|
13425
|
+
};
|
|
13145
13426
|
}
|
|
13427
|
+
await client3.addComment(parsed.key, appendBody(g, opts.fingerprint.text, target));
|
|
13428
|
+
return {
|
|
13429
|
+
...base,
|
|
13430
|
+
outcome: "appended",
|
|
13431
|
+
key: parsed.key,
|
|
13432
|
+
url: target.url,
|
|
13433
|
+
summary: target.summary,
|
|
13434
|
+
target,
|
|
13435
|
+
nextStep: appendedNextStep(target, g.alternative)
|
|
13436
|
+
};
|
|
13146
13437
|
}
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13438
|
+
if ((candidates.length || scanned.truncated) && !opts.forceNew) {
|
|
13439
|
+
const partial = scanned.truncated ? `\u67E5\u91CD\u53EA\u770B\u4E86\u524D ${scanned.count} \u5F20${scanned.total !== null ? `\uFF08\u5171 ${scanned.total} \u5F20\uFF09` : ""}\uFF0C\u53EF\u80FD\u8FD8\u6709\u6CA1\u770B\u5230\u7684\u540C\u4E00\u7F3A\u53E3\u3002` : "";
|
|
13440
|
+
const appendable = candidates.filter((c2) => c2.appendable).map((c2) => c2.key);
|
|
13441
|
+
const choose = !candidates.length ? "\u786E\u8BA4\u4E0D\u662F\u5DF2\u6709\u7684\u7F3A\u53E3\u5C31\u52A0 --new \u65B0\u5F00" : appendable.length ? `\u662F\u540C\u4E00\u4E2A\u7F3A\u53E3\u3001\u4E14\u662F\u80FD\u8FFD\u52A0\u7684\u90A3\u51E0\u5F20\uFF08${appendable.join("\u3001")}\uFF09\u5C31\u52A0 --append-to <\u5355\u53F7>\uFF08\u53EA\u5F80\u4F60\u70B9\u540D\u7684\u90A3\u5F20\u5199\uFF09\uFF1B\u5176\u4F59\u51E0\u5F20\u6309\u5404\u81EA\u540E\u9762\u7684\u63D0\u793A\u8D70\uFF1B\u90FD\u4E0D\u662F\u5C31\u52A0 --new \u65B0\u5F00\uFF08\u5019\u9009\u4F1A\u5199\u8FDB\u65B0\u5355\u7684\u300C\u67E5\u91CD\u300D\u4E00\u8282\uFF09` : `\u5217\u51FA\u7684 ${candidates.length} \u5F20\u90FD\u4E0D\u80FD\u8FFD\u52A0\uFF08\u5DF2\u5173\u95ED\u3001\u91CD\u590D\u6216\u7591\u4F3C\u56DE\u5F52\uFF09\uFF0C\u6309\u6BCF\u5F20\u540E\u9762\u7684\u63D0\u793A\u8D70\uFF08\u91CD\u590D\u5355\u53BB\u539F\u5355\uFF1B\u73AF\u5883\u65E9\u4E8E\u4FEE\u590D\u5148\u5347\u7EA7\u518D\u770B\uFF1B\u5DF2\u4FEE\u590D\u5355\u4E0A\u7591\u4F3C\u56DE\u5F52\u7684\uFF0C\u539F\u5355\u63D0\u5355\u4EBA\u9000\u56DE\u539F\u5355\uFF1B\u6CA1\u4FEE\u5C31\u5173\u3001\u5DF2\u5173\u95ED\u5355\u4E0A\u7591\u4F3C\u56DE\u5F52\u3001\u6216\u4F60\u4E0D\u662F\u539F\u5355\u63D0\u5355\u4EBA\u7684\uFF0C\u624D\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u539F\u5355\u53F7\uFF09\uFF1B\u90FD\u4E0D\u662F\u540C\u4E00\u7F3A\u53E3\u5C31\u52A0 --new\uFF08\u5019\u9009\u4F1A\u5199\u8FDB\u65B0\u5355\u7684\u300C\u67E5\u91CD\u300D\u4E00\u8282\uFF09` + (raw.length > candidates.length ? `\uFF1B\u53E6\u6709 ${raw.length - candidates.length} \u5F20\u6CA1\u5217\uFF0C\u91CC\u9762\u53EF\u80FD\u6709\u80FD\u8FFD\u52A0\u7684\u2014\u2014\u5148\u6536\u7A84\u6807\u9898\u6216\u8865\u9519\u8BEF\u7801\u518D\u67E5` : "");
|
|
13150
13442
|
return {
|
|
13151
13443
|
...base,
|
|
13152
|
-
outcome: "
|
|
13153
|
-
|
|
13154
|
-
written: "no",
|
|
13155
|
-
transition: move,
|
|
13156
|
-
comment: { body },
|
|
13157
|
-
requiredFields,
|
|
13158
|
-
requiredChecked,
|
|
13159
|
-
versionComparison,
|
|
13160
|
-
nextStep: "\u8BA1\u5212\u5982\u4E0A\uFF0C\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u6267\u884C\u3002"
|
|
13444
|
+
outcome: "candidates",
|
|
13445
|
+
nextStep: `\u6CA1\u6709\u63D0\u4EA4\u3002${partial}${choose}\uFF1B\u60F3\u5148\u770B\u4F1A\u5199\u4EC0\u4E48\u518D\u52A0 --dry-run\u3002`
|
|
13161
13446
|
};
|
|
13162
13447
|
}
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13448
|
+
const [types, me, project2] = await Promise.all([client3.createMeta(), who2.myself(), client3.projectInfo()]);
|
|
13449
|
+
const built = buildGapFields(g, {
|
|
13450
|
+
types,
|
|
13451
|
+
me: me.name ?? me.key ?? "",
|
|
13452
|
+
assignee: opts.assigneeOverride || project2.lead?.name || project2.lead?.key,
|
|
13453
|
+
project: client3.project,
|
|
13454
|
+
fingerprintText: opts.fingerprint.text,
|
|
13455
|
+
issuetypeOverride: opts.issuetypeOverride,
|
|
13456
|
+
dedupeNote: renderDedupeNote(candidates, raw.length)
|
|
13457
|
+
});
|
|
13458
|
+
if (opts.dryRun) {
|
|
13459
|
+
return {
|
|
13460
|
+
...base,
|
|
13461
|
+
outcome: "dry-run",
|
|
13462
|
+
planned: "create",
|
|
13463
|
+
summary: built.summary,
|
|
13464
|
+
type: built.type.name,
|
|
13465
|
+
module: built.module,
|
|
13466
|
+
nextStep: "\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u5C31\u4F1A\u6309\u4E0A\u9762\u7684\u6982\u8981\u3001\u7C7B\u578B\u548C\u6A21\u5757\u65B0\u5F00\u3002"
|
|
13467
|
+
};
|
|
13468
|
+
}
|
|
13469
|
+
const created = await client3.createIssue(built.fields);
|
|
13470
|
+
return {
|
|
13471
|
+
...base,
|
|
13472
|
+
outcome: "created",
|
|
13473
|
+
key: created.key,
|
|
13474
|
+
url: client3.browseUrl(created.key),
|
|
13475
|
+
summary: built.summary,
|
|
13476
|
+
type: built.type.name,
|
|
13477
|
+
module: built.module,
|
|
13478
|
+
nextStep: `\u7F3A\u53E3\u5DF2\u63D0\uFF0C\u7F16\u53F7 ${created.key}\uFF1B\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${g.alternative}\u300D\u7EE7\u7EED\uFF0C\u4EA7\u54C1\u5206\u8BCA\u540E\u4F1A\u5728\u90A3\u5355\u91CC\u56DE\u590D\u3002\u62A5\u544A\u91CC\u5199\u300CBLOCKED \xB7 \u5DF2\u63D0 ${created.key} \xB7 \u66FF\u4EE3\u6CD5\uFF1A${g.alternative}\u300D\u3002`
|
|
13479
|
+
};
|
|
13480
|
+
}
|
|
13481
|
+
function searchRow(client3, i) {
|
|
13482
|
+
const state = i.fields.status?.name, resolution = i.fields.resolution?.name;
|
|
13483
|
+
const advice = terminalGapHint({ key: i.key, status: state, resolution });
|
|
13484
|
+
return { where: "Jira", id: i.key, title: i.fields.summary ?? "", state, resolution, url: client3.browseUrl(i.key), ...advice ? { advice } : {} };
|
|
13485
|
+
}
|
|
13486
|
+
async function gapSearch({ client: client3 }, keywords, { includeClosed = true } = {}) {
|
|
13487
|
+
const rows2 = [];
|
|
13488
|
+
let jiraError;
|
|
13489
|
+
let truncated;
|
|
13490
|
+
try {
|
|
13491
|
+
for (const kw of keywords) {
|
|
13492
|
+
const safe = kw.replace(/["\\]/g, " ").trim();
|
|
13493
|
+
const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
|
|
13494
|
+
for (const i of await client3.search(jql, { max: 15 })) {
|
|
13495
|
+
rows2.push(searchRow(client3, i));
|
|
13496
|
+
}
|
|
13497
|
+
}
|
|
13498
|
+
if (!rows2.length) {
|
|
13499
|
+
const jql = includeClosed ? gapDedupeJql(client3.project) : `project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`;
|
|
13500
|
+
const scope = await client3.searchAll(jql, { fields: ["summary", "status", "resolution"] });
|
|
13501
|
+
if (scope.truncated) truncated = { count: scope.issues.length, total: scope.total };
|
|
13502
|
+
for (const i of scope.issues) {
|
|
13503
|
+
if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
|
|
13504
|
+
rows2.push(searchRow(client3, i));
|
|
13505
|
+
}
|
|
13506
|
+
}
|
|
13507
|
+
}
|
|
13508
|
+
} catch (e) {
|
|
13509
|
+
jiraError = e.message;
|
|
13510
|
+
}
|
|
13511
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13512
|
+
return { rows: rows2.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), ...jiraError ? { jiraError } : {}, ...truncated ? { truncated } : {} };
|
|
13513
|
+
}
|
|
13514
|
+
var VERIFY_OVERDUE_DAYS = 14;
|
|
13515
|
+
var DAY_MS = 864e5;
|
|
13516
|
+
var pendingVerifyJql = (project2) => `project = ${project2} AND reporter = currentUser() AND status = "${FIXED_STATUS}" AND status CHANGED TO "${FIXED_STATUS}" BEFORE -${VERIFY_OVERDUE_DAYS}d ORDER BY key ASC`;
|
|
13517
|
+
var verifyCommand = (key2, result = "pass|fail|partial") => `hcm chiron gap verify ${key2} --result ${result} --body <\u8BC1\u636E>`;
|
|
13518
|
+
var entersStatus = (h, status) => (h.items ?? []).some((it) => it.field === "status" && it.toString === status);
|
|
13519
|
+
function lastEnteredStatus(histories, status) {
|
|
13520
|
+
let last;
|
|
13521
|
+
let lastMs = -Infinity;
|
|
13522
|
+
for (const h of histories) {
|
|
13523
|
+
const ms = Date.parse(h.created ?? "");
|
|
13524
|
+
if (entersStatus(h, status) && Number.isFinite(ms) && ms > lastMs) {
|
|
13525
|
+
lastMs = ms;
|
|
13526
|
+
last = h.created;
|
|
13527
|
+
}
|
|
13528
|
+
}
|
|
13529
|
+
return last;
|
|
13530
|
+
}
|
|
13531
|
+
var unparseableEntries = (histories, status) => histories.filter((h) => entersStatus(h, status) && !Number.isFinite(Date.parse(h.created ?? ""))).map((h) => String(h.created ?? "\uFF08\u7A7A\uFF09"));
|
|
13532
|
+
var PENDING_VERIFY_CONCURRENCY = 4;
|
|
13533
|
+
async function gapPendingVerify({ client: client3 }, { now = Date.now(), signal } = {}) {
|
|
13534
|
+
const jql = pendingVerifyJql(client3.project);
|
|
13535
|
+
let pre;
|
|
13536
|
+
try {
|
|
13537
|
+
pre = await client3.searchAll(jql, { fields: ["summary", "status"] });
|
|
13538
|
+
} catch (e) {
|
|
13539
|
+
return {
|
|
13540
|
+
complete: false,
|
|
13541
|
+
items: [],
|
|
13542
|
+
undetermined: [],
|
|
13543
|
+
recentlyRefixed: [],
|
|
13544
|
+
prefilter: { jql, count: 0, total: null, truncated: false },
|
|
13545
|
+
error: firstLine3(String(e.message ?? e)),
|
|
13546
|
+
nextStep: "\u67E5\u8BE2\u5931\u8D25\uFF0C\u65E0\u6CD5\u5224\u5B9A\u662F\u5426\u6709\u5F85\u590D\u9A8C\u7684\u5355\u2014\u2014\u8FD9\u4E0D\u4EE3\u8868\u4E00\u5F20\u90FD\u6CA1\u6709\u3002\u4FEE\u597D\u7F51\u7EDC\u6216 Jira \u4EE4\u724C\u540E\u91CD\u8DD1 hcm chiron gap status\u3002"
|
|
13547
|
+
};
|
|
13548
|
+
}
|
|
13549
|
+
const items = [];
|
|
13550
|
+
const undetermined = [];
|
|
13551
|
+
const recentlyRefixed = [];
|
|
13552
|
+
const judge = async (i) => {
|
|
13553
|
+
const base = { key: i.key, summary: i.fields.summary ?? "", url: client3.browseUrl(i.key) };
|
|
13554
|
+
let reason;
|
|
13555
|
+
let fixedAt;
|
|
13556
|
+
let bad = [];
|
|
13557
|
+
if (signal?.aborted) {
|
|
13558
|
+
undetermined.push({ ...base, reason: "\u65F6\u9650\u5230\u4E86\uFF0C\u8FD9\u5F20\u7684 changelog \u6CA1\u8BFB" });
|
|
13559
|
+
return;
|
|
13170
13560
|
}
|
|
13171
|
-
const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
|
|
13172
|
-
let after2;
|
|
13173
13561
|
try {
|
|
13174
|
-
|
|
13562
|
+
const cl = await client3.changelog(i.key);
|
|
13563
|
+
if (cl.total === null) reason = "Jira \u6CA1\u62A5 changelog \u603B\u6570\uFF0C\u4E0D\u77E5\u9053\u5386\u53F2\u5168\u4E0D\u5168";
|
|
13564
|
+
else if (cl.returned < cl.total) reason = `changelog \u53EA\u8FD4\u56DE\u4E86 ${cl.returned}/${cl.total} \u6761\uFF0C\u6700\u540E\u4E00\u6B21\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u53EF\u80FD\u5728\u6CA1\u8FD4\u56DE\u7684\u90A3\u90E8\u5206\u91CC`;
|
|
13565
|
+
else if ((bad = unparseableEntries(cl.histories, FIXED_STATUS)).length) reason = `changelog \u91CC\u6709 ${bad.length} \u6B21\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u7684\u65F6\u95F4\u8BFB\u4E0D\u51FA\uFF08${bad[0]}\uFF09\uFF0C\u4E0D\u77E5\u9053\u6700\u540E\u4E00\u6B21\u662F\u54EA\u6B21`;
|
|
13566
|
+
else if (!(fixedAt = lastEnteredStatus(cl.histories, FIXED_STATUS))) reason = `changelog \u91CC\u6CA1\u6709\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u7684\u6D41\u8F6C`;
|
|
13175
13567
|
} catch (e) {
|
|
13176
|
-
|
|
13177
|
-
"readback-failed",
|
|
13178
|
-
CliErrorCode30.NETWORK_ERROR,
|
|
13179
|
-
"yes",
|
|
13180
|
-
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
13181
|
-
`\u7528 \`hcm chiron gap status ${key2}\` \u770B\u7ED3\u679C\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\u8BC4\u8BBA\uFF09\u3002`,
|
|
13182
|
-
{ key: key2, comment: comment2.id ?? null },
|
|
13183
|
-
e
|
|
13184
|
-
);
|
|
13568
|
+
reason = `\u8BFB changelog \u5931\u8D25\uFF1A${firstLine3(String(e.message ?? e))}`;
|
|
13185
13569
|
}
|
|
13186
|
-
|
|
13187
|
-
|
|
13188
|
-
|
|
13189
|
-
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
13190
|
-
throw verifyFailure(
|
|
13191
|
-
"readback-mismatch",
|
|
13192
|
-
CliErrorCode30.SERVER_ERROR,
|
|
13193
|
-
"yes",
|
|
13194
|
-
after2.status !== expected ? `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u72B6\u6001\u662F\u300C${after2.status ?? "?"}\u300D\uFF0C\u9884\u671F\u300C${expected}\u300D` : `${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C${key2} \u56DE\u5230\u4E86\u300C${expected}\u300D\uFF0C\u4F46 resolution \u8FD8\u662F\u300C${after2.resolution}\u300D\u2014\u2014\u5B83\u4F1A\u4ECE\u300C\u672A\u89E3\u51B3\u300D\u7684\u67E5\u8BE2\u91CC\u6D88\u5931`,
|
|
13195
|
-
after2.status !== expected ? `\u4EE5 \`hcm chiron gap status ${key2}\` \u4E3A\u51C6\uFF0C\u522B\u5F53\u6210\u5DF2\u7ECF${did}\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002` : "\u8BF7\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u6E05\u6389\u8FD9\u5355\u7684 resolution\uFF08\u300C\u672A\u89E3\u51B3\u300D\u8FD9\u6761\u6D41\u8F6C\u672C\u6765\u4F1A\u6E05\uFF0C\u6CA1\u6E05\u8BF4\u660E\u5DE5\u4F5C\u6D41\u88AB\u6539\u8FC7\uFF09\uFF1B\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4ED6\u3002",
|
|
13196
|
-
{ key: key2, before, after: after2, expected, comment: comment2.id ?? null }
|
|
13197
|
-
);
|
|
13570
|
+
if (reason || !fixedAt) {
|
|
13571
|
+
undetermined.push({ ...base, reason: reason ?? "\u8D77\u7B97\u70B9\u62FF\u4E0D\u5230" });
|
|
13572
|
+
return;
|
|
13198
13573
|
}
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13574
|
+
const elapsed = now - Date.parse(fixedAt);
|
|
13575
|
+
if (elapsed <= VERIFY_OVERDUE_DAYS * DAY_MS) {
|
|
13576
|
+
recentlyRefixed.push(i.key);
|
|
13577
|
+
return;
|
|
13578
|
+
}
|
|
13579
|
+
items.push({ ...base, fixedAt, days: Math.floor(elapsed / DAY_MS), command: verifyCommand(i.key) });
|
|
13580
|
+
};
|
|
13581
|
+
const queue = [...pre.issues];
|
|
13582
|
+
await Promise.all(Array.from({ length: Math.min(PENDING_VERIFY_CONCURRENCY, queue.length) }, async () => {
|
|
13583
|
+
for (let i = queue.shift(); i; i = queue.shift()) await judge(i);
|
|
13584
|
+
}));
|
|
13585
|
+
items.sort((a, b) => b.days - a.days || a.key.localeCompare(b.key, void 0, { numeric: true }));
|
|
13586
|
+
undetermined.sort((a, b) => a.key.localeCompare(b.key, void 0, { numeric: true }));
|
|
13587
|
+
recentlyRefixed.sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
13588
|
+
const complete = !pre.truncated && undetermined.length === 0;
|
|
13589
|
+
const unsure = [
|
|
13590
|
+
pre.truncated ? `\u9884\u7B5B\u53EA\u770B\u4E86\u524D ${pre.issues.length} \u5F20${pre.total !== null ? `\uFF08\u5171 ${pre.total} \u5F20\uFF09` : ""}` : "",
|
|
13591
|
+
undetermined.length ? `${undetermined.length} \u5F20\u65E0\u6CD5\u5224\u5B9A\uFF08\u89C1\u4E0A\uFF09` : ""
|
|
13592
|
+
].filter(Boolean).join("\uFF0C");
|
|
13593
|
+
const nextStep = items.length ? `\u8FD9 ${items.length} \u5F20\u5355\u4FEE\u590D\u5DF2\u8D85\u8FC7 ${VERIFY_OVERDUE_DAYS} \u5929\u3001\u4ECD\u5F85\u590D\u9A8C\uFF1A\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u540E\u6309\u6280\u80FD\u590D\u9A8C\uFF0C\u518D\u8DD1\u6BCF\u884C\u7ED9\u7684 gap verify \u547D\u4EE4\u56DE\u5199\u7ED3\u8BBA\u3002${unsure ? `\u53E6\u6709${unsure}\u3002` : ""}` : complete ? "\u6CA1\u6709\u5F85\u590D\u9A8C\u7684\u5355\u3002" : `\u6CA1\u627E\u5230\u8D85\u671F\u7684\u5355\uFF0C\u4F46${unsure}\uFF0C\u4E0D\u80FD\u636E\u6B64\u8BF4\u300C\u6CA1\u6709\u300D\u3002`;
|
|
13594
|
+
return { complete, items, undetermined, recentlyRefixed, prefilter: { jql, count: pre.issues.length, total: pre.total, truncated: pre.truncated }, nextStep };
|
|
13595
|
+
}
|
|
13596
|
+
var PRODUCT_HANDLING_KEYWORDS = /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/;
|
|
13597
|
+
var HEADLINE_MAX = 300;
|
|
13598
|
+
function commentWhen(created) {
|
|
13599
|
+
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(created ?? "");
|
|
13600
|
+
return m ? `${m[1]} ${m[2]}` : created ?? "?";
|
|
13601
|
+
}
|
|
13602
|
+
function commentHeadline(body) {
|
|
13603
|
+
const lines = (body ?? "").split("\n").map((l) => l.trim()).filter(Boolean);
|
|
13604
|
+
const first = lines[0] ?? "";
|
|
13605
|
+
const cut = first.length > HEADLINE_MAX;
|
|
13606
|
+
return { headline: cut ? first.slice(0, HEADLINE_MAX) + "\u2026" : first, truncated: cut || lines.length > 1 };
|
|
13607
|
+
}
|
|
13608
|
+
function classifyFollowUp(headline) {
|
|
13609
|
+
if (/阻塞|阻断|未通过|不通过|没通过|没过|退回|失败|(仍|还是|依旧)(然)?(能|可)?复现/.test(headline)) return "blocked";
|
|
13610
|
+
if (/部分(通过|验证|复验|验收|可用)|只(验证|验|测)了/.test(headline)) return "partial";
|
|
13611
|
+
if (/(?<![等待])(复验|验收|验证|复测|回归)(已)?通过(?!\s*(才|后|再))|验证无误/.test(headline)) return "passed";
|
|
13612
|
+
if (/已(经)?(部署|发布|上线|跑)|(部署|发布)(完成|好了)|升级到|更新到/.test(headline)) return "deployed";
|
|
13613
|
+
return void 0;
|
|
13614
|
+
}
|
|
13615
|
+
var AUTO_NOTICE = /^(代码库已关闭:|已在代码库登记:)/;
|
|
13616
|
+
var isAutoNotice = (body) => AUTO_NOTICE.test((body ?? "").trim());
|
|
13617
|
+
function commentTime(c2, index) {
|
|
13618
|
+
const t = Date.parse(c2.created ?? "");
|
|
13619
|
+
return Number.isNaN(t) ? index : t;
|
|
13620
|
+
}
|
|
13621
|
+
function sortComments(cs) {
|
|
13622
|
+
return cs.map((c2, i) => ({ c: c2, i, t: commentTime(c2, i) })).sort((a, b) => a.t - b.t || a.i - b.i).map((x) => x.c);
|
|
13623
|
+
}
|
|
13624
|
+
function toView(client3, key2, c2) {
|
|
13625
|
+
const { headline, truncated } = commentHeadline(c2.body);
|
|
13626
|
+
return {
|
|
13627
|
+
id: c2.id,
|
|
13628
|
+
created: c2.created,
|
|
13629
|
+
when: commentWhen(c2.created),
|
|
13630
|
+
author: c2.author?.displayName ?? c2.author?.name ?? "?",
|
|
13631
|
+
headline,
|
|
13632
|
+
truncated,
|
|
13633
|
+
url: c2.id ? client3.commentUrl(key2, c2.id) : void 0
|
|
13634
|
+
};
|
|
13635
|
+
}
|
|
13636
|
+
async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG3) {
|
|
13637
|
+
const parsed = parseRef2(ref, client3.project, casesSlug);
|
|
13638
|
+
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
13639
|
+
if (parsed.kind === "repo") {
|
|
13640
|
+
throw new Error(
|
|
13641
|
+
`${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u987E\u95EE\u4FA7\u67E5\u4E0D\u5230\u5B83\u7684\u72B6\u6001\uFF08\u6CA1\u6709\u90A3\u4E2A\u4ED3\u7684\u8BFB\u6743\u9650\uFF09\u3002next_step=\u7528 Jira \u5355\u53F7\u67E5\uFF08HCMNX-12\uFF09\u3002\u4EA7\u54C1\u4FA7\u7684\u8FDB\u5C55\u4F1A\u56DE\u5199\u5230 Jira \u5355\u4E0A\uFF0C\u90A3\u662F\u4EA7\u54C1\u5BF9\u5916\u7684\u7EDF\u4E00\u9762\u3002`
|
|
13642
|
+
);
|
|
13211
13643
|
}
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13644
|
+
const issue = await client3.issue(parsed.key);
|
|
13645
|
+
const cs = sortComments(await client3.comments(parsed.key));
|
|
13646
|
+
const status = issue.fields.status?.name;
|
|
13647
|
+
const resolution = issue.fields.resolution?.name;
|
|
13648
|
+
const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
|
|
13649
|
+
const productRaw = [...cs].reverse().find((c2) => PRODUCT_HANDLING_KEYWORDS.test(c2.body ?? ""));
|
|
13650
|
+
const latestRaw = cs.at(-1);
|
|
13651
|
+
const fullText = `\u5168\u6587\uFF1A\`hcm chiron gap comments ${issue.key}\``;
|
|
13652
|
+
const render2 = (label, v) => [
|
|
13653
|
+
` ${label}\uFF1A${v.headline}${v.truncated ? `\uFF08\u5DF2\u622A\u65AD\uFF0C${fullText}\uFF09` : ""}`,
|
|
13654
|
+
...v.url ? [` ${v.url}`] : []
|
|
13655
|
+
];
|
|
13656
|
+
const stamp = (v) => `${v.when} ${v.author}`;
|
|
13657
|
+
let latestProductComment;
|
|
13658
|
+
let latestComment;
|
|
13659
|
+
let sameAsProduct;
|
|
13660
|
+
if (productRaw) {
|
|
13661
|
+
latestProductComment = toView(client3, issue.key, productRaw);
|
|
13662
|
+
latestProductComment.matchedKeyword = PRODUCT_HANDLING_KEYWORDS.exec(productRaw.body ?? "")?.[0];
|
|
13217
13663
|
}
|
|
13218
|
-
|
|
13219
|
-
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
throw verifyFailure(
|
|
13223
|
-
"readback-failed",
|
|
13224
|
-
CliErrorCode30.NETWORK_ERROR,
|
|
13225
|
-
"yes",
|
|
13226
|
-
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
13227
|
-
`\u7528 \`hcm chiron gap comments ${key2}\` \u770B\u5B83\u5728\u4E0D\u5728\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF08\u4F1A\u518D\u5199\u4E00\u6761\uFF09\u3002`,
|
|
13228
|
-
{ key: key2, comment: written.id ?? null },
|
|
13229
|
-
e
|
|
13230
|
-
);
|
|
13664
|
+
if (latestRaw) {
|
|
13665
|
+
latestComment = toView(client3, issue.key, latestRaw);
|
|
13666
|
+
sameAsProduct = !!productRaw && productRaw === latestRaw;
|
|
13667
|
+
if (!isAutoNotice(latestRaw.body)) latestComment.signal = classifyFollowUp(latestComment.headline);
|
|
13231
13668
|
}
|
|
13232
|
-
|
|
13233
|
-
if (
|
|
13234
|
-
|
|
13235
|
-
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
13236
|
-
throw verifyFailure(
|
|
13237
|
-
"readback-mismatch",
|
|
13238
|
-
CliErrorCode30.SERVER_ERROR,
|
|
13239
|
-
"yes",
|
|
13240
|
-
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
13241
|
-
`\u7528 \`hcm chiron gap comments ${key2}\` \u6838\u5BF9\uFF1B\u522B\u76F4\u63A5\u91CD\u8DD1\uFF0C\u628A\u8FD9\u6BB5\u8F93\u51FA\u53D1\u7ED9\u4EA7\u54C1\u4FA7\u5206\u8BCA\u4EBA\u3002`,
|
|
13242
|
-
{ key: key2, comment: written.id }
|
|
13243
|
-
);
|
|
13669
|
+
const hit = `\u547D\u4E2D\u300C${latestProductComment?.matchedKeyword ?? "?"}\u300D`;
|
|
13670
|
+
if (latestProductComment && latestComment && sameAsProduct) {
|
|
13671
|
+
lines.push(...render2(`\u6700\u65B0\u5904\u7406\uFF08\u65E2\u662F\u4EA7\u54C1\u4FA7\u5904\u7406\u3014${hit}\u3015\u4E5F\u662F\u6700\u65B0\u8BC4\u8BBA\uFF1B${stamp(latestComment)}\uFF09`, latestComment));
|
|
13244
13672
|
} else {
|
|
13245
|
-
|
|
13673
|
+
if (latestProductComment) lines.push(...render2(`\u4EA7\u54C1\u4FA7\u5904\u7406\uFF08${hit}\uFF1B${stamp(latestProductComment)}\uFF09`, latestProductComment));
|
|
13674
|
+
else if (latestComment) lines.push(" \u8FD8\u6CA1\u6709\u4EA7\u54C1\u4FA7\u5904\u7406\u8BC4\u8BBA\uFF08\u5206\u8BCA / \u5DF2\u8F6C / \u5408\u5165 / \u4EE3\u7801\u5E93\u5DF2\u5173\u95ED \u8FD9\u7C7B\u5173\u952E\u8BCD\u4E00\u6761\u90FD\u6CA1\u547D\u4E2D\uFF09");
|
|
13675
|
+
if (latestComment) lines.push(...render2(`\u6700\u65B0\u8BC4\u8BBA\uFF08${stamp(latestComment)}\uFF09`, latestComment));
|
|
13246
13676
|
}
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13677
|
+
if (!latestComment) lines.push(" \u8FD8\u6CA1\u6709\u4EBA\u5904\u7406\uFF08\u4EA7\u54C1\u4FA7\u6BCF\u5468\u6E05\u4E00\u6B21\uFF1B\u963B\u65AD\u7EA7\u8BF7\u5728\u9879\u76EE\u7FA4\u91CC\u70B9\u540D\u8D1F\u8D23\u4EBA\uFF09");
|
|
13678
|
+
const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
|
|
13679
|
+
const links = linkedRepoRefs(`${remote}
|
|
13680
|
+
${issue.fields.description ?? ""}
|
|
13681
|
+
${cs.map((c2) => c2.body ?? "").join("\n")}`).map((l) => ({
|
|
13682
|
+
...l,
|
|
13683
|
+
url: repoIssueUrl(l.repo, l.number)
|
|
13684
|
+
}));
|
|
13685
|
+
for (const p of links) lines.push(`\u5DF2\u767B\u8BB0\u4EE3\u7801\u5E93\u6761\u76EE ${p.repo}#${p.number}`, ` ${p.url}`);
|
|
13686
|
+
let nextStep;
|
|
13687
|
+
const verifyCmd = `\`hcm chiron gap verify ${issue.key} --result pass|fail|partial --body <\u8BC1\u636E>\``;
|
|
13688
|
+
if (status === "\u5DF2\u4FEE\u590D") {
|
|
13689
|
+
nextStep = `\u4FEE\u590D\u5DF2\u5408\u5165\uFF1B\u8FD8\u6CA1\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5C31\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF0C\u53D1\u5230\u4E4B\u540E\uFF08\`hcm version\` \u7684 commit \u4F1A\u53D8\uFF09\u8DD1 \`hcm chiron skills sync\` \u6309\u6280\u80FD\u590D\u9A8C\uFF0C\u518D\u7531\u63D0\u5355\u4EBA\u7528 ${verifyCmd} \u56DE\u5199\uFF1Apass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\u3002`;
|
|
13690
|
+
} else if (status === "CLOSE") {
|
|
13691
|
+
nextStep = `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u4F1A\u518D\u5F80\u524D\u8D70\u3002${closedGapHint({ key: issue.key, resolution })}\u3002`;
|
|
13692
|
+
} else if (status === "\u8865\u5145\u8BF4\u660E") {
|
|
13693
|
+
nextStep = `\u{1F534} **\u7403\u5728\u4F60\u8FD9\u8FB9**\uFF1A\u4EA7\u54C1\u4FA7\u770B\u4E86\uFF0C\u4F46\u4FE1\u606F\u4E0D\u591F\uFF0C\u628A\u5355\u6253\u56DE\u6765\u8BA9\u4F60\u8865\u5145\u3002\u7167\u6700\u65B0\u90A3\u6761\u8BC4\u8BBA\u8BF4\u7684\u8865\u2014\u2014\u590D\u73B0\u547D\u4EE4\u3001\u539F\u59CB\u8F93\u51FA\u3001\u73AF\u5883\u6307\u7EB9\u7F3A\u54EA\u6837\u8865\u54EA\u6837\uFF0C\u7528 \`hcm chiron gap submit --append-to ${issue.key}\` \u8FFD\u52A0\u4E00\u6761\u73B0\u573A\uFF0C\u6216\u76F4\u63A5\u5728 Jira \u90A3\u5355\u4E0B\u56DE\u590D\u3002\u8865\u5B8C\u8BA9\u5206\u8BCA\u4EBA\u63A8\u300C\u91CD\u65B0\u63D0\u4EA4\u300D\u3002**\u4E0D\u8865\u7684\u8BDD\u8FD9\u5355\u4E0D\u4F1A\u81EA\u5DF1\u5F80\u524D\u8D70\u3002**`;
|
|
13694
|
+
} else if (status === "\u4E0D\u5904\u7406") {
|
|
13695
|
+
nextStep = "\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C\u4E0D\u5904\u7406\u300D\u3002\u770B\u6700\u65B0\u90A3\u6761\u8BC4\u8BBA\u7ED9\u7684\u7406\u7531\u4E0E\u66FF\u4EE3\u6CD5\uFF1B\u4E0D\u8BA4\u540C\u5C31\u5728\u5355\u4E0B\u8BF4\u6E05\u695A\u4E3A\u4EC0\u4E48\uFF0C\u5B83\u8FD8\u80FD\u88AB\u91CD\u5F00\u3002";
|
|
13696
|
+
} else if (status === "\u91CD\u590D\u95EE\u9898") {
|
|
13697
|
+
nextStep = `\u4EA7\u54C1\u4FA7\u5224\u4E86\u300C\u91CD\u590D\u95EE\u9898\u300D\u3002${DUPLICATE_ADVICE}\uFF1B\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\u3002`;
|
|
13698
|
+
} else if (status === "\u7EB3\u5165\u89C4\u5212") {
|
|
13699
|
+
nextStep = "\u5DF2\u6392\u671F\uFF0C\u4F46\u6CA1\u6392\u5728\u8FD1\u671F\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF1B\u8981\u63D0\u524D\u5C31\u5728\u5355\u4E0B\u8BF4\u660E\u4E1A\u52A1\u5F71\u54CD\uFF0C\u5206\u8BCA\u6392\u671F\u65F6\u770B\u5F97\u5230\u3002";
|
|
13700
|
+
} else if (status === "\u65B0\u589E") nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
|
|
13701
|
+
else if (resolution) nextStep = "Jira \u8FD9\u5355\u5DF2\u89E3\u51B3\u3002\u76EE\u6807\u73AF\u5883\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u540E\uFF08`hcm version` \u7684 commit \u4F1A\u53D8\uFF09\uFF0C\u8DD1 `hcm chiron skills sync`\uFF0C\u518D\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\u3002";
|
|
13702
|
+
else if (links.length) nextStep = "\u5DF2\u5206\u8BCA\u3001\u4EE3\u7801\u5E93\u5DF2\u767B\u8BB0\uFF0C\u8FD8\u5728\u505A\u3002\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B\u60F3\u8981\u6392\u671F\u5C31\u5728 Jira \u8FD9\u5355\u4E0B\u7559\u8A00\u3002";
|
|
13703
|
+
else if (status && status !== "\u65B0\u589E") {
|
|
13704
|
+
nextStep = `\u8FD9\u5355\u5728\u300C${status}\u300D\u2014\u2014**\u672C\u6D41\u7A0B\u6CA1\u5B9A\u4E49\u8FD9\u4E2A\u72B6\u6001**\uFF08\u591A\u534A\u662F\u5DE5\u4F5C\u6D41\u53C8\u52A0\u4E86\u72B6\u6001\uFF0C\u6216\u65B9\u6848 12100 \u88AB\u5207\u8D70\u4E86\uFF09\u3002\u6309 Jira \u7684\u5DE5\u4F5C\u6D41\u5B83\u8FD8\u5728\u4EA7\u54C1\u4FA7\u624B\u4E0A\uFF0C\u4E0D\u662F\u5728\u7B49\u4F60\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF1B\u60F3\u77E5\u9053\u5177\u4F53\u8FDB\u5C55\u5C31\u5728\u5355\u4E0B\u95EE\u4E00\u53E5\uFF0C\u6216\u8BA9\u5206\u8BCA\u4EBA\u628A\u5B83\u63A8\u5230\u6536\u5355\u6D41\u7A0B\u91CC\u7684\u72B6\u6001\u4E0A\u3002`;
|
|
13705
|
+
} else nextStep = `\u7B49\u5206\u8BCA\u3002\u5148\u6309\u66FF\u4EE3\u6CD5\u7EE7\u7EED\u4EA4\u4ED8\uFF0C\u62A5\u544A\u5199 BLOCKED \xB7 \u5DF2\u63D0 ${issue.key}\u3002`;
|
|
13706
|
+
const stillOpen = status !== "CLOSE" && status !== DUPLICATE_STATUS && (status === "\u5DF2\u4FEE\u590D" || !resolution);
|
|
13707
|
+
if (latestComment && stillOpen) {
|
|
13708
|
+
const cite = `${latestComment.when} ${latestComment.author}\uFF1A\u300C${latestComment.headline}\u300D`;
|
|
13709
|
+
const tail = latestComment.truncated ? `\uFF08${fullText}\uFF09` : "";
|
|
13710
|
+
const canVerify = status === "\u5DF2\u4FEE\u590D";
|
|
13711
|
+
const waitFixed = "\u7B49\u4EA7\u54C1\u4FA7\u628A\u5355\u63A8\u5230\u300C\u5DF2\u4FEE\u590D\u300D";
|
|
13712
|
+
switch (latestComment.signal) {
|
|
13713
|
+
case "passed":
|
|
13714
|
+
nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u590D\u9A8C\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002` + (canVerify ? `Jira \u72B6\u6001\u8FD8\u505C\u5728\u300C\u5DF2\u4FEE\u590D\u300D\u53EA\u8BF4\u660E\u8FD8\u6CA1\u8D70\u5173\u5355\u6D41\u8F6C\uFF0C\u4E0D\u4EE3\u8868\u8FD8\u6CA1\u90E8\u7F72\uFF1A\u63D0\u5355\u4EBA\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u4E0D\u662F\u63D0\u5355\u4EBA\u5C31\u7B49\u63D0\u5355\u4EBA\u6216\u4EA7\u54C1\u4FA7\u5173\uFF09\u3002` : `Jira \u72B6\u6001\u8FD8\u5728\u300C${status ?? "?"}\u300D\uFF1A${waitFixed}\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass --body <\u8BC1\u636E>\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`) + `\u8DD1 \`hcm chiron skills sync\` \u540E\u6309\u6280\u80FD\u76F4\u63A5\u7528\uFF0C\u4E0D\u5FC5\u518D\u7B49\u90E8\u7F72\u590D\u9A8C\u3002`;
|
|
13715
|
+
break;
|
|
13716
|
+
case "deployed":
|
|
13717
|
+
nextStep = `\u76EE\u6807\u73AF\u5883\u5DF2\u90E8\u7F72\u5230\u542B\u4FEE\u590D\u7684\u7248\u672C\u2014\u2014${cite}${tail}\u3002\u8DD1 \`hcm chiron skills sync\`\uFF0C\u6309\u6280\u80FD\u590D\u9A8C\u4E00\u6B21\uFF0C` + (canVerify ? `\u518D\u7531\u63D0\u5355\u4EBA\u7528 ${verifyCmd} \u56DE\u5199\u7ED3\u8BBA\u3002` : `\u7ED3\u679C\u5148\u8BB0\u5728\u4F60\u7684\u53F0\u8D26\u91CC\uFF1B${waitFixed}\uFF0C\u518D\u7528 ${verifyCmd} \u56DE\u5199\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
|
|
13718
|
+
break;
|
|
13719
|
+
case "partial":
|
|
13720
|
+
nextStep = `\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\u2014\u2014${cite}${tail}\u3002\u9A8C\u8FC7\u7684\u90E8\u5206\u53EF\u4EE5\u7528\uFF1B\u6CA1\u9A8C\u5230\u7684\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\uFF1B` + (canVerify ? `\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\u540E\u63D0\u5355\u4EBA\u518D\u8DD1 \`hcm chiron gap verify ${issue.key} --result pass\`\uFF0C\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\u5C31\u7528 \`--result fail\`\u3002` : `${waitFixed}\u3001\u5168\u90E8\u9A8C\u8FC7\u90FD\u901A\u8FC7\uFF0C\u518D\u7528 \`hcm chiron gap verify ${issue.key} --result pass\` \u5173\u5355\uFF08\u73B0\u5728\u8DD1\u4F1A\u88AB\u62D2\uFF09\u3002`);
|
|
13721
|
+
break;
|
|
13722
|
+
case "blocked":
|
|
13723
|
+
nextStep = `\u590D\u9A8C\u6CA1\u8FC7 / \u88AB\u963B\u585E\u2014\u2014${cite}${tail}\u3002\u7403\u56DE\u5230\u4EA7\u54C1\u4FA7\uFF1A\u7EE7\u7EED\u7528\u66FF\u4EE3\u6CD5\u4EA4\u4ED8\uFF0C\u8FDB\u5C55\u770B\u8FD9\u5355\u540E\u7EED\u8BC4\u8BBA\u3002`;
|
|
13724
|
+
break;
|
|
13725
|
+
default:
|
|
13726
|
+
if (!sameAsProduct) nextStep += ` \u53E6\uFF1A\u6709\u4E00\u6761\u6BD4\u4EA7\u54C1\u4FA7\u5904\u7406\u66F4\u65B0\u7684\u8BC4\u8BBA\u2014\u2014${cite}${tail}\uFF0C\u5148\u770B\u5B83\u3002`;
|
|
13727
|
+
}
|
|
13728
|
+
}
|
|
13729
|
+
return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links, latestProductComment, latestComment, sameAsProduct };
|
|
13730
|
+
}
|
|
13731
|
+
async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug = CASES_REPO_SLUG3) {
|
|
13732
|
+
const parsed = parseRef2(ref, client3.project, casesSlug);
|
|
13733
|
+
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
13734
|
+
if (parsed.kind === "repo") {
|
|
13735
|
+
throw new Error(`${parsed.repo}#${parsed.number} \u662F\u4EA7\u54C1\u4ED3\u7F16\u53F7\uFF0C\u987E\u95EE\u4FA7\u8BFB\u4E0D\u5230\u5B83\u7684\u8BC4\u8BBA\uFF08\u6CA1\u6709\u90A3\u4E2A\u4ED3\u7684\u8BFB\u6743\u9650\uFF09\u3002next_step=\u7528 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09\u3002`);
|
|
13255
13736
|
}
|
|
13737
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) throw new Error(`--limit \u8981\u662F\u6B63\u6574\u6570\uFF0C\u7ED9\u7684\u662F ${String(limit)}`);
|
|
13738
|
+
const all = sortComments(await client3.comments(parsed.key));
|
|
13739
|
+
const picked = limit !== void 0 ? all.slice(-limit) : all;
|
|
13256
13740
|
return {
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13741
|
+
ref,
|
|
13742
|
+
key: parsed.key,
|
|
13743
|
+
url: client3.browseUrl(parsed.key),
|
|
13744
|
+
total: all.length,
|
|
13745
|
+
shown: picked.length,
|
|
13746
|
+
comments: picked.map((c2) => ({
|
|
13747
|
+
id: c2.id,
|
|
13748
|
+
created: c2.created,
|
|
13749
|
+
when: commentWhen(c2.created),
|
|
13750
|
+
author: c2.author?.displayName ?? c2.author?.name ?? "?",
|
|
13751
|
+
body: (c2.body ?? "").trim(),
|
|
13752
|
+
url: c2.id ? client3.commentUrl(parsed.key, c2.id) : void 0
|
|
13753
|
+
}))
|
|
13266
13754
|
};
|
|
13267
13755
|
}
|
|
13268
13756
|
|
|
@@ -13286,22 +13774,58 @@ async function gapSearchCommand(keywords, args, deps = defaultDeps) {
|
|
|
13286
13774
|
await run2(async () => {
|
|
13287
13775
|
if (!keywords.length) throw new Error("\u7ED9\u81F3\u5C11\u4E00\u4E2A\u5173\u952E\u8BCD\uFF1A\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61");
|
|
13288
13776
|
const r = await gapSearch(await gapDeps(deps), keywords, { includeClosed: args.includeClosed !== false });
|
|
13289
|
-
emit5(args.output, r, () =>
|
|
13290
|
-
|
|
13291
|
-
` : "";
|
|
13292
|
-
if (!r.rows.length) return `${head}Jira \u4E0E\u4EA7\u54C1\u4ED3\u90FD\u6CA1\u6709\u76F8\u5173\u8BB0\u5F55\u3002\u53EF\u4EE5 submit\uFF0C\u4F46\u5148\u628A\u4E09\u95EE\u7B54\u5B8C\u3002`;
|
|
13293
|
-
return `${head}\u547D\u4E2D ${r.rows.length} \u6761\uFF08\u540C\u4E00\u7F3A\u53E3\u5DF2\u6709\u7F16\u53F7\u5C31\u5728\u90A3\u6761\u4E0B\u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00\uFF09\uFF1A
|
|
13294
|
-
${r.rows.map((i) => `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
|
|
13295
|
-
${i.url}`).join("\n")}`;
|
|
13296
|
-
});
|
|
13777
|
+
emit5(args.output, r, () => renderGapSearch(r));
|
|
13778
|
+
if (r.jiraError) process.exitCode = 4;
|
|
13297
13779
|
});
|
|
13298
13780
|
}
|
|
13781
|
+
function renderGapSearch(r) {
|
|
13782
|
+
const list = r.rows.map((i) => {
|
|
13783
|
+
const hint = terminalGapHint({ key: i.id, status: i.state, resolution: i.resolution });
|
|
13784
|
+
return `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
|
|
13785
|
+
${i.url}${hint ? `
|
|
13786
|
+
\u2192 ${hint}` : ""}`;
|
|
13787
|
+
}).join("\n");
|
|
13788
|
+
if (r.jiraError) {
|
|
13789
|
+
const got = r.rows.length ? `\u4E0B\u9762\u53EA\u662F\u5931\u8D25\u524D\u67E5\u5230\u7684 ${r.rows.length} \u6761\uFF0C\u4E0D\u4EE3\u8868 Jira \u91CC\u6CA1\u6709\u522B\u7684\uFF1A
|
|
13790
|
+
${list}
|
|
13791
|
+
` : "\u4E00\u6761\u90FD\u6CA1\u67E5\u5230\uFF0C\u8FD9\u4E0D\u4EE3\u8868 Jira \u91CC\u6CA1\u6709\u3002\n";
|
|
13792
|
+
return `\u26A0\uFE0F Jira \u67E5\u8BE2\u5931\u8D25\uFF08${r.jiraError}\uFF09\u3002${got}\u67E5\u91CD\u6CA1\u5B8C\u6210\uFF0C\u5148\u522B submit\uFF1B\u4FEE\u597D\u7F51\u7EDC\u6216\u4EE4\u724C\u540E\u91CD\u8DD1\u672C\u547D\u4EE4\u3002`;
|
|
13793
|
+
}
|
|
13794
|
+
const partial = r.truncated ? `\u26A0\uFE0F \u56DE\u9000\u626B\u63CF\u53EA\u770B\u4E86\u524D ${r.truncated.count} \u5F20${r.truncated.total !== null ? `\uFF08\u5171 ${r.truncated.total} \u5F20\uFF09` : ""}\uFF0C\u53EF\u80FD\u6709\u6CA1\u770B\u5230\u7684\u3002
|
|
13795
|
+
` : "";
|
|
13796
|
+
if (!r.rows.length) return `${partial}Jira \u91CC\u6CA1\u6709\u76F8\u5173\u8BB0\u5F55\u3002\u53EF\u4EE5 submit\uFF0C\u4F46\u5148\u628A\u4E09\u95EE\u7B54\u5B8C\u3002`;
|
|
13797
|
+
return `${partial}\u547D\u4E2D ${r.rows.length} \u6761\uFF08\u540C\u4E00\u7F3A\u53E3\u5DF2\u6709\u672A\u5173\u95ED\u7684\u7F16\u53F7\u5C31\u7528 submit --append-to <\u5355\u53F7> \u8FFD\u52A0\u73B0\u573A\uFF0C\u4E0D\u65B0\u5F00\uFF1B\u5DF2\u5173\u95ED\u3001\u91CD\u590D\u7684\u5355\u7167\u6BCF\u884C\u7684\u63D0\u793A\u8D70\uFF09\uFF1A
|
|
13798
|
+
${list}`;
|
|
13799
|
+
}
|
|
13299
13800
|
async function gapStatusCommand(ref, args, deps = defaultDeps) {
|
|
13300
13801
|
await run2(async () => {
|
|
13802
|
+
if (!ref) {
|
|
13803
|
+
const r2 = await gapPendingVerify(await gapDeps(deps));
|
|
13804
|
+
emit5(args.output, r2, () => renderPendingVerify(r2));
|
|
13805
|
+
if (r2.error) process.exitCode = 4;
|
|
13806
|
+
return;
|
|
13807
|
+
}
|
|
13301
13808
|
const r = await gapStatus(await gapDeps(deps), ref);
|
|
13302
13809
|
emit5(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
13303
13810
|
});
|
|
13304
13811
|
}
|
|
13812
|
+
function renderPendingVerify(r) {
|
|
13813
|
+
if (r.error) return `\u26A0\uFE0F \u5F85\u590D\u9A8C\u6E05\u5355\u67E5\u8BE2\u5931\u8D25\uFF08${r.error}\uFF09\uFF0C\u65E0\u6CD5\u5224\u5B9A\u3002
|
|
13814
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13815
|
+
const head = `\u5F85\u590D\u9A8C\uFF08\u6211\u63D0\u7684\u3001\u5DF2\u4FEE\u590D\u8D85\u8FC7 ${VERIFY_OVERDUE_DAYS} \u5929\uFF0C\u8D77\u7B97\u70B9\u53D6\u6700\u540E\u4E00\u6B21\u8FDB\u5165\u300C\u5DF2\u4FEE\u590D\u300D\uFF09\uFF1A\u9884\u7B5B ${r.prefilter.count} \u5F20`;
|
|
13816
|
+
const items = r.items.map((i) => ` ${i.key} \xB7 \u5DF2\u4FEE\u590D ${i.days} \u5929\uFF08${i.fixedAt.slice(0, 10)}\uFF09\xB7 ${i.summary}
|
|
13817
|
+
${i.url}
|
|
13818
|
+
\u590D\u9A8C\u540E\uFF1A${i.command}`);
|
|
13819
|
+
const unsure = r.undetermined.map((u) => ` ${u.key} \xB7 \u65E0\u6CD5\u5224\u5B9A\uFF1A${u.reason}
|
|
13820
|
+
${u.url}`);
|
|
13821
|
+
return [
|
|
13822
|
+
head,
|
|
13823
|
+
...items,
|
|
13824
|
+
...unsure.length ? ["\u65E0\u6CD5\u5224\u5B9A\uFF1A", ...unsure] : [],
|
|
13825
|
+
...r.recentlyRefixed.length ? [`\u91CD\u5F00\u540E\u53C8\u4FEE\u8FC7\u3001\u6700\u540E\u4E00\u6B21\u4FEE\u590D\u4E0D\u8DB3 ${VERIFY_OVERDUE_DAYS} \u5929\u7684\u4E0D\u5217\uFF1A${r.recentlyRefixed.join("\u3001")}`] : [],
|
|
13826
|
+
`\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`
|
|
13827
|
+
].join("\n");
|
|
13828
|
+
}
|
|
13305
13829
|
function parseLimit(raw) {
|
|
13306
13830
|
if (raw === void 0) return void 0;
|
|
13307
13831
|
const n = typeof raw === "number" ? raw : Number(String(raw).trim());
|
|
@@ -13329,6 +13853,42 @@ async function gapCommentsCommand(ref, args, deps = defaultDeps) {
|
|
|
13329
13853
|
emit5(args.output, r, () => renderGapComments(r));
|
|
13330
13854
|
});
|
|
13331
13855
|
}
|
|
13856
|
+
var revisionLine = (c2) => comparesVersions(c2.situation) ? `
|
|
13857
|
+
\u4FEE\u590D\u7248\u672C ${c2.fixRevision !== void 0 ? `r${c2.fixRevision}` : "\u672A\u77E5"} \xB7 \u4F60\u7684\u73AF\u5883 ${c2.environmentRevision !== void 0 ? `r${c2.environmentRevision}` : "\u672A\u77E5"}` : "";
|
|
13858
|
+
var candidateLine = (c2) => ` ${c2.key} [${c2.status ?? "?"}${c2.resolution ? "\xB7" + c2.resolution : ""}] ${reasonText(c2)}
|
|
13859
|
+
${c2.summary}
|
|
13860
|
+
${c2.url}${revisionLine(c2)}${c2.advice ? `
|
|
13861
|
+
\u2192 ${c2.advice}` : ""}`;
|
|
13862
|
+
var workaroundLine = (r) => `\u672C\u5730\u7ED5\u6CD5\uFF1AlocalWorkaround: ${r.localWorkaround}${r.localWorkaround !== "none" ? "" : r.localWorkaroundStated ? "\uFF08\u8F7D\u8377\u91CC\u660E\u8BF4\u6CA1\u6709\u672C\u5730\u7ED5\u6CD5\uFF09" : "\uFF08\u8F7D\u8377\u91CC\u6CA1\u5199 local_workaround\uFF1B\u7528 hcm-skills/local/ \u7B49\u529E\u6CD5\u7ED5\u8FC7\u53BB\u4E86\u5C31\u8865\u4E0A\uFF09"}`;
|
|
13863
|
+
function renderGapSubmit(r) {
|
|
13864
|
+
const scan = `\u67E5\u91CD\uFF1A${r.scanned.scope}\uFF0C\u770B\u4E86 ${r.scanned.count}${r.scanned.total !== null ? `/${r.scanned.total}` : ""} \u5F20${r.scanned.truncated ? "\uFF08\u6CA1\u770B\u5168\uFF09" : ""}`;
|
|
13865
|
+
const more = r.candidateTotal > r.candidates.length ? `\uFF0C\u53EA\u5217\u524D ${r.candidates.length} \u5F20\uFF0C\u53E6\u6709 ${r.candidateTotal - r.candidates.length} \u5F20\u6CA1\u5217\u2014\u2014\u5173\u952E\u8BCD\u592A\u5BBD\u5C31\u6536\u7A84\u6807\u9898\u6216\u8865\u9519\u8BEF\u7801\u518D\u67E5` : "";
|
|
13866
|
+
const cands = r.candidates.length ? `
|
|
13867
|
+
\u76F8\u4F3C\u5355 ${r.candidateTotal} \u5F20\uFF08\u53EA\u662F\u50CF\uFF0C\u4E0D\u662F\u5224\u5B9A${more}\uFF09\uFF1A
|
|
13868
|
+
${r.candidates.map(candidateLine).join("\n")}` : "";
|
|
13869
|
+
switch (r.outcome) {
|
|
13870
|
+
case "candidates":
|
|
13871
|
+
return `${scan}${cands}
|
|
13872
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13873
|
+
case "dry-run":
|
|
13874
|
+
return r.planned === "append" ? `${scan}
|
|
13875
|
+
[dry-run] \u4F1A\u5F80 ${r.key} [${r.target?.status ?? "?"}${r.target?.resolution ? "\xB7" + r.target.resolution : ""}]\u300C${r.target?.summary ?? ""}\u300D\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D${r.target ? `\uFF08${reasonText(r.target)}\uFF09${revisionLine(r.target)}${r.target.advice ? `
|
|
13876
|
+
\u2192 ${r.target.advice}` : ""}` : ""}
|
|
13877
|
+
${workaroundLine(r)}
|
|
13878
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}` : `${scan}${cands}
|
|
13879
|
+
[dry-run] \u4F1A\u65B0\u5F00\uFF1A${r.summary}\uFF08${r.type} \xB7 ${r.module}\uFF09
|
|
13880
|
+
${workaroundLine(r)}
|
|
13881
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13882
|
+
case "appended":
|
|
13883
|
+
return `\u5DF2\u5F80 ${r.key}\u300C${r.summary}\u300D\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\u8BC4\u8BBA\uFF0C\u6CA1\u6709\u65B0\u5F00\u3002
|
|
13884
|
+
${r.url}
|
|
13885
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A${r.nextStep}`;
|
|
13886
|
+
case "created":
|
|
13887
|
+
return `\u5DF2\u63D0 ${r.key}\uFF08${r.type} \xB7 ${r.module}\uFF09\uFF1A${r.url}${r.candidates.length ? `
|
|
13888
|
+
\u770B\u8FC7\u7684\u76F8\u4F3C\u5355\u5DF2\u5199\u8FDB\u65B0\u5355\u300C\u67E5\u91CD\u300D\u4E00\u8282\uFF1A${r.candidates.map((c2) => c2.key).join("\u3001")}${r.candidateTotal > r.candidates.length ? `\uFF08\u53E6\u6709 ${r.candidateTotal - r.candidates.length} \u5F20\u6CA1\u5217\uFF09` : ""}` : ""}
|
|
13889
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A${r.nextStep}`;
|
|
13890
|
+
}
|
|
13891
|
+
}
|
|
13332
13892
|
function backendFingerprint2(info, cliVersion, envName) {
|
|
13333
13893
|
const commit = info.commit ?? info.gitCommit ?? null;
|
|
13334
13894
|
const backend = commit ? String(commit).slice(0, 12) : `\u672A\u56DE commit\uFF08version=${info.version ?? "?"}\uFF09`;
|
|
@@ -13353,31 +13913,30 @@ async function fingerprintInfo(env2) {
|
|
|
13353
13913
|
return { text: `\u672A\u53D6\u5230\u6307\u7EB9\uFF08env=${env2 ?? "\u672A\u8BBE"}\uFF1B${reason}\uFF09`, source: "unavailable", revision: null, revisionError: `\u8BFB\u53D6 ${VERSION_PATH} \u5931\u8D25\uFF1A${reason}` };
|
|
13354
13914
|
}
|
|
13355
13915
|
}
|
|
13356
|
-
async function fingerprintText(env2) {
|
|
13357
|
-
return (await fingerprintInfo(env2)).text;
|
|
13358
|
-
}
|
|
13359
13916
|
async function gapSubmitCommand(args, deps = defaultDeps) {
|
|
13360
13917
|
await run2(async () => {
|
|
13361
13918
|
const raw = args.file ? readFileSync6(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync6(0, "utf8");
|
|
13362
13919
|
if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
|
|
13920
|
+
if (args.appendTo && args.new) throw new Error("--append-to \u4E0E --new \u4E8C\u9009\u4E00\uFF1A\u70B9\u540D\u8FFD\u52A0\u5230\u5DF2\u6709\u5355\uFF0C\u6216\u65B0\u5F00\u4E00\u5F20\uFF08\u5019\u9009\u5199\u8FDB\u65B0\u5355\u7684\u300C\u67E5\u91CD\u300D\u4E00\u8282\uFF09");
|
|
13363
13921
|
const gap2 = validateGapInput(JSON.parse(raw));
|
|
13364
|
-
const fp = args.fingerprint
|
|
13365
|
-
const r = await gapSubmit(await gapDeps(deps), gap2, {
|
|
13366
|
-
|
|
13367
|
-
args.
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
);
|
|
13922
|
+
const fp = args.fingerprint ? { text: args.fingerprint, source: "given", revision: null, revisionError: "\u6307\u7EB9\u7531 --fingerprint \u76F4\u63A5\u7ED9\u51FA\uFF0C\u6CA1\u6709\u73B0\u67E5\u73AF\u5883\u7248\u672C" } : await fingerprintInfo(args.env);
|
|
13923
|
+
const r = await gapSubmit(await gapDeps(deps), gap2, {
|
|
13924
|
+
fingerprint: fp,
|
|
13925
|
+
issuetypeOverride: args.issuetype,
|
|
13926
|
+
assigneeOverride: args.assignee,
|
|
13927
|
+
appendTo: args.appendTo,
|
|
13928
|
+
forceNew: args.new,
|
|
13929
|
+
dryRun: args.dryRun
|
|
13930
|
+
});
|
|
13931
|
+
emit5(args.output, r, () => renderGapSubmit(r));
|
|
13932
|
+
if (r.outcome === "candidates") process.exitCode = 3;
|
|
13374
13933
|
});
|
|
13375
13934
|
}
|
|
13376
13935
|
function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = () => readFileSync6(0, "utf8")) {
|
|
13377
13936
|
if (opts.file !== void 0 && opts.body !== void 0) {
|
|
13378
13937
|
throw verifyFailure(
|
|
13379
13938
|
"evidence-ambiguous",
|
|
13380
|
-
|
|
13939
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13381
13940
|
"no",
|
|
13382
13941
|
"--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
|
|
13383
13942
|
"\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
|
|
@@ -13389,7 +13948,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13389
13948
|
} catch (e) {
|
|
13390
13949
|
throw verifyFailure(
|
|
13391
13950
|
"evidence-unreadable",
|
|
13392
|
-
|
|
13951
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13393
13952
|
"no",
|
|
13394
13953
|
`\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
|
|
13395
13954
|
"\u6838\u5BF9\u8DEF\u5F84\u4E0E\u6743\u9650\uFF1B\u8BC1\u636E\u6587\u4EF6\u4E00\u822C\u653E\u5728\u9879\u76EE\u4ED3\u7684 evidence/ \u4E0B\u3002",
|
|
@@ -13402,7 +13961,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13402
13961
|
if (stdinIsTTY) {
|
|
13403
13962
|
throw verifyFailure(
|
|
13404
13963
|
"evidence-missing",
|
|
13405
|
-
|
|
13964
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13406
13965
|
"no",
|
|
13407
13966
|
"\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
|
|
13408
13967
|
"\u7528 --body <\u6587\u672C> \u6216 --file <\u6587\u4EF6> \u7ED9\u51FA\uFF1A\u54EA\u4E2A\u73AF\u5883\u3001\u54EA\u4E2A\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48\u3002"
|
|
@@ -13424,7 +13983,9 @@ var FINGERPRINT_SOURCE_TEXT = {
|
|
|
13424
13983
|
function renderGapVerify(r) {
|
|
13425
13984
|
const lines = [];
|
|
13426
13985
|
if (r.outcome === "planned") lines.push(`[dry-run] \u6CA1\u6709\u5199 Jira\u3002\u8BA1\u5212\uFF1A${r.planned ? VERIFY_OUTCOME_TEXT[r.planned] : "?"}`);
|
|
13427
|
-
else
|
|
13986
|
+
else if (r.outcome === "already-closed" && r.before.resolution !== DONE_RESOLUTION) {
|
|
13987
|
+
lines.push(`\u8FD9\u5355\u5DF2\u662F CLOSE\uFF08CLOSE\xB7${r.before.resolution ?? "\u6CA1\u6709 resolution"}\uFF0C${r.before.resolution === DUPLICATE_RESOLUTION ? "\u5224\u91CD\u5173\u7684" : "\u4E0D\u662F\u590D\u9A8C\u5173\u95ED"}\uFF09\uFF0C\u590D\u9A8C\u7ED3\u8BBA\u6CA1\u5199\u8FDB\u53BB`);
|
|
13988
|
+
} else lines.push(VERIFY_OUTCOME_TEXT[r.outcome]);
|
|
13428
13989
|
lines.push(`Jira ${r.key} ${r.summary}`, ` ${r.url}`, ` \u63D0\u5355\u4EBA ${r.reporter} \xB7 \u5F53\u524D\u8EAB\u4EFD ${r.me}`);
|
|
13429
13990
|
if (r.outcome !== "already-closed") {
|
|
13430
13991
|
const to = r.after?.status ?? r.transition?.to ?? r.before.status;
|
|
@@ -13456,13 +14017,12 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
13456
14017
|
}
|
|
13457
14018
|
|
|
13458
14019
|
// src/commands/chiron-doctor.ts
|
|
13459
|
-
init_auth_guard();
|
|
13460
14020
|
import { promises as fs13 } from "fs";
|
|
13461
14021
|
import path15 from "path";
|
|
13462
14022
|
import axios10 from "axios";
|
|
13463
14023
|
import {
|
|
13464
|
-
CliError as
|
|
13465
|
-
CliErrorCode as
|
|
14024
|
+
CliError as CliError36,
|
|
14025
|
+
CliErrorCode as CliErrorCode37,
|
|
13466
14026
|
formatObject as formatObject30,
|
|
13467
14027
|
httpProbe as httpProbe2,
|
|
13468
14028
|
listEnvs as listEnvs2,
|
|
@@ -13474,8 +14034,10 @@ import {
|
|
|
13474
14034
|
resolveEnvContext as resolveEnvContext9,
|
|
13475
14035
|
printResolvedEnvironment as printResolvedEnvironment9,
|
|
13476
14036
|
conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
|
|
13477
|
-
probeConversationHandshake
|
|
14037
|
+
probeConversationHandshake,
|
|
14038
|
+
createJiraClient as createJiraClient2
|
|
13478
14039
|
} from "@hcmai/sdk";
|
|
14040
|
+
init_auth_guard();
|
|
13479
14041
|
|
|
13480
14042
|
// src/commands/chiron-env.ts
|
|
13481
14043
|
init_exit();
|
|
@@ -13485,8 +14047,8 @@ import yaml from "js-yaml";
|
|
|
13485
14047
|
import {
|
|
13486
14048
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
13487
14049
|
assertNotReservedEnvName as assertNotReservedEnvName3,
|
|
13488
|
-
CliError as
|
|
13489
|
-
CliErrorCode as
|
|
14050
|
+
CliError as CliError31,
|
|
14051
|
+
CliErrorCode as CliErrorCode33,
|
|
13490
14052
|
discoverProjectEnv as discoverProjectEnv6,
|
|
13491
14053
|
ENV_FILE as ENV_FILE2,
|
|
13492
14054
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
@@ -13509,7 +14071,7 @@ function summarizeReasons(reasons) {
|
|
|
13509
14071
|
return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
|
|
13510
14072
|
}
|
|
13511
14073
|
function invalid2(message, nextStep) {
|
|
13512
|
-
throw new
|
|
14074
|
+
throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
13513
14075
|
}
|
|
13514
14076
|
function required(value, label) {
|
|
13515
14077
|
if (!value?.trim()) invalid2(`${label} \u4E0D\u80FD\u4E3A\u7A7A\uFF1B\u914D\u7F6E\u672A\u5199\u5165\u3002`, `\u8BF7\u63D0\u4F9B\u975E\u7A7A\u7684 ${label}`);
|
|
@@ -13733,8 +14295,8 @@ import os5 from "os";
|
|
|
13733
14295
|
import path13 from "path";
|
|
13734
14296
|
import yaml2 from "js-yaml";
|
|
13735
14297
|
import {
|
|
13736
|
-
CliError as
|
|
13737
|
-
CliErrorCode as
|
|
14298
|
+
CliError as CliError32,
|
|
14299
|
+
CliErrorCode as CliErrorCode34,
|
|
13738
14300
|
METHOD_REPO_DISPLAY,
|
|
13739
14301
|
METHOD_REPO_URL,
|
|
13740
14302
|
assertSafeSkillId as assertSafeSkillId2,
|
|
@@ -13775,8 +14337,8 @@ function gitErrorText(e) {
|
|
|
13775
14337
|
function classifyGitFailure(e, repoDisplay) {
|
|
13776
14338
|
const err = e;
|
|
13777
14339
|
if (err.code === "ENOENT") {
|
|
13778
|
-
return new
|
|
13779
|
-
code:
|
|
14340
|
+
return new CliError32({
|
|
14341
|
+
code: CliErrorCode34.METHOD_GIT_UNAVAILABLE,
|
|
13780
14342
|
message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
|
|
13781
14343
|
context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
|
|
13782
14344
|
});
|
|
@@ -13784,15 +14346,15 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13784
14346
|
const text = gitErrorText(e);
|
|
13785
14347
|
const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
|
|
13786
14348
|
if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
|
|
13787
|
-
return new
|
|
13788
|
-
code:
|
|
14349
|
+
return new CliError32({
|
|
14350
|
+
code: CliErrorCode34.METHOD_SOURCE_NETWORK,
|
|
13789
14351
|
message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
|
|
13790
14352
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13791
14353
|
});
|
|
13792
14354
|
}
|
|
13793
14355
|
if (/could not read Username|Authentication failed|terminal prompts disabled|returned error: 401|HTTP Basic: Access denied|invalid credentials|Permission denied \(publickey/i.test(text)) {
|
|
13794
|
-
return new
|
|
13795
|
-
code:
|
|
14356
|
+
return new CliError32({
|
|
14357
|
+
code: CliErrorCode34.METHOD_SOURCE_AUTH_REQUIRED,
|
|
13796
14358
|
message: `\u65B9\u6CD5\u8BBA\u4ED3\u8981\u8BA4\u8BC1\uFF0C\u672C\u673A\u6CA1\u6709\u53EF\u7528\u7684 git \u51ED\u636E\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13797
14359
|
context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
|
|
13798
14360
|
});
|
|
@@ -13800,8 +14362,8 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13800
14362
|
const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
|
|
13801
14363
|
if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
|
|
13802
14364
|
const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
|
|
13803
|
-
return new
|
|
13804
|
-
code:
|
|
14365
|
+
return new CliError32({
|
|
14366
|
+
code: CliErrorCode34.METHOD_SOURCE_FORBIDDEN,
|
|
13805
14367
|
message: `\u51ED\u636E\u6709\u6548\u4F46\u8BFB\u4E0D\u5230\u65B9\u6CD5\u8BBA\u4ED3 ${repoDisplay}\uFF1A${head}` + (notFound ? "\uFF08\u8FDC\u7AEF\u5BF9\u65E0\u6743\u8BBF\u95EE\u7684\u79C1\u6709\u4ED3\u4E5F\u53EF\u80FD\u56DE 404\uFF0C\u6240\u4EE5\u8FD9\u91CC\u4E0D\u628A\u5B83\u5224\u6210\u300C\u4ED3\u4E0D\u5B58\u5728\u300D\uFF09" : ""),
|
|
13806
14368
|
context: {
|
|
13807
14369
|
nextStep: "\u627E\u77E5\u8BC6\u7EC4\u7EC7\u7BA1\u7406\u5458\u628A\u4F60\u52A0\u8FDB\u65B9\u6CD5\u8BBA\u4ED3\uFF08\u8981\u4EE3\u7801\u8BFB\u6743\u9650\uFF09" + (overridden ? "\uFF1B\u4F60\u8BBE\u4E86 HCM_METHOD_REPO / HCM_METHOD_REPO_URL\uFF0C\u5148\u6838\u5BF9\u62FC\u5199" : "")
|
|
@@ -13809,14 +14371,14 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13809
14371
|
});
|
|
13810
14372
|
}
|
|
13811
14373
|
if (/Could not resolve host|Failed to connect|Connection refused|Connection timed out|Operation timed out|Network is unreachable|Could not connect|SSL|TLS|timed out/i.test(text)) {
|
|
13812
|
-
return new
|
|
13813
|
-
code:
|
|
14374
|
+
return new CliError32({
|
|
14375
|
+
code: CliErrorCode34.METHOD_SOURCE_NETWORK,
|
|
13814
14376
|
message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13815
14377
|
context: { nextStep: "\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8DD1\uFF1B\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\u79BB\u7EBF\u53EF\u8BFB\uFF0C`hcm chiron method status` \u7167\u5E38\u80FD\u7528" }
|
|
13816
14378
|
});
|
|
13817
14379
|
}
|
|
13818
|
-
return new
|
|
13819
|
-
code:
|
|
14380
|
+
return new CliError32({
|
|
14381
|
+
code: CliErrorCode34.METHOD_SOURCE_GIT_FAILED,
|
|
13820
14382
|
message: `git \u5931\u8D25\u4E86\uFF0C\u539F\u56E0\u4E0D\u5728\u8BA4\u8BC1 / \u6743\u9650 / \u7F51\u7EDC\u4E09\u7C7B\u91CC\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13821
14383
|
context: { nextStep: `\u81EA\u5DF1\u8DD1\u4E00\u6B21 \`git ls-remote --tags <\u65B9\u6CD5\u8BBA\u4ED3\u5730\u5740>\` \u770B\u539F\u8BDD\uFF1B\u628A\u4E0A\u9762\u8FD9\u6BB5\u8FDE\u540C \`git --version\` \u62A5\u7ED9 CLI \u7EF4\u62A4\u8005` }
|
|
13822
14384
|
});
|
|
@@ -13892,8 +14454,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13892
14454
|
if (ref === void 0) {
|
|
13893
14455
|
const latest = versions[0];
|
|
13894
14456
|
if (!latest) {
|
|
13895
|
-
throw new
|
|
13896
|
-
code:
|
|
14457
|
+
throw new CliError32({
|
|
14458
|
+
code: CliErrorCode34.METHOD_REF_NOT_FOUND,
|
|
13897
14459
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
|
|
13898
14460
|
context: { nextStep: tags.size ? `\u4ED3\u91CC\u6709\u8FD9\u4E9B tag\uFF1A${[...tags.keys()].slice(0, 10).join("\u3001")}\uFF0C\u7528 --ref \u6307\u5B9A\u4E00\u4E2A` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13899
14461
|
});
|
|
@@ -13902,8 +14464,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13902
14464
|
}
|
|
13903
14465
|
const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
|
|
13904
14466
|
if (!name) {
|
|
13905
|
-
throw new
|
|
13906
|
-
code:
|
|
14467
|
+
throw new CliError32({
|
|
14468
|
+
code: CliErrorCode34.METHOD_REF_NOT_FOUND,
|
|
13907
14469
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
|
|
13908
14470
|
context: { nextStep: versions.length ? `\u53EF\u7528\u7684\u7248\u672C tag\uFF1A${versions.slice(0, 10).join("\u3001")}` : "\u65B9\u6CD5\u8BBA\u4ED3\u8FD8\u6CA1\u53D1\u8FC7\u7248\uFF0C\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4" }
|
|
13909
14471
|
});
|
|
@@ -13911,8 +14473,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13911
14473
|
return { ref: name, commit: tags.get(name) };
|
|
13912
14474
|
}
|
|
13913
14475
|
function invalidPackage(field, message) {
|
|
13914
|
-
return new
|
|
13915
|
-
code:
|
|
14476
|
+
return new CliError32({
|
|
14477
|
+
code: CliErrorCode34.METHOD_PACKAGE_INVALID,
|
|
13916
14478
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
|
|
13917
14479
|
context: { field, nextStep: "\u8FD9\u662F\u65B9\u6CD5\u5305\u7684\u7F3A\u9677\uFF0C\u4E0D\u662F\u672C\u673A\u95EE\u9898\uFF1A\u628A\u8FD9\u6BB5\u62A5\u7ED9\u65B9\u6CD5\u8BBA\u4ED3\u8D1F\u8D23\u4EBA\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13918
14480
|
});
|
|
@@ -13936,8 +14498,8 @@ function parsePackageManifest(text) {
|
|
|
13936
14498
|
throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
|
|
13937
14499
|
}
|
|
13938
14500
|
if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
|
|
13939
|
-
throw new
|
|
13940
|
-
code:
|
|
14501
|
+
throw new CliError32({
|
|
14502
|
+
code: CliErrorCode34.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
|
|
13941
14503
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355\u7684\u683C\u5F0F\u7248\u672C schemaVersion=${m.schemaVersion}\uFF0C\u8FD9\u7248 CLI\uFF08${CLI_VERSION}\uFF09\u53EA\u8BA4\u8BC6 ${KNOWN_PACKAGE_SCHEMA_VERSIONS.join(" / ")}`,
|
|
13942
14504
|
context: { nextStep: "\u5347\u7EA7 CLI\uFF1A`npm install --global @hcmai/cli@latest`\uFF08\u6216 `hcm upgrade`\uFF09\uFF0C\u518D\u91CD\u8DD1\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8" }
|
|
13943
14505
|
});
|
|
@@ -14151,7 +14713,8 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
14151
14713
|
b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: where }));
|
|
14152
14714
|
}
|
|
14153
14715
|
} catch (e) {
|
|
14154
|
-
|
|
14716
|
+
const reason = e instanceof CliError32 && typeof e.context?.reason === "string" ? `\uFF1A${e.context.reason}` : "";
|
|
14717
|
+
b.note = `\u53D6\u4E0D\u5230 ${online.endpoint} \u7684\u5728\u7EBF\u76EE\u5F55\uFF08${e.message.split("\n")[0]}${reason}\uFF09\uFF0C\u5728\u7EBF\u76EE\u5F55\u672A\u6BD4\u5BF9`;
|
|
14155
14718
|
}
|
|
14156
14719
|
}
|
|
14157
14720
|
blocks.push(b);
|
|
@@ -14173,8 +14736,8 @@ function renderConflictBlocks(blocks) {
|
|
|
14173
14736
|
}
|
|
14174
14737
|
function conflictError(blocks, pkg, commit) {
|
|
14175
14738
|
const hits = blocks.flatMap((b) => b.conflicts);
|
|
14176
|
-
return new
|
|
14177
|
-
code:
|
|
14739
|
+
return new CliError32({
|
|
14740
|
+
code: CliErrorCode34.SKILL_ID_CONFLICT,
|
|
14178
14741
|
message: "\u65B9\u6CD5\u5305\u91CC\u7684\u6280\u80FD id \u4E0E\u5DF2\u6709\u6765\u6E90\u540C\u540D\uFF0C\u62D2\u88C5\uFF1A\n" + hits.map((c2) => ` \xB7 \`${c2.id}\`\uFF1A\u65B9\u6CD5 ${pkg.version} @${commit.slice(0, 12)} \u2194 ${c2.other}`).join("\n") + "\n\u672C\u8D9F\u51B2\u7A81\u68C0\u67E5\uFF1A\n" + renderConflictBlocks(blocks).join("\n"),
|
|
14179
14742
|
context: {
|
|
14180
14743
|
nextStep: `\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\u3002\`${METHOD_SKILL_PREFIX}\` \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF0C\u7EA6\u5B9A\u751F\u6548\u65F6\u4E0D\u8BE5\u649E\u540D\uFF1B\u649E\u4E86\u8BF4\u660E\u6709\u4E00\u8FB9\u8FDD\u53CD\u4E86\u524D\u7F00\u7EA6\u5B9A\u3002\u5DF2\u88C5\u7684\u65B9\u6CD5\u5305\uFF08\u5982\u6709\uFF09\u4FDD\u6301\u539F\u6837\uFF0C\u6CA1\u52A8`,
|
|
@@ -14189,8 +14752,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
|
|
|
14189
14752
|
const finish = existing.indexOf(end);
|
|
14190
14753
|
const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
14191
14754
|
if (malformed) {
|
|
14192
|
-
throw new
|
|
14193
|
-
code:
|
|
14755
|
+
throw new CliError32({
|
|
14756
|
+
code: CliErrorCode34.METHOD_MANAGED_BLOCK_CORRUPT,
|
|
14194
14757
|
message: `${label} \u91CC\u65B9\u6CD5\u53D7\u7BA1\u5757\u7684\u6807\u8BB0\u635F\u574F\u6216\u91CD\u590D\uFF08${begin} \u2026 ${end}\uFF09\uFF0C\u62D2\u7EDD\u8986\u76D6`,
|
|
14195
14758
|
context: { nextStep: `\u624B\u5DE5\u628A ${label} \u91CC\u8FD9\u4E24\u884C\u6807\u8BB0\u4FEE\u6210\u5404\u51FA\u73B0\u4E00\u6B21\u3001begin \u5728\u524D\uFF08\u6216\u8FDE\u540C\u4E2D\u95F4\u5185\u5BB9\u6574\u6BB5\u5220\u6389\uFF09\uFF0C\u518D\u91CD\u8DD1` }
|
|
14196
14759
|
});
|
|
@@ -14254,8 +14817,8 @@ async function readLock(root) {
|
|
|
14254
14817
|
if (e.code === "ENOENT") return void 0;
|
|
14255
14818
|
throw e;
|
|
14256
14819
|
}
|
|
14257
|
-
const bad = (why) => new
|
|
14258
|
-
code:
|
|
14820
|
+
const bad = (why) => new CliError32({
|
|
14821
|
+
code: CliErrorCode34.METHOD_LOCK_INVALID,
|
|
14259
14822
|
message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
|
|
14260
14823
|
context: { nextStep: "\u591A\u534A\u662F\u5408\u5E76\u51B2\u7A81\u7559\u4E0B\u7684\u6807\u8BB0\uFF1A\u6309\u9879\u76EE PR \u91CC\u60F3\u8981\u7684\u90A3\u4E00\u7248\u89E3\u51B3\u51B2\u7A81\uFF08\u6216 `git checkout` \u56DE\u4E0A\u4E00\u7248\uFF09\uFF0C\u518D\u8DD1 `hcm chiron method status`" }
|
|
14261
14824
|
});
|
|
@@ -14295,7 +14858,7 @@ async function resolveMethodRoot(project2, log) {
|
|
|
14295
14858
|
async function resolveTarget(root, requested) {
|
|
14296
14859
|
if (requested === "claude" || requested === "codex") return requested;
|
|
14297
14860
|
if (requested !== void 0 && requested !== "auto") {
|
|
14298
|
-
throw new
|
|
14861
|
+
throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
|
|
14299
14862
|
}
|
|
14300
14863
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
14301
14864
|
}
|
|
@@ -14437,8 +15000,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14437
15000
|
const tags = await listRemoteTags(deps);
|
|
14438
15001
|
const r = resolveRef(tags, input.ref, deps);
|
|
14439
15002
|
if (input.expectCommit && r.commit !== input.expectCommit) {
|
|
14440
|
-
throw new
|
|
14441
|
-
code:
|
|
15003
|
+
throw new CliError32({
|
|
15004
|
+
code: CliErrorCode34.METHOD_TAG_MOVED,
|
|
14442
15005
|
message: `\u9501\u6587\u4EF6\u9501\u5B9A ${r.ref} @ ${input.expectCommit}\uFF0C\u800C\u8FD9\u4E2A tag \u73B0\u5728\u6307\u5411 ${r.commit}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF09`,
|
|
14443
15006
|
context: { nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\u3002\u786E\u8BA4\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`\uFF08\u9501\u6587\u4EF6\u7684\u53D8\u66F4\u8D70\u9879\u76EE PR \u8BC4\u5BA1\uFF09" }
|
|
14444
15007
|
});
|
|
@@ -14453,8 +15016,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14453
15016
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
14454
15017
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
14455
15018
|
if (head !== resolved.commit) {
|
|
14456
|
-
throw new
|
|
14457
|
-
code:
|
|
15019
|
+
throw new CliError32({
|
|
15020
|
+
code: CliErrorCode34.METHOD_TAG_MOVED,
|
|
14458
15021
|
message: `\u89E3\u6790\u65F6 ${resolved.ref} \u6307\u5411 ${resolved.commit}\uFF0C\u53D6\u4E0B\u6765\u7684\u5374\u662F ${head}\uFF08tag \u5728\u8FD9\u51E0\u79D2\u91CC\u88AB\u79FB\u52A8\u4E86\uFF09`,
|
|
14459
15022
|
context: { nextStep: "\u91CD\u8DD1\u4E00\u6B21\uFF1B\u518D\u51FA\u73B0\u5C31\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4\u8FD9\u4E2A tag \u4E3A\u4EC0\u4E48\u5728\u52A8" }
|
|
14460
15023
|
});
|
|
@@ -14633,7 +15196,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14633
15196
|
verdict: "fail",
|
|
14634
15197
|
detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
|
|
14635
15198
|
nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C",
|
|
14636
|
-
code:
|
|
15199
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED
|
|
14637
15200
|
});
|
|
14638
15201
|
return done();
|
|
14639
15202
|
}
|
|
@@ -14647,7 +15210,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14647
15210
|
verdict: "fail",
|
|
14648
15211
|
detail: "\u9501\u6587\u4EF6\u5728\uFF0C\u4F46\u672C\u673A\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF08\u521A clone \u4E0B\u6765\u7684\u9879\u76EE\u4ED3\u5C31\u662F\u8FD9\u6837\uFF09",
|
|
14649
15212
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
|
|
14650
|
-
code:
|
|
15213
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED
|
|
14651
15214
|
});
|
|
14652
15215
|
} else {
|
|
14653
15216
|
report.installed.present = true;
|
|
@@ -14658,7 +15221,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14658
15221
|
verdict: "fail",
|
|
14659
15222
|
detail: "\u672C\u673A\u526F\u672C\u7684 package.yml \u4E0E\u9501\u6587\u4EF6\u8BB0\u7684\u6458\u8981\u4E0D\u4E00\u81F4\uFF1A\u88C5\u7684\u4E0D\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248",
|
|
14660
15223
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
|
|
14661
|
-
code:
|
|
15224
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14662
15225
|
});
|
|
14663
15226
|
} else {
|
|
14664
15227
|
report.rows.push({ item: "\u5B89\u88C5", verdict: "ok", detail: `\u672C\u673A\u526F\u672C\u5C31\u662F\u9501\u5B9A\u7684\u90A3\u4E00\u7248\uFF08${path13.join(root, METHOD_DIR)}/\uFF09` });
|
|
@@ -14702,13 +15265,13 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14702
15265
|
verdict: "fail",
|
|
14703
15266
|
detail: `${bad.length} \u4EFD .claude/skills \u65B9\u6CD5\u526F\u672C\u4E0E\u9501\u5B9A\u7248\u672C\u4E0D\u7B26\uFF08\u8FD9\u53F0\u673A\u5668\u73B0\u5728\u7684 target \u662F ${state.target}\uFF0C\u8FD9\u4E9B\u526F\u672C\u662F\u4E4B\u524D\u7528 claude \u76EE\u6807\u88C5\u65F6\u7559\u4E0B\u7684\uFF09\uFF1A${listing}`,
|
|
14704
15267
|
nextStep: "`hcm chiron method install`\uFF08\u4F1A\u4E00\u5E76\u5237\u65B0 .claude/skills \u4E0B\u5DF2\u6709\u7684\u65B9\u6CD5\u526F\u672C\uFF09\uFF1B\u4E0D\u518D\u7528 Claude Code \u5C31\u5220\u6389 `.claude/skills/method-*/`",
|
|
14705
|
-
code:
|
|
15268
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14706
15269
|
} : {
|
|
14707
15270
|
item: "\u6458\u8981",
|
|
14708
15271
|
verdict: "fail",
|
|
14709
15272
|
detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
|
|
14710
15273
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF0C\u672C\u673A\u6539\u52A8\u4F1A\u88AB\u8986\u76D6\uFF1B\u8981\u6539\u65B9\u6CD5\u5C31\u53BB\u65B9\u6CD5\u8BBA\u4ED3\u63D0\uFF09",
|
|
14711
|
-
code:
|
|
15274
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14712
15275
|
});
|
|
14713
15276
|
} else {
|
|
14714
15277
|
report.rows.push({
|
|
@@ -14731,7 +15294,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14731
15294
|
verdict: "warn",
|
|
14732
15295
|
detail: `tag ${lock.ref} \u73B0\u5728\u6307\u5411 ${report.remote.lockedTagCommit.slice(0, 12)}\uFF0C\u9501\u5B9A\u7684\u662F ${lock.commit.slice(0, 12)}\uFF08tag \u88AB\u79FB\u52A8\u8FC7\uFF1B\u672C\u673A\u526F\u672C\u4EE5\u9501\u5B9A\u7684 commit \u4E3A\u51C6\uFF09`,
|
|
14733
15296
|
nextStep: "\u627E\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u786E\u8BA4 tag \u4E3A\u4EC0\u4E48\u88AB\u79FB\u52A8\uFF1B\u8981\u8DDF\u65B0\u5185\u5BB9\u5C31 `hcm chiron method update --ref <tag>`",
|
|
14734
|
-
code:
|
|
15297
|
+
code: CliErrorCode34.METHOD_TAG_MOVED
|
|
14735
15298
|
});
|
|
14736
15299
|
} else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
|
|
14737
15300
|
report.remote.undetermined = !SEMVER_TAG.test(lock.ref) ? `\u9501\u5B9A\u7684 ref ${lock.ref} \u4E0D\u662F vX.Y.Z \u7248\u672C tag\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E\uFF08\u8FDC\u7AEF\u6700\u65B0\u7248\u672C tag\uFF1A${report.remote.latestTag ?? "\u65E0"}\uFF09` : "\u8FDC\u7AEF\u4E00\u4E2A vX.Y.Z \u7248\u672C tag \u90FD\u6CA1\u6709\uFF0C\u65E0\u6CD5\u5224\u65AD\u662F\u5426\u843D\u540E";
|
|
@@ -14776,7 +15339,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14776
15339
|
const hits = report.conflictCheck.flatMap((b) => b.conflicts);
|
|
14777
15340
|
const unchecked = report.conflictCheck.filter((b) => !b.checked);
|
|
14778
15341
|
const summary = report.conflictCheck.map((b) => b.checked ? `${b.label}\uFF1A\u5DF2\u6BD4\u5BF9 ${b.compared.length} \u4E2A${b.conflicts.length ? `\uFF0C\u540C\u540D ${b.conflicts.map((c2) => c2.id).join("\u3001")}` : "\uFF0C\u65E0\u540C\u540D"}` : `${b.label}\uFF1A\u672A\u6BD4\u5BF9\uFF08${b.note}\uFF09`).join("\uFF1B");
|
|
14779
|
-
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code:
|
|
15342
|
+
report.rows.push(hits.length ? { item: "\u51B2\u7A81", verdict: "fail", detail: summary, nextStep: "\u62A5\u65B9\u6CD5\u8D1F\u8D23\u4EBA\u6539\u540D\uFF08method- \u524D\u7F00\u53EA\u7ED9\u65B9\u6CD5\u6765\u6E90\uFF09", code: CliErrorCode34.SKILL_ID_CONFLICT } : unchecked.length ? { item: "\u51B2\u7A81", verdict: "warn", detail: `${summary}\u2014\u2014\u6CA1\u6BD4\u5BF9\u7684\u5757\u4E0A\u4E0D\u80FD\u8BF4\u300C\u65E0\u51B2\u7A81\u300D` } : { item: "\u51B2\u7A81", verdict: "ok", detail: summary });
|
|
14780
15343
|
}
|
|
14781
15344
|
report.rows.push(report.remote.checked ? { item: "\u6765\u6E90", verdict: "ok", detail: `\u5728\u7EBF\uFF1Agit \u51ED\u636E\u8BA4\u8BC1\u53D6 tag\uFF0Ccommit \u56FA\u5B9A\uFF08${lock.repo}\uFF09` } : { item: "\u6765\u6E90", verdict: "warn", detail: "\u79BB\u7EBF\uFF1A\u53EA\u6838\u4E86\u672C\u673A\u526F\u672C\u7684\u6458\u8981\uFF0C\u6CA1\u4E0E\u8FDC\u7AEF\u6838\u5BF9 tag" });
|
|
14782
15345
|
return done();
|
|
@@ -14795,10 +15358,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
|
|
|
14795
15358
|
const row = (item) => s.rows.find((r) => r.item === item);
|
|
14796
15359
|
const lockRow = row("\u9501\u5B9A");
|
|
14797
15360
|
if (!s.lock) {
|
|
14798
|
-
return lockRow.code ===
|
|
15361
|
+
return lockRow.code === CliErrorCode34.METHOD_NOT_INSTALLED ? { verdict: "warn", detail: "\u672A\u5B89\u88C5\uFF08\u9879\u76EE\u91CC\u6CA1\u6709\u65B9\u6CD5\u5305\u9501\u6587\u4EF6\uFF09", nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" } : { verdict: "warn", detail: `\u65E0\u6CD5\u5224\u65AD\uFF1A${lockRow.detail}`, nextStep: lockRow.nextStep };
|
|
14799
15362
|
}
|
|
14800
15363
|
const install = row("\u5B89\u88C5");
|
|
14801
|
-
if (install?.code ===
|
|
15364
|
+
if (install?.code === CliErrorCode34.METHOD_NOT_INSTALLED) {
|
|
14802
15365
|
return { verdict: "warn", detail: `\u672A\u5B89\u88C5\uFF08\u9501\u6587\u4EF6\u9501\u5B9A\u65B9\u6CD5 ${s.lock.package.version} \xB7 ${s.lock.ref}\uFF0C\u672C\u673A\u8FD8\u6CA1\u6709\u65B9\u6CD5\u5305\u526F\u672C\uFF09`, nextStep: "\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u5C31\u8DD1 `hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09\uFF1B\u6CA1\u6709\u6388\u6743\u53EF\u4EE5\u8DF3\u8FC7\uFF0C\u4E0D\u5F71\u54CD\u4EA7\u54C1\u64CD\u4F5C" };
|
|
14803
15366
|
}
|
|
14804
15367
|
const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
|
|
@@ -14831,8 +15394,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
|
|
|
14831
15394
|
const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
|
|
14832
15395
|
const lock = await readLock(root);
|
|
14833
15396
|
if (!lock) {
|
|
14834
|
-
throw new
|
|
14835
|
-
code:
|
|
15397
|
+
throw new CliError32({
|
|
15398
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED,
|
|
14836
15399
|
message: `${root} \u91CC\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305\uFF0C\u6CA1\u6709\u53EF\u4EE5\u66F4\u65B0\u7684\u8D77\u70B9`,
|
|
14837
15400
|
context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
|
|
14838
15401
|
});
|
|
@@ -14882,7 +15445,7 @@ async function methodStatusCommand(args) {
|
|
|
14882
15445
|
import { promises as fs12 } from "fs";
|
|
14883
15446
|
import path14 from "path";
|
|
14884
15447
|
import axios6 from "axios";
|
|
14885
|
-
import { fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
15448
|
+
import { CliError as CliError33, CliErrorCode as CliErrorCode35, fetchSkillCatalog as fetchSkillCatalog3, fetchSkillMarkdown as fetchSkillMarkdown2, fetchSkillReference as fetchSkillReference2, normalizeReferences as normalizeReferences2, normalizeOrigin as normalizeOrigin6, resolveChironBase as resolveChironBase3 } from "@hcmai/sdk";
|
|
14886
15449
|
|
|
14887
15450
|
// src/commands/doctor/result.ts
|
|
14888
15451
|
import { createHash as createHash7 } from "crypto";
|
|
@@ -14936,8 +15499,9 @@ function makeResult(descriptor2, observation, env2, target, requestedAt, duratio
|
|
|
14936
15499
|
grade: target ? o.grade ?? "WARN" : "WARN",
|
|
14937
15500
|
coverage,
|
|
14938
15501
|
evidence: o.evidence ?? "DIRECT",
|
|
14939
|
-
|
|
14940
|
-
|
|
15502
|
+
...o.value !== void 0 ? { value: o.value } : {},
|
|
15503
|
+
// 带了 reason 的 FOUND 是「发现了,但看到的数据不全」:结构上标 degraded,调用方不用去读摘要
|
|
15504
|
+
...o.reason ? { degraded: true, reason: o.reason } : { degraded: false }
|
|
14941
15505
|
};
|
|
14942
15506
|
break;
|
|
14943
15507
|
case "UNDETERMINED":
|
|
@@ -14971,13 +15535,27 @@ var credential = async (_ctx, env2) => {
|
|
|
14971
15535
|
const slot = await env2.credential();
|
|
14972
15536
|
return slot.resolved ? pass(`\u672C\u673A\u69FD ${slot.resolved.name} \xB7 ${env2.config.endpoint} \xB7 \u79DF\u6237 ${env2.config.tenant}`) : found("CREDENTIAL_MISSING", void 0, { evidence: "ABSENT" });
|
|
14973
15537
|
};
|
|
15538
|
+
var isPrerelease = (v) => /^\d+\.\d+\.\d+-/.test((v ?? "").trim());
|
|
15539
|
+
function parseCliVersion(v) {
|
|
15540
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec((v ?? "").trim());
|
|
15541
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
15542
|
+
}
|
|
14974
15543
|
var version = async (ctx) => {
|
|
14975
15544
|
const latest = await ctx.services.latestVersion();
|
|
14976
15545
|
if (latest === null) return unknown("CLI_LATEST_UNKNOWN");
|
|
14977
|
-
const
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
15546
|
+
const current = parseCliVersion(ctx.cliVersion), newest = parseCliVersion(latest);
|
|
15547
|
+
if (!current || !newest) {
|
|
15548
|
+
const bad = [!current && `\u672C\u673A CLI\u300C${ctx.cliVersion}\u300D`, !newest && `npm \u6700\u65B0\u300C${latest}\u300D`].filter(Boolean).join("\u3001");
|
|
15549
|
+
return unknown(
|
|
15550
|
+
"CLI_VERSION_UNPARSEABLE",
|
|
15551
|
+
`${bad} \u4E0D\u662F X.Y.Z \u7248\u672C\u53F7\uFF0C\u6CA1\u6CD5\u6BD4\u8F83\u65B0\u65E7`,
|
|
15552
|
+
// 最新版本写死从 registry.npmjs.org 取(fetchLatestVersion),与本机 npm 的 registry 配置无关:对照时也指定这个源
|
|
15553
|
+
{ note: "\u5BF9\u7167 hcm --version \u4E0E npm view @hcmai/cli version --registry https://registry.npmjs.org \u7684\u539F\u6837\u8F93\u51FA\uFF1B\u672C\u673A\u90A3\u8FB9\u574F\u4E86\u5C31\u91CD\u88C5 @hcmai/cli\uFF0Cnpm \u6B63\u5F0F\u6E90\u90A3\u8FB9\u574F\u4E86\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9" }
|
|
15554
|
+
);
|
|
15555
|
+
}
|
|
15556
|
+
const first = newest.findIndex((v, i) => v !== current[i]);
|
|
15557
|
+
const behind = first >= 0 ? newest[first] > current[first] : isPrerelease(ctx.cliVersion) && !isPrerelease(latest);
|
|
15558
|
+
return behind ? found("CLI_OUTDATED", `CLI ${ctx.cliVersion}\uFF0Cnpm \u6700\u65B0 ${latest}`) : pass(`CLI ${ctx.cliVersion}\uFF0Cnpm \u6700\u65B0 ${latest}`);
|
|
14981
15559
|
};
|
|
14982
15560
|
var installed = async (ctx) => {
|
|
14983
15561
|
let reading = "";
|
|
@@ -15052,6 +15630,11 @@ async function inspectSkillsFresh(states, endpoint, signal) {
|
|
|
15052
15630
|
const entries = plans.flatMap((p) => p.plan.entries);
|
|
15053
15631
|
return classifySkillFreshness(states.length, entries, plans.flatMap((p) => p.mismatched));
|
|
15054
15632
|
} catch (error) {
|
|
15633
|
+
if (error instanceof CliError33 && error.code === CliErrorCode35.SKILL_CATALOG_UNAVAILABLE) {
|
|
15634
|
+
const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
|
|
15635
|
+
const next = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
|
|
15636
|
+
return unknown("SKILLS_CATALOG_UNAVAILABLE", `\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08${error.message}${reason}\uFF09\uFF0C\u672C\u8F6E\u6CA1\u6CD5\u5BF9\u8D26`, next ? { note: next } : {});
|
|
15637
|
+
}
|
|
15055
15638
|
return unknown("SKILLS_CATALOG_UNCHECKED", void 0, { note: safeError(error) });
|
|
15056
15639
|
}
|
|
15057
15640
|
}
|
|
@@ -15108,18 +15691,80 @@ var cases = async (ctx) => {
|
|
|
15108
15691
|
var jira = async (ctx) => {
|
|
15109
15692
|
const status = await ctx.services.inspectJira({ httpTimeoutMs: 8e3 });
|
|
15110
15693
|
if (status.ok) return pass(`${status.who || "\u5DF2\u8FDE\u63A5"}\uFF0CJira \u9879\u76EE\u53EF\u89C1\uFF08\u53EA\u8BFB\u63A2\u6D3B\uFF09`);
|
|
15111
|
-
const code2 = status.code ?? (status.tokenReadError ? "JIRA_TOKEN_UNREADABLE" : "
|
|
15112
|
-
const undetermined = ["JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE"].includes(code2);
|
|
15694
|
+
const code2 = status.code ?? (status.tokenReadError ? "JIRA_TOKEN_UNREADABLE" : "JIRA_UNCLASSIFIED");
|
|
15695
|
+
const undetermined = ["JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE", "JIRA_UNCLASSIFIED"].includes(code2);
|
|
15113
15696
|
return (undetermined ? unknown : found)(code2, void 0, {
|
|
15114
15697
|
note: [status.reason, status.nextStep, !status.code ? "\u672A\u80FD\u5224\u522B\u5931\u8D25\u7C7B\u578B" : void 0].filter(Boolean).join("\uFF1B")
|
|
15115
15698
|
});
|
|
15116
15699
|
};
|
|
15117
|
-
var
|
|
15700
|
+
var pendingVerify = async (ctx, _env, execution) => {
|
|
15701
|
+
let r;
|
|
15702
|
+
try {
|
|
15703
|
+
r = await ctx.services.pendingVerify(execution?.signal);
|
|
15704
|
+
} catch (error) {
|
|
15705
|
+
return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: `\u5F85\u590D\u9A8C\u6E05\u5355\u6CA1\u67E5\u6210\uFF1A${safeError(error)}` });
|
|
15706
|
+
}
|
|
15707
|
+
if (r.error) return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: `\u5F85\u590D\u9A8C\u6E05\u5355\u67E5\u8BE2\u5931\u8D25\uFF1A${r.error}` });
|
|
15708
|
+
const gaps = [
|
|
15709
|
+
r.undetermined.length ? `${r.undetermined.length} \u5F20\u65E0\u6CD5\u5224\u5B9A` : "",
|
|
15710
|
+
r.prefilter.truncated ? `\u9884\u7B5B\u53EA\u770B\u4E86 ${r.prefilter.count}${r.prefilter.total !== null ? `/${r.prefilter.total}` : ""} \u5F20` : ""
|
|
15711
|
+
].filter(Boolean).join("\u3001");
|
|
15712
|
+
const why = r.undetermined.map((u) => `${u.key}\uFF1A${u.reason}`).join("\uFF1B");
|
|
15713
|
+
if (r.items.length) {
|
|
15714
|
+
return found(
|
|
15715
|
+
"GAPS_VERIFY_PENDING",
|
|
15716
|
+
`${r.items.length} \u5F20\u5DF2\u4FEE\u590D\u8D85\u8FC7 14 \u5929\u5F85\u4F60\u590D\u9A8C\uFF1A${r.items.map((i) => `${i.key}\uFF08${i.days} \u5929\uFF09`).join("\u3001")}${r.complete ? "" : `\uFF1B\u5F20\u6570\u662F\u4E0B\u9650\uFF08${gaps}\uFF09`}`,
|
|
15717
|
+
{ value: r.items.length, ...r.complete ? {} : { reason: "TRUNCATED", note: why || r.nextStep } }
|
|
15718
|
+
);
|
|
15719
|
+
}
|
|
15720
|
+
if (!r.complete) {
|
|
15721
|
+
return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: r.undetermined.map((u) => `${u.key}\uFF1A${u.reason}`).join("\uFF1B") || r.nextStep });
|
|
15722
|
+
}
|
|
15723
|
+
return pass(`\u6CA1\u6709\u5DF2\u4FEE\u590D\u8D85\u8FC7 14 \u5929\u5F85\u590D\u9A8C\u7684\u5355\uFF08\u9884\u7B5B ${r.prefilter.count} \u5F20\uFF09`, { value: 0 });
|
|
15724
|
+
};
|
|
15725
|
+
var shadow = async (ctx) => {
|
|
15726
|
+
const localDir = skillsLocalDir(ctx.root);
|
|
15727
|
+
let r;
|
|
15728
|
+
try {
|
|
15729
|
+
r = await listShadowedSkills({ baseDir: skillsSyncDir(ctx.root), localDir });
|
|
15730
|
+
} catch (error) {
|
|
15731
|
+
const where = error instanceof SkillsDirUnreadable ? path14.relative(ctx.root, error.where) : path14.relative(ctx.root, localDir);
|
|
15732
|
+
const detail = error instanceof SkillsDirUnreadable ? safeError(new Error(error.detail)) : safeError(error);
|
|
15733
|
+
const u = error instanceof SkillsDirUnreadable ? error : void 0;
|
|
15734
|
+
const side = `${u?.side === "sync" ? `${SKILLS_DIR}/sync/` : `${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/`}${u?.id ? ` \u91CC\u7684 ${u.id}` : ""}`;
|
|
15735
|
+
return unknown(
|
|
15736
|
+
"SKILLS_LOCAL_UNREADABLE",
|
|
15737
|
+
`${side} \u8BFB\u4E0D\u4E86\uFF0C\u6CA1\u6CD5\u5224\u6709\u6CA1\u6709\u906E\u853D\u4EA7\u54C1\u6280\u80FD\uFF1B${unreadableFix(u?.code, u?.detail ?? detail)}\u540E\u91CD\u67E5`,
|
|
15738
|
+
{ note: `${where}\uFF1A${detail}` }
|
|
15739
|
+
);
|
|
15740
|
+
}
|
|
15741
|
+
const others = r.unreadable.length ? `\uFF1Bsync/ \u53E6\u6709 ${r.unreadable.length} \u6761\u8BFB\u4E0D\u4E86\u3001\u6CA1\u7B97\u8FDB\u53BB\uFF1A${describeUnreadable(r.unreadable)}` : "";
|
|
15742
|
+
const raw = r.unreadable.map((x) => `${path14.relative(ctx.root, x.where)}\uFF1A${safeError(new Error(x.detail))}`).join("\uFF1B");
|
|
15743
|
+
if (r.shadowed.length) {
|
|
15744
|
+
return found(
|
|
15745
|
+
"SKILLS_LOCAL_SHADOW",
|
|
15746
|
+
`${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u853D\u4E86 ${r.shadowed.length} \u4EFD\u4EA7\u54C1\u6280\u80FD\uFF1A${describeShadows(r.shadowed)}${others}`,
|
|
15747
|
+
{ value: r.shadowed.length, note: raw ? `${SHADOW_HINT} \u8BFB\u4E0D\u4E86\u7684\uFF1A${raw}` : SHADOW_HINT }
|
|
15748
|
+
);
|
|
15749
|
+
}
|
|
15750
|
+
if (!r.product) {
|
|
15751
|
+
if (r.unreadable.length) {
|
|
15752
|
+
return unknown(
|
|
15753
|
+
"SKILLS_LOCAL_UNREADABLE",
|
|
15754
|
+
`${SKILLS_DIR}/sync/ \u91CC\u8BFB\u5F97\u4E86\u7684\u4EA7\u54C1\u6280\u80FD\u4E00\u4EFD\u90FD\u6CA1\u6709\uFF0C\u53E6\u6709 ${r.unreadable.length} \u6761\u8BFB\u4E0D\u4E86\uFF1A${describeUnreadable(r.unreadable)}\uFF1B\u4FEE\u597D\u540E\u91CD\u67E5`,
|
|
15755
|
+
{ note: raw }
|
|
15756
|
+
);
|
|
15757
|
+
}
|
|
15758
|
+
return { level: "NOT_APPLICABLE", summary: `${SKILLS_DIR}/sync/ \u91CC\u8FD8\u6CA1\u6709\u4EA7\u54C1\u6280\u80FD\uFF0C\u8C08\u4E0D\u4E0A\u906E\u853D\uFF08local/ ${r.local} \u4EFD\uFF09` };
|
|
15759
|
+
}
|
|
15760
|
+
return pass(`\u6CA1\u6709\u4EA7\u54C1\u6280\u80FD\u88AB ${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u853D\uFF08local/ ${r.local} \u4EFD\uFF0Csync/ ${r.product} \u4EFD\uFF09${others}`, { value: 0, ...raw ? { note: `\u8BFB\u4E0D\u4E86\u7684\uFF1A${raw}` } : {} });
|
|
15761
|
+
};
|
|
15762
|
+
var localChecks = { project, credential, version, installed, fresh, shadow, boundary, method, cases, jira, pendingVerify };
|
|
15118
15763
|
|
|
15119
15764
|
// src/commands/doctor/connect-checks.ts
|
|
15120
15765
|
init_auth_guard();
|
|
15121
15766
|
import axios8 from "axios";
|
|
15122
|
-
import { CliError as
|
|
15767
|
+
import { CliError as CliError34, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
15123
15768
|
|
|
15124
15769
|
// src/commands/doctor/server-report.ts
|
|
15125
15770
|
import axios7 from "axios";
|
|
@@ -15291,9 +15936,9 @@ function reconcileReport(ctx, env2, report, requested, platformOps) {
|
|
|
15291
15936
|
for (const key2 of ["only", "skip"]) if (!sameTokens(echo?.[key2], requested[key2])) both2(`scope.${key2} \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26`);
|
|
15292
15937
|
if (echo?.active !== requested.active) both2("scope.active \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26");
|
|
15293
15938
|
}
|
|
15294
|
-
if (report.returnedCount !== report.results.length || report.totalCount !== report.scopeIds.length)
|
|
15295
|
-
both2(`\u8BA1\u6570\u4E0D\u7B26\uFF1AreturnedCount=${report.returnedCount}\uFF0Cresults.length=${report.results.length}\uFF1BtotalCount=${report.totalCount}\uFF0CscopeIds.length=${report.scopeIds.length}`);
|
|
15296
15939
|
}
|
|
15940
|
+
if (report.returnedCount !== report.results.length || report.totalCount !== report.scopeIds.length)
|
|
15941
|
+
both2(`\u8BA1\u6570\u4E0D\u7B26\uFF1AreturnedCount=${report.returnedCount}\uFF0Cresults.length=${report.results.length}\uFF1BtotalCount=${report.totalCount}\uFF0CscopeIds.length=${report.scopeIds.length}`);
|
|
15297
15942
|
const groups = /* @__PURE__ */ new Map();
|
|
15298
15943
|
for (const row of report.results) groups.set(row.checkId, [...groups.get(row.checkId) ?? [], row]);
|
|
15299
15944
|
for (const [id, group] of groups) {
|
|
@@ -15302,23 +15947,30 @@ function reconcileReport(ctx, env2, report, requested, platformOps) {
|
|
|
15302
15947
|
issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u7ED3\u679C\u5C42\u4E0D\u662F platform`);
|
|
15303
15948
|
continue;
|
|
15304
15949
|
}
|
|
15305
|
-
if (!
|
|
15950
|
+
if (!scope.has(id)) {
|
|
15306
15951
|
issue(row.layer, `${id}\uFF1A\u7ED3\u679C\u8D8A\u51FA\u672C\u6B21\u8303\u56F4`);
|
|
15307
15952
|
continue;
|
|
15308
15953
|
}
|
|
15309
15954
|
const why = group.length > 1 ? `\u540C\u4E00 id \u51FA\u73B0 ${group.length} \u6761` : verdictViolation(row);
|
|
15310
15955
|
rows2.push(why ? rewrite(row, group, why) : { ...row, env: env2.name });
|
|
15311
15956
|
}
|
|
15312
|
-
if (!
|
|
15313
|
-
|
|
15314
|
-
rows2.push(synthesize(id, "REPORT_ITEM_MISSING", "CLI \u8865\u9879\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879"));
|
|
15315
|
-
}
|
|
15957
|
+
for (const id of expected) if (!rows2.some((row) => row.checkId === id))
|
|
15958
|
+
rows2.push(synthesize(id, "REPORT_ITEM_MISSING", `CLI \u8865\u9879\uFF1A\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879${changed ? "\uFF08\u62A5\u544A\u81EA\u5DF1\u7684 scopeIds \u91CC\u6709\u5B83\uFF09" : ""}`));
|
|
15316
15959
|
const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (platformOps ? layer2 === "platform" : !ctx.scope || ctx.scope.serverLayers.has(layer2));
|
|
15317
15960
|
const marks = /* @__PURE__ */ new Map();
|
|
15318
15961
|
for (const [layer2, notes] of issues) {
|
|
15319
15962
|
const home = selected(layer2) ? layer2 : platformOps ? "platform" : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
|
|
15320
15963
|
marks.set(home, [...marks.get(home) ?? [], ...notes.map((note) => home === layer2 ? note : `${String(layer2)} \u5C42\uFF08\u4E0D\u5728\u672C\u6B21\u8303\u56F4\uFF09\uFF1A${note}`)]);
|
|
15321
15964
|
}
|
|
15965
|
+
const unverifiable = "\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D8\u5316\uFF1A\u670D\u52A1\u7AEF\u6709\u6CA1\u6709\u6F0F\u62A5\u6838\u4E0D\u51FA\u6765\uFF0C\u76EE\u5F55\u7A33\u5B9A\u540E\u91CD\u8DD1\u4E00\u6B21";
|
|
15966
|
+
if (changed) for (const notes of marks.values()) notes.push(unverifiable);
|
|
15967
|
+
if (changed) for (const layer2 of SERVER_PLACEHOLDERS.map((d) => d.layer).filter(selected)) {
|
|
15968
|
+
if (marks.has(layer2)) continue;
|
|
15969
|
+
rows2.push(...placeholderRows(ctx, env2, unknown("REPORT_CATALOG_CHANGED", "\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D8\u5316\uFF0C\u670D\u52A1\u7AEF\u6709\u6CA1\u6709\u6F0F\u62A5\u6838\u4E0D\u51FA\u6765", {
|
|
15970
|
+
reason: "SOURCE_UNAVAILABLE",
|
|
15971
|
+
note: `${env2.report.server.note ?? `\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316\uFF08\u62A5\u544A\u7248\u672C ${report.catalogRevision}\uFF09`}\uFF1B${unverifiable}`
|
|
15972
|
+
})).filter((r) => r.layer === layer2));
|
|
15973
|
+
}
|
|
15322
15974
|
for (const [layer2, notes] of marks) {
|
|
15323
15975
|
env2.report.server.verdict = null;
|
|
15324
15976
|
const observation = unknown("REPORT_MALFORMED", "\u670D\u52A1\u7AEF\u4F53\u68C0\u62A5\u544A\u5BF9\u8D26\u4E0D\u7B26\uFF08CLI \u6807\u8BB0\uFF09", { reason: "EVALUATOR_ERROR", note: notes.join("\uFF1B") });
|
|
@@ -15387,8 +16039,13 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
|
|
|
15387
16039
|
scope: { ...requested, policyDisabled: details.policyDisabled },
|
|
15388
16040
|
recoveryCommand: typeof error.next_step === "string" ? error.next_step : void 0
|
|
15389
16041
|
};
|
|
15390
|
-
env2.report.server
|
|
15391
|
-
|
|
16042
|
+
Object.assign(env2.report.server, {
|
|
16043
|
+
verdict: null,
|
|
16044
|
+
degraded: true,
|
|
16045
|
+
reason: "POLICY_DISABLED_400",
|
|
16046
|
+
note: `\u670D\u52A1\u7AEF\u56DE 400\uFF1A\u6240\u9009\u670D\u52A1\u7AEF\u68C0\u67E5\u5168\u90E8\u88AB\u79DF\u6237\u7B56\u7565\u5173\u95ED\uFF0C\u6CA1\u6709\u8FD4\u56DE\u62A5\u544A\u672C\u8EAB\uFF1B\u670D\u52A1\u7AEF\u4E00\u4FA7\u6309 CLI \u4F9D 400 \u7684 details \u62FC\u7684\u7A7A\u62A5\u544A\u8BA1\uFF080 \u9879\uFF09\uFF0C${env2.catalog?.catalogRevision ? `\u76EE\u5F55\u7248\u672C\u53D6\u81EA /checks\uFF08${env2.catalog.catalogRevision}\uFF09` : "\u76EE\u5F55\u7248\u672C\u672A\u77E5\uFF08/checks \u6CA1\u7ED9\uFF09\uFF0CpolicyDisabled \u6CA1\u80FD\u5BF9\u76EE\u5F55\u6838\u5BF9"}`
|
|
16047
|
+
});
|
|
16048
|
+
return reconcileReport(ctx, env2, env2.serverReport, requested);
|
|
15392
16049
|
}
|
|
15393
16050
|
const failure2 = failedReport(out, env2, ctx.as);
|
|
15394
16051
|
if (failure2) return placeholderRows(ctx, env2, failure2, Date.now() - started);
|
|
@@ -15401,12 +16058,23 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
|
|
|
15401
16058
|
catalogRevision: report.catalogRevision ?? null
|
|
15402
16059
|
});
|
|
15403
16060
|
if (catalogChanged(env2.catalog, report)) {
|
|
16061
|
+
const before = env2.catalog?.catalogRevision;
|
|
16062
|
+
let why, reason = "CATALOG_REFETCH_FAILED";
|
|
15404
16063
|
try {
|
|
15405
16064
|
const refreshed = await ctx.services.probe(env2.config.endpoint, env2.token, controller.signal).get("/api/system/health/checks");
|
|
15406
16065
|
const catalog = refreshed.status === 200 ? parseCatalog(refreshed.body) : void 0;
|
|
15407
16066
|
if (catalog && catalog.catalogRevision === report.catalogRevision) env2.catalog = catalog;
|
|
15408
|
-
|
|
16067
|
+
const unversioned = !!catalog && (catalog.catalogRevision === null || catalog.catalogRevision === void 0);
|
|
16068
|
+
if (catalog && !unversioned) reason = "CATALOG_STILL_CHANGING";
|
|
16069
|
+
why = unversioned ? "\u91CD\u53D6\u7684\u76EE\u5F55\u6CA1\u7ED9\u7248\u672C\uFF08\u79DF\u6237\u68C0\u67E5\u5B9A\u4E49\u53EF\u80FD\u8BFB\u4E0D\u5230\uFF09\uFF0C\u6838\u4E0D\u4E86" : catalog ? catalog.catalogRevision === report.catalogRevision ? "" : `\u91CD\u53D6\u540E\u76EE\u5F55\u7248\u672C\u662F ${catalog.catalogRevision}\uFF0C\u4ECD\u4E0E\u62A5\u544A\u4E0D\u540C\uFF08\u76EE\u5F55\u5728\u6301\u7EED\u53D8\u5316\uFF09` : `\u91CD\u53D6 /checks \u6CA1\u6210\uFF1A${refreshed.status === -1 ? `\u7F51\u7EDC\u6CA1\u8D70\u901A\uFF08${refreshed.detail || refreshed.error || "network"}\uFF09` : `HTTP ${refreshed.status}`}${refreshed.status === 200 ? "\uFF0C\u76EE\u5F55\u5F62\u72B6\u4E0D\u5408\u6CD5" : ""}`;
|
|
16070
|
+
} catch (error2) {
|
|
16071
|
+
why = `\u91CD\u53D6 /checks \u6CA1\u6210\uFF1A${safeError(error2)}`;
|
|
15409
16072
|
}
|
|
16073
|
+
if (why) Object.assign(env2.report.server, {
|
|
16074
|
+
degraded: true,
|
|
16075
|
+
reason,
|
|
16076
|
+
note: `\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316\uFF08/checks \u7248\u672C ${before}\uFF0C\u62A5\u544A\u7248\u672C ${report.catalogRevision}\uFF09\uFF1B${why}`
|
|
16077
|
+
});
|
|
15410
16078
|
}
|
|
15411
16079
|
return reconcileReport(ctx, env2, report, requested);
|
|
15412
16080
|
} catch (error) {
|
|
@@ -15472,8 +16140,8 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15472
16140
|
if (execution.signal.aborted) await e.close?.();
|
|
15473
16141
|
return observation;
|
|
15474
16142
|
} catch (error) {
|
|
15475
|
-
const detail = error instanceof
|
|
15476
|
-
const errorCode = error instanceof
|
|
16143
|
+
const detail = error instanceof CliError34 ? error.context : void 0;
|
|
16144
|
+
const errorCode = error instanceof CliError34 ? error.code : void 0;
|
|
15477
16145
|
const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
|
|
15478
16146
|
if (actorStep) {
|
|
15479
16147
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
@@ -15596,6 +16264,7 @@ var CODE_TABLE = {
|
|
|
15596
16264
|
CREDENTIAL_MISSING: c("\u6CA1\u6709\u5339\u914D endpoint \u4E0E\u79DF\u6237\u7684\u672C\u673A\u51ED\u636E\u69FD", "CRITICAL", "FDE", login),
|
|
15597
16265
|
CLI_OUTDATED: c("CLI \u843D\u540E\u4E8E npm \u6700\u65B0\u7248", "WARN", "FDE", () => "hcm upgrade"),
|
|
15598
16266
|
CLI_LATEST_UNKNOWN: c("\u53D6\u4E0D\u5230 npm \u6700\u65B0\u7248\u672C\uFF1B\u68C0\u67E5 registry \u7F51\u7EDC\u540E\u91CD\u8BD5"),
|
|
16267
|
+
CLI_VERSION_UNPARSEABLE: c("\u7248\u672C\u53F7\u4E0D\u662F X.Y.Z\uFF0C\u6BD4\u4E0D\u4E86\u65B0\u65E7\uFF1B\u5BF9\u7167 hcm --version \u4E0E npm view @hcmai/cli version --registry https://registry.npmjs.org \u7684\u539F\u6837\u8F93\u51FA\uFF0C\u91CD\u88C5\u672C\u673A CLI \u6216\u62A5\u7ED9 CLI \u7EF4\u62A4\u65B9\u540E\u91CD\u67E5"),
|
|
15599
16268
|
SKILLS_STATE_UNREADABLE: c("\u6280\u80FD\u9501\u6587\u4EF6\u65E0\u6CD5\u8BFB\u53D6\uFF1B\u4FEE\u590D\u6587\u4EF6\u540E\u540C\u6B65\u91CD\u67E5", "WARN", "FDE", both),
|
|
15600
16269
|
SKILLS_EMPTY: c("\u4E24\u79CD\u5E03\u5C40\u4E0B\u6280\u80FD\u5747\u4E3A\u7A7A", "CRITICAL", "FDE", both),
|
|
15601
16270
|
SKILLS_LEGACY_LAYOUT: c("\u4EC5\u6709\u65E7\u6241\u5E73\u5E03\u5C40\u7684\u6280\u80FD", "WARN", "FDE", (e) => sync(e, "codex")),
|
|
@@ -15604,6 +16273,10 @@ var CODE_TABLE = {
|
|
|
15604
16273
|
SKILLS_LOCALLY_MODIFIED: c("\u4EA7\u54C1\u6280\u80FD\u6709\u672C\u5730\u6539\u52A8\uFF1B\u5148\u9009\u62E9\u4FDD\u7559\u6216\u653E\u5F03\u6539\u52A8"),
|
|
15605
16274
|
SKILLS_STALE: c("\u6280\u80FD\u526F\u672C\u4E0E\u5F53\u524D\u76EE\u5F55\u4E0D\u4E00\u81F4\uFF1B\u540C\u6B65\u540E\u91CD\u67E5", "WARN", "FDE", both),
|
|
15606
16275
|
SKILLS_CATALOG_UNCHECKED: c("\u6280\u80FD\u6765\u6E90\u672C\u8F6E\u672A\u6838\uFF1B\u6062\u590D\u76EE\u5F55\u8BBF\u95EE\u540E\u91CD\u67E5", "WARN", "FDE", both),
|
|
16276
|
+
// 不给 sync 命令:服务端目录修好之前跑 sync 只会再停一次;下一步是 note 里服务端给的那句
|
|
16277
|
+
SKILLS_CATALOG_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u6280\u80FD\u76EE\u5F55\u4E0D\u53EF\u7528\uFF08\u88C5\u8F7D\u5931\u8D25\u6216\u4E0D\u5B8C\u6574\uFF09\uFF0C\u4E0D\u662F\u672C\u673A\u6280\u80FD\u8981\u540C\u6B65\uFF1B\u6309 note \u5904\u7406\u540E\u91CD\u67E5"),
|
|
16278
|
+
SKILLS_LOCAL_SHADOW: c("hcm-skills/local/ \u906E\u853D\u4E86\u4EA7\u54C1\u6280\u80FD\uFF1B\u906E\u853D\u5408\u6CD5\uFF0C\u662F\u7ED5\u8FC7\u4EA7\u54C1\u7F3A\u53E3\u7684\u529E\u6CD5\u5C31\u63D0\u7F3A\u53E3", "WARN", "FDE", () => "hcm chiron gap submit --file <\u7F3A\u53E3.json>"),
|
|
16279
|
+
SKILLS_LOCAL_UNREADABLE: c("hcm-skills/local/ \u6216 sync/\uFF08\u6574\u4E2A\u76EE\u5F55\u6216\u5176\u4E2D\u4E00\u4EFD\uFF09\u8BFB\u4E0D\u4E86\uFF0C\u6CA1\u6CD5\u5224\u6709\u6CA1\u6709\u906E\u853D\u4EA7\u54C1\u6280\u80FD\uFF1B\u6309\u6458\u8981\u91CC\u7684\u4FEE\u6CD5\u4FEE\u597D\u540E\u91CD\u67E5"),
|
|
15607
16280
|
BOUNDARY_MISSING: c("\u7F3A\u5C11\u9879\u76EE\u8FB9\u754C\u5757\uFF1B\u7528 Claude Code \u65F6\u518D\u521B\u5EFA CLAUDE.md \u2192 AGENTS.md \u8F6F\u94FE", "WARN", "FDE", (e) => sync(e, "codex")),
|
|
15608
16281
|
BOUNDARY_FALLBACK: c("\u53EA\u6709 cli-fallback \u8FB9\u754C\u526F\u672C\uFF1B\u540E\u7AEF\u5347\u7EA7\u5230\u5E26 agentBoundary \u7684\u7248\u672C\u540E\u91CD\u8DD1\u540C\u6B65", "WARN", "RND", (e) => sync(e, "codex")),
|
|
15609
16282
|
METHOD_NOT_INSTALLED: c("\u65B9\u6CD5\u5305\u672A\u5B89\u88C5\uFF1B\u6709\u77E5\u8BC6\u7EC4\u7EC7\u6388\u6743\u65F6\u5B89\u88C5", "WARN", "FDE", () => "hcm chiron method install"),
|
|
@@ -15617,7 +16290,10 @@ var CODE_TABLE = {
|
|
|
15617
16290
|
JIRA_PROJECT_INVISIBLE: c("\u770B\u4E0D\u5230 Jira \u9879\u76EE\uFF1B\u8BF7 Jira \u7BA1\u7406\u5458\u6838\u5BF9\u9879\u76EE\u6743\u9650"),
|
|
15618
16291
|
JIRA_SERVER_ERROR: c("Jira \u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF1B\u68C0\u67E5 Jira \u670D\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"),
|
|
15619
16292
|
JIRA_UNREACHABLE: c("Jira \u8FDE\u4E0D\u4E0A\uFF1B\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8BD5"),
|
|
16293
|
+
JIRA_UNCLASSIFIED: c("Jira \u63A2\u6D3B\u5931\u8D25\uFF0C\u4F46\u5224\u522B\u4E0D\u4E86\u662F\u4EE4\u724C\u3001\u7F51\u7EDC\u8FD8\u662F\u670D\u52A1\u7AEF\u7684\u95EE\u9898\uFF1B\u6309 note \u91CC\u7684\u539F\u59CB\u539F\u56E0\u5904\u7406\u540E\u91CD\u8BD5"),
|
|
15620
16294
|
JIRA_TOKEN_UNREADABLE: c("Jira \u4EE4\u724C\u8BFB\u4E0D\u5230\uFF1B\u68C0\u67E5\u4EE4\u724C\u6765\u6E90\uFF0C\u6216\u6539\u7528 JIRA_TOKEN"),
|
|
16295
|
+
GAPS_VERIFY_PENDING: c("\u6709\u5DF2\u4FEE\u590D\u8D85\u8FC7 14 \u5929\u3001\u7B49\u4F60\u590D\u9A8C\u7684\u7F3A\u53E3\u5355\uFF1B\u590D\u9A8C\u540E\u7528 gap verify \u56DE\u5199", "WARN", "FDE", () => "hcm chiron gap status"),
|
|
16296
|
+
GAPS_VERIFY_UNKNOWN: c("\u67E5\u4E0D\u5230\u6216\u7B97\u4E0D\u51FA\u5F85\u590D\u9A8C\u7684\u7F3A\u53E3\u5355\uFF0C\u4E0D\u4EE3\u8868\u6CA1\u6709\uFF1B\u6309 note \u91CC\u7684\u539F\u56E0\u4FEE\u597D\u540E\u91CD\u67E5", "WARN", "FDE", () => "hcm chiron gap status"),
|
|
15621
16297
|
BACKEND_UNREACHABLE: c("\u540E\u7AEF\u4E0D\u53EF\u8FBE\uFF1B\u68C0\u67E5\u5730\u5740\u3001\u7F51\u7EDC\u4E0E\u4EE3\u7406", "CRITICAL"),
|
|
15622
16298
|
BACKEND_SERVER_ERROR: c("\u540E\u7AEF\u8FD4\u56DE\u670D\u52A1\u9519\u8BEF\uFF1B\u68C0\u67E5\u670D\u52A1\u65E5\u5FD7", "CRITICAL"),
|
|
15623
16299
|
BACKEND_NOT_JSON: c("\u4E0D\u662F\u540E\u7AEF JSON\uFF1B\u68C0\u67E5\u540E\u7AEF\u5730\u5740\u548C\u53CD\u4EE3", "CRITICAL"),
|
|
@@ -15647,6 +16323,7 @@ var CODE_TABLE = {
|
|
|
15647
16323
|
REPORT_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5"),
|
|
15648
16324
|
REPORT_MALFORMED: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u54CD\u5E94\u65E0\u6CD5\u89E3\u6790\uFF1B\u8054\u7CFB\u7814\u53D1\u6838\u5BF9\u534F\u8BAE", "WARN", "RND"),
|
|
15649
16325
|
REPORT_ITEM_MISSING: c("\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879", "WARN", "RND"),
|
|
16326
|
+
REPORT_CATALOG_CHANGED: c("\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D8\u5316\uFF0C\u670D\u52A1\u7AEF\u6709\u6CA1\u6709\u6F0F\u62A5\u6838\u4E0D\u51FA\u6765\uFF1B\u76EE\u5F55\u7A33\u5B9A\u540E\u91CD\u8DD1\u4E00\u6B21"),
|
|
15650
16327
|
SERVER_VERDICT_INVALID: c("\u670D\u52A1\u7AEF\u68C0\u67E5\u7ED3\u8BBA\u4E0D\u5408\u6CD5\uFF1B\u8054\u7CFB\u7814\u53D1\u6838\u5BF9\u534F\u8BAE", "WARN", "RND"),
|
|
15651
16328
|
BUDGET_EXHAUSTED: c("\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8\uFF1B\u7A0D\u540E\u91CD\u8DD1")
|
|
15652
16329
|
};
|
|
@@ -15656,13 +16333,14 @@ function codeStep(code2, env2) {
|
|
|
15656
16333
|
return { owner: row?.owner ?? "FDE", ...row?.command ? { command: row.command(env2) } : {} };
|
|
15657
16334
|
}
|
|
15658
16335
|
var allStages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16336
|
+
var NOT_AT_GOLIVE = /* @__PURE__ */ new Set(["local.cli.version", "local.skills.shadow"]);
|
|
15659
16337
|
function descriptor(id, name, dependsOn, codes, timeoutMs, run3, optional = false, owner = "FDE") {
|
|
15660
16338
|
return {
|
|
15661
16339
|
id,
|
|
15662
16340
|
name,
|
|
15663
16341
|
layer: id.startsWith("local.") ? "local" : "connect",
|
|
15664
16342
|
requirement: optional ? "OPTIONAL" : "REQUIRED",
|
|
15665
|
-
stages: id === "connect.exposure" ? ["golive", "operate"] : optional || id
|
|
16343
|
+
stages: id === "connect.exposure" ? ["golive", "operate"] : optional || NOT_AT_GOLIVE.has(id) ? allStages.filter((s) => s !== "golive") : allStages,
|
|
15666
16344
|
coverageForm: "SINGLE",
|
|
15667
16345
|
coverageDomain: "\u672C\u6B21\u68C0\u67E5\u7684\u4E00\u4E2A\u914D\u7F6E\u6216\u7AEF\u70B9\uFF0Cexpected=1\uFF1B\u72EC\u7ACB\u4E8E\u662F\u5426\u53D1\u73B0\u95EE\u9898",
|
|
15668
16346
|
owner,
|
|
@@ -15675,13 +16353,15 @@ function descriptor(id, name, dependsOn, codes, timeoutMs, run3, optional = fals
|
|
|
15675
16353
|
var CHECKS = [
|
|
15676
16354
|
descriptor("local.project.env", "\u9879\u76EE\u73AF\u5883", [], ["ENV_FILE_MISSING", "ENV_FILE_INVALID", "ENV_NOT_RESOLVED"], 5e3, localChecks.project),
|
|
15677
16355
|
descriptor("local.credential", "\u672C\u673A\u51ED\u636E\u69FD", ["local.project.env"], ["CREDENTIAL_MISSING"], 5e3, localChecks.credential),
|
|
15678
|
-
descriptor("local.cli.version", "CLI \u7248\u672C", [], ["CLI_OUTDATED", "CLI_LATEST_UNKNOWN"], 1e4, localChecks.version),
|
|
16356
|
+
descriptor("local.cli.version", "CLI \u7248\u672C", [], ["CLI_OUTDATED", "CLI_LATEST_UNKNOWN", "CLI_VERSION_UNPARSEABLE"], 1e4, localChecks.version),
|
|
15679
16357
|
descriptor("local.skills.installed", "\u6280\u80FD", ["local.project.env"], ["SKILLS_STATE_UNREADABLE", "SKILLS_EMPTY", "SKILLS_LEGACY_LAYOUT", "SKILLS_SPLIT_LAYOUT", "SKILLS_ENDPOINT_MISMATCH"], 5e3, localChecks.installed),
|
|
15680
|
-
descriptor("local.skills.fresh", "\u6280\u80FD\u65B0\u9C9C\u5EA6", ["local.skills.installed"], ["SKILLS_STALE", "SKILLS_LOCALLY_MODIFIED", "SKILLS_CATALOG_UNCHECKED"], 1e4, localChecks.fresh),
|
|
16358
|
+
descriptor("local.skills.fresh", "\u6280\u80FD\u65B0\u9C9C\u5EA6", ["local.skills.installed"], ["SKILLS_STALE", "SKILLS_LOCALLY_MODIFIED", "SKILLS_CATALOG_UNCHECKED", "SKILLS_CATALOG_UNAVAILABLE"], 1e4, localChecks.fresh),
|
|
16359
|
+
descriptor("local.skills.shadow", "\u672C\u5730\u906E\u853D", [], ["SKILLS_LOCAL_SHADOW", "SKILLS_LOCAL_UNREADABLE"], 5e3, localChecks.shadow),
|
|
15681
16360
|
descriptor("local.boundary", "\u9879\u76EE\u8FB9\u754C", [], ["BOUNDARY_MISSING", "BOUNDARY_FALLBACK"], 5e3, localChecks.boundary),
|
|
15682
16361
|
descriptor("local.method", "\u65B9\u6CD5\u5305", [], ["METHOD_NOT_INSTALLED", "METHOD_UNCHECKED", "METHOD_COPY_MISMATCH", "METHOD_OUTDATED"], 35e3, localChecks.method, true),
|
|
15683
16362
|
descriptor("local.cases", "\u6848\u4F8B\u5E93", [], ["CASES_REMOTE_UNREACHABLE", "CASES_UNREADABLE"], 2e4, localChecks.cases, true),
|
|
15684
|
-
descriptor("local.jira", "Jira", [], ["JIRA_NO_TOKEN", "JIRA_TOKEN_REJECTED", "JIRA_PROJECT_INVISIBLE", "JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE"], 25e3, localChecks.jira, true),
|
|
16363
|
+
descriptor("local.jira", "Jira", [], ["JIRA_NO_TOKEN", "JIRA_TOKEN_REJECTED", "JIRA_PROJECT_INVISIBLE", "JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE", "JIRA_UNCLASSIFIED"], 25e3, localChecks.jira, true),
|
|
16364
|
+
descriptor("local.gaps.verify", "\u5F85\u590D\u9A8C\u7F3A\u53E3", ["local.jira"], ["GAPS_VERIFY_PENDING", "GAPS_VERIFY_UNKNOWN"], 3e4, localChecks.pendingVerify, true),
|
|
15685
16365
|
descriptor("connect.connectivity", "\u540E\u7AEF\u8FDE\u901A", [], ["BACKEND_UNREACHABLE", "BACKEND_SERVER_ERROR", "BACKEND_NOT_JSON", "BACKEND_NOT_FOUND", "BACKEND_REJECTED", "BACKEND_BAD_RESPONSE"], 1e4, connectChecks.connectivity),
|
|
15686
16366
|
descriptor("connect.identity", "\u8EAB\u4EFD", ["connect.connectivity"], ["IDENTITY_META_INVALID", "IDENTITY_USER_MISMATCH", "TOKEN_REJECTED", "TENANT_MISMATCH", "IDENTITY_NOT_LOGGED_IN", "IDENTITY_UNVERIFIED", "AS_PROXY_DENIED"], 1e4, connectChecks.identity),
|
|
15687
16367
|
descriptor("connect.config-admin", "\u914D\u7F6E\u7BA1\u7406\u5458", ["connect.connectivity", "connect.identity"], ["CONFIG_ADMIN_DENIED", "CONFIG_ADMIN_UNVERIFIED"], 1e4, connectChecks.configAdmin, false, "CUSTOMER_ADMIN"),
|
|
@@ -15705,6 +16385,7 @@ var SERVER_PLACEHOLDERS = ["platform", "tenant"].map((layer2) => ({
|
|
|
15705
16385
|
"REPORT_UNAVAILABLE",
|
|
15706
16386
|
"REPORT_MALFORMED",
|
|
15707
16387
|
"REPORT_ITEM_MISSING",
|
|
16388
|
+
"REPORT_CATALOG_CHANGED",
|
|
15708
16389
|
"SERVER_VERDICT_INVALID",
|
|
15709
16390
|
"BUDGET_EXHAUSTED"
|
|
15710
16391
|
]
|
|
@@ -15968,6 +16649,26 @@ function renderPolicyDisabled(rows2, catalog, recoveryCommand, rerun) {
|
|
|
15968
16649
|
indented(recovery(row, rows2, catalog, recoveryCommand, rerun))
|
|
15969
16650
|
])].join("\n");
|
|
15970
16651
|
}
|
|
16652
|
+
function nextStepLine(step2, rerun) {
|
|
16653
|
+
const what = step2.command ?? (step2.skill ? `\u6309\u6280\u80FD ${step2.skill} \u5904\u7406\u540E\u91CD\u8DD1 ${rerun}` : `\u6309\u672C\u9879\u8BF4\u660E\u5904\u7406\u540E\u91CD\u8DD1 ${rerun}`);
|
|
16654
|
+
return `\u2192 ${what}${step2.command && step2.skill ? ` \xB7 \u6280\u80FD ${step2.skill}` : ""} [${step2.owner}]`;
|
|
16655
|
+
}
|
|
16656
|
+
var TOKEN_TEXT = {
|
|
16657
|
+
"server-catalog-unknown": "\u670D\u52A1\u7AEF\u68C0\u67E5\u76EE\u5F55\u672A\u77E5",
|
|
16658
|
+
"platform-ops-only": "\u5171\u4EAB\u90E8\u7F72\u4E0A\u5E73\u53F0\u5C42\u53EA\u5BF9\u5E73\u53F0\u8FD0\u7EF4\u53EF\u89C1",
|
|
16659
|
+
"platform-ops-view": "\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42",
|
|
16660
|
+
"tenant-definitions-unavailable": "\u79DF\u6237\u5C42\u68C0\u67E5\u5B9A\u4E49\u8BFB\u4E0D\u5230",
|
|
16661
|
+
"catalog-changed": "\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316",
|
|
16662
|
+
"no-environment": "\u76EE\u6807\u73AF\u5883\u672A\u89E3\u6790"
|
|
16663
|
+
};
|
|
16664
|
+
function scopeLine(report) {
|
|
16665
|
+
const s = report.scope;
|
|
16666
|
+
const parts = s.incompleteBecause.map((t) => t === "only" ? `\u53EA\u67E5\u4E86 --only ${s.only.join(",")}` : t.startsWith("skip:") ? `\u8DF3\u8FC7\u4E86 ${t.slice("skip:".length)}` : t.startsWith("opt-in:") ? `${t.slice("opt-in:".length)} \u8981\u52A0 --active \u624D\u8DD1` : t === "empty-layer:connect" ? "connect \u5C42\u6CA1\u6709\u53EF\u8FDE\u7684\u73AF\u5883\uFF0C\u4E00\u9879\u90FD\u6CA1\u6267\u884C" : t.startsWith("empty-layer:") ? `${t.slice("empty-layer:".length)} \u5C42\u6CA1\u6709\u68C0\u67E5` : TOKEN_TEXT[t] ?? t);
|
|
16667
|
+
const ran = new Set(report.results.filter((r) => (r.env === null || r.env === report.targetEnv) && r.verdict.level !== "NOT_RUN").map((r) => r.checkId));
|
|
16668
|
+
const done = s.addedPrerequisites.filter((id) => ran.has(id)), idle = s.addedPrerequisites.filter((id) => !ran.has(id));
|
|
16669
|
+
const added = (done.length ? `\uFF1B\u4E3A\u6EE1\u8DB3\u524D\u7F6E\u8865\u67E5\u4E86 ${done.join("\u3001")}` : "") + (idle.length ? `\uFF1B\u4E3A\u6EE1\u8DB3\u524D\u7F6E\u8865\u8FDB\u8303\u56F4\u7684 ${idle.join("\u3001")} \u6CA1\u6709\u6267\u884C` : "");
|
|
16670
|
+
return s.complete ? `\u8303\u56F4\uFF1A\u5B8C\u6574\uFF08complete=true\uFF09${added}` : `\u8303\u56F4\uFF1A\u4E0D\u5B8C\u6574\uFF08complete=false\uFF09\u2014\u2014${parts.join("\uFF1B")}${added}`;
|
|
16671
|
+
}
|
|
15971
16672
|
function renderChironDoctor(report) {
|
|
15972
16673
|
const target = report.environments.find((env2) => env2.target);
|
|
15973
16674
|
const version2 = target?.backend.version;
|
|
@@ -16017,7 +16718,7 @@ function renderChironDoctor(report) {
|
|
|
16017
16718
|
out.push(indented(`${matching.map((r) => r.name).join("\u3001")}\uFF1A${outside ? "\u524D\u7F6E\u9879\u4E0D\u5728\u672C\u6B21\u8303\u56F4\u5185" : "\u524D\u7F6E\u672A\u901A\u8FC7"}\uFF08${v.note}\uFF09`, " \xB7 "));
|
|
16018
16719
|
if (outside) {
|
|
16019
16720
|
for (const item of matching) if (item.nextStep?.command)
|
|
16020
|
-
out.push(indented(
|
|
16721
|
+
out.push(indented(nextStepLine(item.nextStep, rerun)));
|
|
16021
16722
|
}
|
|
16022
16723
|
continue;
|
|
16023
16724
|
}
|
|
@@ -16027,18 +16728,20 @@ function renderChironDoctor(report) {
|
|
|
16027
16728
|
out.push(` ${mark} ${row.name}${row.requirement === "OPTIONAL" ? "\uFF08\u9009\u68C0\uFF09" : ""}${row.layer === "local" && row.env ? ` \xB7 ${row.env}` : ""} ${String(row.summary).replace(/\r?\n/g, "\n ")}`);
|
|
16028
16729
|
}
|
|
16029
16730
|
if (v?.note) out.push(indented(v.note));
|
|
16030
|
-
if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command)) out.push(indented(
|
|
16731
|
+
if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command || row.nextStep.skill)) out.push(indented(nextStepLine(row.nextStep, rerun)));
|
|
16031
16732
|
}
|
|
16032
16733
|
}
|
|
16033
16734
|
const active = report.results.filter(isOptIn).length;
|
|
16034
16735
|
const coverage = (report.coverage.total === null ? `${report.coverage.checked}/?\uFF08\u670D\u52A1\u7AEF\u68C0\u67E5\u6570\u672A\u77E5\uFF09` : `${report.coverage.checked}/${report.coverage.total}`) + (active ? `\uFF08${active} \u9879\u9700 --active\uFF09` : "");
|
|
16035
16736
|
out.push("", `\u7ED3\u8BBA\uFF1A${report.verdict.replaceAll("_", " ")} \xB7 ${report.foundByGrade.CRITICAL} \u963B\u65AD \xB7 ${report.foundByGrade.WARN} \u98CE\u9669 \xB7 ${report.counts.UNDETERMINED + report.counts.NOT_RUN - active} \u672A\u5224 \xB7 \u5DF2\u6838 ${coverage}`);
|
|
16737
|
+
out.push(scopeLine(report));
|
|
16036
16738
|
if (report.scope.incompleteBecause.includes("no-environment")) out.push("\u76EE\u6807\u73AF\u5883\u672A\u89E3\u6790\uFF1A\u4F9D\u8D56\u73AF\u5883\u7684\u68C0\u67E5\u6CA1\u6709\u6267\u884C\uFF08no-environment\uFF09\uFF1B\u8BF7\u6309 stderr \u7684\u4E0B\u4E00\u6B65\u4FEE\u590D\u73AF\u5883\u58F0\u660E");
|
|
16037
16739
|
const policyCatalog = reportCatalogs.get(report), disabled = report.scope.policyDisabled;
|
|
16038
16740
|
if (disabled.length) out.push(`\u9009\u68C0\u672A\u542F\u7528\uFF1A${disabled.map((r) => policyDescription(r, policyCatalog)).join("\uFF1B")}`);
|
|
16039
16741
|
for (const row of disabled.filter((r) => report.scope.only.includes(r.id)))
|
|
16040
16742
|
out.push(`\u8BE5\u9879\u5DF2\u6309\u79DF\u6237\u7B56\u7565\u5173\u95ED\uFF1A${policyCatalog?.checks.find((c2) => c2.id === row.id)?.name ?? row.id}\uFF1B${recovery(row, disabled, policyCatalog, reportRecoveryCommands.get(report), rerun)}`);
|
|
16041
16743
|
if (report.scope.incompleteBecause.includes("catalog-changed")) out.push("\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316\uFF0C\u7A0D\u540E\u91CD\u8DD1");
|
|
16744
|
+
if (!platformOps && target?.server.note) out.push(`\u670D\u52A1\u7AEF\uFF1A${target.server.degraded ? `[degraded \xB7 ${target.server.reason}] ` : ""}${target.server.note}`);
|
|
16042
16745
|
const actions = firstActions(report.results);
|
|
16043
16746
|
if (actions.length) out.push(`\u5148\u5904\u7406\uFF1A${actions.map((r) => `${r.checkId}${r.env ? `\uFF08${r.env}\uFF09` : ""}`).join("\u3001")}`);
|
|
16044
16747
|
if (platformOps) {
|
|
@@ -16054,8 +16757,8 @@ import { createHash as createHash8 } from "crypto";
|
|
|
16054
16757
|
import axios9 from "axios";
|
|
16055
16758
|
import {
|
|
16056
16759
|
classifyStatus as classifyStatus2,
|
|
16057
|
-
CliError as
|
|
16058
|
-
CliErrorCode as
|
|
16760
|
+
CliError as CliError35,
|
|
16761
|
+
CliErrorCode as CliErrorCode36,
|
|
16059
16762
|
loadGlobalConfig as loadGlobalConfig11,
|
|
16060
16763
|
printResolvedEnvironment as printResolvedEnvironment8,
|
|
16061
16764
|
resolveEnvContext as resolveEnvContext8
|
|
@@ -16163,11 +16866,11 @@ async function readPlatformOpsKey(args, io = {
|
|
|
16163
16866
|
} else if (io.isTTY) {
|
|
16164
16867
|
source = "tty";
|
|
16165
16868
|
key2 = await io.prompt();
|
|
16166
|
-
} else throw new
|
|
16869
|
+
} else throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: blank ? "HCM_PLATFORM_OPS_KEY \u5DF2\u8BBE\u7F6E\u4F46\u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1A\u628A\u5BC6\u94A5\u5199\u8FDB\u8BE5\u53D8\u91CF\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" : "\u7F3A\u5C11\u8FD0\u7EF4\u5BC6\u94A5\uFF1A\u8BBE\u7F6E HCM_PLATFORM_OPS_KEY\u3001\u4F7F\u7528 --platform-ops-key-stdin\uFF0C\u6216\u5728 TTY \u4EA4\u4E92\u8F93\u5165" });
|
|
16167
16870
|
if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
|
|
16168
16871
|
`);
|
|
16169
16872
|
key2 = key2.trim();
|
|
16170
|
-
if (!key2) throw new
|
|
16873
|
+
if (!key2) throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
|
|
16171
16874
|
io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
|
|
16172
16875
|
`);
|
|
16173
16876
|
return { key: key2, source };
|
|
@@ -16176,12 +16879,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
|
|
|
16176
16879
|
function scopeFor(args) {
|
|
16177
16880
|
const only = split(args.only), skip = split(args.skip);
|
|
16178
16881
|
for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
|
|
16179
|
-
throw new
|
|
16180
|
-
code:
|
|
16882
|
+
throw new CliError35({
|
|
16883
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16181
16884
|
message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
|
|
16182
16885
|
});
|
|
16183
|
-
if (skip.some((token) => "platform.".startsWith(token))) throw new
|
|
16184
|
-
code:
|
|
16886
|
+
if (skip.some((token) => "platform.".startsWith(token))) throw new CliError35({
|
|
16887
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16185
16888
|
message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
|
|
16186
16889
|
});
|
|
16187
16890
|
return {
|
|
@@ -16337,7 +17040,7 @@ function failure(ctx, env2, health, key2) {
|
|
|
16337
17040
|
}
|
|
16338
17041
|
var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
|
|
16339
17042
|
function resolverMessage(error) {
|
|
16340
|
-
if (error instanceof
|
|
17043
|
+
if (error instanceof CliError35 && error.code === CliErrorCode36.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
|
|
16341
17044
|
return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
|
|
16342
17045
|
}
|
|
16343
17046
|
async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
|
|
@@ -16346,10 +17049,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16346
17049
|
try {
|
|
16347
17050
|
resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
|
|
16348
17051
|
} catch (error2) {
|
|
16349
|
-
throw new
|
|
17052
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
|
|
16350
17053
|
}
|
|
16351
|
-
if (!resolved.config.endpoint) throw new
|
|
16352
|
-
code:
|
|
17054
|
+
if (!resolved.config.endpoint) throw new CliError35({
|
|
17055
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16353
17056
|
message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
|
|
16354
17057
|
});
|
|
16355
17058
|
printResolvedEnvironment8(resolved);
|
|
@@ -16395,8 +17098,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16395
17098
|
const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
16396
17099
|
if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
|
|
16397
17100
|
const trace = out.headers["x-trace-id"];
|
|
16398
|
-
throw new
|
|
16399
|
-
code:
|
|
17101
|
+
throw new CliError35({
|
|
17102
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16400
17103
|
message: `${typeof error.message === "string" ? redact(error.message, key2) : "\u8FD0\u7EF4\u68C0\u67E5\u8303\u56F4\u65E0\u6548"}${scope.only.length || scope.skip.length ? "\uFF1B\u53BB\u6389 --only / --skip \u91CD\u8DD1 hcm chiron doctor --platform-ops \u53EF\u770B\u5230\u5168\u90E8\u5E73\u53F0\u68C0\u67E5" : `\uFF1B\u672C\u6B21\u6CA1\u6709\u5E26 --only / --skip\uFF0C\u53C2\u6570\u4ECD\u88AB\u5224\u65E0\u6548\uFF0C\u5C5E\u670D\u52A1\u7AEF\u7F3A\u9677\uFF1A\u9644 traceId ${trace || "\uFF08\u54CD\u5E94\u672A\u5E26\uFF0C\u9644\u672C\u6B21\u65F6\u95F4\u4E0E\u73AF\u5883\u540D\uFF09"} \u8054\u7CFB\u7814\u53D1`}`
|
|
16401
17104
|
});
|
|
16402
17105
|
}
|
|
@@ -16450,10 +17153,12 @@ var localCriterion = {
|
|
|
16450
17153
|
"local.cli.version": "\u4E0E npm \u6700\u65B0 CLI \u7248\u672C\u6BD4\u8F83",
|
|
16451
17154
|
"local.skills.installed": "\u4E24\u79CD\u5E03\u5C40\u7684\u6280\u80FD\u5E76\u96C6\u3001\u9501\u6587\u4EF6\u4E0E\u76EE\u6807\u73AF\u5883\u4E00\u81F4",
|
|
16452
17155
|
"local.skills.fresh": "\u672C\u673A\u6280\u80FD\u4E0E\u76EE\u6807\u73AF\u5883\u7684\u4EA7\u54C1\u6280\u80FD\u76EE\u5F55\u5BF9\u8D26",
|
|
17156
|
+
"local.skills.shadow": "hcm-skills/local/ \u91CC\u4E0E hcm-skills/sync/ \u540C id \u7684\u6280\u80FD\uFF08\u540C\u540D\u65F6\u751F\u6548\u7684\u662F local/\uFF0C\u4EA7\u54C1\u7248\u88AB\u538B\u4F4F\uFF09\uFF1B\u6709\u5C31 WARN \u5E76\u5217\u51FA id \u4E0E local \u90A3\u4EFD\u7684\u9996\u884C\u8BF4\u660E\u3002local/ \u8BFB\u4E0D\u4E86\u3001\u6216 sync/ \u91CC\u4E0E local/ \u540C id \u7684\u90A3\u4EFD\u8BFB\u4E0D\u4E86\uFF0C\u5224 UNDETERMINED\uFF1Bsync/ \u91CC\u4E0E local/ \u65E0\u5173\u7684\u6761\u76EE\u8BFB\u4E0D\u4E86\u4E0D\u6321\u7ED3\u8BBA\uFF0C\u6458\u8981\u5217\u51FA\u3001note \u5E26\u539F\u59CB\u62A5\u9519\uFF1Bsync/ \u8BFB\u5F97\u4E86\u7684\u4E00\u4EFD\u90FD\u6CA1\u6709\u53C8\u6709\u8BFB\u4E0D\u4E86\u7684\uFF0C\u5224 UNDETERMINED",
|
|
16453
17157
|
"local.boundary": "\u9879\u76EE\u8FB9\u754C\u5757\u5B58\u5728\uFF0C\u4E14\u4E0D\u662F CLI fallback \u526F\u672C",
|
|
16454
17158
|
"local.method": "\u5B9E\u65BD\u65B9\u6CD5\u5305\u5DF2\u5B89\u88C5\u3001\u7248\u672C\u4E0E\u672C\u673A\u526F\u672C\u4E00\u81F4",
|
|
16455
17159
|
"local.cases": "\u6848\u4F8B\u5E93\u7D22\u5F15\u53EF\u8BFB\u53D6\uFF0C\u8FDC\u7AEF\u4E0E\u7F13\u5B58\u6765\u6E90\u53EF\u8FA8",
|
|
16456
17160
|
"local.jira": "Jira \u4EE4\u724C\u3001\u672C\u4EBA\u8EAB\u4EFD\u53CA\u9879\u76EE\u53EF\u89C1\u6027\u9010\u9879\u6838\u9A8C",
|
|
17161
|
+
"local.gaps.verify": "\u6211\u63D0\u7684\u7F3A\u53E3\u5355\u91CC\uFF0C\u6700\u540E\u4E00\u6B21\u8FDB\u5165\u300C\u5DF2\u4FEE\u590D\u300D\u8D85\u8FC7 14 \u5929\u8FD8\u6CA1\u590D\u9A8C\u7684\u5F20\u6570\uFF08\u8D77\u7B97\u70B9\u53D6 changelog\uFF09",
|
|
16457
17162
|
"connect.connectivity": "\u514D\u8BA4\u8BC1\u8BFB\u53D6\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\uFF0C\u786E\u8BA4\u540E\u7AEF\u53EF\u8FBE",
|
|
16458
17163
|
"connect.identity": "\u670D\u52A1\u7AEF\u786E\u8BA4 token \u4E3B\u4F53\u53CA\u79DF\u6237\u4E0E\u9879\u76EE\u58F0\u660E\u4E00\u81F4",
|
|
16459
17164
|
"connect.config-admin": "\u79DF\u6237 meta \u6E05\u5355\u53EF\u8BFB\uFF0C\u96F6\u6761\u4E5F\u6709\u6548",
|
|
@@ -16686,6 +17391,8 @@ var defaultServices = {
|
|
|
16686
17391
|
inspectJira,
|
|
16687
17392
|
inspectMethod: inspectMethodForDoctor,
|
|
16688
17393
|
latestVersion: fetchLatestVersion,
|
|
17394
|
+
// 单次请求 8 秒(与 local.jira 一致):这一项总时限 30 秒,单次用默认的 30 秒卡一次就用完了
|
|
17395
|
+
pendingVerify: async (signal) => gapPendingVerify({ client: await createJiraClient2({ timeoutMs: 8e3 }) }, { signal }),
|
|
16689
17396
|
skillsFresh: inspectSkillsFresh,
|
|
16690
17397
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
16691
17398
|
probe: (endpoint, token, signal) => httpProbe2(axios10.create({
|
|
@@ -16699,13 +17406,13 @@ var defaultServices = {
|
|
|
16699
17406
|
};
|
|
16700
17407
|
function validate(args) {
|
|
16701
17408
|
for (const [key2, value, choices] of [["output", args.output, ["table", "json", "yaml"]], ["fail-on", args.failOn, ["blocked", "risks"]]])
|
|
16702
|
-
if (value !== void 0 && !choices.includes(value)) throw new
|
|
16703
|
-
code:
|
|
17409
|
+
if (value !== void 0 && !choices.includes(value)) throw new CliError36({
|
|
17410
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
16704
17411
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
16705
17412
|
});
|
|
16706
17413
|
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16707
|
-
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new
|
|
16708
|
-
code:
|
|
17414
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError36({
|
|
17415
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
16709
17416
|
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
16710
17417
|
});
|
|
16711
17418
|
if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
|
|
@@ -16726,7 +17433,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
|
|
|
16726
17433
|
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
16727
17434
|
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
16728
17435
|
function invalidScope(message) {
|
|
16729
|
-
throw new
|
|
17436
|
+
throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message });
|
|
16730
17437
|
}
|
|
16731
17438
|
function scopeFor2(args, catalog) {
|
|
16732
17439
|
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
@@ -16761,7 +17468,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
16761
17468
|
try {
|
|
16762
17469
|
resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16763
17470
|
} catch (error) {
|
|
16764
|
-
if (error instanceof
|
|
17471
|
+
if (error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND) return { resolved: null };
|
|
16765
17472
|
throw error;
|
|
16766
17473
|
}
|
|
16767
17474
|
if (as) return { resolved };
|
|
@@ -16770,14 +17477,14 @@ async function readCredential(envFlag, root, as) {
|
|
|
16770
17477
|
try {
|
|
16771
17478
|
identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
|
|
16772
17479
|
} catch (error) {
|
|
16773
|
-
if (error instanceof
|
|
17480
|
+
if (error instanceof CliError36 && error.code === CliErrorCode37.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
|
|
16774
17481
|
throw error;
|
|
16775
17482
|
}
|
|
16776
17483
|
let meta2;
|
|
16777
17484
|
try {
|
|
16778
17485
|
meta2 = await loadIdentity5(identity3);
|
|
16779
17486
|
} catch (error) {
|
|
16780
|
-
if (error instanceof
|
|
17487
|
+
if (error instanceof CliError36 && error.code === CliErrorCode37.IDENTITY_NOT_FOUND) return { resolved, identity: identity3, error: found("IDENTITY_META_INVALID", `\u8EAB\u4EFD ${identity3} \u7684\u5143\u6570\u636E\u4E0D\u5B58\u5728\uFF1B\u91CD\u65B0\u767B\u5F55\u4FEE\u590D`) };
|
|
16781
17488
|
throw error;
|
|
16782
17489
|
}
|
|
16783
17490
|
if (!meta2.env || meta2.env !== resolved.name) return {
|
|
@@ -16819,7 +17526,7 @@ async function prepareContext(args, deps) {
|
|
|
16819
17526
|
const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
|
|
16820
17527
|
projectObservation = found("ENV_NOT_RESOLVED", detail);
|
|
16821
17528
|
targetEnv = null;
|
|
16822
|
-
const slotMissing = error instanceof
|
|
17529
|
+
const slotMissing = error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND;
|
|
16823
17530
|
const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
|
|
16824
17531
|
const step2 = file ? `hcm chiron env add ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --frontend <\u524D\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : slotMissing ? `hcm chiron init --env ${quote(args.env)} --endpoint <\u540E\u7AEF\u5730\u5740> --tenant <\u79DF\u6237\u53F7>${project2}` : `hcm chiron init --env ${quote(args.env)}${project2}`;
|
|
16825
17532
|
if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
|
|
@@ -17030,11 +17737,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
|
17030
17737
|
import fs14 from "fs/promises";
|
|
17031
17738
|
import os6 from "os";
|
|
17032
17739
|
import path17 from "path";
|
|
17033
|
-
import { CliError as
|
|
17740
|
+
import { CliError as CliError39, CliErrorCode as CliErrorCode40, formatObject as formatObject31, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
17034
17741
|
import { createRequire } from "module";
|
|
17035
17742
|
|
|
17036
17743
|
// src/commands/chiron-page-cdp.ts
|
|
17037
|
-
import { CliError as
|
|
17744
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode38 } from "@hcmai/sdk";
|
|
17038
17745
|
|
|
17039
17746
|
// src/commands/chiron-page-shared.ts
|
|
17040
17747
|
function redactTicket(text) {
|
|
@@ -17070,14 +17777,14 @@ function normalizeCdpEndpoint(raw) {
|
|
|
17070
17777
|
try {
|
|
17071
17778
|
url = new URL(candidate);
|
|
17072
17779
|
} catch {
|
|
17073
|
-
throw new
|
|
17780
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--cdp \u8981\u5199\u6210 http://\u4E3B\u673A:\u7AEF\u53E3\uFF08Chrome \u7684 --remote-debugging-port\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
17074
17781
|
}
|
|
17075
17782
|
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
17076
17783
|
if (protocol !== "http:" && protocol !== "https:") {
|
|
17077
|
-
throw new
|
|
17784
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--cdp \u53EA\u8BA4 http(s) \u6216 ws(s) \u7AEF\u70B9\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
17078
17785
|
}
|
|
17079
17786
|
if (!url.port) {
|
|
17080
|
-
throw new
|
|
17787
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--cdp \u8981\u5E26\u7AEF\u53E3\uFF08Chrome \u542F\u52A8\u65F6 --remote-debugging-port=<\u7AEF\u53E3> \u7684\u90A3\u4E2A\uFF09\uFF0C\u6536\u5230\u7684\u662F ${text}` });
|
|
17081
17788
|
}
|
|
17082
17789
|
return `${protocol}//${url.hostname}:${url.port}`;
|
|
17083
17790
|
}
|
|
@@ -17174,8 +17881,8 @@ async function captureViaCdp(input, io) {
|
|
|
17174
17881
|
const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
|
|
17175
17882
|
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
17176
17883
|
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
17177
|
-
throw new
|
|
17178
|
-
code:
|
|
17884
|
+
throw new CliError37({
|
|
17885
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17179
17886
|
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
17180
17887
|
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
17181
17888
|
});
|
|
@@ -17205,7 +17912,7 @@ async function captureViaCdp(input, io) {
|
|
|
17205
17912
|
});
|
|
17206
17913
|
if (r.exceptionDetails) {
|
|
17207
17914
|
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
17208
|
-
throw new
|
|
17915
|
+
throw new CliError37({ code: CliErrorCode38.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why.split("\n")[0] ?? why)}` });
|
|
17209
17916
|
}
|
|
17210
17917
|
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
17211
17918
|
}
|
|
@@ -17216,7 +17923,7 @@ async function captureViaCdp(input, io) {
|
|
|
17216
17923
|
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
17217
17924
|
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
17218
17925
|
if (!shot.data) {
|
|
17219
|
-
throw new
|
|
17926
|
+
throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
17220
17927
|
}
|
|
17221
17928
|
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
17222
17929
|
return { dom, browser, evalResult, navigated, minted };
|
|
@@ -17238,7 +17945,7 @@ var defaultCdpIo = {
|
|
|
17238
17945
|
openSocket: (wsUrl) => new Promise((resolve4, reject) => {
|
|
17239
17946
|
const Ctor = globalThis.WebSocket;
|
|
17240
17947
|
if (!Ctor) {
|
|
17241
|
-
reject(new
|
|
17948
|
+
reject(new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: "\u8FD9\u4E2A Node \u6CA1\u6709\u5168\u5C40 WebSocket\uFF08\u9700\u8981 Node \u2265 22.4\uFF1B22.0\u201322.3 \u8981\u52A0 --experimental-websocket\uFF09" }));
|
|
17242
17949
|
return;
|
|
17243
17950
|
}
|
|
17244
17951
|
const ws = new Ctor(wsUrl);
|
|
@@ -17261,7 +17968,7 @@ var defaultCdpIo = {
|
|
|
17261
17968
|
|
|
17262
17969
|
// src/commands/chiron-page-playwright.ts
|
|
17263
17970
|
import path16 from "path";
|
|
17264
|
-
import { CliError as
|
|
17971
|
+
import { CliError as CliError38, CliErrorCode as CliErrorCode39 } from "@hcmai/sdk";
|
|
17265
17972
|
function playwrightCacheRoot(probe2) {
|
|
17266
17973
|
const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
17267
17974
|
if (override === "0" && probe2.packageRoot) return path16.join(probe2.packageRoot, ".local-browsers");
|
|
@@ -17304,8 +18011,8 @@ function discoverPlaywrightBrowser(probe2) {
|
|
|
17304
18011
|
const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
17305
18012
|
if (explicit) {
|
|
17306
18013
|
if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
17307
|
-
throw new
|
|
17308
|
-
code:
|
|
18014
|
+
throw new CliError38({
|
|
18015
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
17309
18016
|
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
17310
18017
|
context: { nextStep: "\u6307\u5230 Playwright \u88C5\u7684 chrome-headless-shell / chrome \u4E8C\u8FDB\u5236\uFF0C\u6216\u53BB\u6389\u8FD9\u4E2A\u53D8\u91CF\u8BA9 CLI \u81EA\u5DF1\u627E" }
|
|
17311
18018
|
});
|
|
@@ -17347,8 +18054,8 @@ async function captureViaPlaywright(input) {
|
|
|
17347
18054
|
}
|
|
17348
18055
|
}
|
|
17349
18056
|
if (!browser) {
|
|
17350
|
-
throw new
|
|
17351
|
-
code:
|
|
18057
|
+
throw new CliError38({
|
|
18058
|
+
code: CliErrorCode39.SERVER_ERROR,
|
|
17352
18059
|
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
17353
18060
|
context: {
|
|
17354
18061
|
nextStep: "\u88C5\u4E00\u4EFD Playwright \u7684 Chromium\uFF1Anpx playwright install chromium-headless-shell\uFF08\u6216 chromium\uFF09\uFF1B\u5DF2\u7ECF\u88C5\u4E86\u4F46\u4E0D\u5728\u7F3A\u7701\u7F13\u5B58\u76EE\u5F55\u5C31 export PLAYWRIGHT_BROWSERS_PATH=<\u76EE\u5F55> \u6216 HCM_PLAYWRIGHT_EXECUTABLE=<\u4E8C\u8FDB\u5236>\uFF1B\u6C99\u7BB1\u8FDE headless shell \u90FD\u8D77\u4E0D\u4E86\u65F6\uFF0C\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u5E76\u7528 --cdp \u8FDE"
|
|
@@ -17368,7 +18075,7 @@ async function captureViaPlaywright(input) {
|
|
|
17368
18075
|
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
17369
18076
|
} catch (e) {
|
|
17370
18077
|
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
17371
|
-
throw new
|
|
18078
|
+
throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
17372
18079
|
}
|
|
17373
18080
|
}
|
|
17374
18081
|
const dom = await page.content();
|
|
@@ -17392,13 +18099,13 @@ function judgePageContent(input) {
|
|
|
17392
18099
|
function parseViewport(size) {
|
|
17393
18100
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
17394
18101
|
if (!m) {
|
|
17395
|
-
throw new
|
|
18102
|
+
throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--size \u8981\u5199\u6210 <\u5BBD>x<\u9AD8>\uFF0C\u4F8B\u5982 1440x900\uFF0C\u6536\u5230\u7684\u662F ${size}` });
|
|
17396
18103
|
}
|
|
17397
18104
|
const width = Number(m[1]);
|
|
17398
18105
|
const height = Number(m[2]);
|
|
17399
18106
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
17400
|
-
throw new
|
|
17401
|
-
code:
|
|
18107
|
+
throw new CliError39({
|
|
18108
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17402
18109
|
message: `--size \u8D85\u51FA\u8303\u56F4\uFF1A\u5BBD ${VIEWPORT_MIN.width}..${VIEWPORT_MAX.width}\u3001\u9AD8 ${VIEWPORT_MIN.height}..${VIEWPORT_MAX.height}\uFF0C\u6536\u5230\u7684\u662F ${size}`
|
|
17403
18110
|
});
|
|
17404
18111
|
}
|
|
@@ -17408,23 +18115,23 @@ function parseWaitMs(raw) {
|
|
|
17408
18115
|
if (raw === void 0) return 1e4;
|
|
17409
18116
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
17410
18117
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
17411
|
-
throw new
|
|
18118
|
+
throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--wait-ms \u8981\u662F 0..${WAIT_MS_MAX} \u7684\u6574\u6570\uFF0C\u6536\u5230\u7684\u662F ${raw}` });
|
|
17412
18119
|
}
|
|
17413
18120
|
return value;
|
|
17414
18121
|
}
|
|
17415
18122
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
17416
18123
|
if (!out?.trim()) {
|
|
17417
|
-
throw new
|
|
18124
|
+
throw new CliError39({ code: CliErrorCode40.MISSING_FLAG, message: `\u8981\u4F20 --out <${EVIDENCE_DIR}/\u2026/\u622A\u56FE.png>\uFF1A\u622A\u56FE\u843D\u5728\u54EA\u513F\u5FC5\u987B\u662F\u4F60\u5B9A\u7684\uFF0C\u4E0D\u7531\u547D\u4EE4\u731C` });
|
|
17418
18125
|
}
|
|
17419
18126
|
if (!out.endsWith(".png")) {
|
|
17420
|
-
throw new
|
|
18127
|
+
throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
17421
18128
|
}
|
|
17422
18129
|
const root = path17.resolve(projectRoot);
|
|
17423
18130
|
const evidenceRoot = path17.join(root, EVIDENCE_DIR);
|
|
17424
18131
|
const absolute = path17.resolve(root, out);
|
|
17425
18132
|
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path17.sep)) {
|
|
17426
|
-
throw new
|
|
17427
|
-
code:
|
|
18133
|
+
throw new CliError39({
|
|
18134
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17428
18135
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
17429
18136
|
});
|
|
17430
18137
|
}
|
|
@@ -17472,8 +18179,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
|
17472
18179
|
const canonicalParent = await deps.realpath(path17.dirname(absolute));
|
|
17473
18180
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
17474
18181
|
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path17.sep)) {
|
|
17475
|
-
throw new
|
|
17476
|
-
code:
|
|
18182
|
+
throw new CliError39({
|
|
18183
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17477
18184
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
17478
18185
|
});
|
|
17479
18186
|
}
|
|
@@ -17482,8 +18189,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17482
18189
|
const sitePath = normalizeTarget(target);
|
|
17483
18190
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
17484
18191
|
if (expect.length === 0) {
|
|
17485
|
-
throw new
|
|
17486
|
-
code:
|
|
18192
|
+
throw new CliError39({
|
|
18193
|
+
code: CliErrorCode40.MISSING_FLAG,
|
|
17487
18194
|
message: "\u81F3\u5C11\u8981\u4F20\u4E00\u6761 --expect-text\uFF08\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF09\u3002\u53EA\u5224\u300C\u622A\u51FA\u56FE\u4E86\u300D\u4E0D\u7B97\u9A8C\u6536\uFF1A\u767B\u5F55\u9875\u3001\u62A5\u9519\u9875\u3001\u767D\u5C4F\u90FD\u80FD\u622A\u51FA\u56FE\u3002"
|
|
17488
18195
|
});
|
|
17489
18196
|
}
|
|
@@ -17493,8 +18200,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17493
18200
|
const root = path17.resolve(args.project ?? ".");
|
|
17494
18201
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
17495
18202
|
if (await deps.present(absolute)) {
|
|
17496
|
-
throw new
|
|
17497
|
-
code:
|
|
18203
|
+
throw new CliError39({
|
|
18204
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17498
18205
|
message: `\u622A\u56FE\u5DF2\u5B58\u5728\uFF0C\u4E0D\u8986\u76D6\uFF1A${absolute}\u3002\u6362\u4E2A --out\uFF0C\u6216\u5148\u628A\u65E7\u8BC1\u636E\u632A\u8D70\u3002`
|
|
17499
18206
|
});
|
|
17500
18207
|
}
|
|
@@ -17506,8 +18213,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17506
18213
|
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
17507
18214
|
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
17508
18215
|
if (evalJs && !endpoint && !usePlaywright) {
|
|
17509
|
-
throw new
|
|
17510
|
-
code:
|
|
18216
|
+
throw new CliError39({
|
|
18217
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17511
18218
|
message: "--eval \u9700\u8981 Playwright \u6216 --cdp\uFF1A\u8001\u7684 spawn \u8DEF\u5F84\u53EA\u4F1A --dump-dom\uFF0C\u585E\u4E0D\u8FDB\u811A\u672C\u3002",
|
|
17512
18219
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17513
18220
|
});
|
|
@@ -17525,10 +18232,10 @@ async function runChironPage(target, args, deps) {
|
|
|
17525
18232
|
try {
|
|
17526
18233
|
captured = endpoint ? await deps.captureAttached({ endpoint, viewport, waitMs, evalJs, screenshot: absolute, mintUrl: mint }) : await deps.capturePlaywright({ viewport, waitMs, evalJs, screenshot: absolute, browser: playwrightBrowser, mintUrl: mint });
|
|
17527
18234
|
} catch (e) {
|
|
17528
|
-
if (e instanceof
|
|
18235
|
+
if (e instanceof CliError39) throw new CliError39({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
17529
18236
|
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
17530
|
-
throw new
|
|
17531
|
-
code:
|
|
18237
|
+
throw new CliError39({
|
|
18238
|
+
code: CliErrorCode40.SERVER_ERROR,
|
|
17532
18239
|
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
17533
18240
|
context: {
|
|
17534
18241
|
nextStep: endpoint ? `\u6838\u4E00\u773C ${endpoint}/json/version \u80FD\u4E0D\u80FD\u6253\u5F00\uFF1BChrome \u8981\u5E26 --remote-debugging-port \u8D77\uFF0C\u4E14\u6C99\u7BB1\u653E\u884C\u4E86\u8FD9\u4E2A\u7AEF\u53E3` : "npx playwright install chromium-headless-shell \u540E\u91CD\u8DD1\uFF1B\u6216 HCM_CHIRON_PAGE_DRIVER=spawn \u8D70\u8001\u8DEF\u5F84\u5BF9\u7167"
|
|
@@ -17544,8 +18251,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17544
18251
|
mode = "spawn";
|
|
17545
18252
|
const browser = deps.findBrowser();
|
|
17546
18253
|
if (!browser) {
|
|
17547
|
-
throw new
|
|
17548
|
-
code:
|
|
18254
|
+
throw new CliError39({
|
|
18255
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17549
18256
|
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
17550
18257
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF08\u6C99\u7BB1\u91CC\u4E5F\u80FD\u8DD1\uFF09\uFF1B\u6216\u88C5\u4E00\u4E2A Chrome / HCM_CHROME_BIN=/\u7EDD\u5BF9\u8DEF\u5F84\uFF1B\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17551
18258
|
});
|
|
@@ -17553,8 +18260,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17553
18260
|
minted = await mint();
|
|
17554
18261
|
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
17555
18262
|
if (!result.ok) {
|
|
17556
|
-
throw new
|
|
17557
|
-
code:
|
|
18263
|
+
throw new CliError39({
|
|
18264
|
+
code: CliErrorCode40.SERVER_ERROR,
|
|
17558
18265
|
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
17559
18266
|
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
17560
18267
|
});
|
|
@@ -17564,7 +18271,7 @@ async function runChironPage(target, args, deps) {
|
|
|
17564
18271
|
}
|
|
17565
18272
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
17566
18273
|
if (bytes === 0) {
|
|
17567
|
-
throw new
|
|
18274
|
+
throw new CliError39({ code: CliErrorCode40.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
17568
18275
|
}
|
|
17569
18276
|
const verdict = judgePageContent({ dom, expect, reject });
|
|
17570
18277
|
return {
|
|
@@ -17627,8 +18334,8 @@ var defaultChironPageDeps = {
|
|
|
17627
18334
|
const envCfg = await loadEnv6(ctx.env);
|
|
17628
18335
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
17629
18336
|
if (!frontend?.trim()) {
|
|
17630
|
-
throw new
|
|
17631
|
-
code:
|
|
18337
|
+
throw new CliError39({
|
|
18338
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17632
18339
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
17633
18340
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
17634
18341
|
});
|
|
@@ -19620,21 +20327,21 @@ import {
|
|
|
19620
20327
|
adminResetPassword,
|
|
19621
20328
|
formatObject as formatObject34,
|
|
19622
20329
|
fromAxiosError as fromAxiosError26,
|
|
19623
|
-
CliError as
|
|
19624
|
-
CliErrorCode as
|
|
20330
|
+
CliError as CliError40,
|
|
20331
|
+
CliErrorCode as CliErrorCode41
|
|
19625
20332
|
} from "@hcmai/sdk";
|
|
19626
20333
|
function buildAdminResetPasswordRequest(args, password) {
|
|
19627
20334
|
const hasId = Boolean(args.id);
|
|
19628
20335
|
const hasUsername = Boolean(args.username);
|
|
19629
20336
|
if (hasId === hasUsername) {
|
|
19630
|
-
throw new
|
|
19631
|
-
code:
|
|
20337
|
+
throw new CliError40({
|
|
20338
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19632
20339
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
19633
20340
|
});
|
|
19634
20341
|
}
|
|
19635
20342
|
if (!password) {
|
|
19636
|
-
throw new
|
|
19637
|
-
code:
|
|
20343
|
+
throw new CliError40({
|
|
20344
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19638
20345
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
19639
20346
|
});
|
|
19640
20347
|
}
|
|
@@ -19663,8 +20370,8 @@ async function promptPasswordTwice() {
|
|
|
19663
20370
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
19664
20371
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
19665
20372
|
if (password !== confirmation) {
|
|
19666
|
-
throw new
|
|
19667
|
-
code:
|
|
20373
|
+
throw new CliError40({
|
|
20374
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19668
20375
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
19669
20376
|
});
|
|
19670
20377
|
}
|
|
@@ -19797,7 +20504,8 @@ chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u
|
|
|
19797
20504
|
chiron.command("test").description("\u6309\u7528\u4F8B\u8DD1\u4E00\u904D\u5E76\u628A\u95EE\u9898\u627E\u51FA\u6765\uFF1A\u7528\u4F8B\u5728\u9879\u76EE\u4ED3 tests/\uFF0C\u5224\u636E\u5FC5\u987B\u770B\u5185\u5BB9\uFF08\u53EA\u5224\u9000\u51FA\u7801\u7684\u7528\u4F8B\u4F1A\u88AB\u62D2\u7EDD\u52A0\u8F7D\uFF09").argument("[target]", "\u7528\u4F8B\u6587\u4EF6\u6216\u76EE\u5F55\uFF08\u9ED8\u8BA4 tests/\uFF09").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u76EE\u6807\u73AF\u5883\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --env \u65F6\u8865\u4E0A").option("--as <identity>", "\u8EAB\u4EFD\uFF1B\u7528\u4F8B\u91CC\u6CA1\u5199 --as \u65F6\u8865\u4E0A").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironTestCommand(target, opts));
|
|
19798
20505
|
chiron.command("page").description("\u6253\u5F00\u9875\u9762\u622A\u56FE\u5E76\u5BF9\u7740\u9875\u9762\u5185\u5BB9\u5224\u4E00\u6B21\uFF1A\u81F3\u5C11\u8981\u7ED9\u4E00\u6761 --expect-text\uFF0C\u53EA\u622A\u56FE\u4E0D\u7B97\u9A8C\u6536").argument("<\u8DEF\u5F84>", "\u7AD9\u5185\u8DEF\u5F84\uFF0C\u5982 /dashboard/xxx").requiredOption("--out <file>", "\u622A\u56FE\u843D\u70B9\uFF0C\u5FC5\u987B\u5728\u9879\u76EE\u7684 evidence/ \u4E0B\u4E14\u4EE5 .png \u7ED3\u5C3E").option("--expect-text <text...>", "\u9875\u9762\u4E0A\u5FC5\u987B\u51FA\u73B0\u7684\u6587\u672C\uFF08\u81F3\u5C11\u4E00\u6761\uFF09").option("--reject-text <text...>", "\u9875\u9762\u4E0A\u4E0D\u5F97\u51FA\u73B0\u7684\u6587\u672C").option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55", ".").option("--env <name>", "\u9879\u76EE\u73AF\u5883\u540D\u6216\u672C\u673A\u69FD\u540D").option("--as <identity>", "\u4E34\u65F6\u6362\u8EAB\u4EFD").option("--wait-ms <ms>", "\u9875\u9762\u6E32\u67D3\u9884\u7B97\u6BEB\u79D2\u6570", "10000").option("--size <WxH>", "\u89C6\u53E3\u5C3A\u5BF8", "1440x900").option("--cdp <endpoint>", "\u4E0D\u81EA\u5DF1\u8D77 Chrome\uFF0C\u8FDE\u5230\u5DF2\u5728\u8DD1\u7684 Chrome\uFF08--remote-debugging-port\uFF09\uFF1A\u6C99\u7BB1\u91CC\u8D77\u4E0D\u4E86 Chrome \u65F6\u7528\uFF1B\u4E5F\u8BFB HCM_CHROME_CDP").option("--eval <js>", "\u622A\u56FE\u524D\u5728\u9875\u9762\u91CC\u8DD1\u7684 JS\uFF08\u51FD\u6570\u4F53\uFF0C\u53EF await\uFF0C\u8FD4\u56DE\u503C\u8FDB\u56DE\u6267\uFF09\uFF1A\u70B9\u6309\u94AE\u3001\u586B\u8868\u3001\u8FFD\u95EE\u90FD\u9760\u5B83\uFF1B\u9700\u8981 Playwright \u6216 --cdp").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((target, opts) => chironPageCommand(target, opts));
|
|
19799
20506
|
chiron.command("doctor").description(
|
|
19800
|
-
|
|
20507
|
+
// 项数从检查清单算:手写的数会在加检查项时漏改(加 local.gaps.verify 时就漏了一次)
|
|
20508
|
+
`\u4F53\u68C0\u672C\u673A ${CHECKS.filter((d) => d.layer === "local").length} \u9879\u4E0E\u6BCF\u73AF\u5883\u8FDE\u63A5 ${CHECKS.filter((d) => d.layer === "connect").length} \u9879\uFF1B\u7ED3\u8BBA READY / READY_WITH_RISKS / BLOCKED / UNDETERMINED\uFF1BBLOCKED \u4E0E UNDETERMINED \u9000\u51FA 3`
|
|
19801
20509
|
).option("--project <dir>", "\u9879\u76EE\u6839\u76EE\u5F55\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09").option("--env <name>", "\u9009\u5B9A\u76EE\u6807\u73AF\u5883\uFF08\u9ED8\u8BA4 env.yaml default\uFF09\uFF1B\u5176\u4F59\u73AF\u5883\u4ECD\u68C0\u67E5\uFF0C\u5931\u8D25\u8BB0\u98CE\u9669").option("--as <identity>", "\u4EE5\u6307\u5B9A\u8EAB\u4EFD\u4F53\u68C0\uFF08\u6CBF\u7528\u4E1A\u52A1\u547D\u4EE4\u7684\u4EE3\u7406\u56DE\u843D\uFF09").option("--stage <stage>", "\u9636\u6BB5\uFF1Ahandover | baseline | configure | migrate | integrate | golive | operate").option("--only <prefix>", "\u53EA\u68C0\u67E5\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--skip <prefix>", "\u6392\u9664\u8FD9\u4E9B id \u6216\u524D\u7F00\uFF0C\u9017\u53F7\u5206\u9694\uFF1B\u53EF\u91CD\u590D", (value, previous) => [...previous, value], []).option("--active", "\u5141\u8BB8\u4E3B\u52A8\u63A2\u6D4B\u7B2C\u4E09\u65B9\u5E76\u8BB0\u8D26").option("--platform-ops", "\u53EA\u7528\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5\u68C0\u67E5\u5E94\u7B54\u5B9E\u4F8B\u7684\u5E73\u53F0\u5C42").option("--platform-ops-key-stdin", "\u4ECE stdin \u8BFB\u53D6\u8FD0\u7EF4\u53EA\u8BFB\u5BC6\u94A5").option("--list", "\u5217\u51FA\u672C\u673A\u4E0E\u670D\u52A1\u7AEF\u7684\u68C0\u67E5\u76EE\u5F55").option("--explain <id>", "\u8BF4\u660E\u6307\u5B9A\u68C0\u67E5\u7684\u5224\u636E\u3001\u4F9D\u8D56\u548C\u7801\u8868").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").option("--fail-on <level>", "\u975E\u96F6\u9000\u51FA\u9608\u503C\uFF1Ablocked | risks\uFF08\u9ED8\u8BA4 blocked\uFF09").action((opts) => chironDoctorCommand(opts));
|
|
19802
20510
|
var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
|
|
19803
20511
|
chironSkills.command("sync").description("\u8BA9\u8FD9\u4E2A\u4ED3\u7684\u6280\u80FD\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50\uFF1A\u7B2C\u4E00\u6B21\u5C31\u88C5\u9F50\uFF0C\u4E4B\u540E\u6309\u4EA7\u54C1\u5F53\u524D\u5168\u96C6\u5BF9\u8D26\u3002\u5E42\u7B49\uFF0C\u4EA7\u54C1\u5347\u7EA7\u540E\u8DD1\u5B83").option("--only <id...>", "\u53EA\u8981\u8FD9\u51E0\u4E2A\u6280\u80FD\uFF08\u8FDE\u540C requires \u524D\u7F6E\uFF09\uFF0C\u4E0D\u8BA2\u9605\u5168\u96C6\uFF1B\u8BAD\u7EC3\u573A blind \u6863\u7528").option("--check", "\u53EA\u770B\u4F1A\u53D8\u4EC0\u4E48\uFF0C\u4E0D\u5199\u76D8").option("--target <agent>", "claude\uFF08.claude/skills/\uFF09| codex\uFF08hcm-skills/ + Agent \u7D22\u5F15\uFF09| auto", "auto").option("--global", "\u540C\u6B65\u7528\u6237\u7EA7\u76EE\u5F55\u800C\u975E\u5F53\u524D\u9879\u76EE").option("--dir <path>", "\u53EA\u5199\u6307\u5B9A\u76EE\u5F55\uFF1BCodex \u7D22\u5F15\u5199\u5165 <dir>/AGENTS.md").option("--from <dir>", "\u4ECE\u672C\u5730\u76EE\u5F55\u53D6\uFF08\u73B0\u573A\u6539\u8FC7\u7684\u7248\u672C\uFF09\uFF0C\u4E0D\u8D70\u7F51\u7EDC").option("--force", "\u8FDE\u672C\u5730\u6539\u8FC7\u7684\u6280\u80FD\u4E00\u8D77\u8986\u76D6\u6210\u4EA7\u54C1\u8FD9\u4E00\u7248").option("--prune-max <n>", `\u4E00\u8D9F\u6700\u591A\u6E05\u51E0\u4EFD\u4E0A\u6E38\u4E0D\u518D\u53D1\u7684\u6280\u80FD\uFF0C\u8D85\u4E86\u6574\u6279\u62D2\u7EDD\uFF1B0 = \u4E00\u4EFD\u90FD\u522B\u6E05\uFF08\u7F3A\u7701 ${PRUNE_DEFAULT_MAX}\uFF09`).option("--source <kind>", "\u8FD9\u4E00\u8D9F\u770B\u54EA\u4E9B\u6765\u6E90\uFF1Acli\uFF08\u53EA\u770B\u81EA\u5E26\uFF0C\u4E0D\u8FDE\u7F51\uFF09| chiron | all", "all").option("--endpoint <url>", "\u6280\u80FD\u5E93\u5730\u5740\uFF08\u9ED8\u8BA4\u53D6\u9879\u76EE\u73AF\u5883\u6216\u5B89\u88C5\u65F6\u8BB0\u5F55\u7684\u5730\u5740\uFF09").option("--env <name>", "\u4ECE\u8BE5 env \u89E3\u6790 endpoint").option("--output <fmt>", "\u8F93\u51FA\u683C\u5F0F\uFF1Atable | json | yaml", "table").action((opts) => skillsSyncCommand(opts));
|
|
@@ -19810,9 +20518,9 @@ projectEnv.command("edit <name> <field> <value>").description("\u7F16\u8F91 endp
|
|
|
19810
20518
|
projectEnv.command("remove <name>").description("\u5220\u9664\u9879\u76EE\u73AF\u5883\uFF1B\u9ED8\u8BA4\u9879\u987B\u5148\u6539\u5230\u5176\u4ED6\u73AF\u5883").option("--project <dir>", "\u9879\u76EE\u76EE\u5F55\uFF08\u5411\u4E0A\u5BFB\u627E env.yaml\uFF09", ".").option(...OUTPUT_OPT).action((name, opts) => chironEnvCommand("remove", { ...opts, name }));
|
|
19811
20519
|
var gap = chiron.command("gap").description("\u7F3A\u53E3\uFF1A\u649E\u5230\u300C\u4EA7\u54C1\u505A\u4E0D\u5230\u300D\u65F6\u7684\u7EDF\u4E00\u51FA\u53E3\uFF0C\u8FDB Jira\uFF08HCMNX\uFF09\u2014\u2014\u67E5\u91CD search / \u67E5\u8FDB\u5EA6 status / \u8BFB\u8BC4\u8BBA comments / \u63D0\u7F3A\u53E3 submit / \u9A8C\u6536 verify");
|
|
19812
20520
|
gap.command("search").description("\u67E5\u91CD\uFF1A\u6309\u9519\u8BEF\u7801 / Model / Action / \u4E00\u53E5\u73B0\u8C61\u67E5 Jira\uFF0C\u5E26\u56DE\u7F16\u53F7\u4E0E\u72B6\u6001").argument("<keywords...>", "\u5173\u952E\u8BCD\uFF0C\u6BCF\u4E2A\u5355\u72EC\u67E5\u4E00\u6B21").option("--no-include-closed", "\u53EA\u67E5\u672A\u89E3\u51B3\u7684").option(...OUTPUT_OPT).action((keywords, opts) => gapSearchCommand(keywords, opts));
|
|
19813
|
-
gap.command("status").description("\u67E5\u8FDB\u5EA6\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\
|
|
20521
|
+
gap.command("status").description("\u67E5\u8FDB\u5EA6\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\u65F6\uFF0C\u4EA7\u54C1\u4FA7\u6700\u65B0\u5904\u7406\u4E0E\u6700\u65B0\u8BC4\u8BBA\u5404\u7ED9\u9996\u884C\uFF0C\u5168\u6587\u770B comments\uFF1B\u4E0D\u7ED9\u5355\u53F7\u65F6\uFF0C\u5217\u51FA\u6211\u63D0\u7684\u3001\u5DF2\u4FEE\u590D\u8D85\u8FC7 14 \u5929\u5F85\u590D\u9A8C\u7684\u5355\u548C\u6BCF\u5F20\u7684 verify \u547D\u4EE4").argument("[ref]", "Jira \u5355\u53F7\uFF1B\u4E0D\u7ED9\u5C31\u5217\u5F85\u590D\u9A8C\u6E05\u5355").option(...OUTPUT_OPT).action((ref, opts) => gapStatusCommand(ref, opts));
|
|
19814
20522
|
gap.command("comments").description("\u8BFB\u8BC4\u8BBA\uFF1A\u6309\u65F6\u95F4\u6B63\u5E8F\u5217\u51FA\u8FD9\u5355\u4E0B\u7684\u8BC4\u8BBA\u2014\u2014\u65F6\u95F4\uFF08\u5230\u5206\u949F\uFF09/ \u4F5C\u8005 / \u5168\u6587 / \u8BC4\u8BBA\u6C38\u4E45\u94FE\u63A5").argument("<ref>", "Jira \u5355\u53F7").option("--limit <n>", "\u53EA\u770B\u6700\u8FD1 N \u6761\uFF08\u4ECD\u6309\u65F6\u95F4\u6B63\u5E8F\uFF09").option(...OUTPUT_OPT).action((ref, opts) => gapCommentsCommand(ref, opts));
|
|
19815
|
-
gap.command("submit").description("\u63D0\u7F3A\u53E3\uFF1A\u5148\u67E5\u91CD\uFF08\
|
|
20523
|
+
gap.command("submit").description("\u63D0\u7F3A\u53E3\uFF1A\u5148\u67E5\u91CD\uFF08\u672A\u89E3\u51B3 + \u5DF2\u4FEE\u590D + \u8FD1 90 \u5929 CLOSE\uFF09\u3002\u6709\u76F8\u4F3C\u5355\u5C31\u53EA\u5217\u51FA\u6765\u3001\u4E0D\u5199\uFF0C\u7531\u4F60\u70B9\u540D --append-to \u8FFD\u52A0\u6216 --new \u65B0\u5F00\uFF1B\u6CA1\u6709\u5C31\u6309 HCMNX \u5FC5\u586B\u683C\u65B0\u5F00\u3002\u8F7D\u8377 JSON \u8D70 --file \u6216\u6807\u51C6\u8F93\u5165").option("--file <path>", "\u7F3A\u53E3\u8F7D\u8377 JSON\uFF08title/phenomenon/repro/expected/alternative/q_*/severity/kind/module/local_workaround\u2026\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF08\u8BAD\u7EC3\u573A\u4ECE \u573A.yml \u53D6\u65F6\u7528\uFF09\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--issuetype <name>", "\u8986\u76D6 issuetype\uFF08\u7F3A\u7701\u6309 kind \u9009 \u6545\u969C / \u9700\u6C42\uFF09").option("--assignee <user>", "\u8986\u76D6\u7ECF\u529E\u4EBA\uFF08\u7F3A\u7701\u9879\u76EE\u8D1F\u8D23\u4EBA\uFF09").option("--append-to <ref>", "\u786E\u8BA4\u662F\u540C\u4E00\u7F3A\u53E3\uFF1A\u53EA\u5F80\u8FD9\u5F20\u5355\u8FFD\u52A0\u300C\u53C8\u4E00\u4E2A\u73B0\u573A\u300D\uFF08\u5DF2\u5173\u95ED\u7684\u5355\u3001\u91CD\u590D\u5355\u3001\u7591\u4F3C\u56DE\u5F52\u4F1A\u62D2\u7EDD\uFF0C\u7167\u6BCF\u5F20\u7684\u63D0\u793A\u8D70\uFF1A\u53BB\u539F\u5355\u3001\u5148\u5347\u7EA7\u3001\u539F\u5355\u63D0\u5355\u4EBA\u7528 gap verify --result fail \u9000\u56DE\uFF0C\u6216 --new\uFF09").option("--new", "\u65B0\u5F00\u4E00\u5F20\uFF0C\u770B\u8FC7\u7684\u76F8\u4F3C\u5355\u5199\u8FDB\u65B0\u5355\u7684\u300C\u67E5\u91CD\u300D\u4E00\u8282\u3002\u76F8\u4F3C\u5355\u90FD\u4E0D\u662F\u540C\u4E00\u7F3A\u53E3\u3001\u6216\u540C\u4E00\u7F3A\u53E3\u4F46\u539F\u5355\u6CA1\u4FEE\u5C31\u5173\u4E86 / \u5DF2\u542B\u4FEE\u590D\u4ECD\u590D\u73B0\uFF08\u7591\u4F3C\u56DE\u5F52\uFF09\u65F6\u8D70\u8FD9\u91CC\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u539F\u5355\u53F7\uFF1B\u91CD\u590D\u5355\u53BB\u5B83\u6307\u5411\u7684\u539F\u5355\u3001\u73AF\u5883\u65E9\u4E8E\u4FEE\u590D\u5148\u5347\u7EA7\u3001\u539F\u5355\u8FD8\u505C\u5728\u5DF2\u4FEE\u590D\u800C\u4F60\u662F\u63D0\u5355\u4EBA\uFF08\u7528 gap verify --result fail \u9000\u56DE\u539F\u5355\uFF09\uFF0C\u90FD\u4E0D\u8D70\u8FD9\u91CC").option("--dry-run", "\u53EA\u67E5\u91CD\u5E76\u6253\u5370\u4F1A\u505A\u4EC0\u4E48\uFF0C\u4E0D\u5199 Jira").option(...OUTPUT_OPT).action((opts) => gapSubmitCommand(opts));
|
|
19816
20524
|
gap.command("verify").description("\u9A8C\u6536\uFF1A\u4FEE\u590D\u53D1\u5230\u4F60\u7684\u73AF\u5883\u5E76\u6309\u6280\u80FD\u590D\u9A8C\u540E\uFF0C\u7531\u63D0\u5355\u4EBA\u56DE\u5199\u7ED3\u8BBA\u2014\u2014pass \u5173\u5355\u3001fail \u9000\u56DE\u3001partial \u53EA\u8BB0\u5F55\u4E0D\u5173\u5355\uFF1Bfail/partial \u5199\u5165\u524D\u4F1A\u6838\u5BF9\u73AF\u5883 revision \u5DF2\u5305\u542B\u4FEE\u590D").argument("<ref>", "Jira \u5355\u53F7\uFF08HCMNX-12 \u6216\u88F8\u6570\u5B57 12\uFF09\uFF0C\u53EA\u80FD\u662F\u4F60\u81EA\u5DF1\u63D0\u7684\u5355").requiredOption("--result <result>", "\u590D\u9A8C\u7ED3\u8BBA\uFF1Apass\uFF08\u539F\u6545\u969C\u4E0D\u518D\u51FA\u73B0\uFF09/ fail\uFF08\u4ECD\u590D\u73B0\uFF0C\u6216\u9A8C\u51FA\u6CA1\u901A\u8FC7\u7684\uFF09/ partial\uFF08\u53EA\u9A8C\u4E86\u4E00\u90E8\u5206\u3001\u9A8C\u8FC7\u7684\u90FD\u901A\u8FC7\uFF1B\u4E0D\u5173\u5355\uFF09").option("--body <text>", "\u9A8C\u6536\u8BC1\u636E\uFF1A\u73AF\u5883\u3001\u7248\u672C\u3001\u6309\u6280\u80FD\u8DD1\u4E86\u4EC0\u4E48\u3001\u770B\u5230\u4E86\u4EC0\u4E48").option("--file <path>", "\u4ECE\u6587\u4EF6\u8BFB\u9A8C\u6536\u8BC1\u636E\uFF08\u4E0E --body \u4E8C\u9009\u4E00\uFF1B\u90FD\u4E0D\u7ED9\u5C31\u8BFB\u6807\u51C6\u8F93\u5165\uFF09").option("--env <name>", "\u53D6\u73AF\u5883\u6307\u7EB9\u7528\u7684\u73AF\u5883\u522B\u540D\uFF08\u7F3A\u7701 activeEnv\uFF09").option("--fingerprint <text>", "\u76F4\u63A5\u7ED9\u6307\u7EB9\u6587\u672C\uFF0C\u4E0D\u518D\u73B0\u67E5").option("--dry-run", "\u53EA\u6838\u5BF9\u5E76\u6253\u5370\u8BA1\u5212\uFF0C\u4E0D\u5199 Jira").option(...OUTPUT_OPT).action((ref, opts) => gapVerifyCommand(ref, opts));
|
|
19817
20525
|
var kase = chiron.command("case").description("\u516C\u5171\u6848\u4F8B\u5E93\uFF1A\u67E5 search / \u770B show / \u5BF9\u6307\u7EB9 match / \u9879\u76EE\u6848\u4F8B\u4E0A\u884C submit");
|
|
19818
20526
|
kase.command("search").description("\u6309\u5BA2\u6237\u539F\u8BDD / \u9519\u8BEF\u7801 / Model / \u6280\u80FD\u627E\u516C\u5171\u6848\u4F8B\uFF0C\u5E76\u6309\u5F53\u524D\u73AF\u5883\u6307\u7EB9\u6807\u5339\u914D").argument("<query>", "\u4E00\u53E5\u8BDD\u6216\u5173\u952E\u8BCD").option("--top-k <n>", "\u53D6\u524D\u51E0\u6761\uFF081-10\uFF09", "5").option("--refresh", "\u5FFD\u7565\u672C\u673A\u7D22\u5F15\u7F13\u5B58\uFF08\u9ED8\u8BA4\u5B58\u4E00\u5C0F\u65F6\uFF09\uFF0C\u73B0\u62C9\u4E00\u4EFD \u2014\u2014 \u6848\u4F8B\u521A\u5408\u8FDB\u6848\u4F8B\u5E93\u65F6\u7528").option("--env <name>", "\u7528\u54EA\u4E2A\u73AF\u5883\u7684\u540E\u7AEF\u6307\u7EB9\u6BD4\u5BF9\uFF08\u4E0D\u7ED9\u5C31\u6807\u300C\u672A\u6BD4\u5BF9\u300D\uFF0C\u4E0D\u5047\u88C5\u5339\u914D\uFF09").option(...OUTPUT_OPT).action((query, opts) => caseSearchCommand(query, { ...opts, topK: Number(opts.topK) }));
|