chatccc 0.2.230 → 0.2.232

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.
@@ -1,284 +1,284 @@
1
- import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
- import { mkdtempSync, rmSync, writeFileSync, mkdirSync, utimesSync } from "node:fs";
3
- import { homedir, tmpdir } from "node:os";
4
- import { join } from "node:path";
5
-
6
- import {
7
- normalizeSkillPathForPrompt,
8
- parseSkillFrontmatter,
9
- scanSkillsDirs,
10
- buildDefaultSkillDirs,
11
- buildSkillsIndexPrompt,
12
- buildSkillTemplate,
13
- type SkillDirSpec,
14
- type SkillSource,
15
- type SkillScope,
16
- } from "../builtin/skills.ts";
17
-
18
- let tempRoot: string;
19
-
20
- beforeEach(() => {
21
- tempRoot = mkdtempSync(join(tmpdir(), "deepccc-skills-"));
22
- });
23
-
24
- afterEach(() => {
25
- try {
26
- rmSync(tempRoot, { recursive: true, force: true });
27
- } catch {}
28
- });
29
-
30
- function makeSkill(specDir: string, name: string, description: string): string {
31
- const dir = join(specDir, name);
32
- mkdirSync(dir, { recursive: true });
33
- const skillPath = join(dir, "SKILL.md");
34
- writeFileSync(skillPath, `---\nname: ${name}\ndescription: ${description}\n---\n\nbody\n`, "utf8");
35
- return skillPath;
36
- }
37
-
38
- function spec(
39
- dir: string,
40
- source: SkillSource,
41
- scope: SkillScope = "global",
42
- ): SkillDirSpec {
43
- return { dir, source, scope };
44
- }
45
-
46
- describe("parseSkillFrontmatter", () => {
47
- it("parses name and description from frontmatter", () => {
48
- const content = [
49
- "---",
50
- "name: feishu-doc-download-md",
51
- "description: 下载飞书文档为 Markdown",
52
- "---",
53
- "",
54
- "# 正文",
55
- ].join("\n");
56
- expect(parseSkillFrontmatter(content)).toEqual({
57
- name: "feishu-doc-download-md",
58
- description: "下载飞书文档为 Markdown",
59
- });
60
- });
61
-
62
- it("returns null when there is no frontmatter", () => {
63
- expect(parseSkillFrontmatter("# just a heading")).toBeNull();
64
- });
65
-
66
- it("tolerates missing description", () => {
67
- expect(parseSkillFrontmatter("---\nname: minimal-skill\n---\n\nbody")).toEqual({
68
- name: "minimal-skill",
69
- description: "",
70
- });
71
- });
72
-
73
- it("handles CRLF line endings", () => {
74
- const content = "---\r\nname: crlf-skill\r\ndescription: CRLF 描述\r\n---\r\n\r\nbody";
75
- expect(parseSkillFrontmatter(content)).toEqual({
76
- name: "crlf-skill",
77
- description: "CRLF 描述",
78
- });
79
- });
80
- });
81
-
82
- describe("scanSkillsDirs priority matrix", () => {
83
- it("codex wins over cursor, cursor wins over claude for same-name skills", async () => {
84
- const claudeDir = join(tempRoot, "claude");
85
- const cursorDir = join(tempRoot, "cursor");
86
- const codexDir = join(tempRoot, "codex");
87
- makeSkill(claudeDir, "dupe", "claude version");
88
- makeSkill(cursorDir, "dupe", "cursor version");
89
- makeSkill(codexDir, "dupe", "codex version");
90
- makeSkill(codexDir, "only-codex", "codex only");
91
-
92
- const skills = await scanSkillsDirs([
93
- spec(claudeDir, "claude"),
94
- spec(cursorDir, "cursor"),
95
- spec(codexDir, "codex"),
96
- ]);
97
-
98
- const byName = new Map(skills.map((s) => [s.name, s]));
99
- expect(byName.get("dupe")?.description).toBe("codex version");
100
- expect(byName.get("dupe")?.source).toBe("codex");
101
- expect(byName.get("dupe")?.skillPath).toContain(join("codex", "dupe"));
102
- expect(byName.get("only-codex")?.source).toBe("codex");
103
- });
104
-
105
- it("project scope wins over global scope within the same source", async () => {
106
- const globalCodex = join(tempRoot, "codex-global");
107
- const projectCodex = join(tempRoot, "codex-project");
108
- makeSkill(globalCodex, "dup", "global version");
109
- makeSkill(projectCodex, "dup", "project version");
110
-
111
- const skills = await scanSkillsDirs([
112
- spec(globalCodex, "codex", "global"),
113
- spec(projectCodex, "codex", "project"),
114
- ]);
115
-
116
- const byName = new Map(skills.map((s) => [s.name, s]));
117
- expect(byName.get("dup")?.description).toBe("project version");
118
- expect(byName.get("dup")?.scope).toBe("project");
119
- });
120
-
121
- it("deepccc source has the highest priority over codex", async () => {
122
- const codexDir = join(tempRoot, "codex");
123
- const deepcccDir = join(tempRoot, "deepccc");
124
- makeSkill(codexDir, "dup", "from codex");
125
- makeSkill(deepcccDir, "dup", "from deepccc");
126
-
127
- const skills = await scanSkillsDirs([
128
- spec(codexDir, "codex"),
129
- spec(deepcccDir, "deepccc"),
130
- ]);
131
-
132
- expect(skills.find((s) => s.name === "dup")?.description).toBe("from deepccc");
133
- expect(skills.find((s) => s.name === "dup")?.source).toBe("deepccc");
134
- });
135
-
136
- it("skips hidden dirs, dirs without SKILL.md, and missing dirs", async () => {
137
- const dir = join(tempRoot, "src");
138
- mkdirSync(join(dir, ".system"), { recursive: true });
139
- writeFileSync(join(dir, ".system", "SKILL.md"), "---\nname: system-skill\ndescription: x\n---\n", "utf8");
140
- mkdirSync(join(dir, "no-skill-dir"));
141
-
142
- makeSkill(dir, "ok", "fine");
143
- const skills = await scanSkillsDirs([
144
- spec(join(tempRoot, "missing-dir"), "codex"),
145
- spec(dir, "codex"),
146
- ]);
147
-
148
- expect(skills).toHaveLength(1);
149
- expect(skills[0].name).toBe("ok");
150
- });
151
- });
152
-
153
- describe("scanSkillsDirs hot reload (mtime cache)", () => {
154
- it("re-reads a skill after its SKILL.md content changes", async () => {
155
- const dir = join(tempRoot, "src");
156
- const skillPath = makeSkill(dir, "live", "v1");
157
-
158
- const first = await scanSkillsDirs([spec(dir, "deepccc")]);
159
- expect(first.find((s) => s.name === "live")?.description).toBe("v1");
160
-
161
- writeFileSync(skillPath, "---\nname: live\ndescription: v2\n---\n\nbody\n", "utf8");
162
- utimesSync(skillPath, new Date(Date.now() + 3000), new Date(Date.now() + 3000)); // 强制 mtime 前进
163
-
164
- const second = await scanSkillsDirs([spec(dir, "deepccc")]);
165
- expect(second.find((s) => s.name === "live")?.description).toBe("v2");
166
- });
167
-
168
- it("new skill dirs are picked up on the next scan", async () => {
169
- const dir = join(tempRoot, "src");
170
- makeSkill(dir, "a", "A");
171
-
172
- const first = await scanSkillsDirs([spec(dir, "deepccc")]);
173
- expect(first).toHaveLength(1);
174
-
175
- makeSkill(dir, "b", "B"); // 新技能,无需改 mtime(目录枚举每次都做)
176
- const second = await scanSkillsDirs([spec(dir, "deepccc")]);
177
- expect(second.map((s) => s.name).sort()).toEqual(["a", "b"]);
178
- });
179
-
180
- it("unchanged skills return identical results across scans", async () => {
181
- const dir = join(tempRoot, "src");
182
- makeSkill(dir, "a", "A");
183
-
184
- const first = await scanSkillsDirs([spec(dir, "deepccc")]);
185
- const second = await scanSkillsDirs([spec(dir, "deepccc")]);
186
- expect(second).toEqual(first);
187
- });
188
- });
189
-
190
- describe("buildDefaultSkillDirs", () => {
191
- it("orders dirs low->high priority: claude < cursor < codex < deepccc, project after global", () => {
192
- const dirs = buildDefaultSkillDirs("C:/proj");
193
- expect(dirs.map((d) => `${d.source}:${d.scope}`)).toEqual([
194
- "claude:global",
195
- "claude:project",
196
- "cursor:global",
197
- "cursor:project",
198
- "codex:global",
199
- "codex:global",
200
- "codex:project",
201
- "deepccc:global",
202
- "deepccc:project",
203
- ]);
204
- });
205
-
206
- it("points codex global dirs at ~/.codex/skills and ~/.agents/skills", () => {
207
- const dirs = buildDefaultSkillDirs("C:/proj").filter((d) => d.source === "codex" && d.scope === "global");
208
- expect(dirs.map((d) => d.dir)).toEqual([
209
- join(require("node:os").homedir(), ".codex", "skills"),
210
- join(require("node:os").homedir(), ".agents", "skills"),
211
- ]);
212
- });
213
- });
214
-
215
- describe("normalizeSkillPathForPrompt", () => {
216
- it("abbreviates home-directory paths with ~ and normalizes separators", () => {
217
- const home = homedir();
218
- const abs = join(home, ".codex", "skills", "x", "SKILL.md");
219
- expect(normalizeSkillPathForPrompt(abs)).toBe("~/.codex/skills/x/SKILL.md");
220
- expect(normalizeSkillPathForPrompt(home)).toBe("~");
221
- });
222
-
223
- it("keeps paths outside the home directory unchanged (separators normalized)", () => {
224
- expect(normalizeSkillPathForPrompt("C:\\proj\\.claude\\skills\\x\\SKILL.md")).toBe(
225
- "C:/proj/.claude/skills/x/SKILL.md",
226
- );
227
- });
228
- });
229
-
230
- describe("buildSkillsIndexPrompt", () => {
231
- it("renders index with source markers and the skill creation convention", () => {
232
- const prompt = buildSkillsIndexPrompt([
233
- {
234
- name: "feishu-doc",
235
- description: "下载飞书文档",
236
- skillPath: "C:/x/feishu-doc/SKILL.md",
237
- source: "codex",
238
- scope: "global",
239
- },
240
- ]);
241
-
242
- expect(prompt).toContain("## Available Skills");
243
- expect(prompt).toContain("**feishu-doc**");
244
- expect(prompt).toContain("[codex:global]");
245
- expect(prompt).toContain("## Creating Skills");
246
- expect(prompt).toContain(".deepccc/skills");
247
- expect(prompt).toContain("read_file");
248
- });
249
-
250
- it("renders home-abbreviated skill paths so the prompt stays stable across machines", () => {
251
- const home = homedir();
252
- const prompt = buildSkillsIndexPrompt([
253
- {
254
- name: "demo",
255
- description: "d",
256
- skillPath: join(home, ".codex", "skills", "demo", "SKILL.md"),
257
- source: "codex",
258
- scope: "global",
259
- },
260
- ]);
261
-
262
- expect(prompt).toContain("~/.codex/skills/demo/SKILL.md");
263
- expect(prompt).not.toContain(home);
264
- });
265
-
266
- it("returns empty string for no skills", () => {
267
- expect(buildSkillsIndexPrompt([])).toBe("");
268
- });
269
- });
270
-
271
- describe("buildSkillTemplate", () => {
272
- it("renders a Codex-style SKILL.md with frontmatter", () => {
273
- const tpl = buildSkillTemplate("my-skill", "does something");
274
- expect(tpl.startsWith("---")).toBe(true);
275
- expect(tpl).toContain("name: my-skill");
276
- expect(tpl).toContain("description: does something");
277
- expect(tpl).toContain("# my-skill");
278
- });
279
-
280
- it("defaults description to empty when omitted", () => {
281
- const tpl = buildSkillTemplate("bare-skill", "");
282
- expect(tpl).toContain("description: ");
283
- });
284
- });
1
+ import { describe, it, expect, beforeEach, afterEach } from "vitest";
2
+ import { mkdtempSync, rmSync, writeFileSync, mkdirSync, utimesSync } from "node:fs";
3
+ import { homedir, tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+
6
+ import {
7
+ normalizeSkillPathForPrompt,
8
+ parseSkillFrontmatter,
9
+ scanSkillsDirs,
10
+ buildDefaultSkillDirs,
11
+ buildSkillsIndexPrompt,
12
+ buildSkillTemplate,
13
+ type SkillDirSpec,
14
+ type SkillSource,
15
+ type SkillScope,
16
+ } from "../builtin/skills.ts";
17
+
18
+ let tempRoot: string;
19
+
20
+ beforeEach(() => {
21
+ tempRoot = mkdtempSync(join(tmpdir(), "deepccc-skills-"));
22
+ });
23
+
24
+ afterEach(() => {
25
+ try {
26
+ rmSync(tempRoot, { recursive: true, force: true });
27
+ } catch {}
28
+ });
29
+
30
+ function makeSkill(specDir: string, name: string, description: string): string {
31
+ const dir = join(specDir, name);
32
+ mkdirSync(dir, { recursive: true });
33
+ const skillPath = join(dir, "SKILL.md");
34
+ writeFileSync(skillPath, `---\nname: ${name}\ndescription: ${description}\n---\n\nbody\n`, "utf8");
35
+ return skillPath;
36
+ }
37
+
38
+ function spec(
39
+ dir: string,
40
+ source: SkillSource,
41
+ scope: SkillScope = "global",
42
+ ): SkillDirSpec {
43
+ return { dir, source, scope };
44
+ }
45
+
46
+ describe("parseSkillFrontmatter", () => {
47
+ it("parses name and description from frontmatter", () => {
48
+ const content = [
49
+ "---",
50
+ "name: feishu-doc-download-md",
51
+ "description: 下载飞书文档为 Markdown",
52
+ "---",
53
+ "",
54
+ "# 正文",
55
+ ].join("\n");
56
+ expect(parseSkillFrontmatter(content)).toEqual({
57
+ name: "feishu-doc-download-md",
58
+ description: "下载飞书文档为 Markdown",
59
+ });
60
+ });
61
+
62
+ it("returns null when there is no frontmatter", () => {
63
+ expect(parseSkillFrontmatter("# just a heading")).toBeNull();
64
+ });
65
+
66
+ it("tolerates missing description", () => {
67
+ expect(parseSkillFrontmatter("---\nname: minimal-skill\n---\n\nbody")).toEqual({
68
+ name: "minimal-skill",
69
+ description: "",
70
+ });
71
+ });
72
+
73
+ it("handles CRLF line endings", () => {
74
+ const content = "---\r\nname: crlf-skill\r\ndescription: CRLF 描述\r\n---\r\n\r\nbody";
75
+ expect(parseSkillFrontmatter(content)).toEqual({
76
+ name: "crlf-skill",
77
+ description: "CRLF 描述",
78
+ });
79
+ });
80
+ });
81
+
82
+ describe("scanSkillsDirs priority matrix", () => {
83
+ it("codex wins over cursor, cursor wins over claude for same-name skills", async () => {
84
+ const claudeDir = join(tempRoot, "claude");
85
+ const cursorDir = join(tempRoot, "cursor");
86
+ const codexDir = join(tempRoot, "codex");
87
+ makeSkill(claudeDir, "dupe", "claude version");
88
+ makeSkill(cursorDir, "dupe", "cursor version");
89
+ makeSkill(codexDir, "dupe", "codex version");
90
+ makeSkill(codexDir, "only-codex", "codex only");
91
+
92
+ const skills = await scanSkillsDirs([
93
+ spec(claudeDir, "claude"),
94
+ spec(cursorDir, "cursor"),
95
+ spec(codexDir, "codex"),
96
+ ]);
97
+
98
+ const byName = new Map(skills.map((s) => [s.name, s]));
99
+ expect(byName.get("dupe")?.description).toBe("codex version");
100
+ expect(byName.get("dupe")?.source).toBe("codex");
101
+ expect(byName.get("dupe")?.skillPath).toContain(join("codex", "dupe"));
102
+ expect(byName.get("only-codex")?.source).toBe("codex");
103
+ });
104
+
105
+ it("project scope wins over global scope within the same source", async () => {
106
+ const globalCodex = join(tempRoot, "codex-global");
107
+ const projectCodex = join(tempRoot, "codex-project");
108
+ makeSkill(globalCodex, "dup", "global version");
109
+ makeSkill(projectCodex, "dup", "project version");
110
+
111
+ const skills = await scanSkillsDirs([
112
+ spec(globalCodex, "codex", "global"),
113
+ spec(projectCodex, "codex", "project"),
114
+ ]);
115
+
116
+ const byName = new Map(skills.map((s) => [s.name, s]));
117
+ expect(byName.get("dup")?.description).toBe("project version");
118
+ expect(byName.get("dup")?.scope).toBe("project");
119
+ });
120
+
121
+ it("deepccc source has the highest priority over codex", async () => {
122
+ const codexDir = join(tempRoot, "codex");
123
+ const deepcccDir = join(tempRoot, "deepccc");
124
+ makeSkill(codexDir, "dup", "from codex");
125
+ makeSkill(deepcccDir, "dup", "from deepccc");
126
+
127
+ const skills = await scanSkillsDirs([
128
+ spec(codexDir, "codex"),
129
+ spec(deepcccDir, "deepccc"),
130
+ ]);
131
+
132
+ expect(skills.find((s) => s.name === "dup")?.description).toBe("from deepccc");
133
+ expect(skills.find((s) => s.name === "dup")?.source).toBe("deepccc");
134
+ });
135
+
136
+ it("skips hidden dirs, dirs without SKILL.md, and missing dirs", async () => {
137
+ const dir = join(tempRoot, "src");
138
+ mkdirSync(join(dir, ".system"), { recursive: true });
139
+ writeFileSync(join(dir, ".system", "SKILL.md"), "---\nname: system-skill\ndescription: x\n---\n", "utf8");
140
+ mkdirSync(join(dir, "no-skill-dir"));
141
+
142
+ makeSkill(dir, "ok", "fine");
143
+ const skills = await scanSkillsDirs([
144
+ spec(join(tempRoot, "missing-dir"), "codex"),
145
+ spec(dir, "codex"),
146
+ ]);
147
+
148
+ expect(skills).toHaveLength(1);
149
+ expect(skills[0].name).toBe("ok");
150
+ });
151
+ });
152
+
153
+ describe("scanSkillsDirs hot reload (mtime cache)", () => {
154
+ it("re-reads a skill after its SKILL.md content changes", async () => {
155
+ const dir = join(tempRoot, "src");
156
+ const skillPath = makeSkill(dir, "live", "v1");
157
+
158
+ const first = await scanSkillsDirs([spec(dir, "deepccc")]);
159
+ expect(first.find((s) => s.name === "live")?.description).toBe("v1");
160
+
161
+ writeFileSync(skillPath, "---\nname: live\ndescription: v2\n---\n\nbody\n", "utf8");
162
+ utimesSync(skillPath, new Date(Date.now() + 3000), new Date(Date.now() + 3000)); // 强制 mtime 前进
163
+
164
+ const second = await scanSkillsDirs([spec(dir, "deepccc")]);
165
+ expect(second.find((s) => s.name === "live")?.description).toBe("v2");
166
+ });
167
+
168
+ it("new skill dirs are picked up on the next scan", async () => {
169
+ const dir = join(tempRoot, "src");
170
+ makeSkill(dir, "a", "A");
171
+
172
+ const first = await scanSkillsDirs([spec(dir, "deepccc")]);
173
+ expect(first).toHaveLength(1);
174
+
175
+ makeSkill(dir, "b", "B"); // 新技能,无需改 mtime(目录枚举每次都做)
176
+ const second = await scanSkillsDirs([spec(dir, "deepccc")]);
177
+ expect(second.map((s) => s.name).sort()).toEqual(["a", "b"]);
178
+ });
179
+
180
+ it("unchanged skills return identical results across scans", async () => {
181
+ const dir = join(tempRoot, "src");
182
+ makeSkill(dir, "a", "A");
183
+
184
+ const first = await scanSkillsDirs([spec(dir, "deepccc")]);
185
+ const second = await scanSkillsDirs([spec(dir, "deepccc")]);
186
+ expect(second).toEqual(first);
187
+ });
188
+ });
189
+
190
+ describe("buildDefaultSkillDirs", () => {
191
+ it("orders dirs low->high priority: claude < cursor < codex < deepccc, project after global", () => {
192
+ const dirs = buildDefaultSkillDirs("C:/proj");
193
+ expect(dirs.map((d) => `${d.source}:${d.scope}`)).toEqual([
194
+ "claude:global",
195
+ "claude:project",
196
+ "cursor:global",
197
+ "cursor:project",
198
+ "codex:global",
199
+ "codex:global",
200
+ "codex:project",
201
+ "deepccc:global",
202
+ "deepccc:project",
203
+ ]);
204
+ });
205
+
206
+ it("points codex global dirs at ~/.codex/skills and ~/.agents/skills", () => {
207
+ const dirs = buildDefaultSkillDirs("C:/proj").filter((d) => d.source === "codex" && d.scope === "global");
208
+ expect(dirs.map((d) => d.dir)).toEqual([
209
+ join(require("node:os").homedir(), ".codex", "skills"),
210
+ join(require("node:os").homedir(), ".agents", "skills"),
211
+ ]);
212
+ });
213
+ });
214
+
215
+ describe("normalizeSkillPathForPrompt", () => {
216
+ it("abbreviates home-directory paths with ~ and normalizes separators", () => {
217
+ const home = homedir();
218
+ const abs = join(home, ".codex", "skills", "x", "SKILL.md");
219
+ expect(normalizeSkillPathForPrompt(abs)).toBe("~/.codex/skills/x/SKILL.md");
220
+ expect(normalizeSkillPathForPrompt(home)).toBe("~");
221
+ });
222
+
223
+ it("keeps paths outside the home directory unchanged (separators normalized)", () => {
224
+ expect(normalizeSkillPathForPrompt("C:\\proj\\.claude\\skills\\x\\SKILL.md")).toBe(
225
+ "C:/proj/.claude/skills/x/SKILL.md",
226
+ );
227
+ });
228
+ });
229
+
230
+ describe("buildSkillsIndexPrompt", () => {
231
+ it("renders index with source markers and the skill creation convention", () => {
232
+ const prompt = buildSkillsIndexPrompt([
233
+ {
234
+ name: "feishu-doc",
235
+ description: "下载飞书文档",
236
+ skillPath: "C:/x/feishu-doc/SKILL.md",
237
+ source: "codex",
238
+ scope: "global",
239
+ },
240
+ ]);
241
+
242
+ expect(prompt).toContain("## Available Skills");
243
+ expect(prompt).toContain("**feishu-doc**");
244
+ expect(prompt).toContain("[codex:global]");
245
+ expect(prompt).toContain("## Creating Skills");
246
+ expect(prompt).toContain(".deepccc/skills");
247
+ expect(prompt).toContain("read_file");
248
+ });
249
+
250
+ it("renders home-abbreviated skill paths so the prompt stays stable across machines", () => {
251
+ const home = homedir();
252
+ const prompt = buildSkillsIndexPrompt([
253
+ {
254
+ name: "demo",
255
+ description: "d",
256
+ skillPath: join(home, ".codex", "skills", "demo", "SKILL.md"),
257
+ source: "codex",
258
+ scope: "global",
259
+ },
260
+ ]);
261
+
262
+ expect(prompt).toContain("~/.codex/skills/demo/SKILL.md");
263
+ expect(prompt).not.toContain(home);
264
+ });
265
+
266
+ it("returns empty string for no skills", () => {
267
+ expect(buildSkillsIndexPrompt([])).toBe("");
268
+ });
269
+ });
270
+
271
+ describe("buildSkillTemplate", () => {
272
+ it("renders a Codex-style SKILL.md with frontmatter", () => {
273
+ const tpl = buildSkillTemplate("my-skill", "does something");
274
+ expect(tpl.startsWith("---")).toBe(true);
275
+ expect(tpl).toContain("name: my-skill");
276
+ expect(tpl).toContain("description: does something");
277
+ expect(tpl).toContain("# my-skill");
278
+ });
279
+
280
+ it("defaults description to empty when omitted", () => {
281
+ const tpl = buildSkillTemplate("bare-skill", "");
282
+ expect(tpl).toContain("description: ");
283
+ });
284
+ });
@@ -71,6 +71,7 @@ describe("createCccAdapter", () => {
71
71
  }
72
72
 
73
73
  expect(messages).toEqual([
74
+ { type: "assistant", blocks: [{ type: "agent_status", status: "responding" }] },
74
75
  { type: "assistant", blocks: [{ type: "text", text: "hello" }] },
75
76
  { type: "assistant", blocks: [{ type: "text", text: " world" }] },
76
77
  { type: "assistant", blocks: [], isFinalResponse: true },
@@ -102,6 +103,7 @@ describe("createCccAdapter", () => {
102
103
  }
103
104
 
104
105
  expect(messages).toEqual([
106
+ { type: "assistant", blocks: [{ type: "agent_status", status: "responding" }] },
105
107
  {
106
108
  type: "assistant",
107
109
  blocks: [{ type: "tool_use", id: "call-1", name: "read_file", input: { path: "README.md" } }],
@@ -114,6 +116,38 @@ describe("createCccAdapter", () => {
114
116
  ]);
115
117
  });
116
118
 
119
+ it("maps DeepCCC compaction and generation phases to unified activity blocks", async () => {
120
+ const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
121
+ const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-status-"));
122
+ const adapter = createCccAdapter({
123
+ apiKey: "sk-test",
124
+ contextDir,
125
+ compactAtTokens: 1,
126
+ keepRecentMessages: 1,
127
+ });
128
+ const { sessionId } = await adapter.createSession("F:\\repo");
129
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("old") });
130
+ for await (const _message of adapter.prompt(sessionId, "old question", "F:\\repo")) {
131
+ // drain
132
+ }
133
+
134
+ generateTextMock.mockResolvedValueOnce({ text: "summary" });
135
+ streamTextMock.mockReturnValueOnce({ textStream: textStream("new") });
136
+ const messages = [];
137
+ for await (const message of adapter.prompt(sessionId, "new question", "F:\\repo")) {
138
+ messages.push(message);
139
+ }
140
+
141
+ expect(messages[0]).toEqual({
142
+ type: "assistant",
143
+ blocks: [{ type: "agent_status", status: "compacting" }],
144
+ });
145
+ expect(messages).toContainEqual({
146
+ type: "assistant",
147
+ blocks: [{ type: "agent_status", status: "responding" }],
148
+ });
149
+ });
150
+
117
151
  it("passes effort into ChatSession so streamText receives reasoningEffort", async () => {
118
152
  const { createCccAdapter } = await import("../adapters/ccc-adapter.ts");
119
153
  const contextDir = await mkdtemp(join(tmpdir(), "chatccc-ccc-adapter-effort-"));
@@ -9,6 +9,17 @@ function feed(events: ChatEvent[]) {
9
9
  }
10
10
 
11
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
+
12
23
  it("accumulates text via accumulated field", () => {
13
24
  const view = feed([
14
25
  { type: "text", text: "Hello", accumulated: "Hello" },