claude-code-session-manager 0.130.2 → 0.131.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 (88) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/bin/cli.cjs +19 -2
  3. package/dist/assets/AgentLibrary-CYXre0J-.js +2 -0
  4. package/dist/assets/{AppSettings-Bpwynea4.js → AppSettings-xNSfCj8e.js} +2 -2
  5. package/dist/assets/{Button-DSoqrxCB.js → Button-BWljh5IK.js} +1 -1
  6. package/dist/assets/DocumentEditorPane-FUC2hZlp.js +1 -0
  7. package/dist/assets/Extensions-CsyUoklz.js +2 -0
  8. package/dist/assets/{History-DzMo9Otn.js → History-BvNmY9OQ.js} +2 -2
  9. package/dist/assets/{Library-C5wKMTSn.js → Library-DVXk77zA.js} +12 -12
  10. package/dist/assets/{ListDetail-DDQ1S0yu.js → ListDetail-DAAx__24.js} +1 -1
  11. package/dist/assets/{Panel-B-3NWUlv.js → Panel-g2D-e-RM.js} +1 -1
  12. package/dist/assets/ProjectClaudeConfig-BDuHJwaO.js +25 -0
  13. package/dist/assets/{ProvenanceBadge-CUChwz4Z.js → ProvenanceBadge-wew4_nf3.js} +1 -1
  14. package/dist/assets/Scheduler-CbeUIqD-.js +16 -0
  15. package/dist/assets/Settings-B23RsRfm.js +2 -0
  16. package/dist/assets/{SkillReferenceGraph-C6JEdypC.js → SkillReferenceGraph-BxQPCfsg.js} +1 -1
  17. package/dist/assets/Skills-4AR2FQrI.js +29 -0
  18. package/dist/assets/{SourceChip-DcBNYYhe.js → SourceChip-jrC0vjfw.js} +1 -1
  19. package/dist/assets/SystemPrompt-hHoBEnYb.js +1 -0
  20. package/dist/assets/{TiptapBody-DiVYC-_O.js → TiptapBody-FkUqxO9u.js} +1 -1
  21. package/dist/assets/{Toggle-Cs3k6I96.js → Toggle-DQMNWZKT.js} +1 -1
  22. package/dist/assets/ViewTabs-DGU0ZuxB.js +1 -0
  23. package/dist/assets/{VoiceButton-C3NLotUZ.js → VoiceButton-BPPvDllh.js} +1 -1
  24. package/dist/assets/{historyTotals-f-E0L9Xw.js → historyTotals-D8Oc3wUK.js} +1 -1
  25. package/dist/assets/index-9ajPMXBg.js +3097 -0
  26. package/dist/assets/{index-Bp8XE9A6.css → index-oXqzajWV.css} +1 -1
  27. package/dist/index.html +2 -2
  28. package/dist-web/app.css +1 -1
  29. package/dist-web/app.js +455 -427
  30. package/package.json +1 -1
  31. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  32. package/plugins/session-manager-dev/skills/maintaining-md-network/drift-check.md +15 -5
  33. package/plugins/session-manager-dev/skills/maintaining-md-network/scripts/drift-check.cjs +8 -4
  34. package/scripts/scheduler-mcp-server.cjs +71 -0
  35. package/src/main/agentLibrary.cjs +81 -29
  36. package/src/main/agentsIpc.cjs +21 -16
  37. package/src/main/build-info.json +4 -4
  38. package/src/main/index.cjs +9 -0
  39. package/src/main/ipcSchemas.cjs +35 -2
  40. package/src/main/lib/epic/epicMint.cjs +61 -6
  41. package/src/main/lib/epic/epicWorktreeMerge.cjs +11 -9
  42. package/src/main/lib/epic/epicWorktreeMint.cjs +45 -4
  43. package/src/main/lib/epic/promptSessionsCreateEpic.cjs +32 -5
  44. package/src/main/lib/epic/restorableSessions.cjs +749 -0
  45. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +61 -0
  46. package/src/main/lib/feedback-remote/remoteIpcDispatch.cjs +4 -0
  47. package/src/main/lib/git/branchSweep.cjs +9 -3
  48. package/src/main/lib/git/gitExec.cjs +8 -1
  49. package/src/main/lib/git/gitWorktree.cjs +771 -96
  50. package/src/main/lib/git/jobWorktree.cjs +3 -0
  51. package/src/main/lib/git/jobWorktreeBootLive.cjs +14 -2
  52. package/src/main/lib/mcpToolCatalog.cjs +28 -0
  53. package/src/main/lib/mcpToolsProbe.cjs +831 -0
  54. package/src/main/lib/mdNetworkScan.cjs +555 -0
  55. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +18 -5
  56. package/src/main/lib/persona-macro/builtinMacros.cjs +22 -4
  57. package/src/main/lib/persona-macro/macroJobDispatch.cjs +17 -2
  58. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +38 -0
  59. package/src/main/lib/project-pages/competitiveMatrix.cjs +258 -0
  60. package/src/main/lib/project-pages/matrixHtml.cjs +239 -0
  61. package/src/main/lib/project-pages/matrixStore.cjs +112 -0
  62. package/src/main/lib/promptSessionSchema.cjs +5 -0
  63. package/src/main/lib/scheduler/fixPlanSlug.cjs +15 -1
  64. package/src/main/lib/scheduler/reaperHelpers.cjs +35 -0
  65. package/src/main/lib/scheduler/scheduleJobSchema.cjs +2 -0
  66. package/src/main/lib/scheduler/scheduleJobTransitions.cjs +8 -7
  67. package/src/main/lib/scheduler/terminalRunOutcome.cjs +61 -15
  68. package/src/main/projectPages.cjs +51 -7
  69. package/src/main/runVerify.cjs +8 -3
  70. package/src/main/scheduler/budget.cjs +146 -7
  71. package/src/main/scheduler/gitTreeGuard.cjs +92 -20
  72. package/src/main/scheduler/reviewLadder.cjs +60 -0
  73. package/src/main/scheduler.cjs +477 -53
  74. package/src/main/seedAgentPersonas.cjs +1 -1
  75. package/src/preload/api.d.ts +250 -7
  76. package/src/preload/apiSurface.json +28 -0
  77. package/src/preload/index.cjs +6 -0
  78. package/src/seed/agents/competitive-analyst.md +69 -0
  79. package/src/seed/agents/competitive-researcher.md +75 -0
  80. package/src/seed/agents/validator.md +2 -2
  81. package/dist/assets/AgentLibrary-Bfj862qf.js +0 -2
  82. package/dist/assets/Extensions-BziIutWV.js +0 -13
  83. package/dist/assets/Memory-Bq5T33d2.js +0 -25
  84. package/dist/assets/Scheduler-CkGHMXvo.js +0 -16
  85. package/dist/assets/Settings-DGxvyajs.js +0 -2
  86. package/dist/assets/SystemPrompt-CfozyVQx.js +0 -1
  87. package/dist/assets/ViewTabs-DFXH03tb.js +0 -1
  88. package/dist/assets/index-CuAfFXNd.js +0 -3086
