@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/dist/sdk.d.ts CHANGED
@@ -1043,6 +1043,48 @@ interface DefaultRegistryOptions {
1043
1043
  /** 构建注册表;注册失败是编码错误,直接抛出 */
1044
1044
  declare function createDefaultRegistry(options?: DefaultRegistryOptions): CapabilityRegistry;
1045
1045
 
1046
+ interface ToolSkill {
1047
+ id: string;
1048
+ package: string;
1049
+ tool: string;
1050
+ version: string;
1051
+ path: string;
1052
+ contentHash: string;
1053
+ }
1054
+ declare function discoverToolSkills(options?: {
1055
+ resolvePackage?: (name: string) => string | undefined;
1056
+ }): {
1057
+ schemaVersion: number;
1058
+ skills: ToolSkill[];
1059
+ diagnostics: string[];
1060
+ };
1061
+ declare function readRuntimeSkill(command?: string, options?: {
1062
+ resolvePackage?: (name: string) => string | undefined;
1063
+ }): {
1064
+ file: string;
1065
+ content: string;
1066
+ sha256: string;
1067
+ id: string;
1068
+ package: string;
1069
+ tool: string;
1070
+ version: string;
1071
+ path: string;
1072
+ contentHash: string;
1073
+ };
1074
+ /** 外部宿主导出必须显式选择宿主和目录;不探测用户目录。 */
1075
+ declare function exportToolSkill(command: string | undefined, options: {
1076
+ host: string;
1077
+ directory: string;
1078
+ dryRun?: boolean;
1079
+ resolvePackage?: (name: string) => string | undefined;
1080
+ }): {
1081
+ skill: string;
1082
+ host: string;
1083
+ target: string;
1084
+ dryRun: boolean;
1085
+ files: number;
1086
+ };
1087
+
1046
1088
  /**
1047
1089
  * 轻量 JSON Schema 子集:既校验"schema 定义本身"(注册期),
1048
1090
  * 也校验"真实值"(运行期输入/输出)。零依赖,错误信息带 JSON Pointer。
@@ -1150,7 +1192,7 @@ declare function redactArgv(argv: string[]): RedactionResult<string[]>;
1150
1192
  declare const REDACTION_PLACEHOLDER = "***redacted***";
1151
1193
 
1152
1194
  /** 版本常量:与 package.json 保持一致(有测试保证) */
1153
- declare const VERSION = "0.5.2";
1195
+ declare const VERSION = "0.6.1";
1154
1196
 
1155
1197
  /** 已发布命令清单与真实注册表逐项对照,不从命名猜测覆盖。 */
1156
1198
  declare function capabilityCoverage(registry: CapabilityRegistry): {
@@ -1169,4 +1211,4 @@ declare function capabilityCoverage(registry: CapabilityRegistry): {
1169
1211
  }[];
1170
1212
  };
1171
1213
 
1172
- export { type AcceptanceStatus, type ArtProviderDeps, type Artifact, type CapabilityDescriptor, CapabilityError, type CapabilityExecutionContext, type CapabilityImplementation, type CapabilityProvider, type CapabilityRegistration, CapabilityRegistrationError, CapabilityRegistry, type CapabilityRunRequest, type CapabilityRunResult, type CapabilityRuntimeDeps, type CapabilitySummary, type DefaultRegistryOptions, EXECUTION_HANDLE_VERSION, type ErrorCategory, type Evidence, type ExecutionHandle, type ExecutionHandleSeed, type ExecutionLifecycle, type ExecutionStatus, FIGMA_PROVIDER_ID, FIGMA_PROVIDER_VERSION, type FigmaBinding, type FigmaProviderDeps, type HandleVerification, type ImplementationOutcome, type InitProjectConfigResult, JSON_TYPES, type JsonSchema, type JsonSchemaArray, type JsonSchemaBoolean, type JsonSchemaNull, type JsonSchemaNumber, type JsonSchemaObject, type JsonSchemaString, type JsonSchemaType, type LoadProjectConfigResult, type LogRef, NodeProcessExecutor, OPERATIONS_RELATIVE, OperationExistsError, type OperationLogger, OperationStore, type OperationSummary, PROJECT_CLI_CONFIG_RELATIVE, PathSafetyError, type PreconditionChecker, type PreconditionDeclaration, type PreconditionOutcome, type ProcessExecutor, type ProcessInvocation, type ProcessOutcome, type ProjectBindingInfo, type ProjectCliConfig, type ProjectInspection, type ProjectRoot, type ProviderBindingContract, type ProviderBindingResolution, type ProviderBindingResolutionError, type ProviderBindingResolutionOk, type ProviderBindingResolveInput, type ProviderDefaultBinding, type ProviderInfo, type ProviderPathField, type ProviderSet, type ProviderState, type ProviderStatus, REDACTION_PLACEHOLDER, type ResolvedProviderBinding, type ResourceAuthorizationDecision, type ResourceAuthorizationRequest, type ResourceAuthorizer, type ResourceKind, type ResourceMode, type ResourceRequirement, type RetrySemantics, type SideEffectDeclaration, type SideEffectKind, type SideEffectRecord, type StructuredError, UNITY_PROVIDER_ID, UNITY_PROVIDER_VERSION, type UnityBinding, type UnityProviderDeps, type UnityTestMode, VANT_PROJECT_CONFIG_RELATIVE, VERSION, artBindingContract, buildDoctorArgv, buildExecArgv, buildExecutionHandle, canonicalize, capabilityCoverage, createArtProvider, createDefaultRegistry, createFigmaProvider, createUnityProvider, executionFromProcess, exitCodeForResult, figmaBindingContract, formatResultJson, generateOperationId, initProjectConfig, inspectProject, loadProjectConfig, redactArgv, redactSecrets, renderProjectConfig, resolveBindings, resolveInsideProject, resolveProjectRoot, runCapability, splitSafeRelative, structuredError, toProviderSet, toStructuredError, unityBindingContract, validateCapability, validateOperationId, validateProjectCliConfig, validateProvider, validateSchemaDefinition, validateValue, verifyExecutionHandle };
1214
+ export { type AcceptanceStatus, type ArtProviderDeps, type Artifact, type CapabilityDescriptor, CapabilityError, type CapabilityExecutionContext, type CapabilityImplementation, type CapabilityProvider, type CapabilityRegistration, CapabilityRegistrationError, CapabilityRegistry, type CapabilityRunRequest, type CapabilityRunResult, type CapabilityRuntimeDeps, type CapabilitySummary, type DefaultRegistryOptions, EXECUTION_HANDLE_VERSION, type ErrorCategory, type Evidence, type ExecutionHandle, type ExecutionHandleSeed, type ExecutionLifecycle, type ExecutionStatus, FIGMA_PROVIDER_ID, FIGMA_PROVIDER_VERSION, type FigmaBinding, type FigmaProviderDeps, type HandleVerification, type ImplementationOutcome, type InitProjectConfigResult, JSON_TYPES, type JsonSchema, type JsonSchemaArray, type JsonSchemaBoolean, type JsonSchemaNull, type JsonSchemaNumber, type JsonSchemaObject, type JsonSchemaString, type JsonSchemaType, type LoadProjectConfigResult, type LogRef, NodeProcessExecutor, OPERATIONS_RELATIVE, OperationExistsError, type OperationLogger, OperationStore, type OperationSummary, PROJECT_CLI_CONFIG_RELATIVE, PathSafetyError, type PreconditionChecker, type PreconditionDeclaration, type PreconditionOutcome, type ProcessExecutor, type ProcessInvocation, type ProcessOutcome, type ProjectBindingInfo, type ProjectCliConfig, type ProjectInspection, type ProjectRoot, type ProviderBindingContract, type ProviderBindingResolution, type ProviderBindingResolutionError, type ProviderBindingResolutionOk, type ProviderBindingResolveInput, type ProviderDefaultBinding, type ProviderInfo, type ProviderPathField, type ProviderSet, type ProviderState, type ProviderStatus, REDACTION_PLACEHOLDER, type ResolvedProviderBinding, type ResourceAuthorizationDecision, type ResourceAuthorizationRequest, type ResourceAuthorizer, type ResourceKind, type ResourceMode, type ResourceRequirement, type RetrySemantics, type SideEffectDeclaration, type SideEffectKind, type SideEffectRecord, type StructuredError, type ToolSkill, UNITY_PROVIDER_ID, UNITY_PROVIDER_VERSION, type UnityBinding, type UnityProviderDeps, type UnityTestMode, VANT_PROJECT_CONFIG_RELATIVE, VERSION, artBindingContract, buildDoctorArgv, buildExecArgv, buildExecutionHandle, canonicalize, capabilityCoverage, createArtProvider, createDefaultRegistry, createFigmaProvider, createUnityProvider, discoverToolSkills, executionFromProcess, exitCodeForResult, exportToolSkill, figmaBindingContract, formatResultJson, generateOperationId, initProjectConfig, inspectProject, loadProjectConfig, readRuntimeSkill, redactArgv, redactSecrets, renderProjectConfig, resolveBindings, resolveInsideProject, resolveProjectRoot, runCapability, splitSafeRelative, structuredError, toProviderSet, toStructuredError, unityBindingContract, validateCapability, validateOperationId, validateProjectCliConfig, validateProvider, validateSchemaDefinition, validateValue, verifyExecutionHandle };
package/dist/sdk.mjs CHANGED
@@ -2855,6 +2855,20 @@ function validateManifest(input) {
2855
2855
  }
2856
2856
  });
