@hcmai/sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -262,11 +262,11 @@ var TokenStore = class _TokenStore {
262
262
  throw e;
263
263
  }
264
264
  }
265
- async setAccessToken(token2) {
266
- return this.storeToken("access", token2);
265
+ async setAccessToken(token) {
266
+ return this.storeToken("access", token);
267
267
  }
268
- async setRefreshToken(token2) {
269
- return this.storeToken("refresh", token2);
268
+ async setRefreshToken(token) {
269
+ return this.storeToken("refresh", token);
270
270
  }
271
271
  /**
272
272
  * 把一枚 token 存到能存的地方 —— 优先钥匙串,存不进就落 0600 文件。
@@ -284,16 +284,16 @@ var TokenStore = class _TokenStore {
284
284
  * ⇒ 不再有单独的探针,也就不再有「探针探 A、承重靠 B」那道缝:
285
285
  * 直接写,抛了就落回文件。下面那条兜底原本**永远够不到**,现在够得到了。
286
286
  */
287
- async storeToken(kind, token2) {
287
+ async storeToken(kind, token) {
288
288
  const mode = resolveCredentialStoreMode(await loadGlobalConfig().catch(() => null));
289
- if (mode === "file") return this.writeTokenFile(kind, token2, void 0, mode);
289
+ if (mode === "file") return this.writeTokenFile(kind, token, void 0, mode);
290
290
  const keytar = await loadKeytar();
291
- if (!keytar) return this.writeTokenFile(kind, token2, void 0, mode);
291
+ if (!keytar) return this.writeTokenFile(kind, token, void 0, mode);
292
292
  const account = `${this.keychainAccountPrefix()}/${kind}`;
293
293
  try {
294
- await keytar.setPassword(SERVICE_PREFIX, account, token2);
294
+ await keytar.setPassword(SERVICE_PREFIX, account, token);
295
295
  } catch (e) {
296
- return this.writeTokenFile(kind, token2, e, mode);
296
+ return this.writeTokenFile(kind, token, e, mode);
297
297
  }
298
298
  return `keychain:${SERVICE_PREFIX}/${account}`;
299
299
  }
@@ -365,10 +365,10 @@ var TokenStore = class _TokenStore {
365
365
  * (Linux 无 libsecret 等),「有 keytar 但写不进去」是异常,顾问的下一步不同 ——
366
366
  * 后者必须把原始报错**原样转述**出来,否则他看到的还是一句没有出处的话。
367
367
  */
368
- async writeTokenFile(kind, token2, cause, mode = "auto") {
368
+ async writeTokenFile(kind, token, cause, mode = "auto") {
369
369
  const file = `${this.metaFile()}.${kind}`;
370
370
  await fs2.mkdir(this.dataDir(), { recursive: true, mode: 448 });
371
- await fs2.writeFile(file, token2, { mode: 384 });
371
+ await fs2.writeFile(file, token, { mode: 384 });
372
372
  await fs2.chmod(file, 384);
373
373
  if (kind === "access" && mode !== "file") {
374
374
  const why = cause === void 0 ? "OS keychain unavailable" : `OS keychain refused the write (${cause instanceof Error ? cause.message : String(cause)})`;
@@ -419,14 +419,14 @@ async function loginPassword(input) {
419
419
  },
420
420
  { headers: { "Content-Type": "application/json" } }
421
421
  );
422
- const { token: token2, expiresIn, user } = resp.data;
423
- if (!token2) {
422
+ const { token, expiresIn, user } = resp.data;
423
+ if (!token) {
424
424
  throw new Error("Login response missing token");
425
425
  }
426
426
  const ttlSeconds = expiresIn ?? DEFAULT_SESSION_TTL_SECONDS;
427
427
  const expiresAt = new Date(Date.now() + ttlSeconds * 1e3).toISOString();
428
428
  const store = new TokenStore(input.profile);
429
- const accessTokenRef = await store.setAccessToken(token2);
429
+ const accessTokenRef = await store.setAccessToken(token);
430
430
  const record = {
431
431
  scheme: "password",
432
432
  accessTokenRef,
@@ -1188,18 +1188,18 @@ async function action(http, model, actionName, input) {
1188
1188
  if (scope === "object" && !input.id) {
1189
1189
  throw new Error(`object action ${model}.${actionName} requires id`);
1190
1190
  }
1191
- const path25 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1191
+ const path22 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1192
1192
  const resp = await (async () => {
1193
1193
  if (method === "GET") {
1194
- return http.get(path25, { params: queryParams(input) });
1194
+ return http.get(path22, { params: queryParams(input) });
1195
1195
  }
1196
1196
  if (method === "DELETE") {
1197
- return http.delete(path25, { params: queryParams(input) });
1197
+ return http.delete(path22, { params: queryParams(input) });
1198
1198
  }
1199
1199
  if (method === "PUT") {
1200
- return http.put(path25, scope === "object" ? objectBody(input) : classBody(input));
1200
+ return http.put(path22, scope === "object" ? objectBody(input) : classBody(input));
1201
1201
  }
1202
- return http.post(path25, scope === "object" ? objectBody(input) : classBody(input));
1202
+ return http.post(path22, scope === "object" ? objectBody(input) : classBody(input));
1203
1203
  })();
1204
1204
  return resp.data;
1205
1205
  }
@@ -2031,14 +2031,14 @@ async function loginPairing(input) {
2031
2031
  { code: input.code },
2032
2032
  { headers: { "Content-Type": "application/json" } }
2033
2033
  );
2034
- const { token: token2, expiresIn, user } = resp.data;
2035
- if (!token2) {
2034
+ const { token, expiresIn, user } = resp.data;
2035
+ if (!token) {
2036
2036
  throw new Error("Pairing exchange response missing token");
2037
2037
  }
2038
2038
  const ttlSeconds = expiresIn ?? DEFAULT_SESSION_TTL_SECONDS;
2039
2039
  const expiresAt = new Date(Date.now() + ttlSeconds * 1e3).toISOString();
2040
2040
  const store = new TokenStore(input.profile);
2041
- const accessTokenRef = await store.setAccessToken(token2);
2041
+ const accessTokenRef = await store.setAccessToken(token);
2042
2042
  const record = {
2043
2043
  scheme: "pairing",
2044
2044
  accessTokenRef,
@@ -2063,10 +2063,10 @@ function detectPasswordChangeChallenge(err) {
2063
2063
  const body = err?.response?.data;
2064
2064
  const error = body?.error ?? body;
2065
2065
  if (error?.code !== PASSWORD_CHANGE_REQUIRED) return null;
2066
- const token2 = error?.details?.changePasswordToken;
2067
- if (!token2) return null;
2066
+ const token = error?.details?.changePasswordToken;
2067
+ if (!token) return null;
2068
2068
  return {
2069
- changePasswordToken: String(token2),
2069
+ changePasswordToken: String(token),
2070
2070
  expiresInSeconds: Number(error?.details?.expiresInSeconds) || void 0
2071
2071
  };
2072
2072
  }
@@ -5390,7 +5390,7 @@ function parseManifest(text2, manifestPath) {
5390
5390
  }
5391
5391
  async function collectFiles(root, skipAbs) {
5392
5392
  const out = [];
5393
- async function walk5(dir, rel) {
5393
+ async function walk4(dir, rel) {
5394
5394
  const entries = await fsp2.readdir(dir, { withFileTypes: true });
5395
5395
  entries.sort((a, b) => a.name.localeCompare(b.name));
5396
5396
  for (const e of entries) {
@@ -5398,13 +5398,13 @@ async function collectFiles(root, skipAbs) {
5398
5398
  const abs = path6.join(dir, e.name);
5399
5399
  const relPath = rel ? `${rel}/${e.name}` : e.name;
5400
5400
  if (e.isDirectory()) {
5401
- await walk5(abs, relPath);
5401
+ await walk4(abs, relPath);
5402
5402
  } else if (e.isFile() && !skipAbs.has(path6.resolve(abs))) {
5403
5403
  out.push(relPath);
5404
5404
  }
5405
5405
  }
5406
5406
  }
5407
- await walk5(root, "");
5407
+ await walk4(root, "");
5408
5408
  return out;
5409
5409
  }
5410
5410
  async function packDataPackage(packageDir, outPath, opts = {}) {
@@ -5592,18 +5592,18 @@ async function listTenantMeta(http, opts = {}) {
5592
5592
  const total = typeof body?.total === "number" ? body.total : payload?.total;
5593
5593
  return { items, total, raw: payload };
5594
5594
  }
5595
- async function getTenantMeta(http, path25) {
5596
- const resp = await http.get("/api/tenant-meta/meta", { params: { path: path25 } });
5595
+ async function getTenantMeta(http, path22) {
5596
+ const resp = await http.get("/api/tenant-meta/meta", { params: { path: path22 } });
5597
5597
  const payload = resp.data?.data ?? resp.data;
5598
5598
  if (typeof payload === "string") return payload;
5599
5599
  return String(payload?.content ?? "");
5600
5600
  }
5601
- async function saveTenantMeta(http, path25, content) {
5602
- const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path25 } });
5601
+ async function saveTenantMeta(http, path22, content) {
5602
+ const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path22 } });
5603
5603
  return resp.data?.data ?? resp.data;
5604
5604
  }
5605
- async function deleteTenantMeta(http, path25) {
5606
- const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path25 } });
5605
+ async function deleteTenantMeta(http, path22) {
5606
+ const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path22 } });
5607
5607
  return resp.data?.data ?? resp.data;
5608
5608
  }
5609
5609
 
@@ -9391,14 +9391,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
9391
9391
  throw invalid(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
9392
9392
  }
9393
9393
  const state = /* @__PURE__ */ new Map();
9394
- const path25 = [];
9394
+ const path22 = [];
9395
9395
  const order = [];
9396
9396
  const visit = (id, requiredBy) => {
9397
9397
  const current = state.get(id);
9398
9398
  if (current === "done") return;
9399
9399
  if (current === "visiting") {
9400
- const cycleStart = path25.indexOf(id);
9401
- const cycle = [...path25.slice(Math.max(0, cycleStart)), id];
9400
+ const cycleStart = path22.indexOf(id);
9401
+ const cycle = [...path22.slice(Math.max(0, cycleStart)), id];
9402
9402
  throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
9403
9403
  }
9404
9404
  const skill = byId.get(id);
@@ -9407,11 +9407,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
9407
9407
  }
9408
9408
  assertSafeSkillId(skill.id);
9409
9409
  state.set(id, "visiting");
9410
- path25.push(id);
9410
+ path22.push(id);
9411
9411
  for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
9412
9412
  visit(required2, skill.id);
9413
9413
  }
9414
- path25.pop();
9414
+ path22.pop();
9415
9415
  state.set(id, "done");
9416
9416
  order.push(skill);
9417
9417
  };
@@ -9502,11 +9502,11 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
9502
9502
  function parseSettingAssignment(raw) {
9503
9503
  const eq = raw.indexOf("=");
9504
9504
  if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
9505
- const path25 = raw.slice(0, eq).trim();
9505
+ const path22 = raw.slice(0, eq).trim();
9506
9506
  const value = raw.slice(eq + 1);
9507
- const dot = path25.lastIndexOf(".");
9508
- if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path25}"`);
9509
- return { namespace: path25.slice(0, dot), settingKey: path25.slice(dot + 1), value };
9507
+ const dot = path22.lastIndexOf(".");
9508
+ if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path22}"`);
9509
+ return { namespace: path22.slice(0, dot), settingKey: path22.slice(dot + 1), value };
9510
9510
  }
9511
9511
 
9512
9512
  // src/fde/layout.ts
@@ -9895,11 +9895,11 @@ function classifyStatus(status) {
9895
9895
  return "bad-response";
9896
9896
  }
9897
9897
  var CAPABILITIES_HEADER = "x-hcm-capabilities";
