chatccc 0.2.243 → 0.2.245

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 (65) hide show
  1. package/README.md +6 -6
  2. package/bin/cccagent.mjs +17 -17
  3. package/deepccc-agent/README.md +14 -8
  4. package/deepccc-agent/bin/deepccc.mjs +26 -26
  5. package/deepccc-agent/os-prompts/darwin.md +8 -0
  6. package/deepccc-agent/os-prompts/linux.md +8 -0
  7. package/deepccc-agent/os-prompts/win32.md +9 -0
  8. package/deepccc-agent/package-lock.json +2 -2
  9. package/deepccc-agent/package.json +63 -62
  10. package/deepccc-agent/src/__tests__/chat-session.test.ts +682 -578
  11. package/deepccc-agent/src/__tests__/cli-json.test.ts +49 -49
  12. package/deepccc-agent/src/__tests__/config.test.ts +26 -26
  13. package/deepccc-agent/src/__tests__/context.test.ts +319 -319
  14. package/deepccc-agent/src/__tests__/file-tools.test.ts +240 -240
  15. package/deepccc-agent/src/__tests__/permissions.test.ts +195 -195
  16. package/deepccc-agent/src/__tests__/privacy.test.ts +8 -5
  17. package/deepccc-agent/src/__tests__/progress-reducer.test.ts +121 -121
  18. package/deepccc-agent/src/__tests__/session-search.test.ts +262 -262
  19. package/deepccc-agent/src/__tests__/session-select.test.ts +116 -116
  20. package/deepccc-agent/src/__tests__/sigint.test.ts +56 -56
  21. package/deepccc-agent/src/__tests__/skills.test.ts +284 -284
  22. package/deepccc-agent/src/__tests__/terminal-renderer.test.ts +247 -247
  23. package/deepccc-agent/src/__tests__/web-tools.test.ts +220 -220
  24. package/deepccc-agent/src/cli.ts +7 -6
  25. package/deepccc-agent/src/config.ts +88 -84
  26. package/deepccc-agent/src/context.ts +465 -465
  27. package/deepccc-agent/src/file-log.ts +38 -38
  28. package/deepccc-agent/src/index.ts +103 -36
  29. package/deepccc-agent/src/proc-tree-kill.ts +61 -61
  30. package/deepccc-agent/src/progress/cards-helpers.ts +76 -76
  31. package/deepccc-agent/src/progress/reducer.ts +113 -113
  32. package/deepccc-agent/src/progress/terminal-renderer.ts +294 -294
  33. package/deepccc-agent/src/progress/view.ts +77 -77
  34. package/deepccc-agent/src/raw-stream-log.ts +124 -124
  35. package/deepccc-agent/src/session-search.ts +370 -370
  36. package/deepccc-agent/src/session-select.ts +48 -48
  37. package/deepccc-agent/src/sigint.ts +50 -50
  38. package/deepccc-agent/src/skills.ts +205 -205
  39. package/deepccc-agent/src/web-tools.ts +313 -313
  40. package/deepccc-agent/tsconfig.build.json +13 -13
  41. package/deepccc-agent/tsconfig.json +13 -13
  42. package/deepccc-agent/vitest.config.ts +7 -7
  43. package/package.json +1 -1
  44. package/src/__tests__/builtin-chat-session.test.ts +522 -522
  45. package/src/__tests__/builtin-config.test.ts +26 -26
  46. package/src/__tests__/builtin-context.test.ts +319 -319
  47. package/src/__tests__/builtin-file-tools.test.ts +240 -240
  48. package/src/__tests__/builtin-permissions.test.ts +211 -211
  49. package/src/__tests__/builtin-session-search.test.ts +262 -262
  50. package/src/__tests__/builtin-session-select.test.ts +116 -116
  51. package/src/__tests__/builtin-sigint.test.ts +56 -56
  52. package/src/__tests__/builtin-skills.test.ts +284 -284
  53. package/src/__tests__/builtin-web-tools.test.ts +220 -220
  54. package/src/__tests__/ccc-adapter.test.ts +15 -0
  55. package/src/__tests__/config.test.ts +17 -17
  56. package/src/__tests__/progress-reducer.test.ts +121 -121
  57. package/src/__tests__/session-ccc-config.test.ts +45 -45
  58. package/src/__tests__/session.test.ts +369 -306
  59. package/src/adapters/adapter-interface.ts +8 -2
  60. package/src/adapters/ccc-adapter.ts +149 -145
  61. package/src/config-utils.ts +13 -13
  62. package/src/config.ts +13 -13
  63. package/src/progress/reducer.ts +113 -113
  64. package/src/session-chat-binding.ts +83 -83
  65. package/src/session.ts +323 -320
@@ -1,121 +1,121 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- import type { ChatEvent } from "../index.js";
4
- import { reduceProgress, summarizeToolInput, summarizeToolResult } from "../progress/reducer.js";
5
- import { progressView } from "../progress/view.js";
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 "../index.js";
4
+ import { reduceProgress, summarizeToolInput, summarizeToolResult } from "../progress/reducer.js";
5
+ import { progressView } from "../progress/view.js";
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
+ });