@kevlns/v-cli 0.2.18 → 0.3.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/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@kevlns/v-cli",
3
- "version": "0.2.18",
4
- "description": "kevlns 的个人工具箱 CLI(插件化架构,内置 + 本地插件)+ doctor/plugin/ts 命令",
3
+ "version": "0.3.1",
4
+ "description": "kevlns 的个人工具箱 CLI(插件化架构 + 结构化 capability 注册/执行基座)+ doctor/plugin/ts/agent/project/capability 命令",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "v-cli": "dist/cli.mjs"
8
8
  },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/sdk.d.ts",
12
+ "import": "./dist/sdk.mjs"
13
+ },
14
+ "./package.json": "./package.json"
15
+ },
16
+ "types": "./dist/sdk.d.ts",
9
17
  "files": [
10
18
  "dist/",
11
19
  "schemas/",
@@ -49,8 +57,8 @@
49
57
  "@kevlns/art-workshop": "0.2.1",
50
58
  "@kevlns/figma-to-uprefab": "0.1.2",
51
59
  "@kevlns/ship-cli": "0.1.1",
52
- "@kevlns/u-cli-mod": "0.2.4",
53
- "@kevlns/xlmerge": "2.0.1",
60
+ "@kevlns/u-cli-mod": "^0.3.0",
61
+ "@kevlns/xlmerge": "2.0.2",
54
62
  "commander": "^12.1.0"
55
63
  },
