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,349 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState, useCallback, useRef } from "react";
4
+ import type { CommandInfo } from "@/lib/capabilities";
5
+ import {
6
+ SearchIcon,
7
+ XIcon,
8
+ ChevronLeftIcon,
9
+ ChevronDownIcon,
10
+ ChevronRightIcon,
11
+ EditIcon,
12
+ CheckIcon,
13
+ TerminalIcon,
14
+ PackageIcon,
15
+ } from "@/components/icons";
16
+
17
+ const GROUP_LABELS: Record<string, string> = {
18
+ consider: "Decision Frameworks",
19
+ };
20
+
21
+ export function CommandsBrowser() {
22
+ const [commands, setCommands] = useState<CommandInfo[] | null>(null);
23
+ const [selectedCommand, setSelectedCommand] = useState<string | null>(null);
24
+ const [commandContent, setCommandContent] = useState<string | null>(null);
25
+ const [loadingContent, setLoadingContent] = useState(false);
26
+ const [editing, setEditing] = useState(false);
27
+ const [editContent, setEditContent] = useState("");
28
+ const [saving, setSaving] = useState(false);
29
+ const [saveStatus, setSaveStatus] = useState<"idle" | "saved" | "error">("idle");
30
+ const [searchQuery, setSearchQuery] = useState("");
31
+ const [collapsed, setCollapsed] = useState<Record<string, boolean>>({});
32
+ const detailRef = useRef<HTMLDivElement>(null);
33
+
34
+ useEffect(() => {
35
+ fetch("/api/commands")
36
+ .then((r) => r.json())
37
+ .then((data: CommandInfo[]) => setCommands(data));
38
+ }, []);
39
+
40
+ const loadCommandContent = useCallback((slug: string) => {
41
+ setSelectedCommand(slug);
42
+ setLoadingContent(true);
43
+ setEditing(false);
44
+ setSaveStatus("idle");
45
+ fetch(`/api/commands/${encodeURIComponent(slug)}`)
46
+ .then((r) => r.json())
47
+ .then((data) => {
48
+ setCommandContent(data.content || "");
49
+ setEditContent(data.content || "");
50
+ setLoadingContent(false);
51
+ })
52
+ .catch(() => {
53
+ setCommandContent(null);
54
+ setLoadingContent(false);
55
+ });
56
+ setTimeout(() => detailRef.current?.scrollIntoView({ behavior: "smooth", block: "start" }), 50);
57
+ }, []);
58
+
59
+ const handleSave = async () => {
60
+ if (!selectedCommand) return;
61
+ setSaving(true);
62
+ setSaveStatus("idle");
63
+ try {
64
+ const res = await fetch(`/api/commands/${encodeURIComponent(selectedCommand)}`, {
65
+ method: "PATCH",
66
+ headers: { "Content-Type": "application/json" },
67
+ body: JSON.stringify({ content: editContent }),
68
+ });
69
+ if (res.ok) {
70
+ setCommandContent(editContent);
71
+ setEditing(false);
72
+ setSaveStatus("saved");
73
+ setTimeout(() => setSaveStatus("idle"), 2500);
74
+ } else {
75
+ setSaveStatus("error");
76
+ }
77
+ } catch {
78
+ setSaveStatus("error");
79
+ }
80
+ setSaving(false);
81
+ };
82
+
83
+ const handleBack = () => {
84
+ setSelectedCommand(null);
85
+ setCommandContent(null);
86
+ setEditing(false);
87
+ setSaveStatus("idle");
88
+ };
89
+
90
+ const toggleGroup = (group: string) => {
91
+ setCollapsed((prev) => ({ ...prev, [group]: !prev[group] }));
92
+ };
93
+
94
+ if (!commands) {
95
+ return (
96
+ <div>
97
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)] mb-4">Commands</h1>
98
+ <div className="space-y-2 animate-pulse">
99
+ {[...Array(8)].map((_, i) => (
100
+ <div key={i} className="h-9 rounded-md bg-[var(--bg-raised)]" />
101
+ ))}
102
+ </div>
103
+ </div>
104
+ );
105
+ }
106
+
107
+ // Group: ungrouped first, then grouped
108
+ const ungrouped = commands.filter((c) => !c.group);
109
+ const groups = commands.reduce<Record<string, CommandInfo[]>>((acc, cmd) => {
110
+ if (cmd.group) {
111
+ (acc[cmd.group] ||= []).push(cmd);
112
+ }
113
+ return acc;
114
+ }, {});
115
+ const groupNames = Object.keys(groups).sort();
116
+
117
+ // Filter by search
118
+ const q = searchQuery.toLowerCase();
119
+ const filterItems = (items: CommandInfo[]) => {
120
+ if (!q) return items;
121
+ return items.filter(
122
+ (c) => c.name.toLowerCase().includes(q) || c.slug.toLowerCase().includes(q) || c.description.toLowerCase().includes(q)
123
+ );
124
+ };
125
+
126
+ const filteredUngrouped = filterItems(ungrouped);
127
+ const totalFiltered = filteredUngrouped.length + groupNames.reduce((sum, g) => sum + filterItems(groups[g]).length, 0);
128
+
129
+ const selectedInfo = commands.find((c) => c.slug === selectedCommand);
130
+
131
+ // ---- Detail View ----
132
+ if (selectedCommand) {
133
+ return (
134
+ <div ref={detailRef} className="flex flex-col" style={{ height: "calc(100vh - 6rem)" }}>
135
+ <div className="flex items-center justify-between mb-4 shrink-0">
136
+ <div className="flex items-center gap-3 min-w-0">
137
+ <button
138
+ onClick={handleBack}
139
+ className="shrink-0 flex items-center gap-1 rounded-md px-2 py-1 text-[12px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors"
140
+ >
141
+ <ChevronLeftIcon size={14} />
142
+ Back
143
+ </button>
144
+ <div className="min-w-0">
145
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)] truncate">
146
+ /{selectedCommand}
147
+ </h1>
148
+ {selectedInfo?.description && (
149
+ <p className="text-[12px] text-[var(--text-tertiary)] mt-0.5 truncate">{selectedInfo.description}</p>
150
+ )}
151
+ </div>
152
+ </div>
153
+ <div className="flex items-center gap-2 shrink-0">
154
+ {saveStatus === "saved" && (
155
+ <span className="flex items-center gap-1 text-[11px] text-green-400/80">
156
+ <CheckIcon size={12} />
157
+ Saved
158
+ </span>
159
+ )}
160
+ {saveStatus === "error" && (
161
+ <span className="text-[11px] text-red-400/80">Save failed</span>
162
+ )}
163
+ {editing ? (
164
+ <>
165
+ <button
166
+ onClick={() => { setEditing(false); setEditContent(commandContent || ""); }}
167
+ className="rounded-md px-3 py-1.5 text-[12px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors"
168
+ >
169
+ Cancel
170
+ </button>
171
+ <button
172
+ onClick={handleSave}
173
+ disabled={saving}
174
+ className="rounded-md bg-[var(--accent)] px-3 py-1.5 text-[12px] font-medium text-white hover:bg-[var(--accent-hover)] disabled:opacity-50 transition-colors"
175
+ >
176
+ {saving ? "Saving..." : "Save"}
177
+ </button>
178
+ </>
179
+ ) : (
180
+ <button
181
+ onClick={() => setEditing(true)}
182
+ className="flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-[12px] text-[var(--text-tertiary)] hover:text-[var(--text-secondary)] hover:bg-[var(--bg-hover)] transition-colors"
183
+ >
184
+ <EditIcon size={12} />
185
+ Edit
186
+ </button>
187
+ )}
188
+ </div>
189
+ </div>
190
+
191
+ <div className="mb-3 shrink-0">
192
+ <code className="text-[11px] text-[var(--text-muted)] bg-[var(--bg-raised)] border border-[var(--border-subtle)] px-2 py-0.5 rounded-md">
193
+ .claude/commands/{selectedCommand}.md
194
+ </code>
195
+ </div>
196
+
197
+ {loadingContent ? (
198
+ <div className="flex-1 animate-pulse space-y-2">
199
+ {[...Array(6)].map((_, i) => (
200
+ <div key={i} className="h-4 rounded bg-[var(--bg-raised)]" style={{ width: `${70 + Math.random() * 30}%` }} />
201
+ ))}
202
+ </div>
203
+ ) : editing ? (
204
+ <textarea
205
+ value={editContent}
206
+ onChange={(e) => setEditContent(e.target.value)}
207
+ className="flex-1 min-h-0 w-full rounded-lg border border-[var(--border-default)] bg-[var(--bg-base)] p-4 text-[13px] text-[var(--text-secondary)] font-mono leading-relaxed resize-none focus:border-[var(--border-focus)] focus:outline-none"
208
+ spellCheck={false}
209
+ />
210
+ ) : (
211
+ <div className="flex-1 overflow-y-auto">
212
+ <pre className="whitespace-pre-wrap break-words text-[13px] text-[var(--text-secondary)] font-mono leading-relaxed bg-[var(--bg-raised)] rounded-lg border border-[var(--border-subtle)] p-4">
213
+ {commandContent}
214
+ </pre>
215
+ </div>
216
+ )}
217
+ </div>
218
+ );
219
+ }
220
+
221
+ // ---- Browse View ----
222
+ return (
223
+ <div>
224
+ <div className="flex items-center justify-between mb-4">
225
+ <div>
226
+ <h1 className="text-[15px] font-semibold text-[var(--text-primary)]">Commands</h1>
227
+ <p className="text-[12px] text-[var(--text-muted)] mt-0.5">
228
+ {q ? `${totalFiltered} of ${commands.length}` : `${commands.length} commands`}
229
+ </p>
230
+ </div>
231
+ <div className="w-56">
232
+ <div className="relative">
233
+ <SearchIcon size={14} className="absolute left-2.5 top-1/2 -translate-y-1/2 text-[var(--text-muted)]" />
234
+ <input
235
+ type="text"
236
+ placeholder="Search..."
237
+ value={searchQuery}
238
+ onChange={(e) => setSearchQuery(e.target.value)}
239
+ className="w-full rounded-md border border-[var(--border-subtle)] bg-[var(--bg-raised)] pl-8 pr-3 py-1.5 text-[13px] text-[var(--text-secondary)] placeholder:text-[var(--text-muted)] focus:border-[var(--border-focus)] focus:outline-none transition-colors"
240
+ />
241
+ {searchQuery && (
242
+ <button
243
+ onClick={() => setSearchQuery("")}
244
+ className="absolute right-2 top-1/2 -translate-y-1/2 text-[var(--text-muted)] hover:text-[var(--text-secondary)]"
245
+ >
246
+ <XIcon size={12} />
247
+ </button>
248
+ )}
249
+ </div>
250
+ </div>
251
+ </div>
252
+
253
+ <div className="space-y-1">
254
+ {/* Ungrouped commands */}
255
+ {filteredUngrouped.length > 0 && (
256
+ <div>
257
+ <div className="flex items-center gap-2.5 px-2 py-1.5">
258
+ <TerminalIcon size={14} className="text-[var(--text-tertiary)] opacity-70" />
259
+ <span className="text-[12px] font-medium text-[var(--text-secondary)]">General</span>
260
+ <span className="text-[11px] text-[var(--text-muted)] tabular-nums">{filteredUngrouped.length}</span>
261
+ </div>
262
+ <div className="ml-[26px] border-l border-[var(--border-subtle)]">
263
+ {filteredUngrouped.map((cmd) => (
264
+ <button
265
+ key={cmd.slug}
266
+ onClick={() => loadCommandContent(cmd.slug)}
267
+ className="group/item flex items-center gap-2 w-full text-left pl-4 pr-2 py-1.5 hover:bg-[var(--bg-hover)] transition-colors"
268
+ >
269
+ <span className="text-[13px] text-[var(--text-secondary)] group-hover/item:text-[var(--text-primary)] transition-colors truncate">
270
+ /{cmd.slug}
271
+ </span>
272
+ {cmd.description && (
273
+ <span className="text-[11px] text-[var(--text-muted)] truncate flex-1">{cmd.description}</span>
274
+ )}
275
+ <ChevronRightIcon
276
+ size={12}
277
+ className="text-[var(--text-muted)] opacity-0 group-hover/item:opacity-100 transition-opacity shrink-0"
278
+ />
279
+ </button>
280
+ ))}
281
+ </div>
282
+ </div>
283
+ )}
284
+
285
+ {/* Grouped commands */}
286
+ {groupNames.map((group) => {
287
+ const items = filterItems(groups[group]);
288
+ if (!items.length) return null;
289
+ const isCollapsed = collapsed[group] ?? false;
290
+ const label = GROUP_LABELS[group] || group;
291
+
292
+ return (
293
+ <div key={group}>
294
+ <button
295
+ onClick={() => toggleGroup(group)}
296
+ className="flex items-center gap-2.5 w-full text-left px-2 py-1.5 rounded-md hover:bg-[var(--bg-hover)] transition-colors group"
297
+ >
298
+ <ChevronDownIcon
299
+ size={12}
300
+ className={`text-[var(--text-muted)] transition-transform duration-150 ${isCollapsed ? "-rotate-90" : ""}`}
301
+ />
302
+ <PackageIcon size={14} className="text-[var(--text-tertiary)] opacity-70" />
303
+ <span className="text-[12px] font-medium text-[var(--text-secondary)]">
304
+ {label}
305
+ </span>
306
+ <span className="text-[11px] text-[var(--text-muted)] tabular-nums">{items.length}</span>
307
+ </button>
308
+
309
+ {!isCollapsed && (
310
+ <div className="ml-[26px] border-l border-[var(--border-subtle)]">
311
+ {items.map((cmd) => (
312
+ <button
313
+ key={cmd.slug}
314
+ onClick={() => loadCommandContent(cmd.slug)}
315
+ className="group/item flex items-center gap-2 w-full text-left pl-4 pr-2 py-1.5 hover:bg-[var(--bg-hover)] transition-colors"
316
+ >
317
+ <span className="text-[13px] text-[var(--text-secondary)] group-hover/item:text-[var(--text-primary)] transition-colors truncate">
318
+ /{cmd.slug}
319
+ </span>
320
+ {cmd.description && (
321
+ <span className="text-[11px] text-[var(--text-muted)] truncate flex-1">{cmd.description}</span>
322
+ )}
323
+ <ChevronRightIcon
324
+ size={12}
325
+ className="text-[var(--text-muted)] opacity-0 group-hover/item:opacity-100 transition-opacity shrink-0"
326
+ />
327
+ </button>
328
+ ))}
329
+ </div>
330
+ )}
331
+ </div>
332
+ );
333
+ })}
334
+
335
+ {q && totalFiltered === 0 && (
336
+ <div className="text-center py-12">
337
+ <p className="text-[13px] text-[var(--text-tertiary)]">No commands match &ldquo;{searchQuery}&rdquo;</p>
338
+ <button
339
+ onClick={() => setSearchQuery("")}
340
+ className="mt-2 text-[12px] text-[var(--accent-text)] hover:text-[var(--accent-hover)]"
341
+ >
342
+ Clear search
343
+ </button>
344
+ </div>
345
+ )}
346
+ </div>
347
+ </div>
348
+ );
349
+ }