@engenty/wizards-runtime 0.16.2 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/apps/runtime/dist/agents/studio-assistant.js +13 -6
  2. package/apps/runtime/dist/assistant/knows.js +15 -2
  3. package/apps/runtime/dist/broker/call.js +16 -3
  4. package/apps/runtime/dist/broker/grant.js +25 -1
  5. package/apps/runtime/dist/broker/index.js +2 -2
  6. package/apps/runtime/dist/broker/log.js +30 -11
  7. package/apps/runtime/dist/broker/rwx.js +14 -2
  8. package/apps/runtime/dist/broker/send.js +84 -32
  9. package/apps/runtime/dist/connectors/space-connections.js +47 -2
  10. package/apps/runtime/dist/docs/dev/broker.md +72 -26
  11. package/apps/runtime/dist/docs/dev/plugins/space.md +13 -2
  12. package/apps/runtime/dist/docs/user-guide/capabilities.md +51 -7
  13. package/apps/runtime/dist/docs/user-guide/connectors.md +6 -3
  14. package/apps/runtime/dist/docs/user-guide/protocol.md +30 -4
  15. package/apps/runtime/dist/docs/user-guide/together.md +4 -4
  16. package/apps/runtime/dist/elements/knowledge.js +16 -12
  17. package/apps/runtime/dist/engine/steps.js +3 -2
  18. package/apps/runtime/dist/index.js +8 -0
  19. package/apps/runtime/dist/live/hub.js +17 -3
  20. package/apps/runtime/dist/live/origin.js +6 -4
  21. package/apps/runtime/dist/live/views.js +38 -7
  22. package/apps/runtime/dist/models.js +18 -0
  23. package/apps/runtime/dist/prompts/tools.md +1 -1
  24. package/apps/runtime/dist/routes/api.js +2 -2
  25. package/apps/runtime/dist/routes/broker.js +59 -20
  26. package/apps/runtime/dist/routes/live.js +4 -2
  27. package/apps/runtime/dist/routes/studio.js +13 -2
  28. package/apps/runtime/dist/services/api.js +4 -2
  29. package/apps/runtime/dist/services/errors.js +1 -0
  30. package/apps/runtime/dist/services/knowledge.js +93 -27
  31. package/apps/runtime/dist/services/members-studio.js +22 -2
  32. package/apps/runtime/dist/services/space-categories.js +83 -5
  33. package/apps/runtime/dist/services/space-index.js +77 -21
  34. package/apps/runtime/dist/services/space-origin.js +28 -11
  35. package/apps/runtime/dist/services/work-ai.js +15 -5
  36. package/apps/runtime/dist/sharing/jobs.js +2 -0
  37. package/apps/runtime/dist/sync/hub.js +17 -3
  38. package/apps/runtime/dist/texts.js +6 -4
  39. package/apps/runtime/dist/tools/index.js +13 -7
  40. package/apps/runtime/dist/tools/web-search.js +36 -0
  41. package/apps/web/dist/assets/{AboutDialog-BCcD8hKm.js → AboutDialog-B2Xmxyj4.js} +1 -1
  42. package/apps/web/dist/assets/{BlockEditor-DgaUm2pR.js → BlockEditor-D0HoUSih.js} +1 -1
  43. package/apps/web/dist/assets/CapabilitiesPage-C1th2cZE.js +2 -0
  44. package/apps/web/dist/assets/{ChangelogDialog-B08elwyr.js → ChangelogDialog-BIrJbAKi.js} +1 -1
  45. package/apps/web/dist/assets/{CodeEditor-BiyOk_SC.js → CodeEditor-DUVcXI5P.js} +1 -1
  46. package/apps/web/dist/assets/{EditorPage-EMFTHEYD.js → EditorPage-56sIqEfF.js} +1 -1
  47. package/apps/web/dist/assets/{FlowPreview-DF_6TvZ0.js → FlowPreview-BIag8_Be.js} +1 -1
  48. package/apps/web/dist/assets/{LangSwitch-Ba4OWLzJ.js → LangSwitch-CJ00IgaO.js} +1 -1
  49. package/apps/web/dist/assets/{Marketplace-DqziLf66.js → Marketplace-D7-ot9Dz.js} +2 -2
  50. package/apps/web/dist/assets/{NewWizardChannels-CsIGp0nZ.js → NewWizardChannels-DI3SQ4iS.js} +1 -1
  51. package/apps/web/dist/assets/{NewWizardPage-CzQAkKMy.js → NewWizardPage-CytheHxX.js} +1 -1
  52. package/apps/web/dist/assets/{OnboardingPage-B9gr2OX5.js → OnboardingPage-_91Pa8Ad.js} +1 -1
  53. package/apps/web/dist/assets/{PreviewPane-DSOV3o-1.js → PreviewPane-BDsYm-_K.js} +2 -2
  54. package/apps/web/dist/assets/ProtocolSection-D_zaxHEL.js +1 -0
  55. package/apps/web/dist/assets/{PublicRunner-BVs8-Vu3.js → PublicRunner-CEgXSk3r.js} +1 -1
  56. package/apps/web/dist/assets/{ReadOnly--4CIJCDD.js → ReadOnly-CWf5x74a.js} +1 -1
  57. package/apps/web/dist/assets/SettingsPage-Dr8SDk-L.js +2 -0
  58. package/apps/web/dist/assets/{SetupPage-9Zk-KUGA.js → SetupPage-B68n0l4I.js} +1 -1
  59. package/apps/web/dist/assets/{SharePage-D_Ab0gjr.js → SharePage-DfznN7ar.js} +1 -1
  60. package/apps/web/dist/assets/{SkillEditor-DvtameHg.js → SkillEditor-BIcIczRc.js} +1 -1
  61. package/apps/web/dist/assets/{Skills-Cf1Kl4Fy.js → Skills-CN4QE7Kx.js} +1 -1
  62. package/apps/web/dist/assets/{SpacePage-CyqVzX9b.js → SpacePage-DiVTwhnJ.js} +2 -2
  63. package/apps/web/dist/assets/{UpdateCheck-DweZBVP6.js → UpdateCheck-QhBI3rlQ.js} +2 -2
  64. package/apps/web/dist/assets/changelog-a_CuplMX.js +1 -0
  65. package/apps/web/dist/assets/{code-editor-B1RbFTAZ.js → code-editor-DkPo1C-L.js} +2 -2
  66. package/apps/web/dist/assets/{host-CKS5U5Vg.js → host-D6H6Z9Jp.js} +6 -6
  67. package/apps/web/dist/assets/i18n-BaPKbQ1s.js +55 -0
  68. package/apps/web/dist/assets/{index-w-3J3ZJ9.css → index-CCUG6Vnh.css} +1 -1
  69. package/apps/web/dist/assets/{index-Ckcn5vy7.js → index-De0Wb42y.js} +3 -3
  70. package/apps/web/dist/assets/{read-aloud-Bq88XUHC.js → read-aloud-CnFwDSGD.js} +1 -1
  71. package/apps/web/dist/assets/{runners-DvYVe9Dt.js → runners-0sTPbWzr.js} +1 -1
  72. package/apps/web/dist/assets/{session-D2bjiA3P.js → session-BMiUrqHg.js} +1 -1
  73. package/apps/web/dist/assets/{theme-CNJIC2be.js → theme-CkNTe-_Z.js} +1 -1
  74. package/apps/web/dist/assets/{ui-Mplfhz_Z.js → ui-DAk_vjrL.js} +1 -1
  75. package/apps/web/dist/assets/{useMutation-8QRM-z4M.js → useMutation-isHfB33W.js} +1 -1
  76. package/apps/web/dist/assets/{viewers-CEocUV_2.js → viewers-ijNZHJFG.js} +2 -2
  77. package/apps/web/dist/index.html +12 -12
  78. package/apps/web/dist/mcp/flow.html +2 -2
  79. package/node_modules/@engenty/wizards/dist/plugin/index.d.ts +7 -2
  80. package/node_modules/@engenty/wizards-shared/dist/connectors.d.ts +13 -1
  81. package/node_modules/@engenty/wizards-shared/dist/connectors.js +8 -0
  82. package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +12 -0
  83. package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +12 -0
  84. package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
  85. package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
  86. package/node_modules/@engenty/wizards-shared/dist/spaces.d.ts +3 -2
  87. package/node_modules/@engenty/wizards-shared/dist/spaces.js +12 -3
  88. package/package.json +1 -1
  89. package/plugin/.claude-plugin/plugin.json +1 -1
  90. package/plugin/plugin.json +1 -1
  91. package/apps/web/dist/assets/CapabilitiesPage-DuJJV1ll.js +0 -2
  92. package/apps/web/dist/assets/SettingsPage-z2u8lSe2.js +0 -2
  93. package/apps/web/dist/assets/changelog-C85v9OWg.js +0 -1
  94. package/apps/web/dist/assets/connection-sign-in-CaVvh5GQ.js +0 -1
  95. package/apps/web/dist/assets/i18n-Bymk5Ev-.js +0 -55
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dn as i,Dt as a,Gn as o,K as s,Q as c,Vr as l,X as u,an as d,en as f,fn as p,gr as m,hn as h,i as ee,in as g,nn as _,on as v,pt as te,un as y,v as b}from"./ui-Mplfhz_Z.js";import{t as x}from"./useMutation-8QRM-z4M.js";import{d as S,i as C,l as ne,r as w,s as T}from"./marked.esm-DQ7XA7AC.js";import{c as E,d as D,i as O,l as re,n as k,o as ie,t as A,u as ae}from"./Skills-Cf1Kl4Fy.js";import{t as j}from"./code-xml-S4IFi5Jc.js";import{n as M,t as oe}from"./scroll-text-BEnPzQEi.js";import{t as N}from"./eye-TJSuiHHO.js";import{n as P,s as F}from"./i18n-Bymk5Ev-.js";import{t as I}from"./code-editor-B1RbFTAZ.js";import{N as L,a as R,r as z,t as B}from"./dist-CQpLJoQZ.js";var V={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};V.node;var se=S(V),H=e(t(),1),U=B.line({class:`cm-frontmatter`});function W(e){let t=new L,n=e.state.doc;if(n.lines>1&&n.line(1).text.trim()===`---`){for(let e=2;e<=Math.min(n.lines,80);e++)if(n.line(e).text.trim()===`---`){for(let r=1;r<=e;r++)t.add(n.line(r).from,n.line(r).from,U);break}}return t.finish()}function G(){return[R.fromClass(class{decorations;constructor(e){this.decorations=W(e)}update(e){e.docChanged&&(this.decorations=W(e.view))}},{decorations:e=>e.decorations}),z.theme({".cm-frontmatter, .cm-frontmatter *":{fontFamily:`var(--f-mono)`,fontSize:`0.8125rem !important`,fontWeight:`400 !important`,color:`var(--ink-3) !important`,textDecoration:`none !important`}})]}var K=e(n(),1),q=[`always`,`demand`,`off`],ce=G();function J(e){return m({queryKey:u.skill(e),queryFn:()=>c.get(`/api/studio/skills/${e}`)})}function le({value:e,onChange:t,disabled:n}){return(0,K.jsx)(`fieldset`,{"aria-label":F(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 flex flex-col gap-2`,children:q.map(r=>{let i=r===e,a=k[r];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:h(`flex items-start gap-3 rounded-xl bg-card p-3 text-left ring-1 transition disabled:pointer-events-none`,i?`ring-ember shadow-[0_0_0_3px] shadow-ember-tint`:`ring-border-soft hover:ring-ink-4`,n&&!i&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:h(`flex size-8 shrink-0 items-center justify-center rounded-lg`,i?`bg-ember-tint text-ember-strong`:`bg-paper-2 text-ink-3`),children:(0,K.jsx)(a,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:F(`skills.mode.${r}`)}),(0,K.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.modeHint.${r}`)})]})]},r)})})}function ue({skill:e}){let t=l(),n=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{runScripts:t}),onSuccess:async()=>{await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),r=e.source!==`own`&&!e.official;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.scriptsTitle`)}),(0,K.jsxs)(f,{className:`flex flex-col gap-2 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 font-medium text-[0.8125rem]`,children:F(`skills.runScripts`)}),(0,K.jsx)(p,{checked:e.runScripts,label:F(`skills.runScripts`),disabled:e.readOnly||n.isPending,onChange:e=>n.mutate(e)})]}),(0,K.jsx)(`p`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.runScriptsHint`)}),r?(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.75rem] text-ink-2 leading-snug`,children:F(`skills.runScriptsWarn`)}):null,n.error?(0,K.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:n.error.message}):null]})]})}function Y({code:e,onChange:t}){return(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,"aria-pressed":e,onClick:()=>t(!e),children:[e?(0,K.jsx)(N,{className:`size-4`}):(0,K.jsx)(j,{className:`size-4`}),F(e?`skills.rendered`:`skills.code`)]})}var X=e=>`${(e/1e3).toLocaleString(P,{maximumFractionDigits:1})} KB`,Z=e=>X(new TextEncoder().encode(e).length),Q=e=>/\.(md|markdown|mdx)$/i.test(e);function $({file:e,readOnly:t,onChange:n,onDelete:i,onClose:o}){let[s,c]=(0,H.useState)(!1),l=e?Q(e.path):!1,u=s||!l;return(0,K.jsx)(_,{open:e!==null,onClose:o,wide:!0,height:`tall`,title:e?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.path})]}):null,children:e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:Z(e.text)}),l?(0,K.jsx)(Y,{code:s,onChange:c}):null]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:u?(0,K.jsx)(I,{value:e.text,onChange:n,readOnly:t,language:`markdown`,ariaLabel:e.path,className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh]`}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)(a,{text:e.text})})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?null:(0,K.jsxs)(r,{variant:`danger`,size:`sm`,onClick:i,children:[(0,K.jsx)(w,{className:`size-4`}),` `,F(`skills.deleteFile`)]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(r,{size:`sm`,onClick:o,children:F(`skills.done`)})]})]}):null})}function de({open:e,taken:t,onClose:n,onMade:i}){let[a,o]=(0,H.useState)(``),s=a.trim().replace(/^\.?\//,``),c=D(s)&&s!==`SKILL.md`&&!t.includes(s);return(0,K.jsx)(_,{open:e,onClose:n,title:F(`skills.newFile`),children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c&&(i(s),o(``))},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{children:F(`skills.filePath`)}),(0,K.jsx)(d,{"data-autofocus":!0,value:a,placeholder:F(`skills.filePathHint`),onChange:e=>o(e.target.value),className:`font-mono`})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(r,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,K.jsx)(r,{type:`submit`,disabled:!c,children:F(`skills.create`)})]})]})})}function fe({items:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]),(0,K.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,K.jsx)(g,{label:F(`skills.more`),"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`ring-1 ring-border`,children:(0,K.jsx)(M,{className:`size-4`})}),t?(0,K.jsx)(`div`,{role:`menu`,className:`absolute top-11 right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{n(!1),e.onPick()},className:h(`w-full rounded-lg px-2.5 py-2 text-left text-[0.8125rem] transition hover:bg-accent`,e.danger&&`text-rose`),children:e.label},e.label))}):null]})}function pe({skill:e}){let t=l(),[n,o]=(0,H.useState)(!1),s=m({queryKey:[`skill-update`,e.id,e.originHash],queryFn:()=>c.get(`/api/studio/skills/${e.id}/update`),staleTime:6e5,retry:!1}),d=x({mutationFn:t=>c.post(`/api/studio/skills/${e.id}/update`,{hash:t}),onSuccess:async()=>{o(!1),await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),p=s.data?.update;return!p||e.readOnly?null:(0,K.jsxs)(f,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-ember`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-[0.8125rem]`,children:F(`skills.updateAvailable`)}),(0,K.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:F(`skills.showChanges`)}),(0,K.jsx)(_,{open:n,onClose:()=>o(!1),wide:!0,height:`tall`,title:F(`skills.updateTitle`,{name:e.name}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:p.description}),(0,K.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,K.jsx)(a,{text:p.body})}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[0.8125rem]`,children:p.fileList.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e.path},e.path))}),(0,K.jsx)(A,{files:p.fileList,skipped:p.skipped}),d.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(r,{busy:d.isPending,onClick:()=>d.mutate(p.hash),children:F(`skills.takeUpdate`)})})]})})]})}function me({skillId:e,onGone:t,onOpen:n,filesFirst:r}){let i=J(e);return i.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:i.error.message}):i.data?(0,K.jsx)(he,{skill:i.data,onGone:t,onOpen:n,filesFirst:r},i.data.id):(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(y,{className:`size-5`})})}function he({skill:e,onGone:t,onOpen:n,filesFirst:i}){let d=l(),p=e.source===`skills.sh`,m=e.readOnly||p,[h,g]=(0,H.useState)({name:e.name,description:e.description,body:e.body,meta:e.meta,files:e.fileList}),[_,v]=(0,H.useState)(!1),[S,w]=(0,H.useState)(null),[D,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(!1),L=s(h,async t=>{m||(await c.patch(`/api/studio/skills/${e.id}`,t),await d.invalidateQueries({queryKey:u.skills(e.spaceId)}))}),R=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{mode:t}),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skill(e.id)}),await d.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),z=x({mutationFn:()=>c.del(`/api/studio/skills/${e.id}`),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),t()}}),B=x({mutationFn:()=>c.post(`/api/studio/skills/${e.id}/copy`),onSuccess:async({id:t})=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),n(`k:${t}`)}}),V=h.files.find(e=>e.path===A)??null,U=S??ae(h),W=e=>g(t=>({...t,...e})),G=async()=>{await ee(F(p?`skills.removeConfirm`:`skills.deleteConfirm`,{name:e.name}))&&z.mutate()},q=L.error??R.error?.message??null,J=typeof e.meta.license==`string`?e.meta.license:null,Q=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.filesTitle`),children:m?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>N(!0),children:[(0,K.jsx)(C,{className:`size-4`}),` `,F(`skills.addFile`)]})}),h.files.length||e.blobList.length?(0,K.jsxs)(f,{className:`flex flex-col divide-y divide-border-soft overflow-hidden`,children:[h.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>j(e.path),className:`flex items-center gap-2.5 px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:Z(e.text)})]},e.path)),e.blobList.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2.5`,children:[(0,K.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:[F(`skills.forScripts`),` · `,X(e.bytes)]})]},e.path))]}):(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.noFiles`)}),(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.filesHint`)}),e.blobList.length?(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.blobHint`)}):null]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 pb-20`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-start gap-4`,children:[(0,K.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,K.jsx)(oe,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[m?(0,K.jsx)(`h1`,{className:`font-medium font-mono text-2xl`,children:h.name}):(0,K.jsx)(b,{fit:!0,value:h.name,label:F(`skills.name`),placeholder:F(`skills.namePlaceholder`),maxLength:E.name,onChange:e=>{w(null),W({name:e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)})},className:`font-medium font-mono text-2xl`}),(0,K.jsx)(ie,{skill:e}),L.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(y,{className:`size-3`}),` `,F(`space.saving`)]}):L.state===`saved`?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`settings.saved`)}):null]}),m?(0,K.jsx)(`p`,{className:`mt-1 max-w-3xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:h.description}):(0,K.jsx)(`textarea`,{value:h.description,"aria-label":F(`skills.description`),placeholder:F(`skills.descPlaceholder`),maxLength:E.description,rows:2,onChange:e=>{w(null),W({description:e.target.value})},className:`-mx-1 mt-1 block w-full max-w-3xl resize-none rounded-md bg-transparent px-1 py-0.5 text-[0.9375rem] text-ink-2 leading-relaxed outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`}),(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.75rem] text-ink-3`,children:F(`skills.descHint`)})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-1`,children:[(0,K.jsxs)(`a`,{href:te(`/api/studio/skills/${e.id}/zip`),download:!0,className:`inline-flex h-8 items-center gap-2 rounded-full bg-card px-3 font-medium text-[0.8125rem] ring-1 ring-border transition hover:bg-accent`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,F(`skills.download`)]}),e.readOnly?null:(0,K.jsx)(fe,{items:[...p?[]:[{label:F(`skills.copy`),onPick:()=>B.mutate()}],{label:F(p?`skills.remove`:`skills.delete`),danger:!0,onPick:G}]})]})]}),p?(0,K.jsx)(pe,{skill:e}):null,q?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:q}):null,(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,K.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(O,{title:F(`skills.instructions`),children:[(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`skills.chars`,{n:h.body.length.toLocaleString(P)})}),(0,K.jsx)(Y,{code:_,onChange:v})]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:_?(0,K.jsx)(I,{value:U,readOnly:m,onChange:e=>{w(e);try{let t=re(e);k(!1),W({...t,files:h.files})}catch{k(!0)}},language:`markdown`,ariaLabel:`SKILL.md`,extensions:ce,className:`min-h-[55vh] [&_.cm-editor]:min-h-[55vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,K.jsx)(`div`,{className:`min-h-40 p-5 sm:px-8 sm:py-6`,children:h.body.trim()?(0,K.jsx)(a,{text:h.body}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`skills.emptyBody`)})})}),_&&D?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:F(`skills.mdError`)}):null,p?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.readOnlyNote`)}):null]}),(0,K.jsxs)(`aside`,{className:`flex flex-col gap-6`,children:[i?Q:null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.when`)}),(0,K.jsx)(le,{value:e.mode,onChange:e=>R.mutate(e),disabled:e.readOnly||R.isPending})]}),(0,K.jsx)(ue,{skill:e}),p?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.origin`)}),(0,K.jsx)(f,{className:`p-4`,children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] gap-y-2 text-[0.8125rem]`,children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.source`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`a`,{href:`https://skills.sh/${e.origin}`,target:`_blank`,rel:`noreferrer`,className:`break-all underline hover:text-ink`,children:e.origin})}),J?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.license`)}),(0,K.jsx)(`dd`,{className:`break-words`,children:J})]}):null,e.originHash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.version`)}),(0,K.jsx)(`dd`,{className:`font-mono text-[0.75rem]`,children:e.originHash.slice(0,12)})]}):null]})}),e.readOnly?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,className:`self-start`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,F(`skills.copy`)]})]}):null,i?null:Q]})]}),(0,K.jsx)($,{file:V,readOnly:m,onClose:()=>j(null),onChange:e=>W({files:h.files.map(t=>t.path===A?{...t,text:e}:t)}),onDelete:()=>{W({files:h.files.filter(e=>e.path!==A)}),j(null)}}),(0,K.jsx)(de,{open:M,taken:h.files.map(e=>e.path),onClose:()=>N(!1),onMade:e=>{W({files:[...h.files,{path:e,text:``}].sort((e,t)=>e.path.localeCompare(t.path))}),N(!1),j(e)}})]})}export{me as SkillEditor};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dn as i,Dt as a,Gn as o,K as s,Q as c,Vr as l,X as u,an as d,en as f,fn as p,gr as m,hn as h,i as ee,in as g,nn as _,on as v,pt as te,un as y,v as b}from"./ui-DAk_vjrL.js";import{t as x}from"./useMutation-isHfB33W.js";import{d as S,i as C,l as ne,r as w,s as T}from"./marked.esm-DQ7XA7AC.js";import{c as E,d as D,i as O,l as re,n as k,o as ie,t as A,u as ae}from"./Skills-CN4QE7Kx.js";import{t as j}from"./code-xml-S4IFi5Jc.js";import{n as M,t as oe}from"./scroll-text-BEnPzQEi.js";import{t as N}from"./eye-TJSuiHHO.js";import{n as P,s as F}from"./i18n-BaPKbQ1s.js";import{t as I}from"./code-editor-DkPo1C-L.js";import{N as L,a as R,r as z,t as B}from"./dist-CQpLJoQZ.js";var V={name:`file-archive`,size:24,node:[[`path`,{d:`M13.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v11.5`,key:`4pqfef`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M8 12v-1`,key:`1ej8lb`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`path`,{d:`M8 7V6`,key:`1nbb54`}],[`circle`,{cx:`8`,cy:`20`,r:`2`,key:`ckkr5m`}]]};V.node;var se=S(V),H=e(t(),1),U=B.line({class:`cm-frontmatter`});function W(e){let t=new L,n=e.state.doc;if(n.lines>1&&n.line(1).text.trim()===`---`){for(let e=2;e<=Math.min(n.lines,80);e++)if(n.line(e).text.trim()===`---`){for(let r=1;r<=e;r++)t.add(n.line(r).from,n.line(r).from,U);break}}return t.finish()}function G(){return[R.fromClass(class{decorations;constructor(e){this.decorations=W(e)}update(e){e.docChanged&&(this.decorations=W(e.view))}},{decorations:e=>e.decorations}),z.theme({".cm-frontmatter, .cm-frontmatter *":{fontFamily:`var(--f-mono)`,fontSize:`0.8125rem !important`,fontWeight:`400 !important`,color:`var(--ink-3) !important`,textDecoration:`none !important`}})]}var K=e(n(),1),q=[`always`,`demand`,`off`],ce=G();function J(e){return m({queryKey:u.skill(e),queryFn:()=>c.get(`/api/studio/skills/${e}`)})}function le({value:e,onChange:t,disabled:n}){return(0,K.jsx)(`fieldset`,{"aria-label":F(`skills.modeLabel`),className:`m-0 min-w-0 border-0 p-0 flex flex-col gap-2`,children:q.map(r=>{let i=r===e,a=k[r];return(0,K.jsxs)(`button`,{type:`button`,"aria-pressed":i,disabled:n,onClick:()=>!i&&t(r),className:h(`flex items-start gap-3 rounded-xl bg-card p-3 text-left ring-1 transition disabled:pointer-events-none`,i?`ring-ember shadow-[0_0_0_3px] shadow-ember-tint`:`ring-border-soft hover:ring-ink-4`,n&&!i&&`opacity-60`),children:[(0,K.jsx)(`span`,{className:h(`flex size-8 shrink-0 items-center justify-center rounded-lg`,i?`bg-ember-tint text-ember-strong`:`bg-paper-2 text-ink-3`),children:(0,K.jsx)(a,{className:`size-4`})}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`block font-medium text-[0.8125rem]`,children:F(`skills.mode.${r}`)}),(0,K.jsx)(`span`,{className:`block text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.modeHint.${r}`)})]})]},r)})})}function ue({skill:e}){let t=l(),n=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{runScripts:t}),onSuccess:async()=>{await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),r=e.source!==`own`&&!e.official;return(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.scriptsTitle`)}),(0,K.jsxs)(f,{className:`flex flex-col gap-2 p-4`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 font-medium text-[0.8125rem]`,children:F(`skills.runScripts`)}),(0,K.jsx)(p,{checked:e.runScripts,label:F(`skills.runScripts`),disabled:e.readOnly||n.isPending,onChange:e=>n.mutate(e)})]}),(0,K.jsx)(`p`,{className:`text-[0.75rem] text-ink-3 leading-snug`,children:F(`skills.runScriptsHint`)}),r?(0,K.jsx)(`p`,{className:`rounded-lg bg-amber-tint px-3 py-2 text-[0.75rem] text-ink-2 leading-snug`,children:F(`skills.runScriptsWarn`)}):null,n.error?(0,K.jsx)(`p`,{className:`text-[0.75rem] text-rose`,children:n.error.message}):null]})]})}function Y({code:e,onChange:t}){return(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,"aria-pressed":e,onClick:()=>t(!e),children:[e?(0,K.jsx)(N,{className:`size-4`}):(0,K.jsx)(j,{className:`size-4`}),F(e?`skills.rendered`:`skills.code`)]})}var X=e=>`${(e/1e3).toLocaleString(P,{maximumFractionDigits:1})} KB`,Z=e=>X(new TextEncoder().encode(e).length),Q=e=>/\.(md|markdown|mdx)$/i.test(e);function $({file:e,readOnly:t,onChange:n,onDelete:i,onClose:o}){let[s,c]=(0,H.useState)(!1),l=e?Q(e.path):!1,u=s||!l;return(0,K.jsx)(_,{open:e!==null,onClose:o,wide:!0,height:`tall`,title:e?(0,K.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`truncate font-mono text-[0.9375rem]`,children:e.path})]}):null,children:e?(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-[0.75rem] text-ink-3`,children:Z(e.text)}),l?(0,K.jsx)(Y,{code:s,onChange:c}):null]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:u?(0,K.jsx)(I,{value:e.text,onChange:n,readOnly:t,language:`markdown`,ariaLabel:e.path,className:`min-h-[50vh] [&_.cm-editor]:min-h-[50vh]`}):(0,K.jsx)(`div`,{className:`p-5`,children:(0,K.jsx)(a,{text:e.text})})}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t?null:(0,K.jsxs)(r,{variant:`danger`,size:`sm`,onClick:i,children:[(0,K.jsx)(w,{className:`size-4`}),` `,F(`skills.deleteFile`)]}),(0,K.jsx)(`span`,{className:`flex-1`}),(0,K.jsx)(r,{size:`sm`,onClick:o,children:F(`skills.done`)})]})]}):null})}function de({open:e,taken:t,onClose:n,onMade:i}){let[a,o]=(0,H.useState)(``),s=a.trim().replace(/^\.?\//,``),c=D(s)&&s!==`SKILL.md`&&!t.includes(s);return(0,K.jsx)(_,{open:e,onClose:n,title:F(`skills.newFile`),children:(0,K.jsxs)(`form`,{className:`flex flex-col gap-4`,onSubmit:e=>{e.preventDefault(),c&&(i(s),o(``))},children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(v,{children:F(`skills.filePath`)}),(0,K.jsx)(d,{"data-autofocus":!0,value:a,placeholder:F(`skills.filePathHint`),onChange:e=>o(e.target.value),className:`font-mono`})]}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,K.jsx)(r,{variant:`ghost`,onClick:n,children:F(`common.cancel`)}),(0,K.jsx)(r,{type:`submit`,disabled:!c,children:F(`skills.create`)})]})]})})}function fe({items:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useRef)(null);return(0,H.useEffect)(()=>{if(!t)return;let e=e=>{r.current?.contains(e.target)||n(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[t]),(0,K.jsxs)(`div`,{className:`relative`,ref:r,children:[(0,K.jsx)(g,{label:F(`skills.more`),"aria-haspopup":`menu`,"aria-expanded":t,onClick:()=>n(e=>!e),className:`ring-1 ring-border`,children:(0,K.jsx)(M,{className:`size-4`})}),t?(0,K.jsx)(`div`,{role:`menu`,className:`absolute top-11 right-0 z-50 w-56 animate-rise rounded-xl bg-card p-1.5 shadow-overlay ring-1 ring-border-soft`,children:e.map(e=>(0,K.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{n(!1),e.onPick()},className:h(`w-full rounded-lg px-2.5 py-2 text-left text-[0.8125rem] transition hover:bg-accent`,e.danger&&`text-rose`),children:e.label},e.label))}):null]})}function pe({skill:e}){let t=l(),[n,o]=(0,H.useState)(!1),s=m({queryKey:[`skill-update`,e.id,e.originHash],queryFn:()=>c.get(`/api/studio/skills/${e.id}/update`),staleTime:6e5,retry:!1}),d=x({mutationFn:t=>c.post(`/api/studio/skills/${e.id}/update`,{hash:t}),onSuccess:async()=>{o(!1),await t.invalidateQueries({queryKey:u.skill(e.id)}),await t.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),p=s.data?.update;return!p||e.readOnly?null:(0,K.jsxs)(f,{className:`flex flex-wrap items-center gap-3 px-4 py-3`,children:[(0,K.jsx)(i,{className:`size-4 shrink-0 text-ember`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 text-[0.8125rem]`,children:F(`skills.updateAvailable`)}),(0,K.jsx)(r,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:F(`skills.showChanges`)}),(0,K.jsx)(_,{open:n,onClose:()=>o(!1),wide:!0,height:`tall`,title:F(`skills.updateTitle`,{name:e.name}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-2`,children:p.description}),(0,K.jsx)(`div`,{className:`rounded-lg bg-paper-2 p-4`,children:(0,K.jsx)(a,{text:p.body})}),(0,K.jsx)(`ul`,{className:`flex flex-col gap-0.5 text-[0.8125rem]`,children:p.fileList.map(e=>(0,K.jsx)(`li`,{className:`font-mono`,children:e.path},e.path))}),(0,K.jsx)(A,{files:p.fileList,skipped:p.skipped}),d.error?(0,K.jsx)(`p`,{className:`text-[0.875rem] text-rose`,children:d.error.message}):null,(0,K.jsx)(`div`,{className:`flex justify-end`,children:(0,K.jsx)(r,{busy:d.isPending,onClick:()=>d.mutate(p.hash),children:F(`skills.takeUpdate`)})})]})})]})}function me({skillId:e,onGone:t,onOpen:n,filesFirst:r}){let i=J(e);return i.error?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:i.error.message}):i.data?(0,K.jsx)(he,{skill:i.data,onGone:t,onOpen:n,filesFirst:r},i.data.id):(0,K.jsx)(`div`,{className:`flex justify-center py-16`,children:(0,K.jsx)(y,{className:`size-5`})})}function he({skill:e,onGone:t,onOpen:n,filesFirst:i}){let d=l(),p=e.source===`skills.sh`,m=e.readOnly||p,[h,g]=(0,H.useState)({name:e.name,description:e.description,body:e.body,meta:e.meta,files:e.fileList}),[_,v]=(0,H.useState)(!1),[S,w]=(0,H.useState)(null),[D,k]=(0,H.useState)(!1),[A,j]=(0,H.useState)(null),[M,N]=(0,H.useState)(!1),L=s(h,async t=>{m||(await c.patch(`/api/studio/skills/${e.id}`,t),await d.invalidateQueries({queryKey:u.skills(e.spaceId)}))}),R=x({mutationFn:t=>c.patch(`/api/studio/skills/${e.id}`,{mode:t}),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skill(e.id)}),await d.invalidateQueries({queryKey:u.skills(e.spaceId)})}}),z=x({mutationFn:()=>c.del(`/api/studio/skills/${e.id}`),onSuccess:async()=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),t()}}),B=x({mutationFn:()=>c.post(`/api/studio/skills/${e.id}/copy`),onSuccess:async({id:t})=>{await d.invalidateQueries({queryKey:u.skills(e.spaceId)}),n(`k:${t}`)}}),V=h.files.find(e=>e.path===A)??null,U=S??ae(h),W=e=>g(t=>({...t,...e})),G=async()=>{await ee(F(p?`skills.removeConfirm`:`skills.deleteConfirm`,{name:e.name}))&&z.mutate()},q=L.error??R.error?.message??null,J=typeof e.meta.license==`string`?e.meta.license:null,Q=(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.filesTitle`),children:m?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,onClick:()=>N(!0),children:[(0,K.jsx)(C,{className:`size-4`}),` `,F(`skills.addFile`)]})}),h.files.length||e.blobList.length?(0,K.jsxs)(f,{className:`flex flex-col divide-y divide-border-soft overflow-hidden`,children:[h.files.map(e=>(0,K.jsxs)(`button`,{type:`button`,onClick:()=>j(e.path),className:`flex items-center gap-2.5 px-3 py-2.5 text-left transition hover:bg-accent`,children:[(0,K.jsx)(T,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:Z(e.text)})]},e.path)),e.blobList.map(e=>(0,K.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3 py-2.5`,children:[(0,K.jsx)(se,{className:`size-4 shrink-0 text-ink-3`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[0.8125rem]`,children:e.path}),(0,K.jsxs)(`span`,{className:`shrink-0 text-[0.75rem] text-ink-3`,children:[F(`skills.forScripts`),` · `,X(e.bytes)]})]},e.path))]}):(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.noFiles`)}),(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.filesHint`)}),e.blobList.length?(0,K.jsx)(`p`,{className:`px-1 text-[0.75rem] text-ink-3`,children:F(`skills.blobHint`)}):null]});return(0,K.jsxs)(`div`,{className:`flex flex-col gap-5 pb-20`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-start gap-4`,children:[(0,K.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-xl bg-ember-tint text-ember-strong`,children:(0,K.jsx)(oe,{className:`size-6`})}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[m?(0,K.jsx)(`h1`,{className:`font-medium font-mono text-2xl`,children:h.name}):(0,K.jsx)(b,{fit:!0,value:h.name,label:F(`skills.name`),placeholder:F(`skills.namePlaceholder`),maxLength:E.name,onChange:e=>{w(null),W({name:e.toLowerCase().replace(/[^a-z0-9-]/g,`-`)})},className:`font-medium font-mono text-2xl`}),(0,K.jsx)(ie,{skill:e}),L.state===`saving`?(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[0.75rem] text-ink-3`,children:[(0,K.jsx)(y,{className:`size-3`}),` `,F(`space.saving`)]}):L.state===`saved`?(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`settings.saved`)}):null]}),m?(0,K.jsx)(`p`,{className:`mt-1 max-w-3xl text-[0.9375rem] text-ink-2 leading-relaxed`,children:h.description}):(0,K.jsx)(`textarea`,{value:h.description,"aria-label":F(`skills.description`),placeholder:F(`skills.descPlaceholder`),maxLength:E.description,rows:2,onChange:e=>{w(null),W({description:e.target.value})},className:`-mx-1 mt-1 block w-full max-w-3xl resize-none rounded-md bg-transparent px-1 py-0.5 text-[0.9375rem] text-ink-2 leading-relaxed outline-none transition placeholder:text-ink-4 hover:bg-paper-2 focus:bg-card focus:text-ink focus:ring-1 focus:ring-border`}),(0,K.jsx)(`p`,{className:`mt-0.5 text-[0.75rem] text-ink-3`,children:F(`skills.descHint`)})]}),(0,K.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-1`,children:[(0,K.jsxs)(`a`,{href:te(`/api/studio/skills/${e.id}/zip`),download:!0,className:`inline-flex h-8 items-center gap-2 rounded-full bg-card px-3 font-medium text-[0.8125rem] ring-1 ring-border transition hover:bg-accent`,children:[(0,K.jsx)(o,{className:`size-4`}),` `,F(`skills.download`)]}),e.readOnly?null:(0,K.jsx)(fe,{items:[...p?[]:[{label:F(`skills.copy`),onPick:()=>B.mutate()}],{label:F(p?`skills.remove`:`skills.delete`),danger:!0,onPick:G}]})]})]}),p?(0,K.jsx)(pe,{skill:e}):null,q?(0,K.jsx)(`p`,{className:`px-1 text-[0.875rem] text-rose`,children:q}):null,(0,K.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,K.jsxs)(`section`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,K.jsxs)(O,{title:F(`skills.instructions`),children:[(0,K.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:F(`skills.chars`,{n:h.body.length.toLocaleString(P)})}),(0,K.jsx)(Y,{code:_,onChange:v})]}),(0,K.jsx)(f,{className:`overflow-hidden`,children:_?(0,K.jsx)(I,{value:U,readOnly:m,onChange:e=>{w(e);try{let t=re(e);k(!1),W({...t,files:h.files})}catch{k(!0)}},language:`markdown`,ariaLabel:`SKILL.md`,extensions:ce,className:`min-h-[55vh] [&_.cm-editor]:min-h-[55vh] sm:[&_.cm-content]:py-5 sm:[&_.cm-line]:px-5`}):(0,K.jsx)(`div`,{className:`min-h-40 p-5 sm:px-8 sm:py-6`,children:h.body.trim()?(0,K.jsx)(a,{text:h.body}):(0,K.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:F(`skills.emptyBody`)})})}),_&&D?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-rose`,children:F(`skills.mdError`)}):null,p?(0,K.jsx)(`p`,{className:`px-1 text-[0.8125rem] text-ink-3`,children:F(`skills.readOnlyNote`)}):null]}),(0,K.jsxs)(`aside`,{className:`flex flex-col gap-6`,children:[i?Q:null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.when`)}),(0,K.jsx)(le,{value:e.mode,onChange:e=>R.mutate(e),disabled:e.readOnly||R.isPending})]}),(0,K.jsx)(ue,{skill:e}),p?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(O,{title:F(`skills.origin`)}),(0,K.jsx)(f,{className:`p-4`,children:(0,K.jsxs)(`dl`,{className:`grid grid-cols-[6rem_minmax(0,1fr)] gap-y-2 text-[0.8125rem]`,children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.source`)}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(`a`,{href:`https://skills.sh/${e.origin}`,target:`_blank`,rel:`noreferrer`,className:`break-all underline hover:text-ink`,children:e.origin})}),J?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.license`)}),(0,K.jsx)(`dd`,{className:`break-words`,children:J})]}):null,e.originHash?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`dt`,{className:`text-ink-3`,children:F(`skills.version`)}),(0,K.jsx)(`dd`,{className:`font-mono text-[0.75rem]`,children:e.originHash.slice(0,12)})]}):null]})}),e.readOnly?null:(0,K.jsxs)(r,{variant:`secondary`,size:`sm`,className:`self-start`,busy:B.isPending,onClick:()=>B.mutate(),children:[(0,K.jsx)(ne,{className:`size-4`}),` `,F(`skills.copy`)]})]}):null,i?null:Q]})]}),(0,K.jsx)($,{file:V,readOnly:m,onClose:()=>j(null),onChange:e=>W({files:h.files.map(t=>t.path===A?{...t,text:e}:t)}),onDelete:()=>{W({files:h.files.filter(e=>e.path!==A)}),j(null)}}),(0,K.jsx)(de,{open:M,taken:h.files.map(e=>e.path),onClose:()=>N(!1),onMade:e=>{W({files:[...h.files,{path:e,text:``}].sort((e,t)=>e.path.localeCompare(t.path))}),N(!1),j(e)}})]})}export{me as SkillEditor};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dt as i,Q as a,S as o,Sn as s,Tn as c,Vr as l,X as u,Zn as d,an as f,en as p,fn as m,gr as h,hn as g,kn as _,nn as v,on as y,rn as b,rr as x,tn as S,un as C}from"./ui-Mplfhz_Z.js";import{t as w}from"./useMutation-8QRM-z4M.js";import{d as T,i as E}from"./marked.esm-DQ7XA7AC.js";import{t as D}from"./circle-check-DDLzlcXP.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-Bymk5Ev-.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=T(j),N={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};N.node;var P=T(N),F={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function I(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function V(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Dt as i,Q as a,S as o,Sn as s,Tn as c,Vr as l,X as u,Zn as d,an as f,en as p,fn as m,gr as h,hn as g,kn as _,nn as v,on as y,rn as b,rr as x,tn as S,un as C}from"./ui-DAk_vjrL.js";import{t as w}from"./useMutation-isHfB33W.js";import{d as T,i as E}from"./marked.esm-DQ7XA7AC.js";import{t as D}from"./circle-check-DDLzlcXP.js";import{t as O}from"./upload-CAlHC232.js";import{n as k,s as A}from"./i18n-BaPKbQ1s.js";var j={name:`badge-check`,size:24,node:[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m16 9-5.5 5.5L8 12`,key:`xofnsj`}]],aliases:[`verified`]};j.node;var M=T(j),N={name:`circle-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.35 2.69A10 10 0 0 1 21.3 15.65`,key:`1pfsoa`}],[`path`,{d:`M19.08 19.08A10 10 0 1 1 4.92 4.92`,key:`1ablyi`}]]};N.node;var P=T(N),F={name:64,description:1024,skillMd:1e5,file:256e3,total:1e6,files:100,perSpace:100,always:5,alwaysChars:2e4,listed:50,blobFile:5e6,blobTotal:2e7,blobFiles:200};function I(e){return!e||e.length>200||e.startsWith(`/`)||e.includes(`\\`)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`&&/^[\w.@+ -]+$/.test(e))}var L=/\.(py|sh|bash|zsh|js|mjs|cjs|ts|rb|php|go|rs)$/i;function R(e){return L.test(e)}var z=class extends Error{problem;constructor(e){super(`SKILL.md: ${e}`),this.problem=e}};function B(e){let t=e.trim();if(t.length>=2&&t.startsWith(`"`)&&t.endsWith(`"`))try{return JSON.parse(t)}catch{return t.slice(1,-1)}return t.length>=2&&t.startsWith(`'`)&&t.endsWith(`'`)?t.slice(1,-1).replace(/''/g,`'`):t}function V(e,t){let n=Math.min(...t.filter(e=>e.trim()).map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(Number.isFinite(n)?n:0)),i;return i=e.startsWith(`|`)?r.join(`
2
2
  `):r.join(`
3
3
  `).replace(/([^\n])\n(?!\n)/g,`$1 `).replace(/\n\n/g,`
4
4
  `),e.includes(`-`)?i.replace(/\s+$/,``):`${i.replace(/\n*$/,``)}\n`}function H(e){let t={},n=e.replace(/\r\n?/g,`