chatccc 0.2.224 → 0.2.226

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 (68) 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/package.json +1 -1
  6. package/src/__tests__/agent-activity.test.ts +76 -76
  7. package/src/__tests__/builtin-chat-session.test.ts +350 -350
  8. package/src/__tests__/builtin-config.test.ts +26 -37
  9. package/src/__tests__/builtin-context.test.ts +163 -163
  10. package/src/__tests__/builtin-file-tools.test.ts +275 -275
  11. package/src/__tests__/builtin-permissions.test.ts +211 -0
  12. package/src/__tests__/builtin-session-select.test.ts +116 -116
  13. package/src/__tests__/builtin-skills.test.ts +141 -141
  14. package/src/__tests__/card-action-routing.test.ts +18 -18
  15. package/src/__tests__/ccc-adapter.test.ts +136 -136
  16. package/src/__tests__/claude-adapter.test.ts +614 -614
  17. package/src/__tests__/codex-adapter.test.ts +58 -58
  18. package/src/__tests__/codex-raw-stream-log.test.ts +170 -170
  19. package/src/__tests__/cursor-adapter.test.ts +268 -268
  20. package/src/__tests__/feishu-avatar.test.ts +164 -164
  21. package/src/__tests__/feishu-message-ingress.test.ts +138 -138
  22. package/src/__tests__/package-files.test.ts +24 -24
  23. package/src/__tests__/progress-reducer.test.ts +110 -110
  24. package/src/__tests__/response-stall.test.ts +49 -49
  25. package/src/__tests__/sim-platform.test.ts +16 -16
  26. package/src/__tests__/startup-lifecycle.test.ts +231 -231
  27. package/src/__tests__/stop-session.test.ts +34 -34
  28. package/src/__tests__/terminal-renderer.test.ts +247 -143
  29. package/src/__tests__/update-command-guard.test.ts +144 -144
  30. package/src/__tests__/web-ui.test.ts +326 -323
  31. package/src/adapters/adapter-interface.ts +18 -18
  32. package/src/adapters/ccc-adapter.ts +131 -128
  33. package/src/adapters/claude-adapter.ts +620 -620
  34. package/src/adapters/codex-adapter.ts +426 -426
  35. package/src/adapters/cursor-adapter.ts +681 -681
  36. package/src/agent-activity.ts +170 -170
  37. package/src/agent-delegate-task.ts +91 -91
  38. package/src/builtin/cli.ts +598 -514
  39. package/src/builtin/config.ts +84 -0
  40. package/src/builtin/context.ts +323 -323
  41. package/src/builtin/file-log.ts +38 -0
  42. package/src/builtin/file-tools.ts +1407 -1320
  43. package/src/builtin/index.ts +437 -426
  44. package/src/builtin/permissions.ts +226 -0
  45. package/src/builtin/privacy.ts +141 -0
  46. package/src/builtin/proc-tree-kill.ts +61 -0
  47. package/src/builtin/progress/cards-helpers.ts +76 -0
  48. package/src/builtin/progress/reducer.ts +108 -0
  49. package/src/builtin/progress/terminal-renderer.ts +294 -0
  50. package/src/builtin/progress/view.ts +77 -0
  51. package/src/builtin/raw-stream-log.ts +124 -0
  52. package/src/builtin/session-select.ts +48 -48
  53. package/src/builtin/skills.ts +108 -108
  54. package/src/card-action-routing.ts +14 -14
  55. package/src/feishu-api.ts +193 -193
  56. package/src/feishu-message-ingress.ts +195 -195
  57. package/src/index.ts +306 -306
  58. package/src/orchestrator.ts +2388 -2388
  59. package/src/platform-adapter.ts +6 -6
  60. package/src/progress/reducer.ts +108 -108
  61. package/src/progress/terminal-renderer.ts +294 -190
  62. package/src/progress/view.ts +77 -77
  63. package/src/response-stall.ts +28 -28
  64. package/src/session-chat-binding.ts +82 -82
  65. package/src/startup-lifecycle.ts +250 -250
  66. package/src/stream-state.ts +18 -18
  67. package/src/update-command-guard.ts +165 -165
  68. package/src/web-ui.ts +18 -2
@@ -8,11 +8,11 @@
8
8
  import type { CursorUsageSummary } from "./cursor-usage.ts";
9
9
  import type { CodexUsageSummary } from "./feishu-api.ts";
10
10
 
11
- export interface ChatAvatarUsageHints {
12
- codexUsage?: CodexUsageSummary | null;
13
- cursorUsage?: CursorUsageSummary | null;
14
- fastMode?: boolean;
15
- }
11
+ export interface ChatAvatarUsageHints {
12
+ codexUsage?: CodexUsageSummary | null;
13
+ cursorUsage?: CursorUsageSummary | null;
14
+ fastMode?: boolean;
15
+ }
16
16
 
