easymagic 0.4.1 → 0.5.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/AI_USAGE.md CHANGED
@@ -1,27 +1,36 @@
1
1
  # 给 AI 助手的 EasyMagic CLI 使用指南
2
2
 
3
- 目标:用户在浏览器确认一次授权后,由 CLI 创建适合目标客户端的推理密钥并写入配置。AI 不需要复制 PAT、查看完整推理密钥或手工拼接客户端配置文件。
3
+ 目标:用户在浏览器确认一次授权后,由 CLI 创建适合目标客户端的推理密钥并写入配置。AI 使用明确的 `easymagic ai …` 模式,不进入手动菜单,不需要复制 PAT、查看完整推理密钥或手工拼接客户端配置文件。
4
+
5
+ ## 模式约定
6
+
7
+ - `easymagic ai COMMAND …` 与 `easymagic --ai COMMAND …` 等价,默认输出 JSON,永不启动手动菜单或浏览器。
8
+ - `ai login`、`ai onboard` 默认发起或检查授权后立即返回;显示给用户的链接和配对码是安全结果字段。只有显式 `--wait` 才阻塞等待。
9
+ - `easymagic` 在交互终端中打开手动控制台;AI 不应执行菜单按键模拟来代替命令调用。
10
+ - 标准输入/输出不是 TTY 时,无参数入口只显示模式说明,不会等待用户输入。模式由命令明确选择,不猜测调用者是否是 AI。
11
+ - `--json` 兼容旧脚本,但只控制输出;它不等同于 AI 模式的浏览器与等待策略。保留显式 `--start --no-browser --json` 的旧调用仍可使用。
4
12
 
5
13
  ## 1. 先读当前安装版本的接口
6
14
 
7
15
  ```sh
8
16
  easymagic --version
9
- easymagic guide ai --json
10
- easymagic schema --json
11
- easymagic schema onboard --json
12
- easymagic setup list --json
17
+ easymagic ai
18
+ easymagic ai guide ai
19
+ easymagic ai schema
20
+ easymagic ai schema onboard
21
+ easymagic ai setup list
13
22
  ```
14
23
 
15
- `guide` 返回说明文档,`schema` 从当前 CLI 的实际命令树生成参数说明。优先依据当前输出执行,避免把其他版本或相似工具的参数套进来。完整机器交互规则见 [CLI_CONTRACT.md](CLI_CONTRACT.md),18 种客户端的原生配置边界见 [AGENT_SUPPORT.md](AGENT_SUPPORT.md)。
24
+ `easymagic ai` 返回模式说明、命令清单和推荐流程。`guide` 返回说明文档,`schema` 从当前 CLI 的实际命令树生成参数说明。优先依据当前输出执行,避免把其他版本或相似工具的参数套进来。完整机器交互规则见 [CLI_CONTRACT.md](CLI_CONTRACT.md),18 种客户端的原生配置边界见 [AGENT_SUPPORT.md](AGENT_SUPPORT.md)。
16
25
 
17
- 安装包需要 Node.js 22 或更新版本。可通过 `npm install -g easymagic@0.4.1` 安装指定版本,或用 `npx --yes easymagic@0.4.1` 执行命令。仅有源码时需要先构建;调用前用 `easymagic --version` 确认实际版本。浏览器授权要求目标网站已部署配套 device-login API 和授权页面,见 [BACKEND_INTEGRATION.md](BACKEND_INTEGRATION.md)。旧网站仍可由用户提供 PAT,通过 `login --token-stdin` 登录;不要让用户把 PAT 发在聊天里。
26
+ 安装包需要 Node.js 22 或更新版本。可通过 `npm install -g easymagic` 安装,或用 `npx --yes easymagic` 执行命令。仅有源码时需要先构建;调用前用 `easymagic --version` 确认实际版本;明确的 `ai` 模式从 0.5.0 开始提供,旧版本继续使用 `--json`。浏览器授权要求目标网站已部署配套 device-login API 和授权页面,见 [BACKEND_INTEGRATION.md](BACKEND_INTEGRATION.md)。旧网站仍可由用户提供 PAT,通过 `login --token-stdin` 登录;不要让用户把 PAT 发在聊天里。
18
27
 
19
28
  ## 2. 推荐:一次发起,浏览器确认,恢复完成
20
29
 
