claude-code-session-manager 0.108.0 → 0.110.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 (79) hide show
  1. package/dist/assets/AgentLibrary-Cm6MrOnF.js +2 -0
  2. package/dist/assets/{Button-DC6VzovQ.js → Button-CGVncJ6a.js} +1 -1
  3. package/dist/assets/DataModel-C3hlMoa8.js +1 -0
  4. package/dist/assets/History-CTyfGNKn.js +2 -0
  5. package/dist/assets/Hooks-BXxCBibx.js +3 -0
  6. package/dist/assets/{Library-DLmnlfQt.js → Library-aCs7zxAg.js} +24 -24
  7. package/dist/assets/{ListDetail-YylbvUj_.js → ListDetail-B9Hqk1_f.js} +1 -1
  8. package/dist/assets/{MarkdownEditor-DMPKWHTF.js → MarkdownEditor-Djfgp32k.js} +1 -1
  9. package/dist/assets/{McpServers-Da-Ty5nc.js → McpServers-8HQC6QgR.js} +2 -2
  10. package/dist/assets/{Memory-C3rUQ_cg.js → Memory-c4SVE3l2.js} +5 -5
  11. package/dist/assets/{Panel-CC3JTnOI.js → Panel-BEQTwE4z.js} +1 -1
  12. package/dist/assets/Permissions-BaYzgZtc.js +3 -0
  13. package/dist/assets/Plugins-DnXsVau7.js +2 -0
  14. package/dist/assets/ProvenanceBadge-CT2vWps1.js +1 -0
  15. package/dist/assets/RemoteMachines-DHJZfdJC.js +3 -0
  16. package/dist/assets/{SaveBar-C06rFT34.js → SaveBar-DwcHt3iR.js} +1 -1
  17. package/dist/assets/Scheduler-D6Gcuo0M.js +16 -0
  18. package/dist/assets/{ScopeSwitcher-Cp5mxblN.js → ScopeSwitcher-CgvWDc9Y.js} +1 -1
  19. package/dist/assets/Settings-CJoogVAB.js +4 -0
  20. package/dist/assets/{SkillReferenceGraph-DuWRmT_f.js → SkillReferenceGraph-4fq01kxq.js} +14 -14
  21. package/dist/assets/Skills-BU4ZX4h4.js +2 -0
  22. package/dist/assets/SystemPrompt-BCEyMSEq.js +1 -0
  23. package/dist/assets/TagLibrary-m3It8Oal.js +1 -0
  24. package/dist/assets/{TiptapBody-1r4ODLJ7.js → TiptapBody-DVyBsfsT.js} +1 -1
  25. package/dist/assets/{Toggle-BGT68XHP.js → Toggle-In_AExPV.js} +1 -1
  26. package/dist/assets/{ViewTabs-T0NBc8uv.js → ViewTabs-BLHjKUv-.js} +1 -1
  27. package/dist/assets/historyTotals-BXDd3EzP.js +1 -0
  28. package/dist/assets/index-CuiU3I-8.js +3077 -0
  29. package/dist/assets/{index-tr1w3hHB.css → index-Dutcsly-.css} +1 -1
  30. package/dist/assets/listSkills-C1aWKf0T.js +1 -0
  31. package/dist/assets/{settingsSchema-CvoNk3Ye.js → settingsSchema-DD4bc5cT.js} +1 -1
  32. package/dist/assets/useAgentsDirWatch-DMQ_XZtr.js +1 -0
  33. package/dist/assets/useRemotePeers-C9NfteSD.js +1 -0
  34. package/dist/index.html +2 -2
  35. package/package.json +6 -2
  36. package/plugins/session-manager-dev/skills/develop/SKILL.md +3 -1
  37. package/plugins/session-manager-dev/skills/develop/standards.md +5 -0
  38. package/plugins/session-manager-dev/skills/send-feedback/SKILL.md +48 -15
  39. package/scripts/README.md +7 -0
  40. package/scripts/scheduler-mcp-server.cjs +29 -2
  41. package/src/main/agentLibrary.cjs +20 -9
  42. package/src/main/build-info.json +4 -4
  43. package/src/main/chatRunner.cjs +7 -0
  44. package/src/main/config.cjs +20 -10
  45. package/src/main/historyAggregator.cjs +46 -3
  46. package/src/main/index.cjs +8 -0
  47. package/src/main/ipcSchemas.cjs +30 -0
  48. package/src/main/lib/autoUpdater.cjs +190 -0
  49. package/src/main/lib/crossProjectFeedback.cjs +143 -6
  50. package/src/main/lib/mcpToolCatalog.cjs +12 -3
  51. package/src/main/lib/reaperHelpers.cjs +13 -1
  52. package/src/main/lib/relayClientAuth.cjs +133 -0
  53. package/src/main/lib/remoteClientSessions.cjs +84 -0
  54. package/src/main/lib/remoteE2eCrypto.cjs +109 -0
  55. package/src/main/lib/updaterSettings.cjs +64 -0
  56. package/src/main/pty.cjs +53 -0
  57. package/src/main/remoteClient.cjs +334 -0
  58. package/src/main/remoteClientIpc.cjs +133 -0
  59. package/src/main/scheduler.cjs +16 -0
  60. package/src/main/updaterIpc.cjs +110 -0
  61. package/src/main/webRemote.cjs +341 -215
  62. package/src/preload/api.d.ts +97 -7
  63. package/src/preload/index.cjs +51 -3
  64. package/dist/assets/AgentLibrary-Co54GThg.js +0 -2
  65. package/dist/assets/DataModel-DZ0vyJau.js +0 -1
  66. package/dist/assets/History-Df3YwpPe.js +0 -2
  67. package/dist/assets/Hooks-DplG6roH.js +0 -3
  68. package/dist/assets/Permissions-XvBiMj1-.js +0 -3
  69. package/dist/assets/Plugins-CzHY1mgS.js +0 -2
  70. package/dist/assets/ProvenanceBadge-DaJIWVcg.js +0 -1
  71. package/dist/assets/Scheduler-BehadU-0.js +0 -16
  72. package/dist/assets/Settings-Cg9LIni0.js +0 -4
  73. package/dist/assets/Skills-CMmCZfIv.js +0 -3
  74. package/dist/assets/SystemPrompt-D_-MV025.js +0 -1
  75. package/dist/assets/TagLibrary-D9Tv3yOJ.js +0 -1
  76. package/dist/assets/index-3_AtCAyd.js +0 -3077
  77. package/dist/assets/listSkills-QORduPIk.js +0 -1
  78. package/dist/assets/useAgentsDirWatch-1C2CBBya.js +0 -1
  79. package/dist/assets/useConfigDirWatch-Cd5PnTkB.js +0 -1
@@ -1,6 +1,21 @@
1
1
  import type { PromptSession } from '../renderer/state/promptSessions';
2
2
 
3
3
  /** Mirrors the item shape returned by main/lib/prereqs.cjs checkPrereqs(). */
