@hcmai/cli 0.24.0 → 0.25.1
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 +1826 -1018
- 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
|
|
@@ -10213,6 +10336,7 @@ var WORKSPACE_CONTEXT_KIND = "hcm-workspace";
|
|
|
10213
10336
|
var WORKSPACE_CONTEXT_VERSION = 1;
|
|
10214
10337
|
var WORKSPACE_STATE_DIR = ".hcm";
|
|
10215
10338
|
var WORKSPACE_PULL_MANIFEST_FILE = "workspace-manifest.json";
|
|
10339
|
+
var WORKSPACE_PULL_INCOMPLETE_FILE = "workspace-pull-incomplete.json";
|
|
10216
10340
|
var MINI_APPS_DIR = "mini_apps";
|
|
10217
10341
|
var RAW_WORKSPACE_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
10218
10342
|
".git",
|
|
@@ -10380,13 +10504,34 @@ async function workspacePullCommand(args) {
|
|
|
10380
10504
|
);
|
|
10381
10505
|
const context = buildWorkspaceContext({
|
|
10382
10506
|
workspaceKey,
|
|
10383
|
-
profile:
|
|
10507
|
+
profile: client3.profile ?? args.env ?? args.profile ?? existing?.profile,
|
|
10384
10508
|
tenantId: client3.tenantId ?? existing?.tenantId,
|
|
10385
10509
|
endpoint: client3.endpoint ?? existing?.endpoint
|
|
10386
10510
|
});
|
|
10511
|
+
const files = await listWorkspaceFilesForSync(client3.raw(), workspaceKey);
|
|
10512
|
+
const localFiles = await readWorkspaceRawLocalFiles(rootDir);
|
|
10513
|
+
const remotePaths = new Set(files.data.map((file) => file.relativePath));
|
|
10514
|
+
const manifest2 = await readWorkspaceRawManifest(rootDir, context, true);
|
|
10515
|
+
const sameTarget = (manifest2.endpoint ?? existing?.endpoint) === context.endpoint && (manifest2.tenantId ?? existing?.tenantId) === context.tenantId && !!context.endpoint && !!context.tenantId && (manifest2.profile === void 0 || manifest2.profile === existing?.profile || manifest2.endpoint !== void 0 && manifest2.tenantId !== void 0);
|
|
10516
|
+
const previous = sameTarget ? workspaceRawBaselineByPath(manifest2) : /* @__PURE__ */ new Map();
|
|
10517
|
+
const remoteDeleted = localFiles.filter((file) => previous.has(file.localPath) && !remotePaths.has(file.localPath));
|
|
10518
|
+
if (remoteDeleted.length) {
|
|
10519
|
+
throw new CliError26({
|
|
10520
|
+
code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
|
|
10521
|
+
message: `\u8FDC\u7AEF\u5DF2\u5220\u9664\u66FE\u540C\u6B65\u7684\u6587\u4EF6\uFF0C\u672C\u5730\u4ECD\u4FDD\u7559\u5185\u5BB9\uFF1A${remoteDeleted.map((file) => file.localPath).join(", ")}\u3002\u672A\u91CD\u5EFA\u540C\u6B65\u57FA\u7EBF\u3002`,
|
|
10522
|
+
context: {
|
|
10523
|
+
reason: "WORKSPACE_REMOTE_FILE_DELETED",
|
|
10524
|
+
paths: remoteDeleted.map((file) => file.localPath),
|
|
10525
|
+
nextStep: "\u4FDD\u7559\u5F53\u524D\u76EE\u5F55\uFF0Cpull \u5230\u65B0\u7684\u7A7A\u76EE\u5F55\u6838\u5BF9\u8FDC\u7AEF\u5220\u9664\u610F\u56FE\uFF1B\u660E\u786E\u9700\u8981\u6062\u590D\u7684\u5185\u5BB9\u518D\u5408\u5E76\u5230\u65B0\u76EE\u5F55\uFF0C\u5148 push --dry-run \u6838\u5BF9\u3002"
|
|
10526
|
+
}
|
|
10527
|
+
});
|
|
10528
|
+
}
|
|
10387
10529
|
await fs9.mkdir(rootDir, { recursive: true });
|
|
10388
|
-
await
|
|
10389
|
-
|
|
10530
|
+
await fs9.mkdir(path10.join(rootDir, WORKSPACE_STATE_DIR), { recursive: true });
|
|
10531
|
+
await fs9.writeFile(
|
|
10532
|
+
path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE),
|
|
10533
|
+
JSON.stringify(context, null, 2) + "\n"
|
|
10534
|
+
);
|
|
10390
10535
|
const miniApps = detectRemoteMiniApps(files.data);
|
|
10391
10536
|
const pulledMiniApps = [];
|
|
10392
10537
|
for (const appCode of miniApps) {
|
|
@@ -10397,7 +10542,7 @@ async function workspacePullCommand(args) {
|
|
|
10397
10542
|
targetDir: path10.join(rootDir, MINI_APPS_DIR, appCode),
|
|
10398
10543
|
tenantId: client3.tenantId,
|
|
10399
10544
|
endpoint: client3.endpoint,
|
|
10400
|
-
profile:
|
|
10545
|
+
profile: context.profile,
|
|
10401
10546
|
force: !!args.force
|
|
10402
10547
|
});
|
|
10403
10548
|
pulledMiniApps.push(result);
|
|
@@ -10406,20 +10551,34 @@ async function workspacePullCommand(args) {
|
|
|
10406
10551
|
(file) => !isDirectoryMarker(file.relativePath) && !isMiniAppPath(file.relativePath)
|
|
10407
10552
|
);
|
|
10408
10553
|
const pulledRawFiles = [];
|
|
10409
|
-
const
|
|
10554
|
+
const snapshots = [];
|
|
10410
10555
|
for (const file of rawFiles) {
|
|
10411
10556
|
const content = await loadWorkspaceFileContent(client3.raw(), file.id);
|
|
10557
|
+
if (content.workspaceKey !== workspaceKey || content.relativePath !== file.relativePath) {
|
|
10558
|
+
throw new CliError26({
|
|
10559
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
10560
|
+
message: `load-content \u56DE\u6267\u4E0E\u76EE\u6807\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u4E0D\u7B26\uFF1A${file.relativePath}`,
|
|
10561
|
+
context: {
|
|
10562
|
+
reason: "INVALID_WORKSPACE_FILE_CONTENT",
|
|
10563
|
+
nextStep: "\u6838\u5BF9\u6587\u4EF6\u5217\u8868\u548C load-content \u56DE\u6267\u540E\u91CD\u8BD5\uFF1B\u672C\u6B21\u672A\u66F4\u65B0\u540C\u6B65\u57FA\u7EBF\u3002"
|
|
10564
|
+
}
|
|
10565
|
+
});
|
|
10566
|
+
}
|
|
10412
10567
|
const target = path10.join(rootDir, content.relativePath);
|
|
10413
10568
|
await writeTextFile(target, content.content, !!args.force);
|
|
10414
10569
|
pulledRawFiles.push(content.relativePath);
|
|
10415
|
-
|
|
10570
|
+
snapshots.push({
|
|
10571
|
+
localPath: file.relativePath,
|
|
10572
|
+
remotePath: file.relativePath,
|
|
10573
|
+
fileId: file.id,
|
|
10574
|
+
sha256: sha2563(content.content),
|
|
10575
|
+
size: Buffer.byteLength(content.content, "utf8"),
|
|
10576
|
+
lastModified: file.lastModified
|
|
10577
|
+
});
|
|
10416
10578
|
}
|
|
10417
|
-
await writeWorkspaceRawState(
|
|
10418
|
-
|
|
10419
|
-
|
|
10420
|
-
await readWorkspaceRawLocalFiles(rootDir),
|
|
10421
|
-
rawRemoteByLocalPath
|
|
10422
|
-
);
|
|
10579
|
+
await writeWorkspaceRawState(rootDir, context, snapshots);
|
|
10580
|
+
await writeWorkspaceContext(rootDir, context);
|
|
10581
|
+
await fs9.unlink(path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
10423
10582
|
writeWorkspacePullResult(
|
|
10424
10583
|
{
|
|
10425
10584
|
workspaceKey,
|
|
@@ -10429,7 +10588,8 @@ async function workspacePullCommand(args) {
|
|
|
10429
10588
|
appCode: item.appCode,
|
|
10430
10589
|
files: item.files.length
|
|
10431
10590
|
})),
|
|
10432
|
-
rawFiles: pulledRawFiles
|
|
10591
|
+
rawFiles: pulledRawFiles,
|
|
10592
|
+
preservedLocalFiles: localFiles.filter((file) => !remotePaths.has(file.localPath)).map((file) => file.localPath)
|
|
10433
10593
|
},
|
|
10434
10594
|
args.output ?? "table"
|
|
10435
10595
|
);
|
|
@@ -10502,29 +10662,28 @@ async function workspaceRmCommand(relativePath, args) {
|
|
|
10502
10662
|
throw new Error(`workspace rm refuses non-regular files: ${normalized}`);
|
|
10503
10663
|
}
|
|
10504
10664
|
const manifest2 = await readWorkspaceRawManifest(rootDir, context);
|
|
10505
|
-
let manifestEntry = manifest2.
|
|
10506
|
-
if (!manifestEntry
|
|
10507
|
-
const client3 = await
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
|
|
10525
|
-
|
|
10526
|
-
|
|
10527
|
-
}
|
|
10665
|
+
let manifestEntry = workspaceRawBaselineByPath(manifest2).get(normalized);
|
|
10666
|
+
if (!manifestEntry) {
|
|
10667
|
+
const client3 = HcmClient23.fromAuthContext(await getActiveAuthContextFromCli(
|
|
10668
|
+
args,
|
|
10669
|
+
{ fallbackEnv: context.profile }
|
|
10670
|
+
));
|
|
10671
|
+
const remote = (await listWorkspaceFilesForSync(client3.raw(), context.workspaceKey)).data.find(
|
|
10672
|
+
(file) => file.relativePath === normalized
|
|
10673
|
+
);
|
|
10674
|
+
if (remote) {
|
|
10675
|
+
const content = await loadWorkspaceFileContent(client3.raw(), remote.id);
|
|
10676
|
+
manifestEntry = {
|
|
10677
|
+
localPath: normalized,
|
|
10678
|
+
remotePath: remote.relativePath,
|
|
10679
|
+
fileId: remote.id,
|
|
10680
|
+
sha256: sha2563(content.content),
|
|
10681
|
+
size: Buffer.byteLength(content.content, "utf8"),
|
|
10682
|
+
lastModified: remote.lastModified
|
|
10683
|
+
};
|
|
10684
|
+
manifest2.files = manifest2.files.filter((file) => file.localPath !== normalized);
|
|
10685
|
+
manifest2.files.push(manifestEntry);
|
|
10686
|
+
await writeWorkspaceRawManifest(rootDir, manifest2);
|
|
10528
10687
|
}
|
|
10529
10688
|
}
|
|
10530
10689
|
if (!stat) {
|
|
@@ -10964,7 +11123,22 @@ async function writeTextFile(file, content, force) {
|
|
|
10964
11123
|
await fs9.mkdir(path10.dirname(file), { recursive: true });
|
|
10965
11124
|
await fs9.writeFile(file, content);
|
|
10966
11125
|
}
|
|
10967
|
-
async function readWorkspaceRawManifest(rootDir, context) {
|
|
11126
|
+
async function readWorkspaceRawManifest(rootDir, context, forPull = false) {
|
|
11127
|
+
if (!forPull) {
|
|
11128
|
+
try {
|
|
11129
|
+
await fs9.access(path10.join(rootDir, WORKSPACE_STATE_DIR, WORKSPACE_PULL_INCOMPLETE_FILE));
|
|
11130
|
+
throw new CliError26({
|
|
11131
|
+
code: CliErrorCode27.BUSINESS_RULE_VIOLATION,
|
|
11132
|
+
message: "\u4E0A\u6B21 workspace pull \u672A\u5B8C\u6210\uFF0C\u672C\u5730\u53EF\u80FD\u6DF7\u6709\u4E0D\u540C\u76EE\u6807\u7684\u5185\u5BB9\uFF0C\u4E0D\u80FD\u7EE7\u7EED\u540C\u6B65\u3002",
|
|
11133
|
+
context: {
|
|
11134
|
+
reason: "WORKSPACE_PULL_INCOMPLETE",
|
|
11135
|
+
nextStep: `\u4FDD\u7559\u76EE\u5F55\u5E76\u5907\u4EFD\u672C\u5730\u4FEE\u6539\uFF1B\u67E5\u770B .hcm/${WORKSPACE_PULL_INCOMPLETE_FILE} \u4E2D\u7684\u76EE\u6807\uFF0C\u7528\u539F pull \u53C2\u6570\u6210\u529F\u91CD\u8BD5\u540E\u518D verify/push\u3002`
|
|
11136
|
+
}
|
|
11137
|
+
});
|
|
11138
|
+
} catch (e) {
|
|
11139
|
+
if (e.code !== "ENOENT") throw e;
|
|
11140
|
+
}
|
|
11141
|
+
}
|
|
10968
11142
|
try {
|
|
10969
11143
|
const parsed = JSON.parse(
|
|
10970
11144
|
await fs9.readFile(
|
|
@@ -10972,51 +11146,38 @@ async function readWorkspaceRawManifest(rootDir, context) {
|
|
|
10972
11146
|
"utf-8"
|
|
10973
11147
|
)
|
|
10974
11148
|
);
|
|
10975
|
-
if (parsed.version !== WORKSPACE_CONTEXT_VERSION || parsed.workspaceKey !== context.workspaceKey) {
|
|
11149
|
+
if (parsed.version !== WORKSPACE_CONTEXT_VERSION || parsed.workspaceKey !== context.workspaceKey && !forPull) {
|
|
10976
11150
|
throw new Error(
|
|
10977
11151
|
`${WORKSPACE_PULL_MANIFEST_FILE} does not match workspace ${context.workspaceKey}`
|
|
10978
11152
|
);
|
|
10979
11153
|
}
|
|
10980
|
-
return parsed;
|
|
11154
|
+
if (parsed.workspaceKey === context.workspaceKey) return parsed;
|
|
10981
11155
|
} catch (e) {
|
|
10982
11156
|
if (e.code !== "ENOENT") throw e;
|
|
10983
|
-
return {
|
|
10984
|
-
version: WORKSPACE_CONTEXT_VERSION,
|
|
10985
|
-
workspaceKey: context.workspaceKey,
|
|
10986
|
-
profile: context.profile,
|
|
10987
|
-
pulledAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
10988
|
-
files: []
|
|
10989
|
-
};
|
|
10990
11157
|
}
|
|
11158
|
+
return {
|
|
11159
|
+
version: WORKSPACE_CONTEXT_VERSION,
|
|
11160
|
+
workspaceKey: context.workspaceKey,
|
|
11161
|
+
profile: context.profile,
|
|
11162
|
+
endpoint: context.endpoint,
|
|
11163
|
+
tenantId: context.tenantId,
|
|
11164
|
+
pulledAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
11165
|
+
files: []
|
|
11166
|
+
};
|
|
10991
11167
|
}
|
|
10992
|
-
async function writeWorkspaceRawState(rootDir, context,
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
);
|
|
11005
|
-
await fs9.writeFile(
|
|
11006
|
-
path10.join(stateDir, WORKSPACE_PULL_MANIFEST_FILE),
|
|
11007
|
-
JSON.stringify(
|
|
11008
|
-
{
|
|
11009
|
-
version: WORKSPACE_CONTEXT_VERSION,
|
|
11010
|
-
workspaceKey: context.workspaceKey,
|
|
11011
|
-
profile: context.profile,
|
|
11012
|
-
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11013
|
-
files: snapshots
|
|
11014
|
-
},
|
|
11015
|
-
null,
|
|
11016
|
-
2
|
|
11017
|
-
) + "\n",
|
|
11018
|
-
"utf-8"
|
|
11019
|
-
);
|
|
11168
|
+
async function writeWorkspaceRawState(rootDir, context, snapshots) {
|
|
11169
|
+
await writeWorkspaceRawManifest(rootDir, {
|
|
11170
|
+
version: WORKSPACE_CONTEXT_VERSION,
|
|
11171
|
+
workspaceKey: context.workspaceKey,
|
|
11172
|
+
profile: context.profile,
|
|
11173
|
+
endpoint: context.endpoint,
|
|
11174
|
+
tenantId: context.tenantId,
|
|
11175
|
+
pulledAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
11176
|
+
files: snapshots
|
|
11177
|
+
});
|
|
11178
|
+
}
|
|
11179
|
+
function workspaceRawBaselineByPath(manifest2) {
|
|
11180
|
+
return new Map(manifest2.files.filter((file) => typeof file.fileId === "string" && file.fileId.trim().length > 0).map((file) => [file.localPath, file]));
|
|
11020
11181
|
}
|
|
11021
11182
|
async function writeWorkspaceRawManifest(rootDir, manifest2) {
|
|
11022
11183
|
const stateDir = path10.join(rootDir, WORKSPACE_STATE_DIR);
|
|
@@ -11111,7 +11272,7 @@ ${formatPreflightIssues(result.preflight.issues, " ")}`,
|
|
|
11111
11272
|
}
|
|
11112
11273
|
if (plan.conflicts.length) return result;
|
|
11113
11274
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
11114
|
-
const snapshots =
|
|
11275
|
+
const snapshots = workspaceRawBaselineByPath(manifest2);
|
|
11115
11276
|
const committed = [];
|
|
11116
11277
|
const operations = plan.operations;
|
|
11117
11278
|
for (const [index, operation] of operations.entries()) {
|
|
@@ -11328,8 +11489,36 @@ function formatPreflightSummary(preflight, indent2 = "") {
|
|
|
11328
11489
|
if (preflight.nextStep) lines.push(`${indent2} next: ${preflight.nextStep}`);
|
|
11329
11490
|
return lines.join("\n");
|
|
11330
11491
|
}
|
|
11331
|
-
async function
|
|
11492
|
+
async function listWorkspaceFilesForSync(http, workspaceKey) {
|
|
11332
11493
|
const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
|
|
11494
|
+
if (list.total !== list.data.length || new Set(list.data.map((file) => file.relativePath)).size !== list.data.length) {
|
|
11495
|
+
throw new CliError26({
|
|
11496
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
11497
|
+
message: `\u5DE5\u4F5C\u533A\u8FDC\u7AEF\u6587\u4EF6\u6E05\u5355\u4E0D\u5B8C\u6574\uFF1A\u6536\u5230 ${list.data.length} \u6761\uFF0C\u603B\u6570 ${list.total}\uFF0C\u65E0\u6CD5\u5224\u5B9A\u6587\u4EF6\u662F\u5426\u7F3A\u5931\u3002`,
|
|
11498
|
+
context: {
|
|
11499
|
+
reason: "INCOMPLETE_WORKSPACE_FILE_LIST",
|
|
11500
|
+
nextStep: "\u68C0\u67E5\u670D\u52A1\u7AEF\u6587\u4EF6\u5217\u8868\u7684\u5206\u9875\u53CA\u54CD\u5E94\u5B8C\u6574\u6027\u540E\u91CD\u8BD5\uFF1B\u4FDD\u7559\u672C\u5730\u76EE\u5F55\u548C\u540C\u6B65\u57FA\u7EBF\u3002"
|
|
11501
|
+
}
|
|
11502
|
+
});
|
|
11503
|
+
}
|
|
11504
|
+
if (list.data.some((file) => {
|
|
11505
|
+
const relativePath = file.relativePath.replace(/\/$/, "");
|
|
11506
|
+
try {
|
|
11507
|
+
return !file.id.trim() || file.workspaceKey !== workspaceKey || normalizeRelativePath(relativePath) !== relativePath;
|
|
11508
|
+
} catch {
|
|
11509
|
+
return true;
|
|
11510
|
+
}
|
|
11511
|
+
})) {
|
|
11512
|
+
throw new CliError26({
|
|
11513
|
+
code: CliErrorCode27.NETWORK_ERROR,
|
|
11514
|
+
message: "\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u542B\u6709\u65E0\u6548\u7684 ID\u3001\u5DE5\u4F5C\u533A\u6216\u6587\u4EF6\u8DEF\u5F84\u3002",
|
|
11515
|
+
context: { reason: "INVALID_WORKSPACE_FILE_LIST", nextStep: "\u6838\u5BF9\u76EE\u6807\u5DE5\u4F5C\u533A\u6587\u4EF6\u5217\u8868\u540E\u91CD\u8BD5\uFF1B\u4E0D\u80FD\u7528\u65E0\u6548\u8BB0\u5F55\u5224\u65AD\u8FDC\u7AEF\u5B58\u5728\u6027\u3002" }
|
|
11516
|
+
});
|
|
11517
|
+
}
|
|
11518
|
+
return list;
|
|
11519
|
+
}
|
|
11520
|
+
async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
11521
|
+
const list = await listWorkspaceFilesForSync(http, workspaceKey);
|
|
11333
11522
|
const result = [];
|
|
11334
11523
|
for (const item of list.data) {
|
|
11335
11524
|
if (isDirectoryMarker(item.relativePath) || isMiniAppPath(item.relativePath)) continue;
|
|
@@ -11340,7 +11529,7 @@ async function loadWorkspaceRawRemoteFiles(http, workspaceKey) {
|
|
|
11340
11529
|
}
|
|
11341
11530
|
function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
11342
11531
|
const status = computeWorkspaceRawStatus(manifest2, localFiles);
|
|
11343
|
-
const baseByLocal =
|
|
11532
|
+
const baseByLocal = workspaceRawBaselineByPath(manifest2);
|
|
11344
11533
|
const remoteByLocal = new Map(remoteFiles.map((file) => [file.item.relativePath, file]));
|
|
11345
11534
|
const operations = [];
|
|
11346
11535
|
const conflicts = [];
|
|
@@ -11407,6 +11596,10 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
11407
11596
|
}
|
|
11408
11597
|
continue;
|
|
11409
11598
|
}
|
|
11599
|
+
if (!remote) {
|
|
11600
|
+
conflicts.push(workspaceRawConflict(entry, "remote file was deleted after last pull"));
|
|
11601
|
+
continue;
|
|
11602
|
+
}
|
|
11410
11603
|
operations.push({
|
|
11411
11604
|
operation: "skip",
|
|
11412
11605
|
localPath: entry.localPath,
|
|
@@ -11418,7 +11611,7 @@ function buildWorkspaceRawPushPlan(manifest2, localFiles, remoteFiles) {
|
|
|
11418
11611
|
return { operations, conflicts };
|
|
11419
11612
|
}
|
|
11420
11613
|
function computeWorkspaceRawStatus(manifest2, localFiles) {
|
|
11421
|
-
const baseByLocal =
|
|
11614
|
+
const baseByLocal = workspaceRawBaselineByPath(manifest2);
|
|
11422
11615
|
const localByPath = new Map(localFiles.map((file) => [file.localPath, file]));
|
|
11423
11616
|
const paths = [.../* @__PURE__ */ new Set([...baseByLocal.keys(), ...localByPath.keys()])].sort();
|
|
11424
11617
|
return paths.map((localPath) => {
|
|
@@ -11740,8 +11933,10 @@ function writeWorkspacePullResult(result, format) {
|
|
|
11740
11933
|
`directory: ${result.rootDir}`,
|
|
11741
11934
|
`remote files: ${result.totalRemoteFiles}`,
|
|
11742
11935
|
`mini apps: ${result.miniApps.length}`,
|
|
11743
|
-
`raw files: ${result.rawFiles.length}
|
|
11936
|
+
`raw files: ${result.rawFiles.length}`,
|
|
11937
|
+
`preserved local-only files (added): ${result.preservedLocalFiles.length}`
|
|
11744
11938
|
];
|
|
11939
|
+
for (const file of result.preservedLocalFiles) lines.push(` + ${file}`);
|
|
11745
11940
|
if (result.miniApps.length) {
|
|
11746
11941
|
lines.push("mini artifacts:");
|
|
11747
11942
|
for (const app of result.miniApps) lines.push(` - ${app.appCode}: ${app.files} files`);
|
|
@@ -12455,7 +12650,7 @@ async function chironInitCommand(args, deps) {
|
|
|
12455
12650
|
// src/commands/gap.ts
|
|
12456
12651
|
import { readFileSync as readFileSync6 } from "fs";
|
|
12457
12652
|
import {
|
|
12458
|
-
CliErrorCode as
|
|
12653
|
+
CliErrorCode as CliErrorCode32,
|
|
12459
12654
|
createHttpClient as createHttpClient4,
|
|
12460
12655
|
formatObject as formatObject27,
|
|
12461
12656
|
loadGlobalConfig as loadGlobalConfig10,
|
|
@@ -12467,802 +12662,1167 @@ init_exit();
|
|
|
12467
12662
|
import { createJiraClient } from "@hcmai/sdk";
|
|
12468
12663
|
|
|
12469
12664
|
// 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
|
-
|
|
12665
|
+
import { CASES_REPO_SLUG as CASES_REPO_SLUG3, CliError as CliError30, CliErrorCode as CliErrorCode31, describeNonBmpHits, findNonBmpChars, firstLine as firstLine3, repoIssueUrl } from "@hcmai/sdk";
|
|
12666
|
+
import { linkedRepoRefs, parseRef as parseRef2 } from "@hcmai/sdk";
|
|
12667
|
+
|
|
12668
|
+
// src/jira/gap-verify.ts
|
|
12669
|
+
import {
|
|
12670
|
+
CASES_REPO_SLUG as CASES_REPO_SLUG2,
|
|
12671
|
+
CliError as CliError29,
|
|
12672
|
+
CliErrorCode as CliErrorCode30,
|
|
12673
|
+
JiraHttpError,
|
|
12674
|
+
JiraNonBmpContentError,
|
|
12675
|
+
NON_BMP_RULE_NOTE,
|
|
12676
|
+
firstLine as firstLine2,
|
|
12677
|
+
nonBmpHitLines,
|
|
12678
|
+
parseRef
|
|
12679
|
+
} from "@hcmai/sdk";
|
|
12680
|
+
var VERIFY_RESULTS = ["pass", "fail", "partial"];
|
|
12681
|
+
var WRITTEN_TAG = { no: "\u3010\u672A\u5199\u5165\u3011", yes: "\u3010\u5DF2\u5199\u5165\u3011", unknown: "\u3010\u5199\u6CA1\u5199\u4E0D\u786E\u5B9A\u3011" };
|
|
12682
|
+
var FIXED_STATUS = "\u5DF2\u4FEE\u590D";
|
|
12683
|
+
var CLOSED_STATUS = "CLOSE";
|
|
12684
|
+
var DUPLICATE_STATUS = "\u91CD\u590D\u95EE\u9898";
|
|
12685
|
+
var DONE_RESOLUTION = "\u5B8C\u6210";
|
|
12686
|
+
var DUPLICATE_RESOLUTION = "\u91CD\u590D\u63D0\u4EA4";
|
|
12687
|
+
var isDuplicateGap = (s) => s.status === DUPLICATE_STATUS || s.resolution === DUPLICATE_RESOLUTION;
|
|
12688
|
+
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";
|
|
12689
|
+
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";
|
|
12690
|
+
function terminalGapHint(s) {
|
|
12691
|
+
if (isDuplicateGap(s)) return DUPLICATE_ADVICE;
|
|
12692
|
+
return s.status === CLOSED_STATUS ? closedGapHint(s) : void 0;
|
|
12693
|
+
}
|
|
12694
|
+
function closedGapHint(s) {
|
|
12695
|
+
if (s.resolution === DUPLICATE_RESOLUTION) return DUPLICATE_ADVICE;
|
|
12696
|
+
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}`;
|
|
12697
|
+
}
|
|
12698
|
+
var EVIDENCE_MIN = 10;
|
|
12699
|
+
var VERIFY_PLAN = {
|
|
12700
|
+
pass: { header: "\u987E\u95EE\u590D\u9A8C\u901A\u8FC7", transition: { name: "\u786E\u8BA4\u5173\u95ED", to: CLOSED_STATUS }, outcome: "closed" },
|
|
12701
|
+
fail: { header: "\u987E\u95EE\u590D\u9A8C\u672A\u901A\u8FC7\uFF0C\u9000\u56DE", transition: { name: "\u672A\u89E3\u51B3", to: "OPEN" }, outcome: "returned" },
|
|
12702
|
+
partial: { header: "\u987E\u95EE\u590D\u9A8C\u90E8\u5206\u901A\u8FC7\uFF0C\u4E0D\u5173\u5355", outcome: "recorded" }
|
|
12703
|
+
};
|
|
12704
|
+
function parseVerifyResult(raw) {
|
|
12705
|
+
const v = String(raw ?? "").trim().toLowerCase();
|
|
12706
|
+
if (VERIFY_RESULTS.includes(v)) return v;
|
|
12707
|
+
throw new CliError29({
|
|
12708
|
+
code: raw === void 0 ? CliErrorCode30.MISSING_FLAG : CliErrorCode30.INVALID_ARGUMENT,
|
|
12709
|
+
message: `--result \u53EA\u80FD\u662F pass / fail / partial\uFF0C\u7ED9\u7684\u662F\u300C${raw ?? "\uFF08\u6CA1\u7ED9\uFF09"}\u300D`,
|
|
12710
|
+
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" }
|
|
12711
|
+
});
|
|
12712
|
+
}
|
|
12713
|
+
function verifyFailure(reasonCode, code2, written, message, nextStep, extra = {}, cause) {
|
|
12714
|
+
return new CliError29({ code: code2, message: `${message}${WRITTEN_TAG[written]}`, context: { reasonCode, written, nextStep, ...extra }, cause });
|
|
12715
|
+
}
|
|
12716
|
+
function who(u) {
|
|
12717
|
+
if (!u) return "\uFF08\u5355\u4E0A\u6CA1\u6709\uFF09";
|
|
12718
|
+
const shown = u.displayName ?? u.name ?? u.key ?? "?";
|
|
12719
|
+
return u.name && u.name !== shown ? `${shown}\uFF08${u.name}\uFF09` : shown;
|
|
12720
|
+
}
|
|
12721
|
+
function sameUser(a, b) {
|
|
12722
|
+
if (!a || !b) return false;
|
|
12723
|
+
if (a.key || b.key) return !!a.key && !!b.key && a.key === b.key;
|
|
12724
|
+
if (a.name && b.name) return a.name === b.name;
|
|
12725
|
+
return false;
|
|
12726
|
+
}
|
|
12727
|
+
var isEmptyValue = (v) => v === void 0 || v === null || typeof v === "string" && !v.trim() || Array.isArray(v) && v.length === 0;
|
|
12728
|
+
var fieldLabel = ([id, f]) => `${f.name ?? id}(${id})`;
|
|
12729
|
+
function checkRequiredFields(t, issue) {
|
|
12730
|
+
if (!t.fields) return null;
|
|
12731
|
+
const required2 = Object.entries(t.fields).filter(([, f]) => f.required === true);
|
|
12732
|
+
return {
|
|
12733
|
+
checked: required2.map(fieldLabel),
|
|
12734
|
+
missing: required2.filter(([id]) => isEmptyValue(issue.fields[id])).map(fieldLabel)
|
|
12735
|
+
};
|
|
12499
12736
|
}
|
|
12500
|
-
|
|
12501
|
-
var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${g.title} ${gapKeyTag(g)}`;
|
|
12502
|
-
function renderGapDescription(g, fingerprintText2) {
|
|
12737
|
+
function renderVerifyComment(result, evidence, fp, reporter, versionComparison) {
|
|
12503
12738
|
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",
|
|
12739
|
+
VERIFY_PLAN[result].header,
|
|
12740
|
+
`\u73AF\u5883\uFF1A${fp.text}${fp.source === "given" ? "\uFF08\u8C03\u7528\u65B9\u7ED9\u7684\uFF0C\u672A\u73B0\u67E5\uFF09" : ""}`,
|
|
12741
|
+
...versionComparison ? [`${versionComparison.text}`] : [],
|
|
12742
|
+
"\u9A8C\u6536\u8BF4\u660E\uFF1A",
|
|
12743
|
+
evidence.trim(),
|
|
12531
12744
|
"",
|
|
12532
|
-
|
|
12745
|
+
`_\u7531\u63D0\u5355\u4EBA ${reporter} \u7ECF \`hcm chiron gap verify\` \u63D0\u4EA4\u3002_`
|
|
12533
12746
|
].join("\n");
|
|
12534
12747
|
}
|
|
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;
|
|
12748
|
+
function fixRevisionFromComments(comments) {
|
|
12749
|
+
const evidence = [...comments].reverse().find((c2) => {
|
|
12750
|
+
const body = c2.body ?? "";
|
|
12751
|
+
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);
|
|
12752
|
+
});
|
|
12753
|
+
if (!evidence) return void 0;
|
|
12754
|
+
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));
|
|
12755
|
+
return revisions.length ? Math.max(...revisions) : void 0;
|
|
12556
12756
|
}
|
|
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(" / ")}`);
|
|
12570
|
-
}
|
|
12571
|
-
const module = g.module ?? "HCM-Core";
|
|
12572
|
-
const keyTag = gapKeyTag(g);
|
|
12573
|
-
const byName = {
|
|
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
|
-
}
|
|
12757
|
+
function notFixedNextStep(key2, s, result) {
|
|
12758
|
+
const { status } = s;
|
|
12759
|
+
if (status === CLOSED_STATUS) {
|
|
12760
|
+
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`;
|
|
12627
12761
|
}
|
|
12628
|
-
if (
|
|
12629
|
-
|
|
12630
|
-
|
|
12762
|
+
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`;
|
|
12763
|
+
if (status === "\u4E0D\u5904\u7406" || status === "\u7EB3\u5165\u89C4\u5212") {
|
|
12764
|
+
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`;
|
|
12631
12765
|
}
|
|
12632
|
-
if (
|
|
12633
|
-
|
|
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
|
-
);
|
|
12766
|
+
if (status === "\u8865\u5145\u8BF4\u660E") {
|
|
12767
|
+
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`;
|
|
12638
12768
|
}
|
|
12639
|
-
return {
|
|
12769
|
+
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
12770
|
}
|
|
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 };
|
|
12771
|
+
function doneNextStep(key2, outcome, found2) {
|
|
12772
|
+
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";
|
|
12773
|
+
switch (outcome) {
|
|
12774
|
+
case "closed":
|
|
12775
|
+
return `\u5DF2\u5173\u5355\u3002\u62A5\u544A\u91CC\u5199\u300C\u5DF2\u9A8C\u6536\u5173\u95ED ${key2}\u300D\uFF0C${link}\u3002`;
|
|
12776
|
+
case "returned":
|
|
12777
|
+
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`;
|
|
12778
|
+
case "recorded":
|
|
12779
|
+
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`;
|
|
12780
|
+
case "already-closed":
|
|
12781
|
+
return "\u8FD9\u5355\u5DF2\u7ECF\u662F CLOSE\uFF0C\u6CA1\u6709\u91CD\u590D\u5199\u3002";
|
|
12660
12782
|
}
|
|
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
12783
|
}
|
|
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;
|
|
12784
|
+
function rejectNextStep(status, key2) {
|
|
12785
|
+
if (status === 401) {
|
|
12786
|
+
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
12787
|
}
|
|
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;
|
|
12788
|
+
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`;
|
|
12789
|
+
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`;
|
|
12790
|
+
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
12791
|
}
|
|
12717
|
-
|
|
12718
|
-
|
|
12719
|
-
|
|
12720
|
-
const
|
|
12721
|
-
|
|
12792
|
+
function unconfirmedWhy(e) {
|
|
12793
|
+
if (e instanceof JiraHttpError) return `Jira ${e.status}`;
|
|
12794
|
+
if (e instanceof SyntaxError) return "Jira \u56DE\u4E86 2xx \u4F46\u5E94\u7B54\u8BFB\u4E0D\u61C2\uFF0C\u591A\u534A\u5DF2\u5199\u5165";
|
|
12795
|
+
const name = e instanceof Error ? e.name : typeof e;
|
|
12796
|
+
if (name === "TimeoutError" || name === "AbortError") return "\u8D85\u65F6";
|
|
12797
|
+
if (e instanceof TypeError) return "\u8FDE\u63A5\u5931\u8D25";
|
|
12798
|
+
return name;
|
|
12722
12799
|
}
|
|
12723
|
-
function
|
|
12724
|
-
|
|
12800
|
+
function writeFailure(e, key2, what) {
|
|
12801
|
+
if (e instanceof JiraNonBmpContentError) {
|
|
12802
|
+
return verifyFailure(
|
|
12803
|
+
"non-bmp-content",
|
|
12804
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12805
|
+
"no",
|
|
12806
|
+
`\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`,
|
|
12807
|
+
// 🔴 清单落 nextStep,不落 cause:CliError 渲染 cause 时 formatCause 截到 300 字,
|
|
12808
|
+
// 三处命中就会把「该怎么改」整段截掉——那正是顾问唯一需要的那段。
|
|
12809
|
+
`\u6362\u6389\u4E0B\u9762\u8FD9\u4E9B\u5B57\u7B26\u518D\u91CD\u8DD1\uFF08${NON_BMP_RULE_NOTE}\uFF09\uFF1A
|
|
12810
|
+
${nonBmpHitLines(e.hits)}`,
|
|
12811
|
+
{ key: key2, hits: e.hits }
|
|
12812
|
+
);
|
|
12813
|
+
}
|
|
12814
|
+
if (e instanceof JiraHttpError && e.status >= 400 && e.status < 500) {
|
|
12815
|
+
return verifyFailure("write-rejected", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", `Jira \u4EE5 ${e.status} \u62D2\u7EDD\u4E86\u8FD9\u6B21${what}`, rejectNextStep(e.status, key2), {
|
|
12816
|
+
key: key2,
|
|
12817
|
+
status: e.status,
|
|
12818
|
+
details: e.message
|
|
12819
|
+
});
|
|
12820
|
+
}
|
|
12821
|
+
return verifyFailure(
|
|
12822
|
+
"write-unconfirmed",
|
|
12823
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
12824
|
+
"unknown",
|
|
12825
|
+
`${what}\u8BF7\u6C42\u6CA1\u5F97\u5230\u786E\u8BA4\uFF08${unconfirmedWhy(e)}\uFF09`,
|
|
12826
|
+
`\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`,
|
|
12827
|
+
{ key: key2, ...e instanceof JiraHttpError ? { status: e.status } : {} },
|
|
12828
|
+
e
|
|
12829
|
+
);
|
|
12725
12830
|
}
|
|
12726
|
-
function
|
|
12727
|
-
|
|
12728
|
-
|
|
12729
|
-
id:
|
|
12730
|
-
|
|
12731
|
-
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
truncated,
|
|
12735
|
-
url: c2.id ? client3.commentUrl(key2, c2.id) : void 0
|
|
12736
|
-
};
|
|
12831
|
+
async function claimTransitionComment(client3, key2, me, header, body, beforeIds) {
|
|
12832
|
+
try {
|
|
12833
|
+
const hit = (await client3.comments(key2)).filter((c2) => !beforeIds.has(c2.id) && sameUser(c2.author, me) && firstLine2(c2.body ?? "") === header).at(-1);
|
|
12834
|
+
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` };
|
|
12835
|
+
} catch (e) {
|
|
12836
|
+
const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
12837
|
+
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` };
|
|
12838
|
+
}
|
|
12737
12839
|
}
|
|
12738
|
-
|
|
12840
|
+
var snapshotOf = (i) => ({ status: i.fields.status?.name, resolution: i.fields.resolution?.name ?? null });
|
|
12841
|
+
async function gapVerify({ client: client3 }, ref, o, casesSlug = CASES_REPO_SLUG2) {
|
|
12739
12842
|
const parsed = parseRef(ref, client3.project, casesSlug);
|
|
12740
|
-
if (!parsed
|
|
12741
|
-
|
|
12742
|
-
|
|
12743
|
-
|
|
12843
|
+
if (!parsed || parsed.kind !== "jira") {
|
|
12844
|
+
throw verifyFailure(
|
|
12845
|
+
"not-jira-key",
|
|
12846
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12847
|
+
"no",
|
|
12848
|
+
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}`,
|
|
12849
|
+
"\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
12850
|
);
|
|
12745
12851
|
}
|
|
12746
|
-
const
|
|
12747
|
-
const
|
|
12748
|
-
const
|
|
12749
|
-
|
|
12750
|
-
|
|
12751
|
-
|
|
12752
|
-
|
|
12753
|
-
|
|
12754
|
-
|
|
12755
|
-
|
|
12756
|
-
|
|
12757
|
-
|
|
12758
|
-
|
|
12759
|
-
|
|
12760
|
-
|
|
12761
|
-
|
|
12762
|
-
|
|
12763
|
-
|
|
12764
|
-
|
|
12765
|
-
|
|
12766
|
-
|
|
12767
|
-
latestComment = toView(client3, issue.key, latestRaw);
|
|
12768
|
-
sameAsProduct = !!productRaw && productRaw === latestRaw;
|
|
12769
|
-
if (!isAutoNotice(latestRaw.body)) latestComment.signal = classifyFollowUp(latestComment.headline);
|
|
12770
|
-
}
|
|
12771
|
-
const hit = `\u547D\u4E2D\u300C${latestProductComment?.matchedKeyword ?? "?"}\u300D`;
|
|
12772
|
-
if (latestProductComment && latestComment && sameAsProduct) {
|
|
12773
|
-
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));
|
|
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));
|
|
12852
|
+
const key2 = parsed.key;
|
|
12853
|
+
const inProject = (k) => k.startsWith(`${client3.project}-`);
|
|
12854
|
+
const wrongProject = (k) => verifyFailure(
|
|
12855
|
+
"wrong-project",
|
|
12856
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12857
|
+
"no",
|
|
12858
|
+
`${k} \u4E0D\u5728 ${client3.project} \u9879\u76EE\u91CC\uFF0C\u9A8C\u6536\u53EA\u5199 ${client3.project} \u7684\u5355`,
|
|
12859
|
+
`\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`,
|
|
12860
|
+
{ key: k, project: client3.project }
|
|
12861
|
+
);
|
|
12862
|
+
if (!inProject(key2)) throw wrongProject(key2);
|
|
12863
|
+
const evidence = o.evidence.trim();
|
|
12864
|
+
if (evidence.length < EVIDENCE_MIN) {
|
|
12865
|
+
throw verifyFailure(
|
|
12866
|
+
"evidence-too-short",
|
|
12867
|
+
CliErrorCode30.INVALID_ARGUMENT,
|
|
12868
|
+
"no",
|
|
12869
|
+
`\u9A8C\u6536\u8BC1\u636E\u81F3\u5C11 ${EVIDENCE_MIN} \u4E2A\u5B57\uFF0C\u7ED9\u7684\u662F ${evidence.length} \u4E2A\u5B57`,
|
|
12870
|
+
"\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",
|
|
12871
|
+
{ key: key2 }
|
|
12872
|
+
);
|
|
12778
12873
|
}
|
|
12779
|
-
|
|
12780
|
-
|
|
12781
|
-
const
|
|
12782
|
-
|
|
12783
|
-
|
|
12784
|
-
|
|
12785
|
-
|
|
12786
|
-
|
|
12787
|
-
|
|
12788
|
-
|
|
12789
|
-
|
|
12790
|
-
|
|
12791
|
-
|
|
12792
|
-
|
|
12793
|
-
|
|
12794
|
-
}
|
|
12795
|
-
|
|
12796
|
-
|
|
12797
|
-
|
|
12798
|
-
|
|
12799
|
-
|
|
12800
|
-
|
|
12801
|
-
|
|
12802
|
-
|
|
12803
|
-
|
|
12804
|
-
|
|
12805
|
-
}
|
|
12806
|
-
|
|
12807
|
-
|
|
12808
|
-
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12812
|
-
|
|
12813
|
-
|
|
12814
|
-
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12874
|
+
const [issue, me] = await Promise.all([client3.issue(key2), client3.myself()]);
|
|
12875
|
+
if (!inProject(issue.key)) throw wrongProject(issue.key);
|
|
12876
|
+
const before = snapshotOf(issue);
|
|
12877
|
+
const status = before.status;
|
|
12878
|
+
const reporter = issue.fields.reporter;
|
|
12879
|
+
const base = {
|
|
12880
|
+
key: key2,
|
|
12881
|
+
url: client3.browseUrl(key2),
|
|
12882
|
+
summary: issue.fields.summary ?? "",
|
|
12883
|
+
result: o.result,
|
|
12884
|
+
reporter: who(reporter),
|
|
12885
|
+
me: who(me),
|
|
12886
|
+
before,
|
|
12887
|
+
dryRun: o.dryRun === true,
|
|
12888
|
+
fingerprint: o.fingerprint
|
|
12889
|
+
};
|
|
12890
|
+
if (!sameUser(reporter, me)) {
|
|
12891
|
+
throw verifyFailure(
|
|
12892
|
+
"not-reporter",
|
|
12893
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12894
|
+
"no",
|
|
12895
|
+
`\u53EA\u6709\u63D0\u5355\u4EBA\u80FD\u9A8C\u6536 ${key2}\uFF1A\u63D0\u5355\u4EBA\u662F ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD\u662F ${who(me)}`,
|
|
12896
|
+
// 重复单上的 pass:提单人跑了也一个字不写(见下面 ②),叫人去找提单人是一跳死路
|
|
12897
|
+
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`,
|
|
12898
|
+
{ key: key2, status, resolution: before.resolution, reporter: reporter?.key ?? reporter?.name ?? null, me: me.key ?? me.name ?? null }
|
|
12899
|
+
);
|
|
12900
|
+
}
|
|
12901
|
+
if (o.result === "pass" && status === CLOSED_STATUS) {
|
|
12902
|
+
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`;
|
|
12903
|
+
return { ...base, outcome: "already-closed", written: "no", requiredFields: "not-applicable", nextStep };
|
|
12904
|
+
}
|
|
12905
|
+
if (status !== FIXED_STATUS) {
|
|
12906
|
+
throw verifyFailure(
|
|
12907
|
+
"status-not-fixed",
|
|
12908
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12909
|
+
"no",
|
|
12910
|
+
`${key2} \u7684\u72B6\u6001\u662F\u300C${status ?? "?"}\u300D\uFF0C\u9A8C\u6536\u53EA\u5728\u300C${FIXED_STATUS}\u300D\u4E0A\u505A`,
|
|
12911
|
+
notFixedNextStep(key2, before, o.result),
|
|
12912
|
+
{ key: key2, status, resolution: before.resolution }
|
|
12913
|
+
);
|
|
12914
|
+
}
|
|
12915
|
+
let versionComparison;
|
|
12916
|
+
if (o.result !== "pass") {
|
|
12917
|
+
let comments;
|
|
12918
|
+
let readReason;
|
|
12919
|
+
try {
|
|
12920
|
+
comments = await client3.comments(key2);
|
|
12921
|
+
} catch (e) {
|
|
12922
|
+
readReason = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
12923
|
+
}
|
|
12924
|
+
const fixRevision = comments ? fixRevisionFromComments(comments) : void 0;
|
|
12925
|
+
if (fixRevision === void 0) {
|
|
12926
|
+
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";
|
|
12927
|
+
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, reason };
|
|
12928
|
+
} else if (!Number.isSafeInteger(o.fingerprint.revision)) {
|
|
12929
|
+
const reason = o.fingerprint.revisionError ?? "\u73AF\u5883\u7248\u672C\u63A5\u53E3\u6CA1\u6709 revision \u5B57\u6BB5\uFF08\u53EF\u80FD\u662F\u65E7\u540E\u7AEF\uFF09";
|
|
12930
|
+
versionComparison = { status: "skipped", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u672A\u6267\u884C\uFF08\u539F\u56E0\uFF1A${reason}\uFF09`, fixRevision, reason };
|
|
12931
|
+
} else if (o.fingerprint.revision < fixRevision) {
|
|
12932
|
+
const environmentRevision = o.fingerprint.revision;
|
|
12933
|
+
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`;
|
|
12934
|
+
throw verifyFailure("env-behind-fix", CliErrorCode30.BUSINESS_RULE_VIOLATION, "no", message, message, { key: key2, fixRevision, environmentRevision });
|
|
12935
|
+
} else {
|
|
12936
|
+
const environmentRevision = o.fingerprint.revision;
|
|
12937
|
+
versionComparison = { status: "passed", text: `\u7248\u672C\u6BD4\u5BF9\uFF1A\u73AF\u5883 r${environmentRevision} \u2265 \u4FEE\u590D r${fixRevision}`, fixRevision, environmentRevision };
|
|
12827
12938
|
}
|
|
12828
12939
|
}
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
if (
|
|
12834
|
-
|
|
12835
|
-
|
|
12940
|
+
const plan = VERIFY_PLAN[o.result];
|
|
12941
|
+
let transition;
|
|
12942
|
+
let requiredFields = "not-applicable";
|
|
12943
|
+
let requiredChecked;
|
|
12944
|
+
if (plan.transition) {
|
|
12945
|
+
const want = plan.transition;
|
|
12946
|
+
const list = await client3.transitions(key2);
|
|
12947
|
+
transition = list.find((t) => t.name === want.name && t.to?.name === want.to);
|
|
12948
|
+
if (!transition) {
|
|
12949
|
+
const available = list.map((t) => `${t.name}\u2192${t.to?.name ?? "?"}`);
|
|
12950
|
+
throw verifyFailure(
|
|
12951
|
+
"transition-unavailable",
|
|
12952
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12953
|
+
"no",
|
|
12954
|
+
`${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`,
|
|
12955
|
+
"\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",
|
|
12956
|
+
{ key: key2, status, available }
|
|
12957
|
+
);
|
|
12958
|
+
}
|
|
12959
|
+
const req = checkRequiredFields(transition, issue);
|
|
12960
|
+
if (!req) requiredFields = "no-metadata";
|
|
12961
|
+
else if (req.missing.length) {
|
|
12962
|
+
throw verifyFailure(
|
|
12963
|
+
"required-fields-missing",
|
|
12964
|
+
CliErrorCode30.BUSINESS_RULE_VIOLATION,
|
|
12965
|
+
"no",
|
|
12966
|
+
`\u300C${transition.name}\u300D\u8981\u6C42\u8FD9\u4E9B\u5B57\u6BB5\u6709\u503C\uFF0C${key2} \u4E0A\u662F\u7A7A\u7684\uFF1A${req.missing.join("\u3001")}`,
|
|
12967
|
+
"\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",
|
|
12968
|
+
{ key: key2, status, missing: req.missing, checked: req.checked }
|
|
12969
|
+
);
|
|
12970
|
+
} else {
|
|
12971
|
+
requiredFields = "checked";
|
|
12972
|
+
requiredChecked = req.checked;
|
|
12973
|
+
}
|
|
12836
12974
|
}
|
|
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`;
|
|
12975
|
+
const body = renderVerifyComment(o.result, evidence, o.fingerprint, who(reporter), versionComparison);
|
|
12976
|
+
const move = transition ? { id: transition.id, name: transition.name, to: transition.to?.name } : void 0;
|
|
12977
|
+
if (o.dryRun) {
|
|
12978
|
+
return {
|
|
12979
|
+
...base,
|
|
12980
|
+
outcome: "planned",
|
|
12981
|
+
planned: plan.outcome,
|
|
12982
|
+
written: "no",
|
|
12983
|
+
transition: move,
|
|
12984
|
+
comment: { body },
|
|
12985
|
+
requiredFields,
|
|
12986
|
+
requiredChecked,
|
|
12987
|
+
versionComparison,
|
|
12988
|
+
nextStep: "\u8BA1\u5212\u5982\u4E0A\uFF0C\u6CA1\u6709\u5199 Jira\u3002\u53BB\u6389 --dry-run \u6267\u884C\u3002"
|
|
12989
|
+
};
|
|
12935
12990
|
}
|
|
12936
|
-
if (
|
|
12937
|
-
|
|
12991
|
+
if (transition) {
|
|
12992
|
+
const what = `\u6D41\u8F6C\u300C${transition.name}\u300D\u4E0E\u8BC4\u8BBA`;
|
|
12993
|
+
const beforeIds = new Set((await client3.comments(key2)).map((c2) => c2.id));
|
|
12994
|
+
try {
|
|
12995
|
+
await client3.transitionById(key2, transition.id, body);
|
|
12996
|
+
} catch (e) {
|
|
12997
|
+
throw writeFailure(e, key2, what);
|
|
12998
|
+
}
|
|
12999
|
+
const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
|
|
13000
|
+
let after2;
|
|
13001
|
+
try {
|
|
13002
|
+
after2 = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
|
|
13003
|
+
} catch (e) {
|
|
13004
|
+
throw verifyFailure(
|
|
13005
|
+
"readback-failed",
|
|
13006
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
13007
|
+
"yes",
|
|
13008
|
+
`${what}\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u5931\u8D25\uFF0C\u843D\u5230\u4EC0\u4E48\u72B6\u6001\u6CA1\u786E\u8BA4`,
|
|
13009
|
+
`\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`,
|
|
13010
|
+
{ key: key2, comment: comment2.id ?? null },
|
|
13011
|
+
e
|
|
13012
|
+
);
|
|
13013
|
+
}
|
|
13014
|
+
const expected = transition.to?.name ?? "?";
|
|
13015
|
+
const resolutionStuck = o.result === "fail" && !!after2.resolution;
|
|
13016
|
+
if (after2.status !== expected || resolutionStuck) {
|
|
13017
|
+
const did = plan.outcome === "closed" ? "\u5173\u5355" : "\u9000\u56DE";
|
|
13018
|
+
throw verifyFailure(
|
|
13019
|
+
"readback-mismatch",
|
|
13020
|
+
CliErrorCode30.SERVER_ERROR,
|
|
13021
|
+
"yes",
|
|
13022
|
+
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`,
|
|
13023
|
+
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",
|
|
13024
|
+
{ key: key2, before, after: after2, expected, comment: comment2.id ?? null }
|
|
13025
|
+
);
|
|
13026
|
+
}
|
|
13027
|
+
return {
|
|
13028
|
+
...base,
|
|
13029
|
+
outcome: plan.outcome,
|
|
13030
|
+
written: "yes",
|
|
13031
|
+
after: after2,
|
|
13032
|
+
transition: move,
|
|
13033
|
+
comment: comment2,
|
|
13034
|
+
requiredFields,
|
|
13035
|
+
requiredChecked,
|
|
13036
|
+
versionComparison,
|
|
13037
|
+
nextStep: doneNextStep(key2, plan.outcome, comment2.found)
|
|
13038
|
+
};
|
|
13039
|
+
}
|
|
13040
|
+
let written;
|
|
13041
|
+
try {
|
|
13042
|
+
written = await client3.addComment(key2, body);
|
|
13043
|
+
} catch (e) {
|
|
13044
|
+
throw writeFailure(e, key2, "\u8BC4\u8BBA");
|
|
13045
|
+
}
|
|
13046
|
+
let listed;
|
|
13047
|
+
try {
|
|
13048
|
+
listed = await client3.comments(key2);
|
|
13049
|
+
} catch (e) {
|
|
13050
|
+
throw verifyFailure(
|
|
13051
|
+
"readback-failed",
|
|
13052
|
+
CliErrorCode30.NETWORK_ERROR,
|
|
13053
|
+
"yes",
|
|
13054
|
+
`\u8BC4\u8BBA\u5DF2\u88AB Jira \u63A5\u53D7\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u5931\u8D25\uFF0C\u6CA1\u786E\u8BA4\u5B83\u5728`,
|
|
13055
|
+
`\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`,
|
|
13056
|
+
{ key: key2, comment: written.id ?? null },
|
|
13057
|
+
e
|
|
13058
|
+
);
|
|
13059
|
+
}
|
|
13060
|
+
let comment;
|
|
13061
|
+
if (!written.id) {
|
|
13062
|
+
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` };
|
|
13063
|
+
} else if (!listed.some((c2) => c2.id === written.id)) {
|
|
13064
|
+
throw verifyFailure(
|
|
13065
|
+
"readback-mismatch",
|
|
13066
|
+
CliErrorCode30.SERVER_ERROR,
|
|
13067
|
+
"yes",
|
|
13068
|
+
`Jira \u56DE\u4E86\u8BC4\u8BBA ${written.id}\uFF0C\u4F46\u56DE\u8BFB ${key2} \u7684\u8BC4\u8BBA\u91CC\u6CA1\u6709\u5B83`,
|
|
13069
|
+
`\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`,
|
|
13070
|
+
{ key: key2, comment: written.id }
|
|
13071
|
+
);
|
|
13072
|
+
} else {
|
|
13073
|
+
comment = { body, found: true, id: written.id, url: client3.commentUrl(key2, written.id) };
|
|
12938
13074
|
}
|
|
12939
|
-
|
|
12940
|
-
|
|
13075
|
+
let after;
|
|
13076
|
+
let aside = "";
|
|
13077
|
+
try {
|
|
13078
|
+
after = snapshotOf(await client3.issue(key2, ["status", "resolution"]));
|
|
13079
|
+
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`;
|
|
13080
|
+
} catch (e) {
|
|
13081
|
+
const why = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
13082
|
+
aside = `\uFF08\u56DE\u8BFB\u5355\u5B50\u72B6\u6001\u5931\u8D25\uFF1A${why}\uFF1B\u8BC4\u8BBA\u5DF2\u6838\u5728\u3002\uFF09`;
|
|
12941
13083
|
}
|
|
12942
|
-
return
|
|
13084
|
+
return {
|
|
13085
|
+
...base,
|
|
13086
|
+
outcome: "recorded",
|
|
13087
|
+
written: "yes",
|
|
13088
|
+
after,
|
|
13089
|
+
comment,
|
|
13090
|
+
requiredFields,
|
|
13091
|
+
requiredChecked,
|
|
13092
|
+
versionComparison,
|
|
13093
|
+
nextStep: `${doneNextStep(key2, "recorded", comment.found)}${aside}`
|
|
13094
|
+
};
|
|
12943
13095
|
}
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
13096
|
+
|
|
13097
|
+
// src/jira/gaps.ts
|
|
13098
|
+
var MIN_LEN = [
|
|
13099
|
+
["title", 8],
|
|
13100
|
+
["phenomenon", 20],
|
|
13101
|
+
["repro", 10],
|
|
13102
|
+
["expected", 10],
|
|
13103
|
+
["alternative", 5],
|
|
13104
|
+
["q_mechanism", 10],
|
|
13105
|
+
["q_history", 10],
|
|
13106
|
+
["q_skill", 10]
|
|
13107
|
+
];
|
|
13108
|
+
function validateGapInput(x) {
|
|
13109
|
+
if (!x || typeof x !== "object") throw new Error("\u7F3A\u53E3\u8F7D\u8377\u5FC5\u987B\u662F\u4E00\u4E2A JSON \u5BF9\u8C61");
|
|
13110
|
+
const g = x;
|
|
13111
|
+
const problems = [];
|
|
13112
|
+
for (const [k, min] of MIN_LEN) {
|
|
13113
|
+
const v = k === "title" && typeof g[k] === "string" ? normalizeGapTitle(g[k]) : g[k];
|
|
13114
|
+
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
13115
|
}
|
|
13116
|
+
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");
|
|
13117
|
+
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");
|
|
13118
|
+
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");
|
|
13119
|
+
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");
|
|
13120
|
+
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");
|
|
13121
|
+
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");
|
|
13122
|
+
const nonBmp = findNonBmpChars(g);
|
|
13123
|
+
if (nonBmp.length) problems.push(describeNonBmpHits(nonBmp).split("\n").join("\n "));
|
|
13124
|
+
if (problems.length) throw new Error(`\u7F3A\u53E3\u8F7D\u8377\u4E0D\u5408\u683C\uFF0C\u6CA1\u6709\u63D0\uFF1A
|
|
13125
|
+
${problems.join("\n ")}`);
|
|
13126
|
+
return g;
|
|
12956
13127
|
}
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
13128
|
+
var NO_ERROR_CODE = "\u65E0\u9519\u8BEF\u7801";
|
|
13129
|
+
var isMissingCode = (code2) => !code2 || code2 === "-" || code2.startsWith(NO_ERROR_CODE);
|
|
13130
|
+
var gapKeyTag = (g) => `\u3014${[g.model, g.action, isMissingCode(g.error_code) ? NO_ERROR_CODE : g.error_code].filter(Boolean).join("\xB7")}\u3015`;
|
|
13131
|
+
function normalizeGapTitle(title) {
|
|
13132
|
+
let t = (title ?? "").trim();
|
|
13133
|
+
for (; ; ) {
|
|
13134
|
+
const next = t.replace(/^缺口\s*[::]\s*/, "").replace(/\s*〔[^〔〕]*〕\s*$/, "").trim();
|
|
13135
|
+
if (next === t) return t;
|
|
13136
|
+
t = next;
|
|
12960
13137
|
}
|
|
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
13138
|
}
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
if (e instanceof TypeError) return "\u8FDE\u63A5\u5931\u8D25";
|
|
12971
|
-
return name;
|
|
13139
|
+
var gapSummary = (g) => `\u7F3A\u53E3\uFF1A${normalizeGapTitle(g.title)} ${gapKeyTag(g)}`;
|
|
13140
|
+
function parseKeyTag(summary) {
|
|
13141
|
+
const m = /〔([^〔〕]*)〕\s*$/.exec(summary ?? "");
|
|
13142
|
+
if (!m) return [];
|
|
13143
|
+
return m[1].split("\xB7").map((s) => s.trim()).filter((s) => s && !isMissingCode(s));
|
|
12972
13144
|
}
|
|
12973
|
-
function
|
|
12974
|
-
|
|
12975
|
-
|
|
12976
|
-
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
12981
|
-
|
|
12982
|
-
|
|
12983
|
-
|
|
12984
|
-
|
|
12985
|
-
|
|
12986
|
-
|
|
12987
|
-
|
|
12988
|
-
|
|
12989
|
-
|
|
12990
|
-
|
|
12991
|
-
|
|
13145
|
+
function titleSimilarity(a, b) {
|
|
13146
|
+
const bigrams = (t) => {
|
|
13147
|
+
const x = normalizeGapTitle(t).replace(/[\s,。::、()()「」]/g, "");
|
|
13148
|
+
const out = /* @__PURE__ */ new Set();
|
|
13149
|
+
for (let i = 0; i + 1 < x.length; i++) out.add(x.slice(i, i + 2));
|
|
13150
|
+
return out;
|
|
13151
|
+
};
|
|
13152
|
+
const A = bigrams(a);
|
|
13153
|
+
const B = bigrams(b);
|
|
13154
|
+
if (!A.size || !B.size) return 0;
|
|
13155
|
+
let n = 0;
|
|
13156
|
+
for (const s of A) if (B.has(s)) n++;
|
|
13157
|
+
return n / Math.min(A.size, B.size);
|
|
13158
|
+
}
|
|
13159
|
+
var SIMILARITY_THRESHOLD = 0.6;
|
|
13160
|
+
var MAX_CANDIDATES = 5;
|
|
13161
|
+
var APPEND_REFUSED = /* @__PURE__ */ new Set(["duplicate", "closed-unfixed", "likely-regression"]);
|
|
13162
|
+
var appendRefused = (c2) => c2.status === CLOSED_STATUS || c2.situation !== void 0 && APPEND_REFUSED.has(c2.situation);
|
|
13163
|
+
var VERSION_COMPARED = /* @__PURE__ */ new Set(["fixed-not-deployed", "closed-env-older", "likely-regression", "cannot-compare"]);
|
|
13164
|
+
var comparesVersions = (s) => s !== void 0 && VERSION_COMPARED.has(s);
|
|
13165
|
+
var isFixedCandidate = (c2) => c2.status === FIXED_STATUS || c2.status === CLOSED_STATUS && c2.resolution === DONE_RESOLUTION;
|
|
13166
|
+
function regressionStep(key2, who2) {
|
|
13167
|
+
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}`;
|
|
13168
|
+
if (!who2) return `\u4F60${both2}`;
|
|
13169
|
+
if (who2.reportedByYou === null) return `\u6CA1\u8BA4\u51FA\u4F60\u662F\u4E0D\u662F ${key2} \u7684\u63D0\u5355\u4EBA\uFF08${who2.why}\uFF09\u3002${both2}`;
|
|
13170
|
+
const basis = who2.basis ? `\uFF08${who2.basis}\uFF09` : "";
|
|
13171
|
+
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}`;
|
|
13172
|
+
}
|
|
13173
|
+
var reporterFields = (who2) => !who2 ? {} : who2.reportedByYou === null ? { reportedByYou: null, reportedByYouUnknown: who2.why } : { reportedByYou: who2.reportedByYou, ...who2.basis ? { reportedByYouBasis: who2.basis } : {} };
|
|
13174
|
+
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 } : {} };
|
|
13175
|
+
var gapDedupeJql = (project2) => `project = ${project2} AND (resolution = Unresolved OR status = "${FIXED_STATUS}" OR (status = "${CLOSED_STATUS}" AND resolved >= -90d)) ORDER BY created DESC`;
|
|
13176
|
+
var GAP_DEDUPE_SCOPE = "\u672A\u89E3\u51B3 + \u5DF2\u4FEE\u590D + \u8FD1 90 \u5929 CLOSE";
|
|
13177
|
+
function findGapCandidates(issues, g, client3) {
|
|
13178
|
+
const summary = gapSummary(g);
|
|
13179
|
+
const code2 = isMissingCode(g.error_code) ? void 0 : g.error_code;
|
|
13180
|
+
const out = [];
|
|
13181
|
+
for (const i of issues) {
|
|
13182
|
+
const t = i.fields.summary ?? "";
|
|
13183
|
+
const parts = parseKeyTag(t);
|
|
13184
|
+
const has = (x) => !x || parts.includes(x);
|
|
13185
|
+
let reason;
|
|
13186
|
+
let score;
|
|
13187
|
+
if (code2 && parts.includes(code2) && has(g.model) && has(g.action)) reason = "signature";
|
|
13188
|
+
else if (g.model && g.action && parts.includes(g.model) && parts.includes(g.action)) reason = "same-target";
|
|
13189
|
+
else {
|
|
13190
|
+
const s = titleSimilarity(t, summary);
|
|
13191
|
+
if (s >= SIMILARITY_THRESHOLD) {
|
|
13192
|
+
reason = "similar";
|
|
13193
|
+
score = Math.round(s * 100) / 100;
|
|
13194
|
+
}
|
|
13195
|
+
}
|
|
13196
|
+
if (!reason) continue;
|
|
13197
|
+
out.push({
|
|
13198
|
+
key: i.key,
|
|
13199
|
+
summary: t,
|
|
13200
|
+
status: i.fields.status?.name,
|
|
13201
|
+
resolution: i.fields.resolution?.name,
|
|
13202
|
+
url: client3.browseUrl(i.key),
|
|
13203
|
+
reason,
|
|
13204
|
+
...score !== void 0 ? { score } : {}
|
|
12992
13205
|
});
|
|
12993
13206
|
}
|
|
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
|
-
);
|
|
13207
|
+
const rank = { signature: 0, "same-target": 1, similar: 2, named: 3 };
|
|
13208
|
+
return out.sort((a, b) => rank[a.reason] - rank[b.reason] || (b.score ?? 0) - (a.score ?? 0));
|
|
13003
13209
|
}
|
|
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` };
|
|
13210
|
+
function classifyCandidate(c2, fixRevision, fingerprint, readError, who2) {
|
|
13211
|
+
const fixed = c2.status === FIXED_STATUS;
|
|
13212
|
+
if (isDuplicateGap(c2)) return { situation: "duplicate", advice: DUPLICATE_ADVICE };
|
|
13213
|
+
if (c2.status === CLOSED_STATUS && c2.resolution !== DONE_RESOLUTION) {
|
|
13214
|
+
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
13215
|
}
|
|
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
|
-
);
|
|
13216
|
+
if (!isFixedCandidate(c2)) {
|
|
13217
|
+
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` };
|
|
13218
|
+
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` };
|
|
13219
|
+
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` };
|
|
13220
|
+
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
13221
|
}
|
|
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
|
-
);
|
|
13222
|
+
const env2 = Number.isSafeInteger(fingerprint.revision) ? fingerprint.revision : void 0;
|
|
13223
|
+
if (fixRevision === void 0 || env2 === void 0) {
|
|
13224
|
+
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"}`;
|
|
13225
|
+
return {
|
|
13226
|
+
situation: "cannot-compare",
|
|
13227
|
+
...fixRevision !== void 0 ? { fixRevision } : {},
|
|
13228
|
+
...env2 !== void 0 ? { environmentRevision: env2 } : {},
|
|
13229
|
+
// 已修复与已关闭分开说:已关闭的单复验不了(gap verify 在 CLOSE 上不写或拒绝)
|
|
13230
|
+
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}`
|
|
13231
|
+
};
|
|
13046
13232
|
}
|
|
13047
|
-
|
|
13048
|
-
|
|
13049
|
-
|
|
13050
|
-
|
|
13051
|
-
|
|
13052
|
-
|
|
13053
|
-
|
|
13054
|
-
|
|
13055
|
-
|
|
13056
|
-
|
|
13057
|
-
|
|
13058
|
-
|
|
13059
|
-
|
|
13060
|
-
|
|
13061
|
-
|
|
13233
|
+
if (env2 < fixRevision) {
|
|
13234
|
+
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` };
|
|
13235
|
+
}
|
|
13236
|
+
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}` };
|
|
13237
|
+
}
|
|
13238
|
+
function localWorkaroundText(g) {
|
|
13239
|
+
const v = (g.local_workaround ?? "").trim().replace(/\s*\r?\n\s*/g, " / ");
|
|
13240
|
+
const bare = v.replace(/^[\s。..!!,,、;;::]+|[\s。..!!,,、;;::]+$/g, "").toLowerCase();
|
|
13241
|
+
return !bare || NO_WORKAROUND.has(bare) ? "none" : v;
|
|
13242
|
+
}
|
|
13243
|
+
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"]);
|
|
13244
|
+
function renderGapDescription(g, fingerprintText) {
|
|
13245
|
+
return [
|
|
13246
|
+
"h2. \u73B0\u8C61",
|
|
13247
|
+
g.phenomenon,
|
|
13248
|
+
"",
|
|
13249
|
+
"h2. \u590D\u73B0",
|
|
13250
|
+
"{code}",
|
|
13251
|
+
g.repro,
|
|
13252
|
+
"{code}",
|
|
13253
|
+
"",
|
|
13254
|
+
"h2. \u671F\u671B",
|
|
13255
|
+
g.expected,
|
|
13256
|
+
"",
|
|
13257
|
+
"h2. \u73AF\u5883\u6307\u7EB9",
|
|
13258
|
+
fingerprintText,
|
|
13259
|
+
"",
|
|
13260
|
+
"h2. \u66FF\u4EE3\u6CD5",
|
|
13261
|
+
g.alternative,
|
|
13262
|
+
"",
|
|
13263
|
+
"h2. \u672C\u5730\u7ED5\u6CD5",
|
|
13264
|
+
`localWorkaround: ${localWorkaroundText(g)}`,
|
|
13265
|
+
"",
|
|
13266
|
+
"h2. \u4E25\u91CD\u5EA6",
|
|
13267
|
+
`${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`,
|
|
13268
|
+
"",
|
|
13269
|
+
"h2. \u4E09\u95EE\u81EA\u7B54",
|
|
13270
|
+
`# \u673A\u5236\u8FB9\u754C\uFF1A${g.q_mechanism}`,
|
|
13271
|
+
`# \u5386\u53F2\uFF1A${g.q_history}`,
|
|
13272
|
+
`# \u6280\u80FD\u6709\u6CA1\u6709\u6559\u9519\uFF1A${g.q_skill}`,
|
|
13273
|
+
"",
|
|
13274
|
+
"h2. \u5173\u952E\u8BCD",
|
|
13275
|
+
[g.error_code, g.model, g.action].filter(Boolean).join(" \xB7 ") || "\uFF08\u65E0\uFF09",
|
|
13276
|
+
"",
|
|
13277
|
+
"_\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_"
|
|
13278
|
+
].join("\n");
|
|
13279
|
+
}
|
|
13280
|
+
var KIND_TO_TYPE = { \u7F3A\u9677: ["\u6545\u969C", "Bug", "\u7F3A\u9677"], \u7F3A\u80FD\u529B: ["\u9700\u6C42", "Story", "New Feature"] };
|
|
13281
|
+
var KIND_TO_CATEGORY = { \u7F3A\u9677: "\u7A0B\u5E8FBug", \u7F3A\u80FD\u529B: "\u9700\u6C42" };
|
|
13282
|
+
var SEVERITY_TO_PRIORITY = {
|
|
13283
|
+
\u963B\u65AD: ["\u7D27\u6025", "Highest", "High", "\u9AD8"],
|
|
13284
|
+
\u6709\u66FF\u4EE3\u6CD5: ["Medium", "\u4E2D", "\u4E00\u822C", "High"],
|
|
13285
|
+
\u63AA\u8F9E\u7EA7: ["Low", "\u4F4E", "Lowest"]
|
|
13286
|
+
};
|
|
13287
|
+
var MODULE_DEFAULT_CHILD = { "HCM-Core": "\u57FA\u7840\u8BBE\u7F6E", "HCM-Cloud": "\u5F00\u53D1\u5E73\u53F0", \u4EA7\u54C1\u652F\u6301: "\u4EA7\u54C1\u652F\u6301" };
|
|
13288
|
+
function buildGapFields(g, ctx) {
|
|
13289
|
+
const wanted = KIND_TO_TYPE[g.kind] ?? [];
|
|
13290
|
+
const type = ctx.issuetypeOverride && ctx.types.find((t) => t.name === ctx.issuetypeOverride) || wanted.map((n) => ctx.types.find((t) => t.name === n)).find(Boolean);
|
|
13291
|
+
if (!type) {
|
|
13292
|
+
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(" / ")}`);
|
|
13293
|
+
}
|
|
13294
|
+
const module = g.module ?? "HCM-Core";
|
|
13295
|
+
const keyTag = gapKeyTag(g);
|
|
13296
|
+
const byName = {
|
|
13297
|
+
\u6982\u8981: gapSummary(g),
|
|
13298
|
+
\u63CF\u8FF0: renderGapDescription(g, ctx.fingerprintText) + (ctx.dedupeNote ? `
|
|
13299
|
+
|
|
13300
|
+
${ctx.dedupeNote}` : ""),
|
|
13301
|
+
\u95EE\u9898\u7C7B\u522B: KIND_TO_CATEGORY[g.kind],
|
|
13302
|
+
\u95EE\u9898\u6A21\u5757: module,
|
|
13303
|
+
\u4F18\u5148\u7EA7: SEVERITY_TO_PRIORITY[g.severity],
|
|
13304
|
+
\u62A5\u544A\u4EBA: ctx.me,
|
|
13305
|
+
\u7ECF\u529E\u4EBA: ctx.assignee,
|
|
13306
|
+
Bug\u53D1\u73B0\u4EBA: "\u987E\u95EE",
|
|
13307
|
+
Bug\u91CD\u73B0\u64CD\u4F5C\u6B65\u9AA4: g.repro,
|
|
13308
|
+
Bug\u9519\u8BEF\u53F7: g.error_code || "\u65E0\u9519\u8BEF\u7801\uFF08\u73B0\u8C61\u89C1\u63CF\u8FF0\uFF09"
|
|
13062
13309
|
};
|
|
13063
|
-
|
|
13064
|
-
|
|
13065
|
-
|
|
13066
|
-
|
|
13067
|
-
|
|
13068
|
-
|
|
13069
|
-
|
|
13070
|
-
|
|
13071
|
-
|
|
13310
|
+
const fields = { project: { key: ctx.project }, issuetype: { id: type.id } };
|
|
13311
|
+
const unfilled = [];
|
|
13312
|
+
const values = (f) => (f.allowedValues ?? []).map((v) => v.value ?? v.name).join("|");
|
|
13313
|
+
for (const f of type.fields ?? []) {
|
|
13314
|
+
if (["project", "issuetype"].includes(f.fieldId)) continue;
|
|
13315
|
+
const want = byName[f.name];
|
|
13316
|
+
if (want === void 0) {
|
|
13317
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId})${f.allowedValues ? `=[${values(f)}]` : ""}`);
|
|
13318
|
+
continue;
|
|
13319
|
+
}
|
|
13320
|
+
if (f.schema?.type === "option-with-child") {
|
|
13321
|
+
const parent = (f.allowedValues ?? []).find((v) => (v.value ?? v.name) === want);
|
|
13322
|
+
if (!parent) {
|
|
13323
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${String(want)}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
13324
|
+
continue;
|
|
13325
|
+
}
|
|
13326
|
+
const childName = g.module_detail || MODULE_DEFAULT_CHILD[module];
|
|
13327
|
+
const child = (parent.children ?? []).find((c2) => (c2.value ?? c2.name) === childName);
|
|
13328
|
+
if (!child && (parent.children ?? []).length) {
|
|
13329
|
+
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`);
|
|
13330
|
+
continue;
|
|
13331
|
+
}
|
|
13332
|
+
fields[f.fieldId] = { id: parent.id, ...child ? { child: { id: child.id } } : {} };
|
|
13333
|
+
continue;
|
|
13334
|
+
}
|
|
13335
|
+
if (f.allowedValues) {
|
|
13336
|
+
const candidates = Array.isArray(want) ? want : [want];
|
|
13337
|
+
const hit = candidates.map((c2) => f.allowedValues.find((v) => (v.name ?? v.value) === c2)).find(Boolean);
|
|
13338
|
+
if (!hit) {
|
|
13339
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u60F3\u586B\u300C${candidates.join("/")}\u300D\u4F46\u53EF\u9009\u503C\u53EA\u6709 [${values(f)}]`);
|
|
13340
|
+
continue;
|
|
13341
|
+
}
|
|
13342
|
+
fields[f.fieldId] = hit.id ? { id: hit.id } : { name: hit.name ?? hit.value };
|
|
13343
|
+
} else if (f.schema?.type === "user") {
|
|
13344
|
+
if (!want) {
|
|
13345
|
+
if (f.required) unfilled.push(`${f.name}(${f.fieldId}) \u53D6\u4E0D\u5230\u7528\u6237\u540D`);
|
|
13346
|
+
continue;
|
|
13347
|
+
}
|
|
13348
|
+
fields[f.fieldId] = { name: Array.isArray(want) ? want[0] : want };
|
|
13349
|
+
} else {
|
|
13350
|
+
fields[f.fieldId] = Array.isArray(want) ? want[0] : want;
|
|
13351
|
+
}
|
|
13072
13352
|
}
|
|
13073
|
-
if (
|
|
13074
|
-
const
|
|
13075
|
-
|
|
13353
|
+
if ((type.fields ?? []).some((f) => f.fieldId === "labels")) {
|
|
13354
|
+
const sev = { \u963B\u65AD: "blocking", \u6709\u66FF\u4EE3\u6CD5: "workaround", \u63AA\u8F9E\u7EA7: "wording" }[g.severity];
|
|
13355
|
+
fields.labels = ["chiron-gap", `severity-${sev}`];
|
|
13076
13356
|
}
|
|
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 }
|
|
13357
|
+
if (unfilled.length) {
|
|
13358
|
+
throw new Error(
|
|
13359
|
+
`\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
|
|
13360
|
+
${unfilled.join("\n ")}
|
|
13361
|
+
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
13362
|
);
|
|
13086
13363
|
}
|
|
13087
|
-
|
|
13088
|
-
|
|
13089
|
-
|
|
13090
|
-
|
|
13364
|
+
return { fields, type, keyTag, summary: gapSummary(g), module: `${module}/${g.module_detail || MODULE_DEFAULT_CHILD[module]}` };
|
|
13365
|
+
}
|
|
13366
|
+
async function withSituation(client3, c2, fingerprint, reporter) {
|
|
13367
|
+
if (!isFixedCandidate(c2)) return { ...c2, ...classifyCandidate(c2, void 0, fingerprint) };
|
|
13368
|
+
const who2 = c2.status === FIXED_STATUS ? await reporter() : void 0;
|
|
13369
|
+
try {
|
|
13370
|
+
return { ...c2, ...classifyCandidate(c2, fixRevisionFromComments(await client3.comments(c2.key)), fingerprint, void 0, who2), ...reporterFields(who2) };
|
|
13371
|
+
} catch (e) {
|
|
13372
|
+
return { ...c2, ...classifyCandidate(c2, void 0, fingerprint, firstLine3(String(e.message ?? e)), who2), ...reporterFields(who2) };
|
|
13373
|
+
}
|
|
13374
|
+
}
|
|
13375
|
+
function reporterChecker(client3) {
|
|
13376
|
+
let me;
|
|
13377
|
+
const myself = () => me ??= client3.myself();
|
|
13378
|
+
const check = async (reporter) => {
|
|
13379
|
+
let you;
|
|
13091
13380
|
try {
|
|
13092
|
-
|
|
13381
|
+
you = await myself();
|
|
13093
13382
|
} 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 };
|
|
13383
|
+
return { reportedByYou: null, why: `\u8BFB Jira \u5F53\u524D\u8EAB\u4EFD\u5931\u8D25\uFF1A${firstLine3(String(e.message ?? e))}` };
|
|
13110
13384
|
}
|
|
13385
|
+
if (!you) return { reportedByYou: null, why: "\u8BFB Jira \u5F53\u524D\u8EAB\u4EFD\u5931\u8D25\uFF1A/myself \u56DE\u4E86\u7A7A\u6B63\u6587" };
|
|
13386
|
+
if (!reporter) return { reportedByYou: null, why: "\u539F\u5355\u6CA1\u5E26\u63D0\u5355\u4EBA" };
|
|
13387
|
+
const comparable = reporter.key || you.key ? Boolean(reporter.key && you.key) : Boolean(reporter.name && you.name);
|
|
13388
|
+
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" };
|
|
13389
|
+
return { reportedByYou: sameUser(reporter, you), basis: `\u63D0\u5355\u4EBA ${who(reporter)}\uFF0C\u5F53\u524D\u8EAB\u4EFD ${who(you)}` };
|
|
13390
|
+
};
|
|
13391
|
+
return { myself, check };
|
|
13392
|
+
}
|
|
13393
|
+
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}`;
|
|
13394
|
+
var describeCandidate = (c2) => `${c2.key} [${c2.status ?? "?"}${c2.resolution ? "\xB7" + c2.resolution : ""}] ${reasonText(c2)}\uFF1A${c2.summary}`;
|
|
13395
|
+
function renderDedupeNote(candidates, total = candidates.length) {
|
|
13396
|
+
if (!candidates.length) return "";
|
|
13397
|
+
return [
|
|
13398
|
+
"h2. \u67E5\u91CD",
|
|
13399
|
+
"\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",
|
|
13400
|
+
...candidates.map((c2) => `# ${describeCandidate(c2)}${c2.advice ? `\uFF08${c2.advice}\uFF09` : ""}`),
|
|
13401
|
+
...total > candidates.length ? [`\u53E6\u6709 ${total - candidates.length} \u5F20\u76F8\u4F3C\u5355\u672A\u5217\uFF08\u53EA\u5217\u524D ${candidates.length} \u5F20\uFF09\u3002`] : []
|
|
13402
|
+
].join("\n");
|
|
13403
|
+
}
|
|
13404
|
+
var envFirst = (env2) => env2 !== void 0 ? `\u4F60\u7684\u73AF\u5883\u662F r${env2}\uFF0C` : "\u5148\u8DD1 hcm version \u770B\u73AF\u5883\u7248\u672C\u3001";
|
|
13405
|
+
function appendedNextStep(t, alternative) {
|
|
13406
|
+
const keep = `\u5148\u7528\u66FF\u4EE3\u6CD5\u300C${alternative}\u300D\u7EE7\u7EED\u4EA4\u4ED8`;
|
|
13407
|
+
switch (t.situation) {
|
|
13408
|
+
case "fixed-not-deployed":
|
|
13409
|
+
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`;
|
|
13410
|
+
case "cannot-compare":
|
|
13411
|
+
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`;
|
|
13412
|
+
case "planned":
|
|
13413
|
+
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`;
|
|
13414
|
+
case "declined":
|
|
13415
|
+
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`;
|
|
13416
|
+
default:
|
|
13417
|
+
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
13418
|
}
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
-
|
|
13116
|
-
|
|
13117
|
-
|
|
13118
|
-
|
|
13119
|
-
|
|
13120
|
-
|
|
13121
|
-
|
|
13122
|
-
|
|
13123
|
-
|
|
13124
|
-
|
|
13125
|
-
|
|
13126
|
-
|
|
13127
|
-
|
|
13128
|
-
|
|
13129
|
-
|
|
13419
|
+
}
|
|
13420
|
+
var appendBody = (g, fingerprintText, target) => `\u53C8\u4E00\u4E2A\u73B0\u573A\uFF08${fingerprintText}\uFF09
|
|
13421
|
+
|
|
13422
|
+
**\u73B0\u8C61**\uFF1A${g.phenomenon}
|
|
13423
|
+
|
|
13424
|
+
**\u590D\u73B0**\uFF1A
|
|
13425
|
+
{code}
|
|
13426
|
+
${g.repro}
|
|
13427
|
+
{code}
|
|
13428
|
+
|
|
13429
|
+
**\u66FF\u4EE3\u6CD5**\uFF1A${g.alternative}
|
|
13430
|
+
localWorkaround: ${localWorkaroundText(g)}
|
|
13431
|
+
\u4E25\u91CD\u5EA6\uFF1A${g.severity}` + (target?.advice && comparesVersions(target.situation) ? `
|
|
13432
|
+
|
|
13433
|
+
\u7248\u672C\u5224\u65AD\uFF1A${target.advice}` : "");
|
|
13434
|
+
async function gapSubmit({ client: client3 }, g, opts) {
|
|
13435
|
+
const summary = gapSummary(g);
|
|
13436
|
+
const scope = await client3.searchAll(gapDedupeJql(client3.project), { fields: ["summary", "status", "resolution", "reporter"] });
|
|
13437
|
+
const scanned = { scope: GAP_DEDUPE_SCOPE, count: scope.issues.length, total: scope.total, truncated: scope.truncated };
|
|
13438
|
+
const raw = findGapCandidates(scope.issues, g, client3);
|
|
13439
|
+
const reporters = new Map(scope.issues.map((i) => [i.key, i.fields.reporter]));
|
|
13440
|
+
const who2 = reporterChecker(client3);
|
|
13441
|
+
const candidates = [];
|
|
13442
|
+
for (const c2 of raw.slice(0, MAX_CANDIDATES)) {
|
|
13443
|
+
const judged = await withSituation(client3, c2, opts.fingerprint, () => who2.check(reporters.get(c2.key)));
|
|
13444
|
+
candidates.push({ ...judged, appendable: !appendRefused(judged) });
|
|
13445
|
+
}
|
|
13446
|
+
const base = {
|
|
13447
|
+
summary,
|
|
13448
|
+
alternative: g.alternative,
|
|
13449
|
+
candidates,
|
|
13450
|
+
candidateTotal: raw.length,
|
|
13451
|
+
scanned,
|
|
13452
|
+
localWorkaround: localWorkaroundText(g),
|
|
13453
|
+
localWorkaroundStated: Boolean(g.local_workaround?.trim())
|
|
13454
|
+
};
|
|
13455
|
+
if (opts.appendTo) {
|
|
13456
|
+
const parsed = parseRef2(opts.appendTo, client3.project);
|
|
13457
|
+
if (!parsed || parsed.kind !== "jira" || !parsed.key.startsWith(`${client3.project}-`)) {
|
|
13458
|
+
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` });
|
|
13459
|
+
}
|
|
13460
|
+
const issue = await client3.issue(parsed.key, ["summary", "status", "resolution", "reporter"]);
|
|
13461
|
+
const target = await withSituation(client3, {
|
|
13462
|
+
key: parsed.key,
|
|
13463
|
+
summary: issue.fields.summary ?? "",
|
|
13464
|
+
status: issue.fields.status?.name,
|
|
13465
|
+
resolution: issue.fields.resolution?.name,
|
|
13466
|
+
url: client3.browseUrl(parsed.key),
|
|
13467
|
+
...(() => {
|
|
13468
|
+
const hit = raw.find((c2) => c2.key === parsed.key);
|
|
13469
|
+
return hit ? { reason: hit.reason, ...hit.score !== void 0 ? { score: hit.score } : {} } : { reason: "named" };
|
|
13470
|
+
})()
|
|
13471
|
+
}, opts.fingerprint, () => who2.check(issue.fields.reporter));
|
|
13472
|
+
if (appendRefused(target)) {
|
|
13473
|
+
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";
|
|
13474
|
+
throw new CliError30({
|
|
13475
|
+
code: CliErrorCode31.BUSINESS_RULE_VIOLATION,
|
|
13476
|
+
message: `\u6CA1\u6709\u5F80 ${parsed.key} \u8FFD\u52A0\uFF1A${why}`,
|
|
13477
|
+
context: {
|
|
13478
|
+
reasonCode: "append-refused",
|
|
13479
|
+
key: parsed.key,
|
|
13480
|
+
status: target.status ?? null,
|
|
13481
|
+
resolution: target.resolution ?? null,
|
|
13482
|
+
situation: target.situation ?? null,
|
|
13483
|
+
...reporterFields(reporterCheckOf(target)),
|
|
13484
|
+
nextStep: target.advice ?? "\u52A0 --new \u65B0\u5F00\uFF0C\u73B0\u8C61\u91CC\u5199\u4E0A\u539F\u5355\u53F7"
|
|
13485
|
+
}
|
|
13486
|
+
});
|
|
13130
13487
|
}
|
|
13131
|
-
|
|
13132
|
-
|
|
13133
|
-
|
|
13134
|
-
|
|
13135
|
-
"
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
);
|
|
13142
|
-
} else {
|
|
13143
|
-
requiredFields = "checked";
|
|
13144
|
-
requiredChecked = req.checked;
|
|
13488
|
+
if (opts.dryRun) {
|
|
13489
|
+
return {
|
|
13490
|
+
...base,
|
|
13491
|
+
outcome: "dry-run",
|
|
13492
|
+
planned: "append",
|
|
13493
|
+
key: parsed.key,
|
|
13494
|
+
url: target.url,
|
|
13495
|
+
target,
|
|
13496
|
+
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`
|
|
13497
|
+
};
|
|
13145
13498
|
}
|
|
13499
|
+
await client3.addComment(parsed.key, appendBody(g, opts.fingerprint.text, target));
|
|
13500
|
+
return {
|
|
13501
|
+
...base,
|
|
13502
|
+
outcome: "appended",
|
|
13503
|
+
key: parsed.key,
|
|
13504
|
+
url: target.url,
|
|
13505
|
+
summary: target.summary,
|
|
13506
|
+
target,
|
|
13507
|
+
nextStep: appendedNextStep(target, g.alternative)
|
|
13508
|
+
};
|
|
13146
13509
|
}
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13510
|
+
if ((candidates.length || scanned.truncated) && !opts.forceNew) {
|
|
13511
|
+
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` : "";
|
|
13512
|
+
const appendable = candidates.filter((c2) => c2.appendable).map((c2) => c2.key);
|
|
13513
|
+
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
13514
|
return {
|
|
13151
13515
|
...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"
|
|
13516
|
+
outcome: "candidates",
|
|
13517
|
+
nextStep: `\u6CA1\u6709\u63D0\u4EA4\u3002${partial}${choose}\uFF1B\u60F3\u5148\u770B\u4F1A\u5199\u4EC0\u4E48\u518D\u52A0 --dry-run\u3002`
|
|
13161
13518
|
};
|
|
13162
13519
|
}
|
|
13163
|
-
|
|
13164
|
-
|
|
13165
|
-
|
|
13166
|
-
|
|
13167
|
-
|
|
13168
|
-
|
|
13169
|
-
|
|
13520
|
+
const [types, me, project2] = await Promise.all([client3.createMeta(), who2.myself(), client3.projectInfo()]);
|
|
13521
|
+
const built = buildGapFields(g, {
|
|
13522
|
+
types,
|
|
13523
|
+
me: me.name ?? me.key ?? "",
|
|
13524
|
+
assignee: opts.assigneeOverride || project2.lead?.name || project2.lead?.key,
|
|
13525
|
+
project: client3.project,
|
|
13526
|
+
fingerprintText: opts.fingerprint.text,
|
|
13527
|
+
issuetypeOverride: opts.issuetypeOverride,
|
|
13528
|
+
dedupeNote: renderDedupeNote(candidates, raw.length)
|
|
13529
|
+
});
|
|
13530
|
+
if (opts.dryRun) {
|
|
13531
|
+
return {
|
|
13532
|
+
...base,
|
|
13533
|
+
outcome: "dry-run",
|
|
13534
|
+
planned: "create",
|
|
13535
|
+
summary: built.summary,
|
|
13536
|
+
type: built.type.name,
|
|
13537
|
+
module: built.module,
|
|
13538
|
+
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"
|
|
13539
|
+
};
|
|
13540
|
+
}
|
|
13541
|
+
const created = await client3.createIssue(built.fields);
|
|
13542
|
+
return {
|
|
13543
|
+
...base,
|
|
13544
|
+
outcome: "created",
|
|
13545
|
+
key: created.key,
|
|
13546
|
+
url: client3.browseUrl(created.key),
|
|
13547
|
+
summary: built.summary,
|
|
13548
|
+
type: built.type.name,
|
|
13549
|
+
module: built.module,
|
|
13550
|
+
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`
|
|
13551
|
+
};
|
|
13552
|
+
}
|
|
13553
|
+
function searchRow(client3, i) {
|
|
13554
|
+
const state = i.fields.status?.name, resolution = i.fields.resolution?.name;
|
|
13555
|
+
const advice = terminalGapHint({ key: i.key, status: state, resolution });
|
|
13556
|
+
return { where: "Jira", id: i.key, title: i.fields.summary ?? "", state, resolution, url: client3.browseUrl(i.key), ...advice ? { advice } : {} };
|
|
13557
|
+
}
|
|
13558
|
+
async function gapSearch({ client: client3 }, keywords, { includeClosed = true } = {}) {
|
|
13559
|
+
const rows2 = [];
|
|
13560
|
+
let jiraError;
|
|
13561
|
+
let truncated;
|
|
13562
|
+
try {
|
|
13563
|
+
for (const kw of keywords) {
|
|
13564
|
+
const safe = kw.replace(/["\\]/g, " ").trim();
|
|
13565
|
+
const jql = `project = ${client3.project} AND text ~ "${safe}"${includeClosed ? "" : " AND resolution = Unresolved"} ORDER BY updated DESC`;
|
|
13566
|
+
for (const i of await client3.search(jql, { max: 15 })) {
|
|
13567
|
+
rows2.push(searchRow(client3, i));
|
|
13568
|
+
}
|
|
13569
|
+
}
|
|
13570
|
+
if (!rows2.length) {
|
|
13571
|
+
const jql = includeClosed ? gapDedupeJql(client3.project) : `project = ${client3.project} AND resolution = Unresolved ORDER BY created DESC`;
|
|
13572
|
+
const scope = await client3.searchAll(jql, { fields: ["summary", "status", "resolution"] });
|
|
13573
|
+
if (scope.truncated) truncated = { count: scope.issues.length, total: scope.total };
|
|
13574
|
+
for (const i of scope.issues) {
|
|
13575
|
+
if (keywords.some((k) => (i.fields.summary ?? "").includes(k))) {
|
|
13576
|
+
rows2.push(searchRow(client3, i));
|
|
13577
|
+
}
|
|
13578
|
+
}
|
|
13579
|
+
}
|
|
13580
|
+
} catch (e) {
|
|
13581
|
+
jiraError = e.message;
|
|
13582
|
+
}
|
|
13583
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13584
|
+
return { rows: rows2.filter((r) => seen.has(r.id) ? false : (seen.add(r.id), true)), ...jiraError ? { jiraError } : {}, ...truncated ? { truncated } : {} };
|
|
13585
|
+
}
|
|
13586
|
+
var VERIFY_OVERDUE_DAYS = 14;
|
|
13587
|
+
var DAY_MS = 864e5;
|
|
13588
|
+
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`;
|
|
13589
|
+
var verifyCommand = (key2, result = "pass|fail|partial") => `hcm chiron gap verify ${key2} --result ${result} --body <\u8BC1\u636E>`;
|
|
13590
|
+
var entersStatus = (h, status) => (h.items ?? []).some((it) => it.field === "status" && it.toString === status);
|
|
13591
|
+
function lastEnteredStatus(histories, status) {
|
|
13592
|
+
let last;
|
|
13593
|
+
let lastMs = -Infinity;
|
|
13594
|
+
for (const h of histories) {
|
|
13595
|
+
const ms = Date.parse(h.created ?? "");
|
|
13596
|
+
if (entersStatus(h, status) && Number.isFinite(ms) && ms > lastMs) {
|
|
13597
|
+
lastMs = ms;
|
|
13598
|
+
last = h.created;
|
|
13599
|
+
}
|
|
13600
|
+
}
|
|
13601
|
+
return last;
|
|
13602
|
+
}
|
|
13603
|
+
var unparseableEntries = (histories, status) => histories.filter((h) => entersStatus(h, status) && !Number.isFinite(Date.parse(h.created ?? ""))).map((h) => String(h.created ?? "\uFF08\u7A7A\uFF09"));
|
|
13604
|
+
var PENDING_VERIFY_CONCURRENCY = 4;
|
|
13605
|
+
async function gapPendingVerify({ client: client3 }, { now = Date.now(), signal } = {}) {
|
|
13606
|
+
const jql = pendingVerifyJql(client3.project);
|
|
13607
|
+
let pre;
|
|
13608
|
+
try {
|
|
13609
|
+
pre = await client3.searchAll(jql, { fields: ["summary", "status"] });
|
|
13610
|
+
} catch (e) {
|
|
13611
|
+
return {
|
|
13612
|
+
complete: false,
|
|
13613
|
+
items: [],
|
|
13614
|
+
undetermined: [],
|
|
13615
|
+
recentlyRefixed: [],
|
|
13616
|
+
prefilter: { jql, count: 0, total: null, truncated: false },
|
|
13617
|
+
error: firstLine3(String(e.message ?? e)),
|
|
13618
|
+
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"
|
|
13619
|
+
};
|
|
13620
|
+
}
|
|
13621
|
+
const items = [];
|
|
13622
|
+
const undetermined = [];
|
|
13623
|
+
const recentlyRefixed = [];
|
|
13624
|
+
const judge = async (i) => {
|
|
13625
|
+
const base = { key: i.key, summary: i.fields.summary ?? "", url: client3.browseUrl(i.key) };
|
|
13626
|
+
let reason;
|
|
13627
|
+
let fixedAt;
|
|
13628
|
+
let bad = [];
|
|
13629
|
+
if (signal?.aborted) {
|
|
13630
|
+
undetermined.push({ ...base, reason: "\u65F6\u9650\u5230\u4E86\uFF0C\u8FD9\u5F20\u7684 changelog \u6CA1\u8BFB" });
|
|
13631
|
+
return;
|
|
13170
13632
|
}
|
|
13171
|
-
const comment2 = await claimTransitionComment(client3, key2, me, plan.header, body, beforeIds);
|
|
13172
|
-
let after2;
|
|
13173
13633
|
try {
|
|
13174
|
-
|
|
13634
|
+
const cl = await client3.changelog(i.key);
|
|
13635
|
+
if (cl.total === null) reason = "Jira \u6CA1\u62A5 changelog \u603B\u6570\uFF0C\u4E0D\u77E5\u9053\u5386\u53F2\u5168\u4E0D\u5168";
|
|
13636
|
+
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`;
|
|
13637
|
+
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`;
|
|
13638
|
+
else if (!(fixedAt = lastEnteredStatus(cl.histories, FIXED_STATUS))) reason = `changelog \u91CC\u6CA1\u6709\u8FDB\u5165\u300C${FIXED_STATUS}\u300D\u7684\u6D41\u8F6C`;
|
|
13175
13639
|
} 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
|
-
);
|
|
13640
|
+
reason = `\u8BFB changelog \u5931\u8D25\uFF1A${firstLine3(String(e.message ?? e))}`;
|
|
13185
13641
|
}
|
|
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
|
-
);
|
|
13642
|
+
if (reason || !fixedAt) {
|
|
13643
|
+
undetermined.push({ ...base, reason: reason ?? "\u8D77\u7B97\u70B9\u62FF\u4E0D\u5230" });
|
|
13644
|
+
return;
|
|
13198
13645
|
}
|
|
13199
|
-
|
|
13200
|
-
|
|
13201
|
-
|
|
13202
|
-
|
|
13203
|
-
|
|
13204
|
-
|
|
13205
|
-
|
|
13206
|
-
|
|
13207
|
-
|
|
13208
|
-
|
|
13209
|
-
|
|
13210
|
-
|
|
13646
|
+
const elapsed = now - Date.parse(fixedAt);
|
|
13647
|
+
if (elapsed <= VERIFY_OVERDUE_DAYS * DAY_MS) {
|
|
13648
|
+
recentlyRefixed.push(i.key);
|
|
13649
|
+
return;
|
|
13650
|
+
}
|
|
13651
|
+
items.push({ ...base, fixedAt, days: Math.floor(elapsed / DAY_MS), command: verifyCommand(i.key) });
|
|
13652
|
+
};
|
|
13653
|
+
const queue = [...pre.issues];
|
|
13654
|
+
await Promise.all(Array.from({ length: Math.min(PENDING_VERIFY_CONCURRENCY, queue.length) }, async () => {
|
|
13655
|
+
for (let i = queue.shift(); i; i = queue.shift()) await judge(i);
|
|
13656
|
+
}));
|
|
13657
|
+
items.sort((a, b) => b.days - a.days || a.key.localeCompare(b.key, void 0, { numeric: true }));
|
|
13658
|
+
undetermined.sort((a, b) => a.key.localeCompare(b.key, void 0, { numeric: true }));
|
|
13659
|
+
recentlyRefixed.sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
|
|
13660
|
+
const complete = !pre.truncated && undetermined.length === 0;
|
|
13661
|
+
const unsure = [
|
|
13662
|
+
pre.truncated ? `\u9884\u7B5B\u53EA\u770B\u4E86\u524D ${pre.issues.length} \u5F20${pre.total !== null ? `\uFF08\u5171 ${pre.total} \u5F20\uFF09` : ""}` : "",
|
|
13663
|
+
undetermined.length ? `${undetermined.length} \u5F20\u65E0\u6CD5\u5224\u5B9A\uFF08\u89C1\u4E0A\uFF09` : ""
|
|
13664
|
+
].filter(Boolean).join("\uFF0C");
|
|
13665
|
+
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`;
|
|
13666
|
+
return { complete, items, undetermined, recentlyRefixed, prefilter: { jql, count: pre.issues.length, total: pre.total, truncated: pre.truncated }, nextStep };
|
|
13667
|
+
}
|
|
13668
|
+
var PRODUCT_HANDLING_KEYWORDS = /分诊|已转|已修|合入|不做|重复|改技能|产品侧|代码库已关闭/;
|
|
13669
|
+
var HEADLINE_MAX = 300;
|
|
13670
|
+
function commentWhen(created) {
|
|
13671
|
+
const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(created ?? "");
|
|
13672
|
+
return m ? `${m[1]} ${m[2]}` : created ?? "?";
|
|
13673
|
+
}
|
|
13674
|
+
function commentHeadline(body) {
|
|
13675
|
+
const lines = (body ?? "").split("\n").map((l) => l.trim()).filter(Boolean);
|
|
13676
|
+
const first = lines[0] ?? "";
|
|
13677
|
+
const cut = first.length > HEADLINE_MAX;
|
|
13678
|
+
return { headline: cut ? first.slice(0, HEADLINE_MAX) + "\u2026" : first, truncated: cut || lines.length > 1 };
|
|
13679
|
+
}
|
|
13680
|
+
function classifyFollowUp(headline) {
|
|
13681
|
+
if (/阻塞|阻断|未通过|不通过|没通过|没过|退回|失败|(仍|还是|依旧)(然)?(能|可)?复现/.test(headline)) return "blocked";
|
|
13682
|
+
if (/部分(通过|验证|复验|验收|可用)|只(验证|验|测)了/.test(headline)) return "partial";
|
|
13683
|
+
if (/(?<![等待])(复验|验收|验证|复测|回归)(已)?通过(?!\s*(才|后|再))|验证无误/.test(headline)) return "passed";
|
|
13684
|
+
if (/已(经)?(部署|发布|上线|跑)|(部署|发布)(完成|好了)|升级到|更新到/.test(headline)) return "deployed";
|
|
13685
|
+
return void 0;
|
|
13686
|
+
}
|
|
13687
|
+
var AUTO_NOTICE = /^(代码库已关闭:|已在代码库登记:)/;
|
|
13688
|
+
var isAutoNotice = (body) => AUTO_NOTICE.test((body ?? "").trim());
|
|
13689
|
+
function commentTime(c2, index) {
|
|
13690
|
+
const t = Date.parse(c2.created ?? "");
|
|
13691
|
+
return Number.isNaN(t) ? index : t;
|
|
13692
|
+
}
|
|
13693
|
+
function sortComments(cs) {
|
|
13694
|
+
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);
|
|
13695
|
+
}
|
|
13696
|
+
function toView(client3, key2, c2) {
|
|
13697
|
+
const { headline, truncated } = commentHeadline(c2.body);
|
|
13698
|
+
return {
|
|
13699
|
+
id: c2.id,
|
|
13700
|
+
created: c2.created,
|
|
13701
|
+
when: commentWhen(c2.created),
|
|
13702
|
+
author: c2.author?.displayName ?? c2.author?.name ?? "?",
|
|
13703
|
+
headline,
|
|
13704
|
+
truncated,
|
|
13705
|
+
url: c2.id ? client3.commentUrl(key2, c2.id) : void 0
|
|
13706
|
+
};
|
|
13707
|
+
}
|
|
13708
|
+
async function gapStatus({ client: client3 }, ref, casesSlug = CASES_REPO_SLUG3) {
|
|
13709
|
+
const parsed = parseRef2(ref, client3.project, casesSlug);
|
|
13710
|
+
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
13711
|
+
if (parsed.kind === "repo") {
|
|
13712
|
+
throw new Error(
|
|
13713
|
+
`${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`
|
|
13714
|
+
);
|
|
13211
13715
|
}
|
|
13212
|
-
|
|
13213
|
-
|
|
13214
|
-
|
|
13215
|
-
|
|
13216
|
-
|
|
13716
|
+
const issue = await client3.issue(parsed.key);
|
|
13717
|
+
const cs = sortComments(await client3.comments(parsed.key));
|
|
13718
|
+
const status = issue.fields.status?.name;
|
|
13719
|
+
const resolution = issue.fields.resolution?.name;
|
|
13720
|
+
const lines = [`Jira ${issue.key} [${status}${resolution ? "\xB7" + resolution : ""}${issue.fields.priority ? " " + issue.fields.priority.name : ""}] ${issue.fields.summary ?? ""}`, ` ${client3.browseUrl(issue.key)}`];
|
|
13721
|
+
const productRaw = [...cs].reverse().find((c2) => PRODUCT_HANDLING_KEYWORDS.test(c2.body ?? ""));
|
|
13722
|
+
const latestRaw = cs.at(-1);
|
|
13723
|
+
const fullText = `\u5168\u6587\uFF1A\`hcm chiron gap comments ${issue.key}\``;
|
|
13724
|
+
const render2 = (label, v) => [
|
|
13725
|
+
` ${label}\uFF1A${v.headline}${v.truncated ? `\uFF08\u5DF2\u622A\u65AD\uFF0C${fullText}\uFF09` : ""}`,
|
|
13726
|
+
...v.url ? [` ${v.url}`] : []
|
|
13727
|
+
];
|
|
13728
|
+
const stamp = (v) => `${v.when} ${v.author}`;
|
|
13729
|
+
let latestProductComment;
|
|
13730
|
+
let latestComment;
|
|
13731
|
+
let sameAsProduct;
|
|
13732
|
+
if (productRaw) {
|
|
13733
|
+
latestProductComment = toView(client3, issue.key, productRaw);
|
|
13734
|
+
latestProductComment.matchedKeyword = PRODUCT_HANDLING_KEYWORDS.exec(productRaw.body ?? "")?.[0];
|
|
13217
13735
|
}
|
|
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
|
-
);
|
|
13736
|
+
if (latestRaw) {
|
|
13737
|
+
latestComment = toView(client3, issue.key, latestRaw);
|
|
13738
|
+
sameAsProduct = !!productRaw && productRaw === latestRaw;
|
|
13739
|
+
if (!isAutoNotice(latestRaw.body)) latestComment.signal = classifyFollowUp(latestComment.headline);
|
|
13231
13740
|
}
|
|
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
|
-
);
|
|
13741
|
+
const hit = `\u547D\u4E2D\u300C${latestProductComment?.matchedKeyword ?? "?"}\u300D`;
|
|
13742
|
+
if (latestProductComment && latestComment && sameAsProduct) {
|
|
13743
|
+
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
13744
|
} else {
|
|
13245
|
-
|
|
13745
|
+
if (latestProductComment) lines.push(...render2(`\u4EA7\u54C1\u4FA7\u5904\u7406\uFF08${hit}\uFF1B${stamp(latestProductComment)}\uFF09`, latestProductComment));
|
|
13746
|
+
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");
|
|
13747
|
+
if (latestComment) lines.push(...render2(`\u6700\u65B0\u8BC4\u8BBA\uFF08${stamp(latestComment)}\uFF09`, latestComment));
|
|
13246
13748
|
}
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
|
|
13251
|
-
|
|
13252
|
-
|
|
13253
|
-
|
|
13254
|
-
|
|
13749
|
+
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");
|
|
13750
|
+
const remote = (await client3.remoteLinks(parsed.key)).map((l) => l.object?.url ?? "").join("\n");
|
|
13751
|
+
const links = linkedRepoRefs(`${remote}
|
|
13752
|
+
${issue.fields.description ?? ""}
|
|
13753
|
+
${cs.map((c2) => c2.body ?? "").join("\n")}`).map((l) => ({
|
|
13754
|
+
...l,
|
|
13755
|
+
url: repoIssueUrl(l.repo, l.number)
|
|
13756
|
+
}));
|
|
13757
|
+
for (const p of links) lines.push(`\u5DF2\u767B\u8BB0\u4EE3\u7801\u5E93\u6761\u76EE ${p.repo}#${p.number}`, ` ${p.url}`);
|
|
13758
|
+
let nextStep;
|
|
13759
|
+
const verifyCmd = `\`hcm chiron gap verify ${issue.key} --result pass|fail|partial --body <\u8BC1\u636E>\``;
|
|
13760
|
+
if (status === "\u5DF2\u4FEE\u590D") {
|
|
13761
|
+
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`;
|
|
13762
|
+
} else if (status === "CLOSE") {
|
|
13763
|
+
nextStep = `\u8FD9\u5355\u5DF2\u5173\u95ED\uFF0C\u4E0D\u4F1A\u518D\u5F80\u524D\u8D70\u3002${closedGapHint({ key: issue.key, resolution })}\u3002`;
|
|
13764
|
+
} else if (status === "\u8865\u5145\u8BF4\u660E") {
|
|
13765
|
+
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**`;
|
|
13766
|
+
} else if (status === "\u4E0D\u5904\u7406") {
|
|
13767
|
+
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";
|
|
13768
|
+
} else if (status === "\u91CD\u590D\u95EE\u9898") {
|
|
13769
|
+
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`;
|
|
13770
|
+
} else if (status === "\u7EB3\u5165\u89C4\u5212") {
|
|
13771
|
+
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";
|
|
13772
|
+
} 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`;
|
|
13773
|
+
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";
|
|
13774
|
+
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";
|
|
13775
|
+
else if (status && status !== "\u65B0\u589E") {
|
|
13776
|
+
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`;
|
|
13777
|
+
} 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`;
|
|
13778
|
+
const stillOpen = status !== "CLOSE" && status !== DUPLICATE_STATUS && (status === "\u5DF2\u4FEE\u590D" || !resolution);
|
|
13779
|
+
if (latestComment && stillOpen) {
|
|
13780
|
+
const cite = `${latestComment.when} ${latestComment.author}\uFF1A\u300C${latestComment.headline}\u300D`;
|
|
13781
|
+
const tail = latestComment.truncated ? `\uFF08${fullText}\uFF09` : "";
|
|
13782
|
+
const canVerify = status === "\u5DF2\u4FEE\u590D";
|
|
13783
|
+
const waitFixed = "\u7B49\u4EA7\u54C1\u4FA7\u628A\u5355\u63A8\u5230\u300C\u5DF2\u4FEE\u590D\u300D";
|
|
13784
|
+
switch (latestComment.signal) {
|
|
13785
|
+
case "passed":
|
|
13786
|
+
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`;
|
|
13787
|
+
break;
|
|
13788
|
+
case "deployed":
|
|
13789
|
+
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`);
|
|
13790
|
+
break;
|
|
13791
|
+
case "partial":
|
|
13792
|
+
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`);
|
|
13793
|
+
break;
|
|
13794
|
+
case "blocked":
|
|
13795
|
+
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`;
|
|
13796
|
+
break;
|
|
13797
|
+
default:
|
|
13798
|
+
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`;
|
|
13799
|
+
}
|
|
13800
|
+
}
|
|
13801
|
+
return { ref, lines, nextStep, jira: { key: issue.key, status, resolution, url: client3.browseUrl(issue.key) }, links, latestProductComment, latestComment, sameAsProduct };
|
|
13802
|
+
}
|
|
13803
|
+
async function gapComments({ client: client3 }, ref, { limit } = {}, casesSlug = CASES_REPO_SLUG3) {
|
|
13804
|
+
const parsed = parseRef2(ref, client3.project, casesSlug);
|
|
13805
|
+
if (!parsed) throw new Error(`\u770B\u4E0D\u61C2 ${ref}\uFF1A\u7ED9 Jira \u5355\u53F7\uFF08HCMNX-12\uFF09`);
|
|
13806
|
+
if (parsed.kind === "repo") {
|
|
13807
|
+
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
13808
|
}
|
|
13809
|
+
if (limit !== void 0 && (!Number.isInteger(limit) || limit < 1)) throw new Error(`--limit \u8981\u662F\u6B63\u6574\u6570\uFF0C\u7ED9\u7684\u662F ${String(limit)}`);
|
|
13810
|
+
const all = sortComments(await client3.comments(parsed.key));
|
|
13811
|
+
const picked = limit !== void 0 ? all.slice(-limit) : all;
|
|
13256
13812
|
return {
|
|
13257
|
-
|
|
13258
|
-
|
|
13259
|
-
|
|
13260
|
-
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13813
|
+
ref,
|
|
13814
|
+
key: parsed.key,
|
|
13815
|
+
url: client3.browseUrl(parsed.key),
|
|
13816
|
+
total: all.length,
|
|
13817
|
+
shown: picked.length,
|
|
13818
|
+
comments: picked.map((c2) => ({
|
|
13819
|
+
id: c2.id,
|
|
13820
|
+
created: c2.created,
|
|
13821
|
+
when: commentWhen(c2.created),
|
|
13822
|
+
author: c2.author?.displayName ?? c2.author?.name ?? "?",
|
|
13823
|
+
body: (c2.body ?? "").trim(),
|
|
13824
|
+
url: c2.id ? client3.commentUrl(parsed.key, c2.id) : void 0
|
|
13825
|
+
}))
|
|
13266
13826
|
};
|
|
13267
13827
|
}
|
|
13268
13828
|
|
|
@@ -13286,22 +13846,58 @@ async function gapSearchCommand(keywords, args, deps = defaultDeps) {
|
|
|
13286
13846
|
await run2(async () => {
|
|
13287
13847
|
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
13848
|
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
|
-
});
|
|
13849
|
+
emit5(args.output, r, () => renderGapSearch(r));
|
|
13850
|
+
if (r.jiraError) process.exitCode = 4;
|
|
13297
13851
|
});
|
|
13298
13852
|
}
|
|
13853
|
+
function renderGapSearch(r) {
|
|
13854
|
+
const list = r.rows.map((i) => {
|
|
13855
|
+
const hint = terminalGapHint({ key: i.id, status: i.state, resolution: i.resolution });
|
|
13856
|
+
return `${i.where} ${i.id} [${i.state}${i.resolution ? "\xB7" + i.resolution : ""}] ${i.title}
|
|
13857
|
+
${i.url}${hint ? `
|
|
13858
|
+
\u2192 ${hint}` : ""}`;
|
|
13859
|
+
}).join("\n");
|
|
13860
|
+
if (r.jiraError) {
|
|
13861
|
+
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
|
|
13862
|
+
${list}
|
|
13863
|
+
` : "\u4E00\u6761\u90FD\u6CA1\u67E5\u5230\uFF0C\u8FD9\u4E0D\u4EE3\u8868 Jira \u91CC\u6CA1\u6709\u3002\n";
|
|
13864
|
+
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`;
|
|
13865
|
+
}
|
|
13866
|
+
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
|
|
13867
|
+
` : "";
|
|
13868
|
+
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`;
|
|
13869
|
+
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
|
|
13870
|
+
${list}`;
|
|
13871
|
+
}
|
|
13299
13872
|
async function gapStatusCommand(ref, args, deps = defaultDeps) {
|
|
13300
13873
|
await run2(async () => {
|
|
13874
|
+
if (!ref) {
|
|
13875
|
+
const r2 = await gapPendingVerify(await gapDeps(deps));
|
|
13876
|
+
emit5(args.output, r2, () => renderPendingVerify(r2));
|
|
13877
|
+
if (r2.error) process.exitCode = 4;
|
|
13878
|
+
return;
|
|
13879
|
+
}
|
|
13301
13880
|
const r = await gapStatus(await gapDeps(deps), ref);
|
|
13302
13881
|
emit5(args.output, r, () => [...r.lines, `\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`].join("\n"));
|
|
13303
13882
|
});
|
|
13304
13883
|
}
|
|
13884
|
+
function renderPendingVerify(r) {
|
|
13885
|
+
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
|
|
13886
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13887
|
+
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`;
|
|
13888
|
+
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}
|
|
13889
|
+
${i.url}
|
|
13890
|
+
\u590D\u9A8C\u540E\uFF1A${i.command}`);
|
|
13891
|
+
const unsure = r.undetermined.map((u) => ` ${u.key} \xB7 \u65E0\u6CD5\u5224\u5B9A\uFF1A${u.reason}
|
|
13892
|
+
${u.url}`);
|
|
13893
|
+
return [
|
|
13894
|
+
head,
|
|
13895
|
+
...items,
|
|
13896
|
+
...unsure.length ? ["\u65E0\u6CD5\u5224\u5B9A\uFF1A", ...unsure] : [],
|
|
13897
|
+
...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")}`] : [],
|
|
13898
|
+
`\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`
|
|
13899
|
+
].join("\n");
|
|
13900
|
+
}
|
|
13305
13901
|
function parseLimit(raw) {
|
|
13306
13902
|
if (raw === void 0) return void 0;
|
|
13307
13903
|
const n = typeof raw === "number" ? raw : Number(String(raw).trim());
|
|
@@ -13329,6 +13925,42 @@ async function gapCommentsCommand(ref, args, deps = defaultDeps) {
|
|
|
13329
13925
|
emit5(args.output, r, () => renderGapComments(r));
|
|
13330
13926
|
});
|
|
13331
13927
|
}
|
|
13928
|
+
var revisionLine = (c2) => comparesVersions(c2.situation) ? `
|
|
13929
|
+
\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"}` : "";
|
|
13930
|
+
var candidateLine = (c2) => ` ${c2.key} [${c2.status ?? "?"}${c2.resolution ? "\xB7" + c2.resolution : ""}] ${reasonText(c2)}
|
|
13931
|
+
${c2.summary}
|
|
13932
|
+
${c2.url}${revisionLine(c2)}${c2.advice ? `
|
|
13933
|
+
\u2192 ${c2.advice}` : ""}`;
|
|
13934
|
+
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"}`;
|
|
13935
|
+
function renderGapSubmit(r) {
|
|
13936
|
+
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" : ""}`;
|
|
13937
|
+
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` : "";
|
|
13938
|
+
const cands = r.candidates.length ? `
|
|
13939
|
+
\u76F8\u4F3C\u5355 ${r.candidateTotal} \u5F20\uFF08\u53EA\u662F\u50CF\uFF0C\u4E0D\u662F\u5224\u5B9A${more}\uFF09\uFF1A
|
|
13940
|
+
${r.candidates.map(candidateLine).join("\n")}` : "";
|
|
13941
|
+
switch (r.outcome) {
|
|
13942
|
+
case "candidates":
|
|
13943
|
+
return `${scan}${cands}
|
|
13944
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13945
|
+
case "dry-run":
|
|
13946
|
+
return r.planned === "append" ? `${scan}
|
|
13947
|
+
[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 ? `
|
|
13948
|
+
\u2192 ${r.target.advice}` : ""}` : ""}
|
|
13949
|
+
${workaroundLine(r)}
|
|
13950
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}` : `${scan}${cands}
|
|
13951
|
+
[dry-run] \u4F1A\u65B0\u5F00\uFF1A${r.summary}\uFF08${r.type} \xB7 ${r.module}\uFF09
|
|
13952
|
+
${workaroundLine(r)}
|
|
13953
|
+
\u4E0B\u4E00\u6B65\uFF1A${r.nextStep}`;
|
|
13954
|
+
case "appended":
|
|
13955
|
+
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
|
|
13956
|
+
${r.url}
|
|
13957
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A${r.nextStep}`;
|
|
13958
|
+
case "created":
|
|
13959
|
+
return `\u5DF2\u63D0 ${r.key}\uFF08${r.type} \xB7 ${r.module}\uFF09\uFF1A${r.url}${r.candidates.length ? `
|
|
13960
|
+
\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` : ""}` : ""}
|
|
13961
|
+
\u7ED9\u987E\u95EE\u7684\u8BDD\uFF1A${r.nextStep}`;
|
|
13962
|
+
}
|
|
13963
|
+
}
|
|
13332
13964
|
function backendFingerprint2(info, cliVersion, envName) {
|
|
13333
13965
|
const commit = info.commit ?? info.gitCommit ?? null;
|
|
13334
13966
|
const backend = commit ? String(commit).slice(0, 12) : `\u672A\u56DE commit\uFF08version=${info.version ?? "?"}\uFF09`;
|
|
@@ -13353,31 +13985,30 @@ async function fingerprintInfo(env2) {
|
|
|
13353
13985
|
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
13986
|
}
|
|
13355
13987
|
}
|
|
13356
|
-
async function fingerprintText(env2) {
|
|
13357
|
-
return (await fingerprintInfo(env2)).text;
|
|
13358
|
-
}
|
|
13359
13988
|
async function gapSubmitCommand(args, deps = defaultDeps) {
|
|
13360
13989
|
await run2(async () => {
|
|
13361
13990
|
const raw = args.file ? readFileSync6(args.file, "utf8") : process.stdin.isTTY ? "" : readFileSync6(0, "utf8");
|
|
13362
13991
|
if (!raw.trim()) throw new Error("\u7F3A\u53E3\u8F7D\u8377\uFF1A--file <gap.json> \u6216\u4ECE\u6807\u51C6\u8F93\u5165\u5582 JSON");
|
|
13992
|
+
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
13993
|
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
|
-
);
|
|
13994
|
+
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);
|
|
13995
|
+
const r = await gapSubmit(await gapDeps(deps), gap2, {
|
|
13996
|
+
fingerprint: fp,
|
|
13997
|
+
issuetypeOverride: args.issuetype,
|
|
13998
|
+
assigneeOverride: args.assignee,
|
|
13999
|
+
appendTo: args.appendTo,
|
|
14000
|
+
forceNew: args.new,
|
|
14001
|
+
dryRun: args.dryRun
|
|
14002
|
+
});
|
|
14003
|
+
emit5(args.output, r, () => renderGapSubmit(r));
|
|
14004
|
+
if (r.outcome === "candidates") process.exitCode = 3;
|
|
13374
14005
|
});
|
|
13375
14006
|
}
|
|
13376
14007
|
function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = () => readFileSync6(0, "utf8")) {
|
|
13377
14008
|
if (opts.file !== void 0 && opts.body !== void 0) {
|
|
13378
14009
|
throw verifyFailure(
|
|
13379
14010
|
"evidence-ambiguous",
|
|
13380
|
-
|
|
14011
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13381
14012
|
"no",
|
|
13382
14013
|
"--body \u4E0E --file \u540C\u65F6\u7ED9\u4E86\uFF0C\u4E0D\u77E5\u9053\u8BE5\u7528\u54EA\u4EFD\u505A\u9A8C\u6536\u8BC1\u636E",
|
|
13383
14014
|
"\u53EA\u7559\u4E00\u4E2A\uFF1A\u77ED\u8BC1\u636E\u7528 --body\uFF0C\u957F\u8BC1\u636E\u5199\u8FDB\u6587\u4EF6\u7528 --file\u3002"
|
|
@@ -13389,7 +14020,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13389
14020
|
} catch (e) {
|
|
13390
14021
|
throw verifyFailure(
|
|
13391
14022
|
"evidence-unreadable",
|
|
13392
|
-
|
|
14023
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13393
14024
|
"no",
|
|
13394
14025
|
`\u8BFB\u4E0D\u5230\u8BC1\u636E\u6587\u4EF6 ${opts.file}`,
|
|
13395
14026
|
"\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 +14033,7 @@ function readEvidence(opts, stdinIsTTY = !!process.stdin.isTTY, readStdin2 = ()
|
|
|
13402
14033
|
if (stdinIsTTY) {
|
|
13403
14034
|
throw verifyFailure(
|
|
13404
14035
|
"evidence-missing",
|
|
13405
|
-
|
|
14036
|
+
CliErrorCode32.INVALID_ARGUMENT,
|
|
13406
14037
|
"no",
|
|
13407
14038
|
"\u6CA1\u7ED9\u9A8C\u6536\u8BC1\u636E",
|
|
13408
14039
|
"\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 +14055,9 @@ var FINGERPRINT_SOURCE_TEXT = {
|
|
|
13424
14055
|
function renderGapVerify(r) {
|
|
13425
14056
|
const lines = [];
|
|
13426
14057
|
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
|
|
14058
|
+
else if (r.outcome === "already-closed" && r.before.resolution !== DONE_RESOLUTION) {
|
|
14059
|
+
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`);
|
|
14060
|
+
} else lines.push(VERIFY_OUTCOME_TEXT[r.outcome]);
|
|
13428
14061
|
lines.push(`Jira ${r.key} ${r.summary}`, ` ${r.url}`, ` \u63D0\u5355\u4EBA ${r.reporter} \xB7 \u5F53\u524D\u8EAB\u4EFD ${r.me}`);
|
|
13429
14062
|
if (r.outcome !== "already-closed") {
|
|
13430
14063
|
const to = r.after?.status ?? r.transition?.to ?? r.before.status;
|
|
@@ -13456,13 +14089,12 @@ async function gapVerifyCommand(ref, args, deps = defaultDeps) {
|
|
|
13456
14089
|
}
|
|
13457
14090
|
|
|
13458
14091
|
// src/commands/chiron-doctor.ts
|
|
13459
|
-
init_auth_guard();
|
|
13460
14092
|
import { promises as fs13 } from "fs";
|
|
13461
14093
|
import path15 from "path";
|
|
13462
14094
|
import axios10 from "axios";
|
|
13463
14095
|
import {
|
|
13464
|
-
CliError as
|
|
13465
|
-
CliErrorCode as
|
|
14096
|
+
CliError as CliError36,
|
|
14097
|
+
CliErrorCode as CliErrorCode37,
|
|
13466
14098
|
formatObject as formatObject30,
|
|
13467
14099
|
httpProbe as httpProbe2,
|
|
13468
14100
|
listEnvs as listEnvs2,
|
|
@@ -13474,8 +14106,10 @@ import {
|
|
|
13474
14106
|
resolveEnvContext as resolveEnvContext9,
|
|
13475
14107
|
printResolvedEnvironment as printResolvedEnvironment9,
|
|
13476
14108
|
conversationWebSocketEndpoint as conversationWebSocketEndpoint4,
|
|
13477
|
-
probeConversationHandshake
|
|
14109
|
+
probeConversationHandshake,
|
|
14110
|
+
createJiraClient as createJiraClient2
|
|
13478
14111
|
} from "@hcmai/sdk";
|
|
14112
|
+
init_auth_guard();
|
|
13479
14113
|
|
|
13480
14114
|
// src/commands/chiron-env.ts
|
|
13481
14115
|
init_exit();
|
|
@@ -13485,8 +14119,8 @@ import yaml from "js-yaml";
|
|
|
13485
14119
|
import {
|
|
13486
14120
|
AUTH_INFO_PATH as AUTH_INFO_PATH2,
|
|
13487
14121
|
assertNotReservedEnvName as assertNotReservedEnvName3,
|
|
13488
|
-
CliError as
|
|
13489
|
-
CliErrorCode as
|
|
14122
|
+
CliError as CliError31,
|
|
14123
|
+
CliErrorCode as CliErrorCode33,
|
|
13490
14124
|
discoverProjectEnv as discoverProjectEnv6,
|
|
13491
14125
|
ENV_FILE as ENV_FILE2,
|
|
13492
14126
|
findEnvByEndpoint as findEnvByEndpoint5,
|
|
@@ -13509,7 +14143,7 @@ function summarizeReasons(reasons) {
|
|
|
13509
14143
|
return reasons.length === 1 ? reasons[0] : `${reasons[0]} \u7B49 ${reasons.length} \u6761\uFF08--output json \u770B\u5168\u90E8\uFF09`;
|
|
13510
14144
|
}
|
|
13511
14145
|
function invalid2(message, nextStep) {
|
|
13512
|
-
throw new
|
|
14146
|
+
throw new CliError31({ code: CliErrorCode33.INVALID_ARGUMENT, message, context: { nextStep } });
|
|
13513
14147
|
}
|
|
13514
14148
|
function required(value, label) {
|
|
13515
14149
|
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 +14367,8 @@ import os5 from "os";
|
|
|
13733
14367
|
import path13 from "path";
|
|
13734
14368
|
import yaml2 from "js-yaml";
|
|
13735
14369
|
import {
|
|
13736
|
-
CliError as
|
|
13737
|
-
CliErrorCode as
|
|
14370
|
+
CliError as CliError32,
|
|
14371
|
+
CliErrorCode as CliErrorCode34,
|
|
13738
14372
|
METHOD_REPO_DISPLAY,
|
|
13739
14373
|
METHOD_REPO_URL,
|
|
13740
14374
|
assertSafeSkillId as assertSafeSkillId2,
|
|
@@ -13775,8 +14409,8 @@ function gitErrorText(e) {
|
|
|
13775
14409
|
function classifyGitFailure(e, repoDisplay) {
|
|
13776
14410
|
const err = e;
|
|
13777
14411
|
if (err.code === "ENOENT") {
|
|
13778
|
-
return new
|
|
13779
|
-
code:
|
|
14412
|
+
return new CliError32({
|
|
14413
|
+
code: CliErrorCode34.METHOD_GIT_UNAVAILABLE,
|
|
13780
14414
|
message: "\u672C\u673A\u627E\u4E0D\u5230 git\uFF0C\u53D6\u65B9\u6CD5\u5305\u9760\u5B83",
|
|
13781
14415
|
context: { nextStep: "\u88C5\u4E0A git\uFF08`git --version` \u80FD\u8DD1\u901A\uFF09\uFF0C\u518D\u91CD\u8DD1\u8FD9\u6761\u547D\u4EE4" }
|
|
13782
14416
|
});
|
|
@@ -13784,15 +14418,15 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13784
14418
|
const text = gitErrorText(e);
|
|
13785
14419
|
const head = text.split("\n").filter(Boolean).slice(-3).join(" / ").slice(0, 400);
|
|
13786
14420
|
if (err.code === "ETIMEDOUT" || err.signal === "SIGTERM") {
|
|
13787
|
-
return new
|
|
13788
|
-
code:
|
|
14421
|
+
return new CliError32({
|
|
14422
|
+
code: CliErrorCode34.METHOD_SOURCE_NETWORK,
|
|
13789
14423
|
message: `git \u5728\u65F6\u9650\u5185\u6CA1\u6709\u8FD4\u56DE\uFF08${repoDisplay}\uFF09`,
|
|
13790
14424
|
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
14425
|
});
|
|
13792
14426
|
}
|
|
13793
14427
|
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:
|
|
14428
|
+
return new CliError32({
|
|
14429
|
+
code: CliErrorCode34.METHOD_SOURCE_AUTH_REQUIRED,
|
|
13796
14430
|
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
14431
|
context: { nextStep: "`cnb login` \u4E4B\u540E\u91CD\u8DD1\u3002\u65B9\u6CD5\u5305\u8D70\u7684\u662F git \u51ED\u636E\uFF0C\u4E0D\u662F `hcm login`" }
|
|
13798
14432
|
});
|
|
@@ -13800,8 +14434,8 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13800
14434
|
const notFound = /returned error: 404|Repository not found|repository '.*' not found|does not appear to be a git repository/i.test(text);
|
|
13801
14435
|
if (/returned error: 403|403 Forbidden|access denied|not authorized/i.test(text) || notFound) {
|
|
13802
14436
|
const overridden = Boolean(process.env.HCM_METHOD_REPO?.trim() || process.env.HCM_METHOD_REPO_URL?.trim());
|
|
13803
|
-
return new
|
|
13804
|
-
code:
|
|
14437
|
+
return new CliError32({
|
|
14438
|
+
code: CliErrorCode34.METHOD_SOURCE_FORBIDDEN,
|
|
13805
14439
|
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
14440
|
context: {
|
|
13807
14441
|
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,20 +14443,38 @@ function classifyGitFailure(e, repoDisplay) {
|
|
|
13809
14443
|
});
|
|
13810
14444
|
}
|
|
13811
14445
|
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:
|
|
14446
|
+
return new CliError32({
|
|
14447
|
+
code: CliErrorCode34.METHOD_SOURCE_NETWORK,
|
|
13814
14448
|
message: `\u8FDE\u4E0D\u4E0A\u65B9\u6CD5\u8BBA\u4ED3\uFF08${repoDisplay}\uFF09\uFF1A${head}`,
|
|
13815
14449
|
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
14450
|
});
|
|
13817
14451
|
}
|
|
13818
|
-
return new
|
|
13819
|
-
code:
|
|
14452
|
+
return new CliError32({
|
|
14453
|
+
code: CliErrorCode34.METHOD_SOURCE_GIT_FAILED,
|
|
13820
14454
|
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
14455
|
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
14456
|
});
|
|
13823
14457
|
}
|
|
13824
14458
|
function makeGitRunner(repoDisplay) {
|
|
13825
14459
|
return async (args, opts = {}) => {
|
|
14460
|
+
const env2 = { ...process.env, GIT_TERMINAL_PROMPT: "0", GCM_INTERACTIVE: "never" };
|
|
14461
|
+
for (const key2 of [
|
|
14462
|
+
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
|
|
14463
|
+
"GIT_CONFIG",
|
|
14464
|
+
"GIT_CONFIG_PARAMETERS",
|
|
14465
|
+
"GIT_CONFIG_COUNT",
|
|
14466
|
+
"GIT_OBJECT_DIRECTORY",
|
|
14467
|
+
"GIT_DIR",
|
|
14468
|
+
"GIT_WORK_TREE",
|
|
14469
|
+
"GIT_IMPLICIT_WORK_TREE",
|
|
14470
|
+
"GIT_GRAFT_FILE",
|
|
14471
|
+
"GIT_INDEX_FILE",
|
|
14472
|
+
"GIT_NO_REPLACE_OBJECTS",
|
|
14473
|
+
"GIT_REPLACE_REF_BASE",
|
|
14474
|
+
"GIT_PREFIX",
|
|
14475
|
+
"GIT_SHALLOW_FILE",
|
|
14476
|
+
"GIT_COMMON_DIR"
|
|
14477
|
+
]) delete env2[key2];
|
|
13826
14478
|
try {
|
|
13827
14479
|
const pending = promisify2(execFile2)("git", args, {
|
|
13828
14480
|
cwd: opts.cwd,
|
|
@@ -13830,7 +14482,7 @@ function makeGitRunner(repoDisplay) {
|
|
|
13830
14482
|
maxBuffer: 1 << 26,
|
|
13831
14483
|
timeout: opts.timeoutMs ?? GIT_NETWORK_TIMEOUT_MS,
|
|
13832
14484
|
// 🔴 不许 git 停下来问口令:agent 跑它时没人回答,只会一直挂着。凭据缺就当场报认证失败。
|
|
13833
|
-
env:
|
|
14485
|
+
env: env2
|
|
13834
14486
|
});
|
|
13835
14487
|
pending.child.stdin?.end();
|
|
13836
14488
|
const { stdout } = await pending;
|
|
@@ -13885,15 +14537,25 @@ function latestVersionTag(tags) {
|
|
|
13885
14537
|
return [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).pop();
|
|
13886
14538
|
}
|
|
13887
14539
|
async function listRemoteTags(deps) {
|
|
13888
|
-
|
|
14540
|
+
const context = await fsp4.mkdtemp(path13.join(os5.tmpdir(), "hcm-method-tags-"));
|
|
14541
|
+
try {
|
|
14542
|
+
await deps.git(["init", "--quiet", context], { timeoutMs: 1e4 });
|
|
14543
|
+
await deps.git(["remote", "add", "origin", deps.repoUrl], { cwd: context, timeoutMs: 1e4 });
|
|
14544
|
+
return parseLsRemoteTags(await deps.git(["ls-remote", "--tags", deps.repoUrl], {
|
|
14545
|
+
cwd: context,
|
|
14546
|
+
timeoutMs: GIT_LS_REMOTE_TIMEOUT_MS
|
|
14547
|
+
}));
|
|
14548
|
+
} finally {
|
|
14549
|
+
await fsp4.rm(context, { recursive: true, force: true });
|
|
14550
|
+
}
|
|
13889
14551
|
}
|
|
13890
14552
|
function resolveRef(tags, ref, deps) {
|
|
13891
14553
|
const versions = [...tags.keys()].filter((t) => SEMVER_TAG.test(t)).sort(compareTags).reverse();
|
|
13892
14554
|
if (ref === void 0) {
|
|
13893
14555
|
const latest = versions[0];
|
|
13894
14556
|
if (!latest) {
|
|
13895
|
-
throw new
|
|
13896
|
-
code:
|
|
14557
|
+
throw new CliError32({
|
|
14558
|
+
code: CliErrorCode34.METHOD_REF_NOT_FOUND,
|
|
13897
14559
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u4E00\u4E2A vX.Y.Z \u5F62\u5F0F\u7684\u7248\u672C tag \u90FD\u6CA1\u6709`,
|
|
13898
14560
|
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
14561
|
});
|
|
@@ -13902,8 +14564,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13902
14564
|
}
|
|
13903
14565
|
const name = tags.has(ref) ? ref : tags.has(`v${ref}`) ? `v${ref}` : void 0;
|
|
13904
14566
|
if (!name) {
|
|
13905
|
-
throw new
|
|
13906
|
-
code:
|
|
14567
|
+
throw new CliError32({
|
|
14568
|
+
code: CliErrorCode34.METHOD_REF_NOT_FOUND,
|
|
13907
14569
|
message: `\u65B9\u6CD5\u8BBA\u4ED3 ${deps.repoDisplay} \u91CC\u6CA1\u6709 tag ${ref}`,
|
|
13908
14570
|
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
14571
|
});
|
|
@@ -13911,8 +14573,8 @@ function resolveRef(tags, ref, deps) {
|
|
|
13911
14573
|
return { ref: name, commit: tags.get(name) };
|
|
13912
14574
|
}
|
|
13913
14575
|
function invalidPackage(field, message) {
|
|
13914
|
-
return new
|
|
13915
|
-
code:
|
|
14576
|
+
return new CliError32({
|
|
14577
|
+
code: CliErrorCode34.METHOD_PACKAGE_INVALID,
|
|
13916
14578
|
message: `\u65B9\u6CD5\u5305\u6E05\u5355 package.yml \u4E0D\u5408\u683C\uFF1A${message}`,
|
|
13917
14579
|
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
14580
|
});
|
|
@@ -13936,8 +14598,8 @@ function parsePackageManifest(text) {
|
|
|
13936
14598
|
throw invalidPackage("schemaVersion", "\u7F3A schemaVersion\uFF08\u6574\u6570\uFF09");
|
|
13937
14599
|
}
|
|
13938
14600
|
if (!KNOWN_PACKAGE_SCHEMA_VERSIONS.includes(m.schemaVersion)) {
|
|
13939
|
-
throw new
|
|
13940
|
-
code:
|
|
14601
|
+
throw new CliError32({
|
|
14602
|
+
code: CliErrorCode34.METHOD_PACKAGE_SCHEMA_UNSUPPORTED,
|
|
13941
14603
|
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
14604
|
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
14605
|
});
|
|
@@ -14151,7 +14813,8 @@ async function checkMethodConflicts(methodIds, root, online, deps) {
|
|
|
14151
14813
|
b.conflicts = b.compared.filter((id) => wanted.has(id)).map((id) => ({ id, other: where }));
|
|
14152
14814
|
}
|
|
14153
14815
|
} catch (e) {
|
|
14154
|
-
|
|
14816
|
+
const reason = e instanceof CliError32 && typeof e.context?.reason === "string" ? `\uFF1A${e.context.reason}` : "";
|
|
14817
|
+
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
14818
|
}
|
|
14156
14819
|
}
|
|
14157
14820
|
blocks.push(b);
|
|
@@ -14173,8 +14836,8 @@ function renderConflictBlocks(blocks) {
|
|
|
14173
14836
|
}
|
|
14174
14837
|
function conflictError(blocks, pkg, commit) {
|
|
14175
14838
|
const hits = blocks.flatMap((b) => b.conflicts);
|
|
14176
|
-
return new
|
|
14177
|
-
code:
|
|
14839
|
+
return new CliError32({
|
|
14840
|
+
code: CliErrorCode34.SKILL_ID_CONFLICT,
|
|
14178
14841
|
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
14842
|
context: {
|
|
14180
14843
|
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 +14852,8 @@ function upsertManagedBlock(existing, begin, end, block, label) {
|
|
|
14189
14852
|
const finish = existing.indexOf(end);
|
|
14190
14853
|
const malformed = start < 0 !== finish < 0 || start >= 0 && (finish < start || existing.lastIndexOf(begin) !== start || existing.lastIndexOf(end) !== finish);
|
|
14191
14854
|
if (malformed) {
|
|
14192
|
-
throw new
|
|
14193
|
-
code:
|
|
14855
|
+
throw new CliError32({
|
|
14856
|
+
code: CliErrorCode34.METHOD_MANAGED_BLOCK_CORRUPT,
|
|
14194
14857
|
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
14858
|
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
14859
|
});
|
|
@@ -14254,8 +14917,8 @@ async function readLock(root) {
|
|
|
14254
14917
|
if (e.code === "ENOENT") return void 0;
|
|
14255
14918
|
throw e;
|
|
14256
14919
|
}
|
|
14257
|
-
const bad = (why) => new
|
|
14258
|
-
code:
|
|
14920
|
+
const bad = (why) => new CliError32({
|
|
14921
|
+
code: CliErrorCode34.METHOD_LOCK_INVALID,
|
|
14259
14922
|
message: `\u9501\u6587\u4EF6 ${METHOD_DIR}/${METHOD_LOCK_FILE} \u8BFB\u4E0D\u61C2\uFF1A${why}`,
|
|
14260
14923
|
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
14924
|
});
|
|
@@ -14295,7 +14958,7 @@ async function resolveMethodRoot(project2, log) {
|
|
|
14295
14958
|
async function resolveTarget(root, requested) {
|
|
14296
14959
|
if (requested === "claude" || requested === "codex") return requested;
|
|
14297
14960
|
if (requested !== void 0 && requested !== "auto") {
|
|
14298
|
-
throw new
|
|
14961
|
+
throw new CliError32({ code: CliErrorCode34.INVALID_ARGUMENT, message: `--target \u53EA\u8BA4 claude / codex / auto\uFF0C\u6536\u5230 ${requested}` });
|
|
14299
14962
|
}
|
|
14300
14963
|
return (await readState(root))?.target ?? await detectTarget(root) ?? "claude";
|
|
14301
14964
|
}
|
|
@@ -14437,8 +15100,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14437
15100
|
const tags = await listRemoteTags(deps);
|
|
14438
15101
|
const r = resolveRef(tags, input.ref, deps);
|
|
14439
15102
|
if (input.expectCommit && r.commit !== input.expectCommit) {
|
|
14440
|
-
throw new
|
|
14441
|
-
code:
|
|
15103
|
+
throw new CliError32({
|
|
15104
|
+
code: CliErrorCode34.METHOD_TAG_MOVED,
|
|
14442
15105
|
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
15106
|
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
15107
|
});
|
|
@@ -14453,8 +15116,8 @@ async function runMethodPipeline(input, deps) {
|
|
|
14453
15116
|
await deps.git(["clone", "--depth", "1", "--filter=blob:none", "--sparse", "--quiet", "--branch", resolved.ref, deps.repoUrl, checkout]);
|
|
14454
15117
|
const head = (await deps.git(["-C", checkout, "rev-parse", "HEAD"], { timeoutMs: 1e4 })).trim();
|
|
14455
15118
|
if (head !== resolved.commit) {
|
|
14456
|
-
throw new
|
|
14457
|
-
code:
|
|
15119
|
+
throw new CliError32({
|
|
15120
|
+
code: CliErrorCode34.METHOD_TAG_MOVED,
|
|
14458
15121
|
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
15122
|
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
15123
|
});
|
|
@@ -14633,7 +15296,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14633
15296
|
verdict: "fail",
|
|
14634
15297
|
detail: `\u6CA1\u6709 ${METHOD_DIR}/${METHOD_LOCK_FILE}\uFF1A\u8FD9\u4E2A\u9879\u76EE\u8FD8\u6CA1\u88C5\u65B9\u6CD5\u5305`,
|
|
14635
15298
|
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:
|
|
15299
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED
|
|
14637
15300
|
});
|
|
14638
15301
|
return done();
|
|
14639
15302
|
}
|
|
@@ -14647,7 +15310,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14647
15310
|
verdict: "fail",
|
|
14648
15311
|
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
15312
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684\u7248\u672C\u88C5\uFF09",
|
|
14650
|
-
code:
|
|
15313
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED
|
|
14651
15314
|
});
|
|
14652
15315
|
} else {
|
|
14653
15316
|
report.installed.present = true;
|
|
@@ -14658,7 +15321,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14658
15321
|
verdict: "fail",
|
|
14659
15322
|
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
15323
|
nextStep: "`hcm chiron method install`\uFF08\u6309\u9501\u6587\u4EF6\u7684 commit \u91CD\u88C5\uFF09",
|
|
14661
|
-
code:
|
|
15324
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14662
15325
|
});
|
|
14663
15326
|
} else {
|
|
14664
15327
|
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 +15365,13 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14702
15365
|
verdict: "fail",
|
|
14703
15366
|
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
15367
|
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:
|
|
15368
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14706
15369
|
} : {
|
|
14707
15370
|
item: "\u6458\u8981",
|
|
14708
15371
|
verdict: "fail",
|
|
14709
15372
|
detail: `${bad.length} \u4EFD\u6587\u4EF6\u4E0E\u6E05\u5355\u4E0D\u7B26\uFF1A${listing}`,
|
|
14710
15373
|
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:
|
|
15374
|
+
code: CliErrorCode34.METHOD_DIGEST_MISMATCH
|
|
14712
15375
|
});
|
|
14713
15376
|
} else {
|
|
14714
15377
|
report.rows.push({
|
|
@@ -14731,7 +15394,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14731
15394
|
verdict: "warn",
|
|
14732
15395
|
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
15396
|
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:
|
|
15397
|
+
code: CliErrorCode34.METHOD_TAG_MOVED
|
|
14735
15398
|
});
|
|
14736
15399
|
} else if (!SEMVER_TAG.test(lock.ref) || !report.remote.latestTag) {
|
|
14737
15400
|
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 +15439,7 @@ async function runMethodStatus(root, deps, opts = {}) {
|
|
|
14776
15439
|
const hits = report.conflictCheck.flatMap((b) => b.conflicts);
|
|
14777
15440
|
const unchecked = report.conflictCheck.filter((b) => !b.checked);
|
|
14778
15441
|
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:
|
|
15442
|
+
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
15443
|
}
|
|
14781
15444
|
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
15445
|
return done();
|
|
@@ -14795,10 +15458,10 @@ async function inspectMethodForDoctor(root, deps = quietDeps()) {
|
|
|
14795
15458
|
const row = (item) => s.rows.find((r) => r.item === item);
|
|
14796
15459
|
const lockRow = row("\u9501\u5B9A");
|
|
14797
15460
|
if (!s.lock) {
|
|
14798
|
-
return lockRow.code ===
|
|
15461
|
+
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
15462
|
}
|
|
14800
15463
|
const install = row("\u5B89\u88C5");
|
|
14801
|
-
if (install?.code ===
|
|
15464
|
+
if (install?.code === CliErrorCode34.METHOD_NOT_INSTALLED) {
|
|
14802
15465
|
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
15466
|
}
|
|
14804
15467
|
const local = [install, row("\u6458\u8981")].find((r) => r && r.verdict === "fail");
|
|
@@ -14831,8 +15494,8 @@ async function runMethodUpdate(args, deps = defaultMethodDeps()) {
|
|
|
14831
15494
|
const { root, rootSource } = await resolveMethodRoot(args.project, deps.log);
|
|
14832
15495
|
const lock = await readLock(root);
|
|
14833
15496
|
if (!lock) {
|
|
14834
|
-
throw new
|
|
14835
|
-
code:
|
|
15497
|
+
throw new CliError32({
|
|
15498
|
+
code: CliErrorCode34.METHOD_NOT_INSTALLED,
|
|
14836
15499
|
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
15500
|
context: { nextStep: "`hcm chiron method install`\uFF08\u88C5\u6700\u65B0\u7684\u7248\u672C tag\uFF09" }
|
|
14838
15501
|
});
|
|
@@ -14882,7 +15545,7 @@ async function methodStatusCommand(args) {
|
|
|
14882
15545
|
import { promises as fs12 } from "fs";
|
|
14883
15546
|
import path14 from "path";
|
|
14884
15547
|
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";
|
|
15548
|
+
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
15549
|
|
|
14887
15550
|
// src/commands/doctor/result.ts
|
|
14888
15551
|
import { createHash as createHash7 } from "crypto";
|
|
@@ -14936,8 +15599,9 @@ function makeResult(descriptor2, observation, env2, target, requestedAt, duratio
|
|
|
14936
15599
|
grade: target ? o.grade ?? "WARN" : "WARN",
|
|
14937
15600
|
coverage,
|
|
14938
15601
|
evidence: o.evidence ?? "DIRECT",
|
|
14939
|
-
|
|
14940
|
-
|
|
15602
|
+
...o.value !== void 0 ? { value: o.value } : {},
|
|
15603
|
+
// 带了 reason 的 FOUND 是「发现了,但看到的数据不全」:结构上标 degraded,调用方不用去读摘要
|
|
15604
|
+
...o.reason ? { degraded: true, reason: o.reason } : { degraded: false }
|
|
14941
15605
|
};
|
|
14942
15606
|
break;
|
|
14943
15607
|
case "UNDETERMINED":
|
|
@@ -14971,13 +15635,27 @@ var credential = async (_ctx, env2) => {
|
|
|
14971
15635
|
const slot = await env2.credential();
|
|
14972
15636
|
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
15637
|
};
|
|
15638
|
+
var isPrerelease = (v) => /^\d+\.\d+\.\d+-/.test((v ?? "").trim());
|
|
15639
|
+
function parseCliVersion(v) {
|
|
15640
|
+
const m = /^(\d+)\.(\d+)\.(\d+)(?:[-+][0-9A-Za-z.-]+)?$/.exec((v ?? "").trim());
|
|
15641
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
15642
|
+
}
|
|
14974
15643
|
var version = async (ctx) => {
|
|
14975
15644
|
const latest = await ctx.services.latestVersion();
|
|
14976
15645
|
if (latest === null) return unknown("CLI_LATEST_UNKNOWN");
|
|
14977
|
-
const
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
15646
|
+
const current = parseCliVersion(ctx.cliVersion), newest = parseCliVersion(latest);
|
|
15647
|
+
if (!current || !newest) {
|
|
15648
|
+
const bad = [!current && `\u672C\u673A CLI\u300C${ctx.cliVersion}\u300D`, !newest && `npm \u6700\u65B0\u300C${latest}\u300D`].filter(Boolean).join("\u3001");
|
|
15649
|
+
return unknown(
|
|
15650
|
+
"CLI_VERSION_UNPARSEABLE",
|
|
15651
|
+
`${bad} \u4E0D\u662F X.Y.Z \u7248\u672C\u53F7\uFF0C\u6CA1\u6CD5\u6BD4\u8F83\u65B0\u65E7`,
|
|
15652
|
+
// 最新版本写死从 registry.npmjs.org 取(fetchLatestVersion),与本机 npm 的 registry 配置无关:对照时也指定这个源
|
|
15653
|
+
{ 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" }
|
|
15654
|
+
);
|
|
15655
|
+
}
|
|
15656
|
+
const first = newest.findIndex((v, i) => v !== current[i]);
|
|
15657
|
+
const behind = first >= 0 ? newest[first] > current[first] : isPrerelease(ctx.cliVersion) && !isPrerelease(latest);
|
|
15658
|
+
return behind ? found("CLI_OUTDATED", `CLI ${ctx.cliVersion}\uFF0Cnpm \u6700\u65B0 ${latest}`) : pass(`CLI ${ctx.cliVersion}\uFF0Cnpm \u6700\u65B0 ${latest}`);
|
|
14981
15659
|
};
|
|
14982
15660
|
var installed = async (ctx) => {
|
|
14983
15661
|
let reading = "";
|
|
@@ -15052,6 +15730,11 @@ async function inspectSkillsFresh(states, endpoint, signal) {
|
|
|
15052
15730
|
const entries = plans.flatMap((p) => p.plan.entries);
|
|
15053
15731
|
return classifySkillFreshness(states.length, entries, plans.flatMap((p) => p.mismatched));
|
|
15054
15732
|
} catch (error) {
|
|
15733
|
+
if (error instanceof CliError33 && error.code === CliErrorCode35.SKILL_CATALOG_UNAVAILABLE) {
|
|
15734
|
+
const reason = typeof error.context?.reason === "string" ? `\uFF1A${error.context.reason}` : "";
|
|
15735
|
+
const next = typeof error.context?.nextStep === "string" ? error.context.nextStep : void 0;
|
|
15736
|
+
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 } : {});
|
|
15737
|
+
}
|
|
15055
15738
|
return unknown("SKILLS_CATALOG_UNCHECKED", void 0, { note: safeError(error) });
|
|
15056
15739
|
}
|
|
15057
15740
|
}
|
|
@@ -15108,18 +15791,80 @@ var cases = async (ctx) => {
|
|
|
15108
15791
|
var jira = async (ctx) => {
|
|
15109
15792
|
const status = await ctx.services.inspectJira({ httpTimeoutMs: 8e3 });
|
|
15110
15793
|
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);
|
|
15794
|
+
const code2 = status.code ?? (status.tokenReadError ? "JIRA_TOKEN_UNREADABLE" : "JIRA_UNCLASSIFIED");
|
|
15795
|
+
const undetermined = ["JIRA_SERVER_ERROR", "JIRA_UNREACHABLE", "JIRA_TOKEN_UNREADABLE", "JIRA_UNCLASSIFIED"].includes(code2);
|
|
15113
15796
|
return (undetermined ? unknown : found)(code2, void 0, {
|
|
15114
15797
|
note: [status.reason, status.nextStep, !status.code ? "\u672A\u80FD\u5224\u522B\u5931\u8D25\u7C7B\u578B" : void 0].filter(Boolean).join("\uFF1B")
|
|
15115
15798
|
});
|
|
15116
15799
|
};
|
|
15117
|
-
var
|
|
15800
|
+
var pendingVerify = async (ctx, _env, execution) => {
|
|
15801
|
+
let r;
|
|
15802
|
+
try {
|
|
15803
|
+
r = await ctx.services.pendingVerify(execution?.signal);
|
|
15804
|
+
} catch (error) {
|
|
15805
|
+
return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: `\u5F85\u590D\u9A8C\u6E05\u5355\u6CA1\u67E5\u6210\uFF1A${safeError(error)}` });
|
|
15806
|
+
}
|
|
15807
|
+
if (r.error) return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: `\u5F85\u590D\u9A8C\u6E05\u5355\u67E5\u8BE2\u5931\u8D25\uFF1A${r.error}` });
|
|
15808
|
+
const gaps = [
|
|
15809
|
+
r.undetermined.length ? `${r.undetermined.length} \u5F20\u65E0\u6CD5\u5224\u5B9A` : "",
|
|
15810
|
+
r.prefilter.truncated ? `\u9884\u7B5B\u53EA\u770B\u4E86 ${r.prefilter.count}${r.prefilter.total !== null ? `/${r.prefilter.total}` : ""} \u5F20` : ""
|
|
15811
|
+
].filter(Boolean).join("\u3001");
|
|
15812
|
+
const why = r.undetermined.map((u) => `${u.key}\uFF1A${u.reason}`).join("\uFF1B");
|
|
15813
|
+
if (r.items.length) {
|
|
15814
|
+
return found(
|
|
15815
|
+
"GAPS_VERIFY_PENDING",
|
|
15816
|
+
`${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`}`,
|
|
15817
|
+
{ value: r.items.length, ...r.complete ? {} : { reason: "TRUNCATED", note: why || r.nextStep } }
|
|
15818
|
+
);
|
|
15819
|
+
}
|
|
15820
|
+
if (!r.complete) {
|
|
15821
|
+
return unknown("GAPS_VERIFY_UNKNOWN", void 0, { note: r.undetermined.map((u) => `${u.key}\uFF1A${u.reason}`).join("\uFF1B") || r.nextStep });
|
|
15822
|
+
}
|
|
15823
|
+
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 });
|
|
15824
|
+
};
|
|
15825
|
+
var shadow = async (ctx) => {
|
|
15826
|
+
const localDir = skillsLocalDir(ctx.root);
|
|
15827
|
+
let r;
|
|
15828
|
+
try {
|
|
15829
|
+
r = await listShadowedSkills({ baseDir: skillsSyncDir(ctx.root), localDir });
|
|
15830
|
+
} catch (error) {
|
|
15831
|
+
const where = error instanceof SkillsDirUnreadable ? path14.relative(ctx.root, error.where) : path14.relative(ctx.root, localDir);
|
|
15832
|
+
const detail = error instanceof SkillsDirUnreadable ? safeError(new Error(error.detail)) : safeError(error);
|
|
15833
|
+
const u = error instanceof SkillsDirUnreadable ? error : void 0;
|
|
15834
|
+
const side = `${u?.side === "sync" ? `${SKILLS_DIR}/sync/` : `${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/`}${u?.id ? ` \u91CC\u7684 ${u.id}` : ""}`;
|
|
15835
|
+
return unknown(
|
|
15836
|
+
"SKILLS_LOCAL_UNREADABLE",
|
|
15837
|
+
`${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`,
|
|
15838
|
+
{ note: `${where}\uFF1A${detail}` }
|
|
15839
|
+
);
|
|
15840
|
+
}
|
|
15841
|
+
const others = r.unreadable.length ? `\uFF1Bsync/ \u53E6\u6709 ${r.unreadable.length} \u6761\u8BFB\u4E0D\u4E86\u3001\u6CA1\u7B97\u8FDB\u53BB\uFF1A${describeUnreadable(r.unreadable)}` : "";
|
|
15842
|
+
const raw = r.unreadable.map((x) => `${path14.relative(ctx.root, x.where)}\uFF1A${safeError(new Error(x.detail))}`).join("\uFF1B");
|
|
15843
|
+
if (r.shadowed.length) {
|
|
15844
|
+
return found(
|
|
15845
|
+
"SKILLS_LOCAL_SHADOW",
|
|
15846
|
+
`${SKILLS_DIR}/${SKILLS_LOCAL_SUBDIR}/ \u906E\u853D\u4E86 ${r.shadowed.length} \u4EFD\u4EA7\u54C1\u6280\u80FD\uFF1A${describeShadows(r.shadowed)}${others}`,
|
|
15847
|
+
{ value: r.shadowed.length, note: raw ? `${SHADOW_HINT} \u8BFB\u4E0D\u4E86\u7684\uFF1A${raw}` : SHADOW_HINT }
|
|
15848
|
+
);
|
|
15849
|
+
}
|
|
15850
|
+
if (!r.product) {
|
|
15851
|
+
if (r.unreadable.length) {
|
|
15852
|
+
return unknown(
|
|
15853
|
+
"SKILLS_LOCAL_UNREADABLE",
|
|
15854
|
+
`${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`,
|
|
15855
|
+
{ note: raw }
|
|
15856
|
+
);
|
|
15857
|
+
}
|
|
15858
|
+
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` };
|
|
15859
|
+
}
|
|
15860
|
+
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}` } : {} });
|
|
15861
|
+
};
|
|
15862
|
+
var localChecks = { project, credential, version, installed, fresh, shadow, boundary, method, cases, jira, pendingVerify };
|
|
15118
15863
|
|
|
15119
15864
|
// src/commands/doctor/connect-checks.ts
|
|
15120
15865
|
init_auth_guard();
|
|
15121
15866
|
import axios8 from "axios";
|
|
15122
|
-
import { CliError as
|
|
15867
|
+
import { CliError as CliError34, IMPERSONATION_START_PATH, USER_LOOKUP_PATH, probeDoctorEndpoint, probeDoctorLayer, layerDetail, toPrincipal as toPrincipal3 } from "@hcmai/sdk";
|
|
15123
15868
|
|
|
15124
15869
|
// src/commands/doctor/server-report.ts
|
|
15125
15870
|
import axios7 from "axios";
|
|
@@ -15291,9 +16036,9 @@ function reconcileReport(ctx, env2, report, requested, platformOps) {
|
|
|
15291
16036
|
for (const key2 of ["only", "skip"]) if (!sameTokens(echo?.[key2], requested[key2])) both2(`scope.${key2} \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26`);
|
|
15292
16037
|
if (echo?.active !== requested.active) both2("scope.active \u56DE\u663E\u4E0E\u8BF7\u6C42\u4E0D\u7B26");
|
|
15293
16038
|
}
|
|
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
16039
|
}
|
|
16040
|
+
if (report.returnedCount !== report.results.length || report.totalCount !== report.scopeIds.length)
|
|
16041
|
+
both2(`\u8BA1\u6570\u4E0D\u7B26\uFF1AreturnedCount=${report.returnedCount}\uFF0Cresults.length=${report.results.length}\uFF1BtotalCount=${report.totalCount}\uFF0CscopeIds.length=${report.scopeIds.length}`);
|
|
15297
16042
|
const groups = /* @__PURE__ */ new Map();
|
|
15298
16043
|
for (const row of report.results) groups.set(row.checkId, [...groups.get(row.checkId) ?? [], row]);
|
|
15299
16044
|
for (const [id, group] of groups) {
|
|
@@ -15302,23 +16047,30 @@ function reconcileReport(ctx, env2, report, requested, platformOps) {
|
|
|
15302
16047
|
issue("platform", `${id}\uFF1A\u8FD0\u7EF4\u62A5\u544A\u7ED3\u679C\u5C42\u4E0D\u662F platform`);
|
|
15303
16048
|
continue;
|
|
15304
16049
|
}
|
|
15305
|
-
if (!
|
|
16050
|
+
if (!scope.has(id)) {
|
|
15306
16051
|
issue(row.layer, `${id}\uFF1A\u7ED3\u679C\u8D8A\u51FA\u672C\u6B21\u8303\u56F4`);
|
|
15307
16052
|
continue;
|
|
15308
16053
|
}
|
|
15309
16054
|
const why = group.length > 1 ? `\u540C\u4E00 id \u51FA\u73B0 ${group.length} \u6761` : verdictViolation(row);
|
|
15310
16055
|
rows2.push(why ? rewrite(row, group, why) : { ...row, env: env2.name });
|
|
15311
16056
|
}
|
|
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
|
-
}
|
|
16057
|
+
for (const id of expected) if (!rows2.some((row) => row.checkId === id))
|
|
16058
|
+
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
16059
|
const selected = (layer2) => (layer2 === "platform" || layer2 === "tenant") && (platformOps ? layer2 === "platform" : !ctx.scope || ctx.scope.serverLayers.has(layer2));
|
|
15317
16060
|
const marks = /* @__PURE__ */ new Map();
|
|
15318
16061
|
for (const [layer2, notes] of issues) {
|
|
15319
16062
|
const home = selected(layer2) ? layer2 : platformOps ? "platform" : SERVER_PLACEHOLDERS.map((d) => d.layer).find(selected);
|
|
15320
16063
|
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
16064
|
}
|
|
16065
|
+
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";
|
|
16066
|
+
if (changed) for (const notes of marks.values()) notes.push(unverifiable);
|
|
16067
|
+
if (changed) for (const layer2 of SERVER_PLACEHOLDERS.map((d) => d.layer).filter(selected)) {
|
|
16068
|
+
if (marks.has(layer2)) continue;
|
|
16069
|
+
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", {
|
|
16070
|
+
reason: "SOURCE_UNAVAILABLE",
|
|
16071
|
+
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}`
|
|
16072
|
+
})).filter((r) => r.layer === layer2));
|
|
16073
|
+
}
|
|
15322
16074
|
for (const [layer2, notes] of marks) {
|
|
15323
16075
|
env2.report.server.verdict = null;
|
|
15324
16076
|
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 +16139,13 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
|
|
|
15387
16139
|
scope: { ...requested, policyDisabled: details.policyDisabled },
|
|
15388
16140
|
recoveryCommand: typeof error.next_step === "string" ? error.next_step : void 0
|
|
15389
16141
|
};
|
|
15390
|
-
env2.report.server
|
|
15391
|
-
|
|
16142
|
+
Object.assign(env2.report.server, {
|
|
16143
|
+
verdict: null,
|
|
16144
|
+
degraded: true,
|
|
16145
|
+
reason: "POLICY_DISABLED_400",
|
|
16146
|
+
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"}`
|
|
16147
|
+
});
|
|
16148
|
+
return reconcileReport(ctx, env2, env2.serverReport, requested);
|
|
15392
16149
|
}
|
|
15393
16150
|
const failure2 = failedReport(out, env2, ctx.as);
|
|
15394
16151
|
if (failure2) return placeholderRows(ctx, env2, failure2, Date.now() - started);
|
|
@@ -15401,12 +16158,23 @@ async function fetchServerReport(ctx, env2, dependencies, deadline, requested =
|
|
|
15401
16158
|
catalogRevision: report.catalogRevision ?? null
|
|
15402
16159
|
});
|
|
15403
16160
|
if (catalogChanged(env2.catalog, report)) {
|
|
16161
|
+
const before = env2.catalog?.catalogRevision;
|
|
16162
|
+
let why, reason = "CATALOG_REFETCH_FAILED";
|
|
15404
16163
|
try {
|
|
15405
16164
|
const refreshed = await ctx.services.probe(env2.config.endpoint, env2.token, controller.signal).get("/api/system/health/checks");
|
|
15406
16165
|
const catalog = refreshed.status === 200 ? parseCatalog(refreshed.body) : void 0;
|
|
15407
16166
|
if (catalog && catalog.catalogRevision === report.catalogRevision) env2.catalog = catalog;
|
|
15408
|
-
|
|
16167
|
+
const unversioned = !!catalog && (catalog.catalogRevision === null || catalog.catalogRevision === void 0);
|
|
16168
|
+
if (catalog && !unversioned) reason = "CATALOG_STILL_CHANGING";
|
|
16169
|
+
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" : ""}`;
|
|
16170
|
+
} catch (error2) {
|
|
16171
|
+
why = `\u91CD\u53D6 /checks \u6CA1\u6210\uFF1A${safeError(error2)}`;
|
|
15409
16172
|
}
|
|
16173
|
+
if (why) Object.assign(env2.report.server, {
|
|
16174
|
+
degraded: true,
|
|
16175
|
+
reason,
|
|
16176
|
+
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}`
|
|
16177
|
+
});
|
|
15410
16178
|
}
|
|
15411
16179
|
return reconcileReport(ctx, env2, report, requested);
|
|
15412
16180
|
} catch (error) {
|
|
@@ -15472,8 +16240,8 @@ var identity = async (ctx, env2, execution) => {
|
|
|
15472
16240
|
if (execution.signal.aborted) await e.close?.();
|
|
15473
16241
|
return observation;
|
|
15474
16242
|
} catch (error) {
|
|
15475
|
-
const detail = error instanceof
|
|
15476
|
-
const errorCode = error instanceof
|
|
16243
|
+
const detail = error instanceof CliError34 ? error.context : void 0;
|
|
16244
|
+
const errorCode = error instanceof CliError34 ? error.code : void 0;
|
|
15477
16245
|
const actorStep = error !== null && typeof error === "object" ? error[AS_ACTOR_STEP] : void 0;
|
|
15478
16246
|
if (actorStep) {
|
|
15479
16247
|
const actorCode = actorStep === "meta" || actorStep === "env" ? "IDENTITY_META_INVALID" : actorStep === "resolve" && errorCode === "IDENTITY_NOT_FOUND" ? "IDENTITY_NOT_LOGGED_IN" : "IDENTITY_UNVERIFIED";
|
|
@@ -15596,6 +16364,7 @@ var CODE_TABLE = {
|
|
|
15596
16364
|
CREDENTIAL_MISSING: c("\u6CA1\u6709\u5339\u914D endpoint \u4E0E\u79DF\u6237\u7684\u672C\u673A\u51ED\u636E\u69FD", "CRITICAL", "FDE", login),
|
|
15597
16365
|
CLI_OUTDATED: c("CLI \u843D\u540E\u4E8E npm \u6700\u65B0\u7248", "WARN", "FDE", () => "hcm upgrade"),
|
|
15598
16366
|
CLI_LATEST_UNKNOWN: c("\u53D6\u4E0D\u5230 npm \u6700\u65B0\u7248\u672C\uFF1B\u68C0\u67E5 registry \u7F51\u7EDC\u540E\u91CD\u8BD5"),
|
|
16367
|
+
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
16368
|
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
16369
|
SKILLS_EMPTY: c("\u4E24\u79CD\u5E03\u5C40\u4E0B\u6280\u80FD\u5747\u4E3A\u7A7A", "CRITICAL", "FDE", both),
|
|
15601
16370
|
SKILLS_LEGACY_LAYOUT: c("\u4EC5\u6709\u65E7\u6241\u5E73\u5E03\u5C40\u7684\u6280\u80FD", "WARN", "FDE", (e) => sync(e, "codex")),
|
|
@@ -15604,6 +16373,10 @@ var CODE_TABLE = {
|
|
|
15604
16373
|
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
16374
|
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
16375
|
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),
|
|
16376
|
+
// 不给 sync 命令:服务端目录修好之前跑 sync 只会再停一次;下一步是 note 里服务端给的那句
|
|
16377
|
+
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"),
|
|
16378
|
+
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>"),
|
|
16379
|
+
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
16380
|
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
16381
|
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
16382
|
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 +16390,10 @@ var CODE_TABLE = {
|
|
|
15617
16390
|
JIRA_PROJECT_INVISIBLE: c("\u770B\u4E0D\u5230 Jira \u9879\u76EE\uFF1B\u8BF7 Jira \u7BA1\u7406\u5458\u6838\u5BF9\u9879\u76EE\u6743\u9650"),
|
|
15618
16391
|
JIRA_SERVER_ERROR: c("Jira \u670D\u52A1\u8FD4\u56DE\u9519\u8BEF\uFF1B\u68C0\u67E5 Jira \u670D\u52A1\u72B6\u6001\u540E\u91CD\u8BD5"),
|
|
15619
16392
|
JIRA_UNREACHABLE: c("Jira \u8FDE\u4E0D\u4E0A\uFF1B\u68C0\u67E5\u7F51\u7EDC\u6216\u4EE3\u7406\u540E\u91CD\u8BD5"),
|
|
16393
|
+
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
16394
|
JIRA_TOKEN_UNREADABLE: c("Jira \u4EE4\u724C\u8BFB\u4E0D\u5230\uFF1B\u68C0\u67E5\u4EE4\u724C\u6765\u6E90\uFF0C\u6216\u6539\u7528 JIRA_TOKEN"),
|
|
16395
|
+
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"),
|
|
16396
|
+
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
16397
|
BACKEND_UNREACHABLE: c("\u540E\u7AEF\u4E0D\u53EF\u8FBE\uFF1B\u68C0\u67E5\u5730\u5740\u3001\u7F51\u7EDC\u4E0E\u4EE3\u7406", "CRITICAL"),
|
|
15622
16398
|
BACKEND_SERVER_ERROR: c("\u540E\u7AEF\u8FD4\u56DE\u670D\u52A1\u9519\u8BEF\uFF1B\u68C0\u67E5\u670D\u52A1\u65E5\u5FD7", "CRITICAL"),
|
|
15623
16399
|
BACKEND_NOT_JSON: c("\u4E0D\u662F\u540E\u7AEF JSON\uFF1B\u68C0\u67E5\u540E\u7AEF\u5730\u5740\u548C\u53CD\u4EE3", "CRITICAL"),
|
|
@@ -15647,6 +16423,7 @@ var CODE_TABLE = {
|
|
|
15647
16423
|
REPORT_UNAVAILABLE: c("\u670D\u52A1\u7AEF\u4F53\u68C0\u63A5\u53E3\u6682\u4E0D\u53EF\u7528\uFF1B\u7A0D\u540E\u91CD\u8BD5"),
|
|
15648
16424
|
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
16425
|
REPORT_ITEM_MISSING: c("\u670D\u52A1\u7AEF\u62A5\u544A\u91CC\u6CA1\u6709\u8FD9\u4E00\u9879", "WARN", "RND"),
|
|
16426
|
+
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
16427
|
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
16428
|
BUDGET_EXHAUSTED: c("\u9884\u7B97\u8017\u5C3D\uFF0C\u672A\u542F\u52A8\uFF1B\u7A0D\u540E\u91CD\u8DD1")
|
|
15652
16429
|
};
|
|
@@ -15656,13 +16433,14 @@ function codeStep(code2, env2) {
|
|
|
15656
16433
|
return { owner: row?.owner ?? "FDE", ...row?.command ? { command: row.command(env2) } : {} };
|
|
15657
16434
|
}
|
|
15658
16435
|
var allStages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16436
|
+
var NOT_AT_GOLIVE = /* @__PURE__ */ new Set(["local.cli.version", "local.skills.shadow"]);
|
|
15659
16437
|
function descriptor(id, name, dependsOn, codes, timeoutMs, run3, optional = false, owner = "FDE") {
|
|
15660
16438
|
return {
|
|
15661
16439
|
id,
|
|
15662
16440
|
name,
|
|
15663
16441
|
layer: id.startsWith("local.") ? "local" : "connect",
|
|
15664
16442
|
requirement: optional ? "OPTIONAL" : "REQUIRED",
|
|
15665
|
-
stages: id === "connect.exposure" ? ["golive", "operate"] : optional || id
|
|
16443
|
+
stages: id === "connect.exposure" ? ["golive", "operate"] : optional || NOT_AT_GOLIVE.has(id) ? allStages.filter((s) => s !== "golive") : allStages,
|
|
15666
16444
|
coverageForm: "SINGLE",
|
|
15667
16445
|
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
16446
|
owner,
|
|
@@ -15675,13 +16453,15 @@ function descriptor(id, name, dependsOn, codes, timeoutMs, run3, optional = fals
|
|
|
15675
16453
|
var CHECKS = [
|
|
15676
16454
|
descriptor("local.project.env", "\u9879\u76EE\u73AF\u5883", [], ["ENV_FILE_MISSING", "ENV_FILE_INVALID", "ENV_NOT_RESOLVED"], 5e3, localChecks.project),
|
|
15677
16455
|
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),
|
|
16456
|
+
descriptor("local.cli.version", "CLI \u7248\u672C", [], ["CLI_OUTDATED", "CLI_LATEST_UNKNOWN", "CLI_VERSION_UNPARSEABLE"], 1e4, localChecks.version),
|
|
15679
16457
|
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),
|
|
16458
|
+
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),
|
|
16459
|
+
descriptor("local.skills.shadow", "\u672C\u5730\u906E\u853D", [], ["SKILLS_LOCAL_SHADOW", "SKILLS_LOCAL_UNREADABLE"], 5e3, localChecks.shadow),
|
|
15681
16460
|
descriptor("local.boundary", "\u9879\u76EE\u8FB9\u754C", [], ["BOUNDARY_MISSING", "BOUNDARY_FALLBACK"], 5e3, localChecks.boundary),
|
|
15682
16461
|
descriptor("local.method", "\u65B9\u6CD5\u5305", [], ["METHOD_NOT_INSTALLED", "METHOD_UNCHECKED", "METHOD_COPY_MISMATCH", "METHOD_OUTDATED"], 35e3, localChecks.method, true),
|
|
15683
16462
|
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),
|
|
16463
|
+
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),
|
|
16464
|
+
descriptor("local.gaps.verify", "\u5F85\u590D\u9A8C\u7F3A\u53E3", ["local.jira"], ["GAPS_VERIFY_PENDING", "GAPS_VERIFY_UNKNOWN"], 3e4, localChecks.pendingVerify, true),
|
|
15685
16465
|
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
16466
|
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
16467
|
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 +16485,7 @@ var SERVER_PLACEHOLDERS = ["platform", "tenant"].map((layer2) => ({
|
|
|
15705
16485
|
"REPORT_UNAVAILABLE",
|
|
15706
16486
|
"REPORT_MALFORMED",
|
|
15707
16487
|
"REPORT_ITEM_MISSING",
|
|
16488
|
+
"REPORT_CATALOG_CHANGED",
|
|
15708
16489
|
"SERVER_VERDICT_INVALID",
|
|
15709
16490
|
"BUDGET_EXHAUSTED"
|
|
15710
16491
|
]
|
|
@@ -15968,6 +16749,26 @@ function renderPolicyDisabled(rows2, catalog, recoveryCommand, rerun) {
|
|
|
15968
16749
|
indented(recovery(row, rows2, catalog, recoveryCommand, rerun))
|
|
15969
16750
|
])].join("\n");
|
|
15970
16751
|
}
|
|
16752
|
+
function nextStepLine(step2, rerun) {
|
|
16753
|
+
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}`);
|
|
16754
|
+
return `\u2192 ${what}${step2.command && step2.skill ? ` \xB7 \u6280\u80FD ${step2.skill}` : ""} [${step2.owner}]`;
|
|
16755
|
+
}
|
|
16756
|
+
var TOKEN_TEXT = {
|
|
16757
|
+
"server-catalog-unknown": "\u670D\u52A1\u7AEF\u68C0\u67E5\u76EE\u5F55\u672A\u77E5",
|
|
16758
|
+
"platform-ops-only": "\u5171\u4EAB\u90E8\u7F72\u4E0A\u5E73\u53F0\u5C42\u53EA\u5BF9\u5E73\u53F0\u8FD0\u7EF4\u53EF\u89C1",
|
|
16759
|
+
"platform-ops-view": "\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42",
|
|
16760
|
+
"tenant-definitions-unavailable": "\u79DF\u6237\u5C42\u68C0\u67E5\u5B9A\u4E49\u8BFB\u4E0D\u5230",
|
|
16761
|
+
"catalog-changed": "\u6838\u9A8C\u671F\u95F4\u68C0\u67E5\u76EE\u5F55\u53D1\u751F\u53D8\u5316",
|
|
16762
|
+
"no-environment": "\u76EE\u6807\u73AF\u5883\u672A\u89E3\u6790"
|
|
16763
|
+
};
|
|
16764
|
+
function scopeLine(report) {
|
|
16765
|
+
const s = report.scope;
|
|
16766
|
+
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);
|
|
16767
|
+
const ran = new Set(report.results.filter((r) => (r.env === null || r.env === report.targetEnv) && r.verdict.level !== "NOT_RUN").map((r) => r.checkId));
|
|
16768
|
+
const done = s.addedPrerequisites.filter((id) => ran.has(id)), idle = s.addedPrerequisites.filter((id) => !ran.has(id));
|
|
16769
|
+
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` : "");
|
|
16770
|
+
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}`;
|
|
16771
|
+
}
|
|
15971
16772
|
function renderChironDoctor(report) {
|
|
15972
16773
|
const target = report.environments.find((env2) => env2.target);
|
|
15973
16774
|
const version2 = target?.backend.version;
|
|
@@ -16017,7 +16818,7 @@ function renderChironDoctor(report) {
|
|
|
16017
16818
|
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
16819
|
if (outside) {
|
|
16019
16820
|
for (const item of matching) if (item.nextStep?.command)
|
|
16020
|
-
out.push(indented(
|
|
16821
|
+
out.push(indented(nextStepLine(item.nextStep, rerun)));
|
|
16021
16822
|
}
|
|
16022
16823
|
continue;
|
|
16023
16824
|
}
|
|
@@ -16027,18 +16828,20 @@ function renderChironDoctor(report) {
|
|
|
16027
16828
|
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
16829
|
}
|
|
16029
16830
|
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(
|
|
16831
|
+
if (v?.level !== "PASS" && row.nextStep && (v?.level !== "NOT_APPLICABLE" || row.nextStep.command || row.nextStep.skill)) out.push(indented(nextStepLine(row.nextStep, rerun)));
|
|
16031
16832
|
}
|
|
16032
16833
|
}
|
|
16033
16834
|
const active = report.results.filter(isOptIn).length;
|
|
16034
16835
|
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
16836
|
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}`);
|
|
16837
|
+
out.push(scopeLine(report));
|
|
16036
16838
|
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
16839
|
const policyCatalog = reportCatalogs.get(report), disabled = report.scope.policyDisabled;
|
|
16038
16840
|
if (disabled.length) out.push(`\u9009\u68C0\u672A\u542F\u7528\uFF1A${disabled.map((r) => policyDescription(r, policyCatalog)).join("\uFF1B")}`);
|
|
16039
16841
|
for (const row of disabled.filter((r) => report.scope.only.includes(r.id)))
|
|
16040
16842
|
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
16843
|
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");
|
|
16844
|
+
if (!platformOps && target?.server.note) out.push(`\u670D\u52A1\u7AEF\uFF1A${target.server.degraded ? `[degraded \xB7 ${target.server.reason}] ` : ""}${target.server.note}`);
|
|
16042
16845
|
const actions = firstActions(report.results);
|
|
16043
16846
|
if (actions.length) out.push(`\u5148\u5904\u7406\uFF1A${actions.map((r) => `${r.checkId}${r.env ? `\uFF08${r.env}\uFF09` : ""}`).join("\u3001")}`);
|
|
16044
16847
|
if (platformOps) {
|
|
@@ -16054,8 +16857,8 @@ import { createHash as createHash8 } from "crypto";
|
|
|
16054
16857
|
import axios9 from "axios";
|
|
16055
16858
|
import {
|
|
16056
16859
|
classifyStatus as classifyStatus2,
|
|
16057
|
-
CliError as
|
|
16058
|
-
CliErrorCode as
|
|
16860
|
+
CliError as CliError35,
|
|
16861
|
+
CliErrorCode as CliErrorCode36,
|
|
16059
16862
|
loadGlobalConfig as loadGlobalConfig11,
|
|
16060
16863
|
printResolvedEnvironment as printResolvedEnvironment8,
|
|
16061
16864
|
resolveEnvContext as resolveEnvContext8
|
|
@@ -16163,11 +16966,11 @@ async function readPlatformOpsKey(args, io = {
|
|
|
16163
16966
|
} else if (io.isTTY) {
|
|
16164
16967
|
source = "tty";
|
|
16165
16968
|
key2 = await io.prompt();
|
|
16166
|
-
} else throw new
|
|
16969
|
+
} 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
16970
|
if (blank) io.stderr(`HCM_PLATFORM_OPS_KEY \u5168\u662F\u7A7A\u767D\uFF0C\u5DF2\u5FFD\u7565\uFF1B\u6539\u4ECE ${source} \u8BFB\u53D6
|
|
16168
16971
|
`);
|
|
16169
16972
|
key2 = key2.trim();
|
|
16170
|
-
if (!key2) throw new
|
|
16973
|
+
if (!key2) throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: "\u8FD0\u7EF4\u5BC6\u94A5\u4E3A\u7A7A" });
|
|
16171
16974
|
io.stderr(`\u8FD0\u7EF4\u5BC6\u94A5\u6765\u6E90\uFF1A${source} \xB7 \u6307\u7EB9 ${opsKeyFingerprint(key2)}
|
|
16172
16975
|
`);
|
|
16173
16976
|
return { key: key2, source };
|
|
@@ -16176,12 +16979,12 @@ var split = (value) => (Array.isArray(value) ? value : value ? [value] : []).fla
|
|
|
16176
16979
|
function scopeFor(args) {
|
|
16177
16980
|
const only = split(args.only), skip = split(args.skip);
|
|
16178
16981
|
for (const token of [...only, ...skip]) if (!("platform.".startsWith(token) || token.startsWith("platform.")))
|
|
16179
|
-
throw new
|
|
16180
|
-
code:
|
|
16982
|
+
throw new CliError35({
|
|
16983
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16181
16984
|
message: `\u8FD0\u7EF4\u89C6\u56FE\u53EA\u770B\u5E73\u53F0\u5C42\uFF1A--only / --skip \u53EA\u63A5\u53D7 platform \u524D\u7F00\uFF0C\u6536\u5230 ${token}`
|
|
16182
16985
|
});
|
|
16183
|
-
if (skip.some((token) => "platform.".startsWith(token))) throw new
|
|
16184
|
-
code:
|
|
16986
|
+
if (skip.some((token) => "platform.".startsWith(token))) throw new CliError35({
|
|
16987
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16185
16988
|
message: "\u6392\u9664\u4E86\u5E73\u53F0\u5C42\uFF0C\u8FD0\u7EF4\u89C6\u56FE\u6CA1\u6709\u53EF\u770B\u7684\u68C0\u67E5"
|
|
16186
16989
|
});
|
|
16187
16990
|
return {
|
|
@@ -16337,7 +17140,7 @@ function failure(ctx, env2, health, key2) {
|
|
|
16337
17140
|
}
|
|
16338
17141
|
var ENV_HINT = "hcm env list \u67E5\u770B\u53EF\u9009\u73AF\u5883\uFF1Bhcm env add <\u540D> --endpoint <url> \u767B\u8BB0";
|
|
16339
17142
|
function resolverMessage(error) {
|
|
16340
|
-
if (error instanceof
|
|
17143
|
+
if (error instanceof CliError35 && error.code === CliErrorCode36.NO_ACTIVE_ENV) return "\u672A\u9009\u5B9A\u73AF\u5883\uFF1A\u7528 --env <\u540D> \u6307\u5B9A";
|
|
16341
17144
|
return (error instanceof Error ? error.message : safeError(error)).replace(/\s*(&&\s*)?hcm\s+login\b[^;;\n]*/gi, "");
|
|
16342
17145
|
}
|
|
16343
17146
|
async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onReport) {
|
|
@@ -16346,10 +17149,10 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16346
17149
|
try {
|
|
16347
17150
|
resolved = await resolveEnvContext8({ envFlag: args.env }, process.env, await loadGlobalConfig11());
|
|
16348
17151
|
} catch (error2) {
|
|
16349
|
-
throw new
|
|
17152
|
+
throw new CliError35({ code: CliErrorCode36.INVALID_ARGUMENT, message: `${resolverMessage(error2)}\uFF1B${ENV_HINT}` });
|
|
16350
17153
|
}
|
|
16351
|
-
if (!resolved.config.endpoint) throw new
|
|
16352
|
-
code:
|
|
17154
|
+
if (!resolved.config.endpoint) throw new CliError35({
|
|
17155
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16353
17156
|
message: `\u672A\u89E3\u6790\u5230 endpoint\uFF1B${ENV_HINT}`
|
|
16354
17157
|
});
|
|
16355
17158
|
printResolvedEnvironment8(resolved);
|
|
@@ -16395,8 +17198,8 @@ async function runPlatformOps(args, services, readKey = readPlatformOpsKey, onRe
|
|
|
16395
17198
|
const error = out && object(out.body) && object(out.body.error) ? out.body.error : void 0;
|
|
16396
17199
|
if (out?.status === 400 && error?.code === "HEALTH_REPORT_INVALID_PARAM") {
|
|
16397
17200
|
const trace = out.headers["x-trace-id"];
|
|
16398
|
-
throw new
|
|
16399
|
-
code:
|
|
17201
|
+
throw new CliError35({
|
|
17202
|
+
code: CliErrorCode36.INVALID_ARGUMENT,
|
|
16400
17203
|
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
17204
|
});
|
|
16402
17205
|
}
|
|
@@ -16450,10 +17253,12 @@ var localCriterion = {
|
|
|
16450
17253
|
"local.cli.version": "\u4E0E npm \u6700\u65B0 CLI \u7248\u672C\u6BD4\u8F83",
|
|
16451
17254
|
"local.skills.installed": "\u4E24\u79CD\u5E03\u5C40\u7684\u6280\u80FD\u5E76\u96C6\u3001\u9501\u6587\u4EF6\u4E0E\u76EE\u6807\u73AF\u5883\u4E00\u81F4",
|
|
16452
17255
|
"local.skills.fresh": "\u672C\u673A\u6280\u80FD\u4E0E\u76EE\u6807\u73AF\u5883\u7684\u4EA7\u54C1\u6280\u80FD\u76EE\u5F55\u5BF9\u8D26",
|
|
17256
|
+
"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
17257
|
"local.boundary": "\u9879\u76EE\u8FB9\u754C\u5757\u5B58\u5728\uFF0C\u4E14\u4E0D\u662F CLI fallback \u526F\u672C",
|
|
16454
17258
|
"local.method": "\u5B9E\u65BD\u65B9\u6CD5\u5305\u5DF2\u5B89\u88C5\u3001\u7248\u672C\u4E0E\u672C\u673A\u526F\u672C\u4E00\u81F4",
|
|
16455
17259
|
"local.cases": "\u6848\u4F8B\u5E93\u7D22\u5F15\u53EF\u8BFB\u53D6\uFF0C\u8FDC\u7AEF\u4E0E\u7F13\u5B58\u6765\u6E90\u53EF\u8FA8",
|
|
16456
17260
|
"local.jira": "Jira \u4EE4\u724C\u3001\u672C\u4EBA\u8EAB\u4EFD\u53CA\u9879\u76EE\u53EF\u89C1\u6027\u9010\u9879\u6838\u9A8C",
|
|
17261
|
+
"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
17262
|
"connect.connectivity": "\u514D\u8BA4\u8BC1\u8BFB\u53D6\u540E\u7AEF\u7248\u672C\u7AEF\u70B9\uFF0C\u786E\u8BA4\u540E\u7AEF\u53EF\u8FBE",
|
|
16458
17263
|
"connect.identity": "\u670D\u52A1\u7AEF\u786E\u8BA4 token \u4E3B\u4F53\u53CA\u79DF\u6237\u4E0E\u9879\u76EE\u58F0\u660E\u4E00\u81F4",
|
|
16459
17264
|
"connect.config-admin": "\u79DF\u6237 meta \u6E05\u5355\u53EF\u8BFB\uFF0C\u96F6\u6761\u4E5F\u6709\u6548",
|
|
@@ -16686,6 +17491,8 @@ var defaultServices = {
|
|
|
16686
17491
|
inspectJira,
|
|
16687
17492
|
inspectMethod: inspectMethodForDoctor,
|
|
16688
17493
|
latestVersion: fetchLatestVersion,
|
|
17494
|
+
// 单次请求 8 秒(与 local.jira 一致):这一项总时限 30 秒,单次用默认的 30 秒卡一次就用完了
|
|
17495
|
+
pendingVerify: async (signal) => gapPendingVerify({ client: await createJiraClient2({ timeoutMs: 8e3 }) }, { signal }),
|
|
16689
17496
|
skillsFresh: inspectSkillsFresh,
|
|
16690
17497
|
asAuth: (...args) => ensureAsAuth(...args),
|
|
16691
17498
|
probe: (endpoint, token, signal) => httpProbe2(axios10.create({
|
|
@@ -16699,13 +17506,13 @@ var defaultServices = {
|
|
|
16699
17506
|
};
|
|
16700
17507
|
function validate(args) {
|
|
16701
17508
|
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:
|
|
17509
|
+
if (value !== void 0 && !choices.includes(value)) throw new CliError36({
|
|
17510
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
16704
17511
|
message: `--${key2} \u53EA\u63A5\u53D7 ${choices.join(" / ")}\uFF0C\u6536\u5230 ${value}`
|
|
16705
17512
|
});
|
|
16706
17513
|
const stages = ["handover", "baseline", "configure", "migrate", "integrate", "golive", "operate"];
|
|
16707
|
-
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new
|
|
16708
|
-
code:
|
|
17514
|
+
if (args.stage !== void 0 && !stages.includes(args.stage.toLowerCase())) throw new CliError36({
|
|
17515
|
+
code: CliErrorCode37.INVALID_ARGUMENT,
|
|
16709
17516
|
message: `--stage \u53EA\u63A5\u53D7 ${stages.join(" / ")}\uFF0C\u6536\u5230 ${args.stage}`
|
|
16710
17517
|
});
|
|
16711
17518
|
if (args.platformOpsKeyStdin && !args.platformOps) invalidScope("--platform-ops-key-stdin \u53EA\u80FD\u4E0E --platform-ops \u540C\u7528");
|
|
@@ -16726,7 +17533,7 @@ var tokens = (value) => (Array.isArray(value) ? value : value ? [value] : []).fl
|
|
|
16726
17533
|
var matches = (id, only, skip) => (!only.length || only.some((t) => id.startsWith(t))) && !skip.some((t) => id.startsWith(t));
|
|
16727
17534
|
var serverCandidate = (t) => ["platform.", "tenant."].some((prefix) => prefix.startsWith(t) || t.startsWith(prefix));
|
|
16728
17535
|
function invalidScope(message) {
|
|
16729
|
-
throw new
|
|
17536
|
+
throw new CliError36({ code: CliErrorCode37.INVALID_ARGUMENT, message });
|
|
16730
17537
|
}
|
|
16731
17538
|
function scopeFor2(args, catalog) {
|
|
16732
17539
|
const only = tokens(args.only), skip = tokens(args.skip), stage = args.stage?.toLowerCase() ?? null;
|
|
@@ -16761,7 +17568,7 @@ async function readCredential(envFlag, root, as) {
|
|
|
16761
17568
|
try {
|
|
16762
17569
|
resolved = await resolveEnvContext9({ envFlag, cwd: root }, process.env, await loadGlobalConfig12());
|
|
16763
17570
|
} catch (error) {
|
|
16764
|
-
if (error instanceof
|
|
17571
|
+
if (error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND) return { resolved: null };
|
|
16765
17572
|
throw error;
|
|
16766
17573
|
}
|
|
16767
17574
|
if (as) return { resolved };
|
|
@@ -16770,14 +17577,14 @@ async function readCredential(envFlag, root, as) {
|
|
|
16770
17577
|
try {
|
|
16771
17578
|
identity3 = await resolveActiveIdentity2({}, process.env, resolved.name);
|
|
16772
17579
|
} catch (error) {
|
|
16773
|
-
if (error instanceof
|
|
17580
|
+
if (error instanceof CliError36 && error.code === CliErrorCode37.IDENTITY_NOT_FOUND) return { resolved, error: found("IDENTITY_NOT_LOGGED_IN") };
|
|
16774
17581
|
throw error;
|
|
16775
17582
|
}
|
|
16776
17583
|
let meta2;
|
|
16777
17584
|
try {
|
|
16778
17585
|
meta2 = await loadIdentity5(identity3);
|
|
16779
17586
|
} catch (error) {
|
|
16780
|
-
if (error instanceof
|
|
17587
|
+
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
17588
|
throw error;
|
|
16782
17589
|
}
|
|
16783
17590
|
if (!meta2.env || meta2.env !== resolved.name) return {
|
|
@@ -16819,7 +17626,7 @@ async function prepareContext(args, deps) {
|
|
|
16819
17626
|
const detail = `${safeError(error)}\uFF1B\u53EF\u9009\u73AF\u5883\uFF1A${available.join(", ") || "\uFF08\u65E0\uFF09"}`;
|
|
16820
17627
|
projectObservation = found("ENV_NOT_RESOLVED", detail);
|
|
16821
17628
|
targetEnv = null;
|
|
16822
|
-
const slotMissing = error instanceof
|
|
17629
|
+
const slotMissing = error instanceof CliError36 && error.code === CliErrorCode37.ENV_NOT_FOUND;
|
|
16823
17630
|
const project2 = args.project !== void 0 ? ` --project ${quote(root)}` : "";
|
|
16824
17631
|
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
17632
|
if (slotMissing || error instanceof Error && error.message === "\u672C\u673A\u69FD\u4E0D\u5C5E\u4E8E\u5F53\u524D\u9879\u76EE")
|
|
@@ -17030,11 +17837,11 @@ import { accessSync, constants, readdirSync as readdirSync3 } from "fs";
|
|
|
17030
17837
|
import fs14 from "fs/promises";
|
|
17031
17838
|
import os6 from "os";
|
|
17032
17839
|
import path17 from "path";
|
|
17033
|
-
import { CliError as
|
|
17840
|
+
import { CliError as CliError39, CliErrorCode as CliErrorCode40, formatObject as formatObject31, HcmClient as HcmClient25, loadEnv as loadEnv6 } from "@hcmai/sdk";
|
|
17034
17841
|
import { createRequire } from "module";
|
|
17035
17842
|
|
|
17036
17843
|
// src/commands/chiron-page-cdp.ts
|
|
17037
|
-
import { CliError as
|
|
17844
|
+
import { CliError as CliError37, CliErrorCode as CliErrorCode38 } from "@hcmai/sdk";
|
|
17038
17845
|
|
|
17039
17846
|
// src/commands/chiron-page-shared.ts
|
|
17040
17847
|
function redactTicket(text) {
|
|
@@ -17070,14 +17877,14 @@ function normalizeCdpEndpoint(raw) {
|
|
|
17070
17877
|
try {
|
|
17071
17878
|
url = new URL(candidate);
|
|
17072
17879
|
} catch {
|
|
17073
|
-
throw new
|
|
17880
|
+
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
17881
|
}
|
|
17075
17882
|
const protocol = url.protocol === "wss:" ? "https:" : url.protocol === "ws:" ? "http:" : url.protocol;
|
|
17076
17883
|
if (protocol !== "http:" && protocol !== "https:") {
|
|
17077
|
-
throw new
|
|
17884
|
+
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
17885
|
}
|
|
17079
17886
|
if (!url.port) {
|
|
17080
|
-
throw new
|
|
17887
|
+
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
17888
|
}
|
|
17082
17889
|
return `${protocol}//${url.hostname}:${url.port}`;
|
|
17083
17890
|
}
|
|
@@ -17174,8 +17981,8 @@ async function captureViaCdp(input, io) {
|
|
|
17174
17981
|
const browser = version2?.Browser ? String(version2.Browser) : `attached ${input.endpoint}`;
|
|
17175
17982
|
const target = await io.fetchJson(`${input.endpoint}/json/new?about:blank`, "PUT");
|
|
17176
17983
|
if (!target?.id || !target.webSocketDebuggerUrl) {
|
|
17177
|
-
throw new
|
|
17178
|
-
code:
|
|
17984
|
+
throw new CliError37({
|
|
17985
|
+
code: CliErrorCode38.SERVER_ERROR,
|
|
17179
17986
|
message: `${input.endpoint}/json/new \u6CA1\u6709\u7ED9\u51FA\u6807\u7B7E\u9875\uFF08id / webSocketDebuggerUrl \u7F3A\u5931\uFF09`,
|
|
17180
17987
|
context: { nextStep: "\u786E\u8BA4 Chrome \u662F\u5E26 --remote-debugging-port \u8D77\u7684\uFF0C\u4E14 --cdp \u6307\u5230\u7684\u662F\u5B83" }
|
|
17181
17988
|
});
|
|
@@ -17205,7 +18012,7 @@ async function captureViaCdp(input, io) {
|
|
|
17205
18012
|
});
|
|
17206
18013
|
if (r.exceptionDetails) {
|
|
17207
18014
|
const why = r.exceptionDetails.exception?.description ?? r.exceptionDetails.text ?? "unknown";
|
|
17208
|
-
throw new
|
|
18015
|
+
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
18016
|
}
|
|
17210
18017
|
evalResult = r.result && "value" in r.result ? toPlainJson(r.result.value) : toPlainJson(r.result?.description);
|
|
17211
18018
|
}
|
|
@@ -17216,7 +18023,7 @@ async function captureViaCdp(input, io) {
|
|
|
17216
18023
|
const dom = typeof domReply.result?.value === "string" ? domReply.result.value : "";
|
|
17217
18024
|
const shot = await session.send("Page.captureScreenshot", { format: "png" });
|
|
17218
18025
|
if (!shot.data) {
|
|
17219
|
-
throw new
|
|
18026
|
+
throw new CliError37({ code: CliErrorCode38.SERVER_ERROR, message: "Page.captureScreenshot \u6CA1\u6709\u8FD4\u56DE\u56FE\u50CF\u6570\u636E" });
|
|
17220
18027
|
}
|
|
17221
18028
|
await io.writeFile(input.screenshot, Buffer.from(shot.data, "base64"));
|
|
17222
18029
|
return { dom, browser, evalResult, navigated, minted };
|
|
@@ -17238,7 +18045,7 @@ var defaultCdpIo = {
|
|
|
17238
18045
|
openSocket: (wsUrl) => new Promise((resolve4, reject) => {
|
|
17239
18046
|
const Ctor = globalThis.WebSocket;
|
|
17240
18047
|
if (!Ctor) {
|
|
17241
|
-
reject(new
|
|
18048
|
+
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
18049
|
return;
|
|
17243
18050
|
}
|
|
17244
18051
|
const ws = new Ctor(wsUrl);
|
|
@@ -17261,7 +18068,7 @@ var defaultCdpIo = {
|
|
|
17261
18068
|
|
|
17262
18069
|
// src/commands/chiron-page-playwright.ts
|
|
17263
18070
|
import path16 from "path";
|
|
17264
|
-
import { CliError as
|
|
18071
|
+
import { CliError as CliError38, CliErrorCode as CliErrorCode39 } from "@hcmai/sdk";
|
|
17265
18072
|
function playwrightCacheRoot(probe2) {
|
|
17266
18073
|
const override = probe2.env.PLAYWRIGHT_BROWSERS_PATH?.trim();
|
|
17267
18074
|
if (override === "0" && probe2.packageRoot) return path16.join(probe2.packageRoot, ".local-browsers");
|
|
@@ -17304,8 +18111,8 @@ function discoverPlaywrightBrowser(probe2) {
|
|
|
17304
18111
|
const explicit = probe2.env.HCM_PLAYWRIGHT_EXECUTABLE?.trim();
|
|
17305
18112
|
if (explicit) {
|
|
17306
18113
|
if (probe2.executable(explicit)) return { executablePath: explicit, kind: "explicit", from: "HCM_PLAYWRIGHT_EXECUTABLE" };
|
|
17307
|
-
throw new
|
|
17308
|
-
code:
|
|
18114
|
+
throw new CliError38({
|
|
18115
|
+
code: CliErrorCode39.INVALID_ARGUMENT,
|
|
17309
18116
|
message: `HCM_PLAYWRIGHT_EXECUTABLE \u6307\u7684\u6587\u4EF6\u4E0D\u53EF\u6267\u884C\uFF1A${explicit}`,
|
|
17310
18117
|
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
18118
|
});
|
|
@@ -17347,8 +18154,8 @@ async function captureViaPlaywright(input) {
|
|
|
17347
18154
|
}
|
|
17348
18155
|
}
|
|
17349
18156
|
if (!browser) {
|
|
17350
|
-
throw new
|
|
17351
|
-
code:
|
|
18157
|
+
throw new CliError38({
|
|
18158
|
+
code: CliErrorCode39.SERVER_ERROR,
|
|
17352
18159
|
message: `Playwright \u8D77\u4E0D\u4E86\u6D4F\u89C8\u5668\uFF1A${failures.join("\uFF1B")}`,
|
|
17353
18160
|
context: {
|
|
17354
18161
|
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 +18175,7 @@ async function captureViaPlaywright(input) {
|
|
|
17368
18175
|
evalResult = toPlainJson(await page.evaluate(wrapEvalBody(input.evalJs)));
|
|
17369
18176
|
} catch (e) {
|
|
17370
18177
|
const why = (e instanceof Error ? e.message : String(e)).split("\n")[0] ?? "";
|
|
17371
|
-
throw new
|
|
18178
|
+
throw new CliError38({ code: CliErrorCode39.INVALID_ARGUMENT, message: `--eval \u5728\u9875\u9762\u91CC\u629B\u4E86\u5F02\u5E38\uFF1A${redactTicket(why)}` });
|
|
17372
18179
|
}
|
|
17373
18180
|
}
|
|
17374
18181
|
const dom = await page.content();
|
|
@@ -17392,13 +18199,13 @@ function judgePageContent(input) {
|
|
|
17392
18199
|
function parseViewport(size) {
|
|
17393
18200
|
const m = /^(\d+)x(\d+)$/.exec(size.trim());
|
|
17394
18201
|
if (!m) {
|
|
17395
|
-
throw new
|
|
18202
|
+
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
18203
|
}
|
|
17397
18204
|
const width = Number(m[1]);
|
|
17398
18205
|
const height = Number(m[2]);
|
|
17399
18206
|
if (width < VIEWPORT_MIN.width || width > VIEWPORT_MAX.width || height < VIEWPORT_MIN.height || height > VIEWPORT_MAX.height) {
|
|
17400
|
-
throw new
|
|
17401
|
-
code:
|
|
18207
|
+
throw new CliError39({
|
|
18208
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17402
18209
|
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
18210
|
});
|
|
17404
18211
|
}
|
|
@@ -17408,23 +18215,23 @@ function parseWaitMs(raw) {
|
|
|
17408
18215
|
if (raw === void 0) return 1e4;
|
|
17409
18216
|
const value = typeof raw === "number" ? raw : Number(raw);
|
|
17410
18217
|
if (!Number.isInteger(value) || value < 0 || value > WAIT_MS_MAX) {
|
|
17411
|
-
throw new
|
|
18218
|
+
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
18219
|
}
|
|
17413
18220
|
return value;
|
|
17414
18221
|
}
|
|
17415
18222
|
function resolveEvidenceTarget(projectRoot, out) {
|
|
17416
18223
|
if (!out?.trim()) {
|
|
17417
|
-
throw new
|
|
18224
|
+
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
18225
|
}
|
|
17419
18226
|
if (!out.endsWith(".png")) {
|
|
17420
|
-
throw new
|
|
18227
|
+
throw new CliError39({ code: CliErrorCode40.INVALID_ARGUMENT, message: `--out \u8981\u4EE5 .png \u7ED3\u5C3E\uFF0C\u6536\u5230\u7684\u662F ${out}` });
|
|
17421
18228
|
}
|
|
17422
18229
|
const root = path17.resolve(projectRoot);
|
|
17423
18230
|
const evidenceRoot = path17.join(root, EVIDENCE_DIR);
|
|
17424
18231
|
const absolute = path17.resolve(root, out);
|
|
17425
18232
|
if (absolute !== evidenceRoot && !absolute.startsWith(evidenceRoot + path17.sep)) {
|
|
17426
|
-
throw new
|
|
17427
|
-
code:
|
|
18233
|
+
throw new CliError39({
|
|
18234
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17428
18235
|
message: `--out \u8981\u843D\u5728\u9879\u76EE\u7684 ${EVIDENCE_DIR}/ \u4E0B\uFF08${evidenceRoot}\uFF09\uFF0C\u6536\u5230\u7684\u662F ${absolute}`
|
|
17429
18236
|
});
|
|
17430
18237
|
}
|
|
@@ -17472,8 +18279,8 @@ async function assertInsideEvidence(deps, evidenceRoot, absolute) {
|
|
|
17472
18279
|
const canonicalParent = await deps.realpath(path17.dirname(absolute));
|
|
17473
18280
|
if (canonicalRoot === null || canonicalParent === null) return;
|
|
17474
18281
|
if (canonicalParent !== canonicalRoot && !canonicalParent.startsWith(canonicalRoot + path17.sep)) {
|
|
17475
|
-
throw new
|
|
17476
|
-
code:
|
|
18282
|
+
throw new CliError39({
|
|
18283
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17477
18284
|
message: `--out \u7684\u7236\u76EE\u5F55\u7ECF\u7B26\u53F7\u94FE\u63A5\u8DD1\u51FA\u4E86 ${EVIDENCE_DIR}/\uFF1A${canonicalParent}`
|
|
17478
18285
|
});
|
|
17479
18286
|
}
|
|
@@ -17482,8 +18289,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17482
18289
|
const sitePath = normalizeTarget(target);
|
|
17483
18290
|
const expect = (args.expectText ?? []).filter((t) => t.trim().length > 0);
|
|
17484
18291
|
if (expect.length === 0) {
|
|
17485
|
-
throw new
|
|
17486
|
-
code:
|
|
18292
|
+
throw new CliError39({
|
|
18293
|
+
code: CliErrorCode40.MISSING_FLAG,
|
|
17487
18294
|
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
18295
|
});
|
|
17489
18296
|
}
|
|
@@ -17493,8 +18300,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17493
18300
|
const root = path17.resolve(args.project ?? ".");
|
|
17494
18301
|
const { evidenceRoot, absolute } = resolveEvidenceTarget(root, args.out);
|
|
17495
18302
|
if (await deps.present(absolute)) {
|
|
17496
|
-
throw new
|
|
17497
|
-
code:
|
|
18303
|
+
throw new CliError39({
|
|
18304
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17498
18305
|
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
18306
|
});
|
|
17500
18307
|
}
|
|
@@ -17506,8 +18313,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17506
18313
|
const playwrightBrowser = endpoint || forceSpawn ? null : deps.findPlaywrightBrowser();
|
|
17507
18314
|
const usePlaywright = !endpoint && !forceSpawn && (playwrightBrowser !== null || evalJs !== void 0);
|
|
17508
18315
|
if (evalJs && !endpoint && !usePlaywright) {
|
|
17509
|
-
throw new
|
|
17510
|
-
code:
|
|
18316
|
+
throw new CliError39({
|
|
18317
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17511
18318
|
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
18319
|
context: { nextStep: "npx playwright install chromium-headless-shell\uFF0C\u6216\u5728\u6C99\u7BB1\u5916\u8D77 Chrome \u7528 --cdp \u8FDE" }
|
|
17513
18320
|
});
|
|
@@ -17525,10 +18332,10 @@ async function runChironPage(target, args, deps) {
|
|
|
17525
18332
|
try {
|
|
17526
18333
|
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
18334
|
} catch (e) {
|
|
17528
|
-
if (e instanceof
|
|
18335
|
+
if (e instanceof CliError39) throw new CliError39({ code: e.code, message: redactTicket(e.message), context: e.context });
|
|
17529
18336
|
const where = endpoint ? `\u8FDE\u5230 ${endpoint} \u7684 Chrome` : "Playwright \u8D77\u7684\u6D4F\u89C8\u5668";
|
|
17530
|
-
throw new
|
|
17531
|
-
code:
|
|
18337
|
+
throw new CliError39({
|
|
18338
|
+
code: CliErrorCode40.SERVER_ERROR,
|
|
17532
18339
|
message: `${where}\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(e instanceof Error ? e.message : String(e))}`,
|
|
17533
18340
|
context: {
|
|
17534
18341
|
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 +18351,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17544
18351
|
mode = "spawn";
|
|
17545
18352
|
const browser = deps.findBrowser();
|
|
17546
18353
|
if (!browser) {
|
|
17547
|
-
throw new
|
|
17548
|
-
code:
|
|
18354
|
+
throw new CliError39({
|
|
18355
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17549
18356
|
message: "\u672C\u673A\u627E\u4E0D\u5230 Playwright \u7684 Chromium\uFF0C\u4E5F\u627E\u4E0D\u5230 Chrome/Chromium\uFF0C\u622A\u4E0D\u4E86\u56FE\u3002",
|
|
17550
18357
|
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
18358
|
});
|
|
@@ -17553,8 +18360,8 @@ async function runChironPage(target, args, deps) {
|
|
|
17553
18360
|
minted = await mint();
|
|
17554
18361
|
const result = deps.capture({ browser, argv: chromeArgv({ viewport, waitMs, screenshot: absolute, url: minted.url, isRoot: process.getuid?.() === 0 }) });
|
|
17555
18362
|
if (!result.ok) {
|
|
17556
|
-
throw new
|
|
17557
|
-
code:
|
|
18363
|
+
throw new CliError39({
|
|
18364
|
+
code: CliErrorCode40.SERVER_ERROR,
|
|
17558
18365
|
message: `\u6D4F\u89C8\u5668\u6CA1\u8DD1\u5B8C\uFF1A${redactTicket(result.stderr.trim().split("\n").slice(-1)[0] ?? "\u65E0\u8F93\u51FA")}`,
|
|
17559
18366
|
context: { nextStep: spawnFailureNextStep(browser, result, deps.platform) }
|
|
17560
18367
|
});
|
|
@@ -17564,7 +18371,7 @@ async function runChironPage(target, args, deps) {
|
|
|
17564
18371
|
}
|
|
17565
18372
|
const bytes = await deps.present(absolute) ? await deps.sizeOf(absolute) : 0;
|
|
17566
18373
|
if (bytes === 0) {
|
|
17567
|
-
throw new
|
|
18374
|
+
throw new CliError39({ code: CliErrorCode40.SERVER_ERROR, message: `\u6D4F\u89C8\u5668\u6CA1\u5199\u51FA\u975E\u7A7A PNG\uFF1A${absolute}` });
|
|
17568
18375
|
}
|
|
17569
18376
|
const verdict = judgePageContent({ dom, expect, reject });
|
|
17570
18377
|
return {
|
|
@@ -17627,8 +18434,8 @@ var defaultChironPageDeps = {
|
|
|
17627
18434
|
const envCfg = await loadEnv6(ctx.env);
|
|
17628
18435
|
const frontend = ctx.frontend ?? envCfg.frontend;
|
|
17629
18436
|
if (!frontend?.trim()) {
|
|
17630
|
-
throw new
|
|
17631
|
-
code:
|
|
18437
|
+
throw new CliError39({
|
|
18438
|
+
code: CliErrorCode40.INVALID_ARGUMENT,
|
|
17632
18439
|
message: `env '${ctx.env}' \u6CA1\u914D\u524D\u7AEF\u5730\u5740\uFF0C\u5F00\u4E0D\u4E86\u9875\u9762\u3002`,
|
|
17633
18440
|
context: { nextStep: `hcm env edit frontend <\u524D\u7AEF\u5730\u5740> --env ${ctx.env}` }
|
|
17634
18441
|
});
|
|
@@ -19620,21 +20427,21 @@ import {
|
|
|
19620
20427
|
adminResetPassword,
|
|
19621
20428
|
formatObject as formatObject34,
|
|
19622
20429
|
fromAxiosError as fromAxiosError26,
|
|
19623
|
-
CliError as
|
|
19624
|
-
CliErrorCode as
|
|
20430
|
+
CliError as CliError40,
|
|
20431
|
+
CliErrorCode as CliErrorCode41
|
|
19625
20432
|
} from "@hcmai/sdk";
|
|
19626
20433
|
function buildAdminResetPasswordRequest(args, password) {
|
|
19627
20434
|
const hasId = Boolean(args.id);
|
|
19628
20435
|
const hasUsername = Boolean(args.username);
|
|
19629
20436
|
if (hasId === hasUsername) {
|
|
19630
|
-
throw new
|
|
19631
|
-
code:
|
|
20437
|
+
throw new CliError40({
|
|
20438
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19632
20439
|
message: "--id <uuid> \u4E0E --username <user> \u5FC5\u987B\u4E14\u53EA\u80FD\u63D0\u4F9B\u4E00\u4E2A"
|
|
19633
20440
|
});
|
|
19634
20441
|
}
|
|
19635
20442
|
if (!password) {
|
|
19636
|
-
throw new
|
|
19637
|
-
code:
|
|
20443
|
+
throw new CliError40({
|
|
20444
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19638
20445
|
message: "\u65B0\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A"
|
|
19639
20446
|
});
|
|
19640
20447
|
}
|
|
@@ -19663,8 +20470,8 @@ async function promptPasswordTwice() {
|
|
|
19663
20470
|
const password = await promptSecret("\u65B0\u5BC6\u7801: ");
|
|
19664
20471
|
const confirmation = await promptSecret("\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ");
|
|
19665
20472
|
if (password !== confirmation) {
|
|
19666
|
-
throw new
|
|
19667
|
-
code:
|
|
20473
|
+
throw new CliError40({
|
|
20474
|
+
code: CliErrorCode41.INVALID_ARGUMENT,
|
|
19668
20475
|
message: "\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4"
|
|
19669
20476
|
});
|
|
19670
20477
|
}
|
|
@@ -19797,7 +20604,8 @@ chiron.command("init").description("\u5EFA\u987E\u95EE\u9879\u76EE\u4ED3\uFF1A\u
|
|
|
19797
20604
|
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
20605
|
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
20606
|
chiron.command("doctor").description(
|
|
19800
|
-
|
|
20607
|
+
// 项数从检查清单算:手写的数会在加检查项时漏改(加 local.gaps.verify 时就漏了一次)
|
|
20608
|
+
`\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
20609
|
).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
20610
|
var chironSkills = chiron.command("skills").description("\u8FD9\u4E2A\u9879\u76EE\u4ED3\u7684\u6280\u80FD\uFF1A\u8DDF\u76EE\u6807\u73AF\u5883\u5BF9\u9F50");
|
|
19803
20611
|
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 +20618,9 @@ projectEnv.command("edit <name> <field> <value>").description("\u7F16\u8F91 endp
|
|
|
19810
20618
|
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
20619
|
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
20620
|
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\
|
|
20621
|
+
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
20622
|
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\
|
|
20623
|
+
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
20624
|
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
20625
|
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
20626
|
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) }));
|