@koinzhang/paseo-plugin-activity 0.1.0 → 0.2.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 (42) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +71 -0
  3. package/client/activity-heatmap.tsx +72 -14
  4. package/client/global-surface.tsx +24 -25
  5. package/client/panel.tsx +1 -0
  6. package/client/range.ts +20 -0
  7. package/client/usage-stats.tsx +7 -5
  8. package/client/workspace/agent-row.tsx +117 -0
  9. package/client/workspace/agents-section.tsx +323 -0
  10. package/client/workspace/constants.ts +121 -0
  11. package/client/workspace/display-menu.tsx +116 -0
  12. package/client/workspace/filters.ts +30 -0
  13. package/client/workspace/list-host-agents.ts +57 -0
  14. package/client/workspace/panel.tsx +800 -0
  15. package/client/workspace/rank-section.tsx +121 -0
  16. package/client/workspace-panel.tsx +2 -0
  17. package/index.client.tsx +20 -13
  18. package/index.server.ts +11 -0
  19. package/package.json +8 -2
  20. package/server/agents.test.ts +20 -1
  21. package/server/agents.ts +2 -1
  22. package/server/background-sync.test.ts +14 -3
  23. package/server/background-sync.ts +16 -5
  24. package/server/handlers-query.test.ts +58 -0
  25. package/server/handlers.ts +73 -2
  26. package/server/messages.test.ts +8 -2
  27. package/server/store.test.ts +13 -0
  28. package/server/store.ts +2 -2
  29. package/shared/activity.test.ts +22 -12
  30. package/shared/activity.ts +8 -13
  31. package/shared/agent-page-size.test.ts +11 -0
  32. package/shared/agent-title-search.test.ts +28 -0
  33. package/shared/agent-title-search.ts +12 -0
  34. package/shared/explorer-agent-display.ts +30 -0
  35. package/shared/format.test.ts +22 -1
  36. package/shared/format.ts +24 -0
  37. package/shared/insights.test.ts +38 -18
  38. package/shared/insights.ts +38 -19
  39. package/shared/list-agent-pages.test.ts +51 -0
  40. package/shared/list-agent-pages.ts +31 -0
  41. package/shared/usage.test.ts +248 -0
  42. package/shared/usage.ts +327 -11
@@ -2,15 +2,18 @@ import assert from "node:assert/strict";
2
2
  import { describe, it } from "node:test";
3
3
  import {
4
4
  aggregateActivityByDay,
5
+ aggregateAgents,
5
6
  aggregateByProvider,
6
7
  aggregateMcpByTool,
7
8
  aggregateShellTop,
8
9
  aggregateSkillsByName,
9
10
  formatUsagePillLabel,
11
+ isCodingOp,
10
12
  isFileRead,
11
13
  isFileWrite,
12
14
  isShellCall,
13
15
  shellCommandHead,
16
+ shellLooksMutating,
14
17
  } from "./usage.ts";
15
18
  import { summarizeRows } from "../server/handlers.ts";
16
19
  import type { ToolCallRow } from "../server/store.ts";
@@ -380,6 +383,47 @@ describe("shell / file KPI exclusivity (014)", () => {
380
383
  });
381
384
  });
382
385
 
