chatccc 0.2.243 → 0.2.244

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.
Files changed (59) hide show
  1. package/README.md +5 -5
  2. package/bin/cccagent.mjs +17 -17
  3. package/deepccc-agent/bin/deepccc.mjs +26 -26
  4. package/deepccc-agent/os-prompts/darwin.md +8 -0
  5. package/deepccc-agent/os-prompts/linux.md +8 -0
  6. package/deepccc-agent/os-prompts/win32.md +9 -0
  7. package/deepccc-agent/package.json +2 -1
  8. package/deepccc-agent/src/__tests__/chat-session.test.ts +39 -0
  9. package/deepccc-agent/src/__tests__/cli-json.test.ts +49 -49
  10. package/deepccc-agent/src/__tests__/config.test.ts +26 -26
  11. package/deepccc-agent/src/__tests__/context.test.ts +319 -319
  12. package/deepccc-agent/src/__tests__/file-tools.test.ts +240 -240
  13. package/deepccc-agent/src/__tests__/permissions.test.ts +195 -195
  14. package/deepccc-agent/src/__tests__/progress-reducer.test.ts +121 -121
  15. package/deepccc-agent/src/__tests__/session-search.test.ts +262 -262
  16. package/deepccc-agent/src/__tests__/session-select.test.ts +116 -116
  17. package/deepccc-agent/src/__tests__/sigint.test.ts +56 -56
  18. package/deepccc-agent/src/__tests__/skills.test.ts +284 -284
  19. package/deepccc-agent/src/__tests__/terminal-renderer.test.ts +247 -247
  20. package/deepccc-agent/src/__tests__/web-tools.test.ts +220 -220
  21. package/deepccc-agent/src/config.ts +84 -84
  22. package/deepccc-agent/src/context.ts +465 -465
  23. package/deepccc-agent/src/file-log.ts +38 -38
  24. package/deepccc-agent/src/index.ts +46 -16
  25. package/deepccc-agent/src/proc-tree-kill.ts +61 -61
  26. package/deepccc-agent/src/progress/cards-helpers.ts +76 -76
  27. package/deepccc-agent/src/progress/reducer.ts +113 -113
  28. package/deepccc-agent/src/progress/terminal-renderer.ts +294 -294
  29. package/deepccc-agent/src/progress/view.ts +77 -77
  30. package/deepccc-agent/src/raw-stream-log.ts +124 -124
  31. package/deepccc-agent/src/session-search.ts +370 -370
  32. package/deepccc-agent/src/session-select.ts +48 -48
  33. package/deepccc-agent/src/sigint.ts +50 -50
  34. package/deepccc-agent/src/skills.ts +205 -205
  35. package/deepccc-agent/src/web-tools.ts +313 -313
  36. package/deepccc-agent/tsconfig.build.json +13 -13
  37. package/deepccc-agent/tsconfig.json +13 -13
  38. package/deepccc-agent/vitest.config.ts +7 -7
  39. package/package.json +73 -73
  40. package/src/__tests__/builtin-chat-session.test.ts +522 -522
  41. package/src/__tests__/builtin-config.test.ts +26 -26
  42. package/src/__tests__/builtin-context.test.ts +319 -319
  43. package/src/__tests__/builtin-file-tools.test.ts +240 -240
  44. package/src/__tests__/builtin-permissions.test.ts +211 -211
  45. package/src/__tests__/builtin-session-search.test.ts +262 -262
  46. package/src/__tests__/builtin-session-select.test.ts +116 -116
  47. package/src/__tests__/builtin-sigint.test.ts +56 -56
  48. package/src/__tests__/builtin-skills.test.ts +284 -284
  49. package/src/__tests__/builtin-web-tools.test.ts +220 -220
  50. package/src/__tests__/config.test.ts +17 -17
  51. package/src/__tests__/progress-reducer.test.ts +121 -121
  52. package/src/__tests__/session-ccc-config.test.ts +45 -45
  53. package/src/__tests__/session.test.ts +298 -298
  54. package/src/adapters/ccc-adapter.ts +145 -145
  55. package/src/config-utils.ts +13 -13
  56. package/src/config.ts +13 -13
  57. package/src/progress/reducer.ts +113 -113
  58. package/src/session-chat-binding.ts +83 -83
  59. package/src/session.ts +311 -311
