@hcmai/sdk 0.27.4 → 0.28.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
@@ -1018,8 +1018,8 @@ async function resolveEnvContext(args, env2, global) {
1018
1018
  }
1019
1019
  function printResolvedEnvironment(context, identity, tenantId) {
1020
1020
  const file = context.project?.path;
1021
- const relative3 = file ? path2.relative(process.cwd(), file) : void 0;
1022
- const source = context.source === "env.yaml" && relative3 ? relative3.startsWith(".") ? relative3 : `./${relative3}` : `${context.source}${relative3 ? ` \u2192 ${relative3.startsWith(".") ? relative3 : `./${relative3}`}` : ""}`;
1021
+ const relative4 = file ? path2.relative(process.cwd(), file) : void 0;
1022
+ const source = context.source === "env.yaml" && relative4 ? relative4.startsWith(".") ? relative4 : `./${relative4}` : `${context.source}${relative4 ? ` \u2192 ${relative4.startsWith(".") ? relative4 : `./${relative4}`}` : ""}`;
1023
1023
  process.stderr.write(`\u2192 ${context.project?.name ?? context.name}${context.project ? `\uFF08\u672C\u673A\u69FD ${context.name}\uFF09` : ""} \xB7 ${context.config.endpoint} \xB7 \u79DF\u6237 ${tenantId ?? context.project?.environment.tenant ?? context.config.tenantId ?? "\u672A\u6307\u5B9A"} \xB7 \u8EAB\u4EFD ${identity ?? "\u672A\u8BA4\u8BC1"}${context.danger ? " \xB7 danger" : ""}\uFF08\u6765\u81EA ${source}\uFF09
1024
1024
  `);
1025
1025
  }
@@ -1773,18 +1773,18 @@ async function action(http, model, actionName, input) {
1773
1773
  if (scope === "object" && !input.id) {
1774
1774
  throw new Error(`object action ${model}.${actionName} requires id`);
1775
1775
  }
1776
- const path24 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1776
+ const path25 = scope === "object" ? `/api/models/${model}/${input.id}/action/${actionName}` : `/api/models/${model}/action/${actionName}`;
1777
1777
  const resp = await (async () => {
1778
1778
  if (method === "GET") {
1779
- return http.get(path24, { params: queryParams(input) });
1779
+ return http.get(path25, { params: queryParams(input) });
1780
1780
  }
1781
1781
  if (method === "DELETE") {
1782
- return http.delete(path24, { params: queryParams(input) });
1782
+ return http.delete(path25, { params: queryParams(input) });
1783
1783
  }
1784
1784
  if (method === "PUT") {
1785
- return http.put(path24, scope === "object" ? objectBody(input) : classBody(input));
1785
+ return http.put(path25, scope === "object" ? objectBody(input) : classBody(input));
1786
1786
  }
1787
- return http.post(path24, scope === "object" ? objectBody(input) : classBody(input));
1787
+ return http.post(path25, scope === "object" ? objectBody(input) : classBody(input));
1788
1788
  })();
1789
1789
  return resp.data;
1790
1790
  }
@@ -1931,8 +1931,8 @@ function compareFingerprint(recorded, current) {
1931
1931
  continue;
1932
1932
  }
1933
1933
  const raw = notes.fetchFailures;
1934
- const list = Array.isArray(raw) ? raw : [];
1935
- const gateFailures = [...new Set(list.map(String))].filter((x) => GATE_SOURCES.some((s) => x.startsWith(s))).sort();
1934
+ const list2 = Array.isArray(raw) ? raw : [];
1935
+ const gateFailures = [...new Set(list2.map(String))].filter((x) => GATE_SOURCES.some((s) => x.startsWith(s))).sort();
1936
1936
  for (const f of gateFailures) diffs.push(`incomplete:${tag}:${f}`);
1937
1937
  }
1938
1938
  return diffs;
