chatccc 0.2.230 → 0.2.231

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 (116) hide show
  1. package/.agents/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  2. package/.claude/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  3. package/.cursor/skills/create-chatccc-feishu-app/SKILL.md +85 -85
  4. package/README.md +90 -90
  5. package/agent-prompts/claude_specific.md +45 -45
  6. package/agent-prompts/codex_specific.md +2 -2
  7. package/agent-prompts/cursor_specific.md +13 -13
  8. package/bin/cccagent.mjs +17 -17
  9. package/im-skills/feishu-skill/receive-send-file.md +63 -63
  10. package/im-skills/feishu-skill/receive-send-image.md +24 -24
  11. package/im-skills/feishu-skill/skill.md +3 -3
  12. package/im-skills/wechat-file-skill/receive-send-file.md +38 -38
  13. package/im-skills/wechat-file-skill/send-file.mjs +83 -83
  14. package/im-skills/wechat-file-skill/skill.md +10 -10
  15. package/im-skills/wechat-image-skill/skill.md +10 -10
  16. package/im-skills/wechat-video-skill/receive-send-video.md +38 -38
  17. package/im-skills/wechat-video-skill/send-video.mjs +79 -79
  18. package/im-skills/wechat-video-skill/skill.md +10 -10
  19. package/package.json +1 -1
  20. package/scripts/postinstall-sharp-check.mjs +58 -58
  21. package/src/__tests__/agent-activity.test.ts +86 -76
  22. package/src/__tests__/agent-delegate-task-rpc.test.ts +165 -165
  23. package/src/__tests__/agent-reload-config-rpc.test.ts +99 -99
  24. package/src/__tests__/builtin-chat-session.test.ts +65 -1
  25. package/src/__tests__/builtin-cli-json.test.ts +39 -39
  26. package/src/__tests__/builtin-config.test.ts +26 -26
  27. package/src/__tests__/builtin-context.test.ts +202 -163
  28. package/src/__tests__/builtin-permissions.test.ts +211 -211
  29. package/src/__tests__/builtin-session-select.test.ts +116 -116
  30. package/src/__tests__/builtin-sigint.test.ts +56 -56
  31. package/src/__tests__/builtin-web-tools.test.ts +220 -220
  32. package/src/__tests__/card-action-routing.test.ts +18 -18
  33. package/src/__tests__/cardkit.test.ts +60 -60
  34. package/src/__tests__/ccc-adapter.test.ts +170 -136
  35. package/src/__tests__/chatgpt-subscription-rpc.test.ts +89 -89
  36. package/src/__tests__/chatgpt-subscription.test.ts +135 -135
  37. package/src/__tests__/chrome-devtools-guard.test.ts +165 -165
  38. package/src/__tests__/claude-adapter.test.ts +614 -614
  39. package/src/__tests__/claude-raw-stream-log.test.ts +87 -87
  40. package/src/__tests__/codex-adapter.test.ts +58 -58
  41. package/src/__tests__/codex-raw-stream-log.test.ts +170 -170
  42. package/src/__tests__/codex-reset-actions.test.ts +146 -146
  43. package/src/__tests__/cursor-adapter.test.ts +268 -268
  44. package/src/__tests__/feishu-api.test.ts +60 -60
  45. package/src/__tests__/feishu-avatar.test.ts +164 -164
  46. package/src/__tests__/feishu-message-ingress.test.ts +138 -138
  47. package/src/__tests__/feishu-platform.test.ts +22 -22
  48. package/src/__tests__/format-message.test.ts +47 -47
  49. package/src/__tests__/jsonl-stream.test.ts +79 -79
  50. package/src/__tests__/package-files.test.ts +24 -24
  51. package/src/__tests__/privacy.test.ts +198 -198
  52. package/src/__tests__/progress-reducer.test.ts +121 -110
  53. package/src/__tests__/raw-stream-log.test.ts +106 -106
  54. package/src/__tests__/response-stall.test.ts +49 -49
  55. package/src/__tests__/session.test.ts +11 -16
  56. package/src/__tests__/shared-prefix.test.ts +36 -36
  57. package/src/__tests__/sim-platform.test.ts +16 -16
  58. package/src/__tests__/startup-lifecycle.test.ts +231 -231
  59. package/src/__tests__/stop-session.test.ts +34 -34
  60. package/src/__tests__/stream-state.test.ts +42 -42
  61. package/src/__tests__/terminal-renderer.test.ts +247 -247
  62. package/src/__tests__/update-command-guard.test.ts +144 -144
  63. package/src/__tests__/web-ui.test.ts +326 -326
  64. package/src/adapters/adapter-interface.ts +24 -18
  65. package/src/adapters/ccc-adapter.ts +141 -131
  66. package/src/adapters/claude-adapter.ts +620 -620
  67. package/src/adapters/claude-session-meta-store.ts +120 -120
  68. package/src/adapters/codex-adapter.ts +426 -426
  69. package/src/adapters/cursor-adapter.ts +681 -681
  70. package/src/adapters/jsonl-stream.ts +157 -157
  71. package/src/adapters/raw-stream-log.ts +124 -124
  72. package/src/adapters/resource-monitor.ts +140 -140
  73. package/src/agent-activity.ts +175 -170
  74. package/src/agent-delegate-task-rpc.ts +153 -153
  75. package/src/agent-delegate-task.ts +91 -91
  76. package/src/agent-reload-config-rpc.ts +34 -34
  77. package/src/agent-stop-stuck.ts +129 -129
  78. package/src/builtin/cli.ts +9 -2
  79. package/src/builtin/config.ts +84 -84
  80. package/src/builtin/context.ts +62 -4
  81. package/src/builtin/file-log.ts +38 -38
  82. package/src/builtin/index.ts +83 -19
  83. package/src/builtin/proc-tree-kill.ts +61 -61
  84. package/src/builtin/progress/cards-helpers.ts +76 -76
  85. package/src/builtin/progress/reducer.ts +113 -108
  86. package/src/builtin/progress/terminal-renderer.ts +294 -294
  87. package/src/builtin/progress/view.ts +77 -77
  88. package/src/builtin/raw-stream-log.ts +124 -124
  89. package/src/builtin/session-select.ts +48 -48
  90. package/src/builtin/sigint.ts +50 -50
  91. package/src/builtin/web-tools.ts +313 -313
  92. package/src/card-action-routing.ts +14 -14
  93. package/src/chatgpt-subscription-rpc.ts +27 -27
  94. package/src/chatgpt-subscription.ts +299 -299
  95. package/src/chrome-devtools-guard.ts +318 -318
  96. package/src/codex-reset-actions.ts +184 -184
  97. package/src/feishu-api.ts +193 -193
  98. package/src/feishu-message-ingress.ts +195 -195
  99. package/src/feishu-platform.ts +20 -20
  100. package/src/format-message.ts +293 -293
  101. package/src/litellm-proxy.ts +374 -374
  102. package/src/platform-adapter.ts +6 -6
  103. package/src/privacy.ts +118 -118
  104. package/src/progress/reducer.ts +113 -108
  105. package/src/progress/terminal-renderer.ts +294 -294
  106. package/src/progress/view.ts +77 -77
  107. package/src/response-stall.ts +28 -28
  108. package/src/runtime-reload.ts +34 -34
  109. package/src/session-chat-binding.ts +82 -82
  110. package/src/session-name.ts +8 -8
  111. package/src/session.ts +12 -11
  112. package/src/shared-prefix.ts +29 -29
  113. package/src/sim-platform.ts +20 -20
  114. package/src/startup-lifecycle.ts +250 -250
  115. package/src/turn-cards.ts +117 -117
  116. package/src/update-command-guard.ts +165 -165
