claude-code-session-manager 0.133.1 → 0.135.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.
- package/dist/assets/AgentLibrary-DRlcF1YD.js +2 -0
- package/dist/assets/{AppSettings-DwnfV9-4.js → AppSettings-CBhYHKGI.js} +2 -2
- package/dist/assets/{Button-CObXxw7b.js → Button-DtBUGvGI.js} +1 -1
- package/dist/assets/{DocumentEditorPane-CgB5IuOY.js → DocumentEditorPane-C82c7Qtl.js} +1 -1
- package/dist/assets/{Extensions-Fuhshcl6.js → Extensions-Kn-oUD2_.js} +2 -2
- package/dist/assets/{History-DbUV4jxK.js → History-B4c3Uz9u.js} +2 -2
- package/dist/assets/{Library-COr79GyT.js → Library-1RpLT-aH.js} +1 -1
- package/dist/assets/{ListDetail-DY53nXya.js → ListDetail-xr0oxNkv.js} +1 -1
- package/dist/assets/{Panel-D7NX5iP8.js → Panel-O8XPrpJu.js} +1 -1
- package/dist/assets/{ProjectClaudeConfig-DuWzM8qA.js → ProjectClaudeConfig-DBGhhzg2.js} +5 -5
- package/dist/assets/{ProvenanceBadge-AnwE1p5X.js → ProvenanceBadge-DSaizfZL.js} +1 -1
- package/dist/assets/Scheduler-D2_5NyiR.js +16 -0
- package/dist/assets/{Settings-tt0VZCyz.js → Settings-Clgqb3Lq.js} +2 -2
- package/dist/assets/{SkillReferenceGraph-D_rxqWgq.js → SkillReferenceGraph-D80RA7kR.js} +1 -1
- package/dist/assets/{Skills-BVQPJZaF.js → Skills-DNG7tHSf.js} +10 -10
- package/dist/assets/{SourceChip-DC5XD8KC.js → SourceChip-D-Imzszd.js} +1 -1
- package/dist/assets/{SystemPrompt-XnvP0_cS.js → SystemPrompt-CGlOpUQA.js} +1 -1
- package/dist/assets/{TiptapBody-B_TNEADm.js → TiptapBody-CJFGfBdz.js} +28 -28
- package/dist/assets/{Toggle-CxQO8pGN.js → Toggle-0Ff0bPa_.js} +1 -1
- package/dist/assets/{ViewTabs-CEjnWPD9.js → ViewTabs-BCMYQwo_.js} +1 -1
- package/dist/assets/{VoiceButton-B-6gdmKe.js → VoiceButton-JzyC6DAB.js} +1 -1
- package/dist/assets/geist-sans-latin-300-normal-C3kkMBb6.woff2 +0 -0
- package/dist/assets/geist-sans-latin-400-normal-gapTbOY8.woff2 +0 -0
- package/dist/assets/geist-sans-latin-500-normal-uokXdC-Q.woff2 +0 -0
- package/dist/assets/geist-sans-latin-600-normal-DFOURf8L.woff2 +0 -0
- package/dist/assets/geist-sans-latin-700-normal-BmN9tIp5.woff2 +0 -0
- package/dist/assets/{historyTotals-dT8vcKzX.js → historyTotals-B01WPBwh.js} +1 -1
- package/dist/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/dist/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- package/dist/assets/{index-5QIl5Kcd.css → index-CjQ_p5y7.css} +1 -1
- package/dist/assets/index-rt7pTODX.js +3116 -0
- package/dist/assets/newsreader-latin-400-italic-CEihAR-f.woff2 +0 -0
- package/dist/assets/newsreader-latin-400-normal-BFBkh4jY.woff2 +0 -0
- package/dist/assets/newsreader-latin-500-normal-B66TYsaK.woff2 +0 -0
- package/dist/assets/newsreader-latin-600-normal-30OJ_TG_.woff2 +0 -0
- package/dist/assets/newsreader-latin-700-normal-rIgV_oaK.woff2 +0 -0
- package/dist/index.html +2 -5
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +409 -404
- package/dist-web/index.html +0 -3
- package/package.json +1 -1
- package/plugins/session-manager-dev/skills/develop/standards.md +1 -1
- package/scripts/scheduler-mcp-server.cjs +31 -0
- package/src/main/agentLibrary.cjs +27 -4
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +9 -0
- package/src/main/config.cjs +22 -0
- package/src/main/crashDiagnostics.cjs +10 -2
- package/src/main/index.cjs +34 -25
- package/src/main/ipcSchemas.cjs +6 -0
- package/src/main/lib/agent-cli/agentCliEvents.cjs +8 -0
- package/src/main/lib/demo-video-kit/capture.cjs +4 -37
- package/src/main/lib/demo-video-kit/character.cjs +20 -2
- package/src/main/lib/demo-video-kit/checks.cjs +82 -1
- package/src/main/lib/demo-video-kit/frames.cjs +3 -28
- package/src/main/lib/demo-video-kit/playwrightLoader.cjs +67 -0
- package/src/main/lib/demo-video-kit/seedKit.cjs +2 -2
- package/src/main/lib/demo-video-kit/sound.cjs +5 -2
- package/src/main/lib/epic/epicMint.cjs +1 -3
- package/src/main/lib/epic/promptSessionsCreateEpic.cjs +37 -4
- package/src/main/lib/epic/restorableSessions.cjs +88 -0
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +56 -1
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +21 -3
- package/src/main/lib/feedback-remote/remoteAssets.cjs +25 -1
- package/src/main/lib/mcpToolCatalog.cjs +15 -0
- package/src/main/lib/persona-macro/agentPersonaSchema.cjs +10 -1
- package/src/main/lib/persona-macro/builtinMacros.cjs +3 -2
- package/src/main/lib/persona-macro/macroJobDispatch.cjs +3 -2
- package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +22 -0
- package/src/main/lib/prd/listPrdsSingleFlight.cjs +79 -0
- package/src/main/lib/prd/prdAgentType.cjs +17 -7
- package/src/main/lib/prd/prdFrontmatter.cjs +25 -1
- package/src/main/lib/scheduler/scheduleJobSchema.cjs +3 -0
- package/src/main/lib/telemetry/crashTelemetry.cjs +10 -5
- package/src/main/lib/telemetry/telemetryBoot.cjs +77 -4
- package/src/main/lib/telemetry/telemetryClient.cjs +54 -9
- package/src/main/lib/telemetry/telemetryConsent.cjs +3 -0
- package/src/main/lib/telemetry/telemetryCounters.cjs +7 -2
- package/src/main/lib/telemetry/telemetrySettings.cjs +5 -0
- package/src/main/promptSessionEvents.cjs +7 -1
- package/src/main/pty.cjs +2 -2
- package/src/main/runVerify.cjs +2 -2
- package/src/main/scheduler/prdParser.cjs +18 -2
- package/src/main/scheduler.cjs +156 -18
- package/src/main/seedAgentPersonas.cjs +24 -0
- package/src/main/seedStatus.cjs +5 -2
- package/src/main/telemetryIpc.cjs +1 -5
- package/src/main/templates/PRD_AUTHORING.md +2 -2
- package/src/preload/api.d.ts +37 -16
- package/src/preload/apiSurface.json +7 -0
- package/src/preload/index.cjs +3 -1
- package/src/seed/agents/demo-video-builder.md +7 -2
- package/src/seed/agents/project-home-builder.md +4 -2
- package/dist/assets/AgentLibrary-BTIBmZkM.js +0 -2
- package/dist/assets/Scheduler-BHfx0rXd.js +0 -16
- package/dist/assets/index-BLORXCcT.js +0 -3111
- package/src/main/lib/telemetry/telemetryBacklog.cjs +0 -607
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b9 as A,ax as e,b5 as D,aN as b,bf as U,b6 as ee,bh as te,bo as K,w as he,l as P,a4 as fe,v as ge,T as se,aX as be,S as _,a as ye,bq as q,bk as ve,aB as je,aF as we,J as ke,as as Ne}from"./index-BLORXCcT.js";import{P as R}from"./Panel-D7NX5iP8.js";import{P as Se,H as Ce,S as _e}from"./Library-COr79GyT.js";import{S as V}from"./SourceChip-DC5XD8KC.js";import{V as B}from"./ViewTabs-CEjnWPD9.js";import{r as ne}from"./claude-settings-schema-COigsajx.js";import{L as Ee}from"./ListDetail-DY53nXya.js";import{a as Pe}from"./ProvenanceBadge-AnwE1p5X.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-CObXxw7b.js";function Te(t){const n=t??{},s={...n.$defs??{},...n.definitions??{}},o=l=>{if(!l)return{};if(!l.$ref)return i(l);const m=/^#\/(\$defs|definitions)\/(.+)$/.exec(l.$ref);if(!m)return i(l);const h=s[m[2]];return h?o({...h,...u(l)}):i(l)},r=new Set(["__proto__","constructor","prototype"]),a=l=>{if(!l)return{};const m={};for(const[h,f]of Object.entries(l))r.has(h)||(m[h]=f);return m},i=l=>{if(!l.allOf||l.allOf.length===0)return l;const m={...l};delete m.allOf;for(const h of l.allOf){const f=o(h);Object.assign(m,{properties:{...a(m.properties),...a(f.properties)},required:Fe([...m.required??[],...f.required??[]])}),!m.description&&f.description&&(m.description=f.description),m.default===void 0&&f.default!==void 0&&(m.default=f.default),!m.type&&f.type&&(m.type=f.type)}return m},u=l=>{const{$ref:m,...h}=l;return h},d=(l,m)=>{let h=o(l);for(const f of m){if(!h)return null;if(/^\d+$/.test(f)){const E=Array.isArray(h.items)?h.items[Number(f)]:h.items;h=E?o(E):null;continue}const w=h.properties;if(w&&!r.has(f)&&f in w){h=o(w[f]);continue}const k=h.additionalProperties;if(k&&typeof k=="object"){h=o(k);continue}return null}return h},c=(l,m,h)=>{if(!l)return null;const f={};if(l.description&&(f.description=l.description),l.type&&(f.type=l.type),l.default!==void 0&&(f.default=l.default),l.enum&&(f.enum=l.enum),l.const!==void 0&&(f.const=l.const),l.deprecated&&(f.deprecated=!0),l.examples&&(f.examples=l.examples),l.properties&&(f.knownChildren=Object.keys(l.properties)),h&&(m!=null&&m.includes(h))&&(f.required=!0),l.items&&!Array.isArray(l.items)){const w=o(l.items),k=c(w,void 0,null);k&&(f.itemsInfo=k)}return(l.additionalProperties===!0||typeof l.additionalProperties=="object")&&(f.open=!0),f},x=l=>m=>{if(m.length===0)return c(o(l),void 0,null);const h=d(l,m.slice(0,-1));if(!h)return null;const f=m[m.length-1],w=d(h,[f]);return c(w,h.required,f)},y=l=>{const m=o(l);return Object.keys(m.properties??{})},g=l=>({at:x(l),rootKeys:()=>y(l),rootedAt:m=>{const h=d(l,m);return g(h??{})}});return g(n)}function Fe(t){return Array.from(new Set(t))}let H=null;function re(){return H||(H=Te(ne)),H}const Oe=["allow","deny","ask"],z="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function Ae(t){if(t.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{perms:{},full:{},err:"settings file is not a JSON object"};const s=n;return{perms:s.permissions??{},full:s,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function Me({scope:t="user"}={}){const n=U(),s=ee(),o=(s==null?void 0:s.cwd)??null,r=te(l=>l.navFace),[a,i]=b.useState("rules");b.useEffect(()=>{r==="project"&&a==="presets"&&i("rules")},[r,a]);const d=K(he,n,o)[t]??null,c=A(l=>l.files),x=e.jsx(B,{options:[{key:"rules",label:"Rules"},...r==="home"?[{key:"presets",label:"Presets"}]:[]],active:a,onChange:i});if(!n)return e.jsx(P,{title:"loading…"});if(a==="presets")return e.jsx(R,{toolbar:x,children:e.jsx(Se,{})});const y=l=>l!=="user"&&!o,g=d?c[d]:null;return e.jsx(R,{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:y(t)?e.jsx(P,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):d&&g?e.jsx(ae,{scope:t,cwd:o,activePath:d}):e.jsx(P,{title:"resolving…"})})}b.memo(Me);function ae({scope:t,cwd:n,activePath:s}){const o=A(c=>c.files[s]),{perms:r,err:a}=o?Ae(o.draftRaw):{perms:{},err:null},i=(c,x)=>{if(a){D.error(z);return}window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:n,keyPath:["permissions",c],value:x}).catch(y=>D.error(y instanceof Error?y.message:String(y)))},u=(c,x)=>{const y=x.trim();if(!y)return;const g=r[c]??[];g.includes(y)||i(c,[...g,y])},d=(c,x)=>{const y=r[c]??[];i(c,y.filter((g,l)=>l!==x))};return e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[a&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[z," (",a,")"]}),e.jsx(Re,{value:r.defaultMode??"default",onChange:c=>i("defaultMode",c)}),Oe.map(c=>e.jsx($e,{list:c,rules:r[c]??[],disabled:!!a,onAdd:x=>u(c,x),onRemove:x=>d(c,x)},c)),e.jsx(Ie,{dirs:r.additionalDirectories??[],disabled:!!a,onChange:c=>i("additionalDirectories",c)})]})}function Re({value:t,onChange:n}){var a;const o=(((a=re().at(["permissions","defaultMode"]))==null?void 0:a.enum)??[]).filter(i=>typeof i=="string"),r=t&&!o.includes(t)?[...o,t]:o;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:r.map(i=>e.jsx("button",{onClick:()=>n(i),className:`px-2.5 py-1 text-xs transition-colors ${t===i?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},i))})]})}function $e({list:t,rules:n,onAdd:s,onRemove:o,disabled:r}){const[a,i]=b.useState(""),u=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 ${u}`,children:t}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:a,disabled:r,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(s(a),i(""))},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:()=>{s(a),i("")},disabled:r||!a.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((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:()=>o(c),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${c}-${d}`))})]})}function Ie({dirs:t,onChange:n,disabled:s}){const[o,r]=b.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:o,disabled:s,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&o.trim()&&(n([...t,o.trim()]),r(""))},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((a,i)=>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:a}),e.jsx("button",{onClick:()=>n(t.filter((u,d)=>d!==i)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${i}-${a}`))})]})}const De={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 }"}},oe=["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"],Le=new Set(oe),He=["command","http","prompt","agent","mcp_tool"],Ue={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:{}},Y="This settings file has invalid JSON. Fix it in the Settings raw editor first; Hooks will not overwrite it.";function Ke(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{full:{},hooks:{},err:"settings file is not a JSON object"};const s=n;return{full:s,hooks:s.hooks??{},err:null}}catch(n){return{full:{},hooks:{},err:n.message}}}function Be(t,n){return(t[n]??[]).reduce((s,o)=>{var r;return s+(((r=o.hooks)==null?void 0:r.length)??0)},0)}function Ge({scope:t="user"}={}){const n=U(),s=ee(),o=(s==null?void 0:s.cwd)??null,r=te(x=>x.navFace),[a,i]=b.useState("events");b.useEffect(()=>{r==="project"&&a==="library"&&i("events")},[r,a]);const d=K(se,n,o)[t]??null,c=e.jsx(B,{options:[{key:"events",label:"Events"},...r==="home"?[{key:"library",label:"Library"}]:[]],active:a,onChange:i});return n?a==="library"?e.jsx(R,{toolbar:c,children:e.jsx(Ce,{})}):t!=="user"&&!o?e.jsx(R,{toolbar:e.jsx(e.Fragment,{children:c}),children:e.jsx(P,{title:"no active project"})}):d?e.jsx(R,{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(ie,{scope:t,cwd:o,path:d})}):e.jsx(P,{title:"loading…"}):e.jsx(P,{title:"loading…"})}function ie({scope:t,cwd:n,path:s,renderLayout:o}){const[r,a]=b.useState("PreToolUse"),[i,u]=b.useState(null),d=(v,j)=>{window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:n,keyPath:v,value:j}).catch(p=>D.error(p instanceof Error?p.message:String(p)))},c=A(v=>v.files[s]),{hooks:x,err:y}=c?Ke(c.draftRaw):{hooks:{},err:null},g=Object.keys(x).filter(v=>!Le.has(v)),l=g.reduce((v,j)=>v+(x[j]??[]).reduce((p,T)=>{var M;return p+(((M=T.hooks)==null?void 0:M.length)??0)},0),0),m=(v,j)=>{if(y){D.error(Y);return}d(["hooks",v],j)},h=x[r]??[],f=()=>{m(r,[...h,{matcher:"",hooks:[{type:"command",command:""}]}])},w=(v,j)=>{const p=h.slice();p[v]=j,m(r,p)},k=v=>{m(r,h.filter((j,p)=>p!==v))},E=e.jsxs(e.Fragment,{children:[y?e.jsxs("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:[Y," (",y,")"]}):null,l>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:"⚠"})," ",l," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:g.join(", ")}),e.jsx("span",{className:"text-fg-faint",children:" · these are ignored by Claude Code 2026; edit settings.json directly to remove."})]}):null]}),N=y||l>0?E:null,S=e.jsx("div",{className:"py-1",children:oe.map(v=>{const j=Be(x,v),p=De[v],T=p?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:p.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",p.payload]}),p.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",p.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(fe,{content:T,align:"bottom-center",children:e.jsxs("button",{onClick:()=>a(v),title:p==null?void 0:p.when,className:`w-full text-left px-3 py-1 text-xs ${r===v?"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:v}),j>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:j})]}),p?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:p.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},v)})}),C=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:f,disabled:!!y,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"})]}),h.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):h.map((v,j)=>e.jsx(Je,{group:v,jsonInvalid:!!y,onChange:p=>w(j,p),onRemove:()=>k(j),onTestFire:p=>u({event:r,matcher:v.matcher??"",command:p.command??""})},j))]});return e.jsxs(e.Fragment,{children:[o?o({banners:N,list:S,detail:C}):e.jsxs("div",{className:"flex flex-col h-full",children:[N,e.jsx(Ee,{sidebarWidth:"14rem",sidebar:S,detail:C})]}),i?e.jsx(Ye,{event:i.event,matcher:i.matcher,command:i.command,onClose:()=>u(null)}):null]})}b.memo(Ge);function I({value:t,onCommit:n,onDraft:s,...o}){const[r,a]=b.useState(t);b.useEffect(()=>a(t),[t]);const i=()=>{r!==t&&n(r)};return e.jsx("input",{...o,value:r,onChange:u=>{a(u.target.value),s==null||s(u.target.value)},onBlur:i,onKeyDown:u=>{u.key==="Enter"&&i()}})}function Je({group:t,jsonInvalid:n,onChange:s,onRemove:o,onTestFire:r}){const a=()=>s({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),i=(d,c)=>{const x=t.hooks.slice();x[d]=c,s({...t,hooks:x})},u=d=>s({...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(I,{value:t.matcher??"",disabled:n,onCommit:d=>s({...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:o,disabled:n,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(qe,{rule:d,jsonInvalid:n,onChange:x=>i(c,x),onRemove:()=>u(c),onTestFire:()=>r(d)},c)),e.jsx("button",{onClick:a,disabled:n,className:"text-xs text-fg-faint hover:text-fg disabled:opacity-40",children:"+ add hook"})]})}function We(t){var s,o,r;const n=((o=(s=ne.$defs)==null?void 0:s.hookCommand)==null?void 0:o.anyOf)??[];for(const a of n){const i=a.properties;if(((r=i==null?void 0:i.type)==null?void 0:r.const)!==t)continue;const u=i.timeout;if(typeof(u==null?void 0:u.default)=="number")return u.default;const d=/default:\s*(\d+)/.exec((u==null?void 0:u.description)??"");return d?Number(d[1]):null}return null}function Z(t){return/^\d+$/.test(t.trim())&&Number(t)>0?Number(t):null}function qe({rule:t,jsonInvalid:n,onChange:s,onRemove:o,onTestFire:r}){const a=l=>({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"})[l],i=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",u=t[i]??"",d=(t.args??[]).join(" "),[c,x]=b.useState(null),y=We(t.type),g={type:"hook",name:u||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:n,onChange:l=>s({type:l.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:He.map(l=>e.jsx("option",{value:l,children:l},l))}),e.jsx(Pe,{interactive:!1,input:g}),e.jsx(I,{value:u,disabled:n,onCommit:l=>s({...t,[i]:l}),placeholder:a(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${n?"border-red-500/70":u.trim()?"border-line":"border-yellow-600/50"}`}),n?e.jsx("span",{className:"text-red-400 text-xs",title:"The enclosing settings.json is malformed; fix the JSON before editing.",children:"× invalid"}):null,e.jsx(I,{value:t.timeout!=null?String(t.timeout):"",disabled:n,"aria-label":"timeout (seconds)","aria-invalid":c?!0:void 0,title:c??"Timeout in seconds",onDraft:l=>{x(!l.trim()||Z(l)!=null?null:"Timeout must be a positive whole number of seconds")},onCommit:l=>{if(!l.trim()){s({...t,timeout:void 0});return}const m=Z(l);m!=null&&s({...t,timeout:m})},placeholder:y!=null?`${y} (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:r,disabled:n||!u.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:o,disabled:n,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(I,{value:d,disabled:n,onCommit:l=>s({...t,args:l.trim()?l.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(I,{value:t.terminalSequence??"",disabled:n,onCommit:l=>s({...t,terminalSequence:l||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 Ve(t){return JSON.stringify(Ue[t]??{},null,2)}function ze(t,n){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const s=n&&typeof n=="object"&&"tool_name"in n?String(n.tool_name??""):null;if(s==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(s),target:s}}catch{return{matched:t===s,target:s,note:"matcher not valid regex; fell back to exact match"}}}function Ye({event:t,matcher:n,command:s,onClose:o}){const[r,a]=b.useState(()=>Ve(t)),[i,u]=b.useState(!1),[d,c]=b.useState(null),[x,y]=b.useState(null);let g=null;try{JSON.parse(r)}catch(m){g=m.message}const l=async()=>{u(!0),c(null);let m=null;try{m=JSON.parse(r)}catch{}y(ze(n,m));try{const h=await window.api.app.testFireHook({command:s,payload:r,timeoutMs:5e3});c(h)}finally{u(!1)}};return e.jsx(ge,{open:!0,onClose:o,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:s})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1",children:n||e.jsx("span",{className:"text-fg-faint",children:"(empty — matches all)"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-fg-faint",children:"fake event payload (stdin)"}),g?e.jsxs("span",{className:"text-red-400",children:["× ",g]}):null]}),e.jsx("textarea",{value:r,onChange:m=>a(m.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${g?"border-red-500/70":"border-line"}`})]}),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:o,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:l,disabled:i||!!g||!s.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:i?"running…":"run"})]})]})})}const le=[{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"]}],X=new Set(le.flatMap(t=>t.keys)),Ze=[{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"]}],Xe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function ce(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((o,r)=>{const a=Xe[o];return a||(r===0?o.charAt(0).toUpperCase()+o.slice(1):o)}).join(" ")}function de(t){const n=new Set,s=[];for(const r of Ze){const a=r.keys.filter(i=>t.has(i)&&!X.has(i));a.forEach(i=>n.add(i)),a.length!==0&&s.push({id:r.id,title:r.title,summary:r.summary,advanced:!!r.advanced,keys:a})}const o=Array.from(t).filter(r=>!n.has(r)&&r!=="$schema"&&!X.has(r)).sort();return o.length>0&&s.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:o}),s}function Qe(t,n){return de(t).map(s=>({id:s.id,title:s.title,advanced:s.advanced,total:s.keys.length,setCount:s.keys.filter(o=>n.has(o)).length}))}const et={};function ue(t,n){if(n)return{text:n,authored:!1};const s=et[t];return s?{text:s,authored:!0}:null}const me=b.createContext(null);function tt(){const t=b.useContext(me);if(!t)throw new Error("usePageShell() must be used inside a <PageShell>.");return t}function O({header:t,subnav:n,footer:s,children:o,subnavWidth:r=220}){const a=b.useRef(null),i=b.useCallback((d,c)=>{const x=a.current;if(!x)return;let y=null;for(const g of Array.from(x.querySelectorAll("[id]")))if(g.id===d){y=g;break}y&&be(x,y,{block:"start",behavior:c==null?void 0:c.behavior})},[]),u=b.useMemo(()=>({scrollToAnchor:i,contentRef:a}),[i]);return e.jsx(me.Provider,{value:u,children:e.jsxs("div",{"data-testid":"page-shell",className:"h-full w-full min-h-0 min-w-0 flex flex-col overflow-clip",children:[t!=null&&e.jsx("div",{"data-testid":"page-shell-header",className:"shrink-0 min-w-0 overflow-clip",children:t}),e.jsxs("div",{"data-testid":"page-shell-body",className:"flex-1 min-h-0 min-w-0 flex flex-row overflow-clip",children:[n!=null&&e.jsx("nav",{"data-testid":"page-shell-subnav",className:"shrink-0 min-h-0 overflow-y-auto overscroll-contain",style:{width:r},children:n}),e.jsx("div",{ref:a,"data-testid":"page-shell-content",className:"flex-1 min-w-0 min-h-0 overflow-y-auto overscroll-contain",children:o})]}),s!=null&&e.jsx("div",{"data-testid":"page-shell-footer",className:"shrink-0 min-w-0 overflow-clip",children:s})]})})}const st={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"},nt=["user","project","local","default"],rt={user:"user",project:"project",local:"local",default:"default"};function at({node:t,schema:n}){const[s,o]=b.useState(""),[r,a]=b.useState(!1),[i,u]=b.useState(!0),d=t.kind==="object"?t:null,c=d?Object.keys(d.children):[],x=n.rootKeys(),y=new Set([...c,...x]),g=Array.from(y).sort().join(","),l=c.join(","),m=b.useMemo(()=>de(y),[g]),h=b.useMemo(()=>Qe(y,new Set(c)),[g,l]),f=b.useMemo(()=>m.filter(w=>r||!w.advanced).map(w=>({...w,keys:w.keys.filter(k=>{const E=(d==null?void 0:d.children[k])!==void 0;if(!i&&!E)return!1;if(!s.trim())return!0;const N=n.at([k]);return[k,ce(k),(N==null?void 0:N.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(w=>w.keys.length>0),[m,s,r,i,d,n]);return{filter:s,setFilter:o,showAdvanced:r,setShowAdvanced:a,showUnset:i,setShowUnset:u,rootNode:d,schema:n,groups:m,railGroups:h,visibleGroups:f}}function ot({cards:t,targetScope:n}){return e.jsxs("div",{className:"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:_[n].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.showUnset,onChange:s=>t.setShowUnset(s.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:t.showAdvanced,onChange:s=>t.setShowAdvanced(s.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:t.filter,onChange:s=>t.setFilter(s.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]})}function it({cards:t,targetScope:n,onOverride:s}){const{visibleGroups:o,rootNode:r,schema:a,filter:i}=t;return e.jsxs("div",{className:"py-3",children:[o.map(u=>e.jsx(dt,{id:u.id,title:u.title,summary:u.summary,advanced:u.advanced,children:u.keys.map(d=>{const c=r==null?void 0:r.children[d],x=a.at([d]);return e.jsx(ut,{keyName:d,node:c,info:x,targetScope:n,onOverride:(y,g)=>s([d],y,g)},d)})},u.id)),o.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',i,'"']})]})}function lt({cards:t}){const n=tt(),[s,o]=b.useState(null),{groups:r,showAdvanced:a,setShowAdvanced:i}=t,u=d=>{const c=r.find(x=>x.id===d);c!=null&&c.advanced&&!a&&i(!0),o(d)};return b.useEffect(()=>{s&&(o(null),n.scrollToAnchor(`settings-group-${s}`,{behavior:"smooth"}))},[s,n]),e.jsx(ct,{groups:t.railGroups,onJump:u})}function ct({groups:t,onJump:n}){return e.jsx("div",{className:"min-h-full border-r border-line bg-bg-elev/30 py-3",children:t.map(s=>e.jsxs("button",{type:"button","data-group-id":s.id,onClick:()=>n(s.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${s.title}`,children:[e.jsx(ye,{name:st[s.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:s.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[s.setCount,"/",s.total]})]},s.id))})}function dt({id:t,title:n,summary:s,advanced:o,children:r}){const[a,i]=b.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:()=>i(!a),children:[e.jsx("span",{className:"text-fg-faint w-3",children:a?"▾":"▸"}),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:n}),o&&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:s})]})]}),a&&e.jsx("div",{className:"divide-y divide-line/60",children:r})]})}function ut({keyName:t,node:n,info:s,targetScope:o,onOverride:r}){const[a,i]=b.useState(!1),[u,d]=b.useState(!1),c=ce(t),x=n!==void 0,g=(n==null?void 0:n.kind)==="leaf"?n:null,l=(n==null?void 0:n.kind)==="object"||(n==null?void 0:n.kind)==="array",m=s==null?void 0:s.default,h=g&&m!==void 0&&xe(g.value,m),f=yt({isSet:x,leafNode:g,defaultVal:m,isDefault:!!h,node:n}),w=mt(g,m),k=w.length>=2,E=!!g&&!h,N=ue(t,s==null?void 0:s.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:()=>i(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),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(vt,{kind:f.kind,label:f.label}),k&&e.jsxs("button",{onClick:S=>{S.stopPropagation(),a||i(!0),d(C=>!C)},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 · ",w.map(S=>rt[S]).join(" · ")]}),E&&g&&e.jsx("button",{onClick:S=>{S.stopPropagation(),r(void 0,g.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 ${_[g.winner].label}`,children:"↺ reset"}),(s==null?void 0:s.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"}),(s==null?void 0:s.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"})]}),N&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${N.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:N.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:jt(N.text)}),a&&u&&g&&e.jsx(pt,{leaf:g,defaultVal:m,onReset:S=>r(void 0,S)}),a&&e.jsx(xt,{keyName:t,node:n,info:s,targetScope:o,onOverride:S=>r(S)})]}),e.jsx("div",{className:"shrink-0",children:!a&&e.jsx(bt,{node:n,info:s,onSet:S=>{r(S)},disabled:l&&x})})]})})}function mt(t,n){if(!t)return[];const s=new Set;s.add(t.winner);for(const o of t.shadowed)s.add(o.scope);return n!==void 0&&s.add("default"),nt.filter(o=>s.has(o))}function pt({leaf:t,defaultVal:n,onReset:s}){const o={};o[t.winner]={value:t.value,winner:!0};for(const r of t.shadowed)o[r.scope]={value:r.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(r=>{const a=o[r],i=a!==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:_[r].label}),e.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:i?$(a.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>s(r),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 ${_[r].label}`,children:"↺"}):e.jsx("span",{})]},r)}),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:n!==void 0?$(n):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function xt({keyName:t,node:n,info:s,targetScope:o,onOverride:r}){const i=(n==null?void 0:n.kind)==="leaf"?n:null,u=ue(t,s==null?void 0:s.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[u&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${u.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:u.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:u.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(s==null?void 0:s.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(s.type)?s.type.join(" | "):s.type})]}),(s==null?void 0:s.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:$(s.default)})]}),(s==null?void 0:s.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:s.enum.map(d=>String(d)).join(" | ")})]}),i&&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:$(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",_[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((d,c)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[$(d.value)," —"," ",e.jsx("span",{className:"no-underline",children:_[d.scope].label})]},c))})]}),(n==null?void 0:n.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[n.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(ht,{keyName:t,node:n,info:s,onChange:r,targetScope:o})})]})}function ht({node:t,info:n,onChange:s,targetScope:o}){const a=(t==null?void 0:t.kind)==="leaf"?t.value:n==null?void 0:n.default,i=pe(n==null?void 0:n.type);if(i==="boolean"){const u=a===!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:()=>s(d),className:`px-3 py-0.5 text-xs transition-colors ${u===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:["→ ",_[o].label]})]})}return n!=null&&n.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),n.enum.map(u=>{const d=xe(a,u);return e.jsx("button",{onClick:()=>s(u),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(u)},String(u))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",_[o].label]})]}):i==="integer"||i==="number"?e.jsx(ft,{value:typeof a=="number"?a:void 0,integer:i==="integer",onCommit:s,target:_[o].label}):i==="string"?e.jsx(gt,{value:typeof a=="string"?a:"",onCommit:s,target:_[o].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function ft({value:t,integer:n,onCommit:s,target:o}){const[r,a]=b.useState(t!==void 0?String(t):""),i=()=>{const u=n?parseInt(r,10):parseFloat(r);Number.isNaN(u)||s(u)};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:r,onChange:u=>a(u.target.value),onBlur:i,onKeyDown:u=>{u.key==="Enter"&&u.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",o]})]})}function gt({value:t,onCommit:n,target:s}){const[o,r]=b.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:o,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&n(o)},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:()=>n(o),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 → ",s]})]})}function bt({node:t,info:n,onSet:s,disabled:o}){const r=(t==null?void 0:t.kind)==="leaf",a=pe(n==null?void 0:n.type);if(o)return null;if(a==="boolean"){const i=r&&t.value===!0;return e.jsx("button",{onClick:()=>s(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"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:i?"on":"off"})}return null}function yt({isSet:t,leafNode:n,defaultVal:s,isDefault:o,node:r}){return t?(r==null?void 0:r.kind)==="array"?{kind:"accumulated",label:`${r.items.length} items`}:(r==null?void 0:r.kind)==="object"?{kind:"set",label:"configured"}:n?o?{kind:"default",label:`= default · ${_[n.winner].label}`}:n.shadowed.length>0?{kind:"override",label:`overriding ${n.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${_[n.winner].label}`}:{kind:"set",label:"configured"}:s!==void 0?{kind:"default",label:`using default: ${$(s)}`}:{kind:"unset",label:"not configured"}}function vt({kind:t,label:n}){const s={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 ${s}`,children:n})}function pe(t){if(t)return Array.isArray(t)?t.find(s=>s!=="null")??t[0]:t}function xe(t,n){return t===n?!0:typeof t!=typeof n?!1:t&&n&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(n):!1}function jt(t){const n=t.trim().split(`
|
|
2
|
-
`)[0],s=n.match(/^([^.!?]+[.!?])/);return s?s[1]:n.length>120?n.slice(0,120)+"…":n}function $(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 n=JSON.stringify(t);return n.length>60?n.slice(0,60)+"…":n}return String(t)}const
|
|
1
|
+
import{bb as A,ay as e,b7 as D,aO as b,bh as U,b8 as ee,bj as te,bq as G,x as he,m as P,a5 as fe,w as ge,U as se,aZ as be,T as _,b as ye,bs as q,bm as ve,aC as je,aG as we,J as ke,at as Ne}from"./index-rt7pTODX.js";import{P as R}from"./Panel-O8XPrpJu.js";import{P as Se,H as Ce,S as _e}from"./Library-1RpLT-aH.js";import{S as V}from"./SourceChip-D-Imzszd.js";import{V as K}from"./ViewTabs-BCMYQwo_.js";import{r as ne}from"./claude-settings-schema-COigsajx.js";import{L as Ee}from"./ListDetail-xr0oxNkv.js";import{a as Pe}from"./ProvenanceBadge-DSaizfZL.js";import"./monaco-editor-BsIlgG7c.js";import"./Button-DtBUGvGI.js";function Te(t){const n=t??{},s={...n.$defs??{},...n.definitions??{}},o=l=>{if(!l)return{};if(!l.$ref)return i(l);const m=/^#\/(\$defs|definitions)\/(.+)$/.exec(l.$ref);if(!m)return i(l);const h=s[m[2]];return h?o({...h,...u(l)}):i(l)},r=new Set(["__proto__","constructor","prototype"]),a=l=>{if(!l)return{};const m={};for(const[h,f]of Object.entries(l))r.has(h)||(m[h]=f);return m},i=l=>{if(!l.allOf||l.allOf.length===0)return l;const m={...l};delete m.allOf;for(const h of l.allOf){const f=o(h);Object.assign(m,{properties:{...a(m.properties),...a(f.properties)},required:Fe([...m.required??[],...f.required??[]])}),!m.description&&f.description&&(m.description=f.description),m.default===void 0&&f.default!==void 0&&(m.default=f.default),!m.type&&f.type&&(m.type=f.type)}return m},u=l=>{const{$ref:m,...h}=l;return h},d=(l,m)=>{let h=o(l);for(const f of m){if(!h)return null;if(/^\d+$/.test(f)){const E=Array.isArray(h.items)?h.items[Number(f)]:h.items;h=E?o(E):null;continue}const w=h.properties;if(w&&!r.has(f)&&f in w){h=o(w[f]);continue}const k=h.additionalProperties;if(k&&typeof k=="object"){h=o(k);continue}return null}return h},c=(l,m,h)=>{if(!l)return null;const f={};if(l.description&&(f.description=l.description),l.type&&(f.type=l.type),l.default!==void 0&&(f.default=l.default),l.enum&&(f.enum=l.enum),l.const!==void 0&&(f.const=l.const),l.deprecated&&(f.deprecated=!0),l.examples&&(f.examples=l.examples),l.properties&&(f.knownChildren=Object.keys(l.properties)),h&&(m!=null&&m.includes(h))&&(f.required=!0),l.items&&!Array.isArray(l.items)){const w=o(l.items),k=c(w,void 0,null);k&&(f.itemsInfo=k)}return(l.additionalProperties===!0||typeof l.additionalProperties=="object")&&(f.open=!0),f},x=l=>m=>{if(m.length===0)return c(o(l),void 0,null);const h=d(l,m.slice(0,-1));if(!h)return null;const f=m[m.length-1],w=d(h,[f]);return c(w,h.required,f)},y=l=>{const m=o(l);return Object.keys(m.properties??{})},g=l=>({at:x(l),rootKeys:()=>y(l),rootedAt:m=>{const h=d(l,m);return g(h??{})}});return g(n)}function Fe(t){return Array.from(new Set(t))}let H=null;function re(){return H||(H=Te(ne)),H}const Oe=["allow","deny","ask"],z="This settings file has invalid JSON. Fix it in the Settings raw editor first; Permissions will not overwrite it.";function Ae(t){if(t.trim()==="")return{perms:{},full:{},err:null};try{const n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{perms:{},full:{},err:"settings file is not a JSON object"};const s=n;return{perms:s.permissions??{},full:s,err:null}}catch(n){return{perms:{},full:{},err:n.message}}}function Me({scope:t="user"}={}){const n=U(),s=ee(),o=(s==null?void 0:s.cwd)??null,r=te(l=>l.navFace),[a,i]=b.useState("rules");b.useEffect(()=>{r==="project"&&a==="presets"&&i("rules")},[r,a]);const d=G(he,n,o)[t]??null,c=A(l=>l.files),x=e.jsx(K,{options:[{key:"rules",label:"Rules"},...r==="home"?[{key:"presets",label:"Presets"}]:[]],active:a,onChange:i});if(!n)return e.jsx(P,{title:"loading…"});if(a==="presets")return e.jsx(R,{toolbar:x,children:e.jsx(Se,{})});const y=l=>l!=="user"&&!o,g=d?c[d]:null;return e.jsx(R,{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:y(t)?e.jsx(P,{title:"no active project",hint:"open a tab in a project directory to edit project or local permissions"}):d&&g?e.jsx(ae,{scope:t,cwd:o,activePath:d}):e.jsx(P,{title:"resolving…"})})}b.memo(Me);function ae({scope:t,cwd:n,activePath:s}){const o=A(c=>c.files[s]),{perms:r,err:a}=o?Ae(o.draftRaw):{perms:{},err:null},i=(c,x)=>{if(a){D.error(z);return}window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:n,keyPath:["permissions",c],value:x}).catch(y=>D.error(y instanceof Error?y.message:String(y)))},u=(c,x)=>{const y=x.trim();if(!y)return;const g=r[c]??[];g.includes(y)||i(c,[...g,y])},d=(c,x)=>{const y=r[c]??[];i(c,y.filter((g,l)=>l!==x))};return e.jsxs("div",{className:"p-4 space-y-5 max-w-3xl",children:[a&&e.jsxs("div",{role:"alert",className:"text-xs text-red-400 border border-red-400/40 rounded px-3 py-2",children:[z," (",a,")"]}),e.jsx(Re,{value:r.defaultMode??"default",onChange:c=>i("defaultMode",c)}),Oe.map(c=>e.jsx($e,{list:c,rules:r[c]??[],disabled:!!a,onAdd:x=>u(c,x),onRemove:x=>d(c,x)},c)),e.jsx(Ie,{dirs:r.additionalDirectories??[],disabled:!!a,onChange:c=>i("additionalDirectories",c)})]})}function Re({value:t,onChange:n}){var a;const o=(((a=re().at(["permissions","defaultMode"]))==null?void 0:a.enum)??[]).filter(i=>typeof i=="string"),r=t&&!o.includes(t)?[...o,t]:o;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:r.map(i=>e.jsx("button",{onClick:()=>n(i),className:`px-2.5 py-1 text-xs transition-colors ${t===i?"bg-bg-hi text-fg":"bg-bg-elev text-fg-dim hover:text-fg hover:bg-bg-hi"}`,children:i},i))})]})}function $e({list:t,rules:n,onAdd:s,onRemove:o,disabled:r}){const[a,i]=b.useState(""),u=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 ${u}`,children:t}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("input",{value:a,disabled:r,onChange:d=>i(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(s(a),i(""))},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:()=>{s(a),i("")},disabled:r||!a.trim(),className:"px-2.5 py-1 border border-line rounded text-xs text-fg-dim hover:text-fg hover:bg-bg-hi disabled:opacity-40",children:"add"})]}),n.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no rules"}):e.jsx("ul",{className:"space-y-0.5",children:n.map((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:()=>o(c),className:"text-fg-faint hover:text-red-400",title:"remove",children:"×"})]},`${c}-${d}`))})]})}function Ie({dirs:t,onChange:n,disabled:s}){const[o,r]=b.useState("");return e.jsxs("section",{children:[e.jsx("h3",{className:"text-xs text-fg uppercase tracking-wider mb-2",children:"Additional Directories"}),e.jsx("div",{className:"flex gap-2 mb-2",children:e.jsx("input",{value:o,disabled:s,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&o.trim()&&(n([...t,o.trim()]),r(""))},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((a,i)=>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:a}),e.jsx("button",{onClick:()=>n(t.filter((u,d)=>d!==i)),className:"text-fg-faint hover:text-red-400",children:"×"})]},`${i}-${a}`))})]})}const De={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 }"}},oe=["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"],Le=new Set(oe),He=["command","http","prompt","agent","mcp_tool"],Ue={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:{}},Y="This settings file has invalid JSON. Fix it in the Settings raw editor first; Hooks will not overwrite it.";function Ge(t){if(t.trim()==="")return{full:{},hooks:{},err:null};try{const n=JSON.parse(t);if(n===null||typeof n!="object"||Array.isArray(n))return{full:{},hooks:{},err:"settings file is not a JSON object"};const s=n;return{full:s,hooks:s.hooks??{},err:null}}catch(n){return{full:{},hooks:{},err:n.message}}}function Ke(t,n){return(t[n]??[]).reduce((s,o)=>{var r;return s+(((r=o.hooks)==null?void 0:r.length)??0)},0)}function Be({scope:t="user"}={}){const n=U(),s=ee(),o=(s==null?void 0:s.cwd)??null,r=te(x=>x.navFace),[a,i]=b.useState("events");b.useEffect(()=>{r==="project"&&a==="library"&&i("events")},[r,a]);const d=G(se,n,o)[t]??null,c=e.jsx(K,{options:[{key:"events",label:"Events"},...r==="home"?[{key:"library",label:"Library"}]:[]],active:a,onChange:i});return n?a==="library"?e.jsx(R,{toolbar:c,children:e.jsx(Ce,{})}):t!=="user"&&!o?e.jsx(R,{toolbar:e.jsx(e.Fragment,{children:c}),children:e.jsx(P,{title:"no active project"})}):d?e.jsx(R,{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(ie,{scope:t,cwd:o,path:d})}):e.jsx(P,{title:"loading…"}):e.jsx(P,{title:"loading…"})}function ie({scope:t,cwd:n,path:s,renderLayout:o}){const[r,a]=b.useState("PreToolUse"),[i,u]=b.useState(null),d=(v,j)=>{window.api.claudeConfig.patch({fileId:"settings",scope:t,cwd:n,keyPath:v,value:j}).catch(p=>D.error(p instanceof Error?p.message:String(p)))},c=A(v=>v.files[s]),{hooks:x,err:y}=c?Ge(c.draftRaw):{hooks:{},err:null},g=Object.keys(x).filter(v=>!Le.has(v)),l=g.reduce((v,j)=>v+(x[j]??[]).reduce((p,T)=>{var M;return p+(((M=T.hooks)==null?void 0:M.length)??0)},0),0),m=(v,j)=>{if(y){D.error(Y);return}d(["hooks",v],j)},h=x[r]??[],f=()=>{m(r,[...h,{matcher:"",hooks:[{type:"command",command:""}]}])},w=(v,j)=>{const p=h.slice();p[v]=j,m(r,p)},k=v=>{m(r,h.filter((j,p)=>p!==v))},E=e.jsxs(e.Fragment,{children:[y?e.jsxs("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:[Y," (",y,")"]}):null,l>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:"⚠"})," ",l," hook(s) configured under unknown event names: ",e.jsx("span",{className:"font-mono text-fg",children:g.join(", ")}),e.jsx("span",{className:"text-fg-faint",children:" · these are ignored by Claude Code 2026; edit settings.json directly to remove."})]}):null]}),N=y||l>0?E:null,S=e.jsx("div",{className:"py-1",children:oe.map(v=>{const j=Ke(x,v),p=De[v],T=p?e.jsxs("span",{className:"block space-y-1",children:[e.jsx("span",{className:"block text-fg",children:p.when}),e.jsxs("span",{className:"block text-fg-faint font-mono",children:["payload: ",p.payload]}),p.example?e.jsxs("span",{className:"block text-fg-faint italic",children:["e.g. ",p.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(fe,{content:T,align:"bottom-center",children:e.jsxs("button",{onClick:()=>a(v),title:p==null?void 0:p.when,className:`w-full text-left px-3 py-1 text-xs ${r===v?"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:v}),j>0&&e.jsx("span",{className:"text-accent shrink-0 ml-2",children:j})]}),p?e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 font-normal truncate",children:p.when}):e.jsx("span",{className:"block text-[11px] leading-[1.3] text-fg-faint/80 italic font-normal truncate",children:"no documentation yet"})]})})},v)})}),C=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:f,disabled:!!y,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"})]}),h.length===0?e.jsx("div",{className:"text-fg-faint text-xs",children:"no hooks for this event"}):h.map((v,j)=>e.jsx(Je,{group:v,jsonInvalid:!!y,onChange:p=>w(j,p),onRemove:()=>k(j),onTestFire:p=>u({event:r,matcher:v.matcher??"",command:p.command??""})},j))]});return e.jsxs(e.Fragment,{children:[o?o({banners:N,list:S,detail:C}):e.jsxs("div",{className:"flex flex-col h-full",children:[N,e.jsx(Ee,{sidebarWidth:"14rem",sidebar:S,detail:C})]}),i?e.jsx(Ye,{event:i.event,matcher:i.matcher,command:i.command,onClose:()=>u(null)}):null]})}b.memo(Be);function I({value:t,onCommit:n,onDraft:s,...o}){const[r,a]=b.useState(t);b.useEffect(()=>a(t),[t]);const i=()=>{r!==t&&n(r)};return e.jsx("input",{...o,value:r,onChange:u=>{a(u.target.value),s==null||s(u.target.value)},onBlur:i,onKeyDown:u=>{u.key==="Enter"&&i()}})}function Je({group:t,jsonInvalid:n,onChange:s,onRemove:o,onTestFire:r}){const a=()=>s({...t,hooks:[...t.hooks??[],{type:"command",command:""}]}),i=(d,c)=>{const x=t.hooks.slice();x[d]=c,s({...t,hooks:x})},u=d=>s({...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(I,{value:t.matcher??"",disabled:n,onCommit:d=>s({...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:o,disabled:n,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(qe,{rule:d,jsonInvalid:n,onChange:x=>i(c,x),onRemove:()=>u(c),onTestFire:()=>r(d)},c)),e.jsx("button",{onClick:a,disabled:n,className:"text-xs text-fg-faint hover:text-fg disabled:opacity-40",children:"+ add hook"})]})}function We(t){var s,o,r;const n=((o=(s=ne.$defs)==null?void 0:s.hookCommand)==null?void 0:o.anyOf)??[];for(const a of n){const i=a.properties;if(((r=i==null?void 0:i.type)==null?void 0:r.const)!==t)continue;const u=i.timeout;if(typeof(u==null?void 0:u.default)=="number")return u.default;const d=/default:\s*(\d+)/.exec((u==null?void 0:u.description)??"");return d?Number(d[1]):null}return null}function Z(t){return/^\d+$/.test(t.trim())&&Number(t)>0?Number(t):null}function qe({rule:t,jsonInvalid:n,onChange:s,onRemove:o,onTestFire:r}){const a=l=>({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"})[l],i=t.type==="command"?"command":t.type==="http"?"url":t.type==="prompt"?"prompt":t.type==="mcp_tool"?"mcpTool":"agent",u=t[i]??"",d=(t.args??[]).join(" "),[c,x]=b.useState(null),y=We(t.type),g={type:"hook",name:u||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:n,onChange:l=>s({type:l.target.value}),className:"bg-bg border border-line rounded px-1 py-0.5 text-xs text-fg",children:He.map(l=>e.jsx("option",{value:l,children:l},l))}),e.jsx(Pe,{interactive:!1,input:g}),e.jsx(I,{value:u,disabled:n,onCommit:l=>s({...t,[i]:l}),placeholder:a(t.type),className:`flex-1 bg-bg border rounded px-2 py-0.5 text-xs text-fg font-mono ${n?"border-red-500/70":u.trim()?"border-line":"border-yellow-600/50"}`}),n?e.jsx("span",{className:"text-red-400 text-xs",title:"The enclosing settings.json is malformed; fix the JSON before editing.",children:"× invalid"}):null,e.jsx(I,{value:t.timeout!=null?String(t.timeout):"",disabled:n,"aria-label":"timeout (seconds)","aria-invalid":c?!0:void 0,title:c??"Timeout in seconds",onDraft:l=>{x(!l.trim()||Z(l)!=null?null:"Timeout must be a positive whole number of seconds")},onCommit:l=>{if(!l.trim()){s({...t,timeout:void 0});return}const m=Z(l);m!=null&&s({...t,timeout:m})},placeholder:y!=null?`${y} (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:r,disabled:n||!u.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:o,disabled:n,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(I,{value:d,disabled:n,onCommit:l=>s({...t,args:l.trim()?l.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(I,{value:t.terminalSequence??"",disabled:n,onCommit:l=>s({...t,terminalSequence:l||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 Ve(t){return JSON.stringify(Ue[t]??{},null,2)}function ze(t,n){if(!t.trim())return{matched:!0,target:null,note:"empty matcher → matches all"};const s=n&&typeof n=="object"&&"tool_name"in n?String(n.tool_name??""):null;if(s==null)return{matched:!1,target:null,note:"payload has no tool_name to match against"};try{return{matched:new RegExp(`^(?:${t})$`).test(s),target:s}}catch{return{matched:t===s,target:s,note:"matcher not valid regex; fell back to exact match"}}}function Ye({event:t,matcher:n,command:s,onClose:o}){const[r,a]=b.useState(()=>Ve(t)),[i,u]=b.useState(!1),[d,c]=b.useState(null),[x,y]=b.useState(null);let g=null;try{JSON.parse(r)}catch(m){g=m.message}const l=async()=>{u(!0),c(null);let m=null;try{m=JSON.parse(r)}catch{}y(ze(n,m));try{const h=await window.api.app.testFireHook({command:s,payload:r,timeoutMs:5e3});c(h)}finally{u(!1)}};return e.jsx(ge,{open:!0,onClose:o,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:s})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-fg-faint mb-1",children:"matcher"}),e.jsx("div",{className:"font-mono text-fg bg-bg border border-line rounded px-2 py-1",children:n||e.jsx("span",{className:"text-fg-faint",children:"(empty — matches all)"})})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-fg-faint",children:"fake event payload (stdin)"}),g?e.jsxs("span",{className:"text-red-400",children:["× ",g]}):null]}),e.jsx("textarea",{value:r,onChange:m=>a(m.target.value),rows:8,className:`w-full bg-bg border rounded px-2 py-1 font-mono text-fg ${g?"border-red-500/70":"border-line"}`})]}),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:o,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:l,disabled:i||!!g||!s.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:i?"running…":"run"})]})]})})}const le=[{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(le.flatMap(t=>t.keys)),Ze=[{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"]}],Qe={mcp:"MCP",url:"URL",urls:"URLs",http:"HTTP",ui:"UI",id:"ID",uuid:"UUID",api:"API",aws:"AWS",otel:"OTel",json:"JSON"};function ce(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((o,r)=>{const a=Qe[o];return a||(r===0?o.charAt(0).toUpperCase()+o.slice(1):o)}).join(" ")}function de(t){const n=new Set,s=[];for(const r of Ze){const a=r.keys.filter(i=>t.has(i)&&!Q.has(i));a.forEach(i=>n.add(i)),a.length!==0&&s.push({id:r.id,title:r.title,summary:r.summary,advanced:!!r.advanced,keys:a})}const o=Array.from(t).filter(r=>!n.has(r)&&r!=="$schema"&&!Q.has(r)).sort();return o.length>0&&s.push({id:"other",title:"Other",summary:"Keys not yet grouped.",advanced:!1,keys:o}),s}function Xe(t,n){return de(t).map(s=>({id:s.id,title:s.title,advanced:s.advanced,total:s.keys.length,setCount:s.keys.filter(o=>n.has(o)).length}))}const et={};function ue(t,n){if(n)return{text:n,authored:!1};const s=et[t];return s?{text:s,authored:!0}:null}const me=b.createContext(null);function tt(){const t=b.useContext(me);if(!t)throw new Error("usePageShell() must be used inside a <PageShell>.");return t}function O({header:t,subnav:n,footer:s,children:o,subnavWidth:r=220}){const a=b.useRef(null),i=b.useCallback((d,c)=>{const x=a.current;if(!x)return;let y=null;for(const g of Array.from(x.querySelectorAll("[id]")))if(g.id===d){y=g;break}y&&be(x,y,{block:"start",behavior:c==null?void 0:c.behavior})},[]),u=b.useMemo(()=>({scrollToAnchor:i,contentRef:a}),[i]);return e.jsx(me.Provider,{value:u,children:e.jsxs("div",{"data-testid":"page-shell",className:"h-full w-full min-h-0 min-w-0 flex flex-col overflow-clip",children:[t!=null&&e.jsx("div",{"data-testid":"page-shell-header",className:"shrink-0 min-w-0 overflow-clip",children:t}),e.jsxs("div",{"data-testid":"page-shell-body",className:"flex-1 min-h-0 min-w-0 flex flex-row overflow-clip",children:[n!=null&&e.jsx("nav",{"data-testid":"page-shell-subnav",className:"shrink-0 min-h-0 overflow-y-auto overscroll-contain",style:{width:r},children:n}),e.jsx("div",{ref:a,"data-testid":"page-shell-content",className:"flex-1 min-w-0 min-h-0 overflow-y-auto overscroll-contain",children:o})]}),s!=null&&e.jsx("div",{"data-testid":"page-shell-footer",className:"shrink-0 min-w-0 overflow-clip",children:s})]})})}const st={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"},nt=["user","project","local","default"],rt={user:"user",project:"project",local:"local",default:"default"};function at({node:t,schema:n}){const[s,o]=b.useState(""),[r,a]=b.useState(!1),[i,u]=b.useState(!0),d=t.kind==="object"?t:null,c=d?Object.keys(d.children):[],x=n.rootKeys(),y=new Set([...c,...x]),g=Array.from(y).sort().join(","),l=c.join(","),m=b.useMemo(()=>de(y),[g]),h=b.useMemo(()=>Xe(y,new Set(c)),[g,l]),f=b.useMemo(()=>m.filter(w=>r||!w.advanced).map(w=>({...w,keys:w.keys.filter(k=>{const E=(d==null?void 0:d.children[k])!==void 0;if(!i&&!E)return!1;if(!s.trim())return!0;const N=n.at([k]);return[k,ce(k),(N==null?void 0:N.description)??""].join(" ").toLowerCase().includes(s.toLowerCase())})})).filter(w=>w.keys.length>0),[m,s,r,i,d,n]);return{filter:s,setFilter:o,showAdvanced:r,setShowAdvanced:a,showUnset:i,setShowUnset:u,rootNode:d,schema:n,groups:m,railGroups:h,visibleGroups:f}}function ot({cards:t,targetScope:n}){return e.jsxs("div",{className:"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:_[n].label})]}),e.jsxs("label",{className:"flex items-center gap-1 text-fg-faint cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.showUnset,onChange:s=>t.setShowUnset(s.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:t.showAdvanced,onChange:s=>t.setShowAdvanced(s.target.checked),className:"accent-accent"}),"show advanced"]}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:t.filter,onChange:s=>t.setFilter(s.target.value),placeholder:"search settings…",className:"bg-bg border border-line rounded px-2 py-1 text-xs text-fg w-64"})]})}function it({cards:t,targetScope:n,onOverride:s}){const{visibleGroups:o,rootNode:r,schema:a,filter:i}=t;return e.jsxs("div",{className:"py-3",children:[o.map(u=>e.jsx(dt,{id:u.id,title:u.title,summary:u.summary,advanced:u.advanced,children:u.keys.map(d=>{const c=r==null?void 0:r.children[d],x=a.at([d]);return e.jsx(ut,{keyName:d,node:c,info:x,targetScope:n,onOverride:(y,g)=>s([d],y,g)},d)})},u.id)),o.length===0&&e.jsxs("div",{className:"px-6 py-12 text-center text-fg-faint text-sm",children:['no settings match "',i,'"']})]})}function lt({cards:t}){const n=tt(),[s,o]=b.useState(null),{groups:r,showAdvanced:a,setShowAdvanced:i}=t,u=d=>{const c=r.find(x=>x.id===d);c!=null&&c.advanced&&!a&&i(!0),o(d)};return b.useEffect(()=>{s&&(o(null),n.scrollToAnchor(`settings-group-${s}`,{behavior:"smooth"}))},[s,n]),e.jsx(ct,{groups:t.railGroups,onJump:u})}function ct({groups:t,onJump:n}){return e.jsx("div",{className:"min-h-full border-r border-line bg-bg-elev/30 py-3",children:t.map(s=>e.jsxs("button",{type:"button","data-group-id":s.id,onClick:()=>n(s.id),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-bg-hi transition-colors",title:`jump to ${s.title}`,children:[e.jsx(ye,{name:st[s.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:s.title}),e.jsxs("span",{className:"text-[10px] text-fg-faint font-mono shrink-0",children:[s.setCount,"/",s.total]})]},s.id))})}function dt({id:t,title:n,summary:s,advanced:o,children:r}){const[a,i]=b.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:()=>i(!a),children:[e.jsx("span",{className:"text-fg-faint w-3",children:a?"▾":"▸"}),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:n}),o&&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:s})]})]}),a&&e.jsx("div",{className:"divide-y divide-line/60",children:r})]})}function ut({keyName:t,node:n,info:s,targetScope:o,onOverride:r}){const[a,i]=b.useState(!1),[u,d]=b.useState(!1),c=ce(t),x=n!==void 0,g=(n==null?void 0:n.kind)==="leaf"?n:null,l=(n==null?void 0:n.kind)==="object"||(n==null?void 0:n.kind)==="array",m=s==null?void 0:s.default,h=g&&m!==void 0&&xe(g.value,m),f=yt({isSet:x,leafNode:g,defaultVal:m,isDefault:!!h,node:n}),w=mt(g,m),k=w.length>=2,E=!!g&&!h,N=ue(t,s==null?void 0:s.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:()=>i(!a),className:"text-fg-faint hover:text-fg w-3 mt-0.5",title:a?"collapse":"expand",children:a?"▾":"▸"}),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(vt,{kind:f.kind,label:f.label}),k&&e.jsxs("button",{onClick:S=>{S.stopPropagation(),a||i(!0),d(C=>!C)},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 · ",w.map(S=>rt[S]).join(" · ")]}),E&&g&&e.jsx("button",{onClick:S=>{S.stopPropagation(),r(void 0,g.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 ${_[g.winner].label}`,children:"↺ reset"}),(s==null?void 0:s.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"}),(s==null?void 0:s.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"})]}),N&&e.jsx("p",{className:`text-fg-dim text-xs mt-0.5 leading-relaxed ${N.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:N.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:jt(N.text)}),a&&u&&g&&e.jsx(pt,{leaf:g,defaultVal:m,onReset:S=>r(void 0,S)}),a&&e.jsx(xt,{keyName:t,node:n,info:s,targetScope:o,onOverride:S=>r(S)})]}),e.jsx("div",{className:"shrink-0",children:!a&&e.jsx(bt,{node:n,info:s,onSet:S=>{r(S)},disabled:l&&x})})]})})}function mt(t,n){if(!t)return[];const s=new Set;s.add(t.winner);for(const o of t.shadowed)s.add(o.scope);return n!==void 0&&s.add("default"),nt.filter(o=>s.has(o))}function pt({leaf:t,defaultVal:n,onReset:s}){const o={};o[t.winner]={value:t.value,winner:!0};for(const r of t.shadowed)o[r.scope]={value:r.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(r=>{const a=o[r],i=a!==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:_[r].label}),e.jsx("span",{className:`font-mono truncate ${a!=null&&a.winner?"text-accent":"text-fg-dim"}`,children:i?$(a.value):e.jsx("span",{className:"text-fg-faint",children:"—"})}),i?e.jsx("button",{onClick:()=>s(r),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 ${_[r].label}`,children:"↺"}):e.jsx("span",{})]},r)}),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:n!==void 0?$(n):e.jsx("span",{className:"text-fg-faint",children:"—"})}),e.jsx("span",{})]})]})]})}function xt({keyName:t,node:n,info:s,targetScope:o,onOverride:r}){const i=(n==null?void 0:n.kind)==="leaf"?n:null,u=ue(t,s==null?void 0:s.description);return e.jsxs("div",{className:"mt-3 space-y-2 text-xs",children:[u&&e.jsx("p",{className:`text-fg-dim leading-relaxed whitespace-pre-wrap ${u.authored?"inline-block border-b border-dotted border-fg-faint/70 cursor-help":""}`,title:u.authored?"In-app-authored description — not from the official Claude Code schema":void 0,children:u.text}),e.jsxs("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-fg-faint",children:[(s==null?void 0:s.type)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:Array.isArray(s.type)?s.type.join(" | "):s.type})]}),(s==null?void 0:s.default)!==void 0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Default"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:$(s.default)})]}),(s==null?void 0:s.enum)&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Options"}),e.jsx("dd",{className:"text-fg-dim font-mono",children:s.enum.map(d=>String(d)).join(" | ")})]}),i&&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:$(i.value)}),e.jsxs("span",{className:"ml-2 text-fg-faint",children:["from ",_[i.winner].label]})]})]}),i&&i.shadowed.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Shadowed"}),e.jsx("dd",{className:"space-y-0.5",children:i.shadowed.map((d,c)=>e.jsxs("div",{className:"font-mono text-fg-faint line-through",children:[$(d.value)," —"," ",e.jsx("span",{className:"no-underline",children:_[d.scope].label})]},c))})]}),(n==null?void 0:n.kind)==="array"&&e.jsxs(e.Fragment,{children:[e.jsx("dt",{children:"Accumulated"}),e.jsxs("dd",{className:"text-fg-dim",children:[n.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(ht,{keyName:t,node:n,info:s,onChange:r,targetScope:o})})]})}function ht({node:t,info:n,onChange:s,targetScope:o}){const a=(t==null?void 0:t.kind)==="leaf"?t.value:n==null?void 0:n.default,i=pe(n==null?void 0:n.type);if(i==="boolean"){const u=a===!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:()=>s(d),className:`px-3 py-0.5 text-xs transition-colors ${u===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:["→ ",_[o].label]})]})}return n!=null&&n.enum?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-fg-faint",children:"Choose:"}),n.enum.map(u=>{const d=xe(a,u);return e.jsx("button",{onClick:()=>s(u),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(u)},String(u))}),e.jsxs("span",{className:"text-fg-faint",children:["→ ",_[o].label]})]}):i==="integer"||i==="number"?e.jsx(ft,{value:typeof a=="number"?a:void 0,integer:i==="integer",onCommit:s,target:_[o].label}):i==="string"?e.jsx(gt,{value:typeof a=="string"?a:"",onCommit:s,target:_[o].label}):e.jsxs("div",{className:"text-fg-faint",children:["Complex value (",i??"object/array",") — use the"," ",e.jsx("span",{className:"text-fg-dim",children:"Raw"})," tab to edit."]})}function ft({value:t,integer:n,onCommit:s,target:o}){const[r,a]=b.useState(t!==void 0?String(t):""),i=()=>{const u=n?parseInt(r,10):parseFloat(r);Number.isNaN(u)||s(u)};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:r,onChange:u=>a(u.target.value),onBlur:i,onKeyDown:u=>{u.key==="Enter"&&u.target.blur()},className:"w-24 bg-bg border border-line rounded px-2 py-0.5 text-xs text-fg"}),e.jsxs("button",{onClick:i,className:"px-2 py-0.5 text-xs border border-accent/50 rounded text-accent hover:bg-accent hover:text-bg",children:["save → ",o]})]})}function gt({value:t,onCommit:n,target:s}){const[o,r]=b.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:o,onChange:a=>r(a.target.value),onKeyDown:a=>{a.key==="Enter"&&n(o)},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:()=>n(o),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 → ",s]})]})}function bt({node:t,info:n,onSet:s,disabled:o}){const r=(t==null?void 0:t.kind)==="leaf",a=pe(n==null?void 0:n.type);if(o)return null;if(a==="boolean"){const i=r&&t.value===!0;return e.jsx("button",{onClick:()=>s(!i),className:`px-2.5 py-0.5 text-xs rounded border transition-colors ${i?"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:i?"on":"off"})}return null}function yt({isSet:t,leafNode:n,defaultVal:s,isDefault:o,node:r}){return t?(r==null?void 0:r.kind)==="array"?{kind:"accumulated",label:`${r.items.length} items`}:(r==null?void 0:r.kind)==="object"?{kind:"set",label:"configured"}:n?o?{kind:"default",label:`= default · ${_[n.winner].label}`}:n.shadowed.length>0?{kind:"override",label:`overriding ${n.shadowed.length} scope(s)`}:{kind:"set",label:`set in ${_[n.winner].label}`}:{kind:"set",label:"configured"}:s!==void 0?{kind:"default",label:`using default: ${$(s)}`}:{kind:"unset",label:"not configured"}}function vt({kind:t,label:n}){const s={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 ${s}`,children:n})}function pe(t){if(t)return Array.isArray(t)?t.find(s=>s!=="null")??t[0]:t}function xe(t,n){return t===n?!0:typeof t!=typeof n?!1:t&&n&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(n):!1}function jt(t){const n=t.trim().split(`
|
|
2
|
+
`)[0],s=n.match(/^([^.!?]+[.!?])/);return s?s[1]:n.length>120?n.slice(0,120)+"…":n}function $(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 n=JSON.stringify(t);return n.length>60?n.slice(0,60)+"…":n}return String(t)}const X={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 wt({effective:t,onOpenTab:n}){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:le.map(s=>{const o=s.keys.filter(a=>Ne(t,[a])!==null),r=o.length?`${o.length} of ${s.keys.length} keys set (${o.join(", ")})`:"nothing set";return e.jsxs("li",{"data-testid":`owned-summary-${s.id}`,className:"flex items-center gap-2 text-fg-dim",children:[e.jsx("span",{className:"font-semibold text-fg w-28 shrink-0",children:s.label}),e.jsx("span",{className:"truncate",children:r}),s.tab?e.jsxs("button",{type:"button",onClick:()=>n(s.tab),className:"ml-auto text-accent hover:underline shrink-0",children:["edit in ",s.label," tab →"]}):e.jsxs("span",{className:"ml-auto text-fg-faint shrink-0",children:["managed on the ",s.label," page"]})]},s.id)})})}function kt({scope:t="user"}={}){const n=U(),s=q(p=>p.tabs),o=q(p=>p.activeTabId),r=s.find(p=>p.id===o)??null,a=(r==null?void 0:r.cwd)??null,[i,u]=b.useState("general");ve("settings",p=>{(p==="general"||p==="permissions"||p==="hooks"||p==="raw")&&u(p)});const d=G(se,n,a),c=d[t]??null,x=A(p=>p.files),y=A(p=>p.setDraft),g=A(p=>p.saveJson),l=A(p=>p.revert),[m,h]=b.useState(null),f=b.useMemo(()=>je(we(x,d)),[x,d]),w=re(),k=at({node:f,schema:w}),E=(p,T,M)=>{var W;const B=M??t,L=d[B];if(!L)return;const J=((W=x[L])==null?void 0:W.draftRaw)??"";if(J.trim())try{JSON.parse(J)}catch(F){h(`${L} is not valid JSON (${F instanceof Error?F.message:String(F)}) — fix it in Raw before editing from General.`);return}h(null),window.api.claudeConfig.patch({fileId:"settings",scope:B,cwd:a,keyPath:p,value:T}).catch(F=>D.error(F instanceof Error?F.message:String(F)))};if(!n)return e.jsx(P,{title:"loading…"});const N=c?x[c]:null,S=p=>p!=="user"&&!a,C=e.jsxs("div",{"data-testid":"settings-scope-note",className:"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:X[t].title}),e.jsx("span",{className:"mx-1.5 text-fg-faint",children:"·"}),e.jsx("span",{className:"text-fg-dim",children:X[t].body}),c&&e.jsx("span",{className:"ml-1.5 font-mono text-fg-faint",children:c})]}),v=p=>e.jsx("div",{className:"px-3 py-2",children:e.jsx(V,{path:c??"",keyPath:p})}),j=m&&i!=="raw"?e.jsx("div",{role:"alert",className:"px-3 py-2 border-b border-line text-xs text-red-400",children:m}):null;return e.jsx(R,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(K,{options:[{key:"general",label:"General"},{key:"permissions",label:"Permissions"},{key:"hooks",label:"Hooks"},{key:"raw",label:"Raw"}],active:i,onChange:u}),e.jsx(e.Fragment,{children:e.jsx("span",{className:"ml-3 text-fg-faint truncate",children:i==="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 ↗"})]}),children:i==="general"&&!S(t)?e.jsxs(O,{subnavWidth:192,header:e.jsxs(e.Fragment,{children:[C,j,e.jsx(ot,{cards:k,targetScope:t})]}),subnav:e.jsx(lt,{cards:k}),children:[e.jsx("div",{className:"px-3 pt-2",children:e.jsx(V,{path:c??""})}),e.jsx(wt,{effective:f,onOpenTab:u}),e.jsx(it,{cards:k,targetScope:t,onOverride:E})]}):S(t)?e.jsx(O,{header:e.jsxs(e.Fragment,{children:[C,j]}),children:e.jsx(P,{title:"no active project",hint:"open a tab in a project directory to edit project or local settings"})}):c?i==="permissions"?e.jsx(O,{header:e.jsxs(e.Fragment,{children:[C,j,v(["permissions"])]}),children:e.jsx(ae,{scope:t,cwd:a,activePath:c})}):i==="hooks"?e.jsx(ie,{scope:t,cwd:a,path:c,renderLayout:({banners:p,list:T,detail:M})=>e.jsx(O,{subnavWidth:224,header:e.jsxs(e.Fragment,{children:[C,j,v(["hooks"]),p]}),subnav:e.jsx("div",{className:"min-h-full border-r border-line",children:T}),children:M})}):N?e.jsx(O,{header:e.jsxs(e.Fragment,{children:[C,v()]}),footer:e.jsx("div",{className:"border-t border-line bg-bg-elev",children:e.jsx(_e,{dirty:N.dirty,busy:N.busy,parseError:m||N.parseError,lastSavedAt:N.lastSavedAt,leading:N.exists?null:e.jsx("span",{children:"file will be created on save"}),onSave:async()=>{h(null);const p=await g(c);p.ok||h(p.error??"save failed")},onRevert:()=>{h(null),l(c)}})}),children:e.jsx("div",{"data-testid":"settings-raw-editor",className:"h-full overflow-clip",children:e.jsx(ke,{path:c,value:N.draftRaw,onChange:p=>{h(null),y(c,p)}})})}):e.jsx(O,{header:e.jsxs(e.Fragment,{children:[C,j]}),children:e.jsx(P,{title:"resolving…"})}):e.jsx(O,{header:e.jsxs(e.Fragment,{children:[C,j]}),children:e.jsx(P,{title:"resolving…"})})})}const Mt=b.memo(kt);export{X as SETTINGS_SCOPE_NOTES,Mt as Settings};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{aO as Z,R as wo,au as ko,ay as tr}from"./index-rt7pTODX.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.
|