386
+ describe("shellLooksMutating / isCodingOp (019)", () => {
387
+ it("flags common mutating heads, git write subs, redirects, and sudo", () => {
388
+ assert.equal(shellLooksMutating("rm -rf dist"), true);
389
+ assert.equal(shellLooksMutating("npm install"), true);
390
+ assert.equal(shellLooksMutating("/usr/local/bin/pnpm add lodash"), true);
391
+ assert.equal(shellLooksMutating("git commit -m 'x'"), true);
392
+ assert.equal(shellLooksMutating("git -C repo commit -m x"), true);
393
+ assert.equal(shellLooksMutating("echo hi > out.txt"), true);
394
+ assert.equal(shellLooksMutating("cat a | tee b"), true);
395
+ assert.equal(shellLooksMutating("sudo rm foo"), true);
396
+ });
397
+
398
+ it("does not flag read-only shell", () => {
399
+ assert.equal(shellLooksMutating("ls"), false);
400
+ assert.equal(shellLooksMutating("cat README.md"), false);
401
+ assert.equal(shellLooksMutating("git status"), false);
402
+ assert.equal(shellLooksMutating("git log --oneline"), false);
403
+ assert.equal(shellLooksMutating("python script.py"), false);
404
+ assert.equal(shellLooksMutating(null), false);
405
+ });
406
+
407
+ it("isCodingOp accepts file writes and mutating shell only", () => {
408
+ assert.equal(
409
+ isCodingOp({ category: "regular", detailType: "edit", command: null }),
410
+ true,
411
+ );
412
+ assert.equal(
413
+ isCodingOp({ category: "regular", detailType: "read", command: null }),
414
+ false,
415
+ );
416
+ assert.equal(
417
+ isCodingOp({ category: "regular", detailType: "shell", command: "ls" }),
418
+ false,
419
+ );
420
+ assert.equal(
421
+ isCodingOp({ category: "regular", detailType: "shell", command: "mv a b" }),
422
+ true,
423
+ );
424
+ });
425
+ });
426
+
383
427
  describe("shellCommandHead", () => {
384
428
  it("takes first token basename", () => {
385
429
  assert.equal(shellCommandHead("/usr/bin/git status"), "git");
@@ -428,6 +472,7 @@ describe("aggregateByProvider", () => {
428
472
  detailType: "shell",
429
473
  category: "regular",
430
474
  status: "failed",
475
+ command: "rm -rf dist",
431
476
  }),
432
477
  row({
433
478
  callId: "2",
@@ -470,6 +515,7 @@ describe("aggregateByProvider", () => {
470
515
  provider: "codebuddy-code",
471
516
  detailType: "shell",
472
517
  category: "regular",
518
+ command: "ls",
473
519
  }),
474
520
  ],
475
521
  [
@@ -492,6 +538,8 @@ describe("aggregateByProvider", () => {
492
538
  assert.equal(claude.shellFailures, 1);
493
539
  assert.equal(claude.skillCalls.exact, 2);
494
540
  assert.equal(claude.agentCount, 2);
541
+ assert.equal(claude.codingAgentCount, 1); // a1 rm → coding; a4 empty
542
+ assert.equal(claude.chatAgentCount, 0);
495
543
  assert.equal(claude.workspaceCount, 2);
496
544
  assert.equal(claude.callCount, 3);
497
545
  assert.equal(claude.skills.length, 1);
@@ -508,16 +556,112 @@ describe("aggregateByProvider", () => {
508
556
  assert.equal(opencode.mcpTools[0]?.tool, "t");
509
557
  assert.equal(opencode.mcpTools[0]?.count, 1);
510
558
  assert.equal(opencode.workspaceCount, 1);
559
+ assert.equal(opencode.codingAgentCount, 0);
560
+ assert.equal(opencode.chatAgentCount, 1); // MCP-only → chat
511
561
 
512
562
  const codebuddy = result.providers.find((p) => p.provider === "codebuddy");
513
563
  assert.ok(codebuddy);
514
564
  assert.equal(codebuddy.shellCalls, 1);
515
565
  assert.equal(codebuddy.label, "CodeBuddy");
516
566
  assert.equal(codebuddy.workspaceCount, 1);
567
+ assert.equal(codebuddy.codingAgentCount, 0); // ls → not mutating
568
+ assert.equal(codebuddy.chatAgentCount, 1);
517
569
 
518
570
  assert.equal(result.providers[0]?.provider, "claude");
519
571
  });
520
572
 
573
+ it("codingAgentCount uses mutating shell / file write only (019)", () => {
574
+ const result = aggregateByProvider(
575
+ [
576
+ row({
577
+ callId: "1",
578
+ agentId: "chat-only",
579
+ provider: "claude",
580
+ category: "skill",
581
+ confidence: "inferred",
582
+ detailType: "read",
583
+ skillName: "x",
584
+ name: "Read",
585
+ command: null,
586
+ }),
587
+ row({
588
+ callId: "2",
589
+ agentId: "chat-low",
590
+ provider: "codex",
591
+ category: "skill",
592
+ confidence: "low",
593
+ detailType: "shell",
594
+ skillName: "review",
595
+ command: "cat SKILL.md",
596
+ }),
597
+ row({
598
+ callId: "3",
599
+ agentId: "reader",
600
+ provider: "cursor",
601
+ category: "regular",
602
+ detailType: "read",
603
+ name: "Read",
604
+ command: null,
605
+ }),
606
+ row({
607
+ callId: "4",
608
+ agentId: "coder-write",
609
+ provider: "claude",
610
+ category: "regular",
611
+ detailType: "edit",
612
+ name: "Edit",
613
+ command: null,
614
+ }),
615
+ row({
616
+ callId: "5",
617
+ agentId: "coder-shell",
618
+ provider: "codex",
619
+ category: "regular",
620
+ detailType: "shell",
621
+ command: "npm install",
622
+ }),
623
+ row({
624
+ callId: "6",
625
+ agentId: "status",
626
+ provider: "cursor",
627
+ category: "regular",
628
+ detailType: "shell",
629
+ command: "git status",
630
+ }),
631
+ ],
632
+ [
633
+ { agentId: "chat-only", provider: "claude" },
634
+ { agentId: "chat-low", provider: "codex" },
635
+ { agentId: "reader", provider: "cursor" },
636
+ { agentId: "coder-write", provider: "claude" },
637
+ { agentId: "coder-shell", provider: "codex" },
638
+ { agentId: "status", provider: "cursor" },
639
+ { agentId: "idle", provider: "claude" },
640
+ ],
641
+ );
642
+ assert.equal(result.providers.find((p) => p.provider === "claude")?.codingAgentCount, 1);
643
+ assert.equal(result.providers.find((p) => p.provider === "claude")?.chatAgentCount, 1); // chat-only; idle empty
644
+ assert.equal(result.providers.find((p) => p.provider === "codex")?.codingAgentCount, 1);
645
+ assert.equal(result.providers.find((p) => p.provider === "codex")?.chatAgentCount, 1); // chat-low
646
+ assert.equal(result.providers.find((p) => p.provider === "cursor")?.codingAgentCount, 0);
647
+ assert.equal(result.providers.find((p) => p.provider === "cursor")?.chatAgentCount, 2); // reader + status
648
+ });
649
+
650
+ it("message-only agents count as chat; empty creations are excluded", () => {
651
+ const result = aggregateByProvider(
652
+ [],
653
+ [
654
+ { agentId: "msg", provider: "claude" },
655
+ { agentId: "empty", provider: "claude" },
656
+ ],
657
+ [{ agentId: "msg", provider: "claude", model: "opus" }],
658
+ );
659
+ const claude = result.providers.find((p) => p.provider === "claude");
660
+ assert.equal(claude?.agentCount, 2);
661
+ assert.equal(claude?.codingAgentCount, 0);
662
+ assert.equal(claude?.chatAgentCount, 1);
663
+ });
664
+
521
665
  it("includes providers that only have agent creations (no tool calls or messages)", () => {
522
666
  const result = aggregateByProvider(
523
667
  [],
@@ -527,6 +671,8 @@ describe("aggregateByProvider", () => {
527
671
  assert.equal(result.providers.length, 1);
528
672
  assert.equal(result.providers[0]?.provider, "pi");
529
673
  assert.equal(result.providers[0]?.agentCount, 1);
674
+ assert.equal(result.providers[0]?.codingAgentCount, 0);
675
+ assert.equal(result.providers[0]?.chatAgentCount, 0);
530
676
  assert.equal(result.providers[0]?.workspaceCount, 1);
531
677
  assert.equal(result.providers[0]?.callCount, 0);
532
678
  assert.equal(result.providers[0]?.messageCount, 0);
@@ -666,3 +812,105 @@ describe("aggregateActivityByDay", () => {
666
812
  assert.equal(days[1]?.total, 1);
667
813
  });
668
814
  });
815
+
816
+ describe("aggregateAgents (024)", () => {
817
+ it("groups by agent, excludes low from skillCalls, and merges the registry", () => {
818
+ const items = aggregateAgents(
819
+ [
820
+ row({
821
+ callId: "1",
822
+ agentId: "a1",
823
+ provider: "claude/opus",
824
+ name: "Skill",
825
+ detailType: "plain_text",
826
+ category: "skill",
827
+ confidence: "exact",
828
+ skillName: "review",
829
+ command: null,
830
+ }),
831
+ row({
832
+ callId: "2",
833
+ agentId: "a1",
834
+ provider: "claude/opus",
835
+ name: "Skill",
836
+ detailType: "plain_text",
837
+ category: "skill",
838
+ confidence: "low",
839
+ skillName: "review",
840
+ command: null,
841
+ ingestedAt: "2026-09-18T03:00:00.000Z",
842
+ }),
843
+ row({
844
+ callId: "3",
845
+ agentId: "a1",
846
+ provider: "claude/opus",
847
+ name: "mcp__knot__search",
848
+ detailType: "unknown",
849
+ category: "mcp",
850
+ mcpServer: "knot",
851
+ mcpTool: "search",
852
+ command: null,
853
+ }),
854
+ row({
855
+ callId: "4",
856
+ agentId: "a1",
857
+ provider: "claude/opus",
858
+ command: "rm -rf dist",
859
+ ingestedAt: "2026-09-18T04:00:00.000Z",
860
+ }),
861
+ row({ callId: "5", agentId: "a1", provider: "claude/opus", detailType: "read", command: null }),
862
+ row({ callId: "6", agentId: "a1", provider: "claude/opus", detailType: "write", command: null }),
863
+ row({ callId: "7", agentId: "a2", provider: "codex", command: "ls" }),
864
+ ],
865
+ [
866
+ {
867
+ agentId: "a1",
868
+ provider: "claude/opus",
869
+ title: "Review bot",
870
+ createdAt: "2026-09-18T00:00:00.000Z",
871
+ },
872
+ { agentId: "a3", provider: "codex", title: "Idle", createdAt: "2026-09-19T00:00:00.000Z", updatedAt: "2026-09-19T02:00:00.000Z", archivedAt: "2026-09-19T01:00:00.000Z" },
873
+ ],
874
+ [
875
+ { agentId: "a1", provider: "claude/opus", ts: "2026-09-18T05:00:00.000Z" },
876
+ { agentId: "a1", provider: "claude/opus", ts: "2026-09-18T06:00:00.000Z" },
877
+ { agentId: "a2", provider: "codex" },
878
+ ],
879
+ );
880
+
881
+ assert.deepEqual(
882
+ items.map((item) => item.agentId),
883
+ ["a1", "a2", "a3"],
884
+ );
885
+
886
+ const a1 = items[0]!;
887
+ assert.equal(a1.provider, "claude");
888
+ assert.equal(a1.title, "Review bot");
889
+ assert.equal(a1.callCount, 6);
890
+ assert.equal(a1.skillCalls, 1);
891
+ assert.equal(a1.mcpCalls, 1);
892
+ assert.equal(a1.shellCalls, 1);
893
+ assert.equal(a1.fileReads, 1);
894
+ assert.equal(a1.fileWrites, 1);
895
+ assert.equal(a1.coding, true);
896
+ assert.equal(a1.messageCount, 2);
897
+ assert.equal(a1.archivedAt, null);
898
+ assert.equal(a1.updatedAt, null);
899
+ assert.equal(a1.lastActivityAt, "2026-09-18T06:00:00.000Z");
900
+
901
+ const a2 = items[1]!;
902
+ assert.equal(a2.callCount, 1);
903
+ assert.equal(a2.coding, false);
904
+ assert.equal(a2.messageCount, 1);
905
+ assert.equal(a2.lastActivityAt, "2026-09-18T00:00:00.000Z");
906
+
907
+ const a3 = items[2]!;
908
+ assert.equal(a3.callCount, 0);
909
+ assert.equal(a3.messageCount, 0);
910
+ assert.equal(a3.title, "Idle");
911
+ assert.equal(a3.createdAt, "2026-09-19T00:00:00.000Z");
912
+ assert.equal(a3.updatedAt, "2026-09-19T02:00:00.000Z");
913
+ assert.equal(a3.archivedAt, "2026-09-19T01:00:00.000Z");
914
+ assert.equal(a3.lastActivityAt, null);
915
+ });
916
+ });