17
17
  export interface PlatformAdapter {
18
18
  /** 平台标识,用于区分不同平台的行为(如 wechat、feishu 等) */
@@ -67,4 +67,4 @@ export interface PlatformAdapter {
67
67
 
68
68
  /** 更新已发送的进度展示,sequence 保证有序 */
69
69
  cardUpdate(cardId: string, cardJson: string, sequence: number): Promise<void>;
70
- }
70
+ }
@@ -1,108 +1,108 @@
1
- /**
2
- * progress/reducer.ts — ChatEvent 事件流 → ProgressView 的增量合并
3
- *
4
- * 这是飞书与终端共享的唯一一份"事件 → 过程视图"公共逻辑:
5
- * 终端 REPL 直接消费 ChatSession.chat() 的事件流,逐条 reduce;
6
- * 飞书侧 display loop 若未来接入事件流,同样使用本 reducer,保证两端
7
- * 看到的过程状态(正文累积、工具调用、终态判定)完全一致。
8
- */
9
-
10
- import type { ChatEvent } from "../builtin/index.ts";
11
- import {
12
- withProgressView,
13
- type ProgressToolCall,
14
- type ProgressView,
15
- } from "./view.ts";
16
-
17
- /** 工具调用 input 单行摘要(终端折叠行展示用) */
18
- export function summarizeToolInput(input: unknown, maxChars = 120): string {
19
- let raw: string;
20
- if (typeof input === "string") {
21
- raw = input;
22
- } else {
23
- try {
24
- raw = JSON.stringify(input);
25
- } catch {
26
- raw = String(input);
27
- }
28
- }
29
- const oneLine = raw.replace(/\s+/g, " ").trim();
30
- return oneLine.length > maxChars ? oneLine.slice(0, maxChars) + "…" : oneLine;
31
- }
32
-
33
- /** 工具结果单行摘要(成功/失败各取首行) */
34
- export function summarizeToolResult(content: unknown, maxChars = 120): string {
35
- let raw: string;
36
- if (typeof content === "string") {
37
- raw = content;
38
- } else if (content instanceof Error) {
39
- raw = content.message;
40
- } else {
41
- try {
42
- raw = JSON.stringify(content);
43
- } catch {
44
- raw = String(content);
45
- }
46
- }
47
- const firstLine = raw.split("\n")[0] ?? "";
48
- return firstLine.length > maxChars ? firstLine.slice(0, maxChars) + "…" : firstLine;
49
- }
50
-
51
- /**
52
- * 把一条 ChatEvent 合并进 ProgressView,返回新视图(不可变更新)。
53
- * 未识别的/不影响展示的事件(如 compact)返回原视图。
54
- */
55
- export function reduceProgress(prev: ProgressView, event: ChatEvent): ProgressView {
56
- switch (event.type) {
57
- case "text":
58
- // accumulated 是全文累积,直接全量替换,天然幂等
59
- return withProgressView(prev, { text: event.accumulated });
60
-
61
- case "tool_use": {
62
- const tool: ProgressToolCall = {
63
- id: event.id ?? `tool-${prev.tools.length + 1}`,
64
- name: event.name,
65
- status: "running",
66
- detail: summarizeToolInput(event.input),
67
- };
68
- return withProgressView(prev, { tools: [...prev.tools, tool] });
69
- }
70
-
71
- case "tool_result": {
72
- const nextStatus = event.is_error ? ("error" as const) : ("ok" as const);
73
- const summary = summarizeToolResult(event.content);
74
- let matched = false;
75
- const tools = prev.tools.map((t) => {
76
- if (matched || t.id !== event.tool_use_id) return t;
77
- matched = true;
78
- return { ...t, status: nextStatus, summary };
79
- });
80
- if (!matched) {
81
- // id 缺失或失配:兜底更新最后一个 running 工具,避免状态悬挂
82
- const lastRunning = [...prev.tools].reverse().findIndex((t) => t.status === "running");
83
- if (lastRunning >= 0) {
84
- const idx = prev.tools.length - 1 - lastRunning;
85
- const updated = prev.tools.map((t, i) =>
86
- i === idx ? { ...t, status: nextStatus, summary } : t,
87
- );
88
- return withProgressView(prev, { tools: updated });
89
- }
90
- }
91
- return withProgressView(prev, { tools });
92
- }
93
-
94
- case "done":
95
- return withProgressView(prev, {
96
- status: "done",
97
- showStop: false,
98
- text: event.text,
99
- });
100
-
101
- case "error":
102
- return withProgressView(prev, { status: "error", showStop: false });
103
-
104
- case "compact":
105
- // 旧上下文压缩不影响当前过程展示
106
- return prev;
107
- }
108
- }
1
+ /**
2
+ * progress/reducer.ts — ChatEvent 事件流 → ProgressView 的增量合并
3
+ *
4
+ * 这是飞书与终端共享的唯一一份"事件 → 过程视图"公共逻辑:
5
+ * 终端 REPL 直接消费 ChatSession.chat() 的事件流,逐条 reduce;
6
+ * 飞书侧 display loop 若未来接入事件流,同样使用本 reducer,保证两端
7
+ * 看到的过程状态(正文累积、工具调用、终态判定)完全一致。
8
+ */
9
+
10
+ import type { ChatEvent } from "../builtin/index.ts";
11
+ import {
12
+ withProgressView,
13
+ type ProgressToolCall,
14
+ type ProgressView,
15
+ } from "./view.ts";
16
+
17
+ /** 工具调用 input 单行摘要(终端折叠行展示用) */
18
+ export function summarizeToolInput(input: unknown, maxChars = 120): string {
19
+ let raw: string;
20
+ if (typeof input === "string") {
21
+ raw = input;
22
+ } else {
23
+ try {
24
+ raw = JSON.stringify(input);
25
+ } catch {
26
+ raw = String(input);
27
+ }
28
+ }
29
+ const oneLine = raw.replace(/\s+/g, " ").trim();
30
+ return oneLine.length > maxChars ? oneLine.slice(0, maxChars) + "…" : oneLine;
31
+ }
32
+
33
+ /** 工具结果单行摘要(成功/失败各取首行) */
34
+ export function summarizeToolResult(content: unknown, maxChars = 120): string {
35
+ let raw: string;
36
+ if (typeof content === "string") {
37
+ raw = content;
38
+ } else if (content instanceof Error) {
39
+ raw = content.message;
40
+ } else {
41
+ try {
42
+ raw = JSON.stringify(content);
43
+ } catch {
44
+ raw = String(content);
45
+ }
46
+ }
47
+ const firstLine = raw.split("\n")[0] ?? "";
48
+ return firstLine.length > maxChars ? firstLine.slice(0, maxChars) + "…" : firstLine;
49
+ }
50
+
51
+ /**
52
+ * 把一条 ChatEvent 合并进 ProgressView,返回新视图(不可变更新)。
53
+ * 未识别的/不影响展示的事件(如 compact)返回原视图。
54
+ */
55
+ export function reduceProgress(prev: ProgressView, event: ChatEvent): ProgressView {
56
+ switch (event.type) {
57
+ case "text":
58
+ // accumulated 是全文累积,直接全量替换,天然幂等
59
+ return withProgressView(prev, { text: event.accumulated });
60
+
61
+ case "tool_use": {
62
+ const tool: ProgressToolCall = {
63
+ id: event.id ?? `tool-${prev.tools.length + 1}`,
64
+ name: event.name,
65
+ status: "running",
66
+ detail: summarizeToolInput(event.input),
67
+ };
68
+ return withProgressView(prev, { tools: [...prev.tools, tool] });
69
+ }
70
+
71
+ case "tool_result": {
72
+ const nextStatus = event.is_error ? ("error" as const) : ("ok" as const);
73
+ const summary = summarizeToolResult(event.content);
74
+ let matched = false;
75
+ const tools = prev.tools.map((t) => {
76
+ if (matched || t.id !== event.tool_use_id) return t;
77
+ matched = true;
78
+ return { ...t, status: nextStatus, summary };
79
+ });
80
+ if (!matched) {
81
+ // id 缺失或失配:兜底更新最后一个 running 工具,避免状态悬挂
82
+ const lastRunning = [...prev.tools].reverse().findIndex((t) => t.status === "running");
83
+ if (lastRunning >= 0) {
84
+ const idx = prev.tools.length - 1 - lastRunning;
85
+ const updated = prev.tools.map((t, i) =>
86
+ i === idx ? { ...t, status: nextStatus, summary } : t,
87
+ );
88
+ return withProgressView(prev, { tools: updated });
89
+ }
90
+ }
91
+ return withProgressView(prev, { tools });
92
+ }
93
+
94
+ case "done":
95
+ return withProgressView(prev, {
96
+ status: "done",
97
+ showStop: false,
98
+ text: event.text,
99
+ });
100
+
101
+ case "error":
102
+ return withProgressView(prev, { status: "error", showStop: false });
103
+
104
+ case "compact":
105
+ // 旧上下文压缩不影响当前过程展示
106
+ return prev;
107
+ }
108
+ }