@hcmai/sdk 0.4.0 → 0.4.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 CHANGED
@@ -1083,18 +1083,18 @@ async function action(http, model, actionName, input) {
1083
1083
  if (scope === "object" && !input.id) {
1084
1084
  throw new Error(`object action ${model}.${actionName} requires id`);
1085
1085
  }
1086
- const path22 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1086
+ const path24 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1087
1087
  const resp = await (async () => {
1088
1088
  if (method === "GET") {
1089
- return http.get(path22, { params: queryParams(input) });
1089
+ return http.get(path24, { params: queryParams(input) });
1090
1090
  }
1091
1091
  if (method === "DELETE") {
1092
- return http.delete(path22, { params: queryParams(input) });
1092
+ return http.delete(path24, { params: queryParams(input) });
1093
1093
  }
1094
1094
  if (method === "PUT") {
1095
- return http.put(path22, scope === "object" ? objectBody(input) : classBody(input));
1095
+ return http.put(path24, scope === "object" ? objectBody(input) : classBody(input));
1096
1096
  }
1097
- return http.post(path22, scope === "object" ? objectBody(input) : classBody(input));
1097
+ return http.post(path24, scope === "object" ? objectBody(input) : classBody(input));
1098
1098
  })();
1099
1099
  return resp.data;
1100
1100
  }
@@ -5215,18 +5215,18 @@ async function listTenantMeta(http, opts = {}) {
5215
5215
  const items = payload?.items ?? payload?.list ?? payload?.records ?? [];
5216
5216
  return { items, total: payload?.total, raw: payload };
5217
5217
  }
5218
- async function getTenantMeta(http, path22) {
5219
- const resp = await http.get("/api/tenant-meta/meta", { params: { path: path22 } });
5218
+ async function getTenantMeta(http, path24) {
5219
+ const resp = await http.get("/api/tenant-meta/meta", { params: { path: path24 } });
5220
5220
  const payload = resp.data?.data ?? resp.data;
5221
5221
  if (typeof payload === "string") return payload;
5222
5222
  return String(payload?.content ?? "");
5223
5223
  }
5224
- async function saveTenantMeta(http, path22, content) {
5225
- const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path22 } });
5224
+ async function saveTenantMeta(http, path24, content) {
5225
+ const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path24 } });
5226
5226
  return resp.data?.data ?? resp.data;
5227
5227
  }
5228
- async function deleteTenantMeta(http, path22) {
5229
- const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path22 } });
5228
+ async function deleteTenantMeta(http, path24) {
5229
+ const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path24 } });
5230
5230
  return resp.data?.data ?? resp.data;
5231
5231
  }
5232
5232
 
@@ -5328,14 +5328,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
5328
5328
  throw invalid(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
5329
5329
  }
5330
5330
  const state = /* @__PURE__ */ new Map();
5331
- const path22 = [];
5331
+ const path24 = [];
5332
5332
  const order = [];
5333
5333
  const visit = (id, requiredBy) => {
5334
5334
  const current = state.get(id);
5335
5335
  if (current === "done") return;
5336
5336
  if (current === "visiting") {
5337
- const cycleStart = path22.indexOf(id);
5338
- const cycle = [...path22.slice(Math.max(0, cycleStart)), id];
5337
+ const cycleStart = path24.indexOf(id);
5338
+ const cycle = [...path24.slice(Math.max(0, cycleStart)), id];
5339
5339
  throw invalid(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
5340
5340
  }
5341
5341
  const skill = byId.get(id);
@@ -5344,11 +5344,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
5344
5344
  }
5345
5345
  assertSafeSkillId(skill.id);
5346
5346
  state.set(id, "visiting");
5347
- path22.push(id);
5347
+ path24.push(id);
5348
5348
  for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
5349
5349
  visit(required2, skill.id);
5350
5350
  }
5351
- path22.pop();
5351
+ path24.pop();
5352
5352
  state.set(id, "done");
5353
5353
  order.push(skill);
5354
5354
  };
@@ -5439,11 +5439,11 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
5439
5439
  function parseSettingAssignment(raw) {
5440
5440
  const eq = raw.indexOf("=");
5441
5441
  if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
5442
- const path22 = raw.slice(0, eq).trim();
5442
+ const path24 = raw.slice(0, eq).trim();
5443
5443
  const value = raw.slice(eq + 1);
5444
- const dot = path22.lastIndexOf(".");
5445
- if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path22}"`);
5446
- return { namespace: path22.slice(0, dot), settingKey: path22.slice(dot + 1), value };
5444
+ const dot = path24.lastIndexOf(".");
5445
+ if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path24}"`);
5446
+ return { namespace: path24.slice(0, dot), settingKey: path24.slice(dot + 1), value };
5447
5447
  }
5448
5448
 
5449
5449
  // src/fde/layout.ts
@@ -5687,8 +5687,8 @@ var WorkLayout = class {
5687
5687
  }
5688
5688
  /** 读出**文本**,按 UTF-8 严格解码(BOM 先剥掉)。解不出时抛 `TypeError`。 */
5689
5689
  readText(rel) {
5690
- const bytes = this.readBytes(rel);
5691
- const text2 = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
5690
+ const bytes2 = this.readBytes(rel);
5691
+ const text2 = new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
5692
5692
  return text2.startsWith("\uFEFF") ? text2.slice(1) : text2;
5693
5693
  }
5694
5694
  /**
@@ -5832,11 +5832,11 @@ function classifyStatus(status) {
5832
5832
  return "bad-response";
5833
5833
  }
5834
5834
  var CAPABILITIES_HEADER = "x-hcm-capabilities";
5835
- function buildUrl(path22, params) {
5835
+ function buildUrl(path24, params) {
5836
5836
  const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
5837
- if (entries.length === 0) return path22;
5837
+ if (entries.length === 0) return path24;
5838
5838
  const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
5839
- return `${path22}${path22.includes("?") ? "&" : "?"}${qs}`;
5839
+ return `${path24}${path24.includes("?") ? "&" : "?"}${qs}`;
5840
5840
  }
5841
5841
  function lowerHeaders(raw) {
5842
5842
  const out = {};
@@ -5878,14 +5878,14 @@ function httpProbe(http, capabilities) {
5878
5878
  const headers = { [CAPABILITIES_HEADER]: capabilities };
5879
5879
  const probe = {
5880
5880
  capabilities,
5881
- get(path22, params) {
5881
+ get(path24, params) {
5882
5882
  return once(
5883
- () => http.get(buildUrl(path22, params), { headers, validateStatus: () => true })
5883
+ () => http.get(buildUrl(path24, params), { headers, validateStatus: () => true })
5884
5884
  );
5885
5885
  },
5886
- post(path22, body) {
5886
+ post(path24, body) {
5887
5887
  return once(
5888
- () => http.post(path22, body, {
5888
+ () => http.post(path24, body, {
5889
5889
  headers: { ...headers, "content-type": "application/json" },
5890
5890
  validateStatus: () => true
5891
5891
  })
@@ -5997,8 +5997,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
5997
5997
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
5998
5998
  const metas = {};
5999
5999
  const unavailable = [];
6000
- for (const [path22, key] of paths) {
6001
- const out = results[path22];
6000
+ for (const [path24, key] of paths) {
6001
+ const out = results[path24];
6002
6002
  if (out === void 0) {
6003
6003
  unavailable.push({
6004
6004
  modelKey: key,
@@ -6214,8 +6214,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
6214
6214
  const statesEchoed = /* @__PURE__ */ new Set();
6215
6215
  let noStateEcho = 0;
6216
6216
  let answered = 0;