@@ -2124,7 +2124,7 @@ function parseFixture(yamlText, sourcePath) {
2124
2124
  if (hasLegacyKey) {
2125
2125
  const keys = doc.key;
2126
2126
  if (Array.isArray(keys) && keys.length > DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.maxItems) {
2127
- return fail2("hcm import v1 \u4E0D\u652F\u6301\u590D\u5408\u4E1A\u52A1\u952E\uFF1B\u8BF7\u58F0\u660E\u5355\u4E00\u771F\u5B9E\u552F\u4E00\u7684 key_field\uFF0C\u6216\u5728\u5B8C\u6574 DataPackage manifest \u4E2D\u58F0\u660E models[].keys \u5E76\u8D70 hcm datapackage install");
2127
+ return fail2("hcm import v1 \u4E0D\u652F\u6301\u590D\u5408\u4E1A\u52A1\u952E\uFF1B\u8BF7\u58F0\u660E\u5355\u4E00\u771F\u5B9E\u552F\u4E00\u7684 key_field\uFF0C\u6216\u5728\u5B8C\u6574\u5B89\u88C5\u5305 manifest \u4E2D\u58F0\u660E models[].keys \u5E76\u8D70 hcm package install");
2128
2128
  }
2129
2129
  if (!Array.isArray(keys) || keys.length !== DATA_PACKAGE_FIXTURE_SCHEMA_V1.properties.key.minItems || !nonEmptyString(keys[0])) {
2130
2130
  return fail2('"key" \u5FC5\u987B\u662F\u5355\u5143\u7D20\u6570\u7EC4\uFF0C\u5143\u7D20\u987B\u4E3A\u975E\u7A7A\u5B57\u7B26\u4E32\uFF1B\u8BF7\u4F7F\u7528 key_field: code');
@@ -2283,7 +2283,7 @@ function unresolvedError(unresolved, dryRun) {
2283
2283
  if (dryRun) {
2284
2284
  return `${head}\uFF1Bdry-run \u4E0D\u56DE\u67E5\u76EE\u6807\u73AF\u5883\uFF0C\u771F\u8DD1\u65F6\u53EF\u80FD\u89E3\u6790\u5F97\u5230`;
2285
2285
  }
2286
- return `${head}\uFF1B\u5DF2\u6309\u4E1A\u52A1\u952E\u56DE\u67E5\u76EE\u6807\u73AF\u5883\u4ECD\u672A\u547D\u4E2D\u3002\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u88AB\u5F15\u7528\u7684\u884C\u662F\u5426\u771F\u5728\u76EE\u6807\u73AF\u5883\uFF08\u5148\u5BFC\u5165\u88AB\u5F15\u7528\u7684\u76EE\u5F55\uFF09\uFF0C\u6216\u6574\u5305\u8D70 hcm datapackage install\uFF08\u670D\u52A1\u7AEF FixtureRefResolver \u540C\u6837\u4F1A\u56DE\u67E5\u5DF2\u6709\u884C\uFF09`;
2286
+ return `${head}\uFF1B\u5DF2\u6309\u4E1A\u52A1\u952E\u56DE\u67E5\u76EE\u6807\u73AF\u5883\u4ECD\u672A\u547D\u4E2D\u3002\u4E0B\u4E00\u6B65\uFF1A\u786E\u8BA4\u88AB\u5F15\u7528\u7684\u884C\u662F\u5426\u771F\u5728\u76EE\u6807\u73AF\u5883\uFF08\u5148\u5BFC\u5165\u88AB\u5F15\u7528\u7684\u76EE\u5F55\uFF09\uFF0C\u6216\u6574\u5305\u8D70 hcm package install\uFF08\u670D\u52A1\u7AEF FixtureRefResolver \u540C\u6837\u4F1A\u56DE\u67E5\u5DF2\u6709\u884C\uFF09`;
2287
2287
  }
2288
2288
 
2289
2289
  // src/client.ts
@@ -2892,10 +2892,10 @@ function validateCliAuthorizationUrl(raw, label) {
2892
2892
  }
2893
2893
  return url;
2894
2894
  }
2895
- async function post(input, path24, body, timeout = 3e4) {
2895
+ async function post(input, path25, body, timeout = 3e4) {
2896
2896
  checkCancelled(input.signal);
2897
2897
  try {
2898
- const { data } = await input.httpClient.post(`${input.endpoint.replace(/\/+$/, "")}${path24}`, body, {
2898
+ const { data } = await input.httpClient.post(`${input.endpoint.replace(/\/+$/, "")}${path25}`, body, {
2899
2899
  timeout,
2900
2900
  maxRedirects: 0,
2901
2901
  signal: input.signal,
@@ -3031,10 +3031,9 @@ function watchBrowserAuthorization(input) {
3031
3031
  let lastStatus;
3032
3032
  void (async () => {
3033
3033
  while (!stopped) {
3034
- const remaining = input.deadline - Date.now();
3035
- if (remaining <= 0) return;
3034
+ if (input.deadline - Date.now() <= interval) return;
3036
3035
  try {
3037
- await delay(Math.min(interval, remaining), void 0, { signal: input.signal });
3036
+ await delay(interval, void 0, { signal: input.signal });
3038
3037
  } catch {
3039
3038
  return;
3040
3039
  }
@@ -4384,12 +4383,12 @@ function buildResumeSummary(conversationId, items, maxRounds = 2, maxWidth = 76)
4384
4383
  }
4385
4384
  var isDeliveredAssistant = (it) => it.kind === "chat-text" && !isSupersededItem(it) && Number.isInteger(it.seq);
4386
4385
  function findLastAssistantTarget(items) {
4387
- const list = [...items ?? []].reverse();
4388
- if (list.length === 0) return { seq: null, reason: "empty" };
4386
+ const list2 = [...items ?? []].reverse();
4387
+ if (list2.length === 0) return { seq: null, reason: "empty" };
4389
4388
  let crossedTurn = false;
4390
4389
  let sawSuperseded = false;
4391
4390
  let earlierSeq;
4392
- for (const it of list) {
4391
+ for (const it of list2) {
4393
4392
  if (it.kind === "user-msg") {
4394
4393
  if (crossedTurn) break;
4395
4394
  crossedTurn = true;
@@ -7104,9 +7103,9 @@ function computeStatusEntries(context, manifest2, localFiles) {
7104
7103
  }
7105
7104
  async function loadRemoteMiniAppFiles(http, workspaceKey, appCode) {
7106
7105
  const prefix = miniRemotePrefix(appCode) + "/";
7107
- const list = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
7106
+ const list2 = await listWorkspaceFiles(http, workspaceKey, { pageSize: 5e3 });
7108
7107
  const result = [];
7109
- for (const item of list.data) {
7108
+ for (const item of list2.data) {
7110
7109
  if (!item.relativePath.startsWith(prefix) || isDirectoryMarkerPath(item.relativePath)) continue;
7111
7110
  const content = await loadWorkspaceFileContent(http, item.id);
7112
7111
  result.push({ item, content });
@@ -7415,44 +7414,367 @@ function nonnegativeInteger(value) {
7415
7414
  // src/datapackage/pack.ts
7416
7415
  import * as fsp2 from "fs/promises";
7417
7416
  import * as fs11 from "fs";
7418
- import * as path7 from "path";
7419
- import yaml8, { JSON_SCHEMA as JSON_SCHEMA2 } from "js-yaml";
7417
+ import * as path8 from "path";
7420
7418
  import * as yazl from "yazl";
7421
- function fail(message) {
7422
- throw new CliError({ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */, message: `datapackage pack: ${message}` });
7419
+
7420
+ // src/datapackage/manifest.ts
7421
+ import * as path7 from "path";
7422
+ import { stringify } from "yaml";
7423
+
7424
+ // src/datapackage/validation.ts
7425
+ import { parseDocument, LineCounter } from "yaml";
7426
+ var PackageErrorCode = {
7427
+ VALIDATION_ERROR: "VALIDATION_ERROR",
7428
+ FILE_MISSING: "DATA_PACKAGE_FILE_MISSING",
7429
+ PATH_TRAVERSAL: "DATA_PACKAGE_PATH_TRAVERSAL",
7430
+ SECTIONS_CONFLICT: "PACKAGE_EXTENSION_SECTIONS_CONFLICT",
7431
+ MANIFEST_INVALID: "PACKAGE_EXTENSION_MANIFEST_INVALID",
7432
+ FILE_TYPE_UNSUPPORTED: "PACKAGE_EXTENSION_FILE_TYPE_UNSUPPORTED",
7433
+ SIZE_EXCEEDED: "PACKAGE_EXTENSION_SIZE_EXCEEDED",
7434
+ BARE_UUID: "PACKAGE_BARE_UUID",
7435
+ OPAQUE_FIELD_IS_REFERENCE: "PACKAGE_OPAQUE_FIELD_IS_REFERENCE",
7436
+ MODEL_MISMATCH: "PACKAGE_MODEL_MISMATCH",
7437
+ DEFINITION_ID_PRESENT: "PACKAGE_EXTENSION_DEFINITION_ID_PRESENT",
7438
+ REFERENCE_SCAN_FAILED: "PACKAGE_REFERENCE_SCAN_FAILED"
7439
+ };
7440
+ function fail(message, code) {
7441
+ throw new CliError({
7442
+ code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
7443
+ message: `\u5B89\u88C5\u5305 pack: ${code ? `${code}: ` : ""}${message}`,
7444
+ context: code ? { packageErrorCode: code } : void 0
7445
+ });
7423
7446
  }
7424
- function parseManifest(text3, manifestPath) {
7425
- let parsed;
7447
+ function parseYaml(text3, file, onWarning, code) {
7448
+ const lines = new LineCounter();
7449
+ const doc = parseDocument(text3, { lineCounter: lines, merge: true, keepSourceTokens: true });
7450
+ doc.errors = doc.errors.filter((error) => {
7451
+ if (error.code !== "DUPLICATE_KEY") return true;
7452
+ onWarning?.(`${file}:${error.linePos?.[0]?.line ?? 1} YAML_DUPLICATE_KEY: ${error.message.split("\n")[0]}\uFF08\u91C7\u7528\u6700\u540E\u4E00\u4E2A\u503C\uFF09`);
7453
+ return false;
7454
+ });
7455
+ const errors = [...doc.errors, ...doc.warnings];
7456
+ if (errors.length) fail(`${file}: ${errors.map((e) => e.message).join("\n")}`, code);
7457
+ return { doc, lines };
7458
+ }
7459
+ function mapping(value, label, code) {
7460
+ if (!value || typeof value !== "object" || Array.isArray(value)) fail(`${label} \u5FC5\u987B\u662F mapping`, code);
7461
+ return value;
7462
+ }
7463
+ function list(value, label, code) {
7464
+ if (value === void 0) return [];
7465
+ if (!Array.isArray(value)) fail(`${label} \u5FC5\u987B\u662F list`, code);
7466
+ return value;
7467
+ }
7468
+ function safePath(value, code = PackageErrorCode.MANIFEST_INVALID) {
7469
+ if (typeof value === "string") value = value.trim();
7470
+ if (typeof value !== "string" || !value || value.includes("\\") || value.includes("\0") || value.startsWith("/") || /^[A-Za-z]:/.test(value) || value.replace(/\/$/, "").split("/").some((p) => !p || p === "." || p === "..")) {
7471
+ fail(`\u4E0D\u5B89\u5168\u7684\u76F8\u5BF9\u8DEF\u5F84: ${String(value)}`, code);
7472
+ }
7473
+ return value;
7474
+ }
7475
+ function assetPath(value, directory = false) {
7476
+ const p = safePath(value);
7477
+ const parts = p.replace(/\/$/, "").split("/");
7478
+ const kind = parts[0] ?? "";
7479
+ const suffixes = {
7480
+ metas: [".yml", ".yaml", ".properties"],
7481
+ scripts: [".js"],
7482
+ menus: [".yml", ".yaml"],
7483
+ mini_apps: [".js", ".json", ".html", ".css"]
7484
+ };
7485
+ const allowed = suffixes[kind];
7486
+ if (!allowed || !directory && ((kind === "scripts" || kind === "menus") && parts.length !== 2) || !directory && kind === "scripts" && p.endsWith(".js") && !parts[1]?.slice(0, -3).trim() || kind === "mini_apps" && parts.length < (directory ? 2 : 3) || directory && (kind === "scripts" || kind === "menus") && parts.length !== 1) {
7487
+ fail(`\u4E0D\u5728\u6269\u5C55\u8D44\u4EA7\u8FD0\u884C\u65F6\u6587\u672C\u767D\u540D\u5355: ${p}\uFF08\u5141\u8BB8 metas/\u3001scripts/\u3001menus/\u3001mini_apps/ \u4E0B\u7684\u8FD0\u884C\u65F6\u6587\u672C\uFF1Bapps/ \u4E0D\u8FDB\u5B89\u88C5\u5305\uFF09`, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7488
+ }
7489
+ if (!directory && !allowed.some((ext) => p.endsWith(ext))) {
7490
+ fail(`${p}\uFF1B\u56FE\u7247/\u5B57\u4F53\u8BF7\u5185\u8054\u4E3A data URI \u6216\u8D70\u770B\u677F/\u6587\u6863\u80FD\u529B`, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7491
+ }
7492
+ return p;
7493
+ }
7494
+ function utf8(bytes2, file) {
7495
+ const text3 = decodeUtf8(bytes2);
7496
+ if (text3 === void 0 || text3.includes("\0")) {
7497
+ return fail(
7498
+ `${file} \u4E0D\u662F UTF-8 \u6587\u672C\u6216\u542B NUL\uFF1B\u56FE\u7247/\u5B57\u4F53\u8BF7\u5185\u8054\u4E3A data URI \u6216\u8D70\u770B\u677F/\u6587\u6863\u80FD\u529B`,
7499
+ PackageErrorCode.FILE_TYPE_UNSUPPORTED
7500
+ );
7501
+ }
7502
+ return text3;
7503
+ }
7504
+ function decodeUtf8(bytes2) {
7426
7505
  try {
7427
- parsed = yaml8.load(text3, { schema: JSON_SCHEMA2 });
7428
- } catch (e) {
7429
- return fail(`package.yml \u89E3\u6790\u5931\u8D25: ${e.message} (${manifestPath})`);
7506
+ return new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(bytes2);
7507
+ } catch {
7508
+ return void 0;
7430
7509
  }
7431
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
7432
- return fail(`package.yml \u4E3A\u7A7A\u6216\u4E0D\u662F mapping (${manifestPath})`);
7510
+ }
7511
+
7512
+ // src/datapackage/manifest.ts
7513
+ function parseManifest(text3, onWarning) {
7514
+ const { VALIDATION_ERROR, MANIFEST_INVALID } = PackageErrorCode;
7515
+ const doc = mapping(parseYaml(text3, "package.yml", onWarning, VALIDATION_ERROR).doc.toJS(), "package.yml", VALIDATION_ERROR);
7516
+ let trimmed = false;
7517
+ const trimPaths = (entry) => {
7518
+ for (const key of ["file", "dir", "path"]) {
7519
+ const value = entry[key];
7520
+ if (typeof value === "string" && value !== value.trim()) {
7521
+ entry[key] = value.trim();
7522
+ trimmed = true;
7523
+ }
7524
+ }
7525
+ };
7526
+ const dropFields = (entry) => {
7527
+ if (entry.drop_fields !== void 0 && (!Array.isArray(entry.drop_fields) || entry.drop_fields.some((f) => typeof f !== "string" || !f.trim()))) fail("drop_fields \u5FC5\u987B\u662F\u5B57\u6BB5\u540D list", MANIFEST_INVALID);
7528
+ };
7529
+ if (typeof doc.name !== "string" || !doc.name.trim()) fail("package.yml \u7F3A name", VALIDATION_ERROR);
7530
+ if (typeof doc.version !== "string" || !doc.version.trim()) fail("package.yml \u7F3A version", VALIDATION_ERROR);
7531
+ if ((doc.metas !== void 0 || doc.metas_delete !== void 0) && (doc.extensions !== void 0 || doc.extensions_delete !== void 0)) {
7532
+ fail("metas/metas_delete \u4E0E extensions/extensions_delete \u4E0D\u80FD\u540C\u65F6\u51FA\u73B0", PackageErrorCode.SECTIONS_CONFLICT);
7533
+ }
7534
+ const models = /* @__PURE__ */ new Map();
7535
+ for (const [i, value] of list(doc.models, "models", VALIDATION_ERROR).entries()) {
7536
+ const m = mapping(value, `models[${i}]`, VALIDATION_ERROR);
7537
+ trimPaths(m);
7538
+ if (typeof m.name !== "string" || !m.name.trim()) fail(`models[${i}] \u7F3A name`, VALIDATION_ERROR);
7539
+ if (typeof m.file !== "string" || !m.file.trim()) fail(`models[${i}] \u7F3A file`, VALIDATION_ERROR);
7540
+ if (!Array.isArray(m.keys) || !m.keys.length) fail(`models[${i}] \u7F3A keys`, VALIDATION_ERROR);
7541
+ models.set(safePath(m.file, PackageErrorCode.PATH_TRAVERSAL), m.name);
7542
+ }
7543
+ const legacy = doc.metas !== void 0 || doc.metas_delete !== void 0;
7544
+ const extensions = list(doc.extensions ?? doc.metas, legacy ? "metas" : "extensions", MANIFEST_INVALID).map((value, i) => {
7545
+ const e = mapping(value, `extensions[${i}]`, MANIFEST_INVALID);
7546
+ trimPaths(e);
7547
+ if (e.file === void 0 === (e.dir === void 0)) fail(`extensions[${i}] \u5FC5\u987B\u4E14\u53EA\u80FD\u6709 file \u6216 dir`, MANIFEST_INVALID);
7548
+ if (e.adopt !== void 0 && typeof e.adopt !== "boolean") fail(`extensions[${i}].adopt \u5FC5\u987B\u662F boolean`, VALIDATION_ERROR);
7549
+ const source = safePath(e.file ?? e.dir).replace(/\/$/, "");
7550
+ const directory = e.dir !== void 0;
7551
+ const stripped = source.startsWith("extensions/") ? source.slice(11) : void 0;
7552
+ const declared = typeof e.path === "string" && e.path.trim() ? e.path : void 0;
7553
+ const target = assetPath(declared ?? (!legacy && e.path == null ? stripped ?? source : stripped ?? `metas/${path7.posix.basename(source)}`), directory).replace(/\/$/, "");
7554
+ dropFields(e);
7555
+ return { source, target, directory };
7556
+ });
7557
+ const targets = /* @__PURE__ */ new Set();
7558
+ for (const entry of extensions) {
7559
+ if (targets.has(entry.target)) fail(`\u6269\u5C55\u76EE\u6807\u8DEF\u5F84\u91CD\u590D: ${entry.target}`, MANIFEST_INVALID);
7560
+ targets.add(entry.target);
7561
+ if (extensions.some((other) => other !== entry && other.directory && entry.target.startsWith(other.target + "/"))) {
7562
+ fail(`\u6269\u5C55\u76EE\u5F55\u4E0E\u6761\u76EE\u91CD\u53E0: ${entry.target}`, MANIFEST_INVALID);
7563
+ }
7564
+ }
7565
+ const deletes = list(doc.extensions_delete ?? doc.metas_delete, "extensions_delete", MANIFEST_INVALID).map((value, i) => {
7566
+ if (typeof value === "string") {
7567
+ const values = doc.extensions_delete ?? doc.metas_delete;
7568
+ values[i] = value = { path: value };
7569
+ }
7570
+ const e = mapping(value, `extensions_delete[${i}]`, MANIFEST_INVALID);
7571
+ trimPaths(e);
7572
+ if (typeof e.path !== "string" || !e.path) fail(`extensions_delete[${i}].path \u5FC5\u586B`, MANIFEST_INVALID);
7573
+ const p = assetPath(e.path, typeof e.path === "string" && e.path.endsWith("/"));
7574
+ const plain = p.replace(/\/$/, "");
7575
+ if (extensions.some((e2) => plain === e2.target || p.endsWith("/") && e2.target.startsWith(p) || e2.directory && plain.startsWith(e2.target + "/"))) fail(`\u540C\u4E00\u6587\u4EF6\u4E0D\u80FD\u65E2\u5199\u53C8\u5220\uFF0C\u76EE\u6807\u91CD\u53E0: ${p}`, MANIFEST_INVALID);
7576
+ dropFields(e);
7577
+ return p;
7578
+ });
7579
+ if (!models.size && !extensions.length && !deletes.length) fail("models \u4E0E extensions\uFF08\u542B\u5220\u9664\u6761\u76EE\uFF09\u4E0D\u80FD\u540C\u65F6\u4E3A\u7A7A", VALIDATION_ERROR);
7580
+ const opaqueFields = /* @__PURE__ */ new Set();
7581
+ const { OPAQUE_FIELD_IS_REFERENCE } = PackageErrorCode;
7582
+ for (const field of list(doc.opaque_uuid_fields, "opaque_uuid_fields", OPAQUE_FIELD_IS_REFERENCE)) {
7583
+ if (typeof field !== "string" || !/^[A-Za-z_][A-Za-z0-9_]*\.[A-Za-z_][A-Za-z0-9_]*$/.test(field)) {
7584
+ fail(`opaque_uuid_fields \u5FC5\u987B\u4F7F\u7528 \u6A21\u578B.\u5B57\u6BB5\uFF08\u5B57\u6BCD\u6570\u5B57\u4E0B\u5212\u7EBF\uFF09: ${String(field)}`, OPAQUE_FIELD_IS_REFERENCE);
7585
+ }
7586
+ if (/(?:_id|Id)$/.test(field)) fail(`${field} \u662F\u5F15\u7528\u7C7B\u5B57\u6BB5\uFF0C\u4E0D\u80FD\u58F0\u660E\u4E3A opaque_uuid_fields`, OPAQUE_FIELD_IS_REFERENCE);
7587
+ opaqueFields.add(field);
7433
7588
  }
7434
- const doc = parsed;
7435
- if (typeof doc.name !== "string" || !doc.name.trim()) return fail("package.yml \u7F3A name");
7436
- if (typeof doc.version !== "string" || !doc.version.trim()) return fail("package.yml \u7F3A version");
7437
- if (!Array.isArray(doc.models) || doc.models.length === 0) return fail("package.yml \u7F3A models \u5217\u8868");
7438
- const referenced = [];
7439
- for (const [i, m] of doc.models.entries()) {
7440
- const entry = m;
7441
- if (typeof entry.name !== "string" || !entry.name) return fail(`models[${i}] \u7F3A name`);
7442
- if (typeof entry.file !== "string" || !entry.file) return fail(`models[${i}] \u7F3A file`);
7443
- if (!Array.isArray(entry.keys) || entry.keys.length === 0) return fail(`models[${i}] \u7F3A keys`);
7444
- referenced.push(entry.file);
7445
- }
7446
- if (doc.metas !== void 0) {
7447
- if (!Array.isArray(doc.metas)) return fail("metas \u5FC5\u987B\u662F list");
7448
- for (const [i, m] of doc.metas.entries()) {
7449
- const entry = m;
7450
- if (typeof entry.file !== "string" || !entry.file) return fail(`metas[${i}] \u7F3A file`);
7451
- referenced.push(entry.file);
7452
- }
7453
- }
7454
- return { name: doc.name.trim(), version: doc.version.trim(), referenced };
7589
+ return {
7590
+ name: doc.name.trim(),
7591
+ version: doc.version.trim(),
7592
+ models,
7593
+ extensions,
7594
+ deletes,
7595
+ opaqueFields,
7596
+ artifactText: trimmed ? stringify(doc) : text3
7597
+ };
7455
7598
  }
7599
+
7600
+ // src/datapackage/uuid.ts
7601
+ import { isAlias, isMap, isNode, isScalar, isSeq, Parser } from "yaml";
7602
+ var UUID2 = /[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}/gi;
7603
+ var isUuid = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
7604
+ function validateUuids(files, opaqueFields, onWarning) {
7605
+ const parsed = files.map((file) => ({
7606
+ ...file,
7607
+ yaml: !file.extension && (file.model || /\.ya?ml$|\.json$/.test(file.file)) ? parseYaml(file.text, file.file, onWarning) : void 0
7608
+ }));
7609
+ const ownIds = /* @__PURE__ */ new Set();
7610
+ for (const file of parsed) {
7611
+ if (file.model === void 0 && !/^data\/.*\.ya?ml$/.test(file.file)) continue;
7612
+ const data = file.yaml?.doc.toJS();
7613
+ if (data && Array.isArray(data.items)) {
7614
+ for (const row of data.items) if (isUuid(row?.id)) ownIds.add(row.id.toLowerCase());
7615
+ }
7616
+ }
7617
+ for (const file of parsed) {
7618
+ if (file.model === void 0 || !file.yaml) continue;
7619
+ const node = file.yaml.doc.get("model", true);
7620
+ const authored = isScalar(node) ? String(node.source ?? node.value ?? "") : "";
7621
+ if (authored && authored !== file.model) {
7622
+ fail(
7623
+ `${file.file}:1 ${file.model}\uFF1B\u6587\u4EF6 model=${authored} \u4E0E\u6E05\u5355\u76EE\u6807\u6A21\u578B\u4E0D\u4E00\u81F4\uFF1B\u5C06\u6587\u4EF6 model \u4E0E manifest models[].name \u5BF9\u9F50\u540E\u91CD\u65B0\u6253\u5305`,
7624
+ PackageErrorCode.MODEL_MISMATCH
7625
+ );
7626
+ }
7627
+ }
7628
+ const violations = [];
7629
+ for (const file of parsed) {
7630
+ const comments = commentRanges(file);
7631
+ const modelNode = file.yaml?.doc.get("model");
7632
+ const model = file.model ?? (typeof modelNode === "string" ? modelNode : "?");
7633
+ const spans = [];
7634
+ const decoded = [];
7635
+ const collect = (node, field, visited = /* @__PURE__ */ new Set(), aliasOffset) => {
7636
+ if (!isNode(node) || visited.has(node)) return;
7637
+ const next = new Set(visited).add(node);
7638
+ const offset = aliasOffset ?? node.range?.[0] ?? 0;
7639
+ if (isScalar(node)) {
7640
+ if (typeof node.value === "string") decoded.push({ value: node.value, offset, field });
7641
+ } else if (isAlias(node) && file.yaml) {
7642
+ collect(node.resolve(file.yaml.doc), field, next, offset);
7643
+ } else if (isMap(node)) {
7644
+ node.items.forEach((pair) => {
7645
+ collect(pair.key, field, next, aliasOffset);
7646
+ collect(pair.value, field, next, aliasOffset);
7647
+ });
7648
+ } else if (isSeq(node)) node.items.forEach((child) => collect(child, field, next, aliasOffset));
7649
+ };
7650
+ const items = file.yaml?.doc.get("items", true);
7651
+ if (isSeq(items)) {
7652
+ for (const item of items.items) {
7653
+ if (!isMap(item)) {
7654
+ collect(item, `${model}.?`);
7655
+ continue;
7656
+ }
7657
+ for (const pair of item.items) {
7658
+ const field = `${model}.${isScalar(pair.key) ? String(pair.key.value) : "?"}`;
7659
+ if (isNode(pair.key) && pair.key.range && isNode(pair.value) && pair.value.range) {
7660
+ spans.push({ start: pair.key.range[0], end: pair.value.range[1], field });
7661
+ }
7662
+ collect(pair.value, field);
7663
+ }
7664
+ }
7665
+ }
7666
+ const seen = /* @__PURE__ */ new Set();
7667
+ const report = (uuid, offset, field) => {
7668
+ if (!file.extension && (ownIds.has(uuid.toLowerCase()) || opaqueFields.has(field))) return;
7669
+ const line = file.text.slice(0, offset).split("\n").length;
7670
+ const key = `${offset}:${field}:${uuid}`;
7671
+ if (seen.has(key)) return;
7672
+ seen.add(key);
7673
+ const advice = file.extension ? "\u6269\u5C55\u8D44\u4EA7\u4E0D\u66FF\u6362\u5F15\u7528\uFF0C\u8BF7\u6539\u4E3A\u6309\u7F16\u7801\u53D6\u6570" : "\u8BF7\u6539\u4E3A ${Model:key} \u6216 ${ref:Model:key}";
7674
+ const comment = comments.some(([start, end]) => offset >= start && offset < end) ? "\uFF08\u6CE8\u91CA\uFF09" : "";
7675
+ violations.push(`${file.file}:${line} ${field}${comment}: ${uuid}\uFF1B${advice}`);
7676
+ };
7677
+ for (const match of file.text.matchAll(UUID2)) {
7678
+ const field = file.extension ? "\u6269\u5C55\u8D44\u4EA7.\u6587\u672C" : spans.find((s) => match.index >= s.start && match.index < s.end)?.field ?? `${model}.?`;
7679
+ report(match[0], match.index, field);
7680
+ }
7681
+ for (const value of decoded) {
7682
+ for (const match of value.value.matchAll(UUID2)) {
7683
+ const span = spans.find((s) => value.offset >= s.start && value.offset < s.end);
7684
+ if (span && [...file.text.slice(value.offset, span.end).matchAll(UUID2)].some((raw) => raw[0] === match[0])) continue;
7685
+ report(match[0], value.offset, value.field);
7686
+ }
7687
+ }
7688
+ }
7689
+ if (violations.length) fail(`${violations.length} \u5904\u88F8 UUID \u8FDD\u89C4
7690
+ ${violations.join("\n")}`, PackageErrorCode.BARE_UUID);
7691
+ }
7692
+ function commentRanges(file) {
7693
+ const ranges = [];
7694
+ if (file.model || /\.ya?ml$/.test(file.file)) {
7695
+ const visit = (value) => {
7696
+ if (!value || typeof value !== "object") return;
7697
+ const token = value;
7698
+ if (token.type === "comment" && token.offset !== void 0 && token.source) ranges.push([token.offset, token.offset + token.source.length]);
7699
+ else Object.values(value).forEach(visit);
7700
+ };
7701
+ for (const token of new Parser().parse(file.text)) visit(token);
7702
+ } else {
7703
+ const pattern = /\.properties$/.test(file.file) ? /^[ \t]*[#!].*$/gm : /\.html$/.test(file.file) ? /<!--[\s\S]*?-->/g : /\.(js|css)$/.test(file.file) ? /"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^`\\])*`|(\/\/[^\r\n]*|\/\*[\s\S]*?\*\/)/g : void 0;
7704
+ if (pattern) for (const match of file.text.matchAll(pattern)) {
7705
+ if (!/\.(js|css)$/.test(file.file) || match[1]) ranges.push([match.index, match.index + match[0].length]);
7706
+ }
7707
+ }
7708
+ return ranges;
7709
+ }
7710
+ function definitionIdLine(text3, file, onWarning) {
7711
+ const { doc, lines } = parseYaml(text3, file, onWarning);
7712
+ const fields = doc.get("fields", true);
7713
+ if (!isSeq(fields)) return void 0;
7714
+ for (const field of fields.items) {
7715
+ if (!isMap(field)) continue;
7716
+ const pair = field.items.find((p) => isScalar(p.key) && p.key.value === "definitionId");
7717
+ if (pair) return lines.linePos(isNode(pair.key) ? pair.key.range?.[0] ?? 0 : 0).line;
7718
+ }
7719
+ return void 0;
7720
+ }
7721
+ function stripDefinitionIds(text3, file, onWarning) {
7722
+ const { doc } = parseYaml(text3, file, onWarning);
7723
+ const fields = doc.get("fields", true);
7724
+ let count = 0;
7725
+ const ranges = [];
7726
+ if (isSeq(fields)) {
7727
+ for (const field of fields.items) {
7728
+ if (!isMap(field)) continue;
7729
+ const removable = field.items.map((pair) => isScalar(pair.key) && pair.key.value === "definitionId");
7730
+ for (let i = 0; i < field.items.length; i++) {
7731
+ if (!removable[i]) continue;
7732
+ const first = field.items[i];
7733
+ let last = first;
7734
+ const keyStart = isNode(first.key) ? first.key.range?.[0] : void 0;
7735
+ if (keyStart === void 0) continue;
7736
+ count++;
7737
+ if (field.flow) {
7738
+ while (removable[i + 1]) {
7739
+ last = field.items[++i];
7740
+ count++;
7741
+ }
7742
+ const next = field.items[i + 1];
7743
+ const comma = first.srcToken?.start.find((token) => token.type === "comma");
7744
+ const valueEnd = isNode(last.value) ? last.value.range?.[1] : void 0;
7745
+ const end = valueEnd ?? last.srcToken?.sep?.reduce((end2, token) => token.offset + token.source.length, keyStart) ?? keyStart;
7746
+ if (comma) ranges.push([comma.offset, end]);
7747
+ else {
7748
+ ranges.push([keyStart, end]);
7749
+ const separator = next?.srcToken?.start ?? (field.srcToken?.type === "flow-collection" ? field.srcToken.items.at(-1)?.start : void 0);
7750
+ const commaIndex = separator?.findIndex((token) => token.type === "comma" && token.offset >= end) ?? -1;
7751
+ if (separator && commaIndex >= 0) {
7752
+ const comma2 = separator[commaIndex];
7753
+ let end2 = comma2.offset + comma2.source.length;
7754
+ for (let i2 = commaIndex + 1; separator[i2]?.type === "space"; i2++) end2 += separator[i2].source.length;
7755
+ ranges.push([comma2.offset, end2]);
7756
+ }
7757
+ }
7758
+ } else {
7759
+ const lineStart = text3.lastIndexOf("\n", keyStart - 1) + 1;
7760
+ const valueEnd = isNode(last.value) ? last.value.range?.[2] : void 0;
7761
+ const newline = text3.indexOf("\n", valueEnd ?? keyStart);
7762
+ const end = valueEnd && text3[valueEnd - 1] === "\n" ? valueEnd : newline < 0 ? text3.length : newline + 1;
7763
+ const dash = text3.slice(lineStart, keyStart).indexOf("-");
7764
+ ranges.push(dash < 0 ? [lineStart, end] : [lineStart + dash + 1, end - (text3[end - 2] === "\r" ? 2 : text3[end - 1] === "\n" ? 1 : 0)]);
7765
+ }
7766
+ }
7767
+ }
7768
+ }
7769
+ let stripped = text3, scanText = text3;
7770
+ for (const [start, end] of ranges.sort((a, b) => b[0] - a[0])) {
7771
+ stripped = stripped.slice(0, start) + stripped.slice(end);
7772
+ scanText = scanText.slice(0, start) + scanText.slice(start, end).replace(/[^\n\r]/g, " ") + scanText.slice(end);
7773
+ }
7774
+ return { text: stripped, scanText, count };
7775
+ }
7776
+
7777
+ // src/datapackage/pack.ts
7456
7778
  async function collectFiles(root, skipAbs) {
7457
7779
  const out = [];
7458
7780
  async function walk4(dir, rel) {
@@ -7460,44 +7782,130 @@ async function collectFiles(root, skipAbs) {
7460
7782
  entries.sort((a, b) => a.name.localeCompare(b.name));
7461
7783
  for (const e of entries) {
7462
7784
  if (e.name.startsWith(".")) continue;
7463
- const abs = path7.join(dir, e.name);
7785
+ const abs = path8.join(dir, e.name);
7464
7786
  const relPath = rel ? `${rel}/${e.name}` : e.name;
7465
- if (e.isDirectory()) {
7466
- await walk4(abs, relPath);
7467
- } else if (e.isFile() && !skipAbs.has(path7.resolve(abs))) {
7468
- out.push(relPath);
7469
- }
7787
+ if (e.isSymbolicLink()) fail(`\u5B89\u88C5\u5305\u4E0D\u6536\u5F55\u7B26\u53F7\u94FE\u63A5: ${relPath}`, PackageErrorCode.PATH_TRAVERSAL);
7788
+ if (e.isDirectory()) await walk4(abs, relPath);
7789
+ else if (e.isFile() && !skipAbs.has(path8.resolve(abs))) out.push(relPath);
7470
7790
  }
7471
7791
  }
7472
7792
  await walk4(root, "");
7473
7793
  return out;
7474
7794
  }
7475
7795
  async function packDataPackage(packageDir, outPath, opts = {}) {
7476
- const root = path7.resolve(packageDir);
7477
- const manifestPath = path7.join(root, "package.yml");
7796
+ const root = path8.resolve(packageDir);
7478
7797
  let manifestText;
7479
7798
  try {
7480
- manifestText = await fsp2.readFile(manifestPath, "utf8");
7799
+ manifestText = await fsp2.readFile(path8.join(root, "package.yml"), "utf8");
7481
7800
  } catch {
7482
- return fail(`\u76EE\u5F55\u91CC\u6CA1\u6709 package.yml\uFF1A${root}\uFF08\u8981\u4F20\u5305\u7248\u672C\u76EE\u5F55\uFF0C\u5982 fixtures/scenario/<pkg>/v1.0.0\uFF09`);
7483
- }
7484
- const { name, version, referenced } = parseManifest(manifestText, manifestPath);
7485
- for (const relFile of referenced) {
7486
- const abs = path7.resolve(root, relFile);
7487
- if (!abs.startsWith(root + path7.sep)) return fail(`\u5F15\u7528\u8DEF\u5F84\u8D8A\u51FA\u5305\u76EE\u5F55: ${relFile}`);
7488
- if (!fs11.existsSync(abs) || !fs11.statSync(abs).isFile()) {
7489
- return fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728: ${relFile}`);
7490
- }
7801
+ return fail(`\u76EE\u5F55\u91CC\u6CA1\u6709 package.yml\uFF1A${root}\uFF08\u8981\u4F20\u5305\u7248\u672C\u76EE\u5F55\uFF0C\u5982 fixtures/scenario/<pkg>/v1.0.0\uFF09`, PackageErrorCode.FILE_MISSING);
7491
7802
  }
7803
+ const warnings = [];
7804
+ const onWarning = (message) => {
7805
+ warnings.push(message);
7806
+ opts.onWarning?.(message);
7807
+ };
7808
+ const manifest2 = parseManifest(manifestText, onWarning);
7809
+ const { name, version } = manifest2;
7492
7810
  const lastSegment = name.includes("/") ? name.slice(name.lastIndexOf("/") + 1) : name;
7493
- const artifactPath = path7.resolve(outPath ?? `${lastSegment}-${version}.hcmpkg`);
7811
+ const artifactPath = path8.resolve(outPath ?? `${lastSegment}-${version}.hcmpkg`);
7812
+ const outputRel = path8.relative(root, artifactPath).split(path8.sep).join("/");
7813
+ if (outputRel === "package.yml" || /^(data|extensions)\//.test(outputRel) || manifest2.models.has(outputRel) || manifest2.extensions.some((e) => outputRel === e.source || e.directory && outputRel.startsWith(e.source + "/"))) {
7814
+ fail("\u4EA7\u7269\u8DEF\u5F84\u4E0D\u80FD\u8986\u76D6\u5B89\u88C5\u5305\u4F5C\u8005\u6587\u4EF6\u6216\u4F4D\u4E8E\u6570\u636E\u3001\u6269\u5C55\u6765\u6E90\u76EE\u5F55\u5185");
7815
+ }
7494
7816
  const files = await collectFiles(root, /* @__PURE__ */ new Set([artifactPath]));
7495
- if (!files.includes("package.yml")) return fail("\u6536\u96C6\u4E0D\u5230 package.yml\uFF08\u4E0D\u5E94\u53D1\u751F\uFF09");
7496
- await fsp2.mkdir(path7.dirname(artifactPath), { recursive: true });
7817
+ if (!files.includes("package.yml")) fail("\u6536\u96C6\u4E0D\u5230 package.yml\uFF1B\u4EA7\u7269\u8DEF\u5F84\u4E0D\u80FD\u8986\u76D6\u4F5C\u8005\u6587\u4EF6");
7818
+ for (const file of manifest2.models.keys()) {
7819
+ if (!files.includes(file)) fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u672A\u6536\u5F55: ${file}`, PackageErrorCode.FILE_MISSING);
7820
+ }
7821
+ const targets = /* @__PURE__ */ new Map();
7822
+ const sources = /* @__PURE__ */ new Map();
7823
+ for (const entry of manifest2.extensions) {
7824
+ const selected = entry.directory ? files.filter((f) => f.startsWith(entry.source + "/")) : [entry.source];
7825
+ if (entry.directory) {
7826
+ const stat2 = await fsp2.stat(path8.join(root, entry.source)).catch(() => void 0);
7827
+ if (!stat2?.isDirectory()) fail(`manifest \u5F15\u7528\u7684\u76EE\u5F55\u4E0D\u5B58\u5728: ${entry.source}`, PackageErrorCode.MANIFEST_INVALID);
7828
+ if (!selected.length) fail(`\u6269\u5C55\u76EE\u5F55\u6CA1\u6709\u6587\u4EF6: ${entry.source}\uFF1B\u786E\u5B9E\u8981\u5220\u8BF7\u7528 extensions_delete`, PackageErrorCode.MANIFEST_INVALID);
7829
+ }
7830
+ for (const file of selected) {
7831
+ if (!files.includes(file)) fail(`manifest \u5F15\u7528\u7684\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u672A\u6536\u5F55: ${file}`, PackageErrorCode.FILE_MISSING);
7832
+ const target = assetPath(entry.directory ? entry.target + file.slice(entry.source.length) : entry.target);
7833
+ if (!/\.(yml|yaml|properties|js|json|html|css)$/.test(file)) fail(file, PackageErrorCode.FILE_TYPE_UNSUPPORTED);
7834
+ if (targets.has(target)) fail(`\u6269\u5C55\u76EE\u6807\u8DEF\u5F84\u91CD\u590D: ${target}`, PackageErrorCode.MANIFEST_INVALID);
7835
+ if (sources.has(file)) fail(`\u6269\u5C55\u6765\u6E90\u91CD\u590D: ${file}`);
7836
+ if (manifest2.models.has(file)) fail(`\u6587\u4EF6\u4E0D\u80FD\u540C\u65F6\u4F5C\u4E3A\u6A21\u578B\u6570\u636E\u548C\u6269\u5C55\u8D44\u4EA7: ${file}`);
7837
+ targets.set(target, file);
7838
+ sources.set(file, target);
7839
+ }
7840
+ }
7841
+ const seenDeletes = /* @__PURE__ */ new Set();
7842
+ for (const deletion of manifest2.deletes) {
7843
+ if (seenDeletes.has(deletion)) fail(`extensions_delete \u8DEF\u5F84\u91CD\u590D: ${deletion}`, PackageErrorCode.MANIFEST_INVALID);
7844
+ seenDeletes.add(deletion);
7845
+ if ([...targets.keys()].some((t) => t === deletion || deletion.endsWith("/") && t.startsWith(deletion))) {
7846
+ fail(`extensions_delete \u4E0E\u5199\u5165\u76EE\u6807\u91CD\u53E0: ${deletion}`, PackageErrorCode.MANIFEST_INVALID);
7847
+ }
7848
+ }
7849
+ const undeclaredExtensionFiles = files.filter((f) => f.startsWith("extensions/") && !sources.has(f) && !manifest2.models.has(f));
7850
+ const skippedBinaryDataFiles = [];
7851
+ const contents = /* @__PURE__ */ new Map([["package.yml", Buffer.from(manifest2.artifactText)]]);
7852
+ const scans = [];
7853
+ let totalBytes = 0, strippedDefinitionIds = 0;
7854
+ for (const [file, target] of sources) {
7855
+ const abs = path8.join(root, file);
7856
+ const size = (await fsp2.stat(abs)).size;
7857
+ totalBytes += size;
7858
+ if (size > 4 * 1024 * 1024) fail(`${file} \u5B9E\u6D4B ${size} \u5B57\u8282\uFF0C\u5355\u6587\u4EF6\u4E0A\u9650 4MB\uFF08fileBytes=${size}, totalBytes=${totalBytes}\uFF09`, PackageErrorCode.SIZE_EXCEEDED);
7859
+ if (totalBytes > 32 * 1024 * 1024) fail(`\u6269\u5C55\u603B\u91CF\u5B9E\u6D4B ${totalBytes} \u5B57\u8282\uFF0C\u4E0A\u9650 32MB\uFF08fileBytes=${size}, totalBytes=${totalBytes}\uFF09`, PackageErrorCode.SIZE_EXCEEDED);
7860
+ const text3 = utf8(await fsp2.readFile(abs), file);
7861
+ const stripped = target.startsWith("metas/") && /\.ya?ml$/.test(target) ? stripDefinitionIds(text3, file, onWarning) : { text: text3, scanText: text3, count: 0 };
7862
+ strippedDefinitionIds += stripped.count;
7863
+ contents.set(file, Buffer.from(stripped.text));
7864
+ scans.push({ file, text: stripped.scanText, extension: true });
7865
+ }
7866
+ for (const file of undeclaredExtensionFiles) {
7867
+ const text3 = decodeUtf8(await fsp2.readFile(path8.join(root, file)));
7868
+ if (text3 === void 0) {
7869
+ fail(
7870
+ `${file} \u4E0D\u662F UTF-8 \u6587\u672C\uFF08\u672A\u5728 manifest \u58F0\u660E\uFF0C\u4F46\u670D\u52A1\u7AEF\u4ECD\u4F1A\u626B\u63CF extensions/ \u4E0B\u5168\u90E8\u6587\u4EF6\uFF09\uFF1B\u4ECE extensions/ \u79FB\u8D70\u6216\u5220\u9664\u540E\u91CD\u65B0\u6253\u5305`,
7871
+ PackageErrorCode.REFERENCE_SCAN_FAILED
7872
+ );
7873
+ }
7874
+ scans.push({ file, text: text3, extension: true });
7875
+ }
7876
+ for (const scan of scans) {
7877
+ if (!scan.extension || !scan.file.startsWith("extensions/") || !scan.file.includes("/metas/") || !/\.ya?ml$/.test(scan.file)) continue;
7878
+ const target = sources.get(scan.file);
7879
+ if (target?.startsWith("metas/") && /\.ya?ml$/.test(target)) continue;
7880
+ const line = definitionIdLine(scan.text, scan.file, onWarning);
7881
+ if (line !== void 0) {
7882
+ fail(
7883
+ `${scan.file}:${line} fields[].definitionId\uFF1B\u6269\u5C55\u5143\u6570\u636E\u643A\u5E26\u6E90\u73AF\u5883\u5B57\u6BB5\u8EAB\u4EFD\uFF1B\u5728 manifest \u58F0\u660E\u4E3A metas/ \u76EE\u6807\u8BA9 pack \u5265\u79BB\uFF0C\u6216\u4ECE\u6E90\u6587\u4EF6\u5220\u9664`,
7884
+ PackageErrorCode.DEFINITION_ID_PRESENT
7885
+ );
7886
+ }
7887
+ }
7888
+ for (const file of files) {
7889
+ if (!sources.has(file) && (file.startsWith("data/") || manifest2.models.has(file))) {
7890
+ const bytes2 = await fsp2.readFile(path8.join(root, file));
7891
+ contents.set(file, bytes2);
7892
+ const text3 = decodeUtf8(bytes2);
7893
+ if (text3 === void 0) {
7894
+ skippedBinaryDataFiles.push(file);
7895
+ continue;
7896
+ }
7897
+ scans.push({ file, text: text3, model: manifest2.models.get(file) });
7898
+ }
7899
+ }
7900
+ validateUuids(scans, manifest2.opaqueFields, onWarning);
7901
+ const uuidScannedFiles = { data: scans.filter((f) => !f.extension).length, extensions: scans.filter((f) => f.extension).length };
7902
+ await fsp2.mkdir(path8.dirname(artifactPath), { recursive: true });
7497
7903
  await new Promise((resolve6, reject2) => {
7498
7904
  const zip = new yazl.ZipFile();
7499
7905
  files.forEach((rel, i) => {
7500
- zip.addFile(path7.join(root, rel), rel);
7906
+ const content = contents.get(rel);
7907
+ if (content) zip.addBuffer(content, rel);
7908
+ else zip.addFile(path8.join(root, rel), rel);
7501
7909
  opts.onFile?.(rel, i + 1, files.length);
7502
7910
  });
7503
7911
  zip.end();
@@ -7507,7 +7915,18 @@ async function packDataPackage(packageDir, outPath, opts = {}) {
7507
7915
  ws.on("error", reject2);
7508
7916
  zip.outputStream.on("error", reject2);
7509
7917
  });
7510
- return { artifactPath, name, version, entryCount: files.length };
7918
+ return {
7919
+ artifactPath,
7920
+ name,
7921
+ version,
7922
+ entryCount: files.length,
7923
+ strippedDefinitionIds,
7924
+ bareUuidCount: 0,
7925
+ uuidScannedFiles,
7926
+ skippedBinaryDataFiles,
7927
+ undeclaredExtensionFiles,
7928
+ warnings
7929
+ };
7511
7930
  }
7512
7931
 
7513
7932
  // src/datapackage/install.ts
@@ -7524,6 +7943,24 @@ function isTerminalRunStatus(status) {
7524
7943
  if (!status) return false;
7525
7944
  return status !== "RUNNING" && status !== "QUEUED" && status !== "MAIN_COMMITTED";
7526
7945
  }
7946
+ function confirmationParams(opts) {
7947
+ return {
7948
+ ...opts.allowDowngrade ? { allowDowngrade: true } : {},
7949
+ ...opts.acceptContentChange ? { acceptContentChange: true } : {}
7950
+ };
7951
+ }
7952
+ var INSTALL_CONFIRMATION_HINTS = [
7953
+ {
7954
+ code: "DATA_PACKAGE_DOWNGRADE_REQUIRES_CONFIRMATION",
7955
+ flag: "--allow-downgrade",
7956
+ nextStep: "\u786E\u8BA4\u964D\u7EA7\u5F71\u54CD\uFF08\u65E7\u7248\u672C\u6570\u636E\u8986\u76D6\u65B0\u7248\u672C\uFF09\u540E\u52A0 --allow-downgrade \u91CD\u8DD1\uFF1B\u5426\u5219\u6539\u88C5\u4E0D\u4F4E\u4E8E\u5DF2\u88C5\u7248\u672C\u7684\u5236\u54C1"
7957
+ },
7958
+ {
7959
+ code: "DATA_PACKAGE_VERSION_DIGEST_CONFLICT",
7960
+ flag: "--accept-content-change",
7961
+ nextStep: "\u9996\u9009\u5347\u7248\u672C\u53F7\u91CD\u65B0 pack \u518D\u88C5\uFF1B\u786E\u8BA4\u540C\u7248\u672C\u8986\u76D6\u5F71\u54CD\u540E\u624D\u52A0 --accept-content-change \u5168\u91CF\u91CD\u88C5"
7962
+ }
7963
+ ];
7527
7964
  async function installDataPackageArtifactAsync(client, artifactPath, opts = {}) {
7528
7965
  const meta = await uploadDocument(
7529
7966
  client.raw(),
@@ -7535,7 +7972,7 @@ async function installDataPackageArtifactAsync(client, artifactPath, opts = {})
7535
7972
  "DataPackage",
7536
7973
  "installFromDocumentAsync",
7537
7974
  {
7538
- params: { documentId: meta.documentId, tenantId: client.tenantId }
7975
+ params: { documentId: meta.documentId, tenantId: client.tenantId, ...confirmationParams(opts) }
7539
7976
  }
7540
7977
  );
7541
7978
  const body = unwrapActionPayload(resp);
@@ -7567,8 +8004,9 @@ async function waitForInstallRun(client, runId, opts) {
7567
8004
  const deadline = now() + opts.timeoutMs;
7568
8005
  let last;
7569
8006
  for (; ; ) {
7570
- last = await fetchInstallRun(client, runId);
7571
- opts.onProgress?.(last);
8007
+ const current = await fetchInstallRun(client, runId);
8008
+ if (current) last = current;
8009
+ opts.onProgress?.(current);
7572
8010
  if (isTerminalRunStatus(last?.status)) {
7573
8011
  return { run: last, timedOut: false };
7574
8012
  }
@@ -7589,7 +8027,7 @@ async function installDataPackageArtifact(client, artifactPath, opts = {}) {
7589
8027
  "DataPackage",
7590
8028
  "installFromDocument",
7591
8029
  {
7592
- params: { documentId: meta.documentId, tenantId: client.tenantId }
8030
+ params: { documentId: meta.documentId, tenantId: client.tenantId, ...confirmationParams(opts) }
7593
8031
  }
7594
8032
  );
7595
8033
  const view = unwrapActionPayload(resp);
@@ -7702,18 +8140,18 @@ async function listTenantMeta(http, opts = {}) {
7702
8140
  const total = typeof body?.total === "number" ? body.total : payload?.total;
7703
8141
  return { items, total, raw: payload };
7704
8142
  }
7705
- async function getTenantMeta(http, path24) {
7706
- const resp = await http.get("/api/tenant-meta/meta", { params: { path: path24 } });
8143
+ async function getTenantMeta(http, path25) {
8144
+ const resp = await http.get("/api/tenant-meta/meta", { params: { path: path25 } });
7707
8145
  const payload = resp.data?.data ?? resp.data;
7708
8146
  if (typeof payload === "string") return payload;
7709
8147
  return String(payload?.content ?? "");
7710
8148
  }
7711
- async function saveTenantMeta(http, path24, content) {
7712
- const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path24 } });
8149
+ async function saveTenantMeta(http, path25, content) {
8150
+ const resp = await http.put("/api/tenant-meta/meta", { content }, { params: { path: path25 } });
7713
8151
  return resp.data?.data ?? resp.data;
7714
8152
  }
7715
- async function deleteTenantMeta(http, path24) {
7716
- const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path24 } });
8153
+ async function deleteTenantMeta(http, path25) {
8154
+ const resp = await http.delete("/api/tenant-meta/meta", { params: { path: path25 } });
7717
8155
  return resp.data?.data ?? resp.data;
7718
8156
  }
7719
8157
 
@@ -7740,10 +8178,10 @@ function headers(opts) {
7740
8178
  function isRecord2(value) {
7741
8179
  return typeof value === "object" && value !== null && !Array.isArray(value);
7742
8180
  }
7743
- function unexpected(path24, body) {
8181
+ function unexpected(path25, body) {
7744
8182
  return new CliError({
7745
8183
  code: "PROTOCOL_UNSUPPORTED" /* PROTOCOL_UNSUPPORTED */,
7746
- message: `${path24} \u8FD4\u56DE\u4E86 2xx\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709\u7EA6\u5B9A\u7684 data \u7ED3\u6784\uFF1B\u6CA1\u6709\u628A\u7F3A\u7684\u90E8\u5206\u8865\u6210\u7A7A\u5217\u8868`,
8184
+ message: `${path25} \u8FD4\u56DE\u4E86 2xx\uFF0C\u4F46\u54CD\u5E94\u91CC\u6CA1\u6709\u7EA6\u5B9A\u7684 data \u7ED3\u6784\uFF1B\u6CA1\u6709\u628A\u7F3A\u7684\u90E8\u5206\u8865\u6210\u7A7A\u5217\u8868`,
7747
8185
  context: {
7748
8186
  reasonCode: "COLUMN_SLOT_RESPONSE_UNRECOGNIZED",
7749
8187
  details: body,
@@ -7772,7 +8210,7 @@ async function getColumnSlotSql(http, params, opts = {}) {
7772
8210
  }
7773
8211
 
7774
8212
  // src/meta/validate-meta.ts
7775
- import yaml9 from "js-yaml";
8213
+ import yaml8 from "js-yaml";
7776
8214
 
7777
8215
  // src/meta/generated/meta-schemas.ts
7778
8216
  var META_SCHEMA_SOURCE_COMMIT = "6b872a5b3749147cd4fed9dd1a1598e5876c8c76";
@@ -14708,7 +15146,7 @@ function validateScriptActionNames(doc, issues) {
14708
15146
  return;
14709
15147
  const reserved = /* @__PURE__ */ new Set(["list", "get", "create", "update", "delete"]);
14710
15148
  const visited = /* @__PURE__ */ new Set();
14711
- const visit = (raw, path24) => {
15149
+ const visit = (raw, path25) => {
14712
15150
  if (!raw || typeof raw !== "object" || Array.isArray(raw) || visited.has(raw)) return;
14713
15151
  visited.add(raw);
14714
15152
  const action3 = raw;
@@ -14716,7 +15154,7 @@ function validateScriptActionNames(doc, issues) {
14716
15154
  if (type === "script" && typeof action3.key === "string" && reserved.has(action3.key.trim().toLowerCase())) {
14717
15155
  issues.push({
14718
15156
  severity: "error",
14719
- path: `${path24}.key`,
15157
+ path: `${path25}.key`,
14720
15158
  message: `E_SCRIPT_ACTION_RESERVED_KEY: \u811A\u672C Action key '${action3.key}' \u4E0E CRUD \u4FDD\u7559\u540D\u51B2\u7A81\uFF08list/get/create/update/delete\uFF09`,
14721
15159
  hint: "\u6539\u7528\u4E1A\u52A1\u8BED\u4E49 key\uFF08\u5982 createBusinessRequest\uFF09\uFF0C\u5E76\u663E\u5F0F\u6388\u6743 action:<key>\uFF1BCRUD \u6743\u9650\u4E0E\u81EA\u5B9A\u4E49 Action \u6743\u9650\u72EC\u7ACB"
14722
15160
  });
@@ -14727,7 +15165,7 @@ function validateScriptActionNames(doc, issues) {
14727
15165
  const steps = composite.steps;
14728
15166
  if (!Array.isArray(steps)) return;
14729
15167
  steps.forEach((step, index) => {
14730
- const stepPath = `${path24}.composite.steps[${index}]`;
15168
+ const stepPath = `${path25}.composite.steps[${index}]`;
14731
15169
  visit(step, stepPath);
14732
15170
  if (step && typeof step === "object" && !Object.hasOwn(step, "type")) {
14733
15171
  visit(step.action, `${stepPath}.action`);
@@ -14759,7 +15197,7 @@ function validateMetaContent(metaPath2, content) {
14759
15197
  }
14760
15198
  let doc;
14761
15199
  try {
14762
- doc = yaml9.load(content);
15200
+ doc = yaml8.load(content);
14763
15201
  } catch (e) {
14764
15202
  const y = e;
14765
15203
  issues.push({
@@ -14833,7 +15271,7 @@ function explainJacksonError(raw) {
14833
15271
  }
14834
15272
 
14835
15273
  // src/skills.ts
14836
- import yaml10, { JSON_SCHEMA as JSON_SCHEMA3 } from "js-yaml";
15274
+ import yaml9, { JSON_SCHEMA as JSON_SCHEMA2 } from "js-yaml";
14837
15275
  var CHIRON_BASE_CANDIDATES = ["/api/chiron", "/api/skills", "/chiron", "/skills"];
14838
15276
  function looksLikeManifest(data) {
14839
15277
  if (!data || typeof data !== "object") return false;
@@ -14989,14 +15427,14 @@ function resolveSkillInstallOrder(manifest2, targetId) {
14989
15427
  throw invalid2(`\u6280\u80FD\u76EE\u5F55\u4E2D\u4E0D\u5B58\u5728 ${targetId}`);
14990
15428
  }
14991
15429
  const state = /* @__PURE__ */ new Map();
14992
- const path24 = [];
15430
+ const path25 = [];
14993
15431
  const order = [];
14994
15432
  const visit = (id, requiredBy) => {
14995
15433
  const current = state.get(id);
14996
15434
  if (current === "done") return;
14997
15435
  if (current === "visiting") {
14998
- const cycleStart = path24.indexOf(id);
14999
- const cycle = [...path24.slice(Math.max(0, cycleStart)), id];
15436
+ const cycleStart = path25.indexOf(id);
15437
+ const cycle = [...path25.slice(Math.max(0, cycleStart)), id];
15000
15438
  throw invalid2(`\u6280\u80FD\u4F9D\u8D56\u5B58\u5728\u73AF: ${cycle.join(" -> ")}`);
15001
15439
  }
15002
15440
  const skill = byId.get(id);
@@ -15005,11 +15443,11 @@ function resolveSkillInstallOrder(manifest2, targetId) {
15005
15443
  }
15006
15444
  assertSafeSkillId(skill.id);
15007
15445
  state.set(id, "visiting");
15008
- path24.push(id);
15446
+ path25.push(id);
15009
15447
  for (const required2 of normalizeRequirements(skill.requires, skill.id)) {
15010
15448
  visit(required2, skill.id);
15011
15449
  }
15012
- path24.pop();
15450
+ path25.pop();
15013
15451
  state.set(id, "done");
15014
15452
  order.push(skill);
15015
15453
  };
@@ -15031,7 +15469,7 @@ function parseSkillFrontmatter(markdown, skillId) {
15031
15469
  if (!match) return {};
15032
15470
  let frontmatter;
15033
15471
  try {
15034
- frontmatter = yaml10.load(match[1] ?? "", { schema: JSON_SCHEMA3 });
15472
+ frontmatter = yaml9.load(match[1] ?? "", { schema: JSON_SCHEMA2 });
15035
15473
  } catch (cause) {
15036
15474
  throw new CliError({
15037
15475
  code: "INVALID_ARGUMENT" /* INVALID_ARGUMENT */,
@@ -15100,18 +15538,18 @@ async function resetSettingItem(http, domain, namespace, settingKey, revision) {
15100
15538
  function parseSettingAssignment(raw) {
15101
15539
  const eq = raw.indexOf("=");
15102
15540
  if (eq <= 0) throw new Error(`--set \u9700\u8981 namespace.key=value \u5F62\u6001\uFF0C\u6536\u5230 "${raw}"`);
15103
- const path24 = raw.slice(0, eq).trim();
15541
+ const path25 = raw.slice(0, eq).trim();
15104
15542
  const value = raw.slice(eq + 1);
15105
- const dot = path24.lastIndexOf(".");
15106
- if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path24}"`);
15107
- return { namespace: path24.slice(0, dot), settingKey: path24.slice(dot + 1), value };
15543
+ const dot = path25.lastIndexOf(".");
15544
+ if (dot <= 0) throw new Error(`--set \u7684\u952E\u9700\u542B namespace\uFF0C\u5982 security.password.passwordPolicy=complex\uFF0C\u6536\u5230 "${path25}"`);
15545
+ return { namespace: path25.slice(0, dot), settingKey: path25.slice(dot + 1), value };
15108
15546
  }
15109
15547
 
15110
15548
  // src/fde/layout.ts
15111
15549
  import { createHash as createHash3, randomBytes as randomBytes2 } from "crypto";
15112
15550
  import {
15113
15551
  closeSync,
15114
- existsSync as existsSync3,
15552
+ existsSync as existsSync2,
15115
15553
  fsyncSync,
15116
15554
  linkSync,
15117
15555
  mkdirSync,
@@ -15122,7 +15560,7 @@ import {
15122
15560
  writeFileSync,
15123
15561
  writeSync
15124
15562
  } from "fs";
15125
- import * as path8 from "path";
15563
+ import * as path9 from "path";
15126
15564
  var UNSAFE = /[^A-Za-z0-9._-]/g;
15127
15565
  function slug(value) {
15128
15566
  return (value || "unknown").replace(UNSAFE, "_");
@@ -15136,10 +15574,10 @@ function tenantSegment(value) {
15136
15574
  return safeSegment(value);
15137
15575
  }
15138
15576
  function isInside(p, container) {
15139
- const rel = path8.relative(container, p);
15577
+ const rel = path9.relative(container, p);
15140
15578
  if (rel === "") return true;
15141
- if (path8.isAbsolute(rel)) return false;
15142
- return !rel.split(path8.sep).includes("..");
15579
+ if (path9.isAbsolute(rel)) return false;
15580
+ return !rel.split(path9.sep).includes("..");
15143
15581
  }
15144
15582
  function hasDotDotComponent(rel) {
15145
15583
  return rel.split(/[/\\]/).includes("..");
@@ -15153,14 +15591,14 @@ var ReconLayout = class {
15153
15591
  this.root = root;
15154
15592
  this.tenantId = String(tenantId);
15155
15593
  this.sourceKey = sourceKey;
15156
- this.dir = path8.join(
15594
+ this.dir = path9.join(
15157
15595
  this.root,
15158
15596
  "recon",
15159
15597
  tenantSegment(this.tenantId),
15160
15598
  safeSegment(sourceKey)
15161
15599
  );
15162
- const container = path8.resolve(this.root, "recon");
15163
- if (!isInside(path8.resolve(this.dir), container)) {
15600
+ const container = path9.resolve(this.root, "recon");
15601
+ if (!isInside(path9.resolve(this.dir), container)) {
15164
15602
  throw new LayoutContainmentError(
15165
15603
  `\u79DF\u6237\u6BB5\u8D8A\u754C\uFF0C\u62D2\u7EDD\u6784\u9020\u4EA7\u7269\u76EE\u5F55\uFF1AtenantId=${JSON.stringify(tenantId)}\uFF08\u4EA7\u7269\u6839 ${container}\uFF09`
15166
15604
  );
@@ -15183,19 +15621,19 @@ var ReconLayout = class {
15183
15621
  * ⚠️ 拒绝而不是消毒:消毒会让 `meta/<modelKey>.json` 不再能按 modelKey grep 回去。
15184
15622
  */
15185
15623
  resolvePath(rel, createParents = true) {
15186
- const p = path8.join(this.dir, rel);
15624
+ const p = path9.join(this.dir, rel);
15187
15625
  if (hasDotDotComponent(rel)) {
15188
15626
  throw new LayoutContainmentError(
15189
15627
  `\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4F1A\u8D8A\u51FA\u9884\u671F\u5B50\u76EE\u5F55\u3001\u9759\u9ED8\u9876\u6389\u540C\u7EA7\u4EA7\u7269\uFF1B\u4EA7\u7269\u6839 ${this.dir}\uFF09`
15190
15628
  );
15191
15629
  }
15192
- if (!isInside(path8.resolve(p), path8.resolve(this.dir))) {
15630
+ if (!isInside(path9.resolve(p), path9.resolve(this.dir))) {
15193
15631
  throw new LayoutContainmentError(
15194
15632
  `\u4EA7\u7269\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08\u4EA7\u7269\u6839 ${this.dir}\uFF09`
15195
15633
  );
15196
15634
  }
15197
15635
  if (createParents) {
15198
- mkdirSync(path8.dirname(p), { recursive: true });
15636
+ mkdirSync(path9.dirname(p), { recursive: true });
15199
15637
  }
15200
15638
  return p;
15201
15639
  }
@@ -15244,18 +15682,18 @@ var WorkLayout = class {
15244
15682
  }
15245
15683
  /** 与 {@link ReconLayout.resolvePath} 同样的两道闸,理由见那里。 */
15246
15684
  resolvePath(rel, createParents = true) {
15247
- const p = path8.join(this.dir, rel);
15685
+ const p = path9.join(this.dir, rel);
15248
15686
  if (hasDotDotComponent(rel)) {
15249
15687
  throw new LayoutContainmentError(
15250
15688
  `work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u542B \`..\` \u5206\u91CF\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
15251
15689
  );
15252
15690
  }
15253
- if (!isInside(path8.resolve(p), path8.resolve(this.dir))) {
15691
+ if (!isInside(path9.resolve(p), path9.resolve(this.dir))) {
15254
15692
  throw new LayoutContainmentError(
15255
15693
  `work \u76EE\u5F55\u76F8\u5BF9\u8DEF\u5F84\u8D8A\u754C\uFF0C\u62D2\u7EDD\u5199\u5165\uFF1A${JSON.stringify(rel)}\uFF08work \u6839 ${this.dir}\uFF09`
15256
15694
  );
15257
15695
  }
15258
- if (createParents) mkdirSync(path8.dirname(p), { recursive: true });
15696
+ if (createParents) mkdirSync(path9.dirname(p), { recursive: true });
15259
15697
  return p;
15260
15698
  }
15261
15699
  /** 写一份 JSON 产物。中文逐字落盘(本地 grep 才找得到),末尾带换行。 */
@@ -15363,7 +15801,7 @@ var WorkLayout = class {
15363
15801
  return readFileSync2(this.resolvePath(rel, false));
15364
15802
  }
15365
15803
  exists(rel) {
15366
- return existsSync3(this.resolvePath(rel, false));
15804
+ return existsSync2(this.resolvePath(rel, false));
15367
15805
  }
15368
15806
  };
15369
15807
  function tempPath(target) {
@@ -15438,11 +15876,11 @@ function classifyStatus(status) {
15438
15876
  return "bad-response";
15439
15877
  }
15440
15878
  var CAPABILITIES_HEADER = "x-hcm-capabilities";
15441
- function buildUrl(path24, params) {
15879
+ function buildUrl(path25, params) {
15442
15880
  const entries = Object.entries(params ?? {}).filter(([, v]) => v !== void 0 && v !== null);
15443
- if (entries.length === 0) return path24;
15881
+ if (entries.length === 0) return path25;
15444
15882
  const qs = entries.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
15445
- return `${path24}${path24.includes("?") ? "&" : "?"}${qs}`;
15883
+ return `${path25}${path25.includes("?") ? "&" : "?"}${qs}`;
15446
15884
  }
15447
15885
  function lowerHeaders(raw) {
15448
15886
  const out = {};
@@ -15497,14 +15935,14 @@ function httpProbe(http, capabilities) {
15497
15935
  const headers2 = { [CAPABILITIES_HEADER]: capabilities };
15498
15936
  const probe = {
15499
15937
  capabilities,
15500
- get(path24, params) {
15938
+ get(path25, params) {
15501
15939
  return once(
15502
- () => http.get(buildUrl(path24, params), { headers: headers2, validateStatus: () => true })
15940
+ () => http.get(buildUrl(path25, params), { headers: headers2, validateStatus: () => true })
15503
15941
  );
15504
15942
  },
15505
- post(path24, body) {
15943
+ post(path25, body) {
15506
15944
  return once(
15507
- () => http.post(path24, body, {
15945
+ () => http.post(path25, body, {
15508
15946
  headers: { ...headers2, "content-type": "application/json" },
15509
15947
  validateStatus: () => true
15510
15948
  })
@@ -15541,8 +15979,8 @@ function networkOutcome() {
15541
15979
 
15542
15980
  // src/fde/recon/runner.ts
15543
15981
  import { randomBytes as randomBytes3 } from "crypto";
15544
- import { existsSync as existsSync5, readFileSync as readFileSync3, readdirSync } from "fs";
15545
- import * as path10 from "path";
15982
+ import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync } from "fs";
15983
+ import * as path11 from "path";
15546
15984
 
15547
15985
  // src/fde/recon/carry-over.ts
15548
15986
  var KIT_CARRY_OVER_KEY = "_kitCarryOver";
@@ -15610,8 +16048,8 @@ async function crawlMeta(probe, modelKeys2, metaType = DEFAULT_META_TYPE) {
15610
16048
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
15611
16049
  const metas = {};
15612
16050
  const unavailable = [];
15613
- for (const [path24, key] of paths) {
15614
- const out = results[path24];
16051
+ for (const [path25, key] of paths) {
16052
+ const out = results[path25];
15615
16053
  if (out === void 0) {
15616
16054
  unavailable.push({
15617
16055
  modelKey: key,
@@ -15843,8 +16281,8 @@ async function collectActionGates(probe, modelKeys2, state = "") {
15843
16281
  const statesEchoed = /* @__PURE__ */ new Set();
15844
16282
  let noStateEcho = 0;
15845
16283
  let answered = 0;
15846
- for (const [path24, model] of paths) {
15847
- const out = results[path24];
16284
+ for (const [path25, model] of paths) {
16285
+ const out = results[path25];
15848
16286
  if (out === void 0) {
15849
16287
  unavailable.push({
15850
16288
  modelKey: model,
@@ -16263,8 +16701,8 @@ async function collectMutation(probe, modelKeys2) {
16263
16701
  const results = probe.getMany ? await probe.getMany([...paths.keys()]) : await sequentialGet(probe, [...paths.keys()]);
16264
16702
  const mutation = {};
16265
16703
  const problems = [];
16266
- for (const [path24, key] of paths) {
16267
- const out = results[path24];
16704
+ for (const [path25, key] of paths) {
16705
+ const out = results[path25];
16268
16706
  if (out === void 0) {
16269
16707
  problems.push(`${key}: mutation-capability ${BATCH_LOST}`);
16270
16708
  mutation[key] = Object.fromEntries(
@@ -16510,9 +16948,9 @@ function gateDesc(gate) {
16510
16948
  function renderModelsMd(modelsBody, metas, gates, dropped = []) {
16511
16949
  const byModel = /* @__PURE__ */ new Map();
16512
16950
  for (const g of gates) {
16513
- const list = byModel.get(g.model) ?? [];
16514
- list.push(g);
16515
- byModel.set(g.model, list);
16951
+ const list2 = byModel.get(g.model) ?? [];
16952
+ list2.push(g);
16953
+ byModel.set(g.model, list2);
16516
16954
  }
16517
16955
  const parts = [
16518
16956
  "# \u6A21\u578B\u7D22\u5F15",
@@ -16574,8 +17012,8 @@ function writeModelsMd(layout, text3) {
16574
17012
  }
16575
17013
 
16576
17014
  // src/fde/recon/pointer-audit.ts
16577
- import { existsSync as existsSync4 } from "fs";
16578
- import * as path9 from "path";
17015
+ import { existsSync as existsSync3 } from "fs";
17016
+ import * as path10 from "path";
16579
17017
  function isRecord5(v) {
16580
17018
  return Boolean(v) && typeof v === "object" && !Array.isArray(v);
16581
17019
  }
@@ -16588,7 +17026,7 @@ function auditValueDomainPointers(layout, sheets) {
16588
17026
  const pointer = isRecord5(ref) ? ref.valueDomain : null;
16589
17027
  if (typeof pointer !== "string" || pointer === "") continue;
16590
17028
  if (!seen.has(pointer)) {
16591
- seen.set(pointer, existsSync4(path9.join(layout.dir, pointer)));
17029
+ seen.set(pointer, existsSync3(path10.join(layout.dir, pointer)));
16592
17030
  }
16593
17031
  if (!seen.get(pointer)) {
16594
17032
  problems.push(
@@ -16709,11 +17147,11 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
16709
17147
  keys.push(key);
16710
17148
  }
16711
17149
  for (const key of [...new Set(keys)].sort()) {
16712
- const path24 = listPath(key);
17150
+ const path25 = listPath(key);
16713
17151
  const started = tick();
16714
17152
  let requests = 0;
16715
17153
  let truncatedBy = null;
16716
- const probeOut = await post2.call(probe, path24, { page: 0, size: 0 });
17154
+ const probeOut = await post2.call(probe, path25, { page: 0, size: 0 });
16717
17155
  requests += 1;
16718
17156
  let total = null;
16719
17157
  let reason = null;
@@ -16762,7 +17200,7 @@ async function collectCodeTables(probe, modelEntries2, opts = {}) {
16762
17200
  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`;
16763
17201
  break;
16764
17202
  }
16765
- const out = await post2.call(probe, path24, { page, size: PAGE_SIZE });
17203
+ const out = await post2.call(probe, path25, { page, size: PAGE_SIZE });
16766
17204
  requests += 1;
16767
17205
  if (out.error !== "ok") {
16768
17206
  failed = `\u7B2C ${page} \u9875\u5931\u8D25\uFF08HTTP ${out.status} / ${out.error}\uFF09`;
@@ -16983,7 +17421,7 @@ function readJsonSoft(file) {
16983
17421
  }
16984
17422
  }
16985
17423
  function readCrawledAt(layout) {
16986
- const body = readJsonSoft(path10.join(layout.dir, KIT_CRAWLED_AT_FILE));
17424
+ const body = readJsonSoft(path11.join(layout.dir, KIT_CRAWLED_AT_FILE));
16987
17425
  const models = isRecord7(body) ? body.models : null;
16988
17426
  return isRecord7(models) ? models : {};
16989
17427
  }
@@ -17013,7 +17451,7 @@ function writeCrawledAt(layout, freshKeys, carriedKeys, roundId, started) {
17013
17451
  return sorted;
17014
17452
  }
17015
17453
  function finishRound(layout, models, roundId, started, products) {
17016
- const written = [...new Set(products.filter((rel) => rel && existsSync5(path10.join(layout.dir, rel))))].sort();
17454
+ const written = [...new Set(products.filter((rel) => rel && existsSync4(path11.join(layout.dir, rel))))].sort();
17017
17455
  layout.writeJson(KIT_CRAWLED_AT_FILE, {
17018
17456
  note: CRAWLED_AT_NOTE,
17019
17457
  roundNote: ROUND_NOTE,
@@ -17025,13 +17463,13 @@ function finishRound(layout, models, roundId, started, products) {
17025
17463
  return written;
17026
17464
  }
17027
17465
  function relOf(layout, p) {
17028
- const rel = path10.relative(layout.dir, p);
17466
+ const rel = path11.relative(layout.dir, p);
17029
17467
  if (!rel || rel.startsWith("..")) return p;
17030
- return rel.split(path10.sep).join("/");
17468
+ return rel.split(path11.sep).join("/");
17031
17469
  }
17032
17470
  function productRoundId(root, rel) {
17033
- const p = path10.join(root, rel);
17034
- if (!existsSync5(p)) return ["missing", null];
17471
+ const p = path11.join(root, rel);
17472
+ if (!existsSync4(p)) return ["missing", null];
17035
17473
  const body = readJsonSoft(p);
17036
17474
  if (body === void 0 || !isRecord7(body)) return ["unreadable", null];
17037
17475
  const rid = body.roundId;
@@ -17039,7 +17477,7 @@ function productRoundId(root, rel) {
17039
17477
  return ["stamped", rid];
17040
17478
  }
17041
17479
  function inspectRound(root) {
17042
- const raw = readJsonSoft(path10.join(root, KIT_CRAWLED_AT_FILE));
17480
+ const raw = readJsonSoft(path11.join(root, KIT_CRAWLED_AT_FILE));
17043
17481
  const ledger = isRecord7(raw) ? raw : {};
17044
17482
  const rid = ledger.roundId;
17045
17483
  const roundId = typeof rid === "string" && rid ? rid : null;
@@ -17047,7 +17485,7 @@ function inspectRound(root) {
17047
17485
  const written = Array.isArray(rawWritten) ? rawWritten : null;
17048
17486
  let ledgerMissing = null;
17049
17487
  if (written !== null) {
17050
- const gone = written.filter((rel) => typeof rel === "string" && !existsSync5(path10.join(root, rel))).sort();
17488
+ const gone = written.filter((rel) => typeof rel === "string" && !existsSync4(path11.join(root, rel))).sort();
17051
17489
  ledgerMissing = { checked: written.length, count: gone.length, files: gone };
17052
17490
  }
17053
17491
  const products = [];
@@ -17167,7 +17605,7 @@ function carriedGatesSchemaProblem(oldGates) {
17167
17605
  function collectCarryOver(layout, freshMetas) {
17168
17606
  const problems = [];
17169
17607
  const carriedMetas = {};
17170
- const metaDir = path10.join(layout.dir, "meta");
17608
+ const metaDir = path11.join(layout.dir, "meta");
17171
17609
  const suffix = `.${DEFAULT_META_TYPE}.json`;
17172
17610
  let names = [];
17173
17611
  try {
@@ -17178,7 +17616,7 @@ function collectCarryOver(layout, freshMetas) {
17178
17616
  for (const name of names) {
17179
17617
  const key = name.slice(0, -suffix.length);
17180
17618
  if (key in freshMetas) continue;
17181
- const file = path10.join(metaDir, name);
17619
+ const file = path11.join(metaDir, name);
17182
17620
  let body;
17183
17621
  try {
17184
17622
  body = JSON.parse(readFileSync3(file, "utf8"));
@@ -17194,7 +17632,7 @@ function collectCarryOver(layout, freshMetas) {
17194
17632
  }
17195
17633
  }
17196
17634
  const carriedGates = [];
17197
- const oldGates = readJsonSoft(path10.join(layout.dir, "gates.json"));
17635
+ const oldGates = readJsonSoft(path11.join(layout.dir, "gates.json"));
17198
17636
  if (oldGates === void 0) {
17199
17637
  problems.push("gates.json: \u6CA1\u6709\u53EF\u6CBF\u7528\u7684\u4E0A\u4E00\u8F6E\u95F8\u8868\uFF08\u4E0D\u5B58\u5728\u6216\u8BFB\u4E0D\u51FA JSON\uFF09");
17200
17638
  } else {
@@ -17311,7 +17749,7 @@ async function runRecon(probe, layout, opts = {}) {
17311
17749
  const writtenPaths = new Set(vdWritten);
17312
17750
  const codeTableFiles = new Set(
17313
17751
  Object.keys(codeTables).filter(
17314
- (k) => unsafeTableKeyReason(k) === null && writtenPaths.has(path10.join(layout.dir, "valuedomain", `${k}.json`))
17752
+ (k) => unsafeTableKeyReason(k) === null && writtenPaths.has(path11.join(layout.dir, "valuedomain", `${k}.json`))
17315
17753
  )
17316
17754
  );
17317
17755
  const { mutation, problems: mutProblems } = await collectMutation(probe, Object.keys(metas).sort());
@@ -17326,7 +17764,7 @@ async function runRecon(probe, layout, opts = {}) {
17326
17764
  });
17327
17765
  products.push(...mappingPaths.map((p) => relOf(layout, p)));
17328
17766
  const sheetsWritten = Math.max(mappingPaths.length - 1, 0);
17329
- let previous = readJsonSoft(path10.join(layout.dir, "fingerprint.json"));
17767
+ let previous = readJsonSoft(path11.join(layout.dir, "fingerprint.json"));
17330
17768
  if (!isRecord7(previous)) previous = null;
17331
17769
  const current = await computeFingerprint(probe);
17332
17770
  products.push(relOf(layout, layout.writeJson("fingerprint.json", current)));
@@ -17421,12 +17859,12 @@ async function runRecon(probe, layout, opts = {}) {
17421
17859
  }
17422
17860
 
17423
17861
  // src/fde/seed/command.ts
17424
- import { existsSync as existsSync8, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync7 } from "fs";
17425
- import * as path16 from "path";
17862
+ import { existsSync as existsSync7, readFileSync as readFileSync7, readdirSync as readdirSync2, statSync as statSync6 } from "fs";
17863
+ import * as path17 from "path";
17426
17864
 
17427
17865
  // src/fde/seed/risk.ts
17428
- import { readFileSync as readFileSync6, realpathSync, statSync as statSync6 } from "fs";
17429
- import * as path15 from "path";
17866
+ import { readFileSync as readFileSync6, realpathSync, statSync as statSync5 } from "fs";
17867
+ import * as path16 from "path";
17430
17868
 
17431
17869
  // src/fde/seed/key-index.ts
17432
17870
  var MAX_PAGE_SIZE = 1e4;
@@ -17526,7 +17964,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17526
17964
  for (const name of ["id", ...fields]) {
17527
17965
  if (!projected.includes(name)) projected.push(name);
17528
17966
  }
17529
- const path24 = listPath2(model);
17967
+ const path25 = listPath2(model);
17530
17968
  const idx = /* @__PURE__ */ new Map();
17531
17969
  let total = null;
17532
17970
  let pages = 0;
@@ -17543,7 +17981,7 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17543
17981
  let repeatedIds = 0;
17544
17982
  while (total === null || received < total) {
17545
17983
  const pageNo = pages;
17546
- const out = await client.post(path24, {
17984
+ const out = await client.post(path25, {
17547
17985
  page: pageNo,
17548
17986
  size: pageSize,
17549
17987
  fields: projected,
@@ -17707,8 +18145,8 @@ async function loadKeyIndex(client, model, keyFields, pageSize = PAGE_SIZE_DEFAU
17707
18145
  }
17708
18146
 
17709
18147
  // src/fde/seed/artifacts.ts
17710
- import * as path14 from "path";
17711
- import { existsSync as existsSync7, readFileSync as readFileSync5, statSync as statSync5 } from "fs";
18148
+ import * as path15 from "path";
18149
+ import { existsSync as existsSync6, readFileSync as readFileSync5, statSync as statSync4 } from "fs";
17712
18150
 
17713
18151
  // src/fde/seed/errors.ts
17714
18152
  var SourceError = class extends Error {
@@ -17726,17 +18164,17 @@ var SHEETED_SUFFIXES = [".xlsx", ".xlsm"];
17726
18164
  var TEXT_SUFFIXES = [".csv", ".tsv"];
17727
18165
 
17728
18166
  // src/fde/seed/source.ts
17729
- import { existsSync as existsSync6, openSync as openSync3, readSync as readSync2, closeSync as closeSync3, statSync as statSync4 } from "fs";
17730
- import * as path13 from "path";
18167
+ import { existsSync as existsSync5, openSync as openSync3, readSync as readSync2, closeSync as closeSync3, statSync as statSync3 } from "fs";
18168
+ import * as path14 from "path";
17731
18169
 
17732
18170
  // src/fde/seed/container.ts
17733
- import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as statSync3 } from "fs";
18171
+ import { openSync as openSync2, readSync, closeSync as closeSync2, statSync as statSync2 } from "fs";
17734
18172
  var CFB_MAGIC = Buffer.from([208, 207, 17, 224, 161, 177, 26, 225]);
17735
18173
  var ENCRYPTED_PACKAGE = Buffer.from("EncryptedPackage", "utf16le");
17736
18174
  var MAX_ENTRY_BYTES = 128 * 1024 * 1024;
17737
18175
  var SCAN_CHUNK_BYTES = 1024 * 1024;
17738
- function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
17739
- const fd = openSync2(path24, "r");
18176
+ function scanFor(path25, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
18177
+ const fd = openSync2(path25, "r");
17740
18178
  try {
17741
18179
  let tail = Buffer.alloc(0);
17742
18180
  let seen = 0;
@@ -17757,9 +18195,9 @@ function scanFor(path24, needle = ENCRYPTED_PACKAGE, budget = MAX_ENTRY_BYTES) {
17757
18195
  closeSync2(fd);
17758
18196
  }
17759
18197
  }
17760
- function isCfb(path24) {
17761
- if (statSync3(path24).size < CFB_MAGIC.length) return false;
17762
- const fd = openSync2(path24, "r");
18198
+ function isCfb(path25) {
18199
+ if (statSync2(path25).size < CFB_MAGIC.length) return false;
18200
+ const fd = openSync2(path25, "r");
17763
18201
  try {
17764
18202
  const head = Buffer.alloc(CFB_MAGIC.length);
17765
18203
  const n = readSync(fd, head, 0, CFB_MAGIC.length, 0);
@@ -17768,9 +18206,9 @@ function isCfb(path24) {
17768
18206
  closeSync2(fd);
17769
18207
  }
17770
18208
  }
17771
- function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
17772
- if (!isCfb(path24)) return "not-cfb";
17773
- switch (scanFor(path24, ENCRYPTED_PACKAGE, budget)) {
18209
+ function classifyCfb(path25, budget = MAX_ENTRY_BYTES) {
18210
+ if (!isCfb(path25)) return "not-cfb";
18211
+ switch (scanFor(path25, ENCRYPTED_PACKAGE, budget)) {
17774
18212
  case "found":
17775
18213
  return "encrypted";
17776
18214
  case "absent":
@@ -17782,7 +18220,7 @@ function classifyCfb(path24, budget = MAX_ENTRY_BYTES) {
17782
18220
 
17783
18221
  // src/fde/seed/delimited.ts
17784
18222
  import { readFileSync as readFileSync4 } from "fs";
17785
- import * as path11 from "path";
18223
+ import * as path12 from "path";
17786
18224
 
17787
18225
  // src/fde/seed/columns.ts
17788
18226
  function resolveColumns(headerCells, dataRows, label, origin, filename, notes) {
@@ -17949,7 +18387,7 @@ function parseDelimited(text3, delimiter) {
17949
18387
  return records;
17950
18388
  }
17951
18389
  function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defaultDecoderFactory) {
17952
- const filename = path11.basename(file);
18390
+ const filename = path12.basename(file);
17953
18391
  if (sheet !== null && sheet !== void 0) {
17954
18392
  throw new SourceError(
17955
18393
  "sheet-not-applicable",
@@ -18030,7 +18468,7 @@ function readDelimited(file, suffix, sheet, headerRow, notes, makeDecoder = defa
18030
18468
  }
18031
18469
 
18032
18470
  // src/fde/seed/xlsx.ts
18033
- import * as path12 from "path";
18471
+ import * as path13 from "path";
18034
18472
 
18035
18473
  // src/fde/seed/zip.ts
18036
18474
  import yauzl from "yauzl";
@@ -18471,7 +18909,7 @@ function readSheetText(text3, shared, headerRow, filename, notes) {
18471
18909
  return { header, rows: assemble(header, body, headerRow) };
18472
18910
  }
18473
18911
  async function readXlsx(file, sheet, headerRow, notes, maxEntryBytes) {
18474
- const filename = path12.basename(file);
18912
+ const filename = path13.basename(file);
18475
18913
  const parts = await openParts(file, filename, maxEntryBytes);
18476
18914
  try {
18477
18915
  if (!parts.names.has("xl/workbook.xml")) {
@@ -18549,7 +18987,7 @@ function classifyContainer(file, filename, defaultReason, budget) {
18549
18987
  );
18550
18988
  }
18551
18989
  function startsWithPk(file) {
18552
- if (statSync4(file).size < 2) return false;
18990
+ if (statSync3(file).size < 2) return false;
18553
18991
  const fd = openSync3(file, "r");
18554
18992
  try {
18555
18993
  const head = Buffer.alloc(2);
@@ -18561,7 +18999,7 @@ function startsWithPk(file) {
18561
18999
  async function readTable(file, options = {}) {
18562
19000
  const sheet = options.sheet ?? null;
18563
19001
  const headerRow = options.headerRow ?? 1;
18564
- const filename = path13.basename(file);
19002
+ const filename = path14.basename(file);
18565
19003
  if (headerRow < 1) {
18566
19004
  throw new SourceError(
18567
19005
  "bad-header-row",
@@ -18569,10 +19007,10 @@ async function readTable(file, options = {}) {
18569
19007
  "\u8868\u5934\u884C\u53F7\u4ECE 1 \u8D77\u7B97\uFF08\u7B2C 1 \u884C\u5C31\u662F 1\uFF09\uFF0C\u4E0D\u662F\u4ECE 0"
18570
19008
  );
18571
19009
  }
18572
- if (!existsSync6(file) || !statSync4(file).isFile()) {
19010
+ if (!existsSync5(file) || !statSync3(file).isFile()) {
18573
19011
  throw new SourceError("not-found", `\u627E\u4E0D\u5230\u6E90\u8868 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF0C\u4EE5\u53CA\u6587\u4EF6\u662F\u5426\u8FD8\u5728\u5171\u4EAB\u76D8\u4E0A\u6CA1\u540C\u6B65\u4E0B\u6765");
18574
19012
  }
18575
- const suffix = path13.extname(file).toLowerCase();
19013
+ const suffix = path14.extname(file).toLowerCase();
18576
19014
  if (suffix === ".xls") {
18577
19015
  throw classifyContainer(file, filename, "legacy-xls", options.scanBudgetBytes);
18578
19016
  }
@@ -18942,7 +19380,7 @@ var MODEL_KEYS = [
18942
19380
  "valueMap"
18943
19381
  ];
18944
19382
  function loadMapping(file) {
18945
- if (!existsSync7(file) || !statSync5(file).isFile()) {
19383
+ if (!existsSync6(file) || !statSync4(file).isFile()) {
18946
19384
  throw new MappingError("not-found", `\u627E\u4E0D\u5230\u6620\u5C04\u5DE5\u4EF6 ${file}`, "\u786E\u8BA4\u8DEF\u5F84\uFF1B\u5DE5\u4EF6\u4E00\u822C\u5728 work/mapping.json");
18947
19385
  }
18948
19386
  let text3;
@@ -19189,16 +19627,16 @@ function stamp(note, model, file) {
19189
19627
  }
19190
19628
  return { ...asRecord3, model, file };
19191
19629
  }
19192
- async function scanSources(mapping, baseDir, options = {}) {
19630
+ async function scanSources(mapping2, baseDir, options = {}) {
19193
19631
  const read = options.readTableImpl ?? readTable;
19194
- const base = baseDir ?? path14.dirname(mapping.path);
19632
+ const base = baseDir ?? path15.dirname(mapping2.path);
19195
19633
  const headers2 = /* @__PURE__ */ new Map();
19196
19634
  const rows = /* @__PURE__ */ new Map();
19197
19635
  const notes = [];
19198
19636
  const problems = [];
19199
19637
  const takenBy = /* @__PURE__ */ new Map();
19200
- for (const [index, mm] of mapping.models.entries()) {
19201
- const file = path14.join(base, mm.source.file);
19638
+ for (const [index, mm] of mapping2.models.entries()) {
19639
+ const file = path15.join(base, mm.source.file);
19202
19640
  const owner = takenBy.get(mm.model);
19203
19641
  if (owner !== void 0) {
19204
19642
  problems.push(
@@ -19240,9 +19678,9 @@ async function scanSources(mapping, baseDir, options = {}) {
19240
19678
  }
19241
19679
  return { headers: headers2, rows, notes, problems };
19242
19680
  }
19243
- function validateMapping(mapping, headers2) {
19681
+ function validateMapping(mapping2, headers2) {
19244
19682
  const declaredKeys = /* @__PURE__ */ new Map();
19245
- for (const mm of mapping.models) {
19683
+ for (const mm of mapping2.models) {
19246
19684
  const fields = mm.businessKey ? [...mm.businessKey.fields] : [];
19247
19685
  if (!declaredKeys.has(mm.model)) {
19248
19686
  declaredKeys.set(mm.model, fields);
@@ -19257,7 +19695,7 @@ function validateMapping(mapping, headers2) {
19257
19695
  }
19258
19696
  const problems = [];
19259
19697
  const positions = /* @__PURE__ */ new Map();
19260
- mapping.models.forEach((mm, i) => {
19698
+ mapping2.models.forEach((mm, i) => {
19261
19699
  const spots = positions.get(mm.model);
19262
19700
  if (spots) spots.push(i);
19263
19701
  else positions.set(mm.model, [i]);
@@ -19275,7 +19713,7 @@ function validateMapping(mapping, headers2) {
19275
19713
  )
19276
19714
  );
19277
19715
  }
19278
- mapping.models.forEach((mm, index) => {
19716
+ mapping2.models.forEach((mm, index) => {
19279
19717
  problems.push(...validateModel(mm, headers2, duplicated.has(mm.model), index, declaredKeys));
19280
19718
  });
19281
19719
  return problems;
@@ -19369,7 +19807,7 @@ function checkOnExisting(mm) {
19369
19807
  return [];
19370
19808
  }
19371
19809
  function checkSourceRef(mm) {
19372
- const suffix = path14.extname(mm.source.file).toLowerCase();
19810
+ const suffix = path15.extname(mm.source.file).toLowerCase();
19373
19811
  if (!SUPPORTED_SUFFIXES.includes(suffix)) {
19374
19812
  return [
19375
19813
  problem(
@@ -19515,8 +19953,8 @@ function assignmentMap(mm, includeBusinessKey) {
19515
19953
  const translations = (field) => mm.valueMap.get(field) ?? /* @__PURE__ */ new Map();
19516
19954
  const out = /* @__PURE__ */ new Map();
19517
19955
  const push = (a) => {
19518
- const list = out.get(a.field);
19519
- if (list) list.push(a);
19956
+ const list2 = out.get(a.field);
19957
+ if (list2) list2.push(a);
19520
19958
  else out.set(a.field, [a]);
19521
19959
  };
19522
19960
  if (includeBusinessKey && mm.businessKey !== null) {
@@ -19628,8 +20066,8 @@ function checkColumnsAgainstHeader(mm, header, includeKey, includeColumns) {
19628
20066
  }
19629
20067
  const declared = /* @__PURE__ */ new Map();
19630
20068
  const declare = (column, origin) => {
19631
- const list = declared.get(column);
19632
- if (list) list.push(origin);
20069
+ const list2 = declared.get(column);
20070
+ if (list2) list2.push(origin);
19633
20071
  else declared.set(column, [origin]);
19634
20072
  };
19635
20073
  if (includeKey && mm.businessKey !== null) {
@@ -19729,20 +20167,20 @@ var PlanInvariantError = class extends Error {
19729
20167
  this.name = "PlanInvariantError";
19730
20168
  }
19731
20169
  };
19732
- function buildImportPlan(mapping, tables, indexes, options = {}) {
20170
+ function buildImportPlan(mapping2, tables, indexes, options = {}) {
19733
20171
  const problems = [];
19734
20172
  const models = [];
19735
20173
  const keyFieldsByModel = /* @__PURE__ */ new Map();
19736
- for (const mm of mapping.models) {
20174
+ for (const mm of mapping2.models) {
19737
20175
  if (mm.businessKey && mm.businessKey.fields.length && !keyFieldsByModel.has(mm.model)) {
19738
20176
  keyFieldsByModel.set(mm.model, [...mm.businessKey.fields]);
19739
20177
  }
19740
20178
  }
19741
20179
  const resolvedKeyModels = new Set(
19742
- mapping.models.filter((mm) => mm.businessKey && mm.businessKey.resolveBy.size).map((mm) => mm.model)
20180
+ mapping2.models.filter((mm) => mm.businessKey && mm.businessKey.resolveBy.size).map((mm) => mm.model)
19743
20181
  );
19744
20182
  const indexErrors = options.indexErrors ?? /* @__PURE__ */ new Map();
19745
- mapping.models.forEach((mm, entry) => {
20183
+ mapping2.models.forEach((mm, entry) => {
19746
20184
  const [modelPlan, modelProblems] = planModel(
19747
20185
  mm,
19748
20186
  tables,
@@ -19755,7 +20193,7 @@ function buildImportPlan(mapping, tables, indexes, options = {}) {
19755
20193
  models.push(modelPlan);
19756
20194
  problems.push(...modelProblems);
19757
20195
  });
19758
- const [orderInfo, orderProblems] = crossModelOrder(mapping, models, resolvedKeyModels);
20196
+ const [orderInfo, orderProblems] = crossModelOrder(mapping2, models, resolvedKeyModels);
19759
20197
  problems.push(...orderProblems);
19760
20198
  const roundId = options.roundId ?? newRoundId(/* @__PURE__ */ new Date());
19761
20199
  return {
@@ -19771,15 +20209,15 @@ function buildImportPlan(mapping, tables, indexes, options = {}) {
19771
20209
  var CROSS_MODEL_NOTE = "\u53EA\u6838\u4E86\u8FD9\u4EFD\u5DE5\u4EF6\u81EA\u5DF1\u58F0\u660E\u7684 resolveBy \u5F15\u7528\u8FB9\uFF08\u5DE5\u4EF6\u5185\u7684\u6A21\u578B\u4E4B\u95F4\uFF09\u3002\u4EA7\u54C1\u7EA7\u7684\u6A21\u578B\u4F9D\u8D56\u56FE topology.json **\u672C\u8F6E\u6CA1\u6709\u8BFB** \u2014\u2014 \u300C\u6CA1\u62A5\u987A\u5E8F\u95EE\u9898\u300D\u53EA\u7B49\u4E8E\u300C\u5DE5\u4EF6\u5185\u58F0\u660E\u7684\u8FB9\u6CA1\u51B2\u7A81\u300D\uFF0C**\u4E0D\u7B49\u4E8E**\u300C\u8DE8\u6A21\u578B\u987A\u5E8F\u6838\u8FC7\u4E86\u300D\u3002\u5DE5\u4EF6\u4E4B\u5916\u7684\u4F9D\u8D56\uFF08\u76EE\u6807\u6A21\u578B\u4E0D\u5728\u672C\u5DE5\u4EF6\u91CC\u7684\u90A3\u4E9B\u8FB9\uFF09\u672C\u5C42\u5224\u4E0D\u4E86\uFF0C\u53EA\u5982\u5B9E\u8BB0\u5728 edges \u91CC";
19772
20210
  var WHY_ASSIGNMENTS_UNUSABLE = "\u8FD9\u4E2A\u6A21\u578B\u7684\u5DE5\u4EF6\u62FC\u4E0D\u51FA\u5B57\u6BB5\u8D4B\u503C\u96C6\u5408\uFF08[{reason}]\uFF09\u21D2 \u5B83\u6709\u54EA\u4E9B\u5F15\u7528\u8FB9**\u6839\u672C\u6CA1\u626B\u8FC7**\u3002\u672C\u8F6E problems \u91CC\u53E6\u6709\u5B83\u7684 MAPPING_NOT_USABLE\uFF08\u4E0E\u672C\u6761\u540C\u4E00\u6B21\u8C03\u7528\u53D1\u51FA\uFF0C\u4E00\u5B9A\u5728\uFF09";
19773
20211
  var WHY_DUPLICATE_ENTRIES = "\u540C\u540D\u6A21\u578B\u5728\u8FD9\u4EFD\u5DE5\u4EF6\u91CC\u6709**\u591A\u6761 entry**\uFF0C\u4E00\u6761\u5F15\u7528\u8FB9\u5C5E\u4E8E\u54EA\u4E00\u6761**\u5206\u4E0D\u51FA\u6765** \u21D2 \u6CA1\u626B\u3002\u26A0\uFE0F \u522B\u53BB problems \u91CC\u627E DUPLICATE_MODEL_ENTRY\uFF1A\u90A3\u662F**\u5DE5\u4EF6\u5C42\u6821\u9A8C**\uFF08validateMapping\uFF09\u53D1\u7684 code\uFF0C\u800C\u5B83\u7531\u95E8\u9762 planFromArtifacts \u8D1F\u8D23\u8DD1 \u2014\u2014 \u8D70\u5230\u8FD9\u6761\u5206\u652F\u8BF4\u660E\u8C03\u7528\u65B9\u662F**\u76F4\u63A5\u8C03 buildImportPlan**\uFF0C\u90A3\u6761\u8DEF\u4E0A\u5DE5\u4EF6\u5C42\u6821\u9A8C\u4ECE\u6CA1\u8DD1\u8FC7\uFF0C\u6240\u4EE5\u90A3\u6761 code \u4E0D\u4F1A\u51FA\u73B0\u3002\u6B63\u786E\u505A\u6CD5\u662F\u5148\u8DD1\u4E00\u904D validateMapping\uFF0C\u5B83\u4F1A\u62D2\u6389\u8FD9\u4EFD\u5DE5\u4EF6";
19774
- function crossModelOrder(mapping, modelPlans, resolvedKeyModels) {
20212
+ function crossModelOrder(mapping2, modelPlans, resolvedKeyModels) {
19775
20213
  const positions = /* @__PURE__ */ new Map();
19776
- mapping.models.forEach((mm, i) => {
20214
+ mapping2.models.forEach((mm, i) => {
19777
20215
  if (!positions.has(mm.model)) positions.set(mm.model, i);
19778
20216
  });
19779
20217
  const plans = /* @__PURE__ */ new Map();
19780
20218
  for (const p of modelPlans) if (!plans.has(p.model)) plans.set(p.model, p);
19781
20219
  const seen = /* @__PURE__ */ new Map();
19782
- for (const mm of mapping.models) seen.set(mm.model, (seen.get(mm.model) ?? 0) + 1);
20220
+ for (const mm of mapping2.models) seen.set(mm.model, (seen.get(mm.model) ?? 0) + 1);
19783
20221
  const duplicated = new Set([...seen].filter(([, c]) => c > 1).map(([m]) => m));
19784
20222
  const edges = [];
19785
20223
  const problems = [];
@@ -19788,7 +20226,7 @@ function crossModelOrder(mapping, modelPlans, resolvedKeyModels) {
19788
20226
  const notScan = (model, why) => {
19789
20227
  if (!notScanned.some((item) => item.model === model)) notScanned.push({ model, why });
19790
20228
  };
19791
- for (const mm of mapping.models) {
20229
+ for (const mm of mapping2.models) {
19792
20230
  if (duplicated.has(mm.model)) {
19793
20231
  notScan(mm.model, WHY_DUPLICATE_ENTRIES);
19794
20232
  continue;
@@ -19936,8 +20374,8 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
19936
20374
  const blocked = /* @__PURE__ */ new Map();
19937
20375
  const block = (code) => {
19938
20376
  for (const group of PREMISE_BLOCKS2[code]) {
19939
- const list = blocked.get(group);
19940
- if (list) list.push(code);
20377
+ const list2 = blocked.get(group);
20378
+ if (list2) list2.push(code);
19941
20379
  else blocked.set(group, [code]);
19942
20380
  }
19943
20381
  };
@@ -20007,9 +20445,9 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
20007
20445
  const got = rowKey(row, assign, keyFields, indexes, keyFieldsByModel, resolvedKeyModels);
20008
20446
  keys.push(got.key);
20009
20447
  if (got.key === null) {
20010
- const list = byCode.get(got.code) ?? [];
20011
- list.push(`\u7B2C ${rowNo(mm, i)} \u884C\uFF08${got.why}\uFF09`);
20012
- byCode.set(got.code, list);
20448
+ const list2 = byCode.get(got.code) ?? [];
20449
+ list2.push(`\u7B2C ${rowNo(mm, i)} \u884C\uFF08${got.why}\uFF09`);
20450
+ byCode.set(got.code, list2);
20013
20451
  }
20014
20452
  });
20015
20453
  const listed3 = (items) => items.slice(0, MAX_LISTED).join("\u3001") + (items.length > MAX_LISTED ? `\u2026\uFF08\u5171 ${items.length} \u884C\uFF09` : "");
@@ -20043,8 +20481,8 @@ function planModel(mm, tables, indexes, entry, indexError, keyFieldsByModel, res
20043
20481
  keys.forEach((key, i) => {
20044
20482
  if (key === null) return;
20045
20483
  const enc = encodeKeyTuple(key);
20046
- const list = positions.get(enc);
20047
- if (list) list.push(i);
20484
+ const list2 = positions.get(enc);
20485
+ if (list2) list2.push(i);
20048
20486
  else positions.set(enc, [i]);
20049
20487
  });
20050
20488
  const duplicated = [...positions].filter(([, spots]) => spots.length > 1).map(([enc, spots]) => ({ enc, spots, parts: keys[spots[0]] })).sort((a, b) => compareParts(a.parts, b.parts));
@@ -20310,24 +20748,24 @@ function rowCycles(parents) {
20310
20748
  const cycles = [];
20311
20749
  for (const start of [...parents.keys()].sort((a, b) => a - b)) {
20312
20750
  if (done.has(start)) continue;
20313
- const path24 = [];
20751
+ const path25 = [];
20314
20752
  const seen = /* @__PURE__ */ new Map();
20315
20753
  let node = start;
20316
20754
  while (node !== void 0 && !seen.has(node) && !done.has(node)) {
20317
- seen.set(node, path24.length);
20318
- path24.push(node);
20755
+ seen.set(node, path25.length);
20756
+ path25.push(node);
20319
20757
  node = parents.get(node);
20320
20758
  }
20321
- if (node !== void 0 && seen.has(node)) cycles.push(path24.slice(seen.get(node)));
20322
- for (const n of path24) done.add(n);
20759
+ if (node !== void 0 && seen.has(node)) cycles.push(path25.slice(seen.get(node)));
20760
+ for (const n of path25) done.add(n);
20323
20761
  }
20324
20762
  return cycles;
20325
20763
  }
20326
20764
  function withDescendants(excluded, parents) {
20327
20765
  const children = /* @__PURE__ */ new Map();
20328
20766
  for (const [child, parent] of parents) {
20329
- const list = children.get(parent);
20330
- if (list) list.push(child);
20767
+ const list2 = children.get(parent);
20768
+ if (list2) list2.push(child);
20331
20769
  else children.set(parent, [child]);
20332
20770
  }
20333
20771
  const out = new Map(excluded);
@@ -20371,8 +20809,8 @@ function waveLevels(parents, excluded, count) {
20371
20809
  function buildWaves(mm, rows, keys, levels, assign, selfRef, parentValues, parents, index, checkExistence, indexes, keyFieldsByModel, resolvedKeyModels) {
20372
20810
  const byLevel = /* @__PURE__ */ new Map();
20373
20811
  for (const [i, lv] of levels) {
20374
- const list = byLevel.get(lv);
20375
- if (list) list.push(i);
20812
+ const list2 = byLevel.get(lv);
20813
+ if (list2) list2.push(i);
20376
20814
  else byLevel.set(lv, [i]);
20377
20815
  }
20378
20816
  const waves = [];
@@ -20674,7 +21112,7 @@ var NEEDS_SHEET = [
20674
21112
  ];
20675
21113
  function whyNoSheetNoChecks(sourceFile) {
20676
21114
  const workbook = SHEETED_SUFFIXES.includes(
20677
- path15.extname(sourceFile).toLowerCase()
21115
+ path16.extname(sourceFile).toLowerCase()
20678
21116
  );
20679
21117
  let text3 = `\u{1F534} \u4F9D\u8D56\u8FD9\u4EFD sheet \u7684 ${NEEDS_SHEET.length} \u7EC4\u5224\u636E**\u4E00\u7EC4\u90FD\u6CA1\u8DD1**\uFF1A${NEEDS_SHEET.join("\uFF1B")}`;
20680
21118
  if (!workbook) {
@@ -20758,7 +21196,7 @@ function unsafeRelReason(rel) {
20758
21196
  if (hasDotDotComponent(rel)) {
20759
21197
  return `\u542B \`..\` \u5206\u91CF\uFF0C\u4F1A\u8BFB\u5230 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${JSON.stringify(rel)}`;
20760
21198
  }
20761
- if (path15.isAbsolute(rel) || rel.startsWith("/") || rel.startsWith("\\")) {
21199
+ if (path16.isAbsolute(rel) || rel.startsWith("/") || rel.startsWith("\\")) {
20762
21200
  return `\u662F\u7EDD\u5BF9\u8DEF\u5F84\uFF0C\u4E0D\u662F recon \u4EA7\u7269\u91CC\u7684\u76F8\u5BF9\u4F4D\u7F6E\uFF1A${JSON.stringify(rel)}`;
20763
21201
  }
20764
21202
  return null;
@@ -20786,7 +21224,7 @@ var ReconView = class {
20786
21224
  resolve(rel) {
20787
21225
  const reason = unsafeRelReason(rel);
20788
21226
  if (reason !== null) return { file: null, reason };
20789
- const file = path15.join(this.dir, rel);
21227
+ const file = path16.join(this.dir, rel);
20790
21228
  if (!isInside(realOf(file), realOf(this.dir))) {
20791
21229
  return { file: null, reason: `\u89E3\u6790\u4E4B\u540E\u843D\u5728 recon \u4EA7\u7269\u76EE\u5F55\u4E4B\u5916\uFF1A${file}` };
20792
21230
  }
@@ -20798,7 +21236,7 @@ var ReconView = class {
20798
21236
  if (!isFile(file)) return { body: null, failure: "missing", detail: `${file} \u4E0D\u5B58\u5728` };
20799
21237
  let text3;
20800
21238
  try {
20801
- text3 = decodeUtf8(readFileSync6(file));
21239
+ text3 = decodeUtf82(readFileSync6(file));
20802
21240
  } catch (e) {
20803
21241
  const why = e instanceof Utf8Error ? `${file} \u4E0D\u662F UTF-8 \u7F16\u7801` : `${file} \u8BFB\u4E0D\u4E86\uFF1A${e.message}`;
20804
21242
  return { body: null, failure: "unreadable", detail: why };
@@ -20819,7 +21257,7 @@ var ReconView = class {
20819
21257
  const cached = this.sheets.get(modelKey);
20820
21258
  if (cached !== void 0) return cached;
20821
21259
  const rel = `${MAPPING_SUBDIR}/${modelKey}.json`;
20822
- const got = { ...this.readJson(rel), path: path15.join(this.dir, rel) };
21260
+ const got = { ...this.readJson(rel), path: path16.join(this.dir, rel) };
20823
21261
  this.sheets.set(modelKey, got);
20824
21262
  return got;
20825
21263
  }
@@ -20870,7 +21308,7 @@ var ReconView = class {
20870
21308
  if (!isFile(file)) return { index: null, failure: "missing", detail: `${file} \u4E0D\u5B58\u5728` };
20871
21309
  let text3;
20872
21310
  try {
20873
- text3 = decodeUtf8(readFileSync6(file));
21311
+ text3 = decodeUtf82(readFileSync6(file));
20874
21312
  } catch (e) {
20875
21313
  const why = e instanceof Utf8Error ? `${file} \u4E0D\u662F UTF-8 \u7F16\u7801` : `${file} \u8BFB\u4E0D\u4E86\uFF1A${e.message}`;
20876
21314
  return { index: null, failure: "unreadable", detail: why };
@@ -20905,7 +21343,7 @@ function enumKey(model, field) {
20905
21343
  }
20906
21344
  var Utf8Error = class extends Error {
20907
21345
  };
20908
- function decodeUtf8(bytes2) {
21346
+ function decodeUtf82(bytes2) {
20909
21347
  try {
20910
21348
  return new TextDecoder("utf-8", { fatal: true }).decode(bytes2).replace(/^\uFEFF/, "");
20911
21349
  } catch {
@@ -20914,21 +21352,21 @@ function decodeUtf8(bytes2) {
20914
21352
  }
20915
21353
  function isFile(p) {
20916
21354
  try {
20917
- return statSync6(p).isFile();
21355
+ return statSync5(p).isFile();
20918
21356
  } catch {
20919
21357
  return false;
20920
21358
  }
20921
21359
  }
20922
21360
  function realOf(p) {
20923
21361
  const rest = [];
20924
- let cur = path15.resolve(p);
21362
+ let cur = path16.resolve(p);
20925
21363
  for (; ; ) {
20926
21364
  try {
20927
- return path15.join(realpathSync(cur), ...rest);
21365
+ return path16.join(realpathSync(cur), ...rest);
20928
21366
  } catch {
20929
- const parent = path15.dirname(cur);
20930
- if (parent === cur) return path15.resolve(p);
20931
- rest.unshift(path15.basename(cur));
21367
+ const parent = path16.dirname(cur);
21368
+ if (parent === cur) return path16.resolve(p);
21369
+ rest.unshift(path16.basename(cur));
20932
21370
  cur = parent;
20933
21371
  }
20934
21372
  }
@@ -21526,7 +21964,7 @@ function noteProblems(notes) {
21526
21964
  const model = n.model;
21527
21965
  const file = n.file;
21528
21966
  const column = n.column;
21529
- const suffix = typeof file === "string" ? path15.extname(file).toLowerCase() : "";
21967
+ const suffix = typeof file === "string" ? path16.extname(file).toLowerCase() : "";
21530
21968
  const notation = NOTATION_BY_SUFFIX[suffix] ?? NOTATION_UNKNOWN;
21531
21969
  out.push(
21532
21970
  problem3(
@@ -21696,7 +22134,7 @@ function riskModel(mm, entry, recon, tables, plan = null) {
21696
22134
  );
21697
22135
  block("AC6_PREMISE_SOURCE_ROWS_EMPTY");
21698
22136
  }
21699
- if (!SHEETED_SUFFIXES.includes(path15.extname(mm.source.file).toLowerCase())) {
22137
+ if (!SHEETED_SUFFIXES.includes(path16.extname(mm.source.file).toLowerCase())) {
21700
22138
  notApplicable.set(CHECK_DATE_SERIAL, WHY_NOT_A_WORKBOOK);
21701
22139
  } else if (rows === void 0) {
21702
22140
  block(WHY_NO_SOURCE_ROWS, [CHECK_DATE_SERIAL]);
@@ -21907,14 +22345,14 @@ function checksSkipped(models, provided) {
21907
22345
  }
21908
22346
  return false;
21909
22347
  }
21910
- function buildRisk(mapping, reconDir, options = {}) {
22348
+ function buildRisk(mapping2, reconDir, options = {}) {
21911
22349
  const recon = new ReconView(reconDir);
21912
22350
  const notesGiven = options.notes !== void 0 && options.notes !== null;
21913
22351
  const exemptionsGiven = options.exemptions !== void 0 && options.exemptions !== null;
21914
22352
  const roundGiven = options.roundPremise !== void 0 && options.roundPremise !== null;
21915
22353
  let problems = [];
21916
22354
  const models = [];
21917
- mapping.models.forEach((mm, entry) => {
22355
+ mapping2.models.forEach((mm, entry) => {
21918
22356
  const got = riskModel(mm, entry, recon, options.tables ?? null, options.plan ?? null);
21919
22357
  models.push(got.model);
21920
22358
  problems.push(...got.problems);
@@ -21955,20 +22393,20 @@ var MAPPING_FILE = "mapping.json";
21955
22393
  var OFFLINE_COMMANDS = ["find", "values"];
21956
22394
  function seedWorkDir(args) {
21957
22395
  if (args.work) return args.work;
21958
- return path16.join(args.out, WORK_DIRNAME, tenantSegment(String(args.tenant)));
22396
+ return path17.join(args.out, WORK_DIRNAME, tenantSegment(String(args.tenant)));
21959
22397
  }
21960
22398
  function seedMappingPath(args, work) {
21961
- return args.mapping ? args.mapping : path16.join(work, MAPPING_FILE);
22399
+ return args.mapping ? args.mapping : path17.join(work, MAPPING_FILE);
21962
22400
  }
21963
22401
  function seedBaselines(out, tenant) {
21964
- const base = path16.join(out, "recon", tenantSegment(String(tenant)));
21965
- if (!existsSync8(base) || !statSync7(base).isDirectory()) return [base, []];
22402
+ const base = path17.join(out, "recon", tenantSegment(String(tenant)));
22403
+ if (!existsSync7(base) || !statSync6(base).isDirectory()) return [base, []];
21966
22404
  const found = [];
21967
22405
  for (const name of readdirSync2(base).sort()) {
21968
- const reconDir = path16.join(base, name);
21969
- if (!statSync7(reconDir).isDirectory()) continue;
21970
- const indexFile = path16.join(reconDir, "index", "fields.jsonl");
21971
- if (existsSync8(indexFile)) found.push({ indexFile, reconDir });
22406
+ const reconDir = path17.join(base, name);
22407
+ if (!statSync6(reconDir).isDirectory()) continue;
22408
+ const indexFile = path17.join(reconDir, "index", "fields.jsonl");
22409
+ if (existsSync7(indexFile)) found.push({ indexFile, reconDir });
21972
22410
  }
21973
22411
  return [base, found];
21974
22412
  }
@@ -22063,7 +22501,7 @@ var JOURNAL_STOP_UNKNOWN = [
22063
22501
  ""
22064
22502
  ];
22065
22503
  function journalNote(journalPath, whenPresent = "") {
22066
- if (!existsSync8(journalPath)) {
22504
+ if (!existsSync7(journalPath)) {
22067
22505
  return ` \u53F0\u8D26 \`${journalPath}\` **\u6B64\u523B\u4E0D\u5728\u76D8\u4E0A**\uFF08\u672C\u5C42\u521A\u67E5\u8FC7\uFF09\u2014\u2014\u6240\u4EE5\u6CA1\u6709\u300C\u5DF2\u7ECF\u8BB0\u4E0B\u6765\u7684\u5199\u300D\u53EF\u4EE5\u62FF\u3002`;
22068
22506
  }
22069
22507
  return ` \u53F0\u8D26\u5728 \`${journalPath}\`\u3002${whenPresent}`;
@@ -22099,7 +22537,7 @@ function existingJournalStop(journalPath, entries) {
22099
22537
  }
22100
22538
 
22101
22539
  // src/fde/seed/plan-io.ts
22102
- import * as path17 from "path";
22540
+ import * as path18 from "path";
22103
22541
  var PLAN_JSON_KEYS = [
22104
22542
  "version",
22105
22543
  "roundId",
@@ -22125,9 +22563,9 @@ function fromArtifactProblem(p) {
22125
22563
  async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22126
22564
  const baseline = options.baseline ?? null;
22127
22565
  const loadIndex = options.loadKeyIndexImpl ?? loadKeyIndex;
22128
- const mapping = loadMapping(mappingPath);
22129
- const scan = await scanSources(mapping, sourceDir);
22130
- const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
22566
+ const mapping2 = loadMapping(mappingPath);
22567
+ const scan = await scanSources(mapping2, sourceDir);
22568
+ const problems = [...scan.problems, ...validateMapping(mapping2, scan.headers)];
22131
22569
  if (problems.length) {
22132
22570
  const converted = problems.map(fromArtifactProblem);
22133
22571
  converted.push({
@@ -22150,7 +22588,7 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22150
22588
  }
22151
22589
  const indexes = /* @__PURE__ */ new Map();
22152
22590
  const indexErrors = /* @__PURE__ */ new Map();
22153
- for (const mm of mapping.models) {
22591
+ for (const mm of mapping2.models) {
22154
22592
  if (mm.businessKey === null || !mm.businessKey.fields.length) continue;
22155
22593
  try {
22156
22594
  indexes.set(mm.model, await loadIndex(client, mm.model, [...mm.businessKey.fields]));
@@ -22159,7 +22597,7 @@ async function planFromArtifacts(client, mappingPath, sourceDir, options = {}) {
22159
22597
  indexErrors.set(mm.model, e.hint ? e.message : `${e.message} \u2014\u2014 \u5148\u628A\u53D6\u6570\u95EE\u9898\u89E3\u51B3\u518D\u8DD1\u4E00\u6B21`);
22160
22598
  }
22161
22599
  }
22162
- return buildImportPlan(mapping, scan.rows, indexes, {
22600
+ return buildImportPlan(mapping2, scan.rows, indexes, {
22163
22601
  notes: [...scan.notes],
22164
22602
  indexErrors,
22165
22603
  baseline
@@ -22236,7 +22674,7 @@ var PlanReadError = class extends Error {
22236
22674
  };
22237
22675
  function readImportPlan(out) {
22238
22676
  const work = new WorkLayout(out);
22239
- const target = path17.join(out, IMPORT_PLAN_FILE);
22677
+ const target = path18.join(out, IMPORT_PLAN_FILE);
22240
22678
  if (!work.exists(IMPORT_PLAN_FILE)) {
22241
22679
  throw new PlanReadError(
22242
22680
  "plan-missing",
@@ -22428,9 +22866,9 @@ function rowFromJson(r) {
22428
22866
 
22429
22867
  // src/fde/seed/journal.ts
22430
22868
  import { createHash as createHash4 } from "crypto";
22431
- import { existsSync as existsSync9, statSync as statSync8 } from "fs";
22869
+ import { existsSync as existsSync8, statSync as statSync7 } from "fs";
22432
22870
  import * as os3 from "os";
22433
- import * as path18 from "path";
22871
+ import * as path19 from "path";
22434
22872
  var JOURNAL_FILE = "journal.jsonl";
22435
22873
  var STATUSES = ["done", "skipped", "failed", "unknown", "quarantined"];
22436
22874
  var STEP_SEND = "send";
@@ -22677,7 +23115,7 @@ function waiverFromJson(row, where) {
22677
23115
  };
22678
23116
  }
22679
23117
  function workDirOf(p) {
22680
- if (existsSync9(p) && !statSync8(p).isDirectory()) {
23118
+ if (existsSync8(p) && !statSync7(p).isDirectory()) {
22681
23119
  throw new JournalError(
22682
23120
  "not-a-work-dir",
22683
23121
  `${p} \u5DF2\u5B58\u5728\uFF0C\u4F46\u5B83\u4E0D\u662F\u76EE\u5F55 \u2014\u2014 \u53F0\u8D26\u6536\u7684\u662F **work \u76EE\u5F55**\uFF0C\u4E0D\u662F\u53F0\u8D26\u6587\u4EF6`,
@@ -22704,7 +23142,7 @@ var Journal = class _Journal {
22704
23142
  constructor(workDir, entries = [], exists = false, waivers = []) {
22705
23143
  this.workDir = workDirOf(workDir);
22706
23144
  this.layout = new WorkLayout(this.workDir);
22707
- this.path = path18.join(this.workDir, JOURNAL_FILE);
23145
+ this.path = path19.join(this.workDir, JOURNAL_FILE);
22708
23146
  this.entries = [...entries];
22709
23147
  this.waivers = [...waivers];
22710
23148
  this.exists = exists;
@@ -22718,8 +23156,8 @@ var Journal = class _Journal {
22718
23156
  */
22719
23157
  static load(p) {
22720
23158
  const work = workDirOf(p);
22721
- const target = path18.join(work, JOURNAL_FILE);
22722
- if (!existsSync9(target)) return new _Journal(work, [], false);
23159
+ const target = path19.join(work, JOURNAL_FILE);
23160
+ if (!existsSync8(target)) return new _Journal(work, [], false);
22723
23161
  let text3;
22724
23162
  try {
22725
23163
  text3 = new WorkLayout(work).readText(JOURNAL_FILE);
@@ -23014,8 +23452,8 @@ function sameIdentity(a, b) {
23014
23452
  return a.length === b.length && a.every((x, i) => x === b[i]);
23015
23453
  }
23016
23454
  function readLease(layout, file = LEASE_FILE) {
23017
- const p = path18.join(layout.dir, file);
23018
- if (!existsSync9(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
23455
+ const p = path19.join(layout.dir, file);
23456
+ if (!existsSync8(p)) return [null, `${p} \u4E0D\u5B58\u5728`];
23019
23457
  let text3;
23020
23458
  try {
23021
23459
  text3 = layout.readText(file);
@@ -23073,7 +23511,7 @@ var Lease = class {
23073
23511
  beatMark;
23074
23512
  constructor(layout, spec, reclaimed = null, clock = SYSTEM_CLOCK) {
23075
23513
  this.layout = layout;
23076
- this.path = path18.join(layout.dir, LEASE_FILE);
23514
+ this.path = path19.join(layout.dir, LEASE_FILE);
23077
23515
  this.host = spec.host;
23078
23516
  this.pid = spec.pid;
23079
23517
  this.roundId = spec.roundId;
@@ -23141,7 +23579,7 @@ var Lease = class {
23141
23579
  throw new LeaseViolation(
23142
23580
  "lease-unwritable",
23143
23581
  `\u76D6\u5FC3\u8DF3\u65F6\u5199\u4E0D\u8FDB\u79DF\u7EA6\u6587\u4EF6 ${this.path}\uFF1A${String(e)}`,
23144
- `**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path18.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
23582
+ `**\u8FD9\u4E00\u6B21\u5FC3\u8DF3\u6CA1\u6709\u76D6\u4E0A**\uFF0C\u79DF\u7EA6\u6587\u4EF6\u7684\u5185\u5BB9**\u6CA1\u6709\u88AB\u6539\u52A8**\uFF08\u4E34\u65F6\u6587\u4EF6\u5DF2\u6536\u62FE\u6389\uFF0C\u6539\u540D\u6CA1\u9876\u4E0A\u53BB\uFF09\u3002${leaseStampNote(held.heartbeatAt, beat, attemptedAt)}\u5199\u4E4B\u524D\u521A\u6838\u5BF9\u8FC7\u8EAB\u4EFD \u2014\u2014 **\u90A3\u4E00\u6B21\u8BFB\u5230\u7684**\u79DF\u7EA6\u662F\u6211\u65B9\u7684\u3002\u4E09\u79CD\u5E38\u89C1\u6210\u56E0\uFF1A\u2460 \u78C1\u76D8\u6EE1\uFF1B\u2461 \u76EE\u5F55\u53EA\u8BFB\u6216\u6743\u9650\u4E0D\u8DB3\uFF1B\u2462 \u4ECB\u8D28\u51FA\u9519\u3002**\u5148\u505C\u624B\u518D\u5904\u7406**\uFF1A\u5DF2\u7ECF\u53D1\u51FA\u53BB\u7684\u5199\u90FD\u8BB0\u5728 ${path19.dirname(this.path)} \u7684\u53F0\u8D26\u91CC\uFF08\u5199\u524D\u843D\u8D26\uFF1A\u53D1\u8BF7\u6C42\u4E4B\u524D\u5148 begin \u843D\u4E00\u6761 unknown\uFF09\u3002${LEASE_JUDGE_SIGNPOST}`
23145
23583
  );
23146
23584
  }
23147
23585
  this.beatMark = this.clock.monotonic();
@@ -23187,7 +23625,7 @@ function acquireLease(workDir, roundId, clock = SYSTEM_CLOCK) {
23187
23625
  );
23188
23626
  }
23189
23627
  const layout = new WorkLayout(workDirOf(workDir));
23190
- const p = path18.join(layout.dir, LEASE_FILE);
23628
+ const p = path19.join(layout.dir, LEASE_FILE);
23191
23629
  const me = [hostname2(), process.pid, roundId];
23192
23630
  const now = clock.now();
23193
23631
  const fresh = new Lease(
@@ -23389,7 +23827,7 @@ var ACTION_HINTS = {
23389
23827
  function listed2(items, total) {
23390
23828
  return `${items.slice(0, MAX_LISTED3).join("\uFF1B")}${total > MAX_LISTED3 ? `\u2026\uFF08\u5171 ${total} \u6761\uFF09` : ""}`;
23391
23829
  }
23392
- function preflight(plan, mapping) {
23830
+ function preflight(plan, mapping2) {
23393
23831
  const out = [];
23394
23832
  if (plan.problems.length > 0) {
23395
23833
  const codes = [...new Set(plan.problems.map((p) => p.code))].sort();
@@ -23403,7 +23841,7 @@ function preflight(plan, mapping) {
23403
23841
  );
23404
23842
  }
23405
23843
  const plannedModels = plan.models.map((m) => m.model);
23406
- const artifactModels = mapping.models.map((m) => m.model);
23844
+ const artifactModels = mapping2.models.map((m) => m.model);
23407
23845
  if (JSON.stringify(plannedModels) !== JSON.stringify(artifactModels)) {
23408
23846
  out.push(
23409
23847
  problem4(
@@ -23415,7 +23853,7 @@ function preflight(plan, mapping) {
23415
23853
  );
23416
23854
  } else {
23417
23855
  plan.models.forEach((modelPlan, i) => {
23418
- const declared = mapping.models[i].businessKey?.fields ?? [];
23856
+ const declared = mapping2.models[i].businessKey?.fields ?? [];
23419
23857
  if (JSON.stringify(modelPlan.businessKeyFields) !== JSON.stringify([...declared])) {
23420
23858
  out.push(
23421
23859
  problem4(
@@ -23892,7 +24330,7 @@ async function applyRow(client, plan, modelPlan, row, journal, createdIds, tally
23892
24330
  tally.add("requests");
23893
24331
  return judgeCreate(client, out, plan, modelPlan, row, journal, createdIds, tally, problems, sample);
23894
24332
  }
23895
- async function applyPlan(client, plan, mapping, journal, options = {}) {
24333
+ async function applyPlan(client, plan, mapping2, journal, options = {}) {
23896
24334
  const dryRun = options.dryRun ?? true;
23897
24335
  const sample = options.sample ?? null;
23898
24336
  const onRequestSpent = options.onRequestSpent ?? null;
@@ -23917,7 +24355,7 @@ async function applyPlan(client, plan, mapping, journal, options = {}) {
23917
24355
  "\u5B83\u662F\u6BCF\u82B1\u6389\u4E00\u6B21\u8BF7\u6C42\u8981\u76D6\u7684\u90A3\u4E00\u6B21\u7AE0\uFF08\u751F\u4EA7\u4E0A = `Lease.heartbeatIfDue`\uFF09\u3002\u4E0D\u60F3\u76D6\u5C31\u4F20 null \u2014\u2014 \u4F20\u4E00\u4E2A\u8C03\u4E0D\u52A8\u7684\u4E1C\u897F\u4F1A\u5728\u7B2C\u4E00\u6B21\u8BF7\u6C42\u53D1\u51FA\u53BB\u4E4B\u540E\u70B8\u5728\u534A\u8DEF\u4E0A\uFF0C\u800C\u90A3\u4E00\u6B21\u8BF7\u6C42\u5DF2\u7ECF\u51FA\u53BB\u4E86"
23918
24356
  );
23919
24357
  }
23920
- const problems = preflight(plan, mapping);
24358
+ const problems = preflight(plan, mapping2);
23921
24359
  if (problems.length > 0) {
23922
24360
  return reportOf(plan, dryRun, sample, false, "preflight", [], new Tally(), problems);
23923
24361
  }
@@ -24009,8 +24447,8 @@ function applyReportText(report) {
24009
24447
  }
24010
24448
 
24011
24449
  // src/fde/seed/drift.ts
24012
- import { existsSync as existsSync10, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync9 } from "fs";
24013
- import * as path19 from "path";
24450
+ import { existsSync as existsSync9, readFileSync as readFileSync8, realpathSync as realpathSync2, statSync as statSync8 } from "fs";
24451
+ import * as path20 from "path";
24014
24452
  var VERDICT_SAME = "same";
24015
24453
  var VERDICT_DIVERGED = "diverged";
24016
24454
  var VERDICT_INCOMPARABLE = "incomparable";
@@ -24037,21 +24475,21 @@ function resolveBaselineDir(outRoot, baselineRef) {
24037
24475
  return [null, CAUSE_PLAN_HAS_NO_BASELINE];
24038
24476
  }
24039
24477
  const ref = String(baselineRef);
24040
- const root = path19.join(outRoot, RECON_DIRNAME);
24478
+ const root = path20.join(outRoot, RECON_DIRNAME);
24041
24479
  const parts = ref.split(/[\\/]+/);
24042
- if (!ref || parts.includes("..") || path19.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
24480
+ if (!ref || parts.includes("..") || path20.isAbsolute(ref) || /^[A-Za-z]:/.test(ref)) {
24043
24481
  return [null, CAUSE_BASELINE_NOT_ON_DISK];
24044
24482
  }
24045
- const base = path19.join(root, ref);
24483
+ const base = path20.join(root, ref);
24046
24484
  let inside;
24047
24485
  try {
24048
24486
  const realRoot = realpathSync2(root);
24049
24487
  const realBase = realpathSync2(base);
24050
- inside = realBase === realRoot || realBase.startsWith(realRoot + path19.sep);
24488
+ inside = realBase === realRoot || realBase.startsWith(realRoot + path20.sep);
24051
24489
  } catch {
24052
24490
  inside = false;
24053
24491
  }
24054
- if (!inside || !existsSync10(base) || !statSync9(base).isDirectory()) {
24492
+ if (!inside || !existsSync9(base) || !statSync8(base).isDirectory()) {
24055
24493
  return [null, CAUSE_BASELINE_NOT_ON_DISK];
24056
24494
  }
24057
24495
  return [base, null];
@@ -24061,7 +24499,7 @@ function loadRecordedFingerprint(outRoot, baselineRef) {
24061
24499
  if (cause !== null) return [null, cause];
24062
24500
  let body;
24063
24501
  try {
24064
- body = JSON.parse(readFileSync8(path19.join(base, FINGERPRINT_FILE), "utf-8"));
24502
+ body = JSON.parse(readFileSync8(path20.join(base, FINGERPRINT_FILE), "utf-8"));
24065
24503
  } catch {
24066
24504
  return [null, CAUSE_FINGERPRINT_UNREADABLE];
24067
24505
  }
@@ -24812,11 +25250,11 @@ function fromArtifactProblem2(p) {
24812
25250
  };
24813
25251
  }
24814
25252
  async function riskFromArtifacts(mappingPath, reconDir, options = {}) {
24815
- const mapping = loadMapping(mappingPath);
24816
- const scan = await scanSources(mapping, options.sourceDir);
24817
- const problems = [...scan.problems, ...validateMapping(mapping, scan.headers)];
25253
+ const mapping2 = loadMapping(mappingPath);
25254
+ const scan = await scanSources(mapping2, options.sourceDir);
25255
+ const problems = [...scan.problems, ...validateMapping(mapping2, scan.headers)];
24818
25256
  if (problems.length === 0) {
24819
- return buildRisk(mapping, reconDir, {
25257
+ return buildRisk(mapping2, reconDir, {
24820
25258
  notes: [...scan.notes],
24821
25259
  tables: scan.rows,
24822
25260
  exemptions: options.exemptions,
@@ -24910,8 +25348,8 @@ function writeRisk(risk, out) {
24910
25348
  }
24911
25349
 
24912
25350
  // src/fde/seed/value-hints.ts
24913
- import { existsSync as existsSync11, readFileSync as readFileSync9 } from "fs";
24914
- import * as path20 from "path";
25351
+ import { existsSync as existsSync10, readFileSync as readFileSync9 } from "fs";
25352
+ import * as path21 from "path";
24915
25353
  var HINT_REF = (domain) => ` \u503C\uFF1A\u586B id\uFF08\u4E0D\u662F code\uFF09\u2190 ${domain}`;
24916
25354
  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`;
24917
25355
  var HINT_ENUM = (n, model) => ` \u503C\uFF1A\u679A\u4E3E ${n} \u9879 \u2190 mapping/${model}.json`;
@@ -24927,7 +25365,7 @@ function isLocalName(name) {
24927
25365
  if (typeof name !== "string" || name.length === 0) return false;
24928
25366
  if (name.includes("/") || name.includes("\\")) return false;
24929
25367
  if (name === "." || name === "..") return false;
24930
- return !path20.isAbsolute(name);
25368
+ return !path21.isAbsolute(name);
24931
25369
  }
24932
25370
  var readJson = (file) => {
24933
25371
  try {
@@ -24947,7 +25385,7 @@ var ValueHints = class {
24947
25385
  /** → `{modelKey: completeness}`;**索引根本读不到时返回 `null`**(与「读到了但是空的」分开)。 */
24948
25386
  domainIndex() {
24949
25387
  if (this.domains === void 0) {
24950
- const body = readJson(path20.join(this.root, "valuedomain", "_index.json"));
25388
+ const body = readJson(path21.join(this.root, "valuedomain", "_index.json"));
24951
25389
  const by = isRec(body) ? body.byCompleteness : void 0;
24952
25390
  if (!isRec(by)) {
24953
25391
  this.domains = null;
@@ -24968,7 +25406,7 @@ var ValueHints = class {
24968
25406
  if (!this.sheets.has(key)) {
24969
25407
  let fields = null;
24970
25408
  if (isLocalName(key)) {
24971
- const body = readJson(path20.join(this.root, "mapping", `${key}.json`));
25409
+ const body = readJson(path21.join(this.root, "mapping", `${key}.json`));
24972
25410
  const rows = isRec(body) ? body.fields : void 0;
24973
25411
  if (Array.isArray(rows)) {
24974
25412
  fields = /* @__PURE__ */ new Map();
@@ -24986,7 +25424,7 @@ var ValueHints = class {
24986
25424
  const index = this.domainIndex();
24987
25425
  const completeness = index === null ? void 0 : index.get(target);
24988
25426
  const pointer = ref.valueDomain;
24989
- const landed = isLocalName(target) && existsSync11(path20.join(this.root, "valuedomain", `${target}.json`));
25427
+ const landed = isLocalName(target) && existsSync10(path21.join(this.root, "valuedomain", `${target}.json`));
24990
25428
  let line;
24991
25429
  if (pointer && completeness && completeness !== "unavailable" && landed) {
24992
25430
  line = HINT_REF(String(pointer));
@@ -25176,8 +25614,8 @@ function renderFind(hits, term, total, options = {}) {
25176
25614
  }
25177
25615
 
25178
25616
  // src/fde/seed/values.ts
25179
- import { existsSync as existsSync12, readFileSync as readFileSync10 } from "fs";
25180
- import * as path21 from "path";
25617
+ import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
25618
+ import * as path22 from "path";
25181
25619
  var readJson2 = (file) => {
25182
25620
  try {
25183
25621
  return JSON.parse(readFileSync10(file, "utf-8"));
@@ -25224,13 +25662,13 @@ function valuesRoundCaveat(round) {
25224
25662
  return VALUES_ROUND_MIXED(String(state ?? "unknown"));
25225
25663
  }
25226
25664
  function renderValues(root, model, options = {}) {
25227
- const indexBody = readJson2(path21.join(root, "valuedomain", "_index.json"));
25665
+ const indexBody = readJson2(path22.join(root, "valuedomain", "_index.json"));
25228
25666
  const byCompleteness = isRec2(indexBody) ? indexBody.byCompleteness : void 0;
25229
25667
  if (!isRec2(byCompleteness)) {
25230
25668
  return {
25231
25669
  ok: false,
25232
25670
  kind: "index-unreadable",
25233
- 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 ${path21.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
25671
+ 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 ${path22.join(root, "valuedomain")}\` \u770B\u4E00\u773C\uFF1B\u786E\u5B9E\u6CA1\u6709\u5C31\u91CD\u8DD1\u4E00\u6B21 recon\u3002`
25234
25672
  };
25235
25673
  }
25236
25674
  let completeness;
@@ -25241,7 +25679,7 @@ function renderValues(root, model, options = {}) {
25241
25679
  }
25242
25680
  }
25243
25681
  if (completeness === void 0) {
25244
- if (isLocalName(model) && existsSync12(path21.join(root, "mapping", `${model}.json`))) {
25682
+ if (isLocalName(model) && existsSync11(path22.join(root, "mapping", `${model}.json`))) {
25245
25683
  return {
25246
25684
  ok: false,
25247
25685
  kind: "not-a-code-table",
@@ -25251,11 +25689,11 @@ function renderValues(root, model, options = {}) {
25251
25689
  return {
25252
25690
  ok: false,
25253
25691
  kind: "model-not-in-baseline",
25254
- message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path21.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
25692
+ message: `\u57FA\u7EBF\u91CC\u6CA1\u6709\u8FD9\u4E2A\u6A21\u578B\uFF1A${model}\u3002\`ls ${path22.join(root, "mapping")}\` \u770B\u6709\u54EA\u4E9B\u3002`
25255
25693
  };
25256
25694
  }
25257
- const file = path21.join(root, "valuedomain", `${model}.json`);
25258
- if (!isLocalName(model) || !existsSync12(file)) {
25695
+ const file = path22.join(root, "valuedomain", `${model}.json`);
25696
+ if (!isLocalName(model) || !existsSync11(file)) {
25259
25697
  return {
25260
25698
  ok: false,
25261
25699
  kind: "file-missing",
@@ -25324,7 +25762,7 @@ var CARRIER_LABELS = {
25324
25762
  "graaljs-spi": "GraalJS SPI \u2014\u2014 \u5F00\u53D1\u7A7A\u95F4\u91CC\u7684\u79DF\u6237\u6269\u5C55\u811A\u672C",
25325
25763
  "flex-data": "\u5F39\u6027\u5B57\u6BB5 \u2014\u2014 \u6302\u5728\u65E2\u6709\u6A21\u578B\u4E0A\u7684\u79DF\u6237\u81EA\u5B9A\u4E49\u5B57\u6BB5",
25326
25764
  "indicator-dashboard": "\u6307\u6807/\u770B\u677F \u2014\u2014 \u6307\u6807\u5E93\u3001\u76EE\u6807\u9608\u503C\u4E0E\u770B\u677F\u5B9A\u4E49\uFF0C\u5206\u6790\u5C42\u7684\u627F\u8F7D\u7269",
25327
- "data-package": "DataPackage \u2014\u2014 \u53EF\u590D\u5236\u7684\u573A\u666F\u6570\u636E\u5305"
25765
+ "data-package": "\u5B89\u88C5\u5305 \u2014\u2014 \u6269\u5C55\u8D44\u4EA7\u4E0E\u53EF\u590D\u5236\u7684\u573A\u666F\u6570\u636E"
25328
25766
  };
25329
25767
  var CARRIER_HIT = "hit";
25330
25768
  var CARRIER_MISS = "miss";
@@ -25369,7 +25807,7 @@ function buildCarrierResult(carrier, verdict2, options = {}) {
25369
25807
 
25370
25808
  // src/fde/triage/probe.ts
25371
25809
  import { readFileSync as readFileSync11 } from "fs";
25372
- import * as path22 from "path";
25810
+ import * as path23 from "path";
25373
25811
  var WORKSPACES_PATH = "/api/tenant-extension/workspaces";
25374
25812
  var MODELS_REL = "models.json";
25375
25813
  var FIELDS_REL = "index/fields.jsonl";
@@ -25396,10 +25834,10 @@ function unavailableCell(carrier, err) {
25396
25834
  });
25397
25835
  }
25398
25836
  function readArtifactJson(dir, rel) {
25399
- return JSON.parse(readFileSync11(path22.join(dir, rel), "utf8"));
25837
+ return JSON.parse(readFileSync11(path23.join(dir, rel), "utf8"));
25400
25838
  }
25401
25839
  function readArtifactJsonl(dir, rel) {
25402
- const body = readFileSync11(path22.join(dir, rel), "utf8");
25840
+ const body = readFileSync11(path23.join(dir, rel), "utf8");
25403
25841
  const rows = [];
25404
25842
  for (const line of body.split("\n")) {
25405
25843
  const trimmed = line.trim();
@@ -25453,8 +25891,8 @@ function probeFlexModel(catalog) {
25453
25891
  }
25454
25892
  return buildCarrierResult("flex-model", CARRIER_HIT, { evidence: hits.slice(0, 20) });
25455
25893
  }
25456
- function isReadOnly(mapping) {
25457
- const mut = mapping && typeof mapping === "object" ? mapping.mutation : null;
25894
+ function isReadOnly(mapping2) {
25895
+ const mut = mapping2 && typeof mapping2 === "object" ? mapping2.mutation : null;
25458
25896
  if (!mut || typeof mut !== "object") return false;
25459
25897
  for (const op of WRITE_OPS) {
25460
25898
  const cell = mut[op];
@@ -25474,13 +25912,13 @@ function probeJsonModel(dir) {
25474
25912
  for (const row of rows) {
25475
25913
  const key = entryKey(row);
25476
25914
  if (key === null) continue;
25477
- let mapping;
25915
+ let mapping2;
25478
25916
  try {
25479
- mapping = readArtifactJson(dir, `mapping/${key}.json`);
25917
+ mapping2 = readArtifactJson(dir, `mapping/${key}.json`);
25480
25918
  } catch {
25481
25919
  continue;
25482
25920
  }
25483
- if (isReadOnly(mapping)) hits.push(key);
25921
+ if (isReadOnly(mapping2)) hits.push(key);
25484
25922
  }
25485
25923
  if (hits.length === 0) {
25486
25924
  return buildCarrierResult("json-model", CARRIER_MISS, {
@@ -25552,12 +25990,12 @@ function probeDataPackage(catalog) {
25552
25990
  const missing = DATA_PACKAGE_MODELS.filter((m) => !present.has(m));
25553
25991
  if (missing.length > 0) {
25554
25992
  return buildCarrierResult("data-package", CARRIER_MISS, {
25555
- note: `\u6A21\u578B\u6E05\u5355\u91CC\u6CA1\u6709 ${missing.join("\u3001")} \u2014\u2014 \u8FD9\u4E2A\u73AF\u5883\u4E0A\u8D70\u4E0D\u4E86\u6570\u636E\u5305\u8FD9\u6761\u8DEF`
25993
+ note: `\u6A21\u578B\u6E05\u5355\u91CC\u6CA1\u6709 ${missing.join("\u3001")} \u2014\u2014 \u8FD9\u4E2A\u73AF\u5883\u4E0A\u8D70\u4E0D\u4E86\u5B89\u88C5\u5305\u8FD9\u6761\u8DEF`
25556
25994
  });
25557
25995
  }
25558
25996
  return buildCarrierResult("data-package", CARRIER_HIT, {
25559
25997
  evidence: [...DATA_PACKAGE_MODELS],
25560
- note: "\u88C5\u5305\u8D70 `hcm datapackage pack` \u2192 `install`\uFF08Action \u901A\u9053 DataPackage.installFromDocument\uFF09\uFF0C\u88C5\u8F7D\u7ED3\u679C\u770B DataPackageInstallRun"
25998
+ note: "\u88C5\u5305\u8D70 `hcm package pack` \u2192 `install`\uFF08Action \u901A\u9053 DataPackage.installFromDocumentAsync\uFF09\uFF0C\u88C5\u8F7D\u7ED3\u679C\u770B DataPackageInstallRun"
25561
25999
  });
25562
26000
  }
25563
26001
  async function probeAll(client, artifactsDir) {
@@ -26484,19 +26922,19 @@ import { execFile } from "child_process";
26484
26922
  import { promisify } from "util";
26485
26923
  import { promises as fs12 } from "fs";
26486
26924
  import os4 from "os";
26487
- import path23 from "path";
26925
+ import path24 from "path";
26488
26926
 
26489
26927
  // src/jira/http-error.ts
26490
26928
  var JiraHttpError = class extends Error {
26491
26929
  status;
26492
26930
  method;
26493
26931
  path;
26494
- constructor(status, method, path24, message) {
26932
+ constructor(status, method, path25, message) {
26495
26933
  super(message);
26496
26934
  this.name = "JiraHttpError";
26497
26935
  this.status = status;
26498
26936
  this.method = method;
26499
- this.path = path24;
26937
+ this.path = path25;
26500
26938
  }
26501
26939
  };
26502
26940
 
@@ -26516,21 +26954,21 @@ var BMP_REPLACEMENTS = {
26516
26954
  var isIdeographic = (cp) => cp >= 131072 && cp <= 262143;
26517
26955
  var asCodePoint = (cp) => `U+${cp.toString(16).toUpperCase()}`;
26518
26956
  var NON_BMP_RULE_NOTE = "\u5224\u636E\u662F\u7801\u70B9 > U+FFFF\uFF0C\u4E0D\u662F\u300C\u662F\u4E0D\u662F emoji\u300D\uFF1A\u2705 \u26A0 \u274C \u8FD9\u4E9B BMP \u7B26\u53F7 Jira \u7167\u6536";
26519
- function findNonBmpChars(value, path24 = "") {
26957
+ function findNonBmpChars(value, path25 = "") {
26520
26958
  if (typeof value === "string") {
26521
26959
  const hits = [];
26522
26960
  let index = 0;
26523
26961
  for (const char of value) {
26524
26962
  const cp = char.codePointAt(0);
26525
- if (cp > 65535) hits.push({ path: path24, index, char, codePoint: asCodePoint(cp) });
26963
+ if (cp > 65535) hits.push({ path: path25, index, char, codePoint: asCodePoint(cp) });
26526
26964
  index += 1;
26527
26965
  }
26528
26966
  return hits;
26529
26967
  }
26530
- if (Array.isArray(value)) return value.flatMap((item, i) => findNonBmpChars(item, `${path24}[${i}]`));
26968
+ if (Array.isArray(value)) return value.flatMap((item, i) => findNonBmpChars(item, `${path25}[${i}]`));
26531
26969
  if (value && typeof value === "object") {
26532
26970
  return Object.entries(value).flatMap(
26533
- ([key, item]) => findNonBmpChars(item, path24 ? `${path24}.${key}` : key)
26971
+ ([key, item]) => findNonBmpChars(item, path25 ? `${path25}.${key}` : key)
26534
26972
  );
26535
26973
  }
26536
26974
  return [];
@@ -26560,23 +26998,23 @@ function describeNonBmpHits(hits) {
26560
26998
  }
26561
26999
  var JiraNonBmpContentError = class extends Error {
26562
27000
  hits;
26563
- constructor(hits, method, path24) {
26564
- super(`Jira ${method} ${path24} \u6CA1\u6709\u53D1\u51FA\uFF1A${describeNonBmpHits(hits)}`);
27001
+ constructor(hits, method, path25) {
27002
+ super(`Jira ${method} ${path25} \u6CA1\u6709\u53D1\u51FA\uFF1A${describeNonBmpHits(hits)}`);
26565
27003
  this.name = "JiraNonBmpContentError";
26566
27004
  this.hits = hits;
26567
27005
  }
26568
27006
  };
26569
27007
 
26570
27008
  // src/jira/client.ts
26571
- var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path23.join(os4.homedir(), ".config", "hcm", "jira-token");
27009
+ var JIRA_TOKEN_FILE = () => process.env.JIRA_TOKEN_FILE || path24.join(os4.homedir(), ".config", "hcm", "jira-token");
26572
27010
  async function jiraTokenSource(opts = {}) {
26573
27011
  if (process.env.JIRA_TOKEN?.trim()) return { kind: "token", source: { token: process.env.JIRA_TOKEN.trim(), from: "\u73AF\u5883\u53D8\u91CF JIRA_TOKEN" } };
26574
27012
  const file = JIRA_TOKEN_FILE();
26575
27013
  try {
26576
- const stat = await fs12.stat(file);
27014
+ const stat2 = await fs12.stat(file);
26577
27015
  const value = (await fs12.readFile(file, "utf8")).trim();
26578
27016
  if (value) {
26579
- if (stat.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
27017
+ if (stat2.mode & 63) process.stderr.write(`[jira] \u8B66\u544A\uFF1A${file} \u5BF9\u5176\u4ED6\u7528\u6237\u53EF\u8BFB\uFF08chmod 600 \u6536\u7D27\uFF09
26580
27018
  `);
26581
27019
  return { kind: "token", source: { token: value, from: file } };
26582
27020
  }
@@ -26753,11 +27191,11 @@ var JiraClient = class {
26753
27191
  }
26754
27192
  /** 按流转 id / 流转名 / 目标状态名三种写法找;找不到把可用流转列出来,不猜。 */
26755
27193
  async transition(key, nameOrId, comment) {
26756
- const list = await this.transitions(key);
26757
- const hit = list.find((t) => t.id === String(nameOrId)) || list.find((t) => t.name === nameOrId) || list.find((t) => t.to?.name === nameOrId);
27194
+ const list2 = await this.transitions(key);
27195
+ const hit = list2.find((t) => t.id === String(nameOrId)) || list2.find((t) => t.name === nameOrId) || list2.find((t) => t.to?.name === nameOrId);
26758
27196
  if (!hit) {
26759
27197
  throw new Error(
26760
- `${key} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
27198
+ `${key} \u4E0A\u6CA1\u6709\u5230\u300C${nameOrId}\u300D\u7684\u6D41\u8F6C\u3002\u53EF\u7528\uFF1A${list2.map((t) => `${t.name}\u2192${t.to?.name}`).join(" / ") || "\uFF08\u65E0\uFF09"}`
26761
27199
  );
26762
27200
  }
26763
27201
  await this.transitionById(key, hit.id, comment);
@@ -26787,10 +27225,10 @@ var JiraClient = class {
26787
27225
  * Jira 9 起旧的 `createmeta?projectKeys=&expand=` 已移除(11.3.2 实测 404),用按 issuetype 分页的新接口。
26788
27226
  */
26789
27227
  async createMeta(project = this.project) {
26790
- const list = await this.api(
27228
+ const list2 = await this.api(
26791
27229
  `/rest/api/2/issue/createmeta/${project}/issuetypes`
26792
27230
  );
26793
- const types = list.values ?? list.issueTypes ?? [];
27231
+ const types = list2.values ?? list2.issueTypes ?? [];
26794
27232
  const out = [];
26795
27233
  for (const t of types) {
26796
27234
  if (t.subtask) continue;
@@ -26969,6 +27407,7 @@ export {
26969
27407
  IMPERSONATION_START_PATH,
26970
27408
  IMPORT_PLAN_FILE,
26971
27409
  INIT_EXIT_CODES,
27410
+ INSTALL_CONFIRMATION_HINTS,
26972
27411
  JIRA_BASE,
26973
27412
  JIRA_KEYCHAIN,
26974
27413
  JIRA_PROJECT,