@kevlns/v-cli 0.3.1 → 0.4.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/AGENTS.md +12 -12
- package/README.md +102 -270
- package/dist/cli.mjs +484 -79
- package/dist/sdk.d.ts +15 -5
- package/dist/sdk.mjs +453 -46
- package/docs/execution-identities.md +46 -0
- package/docs/provider-development.md +32 -0
- package/docs/provider-protocols.md +37 -0
- package/docs/registration-execution.md +47 -0
- package/package.json +6 -4
- package/skills/v-cli/SKILL.md +29 -167
package/dist/cli.mjs
CHANGED
|
@@ -11,8 +11,8 @@ import path2 from "path";
|
|
|
11
11
|
import fs from "fs";
|
|
12
12
|
import path from "path";
|
|
13
13
|
var ConfigStore = class _ConfigStore {
|
|
14
|
-
constructor(
|
|
15
|
-
this.file =
|
|
14
|
+
constructor(file2) {
|
|
15
|
+
this.file = file2;
|
|
16
16
|
}
|
|
17
17
|
static fromHome(homeDir) {
|
|
18
18
|
return new _ConfigStore(path.join(homeDir, "config.json"));
|
|
@@ -71,12 +71,12 @@ function createContext(homeDir, json) {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
function defaultHomeDir() {
|
|
74
|
-
return process.env.V_CLI_HOME || path2.join(os.homedir(), ".v-cli");
|
|
74
|
+
return process.env.V_CLI_HOME || path2.join(process.env.VANT_HOME || path2.join(os.homedir(), ".vant"), "tools", "v-cli");
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// src/core/loader.ts
|
|
78
78
|
import fs13 from "fs";
|
|
79
|
-
import
|
|
79
|
+
import path15 from "path";
|
|
80
80
|
import { pathToFileURL } from "url";
|
|
81
81
|
|
|
82
82
|
// src/core/official.ts
|
|
@@ -361,15 +361,15 @@ function defaultResolvePackage(pkg, opts = {}) {
|
|
|
361
361
|
}
|
|
362
362
|
return void 0;
|
|
363
363
|
}
|
|
364
|
-
function defaultExists(
|
|
364
|
+
function defaultExists(file2) {
|
|
365
365
|
try {
|
|
366
|
-
return fs2.existsSync(
|
|
366
|
+
return fs2.existsSync(file2);
|
|
367
367
|
} catch {
|
|
368
368
|
return false;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
function defaultRead(
|
|
372
|
-
return fs2.readFileSync(
|
|
371
|
+
function defaultRead(file2) {
|
|
372
|
+
return fs2.readFileSync(file2, "utf-8");
|
|
373
373
|
}
|
|
374
374
|
function formatErrors(errors) {
|
|
375
375
|
return errors.join("\uFF1B");
|
|
@@ -654,7 +654,7 @@ import { createHash, randomBytes } from "crypto";
|
|
|
654
654
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
655
655
|
|
|
656
656
|
// src/version.ts
|
|
657
|
-
var VERSION = "0.
|
|
657
|
+
var VERSION = "0.4.0";
|
|
658
658
|
|
|
659
659
|
// src/core/agent-docs.ts
|
|
660
660
|
var BUNDLED_DOCS_FILE = "AGENTS.md";
|
|
@@ -703,8 +703,8 @@ function resolveBundledAgentsMd(opts = {}) {
|
|
|
703
703
|
return void 0;
|
|
704
704
|
}
|
|
705
705
|
function readBundledAgentsMd(opts = {}) {
|
|
706
|
-
const
|
|
707
|
-
if (!
|
|
706
|
+
const file2 = resolveBundledAgentsMd(opts);
|
|
707
|
+
if (!file2) {
|
|
708
708
|
const tried = bundledCandidatePaths(opts.base ?? fileURLToPath2(import.meta.url));
|
|
709
709
|
const lastTried = tried.length > 0 ? tried[tried.length - 1] : "\uFF08\u65E0\u5019\u9009\u4F4D\u7F6E\uFF09";
|
|
710
710
|
throw new Error(
|
|
@@ -713,14 +713,14 @@ function readBundledAgentsMd(opts = {}) {
|
|
|
713
713
|
}
|
|
714
714
|
let content;
|
|
715
715
|
try {
|
|
716
|
-
content = fs3.readFileSync(
|
|
716
|
+
content = fs3.readFileSync(file2, "utf-8");
|
|
717
717
|
} catch (err) {
|
|
718
718
|
throw new Error(
|
|
719
|
-
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E ${BUNDLED_DOCS_FILE}\uFF08${
|
|
719
|
+
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E ${BUNDLED_DOCS_FILE}\uFF08${file2}\uFF09: ${err instanceof Error ? err.message : String(err)}`
|
|
720
720
|
);
|
|
721
721
|
}
|
|
722
722
|
return {
|
|
723
|
-
file,
|
|
723
|
+
file: file2,
|
|
724
724
|
content,
|
|
725
725
|
sha256: sha256Hex(content),
|
|
726
726
|
bytes: Buffer.byteLength(content, "utf-8")
|
|
@@ -751,21 +751,21 @@ function readOfficialAgentsMd(command, opts = {}) {
|
|
|
751
751
|
if (pkgJson.name !== spec.package || typeof pkgJson.version !== "string") {
|
|
752
752
|
throw new Error(`\u5B98\u65B9\u63D2\u4EF6 package.json \u8EAB\u4EFD\u65E0\u6548: \u671F\u671B ${spec.package} \u4E14 version \u4E3A\u5B57\u7B26\u4E32\u3002`);
|
|
753
753
|
}
|
|
754
|
-
const
|
|
754
|
+
const file2 = path4.join(path4.dirname(pkgJsonPath), BUNDLED_DOCS_FILE);
|
|
755
755
|
let content;
|
|
756
756
|
try {
|
|
757
|
-
if (!fs3.lstatSync(
|
|
758
|
-
content = fs3.readFileSync(
|
|
757
|
+
if (!fs3.lstatSync(file2).isFile()) throw new Error("\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");
|
|
758
|
+
content = fs3.readFileSync(file2, "utf-8");
|
|
759
759
|
} catch (err) {
|
|
760
760
|
throw new Error(
|
|
761
|
-
`\u5B98\u65B9\u63D2\u4EF6 ${spec.package}@${pkgJson.version} \u672A\u63D0\u4F9B\u53EF\u8BFB\u7684 ${BUNDLED_DOCS_FILE}\uFF08${
|
|
761
|
+
`\u5B98\u65B9\u63D2\u4EF6 ${spec.package}@${pkgJson.version} \u672A\u63D0\u4F9B\u53EF\u8BFB\u7684 ${BUNDLED_DOCS_FILE}\uFF08${file2}\uFF09: ${err instanceof Error ? err.message : String(err)}\u3002\u8BF7\u5347\u7EA7\u6216\u91CD\u65B0\u5B89\u88C5\u8BE5\u63D2\u4EF6\u3002`
|
|
762
762
|
);
|
|
763
763
|
}
|
|
764
764
|
return {
|
|
765
765
|
package: spec.package,
|
|
766
766
|
command,
|
|
767
767
|
version: pkgJson.version,
|
|
768
|
-
file,
|
|
768
|
+
file: file2,
|
|
769
769
|
content,
|
|
770
770
|
sha256: sha256Hex(content),
|
|
771
771
|
bytes: Buffer.byteLength(content, "utf-8")
|
|
@@ -924,19 +924,19 @@ function readSkillSource(opts = {}) {
|
|
|
924
924
|
`\u65E0\u6CD5\u5B9A\u4F4D ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E skill\uFF08skills/${SKILL_NAME}\uFF09\uFF1A\u8BF7\u786E\u8BA4\u5B89\u88C5\u7684\u5305\u5185\u5305\u542B skills/ \u76EE\u5F55\uFF08\u91CD\u65B0\u5B89\u88C5 @kevlns/v-cli \u540E\u91CD\u8BD5\uFF09\u3002`
|
|
925
925
|
);
|
|
926
926
|
}
|
|
927
|
-
const
|
|
927
|
+
const file2 = path5.join(root, SKILL_FILE);
|
|
928
928
|
let content;
|
|
929
929
|
try {
|
|
930
|
-
if (!fs4.lstatSync(
|
|
931
|
-
content = fs4.readFileSync(
|
|
930
|
+
if (!fs4.lstatSync(file2).isFile()) throw new Error("\u5165\u53E3\u4E0D\u662F\u666E\u901A\u6587\u4EF6");
|
|
931
|
+
content = fs4.readFileSync(file2, "utf-8");
|
|
932
932
|
} catch (err) {
|
|
933
933
|
throw new Error(
|
|
934
|
-
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E skill\uFF08${
|
|
934
|
+
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E skill\uFF08${file2}\uFF09: ${err instanceof Error ? err.message : String(err)}`
|
|
935
935
|
);
|
|
936
936
|
}
|
|
937
937
|
return {
|
|
938
938
|
root,
|
|
939
|
-
file,
|
|
939
|
+
file: file2,
|
|
940
940
|
content,
|
|
941
941
|
sha256: sha256Hex(content),
|
|
942
942
|
bytes: Buffer.byteLength(content, "utf-8")
|
|
@@ -963,9 +963,9 @@ function syncSkillDir(srcRoot, destDir, opts = {}) {
|
|
|
963
963
|
}
|
|
964
964
|
function readSkillFileAt(targetDir) {
|
|
965
965
|
try {
|
|
966
|
-
const
|
|
967
|
-
if (!fs4.lstatSync(
|
|
968
|
-
return fs4.readFileSync(
|
|
966
|
+
const file2 = path5.join(targetDir, SKILL_FILE);
|
|
967
|
+
if (!fs4.lstatSync(file2).isFile()) return void 0;
|
|
968
|
+
return fs4.readFileSync(file2, "utf-8");
|
|
969
969
|
} catch {
|
|
970
970
|
return void 0;
|
|
971
971
|
}
|
|
@@ -1390,7 +1390,7 @@ var agent = {
|
|
|
1390
1390
|
|
|
1391
1391
|
// src/commands/capability.ts
|
|
1392
1392
|
import fs11 from "fs";
|
|
1393
|
-
import
|
|
1393
|
+
import path13 from "path";
|
|
1394
1394
|
|
|
1395
1395
|
// src/core/execution/errors.ts
|
|
1396
1396
|
function structuredError(code, category, message, options = {}) {
|
|
@@ -2449,24 +2449,24 @@ function resolveBindings(project2, config, providers) {
|
|
|
2449
2449
|
return { ok: true, bindings: result };
|
|
2450
2450
|
}
|
|
2451
2451
|
function loadProjectConfig(project2, providers) {
|
|
2452
|
-
const
|
|
2452
|
+
const file2 = path8.join(project2.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
|
|
2453
2453
|
const initHint = `\u8BF7\u5148\u5728\u5DE5\u7A0B\u6839\u8FD0\u884C \`v-cli project init --project <\u5DE5\u7A0B\u6839>\` \u751F\u6210 ${PROJECT_CLI_CONFIG_RELATIVE}`;
|
|
2454
2454
|
let text;
|
|
2455
2455
|
try {
|
|
2456
2456
|
resolveInsideProject(project2, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
|
|
2457
|
-
text = fs6.readFileSync(
|
|
2457
|
+
text = fs6.readFileSync(file2, "utf-8");
|
|
2458
2458
|
} catch (err) {
|
|
2459
2459
|
if (err instanceof Error && "code" in err && String(err.code).startsWith("path-")) {
|
|
2460
|
-
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" };
|
|
2460
|
+
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" };
|
|
2461
2461
|
}
|
|
2462
2462
|
if (err instanceof Error && "code" in err && err.code === "ENOENT") {
|
|
2463
|
-
return { ok: false, file, kind: "missing", errors: [], hint: initHint };
|
|
2463
|
+
return { ok: false, file: file2, kind: "missing", errors: [], hint: initHint };
|
|
2464
2464
|
}
|
|
2465
2465
|
return {
|
|
2466
2466
|
ok: false,
|
|
2467
|
-
file,
|
|
2467
|
+
file: file2,
|
|
2468
2468
|
kind: "invalid",
|
|
2469
|
-
errors: [`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${
|
|
2469
|
+
errors: [`\u65E0\u6CD5\u8BFB\u53D6\u914D\u7F6E\u6587\u4EF6 ${file2}: ${err instanceof Error ? err.message : String(err)}`],
|
|
2470
2470
|
hint: "\u8BF7\u68C0\u67E5\u914D\u7F6E\u6587\u4EF6\u6743\u9650\u540E\u91CD\u8BD5"
|
|
2471
2471
|
};
|
|
2472
2472
|
}
|
|
@@ -2476,7 +2476,7 @@ function loadProjectConfig(project2, providers) {
|
|
|
2476
2476
|
} catch (err) {
|
|
2477
2477
|
return {
|
|
2478
2478
|
ok: false,
|
|
2479
|
-
file,
|
|
2479
|
+
file: file2,
|
|
2480
2480
|
kind: "invalid",
|
|
2481
2481
|
errors: [`\u4E0D\u662F\u5408\u6CD5 JSON: ${err instanceof Error ? err.message : String(err)}`],
|
|
2482
2482
|
hint: "\u8BF7\u4FEE\u6B63\u914D\u7F6E\u6587\u4EF6\u5185\u5BB9\u540E\u91CD\u8BD5"
|
|
@@ -2486,7 +2486,7 @@ function loadProjectConfig(project2, providers) {
|
|
|
2486
2486
|
if (shellErrors.length > 0) {
|
|
2487
2487
|
return {
|
|
2488
2488
|
ok: false,
|
|
2489
|
-
file,
|
|
2489
|
+
file: file2,
|
|
2490
2490
|
kind: "invalid",
|
|
2491
2491
|
errors: shellErrors,
|
|
2492
2492
|
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"
|
|
@@ -2497,14 +2497,14 @@ function loadProjectConfig(project2, providers) {
|
|
|
2497
2497
|
if (!resolvedBindings.ok) {
|
|
2498
2498
|
return {
|
|
2499
2499
|
ok: false,
|
|
2500
|
-
file,
|
|
2500
|
+
file: file2,
|
|
2501
2501
|
kind: resolvedBindings.pathUnsafe ? "unsafe-binding" : "invalid",
|
|
2502
2502
|
errors: resolvedBindings.errors,
|
|
2503
2503
|
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"
|
|
2504
2504
|
};
|
|
2505
2505
|
}
|
|
2506
2506
|
const unbound = [...providers.keys()].filter((id) => !(id in config.bindings));
|
|
2507
|
-
return { ok: true, file, config, resolved: resolvedBindings.bindings, unbound };
|
|
2507
|
+
return { ok: true, file: file2, config, resolved: resolvedBindings.bindings, unbound };
|
|
2508
2508
|
}
|
|
2509
2509
|
function renderProjectConfig(project2, providers, overrides = {}) {
|
|
2510
2510
|
const bindings = {};
|
|
@@ -2532,14 +2532,14 @@ function renderProjectConfig(project2, providers, overrides = {}) {
|
|
|
2532
2532
|
};
|
|
2533
2533
|
}
|
|
2534
2534
|
var CONFIG_BACKUP_RELATIVE = ".vant/state/config-backups";
|
|
2535
|
-
function atomicWriteConfig(project2,
|
|
2536
|
-
const configDir = path8.dirname(
|
|
2535
|
+
function atomicWriteConfig(project2, file2, content) {
|
|
2536
|
+
const configDir = path8.dirname(file2);
|
|
2537
2537
|
resolveInsideProject(project2, ".vant/config", ".vant/config");
|
|
2538
2538
|
fs6.mkdirSync(configDir, { recursive: true });
|
|
2539
|
-
const tmpPath = `${
|
|
2539
|
+
const tmpPath = `${file2}.${process.pid}.${Date.now()}.tmp`;
|
|
2540
2540
|
try {
|
|
2541
2541
|
fs6.writeFileSync(tmpPath, content, { encoding: "utf-8" });
|
|
2542
|
-
fs6.renameSync(tmpPath,
|
|
2542
|
+
fs6.renameSync(tmpPath, file2);
|
|
2543
2543
|
} catch (err) {
|
|
2544
2544
|
try {
|
|
2545
2545
|
fs6.rmSync(tmpPath, { force: true });
|
|
@@ -2549,13 +2549,13 @@ function atomicWriteConfig(project2, file, content) {
|
|
|
2549
2549
|
}
|
|
2550
2550
|
}
|
|
2551
2551
|
function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
2552
|
-
const
|
|
2552
|
+
const file2 = path8.join(project2.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
|
|
2553
2553
|
const vantFile = path8.join(project2.root, ...VANT_PROJECT_CONFIG_RELATIVE.split("/"));
|
|
2554
2554
|
const vantConfig = { file: vantFile, exists: fs6.existsSync(vantFile) };
|
|
2555
2555
|
const refused = (reason) => ({
|
|
2556
2556
|
ok: false,
|
|
2557
2557
|
action: "refused",
|
|
2558
|
-
file,
|
|
2558
|
+
file: file2,
|
|
2559
2559
|
relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
|
|
2560
2560
|
projectRoot: project2.root,
|
|
2561
2561
|
reason,
|
|
@@ -2566,14 +2566,14 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2566
2566
|
const known = [...providers.keys()].sort().join(", ") || "\uFF08\u65E0\u5DF2\u6CE8\u518C Provider\uFF09";
|
|
2567
2567
|
return refused(`\u672A\u77E5 Provider \u7ED1\u5B9A\u8986\u76D6: ${unknownOverrides.join(", ")}\uFF08\u5DF2\u6CE8\u518C: ${known}\uFF09`);
|
|
2568
2568
|
}
|
|
2569
|
-
const exists = fs6.existsSync(
|
|
2569
|
+
const exists = fs6.existsSync(file2);
|
|
2570
2570
|
const reset = options.reset === true;
|
|
2571
2571
|
const dryRun = options.dryRun === true;
|
|
2572
2572
|
if (exists && !reset) {
|
|
2573
2573
|
resolveInsideProject(project2, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
|
|
2574
2574
|
let existing;
|
|
2575
2575
|
try {
|
|
2576
|
-
existing = JSON.parse(fs6.readFileSync(
|
|
2576
|
+
existing = JSON.parse(fs6.readFileSync(file2, "utf-8"));
|
|
2577
2577
|
} catch (err) {
|
|
2578
2578
|
return refused(
|
|
2579
2579
|
`\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`
|
|
@@ -2620,14 +2620,14 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2620
2620
|
if (!existingCheck.ok) {
|
|
2621
2621
|
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`);
|
|
2622
2622
|
}
|
|
2623
|
-
const current = fs6.readFileSync(
|
|
2623
|
+
const current = fs6.readFileSync(file2, "utf-8");
|
|
2624
2624
|
return {
|
|
2625
2625
|
ok: true,
|
|
2626
2626
|
action: "unchanged",
|
|
2627
2627
|
dryRun,
|
|
2628
2628
|
existed: true,
|
|
2629
2629
|
added: [],
|
|
2630
|
-
file,
|
|
2630
|
+
file: file2,
|
|
2631
2631
|
relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
|
|
2632
2632
|
bytes: Buffer.byteLength(current, "utf-8"),
|
|
2633
2633
|
sha256: createHash2("sha256").update(current, "utf-8").digest("hex"),
|
|
@@ -2645,7 +2645,7 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2645
2645
|
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`);
|
|
2646
2646
|
}
|
|
2647
2647
|
if (!dryRun) {
|
|
2648
|
-
atomicWriteConfig(project2,
|
|
2648
|
+
atomicWriteConfig(project2, file2, content);
|
|
2649
2649
|
}
|
|
2650
2650
|
return {
|
|
2651
2651
|
ok: true,
|
|
@@ -2653,7 +2653,7 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2653
2653
|
dryRun,
|
|
2654
2654
|
existed: true,
|
|
2655
2655
|
added,
|
|
2656
|
-
file,
|
|
2656
|
+
file: file2,
|
|
2657
2657
|
relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
|
|
2658
2658
|
bytes: Buffer.byteLength(content, "utf-8"),
|
|
2659
2659
|
sha256: createHash2("sha256").update(content, "utf-8").digest("hex"),
|
|
@@ -2679,16 +2679,16 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2679
2679
|
fs6.mkdirSync(backupDir, { recursive: true });
|
|
2680
2680
|
const stamp = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${process.pid.toString(36)}`;
|
|
2681
2681
|
backupPath = path8.join(backupDir, `v-cli.${stamp}.json`);
|
|
2682
|
-
fs6.copyFileSync(
|
|
2682
|
+
fs6.copyFileSync(file2, backupPath);
|
|
2683
2683
|
}
|
|
2684
2684
|
if (!dryRun) {
|
|
2685
2685
|
if (exists) {
|
|
2686
|
-
atomicWriteConfig(project2,
|
|
2686
|
+
atomicWriteConfig(project2, file2, rendered.content);
|
|
2687
2687
|
} else {
|
|
2688
2688
|
const configDir = path8.join(project2.root, ".vant", "config");
|
|
2689
2689
|
resolveInsideProject(project2, ".vant/config", ".vant/config");
|
|
2690
2690
|
fs6.mkdirSync(configDir, { recursive: true });
|
|
2691
|
-
fs6.writeFileSync(
|
|
2691
|
+
fs6.writeFileSync(file2, rendered.content, { encoding: "utf-8", flag: "wx" });
|
|
2692
2692
|
}
|
|
2693
2693
|
}
|
|
2694
2694
|
return {
|
|
@@ -2697,7 +2697,7 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2697
2697
|
dryRun,
|
|
2698
2698
|
existed: exists,
|
|
2699
2699
|
added: Object.keys(candidate.bindings),
|
|
2700
|
-
file,
|
|
2700
|
+
file: file2,
|
|
2701
2701
|
relativeFile: PROJECT_CLI_CONFIG_RELATIVE,
|
|
2702
2702
|
bytes: rendered.bytes,
|
|
2703
2703
|
sha256: rendered.sha256,
|
|
@@ -4004,9 +4004,9 @@ var FAIL_COUNT_PATHS = [
|
|
|
4004
4004
|
];
|
|
4005
4005
|
function extractFailCount(payload) {
|
|
4006
4006
|
if (!isPlainObject8(payload)) return { count: null, source: null };
|
|
4007
|
-
for (const
|
|
4007
|
+
for (const path16 of FAIL_COUNT_PATHS) {
|
|
4008
4008
|
let current = payload;
|
|
4009
|
-
for (const segment of
|
|
4009
|
+
for (const segment of path16) {
|
|
4010
4010
|
if (!isPlainObject8(current)) {
|
|
4011
4011
|
current = void 0;
|
|
4012
4012
|
break;
|
|
@@ -4014,16 +4014,16 @@ function extractFailCount(payload) {
|
|
|
4014
4014
|
current = current[segment];
|
|
4015
4015
|
}
|
|
4016
4016
|
if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
|
|
4017
|
-
return { count: current, source:
|
|
4017
|
+
return { count: current, source: path16.join(".") };
|
|
4018
4018
|
}
|
|
4019
4019
|
}
|
|
4020
4020
|
return { count: null, source: null };
|
|
4021
4021
|
}
|
|
4022
4022
|
function extractTotal(payload) {
|
|
4023
4023
|
if (!isPlainObject8(payload)) return { total: null, source: null };
|
|
4024
|
-
for (const
|
|
4024
|
+
for (const path16 of [["summary", "total"]]) {
|
|
4025
4025
|
let current = payload;
|
|
4026
|
-
for (const segment of
|
|
4026
|
+
for (const segment of path16) {
|
|
4027
4027
|
if (!isPlainObject8(current)) {
|
|
4028
4028
|
current = void 0;
|
|
4029
4029
|
break;
|
|
@@ -4031,7 +4031,7 @@ function extractTotal(payload) {
|
|
|
4031
4031
|
current = current[segment];
|
|
4032
4032
|
}
|
|
4033
4033
|
if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
|
|
4034
|
-
return { total: current, source:
|
|
4034
|
+
return { total: current, source: path16.join(".") };
|
|
4035
4035
|
}
|
|
4036
4036
|
}
|
|
4037
4037
|
return { total: null, source: null };
|
|
@@ -6021,9 +6021,413 @@ function createUnityProvider(deps) {
|
|
|
6021
6021
|
};
|
|
6022
6022
|
}
|
|
6023
6023
|
|
|
6024
|
+
// src/providers/art/index.ts
|
|
6025
|
+
import path11 from "path";
|
|
6026
|
+
import { readFileSync } from "fs";
|
|
6027
|
+
var identifier = {
|
|
6028
|
+
type: "string",
|
|
6029
|
+
pattern: "^[a-z0-9][a-z0-9-]{0,63}$"
|
|
6030
|
+
};
|
|
6031
|
+
var revision = { type: "integer", minimum: 1 };
|
|
6032
|
+
var file = {
|
|
6033
|
+
type: "string",
|
|
6034
|
+
minLength: 1,
|
|
6035
|
+
description: "\u76F8\u5BF9\u5DE5\u7A0B\u6839\u7684\u53D7\u63A7\u6587\u4EF6\u8DEF\u5F84"
|
|
6036
|
+
};
|
|
6037
|
+
var artBindingContract = {
|
|
6038
|
+
schema: {
|
|
6039
|
+
type: "object",
|
|
6040
|
+
additionalProperties: false,
|
|
6041
|
+
required: ["workspace", "output", "cache", "projectId"],
|
|
6042
|
+
properties: {
|
|
6043
|
+
workspace: file,
|
|
6044
|
+
output: file,
|
|
6045
|
+
cache: file,
|
|
6046
|
+
projectId: identifier
|
|
6047
|
+
}
|
|
6048
|
+
},
|
|
6049
|
+
pathFields: ["workspace", "output", "cache"].map((field) => ({
|
|
6050
|
+
field,
|
|
6051
|
+
kind: "dir",
|
|
6052
|
+
required: true
|
|
6053
|
+
})),
|
|
6054
|
+
resolve: ({ project: project2, raw, resolveInsideProject: inside }) => {
|
|
6055
|
+
const b = raw;
|
|
6056
|
+
if (!b || typeof b !== "object" || !["workspace", "output", "cache", "projectId"].every(
|
|
6057
|
+
(k) => typeof b[k] === "string"
|
|
6058
|
+
))
|
|
6059
|
+
return {
|
|
6060
|
+
ok: false,
|
|
6061
|
+
errors: ["art \u7ED1\u5B9A\u5FC5\u987B\u5305\u542B workspace/output/cache/projectId"]
|
|
6062
|
+
};
|
|
6063
|
+
const dirs = Object.fromEntries(
|
|
6064
|
+
["workspace", "output", "cache"].map((k) => [
|
|
6065
|
+
k,
|
|
6066
|
+
inside(project2, b[k], "bindings.art." + k).path
|
|
6067
|
+
])
|
|
6068
|
+
);
|
|
6069
|
+
return { ok: true, dirs, files: {}, section: { ...b }, warnings: [] };
|
|
6070
|
+
}
|
|
6071
|
+
};
|
|
6072
|
+
var objectFields = { id: identifier, revision, input: file };
|
|
6073
|
+
var definitions = [
|
|
6074
|
+
{ id: "job-template", command: ["job", "template"], fields: { kind: { type: "string", enum: ["generate", "edit"] }, core: identifier }, required: ["kind"], readonly: true },
|
|
6075
|
+
{ 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"] },
|
|
6076
|
+
{ id: "deployment-plan", command: ["deployment", "plan"], fields: { directory: { type: "string", minLength: 1 }, endpoint: { type: "string", minLength: 1 } }, required: ["directory"], readonly: true },
|
|
6077
|
+
{ id: "deployment-start", command: ["deployment", "start"], fields: { plan: file, operation: { type: "string", pattern: "^[a-z0-9-]{1,128}$" } }, required: ["plan", "operation"], network: true },
|
|
6078
|
+
...["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" })),
|
|
6079
|
+
{ id: "run-recover", command: ["task", "recover"], fields: { operation: { type: "string", pattern: "^[a-z0-9-]{1,128}$" } }, required: ["operation"], start: true },
|
|
6080
|
+
...["style", "job"].flatMap(
|
|
6081
|
+
(kind) => ["create", "list", "read", "update", "derive", "discard"].map(
|
|
6082
|
+
(action) => ({
|
|
6083
|
+
id: kind + "-" + action,
|
|
6084
|
+
command: [kind, action],
|
|
6085
|
+
fields: action === "list" ? {} : action === "create" ? { input: file } : action === "read" ? { id: identifier } : action === "update" ? objectFields : { id: identifier, revision },
|
|
6086
|
+
required: action === "list" ? [] : action === "create" ? ["input"] : action === "read" ? ["id"] : action === "update" ? ["id", "revision", "input"] : ["id", "revision"],
|
|
6087
|
+
readonly: ["list", "read"].includes(action)
|
|
6088
|
+
})
|
|
6089
|
+
)
|
|
6090
|
+
),
|
|
6091
|
+
{ id: "run-list", command: ["task", "list"], fields: {}, readonly: true },
|
|
6092
|
+
{
|
|
6093
|
+
id: "project-init",
|
|
6094
|
+
command: ["project", "init"],
|
|
6095
|
+
fields: { input: file },
|
|
6096
|
+
required: ["input"]
|
|
6097
|
+
},
|
|
6098
|
+
{
|
|
6099
|
+
id: "style-analyze",
|
|
6100
|
+
command: ["style", "analyze"],
|
|
6101
|
+
fields: { id: identifier, revision, dry: { type: "boolean" } },
|
|
6102
|
+
required: ["id", "revision"],
|
|
6103
|
+
start: true
|
|
6104
|
+
},
|
|
6105
|
+
{
|
|
6106
|
+
id: "job-analyze",
|
|
6107
|
+
command: ["job", "analyze"],
|
|
6108
|
+
fields: { id: identifier, revision, dry: { type: "boolean" } },
|
|
6109
|
+
required: ["id", "revision"],
|
|
6110
|
+
start: true
|
|
6111
|
+
},
|
|
6112
|
+
{
|
|
6113
|
+
id: "style-adopt",
|
|
6114
|
+
command: ["style", "adopt"],
|
|
6115
|
+
fields: { id: identifier, revision, note: { type: "string" } },
|
|
6116
|
+
required: ["id", "revision"]
|
|
6117
|
+
},
|
|
6118
|
+
{
|
|
6119
|
+
id: "style-recover",
|
|
6120
|
+
command: ["style", "recover"],
|
|
6121
|
+
fields: { id: identifier },
|
|
6122
|
+
required: ["id"]
|
|
6123
|
+
},
|
|
6124
|
+
...["generate", "edit"].map((kind) => ({
|
|
6125
|
+
id: kind + "-plan",
|
|
6126
|
+
command: [kind, "plan"],
|
|
6127
|
+
fields: { job: identifier, backend: identifier, out: file },
|
|
6128
|
+
required: ["job"]
|
|
6129
|
+
})),
|
|
6130
|
+
...["generate", "edit"].map((kind) => ({
|
|
6131
|
+
id: kind + "-start",
|
|
6132
|
+
command: [kind, "run"],
|
|
6133
|
+
fields: {
|
|
6134
|
+
plan: file,
|
|
6135
|
+
item: identifier,
|
|
6136
|
+
variant: identifier,
|
|
6137
|
+
"all-variants": { type: "boolean" },
|
|
6138
|
+
"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" },
|
|
6139
|
+
dry: { type: "boolean" }
|
|
6140
|
+
},
|
|
6141
|
+
required: ["plan"],
|
|
6142
|
+
start: true
|
|
6143
|
+
})),
|
|
6144
|
+
...["status", "cancel", "resume"].map((action) => ({
|
|
6145
|
+
id: "run-" + action,
|
|
6146
|
+
command: ["task", action],
|
|
6147
|
+
fields: {
|
|
6148
|
+
handle: { type: "object", additionalProperties: true }
|
|
6149
|
+
},
|
|
6150
|
+
required: ["handle"],
|
|
6151
|
+
control: true,
|
|
6152
|
+
readonly: action === "status"
|
|
6153
|
+
})),
|
|
6154
|
+
{
|
|
6155
|
+
id: "reference-list",
|
|
6156
|
+
command: ["reference", "list"],
|
|
6157
|
+
fields: {
|
|
6158
|
+
kind: { type: "string", enum: ["style", "task"] },
|
|
6159
|
+
id: identifier
|
|
6160
|
+
},
|
|
6161
|
+
required: ["kind", "id"],
|
|
6162
|
+
readonly: true
|
|
6163
|
+
},
|
|
6164
|
+
{
|
|
6165
|
+
id: "reference-import",
|
|
6166
|
+
command: ["reference", "import"],
|
|
6167
|
+
fields: {
|
|
6168
|
+
kind: { type: "string", enum: ["style", "task"] },
|
|
6169
|
+
id: identifier,
|
|
6170
|
+
revision,
|
|
6171
|
+
source: file,
|
|
6172
|
+
category: {
|
|
6173
|
+
type: "string",
|
|
6174
|
+
enum: ["style", "palette", "shape-language", "rendering"]
|
|
6175
|
+
},
|
|
6176
|
+
purposes: { type: "string" },
|
|
6177
|
+
note: { type: "string" }
|
|
6178
|
+
},
|
|
6179
|
+
required: ["kind", "id", "revision", "source"]
|
|
6180
|
+
},
|
|
6181
|
+
{
|
|
6182
|
+
id: "reference-remove",
|
|
6183
|
+
command: ["reference", "remove"],
|
|
6184
|
+
fields: {
|
|
6185
|
+
kind: { type: "string", enum: ["style", "task"] },
|
|
6186
|
+
id: identifier,
|
|
6187
|
+
revision,
|
|
6188
|
+
item: identifier
|
|
6189
|
+
},
|
|
6190
|
+
required: ["kind", "id", "revision", "item"]
|
|
6191
|
+
},
|
|
6192
|
+
{
|
|
6193
|
+
id: "reference-update",
|
|
6194
|
+
command: ["reference", "update"],
|
|
6195
|
+
fields: { kind: { type: "string", enum: ["style", "task"] }, id: identifier, revision, item: identifier, input: file },
|
|
6196
|
+
required: ["kind", "id", "revision", "item", "input"]
|
|
6197
|
+
},
|
|
6198
|
+
...["list", "finalizations", "finalize", "delete"].map(
|
|
6199
|
+
(action) => ({
|
|
6200
|
+
id: "candidate-" + action,
|
|
6201
|
+
command: ["candidate", action],
|
|
6202
|
+
fields: {
|
|
6203
|
+
job: identifier,
|
|
6204
|
+
run: identifier,
|
|
6205
|
+
candidate: { type: "string" },
|
|
6206
|
+
revision,
|
|
6207
|
+
actor: { type: "string" },
|
|
6208
|
+
replace: { type: "boolean" },
|
|
6209
|
+
confirm: { type: "boolean" }
|
|
6210
|
+
},
|
|
6211
|
+
required: [
|
|
6212
|
+
"job",
|
|
6213
|
+
...action === "finalizations" ? [] : ["run"],
|
|
6214
|
+
...["finalize", "delete"].includes(action) ? ["candidate", "revision", "actor"] : []
|
|
6215
|
+
],
|
|
6216
|
+
readonly: ["list", "finalizations"].includes(action)
|
|
6217
|
+
})
|
|
6218
|
+
)
|
|
6219
|
+
];
|
|
6220
|
+
function createArtProvider(deps) {
|
|
6221
|
+
const discover = deps.discoverBackend ?? (() => discoverOfficialPlugin(
|
|
6222
|
+
OFFICIAL_PLUGINS.find((s) => s.command === "art")
|
|
6223
|
+
));
|
|
6224
|
+
const registrations = definitions.map((d) => ({
|
|
6225
|
+
descriptor: {
|
|
6226
|
+
id: "art." + d.id,
|
|
6227
|
+
version: "0.1.0",
|
|
6228
|
+
description: "\u7F8E\u672F\u5DE5\u574A " + d.command.join(" ") + "\uFF1B\u5BF9\u8C61\u7248\u672C\u4E0E\u505C\u6B62\u8BC1\u636E\u7531\u5DE5\u5177\u6838\u9A8C",
|
|
6229
|
+
inputSchema: {
|
|
6230
|
+
type: "object",
|
|
6231
|
+
additionalProperties: false,
|
|
6232
|
+
properties: d.fields,
|
|
6233
|
+
required: d.required ?? []
|
|
6234
|
+
},
|
|
6235
|
+
outputSchema: {
|
|
6236
|
+
type: "object",
|
|
6237
|
+
additionalProperties: true,
|
|
6238
|
+
required: ["result"],
|
|
6239
|
+
properties: { result: { type: "object", additionalProperties: true } }
|
|
6240
|
+
},
|
|
6241
|
+
preconditions: [],
|
|
6242
|
+
sideEffects: [
|
|
6243
|
+
{
|
|
6244
|
+
id: "read-art",
|
|
6245
|
+
kind: "fs-read",
|
|
6246
|
+
description: "\u8BFB\u53D6\u53D7\u7BA1\u5BF9\u8C61\u4E0E\u6267\u884C\u8BC1\u636E",
|
|
6247
|
+
reversible: true
|
|
6248
|
+
},
|
|
6249
|
+
{
|
|
6250
|
+
id: "invoke-art",
|
|
6251
|
+
kind: "process-exec",
|
|
6252
|
+
description: "\u53D7\u63A7\u53C2\u6570\u8C03\u7528\u5B98\u65B9 art \u5DE5\u5177",
|
|
6253
|
+
reversible: false
|
|
6254
|
+
},
|
|
6255
|
+
...d.start || d.control || d.network ? [
|
|
6256
|
+
{
|
|
6257
|
+
id: "art-network",
|
|
6258
|
+
kind: "network",
|
|
6259
|
+
description: "\u8C03\u7528\u6A21\u578B\u6216\u67E5\u8BE2\u3001\u53D6\u6D88\u540E\u7AEF\u6267\u884C",
|
|
6260
|
+
reversible: false
|
|
6261
|
+
}
|
|
6262
|
+
] : [],
|
|
6263
|
+
...!d.readonly ? [
|
|
6264
|
+
{
|
|
6265
|
+
id: "art-mutation",
|
|
6266
|
+
kind: "fs-write",
|
|
6267
|
+
description: "\u5BF9\u8C61\u914D\u7F6E\u3001\u6267\u884C\u8BC1\u636E\u6216\u5B9A\u7248\u53D8\u66F4\uFF1B\u542F\u52A8\u53EF\u8C03\u7528\u6A21\u578B",
|
|
6268
|
+
reversible: false
|
|
6269
|
+
}
|
|
6270
|
+
] : []
|
|
6271
|
+
],
|
|
6272
|
+
resources: [
|
|
6273
|
+
{
|
|
6274
|
+
kind: "project-workspace",
|
|
6275
|
+
mode: d.readonly ? "shared" : "exclusive",
|
|
6276
|
+
scope: "project",
|
|
6277
|
+
description: "\u7EC4\u7EC7\u5C42\u7BA1\u7406\u5BF9\u8C61\u8D44\u6E90\u5360\u7528\uFF0C\u505C\u6B62\u672A\u77E5\u7EE7\u7EED\u5360\u7528"
|
|
6278
|
+
}
|
|
6279
|
+
],
|
|
6280
|
+
retry: {
|
|
6281
|
+
safe: !!d.readonly,
|
|
6282
|
+
maxAttempts: 1,
|
|
6283
|
+
strategy: "none",
|
|
6284
|
+
description: "\u542F\u52A8\u4E0D\u81EA\u52A8\u91CD\u8BD5\uFF1B\u6062\u590D\u67E5\u8BE2\u539F\u53E5\u67C4"
|
|
6285
|
+
},
|
|
6286
|
+
timeoutMs: 9e4,
|
|
6287
|
+
tags: ["art", "lifecycle"]
|
|
6288
|
+
},
|
|
6289
|
+
implementation: {
|
|
6290
|
+
execute: async (input, ctx) => {
|
|
6291
|
+
const backend = discover();
|
|
6292
|
+
const fail = (code, message) => ({
|
|
6293
|
+
execution: {
|
|
6294
|
+
status: "failed",
|
|
6295
|
+
lifecycle: "failed",
|
|
6296
|
+
error: structuredError(code, "precondition", message)
|
|
6297
|
+
},
|
|
6298
|
+
acceptance: { status: "not-run", reason: message }
|
|
6299
|
+
});
|
|
6300
|
+
if (backend.status !== "available" || !backend.bin)
|
|
6301
|
+
return fail(
|
|
6302
|
+
"art-backend-unavailable",
|
|
6303
|
+
backend.error ?? "art \u540E\u7AEF\u4E0D\u53EF\u7528"
|
|
6304
|
+
);
|
|
6305
|
+
if (!ctx.binding || !ctx.bindingDirs.workspace)
|
|
6306
|
+
return fail("art-binding-missing", "\u7F3A\u5C11 art \u5DE5\u7A0B\u7ED1\u5B9A");
|
|
6307
|
+
if (d.start && input.plan) {
|
|
6308
|
+
const file2 = resolveInsideProject(ctx.projectAnchor, String(input.plan), "art.plan").path;
|
|
6309
|
+
const plan = JSON.parse(readFileSync(file2, "utf8"));
|
|
6310
|
+
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");
|
|
6311
|
+
}
|
|
6312
|
+
const argv = [
|
|
6313
|
+
...d.command,
|
|
6314
|
+
"--workspace",
|
|
6315
|
+
ctx.bindingDirs.workspace,
|
|
6316
|
+
"--output-dir",
|
|
6317
|
+
ctx.bindingDirs.output,
|
|
6318
|
+
"--cache-dir",
|
|
6319
|
+
ctx.bindingDirs.cache,
|
|
6320
|
+
"--config",
|
|
6321
|
+
path11.join(ctx.bindingDirs.workspace, "settings.json")
|
|
6322
|
+
];
|
|
6323
|
+
if (!d.control && !(d.command[1] === "run" && input.plan))
|
|
6324
|
+
argv.push("--project", String(ctx.binding.projectId));
|
|
6325
|
+
if (d.control) {
|
|
6326
|
+
const verification = verifyExecutionHandle({
|
|
6327
|
+
project: ctx.projectAnchor,
|
|
6328
|
+
handle: input.handle,
|
|
6329
|
+
expectProviderId: "art"
|
|
6330
|
+
});
|
|
6331
|
+
if (!verification.ok)
|
|
6332
|
+
return fail(verification.code, verification.errors.join("; "));
|
|
6333
|
+
if (!verification.record.backendTaskId)
|
|
6334
|
+
return fail("art-handle-missing", "\u53E5\u67C4\u7F3A\u5C11\u540E\u7AEF\u8FD0\u884C\u8EAB\u4EFD");
|
|
6335
|
+
const origin = JSON.parse(readFileSync(resolveInsideProject(ctx.projectAnchor, verification.record.recordDir + "/result.json", "art.origin").path, "utf8"));
|
|
6336
|
+
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");
|
|
6337
|
+
argv.splice(2, 0, verification.record.backendTaskId);
|
|
6338
|
+
}
|
|
6339
|
+
for (const [key, value] of Object.entries(input)) {
|
|
6340
|
+
if (key === "handle" || value === false) continue;
|
|
6341
|
+
const actual = ["input", "source", "plan", "out"].includes(key) ? resolveInsideProject(
|
|
6342
|
+
ctx.projectAnchor,
|
|
6343
|
+
String(value),
|
|
6344
|
+
"art." + key
|
|
6345
|
+
).path : value;
|
|
6346
|
+
argv.push("--" + key);
|
|
6347
|
+
if (value !== true) argv.push(String(actual));
|
|
6348
|
+
}
|
|
6349
|
+
if (d.start && d.id !== "run-recover" && !input.dry) argv.push("--operation", ctx.operationId);
|
|
6350
|
+
if (d.start && d.command[1] === "run" && !input.dry)
|
|
6351
|
+
argv.push("--background");
|
|
6352
|
+
const outcome = await deps.executor.run({
|
|
6353
|
+
file: process.execPath,
|
|
6354
|
+
args: [backend.bin, ...argv],
|
|
6355
|
+
cwd: ctx.projectAnchor.root,
|
|
6356
|
+
env: deps.env,
|
|
6357
|
+
timeoutMs: 9e4,
|
|
6358
|
+
signal: ctx.signal
|
|
6359
|
+
});
|
|
6360
|
+
let output;
|
|
6361
|
+
try {
|
|
6362
|
+
const parsed = JSON.parse(outcome.stdout);
|
|
6363
|
+
output = Array.isArray(parsed) ? { items: parsed } : parsed;
|
|
6364
|
+
if (!output || typeof output !== "object") throw new Error();
|
|
6365
|
+
} catch {
|
|
6366
|
+
const processState = executionFromProcess(outcome);
|
|
6367
|
+
const uncertain = d.start || d.control || d.id === "deployment-start" || processState.lifecycle === "unknown";
|
|
6368
|
+
return {
|
|
6369
|
+
execution: {
|
|
6370
|
+
...processState,
|
|
6371
|
+
status: "failed",
|
|
6372
|
+
lifecycle: uncertain ? "unknown" : processState.lifecycle,
|
|
6373
|
+
error: structuredError(
|
|
6374
|
+
"art-output-invalid",
|
|
6375
|
+
"protocol",
|
|
6376
|
+
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"
|
|
6377
|
+
)
|
|
6378
|
+
},
|
|
6379
|
+
acceptance: { status: "not-run", reason: "\u534F\u8BAE\u7ED3\u679C\u672A\u77E5\uFF0C\u4E0D\u80FD\u58F0\u79F0\u4E1A\u52A1\u6210\u529F" },
|
|
6380
|
+
rawOutput: outcome
|
|
6381
|
+
};
|
|
6382
|
+
}
|
|
6383
|
+
let lifecycle = executionFromProcess(outcome).lifecycle;
|
|
6384
|
+
if (typeof output.taskId === "string")
|
|
6385
|
+
lifecycle = output.lifecycle ?? (d.start && !input.dry ? "accepted" : output.stopConfirmed === true ? "completed" : "unknown");
|
|
6386
|
+
return {
|
|
6387
|
+
execution: {
|
|
6388
|
+
...executionFromProcess(outcome),
|
|
6389
|
+
lifecycle,
|
|
6390
|
+
...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"))) } : {}
|
|
6391
|
+
},
|
|
6392
|
+
acceptance: {
|
|
6393
|
+
status: "not-run",
|
|
6394
|
+
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"
|
|
6395
|
+
},
|
|
6396
|
+
output: { result: { ...output, ...d.start ? { project: ctx.binding.projectId } : {} } },
|
|
6397
|
+
rawOutput: { stdout: outcome.stdout, stderr: outcome.stderr },
|
|
6398
|
+
...d.start && !input.dry && typeof output.taskId === "string" ? { handle: { backendTaskId: output.taskId } } : {}
|
|
6399
|
+
};
|
|
6400
|
+
}
|
|
6401
|
+
}
|
|
6402
|
+
}));
|
|
6403
|
+
return {
|
|
6404
|
+
id: "art",
|
|
6405
|
+
version: "0.1.0",
|
|
6406
|
+
description: "\u7F8E\u672F\u5DE5\u574A\u6CE8\u518C\u6267\u884C\u9002\u914D\uFF1B\u65E0\u989D\u5916\u961F\u5217\u6216\u4E1A\u52A1\u72B6\u6001",
|
|
6407
|
+
binding: artBindingContract,
|
|
6408
|
+
defaultBinding: () => ({
|
|
6409
|
+
section: {
|
|
6410
|
+
workspace: ".vant/art",
|
|
6411
|
+
output: ".vant/art/output",
|
|
6412
|
+
cache: ".vant/art/cache",
|
|
6413
|
+
projectId: "project"
|
|
6414
|
+
},
|
|
6415
|
+
warnings: []
|
|
6416
|
+
}),
|
|
6417
|
+
status: async () => {
|
|
6418
|
+
const info = discover();
|
|
6419
|
+
return {
|
|
6420
|
+
state: info.status === "available" ? "available" : info.status,
|
|
6421
|
+
detail: info.error ?? "\u5B98\u65B9 art \u540E\u7AEF"
|
|
6422
|
+
};
|
|
6423
|
+
},
|
|
6424
|
+
capabilities: () => registrations
|
|
6425
|
+
};
|
|
6426
|
+
}
|
|
6427
|
+
|
|
6024
6428
|
// src/providers/figma/index.ts
|
|
6025
6429
|
import fs10 from "fs";
|
|
6026
|
-
import
|
|
6430
|
+
import path12 from "path";
|
|
6027
6431
|
|
|
6028
6432
|
// src/providers/figma/protocol.ts
|
|
6029
6433
|
var VALID_LINE = /^(?:\[figma-to-uprefab\] )?Contract valid: (\d+) root\(s\)\.$/;
|
|
@@ -6126,8 +6530,8 @@ var figmaBindingContract = {
|
|
|
6126
6530
|
if (errors.length > 0) return { ok: false, errors };
|
|
6127
6531
|
const projectDir = resolve(project2, section.projectDir, "bindings.figma.projectDir");
|
|
6128
6532
|
const stagingRoot = resolve(project2, section.stagingRoot, "bindings.figma.stagingRoot");
|
|
6129
|
-
const rel =
|
|
6130
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
6533
|
+
const rel = path12.relative(projectDir.path, stagingRoot.path);
|
|
6534
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path12.sep}`) || path12.isAbsolute(rel)) {
|
|
6131
6535
|
return {
|
|
6132
6536
|
ok: false,
|
|
6133
6537
|
errors: [`bindings.figma.stagingRoot \u5FC5\u987B\u4F4D\u4E8E bindings.figma.projectDir\uFF08${section.projectDir}\uFF09\u5185\uFF08\u6536\u5230 ${section.stagingRoot}\uFF09`]
|
|
@@ -6148,7 +6552,7 @@ function figmaBinding(ctx) {
|
|
|
6148
6552
|
return binding;
|
|
6149
6553
|
}
|
|
6150
6554
|
function normalizeProjectKey(projectPath) {
|
|
6151
|
-
let key =
|
|
6555
|
+
let key = path12.resolve(projectPath).replace(/\\/g, "/");
|
|
6152
6556
|
if (process.platform === "win32") key = key.toLowerCase();
|
|
6153
6557
|
if (key.length > 3 && key.endsWith("/")) key = key.slice(0, -1);
|
|
6154
6558
|
return key;
|
|
@@ -6184,15 +6588,15 @@ function createFigmaProvider(deps) {
|
|
|
6184
6588
|
};
|
|
6185
6589
|
}
|
|
6186
6590
|
function writeManagedConfig(ctx, unityDir, stagingRootAbs) {
|
|
6187
|
-
const configPath =
|
|
6188
|
-
const stagingRelativeToUnity =
|
|
6591
|
+
const configPath = path12.join(ctx.projectAnchor.root, ...MANAGED_CONFIG_RELATIVE.split("/"));
|
|
6592
|
+
const stagingRelativeToUnity = path12.relative(unityDir, stagingRootAbs).split(path12.sep).join("/");
|
|
6189
6593
|
const payload = {
|
|
6190
6594
|
schemaVersion: 1,
|
|
6191
6595
|
projects: {
|
|
6192
6596
|
[normalizeProjectKey(unityDir)]: { uiSystem: "UGUI", staging: { root: stagingRelativeToUnity } }
|
|
6193
6597
|
}
|
|
6194
6598
|
};
|
|
6195
|
-
fs10.mkdirSync(
|
|
6599
|
+
fs10.mkdirSync(path12.dirname(configPath), { recursive: true });
|
|
6196
6600
|
const tmpPath = `${configPath}.${process.pid}.${Date.now()}.tmp`;
|
|
6197
6601
|
try {
|
|
6198
6602
|
fs10.writeFileSync(tmpPath, `${JSON.stringify(payload, null, 2)}
|
|
@@ -6590,10 +6994,10 @@ function createFigmaProvider(deps) {
|
|
|
6590
6994
|
binding: figmaBindingContract,
|
|
6591
6995
|
defaultBinding: (project2) => {
|
|
6592
6996
|
const warnings = [];
|
|
6593
|
-
const declared =
|
|
6997
|
+
const declared = path12.join(project2.root, "Client");
|
|
6594
6998
|
if (!fs10.existsSync(declared)) {
|
|
6595
6999
|
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');
|
|
6596
|
-
} else if (!fs10.existsSync(
|
|
7000
|
+
} else if (!fs10.existsSync(path12.join(declared, ...DEFAULT_STAGING_ROOT_SEGMENTS.split("/")))) {
|
|
6597
7001
|
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`);
|
|
6598
7002
|
}
|
|
6599
7003
|
return { section: { projectDir: "Client", stagingRoot: `Client/${DEFAULT_STAGING_ROOT_SEGMENTS}` }, warnings };
|
|
@@ -6635,6 +7039,7 @@ function createDefaultRegistry(options = {}) {
|
|
|
6635
7039
|
discoverBackend: options.figmaDiscoverBackend
|
|
6636
7040
|
})
|
|
6637
7041
|
);
|
|
7042
|
+
registry.registerProvider(createArtProvider({ executor, discoverBackend: options.artDiscoverBackend, env: options.artEnv }));
|
|
6638
7043
|
return registry;
|
|
6639
7044
|
}
|
|
6640
7045
|
|
|
@@ -6912,19 +7317,19 @@ var capability = {
|
|
|
6912
7317
|
try {
|
|
6913
7318
|
let input = {};
|
|
6914
7319
|
if (opts.inputFile) {
|
|
6915
|
-
const
|
|
7320
|
+
const file2 = path13.resolve(process.cwd(), opts.inputFile);
|
|
6916
7321
|
let text;
|
|
6917
7322
|
try {
|
|
6918
|
-
text = fs11.readFileSync(
|
|
7323
|
+
text = fs11.readFileSync(file2, "utf-8");
|
|
6919
7324
|
} catch (err) {
|
|
6920
7325
|
throw new CapabilityError({
|
|
6921
7326
|
code: "input-file-unreadable",
|
|
6922
7327
|
category: "request",
|
|
6923
|
-
message: `\u65E0\u6CD5\u8BFB\u53D6 --input-file ${
|
|
7328
|
+
message: `\u65E0\u6CD5\u8BFB\u53D6 --input-file ${file2}: ${err instanceof Error ? err.message : String(err)}`,
|
|
6924
7329
|
retryable: false
|
|
6925
7330
|
});
|
|
6926
7331
|
}
|
|
6927
|
-
input = parseJsonArg(text, `--input-file ${
|
|
7332
|
+
input = parseJsonArg(text, `--input-file ${file2}`);
|
|
6928
7333
|
}
|
|
6929
7334
|
if (opts.input) {
|
|
6930
7335
|
input = { ...input, ...parseJsonArg(opts.input, "--input") };
|
|
@@ -7045,7 +7450,7 @@ var doctor = {
|
|
|
7045
7450
|
};
|
|
7046
7451
|
|
|
7047
7452
|
// src/commands/plugin.ts
|
|
7048
|
-
import
|
|
7453
|
+
import path14 from "path";
|
|
7049
7454
|
var plugin = {
|
|
7050
7455
|
name: "plugin",
|
|
7051
7456
|
description: "\u63D2\u4EF6\u7BA1\u7406\uFF1Alist \u5217\u51FA\u547D\u4EE4\uFF0Cpath \u663E\u793A\u672C\u5730\u63D2\u4EF6\u76EE\u5F55",
|
|
@@ -7084,7 +7489,7 @@ var plugin = {
|
|
|
7084
7489
|
}
|
|
7085
7490
|
});
|
|
7086
7491
|
program.command("path").description("\u6253\u5370\u672C\u5730\u63D2\u4EF6\u76EE\u5F55\uFF08\u653E\u5165 .mjs \u6587\u4EF6\u5373\u751F\u6548\uFF09").option("--json", "\u8F93\u51FA\u673A\u5668\u53EF\u8BFB JSON").action((opts) => {
|
|
7087
|
-
const dir =
|
|
7492
|
+
const dir = path14.join(ctx.homeDir, "commands");
|
|
7088
7493
|
if (ctx.json || opts.json) {
|
|
7089
7494
|
ctx.log.result({ dir });
|
|
7090
7495
|
} else {
|
|
@@ -7282,7 +7687,7 @@ var project = {
|
|
|
7282
7687
|
...report.config.providerBindings.flatMap((b) => [
|
|
7283
7688
|
` [${b.providerId}] ${b.state === "bound" ? "\u5DF2\u7ED1\u5B9A" : b.state === "missing-binding" ? "\u7F3A\u7ED1\u5B9A\uFF08\u8FD0\u884C\u671F\u524D\u7F6E\u6761\u4EF6\u5C06\u5931\u8D25\uFF09" : "\u65E0\u6548"}`,
|
|
7284
7689
|
...Object.entries(b.dirs).map(([field, dir]) => ` ${field}: ${dir}`),
|
|
7285
|
-
...Object.entries(b.files).map(([field,
|
|
7690
|
+
...Object.entries(b.files).map(([field, file2]) => ` ${field}: ${file2}`),
|
|
7286
7691
|
...b.warnings.map((w) => ` \u8B66\u544A: ${w}`),
|
|
7287
7692
|
...b.errors.map((e) => ` - ${e}`)
|
|
7288
7693
|
]),
|
|
@@ -7357,12 +7762,12 @@ async function loadBuiltinCommands() {
|
|
|
7357
7762
|
return builtinCommands.map((command) => ({ command, source: "builtin" }));
|
|
7358
7763
|
}
|
|
7359
7764
|
async function loadLocalPlugins(ctx) {
|
|
7360
|
-
const dir =
|
|
7765
|
+
const dir = path15.join(ctx.homeDir, "commands");
|
|
7361
7766
|
const loaded = [];
|
|
7362
7767
|
if (!fs13.existsSync(dir)) return loaded;
|
|
7363
7768
|
const files = fs13.readdirSync(dir).filter((f) => f.endsWith(".mjs")).sort();
|
|
7364
|
-
for (const
|
|
7365
|
-
const abs =
|
|
7769
|
+
for (const file2 of files) {
|
|
7770
|
+
const abs = path15.join(dir, file2);
|
|
7366
7771
|
try {
|
|
7367
7772
|
const mod = await import(
|
|
7368
7773
|
/* @vite-ignore */
|