chatccc 0.2.226 → 0.2.227
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/.agents/skills/create-chatccc-feishu-app/SKILL.md +85 -85
- package/.claude/skills/create-chatccc-feishu-app/SKILL.md +85 -85
- package/.cursor/skills/create-chatccc-feishu-app/SKILL.md +85 -85
- package/README.md +90 -90
- package/package.json +1 -1
- package/src/__tests__/agent-activity.test.ts +76 -76
- package/src/__tests__/builtin-chat-session.test.ts +350 -350
- package/src/__tests__/builtin-config.test.ts +26 -26
- package/src/__tests__/builtin-context.test.ts +163 -163
- package/src/__tests__/builtin-file-tools.test.ts +275 -275
- package/src/__tests__/builtin-permissions.test.ts +211 -211
- package/src/__tests__/builtin-session-select.test.ts +116 -116
- package/src/__tests__/builtin-skills.test.ts +185 -74
- package/src/__tests__/card-action-routing.test.ts +18 -18
- package/src/__tests__/ccc-adapter.test.ts +136 -136
- package/src/__tests__/claude-adapter.test.ts +614 -614
- package/src/__tests__/codex-adapter.test.ts +58 -58
- package/src/__tests__/codex-raw-stream-log.test.ts +170 -170
- package/src/__tests__/cursor-adapter.test.ts +268 -268
- package/src/__tests__/feishu-avatar.test.ts +164 -164
- package/src/__tests__/feishu-message-ingress.test.ts +138 -138
- package/src/__tests__/package-files.test.ts +24 -24
- package/src/__tests__/progress-reducer.test.ts +110 -110
- package/src/__tests__/response-stall.test.ts +49 -49
- package/src/__tests__/sim-platform.test.ts +16 -16
- package/src/__tests__/startup-lifecycle.test.ts +231 -231
- package/src/__tests__/stop-session.test.ts +34 -34
- package/src/__tests__/terminal-renderer.test.ts +247 -247
- package/src/__tests__/update-command-guard.test.ts +144 -144
- package/src/__tests__/web-ui.test.ts +326 -326
- package/src/adapters/adapter-interface.ts +18 -18
- package/src/adapters/ccc-adapter.ts +131 -131
- package/src/adapters/claude-adapter.ts +620 -620
- package/src/adapters/codex-adapter.ts +426 -426
- package/src/adapters/cursor-adapter.ts +681 -681
- package/src/agent-activity.ts +170 -170
- package/src/agent-delegate-task.ts +91 -91
- package/src/builtin/cli.ts +61 -2
- package/src/builtin/config.ts +84 -84
- package/src/builtin/context.ts +323 -323
- package/src/builtin/file-log.ts +38 -38
- package/src/builtin/index.ts +44 -24
- package/src/builtin/proc-tree-kill.ts +61 -61
- package/src/builtin/progress/cards-helpers.ts +76 -76
- package/src/builtin/progress/reducer.ts +108 -108
- package/src/builtin/progress/terminal-renderer.ts +294 -294
- package/src/builtin/progress/view.ts +77 -77
- package/src/builtin/raw-stream-log.ts +124 -124
- package/src/builtin/session-select.ts +48 -48
- package/src/builtin/skills.ts +126 -44
- package/src/card-action-routing.ts +14 -14
- package/src/feishu-api.ts +193 -193
- package/src/feishu-message-ingress.ts +195 -195
- package/src/index.ts +306 -306
- package/src/orchestrator.ts +2388 -2388
- package/src/platform-adapter.ts +6 -6
- package/src/progress/reducer.ts +108 -108
- package/src/progress/terminal-renderer.ts +294 -294
- package/src/progress/view.ts +77 -77
- package/src/response-stall.ts +28 -28
- package/src/session-chat-binding.ts +82 -82
- package/src/startup-lifecycle.ts +250 -250
- package/src/stream-state.ts +18 -18
- package/src/update-command-guard.ts +165 -165
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
|
|
6
|
-
const CREATE_APP_SKILL_DIRS = [
|
|
7
|
-
".agents/skills/create-chatccc-feishu-app/",
|
|
8
|
-
".claude/skills/create-chatccc-feishu-app/",
|
|
9
|
-
".cursor/skills/create-chatccc-feishu-app/",
|
|
10
|
-
];
|
|
11
|
-
|
|
12
|
-
describe("npm package files", () => {
|
|
13
|
-
it("ships the Feishu app creation skill for every supported agent", () => {
|
|
14
|
-
const root = process.cwd();
|
|
15
|
-
const packageJson = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
|
|
16
|
-
files?: string[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
for (const skillDir of CREATE_APP_SKILL_DIRS) {
|
|
20
|
-
expect(packageJson.files).toContain(skillDir);
|
|
21
|
-
expect(existsSync(join(root, skillDir, "SKILL.md"))).toBe(true);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
const CREATE_APP_SKILL_DIRS = [
|
|
7
|
+
".agents/skills/create-chatccc-feishu-app/",
|
|
8
|
+
".claude/skills/create-chatccc-feishu-app/",
|
|
9
|
+
".cursor/skills/create-chatccc-feishu-app/",
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
describe("npm package files", () => {
|
|
13
|
+
it("ships the Feishu app creation skill for every supported agent", () => {
|
|
14
|
+
const root = process.cwd();
|
|
15
|
+
const packageJson = JSON.parse(readFileSync(join(root, "package.json"), "utf8")) as {
|
|
16
|
+
files?: string[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
for (const skillDir of CREATE_APP_SKILL_DIRS) {
|
|
20
|
+
expect(packageJson.files).toContain(skillDir);
|
|
21
|
+
expect(existsSync(join(root, skillDir, "SKILL.md"))).toBe(true);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import type { ChatEvent } from "../builtin/index.ts";
|
|
4
|
-
import { reduceProgress, summarizeToolInput, summarizeToolResult } from "../progress/reducer.ts";
|
|
5
|
-
import { progressView } from "../progress/view.ts";
|
|
6
|
-
|
|
7
|
-
function feed(events: ChatEvent[]) {
|
|
8
|
-
return events.reduce(reduceProgress, progressView({ headerTitle: "生成中..." }));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
describe("reduceProgress", () => {
|
|
12
|
-
it("accumulates text via accumulated field", () => {
|
|
13
|
-
const view = feed([
|
|
14
|
-
{ type: "text", text: "Hello", accumulated: "Hello" },
|
|
15
|
-
{ type: "text", text: " world", accumulated: "Hello world" },
|
|
16
|
-
]);
|
|
17
|
-
expect(view.text).toBe("Hello world");
|
|
18
|
-
expect(view.status).toBe("generating");
|
|
19
|
-
expect(view.showStop).toBe(true);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("appends tool_use as running and resolves status on tool_result", () => {
|
|
23
|
-
const view = feed([
|
|
24
|
-
{ type: "tool_use", id: "t1", name: "edit_file", input: { path: "a.ts" } },
|
|
25
|
-
{ type: "tool_result", tool_use_id: "t1", name: "edit_file", content: "ok", is_error: false },
|
|
26
|
-
]);
|
|
27
|
-
expect(view.tools).toHaveLength(1);
|
|
28
|
-
expect(view.tools[0]).toMatchObject({
|
|
29
|
-
id: "t1",
|
|
30
|
-
name: "edit_file",
|
|
31
|
-
status: "ok",
|
|
32
|
-
summary: "ok",
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it("marks tool as error when is_error is true", () => {
|
|
37
|
-
const view = feed([
|
|
38
|
-
{ type: "tool_use", id: "t2", name: "run_command", input: { command: "npm test" } },
|
|
39
|
-
{ type: "tool_result", tool_use_id: "t2", name: "run_command", content: "boom", is_error: true },
|
|
40
|
-
]);
|
|
41
|
-
expect(view.tools[0].status).toBe("error");
|
|
42
|
-
expect(view.tools[0].summary).toBe("boom");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("falls back to last running tool when tool_use_id mismatches", () => {
|
|
46
|
-
const view = feed([
|
|
47
|
-
{ type: "tool_use", id: undefined, name: "list_dir", input: {} },
|
|
48
|
-
{ type: "tool_result", tool_use_id: "unknown-id", name: "list_dir", content: "ok", is_error: false },
|
|
49
|
-
]);
|
|
50
|
-
expect(view.tools[0].status).toBe("ok");
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it("keeps multiple tool calls independently", () => {
|
|
54
|
-
const view = feed([
|
|
55
|
-
{ type: "tool_use", id: "a", name: "read_file", input: { path: "a" } },
|
|
56
|
-
{ type: "tool_use", id: "b", name: "read_file", input: { path: "b" } },
|
|
57
|
-
{ type: "tool_result", tool_use_id: "b", name: "read_file", content: "bb", is_error: false },
|
|
58
|
-
]);
|
|
59
|
-
expect(view.tools[0].status).toBe("running");
|
|
60
|
-
expect(view.tools[1].status).toBe("ok");
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("marks done: status done, showStop false, text finalized", () => {
|
|
64
|
-
const view = feed([
|
|
65
|
-
{ type: "text", text: "part", accumulated: "part" },
|
|
66
|
-
{ type: "done", text: "final answer" },
|
|
67
|
-
]);
|
|
68
|
-
expect(view.status).toBe("done");
|
|
69
|
-
expect(view.showStop).toBe(false);
|
|
70
|
-
expect(view.text).toBe("final answer");
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("marks error status and keeps text", () => {
|
|
74
|
-
const view = feed([
|
|
75
|
-
{ type: "text", text: "x", accumulated: "x" },
|
|
76
|
-
{ type: "error", message: "boom" },
|
|
77
|
-
]);
|
|
78
|
-
expect(view.status).toBe("error");
|
|
79
|
-
expect(view.showStop).toBe(false);
|
|
80
|
-
expect(view.text).toBe("x");
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("ignores compact events without changing the view identity", () => {
|
|
84
|
-
const base = progressView({ headerTitle: "生成中..." });
|
|
85
|
-
const result = reduceProgress(base, { type: "compact", compactedMessages: 5 });
|
|
86
|
-
expect(result).toBe(base);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("does not mutate the previous view (immutable updates)", () => {
|
|
90
|
-
const base = progressView({ headerTitle: "生成中..." });
|
|
91
|
-
const next = reduceProgress(base, { type: "text", text: "hi", accumulated: "hi" });
|
|
92
|
-
expect(base.text).toBe("");
|
|
93
|
-
expect(next.text).toBe("hi");
|
|
94
|
-
expect(next).not.toBe(base);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
describe("summarizeToolInput / summarizeToolResult", () => {
|
|
99
|
-
it("flattens multiline input to one line", () => {
|
|
100
|
-
const s = summarizeToolInput({ path: "a\nb", big: "x".repeat(200) });
|
|
101
|
-
expect(s).not.toContain("\n");
|
|
102
|
-
expect(s.length).toBeLessThanOrEqual(121);
|
|
103
|
-
expect(s.endsWith("…")).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it("takes first line of result content", () => {
|
|
107
|
-
expect(summarizeToolResult("line1\nline2\n")).toBe("line1");
|
|
108
|
-
expect(summarizeToolResult({ ok: true })).toBe('{"ok":true}');
|
|
109
|
-
});
|
|
110
|
-
});
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import type { ChatEvent } from "../builtin/index.ts";
|
|
4
|
+
import { reduceProgress, summarizeToolInput, summarizeToolResult } from "../progress/reducer.ts";
|
|
5
|
+
import { progressView } from "../progress/view.ts";
|
|
6
|
+
|
|
7
|
+
function feed(events: ChatEvent[]) {
|
|
8
|
+
return events.reduce(reduceProgress, progressView({ headerTitle: "生成中..." }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
describe("reduceProgress", () => {
|
|
12
|
+
it("accumulates text via accumulated field", () => {
|
|
13
|
+
const view = feed([
|
|
14
|
+
{ type: "text", text: "Hello", accumulated: "Hello" },
|
|
15
|
+
{ type: "text", text: " world", accumulated: "Hello world" },
|
|
16
|
+
]);
|
|
17
|
+
expect(view.text).toBe("Hello world");
|
|
18
|
+
expect(view.status).toBe("generating");
|
|
19
|
+
expect(view.showStop).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("appends tool_use as running and resolves status on tool_result", () => {
|
|
23
|
+
const view = feed([
|
|
24
|
+
{ type: "tool_use", id: "t1", name: "edit_file", input: { path: "a.ts" } },
|
|
25
|
+
{ type: "tool_result", tool_use_id: "t1", name: "edit_file", content: "ok", is_error: false },
|
|
26
|
+
]);
|
|
27
|
+
expect(view.tools).toHaveLength(1);
|
|
28
|
+
expect(view.tools[0]).toMatchObject({
|
|
29
|
+
id: "t1",
|
|
30
|
+
name: "edit_file",
|
|
31
|
+
status: "ok",
|
|
32
|
+
summary: "ok",
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("marks tool as error when is_error is true", () => {
|
|
37
|
+
const view = feed([
|
|
38
|
+
{ type: "tool_use", id: "t2", name: "run_command", input: { command: "npm test" } },
|
|
39
|
+
{ type: "tool_result", tool_use_id: "t2", name: "run_command", content: "boom", is_error: true },
|
|
40
|
+
]);
|
|
41
|
+
expect(view.tools[0].status).toBe("error");
|
|
42
|
+
expect(view.tools[0].summary).toBe("boom");
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("falls back to last running tool when tool_use_id mismatches", () => {
|
|
46
|
+
const view = feed([
|
|
47
|
+
{ type: "tool_use", id: undefined, name: "list_dir", input: {} },
|
|
48
|
+
{ type: "tool_result", tool_use_id: "unknown-id", name: "list_dir", content: "ok", is_error: false },
|
|
49
|
+
]);
|
|
50
|
+
expect(view.tools[0].status).toBe("ok");
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("keeps multiple tool calls independently", () => {
|
|
54
|
+
const view = feed([
|
|
55
|
+
{ type: "tool_use", id: "a", name: "read_file", input: { path: "a" } },
|
|
56
|
+
{ type: "tool_use", id: "b", name: "read_file", input: { path: "b" } },
|
|
57
|
+
{ type: "tool_result", tool_use_id: "b", name: "read_file", content: "bb", is_error: false },
|
|
58
|
+
]);
|
|
59
|
+
expect(view.tools[0].status).toBe("running");
|
|
60
|
+
expect(view.tools[1].status).toBe("ok");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("marks done: status done, showStop false, text finalized", () => {
|
|
64
|
+
const view = feed([
|
|
65
|
+
{ type: "text", text: "part", accumulated: "part" },
|
|
66
|
+
{ type: "done", text: "final answer" },
|
|
67
|
+
]);
|
|
68
|
+
expect(view.status).toBe("done");
|
|
69
|
+
expect(view.showStop).toBe(false);
|
|
70
|
+
expect(view.text).toBe("final answer");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("marks error status and keeps text", () => {
|
|
74
|
+
const view = feed([
|
|
75
|
+
{ type: "text", text: "x", accumulated: "x" },
|
|
76
|
+
{ type: "error", message: "boom" },
|
|
77
|
+
]);
|
|
78
|
+
expect(view.status).toBe("error");
|
|
79
|
+
expect(view.showStop).toBe(false);
|
|
80
|
+
expect(view.text).toBe("x");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("ignores compact events without changing the view identity", () => {
|
|
84
|
+
const base = progressView({ headerTitle: "生成中..." });
|
|
85
|
+
const result = reduceProgress(base, { type: "compact", compactedMessages: 5 });
|
|
86
|
+
expect(result).toBe(base);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("does not mutate the previous view (immutable updates)", () => {
|
|
90
|
+
const base = progressView({ headerTitle: "生成中..." });
|
|
91
|
+
const next = reduceProgress(base, { type: "text", text: "hi", accumulated: "hi" });
|
|
92
|
+
expect(base.text).toBe("");
|
|
93
|
+
expect(next.text).toBe("hi");
|
|
94
|
+
expect(next).not.toBe(base);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe("summarizeToolInput / summarizeToolResult", () => {
|
|
99
|
+
it("flattens multiline input to one line", () => {
|
|
100
|
+
const s = summarizeToolInput({ path: "a\nb", big: "x".repeat(200) });
|
|
101
|
+
expect(s).not.toContain("\n");
|
|
102
|
+
expect(s.length).toBeLessThanOrEqual(121);
|
|
103
|
+
expect(s.endsWith("…")).toBe(true);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("takes first line of result content", () => {
|
|
107
|
+
expect(summarizeToolResult("line1\nline2\n")).toBe("line1");
|
|
108
|
+
expect(summarizeToolResult({ ok: true })).toBe('{"ok":true}');
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
hasResponseStalled,
|
|
5
|
-
observeResponseProgress,
|
|
6
|
-
} from "../response-stall.ts";
|
|
7
|
-
|
|
8
|
-
describe("response stall detection", () => {
|
|
9
|
-
it("starts tracking while responding even when the total character count is zero", () => {
|
|
10
|
-
const observation = observeResponseProgress(undefined, true, 0, 1_000);
|
|
11
|
-
|
|
12
|
-
expect(observation).toEqual({
|
|
13
|
-
totalChars: 0,
|
|
14
|
-
unchangedSince: 1_000,
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it("auto-ends only after the same character count has lasted three minutes", () => {
|
|
19
|
-
const first = observeResponseProgress(undefined, true, 12, 1_000);
|
|
20
|
-
const unchanged = observeResponseProgress(first, true, 12, 90_000);
|
|
21
|
-
|
|
22
|
-
expect(unchanged).toBe(first);
|
|
23
|
-
expect(hasResponseStalled(unchanged, 180_999, 180_000)).toBe(false);
|
|
24
|
-
expect(hasResponseStalled(unchanged, 181_000, 180_000)).toBe(true);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("restarts the timer whenever the total character count changes", () => {
|
|
28
|
-
const first = observeResponseProgress(undefined, true, 12, 1_000);
|
|
29
|
-
const changed = observeResponseProgress(first, true, 13, 150_000);
|
|
30
|
-
|
|
31
|
-
expect(changed).toEqual({
|
|
32
|
-
totalChars: 13,
|
|
33
|
-
unchangedSince: 150_000,
|
|
34
|
-
});
|
|
35
|
-
expect(hasResponseStalled(changed, 181_000, 180_000)).toBe(false);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("clears tracking outside responding and starts a fresh window after returning", () => {
|
|
39
|
-
const first = observeResponseProgress(undefined, true, 0, 1_000);
|
|
40
|
-
const cleared = observeResponseProgress(first, false, 0, 100_000);
|
|
41
|
-
const resumed = observeResponseProgress(cleared, true, 0, 200_000);
|
|
42
|
-
|
|
43
|
-
expect(cleared).toBeUndefined();
|
|
44
|
-
expect(resumed).toEqual({
|
|
45
|
-
totalChars: 0,
|
|
46
|
-
unchangedSince: 200_000,
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
hasResponseStalled,
|
|
5
|
+
observeResponseProgress,
|
|
6
|
+
} from "../response-stall.ts";
|
|
7
|
+
|
|
8
|
+
describe("response stall detection", () => {
|
|
9
|
+
it("starts tracking while responding even when the total character count is zero", () => {
|
|
10
|
+
const observation = observeResponseProgress(undefined, true, 0, 1_000);
|
|
11
|
+
|
|
12
|
+
expect(observation).toEqual({
|
|
13
|
+
totalChars: 0,
|
|
14
|
+
unchangedSince: 1_000,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("auto-ends only after the same character count has lasted three minutes", () => {
|
|
19
|
+
const first = observeResponseProgress(undefined, true, 12, 1_000);
|
|
20
|
+
const unchanged = observeResponseProgress(first, true, 12, 90_000);
|
|
21
|
+
|
|
22
|
+
expect(unchanged).toBe(first);
|
|
23
|
+
expect(hasResponseStalled(unchanged, 180_999, 180_000)).toBe(false);
|
|
24
|
+
expect(hasResponseStalled(unchanged, 181_000, 180_000)).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("restarts the timer whenever the total character count changes", () => {
|
|
28
|
+
const first = observeResponseProgress(undefined, true, 12, 1_000);
|
|
29
|
+
const changed = observeResponseProgress(first, true, 13, 150_000);
|
|
30
|
+
|
|
31
|
+
expect(changed).toEqual({
|
|
32
|
+
totalChars: 13,
|
|
33
|
+
unchangedSince: 150_000,
|
|
34
|
+
});
|
|
35
|
+
expect(hasResponseStalled(changed, 181_000, 180_000)).toBe(false);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("clears tracking outside responding and starts a fresh window after returning", () => {
|
|
39
|
+
const first = observeResponseProgress(undefined, true, 0, 1_000);
|
|
40
|
+
const cleared = observeResponseProgress(first, false, 0, 100_000);
|
|
41
|
+
const resumed = observeResponseProgress(cleared, true, 0, 200_000);
|
|
42
|
+
|
|
43
|
+
expect(cleared).toBeUndefined();
|
|
44
|
+
expect(resumed).toEqual({
|
|
45
|
+
totalChars: 0,
|
|
46
|
+
unchangedSince: 200_000,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -62,21 +62,21 @@ describe("SimulatedPlatform", () => {
|
|
|
62
62
|
await expect(SimulatedPlatform.setChatAvatar("t", "ch1", "claude", "busy")).resolves.toBeUndefined();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
it("纯函数 extractSessionInfo 正常工作", () => {
|
|
66
|
-
const result = SimulatedPlatform.extractSessionInfo("Claude Code Session: a1b2c3d4-e5f6-7890-abcd-ef1234567890");
|
|
67
|
-
expect(result).toEqual({ sessionId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", tool: "claude" });
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it("pure extractSessionInfo recognizes ccc session ids", () => {
|
|
71
|
-
const result = SimulatedPlatform.extractSessionInfo("CCC Session: session-20260702-121530-a1b2c3");
|
|
72
|
-
expect(result).toEqual({ sessionId: "session-20260702-121530-a1b2c3", tool: "ccc" });
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("纯函数 formatDelayNotice 正常工作", () => {
|
|
76
|
-
const notice = SimulatedPlatform.formatDelayNotice(Date.now() - 20 * 60 * 1000, "测试消息");
|
|
77
|
-
expect(notice).toBeDefined();
|
|
78
|
-
expect(notice).toContain("延迟送达");
|
|
79
|
-
expect(notice).not.toContain("因服务离线");
|
|
65
|
+
it("纯函数 extractSessionInfo 正常工作", () => {
|
|
66
|
+
const result = SimulatedPlatform.extractSessionInfo("Claude Code Session: a1b2c3d4-e5f6-7890-abcd-ef1234567890");
|
|
67
|
+
expect(result).toEqual({ sessionId: "a1b2c3d4-e5f6-7890-abcd-ef1234567890", tool: "claude" });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("pure extractSessionInfo recognizes ccc session ids", () => {
|
|
71
|
+
const result = SimulatedPlatform.extractSessionInfo("CCC Session: session-20260702-121530-a1b2c3");
|
|
72
|
+
expect(result).toEqual({ sessionId: "session-20260702-121530-a1b2c3", tool: "ccc" });
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("纯函数 formatDelayNotice 正常工作", () => {
|
|
76
|
+
const notice = SimulatedPlatform.formatDelayNotice(Date.now() - 20 * 60 * 1000, "测试消息");
|
|
77
|
+
expect(notice).toBeDefined();
|
|
78
|
+
expect(notice).toContain("延迟送达");
|
|
79
|
+
expect(notice).not.toContain("因服务离线");
|
|
80
80
|
// 近期消息不触发
|
|
81
81
|
expect(SimulatedPlatform.formatDelayNotice(Date.now(), "test")).toBeNull();
|
|
82
82
|
});
|
|
@@ -90,4 +90,4 @@ describe("SimulatedPlatform", () => {
|
|
|
90
90
|
// 未来时间戳(时钟偏移)不触发
|
|
91
91
|
expect(SimulatedPlatform.formatDelayNotice(now + 60 * 1000, "边界", now)).toBeNull();
|
|
92
92
|
});
|
|
93
|
-
});
|
|
93
|
+
});
|