@kevlns/v-cli 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/sdk.mjs CHANGED
@@ -903,24 +903,24 @@ function resolveBindings(project, config, providers) {
903
903
  return { ok: true, bindings: result };
904
904
  }
905
905
  function loadProjectConfig(project, providers) {
906
- const file = path2.join(project.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
906
+ const file2 = path2.join(project.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
907
907
  const initHint = `\u8BF7\u5148\u5728\u5DE5\u7A0B\u6839\u8FD0\u884C \`v-cli project init --project <\u5DE5\u7A0B\u6839>\` \u751F\u6210 ${PROJECT_CLI_CONFIG_RELATIVE}`;
908
908
  let text;
909
909
  try {
910
910
  resolveInsideProject(project, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
911
- text = fs2.readFileSync(file, "utf-8");
911
+ text = fs2.readFileSync(file2, "utf-8");
912
912
  } catch (err) {
913
913
  if (err instanceof Error && "code" in err && String(err.code).startsWith("path-")) {
914
- return { ok: false, file, kind: "unsafe-binding", errors: [err.message], hint: "\u914D\u7F6E\u6587\u4EF6\u5FC5\u987B\u4F4D\u4E8E\u5DE5\u7A0B\u6839\u5185\uFF0C\u7981\u6B62\u7B26\u53F7\u94FE\u63A5" };
914
+ return { ok: false, file: file2, kind: "unsafe-binding", errors: [err.message], hint: "\u914D\u7F6E\u6587\u4EF6\u5FC5\u987B\u4F4D\u4E8E\u5DE5\u7A0B\u6839\u5185\uFF0C\u7981\u6B62\u7B26\u53F7\u94FE\u63A5" };
915
915
  }
916
916
  if (err instanceof Error && "code" in err && err.code === "ENOENT") {
917
- return { ok: false, file, kind: "missing", errors: [], hint: initHint };
917
+ return { ok: false, file: file2, kind: "missing", errors: [], hint: initHint };
918
918
  }
919
919
  return {
920
920
  ok: false,
921
- file,
921
+ file: file2,
922
922
  kind: "invalid",
923
- errors: [`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${file}: ${err instanceof Error ? err.message : String(err)}`],
923
+ errors: [`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${file2}: ${err instanceof Error ? err.message : String(err)}`],
924
924
  hint: "\u8BF7\u68C0\u67E5\u914D\u7F6E\u6587\u4EF6\u6743\u9650\u540E\u91CD\u8BD5"
925
925
  };
926
926
  }
@@ -930,7 +930,7 @@ function loadProjectConfig(project, providers) {
930
930
  } catch (err) {
931
931
  return {
932
932
  ok: false,
933
- file,
933
+ file: file2,
934
934
  kind: "invalid",
935
935
  errors: [`\u4E0D\u662F\u5408\u6CD5 JSON: ${err instanceof Error ? err.message : String(err)}`],
936
936
  hint: "\u8BF7\u4FEE\u6B63\u914D\u7F6E\u6587\u4EF6\u5185\u5BB9\u540E\u91CD\u8BD5"
@@ -940,7 +940,7 @@ function loadProjectConfig(project, providers) {
940
940
  if (shellErrors.length > 0) {
941
941
  return {
942
942
  ok: false,
943
- file,
943
+ file: file2,
944
944
  kind: "invalid",
945
945
  errors: shellErrors,
946
946
  hint: "\u8BF7\u4FEE\u6B63\u914D\u7F6E\u6587\u4EF6\u5185\u5BB9\u540E\u91CD\u8BD5\uFF08\u4E0D\u8981\u5728\u6B64\u6587\u4EF6\u5199 Vant \u89D2\u8272/workflow\uFF09"
@@ -951,14 +951,14 @@ function loadProjectConfig(project, providers) {
951
951
  if (!resolvedBindings.ok) {
952
952
  return {
953
953
  ok: false,
954
- file,
954
+ file: file2,
955
955
  kind: resolvedBindings.pathUnsafe ? "unsafe-binding" : "invalid",
956
956
  errors: resolvedBindings.errors,
957
957
  hint: resolvedBindings.pathUnsafe ? "\u7ED1\u5B9A\u8DEF\u5F84\u8D8A\u754C\u6216\u6307\u5411\u94FE\u63A5\uFF0C\u5DF2\u88AB\u62D2\u7EDD" : "\u8BF7\u6309\u5404 Provider \u7684\u7ED1\u5B9A\u5951\u7EA6\u4FEE\u6B63 bindings\uFF08\u5DF2\u58F0\u660E\u7684\u65E0\u6548\u7ED1\u5B9A\u6574\u4F53\u62D2\u7EDD\uFF09"
958
958
  };
959
959
  }
960
960
  const unbound = [...providers.keys()].filter((id) => !(id in config.bindings));
961
- return { ok: true, file, config, resolved: resolvedBindings.bindings, unbound };
961
+ return { ok: true, file: file2, config, resolved: resolvedBindings.bindings, unbound };
962
962
  }
963
963
  function renderProjectConfig(project, providers, overrides = {}) {
964
964
  const bindings = {};
@@ -986,14 +986,14 @@ function renderProjectConfig(project, providers, overrides = {}) {
986
986
  };
987
987
  }
988
988
  var CONFIG_BACKUP_RELATIVE = ".vant/state/config-backups";
989
- function atomicWriteConfig(project, file, content) {
990
- const configDir = path2.dirname(file);
989
+ function atomicWriteConfig(project, file2, content) {
990
+ const configDir = path2.dirname(file2);
991
991
  resolveInsideProject(project, ".vant/config", ".vant/config");
992
992
  fs2.mkdirSync(configDir, { recursive: true });
993
- const tmpPath = `${file}.${process.pid}.${Date.now()}.tmp`;
993
+ const tmpPath = `${file2}.${process.pid}.${Date.now()}.tmp`;
994
994
  try {
995
995
  fs2.writeFileSync(tmpPath, content, { encoding: "utf-8" });
996
- fs2.renameSync(tmpPath, file);
996
+ fs2.renameSync(tmpPath, file2);
997
997
  } catch (err) {
998
998
  try {
999
999
  fs2.rmSync(tmpPath, { force: true });
@@ -1003,13 +1003,13 @@ function atomicWriteConfig(project, file, content) {
1003
1003
  }
1004
1004
  }
1005
1005
  function initProjectConfig(project, providers, overrides = {}, options = {}) {
1006
- const file = path2.join(project.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
1006
+ const file2 = path2.join(project.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
1007
1007
  const vantFile = path2.join(project.root, ...VANT_PROJECT_CONFIG_RELATIVE.split("/"));
1008
1008
  const vantConfig = { file: vantFile, exists: fs2.existsSync(vantFile) };
1009
1009
  const refused = (reason) => ({
1010
1010
  ok: false,
1011
1011
  action: "refused",
1012
- file,
1012
+ file: file2,
1013
1013
  relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
1014
1014
  projectRoot: project.root,
1015
1015
  reason,
@@ -1020,14 +1020,14 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1020
1020
  const known = [...providers.keys()].sort().join(", ") || "\uFF08\u65E0\u5DF2\u6CE8\u518C Provider\uFF09";
1021
1021
  return refused(`\u672A\u77E5 Provider \u7ED1\u5B9A\u8986\u76D6: ${unknownOverrides.join(", ")}\uFF08\u5DF2\u6CE8\u518C: ${known}\uFF09`);
1022
1022
  }
1023
- const exists = fs2.existsSync(file);
1023
+ const exists = fs2.existsSync(file2);
1024
1024
  const reset = options.reset === true;
1025
1025
  const dryRun = options.dryRun === true;
1026
1026
  if (exists && !reset) {
1027
1027
  resolveInsideProject(project, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
1028
1028
  let existing;
1029
1029
  try {
1030
- existing = JSON.parse(fs2.readFileSync(file, "utf-8"));
1030
+ existing = JSON.parse(fs2.readFileSync(file2, "utf-8"));
1031
1031
  } catch (err) {
1032
1032
  return refused(
1033
1033
  `\u5DF2\u5B58\u5728 ${PROJECT_CLI_CONFIG_RELATIVE} \u4F46\u4E0D\u662F\u5408\u6CD5 JSON\uFF08${err instanceof Error ? err.message : String(err)}\uFF09\uFF1A\u5E42\u7B49\u8865\u5168\u8981\u6C42\u53EF\u89E3\u6790\uFF0C\u8BF7\u4FEE\u6B63\u540E\u91CD\u8BD5\u6216\u663E\u5F0F --reset\uFF08\u5C06\u5148\u5907\u4EFD\u65E7\u6587\u4EF6\uFF09`
@@ -1074,14 +1074,14 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1074
1074
  if (!existingCheck.ok) {
1075
1075
  return refused(`\u914D\u7F6E\u9F50\u5907\u4F46\u5B58\u5728\u65E0\u6548\u7ED1\u5B9A\uFF08${existingCheck.errors.join("\uFF1B")}\uFF09\uFF1A\u8BF7\u4FEE\u6B63\u6216\u663E\u5F0F --reset`);
1076
1076
  }
1077
- const current = fs2.readFileSync(file, "utf-8");
1077
+ const current = fs2.readFileSync(file2, "utf-8");
1078
1078
  return {
1079
1079
  ok: true,
1080
1080
  action: "unchanged",
1081
1081
  dryRun,
1082
1082
  existed: true,
1083
1083
  added: [],
1084
- file,
1084
+ file: file2,
1085
1085
  relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
1086
1086
  bytes: Buffer.byteLength(current, "utf-8"),
1087
1087
  sha256: createHash("sha256").update(current, "utf-8").digest("hex"),
@@ -1099,7 +1099,7 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1099
1099
  return refused(`\u8865\u5168\u540E\u7684\u914D\u7F6E\u672A\u901A\u8FC7\u6821\u9A8C\uFF08${bindingResult2.errors.join("\uFF1B")}\uFF09\uFF1A\u8BF7\u4FEE\u6B63\u5DF2\u6709\u6BB5\u6216\u663E\u5F0F --reset`);
1100
1100
  }
1101
1101
  if (!dryRun) {
1102
- atomicWriteConfig(project, file, content);
1102
+ atomicWriteConfig(project, file2, content);
1103
1103
  }
1104
1104
  return {
1105
1105
  ok: true,
@@ -1107,7 +1107,7 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1107
1107
  dryRun,
1108
1108
  existed: true,
1109
1109
  added,
1110
- file,
1110
+ file: file2,
1111
1111
  relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
1112
1112
  bytes: Buffer.byteLength(content, "utf-8"),
1113
1113
  sha256: createHash("sha256").update(content, "utf-8").digest("hex"),
@@ -1133,16 +1133,16 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1133
1133
  fs2.mkdirSync(backupDir, { recursive: true });
1134
1134
  const stamp = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${process.pid.toString(36)}`;
1135
1135
  backupPath = path2.join(backupDir, `v-cli.${stamp}.json`);
1136
- fs2.copyFileSync(file, backupPath);
1136
+ fs2.copyFileSync(file2, backupPath);
1137
1137
  }
1138
1138
  if (!dryRun) {
1139
1139
  if (exists) {
1140
- atomicWriteConfig(project, file, rendered.content);
1140
+ atomicWriteConfig(project, file2, rendered.content);
1141
1141
  } else {
1142
1142
  const configDir = path2.join(project.root, ".vant", "config");
1143
1143
  resolveInsideProject(project, ".vant/config", ".vant/config");
1144
1144
  fs2.mkdirSync(configDir, { recursive: true });
1145
- fs2.writeFileSync(file, rendered.content, { encoding: "utf-8", flag: "wx" });
1145
+ fs2.writeFileSync(file2, rendered.content, { encoding: "utf-8", flag: "wx" });
1146
1146
  }
1147
1147
  }
1148
1148
  return {
@@ -1151,7 +1151,7 @@ function initProjectConfig(project, providers, overrides = {}, options = {}) {
1151
1151
  dryRun,
1152
1152
  existed: exists,
1153
1153
  added: Object.keys(candidate.bindings),
1154
- file,
1154
+ file: file2,
1155
1155
  relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
1156
1156
  bytes: rendered.bytes,
1157
1157
  sha256: rendered.sha256,
@@ -2826,15 +2826,15 @@ function defaultResolvePackage(pkg, opts = {}) {
2826
2826
  }
2827
2827
  return void 0;
2828
2828
  }
2829
- function defaultExists(file) {
2829
+ function defaultExists(file2) {
2830
2830
  try {
2831
- return fs5.existsSync(file);
2831
+ return fs5.existsSync(file2);
2832
2832
  } catch {
2833
2833
  return false;
2834
2834
  }
2835
2835
  }
2836
- function defaultRead(file) {
2837
- return fs5.readFileSync(file, "utf-8");
2836
+ function defaultRead(file2) {
2837
+ return fs5.readFileSync(file2, "utf-8");
2838
2838
  }
2839
2839
  function formatErrors2(errors) {
2840
2840
  return errors.join("\uFF1B");
@@ -3077,9 +3077,9 @@ var FAIL_COUNT_PATHS = [
3077
3077
  ];
3078
3078
  function extractFailCount(payload) {
3079
3079
  if (!isPlainObject7(payload)) return { count: null, source: null };
3080
- for (const path7 of FAIL_COUNT_PATHS) {
3080
+ for (const path8 of FAIL_COUNT_PATHS) {
3081
3081
  let current = payload;
3082
- for (const segment of path7) {
3082
+ for (const segment of path8) {
3083
3083
  if (!isPlainObject7(current)) {
3084
3084
  current = void 0;
3085
3085
  break;
@@ -3087,16 +3087,16 @@ function extractFailCount(payload) {
3087
3087
  current = current[segment];
3088
3088
  }
3089
3089
  if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
3090
- return { count: current, source: path7.join(".") };
3090
+ return { count: current, source: path8.join(".") };
3091
3091
  }
3092
3092
  }
3093
3093
  return { count: null, source: null };
3094
3094
  }
3095
3095
  function extractTotal(payload) {
3096
3096
  if (!isPlainObject7(payload)) return { total: null, source: null };
3097
- for (const path7 of [["summary", "total"]]) {
3097
+ for (const path8 of [["summary", "total"]]) {
3098
3098
  let current = payload;
3099
- for (const segment of path7) {
3099
+ for (const segment of path8) {
3100
3100
  if (!isPlainObject7(current)) {
3101
3101
  current = void 0;
3102
3102
  break;
@@ -3104,7 +3104,7 @@ function extractTotal(payload) {
3104
3104
  current = current[segment];
3105
3105
  }
3106
3106
  if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
3107
- return { total: current, source: path7.join(".") };
3107
+ return { total: current, source: path8.join(".") };
3108
3108
  }
3109
3109
  }
3110
3110
  return { total: null, source: null };
@@ -5094,9 +5094,413 @@ function createUnityProvider(deps) {
5094
5094
  };
5095
5095
  }
5096
5096
 
5097
+ // src/providers/art/index.ts
5098
+ import path6 from "path";
5099
+ import { readFileSync } from "fs";
5100
+ var identifier = {
5101
+ type: "string",
5102
+ pattern: "^[a-z0-9][a-z0-9-]{0,63}$"
5103
+ };
5104
+ var revision = { type: "integer", minimum: 1 };
5105
+ var file = {
5106
+ type: "string",
5107
+ minLength: 1,
5108
+ description: "\u76F8\u5BF9\u5DE5\u7A0B\u6839\u7684\u53D7\u63A7\u6587\u4EF6\u8DEF\u5F84"
5109
+ };
5110
+ var artBindingContract = {
5111
+ schema: {
5112
+ type: "object",
5113
+ additionalProperties: false,
5114
+ required: ["workspace", "output", "cache", "projectId"],
5115
+ properties: {
5116
+ workspace: file,
5117
+ output: file,
5118
+ cache: file,
5119
+ projectId: identifier
5120
+ }
5121
+ },
5122
+ pathFields: ["workspace", "output", "cache"].map((field) => ({
5123
+ field,
5124
+ kind: "dir",
5125
+ required: true
5126
+ })),
5127
+ resolve: ({ project, raw, resolveInsideProject: inside }) => {
5128
+ const b = raw;
5129
+ if (!b || typeof b !== "object" || !["workspace", "output", "cache", "projectId"].every(
5130
+ (k) => typeof b[k] === "string"
5131
+ ))
5132
+ return {
5133
+ ok: false,
5134
+ errors: ["art \u7ED1\u5B9A\u5FC5\u987B\u5305\u542B workspace/output/cache/projectId"]
5135
+ };
5136
+ const dirs = Object.fromEntries(
5137
+ ["workspace", "output", "cache"].map((k) => [
5138
+ k,
5139
+ inside(project, b[k], "bindings.art." + k).path
5140
+ ])
5141
+ );
5142
+ return { ok: true, dirs, files: {}, section: { ...b }, warnings: [] };
5143
+ }
5144
+ };
5145
+ var objectFields = { id: identifier, revision, input: file };
5146
+ var definitions = [
5147
+ { id: "job-template", command: ["job", "template"], fields: { kind: { type: "string", enum: ["generate", "edit"] }, core: identifier }, required: ["kind"], readonly: true },
5148
+ { id: "job-from-candidate", command: ["job", "from-candidate"], fields: { id: identifier, run: identifier, candidate: { type: "string", pattern: "^[a-f0-9]{64}$" } }, required: ["id", "run", "candidate"] },
5149
+ { id: "deployment-plan", command: ["deployment", "plan"], fields: { directory: { type: "string", minLength: 1 }, endpoint: { type: "string", minLength: 1 } }, required: ["directory"], readonly: true },
5150
+ { id: "deployment-start", command: ["deployment", "start"], fields: { plan: file, operation: { type: "string", pattern: "^[a-z0-9-]{1,128}$" } }, required: ["plan", "operation"], network: true },
5151
+ ...["status", "cancel", "recover"].map((action) => ({ id: "deployment-" + action, command: ["deployment", action], fields: action === "recover" ? { operation: { type: "string", pattern: "^[a-z0-9-]{1,128}$" } } : { id: identifier }, required: [action === "recover" ? "operation" : "id"], readonly: action !== "cancel" })),
5152
+ { id: "run-recover", command: ["task", "recover"], fields: { operation: { type: "string", pattern: "^[a-z0-9-]{1,128}$" } }, required: ["operation"], start: true },
5153
+ ...["style", "job"].flatMap(
5154
+ (kind) => ["create", "list", "read", "update", "derive", "discard"].map(
5155
+ (action) => ({
5156
+ id: kind + "-" + action,
5157
+ command: [kind, action],
5158
+ fields: action === "list" ? {} : action === "create" ? { input: file } : action === "read" ? { id: identifier } : action === "update" ? objectFields : { id: identifier, revision },
5159
+ required: action === "list" ? [] : action === "create" ? ["input"] : action === "read" ? ["id"] : action === "update" ? ["id", "revision", "input"] : ["id", "revision"],
5160
+ readonly: ["list", "read"].includes(action)
5161
+ })
5162
+ )
5163
+ ),
5164
+ { id: "run-list", command: ["task", "list"], fields: {}, readonly: true },
5165
+ {
5166
+ id: "project-init",
5167
+ command: ["project", "init"],
5168
+ fields: { input: file },
5169
+ required: ["input"]
5170
+ },
5171
+ {
5172
+ id: "style-analyze",
5173
+ command: ["style", "analyze"],
5174
+ fields: { id: identifier, revision, dry: { type: "boolean" } },
5175
+ required: ["id", "revision"],
5176
+ start: true
5177
+ },
5178
+ {
5179
+ id: "job-analyze",
5180
+ command: ["job", "analyze"],
5181
+ fields: { id: identifier, revision, dry: { type: "boolean" } },
5182
+ required: ["id", "revision"],
5183
+ start: true
5184
+ },
5185
+ {
5186
+ id: "style-adopt",
5187
+ command: ["style", "adopt"],
5188
+ fields: { id: identifier, revision, note: { type: "string" } },
5189
+ required: ["id", "revision"]
5190
+ },
5191
+ {
5192
+ id: "style-recover",
5193
+ command: ["style", "recover"],
5194
+ fields: { id: identifier },
5195
+ required: ["id"]
5196
+ },
5197
+ ...["generate", "edit"].map((kind) => ({
5198
+ id: kind + "-plan",
5199
+ command: [kind, "plan"],
5200
+ fields: { job: identifier, backend: identifier, out: file },
5201
+ required: ["job"]
5202
+ })),
5203
+ ...["generate", "edit"].map((kind) => ({
5204
+ id: kind + "-start",
5205
+ command: [kind, "run"],
5206
+ fields: {
5207
+ plan: file,
5208
+ item: identifier,
5209
+ variant: identifier,
5210
+ "all-variants": { type: "boolean" },
5211
+ "retry-run": { ...identifier, description: "\u539F\u6279\u6B21\u505C\u6B62\u5DF2\u786E\u8BA4\u540E\uFF0C\u4EC5\u91CD\u8BD5\u539F\u8BA1\u5212\u4E2D\u660E\u786E\u5931\u8D25\u7684\u9879\uFF1B\u6210\u529F\u9879\u4E0D\u4F1A\u91CD\u505A" },
5212
+ dry: { type: "boolean" }
5213
+ },
5214
+ required: ["plan"],
5215
+ start: true
5216
+ })),
5217
+ ...["status", "cancel", "resume"].map((action) => ({
5218
+ id: "run-" + action,
5219
+ command: ["task", action],
5220
+ fields: {
5221
+ handle: { type: "object", additionalProperties: true }
5222
+ },
5223
+ required: ["handle"],
5224
+ control: true,
5225
+ readonly: action === "status"
5226
+ })),
5227
+ {
5228
+ id: "reference-list",
5229
+ command: ["reference", "list"],
5230
+ fields: {
5231
+ kind: { type: "string", enum: ["style", "task"] },
5232
+ id: identifier
5233
+ },
5234
+ required: ["kind", "id"],
5235
+ readonly: true
5236
+ },
5237
+ {
5238
+ id: "reference-import",
5239
+ command: ["reference", "import"],
5240
+ fields: {
5241
+ kind: { type: "string", enum: ["style", "task"] },
5242
+ id: identifier,
5243
+ revision,
5244
+ source: file,
5245
+ category: {
5246
+ type: "string",
5247
+ enum: ["style", "palette", "rendering"]
5248
+ },
5249
+ purposes: { type: "string" },
5250
+ note: { type: "string" }
5251
+ },
5252
+ required: ["kind", "id", "revision", "source"]
5253
+ },
5254
+ {
5255
+ id: "reference-remove",
5256
+ command: ["reference", "remove"],
5257
+ fields: {
5258
+ kind: { type: "string", enum: ["style", "task"] },
5259
+ id: identifier,
5260
+ revision,
5261
+ item: identifier
5262
+ },
5263
+ required: ["kind", "id", "revision", "item"]
5264
+ },
5265
+ {
5266
+ id: "reference-update",
5267
+ command: ["reference", "update"],
5268
+ fields: { kind: { type: "string", enum: ["style", "task"] }, id: identifier, revision, item: identifier, input: file },
5269
+ required: ["kind", "id", "revision", "item", "input"]
5270
+ },
5271
+ ...["list", "finalizations", "finalize", "delete"].map(
5272
+ (action) => ({
5273
+ id: "candidate-" + action,
5274
+ command: ["candidate", action],
5275
+ fields: {
5276
+ job: identifier,
5277
+ run: identifier,
5278
+ candidate: { type: "string" },
5279
+ revision,
5280
+ actor: { type: "string" },
5281
+ replace: { type: "boolean" },
5282
+ confirm: { type: "boolean" }
5283
+ },
5284
+ required: [
5285
+ "job",
5286
+ ...action === "finalizations" ? [] : ["run"],
5287
+ ...["finalize", "delete"].includes(action) ? ["candidate", "revision", "actor"] : []
5288
+ ],
5289
+ readonly: ["list", "finalizations"].includes(action)
5290
+ })
5291
+ )
5292
+ ];
5293
+ function createArtProvider(deps) {
5294
+ const discover = deps.discoverBackend ?? (() => discoverOfficialPlugin(
5295
+ OFFICIAL_PLUGINS.find((s) => s.command === "art")
5296
+ ));
5297
+ const registrations = definitions.map((d) => ({
5298
+ descriptor: {
5299
+ id: "art." + d.id,
5300
+ version: "0.1.0",
5301
+ description: "\u7F8E\u672F\u5DE5\u574A " + d.command.join(" ") + "\uFF1B\u5BF9\u8C61\u7248\u672C\u4E0E\u505C\u6B62\u8BC1\u636E\u7531\u5DE5\u5177\u6838\u9A8C",
5302
+ inputSchema: {
5303
+ type: "object",
5304
+ additionalProperties: false,
5305
+ properties: d.fields,
5306
+ required: d.required ?? []
5307
+ },
5308
+ outputSchema: {
5309
+ type: "object",
5310
+ additionalProperties: true,
5311
+ required: ["result"],
5312
+ properties: { result: { type: "object", additionalProperties: true } }
5313
+ },
5314
+ preconditions: [],
5315
+ sideEffects: [
5316
+ {
5317
+ id: "read-art",
5318
+ kind: "fs-read",
5319
+ description: "\u8BFB\u53D6\u53D7\u7BA1\u5BF9\u8C61\u4E0E\u6267\u884C\u8BC1\u636E",
5320
+ reversible: true
5321
+ },
5322
+ {
5323
+ id: "invoke-art",
5324
+ kind: "process-exec",
5325
+ description: "\u53D7\u63A7\u53C2\u6570\u8C03\u7528\u5B98\u65B9 art \u5DE5\u5177",
5326
+ reversible: false
5327
+ },
5328
+ ...d.start || d.control || d.network ? [
5329
+ {
5330
+ id: "art-network",
5331
+ kind: "network",
5332
+ description: "\u8C03\u7528\u6A21\u578B\u6216\u67E5\u8BE2\u3001\u53D6\u6D88\u540E\u7AEF\u6267\u884C",
5333
+ reversible: false
5334
+ }
5335
+ ] : [],
5336
+ ...!d.readonly ? [
5337
+ {
5338
+ id: "art-mutation",
5339
+ kind: "fs-write",
5340
+ description: "\u5BF9\u8C61\u914D\u7F6E\u3001\u6267\u884C\u8BC1\u636E\u6216\u5B9A\u7248\u53D8\u66F4\uFF1B\u542F\u52A8\u53EF\u8C03\u7528\u6A21\u578B",
5341
+ reversible: false
5342
+ }
5343
+ ] : []
5344
+ ],
5345
+ resources: [
5346
+ {
5347
+ kind: "project-workspace",
5348
+ mode: d.readonly ? "shared" : "exclusive",
5349
+ scope: "project",
5350
+ description: "\u7EC4\u7EC7\u5C42\u7BA1\u7406\u5BF9\u8C61\u8D44\u6E90\u5360\u7528\uFF0C\u505C\u6B62\u672A\u77E5\u7EE7\u7EED\u5360\u7528"
5351
+ }
5352
+ ],
5353
+ retry: {
5354
+ safe: !!d.readonly,
5355
+ maxAttempts: 1,
5356
+ strategy: "none",
5357
+ description: "\u542F\u52A8\u4E0D\u81EA\u52A8\u91CD\u8BD5\uFF1B\u6062\u590D\u67E5\u8BE2\u539F\u53E5\u67C4"
5358
+ },
5359
+ timeoutMs: 9e4,
5360
+ tags: ["art", "lifecycle"]
5361
+ },
5362
+ implementation: {
5363
+ execute: async (input, ctx) => {
5364
+ const backend = discover();
5365
+ const fail = (code, message) => ({
5366
+ execution: {
5367
+ status: "failed",
5368
+ lifecycle: "failed",
5369
+ error: structuredError(code, "precondition", message)
5370
+ },
5371
+ acceptance: { status: "not-run", reason: message }
5372
+ });
5373
+ if (backend.status !== "available" || !backend.bin)
5374
+ return fail(
5375
+ "art-backend-unavailable",
5376
+ backend.error ?? "art \u540E\u7AEF\u4E0D\u53EF\u7528"
5377
+ );
5378
+ if (!ctx.binding || !ctx.bindingDirs.workspace)
5379
+ return fail("art-binding-missing", "\u7F3A\u5C11 art \u5DE5\u7A0B\u7ED1\u5B9A");
5380
+ if (d.start && input.plan) {
5381
+ const file2 = resolveInsideProject(ctx.projectAnchor, String(input.plan), "art.plan").path;
5382
+ const plan = JSON.parse(readFileSync(file2, "utf8"));
5383
+ if (plan.project !== ctx.binding.projectId || plan.module !== d.command[0]) return fail("art-plan-scope-mismatch", "\u8BA1\u5212\u4E0D\u5C5E\u4E8E\u5F53\u524D art \u5DE5\u7A0B\u6216\u6267\u884C\u7C7B\u578B");
5384
+ }
5385
+ const argv = [
5386
+ ...d.command,
5387
+ "--workspace",
5388
+ ctx.bindingDirs.workspace,
5389
+ "--output-dir",
5390
+ ctx.bindingDirs.output,
5391
+ "--cache-dir",
5392
+ ctx.bindingDirs.cache,
5393
+ "--config",
5394
+ path6.join(ctx.bindingDirs.workspace, "settings.json")
5395
+ ];
5396
+ if (!d.control && !(d.command[1] === "run" && input.plan))
5397
+ argv.push("--project", String(ctx.binding.projectId));
5398
+ if (d.control) {
5399
+ const verification = verifyExecutionHandle({
5400
+ project: ctx.projectAnchor,
5401
+ handle: input.handle,
5402
+ expectProviderId: "art"
5403
+ });
5404
+ if (!verification.ok)
5405
+ return fail(verification.code, verification.errors.join("; "));
5406
+ if (!verification.record.backendTaskId)
5407
+ return fail("art-handle-missing", "\u53E5\u67C4\u7F3A\u5C11\u540E\u7AEF\u8FD0\u884C\u8EAB\u4EFD");
5408
+ const origin = JSON.parse(readFileSync(resolveInsideProject(ctx.projectAnchor, verification.record.recordDir + "/result.json", "art.origin").path, "utf8"));
5409
+ if (origin.output?.result?.project !== ctx.binding.projectId || ["workspace", "output", "cache"].some((key) => origin.project?.bindingDirs?.art?.[key] !== ctx.bindingDirs?.[key])) return fail("art-handle-binding-changed", "\u8FD0\u884C\u8EAB\u4EFD\u4E0E\u5F53\u524D\u5DE5\u7A0B\u7ED1\u5B9A\u4E0D\u540C\uFF1B\u8BF7\u6062\u590D\u539F\u7ED1\u5B9A\u540E\u64CD\u4F5C");
5410
+ argv.splice(2, 0, verification.record.backendTaskId);
5411
+ }
5412
+ for (const [key, value] of Object.entries(input)) {
5413
+ if (key === "handle" || value === false) continue;
5414
+ const actual = ["input", "source", "plan", "out"].includes(key) ? resolveInsideProject(
5415
+ ctx.projectAnchor,
5416
+ String(value),
5417
+ "art." + key
5418
+ ).path : value;
5419
+ argv.push("--" + key);
5420
+ if (value !== true) argv.push(String(actual));
5421
+ }
5422
+ if (d.start && d.id !== "run-recover" && !input.dry) argv.push("--operation", ctx.operationId);
5423
+ if (d.start && d.command[1] === "run" && !input.dry)
5424
+ argv.push("--background");
5425
+ const outcome = await deps.executor.run({
5426
+ file: process.execPath,
5427
+ args: [backend.bin, ...argv],
5428
+ cwd: ctx.projectAnchor.root,
5429
+ env: deps.env,
5430
+ timeoutMs: 9e4,
5431
+ signal: ctx.signal
5432
+ });
5433
+ let output;
5434
+ try {
5435
+ const parsed = JSON.parse(outcome.stdout);
5436
+ output = Array.isArray(parsed) ? { items: parsed } : parsed;
5437
+ if (!output || typeof output !== "object") throw new Error();
5438
+ } catch {
5439
+ const processState = executionFromProcess(outcome);
5440
+ const uncertain = d.start || d.control || d.id === "deployment-start" || processState.lifecycle === "unknown";
5441
+ return {
5442
+ execution: {
5443
+ ...processState,
5444
+ status: "failed",
5445
+ lifecycle: uncertain ? "unknown" : processState.lifecycle,
5446
+ error: structuredError(
5447
+ "art-output-invalid",
5448
+ "protocol",
5449
+ uncertain ? "art \u672A\u8FD4\u56DE\u5B8C\u6574 JSON\uFF0C\u4E0D\u80FD\u636E\u6B64\u91CA\u653E\u8D44\u6E90" : "art \u672A\u8FD4\u56DE\u5B8C\u6574 JSON\uFF1B\u540C\u6B65\u8FDB\u7A0B\u5DF2\u7ED3\u675F\uFF0C\u64CD\u4F5C\u7ED3\u679C\u9700\u67E5\u8BE2\u6838\u9A8C"
5450
+ )
5451
+ },
5452
+ acceptance: { status: "not-run", reason: "\u534F\u8BAE\u7ED3\u679C\u672A\u77E5\uFF0C\u4E0D\u80FD\u58F0\u79F0\u4E1A\u52A1\u6210\u529F" },
5453
+ rawOutput: outcome
5454
+ };
5455
+ }
5456
+ let lifecycle = executionFromProcess(outcome).lifecycle;
5457
+ if (typeof output.taskId === "string")
5458
+ lifecycle = output.lifecycle ?? (d.start && !input.dry ? "accepted" : output.stopConfirmed === true ? "completed" : "unknown");
5459
+ return {
5460
+ execution: {
5461
+ ...executionFromProcess(outcome),
5462
+ lifecycle,
5463
+ ...output.ok === false ? { status: "failed", error: structuredError("art-operation-failed", "process", String(output.error ?? JSON.stringify(output.issues ?? output.diagnostic ?? "\u7F8E\u672F\u64CD\u4F5C\u5931\u8D25"))) } : {}
5464
+ },
5465
+ acceptance: {
5466
+ status: "not-run",
5467
+ reason: d.start ? "\u5DF2\u767B\u8BB0\u6267\u884C\uFF1B\u5B8C\u6210\u4E0E\u5B9A\u7248\u9700\u67E5\u8BE2\u771F\u5B9E\u8BC1\u636E" : "\u5DE5\u5177\u72B6\u6001\u5DF2\u8BFB\u53D6\uFF0C\u4E1A\u52A1\u7ED3\u8BBA\u89C1 result"
5468
+ },
5469
+ output: { result: { ...output, ...d.start ? { project: ctx.binding.projectId } : {} } },
5470
+ rawOutput: { stdout: outcome.stdout, stderr: outcome.stderr },
5471
+ ...d.start && !input.dry && typeof output.taskId === "string" ? { handle: { backendTaskId: output.taskId } } : {}
5472
+ };
5473
+ }
5474
+ }
5475
+ }));
5476
+ return {
5477
+ id: "art",
5478
+ version: "0.1.0",
5479
+ description: "\u7F8E\u672F\u5DE5\u574A\u6CE8\u518C\u6267\u884C\u9002\u914D\uFF1B\u65E0\u989D\u5916\u961F\u5217\u6216\u4E1A\u52A1\u72B6\u6001",
5480
+ binding: artBindingContract,
5481
+ defaultBinding: () => ({
5482
+ section: {
5483
+ workspace: ".vant/art",
5484
+ output: ".vant/art/output",
5485
+ cache: ".vant/art/cache",
5486
+ projectId: "project"
5487
+ },
5488
+ warnings: []
5489
+ }),
5490
+ status: async () => {
5491
+ const info = discover();
5492
+ return {
5493
+ state: info.status === "available" ? "available" : info.status,
5494
+ detail: info.error ?? "\u5B98\u65B9 art \u540E\u7AEF"
5495
+ };
5496
+ },
5497
+ capabilities: () => registrations
5498
+ };
5499
+ }
5500
+
5097
5501
  // src/providers/figma/index.ts
5098
5502
  import fs7 from "fs";
5099
- import path6 from "path";
5503
+ import path7 from "path";
5100
5504
 
5101
5505
  // src/providers/figma/protocol.ts
5102
5506
  var VALID_LINE = /^(?:\[figma-to-uprefab\] )?Contract valid: (\d+) root\(s\)\.$/;
@@ -5199,8 +5603,8 @@ var figmaBindingContract = {
5199
5603
  if (errors.length > 0) return { ok: false, errors };
5200
5604
  const projectDir = resolve(project, section.projectDir, "bindings.figma.projectDir");
5201
5605
  const stagingRoot = resolve(project, section.stagingRoot, "bindings.figma.stagingRoot");
5202
- const rel = path6.relative(projectDir.path, stagingRoot.path);
5203
- if (rel === "" || rel === ".." || rel.startsWith(`..${path6.sep}`) || path6.isAbsolute(rel)) {
5606
+ const rel = path7.relative(projectDir.path, stagingRoot.path);
5607
+ if (rel === "" || rel === ".." || rel.startsWith(`..${path7.sep}`) || path7.isAbsolute(rel)) {
5204
5608
  return {
5205
5609
  ok: false,
5206
5610
  errors: [`bindings.figma.stagingRoot \u5FC5\u987B\u4F4D\u4E8E bindings.figma.projectDir\uFF08${section.projectDir}\uFF09\u5185\uFF08\u6536\u5230 ${section.stagingRoot}\uFF09`]
@@ -5221,7 +5625,7 @@ function figmaBinding(ctx) {
5221
5625
  return binding;
5222
5626
  }
5223
5627
  function normalizeProjectKey(projectPath) {
5224
- let key = path6.resolve(projectPath).replace(/\\/g, "/");
5628
+ let key = path7.resolve(projectPath).replace(/\\/g, "/");
5225
5629
  if (process.platform === "win32") key = key.toLowerCase();
5226
5630
  if (key.length > 3 && key.endsWith("/")) key = key.slice(0, -1);
5227
5631
  return key;
@@ -5257,15 +5661,15 @@ function createFigmaProvider(deps) {
5257
5661
  };
5258
5662
  }
5259
5663
  function writeManagedConfig(ctx, unityDir, stagingRootAbs) {
5260
- const configPath = path6.join(ctx.projectAnchor.root, ...MANAGED_CONFIG_RELATIVE.split("/"));
5261
- const stagingRelativeToUnity = path6.relative(unityDir, stagingRootAbs).split(path6.sep).join("/");
5664
+ const configPath = path7.join(ctx.projectAnchor.root, ...MANAGED_CONFIG_RELATIVE.split("/"));
5665
+ const stagingRelativeToUnity = path7.relative(unityDir, stagingRootAbs).split(path7.sep).join("/");
5262
5666
  const payload = {
5263
5667
  schemaVersion: 1,
5264
5668
  projects: {
5265
5669
  [normalizeProjectKey(unityDir)]: { uiSystem: "UGUI", staging: { root: stagingRelativeToUnity } }
5266
5670
  }
5267
5671
  };
5268
- fs7.mkdirSync(path6.dirname(configPath), { recursive: true });
5672
+ fs7.mkdirSync(path7.dirname(configPath), { recursive: true });
5269
5673
  const tmpPath = `${configPath}.${process.pid}.${Date.now()}.tmp`;
5270
5674
  try {
5271
5675
  fs7.writeFileSync(tmpPath, `${JSON.stringify(payload, null, 2)}
@@ -5663,10 +6067,10 @@ function createFigmaProvider(deps) {
5663
6067
  binding: figmaBindingContract,
5664
6068
  defaultBinding: (project) => {
5665
6069
  const warnings = [];
5666
- const declared = path6.join(project.root, "Client");
6070
+ const declared = path7.join(project.root, "Client");
5667
6071
  if (!fs7.existsSync(declared)) {
5668
6072
  warnings.push('bindings.figma.projectDir="Client" \u5F53\u524D\u4E0D\u5B58\u5728\uFF1A\u8BF7\u6309\u5DE5\u7A0B\u5B9E\u9645\u76EE\u5F55\u4FEE\u6539 .vant/config/v-cli.json \u6216\u7528 --binding figma \u8986\u76D6');
5669
- } else if (!fs7.existsSync(path6.join(declared, ...DEFAULT_STAGING_ROOT_SEGMENTS.split("/")))) {
6073
+ } else if (!fs7.existsSync(path7.join(declared, ...DEFAULT_STAGING_ROOT_SEGMENTS.split("/")))) {
5670
6074
  warnings.push(`\u9ED8\u8BA4 staging \u6839 Client/${DEFAULT_STAGING_ROOT_SEGMENTS} \u5F53\u524D\u4E0D\u5B58\u5728\uFF1Afigma.contract \u5C06\u6309 CON_INDEX_MISSING \u660E\u786E\u5931\u8D25\uFF08staging \u7531 Figma \u5BFC\u51FA\u6D41\u7A0B\u4EA7\u51FA\uFF09`);
5671
6075
  }
5672
6076
  return { section: { projectDir: "Client", stagingRoot: `Client/${DEFAULT_STAGING_ROOT_SEGMENTS}` }, warnings };
@@ -5708,11 +6112,12 @@ function createDefaultRegistry(options = {}) {
5708
6112
  discoverBackend: options.figmaDiscoverBackend
5709
6113
  })
5710
6114
  );
6115
+ registry.registerProvider(createArtProvider({ executor, discoverBackend: options.artDiscoverBackend, env: options.artEnv }));
5711
6116
  return registry;
5712
6117
  }
5713
6118
 
5714
6119
  // src/version.ts
5715
- var VERSION = "0.3.1";
6120
+ var VERSION = "0.4.1";
5716
6121
  export {
5717
6122
  CapabilityError,
5718
6123
  CapabilityRegistrationError,
@@ -5732,10 +6137,12 @@ export {
5732
6137
  UNITY_PROVIDER_VERSION,
5733
6138
  VANT_PROJECT_CONFIG_RELATIVE,
5734
6139
  VERSION,
6140
+ artBindingContract,
5735
6141
  buildDoctorArgv,
5736
6142
  buildExecArgv,
5737
6143
  buildExecutionHandle,
5738
6144
  canonicalize,
6145
+ createArtProvider,
5739
6146
  createDefaultRegistry,
5740
6147
  createFigmaProvider,
5741
6148
  createUnityProvider,