@@ -1,87 +1,87 @@
1
- import { afterEach, describe, expect, it, vi } from "vitest";
2
-
3
- const resumeSessionMock = vi.hoisted(() => vi.fn());
4
- const createRawStreamLogMock = vi.hoisted(() => vi.fn());
5
- const rawLogWriteLineMock = vi.hoisted(() => vi.fn());
6
- const rawLogCloseMock = vi.hoisted(() => vi.fn());
7
-
8
- vi.mock("@anthropic-ai/claude-agent-sdk", () => ({
9
- getSessionInfo: vi.fn(),
10
- unstable_v2_createSession: vi.fn(),
11
- unstable_v2_resumeSession: resumeSessionMock,
12
- }));
13
-
14
- vi.mock("../adapters/raw-stream-log.ts", () => ({
15
- createRawStreamLog: createRawStreamLogMock,
16
- }));
17
-
18
- import { config } from "../config.ts";
19
- import { createClaudeAdapter } from "../adapters/claude-adapter.ts";
20
-
21
- const originalRawStreamLogs = structuredClone(config.rawStreamLogs);
22
-
23
- async function collect(iterable: AsyncIterable<unknown>): Promise<unknown[]> {
24
- const events: unknown[] = [];
25
- for await (const event of iterable) events.push(event);
26
- return events;
27
- }
28
-
29
- afterEach(() => {
30
- resumeSessionMock.mockReset();
31
- createRawStreamLogMock.mockReset();
32
- rawLogWriteLineMock.mockReset();
33
- rawLogCloseMock.mockReset();
34
- config.rawStreamLogs = structuredClone(originalRawStreamLogs);
35
- });
36
-
37
- describe("Claude raw stream logs", () => {
38
- it("writes raw Claude SDK stream messages when enabled", async () => {
39
- const rawMessages = [
40
- { type: "system", subtype: "init", session_id: "sid-raw", cwd: "F:/project", model: "claude-test" },
41
- { type: "assistant", message: { content: [{ type: "text", text: "hello" }] } },
42
- ];
43
- const session = {
44
- send: vi.fn(async () => {}),
45
- stream: async function* () {
46
- for (const msg of rawMessages) yield msg;
47
- },
48
- close: vi.fn(),
49
- };
50
- resumeSessionMock.mockReturnValueOnce(session);
51
- createRawStreamLogMock.mockResolvedValueOnce({
52
- filePath: "claude.jsonl.gz",
53
- writeLine: rawLogWriteLineMock,
54
- close: rawLogCloseMock,
55
- });
56
- config.rawStreamLogs.claude = {
57
- enabled: true,
58
- maxBytesPerTurn: 4096,
59
- retentionDays: 5,
60
- keepCompleted: false,
61
- };
62
-
63
- const adapter = createClaudeAdapter({
64
- model: "claude-test",
65
- effort: "high",
66
- isEmpty: (value) => value.trim() === "",
67
- });
68
- const events = await collect(adapter.prompt("sid-raw", "hi", "F:/project"));
69
-
70
- expect(createRawStreamLogMock).toHaveBeenCalledWith(expect.objectContaining({
71
- enabled: true,
72
- tool: "claude",
73
- sessionId: "sid-raw",
74
- label: "prompt",
75
- maxBytesPerTurn: 4096,
76
- retentionDays: 5,
77
- }));
78
- expect(rawLogWriteLineMock).toHaveBeenNthCalledWith(1, JSON.stringify(rawMessages[0]));
79
- expect(rawLogWriteLineMock).toHaveBeenNthCalledWith(2, JSON.stringify(rawMessages[1]));
80
- expect(rawLogCloseMock).toHaveBeenCalledWith({ keep: false });
81
- expect(session.close).toHaveBeenCalledOnce();
82
- expect(events).toContainEqual({
83
- type: "assistant",
84
- blocks: [{ type: "text", text: "hello" }],
85
- });
86
- });
87
- });
1
+ import { afterEach, describe, expect, it, vi } from "vitest";
2
+
3
+ const resumeSessionMock = vi.hoisted(() => vi.fn());
4
+ const createRawStreamLogMock = vi.hoisted(() => vi.fn());
5
+ const rawLogWriteLineMock = vi.hoisted(() => vi.fn());
6
+ const rawLogCloseMock = vi.hoisted(() => vi.fn());
7
+
8
+ vi.mock("@anthropic-ai/claude-agent-sdk", () => ({
9
+ getSessionInfo: vi.fn(),
10
+ unstable_v2_createSession: vi.fn(),
11
+ unstable_v2_resumeSession: resumeSessionMock,
12
+ }));
13
+
14
+ vi.mock("../adapters/raw-stream-log.ts", () => ({
15
+ createRawStreamLog: createRawStreamLogMock,
16
+ }));
17
+
18
+ import { config } from "../config.ts";
19
+ import { createClaudeAdapter } from "../adapters/claude-adapter.ts";
20
+
21
+ const originalRawStreamLogs = structuredClone(config.rawStreamLogs);
22
+
23
+ async function collect(iterable: AsyncIterable<unknown>): Promise<unknown[]> {
24
+ const events: unknown[] = [];
25
+ for await (const event of iterable) events.push(event);
26
+ return events;
27
+ }
28
+
29
+ afterEach(() => {
30
+ resumeSessionMock.mockReset();
31
+ createRawStreamLogMock.mockReset();
32
+ rawLogWriteLineMock.mockReset();
33
+ rawLogCloseMock.mockReset();
34
+ config.rawStreamLogs = structuredClone(originalRawStreamLogs);
35
+ });
36
+
37
+ describe("Claude raw stream logs", () => {
38
+ it("writes raw Claude SDK stream messages when enabled", async () => {
39
+ const rawMessages = [
40
+ { type: "system", subtype: "init", session_id: "sid-raw", cwd: "F:/project", model: "claude-test" },
41
+ { type: "assistant", message: { content: [{ type: "text", text: "hello" }] } },
42
+ ];
43
+ const session = {
44
+ send: vi.fn(async () => {}),
45
+ stream: async function* () {
46
+ for (const msg of rawMessages) yield msg;
47
+ },
48
+ close: vi.fn(),
49
+ };
50
+ resumeSessionMock.mockReturnValueOnce(session);
51
+ createRawStreamLogMock.mockResolvedValueOnce({
52
+ filePath: "claude.jsonl.gz",
53
+ writeLine: rawLogWriteLineMock,
54
+ close: rawLogCloseMock,
55
+ });
56
+ config.rawStreamLogs.claude = {
57
+ enabled: true,
58
+ maxBytesPerTurn: 4096,
59
+ retentionDays: 5,
60
+ keepCompleted: false,
61
+ };
62
+
63
+ const adapter = createClaudeAdapter({
64
+ model: "claude-test",
65
+ effort: "high",
66
+ isEmpty: (value) => value.trim() === "",
67
+ });
68
+ const events = await collect(adapter.prompt("sid-raw", "hi", "F:/project"));
69
+
70
+ expect(createRawStreamLogMock).toHaveBeenCalledWith(expect.objectContaining({
71
+ enabled: true,
72
+ tool: "claude",
73
+ sessionId: "sid-raw",
74
+ label: "prompt",
75
+ maxBytesPerTurn: 4096,
76
+ retentionDays: 5,
77
+ }));
78
+ expect(rawLogWriteLineMock).toHaveBeenNthCalledWith(1, JSON.stringify(rawMessages[0]));
79
+ expect(rawLogWriteLineMock).toHaveBeenNthCalledWith(2, JSON.stringify(rawMessages[1]));
80
+ expect(rawLogCloseMock).toHaveBeenCalledWith({ keep: false });
81
+ expect(session.close).toHaveBeenCalledOnce();
82
+ expect(events).toContainEqual({
83
+ type: "assistant",
84
+ blocks: [{ type: "text", text: "hello" }],
85
+ });
86
+ });
87
+ });
@@ -2,9 +2,9 @@ import { describe, it, expect } from "vitest";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { join, dirname } from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
- import {
6
- buildCodexInvocationArgs,
7
- normalizeCodexMessage,
5
+ import {
6
+ buildCodexInvocationArgs,
7
+ normalizeCodexMessage,
8
8
  createCodexAdapter,
9
9
  type CreateCodexAdapterOptions,
10
10
  } from "../adapters/codex-adapter.ts";
@@ -15,21 +15,21 @@ import {
15
15
  } from "../adapters/codex-session-meta-store.ts";
16
16
  import { accumulateBlockContent, pickFinalReply, type AccumulatorState } from "../session.ts";
17
17
 
18
- const __dirname = dirname(fileURLToPath(import.meta.url));
19
-
20
- describe("buildCodexInvocationArgs", () => {
21
- it("forces the priority service tier when Fast mode is on", () => {
22
- expect(buildCodexInvocationArgs(["exec", "--json"], "", "", true)).toContain(
23
- 'service_tier="fast"',
24
- );
25
- });
26
-
27
- it("forces the standard service tier when Fast mode is off", () => {
28
- const args = buildCodexInvocationArgs(["exec", "--json"], "", "", false);
29
- expect(args).toContain('service_tier="default"');
30
- expect(args).not.toContain('service_tier="fast"');
31
- });
32
- });
18
+ const __dirname = dirname(fileURLToPath(import.meta.url));
19
+
20
+ describe("buildCodexInvocationArgs", () => {
21
+ it("forces the priority service tier when Fast mode is on", () => {
22
+ expect(buildCodexInvocationArgs(["exec", "--json"], "", "", true)).toContain(
23
+ 'service_tier="fast"',
24
+ );
25
+ });
26
+
27
+ it("forces the standard service tier when Fast mode is off", () => {
28
+ const args = buildCodexInvocationArgs(["exec", "--json"], "", "", false);
29
+ expect(args).toContain('service_tier="default"');
30
+ expect(args).not.toContain('service_tier="fast"');
31
+ });
32
+ });
33
33
 
34
34
  function readFixture(name: string): unknown[] {
35
35
  const raw = readFileSync(join(__dirname, "fixtures", name), "utf-8");
@@ -71,16 +71,16 @@ function createInMemoryMetaStore(
71
71
  // ---------------------------------------------------------------------------
72
72
 
73
73
  describe("normalizeCodexMessage", () => {
74
- it("normalizes agent_message into assistant text block", () => {
75
- const result = normalizeCodexMessage({
76
- type: "item.completed",
77
- item: { id: "item_0", type: "agent_message", text: "hello" },
74
+ it("normalizes agent_message into assistant text block", () => {
75
+ const result = normalizeCodexMessage({
76
+ type: "item.completed",
77
+ item: { id: "item_0", type: "agent_message", text: "hello" },
78
78
  });
79
- expect(result).not.toBeNull();
80
- expect(result!.type).toBe("assistant");
81
- expect(result!.blocks).toEqual([{ type: "text", text: "hello" }]);
82
- expect(result!.isFinalResponse).toBeUndefined();
83
- });
79
+ expect(result).not.toBeNull();
80
+ expect(result!.type).toBe("assistant");
81
+ expect(result!.blocks).toEqual([{ type: "text", text: "hello" }]);
82
+ expect(result!.isFinalResponse).toBeUndefined();
83
+ });
84
84
 
85
85
  it("normalizes command_execution start into tool_use block", () => {
86
86
  const result = normalizeCodexMessage({
@@ -92,12 +92,12 @@ describe("normalizeCodexMessage", () => {
92
92
  status: "in_progress",
93
93
  },
94
94
  });
95
- expect(result).not.toBeNull();
96
- expect(result!.type).toBe("assistant");
97
- expect(result!.blocks).toEqual([
98
- { type: "tool_use", id: "item_0", name: "Bash", input: { command: "powershell.exe -Command ls" } },
99
- ]);
100
- });
95
+ expect(result).not.toBeNull();
96
+ expect(result!.type).toBe("assistant");
97
+ expect(result!.blocks).toEqual([
98
+ { type: "tool_use", id: "item_0", name: "Bash", input: { command: "powershell.exe -Command ls" } },
99
+ ]);
100
+ });
101
101
 
102
102
  it("normalizes command_execution completion as tool_result (success)", () => {
103
103
  const result = normalizeCodexMessage({
@@ -158,17 +158,17 @@ describe("normalizeCodexMessage", () => {
158
158
  expect(normalizeCodexMessage({ type: "turn.started" })).toBeNull();
159
159
  });
160
160
 
161
- it("marks turn.completed as the authoritative final response", () => {
162
- expect(
163
- normalizeCodexMessage({
164
- type: "turn.completed",
165
- usage: { input_tokens: 100, output_tokens: 50 },
166
- }),
167
- ).toEqual({
168
- type: "assistant",
169
- blocks: [],
170
- isFinalResponse: true,
171
- });
161
+ it("marks turn.completed as the authoritative final response", () => {
162
+ expect(
163
+ normalizeCodexMessage({
164
+ type: "turn.completed",
165
+ usage: { input_tokens: 100, output_tokens: 50 },
166
+ }),
167
+ ).toEqual({
168
+ type: "assistant",
169
+ blocks: [],
170
+ isFinalResponse: true,
171
+ });
172
172
  });
173
173
 
174
174
  it("returns null for unknown event types", () => {
@@ -244,7 +244,7 @@ describe("Codex stream fixtures", () => {
244
244
  expect(state.accumulatedContent).toContain("tool_test");
245
245
  });
246
246
 
247
- it("with tool: 普通输出不标终态,只有 turn.completed 标记终态", () => {
247
+ it("with tool: 普通输出不标终态,只有 turn.completed 标记终态", () => {
248
248
  const lines = readFixture("codex_with_tool.jsonl");
249
249
  const messages: UnifiedStreamMessage[] = [];
250
250
  for (const raw of lines) {
@@ -254,18 +254,18 @@ describe("Codex stream fixtures", () => {
254
254
  if (normalized) messages.push(normalized);
255
255
  }
256
256
 
257
- // 应有: tool_use + tool_result + text + turn.completed = 4 条消息
258
- expect(messages.length).toBe(4);
259
- expect(messages[0].blocks[0].type).toBe("tool_use");
260
- expect(messages[1].blocks[0].type).toBe("tool_result");
261
- expect(messages[2].blocks[0].type).toBe("text");
262
- expect(messages[2].isFinalResponse).toBeUndefined();
263
- expect(messages[3]).toEqual({
264
- type: "assistant",
265
- blocks: [],
266
- isFinalResponse: true,
267
- });
268
- });
257
+ // 应有: tool_use + tool_result + text + turn.completed = 4 条消息
258
+ expect(messages.length).toBe(4);
259
+ expect(messages[0].blocks[0].type).toBe("tool_use");
260
+ expect(messages[1].blocks[0].type).toBe("tool_result");
261
+ expect(messages[2].blocks[0].type).toBe("text");
262
+ expect(messages[2].isFinalResponse).toBeUndefined();
263
+ expect(messages[3]).toEqual({
264
+ type: "assistant",
265
+ blocks: [],
266
+ isFinalResponse: true,
267
+ });
268
+ });
269
269
  });
270
270
 
271
271
  // ---------------------------------------------------------------------------
@@ -328,4 +328,4 @@ describe("createCodexAdapter", () => {
328
328
  });
329
329
  expect(await adapter.getSessionInfo("sid-C")).toBeUndefined();
330
330
  });
331
- });
331
+ });