create-claude-code-visualizer 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 (220) hide show
  1. package/index.js +393 -0
  2. package/package.json +31 -0
  3. package/templates/CLAUDE.md +108 -0
  4. package/templates/app/.env.local.example +14 -0
  5. package/templates/app/ecosystem.config.js +29 -0
  6. package/templates/app/next-env.d.ts +6 -0
  7. package/templates/app/next.config.ts +16 -0
  8. package/templates/app/package-lock.json +4581 -0
  9. package/templates/app/package.json +38 -0
  10. package/templates/app/postcss.config.js +5 -0
  11. package/templates/app/src/app/agents/[slug]/chat/loading.tsx +26 -0
  12. package/templates/app/src/app/agents/[slug]/chat/page.tsx +579 -0
  13. package/templates/app/src/app/agents/[slug]/loading.tsx +19 -0
  14. package/templates/app/src/app/agents/page.tsx +8 -0
  15. package/templates/app/src/app/api/agents/[slug]/capabilities/route.ts +11 -0
  16. package/templates/app/src/app/api/agents/[slug]/route.ts +57 -0
  17. package/templates/app/src/app/api/agents/route.ts +28 -0
  18. package/templates/app/src/app/api/ai/generate-agent/route.ts +87 -0
  19. package/templates/app/src/app/api/ai/improve-claude-md/route.ts +78 -0
  20. package/templates/app/src/app/api/ai/suggestions/route.ts +64 -0
  21. package/templates/app/src/app/api/ai/title/route.ts +88 -0
  22. package/templates/app/src/app/api/auth/role/route.ts +17 -0
  23. package/templates/app/src/app/api/commands/[slug]/route.ts +61 -0
  24. package/templates/app/src/app/api/commands/route.ts +6 -0
  25. package/templates/app/src/app/api/governance/costs/route.ts +117 -0
  26. package/templates/app/src/app/api/governance/sessions/route.ts +335 -0
  27. package/templates/app/src/app/api/notifications/route.ts +62 -0
  28. package/templates/app/src/app/api/preferences/route.ts +44 -0
  29. package/templates/app/src/app/api/runs/[id]/approve/route.ts +38 -0
  30. package/templates/app/src/app/api/runs/[id]/events/route.ts +28 -0
  31. package/templates/app/src/app/api/runs/[id]/metadata/route.ts +30 -0
  32. package/templates/app/src/app/api/runs/[id]/route.ts +21 -0
  33. package/templates/app/src/app/api/runs/[id]/start/route.ts +61 -0
  34. package/templates/app/src/app/api/runs/[id]/stop/route.ts +16 -0
  35. package/templates/app/src/app/api/runs/[id]/stream/route.ts +201 -0
  36. package/templates/app/src/app/api/runs/route.ts +95 -0
  37. package/templates/app/src/app/api/schedules/[id]/route.ts +81 -0
  38. package/templates/app/src/app/api/schedules/route.ts +75 -0
  39. package/templates/app/src/app/api/settings/access-logs/route.ts +33 -0
  40. package/templates/app/src/app/api/settings/claude-md/route.ts +44 -0
  41. package/templates/app/src/app/api/settings/env-keys/route.ts +271 -0
  42. package/templates/app/src/app/api/settings/users/route.ts +108 -0
  43. package/templates/app/src/app/api/skills/[slug]/route.ts +43 -0
  44. package/templates/app/src/app/api/skills/route.ts +6 -0
  45. package/templates/app/src/app/api/tools/route.ts +65 -0
  46. package/templates/app/src/app/api/uploads/cleanup/route.ts +29 -0
  47. package/templates/app/src/app/api/uploads/route.ts +77 -0
  48. package/templates/app/src/app/auth/callback/route.ts +19 -0
  49. package/templates/app/src/app/globals.css +115 -0
  50. package/templates/app/src/app/layout.tsx +24 -0
  51. package/templates/app/src/app/loading.tsx +16 -0
  52. package/templates/app/src/app/login/page.tsx +64 -0
  53. package/templates/app/src/app/not-authorized/page.tsx +33 -0
  54. package/templates/app/src/app/runs/page.tsx +55 -0
  55. package/templates/app/src/app/schedules/page.tsx +110 -0
  56. package/templates/app/src/app/settings/page.tsx +1294 -0
  57. package/templates/app/src/app/skills/page.tsx +7 -0
  58. package/templates/app/src/components/agent-card.tsx +58 -0
  59. package/templates/app/src/components/agent-grid.tsx +90 -0
  60. package/templates/app/src/components/auth/auth-context.tsx +79 -0
  61. package/templates/app/src/components/chat-thread.tsx +50 -0
  62. package/templates/app/src/components/chat-view.tsx +670 -0
  63. package/templates/app/src/components/commands-browser.tsx +349 -0
  64. package/templates/app/src/components/create-agent-modal.tsx +388 -0
  65. package/templates/app/src/components/governance-dashboard.tsx +397 -0
  66. package/templates/app/src/components/icons.tsx +401 -0
  67. package/templates/app/src/components/layout/agent-sidebar.tsx +504 -0
  68. package/templates/app/src/components/layout/app-shell.tsx +29 -0
  69. package/templates/app/src/components/layout/nav.tsx +87 -0
  70. package/templates/app/src/components/layout/overview-inner.tsx +14 -0
  71. package/templates/app/src/components/layout/profile-menu.tsx +95 -0
  72. package/templates/app/src/components/layout/sidebar.tsx +30 -0
  73. package/templates/app/src/components/markdown.tsx +57 -0
  74. package/templates/app/src/components/message-bar.tsx +161 -0
  75. package/templates/app/src/components/notifications/notification-bell.tsx +104 -0
  76. package/templates/app/src/components/notifications/notification-panel.tsx +116 -0
  77. package/templates/app/src/components/overview/overview-content.tsx +287 -0
  78. package/templates/app/src/components/overview/overview-context.tsx +88 -0
  79. package/templates/app/src/components/preferences-modal.tsx +112 -0
  80. package/templates/app/src/components/run-form.tsx +73 -0
  81. package/templates/app/src/components/run-history-table.tsx +226 -0
  82. package/templates/app/src/components/run-output.tsx +187 -0
  83. package/templates/app/src/components/schedule-form.tsx +148 -0
  84. package/templates/app/src/components/skills-browser.tsx +338 -0
  85. package/templates/app/src/components/tool-tooltip.tsx +82 -0
  86. package/templates/app/src/hooks/use-sse.ts +115 -0
  87. package/templates/app/src/instrumentation.ts +9 -0
  88. package/templates/app/src/lib/agent-cache.ts +19 -0
  89. package/templates/app/src/lib/agent-runner.ts +411 -0
  90. package/templates/app/src/lib/agents.ts +168 -0
  91. package/templates/app/src/lib/ai.ts +40 -0
  92. package/templates/app/src/lib/approval-store.ts +70 -0
  93. package/templates/app/src/lib/auth-guard.ts +116 -0
  94. package/templates/app/src/lib/capabilities.ts +191 -0
  95. package/templates/app/src/lib/line-diff.ts +96 -0
  96. package/templates/app/src/lib/queue.ts +22 -0
  97. package/templates/app/src/lib/redis.ts +12 -0
  98. package/templates/app/src/lib/role-permissions.ts +166 -0
  99. package/templates/app/src/lib/run-agent.ts +442 -0
  100. package/templates/app/src/lib/supabase-browser.ts +8 -0
  101. package/templates/app/src/lib/supabase-middleware.ts +63 -0
  102. package/templates/app/src/lib/supabase-server.ts +28 -0
  103. package/templates/app/src/lib/supabase.ts +6 -0
  104. package/templates/app/src/lib/tool-descriptions.ts +29 -0
  105. package/templates/app/src/lib/types.ts +73 -0
  106. package/templates/app/src/lib/typewriter-animation.ts +159 -0
  107. package/templates/app/src/middleware.ts +13 -0
  108. package/templates/app/tsconfig.json +21 -0
  109. package/templates/app/uploads/.gitkeep +0 -0
  110. package/templates/app/worker/index.ts +342 -0
  111. package/templates/claude/agents/ai-trends-scout.md +66 -0
  112. package/templates/claude/commands/add-to-todos.md +56 -0
  113. package/templates/claude/commands/check-todos.md +56 -0
  114. package/templates/claude/hooks/auto-approve-safe.sh +34 -0
  115. package/templates/claude/hooks/auto-format.sh +25 -0
  116. package/templates/claude/hooks/block-destructive.sh +32 -0
  117. package/templates/claude/hooks/compaction-preserver.sh +16 -0
  118. package/templates/claude/hooks/notify.sh +26 -0
  119. package/templates/claude/settings.local.json +66 -0
  120. package/templates/claude/skills/frontend-design/SKILL.md +127 -0
  121. package/templates/claude/skills/frontend-design/reference/color-and-contrast.md +132 -0
  122. package/templates/claude/skills/frontend-design/reference/interaction-design.md +123 -0
  123. package/templates/claude/skills/frontend-design/reference/motion-design.md +99 -0
  124. package/templates/claude/skills/frontend-design/reference/responsive-design.md +114 -0
  125. package/templates/claude/skills/frontend-design/reference/spatial-design.md +100 -0
  126. package/templates/claude/skills/frontend-design/reference/typography.md +131 -0
  127. package/templates/claude/skills/frontend-design/reference/ux-writing.md +107 -0
  128. package/templates/claude/skills/gws-admin-reports/SKILL.md +57 -0
  129. package/templates/claude/skills/gws-calendar/SKILL.md +108 -0
  130. package/templates/claude/skills/gws-calendar-agenda/SKILL.md +52 -0
  131. package/templates/claude/skills/gws-calendar-insert/SKILL.md +55 -0
  132. package/templates/claude/skills/gws-chat/SKILL.md +73 -0
  133. package/templates/claude/skills/gws-chat-send/SKILL.md +49 -0
  134. package/templates/claude/skills/gws-classroom/SKILL.md +75 -0
  135. package/templates/claude/skills/gws-docs/SKILL.md +48 -0
  136. package/templates/claude/skills/gws-docs-write/SKILL.md +49 -0
  137. package/templates/claude/skills/gws-drive/SKILL.md +137 -0
  138. package/templates/claude/skills/gws-drive-upload/SKILL.md +52 -0
  139. package/templates/claude/skills/gws-events/SKILL.md +67 -0
  140. package/templates/claude/skills/gws-events-renew/SKILL.md +48 -0
  141. package/templates/claude/skills/gws-events-subscribe/SKILL.md +59 -0
  142. package/templates/claude/skills/gws-forms/SKILL.md +45 -0
  143. package/templates/claude/skills/gws-gmail/SKILL.md +59 -0
  144. package/templates/claude/skills/gws-gmail-forward/SKILL.md +53 -0
  145. package/templates/claude/skills/gws-gmail-reply/SKILL.md +56 -0
  146. package/templates/claude/skills/gws-gmail-reply-all/SKILL.md +60 -0
  147. package/templates/claude/skills/gws-gmail-send/SKILL.md +55 -0
  148. package/templates/claude/skills/gws-gmail-triage/SKILL.md +50 -0
  149. package/templates/claude/skills/gws-gmail-watch/SKILL.md +58 -0
  150. package/templates/claude/skills/gws-keep/SKILL.md +48 -0
  151. package/templates/claude/skills/gws-meet/SKILL.md +51 -0
  152. package/templates/claude/skills/gws-modelarmor/SKILL.md +42 -0
  153. package/templates/claude/skills/gws-modelarmor-create-template/SKILL.md +53 -0
  154. package/templates/claude/skills/gws-modelarmor-sanitize-prompt/SKILL.md +48 -0
  155. package/templates/claude/skills/gws-modelarmor-sanitize-response/SKILL.md +48 -0
  156. package/templates/claude/skills/gws-people/SKILL.md +67 -0
  157. package/templates/claude/skills/gws-shared/SKILL.md +66 -0
  158. package/templates/claude/skills/gws-sheets/SKILL.md +53 -0
  159. package/templates/claude/skills/gws-sheets-append/SKILL.md +51 -0
  160. package/templates/claude/skills/gws-sheets-read/SKILL.md +47 -0
  161. package/templates/claude/skills/gws-slides/SKILL.md +43 -0
  162. package/templates/claude/skills/gws-tasks/SKILL.md +56 -0
  163. package/templates/claude/skills/gws-workflow/SKILL.md +44 -0
  164. package/templates/claude/skills/gws-workflow-email-to-task/SKILL.md +47 -0
  165. package/templates/claude/skills/gws-workflow-file-announce/SKILL.md +50 -0
  166. package/templates/claude/skills/gws-workflow-meeting-prep/SKILL.md +47 -0
  167. package/templates/claude/skills/gws-workflow-standup-report/SKILL.md +46 -0
  168. package/templates/claude/skills/gws-workflow-weekly-digest/SKILL.md +46 -0
  169. package/templates/claude/skills/persona-content-creator/SKILL.md +33 -0
  170. package/templates/claude/skills/persona-customer-support/SKILL.md +34 -0
  171. package/templates/claude/skills/persona-event-coordinator/SKILL.md +35 -0
  172. package/templates/claude/skills/persona-exec-assistant/SKILL.md +35 -0
  173. package/templates/claude/skills/persona-hr-coordinator/SKILL.md +33 -0
  174. package/templates/claude/skills/persona-it-admin/SKILL.md +30 -0
  175. package/templates/claude/skills/persona-project-manager/SKILL.md +35 -0
  176. package/templates/claude/skills/persona-researcher/SKILL.md +33 -0
  177. package/templates/claude/skills/persona-sales-ops/SKILL.md +35 -0
  178. package/templates/claude/skills/persona-team-lead/SKILL.md +36 -0
  179. package/templates/claude/skills/recipe-backup-sheet-as-csv/SKILL.md +25 -0
  180. package/templates/claude/skills/recipe-batch-invite-to-event/SKILL.md +25 -0
  181. package/templates/claude/skills/recipe-block-focus-time/SKILL.md +24 -0
  182. package/templates/claude/skills/recipe-bulk-download-folder/SKILL.md +25 -0
  183. package/templates/claude/skills/recipe-collect-form-responses/SKILL.md +25 -0
  184. package/templates/claude/skills/recipe-compare-sheet-tabs/SKILL.md +25 -0
  185. package/templates/claude/skills/recipe-copy-sheet-for-new-month/SKILL.md +25 -0
  186. package/templates/claude/skills/recipe-create-classroom-course/SKILL.md +25 -0
  187. package/templates/claude/skills/recipe-create-doc-from-template/SKILL.md +29 -0
  188. package/templates/claude/skills/recipe-create-events-from-sheet/SKILL.md +24 -0
  189. package/templates/claude/skills/recipe-create-expense-tracker/SKILL.md +26 -0
  190. package/templates/claude/skills/recipe-create-feedback-form/SKILL.md +25 -0
  191. package/templates/claude/skills/recipe-create-gmail-filter/SKILL.md +26 -0
  192. package/templates/claude/skills/recipe-create-meet-space/SKILL.md +25 -0
  193. package/templates/claude/skills/recipe-create-presentation/SKILL.md +25 -0
  194. package/templates/claude/skills/recipe-create-shared-drive/SKILL.md +25 -0
  195. package/templates/claude/skills/recipe-create-task-list/SKILL.md +26 -0
  196. package/templates/claude/skills/recipe-create-vacation-responder/SKILL.md +25 -0
  197. package/templates/claude/skills/recipe-draft-email-from-doc/SKILL.md +25 -0
  198. package/templates/claude/skills/recipe-email-drive-link/SKILL.md +25 -0
  199. package/templates/claude/skills/recipe-find-free-time/SKILL.md +25 -0
  200. package/templates/claude/skills/recipe-find-large-files/SKILL.md +24 -0
  201. package/templates/claude/skills/recipe-forward-labeled-emails/SKILL.md +27 -0
  202. package/templates/claude/skills/recipe-generate-report-from-sheet/SKILL.md +34 -0
  203. package/templates/claude/skills/recipe-label-and-archive-emails/SKILL.md +25 -0
  204. package/templates/claude/skills/recipe-log-deal-update/SKILL.md +25 -0
  205. package/templates/claude/skills/recipe-organize-drive-folder/SKILL.md +26 -0
  206. package/templates/claude/skills/recipe-plan-weekly-schedule/SKILL.md +26 -0
  207. package/templates/claude/skills/recipe-post-mortem-setup/SKILL.md +25 -0
  208. package/templates/claude/skills/recipe-reschedule-meeting/SKILL.md +25 -0
  209. package/templates/claude/skills/recipe-review-meet-participants/SKILL.md +25 -0
  210. package/templates/claude/skills/recipe-review-overdue-tasks/SKILL.md +25 -0
  211. package/templates/claude/skills/recipe-save-email-attachments/SKILL.md +26 -0
  212. package/templates/claude/skills/recipe-save-email-to-doc/SKILL.md +29 -0
  213. package/templates/claude/skills/recipe-schedule-recurring-event/SKILL.md +24 -0
  214. package/templates/claude/skills/recipe-send-team-announcement/SKILL.md +24 -0
  215. package/templates/claude/skills/recipe-share-doc-and-notify/SKILL.md +25 -0
  216. package/templates/claude/skills/recipe-share-event-materials/SKILL.md +25 -0
  217. package/templates/claude/skills/recipe-share-folder-with-team/SKILL.md +26 -0
  218. package/templates/claude/skills/recipe-sync-contacts-to-sheet/SKILL.md +25 -0
  219. package/templates/claude/skills/recipe-watch-drive-changes/SKILL.md +25 -0
  220. package/templates/mcp.json +12 -0