56
64
  "devDependencies": {
@@ -12,11 +12,53 @@ description: >
12
12
 
13
13
  - `@kevlns/v-cli` 是 npm 全局安装的个人工具箱 CLI,插件化架构;环境要求 Node.js >= 20(`unity` 与 `figma` 插件仅 win32,其他平台 v-cli 拒绝路由)。
14
14
  - 命令分三类:
15
- - **builtin**(内置):`doctor`(环境体检)、`plugin list/path`(插件管理)、`ts`(时间戳互转)、`agent index/describe/docs/init`(agent 引导)。
15
+ - **builtin**(内置):`doctor`(环境体检)、`plugin list/path`(插件管理)、`ts`(时间戳互转)、`agent index/describe/docs/init`(agent 引导)、`project init/inspect`(工程绑定)、`capability list/describe/run`(结构化能力执行)。
16
16
  - **local**:`~/.v-cli/commands/` 下的本地插件。
17
17
  - **official**(官方插件,经 v-cli 路由):`xlmerge`、`unity`、`figma`、`ship`、`art`。
18
18
  - **本文件不写死任何版本号**:v-cli 本体与官方插件的实际版本、命令集合、参数一律以 `v-cli doctor` 与 `v-cli agent index --json` 的实时输出为准。
19
19
 
20
+ ## 工程执行基座:project / capability(结构化执行与验收分离)
21
+
22
+ v-cli 是**注册和执行基座**:capability 具有稳定 id、版本、输入/输出 schema、前置条件、声明的副作用、资源需求与重试语义。
23
+ Vant 组织层负责任务调度/持久化任务/资源租约;v-cli 只做注册与执行,并在 `<工程根>/.vant/state/operations/<operationId>/` 留本地记录。
24
+
25
+ ### 命令
26
+
27
+ - `v-cli project init [--project <目录>] [--binding <providerId>=<JSON>]… [--json]`
28
+ — 写入 `.vant/config/v-cli.json`(通用外壳:schemaVersion + 按 Provider 分组的 bindings;只放 CLI 能力/适配器绑定)。为有默认绑定的 Provider 生成默认段,`--binding` 可完整覆盖某段(例:`--binding unity='{"projectDir":"Client","editorVersion":"2022.3.59f1c1"}'`)。幂等补全(已有段不动);不修改、不读 Vant 的 `.vant/config/project.json`(角色/workflow 归 Vant)。各 Provider 绑定段的字段契约用 `v-cli capability describe <id> --json` 查看(provider.binding)。
29
+ - `v-cli project inspect [--project <目录>] [--json]` — 只读检查配置、绑定目录、`.vant` 布局与 provider 发现状态。
30
+ - `v-cli capability list [--provider <id>] [--json]` — 列出 capability(只读,不执行工具)。
31
+ - `v-cli capability describe <id> [--json]` — 单能力完整契约;执行前先读它,不猜参数。
32
+ - `v-cli capability run <id> [--project <目录>] [--input <json> | --input-file <路径>] [--set k=v]… [--operation-id <id>] [--task-id <id>] [--run-id <id>] [--no-persist] [--json]`
33
+ — 异步触发(unity.compile / unity.test-start)在结果 `handle` 中返回执行句柄(backendTaskId=后端 runId,需 u-cli-mod ≥0.3.0 且工程适配包 patchVersion 3)。
34
+ — Figma 离线校验:`figma.contract`(staging 契约,roots>0 才通过)/ `figma.doctor`(只读诊断;token FAIL 是离线预期)。绑定 `bindings.figma {projectDir, stagingRoot}`;v-cli 自动注入无令牌的托管配置,全程无网络、不碰凭据。
35
+ 按句柄关联操作:`unity.compile-query` / `unity.test-query` / `unity.test-cancel-run`,入参 `--input '{"handle": <结果里的 handle 对象>}'`;关联失效(被顶替/记录不存在)明确 failed(后端 unknown_run),绝不采信其他任务的记录。
36
+
37
+ ### 硬性规则
38
+
39
+ 1. **验收与退出码**:进程退出码 0 不等于业务通过。`execution.status`(succeeded/failed/cancelled/unknown)与 `acceptance.status`(passed/failed/not-run)分开读。
40
+ `capability run` 退出码:`0` 验收 passed;`1` 执行或验收失败;`2` 未执行(入参/配置/前置条件/资源授权);`3` 已执行但验收 not-run;`4` 已确认取消;`5` 结果未知。
41
+ 2. **退出码 3 = 未通过**:`acceptance.pending=true` 时按 `followUp` 轮询对应状态能力,不得把"已启动/已触发"报告为成功。
42
+ 3. **异步能力**:`unity.compile`/`unity.test-start` 只报告 accepted;完成判定用 `unity.compile-status`/`unity.test-status`。
43
+ 4. **测试通过判据**:只有 `test_status=completed` **且失败数 0 且存在有效报告**才算 passed;缺字段/未知取值一律不通过。
44
+ 5. **取消**:只有确认(响应字段或 `test_status` 探测)才认为取消生效;未确认不得报告已取消。
45
+ 6. **工程根**:一律 `--project` 显式锚定;能力输入不接受 `projectPath` 覆盖(用 `--set projectPath=…` 会因 schema `additionalProperties:false` 直接失败)。
46
+ 7. **配置缺失**:报 `project-config-missing` 时先 `v-cli project init --project <工程根>`;不要手写配置里的角色/workflow(会被拒绝)。
47
+ 8. **operationId**:默认自动生成;显式传入时同一 id 只能执行一次(已存在直接拒绝,绝不覆盖)。`--no-persist` 仅用于测试/SDK 探测,会失去本地证据记录。
48
+ 9. Unity capability 走受控 argv(不拼 shell);exec 前默认自动 doctor 就绪核对(不得跳过)。真实 Unity 协议字段以 `capability describe` 与执行结果中的 `output`/`evidence` 为准,不要自行发明字段。
49
+
50
+ ### Unity capability 一览(先 describe 再 run)
51
+
52
+ | id | 用途 | 验收 |
53
+ |---|---|---|
54
+ | `unity.doctor` | 只读体检(路由/CLI/适配包) | routeSupported+cli.state=valid+pipeline.installed+pipeline.state=current |
55
+ | `unity.editor-status` | Editor/Pipeline 连接状态 | `status="ready"` |
56
+ | `unity.compile` | 触发重编译(异步) | 一律 not-run(pending) → 轮询 `unity.compile-status` |
57
+ | `unity.compile-status` | 重编译状态 | completed/up_to_date → passed;进行中 → pending;其余不通过 |
58
+ | `unity.test-start` | 启动测试(固定 `--async_tests`) | 一律 not-run(pending) → 轮询 `unity.test-status` |
59
+ | `unity.test-status` | 测试状态与失败数 | completed + 失败数 0 + 有效报告 → passed |
60
+ | `unity.test-cancel` | 请求取消测试 | 需确认(响应或探测)才 passed |
61
+
20
62
  ## 能力发现协议(核心规则,必须遵守)
21
63
 
22
64
  **一切能力、参数、用法以 v-cli 自己的 agent 命令输出为准,严禁自行翻查 npm 安装目录、源码或 README 来猜测用法。**