@yuriai/web 0.2.40-beta.3 → 0.2.40-beta.4
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/{AgentAvatar-kQhfwlay.js → AgentAvatar-BmT_6apW.js} +1 -1
- package/dist/assets/{AssistantConversationSurface-CW3U6Lhp.js → AssistantConversationSurface-B-D-mLgs.js} +3 -3
- package/dist/assets/{AssistantUnreadBadge-B2SY-_-u.js → AssistantUnreadBadge-C34eOGCL.js} +1 -1
- package/dist/assets/{AssistantView-C_hiAuTd.js → AssistantView-0nXkM9VG.js} +1 -1
- package/dist/assets/{DiagramView-CzhdZEw4.js → DiagramView-BU6jWxKJ.js} +1 -1
- package/dist/assets/{FadeInOnReveal-CMeIdEKz.js → FadeInOnReveal-CCVdl9Vt.js} +1 -1
- package/dist/assets/{GuiPluginPage-WXqykPAg.js → GuiPluginPage-BMt5AMqg.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BG3hENTt.js → GuiPluginSurface-kxAcgmf1.js} +1 -1
- package/dist/assets/{GuiPluginWindow-BLzchKn7.js → GuiPluginWindow-BVvzrnp1.js} +1 -1
- package/dist/assets/{Icon-DygEqfgq.js → Icon-B5nBc6dO.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-kbBRpDSD.js → ImageLoadingPlaceholder-Bv5mmf2U.js} +1 -1
- package/dist/assets/{LoadingImage-DmucvXdY.js → LoadingImage-BzBw_1lI.js} +1 -1
- package/dist/assets/{MarkdownRenderer-BkOMcK8x.js → MarkdownRenderer-CoMohPOZ.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-B5vJtPoa.js → MarkdownRendererImpl-DoZW1UKH.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-1J-Gu2M2.js → MarkstreamRendererImpl-B3zd5x2O.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-48o8aG28.js → MobileDetailNavigation-bEZ_NA03.js} +1 -1
- package/dist/assets/{MobileResizableSheet-Dt2U0JHY.js → MobileResizableSheet-D5PcZMuI.js} +1 -1
- package/dist/assets/{MobileShareBridge-DnYT3Dbz.js → MobileShareBridge-Cjukxazk.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-D6kqRFm0.js → MobileTabPageHeader-Da1maXx-.js} +1 -1
- package/dist/assets/{MultiRunWindow-BuRo90Ma.js → MultiRunWindow-rMqP99ID.js} +1 -1
- package/dist/assets/{OnboardingScreen-Bn0RgrJU.js → OnboardingScreen-CZhqHzAj.js} +1 -1
- package/dist/assets/{OverlayScrollbar-B0X61qR-.js → OverlayScrollbar-Byx2H3pc.js} +1 -1
- package/dist/assets/{SettingsView-Bla2lVqS.js → SettingsView-7Bea2DvF.js} +1 -1
- package/dist/assets/{SettingsWindow-kCbf8IoB.js → SettingsWindow-U-RDDOS7.js} +1 -1
- package/dist/assets/{SetupTourDialog-GDRS3gDa.js → SetupTourDialog-CKec5tUy.js} +1 -1
- package/dist/assets/{TerminalView-B1u3s7IN.js → TerminalView-CS1oSAuY.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CYUPmbtq.js → ToolOutputDialog-BWhrFvvI.js} +1 -1
- package/dist/assets/{VoiceSettings-Dy6-nkQo.js → VoiceSettings-7aFmJq9Z.js} +1 -1
- package/dist/assets/{appThemeRegistry--G1XaYmo.js → appThemeRegistry-LyWTE-mT.js} +1 -1
- package/dist/assets/{capgoAdapter-DO1rEVQf.js → capgoAdapter-B5NImlKh.js} +1 -1
- package/dist/assets/{checkbox-BW80bcK5.js → checkbox-Bdj4n5cI.js} +1 -1
- package/dist/assets/{collapsible-BOL5Wx2J.js → collapsible-D1JZOgJZ.js} +1 -1
- package/dist/assets/{context-menu-CiFnjP1q.js → context-menu-DDX0ZFhc.js} +1 -1
- package/dist/assets/{diagram-DRn8iIs1.js → diagram-C72TQWfh.js} +1 -1
- package/dist/assets/{dialog-DQp289fr.js → dialog-CIKJalI5.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-582p0uCX.js → fileMentionTouchSelection-tnd9RDDh.js} +1 -1
- package/dist/assets/{gitApi-vYBmQIuU.js → gitApi-BI8OG_ts.js} +1 -1
- package/dist/assets/{input-B281XcMR.js → input-gVHSS0EB.js} +1 -1
- package/dist/assets/{insertionBoundaries-CB4gv9rr.js → insertionBoundaries-B-yZI6iY.js} +1 -1
- package/dist/assets/{main-Caf-6KmT.js → main-BfAN93rT.js} +4 -4
- package/dist/assets/{main-B1KrAdkh.js → main-DYWwmI_W.js} +2 -2
- package/dist/assets/{markdownHeightCache-BgYJswDy.js → markdownHeightCache-B-FoaQ1U.js} +1 -1
- package/dist/assets/{mcpQueries-CQyOFjX2.js → mcpQueries-CehWHIB1.js} +1 -1
- package/dist/assets/{miniChat-zEoOVjOQ.js → miniChat-BlkcLQBr.js} +2 -2
- package/dist/assets/{mobile-Dt8wAkc4.js → mobile-I3Xe5NtO.js} +2 -2
- package/dist/assets/{mobileBackNavigation-BbKMa0Jb.js → mobileBackNavigation-BFUH-c-G.js} +1 -1
- package/dist/assets/{mobileConnections-CXYj4P9M.js → mobileConnections-BFvtbJXX.js} +2 -2
- package/dist/assets/{multirun-9v2r_beX.js → multirun-DdEjp77z.js} +1 -1
- package/dist/assets/{native-config-BOaqa45X.js → native-config-DqDXViVx.js} +1 -1
- package/dist/assets/{projectMeta-ZouOo-T_.js → projectMeta-BKgum5WN.js} +1 -1
- package/dist/assets/{pwa-syKJBLoe.js → pwa-BvKUY4Hk.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-BYH5yLM2.js → queue-abort-optimistic-BcbiNk8t.js} +1 -1
- package/dist/assets/{react-DPhQUTaH.js → react-DeB-Vc_L.js} +1 -1
- package/dist/assets/{readiness-BpVAjFhF.js → readiness-CIlvQ-aQ.js} +2 -2
- package/dist/assets/{renderElectronMiniChatApp-DprABvit.js → renderElectronMiniChatApp-DIjWdFHu.js} +2 -2
- package/dist/assets/{renderMobileApp-DQmX6iak.js → renderMobileApp-CE0QyOH0.js} +4 -4
- package/dist/assets/{runtimeConfig-7Umh9QWi.js → runtimeConfig-uhjQn4kK.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-BYtLmSuX.js → runtimeEndpointReset-DezNESKT.js} +3 -3
- package/dist/assets/{select-CyPxbnW8.js → select-BwCKwnTH.js} +1 -1
- package/dist/assets/{sessionLookup-D_fPlqqT.js → sessionLookup-DzKZsy-W.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-BclS0Hnd.js → sortable-tabs-strip-m5JQrTx4.js} +1 -1
- package/dist/assets/{speechSettingsQueries-CTsBn-Ib.js → speechSettingsQueries-C5mPRWIv.js} +1 -1
- package/dist/assets/{textarea-CjJsstUF.js → textarea-CaTDyZrS.js} +1 -1
- package/dist/assets/{tooltip-Di_DSZ8p.js → tooltip-BvZzoiqg.js} +1 -1
- package/dist/assets/{types-wnqkJWYs.js → types-Bm8kDgSv.js} +1 -1
- package/dist/assets/{useAppFontEffects-BRMf55oN.js → useAppFontEffects-C9IaiJgF.js} +5 -5
- package/dist/assets/{useDesktopWindowControlsLayout-Bq9DFNYn.js → useDesktopWindowControlsLayout-C3M12PjJ.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-5RwQ_nuK.js → useEffectiveDirectory-Do4UqfZR.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-ePbEoQwb.js → useMobileNavigationStore-InwdmuDX.js} +5 -5
- package/dist/assets/{usePluginsStore-HJJZ65gd.js → usePluginsStore-BH4-CNcj.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-CjMALEr7.js → useStreamingTextThrottle-CeKHHK13.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-6x1R4afJ.js → useWorkerHighlightedLines-0XahwAbS.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/lib/assistants/builtin-skills.js +1 -1
- package/server/lib/assistants/builtin-skills.test.js +2 -0
- package/server/lib/gui-customization/DOCUMENTATION.md +25 -1
- package/server/lib/gui-customization/projects-client.mjs +59 -0
- package/server/lib/gui-customization/projects.js +43 -0
- package/server/lib/gui-customization/projects.test.js +103 -0
- package/server/lib/gui-customization/remote-connections-client.mjs +2 -8
- package/server/lib/gui-customization/session-skill-command.mjs +8 -0
- package/server/lib/gui-customization/session-skill.js +15 -10
- package/server/lib/gui-customization/session-skill.test.js +21 -2
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/projects.md +63 -0
- package/server/lib/notifications/DOCUMENTATION.md +12 -0
- package/server/lib/notifications/runtime.js +20 -2
- package/server/lib/notifications/runtime.test.js +21 -0
- package/server/lib/notifications/session-unread-runtime.js +51 -13
- package/server/lib/notifications/session-unread.test.js +113 -1
- package/server/lib/opencode/core-routes.js +2 -1
- package/server/lib/opencode/feature-routes-runtime.js +6 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +4 -0
- package/server/lib/projects/DOCUMENTATION.md +6 -3
- package/server/lib/scheduled-tasks/session-skill.js +2 -1
- package/server/lib/scheduled-tasks/session-skill.test.js +34 -1
- package/server/lib/session-index/DOCUMENTATION.md +4 -1
- package/server/lib/session-index/event-ingest.js +8 -0
- package/server/lib/session-index/event-ingest.test.js +16 -0
- package/server/lib/session-index/service.js +1 -0
- package/server/lib/session-index/service.test.js +3 -1
- package/server/lib/session-metadata/DOCUMENTATION.md +18 -1
- package/server/lib/session-title/DOCUMENTATION.md +3 -0
- package/server/lib/session-title/runtime.js +1 -0
- package/server/lib/session-title/runtime.test.js +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./runtime-switch-BMjl5Y5W.js";import{n}from"./runtime-fetch-DKZOpfzo.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{kn as l}from"./gitApiHttp-D4d-rgcR.js";import{w as u}from"./useUIStore-vvNwcOk3.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{_ as p,g as m,h}from"./fileQueries-D9l0crnM.js";import{t as g}from"./i18n-UaLestuf.js";import{Ea as _,Jn as v,Kn as y,wa as b}from"./useMobileNavigationStore-ePbEoQwb.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=g(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=v(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(y,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=v(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=v(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=v(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=v(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=v(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=v(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let _;t[17]===a?_=t[18]:(_=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=_);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==_?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,_]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=_,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=v(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>p.plugins.list(t,n),P=(t,n,r=!1,i=e())=>p.plugins.registry(t,n,r,i),F=(t,n=e())=>p.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=b(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=h(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=b(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(m,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=_(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=_(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=_(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=_.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let p=K.get(l);if(!n?.force&&p)return p;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(m,a,o):await m.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(m.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(m,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
|
1
|
+
import{i as e,n as t}from"./runtime-switch-BMjl5Y5W.js";import{n}from"./runtime-fetch-DKZOpfzo.js";import{a as r,i,r as a}from"./vendor-zustand-vDaAPGfl.js";import{o,ot as s,s as c}from"./vendor-base-ui-CzHs0bHY.js";import{kn as l}from"./gitApiHttp-D4d-rgcR.js";import{w as u}from"./useUIStore-vvNwcOk3.js";import{n as d}from"./vendor-react-DlzBev0S.js";import{s as f}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{_ as p,g as m,h}from"./fileQueries-D9l0crnM.js";import{t as g}from"./i18n-UaLestuf.js";import{Ea as _,Jn as v,Kn as y,wa as b}from"./useMobileNavigationStore-InwdmuDX.js";var x=d(),S=s();function ee(e){let t=(0,x.c)(17),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:s}=e,l=i!==void 0&&i,{t:u}=g(),d;t[0]!==n||t[1]!==l||t[2]!==r?(d=e=>{!l&&e!==n&&r(e)},t[0]=n,t[1]=l,t[2]=r,t[3]=d):d=t[3];let f;t[4]===s?f=t[5]:(f=v(`yuri-settings-switch`,s),t[4]=s,t[5]=f);let p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=[!1,!0],t[6]=p):p=t[6];let m;t[7]!==n||t[8]!==u?(m=p.map(e=>(0,S.jsxs)(c,{value:e,nativeButton:!0,render:(0,S.jsx)(y,{variant:`ghost`,size:`xs`}),className:`yuri-settings-switch-option`,children:[n===e&&(0,S.jsx)(`span`,{"aria-hidden":!0,className:`yuri-segmented-selected-pill yuri-settings-switch-pill`}),(0,S.jsx)(`span`,{className:`relative`,children:u(e?`settings.switch.on`:`settings.switch.off`)})]},String(e))),t[7]=n,t[8]=u,t[9]=m):m=t[9];let h;return t[10]!==a||t[11]!==n||t[12]!==l||t[13]!==d||t[14]!==f||t[15]!==m?(h=(0,S.jsx)(o,{value:n,onValueChange:d,disabled:l,"aria-label":a,"aria-orientation":`horizontal`,"data-slot":`settings-switch`,className:f,onClick:w,onKeyDown:C,children:m}),t[10]=a,t[11]=n,t[12]=l,t[13]=d,t[14]=f,t[15]=m,t[16]=h):h=t[16],h}function C(e){return e.stopPropagation()}function w(e){return e.stopPropagation()}function T(e){let t=(0,x.c)(10),{children:n,actions:r,className:i}=e,a;t[0]===i?a=t[1]:(a=v(`flex shrink-0 items-center justify-between gap-3 py-3`,i),t[0]=i,t[1]=a);let o;t[2]===n?o=t[3]:(o=(0,S.jsx)(`div`,{className:`min-w-0 flex-1`,children:n}),t[2]=n,t[3]=o);let s;t[4]===r?s=t[5]:(s=(0,S.jsx)(`div`,{className:`flex max-w-[70%] shrink-0 flex-wrap items-center justify-end gap-2 [&_button]:max-w-full [&_button]:whitespace-normal`,children:r}),t[4]=r,t[5]=s);let c;return t[6]!==a||t[7]!==o||t[8]!==s?(c=(0,S.jsxs)(`header`,{"data-settings-action-header":``,className:a,children:[o,s]}),t[6]=a,t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function E(e){let t=(0,x.c)(21),{label:n,actions:r,children:i,description:a,itemId:o,ariaLabel:s,className:c,cardClassName:l,cardId:u}=e,d=typeof n==`string`&&/^[\p{Script=Latin}\p{Number}\p{Punctuation}\p{Separator}]+$/u.test(n)?`latin`:void 0,f;t[0]===c?f=t[1]:(f=v(`yuri-settings-group`,c),t[0]=c,t[1]=f);let p;t[2]!==r||t[3]!==n||t[4]!==d?(p=r?(0,S.jsx)(T,{className:`py-0`,actions:r,children:n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null}):n?(0,S.jsx)(`div`,{className:`yuri-settings-group-label`,"data-settings-label-script":d,children:n}):null,t[2]=r,t[3]=n,t[4]=d,t[5]=p):p=t[5];let m;t[6]===l?m=t[7]:(m=v(`yuri-settings-group-card`,l),t[6]=l,t[7]=m);let h;t[8]!==u||t[9]!==i||t[10]!==o||t[11]!==m?(h=(0,S.jsx)(`div`,{id:u,"data-settings-item":o,className:m,children:i}),t[8]=u,t[9]=i,t[10]=o,t[11]=m,t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=a?(0,S.jsx)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:a}):null,t[13]=a,t[14]=g);let _;return t[15]!==s||t[16]!==f||t[17]!==p||t[18]!==h||t[19]!==g?(_=(0,S.jsxs)(`section`,{className:f,"aria-label":s,children:[p,h,g]}),t[15]=s,t[16]=f,t[17]=p,t[18]=h,t[19]=g,t[20]=_):_=t[20],_}function D(e){let t=(0,x.c)(20),n,r,i,a,o,s,c,l;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8]):({label:s,description:a,descriptionPlacement:l,ariaLabel:n,groupClassName:o,cardClassName:r,children:i,...c}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l);let u=l===void 0?`inside`:l,d=u===`outside`?a:void 0,f=u===`inside`?a:void 0,p;t[9]!==i||t[10]!==s||t[11]!==c||t[12]!==f?(p=(0,S.jsx)(O,{label:s,description:f,...c,children:i}),t[9]=i,t[10]=s,t[11]=c,t[12]=f,t[13]=p):p=t[13];let m;return t[14]!==n||t[15]!==r||t[16]!==o||t[17]!==d||t[18]!==p?(m=(0,S.jsx)(E,{ariaLabel:n,className:o,cardClassName:r,description:d,children:p}),t[14]=n,t[15]=r,t[16]=o,t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function O(e){let t=(0,x.c)(25),{label:n,children:r,description:i,footer:a,itemId:o,className:s,copyClassName:c,controlClassName:l}=e,u;t[0]===s?u=t[1]:(u=v(`yuri-settings-group-row yuri-settings-split-row`,s),t[0]=s,t[1]=u);let d;t[2]===c?d=t[3]:(d=v(`yuri-settings-split-row-copy`,c),t[2]=c,t[3]=d);let f;t[4]===n?f=t[5]:(f=n?(0,S.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:n}):null,t[4]=n,t[5]=f);let p;t[6]===i?p=t[7]:(p=i?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i}):null,t[6]=i,t[7]=p);let m;t[8]!==d||t[9]!==f||t[10]!==p?(m=(0,S.jsxs)(`div`,{className:d,children:[f,p]}),t[8]=d,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]===l?h=t[13]:(h=v(`yuri-settings-split-row-control`,l),t[12]=l,t[13]=h);let g;t[14]!==r||t[15]!==h?(g=(0,S.jsx)(`div`,{"data-settings-value":``,className:h,children:r}),t[14]=r,t[15]=h,t[16]=g):g=t[16];let _;t[17]===a?_=t[18]:(_=a?(0,S.jsx)(`div`,{"data-slot":`settings-row-footer`,className:`col-span-full min-w-0`,children:a}):null,t[17]=a,t[18]=_);let y;return t[19]!==o||t[20]!==u||t[21]!==m||t[22]!==g||t[23]!==_?(y=(0,S.jsxs)(`div`,{"data-settings-item":o,className:u,children:[m,g,_]}),t[19]=o,t[20]=u,t[21]=m,t[22]=g,t[23]=_,t[24]=y):y=t[24],y}function te(e){let t=(0,x.c)(32),{checked:n,onChange:r,label:i,ariaLabel:a,description:o,itemId:s,disabled:c,className:l}=e,u=c!==void 0&&c,d;t[0]!==n||t[1]!==u||t[2]!==r?(d=()=>{u||r(!n)},t[0]=n,t[1]=u,t[2]=r,t[3]=d):d=t[3];let f=d,p=ne,m=u?`cursor-not-allowed`:`cursor-pointer`,h;t[4]!==l||t[5]!==m?(h=v(`yuri-settings-group-row yuri-settings-split-row group`,m,l),t[4]=l,t[5]=m,t[6]=h):h=t[6];let g=u?-1:0,_=u||void 0,y,b;t[7]===f?(y=t[8],b=t[9]):(y=e=>{p(e.target)||f()},b=e=>{p(e.target)||(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),f())},t[7]=f,t[8]=y,t[9]=b);let C;t[10]===i?C=t[11]:(C=(0,S.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i}),t[10]=i,t[11]=C);let w;t[12]===o?w=t[13]:(w=o?(0,S.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o}):null,t[12]=o,t[13]=w);let T;t[14]!==w||t[15]!==C?(T=(0,S.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[C,w]}),t[14]=w,t[15]=C,t[16]=T):T=t[16];let E;t[17]!==a||t[18]!==n||t[19]!==u||t[20]!==r?(E=(0,S.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,S.jsx)(ee,{checked:n,onChange:r,disabled:u,ariaLabel:a})}),t[17]=a,t[18]=n,t[19]=u,t[20]=r,t[21]=E):E=t[21];let D;return t[22]!==n||t[23]!==s||t[24]!==T||t[25]!==E||t[26]!==h||t[27]!==g||t[28]!==_||t[29]!==y||t[30]!==b?(D=(0,S.jsxs)(`div`,{"data-settings-item":s,className:h,role:`button`,tabIndex:g,"aria-pressed":n,"aria-disabled":_,onClick:y,onKeyDown:b,children:[T,E]}),t[22]=n,t[23]=s,t[24]=T,t[25]=E,t[26]=h,t[27]=g,t[28]=_,t[29]=y,t[30]=b,t[31]=D):D=t[31],D}function ne(e){return e instanceof HTMLElement&&e.closest(`button, a, input, select, textarea`)!==null}var k=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},A=()=>{let e=l.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},re=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},ie=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},ae=e=>({source:re(e.source),state:ie(e.state)}),oe=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>ae(e))};async function j(e,t){return oe((await A().list(k(e),t?{signal:t}:void 0))?.data)}async function se(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await A().update({...k(e),targets:[r]},n?{signal:n}:void 0)}function ce(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var le=1500,M=e=>e?.trim()||null,N=(t,n=e())=>p.plugins.list(t,n),P=(t,n,r=!1,i=e())=>p.plugins.registry(t,n,r,i),F=(t,n=e())=>p.plugins.runtime(t,n),I=0,L=()=>(I+=1,I),R=(e,t,n)=>e.getQueryData(F(t,n)),z=(t=b(),r=e())=>{let i=M(t);return{queryKey:N(i,r),queryFn:async({signal:e})=>{let t=await n(he(`/api/config/plugins`,i),{headers:U(i),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},B=(t,r,i=!1,a=e(),o=!1)=>{let s=M(t),c=h(r);return{queryKey:o?[...P(s,c,i,a),`details`]:P(s,c,i,a),queryFn:async({signal:e})=>{let t={};for(let r of _e(c)){let a=ge(r,i,s),c=await n(o?`${a}&details=true`:a,{headers:U(s),signal:e});if(!c.ok)throw Error(`Failed to load plugin registry info`);let l=await c.json();for(let e of l.results??[])t[e.spec]=e}return t},staleTime:i?0:3e5,retry:2}},ue=(t=b(),n=e())=>{let r=M(t);return{queryKey:F(r,n),queryFn:async({signal:e})=>{let t=L(),i=await j(r,e);if(t!==I){let e=R(m,r,n);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},de=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=_(ve),a;t[2]===i?a=t[3]:(a=z(M(i)??M(l.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},fe=(e,t)=>{let n=(0,x.c)(6),r=t!==void 0&&t,i=_(ye),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=B(M(i)??M(l.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),f(o)},V=()=>{let e=(0,x.c)(2),t=_(be),n;return e[0]===t?n=e[1]:(n=M(t)??M(l.getDirectory()),e[0]=t,e[1]=n),n},pe=e=>{let t=(0,x.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=V(),a;t[2]===i?a=t[3]:(a=ue(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],f(o)},H=async(t,n,r)=>{let i=M(n);return e()===r?t.fetchQuery({...z(i,r),staleTime:0}):t.getQueryData(N(i,r))??{entries:[],files:[]}},me=async(t,n,r)=>{let i=M(n);if(e()!==r)return R(t,i,r);let a=L(),o=await j(i);return a!==I||e()!==r?R(t,i,r):(t.setQueryData(F(i,r),o),o)};function he(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ge(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function _e(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>le){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function U(e){return e?{"x-opencode-directory":e}:void 0}function ve(e){return e.getActiveProject?.()?.path??null}function ye(e){return e.getActiveProject?.()?.path??null}function be(e){return e.getActiveProject?.()?.path??null}var W=()=>{try{let e=_.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=l.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},xe=5e3,Se=`__default__`,G=new Map,K=new Map,Ce=1500,q=e=>e?.trim()||Se,we=e=>{G.delete(q(e))},J=r()(a(i((r,i)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,setSelected:e=>r({selectedId:e}),setDraft:e=>r({draft:e}),loadPlugins:async n=>{let a=W(),o=e(),s=t(),c=()=>o===e()&&s===t()&&a===W(),l=q(a),u=Date.now(),d=G.get(l)??0,f=i().entries.length>0||i().files.length>0;if(!n?.force&&f&&u-d<xe)return!0;let p=K.get(l);if(!n?.force&&p)return p;let h=(async()=>{r({isLoading:!0});try{let e=n?.force?await H(m,a,o):await m.fetchQuery(z(a,o));return c()?(r({entries:e.entries??[],files:e.files??[],isLoading:!1}),G.set(l,Date.now()),n?.force||i().loadRegistryInfo(),!0):!1}catch(e){return console.error(`[PluginsStore] Failed to load plugins:`,e),c()&&r({isLoading:!1}),!1}})();K.set(l,h);try{return await h}finally{K.delete(l)}},loadRegistryInfo:async e=>{let t=Ee(e?.specs??i().entries.map(e=>e.spec));if(t.length===0){r({isLoadingRegistry:!1});return}r({isLoadingRegistry:!0});try{let a=W(),o={...i().registryInfo};for(let r of De(t)){let t=await n(Te(r,e?.force===!0,a),{headers:X(a)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let i=await $(t);for(let e of i.results??[])o[e.spec]=e}r({registryInfo:o,isLoadingRegistry:!1})}catch(e){console.error(`[PluginsStore] Failed to load plugin registry info:`,e),r({isLoadingRegistry:!1})}},updateToLatest:async e=>{let t=i().entries.find(t=>t.id===e);if(!t)return{ok:!1};let n=i().registryInfo[t.spec];return!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion?{ok:!1}:await i().updateEntry(e,{spec:`${n.name}@${n.latestVersion}`})},createEntry:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/entry`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(Oe(e))}));return t.ok&&i().loadRegistryInfo({specs:[e.spec],force:!0}),t},updateEntry:async(t,r)=>{let a=(m.getQueryData(z(W(),e()).queryKey)?.entries??i().entries).find(e=>e.id===t),o=a?.spec,s=r.spec??o,c=await Q(async e=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(t)}`,e),{method:`PATCH`,headers:Z(e),body:JSON.stringify(Oe(r))}),a&&s?{...a,spec:s}:void 0);return c.ok&&s&&i().loadRegistryInfo({specs:[s],force:!0}),c},deleteEntry:async e=>{let t=i().entries.find(t=>t.id===e),a=await Q(async t=>await n(Y(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));if(a.ok&&i().selectedId===e&&r({selectedId:null}),a.ok&&t){let e={...i().registryInfo};delete e[t.spec],r({registryInfo:e})}return a},readFile:async e=>{try{let t=W(),r=await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:X(t)});if(!r.ok)throw Error(`Failed to read plugin file`);return await $(r)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>Q(async t=>await n(Y(`/api/config/plugins/file`,t),{method:`POST`,headers:Z(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>Q(async r=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,r),{method:`PUT`,headers:Z(r),body:JSON.stringify(t)})),deleteFile:async e=>{let t=await Q(async t=>await n(Y(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{method:`DELETE`,headers:X(t)}));return t.ok&&i().selectedId===e&&r({selectedId:null}),t},getById:e=>i().entries.find(t=>t.id===e)??i().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:u(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function Y(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function Te(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Ee(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function De(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>Ce?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function X(e){return e?{"x-opencode-directory":e}:void 0}function Z(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function Oe(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function Q(n,r){let i=e(),a=t();try{let o=W(),s=await n(o),c=await $(s).catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update plugin configuration`);if(i!==e()||a!==t())return{ok:!0};we(o);let l=await H(m,o,i);if(o===W()&&i===e()&&a===t()){let e=r&&J.getState().selectedId===r.id?l.entries.find(e=>e.spec===r.spec&&e.scope===r.scope&&e.sourcePath===r.sourcePath):void 0;J.setState({entries:l.entries,files:l.files,...e?{selectedId:e.id}:{}}),G.set(q(o),Date.now())}return{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function $(e){return await e.json()}export{V as a,de as c,D as d,E as f,ee as g,T as h,me as i,ce as l,te as m,B as n,fe as o,O as p,z as r,pe as s,J as t,se as u};
|
package/dist/assets/{useStreamingTextThrottle-CjMALEr7.js → useStreamingTextThrottle-CeKHHK13.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-DMsFWy1a.js";import{st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./FadeInOnReveal-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./platform-DMsFWy1a.js";import{st as n}from"./vendor-base-ui-CzHs0bHY.js";import{r}from"./FadeInOnReveal-CCVdl9Vt.js";var i=e(n(),1),a=(e,t,n)=>{let r=t-e;return Math.max(0,n-r)},o=e=>{e.timer&&=(clearTimeout(e.timer),null)},s=({text:e,isStreaming:n,throttleMs:s=r(t()).textThrottleMs,identityKey:c})=>{let[l,u]=i.useState(e),d=i.useRef(e),f=i.useRef(l),p=i.useRef({timer:null,pendingText:e,lastEmitAt:0});return i.useEffect(()=>{d.current=e},[e]),i.useEffect(()=>{f.current=l},[l]),i.useEffect(()=>{let e=p.current;o(e),e.pendingText=d.current,e.lastEmitAt=0,u(d.current)},[c]),i.useEffect(()=>{let t=p.current;t.pendingText=e;let r=f.current,i=n&&r.length>e.length?r:e;if(!n){o(t),t.lastEmitAt=Date.now(),u(i);return}let c=Date.now(),l=a(t.lastEmitAt,c,s);if(l<=0){o(t),t.lastEmitAt=c,u(i);return}return o(t),t.timer=setTimeout(()=>{t.timer=null,t.lastEmitAt=Date.now(),u(e=>n&&e.length>t.pendingText.length?e:t.pendingText)},l),()=>{o(t)}},[n,e,s]),i.useEffect(()=>{let e=p.current;return()=>{o(e)}},[]),l};export{s as t};
|
package/dist/assets/{useWorkerHighlightedLines-6x1R4afJ.js → useWorkerHighlightedLines-0XahwAbS.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{S as r}from"./useUIStore-vvNwcOk3.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{t as a}from"./i18n-UaLestuf.js";import{Jn as o,Kn as s}from"./useMobileNavigationStore-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-CzHs0bHY.js";import{S as r}from"./useUIStore-vvNwcOk3.js";import{n as i}from"./vendor-react-DlzBev0S.js";import{t as a}from"./i18n-UaLestuf.js";import{Jn as o,Kn as s}from"./useMobileNavigationStore-InwdmuDX.js";import{n as c}from"./useThemeSystem-CNzUUkFn.js";import{n as l}from"./Icon-B5nBc6dO.js";import{n as u}from"./MarkdownRenderer-CoMohPOZ.js";import{n as d,r as f}from"./toolHelpers-iEHVHQ9p.js";import{n as p}from"./markdownTheme-CHNl6tUv.js";import{n as m,t as h}from"./markdown-worker-oBGEB9Eg.js";var g=e(n(),1),_=i(),v=t(),y=e=>e===`in_progress`||e===`completed`||e===`cancelled`?e:`pending`,b=e=>e.status===`completed`||e.status===`cancelled`,x={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},S={in_progress:`text-foreground`,pending:`text-muted-foreground/60`,completed:`text-muted-foreground`,cancelled:`text-muted-foreground/60`},C={in_progress:`text-foreground`,pending:`text-muted-foreground`,completed:`text-muted-foreground/60 line-through decoration-1`,cancelled:`text-muted-foreground/60 line-through decoration-1`},w=1.2,T=24,E=`1 1`,D=e=>{let t=(0,_.c)(23),{status:n,className:r}=e,{t:i}=a(),s=x[n],c;t[0]!==i||t[1]!==s?(c=i(s),t[0]=i,t[1]=s,t[2]=c):c=t[2];let l=S[n],u;t[3]!==r||t[4]!==l?(u=o(`size-[1em] shrink-0 transition-colors duration-300`,l,r),t[3]=r,t[4]=l,t[5]=u):u=t[5];let d=n===`pending`?w:void 0,f=n===`pending`?T:void 0,p=n===`pending`?E:void 0,m;t[6]!==d||t[7]!==f||t[8]!==p?(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:d,pathLength:f,strokeDasharray:p}),t[6]=d,t[7]=f,t[8]=p,t[9]=m):m=t[9];let h;t[10]===n?h=t[11]:(h=n===`in_progress`?(0,v.jsx)(`path`,{d:`M4.8 8h6.4M8.6 5.4 11.2 8l-2.6 2.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[10]=n,t[11]=h);let g;t[12]===n?g=t[13]:(g=n===`completed`?(0,v.jsx)(`path`,{d:`M5 8 7.5 11 11 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[12]=n,t[13]=g);let y;t[14]===n?y=t[15]:(y=n===`cancelled`?(0,v.jsx)(`path`,{d:`M3.5 12.5 12.5 3.5`,stroke:`currentColor`}):null,t[14]=n,t[15]=y);let b;return t[16]!==g||t[17]!==y||t[18]!==c||t[19]!==u||t[20]!==m||t[21]!==h?(b=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,role:`img`,"aria-label":c,className:u,children:[m,h,g,y]}),t[16]=g,t[17]=y,t[18]=c,t[19]=u,t[20]=m,t[21]=h,t[22]=b):b=t[22],b},O=3.2,k=e=>{let t=Math.PI*2*e,n=8+O*Math.sin(t),r=8-O*Math.cos(t);return`M8 8 L8 4.8 A${O} ${O} 0 ${+(e>.5)} 1 ${n.toFixed(3)} ${r.toFixed(3)} Z`},A=e=>{let t=(0,_.c)(11),{done:n,total:r,spinning:i,className:a}=e,s=n===void 0?0:n,c=r===void 0?0:r,l=i!==void 0&&i,u=c>0?Math.min(1,s/c):0,d;t[0]===a?d=t[1]:(d=o(`size-[1.15em] shrink-0 text-foreground`,a),t[0]=a,t[1]=d);let f=l?`yuri-todo-spin`:void 0,p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p={transformBox:`fill-box`,transformOrigin:`center`},t[2]=p):p=t[2];let m;t[3]===f?m=t[4]:(m=(0,v.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:w,pathLength:T,strokeDasharray:E,className:f,style:p}),t[3]=f,t[4]=m);let h;t[5]===u?h=t[6]:(h=u>0?(0,v.jsx)(`path`,{d:k(u),fill:`currentColor`,className:`transition-opacity duration-300`}):null,t[5]=u,t[6]=h);let g;return t[7]!==d||t[8]!==m||t[9]!==h?(g=(0,v.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:d,children:[m,h]}),t[7]=d,t[8]=m,t[9]=h,t[10]=g):g=t[10],g},j=({done:e,total:t,className:n,animate:r=!0})=>{let i=g.useRef(e),a=r&&i.current!==e;return g.useEffect(()=>{i.current=e},[e]),(0,v.jsxs)(`span`,{className:o(`shrink-0 tabular-nums`,n),children:[(0,v.jsx)(`span`,{className:o(a&&`yuri-todo-count-tick`),children:e},e),`/${t}`]})},ee=e=>{let t=(0,_.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=o(`flex size-[1.15em] shrink-0 items-center justify-center rounded-full bg-[var(--status-success)] text-[var(--status-success-foreground)]`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,v.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`size-[70%]`,children:(0,v.jsx)(`path`,{d:`M4.5 8.2 7 10.8 11.5 5.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,v.jsx)(`span`,{"data-todo-complete":!0,className:r,children:i}),t[3]=r,t[4]=a),a},M=e=>{let t=(0,_.c)(27),{todos:n,isWorking:r,animate:i,className:s,rowClassName:c,listRef:l,id:u}=e,d=r!==void 0&&r,f=i!==void 0&&i,{t:p}=a(),m=n.findIndex(N),h;t[0]!==m||t[1]!==n?(h=m>=0?m:n.findIndex(P),t[0]=m,t[1]=n,t[2]=h):h=t[2];let g=h,b;t[3]===n?b=t[4]:(b=n.some(F),t[3]=n,t[4]=b);let S=b,w;t[5]===s?w=t[6]:(w=o(`m-0 flex min-w-0 list-none flex-col gap-[0.125em] p-0`,s),t[5]=s,t[6]=w);let T;if(t[7]!==g||t[8]!==f||t[9]!==S||t[10]!==d||t[11]!==c||t[12]!==p||t[13]!==n){let e;t[15]!==g||t[16]!==f||t[17]!==S||t[18]!==d||t[19]!==c||t[20]!==p?(e=(e,t)=>{let n=y(e.status),r=d&&!S&&t===g&&n===`pending`?`in_progress`:n;return(0,v.jsxs)(`li`,{"data-status":r,"aria-current":t===g?`step`:void 0,className:o(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)] items-start py-[0.25em]`,c??`gap-[0.6em] px-[0.5em]`,f&&`yuri-todo-row-in`),children:[(0,v.jsx)(`span`,{className:o(`flex h-[1.32em] w-[1.15em] items-center justify-center`,f&&`yuri-todo-icon-pop`),title:p(x[r]),children:(0,v.jsx)(D,{status:r})},r),(0,v.jsx)(`span`,{dir:`auto`,title:e.content,className:o(`line-clamp-3 min-w-0 whitespace-normal text-[0.88em] break-words leading-[1.5] transition-colors duration-300`,C[r]),children:(0,v.jsx)(`span`,{className:o(r===`in_progress`&&`animate-text-shimmer`),children:e.content})})]},e.id??`${t}:${e.content}`)},t[15]=g,t[16]=f,t[17]=S,t[18]=d,t[19]=c,t[20]=p,t[21]=e):e=t[21],T=n.map(e),t[7]=g,t[8]=f,t[9]=S,t[10]=d,t[11]=c,t[12]=p,t[13]=n,t[14]=T}else T=t[14];let E;return t[22]!==u||t[23]!==l||t[24]!==w||t[25]!==T?(E=(0,v.jsx)(`ul`,{id:u,ref:l,className:w,children:T}),t[22]=u,t[23]=l,t[24]=w,t[25]=T,t[26]=E):E=t[26],E};function N(e){return e.status===`in_progress`}function P(e){return e.status===`pending`}function F(e){return e.status===`in_progress`}var I=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),L=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,R=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=L(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},z=e=>`<pre><code>${I(e)}</code></pre>`,B=e=>{let t=(0,_.c)(21),{code:n,language:r,className:i,style:a,codeStyle:s,wrap:l}=e,u=l!==void 0&&l,{currentTheme:d}=c(),f=g.useRef(null),m;t[0]===d?m=t[1]:(m=p(d),t[0]=d,t[1]=m);let y=m,b,x;t[2]!==n||t[3]!==s||t[4]!==u?(b=()=>{let e=f.current;e&&(e.innerHTML=z(n),R(e,u,s))},x=[n,u,s],t[2]=n,t[3]=s,t[4]=u,t[5]=b,t[6]=x):(b=t[5],x=t[6]),g.useLayoutEffect(b,x);let S,C;t[7]!==n||t[8]!==s||t[9]!==r||t[10]!==u?(S=()=>{let e=f.current;if(!e)return;let t=!0,i=new AbortController;return h(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,R(e,u,s))}),()=>{t=!1,i.abort()}},C=[n,r,u,s],t[7]=n,t[8]=s,t[9]=r,t[10]=u,t[11]=S,t[12]=C):(S=t[11],C=t[12]),g.useEffect(S,C);let w;t[13]===i?w=t[14]:(w=o(`typography-code`,i),t[13]=i,t[14]=w);let T=y,E;t[15]!==a||t[16]!==T?(E={...T,...a},t[15]=a,t[16]=T,t[17]=E):E=t[17];let D;return t[18]!==w||t[19]!==E?(D=(0,v.jsx)(`div`,{ref:f,className:w,style:E}),t[18]=w,t[19]=E,t[20]=D):D=t[20],D},V=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},H=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},U=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,W=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,G=(e,t)=>!e||typeof e!=`object`?String(e):f(e,t||``),K=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},q=e=>{if(!e||typeof e!=`object`)return;let t=K(e.patch)??K(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=K(e.patch)??K(e.diff);if(t)return t}},J=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},Y=(e,t,n)=>{let r=V(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&U(r)&&(r=W(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=q(n);if(e)return e}return r},X=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
|
|
2
2
|
`).split(`
|
|
3
3
|
`),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},Z=(e,t)=>{try{let n=e.trim().split(`
|
|
4
4
|
`).filter(Boolean);if(n.length===0)return null;let i=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,r=Math.floor(e.length/2),a=!n.endsWith(`/`);i.push({name:n.replace(/\/$/,``),depth:r,isFile:a})}}),(0,v.jsx)(`div`,{className:o(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:r.tool.popup,children:i.map((e,t)=>(0,v.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,v.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,v.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Q={backgroundColor:`var(--status-info)`,opacity:.6},te=(e,t,n)=>{try{let i=e.trim().split(`
|
package/dist/index.html
CHANGED
|
@@ -571,7 +571,7 @@
|
|
|
571
571
|
opacity: 0.72;
|
|
572
572
|
}
|
|
573
573
|
</style>
|
|
574
|
-
<script type="module" crossorigin src="/assets/main-
|
|
574
|
+
<script type="module" crossorigin src="/assets/main-DYWwmI_W.js"></script>
|
|
575
575
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
576
576
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
577
577
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -605,10 +605,10 @@
|
|
|
605
605
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-D4d-rgcR.js">
|
|
606
606
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-DK4KmfFn.js">
|
|
607
607
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DMY1k1af.js">
|
|
608
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
609
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
610
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
611
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
608
|
+
<link rel="modulepreload" crossorigin href="/assets/types-Bm8kDgSv.js">
|
|
609
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-B5NImlKh.js">
|
|
610
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-DqDXViVx.js">
|
|
611
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-uhjQn4kK.js">
|
|
612
612
|
<link rel="stylesheet" crossorigin href="/assets/src-HgtAe3Q4.css">
|
|
613
613
|
</head>
|
|
614
614
|
<body class="h-full bg-background text-foreground">
|
package/dist/mini-chat.html
CHANGED
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
.dark #initial-loading img { filter: invert(1); }
|
|
78
78
|
</style>
|
|
79
79
|
|
|
80
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
80
|
+
<script type="module" crossorigin src="/assets/miniChat-BlkcLQBr.js"></script>
|
|
81
81
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
82
82
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
83
83
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
|
@@ -111,10 +111,10 @@
|
|
|
111
111
|
<link rel="modulepreload" crossorigin href="/assets/gitApiHttp-D4d-rgcR.js">
|
|
112
112
|
<link rel="modulepreload" crossorigin href="/assets/terminalApi-DK4KmfFn.js">
|
|
113
113
|
<link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DMY1k1af.js">
|
|
114
|
-
<link rel="modulepreload" crossorigin href="/assets/types-
|
|
115
|
-
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-
|
|
116
|
-
<link rel="modulepreload" crossorigin href="/assets/native-config-
|
|
117
|
-
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-
|
|
114
|
+
<link rel="modulepreload" crossorigin href="/assets/types-Bm8kDgSv.js">
|
|
115
|
+
<link rel="modulepreload" crossorigin href="/assets/capgoAdapter-B5NImlKh.js">
|
|
116
|
+
<link rel="modulepreload" crossorigin href="/assets/native-config-DqDXViVx.js">
|
|
117
|
+
<link rel="modulepreload" crossorigin href="/assets/runtimeConfig-uhjQn4kK.js">
|
|
118
118
|
<link rel="stylesheet" crossorigin href="/assets/src-HgtAe3Q4.css">
|
|
119
119
|
</head>
|
|
120
120
|
<body class="h-full bg-background text-foreground">
|
package/dist/mobile.html
CHANGED
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
66
|
<style>.dark #mobile-startup-logo img { filter: invert(1); }</style>
|
|
67
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
67
|
+
<script type="module" crossorigin src="/assets/mobile-I3Xe5NtO.js"></script>
|
|
68
68
|
<link rel="modulepreload" crossorigin href="/assets/modulepreload-polyfill-P2Xu9kJm.js">
|
|
69
69
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
70
70
|
<link rel="modulepreload" crossorigin href="/assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js">
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@ export function formatAssistantBuiltinSkillsPrompt(tools) {
|
|
|
10
10
|
skills.push('- opencode: For OpenCode itself: configuration, agents, skills, tools, permissions, MCP, providers, plugins, CLI, SDK/API and troubleshooting. Load load_tools({"domain":"opencode.catalog"}), then read_opencode_skill({"id":"opencode"}); continue with nextOffset when partial. Use the current connected catalog, not a copied skill body or a virtual built-in file path.');
|
|
11
11
|
}
|
|
12
12
|
if (names.has('read')) {
|
|
13
|
-
skills.push(`- yuri-customization: For Yuri appearance, themes/CSS/layout, logos/Dock, GUI plugins, pages/tabs, widgets, file previews/exports, panels and settings, or SSH/config-sync/Relay capability boundaries. Load with read({"path":${JSON.stringify(customizationSkillPath)}}), then read only the matching references relative to ${JSON.stringify(path.dirname(customizationSkillPath))}. This contact has no bound local desktop helper for SSH, configuration sync or Relay pairing; those operations are unavailable here. Reading the skill does not create that authorization.`);
|
|
13
|
+
skills.push(`- yuri-customization: For adding a directory as a project in Yuri, appearance, themes/CSS/layout, logos/Dock, GUI plugins, pages/tabs, widgets, file previews/exports, panels and settings, or SSH/config-sync/Relay capability boundaries. Load with read({"path":${JSON.stringify(customizationSkillPath)}}), then read only the matching references relative to ${JSON.stringify(path.dirname(customizationSkillPath))}. Project registration uses granted yuri.projects tools, not a session-bound helper. This contact has no bound local desktop helper for SSH, configuration sync or Relay pairing; those operations are unavailable here. Reading the skill does not create that authorization.`);
|
|
14
14
|
}
|
|
15
15
|
return skills.length > 0 ? [
|
|
16
16
|
'Built-in skills (progressive instructions): load the matching skill before following its workflow. Reading instructions does not mount tools or grant permissions; use the actual contact tools, or assign substantive implementation to a worker with the relevant context.',
|
|
@@ -11,6 +11,8 @@ describe('assistant built-in skill pointers', () => {
|
|
|
11
11
|
expect(prompt).toContain('load_tools({"domain":"opencode.catalog"})');
|
|
12
12
|
expect(prompt).toContain('read_opencode_skill({"id":"opencode"})');
|
|
13
13
|
expect(prompt).toContain('nextOffset');
|
|
14
|
+
expect(prompt).toContain('adding a directory as a project in Yuri');
|
|
15
|
+
expect(prompt).toContain('granted yuri.projects tools');
|
|
14
16
|
expect(prompt).toContain('no bound local desktop helper');
|
|
15
17
|
expect(prompt).toContain('does not create that authorization');
|
|
16
18
|
expect(prompt).not.toContain('.opencode/skills');
|
|
@@ -13,12 +13,33 @@ run on the Host, so the pointer names the package-local resource directly rather
|
|
|
13
13
|
than staging a Session instruction. It advertises no bound desktop helper and
|
|
14
14
|
grants no SSH/config-sync/Relay capability. Read-only background reviews omit it.
|
|
15
15
|
|
|
16
|
-
References are organized by capability: window APIs, appearance, UI surfaces, plugin styles, global pages, work-status widgets, icons,
|
|
16
|
+
References are organized by capability: project registration, window APIs, appearance, UI surfaces, plugin styles, global pages, work-status widgets, icons,
|
|
17
17
|
file parsing/previews, preview actions/exports, and package workflow. Host contracts
|
|
18
18
|
and verification criteria are separate from illustrative templates and case
|
|
19
19
|
studies. Runmark and Eficy remain integration references; their service protocols,
|
|
20
20
|
renderers and compatibility choices are not requirements for unrelated plugins.
|
|
21
21
|
|
|
22
|
+
`references/projects.md` routes project registration through the bound projects
|
|
23
|
+
API helper, before plugin authoring. Shared-service admission supplies its binding
|
|
24
|
+
independently of Electron's remote-connections adapter. `projects-client.mjs` is
|
|
25
|
+
staged as `projects.mjs`; it and the remote helper share the staged
|
|
26
|
+
`session-skill-command.mjs` command formatter. Only bound helpers are staged, and
|
|
27
|
+
each resource combination has its own content fingerprint. Existing sessions keep
|
|
28
|
+
their immutable staged references until a new session is admitted. Contacts use
|
|
29
|
+
their own granted `yuri.projects` tools, not this session binding.
|
|
30
|
+
|
|
31
|
+
`projects.js` owns `POST /api/yuri/session-skills/projects` (`describe`, `list`,
|
|
32
|
+
`add`). The global gate and route require the existing loopback service credential,
|
|
33
|
+
no browser Origin, shared-service ownership and the session's admitted Host origin.
|
|
34
|
+
The bridge reuses `projects/registry.js`, just like the UI directory API and contact
|
|
35
|
+
tools: strict reads, canonical path deduplication, serialized persistence and
|
|
36
|
+
existing project-order SSE notifications remain with their owners. Registration
|
|
37
|
+
preserves an existing active selection and returns only `{project, created}` after
|
|
38
|
+
persistence, never settings/credentials. List errors remain errors. There is no
|
|
39
|
+
cloning, directory creation, conversation creation or desktop window navigation.
|
|
40
|
+
Web/Electron/connected-mobile shared-service sessions operate on their bound Host;
|
|
41
|
+
private/external OpenCode and standalone VS Code have no session helper admission.
|
|
42
|
+
|
|
22
43
|
`references/plugin-styles.md` inventories existing host CSS variables for plugin-owned
|
|
23
44
|
Solid/DOM content, including colors, typography, geometry, controls and optional
|
|
24
45
|
theme config. The workflow routes every plugin view through this reference. Visual
|
|
@@ -111,6 +132,9 @@ sessions across backend upgrades.
|
|
|
111
132
|
|
|
112
133
|
## Validation
|
|
113
134
|
|
|
135
|
+
`projects.test.js` exercises project bridge validation, authentication, binding,
|
|
136
|
+
persisted idempotent registration and failure receipts. Shared-service admission
|
|
137
|
+
tests execute the exact staged project helper through the real global auth gate.
|
|
114
138
|
`session-skill.test.js` exercises staging, complete resource availability, short
|
|
115
139
|
per-session pointers, managed admission/rollback/adopted sessions and external
|
|
116
140
|
ownership. Shared-service admission is covered by
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { sessionSkillCommand } from './session-skill-command.mjs';
|
|
5
|
+
|
|
6
|
+
async function main() {
|
|
7
|
+
let bound = false;
|
|
8
|
+
try {
|
|
9
|
+
const [encoded, operation] = process.argv.slice(2);
|
|
10
|
+
const binding = JSON.parse(Buffer.from(encoded, 'base64url').toString());
|
|
11
|
+
if (!['describe', 'list', 'add'].includes(operation)) throw new Error();
|
|
12
|
+
const origin = new URL(binding.hostOrigin);
|
|
13
|
+
if (origin.protocol !== 'http:' || !['127.0.0.1', '[::1]'].includes(origin.hostname) || origin.username || origin.password) throw new Error();
|
|
14
|
+
const registration = JSON.parse(await readFile(binding.registrationFile, 'utf8'));
|
|
15
|
+
if (new URL(registration.url).origin !== binding.upstreamOrigin || typeof registration.password !== 'string' || !registration.password) throw new Error();
|
|
16
|
+
bound = true;
|
|
17
|
+
let input = {};
|
|
18
|
+
if (operation === 'add') {
|
|
19
|
+
let text = '';
|
|
20
|
+
for await (const chunk of process.stdin) {
|
|
21
|
+
text += chunk;
|
|
22
|
+
if (Buffer.byteLength(text) > 16 * 1024) throw new Error();
|
|
23
|
+
}
|
|
24
|
+
input = JSON.parse(text);
|
|
25
|
+
}
|
|
26
|
+
const response = await fetch(new URL('/api/yuri/session-skills/projects', origin), {
|
|
27
|
+
method: 'POST', redirect: 'error', signal: AbortSignal.timeout(30_000),
|
|
28
|
+
headers: { 'content-type': 'application/json', authorization: `Basic ${Buffer.from(`opencode:${registration.password}`).toString('base64')}` },
|
|
29
|
+
body: JSON.stringify({ sessionID: binding.sessionID, operation, input }),
|
|
30
|
+
});
|
|
31
|
+
const result = await response.json();
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
const terminal = [401, 403, 501].includes(response.status);
|
|
34
|
+
console.error(JSON.stringify({ error: 'Project API operation failed', status: response.status, terminal,
|
|
35
|
+
...(['invalid_input', 'validation_error', 'project_unavailable', 'project_operation_failed'].includes(result?.code) ? { code: result.code } : {}),
|
|
36
|
+
recovery: terminal ? 'Stop this workflow; resume only with a new supported session and its bound project describe command.'
|
|
37
|
+
: 'Result not confirmed. Check the path; use list or retry add with the same path after recovery. Never claim success from a failed request.',
|
|
38
|
+
}));
|
|
39
|
+
process.exitCode = 1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (operation === 'add' && (typeof result.project?.id !== 'string' || typeof result.project?.path !== 'string' || typeof result.created !== 'boolean')) throw new Error();
|
|
43
|
+
if (operation === 'list' && !Array.isArray(result.projects)) throw new Error();
|
|
44
|
+
if (operation === 'describe' && result.supported !== true) throw new Error();
|
|
45
|
+
console.log(JSON.stringify(operation === 'describe' ? { ...result,
|
|
46
|
+
commands: Object.fromEntries(['list', 'add'].map((op) => [op, sessionSkillCommand(process.execPath, process.argv[1], encoded, op)])),
|
|
47
|
+
} : result));
|
|
48
|
+
} catch {
|
|
49
|
+
console.error(JSON.stringify({ error: 'Bound project helper failed; the result is unconfirmed', terminal: !bound,
|
|
50
|
+
recovery: !bound ? 'Stop this workflow; resume only with a new supported session and its bound project describe command.'
|
|
51
|
+
: 'Check the input or connection. Resume with the bound describe command; retry add with the same path only after recovery.' }));
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let directEntry = false;
|
|
57
|
+
try { directEntry = Boolean(process.argv[1] && pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url); }
|
|
58
|
+
catch { /* Imports and Electron flags need not name a script. */ }
|
|
59
|
+
if (directEntry) await main();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { authorizeScheduledTaskSkillRequest } from '../scheduled-tasks/session-skill-contract.js';
|
|
3
|
+
|
|
4
|
+
export const PROJECTS_SKILL_PATH = '/api/yuri/session-skills/projects';
|
|
5
|
+
|
|
6
|
+
const projectResult = ({ id, path, label }) => ({ id, path, ...(label ? { label } : {}) });
|
|
7
|
+
const validInput = (operation, input) => {
|
|
8
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return false;
|
|
9
|
+
const allowed = operation === 'add' ? ['path', 'label'] : [];
|
|
10
|
+
if (Object.keys(input).some((key) => !allowed.includes(key))) return false;
|
|
11
|
+
if (Object.entries(input).some(([key, value]) => typeof value !== 'string' || !value.trim()
|
|
12
|
+
|| value.length > (key === 'label' ? 80 : 4096) || /[\x00-\x1f]/.test(value))) return false;
|
|
13
|
+
return operation !== 'add' || (typeof input.path === 'string' && path.isAbsolute(input.path.trim()));
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Session-bound Host registration; the shared project registry owns persistence. */
|
|
17
|
+
export function registerProjectsSkill(app, { express, getIsSharedOpenCodeService, getOpenCodeAuthHeaders, createClient, registerProject, readSettingsFromDiskStrict, sanitizeProjects }) {
|
|
18
|
+
app.post(PROJECTS_SKILL_PATH, express.json({ limit: '16kb' }), async (req, res) => {
|
|
19
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
20
|
+
if (!getIsSharedOpenCodeService() || !authorizeScheduledTaskSkillRequest(req, getOpenCodeAuthHeaders())) return res.status(403).json({ error: 'Forbidden' });
|
|
21
|
+
const { sessionID, operation, input = {} } = req.body ?? {};
|
|
22
|
+
if (typeof sessionID !== 'string' || !sessionID || sessionID.length > 256
|
|
23
|
+
|| !['describe', 'list', 'add'].includes(operation) || !validInput(operation, input)) return res.status(400).json({ code: 'invalid_input', error: 'Invalid project input' });
|
|
24
|
+
try {
|
|
25
|
+
const session = await createClient().session.get({ sessionID });
|
|
26
|
+
const hostOrigin = `http://${req.socket.localAddress === '::1' ? '[::1]' : '127.0.0.1'}:${req.socket.localPort}`;
|
|
27
|
+
if (session.metadata?.yuri?.scheduledTaskSkill?.hostOrigin !== hostOrigin) return res.status(403).json({ error: 'Session is not bound to this Host' });
|
|
28
|
+
if (operation === 'describe') return res.json({ supported: true, inputs: { add: '{path: existing absolute Host directory, label?: display name}', list: '{}' },
|
|
29
|
+
completion: 'add returns the persisted project and created=true/false. Registration does not clone/create files, open a session or change an existing active selection. Retry the same path safely after an interrupted response.' });
|
|
30
|
+
if (operation === 'list') {
|
|
31
|
+
const settings = await readSettingsFromDiskStrict();
|
|
32
|
+
if (!settings || typeof settings !== 'object' || Array.isArray(settings)
|
|
33
|
+
|| (settings.projects !== undefined && !Array.isArray(settings.projects))) throw new Error('Invalid project settings');
|
|
34
|
+
return res.json({ projects: (sanitizeProjects(settings.projects) || []).map(projectResult) });
|
|
35
|
+
}
|
|
36
|
+
const { project, created } = await registerProject(input);
|
|
37
|
+
return res.json({ project: projectResult(project), created });
|
|
38
|
+
} catch (error) {
|
|
39
|
+
const code = ['validation_error', 'project_unavailable'].includes(error?.code) ? error.code : 'project_operation_failed';
|
|
40
|
+
return res.status(code === 'validation_error' ? 400 : 503).json({ code, error: 'Project operation was not confirmed; check the path or retry the same path after recovery' });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
7
|
+
import { createProjectRegistry } from '../projects/registry.js';
|
|
8
|
+
import { createProjectIdFromPath } from '../projects/project-id.js';
|
|
9
|
+
import { createSettingsRuntime } from '../opencode/settings-runtime.js';
|
|
10
|
+
import { createSettingsNormalizationRuntime } from '../opencode/settings-normalization-runtime.js';
|
|
11
|
+
import { createProjectDirectoryRuntime } from '../opencode/project-directory-runtime.js';
|
|
12
|
+
import { registerProjectsSkill, PROJECTS_SKILL_PATH } from './projects.js';
|
|
13
|
+
|
|
14
|
+
describe('session project registration API', () => {
|
|
15
|
+
let root, workspace, settingsPath, runtime, server, origin, getSession, binding, registerProject, shared, failWrites, tips;
|
|
16
|
+
const auth = { Authorization: `Basic ${Buffer.from('opencode:fixture').toString('base64')}` };
|
|
17
|
+
beforeEach(async () => {
|
|
18
|
+
root = await fs.mkdtemp(path.join(os.tmpdir(), 'project-skill-'));
|
|
19
|
+
workspace = path.join(root, '项目 & # 100%');
|
|
20
|
+
await fs.mkdir(workspace);
|
|
21
|
+
settingsPath = path.join(root, 'settings.json');
|
|
22
|
+
const normalization = createSettingsNormalizationRuntime({ os, path, processLike: process });
|
|
23
|
+
tips = vi.fn(); failWrites = false; shared = true;
|
|
24
|
+
runtime = createSettingsRuntime({ fsPromises: { ...fs, rename: (...args) => failWrites ? Promise.reject(new Error('private-write-error')) : fs.rename(...args) },
|
|
25
|
+
path, crypto, SETTINGS_FILE_PATH: settingsPath, ...normalization,
|
|
26
|
+
sanitizeSettingsUpdate: (patch) => patch, mergePersistedSettings: (current, patch) => ({ ...current, ...patch }),
|
|
27
|
+
formatSettingsResponse: (value) => value, resolveDirectoryCandidate: (value) => value, onProjectOrderChanged: tips,
|
|
28
|
+
});
|
|
29
|
+
const { validateDirectoryPath } = createProjectDirectoryRuntime({ fsPromises: fs, path, normalizeDirectoryPath: normalization.normalizeDirectoryPath });
|
|
30
|
+
const registry = createProjectRegistry({ persistSettings: runtime.persistSettings, validateDirectoryPath });
|
|
31
|
+
registerProject = vi.fn((input) => registry.register(input));
|
|
32
|
+
getSession = vi.fn(async () => ({ metadata: { yuri: { scheduledTaskSkill: { hostOrigin: binding } } } }));
|
|
33
|
+
const app = express();
|
|
34
|
+
registerProjectsSkill(app, { express, getIsSharedOpenCodeService: () => shared, getOpenCodeAuthHeaders: () => auth,
|
|
35
|
+
createClient: () => ({ session: { get: getSession } }), registerProject, readSettingsFromDiskStrict: runtime.readSettingsFromDiskStrict,
|
|
36
|
+
sanitizeProjects: normalization.sanitizeProjects,
|
|
37
|
+
});
|
|
38
|
+
server = await new Promise((resolve) => { const s = app.listen(0, '127.0.0.1', () => resolve(s)); });
|
|
39
|
+
origin = `http://127.0.0.1:${server.address().port}`; binding = origin;
|
|
40
|
+
});
|
|
41
|
+
afterEach(async () => { await new Promise((resolve) => server.close(resolve)); await fs.rm(root, { recursive: true, force: true }); });
|
|
42
|
+
const request = (operation, input = {}, headers = auth) => fetch(`${origin}${PROJECTS_SKILL_PATH}`, { method: 'POST',
|
|
43
|
+
headers: { 'content-type': 'application/json', ...headers }, body: JSON.stringify({ sessionID: 'ses_one', operation, input }) });
|
|
44
|
+
|
|
45
|
+
it('confirms persisted registration, deduplicates canonical paths and preserves existing selection/settings', async () => {
|
|
46
|
+
const oldPath = path.join(root, 'offline');
|
|
47
|
+
const oldId = createProjectIdFromPath(oldPath);
|
|
48
|
+
await fs.writeFile(settingsPath, JSON.stringify({ secret: 'private-settings', projects: [{ id: oldId, path: oldPath, label: 'Old' }], activeProjectId: oldId }));
|
|
49
|
+
const response = await request('add', { path: workspace, label: 'App' });
|
|
50
|
+
expect(response.status).toBe(200);
|
|
51
|
+
expect(response.headers.get('cache-control')).toBe('no-store');
|
|
52
|
+
const added = await response.json();
|
|
53
|
+
expect(added).toEqual({ created: true, project: { id: expect.any(String), path: await fs.realpath(workspace), label: 'App' } });
|
|
54
|
+
const alias = path.join(root, 'alias'); await fs.symlink(workspace, alias);
|
|
55
|
+
expect(await (await request('add', { path: alias, label: 'Do not rename' })).json()).toEqual({ ...added, created: false });
|
|
56
|
+
const persisted = await runtime.readSettingsFromDiskStrict();
|
|
57
|
+
expect(persisted.projects).toHaveLength(2);
|
|
58
|
+
expect(persisted.activeProjectId).toBe(oldId);
|
|
59
|
+
expect(persisted.secret).toBe('private-settings');
|
|
60
|
+
expect(tips).toHaveBeenCalledTimes(1);
|
|
61
|
+
const listed = await (await request('list')).json();
|
|
62
|
+
expect(listed.projects).toContainEqual(added.project);
|
|
63
|
+
expect(JSON.stringify({ added, listed })).not.toContain('private-settings');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('rejects invalid input and nonexistent/file paths without changing saved state', async () => {
|
|
67
|
+
await fs.writeFile(settingsPath, JSON.stringify({ projects: [], secret: 'saved' }));
|
|
68
|
+
const before = await fs.readFile(settingsPath, 'utf8');
|
|
69
|
+
for (const input of [{}, [], null, { path: 'relative' }, { path: workspace, activate: true }, { path: workspace, label: '' },
|
|
70
|
+
{ path: workspace, label: 'x'.repeat(81) }, { path: workspace + '\u0000' }, { path: path.join(root, 'missing') }, { path: settingsPath }]) {
|
|
71
|
+
expect((await request('add', input)).status).toBe(400);
|
|
72
|
+
}
|
|
73
|
+
expect((await request('remove', { path: workspace })).status).toBe(400);
|
|
74
|
+
expect((await request('list', { path: workspace })).status).toBe(400);
|
|
75
|
+
expect(await fs.readFile(settingsPath, 'utf8')).toBe(before);
|
|
76
|
+
expect(tips).not.toHaveBeenCalled();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('requires service authentication, shared ownership and the admitted Host before registration', async () => {
|
|
80
|
+
for (const headers of [{}, { Authorization: 'Bearer browser' }, { ...auth, Origin: origin }]) expect((await request('add', { path: workspace }, headers)).status).toBe(403);
|
|
81
|
+
shared = false;
|
|
82
|
+
expect((await request('describe')).status).toBe(403);
|
|
83
|
+
expect(getSession).not.toHaveBeenCalled();
|
|
84
|
+
shared = true; binding = 'http://127.0.0.1:1';
|
|
85
|
+
for (const operation of ['describe', 'list', 'add']) expect((await request(operation, operation === 'add' ? { path: workspace } : {})).status).toBe(403);
|
|
86
|
+
expect(registerProject).not.toHaveBeenCalled();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('never reports corrupt reads or failed persistence as successful empty or added results', async () => {
|
|
90
|
+
for (const corrupt of ['{broken', '[]', 'null', '{"projects":{}}']) {
|
|
91
|
+
await fs.writeFile(settingsPath, corrupt);
|
|
92
|
+
expect((await request('list')).status).toBe(503);
|
|
93
|
+
expect(await fs.readFile(settingsPath, 'utf8')).toBe(corrupt);
|
|
94
|
+
}
|
|
95
|
+
await fs.writeFile(settingsPath, '{"projects":[]}');
|
|
96
|
+
failWrites = true;
|
|
97
|
+
const response = await request('add', { path: workspace });
|
|
98
|
+
expect(response.status).toBe(503);
|
|
99
|
+
expect(await response.text()).not.toContain('private-write-error');
|
|
100
|
+
expect(await fs.readFile(settingsPath, 'utf8')).toBe('{"projects":[]}');
|
|
101
|
+
expect(tips).not.toHaveBeenCalled();
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { realpathSync } from 'node:fs';
|
|
3
3
|
import { pathToFileURL } from 'node:url';
|
|
4
|
+
import { sessionSkillCommand } from './session-skill-command.mjs';
|
|
4
5
|
|
|
5
|
-
export const remoteConnectionsCommand =
|
|
6
|
-
const args = [executable, script, encoded, operation];
|
|
7
|
-
const quote = (value) => `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
8
|
-
if (process.platform !== 'win32') return `ELECTRON_RUN_AS_NODE=1 ${args.map(quote).join(' ')}`;
|
|
9
|
-
const psQuote = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
10
|
-
const ps = `$env:ELECTRON_RUN_AS_NODE='1'; & ${args.map(psQuote).join(' ')}`;
|
|
11
|
-
return `powershell.exe -NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${Buffer.from(ps, 'utf16le').toString('base64')}`;
|
|
12
|
-
};
|
|
6
|
+
export const remoteConnectionsCommand = sessionSkillCommand;
|
|
13
7
|
|
|
14
8
|
async function main() {
|
|
15
9
|
try {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const sessionSkillCommand = (executable, script, encoded, operation) => {
|
|
2
|
+
const args = [executable, script, encoded, operation];
|
|
3
|
+
const quote = (value) => `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
4
|
+
if (process.platform !== 'win32') return `ELECTRON_RUN_AS_NODE=1 ${args.map(quote).join(' ')}`;
|
|
5
|
+
const psQuote = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
6
|
+
const ps = `$env:ELECTRON_RUN_AS_NODE='1'; & ${args.map(psQuote).join(' ')}`;
|
|
7
|
+
return `powershell.exe -NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${Buffer.from(ps, 'utf16le').toString('base64')}`;
|
|
8
|
+
};
|
|
@@ -2,16 +2,20 @@ import { readFile, mkdir, writeFile, rename, rm } from 'node:fs/promises';
|
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { remoteConnectionsCommand } from './remote-connections-client.mjs';
|
|
5
|
+
import { sessionSkillCommand } from './session-skill-command.mjs';
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const scripts = { 'remote-connections.mjs': './remote-connections-client.mjs', 'projects.mjs': './projects-client.mjs', 'session-skill-command.mjs': './session-skill-command.mjs' };
|
|
8
|
+
const files = ['SKILL.md', 'references/projects.md', 'references/appearance.md', 'references/ui-surfaces.md', 'references/plugin-styles.md', 'references/gui-api.md', 'references/workflow.md', 'references/global-pages.md', 'references/work-status.md', 'references/icons.md', 'references/file-previews.md', 'references/preview-exports.md', 'references/remote-connections.md', ...Object.keys(scripts)];
|
|
7
9
|
|
|
8
10
|
/** Stage immutable, shipped instructions; never edit the user's global skills/config. */
|
|
9
11
|
export function createCustomizationSkillInstaller({ yuriDataDir }) {
|
|
10
12
|
const resources = new Map();
|
|
11
|
-
const prepare = (withRemote) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
13
|
+
const prepare = (withRemote, withProjects) => {
|
|
14
|
+
const key = `${withRemote}:${withProjects}`;
|
|
15
|
+
if (!resources.has(key)) resources.set(key, (async () => {
|
|
16
|
+
const stagedFiles = files.filter((name) => (name !== 'remote-connections.mjs' || withRemote)
|
|
17
|
+
&& (name !== 'projects.mjs' || withProjects) && (name !== 'session-skill-command.mjs' || withRemote || withProjects));
|
|
18
|
+
const contents = await Promise.all(stagedFiles.map((name) => readFile(new URL(scripts[name] ?? `./skill/${name}`, import.meta.url), 'utf8')));
|
|
15
19
|
const hash = createHash('sha256').update(contents.join('\0')).digest('hex').slice(0, 16);
|
|
16
20
|
const directory = path.join(yuriDataDir, 'session-skills', `yuri-customization-${hash}`);
|
|
17
21
|
await mkdir(path.join(directory, 'references'), { recursive: true, mode: 0o700 });
|
|
@@ -22,14 +26,15 @@ export function createCustomizationSkillInstaller({ yuriDataDir }) {
|
|
|
22
26
|
finally { await rm(temporary, { force: true }); }
|
|
23
27
|
}));
|
|
24
28
|
return path.join(directory, 'SKILL.md');
|
|
25
|
-
})().catch((error) => { resources.delete(
|
|
26
|
-
return resources.get(
|
|
29
|
+
})().catch((error) => { resources.delete(key); throw error; }));
|
|
30
|
+
return resources.get(key);
|
|
27
31
|
};
|
|
28
|
-
return async (client, sessionID, remoteBinding) => {
|
|
29
|
-
const file = await prepare(Boolean(remoteBinding));
|
|
32
|
+
return async (client, sessionID, { remoteBinding, projectBinding } = {}) => {
|
|
33
|
+
const file = await prepare(Boolean(remoteBinding), Boolean(projectBinding));
|
|
34
|
+
const projects = projectBinding ? ` For project registration, read references/projects.md and run the bound project API helper.\nBound project helper: ${sessionSkillCommand(process.execPath, path.join(path.dirname(file), 'projects.mjs'), Buffer.from(JSON.stringify({ ...projectBinding, sessionID })).toString('base64url'), 'describe')}\n` : ' No bound project helper is provided; project registration is unavailable through this session skill.';
|
|
30
35
|
const remote = remoteBinding ? ` For SSH setup/config sync or Relay pairing, use only this bound helper after reading references/remote-connections.md. Bound local desktop helper: ${remoteConnectionsCommand(process.execPath, path.join(path.dirname(file), 'remote-connections.mjs'), Buffer.from(JSON.stringify({ ...remoteBinding, sessionID })).toString('base64url'), 'describe')}` : ' No bound SSH/Relay command is provided: these operations are unavailable in this session. Report that limit and stop this branch; use native Settings or a new supported local desktop session. A script or another capability\'s binding does not enable it. There is no credential/filesystem fallback for this capability.';
|
|
31
36
|
await client.session.instructions.entry.put({ sessionID, key: 'yuri.customization',
|
|
32
|
-
value: `Yuri customization: for SSH connections, configuration sync, Relay pairing, appearance (themes, CSS/layout, Logo, macOS Dock), work-status widgets, global pages/tabs, custom file parsing/previews, preview exports, or GUI panels/commands/settings, read ${JSON.stringify(file)} first. Use the matching reference and apply changes only when requested.${remote}`,
|
|
37
|
+
value: `Yuri customization: for adding a directory as a project in Yuri, SSH connections, configuration sync, Relay pairing, appearance (themes, CSS/layout, Logo, macOS Dock), work-status widgets, global pages/tabs, custom file parsing/previews, preview exports, or GUI panels/commands/settings, read ${JSON.stringify(file)} first. Use the matching reference and apply changes only when requested.${projects}${remote}`,
|
|
33
38
|
});
|
|
34
39
|
};
|
|
35
40
|
}
|