9898
- function buildUrl(path25, params) {
9898
+ function buildUrl(path22, params) {
9899
9899
  const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
9900
- if (entries.length === 0) return path25;
9900
+ if (entries.length === 0) return path22;
9901
9901
  const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
9902
- return `${path25}${path25.includes("?") ? "&" : "?"}${qs}`;
9902
+ return `${path22}${path22.includes("?") ? "&" : "?"}${qs}`;
9903
9903
  }
9904
9904
  function lowerHeaders(raw) {
9905
9905
  const out = {};
@@ -9941,14 +9941,14 @@ function httpProbe(http, capabilities) {
9941
9941
  const headers = { [CAPABILITIES_HEADER]: capabilities };
9942
9942
  const probe = {
9943
9943
  capabilities,
9944
- get(path25, params) {
9944
+ get(path22, params) {
9945
9945
  return once(
9946
- () => http.get(buildUrl(path25, params), { headers, validateStatus: () => true })
9946
+ () => http.get(buildUrl(path22, params), { headers, validateStatus: () => true })
9947
9947
  );
9948
9948
  },
9949
- post(path25, body) {
9949
+ post(path22, body) {
9950
9950
  return once(
9951
- () => http.post(path25, body, {
9951
+ () => http.post(path22, body, {
9952
9952
  headers: { ...headers, "content-type": "application/json" },
9953
9953
  validateStatus: () => true
9954
9954
  })
@@ -10060,8 +10060,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
10060
10060
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
10061
10061
  const metas = {};
10062
10062
  const unavailable = [];
10063
- for (const [path25, key] of paths) {
10064
- const out = results[path25];
10063
+ for (const [path22, key] of paths) {
10064
+ const out = results[path22];
10065
10065
  if (out === void 0) {
10066
10066
  unavailable.push({
10067
10067
  modelKey: key,
@@ -10291,8 +10291,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
10291
10291
  const statesEchoed = /* @__PURE__ */ new Set();
10292
10292
  let noStateEcho = 0;
10293
10293
  let answered = 0;
10294
- for (const [path25, model] of paths) {
10295
- const out = results[path25];
10294
+ for (const [path22, model] of paths) {
10295
+ const out = results[path22];
10296
10296
  if (out === void 0) {
10297
10297
  unavailable.push({
10298
10298
  modelKey: model,
@@ -10701,8 +10701,8 @@ async function collectMutation(probe, modelKeys2) {
10701
10701
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
10702
10702
  const mutation = {};
10703
10703
  const problems = [];
10704
- for (const [path25, key] of paths) {
10705
- const out = results[path25];
10704
+ for (const [path22, key] of paths) {
10705
+ const out = results[path22];
10706
10706
  if (out === void 0) {
10707
10707
  problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
10708
10708
  mutation[key] = Object.fromEntries(
@@ -11147,11 +11147,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
11147
11147
  keys.push(key);
11148
11148
  }
11149
11149
  for (const key of [...new Set(keys)].sort()) {
11150
- const path25 = listPath(key);
11150
+ const path22 = listPath(key);
11151
11151
  const started = tick();
11152
11152
  let requests = 0;
11153
11153
  let truncatedBy = null;
11154
- const probeOut = await post.call(probe, path25, { page: 0, size: 0 });
11154
+ const probeOut = await post.call(probe, path22, { page: 0, size: 0 });
11155
11155
  requests += 1;
11156
11156
  let total = null;
11157
11157
  let reason = null;
@@ -11200,7 +11200,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
11200
11200
  failed = `\u89E6\u53D1\u5DE5\u5177\u7684\u6BCF\u8868${which === "requests" ? "\u8BF7\u6C42" : "\u5899\u949F"}\u4E0A\u9650\uFF08${which === "requests" ? `\u5DF2\u53D1 ${requests} \u6B21\u8BF7\u6C42` : `\u5DF2\u82B1 ${elapsed.toFixed(3)}s`}\uFF09\uFF0C\u505C\u5728\u7B2C ${page} \u9875\uFF0C\u5DF2\u6536 ${rows.length} \u884C / \u8BA1\u6570 ${total} \u884C\uFF0C\u672C\u8868\u6807 partial\u3002**\u8FD9\u662F\u5DE5\u5177\u7684\u622A\u65AD\uFF0C\u4E0D\u662F\u670D\u52A1\u7AEF\u7684\u6BDB\u75C5** \u2014\u2014 \u8C03\u5927 valuedomain.${which === "requests" ? "MAX_REQUESTS_PER_TABLE" : "MAX_SECONDS_PER_TABLE"} \u6216\u7ED9 collectCodeTables \u4F20 ${which === "requests" ? "maxRequests" : "maxSeconds"} \u540E\u91CD\u8DD1\u5C31\u80FD\u53D6\u5168`;
11201
11201
  break;
11202
11202
  }
11203
- const out = await post.call(probe, path25, { page, size: PAGE_SIZE });
11203
+ const out = await post.call(probe, path22, { page, size: PAGE_SIZE });
11204
11204
  requests += 1;
11205
11205
  if (out.error !== "ok") {
11206
11206
  failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
@@ -11964,7 +11964,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
11964
11964
  for (const name of ["id", ...fields]) {
11965
11965
  if (!projected.includes(name)) projected.push(name);
11966
11966
  }
11967
- const path25 = listPath2(model);
11967
+ const path22 = listPath2(model);
11968
11968
  const idx = /* @__PURE__ */ new Map();
11969
11969
  let total = null;
11970
11970
  let pages = 0;
@@ -11981,7 +11981,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
11981
11981
  let repeatedIds = 0;
11982
11982
  while (total === null || received < total) {
11983
11983
  const pageNo = pages;
11984
- const out = await client.post(path25, {
11984
+ const out = await client.post(path22, {
11985
11985
  page: pageNo,
11986
11986
  size: pageSize,
11987
11987
  fields: projected,
@@ -12173,8 +12173,8 @@ var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
12173
12173
  var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
12174
12174
  var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
12175
12175
  var SCAN_CHUNK_BYTES = 1024 * 1024;
12176
- function scanFor(path25, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
12177
- const fd = openSync2(path25, "r");
12176
+ function scanFor(path22, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
12177
+ const fd = openSync2(path22, "r");
12178
12178
  try {
12179
12179
  let tail = Buffer.alloc(0);
12180
12180
  let seen = 0;
@@ -12195,9 +12195,9 @@ function scanFor(path25, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
12195
12195
  closeSync2(fd);
12196
12196
  }
12197
12197
  }
12198
- function isCfb(path25) {
12199
- if (statSync3(path25).size < CFB_MAGIC.length) return false;
12200
- const fd = openSync2(path25, "r");
12198
+ function isCfb(path22) {
12199
+ if (statSync3(path22).size < CFB_MAGIC.length) return false;
12200
+ const fd = openSync2(path22, "r");
12201
12201
  try {
12202
12202
  const head = Buffer.alloc(CFB_MAGIC.length);
12203
12203
  const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
@@ -12206,9 +12206,9 @@ function isCfb(path25) {
12206
12206
  closeSync2(fd);
12207
12207
  }
12208
12208
  }
12209
- function classifyCfb(path25, budget = MAX_ENTRY_BYTES) {
12210
- if (!isCfb(path25)) return "not-cfb";
12211
- switch (scanFor(path25, ENCRYPTED_PACKAGE, budget)) {
12209
+ function classifyCfb(path22, budget = MAX_ENTRY_BYTES) {
12210
+ if (!isCfb(path22)) return "not-cfb";
12211
+ switch (scanFor(path22, ENCRYPTED_PACKAGE, budget)) {
12212
12212
  case "found":
12213
12213
  return "encrypted";
12214
12214
  case "absent":
@@ -14748,16 +14748,16 @@ function rowCycles(parents) {
14748
14748
  const cycles = [];
14749
14749
  for (const start of [...parents.keys()].sort((a, b) => a - b)) {
14750
14750
  if (done.has(start)) continue;
14751
- const path25 = [];
14751
+ const path22 = [];
14752
14752
  const seen = /* @__PURE__ */ new Map();
14753
14753
  let node = start;
14754
14754
  while (node !== void 0 && !seen.has(node) && !done.has(node)) {
14755
- seen.set(node, path25.length);
14756
- path25.push(node);
14755
+ seen.set(node, path22.length);
14756
+ path22.push(node);
14757
14757
  node = parents.get(node);
14758
14758
  }
14759
- if (node !== void 0 && seen.has(node)) cycles.push(path25.slice(seen.get(node)));
14760
- for (const n of path25) done.add(n);
14759
+ if (node !== void 0 && seen.has(node)) cycles.push(path22.slice(seen.get(node)));
14760
+ for (const n of path22) done.add(n);
14761
14761
  }
14762
14762
  return cycles;
14763
14763
  }
@@ -16210,9 +16210,9 @@ function applyExemptions(problems, exemptions, recon) {
16210
16210
  for (const record of ledger) {
16211
16211
  if (!record.accepted) continue;
16212
16212
  const key = tripleKey(record.code, record.model, record.field);
16213
- const covered2 = hit.get(key) ?? [];
16214
- record.matched = covered2.length;
16215
- record.evidence = covered2.map((e) => evidenceOrReason(String(record.code), e));
16213
+ const covered = hit.get(key) ?? [];
16214
+ record.matched = covered.length;
16215
+ record.evidence = covered.map((e) => evidenceOrReason(String(record.code), e));
16216
16216
  if (record.matched === 0) {
16217
16217
  record.accepted = false;
16218
16218
  record.why = `\u8FD9\u4EFD\u8C41\u514D\u672C\u8EAB\u5408\u89C4\uFF0C\u4F46**\u6CA1\u6709\u5BF9\u5E94\u7684\u98CE\u9669\u9879**\uFF1A\u8FD9\u4E00\u8F6E\u6CA1\u6709 code=${String(record.code)} / model=${String(record.model)} / field=${String(record.field)} \u8FD9\u4E00\u6761`;
@@ -16564,8 +16564,8 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
16564
16564
  const baseline = options.baseline ?? null;
16565
16565
  const loadIndex = options.loadKeyIndexImpl ?? loadKeyIndex;
16566
16566
  const mapping = loadMapping(mappingPath);
16567
- const scan2 = await scanSources(mapping, sourceDir);
16568
- const problems = [...scan2.problems, ...validateMapping(mapping, scan2.headers)];
16567
+ const scan = await scanSources(mapping, sourceDir);
16568
+ const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
16569
16569
  if (problems.length) {
16570
16570
  const converted = problems.map(fromArtifactProblem);
16571
16571
  converted.push({
@@ -16581,7 +16581,7 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
16581
16581
  roundId: newRoundId(/* @__PURE__ */ new Date()),
16582
16582
  models: [],
16583
16583
  problems: converted,
16584
- notes: [...scan2.notes],
16584
+ notes: [...scan.notes],
16585
16585
  crossModelOrder: orderNotChecked(),
16586
16586
  baseline
16587
16587
  };
@@ -16597,8 +16597,8 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
16597
16597
  indexErrors.set(mm.model, e.hint ? e.message : `${e.message} \u2014\u2014 \u5148\u628A\u53D6\u6570\u95EE\u9898\u89E3\u51B3\u518D\u8DD1\u4E00\u6B21`);
16598
16598
  }
16599
16599
  }
16600
- return buildImportPlan(mapping, scan2.rows, indexes, {
16601
- notes: [...scan2.notes],
16600
+ return buildImportPlan(mapping, scan.rows, indexes, {
16601
+ notes: [...scan.notes],
16602
16602
  indexErrors,
16603
16603
  baseline
16604
16604
  });
@@ -19251,12 +19251,12 @@ function fromArtifactProblem2(p) {
19251
19251
  }
19252
19252
  async function riskFromArtifacts(mappingPath, reconDir, options = {}) {
19253
19253
  const mapping = loadMapping(mappingPath);
19254
- const scan2 = await scanSources(mapping, options.sourceDir);
19255
- const problems = [...scan2.problems, ...validateMapping(mapping, scan2.headers)];
19254
+ const scan = await scanSources(mapping, options.sourceDir);
19255
+ const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
19256
19256
  if (problems.length === 0) {
19257
19257
  return buildRisk(mapping, reconDir, {
19258
- notes: [...scan2.notes],
19259
- tables: scan2.rows,
19258
+ notes: [...scan.notes],
19259
+ tables: scan.rows,
19260
19260
  exemptions: options.exemptions,
19261
19261
  plan: options.plan,
19262
19262
  roundPremise: options.roundPremise
@@ -19284,7 +19284,7 @@ async function riskFromArtifacts(mappingPath, reconDir, options = {}) {
19284
19284
  problems: converted,
19285
19285
  // 🔴 `notes` 照常带出:源表扫过了(扫描在校验之前跑),丢掉它等于把已经查到的事实
19286
19286
  // 一起扔了。
19287
- notes: [...scan2.notes],
19287
+ notes: [...scan.notes],
19288
19288
  notesProvided: true,
19289
19289
  exemptions: [],
19290
19290
  // 🔴 传了豁免也**没有判**(一条风险项都没算出来,无从匹配)⇒ 这里必须是 false:
@@ -19745,1141 +19745,6 @@ function renderValues(root, model, options = {}) {
19745
19745
  return { ok: true, text: out };
19746
19746
  }
19747
19747
 
19748
- // src/fde/gate0/aclass.ts
19749
- import { existsSync as existsSync13, readFileSync as readFileSync12, readdirSync as readdirSync3, statSync as statSync10 } from "fs";
19750
- import * as path21 from "path";
19751
-
19752
- // src/fde/gate0/mapping-artifact.ts
19753
- import { readFileSync as readFileSync11 } from "fs";
19754
- var MAPPING_ARTIFACT_VERSION = 1;
19755
- var MappingArtifactError = class extends Error {
19756
- constructor(reason, message) {
19757
- super(`[${reason}] ${message}`);
19758
- this.reason = reason;
19759
- this.message = message;
19760
- this.name = "MappingArtifactError";
19761
- }
19762
- reason;
19763
- message;
19764
- };
19765
- function isRecord6(value) {
19766
- return typeof value === "object" && value !== null && !Array.isArray(value);
19767
- }
19768
- function readBusinessKeyFields(file) {
19769
- let text2;
19770
- try {
19771
- text2 = readFileSync11(file, "utf8");
19772
- } catch (e) {
19773
- const code = e?.code;
19774
- if (code === "ENOENT") throw new MappingArtifactError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`);
19775
- throw new MappingArtifactError("unreadable", `${file} \u8BFB\u4E0D\u52A8\uFF08${String(e)}\uFF09`);
19776
- }
19777
- if (text2.charCodeAt(0) === 65279) text2 = text2.slice(1);
19778
- let body;
19779
- try {
19780
- body = JSON.parse(text2);
19781
- } catch (e) {
19782
- throw new MappingArtifactError("not-json", `${file} \u4E0D\u662F\u5408\u6CD5 JSON\uFF1A${String(e)}`);
19783
- }
19784
- if (!isRecord6(body)) {
19785
- throw new MappingArtifactError("bad-shape", `${file} \u7684\u6839\u4E0D\u662F\u5BF9\u8C61`);
19786
- }
19787
- if (!("version" in body)) {
19788
- throw new MappingArtifactError("version-missing", `${file} \u6CA1\u6709 version \u5B57\u6BB5`);
19789
- }
19790
- if (body.version !== MAPPING_ARTIFACT_VERSION) {
19791
- throw new MappingArtifactError(
19792
- "unsupported-version",
19793
- `${file} \u7684 version \u662F ${JSON.stringify(body.version)}\uFF0C\u672C\u5DE5\u5177\u53EA\u8BA4 ${MAPPING_ARTIFACT_VERSION} \u2014\u2014\u300C\u5C3D\u91CF\u6309\u8001\u7248\u672C\u8BFB\u300D\u4F1A\u628A\u65B0\u8BED\u4E49\u9759\u9ED8\u4E22\u6389`
19794
- );
19795
- }
19796
- const models = body.models;
19797
- if (!Array.isArray(models)) {
19798
- throw new MappingArtifactError(
19799
- "bad-shape",
19800
- `${file} \u7684 models \u5E94\u5F53\u662F\u4E00\u4E2A\u6570\u7EC4\uFF0C\u5B9E\u9645\u662F ${models === null ? "null" : typeof models}`
19801
- );
19802
- }
19803
- if (models.length === 0) {
19804
- throw new MappingArtifactError(
19805
- "empty",
19806
- `${file} \u7684 models \u662F\u7A7A\u7684 \u2014\u2014 \u7A7A\u5DE5\u4EF6\u8DD1\u5B8C\u4EC0\u4E48\u4E5F\u4E0D\u4F1A\u53D1\u751F\uFF0C\u800C\u987E\u95EE\u4F1A\u4EE5\u4E3A\u300C\u5BFC\u8FC7\u4E86\u300D`
19807
- );
19808
- }
19809
- return models.map((raw, i) => {
19810
- if (!isRecord6(raw)) {
19811
- throw new MappingArtifactError("bad-shape", `${file} \u7684 models[${i}] \u4E0D\u662F\u5BF9\u8C61`);
19812
- }
19813
- const businessKey = raw.businessKey;
19814
- if (businessKey === void 0 || businessKey === null) return [];
19815
- if (!isRecord6(businessKey)) {
19816
- throw new MappingArtifactError("bad-shape", `${file} \u7684 models[${i}].businessKey \u4E0D\u662F\u5BF9\u8C61`);
19817
- }
19818
- const fields = businessKey.fields;
19819
- if (fields === void 0 || fields === null) return [];
19820
- if (!Array.isArray(fields)) {
19821
- throw new MappingArtifactError(
19822
- "bad-shape",
19823
- `${file} \u7684 models[${i}].businessKey.fields \u4E0D\u662F\u6570\u7EC4`
19824
- );
19825
- }
19826
- return fields.filter((f) => typeof f === "string" && f !== "");
19827
- });
19828
- }
19829
-
19830
- // src/fde/gate0/aclass.ts
19831
- var ACLASS_KINDS = [
19832
- "fieldKey",
19833
- "fieldLabel",
19834
- "enumValue",
19835
- "modelName",
19836
- "codeValue",
19837
- "naturalKey",
19838
- "caliber"
19839
- ];
19840
- var FIELDS_INDEX = ["index", "fields.jsonl"];
19841
- var ENUM_MIRROR = ["valuedomain", "_enums.jsonl"];
19842
- var MODEL_ROSTER = ["models.json"];
19843
- var VALUE_DOMAIN_DIR = "valuedomain";
19844
- var ENUM_ELEMENT_KEYS = ["value", "label", "key"];
19845
- var MAPPING_ARTIFACT_HINT = "work/mapping.json";
19846
- var CLASS_SCOPE = "class";
19847
- var ENTRY_SCOPE = "entry";
19848
- var SCOPES = [CLASS_SCOPE, ENTRY_SCOPE];
19849
- var REASON_UNREAD = "unread";
19850
- var REASON_EMPTY = "empty";
19851
- var CLASS_REASONS = [REASON_UNREAD, REASON_EMPTY];
19852
- function unguardedKinds(problems) {
19853
- const out = /* @__PURE__ */ new Set();
19854
- for (const problem6 of problems) {
19855
- if (!SCOPES.includes(problem6.scope)) {
19856
- throw new Error(
19857
- `\u53F0\u8D26\u7684 scope \u53EA\u6709 ${SCOPES.join("/")} \u4E24\u4E2A\u53D6\u503C\uFF0C\u62FF\u5230\u7684\u662F ${JSON.stringify(problem6.scope)}\uFF08${problem6.message}\uFF09`
19858
- );
19859
- }
19860
- if (problem6.scope === CLASS_SCOPE) for (const kind of problem6.kinds) out.add(kind);
19861
- }
19862
- return out;
19863
- }
19864
- function unguardedWord(kinds) {
19865
- return kinds.join("/");
19866
- }
19867
- function token(value) {
19868
- if (typeof value === "string") return value === "" ? null : value;
19869
- if (typeof value === "number" && Number.isFinite(value)) return String(value);
19870
- return null;
19871
- }
19872
- function scalarsWithin(value) {
19873
- if (Array.isArray(value)) return value.flatMap(scalarsWithin);
19874
- if (typeof value === "object" && value !== null) {
19875
- return Object.values(value).flatMap(scalarsWithin);
19876
- }
19877
- const one = token(value);
19878
- return one === null ? [] : [one];
19879
- }
19880
- function readText(file, kinds, scope, problems) {
19881
- try {
19882
- return readFileSync12(file, "utf8");
19883
- } catch (e) {
19884
- const code = e?.code;
19885
- const name = path21.basename(file);
19886
- problems.push({
19887
- scope,
19888
- reason: REASON_UNREAD,
19889
- kinds,
19890
- message: code === "ENOENT" ? `\u7F3A\u4EA7\u7269 ${name} \u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88` : `\u4EA7\u7269 ${name} \u8BFB\u4E0D\u52A8\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
19891
- });
19892
- return null;
19893
- }
19894
- }
19895
- function readJsonl(file, kinds, scope, problems) {
19896
- const text2 = readText(file, kinds, scope, problems);
19897
- if (text2 === null) return [];
19898
- const name = path21.basename(file);
19899
- const rows = [];
19900
- text2.split("\n").forEach((raw, i) => {
19901
- const line = raw.trim();
19902
- if (line === "") return;
19903
- let row;
19904
- try {
19905
- row = JSON.parse(line);
19906
- } catch (e) {
19907
- problems.push({
19908
- scope: ENTRY_SCOPE,
19909
- reason: "bad-line",
19910
- kinds,
19911
- message: `${name}:${i + 1} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 \u8FD9\u4E00\u884C\u7684\u53D6\u503C\u6CA1\u6709\u8FDB ${unguardedWord(kinds)}`
19912
- });
19913
- return;
19914
- }
19915
- if (typeof row !== "object" || row === null || Array.isArray(row)) {
19916
- problems.push({
19917
- scope: ENTRY_SCOPE,
19918
- reason: "bad-line",
19919
- kinds,
19920
- message: `${name}:${i + 1} \u4E0D\u662F\u5BF9\u8C61\uFF08${row === null ? "null" : typeof row}\uFF09\u21D2 \u8FD9\u4E00\u884C\u7684\u53D6\u503C\u6CA1\u6709\u8FDB ${unguardedWord(kinds)}`
19921
- });
19922
- return;
19923
- }
19924
- rows.push(row);
19925
- });
19926
- return rows;
19927
- }
19928
- var UNREADABLE = /* @__PURE__ */ Symbol("unreadable");
19929
- function readJson3(file, kinds, scope, problems) {
19930
- const text2 = readText(file, kinds, scope, problems);
19931
- if (text2 === null) return UNREADABLE;
19932
- try {
19933
- return JSON.parse(text2);
19934
- } catch (e) {
19935
- problems.push({
19936
- scope,
19937
- reason: REASON_UNREAD,
19938
- kinds,
19939
- message: `\u4EA7\u7269 ${path21.basename(file)} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
19940
- });
19941
- return UNREADABLE;
19942
- }
19943
- }
19944
- function listUnder(payload, key, file, kinds, scope, problems) {
19945
- const name = path21.basename(file);
19946
- if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
19947
- problems.push({
19948
- scope,
19949
- reason: REASON_UNREAD,
19950
- kinds,
19951
- message: `\u4EA7\u7269 ${name} \u4E0D\u662F\u5BF9\u8C61\uFF08${payload === null ? "null" : Array.isArray(payload) ? "array" : typeof payload}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
19952
- });
19953
- return [];
19954
- }
19955
- const body = payload;
19956
- if (!(key in body)) {
19957
- problems.push({
19958
- scope,
19959
- reason: REASON_UNREAD,
19960
- kinds,
19961
- message: `\u4EA7\u7269 ${name} \u91CC\u6CA1\u6709 ${key} \u8FD9\u4E2A\u952E\uFF08\u9876\u5C42\u952E\u662F ${JSON.stringify(Object.keys(body).sort())}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
19962
- });
19963
- return [];
19964
- }
19965
- const value = body[key];
19966
- if (!Array.isArray(value)) {
19967
- problems.push({
19968
- scope,
19969
- reason: REASON_UNREAD,
19970
- kinds,
19971
- message: `\u4EA7\u7269 ${name} \u7684 ${key} \u4E0D\u662F\u6570\u7EC4\uFF08${value === null ? "null" : typeof value}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
19972
- });
19973
- return [];
19974
- }
19975
- return value;
19976
- }
19977
- function deriveAclass(root, mappingArtifact = null) {
19978
- const problems = [];
19979
- const out = Object.fromEntries(ACLASS_KINDS.map((k) => [k, /* @__PURE__ */ new Set()]));
19980
- for (const row of readJsonl(
19981
- path21.join(root, ...FIELDS_INDEX),
19982
- ["fieldKey", "fieldLabel", "caliber"],
19983
- CLASS_SCOPE,
19984
- problems
19985
- )) {
19986
- const key = token(row.key);
19987
- if (key !== null) out.fieldKey.add(key);
19988
- const name = token(row.name);
19989
- if (name !== null) out.fieldLabel.add(name);
19990
- const synonyms = row.synonyms;
19991
- for (const syn of Array.isArray(synonyms) ? synonyms : []) {
19992
- const one = token(syn);
19993
- if (one !== null) out.caliber.add(one);
19994
- }
19995
- }
19996
- for (const row of readJsonl(
19997
- path21.join(root, ...ENUM_MIRROR),
19998
- ["enumValue"],
19999
- CLASS_SCOPE,
20000
- problems
20001
- )) {
20002
- const enums = row.enums;
20003
- for (const element of Array.isArray(enums) ? enums : []) {
20004
- if (typeof element !== "object" || element === null || Array.isArray(element)) continue;
20005
- for (const field of ENUM_ELEMENT_KEYS) {
20006
- const one = token(element[field]);
20007
- if (one !== null) out.enumValue.add(one);
20008
- }
20009
- }
20010
- }
20011
- const rosterPath = path21.join(root, ...MODEL_ROSTER);
20012
- const roster = readJson3(rosterPath, ["modelName"], CLASS_SCOPE, problems);
20013
- if (roster !== UNREADABLE) {
20014
- const rows = listUnder(roster, "models", rosterPath, ["modelName"], CLASS_SCOPE, problems);
20015
- const entries = modelEntries(roster);
20016
- const keys = modelKeys(roster);
20017
- for (const key of keys) out.modelName.add(key);
20018
- for (const entry of entries) {
20019
- const name = token(entry.name);
20020
- if (name !== null) out.modelName.add(name);
20021
- }
20022
- if (rows.length !== entries.length) {
20023
- problems.push({
20024
- scope: ENTRY_SCOPE,
20025
- reason: "dropped-entries",
20026
- kinds: ["modelName"],
20027
- message: `models.json \u91CC ${rows.length} \u6761\u6A21\u578B\u6761\u76EE\u6709 ${rows.length - entries.length} \u6761\u4E0D\u662F\u5BF9\u8C61 \u21D2 \u5B83\u4EEC\u7684\u6A21\u578B\u540D\u6CA1\u6709\u8FDB modelName`
20028
- });
20029
- }
20030
- if (entries.length !== keys.length) {
20031
- problems.push({
20032
- scope: ENTRY_SCOPE,
20033
- reason: "dropped-keys",
20034
- kinds: ["modelName"],
20035
- message: `models.json \u91CC ${entries.length} \u6761\u6A21\u578B\u6761\u76EE\u6709 ${entries.length - keys.length} \u6761\u6CA1\u6709 modelKey \u21D2 \u5B83\u4EEC\u7684\u82F1\u6587\u6A21\u578B\u540D\u6CA1\u6709\u8FDB modelName`
20036
- });
20037
- }
20038
- }
20039
- const valueDomain = path21.join(root, VALUE_DOMAIN_DIR);
20040
- if (existsSync13(valueDomain) && statSync10(valueDomain).isDirectory()) {
20041
- const tables = readdirSync3(valueDomain).filter((f) => f.endsWith(".json") && !RESERVED_FILENAMES.includes(f)).sort();
20042
- for (const name of tables) {
20043
- const file = path21.join(valueDomain, name);
20044
- const payload = readJson3(file, ["codeValue"], ENTRY_SCOPE, problems);
20045
- if (payload === UNREADABLE) continue;
20046
- for (const row of listUnder(payload, "rows", file, ["codeValue"], ENTRY_SCOPE, problems)) {
20047
- if (typeof row !== "object" || row === null || Array.isArray(row)) {
20048
- problems.push({
20049
- scope: ENTRY_SCOPE,
20050
- reason: "bad-row",
20051
- kinds: ["codeValue"],
20052
- message: `${name} \u7684 rows \u91CC\u6709\u4E00\u4E2A\u5143\u7D20\u4E0D\u662F\u5BF9\u8C61\uFF08${row === null ? "null" : typeof row}\uFF09\u21D2 \u5B83\u7684\u53D6\u503C\u6CA1\u6709\u8FDB codeValue`
20053
- });
20054
- continue;
20055
- }
20056
- for (const value of scalarsWithin(row)) out.codeValue.add(value);
20057
- }
20058
- }
20059
- } else {
20060
- problems.push({
20061
- scope: CLASS_SCOPE,
20062
- reason: REASON_UNREAD,
20063
- kinds: ["codeValue"],
20064
- message: `\u7F3A\u4EA7\u7269\u76EE\u5F55 ${VALUE_DOMAIN_DIR}/ \u21D2 codeValue \u8FD9\u4E00\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
20065
- });
20066
- }
20067
- let businessKeys = null;
20068
- if (mappingArtifact === null) {
20069
- problems.push({
20070
- scope: CLASS_SCOPE,
20071
- reason: REASON_UNREAD,
20072
- kinds: ["naturalKey"],
20073
- message: `\u6CA1\u6709\u6307\u5B9A\u6620\u5C04\u5DE5\u4EF6 \u21D2 naturalKey \u8FD9\u4E00\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88\uFF08\u628A ${MAPPING_ARTIFACT_HINT} \u7684\u8DEF\u5F84\u4F20\u8FDB\u6765\uFF09`
20074
- });
20075
- } else {
20076
- try {
20077
- businessKeys = readBusinessKeyFields(mappingArtifact);
20078
- } catch (e) {
20079
- const err = e;
20080
- problems.push({
20081
- scope: CLASS_SCOPE,
20082
- reason: REASON_UNREAD,
20083
- kinds: ["naturalKey"],
20084
- message: `\u6620\u5C04\u5DE5\u4EF6\u8BFB\u4E0D\u52A8\uFF08[${err.reason ?? "unknown"}] ${err.message}\uFF09\u21D2 naturalKey \u8FD9\u4E00\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
20085
- });
20086
- }
20087
- }
20088
- for (const fields of businessKeys ?? []) {
20089
- for (const field of fields) out.naturalKey.add(field);
20090
- if (fields.length > 1) {
20091
- out.naturalKey.add(fields.join("+"));
20092
- }
20093
- }
20094
- const named = unguardedKinds(problems);
20095
- for (const kind of ACLASS_KINDS) {
20096
- if (out[kind].size === 0 && !named.has(kind)) {
20097
- problems.push({
20098
- scope: CLASS_SCOPE,
20099
- reason: REASON_EMPTY,
20100
- kinds: [kind],
20101
- message: `${kind}\uFF1A\u4EA7\u7269\u8BFB\u5230\u4E86\uFF0C\u4F46\u4E00\u6761\u53D6\u503C\u90FD\u6CA1\u6D3E\u751F\u51FA\u6765 \u21D2 \u95E8 0 \u5BF9\u8FD9\u4E00\u7C7B\u6052\u7EFF\uFF08\u540C\u6279\u53F0\u8D26\u91CC\u82E5\u6709\u6761\u76EE\u7EA7\u95EE\u9898\uFF0C\u771F\u56E0\u5728\u90A3\u91CC\uFF09`
20102
- });
20103
- }
20104
- }
20105
- return { aclass: out, problems };
20106
- }
20107
-
20108
- // src/fde/gate0/facts.ts
20109
- import { existsSync as existsSync14, readFileSync as readFileSync13 } from "fs";
20110
- import * as path22 from "path";
20111
- var REGISTRY_SCOPE = "registry";
20112
- var ENTRY_SCOPE2 = "entry";
20113
- var REASON_NO_ENTRIES = "no-entries";
20114
- var REASON_PROBE_UNVERIFIED = "probe-unverified";
20115
- var REGISTRY_REASONS = [REASON_NO_ENTRIES, REASON_PROBE_UNVERIFIED];
20116
- var REASON_PROBE_SHAPE = "probe-shape";
20117
- var REASON_PROBE_ABSENT = "probe-absent";
20118
- var REASON_DUPLICATE_TOKEN = "duplicate-token";
20119
- var ENTRY_REASONS = [
20120
- REASON_PROBE_SHAPE,
20121
- REASON_PROBE_ABSENT,
20122
- REASON_DUPLICATE_TOKEN
20123
- ];
20124
- var FACTS_REASONS = [...REGISTRY_REASONS, ...ENTRY_REASONS];
20125
- var PROBE_SHAPE = /^(?<file>[A-Za-z0-9_./-]+\.test\.ts)::(?<mark>[A-Za-z0-9_-]+)$/;
20126
- var PROBE_MARK_PREFIX = "// P:";
20127
- var PROTOCOL_FACTS = [
20128
- {
20129
- token: "/api/models/{model}/meta",
20130
- probe: "packages/core/tests/fde-recon-crawl.test.ts::meta-path-wire-shape",
20131
- note: "\u5B57\u6BB5\u5143\u6570\u636E\u8D70\u88F8\u8DEF\u5F84 GET\uFF0C\u9ED8\u8BA4\u4E0D\u7F00 ?type=\u3002\u63A2\u9488\u65AD\u7684\u662F**\u5B9E\u9645\u53D1\u51FA\u53BB\u7684 URL**\uFF0C\u4E0D\u662F\u62FC\u4E32\u51FD\u6570\u7684\u8FD4\u56DE\u503C\u3002"
20132
- },
20133
- {
20134
- token: "/api/models/{model}/list/dsl",
20135
- probe: "packages/core/tests/fde-recon-valuedomain.test.ts::list-dsl-count-probe",
20136
- note: "\u5217\u8868\u67E5\u8BE2\u8D70 POST DSL\u3002\u63A2\u9488\u65AD\u7684\u662F\u884C\u4E3A\uFF1Asize=0 \u7684\u90A3\u4E00\u53D1\u5148\u51FA\u4E14\u8FD4\u56DE totalElements\uFF0C\u53D6\u9875\u5224\u636E\u4EE5\u6B64\u4E3A\u524D\u63D0\u3002"
20137
- },
20138
- {
20139
- token: "/api/auth/login",
20140
- probe: "packages/core/tests/fde-gate0-facts.test.ts::login-body-carries-tenant",
20141
- note: "\u767B\u5F55\u7684 tenantId \u5728**\u8BF7\u6C42\u4F53**\u91CC\uFF0C\u4E0D\u5728 header\u3002\u63A2\u9488\u65AD\u7684\u662F\u5B9E\u9645\u53D1\u51FA\u53BB\u7684\u8BF7\u6C42\u4F53\u4E0E\u8BF7\u6C42\u5934\uFF0C\u5220\u6389 tenantId \u6216\u632A\u8FDB header \u90FD\u4F1A\u7EA2\u3002"
20142
- },
20143
- {
20144
- token: "/api/tenant-extension/workspaces",
20145
- probe: "packages/core/tests/fde-triage-probe.test.ts::workspaces-path-wire-shape",
20146
- note: "\u5F00\u53D1\u7A7A\u95F4\u6E05\u5355\u8D70\u88F8\u8DEF\u5F84 GET\uFF0C\u662F\u5206\u8BCA\u4E03\u683C\u91CC `graaljs-spi` \u90A3\u4E00\u683C\u552F\u4E00\u8981\u8054\u7F51\u7684\u4E00\u53D1\u3002\u63A2\u9488\u65AD\u7684\u662F**\u6574\u8D9F\u5B9E\u9645\u6253\u51FA\u53BB\u7684\u8DEF\u5F84\u5217\u8868\u9010\u5B57\u76F8\u7B49**\uFF08\u4E0D\u662F\u300C\u542B\u67D0\u4E2A\u8BCD\u300D\uFF09\u2014\u2014\u8DEF\u5F84\u6539\u4E86\u3001\u6216\u8005\u522B\u7684\u683C\u5077\u5077\u591A\u6253\u4E86\u4E00\u53D1\uFF0C\u90FD\u4F1A\u7EA2\u3002"
20147
- }
20148
- ];
20149
- function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
20150
- const problems = [];
20151
- const probeRoot = options.probeRoot;
20152
- if (probeRoot === void 0 && entries !== PROTOCOL_FACTS) {
20153
- problems.push({
20154
- scope: REGISTRY_SCOPE,
20155
- reason: REASON_PROBE_UNVERIFIED,
20156
- index: 0,
20157
- token: null,
20158
- message: "\u8FD9\u4EFD\u767B\u8BB0\u518C\u4E0D\u662F\u968F\u5305\u90A3\u4E00\u4EFD\uFF0C\u53C8\u6CA1\u6709\u7ED9\u63A2\u9488\u6839\u76EE\u5F55 \u21D2 \u4E00\u6761\u63A2\u9488\u90FD\u6CA1\u9A8C\u8FC7 \u2014\u2014\u300C\u63A2\u9488\u90FD\u5728\u300D\u4E0E\u300C\u6CA1\u67E5\u63A2\u9488\u300D\u5728\u8FD4\u56DE\u503C\u4E0A\u540C\u5F62\uFF0C\u6240\u4EE5\u8FD9\u91CC\u8BB0\u4E00\u7B14\uFF0C\u4E0D\u88C5\u4F5C\u9A8C\u8FC7"
20159
- });
20160
- }
20161
- if (entries.length === 0) {
20162
- problems.push({
20163
- scope: REGISTRY_SCOPE,
20164
- reason: REASON_NO_ENTRIES,
20165
- index: 0,
20166
- token: null,
20167
- message: "\u767B\u8BB0\u518C\u4E00\u6761\u90FD\u6CA1\u6709 \u2014\u2014 **\u67E5\u8FC7\u4E14\u4E3A\u7A7A**\uFF0C\u4E0D\u662F\u300C\u6CA1\u67E5\u300D"
20168
- });
20169
- }
20170
- const times = /* @__PURE__ */ new Map();
20171
- for (const entry of entries) times.set(entry.token, (times.get(entry.token) ?? 0) + 1);
20172
- const facts = [];
20173
- entries.forEach((entry, position) => {
20174
- const index = position + 1;
20175
- if ((times.get(entry.token) ?? 0) > 1) {
20176
- problems.push({
20177
- scope: ENTRY_SCOPE2,
20178
- reason: REASON_DUPLICATE_TOKEN,
20179
- index,
20180
- token: entry.token,
20181
- message: `${entry.token} \u767B\u8BB0\u4E86\u4E0D\u6B62\u4E00\u6B21 \u21D2 \u4E24\u6761\u90FD\u4E0D\u8FDB P\uFF08\u7559\u4E0B\u4EFB\u4F55\u4E00\u8FB9\u90FD\u8981\u56DE\u7B54\u300C\u4EE5\u54EA\u4EFD\u4E3A\u51C6\u300D\uFF09`
20182
- });
20183
- return;
20184
- }
20185
- const shape = PROBE_SHAPE.exec(entry.probe);
20186
- if (!shape?.groups) {
20187
- problems.push({
20188
- scope: ENTRY_SCOPE2,
20189
- reason: REASON_PROBE_SHAPE,
20190
- index,
20191
- token: entry.token,
20192
- message: `${entry.token} \u7684\u63A2\u9488 ${JSON.stringify(entry.probe)} \u4E0D\u662F \`<\u6D4B\u8BD5\u6587\u4EF6>.test.ts::<\u6807\u8BB0>\` \u5F62\u6001 \u2014\u2014 \u53EA\u7ED9\u6587\u4EF6\u8DEF\u5F84\u662F\u540C\u4E49\u53CD\u590D\uFF08\u300C\u90A3\u4E2A\u6587\u4EF6\u5B58\u5728\u300D\u4E0D\u7B97\u80CC\u4E66\uFF09`
20193
- });
20194
- return;
20195
- }
20196
- if (probeRoot !== void 0) {
20197
- const file = path22.join(probeRoot, shape.groups.file);
20198
- const mark = `${PROBE_MARK_PREFIX} ${shape.groups.mark}`;
20199
- const found = existsSync14(file) && readFileSync13(file, "utf8").includes(mark);
20200
- if (!found) {
20201
- problems.push({
20202
- scope: ENTRY_SCOPE2,
20203
- reason: REASON_PROBE_ABSENT,
20204
- index,
20205
- token: entry.token,
20206
- message: `${entry.token} \u7684\u63A2\u9488\u6307\u5411 ${entry.probe}\uFF0C\u4F46\u90A3\u91CC\u627E\u4E0D\u5230 \`${mark}\` \u8FD9\u6761\u6807\u8BB0 \u21D2 \u8FD9\u6761\u767B\u8BB0\u6CA1\u6709\u80CC\u4E66\uFF0C\u4E0D\u8FDB P`
20207
- });
20208
- return;
20209
- }
20210
- }
20211
- facts.push(entry.token);
20212
- });
20213
- return { facts, problems };
20214
- }
20215
-
20216
- // src/fde/gate0/scan.ts
20217
- import { readFileSync as readFileSync14, readdirSync as readdirSync4, readlinkSync, statSync as statSync11 } from "fs";
20218
- import * as path23 from "path";
20219
-
20220
- // src/fde/gate0/owned.ts
20221
- var OWNED_CODE_SETS = [
20222
- PROBLEM_CODES,
20223
- RISK_CODES,
20224
- APPLY_PROBLEM_CODES,
20225
- PLAN_PROBLEM_CODES
20226
- ];
20227
- var OWNED_CODES = new Set(OWNED_CODE_SETS.flat());
20228
-
20229
- // src/fde/gate0/scan.ts
20230
- var CHANNEL_ARTIFACT = "artifact-path";
20231
- var CHANNEL_UNREGISTERED = "protocol-unregistered";
20232
- var CHANNEL_REGISTERED_IS_ACLASS = "registered-but-is-aclass";
20233
- var CHANNEL_NO_PROBE = "no-probe";
20234
- var CHANNELS = [
20235
- CHANNEL_ARTIFACT,
20236
- CHANNEL_UNREGISTERED,
20237
- CHANNEL_REGISTERED_IS_ACLASS,
20238
- CHANNEL_NO_PROBE
20239
- ];
20240
- var REASON_NO_SKILL_ROOT = "no-skill-root";
20241
- var REASON_NOTHING_SCANNED = "nothing-scanned";
20242
- var REASON_FILE_UNREADABLE = "file-unreadable";
20243
- var REASON_ACLASS_EMPTY = "aclass-empty";
20244
- var REASON_ACLASS_PARTIALLY_UNREAD = "aclass-partially-unread";
20245
- var REASON_REGISTRY = "registry-not-established";
20246
- var REASON_CHANNEL_FOUR_UNCHECKED = "channel-four-unchecked";
20247
- var REASON_BASELINE_ROUND_NOT_COMPLETE = "baseline-round-not-complete";
20248
- var REASON_SYMLINK_NOT_SCANNED = "symlink-not-scanned";
20249
- var PREMISE_REASONS = [
20250
- REASON_NO_SKILL_ROOT,
20251
- REASON_NOTHING_SCANNED,
20252
- REASON_FILE_UNREADABLE,
20253
- REASON_ACLASS_EMPTY,
20254
- REASON_ACLASS_PARTIALLY_UNREAD,
20255
- REASON_REGISTRY,
20256
- REASON_CHANNEL_FOUR_UNCHECKED,
20257
- REASON_BASELINE_ROUND_NOT_COMPLETE,
20258
- REASON_SYMLINK_NOT_SCANNED
20259
- ];
20260
- var PREMISE_REGISTRY_REASONS = REGISTRY_REASONS.filter(
20261
- (r) => r !== REASON_NO_ENTRIES
20262
- );
20263
- var WORD_RE = /[A-Za-z0-9_]+/g;
20264
- var SIMPLE_TOKEN = /^[A-Za-z0-9_]+$/;
20265
- var WORD_CHARS = new Set("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_");
20266
- function isWordChar(char) {
20267
- return char !== void 0 && WORD_CHARS.has(char);
20268
- }
20269
- var ENDPOINT_PREFIXES = ["api", "ws"];
20270
- var ENDPOINT_PATH = `/(?:${ENDPOINT_PREFIXES.join("|")})(?:/(?:\\{[A-Za-z0-9_]+\\}|[A-Za-z0-9_.\\-]+))+`;
20271
- var BARE_ENDPOINT_RE = new RegExp(`(?<![A-Za-z0-9_.\\-/])${ENDPOINT_PATH}`, "g");
20272
- var URL_ENDPOINT_RE = new RegExp(
20273
- `[A-Za-z][A-Za-z0-9+.\\-]*://[^\\s"'\`<>]*?(${ENDPOINT_PATH})`,
20274
- "g"
20275
- );
20276
- var HOSTLESS_HOST = `(?:(?:[A-Za-z0-9_\\-]+\\.)+[A-Za-z]{2,}(?::[0-9]+)?|[A-Za-z0-9_\\-]+:[0-9]+)`;
20277
- var HOSTLESS_ENDPOINT_RE = new RegExp(
20278
- `(?<![A-Za-z0-9_.\\-/:@])${HOSTLESS_HOST}(${ENDPOINT_PATH})`,
20279
- "g"
20280
- );
20281
- var ERROR_CODE_RE = /(?<![A-Za-z0-9_])[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+(?![A-Za-z0-9_])/g;
20282
- var PATHISH_RE = /(?<![A-Za-z0-9_./-])\.?[A-Za-z0-9_.-]+(?:\/[A-Za-z0-9_.-]+)+/g;
20283
- var ARTIFACT_SUFFIXES = [".json", ".jsonl"];
20284
- var PRODUCT_FILE_RE = new RegExp(
20285
- `(?<![A-Za-z0-9_./\\-])[A-Za-z0-9_.\\-]+(?:${ARTIFACT_SUFFIXES.map((s) => s.replace(".", "\\.")).join("|")})(?![A-Za-z0-9_])`,
20286
- "g"
20287
- );
20288
- var PLACEHOLDER_RE2 = /\{[A-Za-z0-9_]*\}/g;
20289
- var ARTIFACT_ROOT = ".hcmnx";
20290
- var RECON_DIRNAME2 = "recon";
20291
- var RECON_SEGMENTS_BELOW_ROOT = 2;
20292
- var PRODUCT_RELATIVE_SHAPES = [
20293
- ["index", ".md"],
20294
- ["index", ".jsonl"],
20295
- ["mapping", ".json"],
20296
- ["meta", ".json"],
20297
- ["valuedomain", ".json"],
20298
- ["valuedomain", ".jsonl"]
20299
- ];
20300
- var REASON_PRODUCT_TREE_PATH = "product-tree-path";
20301
- var REASON_PRODUCT_RELATIVE_PATH = "product-relative-path";
20302
- var REASON_PRODUCT_FILE_NAME = "product-file-name";
20303
- var REASON_ENDPOINT = "endpoint";
20304
- var REASON_ERROR_CODE = "error-code";
20305
- var REASON_REGISTERED_IS_ACLASS = "registered-is-aclass";
20306
- var REASON_REJECTED_REGISTRATION = "rejected-registration";
20307
- var RED_REASONS = {
20308
- [CHANNEL_ARTIFACT]: [
20309
- REASON_PRODUCT_TREE_PATH,
20310
- REASON_PRODUCT_RELATIVE_PATH,
20311
- REASON_PRODUCT_FILE_NAME
20312
- ],
20313
- [CHANNEL_UNREGISTERED]: [REASON_ENDPOINT, REASON_ERROR_CODE],
20314
- [CHANNEL_REGISTERED_IS_ACLASS]: [REASON_REGISTERED_IS_ACLASS],
20315
- [CHANNEL_NO_PROBE]: [REASON_REJECTED_REGISTRATION]
20316
- };
20317
- var ARTIFACT_WORDING = {
20318
- [REASON_PRODUCT_TREE_PATH]: (t) => `\u51FA\u73B0**\u4EA7\u7269\u6811\u91CC\u7684**\u8DEF\u5F84 ${JSON.stringify(t)}`,
20319
- [REASON_PRODUCT_RELATIVE_PATH]: (t) => `\u51FA\u73B0**\u4EA7\u7269\u6839\u76F8\u5BF9\u8DEF\u5F84** ${JSON.stringify(t)}\uFF08\u4EA7\u7269\u5B50\u76EE\u5F55\u4E0B\u7684\u90A3\u4E00\u4EFD\uFF09`,
20320
- [REASON_PRODUCT_FILE_NAME]: (t) => `\u51FA\u73B0\u4EA7\u7269\u6587\u4EF6\u540D\u5F62\u6001 ${JSON.stringify(t)}\uFF08\u4EE5 .json/.jsonl \u6536\u5C3E\uFF1B**\u8FD9\u4E00\u6863\u4F1A\u8FC7\u5224**\uFF0C\u5B83\u4E0E\u4EA7\u7269\u65E0\u5173\u65F6\u8BF7\u7167\u76F4\u8BF4\u660E\uFF09`
20321
- };
20322
- function artifactWordingFor(reason) {
20323
- const wording = ARTIFACT_WORDING[reason];
20324
- if (wording === void 0) {
20325
- throw new Error(
20326
- `\u4EA7\u7269\u8DEF\u5F84\u6210\u56E0 ${JSON.stringify(reason)} \u6CA1\u6709\u5BF9\u5E94\u7684\u63AA\u8F9E\uFF08\u8BA4\u5F97\u7684\u662F ${Object.keys(ARTIFACT_WORDING).join("/")}\uFF09`
20327
- );
20328
- }
20329
- return wording;
20330
- }
20331
- var ACLASS_EMPTY_WHY = {
20332
- [REASON_UNREAD]: "\uFF08\u4EA7\u7269/\u5DE5\u4EF6\u90A3\u4E00\u5934\u6839\u672C\u6CA1\u8BFB\u5230\uFF09",
20333
- [REASON_EMPTY]: "\uFF08\u4EA7\u7269\u8BFB\u5230\u4E86\uFF0C\u4E00\u6761\u53D6\u503C\u90FD\u6CA1\u6D3E\u751F\u51FA\u6765\uFF09"
20334
- };
20335
- var GAP_NOISE_TOKEN = "pure-digit-or-single-char";
20336
- var GAP_CJK_INSIDE_LONGER_RUN = "cjk-inside-longer-run";
20337
- var GAP_ACLASS_NOT_DISCRIMINATIVE = "aclass-not-discriminative";
20338
- var GAP_REASONS = [
20339
- GAP_NOISE_TOKEN,
20340
- GAP_CJK_INSIDE_LONGER_RUN,
20341
- GAP_ACLASS_NOT_DISCRIMINATIVE
20342
- ];
20343
- function checkReds(reds) {
20344
- for (const red of reds) {
20345
- if (!CHANNELS.includes(red.channel)) {
20346
- throw new Error(
20347
- `\u5224\u7EA2\u7684 channel \u53EA\u6709 ${CHANNELS.join("/")} \u8FD9\u51E0\u4E2A\u53D6\u503C\uFF0C\u62FF\u5230\u7684\u662F ${JSON.stringify(red.channel)}\uFF08${red.message}\uFF09`
20348
- );
20349
- }
20350
- if (!RED_REASONS[red.channel].includes(red.reason)) {
20351
- throw new Error(
20352
- `${JSON.stringify(red.reason)} \u8FD9\u4E2A reason \u4E0D\u5C5E\u4E8E ${red.channel} \u8FD9\u6761\u901A\u9053\uFF08\u8BA4\u5F97\u7684\u662F ${RED_REASONS[red.channel].join("/")}\uFF1B${red.message}\uFF09`
20353
- );
20354
- }
20355
- }
20356
- return [...reds];
20357
- }
20358
- function checkGaps(gaps) {
20359
- for (const gap of gaps) {
20360
- if (!GAP_REASONS.includes(gap.reason)) {
20361
- throw new Error(
20362
- `\u7F3A\u53E3\u53F0\u8D26\u7684 reason \u53EA\u6709 ${GAP_REASONS.join("/")} \u8FD9\u51E0\u4E2A\u53D6\u503C\uFF0C\u62FF\u5230\u7684\u662F ${JSON.stringify(gap.reason)}\uFF08${gap.why}\uFF09`
20363
- );
20364
- }
20365
- }
20366
- return [...gaps];
20367
- }
20368
- function checkPremise(problems) {
20369
- for (const problem6 of problems) {
20370
- if (!PREMISE_REASONS.includes(problem6.reason)) {
20371
- throw new Error(
20372
- `\u524D\u63D0\u7EA7\u53F0\u8D26\u7684 reason \u4E0D\u5728\u53D6\u503C\u57DF\u91CC\uFF1A${JSON.stringify(problem6.reason)}\uFF08${problem6.message}\uFF09`
20373
- );
20374
- }
20375
- }
20376
- return [...problems];
20377
- }
20378
- function baselineRoundPremise(round) {
20379
- const state = round && typeof round === "object" ? round.state : void 0;
20380
- if (state === "complete") return [];
20381
- return [
20382
- {
20383
- reason: REASON_BASELINE_ROUND_NOT_COMPLETE,
20384
- message: `\u8FD9\u4EFD\u57FA\u7EBF\u7684\u8F6E\u6B21\u72B6\u6001\u662F ${JSON.stringify(state)}\uFF08\u4E0D\u662F complete\uFF09\u21D2 A \u7C7B\u4E8B\u5B9E\u662F\u4ECE**\u6DF7\u7740\u4E0D\u540C\u8F6E\u6B21 / \u5224\u4E0D\u4E86\u8F6E\u6B21**\u7684\u4EA7\u7269\u91CC\u73B0\u7B97\u7684\uFF0C\u300C\u5224\u7EA2 0 \u6761\u300D\u5BF9\u54EA\u4E00\u8F6E\u90FD\u4E0D\u7B97\u6570\u3002\u5148\u8DD1 \`hcm chiron recon round\` \u770B\u662F\u54EA\u51E0\u4EFD\uFF0C\u6216\u91CD\u8DD1\u4E00\u6B21 \`hcm chiron recon\`\u3002\u26A0\uFE0F **\`hcm chiron recon\` \u8981\u8FDE\u5BA2\u6237\u5185\u7F51\u7684 HCM** \u2014\u2014 \u62FF\u4E0D\u5230\u7F51\u7684\u673A\u5668\u4E0A\u8FD9\u6761\u51FA\u8DEF\u8D70\u4E0D\u901A\uFF0C\u6B64\u65F6**\u522B\u628A\u8FD9\u4EFD\u57FA\u7EBF\u5F53 complete \u7528**\uFF0C\u628A\u5B83\u5E26\u56DE\u8FDE\u5F97\u4E0A\u7684\u5730\u65B9\u91CD\u722C`
20385
- }
20386
- ];
20387
- }
20388
- function inGap(token2) {
20389
- return [...token2].length <= 1 || /^\p{Nd}+$/u.test(token2);
20390
- }
20391
- function allMatches(regex, line) {
20392
- const out = [];
20393
- const re = new RegExp(regex.source, regex.flags.includes("g") ? regex.flags : `${regex.flags}g`);
20394
- let m;
20395
- while ((m = re.exec(line)) !== null) {
20396
- if (m[0] === "") {
20397
- re.lastIndex += 1;
20398
- continue;
20399
- }
20400
- out.push(m);
20401
- }
20402
- return out;
20403
- }
20404
- function overlaps(span, spans) {
20405
- return spans.some(([s, e]) => span[0] < e && s < span[1]);
20406
- }
20407
- function endpointsIn(line) {
20408
- const out = [];
20409
- for (const regex of [URL_ENDPOINT_RE, HOSTLESS_ENDPOINT_RE]) {
20410
- for (const m of allMatches(regex, line)) {
20411
- const span = [m.index, m.index + m[0].length];
20412
- if (!overlaps(
20413
- span,
20414
- out.map(([, s]) => s)
20415
- )) {
20416
- out.push([m[1], span]);
20417
- }
20418
- }
20419
- }
20420
- for (const m of allMatches(BARE_ENDPOINT_RE, line)) {
20421
- const span = [m.index, m.index + m[0].length];
20422
- if (!overlaps(
20423
- span,
20424
- out.map(([, s]) => s)
20425
- )) {
20426
- out.push([m[0], span]);
20427
- }
20428
- }
20429
- return out;
20430
- }
20431
- function normalize(token2) {
20432
- return token2.replace(PLACEHOLDER_RE2, "{}");
20433
- }
20434
- function factsIndex(facts) {
20435
- return facts.map((token2) => segmentsOf(normalize(token2)));
20436
- }
20437
- function covered(token2, index) {
20438
- const segments = segmentsOf(normalize(token2));
20439
- return index.some(
20440
- (template2) => template2.length === segments.length && template2.every((t, i) => t === "{}" || t === segments[i])
20441
- );
20442
- }
20443
- var SEGMENT_SEPARATOR = "/";
20444
- function segmentsOf(token2) {
20445
- return token2.split(SEGMENT_SEPARATOR);
20446
- }
20447
- function artifactReason(token2) {
20448
- const segments = segmentsOf(token2);
20449
- const head = segments.slice(0, -1);
20450
- const last = segments[segments.length - 1] ?? "";
20451
- if (head.includes(ARTIFACT_ROOT)) return REASON_PRODUCT_TREE_PATH;
20452
- for (let i = 0; i < head.length; i += 1) {
20453
- if (head[i] === RECON_DIRNAME2 && segments.length - i - 1 > RECON_SEGMENTS_BELOW_ROOT) {
20454
- return REASON_PRODUCT_TREE_PATH;
20455
- }
20456
- }
20457
- if (segments.length === 2 && PRODUCT_RELATIVE_SHAPES.some(
20458
- ([subdir, suffix]) => segments[0] === subdir && last.endsWith(suffix)
20459
- )) {
20460
- return REASON_PRODUCT_RELATIVE_PATH;
20461
- }
20462
- if (ARTIFACT_SUFFIXES.some((suffix) => last.endsWith(suffix))) return REASON_PRODUCT_FILE_NAME;
20463
- return null;
20464
- }
20465
- var CJK_RANGES = [
20466
- [13312, 19903],
20467
- [19968, 40959],
20468
- [63744, 64255]
20469
- ];
20470
- function isCjk(char) {
20471
- const code = char?.codePointAt(0);
20472
- return code !== void 0 && CJK_RANGES.some(([low, high]) => code >= low && code <= high);
20473
- }
20474
- function boundedFind(line, token2) {
20475
- let start = line.indexOf(token2);
20476
- while (start >= 0) {
20477
- const end = start + token2.length;
20478
- const leftOk = start === 0 || !(isWordChar(token2[0]) && isWordChar(line[start - 1]));
20479
- const rightOk = end >= line.length || !(isWordChar(token2[token2.length - 1]) && isWordChar(line[end]));
20480
- if (leftOk && rightOk) return start;
20481
- start = line.indexOf(token2, start + 1);
20482
- }
20483
- return -1;
20484
- }
20485
- function cjkRunAt(line, start, token2) {
20486
- const end = start + token2.length;
20487
- if (isCjk(token2[0]) && start > 0 && isCjk(line[start - 1])) return true;
20488
- return isCjk(token2[token2.length - 1]) && end < line.length && isCjk(line[end]);
20489
- }
20490
- var Matcher = class {
20491
- owners;
20492
- simple;
20493
- byFirst;
20494
- constructor(aclass) {
20495
- this.owners = /* @__PURE__ */ new Map();
20496
- for (const kind of ACLASS_KINDS) {
20497
- for (const token2 of [...aclass[kind] ?? []].sort()) {
20498
- const owned = this.owners.get(token2);
20499
- if (owned) owned.push(kind);
20500
- else this.owners.set(token2, [kind]);
20501
- }
20502
- }
20503
- this.simple = new Set([...this.owners.keys()].filter((t) => SIMPLE_TOKEN.test(t)));
20504
- this.byFirst = /* @__PURE__ */ new Map();
20505
- for (const token2 of this.owners.keys()) {
20506
- if (this.simple.has(token2)) continue;
20507
- const first = token2[0];
20508
- if (first === void 0) continue;
20509
- const bucket = this.byFirst.get(first);
20510
- if (bucket) bucket.push(token2);
20511
- else this.byFirst.set(first, [token2]);
20512
- }
20513
- }
20514
- /**
20515
- * → 这一行命中的 `[(token, **有边界的**那一处的位置)]`,同一 token 一行只报一次。
20516
- *
20517
- * 🔴 **位置必须来自 `boundedFind`,不许再算一遍 `indexOf`**。起手那版用 `boundedFind`
20518
- * 确认「这一行**存在**一处合法边界命中」,返回的却是第一处裸子串 —— 可能根本不是那一处。
20519
- * 下游把这个位置交给 `cjkRunAt` 做分桶,于是**在同一行前面加一处诱饵写法就能把一条
20520
- * 真红压掉**。辖区 = 首/末字符为 CJK、另一端为词字符的**混合形态** token;纯 ASCII 与
20521
- * 纯 CJK 两个位置必然相等,所以此前每一项变异都照不到它。
20522
- * 「存在一处合法命中」是「这一处合法」的**必要条件**,不是充分条件。
20523
- *
20524
- * 🔴 **`sort` 不是洁癖,它是这份输出的确定性本身**:按插入序遍历会让非纯词形 token 的
20525
- * 先后随输入变化,集合、rc、判词全都一样,只有顺序变 —— 那正是「静默」的定义,
20526
- * 而它坏的是**验证仪器**:任何「前后两版输出逐字相等」的复核都会假红。
20527
- */
20528
- hits(line) {
20529
- const seen = /* @__PURE__ */ new Set();
20530
- const result = [];
20531
- for (const m of allMatches(WORD_RE, line)) {
20532
- const token2 = m[0];
20533
- if (token2 !== void 0 && this.simple.has(token2) && !seen.has(token2)) {
20534
- seen.add(token2);
20535
- result.push([token2, boundedFind(line, token2)]);
20536
- }
20537
- }
20538
- for (const char of [.../* @__PURE__ */ new Set([...line])].sort()) {
20539
- for (const token2 of this.byFirst.get(char) ?? []) {
20540
- if (seen.has(token2)) continue;
20541
- const start = boundedFind(line, token2);
20542
- if (start >= 0) {
20543
- seen.add(token2);
20544
- result.push([token2, start]);
20545
- }
20546
- }
20547
- }
20548
- return result;
20549
- }
20550
- };
20551
- function classReasons(problems) {
20552
- const out = /* @__PURE__ */ new Map();
20553
- for (const problem6 of problems ?? []) {
20554
- if (problem6.scope === CLASS_SCOPE) {
20555
- for (const kind of problem6.kinds) out.set(kind, problem6.reason);
20556
- }
20557
- }
20558
- return out;
20559
- }
20560
- var INVISIBLE_RE = /\p{Cf}/u;
20561
- var FULLWIDTH_ALNUM_RANGES = [
20562
- [65296, 65305, 65296 - 48],
20563
- [65313, 65338, 65313 - 65],
20564
- [65345, 65370, 65345 - 97]
20565
- ];
20566
- var FOLDED_NOTE = "\uFF1B\u26A0\uFE0F \u8FD9\u4E00\u5904\u662F**\u5F52\u4E00\u4E4B\u540E**\u624D\u8BA4\u51FA\u6765\u7684\uFF1A\u539F\u6587\u91CC\u5939\u4E86\u4E0D\u53EF\u89C1\u5B57\u7B26\u6216\u5168\u89D2\u5B57\u7B26\uFF0C\u76F4\u63A5\u6309\u4E0A\u9762\u8FD9\u4E2A\u8BCD\u53BB grep \u4F1A\u641C\u4E0D\u5230";
20567
- var foldedOriginal = (literal) => `\uFF0C\u539F\u6587\u91CC\u90A3\u4E00\u6BB5\u662F ${JSON.stringify(literal)}`;
20568
- function foldWithMap(line) {
20569
- const out = [];
20570
- const origin = [];
20571
- for (let i = 0; i < line.length; i += 1) {
20572
- const char = line[i];
20573
- if (INVISIBLE_RE.test(char)) continue;
20574
- const code = char.charCodeAt(0);
20575
- let folded = char;
20576
- for (const [low, high, offset] of FULLWIDTH_ALNUM_RANGES) {
20577
- if (code >= low && code <= high) {
20578
- folded = String.fromCharCode(code - offset);
20579
- break;
20580
- }
20581
- }
20582
- out.push(folded);
20583
- origin.push(i);
20584
- }
20585
- return [out.join(""), origin];
20586
- }
20587
- function foldConfusables(line) {
20588
- return foldWithMap(line)[0];
20589
- }
20590
- function foldedNoteFor(original, folded, token2) {
20591
- if (original.includes(token2)) return "";
20592
- let start = boundedFind(folded, token2);
20593
- if (start < 0) start = folded.indexOf(token2);
20594
- if (start < 0) {
20595
- return FOLDED_NOTE;
20596
- }
20597
- const [, origin] = foldWithMap(original);
20598
- const from = origin[start];
20599
- const to = origin[start + token2.length - 1];
20600
- if (from === void 0 || to === void 0) return FOLDED_NOTE;
20601
- return FOLDED_NOTE + foldedOriginal(original.slice(from, to + 1));
20602
- }
20603
- function judgeLine(line, lineno, rel, matcher, index, reds, gaps) {
20604
- const folded = foldConfusables(line);
20605
- const lineReds = [];
20606
- const lineGaps = [];
20607
- judgePass(line, lineno, rel, matcher, index, lineReds, lineGaps);
20608
- if (folded !== line) judgePass(folded, lineno, rel, matcher, index, lineReds, lineGaps);
20609
- const seen = /* @__PURE__ */ new Set();
20610
- const unique2 = [];
20611
- for (const red of lineReds) {
20612
- const key = `${red.channel} ${red.token}`;
20613
- if (seen.has(key)) continue;
20614
- seen.add(key);
20615
- unique2.push({ ...red, message: red.message + foldedNoteFor(line, folded, red.token) });
20616
- }
20617
- reds.push(...unique2);
20618
- const definite = new Set(
20619
- lineGaps.filter((g) => g.reason === GAP_ACLASS_NOT_DISCRIMINATIVE).map((g) => g.token)
20620
- );
20621
- const seenGaps = /* @__PURE__ */ new Set();
20622
- for (const gap of lineGaps) {
20623
- const key = `${gap.reason} ${gap.token}`;
20624
- if (seenGaps.has(key) || folded !== line && gap.reason !== GAP_ACLASS_NOT_DISCRIMINATIVE && definite.has(gap.token))
20625
- continue;
20626
- seenGaps.add(key);
20627
- gaps.push({ ...gap, why: gap.why + foldedNoteFor(line, folded, gap.token) });
20628
- }
20629
- }
20630
- function judgePass(line, lineno, rel, matcher, index, reds, gaps) {
20631
- for (const [token2, start] of matcher.hits(line)) {
20632
- const kinds = matcher.owners.get(token2) ?? [];
20633
- if (inGap(token2)) {
20634
- gaps.push({
20635
- reason: GAP_NOISE_TOKEN,
20636
- token: token2,
20637
- kinds,
20638
- path: rel,
20639
- line: lineno,
20640
- why: `${rel}:${lineno} \u7EAF\u6570\u5B57 / \u5355\u5B57\u7B26 ${JSON.stringify(token2)} \u2014\u2014 \u5224\u7EA2\u8FD9\u4E00\u5C42**\u58F0\u660E\u7684\u7F3A\u53E3**\uFF0C\u67E5\u8FC7\u3001\u6309\u7F3A\u53E3\u653E\u884C`
20641
- });
20642
- continue;
20643
- }
20644
- if (cjkRunAt(line, start, token2)) {
20645
- gaps.push({
20646
- reason: GAP_CJK_INSIDE_LONGER_RUN,
20647
- token: token2,
20648
- kinds,
20649
- path: rel,
20650
- line: lineno,
20651
- why: `${rel}:${lineno} ${JSON.stringify(token2)}\uFF08A \u7C7B ${kinds.join("/")}\uFF09\u843D\u5728\u4E00\u4E32\u66F4\u957F\u7684\u4E2D\u6587\u91CC \u2014\u2014 \u4E2D\u6587\u6CA1\u6709\u5206\u8BCD\u8FB9\u754C\uFF0C**\u8BF4\u4E0D\u51C6**\u5B83\u662F\u4E0D\u662F\u90A3\u4E2A\u53D6\u503C\uFF1B\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C`
20652
- });
20653
- continue;
20654
- }
20655
- gaps.push({
20656
- reason: GAP_ACLASS_NOT_DISCRIMINATIVE,
20657
- token: token2,
20658
- kinds,
20659
- path: rel,
20660
- line: lineno,
20661
- why: `${rel}:${lineno} ${JSON.stringify(token2)} \u5728\u57FA\u7EBF\u91CC\u51FA\u73B0\u8FC7\uFF08A \u7C7B ${kinds.join("/")}\uFF09\u2014\u2014 **\u8FD9\u53E5\u8BDD\u51E0\u4E4E\u4E0D\u542B\u4FE1\u606F\u91CF**\uFF1A\u57FA\u7EBF\u662F\u4EA7\u54C1\u5168\u91CF\uFF0C\u4E0B\u4E00\u4E2A\u5BA2\u6237\u88C5\u7684\u662F\u540C\u4E00\u4E2A\u4EA7\u54C1\uFF0C\u8FD9\u4E2A\u5B57\u9762\u5728\u90A3\u8FB9\u4E5F\u4E00\u6837\u5728\u3002\u4E0D\u9876 rc\uFF0C\u8BF7\u81EA\u5DF1\u770B\u4E00\u773C\u5B83\u5230\u5E95\u662F\u4E0D\u662F\u53D6\u503C`
20662
- });
20663
- }
20664
- const spans = [];
20665
- for (const [token2, span] of endpointsIn(line)) {
20666
- spans.push(span);
20667
- judgeProtocol(token2, REASON_ENDPOINT, "\u7AEF\u70B9", lineno, rel, matcher, index, reds);
20668
- }
20669
- for (const regex of [PATHISH_RE, PRODUCT_FILE_RE]) {
20670
- for (const m of allMatches(regex, line)) {
20671
- const span = [m.index, m.index + m[0].length];
20672
- if (overlaps(span, spans)) continue;
20673
- const token2 = m[0];
20674
- const reason = artifactReason(token2);
20675
- if (reason === null) continue;
20676
- spans.push(span);
20677
- reds.push({
20678
- channel: CHANNEL_ARTIFACT,
20679
- reason,
20680
- token: token2,
20681
- path: rel,
20682
- line: lineno,
20683
- kinds: [],
20684
- message: `${rel}:${lineno} ${artifactWordingFor(reason)(token2)} \u2014\u2014 \u4EA7\u7269\u8DEF\u5F84**\u65E0\u8C41\u514D**\uFF0C\u767B\u8BB0\u518C\u4E0D\u53D7\u7406\u5B83\uFF1Bskill \u6B63\u6587\u8BE5\u8BF4\u7684\u662F\u8DD1\u54EA\u6761\u547D\u4EE4\uFF0C\u4E0D\u662F\u53BB\u8BFB\u54EA\u4E2A\u6587\u4EF6`
20685
- });
20686
- }
20687
- }
20688
- for (const m of allMatches(ERROR_CODE_RE, line)) {
20689
- const span = [m.index, m.index + m[0].length];
20690
- if (overlaps(span, spans)) continue;
20691
- spans.push(span);
20692
- judgeProtocol(m[0], REASON_ERROR_CODE, "\u9519\u8BEF\u7801", lineno, rel, matcher, index, reds);
20693
- }
20694
- }
20695
- function judgeProtocol(token2, reason, shape, lineno, rel, matcher, index, reds) {
20696
- if (matcher.owners.has(token2)) return;
20697
- if (covered(token2, index)) return;
20698
- if (reason === REASON_ERROR_CODE && OWNED_CODES.has(token2)) return;
20699
- reds.push({
20700
- channel: CHANNEL_UNREGISTERED,
20701
- reason,
20702
- token: token2,
20703
- path: rel,
20704
- line: lineno,
20705
- kinds: [],
20706
- message: `${rel}:${lineno} \u51FA\u73B0${shape} ${JSON.stringify(token2)}\uFF0C\u800C\u5B83**\u6CA1\u6709\u767B\u8BB0**\u5728\u968F\u5305\u7684\u534F\u8BAE\u4E8B\u5B9E\u767B\u8BB0\u518C\u91CC \u21D2 \u8981\u4E48\u6539\u5199\u6210\u4E0D\u4F9D\u8D56\u5B83\u7684\u8BF4\u6CD5\uFF0C\u8981\u4E48\u7ED9 CLI \u63D0\u4E00\u6761\u767B\u8BB0\uFF08\u767B\u8BB0\u5FC5\u987B\u9644\u4E00\u4E2A\u65AD\u884C\u4E3A\u7684\u63A2\u9488\uFF09`
20707
- });
20708
- }
20709
- function scan(skillRoot, aclass, facts, options = {}) {
20710
- const reds = [];
20711
- const premise2 = [];
20712
- const gaps = [];
20713
- const scanned = [];
20714
- const matcher = new Matcher(aclass);
20715
- const index = factsIndex(facts);
20716
- const reasons = classReasons(options.aclassProblems);
20717
- for (const kind of ACLASS_KINDS) {
20718
- if ((aclass[kind]?.size ?? 0) > 0) continue;
20719
- const reason = reasons.get(kind);
20720
- let why = "";
20721
- if (reason !== void 0) {
20722
- if (!(reason in ACLASS_EMPTY_WHY)) {
20723
- throw new Error(
20724
- `\u7C7B\u7EA7\u6210\u56E0 ${JSON.stringify(reason)} \u6CA1\u6709\u5BF9\u5E94\u7684\u63AA\u8F9E\uFF08\u8BA4\u5F97\u7684\u662F ${CLASS_REASONS.join("/")}\uFF09`
20725
- );
20726
- }
20727
- why = ACLASS_EMPTY_WHY[reason];
20728
- }
20729
- premise2.push({
20730
- reason: REASON_ACLASS_EMPTY,
20731
- message: `A \u7C7B\u5B50\u96C6 ${kind} \u662F\u7A7A\u7684${why} \u21D2 \u95E8 0 \u5BF9\u8FD9\u4E00\u7C7B**\u6052\u7EFF**\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570`
20732
- });
20733
- }
20734
- for (const problem6 of options.aclassProblems ?? []) {
20735
- if (problem6.scope !== ENTRY_SCOPE) continue;
20736
- premise2.push({
20737
- reason: REASON_ACLASS_PARTIALLY_UNREAD,
20738
- message: `A \u7C7B\u5B50\u96C6 ${problem6.kinds.join("/")} \u5C11\u4E86\u4E00\u90E8\u5206\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message} \u21D2 \u5C11\u6389\u7684\u90A3\u90E8\u5206\u95E8 0 \u5224\u4E0D\u51FA\u6765\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570`
20739
- });
20740
- }
20741
- let factsProblems = options.factsProblems;
20742
- if (factsProblems === void 0) {
20743
- premise2.push({
20744
- reason: REASON_CHANNEL_FOUR_UNCHECKED,
20745
- message: "\u6CA1\u6709\u628A loadProtocolFacts \u7684\u53F0\u8D26\u4F20\u8FDB\u6765 \u21D2 \u901A\u9053\u56DB\uFF08\u767B\u8BB0\u9879\u88AB\u62D2\uFF09\u4E00\u6761\u90FD\u6CA1\u67E5\u8FC7\u2014\u2014\u300C\u767B\u8BB0\u518C\u5E72\u51C0\u300D\u4E0E\u300C\u6CA1\u67E5\u767B\u8BB0\u518C\u300D\u5728\u8FD4\u56DE\u503C\u4E0A\u540C\u5F62"
20746
- });
20747
- factsProblems = [];
20748
- }
20749
- for (const problem6 of factsProblems) {
20750
- if (problem6.scope === REGISTRY_SCOPE && PREMISE_REGISTRY_REASONS.includes(problem6.reason)) {
20751
- premise2.push({
20752
- reason: REASON_REGISTRY,
20753
- message: `\u767B\u8BB0\u518C\u8FD9\u4E00\u5C42\u6CA1\u7ACB\u4F4F\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message} \u21D2 \u8C41\u514D\u901A\u9053 P \u4E0D\u53EF\u4FE1`
20754
- });
20755
- }
20756
- }
20757
- for (const problem6 of factsProblems) {
20758
- if (problem6.scope === REGISTRY_SCOPE) continue;
20759
- reds.push({
20760
- channel: CHANNEL_NO_PROBE,
20761
- reason: REASON_REJECTED_REGISTRATION,
20762
- token: problem6.token ?? `(\u7B2C${problem6.index}\u6761)`,
20763
- path: null,
20764
- line: 0,
20765
- kinds: [],
20766
- message: `\u767B\u8BB0\u518C\u7B2C ${problem6.index} \u6761\u88AB\u62D2\uFF08${problem6.reason}\uFF09\uFF1A${problem6.message}`
20767
- });
20768
- }
20769
- for (const token2 of [...facts].sort()) {
20770
- const kinds = matcher.owners.get(token2);
20771
- if (!kinds) continue;
20772
- reds.push({
20773
- channel: CHANNEL_REGISTERED_IS_ACLASS,
20774
- reason: REASON_REGISTERED_IS_ACLASS,
20775
- token: token2,
20776
- path: null,
20777
- line: 0,
20778
- kinds,
20779
- message: `\u767B\u8BB0\u518C\u767B\u8BB0\u4E86 ${JSON.stringify(token2)}\uFF0C\u800C\u5B83\u662F A \u7C7B\u73AF\u5883\u4E8B\u5B9E\uFF08${kinds.join("/")}\uFF09\u2014\u2014 recon \u67E5\u5F97\u5230\u7684\u4E1C\u897F\u4E0D\u662F\u7248\u672C\u7EA7\u534F\u8BAE\uFF0C\u767B\u8BB0\u5B83\u4E70\u4E0D\u5230\u4EFB\u4F55\u8C41\u514D`
20780
- });
20781
- }
20782
- let files = [];
20783
- if (!isDirectory(skillRoot)) {
20784
- premise2.push({
20785
- reason: REASON_NO_SKILL_ROOT,
20786
- message: `\u626B\u63CF\u9762 ${skillRoot} \u4E0D\u662F\u4E00\u4E2A\u76EE\u5F55 \u21D2 \u4E00\u4E2A\u5B57\u90FD\u6CA1\u626B\u8FC7\uFF08\u8FD9\u4E0D\u662F\u300C\u626B\u8FC7\u3001\u5E72\u51C0\u300D\uFF09`
20787
- });
20788
- } else {
20789
- const walked = walk4(skillRoot);
20790
- files = walked.files;
20791
- for (const link of walked.unscannedLinks) {
20792
- let target;
20793
- try {
20794
- target = readlinkSync(link);
20795
- } catch {
20796
- target = "(\u8BFB\u4E0D\u51FA\u94FE\u63A5\u76EE\u6807)";
20797
- }
20798
- premise2.push({
20799
- reason: REASON_SYMLINK_NOT_SCANNED,
20800
- message: `${path23.relative(skillRoot, link)} \u662F\u4E00\u4E2A\u7B26\u53F7\u94FE\u63A5\uFF08\u6307\u5411 ${JSON.stringify(target)}\uFF09\u21D2 \u95E8 0 **\u6CA1\u6709\u987A\u7740\u5B83\u626B\u8FC7\u4E00\u4E2A\u5B57**\uFF0C\u8FD9\u4E00\u8F6E\u7684\u7EFF\u4E0D\u7B97\u6570\u3002\u51FA\u8DEF\uFF1A\u628A\u8FD9\u6761\u94FE\u4ECE skill \u91CC\u53BB\u6389 \u2014\u2014 \u94FE\u540E\u9762\u90A3\u4EFD\u5185\u5BB9\u672C\u8BE5\u88AB\u5224\u5C31 \`cp -RL\` \u62F7\u6210\u771F\u5185\u5BB9\uFF08\u26A0\uFE0F \u73AF\u8DEF\u4E0E\u65AD\u94FE\u4E0A\u5B83\u4F1A\u5F53\u573A\u62A5\u9519\uFF0C\u90A3\u4E24\u79CD\u76F4\u63A5\u5220\uFF09\uFF1B\u5185\u5BB9\u5DF2\u7ECF\u5728 skill \u91CC\uFF08\u6307\u5411\u540C\u6811\u7684\u522B\u540D\uFF09\u4E5F\u76F4\u63A5\u5220\u3002**\u4E0D\u8DDF\u968F**\u662F\u523B\u610F\u7684 \u2014\u2014 \u8DDF\u8FC7\u53BB\u4F1A\u8FDE\u4E0A\u73AF\u8DEF\u3001\u6216\u8D8A\u51FA skill \u76EE\u5F55\u626B\u5230\u65E0\u5173\u6587\u4EF6`
20801
- });
20802
- }
20803
- if (files.length === 0) {
20804
- premise2.push({
20805
- reason: REASON_NOTHING_SCANNED,
20806
- message: `\u626B\u63CF\u9762 ${skillRoot} \u5728\u76D8\u4E0A\uFF0C\u4F46\u91CC\u9762\u4E00\u4E2A\u6587\u4EF6\u90FD\u6CA1\u6709 \u2014\u2014 \u67E5\u8FC7\u4E14\u4E3A\u7A7A`
20807
- });
20808
- }
20809
- }
20810
- for (const file of files) {
20811
- let text2;
20812
- try {
20813
- text2 = readFileSync14(file, "utf8");
20814
- } catch (e) {
20815
- premise2.push({
20816
- reason: REASON_FILE_UNREADABLE,
20817
- message: `${file} \u8BFB\u4E0D\u52A8\uFF08${String(e)}\uFF09\u21D2 \u5224\u4E0D\u4E86\u5B83\u5E72\u4E0D\u5E72\u51C0\uFF0C\u95E8 0 \u4E0D\u80FD\u5BF9\u7740\u5B83\u8BF4\u7EFF`
20818
- });
20819
- continue;
20820
- }
20821
- const rel = path23.relative(skillRoot, file);
20822
- scanned.push(rel);
20823
- text2.split("\n").forEach((line, i) => {
20824
- judgeLine(line, i + 1, rel, matcher, index, reds, gaps);
20825
- });
20826
- }
20827
- const seen = /* @__PURE__ */ new Set();
20828
- const unique2 = [];
20829
- for (const red of checkReds(reds)) {
20830
- const key = `${red.channel} ${red.token} ${red.path} ${red.line}`;
20831
- if (seen.has(key)) continue;
20832
- seen.add(key);
20833
- unique2.push(red);
20834
- }
20835
- const channels = Object.fromEntries(
20836
- CHANNELS.map((name) => [name, unique2.filter((r) => r.channel === name)])
20837
- );
20838
- return {
20839
- red: unique2,
20840
- channels,
20841
- scanned,
20842
- gaps: checkGaps(gaps),
20843
- premise: checkPremise(premise2)
20844
- };
20845
- }
20846
- function isDirectory(target) {
20847
- try {
20848
- return statSync11(target).isDirectory();
20849
- } catch {
20850
- return false;
20851
- }
20852
- }
20853
- function walk4(root) {
20854
- const files = [];
20855
- const unscannedLinks = [];
20856
- const visit = (dir) => {
20857
- for (const entry of readdirSync4(dir, { withFileTypes: true })) {
20858
- const full = path23.join(dir, entry.name);
20859
- let followed = null;
20860
- try {
20861
- followed = statSync11(full);
20862
- } catch {
20863
- followed = null;
20864
- }
20865
- if (followed?.isFile()) {
20866
- files.push(full);
20867
- } else if (entry.isSymbolicLink()) {
20868
- unscannedLinks.push(full);
20869
- } else if (followed?.isDirectory()) {
20870
- visit(full);
20871
- }
20872
- }
20873
- };
20874
- visit(root);
20875
- return { files: files.sort(), unscannedLinks: unscannedLinks.sort() };
20876
- }
20877
- function exitCode(result) {
20878
- if (result.premise.length > 0) return 2;
20879
- if (result.red.length > 0) return 1;
20880
- return 0;
20881
- }
20882
-
20883
19748
  // src/fde/triage/carriers.ts
20884
19749
  var CARRIER_KEYS = [
20885
19750
  "config-surface",
@@ -20941,8 +19806,8 @@ function buildCarrierResult(carrier, verdict2, options = {}) {
20941
19806
  }
20942
19807
 
20943
19808
  // src/fde/triage/probe.ts
20944
- import { readFileSync as readFileSync15 } from "fs";
20945
- import * as path24 from "path";
19809
+ import { readFileSync as readFileSync11 } from "fs";
19810
+ import * as path21 from "path";
20946
19811
  var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
20947
19812
  var MODELS_REL = "models.json";
20948
19813
  var FIELDS_REL = "index/fields.jsonl";
@@ -20966,10 +19831,10 @@ function unavailableCell(carrier, err) {
20966
19831
  });
20967
19832
  }
20968
19833
  function readArtifactJson(dir, rel) {
20969
- return JSON.parse(readFileSync15(path24.join(dir, rel), "utf8"));
19834
+ return JSON.parse(readFileSync11(path21.join(dir, rel), "utf8"));
20970
19835
  }
20971
19836
  function readArtifactJsonl(dir, rel) {
20972
- const body = readFileSync15(path24.join(dir, rel), "utf8");
19837
+ const body = readFileSync11(path21.join(dir, rel), "utf8");
20973
19838
  const rows = [];
20974
19839
  for (const line of body.split("\n")) {
20975
19840
  const trimmed = line.trim();
@@ -21991,17 +20856,25 @@ async function runActiveVerify(client, args) {
21991
20856
  if (raised) throw pending;
21992
20857
  return verdict(code, done, bindingState, layer, w, present, missing);
21993
20858
  }
20859
+
20860
+ // src/fde/recon/round-premise.ts
20861
+ var REASON_BASELINE_ROUND_NOT_COMPLETE = "baseline-round-not-complete";
20862
+ function baselineRoundPremise(round) {
20863
+ const state = round && typeof round === "object" ? round.state : void 0;
20864
+ if (state === "complete") return [];
20865
+ return [
20866
+ {
20867
+ reason: REASON_BASELINE_ROUND_NOT_COMPLETE,
20868
+ message: `\u8FD9\u4EFD\u57FA\u7EBF\u7684\u8F6E\u6B21\u72B6\u6001\u662F ${JSON.stringify(state)}\uFF08\u4E0D\u662F complete\uFF09\u21D2 \u7ED3\u8BBA\u662F\u4ECE**\u6DF7\u7740\u4E0D\u540C\u8F6E\u6B21 / \u5224\u4E0D\u4E86\u8F6E\u6B21**\u7684\u4EA7\u7269\u91CC\u73B0\u7B97\u7684\uFF0C\u5BF9\u54EA\u4E00\u8F6E\u90FD\u4E0D\u7B97\u6570\u3002\u5148\u8DD1 \`hcm chiron recon round\` \u770B\u662F\u54EA\u51E0\u4EFD\uFF0C\u6216\u91CD\u8DD1\u4E00\u6B21 \`hcm chiron recon\`\u3002\u26A0\uFE0F **\`hcm chiron recon\` \u8981\u8FDE\u5BA2\u6237\u5185\u7F51\u7684 HCM** \u2014\u2014 \u62FF\u4E0D\u5230\u7F51\u7684\u673A\u5668\u4E0A\u8FD9\u6761\u51FA\u8DEF\u8D70\u4E0D\u901A\uFF0C\u6B64\u65F6**\u522B\u628A\u8FD9\u4EFD\u57FA\u7EBF\u5F53 complete \u7528**\uFF0C\u628A\u5B83\u5E26\u56DE\u8FDE\u5F97\u4E0A\u7684\u5730\u65B9\u91CD\u722C`
20869
+ }
20870
+ ];
20871
+ }
21994
20872
  export {
21995
- ACLASS_EMPTY_WHY,
21996
- ACLASS_KINDS,
21997
20873
  ADVISORY_CODES,
21998
20874
  AGREEING_VERDICTS,
21999
20875
  APPLY_CAVEAT,
22000
20876
  APPLY_PROBLEM_CODES,
22001
20877
  PROBLEM_CODES as ARTIFACT_PROBLEM_CODES,
22002
- ARTIFACT_ROOT,
22003
- ARTIFACT_SUFFIXES,
22004
- ARTIFACT_WORDING,
22005
20878
  AUTH_INFO_PATH,
22006
20879
  ApplyInvariantError,
22007
20880
  ApplyPremiseError,
@@ -22026,14 +20899,7 @@ export {
22026
20899
  CHANGE_STATES,
22027
20900
  CHANGE_UNKNOWN,
22028
20901
  CHANGE_WRITTEN,
22029
- CHANNELS,
22030
- CHANNEL_ARTIFACT,
22031
- CHANNEL_NO_PROBE,
22032
- CHANNEL_REGISTERED_IS_ACLASS,
22033
- CHANNEL_UNREGISTERED,
22034
20902
  CHECK_GROUPS2 as CHECK_GROUPS,
22035
- CLASS_REASONS,
22036
- CLASS_SCOPE,
22037
20903
  CODE_BINDING_ELSEWHERE,
22038
20904
  CODE_BINDING_OFF,
22039
20905
  CODE_BINDING_UNREADABLE,
@@ -22071,26 +20937,16 @@ export {
22071
20937
  EFFECT_READ_ONLY,
22072
20938
  EFFECT_UNKNOWN,
22073
20939
  EFFECT_WRITES,
22074
- ENDPOINT_PREFIXES,
22075
- ENTRY_SCOPE,
22076
- ENUM_ELEMENT_KEYS,
22077
20940
  ENUM_SHOW,
22078
20941
  EXEMPTIBLE_CODES,
22079
20942
  EXEMPTION_CODES,
22080
20943
  EXEMPTION_REQUIRED_KEYS,
22081
20944
  EXTENSION_SOURCE_HEADER,
22082
20945
  ExitCode,
22083
- FACTS_REASONS,
22084
20946
  FIND_LIMIT,
22085
20947
  MAX_BYTES as FIND_MAX_BYTES,
22086
- FOLDED_NOTE,
22087
20948
  FORCE_STALE_FLAG,
22088
20949
  FORCE_STALE_FLAG_TEXT,
22089
- FULLWIDTH_ALNUM_RANGES,
22090
- GAP_ACLASS_NOT_DISCRIMINATIVE,
22091
- GAP_CJK_INSIDE_LONGER_RUN,
22092
- GAP_NOISE_TOKEN,
22093
- GAP_REASONS,
22094
20950
  GATE_COMPONENTS,
22095
20951
  HCM_LANG_ENV,
22096
20952
  HcmClient,
@@ -22112,7 +20968,6 @@ export {
22112
20968
  Lease,
22113
20969
  LeaseViolation,
22114
20970
  MANIFEST_PATH,
22115
- MAPPING_ARTIFACT_VERSION,
22116
20971
  MAPPING_FILE,
22117
20972
  MAX_MANIFEST_PAGES,
22118
20973
  MAX_SOURCE_PROBES,
@@ -22131,9 +20986,7 @@ export {
22131
20986
  MINI_STATE_DIR,
22132
20987
  MODELS_PATH,
22133
20988
  MODEL_META_PATH,
22134
- MappingArtifactError,
22135
20989
  MappingError,
22136
- Matcher,
22137
20990
  NETWORK_GATES,
22138
20991
  NEXT_STEP,
22139
20992
  NOT_COVERED_LAYER1,
@@ -22151,33 +21004,17 @@ export {
22151
21004
  PREMISE_JOURNAL_ON_DISK,
22152
21005
  PREMISE_KEY_FIELDS,
22153
21006
  PREMISE_PLAN_READABLE,
22154
- PREMISE_REASONS,
22155
- PREMISE_REGISTRY_REASONS,
22156
21007
  PREMISE_ROWS_TO_CHECK,
22157
21008
  PREMISE_UNMET,
22158
21009
  PREMISE_WORDS,
22159
21010
  PROACTIVE_REFRESH_MARGIN_SECONDS,
22160
- PROBE_MARK_PREFIX,
22161
- PRODUCT_RELATIVE_SHAPES,
22162
21011
  PRODUCT_STATE_WORDS,
22163
- PROTOCOL_FACTS,
22164
21012
  PlanReadError,
22165
21013
  RC_DECIDING_FIELDS,
22166
21014
  RC_DECIDING_REPORT_FIELDS,
22167
- REASON_DUPLICATE_TOKEN,
22168
- REASON_EMPTY,
22169
- REASON_NO_ENTRIES,
22170
- REASON_PROBE_ABSENT,
22171
- REASON_PROBE_SHAPE,
22172
- REASON_PROBE_UNVERIFIED,
22173
- REASON_UNREAD,
21015
+ REASON_BASELINE_ROUND_NOT_COMPLETE,
22174
21016
  VERDICTS2 as RECONCILE_VERDICTS,
22175
- RECON_DIRNAME2 as RECON_DIRNAME,
22176
- RECON_SEGMENTS_BELOW_ROOT,
22177
21017
  RECOVERY_WORDS,
22178
- RED_REASONS,
22179
- REGISTRY_REASONS,
22180
- REGISTRY_SCOPE,
22181
21018
  REQUIRED_SECTIONS,
22182
21019
  RESTORE_CODES,
22183
21020
  RISK_CODES,
@@ -22192,9 +21029,7 @@ export {
22192
21029
  ReconLayout,
22193
21030
  RefStore,
22194
21031
  RestoreFailed,
22195
- SCOPES,
22196
21032
  SDK_VERSION,
22197
- SEGMENT_SEPARATOR,
22198
21033
  STATUSES,
22199
21034
  STEP_NOTHING,
22200
21035
  STEP_PROBE,
@@ -22243,7 +21078,6 @@ export {
22243
21078
  applyReportText,
22244
21079
  applyReportToJson,
22245
21080
  archiveDir,
22246
- artifactReason,
22247
21081
  askedTheDatabase,
22248
21082
  assertNotReservedEnvName,
22249
21083
  assertSafeReferencePath,
@@ -22251,7 +21085,6 @@ export {
22251
21085
  assertSafeSkillId,
22252
21086
  baselineRoundPremise,
22253
21087
  bootstrapTenant,
22254
- boundedFind,
22255
21088
  buildAnswer,
22256
21089
  buildCarrierResult,
22257
21090
  buildConfirm,
@@ -22267,10 +21100,6 @@ export {
22267
21100
  camelizeKeys,
22268
21101
  changePassword,
22269
21102
  checkCoherence,
22270
- checkGaps,
22271
- checkPremise,
22272
- checkReds,
22273
- cjkRunAt,
22274
21103
  classifyEffect,
22275
21104
  classifyMessage,
22276
21105
  classifyStatus,
@@ -22282,7 +21111,6 @@ export {
22282
21111
  computeReconSourceKey,
22283
21112
  contentHash,
22284
21113
  conversationStateFile,
22285
- covered,
22286
21114
  create,
22287
21115
  createConversation,
22288
21116
  createHttpClient,
@@ -22296,7 +21124,6 @@ export {
22296
21124
  deleteTenantMeta,
22297
21125
  deleteWorkspaceFile,
22298
21126
  deliveryRunFields,
22299
- deriveAclass,
22300
21127
  deriveNamelessToolLabel,
22301
21128
  describePrincipal,
22302
21129
  describeWaiver,
@@ -22306,18 +21133,15 @@ export {
22306
21133
  discardedColumnLines,
22307
21134
  displayWidth,
22308
21135
  downloadDocument,
22309
- endpointsIn,
22310
21136
  enforceDriftGate,
22311
21137
  ensureSessionFresh,
22312
21138
  envDir,
22313
21139
  envFile,
22314
21140
  envsDir,
22315
21141
  existingJournalStop,
22316
- exitCode,
22317
21142
  exitCodeFor,
22318
21143
  explainJacksonError,
22319
21144
  extractNextSteps,
22320
- factsIndex,
22321
21145
  fetchConversationTimeline,
22322
21146
  fetchConversationTimelineStrict,
22323
21147
  fetchInstallRun,
@@ -22331,8 +21155,6 @@ export {
22331
21155
  find,
22332
21156
  findLastAssistantSeq,
22333
21157
  flattenSkills,
22334
- foldConfusables,
22335
- foldedNoteFor,
22336
21158
  formatMetaIssues,
22337
21159
  formatMiniVerifyReport,
22338
21160
  formatObject,
@@ -22352,13 +21174,11 @@ export {
22352
21174
  identityDir,
22353
21175
  identityKnown,
22354
21176
  identityMetaFile,
22355
- inGap,
22356
21177
  inferMiniWritableTemplateOptionsFromModel,
22357
21178
  initMiniAppProject,
22358
21179
  inspectRound,
22359
21180
  installDataPackageArtifact,
22360
21181
  installDataPackageArtifactAsync,
22361
- isCjk,
22362
21182
  isDelegationToolName,
22363
21183
  isLocalName,
22364
21184
  isReadOnly,
@@ -22382,7 +21202,6 @@ export {
22382
21202
  loadIdentity,
22383
21203
  loadMapping,
22384
21204
  loadProfile,
22385
- loadProtocolFacts,
22386
21205
  loadRecordedFingerprint,
22387
21206
  loadRows,
22388
21207
  loadWorkspaceFileContent,
@@ -22400,7 +21219,6 @@ export {
22400
21219
  modelKeys,
22401
21220
  needsRefresh,
22402
21221
  newRoundId,
22403
- normalize,
22404
21222
  normalizeReferences,
22405
21223
  notAsked,
22406
21224
  oneShot,
@@ -22426,7 +21244,6 @@ export {
22426
21244
  pullMiniAppProject,
22427
21245
  pushMiniAppProject,
22428
21246
  queryScriptLogs,
22429
- readBusinessKeyFields,
22430
21247
  readImportPlan,
22431
21248
  readMiniContext,
22432
21249
  readPullManifest,
@@ -22468,12 +21285,10 @@ export {
22468
21285
  saveProfile,
22469
21286
  saveTenantMeta,
22470
21287
  saveWorkspaceFileContent,
22471
- scan,
22472
21288
  scriptDryRun,
22473
21289
  seedBaselines,
22474
21290
  seedMappingPath,
22475
21291
  seedWorkDir,
22476
- segmentsOf,
22477
21292
  sendMessageAndStream,
22478
21293
  shelfPartition,
22479
21294
  snakeToCamel,
@@ -22486,7 +21301,6 @@ export {
22486
21301
  toYaml,
22487
21302
  truncateDisplay,
22488
21303
  unbindPayload,
22489
- unguardedKinds,
22490
21304
  update,
22491
21305
  uploadDocument,
22492
21306
  validateMetaContent,