4
+ export type AutoUpdaterState =
5
+ | 'unsupported' | 'disabled' | 'idle' | 'checking'
6
+ | 'downloading' | 'ready' | 'deferred' | 'error';
7
+
8
+ export type AutoUpdaterStatus = {
9
+ state: AutoUpdaterState;
10
+ current: string;
11
+ latest: string | null;
12
+ progress: number | null;
13
+ error: string | null;
14
+ busyReason: string | null;
15
+ lastCheckedAt: number | null;
16
+ enabled: boolean;
17
+ };
18
+
4
19
  export interface PrereqItem {
5
20
  id: string;
6
21
  label: string;
@@ -317,12 +332,13 @@ export interface AgentPersonaSaveInput {
317
332
  effort?: string;
318
333
  color: string;
319
334
  tags: AgentPersonaTag[];
320
- /** Project cwds (or the `'*'` sentinel) this persona's Action button appears in. */
335
+ /** Project cwds (or the `'*'` sentinel) this persona's Action button appears in. Omit to keep the existing file's value; `[]` clears it. */
321
336
  projects?: string[];
322
- /** Opening instruction sent by this persona's Action button. */
337
+ /** Opening instruction sent by this persona's Action button. Omit to keep the existing file's value. */
323
338
  action?: string;
324
- /** Caption override for this persona's Action button. */
339
+ /** Caption override for this persona's Action button. Omit to keep the existing file's value. */
325
340
  actionLabel?: string;
341
+ /** Omit to keep the existing file's value. */
326
342
  title?: string;
327
343
  /** Open project name: write that project's frontmatter-only override (only `model`/`effort` are used) instead of the global file. */
328
344
  projectName?: string;
@@ -1593,6 +1609,42 @@ export interface WebRemoteDevice {
1593
1609
  lastConnectedAt: string | null;
1594
1610
  }
1595
1611
 
1612
+ export interface RemoteMachinePeer {
1613
+ peerId: string;
1614
+ deviceId: string;
1615
+ machineName: string;
1616
+ pairedAt: string;
1617
+ clientPublicKey: string;
1618
+ verifiedDevicePubKey: string | null;
1619
+ /** process.platform of the remote machine, last known (null until first authenticated). */
1620
+ os: string | null;
1621
+ status: string;
1622
+ reason: string | null;
1623
+ sas: string | null;
1624
+ }
1625
+
1626
+ export interface RemoteClientDevice {
1627
+ deviceId: string;
1628
+ email: string;
1629
+ issuedAt: string;
1630
+ expiresAt: string;
1631
+ isOnline: boolean;
1632
+ devicePubKey: string;
1633
+ }
1634
+
1635
+ export interface RemoteClientStatus {
1636
+ peerId: string;
1637
+ status: string;
1638
+ reason: string | null;
1639
+ sas: string | null;
1640
+ }
1641
+
1642
+ export interface RemoteClientEvent {
1643
+ peerId: string;
1644
+ type: string;
1645
+ payload: unknown;
1646
+ }
1647
+
1596
1648
  export interface WebRemoteStatus {
1597
1649
  enabled: boolean;
1598
1650
  remoteControlEnabled: boolean;
@@ -1604,9 +1656,18 @@ export interface WebRemoteStatus {
1604
1656
  e2eState: 'idle' | 'pending_sas' | 'authenticated' | 'failed';
1605
1657
  /** 6-digit Short Authentication String pending user confirmation, or null. */
1606
1658
  pendingSas: string | null;
1659
+ /** Every connected client's E2E state (no key material). */
1660
+ clients: WebRemoteClientStatus[];
1607
1661
  devices: WebRemoteDevice[];
1608
1662
  }
1609
1663
 
1664
+ export interface WebRemoteClientStatus {
1665
+ key: string;
1666
+ clientId: string | null;
1667
+ state: 'idle' | 'pending_sas' | 'authenticated' | 'failed';
1668
+ pendingSas: string | null;
1669
+ }
1670
+
1610
1671
  export interface WebRemotePairResult {
1611
1672
  ok: boolean;
1612
1673
  deviceId?: string;
@@ -1814,8 +1875,8 @@ export interface SessionManagerAPI {
1814
1875
  writeText: (path: string, text: string, writer?: OpsWriter) => Promise<WriteResult>;
1815
1876
  listDir: (path: string, opts?: { filesOnly?: boolean; dirsOnly?: boolean; includeHidden?: boolean }) => Promise<ListDirResult>;
1816
1877
  exists: (path: string) => Promise<boolean>;
1817
- watch: (paths: string[]) => void;
1818
- unwatch: (paths: string[]) => void;
1878
+ watch: (paths: string[], opts?: { depth?: 0 | 1 | 2 }) => void;
1879
+ unwatch: (paths: string[], opts?: { depth?: 0 | 1 | 2 }) => void;
1819
1880
  onChanged: (handler: (info: ConfigChangedEvent) => void) => () => void;
1820
1881
  parseImports: (path: string) => Promise<{ ok: true; imports: ImportRef[] } | { ok: false; error: string }>;
1821
1882
  };
@@ -1930,6 +1991,8 @@ export interface SessionManagerAPI {
1930
1991
  aggregate: (req?: HistoryAggregateRequest) => Promise<HistoryAggregateResult>;
1931
1992
  scanProjects: () => Promise<SessionScanResult>;
1932
1993
  dashboard: (req: HistoryDashboardRequest) => Promise<HistoryDashboardResult>;
1994
+ /** Fires (throttled to 1/5 s) when main appends days to the rollup. Returns unsubscribe. */
1995
+ onUpdated: (handler: () => void) => () => void;
1933
1996
  };
1934
1997
  schedule: {
1935
1998
  state: () => Promise<ScheduleStateSnapshot>;
@@ -2111,6 +2174,28 @@ export interface SessionManagerAPI {
2111
2174
  * renderer needs per-row badges without a separate git call per file. */
2112
2175
  fileStatus: (cwd: string) => Promise<GitFileStatusMap>;
2113
2176
  };
2177
+ remoteClient: {
2178
+ list: () => Promise<RemoteMachinePeer[]>;
2179
+ connect: (peerId: string) => Promise<{ status: string; reason: string | null; sas: string | null }>;
2180
+ confirmSas: (peerId: string) => Promise<{ ok: boolean; reason?: string }>;
2181
+ remove: (peerId: string) => Promise<{ ok: boolean }>;
2182
+ authStatus: () => Promise<{ paired: boolean; clientId: string | null }>;
2183
+ pair: (code: string, clientName?: string) => Promise<{ ok: boolean; clientId?: string; error?: string }>;
2184
+ unpair: () => Promise<{ ok: boolean }>;
2185
+ devices: () => Promise<{ ok: boolean; devices?: RemoteClientDevice[]; error?: string }>;
2186
+ add: (deviceId: string, machineName: string) => Promise<RemoteMachinePeer>;
2187
+ send: (peerId: string, type: string, payload?: unknown) => Promise<unknown>;
2188
+ onStatus: (handler: (status: RemoteClientStatus) => void) => () => void;
2189
+ onEvent: (handler: (ev: RemoteClientEvent) => void) => () => void;
2190
+ };
2191
+ updater: {
2192
+ status: () => Promise<AutoUpdaterStatus>;
2193
+ check: () => Promise<AutoUpdaterStatus>;
2194
+ install: (force?: boolean) => Promise<{ ok: boolean; error?: string }>;
2195
+ cancelDeferred: () => Promise<AutoUpdaterStatus>;
2196
+ setEnabled: (enabled: boolean) => Promise<AutoUpdaterStatus>;
2197
+ onStatus: (handler: (status: AutoUpdaterStatus) => void) => () => void;
2198
+ };
2114
2199
  webRemote: {
2115
2200
  getStatus: () => Promise<WebRemoteStatus>;
2116
2201
  enable: () => Promise<WebRemoteMutationResult>;
@@ -2129,8 +2214,9 @@ export interface SessionManagerAPI {
2129
2214
  /** Subscribe to the completion event broadcast after revokeAll. */
2130
2215
  onRevokedAll: (handler: (ev: { revokedCount: number }) => void) => () => void;
2131
2216
  /** Confirm that the SAS shown on the desktop matches the browser — marks the
2132
- * E2E session as authenticated and unblocks MUTATE-tier commands. */
2133
- confirmSas: () => Promise<WebRemoteMutationResult>;
2217
+ * E2E session as authenticated and unblocks MUTATE-tier commands. Pass the
2218
+ * client's `key` when several clients are pending (else `ambiguous_pending_sas`). */
2219
+ confirmSas: (clientKey?: string) => Promise<WebRemoteMutationResult>;
2134
2220
  };
2135
2221
  chat: {
2136
2222
  /** Spawn a headless `claude -p` run for a tab. Results arrive via the on* listeners. */
@@ -2150,6 +2236,10 @@ export interface SessionManagerAPI {
2150
2236
  * tool) pushes a prompt into an open tab's queue from outside the
2151
2237
  * renderer (PRD 753). */
2152
2238
  onExternalSend: (handler: (e: ChatExternalSendEvent) => void) => () => void;
2239
+ /** Fires when a paired phone asks main to start a new Session (payload pre-validated in main). */
2240
+ onExternalNewSession: (
2241
+ handler: (e: { cwd: string; agentName: string; tag: AgentPersonaTag; title: string; prompt: string }) => void,
2242
+ ) => () => void;
2153
2243
  /** Classify a queued PromptTicket's text as 'inline' (run through
2154
2244
  * chatRunner) or 'develop' (dispatch to /develop for PRD decomposition).
2155
2245
  * A single bounded `claude -p` call, never a scheduler job. */
@@ -150,8 +150,8 @@ contextBridge.exposeInMainWorld('api', {
150
150
  writeText: (path, text, writer) => ipcRenderer.invoke('config:write-text', { path, text, writer }),
151
151
  listDir: (path, opts) => ipcRenderer.invoke('config:list-dir', { path, opts }),
152
152
  exists: (path) => ipcRenderer.invoke('config:exists', { path }),
153
- watch: (paths) => ipcRenderer.send('config:watch', { paths }),
154
- unwatch: (paths) => ipcRenderer.send('config:unwatch', { paths }),
153
+ watch: (paths, opts) => ipcRenderer.send('config:watch', { paths, opts }),
154
+ unwatch: (paths, opts) => ipcRenderer.send('config:unwatch', { paths, opts }),
155
155
  parseImports: (path) => ipcRenderer.invoke('config:parse-imports', { path }),
156
156
  onChanged: (handler) => {
157
157
  const listener = (_e, info) => handler(info);
@@ -234,6 +234,12 @@ contextBridge.exposeInMainWorld('api', {
234
234
  aggregate: (req) => ipcRenderer.invoke('history:aggregate', req),
235
235
  scanProjects: () => ipcRenderer.invoke('history:scan-projects'),
236
236
  dashboard: (req) => ipcRenderer.invoke('history:dashboard', req),
237
+ // Fired (throttled) after main appends new days to the rollup.
238
+ onUpdated: (handler) => {
239
+ const listener = () => handler();
240
+ ipcRenderer.on('history:updated', listener);
241
+ return () => ipcRenderer.removeListener('history:updated', listener);
242
+ },
237
243
  },
238
244
  files: {
239
245
  list: (path, showHidden) => ipcRenderer.invoke('files:list', { path, showHidden }),
@@ -392,6 +398,42 @@ contextBridge.exposeInMainWorld('api', {
392
398
  status: (cwd) => ipcRenderer.invoke('git:status', { cwd }),
393
399
  fileStatus: (cwd) => ipcRenderer.invoke('git:file-status', { cwd }),
394
400
  },
401
+ remoteClient: {
402
+ /** Paired remote machines merged with live connection status. */
403
+ list: () => ipcRenderer.invoke('remoteClient:list'),
404
+ connect: (peerId) => ipcRenderer.invoke('remoteClient:connect', { peerId }),
405
+ /** Confirm the short authentication string matches the remote machine. */
406
+ confirmSas: (peerId) => ipcRenderer.invoke('remoteClient:confirm-sas', { peerId }),
407
+ remove: (peerId) => ipcRenderer.invoke('remoteClient:remove', { peerId }),
408
+ authStatus: () => ipcRenderer.invoke('remoteClient:auth-status'),
409
+ pair: (code, clientName) => ipcRenderer.invoke('remoteClient:pair', { code, clientName }),
410
+ unpair: () => ipcRenderer.invoke('remoteClient:unpair'),
411
+ devices: () => ipcRenderer.invoke('remoteClient:devices'),
412
+ add: (deviceId, machineName) => ipcRenderer.invoke('remoteClient:add', { deviceId, machineName }),
413
+ send: (peerId, type, payload) => ipcRenderer.invoke('remoteClient:send', { peerId, type, payload }),
414
+ onStatus: (handler) => {
415
+ const listener = (_e, payload) => handler(payload);
416
+ ipcRenderer.on('remoteClient:status', listener);
417
+ return () => ipcRenderer.removeListener('remoteClient:status', listener);
418
+ },
419
+ onEvent: (handler) => {
420
+ const listener = (_e, payload) => handler(payload);
421
+ ipcRenderer.on('remoteClient:event', listener);
422
+ return () => ipcRenderer.removeListener('remoteClient:event', listener);
423
+ },
424
+ },
425
+ updater: {
426
+ status: () => ipcRenderer.invoke('updater:status'),
427
+ check: () => ipcRenderer.invoke('updater:check'),
428
+ install: (force) => ipcRenderer.invoke('updater:install', { force: force === true }),
429
+ cancelDeferred: () => ipcRenderer.invoke('updater:cancel-deferred'),
430
+ setEnabled: (enabled) => ipcRenderer.invoke('updater:set-enabled', { enabled }),
431
+ onStatus: (handler) => {
432
+ const listener = (_e, payload) => handler(payload);
433
+ ipcRenderer.on('updater:status', listener);
434
+ return () => ipcRenderer.removeListener('updater:status', listener);
435
+ },
436
+ },
395
437
  webRemote: {
396
438
  /** Current connection state (no token values). */
397
439
  getStatus: () => ipcRenderer.invoke('webRemote:get-status'),
@@ -423,7 +465,7 @@ contextBridge.exposeInMainWorld('api', {
423
465
  },
424
466
  /** Revoke ALL paired devices and tear down every session immediately. */
425
467
  revokeAll: () => ipcRenderer.invoke('webRemote:revoke-all'),
426
- confirmSas: () => ipcRenderer.invoke('webRemote:confirm-sas'),
468
+ confirmSas: (clientKey) => ipcRenderer.invoke('webRemote:confirm-sas', clientKey ? { clientKey } : undefined),
427
469
  /** Push event when revokeAll completes (main broadcasts webRemote:revoked-all). */
428
470
  onRevokedAll: (handler) => {
429
471
  const listener = (_e, payload) => handler(payload);
@@ -484,6 +526,12 @@ contextBridge.exposeInMainWorld('api', {
484
526
  ipcRenderer.on('chat:external-send', listener);
485
527
  return () => ipcRenderer.removeListener('chat:external-send', listener);
486
528
  },
529
+ /** Fires when a paired phone asks main to start a new Session. */
530
+ onExternalNewSession: (handler) => {
531
+ const listener = (_e, payload) => handler(payload);
532
+ ipcRenderer.on('chat:external-new-session', listener);
533
+ return () => ipcRenderer.removeListener('chat:external-new-session', listener);
534
+ },
487
535
  /** Classify a queued PromptTicket's text as 'inline' or 'develop'. */
488
536
  classifyTicket: (payload) => ipcRenderer.invoke('chat:classify-ticket', payload),
489
537
  /** Author a mechanical draft PRD from a queued PromptTicket classified 'develop'. */
@@ -1,2 +0,0 @@
1
- import{ak as A,aw as y,b0 as de,ah as e,m as U,a as M,aL as k,aI as ce,U as Q,aK as fe,aV as X,M as me,c as G,E as xe}from"./index-3_AtCAyd.js";import{P as he}from"./Panel-CC3JTnOI.js";import{L as pe}from"./ListDetail-YylbvUj_.js";import{B as R}from"./Button-DC6VzovQ.js";import{u as ue}from"./useAgentsDirWatch-1C2CBBya.js";import{r as ge}from"./claude-settings-schema-COigsajx.js";import"./monaco-editor-BsIlgG7c.js";import"./useConfigDirWatch-Cd5PnTkB.js";const ve=n=>{const[s,r]=n.split(".");return Number(s)+(r?Number(r)/100:0)};function be(n){const s=/Effort is supported on ([^.]*?)(?:, with|\.|$)/.exec(n);if(!s)return[];const r=[];for(const d of s[1].split(/,\s*|\s+and\s+/)){const o=/^(\w+)\s+(\d+(?:\.\d+)?)$/.exec(d.trim());o&&r.push({family:o[1].toLowerCase(),version:ve(o[2])})}return r}var J,Y;const je=be(String(((Y=(J=ge.properties)==null?void 0:J.effortLevel)==null?void 0:Y.description)??""));function we(n,s){const r=new RegExp(`${s}-(\\d+)(?:-(\\d{1,2})(?!\\d))?`,"i").exec(n);if(r)return Number(r[1])+(r[2]?Number(r[2])/100:0);const d=new RegExp(`claude-(\\d+)(?:-(\\d{1,2}))?-${s}`,"i").exec(n);return d?Number(d[1])+(d[2]?Number(d[2])/100:0):null}function ye(n,s=je){if(!n||n==="inherit"||s.length===0)return null;const r=A(n);if(!r)return null;const d=s.filter(l=>l.family===r);if(d.length===0)return!1;const o=we(n,r);return o===null?null:o>=Math.min(...d.map(l=>l.version))}const z=["Read","Grep","Glob","Bash","Write","Edit","WebFetch","WebSearch","Task"],Ne=["","red","orange","yellow","green","cyan","blue","purple","pink"],Z={red:"#c0392b",orange:"#b85c34",yellow:"#c9a227",green:"#6f7d52",cyan:"#3f8f8a",blue:"#4a6fa5",purple:"#7a6a8a",pink:"#b45a80"};function W(n){return{name:n.name,description:n.description??"",tools:n.tools,model:n.model??"inherit",effort:n.effort??"inherit",color:n.color??"",tags:n.tags,body:n.body}}const q={name:"new-agent",description:"",tools:["Read","Grep"],model:"inherit",effort:"inherit",color:"",tags:[],body:""},Ce=new Set(Q.map(n=>n.tag));function ke(n){return n.filter(s=>Ce.has(s))}function $e(n){return n.overridingProjects.map(s=>{var o;const r=(o=n.overrideDetails)==null?void 0:o.find(l=>l.project===s);if(!r)return s;const d=[...r.fields.filter(l=>l!=="name"),...r.bodyOverridden?["full body"]:[]];return`${s}: ${d.join(", ")||"overlay"}`}).join(`
2
- `)}function Se(){const[n,s]=y.useState(null),[r,d]=y.useState(null),[o,l]=y.useState(""),[i,m]=y.useState(null),[S,h]=y.useState(!1),[w,v]=y.useState(!1),[N,u]=y.useState(null),[b,j]=y.useState(!1),L=y.useRef(!0);y.useEffect(()=>()=>{L.current=!1},[]);const a=de(t=>{var x;return((x=t.tabs.find(E=>E.id===t.activeTabId))==null?void 0:x.cwd)??null}),g=a?a.replace(/\/+$/,"").split("/").pop()||a:null,C=y.useRef(0),$=async t=>{const x=++C.current;try{const E=await window.api.agents.listPersonas();if(!L.current||C.current!==x)return;s(E),d(V=>{var P;return t??V??((P=E[0])==null?void 0:P.name)??null})}catch(E){if(!L.current||C.current!==x)return;s([]),k.error(E.message||"failed to load agent personas")}};if(y.useEffect(()=>{$()},[]),y.useEffect(()=>window.api.agents.onChanged(()=>$()),[]),ue(a,()=>$()),y.useEffect(()=>{const t=ce();t&&d(t);const x=E=>d(E.detail);return window.addEventListener("sm:select-persona",x),()=>window.removeEventListener("sm:select-persona",x)},[]),n===null)return e.jsx(U,{title:"loading…"});const T=o.toLowerCase(),F=n.filter(t=>!T||t.name.toLowerCase().includes(T)||(t.description??"").toLowerCase().includes(T)),c=n.find(t=>t.name===r)??n[0]??null,f=i??(c?W(c):null),B=!!i&&!!c&&JSON.stringify(i)!==JSON.stringify(W(c)),O=S,I=t=>{m(null),h(!1),v(!1),u(null),d(t)},p=t=>m(x=>({...x??(c?W(c):q),...t})),K=()=>{m({...q}),h(!0),v(!1)},ne=()=>{f&&(m({...f,name:f.name+"-copy"}),h(!0))},se=()=>{m(null),h(!1)},ae=async()=>{if(f){if(!/^[a-z][a-z0-9-]*$/.test(f.name)){k.error('agent name must be lowercase, hyphenated (e.g. "my-agent")');return}j(!0);try{const t=O?null:c,x={name:f.name,originalName:O||c==null?void 0:c.name,description:f.description,tools:f.tools,model:f.model,effort:f.effort,color:f.color,tags:ke(f.tags),projects:(t==null?void 0:t.projects)??void 0,action:(t==null?void 0:t.action)??void 0,actionLabel:(t==null?void 0:t.actionLabel)??void 0,body:f.body};await window.api.agents.savePersona(x),k.info(O?`created ${f.name}`:`saved ${f.name}`),m(null),h(!1),await $(f.name)}catch(t){k.error(t.message||"failed to save agent persona")}finally{j(!1)}}},oe=async()=>{if(c){j(!0);try{await window.api.agents.deletePersona({name:c.name}),k.info(`deleted ${c.name}`),v(!1),m(null),h(!1),await $()}catch(t){k.error(t.message||"failed to delete agent persona")}finally{j(!1)}}},re=async t=>{j(!0);try{await window.api.agents.deletePersona({name:t}),k.info(`deleted ${t}`),u(null),r===t&&(m(null),h(!1)),await $()}catch(x){k.error(x.message||"failed to delete agent persona")}finally{j(!1)}},ie=async t=>{if(c)try{await window.api.agents.removeOverride({name:c.name,projectName:t}),k.info(`removed ${t}'s override of ${c.name}`),await $(c.name)}catch(x){k.error(x.message||"failed to remove override")}},le=async t=>{if(!(!c||!g)){j(!0);try{t.model==="inherit"&&t.effort==="inherit"?(await window.api.agents.removeOverride({name:c.name,projectName:g}),k.info(`cleared ${g}'s override of ${c.name}`)):(await window.api.agents.savePersona({name:c.name,projectName:g,description:"",tools:[],color:"",tags:[],body:"",model:t.model,effort:t.effort}),k.info(`saved ${g}'s override of ${c.name}`)),await $(c.name)}catch(x){k.error(x.message||"failed to save project override")}finally{j(!1)}}};return e.jsx(he,{toolbar:e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-fg-faint",children:[n.length," persona",n.length===1?"":"s"]}),e.jsx("input",{value:o,onChange:t=>l(t.target.value),placeholder:"filter…",className:"bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg w-40"}),e.jsx("div",{className:"flex-1"}),e.jsx(R,{variant:"primary",onClick:K,children:"+ New agent"})]}),children:e.jsx(pe,{sidebar:e.jsxs("div",{className:"py-1",children:[O&&e.jsx("div",{className:"w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 bg-bg-hi text-fg border-l-2 border-accent",children:e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsx("span",{className:"truncate font-mono",children:f==null?void 0:f.name}),e.jsx("span",{className:"shrink-0 text-[10px] font-semibold text-accent",children:"new"})]})}),F.length===0&&!O?e.jsx("div",{className:"px-3 py-1 text-xs text-fg-faint italic",children:"no agent personas found"}):F.map(t=>{const x=!O&&t.name===r,E=x&&B,V=N===t.name;return e.jsxs("div",{"data-agent-row":t.name,className:`group w-full text-left px-3 py-1 text-xs flex flex-col gap-0.5 border-l-2 cursor-pointer ${x?"bg-bg-hi text-fg border-accent":"text-fg-dim hover:text-fg hover:bg-bg-hi border-transparent"}`,onClick:()=>I(t.name),children:[e.jsxs("span",{className:"flex items-center gap-2 justify-between w-full",children:[e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:t.color?Z[t.color]??t.color:"var(--fg-faint, #999)",opacity:t.color?1:.35}}),e.jsx("span",{className:"truncate font-mono",children:t.name})]}),e.jsxs("span",{className:"shrink-0 flex items-center gap-1.5",children:[E&&e.jsx("span",{className:"text-[10px] font-semibold text-accent",children:"unsaved"}),!E&&t.overridingProjects.length>0&&e.jsx("span",{title:$e(t),children:e.jsxs(M,{tone:"dim",children:[t.overridingProjects.length," override",t.overridingProjects.length>1?"s":""]})}),V?e.jsxs("span",{className:"flex items-center gap-1",onClick:P=>P.stopPropagation(),children:[e.jsx("button",{onClick:()=>re(t.name),disabled:b,title:`Delete ${t.name}`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),e.jsx("button",{onClick:()=>u(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):e.jsx("button",{onClick:P=>{P.stopPropagation(),u(t.name)},title:`Delete ${t.name}`,className:"opacity-0 group-hover:opacity-100 text-fg-faint hover:text-red-400 transition-opacity",children:"×"})]})]}),t.description&&e.jsx("span",{className:"truncate text-fg-faint",children:t.description})]},t.name)})]}),detail:f?e.jsx(Le,{obj:f,set:p,saved:c,dirty:B,isNew:O,busy:b,confirmDelete:w,setConfirmDelete:v,onDuplicate:ne,onRevert:se,onSave:ae,onDelete:oe,onDropOverride:ie,activeProject:g,onSaveOverride:le}):e.jsx(U,{title:"select an agent"})})})}const Me=y.memo(Se);function Le({obj:n,set:s,saved:r,dirty:d,isNew:o,busy:l,confirmDelete:i,setConfirmDelete:m,onDuplicate:S,onRevert:h,onSave:w,onDelete:v,onDropOverride:N,activeProject:u,onSaveOverride:b}){const j=`~/.claude/agents/${n.name}.md`,L=d||o;return e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-line flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-fg font-mono",children:n.name}),o?e.jsx(M,{tone:"accent",children:"unsaved draft"}):d?e.jsx(M,{tone:"warn",children:"edited"}):e.jsx(M,{tone:"good",children:"saved"}),e.jsx("span",{className:"ml-auto text-[11px] text-fg-faint font-mono",children:j})]}),e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(D,{label:"name",hint:"Filename on disk — lowercase, hyphenated.",children:e.jsx("input",{value:n.name,onChange:a=>s({name:a.target.value.toLowerCase()}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg font-mono"})}),e.jsx(D,{label:"description",hint:"Shown in the list and in agent pickers.",children:e.jsx("input",{value:n.description,onChange:a=>s({description:a.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1 text-xs text-fg"})}),e.jsx(ee,{value:n.model,onChange:a=>s({model:a})}),e.jsx(te,{value:n.effort,model:n.model,onChange:a=>s({effort:a})}),!o&&r&&e.jsx(Ee,{saved:r,activeProject:u,busy:l,onSave:b}),e.jsx(D,{label:"tools",hint:`${n.tools.length} of ${z.length} granted. Anything not ticked is refused at call time.`,children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:z.map(a=>{const g=n.tools.includes(a);return e.jsx("button",{onClick:()=>s({tools:g?n.tools.filter(C=>C!==a):[...n.tools,a]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${g?"bg-sage/15 text-sage-dark border-sage/30":"bg-bg-hi text-fg-faint border-line"}`,children:a},a)})})}),e.jsx(D,{label:"color",children:e.jsx("div",{className:"flex gap-1.5",children:Ne.map(a=>e.jsx("button",{title:a||"none",onClick:()=>s({color:a}),className:"w-5 h-5 rounded",style:{background:a?Z[a]:"transparent",border:n.color===a?"2px solid var(--accent, #b85c34)":"1px solid var(--line, #555)"}},a||"none"))})}),e.jsx(D,{label:"tags",hint:"Session mission tags this persona is associated with — shown as the default agent on that tag's own page. The first one (in Tag Library order) is the MISSION an Action button's session opens with.",children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Q.map(a=>{const g=n.tags.includes(a.tag),C=fe(a.tag);return e.jsxs("button",{onClick:()=>s({tags:g?n.tags.filter($=>$!==a.tag):[...n.tags,a.tag]}),className:`px-2 py-0.5 rounded-full text-[11px] font-mono border ${g?`${C.bg} ${C.text} ${C.border?"border-current/30":"border-transparent"}`:"bg-bg-hi text-fg-faint border-line"}`,children:["#",a.tag]},a.tag)})})}),e.jsx(D,{label:"definition",hint:"The system prompt this persona runs under.",children:e.jsx("textarea",{rows:9,value:n.body,onChange:a=>s({body:a.target.value}),className:"w-full bg-bg border border-line rounded px-2 py-1.5 text-xs text-fg font-mono leading-relaxed resize-y"})}),e.jsx(D,{label:"project overrides",hint:"Open projects that shadow this definition with a local copy.",children:r&&r.overridingProjects.length>0?e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.overridingProjects.map(a=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 bg-bg-elev border border-line rounded px-2 py-0.5 text-[11px] font-mono text-fg-dim",children:[a,e.jsx("button",{onClick:()=>N(a),title:"Drop the local copy",className:"text-fg-faint hover:text-fg",children:"×"})]},a))}):e.jsx("div",{className:"text-xs text-fg-faint italic",children:o?"save first to see project overrides.":"no open project overlays this agent — the global definition applies everywhere."})})]}),e.jsx("div",{className:"px-4 py-2.5 border-t border-line flex items-center gap-2 flex-wrap",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-fg-dim",children:["Delete ",e.jsx("strong",{className:"font-mono",children:n.name})," and its file?"]}),e.jsx(R,{variant:"danger",onClick:v,disabled:l,children:"Delete"}),e.jsx(R,{onClick:()=>m(!1),children:"Keep"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{onClick:S,disabled:l,children:"Duplicate"}),!o&&e.jsx(R,{variant:"danger",onClick:()=>m(!0),disabled:l,children:"Delete"}),e.jsx("div",{className:"flex-1"}),L&&e.jsx("span",{className:"text-[11px] text-fg-faint",children:"unsaved changes"}),e.jsx(R,{onClick:h,disabled:!L||l,children:"Revert"}),e.jsx(R,{variant:"primary",onClick:w,disabled:!L||l,children:l?"Saving…":o?"Create":"Save"})]})})]})}function D({label:n,hint:s,children:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-fg-faint mb-1.5 font-mono",children:n}),r,s&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug",children:s})]})}const _="latest",H="Blocked by the availableModels allowlist in your Claude settings";function ee({value:n,onChange:s,label:r="default model",hint:d,testIdPrefix:o="",inheritLabel:l}){var O,I;const{catalog:i,loading:m,degraded:S,refresh:h}=X(null),w=i?["inherit",...i.aliases]:[...me],v=(i==null?void 0:i.availableModels)??null,N=p=>!!v&&p!=="inherit"&&!v.includes(p),u=(p,K)=>!!v&&!v.includes(p)&&!(K&&v.includes(K)),b=n||"inherit",j=((O=/\[[^\]]*\]$/.exec(b))==null?void 0:O[0])??"",L=w.includes(b),a=!L&&i&&A(b)&&w.includes(A(b)+j)?A(b)+j:null,g=L?b:a??b,C=A(g),$=((I=/\[[^\]]*\]$/.exec(g))==null?void 0:I[0])??"",T=!!i&&b!=="inherit"&&!!C&&w.includes(g),F=T?i.models.filter(p=>A(p)===C).map(p=>p+$):[],c=L?_:b,f={};if(i)for(const p of w)N(p)&&(f[p]=H);const B={};for(const p of F)u(p,C)&&(B[p]=H);return e.jsxs(D,{label:r,hint:d??"This persona's default model for its Epics — sets the --model an Epic launches with (Terminal + Chat both honor it). 'inherit' falls back to each view's own default, not this Settings page. Cheap models for read-only personas; opus for judgement calls.",children:[e.jsx("div",{"data-testid":`${o}model-row`,children:e.jsx(G,{options:w,value:g,onChange:s,mono:!0,blocked:f,labels:l?{inherit:l}:void 0})}),T&&e.jsxs("div",{className:"mt-2","data-testid":`${o}model-version-row`,children:[e.jsx("div",{className:"text-[10.5px] text-fg-faint mb-1 font-mono",children:"version"}),e.jsx(G,{options:[_,...F],value:c,onChange:p=>s(p===_?g:p),mono:!0,blocked:B})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint mt-1 leading-snug flex items-center gap-2",children:[e.jsx("span",{children:i?`Models are live-read from the installed claude CLI${S?" (cached — CLI probe unavailable)":""}. "latest" keeps the floating alias.`:m?"Loading model catalog…":"catalog unavailable — showing the standard list."}),e.jsx("button",{"data-testid":`${o}model-catalog-refresh`,onClick:()=>{h()},disabled:m,className:"underline text-fg-dim disabled:opacity-40",children:"refresh"})]})]})}function te({value:n,model:s,onChange:r,label:d="effort",testIdPrefix:o="",inheritLabel:l}){const{catalog:i}=X(null),m=i&&i.effortLevels.length?["inherit",...i.effortLevels]:[...xe],S=(i==null?void 0:i.settingsEffortLevels)??[],h=i?m.filter(N=>N!=="inherit"&&!S.includes(N)):[],w=n||"inherit",v=w!=="inherit"&&ye(s)===!1;return e.jsxs(D,{label:d,hint:i?`Effort levels are live-read from the installed claude CLI (what /effort accepts). ${h.length?`${h.join(", ")} ${h.length>1?"are":"is"} session-only — settings.json accepts ${S.join(", ")}. `:""}'inherit' writes no effort: line.`:"catalog unavailable — showing the standard list. 'inherit' writes no effort: line.",children:[e.jsx("div",{"data-testid":`${o}effort-row`,children:e.jsx(G,{options:m,value:w,onChange:r,mono:!0,labels:l?{inherit:l}:void 0})}),h.length>0&&e.jsx("div",{className:"text-[11px] text-fg-faint mt-1 font-mono","data-testid":`${o}effort-session-only`,children:h.map(N=>`${N} (session-only)`).join(" · ")}),v&&e.jsx("div",{className:"text-[11px] text-amber-400 mt-1 leading-snug","data-testid":`${o}effort-unsupported-note`,children:"The selected model does not support effort — the CLI will ignore this setting."})]})}function Ee({saved:n,activeProject:s,busy:r,onSave:d}){var w,v,N;if(!s)return e.jsxs("div",{"data-testid":"project-override-none",className:"border border-dashed border-line rounded p-3 text-[11px] text-fg-faint",children:[e.jsx("div",{className:"text-[10.5px] font-semibold uppercase tracking-wide mb-1 font-mono",children:"project override"}),"No active project — open a project tab to override this persona's model or effort for that project only."]});const o=(w=n.overrideDetails)==null?void 0:w.find(u=>u.project===s),l=!!(o!=null&&o.bodyOverridden),i=((v=o==null?void 0:o.values)==null?void 0:v.model)??"inherit",m=((N=o==null?void 0:o.values)==null?void 0:N.effort)??"inherit",S=n.model??"inherit",h=n.effort??"inherit";return e.jsxs("div",{"data-testid":"project-override",className:"border border-accent/40 rounded p-3 space-y-3 bg-accent/5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-wide text-accent font-mono",children:"project override"}),e.jsxs(M,{tone:"accent",children:[s," only"]}),e.jsx("span",{className:"ml-auto text-[11px] text-fg-faint font-mono",children:`<project>/.claude/agents/${n.name}.md`})]}),e.jsxs("div",{className:"text-[11px] text-fg-faint leading-snug",children:["Changes what the SCHEDULER (and new Epics) spawn for ",e.jsx("strong",{children:s})," only — a frontmatter-only overlay with just the keys you set; the persona's body stays the global one. The global model/effort rows edit the machine-wide persona and are never touched here."]}),l&&e.jsxs("div",{"data-testid":"project-override-fullbody",className:"text-[11px] text-amber-400 leading-snug",children:[s,' already has a FULL-BODY override of this persona (its own definition text). It is shown as-is and not converted to a frontmatter-only overlay — edit that file directly, or drop it with × under "project overrides" below.']}),e.jsxs("fieldset",{disabled:r||l,className:"space-y-3 border-0 p-0 m-0 min-w-0",children:[e.jsx(ee,{value:i,onChange:u=>{l||d({model:u,effort:m})},label:"project model",hint:"'use global' writes no model: line in the overlay.",testIdPrefix:"override-",inheritLabel:"use global"}),e.jsx(te,{value:m,model:i!=="inherit"?i:S,onChange:u=>{l||d({model:i,effort:u})},label:"project effort",testIdPrefix:"override-",inheritLabel:"use global"})]}),e.jsx("div",{"data-testid":"override-provenance",className:"text-[11px] font-mono text-fg-dim space-y-0.5",children:[["model",S,i],["effort",h,m]].map(([u,b,j])=>e.jsxs("div",{"data-testid":`override-provenance-${u}`,children:[u,": ",j!=="inherit"?e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global)"})," → ",e.jsx("span",{className:"text-accent",children:j})," ",e.jsx("span",{className:"text-fg-faint",children:"(this project)"})]}):e.jsxs(e.Fragment,{children:[b," ",e.jsx("span",{className:"text-fg-faint",children:"(global — not overridden)"})]})]},u))})]})}export{Me as AgentLibrary};
@@ -1 +0,0 @@
1
- import{aw as d,i as j,ai as $,a1 as g,ah as e,m as N,al as E,a2 as b,aA as S,a as p,Y as T,j as v,h as D}from"./index-3_AtCAyd.js";import{P as R}from"./Panel-CC3JTnOI.js";import{V}from"./ViewTabs-T0NBc8uv.js";import"./monaco-editor-BsIlgG7c.js";const C=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function G(){const[s,t]=d.useState("diagram"),[a,i]=d.useState(null),[l,n]=d.useState(()=>new Set),c=d.useMemo(()=>j.filter(r=>!l.has(r.group)),[l]),m=d.useMemo(()=>$(c),[c]),o=r=>{n(x=>{const h=new Set(x);return h.has(r)?h.delete(r):h.add(r),h}),i(null)},u=a?g(a):null,y=r=>c.some(x=>x.id===r);return e.jsx(R,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(V,{options:C,active:s,onChange:t}),e.jsx(M,{hiddenGroups:l,onToggle:o}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[j.length," entities"]})]}),children:s==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(O,{layout:m,selectedId:a,onSelect:r=>i(x=>x===r?null:r)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:u?e.jsx(F,{entity:u,onSelectRelated:r=>y(r)?i(r):void 0}):e.jsx(N,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(P,{})})}const X=d.memo(G);function M({hiddenGroups:s,onToggle:t}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:v.map(a=>{const i=s.has(a.id);return e.jsxs("button",{onClick:()=>t(a.id),title:`${a.blurb} (${a.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${i?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${a.tone.dot}`}),a.label,e.jsx("span",{className:"text-fg-faint",children:a.realm})]},a.id)})})}function O({layout:s,selectedId:t,onSelect:a}){const i=d.useMemo(()=>t?new Set(E(t)):null,[t]),l=n=>!!t&&(n.relation.from===t||n.relation.to===t);return s.boxes.length===0?e.jsx(N,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:s.width+32,height:s.height+32},children:[e.jsxs("svg",{width:s.width,height:s.height,className:"absolute left-4 top-4 overflow-visible",children:[s.edges.map(n=>{const c=l(n);return e.jsx("path",{"data-testid":`erd-edge-${n.relation.from}-${n.relation.to}`,d:n.d,fill:"none",className:c?"stroke-accent":"stroke-line",strokeWidth:c?2:1,opacity:t&&!c?.25:1},`${n.relation.from}-${n.relation.to}-${n.relation.label}`)}),s.edges.map(n=>l(n)?e.jsx("text",{x:n.mx,y:n.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:n.relation.label},`label-${n.relation.from}-${n.relation.to}-${n.relation.label}`):null)]}),s.boxes.map(n=>e.jsx(_,{box:n,selected:n.id===t,dimmed:!!t&&n.id!==t&&!(i!=null&&i.has(n.id)),onClick:()=>a(n.id)},n.id))]})}function _({box:s,selected:t,dimmed:a,onClick:i}){const l=g(s.id),n=b(s.group),c=l.fields.slice(0,D),m=l.fields.length-c.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${s.id}`,onClick:i,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${t?"border-accent ring-1 ring-accent":"border-line"} ${a?"opacity-30":""}`,style:{left:s.x,top:s.y,width:s.w,height:s.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${n.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:l.name})]}),l.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:l.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[c.map(o=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[o.key&&e.jsx("span",{className:"text-fg-faint",children:o.key}),e.jsx("span",{className:"truncate",children:o.name})]},o.name)),m>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",m," more"]})]})]})}function w({fields:s}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[t.name,t.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:t.type}),e.jsx("td",{className:"px-2 py-1",children:t.key&&e.jsxs(p,{tone:t.key==="pk"?"accent":"dim",children:[t.key,t.ref?` → ${t.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:t.note})]},t.name))})]})}function k({entity:s}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:s.store.format})]}),s.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(p,{tone:"accent",children:["single-writer: ",s.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:s.store.definedIn})]})]})}function F({entity:s,onSelectRelated:t}){const a=b(s.group),i=S(s.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${a.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:s.name})]}),s.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:s.aka}),e.jsx(p,{tone:"dim",className:"mt-1",children:a.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:s.summary}),e.jsxs("div",{children:[e.jsx(f,{children:"storage"}),e.jsx(k,{entity:s})]}),e.jsxs("div",{children:[e.jsx(f,{children:"fields"}),e.jsx(w,{fields:s.fields})]}),s.notes&&s.notes.length>0&&e.jsxs("div",{children:[e.jsx(f,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:s.notes.map(l=>e.jsx("li",{children:l},l))})]}),e.jsxs("div",{children:[e.jsx(f,{children:"relations"}),i.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:i.map(l=>{const n=l.from===s.id?l.to:l.from,c=g(n);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:T(l.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:l.label}),l.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",l.via]}),e.jsx("button",{type:"button",onClick:()=>t(n),className:"ml-auto text-accent hover:underline font-mono",children:c.name})]},`${l.from}-${l.to}-${l.label}`)})})]})]})}function f({children:s}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:s})}function P(){return e.jsx("div",{className:"p-4 space-y-6",children:v.map(s=>{const t=j.filter(a=>a.group===s.id);return t.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${s.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:s.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:s.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:t.map(a=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:a.name}),a.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:a.aka})]}),e.jsx(p,{tone:"dim",className:"mt-1",children:s.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:a.summary}),e.jsx(k,{entity:a}),e.jsx(w,{fields:a.fields}),a.notes&&a.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:a.notes.map(i=>e.jsx("li",{children:i},i))})]},a.id))})]},s.id)})})}export{X as DataModel};
@@ -1,2 +0,0 @@
1
- import{ar as xe,az as Le,b7 as Ie,ah as e,aw as m,aL as q,as as A,at as W,aU as We,b0 as Ne,am as ze,aT as Ke,m as Ge}from"./index-3_AtCAyd.js";import{P as Ye}from"./Panel-CC3JTnOI.js";import"./monaco-editor-BsIlgG7c.js";function re(){return{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0}}function we(t,s){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd}function Ve(t){return t.promptCount>0||t.sessionCount>0||t.toolCallCount>0||t.inputTokens>0||t.outputTokens>0}function Xe(t,s){const n=s===null,c=[],o=re(),r={};let a=0;for(const l of t.days){const u=re();let d=!1;for(const[i,x]of Object.entries(l.byProject))if(!(!n&&!s.has(i))){we(u,x),we(o,x),Ve(x)&&(d=!0);for(const[f,v]of Object.entries(x.byModel)){const C=r[f]??(r[f]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});C.inputTokens+=v.inputTokens,C.outputTokens+=v.outputTokens,C.cacheReadTokens+=v.cacheReadTokens,C.cacheCreationTokens+=v.cacheCreationTokens,C.costUsd+=v.costUsd,v.estimated&&(C.estimated=!0)}}d&&(a+=1),c.push({date:l.date,totals:u})}return{days:c,totals:o,prevTotals:n?t.prevTotals:re(),prevAvailable:n,byModelTotals:r,activeDays:a}}function Ue(t,s){if(!s)return{pct:null,direction:"flat"};const n=(t-s)/s*100,c=n>0?"up":n<0?"down":"flat";return{pct:n,direction:c}}function Qe(t,s,n){return s<=0?0:t/s*n}const Ee={in:"In tokens",out:"Out tokens",total:"Total tokens",prompts:"Prompts",sessions:"Sessions",time:"Time",spend:"Spend"};function R(t,s){const n=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens;switch(s){case"in":return n;case"out":return t.outputTokens;case"total":return n+t.outputTokens;case"prompts":return t.promptCount;case"sessions":return t.sessionCount;case"time":return t.activeMinutes;case"spend":return t.estimatedCostUsd}}function Ze(t,s){const n=R(t.totals,s),c=t.prevAvailable?Ue(n,R(t.prevTotals,s)):null,o=t.days.map(r=>R(r.totals,s));return{value:n,delta:c,series:o}}function Me(t,s){const n=new Map,c=Math.ceil(t.length/2);t.forEach((a,l)=>{for(const[u,d]of Object.entries(a.byProject)){let i=n.get(u);i||(i={totals:{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0},toolBreakdown:{},firstHalf:0,secondHalf:0},n.set(u,i)),i.totals.promptCount+=d.promptCount,i.totals.inputTokens+=d.inputTokens,i.totals.outputTokens+=d.outputTokens,i.totals.cacheReadTokens+=d.cacheReadTokens,i.totals.cacheCreationTokens+=d.cacheCreationTokens,i.totals.toolCallCount+=d.toolCallCount,i.totals.sessionCount+=d.sessionCount,i.totals.errorCount+=d.errorCount,i.totals.activeMinutes+=d.activeMinutes,i.totals.estimatedCostUsd+=d.estimatedCostUsd;for(const[f,v]of Object.entries(d.toolBreakdown))i.toolBreakdown[f]=(i.toolBreakdown[f]??0)+v;const x=R(d,s);l<c?i.firstHalf+=x:i.secondHalf+=x}});const o=Array.from(n.entries()).map(([a,l])=>{let u="",d=-1;for(const[i,x]of Object.entries(l.toolBreakdown))x>d&&(d=x,u=i);return{projectDir:a,value:R(l.totals,s),sharePct:0,trend:Ue(l.secondHalf,l.firstHalf),sessions:l.totals.sessionCount,topTool:u}}),r=o.reduce((a,l)=>a+l.value,0);for(const a of o)a.sharePct=r>0?a.value/r*100:0;return o.sort((a,l)=>l.value-a.value)}const qe=["date","cost_usd","input_tokens","output_tokens","cache_write_tokens","cache_read_tokens","total_tokens","cache_hit_pct","num_models","top_model"];function Je(t){return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function Se(t){return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreationTokens}function et(t){const s=t.map(n=>{const c=n.inputTokens+n.outputTokens+n.cacheCreationTokens+n.cacheReadTokens,o=n.inputTokens+n.cacheReadTokens+n.cacheCreationTokens,r=o>0?n.cacheReadTokens/o*100:0,a=Object.entries(n.byModel).filter(([,i])=>Se(i)>0);let l="",u=-1;for(const[i,x]of a){const f=Se(x);f>u&&(u=f,l=i)}return[n.date,n.costUsd.toFixed(4),String(n.inputTokens),String(n.outputTokens),String(n.cacheCreationTokens),String(n.cacheReadTokens),String(c),r.toFixed(1),String(a.length),l?xe(l):""].map(Je).join(",")});return[qe.join(","),...s].join(`
2
- `)}const tt={folderCount:0,sessionCount:0,promptCount:0,estimatedCostUsd:0,totalTokens:0};function st(t,s){t.promptCount+=s.promptCount,t.inputTokens+=s.inputTokens,t.outputTokens+=s.outputTokens,t.cacheReadTokens+=s.cacheReadTokens,t.cacheCreationTokens+=s.cacheCreationTokens,t.toolCallCount+=s.toolCallCount,t.sessionCount+=s.sessionCount,t.errorCount+=s.errorCount,t.activeMinutes+=s.activeMinutes,t.estimatedCostUsd+=s.estimatedCostUsd;for(const[n,c]of Object.entries(s.toolBreakdown??{}))t.toolBreakdown[n]=(t.toolBreakdown[n]??0)+c;for(const[n,c]of Object.entries(s.byModel??{})){const o=t.byModel[n]??(t.byModel[n]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});o.inputTokens+=c.inputTokens,o.outputTokens+=c.outputTokens,o.cacheReadTokens+=c.cacheReadTokens,o.cacheCreationTokens+=c.cacheCreationTokens,o.costUsd+=c.costUsd,c.estimated&&(o.estimated=!0)}}function nt(t,s){const n={};for(const[c,o]of Object.entries(t.byModel??{}))n[c]={...o};return{...t,projectDir:s,toolBreakdown:{...t.toolBreakdown??{}},byModel:n}}function ot(t,s){const n={...tt},c=new Set,o=t.map(r=>{const a={};for(const[l,u]of Object.entries(r.byProject)){const d=s[l];if(!d){c.add(l),n.sessionCount+=u.sessionCount,n.promptCount+=u.promptCount,n.estimatedCostUsd+=u.estimatedCostUsd,n.totalTokens+=u.inputTokens+u.outputTokens;continue}const i=a[d];i?st(i,u):a[d]=nt(u,d)}return{...r,byProject:a}});return n.folderCount=c.size,{days:o,excluded:n}}function at(t){return t.folderCount>0}function ct(t){const s=[`${t.folderCount} transcript folder${t.folderCount===1?"":"s"} with no resolvable working directory`];return t.sessionCount&&s.push(`${t.sessionCount.toLocaleString()} sessions`),t.promptCount&&s.push(`${t.promptCount.toLocaleString()} prompts`),t.estimatedCostUsd>=.005&&s.push(`$${t.estimatedCostUsd.toFixed(2)}`),`Excluded: ${s.join(" · ")}`}async function he(){return(await Le()).history??{}}let $e=Promise.resolve();function ue(t){const s=$e.then(async()=>{const n=await he();await Ie({history:{...n,...t}})});return $e=s.catch(()=>{}),s}const rt=["in","out","total","prompts","sessions","time","spend"],it=[{value:30,label:"30d"},{value:60,label:"60d"},{value:90,label:"90d"},{value:0,label:"All time"}];function Re({value:t,options:s,onChange:n}){return e.jsx("div",{className:"flex gap-0.5 p-0.5 rounded bg-bg-elev shadow-[inset_0_0_0_1px_rgba(0,0,0,0.06)] text-[11px]",children:s.map(c=>e.jsx("button",{onClick:()=>n(c.value),className:`px-2 py-1 rounded whitespace-nowrap font-mono ${t===c.value?"bg-bg-hi text-fg shadow-sm":"text-fg-faint hover:text-fg"}`,children:c.label},String(c.value)))})}function lt({measure:t,onMeasure:s,range:n,onRange:c,projectsShown:o,projectsTotal:r,fromDate:a,toDate:l,onRefresh:u,onExport:d,exportDisabled:i}){return e.jsxs("div",{className:"sticky top-0 z-10 border-b border-line px-4 py-2.5 flex flex-wrap items-center gap-3 backdrop-blur-sm",style:{backgroundColor:"rgba(246,239,225,0.93)"},children:[e.jsx(Re,{value:t,options:rt.map(x=>({value:x,label:Ee[x]})),onChange:s}),e.jsx(Re,{value:n,options:it,onChange:c}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[o," / ",r," projects"]}),e.jsxs("span",{className:"text-[11px] text-fg-faint font-mono",children:[a," → ",l]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:u,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint",title:"Re-fetch the rollup (no scan)",children:"↻ Refresh"}),e.jsx("button",{onClick:d,disabled:i,className:"px-2 py-1 text-[11px] border border-line rounded hover:text-fg hover:bg-bg-hi text-fg-faint disabled:opacity-40 disabled:pointer-events-none",children:"Export CSV"})]})}function E(t){const s=Number.isFinite(t)?t:0,n=Math.abs(s)<1?4:2;return`$${s.toFixed(n)}`}function z(t){const s=Number.isFinite(t)?t:0,n=Math.abs(s);return n>=1e9?`${(s/1e9).toFixed(1)}B`:n>=1e6?`${(s/1e6).toFixed(1)}M`:n>=1e3?`${(s/1e3).toFixed(1)}K`:`${Math.round(s)}`}function K(t){const s=Number.isFinite(t)?t:0;return Math.round(s).toLocaleString("en-US")}function Pe(t){const s=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(s<60)return`${s}m`;const n=Math.floor(s/60),c=s%60;return c===0?`${n}h`:`${n}h ${c}m`}function Fe(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}const M="rounded-card bg-bg-hi border border-line",dt="#ded2bd",ut="#6f7d52";function D({kicker:t,title:s,right:n}){return e.jsxs("div",{className:"flex items-baseline justify-between gap-3 mb-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10.5px] uppercase tracking-wider text-accent font-mono",children:t}),e.jsx("h2",{className:"font-serif text-[25px] leading-tight tracking-tight text-fg",children:s})]}),n]})}function J(t,s){switch(t){case"spend":return E(s);case"in":case"out":case"total":return z(s);case"time":return Pe(s);default:return K(s)}}function pt({measure:t,headline:s,activeDays:n,projectsTouched:c,totalSessions:o}){const r=n>0?s.value/n:0,a=o>0?s.value/o:0,{delta:l}=s,u=l&&(t==="spend"?l.direction==="down":l.direction==="up"),d=l&&l.direction!=="flat"&&(t==="spend"?l.direction==="up":l.direction==="down"),i=u?"text-delta-good":d?"text-delta-bad":"text-fg-faint";return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"01 · overview",title:Ee[t]}),e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[52px] leading-none font-mono tracking-tight text-fg",children:J(t,s.value)}),l?e.jsxs("div",{className:`text-xs font-mono mt-2 ${i}`,children:[l.direction==="up"?"▲":l.direction==="down"?"▼":"·"," ",Fe(Math.abs(l.pct??0))," vs prior period"]}):e.jsx("div",{className:"text-xs text-fg-faint mt-2",children:"no prior window to compare"})]}),e.jsx("div",{className:"flex-1 min-w-0 self-stretch",children:e.jsx(xt,{series:s.series})})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3 mt-4 pt-3 border-t border-line",children:[e.jsx(Z,{label:"per active day",value:J(t,r)}),e.jsx(Z,{label:"per session",value:J(t,a)}),e.jsx(Z,{label:"active days",value:K(n)}),e.jsx(Z,{label:"projects touched",value:K(c)})]})]})}function Z({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg-dim",children:s})]})}function xt({series:t}){if(t.length<2)return null;const c=Math.max(...t,0),o=Math.min(...t,0),r=c-o||1,a=160/(t.length-1),l=t.map((d,i)=>`${i*a},${48-(d-o)/r*48}`).join(" "),u=`0,48 ${l} 160,48`;return e.jsxs("svg",{viewBox:"0 0 160 48",preserveAspectRatio:"none",className:"w-full h-full min-h-[48px]",children:[e.jsx("polygon",{points:u,fill:"#b85c34",opacity:.15}),e.jsx("polyline",{points:l,fill:"none",stroke:"#b85c34",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"})]})}const ht=50;function ft({days:t}){const[s,n]=m.useState(ht),c=m.useRef(!1);m.useEffect(()=>{let d=!1;return he().then(i=>{d||c.current||typeof i.budgetCapUsd=="number"&&Number.isFinite(i.budgetCapUsd)&&i.budgetCapUsd>0&&n(i.budgetCapUsd)}),()=>{d=!0}},[]);const o=d=>{c.current=!0;const i=s;n(d),ue({budgetCapUsd:d}).catch(()=>{n(i),q.error("Couldn't save the budget cap — reverted.")})},{mtdSpend:r,projectedSpend:a}=m.useMemo(()=>{const d=new Date,i=d.toLocaleDateString("en-CA").slice(0,7),x=new Date(d.getFullYear(),d.getMonth()+1,0).getDate(),f=d.getDate();let v=0;for(const C of t)if(C.date.startsWith(i))for(const S of Object.values(C.byProject))v+=S.estimatedCostUsd;return{mtdSpend:v,projectedSpend:Qe(v,f,x)}},[t]),l=a>s,u=s>0?Math.min(100,r/s*100):0;return e.jsxs("div",{className:`${M} p-3`,children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"text-[10.5px] uppercase tracking-wider text-fg-faint font-mono",children:"Monthly budget"}),e.jsxs("label",{className:"flex items-center gap-1.5 text-[10px] text-fg-faint",children:["cap",e.jsx("span",{children:"$"}),e.jsx("input",{type:"number",min:1,step:1,value:s,onChange:d=>{const i=Number(d.target.value);Number.isFinite(i)&&i>0&&o(i)},className:"w-16 bg-bg border border-line rounded px-1.5 py-0.5 text-xs text-fg font-mono"})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono mb-1.5",children:[e.jsxs("span",{className:"text-fg",children:[E(r)," ",e.jsx("span",{className:"text-fg-faint",children:"month-to-date"})]}),e.jsxs("span",{className:l?"text-delta-bad":"text-fg-dim",children:[E(a)," ",e.jsx("span",{className:"text-fg-faint",children:"projected"})]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:`h-full ${l?"bg-delta-bad":"bg-sage"}`,style:{width:`${Math.max(u,u>0?2:0)}%`}})}),e.jsx("div",{className:`text-[10px] mt-1 font-mono ${l?"text-delta-bad":"text-fg-faint"}`,children:l?`projected to exceed $${s.toFixed(0)} cap`:`${u.toFixed(0)}% of $${s.toFixed(0)} cap`})]})}function mt({chips:t,keep:s,onToggle:n,onIsolate:c,onShowAll:o}){const r=s===null;return e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsxs("button",{onClick:o,className:`px-2 py-1 rounded text-[11px] font-mono border ${r?"bg-accent text-white border-accent":"border-line text-fg-faint hover:text-fg hover:bg-bg-hi"}`,children:["show all (",t.length,")"]}),t.map(a=>{const l=r||s.has(a.projectDir);return e.jsxs("button",{onClick:u=>u.shiftKey?c(a.projectDir):n(a.projectDir),title:a.projectDir,className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-[11px] font-mono border ${l?"border-line text-fg-dim bg-bg-hi":"border-line text-fg-faint opacity-40 hover:opacity-70"}`,children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(a.projectDir)}}),W(a.projectDir)??a.projectDir]},a.projectDir)})]})}function jt(t,s){const n=new Map;for(const o of t)for(const[r,a]of Object.entries(o.values))n.set(r,(n.get(r)??0)+a);const c=Array.from(n.entries()).sort((o,r)=>r[1]-o[1]).map(([o])=>o);return t.map(o=>{const r=c.reduce((u,d)=>u+(o.values[d]??0),0);let a=0;const l=c.map(u=>{const d=o.values[u]??0;if(r<=0)return{projectDir:u,value:d,y0:0,y1:0};const i=s==="share"?d/r:d,x=a,f=a+i;return a=f,{projectDir:u,value:d,y0:x,y1:f}});return{date:o.date,bands:l,total:r}})}const ie=720,le=220,de=44,gt=20;function kt(t,s){return t==="spend"?E(s):z(s)}function bt({days:t,measure:s,selected:n,onSelect:c}){const[o,r]=m.useState("absolute"),a=m.useMemo(()=>jt(t,o),[t,o]),l=m.useMemo(()=>{if(o==="share")return 1;let h=0;for(const k of a)h=Math.max(h,k.total);return h||1},[a,o]),u=ie-de,d=le-gt,i=a.length>1?u/(a.length-1):u,x=h=>de+h*i,f=h=>d-h/l*d,v=Math.max(1,Math.ceil(a.length/8)),C=4,S=Array.from({length:C+1},(h,k)=>l/C*k);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"02 · over time",title:"Trend by project",right:e.jsx("div",{className:"flex border border-line rounded overflow-hidden text-[10px] font-mono",children:["absolute","share"].map(h=>e.jsx("button",{onClick:()=>r(h),className:`px-2 py-0.5 ${o===h?"bg-accent text-white":"text-fg-faint hover:text-fg"}`,children:h},h))})}),e.jsxs("svg",{width:"100%",viewBox:`0 0 ${ie} ${le}`,className:"overflow-visible",children:[S.map((h,k)=>e.jsxs("g",{children:[e.jsx("line",{x1:de,x2:ie,y1:f(h),y2:f(h),stroke:"currentColor",className:"text-line",strokeWidth:1}),e.jsx("text",{x:0,y:f(h)+3,fontSize:9,className:"fill-fg-faint",children:o==="share"?`${Math.round(h*100)}%`:kt(s,h)})]},k)),a.map((h,k)=>{if(k===0)return null;const P=a[k-1];return h.bands.map((j,te)=>{const G=P.bands[te],B=n!==null&&n!==j.projectDir,se=B?dt:A(j.projectDir),ne=[`${x(k-1)},${f(G.y0)}`,`${x(k)},${f(j.y0)}`,`${x(k)},${f(j.y1)}`,`${x(k-1)},${f(G.y1)}`].join(" ");return e.jsx("polygon",{points:ne,fill:se,opacity:B?.6:.75,className:"cursor-pointer",onClick:()=>c(n===j.projectDir?null:j.projectDir),children:e.jsx("title",{children:W(j.projectDir)??j.projectDir})},`${j.projectDir}-${k}`)})}),a.map((h,k)=>k%v!==0&&k!==a.length-1?null:e.jsx("text",{x:x(k),y:le-4,fontSize:9,textAnchor:"middle",className:"fill-fg-faint",children:h.date.slice(5)},h.date))]})]})}function vt({rows:t,measure:s,selected:n,onSelect:c}){return t.length?e.jsxs("div",{className:`${M} overflow-hidden`,children:[e.jsx("div",{className:"p-4 pb-0",children:e.jsx(D,{kicker:"03 · by project",title:"Ranking"})}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-bg-elev",children:e.jsx("tr",{children:["project","share","value","share %","trend","sessions","top tool"].map(o=>e.jsx("th",{className:"text-left px-3 py-2 text-fg-faint uppercase tracking-wider whitespace-nowrap",children:o},o))})}),e.jsx("tbody",{children:t.map(o=>{const r=A(o.projectDir),a=n===o.projectDir;return e.jsxs("tr",{onClick:()=>c(o.projectDir),className:`border-t border-line hover:bg-bg-elev cursor-pointer ${a?"bg-bg-elev":""}`,children:[e.jsx("td",{className:"px-3 py-2 font-mono text-fg-dim",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:r}}),W(o.projectDir)??o.projectDir]})}),e.jsx("td",{className:"px-3 py-2 w-32",children:e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(o.sharePct,o.sharePct>0?2:0)}%`,backgroundColor:r}})})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:J(s,o.value)}),e.jsxs("td",{className:"px-3 py-2 text-fg-faint font-mono",children:[o.sharePct.toFixed(1),"%"]}),e.jsx("td",{className:"px-3 py-2 font-mono",children:o.trend.pct===null?e.jsx("span",{className:"text-fg-faint",children:"—"}):e.jsxs("span",{className:o.trend.direction==="up"?"text-delta-good":o.trend.direction==="down"?"text-delta-bad":"text-fg-faint",children:[o.trend.direction==="up"?"▲":o.trend.direction==="down"?"▼":"·"," ",Fe(Math.abs(o.trend.pct))]})}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:K(o.sessions)}),e.jsx("td",{className:"px-3 py-2 text-fg-faint font-mono",children:o.topTool||"—"})]},o.projectDir)})})]})]}):e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"03 · by project",title:"Ranking"}),e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"})]})}function Ct({projectDir:t,totals:s,byModel:n,toolBreakdown:c,onClear:o}){var i;const r=R(s,"in"),a=R(s,"out"),l=Object.entries(n).sort((x,f)=>f[1].costUsd-x[1].costUsd),u=Object.entries(c).sort((x,f)=>f[1]-x[1]),d=((i=u[0])==null?void 0:i[1])??0;return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"04 · drill in",title:W(t)??t,right:e.jsx("button",{onClick:o,className:"text-[11px] text-fg-faint hover:text-fg font-mono",children:"clear ✕"})}),e.jsx("div",{className:"flex items-center gap-1.5 -mt-2 mb-3",children:e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(t)}})}),e.jsxs("div",{className:"grid grid-cols-6 gap-3 mb-4",children:[e.jsx(I,{label:"prompts",value:K(s.promptCount)}),e.jsx(I,{label:"sessions",value:K(s.sessionCount)}),e.jsx(I,{label:"in tokens",value:z(r)}),e.jsx(I,{label:"out tokens",value:z(a)}),e.jsx(I,{label:"spend",value:E(s.estimatedCostUsd)}),e.jsx(I,{label:"time",value:Pe(s.activeMinutes)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"model mix"}),l.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data"}):e.jsx("div",{className:"space-y-1",children:l.map(([x,f])=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-fg-dim",children:[e.jsx("span",{children:xe(x)}),e.jsx("span",{className:"text-fg-faint",children:E(f.costUsd)})]},x))})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider mb-1.5",children:"tool mix"}),u.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no tool data"}):e.jsx("div",{className:"space-y-1",children:u.slice(0,6).map(([x,f])=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx("span",{className:"w-20 shrink-0 truncate text-fg-dim font-mono",children:x}),e.jsx("div",{className:"flex-1 h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full bg-hive-teal",style:{width:`${d>0?f/d*100:0}%`}})}),e.jsx("span",{className:"text-fg-faint font-mono w-8 text-right",children:f})]},x))})]})]})]})}function I({label:t,value:s}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-fg-faint uppercase tracking-wider",children:t}),e.jsx("div",{className:"text-[17px] font-mono tracking-tight text-fg",children:s})]})}function Tt({byModelTotals:t}){const s=Object.entries(t).sort((c,o)=>o[1].costUsd-c[1].costUsd),n=s.reduce((c,[,o])=>c+o.costUsd,0);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Model mix",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:[E(n)," total"]})}),s.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no model data in range"}):e.jsx("div",{className:"space-y-2",children:s.map(([c,o])=>{const r=n>0?o.costUsd/n*100:0,a=A(c);return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs mb-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1.5 font-mono text-fg-dim truncate",children:[e.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{backgroundColor:a}}),xe(c),o.estimated&&e.jsx("span",{className:"text-fg-faint",children:"(est.)"})]}),e.jsxs("span",{className:"text-fg-faint whitespace-nowrap ml-2",children:[E(o.costUsd)," · ",r.toFixed(0),"%"]})]}),e.jsx("div",{className:"h-1.5 rounded bg-bg-hi overflow-hidden",children:e.jsx("div",{className:"h-full",style:{width:`${Math.max(r,r>0?2:0)}%`,backgroundColor:a}})})]},c)})})]})}function yt({rows:t}){const s=t.slice(0,3),n=s.reduce((r,a)=>r+a.sharePct,0),c=t.slice(3),o=c.reduce((r,a)=>r+a.sharePct,0);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Concentration",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["top 3 = ",n.toFixed(0),"%"]})}),t.length===0?e.jsx("div",{className:"text-xs text-fg-faint",children:"no projects in range"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex h-3 rounded overflow-hidden mb-2",children:t.map(r=>e.jsx("div",{style:{width:`${Math.max(r.sharePct,.5)}%`,backgroundColor:A(r.projectDir)},title:`${W(r.projectDir)??r.projectDir} · ${r.sharePct.toFixed(1)}%`},r.projectDir))}),e.jsx("div",{className:"space-y-1 mb-2",children:s.map(r=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono",children:[e.jsxs("span",{className:"flex items-center gap-1.5 text-fg-dim truncate",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{backgroundColor:A(r.projectDir)}}),W(r.projectDir)??r.projectDir]}),e.jsxs("span",{className:"text-fg-faint",children:[r.sharePct.toFixed(1),"%"]})]},r.projectDir))}),c.length>0&&e.jsxs("p",{className:"text-[10px] text-fg-faint",children:[c.length," more project",c.length===1?"":"s"," account for ",o.toFixed(1),"% (long tail)."]})]})]})}const ee=30,pe=9,F=(ee+pe)*2;function Nt({totals:t}){const s=t.inputTokens+t.cacheReadTokens+t.cacheCreationTokens,n=s>0?t.cacheReadTokens/s*100:0,c=2*Math.PI*ee,o=F/2;return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Cache"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"relative shrink-0",style:{width:F,height:F},children:[e.jsxs("svg",{width:F,height:F,viewBox:`0 0 ${F} ${F}`,className:"-rotate-90",children:[e.jsx("circle",{cx:o,cy:o,r:ee,fill:"none",stroke:"currentColor",className:"text-bg-hi",strokeWidth:pe}),e.jsx("circle",{cx:o,cy:o,r:ee,fill:"none",stroke:ut,strokeWidth:pe,strokeDasharray:c,strokeDashoffset:c*(1-n/100),strokeLinecap:"round"})]}),e.jsxs("div",{className:"absolute inset-0 flex items-center justify-center text-[13px] font-mono text-fg",children:[n.toFixed(0),"%"]})]}),e.jsxs("div",{className:"text-[11px] space-y-1 font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"reused (cache read)"}),e.jsx("span",{className:"text-fg-dim",children:z(t.cacheReadTokens)})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-fg-faint",children:"written to cache"}),e.jsx("span",{className:"text-fg-dim",children:z(t.cacheCreationTokens)})]})]})]})]})}const wt=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function Mt({days:t,measure:s}){const{buckets:n,weekendShare:c,peakIdx:o}=m.useMemo(()=>{const a=new Array(7).fill(0);for(const i of t){const[x,f,v]=i.date.split("-").map(Number),C=new Date(x,f-1,v).getDay();a[C]+=R(i.totals,s)}const l=a.reduce((i,x)=>i+x,0),u=a[0]+a[6];let d=0;for(let i=1;i<7;i++)a[i]>a[d]&&(d=i);return{buckets:a,weekendShare:l>0?u/l*100:0,peakIdx:d}},[t,s]),r=Math.max(...n,1);return e.jsxs("div",{className:`${M} p-4`,children:[e.jsx(D,{kicker:"05 · composition",title:"Rhythm",right:e.jsxs("span",{className:"text-xs font-mono text-fg-faint",children:["weekend ",c.toFixed(0),"%"]})}),e.jsx("div",{className:"flex items-end gap-2 h-24",children:n.map((a,l)=>e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-end gap-1 h-full",children:[e.jsx("div",{className:`w-full rounded-t ${l===o?"bg-accent":"bg-rhythm"}`,style:{height:`${r>0?a/r*100:0}%`,minHeight:a>0?2:0}}),e.jsx("span",{className:"text-[9px] text-fg-faint font-mono",children:wt[l]})]},l))})]})}const St=["in","out","total","prompts","sessions","time","spend"],$t=[30,60,90,0],Rt="spend",Dt=30,Ut=[];function Et(){return{promptCount:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,toolCallCount:0,sessionCount:0,errorCount:0,activeMinutes:0,estimatedCostUsd:0}}function Pt(){var be;const[t,s]=m.useState(Rt),[n,c]=m.useState(Dt),o=m.useRef(!1),r=m.useRef(!1),a=p=>{o.current=!0;const g=t;s(p),ue({measure:p}).catch(()=>{s(g),q.error("Couldn't save the measure preference — reverted.")})},l=p=>{r.current=!0;const g=n;c(p),ue({range:p}).catch(()=>{c(g),q.error("Couldn't save the range preference — reverted.")})};m.useEffect(()=>{let p=!1;return he().then(g=>{p||(!o.current&&g.measure&&St.includes(g.measure)&&s(g.measure),!r.current&&g.range!==void 0&&$t.includes(g.range)&&c(g.range))}),()=>{p=!0}},[]);const u=We(p=>p.navFace),d=Ne(p=>p.tabs),i=Ne(p=>p.activeTabId),x=((be=d.find(p=>p.id===i))==null?void 0:be.cwd)??null,f=m.useRef(u),v=x?ze(x):null,[C,S]=m.useState(null),h=m.useMemo(()=>u==="project"&&v?new Set([v]):C,[u,v,C]),[k,P]=m.useState(null),[j,te]=m.useState(null),[G,B]=m.useState(!0),[se,ne]=m.useState(0);m.useEffect(()=>{let p=!1;return B(!0),window.api.history.dashboard({rangeDays:n}).then(g=>{p||(te(g),B(!1))}).catch(g=>{p||(B(!1),q.error(`History analytics failed to load: ${String(g)}`))}),()=>{p=!0}},[n,se]);const fe=m.useRef(!1);m.useEffect(()=>{if(!fe.current){fe.current=!0;return}S(null),P(null)},[n]),m.useEffect(()=>{f.current!==u&&(f.current=u,u==="home"&&S(null))},[u]);const{projects:me,resolving:je}=Ke(),ge=m.useMemo(()=>{const p={};for(const g of me)for(const T of g.encodedIds)p[T]=g.cwd;return p},[me]),_=m.useMemo(()=>j&&!je?ot(j.days,ge):null,[j,ge,je]),y=(_==null?void 0:_.days)??(j==null?void 0:j.days)??Ut,oe=(_==null?void 0:_.excluded)??null,$=m.useMemo(()=>j?Xe({days:y,totals:j.totals,prevTotals:j.prevTotals},h):null,[j,y,h]),O=m.useMemo(()=>h===null?y:y.map(p=>({date:p.date,byProject:Object.fromEntries(Object.entries(p.byProject).filter(([g])=>h.has(g)))})),[y,h]),Y=m.useMemo(()=>Me(y,t),[y,t]),ae=m.useMemo(()=>Me(O,t),[O,t]),Ae=m.useMemo(()=>O.map(p=>({date:p.date,values:Object.fromEntries(Object.entries(p.byProject).map(([g,T])=>[g,R(T,t)]))})),[O,t]),ke=m.useMemo(()=>$?Ze($,t):null,[$,t]),V=m.useMemo(()=>{if(!j||!k)return null;const p=Et(),g={},T={};for(const H of y){const b=H.byProject[k];if(b){p.promptCount+=b.promptCount,p.inputTokens+=b.inputTokens,p.outputTokens+=b.outputTokens,p.cacheReadTokens+=b.cacheReadTokens,p.cacheCreationTokens+=b.cacheCreationTokens,p.toolCallCount+=b.toolCallCount,p.sessionCount+=b.sessionCount,p.errorCount+=b.errorCount,p.activeMinutes+=b.activeMinutes,p.estimatedCostUsd+=b.estimatedCostUsd;for(const[N,w]of Object.entries(b.byModel)){const U=g[N]??(g[N]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});U.inputTokens+=w.inputTokens,U.outputTokens+=w.outputTokens,U.cacheReadTokens+=w.cacheReadTokens,U.cacheCreationTokens+=w.cacheCreationTokens,U.costUsd+=w.costUsd}for(const[N,w]of Object.entries(b.toolBreakdown))T[N]=(T[N]??0)+w}}return{totals:p,byModel:g,toolBreakdown:T}},[j,y,k]);m.useEffect(()=>{k&&h!==null&&!h.has(k)&&P(null)},[k,h]);function Be(p){S(g=>{const T=new Set(Y.map(N=>N.projectDir)),H=g??new Set(T),b=new Set(H);return b.has(p)?b.delete(p):b.add(p),b.size>=T.size?null:b})}function _e(p){S(new Set([p]))}function Oe(){S(null)}function He(){if(!j)return;const p=O.map(N=>{let w=0,U=0,ve=0,Ce=0,Te=0;const ce={};for(const L of Object.values(N.byProject)){w+=L.estimatedCostUsd,U+=L.inputTokens,ve+=L.outputTokens,Ce+=L.cacheCreationTokens,Te+=L.cacheReadTokens;for(const[ye,X]of Object.entries(L.byModel)){const Q=ce[ye]??(ce[ye]={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreationTokens:0,costUsd:0});Q.inputTokens+=X.inputTokens,Q.outputTokens+=X.outputTokens,Q.cacheReadTokens+=X.cacheReadTokens,Q.cacheCreationTokens+=X.cacheCreationTokens}}return{date:N.date,costUsd:w,inputTokens:U,outputTokens:ve,cacheCreationTokens:Ce,cacheReadTokens:Te,byModel:ce}}),g=et(p),T=new Blob([g],{type:"text/csv"}),H=URL.createObjectURL(T),b=document.createElement("a");b.href=H,b.download=`usage-history-${j.from}-${j.to}.csv`,b.click(),URL.revokeObjectURL(H)}return G&&!j?e.jsx(De,{}):j&&j.days.length===0?e.jsx(Ge,{title:"no sessions in range",hint:"Widen the range or check back after your next session."}):!j||!$||!ke?e.jsx(De,{}):e.jsxs("div",{"data-testid":"history-dashboard",className:"flex flex-col h-full",children:[e.jsxs("h1",{className:"font-serif text-[42px] leading-tight tracking-tight text-fg px-4 pt-4",children:["Where your ",e.jsx("em",{className:"italic text-accent",children:"Claude time"})," goes"]}),e.jsx(lt,{measure:t,onMeasure:a,range:n,onRange:l,projectsShown:h===null?Y.length:h.size,projectsTotal:Y.length,fromDate:j.from,toDate:j.to,onRefresh:()=>ne(p=>p+1),onExport:He,exportDisabled:O.length===0}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto p-4 space-y-4",children:[e.jsx(pt,{measure:t,headline:ke,activeDays:$.activeDays,projectsTouched:ae.length,totalSessions:$.totals.sessionCount}),e.jsx(ft,{days:y}),oe&&at(oe)&&e.jsx("div",{"data-testid":"history-excluded-note",className:"rounded-[10px] border border-line bg-bg-hi px-3 py-2 text-[11.5px] font-mono text-fg-faint",title:"A project is a working directory. ~/.claude/projects holds one folder per path the CLI was ever launched from — throwaway /tmp dirs and test fixtures included — and a folder whose cwd can't be recovered from its transcripts is not a project. Their totals are stated here rather than silently folded into the charts.",children:ct(oe)}),u==="home"&&e.jsx(mt,{chips:Y.map(p=>({projectDir:p.projectDir,value:p.value})),keep:h,onToggle:Be,onIsolate:_e,onShowAll:Oe}),e.jsx(bt,{days:Ae,measure:t,selected:k,onSelect:P}),e.jsx(vt,{rows:ae,measure:t,selected:k,onSelect:P}),k&&V&&e.jsx(Ct,{projectDir:k,totals:V.totals,byModel:V.byModel,toolBreakdown:V.toolBreakdown,onClear:()=>P(null)}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(Tt,{byModelTotals:$.byModelTotals}),e.jsx(yt,{rows:ae}),e.jsx(Nt,{totals:$.totals}),e.jsx(Mt,{days:$.days,measure:t})]})]})]})}function De(){return e.jsxs("div",{className:"p-4 space-y-4 animate-pulse",children:[e.jsx("div",{className:"h-24 bg-bg-elev rounded"}),e.jsx("div",{className:"h-16 bg-bg-elev rounded"}),e.jsx("div",{className:"h-8 bg-bg-elev rounded"}),e.jsx("div",{className:"h-56 bg-bg-elev rounded"}),e.jsx("div",{className:"h-40 bg-bg-elev rounded"})]})}function Ft(){return e.jsx(Ye,{children:e.jsx(Pt,{})})}const Ot=m.memo(Ft);export{Ot as History};
@@ -1,3 +0,0 @@
1
- import{aw as d,aS as X,aM as Z,aU as ee,aN as F,aj as te,ao as se,ad as ae,ah as e,m as E,V as oe,G as ne,aD as re,u as ie}from"./index-3_AtCAyd.js";import{P as R}from"./Panel-CC3JTnOI.js";import{L as le}from"./ListDetail-YylbvUj_.js";import{S as ce}from"./SaveBar-C06rFT34.js";import{S as D}from"./ScopeSwitcher-Cp5mxblN.js";import{P as de}from"./ProvenanceBadge-DaJIWVcg.js";import{u as me,E as pe,s as ue}from"./settingsSchema-CvoNk3Ye.js";import{H as he}from"./Library-DLmnlfQt.js";import{V as xe}from"./ViewTabs-T0NBc8uv.js";import"./monaco-editor-BsIlgG7c.js";import"./claude-settings-schema-COigsajx.js";import"./Button-DC6VzovQ.js";const fe={UserPromptSubmit:{when:"Fires just before the user prompt is sent to the model.",payload:"{ prompt: string }",example:"Block submission if the prompt mentions a secret."},UserPromptExpansion:{when:"Fires when a slash command expands into its final prompt text.",payload:"{ command: string, expanded: string }",example:"Audit which slash commands actually run, post-expansion."},PreToolUse:{when:"Fires before any tool runs. Can block the call.",payload:"{ tool_name: string, tool_input: object }",example:'matcher="Bash" — block dangerous shell commands.'},PostToolUse:{when:"Fires after a tool completes successfully.",payload:"{ tool_name: string, tool_input: object, tool_result: string }",example:'matcher="Write|Edit" — run a linter on changed files.'},PostToolUseFailure:{when:"Fires after a tool errors out (non-zero exit, exception, or refusal).",payload:"{ tool_name: string, tool_input: object, error: string }",example:"Pipe failed Bash runs into a desktop notification."},PostToolBatch:{when:"Fires once after a parallel batch of tool calls all complete.",payload:"{ tool_uses: Array<{ tool_name, tool_input, tool_result? }> }",example:"Aggregate file-edit batches into a single commit message."},Stop:{when:"Fires when the model emits end_turn.",payload:"{ stop_reason: string, output_tokens: number }",example:"Play a chime when the agent finishes a long task."},StopFailure:{when:"Fires when a turn aborts without end_turn (rate-limit, network, OOM).",payload:'{ reason: "rate_limit"|"network"|"oom"|"killed"|string }',example:"Auto-resume on transient failures."},SessionStart:{when:"Fires once when a session boots (claude or claude -p).",payload:'{ source: "startup"|"resume", model: string, agent_type: string }',example:"Inject a project-specific system prompt addendum."},SessionEnd:{when:"Fires once when the session terminates.",payload:'{ reason: "user_quit"|"timeout"|"error"|string }',example:"Persist transcript summary to ~/.claude/projects/<>."},Setup:{when:"Fires during interactive setup (claude /setup, /init).",payload:'{ mode: "init"|"reconfigure"|string }'},PreCompact:{when:"Fires before transcript compaction runs.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }',example:"Snapshot the pre-compact transcript for later diffing."},PostCompact:{when:"Fires after compaction; the active transcript is the compacted one.",payload:'{ transcript_path: string, trigger: "manual"|"auto" }'},InstructionsLoaded:{when:"Fires after CLAUDE.md and any imported memory files are loaded.",payload:'{ source: "session_start"|"reload" }'},Notification:{when:"Fires when Claude Code emits a desktop notification.",payload:"{ title: string, message: string }",example:"Forward to your own notify-send / osascript pipeline."},PermissionRequest:{when:"Fires when a tool needs user permission (per the permissions block).",payload:"{ tool_name: string, tool_input?: object }",example:"Auto-allow npm test invocations."},PermissionDenied:{when:"Fires when the user (or policy) denies a permission request.",payload:"{ tool_name: string, retry: boolean }",example:"Track which tools the user habitually rejects."},SubagentStart:{when:"Fires when a subagent (Task tool) spawns.",payload:"{ agent_type: string }",example:'matcher="security-reviewer" — log every security scan.'},SubagentStop:{when:"Fires when a subagent finishes.",payload:'{ agent_type: string, reason: "end_turn"|"error"|string }'},TeammateIdle:{when:"Fires when a teammate agent goes idle (waiting for input).",payload:"{ teammate_id?: string }"},TaskCreated:{when:"Fires when a new Task is created via the Task tool.",payload:"{ task: { description: string, ...} }",example:"Track each spawned task in an external queue."},TaskCompleted:{when:"Fires when a Task completes (success or failure).",payload:"{ task: { description: string, ...} }"},ConfigChange:{when:"Fires when settings.json (any scope) is mutated mid-session.",payload:'{ source: "user_settings"|"project_settings"|"local_settings" }',example:"Reload tooling that depends on env vars on config change."},CwdChanged:{when:"Fires when the working directory changes (e.g. agent cd-ing).",payload:"{ old_cwd: string, new_cwd: string }",example:"Refresh project-scoped indexers when cwd drifts."},FileChanged:{when:"Fires when a watched file outside Claude Code's edits changes.",payload:'{ file_path: string, change_type: "modified"|"created"|"deleted" }',example:"Re-run typecheck when any .ts file changes."},WorktreeCreate:{when:"Fires after a git worktree is created via /worktree or subagent isolation.",payload:"{ worktree_path?: string, branch?: string }"},WorktreeRemove:{when:"Fires after a git worktree is removed.",payload:"{ worktree_path?: string }"},Elicitation:{when:"Fires when Claude asks the user a multiple-choice question.",payload:'{ action: "accept"|"reject", ...}'},ElicitationResult:{when:"Fires after the user resolves an elicitation prompt.",payload:"{ choice?: string }"}},I=["UserPromptSubmit","UserPromptExpansion","PreToolUse","PostToolUse","PostToolUseFailure","PostToolBatch","Stop","StopFailure","SessionStart","SessionEnd","Setup","PreCompact","PostCompact","InstructionsLoaded","Notification","PermissionRequest","PermissionDenied","SubagentStart","SubagentStop","TeammateIdle","TaskCreated","TaskCompleted","ConfigChange","CwdChanged","FileChanged","WorktreeCreate","WorktreeRemove","Elicitation","ElicitationResult"],ge=new Set(I),be=["command","http","prompt","agent","mcp_tool"],ye={UserPromptSubmit:{prompt:"hello"},UserPromptExpansion:{command:"/example",expanded:"hello"},PreToolUse:{tool_name:"Bash",tool_input:{command:"ls"}},PostToolUse:{tool_name:"Bash",tool_input:{command:"ls"},tool_result:""},PostToolUseFailure:{tool_name:"Bash",tool_input:{command:"ls"},error:""},PostToolBatch:{tool_uses:[]},Stop:{stop_reason:"end_turn",output_tokens:0},StopFailure:{reason:"rate_limit"},SessionStart:{source:"startup",model:"",agent_type:""},SessionEnd:{reason:"user_quit"},Setup:{mode:"init"},PreCompact:{transcript_path:"",trigger:"manual"},PostCompact:{transcript_path:"",trigger:"manual"},InstructionsLoaded:{source:"session_start"},Notification:{title:"test",message:"test notification"},PermissionRequest:{tool_name:"Bash"},PermissionDenied:{tool_name:"Bash",retry:!1},SubagentStart:{agent_type:"general-purpose"},SubagentStop:{agent_type:"general-purpose",reason:"end_turn"},TeammateIdle:{},TaskCreated:{task:{description:""}},TaskCompleted:{task:{description:""}},ConfigChange:{source:"user_settings"},CwdChanged:{old_cwd:"",new_cwd:""},FileChanged:{file_path:"",change_type:"modified"},WorktreeCreate:{},WorktreeRemove:{},Elicitation:{action:"accept"},ElicitationResult:{}};function ve(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const n=JSON.parse(t);return{full:n,hooks:n.hooks??{},err:null}}catch(n){return{full:{},hooks:{},err:n.message}}}function je(t,n){return JSON.stringify({...t,hooks:n},null,2)+`
2
- `}function we(t,n){return(t[n]??[]).reduce((o,l)=>{var c;return o+(((c=l.hooks)==null?void 0:c.length)??0)},0)}function ke(){const t=X(),n=Z(),o=(n==null?void 0:n.cwd)??null,l=ee(a=>a.navFace),c=d.useRef(!1),f=d.useRef(l),[m,x]=d.useState(()=>l==="project"&&o?"project":"user"),[r,u]=d.useState("PreToolUse"),[s,S]=d.useState("effective");d.useEffect(()=>{if(f.current!==l){if(f.current=l,c.current){c.current=!1;return}x(l==="project"&&o?"project":"user")}},[l,o]),d.useEffect(()=>{l==="project"&&s==="library"&&S("effective")},[l,s]);const g=a=>{c.current=!0,x(a)},j=me(ne,t,o),p=j[m]??null,w=F(a=>a.files),O=F(a=>a.setDraft),q=F(a=>a.saveJson),J=F(a=>a.revert),[M,N]=d.useState(null),[C,U]=d.useState(null),T=e.jsx(xe,{options:[{key:"effective",label:"Effective"},{key:"events",label:"Events"},...l==="home"?[{key:"library",label:"Library"}]:[]],active:s,onChange:S}),W=d.useMemo(()=>{const a=te(se(w,j));return ae(a,["hooks"])??{kind:"object",children:{}}},[w,j]),$=(a,h)=>{var L;const i=j[m];if(!i)return;N(null);const k=((L=w[i])==null?void 0:L.draftRaw)??"";let v={};if(k.trim())try{v=JSON.parse(k)}catch{v={}}const Y=re(v.hooks??{},a,h),Q={...v,hooks:Y};O(i,JSON.stringify(Q,null,2)+`
3
- `)};if(!t)return e.jsx(E,{title:"loading…"});if(s==="library")return e.jsx(R,{toolbar:T,children:e.jsx(he,{})});if(m!=="user"&&!o)return e.jsx(R,{toolbar:e.jsxs(e.Fragment,{children:[T,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(D,{scopes:["user","project","local"],active:m,onChange:g})]}),children:e.jsx(E,{title:"no active project"})});if(!p)return e.jsx(E,{title:"loading…"});const b=w[p],{full:V,hooks:y,err:H}=b?ve(b.draftRaw):{full:{},hooks:{},err:null},A=Object.keys(y).filter(a=>!ge.has(a)),B=A.reduce((a,h)=>a+(y[h]??[]).reduce((i,k)=>{var v;return i+(((v=k.hooks)==null?void 0:v.length)??0)},0),0),P=a=>{N(null),O(p,je(V,a))},_=y[r]??[],G=()=>{P({...y,[r]:[..._,{matcher:"",hooks:[{type:"command",command:""}]}]})},K=(a,h)=>{const i=_.slice();i[a]=h,P({...y,[r]:i})},z=a=>{P({...y,[r]:_.filter((h,i)=>i!==a)})};return e.jsxs(R,{toolbar:e.jsxs(e.Fragment,{children:[T,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(D,{scopes:["user","project","local"],active:m,onChange:g}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:s==="effective"?`overrides → ${p}`:p}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/hooks",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"hook reference ↗"})]}),footer:b?e.jsx(ce,{dirty:b.dirty,busy:b.busy,parseError:M||H||b.parseError,lastSavedAt:b.lastSavedAt,onSave:async()=>{N(null);const a=await q(p);a.ok||N(a.error??"save failed")},onRevert:()=>{N(null),J(p)}}):null,children:[s==="effective"?e.jsx(pe,{node:W,targetScope:m,onOverride:$,schema:ue().rootedAt(["hooks"]),rootLabel:"hooks"}):e.jsxs("div",{className:"flex flex-col h-full",children:[B>0?e.jsxs("div",{className:"px-3 py-2 border-b border-line text-xs bg-bg-elev text-fg-dim",children:[e.jsx("span",{className:"text-yellow-400",children:"⚠"})," ",B," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:A.join(", ")}),e.jsx("span",{className:"text-fg-faint",children:" · these are ignored by Claude Code 2026; edit settings.json directly to remove."})]}):null,e.jsx(le,{sidebarWidth:"14rem",sidebar:e.jsx("div",{className:"py-1",children:I.map(a=>{const h=we(y,a),i=fe[a],k=i?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:i.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",i.payload]}),i.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",i.example]}):null]}):e.jsx("span",{className:"text-fg-faint italic",children:"no documentation yet"});return e.jsx("div",{className:"[&>span]:w-full",children:e.jsx(oe,{content:k,align:"bottom-center",children:e.jsxs("button",{onClick:()=>u(a),title:i==null?void 0:i.when,className:`w-full text-left px-3 py-1 text-xs ${r===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"truncate",children:a}),h>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:h})]}),i?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:i.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},a)})}),detail:e.jsxs("div",{className:"p-4 space-y-3 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-xs uppercase tracking-wider text-fg",children:r}),e.jsx("button",{onClick:G,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+ add group"})]}),_.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):_.map((a,h)=>e.jsx(Ne,{group:a,jsonInvalid:!!H,onChange:i=>K(h,i),onRemove:()=>z(h),onTestFire:i=>U({event:r,matcher:a.matcher??"",command:i.command??""})},h))]})})]}),C?e.jsx(Fe,{event:C.event,matcher:C.matcher,command:C.command,onClose:()=>U(null)}):null]})}const qe=d.memo(ke);function Ne({group:t,jsonInvalid:n,onChange:o,onRemove:l,onTestFire:c}){const f=()=>o({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),m=(r,u)=>{const s=t.hooks.slice();s[r]=u,o({...t,hooks:s})},x=r=>o({...t,hooks:t.hooks.filter((u,s)=>s!==r)});return e.jsxs("div",{className:"border border-line rounded p-3 bg-bg-elev space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-fg-faint w-16",children:"matcher"}),e.jsx("input",{value:t.matcher??"",onChange:r=>o({...t,matcher:r.target.value}),placeholder:"tool name regex or exact match (optional)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),e.jsx("button",{onClick:l,className:"text-fg-faint hover:text-red-400 text-xs",title:"remove group",children:"× group"})]}),(t.hooks??[]).map((r,u)=>e.jsx(_e,{rule:r,jsonInvalid:n,onChange:s=>m(u,s),onRemove:()=>x(u),onTestFire:()=>c(r)},u)),e.jsx("button",{onClick:f,className:"text-xs text-fg-faint hover:text-fg",children:"+ add hook"})]})}function _e({rule:t,jsonInvalid:n,onChange:o,onRemove:l,onTestFire:c}){const f=s=>({command:"e.g. node ./scripts/lint.js $FILE",http:"e.g. https://hooks.example.com/notify",prompt:"e.g. Review this change for security issues",agent:"e.g. security-reviewer",mcp_tool:"e.g. mcp__server__tool"})[s],m=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",x=t[m]??"",r=(t.args??[]).join(" "),u={type:"hook",name:x||t.type,command:t.type==="command"?t.command:void 0,url:t.type==="http"?t.url:void 0};return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("select",{value:t.type,onChange:s=>o({type:s.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:be.map(s=>e.jsx("option",{value:s,children:s},s))}),e.jsx(de,{interactive:!1,input:u}),e.jsx("input",{value:x,onChange:s=>o({...t,[m]:s.target.value}),placeholder:f(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${n?"border-red-500/70":x.trim()?"border-line":"border-yellow-600/50"}`}),n?e.jsx("span",{className:"text-red-400 text-xs",title:"The enclosing settings.json is malformed; fix the JSON before editing.",children:"× invalid"}):null,e.jsx("input",{value:t.timeout??"",onChange:s=>o({...t,timeout:s.target.value?Number(s.target.value):void 0}),placeholder:"timeout ms",className:"w-20 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),t.type==="command"?e.jsx("button",{onClick:c,disabled:n||!x.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",title:"Run this command with a fake event payload",children:"test fire"}):null,e.jsx("button",{onClick:l,className:"text-fg-faint hover:text-red-400 text-xs",children:"×"})]}),t.type==="command"?e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"args"}),e.jsx("input",{value:r,onChange:s=>o({...t,args:s.target.value.trim()?s.target.value.split(/\s+/).filter(Boolean):void 0}),placeholder:"argv array (v2.1.139+ exec form, no shell)",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]}):null,e.jsxs("div",{className:"flex items-center gap-2 pl-[3.75rem]",children:[e.jsx("span",{className:"text-xs text-fg-faint w-12",children:"term"}),e.jsx("input",{value:t.terminalSequence??"",onChange:s=>o({...t,terminalSequence:s.target.value||void 0}),placeholder:"terminalSequence — e.g. \\\\a (bell), v2.1.141+",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"})]})]})}function Se(t){return JSON.stringify(ye[t]??{},null,2)}function Ce(t,n){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const o=n&&typeof n=="object"&&"tool_name"in n?String(n.tool_name??""):null;if(o==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(o),target:o}}catch{return{matched:t===o,target:o,note:"matcher not valid regex; fell back to exact match"}}}function Fe({event:t,matcher:n,command:o,onClose:l}){const[c,f]=d.useState(()=>Se(t)),[m,x]=d.useState(!1),[r,u]=d.useState(null),[s,S]=d.useState(null);let g=null;try{JSON.parse(c)}catch(p){g=p.message}const j=async()=>{x(!0),u(null);let p=null;try{p=JSON.parse(c)}catch{}S(Ce(n,p));try{const w=await window.api.app.testFireHook({command:o,payload:c,timeoutMs:5e3});u(w)}finally{x(!1)}};return e.jsx(ie,{open:!0,onClose:l,title:`Test fire — ${t}`,children:e.jsxs("div",{className:"space-y-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"resolved command"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1 break-all",children:o})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1",children:n||e.jsx("span",{className:"text-fg-faint",children:"(empty — matches all)"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-fg-faint",children:"fake event payload (stdin)"}),g?e.jsxs("span",{className:"text-red-400",children:["× ",g]}):null]}),e.jsx("textarea",{value:c,onChange:p=>f(p.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${g?"border-red-500/70":"border-line"}`})]}),s?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher result"}),e.jsxs("div",{className:"font-mono",children:[e.jsx("span",{className:s.matched?"text-green-400":"text-red-400",children:s.matched?"✓ match":"✗ no match"}),s.target!=null?e.jsxs("span",{className:"text-fg-dim",children:[' · target tool_name="',s.target,'"']}):null,s.note?e.jsx("div",{className:"text-fg-faint",children:s.note}):null]})]}):null,r?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-fg-faint",children:["exit ",r.exitCode," · ",r.durationMs,"ms"]}),r.stdout?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stdout"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-fg whitespace-pre-wrap break-all max-h-40 overflow-auto",children:r.stdout})]}):null,r.stderr?e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint",children:"stderr"}),e.jsx("pre",{className:"bg-bg border border-line rounded p-2 font-mono text-red-300 whitespace-pre-wrap break-all max-h-40 overflow-auto",children:r.stderr})]}):null]}):null,e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:l,className:"px-2 py-0.5 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"close"}),e.jsx("button",{onClick:j,disabled:m||!!g||!o.trim(),className:"px-2 py-0.5 text-xs border border-line rounded text-fg hover:bg-bg-hi disabled:opacity-40 disabled:cursor-not-allowed",children:m?"running…":"run"})]})]})})}export{qe as Hooks};
@@ -1,3 +0,0 @@
1
- import{aw as d,aS as z,aM as H,aU as U,aN as N,aj as W,ao as q,ad as G,ah as e,m as w,P as D,aD as Q}from"./index-3_AtCAyd.js";import{P as A}from"./Panel-CC3JTnOI.js";import{S as X}from"./ScopeSwitcher-Cp5mxblN.js";import{S as Y}from"./SaveBar-C06rFT34.js";import{P as Z}from"./Library-DLmnlfQt.js";import{u as ee,E as te,s as se}from"./settingsSchema-CvoNk3Ye.js";import{V as re}from"./ViewTabs-T0NBc8uv.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-DC6VzovQ.js";import"./claude-settings-schema-COigsajx.js";const ne=["allow","deny","ask"];function oe(r){if(r.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(r);return{perms:n.permissions??{},full:n,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function ae(r,n){const o={...r,permissions:n};return JSON.stringify(o,null,2)+`
2
- `}function ie(){const r=z(),n=H(),o=(n==null?void 0:n.cwd)??null,s=U(t=>t.navFace),i=d.useRef(!1),u=d.useRef(s),[x,c]=d.useState(()=>s==="project"&&o?"project":"user"),[m,P]=d.useState("effective");d.useEffect(()=>{if(u.current!==s){if(u.current=s,i.current){i.current=!1;return}c(s==="project"&&o?"project":"user")}},[s,o]),d.useEffect(()=>{s==="project"&&m==="presets"&&P("effective")},[s,m]);const J=t=>{i.current=!0,c(t)},b=ee(D,r,o),f=b[x]??null,j=N(t=>t.files),E=N(t=>t.setDraft),M=N(t=>t.saveJson),O=N(t=>t.revert),[I,y]=d.useState(null),k=e.jsx(re,{options:[{key:"effective",label:"Effective"},{key:"rules",label:"Rules"},...s==="home"?[{key:"presets",label:"Presets"}]:[]],active:m,onChange:P}),$=d.useMemo(()=>{const t=W(q(j,b));return G(t,["permissions"])??{kind:"object",children:{}}},[j,b]),F=(t,l)=>{var R;const a=b[x];if(!a)return;y(null);const g=((R=j[a])==null?void 0:R.draftRaw)??"";let v={};if(g.trim())try{v=JSON.parse(g)}catch{v={}}const B=Q(v.permissions??{},t,l),K={...v,permissions:B};E(a,JSON.stringify(K,null,2)+`
3
- `)};if(!r)return e.jsx(w,{title:"loading…"});if(m==="presets")return e.jsx(A,{toolbar:k,children:e.jsx(Z,{})});const C=t=>t!=="user"&&!o,h=f?j[f]:null,{perms:p,full:L,err:T}=h?oe(h.draftRaw):{perms:{},full:{},err:null},S=t=>{f&&(y(null),E(f,ae(L,t)))},_=(t,l)=>{const a=l.trim();if(!a)return;const g=p[t]??[];g.includes(a)||S({...p,[t]:[...g,a]})},V=(t,l)=>{const a=p[t]??[];S({...p,[t]:a.filter((g,v)=>v!==l)})};return e.jsx(A,{toolbar:e.jsxs(e.Fragment,{children:[k,e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx(X,{scopes:D.scopes,active:x,onChange:J,annotate:t=>{if(C(t))return{exists:!1};const l=b[t];if(!l)return null;const a=j[l];return{exists:(a==null?void 0:a.exists)??!1,dirty:(a==null?void 0:a.dirty)??!1}}}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:f??"—"}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings#permissions",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"rule syntax ↗"})]}),footer:f&&h?e.jsx(Y,{dirty:h.dirty,busy:h.busy,parseError:I||T||h.parseError,lastSavedAt:h.lastSavedAt,onSave:async()=>{y(null);const t=await M(f);t.ok||y(t.error??"save failed")},onRevert:()=>{y(null),O(f)}}):null,children:C(x)?e.jsx(w,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):m==="effective"?e.jsx(te,{node:$,targetScope:x,onOverride:F,schema:se().rootedAt(["permissions"]),rootLabel:"permissions"}):f&&h?e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[e.jsx(le,{value:p.defaultMode??"default",onChange:t=>S({...p,defaultMode:t})}),ne.map(t=>e.jsx(ce,{list:t,rules:p[t]??[],onAdd:l=>_(t,l),onRemove:l=>V(t,l)},t)),e.jsx(de,{dirs:p.additionalDirectories??[],onChange:t=>S({...p,additionalDirectories:t})})]}):e.jsx(w,{title:"resolving…"})})}const ye=d.memo(ie);function le({value:r,onChange:n}){const o=["default","acceptEdits","plan","bypassPermissions"];return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Default Mode"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:o.map(s=>e.jsx("button",{onClick:()=>n(s),className:`px-2.5 py-1 text-xs transition-colors ${r===s?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:s},s))})]})}function ce({list:r,rules:n,onAdd:o,onRemove:s}){const[i,u]=d.useState(""),x=r==="allow"?"text-green-400":r==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${x}`,children:r}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:i,onChange:c=>u(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(o(i),u(""))},placeholder:r==="allow"?"e.g. Bash(ls:*) or Read(~/.claude/**)":"e.g. Write(/etc/**)",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"}),e.jsx("button",{onClick:()=>{o(i),u("")},disabled:!i.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((c,m)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:c}),e.jsx("button",{onClick:()=>s(m),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${m}-${c}`))})]})}function de({dirs:r,onChange:n}){const[o,s]=d.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:o,onChange:i=>s(i.target.value),onKeyDown:i=>{i.key==="Enter"&&o.trim()&&(n([...r,o.trim()]),s(""))},placeholder:"/absolute/path/to/dir",className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg placeholder-fg-faint"})}),e.jsx("ul",{className:"space-y-0.5",children:r.map((i,u)=>e.jsxs("li",{className:"flex items-center gap-2 text-xs font-mono bg-bg-elev border border-line rounded px-2 py-1",children:[e.jsx("span",{className:"flex-1 text-fg-dim truncate",children:i}),e.jsx("button",{onClick:()=>n(r.filter((x,c)=>c!==u)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${u}-${i}`))})]})}export{ye as Permissions};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./SkillReferenceGraph-DuWRmT_f.js","./index-3_AtCAyd.js","./monaco-editor-BsIlgG7c.js","./monaco-editor-Cu5D__1H.css","./index-tr1w3hHB.css"])))=>i.map(i=>d[i]);
2
- import{ah as e,aw as h,m as k,aS as X,aL as V,a as Y}from"./index-3_AtCAyd.js";import{P as W}from"./Panel-CC3JTnOI.js";import{P as z}from"./ProvenanceBadge-DaJIWVcg.js";import{u as Z}from"./useConfigDirWatch-Cd5PnTkB.js";import{e as ee}from"./Library-DLmnlfQt.js";import{p as G}from"./skillFrontmatter-Dif5JIg7.js";import{_ as te}from"./monaco-editor-BsIlgG7c.js";import{L as ne}from"./ListDetail-YylbvUj_.js";import{M as se}from"./MarkdownEditor-DMPKWHTF.js";import"./Button-DC6VzovQ.js";function ie({columns:t,rows:n,getKey:o,onRowClick:a,activeKey:i,empty:m}){return n.length===0?e.jsx("div",{className:"p-6 text-fg-faint text-xs text-center",children:m??"no entries"}):e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sticky top-0 bg-bg-elev text-fg-faint uppercase tracking-wider",children:e.jsx("tr",{className:"border-b border-line",children:t.map(l=>e.jsx("th",{className:`text-left font-normal px-3 py-1.5 ${l.className??""}`,style:l.width?{width:l.width}:void 0,children:l.header},l.key))})}),e.jsx("tbody",{children:n.map(l=>{const r=o(l),d=i===r;return e.jsx("tr",{"data-row-key":r,onClick:()=>a==null?void 0:a(l),className:`border-b border-line/50 transition-colors ${a?"cursor-pointer":""} ${d?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg-hi/50"}`,children:t.map(p=>e.jsx("td",{className:`px-3 py-1 ${p.className??""}`,children:p.render(l)},p.key))},r)})})]})}async function ae(t,n,o){var p,g;const a=`${n}/skills`;try{const c=await window.api.config.listDir(a,{dirsOnly:!0});if(c.ok&&c.entries.length>0)return a}catch{}let i=null;try{const c=await window.api.config.readJson(`${o}/.claude/plugins/installed_plugins.json`);c.exists&&!c.parseError&&c.data&&typeof c.data=="object"&&(i=c.data)}catch{return null}if(!(i!=null&&i.plugins))return null;const m=Object.keys(i.plugins).find(c=>c===t||c.startsWith(`${t}@`));if(!m)return null;const l=(g=(p=i.plugins[m])==null?void 0:p[0])==null?void 0:g.installPath;if(!l)return null;const r=`${l}/skills`;return await window.api.config.exists(r)?r:null}async function le(t){const n=await window.api.config.listDir(t,{dirsOnly:!0}),o=[];for(const a of n.entries){const i=`${a.path}/SKILL.md`,m=await window.api.config.readText(i);if(!m.exists)continue;const l=G(m.text);o.push({id:a.name,name:l.name,description:l.description,dir:a.path,path:i,body:l.body})}return o}function re(t){const n=[],o=new Set;for(const a of t)for(const i of t){if(a.id===i.id)continue;const m=i.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),l=[`/${m}\\b`,`\`${m}\``];if(i.id.length>=4&&l.push(`\\b${m}\\b`),!l.some(p=>new RegExp(p,"i").test(a.body)))continue;const d=`${a.id}->${i.id}`;o.has(d)||(o.add(d),n.push({from:a.id,to:i.id}))}return n}const oe=h.lazy(()=>te(()=>import("./SkillReferenceGraph-DuWRmT_f.js"),__vite__mapDeps([0,1,2,3,4]),import.meta.url).then(t=>({default:t.SkillReferenceGraph})));function ce({pluginName:t,skills:n,onBack:o,initialSelectedId:a}){var g;const[i,m]=h.useState(a??((g=n[0])==null?void 0:g.id)??null),l=i?n.find(c=>c.id===i)??null:null,r=h.useMemo(()=>re(n),[n]),[d,p]=h.useState("list");return e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsxs("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:["← ",t]}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:(l==null?void 0:l.name)??(l==null?void 0:l.id)??"skill"}),e.jsx("span",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs("div",{className:"flex rounded border border-line overflow-hidden",children:[e.jsx("button",{onClick:()=>p("list"),className:`px-2 py-0.5 text-xs ${d==="list"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"list"}),e.jsx("button",{onClick:()=>p("graph"),className:`px-2 py-0.5 text-xs ${d==="graph"?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:"graph"})]})})]}),e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[l!=null&&l.description?e.jsx("span",{className:"text-fg-dim truncate normal-case",children:l.description}):null,e.jsxs("span",{className:"ml-auto text-fg-faint truncate normal-case",children:[n.length," ",n.length===1?"skill":"skills"," · ",r.length," ",r.length===1?"reference":"references"]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:n.length===0?e.jsx(k,{title:"no skills in this plugin"}):d==="graph"?e.jsx(h.Suspense,{fallback:e.jsx("div",{className:"p-6 text-xs text-fg-faint",children:"Loading graph…"}),children:e.jsx(oe,{skills:n,edges:r,selectedId:i,onSelect:m})}):e.jsx(ne,{sidebar:e.jsx("div",{className:"py-1",children:n.map(c=>e.jsxs("button",{onClick:()=>m(c.id),className:`w-full px-3 py-1 text-xs text-left ${i===c.id?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("div",{className:"truncate",children:c.name??c.id}),c.description?e.jsx("div",{className:"truncate text-fg-faint",children:c.description}):null]},c.id))}),detail:l?e.jsx("div",{className:"h-full min-h-0",children:e.jsx(se,{path:l.path,value:l.body,onChange:()=>{},readOnly:!0})}):e.jsx(k,{title:"select a skill"})})})]})}const Q=t=>{var n,o;return{type:"plugin",name:t.name,repository:(n=t.manifest)==null?void 0:n.repository,homepage:(o=t.manifest)==null?void 0:o.homepage}};function de(){const t=X(),[n,o]=h.useState([]),[a,i]=h.useState(!0),[m,l]=h.useState(null),[r,d]=h.useState("installed"),[p,g]=h.useState(null),[c,E]=h.useState(new Set);h.useEffect(()=>{var x,v;let s=!1;return(v=(x=window.api.app).seedStatus)==null||v.call(x).then(j=>{s||g(j)}).catch(()=>{}),()=>{s=!0}},[]);const w=h.useRef(0),$=h.useCallback(async()=>{var v;const s=++w.current;if(!t)return;i(!0);const x=[];try{const j=await window.api.config.readJson(`${t}/.claude/plugins/installed_plugins.json`);if(j.exists&&!j.parseError&&j.data&&typeof j.data=="object"){const M=j.data;for(const[O,u]of Object.entries(M.plugins??{})){if(!Array.isArray(u))continue;const y=O.split("@")[0],I=O.split("@")[1];for(const b of u){if(!(b!=null&&b.installPath))continue;const R={name:y,path:b.installPath,isDirectory:!0,isFile:!1,mtimeMs:0,size:0},P=await pe(R);(v=P.manifest)!=null&&v.version||(P.manifest={...P.manifest??{},version:b.version}),P.marketplace=I,x.push(P)}}}}catch{}w.current===s&&(x.sort((j,M)=>j.name.localeCompare(M.name)),o(x),i(!1))},[t]);h.useEffect(()=>{$()},[$]),h.useEffect(()=>()=>{w.current+=1},[]),Z(t?[`${t}/.claude/plugins/installed_plugins.json`]:[],$);const D=[{key:"name",header:"name",render:s=>{var x;return e.jsxs("div",{style:{maxWidth:"16rem"},children:[e.jsx("div",{className:"truncate",children:s.name}),(x=s.manifest)!=null&&x.description?e.jsx("div",{className:"truncate text-fg-faint",title:s.manifest.description,children:s.manifest.description}):null]})},width:"16rem"},{key:"origin",header:"origin",render:s=>e.jsx(z,{interactive:!1,input:Q(s)}),width:"7rem"},{key:"version",header:"version",render:s=>{var x;return((x=s.manifest)==null?void 0:x.version)??e.jsx("span",{className:"text-fg-faint",children:"—"})},width:"6rem"},{key:"manifest",header:"manifest",render:s=>s.hasManifest?"plugin.json":e.jsx("span",{className:"text-fg-faint",children:"—"}),width:"8rem"},{key:"contents",header:"contents",render:s=>e.jsx("span",{className:"font-mono text-fg-faint text-xs",children:[s.agents>0?`${s.agents} agents`:null,s.skills>0?`${s.skills} skills`:null,s.hooks>0?`${s.hooks} hooks`:null,s.monitors>0?`${s.monitors} monitors`:null,s.binCount>0?`${s.binCount} bin`:null,s.hasLsp?"lsp":null,s.hasMcp?"mcp":null].filter(Boolean).join(" · ")||"—"})},{key:"path",header:"path",render:s=>e.jsx("span",{className:"font-mono text-fg-faint truncate",children:s.path})}],f=h.useMemo(()=>p?Object.keys(p).filter(s=>p[s].status==="exhausted"&&!c.has(s)):[],[p,c]),C=f.length>0?e.jsx(me,{seeders:f,seedStatus:p,onDismiss:s=>E(x=>new Set(x).add(s)),onOpenLibrary:()=>d("library")}):null;if(r==="library")return e.jsxs(W,{toolbar:e.jsx(q,{active:r,onChange:d}),children:[C,e.jsx(ee,{})]});const S=m?n.find(s=>s.path===m)??null:null;return e.jsxs(W,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(q,{active:r,onChange:d}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsxs("span",{className:"text-fg-faint",children:[n.length," plugins"]}),e.jsx("div",{className:"flex-1"}),e.jsx("span",{className:"text-fg-faint font-mono truncate",children:"~/.claude/plugins/installed_plugins.json"})]}),children:[C,a?e.jsx(k,{title:"scanning plugins…"}):S?e.jsx(he,{row:S,home:t,onBack:()=>l(null)},S.path):e.jsx("div",{className:"flex flex-col h-full",children:e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(ie,{columns:D,rows:n,getKey:s=>s.path,activeKey:m,onRowClick:s=>l(s.path),empty:e.jsxs(e.Fragment,{children:["no plugins installed",e.jsxs("div",{className:"mt-2 text-fg-faint",children:["drop a plugin into ",e.jsx("code",{children:"~/.claude/plugins/"})]})]})})})})]})}const Se=h.memo(de),K={"dev-plugin":"session-manager-dev plugin","scheduler-mcp":"Scheduler MCP server","agent-personas":"Agent personas (Architect, Dev Lead)"};function me({seeders:t,seedStatus:n,onDismiss:o,onOpenLibrary:a}){return e.jsx("div",{className:"shrink-0 flex flex-col gap-1.5 px-3 py-2 border-b border-line bg-yellow-950/20",children:t.map(i=>e.jsxs("div",{className:"flex items-start gap-2 text-xs text-yellow-300",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"font-medium",children:[K[i]," setup failed after retrying — manual fix needed"]}),i==="dev-plugin"?e.jsxs("div",{className:"text-yellow-400/80 mt-0.5",children:["Click ",e.jsx("button",{onClick:a,className:"underline hover:no-underline",children:"here"}),' to open the Library tab, then click Install next to "session-manager-dev".']}):e.jsx("div",{className:"text-yellow-400/80 mt-0.5 font-mono",children:n[i].fix})]}),e.jsx("button",{onClick:()=>o(i),className:"shrink-0 text-yellow-400/70 hover:text-yellow-300","aria-label":`Dismiss ${K[i]} warning`,children:"✕"})]},i))})}function q({active:t,onChange:n}){const o=[["installed","Installed"],["library","Library"]];return e.jsx("div",{className:"flex rounded border border-line overflow-hidden",role:"tablist","aria-label":"Plugins view",children:o.map(([a,i])=>e.jsx("button",{onClick:()=>n(a),role:"tab","aria-selected":t===a,className:`px-2 py-0.5 text-xs ${t===a?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},a))})}function he({row:t,home:n,onBack:o}){var x,v,j,M,O;const[a,i]=h.useState([]),[m,l]=h.useState([]),[r,d]=h.useState([]),[p,g]=h.useState([]),[c,E]=h.useState("skills"),[w,$]=h.useState(null),[D,f]=h.useState(!0);h.useEffect(()=>{if(!n)return;let u=!1;return(async()=>{f(!0);try{const[y,I,b,R]=await Promise.all([ae(t.name,t.path,n),F(`${t.path}/agents`,{filesOnly:!0}),t.hasMcp?window.api.config.readJson(`${t.path}/.mcp.json`):Promise.resolve(null),F(`${t.path}/bin`,{filesOnly:!0})]),P=y?await le(y):[],T=I.filter(N=>N.endsWith(".md")),U=await Promise.all(T.map(N=>window.api.config.readText(`${t.path}/agents/${N}`))),H=[];T.forEach((N,B)=>{const A=U[B];if(!A.exists)return;const _=G(A.text);H.push({id:N,name:_.name??N.replace(/\.md$/,""),description:_.description})});const J=[];if(b&&b.exists&&!b.parseError&&b.data&&typeof b.data=="object"){const N=b.data.mcpServers;if(N&&typeof N=="object")for(const[B,A]of Object.entries(N)){const _=A&&typeof A=="object"?A.command:void 0;J.push({id:B,name:B,description:typeof _=="string"?_:null})}}if(u)return;i(P),l(H),d(J),g(R),E(P.length>0?"skills":H.length>0?"agents":J.length>0?"mcp":t.hooks>0?"hooks":t.monitors>0?"monitors":t.hasLsp?"lsp":"files")}catch(y){if(u)return;V.error(`Failed to load plugin contents: ${y instanceof Error?y.message:String(y)}`),i([]),l([]),d([]),g([])}finally{u||f(!1)}})(),()=>{u=!0}},[t.path,t.name,t.hasMcp,t.hooks,t.monitors,t.hasLsp,n]);const C=[{key:"skills",label:"Skills",count:a.length},{key:"agents",label:"Agents",count:m.length},{key:"mcp",label:"MCP server",count:r.length},{key:"hooks",label:"Hooks",count:t.hooks},{key:"monitors",label:"Monitors",count:t.monitors},{key:"lsp",label:"LSP",count:t.hasLsp?1:0},{key:"files",label:"Bin",count:p.length}],S=(x=t.manifest)!=null&&x.author?typeof t.manifest.author=="string"?t.manifest.author:t.manifest.author.name??null:null,s=async u=>{const y=await window.api.shell.open({as:"external",url:u});y.ok||V.error(y.error??`Failed to open ${u}`)};return w?e.jsx(ce,{pluginName:((v=t.manifest)==null?void 0:v.name)??t.name,skills:a,initialSelectedId:w.id,onBack:()=>$(null)},w.id):e.jsxs("div",{className:"flex flex-col h-full min-h-0 overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 h-11 flex items-baseline gap-3.5 px-3 border-b border-line bg-bg",children:[e.jsx("button",{type:"button",onClick:o,className:"font-mono text-accent hover:underline shrink-0 text-xs",children:"← Plugins"}),e.jsx("span",{className:"font-serif text-[22px] text-fg shrink-0 truncate max-w-[16rem]",children:((j=t.manifest)==null?void 0:j.name)??t.name}),(M=t.manifest)!=null&&M.version?e.jsxs("span",{className:"font-mono text-fg-faint text-xs shrink-0",children:["v",t.manifest.version]}):null,(O=t.manifest)!=null&&O.description?e.jsx("span",{className:"text-fg-dim text-xs min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap",children:t.manifest.description}):e.jsx("span",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(z,{input:Q(t)}),t.hasMcp?e.jsx(Y,{tone:"accent",children:"MCP"}):null]})]}),t.manifest?e.jsxs("div",{className:"shrink-0 h-[26px] flex items-center gap-[18px] px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:[S?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"Author "}),S]}):null,t.manifest.license?e.jsxs("span",{className:"text-fg-dim truncate",children:[e.jsx("span",{className:"text-fg-faint",children:"License "}),t.manifest.license]}):null,t.manifest.homepage?e.jsxs("button",{onClick:()=>s(t.manifest.homepage),className:"text-accent hover:underline truncate normal-case",title:t.manifest.homepage,children:[e.jsx("span",{className:"text-fg-faint uppercase",children:"Homepage "}),t.manifest.homepage]}):null,e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})]}):e.jsx("div",{className:"shrink-0 h-[26px] flex items-center px-3 bg-bg-elev border-b border-line text-[9px] font-mono uppercase tracking-wide overflow-hidden",children:e.jsx("span",{className:"ml-auto text-fg-faint truncate normal-case",children:t.path})}),e.jsxs("div",{className:"flex-1 min-h-0 grid overflow-hidden",style:{gridTemplateColumns:"170px 1fr"},children:[e.jsx("div",{className:"min-h-0 overflow-auto bg-bg-elev border-r border-line py-1",children:C.map(u=>e.jsxs("button",{type:"button",disabled:u.count===0,onClick:()=>E(u.key),className:`w-full text-left px-3 py-1.5 text-xs flex items-center justify-between ${u.count===0?"text-fg-faint opacity-50 cursor-default":c===u.key?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:[e.jsx("span",{children:u.label}),u.count>0?e.jsx("span",{className:"font-mono text-fg-faint",children:u.count}):null]},u.key))}),e.jsx("div",{className:"min-h-0 overflow-auto",children:D?e.jsx(k,{title:"scanning…"}):e.jsx(fe,{active:c,row:t,skills:a,agents:m,mcpServers:r,files:p,onOpenSkill:$})})]})]})}function fe({active:t,row:n,skills:o,agents:a,mcpServers:i,files:m,onOpenSkill:l}){return t==="skills"?o.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:o.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description,onClick:()=>l(r)},r.id))}):t==="agents"?a.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:a.map((r,d)=>e.jsx(L,{n:d+1,name:r.name??r.id,description:r.description},r.id))}):t==="mcp"?i.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:i.map((r,d)=>e.jsx(L,{n:d+1,name:r.name,description:r.description},r.id))}):t==="hooks"?n.hooks===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.hooks} ${n.hooks===1?"hook":"hooks"} configured`,description:`${n.path}/hooks/hooks.json`})}):t==="monitors"?n.monitors===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:e.jsx(L,{n:1,name:`${n.monitors} ${n.monitors===1?"monitor":"monitors"} configured`,description:`${n.path}/monitors/monitors.json`})}):t==="lsp"?n.hasLsp?e.jsx("div",{children:e.jsx(L,{n:1,name:"LSP server enabled",description:`${n.path}/.lsp.json`})}):e.jsx(k,{title:"no components"}):m.length===0?e.jsx(k,{title:"no components"}):e.jsx("div",{children:m.map((r,d)=>e.jsx(L,{n:d+1,name:r,description:null},r))})}function L({n:t,name:n,description:o,onClick:a}){const i=a?"button":"div";return e.jsxs(i,{onClick:a,className:`w-full flex items-baseline gap-2.5 py-[9px] px-3 border-b border-line text-left min-w-0 ${a?"hover:bg-bg-hi cursor-pointer":""}`,children:[e.jsx("span",{className:"font-serif text-fg-faint text-xs shrink-0 w-6 text-right",children:String(t).padStart(2,"0")}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"font-mono font-semibold text-accent truncate",children:n}),o?e.jsx("div",{className:"text-fg-dim text-xs truncate",children:o}):null]})]})}async function pe(t){let n=`${t.path}/.claude-plugin/plugin.json`,o=await window.api.config.exists(n);o||(n=`${t.path}/plugin.json`,o=await window.api.config.exists(n));let a=null;if(o){const f=await window.api.config.readJson(n);f.exists&&!f.parseError&&f.data&&typeof f.data=="object"&&(a=f.data)}const[i,m,l,r]=await Promise.all([window.api.config.exists(`${t.path}/.lsp.json`),window.api.config.exists(`${t.path}/.mcp.json`),window.api.config.exists(`${t.path}/monitors/monitors.json`),window.api.config.exists(`${t.path}/hooks/hooks.json`)]);let d=0;if(l){const f=await window.api.config.readJson(`${t.path}/monitors/monitors.json`);Array.isArray(f.data)?d=f.data.length:f.data&&typeof f.data=="object"&&Array.isArray(f.data.monitors)&&(d=f.data.monitors.length)}let p=0;if(r){const f=await window.api.config.readJson(`${t.path}/hooks/hooks.json`);if(f.data&&typeof f.data=="object"){const C=f.data;p=Object.values(C).reduce((S,s)=>Array.isArray(s)?S+s.reduce((x,v)=>x+(Array.isArray(v.hooks)?v.hooks.length:0),0):S,0)}}const[g,c,E]=await Promise.all([F(`${t.path}/agents`,{filesOnly:!0}),F(`${t.path}/bin`,{filesOnly:!0}),F(`${t.path}/skills`,{dirsOnly:!0})]),w=g.filter(f=>f.endsWith(".md")).length,$=c.length,D=E.length;return{name:t.name,path:t.path,mtimeMs:t.mtimeMs,hasManifest:o,manifest:a,hasLsp:i,monitors:d,hooks:p,agents:w,skills:D,binCount:$,hasMcp:m}}async function F(t,n){try{return(await window.api.config.listDir(t,n)).entries.map(a=>a.name)}catch{return[]}}export{Se as Plugins};
@@ -1 +0,0 @@
1
- import{_ as P,aS as G,aw as x,ah as i,Z as _,B as R,a as T}from"./index-3_AtCAyd.js";import{a as S,C as B,c as E,d as L,b as I}from"./Library-DLmnlfQt.js";const O=e=>`${e}/.claude/session-manager/provenance.json`;function D(e){if(!e||typeof e!="object")return{};const t={};for(const[n,o]of Object.entries(e))(o==="anthropic"||o==="community"||o==="local")&&(t[n]=o);return t}const K=P((e,t)=>({overrides:{},loaded:!1,loading:!1,home:null,load:async n=>{const o=t();if(!(o.home===n&&(o.loaded||o.loading))){e({home:n,loading:!0});try{const r=await window.api.config.readJson(O(n)),d=r.exists?D(r.data):{};e(h=>({overrides:{...d,...h.overrides},loaded:!0,loading:!1}))}catch{e({loaded:!0,loading:!1})}}},setOverride:async(n,o)=>{const r={...t().overrides};o===null?delete r[n]:r[n]=o,e({overrides:r});const d=t().home;if(d)try{await window.api.config.writeJson(O(d),r)}catch{}}})),a=e=>(e??"").toLowerCase().trim(),j=new Set,$=new Set;for(const e of I){const t=e.official?j:$;t.add(a(e.id)),t.add(a(e.name))}const H=new Set(L.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),J=new Set(L.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),U=new Set(E.filter(e=>e.official).flatMap(e=>[a(e.id),a(e.name)])),V=new Set(E.filter(e=>!e.official).flatMap(e=>[a(e.id),a(e.name)])),z=new Set(B.flatMap(e=>[a(e.id),a(e.name)])),Z=new Set(S.flatMap(e=>[a(e.id),a(e.name)])),q=new Set(S.map(e=>e.command.trim())),F=new Set(["security-review","pr-comments","release-notes","add-dir","code-review","simplify"]),Q=/(@anthropic-ai\/|anthropic\.com|github\.com\/anthropics)/i,W=/(^|\s)(npx|uvx|pipx|bunx|mcp-remote|deno\s+run|docker\s+run)(\s|$)/i;function X(e){return[e.command,...e.args??[],e.url,e.repository,e.homepage].filter(Boolean).join(" ").toLowerCase()}const l=e=>({provenance:"anthropic",reason:e}),w=e=>({provenance:"community",reason:e});function Y(e,t,n){switch(e){case"mcp":return j.has(t)?l("official MCP server (catalog)"):$.has(t)?w("third-party server (catalog)"):null;case"skill":case"command":return H.has(t)?l("official Anthropic skill (catalog)"):J.has(t)?w("third-party skill (catalog)"):null;case"plugin":return U.has(t)?l("official Anthropic plugin (catalog)"):V.has(t)?w("third-party plugin (catalog)"):null;case"subagent":return z.has(t)?l("bundled Anthropic subagent (catalog)"):null;case"hook":return Z.has(t)||n&&q.has(n.trim())?l("bundled hook (catalog)"):null}}function ee(e,t){return e.repository?"has a source repository":e.homepage?"has a homepage":e.url?"remote endpoint":W.test(t)?"installed from a package registry":null}function te(e){const t=a(e.name),n=X(e),o=Y(e.type,t,e.command);if(o)return o;if((e.type==="command"||e.type==="skill")&&F.has(t))return l("built-in Claude Code command");if(Q.test(n))return l("Anthropic package or repo");const r=ee(e,n);return r?w(r):{provenance:"local",reason:"no external source — assumed self-created"}}function ne(e,t,n){return`${e}:${t??"-"}:${n}`}const c={anthropic:"Anthropic",community:"Community",local:"Local"},N={anthropic:"accent",community:"warn",local:"dim"},oe=["anthropic","community","local"];function se({input:e,scope:t,interactive:n=!0,className:o=""}){const r=G(),{overrides:d,load:h,setOverride:k}=K(),[y,m]=x.useState(!1),v=x.useRef(null);x.useEffect(()=>{r&&h(r)},[r,h]),x.useEffect(()=>{if(!y)return;const s=C=>{v.current&&!v.current.contains(C.target)&&m(!1)},g=C=>{C.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",s),window.addEventListener("keydown",g),()=>{window.removeEventListener("mousedown",s),window.removeEventListener("keydown",g)}},[y]);const b=ne(e.type,t??null,e.name),f=te(e),p=d[b],u=p??f.provenance,M=p?`Origin manually set to ${c[u]} — auto-detected ${c[f.provenance]} (${f.reason})`:`Auto-detected ${c[u]}: ${f.reason}`,A=i.jsxs(T,{tone:N[u],title:M,className:`${n?"cursor-pointer hover:brightness-125":""} ${o}`,children:[c[u],p&&i.jsx("span",{className:"w-1 h-1 rounded-full bg-current opacity-70","aria-hidden":!0})]});return n?i.jsxs("span",{ref:v,className:"relative inline-flex",children:[i.jsx("button",{type:"button",onClick:s=>{s.stopPropagation(),m(g=>!g)},className:"inline-flex","aria-label":`Origin: ${c[u]}. Click to change.`,children:A}),y&&i.jsxs("span",{className:`absolute ${_.dialog} top-full right-0 mt-1 min-w-[7.5rem] rounded-md border border-line bg-bg-elev shadow-lg py-1 text-left`,onClick:s=>s.stopPropagation(),children:[i.jsx("span",{className:"block px-2 pb-1 text-[10px] uppercase tracking-wide text-fg-faint",children:"Mark origin as"}),oe.map(s=>i.jsxs("button",{type:"button",onClick:()=>{k(b,s),m(!1)},className:`flex w-full items-center gap-2 px-2 py-1 text-[12px] hover:bg-bg-hi/60 ${u===s?"text-fg":"text-fg-dim"}`,children:[i.jsx("span",{className:`w-2 h-2 rounded-full border ${R[N[s]]}`,"aria-hidden":!0}),c[s],p===s&&i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:"set"})]},s)),i.jsx("div",{className:"my-1 border-t border-line"}),i.jsxs("button",{type:"button",onClick:()=>{k(b,null),m(!1)},disabled:!p,className:"flex w-full items-center gap-2 px-2 py-1 text-[12px] text-fg-dim hover:bg-bg-hi/60 disabled:opacity-40 disabled:hover:bg-transparent",title:`Revert to auto-detection (${c[f.provenance]})`,children:["Auto-detect",i.jsx("span",{className:"ml-auto text-[10px] text-fg-faint",children:c[f.provenance]})]})]})]}):A}export{se as P};