test(compat): add v1 compatibility suite; docs: add V1_COMPATIBILITY.md
All checks were successful
技能自动化发布 / release (push) Successful in 9s
All checks were successful
技能自动化发布 / release (push) Successful in 9s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
将 `{baseDir}` 替换为技能根目录。所有命令通过 `python {baseDir}/scripts/main.py` 调用(工作目录可为技能根或 `scripts/`,与命令中的路径一致即可)。下文示例简写为 `python main.py`,表示在 `{baseDir}/scripts/` 下执行。
|
||||
|
||||
> **说明**:`scripts/cli/app.py` 内置的帮助字符串 `_USAGE` 主要覆盖 platform / account / credential / lease / open;实际路由还支持 **`account init-master-key` / `account export-credentials` / `account import-credentials`**(本文档以代码为准)。
|
||||
> **说明**:内置 `_USAGE`(无参数启动 CLI)已列出加密三类子命令;更完整的 JSON 约定仍以本文与源码为准。
|
||||
|
||||
|
||||
## stdout / JSON 约定(集成必读)
|
||||
|
||||
@@ -201,3 +202,7 @@ ACCOUNT_MANAGER_MASTER_KEY="<base64-44-chars>" python main.py account init-maste
|
||||
- **数据与路径**:库文件、profile、`master.key` 布局见 [RUNTIME.md](RUNTIME.md)。
|
||||
- **机器可读集成**:见 [INTEGRATION.md](INTEGRATION.md)。
|
||||
- **错误码**:见 [ERRORS.md](ERRORS.md)。
|
||||
|
||||
## 内置 `_USAGE`(阶段 F)
|
||||
|
||||
无参数运行 CLI(例如 `python scripts/main.py` / `python -m cli.app`,cwd=`scripts/`)打印的内置 `_USAGE` 已与 `main()` 路由对齐,包含 **`account init-master-key` / `account export-credentials` / `account import-credentials`**。面向外部仓库的契约摘要见 [V1_COMPATIBILITY.md](V1_COMPATIBILITY.md)。
|
||||
|
||||
43
references/V1_COMPATIBILITY.md
Normal file
43
references/V1_COMPATIBILITY.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# v1 调用方兼容承诺(account-manager v2)
|
||||
|
||||
account-manager v2 **不破坏**下列面向脚本 / 其它仓库(通过 CLI subprocess 集成)的契约。
|
||||
|
||||
## CLI 命令
|
||||
|
||||
下列命令的**子命令名与既有必填参数**保持不变(v2 仅 **扩展** 可选参数,不移除):
|
||||
|
||||
- `account pick-web` / `lease release` / `account mark-used` / `account mark-session` / `account mark-error`
|
||||
- `account get` / `account list` / `account add-web` / `account add-secret`
|
||||
- 兼容入口:`get`、`list-json`、`pick-web`、`add`、`delete`、`open`
|
||||
|
||||
加密相关:`account init-master-key` / `account export-credentials` / `account import-credentials`(**仅新增**,不影响旧调用方)。
|
||||
|
||||
内置 `--help` / 无参数打印的 `_USAGE` 文案见仓库 `scripts/cli/app.py`(阶段 F 已与路由对齐)。
|
||||
|
||||
## JSON 字段
|
||||
|
||||
- **`account pick-web`**:成功时为 **单层 JSON 对象**(**无** `success`/`data` 外层)。保留字段包括但不限于:`id`、`platform_key`、`environment`、`role`、`profile_dir`、`lease_token`、`lease_expires_at`(带 `--lease` 时)。v2 **允许追加**字段(如 `auth_strategy`、`session_persistent`、`device_fingerprint`),**不得改名或删除**上述 v1 字段。
|
||||
- **`account get`**:仍为单行账号 JSON(字段集合见 [SCHEMA.md](SCHEMA.md))。
|
||||
- **`lease release` / `account mark-*`**:成功时使用 `_ok_json`(`{"success": true, "data": {...}}`);失败为统一错误 JSON。
|
||||
|
||||
## 错误码
|
||||
|
||||
下列 **`error.code` 字面值**保持不变:
|
||||
|
||||
- `ERROR:NO_ACCOUNT`
|
||||
- `ERROR:LEASE_CONFLICT`
|
||||
- `ERROR:ACCOUNT_NOT_FOUND`
|
||||
- `ERROR:INVALID_PLATFORM`
|
||||
- `ERROR:ACCOUNT_DISABLED`
|
||||
- `ERROR:DB_ERROR`
|
||||
|
||||
v2 新增的 `ERR_*` 代码(如 `ERR_LEASE_INVALID`、`ERR_AUTH_STRATEGY_NOT_SUPPORTED`)仅出现在 **v2 新命令**路径,不应干扰上述 monitor 命令的失败解析。
|
||||
|
||||
## stderr
|
||||
|
||||
v2 可能在 stderr 打印迁移摘要、`[export] WARNING` 等。**调用方应只解析 stdout**,并与 monitor 一样优先取 **最后一行非空行** 做 `json.loads`(见集成测试 `tests/test_v1_compatibility.py`)。
|
||||
|
||||
## 集成验证
|
||||
|
||||
- 仓库内 **`tests/test_v1_compatibility.py`** 以 subprocess 覆盖典型调用序列与 stdout 形态。
|
||||
- 已知调用方:**`monitor-competitor-rates`**(物流仓库)—— 仅 CLI,无 Python import。
|
||||
Reference in New Issue
Block a user