@@ -1,121 +1,121 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import type { ChatEvent } from "../../deepccc-agent/src/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("renders explicit compaction and generation phases", () => {
13
- const compacting = reduceProgress(
14
- progressView({ headerTitle: "Generating..." }),
15
- { type: "status", phase: "compacting" },
16
- );
17
- expect(compacting.headerTitle).toBe("压缩上下文中...");
18
-
19
- const generating = reduceProgress(compacting, { type: "status", phase: "generating" });
20
- expect(generating.headerTitle).toBe("生成回复中...");
21
- });
22
-
23
- it("accumulates text via accumulated field", () => {
24
- const view = feed([
25
- { type: "text", text: "Hello", accumulated: "Hello" },
26
- { type: "text", text: " world", accumulated: "Hello world" },
27
- ]);
28
- expect(view.text).toBe("Hello world");
29
- expect(view.status).toBe("generating");
30
- expect(view.showStop).toBe(true);
31
- });
32
-
33
- it("appends tool_use as running and resolves status on tool_result", () => {
34
- const view = feed([
35
- { type: "tool_use", id: "t1", name: "edit_file", input: { path: "a.ts" } },
36
- { type: "tool_result", tool_use_id: "t1", name: "edit_file", content: "ok", is_error: false },
37
- ]);
38
- expect(view.tools).toHaveLength(1);
39
- expect(view.tools[0]).toMatchObject({
40
- id: "t1",
41
- name: "edit_file",
42
- status: "ok",
43
- summary: "ok",
44
- });
45
- });
46
-
47
- it("marks tool as error when is_error is true", () => {
48
- const view = feed([
49
- { type: "tool_use", id: "t2", name: "run_command", input: { command: "npm test" } },
50
- { type: "tool_result", tool_use_id: "t2", name: "run_command", content: "boom", is_error: true },
51
- ]);
52
- expect(view.tools[0].status).toBe("error");
53
- expect(view.tools[0].summary).toBe("boom");
54
- });
55
-
56
- it("falls back to last running tool when tool_use_id mismatches", () => {
57
- const view = feed([
58
- { type: "tool_use", id: undefined, name: "list_dir", input: {} },
59
- { type: "tool_result", tool_use_id: "unknown-id", name: "list_dir", content: "ok", is_error: false },
60
- ]);
61
- expect(view.tools[0].status).toBe("ok");
62
- });
63
-
64
- it("keeps multiple tool calls independently", () => {
65
- const view = feed([
66
- { type: "tool_use", id: "a", name: "read_file", input: { path: "a" } },
67
- { type: "tool_use", id: "b", name: "read_file", input: { path: "b" } },
68
- { type: "tool_result", tool_use_id: "b", name: "read_file", content: "bb", is_error: false },
69
- ]);
70
- expect(view.tools[0].status).toBe("running");
71
- expect(view.tools[1].status).toBe("ok");
72
- });
73
-
74
- it("marks done: status done, showStop false, text finalized", () => {
75
- const view = feed([
76
- { type: "text", text: "part", accumulated: "part" },
77
- { type: "done", text: "final answer" },
78
- ]);
79
- expect(view.status).toBe("done");
80
- expect(view.showStop).toBe(false);
81
- expect(view.text).toBe("final answer");
82
- });
83
-
84
- it("marks error status and keeps text", () => {
85
- const view = feed([
86
- { type: "text", text: "x", accumulated: "x" },
87
- { type: "error", message: "boom" },
88
- ]);
89
- expect(view.status).toBe("error");
90
- expect(view.showStop).toBe(false);
91
- expect(view.text).toBe("x");
92
- });
93
-
94
- it("ignores compact events without changing the view identity", () => {
95
- const base = progressView({ headerTitle: "生成中..." });
96
- const result = reduceProgress(base, { type: "compact", compactedMessages: 5 });
97
- expect(result).toBe(base);
98
- });
99
-
100
- it("does not mutate the previous view (immutable updates)", () => {
101
- const base = progressView({ headerTitle: "生成中..." });
102
- const next = reduceProgress(base, { type: "text", text: "hi", accumulated: "hi" });
103
- expect(base.text).toBe("");
104
- expect(next.text).toBe("hi");
105
- expect(next).not.toBe(base);
106
- });
107
- });
108
-
109
- describe("summarizeToolInput / summarizeToolResult", () => {
110
- it("flattens multiline input to one line", () => {
111
- const s = summarizeToolInput({ path: "a\nb", big: "x".repeat(200) });
112
- expect(s).not.toContain("\n");
113
- expect(s.length).toBeLessThanOrEqual(121);
114
- expect(s.endsWith("…")).toBe(true);
115
- });
116
-
117
- it("takes first line of result content", () => {
118
- expect(summarizeToolResult("line1\nline2\n")).toBe("line1");
119
- expect(summarizeToolResult({ ok: true })).toBe('{"ok":true}');
120
- });
121
- });
1
+ import { describe, expect, it } from "vitest";
2
+
3
+ import type { ChatEvent } from "../../deepccc-agent/src/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("renders explicit compaction and generation phases", () => {
13
+ const compacting = reduceProgress(
14
+ progressView({ headerTitle: "Generating..." }),
15
+ { type: "status", phase: "compacting" },
16
+ );
17
+ expect(compacting.headerTitle).toBe("压缩上下文中...");
18
+
19
+ const generating = reduceProgress(compacting, { type: "status", phase: "generating" });
20
+ expect(generating.headerTitle).toBe("生成回复中...");
21
+ });
22
+
23
+ it("accumulates text via accumulated field", () => {
24
+ const view = feed([
25
+ { type: "text", text: "Hello", accumulated: "Hello" },
26
+ { type: "text", text: " world", accumulated: "Hello world" },
27
+ ]);
28
+ expect(view.text).toBe("Hello world");
29
+ expect(view.status).toBe("generating");
30
+ expect(view.showStop).toBe(true);
31
+ });
32
+
33
+ it("appends tool_use as running and resolves status on tool_result", () => {
34
+ const view = feed([
35
+ { type: "tool_use", id: "t1", name: "edit_file", input: { path: "a.ts" } },
36
+ { type: "tool_result", tool_use_id: "t1", name: "edit_file", content: "ok", is_error: false },
37
+ ]);
38
+ expect(view.tools).toHaveLength(1);
39
+ expect(view.tools[0]).toMatchObject({
40
+ id: "t1",
41
+ name: "edit_file",
42
+ status: "ok",
43
+ summary: "ok",
44
+ });
45
+ });
46
+
47
+ it("marks tool as error when is_error is true", () => {
48
+ const view = feed([
49
+ { type: "tool_use", id: "t2", name: "run_command", input: { command: "npm test" } },
50
+ { type: "tool_result", tool_use_id: "t2", name: "run_command", content: "boom", is_error: true },
51
+ ]);
52
+ expect(view.tools[0].status).toBe("error");
53
+ expect(view.tools[0].summary).toBe("boom");
54
+ });
55
+
56
+ it("falls back to last running tool when tool_use_id mismatches", () => {
57
+ const view = feed([
58
+ { type: "tool_use", id: undefined, name: "list_dir", input: {} },
59
+ { type: "tool_result", tool_use_id: "unknown-id", name: "list_dir", content: "ok", is_error: false },
60
+ ]);
61
+ expect(view.tools[0].status).toBe("ok");
62
+ });
63
+
64
+ it("keeps multiple tool calls independently", () => {
65
+ const view = feed([
66
+ { type: "tool_use", id: "a", name: "read_file", input: { path: "a" } },
67
+ { type: "tool_use", id: "b", name: "read_file", input: { path: "b" } },
68
+ { type: "tool_result", tool_use_id: "b", name: "read_file", content: "bb", is_error: false },
69
+ ]);
70
+ expect(view.tools[0].status).toBe("running");
71
+ expect(view.tools[1].status).toBe("ok");
72
+ });
73
+
74
+ it("marks done: status done, showStop false, text finalized", () => {
75
+ const view = feed([
76
+ { type: "text", text: "part", accumulated: "part" },
77
+ { type: "done", text: "final answer" },
78
+ ]);
79
+ expect(view.status).toBe("done");
80
+ expect(view.showStop).toBe(false);
81
+ expect(view.text).toBe("final answer");
82
+ });
83
+
84
+ it("marks error status and keeps text", () => {
85
+ const view = feed([
86
+ { type: "text", text: "x", accumulated: "x" },
87
+ { type: "error", message: "boom" },
88
+ ]);
89
+ expect(view.status).toBe("error");
90
+ expect(view.showStop).toBe(false);
91
+ expect(view.text).toBe("x");
92
+ });
93
+
94
+ it("ignores compact events without changing the view identity", () => {
95
+ const base = progressView({ headerTitle: "生成中..." });
96
+ const result = reduceProgress(base, { type: "compact", compactedMessages: 5 });
97
+ expect(result).toBe(base);
98
+ });
99
+
100
+ it("does not mutate the previous view (immutable updates)", () => {
101
+ const base = progressView({ headerTitle: "生成中..." });
102
+ const next = reduceProgress(base, { type: "text", text: "hi", accumulated: "hi" });
103
+ expect(base.text).toBe("");
104
+ expect(next.text).toBe("hi");
105
+ expect(next).not.toBe(base);
106
+ });
107
+ });
108
+
109
+ describe("summarizeToolInput / summarizeToolResult", () => {
110
+ it("flattens multiline input to one line", () => {
111
+ const s = summarizeToolInput({ path: "a\nb", big: "x".repeat(200) });
112
+ expect(s).not.toContain("\n");
113
+ expect(s.length).toBeLessThanOrEqual(121);
114
+ expect(s.endsWith("…")).toBe(true);
115
+ });
116
+
117
+ it("takes first line of result content", () => {
118
+ expect(summarizeToolResult("line1\nline2\n")).toBe("line1");
119
+ expect(summarizeToolResult({ ok: true })).toBe('{"ok":true}');
120
+ });
121
+ });
@@ -1,45 +1,45 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
-
3
- const createCccAdapterMock = vi.hoisted(() => vi.fn(() => ({
4
- displayName: "CCC Agent",
5
- sessionDescPrefix: "CCC Session:",
6
- createSession: vi.fn(),
7
- prompt: vi.fn(),
8
- getSessionInfo: vi.fn(),
9
- closeSession: vi.fn(),
10
- })));
11
-
12
- vi.mock("../adapters/ccc-adapter.ts", () => ({
13
- createCccAdapter: createCccAdapterMock,
14
- }));
15
-
16
- import { config } from "../config.ts";
17
- import { _clearAdapterCacheForTest, getAdapterForTool } from "../session.ts";
18
-
19
- describe("CCC Agent ChatCCC configuration", () => {
20
- const original = { ...config.ccc };
21
-
22
- afterEach(() => {
23
- Object.assign(config.ccc, original);
24
- _clearAdapterCacheForTest();
25
- createCccAdapterMock.mockClear();
26
- });
27
-
28
- it("injects ChatCCC credentials and endpoint instead of relying on ~/.deepccc", () => {
29
- Object.assign(config.ccc, {
30
- DEEPSEEK_API_KEY: "chatccc-api-key",
31
- DEEPSEEK_BASE_URL: "https://chatccc.example.com/v1",
32
- model: "chatccc-model",
33
- effort: "high",
34
- });
35
-
36
- getAdapterForTool("ccc");
37
-
38
- expect(createCccAdapterMock).toHaveBeenCalledWith({
39
- apiKey: "chatccc-api-key",
40
- baseURL: "https://chatccc.example.com/v1",
41
- model: "chatccc-model",
42
- effort: "high",
43
- });
44
- });
45
- });
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+
3
+ const createCccAdapterMock = vi.hoisted(() => vi.fn(() => ({
4
+ displayName: "CCC Agent",
5
+ sessionDescPrefix: "CCC Session:",
6
+ createSession: vi.fn(),
7
+ prompt: vi.fn(),
8
+ getSessionInfo: vi.fn(),
9
+ closeSession: vi.fn(),
10
+ })));
11
+
12
+ vi.mock("../adapters/ccc-adapter.ts", () => ({
13
+ createCccAdapter: createCccAdapterMock,
14
+ }));
15
+
16
+ import { config } from "../config.ts";
17
+ import { _clearAdapterCacheForTest, getAdapterForTool } from "../session.ts";
18
+
19
+ describe("CCC Agent ChatCCC configuration", () => {
20
+ const original = { ...config.ccc };
21
+
22
+ afterEach(() => {
23
+ Object.assign(config.ccc, original);
24
+ _clearAdapterCacheForTest();
25
+ createCccAdapterMock.mockClear();
26
+ });
27
+
28
+ it("injects ChatCCC credentials and endpoint instead of relying on ~/.deepccc", () => {
29
+ Object.assign(config.ccc, {
30
+ DEEPSEEK_API_KEY: "chatccc-api-key",
31
+ DEEPSEEK_BASE_URL: "https://chatccc.example.com/v1",
32
+ model: "chatccc-model",
33
+ effort: "high",
34
+ });
35
+
36
+ getAdapterForTool("ccc");
37
+
38
+ expect(createCccAdapterMock).toHaveBeenCalledWith({
39
+ apiKey: "chatccc-api-key",
40
+ baseURL: "https://chatccc.example.com/v1",
41
+ model: "chatccc-model",
42
+ effort: "high",
43
+ });
44
+ });
45
+ });