easymagic 0.5.0 → 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/AUDIT.md +6 -0
- package/README.md +5 -1
- package/dist/cli.js +120 -11
- package/package.json +1 -1
package/AUDIT.md
CHANGED
|
@@ -49,3 +49,9 @@
|
|
|
49
49
|
AI 模式明确通过 `ai` / `--ai` 选择,默认非阻塞、不打开浏览器。正常结果、帮助、版本、缺少子命令和错误均验证为 JSON;原来的 `--json` 保持兼容。
|
|
50
50
|
|
|
51
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/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm install -g easymagic
|
|
|
13
13
|
easymagic --help
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
也可以不全局安装,直接执行 `npx --yes easymagic --help`。离线分发则使用安装包:`npm install -g ./easymagic-0.5.
|
|
16
|
+
也可以不全局安装,直接执行 `npx --yes easymagic --help`。离线分发则使用安装包:`npm install -g ./easymagic-0.5.1.tgz`。
|
|
17
17
|
|
|
18
18
|
源码构建需要 Bun:
|
|
19
19
|
|
|
@@ -37,6 +37,10 @@ easymagic interactive
|
|
|
37
37
|
|
|
38
38
|
手动控制台使用方向键选择、Enter 确认,按 Ctrl+C 取消当前操作或退出。`TERM=dumb` 的交互终端改用编号输入,输入 `q` 返回或退出;`NO_COLOR` 会关闭颜色。首页包含配置 Agent、登录与切换账号、密钥管理、模型和用量、诊断、配置恢复及操作记录。开始时读取本地账号状态,实际请求和变更在选择具体操作后执行。密码式 PAT 输入不回显,删除、恢复等变更需要确认;取消不会被当成确认。
|
|
39
39
|
|
|
40
|
+
从 0.5.1 起,首页的 **中文 / English** 可立即切换整套菜单语言,并记住选择。语言偏好保存在 CLI 配置目录的 `preferences.json`,与登录凭据分开;取消选择不会更改偏好。启动时的优先级为 `--lang` > `EASYMAGIC_LANG` > 已保存的菜单语言 > 系统语言。比如 `easymagic --lang en` 可临时用英文打开,首页语言选项仍可随时切换。AI 模式不读取手动菜单的语言偏好。
|
|
41
|
+
|
|
42
|
+
首页同时显示 EasyMagic 终端品牌标识、简短介绍和官网 `https://easymagic.ai`;窄终端使用紧凑布局,品牌区不会代替账户状态或操作菜单。
|
|
43
|
+
|
|
40
44
|
AI 和脚本使用明确的另一种入口:
|
|
41
45
|
|
|
42
46
|
```sh
|
package/dist/cli.js
CHANGED
|
@@ -16573,7 +16573,7 @@ var package_default;
|
|
|
16573
16573
|
var init_package = __esm(() => {
|
|
16574
16574
|
package_default = {
|
|
16575
16575
|
name: "easymagic",
|
|
16576
|
-
version: "0.5.
|
|
16576
|
+
version: "0.5.1",
|
|
16577
16577
|
description: "Manage EasyMagic API keys, inspect usage, and configure coding clients",
|
|
16578
16578
|
type: "module",
|
|
16579
16579
|
bin: {
|
|
@@ -16749,6 +16749,65 @@ async function runCommand(args, options = {}) {
|
|
|
16749
16749
|
}
|
|
16750
16750
|
var init_runner = () => {};
|
|
16751
16751
|
|
|
16752
|
+
// src/interactive/preferences.ts
|
|
16753
|
+
import fs19 from "node:fs";
|
|
16754
|
+
import path18 from "node:path";
|
|
16755
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
16756
|
+
function preferencesPath() {
|
|
16757
|
+
return path18.join(path18.dirname(configPath()), "preferences.json");
|
|
16758
|
+
}
|
|
16759
|
+
function loadUILanguage() {
|
|
16760
|
+
try {
|
|
16761
|
+
const file = preferencesPath();
|
|
16762
|
+
const stat = fs19.lstatSync(file);
|
|
16763
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 4096)
|
|
16764
|
+
return;
|
|
16765
|
+
const value = JSON.parse(fs19.readFileSync(file, "utf8"));
|
|
16766
|
+
return value?.version === 1 && ["zh", "en"].includes(value.language) ? value.language : undefined;
|
|
16767
|
+
} catch {
|
|
16768
|
+
return;
|
|
16769
|
+
}
|
|
16770
|
+
}
|
|
16771
|
+
function resolveUILanguage(override) {
|
|
16772
|
+
if (override)
|
|
16773
|
+
return override;
|
|
16774
|
+
if (process.env.EASYMAGIC_LANG)
|
|
16775
|
+
return process.env.EASYMAGIC_LANG.toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
16776
|
+
const saved = loadUILanguage();
|
|
16777
|
+
if (saved)
|
|
16778
|
+
return saved;
|
|
16779
|
+
return (process.env.LC_ALL || process.env.LANG || "en").toLowerCase().startsWith("zh") ? "zh" : "en";
|
|
16780
|
+
}
|
|
16781
|
+
function saveUILanguage(language) {
|
|
16782
|
+
if (language !== "zh" && language !== "en")
|
|
16783
|
+
throw new Error("Choose 简体中文 or English.");
|
|
16784
|
+
const file = preferencesPath();
|
|
16785
|
+
const directory = path18.dirname(file);
|
|
16786
|
+
fs19.mkdirSync(directory, { recursive: true, mode: 448 });
|
|
16787
|
+
const stat = fs19.lstatSync(directory);
|
|
16788
|
+
if (!stat.isDirectory() || stat.isSymbolicLink())
|
|
16789
|
+
throw new Error("UI preference directory must be a real directory.");
|
|
16790
|
+
const unlock = acquireFileLock(file + ".lock", "Another process is saving the interface language. Try again.");
|
|
16791
|
+
const temporary = `${file}.${randomUUID8()}.tmp`;
|
|
16792
|
+
try {
|
|
16793
|
+
if (fs19.existsSync(file)) {
|
|
16794
|
+
const existing = fs19.lstatSync(file);
|
|
16795
|
+
if (!existing.isFile() || existing.isSymbolicLink())
|
|
16796
|
+
throw new Error("UI preferences must be a regular file.");
|
|
16797
|
+
}
|
|
16798
|
+
fs19.writeFileSync(temporary, JSON.stringify({ version: 1, language }, null, 2) + `
|
|
16799
|
+
`, { flag: "wx", mode: 384 });
|
|
16800
|
+
fs19.renameSync(temporary, file);
|
|
16801
|
+
} finally {
|
|
16802
|
+
fs19.rmSync(temporary, { force: true });
|
|
16803
|
+
unlock();
|
|
16804
|
+
}
|
|
16805
|
+
}
|
|
16806
|
+
var init_preferences = __esm(() => {
|
|
16807
|
+
init_config();
|
|
16808
|
+
init_file_lock();
|
|
16809
|
+
});
|
|
16810
|
+
|
|
16752
16811
|
// node_modules/fast-string-truncated-width/dist/utils.js
|
|
16753
16812
|
var getCodePointsLength, isFullWidth = (x) => {
|
|
16754
16813
|
return x === 12288 || x >= 65281 && x <= 65376 || x >= 65504 && x <= 65510;
|
|
@@ -18118,6 +18177,20 @@ var init_string_width = __esm(() => {
|
|
|
18118
18177
|
emojiZwjSequenceRegex = /\u{200D}\p{Extended_Pictographic}/v;
|
|
18119
18178
|
});
|
|
18120
18179
|
|
|
18180
|
+
// src/interactive/brand.ts
|
|
18181
|
+
var TERMINAL_MARK, BRAND_WEBSITE = "https://easymagic.ai", BRAND_TAGLINE;
|
|
18182
|
+
var init_brand = __esm(() => {
|
|
18183
|
+
TERMINAL_MARK = [
|
|
18184
|
+
"┏━━╸ ╻╲ ╱╻",
|
|
18185
|
+
"┣━━╸ ┃ ╲╱ ┃",
|
|
18186
|
+
"┗━━╸ ╹ ╹"
|
|
18187
|
+
];
|
|
18188
|
+
BRAND_TAGLINE = {
|
|
18189
|
+
zh: "一个入口,连接你的 AI 工具",
|
|
18190
|
+
en: "One gateway for your AI tools"
|
|
18191
|
+
};
|
|
18192
|
+
});
|
|
18193
|
+
|
|
18121
18194
|
// src/interactive/ui.ts
|
|
18122
18195
|
import { createInterface } from "node:readline/promises";
|
|
18123
18196
|
import { emitKeypressEvents } from "node:readline";
|
|
@@ -18319,9 +18392,19 @@ function startTask(message) {
|
|
|
18319
18392
|
function banner(options) {
|
|
18320
18393
|
const style = color();
|
|
18321
18394
|
const width = terminalWidth() - 4;
|
|
18322
|
-
|
|
18323
|
-
|
|
18324
|
-
console.log("
|
|
18395
|
+
const version = `v${cleanText(options.version)}`;
|
|
18396
|
+
const tagline = BRAND_TAGLINE[language2];
|
|
18397
|
+
console.log("");
|
|
18398
|
+
if (width >= 68 && process.env.TERM !== "dumb") {
|
|
18399
|
+
console.log(" " + style.cyan(TERMINAL_MARK[0]) + " " + style.cyan.bold("EasyMagic") + " " + style.dim(version));
|
|
18400
|
+
console.log(" " + style.cyan(TERMINAL_MARK[1]) + " " + tagline);
|
|
18401
|
+
console.log(" " + style.cyan(TERMINAL_MARK[2]) + " " + style.underline(BRAND_WEBSITE));
|
|
18402
|
+
} else {
|
|
18403
|
+
console.log(" " + style.cyan.bold("EasyMagic") + " " + style.dim(version));
|
|
18404
|
+
for (const line of wrapText(tagline, width))
|
|
18405
|
+
console.log(" " + line);
|
|
18406
|
+
console.log(" " + style.underline(BRAND_WEBSITE));
|
|
18407
|
+
}
|
|
18325
18408
|
console.log(" " + style.dim("─".repeat(width)));
|
|
18326
18409
|
if (options.profile)
|
|
18327
18410
|
console.log(" " + style.dim(t2("账户配置 ", "Profile ")) + truncateText(options.profile, width - 10));
|
|
@@ -18377,6 +18460,7 @@ var init_ui = __esm(() => {
|
|
|
18377
18460
|
init_dist6();
|
|
18378
18461
|
init_source();
|
|
18379
18462
|
init_string_width();
|
|
18463
|
+
init_brand();
|
|
18380
18464
|
UserCancelled = class UserCancelled extends Error {
|
|
18381
18465
|
constructor() {
|
|
18382
18466
|
super("Interactive action cancelled.");
|
|
@@ -18397,7 +18481,7 @@ var init_ui = __esm(() => {
|
|
|
18397
18481
|
});
|
|
18398
18482
|
|
|
18399
18483
|
// src/interactive/main.ts
|
|
18400
|
-
import
|
|
18484
|
+
import path19 from "node:path";
|
|
18401
18485
|
async function execute2(ctx, args, message, input) {
|
|
18402
18486
|
const task = startTask(message);
|
|
18403
18487
|
try {
|
|
@@ -18616,13 +18700,13 @@ async function configure(ctx) {
|
|
|
18616
18700
|
options.push("--context-window", context);
|
|
18617
18701
|
}
|
|
18618
18702
|
const directory = await textInput(t3(ctx, "配置目录(可修改)", "Configuration directory"), { initialValue: adapter.configDir(), validate: (value) => value.trim() ? undefined : t3(ctx, "请输入目录", "Enter a directory") });
|
|
18619
|
-
options.push("--config-dir",
|
|
18703
|
+
options.push("--config-dir", path19.resolve(directory));
|
|
18620
18704
|
displayPairs(t3(ctx, "确认配置", "Review configuration"), [
|
|
18621
18705
|
[t3(ctx, "Agent", "Agent"), adapter.label],
|
|
18622
18706
|
[t3(ctx, "账户", "Account"), ctx.profile],
|
|
18623
18707
|
[t3(ctx, "模型", "Model"), modelChoice === "__automatic" ? t3(ctx, "自动选择兼容模型", "Automatic compatible selection") : modelChoice],
|
|
18624
18708
|
[t3(ctx, "协议 / 分组", "Protocol / group"), `${protocol} / ${group}`],
|
|
18625
|
-
[t3(ctx, "目录", "Directory"),
|
|
18709
|
+
[t3(ctx, "目录", "Directory"), path19.resolve(directory)],
|
|
18626
18710
|
[t3(ctx, "密钥", "Key"), key ? `${text3(key.name)} #${key.id}` : t3(ctx, "新建专用密钥(不限额、不过期)", "New dedicated key (unlimited, no expiration)")]
|
|
18627
18711
|
]);
|
|
18628
18712
|
showInfo(t3(ctx, "已有配置会备份;本次不会发送计费推理请求。", "Existing configuration will be backed up. No billable inference request will be sent."));
|
|
@@ -18760,7 +18844,7 @@ async function keyMenu(ctx) {
|
|
|
18760
18844
|
if (choice === "manage")
|
|
18761
18845
|
await manageKey(ctx);
|
|
18762
18846
|
if (choice === "export") {
|
|
18763
|
-
const file = await textInput(t3(ctx, "导出文件路径(JSON 或 CSV)", "Export file path (JSON or CSV)"), { initialValue:
|
|
18847
|
+
const file = await textInput(t3(ctx, "导出文件路径(JSON 或 CSV)", "Export file path (JSON or CSV)"), { initialValue: path19.resolve("easymagic-keys.json"), validate: (value) => value.trim() ? undefined : t3(ctx, "请输入路径", "Enter a path") });
|
|
18764
18848
|
if (await confirmAction(t3(ctx, "导出全部密钥策略(不含完整密钥)?", "Export all key policies without full secrets?"))) {
|
|
18765
18849
|
const result = await execute2(ctx, ["keys", "export", "--all", "--file", file], t3(ctx, "导出策略", "Exporting policies"));
|
|
18766
18850
|
showSuccess(`${t3(ctx, "已导出", "Exported")}: ${text3(result.data?.file)}`);
|
|
@@ -18930,7 +19014,7 @@ async function runInteractive(options = {}) {
|
|
|
18930
19014
|
try {
|
|
18931
19015
|
defaultProfile = listProfiles().active;
|
|
18932
19016
|
} catch {}
|
|
18933
|
-
const ctx = { profile: options.profile || defaultProfile, language: options.language
|
|
19017
|
+
const ctx = { profile: options.profile || defaultProfile, language: resolveUILanguage(options.language) };
|
|
18934
19018
|
setUILanguage(ctx.language);
|
|
18935
19019
|
let running = true;
|
|
18936
19020
|
while (running) {
|
|
@@ -18959,6 +19043,7 @@ async function runInteractive(options = {}) {
|
|
|
18959
19043
|
{ value: "doctor", label: t3(ctx, "诊断连接", "Diagnose connections") },
|
|
18960
19044
|
{ value: "recovery", label: t3(ctx, "恢复与操作记录", "Recovery and operation history") },
|
|
18961
19045
|
{ value: "ai", label: t3(ctx, "AI 调用方式", "Using the AI mode") },
|
|
19046
|
+
{ value: "language", label: "中文 / English", hint: t3(ctx, "界面语言:简体中文", "Interface language: English") },
|
|
18962
19047
|
{ value: "exit", label: t3(ctx, "退出", "Exit") }
|
|
18963
19048
|
]);
|
|
18964
19049
|
} catch (error) {
|
|
@@ -18987,6 +19072,19 @@ easymagic ai onboard codex --start
|
|
|
18987
19072
|
easymagic ai onboard --resume <onboarding_id>`, t3(ctx, "AI 模式:结构化输出,无交互菜单", "AI mode: structured output, no interactive menus"));
|
|
18988
19073
|
await pause(t3(ctx, "按 Enter 返回主页", "Press Enter to return home"));
|
|
18989
19074
|
}
|
|
19075
|
+
if (action === "language") {
|
|
19076
|
+
const selected = await selectChoice("选择语言 / Choose language", [
|
|
19077
|
+
{ value: "zh", label: "简体中文" },
|
|
19078
|
+
{ value: "en", label: "English" },
|
|
19079
|
+
{ value: "back", label: "返回 / Back" }
|
|
19080
|
+
]);
|
|
19081
|
+
if (selected !== "back") {
|
|
19082
|
+
saveUILanguage(selected);
|
|
19083
|
+
ctx.language = selected;
|
|
19084
|
+
setUILanguage(selected);
|
|
19085
|
+
showSuccess(t3(ctx, "已切换为简体中文,语言偏好已保存。", "Switched to English. Language preference saved."));
|
|
19086
|
+
}
|
|
19087
|
+
}
|
|
18990
19088
|
if (action === "exit")
|
|
18991
19089
|
running = false;
|
|
18992
19090
|
} catch (error) {
|
|
@@ -19009,6 +19107,7 @@ var init_main3 = __esm(() => {
|
|
|
19009
19107
|
init_format();
|
|
19010
19108
|
init_package();
|
|
19011
19109
|
init_runner();
|
|
19110
|
+
init_preferences();
|
|
19012
19111
|
init_ui();
|
|
19013
19112
|
});
|
|
19014
19113
|
|
|
@@ -21390,7 +21489,7 @@ npm install -g easymagic
|
|
|
21390
21489
|
easymagic --help
|
|
21391
21490
|
\`\`\`
|
|
21392
21491
|
|
|
21393
|
-
也可以不全局安装,直接执行 \`npx --yes easymagic --help\`。离线分发则使用安装包:\`npm install -g ./easymagic-0.5.
|
|
21492
|
+
也可以不全局安装,直接执行 \`npx --yes easymagic --help\`。离线分发则使用安装包:\`npm install -g ./easymagic-0.5.1.tgz\`。
|
|
21394
21493
|
|
|
21395
21494
|
源码构建需要 Bun:
|
|
21396
21495
|
|
|
@@ -21414,6 +21513,10 @@ easymagic interactive
|
|
|
21414
21513
|
|
|
21415
21514
|
手动控制台使用方向键选择、Enter 确认,按 Ctrl+C 取消当前操作或退出。\`TERM=dumb\` 的交互终端改用编号输入,输入 \`q\` 返回或退出;\`NO_COLOR\` 会关闭颜色。首页包含配置 Agent、登录与切换账号、密钥管理、模型和用量、诊断、配置恢复及操作记录。开始时读取本地账号状态,实际请求和变更在选择具体操作后执行。密码式 PAT 输入不回显,删除、恢复等变更需要确认;取消不会被当成确认。
|
|
21416
21515
|
|
|
21516
|
+
从 0.5.1 起,首页的 **中文 / English** 可立即切换整套菜单语言,并记住选择。语言偏好保存在 CLI 配置目录的 \`preferences.json\`,与登录凭据分开;取消选择不会更改偏好。启动时的优先级为 \`--lang\` > \`EASYMAGIC_LANG\` > 已保存的菜单语言 > 系统语言。比如 \`easymagic --lang en\` 可临时用英文打开,首页语言选项仍可随时切换。AI 模式不读取手动菜单的语言偏好。
|
|
21517
|
+
|
|
21518
|
+
首页同时显示 EasyMagic 终端品牌标识、简短介绍和官网 \`https://easymagic.ai\`;窄终端使用紧凑布局,品牌区不会代替账户状态或操作菜单。
|
|
21519
|
+
|
|
21417
21520
|
AI 和脚本使用明确的另一种入口:
|
|
21418
21521
|
|
|
21419
21522
|
\`\`\`sh
|
|
@@ -21648,6 +21751,12 @@ var AUDIT_default = `# 0.4.1 安全与流程复核
|
|
|
21648
21751
|
AI 模式明确通过 \`ai\` / \`--ai\` 选择,默认非阻塞、不打开浏览器。正常结果、帮助、版本、缺少子命令和错误均验证为 JSON;原来的 \`--json\` 保持兼容。
|
|
21649
21752
|
|
|
21650
21753
|
验证:166 项测试、1106 个断言通过,18 种 Agent 配置/备份/恢复流程通过;真实 PTY 验证 40/80/120 列、NO_COLOR、TERM=dumb、隐藏 PAT、取消不写入以及请求子进程回收。独立复核确认取消行为、完整确认信息及 10 种 AI 输出路径。新终端依赖的许可证随安装包提供,依赖审计未报告已知漏洞。
|
|
21754
|
+
|
|
21755
|
+
## 0.5.1 首页品牌与语言偏好
|
|
21756
|
+
|
|
21757
|
+
首页新增始终可识别的“中文 / English”菜单项,选择后立即刷新界面并将偏好保存到独立 \`preferences.json\`;不改账号元数据、PAT 或推理密钥。优先级为显式 \`--lang\`、\`EASYMAGIC_LANG\`、保存的界面偏好、系统语言。AI 模式不读取该偏好。
|
|
21758
|
+
|
|
21759
|
+
品牌区采用原 EasyMagic EM 标识的纯文本终端形式,配有本地双语介绍和完整官网地址;窄屏及 \`TERM=dumb\` 使用紧凑版本,不请求远程图片。172 项测试、1228 个断言、18 种客户端流程通过;真实 PTY 与独立复验覆盖语言切换、记忆、取消、NO_COLOR 和 40/80/120 列显示。
|
|
21651
21760
|
`;
|
|
21652
21761
|
|
|
21653
21762
|
// src/commands/guide.ts
|
|
@@ -21762,7 +21871,7 @@ async function openInteractive(command) {
|
|
|
21762
21871
|
throw new Error("Interactive mode requires a TTY. Open a terminal, or use easymagic ai for machine-readable commands.");
|
|
21763
21872
|
}
|
|
21764
21873
|
await Promise.resolve().then(() => init_main3());
|
|
21765
|
-
await runInteractive({ profile: command.optsWithGlobals().profile, language: language3 });
|
|
21874
|
+
await runInteractive({ profile: command.optsWithGlobals().profile, language: command.optsWithGlobals().lang ? language3 : undefined });
|
|
21766
21875
|
}
|
|
21767
21876
|
program2.action(async (_options, command) => {
|
|
21768
21877
|
if (invocation.ai) {
|