@nggaigc/cli 0.1.16 → 0.1.18

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/bin.test.js DELETED
@@ -1,99 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { main } from "./bin.js";
3
- import { CliError } from "./errors.js";
4
- describe("candidate npm Skill command entry", () => {
5
- it("offers the short-lived manual URL even when browser dispatch reports success", async () => {
6
- const output = [];
7
- const code = await main(["install"], {
8
- install: (options) => {
9
- const launcherOptions = options?.launcherOptionsFactory?.({});
10
- const manualLink = launcherOptions?.browserManualLink;
11
- manualLink?.("https://example.invalid/connect-codex?challenge=once");
12
- return Promise.resolve({
13
- status: "connected",
14
- installation: "installed",
15
- version: "1.1.16",
16
- });
17
- },
18
- output: (line) => output.push(line),
19
- });
20
- expect(code).toBe(0);
21
- expect(output.join("")).toContain("如果没有看到授权网页");
22
- expect(output.join("")).toContain("challenge=once");
23
- });
24
- it("reports verified installation separately from a blocked device connection", async () => {
25
- const output = [];
26
- const errors = [];
27
- const code = await main(["install"], {
28
- install: (options) => {
29
- options?.reporter?.("installing");
30
- return Promise.resolve({
31
- status: "installed-unconnected",
32
- installation: "installed",
33
- version: "1.1.16",
34
- connectionError: "POWERSHELL_EXECUTION_POLICY_BLOCKED",
35
- });
36
- },
37
- output: (line) => output.push(line),
38
- error: (line) => errors.push(line),
39
- });
40
- expect(code).toBe(2);
41
- expect(output.join("")).toContain("正在安全安装");
42
- expect(errors.join("")).toContain("文件已安装,但设备尚未连接");
43
- expect(errors.join("")).toContain("脚本执行受到系统或组织策略限制");
44
- expect(errors.join("")).not.toContain("重新运行安装命令");
45
- });
46
- it("uses a failing installer exit code only for an actual installation rejection", async () => {
47
- const errors = [];
48
- const code = await main(["install"], {
49
- install: () => Promise.reject(new CliError("PACKAGE_VERIFICATION_FAILED")),
50
- error: (line) => errors.push(line),
51
- });
52
- expect(code).toBe(1);
53
- expect(errors).toEqual(["安装包签名或完整性验证失败,已停止安装。\n"]);
54
- expect(errors.join("")).not.toContain("PACKAGE_VERIFICATION_FAILED");
55
- });
56
- it("dispatches a public ability identity to the generic start path and returns only a verified path", async () => {
57
- const output = [];
58
- const errors = [];
59
- const calls = [];
60
- const code = await main(["start-skill", "skill.local-marker", "1.0.0"], {
61
- startSkill: (id, version) => {
62
- calls.push([id, version]);
63
- return Promise.resolve({
64
- id,
65
- version: version,
66
- skillPath: "C:/isolated/skills/local-marker/SKILL.md",
67
- reused: false,
68
- });
69
- },
70
- output: (line) => output.push(line),
71
- error: (line) => errors.push(line),
72
- });
73
- expect(code).toBe(0);
74
- expect(calls).toEqual([["skill.local-marker", "1.0.0"]]);
75
- expect(JSON.parse(output[0])).toEqual({
76
- status: "ready",
77
- id: "skill.local-marker",
78
- version: "1.0.0",
79
- skillPath: "C:/isolated/skills/local-marker/SKILL.md",
80
- reused: false,
81
- });
82
- expect(errors).toEqual([]);
83
- });
84
- it("does not expose raw exceptions or accept extra command arguments", async () => {
85
- const errors = [];
86
- expect(await main(["start-skill", "skill.local-marker"], {
87
- startSkill: () => Promise.reject(new Error("private error and token")),
88
- error: (line) => errors.push(line),
89
- })).toBe(1);
90
- expect(JSON.parse(errors[0])).toEqual({
91
- error: { code: "SKILL_START_UNAVAILABLE" },
92
- });
93
- expect(errors[0]).not.toContain("private error");
94
- expect(await main(["start-skill", "skill.local-marker", "1.0.0", "secret"], {
95
- error: (line) => errors.push(line),
96
- })).toBe(1);
97
- expect(errors[1]).toContain("命令格式无效");
98
- });
99
- });