21
- 以下命令以 Claude Code 为例。把 `claude-code` 换成 `setup list --json` 返回的目标 ID,例如 `codex`、`opencode` 或 `pi`。
30
+ 以下命令以 Claude Code 为例。把 `claude-code` 换成 `easymagic ai setup list` 返回的目标 ID,例如 `codex`、`opencode` 或 `pi`。
22
31
 
23
32
  ```sh
24
- easymagic onboard claude-code --start --no-browser --json
33
+ easymagic ai onboard claude-code --start --no-browser
25
34
  ```
26
35
 
27
36
  解析返回的 `status`,保留 `onboarding_id` 和 `next_command`。若为 `authorization_pending`,把返回的授权网址和用户校验码展示给用户,请其在自己的浏览器登录并确认;不要要求用户提供密码、验证码、Cookie、PAT 或完整 API key。
@@ -29,13 +38,13 @@ easymagic onboard claude-code --start --no-browser --json
29
38
  用户确认后,执行返回的 `next_command`。也可以使用同一编号:
30
39
 
31
40
  ```sh
32
- easymagic onboard --resume ONBOARDING_ID --json
41
+ easymagic ai onboard --resume ONBOARDING_ID
33
42
  ```
34
43
 
35
44
  不需要持续占用进程时,每次恢复只检查一次状态;确需等待时使用:
36
45
 
37
46
  ```sh
38
- easymagic onboard --resume ONBOARDING_ID --wait --json
47
+ easymagic ai onboard --resume ONBOARDING_ID --wait
39
48
  ```
40
49
 
41
50
  只能使用本次输出的 `ONBOARDING_ID`,不要把浏览器校验码、登录 `flow_id` 和配置操作编号混用。仍在等待授权时保留编号,稍后继续同一流程。完成后的恢复返回已保存的结果,不应创建第二把密钥。
@@ -48,7 +57,7 @@ easymagic onboard --resume ONBOARDING_ID --wait --json
48
57
  easymagic onboard claude-code
49
58
  ```
50
59
 
51
- 这条交互路径会发起浏览器授权、等待确认,然后继续配置。AI 工具调用优先使用 `--start --json` / `--resume`,避免长时间阻塞。
60
+ 人也可以直接运行 `easymagic`,在菜单中完成相同流程。上述直接子命令会发起浏览器授权、等待确认,然后继续配置。AI 工具调用优先使用 `easymagic ai onboard …` / `--resume`,避免长时间阻塞。
52
61
 
53
62
  ## 3. 根据真实状态继续,不猜测成功
54
63
 
@@ -68,17 +77,17 @@ easymagic onboard claude-code
68
77
  补齐所缺参数后继续原流程,例如:
69
78
 
70
79
  ```sh
71
- easymagic onboard --resume ONBOARDING_ID --retry --context-window YOUR_MODEL_CONTEXT --json
80
+ easymagic ai onboard --resume ONBOARDING_ID --retry --context-window YOUR_MODEL_CONTEXT
72
81
  ```
73
82
 
74
83
  ## 4. 已登录账号的操作
75
84
 
76
85
  ```sh
77
- easymagic profile list --json
78
- easymagic --profile work whoami --json
79
- easymagic --profile work groups --json
80
- easymagic --profile work models --json
81
- easymagic --profile work onboard codex --start --json
86
+ easymagic ai profile list
87
+ easymagic ai --profile work whoami
88
+ easymagic ai --profile work groups
89
+ easymagic ai --profile work models
90
+ easymagic ai --profile work onboard codex --start
82
91
  ```
83
92
 
84
93
  账号 profile、站点和目标客户端是三件不同的事。恢复操作使用原始站点和账号,不要为了消除权限错误换 profile 重放。`logout` 只删除选中的本地登录;不会吊销服务端 PAT,也不会清除 shell 中的 `EASYMAGIC_TOKEN`。
@@ -86,9 +95,9 @@ easymagic --profile work onboard codex --start --json
86
95
  若用户指定复用已有推理密钥,可走手动配置入口;该入口不会自动创建新密钥:
87
96
 
88
97
  ```sh
89
- easymagic keys list --all --json
90
- easymagic setup codex --key-id KEY_ID --dry-run --json
91
- easymagic setup codex --key-id KEY_ID --json
98
+ easymagic ai keys list --all
99
+ easymagic ai setup codex --key-id KEY_ID --dry-run
100
+ easymagic ai setup codex --key-id KEY_ID
92
101
  ```
93
102
 
94
103
  `KEY_ID` 使用列表返回的数字 ID。默认列表与详情隐藏完整 key;AI 配置流程不需要 `keys show --reveal`。
@@ -98,21 +107,21 @@ easymagic setup codex --key-id KEY_ID --json
98
107
  默认诊断可检查配置、账户、模型可见性和协议匹配;它不发送推理生成请求:
99
108
 
100
109
  ```sh