@@ -0,0 +1,2 @@
1
+ import{b8 as T,ax as e,b4 as R,aN as y,be as L,b5 as V,bg as z,bn as H,w as le,l as C,a4 as ce,v as de,T as Y,S,a as ue,bp as B,bj as pe,aB as me,aF as xe,J as he,as as fe}from"./index-9ajPMXBg.js";import{P as F}from"./Panel-g2D-e-RM.js";import{P as ge,H as be,S as ye}from"./Library-DVXk77zA.js";import{S as I}from"./SourceChip-jrC0vjfw.js";import{V as U}from"./ViewTabs-DGU0ZuxB.js";import{r as Z}from"./claude-settings-schema-COigsajx.js";import{L as je}from"./ListDetail-DAAx__24.js";import{a as ve}from"./ProvenanceBadge-wew4_nf3.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BWljh5IK.js";function ke(t){const s=t??{},n={...s.$defs??{},...s.definitions??{}},r=i=>{if(!i)return{};if(!i.$ref)return l(i);const u=/^#\/(\$defs|definitions)\/(.+)$/.exec(i.$ref);if(!u)return l(i);const h=n[u[2]];return h?r({...h,...p(i)}):l(i)},a=new Set(["__proto__","constructor","prototype"]),o=i=>{if(!i)return{};const u={};for(const[h,f]of Object.entries(i))a.has(h)||(u[h]=f);return u},l=i=>{if(!i.allOf||i.allOf.length===0)return i;const u={...i};delete u.allOf;for(const h of i.allOf){const f=r(h);Object.assign(u,{properties:{...o(u.properties),...o(f.properties)},required:we([...u.required??[],...f.required??[]])}),!u.description&&f.description&&(u.description=f.description),u.default===void 0&&f.default!==void 0&&(u.default=f.default),!u.type&&f.type&&(u.type=f.type)}return u},p=i=>{const{$ref:u,...h}=i;return h},d=(i,u)=>{let h=r(i);for(const f of u){if(!h)return null;if(/^\d+$/.test(f)){const k=Array.isArray(h.items)?h.items[Number(f)]:h.items;h=k?r(k):null;continue}const N=h.properties;if(N&&!a.has(f)&&f in N){h=r(N[f]);continue}const g=h.additionalProperties;if(g&&typeof g=="object"){h=r(g);continue}return null}return h},c=(i,u,h)=>{if(!i)return null;const f={};if(i.description&&(f.description=i.description),i.type&&(f.type=i.type),i.default!==void 0&&(f.default=i.default),i.enum&&(f.enum=i.enum),i.const!==void 0&&(f.const=i.const),i.deprecated&&(f.deprecated=!0),i.examples&&(f.examples=i.examples),i.properties&&(f.knownChildren=Object.keys(i.properties)),h&&(u!=null&&u.includes(h))&&(f.required=!0),i.items&&!Array.isArray(i.items)){const N=r(i.items),g=c(N,void 0,null);g&&(f.itemsInfo=g)}return(i.additionalProperties===!0||typeof i.additionalProperties=="object")&&(f.open=!0),f},x=i=>u=>{if(u.length===0)return c(r(i),void 0,null);const h=d(i,u.slice(0,-1));if(!h)return null;const f=u[u.length-1],N=d(h,[f]);return c(N,h.required,f)},v=i=>{const u=r(i);return Object.keys(u.properties??{})},j=i=>({at:x(i),rootKeys:()=>v(i),rootedAt:u=>{const h=d(i,u);return j(h??{})}});return j(s)}function we(t){return Array.from(new Set(t))}let D=null;function Q(){return D||(D=ke(Z)),D}const Ne=["allow","deny","ask"],K="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function Se(t){if(t.trim()==="")return{perms:{},full:{},err:null};try{const s=JSON.parse(t);if(s===null||typeof s!="object"||Array.isArray(s))return{perms:{},full:{},err:"settings file is not a JSON object"};const n=s;return{perms:n.permissions??{},full:n,err:null}}catch(s){return{perms:{},full:{},err:s.message}}}function Ce({scope:t="user"}={}){const s=L(),n=V(),r=(n==null?void 0:n.cwd)??null,a=z(i=>i.navFace),[o,l]=y.useState("rules");y.useEffect(()=>{a==="project"&&o==="presets"&&l("rules")},[a,o]);const d=H(le,s,r)[t]??null,c=T(i=>i.files),x=e.jsx(U,{options:[{key:"rules",label:"Rules"},...a==="home"?[{key:"presets",label:"Presets"}]:[]],active:o,onChange:l});if(!s)return e.jsx(C,{title:"loading…"});if(o==="presets")return e.jsx(F,{toolbar:x,children:e.jsx(ge,{})});const v=i=>i!=="user"&&!r,j=d?c[d]:null;return e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[x,e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:d??"—"}),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 ↗"})]}),children:v(t)?e.jsx(C,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):d&&j?e.jsx(X,{scope:t,cwd:r,activePath:d}):e.jsx(C,{title:"resolving…"})})}y.memo(Ce);function X({scope:t,cwd:s,activePath:n}){const r=T(c=>c.files[n]),{perms:a,err:o}=r?Se(r.draftRaw):{perms:{},err:null},l=(c,x)=>{if(o){R.error(K);return}window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:s,keyPath:["permissions",c],value:x}).catch(v=>R.error(v instanceof Error?v.message:String(v)))},p=(c,x)=>{const v=x.trim();if(!v)return;const j=a[c]??[];j.includes(v)||l(c,[...j,v])},d=(c,x)=>{const v=a[c]??[];l(c,v.filter((j,i)=>i!==x))};return e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[o&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[K," (",o,")"]}),e.jsx(_e,{value:a.defaultMode??"default",onChange:c=>l("defaultMode",c)}),Ne.map(c=>e.jsx(Ee,{list:c,rules:a[c]??[],disabled:!!o,onAdd:x=>p(c,x),onRemove:x=>d(c,x)},c)),e.jsx(Pe,{dirs:a.additionalDirectories??[],disabled:!!o,onChange:c=>l("additionalDirectories",c)})]})}function _e({value:t,onChange:s}){var o;const r=(((o=Q().at(["permissions","defaultMode"]))==null?void 0:o.enum)??[]).filter(l=>typeof l=="string"),a=t&&!r.includes(t)?[...r,t]:r;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:a.map(l=>e.jsx("button",{onClick:()=>s(l),className:`px-2.5 py-1 text-xs transition-colors ${t===l?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:l},l))})]})}function Ee({list:t,rules:s,onAdd:n,onRemove:r,disabled:a}){const[o,l]=y.useState(""),p=t==="allow"?"text-green-400":t==="deny"?"text-red-400":"text-yellow-400";return e.jsxs("section",{children:[e.jsx("h3",{className:`text-xs uppercase tracking-wider mb-2 ${p}`,children:t}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:o,disabled:a,onChange:d=>l(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(n(o),l(""))},placeholder:t==="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:()=>{n(o),l("")},disabled:a||!o.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"})]}),s.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:s.map((d,c)=>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:d}),e.jsx("button",{onClick:()=>r(c),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${c}-${d}`))})]})}function Pe({dirs:t,onChange:s,disabled:n}){const[r,a]=y.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:r,disabled:n,onChange:o=>a(o.target.value),onKeyDown:o=>{o.key==="Enter"&&r.trim()&&(s([...t,r.trim()]),a(""))},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:t.map((o,l)=>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:o}),e.jsx("button",{onClick:()=>s(t.filter((p,d)=>d!==l)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${l}-${o}`))})]})}const Te={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 }"}},ee=["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"],Fe=new Set(ee),Oe=["command","http","prompt","agent","mcp_tool"],Ae={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:{}},J="This settings file has invalid JSON. Fix it in the Settings raw editor first; Hooks will not overwrite it.";function Me(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const s=JSON.parse(t);if(s===null||typeof s!="object"||Array.isArray(s))return{full:{},hooks:{},err:"settings file is not a JSON object"};const n=s;return{full:n,hooks:n.hooks??{},err:null}}catch(s){return{full:{},hooks:{},err:s.message}}}function Re(t,s){return(t[s]??[]).reduce((n,r)=>{var a;return n+(((a=r.hooks)==null?void 0:a.length)??0)},0)}function $e({scope:t="user"}={}){const s=L(),n=V(),r=(n==null?void 0:n.cwd)??null,a=z(x=>x.navFace),[o,l]=y.useState("events");y.useEffect(()=>{a==="project"&&o==="library"&&l("events")},[a,o]);const d=H(Y,s,r)[t]??null,c=e.jsx(U,{options:[{key:"events",label:"Events"},...a==="home"?[{key:"library",label:"Library"}]:[]],active:o,onChange:l});return s?o==="library"?e.jsx(F,{toolbar:c,children:e.jsx(be,{})}):t!=="user"&&!r?e.jsx(F,{toolbar:e.jsx(e.Fragment,{children:c}),children:e.jsx(C,{title:"no active project"})}):d?e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[c,e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:d}),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 ↗"})]}),children:e.jsx(te,{scope:t,cwd:r,path:d})}):e.jsx(C,{title:"loading…"}):e.jsx(C,{title:"loading…"})}function te({scope:t,cwd:s,path:n}){const[r,a]=y.useState("PreToolUse"),[o,l]=y.useState(null),p=(g,k)=>{window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:s,keyPath:g,value:k}).catch(m=>R.error(m instanceof Error?m.message:String(m)))},d=T(g=>g.files[n]),{hooks:c,err:x}=d?Me(d.draftRaw):{hooks:{},err:null},v=Object.keys(c).filter(g=>!Fe.has(g)),j=v.reduce((g,k)=>g+(c[k]??[]).reduce((m,b)=>{var w;return m+(((w=b.hooks)==null?void 0:w.length)??0)},0),0),i=(g,k)=>{if(x){R.error(J);return}p(["hooks",g],k)},u=c[r]??[],h=()=>{i(r,[...u,{matcher:"",hooks:[{type:"command",command:""}]}])},f=(g,k)=>{const m=u.slice();m[g]=k,i(r,m)},N=g=>{i(r,u.filter((k,m)=>m!==g))};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col h-full",children:[x?e.jsxs("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:[J," (",x,")"]}):null,j>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:"⚠"})," ",j," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:v.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(je,{sidebarWidth:"14rem",sidebar:e.jsx("div",{className:"py-1",children:ee.map(g=>{const k=Re(c,g),m=Te[g],b=m?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:m.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",m.payload]}),m.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",m.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(ce,{content:b,align:"bottom-center",children:e.jsxs("button",{onClick:()=>a(g),title:m==null?void 0:m.when,className:`w-full text-left px-3 py-1 text-xs ${r===g?"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:g}),k>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:k})]}),m?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:m.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},g)})}),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:h,disabled:!!x,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",children:"+ add group"})]}),u.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):u.map((g,k)=>e.jsx(Ie,{group:g,jsonInvalid:!!x,onChange:m=>f(k,m),onRemove:()=>N(k),onTestFire:m=>l({event:r,matcher:g.matcher??"",command:m.command??""})},k))]})})]}),o?e.jsx(Be,{event:o.event,matcher:o.matcher,command:o.command,onClose:()=>l(null)}):null]})}y.memo($e);function M({value:t,onCommit:s,onDraft:n,...r}){const[a,o]=y.useState(t);y.useEffect(()=>o(t),[t]);const l=()=>{a!==t&&s(a)};return e.jsx("input",{...r,value:a,onChange:p=>{o(p.target.value),n==null||n(p.target.value)},onBlur:l,onKeyDown:p=>{p.key==="Enter"&&l()}})}function Ie({group:t,jsonInvalid:s,onChange:n,onRemove:r,onTestFire:a}){const o=()=>n({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),l=(d,c)=>{const x=t.hooks.slice();x[d]=c,n({...t,hooks:x})},p=d=>n({...t,hooks:t.hooks.filter((c,x)=>x!==d)});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(M,{value:t.matcher??"",disabled:s,onCommit:d=>n({...t,matcher:d}),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:r,disabled:s,className:"text-fg-faint hover:text-red-400 text-xs disabled:opacity-40",title:"remove group",children:"× group"})]}),(t.hooks??[]).map((d,c)=>e.jsx(Le,{rule:d,jsonInvalid:s,onChange:x=>l(c,x),onRemove:()=>p(c),onTestFire:()=>a(d)},c)),e.jsx("button",{onClick:o,disabled:s,className:"text-xs text-fg-faint hover:text-fg disabled:opacity-40",children:"+ add hook"})]})}function De(t){var n,r,a;const s=((r=(n=Z.$defs)==null?void 0:n.hookCommand)==null?void 0:r.anyOf)??[];for(const o of s){const l=o.properties;if(((a=l==null?void 0:l.type)==null?void 0:a.const)!==t)continue;const p=l.timeout;if(typeof(p==null?void 0:p.default)=="number")return p.default;const d=/default:\s*(\d+)/.exec((p==null?void 0:p.description)??"");return d?Number(d[1]):null}return null}function G(t){return/^\d+$/.test(t.trim())&&Number(t)>0?Number(t):null}function Le({rule:t,jsonInvalid:s,onChange:n,onRemove:r,onTestFire:a}){const o=i=>({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"})[i],l=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",p=t[l]??"",d=(t.args??[]).join(" "),[c,x]=y.useState(null),v=De(t.type),j={type:"hook",name:p||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,disabled:s,onChange:i=>n({type:i.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:Oe.map(i=>e.jsx("option",{value:i,children:i},i))}),e.jsx(ve,{interactive:!1,input:j}),e.jsx(M,{value:p,disabled:s,onCommit:i=>n({...t,[l]:i}),placeholder:o(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${s?"border-red-500/70":p.trim()?"border-line":"border-yellow-600/50"}`}),s?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(M,{value:t.timeout!=null?String(t.timeout):"",disabled:s,"aria-label":"timeout (seconds)","aria-invalid":c?!0:void 0,title:c??"Timeout in seconds",onDraft:i=>{x(!i.trim()||G(i)!=null?null:"Timeout must be a positive whole number of seconds")},onCommit:i=>{if(!i.trim()){n({...t,timeout:void 0});return}const u=G(i);u!=null&&n({...t,timeout:u})},placeholder:v!=null?`${v} (seconds)`:"seconds",className:`w-24 bg-bg border rounded px-2 py-0.5 text-xs text-fg ${c?"border-red-500/70":"border-line"}`}),c?e.jsx("span",{role:"alert",className:"text-red-400 text-xs",children:c}):null,t.type==="command"?e.jsx("button",{onClick:a,disabled:s||!p.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:r,disabled:s,className:"text-fg-faint hover:text-red-400 text-xs disabled:opacity-40",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(M,{value:d,disabled:s,onCommit:i=>n({...t,args:i.trim()?i.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(M,{value:t.terminalSequence??"",disabled:s,onCommit:i=>n({...t,terminalSequence:i||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 He(t){return JSON.stringify(Ae[t]??{},null,2)}function Ue(t,s){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const n=s&&typeof s=="object"&&"tool_name"in s?String(s.tool_name??""):null;if(n==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(n),target:n}}catch{return{matched:t===n,target:n,note:"matcher not valid regex; fell back to exact match"}}}function Be({event:t,matcher:s,command:n,onClose:r}){const[a,o]=y.useState(()=>He(t)),[l,p]=y.useState(!1),[d,c]=y.useState(null),[x,v]=y.useState(null);let j=null;try{JSON.parse(a)}catch(u){j=u.message}const i=async()=>{p(!0),c(null);let u=null;try{u=JSON.parse(a)}catch{}v(Ue(s,u));try{const h=await window.api.app.testFireHook({command:n,payload:a,timeoutMs:5e3});c(h)}finally{p(!1)}};return e.jsx(de,{open:!0,onClose:r,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:n})]}),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:s||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)"}),j?e.jsxs("span",{className:"text-red-400",children:["× ",j]}):null]}),e.jsx("textarea",{value:a,onChange:u=>o(u.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${j?"border-red-500/70":"border-line"}`})]}),x?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:x.matched?"text-green-400":"text-red-400",children:x.matched?"✓ match":"✗ no match"}),x.target!=null?e.jsxs("span",{className:"text-fg-dim",children:[' · target tool_name="',x.target,'"']}):null,x.note?e.jsx("div",{className:"text-fg-faint",children:x.note}):null]})]}):null,d?e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"text-fg-faint",children:["exit ",d.exitCode," · ",d.durationMs,"ms"]}),d.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:d.stdout})]}):null,d.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:d.stderr})]}):null]}):null,e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:r,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:i,disabled:l||!!j||!n.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:l?"running…":"run"})]})]})})}const se=[{id:"permissions",label:"Permissions",tab:"permissions",keys:["permissions"]},{id:"hooks",label:"Hooks",tab:"hooks",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",label:"MCP Servers",tab:null,keys:["enabledMcpjsonServers","disabledMcpjsonServers","enableAllProjectMcpServers"]},{id:"plugins",label:"Plugins",tab:null,keys:["enabledPlugins"]}],q=new Set(se.flatMap(t=>t.keys)),Ke=[{id:"essentials",title:"Essentials",summary:"The knobs you reach for first.",keys:["model","language","outputStyle"]},{id:"git",title:"Git & Commits",summary:"How Claude writes commits and pull requests on your behalf.",keys:["attribution","includeGitInstructions","includeCoAuthoredBy"]},{id:"memory",title:"Memory & Plans",summary:"Context Claude keeps between sessions and where it files plans.",keys:["autoMemoryEnabled","plansDirectory","claudeMdExcludes","respectGitignore"]},{id:"model",title:"Model & Reasoning",summary:"Model allow/override lists, reasoning depth, and fast-mode toggles — machine-wide, with no per-Epic override yet. An Epic's Agent persona model (Agent Library) still wins over Essentials' plain model default.",advanced:!0,keys:["availableModels","modelOverrides","effortLevel","fastMode","fastModePerSessionOptIn","alwaysThinkingEnabled","fallbackModel","enforceAvailableModels","teammateDefaultModel","advisorModel"]},{id:"interface",title:"Interface",summary:"Visual polish — spinners, progress bars, motion.",keys:["spinnerTipsEnabled","spinnerTipsOverride","spinnerVerbs","terminalProgressBarEnabled","showTurnDuration","prefersReducedMotion","companyAnnouncements","statusLine","teammateMode"]},{id:"updates",title:"Updates & Cleanup",summary:"Release channel and how long transcripts stick around.",keys:["autoUpdatesChannel","cleanupPeriodDays"]},{id:"env",title:"Environment & Auth",summary:"Environment variables and auth-helper scripts.",keys:["env","apiKeyHelper","awsCredentialExport","awsAuthRefresh"]},{id:"hooks",title:"Hooks",summary:"Scripts Claude runs before/after tool use.",keys:["hooks","disableAllHooks","allowedHttpHookUrls","httpHookAllowedEnvVars"]},{id:"mcp",title:"MCP Servers",summary:"External tool providers Claude can talk to.",keys:["enableAllProjectMcpServers","enabledMcpjsonServers","disabledMcpjsonServers"]},{id:"plugins",title:"Plugins",summary:"Installed plugins, marketplaces, and per-plugin configuration.",keys:["enabledPlugins","extraKnownMarketplaces","skippedPlugins","skippedMarketplaces","pluginConfigs"]},{id:"filesystem",title:"File Picker & Sandbox",summary:"How Claude browses files and the sandbox it runs in.",keys:["fileSuggestion","sandbox","worktree"]},{id:"login",title:"Login",summary:"Which login method to force on startup.",keys:["forceLoginMethod","forceLoginOrgUUID"]},{id:"feedback",title:"Feedback",summary:"Session-quality surveys.",keys:["feedbackSurveyRate"]},{id:"advanced",title:"Advanced / Enterprise",summary:"Managed-settings-only keys and enterprise allow/denylists.",advanced:!0,keys:["allowedMcpServers","deniedMcpServers","allowManagedHooksOnly","allowManagedPermissionRulesOnly","allowManagedMcpServersOnly","strictKnownMarketplaces","blockedMarketplaces","pluginTrustMessage","otelHeadersHelper","skipWebFetchPreflight"]}],Je={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function ne(t){return t.replace(/^\$/,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").toLowerCase().split(/\s+/).filter(Boolean).map((r,a)=>{const o=Je[r];return o||(a===0?r.charAt(0).toUpperCase()+r.slice(1):r)}).join(" ")}function re(t){const s=new Set,n=[];for(const a of Ke){const o=a.keys.filter(l=>t.has(l)&&!q.has(l));o.forEach(l=>s.add(l)),o.length!==0&&n.push({id:a.id,title:a.title,summary:a.summary,advanced:!!a.advanced,keys:o})}const r=Array.from(t).filter(a=>!s.has(a)&&a!=="$schema"&&!q.has(a)).sort();return r.length>0&&n.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:r}),n}function Ge(t,s){return re(t).map(n=>({id:n.id,title:n.title,advanced:n.advanced,total:n.keys.length,setCount:n.keys.filter(r=>s.has(r)).length}))}const qe={};function ae(t,s){if(s)return{text:s,authored:!1};const n=qe[t];return n?{text:n,authored:!0}:null}const We={essentials:"star",git:"link",memory:"memory",model:"sparkle",interface:"eye",updates:"reload",env:"keys",hooks:"hooks",mcp:"mcp",plugins:"plugins",filesystem:"folder",login:"lock",feedback:"send",advanced:"shield",other:"dot"},Ve=["user","project","local","default"],ze={user:"user",project:"project",local:"local",default:"default"};function Ye({node:t,targetScope:s,onOverride:n,schema:r}){const[a,o]=y.useState(""),[l,p]=y.useState(!1),[d,c]=y.useState(!0),x=t.kind==="object"?t:null,v=x?Object.keys(x.children):[],j=r.rootKeys(),i=new Set([...v,...j]),u=y.useMemo(()=>re(i),[Array.from(i).sort().join(",")]),h=y.useMemo(()=>Ge(i,new Set(v)),[Array.from(i).sort().join(","),v.join(",")]),[f,N]=y.useState(null),g=y.useRef(null),k=b=>{const w=u.find(_=>_.id===b);w!=null&&w.advanced&&!l&&p(!0),N(b)};y.useEffect(()=>{if(!f)return;N(null);const b=g.current,w=document.getElementById(`settings-group-${f}`);if(!b||!w)return;const _=w.getBoundingClientRect().top-b.getBoundingClientRect().top;b.scrollBy({top:_,behavior:"smooth"})},[f]);const m=y.useMemo(()=>u.filter(b=>l||!b.advanced).map(b=>({...b,keys:b.keys.filter(w=>{const _=(x==null?void 0:x.children[w])!==void 0;if(!d&&!_)return!1;if(!a.trim())return!0;const E=r.at([w]);return[w,ne(w),(E==null?void 0:E.description)??""].join(" ").toLowerCase().includes(a.toLowerCase())})})).filter(b=>b.keys.length>0),[u,a,l,d,x,r]);return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 flex items-center gap-3 text-xs",children:[e.jsxs("span",{className:"text-fg-faint",children:["writing overrides to"," ",e.jsx("span",{className:"text-fg-dim font-medium",children:S[s].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:d,onChange:b=>c(b.target.checked),className:"accent-accent"}),"show not-yet-configured"]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:l,onChange:b=>p(b.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:a,onChange:b=>o(b.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx(Ze,{groups:h,onJump:k}),e.jsxs("div",{ref:g,className:"flex-1 overflow-auto py-3",children:[m.map(b=>e.jsx(Qe,{id:b.id,title:b.title,summary:b.summary,advanced:b.advanced,children:b.keys.map(w=>{const _=x==null?void 0:x.children[w],E=r.at([w]);return e.jsx(Xe,{keyName:w,node:_,info:E,targetScope:s,onOverride:(A,$)=>n([w],A,$)},w)})},b.id)),m.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',a,'"']})]})]})]})}function Ze({groups:t,onJump:s}){return e.jsx("nav",{className:"shrink-0 w-48 border-r border-line bg-bg-elev/30 overflow-y-auto py-3",children:t.map(n=>e.jsxs("button",{onClick:()=>s(n.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${n.title}`,children:[e.jsx(ue,{name:We[n.id]??"dot",size:15,className:"text-fg-faint shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 truncate text-xs text-fg-dim",children:n.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[n.setCount,"/",n.total]})]},n.id))})}function Qe({id:t,title:s,summary:n,advanced:r,children:a}){const[o,l]=y.useState(!0);return e.jsxs("section",{id:`settings-group-${t}`,className:"mx-4 mb-4 rounded-lg border border-line shadow-sm bg-bg-elev/50 overflow-hidden",children:[e.jsxs("header",{className:"px-4 py-3 bg-bg-elev cursor-pointer hover:bg-bg-hi flex items-center gap-3 border-b border-line",onClick:()=>l(!o),children:[e.jsx("span",{className:"text-fg-faint w-3",children:o?"▾":"▸"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-fg text-base font-semibold",children:s}),r&&e.jsx("span",{className:"text-[9px] px-1.5 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"advanced"})]}),e.jsx("p",{className:"text-fg-dim text-sm mt-0.5",children:n})]})]}),o&&e.jsx("div",{className:"divide-y divide-line/60",children:a})]})}function Xe({keyName:t,node:s,info:n,targetScope:r,onOverride:a}){const[o,l]=y.useState(!1),[p,d]=y.useState(!1),c=ne(t),x=s!==void 0,j=(s==null?void 0:s.kind)==="leaf"?s:null,i=(s==null?void 0:s.kind)==="object"||(s==null?void 0:s.kind)==="array",u=n==null?void 0:n.default,h=j&&u!==void 0&&ie(j.value,u),f=it({isSet:x,leafNode:j,defaultVal:u,isDefault:!!h,node:s}),N=et(j,u),g=N.length>=2,k=!!j&&!h,m=ae(t,n==null?void 0:n.description);return e.jsx("div",{className:"px-4 py-3 hover:bg-bg-elev/20",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("button",{onClick:()=>l(!o),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:o?"collapse":"expand",children:o?"▾":"▸"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-fg text-sm",children:c}),e.jsx(lt,{kind:f.kind,label:f.label}),g&&e.jsxs("button",{onClick:b=>{b.stopPropagation(),o||l(!0),d(w=>!w)},className:"text-[9px] px-1.5 py-0 rounded border border-blue-900/40 bg-blue-950/30 text-blue-300/90 uppercase tracking-wide hover:bg-blue-900/40",title:"this key is defined in multiple scopes — click to expand",children:["drift · ",N.map(b=>ze[b]).join(" · ")]}),k&&j&&e.jsx("button",{onClick:b=>{b.stopPropagation(),a(void 0,j.winner)},className:"text-[9px] px-1.5 py-0 rounded border border-line bg-bg-elev text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`reset · delete from ${S[j.winner].label}`,children:"↺ reset"}),(n==null?void 0:n.deprecated)&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-yellow-900/40 bg-yellow-950/30 text-yellow-500/80 uppercase tracking-wide",children:"deprecated"}),(n==null?void 0:n.required)&&!x&&e.jsx("span",{className:"text-[9px] px-1 py-0 rounded border border-red-900/40 bg-red-950/30 text-red-400/80 uppercase tracking-wide",children:"required"})]}),m&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${m.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:m.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:ct(m.text)}),o&&p&&j&&e.jsx(tt,{leaf:j,defaultVal:u,onReset:b=>a(void 0,b)}),o&&e.jsx(st,{keyName:t,node:s,info:n,targetScope:r,onOverride:b=>a(b)})]}),e.jsx("div",{className:"shrink-0",children:!o&&e.jsx(ot,{node:s,info:n,onSet:b=>{a(b)},disabled:i&&x})})]})})}function et(t,s){if(!t)return[];const n=new Set;n.add(t.winner);for(const r of t.shadowed)n.add(r.scope);return s!==void 0&&n.add("default"),Ve.filter(r=>n.has(r))}function tt({leaf:t,defaultVal:s,onReset:n}){const r={};r[t.winner]={value:t.value,winner:!0};for(const a of t.shadowed)r[a.scope]={value:a.value,winner:!1};return e.jsxs("div",{className:"mt-2 border border-line rounded bg-bg-elev/40 text-xs",children:[e.jsx("div",{className:"px-2 py-1 text-fg-faint border-b border-line/60",children:"Values across all scopes (winner highlighted · reset removes that scope's value):"}),e.jsxs("div",{className:"divide-y divide-line/60",children:[["user","project","local"].map(a=>{const o=r[a],l=o!==void 0;return e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:S[a].label}),e.jsx("span",{className:`font-mono truncate ${o!=null&&o.winner?"text-accent":"text-fg-dim"}`,children:l?O(o.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),l?e.jsx("button",{onClick:()=>n(a),className:"text-[9px] px-1.5 py-0 rounded border border-line text-fg-faint uppercase tracking-wide hover:text-fg hover:bg-bg-hi",title:`delete this key from ${S[a].label}`,children:"↺"}):e.jsx("span",{})]},a)}),e.jsxs("div",{className:"grid grid-cols-[5rem_1fr_auto] gap-2 px-2 py-1 items-center",children:[e.jsx("span",{className:"text-fg-faint",children:"Default"}),e.jsx("span",{className:"font-mono text-fg-dim truncate",children:s!==void 0?O(s):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function st({keyName:t,node:s,info:n,targetScope:r,onOverride:a}){const l=(s==null?void 0:s.kind)==="leaf"?s:null,p=ae(t,n==null?void 0:n.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[p&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${p.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:p.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:p.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(n==null?void 0:n.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(n.type)?n.type.join(" | "):n.type})]}),(n==null?void 0:n.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:O(n.default)})]}),(n==null?void 0:n.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:n.enum.map(d=>String(d)).join(" | ")})]}),l&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Current"}),e.jsxs("dd",{className:"font-mono",children:[e.jsx("span",{className:"text-fg-dim",children:O(l.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",S[l.winner].label]})]})]}),l&&l.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:l.shadowed.map((d,c)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[O(d.value)," —"," ",e.jsx("span",{className:"no-underline",children:S[d.scope].label})]},c))})]}),(s==null?void 0:s.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[s.items.length," items across all scopes"]})]})]}),e.jsx("div",{className:"pt-2 flex items-center gap-2 flex-wrap border-t border-line/60",children:e.jsx(nt,{keyName:t,node:s,info:n,onChange:a,targetScope:r})})]})}function nt({node:t,info:s,onChange:n,targetScope:r}){const o=(t==null?void 0:t.kind)==="leaf"?t.value:s==null?void 0:s.default,l=oe(s==null?void 0:s.type);if(l==="boolean"){const p=o===!0;return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("div",{className:"inline-flex rounded border border-line overflow-hidden",children:[{v:!0,label:"on"},{v:!1,label:"off"}].map(({v:d,label:c})=>e.jsx("button",{onClick:()=>n(d),className:`px-3 py-0.5 text-xs transition-colors ${p===d?"bg-accent text-bg":"bg-bg-elev text-fg-dim hover:bg-bg-hi hover:text-fg"}`,children:c},c))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",S[r].label]})]})}return s!=null&&s.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),s.enum.map(p=>{const d=ie(o,p);return e.jsx("button",{onClick:()=>n(p),className:`px-2 py-0.5 text-xs rounded border ${d?"bg-accent text-bg border-accent":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,children:String(p)},String(p))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",S[r].label]})]}):l==="integer"||l==="number"?e.jsx(rt,{value:typeof o=="number"?o:void 0,integer:l==="integer",onCommit:n,target:S[r].label}):l==="string"?e.jsx(at,{value:typeof o=="string"?o:"",onCommit:n,target:S[r].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",l??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function rt({value:t,integer:s,onCommit:n,target:r}){const[a,o]=y.useState(t!==void 0?String(t):""),l=()=>{const p=s?parseInt(a,10):parseFloat(a);Number.isNaN(p)||n(p)};return e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-fg-faint",children:"Set to:"}),e.jsx("input",{type:"number",value:a,onChange:p=>o(p.target.value),onBlur:l,onKeyDown:p=>{p.key==="Enter"&&p.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:l,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",r]})]})}function at({value:t,onCommit:s,target:n}){const[r,a]=y.useState(t);return e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"text-fg-faint shrink-0",children:"Set to:"}),e.jsx("input",{type:"text",value:r,onChange:o=>a(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s(r)},className:"flex-1 min-w-0 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:()=>s(r),className:"shrink-0 px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",n]})]})}function ot({node:t,info:s,onSet:n,disabled:r}){const a=(t==null?void 0:t.kind)==="leaf",o=oe(s==null?void 0:s.type);if(r)return null;if(o==="boolean"){const l=a&&t.value===!0;return e.jsx("button",{onClick:()=>n(!l),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${l?"bg-accent/15 text-accent border-accent/40 hover:bg-accent hover:text-bg":"bg-bg-elev text-fg-dim border-line hover:text-fg hover:bg-bg-hi"}`,title:"toggle",children:l?"on":"off"})}return null}function it({isSet:t,leafNode:s,defaultVal:n,isDefault:r,node:a}){return t?(a==null?void 0:a.kind)==="array"?{kind:"accumulated",label:`${a.items.length} items`}:(a==null?void 0:a.kind)==="object"?{kind:"set",label:"configured"}:s?r?{kind:"default",label:`= default · ${S[s.winner].label}`}:s.shadowed.length>0?{kind:"override",label:`overriding ${s.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${S[s.winner].label}`}:{kind:"set",label:"configured"}:n!==void 0?{kind:"default",label:`using default: ${O(n)}`}:{kind:"unset",label:"not configured"}}function lt({kind:t,label:s}){const n={set:"bg-accent/15 text-accent border-accent/30",default:"bg-bg-hi text-fg-dim border-line",unset:"bg-bg-elev text-fg-faint border-line",override:"bg-purple-950/30 text-purple-400/80 border-purple-900/40",accumulated:"bg-blue-950/30 text-blue-400/80 border-blue-900/40"}[t];return e.jsx("span",{className:`text-[9px] px-1.5 py-0 rounded border uppercase tracking-wide ${n}`,children:s})}function oe(t){if(t)return Array.isArray(t)?t.find(n=>n!=="null")??t[0]:t}function ie(t,s){return t===s?!0:typeof t!=typeof s?!1:t&&s&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(s):!1}function ct(t){const s=t.trim().split(`
2
+ `)[0],n=s.match(/^([^.!?]+[.!?])/);return n?n[1]:s.length>120?s.slice(0,120)+"…":s}function O(t){if(typeof t=="string")return t===""?'""':JSON.stringify(t);if(t===null)return"null";if(t===void 0)return"—";if(typeof t=="object"){const s=JSON.stringify(t);return s.length>60?s.slice(0,60)+"…":s}return String(t)}const W={user:{title:"Global settings",body:"This is the real ~/.claude/settings.json on disk — the same file the claude CLI reads on every session it starts. Edits apply machine-wide, to every project and every session."},project:{title:"Project settings",body:"This is the real <project>/.claude/settings.json on disk, checked into git. Edits apply to every current and future session in this project, for anyone who clones it."},local:{title:"Local settings",body:"This is the real <project>/.claude/settings.local.json on disk, gitignored. Edits apply to every current and future session in this project, on this machine only."}};function dt({effective:t,onOpenTab:s}){return e.jsx("ul",{"data-testid":"settings-owned-summaries",className:"px-3 py-2 space-y-1 text-[11.5px] border-b border-line",children:se.map(n=>{const r=n.keys.filter(o=>fe(t,[o])!==null),a=r.length?`${r.length} of ${n.keys.length} keys set (${r.join(", ")})`:"nothing set";return e.jsxs("li",{"data-testid":`owned-summary-${n.id}`,className:"flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg w-28 shrink-0",children:n.label}),e.jsx("span",{className:"truncate",children:a}),n.tab?e.jsxs("button",{type:"button",onClick:()=>s(n.tab),className:"ml-auto text-accent hover:underline shrink-0",children:["edit in ",n.label," tab →"]}):e.jsxs("span",{className:"ml-auto text-fg-faint shrink-0",children:["managed on the ",n.label," page"]})]},n.id)})})}function ut({scope:t="user"}={}){const s=L(),n=B(m=>m.tabs),r=B(m=>m.activeTabId),a=n.find(m=>m.id===r)??null,o=(a==null?void 0:a.cwd)??null,[l,p]=y.useState("general");pe("settings",m=>{(m==="general"||m==="permissions"||m==="hooks"||m==="raw")&&p(m)});const d=H(Y,s,o),c=d[t]??null,x=T(m=>m.files),v=T(m=>m.setDraft),j=T(m=>m.saveJson),i=T(m=>m.revert),[u,h]=y.useState(null),f=y.useMemo(()=>me(xe(x,d)),[x,d]),N=(m,b,w)=>{var $;const _=w??t,E=d[_];if(!E)return;const A=(($=x[E])==null?void 0:$.draftRaw)??"";if(A.trim())try{JSON.parse(A)}catch(P){h(`${E} is not valid JSON (${P instanceof Error?P.message:String(P)}) — fix it in Raw before editing from General.`);return}h(null),window.api.claudeConfig.patch({fileId:"settings",scope:_,cwd:o,keyPath:m,value:b}).catch(P=>R.error(P instanceof Error?P.message:String(P)))};if(!s)return e.jsx(C,{title:"loading…"});const g=c?x[c]:null,k=m=>m!=="user"&&!o;return e.jsx(F,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(U,{options:[{key:"general",label:"General"},{key:"permissions",label:"Permissions"},{key:"hooks",label:"Hooks"},{key:"raw",label:"Raw"}],active:l,onChange:p}),e.jsx(e.Fragment,{children:e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:l==="general"?`overrides → ${c??"—"}`:c??"—"})}),e.jsx("div",{className:"flex-1"}),e.jsx("a",{href:"https://code.claude.com/docs/en/settings",target:"_blank",rel:"noreferrer",className:"text-fg-faint hover:text-fg-dim underline-offset-2 hover:underline",children:"schema reference ↗"})]}),footer:l==="raw"&&c&&g?e.jsx(ye,{dirty:g.dirty,busy:g.busy,parseError:u||g.parseError,lastSavedAt:g.lastSavedAt,leading:g.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{h(null);const m=await j(c);m.ok||h(m.error??"save failed")},onRevert:()=>{h(null),i(c)}}):null,children:e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"settings-scope-note",className:"sticky top-0 z-10 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:W[t].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:W[t].body}),c&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:c})]}),u&&l!=="raw"&&e.jsx("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:u}),k(t)?e.jsx(C,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"}):l==="general"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c??""})}),e.jsx(dt,{effective:f,onOpenTab:p}),e.jsx(Ye,{node:f,targetScope:t,onOverride:N,schema:Q()})]}):l==="permissions"?c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c,keyPath:["permissions"]})}),e.jsx(X,{scope:t,cwd:o,activePath:c})]}):e.jsx(C,{title:"resolving…"}):l==="hooks"?c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c,keyPath:["hooks"]})}),e.jsx(te,{scope:t,cwd:o,path:c})]}):e.jsx(C,{title:"resolving…"}):c&&g?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(I,{path:c})}),e.jsx(he,{path:c,value:g.draftRaw,onChange:m=>{h(null),v(c,m)}})]}):e.jsx(C,{title:"resolving…"})]})})}const kt=y.memo(ut);export{W as SETTINGS_SCOPE_NOTES,kt as Settings};
@@ -1,4 +1,4 @@
1
- import{aJ as Z,R as wo,aq as ko,at as tr}from"./index-CuAfFXNd.js";import"./monaco-editor-BsIlgG7c.js";function Ao(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Co(e,n,r){return n=zo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return To(e)||Ao(e,n)||ci(e,n)||Eo()}function So(e){return Mo(e)||Po(e)||ci(e)||Oo()}function Mo(e){if(Array.isArray(e))return gn(e)}function To(e){if(Array.isArray(e))return e}function Po(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ci(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Oo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{aN as Z,R as wo,at as ko,ax as tr}from"./index-9ajPMXBg.js";import"./monaco-editor-BsIlgG7c.js";function Ao(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Co(e,n,r){return n=zo(n),n in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function er(e,n){return To(e)||Ao(e,n)||ci(e,n)||Eo()}function So(e){return Mo(e)||Po(e)||ci(e)||Oo()}function Mo(e){if(Array.isArray(e))return gn(e)}function To(e){if(Array.isArray(e))return e}function Po(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ci(e,n){if(e){if(typeof e=="string")return gn(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return gn(e,n)}}function gn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=e[r];return i}function Oo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Eo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
3
3
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ro(e,n){if(typeof e!="object"||e===null)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function zo(e){var n=Ro(e,"string");return typeof n=="symbol"?n:String(n)}var No=function(n,r){var i=new Set(r);return Object.assign.apply(Object,[{}].concat(So(Object.entries(n).filter(function(o){var a=er(o,1),s=a[0];return!i.has(s)}).map(function(o){var a=er(o,2),s=a[0],u=a[1];return Co({},s,u)}))))};function yn(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Io(e){if(Array.isArray(e))return e}function $o(e){if(Array.isArray(e))return yn(e)}function Do(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function jo(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,o,a,s,u=[],l=!0,f=!1;try{if(a=(r=r.call(e)).next,n!==0)for(;!(l=(i=a.call(r)).done)&&(u.push(i.value),u.length!==n);l=!0);}catch(h){f=!0,o=h}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return u}}function Fo(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
4
4
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Lo(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
@@ -0,0 +1,29 @@
1
+ import{aN as f,ax as s,a6 as Bt,ac as Kt,b4 as q,ai as Wt,b as Ht,ab as Ut,ay as jt,be as yt,b5 as wt,b8 as T,l as ne,br as Jt,F as Yt,P as Vt,ae as zt,aR as qt,aU as Gt,b9 as Nt}from"./index-9ajPMXBg.js";import{P as Te}from"./Panel-g2D-e-RM.js";import{L as St}from"./ListDetail-DAAx__24.js";import{f as rt,S as $t,m as Qt}from"./Library-DVXk77zA.js";import{a as Qe,u as lt,p as Zt,c as Xt,P as es}from"./ProvenanceBadge-wew4_nf3.js";import{T as ts}from"./Toggle-DQMNWZKT.js";function Ct({filter:e,onFilterChange:t,placeholder:n,summary:a,children:l,primary:r}){const[i,o]=f.useState(!1),h=f.useRef(null),m=f.useRef(null),g=f.useId();return f.useEffect(()=>{if(!i)return;const u=v=>{var b,w;const p=v.target;(b=h.current)!=null&&b.contains(p)||(w=m.current)!=null&&w.contains(p)||o(!1)},x=v=>{v.key==="Escape"&&o(!1)};return window.addEventListener("mousedown",u),window.addEventListener("keydown",x),()=>{window.removeEventListener("mousedown",u),window.removeEventListener("keydown",x)}},[i]),s.jsxs("div",{"data-testid":"extensions-toolbar",className:"relative shrink-0 h-11 flex items-center gap-3 px-3 bg-bg-elev border-b border-line text-xs",children:[s.jsxs("div",{className:"relative shrink-0",children:[s.jsxs("svg",{"aria-hidden":"true",className:"pointer-events-none absolute left-[9px] top-1/2 -translate-y-1/2 text-fg-faint/80",width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("circle",{cx:"11",cy:"11",r:"8"}),s.jsx("path",{d:"m21 21-4.3-4.3"})]}),s.jsx("input",{type:"text","data-testid":"extensions-toolbar-filter",value:e,onChange:u=>t(u.target.value),placeholder:n,"aria-label":n,spellCheck:!1,className:"w-[276px] h-7 pl-[29px] pr-[9px] bg-bg-hi border border-line rounded-md text-xs text-fg placeholder:text-fg-faint/80 focus:outline-none focus:border-fg-faint"})]}),s.jsx("span",{"data-testid":"extensions-toolbar-summary",className:"min-w-0 truncate text-fg-faint",children:a}),l,s.jsxs("button",{ref:h,type:"button","data-testid":r.testId,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?g:void 0,onClick:()=>o(u=>!u),className:"ml-auto shrink-0 h-7 inline-flex items-center gap-1.5 pl-3 pr-2.5 rounded-md bg-accent text-bg-hi text-[12.5px] font-semibold shadow-sm hover:bg-accent/90",children:[r.label,s.jsx("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round",children:s.jsx("path",{d:"m6 9 6 6 6-6"})})]}),i&&s.jsx("div",{ref:m,id:g,role:"menu","aria-label":r.label,"data-testid":`${r.testId}-menu`,className:`absolute ${Bt.dialog} right-3 top-[42px] min-w-[210px] p-[5px] flex flex-col bg-bg-hi border border-line rounded-lg shadow-lg text-[12.5px] text-fg`,children:r.items.map(u=>s.jsx("button",{type:"button",role:"menuitem","data-testid":u.testId,onClick:()=>{o(!1),u.onSelect()},className:"px-2.5 py-[7px] rounded-[5px] text-left whitespace-nowrap hover:bg-bg-elev",children:u.label},u.testId))})]})}const ss=2;function be(e){return`${e.source}:${e.pluginKey??e.cwd??""}:${e.name}`}const He=new Map,ns=e=>e instanceof Error?e.message:String(e);async function as(e){try{return await window.api.mcp.checkServer(e)}catch(t){const n=ns(t);return q.error(`MCP check of ${e.name} failed: ${n}`),{ok:!1,status:"failed",error:n,checkedAt:Date.now()}}}const ve=Kt((e,t)=>({results:{},checking:{},check:n=>{const a=be(n),l=He.get(a);if(l)return l;e(i=>({checking:{...i.checking,[a]:!0}}));const r=as(n).then(i=>(He.delete(a),e(o=>{const h={...o.checking};return delete h[a],{results:{...o.results,[a]:i},checking:h}}),i));return He.set(a,r),r},checkAll:async n=>{const a=[...new Map(n.map(i=>[be(i),i])).values()];let l=0;const r=async()=>{for(;l<a.length;)await t().check(a[l++])};await Promise.all(Array.from({length:Math.min(ss,a.length)},r))}})),rs=e=>e.results,ls=e=>e.checking,qe={unchecked:"Not checked",connected:"Connected",failed:"Failed","needs-auth":"Needs auth"},Et={unchecked:"border-[1.5px] border-fg-faint/60",connected:"bg-sage",failed:"bg-red-500","needs-auth":"bg-honey"},is={unchecked:"bg-bg-elev text-fg-dim",connected:"bg-sage/15 text-sage-dark",failed:"bg-red-500/10 text-red-700","needs-auth":"bg-honey/15 text-honey-dark"},os={user:"User scope",project:"Project scope",local:"Local scope"},cs=3e4,ds="••••••••",us=/^[A-Za-z0-9_@%+=:,./-]+$/;function ms(e){return us.test(e)?e:`'${e.replace(/'/g,"'\\''")}'`}function Ze(e){return(e.type??"stdio")!=="stdio"}function ps(e){return Ze(e)?e.url??"":e.command?[e.command,...e.args??[]].map(ms).join(" "):""}const it=e=>e.replace(/[^A-Za-z0-9_-]/g,"_");function fs(e,t){return`mcp__${it(e)}__${it(t)}`}const Ue="h-7 inline-flex items-center whitespace-nowrap px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",Xe="text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",Je="px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint";function ot({name:e,server:t,scope:n,fileLabel:a,plugin:l,checkRequest:r,provenance:i,onChange:o,editing:h=!1,onEditingChange:m,editor:g}){const u=l!==void 0,x=!u&&h,v=r?be(r):null,p=ve(P=>v===null?void 0:P.results[v]),b=ve(P=>v===null?!1:P.checking[v]===!0),w=ve(P=>P.check);xs(cs,p!==void 0);const C=(p==null?void 0:p.status)??"unchecked",A=Date.now(),J=Ze(t);return s.jsxs("div",{"data-testid":"mcp-detail",className:"flex flex-col gap-[18px] px-6 py-[18px]",children:[s.jsxs("div",{className:"flex items-start gap-4",children:[s.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[s.jsxs("div",{className:"min-w-0 flex items-center gap-3",children:[s.jsx("h2",{"data-testid":"mcp-detail-name",className:"min-w-0 truncate text-[22px] leading-tight font-semibold tracking-[-.01em] text-fg",children:e}),s.jsxs("span",{"data-testid":"mcp-detail-status","data-status":C,title:p&&!p.ok?p.error:void 0,className:`shrink-0 inline-flex items-center gap-1.5 h-[22px] px-[9px] rounded-full text-xs font-semibold ${is[C]}`,children:[s.jsx("span",{"aria-hidden":"true",className:`w-1.5 h-1.5 shrink-0 box-border rounded-full ${Et[C]}${b?" animate-pulse":""}`}),qe[C]]}),b?s.jsx("span",{"data-testid":"mcp-detail-checked",className:"shrink-0 text-xs text-fg-faint",children:"checking…"}):p?s.jsxs("span",{"data-testid":"mcp-detail-checked",title:new Date(p.checkedAt).toLocaleString(),className:"shrink-0 text-xs text-fg-faint",children:["checked ",Wt(Math.min(p.checkedAt,A),A)]}):null]}),s.jsxs("div",{"data-testid":"mcp-detail-meta",className:"flex flex-wrap items-center gap-2 text-xs text-fg-faint",children:[s.jsx(Qe,{scope:n,input:i,interactive:!1}),s.jsx("span",{"data-testid":"mcp-detail-transport",className:"inline-flex",children:s.jsx(Ht,{tone:"dim",children:u?"plugin":t.type??"stdio"})}),u?s.jsxs(s.Fragment,{children:[s.jsxs("span",{"data-testid":"mcp-detail-plugin",children:["via the ",l," plugin"]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsx("span",{"data-testid":"mcp-detail-readonly",children:"read-only"})]}):s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-detail-scope",children:os[n]}),s.jsx("span",{"aria-hidden":"true",className:"text-fg-faint/60",children:"·"}),s.jsxs("span",{"data-testid":"mcp-detail-keypath",className:"min-w-0 font-mono text-[11.5px] text-fg-dim break-words",children:[a," › mcpServers › ",e]})]})]})]}),s.jsxs("div",{className:"ml-auto shrink-0 flex items-center gap-2",children:[s.jsx("button",{type:"button","data-testid":"mcp-check-again",onClick:()=>{r&&w(r)},disabled:r===null||b,className:Ue,children:b?"Checking…":"Check again"}),u?null:x?s.jsx("button",{type:"button","data-testid":"mcp-edit-done",onClick:()=>m==null?void 0:m(!1),className:Ue,children:"Done"}):s.jsx("button",{type:"button","data-testid":"mcp-edit-json",onClick:()=>m==null?void 0:m(!0),className:Ue,children:"Edit JSON"})]})]}),x?g:s.jsxs(s.Fragment,{children:[s.jsx(hs,{server:t,readOnly:u}),u?null:J?s.jsx(ct,{testId:"mcp-headers",label:"Headers",noun:"header",separator:":",emptyText:"No headers set",values:t.headers??{},onAdd:(P,B)=>o==null?void 0:o({...t,headers:{...t.headers??{},[P]:B}})}):s.jsx(ct,{testId:"mcp-env",label:"Environment",noun:"variable",separator:"=",emptyText:"No variables set",values:t.env??{},onAdd:(P,B)=>o==null?void 0:o({...t,env:{...t.env??{},[P]:B}})}),s.jsx(gs,{serverName:e,result:p})]})]})}function xs(e,t){const[,n]=f.useState(0);f.useEffect(()=>{if(!t)return;const a=window.setInterval(()=>n(l=>l+1),e);return()=>window.clearInterval(a)},[e,t])}function hs({server:e,readOnly:t}){const n=Ze(e),a=ps(e),l=async()=>{await Ut(a)?q.success(n?"URL copied":"Command copied"):q.error(n?"Copy failed — the URL was not copied":"Copy failed — the command was not copied")};return s.jsxs("section",{className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:"Command"}),s.jsxs("div",{"data-testid":"mcp-command-box",className:"flex items-center gap-2.5 px-3 py-2.5 bg-bg-hi border border-line rounded-md font-mono text-[13px] text-fg",children:[n?null:s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:"$"}),a?s.jsx("span",{"data-testid":"mcp-command",className:"min-w-0 break-words",children:a}):s.jsx("span",{"data-testid":"mcp-command-empty",className:"min-w-0 font-sans text-[12.5px] text-fg-faint",children:t?n?"No URL set.":"No command set.":n?"No URL set — Edit JSON to add one.":"No command set — Edit JSON to add one."}),s.jsx("button",{type:"button","data-testid":"mcp-command-copy",onClick:()=>void l(),disabled:!a,className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg disabled:opacity-50 disabled:hover:text-fg-faint",children:"Copy"})]})]})}function ct({testId:e,label:t,noun:n,separator:a,emptyText:l,values:r,onAdd:i}){const[o,h]=f.useState(()=>new Set),[m,g]=f.useState(!1),[u,x]=f.useState(""),v=f.useRef(null),p=Object.keys(r),b=u.trim(),w=b!==""&&!/\s/.test(b)&&!b.includes(a),C=N=>h(L=>{const G=new Set(L);return G.has(N)?G.delete(N):G.add(N),G}),A=()=>{g(!1),x("")},J=()=>{var N;w&&(i(b,((N=v.current)==null?void 0:N.value)??""),A())},P=N=>{N.key==="Enter"?(N.preventDefault(),J()):N.key==="Escape"&&(N.preventDefault(),A())},B=s.jsxs("button",{type:"button","data-testid":`${e}-add`,onClick:()=>g(!0),className:"shrink-0 text-[12.5px] font-semibold text-accent hover:text-accent-dark",children:["+ Add ",n]});return s.jsxs("section",{"data-testid":e,className:"flex flex-col gap-[7px]",children:[s.jsx("h3",{className:Xe,children:t}),p.length===0&&!m?s.jsxs("div",{"data-testid":`${e}-empty`,className:"flex items-center gap-2.5 px-3 py-2.5 border border-dashed border-rule rounded-md text-[12.5px] text-fg-faint",children:[l,s.jsx("span",{className:"ml-auto",children:B})]}):null,p.length>0?s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:p.map(N=>{const L=o.has(N);return s.jsxs("div",{"data-testid":`${e}-row-${N}`,className:"flex items-center gap-2.5 px-3 py-2 font-mono text-[12.5px]",children:[s.jsx("span",{className:"shrink-0 font-semibold text-fg",children:N}),s.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-fg-faint/60",children:a}),s.jsx("span",{"data-testid":`${e}-value-${N}`,title:L?void 0:"Hidden — Show reveals it",className:`min-w-0 break-words ${L?"text-fg-dim":"text-fg-faint tracking-wider"}`,children:L?r[N]:ds}),s.jsx("button",{type:"button","data-testid":`${e}-reveal-${N}`,"aria-pressed":L,"aria-label":`${L?"Hide":"Show"} the value of ${N}`,onClick:()=>C(N),className:"ml-auto shrink-0 font-sans text-xs text-fg-faint hover:text-fg",children:L?"Hide":"Show"})]},N)})}):null,m?s.jsxs("div",{"data-testid":`${e}-add-form`,className:"flex items-center gap-2 px-3 py-2 bg-bg-hi border border-line rounded-md",children:[s.jsx("input",{"data-testid":`${e}-new-key`,"aria-label":`New ${n} name`,value:u,onChange:N=>x(N.target.value),onKeyDown:P,placeholder:n==="variable"?"KEY":"Header-Name",spellCheck:!1,autoFocus:!0,className:"w-44 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("span",{"aria-hidden":"true",className:"font-mono text-xs text-fg-faint",children:a}),s.jsx("input",{ref:v,type:"password",autoComplete:"off","data-testid":`${e}-new-value`,"aria-label":`New ${n} value`,onKeyDown:P,placeholder:"value",spellCheck:!1,className:"flex-1 min-w-0 h-7 px-2 bg-bg border border-line rounded font-mono text-xs text-fg"}),s.jsx("button",{type:"button","data-testid":`${e}-add-confirm`,onClick:J,disabled:!w,className:"shrink-0 h-7 px-2.5 rounded-md bg-accent text-bg-hi text-xs font-semibold hover:bg-accent/90 disabled:opacity-50 disabled:hover:bg-accent",children:"Add"}),s.jsx("button",{type:"button","data-testid":`${e}-add-cancel`,onClick:A,className:"shrink-0 h-7 px-2 text-xs text-fg-faint hover:text-fg",children:"Cancel"})]}):p.length>0?s.jsx("div",{children:B}):null]})}function gs({serverName:e,result:t}){return s.jsxs("section",{"data-testid":"mcp-tools",className:"flex flex-col gap-[7px]",children:[s.jsxs("h3",{className:`flex items-baseline gap-2 ${Xe}`,children:["Tools",t!=null&&t.ok?s.jsxs(s.Fragment,{children:[s.jsx("span",{"data-testid":"mcp-tools-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t.tools.length}),s.jsx("span",{className:"font-normal tracking-normal normal-case text-fg-faint/80",children:"from the last check"})]}):null]}),t?t.ok?t.tools.length===0?s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"The last check listed no tools."}):s.jsx("div",{className:"bg-bg-hi border border-line rounded-md divide-y divide-line",children:t.tools.map((n,a)=>s.jsxs("div",{"data-testid":`mcp-tool-row-${n.name}`,className:"grid grid-cols-[120px_minmax(0,1fr)_auto] items-baseline gap-4 px-3 py-2.5",children:[s.jsx("span",{title:n.name,className:"truncate font-mono text-[12.5px] font-semibold text-fg",children:n.name}),s.jsx("span",{title:n.description||void 0,className:"line-clamp-2 text-[12.5px] text-fg-dim",children:n.description??""}),s.jsx("span",{className:"font-mono text-[11px] text-fg-faint/80",children:fs(e,n.name)})]},`${a}:${n.name}`))}):s.jsxs("div",{"data-testid":"mcp-tools-empty",className:Je,children:[t.status==="needs-auth"?"The last check needs auth":"The last check failed",": ",t.error]}):s.jsx("div",{"data-testid":"mcp-tools-empty",className:Je,children:"Check this server to list its tools."})]})}const et=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/,Ye="disable-model-invocation",At=/^\s*disable-model-invocation\s*:/;function bs(e){const t=e.match(et);if(!t)return!1;for(const n of t[1].split(/\r?\n/)){if(!At.test(n))continue;const a=n.slice(n.indexOf(":")+1).trim().toLowerCase();return a==="true"||a==="yes"}return!1}function vs(e){const t=e.trim();return t.length>=2&&(t[0]==='"'&&t[t.length-1]==='"'||t[0]==="'"&&t[t.length-1]==="'")?t.slice(1,-1):t}function de(e){return e.length-e.trimStart().length}function Oe(e){const t=e.match(et);if(!t)return{name:null,description:null,body:e};const n=t[1].split(/\r?\n/),a=t[2]??"";let l=null,r=null;for(let i=0;i<n.length;i++){const o=n[i],h=o.match(/^(\s*)(name|description)\s*:(.*)$/);if(!h)continue;const[,,m,g]=h,u=g.trim(),x=de(o);let v;if(u===""||u===">-"||u===">"||u==="|-"||u==="|"){const p=[];let b=i+1;for(;b<n.length&&n[b].trim()!==""&&de(n[b])>x;)p.push(n[b].trim()),b++;v=p.join(" ")}else v=vs(u);m==="name"?l=v:r=v}return{name:l,description:r,body:a}}function ks(e,t){const n=e.match(et);if(!n){if(!t)return e;const i=e.startsWith(`
2
+ `)?"":`
3
+ `;return`---
4
+ ${Ye}: true
5
+ ---
6
+ ${i}${e}`}const a=n[2]??"",l=n[1].split(/\r?\n/),r=l.findIndex(i=>At.test(i));if(t)r>=0?l[r]=`${Ye}: true`:l.push(`${Ye}: true`);else{if(r<0)return e;l.splice(r,1)}return`---
7
+ ${l.join(`
8
+ `)}
9
+ ---
10
+ ${a}`}const Lt=/^(---\r?\n)([\s\S]*?\r?\n)---/,Rt=/^\s*description\s*:/,js=/^\s*name\s*:/,ys=/^[|>][-+\d]*\s*(?:#.*)?$/;function ws(e){const t=Lt.exec(e);if(!t)return{frontmatter:null,body:e};const n=e.indexOf(`
11
+ `,t[0].length),a=n===-1?e.length:n+1;return{frontmatter:e.slice(0,a),body:e.slice(a)}}function Ns(e,t){if(!e||!t||e.endsWith(`
12
+ `))return(e??"")+t;const n=e.endsWith("\r")?`
13
+ `:e.startsWith(`---\r
14
+ `)?`\r
15
+ `:`
16
+ `;return e+n+t}function _t(e){const t=Lt.exec(e);if(!t)return null;const n=t[1],a=t[2],l=a.match(/[^\n]*\n/g)??[],r=l.map(o=>o.replace(/\r?\n$/,""));let i=null;for(const o of r)o.trim()===""||o.trimStart().startsWith("#")||(i===null||de(o)<i.length)&&(i=o.slice(0,de(o)));return{open:n,lines:l,texts:r,pad:i??"",rest:e.slice(n.length+a.length)}}function Ge(e,t){const{texts:n}=e,a=e.pad.length,l=[];for(let r=0;r<n.length;r++){if(de(n[r])!==a||!t.test(n[r]))continue;let i=r+1;for(let o=i;o<n.length;o++)if(n[o].trim()!==""){if(de(n[o])<=a)break;i=o+1}l.push({start:r,end:i}),r=i-1}return l}function dt(e){return e.endsWith(`\r
17
+ `)?`\r
18
+ `:`
19
+ `}const Ss=/^(?:true|false|yes|no|on|off|y|n|null|~|[-+]?(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:e[-+]?\d+)?|0x[\da-f_]+|0o[0-7_]+|0b[01_]+|[-+]?\.(?:inf|nan)|\d{4}-\d\d?-\d\d?)$/i,$s=/^$|^[-?,[\]{}&*!|>'"%@`]|[\u0000-\u001f\u007f\u0085\u2028\u2029]/,Cs={"\\":"\\\\",'"':'\\"',"\n":"\\n","\r":"\\r"," ":"\\t"};function Es(e){return/[:#]|^\s|\s$/.test(e)||$s.test(e)||Ss.test(e)?`"${e.replace(/[\\"\u0000-\u001f\u007f\u0085\u2028\u2029]/g,a=>Cs[a]??`\\u${a.charCodeAt(0).toString(16).padStart(4,"0")}`)}"`:e}function As(e,t){const n=`description: ${Es(t)}`,a=_t(e);if(!a){const u=e.indexOf(`
20
+ `),x=u>0&&e[u-1]==="\r"?`\r
21
+ `:`
22
+ `;return`---${x}${n}${x}---${x}${e}`}const{open:l,lines:r,texts:i,pad:o,rest:h}=a,[m,...g]=Ge(a,Rt);if(m){for(const x of g.reverse())r.splice(x.start,x.end-x.start);const u=r[m.start];r.splice(m.start,m.end-m.start,u.slice(0,de(u))+n+dt(u))}else{const[u]=Ge(a,js);let x=u?u.end:i.length;if(!u)for(;x>0&&i[x-1].trim()==="";)x--;r.splice(x,0,o+n+dt(x>0?r[x-1]:l))}return l+r.join("")+h}const Ls={0:"\0",a:"\x07",b:"\b",t:" "," ":" ",n:`
23
+ `,v:"\v",f:"\f",r:"\r",e:"\x1B"," ":" ",'"':'"',"/":"/","\\":"\\",N:"…",_:" ",L:"\u2028",P:"\u2029"};function Rs(e){const t=e.trim(),n=/^"((?:[^"\\]|\\[\s\S])*)"/.exec(t);if(n)return n[1].replace(/\\(x[\da-fA-F]{2}|u[\da-fA-F]{4}|U[\da-fA-F]{8}|[\s\S])/g,(r,i)=>{if(i.length===1)return Ls[i]??r;const o=parseInt(i.slice(1),16);return o<=1114111?String.fromCodePoint(o):r});const a=/^'((?:[^']|'')*)'/.exec(t);if(a)return a[1].replace(/''/g,"'");const l=t.search(/(?:^|\s)#/);return l===-1?t:t.slice(0,l).trimEnd()}function _s(e){const t=_t(e),n=t?Ge(t,Rt)[0]:void 0;if(!t||!n)return null;const[a,...l]=t.texts.slice(n.start,n.end),r=a.slice(a.indexOf(":")+1).trim().replace(/^#.*/,""),i=l.map(o=>o.trim()).filter(Boolean);return ys.test(r)?i.join(" "):Rs([r,...i].join(" "))}async function Pt(e){const t=`${e}/skills`;return await window.api.config.exists(t)?t:null}async function Mt(e){const{entries:t}=await jt(e,{nested:!1});return t.map(n=>{const a=Oe(n.text);return{id:n.name,name:a.name,description:a.description,dir:n.dir,path:n.path,body:a.body}})}function wn(e){const t=[],n=new Set;for(const a of e)for(const l of e){if(a.id===l.id)continue;const r=l.id.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=[`/${r}\\b`,`\`${r}\``];if(l.id.length>=4&&i.push(`\\b${r}\\b`),!i.some(m=>new RegExp(m,"i").test(a.body)))continue;const h=`${a.id}->${l.id}`;n.has(h)||(n.add(h),t.push({from:a.id,to:l.id}))}return t}function Nn(e,t){return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:!1,manifest:null,hasLsp:!1,monitors:0,hooks:0,agents:0,commands:0,skills:0,binCount:0,hasMcp:!1,mcpServers:0,error:t}}async function Sn(e){const{hasManifest:t,manifest:n}=await tt(e.path),[a,l]=await Promise.all([window.api.config.exists(`${e.path}/.lsp.json`),window.api.config.exists(`${e.path}/monitors/monitors.json`)]);let r=0;if(l){const u=await window.api.config.readJson(`${e.path}/monitors/monitors.json`);Array.isArray(u.data)?r=u.data.length:u.data&&typeof u.data=="object"&&Array.isArray(u.data.monitors)&&(r=u.data.monitors.length)}const[i,o,h]=await Promise.all([Ot(e.path,n),It(`${e.path}/bin`,{filesOnly:!0}),Pt(e.path)]),m=o.length,g=h?(await Mt(h)).length:0;return{name:e.name,path:e.path,mtimeMs:e.mtimeMs,hasManifest:t,manifest:n,hasLsp:a,monitors:r,hooks:i.hooks,agents:i.agentFiles.length,commands:i.commandFiles.length,skills:g,binCount:m,hasMcp:i.mcpServers.length>0,mcpServers:i.mcpServers.length}}function $n(e){return{skills:e.skills,commands:e.commands,agents:e.agents,hooks:e.hooks,mcpServers:e.mcpServers}}async function tt(e){let t=`${e}/.claude-plugin/plugin.json`,n=await window.api.config.exists(t);if(n||(t=`${e}/plugin.json`,n=await window.api.config.exists(t)),!n)return{hasManifest:n,manifest:null};const a=await window.api.config.readJson(t),l=a.exists&&!a.parseError&&a.data&&typeof a.data=="object"&&!Array.isArray(a.data);return{hasManifest:n,manifest:l?a.data:null}}const Q=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function Ps(e,t){const n=t.startsWith("/")?t.startsWith(`${e}/`)?t.slice(e.length+1):null:t;if(n===null)return ut(t);const a=[];for(const l of n.split("/"))if(!(l===""||l===".")){if(l!=="..")a.push(l);else if(a.pop()===void 0)return ut(t)}return a.length>0?`${e}/${a.join("/")}`:e}function ut(e){return console.warn(`[plugins] ignoring manifest path outside the plugin root: ${e}`),null}function Ms(e){return typeof e=="string"?[e]:Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Fs(e){if(!Q(e))return null;if(Q(e.mcpServers))return e.mcpServers;const t=Object.values(e);return t.length>0&&t.every(a=>Q(a)&&(typeof a.command=="string"||typeof a.url=="string"))?e:null}function Ds(e){if(!Q(e))return 0;const t=Q(e.hooks)?e.hooks:e;return Object.values(t).reduce((n,a)=>Array.isArray(a)?n+a.reduce((l,r)=>l+(Q(r)&&Array.isArray(r.hooks)?r.hooks.length:0),0):n,0)}function Me(e,t,n){const a=new Set;for(const l of Ms(t)){const r=Ps(e,l);r&&a.add(r)}return a.add(`${e}/${n}`),[...a]}async function Ft(e){try{const t=await window.api.config.readJson(e);return t.exists&&!t.parseError?t.data:null}catch{return null}}function Dt(e,t){return Me(e,typeof t=="string"||Array.isArray(t)?t:void 0,".mcp.json")}async function Tt(e,t){const n=await Promise.all(t.map(Ft)),a=new Map;for(const l of[...Q(e)?[e]:[],...n])for(const[r,i]of Object.entries(Fs(l)??{})){if(a.has(r))continue;const o=Q(i)?i.command:void 0,h=Q(i)?i.url:void 0;a.set(r,{id:r,name:r,description:typeof o=="string"?o:typeof h=="string"?h:null})}return[...a.values()]}async function Ot(e,t){const n=async p=>{const b=new Set;for(const w of p)if(w.endsWith(".md"))b.add(w);else for(const C of await It(w,{filesOnly:!0}))C.endsWith(".md")&&b.add(`${w}/${C}`);return[...b]},a=Me(e,t==null?void 0:t.commands,"commands"),l=Me(e,t==null?void 0:t.agents,"agents"),r=t==null?void 0:t.hooks,i=Me(e,typeof r=="string"||Array.isArray(r)?r:void 0,"hooks/hooks.json"),o=t==null?void 0:t.mcpServers,h=Dt(e,o),[m,g,u,x]=await Promise.all([n(a),n(l),Promise.all(i.map(Ft)),Tt(o,h)]),v=[...Q(r)?[r]:[],...u].reduce((p,b)=>p+Ds(b),0);return{commandFiles:m,agentFiles:g,hooks:v,mcpServers:x,sourcePaths:[...a,...l,...i,...h]}}async function Ts(e){const{manifest:t}=await tt(e),n=t==null?void 0:t.mcpServers;return Tt(n,Dt(e,n))}async function Os(e){const t=await Promise.all(e.map(a=>window.api.config.readText(a))),n=[];return e.forEach((a,l)=>{if(!t[l].exists)return;const r=a.slice(a.lastIndexOf("/")+1),i=Oe(t[l].text);n.push({id:a,name:i.name??r.replace(/\.md$/,""),description:i.description})}),n}async function It(e,t){try{return(await window.api.config.listDir(e,t)).entries.map(a=>a.name)}catch{return[]}}const Fe=(e,t)=>({type:"mcp",name:e,command:t.command,args:t.args,url:t.url}),Is=["stdio","http","streamable-http","sse","ws"],Bs=new Set(["workspace"]),Ks=new Set(["ide","tasks"]);function Ws(e,t,n){return e==="user"?`${t}/.claude.json`:n?`${n}/.mcp.json`:null}function Hs(e){if(e.trim()==="")return{full:{},servers:{},err:null};try{const t=JSON.parse(e),n=t.mcpServers??{};return{full:t,servers:n,err:null}}catch(t){return{full:{},servers:{},err:t.message}}}function Us(e,t){const n={};for(const[a,l]of Object.entries(t)){const{enabled:r,...i}=l;n[a]=i}return JSON.stringify({...e,mcpServers:n},null,2)+`
24
+ `}function Js(e,t){const n=[];for(const[a,l]of Object.entries(t)){if(JSON.stringify(l)===JSON.stringify(e[a]))continue;const{enabled:r,...i}=l;n.push({name:a,value:i})}for(const a of Object.keys(e))a in t||n.push({name:a,value:void 0});return n}function Ys(e){let t=Object.keys(e).length+1,n=`server-${t}`;for(;e[n];)t+=1,n=`server-${t}`;return n}const Ve=e=>({source:"plugin",name:e.name,pluginKey:e.pluginKey});async function Vs(){var r,i;const t=(await((i=(r=window.api.plugins)==null?void 0:r.list)==null?void 0:i.call(r))??[]).filter(o=>o.enabled&&!!o.installPath),n=await Promise.allSettled(t.map(o=>Ts(o.installPath))),a=[],l=[];return n.forEach((o,h)=>{const m=t[h];if(o.status==="rejected"){l.push(m.name);return}for(const g of o.value){const u=g.description??"",x=/^[a-z][a-z0-9+.-]*:\/\//i.test(u)?{type:"http",url:u}:{command:u||void 0};a.push({id:`${m.key}/${g.name}`,pluginKey:m.key,plugin:m.name,name:g.name,server:x})}}),l.length>0&&q.error(`Could not read the MCP servers of plugin ${l.join(", ")}`),a.sort((o,h)=>o.plugin.localeCompare(h.plugin)||o.name.localeCompare(h.name))}const zs={anthropic:"text-accent-dark",community:"text-honey-dark",local:""};function mt(e){if(!e)return"not checked";if(e.status==="connected"){const t=e.tools.length;return`connected · ${t} tool${t===1?"":"s"}`}return e.status==="needs-auth"?"needs auth":"failed"}function qs(e,t,n){return e==="user"?{source:"user",name:n}:t?{source:"project",name:n,cwd:t}:null}function pt({result:e,checking:t,testId:n}){const a=(e==null?void 0:e.status)??"unchecked";return s.jsx("span",{"aria-hidden":"true","data-testid":n,"data-status":a,title:e&&!e.ok?`${qe[a]}: ${e.error}`:qe[a],className:`w-2 h-2 shrink-0 box-border rounded-full ${Et[a]}${t?" animate-pulse":""}`})}function Gs({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState(null),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState(null),v=f.useRef(null),p=f.useMemo(()=>n?Ws(t,n,l):null,[n,t,l]),b=T(d=>d.files),w=T(d=>d.loadJson),C=T(d=>d.setDraft),A=T(d=>d.revert),J=T(d=>d.watchFile),P=T(d=>d.unwatchFile);f.useEffect(()=>{if(p)return b[p]||w(p),J(p),()=>P(p)},[p]);const[B,N]=f.useState(null),[L,G]=f.useState([]);f.useEffect(()=>{if(t!=="user"){G([]);return}let d=!0;return Vs().then(k=>{d&&G(k)}).catch(k=>{d&&q.error(`Could not list plugin MCP servers: ${k instanceof Error?k.message:String(k)}`)}),()=>{d=!1}},[t]);const ae=ve(rs),ee=ve(ls),$e=ve(d=>d.checkAll),ue=lt(d=>d.overrides),R=lt(d=>d.load);if(f.useEffect(()=>{n&&R(n)},[n,R]),!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project"})});if(!p)return s.jsx(ne,{title:"loading…"});const W=b[p],{full:me,servers:D,err:Ce}=W?Hs(W.draftRaw):{full:{},servers:{},err:null},K=Object.keys(D).sort(),Y=m.trim().toLowerCase(),H=Y?K.filter(d=>d.toLowerCase().includes(Y)):K,V=Y?L.filter(d=>d.name.toLowerCase().includes(Y)):L,ke=o!==null?L.find(d=>d.id===o)??null:null,Ee=r!==null&&K.includes(r)?r:null,re=H[0]??(V.length>0?null:K[0]??null),O=ke??(Ee===null&&re===null?V[0]??L[0]??null:null),M=O?null:Ee??re,pe=d=>qs(t,l,d),Ae=d=>{const k=pe(d);return k?ae[be(k)]:void 0},Le=d=>{const k=pe(d);return k?ee[be(k)]===!0:!1},fe=d=>be(Ve(d)),Re=[...H.map(pe).filter(d=>d!==null),...V.map(Ve)],Ie=[`${K.length} server${K.length===1?"":"s"}`,...L.length>0?[`${L.length} from plugins`]:[]],Be=K.filter(d=>Ae(d)!==void 0).length+L.filter(d=>ae[fe(d)]!==void 0).length,le=H.some(Le)||V.some(d=>ee[fe(d)]===!0),ie=t==="user"?"~/.claude.json":".mcp.json",oe=d=>{N(null),C(p,Us(me,d))},je=()=>{const d=Ys(D);oe({...D,[d]:{type:"stdio",command:"",args:[]}}),i(d),h(null),x(d)},Ke=d=>{d!==M&&x(null),i(d),h(null)},z=d=>{x(null),h(d)},te=d=>{const k=H.includes(d)?H:K,E=k.indexOf(d),_=k.filter(Z=>Z!==d),I={...D};delete I[d],oe(I),i(_[Math.min(E,_.length-1)]??null),x(null)},_e=(d,k)=>{if(!k||k===d||D[k])return;const E={};for(const _ of Object.keys(D))E[_===d?k:_]=D[_];oe(E),i(k),x(_=>_===d?k:_)},ce=(d,k)=>{oe({...D,[d]:k})},ye=[{label:"New server",testId:"mcp-new-server",onSelect:je}];return e&&ye.push({label:"Browse catalog…",testId:"mcp-browse-catalog",onSelect:()=>e({scope:t,cwd:l})}),s.jsxs("div",{ref:v,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter servers",summary:[...Ie,`${Be} checked`].join(" · "),primary:{label:"+ Add server",testId:"mcp-add-server",items:ye},children:s.jsx("button",{type:"button","data-testid":"mcp-check-all",onClick:()=>void $e(Re),disabled:Re.length===0||le,className:"shrink-0 h-7 inline-flex items-center px-[11px] bg-bg-hi border border-line rounded-md text-[12.5px] text-fg hover:border-rule disabled:opacity-50 disabled:hover:border-line",children:le?"Checking…":"Check all"})}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsxs(Te,{footer:W&&!O?s.jsx($t,{dirty:W.dirty,busy:W.busy,parseError:B||Ce||W.parseError,lastSavedAt:W.lastSavedAt,onSave:async()=>{var k;N(null);const d=((k=W.diskData)==null?void 0:k.mcpServers)??{};for(const[E,_]of Object.entries(D)){if(JSON.stringify(_)===JSON.stringify(d[E]))continue;const I=rt(_);if(I.length>0){Jt.getState().show("error",`Not saved: "${E}" still contains placeholder ${I.map(Z=>Z.token).join(", ")} — replace it with a real value`);return}}try{for(const E of Js(d,D))await window.api.claudeConfig.patch({...Qt(t,l),keyPath:["mcpServers",E.name],value:E.value});await w(p)}catch(E){N(E.message||"save failed")}},onRevert:()=>{N(null),A(p)},cleanLabel:`Saved — matches ${ie}`,shortcutHint:!0,scopeRef:v}):null,children:[t==="project"&&l&&s.jsx(Zs,{cwd:l,names:K}),s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{className:"flex flex-col gap-0.5 px-2 py-1",children:[s.jsxs("div",{"data-testid":"mcp-list-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:[`In ${ie}`,s.jsx("span",{className:"font-mono font-medium tracking-normal text-fg-faint/60",children:H.length})]}),K.length===0?s.jsx("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:L.length>0?`No servers in ${ie} yet.`:"No servers yet."}):H.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No servers match “",m.trim(),"”."]}):H.map(d=>{var we;const k=D[d],E=d===M,_=Ae(d),I=Le(d),Z=ue[Zt("mcp",t,d)]??Xt(Fe(d,k)).provenance,xe=rt(k).map(We=>We.token).join(", ");return s.jsxs("button",{type:"button","data-testid":`mcp-row-${d}`,"aria-current":E?"true":void 0,title:((we=k.description)==null?void 0:we.trim())||void 0,onClick:()=>Ke(d),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${E?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:_,checking:I,testId:`mcp-dot-${d}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${E?" font-semibold":""}`,children:d}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:k.type??"stdio"}),s.jsxs("span",{"data-testid":`mcp-status-${d}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:[s.jsx("span",{className:zs[Z],children:es[Z]})," · ",I?"checking…":mt(_)]}),xe?s.jsxs("span",{className:"col-start-2 col-span-2 truncate text-[11px] text-honey-dark",title:`${t} scope · ${p} — replace ${xe} with a real value; Save refuses it until then`,children:["⚠ unconfigured placeholder: ",xe]}):null]},d)}),L.length>0?s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"mcp-plugins-header",className:"flex items-center gap-2 mx-1.5 mt-3 mb-1 text-[11px] font-semibold tracking-[.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"mcp-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:V.length}),s.jsx("span",{"data-testid":"mcp-plugins-readonly",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint/80",children:"READ-ONLY"})]}),V.length===0?s.jsxs("div",{className:"mx-1.5 py-1 text-xs text-fg-faint",children:["No plugin servers match “",m.trim(),"”."]}):V.map(d=>{const k=(O==null?void 0:O.id)===d.id,E=fe(d),_=ae[E],I=ee[E]===!0;return s.jsxs("button",{type:"button","data-testid":`mcp-plugin-row-${d.id}`,"aria-current":k?"true":void 0,onClick:()=>z(d.id),className:`w-full text-left grid grid-cols-[8px_minmax(0,1fr)_auto] items-center gap-x-2.5 px-2.5 py-1.5 rounded-[7px] border ${k?"bg-bg-hi border-line":"border-transparent hover:bg-bg-hi/60"}`,children:[s.jsx(pt,{result:_,checking:I,testId:`mcp-plugin-dot-${d.id}`}),s.jsx("span",{className:`truncate text-[13px] text-fg${k?" font-semibold":""}`,children:d.name}),s.jsx("span",{className:"font-mono text-[10.5px] text-fg-faint/80",children:"plugin"}),s.jsxs("span",{"data-testid":`mcp-plugin-status-${d.id}`,className:"col-start-2 col-span-2 truncate text-[11px] text-fg-faint",children:["via the ",d.plugin," plugin · ",I?"checking…":mt(_)]})]},d.id)})]}):null]}),detail:O?s.jsx(ot,{name:O.name,server:O.server,scope:"user",plugin:O.plugin,checkRequest:Ve(O),provenance:Fe(O.name,O.server)},`plugin:${O.id}`):M!==null?s.jsx(ot,{name:M,server:D[M],scope:t,fileLabel:ie,checkRequest:pe(M),provenance:Fe(M,D[M]),onChange:d=>ce(M,d),editing:u===M,onEditingChange:d=>x(d?M:null),editor:u===M?s.jsx(Qs,{name:M,server:D[M],scope:t,onRename:d=>_e(M,d),onChange:d=>ce(M,d),onRemove:()=>te(M)}):null},M):s.jsx(ne,{title:"No MCP servers yet",hint:e?"+ Add server starts a new one or browses the catalog.":"+ Add server starts a new one."})})]})})]})}const Cn=f.memo(Gs);function Qs({name:e,server:t,scope:n,onRename:a,onChange:l,onRemove:r}){var v;const i=t.type??"stdio",o=Bs.has(e),h=Ks.has(e),m=(v=t.permissions)==null?void 0:v.tools,g=m===void 0?"inherit":m==="allow"?"allow":m==="deny"?"deny":"list",u=Array.isArray(m)?m:[],x=(t.disabledTools??[]).join(", ");return s.jsxs("div",{"data-testid":"mcp-json-form",className:"space-y-4 max-w-2xl",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs text-fg-faint w-20",children:"origin"}),s.jsx(Qe,{scope:n,input:Fe(e,t)}),s.jsx("span",{className:"text-xs text-fg-faint",children:"click to change"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"name"}),s.jsx("input",{"aria-label":"Server name",defaultValue:e,onBlur:p=>a(p.target.value.trim()),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}),s.jsx("button",{onClick:r,className:"text-xs text-fg-faint hover:text-red-400 px-2 py-1 border border-line rounded",children:"delete"})]}),s.jsx(Ne,{label:"description",value:t.description??"",onChange:p=>l({...t,description:p||void 0}),placeholder:"what this server does…"}),o?s.jsxs("div",{className:"text-xs px-2 py-1 border border-red-500/50 rounded text-red-300 bg-red-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," is a reserved name — Claude Code will refuse to load this server (v2.1.128+)."]}):h?s.jsxs("div",{className:"text-xs px-2 py-1 border border-yellow-600/50 rounded text-yellow-200 bg-yellow-500/5",children:["⚠ ",s.jsx("span",{className:"font-mono",children:e})," collides with a commonly-bundled MCP name; expect surprises in other tools."]}):null,s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"type"}),s.jsx("select",{value:i,onChange:p=>l({...t,type:p.target.value}),className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:Is.map(p=>s.jsx("option",{value:p,children:p},p))}),i==="sse"?s.jsx("span",{className:"text-xs text-yellow-400/80",children:"sse is deprecated — prefer streamable-http"}):null]}),i==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"command",value:t.command??"",onChange:p=>l({...t,command:p}),placeholder:"npx / node / python …"}),s.jsx(Ne,{label:"args",value:(t.args??[]).join(" "),onChange:p=>l({...t,args:p.split(/\s+/).filter(Boolean)}),placeholder:"space-separated args"}),s.jsx(ft,{label:"env",value:t.env??{},onChange:p=>l({...t,env:p})})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ne,{label:"url",value:t.url??"",onChange:p=>l({...t,url:p}),placeholder:"https://…"}),s.jsx(ft,{label:"headers",value:t.headers??{},onChange:p=>l({...t,headers:p})})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:"alwaysLoad"}),s.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg",children:[s.jsx("input",{type:"checkbox",checked:t.alwaysLoad===!0,onChange:p=>l({...t,alwaysLoad:p.target.checked||void 0})}),s.jsx("span",{className:"text-fg-dim",children:"bypass tool-search deferral (v2.1.121+)"})]})]}),s.jsx(Ne,{label:"disabledTools",value:x,onChange:p=>{const b=p.split(",").map(w=>w.trim()).filter(Boolean);l({...t,disabledTools:b.length?b:void 0})},placeholder:"comma-separated tool names to hide"}),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:"permissions"}),s.jsxs("div",{className:"flex-1 space-y-1",children:[s.jsxs("select",{value:g,onChange:p=>{const b=p.target.value,w={...t};if(b==="inherit"){if(w.permissions){const{tools:C,...A}=w.permissions;w.permissions=Object.keys(A).length?A:void 0}}else b==="list"?w.permissions={...w.permissions??{},tools:[]}:w.permissions={...w.permissions??{},tools:b};l(w)},className:"bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg",children:[s.jsx("option",{value:"inherit",children:"inherit (default)"}),s.jsx("option",{value:"allow",children:"allow all tools"}),s.jsx("option",{value:"deny",children:"deny all tools"}),s.jsx("option",{value:"list",children:"allowlist…"})]}),g==="list"?s.jsx("input",{value:u.join(", "),onChange:p=>{const b=p.target.value.split(",").map(w=>w.trim()).filter(Boolean);l({...t,permissions:{...t.permissions??{},tools:b}})},placeholder:"comma-separated tool names",className:"w-full bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"}):null]})]})]})}function Ne({label:e,value:t,onChange:n,placeholder:a}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20",children:e}),s.jsx("input",{value:t,onChange:l=>n(l.target.value),placeholder:a,className:"flex-1 bg-bg-elev border border-line rounded px-2 py-1 text-xs text-fg font-mono"})]})}function ft({label:e,value:t,onChange:n}){const[a,l]=f.useState(""),[r,i]=f.useState(""),o=Object.entries(t);return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("label",{className:"text-xs text-fg-faint w-20 pt-1",children:e}),s.jsxs("div",{className:"flex-1 space-y-1",children:[o.map(([h,m])=>s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:h,onChange:g=>{const u={...t};delete u[h],u[g.target.value]=m,n(u)},className:"w-32 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("input",{value:m,onChange:g=>n({...t,[h]:g.target.value}),className:"flex-1 bg-bg-elev border border-line rounded px-2 py-0.5 text-xs text-fg font-mono"}),s.jsx("button",{onClick:()=>{const g={...t};delete g[h],n(g)},className:"text-fg-faint hover:text-red-400 text-xs px-1",children:"×"})]},h)),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{value:a,onChange:h=>l(h.target.value),placeholder:"key",className:"w-32 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),s.jsx("input",{value:r,onChange:h=>i(h.target.value),placeholder:"value",className:"flex-1 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg-dim font-mono"}),s.jsx("button",{onClick:()=>{a.trim()&&(n({...t,[a.trim()]:r}),l(""),i(""))},className:"px-2 text-xs border border-line rounded text-fg-dim hover:text-fg hover:bg-bg-hi",children:"+"})]})]})]})}function Zs({cwd:e,names:t}){const n={fileId:"settings",scope:"project",cwd:e},[a,l]=f.useState([]),[r,i]=f.useState(!1),[o,h]=f.useState(!1);f.useEffect(()=>{var p,b;let u=!0;const x=()=>window.api.claudeConfig.read(n).then(w=>{if(!u)return;const C=w.data;l(Array.isArray(C==null?void 0:C.disabledMcpjsonServers)?C.disabledMcpjsonServers:[]),i((C==null?void 0:C.enableAllProjectMcpServers)===!0)}).catch(()=>{});x();const v=(b=(p=window.api.config)==null?void 0:p.onChanged)==null?void 0:b.call(p,()=>{x()});return()=>{u=!1,v==null||v()}},[e]);const m=async(u,x)=>{h(!0);try{await window.api.claudeConfig.patch({...n,keyPath:[u],value:x})}catch(v){q.error(v.message||"save failed")}finally{h(!1)}},g=async(u,x)=>{const v=x?a.filter(p=>p!==u):[...new Set([...a,u])];l(v),await m("disabledMcpjsonServers",v.length?v:void 0)};return s.jsxs("div",{className:"px-3 py-1 text-xs text-fg-faint border-b border-line flex flex-wrap items-center gap-x-4 gap-y-1","data-testid":"mcp-gating",children:[s.jsxs("span",{children:["Gating · ",e,"/.claude/settings.json"]}),s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":"mcp-enable-all",checked:r,disabled:o,onChange:u=>{i(u.target.checked),m("enableAllProjectMcpServers",u.target.checked?!0:void 0)}}),"enableAllProjectMcpServers"]}),t.map(u=>s.jsxs("label",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"checkbox","data-testid":`mcp-gate-${u}`,checked:!a.includes(u),disabled:o,onChange:x=>g(u,x.target.checked)}),u]},u))]})}function Xs({value:e,onChange:t,path:n,readOnly:a,theme:l="dark"}){const r=l==="paper";return s.jsx(Yt,{path:`file://${n}`,defaultLanguage:"markdown",value:e,onChange:i=>t(i??""),beforeMount:r?zt:void 0,theme:r?Vt:"vs-dark",options:{minimap:{enabled:!1},fontSize:13,fontFamily:"JetBrains Mono, ui-monospace, Menlo, monospace",lineNumbers:"on",renderLineHighlight:"line",scrollBeyondLastLine:!1,tabSize:2,wordWrap:"on",readOnly:a,automaticLayout:!0}})}const Pe="h-4 inline-flex items-center px-1.5 bg-bg-elev border border-line rounded-[3px] text-[10px] tracking-[0.04em] text-fg-dim",ze="text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",en=["prose-chat max-w-[720px] px-[26px] py-4 text-[14px] leading-[1.6] text-fg","[&_h1]:font-serif [&_h2]:font-serif [&_h3]:font-serif [&_h4]:font-serif","[&_h1]:text-[24px] [&_h2]:text-[20px] [&_h3]:text-[18px] [&_h1]:font-semibold [&_h2]:font-semibold [&_h3]:font-semibold","[&_h1]:mb-1.5 [&_h2]:mb-1.5 [&_h3]:mb-1.5 [&_p]:mb-3.5 [&_ul]:mb-3.5 [&_ul]:pl-5 [&_ul]:list-disc [&_ol]:pl-5 [&_ol]:list-decimal","[&_pre]:!bg-bg-elev [&_code]:!bg-bg-elev"].join(" ");function tn(e,t){return t&&(e===t||e.startsWith(`${t}/`))?`~${e.slice(t.length)}`:e}function xt({item:e,home:t,draft:n,dirty:a,busy:l,lastSavedAt:r,saveError:i,onDraftChange:o,onSave:h,onRevert:m,readOnly:g=!1}){const u=f.useRef(null),[x,v]=f.useState("source"),p=f.useMemo(()=>ws(n),[n]),b=f.useMemo(()=>_s(n)??"",[n]),w=f.useMemo(()=>x==="preview"?qt(p.body):"",[x,p.body]),C=(A,J)=>{const P=x===A;return s.jsx("button",{type:"button","data-testid":`skill-view-${A}`,"aria-pressed":P,onClick:()=>v(A),className:`h-6 inline-flex items-center px-[11px] rounded-[5px] text-xs ${P?"bg-bg-hi shadow-sm font-semibold text-fg":"text-fg-faint hover:text-fg"}`,children:J})};return s.jsxs("div",{ref:u,"data-testid":"skill-detail",className:"h-full min-h-0 flex flex-col",children:[s.jsxs("div",{className:"flex-1 min-h-0 flex flex-col px-[22px] pt-4",children:[s.jsxs("div",{className:"flex items-center gap-2.5",children:[s.jsxs("span",{"data-testid":"skill-detail-name",className:"min-w-0 truncate font-mono text-[18px] font-semibold text-fg",children:["/",e.name]}),s.jsx("span",{"data-testid":"skill-detail-kind",className:Pe,children:e.kind==="commands"?"COMMAND":"SKILL"}),e.plugin?s.jsxs("span",{"data-testid":"skill-detail-plugin",className:Pe,children:["from ",e.plugin]}):s.jsx("span",{"data-testid":"skill-detail-scope",className:Pe,children:e.scope.toUpperCase()}),g&&s.jsx("span",{"data-testid":"skill-detail-readonly",className:Pe,children:"READ-ONLY"}),s.jsxs("div",{role:"group","aria-label":"View",className:"ml-auto flex gap-0.5 p-0.5 bg-bg-elev border border-line rounded-[7px]",children:[C("source","Source"),C("preview","Preview")]})]}),s.jsxs("div",{className:"grid grid-cols-[84px_minmax(0,1fr)] items-baseline gap-x-3 gap-y-2.5 mt-3.5",children:[g?s.jsx("span",{className:ze,children:"Description"}):s.jsx("label",{htmlFor:`skill-desc-${e.path}`,className:ze,children:"Description"}),g?s.jsx("span",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description-text",className:"text-[13px] leading-[1.45] text-fg-dim",children:b||s.jsx("span",{className:"text-fg-faint",children:"No description"})}):s.jsx("input",{id:`skill-desc-${e.path}`,"data-testid":"skill-detail-description",type:"text",value:b,onChange:A=>o(As(n,A.target.value)),placeholder:"What this does and when Claude should use it",className:"px-2.5 py-[7px] bg-bg-hi border border-line rounded-md text-[13px] leading-[1.45] text-fg outline-none focus:border-accent"}),s.jsx("span",{className:ze,children:"File"}),s.jsxs("div",{className:"min-w-0 flex items-baseline gap-3 text-xs",children:[s.jsx("span",{"data-testid":"skill-detail-path",title:e.path,className:"min-w-0 truncate font-mono text-[11.5px] text-fg-dim",children:tn(e.path,t)}),s.jsx("button",{type:"button","data-testid":"skill-detail-reveal",onClick:()=>Gt(e.path),className:"shrink-0 font-medium text-accent hover:underline",children:"Reveal in File Explorer"})]})]}),s.jsx("div",{className:"flex-1 min-h-0 mt-3.5 border border-line border-b-0 rounded-t-[7px] bg-bg-hi overflow-hidden",children:x==="source"?s.jsx(Xs,{path:e.path,theme:"paper",value:p.body,readOnly:g,onChange:A=>{g||o(Ns(p.frontmatter,A))}}):s.jsx("div",{className:"h-full overflow-auto",children:s.jsx("div",{"data-testid":"skill-preview",className:en,dangerouslySetInnerHTML:{__html:w}})})})]}),!g&&s.jsx("div",{className:"shrink-0 border-t border-line bg-bg-elev",children:s.jsx($t,{dirty:a,busy:l,parseError:i,lastSavedAt:r,onSave:h,onRevert:m,cleanLabel:"Saved — matches the file on disk",shortcutHint:!0,scopeRef:u})})]})}const ht=e=>e instanceof Error?e.message:String(e),gt=(e,t,n)=>`${e} ${e===1?t:n}`,bt=(e,t)=>e.name.localeCompare(t.name);async function sn(e,t){const[n,{manifest:a}]=await Promise.all([Pt(t),tt(t)]),[l,r]=await Promise.all([n?Mt(n):Promise.resolve([]),Ot(t,a)]),i=await Os(r.commandFiles);return[...l.map(o=>({kind:"skills",plugin:e,name:o.name??o.id,path:o.path,description:o.description??void 0})).sort(bt),...i.map(o=>({kind:"commands",plugin:e,name:o.name??o.id,path:o.id,description:o.description??void 0})).sort(bt)]}function nn(e,t){const[n,a]=f.useState([]),l=f.useRef(0),r=f.useCallback(async()=>{const i=++l.current;if(!t){a([]);return}let o=[];try{const h=(await window.api.plugins.list()).filter(m=>m.enabled&&m.installPath);o=await Promise.all(h.map(async m=>{try{return{key:m.key,name:m.name,items:await sn(m.name,m.installPath)}}catch(g){return{key:m.key,name:m.name,items:[],error:ht(g)}}}))}catch(h){console.warn(`[skills] could not list plugins: ${ht(h)}`)}l.current===i&&(o.sort((h,m)=>h.name.localeCompare(m.name)),a(o))},[t]);return f.useEffect(()=>{r()},[r]),f.useEffect(()=>()=>{l.current+=1},[]),Nt(t&&e?[`${e}/.claude/plugins/installed_plugins.json`,`${e}/.claude/settings.json`]:[],()=>{r()}),n}function an(e){const t=e.filter(a=>a.kind==="skills").length,n=e.length-t;return[t?gt(t,"skill","skills"):"",n?gt(n,"command","commands"):""].filter(Boolean).join(" · ")}function rn({open:e}){return s.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 text-fg-faint/60 transition-transform ${e?"rotate-90":""}`,"aria-hidden":!0,children:s.jsx("path",{d:"m9 18 6-6-6-6"})})}function ln({plugins:e,needle:t,selectedPath:n,onSelect:a}){const[l,r]=f.useState(()=>new Set),i=e.map(m=>{if(!t||m.name.toLowerCase().includes(t))return{p:m,items:m.items};const g=m.items.filter(u=>{var x;return u.name.toLowerCase().includes(t)||!!((x=u.description)!=null&&x.toLowerCase().includes(t))});return{p:m,items:g}}).filter(({p:m,items:g})=>!t||g.length>0||m.name.toLowerCase().includes(t)),o=i.reduce((m,g)=>m+g.items.length,0),h=m=>r(g=>{const u=new Set(g);return u.has(m)?u.delete(m):u.add(m),u});return s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-testid":"skills-section-plugins",className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:["From plugins",s.jsx("span",{"data-testid":"skills-section-plugins-count",className:"font-mono font-medium tracking-normal text-fg-faint/60",children:o}),s.jsx("span",{"data-testid":"skills-section-plugins-readonly",title:"Plugin files are managed by the plugin — open them to read, not edit",className:"ml-auto px-[5px] border border-line rounded-[3px] text-[9.5px] font-medium tracking-normal text-fg-faint",children:"READ-ONLY"})]}),e.length===0&&s.jsx("div",{className:"mx-1.5 mb-1 text-xs text-fg-faint",children:"No enabled plugin adds skills or commands"}),i.map(({p:m,items:g})=>{const u=!m.error&&(l.has(m.key)||!!t&&g.length>0);return s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("button",{type:"button","data-testid":"plugin-skills-row","data-plugin":m.name,"aria-expanded":u,onClick:()=>h(m.key),className:"flex items-center gap-2 px-2.5 py-[7px] border border-transparent rounded-[7px] text-left text-[12.5px] text-fg-dim hover:bg-bg-hi",children:[s.jsx("span",{className:"min-w-0 truncate",children:m.name}),m.error?s.jsx("span",{"data-testid":"plugin-skills-row-error",title:m.error,className:"ml-auto shrink-0 text-[11px] text-red-400",children:"Could not read plugin"}):s.jsx("span",{"data-testid":"plugin-skills-row-counts",className:"ml-auto shrink-0 font-mono text-[11px] text-fg-faint",children:an(m.items)||"nothing to list"}),s.jsx(rn,{open:u})]}),u&&g.map(x=>{const v=n===x.path;return s.jsxs("button",{type:"button","data-testid":"plugin-skills-item","data-path":x.path,"aria-current":v?"true":void 0,onClick:()=>a(x.path),className:`ml-3 mb-0.5 flex flex-col gap-[2px] px-2.5 py-1.5 border rounded-[7px] text-left ${v?"border-accent bg-bg-hi":"border-transparent hover:bg-bg-hi"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsxs("span",{"data-testid":"plugin-skills-item-name",className:"min-w-0 truncate font-mono text-[12px] font-semibold text-fg",children:["/",x.name]}),s.jsx("span",{className:"ml-auto shrink-0 text-[9.5px] tracking-[0.04em] text-fg-faint",children:x.kind==="commands"?"COMMAND":"SKILL"})]}),x.description&&s.jsx("span",{title:x.description,className:"truncate text-[11px] text-fg-faint",children:x.description})]},x.path)})]},m.key)})]})}const on=250,cn=2e3,dn=6;function un(e,t){return{user:{skills:`${e}/.claude/skills`,commands:`${e}/.claude/commands`},project:t?{skills:`${t}/.claude/skills`,commands:`${t}/.claude/commands`}:null}}const De=e=>e instanceof Error?e.message:String(e);async function mn(e,t){const n=e.map(()=>{});let a=0;const l=async()=>{for(let r=a++;r<e.length;r=a++)try{const i=await window.api.config.readText(e[r]);i.error?t.push({path:e[r],error:i.error}):i.exists&&(n[r]=Oe(i.text).description??void 0)}catch(i){t.push({path:e[r],error:De(i)})}};return await Promise.all(Array.from({length:Math.min(dn,e.length)},l)),n}const pn=/^[a-z0-9][a-z0-9-]{0,63}$/,fn="Use lowercase letters, digits and hyphens (max 64), starting with a letter or digit",xn=(e,t)=>e==="skills"?["---",`name: ${t}`,'description: ""',"---","",`# ${t}`,""].join(`
25
+ `):["---",'description: ""',"---",""].join(`
26
+ `),vt=(e,t,n)=>`${e} ${e===1?t:n}`;function kt({label:e,count:t,testId:n}){return s.jsxs("div",{"data-testid":n,className:"flex items-center gap-2 mt-3 mx-1.5 mb-1 text-[11px] font-semibold tracking-[0.06em] uppercase text-fg-faint",children:[e,s.jsx("span",{"data-testid":`${n}-count`,className:"font-mono font-medium tracking-normal text-fg-faint/60",children:t})]})}function Se({children:e,testId:t,title:n}){return s.jsx("div",{"data-testid":t,title:n,className:"mx-1.5 mb-1 text-xs text-fg-faint",children:e})}function hn({onAdd:e,scope:t="user"}={}){const n=yt(),a=wt(),l=(a==null?void 0:a.cwd)??null,[r,i]=f.useState([]),[o,h]=f.useState(null),[m,g]=f.useState(""),[u,x]=f.useState([]),[v,p]=f.useState(null),[b,w]=f.useState(!1),[C,A]=f.useState(null),[J,P]=f.useState(""),[B,N]=f.useState(null),L=f.useRef(null),G=f.useRef(null),ae=nn(n,t==="user"),ee=f.useMemo(()=>ae.flatMap(c=>c.items),[ae]),$e=f.useRef(ee);$e.current=ee;const ue=f.useMemo(()=>n?un(n,l):null,[n,l]),R=f.useMemo(()=>ue?t==="user"?ue.user:ue.project:null,[t,ue]),W=f.useRef(0),me=f.useCallback(async()=>{const c=++W.current;if(!R){i([]),x([]),w(!0);return}const j=[],S=[];try{const y=await jt(R.skills);S.push(...y.errors);for(const $ of y.entries)j.push({kind:"skills",scope:t,name:$.name,path:$.path,dir:$.dir,disabled:bs($.text),description:Oe($.text).description??void 0})}catch(y){S.push({path:R.skills,error:De(y)})}try{const y=await window.api.config.listDir(R.commands,{filesOnly:!0});y.ok||S.push({path:R.commands,error:y.error??"failed to list directory"});const $=y.entries.filter(U=>U.name.endsWith(".md")),F=await mn($.map(U=>U.path),S);$.forEach((U,X)=>{j.push({kind:"commands",scope:t,name:U.name.replace(/\.md$/,""),path:U.path,dir:null,disabled:!1,description:F[X]})})}catch(y){S.push({path:R.commands,error:De(y)})}if(W.current===c){for(const y of S)q.error(`Could not read ${y.path}: ${y.error}`);x(S),j.sort((y,$)=>y.kind===$.kind?y.name.localeCompare($.name):y.kind==="skills"?-1:1),i(j),w(!0),h(y=>{var $;return j.find(F=>F.path===y)||$e.current.some(F=>F.path===y)?y:(($=j[0])==null?void 0:$.path)??null})}},[R,t]);f.useEffect(()=>{me()},[me]),f.useEffect(()=>()=>{W.current+=1},[]);const D=f.useRef(me);D.current=me;const Ce=f.useRef(r);Ce.current=r;const K=f.useRef(o);K.current=o;const Y=f.useRef(null),H=f.useRef(!1),V=f.useRef(!1),ke=f.useCallback(async()=>{if(H.current){V.current=!0;return}H.current=!0;try{await D.current()}finally{H.current=!1}V.current&&(V.current=!1,ke())},[]);f.useEffect(()=>()=>{Y.current&&clearTimeout(Y.current)},[]);const Ee=f.useCallback(c=>{var $;const j=K.current,S=j?Ce.current.find(F=>F.path===j):null,y=j?($=T.getState().files[j])==null?void 0:$.lastSavedAt:null;S!=null&&S.dir&&y&&Date.now()-y<cn&&(c===S.dir||S.dir.startsWith(`${c}/`))||(Y.current&&clearTimeout(Y.current),Y.current=setTimeout(()=>{Y.current=null,ke()},on))},[ke]);Nt(R?[R.skills,R.commands]:[],Ee);const re=T(c=>c.files),O=T(c=>c.loadText),M=T(c=>c.setDraft),pe=T(c=>c.saveText),Ae=T(c=>c.revert),Le=T(c=>c.watchFile),fe=T(c=>c.unwatchFile);async function Re(c,j){const S=await window.api.config.readText(c.path);if(!S.exists)return;const y=ks(S.text,j);if(y===S.text)return;const $=await window.api.config.writeText(c.path,y);if(!$.ok){q.error($.error??"failed to update skill");return}i(F=>F.map(U=>U.path===c.path?{...U,disabled:j}:U)),T.getState().files[c.path]&&T.getState().loadText(c.path,!0)}async function Ie(c){if(!c.dir)return;p(null);const j=await window.api.files.delete(c.dir);if(!j.ok){q.error(j.error??"failed to remove skill");return}q.info(`Removed "${c.name}" — moved to trash`),fe(c.path),i(S=>{const y=S.filter($=>$.path!==c.path);return h($=>{var F;return $!==c.path?$:((F=y[0])==null?void 0:F.path)??null}),y})}f.useEffect(()=>{if(o)return re[o]||O(o),Le(o),()=>fe(o)},[o]);const[Be,le]=f.useState(null),ie=!!(o&&re[o]);f.useEffect(()=>{var j;if(!ie||!o||L.current!==o)return;const c=(j=G.current)==null?void 0:j.querySelector('[data-testid="skill-detail-description"]');c&&(L.current=null,c.focus())},[ie,o]);function oe(c){g(""),P(""),N(null),A(c)}function je(){A(null),P(""),N(null)}async function Ke(c,j){if(!R)return;const S=j.trim();if(!pn.test(S)){N(fn);return}const y=c==="skills"?"skill":"command";if(r.some(X=>X.kind===c&&X.name===S)){N(`A ${y} named "${S}" already exists`);return}const $=c==="skills"?`${R.skills}/${S}`:null,F=c==="skills"?`${$}/SKILL.md`:`${R.commands}/${S}.md`;try{if((await window.api.config.readText(F)).exists){N(`A ${y} named "${S}" already exists`);return}const se=await window.api.config.writeText(F,xn(c,S));if(!se.ok)throw new Error(se.error??"write failed")}catch(X){q.error(`Could not create ${y} "${S}": ${De(X)}`),je(),h(null);return}je();const U={kind:c,scope:t,name:S,path:F,dir:$,disabled:!1,description:""};i(X=>[...X.filter(se=>se.path!==F),U].sort((se,at)=>se.kind===at.kind?se.name.localeCompare(at.name):se.kind==="skills"?-1:1)),L.current=F,h(F)}if(!n)return s.jsx(ne,{title:"loading…"});if(t==="project"&&!l)return s.jsx(Te,{toolbar:s.jsx(s.Fragment,{}),children:s.jsx(ne,{title:"no active project",hint:"open a tab in a project directory to view project skills & commands"})});const z=o?re[o]:null,te=o?r.find(c=>c.path===o)??null:null,_e=!te&&o?ee.find(c=>c.path===o)??null:null,ce=m.trim().toLowerCase().replace(/^\//,""),ye=c=>{var j;return!ce||c.name.toLowerCase().includes(ce)||!!((j=c.description)!=null&&j.toLowerCase().includes(ce))},d=r.filter(c=>c.kind==="skills"),k=r.filter(c=>c.kind==="commands"),E=d.filter(ye),_=k.filter(ye),I=c=>c?u.filter(j=>j.path===c||j.path.startsWith(`${c}/`)):[],Z=I(R==null?void 0:R.skills),xe=I(R==null?void 0:R.commands),we=()=>oe("skills"),We=[{label:"New skill",testId:"skills-new-skill",onSelect:we},{label:"New command",testId:"skills-new-command",onSelect:()=>oe("commands")},...e?[{label:"Browse catalog…",testId:"skills-new-browse-catalog",onSelect:e}]:[]],st=c=>C!==c?null:s.jsxs("div",{"data-testid":`skills-new-row-${c}`,className:"mx-0.5 mb-1 flex flex-col gap-1",children:[s.jsx("input",{autoFocus:!0,"data-testid":`skills-new-name-${c}`,"aria-label":c==="skills"?"New skill name":"New command name","aria-invalid":B?"true":void 0,placeholder:c==="skills"?"skill-name":"command-name",value:J,spellCheck:!1,onChange:j=>{P(j.target.value),N(null)},onKeyDown:j=>{j.key==="Escape"?(j.preventDefault(),j.stopPropagation(),je()):j.key==="Enter"&&(j.preventDefault(),Ke(c,J))},className:`h-7 px-2.5 bg-bg-hi border rounded-[7px] font-mono text-[12.5px] text-fg outline-none ${B?"border-red-400":"border-accent"}`}),B&&s.jsx("div",{"data-testid":`skills-new-error-${c}`,role:"alert",className:"mx-1 text-[11px] text-red-400",children:B})]}),nt=c=>{var y;const j=o===c.path,S=!!((y=re[c.path])!=null&&y.dirty);return s.jsxs("div",{"data-testid":"skills-item","data-path":c.path,onClick:()=>h(c.path),className:`flex flex-col gap-[3px] px-2.5 py-2 bg-bg-hi border rounded-[7px] cursor-pointer ${j?"border-accent":"border-line hover:border-rule"}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button","data-testid":"skills-item-name","aria-current":j?"true":void 0,title:c.disabled?"Disabled — Claude will not auto-invoke this skill":void 0,className:`flex-1 min-w-0 truncate text-left font-mono text-[12.5px] font-semibold text-fg ${c.disabled?"line-through opacity-50":""}`,children:["/",c.name]}),s.jsx(Qe,{interactive:!1,scope:c.scope,input:{type:c.kind==="commands"?"command":"skill",name:c.name}}),S&&s.jsx("span",{"data-testid":"skills-item-dirty",title:"Unsaved edits",className:"shrink-0 w-1 h-1 rounded-full bg-accent"}),c.kind==="skills"&&s.jsxs("span",{className:"shrink-0 flex items-center gap-2",onClick:$=>$.stopPropagation(),children:[s.jsx("span",{title:S?"This skill has unsaved edits — save or revert before toggling":void 0,children:s.jsx(ts,{checked:!c.disabled,disabled:S,onChange:$=>void Re(c,!$)})}),v===c.path?s.jsxs("span",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:()=>void Ie(c),title:`Remove ${c.name} — moves the folder to trash; reinstall from the Library`,className:"text-[10px] font-semibold text-red-400 hover:text-red-300",children:"confirm"}),s.jsx("button",{type:"button",onClick:()=>p(null),title:"Cancel",className:"text-[10px] text-fg-faint hover:text-fg",children:"cancel"})]}):s.jsx("button",{type:"button",onClick:()=>p(c.path),title:"Remove skill — moves the folder to trash; reinstall from the Library","aria-label":`Remove ${c.name}`,className:"text-fg-faint hover:text-red-400 leading-none px-0.5",children:"✕"})]})]}),c.description&&s.jsx("div",{"data-testid":"skills-item-desc",title:c.description,className:"truncate text-[11.5px] text-fg-faint",children:c.description})]},c.path)};let he=null;E.length>0?he=E.map(nt):b?d.length>0?he=s.jsx(Se,{children:"No skills match the filter"}):Z.length>0?he=s.jsx(Se,{testId:"skills-list-skills-error",title:Z.map(c=>`${c.path}: ${c.error}`).join(`
27
+ `),children:"Could not list skills"}):he=s.jsxs("div",{"data-testid":"skills-empty",className:"mx-0.5 mb-1 px-3 py-[11px] flex flex-col gap-[5px] border border-dashed border-rule rounded-[7px] text-xs leading-[1.45] text-fg-dim",children:[s.jsx("span",{className:"font-semibold text-fg",children:"No skills yet"}),s.jsx("span",{children:"A skill is a folder with a SKILL.md that Claude loads when a task calls for it."}),s.jsx("button",{type:"button","data-testid":"skills-create-link",onClick:()=>we(),className:"self-start font-semibold text-accent hover:underline",children:"Create a skill →"})]}):he=null;let ge=null;return _.length>0?ge=_.map(nt):b?k.length>0?ge=s.jsx(Se,{children:"No commands match the filter"}):xe.length>0?ge=s.jsx(Se,{testId:"skills-list-commands-error",title:xe.map(c=>`${c.path}: ${c.error}`).join(`
28
+ `),children:"Could not list slash commands"}):ge=s.jsx(Se,{children:"No slash commands"}):ge=null,s.jsxs("div",{ref:G,className:"h-full flex flex-col",children:[s.jsx(Ct,{filter:m,onFilterChange:g,placeholder:"Filter skills and commands",summary:[vt(d.length,"skill","skills"),vt(k.length,"command","commands"),...t==="user"?[`${ee.length} from plugins`]:[]].join(" · "),primary:{label:"+ New",testId:"skills-new",items:We}}),s.jsx("div",{className:"flex-1 min-h-0",children:s.jsx(Te,{children:s.jsx(St,{sidebarWidth:"300px",sidebar:s.jsxs("div",{"data-testid":"skills-list",className:"flex flex-col gap-1 px-2 py-1",children:[s.jsx(kt,{label:"Skills",count:E.length,testId:"skills-section-skills"}),st("skills"),he,s.jsx(kt,{label:"Slash commands",count:_.length,testId:"skills-section-commands"}),st("commands"),ge,t==="user"&&b&&s.jsx(ln,{plugins:ae,needle:ce,selectedPath:o,onSelect:h})]}),detail:te&&z?s.jsx(xt,{item:te,home:n,draft:z.draftRaw,dirty:z.dirty,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:Be,onDraftChange:c=>{le(null),M(te.path,c)},onSave:async()=>{le(null);const c=await pe(te.path);c.ok||le(c.error??"save failed")},onRevert:()=>{le(null),Ae(te.path)}}):_e&&z?s.jsx(xt,{readOnly:!0,item:{..._e,scope:t},home:n,draft:z.draftRaw,dirty:!1,busy:z.busy,lastSavedAt:z.lastSavedAt,saveError:null,onDraftChange:()=>{},onSave:()=>{},onRevert:()=>{}}):r.length===0&&u.length>0?s.jsx("div",{"data-testid":"skills-list-error",children:s.jsx(ne,{title:"could not list skills or commands",hint:u.map(c=>`${c.path}: ${c.error}`).join(`
29
+ `)})}):s.jsx(ne,{title:r.length===0?"no skills or commands":"select an item"})})})})]})}const En=f.memo(hn);export{Ct as E,Xs as M,En as S,Cn as a,Mt as b,tt as c,wn as d,Pt as e,Nn as f,Ot as g,Sn as i,It as l,Os as r,$n as s};
@@ -1 +1 @@
1
- import{b9 as p,aJ as d,ak as g,at as o,b7 as b}from"./index-CuAfFXNd.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function w({path:e,keyPath:t,note:l}){const u=p(),[n,r]=d.useState(void 0);d.useEffect(()=>{let i=!0;const c=()=>{window.api.config.readText(e,{maxBytes:1}).then(s=>{i&&r(s.exists?s.mtimeMs:null)}).catch(()=>{i&&r(void 0)})};c();const x=window.api.config.onChanged(s=>{s.path===e&&c()});return()=>{i=!1,x()}},[e]);const f=h(e,u)+(t&&t.length?` › ${t.join(".")}`:""),a=n===void 0?"":n===null?"created on first save":g(n),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return o.jsxs("button",{type:"button","data-testid":"source-chip",title:l??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[o.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),a&&o.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",a]})]})}export{w as S};
1
+ import{be as p,aN as d,an as g,ax as o,bc as b}from"./index-9ajPMXBg.js";function h(e,t){return t&&(e===t||e.startsWith(t+"/"))?"~"+e.slice(t.length):e}function w({path:e,keyPath:t,note:l}){const u=p(),[n,r]=d.useState(void 0);d.useEffect(()=>{let i=!0;const c=()=>{window.api.config.readText(e,{maxBytes:1}).then(s=>{i&&r(s.exists?s.mtimeMs:null)}).catch(()=>{i&&r(void 0)})};c();const x=window.api.config.onChanged(s=>{s.path===e&&c()});return()=>{i=!1,x()}},[e]);const f=h(e,u)+(t&&t.length?` › ${t.join(".")}`:""),a=n===void 0?"":n===null?"created on first save":g(n),m=()=>{b.getState().openFile(e),window.dispatchEvent(new CustomEvent("sm:open-editor"))};return o.jsxs("button",{type:"button","data-testid":"source-chip",title:l??`Open ${e} in the editor`,onClick:m,className:"inline-flex items-center gap-1.5 max-w-full text-[11px] px-2 py-0.5 rounded border border-line bg-bg-elev text-fg-dim hover:bg-bg-hi",children:[o.jsx("span",{className:"font-mono truncate","data-testid":"source-chip-path",children:f}),a&&o.jsxs("span",{className:"text-fg-dim/70 shrink-0","data-testid":"source-chip-age",children:["· ",a]})]})}export{w as S,h as s};
@@ -0,0 +1 @@
1
+ import{aN as i,b8 as d,ax as e,a8 as E,b4 as O,be as _,C as B,l as C,ag as P}from"./index-9ajPMXBg.js";import{P as $}from"./Panel-g2D-e-RM.js";import{S as z,I as H}from"./Library-DVXk77zA.js";import{D as W}from"./DocumentEditorPane-FUC2hZlp.js";import{S as q}from"./SourceChip-jrC0vjfw.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-BWljh5IK.js";const G=300;function J({activePath:o,selectedPath:r,onSelect:s}){const[f,n]=i.useState([]),x=i.useRef(0),j=i.useRef(s);j.current=s;const h=d(a=>{var l;return o?(l=a.files[o])==null?void 0:l.diskRaw:void 0}),u=i.useRef(null);if(i.useEffect(()=>{j.current(null)},[o]),i.useEffect(()=>{if(x.current+=1,!o){u.current=null,n([]);return}const a=u.current!==o;u.current=o;let l=!1;const m=()=>{x.current+=1;const y=x.current;window.api.config.parseImports(o).then(p=>{l||x.current!==y||(p.ok?n(p.imports):(n([]),O.error(p.error||"failed to parse @-imports")))})},v=a?null:setTimeout(m,G);return a&&m(),()=>{l=!0,v&&clearTimeout(v)}},[o,h]),f.length===0||!o)return null;const b=r===o||r===null;return e.jsxs("div",{className:"w-64 shrink-0 border-r border-line bg-bg-elev overflow-auto","data-testid":"referenced-files-rail",children:[e.jsxs("div",{className:"px-3 py-2 text-[10px] uppercase tracking-wide text-fg-faint border-b border-line",children:["Documents · ",f.length+1]}),e.jsxs("button",{type:"button",onClick:()=>s(null),"aria-current":b,"data-testid":"referenced-file-root",className:`w-full text-left px-3 py-2 border-b border-line ${b?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsx("div",{className:"text-[11.5px] font-medium truncate",children:E(o)}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:o,children:"this system prompt"})]}),f.map(a=>{const l=!a.ok||!a.exists,m=r===a.path;return e.jsxs("button",{type:"button",onClick:()=>s(a),"aria-current":m,"data-testid":"referenced-file-row",className:`w-full text-left px-3 py-2 border-b border-line last:border-b-0 ${m?"bg-bg-hi text-fg":"text-fg-dim hover:bg-bg"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-[11.5px] font-medium truncate flex-1",children:E(a.path)}),l&&e.jsx("span",{className:"shrink-0 px-1.5 py-0.5 rounded text-[9px] uppercase tracking-wide text-amber-400/90 border border-amber-400/30","data-testid":"referenced-file-missing",children:"missing"})]}),e.jsx("div",{className:"text-[10px] text-fg-faint truncate",title:a.path,children:a.path}),e.jsxs("div",{className:"text-[10px] text-fg-faint",children:[a.sizeBytes.toLocaleString()," bytes · ~",a.tokenEstimate.toLocaleString()," tokens"]})]},a.path)})]})}const R={title:"User system prompt",body:"This is the real ~/.claude/CLAUDE.md on disk — the instructions the claude CLI loads into every session it starts on this machine, in every project. A project's own CLAUDE.md / CLAUDE.local.md are read from that project's directory when a session launches there; they are not edited here."};function K(){const o=_(),r=i.useMemo(()=>o?B.resolve("user",o,null):null,[o]),[s,f]=i.useState(null),n=(s==null?void 0:s.path)??r,[x,j]=i.useState({});i.useEffect(()=>{const t=s==null?void 0:s.path;if(!t||!s.ok||!s.exists)return;let k=!0;return Promise.resolve().then(()=>window.api.config.canWrite(t)).then(I=>{k&&j(M=>({...M,[t]:I===!1}))}).catch(()=>{}),()=>{k=!1}},[s]);const h=!!s&&x[s.path]===!0,u=!!s&&(!s.ok||!s.exists||h),b=d(t=>t.files),a=d(t=>t.loadText),l=d(t=>t.setDraft),m=d(t=>t.saveText),v=d(t=>t.revert),y=d(t=>t.watchFile),p=d(t=>t.unwatchFile);i.useEffect(()=>{if(r)return a(r,!0),y(r),()=>{p(r)}},[r]),i.useEffect(()=>{if(!(!n||n===r))return a(n,!0),y(n),()=>{p(n)}},[n,r]);const[D,g]=i.useState(null),T=i.useCallback(t=>{g(null),f(t)},[]);if(!o)return e.jsx(C,{title:"loading…"});const L=r?b[r]:null,c=n?b[n]:null,N=(c==null?void 0:c.draftRaw)??"",U=P(N),A=N.length,F=u&&!h,S=u,w=async()=>{if(!n)return;g(null);const t=await m(n);t.ok||g(t.error??"save failed")};return e.jsx($,{toolbar:e.jsxs(e.Fragment,{children:[r&&e.jsx(H,{path:r,disabled:!!s}),e.jsx("span",{className:"mx-2 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:"User scope"}),e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:n??"—"}),r&&e.jsx("span",{className:"ml-3",children:e.jsx(q,{path:r})}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-fg-faint",children:[A.toLocaleString()," chars · ~",U.toLocaleString()," tokens"]})]}),footer:n&&c&&!S?e.jsx(z,{dirty:c.dirty,busy:c.busy,parseError:D,lastSavedAt:c.lastSavedAt,leading:c.exists?s?e.jsx("span",{children:"editing an imported file"}):null:e.jsx("span",{children:"file will be created on save"}),onSave:w,onRevert:()=>{g(null),v(n)}}):null,children:r&&L?e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{"data-testid":"system-prompt-scope-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-2 text-[11.5px] leading-snug",children:[e.jsx("span",{className:"font-semibold text-fg",children:R.title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:R.body}),e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:r})]}),e.jsxs("div",{className:"flex-1 min-h-0 flex",children:[e.jsx(J,{activePath:r,selectedPath:n,onSelect:T}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[F&&e.jsx("div",{"data-testid":"system-prompt-missing-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:"This import does not resolve to a readable file — the CLI will skip it."}),h&&s&&e.jsxs("div",{"data-testid":"system-prompt-readonly-note",className:"shrink-0 border-b border-line bg-bg-elev px-3 py-1.5 text-[11px] text-amber-400/90",children:["Read-only: ",e.jsx("span",{className:"font-mono",children:s.path})," is outside the folders Session Manager may write to."]}),n&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(W,{path:n,value:N,readOnly:S,defaultMode:"split",onChange:t=>{g(null),l(n,t)},onSave:()=>{w()}},n)})]})]})]}):e.jsx(C,{title:"resolving…"})})}const se=i.memo(K);export{se as SystemPrompt};
@@ -1,4 +1,4 @@
1
- import{aO as aa,aJ as G,R as Pt,at as R,G as Nf,aq as If,a5 as Rf}from"./index-CuAfFXNd.js";import"./monaco-editor-BsIlgG7c.js";var zi={exports:{}},$i={};/**
1
+ import{aS as aa,aN as G,R as Pt,ax as R,N as Nf,at as If,a6 as Rf}from"./index-9ajPMXBg.js";import"./monaco-editor-BsIlgG7c.js";var zi={exports:{}},$i={};/**
2
2
  * @license React
3
3
  * use-sync-external-store-shim.production.js
4
4
  *
@@ -1 +1 @@
1
- import{at as r}from"./index-CuAfFXNd.js";function a({checked:t,onChange:e,label:n,disabled:s}){return r.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${s?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[r.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:s,onClick:()=>!s&&e(!t),className:`relative w-7 h-4 rounded-full transition-colors ${t?"bg-accent":"bg-bg-hi border border-line"}`,children:r.jsx("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-fg transition-transform ${t?"translate-x-3.5":"translate-x-0.5"}`})}),n&&r.jsx("span",{className:"text-fg-dim",children:n})]})}export{a as T};
1
+ import{ax as r}from"./index-9ajPMXBg.js";function a({checked:t,onChange:e,label:n,disabled:s}){return r.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${s?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:[r.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:s,onClick:()=>!s&&e(!t),className:`relative w-7 h-4 rounded-full transition-colors ${t?"bg-accent":"bg-bg-hi border border-line"}`,children:r.jsx("span",{className:`absolute top-0.5 w-3 h-3 rounded-full bg-fg transition-transform ${t?"translate-x-3.5":"translate-x-0.5"}`})}),n&&r.jsx("span",{className:"text-fg-dim",children:n})]})}export{a as T};
@@ -0,0 +1 @@
1
+ import{ax as r}from"./index-9ajPMXBg.js";function n({options:t,active:o,onChange:i}){return r.jsx("div",{className:"flex rounded border border-line overflow-hidden",children:t.map(({key:e,label:x})=>r.jsx("button",{onClick:()=>i(e),className:`px-2 py-0.5 text-xs ${o===e?"bg-bg-hi text-fg":"text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:x},e))})}export{n as V};
@@ -1 +1 @@
1
- import{bn as o,bl as m,a8 as j,at as e,aS as l,bk as b,aw as R}from"./index-CuAfFXNd.js";let u=0;const T=1e3;function w(n){const s=performance.now();s-u<T||(u=s,R.debug("voice","mic.gate.click_rejected",{reason:n}))}function y(){const n=o(t=>t.isRecording),s=o(t=>t.error),i=o(t=>t.loadingProgress),r=o(m(l)),x=()=>{const t=o.getState(),{canRecord:h,reason:a}=l(t);if(t.isRecording)return t.stopRecording();if(t.wizardArmed&&!t.wizardOpen){t.openWizard();return}if(a==="error"||a==="load-timeout"){t.resetAndRetryModel();return}if(!h)return w(a);const c=b.getState().activeTabId;c&&t.startRecording(c)},d=j(r.reason,{loadingPct:i,errorMessage:s,isRecording:n}),g=r.reason==="unsupported",p=!r.canRecord,f=r.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":r.reason==="error"||r.reason==="load-timeout"?"text-red-400 cursor-pointer":r.reason==="permission-denied"?"text-amber-400 cursor-pointer":r.reason==="idle"?"text-fg-faint cursor-pointer":r.reason==="unsupported"?"text-fg-faint cursor-not-allowed":n?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return e.jsx("button",{onClick:x,disabled:g,"aria-disabled":p,"aria-label":d,title:d,"data-testid":"mic-button","data-state":r.reason,className:`p-1.5 rounded transition-colors ${f}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),e.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function v(){const n=o(i=>i.ttsEnabled),s=o(i=>i.toggleTTS);return e.jsxs("button",{onClick:s,title:n?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${n?"text-accent":"text-fg-dim hover:text-fg"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),n?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),e.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),e.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}export{v as T,y as V};
1
+ import{bs as o,bq as m,aa as j,ax as e,aX as l,bp as b,aA as R}from"./index-9ajPMXBg.js";let u=0;const T=1e3;function w(n){const s=performance.now();s-u<T||(u=s,R.debug("voice","mic.gate.click_rejected",{reason:n}))}function k(){const n=o(t=>t.isRecording),s=o(t=>t.error),i=o(t=>t.loadingProgress),r=o(m(l)),x=()=>{const t=o.getState(),{canRecord:h,reason:a}=l(t);if(t.isRecording)return t.stopRecording();if(t.wizardArmed&&!t.wizardOpen){t.openWizard();return}if(a==="error"||a==="load-timeout"){t.resetAndRetryModel();return}if(!h)return w(a);const c=b.getState().activeTabId;c&&t.startRecording(c)},d=j(r.reason,{loadingPct:i,errorMessage:s,isRecording:n}),g=r.reason==="unsupported",p=!r.canRecord,f=r.reason==="loading"?"text-fg-faint animate-pulse cursor-wait":r.reason==="error"||r.reason==="load-timeout"?"text-red-400 cursor-pointer":r.reason==="permission-denied"?"text-amber-400 cursor-pointer":r.reason==="idle"?"text-fg-faint cursor-pointer":r.reason==="unsupported"?"text-fg-faint cursor-not-allowed":n?"text-red-400 ring-2 ring-red-400 animate-pulse":"text-fg-dim hover:text-fg";return e.jsx("button",{onClick:x,disabled:g,"aria-disabled":p,"aria-label":d,title:d,"data-testid":"mic-button","data-state":r.reason,className:`p-1.5 rounded transition-colors ${f}`,children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"9",y:"1",width:"6",height:"12",rx:"3"}),e.jsx("path",{d:"M5 10a7 7 0 0 0 14 0"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"})]})})}function v(){const n=o(i=>i.ttsEnabled),s=o(i=>i.toggleTTS);return e.jsxs("button",{onClick:s,title:n?"Read Claude replies aloud: ON":"Read Claude replies aloud: OFF",className:`px-1.5 py-1 rounded transition-colors flex items-center gap-1 ${n?"text-accent":"text-fg-dim hover:text-fg"}`,children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),n?e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07"}),e.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14"})]}):e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:"23",y1:"9",x2:"17",y2:"15"}),e.jsx("line",{x1:"17",y1:"9",x2:"23",y2:"15"})]})]}),e.jsx("span",{className:"text-[10px] font-medium tracking-wide",children:"TTS"})]})}export{v as T,k as V};
@@ -1 +1 @@
1
- import{bq as s}from"./index-CuAfFXNd.js";function a(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e)<1?4:2;return`$${e.toFixed(r)}`}function u(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1)}B`:r>=1e6?`${(e/1e6).toFixed(1)}M`:r>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`}function f(t){const e=Number.isFinite(t)?t:0;return Math.round(e).toLocaleString("en-US")}function m(t){const e=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(e<60)return`${e}m`;const r=Math.floor(e/60),n=e%60;return n===0?`${r}h`:`${r}h ${n}m`}function h(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}async function l(t,e=5e3){try{return{ok:!0,data:await s(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:t})),e,"history.dashboard")}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function c(t){return`${a(t.costUsd)} · ${u(t.tokens)} tok`}function b(t,e){const r=e!=null&&e.day?t.days.filter(o=>o.date===e.day).flatMap(o=>Object.values(o.byProject)):[t.totals];let n=0,i=0;for(const o of r)n+=o.estimatedCostUsd,i+=o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreationTokens;return{costUsd:n,tokens:i,label:c({costUsd:n,tokens:i})}}export{c as a,l as f,f as i,m,h as p,b as s,u as t,a as u};
1
+ import{bv as s}from"./index-9ajPMXBg.js";function a(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e)<1?4:2;return`$${e.toFixed(r)}`}function u(t){const e=Number.isFinite(t)?t:0,r=Math.abs(e);return r>=1e9?`${(e/1e9).toFixed(1)}B`:r>=1e6?`${(e/1e6).toFixed(1)}M`:r>=1e3?`${(e/1e3).toFixed(1)}K`:`${Math.round(e)}`}function f(t){const e=Number.isFinite(t)?t:0;return Math.round(e).toLocaleString("en-US")}function m(t){const e=Math.max(0,Math.round(Number.isFinite(t)?t:0));if(e<60)return`${e}m`;const r=Math.floor(e/60),n=e%60;return n===0?`${r}h`:`${r}h ${n}m`}function h(t){return Number.isFinite(t)?t>0&&t<1?"<1%":`${t.toFixed(1)}%`:"0.0%"}async function l(t,e=5e3){try{return{ok:!0,data:await s(Promise.resolve().then(()=>window.api.history.dashboard({rangeDays:t})),e,"history.dashboard")}}catch(r){return{ok:!1,error:r instanceof Error?r.message:String(r)}}}function c(t){return`${a(t.costUsd)} · ${u(t.tokens)} tok`}function b(t,e){const r=e!=null&&e.day?t.days.filter(o=>o.date===e.day).flatMap(o=>Object.values(o.byProject)):[t.totals];let n=0,i=0;for(const o of r)n+=o.estimatedCostUsd,i+=o.inputTokens+o.outputTokens+o.cacheReadTokens+o.cacheCreationTokens;return{costUsd:n,tokens:i,label:c({costUsd:n,tokens:i})}}export{c as a,l as f,f as i,m,h as p,b as s,u as t,a as u};