forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit-feature-parity.ts
More file actions
194 lines (173 loc) · 5.21 KB
/
Copy pathsplit-feature-parity.ts
File metadata and controls
194 lines (173 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// showcase/scripts/split-feature-parity.ts
// One-time migration: split feature-parity.json into d4/ and d6/ files
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const AIMOCK_DIR = path.resolve(__dirname, "..", "aimock");
interface Fixture {
_comment?: string;
match: Record<string, unknown>;
response: unknown;
}
interface FixtureFile {
fixtures: Fixture[];
}
const INTEGRATIONS = [
"langgraph-python",
"langgraph-typescript",
"langgraph-fastapi",
"google-adk",
"mastra",
"crewai-crews",
"pydantic-ai",
"claude-sdk-python",
"claude-sdk-typescript",
"agno",
"ag2",
"llamaindex",
"strands",
"langroid",
"ms-agent-python",
"ms-agent-dotnet",
"spring-ai",
"built-in-agent",
];
const fp: FixtureFile = JSON.parse(
readFileSync(path.join(AIMOCK_DIR, "feature-parity.json"), "utf-8"),
);
// Also load d5-all.json to find and skip duplicates
const d5All: FixtureFile = JSON.parse(
readFileSync(path.join(AIMOCK_DIR, "d5-all.json"), "utf-8"),
);
const d5MatchKeys = new Set<string>();
for (const f of d5All.fixtures) {
d5MatchKeys.add(JSON.stringify(f.match));
}
// Categorize: fixtures with simple userMessage patterns (single-turn
// chat/tool smoke) go to d4/; multi-turn deep conversation fixtures
// go to d6/
const d4Fixtures: Fixture[] = [];
const d6Fixtures: Fixture[] = [];
let skippedDupes = 0;
for (const f of fp.fixtures) {
// Skip fixtures that already exist in d5-all.json (they'll be in d6/)
const matchKey = JSON.stringify(f.match);
if (d5MatchKeys.has(matchKey)) {
skippedDupes++;
continue;
}
const comment = String(f._comment ?? "").toLowerCase();
const turnIndex = f.match.turnIndex;
// Simple heuristic: chat/tools smoke fixtures are single-turn (no
// turnIndex or turnIndex=0), no multi-step conversation context.
// Multi-turn fixtures have turnIndex > 0 or reference tool results.
if (
(turnIndex !== undefined && (turnIndex as number) > 0) ||
comment.includes("multi-turn") ||
comment.includes("conversation") ||
comment.includes("pill")
) {
d6Fixtures.push(f);
} else {
d4Fixtures.push(f);
}
}
console.log(`Skipped ${skippedDupes} duplicates (already in d5-all.json / d6)`);
console.log(`D4 (chat/tools): ${d4Fixtures.length}`);
console.log(`D6 (deep): ${d6Fixtures.length}`);
// Write D4 fixtures per integration
for (const slug of INTEGRATIONS) {
const d4Dir = path.join(AIMOCK_DIR, "d4", slug);
mkdirSync(d4Dir, { recursive: true });
// Chat fixtures (non-tool related)
const chatFixtures = d4Fixtures
.filter((f) => {
const comment = String(f._comment ?? "").toLowerCase();
return !comment.includes("tool");
})
.map((f) => ({
...(f._comment ? { _comment: f._comment } : {}),
match: { ...f.match, context: slug },
response: f.response,
}));
if (chatFixtures.length > 0) {
writeFileSync(
path.join(d4Dir, "chat.json"),
JSON.stringify(
{
_meta: {
description: `D4 chat fixtures for ${slug}`,
sourceFile: "feature-parity.json",
created: new Date().toISOString().split("T")[0],
},
fixtures: chatFixtures,
},
null,
2,
),
);
}
// Tools fixtures
const toolsFixtures = d4Fixtures
.filter((f) => {
const comment = String(f._comment ?? "").toLowerCase();
return comment.includes("tool");
})
.map((f) => ({
...(f._comment ? { _comment: f._comment } : {}),
match: { ...f.match, context: slug },
response: f.response,
}));
if (toolsFixtures.length > 0) {
writeFileSync(
path.join(d4Dir, "tools.json"),
JSON.stringify(
{
_meta: {
description: `D4 tools fixtures for ${slug}`,
sourceFile: "feature-parity.json",
created: new Date().toISOString().split("T")[0],
},
fixtures: toolsFixtures,
},
null,
2,
),
);
}
console.log(`Wrote d4/${slug}/`);
}
// D6 deep conversation fixtures from feature-parity -- merge into
// existing d6/<integration>/ files or create new ones
for (const slug of INTEGRATIONS) {
const d6Dir = path.join(AIMOCK_DIR, "d6", slug);
mkdirSync(d6Dir, { recursive: true });
// Group by inferred feature type from _comment
const contextFixtures = d6Fixtures.map((f) => ({
...(f._comment ? { _comment: f._comment } : {}),
match: { ...f.match, context: slug },
response: f.response,
}));
if (contextFixtures.length > 0) {
// Append to a catch-all file for now; manual review will
// redistribute to per-feature files
writeFileSync(
path.join(d6Dir, "_from-feature-parity.json"),
JSON.stringify(
{
_meta: {
description: `Deep fixtures from feature-parity.json for ${slug} (needs manual redistribution)`,
created: new Date().toISOString().split("T")[0],
},
fixtures: contextFixtures,
},
null,
2,
),
);
}
}
console.log(
`\nDone. D4: ${d4Fixtures.length} per integration, D6 overflow: ${d6Fixtures.length} per integration.`,
);