import{n as q,a as b,b as y,o as p,u as j,j as e,k as u,B as f,l as m,L as B,I as F}from"./index-O0BQoyzo.js";import{r as x}from"./react-Cb2sDjhD.js";import{u as L}from"./useQuery-PdiC7-sY.js";import{L as N}from"./loader-circle-9VUMGitw.js";import{R as M}from"./refresh-ccw-D2CWiyU_.js";import{T as P}from"./trash-2-Dfov8aHD.js";import{S as T}from"./save-DB0BDYTs.js";/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const z=q("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/**
 * @license lucide-react v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const E=q("FilePlus2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),k={all:["agim-skills"],list:["agim-skills","list"],one:s=>["agim-skills","one",s]};function K(){return L({queryKey:k.list,queryFn:()=>p.get("/api/agim-skills")})}function Q(s){return L({queryKey:s?k.one(s):["agim-skills","one","__none__"],queryFn:()=>p.get(`/api/agim-skills/${encodeURIComponent(s)}`),enabled:!!s})}function _(){const s=b();return y({mutationFn:t=>p.post("/api/agim-skills",{body:t}),onSuccess:()=>s.invalidateQueries({queryKey:k.all})})}function D(){const s=b();return y({mutationFn:({name:t,body:o})=>p.put(`/api/agim-skills/${encodeURIComponent(t)}`,{body:{body:o}}),onSuccess:()=>s.invalidateQueries({queryKey:k.all})})}function I(){const s=b();return y({mutationFn:t=>p.delete(`/api/agim-skills/${encodeURIComponent(t)}`),onSuccess:()=>s.invalidateQueries({queryKey:k.all})})}function O(){const s=b();return y({mutationFn:()=>p.post("/api/agim-skills/refresh"),onSuccess:()=>s.invalidateQueries({queryKey:k.all})})}const $=`---
name: my-skill
description: One-line summary the LLM uses to decide whether to load this skill.
always: false
---

# My Skill

Write the body the agent should read when this skill applies.

## When to use this skill

- bullet 1
- bullet 2

## Steps

1. step one
2. step two
`;function se(){const{t:s}=j(["settings","common"]),t=K(),o=O(),[a,i]=x.useState(null);x.useEffect(()=>{!a&&t.data?.skills.length&&i(t.data.skills[0]?.name??null)},[a,t.data]);const l=t.data?.skills??[],d=t.data?.maxBodyChars??32e3;async function c(){try{const n=await o.mutateAsync();m.success(s("agimSkills.reloadedToast",{count:n.count}))}catch(n){m.error(n?.message??String(n))}}return e.jsxs("div",{className:"mx-auto flex max-w-6xl flex-col gap-4",children:[e.jsxs("header",{className:"flex items-center gap-3",children:[e.jsx(z,{className:"h-5 w-5 text-text-dim"}),e.jsx("h1",{className:"text-xl font-semibold",children:s("agimSkills.title")}),e.jsx(u,{variant:"info",children:l.length}),e.jsxs(f,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>void c(),disabled:o.isPending,children:[o.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(M,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:s("agimSkills.reload")})]}),e.jsx(H,{onCreate:n=>i(n)})]}),e.jsx("p",{className:"text-sm text-text-dim",children:s("agimSkills.subtitle")}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[280px,1fr]",children:[e.jsx(U,{skills:l,selected:a,onSelect:i,loading:t.isLoading}),a?e.jsx(W,{name:a,maxBody:d,onDeleted:()=>i(null)},a):e.jsx("section",{className:"flex items-center justify-center rounded-md border border-border bg-surface p-12 text-sm text-text-dim",children:s("agimSkills.selectHint")})]})]})}function U({skills:s,selected:t,onSelect:o,loading:a}){const{t:i}=j(["settings","common"]);return a?e.jsx("div",{className:"h-48 rounded-md bg-surface-2 animate-pulse"}):s.length===0?e.jsx("section",{className:"rounded-md border border-border bg-surface p-4 text-sm text-text-dim",children:i("agimSkills.emptyList")}):e.jsx("nav",{className:"rounded-md border border-border bg-surface",children:e.jsx("ul",{className:"divide-y divide-border",children:s.map(l=>{const d=t===l.name,c=l.available?l.always?e.jsx(u,{variant:"success",children:i("agimSkills.alwaysOn")}):null:e.jsx(u,{variant:"outline",title:l.unavailableReason,children:i("agimSkills.unavailable")}),n=l.source==="workspace"?e.jsx(u,{variant:"info",children:i("agimSkills.sourceWs")}):e.jsx(u,{variant:"outline",children:i("agimSkills.sourceBuiltin")});return e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>o(l.name),className:"flex w-full flex-col items-start gap-1 px-3 py-2 text-left text-xs transition hover:bg-surface-2 "+(d?"bg-surface-2 font-semibold":""),children:[e.jsxs("span",{className:"flex w-full items-center gap-2 font-mono text-[12px]",children:[e.jsx("span",{className:"grow truncate",children:l.name}),n,c]}),e.jsx("span",{className:"line-clamp-2 text-[11px] text-text-dim",children:l.description})]})},l.name)})})})}function W({name:s,maxBody:t,onDeleted:o}){const{t:a}=j(["settings","common"]),i=Q(s),l=D(),d=I(),[c,n]=x.useState(""),[g,v]=x.useState("");x.useEffect(()=>{i.data&&g!==s&&(n(i.data.body),v(s))},[i.data,s,g]);const r=i.data?.meta,S=r?.source==="builtin",w=i.data?.body??"",C=x.useMemo(()=>c!==w,[c,w]);async function A(){try{await l.mutateAsync({name:s,body:c}),m.success(a("agimSkills.savedToast",{name:s}))}catch(h){m.error(h?.message??String(h))}}async function R(){if(!S&&confirm(a("agimSkills.deleteConfirm",{name:s})))try{await d.mutateAsync(s),m.success(a("agimSkills.deletedToast",{name:s})),o()}catch(h){m.error(h?.message??String(h))}}return i.isLoading?e.jsx("section",{className:"h-72 rounded-md bg-surface-2 animate-pulse"}):r?e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("header",{className:"flex flex-wrap items-center gap-2 rounded-md border border-border bg-surface px-3 py-2",children:[e.jsx("span",{className:"font-mono text-sm font-semibold",children:r.name}),r.source==="workspace"?e.jsx(u,{variant:"info",children:a("agimSkills.sourceWorkspace")}):e.jsx(u,{variant:"outline",children:a("agimSkills.sourceBuiltinReadonly")}),r.always&&e.jsx(u,{variant:"success",children:a("agimSkills.alwaysOn")}),!r.available&&e.jsx(u,{variant:"outline",title:r.unavailableReason,children:a("agimSkills.unavailable")}),e.jsxs("span",{className:"ml-auto text-[11px] text-text-dim",children:[c.length," / ",t]})]}),e.jsx("textarea",{value:c,onChange:h=>n(h.target.value),disabled:S&&!C,spellCheck:!1,className:"min-h-[500px] w-full rounded-md border border-border bg-surface p-3 font-mono text-xs leading-relaxed focus:border-accent focus:outline-none"}),e.jsxs("div",{className:"text-[11px] text-text-dim",children:[a("agimSkills.pathLabel")," ",e.jsx("code",{children:r.dir})," ·",a("agimSkills.binsLabel")," ",e.jsx("code",{children:r.requiresBins.join(", ")||a("agimSkills.none")})," ·",a("agimSkills.envLabel")," ",e.jsx("code",{children:r.requiresEnv.join(", ")||a("agimSkills.none")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[S&&e.jsx("span",{className:"text-[11px] text-text-dim",children:a("agimSkills.builtinShadowHint")}),e.jsx("span",{className:"ml-auto"}),!S&&e.jsxs(f,{variant:"ghost",size:"sm",onClick:()=>void R(),disabled:d.isPending,className:"text-danger hover:text-danger",children:[e.jsx(P,{className:"h-4 w-4"}),a("agimSkills.delete")]}),e.jsxs(f,{size:"sm",onClick:()=>void A(),disabled:l.isPending||!C,children:[l.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):e.jsx(T,{className:"h-4 w-4"}),a(S?"agimSkills.saveShadow":"agimSkills.save")]})]})]}):e.jsx("section",{className:"rounded-md border border-border bg-surface p-4 text-sm text-danger",children:a("agimSkills.notFound")})}function H({onCreate:s}){const{t}=j(["settings","common"]),o=_(),[a,i]=x.useState(!1),[l,d]=x.useState("");async function c(n){n.preventDefault();const g=l.trim();if(!g){m.error(t("agimSkills.nameRequired"));return}if(!/^[A-Za-z0-9._-]+$/.test(g)){m.error("safe chars only: [A-Za-z0-9._-]");return}const v=$.replace("name: my-skill",`name: ${g}`);try{const r=await o.mutateAsync({name:g,body:v});m.success(t("agimSkills.createdToast",{name:r.meta.name})),i(!1),d(""),s(r.meta.name)}catch(r){m.error(r?.message??String(r))}}return a?e.jsxs("form",{onSubmit:n=>void c(n),className:"flex items-center gap-1",children:[e.jsx(B,{className:"sr-only",children:t("agimSkills.newName")}),e.jsx(F,{autoFocus:!0,value:l,onChange:n=>d(n.target.value),placeholder:t("agimSkills.newNamePlaceholder"),className:"h-8 w-44 font-mono text-xs"}),e.jsx(f,{type:"submit",size:"sm",disabled:o.isPending,children:o.isPending?e.jsx(N,{className:"h-4 w-4 animate-spin"}):t("agimSkills.newCreate")}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",onClick:()=>{i(!1),d("")},children:t("actions.cancel",{ns:"common"})})]}):e.jsxs(f,{size:"sm",onClick:()=>i(!0),children:[e.jsx(E,{className:"h-4 w-4"})," ",t("agimSkills.new")]})}export{se as default};
//# sourceMappingURL=installed-Co9WrtQ7.js.map