2857
2857
  }
2858
+ if (m.skills !== void 0) {
2859
+ if (!Array.isArray(m.skills)) errors.push("skills \u5FC5\u987B\u662F\u6570\u7EC4");
2860
+ else {
2861
+ const seen = /* @__PURE__ */ new Set();
2862
+ m.skills.forEach((skill, i) => {
2863
+ if (!isPlainObject5(skill) || typeof skill.id !== "string" || !COMMAND_NAME_RE.test(skill.id) || typeof skill.path !== "string" || !/^skills\/[a-z0-9-]+\/SKILL\.md$/.test(skill.path)) {
2864
+ errors.push(`skills[${i}] \u6807\u8BC6\u6216\u5165\u53E3\u8DEF\u5F84\u65E0\u6548`);
2865
+ return;
2866
+ }
2867
+ if (seen.has(skill.id)) errors.push(`skills[${i}] \u6807\u8BC6\u91CD\u590D`);
2868
+ seen.add(skill.id);
2869
+ });
2870
+ }
2871
+ }
2858
2872
  const agent = m.agent;
2859
2873
  if (!isPlainObject5(agent)) {
2860
2874
  errors.push("agent \u5FC5\u987B\u662F\u5BF9\u8C61");
@@ -4171,9 +4185,9 @@ var FAIL_COUNT_PATHS = [
4171
4185
  ];
4172
4186
  function extractFailCount(payload) {
4173
4187
  if (!isPlainObject7(payload)) return { count: null, source: null };
4174
- for (const path11 of FAIL_COUNT_PATHS) {
4188
+ for (const path12 of FAIL_COUNT_PATHS) {
4175
4189
  let current = payload;
4176
- for (const segment of path11) {
4190
+ for (const segment of path12) {
4177
4191
  if (!isPlainObject7(current)) {
4178
4192
  current = void 0;
4179
4193
  break;
@@ -4181,16 +4195,16 @@ function extractFailCount(payload) {
4181
4195
  current = current[segment];
4182
4196
  }
4183
4197
  if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
4184
- return { count: current, source: path11.join(".") };
4198
+ return { count: current, source: path12.join(".") };
4185
4199
  }
4186
4200
  }
4187
4201
  return { count: null, source: null };
4188
4202
  }
4189
4203
  function extractTotal(payload) {
4190
4204
  if (!isPlainObject7(payload)) return { total: null, source: null };
4191
- for (const path11 of [["summary", "total"]]) {
4205
+ for (const path12 of [["summary", "total"]]) {
4192
4206
  let current = payload;
4193
- for (const segment of path11) {
4207
+ for (const segment of path12) {
4194
4208
  if (!isPlainObject7(current)) {
4195
4209
  current = void 0;
4196
4210
  break;
@@ -4198,7 +4212,7 @@ function extractTotal(payload) {
4198
4212
  current = current[segment];
4199
4213
  }
4200
4214
  if (typeof current === "number" && Number.isSafeInteger(current) && current >= 0) {
4201
- return { total: current, source: path11.join(".") };
4215
+ return { total: current, source: path12.join(".") };
4202
4216
  }
4203
4217
  }
4204
4218
  return { total: null, source: null };
@@ -7413,8 +7427,106 @@ function createDefaultRegistry(options = {}) {
7413
7427
  return registry;
7414
7428
  }
7415
7429
 
7430
+ // src/core/skills.ts
7431
+ import fs11 from "fs";
7432
+ import path11 from "path";
7433
+ import { createHash as createHash5 } from "crypto";
7434
+ function discoverToolSkills(options = {}) {
7435
+ const resolvePackage = options.resolvePackage ?? defaultResolvePackage;
7436
+ const skills = [], diagnostics = [];
7437
+ for (const spec of [{ package: "@kevlns/v-cli", command: "v-cli" }, ...OFFICIAL_PLUGINS]) {
7438
+ const pkgFile = resolvePackage(spec.package);
7439
+ if (!pkgFile) continue;
7440
+ const root2 = path11.dirname(pkgFile), file2 = path11.join(root2, "v-cli.plugin.json");
7441
+ if (!fs11.existsSync(file2)) continue;
7442
+ const pkg = JSON.parse(fs11.readFileSync(pkgFile, "utf8"));
7443
+ const manifest = JSON.parse(fs11.readFileSync(file2, "utf8"));
7444
+ if (pkg.name !== spec.package || manifest.package !== spec.package || manifest.command !== spec.command)
7445
+ throw new Error("\u5DE5\u5177\u6280\u80FD\u58F0\u660E\u8EAB\u4EFD\u4E0D\u4E00\u81F4\uFF1A" + spec.package);
7446
+ if (manifest.skills !== void 0 && !Array.isArray(manifest.skills)) throw new Error("\u6280\u80FD\u58F0\u660E\u65E0\u6548");
7447
+ for (const item of manifest.skills ?? []) {
7448
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(item.id) || item.path !== `skills/${item.id}/SKILL.md`)
7449
+ throw new Error("\u6280\u80FD\u58F0\u660E\u65E0\u6548");
7450
+ const entry = path11.resolve(root2, item.path), actual = fs11.realpathSync(entry), realRoot = fs11.realpathSync(root2);
7451
+ const relative = path11.relative(realRoot, actual);
7452
+ if (path11.isAbsolute(relative) || relative === ".." || relative.startsWith(".." + path11.sep)) throw new Error("\u6280\u80FD\u58F0\u660E\u8D8A\u754C");
7453
+ if (skills.some((s) => s.id === item.id)) throw new Error("\u6280\u80FD\u6807\u8BC6\u91CD\u590D\uFF1A" + item.id);
7454
+ skills.push({
7455
+ id: item.id,
7456
+ package: pkg.name,
7457
+ tool: spec.command,
7458
+ version: pkg.version,
7459
+ path: actual,
7460
+ contentHash: skillBundleHash(path11.dirname(actual))
7461
+ });
7462
+ }
7463
+ if (manifest.skills === void 0) diagnostics.push(spec.command + " \u672A\u58F0\u660E\u6280\u80FD");
7464
+ }
7465
+ return { schemaVersion: 1, skills, diagnostics };
7466
+ }
7467
+ function readRuntimeSkill(command, options = {}) {
7468
+ const tool = command ?? "v-cli";
7469
+ const result4 = discoverToolSkills(options), skill = result4.skills.find((s) => s.tool === tool);
7470
+ if (!skill) throw new Error("\u5DE5\u5177\u672A\u58F0\u660E\u8FD0\u884C\u6280\u80FD\uFF1A" + tool);
7471
+ return { ...skill, file: skill.path, content: fs11.readFileSync(skill.path, "utf8"), sha256: createHash5("sha256").update(fs11.readFileSync(skill.path)).digest("hex") };
7472
+ }
7473
+ function skillBundleHash(root2) {
7474
+ const files = [];
7475
+ const walk = (directory, prefix = "") => {
7476
+ for (const entry of fs11.readdirSync(directory, { withFileTypes: true })) {
7477
+ if (entry.name === "__pycache__" || entry.name.endsWith(".pyc")) continue;
7478
+ if (entry.isSymbolicLink()) throw new Error("\u6280\u80FD\u8D44\u6E90\u4E0D\u80FD\u5305\u542B\u94FE\u63A5");
7479
+ const relative = prefix + entry.name, full = path11.join(directory, entry.name);
7480
+ if (entry.isDirectory()) walk(full, relative + "/");
7481
+ else if (entry.isFile()) files.push({ path: relative, hash: createHash5("sha256").update(fs11.readFileSync(full)).digest("hex") });
7482
+ }
7483
+ };
7484
+ walk(root2);
7485
+ files.sort((a, b) => a.path < b.path ? -1 : a.path > b.path ? 1 : 0);
7486
+ return createHash5("sha256").update(JSON.stringify(files)).digest("hex");
7487
+ }
7488
+ function exportToolSkill(command, options) {
7489
+ if (!["codex", "claude"].includes(options.host) || !options.directory)
7490
+ throw new Error("\u5BFC\u51FA\u5FC5\u987B\u663E\u5F0F\u9009\u62E9 host \u548C directory");
7491
+ const skill = readRuntimeSkill(command, options);
7492
+ const base = path11.resolve(options.directory);
7493
+ if (!fs11.lstatSync(base).isDirectory() || fs11.lstatSync(base).isSymbolicLink())
7494
+ throw new Error("\u5BFC\u51FA\u76EE\u5F55\u5FC5\u987B\u662F\u5DF2\u6709\u666E\u901A\u76EE\u5F55");
7495
+ const root2 = path11.resolve(path11.dirname(skill.path), "../.."), target = path11.join(base, skill.id);
7496
+ const planned = [];
7497
+ const check = (file2, directory) => {
7498
+ let stat;
7499
+ try {
7500
+ stat = fs11.lstatSync(file2);
7501
+ } catch (e) {
7502
+ if (e.code !== "ENOENT") throw e;
7503
+ }
7504
+ if (stat && (stat.isSymbolicLink() || stat.isDirectory() !== directory)) throw new Error("\u5BFC\u51FA\u76EE\u6807\u7C7B\u578B\u51B2\u7A81");
7505
+ };
7506
+ check(target, true);
7507
+ const walk = (source, dest) => {
7508
+ for (const entry of fs11.readdirSync(source, { withFileTypes: true })) {
7509
+ if (entry.name === "__pycache__" || entry.name.endsWith(".pyc")) continue;
7510
+ if (entry.isSymbolicLink()) throw new Error("\u6280\u80FD\u5BFC\u51FA\u4E0D\u80FD\u5305\u542B\u94FE\u63A5");
7511
+ const from = path11.join(source, entry.name), to = path11.join(dest, entry.name);
7512
+ check(to, entry.isDirectory());
7513
+ if (entry.isDirectory()) walk(from, to);
7514
+ else if (entry.isFile()) planned.push({ path: to, bytes: fs11.readFileSync(from) });
7515
+ else throw new Error("\u6280\u80FD\u8D44\u6E90\u7C7B\u578B\u4E0D\u53D7\u652F\u6301");
7516
+ }
7517
+ };
7518
+ walk(path11.dirname(skill.path), target);
7519
+ const adapter = path11.join(root2, "adapters", options.host);
7520
+ if (fs11.existsSync(adapter)) walk(adapter, target);
7521
+ if (!options.dryRun) for (const file2 of planned) {
7522
+ fs11.mkdirSync(path11.dirname(file2.path), { recursive: true });
7523
+ fs11.writeFileSync(file2.path, file2.bytes);
7524
+ }
7525
+ return { skill: skill.id, host: options.host, target, dryRun: !!options.dryRun, files: planned.length };
7526
+ }
7527
+
7416
7528
  // src/version.ts
7417
- var VERSION = "0.5.2";
7529
+ var VERSION = "0.6.1";
7418
7530
 
7419
7531
  // src/capability-coverage.ts
7420
7532
  function capabilityCoverage(registry) {
@@ -7476,14 +7588,17 @@ export {
7476
7588
  createDefaultRegistry,
7477
7589
  createFigmaProvider,
7478
7590
  createUnityProvider,
7591
+ discoverToolSkills,
7479
7592
  executionFromProcess,
7480
7593
  exitCodeForResult,
7594
+ exportToolSkill,
7481
7595
  figmaBindingContract,
7482
7596
  formatResultJson,
7483
7597
  generateOperationId,
7484
7598
  initProjectConfig,
7485
7599
  inspectProject,
7486
7600
  loadProjectConfig,
7601
+ readRuntimeSkill,
7487
7602
  redactArgv,
7488
7603
  redactSecrets,
7489
7604
  renderProjectConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevlns/v-cli",
3
- "version": "0.5.2",
3
+ "version": "0.6.1",
4
4
  "description": "提供工具发现、插件路由、工程绑定、结构化能力执行和操作证据管理。",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,7 +19,9 @@
19
19
  "schemas/",
20
20
  "skills/",
21
21
  "AGENTS.md",
22
- "docs/"
22
+ "docs/",
23
+ "v-cli.plugin.json",
24
+ "adapters/"
23
25
  ],
24
26
  "scripts": {
25
27
  "build": "tsup",
@@ -56,7 +58,7 @@
56
58
  "toolbox"
57
59
  ],
58
60
  "dependencies": {
59
- "@kevlns/art-workshop": "0.4.2",
61
+ "@kevlns/art-workshop": "0.5.1",
60
62
  "@kevlns/figma-to-uprefab": "0.1.4",
61
63
  "@kevlns/ship-cli": "0.1.2",
62
64
  "@kevlns/u-cli-mod": "0.3.1",