@silvery/examples 0.17.3 → 0.17.4
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/dist/UPNG-Cy7ViL8f.mjs +5074 -0
- package/dist/__vite-browser-external-2447137e-BML7CYau.mjs +4 -0
- package/dist/_banner-DLPxCqVy.mjs +44 -0
- package/dist/ansi-CCE2pVS0.mjs +16397 -0
- package/dist/apng-HhhBjRGt.mjs +68 -0
- package/dist/apng-mwUQbTTF.mjs +3 -0
- package/dist/apps/aichat/index.mjs +1299 -0
- package/dist/apps/app-todo.mjs +139 -0
- package/dist/apps/async-data.mjs +204 -0
- package/dist/apps/cli-wizard.mjs +339 -0
- package/dist/apps/clipboard.mjs +198 -0
- package/dist/apps/components.mjs +864 -0
- package/dist/apps/data-explorer.mjs +483 -0
- package/dist/apps/dev-tools.mjs +397 -0
- package/dist/apps/explorer.mjs +698 -0
- package/dist/apps/gallery.mjs +766 -0
- package/dist/apps/inline-bench.mjs +115 -0
- package/dist/apps/kanban.mjs +280 -0
- package/dist/apps/layout-ref.mjs +187 -0
- package/dist/apps/outline.mjs +203 -0
- package/dist/apps/paste-demo.mjs +189 -0
- package/dist/apps/scroll.mjs +86 -0
- package/dist/apps/search-filter.mjs +287 -0
- package/dist/apps/selection.mjs +355 -0
- package/dist/apps/spatial-focus-demo.mjs +388 -0
- package/dist/apps/task-list.mjs +258 -0
- package/dist/apps/terminal-caps-demo.mjs +315 -0
- package/dist/apps/terminal.mjs +872 -0
- package/dist/apps/text-selection-demo.mjs +254 -0
- package/dist/apps/textarea.mjs +178 -0
- package/dist/apps/theme.mjs +661 -0
- package/dist/apps/transform.mjs +215 -0
- package/dist/apps/virtual-10k.mjs +422 -0
- package/dist/assets/resvgjs.darwin-arm64-BtufyGW1.node +0 -0
- package/dist/backends-Bahh9mKN.mjs +1179 -0
- package/dist/backends-CCtCDQ94.mjs +3 -0
- package/dist/{cli.mjs → bin/cli.mjs} +15 -19
- package/dist/chunk-BSw8zbkd.mjs +37 -0
- package/dist/components/counter.mjs +48 -0
- package/dist/components/hello.mjs +31 -0
- package/dist/components/progress-bar.mjs +59 -0
- package/dist/components/select-list.mjs +85 -0
- package/dist/components/spinner.mjs +57 -0
- package/dist/components/text-input.mjs +62 -0
- package/dist/components/virtual-list.mjs +51 -0
- package/dist/flexily-zero-adapter-UB-ra8fR.mjs +3374 -0
- package/dist/gif-BZaqPPVX.mjs +3 -0
- package/dist/gif-BtnXuxLF.mjs +71 -0
- package/dist/gifenc-CLRW41dk.mjs +728 -0
- package/dist/jsx-runtime-dMs_8fNu.mjs +241 -0
- package/dist/key-mapping-5oYQdAQE.mjs +3 -0
- package/dist/key-mapping-D4LR1go6.mjs +130 -0
- package/dist/layout/dashboard.mjs +1204 -0
- package/dist/layout/live-resize.mjs +303 -0
- package/dist/layout/overflow.mjs +70 -0
- package/dist/layout/text-layout.mjs +335 -0
- package/dist/node-NuJ94BWl.mjs +1083 -0
- package/dist/plugins-D1KtkT4a.mjs +3057 -0
- package/dist/resvg-js-C_8Wps1F.mjs +201 -0
- package/dist/src-BTEVGpd9.mjs +23538 -0
- package/dist/src-CUUOuRH6.mjs +5322 -0
- package/dist/src-CzfRafCQ.mjs +814 -0
- package/dist/usingCtx-CsEf0xO3.mjs +57 -0
- package/dist/yoga-adapter-BVtQ5OJR.mjs +237 -0
- package/package.json +18 -13
- package/_banner.tsx +0 -60
- package/apps/aichat/components.tsx +0 -469
- package/apps/aichat/index.tsx +0 -220
- package/apps/aichat/script.ts +0 -460
- package/apps/aichat/state.ts +0 -325
- package/apps/aichat/types.ts +0 -19
- package/apps/app-todo.tsx +0 -201
- package/apps/async-data.tsx +0 -196
- package/apps/cli-wizard.tsx +0 -332
- package/apps/clipboard.tsx +0 -183
- package/apps/components.tsx +0 -658
- package/apps/data-explorer.tsx +0 -490
- package/apps/dev-tools.tsx +0 -395
- package/apps/explorer.tsx +0 -731
- package/apps/gallery.tsx +0 -653
- package/apps/inline-bench.tsx +0 -138
- package/apps/kanban.tsx +0 -265
- package/apps/layout-ref.tsx +0 -173
- package/apps/outline.tsx +0 -160
- package/apps/panes/index.tsx +0 -203
- package/apps/paste-demo.tsx +0 -185
- package/apps/scroll.tsx +0 -80
- package/apps/search-filter.tsx +0 -240
- package/apps/selection.tsx +0 -346
- package/apps/spatial-focus-demo.tsx +0 -372
- package/apps/task-list.tsx +0 -271
- package/apps/terminal-caps-demo.tsx +0 -317
- package/apps/terminal.tsx +0 -784
- package/apps/text-selection-demo.tsx +0 -193
- package/apps/textarea.tsx +0 -155
- package/apps/theme.tsx +0 -515
- package/apps/transform.tsx +0 -229
- package/apps/virtual-10k.tsx +0 -405
- package/apps/vterm-demo/index.tsx +0 -216
- package/components/counter.tsx +0 -49
- package/components/hello.tsx +0 -38
- package/components/progress-bar.tsx +0 -52
- package/components/select-list.tsx +0 -54
- package/components/spinner.tsx +0 -44
- package/components/text-input.tsx +0 -61
- package/components/virtual-list.tsx +0 -56
- package/dist/cli.d.mts +0 -1
- package/dist/cli.mjs.map +0 -1
- package/layout/dashboard.tsx +0 -953
- package/layout/live-resize.tsx +0 -282
- package/layout/overflow.tsx +0 -51
- package/layout/text-layout.tsx +0 -283
package/apps/aichat/script.ts
DELETED
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Script data for the AI coding agent demo.
|
|
3
|
-
*
|
|
4
|
-
* Contains the realistic conversation script, random prompts for off-script
|
|
5
|
-
* mode, and the stress test generator for performance testing.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { ScriptEntry } from "./types.js"
|
|
9
|
-
|
|
10
|
-
// ============================================================================
|
|
11
|
-
// Constants
|
|
12
|
-
// ============================================================================
|
|
13
|
-
|
|
14
|
-
export const MODEL_NAME = "claude-opus-4-6"
|
|
15
|
-
export const INPUT_COST_PER_M = 15 // $/M input tokens
|
|
16
|
-
export const OUTPUT_COST_PER_M = 75 // $/M output tokens
|
|
17
|
-
export const CONTEXT_WINDOW = 200_000
|
|
18
|
-
|
|
19
|
-
export const TOOL_COLORS: Record<string, string> = {
|
|
20
|
-
Read: "$info",
|
|
21
|
-
Edit: "$warning",
|
|
22
|
-
Bash: "$error",
|
|
23
|
-
Write: "$accent",
|
|
24
|
-
Glob: "$muted",
|
|
25
|
-
Grep: "$success",
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const TOOL_ICONS: Record<string, string> = {
|
|
29
|
-
Read: "📖",
|
|
30
|
-
Edit: "✏️",
|
|
31
|
-
Bash: "⚡",
|
|
32
|
-
Write: "📝",
|
|
33
|
-
Glob: "🔍",
|
|
34
|
-
Grep: "🔎",
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** Random user commands for Tab-to-inject feature. */
|
|
38
|
-
export const RANDOM_USER_COMMANDS = [
|
|
39
|
-
"Can you add unit tests for the auth module?",
|
|
40
|
-
"Refactor the database queries to use prepared statements.",
|
|
41
|
-
"Add TypeScript strict mode and fix any errors.",
|
|
42
|
-
"Set up CI/CD with GitHub Actions.",
|
|
43
|
-
"The search feature is slow — can you optimize it?",
|
|
44
|
-
"Add dark mode support to the UI.",
|
|
45
|
-
"We need input validation on the registration form.",
|
|
46
|
-
"Create a migration script for the new schema.",
|
|
47
|
-
"Add WebSocket support for real-time updates.",
|
|
48
|
-
"The CSV export is broken — dates are wrong.",
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
/** Random agent responses for Tab-injected turns. */
|
|
52
|
-
export const RANDOM_AGENT_RESPONSES: ScriptEntry[] = [
|
|
53
|
-
{
|
|
54
|
-
role: "agent",
|
|
55
|
-
thinking: "Let me analyze the codebase to understand the current structure.",
|
|
56
|
-
content: "I'll look at the relevant files and make the changes.",
|
|
57
|
-
toolCalls: [
|
|
58
|
-
{ tool: "Read", args: "src/index.ts", output: ["export function main() { /* ... */ }"] },
|
|
59
|
-
{ tool: "Edit", args: "src/index.ts", output: ["+ // Updated implementation"] },
|
|
60
|
-
],
|
|
61
|
-
tokens: { input: 12400, output: 890 },
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
role: "agent",
|
|
65
|
-
content: "Done! I've made the changes and verified everything works.",
|
|
66
|
-
tokens: { input: 15200, output: 340 },
|
|
67
|
-
},
|
|
68
|
-
]
|
|
69
|
-
|
|
70
|
-
/** Regex matching https/http URLs in output text. */
|
|
71
|
-
export const URL_RE = /https?:\/\/[^\s)]+/g
|
|
72
|
-
|
|
73
|
-
// ============================================================================
|
|
74
|
-
// Script — Realistic coding agent story with thinking + tokens
|
|
75
|
-
// ============================================================================
|
|
76
|
-
|
|
77
|
-
export const SCRIPT: ScriptEntry[] = [
|
|
78
|
-
{
|
|
79
|
-
role: "user",
|
|
80
|
-
content: "Fix the login bug in auth.ts — expired tokens throw instead of refreshing.",
|
|
81
|
-
tokens: { input: 84, output: 0 },
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
role: "agent",
|
|
85
|
-
thinking:
|
|
86
|
-
"The user reports expired tokens throw instead of refreshing. This is likely in the token validation flow. I should read auth.ts to see the current expiry check logic. The bug is probably comparing jwt.exp (seconds) with Date.now() (milliseconds).",
|
|
87
|
-
content: "Let me look at the auth module.",
|
|
88
|
-
toolCalls: [
|
|
89
|
-
{
|
|
90
|
-
tool: "Read",
|
|
91
|
-
args: "src/auth.ts",
|
|
92
|
-
output: [
|
|
93
|
-
"export async function login(token: string) {",
|
|
94
|
-
" const decoded = jwt.decode(token)",
|
|
95
|
-
" if (decoded.exp < Date.now()) {",
|
|
96
|
-
' throw new Error("Token expired")',
|
|
97
|
-
" }",
|
|
98
|
-
" return decoded.user",
|
|
99
|
-
"}",
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
tokens: { input: 3694, output: 624 },
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
role: "agent",
|
|
107
|
-
thinking:
|
|
108
|
-
"Found it — decoded.exp is in seconds (Unix timestamp) but Date.now() returns milliseconds. Every token appears expired because exp (e.g. 1700000000) is always less than Date.now() (e.g. 1700000000000). I need to divide Date.now() by 1000, and change the throw to a refresh call.",
|
|
109
|
-
content: "Found it. The expiry check compares seconds (jwt.exp) to milliseconds (Date.now()). Fixing now.",
|
|
110
|
-
toolCalls: [
|
|
111
|
-
{
|
|
112
|
-
tool: "Edit",
|
|
113
|
-
args: "src/auth.ts",
|
|
114
|
-
output: [
|
|
115
|
-
" const decoded = jwt.decode(token)",
|
|
116
|
-
"- if (decoded.exp < Date.now()) {",
|
|
117
|
-
'- throw new Error("Token expired")',
|
|
118
|
-
"+ if (decoded.exp < Date.now() / 1000) {",
|
|
119
|
-
"+ return refreshToken(token)",
|
|
120
|
-
" }",
|
|
121
|
-
],
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
tokens: { input: 4312, output: 574 },
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
role: "agent",
|
|
128
|
-
content: "Running tests to verify the fix.",
|
|
129
|
-
toolCalls: [
|
|
130
|
-
{
|
|
131
|
-
tool: "Bash",
|
|
132
|
-
args: "bun test src/auth.test.ts",
|
|
133
|
-
output: [
|
|
134
|
-
"auth.test.ts",
|
|
135
|
-
" ✓ login with valid token (2ms)",
|
|
136
|
-
" ✓ login with expired token refreshes (3ms)",
|
|
137
|
-
" ✓ login with invalid token rejects (1ms)",
|
|
138
|
-
"",
|
|
139
|
-
"3 passed | 0 failed",
|
|
140
|
-
],
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
tokens: { input: 4978, output: 312 },
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
role: "agent",
|
|
147
|
-
content:
|
|
148
|
-
"Fixed! The bug was comparing jwt.exp (seconds since epoch) with Date.now() (milliseconds). Expired tokens now trigger a refresh instead of throwing.",
|
|
149
|
-
tokens: { input: 5202, output: 178 },
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
role: "user",
|
|
153
|
-
content: "Nice. Can you also add rate limiting to the login endpoint?",
|
|
154
|
-
tokens: { input: 116, output: 0 },
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
role: "agent",
|
|
158
|
-
thinking:
|
|
159
|
-
"The user wants rate limiting on login. I should check if there's existing rate limiting infrastructure before building from scratch. Let me search for rate-limit patterns in the codebase.",
|
|
160
|
-
content: "I'll check what rate limiting infrastructure exists.",
|
|
161
|
-
toolCalls: [
|
|
162
|
-
{
|
|
163
|
-
tool: "Grep",
|
|
164
|
-
args: "rateLimit|rate-limit",
|
|
165
|
-
output: [
|
|
166
|
-
"src/middleware/rate-limit.ts",
|
|
167
|
-
"src/config.ts",
|
|
168
|
-
"See https://docs.example.com/api/rate-limiting for API docs",
|
|
169
|
-
],
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
tool: "Read",
|
|
173
|
-
args: "src/middleware/rate-limit.ts",
|
|
174
|
-
output: [
|
|
175
|
-
"import { RateLimiter } from '@lib/rate-limit'",
|
|
176
|
-
"",
|
|
177
|
-
"export function createLimiter(opts: { window: number; max: number }) {",
|
|
178
|
-
" return new RateLimiter(opts)",
|
|
179
|
-
"}",
|
|
180
|
-
],
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
tokens: { input: 6490, output: 846 },
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
role: "agent",
|
|
187
|
-
thinking:
|
|
188
|
-
"Good — there's already a RateLimiter abstraction. I just need to create an instance with appropriate settings (5 attempts per 60s window seems reasonable for login) and wire it into the auth route as middleware.",
|
|
189
|
-
content: "Good, there's already a rate limiter. I'll wire it into the auth route.",
|
|
190
|
-
toolCalls: [
|
|
191
|
-
{
|
|
192
|
-
tool: "Edit",
|
|
193
|
-
args: "src/routes/auth.ts",
|
|
194
|
-
output: [
|
|
195
|
-
"+ import { createLimiter } from '../middleware/rate-limit'",
|
|
196
|
-
"+",
|
|
197
|
-
"+ const loginLimiter = createLimiter({ window: 60_000, max: 5 })",
|
|
198
|
-
"+",
|
|
199
|
-
" router.post('/login', async (req, res) => {",
|
|
200
|
-
"+ const limited = await loginLimiter.check(req.ip)",
|
|
201
|
-
"+ if (limited) return res.status(429).json({ error: 'Too many attempts' })",
|
|
202
|
-
" const { token } = req.body",
|
|
203
|
-
],
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
tokens: { input: 7782, output: 756 },
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
role: "agent",
|
|
210
|
-
content: "Running the full test suite.",
|
|
211
|
-
toolCalls: [
|
|
212
|
-
{
|
|
213
|
-
tool: "Bash",
|
|
214
|
-
args: "bun test",
|
|
215
|
-
output: [
|
|
216
|
-
"auth.test.ts ........... 3 passed",
|
|
217
|
-
"rate-limit.test.ts ..... 5 passed",
|
|
218
|
-
"routes/auth.test.ts .... 7 passed",
|
|
219
|
-
"",
|
|
220
|
-
"15 passed | 0 failed | 3 files",
|
|
221
|
-
],
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
tokens: { input: 8204, output: 334 },
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
role: "agent",
|
|
228
|
-
content: "Rate limiting added: 5 attempts per minute per IP on the login endpoint. All 15 tests pass.",
|
|
229
|
-
tokens: { input: 8468, output: 156 },
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
role: "user",
|
|
233
|
-
content: "Now add i18n support for error messages. We need 日本語 (Japanese) and Deutsch (German). 🌍",
|
|
234
|
-
tokens: { input: 146, output: 0 },
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
role: "agent",
|
|
238
|
-
thinking:
|
|
239
|
-
"i18n for error messages — I need to create translation JSON files for ja and de, then build a simple t() function that resolves message keys by locale. I'll also need to update the error responses in auth.ts to use t() with the request's locale.",
|
|
240
|
-
content: "I'll create the translation files and update the error handling.",
|
|
241
|
-
toolCalls: [
|
|
242
|
-
{
|
|
243
|
-
tool: "Write",
|
|
244
|
-
args: "src/i18n/ja.json",
|
|
245
|
-
output: [
|
|
246
|
-
"{",
|
|
247
|
-
' "token_expired": "トークンの有効期限が切れました 🔧",',
|
|
248
|
-
' "rate_limited": "リクエストが多すぎます。後でもう一度お試しください",',
|
|
249
|
-
' "invalid_token": "無効なトークンです 🐛",',
|
|
250
|
-
' "login_success": "ログイン成功 ✅"',
|
|
251
|
-
"}",
|
|
252
|
-
],
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
tool: "Write",
|
|
256
|
-
args: "src/i18n/de.json",
|
|
257
|
-
output: [
|
|
258
|
-
"{",
|
|
259
|
-
' "token_expired": "Token abgelaufen",',
|
|
260
|
-
' "rate_limited": "Zu viele Anfragen. Bitte versuchen Sie es später",',
|
|
261
|
-
' "invalid_token": "Ungültiges Token",',
|
|
262
|
-
' "login_success": "Anmeldung erfolgreich"',
|
|
263
|
-
"}",
|
|
264
|
-
],
|
|
265
|
-
},
|
|
266
|
-
],
|
|
267
|
-
tokens: { input: 17868, output: 1134 },
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
role: "agent",
|
|
271
|
-
thinking:
|
|
272
|
-
"Now I need the i18n loader module that imports the locale files and exports a t() function. The function should look up the key in the requested locale, falling back to English defaults. Then I'll wire it into the auth error responses.",
|
|
273
|
-
content: "Now I'll create the i18n loader and wire it into the error responses.",
|
|
274
|
-
toolCalls: [
|
|
275
|
-
{
|
|
276
|
-
tool: "Write",
|
|
277
|
-
args: "src/i18n/index.ts",
|
|
278
|
-
output: [
|
|
279
|
-
"import ja from './ja.json'",
|
|
280
|
-
"import de from './de.json'",
|
|
281
|
-
"",
|
|
282
|
-
"const locales = { ja, de, en: { /* defaults */ } }",
|
|
283
|
-
"",
|
|
284
|
-
"export function t(key: string, lang = 'en'): string {",
|
|
285
|
-
" return locales[lang]?.[key] ?? locales.en[key] ?? key",
|
|
286
|
-
"}",
|
|
287
|
-
],
|
|
288
|
-
},
|
|
289
|
-
{
|
|
290
|
-
tool: "Edit",
|
|
291
|
-
args: "src/auth.ts",
|
|
292
|
-
output: [
|
|
293
|
-
"+ import { t } from './i18n'",
|
|
294
|
-
"",
|
|
295
|
-
"- return res.status(429).json({ error: 'Too many attempts' })",
|
|
296
|
-
"+ return res.status(429).json({ error: t('rate_limited', req.lang) })",
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
tokens: { input: 19752, output: 890 },
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
role: "agent",
|
|
304
|
-
content: "Running tests with locale coverage.",
|
|
305
|
-
toolCalls: [
|
|
306
|
-
{
|
|
307
|
-
tool: "Bash",
|
|
308
|
-
args: "bun test src/i18n/",
|
|
309
|
-
output: [
|
|
310
|
-
"i18n.test.ts",
|
|
311
|
-
" ✓ English fallback for unknown key",
|
|
312
|
-
" ✓ Japanese: トークンの有効期限が切れました 🔧",
|
|
313
|
-
" ✓ German: Token abgelaufen",
|
|
314
|
-
" ✓ Emoji preserved in translations 🐛✅",
|
|
315
|
-
"",
|
|
316
|
-
"4 passed | 0 failed",
|
|
317
|
-
],
|
|
318
|
-
},
|
|
319
|
-
],
|
|
320
|
-
tokens: { input: 20468, output: 356 },
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
role: "agent",
|
|
324
|
-
content:
|
|
325
|
-
"i18n support added with Japanese (日本語) and German (Deutsch) translations. Error messages are now locale-aware. 🌍✅",
|
|
326
|
-
tokens: { input: 20802, output: 134 },
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
role: "user",
|
|
330
|
-
content: "Add a health check endpoint at /health that returns the service version.",
|
|
331
|
-
tokens: { input: 104, output: 0 },
|
|
332
|
-
},
|
|
333
|
-
{
|
|
334
|
-
role: "agent",
|
|
335
|
-
thinking:
|
|
336
|
-
"Simple task — read the version from package.json and expose it on GET /health alongside uptime. Quick implementation.",
|
|
337
|
-
content: "Simple addition — reading package.json for the version, then adding the route.",
|
|
338
|
-
toolCalls: [
|
|
339
|
-
{
|
|
340
|
-
tool: "Read",
|
|
341
|
-
args: "package.json",
|
|
342
|
-
output: ["{", ' "name": "auth-service",', ' "version": "2.4.1",', " ...", "}"],
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
tool: "Edit",
|
|
346
|
-
args: "src/routes/health.ts",
|
|
347
|
-
output: [
|
|
348
|
-
"+ import { version } from '../../package.json'",
|
|
349
|
-
"+",
|
|
350
|
-
"+ router.get('/health', (req, res) => {",
|
|
351
|
-
"+ res.json({ status: 'ok', version, uptime: process.uptime() })",
|
|
352
|
-
"+ })",
|
|
353
|
-
],
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
tokens: { input: 21578, output: 468 },
|
|
357
|
-
},
|
|
358
|
-
{
|
|
359
|
-
role: "agent",
|
|
360
|
-
content: "Running final tests.",
|
|
361
|
-
toolCalls: [
|
|
362
|
-
{
|
|
363
|
-
tool: "Bash",
|
|
364
|
-
args: "bun test",
|
|
365
|
-
output: [
|
|
366
|
-
"auth.test.ts ........... 3 passed",
|
|
367
|
-
"rate-limit.test.ts ..... 5 passed",
|
|
368
|
-
"routes/auth.test.ts .... 7 passed",
|
|
369
|
-
"routes/health.test.ts .. 2 passed",
|
|
370
|
-
"i18n.test.ts ........... 4 passed",
|
|
371
|
-
"",
|
|
372
|
-
"21 passed | 0 failed | 5 files",
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
],
|
|
376
|
-
tokens: { input: 22046, output: 290 },
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
role: "agent",
|
|
380
|
-
content:
|
|
381
|
-
"All done! Summary of changes:\n• Fixed token expiry bug (seconds vs milliseconds)\n• Added rate limiting (5 req/min per IP)\n• Added i18n support (日本語 + Deutsch) 🌍\n• Added /health endpoint (v2.4.1)\n\nAll 21 tests pass. Ready to commit?",
|
|
382
|
-
tokens: { input: 22468, output: 224 },
|
|
383
|
-
},
|
|
384
|
-
]
|
|
385
|
-
|
|
386
|
-
// ============================================================================
|
|
387
|
-
// Stress test script — 200 programmatically generated exchanges
|
|
388
|
-
// ============================================================================
|
|
389
|
-
|
|
390
|
-
export function generateStressScript(): ScriptEntry[] {
|
|
391
|
-
const exchanges: ScriptEntry[] = []
|
|
392
|
-
const tools = ["Read", "Edit", "Bash", "Write", "Grep", "Glob"]
|
|
393
|
-
const files = [
|
|
394
|
-
"src/auth.ts",
|
|
395
|
-
"src/db.ts",
|
|
396
|
-
"src/routes/api.ts",
|
|
397
|
-
"src/middleware/cors.ts",
|
|
398
|
-
"src/utils/crypto.ts",
|
|
399
|
-
"src/config.ts",
|
|
400
|
-
"tests/integration.test.ts",
|
|
401
|
-
"src/i18n/日本語.json",
|
|
402
|
-
]
|
|
403
|
-
|
|
404
|
-
let cumulativeInput = 4000
|
|
405
|
-
|
|
406
|
-
for (let i = 0; i < 200; i++) {
|
|
407
|
-
if (i % 5 === 0) {
|
|
408
|
-
const prompts = [
|
|
409
|
-
`Fix bug #${100 + i} in ${files[i % files.length]}`,
|
|
410
|
-
`Add feature: ${["caching", "logging", "retry", "batching", "バリデーション"][i % 5]}`,
|
|
411
|
-
`Refactor ${files[i % files.length]} — it's too complex 🔧`,
|
|
412
|
-
`Why is test #${i} failing? 🐛`,
|
|
413
|
-
`Add 日本語 translations for module ${i}`,
|
|
414
|
-
]
|
|
415
|
-
exchanges.push({
|
|
416
|
-
role: "user",
|
|
417
|
-
content: prompts[Math.floor(i / 5) % prompts.length]!,
|
|
418
|
-
tokens: { input: 40 + (i % 30), output: 0 },
|
|
419
|
-
})
|
|
420
|
-
} else if (i % 5 === 4) {
|
|
421
|
-
exchanges.push({
|
|
422
|
-
role: "agent",
|
|
423
|
-
content: `Done with batch ${Math.floor(i / 5) + 1}. ${3 + (i % 7)} tests pass. ✅`,
|
|
424
|
-
tokens: { input: cumulativeInput, output: 45 + (i % 60) },
|
|
425
|
-
})
|
|
426
|
-
} else {
|
|
427
|
-
const tool = tools[i % tools.length]!
|
|
428
|
-
const file = files[i % files.length]!
|
|
429
|
-
cumulativeInput += 200 + (i % 300)
|
|
430
|
-
exchanges.push({
|
|
431
|
-
role: "agent",
|
|
432
|
-
thinking: i % 3 === 0 ? `Analyzing ${file} for the reported issue...` : undefined,
|
|
433
|
-
content: `Working on ${file}...`,
|
|
434
|
-
toolCalls: [
|
|
435
|
-
{
|
|
436
|
-
tool,
|
|
437
|
-
args: tool === "Bash" ? `bun test ${file.replace("src/", "tests/")}` : file,
|
|
438
|
-
output: [
|
|
439
|
-
`// ${tool} output for ${file}`,
|
|
440
|
-
`line ${i * 10 + 1}: processing...`,
|
|
441
|
-
tool === "Edit" ? `- old code at line ${i}` : ` existing line ${i}`,
|
|
442
|
-
tool === "Edit" ? `+ new code at line ${i}` : ` result: ok`,
|
|
443
|
-
i % 10 === 0 ? `✓ テスト合格 🎉` : `✓ done`,
|
|
444
|
-
],
|
|
445
|
-
},
|
|
446
|
-
],
|
|
447
|
-
tokens: { input: cumulativeInput, output: 120 + (i % 200) },
|
|
448
|
-
})
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (i === 80 || i === 160) {
|
|
452
|
-
exchanges.push({
|
|
453
|
-
role: "system",
|
|
454
|
-
content: `📦 Compaction #${i === 80 ? 1 : 2}: context cleared. Scrollback preserved above.`,
|
|
455
|
-
})
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
return exchanges
|
|
460
|
-
}
|