101
- easymagic doctor --client codex --json
102
- easymagic setup history --json
103
- easymagic setup restore RESTORE_ID --dry-run --json
110
+ easymagic ai doctor --client codex
111
+ easymagic ai setup history
112
+ easymagic ai setup restore RESTORE_ID --dry-run
104
113
  ```
105
114
 
106
115
  用户要求实际验证推理时才加 `--check`,它可能消耗额度:
107
116
 
108
117
  ```sh
109
- easymagic doctor --client codex --check --json
118
+ easymagic ai doctor --client codex --check
110
119
  ```
111
120
 
112
121
  确认需要恢复后执行:
113
122
 
114
123
  ```sh
115
- easymagic setup restore RESTORE_ID --yes --json
124
+ easymagic ai setup restore RESTORE_ID --yes
116
125
  ```
117
126
 
118
127
  恢复会检测配置后的人工修改;默认拒绝覆盖这些修改。不要自动追加 `--force`。配置恢复也不等于删除服务端密钥或撤销已产生的费用。
@@ -122,8 +131,8 @@ easymagic setup restore RESTORE_ID --yes --json
122
131
  创建密钥后连接中断,不能据此断言“没有创建成功”。从结果或错误提示中保留 `operation_id`,先检查和回查:
123
132
 
124
133
  ```sh
125
- easymagic operations show OPERATION_ID --json
126
- easymagic operations reconcile OPERATION_ID --json
134
+ easymagic ai operations show OPERATION_ID
135
+ easymagic ai operations reconcile OPERATION_ID
127
136
  ```
128
137
 
129
138
  | 操作条目状态 | 处理方式 |
@@ -138,9 +147,9 @@ easymagic operations reconcile OPERATION_ID --json
138
147
  ## 7. 多客户端和批量操作
139
148
 
140
149
  ```sh
