@koinzhang/paseo-plugin-activity 0.1.0

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.
Files changed (52) hide show
  1. package/client/activity-heatmap.tsx +138 -0
  2. package/client/global-surface.tsx +689 -0
  3. package/client/panel.tsx +423 -0
  4. package/client/pending-skill.ts +50 -0
  5. package/client/pill-data-cache.test.ts +68 -0
  6. package/client/pill-data-cache.ts +37 -0
  7. package/client/pill.tsx +211 -0
  8. package/client/provider-filter.test.ts +95 -0
  9. package/client/provider-filter.ts +44 -0
  10. package/client/rank-color.test.ts +35 -0
  11. package/client/rank-color.ts +69 -0
  12. package/client/usage-popover.tsx +383 -0
  13. package/client/usage-query.tsx +54 -0
  14. package/client/usage-stats.tsx +18 -0
  15. package/client/use-app-language.ts +14 -0
  16. package/client/web.ts +28 -0
  17. package/index.client.tsx +62 -0
  18. package/index.server.ts +128 -0
  19. package/package.json +31 -0
  20. package/paseo-plugin.json +6 -0
  21. package/server/agents.test.ts +67 -0
  22. package/server/agents.ts +75 -0
  23. package/server/background-sync.test.ts +143 -0
  24. package/server/background-sync.ts +105 -0
  25. package/server/handlers-query.test.ts +91 -0
  26. package/server/handlers.ts +531 -0
  27. package/server/host-types.ts +14 -0
  28. package/server/ingest.test.ts +233 -0
  29. package/server/ingest.ts +277 -0
  30. package/server/mcp-servers.test.ts +70 -0
  31. package/server/mcp-servers.ts +212 -0
  32. package/server/messages.test.ts +150 -0
  33. package/server/migrate-data.test.ts +65 -0
  34. package/server/migrate-data.ts +54 -0
  35. package/server/resolve-model.test.ts +11 -0
  36. package/server/resolve-model.ts +30 -0
  37. package/server/skill-path.test.ts +56 -0
  38. package/server/skill-path.ts +85 -0
  39. package/server/store.test.ts +221 -0
  40. package/server/store.ts +909 -0
  41. package/server/ttl-cache.ts +34 -0
  42. package/shared/activity.test.ts +86 -0
  43. package/shared/activity.ts +185 -0
  44. package/shared/classify.test.ts +306 -0
  45. package/shared/classify.ts +378 -0
  46. package/shared/format.test.ts +48 -0
  47. package/shared/format.ts +45 -0
  48. package/shared/insights.test.ts +122 -0
  49. package/shared/insights.ts +188 -0
  50. package/shared/plugin-id.ts +7 -0
  51. package/shared/usage.test.ts +668 -0
  52. package/shared/usage.ts +726 -0