@@ -0,0 +1,287 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState, useCallback } from "react";
4
+ import { useOverview } from "./overview-context";
5
+ import { AgentGrid } from "@/components/agent-grid";
6
+ import { RunHistoryTable } from "@/components/run-history-table";
7
+ import { ScheduleForm } from "@/components/schedule-form";
8
+ import { SkillsBrowser } from "@/components/skills-browser";
9
+ import { CommandsBrowser } from "@/components/commands-browser";
10
+ import { GovernanceDashboard } from "@/components/governance-dashboard";
11
+ import SettingsPage from "@/app/settings/page";
12
+ import type { AgentMeta, AgentRun, AgentSchedule } from "@/lib/types";
13
+ import type { SkillInfo } from "@/lib/capabilities";
14
+
15
+ type MountedTabs = { agents: boolean; skills: boolean; commands: boolean; runs: boolean; schedules: boolean; governance: boolean; settings: boolean };
16
+
17
+ export function OverviewContent() {
18
+ const { activeTab } = useOverview();
19
+ const [mounted, setMounted] = useState<MountedTabs>({
20
+ agents: activeTab === "agents",
21
+ skills: activeTab === "skills",
22
+ commands: activeTab === "commands",
23
+ runs: activeTab === "runs",
24
+ schedules: activeTab === "schedules",
25
+ governance: activeTab === "governance",
26
+ settings: activeTab === "settings",
27
+ });
28
+
29
+ useEffect(() => {
30
+ setMounted((prev) => ({ ...prev, [activeTab]: true }));
31
+ }, [activeTab]);
32
+
33
+ return (
34
+ <div className="relative h-full">
35
+ <div className={activeTab === "agents" ? "" : "hidden"}>
36
+ {mounted.agents && <AgentsTab />}
37
+ </div>
38
+ <div className={activeTab === "skills" ? "" : "hidden"}>
39
+ {mounted.skills && <SkillsTab />}
40
+ </div>
41
+ <div className={activeTab === "commands" ? "" : "hidden"}>
42
+ {mounted.commands && <CommandsBrowser />}
43
+ </div>
44
+ <div className={activeTab === "runs" ? "" : "hidden"}>
45
+ {mounted.runs && <RunsTab />}
46
+ </div>
47
+ <div className={activeTab === "schedules" ? "" : "hidden"}>
48
+ {mounted.schedules && <SchedulesTab />}
49
+ </div>
50
+ <div className={activeTab === "governance" ? "" : "hidden"}>
51
+ {mounted.governance && <GovernanceDashboard />}
52
+ </div>
53
+ <div className={activeTab === "settings" ? "" : "hidden"}>
54
+ {mounted.settings && <SettingsPage />}
55
+ </div>
56
+ </div>
57
+ );
58
+ }
59
+
60
+ // --- Agents Tab ---
61
+
62
+ function AgentsTab() {
63
+ const [agents, setAgents] = useState<AgentMeta[] | null>(null);
64
+
65
+ const loadAgents = useCallback(() => {
66
+ fetch("/api/agents")
67
+ .then((r) => r.json())
68
+ .then((data: AgentMeta[]) => {
69
+ setAgents(data.filter((a) => a.slug !== "main"));
70
+ });
71
+ }, []);
72
+
73
+ useEffect(() => {
74
+ loadAgents();
75
+ }, [loadAgents]);
76
+
77
+ useEffect(() => {
78
+ const handler = () => loadAgents();
79
+ window.addEventListener("agents-updated", handler);
80
+ return () => window.removeEventListener("agents-updated", handler);
81
+ }, [loadAgents]);
82
+
83
+ if (!agents) {
84
+ return (
85
+ <div>
86
+ <h2 className="text-[11px] font-medium uppercase tracking-wider text-[var(--text-tertiary)] mb-2">
87
+ Specialist Agents
88
+ </h2>
89
+ <div className="space-y-1 animate-pulse">
90
+ {[...Array(6)].map((_, i) => (
91
+ <div key={i} className="flex items-center gap-3 px-3 py-2.5 rounded-md">
92
+ <div className="h-4 w-4 rounded bg-[var(--bg-elevated)]" />
93
+ <div className="h-3.5 w-32 rounded bg-[var(--bg-elevated)]" />
94
+ <div className="h-3 flex-1 rounded bg-[var(--bg-raised)]" />
95
+ </div>
96
+ ))}
97
+ </div>
98
+ </div>
99
+ );
100
+ }
101
+
102
+ return <AgentGrid agents={agents} />;
103
+ }
104
+
105
+ // --- Runs Tab ---
106
+
107
+ function RunsTab() {
108
+ const [runs, setRuns] = useState<AgentRun[]>([]);
109
+ const [loading, setLoading] = useState(true);
110
+
111
+ const fetchRuns = useCallback(() => {
112
+ setLoading(true);
113
+ fetch("/api/runs?limit=100")
114
+ .then((r) => r.json())
115
+ .then((data) => {
116
+ setRuns(data);
117
+ setLoading(false);
118
+ });
119
+ }, []);
120
+
121
+ useEffect(() => {
122
+ fetchRuns();
123
+ }, [fetchRuns]);
124
+
125
+ return (
126
+ <div>
127
+ <div className="flex items-center justify-between mb-4">
128
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)]">Run History</h1>
129
+ <button
130
+ onClick={fetchRuns}
131
+ className="rounded-md px-2.5 py-1 text-[12px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors"
132
+ >
133
+ Refresh
134
+ </button>
135
+ </div>
136
+ {loading ? (
137
+ <div className="space-y-1 animate-pulse">
138
+ {[...Array(6)].map((_, i) => (
139
+ <div key={i} className="flex items-center gap-3 px-3 py-2.5 rounded-md">
140
+ <div className="h-2 w-2 rounded-full bg-[var(--bg-elevated)]" />
141
+ <div className="h-3.5 w-28 rounded bg-[var(--bg-elevated)]" />
142
+ <div className="h-3 flex-1 rounded bg-[var(--bg-raised)]" />
143
+ <div className="h-3 w-16 rounded bg-[var(--bg-raised)]" />
144
+ </div>
145
+ ))}
146
+ </div>
147
+ ) : (
148
+ <RunHistoryTable runs={runs} />
149
+ )}
150
+ </div>
151
+ );
152
+ }
153
+
154
+ // --- Schedules Tab ---
155
+
156
+ function SchedulesTab() {
157
+ const [schedules, setSchedules] = useState<AgentSchedule[]>([]);
158
+ const [agents, setAgents] = useState<AgentMeta[]>([]);
159
+ const [skills, setSkills] = useState<SkillInfo[]>([]);
160
+ const [isSubmitting, setIsSubmitting] = useState(false);
161
+ const [loading, setLoading] = useState(true);
162
+
163
+ const loadData = useCallback(() => {
164
+ Promise.all([
165
+ fetch("/api/schedules").then((r) => r.json()),
166
+ fetch("/api/agents").then((r) => r.json()),
167
+ fetch("/api/skills").then((r) => r.json()),
168
+ ]).then(([sched, ag, sk]) => {
169
+ setSchedules(sched);
170
+ setAgents(ag);
171
+ setSkills(sk);
172
+ setLoading(false);
173
+ });
174
+ }, []);
175
+
176
+ useEffect(() => {
177
+ loadData();
178
+ }, [loadData]);
179
+
180
+ const handleCreate = async (data: {
181
+ agent_slug: string;
182
+ agent_name: string;
183
+ prompt: string;
184
+ cron: string;
185
+ skill_slug?: string;
186
+ }) => {
187
+ setIsSubmitting(true);
188
+ await fetch("/api/schedules", {
189
+ method: "POST",
190
+ headers: { "Content-Type": "application/json" },
191
+ body: JSON.stringify(data),
192
+ });
193
+ setIsSubmitting(false);
194
+ loadData();
195
+ };
196
+
197
+ const handleToggle = async (id: string, enabled: boolean) => {
198
+ await fetch(`/api/schedules/${id}`, {
199
+ method: "PATCH",
200
+ headers: { "Content-Type": "application/json" },
201
+ body: JSON.stringify({ enabled }),
202
+ });
203
+ loadData();
204
+ };
205
+
206
+ const handleDelete = async (id: string) => {
207
+ await fetch(`/api/schedules/${id}`, { method: "DELETE" });
208
+ loadData();
209
+ };
210
+
211
+ const getSkillName = (slug: string | null) => {
212
+ if (!slug) return null;
213
+ return skills.find((s) => s.slug === slug)?.name || slug;
214
+ };
215
+
216
+ if (loading) {
217
+ return (
218
+ <div className="max-w-3xl space-y-6">
219
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)]">Schedules</h1>
220
+ <div className="space-y-2 animate-pulse">
221
+ {[...Array(4)].map((_, i) => (
222
+ <div key={i} className="h-10 rounded-md bg-[var(--bg-raised)]" />
223
+ ))}
224
+ </div>
225
+ </div>
226
+ );
227
+ }
228
+
229
+ return (
230
+ <div className="max-w-3xl space-y-6">
231
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)]">Schedules</h1>
232
+
233
+ <ScheduleForm agents={agents} skills={skills} onSubmit={handleCreate} isSubmitting={isSubmitting} />
234
+
235
+ <div className="border border-[var(--border-subtle)] rounded-lg divide-y divide-[var(--border-subtle)]">
236
+ {schedules.length === 0 ? (
237
+ <p className="text-[13px] text-[var(--text-tertiary)] py-8 text-center">No schedules yet</p>
238
+ ) : (
239
+ schedules.map((schedule) => (
240
+ <div
241
+ key={schedule.id}
242
+ className="flex items-center justify-between px-3 py-2.5"
243
+ >
244
+ <div className="min-w-0 flex-1">
245
+ <div className="flex items-center gap-2 flex-wrap">
246
+ <span className="text-[13px] font-medium text-[var(--text-primary)]">{schedule.agent_name}</span>
247
+ {schedule.skill_slug && (
248
+ <span className="rounded-md bg-[var(--accent-muted)] px-1.5 py-0.5 text-[11px] text-[var(--accent-text)]">
249
+ {getSkillName(schedule.skill_slug)}
250
+ </span>
251
+ )}
252
+ <code className="rounded-md bg-[var(--bg-raised)] border border-[var(--border-subtle)] px-1.5 py-0.5 text-[11px] text-[var(--text-tertiary)]">
253
+ {schedule.cron}
254
+ </code>
255
+ <span className={`h-1.5 w-1.5 rounded-full ${schedule.enabled ? "bg-green-400" : "bg-[var(--text-muted)]"}`} />
256
+ </div>
257
+ {schedule.prompt && (
258
+ <p className="mt-0.5 text-[12px] text-[var(--text-tertiary)] truncate">{schedule.prompt}</p>
259
+ )}
260
+ </div>
261
+ <div className="flex items-center gap-1.5 ml-4 shrink-0">
262
+ <button
263
+ onClick={() => handleToggle(schedule.id, !schedule.enabled)}
264
+ className="rounded-md px-2.5 py-1 text-[11px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors"
265
+ >
266
+ {schedule.enabled ? "Pause" : "Resume"}
267
+ </button>
268
+ <button
269
+ onClick={() => handleDelete(schedule.id)}
270
+ className="rounded-md px-2.5 py-1 text-[11px] text-red-400/60 hover:text-red-400 hover:bg-red-500/10 transition-colors"
271
+ >
272
+ Delete
273
+ </button>
274
+ </div>
275
+ </div>
276
+ ))
277
+ )}
278
+ </div>
279
+ </div>
280
+ );
281
+ }
282
+
283
+ // --- Skills Tab ---
284
+
285
+ function SkillsTab() {
286
+ return <SkillsBrowser />;
287
+ }
@@ -0,0 +1,88 @@
1
+ "use client";
2
+
3
+ import { createContext, useContext, useState, useCallback, useEffect } from "react";
4
+
5
+ export type OverviewTab = "agents" | "skills" | "commands" | "runs" | "schedules" | "governance" | "settings";
6
+
7
+ const OVERVIEW_PATHS = ["/agents", "/skills", "/commands", "/runs", "/schedules", "/governance", "/settings"];
8
+
9
+ export function isOverviewPath(pathname: string): boolean {
10
+ return OVERVIEW_PATHS.some((p) => pathname === p);
11
+ }
12
+
13
+ function pathToTab(pathname: string): OverviewTab | null {
14
+ if (pathname === "/agents") return "agents";
15
+ if (pathname.startsWith("/skills")) return "skills";
16
+ if (pathname.startsWith("/commands")) return "commands";
17
+ if (pathname.startsWith("/runs")) return "runs";
18
+ if (pathname.startsWith("/schedules")) return "schedules";
19
+ if (pathname.startsWith("/governance")) return "governance";
20
+ if (pathname.startsWith("/settings")) return "settings";
21
+ return null;
22
+ }
23
+
24
+ interface OverviewContextValue {
25
+ activeTab: OverviewTab;
26
+ setTab: (tab: OverviewTab) => void;
27
+ isOverview: boolean;
28
+ }
29
+
30
+ const OverviewContext = createContext<OverviewContextValue>({
31
+ activeTab: "agents",
32
+ setTab: () => {},
33
+ isOverview: false,
34
+ });
35
+
36
+ export function useOverview() {
37
+ return useContext(OverviewContext);
38
+ }
39
+
40
+ const TAB_PATHS: Record<OverviewTab, string> = {
41
+ agents: "/agents",
42
+ skills: "/skills",
43
+ commands: "/commands",
44
+ runs: "/runs",
45
+ schedules: "/schedules",
46
+ governance: "/governance",
47
+ settings: "/settings",
48
+ };
49
+
50
+ export function OverviewProvider({ children, pathname }: { children: React.ReactNode; pathname: string }) {
51
+ const detectedTab = pathToTab(pathname);
52
+ const [isOverview, setIsOverview] = useState(detectedTab !== null);
53
+ const [activeTab, setActiveTab] = useState<OverviewTab>(detectedTab || "agents");
54
+
55
+ useEffect(() => {
56
+ const tab = pathToTab(pathname);
57
+ setIsOverview(tab !== null);
58
+ if (tab) {
59
+ setActiveTab(tab);
60
+ }
61
+ }, [pathname]);
62
+
63
+ useEffect(() => {
64
+ const handlePopState = () => {
65
+ const tab = pathToTab(window.location.pathname);
66
+ if (tab) {
67
+ setIsOverview(true);
68
+ setActiveTab(tab);
69
+ } else {
70
+ setIsOverview(false);
71
+ }
72
+ };
73
+ window.addEventListener("popstate", handlePopState);
74
+ return () => window.removeEventListener("popstate", handlePopState);
75
+ }, []);
76
+
77
+ const setTab = useCallback((tab: OverviewTab) => {
78
+ setActiveTab(tab);
79
+ setIsOverview(true);
80
+ window.history.pushState(null, "", TAB_PATHS[tab]);
81
+ }, []);
82
+
83
+ return (
84
+ <OverviewContext.Provider value={{ activeTab, setTab, isOverview }}>
85
+ {children}
86
+ </OverviewContext.Provider>
87
+ );
88
+ }
@@ -0,0 +1,112 @@
1
+ "use client";
2
+
3
+ import { useState, useEffect, useCallback } from "react";
4
+ import { XIcon } from "@/components/icons";
5
+
6
+ interface PreferencesModalProps {
7
+ open: boolean;
8
+ onClose: () => void;
9
+ }
10
+
11
+ export function PreferencesModal({ open, onClose }: PreferencesModalProps) {
12
+ const [preferences, setPreferences] = useState("");
13
+ const [loading, setLoading] = useState(true);
14
+ const [saving, setSaving] = useState(false);
15
+ const [dirty, setDirty] = useState(false);
16
+
17
+ useEffect(() => {
18
+ if (!open) return;
19
+ setLoading(true);
20
+ fetch("/api/preferences")
21
+ .then((r) => r.json())
22
+ .then((data) => {
23
+ setPreferences(data.preferences || "");
24
+ setDirty(false);
25
+ })
26
+ .catch(() => {})
27
+ .finally(() => setLoading(false));
28
+ }, [open]);
29
+
30
+ const save = useCallback(async () => {
31
+ setSaving(true);
32
+ try {
33
+ await fetch("/api/preferences", {
34
+ method: "PUT",
35
+ headers: { "Content-Type": "application/json" },
36
+ body: JSON.stringify({ preferences }),
37
+ });
38
+ setDirty(false);
39
+ } catch {
40
+ // silent
41
+ } finally {
42
+ setSaving(false);
43
+ }
44
+ }, [preferences]);
45
+
46
+ useEffect(() => {
47
+ if (!open) return;
48
+ const handle = (e: KeyboardEvent) => {
49
+ if ((e.metaKey || e.ctrlKey) && e.key === "s") {
50
+ e.preventDefault();
51
+ save();
52
+ }
53
+ };
54
+ document.addEventListener("keydown", handle);
55
+ return () => document.removeEventListener("keydown", handle);
56
+ }, [open, save]);
57
+
58
+ if (!open) return null;
59
+
60
+ return (
61
+ <div className="fixed inset-0 z-50 flex items-center justify-center">
62
+ <div className="absolute inset-0 bg-black/60 backdrop-blur-sm" onClick={onClose} />
63
+ <div className="relative w-full max-w-lg mx-4 rounded-lg border border-[var(--border-default)] bg-[#111113] shadow-2xl shadow-black/50">
64
+ {/* Header */}
65
+ <div className="flex items-center justify-between px-5 py-4 border-b border-[var(--border-subtle)]">
66
+ <div>
67
+ <h2 className="text-[13px] font-semibold text-[var(--text-primary)]">Personal Preferences</h2>
68
+ <p className="text-[11px] text-[var(--text-muted)] mt-0.5">
69
+ Sent to the AI with every message as context about you.
70
+ </p>
71
+ </div>
72
+ <button onClick={onClose} className="p-1 rounded-md text-[var(--text-muted)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors">
73
+ <XIcon size={14} />
74
+ </button>
75
+ </div>
76
+
77
+ {/* Body */}
78
+ <div className="px-5 py-4">
79
+ {loading ? (
80
+ <div className="h-48 rounded-md bg-[var(--bg-raised)] animate-pulse" />
81
+ ) : (
82
+ <>
83
+ <textarea
84
+ value={preferences}
85
+ onChange={(e) => { setPreferences(e.target.value); setDirty(true); }}
86
+ placeholder={"Tell the AI about yourself — your role, communication style, technical level, preferred tools, formatting preferences.\n\nExamples:\n• I'm a senior engineer, skip basic explanations\n• Always respond concisely — no fluff\n• I prefer TypeScript over JavaScript"}
87
+ className="w-full h-48 rounded-md border border-[var(--border-default)] bg-[var(--bg-raised)] px-3 py-2.5 text-[13px] text-[var(--text-primary)] placeholder:text-[var(--text-muted)] focus:outline-none focus:border-[var(--border-focus)] resize-none"
88
+ />
89
+ <p className="text-[11px] text-[var(--text-muted)] mt-2">
90
+ {preferences.length} characters{dirty ? " · unsaved" : ""} · Ctrl+S to save
91
+ </p>
92
+ </>
93
+ )}
94
+ </div>
95
+
96
+ {/* Footer */}
97
+ <div className="flex items-center justify-end gap-2 px-5 py-3 border-t border-[var(--border-subtle)]">
98
+ <button onClick={onClose} className="px-3 py-1.5 text-[12px] font-medium text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] rounded-md hover:bg-[var(--bg-hover)] transition-colors">
99
+ Cancel
100
+ </button>
101
+ <button
102
+ onClick={async () => { await save(); onClose(); }}
103
+ disabled={saving || !dirty}
104
+ className="px-3 py-1.5 text-[12px] font-medium rounded-md bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)] disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
105
+ >
106
+ {saving ? "Saving…" : "Save"}
107
+ </button>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ );
112
+ }
@@ -0,0 +1,73 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import type { AgentMeta } from "@/lib/types";
5
+
6
+ interface RunFormProps {
7
+ agent: AgentMeta;
8
+ onRun: (prompt: string) => void;
9
+ isRunning: boolean;
10
+ isFollowUp?: boolean;
11
+ }
12
+
13
+ export function RunForm({ agent, onRun, isRunning, isFollowUp }: RunFormProps) {
14
+ const [prompt, setPrompt] = useState("");
15
+
16
+ const handleSubmit = (e: React.FormEvent) => {
17
+ e.preventDefault();
18
+ if (!prompt.trim() || isRunning) return;
19
+ onRun(prompt.trim());
20
+ setPrompt("");
21
+ };
22
+
23
+ const handleKeyDown = (e: React.KeyboardEvent) => {
24
+ if (isFollowUp && e.key === "Enter" && !e.shiftKey) {
25
+ e.preventDefault();
26
+ handleSubmit(e);
27
+ }
28
+ };
29
+
30
+ if (isFollowUp) {
31
+ return (
32
+ <form onSubmit={handleSubmit} className="flex gap-2 items-end">
33
+ <textarea
34
+ value={prompt}
35
+ onChange={(e) => setPrompt(e.target.value)}
36
+ onKeyDown={handleKeyDown}
37
+ placeholder="Follow up..."
38
+ rows={1}
39
+ className="flex-1 resize-none rounded-md border border-[var(--border-default)] bg-[var(--bg-raised)] px-4 py-2.5 text-[13px] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:border-[var(--border-focus)] focus:outline-none"
40
+ />
41
+ <button
42
+ type="submit"
43
+ disabled={!prompt.trim() || isRunning}
44
+ className="rounded-md bg-[var(--accent)] px-4 py-2.5 text-[13px] font-medium text-white transition-colors hover:bg-[var(--accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed shrink-0"
45
+ >
46
+ {isRunning ? "..." : "Send"}
47
+ </button>
48
+ </form>
49
+ );
50
+ }
51
+
52
+ return (
53
+ <form onSubmit={handleSubmit} className="space-y-3">
54
+ <label className="block text-[12px] font-medium text-[var(--text-secondary)]">
55
+ Prompt for {agent.name}
56
+ </label>
57
+ <textarea
58
+ value={prompt}
59
+ onChange={(e) => setPrompt(e.target.value)}
60
+ placeholder="Enter a prompt for this agent..."
61
+ rows={3}
62
+ className="w-full rounded-md border border-[var(--border-default)] bg-[var(--bg-raised)] px-4 py-3 text-[13px] text-[var(--text-primary)] placeholder-[var(--text-muted)] focus:border-[var(--border-focus)] focus:outline-none"
63
+ />
64
+ <button
65
+ type="submit"
66
+ disabled={!prompt.trim() || isRunning}
67
+ className="rounded-md bg-[var(--accent)] px-4 py-2 text-[12px] font-medium text-white transition-colors hover:bg-[var(--accent-hover)] disabled:opacity-50 disabled:cursor-not-allowed"
68
+ >
69
+ {isRunning ? "Running..." : "Run Agent"}
70
+ </button>
71
+ </form>
72
+ );
73
+ }