141
- easymagic setup all --clients claude-code,codex,opencode --key-id KEY_ID --dry-run --json
142
- easymagic keys update --where-group cc --quota 20 --dry-run --json
143
- easymagic keys export --all --file keys.json --json
150
+ easymagic ai setup all --clients claude-code,codex,opencode --key-id KEY_ID --dry-run
151
+ easymagic ai keys update --where-group cc --quota 20 --dry-run
152
+ easymagic ai keys export --all --file keys.json
144
153
  ```
145
154
 
146
155
  执行多客户端配置、导入、删除或批量修改前,先检查预览范围,再使用相应的 `--yes`。多个客户端结果逐项报告,失败不会撤销已经成功的目标。一个 key 的协议和分组未必同时适合所有客户端,不要把“18 种配置适配器”解释成“一把 key 对全部客户端可用”。
@@ -149,7 +158,7 @@ easymagic keys export --all --file keys.json --json
149
158
 
150
159
  ## 8. 支持范围与行为约束
151
160
 
152
- 18 个 ID:`claude-code`、`claude-desktop`、`codex`、`gemini`、`grok-build`、`opencode`、`openclaw`、`hermes`、`pi`、`minimax-code`、`kimi-code`、`deepseek-harness`、`agy`、`oh-my-pi`、`copilot`、`workbuddy`、`codebuddy`、`zcode`。安装版本的最终清单以 `setup list --json` 为准。
161
+ 18 个 ID:`claude-code`、`claude-desktop`、`codex`、`gemini`、`grok-build`、`opencode`、`openclaw`、`hermes`、`pi`、`minimax-code`、`kimi-code`、`deepseek-harness`、`agy`、`oh-my-pi`、`copilot`、`workbuddy`、`codebuddy`、`zcode`。安装版本的最终清单以 `easymagic ai setup list` 为准。
153
162
 
154
163
  所有适配器都有配置契约测试;只有 [COMPATIBILITY.md](COMPATIBILITY.md) 记录的具体客户端版本做过原生运行验证。部分桌面客户端仍需用户在应用内选择新 provider/model。CLI 不安装这些客户端,不修改其审批或沙盒策略,不内置协议转换代理,也不保证未来版本配置格式不变。
155
164
 
package/AUDIT.md CHANGED
@@ -41,3 +41,17 @@
41
41
  - 无法唯一确认的远程写入继续保持 `unknown`,需要核对操作记录。恢复保护文件本身若在接管期间崩溃遗留,会要求检查;不能直接删除仍属于活进程的锁。
42
42
 
43
43
  扫描未发现凭据不等于对所有未来输入或依赖版本作出保证;发布新版本时应重复检查安装包与 Git 变更。
44
+
45
+ ## 0.5.0 手动与 AI 模式复核
46
+
47
+ 新增手动控制台复用原有子命令,PAT 通过隐藏输入和 stdin 交付;已选择的保存账户不会被另一个环境令牌悄悄覆盖。写入前完整显示目录、模型及策略变更,长值换行,不用省略号隐藏确认信息。Ctrl+C 终止并回收当前命令后返回菜单;待授权操作保留原始恢复编号。
48
+
49
+ AI 模式明确通过 `ai` / `--ai` 选择,默认非阻塞、不打开浏览器。正常结果、帮助、版本、缺少子命令和错误均验证为 JSON;原来的 `--json` 保持兼容。
50
+
51
+ 验证:166 项测试、1106 个断言通过,18 种 Agent 配置/备份/恢复流程通过;真实 PTY 验证 40/80/120 列、NO_COLOR、TERM=dumb、隐藏 PAT、取消不写入以及请求子进程回收。独立复核确认取消行为、完整确认信息及 10 种 AI 输出路径。新终端依赖的许可证随安装包提供,依赖审计未报告已知漏洞。
52
+
53
+ ## 0.5.1 首页品牌与语言偏好
54
+
55
+ 首页新增始终可识别的“中文 / English”菜单项,选择后立即刷新界面并将偏好保存到独立 `preferences.json`;不改账号元数据、PAT 或推理密钥。优先级为显式 `--lang`、`EASYMAGIC_LANG`、保存的界面偏好、系统语言。AI 模式不读取该偏好。
56
+
57
+ 品牌区采用原 EasyMagic EM 标识的纯文本终端形式,配有本地双语介绍和完整官网地址;窄屏及 `TERM=dumb` 使用紧凑版本,不请求远程图片。172 项测试、1228 个断言、18 种客户端流程通过;真实 PTY 与独立复验覆盖语言切换、记忆、取消、NO_COLOR 和 40/80/120 列显示。
package/CLI_CONTRACT.md CHANGED
@@ -1,27 +1,37 @@
1
1
  # EasyMagic CLI 机器交互契约
2
2
 
3
- 本文面向调用 CLI 的 AI、脚本和集成程序。具体参数以本次安装的 `easymagic schema --json` 为准;本文说明状态处理、安全边界和恢复语义,不替代目标网站的 API 权限规则。
3
+ 本文面向调用 CLI 的 AI、脚本和集成程序。具体参数以本次安装的 `easymagic ai schema` 为准;本文说明状态处理、安全边界和恢复语义,不替代目标网站的 API 权限规则。
4
+
5
+ ## 模式选择
6
+
7
+ `easymagic ai [COMMAND …]` 与 `easymagic --ai [COMMAND …]` 是机器模式。无子命令时返回包含 `schema_version`、`mode: "ai"`、`version`、`commands` 和 `recommended_workflow` 的发现结果;具名命令返回原有业务 JSON。模式从 0.5.0 开始提供。
8
+
9
+ 机器模式不弹菜单、不读取交互提示、不打开浏览器。`login` 和 `onboard` 默认返回可恢复授权状态,只有显式 `--wait` 才等待网页授权;等待期间 stderr 仍可输出 JSON 事件。
10
+
11
+ `easymagic` 无参数且标准输入/输出均为 TTY 时进入手动控制台。`easymagic interactive` 明确请求同一控制台,非 TTY 时拒绝运行。TTY 的 `TERM=dumb` 使用编号输入;`NO_COLOR` 禁用颜色。没有 TTY 的无参数入口只输出模式说明,不等待输入。CLI 不根据进程名称、父进程或 AI 专用环境变量隐式切换模式。
12
+
13
+ 原有命令和 `--json` 输出选项保持兼容。`--json` 只指定输出格式,不承诺 AI 模式的非阻塞/不打开浏览器策略;旧调用需继续传 `--start --no-browser` 等显式选项。
4
14
 
5
15
  ## 接口发现
6
16
 
7
17
  ```sh
