@kevlns/v-cli 0.5.2 → 0.6.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/AGENTS.md +25 -118
- package/LICENSE +21 -21
- package/README.md +184 -184
- package/dist/cli.mjs +267 -668
- package/dist/sdk.d.ts +44 -2
- package/dist/sdk.mjs +122 -7
- package/package.json +5 -3
- package/schemas/v-cli-plugin.schema.json +247 -144
- package/skills/v-cli/SKILL.md +10 -123
- package/skills/v-cli/references/project.md +115 -0
- package/v-cli.plugin.json +27 -0
package/dist/cli.mjs
CHANGED
|
@@ -75,8 +75,8 @@ function defaultHomeDir() {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// src/core/loader.ts
|
|
78
|
-
import
|
|
79
|
-
import
|
|
78
|
+
import fs15 from "fs";
|
|
79
|
+
import path16 from "path";
|
|
80
80
|
import { pathToFileURL } from "url";
|
|
81
81
|
|
|
82
82
|
// src/core/official.ts
|
|
@@ -177,6 +177,20 @@ function validateManifest(input) {
|
|
|
177
177
|
}
|
|
178
178
|
});
|
|
179
179
|
}
|
|
180
|
+
if (m.skills !== void 0) {
|
|
181
|
+
if (!Array.isArray(m.skills)) errors.push("skills \u5FC5\u987B\u662F\u6570\u7EC4");
|
|
182
|
+
else {
|
|
183
|
+
const seen = /* @__PURE__ */ new Set();
|
|
184
|
+
m.skills.forEach((skill, i) => {
|
|
185
|
+
if (!isPlainObject(skill) || typeof skill.id !== "string" || !COMMAND_NAME_RE.test(skill.id) || typeof skill.path !== "string" || !/^skills\/[a-z0-9-]+\/SKILL\.md$/.test(skill.path)) {
|
|
186
|
+
errors.push(`skills[${i}] \u6807\u8BC6\u6216\u5165\u53E3\u8DEF\u5F84\u65E0\u6548`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (seen.has(skill.id)) errors.push(`skills[${i}] \u6807\u8BC6\u91CD\u590D`);
|
|
190
|
+
seen.add(skill.id);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
180
194
|
const agent2 = m.agent;
|
|
181
195
|
if (!isPlainObject(agent2)) {
|
|
182
196
|
errors.push("agent \u5FC5\u987B\u662F\u5BF9\u8C61");
|
|
@@ -648,383 +662,108 @@ function validateLocalCommand(candidate, options = {}) {
|
|
|
648
662
|
return { ok: true, command: candidate, errors: [] };
|
|
649
663
|
}
|
|
650
664
|
|
|
651
|
-
// src/
|
|
652
|
-
import path6 from "path";
|
|
653
|
-
|
|
654
|
-
// src/core/agent-docs.ts
|
|
665
|
+
// src/core/skills.ts
|
|
655
666
|
import fs3 from "fs";
|
|
656
667
|
import path4 from "path";
|
|
657
|
-
import { createHash
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
668
|
+
import { createHash } from "crypto";
|
|
669
|
+
function discoverToolSkills(options = {}) {
|
|
670
|
+
const resolvePackage = options.resolvePackage ?? defaultResolvePackage;
|
|
671
|
+
const skills = [], diagnostics = [];
|
|
672
|
+
for (const spec of [{ package: "@kevlns/v-cli", command: "v-cli" }, ...OFFICIAL_PLUGINS]) {
|
|
673
|
+
const pkgFile = resolvePackage(spec.package);
|
|
674
|
+
if (!pkgFile) continue;
|
|
675
|
+
const root2 = path4.dirname(pkgFile), file2 = path4.join(root2, "v-cli.plugin.json");
|
|
676
|
+
if (!fs3.existsSync(file2)) continue;
|
|
677
|
+
const pkg = JSON.parse(fs3.readFileSync(pkgFile, "utf8"));
|
|
678
|
+
const manifest = JSON.parse(fs3.readFileSync(file2, "utf8"));
|
|
679
|
+
if (pkg.name !== spec.package || manifest.package !== spec.package || manifest.command !== spec.command)
|
|
680
|
+
throw new Error("\u5DE5\u5177\u6280\u80FD\u58F0\u660E\u8EAB\u4EFD\u4E0D\u4E00\u81F4\uFF1A" + spec.package);
|
|
681
|
+
if (manifest.skills !== void 0 && !Array.isArray(manifest.skills)) throw new Error("\u6280\u80FD\u58F0\u660E\u65E0\u6548");
|
|
682
|
+
for (const item of manifest.skills ?? []) {
|
|
683
|
+
if (!/^[a-z0-9][a-z0-9-]*$/.test(item.id) || item.path !== `skills/${item.id}/SKILL.md`)
|
|
684
|
+
throw new Error("\u6280\u80FD\u58F0\u660E\u65E0\u6548");
|
|
685
|
+
const entry = path4.resolve(root2, item.path), actual = fs3.realpathSync(entry), realRoot = fs3.realpathSync(root2);
|
|
686
|
+
const relative = path4.relative(realRoot, actual);
|
|
687
|
+
if (path4.isAbsolute(relative) || relative === ".." || relative.startsWith(".." + path4.sep)) throw new Error("\u6280\u80FD\u58F0\u660E\u8D8A\u754C");
|
|
688
|
+
if (skills.some((s) => s.id === item.id)) throw new Error("\u6280\u80FD\u6807\u8BC6\u91CD\u590D\uFF1A" + item.id);
|
|
689
|
+
skills.push({
|
|
690
|
+
id: item.id,
|
|
691
|
+
package: pkg.name,
|
|
692
|
+
tool: spec.command,
|
|
693
|
+
version: pkg.version,
|
|
694
|
+
path: actual,
|
|
695
|
+
contentHash: skillBundleHash(path4.dirname(actual))
|
|
696
|
+
});
|
|
684
697
|
}
|
|
685
|
-
|
|
686
|
-
if (parent === dir) break;
|
|
687
|
-
dir = parent;
|
|
698
|
+
if (manifest.skills === void 0) diagnostics.push(spec.command + " \u672A\u58F0\u660E\u6280\u80FD");
|
|
688
699
|
}
|
|
689
|
-
return
|
|
700
|
+
return { schemaVersion: 1, skills, diagnostics };
|
|
690
701
|
}
|
|
691
|
-
function
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
return void 0;
|
|
697
|
-
}
|
|
702
|
+
function readRuntimeSkill(command, options = {}) {
|
|
703
|
+
const tool = command ?? "v-cli";
|
|
704
|
+
const result4 = discoverToolSkills(options), skill = result4.skills.find((s) => s.tool === tool);
|
|
705
|
+
if (!skill) throw new Error("\u5DE5\u5177\u672A\u58F0\u660E\u8FD0\u884C\u6280\u80FD\uFF1A" + tool);
|
|
706
|
+
return { ...skill, file: skill.path, content: fs3.readFileSync(skill.path, "utf8"), sha256: createHash("sha256").update(fs3.readFileSync(skill.path)).digest("hex") };
|
|
698
707
|
}
|
|
699
|
-
function
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
if (
|
|
704
|
-
|
|
708
|
+
function skillBundleHash(root2) {
|
|
709
|
+
const files = [];
|
|
710
|
+
const walk = (directory, prefix = "") => {
|
|
711
|
+
for (const entry of fs3.readdirSync(directory, { withFileTypes: true })) {
|
|
712
|
+
if (entry.name === "__pycache__" || entry.name.endsWith(".pyc")) continue;
|
|
713
|
+
if (entry.isSymbolicLink()) throw new Error("\u6280\u80FD\u8D44\u6E90\u4E0D\u80FD\u5305\u542B\u94FE\u63A5");
|
|
714
|
+
const relative = prefix + entry.name, full = path4.join(directory, entry.name);
|
|
715
|
+
if (entry.isDirectory()) walk(full, relative + "/");
|
|
716
|
+
else if (entry.isFile()) files.push({ path: relative, hash: createHash("sha256").update(fs3.readFileSync(full)).digest("hex") });
|
|
705
717
|
}
|
|
706
|
-
}
|
|
707
|
-
return void 0;
|
|
708
|
-
}
|
|
709
|
-
function readBundledAgentsMd(opts = {}) {
|
|
710
|
-
const file2 = resolveBundledAgentsMd(opts);
|
|
711
|
-
if (!file2) {
|
|
712
|
-
const tried = bundledCandidatePaths(opts.base ?? fileURLToPath2(import.meta.url));
|
|
713
|
-
const lastTried = tried.length > 0 ? tried[tried.length - 1] : "\uFF08\u65E0\u5019\u9009\u4F4D\u7F6E\uFF09";
|
|
714
|
-
throw new Error(
|
|
715
|
-
`\u65E0\u6CD5\u5B9A\u4F4D ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E ${BUNDLED_DOCS_FILE}\uFF1A\u5DF2\u68C0\u67E5 ${tried.length} \u4E2A\u5019\u9009\u4F4D\u7F6E\u5747\u4E0D\u5B58\u5728\u6216\u4E0D\u53EF\u8BFB\uFF08\u6700\u540E\u68C0\u67E5: ${lastTried}\uFF09\u3002\u8BF7\u786E\u8BA4\u5B89\u88C5\u7684\u5305\u5185\u5305\u542B AGENTS.md\uFF08\u91CD\u65B0\u5B89\u88C5 @kevlns/v-cli \u540E\u91CD\u8BD5\uFF09\u3002`
|
|
716
|
-
);
|
|
717
|
-
}
|
|
718
|
-
let content;
|
|
719
|
-
try {
|
|
720
|
-
content = fs3.readFileSync(file2, "utf-8");
|
|
721
|
-
} catch (err) {
|
|
722
|
-
throw new Error(
|
|
723
|
-
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E ${BUNDLED_DOCS_FILE}\uFF08${file2}\uFF09: ${err instanceof Error ? err.message : String(err)}`
|
|
724
|
-
);
|
|
725
|
-
}
|
|
726
|
-
return {
|
|
727
|
-
file: file2,
|
|
728
|
-
content,
|
|
729
|
-
sha256: sha256Hex(content),
|
|
730
|
-
bytes: Buffer.byteLength(content, "utf-8")
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
function readOfficialAgentsMd(command, opts = {}) {
|
|
734
|
-
const spec = OFFICIAL_PLUGINS.find((item) => item.command === command);
|
|
735
|
-
if (!spec) {
|
|
736
|
-
throw new Error(
|
|
737
|
-
`\u672A\u627E\u5230\u5B98\u65B9\u63D2\u4EF6\u547D\u4EE4: ${command}\u3002\u8BF7\u5148\u8FD0\u884C v-cli agent index --json \u67E5\u770B\u53EF\u7528\u5B98\u65B9\u63D2\u4EF6\u3002`
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
const resolvePackage = opts.resolvePackage ?? defaultResolvePackage;
|
|
741
|
-
const pkgJsonPath = resolvePackage(spec.package);
|
|
742
|
-
if (!pkgJsonPath) {
|
|
743
|
-
throw new Error(
|
|
744
|
-
`\u672A\u5B89\u88C5\u5B98\u65B9\u63D2\u4EF6\u5305 ${spec.package}\uFF08\u547D\u4EE4 ${command}\uFF09\uFF0C\u6216\u5B83\u4E0D\u5728\u53EF\u89E3\u6790\u8DEF\u5F84\u3002\u8BF7\u5148\u5B89\u88C5\u540E\u91CD\u8BD5\u3002`
|
|
745
|
-
);
|
|
746
|
-
}
|
|
747
|
-
let pkgJson;
|
|
748
|
-
try {
|
|
749
|
-
pkgJson = JSON.parse(fs3.readFileSync(pkgJsonPath, "utf-8"));
|
|
750
|
-
} catch (err) {
|
|
751
|
-
throw new Error(
|
|
752
|
-
`\u65E0\u6CD5\u8BFB\u53D6\u5B98\u65B9\u63D2\u4EF6 ${spec.package} \u7684 package.json\uFF08${pkgJsonPath}\uFF09: ${err instanceof Error ? err.message : String(err)}`
|
|
753
|
-
);
|
|
754
|
-
}
|
|
755
|
-
if (pkgJson.name !== spec.package || typeof pkgJson.version !== "string") {
|
|
756
|
-
throw new Error(`\u5B98\u65B9\u63D2\u4EF6 package.json \u8EAB\u4EFD\u65E0\u6548: \u671F\u671B ${spec.package} \u4E14 version \u4E3A\u5B57\u7B26\u4E32\u3002`);
|
|
757
|
-
}
|
|
758
|
-
const file2 = path4.join(path4.dirname(pkgJsonPath), BUNDLED_DOCS_FILE);
|
|
759
|
-
let content;
|
|
760
|
-
try {
|
|
761
|
-
if (!fs3.lstatSync(file2).isFile()) throw new Error("\u76EE\u6807\u4E0D\u662F\u666E\u901A\u6587\u4EF6");
|
|
762
|
-
content = fs3.readFileSync(file2, "utf-8");
|
|
763
|
-
} catch (err) {
|
|
764
|
-
throw new Error(
|
|
765
|
-
`\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`
|
|
766
|
-
);
|
|
767
|
-
}
|
|
768
|
-
return {
|
|
769
|
-
package: spec.package,
|
|
770
|
-
command,
|
|
771
|
-
version: pkgJson.version,
|
|
772
|
-
file: file2,
|
|
773
|
-
content,
|
|
774
|
-
sha256: sha256Hex(content),
|
|
775
|
-
bytes: Buffer.byteLength(content, "utf-8")
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
function sha256Hex(content) {
|
|
779
|
-
return createHash("sha256").update(content, "utf-8").digest("hex");
|
|
780
|
-
}
|
|
781
|
-
function performAgentInit(opts) {
|
|
782
|
-
const { directory, docs, force = false, dryRun = false, explicitDirectory = false } = opts;
|
|
783
|
-
const target = path4.join(directory, BUNDLED_DOCS_FILE);
|
|
784
|
-
const base = {
|
|
785
|
-
ok: false,
|
|
786
|
-
dryRun,
|
|
787
|
-
action: "refused",
|
|
788
|
-
directory,
|
|
789
|
-
target,
|
|
790
|
-
package: BUNDLED_DOCS_PACKAGE,
|
|
791
|
-
version: VERSION,
|
|
792
|
-
sha256: docs.sha256,
|
|
793
|
-
bytes: docs.bytes
|
|
794
718
|
};
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
719
|
+
walk(root2);
|
|
720
|
+
files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
|
|
721
|
+
return createHash("sha256").update(JSON.stringify(files)).digest("hex");
|
|
722
|
+
}
|
|
723
|
+
function exportToolSkill(command, options) {
|
|
724
|
+
if (!["codex", "claude"].includes(options.host) || !options.directory)
|
|
725
|
+
throw new Error("\u5BFC\u51FA\u5FC5\u987B\u663E\u5F0F\u9009\u62E9 host \u548C directory");
|
|
726
|
+
const skill = readRuntimeSkill(command, options);
|
|
727
|
+
const base = path4.resolve(options.directory);
|
|
728
|
+
if (!fs3.lstatSync(base).isDirectory() || fs3.lstatSync(base).isSymbolicLink())
|
|
729
|
+
throw new Error("\u5BFC\u51FA\u76EE\u5F55\u5FC5\u987B\u662F\u5DF2\u6709\u666E\u901A\u76EE\u5F55");
|
|
730
|
+
const root2 = path4.resolve(path4.dirname(skill.path), "../.."), target = path4.join(base, skill.id);
|
|
731
|
+
const planned = [];
|
|
732
|
+
const check = (file2, directory) => {
|
|
733
|
+
let stat;
|
|
807
734
|
try {
|
|
808
|
-
|
|
809
|
-
} catch {
|
|
810
|
-
|
|
811
|
-
if (dirLstat && dirLstat.isSymbolicLink()) {
|
|
812
|
-
return refuse(
|
|
813
|
-
`\u62D2\u7EDD\u5199\u5165\uFF1A\u76EE\u6807\u76EE\u5F55 ${directory} \u662F\u7B26\u53F7\u94FE\u63A5/\u8054\u63A5\u76EE\u5F55\uFF08fail-closed\uFF0C\u4E0D\u8DDF\u968F\uFF09\u3002\u8BF7\u4F20\u5165\u771F\u5B9E\u76EE\u5F55\u8DEF\u5F84\uFF0C\u6216\u7701\u7565\u53C2\u6570\u8BA9 v-cli \u4F7F\u7528\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55`
|
|
814
|
-
);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
let targetStat;
|
|
818
|
-
try {
|
|
819
|
-
targetStat = fs3.lstatSync(target);
|
|
820
|
-
} catch {
|
|
821
|
-
targetStat = void 0;
|
|
822
|
-
}
|
|
823
|
-
if (targetStat) {
|
|
824
|
-
if (targetStat.isSymbolicLink()) {
|
|
825
|
-
return refuse(
|
|
826
|
-
`\u62D2\u7EDD\u5199\u5165 ${target}\uFF1A\u76EE\u6807\u662F\u7B26\u53F7\u94FE\u63A5\uFF08fail-closed\uFF0C\u4E0D\u8DDF\u968F\u3001\u4E0D\u8986\u76D6\u94FE\u63A5\u76EE\u6807\uFF09\u3002\u8BF7\u5148\u79FB\u9664\u94FE\u63A5\u6216\u9009\u62E9\u5176\u4ED6\u76EE\u5F55`
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
if (targetStat.isDirectory()) {
|
|
830
|
-
return refuse(`\u62D2\u7EDD\u5199\u5165 ${target}\uFF1A\u76EE\u6807\u662F\u4E00\u4E2A\u76EE\u5F55\uFF08\u65E0\u6CD5\u4EE5\u6587\u4EF6\u8986\u76D6\uFF09`);
|
|
831
|
-
}
|
|
832
|
-
if (!force) {
|
|
833
|
-
return refuse(
|
|
834
|
-
`${target} \u5DF2\u5B58\u5728\uFF0C\u9ED8\u8BA4\u62D2\u7EDD\u8986\u76D6\uFF08\u4E0D\u505A\u4EFB\u4F55\u6539\u52A8\uFF09\u3002\u5982\u9700\u8986\u76D6\u8BF7\u4F7F\u7528 --force\uFF1B\u5982\u9700\u9884\u89C8\u8BF7\u4F7F\u7528 --dry-run\uFF1B\u5982\u9700\u5148\u67E5\u770B\u5185\u5BB9\u8BF7\u8FD0\u884C v-cli agent docs`
|
|
835
|
-
);
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
const existed = targetStat !== void 0;
|
|
839
|
-
const action = existed ? dryRun ? "overwrite" : "overwritten" : dryRun ? "write" : "written";
|
|
840
|
-
if (dryRun) {
|
|
841
|
-
return { ...base, ok: true, action };
|
|
842
|
-
}
|
|
843
|
-
try {
|
|
844
|
-
atomicWrite(target, docs.content);
|
|
845
|
-
} catch (err) {
|
|
846
|
-
return refuse(`\u5199\u5165\u5931\u8D25 ${target}: ${err instanceof Error ? err.message : String(err)}`);
|
|
847
|
-
}
|
|
848
|
-
return { ...base, ok: true, action };
|
|
849
|
-
}
|
|
850
|
-
function isEexist(err) {
|
|
851
|
-
return typeof err === "object" && err !== null && err.code === "EEXIST";
|
|
852
|
-
}
|
|
853
|
-
var MAX_TMP_RETRIES = 5;
|
|
854
|
-
function atomicWrite(target, content) {
|
|
855
|
-
let lastError;
|
|
856
|
-
for (let attempt = 0; attempt < MAX_TMP_RETRIES; attempt++) {
|
|
857
|
-
const tmp = path4.join(
|
|
858
|
-
path4.dirname(target),
|
|
859
|
-
`.${BUNDLED_DOCS_FILE}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`
|
|
860
|
-
);
|
|
861
|
-
let created = false;
|
|
862
|
-
try {
|
|
863
|
-
fs3.writeFileSync(tmp, content, { encoding: "utf-8", flag: "wx", mode: 420 });
|
|
864
|
-
created = true;
|
|
865
|
-
fs3.renameSync(tmp, target);
|
|
866
|
-
return;
|
|
867
|
-
} catch (err) {
|
|
868
|
-
lastError = err;
|
|
869
|
-
if (created) {
|
|
870
|
-
try {
|
|
871
|
-
fs3.rmSync(tmp, { force: true });
|
|
872
|
-
} catch {
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
if (isEexist(err)) continue;
|
|
876
|
-
throw err;
|
|
735
|
+
stat = fs3.lstatSync(file2);
|
|
736
|
+
} catch (e) {
|
|
737
|
+
if (e.code !== "ENOENT") throw e;
|
|
877
738
|
}
|
|
878
|
-
|
|
879
|
-
const detail = lastError instanceof Error ? lastError.message : String(lastError ?? "\u672A\u77E5\u9519\u8BEF");
|
|
880
|
-
throw new Error(`\u539F\u5B50\u5199\u5165\u5931\u8D25\uFF08\u4E34\u65F6\u6587\u4EF6\u547D\u540D\u78B0\u649E\u91CD\u8BD5 ${MAX_TMP_RETRIES} \u6B21\u672A\u679C\uFF09: ${detail}`);
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
// src/core/agent-skill.ts
|
|
884
|
-
import fs4 from "fs";
|
|
885
|
-
import path5 from "path";
|
|
886
|
-
|
|
887
|
-
// src/core/agent-dirs.ts
|
|
888
|
-
var AGENT_SKILL_DIRS = [
|
|
889
|
-
".claude/skills",
|
|
890
|
-
".claude/skill",
|
|
891
|
-
".cursor/skills",
|
|
892
|
-
".cursor/rules",
|
|
893
|
-
".github/prompts",
|
|
894
|
-
".gemini/skills",
|
|
895
|
-
".codex/skills",
|
|
896
|
-
".agents/skills",
|
|
897
|
-
".agent/skills",
|
|
898
|
-
".agent/skill",
|
|
899
|
-
"AgentHome/skills",
|
|
900
|
-
".windsurf/skills",
|
|
901
|
-
".trae/skills",
|
|
902
|
-
".kilocode/skills",
|
|
903
|
-
".roo/skills",
|
|
904
|
-
".opencode/skills",
|
|
905
|
-
".augment/skills",
|
|
906
|
-
".kiro/skills",
|
|
907
|
-
".amazonq/skills",
|
|
908
|
-
".continue/skills"
|
|
909
|
-
];
|
|
910
|
-
|
|
911
|
-
// src/core/agent-skill.ts
|
|
912
|
-
var SKILL_NAME = "v-cli";
|
|
913
|
-
var SKILL_FILE = "SKILL.md";
|
|
914
|
-
function resolveSkillSourceRoot(opts = {}) {
|
|
915
|
-
const agentsMd = resolveBundledAgentsMd(opts);
|
|
916
|
-
if (!agentsMd) return void 0;
|
|
917
|
-
const root2 = path5.join(path5.dirname(agentsMd), "skills", SKILL_NAME);
|
|
918
|
-
try {
|
|
919
|
-
if (fs4.statSync(root2).isDirectory()) return root2;
|
|
920
|
-
} catch {
|
|
921
|
-
}
|
|
922
|
-
return void 0;
|
|
923
|
-
}
|
|
924
|
-
function readSkillSource(opts = {}) {
|
|
925
|
-
const root2 = resolveSkillSourceRoot(opts);
|
|
926
|
-
if (!root2) {
|
|
927
|
-
throw new Error(
|
|
928
|
-
`\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`
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
const file2 = path5.join(root2, SKILL_FILE);
|
|
932
|
-
let content;
|
|
933
|
-
try {
|
|
934
|
-
if (!fs4.lstatSync(file2).isFile()) throw new Error("\u5165\u53E3\u4E0D\u662F\u666E\u901A\u6587\u4EF6");
|
|
935
|
-
content = fs4.readFileSync(file2, "utf-8");
|
|
936
|
-
} catch (err) {
|
|
937
|
-
throw new Error(
|
|
938
|
-
`\u65E0\u6CD5\u8BFB\u53D6 ${BUNDLED_DOCS_PACKAGE} \u5185\u7F6E skill\uFF08${file2}\uFF09: ${err instanceof Error ? err.message : String(err)}`
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
return {
|
|
942
|
-
root: root2,
|
|
943
|
-
file: file2,
|
|
944
|
-
content,
|
|
945
|
-
sha256: sha256Hex(content),
|
|
946
|
-
bytes: Buffer.byteLength(content, "utf-8")
|
|
739
|
+
if (stat && (stat.isSymbolicLink() || stat.isDirectory() !== directory)) throw new Error("\u5BFC\u51FA\u76EE\u6807\u7C7B\u578B\u51B2\u7A81");
|
|
947
740
|
};
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
741
|
+
check(target, true);
|
|
742
|
+
const walk = (source, dest) => {
|
|
743
|
+
for (const entry of fs3.readdirSync(source, { withFileTypes: true })) {
|
|
744
|
+
if (entry.name === "__pycache__" || entry.name.endsWith(".pyc")) continue;
|
|
745
|
+
if (entry.isSymbolicLink()) throw new Error("\u6280\u80FD\u5BFC\u51FA\u4E0D\u80FD\u5305\u542B\u94FE\u63A5");
|
|
746
|
+
const from = path4.join(source, entry.name), to = path4.join(dest, entry.name);
|
|
747
|
+
check(to, entry.isDirectory());
|
|
748
|
+
if (entry.isDirectory()) walk(from, to);
|
|
749
|
+
else if (entry.isFile()) planned.push({ path: to, bytes: fs3.readFileSync(from) });
|
|
750
|
+
else throw new Error("\u6280\u80FD\u8D44\u6E90\u7C7B\u578B\u4E0D\u53D7\u652F\u6301");
|
|
956
751
|
}
|
|
957
|
-
}
|
|
958
|
-
return hits;
|
|
959
|
-
}
|
|
960
|
-
function syncSkillDir(srcRoot, destDir, opts = {}) {
|
|
961
|
-
if (opts.purgeExtras) {
|
|
962
|
-
fs4.rmSync(destDir, { recursive: true, force: true });
|
|
963
|
-
} else {
|
|
964
|
-
fs4.mkdirSync(destDir, { recursive: true });
|
|
965
|
-
}
|
|
966
|
-
fs4.cpSync(srcRoot, destDir, { recursive: true, force: true });
|
|
967
|
-
}
|
|
968
|
-
function readSkillFileAt(targetDir) {
|
|
969
|
-
try {
|
|
970
|
-
const file2 = path5.join(targetDir, SKILL_FILE);
|
|
971
|
-
if (!fs4.lstatSync(file2).isFile()) return void 0;
|
|
972
|
-
return fs4.readFileSync(file2, "utf-8");
|
|
973
|
-
} catch {
|
|
974
|
-
return void 0;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
function performAgentSkillAssembly(opts) {
|
|
978
|
-
const { directory, source, dryRun = false, force = false } = opts;
|
|
979
|
-
const base = {
|
|
980
|
-
ok: true,
|
|
981
|
-
dryRun,
|
|
982
|
-
directory,
|
|
983
|
-
assembled: [],
|
|
984
|
-
skill: { name: SKILL_NAME, sha256: source.sha256, bytes: source.bytes }
|
|
985
752
|
};
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
if (!dirStat.isDirectory()) {
|
|
993
|
-
return { ...base, ok: false, reason: `\u76EE\u6807\u4E0D\u662F\u76EE\u5F55: ${directory}` };
|
|
994
|
-
}
|
|
995
|
-
const hits = collectAgentSkillDirs(directory);
|
|
996
|
-
for (const dir of hits) {
|
|
997
|
-
const target = path5.join(dir, SKILL_NAME);
|
|
998
|
-
const existing = readSkillFileAt(target);
|
|
999
|
-
const exists = existing !== void 0;
|
|
1000
|
-
const localModified = exists && existing !== source.content;
|
|
1001
|
-
const action = dryRun ? "assemble" : "assembled";
|
|
1002
|
-
if (!dryRun) {
|
|
1003
|
-
syncSkillDir(source.root, target, { purgeExtras: force });
|
|
1004
|
-
}
|
|
1005
|
-
base.assembled.push({ dir, target, action, overwrite: exists, localModified });
|
|
753
|
+
walk(path4.dirname(skill.path), target);
|
|
754
|
+
const adapter = path4.join(root2, "adapters", options.host);
|
|
755
|
+
if (fs3.existsSync(adapter)) walk(adapter, target);
|
|
756
|
+
if (!options.dryRun) for (const file2 of planned) {
|
|
757
|
+
fs3.mkdirSync(path4.dirname(file2.path), { recursive: true });
|
|
758
|
+
fs3.writeFileSync(file2.path, file2.bytes);
|
|
1006
759
|
}
|
|
1007
|
-
return
|
|
760
|
+
return { skill: skill.id, host: options.host, target, dryRun: !!options.dryRun, files: planned.length };
|
|
1008
761
|
}
|
|
1009
762
|
|
|
763
|
+
// src/version.ts
|
|
764
|
+
var VERSION = "0.6.1";
|
|
765
|
+
|
|
1010
766
|
// src/commands/agent.ts
|
|
1011
|
-
function skillOutcomeText(outcome, dryRun) {
|
|
1012
|
-
const verb = dryRun ? "\u5C06\u88C5\u914D\u5230" : "\u5DF2\u88C5\u914D\u5230";
|
|
1013
|
-
switch (outcome.status) {
|
|
1014
|
-
case "assembled": {
|
|
1015
|
-
const dirs = outcome.assembled.map((t) => t.dir).join(", ");
|
|
1016
|
-
const refreshed = outcome.assembled.filter((t) => t.localModified).map((t) => t.dir);
|
|
1017
|
-
const note = refreshed.length > 0 ? `\uFF1B\u5176\u4E2D ${refreshed.length} \u4E2A\u672C\u5730\u5DF2\u4FEE\u6539\u7684 SKILL.md \u5DF2\u6309\u968F\u5305\u7248\u672C\u5237\u65B0\uFF08\u540C\u76EE\u5F55\u6269\u5C55\u6587\u4EF6\u4FDD\u7559\uFF09\uFF1A${refreshed.join(", ")}` : "";
|
|
1018
|
-
return `[skill v-cli] ${verb} ${outcome.assembled.length} \u4E2A agent \u76EE\u5F55\uFF1A${dirs}${note}`;
|
|
1019
|
-
}
|
|
1020
|
-
case "skipped-none":
|
|
1021
|
-
return "[skill v-cli] \u672A\u68C0\u6D4B\u5230\u5339\u914D\u7684 agent \u6280\u80FD\u76EE\u5F55\uFF0C\u8DF3\u8FC7\u88C5\u914D";
|
|
1022
|
-
case "skipped-source-missing":
|
|
1023
|
-
return `[skill v-cli] \u8DF3\u8FC7\u88C5\u914D\uFF08\u6E90\u7F3A\u5931\uFF09\uFF1A${outcome.reason}`;
|
|
1024
|
-
case "skipped-init-failed":
|
|
1025
|
-
return "[skill v-cli] \u8DF3\u8FC7\u88C5\u914D\uFF08AGENTS.md \u672A\u5C31\u7EEA\uFF09";
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
767
|
function buildAgentIndex(builtin, local, official) {
|
|
1029
768
|
const rows = [];
|
|
1030
769
|
for (const cmd of builtin) {
|
|
@@ -1096,81 +835,14 @@ function describeCommandLine(c) {
|
|
|
1096
835
|
const safeText = Array.isArray(c.safety) && c.safety.length > 0 ? ` \u5B89\u5168: ${c.safety.join("\uFF1B")}` : "";
|
|
1097
836
|
return ` ${pathText} \u2014 ${c.description}${c.usage ? ` (\u7528\u6CD5: ${c.usage})` : ""}${argText}${optText}${outputText}${exitText}${safeText}`;
|
|
1098
837
|
}
|
|
1099
|
-
var AGENT_HELP_TEXT = [
|
|
1100
|
-
|
|
1101
|
-
" index \u5217\u51FA\u5168\u90E8\u547D\u4EE4\uFF08builtin/local/official\uFF09\u4E0E agent \u5143\u6570\u636E\uFF1B--json \u8F93\u51FA\u7A33\u5B9A JSON \u6570\u7EC4",
|
|
1102
|
-
" describe \u67E5\u770B\u5355\u4E2A\u547D\u4EE4\u7684\u5B8C\u6574\u8BB0\u5F55\uFF08\u7528\u6CD5/\u53C2\u6570/\u9009\u9879/\u8F93\u51FA/\u9000\u51FA\u7801/\u5B89\u5168\u6807\u7B7E\uFF09\uFF1B--json \u8F93\u51FA\u5355\u6761\u8BB0\u5F55",
|
|
1103
|
-
" docs \u65E0\u53C2\u8F93\u51FA v-cli AGENTS.md\uFF1B\u4F20 <command> \u8F93\u51FA\u5DF2\u5B89\u88C5\u5B98\u65B9\u63D2\u4EF6\u5305\u5185 AGENTS.md",
|
|
1104
|
-
" init \u628A\u5185\u7F6E AGENTS.md \u5199\u5165\u5DE5\u4F5C\u533A\uFF08\u9ED8\u8BA4\u5F53\u524D\u76EE\u5F55\uFF09\uFF1B\u5DF2\u5B58\u5728\u9ED8\u8BA4\u62D2\u7EDD\uFF0C--force \u8986\u76D6\uFF0C--dry-run \u9884\u89C8",
|
|
1105
|
-
"",
|
|
1106
|
-
"JSON\uFF1A\u6240\u6709\u5B50\u547D\u4EE4\u652F\u6301 --json\uFF08\u6216\u524D\u7F6E\u5168\u5C40 --json\uFF0C\u5982 v-cli --json agent index\uFF09",
|
|
1107
|
-
"",
|
|
1108
|
-
"AI Agent \u5FEB\u901F\u5F00\u59CB\uFF08\u63A8\u8350\u987A\u5E8F\uFF09\uFF1A",
|
|
1109
|
-
" 1. v-cli agent docs",
|
|
1110
|
-
" 2. v-cli agent index --json",
|
|
1111
|
-
" 3. v-cli agent describe <name> --json",
|
|
1112
|
-
" 4. v-cli agent init . \uFF08\u53EF\u9009\uFF1A\u5199\u5165\u5DE5\u4F5C\u533A AGENTS.md\uFF0CAI Agent \u81EA\u52A8\u8BFB\u53D6\uFF09",
|
|
1113
|
-
"",
|
|
1114
|
-
"\u793A\u4F8B\uFF1A",
|
|
1115
|
-
" v-cli agent index --json # \u5168\u91CF\u547D\u4EE4\u7D22\u5F15",
|
|
1116
|
-
" v-cli agent describe ts --json # \u5355\u547D\u4EE4\u8BE6\u60C5",
|
|
1117
|
-
" v-cli agent docs # v-cli \u7626\u7D22\u5F15\u539F\u6587",
|
|
1118
|
-
" v-cli agent docs unity # u-cli-mod \u5305\u5185\u4F7F\u7528\u89C4\u8303",
|
|
1119
|
-
" v-cli agent docs xlmerge --json # xlmerge \u5305\u5185\u89C4\u8303\uFF08JSON\uFF09",
|
|
1120
|
-
" v-cli agent init . --dry-run # \u9884\u89C8\u521D\u59CB\u5316\u76EE\u6807"
|
|
1121
|
-
].join("\n");
|
|
1122
|
-
var DOCS_HELP_TEXT = [
|
|
1123
|
-
"\u8F93\u51FA AGENTS.md \u539F\u6587\uFF08\u9010\u5B57\u8282\u539F\u6837\u8F93\u51FA\u3001\u4E0D\u8FFD\u52A0\u6362\u884C\uFF09\u3002",
|
|
1124
|
-
" \u7701\u7565 [command]\uFF1A\u5F53\u524D @kevlns/v-cli \u5305\u5185\u7F6E\u7626\u7D22\u5F15\u3002",
|
|
1125
|
-
" \u4F20\u5165 [command]\uFF1A\u5DF2\u5B89\u88C5\u5B98\u65B9\u63D2\u4EF6\u5305\u6839 AGENTS.md\uFF08\u5982 unity / xlmerge\uFF09\u3002",
|
|
1126
|
-
"",
|
|
1127
|
-
"\u53C2\u6570\uFF1A",
|
|
1128
|
-
" [command] official \u63D2\u4EF6\u547D\u4EE4\u540D\uFF1B\u5148\u7528 v-cli agent index --json \u67E5\u770B",
|
|
1129
|
-
"",
|
|
1130
|
-
"JSON \u884C\u4E3A\uFF08--json \u6216\u524D\u7F6E\u5168\u5C40 --json\uFF09\uFF1A",
|
|
1131
|
-
" \u6210\u529F\uFF1Astdout \u8F93\u51FA\u7A33\u5B9A\u5BF9\u8C61 { package, version, sha256, content }",
|
|
1132
|
-
" \u5931\u8D25\uFF1Astdout \u8F93\u51FA\u7A00\u758F\u5BF9\u8C61 { ok: false, error }\uFF0Cstderr \u518D\u8F93\u51FA\u540C\u4E00 error\uFF0C\u9000\u51FA\u7801 1",
|
|
1133
|
-
"",
|
|
1134
|
-
"\u9000\u51FA\u7801\uFF1A0 \u6210\u529F\uFF1B1 \u547D\u4EE4\u672A\u77E5 / \u63D2\u4EF6\u672A\u5B89\u88C5 / AGENTS.md \u7F3A\u5931\u6216\u4E0D\u53EF\u8BFB",
|
|
1135
|
-
"",
|
|
1136
|
-
"\u793A\u4F8B\uFF1A",
|
|
1137
|
-
" v-cli agent docs",
|
|
1138
|
-
" v-cli agent docs unity",
|
|
1139
|
-
" v-cli agent docs xlmerge --json"
|
|
1140
|
-
].join("\n");
|
|
1141
|
-
var INIT_HELP_TEXT = [
|
|
1142
|
-
"\u628A\u5F53\u524D @kevlns/v-cli \u5305\u5185\u7F6E AGENTS.md \u539F\u6837\u5199\u5165 <\u76EE\u5F55>/AGENTS.md\uFF0CAI Agent \u4F1A\u81EA\u52A8\u8BFB\u53D6\u5DE5\u4F5C\u533A\u6587\u6863\uFF1B",
|
|
1143
|
-
"\u540C\u65F6\u628A\u968F\u5305\u53D1\u5E03\u7684 v-cli skill\uFF08skills/v-cli\uFF09\u88C5\u914D\u5230 <\u76EE\u5F55> \u4E0B\u5339\u914D\u7684 agent \u6280\u80FD\u76EE\u5F55\uFF08\u5982 .claude/skills\u3001.agent/skill\u3001AgentHome/skills \u7B49\uFF09\uFF0C\u65E0\u5339\u914D\u76EE\u5F55\u5219\u8DF3\u8FC7\u3002",
|
|
1144
|
-
"",
|
|
1145
|
-
"\u53C2\u6570\uFF1A",
|
|
1146
|
-
" [directory] \u76EE\u6807\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1B\u5FC5\u987B\u5DF2\u5B58\u5728\u4E14\u4E3A\u76EE\u5F55",
|
|
1147
|
-
"",
|
|
1148
|
-
"\u9ED8\u8BA4\u884C\u4E3A\uFF08\u65E0 --force\uFF09\uFF1A\u76EE\u6807\u5DF2\u5B58\u5728 AGENTS.md \u65F6\u62D2\u7EDD\u5E76\u9000\u51FA 1\uFF0C\u7EDD\u4E0D\u6539\u52A8\u73B0\u6709\u6587\u4EF6\u3002",
|
|
1149
|
-
" --force \u8986\u76D6\u5DF2\u5B58\u5728\u7684 AGENTS.md\uFF1Bskill \u76EE\u5F55\u505A\u5B8C\u5168\u540C\u6B65\uFF08\u6E05\u6389\u6269\u5C55\u6587\u4EF6\uFF09\uFF08\u539F\u5B50\u5199\u5165\uFF1A\u540C\u76EE\u5F55\u4E34\u65F6\u6587\u4EF6 + rename\uFF09",
|
|
1150
|
-
" skill \u540C\u6B65 \u968F\u5305\u7248\u672C\u662F\u89C4\u8303\u552F\u4E00\u6743\u5A01\uFF1A\u540C\u540D SKILL.md \u4E00\u5F8B\u6309\u968F\u5305\u7248\u672C\u5237\u65B0\uFF08\u672C\u5730\u4FEE\u6539\u4F1A\u88AB\u8986\u76D6\u5E76\u63D0\u793A\uFF09\uFF1B",
|
|
1151
|
-
" \u76EE\u6807\u76EE\u5F55\u4E2D\u968F\u5305\u6CA1\u6709\u7684\u6587\u4EF6\uFF08\u9879\u76EE\u6269\u5C55\uFF0C\u5982 PROJECT.md\uFF09\u9ED8\u8BA4\u4FDD\u7559\uFF0C--force \u65F6\u5B8C\u5168\u540C\u6B65\u3002",
|
|
1152
|
-
" --dry-run \u53EA\u62A5\u544A\u76EE\u6807\u4E0E\u5C06\u6267\u884C\u7684\u52A8\u4F5C\uFF0C\u4E0D\u5199\u5165\u4EFB\u4F55\u6587\u4EF6",
|
|
1153
|
-
" --json \u6210\u529F/\u5E72\u8DD1\u8F93\u51FA\u7A33\u5B9A JSON { ok, dryRun, action, directory, target, package, version, sha256, bytes }\uFF1B",
|
|
1154
|
-
' \u62D2\u7EDD\uFF08\u5982\u5DF2\u5B58\u5728\u672A\u52A0 --force\uFF09\u8F93\u51FA { ok: false, action: "refused", reason, \u2026 } \u4E14\u9000\u51FA 1\uFF1B',
|
|
1155
|
-
" \u5185\u7F6E\u6587\u6863\u7F3A\u5931\u65F6\u8F93\u51FA\u7A00\u758F { ok: false, error } \u4E14\u9000\u51FA 1",
|
|
1156
|
-
" \u7B26\u53F7\u94FE\u63A5\u89C4\u5219\uFF1A\u76EE\u6807 AGENTS.md \u662F\u7B26\u53F7\u94FE\u63A5\u4E00\u5F8B\u62D2\u7EDD\uFF08fail-closed\uFF1A\u4E0D\u8DDF\u968F\u3001\u4E0D\u8986\u76D6\u94FE\u63A5\u76EE\u6807\uFF09\uFF1B",
|
|
1157
|
-
" \u663E\u5F0F\u4F20\u5165\u7684\u76EE\u5F55\u672C\u8EAB\u662F\u7B26\u53F7\u94FE\u63A5/\u8054\u63A5\u76EE\u5F55\uFF08junction\uFF09\u4E5F\u62D2\u7EDD\uFF1B\u7701\u7565\u76EE\u5F55\u53C2\u6570\uFF08\u9ED8\u8BA4\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF09\u4E0D\u53D7\u6B64\u9650\u5236",
|
|
1158
|
-
"",
|
|
1159
|
-
"\u9000\u51FA\u7801\uFF1A0 \u6210\u529F\u6216\u5E72\u8DD1\uFF1B1 \u76EE\u5F55\u65E0\u6548 / \u5DF2\u5B58\u5728\u672A\u52A0 --force / \u7B26\u53F7\u94FE\u63A5\u6216\u8054\u63A5\u76EE\u6807 / \u5185\u7F6E\u6587\u6863\u7F3A\u5931 / \u5199\u5165\u5931\u8D25",
|
|
1160
|
-
"",
|
|
1161
|
-
"\u793A\u4F8B\uFF1A",
|
|
1162
|
-
" v-cli agent init",
|
|
1163
|
-
" v-cli agent init ./myproj",
|
|
1164
|
-
" v-cli agent init --dry-run",
|
|
1165
|
-
" v-cli agent init --force",
|
|
1166
|
-
" v-cli agent init --json"
|
|
1167
|
-
].join("\n");
|
|
838
|
+
var AGENT_HELP_TEXT = "\u8FD0\u884C\u89C4\u8303\uFF1Aagent docs [\u5DE5\u5177]\uFF1B\u53D7\u7BA1\u6280\u80FD\uFF1Aagent skills --json\u3002\u5916\u90E8\u5BBF\u4E3B\u53EA\u80FD\u901A\u8FC7 agent export --host --directory \u663E\u5F0F\u5BFC\u51FA\u3002";
|
|
839
|
+
var DOCS_HELP_TEXT = "\u8F93\u51FA\u6E05\u5355\u58F0\u660E\u7684 SKILL.md \u539F\u6587\uFF1B--json \u5305\u542B sha256/content\u3002\u793A\u4F8B\uFF1Av-cli agent docs xlmerge --json\u3002AGENTS.md \u53EA\u9762\u5411\u5DE5\u5177\u4ED3\u5E93\u5F00\u53D1\u3002";
|
|
1168
840
|
var agent = {
|
|
1169
841
|
name: "agent",
|
|
1170
|
-
description: "
|
|
842
|
+
description: "\u53D1\u73B0\u547D\u4EE4\u4E0E\u8FD0\u884C\u6280\u80FD\uFF0C\u663E\u5F0F\u5BFC\u51FA\u5BBF\u4E3B\u9002\u914D",
|
|
1171
843
|
apiVersion: 1,
|
|
1172
844
|
agent: {
|
|
1173
|
-
whenToUse: "\
|
|
845
|
+
whenToUse: "\u53D1\u73B0\u547D\u4EE4\u7528 index/describe\uFF1B\u8FD0\u884C\u89C4\u8303\u7528 docs\uFF1B\u5916\u90E8\u9002\u914D\u4F7F\u7528\u663E\u5F0F export\u3002",
|
|
1174
846
|
globalOptions: [
|
|
1175
847
|
{ flags: "-h, --help", description: "\u663E\u793A\u547D\u4EE4\u5E2E\u52A9" }
|
|
1176
848
|
],
|
|
@@ -1201,44 +873,35 @@ var agent = {
|
|
|
1201
873
|
{
|
|
1202
874
|
path: ["docs"],
|
|
1203
875
|
usage: "v-cli agent docs [command] [--json]",
|
|
1204
|
-
description: "\
|
|
876
|
+
description: "\u8BFB\u53D6\u5DE5\u5177\u58F0\u660E\u7684\u8FD0\u884C\u6280\u80FD\u5165\u53E3",
|
|
1205
877
|
arguments: [{ name: "command", required: false, description: "\u5B98\u65B9\u63D2\u4EF6\u547D\u4EE4\u540D\uFF08\u5982 unity\u3001xlmerge\uFF09" }],
|
|
1206
878
|
options: [{ flags: "--json", description: "\u8F93\u51FA { package, version, sha256, content }" }],
|
|
1207
879
|
output: {
|
|
1208
880
|
format: "stdout",
|
|
1209
|
-
description: "
|
|
881
|
+
description: "SKILL.md \u539F\u6587\u9010\u5B57\u8282\u8F93\u51FA\u5230 stdout\uFF1B--json \u65F6\u8F93\u51FA\u542B sha256/content \u7684\u7A33\u5B9A JSON"
|
|
1210
882
|
},
|
|
1211
|
-
exitCodes: { "0": "\u6210\u529F", "1": "\u547D\u4EE4\u672A\u77E5 / \u63D2\u4EF6\u672A\u5B89\u88C5 /
|
|
883
|
+
exitCodes: { "0": "\u6210\u529F", "1": "\u547D\u4EE4\u672A\u77E5 / \u63D2\u4EF6\u672A\u5B89\u88C5 / SKILL.md \u7F3A\u5931\u6216\u4E0D\u53EF\u8BFB" },
|
|
1212
884
|
safety: ["read-only", "no-network"]
|
|
1213
885
|
},
|
|
1214
886
|
{
|
|
1215
|
-
path: ["
|
|
1216
|
-
usage: "v-cli agent
|
|
1217
|
-
description: "\
|
|
1218
|
-
arguments: [
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
],
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
},
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
},
|
|
1234
|
-
safety: [
|
|
1235
|
-
"writes-target-atomic",
|
|
1236
|
-
"refuses-existing",
|
|
1237
|
-
"fail-closed-symlink",
|
|
1238
|
-
"dry-run-supported",
|
|
1239
|
-
"no-commit",
|
|
1240
|
-
"assembles-skill"
|
|
1241
|
-
]
|
|
887
|
+
path: ["skills"],
|
|
888
|
+
usage: "v-cli agent skills [--json]",
|
|
889
|
+
description: "\u5217\u51FA\u53D7\u7BA1\u5DE5\u5177\u58F0\u660E\u7684\u6280\u80FD",
|
|
890
|
+
arguments: [],
|
|
891
|
+
options: [{ flags: "--json", description: "JSON \u8F93\u51FA" }],
|
|
892
|
+
output: { format: "json", description: "\u6280\u80FD\u6765\u6E90\u4E0E\u8BCA\u65AD" },
|
|
893
|
+
exitCodes: { "0": "\u6210\u529F" },
|
|
894
|
+
safety: ["read-only", "no-network"]
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
path: ["export"],
|
|
898
|
+
usage: "v-cli agent export [command] --host <codex|claude> --directory <path> [--dry-run] [--json]",
|
|
899
|
+
description: "\u5411\u6307\u5B9A\u76EE\u5F55\u5BFC\u51FA\u8FD0\u884C\u6280\u80FD\u548C\u663E\u5F0F\u5BBF\u4E3B\u9002\u914D",
|
|
900
|
+
arguments: [{ name: "command", required: false, description: "\u5DE5\u5177\u540D\uFF0C\u9ED8\u8BA4 v-cli" }],
|
|
901
|
+
options: [{ flags: "--host <name>", description: "\u663E\u5F0F\u5BBF\u4E3B" }, { flags: "--directory <path>", description: "\u5DF2\u6709\u6280\u80FD\u6839\u76EE\u5F55" }, { flags: "--dry-run", description: "\u53EA\u9884\u89C8" }, { flags: "--json", description: "JSON \u8F93\u51FA" }],
|
|
902
|
+
output: { format: "json", description: "\u5BFC\u51FA\u6587\u4EF6\u4E0E\u76EE\u6807" },
|
|
903
|
+
exitCodes: { "0": "\u6210\u529F", "1": "\u975E\u6CD5\u76EE\u6807\u6216\u6765\u6E90" },
|
|
904
|
+
safety: ["explicit-target", "no-network"]
|
|
1242
905
|
}
|
|
1243
906
|
]
|
|
1244
907
|
},
|
|
@@ -1287,19 +950,19 @@ var agent = {
|
|
|
1287
950
|
}
|
|
1288
951
|
ctx.log.result(lines.join("\n"));
|
|
1289
952
|
});
|
|
1290
|
-
program.command("docs").description("\
|
|
953
|
+
program.command("docs").description("\u8BFB\u53D6\u5DE5\u5177\u58F0\u660E\u7684\u8FD0\u884C\u6280\u80FD\u5165\u53E3").argument("[command]", "\u5B98\u65B9\u63D2\u4EF6\u547D\u4EE4\u540D\uFF08\u5982 unity\u3001xlmerge\uFF09").option("--json", "\u8F93\u51FA\u673A\u5668\u53EF\u8BFB JSON\uFF08\u542B sha256/content\uFF09").addHelpText("after", DOCS_HELP_TEXT).action((command, opts) => {
|
|
1291
954
|
const json = ctx.json || opts.json;
|
|
1292
955
|
let docs;
|
|
1293
|
-
let packageName =
|
|
956
|
+
let packageName = "@kevlns/v-cli";
|
|
1294
957
|
let version = VERSION;
|
|
1295
958
|
try {
|
|
1296
959
|
if (command) {
|
|
1297
|
-
const pluginDocs =
|
|
960
|
+
const pluginDocs = readRuntimeSkill(command);
|
|
1298
961
|
docs = pluginDocs;
|
|
1299
962
|
packageName = pluginDocs.package;
|
|
1300
963
|
version = pluginDocs.version;
|
|
1301
964
|
} else {
|
|
1302
|
-
docs =
|
|
965
|
+
docs = readRuntimeSkill();
|
|
1303
966
|
}
|
|
1304
967
|
} catch (err) {
|
|
1305
968
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -1319,75 +982,11 @@ var agent = {
|
|
|
1319
982
|
}
|
|
1320
983
|
process.stdout.write(docs.content);
|
|
1321
984
|
});
|
|
1322
|
-
program.command("
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
docs = readBundledAgentsMd();
|
|
1328
|
-
} catch (err) {
|
|
1329
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
1330
|
-
if (json) ctx.log.result({ ok: false, error: message });
|
|
1331
|
-
ctx.log.error(message);
|
|
1332
|
-
process.exitCode = 1;
|
|
1333
|
-
return;
|
|
1334
|
-
}
|
|
1335
|
-
const resolvedDir = path6.resolve(directory ?? process.cwd());
|
|
1336
|
-
const result4 = performAgentInit({
|
|
1337
|
-
directory: resolvedDir,
|
|
1338
|
-
docs,
|
|
1339
|
-
force: opts.force,
|
|
1340
|
-
dryRun: opts.dryRun,
|
|
1341
|
-
// 显式传入目录才做目录符号链接/联接 fail-closed;默认 cwd 不受限
|
|
1342
|
-
explicitDirectory: directory !== void 0
|
|
1343
|
-
});
|
|
1344
|
-
let skillOutcome;
|
|
1345
|
-
if (result4.ok) {
|
|
1346
|
-
try {
|
|
1347
|
-
const source = readSkillSource();
|
|
1348
|
-
const skill = performAgentSkillAssembly({
|
|
1349
|
-
directory: resolvedDir,
|
|
1350
|
-
source,
|
|
1351
|
-
dryRun: opts.dryRun,
|
|
1352
|
-
force: opts.force
|
|
1353
|
-
});
|
|
1354
|
-
skillOutcome = skill.assembled.length > 0 ? {
|
|
1355
|
-
status: "assembled",
|
|
1356
|
-
assembled: skill.assembled,
|
|
1357
|
-
name: skill.skill.name,
|
|
1358
|
-
sha256: skill.skill.sha256,
|
|
1359
|
-
bytes: skill.skill.bytes
|
|
1360
|
-
} : {
|
|
1361
|
-
status: "skipped-none",
|
|
1362
|
-
assembled: [],
|
|
1363
|
-
name: skill.skill.name,
|
|
1364
|
-
sha256: skill.skill.sha256,
|
|
1365
|
-
bytes: skill.skill.bytes
|
|
1366
|
-
};
|
|
1367
|
-
} catch (err) {
|
|
1368
|
-
skillOutcome = {
|
|
1369
|
-
status: "skipped-source-missing",
|
|
1370
|
-
reason: err instanceof Error ? err.message : String(err)
|
|
1371
|
-
};
|
|
1372
|
-
}
|
|
1373
|
-
} else {
|
|
1374
|
-
skillOutcome = { status: "skipped-init-failed" };
|
|
1375
|
-
}
|
|
1376
|
-
if (json) {
|
|
1377
|
-
ctx.log.result({ ...result4, skill: skillOutcome });
|
|
1378
|
-
if (!result4.ok && result4.reason) ctx.log.error(result4.reason);
|
|
1379
|
-
if (!result4.ok) process.exitCode = 1;
|
|
1380
|
-
return;
|
|
1381
|
-
}
|
|
1382
|
-
if (!result4.ok) {
|
|
1383
|
-
if (result4.reason) ctx.log.error(result4.reason);
|
|
1384
|
-
process.exitCode = 1;
|
|
1385
|
-
return;
|
|
1386
|
-
}
|
|
1387
|
-
const head = result4.dryRun ? `[dry-run] \u5C06${result4.action === "overwrite" ? "\u8986\u76D6" : "\u5199\u5165"} ${result4.target}\uFF08${result4.bytes} \u5B57\u8282\uFF09` : `\u5DF2${result4.action === "overwritten" ? "\u8986\u76D6" : "\u5199\u5165"} ${result4.target}\uFF08${result4.bytes} \u5B57\u8282\uFF0CSHA-256 ${result4.sha256.slice(0, 12)}\u2026\uFF09`;
|
|
1388
|
-
ctx.log.result([head, skillOutcomeText(skillOutcome, result4.dryRun)].join("\n"));
|
|
1389
|
-
}
|
|
1390
|
-
);
|
|
985
|
+
program.command("skills").description("\u5217\u51FA\u53D7\u7BA1\u5DE5\u5177\u58F0\u660E\u7684\u6280\u80FD").option("--json", "JSON \u8F93\u51FA").action(() => ctx.log.result(discoverToolSkills()));
|
|
986
|
+
program.command("export").description("\u663E\u5F0F\u5BFC\u51FA\u5916\u90E8\u5BBF\u4E3B\u6280\u80FD").argument("[command]").requiredOption("--host <name>").requiredOption("--directory <path>").option("--dry-run").option("--json").action((command, opts) => ctx.log.result(exportToolSkill(command, opts)));
|
|
987
|
+
program.command("init").description("\u5DF2\u8FC1\u79FB\uFF1A\u4F7F\u7528 project init").argument("[directory]").option("--json").option("--dry-run").option("--force").action(() => {
|
|
988
|
+
throw new Error("agent init \u5DF2\u8FC1\u79FB\uFF1B\u9879\u76EE\u4F7F\u7528 v-cli project init\uFF0C\u5916\u90E8\u5BBF\u4E3B\u4F7F\u7528 agent export --host --directory\u3002");
|
|
989
|
+
});
|
|
1391
990
|
program.addHelpText("after", AGENT_HELP_TEXT);
|
|
1392
991
|
}
|
|
1393
992
|
};
|
|
@@ -1425,8 +1024,8 @@ function capabilityCoverage(registry) {
|
|
|
1425
1024
|
}
|
|
1426
1025
|
|
|
1427
1026
|
// src/commands/capability.ts
|
|
1428
|
-
import
|
|
1429
|
-
import
|
|
1027
|
+
import fs13 from "fs";
|
|
1028
|
+
import path14 from "path";
|
|
1430
1029
|
|
|
1431
1030
|
// src/core/execution/errors.ts
|
|
1432
1031
|
function structuredError(code, category, message, options = {}) {
|
|
@@ -1464,17 +1063,17 @@ function toStructuredError(err) {
|
|
|
1464
1063
|
}
|
|
1465
1064
|
|
|
1466
1065
|
// src/providers/ship/index.ts
|
|
1467
|
-
import
|
|
1066
|
+
import fs9 from "fs";
|
|
1468
1067
|
|
|
1469
1068
|
// src/core/execution/resource-locks.ts
|
|
1470
|
-
import
|
|
1471
|
-
import
|
|
1069
|
+
import fs5 from "fs";
|
|
1070
|
+
import path6 from "path";
|
|
1472
1071
|
import os2 from "os";
|
|
1473
1072
|
import { createHash as createHash2, randomUUID } from "crypto";
|
|
1474
1073
|
|
|
1475
1074
|
// src/core/project/paths.ts
|
|
1476
|
-
import
|
|
1477
|
-
import
|
|
1075
|
+
import fs4 from "fs";
|
|
1076
|
+
import path5 from "path";
|
|
1478
1077
|
var PathSafetyError = class extends Error {
|
|
1479
1078
|
code;
|
|
1480
1079
|
constructor(code, message) {
|
|
@@ -1484,13 +1083,13 @@ var PathSafetyError = class extends Error {
|
|
|
1484
1083
|
}
|
|
1485
1084
|
};
|
|
1486
1085
|
function isPlainAbsolute(input) {
|
|
1487
|
-
return
|
|
1086
|
+
return path5.isAbsolute(input) || /^[A-Za-z]:/.test(input) || input.startsWith("\\\\") || input.startsWith("//");
|
|
1488
1087
|
}
|
|
1489
1088
|
function resolveProjectRoot(input, cwd = process.cwd()) {
|
|
1490
|
-
const root2 =
|
|
1089
|
+
const root2 = path5.resolve(cwd, input ?? ".");
|
|
1491
1090
|
let stat;
|
|
1492
1091
|
try {
|
|
1493
|
-
stat =
|
|
1092
|
+
stat = fs4.statSync(root2);
|
|
1494
1093
|
} catch {
|
|
1495
1094
|
throw new PathSafetyError("project-root-missing", `\u5DE5\u7A0B\u6839\u4E0D\u5B58\u5728: ${root2}`);
|
|
1496
1095
|
}
|
|
@@ -1499,7 +1098,7 @@ function resolveProjectRoot(input, cwd = process.cwd()) {
|
|
|
1499
1098
|
}
|
|
1500
1099
|
let realRoot;
|
|
1501
1100
|
try {
|
|
1502
|
-
realRoot =
|
|
1101
|
+
realRoot = fs4.realpathSync.native(root2);
|
|
1503
1102
|
} catch (err) {
|
|
1504
1103
|
throw new PathSafetyError(
|
|
1505
1104
|
"project-root-unreadable",
|
|
@@ -1530,15 +1129,15 @@ function splitSafeRelative(relative, label) {
|
|
|
1530
1129
|
return segments;
|
|
1531
1130
|
}
|
|
1532
1131
|
function isInside(rootReal, candidateReal) {
|
|
1533
|
-
const rel =
|
|
1132
|
+
const rel = path5.relative(rootReal, candidateReal);
|
|
1534
1133
|
if (rel === "") return true;
|
|
1535
|
-
return !rel.startsWith("..") && !
|
|
1134
|
+
return !rel.startsWith("..") && !path5.isAbsolute(rel);
|
|
1536
1135
|
}
|
|
1537
1136
|
function deepestExisting(target, stopAt) {
|
|
1538
1137
|
let current = target;
|
|
1539
1138
|
for (; ; ) {
|
|
1540
|
-
if (
|
|
1541
|
-
const parent =
|
|
1139
|
+
if (fs4.existsSync(current)) return current;
|
|
1140
|
+
const parent = path5.dirname(current);
|
|
1542
1141
|
if (parent === current || current === stopAt) return stopAt;
|
|
1543
1142
|
current = parent;
|
|
1544
1143
|
}
|
|
@@ -1548,11 +1147,11 @@ function resolveInsideProject(project2, relative, label) {
|
|
|
1548
1147
|
return { path: project2.root, realPath: project2.realRoot };
|
|
1549
1148
|
}
|
|
1550
1149
|
const segments = splitSafeRelative(relative, label);
|
|
1551
|
-
const target =
|
|
1150
|
+
const target = path5.join(project2.root, ...segments);
|
|
1552
1151
|
const existingAncestor = deepestExisting(target, project2.realRoot);
|
|
1553
1152
|
let ancestorReal;
|
|
1554
1153
|
try {
|
|
1555
|
-
ancestorReal =
|
|
1154
|
+
ancestorReal = fs4.realpathSync.native(existingAncestor);
|
|
1556
1155
|
} catch (err) {
|
|
1557
1156
|
throw new PathSafetyError(
|
|
1558
1157
|
"path-unresolvable",
|
|
@@ -1566,12 +1165,12 @@ function resolveInsideProject(project2, relative, label) {
|
|
|
1566
1165
|
);
|
|
1567
1166
|
}
|
|
1568
1167
|
let realPath = null;
|
|
1569
|
-
if (
|
|
1570
|
-
const lst =
|
|
1168
|
+
if (fs4.existsSync(target)) {
|
|
1169
|
+
const lst = fs4.lstatSync(target);
|
|
1571
1170
|
if (lst.isSymbolicLink()) {
|
|
1572
1171
|
throw new PathSafetyError("path-symlink", `${label} \u662F\u7B26\u53F7\u94FE\u63A5/\u8054\u63A5\uFF0C\u62D2\u7EDD\u5199\u5165\u6216\u8DDF\u968F: ${target}`);
|
|
1573
1172
|
}
|
|
1574
|
-
realPath =
|
|
1173
|
+
realPath = fs4.realpathSync.native(target);
|
|
1575
1174
|
if (!isInside(project2.realRoot, realPath)) {
|
|
1576
1175
|
throw new PathSafetyError("path-escape", `${label} \u7684\u771F\u5B9E\u8DEF\u5F84\u9003\u9038\u5DE5\u7A0B\u6839: ${realPath}`);
|
|
1577
1176
|
}
|
|
@@ -1592,7 +1191,7 @@ var alive = (pid) => {
|
|
|
1592
1191
|
return e.code !== "ESRCH";
|
|
1593
1192
|
}
|
|
1594
1193
|
};
|
|
1595
|
-
var root = () =>
|
|
1194
|
+
var root = () => path6.join(
|
|
1596
1195
|
os2.tmpdir(),
|
|
1597
1196
|
"vant-capability-resources",
|
|
1598
1197
|
createHash2("sha256").update(os2.homedir()).digest("hex")
|
|
@@ -1623,7 +1222,7 @@ async function retryFile(action) {
|
|
|
1623
1222
|
}
|
|
1624
1223
|
async function remove(file2) {
|
|
1625
1224
|
try {
|
|
1626
|
-
await retryFile(() =>
|
|
1225
|
+
await retryFile(() => fs5.unlinkSync(file2));
|
|
1627
1226
|
} catch (e) {
|
|
1628
1227
|
if (e.code !== "ENOENT") throw e;
|
|
1629
1228
|
}
|
|
@@ -1633,9 +1232,9 @@ async function acquireResources(project2, resources, bindingPaths = [], options
|
|
|
1633
1232
|
return Object.assign(async () => {
|
|
1634
1233
|
}, { transfer: async () => false });
|
|
1635
1234
|
const dir = root();
|
|
1636
|
-
|
|
1235
|
+
fs5.mkdirSync(dir, { recursive: true });
|
|
1637
1236
|
const paths = [project2, ...bindingPaths].map(
|
|
1638
|
-
(p) => comparePathForm(
|
|
1237
|
+
(p) => comparePathForm(fs5.existsSync(p) ? fs5.realpathSync.native(p) : path6.resolve(p))
|
|
1639
1238
|
);
|
|
1640
1239
|
const claim = {
|
|
1641
1240
|
token: randomUUID(),
|
|
@@ -1644,14 +1243,14 @@ async function acquireResources(project2, resources, bindingPaths = [], options
|
|
|
1644
1243
|
paths,
|
|
1645
1244
|
resources
|
|
1646
1245
|
};
|
|
1647
|
-
const file2 =
|
|
1246
|
+
const file2 = path6.join(dir, claim.token + ".json");
|
|
1648
1247
|
async function write() {
|
|
1649
1248
|
const temp = file2 + "." + randomUUID() + ".pending";
|
|
1650
1249
|
try {
|
|
1651
|
-
|
|
1652
|
-
await retryFile(() =>
|
|
1250
|
+
fs5.writeFileSync(temp, JSON.stringify(claim), { flag: "wx" });
|
|
1251
|
+
await retryFile(() => fs5.renameSync(temp, file2));
|
|
1653
1252
|
} finally {
|
|
1654
|
-
if (
|
|
1253
|
+
if (fs5.existsSync(temp)) await remove(temp);
|
|
1655
1254
|
}
|
|
1656
1255
|
}
|
|
1657
1256
|
const deadline = Date.now() + (options.timeoutMs ?? 9e4);
|
|
@@ -1661,13 +1260,13 @@ async function acquireResources(project2, resources, bindingPaths = [], options
|
|
|
1661
1260
|
await write();
|
|
1662
1261
|
try {
|
|
1663
1262
|
let localBusy = false;
|
|
1664
|
-
for (const name of
|
|
1665
|
-
const existing =
|
|
1263
|
+
for (const name of fs5.readdirSync(dir).filter((n) => n.endsWith(".json"))) {
|
|
1264
|
+
const existing = path6.join(dir, name);
|
|
1666
1265
|
if (existing === file2) continue;
|
|
1667
1266
|
let other;
|
|
1668
1267
|
try {
|
|
1669
1268
|
other = JSON.parse(
|
|
1670
|
-
await retryFile(() =>
|
|
1269
|
+
await retryFile(() => fs5.readFileSync(existing, "utf8"))
|
|
1671
1270
|
);
|
|
1672
1271
|
} catch (error) {
|
|
1673
1272
|
if (error.code === "ENOENT") continue;
|
|
@@ -1696,7 +1295,7 @@ async function acquireResources(project2, resources, bindingPaths = [], options
|
|
|
1696
1295
|
if (transferred) return;
|
|
1697
1296
|
try {
|
|
1698
1297
|
const current = JSON.parse(
|
|
1699
|
-
await retryFile(() =>
|
|
1298
|
+
await retryFile(() => fs5.readFileSync(file2, "utf8"))
|
|
1700
1299
|
);
|
|
1701
1300
|
if (current.pid !== process.pid) return;
|
|
1702
1301
|
} catch (error) {
|
|
@@ -1968,8 +1567,8 @@ function validateValue(value, schema, pointer = "$") {
|
|
|
1968
1567
|
}
|
|
1969
1568
|
|
|
1970
1569
|
// src/core/project/config.ts
|
|
1971
|
-
import
|
|
1972
|
-
import
|
|
1570
|
+
import fs6 from "fs";
|
|
1571
|
+
import path7 from "path";
|
|
1973
1572
|
import { createHash as createHash3 } from "crypto";
|
|
1974
1573
|
var PROJECT_CLI_CONFIG_RELATIVE = ".vant/config/v-cli.json";
|
|
1975
1574
|
var VANT_PROJECT_CONFIG_RELATIVE = ".vant/config/project.json";
|
|
@@ -2127,12 +1726,12 @@ function resolveBindings(project2, config, providers) {
|
|
|
2127
1726
|
return { ok: true, bindings: result4 };
|
|
2128
1727
|
}
|
|
2129
1728
|
function loadProjectConfig(project2, providers) {
|
|
2130
|
-
const file2 =
|
|
1729
|
+
const file2 = path7.join(project2.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
|
|
2131
1730
|
const initHint = `\u8BF7\u5148\u5728\u5DE5\u7A0B\u6839\u8FD0\u884C \`v-cli project init --project <\u5DE5\u7A0B\u6839>\` \u751F\u6210 ${PROJECT_CLI_CONFIG_RELATIVE}`;
|
|
2132
1731
|
let text5;
|
|
2133
1732
|
try {
|
|
2134
1733
|
resolveInsideProject(project2, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
|
|
2135
|
-
text5 =
|
|
1734
|
+
text5 = fs6.readFileSync(file2, "utf-8");
|
|
2136
1735
|
} catch (err) {
|
|
2137
1736
|
if (err instanceof Error && "code" in err && String(err.code).startsWith("path-")) {
|
|
2138
1737
|
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" };
|
|
@@ -2211,25 +1810,25 @@ function renderProjectConfig(project2, providers, overrides = {}) {
|
|
|
2211
1810
|
}
|
|
2212
1811
|
var CONFIG_BACKUP_RELATIVE = ".vant/state/config-backups";
|
|
2213
1812
|
function atomicWriteConfig(project2, file2, content) {
|
|
2214
|
-
const configDir =
|
|
1813
|
+
const configDir = path7.dirname(file2);
|
|
2215
1814
|
resolveInsideProject(project2, ".vant/config", ".vant/config");
|
|
2216
|
-
|
|
1815
|
+
fs6.mkdirSync(configDir, { recursive: true });
|
|
2217
1816
|
const tmpPath = `${file2}.${process.pid}.${Date.now()}.tmp`;
|
|
2218
1817
|
try {
|
|
2219
|
-
|
|
2220
|
-
|
|
1818
|
+
fs6.writeFileSync(tmpPath, content, { encoding: "utf-8" });
|
|
1819
|
+
fs6.renameSync(tmpPath, file2);
|
|
2221
1820
|
} catch (err) {
|
|
2222
1821
|
try {
|
|
2223
|
-
|
|
1822
|
+
fs6.rmSync(tmpPath, { force: true });
|
|
2224
1823
|
} catch {
|
|
2225
1824
|
}
|
|
2226
1825
|
throw err;
|
|
2227
1826
|
}
|
|
2228
1827
|
}
|
|
2229
1828
|
function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
2230
|
-
const file2 =
|
|
2231
|
-
const vantFile =
|
|
2232
|
-
const vantConfig = { file: vantFile, exists:
|
|
1829
|
+
const file2 = path7.join(project2.root, ...PROJECT_CLI_CONFIG_RELATIVE.split("/"));
|
|
1830
|
+
const vantFile = path7.join(project2.root, ...VANT_PROJECT_CONFIG_RELATIVE.split("/"));
|
|
1831
|
+
const vantConfig = { file: vantFile, exists: fs6.existsSync(vantFile) };
|
|
2233
1832
|
const refused = (reason) => ({
|
|
2234
1833
|
ok: false,
|
|
2235
1834
|
action: "refused",
|
|
@@ -2244,14 +1843,14 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2244
1843
|
const known = [...providers.keys()].sort().join(", ") || "\uFF08\u65E0\u5DF2\u6CE8\u518C Provider\uFF09";
|
|
2245
1844
|
return refused(`\u672A\u77E5 Provider \u7ED1\u5B9A\u8986\u76D6: ${unknownOverrides.join(", ")}\uFF08\u5DF2\u6CE8\u518C: ${known}\uFF09`);
|
|
2246
1845
|
}
|
|
2247
|
-
const exists =
|
|
1846
|
+
const exists = fs6.existsSync(file2);
|
|
2248
1847
|
const reset = options.reset === true;
|
|
2249
1848
|
const dryRun = options.dryRun === true;
|
|
2250
1849
|
if (exists && !reset) {
|
|
2251
1850
|
resolveInsideProject(project2, PROJECT_CLI_CONFIG_RELATIVE, PROJECT_CLI_CONFIG_RELATIVE);
|
|
2252
1851
|
let existing;
|
|
2253
1852
|
try {
|
|
2254
|
-
existing = JSON.parse(
|
|
1853
|
+
existing = JSON.parse(fs6.readFileSync(file2, "utf-8"));
|
|
2255
1854
|
} catch (err) {
|
|
2256
1855
|
return refused(
|
|
2257
1856
|
`\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`
|
|
@@ -2298,7 +1897,7 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2298
1897
|
if (!existingCheck.ok) {
|
|
2299
1898
|
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`);
|
|
2300
1899
|
}
|
|
2301
|
-
const current =
|
|
1900
|
+
const current = fs6.readFileSync(file2, "utf-8");
|
|
2302
1901
|
return {
|
|
2303
1902
|
ok: true,
|
|
2304
1903
|
action: "unchanged",
|
|
@@ -2352,21 +1951,21 @@ function initProjectConfig(project2, providers, overrides = {}, options = {}) {
|
|
|
2352
1951
|
}
|
|
2353
1952
|
let backupPath;
|
|
2354
1953
|
if (reset && exists && !dryRun) {
|
|
2355
|
-
const backupDir =
|
|
1954
|
+
const backupDir = path7.join(project2.root, ...CONFIG_BACKUP_RELATIVE.split("/"));
|
|
2356
1955
|
resolveInsideProject(project2, CONFIG_BACKUP_RELATIVE, CONFIG_BACKUP_RELATIVE);
|
|
2357
|
-
|
|
1956
|
+
fs6.mkdirSync(backupDir, { recursive: true });
|
|
2358
1957
|
const stamp = `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${process.pid.toString(36)}`;
|
|
2359
|
-
backupPath =
|
|
2360
|
-
|
|
1958
|
+
backupPath = path7.join(backupDir, `v-cli.${stamp}.json`);
|
|
1959
|
+
fs6.copyFileSync(file2, backupPath);
|
|
2361
1960
|
}
|
|
2362
1961
|
if (!dryRun) {
|
|
2363
1962
|
if (exists) {
|
|
2364
1963
|
atomicWriteConfig(project2, file2, rendered.content);
|
|
2365
1964
|
} else {
|
|
2366
|
-
const configDir =
|
|
1965
|
+
const configDir = path7.join(project2.root, ".vant", "config");
|
|
2367
1966
|
resolveInsideProject(project2, ".vant/config", ".vant/config");
|
|
2368
|
-
|
|
2369
|
-
|
|
1967
|
+
fs6.mkdirSync(configDir, { recursive: true });
|
|
1968
|
+
fs6.writeFileSync(file2, rendered.content, { encoding: "utf-8", flag: "wx" });
|
|
2370
1969
|
}
|
|
2371
1970
|
}
|
|
2372
1971
|
return {
|
|
@@ -2413,7 +2012,7 @@ function inspectProject(project2, providers) {
|
|
|
2413
2012
|
} else if (loaded.kind === "invalid" || loaded.kind === "unsafe-binding") {
|
|
2414
2013
|
let rawBindings = {};
|
|
2415
2014
|
try {
|
|
2416
|
-
const parsed = JSON.parse(
|
|
2015
|
+
const parsed = JSON.parse(fs6.readFileSync(loaded.file, "utf-8"));
|
|
2417
2016
|
if (isPlainObject5(parsed) && isPlainObject5(parsed.bindings)) rawBindings = parsed.bindings;
|
|
2418
2017
|
} catch {
|
|
2419
2018
|
}
|
|
@@ -2468,26 +2067,26 @@ function inspectProject(project2, providers) {
|
|
|
2468
2067
|
});
|
|
2469
2068
|
}
|
|
2470
2069
|
}
|
|
2471
|
-
const vantDir =
|
|
2070
|
+
const vantDir = path7.join(project2.root, ".vant");
|
|
2472
2071
|
let configFiles = [];
|
|
2473
|
-
const configDir =
|
|
2474
|
-
if (
|
|
2072
|
+
const configDir = path7.join(vantDir, "config");
|
|
2073
|
+
if (fs6.existsSync(configDir)) {
|
|
2475
2074
|
try {
|
|
2476
|
-
configFiles =
|
|
2075
|
+
configFiles = fs6.readdirSync(configDir).sort();
|
|
2477
2076
|
} catch {
|
|
2478
2077
|
configFiles = [];
|
|
2479
2078
|
}
|
|
2480
2079
|
}
|
|
2481
|
-
const stateDir =
|
|
2080
|
+
const stateDir = path7.join(project2.root, ...OPERATIONS_RELATIVE.split("/"));
|
|
2482
2081
|
let operationCount = 0;
|
|
2483
|
-
if (
|
|
2082
|
+
if (fs6.existsSync(stateDir)) {
|
|
2484
2083
|
try {
|
|
2485
|
-
operationCount =
|
|
2084
|
+
operationCount = fs6.readdirSync(stateDir).filter((name) => fs6.statSync(path7.join(stateDir, name)).isDirectory()).length;
|
|
2486
2085
|
} catch {
|
|
2487
2086
|
operationCount = 0;
|
|
2488
2087
|
}
|
|
2489
2088
|
}
|
|
2490
|
-
const vantFile =
|
|
2089
|
+
const vantFile = path7.join(project2.root, ...VANT_PROJECT_CONFIG_RELATIVE.split("/"));
|
|
2491
2090
|
let bindingsValue = {};
|
|
2492
2091
|
if (loaded.ok) bindingsValue = loaded.config.bindings;
|
|
2493
2092
|
return {
|
|
@@ -2507,14 +2106,14 @@ function inspectProject(project2, providers) {
|
|
|
2507
2106
|
},
|
|
2508
2107
|
vant: {
|
|
2509
2108
|
dir: vantDir,
|
|
2510
|
-
exists:
|
|
2109
|
+
exists: fs6.existsSync(vantDir),
|
|
2511
2110
|
configFiles,
|
|
2512
2111
|
projectConfigFile: vantFile,
|
|
2513
|
-
projectConfigExists:
|
|
2112
|
+
projectConfigExists: fs6.existsSync(vantFile)
|
|
2514
2113
|
},
|
|
2515
2114
|
state: {
|
|
2516
2115
|
dir: stateDir,
|
|
2517
|
-
exists:
|
|
2116
|
+
exists: fs6.existsSync(stateDir),
|
|
2518
2117
|
operationCount
|
|
2519
2118
|
},
|
|
2520
2119
|
initHint: `v-cli project init --project ${project2.root}`
|
|
@@ -2522,13 +2121,13 @@ function inspectProject(project2, providers) {
|
|
|
2522
2121
|
}
|
|
2523
2122
|
|
|
2524
2123
|
// src/core/execution/handle.ts
|
|
2525
|
-
import
|
|
2124
|
+
import fs8 from "fs";
|
|
2526
2125
|
import { createHash as createHash5 } from "crypto";
|
|
2527
2126
|
|
|
2528
2127
|
// src/core/project/operation-store.ts
|
|
2529
|
-
import
|
|
2530
|
-
import
|
|
2531
|
-
import { createHash as createHash4, randomBytes
|
|
2128
|
+
import fs7 from "fs";
|
|
2129
|
+
import path8 from "path";
|
|
2130
|
+
import { createHash as createHash4, randomBytes } from "crypto";
|
|
2532
2131
|
var OPERATION_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
2533
2132
|
var WINDOWS_RESERVED = /* @__PURE__ */ new Set([
|
|
2534
2133
|
"con",
|
|
@@ -2568,7 +2167,7 @@ function validateOperationId(operationId) {
|
|
|
2568
2167
|
function generateOperationId(capabilityId, now = /* @__PURE__ */ new Date(), entropy) {
|
|
2569
2168
|
const stamp = now.toISOString().replace(/[-:]/g, "").replace("T", "-").slice(0, 15);
|
|
2570
2169
|
const slug = capabilityId.replace(/\./g, "-").replace(/[^a-z0-9-]/gi, "-").toLowerCase();
|
|
2571
|
-
const suffix = entropy ??
|
|
2170
|
+
const suffix = entropy ?? randomBytes(3).toString("hex");
|
|
2572
2171
|
return `${stamp}-${slug}-${suffix}`;
|
|
2573
2172
|
}
|
|
2574
2173
|
var OperationStore = class _OperationStore {
|
|
@@ -2596,7 +2195,7 @@ var OperationStore = class _OperationStore {
|
|
|
2596
2195
|
}
|
|
2597
2196
|
const operationsRoot = resolveInsideProject(project2, OPERATIONS_RELATIVE, OPERATIONS_RELATIVE);
|
|
2598
2197
|
try {
|
|
2599
|
-
|
|
2198
|
+
fs7.mkdirSync(operationsRoot.path, { recursive: true });
|
|
2600
2199
|
} catch (err) {
|
|
2601
2200
|
throw new PathSafetyError(
|
|
2602
2201
|
"operations-dir-failed",
|
|
@@ -2604,9 +2203,9 @@ var OperationStore = class _OperationStore {
|
|
|
2604
2203
|
);
|
|
2605
2204
|
}
|
|
2606
2205
|
const verifiedRoot = resolveInsideProject(project2, OPERATIONS_RELATIVE, OPERATIONS_RELATIVE);
|
|
2607
|
-
const dir =
|
|
2206
|
+
const dir = path8.join(verifiedRoot.path, operationId);
|
|
2608
2207
|
try {
|
|
2609
|
-
|
|
2208
|
+
fs7.mkdirSync(dir);
|
|
2610
2209
|
} catch (err) {
|
|
2611
2210
|
if (err.code === "EEXIST") {
|
|
2612
2211
|
throw new OperationExistsError(operationId, dir);
|
|
@@ -2632,7 +2231,7 @@ var OperationStore = class _OperationStore {
|
|
|
2632
2231
|
write(fileName, content, flags = "w") {
|
|
2633
2232
|
if (!this.enabled || !this.dir) return false;
|
|
2634
2233
|
try {
|
|
2635
|
-
|
|
2234
|
+
fs7.writeFileSync(path8.join(this.dir, fileName), content, { encoding: "utf-8", flag: flags });
|
|
2636
2235
|
if (!this.writtenFiles.includes(fileName)) this.writtenFiles.push(fileName);
|
|
2637
2236
|
return true;
|
|
2638
2237
|
} catch (err) {
|
|
@@ -2651,7 +2250,7 @@ var OperationStore = class _OperationStore {
|
|
|
2651
2250
|
this.events.push(record);
|
|
2652
2251
|
if (!this.enabled || !this.dir) return;
|
|
2653
2252
|
try {
|
|
2654
|
-
|
|
2253
|
+
fs7.appendFileSync(path8.join(this.dir, "events.jsonl"), `${JSON.stringify(record)}
|
|
2655
2254
|
`, "utf-8");
|
|
2656
2255
|
if (!this.writtenFiles.includes("events.jsonl")) this.writtenFiles.push("events.jsonl");
|
|
2657
2256
|
} catch (err) {
|
|
@@ -2825,14 +2424,14 @@ function verifyExecutionHandle(input) {
|
|
|
2825
2424
|
}
|
|
2826
2425
|
throw err;
|
|
2827
2426
|
}
|
|
2828
|
-
if (!
|
|
2427
|
+
if (!fs8.existsSync(recordPath)) {
|
|
2829
2428
|
return fail("handle-evidence-missing", [
|
|
2830
2429
|
`\u53E5\u67C4\u8BC1\u636E\u7F3A\u5931: ${expectedDir}/result.json\uFF08\u76EE\u5F55\u6216\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1B\u4E0D\u56DE\u9000\u6700\u8FD1\u4EFB\u52A1\uFF09`
|
|
2831
2430
|
]);
|
|
2832
2431
|
}
|
|
2833
2432
|
let raw;
|
|
2834
2433
|
try {
|
|
2835
|
-
raw = JSON.parse(
|
|
2434
|
+
raw = JSON.parse(fs8.readFileSync(recordPath, "utf-8"));
|
|
2836
2435
|
} catch (err) {
|
|
2837
2436
|
return fail("handle-evidence-unreadable", [
|
|
2838
2437
|
`\u53E5\u67C4\u8BC1\u636E\u4E0D\u53EF\u8BFB: ${err instanceof Error ? err.message : String(err)}`
|
|
@@ -3945,7 +3544,7 @@ var commands = [
|
|
|
3945
3544
|
description: "\u521B\u5EFA\u6E38\u620F\u5206\u53D1\u914D\u7F6E",
|
|
3946
3545
|
fields: { force: bool },
|
|
3947
3546
|
result: result({ written: text, force: bool }),
|
|
3948
|
-
verify: (r) => typeof r.written === "string" &&
|
|
3547
|
+
verify: (r) => typeof r.written === "string" && fs9.existsSync(r.written)
|
|
3949
3548
|
},
|
|
3950
3549
|
{
|
|
3951
3550
|
id: "config-validate",
|
|
@@ -3975,7 +3574,7 @@ var commands = [
|
|
|
3975
3574
|
depots: { type: "array" },
|
|
3976
3575
|
preview: bool
|
|
3977
3576
|
}),
|
|
3978
|
-
verify: (r) => typeof r.appBuild === "string" &&
|
|
3577
|
+
verify: (r) => typeof r.appBuild === "string" && fs9.existsSync(r.appBuild)
|
|
3979
3578
|
},
|
|
3980
3579
|
...["preview", "push"].map((action) => ({
|
|
3981
3580
|
id: `steam-${action}`,
|
|
@@ -4038,7 +3637,7 @@ var commands = [
|
|
|
4038
3637
|
robot: { type: "integer" },
|
|
4039
3638
|
qrOut: { type: "string", nullable: true }
|
|
4040
3639
|
}),
|
|
4041
|
-
verify: (r) => r.ok === true && r.mode === (action === "push" ? "upload" : "preview") && (action !== "preview" || typeof r.qrOut === "string" &&
|
|
3640
|
+
verify: (r) => r.ok === true && r.mode === (action === "push" ? "upload" : "preview") && (action !== "preview" || typeof r.qrOut === "string" && fs9.existsSync(r.qrOut))
|
|
4042
3641
|
}))
|
|
4043
3642
|
];
|
|
4044
3643
|
var definitions = commands.map((d) => ({
|
|
@@ -4064,8 +3663,8 @@ var definitions = commands.map((d) => ({
|
|
|
4064
3663
|
var createShipProvider = (deps) => projectCommandProvider("ship", definitions, deps);
|
|
4065
3664
|
|
|
4066
3665
|
// src/providers/xlmerge/index.ts
|
|
4067
|
-
import
|
|
4068
|
-
import
|
|
3666
|
+
import fs10 from "fs";
|
|
3667
|
+
import path9 from "path";
|
|
4069
3668
|
var text2 = { type: "string", minLength: 1 };
|
|
4070
3669
|
var ok2 = {
|
|
4071
3670
|
type: "object",
|
|
@@ -4112,7 +3711,7 @@ var commands2 = [
|
|
|
4112
3711
|
properties: { ok: { type: "boolean" }, manifest: text2 },
|
|
4113
3712
|
additionalProperties: true
|
|
4114
3713
|
},
|
|
4115
|
-
verify: (r) => r.ok === true && typeof r.manifest === "string" &&
|
|
3714
|
+
verify: (r) => r.ok === true && typeof r.manifest === "string" && fs10.existsSync(r.manifest)
|
|
4116
3715
|
},
|
|
4117
3716
|
...["launch", "resolve"].map((action) => ({
|
|
4118
3717
|
id: action,
|
|
@@ -4179,7 +3778,7 @@ var createXlmergeProvider = (deps) => projectCommandProvider(
|
|
|
4179
3778
|
"--repo",
|
|
4180
3779
|
ctx.bindingDirs.projectDir,
|
|
4181
3780
|
"--runtime-dir",
|
|
4182
|
-
|
|
3781
|
+
path9.join(ctx.projectRoot, ".vant/state/xlmerge", ctx.operationId)
|
|
4183
3782
|
];
|
|
4184
3783
|
if (d.control) {
|
|
4185
3784
|
const checked = verifyExecutionHandle({
|
|
@@ -4189,7 +3788,7 @@ var createXlmergeProvider = (deps) => projectCommandProvider(
|
|
|
4189
3788
|
});
|
|
4190
3789
|
if (!checked.ok) throw Error(checked.errors.join("\uFF1B"));
|
|
4191
3790
|
const origin = JSON.parse(
|
|
4192
|
-
|
|
3791
|
+
fs10.readFileSync(
|
|
4193
3792
|
resolveInsideProject(
|
|
4194
3793
|
ctx.projectAnchor,
|
|
4195
3794
|
checked.record.recordDir + "/result.json",
|
|
@@ -4204,7 +3803,7 @@ var createXlmergeProvider = (deps) => projectCommandProvider(
|
|
|
4204
3803
|
throw Error("\u539F\u5BA1\u9605\u4E0D\u5C5E\u4E8E\u5F53\u524D\u4ED3\u5E93\u7ED1\u5B9A");
|
|
4205
3804
|
const manifest = origin.output?.result?.manifest;
|
|
4206
3805
|
if (typeof manifest !== "string") throw Error("\u539F\u5BA1\u9605\u7F3A\u5C11\u6E05\u5355\u8EAB\u4EFD");
|
|
4207
|
-
const relative =
|
|
3806
|
+
const relative = path9.relative(ctx.projectRoot, manifest);
|
|
4208
3807
|
resolveInsideProject(ctx.projectAnchor, relative, "xlmerge.session");
|
|
4209
3808
|
return [
|
|
4210
3809
|
"--repo",
|
|
@@ -4235,8 +3834,8 @@ var createXlmergeProvider = (deps) => projectCommandProvider(
|
|
|
4235
3834
|
`xlmerge.${key}`
|
|
4236
3835
|
).path;
|
|
4237
3836
|
if (key === "manifest") {
|
|
4238
|
-
const manifest = JSON.parse(
|
|
4239
|
-
if (typeof manifest.repoRoot !== "string" || comparePathForm(
|
|
3837
|
+
const manifest = JSON.parse(fs10.readFileSync(actual, "utf8"));
|
|
3838
|
+
if (typeof manifest.repoRoot !== "string" || comparePathForm(fs10.realpathSync(manifest.repoRoot)) !== comparePathForm(fs10.realpathSync(ctx.bindingDirs.projectDir)))
|
|
4240
3839
|
throw Error("\u5408\u5E76\u6E05\u5355\u4E0D\u5C5E\u4E8E\u5F53\u524D\u4ED3\u5E93");
|
|
4241
3840
|
}
|
|
4242
3841
|
}
|
|
@@ -4605,7 +4204,7 @@ var CapabilityRegistry = class {
|
|
|
4605
4204
|
|
|
4606
4205
|
// src/core/execution/executor.ts
|
|
4607
4206
|
import { spawn } from "child_process";
|
|
4608
|
-
import
|
|
4207
|
+
import path10 from "path";
|
|
4609
4208
|
var DEFAULT_MAX_OUTPUT = 8 * 1024 * 1024;
|
|
4610
4209
|
var OutputCollector = class {
|
|
4611
4210
|
constructor(limit) {
|
|
@@ -4715,7 +4314,7 @@ var NodeProcessExecutor = class {
|
|
|
4715
4314
|
}
|
|
4716
4315
|
if (process.platform === "win32") {
|
|
4717
4316
|
killTree = new Promise((resolve) => {
|
|
4718
|
-
const killer = spawn(
|
|
4317
|
+
const killer = spawn(path10.join(process.env.SystemRoot ?? "C:\\Windows", "System32", "taskkill.exe"), ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, stdio: "ignore", shell: false });
|
|
4719
4318
|
const timeout = setTimeout(() => {
|
|
4720
4319
|
killer.kill();
|
|
4721
4320
|
resolve(false);
|
|
@@ -5035,8 +4634,8 @@ var PIPELINE_COMMANDS = {
|
|
|
5035
4634
|
};
|
|
5036
4635
|
|
|
5037
4636
|
// src/providers/unity/index.ts
|
|
5038
|
-
import
|
|
5039
|
-
import
|
|
4637
|
+
import fs11 from "fs";
|
|
4638
|
+
import path11 from "path";
|
|
5040
4639
|
|
|
5041
4640
|
// src/providers/unity/protocol.ts
|
|
5042
4641
|
function isPlainObject8(v) {
|
|
@@ -5130,9 +4729,9 @@ var FAIL_COUNT_PATHS = [
|
|
|
5130
4729
|
];
|
|
5131
4730
|
function extractFailCount(payload) {
|
|
5132
4731
|
if (!isPlainObject8(payload)) return { count: null, source: null };
|
|
5133
|
-
for (const
|
|
4732
|
+
for (const path17 of FAIL_COUNT_PATHS) {
|
|
5134
4733
|
let current = payload;
|
|
5135
|
-
for (const segment of
|
|
4734
|
+
for (const segment of path17) {
|
|
5136
4735
|
if (!isPlainObject8(current)) {
|
|
5137
4736
|
current = void 0;
|
|
5138
4737
|
break;
|
|
@@ -5140,16 +4739,16 @@ function extractFailCount(payload) {
|
|
|
5140
4739
|
current = current[segment];
|
|
5141
4740
|
}
|
|
5142
4741
|
if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
|
|
5143
|
-
return { count: current, source:
|
|
4742
|
+
return { count: current, source: path17.join(".") };
|
|
5144
4743
|
}
|
|
5145
4744
|
}
|
|
5146
4745
|
return { count: null, source: null };
|
|
5147
4746
|
}
|
|
5148
4747
|
function extractTotal(payload) {
|
|
5149
4748
|
if (!isPlainObject8(payload)) return { total: null, source: null };
|
|
5150
|
-
for (const
|
|
4749
|
+
for (const path17 of [["summary", "total"]]) {
|
|
5151
4750
|
let current = payload;
|
|
5152
|
-
for (const segment of
|
|
4751
|
+
for (const segment of path17) {
|
|
5153
4752
|
if (!isPlainObject8(current)) {
|
|
5154
4753
|
current = void 0;
|
|
5155
4754
|
break;
|
|
@@ -5157,7 +4756,7 @@ function extractTotal(payload) {
|
|
|
5157
4756
|
current = current[segment];
|
|
5158
4757
|
}
|
|
5159
4758
|
if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
|
|
5160
|
-
return { total: current, source:
|
|
4759
|
+
return { total: current, source: path17.join(".") };
|
|
5161
4760
|
}
|
|
5162
4761
|
}
|
|
5163
4762
|
return { total: null, source: null };
|
|
@@ -5566,7 +5165,7 @@ function unityPathsEqual(a, b) {
|
|
|
5566
5165
|
const norm = comparePathForm;
|
|
5567
5166
|
if (norm(a) === norm(b)) return true;
|
|
5568
5167
|
try {
|
|
5569
|
-
return norm(
|
|
5168
|
+
return norm(fs11.realpathSync(a)) === norm(fs11.realpathSync(b));
|
|
5570
5169
|
} catch {
|
|
5571
5170
|
return false;
|
|
5572
5171
|
}
|
|
@@ -5709,8 +5308,8 @@ function createUnityProvider(deps) {
|
|
|
5709
5308
|
if (!dir) {
|
|
5710
5309
|
return { id: "unity.project-version-file", status: "violated", detail: "\u7F3A\u5C11\u5DE5\u7A0B\u76EE\u5F55\u7ED1\u5B9A" };
|
|
5711
5310
|
}
|
|
5712
|
-
const versionFile =
|
|
5713
|
-
if (
|
|
5311
|
+
const versionFile = path11.join(dir, "ProjectSettings", "ProjectVersion.txt");
|
|
5312
|
+
if (fs11.existsSync(versionFile)) {
|
|
5714
5313
|
return {
|
|
5715
5314
|
id: "unity.project-version-file",
|
|
5716
5315
|
status: "satisfied",
|
|
@@ -7163,8 +6762,8 @@ function createUnityProvider(deps) {
|
|
|
7163
6762
|
binding: unityBindingContract,
|
|
7164
6763
|
defaultBinding: (project2) => {
|
|
7165
6764
|
const warnings = [];
|
|
7166
|
-
const declared =
|
|
7167
|
-
if (!
|
|
6765
|
+
const declared = path11.join(project2.root, "Client");
|
|
6766
|
+
if (!fs11.existsSync(declared)) {
|
|
7168
6767
|
warnings.push(
|
|
7169
6768
|
`bindings.unity.projectDir="Client" \u5F53\u524D\u4E0D\u5B58\u5728\uFF1A\u8BF7\u6309\u5DE5\u7A0B\u5B9E\u9645\u76EE\u5F55\u4FEE\u6539 ${PROJECT_CLI_CONFIG_RELATIVE} \u6216\u7528 --binding unity='{...}' \u8986\u76D6`
|
|
7170
6769
|
);
|
|
@@ -7188,7 +6787,7 @@ function createUnityProvider(deps) {
|
|
|
7188
6787
|
}
|
|
7189
6788
|
|
|
7190
6789
|
// src/providers/art/index.ts
|
|
7191
|
-
import
|
|
6790
|
+
import path12 from "path";
|
|
7192
6791
|
import { readFileSync } from "fs";
|
|
7193
6792
|
var identifier = {
|
|
7194
6793
|
type: "string",
|
|
@@ -7519,7 +7118,7 @@ function createArtProvider(deps) {
|
|
|
7519
7118
|
"--cache-dir",
|
|
7520
7119
|
ctx.bindingDirs.cache,
|
|
7521
7120
|
"--config",
|
|
7522
|
-
|
|
7121
|
+
path12.join(ctx.bindingDirs.workspace, "settings.json")
|
|
7523
7122
|
];
|
|
7524
7123
|
if (!d.global && !d.control && !(d.command[1] === "run" && input.plan))
|
|
7525
7124
|
argv.push("--project", String(ctx.binding.projectId));
|
|
@@ -7753,8 +7352,8 @@ function figmaCommandRegistrations(deps) {
|
|
|
7753
7352
|
}
|
|
7754
7353
|
|
|
7755
7354
|
// src/providers/figma/index.ts
|
|
7756
|
-
import
|
|
7757
|
-
import
|
|
7355
|
+
import fs12 from "fs";
|
|
7356
|
+
import path13 from "path";
|
|
7758
7357
|
|
|
7759
7358
|
// src/providers/figma/protocol.ts
|
|
7760
7359
|
var VALID_LINE = /^(?:\[figma-to-uprefab\] )?Contract valid: (\d+) root\(s\)\.$/;
|
|
@@ -7857,8 +7456,8 @@ var figmaBindingContract = {
|
|
|
7857
7456
|
if (errors.length > 0) return { ok: false, errors };
|
|
7858
7457
|
const projectDir = resolve(project2, section.projectDir, "bindings.figma.projectDir");
|
|
7859
7458
|
const stagingRoot = resolve(project2, section.stagingRoot, "bindings.figma.stagingRoot");
|
|
7860
|
-
const rel =
|
|
7861
|
-
if (rel === "" || rel === ".." || rel.startsWith(`..${
|
|
7459
|
+
const rel = path13.relative(projectDir.path, stagingRoot.path);
|
|
7460
|
+
if (rel === "" || rel === ".." || rel.startsWith(`..${path13.sep}`) || path13.isAbsolute(rel)) {
|
|
7862
7461
|
return {
|
|
7863
7462
|
ok: false,
|
|
7864
7463
|
errors: [`bindings.figma.stagingRoot \u5FC5\u987B\u4F4D\u4E8E bindings.figma.projectDir\uFF08${section.projectDir}\uFF09\u5185\uFF08\u6536\u5230 ${section.stagingRoot}\uFF09`]
|
|
@@ -7879,7 +7478,7 @@ function figmaBinding(ctx) {
|
|
|
7879
7478
|
return binding;
|
|
7880
7479
|
}
|
|
7881
7480
|
function normalizeProjectKey(projectPath) {
|
|
7882
|
-
let key =
|
|
7481
|
+
let key = path13.resolve(projectPath).replace(/\\/g, "/");
|
|
7883
7482
|
if (process.platform === "win32") key = key.toLowerCase();
|
|
7884
7483
|
if (key.length > 3 && key.endsWith("/")) key = key.slice(0, -1);
|
|
7885
7484
|
return key;
|
|
@@ -7915,23 +7514,23 @@ function createFigmaProvider(deps) {
|
|
|
7915
7514
|
};
|
|
7916
7515
|
}
|
|
7917
7516
|
function writeManagedConfig(ctx, unityDir, stagingRootAbs) {
|
|
7918
|
-
const configPath =
|
|
7919
|
-
const stagingRelativeToUnity =
|
|
7517
|
+
const configPath = path13.join(ctx.projectAnchor.root, ...MANAGED_CONFIG_RELATIVE.split("/"));
|
|
7518
|
+
const stagingRelativeToUnity = path13.relative(unityDir, stagingRootAbs).split(path13.sep).join("/");
|
|
7920
7519
|
const payload = {
|
|
7921
7520
|
schemaVersion: 1,
|
|
7922
7521
|
projects: {
|
|
7923
7522
|
[normalizeProjectKey(unityDir)]: { uiSystem: "UGUI", staging: { root: stagingRelativeToUnity } }
|
|
7924
7523
|
}
|
|
7925
7524
|
};
|
|
7926
|
-
|
|
7525
|
+
fs12.mkdirSync(path13.dirname(configPath), { recursive: true });
|
|
7927
7526
|
const tmpPath = `${configPath}.${process.pid}.${Date.now()}.tmp`;
|
|
7928
7527
|
try {
|
|
7929
|
-
|
|
7528
|
+
fs12.writeFileSync(tmpPath, `${JSON.stringify(payload, null, 2)}
|
|
7930
7529
|
`, "utf-8");
|
|
7931
|
-
|
|
7530
|
+
fs12.renameSync(tmpPath, configPath);
|
|
7932
7531
|
} catch (err) {
|
|
7933
7532
|
try {
|
|
7934
|
-
|
|
7533
|
+
fs12.rmSync(tmpPath, { force: true });
|
|
7935
7534
|
} catch {
|
|
7936
7535
|
}
|
|
7937
7536
|
throw err;
|
|
@@ -8321,10 +7920,10 @@ function createFigmaProvider(deps) {
|
|
|
8321
7920
|
binding: figmaBindingContract,
|
|
8322
7921
|
defaultBinding: (project2) => {
|
|
8323
7922
|
const warnings = [];
|
|
8324
|
-
const declared =
|
|
8325
|
-
if (!
|
|
7923
|
+
const declared = path13.join(project2.root, "Client");
|
|
7924
|
+
if (!fs12.existsSync(declared)) {
|
|
8326
7925
|
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');
|
|
8327
|
-
} else if (!
|
|
7926
|
+
} else if (!fs12.existsSync(path13.join(declared, ...DEFAULT_STAGING_ROOT_SEGMENTS.split("/")))) {
|
|
8328
7927
|
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`);
|
|
8329
7928
|
}
|
|
8330
7929
|
return { section: { projectDir: "Client", stagingRoot: `Client/${DEFAULT_STAGING_ROOT_SEGMENTS}` }, warnings };
|
|
@@ -8653,10 +8252,10 @@ var capability = {
|
|
|
8653
8252
|
try {
|
|
8654
8253
|
let input = {};
|
|
8655
8254
|
if (opts.inputFile) {
|
|
8656
|
-
const file2 =
|
|
8255
|
+
const file2 = path14.resolve(process.cwd(), opts.inputFile);
|
|
8657
8256
|
let text5;
|
|
8658
8257
|
try {
|
|
8659
|
-
text5 =
|
|
8258
|
+
text5 = fs13.readFileSync(file2, "utf-8");
|
|
8660
8259
|
} catch (err) {
|
|
8661
8260
|
throw new CapabilityError({
|
|
8662
8261
|
code: "input-file-unreadable",
|
|
@@ -8723,7 +8322,7 @@ var capability = {
|
|
|
8723
8322
|
};
|
|
8724
8323
|
|
|
8725
8324
|
// src/commands/doctor.ts
|
|
8726
|
-
import
|
|
8325
|
+
import fs14 from "fs";
|
|
8727
8326
|
var doctor = {
|
|
8728
8327
|
name: "doctor",
|
|
8729
8328
|
description: "\u4F53\u68C0\uFF1Anode/v-cli \u7248\u672C\u3001homeDir\u3001config\u3001\u63D2\u4EF6\u72B6\u6001",
|
|
@@ -8732,7 +8331,7 @@ var doctor = {
|
|
|
8732
8331
|
program.option("--json", "\u8F93\u51FA\u673A\u5668\u53EF\u8BFB JSON").action(async (opts) => {
|
|
8733
8332
|
const json = ctx.json || opts.json;
|
|
8734
8333
|
const homeDir = ctx.homeDir;
|
|
8735
|
-
const exists =
|
|
8334
|
+
const exists = fs14.existsSync(homeDir);
|
|
8736
8335
|
let configWritable = false;
|
|
8737
8336
|
try {
|
|
8738
8337
|
ctx.config.set((cfg) => cfg);
|
|
@@ -8786,7 +8385,7 @@ var doctor = {
|
|
|
8786
8385
|
};
|
|
8787
8386
|
|
|
8788
8387
|
// src/commands/plugin.ts
|
|
8789
|
-
import
|
|
8388
|
+
import path15 from "path";
|
|
8790
8389
|
var plugin = {
|
|
8791
8390
|
name: "plugin",
|
|
8792
8391
|
description: "\u63D2\u4EF6\u7BA1\u7406\uFF1Alist \u5217\u51FA\u547D\u4EE4\uFF0Cpath \u663E\u793A\u672C\u5730\u63D2\u4EF6\u76EE\u5F55",
|
|
@@ -8825,7 +8424,7 @@ var plugin = {
|
|
|
8825
8424
|
}
|
|
8826
8425
|
});
|
|
8827
8426
|
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) => {
|
|
8828
|
-
const dir =
|
|
8427
|
+
const dir = path15.join(ctx.homeDir, "commands");
|
|
8829
8428
|
if (ctx.json || opts.json) {
|
|
8830
8429
|
ctx.log.result({ dir });
|
|
8831
8430
|
} else {
|
|
@@ -9098,12 +8697,12 @@ async function loadBuiltinCommands() {
|
|
|
9098
8697
|
return builtinCommands.map((command) => ({ command, source: "builtin" }));
|
|
9099
8698
|
}
|
|
9100
8699
|
async function loadLocalPlugins(ctx) {
|
|
9101
|
-
const dir =
|
|
8700
|
+
const dir = path16.join(ctx.homeDir, "commands");
|
|
9102
8701
|
const loaded = [];
|
|
9103
|
-
if (!
|
|
9104
|
-
const files =
|
|
8702
|
+
if (!fs15.existsSync(dir)) return loaded;
|
|
8703
|
+
const files = fs15.readdirSync(dir).filter((f) => f.endsWith(".mjs")).sort();
|
|
9105
8704
|
for (const file2 of files) {
|
|
9106
|
-
const abs =
|
|
8705
|
+
const abs = path16.join(dir, file2);
|
|
9107
8706
|
try {
|
|
9108
8707
|
const mod = await import(
|
|
9109
8708
|
/* @vite-ignore */
|
|
@@ -9252,7 +8851,7 @@ async function main() {
|
|
|
9252
8851
|
" 1. v-cli agent docs",
|
|
9253
8852
|
" 2. v-cli agent index --json",
|
|
9254
8853
|
" 3. v-cli agent describe <name> --json",
|
|
9255
|
-
" 4. v-cli agent
|
|
8854
|
+
" 4. v-cli agent skills --json \uFF08\u6309\u58F0\u660E\u53D1\u73B0\u8FD0\u884C\u6280\u80FD\uFF09",
|
|
9256
8855
|
"",
|
|
9257
8856
|
"\u5DE5\u7A0B\u6267\u884C\u57FA\u5EA7\uFF08\u7ED3\u6784\u5316\u80FD\u529B\uFF0C\u9A8C\u6536\u4E0E\u9000\u51FA\u7801\u5206\u79BB\uFF09\uFF1A",
|
|
9258
8857
|
" v-cli project init --project . \uFF08\u5199\u5165 .vant/config/v-cli.json\uFF0C\u5E42\u7B49\u8865\u5168\uFF08\u5DF2\u6709\u6BB5\u4E0D\u52A8\uFF09\uFF09",
|
|
@@ -9261,7 +8860,7 @@ async function main() {
|
|
|
9261
8860
|
" v-cli capability run unity.doctor --project . --json",
|
|
9262
8861
|
"",
|
|
9263
8862
|
"\u8BE6\u60C5\u89C1 `v-cli agent --help`\u3001`v-cli capability --help`\u3001`v-cli project --help`\uFF1B",
|
|
9264
|
-
"\u5355\u547D\u4EE4\u8BF4\u660E\u4E66\uFF1A`v-cli agent docs --help` / `v-cli agent
|
|
8863
|
+
"\u5355\u547D\u4EE4\u8BF4\u660E\u4E66\uFF1A`v-cli agent docs --help` / `v-cli agent export --help`\u3002"
|
|
9265
8864
|
].join("\n")
|
|
9266
8865
|
);
|
|
9267
8866
|
const loaded = await loadAllCommands(ctx);
|