@monotykamary/pi-vcc 0.4.0 → 0.4.1
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/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/__tests__/helpers.ts +0 -135
- package/__tests__/root-causes.test.ts +0 -858
- package/demo.gif +0 -0
- package/knip.json +0 -4
- package/scripts/audit-sessions.ts +0 -88
- package/scripts/benchmark-real-sessions.ts +0 -25
- package/scripts/compare-before-after.ts +0 -36
- package/scripts/dump-branch-output.ts +0 -20
- package/stress-debug.ts +0 -202
- package/stress-degradation-curve.ts +0 -251
- package/tests/australian-government.test.ts +0 -479
- package/tests/before-compact-hook.test.ts +0 -185
- package/tests/before-compact.test.ts +0 -227
- package/tests/breadcrumbs.test.ts +0 -312
- package/tests/brief.test.ts +0 -215
- package/tests/build-sections.test.ts +0 -59
- package/tests/compile.test.ts +0 -89
- package/tests/content.test.ts +0 -66
- package/tests/deep-extraction.test.ts +0 -322
- package/tests/extract-goals.test.ts +0 -86
- package/tests/extract-preferences.test.ts +0 -30
- package/tests/filter-noise.test.ts +0 -61
- package/tests/fixtures.ts +0 -61
- package/tests/format-recall.test.ts +0 -87
- package/tests/format.test.ts +0 -73
- package/tests/government-domain.test.ts +0 -542
- package/tests/lineage.test.ts +0 -33
- package/tests/load-messages.test.ts +0 -49
- package/tests/model-threshold-hook.test.ts +0 -311
- package/tests/model-threshold.test.ts +0 -223
- package/tests/normalize.test.ts +0 -104
- package/tests/proactive-threshold.test.ts +0 -490
- package/tests/real-sessions.test.ts +0 -38
- package/tests/recall-expand.test.ts +0 -15
- package/tests/recall-scope.test.ts +0 -32
- package/tests/recall-tool-scope.test.ts +0 -67
- package/tests/render-entries.test.ts +0 -92
- package/tests/report.test.ts +0 -58
- package/tests/sanitize.test.ts +0 -24
- package/tests/search-entries.test.ts +0 -233
- package/tests/stress-100-compactions.test.ts +0 -373
- package/tests/support/load-session.ts +0 -23
- package/tests/support/real-sessions.ts +0 -51
- package/tests/threshold-integration.test.ts +0 -335
package/tests/brief.test.ts
DELETED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { compileBrief } from "../src/core/brief";
|
|
3
|
-
import type { NormalizedBlock } from "../src/types";
|
|
4
|
-
|
|
5
|
-
describe("compileBrief", () => {
|
|
6
|
-
it("returns empty string for no blocks", () => {
|
|
7
|
-
expect(compileBrief([])).toBe("");
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it("renders user and assistant text", () => {
|
|
11
|
-
const blocks: NormalizedBlock[] = [
|
|
12
|
-
{ kind: "user", text: "fix auth bug" },
|
|
13
|
-
{ kind: "assistant", text: "Let me look at the auth module." },
|
|
14
|
-
];
|
|
15
|
-
const r = compileBrief(blocks);
|
|
16
|
-
expect(r).toContain("[user]");
|
|
17
|
-
expect(r).toContain("fix auth bug");
|
|
18
|
-
expect(r).toContain("[assistant]");
|
|
19
|
-
expect(r).toContain("Let me look at the auth module.");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("renders bash commands as user actions", () => {
|
|
23
|
-
const blocks: NormalizedBlock[] = [
|
|
24
|
-
{ kind: "bash", command: "npm test", output: "FAIL noisy output", exitCode: 1, sourceIndex: 2 },
|
|
25
|
-
];
|
|
26
|
-
const r = compileBrief(blocks);
|
|
27
|
-
expect(r).toContain("[user]\n$ npm test (#2)");
|
|
28
|
-
expect(r).not.toContain("FAIL noisy output");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("strips filler prefixes but preserves meaningful lead-ins", () => {
|
|
32
|
-
const blocks: NormalizedBlock[] = [
|
|
33
|
-
{ kind: "assistant", text: "Okay, I found the root cause." },
|
|
34
|
-
{ kind: "assistant", text: "Actually, the issue is in middleware." },
|
|
35
|
-
{ kind: "assistant", text: "Let me check the logs." },
|
|
36
|
-
];
|
|
37
|
-
const r = compileBrief(blocks);
|
|
38
|
-
expect(r).toContain("I found the root cause.");
|
|
39
|
-
expect(r).toContain("the issue is in middleware.");
|
|
40
|
-
expect(r).toContain("Let me check the logs.");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("collapses tool calls to one-liners under [assistant]", () => {
|
|
44
|
-
const blocks: NormalizedBlock[] = [
|
|
45
|
-
{ kind: "assistant", text: "Let me check." },
|
|
46
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "auth.ts" } },
|
|
47
|
-
{ kind: "tool_call", name: "Edit", args: { file_path: "auth.ts" } },
|
|
48
|
-
];
|
|
49
|
-
const r = compileBrief(blocks);
|
|
50
|
-
expect(r).toContain('* Read "auth.ts"');
|
|
51
|
-
expect(r).toContain('* Edit "auth.ts"');
|
|
52
|
-
// Should merge into single [assistant] section
|
|
53
|
-
const matches = r.match(/\[assistant\]/g);
|
|
54
|
-
expect(matches?.length).toBe(1);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("hides non-error tool results", () => {
|
|
58
|
-
const blocks: NormalizedBlock[] = [
|
|
59
|
-
{ kind: "tool_result", name: "Read", text: "const x = 1;\nconst y = 2;\n// lots of code", isError: false },
|
|
60
|
-
];
|
|
61
|
-
const r = compileBrief(blocks);
|
|
62
|
-
expect(r).toBe("");
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("shows tool errors with first line", () => {
|
|
66
|
-
const blocks: NormalizedBlock[] = [
|
|
67
|
-
{ kind: "tool_result", name: "bash", text: "FAIL auth.test.ts\nexpected 200 got 401", isError: true },
|
|
68
|
-
];
|
|
69
|
-
const r = compileBrief(blocks);
|
|
70
|
-
expect(r).toContain("[tool_error] bash");
|
|
71
|
-
expect(r).toContain("FAIL auth.test.ts");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("hides thinking blocks", () => {
|
|
75
|
-
const blocks: NormalizedBlock[] = [
|
|
76
|
-
{ kind: "thinking", text: "Let me think about this...", redacted: false },
|
|
77
|
-
{ kind: "assistant", text: "Here's what I found." },
|
|
78
|
-
];
|
|
79
|
-
const r = compileBrief(blocks);
|
|
80
|
-
expect(r).not.toContain("think");
|
|
81
|
-
expect(r).toContain("Here's what I found.");
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("merges adjacent assistant sections", () => {
|
|
85
|
-
const blocks: NormalizedBlock[] = [
|
|
86
|
-
{ kind: "assistant", text: "First part." },
|
|
87
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "a.ts" } },
|
|
88
|
-
// No user/tool_result between these — should merge
|
|
89
|
-
{ kind: "assistant", text: "Second part." },
|
|
90
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "b.ts" } },
|
|
91
|
-
];
|
|
92
|
-
const r = compileBrief(blocks);
|
|
93
|
-
const matches = r.match(/\[assistant\]/g);
|
|
94
|
-
expect(matches?.length).toBe(1);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it("does NOT merge assistant after user", () => {
|
|
98
|
-
const blocks: NormalizedBlock[] = [
|
|
99
|
-
{ kind: "assistant", text: "First." },
|
|
100
|
-
{ kind: "user", text: "Next task." },
|
|
101
|
-
{ kind: "assistant", text: "Second." },
|
|
102
|
-
];
|
|
103
|
-
const r = compileBrief(blocks);
|
|
104
|
-
const matches = r.match(/\[assistant\]/g);
|
|
105
|
-
expect(matches?.length).toBe(2);
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it("truncates long user text", () => {
|
|
109
|
-
const longText = Array.from({ length: 300 }, (_, i) => `word${i}`).join(" ");
|
|
110
|
-
const blocks: NormalizedBlock[] = [
|
|
111
|
-
{ kind: "user", text: longText },
|
|
112
|
-
];
|
|
113
|
-
const r = compileBrief(blocks);
|
|
114
|
-
expect(r).toContain("(truncated)");
|
|
115
|
-
expect(r).not.toContain("word299");
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it("truncates long assistant text", () => {
|
|
119
|
-
const longText = Array.from({ length: 300 }, (_, i) => `word${i}`).join(" ");
|
|
120
|
-
const blocks: NormalizedBlock[] = [
|
|
121
|
-
{ kind: "assistant", text: longText },
|
|
122
|
-
];
|
|
123
|
-
const r = compileBrief(blocks);
|
|
124
|
-
expect(r).toContain("(truncated)");
|
|
125
|
-
expect(r).not.toContain("word299");
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it("renders a realistic conversation flow", () => {
|
|
129
|
-
const blocks: NormalizedBlock[] = [
|
|
130
|
-
{ kind: "user", text: "fix the login bug" },
|
|
131
|
-
{ kind: "thinking", text: "I need to check...", redacted: false },
|
|
132
|
-
{ kind: "assistant", text: "Let me investigate." },
|
|
133
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "login.ts" } },
|
|
134
|
-
{ kind: "tool_result", name: "Read", text: "export function login() { ... }", isError: false },
|
|
135
|
-
{ kind: "tool_call", name: "bash", args: { command: "npm test" } },
|
|
136
|
-
{ kind: "tool_result", name: "bash", text: "FAIL: login test\nExpected true, got false", isError: true },
|
|
137
|
-
{ kind: "assistant", text: "The test is failing because..." },
|
|
138
|
-
{ kind: "tool_call", name: "Edit", args: { file_path: "login.ts" } },
|
|
139
|
-
{ kind: "tool_result", name: "Edit", text: "File edited successfully", isError: false },
|
|
140
|
-
{ kind: "user", text: "test lại đi" },
|
|
141
|
-
{ kind: "assistant", text: "Running tests again." },
|
|
142
|
-
{ kind: "tool_call", name: "bash", args: { command: "npm test" } },
|
|
143
|
-
{ kind: "tool_result", name: "bash", text: "All tests passed", isError: false },
|
|
144
|
-
];
|
|
145
|
-
const r = compileBrief(blocks);
|
|
146
|
-
|
|
147
|
-
// Check structure
|
|
148
|
-
expect(r).toContain("[user]\nfix the login bug");
|
|
149
|
-
expect(r).toContain('[assistant]\nLet me investigate.\n* Read "login.ts"');
|
|
150
|
-
expect(r).toContain("[tool_error] bash\nFAIL: login test");
|
|
151
|
-
expect(r).toContain('[assistant]\nThe test is failing because...\n* Edit "login.ts"');
|
|
152
|
-
expect(r).toContain("[user]\ntest lại đi");
|
|
153
|
-
expect(r).toContain('[assistant]\nRunning tests again.\n* bash "npm test"');
|
|
154
|
-
|
|
155
|
-
// Hidden content
|
|
156
|
-
expect(r).not.toContain("think");
|
|
157
|
-
expect(r).not.toContain("export function login");
|
|
158
|
-
expect(r).not.toContain("File edited successfully");
|
|
159
|
-
expect(r).not.toContain("All tests passed");
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// ── noise filtering tests (aligned with VCC) ──
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
it("suppresses blank lines between consecutive tool-only sections", () => {
|
|
173
|
-
const blocks: NormalizedBlock[] = [
|
|
174
|
-
{ kind: "assistant", text: "Checking files." },
|
|
175
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "a.ts" } },
|
|
176
|
-
{ kind: "tool_result", name: "Read", text: "...", isError: false },
|
|
177
|
-
// tool_result hidden → next tool_call starts new assistant section
|
|
178
|
-
// but since both are tool-only, no blank line between
|
|
179
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "b.ts" } },
|
|
180
|
-
{ kind: "tool_result", name: "Read", text: "...", isError: false },
|
|
181
|
-
];
|
|
182
|
-
const r = compileBrief(blocks);
|
|
183
|
-
// The first assistant section has text + tool, so it's NOT tool-only
|
|
184
|
-
// The second would be tool-only but merges into the first (adjacent assistant)
|
|
185
|
-
// So all under one [assistant]
|
|
186
|
-
expect(r.match(/\[assistant\]/g)?.length).toBe(1);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("caps tool calls per [assistant] turn at 8 (keep tail)", () => {
|
|
190
|
-
const blocks: NormalizedBlock[] = [
|
|
191
|
-
{ kind: "assistant", text: "Working." },
|
|
192
|
-
];
|
|
193
|
-
for (let i = 1; i <= 12; i++) {
|
|
194
|
-
blocks.push({ kind: "tool_call", name: "bash", args: { command: `echo ${i}` } });
|
|
195
|
-
}
|
|
196
|
-
const r = compileBrief(blocks);
|
|
197
|
-
expect(r).toContain("(4 earlier tool-call entries omitted)");
|
|
198
|
-
// Last 8 (5..12) kept; first 4 dropped
|
|
199
|
-
expect(r).not.toContain("echo 1\"");
|
|
200
|
-
expect(r).not.toContain("echo 4\"");
|
|
201
|
-
expect(r).toContain("echo 5");
|
|
202
|
-
expect(r).toContain("echo 12");
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
it("does not cap when tool calls per turn <= 8", () => {
|
|
206
|
-
const blocks: NormalizedBlock[] = [{ kind: "assistant", text: "ok" }];
|
|
207
|
-
for (let i = 1; i <= 8; i++) {
|
|
208
|
-
blocks.push({ kind: "tool_call", name: "bash", args: { command: `c${i}` } });
|
|
209
|
-
}
|
|
210
|
-
const r = compileBrief(blocks);
|
|
211
|
-
expect(r).not.toContain("entries omitted");
|
|
212
|
-
expect(r).toContain("c1");
|
|
213
|
-
expect(r).toContain("c8");
|
|
214
|
-
});
|
|
215
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { buildSections } from "../src/core/build-sections";
|
|
3
|
-
import type { NormalizedBlock } from "../src/types";
|
|
4
|
-
|
|
5
|
-
describe("buildSections", () => {
|
|
6
|
-
it("returns all-empty for no blocks", () => {
|
|
7
|
-
const r = buildSections({ blocks: [] });
|
|
8
|
-
expect(r.sessionGoal).toEqual([]);
|
|
9
|
-
expect(r.outstandingContext).toEqual([]);
|
|
10
|
-
expect(r.briefTranscript).toBe("");
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("populates sections from realistic blocks", () => {
|
|
14
|
-
const blocks: NormalizedBlock[] = [
|
|
15
|
-
{ kind: "user", text: "Fix the auth bug" },
|
|
16
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "auth.ts" } },
|
|
17
|
-
{ kind: "tool_result", name: "Read", text: "const x = 1;", isError: false },
|
|
18
|
-
{ kind: "tool_call", name: "Edit", args: { file_path: "auth.ts" } },
|
|
19
|
-
{ kind: "tool_result", name: "Edit", text: "ok", isError: false },
|
|
20
|
-
{ kind: "assistant", text: "- run tests next" },
|
|
21
|
-
];
|
|
22
|
-
const r = buildSections({ blocks });
|
|
23
|
-
expect(r.sessionGoal).toContain("Fix the auth bug");
|
|
24
|
-
expect(r.briefTranscript).toContain('[user]');
|
|
25
|
-
expect(r.briefTranscript).toContain('* Read "auth.ts"');
|
|
26
|
-
expect(r.briefTranscript).toContain('* Edit "auth.ts"');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("captures outstanding context from errors", () => {
|
|
30
|
-
const blocks: NormalizedBlock[] = [
|
|
31
|
-
{ kind: "tool_result", name: "bash", text: "FAIL: test broken\ndetails here", isError: true },
|
|
32
|
-
];
|
|
33
|
-
const r = buildSections({ blocks });
|
|
34
|
-
expect(r.outstandingContext.length).toBeGreaterThan(0);
|
|
35
|
-
expect(r.outstandingContext[0]).toContain("FAIL");
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("brief transcript hides tool results but shows errors", () => {
|
|
39
|
-
const blocks: NormalizedBlock[] = [
|
|
40
|
-
{ kind: "tool_result", name: "Read", text: "lots of code here ...", isError: false },
|
|
41
|
-
{ kind: "tool_result", name: "bash", text: "Command not found", isError: true },
|
|
42
|
-
];
|
|
43
|
-
const r = buildSections({ blocks });
|
|
44
|
-
expect(r.briefTranscript).not.toContain("lots of code");
|
|
45
|
-
expect(r.briefTranscript).toContain("[tool_error] bash");
|
|
46
|
-
expect(r.briefTranscript).toContain("Command not found");
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("brief transcript merges adjacent assistant sections", () => {
|
|
50
|
-
const blocks: NormalizedBlock[] = [
|
|
51
|
-
{ kind: "assistant", text: "Part one." },
|
|
52
|
-
{ kind: "tool_call", name: "Read", args: { file_path: "a.ts" } },
|
|
53
|
-
{ kind: "assistant", text: "Part two." },
|
|
54
|
-
];
|
|
55
|
-
const r = buildSections({ blocks });
|
|
56
|
-
const matches = r.briefTranscript.match(/\[assistant\]/g);
|
|
57
|
-
expect(matches?.length).toBe(1);
|
|
58
|
-
});
|
|
59
|
-
});
|
package/tests/compile.test.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { compile } from "../src/core/summarize";
|
|
3
|
-
import {
|
|
4
|
-
userMsg,
|
|
5
|
-
assistantText,
|
|
6
|
-
assistantWithToolCall,
|
|
7
|
-
toolResult,
|
|
8
|
-
} from "./fixtures";
|
|
9
|
-
|
|
10
|
-
describe("compile", () => {
|
|
11
|
-
it("returns empty string for no messages", () => {
|
|
12
|
-
expect(compile({ messages: [] })).toBe("");
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("produces hybrid output with header + brief transcript", () => {
|
|
16
|
-
const r = compile({
|
|
17
|
-
messages: [
|
|
18
|
-
userMsg("Fix login bug"),
|
|
19
|
-
assistantWithToolCall("Read", { path: "auth.ts" }),
|
|
20
|
-
assistantText("Found the issue.\n1. Fix validation"),
|
|
21
|
-
],
|
|
22
|
-
});
|
|
23
|
-
expect(r).toContain("[Session Goal]");
|
|
24
|
-
expect(r).toContain("Fix login bug");
|
|
25
|
-
expect(r).toContain("---");
|
|
26
|
-
expect(r).toContain("[user]\nFix login bug");
|
|
27
|
-
expect(r).toContain('* Read "auth.ts"');
|
|
28
|
-
expect(r).toContain("Found the issue.");
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("merges previous summary goals", () => {
|
|
32
|
-
const r = compile({
|
|
33
|
-
messages: [userMsg("New task")],
|
|
34
|
-
previousSummary: "[Session Goal]\n- Original goal\n\n---\n\n[user]\nOriginal goal",
|
|
35
|
-
});
|
|
36
|
-
expect(r).toContain("- Original goal");
|
|
37
|
-
expect(r).toContain("- New task");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("appends brief transcript on merge", () => {
|
|
41
|
-
const previousSummary = [
|
|
42
|
-
"[Session Goal]\n- Original goal",
|
|
43
|
-
"---",
|
|
44
|
-
"[user]\nOriginal goal\n\n[assistant]\n* Read \"old.ts\"",
|
|
45
|
-
].join("\n\n");
|
|
46
|
-
const r = compile({
|
|
47
|
-
previousSummary,
|
|
48
|
-
messages: [
|
|
49
|
-
userMsg("Next step"),
|
|
50
|
-
assistantWithToolCall("Read", { path: "new.ts" }),
|
|
51
|
-
],
|
|
52
|
-
});
|
|
53
|
-
expect(r).toContain('* Read "old.ts"');
|
|
54
|
-
expect(r).toContain('* Read "new.ts"');
|
|
55
|
-
expect(r).toContain("Next step");
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("outstanding context is volatile (fresh only)", () => {
|
|
59
|
-
const previousSummary = "[Outstanding Context]\n- old blocker\n\n---\n\n[user]\nhi";
|
|
60
|
-
const r = compile({
|
|
61
|
-
previousSummary,
|
|
62
|
-
messages: [userMsg("continue")],
|
|
63
|
-
});
|
|
64
|
-
expect(r).not.toContain("old blocker");
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("caps long brief transcript with rolling window", () => {
|
|
68
|
-
// Build a very long previous transcript
|
|
69
|
-
const longTranscript = Array.from({ length: 200 }, (_, i) =>
|
|
70
|
-
`[user]\nmessage ${i}`
|
|
71
|
-
).join("\n\n");
|
|
72
|
-
const previousSummary = `[Session Goal]\n- goal\n\n---\n\n${longTranscript}`;
|
|
73
|
-
const r = compile({
|
|
74
|
-
previousSummary,
|
|
75
|
-
messages: [userMsg("latest")],
|
|
76
|
-
});
|
|
77
|
-
expect(r).toContain("earlier lines omitted");
|
|
78
|
-
expect(r).toContain("latest");
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("wraps final output including recall note", () => {
|
|
82
|
-
const r = compile({
|
|
83
|
-
messages: [userMsg("check final summary wrapping")],
|
|
84
|
-
});
|
|
85
|
-
const maxLineLength = Math.max(...r.split("\n").map((line) => line.length));
|
|
86
|
-
expect(r).toContain("vcc_recall");
|
|
87
|
-
expect(maxLineLength).toBeLessThanOrEqual(120);
|
|
88
|
-
});
|
|
89
|
-
});
|
package/tests/content.test.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "bun:test";
|
|
2
|
-
import { textOf, thinkingOf, clip, firstLine } from "../src/core/content";
|
|
3
|
-
|
|
4
|
-
describe("textOf", () => {
|
|
5
|
-
it("returns empty string for undefined content", () => {
|
|
6
|
-
expect(textOf(undefined as any)).toBe("");
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it("returns empty string for null content", () => {
|
|
10
|
-
expect(textOf(null as any)).toBe("");
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns string content as-is", () => {
|
|
14
|
-
expect(textOf("hello")).toBe("hello");
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it("extracts text parts from array content", () => {
|
|
18
|
-
const content = [
|
|
19
|
-
{ type: "text" as const, text: "first" },
|
|
20
|
-
{ type: "toolCall" as const, name: "x", id: "1", arguments: {} },
|
|
21
|
-
{ type: "text" as const, text: "second" },
|
|
22
|
-
];
|
|
23
|
-
expect(textOf(content)).toBe("first\nsecond");
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it("ignores thinking parts", () => {
|
|
27
|
-
const content = [
|
|
28
|
-
{ type: "thinking" as const, thinking: "let me think" },
|
|
29
|
-
{ type: "text" as const, text: "here is the answer" },
|
|
30
|
-
];
|
|
31
|
-
expect(textOf(content)).toBe("here is the answer");
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe("thinkingOf", () => {
|
|
36
|
-
it("returns empty string for undefined content", () => {
|
|
37
|
-
expect(thinkingOf(undefined as any)).toBe("");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it("returns empty string for string content", () => {
|
|
41
|
-
expect(thinkingOf("hello")).toBe("");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("extracts thinking parts from array content", () => {
|
|
45
|
-
const content = [
|
|
46
|
-
{ type: "thinking" as const, thinking: "let me think" },
|
|
47
|
-
{ type: "text" as const, text: "here is the answer" },
|
|
48
|
-
];
|
|
49
|
-
expect(thinkingOf(content)).toBe("let me think");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("joins multiple thinking parts", () => {
|
|
53
|
-
const content = [
|
|
54
|
-
{ type: "thinking" as const, thinking: "first thought" },
|
|
55
|
-
{ type: "text" as const, text: "answer" },
|
|
56
|
-
{ type: "thinking" as const, thinking: "second thought" },
|
|
57
|
-
];
|
|
58
|
-
expect(thinkingOf(content)).toBe("first thought\nsecond thought");
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
describe("textOf", () => {
|
|
63
|
-
it("returns empty string for undefined content", () => {
|
|
64
|
-
expect(textOf(undefined as any)).toBe("");
|
|
65
|
-
});
|
|
66
|
-
});
|