8
- easymagic guide --json
9
- easymagic guide ai --json
10
- easymagic guide contract --json
11
- easymagic schema --json
12
- easymagic schema onboard --json
13
- easymagic schema keys update --json
18
+ easymagic ai guide
19
+ easymagic ai guide ai
20
+ easymagic ai guide contract
21
+ easymagic ai schema
22
+ easymagic ai schema onboard
23
+ easymagic ai schema keys update
14
24
  ```
15
25
 
16
26
  `guide [topic]` 支持 `quickstart`、`ai`、`contract`、`agents`、`backend`、`audit`,JSON 输出中包含 Markdown。`schema [command...]` 从 Commander 命令树读取参数、选项及子命令。不要将自然语言 help 文案作为稳定的状态标识,也不要假定未被 schema 列出的 flag 可用。
17
27
 
18
28
  ## 输入、输出与退出码
19
29
 
20
- - 使用全局 `--json` 获取机器输出;`--profile NAME` 固定管理账号/站点,`--lang en|zh` 控制界面语言。
30
+ - 推荐使用 `ai` 前缀或全局 `--ai` 获取机器模式,原有全局 `--json` 仍可获取 JSON 输出;`--profile NAME` 固定管理账号/站点,`--lang en|zh` 控制界面语言。
21
31
  - 成功及可处理的异步状态输出到 stdout;顶层参数、权限、网络等错误输出到 stderr。等待授权时 stderr 也可能包含逐行 JSON 进度事件,不能把整段 stderr 一律当成单个错误对象。应分别捕获两个流,读取退出码后解析 JSON。
22
32
  - 批量部分失败仍在 stdout 返回逐项结果,并以非零退出码结束。不要只检查 stderr 是否为空。
23
33
  - 退出码 `0` 表示命令本身成功,不必然代表授权或配置已完成;异步流程还必须检查 `status`。退出码 `1` 表示失败、部分失败或未确认的写入结果。
24
- - 显式 `--help` 和 `--version` 是文本接口;不要将其当 JSON 解析。
34
+ - AI 模式的 `--help` 返回包含 `help` 文本的 JSON 对象,`--version` 返回版本 JSON;无 AI 模式时保持文本输出,包括旧 `--json --help` / `--json --version`。
25
35
  - 各具名命令没有统一的顶层成功 envelope。`whoami`、`keys list`、`setup`、`operations` 的结果字段各不相同;直接 `api` 返回后端原始 JSON。
26
36
 
27
37
  常规错误形状如下;可选字段可能因 JSON 序列化被省略:
@@ -48,8 +58,8 @@ easymagic schema keys update --json
48
58
  默认 `keys list/show` 隐藏完整 key,普通导出不包含 key。以下是显式敏感输出入口,应避免将输出发到聊天、公共日志或版本库:
49
59
 
50
60
  ```sh
51
- easymagic keys show KEY_ID --reveal --json
52
- easymagic keys export --all --reveal --file private-keys.json --json
61
+ easymagic ai keys show KEY_ID --reveal
62
+ easymagic ai keys export --all --reveal --file private-keys.json
53
63
  ```
54
64
 
55
65
  `api` 返回任意同站点后端内容,不能保证敏感字段已经遮罩。`--token` 会把 PAT 放进 argv;交互登录优先 browser,自动化秘密优先 stdin 或受控环境变量。
@@ -59,12 +69,12 @@ easymagic keys export --all --reveal --file private-keys.json --json
59
69
  推荐新用户通过 `onboard` 完成登录、创建目标客户端专用 key 和写入配置:
60
70
 
61
71
  ```sh
62
- easymagic onboard codex --start --no-browser --json
63
- easymagic onboard --resume ONBOARDING_ID --json
64
- easymagic onboard --resume ONBOARDING_ID --wait --json
72
+ easymagic ai onboard codex --start --no-browser
73
+ easymagic ai onboard --resume ONBOARDING_ID
74
+ easymagic ai onboard --resume ONBOARDING_ID --wait
65
75
  ```
66
76
 
67
- `onboard [client]` 接受目标客户端配置选项,包括分组、模型、协议、配置目录及已知模型容量;它不接受手工推理 key。普通交互调用可以打开浏览器并等待。机器调用应优先 start/resume,保留返回的 `onboarding_id`,使用 `next_command` 继续。
77
+ `ai onboard [client]` 接受目标客户端配置选项,包括分组、模型、协议、配置目录及已知模型容量;它不接受手工推理 key。手动控制台和普通子命令调用可以打开浏览器并等待;AI 模式不会自动打开浏览器。机器调用应优先 AI 模式的发起/恢复,保留返回的 `onboarding_id`,使用 `next_command` 继续。
68
78
 
69
79
  安全结果包含 `status`、`onboarding_id`、`next_command` 以及相应阶段的 `login` / `setup` 数据;并非所有字段在每个阶段都有值。
70
80
 
@@ -84,10 +94,10 @@ easymagic onboard --resume ONBOARDING_ID --wait --json
84
94
  独立登录支持非阻塞发起、检查/等待和取消:
85
95
 
86
96
  ```sh
