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.
- package/README.md +5 -5
- package/bin/cccagent.mjs +17 -17
- package/deepccc-agent/bin/deepccc.mjs +26 -26
- package/deepccc-agent/os-prompts/darwin.md +8 -0
- package/deepccc-agent/os-prompts/linux.md +8 -0
- package/deepccc-agent/os-prompts/win32.md +9 -0
- package/deepccc-agent/package.json +2 -1
- package/deepccc-agent/src/__tests__/chat-session.test.ts +39 -0
- package/deepccc-agent/src/__tests__/cli-json.test.ts +49 -49
- package/deepccc-agent/src/__tests__/config.test.ts +26 -26
- package/deepccc-agent/src/__tests__/context.test.ts +319 -319
- package/deepccc-agent/src/__tests__/file-tools.test.ts +240 -240
- package/deepccc-agent/src/__tests__/permissions.test.ts +195 -195
- package/deepccc-agent/src/__tests__/progress-reducer.test.ts +121 -121
- package/deepccc-agent/src/__tests__/session-search.test.ts +262 -262
- package/deepccc-agent/src/__tests__/session-select.test.ts +116 -116
- package/deepccc-agent/src/__tests__/sigint.test.ts +56 -56
- package/deepccc-agent/src/__tests__/skills.test.ts +284 -284
- package/deepccc-agent/src/__tests__/terminal-renderer.test.ts +247 -247
- package/deepccc-agent/src/__tests__/web-tools.test.ts +220 -220
- package/deepccc-agent/src/config.ts +84 -84
- package/deepccc-agent/src/context.ts +465 -465
- package/deepccc-agent/src/file-log.ts +38 -38
- package/deepccc-agent/src/index.ts +46 -16
- package/deepccc-agent/src/proc-tree-kill.ts +61 -61
- package/deepccc-agent/src/progress/cards-helpers.ts +76 -76
- package/deepccc-agent/src/progress/reducer.ts +113 -113
- package/deepccc-agent/src/progress/terminal-renderer.ts +294 -294
- package/deepccc-agent/src/progress/view.ts +77 -77
- package/deepccc-agent/src/raw-stream-log.ts +124 -124
- package/deepccc-agent/src/session-search.ts +370 -370
- package/deepccc-agent/src/session-select.ts +48 -48
- package/deepccc-agent/src/sigint.ts +50 -50
- package/deepccc-agent/src/skills.ts +205 -205
- package/deepccc-agent/src/web-tools.ts +313 -313
- package/deepccc-agent/tsconfig.build.json +13 -13
- package/deepccc-agent/tsconfig.json +13 -13
- package/deepccc-agent/vitest.config.ts +7 -7
- package/package.json +73 -73
- package/src/__tests__/builtin-chat-session.test.ts +522 -522
- package/src/__tests__/builtin-config.test.ts +26 -26
- package/src/__tests__/builtin-context.test.ts +319 -319
- package/src/__tests__/builtin-file-tools.test.ts +240 -240
- package/src/__tests__/builtin-permissions.test.ts +211 -211
- package/src/__tests__/builtin-session-search.test.ts +262 -262
- package/src/__tests__/builtin-session-select.test.ts +116 -116
- package/src/__tests__/builtin-sigint.test.ts +56 -56
- package/src/__tests__/builtin-skills.test.ts +284 -284
- package/src/__tests__/builtin-web-tools.test.ts +220 -220
- package/src/__tests__/config.test.ts +17 -17
- package/src/__tests__/progress-reducer.test.ts +121 -121
- package/src/__tests__/session-ccc-config.test.ts +45 -45
- package/src/__tests__/session.test.ts +298 -298
- package/src/adapters/ccc-adapter.ts +145 -145
- package/src/config-utils.ts +13 -13
- package/src/config.ts +13 -13
- package/src/progress/reducer.ts +113 -113
- package/src/session-chat-binding.ts +83 -83
- package/src/session.ts +311 -311
|
@@ -1,116 +1,116 @@
|
|
|
1
|
-
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
|
|
5
|
-
import { describe, expect, it } from "vitest";
|
|
6
|
-
|
|
7
|
-
import { defaultBuiltinSessionId } from "../context.js";
|
|
8
|
-
import { resolveBuiltinSession } from "../session-select.js";
|
|
9
|
-
|
|
10
|
-
async function writeSession(
|
|
11
|
-
contextDir: string,
|
|
12
|
-
sessionId: string,
|
|
13
|
-
options: { cwd?: string; updatedAt: number; totalMessages?: number },
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const dir = join(contextDir, sessionId);
|
|
16
|
-
await mkdir(dir, { recursive: true });
|
|
17
|
-
await writeFile(
|
|
18
|
-
join(dir, "context.json"),
|
|
19
|
-
JSON.stringify({
|
|
20
|
-
version: 1,
|
|
21
|
-
createdAt: options.updatedAt,
|
|
22
|
-
updatedAt: options.updatedAt,
|
|
23
|
-
sessionId,
|
|
24
|
-
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
25
|
-
summary: "",
|
|
26
|
-
messages: [],
|
|
27
|
-
totalMessages: options.totalMessages ?? 0,
|
|
28
|
-
compactedMessages: 0,
|
|
29
|
-
}),
|
|
30
|
-
"utf8",
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
describe("resolveBuiltinSession", () => {
|
|
35
|
-
it("creates a fresh timestamp session by default", async () => {
|
|
36
|
-
const contextDir = await mkdtemp(join(tmpdir(), "chatccc-session-select-new-"));
|
|
37
|
-
|
|
38
|
-
const result = resolveBuiltinSession({
|
|
39
|
-
cwd: "C:\\repo",
|
|
40
|
-
contextDir,
|
|
41
|
-
now: new Date(2026, 6, 2, 12, 15, 30),
|
|
42
|
-
randomSuffix: "a1b2c3",
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
expect(result).toEqual({
|
|
46
|
-
mode: "new",
|
|
47
|
-
sessionId: "session-20260702-121530-a1b2c3",
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("resumes an explicit existing session id", async () => {
|
|
52
|
-
const contextDir = join(tmpdir(), `chatccc-session-select-explicit-${Date.now()}`);
|
|
53
|
-
await writeSession(contextDir, "manual-session", { updatedAt: 1 });
|
|
54
|
-
|
|
55
|
-
expect(resolveBuiltinSession({
|
|
56
|
-
cwd: "C:\\repo",
|
|
57
|
-
contextDir,
|
|
58
|
-
resume: "manual-session",
|
|
59
|
-
})).toEqual({
|
|
60
|
-
mode: "resumed",
|
|
61
|
-
sessionId: "manual-session",
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("fails when an explicit session id does not exist", async () => {
|
|
66
|
-
const contextDir = join(tmpdir(), `chatccc-session-select-missing-${Date.now()}`);
|
|
67
|
-
|
|
68
|
-
expect(() => resolveBuiltinSession({
|
|
69
|
-
cwd: "C:\\repo",
|
|
70
|
-
contextDir,
|
|
71
|
-
resume: "missing",
|
|
72
|
-
})).toThrow("DeepCCC session not found: missing");
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it("resumes the newest session for cwd when resume has no id", async () => {
|
|
76
|
-
const contextDir = join(tmpdir(), `chatccc-session-select-cwd-${Date.now()}`);
|
|
77
|
-
await writeSession(contextDir, "old-match", { cwd: "C:\\repo", updatedAt: 1_000 });
|
|
78
|
-
await writeSession(contextDir, "new-match", { cwd: "C:\\repo", updatedAt: 2_000 });
|
|
79
|
-
await writeSession(contextDir, "other-cwd", { cwd: "C:\\other", updatedAt: 3_000 });
|
|
80
|
-
|
|
81
|
-
expect(resolveBuiltinSession({
|
|
82
|
-
cwd: "C:\\repo",
|
|
83
|
-
contextDir,
|
|
84
|
-
resume: true,
|
|
85
|
-
})).toEqual({
|
|
86
|
-
mode: "resumed",
|
|
87
|
-
sessionId: "new-match",
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("resumes legacy cwd-hash sessions when resume has no id", async () => {
|
|
92
|
-
const contextDir = join(tmpdir(), `chatccc-session-select-legacy-${Date.now()}`);
|
|
93
|
-
const cwd = "C:\\repo";
|
|
94
|
-
const legacySessionId = defaultBuiltinSessionId(cwd);
|
|
95
|
-
await writeSession(contextDir, legacySessionId, { updatedAt: 1_000 });
|
|
96
|
-
|
|
97
|
-
expect(resolveBuiltinSession({
|
|
98
|
-
cwd,
|
|
99
|
-
contextDir,
|
|
100
|
-
resume: true,
|
|
101
|
-
})).toEqual({
|
|
102
|
-
mode: "resumed",
|
|
103
|
-
sessionId: legacySessionId,
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("fails when there is no cwd session to resume", async () => {
|
|
108
|
-
const contextDir = join(tmpdir(), `chatccc-session-select-empty-${Date.now()}`);
|
|
109
|
-
|
|
110
|
-
expect(() => resolveBuiltinSession({
|
|
111
|
-
cwd: "C:\\repo",
|
|
112
|
-
contextDir,
|
|
113
|
-
resume: true,
|
|
114
|
-
})).toThrow("No resumable DeepCCC session found for cwd: C:\\repo");
|
|
115
|
-
});
|
|
116
|
-
});
|
|
1
|
+
import { mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
|
|
5
|
+
import { describe, expect, it } from "vitest";
|
|
6
|
+
|
|
7
|
+
import { defaultBuiltinSessionId } from "../context.js";
|
|
8
|
+
import { resolveBuiltinSession } from "../session-select.js";
|
|
9
|
+
|
|
10
|
+
async function writeSession(
|
|
11
|
+
contextDir: string,
|
|
12
|
+
sessionId: string,
|
|
13
|
+
options: { cwd?: string; updatedAt: number; totalMessages?: number },
|
|
14
|
+
): Promise<void> {
|
|
15
|
+
const dir = join(contextDir, sessionId);
|
|
16
|
+
await mkdir(dir, { recursive: true });
|
|
17
|
+
await writeFile(
|
|
18
|
+
join(dir, "context.json"),
|
|
19
|
+
JSON.stringify({
|
|
20
|
+
version: 1,
|
|
21
|
+
createdAt: options.updatedAt,
|
|
22
|
+
updatedAt: options.updatedAt,
|
|
23
|
+
sessionId,
|
|
24
|
+
...(options.cwd ? { cwd: options.cwd } : {}),
|
|
25
|
+
summary: "",
|
|
26
|
+
messages: [],
|
|
27
|
+
totalMessages: options.totalMessages ?? 0,
|
|
28
|
+
compactedMessages: 0,
|
|
29
|
+
}),
|
|
30
|
+
"utf8",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
describe("resolveBuiltinSession", () => {
|
|
35
|
+
it("creates a fresh timestamp session by default", async () => {
|
|
36
|
+
const contextDir = await mkdtemp(join(tmpdir(), "chatccc-session-select-new-"));
|
|
37
|
+
|
|
38
|
+
const result = resolveBuiltinSession({
|
|
39
|
+
cwd: "C:\\repo",
|
|
40
|
+
contextDir,
|
|
41
|
+
now: new Date(2026, 6, 2, 12, 15, 30),
|
|
42
|
+
randomSuffix: "a1b2c3",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(result).toEqual({
|
|
46
|
+
mode: "new",
|
|
47
|
+
sessionId: "session-20260702-121530-a1b2c3",
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("resumes an explicit existing session id", async () => {
|
|
52
|
+
const contextDir = join(tmpdir(), `chatccc-session-select-explicit-${Date.now()}`);
|
|
53
|
+
await writeSession(contextDir, "manual-session", { updatedAt: 1 });
|
|
54
|
+
|
|
55
|
+
expect(resolveBuiltinSession({
|
|
56
|
+
cwd: "C:\\repo",
|
|
57
|
+
contextDir,
|
|
58
|
+
resume: "manual-session",
|
|
59
|
+
})).toEqual({
|
|
60
|
+
mode: "resumed",
|
|
61
|
+
sessionId: "manual-session",
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("fails when an explicit session id does not exist", async () => {
|
|
66
|
+
const contextDir = join(tmpdir(), `chatccc-session-select-missing-${Date.now()}`);
|
|
67
|
+
|
|
68
|
+
expect(() => resolveBuiltinSession({
|
|
69
|
+
cwd: "C:\\repo",
|
|
70
|
+
contextDir,
|
|
71
|
+
resume: "missing",
|
|
72
|
+
})).toThrow("DeepCCC session not found: missing");
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("resumes the newest session for cwd when resume has no id", async () => {
|
|
76
|
+
const contextDir = join(tmpdir(), `chatccc-session-select-cwd-${Date.now()}`);
|
|
77
|
+
await writeSession(contextDir, "old-match", { cwd: "C:\\repo", updatedAt: 1_000 });
|
|
78
|
+
await writeSession(contextDir, "new-match", { cwd: "C:\\repo", updatedAt: 2_000 });
|
|
79
|
+
await writeSession(contextDir, "other-cwd", { cwd: "C:\\other", updatedAt: 3_000 });
|
|
80
|
+
|
|
81
|
+
expect(resolveBuiltinSession({
|
|
82
|
+
cwd: "C:\\repo",
|
|
83
|
+
contextDir,
|
|
84
|
+
resume: true,
|
|
85
|
+
})).toEqual({
|
|
86
|
+
mode: "resumed",
|
|
87
|
+
sessionId: "new-match",
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it("resumes legacy cwd-hash sessions when resume has no id", async () => {
|
|
92
|
+
const contextDir = join(tmpdir(), `chatccc-session-select-legacy-${Date.now()}`);
|
|
93
|
+
const cwd = "C:\\repo";
|
|
94
|
+
const legacySessionId = defaultBuiltinSessionId(cwd);
|
|
95
|
+
await writeSession(contextDir, legacySessionId, { updatedAt: 1_000 });
|
|
96
|
+
|
|
97
|
+
expect(resolveBuiltinSession({
|
|
98
|
+
cwd,
|
|
99
|
+
contextDir,
|
|
100
|
+
resume: true,
|
|
101
|
+
})).toEqual({
|
|
102
|
+
mode: "resumed",
|
|
103
|
+
sessionId: legacySessionId,
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("fails when there is no cwd session to resume", async () => {
|
|
108
|
+
const contextDir = join(tmpdir(), `chatccc-session-select-empty-${Date.now()}`);
|
|
109
|
+
|
|
110
|
+
expect(() => resolveBuiltinSession({
|
|
111
|
+
cwd: "C:\\repo",
|
|
112
|
+
contextDir,
|
|
113
|
+
resume: true,
|
|
114
|
+
})).toThrow("No resumable DeepCCC session found for cwd: C:\\repo");
|
|
115
|
+
});
|
|
116
|
+
});
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
|
|
3
|
-
import { createCtrlCState } from "../sigint.js";
|
|
4
|
-
|
|
5
|
-
describe("builtin CLI Ctrl+C state", () => {
|
|
6
|
-
it("requires two presses to interrupt an active generation", () => {
|
|
7
|
-
let now = 1_000;
|
|
8
|
-
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
9
|
-
|
|
10
|
-
expect(state.press(true)).toBe("arm-interrupt");
|
|
11
|
-
expect(state.press(true)).toBe("interrupt");
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it("requires two presses to exit while idle", () => {
|
|
15
|
-
let now = 1_000;
|
|
16
|
-
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
17
|
-
|
|
18
|
-
expect(state.press(false)).toBe("arm-exit");
|
|
19
|
-
expect(state.press(false)).toBe("exit");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("expires the pending confirmation after the window", () => {
|
|
23
|
-
let now = 1_000;
|
|
24
|
-
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
25
|
-
|
|
26
|
-
expect(state.press(true)).toBe("arm-interrupt");
|
|
27
|
-
|
|
28
|
-
now += 2_001;
|
|
29
|
-
|
|
30
|
-
expect(state.press(true)).toBe("arm-interrupt");
|
|
31
|
-
expect(state.press(true)).toBe("interrupt");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("does not convert a pending interrupt into an idle exit after reset", () => {
|
|
35
|
-
let now = 1_000;
|
|
36
|
-
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
37
|
-
|
|
38
|
-
expect(state.press(true)).toBe("arm-interrupt");
|
|
39
|
-
|
|
40
|
-
state.reset();
|
|
41
|
-
now += 1_000;
|
|
42
|
-
|
|
43
|
-
expect(state.press(false)).toBe("arm-exit");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it("does not confirm a different action with the second press", () => {
|
|
47
|
-
let now = 1_000;
|
|
48
|
-
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
49
|
-
|
|
50
|
-
expect(state.press(true)).toBe("arm-interrupt");
|
|
51
|
-
now += 500;
|
|
52
|
-
|
|
53
|
-
expect(state.press(false)).toBe("arm-exit");
|
|
54
|
-
expect(state.press(false)).toBe("exit");
|
|
55
|
-
});
|
|
56
|
-
});
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { createCtrlCState } from "../sigint.js";
|
|
4
|
+
|
|
5
|
+
describe("builtin CLI Ctrl+C state", () => {
|
|
6
|
+
it("requires two presses to interrupt an active generation", () => {
|
|
7
|
+
let now = 1_000;
|
|
8
|
+
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
9
|
+
|
|
10
|
+
expect(state.press(true)).toBe("arm-interrupt");
|
|
11
|
+
expect(state.press(true)).toBe("interrupt");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("requires two presses to exit while idle", () => {
|
|
15
|
+
let now = 1_000;
|
|
16
|
+
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
17
|
+
|
|
18
|
+
expect(state.press(false)).toBe("arm-exit");
|
|
19
|
+
expect(state.press(false)).toBe("exit");
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("expires the pending confirmation after the window", () => {
|
|
23
|
+
let now = 1_000;
|
|
24
|
+
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
25
|
+
|
|
26
|
+
expect(state.press(true)).toBe("arm-interrupt");
|
|
27
|
+
|
|
28
|
+
now += 2_001;
|
|
29
|
+
|
|
30
|
+
expect(state.press(true)).toBe("arm-interrupt");
|
|
31
|
+
expect(state.press(true)).toBe("interrupt");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("does not convert a pending interrupt into an idle exit after reset", () => {
|
|
35
|
+
let now = 1_000;
|
|
36
|
+
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
37
|
+
|
|
38
|
+
expect(state.press(true)).toBe("arm-interrupt");
|
|
39
|
+
|
|
40
|
+
state.reset();
|
|
41
|
+
now += 1_000;
|
|
42
|
+
|
|
43
|
+
expect(state.press(false)).toBe("arm-exit");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("does not confirm a different action with the second press", () => {
|
|
47
|
+
let now = 1_000;
|
|
48
|
+
const state = createCtrlCState({ windowMs: 2_000, now: () => now });
|
|
49
|
+
|
|
50
|
+
expect(state.press(true)).toBe("arm-interrupt");
|
|
51
|
+
now += 500;
|
|
52
|
+
|
|
53
|
+
expect(state.press(false)).toBe("arm-exit");
|
|
54
|
+
expect(state.press(false)).toBe("exit");
|
|
55
|
+
});
|
|
56
|
+
});
|