@@ -0,0 +1,668 @@
1
+ import assert from "node:assert/strict";
2
+ import { describe, it } from "node:test";
3
+ import {
4
+ aggregateActivityByDay,
5
+ aggregateByProvider,
6
+ aggregateMcpByTool,
7
+ aggregateShellTop,
8
+ aggregateSkillsByName,
9
+ formatUsagePillLabel,
10
+ isFileRead,
11
+ isFileWrite,
12
+ isShellCall,
13
+ shellCommandHead,
14
+ } from "./usage.ts";
15
+ import { summarizeRows } from "../server/handlers.ts";
16
+ import type { ToolCallRow } from "../server/store.ts";
17
+
18
+ function row(over: Partial<ToolCallRow> = {}): ToolCallRow {
19
+ return {
20
+ agentId: "a1",
21
+ callId: "c1",
22
+ workspaceId: "w1",
23
+ provider: "claude",
24
+ turnId: null,
25
+ name: "Bash",
26
+ detailType: "shell",
27
+ category: "regular",
28
+ confidence: null,
29
+ skillName: null,
30
+ mcpServer: null,
31
+ mcpTool: null,
32
+ command: "ls",
33
+ filePath: null,
34
+ status: "completed",
35
+ errorMessage: null,
36
+ seq: null,
37
+ ts: null,
38
+ ingestedAt: "2026-09-18T00:00:00.000Z",
39
+ ...over,
40
+ };
41
+ }
42
+
43
+ describe("formatUsagePillLabel", () => {
44
+ it("shows most recently used skill or mcp; +N when more than one entity", () => {
45
+ assert.equal(
46
+ formatUsagePillLabel(
47
+ { shellCalls: 12 },
48
+ [
49
+ { skillName: "paseo", total: 2, lastUsedAt: "2026-09-18T01:00:00.000Z" },
50
+ { skillName: "review", total: 5, lastUsedAt: "2026-09-18T02:00:00.000Z" },
51
+ { skillName: "alpha", total: 5, lastUsedAt: "2026-09-18T04:00:00.000Z" },
52
+ ],
53
+ [
54
+ {
55
+ server: "knot",
56
+ tool: "tapd_search",
57
+ count: 99,
58
+ lastUsedAt: "2026-09-18T03:00:00.000Z",
59
+ },
60
+ ],
61
+ ),
62
+ "Alpha + 3",
63
+ );
64
+ });
65
+
66
+ it("shows bare name for a single entity", () => {
67
+ assert.equal(
68
+ formatUsagePillLabel(
69
+ undefined,
70
+ [{ skillName: "zhihu", total: 2, lastUsedAt: "2026-09-18T01:00:00.000Z" }],
71
+ [],
72
+ ),
73
+ "Zhihu",
74
+ );
75
+ assert.equal(
76
+ formatUsagePillLabel(
77
+ undefined,
78
+ [],
79
+ [
80
+ {
81
+ server: "knot",
82
+ tool: "tapd_search",
83
+ count: 3,
84
+ lastUsedAt: "2026-09-18T01:00:00.000Z",
85
+ },
86
+ ],
87
+ ),
88
+ "Knot.Tapd Search",
89
+ );
90
+ });
91
+
92
+ it("returns empty when no skills or mcp with counts", () => {
93
+ assert.equal(formatUsagePillLabel({ shellCalls: 3 }), "");
94
+ assert.equal(
95
+ formatUsagePillLabel(undefined, [{ skillName: "low-only", total: 0 }], []),
96
+ "",
97
+ );
98
+ });
99
+
100
+ it("prefers skill on equal lastUsedAt; alphabetical within kind", () => {
101
+ assert.equal(
102
+ formatUsagePillLabel(
103
+ undefined,
104
+ [
105
+ { skillName: "zhihu", total: 1, lastUsedAt: "2026-09-18T01:00:00.000Z" },
106
+ { skillName: "tapd", total: 1, lastUsedAt: "2026-09-18T01:00:00.000Z" },
107
+ ],
108
+ [{ server: "knot", tool: "x", count: 1, lastUsedAt: "2026-09-18T01:00:00.000Z" }],
109
+ ),
110
+ "Tapd + 2",
111
+ );
112
+ });
113
+
114
+ it("picks latest mcp over older high-count skill", () => {
115
+ assert.equal(
116
+ formatUsagePillLabel(
117
+ undefined,
118
+ [{ skillName: "paseo", total: 50, lastUsedAt: "2026-09-18T01:00:00.000Z" }],
119
+ [
120
+ {
121
+ server: "knot",
122
+ tool: "search",
123
+ count: 1,
124
+ lastUsedAt: "2026-09-18T09:00:00.000Z",
125
+ },
126
+ ],
127
+ ),
128
+ "Knot.Search + 1",
129
+ );
130
+ });
131
+ });
132
+
133
+ describe("aggregateMcpByTool", () => {
134
+ it("tracks lastUsedAt from the newest row", () => {
135
+ const items = aggregateMcpByTool([
136
+ {
137
+ category: "mcp",
138
+ mcpServer: "knot",
139
+ mcpTool: "a",
140
+ status: "completed",
141
+ ts: "2026-09-18T01:00:00.000Z",
142
+ ingestedAt: "2026-09-18T01:00:00.000Z",
143
+ },
144
+ {
145
+ category: "mcp",
146
+ mcpServer: "knot",
147
+ mcpTool: "b",
148
+ status: "completed",
149
+ ts: "2026-09-18T03:00:00.000Z",
150
+ ingestedAt: "2026-09-18T03:00:00.000Z",
151
+ },
152
+ {
153
+ category: "mcp",
154
+ mcpServer: "knot",
155
+ mcpTool: "a",
156
+ status: "failed",
157
+ ts: "2026-09-18T02:00:00.000Z",
158
+ ingestedAt: "2026-09-18T02:00:00.000Z",
159
+ },
160
+ ]);
161
+ assert.equal(items.length, 2);
162
+ const a = items.find((i) => i.tool === "a");
163
+ const b = items.find((i) => i.tool === "b");
164
+ assert.equal(a?.lastUsedAt, "2026-09-18T02:00:00.000Z");
165
+ assert.equal(a?.count, 2);
166
+ assert.equal(a?.failures, 1);
167
+ assert.equal(b?.lastUsedAt, "2026-09-18T03:00:00.000Z");
168
+ });
169
+ });
170
+
171
+ describe("aggregateSkillsByName", () => {
172
+ it("groups by skill; total excludes low", () => {
173
+ const items = aggregateSkillsByName([
174
+ row({
175
+ callId: "1",
176
+ category: "skill",
177
+ confidence: "exact",
178
+ skillName: "paseo",
179
+ command: null,
180
+ detailType: "plain_text",
181
+ ingestedAt: "2026-09-18T01:00:00.000Z",
182
+ }),
183
+ row({
184
+ callId: "2",
185
+ category: "skill",
186
+ confidence: "inferred",
187
+ skillName: "paseo",
188
+ command: null,
189
+ detailType: "read",
190
+ filePath: "/home/u/.claude/skills/paseo/SKILL.md",
191
+ ingestedAt: "2026-09-18T02:00:00.000Z",
192
+ }),
193
+ row({
194
+ callId: "3",
195
+ category: "skill",
196
+ confidence: "low",
197
+ skillName: "review",
198
+ command: null,
199
+ detailType: "shell",
200
+ ingestedAt: "2026-09-18T00:30:00.000Z",
201
+ }),
202
+ row({
203
+ callId: "4",
204
+ category: "skill",
205
+ confidence: "low",
206
+ skillName: "paseo",
207
+ command: null,
208
+ detailType: "shell",
209
+ ingestedAt: "2026-09-18T03:00:00.000Z",
210
+ }),
211
+ ]);
212
+ assert.equal(items.length, 2);
213
+ assert.equal(items[0]?.skillName, "paseo");
214
+ assert.equal(items[0]?.exact, 1);
215
+ assert.equal(items[0]?.inferred, 1);
216
+ assert.equal(items[0]?.low, 1);
217
+ assert.equal(items[0]?.total, 2);
218
+ assert.equal(items[0]?.lastUsedAt, "2026-09-18T03:00:00.000Z");
219
+ assert.equal(items[0]?.skillPath, "/home/u/.claude/skills/paseo/SKILL.md");
220
+ assert.equal(items[1]?.skillName, "review");
221
+ assert.equal(items[1]?.low, 1);
222
+ assert.equal(items[1]?.total, 0);
223
+ });
224
+ });
225
+
226
+ describe("shell / file KPI exclusivity (014)", () => {
227
+ it("predicates: low-skill shell is not a shell call; skill read is not a file read", () => {
228
+ assert.equal(
229
+ isShellCall({ category: "skill", detailType: "shell" }),
230
+ false,
231
+ );
232
+ assert.equal(
233
+ isShellCall({ category: "regular", detailType: "shell" }),
234
+ true,
235
+ );
236
+ assert.equal(
237
+ isFileRead({ category: "skill", detailType: "read" }),
238
+ false,
239
+ );
240
+ assert.equal(
241
+ isFileRead({ category: "regular", detailType: "read" }),
242
+ true,
243
+ );
244
+ assert.equal(
245
+ isFileWrite({ category: "regular", detailType: "edit" }),
246
+ true,
247
+ );
248
+ assert.equal(
249
+ isFileWrite({ category: "regular", detailType: "write" }),
250
+ true,
251
+ );
252
+ assert.equal(
253
+ isFileWrite({ category: "regular", detailType: "delete" }),
254
+ true,
255
+ );
256
+ assert.equal(
257
+ isFileWrite({ category: "regular", detailType: "read" }),
258
+ false,
259
+ );
260
+ });
261
+
262
+ it("summarizeRows excludes low-skill shell from shellCalls and skill read from fileReads", () => {
263
+ const summary = summarizeRows([
264
+ row({
265
+ callId: "low",
266
+ category: "skill",
267
+ confidence: "low",
268
+ detailType: "shell",
269
+ skillName: "review",
270
+ command: "cat ~/.codex/skills/review/SKILL.md",
271
+ }),
272
+ row({
273
+ callId: "inferred",
274
+ category: "skill",
275
+ confidence: "inferred",
276
+ detailType: "read",
277
+ skillName: "paseo",
278
+ command: null,
279
+ filePath: "/home/u/.claude/skills/paseo/SKILL.md",
280
+ name: "Read",
281
+ }),
282
+ row({
283
+ callId: "sh",
284
+ category: "regular",
285
+ detailType: "shell",
286
+ command: "ls",
287
+ }),
288
+ row({
289
+ callId: "rd",
290
+ category: "regular",
291
+ detailType: "read",
292
+ command: null,
293
+ filePath: "/tmp/a.ts",
294
+ name: "Read",
295
+ }),
296
+ row({
297
+ callId: "ed",
298
+ category: "regular",
299
+ detailType: "edit",
300
+ command: null,
301
+ filePath: "/tmp/a.ts",
302
+ name: "Edit",
303
+ }),
304
+ ]);
305
+ assert.equal(summary.skillCalls.low, 1);
306
+ assert.equal(summary.skillCalls.inferred, 1);
307
+ assert.equal(summary.shellCalls, 1);
308
+ assert.equal(summary.fileReads, 1);
309
+ assert.equal(summary.fileWrites, 1);
310
+ });
311
+
312
+ it("aggregateShellTop skips skill-category shell rows", () => {
313
+ const top = aggregateShellTop([
314
+ {
315
+ category: "skill",
316
+ detailType: "shell",
317
+ command: "cat SKILL.md",
318
+ status: "completed",
319
+ },
320
+ {
321
+ category: "regular",
322
+ detailType: "shell",
323
+ command: "git status",
324
+ status: "completed",
325
+ },
326
+ {
327
+ category: "regular",
328
+ detailType: "shell",
329
+ command: "git diff",
330
+ status: "failed",
331
+ },
332
+ ]);
333
+ assert.deepEqual(top, [{ command: "git", count: 2, failures: 1 }]);
334
+ });
335
+
336
+ it("aggregateByProvider file/shell totals follow exclusivity", () => {
337
+ const result = aggregateByProvider([
338
+ row({
339
+ callId: "1",
340
+ provider: "codex",
341
+ category: "skill",
342
+ confidence: "low",
343
+ detailType: "shell",
344
+ skillName: "review",
345
+ command: "cat SKILL.md",
346
+ }),
347
+ row({
348
+ callId: "2",
349
+ provider: "cursor",
350
+ category: "regular",
351
+ detailType: "shell",
352
+ command: "npm test",
353
+ }),
354
+ row({
355
+ callId: "3",
356
+ provider: "claude",
357
+ category: "regular",
358
+ detailType: "read",
359
+ command: null,
360
+ name: "Read",
361
+ }),
362
+ row({
363
+ callId: "4",
364
+ provider: "claude",
365
+ category: "skill",
366
+ confidence: "inferred",
367
+ detailType: "read",
368
+ skillName: "x",
369
+ command: null,
370
+ name: "Read",
371
+ }),
372
+ ]);
373
+ assert.equal(result.totals.shellCalls, 1);
374
+ assert.equal(result.totals.fileReads, 1);
375
+ assert.equal(result.totals.skillCalls.low, 1);
376
+ assert.equal(result.totals.skillCalls.inferred, 1);
377
+ const cursor = result.providers.find((p) => p.provider === "cursor");
378
+ assert.equal(cursor?.shellCalls, 1);
379
+ assert.equal(cursor?.shellTop[0]?.command, "npm");
380
+ });
381
+ });
382
+
383
+ describe("shellCommandHead", () => {
384
+ it("takes first token basename", () => {
385
+ assert.equal(shellCommandHead("/usr/bin/git status"), "git");
386
+ assert.equal(shellCommandHead("echo hi"), "echo");
387
+ });
388
+ });
389
+
390
+ describe("summarizeRows", () => {
391
+ it("counts categories", () => {
392
+ const summary = summarizeRows([
393
+ row({ callId: "1", detailType: "shell", category: "regular", status: "failed" }),
394
+ row({
395
+ callId: "2",
396
+ name: "Skill",
397
+ detailType: "plain_text",
398
+ category: "skill",
399
+ confidence: "exact",
400
+ skillName: "x",
401
+ command: null,
402
+ }),
403
+ row({
404
+ callId: "3",
405
+ name: "mcp__s__t",
406
+ detailType: "unknown",
407
+ category: "mcp",
408
+ mcpServer: "s",
409
+ mcpTool: "t",
410
+ command: null,
411
+ }),
412
+ ]);
413
+ assert.equal(summary.shellCalls, 1);
414
+ assert.equal(summary.shellFailures, 1);
415
+ assert.equal(summary.skillCalls.exact, 1);
416
+ assert.equal(summary.mcpCalls, 1);
417
+ });
418
+ });
419
+
420
+ describe("aggregateByProvider", () => {
421
+ it("groups claude/opus into claude and lists skills by name", () => {
422
+ const result = aggregateByProvider(
423
+ [
424
+ row({
425
+ callId: "1",
426
+ agentId: "a1",
427
+ provider: "claude/opus",
428
+ detailType: "shell",
429
+ category: "regular",
430
+ status: "failed",
431
+ }),
432
+ row({
433
+ callId: "2",
434
+ agentId: "a1",
435
+ provider: "claude",
436
+ name: "Skill",
437
+ detailType: "plain_text",
438
+ category: "skill",
439
+ confidence: "exact",
440
+ skillName: "paseo",
441
+ command: null,
442
+ }),
443
+ row({
444
+ callId: "2b",
445
+ agentId: "a1",
446
+ provider: "claude/opus",
447
+ name: "Skill",
448
+ detailType: "plain_text",
449
+ category: "skill",
450
+ confidence: "exact",
451
+ skillName: "paseo",
452
+ command: null,
453
+ ingestedAt: "2026-09-18T01:00:00.000Z",
454
+ }),
455
+ row({
456
+ callId: "3",
457
+ agentId: "a2",
458
+ provider: "opencode",
459
+ name: "mcp__s__t",
460
+ detailType: "unknown",
461
+ category: "mcp",
462
+ mcpServer: "s",
463
+ mcpTool: "t",
464
+ command: null,
465
+ status: "failed",
466
+ }),
467
+ row({
468
+ callId: "4",
469
+ agentId: "a3",
470
+ provider: "codebuddy-code",
471
+ detailType: "shell",
472
+ category: "regular",
473
+ }),
474
+ ],
475
+ [
476
+ { agentId: "a1", provider: "claude", workspaceId: "w-shared" },
477
+ { agentId: "a2", provider: "opencode", workspaceId: "w-shared" },
478
+ { agentId: "a3", provider: "codebuddy-code", workspaceId: "w-cb" },
479
+ { agentId: "a4", provider: "claude", workspaceId: "w-claude" }, // created, no tool calls
480
+ ],
481
+ );
482
+
483
+ assert.equal(result.totals.shellCalls, 2);
484
+ assert.equal(result.totals.skillCalls.exact, 2);
485
+ assert.equal(result.totals.mcpCalls, 1);
486
+ assert.equal(result.totals.workspaceCount, 3);
487
+
488
+ const claude = result.providers.find((p) => p.provider === "claude");
489
+ assert.ok(claude);
490
+ assert.equal(claude.label, "Claude");
491
+ assert.equal(claude.shellCalls, 1);
492
+ assert.equal(claude.shellFailures, 1);
493
+ assert.equal(claude.skillCalls.exact, 2);
494
+ assert.equal(claude.agentCount, 2);
495
+ assert.equal(claude.workspaceCount, 2);
496
+ assert.equal(claude.callCount, 3);
497
+ assert.equal(claude.skills.length, 1);
498
+ assert.equal(claude.skills[0]?.skillName, "paseo");
499
+ assert.equal(claude.skills[0]?.total, 2);
500
+
501
+ const opencode = result.providers.find((p) => p.provider === "opencode");
502
+ assert.ok(opencode);
503
+ assert.equal(opencode.mcpCalls, 1);
504
+ assert.equal(opencode.mcpFailures, 1);
505
+ assert.equal(opencode.skills.length, 0);
506
+ assert.equal(opencode.mcpTools.length, 1);
507
+ assert.equal(opencode.mcpTools[0]?.server, "s");
508
+ assert.equal(opencode.mcpTools[0]?.tool, "t");
509
+ assert.equal(opencode.mcpTools[0]?.count, 1);
510
+ assert.equal(opencode.workspaceCount, 1);
511
+
512
+ const codebuddy = result.providers.find((p) => p.provider === "codebuddy");
513
+ assert.ok(codebuddy);
514
+ assert.equal(codebuddy.shellCalls, 1);
515
+ assert.equal(codebuddy.label, "CodeBuddy");
516
+ assert.equal(codebuddy.workspaceCount, 1);
517
+
518
+ assert.equal(result.providers[0]?.provider, "claude");
519
+ });
520
+
521
+ it("includes providers that only have agent creations (no tool calls or messages)", () => {
522
+ const result = aggregateByProvider(
523
+ [],
524
+ [{ agentId: "solo", provider: "pi", workspaceId: "w1" }],
525
+ [],
526
+ );
527
+ assert.equal(result.providers.length, 1);
528
+ assert.equal(result.providers[0]?.provider, "pi");
529
+ assert.equal(result.providers[0]?.agentCount, 1);
530
+ assert.equal(result.providers[0]?.workspaceCount, 1);
531
+ assert.equal(result.providers[0]?.callCount, 0);
532
+ assert.equal(result.providers[0]?.messageCount, 0);
533
+ assert.equal(result.totals.workspaceCount, 1);
534
+ });
535
+
536
+ it("skips null workspace ids and does not double-count shared workspaces in totals", () => {
537
+ const result = aggregateByProvider(
538
+ [],
539
+ [
540
+ { agentId: "a1", provider: "claude", workspaceId: "w1" },
541
+ { agentId: "a2", provider: "codex", workspaceId: "w1" },
542
+ { agentId: "a3", provider: "claude", workspaceId: null },
543
+ { agentId: "a4", provider: "pi", workspaceId: " " },
544
+ ],
545
+ );
546
+ assert.equal(result.totals.workspaceCount, 1);
547
+ assert.equal(result.providers.find((p) => p.provider === "claude")?.workspaceCount, 1);
548
+ assert.equal(result.providers.find((p) => p.provider === "pi")?.workspaceCount, 0);
549
+ });
550
+
551
+ it("ranks models by message stamps and skips blanks", () => {
552
+ const result = aggregateByProvider(
553
+ [],
554
+ [],
555
+ [
556
+ { provider: "codex", model: "gpt-5.4" },
557
+ { provider: "codex", model: "gpt-5.4" },
558
+ { provider: "codex", model: null },
559
+ { provider: "codex", model: " " },
560
+ { provider: "claude", model: "opus" },
561
+ ],
562
+ );
563
+ const codex = result.providers.find((p) => p.provider === "codex");
564
+ assert.deepEqual(codex?.models, [{ model: "gpt-5.4", count: 2 }]);
565
+ assert.equal(codex?.messageCount, 4);
566
+ const claude = result.providers.find((p) => p.provider === "claude");
567
+ assert.deepEqual(claude?.models, [{ model: "opus", count: 1 }]);
568
+ });
569
+ });
570
+
571
+ describe("aggregateActivityByDay", () => {
572
+ it("buckets skill and mcp by local day and skips low-confidence skills", () => {
573
+ const days = aggregateActivityByDay([
574
+ row({
575
+ callId: "1",
576
+ category: "skill",
577
+ confidence: "exact",
578
+ skillName: "a",
579
+ ingestedAt: "2026-09-18T10:00:00.000Z",
580
+ }),
581
+ row({
582
+ callId: "2",
583
+ category: "skill",
584
+ confidence: "low",
585
+ skillName: "b",
586
+ ingestedAt: "2026-09-18T11:00:00.000Z",
587
+ }),
588
+ row({
589
+ callId: "3",
590
+ category: "mcp",
591
+ mcpServer: "s",
592
+ mcpTool: "t",
593
+ ingestedAt: "2026-09-18T12:00:00.000Z",
594
+ }),
595
+ row({
596
+ callId: "4",
597
+ category: "mcp",
598
+ provider: "codex",
599
+ mcpServer: "s",
600
+ mcpTool: "u",
601
+ ingestedAt: "2026-09-19T08:00:00.000Z",
602
+ }),
603
+ ]);
604
+
605
+ assert.equal(days.length, 2);
606
+ assert.equal(days[0]?.skills, 1);
607
+ assert.equal(days[0]?.mcp, 1);
608
+ assert.equal(days[0]?.agents, 0);
609
+ assert.equal(days[0]?.total, 2);
610
+ assert.equal(days[1]?.skills, 0);
611
+ assert.equal(days[1]?.mcp, 1);
612
+ assert.equal(days[1]?.agents, 0);
613
+
614
+ const onlyCodex = aggregateActivityByDay(
615
+ [
616
+ row({
617
+ callId: "4",
618
+ category: "mcp",
619
+ provider: "codex",
620
+ mcpServer: "s",
621
+ mcpTool: "u",
622
+ ingestedAt: "2026-09-19T08:00:00.000Z",
623
+ }),
624
+ row({
625
+ callId: "5",
626
+ category: "mcp",
627
+ provider: "claude",
628
+ mcpServer: "s",
629
+ mcpTool: "v",
630
+ ingestedAt: "2026-09-19T09:00:00.000Z",
631
+ }),
632
+ ],
633
+ { provider: "codex" },
634
+ );
635
+ assert.equal(onlyCodex.length, 1);
636
+ assert.equal(onlyCodex[0]?.mcp, 1);
637
+ assert.equal(onlyCodex[0]?.agents, 0);
638
+ });
639
+
640
+ it("counts agent creations per day independent of tool calls", () => {
641
+ const days = aggregateActivityByDay(
642
+ [
643
+ row({
644
+ callId: "1",
645
+ agentId: "a1",
646
+ category: "skill",
647
+ confidence: "exact",
648
+ skillName: "x",
649
+ ingestedAt: "2026-09-18T10:00:00.000Z",
650
+ }),
651
+ ],
652
+ {
653
+ agents: [
654
+ { agentId: "a1", provider: "claude", createdAt: "2026-09-18T08:00:00.000Z" },
655
+ { agentId: "a2", provider: "claude", createdAt: "2026-09-18T09:00:00.000Z" },
656
+ { agentId: "a3", provider: "codex", createdAt: "2026-09-19T08:00:00.000Z" },
657
+ ],
658
+ },
659
+ );
660
+ assert.equal(days.length, 2);
661
+ assert.equal(days[0]?.skills, 1);
662
+ assert.equal(days[0]?.agents, 2);
663
+ assert.equal(days[1]?.skills, 0);
664
+ assert.equal(days[1]?.mcp, 0);
665
+ assert.equal(days[1]?.agents, 1);
666
+ assert.equal(days[1]?.total, 1);
667
+ });
668
+ });