87
- easymagic login --start --no-browser --json
88
- easymagic login --resume FLOW_ID --json
89
- easymagic login --resume FLOW_ID --wait --json
90
- easymagic login --cancel FLOW_ID --json
97
+ easymagic ai login --start --no-browser
98
+ easymagic ai login --resume FLOW_ID
99
+ easymagic ai login --resume FLOW_ID --wait
100
+ easymagic ai login --cancel FLOW_ID
91
101
  ```
92
102
 
93
103
  只把安全授权链接、校验码和过期提示交给用户;设备秘密和获得的 PAT 留在 CLI 内部。用户应在网站完成登录、协议签署及确认,AI 不代填密码、恢复码或绕过验证。
@@ -123,10 +133,10 @@ easymagic login --cancel FLOW_ID --json
123
133
  | `unknown` | 已发起但结果不确定 | `reconcile`,禁止盲目创建重试 |
124
134
 
125
135
  ```sh
126
- easymagic operations show OPERATION_ID --json
127
- easymagic operations reconcile OPERATION_ID --json
128
- easymagic operations resume OPERATION_ID --dry-run --json
129
- easymagic operations retry OPERATION_ID --dry-run --json
136
+ easymagic ai operations show OPERATION_ID
137
+ easymagic ai operations reconcile OPERATION_ID
138
+ easymagic ai operations resume OPERATION_ID --dry-run
139
+ easymagic ai operations retry OPERATION_ID --dry-run
130
140
  ```
131
141
 
132
142
  流程自行创建后又确认清理的密钥,允许在显式 `onboard --resume ID --retry` 后创建替代密钥;未知清理结果或普通 404 不会触发重建。
@@ -154,5 +164,5 @@ easymagic operations retry OPERATION_ID --dry-run --json
154
164
  2. 保留并使用原始 flow/onboarding/operation/restore 编号,不自行生成替代编号。
155
165
  3. 等待用户浏览器确认;不读取或绕过用户密码、MFA、Cookie 和协议确认。
156
166
  4. 未知写入先回查,重试只针对已确认失败项;不要以新创建命令掩盖不确定结果。
157
- 5. 不把 `--json` 理解为秘密自动脱敏保证;显式 reveal 和低层 api 是敏感输出。
167
+ 5. 不把 AI 模式或 `--json` 理解为秘密自动脱敏保证;显式 reveal 和低层 api 是敏感输出。
158
168
  6. 不把配置成功当成所有模型均可调用或计费测试已通过;报告验证范围及仍需用户执行的客户端内动作。
package/README.md CHANGED
@@ -1,19 +1,19 @@
1
1
  # EasyMagic CLI
2
2
 
3
- 管理 EasyMagic 账户、API 密钥与用量,并配置 18 种编码 Agent。`onboard` 将浏览器登录、创建专用推理密钥、选择兼容模型、写入客户端配置串成可恢复的流程。支持人使用,也支持 AI 通过 JSON 调用。
3
+ 管理 EasyMagic 账户、API 密钥与用量,并配置 18 种编码 Agent。提供手动控制台与 AI 命令模式:人使用菜单,AI 使用稳定的 JSON 接口。`onboard` 将浏览器登录、创建专用推理密钥、选择兼容模型、写入客户端配置串成可恢复的流程。
4
4
 
5
5
  0.4.1 的数据扫描结果、已修复流程及凭据边界见 [审计报告](AUDIT.md),也可执行 `easymagic guide audit` 离线查看。
6
6
 
7
7
  ## 安装
8
8
 
9
- 需要 Node.js 22 或更新版本。从 npm 安装指定版本:
9
+ 需要 Node.js 22 或更新版本。从 npm 安装:
10
10
 
11
11
  ```sh
12
- npm install -g easymagic@0.4.1
12
+ npm install -g easymagic
13
13
  easymagic --help