6217
- for (const [path22, model] of paths) {
6218
- const out = results[path22];
6217
+ for (const [path24, model] of paths) {
6218
+ const out = results[path24];
6219
6219
  if (out === void 0) {
6220
6220
  unavailable.push({
6221
6221
  modelKey: model,
@@ -6594,8 +6594,8 @@ async function collectMutation(probe, modelKeys2) {
6594
6594
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
6595
6595
  const mutation = {};
6596
6596
  const problems = [];
6597
- for (const [path22, key] of paths) {
6598
- const out = results[path22];
6597
+ for (const [path24, key] of paths) {
6598
+ const out = results[path24];
6599
6599
  if (out === void 0) {
6600
6600
  problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
6601
6601
  mutation[key] = Object.fromEntries(
@@ -7040,11 +7040,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
7040
7040
  keys.push(key);
7041
7041
  }
7042
7042
  for (const key of [...new Set(keys)].sort()) {
7043
- const path22 = listPath(key);
7043
+ const path24 = listPath(key);
7044
7044
  const started = tick();
7045
7045
  let requests = 0;
7046
7046
  let truncatedBy = null;
7047
- const probeOut = await post.call(probe, path22, { page: 0, size: 0 });
7047
+ const probeOut = await post.call(probe, path24, { page: 0, size: 0 });
7048
7048
  requests += 1;
7049
7049
  let total = null;
7050
7050
  let reason = null;
@@ -7093,7 +7093,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
7093
7093
  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`;
7094
7094
  break;
7095
7095
  }
7096
- const out = await post.call(probe, path22, { page, size: PAGE_SIZE });
7096
+ const out = await post.call(probe, path24, { page, size: PAGE_SIZE });
7097
7097
  requests += 1;
7098
7098
  if (out.error !== "ok") {
7099
7099
  failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
@@ -7833,7 +7833,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
7833
7833
  for (const name of ["id", ...fields]) {
7834
7834
  if (!projected.includes(name)) projected.push(name);
7835
7835
  }
7836
- const path22 = listPath2(model);
7836
+ const path24 = listPath2(model);
7837
7837
  const idx = /* @__PURE__ */ new Map();
7838
7838
  let total = null;
7839
7839
  let pages = 0;
@@ -7850,7 +7850,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
7850
7850
  let repeatedIds = 0;
7851
7851
  while (total === null || received < total) {
7852
7852
  const pageNo = pages;
7853
- const out = await client.post(path22, {
7853
+ const out = await client.post(path24, {
7854
7854
  page: pageNo,
7855
7855
  size: pageSize,
7856
7856
  fields: projected,
@@ -8042,8 +8042,8 @@ var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
8042
8042
  var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
8043
8043
  var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
8044
8044
  var SCAN_CHUNK_BYTES = 1024 * 1024;
8045
- function scanFor(path22, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
8046
- const fd = openSync2(path22, "r");
8045
+ function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
8046
+ const fd = openSync2(path24, "r");
8047
8047
  try {
8048
8048
  let tail = Buffer.alloc(0);
8049
8049
  let seen = 0;
@@ -8064,9 +8064,9 @@ function scanFor(path22, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
8064
8064
  closeSync2(fd);
8065
8065
  }
8066
8066
  }
8067
- function isCfb(path22) {
8068
- if (statSync2(path22).size < CFB_MAGIC.length) return false;
8069
- const fd = openSync2(path22, "r");
8067
+ function isCfb(path24) {
8068
+ if (statSync2(path24).size < CFB_MAGIC.length) return false;
8069
+ const fd = openSync2(path24, "r");
8070
8070
  try {
8071
8071
  const head = Buffer.alloc(CFB_MAGIC.length);
8072
8072
  const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
@@ -8075,9 +8075,9 @@ function isCfb(path22) {
8075
8075
  closeSync2(fd);
8076
8076
  }
8077
8077
  }
8078
- function classifyCfb(path22, budget = MAX_ENTRY_BYTES) {
8079
- if (!isCfb(path22)) return "not-cfb";
8080
- switch (scanFor(path22, ENCRYPTED_PACKAGE, budget)) {
8078
+ function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
8079
+ if (!isCfb(path24)) return "not-cfb";
8080
+ switch (scanFor(path24, ENCRYPTED_PACKAGE, budget)) {
8081
8081
  case "found":
8082
8082
  return "encrypted";
8083
8083
  case "absent":
@@ -9978,6 +9978,19 @@ function problem(code, model, message, hint, entry) {
9978
9978
  // src/fde/seed/plan.ts
9979
9979
  var VERSION2 = 1;
9980
9980
  var IMPORT_PLAN_FILE = "import-plan.json";
9981
+ var PLAN_PROBLEM_CODES = [
9982
+ "DUPLICATE_BUSINESS_KEY",
9983
+ "DANGLING_PARENT",
9984
+ "ROW_LEVEL_CYCLE",
9985
+ "MODEL_ORDER_CONFLICT",
9986
+ "BUSINESS_KEY_VALUE_MISSING",
9987
+ "BUSINESS_KEY_REFERENCE_UNRESOLVED",
9988
+ "SELF_REFERENCE_UNUSABLE",
9989
+ "EXISTING_INDEX_MISSING",
9990
+ "SOURCE_ROWS_MISSING",
9991
+ "MAPPING_NOT_USABLE",
9992
+ "PLAN_CHECKS_SKIPPED"
9993
+ ];
9981
9994
  var PREMISE_CODES2 = [
9982
9995
  "DUPLICATE_BUSINESS_KEY",
9983
9996
  "BUSINESS_KEY_VALUE_MISSING",
@@ -10604,16 +10617,16 @@ function rowCycles(parents) {
10604
10617
  const cycles = [];
10605
10618
  for (const start of [...parents.keys()].sort((a, b) => a - b)) {
10606
10619
  if (done.has(start)) continue;
10607
- const path22 = [];
10620
+ const path24 = [];
10608
10621
  const seen = /* @__PURE__ */ new Map();
10609
10622
  let node = start;
10610
10623
  while (node !== void 0 && !seen.has(node) && !done.has(node)) {
10611
- seen.set(node, path22.length);
10612
- path22.push(node);
10624
+ seen.set(node, path24.length);
10625
+ path24.push(node);
10613
10626
  node = parents.get(node);
10614
10627
  }
10615
- if (node !== void 0 && seen.has(node)) cycles.push(path22.slice(seen.get(node)));
10616
- for (const n of path22) done.add(n);
10628
+ if (node !== void 0 && seen.has(node)) cycles.push(path24.slice(seen.get(node)));
10629
+ for (const n of path24) done.add(n);
10617
10630
  }
10618
10631
  return cycles;
10619
10632
  }
@@ -11199,9 +11212,9 @@ function enumKey(model, field) {
11199
11212
  }
11200
11213
  var Utf8Error = class extends Error {
11201
11214
  };
11202
- function decodeUtf8(bytes) {
11215
+ function decodeUtf8(bytes2) {
11203
11216
  try {
11204
- return new TextDecoder("utf-8", { fatal: true }).decode(bytes).replace(/^\uFEFF/, "");
11217
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes2).replace(/^\uFEFF/, "");
11205
11218
  } catch {
11206
11219
  throw new Utf8Error("not utf-8");
11207
11220
  }
@@ -12538,9 +12551,9 @@ function readImportPlan(out) {
12538
12551
  "\u5148\u5728\u540C\u4E00\u4E2A work \u76EE\u5F55\u4E0A\u8DD1\u4E00\u6B21 `plan` \u5B50\u547D\u4EE4\u3002\u{1F534} `apply` \u4E0D\u4F1A\u81EA\u5DF1\u53BB\u7B97\u8BA1\u5212\uFF1A\u7B97\u8BA1\u5212\u8981\u53D1\u8BF7\u6C42\u5EFA\u65E2\u5B58\u7D22\u5F15\uFF0C\u800C\u300C\u987A\u624B\u7B97\u4E00\u4EFD\u300D\u610F\u5473\u7740\u4F60 apply \u7684\u4E0D\u662F\u4F60\u770B\u8FC7\u7684\u90A3\u4E00\u4EFD"
12539
12552
  );
12540
12553
  }
12541
- let bytes;
12554
+ let bytes2;
12542
12555
  try {
12543
- bytes = work.readBytes(IMPORT_PLAN_FILE);
12556
+ bytes2 = work.readBytes(IMPORT_PLAN_FILE);
12544
12557
  } catch (e) {
12545
12558
  throw new PlanReadError(
12546
12559
  "plan-unreadable",
@@ -12550,7 +12563,7 @@ function readImportPlan(out) {
12550
12563
  }
12551
12564
  let raw;
12552
12565
  try {
12553
- raw = new TextDecoder("utf-8", { fatal: true }).decode(bytes).replace(/^\uFEFF/, "");
12566
+ raw = new TextDecoder("utf-8", { fatal: true }).decode(bytes2).replace(/^\uFEFF/, "");
12554
12567
  } catch {
12555
12568
  throw new PlanReadError(
12556
12569
  "plan-unreadable",
@@ -15203,12 +15216,410 @@ function writeRisk(risk, out) {
15203
15216
  return new WorkLayout(out).writeJson(RISK_FILE, riskToJson(risk));
15204
15217
  }
15205
15218
 
15206
- // src/fde/gate0/aclass.ts
15207
- import { existsSync as existsSync10, readFileSync as readFileSync10, readdirSync as readdirSync3, statSync as statSync9 } from "fs";
15219
+ // src/fde/seed/value-hints.ts
15220
+ import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
15208
15221
  import * as path18 from "path";
15222
+ var HINT_REF = (domain) => ` \u503C\uFF1A\u586B id\uFF08\u4E0D\u662F code\uFF09\u2190 ${domain}`;
15223
+ var HINT_NO_DOMAIN = (to) => ` \u503C\uFF1A\u586B ${to} \u7684 id\uFF08\u4E0D\u662F code\uFF09\uFF1B\u65E0\u5BF9\u7167\u8868\uFF0C\u6309\u4E1A\u52A1\u952E\u73B0\u67E5`;
15224
+ var HINT_ENUM = (n, model) => ` \u503C\uFF1A\u679A\u4E3E ${n} \u9879 \u2190 mapping/${model}.json`;
15225
+ var HINT_DOMAIN_MISSING = (to) => `\uFF1B\u26A0\uFE0F \u7D22\u5F15\u91CC\u6709\u8FD9\u5F20\u8868\u4F46\u76D8\u4E0A\u6CA1\u6709\u6587\u4EF6\uFF08\`values ${to}\` \u770B\u539F\u56E0\uFF09`;
15226
+ var HINT_DOMAIN_UNAVAILABLE = "\uFF1B\u26A0\uFE0F \u8FD9\u5F20\u8868\u672C\u8F6E\u8FDE\u8BA1\u6570\u90FD\u6CA1\u8BFB\u5230\uFF08unavailable\uFF09\uFF0C\u7981\u6B62\u636E\u6B64\u5199\u811A\u672C";
15227
+ var HINT_DOMAIN_INDEX_UNREADABLE = (to) => `\uFF1B\u26A0\uFE0F \u8FD9\u4EFD\u57FA\u7EBF\u7684 valuedomain/_index.json \u8BFB\u4E0D\u5230\uFF0C**\u65E0\u6CD5\u5224\u65AD**\u6709\u6CA1\u6709\u5BF9\u7167\u8868\uFF08\u53BB valuedomain/ \u76EE\u5F55\u770B\u6709\u6CA1\u6709 ${to}.json\uFF09`;
15228
+ var HINT_DOMAIN_UNKNOWN_TO_INDEX = "\uFF1B\u26A0\uFE0F mapping \u8BF4\u5B83\u662F\u7801\u8868\uFF0Cvaluedomain \u7D22\u5F15\u91CC\u5374\u6CA1\u6709\u8FD9\u5F20\u8868\uFF08\u5BF9\u4E0D\u4E0A\u8D26\uFF09";
15229
+ var HINT_LABEL = (label) => `\uFF1B\u62FF ${label} \u53CD\u67E5 id`;
15230
+ var HINT_LABEL_UNKNOWN = "\uFF1B\u6807\u7B7E\u5B57\u6BB5\u672A\u77E5\uFF08\u4EA7\u54C1\u6CA1\u58F0\u660E\u663E\u793A\u5B57\u6BB5\u540D\uFF0C\u522B\u9ED8\u8BA4\u662F name\uFF09";
15231
+ var HINT_AUDIT = "\uFF1B\u26A0\uFE0F \u5BA1\u8BA1\u56DE\u6307\uFF0C\u670D\u52A1\u7AEF\u81EA\u5DF1\u586B\uFF0C\u987E\u95EE\u4E0D\u586B";
15232
+ var VALUE_FOOTNOTE = "\uFF08\u6307\u8DEF\u53EA\u4F9D\u636E\u4EA7\u7269\u91CC**\u771F\u5B9E\u5B58\u5728**\u7684\u6587\u4EF6\u3002\u26A0\uFE0F \u300C\u6211\u8981\u4E86\u5B57\u6BB5 X\uFF0C\u56DE\u6765\u6CA1\u6709 X\u300D\u6709\u4E09\u79CD\u540C\u5F62\u6210\u56E0\uFF1A\u2460 \u4EA7\u54C1\u91CC\u6CA1\u8FD9\u4E2A\u5B57\u6BB5 \u2461 \u8BE5\u884C\u8BE5\u5B57\u6BB5\u4E3A null \u2462 \u4F60\u7684\u89D2\u8272\u88AB RBAC \u88C1\u6389\u4E86\u8FD9\u4E00\u5217 \u2014\u2014 \u4EA7\u7269\u5206\u4E0D\u5F00\uFF0C\u522B\u628A\u5176\u4E2D\u4EFB\u4E00\u8BFB\u6210\u53E6\u4E00\u4E2A\u3002\uFF09\n";
15233
+ function isLocalName(name) {
15234
+ if (typeof name !== "string" || name.length === 0) return false;
15235
+ if (name.includes("/") || name.includes("\\")) return false;
15236
+ if (name === "." || name === "..") return false;
15237
+ return !path18.isAbsolute(name);
15238
+ }
15239
+ var readJson = (file) => {
15240
+ try {
15241
+ return JSON.parse(readFileSync9(file, "utf-8"));
15242
+ } catch {
15243
+ return void 0;
15244
+ }
15245
+ };
15246
+ var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
15247
+ var ValueHints = class {
15248
+ root;
15249
+ sheets = /* @__PURE__ */ new Map();
15250
+ domains = void 0;
15251
+ constructor(root) {
15252
+ this.root = root;
15253
+ }
15254
+ /** → `{modelKey: completeness}`;**索引根本读不到时返回 `null`**(与「读到了但是空的」分开)。 */
15255
+ domainIndex() {
15256
+ if (this.domains === void 0) {
15257
+ const body = readJson(path18.join(this.root, "valuedomain", "_index.json"));
15258
+ const by = isRec(body) ? body.byCompleteness : void 0;
15259
+ if (!isRec(by)) {
15260
+ this.domains = null;
15261
+ } else {
15262
+ const index = /* @__PURE__ */ new Map();
15263
+ for (const [completeness, names] of Object.entries(by)) {
15264
+ if (!Array.isArray(names)) continue;
15265
+ for (const n of names) if (typeof n === "string") index.set(n, completeness);
15266
+ }
15267
+ this.domains = index;
15268
+ }
15269
+ }
15270
+ return this.domains;
15271
+ }
15272
+ /** 某个模型的 `mapping/<model>.json` → `{fieldKey: 该字段那一行}`;没有则 null。 */
15273
+ sheet(model) {
15274
+ const key = String(model ?? "");
15275
+ if (!this.sheets.has(key)) {
15276
+ let fields = null;
15277
+ if (isLocalName(key)) {
15278
+ const body = readJson(path18.join(this.root, "mapping", `${key}.json`));
15279
+ const rows = isRec(body) ? body.fields : void 0;
15280
+ if (Array.isArray(rows)) {
15281
+ fields = /* @__PURE__ */ new Map();
15282
+ for (const f of rows) {
15283
+ if (isRec(f) && typeof f.key === "string") fields.set(f.key, f);
15284
+ }
15285
+ }
15286
+ }
15287
+ this.sheets.set(key, fields);
15288
+ }
15289
+ return this.sheets.get(key) ?? null;
15290
+ }
15291
+ refLine(ref) {
15292
+ const target = String(ref.toModel ?? "");
15293
+ const index = this.domainIndex();
15294
+ const completeness = index === null ? void 0 : index.get(target);
15295
+ const pointer = ref.valueDomain;
15296
+ const landed = isLocalName(target) && existsSync10(path18.join(this.root, "valuedomain", `${target}.json`));
15297
+ let line;
15298
+ if (pointer && completeness && completeness !== "unavailable" && landed) {
15299
+ line = HINT_REF(String(pointer));
15300
+ } else {
15301
+ line = HINT_NO_DOMAIN(target);
15302
+ if (pointer && index === null) line += HINT_DOMAIN_INDEX_UNREADABLE(target);
15303
+ else if (pointer && completeness === void 0) line += HINT_DOMAIN_UNKNOWN_TO_INDEX;
15304
+ else if (pointer && completeness === "unavailable") line += HINT_DOMAIN_UNAVAILABLE;
15305
+ else if (pointer && !landed) line += HINT_DOMAIN_MISSING(target);
15306
+ }
15307
+ if (ref.labelFieldSource === "declared" && ref.labelField) line += HINT_LABEL(String(ref.labelField));
15308
+ else line += HINT_LABEL_UNKNOWN;
15309
+ if (ref.auditBackref) line += HINT_AUDIT;
15310
+ return `${line}
15311
+ `;
15312
+ }
15313
+ /** 一条命中的指路行(含换行);无从指路时返回空串。 */
15314
+ line(model, key) {
15315
+ const sheet = this.sheet(model);
15316
+ if (!sheet || sheet.size === 0) return "";
15317
+ const field = sheet.get(String(key ?? ""));
15318
+ if (!isRec(field)) return "";
15319
+ const ref = field.ref;
15320
+ if (isRec(ref)) return this.refLine(ref);
15321
+ const count = field.enumCount;
15322
+ if (typeof count === "number" && Number.isInteger(count) && count > 0) {
15323
+ return `${HINT_ENUM(count, String(model))}
15324
+ `;
15325
+ }
15326
+ return "";
15327
+ }
15328
+ };
15329
+
15330
+ // src/fde/seed/find.ts
15331
+ var MAX_BYTES = 8192;
15332
+ var FIND_LIMIT = 500;
15333
+ var ENUM_SHOW = 8;
15334
+ var SYNTH_MARK = "\u26A0\u5408\u6210";
15335
+ var SYNTH_FOOTNOTE = `\uFF08\u5E26 ${SYNTH_MARK} \u7684\u53D6\u503C\u662F\u5DE5\u5177\u4ECE label \u6216\u5143\u7D20\u672C\u8EAB\u8865\u51FA\u6765\u7684\uFF0C\u4EA7\u54C1\u4ECE\u672A\u53D1\u51FA\u8FD9\u4E2A value\uFF0C**\u4E0D\u53EF**\u76F4\u63A5\u62FF\u53BB\u62FC\u7B5B\u9009\u6761\u4EF6\u3002\uFF09
15336
+ `;
15337
+ var DIMENSION_LABELS = {
15338
+ name: "\u540D\u79F0",
15339
+ key: "\u5B57\u6BB5\u540D",
15340
+ model: "\u6A21\u578B\u540D",
15341
+ synonyms: "\u540C\u4E49\u8BCD",
15342
+ description: "\u63CF\u8FF0",
15343
+ enumLabel: "\u679A\u4E3E\u6807\u7B7E",
15344
+ enumValue: "\u679A\u4E3E\u503C"
15345
+ };
15346
+ var KIT_MATCHED_ON = "_kitMatchedOn";
15347
+ var DIMENSION_RANK = {
15348
+ name: 2,
15349
+ key: 3,
15350
+ model: 3,
15351
+ synonyms: 4,
15352
+ enumLabel: 5,
15353
+ enumValue: 6,
15354
+ description: 7
15355
+ };
15356
+ var EXACT_NAME_RANK = 0;
15357
+ var EXACT_KEY_RANK = 1;
15358
+ var WEAKEST_RANK = Object.keys(DIMENSION_RANK).length;
15359
+ var VISIBLE_DIMENSIONS = /* @__PURE__ */ new Set(["name", "key", "model"]);
15360
+ var asList = (v) => v === null || v === void 0 ? [] : Array.isArray(v) ? v : [v];
15361
+ var str2 = (v) => v === null || v === void 0 ? "" : String(v);
15362
+ var bytes = (s) => Buffer.byteLength(s, "utf-8");
15363
+ function loadRows(text2) {
15364
+ const rows = [];
15365
+ const problems = [];
15366
+ const lines = text2.split("\n");
15367
+ lines.forEach((raw, i) => {
15368
+ const line = raw.trim();
15369
+ if (!line) return;
15370
+ try {
15371
+ const parsed = JSON.parse(line);
15372
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
15373
+ problems.push(`\u7B2C ${i + 1} \u884C\u4E0D\u662F JSON \u5BF9\u8C61\uFF0C\u5DF2\u8DF3\u8FC7`);
15374
+ return;
15375
+ }
15376
+ rows.push(parsed);
15377
+ } catch {
15378
+ problems.push(`\u7B2C ${i + 1} \u884C\u89E3\u6790\u5931\u8D25\uFF0C\u5DF2\u8DF3\u8FC7`);
15379
+ }
15380
+ });
15381
+ return { rows, problems };
15382
+ }
15383
+ function matchedDimensions(row, term) {
15384
+ const t = term.toLowerCase();
15385
+ const dims = [];
15386
+ for (const dim of ["name", "key", "model"]) {
15387
+ if (str2(row[dim]).toLowerCase().includes(t)) dims.push(dim);
15388
+ }
15389
+ if (asList(row.synonyms).some((s) => str2(s).toLowerCase().includes(t))) dims.push("synonyms");
15390
+ if (str2(row.description).toLowerCase().includes(t)) dims.push("description");
15391
+ const labels = [];
15392
+ const values = [];
15393
+ for (const e of asList(row.enums)) {
15394
+ if (e && typeof e === "object" && !Array.isArray(e)) {
15395
+ const o = e;
15396
+ values.push(str2(o.value));
15397
+ labels.push(str2(o.label));
15398
+ } else {
15399
+ values.push(str2(e));
15400
+ }
15401
+ }
15402
+ if (labels.some((x) => x.toLowerCase().includes(t))) dims.push("enumLabel");
15403
+ if (values.some((x) => x.toLowerCase().includes(t))) dims.push("enumValue");
15404
+ return dims;
15405
+ }
15406
+ function hitRank(row, dims, term) {
15407
+ const t = term.toLowerCase();
15408
+ if (dims.includes("name") && str2(row.name).toLowerCase() === t) return EXACT_NAME_RANK;
15409
+ if (dims.includes("key") && str2(row.key).toLowerCase() === t) return EXACT_KEY_RANK;
15410
+ let best = WEAKEST_RANK;
15411
+ for (const d of dims) best = Math.min(best, DIMENSION_RANK[d] ?? WEAKEST_RANK);
15412
+ return best;
15413
+ }
15414
+ function find(rows, term, limit = FIND_LIMIT) {
15415
+ const t = (term ?? "").toLowerCase();
15416
+ if (!t) return [];
15417
+ const scored = [];
15418
+ rows.forEach((r, i) => {
15419
+ const dims = matchedDimensions(r, t);
15420
+ if (dims.length === 0) return;
15421
+ scored.push({ rank: hitRank(r, dims, t), i, hit: { ...r, [KIT_MATCHED_ON]: dims } });
15422
+ });
15423
+ scored.sort((a, b) => a.rank - b.rank || a.i - b.i);
15424
+ return scored.slice(0, limit).map((s) => s.hit);
15425
+ }
15426
+ function enumTail(row) {
15427
+ const items = asList(row.enums);
15428
+ if (items.length === 0) return { tail: "", hasSynth: false };
15429
+ const shown = [];
15430
+ let hasSynth = false;
15431
+ for (const e of items.slice(0, ENUM_SHOW)) {
15432
+ if (e && typeof e === "object" && !Array.isArray(e)) {
15433
+ const o = e;
15434
+ const synth = o[KIT_VALUE_SOURCE] !== void 0 && o[KIT_VALUE_SOURCE] !== null;
15435
+ if (synth) hasSynth = true;
15436
+ shown.push(`${str2(o.value)}${synth ? SYNTH_MARK : ""}`);
15437
+ } else {
15438
+ shown.push(str2(e));
15439
+ }
15440
+ }
15441
+ const more = items.length > ENUM_SHOW ? `\u2026\u5171 ${items.length} \u4E2A` : "";
15442
+ return { tail: ` {${shown.join("/")}${more}}`, hasSynth };
15443
+ }
15444
+ function matchNote(hit) {
15445
+ const dims = asList(hit[KIT_MATCHED_ON]).map(str2);
15446
+ if (dims.length === 0) return "";
15447
+ if (dims.some((d) => VISIBLE_DIMENSIONS.has(d))) return "";
15448
+ return " \u2190\u547D\u4E2D\u4E8E" + dims.map((d) => DIMENSION_LABELS[d] ?? d).join("/");
15449
+ }
15450
+ var budgetNote = (hitCount, shown) => `
15451
+ \uFF08\u5DF2\u622A\u65AD\uFF1A\u547D\u4E2D ${hitCount} \u6761\uFF0C\u6B64\u5904\u53EA\u663E\u793A ${shown} \u6761\u3002\u8BF7\u7F29\u5C0F\u68C0\u7D22\u8BCD\u3002\uFF09
15452
+ `;
15453
+ var searchCapNote = () => `\uFF08\u547D\u4E2D\u5DF2\u8FBE\u68C0\u7D22\u4E0A\u9650 ${FIND_LIMIT}\uFF0C\u5B9E\u9645\u53EF\u80FD\u66F4\u591A\uFF0C\u8BF7\u7F29\u5C0F\u68C0\u7D22\u8BCD\u3002\uFF09
15454
+ `;
15455
+ function renderFind(hits, term, total, options = {}) {
15456
+ const head = `# find \`${term}\` \u2014 ${hits.length} \u547D\u4E2D / \u7D22\u5F15\u5171 ${total} \u5B57\u6BB5
15457
+
15458
+ `;
15459
+ const reserve = bytes(budgetNote(hits.length, hits.length) + searchCapNote() + SYNTH_FOOTNOTE + VALUE_FOOTNOTE);
15460
+ const budget = MAX_BYTES - Math.max(0, Math.trunc(options.prefixBytes ?? 0));
15461
+ const lines = [];
15462
+ let shown = 0;
15463
+ let synthShown = false;
15464
+ let valueShown = false;
15465
+ for (const h of hits) {
15466
+ const { tail, hasSynth } = enumTail(h);
15467
+ const line = `- ${str2(h.name)} \u2192 \`${str2(h.model)}\`.\`${str2(h.key)}\` [${str2(h.type)}]${h.isRequired ? "\u5FC5\u586B" : ""}${tail}${matchNote(h)}
15468
+ `;
15469
+ const hint = options.hints ? options.hints.line(h.model, h.key) : "";
15470
+ const block = line + hint;
15471
+ if (bytes(head + lines.join("") + block) > budget - reserve) break;
15472
+ lines.push(block);
15473
+ shown += 1;
15474
+ synthShown = synthShown || hasSynth;
15475
+ valueShown = valueShown || hint.length > 0;
15476
+ }
15477
+ let out = head + lines.join("");
15478
+ if (shown < hits.length) out += budgetNote(hits.length, shown);
15479
+ if (hits.length >= FIND_LIMIT) out += searchCapNote();
15480
+ if (synthShown) out += SYNTH_FOOTNOTE;
15481
+ if (valueShown) out += VALUE_FOOTNOTE;
15482
+ return out;
15483
+ }
15484
+
15485
+ // src/fde/seed/values.ts
15486
+ import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
15487
+ import * as path19 from "path";
15488
+ var readJson2 = (file) => {
15489
+ try {
15490
+ return JSON.parse(readFileSync10(file, "utf-8"));
15491
+ } catch {
15492
+ return void 0;
15493
+ }
15494
+ };
15495
+ var isRec2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
15496
+ var VALUE_CELL_MISSING = "\u2014";
15497
+ var VALUE_STATE_DISABLED = "\u505C\u7528";
15498
+ var VALUE_STATE_ENABLED = "";
15499
+ var VALUE_STATE_UNKNOWN = "enabled?";
15500
+ var VALUE_STATE_FOOTNOTE = `\uFF08\u300C${VALUE_STATE_DISABLED}\u300D= \u8BE5\u884C \`enabled=false\`\uFF0C**\u522B\u5199\u8FDB\u5BFC\u5165\u811A\u672C**\uFF1B\u300C${VALUE_STATE_UNKNOWN}\u300D= \u8FD9\u4EFD\u4EA7\u7269\u91CC\u90A3\u4E00\u884C**\u6CA1\u6709 \`enabled\` \u952E**\uFF0C\u5DE5\u5177\u4E0D\u66FF\u4EA7\u54C1\u5047\u8BBE\u5B83\u662F\u542F\u7528\u7684\u3002\uFF09
15501
+ `;
15502
+ var valuesTruncated = (total, shown, file) => `\uFF08\u5DF2\u622A\u65AD\uFF1A\u5171 ${total} \u884C\uFF0C\u6B64\u5904\u53EA\u663E\u793A ${shown} \u884C \u2014\u2014 \u884C\u5757\u6709 ${MAX_BYTES} \u5B57\u8282\u9884\u7B97\uFF08\u62AC\u5934\u4E0E\u811A\u6CE8\u4E0D\u8BA1\u5165\uFF09\u3002\u5168\u91CF\u5728 ${file}\uFF1B\u8981\u5168\u90E8\u6253\u5370\u7528 \`--limit 0\`\uFF0C\u6216 \`--limit N\` \u6307\u5B9A\u884C\u6570\u3002\uFF09
15503
+ `;
15504
+ function valueState(row) {
15505
+ if (!Object.prototype.hasOwnProperty.call(row, "enabled")) return VALUE_STATE_UNKNOWN;
15506
+ const enabled = row.enabled;
15507
+ if (enabled === false) return VALUE_STATE_DISABLED;
15508
+ if (enabled === true) return VALUE_STATE_ENABLED;
15509
+ return `${VALUE_STATE_UNKNOWN}=${JSON.stringify(enabled)}`;
15510
+ }
15511
+ var VALUES_ROUND_STALE = (detail) => `> \u{1F534} \`valuedomain/_index.json\` ${detail} \u2014\u2014 \u4E0B\u9762\u90A3\u53E5\u53E3\u5F84\u91CC\u7684\u300C\u672C\u8F6E\u300D**\u4E0D\u662F\u4F60\u521A\u8DD1\u7684\u90A3\u4E00\u8F6E**\uFF0C\u8FD9\u5F20\u7801\u8868\u5FEB\u7167\u53EF\u80FD\u66F4\u65E9\u3002
15512
+ `;
15513
+ var VALUES_ROUND_MIXED = (state) => `> \u26A0\uFE0F \u8FD9\u4EFD\u57FA\u7EBF\u4E0D\u662F\u4E00\u8F6E\u5B8C\u6574\u8DD1\u51FA\u6765\u7684\uFF08\`round\` = ${state}\uFF09\uFF0C\u4E0D\u8FC7 \`valuedomain/_index.json\` \u672C\u8EAB\u662F\u672C\u8F6E\u7684 \u2014\u2014 \u4E0B\u9762\u90A3\u53E5\u53E3\u5F84\u91CC\u7684\u300C\u672C\u8F6E\u300D\u6309\u5B83\u7406\u89E3\u3002
15514
+ `;
15515
+ var STALE_WORDS = {
15516
+ "older-round": "\u662F**\u522B\u7684\u8F6E\u6B21**\u7559\u4E0B\u7684",
15517
+ unstamped: "**\u6CA1\u6709\u8F6E\u6B21\u6233**\uFF08\u66F4\u65E9\u7248\u672C\u5199\u7684\uFF09",
15518
+ missing: "**\u4E0D\u5728\u76D8\u4E0A**",
15519
+ unreadable: "**\u8BFB\u4E0D\u51FA JSON**"
15520
+ };
15521
+ function valuesRoundCaveat(round) {
15522
+ if (!isRec2(round)) return "";
15523
+ const state = round.state;
15524
+ if (state === "complete") return "";
15525
+ const products = round.products;
15526
+ const entry = Array.isArray(products) ? products.find((p) => isRec2(p) && p.path === "valuedomain/_index.json") : void 0;
15527
+ const productState = isRec2(entry) ? entry.state : void 0;
15528
+ if (typeof productState === "string" && productState in STALE_WORDS) {
15529
+ return VALUES_ROUND_STALE(STALE_WORDS[productState]);
15530
+ }
15531
+ return VALUES_ROUND_MIXED(String(state ?? "unknown"));
15532
+ }
15533
+ function renderValues(root, model, options = {}) {
15534
+ const indexBody = readJson2(path19.join(root, "valuedomain", "_index.json"));
15535
+ const byCompleteness = isRec2(indexBody) ? indexBody.byCompleteness : void 0;
15536
+ if (!isRec2(byCompleteness)) {
15537
+ return {
15538
+ ok: false,
15539
+ kind: "index-unreadable",
15540
+ message: `\u8BFB\u4E0D\u5230 valuedomain/_index.json\uFF08${root}\uFF09\u2014\u2014 \u53EF\u80FD\u662F\uFF1A\u8FD9\u4EFD\u57FA\u7EBF\u7531\u66F4\u65E9\u7248\u672C\u722C\u7684\u3001\u4F60\u6CA1\u62F7 valuedomain/ \u76EE\u5F55\u8FC7\u6765\u3001\u6216\u8005\u90A3\u4E2A\u6587\u4EF6\u574F\u4E86\u3002\u5148 \`ls ${path19.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
15541
+ };
15542
+ }
15543
+ let completeness;
15544
+ for (const [c, names] of Object.entries(byCompleteness)) {
15545
+ if (Array.isArray(names) && names.includes(model)) {
15546
+ completeness = c;
15547
+ break;
15548
+ }
15549
+ }
15550
+ if (completeness === void 0) {
15551
+ if (isLocalName(model) && existsSync11(path19.join(root, "mapping", `${model}.json`))) {
15552
+ return {
15553
+ ok: false,
15554
+ kind: "not-a-code-table",
15555
+ message: `${model} \u4E0D\u662F\u7801\u8868\uFF08\`type != DYNAMIC\`\uFF0Cvaluedomain/ \u91CC\u6CA1\u6709\u5B83\uFF09\u2014\u2014 \u6307\u5411\u5B83\u7684\u5F15\u7528\u503C\u53EA\u80FD\u6309\u4E1A\u52A1\u952E\u73B0\u67E5\u3002\u5B83\u7684\u5B57\u6BB5\u6E05\u5355\u5728 mapping/${model}.json\u3002`
15556
+ };
15557
+ }
15558
+ return {
15559
+ ok: false,
15560
+ kind: "model-not-in-baseline",
15561
+ message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path19.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
15562
+ };
15563
+ }
15564
+ const file = path19.join(root, "valuedomain", `${model}.json`);
15565
+ if (!isLocalName(model) || !existsSync11(file)) {
15566
+ return {
15567
+ ok: false,
15568
+ kind: "file-missing",
15569
+ message: `${model} \u5728 valuedomain/_index.json \u91CC\u6302\u7740\uFF08completeness=${completeness}\uFF09\uFF0C\u4F46\u76D8\u4E0A\u6CA1\u6709\u8FD9\u4EFD\u6587\u4EF6 \u2014\u2014 \u53BB\u770B _index.json \u7684 writeProblems\u3002`
15570
+ };
15571
+ }
15572
+ const table = readJson2(file);
15573
+ const rows = isRec2(table) ? table.rows : void 0;
15574
+ if (!Array.isArray(rows)) {
15575
+ return { ok: false, kind: "rows-unreadable", message: `${file} \u8BFB\u4E0D\u51FA rows` };
15576
+ }
15577
+ const head = `# values ${model} \u2014 completeness=${completeness}\uFF0C\u53D6\u56DE ${String(isRec2(table) ? table.rowsRetrieved : "?")} \u884C / \u8BA1\u6570 ${String(isRec2(table) ? table.totalElements : "?")} \u884C
15578
+ `;
15579
+ const caveat = options.roundCaveat ?? "";
15580
+ const wording = `> ${String(indexBody && isRec2(indexBody) ? indexBody.wording ?? "" : "")}
15581
+ `;
15582
+ const lines = ["id code name \u72B6\u6001\n"];
15583
+ let missing = false;
15584
+ let stateShown = false;
15585
+ let shown = 0;
15586
+ let used = 0;
15587
+ const limit = options.limit;
15588
+ for (const row of rows) {
15589
+ if (!isRec2(row)) continue;
15590
+ const cells = [];
15591
+ for (const key of ["id", "code", "name"]) {
15592
+ const v = row[key];
15593
+ if (v === null || v === void 0) missing = true;
15594
+ cells.push(v === null || v === void 0 ? VALUE_CELL_MISSING : String(v));
15595
+ }
15596
+ const state = valueState(row);
15597
+ const line = `${[...cells, state].join(" ")}
15598
+ `;
15599
+ if (limit === void 0) {
15600
+ used += Buffer.byteLength(line, "utf-8");
15601
+ if (used > MAX_BYTES) break;
15602
+ } else if (limit > 0 && shown >= limit) {
15603
+ break;
15604
+ }
15605
+ lines.push(line);
15606
+ shown += 1;
15607
+ stateShown = stateShown || state.length > 0;
15608
+ }
15609
+ const total = rows.filter((r) => isRec2(r)).length;
15610
+ let out = head + caveat + wording + lines.join("");
15611
+ if (shown < total) out += valuesTruncated(total, shown, `valuedomain/${model}.json`);
15612
+ if (stateShown) out += VALUE_STATE_FOOTNOTE;
15613
+ if (missing) out += VALUE_FOOTNOTE;
15614
+ return { ok: true, text: out };
15615
+ }
15616
+
15617
+ // src/fde/gate0/aclass.ts
15618
+ import { existsSync as existsSync12, readFileSync as readFileSync12, readdirSync as readdirSync3, statSync as statSync9 } from "fs";
15619
+ import * as path20 from "path";
15209
15620
 
15210
15621
  // src/fde/gate0/mapping-artifact.ts
15211
- import { readFileSync as readFileSync9 } from "fs";
15622
+ import { readFileSync as readFileSync11 } from "fs";
15212
15623
  var MAPPING_ARTIFACT_VERSION = 1;
15213
15624
  var MappingArtifactError = class extends Error {
15214
15625
  constructor(reason, message) {
@@ -15226,7 +15637,7 @@ function isRecord6(value) {
15226
15637
  function readBusinessKeyFields(file) {
15227
15638
  let text2;
15228
15639
  try {
15229
- text2 = readFileSync9(file, "utf8");
15640
+ text2 = readFileSync11(file, "utf8");
15230
15641
  } catch (e) {
15231
15642
  const code = e?.code;
15232
15643
  if (code === "ENOENT") throw new MappingArtifactError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`);
@@ -15337,10 +15748,10 @@ function scalarsWithin(value) {
15337
15748
  }
15338
15749
  function readText(file, kinds, scope, problems) {
15339
15750
  try {
15340
- return readFileSync10(file, "utf8");
15751
+ return readFileSync12(file, "utf8");
15341
15752
  } catch (e) {
15342
15753
  const code = e?.code;
15343
- const name = path18.basename(file);
15754
+ const name = path20.basename(file);
15344
15755
  problems.push({
15345
15756
  scope,
15346
15757
  reason: REASON_UNREAD,
@@ -15353,7 +15764,7 @@ function readText(file, kinds, scope, problems) {
15353
15764
  function readJsonl(file, kinds, scope, problems) {
15354
15765
  const text2 = readText(file, kinds, scope, problems);
15355
15766
  if (text2 === null) return [];
15356
- const name = path18.basename(file);
15767
+ const name = path20.basename(file);
15357
15768
  const rows = [];
15358
15769
  text2.split("\n").forEach((raw, i) => {
15359
15770
  const line = raw.trim();
@@ -15384,7 +15795,7 @@ function readJsonl(file, kinds, scope, problems) {
15384
15795
  return rows;
15385
15796
  }
15386
15797
  var UNREADABLE = /* @__PURE__ */ Symbol("unreadable");
15387
- function readJson(file, kinds, scope, problems) {
15798
+ function readJson3(file, kinds, scope, problems) {
15388
15799
  const text2 = readText(file, kinds, scope, problems);
15389
15800
  if (text2 === null) return UNREADABLE;
15390
15801
  try {
@@ -15394,13 +15805,13 @@ function readJson(file, kinds, scope, problems) {
15394
15805
  scope,
15395
15806
  reason: REASON_UNREAD,
15396
15807
  kinds,
15397
- message: `\u4EA7\u7269 ${path18.basename(file)} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
15808
+ message: `\u4EA7\u7269 ${path20.basename(file)} \u4E0D\u662F\u5408\u6CD5 JSON\uFF08${String(e)}\uFF09\u21D2 ${unguardedWord(kinds)} \u8FD9\u51E0\u7C7B\u6B64\u523B\u65E0\u4EBA\u5B88`
15398
15809
  });
15399
15810
  return UNREADABLE;
15400
15811
  }
15401
15812
  }
15402
15813
  function listUnder(payload, key, file, kinds, scope, problems) {
15403
- const name = path18.basename(file);
15814
+ const name = path20.basename(file);
15404
15815
  if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
15405
15816
  problems.push({
15406
15817
  scope,
@@ -15436,7 +15847,7 @@ function deriveAclass(root, mappingArtifact = null) {
15436
15847
  const problems = [];
15437
15848
  const out = Object.fromEntries(ACLASS_KINDS.map((k) => [k, /* @__PURE__ */ new Set()]));
15438
15849
  for (const row of readJsonl(
15439
- path18.join(root, ...FIELDS_INDEX),
15850
+ path20.join(root, ...FIELDS_INDEX),
15440
15851
  ["fieldKey", "fieldLabel", "caliber"],
15441
15852
  CLASS_SCOPE,
15442
15853
  problems
@@ -15452,7 +15863,7 @@ function deriveAclass(root, mappingArtifact = null) {
15452
15863
  }
15453
15864
  }
15454
15865
  for (const row of readJsonl(
15455
- path18.join(root, ...ENUM_MIRROR),
15866
+ path20.join(root, ...ENUM_MIRROR),
15456
15867
  ["enumValue"],
15457
15868
  CLASS_SCOPE,
15458
15869
  problems
@@ -15466,8 +15877,8 @@ function deriveAclass(root, mappingArtifact = null) {
15466
15877
  }
15467
15878
  }
15468
15879
  }
15469
- const rosterPath = path18.join(root, ...MODEL_ROSTER);
15470
- const roster = readJson(rosterPath, ["modelName"], CLASS_SCOPE, problems);
15880
+ const rosterPath = path20.join(root, ...MODEL_ROSTER);
15881
+ const roster = readJson3(rosterPath, ["modelName"], CLASS_SCOPE, problems);
15471
15882
  if (roster !== UNREADABLE) {
15472
15883
  const rows = listUnder(roster, "models", rosterPath, ["modelName"], CLASS_SCOPE, problems);
15473
15884
  const entries = modelEntries(roster);
@@ -15494,12 +15905,12 @@ function deriveAclass(root, mappingArtifact = null) {
15494
15905
  });
15495
15906
  }
15496
15907
  }
15497
- const valueDomain = path18.join(root, VALUE_DOMAIN_DIR);
15498
- if (existsSync10(valueDomain) && statSync9(valueDomain).isDirectory()) {
15908
+ const valueDomain = path20.join(root, VALUE_DOMAIN_DIR);
15909
+ if (existsSync12(valueDomain) && statSync9(valueDomain).isDirectory()) {
15499
15910
  const tables = readdirSync3(valueDomain).filter((f) => f.endsWith(".json") && !RESERVED_FILENAMES.includes(f)).sort();
15500
15911
  for (const name of tables) {
15501
- const file = path18.join(valueDomain, name);
15502
- const payload = readJson(file, ["codeValue"], ENTRY_SCOPE, problems);
15912
+ const file = path20.join(valueDomain, name);
15913
+ const payload = readJson3(file, ["codeValue"], ENTRY_SCOPE, problems);
15503
15914
  if (payload === UNREADABLE) continue;
15504
15915
  for (const row of listUnder(payload, "rows", file, ["codeValue"], ENTRY_SCOPE, problems)) {
15505
15916
  if (typeof row !== "object" || row === null || Array.isArray(row)) {
@@ -15564,8 +15975,8 @@ function deriveAclass(root, mappingArtifact = null) {
15564
15975
  }
15565
15976
 
15566
15977
  // src/fde/gate0/facts.ts
15567
- import { existsSync as existsSync11, readFileSync as readFileSync11 } from "fs";
15568
- import * as path19 from "path";
15978
+ import { existsSync as existsSync13, readFileSync as readFileSync13 } from "fs";
15979
+ import * as path21 from "path";
15569
15980
  var REGISTRY_SCOPE = "registry";
15570
15981
  var ENTRY_SCOPE2 = "entry";
15571
15982
  var REASON_NO_ENTRIES = "no-entries";
@@ -15647,9 +16058,9 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
15647
16058
  return;
15648
16059
  }
15649
16060
  if (probeRoot !== void 0) {
15650
- const file = path19.join(probeRoot, shape.groups.file);
16061
+ const file = path21.join(probeRoot, shape.groups.file);
15651
16062
  const mark = `${PROBE_MARK_PREFIX} ${shape.groups.mark}`;
15652
- const found = existsSync11(file) && readFileSync11(file, "utf8").includes(mark);
16063
+ const found = existsSync13(file) && readFileSync13(file, "utf8").includes(mark);
15653
16064
  if (!found) {
15654
16065
  problems.push({
15655
16066
  scope: ENTRY_SCOPE2,
@@ -15667,8 +16078,8 @@ function loadProtocolFacts(entries = PROTOCOL_FACTS, options = {}) {
15667
16078
  }
15668
16079
 
15669
16080
  // src/fde/gate0/scan.ts
15670
- import { readFileSync as readFileSync12, readdirSync as readdirSync4, readlinkSync, statSync as statSync10 } from "fs";
15671
- import * as path20 from "path";
16081
+ import { readFileSync as readFileSync14, readdirSync as readdirSync4, readlinkSync, statSync as statSync10 } from "fs";
16082
+ import * as path22 from "path";
15672
16083
  var CHANNEL_ACLASS = "aclass";
15673
16084
  var CHANNEL_ARTIFACT = "artifact-path";
15674
16085
  var CHANNEL_UNREGISTERED = "protocol-unregistered";
@@ -16235,7 +16646,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
16235
16646
  }
16236
16647
  premise2.push({
16237
16648
  reason: REASON_SYMLINK_NOT_SCANNED,
16238
- message: `${path20.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`
16649
+ message: `${path22.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`
16239
16650
  });
16240
16651
  }
16241
16652
  if (files.length === 0) {
@@ -16248,7 +16659,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
16248
16659
  for (const file of files) {
16249
16660
  let text2;
16250
16661
  try {
16251
- text2 = readFileSync12(file, "utf8");
16662
+ text2 = readFileSync14(file, "utf8");
16252
16663
  } catch (e) {
16253
16664
  premise2.push({
16254
16665
  reason: REASON_FILE_UNREADABLE,
@@ -16256,7 +16667,7 @@ function scan(skillRoot, aclass, facts, options = {}) {
16256
16667
  });
16257
16668
  continue;
16258
16669
  }
16259
- const rel = path20.relative(skillRoot, file);
16670
+ const rel = path22.relative(skillRoot, file);
16260
16671
  scanned.push(rel);
16261
16672
  text2.split("\n").forEach((line, i) => {
16262
16673
  judgeLine(line, i + 1, rel, matcher, index, reds, gaps);
@@ -16293,7 +16704,7 @@ function walk3(root) {
16293
16704
  const unscannedLinks = [];
16294
16705
  const visit = (dir) => {
16295
16706
  for (const entry of readdirSync4(dir, { withFileTypes: true })) {
16296
- const full = path20.join(dir, entry.name);
16707
+ const full = path22.join(dir, entry.name);
16297
16708
  let followed = null;
16298
16709
  try {
16299
16710
  followed = statSync10(full);
@@ -16377,8 +16788,8 @@ function buildCarrierResult(carrier, verdict, options = {}) {
16377
16788
  }
16378
16789
 
16379
16790
  // src/fde/triage/probe.ts
16380
- import { readFileSync as readFileSync13 } from "fs";
16381
- import * as path21 from "path";
16791
+ import { readFileSync as readFileSync15 } from "fs";
16792
+ import * as path23 from "path";
16382
16793
  var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
16383
16794
  var MODELS_REL = "models.json";
16384
16795
  var FIELDS_REL = "index/fields.jsonl";
@@ -16401,10 +16812,10 @@ function unavailableCell(carrier, err) {
16401
16812
  });
16402
16813
  }
16403
16814
  function readArtifactJson(dir, rel) {
16404
- return JSON.parse(readFileSync13(path21.join(dir, rel), "utf8"));
16815
+ return JSON.parse(readFileSync15(path23.join(dir, rel), "utf8"));
16405
16816
  }
16406
16817
  function readArtifactJsonl(dir, rel) {
16407
- const body = readFileSync13(path21.join(dir, rel), "utf8");
16818
+ const body = readFileSync15(path23.join(dir, rel), "utf8");
16408
16819
  const rows = [];
16409
16820
  for (const line of body.split("\n")) {
16410
16821
  const trimmed = line.trim();
@@ -16730,6 +17141,7 @@ export {
16730
17141
  AGREEING_VERDICTS,
16731
17142
  APPLY_CAVEAT,
16732
17143
  APPLY_PROBLEM_CODES,
17144
+ PROBLEM_CODES as ARTIFACT_PROBLEM_CODES,
16733
17145
  ARTIFACT_ROOT,
16734
17146
  ARTIFACT_SUFFIXES,
16735
17147
  ARTIFACT_WORDING,
@@ -16764,6 +17176,7 @@ export {
16764
17176
  DEFAULT_AGENT_ID,
16765
17177
  DEFAULT_SESSION_TTL_SECONDS,
16766
17178
  PREMISE_CODES4 as DELIVERY_PREMISE_CODES,
17179
+ DIMENSION_LABELS,
16767
17180
  DOCTOR_ANCHORS,
16768
17181
  DRY_RUN_NOTE,
16769
17182
  DRY_RUN_TAIL,
@@ -16771,12 +17184,15 @@ export {
16771
17184
  ENDPOINT_PREFIXES,
16772
17185
  ENTRY_SCOPE,
16773
17186
  ENUM_ELEMENT_KEYS,
17187
+ ENUM_SHOW,
16774
17188
  EXEMPTIBLE_CODES,
16775
17189
  EXEMPTION_CODES,
16776
17190
  EXEMPTION_REQUIRED_KEYS,
16777
17191
  EXTENSION_SOURCE_HEADER,
16778
17192
  ExitCode,
16779
17193
  FACTS_REASONS,
17194
+ FIND_LIMIT,
17195
+ MAX_BYTES as FIND_MAX_BYTES,
16780
17196
  FOLDED_NOTE,
16781
17197
  FORCE_STALE_FLAG,
16782
17198
  FORCE_STALE_FLAG_TEXT,
@@ -16795,6 +17211,7 @@ export {
16795
17211
  JournalError,
16796
17212
  KIT_CARRY_OVER_KEY,
16797
17213
  KIT_CRAWLED_AT_FILE,
17214
+ KIT_MATCHED_ON,
16798
17215
  LEASE_FILE,
16799
17216
  LEDGER_MISSING_WORD,
16800
17217
  LEDGER_ONLY_FLAG,
@@ -16823,7 +17240,10 @@ export {
16823
17240
  NOT_COVERED_LAYER2,
16824
17241
  NOT_COVERED_SELF,
16825
17242
  OFFLINE_COMMANDS,
17243
+ ON_EXISTING,
16826
17244
  PASSWORD_CHANGE_REQUIRED,
17245
+ PLAN_JSON_KEYS,
17246
+ PLAN_PROBLEM_CODES,
16827
17247
  PREMISE_CLIENT,
16828
17248
  PREMISE_IDENTITY,
16829
17249
  PREMISE_JOURNAL_HAS_ENTRIES,
@@ -16873,17 +17293,25 @@ export {
16873
17293
  STATUSES,
16874
17294
  STEP_NOTHING,
16875
17295
  STEP_STOP,
17296
+ SYNTH_FOOTNOTE,
17297
+ SYNTH_MARK,
16876
17298
  CONFIG as TRIAGE_CONFIG,
16877
17299
  GAP as TRIAGE_GAP,
16878
17300
  VERDICTS3 as TRIAGE_VERDICTS,
16879
17301
  TargetModelNotFound,
16880
17302
  TokenStore,
17303
+ VALUE_CELL_MISSING,
17304
+ VALUE_FOOTNOTE,
17305
+ VALUE_STATE_DISABLED,
17306
+ VALUE_STATE_FOOTNOTE,
17307
+ VALUE_STATE_UNKNOWN,
16881
17308
  VERDICTS,
16882
17309
  VERDICT_DIVERGED,
16883
17310
  VERDICT_INCOMPARABLE,
16884
17311
  VERDICT_SAME,
16885
17312
  VERDICT_WORDS,
16886
17313
  VERSION_PATH,
17314
+ ValueHints,
16887
17315
  WAIVER_REPLAY,
16888
17316
  WARNED_ROUND_STATES,
16889
17317
  WORKSPACES_PATH,
@@ -16975,6 +17403,7 @@ export {
16975
17403
  fetchSkillMarkdown,
16976
17404
  fetchSkillReference,
16977
17405
  filterByStage,
17406
+ find,
16978
17407
  findLastAssistantSeq,
16979
17408
  flattenSkills,
16980
17409
  foldConfusables,
@@ -16990,6 +17419,7 @@ export {
16990
17419
  globalConfigFile,
16991
17420
  guessMimeType,
16992
17421
  hcmConfigDir,
17422
+ hitRank,
16993
17423
  httpProbe,
16994
17424
  identitiesDir,
16995
17425
  identityDir,
@@ -17002,6 +17432,7 @@ export {
17002
17432
  inspectRound,
17003
17433
  isCjk,
17004
17434
  isDelegationToolName,
17435
+ isLocalName,
17005
17436
  isReadOnly,
17006
17437
  isServerSlidingSession,
17007
17438
  isZeroNetwork,
@@ -17023,12 +17454,15 @@ export {
17023
17454
  loadProfile,
17024
17455
  loadProtocolFacts,
17025
17456
  loadRecordedFingerprint,
17457
+ loadRows,
17026
17458
  loadWorkspaceFileContent,
17027
17459
  loginClientCredentials,
17028
17460
  loginPairing,
17029
17461
  loginPassword,
17030
17462
  loginPat,
17463
+ matchNote,
17031
17464
  matchSkills,
17465
+ matchedDimensions,
17032
17466
  migrateLegacyProfiles,
17033
17467
  modelEntries,
17034
17468
  modelKeys,
@@ -17064,8 +17498,10 @@ export {
17064
17498
  readPullManifest,
17065
17499
  refreshToken,
17066
17500
  remove,
17501
+ renderFind,
17067
17502
  renderRound,
17068
17503
  renderTriage,
17504
+ renderValues,
17069
17505
  replHistoryFile,
17070
17506
  resetSettingItem,
17071
17507
  resolveActiveEnv,
@@ -17111,6 +17547,8 @@ export {
17111
17547
  update,
17112
17548
  uploadDocument,
17113
17549
  validateMiniProject,
17550
+ valueState,
17551
+ valuesRoundCaveat,
17114
17552
  verifyAttention,
17115
17553
  verifyRc,
17116
17554
  verifyText,