14
14
  ```
15
15
 
16
- 也可以不全局安装,直接执行 `npx --yes easymagic@0.4.1 --help`。离线分发则使用安装包:`npm install -g ./easymagic-0.4.1.tgz`。
16
+ 也可以不全局安装,直接执行 `npx --yes easymagic --help`。离线分发则使用安装包:`npm install -g ./easymagic-0.5.1.tgz`。
17
17
 
18
18
  源码构建需要 Bun:
19
19
 
@@ -23,6 +23,39 @@ bun run build
23
23
  node dist/cli.js --help
24
24
  ```
25
25
 
26
+ ## 手动模式与 AI 模式
27
+
28
+ 双模式入口从 0.5.0 开始提供,可用 `easymagic --version` 确认当前版本。
29
+
30
+ 在终端直接运行:
31
+
32
+ ```sh
33
+ easymagic
34
+ # 也可明确进入手动控制台
35
+ easymagic interactive
36
+ ```
37
+
38
+ 手动控制台使用方向键选择、Enter 确认,按 Ctrl+C 取消当前操作或退出。`TERM=dumb` 的交互终端改用编号输入,输入 `q` 返回或退出;`NO_COLOR` 会关闭颜色。首页包含配置 Agent、登录与切换账号、密钥管理、模型和用量、诊断、配置恢复及操作记录。开始时读取本地账号状态,实际请求和变更在选择具体操作后执行。密码式 PAT 输入不回显,删除、恢复等变更需要确认;取消不会被当成确认。
39
+
40
+ 从 0.5.1 起,首页的 **中文 / English** 可立即切换整套菜单语言,并记住选择。语言偏好保存在 CLI 配置目录的 `preferences.json`,与登录凭据分开;取消选择不会更改偏好。启动时的优先级为 `--lang` > `EASYMAGIC_LANG` > 已保存的菜单语言 > 系统语言。比如 `easymagic --lang en` 可临时用英文打开,首页语言选项仍可随时切换。AI 模式不读取手动菜单的语言偏好。
41
+
42
+ 首页同时显示 EasyMagic 终端品牌标识、简短介绍和官网 `https://easymagic.ai`;窄终端使用紧凑布局,品牌区不会代替账户状态或操作菜单。
43
+
44
+ AI 和脚本使用明确的另一种入口:
45
+
46
+ ```sh
47
+ easymagic ai
48
+ easymagic ai guide ai
49
+ easymagic ai schema onboard
50
+ easymagic ai onboard codex
51
+ # 等价的全局选项
52
+ easymagic --ai onboard codex
53
+ ```
54
+
55
+ `ai` 模式始终输出 JSON,不进入菜单、不自动打开浏览器,也不提示输入。登录或配置需要用户授权时返回 `authorization_pending` 和恢复编号;用户完成网页授权后再用同一编号继续。只有显式 `--wait` 才等待授权。原有 `--json` 和各子命令仍兼容。
56
+
57
+ 菜单要求标准输入和输出都连接交互终端(TTY)。重定向、管道或无终端工具调用中,直接运行不会等待输入,而会显示模式说明;`interactive` 则明确报错。CLI 不通过调用者进程名或 AI 环境变量猜测模式。
58
+
26
59
  ## 一条命令完成配置
27
60
 
28
61
  先安装目标 Agent,然后运行:
@@ -55,15 +88,15 @@ easymagic onboard kimi-code --model YOUR_MODEL --context-window YOUR_MODEL_CONTE
55
88
  完整调用规范见 [AI_USAGE.md](AI_USAGE.md) 和 [CLI_CONTRACT.md](CLI_CONTRACT.md),这些文档也随安装包内置,离线可读:
56
89
 
57
90
  ```sh
58
- easymagic guide ai --json
59
- easymagic schema onboard --json
60
- easymagic setup list --json
91
+ easymagic ai guide ai
92
+ easymagic ai schema onboard
93
+ easymagic ai setup list
61
94
 
62
95
  # 不长时间占用工具调用;将返回的授权链接和配对码交给用户
63
- easymagic onboard claude-code --start --json
96
+ easymagic ai onboard claude-code --start
64
97
 
65
98
  # 用户确认后用同一编号继续;不要另起一次 onboard
66
- easymagic onboard --resume ONBOARDING_ID --json
99
+ easymagic ai onboard --resume ONBOARDING_ID
67
100
  ```
68
101
 
69
102
  读取 JSON 的 `status`:`authorization_pending` 表示等待用户,`configured` 才表示配置完成。两者退出码均为 0,因此不能仅靠退出码判断全流程完成。`action_required`、`expired`、`denied`、`cancelled` 返回 1。网络、参数等常规错误在 stderr 的 `error` 对象中;恢复流程可操作的结果在 stdout。等待事件使用 stderr JSON,不混入 stdout。
@@ -77,8 +110,8 @@ easymagic login
77
110
  # 无浏览器/远程终端:输出链接,在自己的浏览器中打开
78
111
  easymagic login --no-browser
79
112
  # AI 非阻塞登录
80
- easymagic login --start --json
81
- easymagic login --resume FLOW_ID --json
113
+ easymagic ai login
114
+ easymagic ai login --resume FLOW_ID
82
115
  ```
83
116
 
84
117
  兼容旧站点:在个人设置创建具有 `profile:read`、`api_key:read`、`api_key:write`、`api_key:reveal`、`usage:read` 的 PAT(`nap_…`),从标准输入传入。Bash 隐藏输入示例:
@@ -121,3 +121,158 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
121
121
  SOFTWARE.
122
122
 
123
123
  [others]: https://github.com/json5/json5/contributors
124
+
125
+
126
+ ## @clack/prompts 1.9.0
127
+
128
+ MIT License
129
+
130
+ MIT License Copyright (c) 2025-Present [Bombshell contributors](https://bomb.sh/team)
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
133
+
134
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
135
+
136
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
137
+
138
+
139
+ ## @clack/core 1.6.0
140
+
141
+ MIT License
142
+
143
+ MIT License Copyright (c) 2025-Present [Bombshell contributors](https://bomb.sh/team)
144
+
145
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
146
+
147
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148
+
149
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
150
+
151
+
152
+ ## sisteransi 2.0.1
153
+
154
+ MIT License
155
+
156
+ Copyright (c) 2018 Terkel Gjervig Nielsen
157
+
158
+ Permission is hereby granted, free of charge, to any person obtaining a copy
159
+ of this software and associated documentation files (the "Software"), to deal
160
+ in the Software without restriction, including without limitation the rights
161
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
162
+ copies of the Software, and to permit persons to whom the Software is
163
+ furnished to do so, subject to the following conditions:
164
+
165
+ The above copyright notice and this permission notice shall be included in all
166
+ copies or substantial portions of the Software.
167
+
168
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
169
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
171
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
172
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
173
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
174
+ SOFTWARE.
175
+
176
+
177
+ ## fast-wrap-ansi 0.2.2
178
+
179
+ MIT License
180
+
181
+ Copyright (c) 2025 James Garbutt
182
+
183
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
184
+
185
+ Permission is hereby granted, free of charge, to any person obtaining a copy
186
+ of this software and associated documentation files (the "Software"), to deal
187
+ in the Software without restriction, including without limitation the rights
188
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
189
+ copies of the Software, and to permit persons to whom the Software is
190
+ furnished to do so, subject to the following conditions:
191
+
192
+ The above copyright notice and this permission notice shall be included in all
193
+ copies or substantial portions of the Software.
194
+
195
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
196
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
197
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
198
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
199
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
200
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
201
+ SOFTWARE.
202
+
203
+
204
+ ## fast-string-width 3.0.2
205
+
206
+ The MIT License (MIT)
207
+
208
+ Copyright (c) 2024-present Fabio Spampinato
209
+
210
+ Permission is hereby granted, free of charge, to any person obtaining a
211
+ copy of this software and associated documentation files (the "Software"),
212
+ to deal in the Software without restriction, including without limitation
213
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
214
+ and/or sell copies of the Software, and to permit persons to whom the
215
+ Software is furnished to do so, subject to the following conditions:
216
+
217
+ The above copyright notice and this permission notice shall be included in
218
+ all copies or substantial portions of the Software.
219
+
220
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
222
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
224
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
225
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
226
+ DEALINGS IN THE SOFTWARE.
227
+
228
+
229
+ ## string-width 9.0.0
230
+
231
+ MIT License
232
+
233
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
234
+
235
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
236
+
237
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
238
+
239
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
240
+
241
+
242
+ ## get-east-asian-width 1.7.0
243
+
244
+ MIT License
245
+
246
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
247
+
248
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
249
+
250
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
251
+
252
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
253
+
254
+
255
+ ## strip-ansi 7.2.0
256
+
257
+ MIT License
258
+
259
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
260
+
261
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
262
+
263
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
264
+
265
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
266
+
267
+
268
+ ## ansi-regex 6.6.0
269
+
270
+ MIT License
271
+
272
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
273
+
274
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
275
+
276
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
277
+
278
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.