cogpit 3.5.5 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-runtime.js +209 -129
- package/dist/instance-worker.js +120 -27
- package/dist/web/assets/{AgentCheckDialog-DdcPaEtO.js → AgentCheckDialog-DeSKJqG3.js} +1 -1
- package/dist/web/assets/{AutomationsPanel-DHA6W_CZ.js → AutomationsPanel-BWjD657g.js} +1 -1
- package/dist/web/assets/{CogpitBlock-CN0s_qTc.js → CogpitBlock-DEl4Kxl9.js} +1 -1
- package/dist/web/assets/CogpitView-BYDVcso1.js +85 -0
- package/dist/web/assets/{CommandPaletteHost-D5mRzqIm.js → CommandPaletteHost-BWee2Tov.js} +1 -1
- package/dist/web/assets/{ConfigBrowser-CXxrxWWl.js → ConfigBrowser-CQOlu4Gg.js} +1 -1
- package/dist/web/assets/{CrewPanel-DJM6YaDN.js → CrewPanel-Dzyxoj46.js} +1 -1
- package/dist/web/assets/{HighlightedEditor-G-YJnadM.js → HighlightedEditor-B-bjFcyU.js} +1 -1
- package/dist/web/assets/{KeyboardShortcutsDialog-CcyskXfr.js → KeyboardShortcutsDialog-9k4clgVv.js} +1 -1
- package/dist/web/assets/{MissionHome-o1MjTkAZ.js → MissionHome-CIwnHTXt.js} +1 -1
- package/dist/web/assets/{MobileFileChanges-SeyE4VAV.js → MobileFileChanges-B8RaPAmX.js} +1 -1
- package/dist/web/assets/OrbitControls-CcXenNM0.js +1861 -0
- package/dist/web/assets/{PluginsDialog-BPHFbLGS.js → PluginsDialog-CYiiMArh.js} +1 -1
- package/dist/web/assets/{PreviewPanel-Cb6P4TQ0.js → PreviewPanel-CZazqeGT.js} +1 -1
- package/dist/web/assets/{ProjectFilesPanel-BIEcyM9w.js → ProjectFilesPanel-oFw09UPd.js} +1 -1
- package/dist/web/assets/{ProjectSwitcherModal-CXI-isj1.js → ProjectSwitcherModal-Bq7zI10J.js} +1 -1
- package/dist/web/assets/{TerminalOutput-Cmf1kDEH.js → TerminalOutput-BDmdqvpJ.js} +1 -1
- package/dist/web/assets/{ThemeSelectorModal-DKvI2x91.js → ThemeSelectorModal-Crb0YaTK.js} +1 -1
- package/dist/web/assets/{WorkflowsPanel-B7bJ_vvB.js → WorkflowsPanel-HqdzMBXP.js} +1 -1
- package/dist/web/assets/{WorktreePanel-Bu2NThZy.js → WorktreePanel-DHW4Agwj.js} +1 -1
- package/dist/web/assets/auto-render.min-BCDUXXLr.js +1 -0
- package/dist/web/assets/d3.min-DhuWnDrq.js +1 -0
- package/dist/web/assets/{edition-ui-CpK32xJF.js → edition-ui-Cm-dw9e0.js} +1 -1
- package/dist/web/assets/index-BtF9zrz_.css +1 -0
- package/dist/web/assets/{index-lC5dVkKa.js → index-C3zvtMTl.js} +1 -1
- package/dist/web/assets/{index-DUyjpORE.js → index-DGG5ZuyK.js} +1 -1
- package/dist/web/assets/{index-TyUw7tBu.js → index-DUeulx0e.js} +1 -1
- package/dist/web/assets/{index-N7rDyHyl.js → index-Dn2vHUyS.js} +2 -2
- package/dist/web/assets/index-Dv2TZ38C.js +521 -0
- package/dist/web/assets/katex.min-C_ZjXvJu.js +1 -0
- package/dist/web/assets/{switch-DFZA-ROd.js → switch-mgfHveYR.js} +1 -1
- package/dist/web/assets/three.core.min-D_80lYGt.js +1 -0
- package/dist/web/assets/three.module.min-CXftPEfC.js +1 -0
- package/dist/web/assets/{vendor-ui-B0az9ATE.js → vendor-ui-ClPj6-Gu.js} +212 -202
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/dist/web/assets/index-BYVl1VlW.js +0 -515
- package/dist/web/assets/index-RGkLLDnk.css +0 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import{c as H,r as d,j as n}from"./vendor-react-gGw_S5I_.js";import{bH as I,x as X,B as M,d6 as K,o as Q,n as Z,D as ee,dc as te,c as W}from"./index-Dv2TZ38C.js";import{dB as re,dC as ne,bL as oe,bs as se,aW as ie}from"./vendor-ui-ClPj6-Gu.js";import"./vendor-markdown-BEJ8yVzA.js";const ae="/api/views/shell/v1",le=/cogpit:lib\/([a-z0-9-]+)/g,ce=/["'](?:three|three\/addons\/controls\/OrbitControls\.js)["']/,de={three:"cogpit:lib/three","three/core":"cogpit:lib/three-core","three/addons/controls/OrbitControls.js":"cogpit:lib/three-orbit-controls"};function ue(r){const e=new Set;for(const[,t]of r.matchAll(le))(t==="d3"||t==="katex"||t==="three")&&e.add(t);return(e.has("three")||ce.test(r))&&(e.add("three"),e.add("three-core"),e.add("three-orbit-controls")),e}function pe(r){var t,o;return((o=(t=r.match(/<title[^>]*>([^<]{1,200})<\/title>/i))==null?void 0:t[1])==null?void 0:o.replace(/\s+/g," ").trim())||null}const me=`*,*::before,*::after{box-sizing:border-box}
|
|
2
|
+
html{background:var(--card);color:var(--card-foreground,var(--foreground));font:13.5px/1.55 var(--font-sans,system-ui,sans-serif);-webkit-font-smoothing:antialiased}
|
|
3
|
+
body{margin:0;padding:16px}
|
|
4
|
+
h1,h2,h3,h4{margin:0 0 .5em;line-height:1.25;font-weight:600}
|
|
5
|
+
h1{font-size:1.3em}h2{font-size:1.15em}h3{font-size:1.02em}
|
|
6
|
+
p{margin:0 0 .75em}
|
|
7
|
+
a{color:var(--primary)}
|
|
8
|
+
code,kbd,pre{font-family:var(--font-mono,ui-monospace,monospace);font-size:.92em}
|
|
9
|
+
pre{margin:0 0 .75em;padding:10px 12px;overflow:auto;border-radius:calc(var(--radius,10px) - 2px);background:var(--muted)}
|
|
10
|
+
button{font:inherit;cursor:pointer;padding:5px 12px;border-radius:calc(var(--radius,10px) - 2px);border:1px solid var(--border);background:var(--secondary);color:var(--secondary-foreground)}
|
|
11
|
+
button:hover{background:var(--accent);color:var(--accent-foreground)}
|
|
12
|
+
button.primary{background:var(--primary);color:var(--primary-foreground);border-color:transparent}
|
|
13
|
+
button:disabled{opacity:.5;cursor:default}
|
|
14
|
+
input,select,textarea{font:inherit;color:inherit;background:var(--background);border:1px solid var(--input,var(--border));border-radius:calc(var(--radius,10px) - 2px);padding:4px 8px}
|
|
15
|
+
input[type=range],input[type=checkbox],input[type=radio]{accent-color:var(--primary)}
|
|
16
|
+
input[type=range]{padding:0;border:0;background:none}
|
|
17
|
+
label{display:inline-flex;align-items:center;gap:6px}
|
|
18
|
+
table{border-collapse:collapse;width:100%}
|
|
19
|
+
th,td{padding:6px 8px;border-bottom:1px solid var(--border);text-align:left}
|
|
20
|
+
th{font-weight:600;color:var(--muted-foreground)}
|
|
21
|
+
.muted{color:var(--muted-foreground)}
|
|
22
|
+
math{font-size:1.1em}`,fe=String.raw`(initialTheme) => {
|
|
23
|
+
const host = window.parent
|
|
24
|
+
const root = document.documentElement
|
|
25
|
+
const post = (message) => host.postMessage({ cogpitView: 1, ...message }, "*")
|
|
26
|
+
const report = (error) => post({ type: "error", message: String(error?.message ?? error ?? "Unknown error") })
|
|
27
|
+
addEventListener("error", (event) => report(event.error ?? event.message))
|
|
28
|
+
addEventListener("unhandledrejection", (event) => report(event.reason))
|
|
29
|
+
let theme = initialTheme
|
|
30
|
+
let applied = []
|
|
31
|
+
const themeListeners = new Set()
|
|
32
|
+
const applyTheme = (next) => {
|
|
33
|
+
theme = next
|
|
34
|
+
root.classList.toggle("dark", next.mode === "dark")
|
|
35
|
+
root.style.colorScheme = next.mode
|
|
36
|
+
for (const name of applied) root.style.removeProperty(name)
|
|
37
|
+
applied = Object.keys(next.tokens)
|
|
38
|
+
for (const [name, value] of Object.entries(next.tokens)) root.style.setProperty(name, value)
|
|
39
|
+
for (const listener of themeListeners) {
|
|
40
|
+
try { listener(next) } catch (error) { report(error) }
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
addEventListener("message", (event) => {
|
|
44
|
+
if (event.source === host && event.data?.type === "cogpit-view:theme" && event.data.theme) applyTheme(event.data.theme)
|
|
45
|
+
})
|
|
46
|
+
let lastHeight = -1
|
|
47
|
+
new ResizeObserver(() => {
|
|
48
|
+
const height = Math.ceil(root.getBoundingClientRect().height)
|
|
49
|
+
if (height !== lastHeight) post({ type: "resize", height: (lastHeight = height) })
|
|
50
|
+
}).observe(root)
|
|
51
|
+
document.addEventListener("click", (event) => {
|
|
52
|
+
const link = event.target instanceof Element ? event.target.closest("a[href]") : null
|
|
53
|
+
if (!link || (link.getAttribute("href") ?? "").startsWith("#")) return
|
|
54
|
+
event.preventDefault()
|
|
55
|
+
post({ type: "open", href: link.href })
|
|
56
|
+
}, true)
|
|
57
|
+
const probe = document.createElement("canvas").getContext("2d", { willReadFrequently: true })
|
|
58
|
+
const color = (name) => {
|
|
59
|
+
const value = getComputedStyle(root).getPropertyValue(name.startsWith("--") ? name : "--" + name).trim()
|
|
60
|
+
if (!value || !probe) return value
|
|
61
|
+
probe.clearRect(0, 0, 1, 1)
|
|
62
|
+
probe.fillStyle = value
|
|
63
|
+
probe.fillRect(0, 0, 1, 1)
|
|
64
|
+
const [r, g, b, a] = probe.getImageData(0, 0, 1, 1).data
|
|
65
|
+
return a === 255 ? "#" + [r, g, b].map((part) => part.toString(16).padStart(2, "0")).join("") : "rgba(" + r + ", " + g + ", " + b + ", " + (a / 255).toFixed(3) + ")"
|
|
66
|
+
}
|
|
67
|
+
window.cogpit = Object.freeze({
|
|
68
|
+
get theme() { return theme },
|
|
69
|
+
color,
|
|
70
|
+
onTheme(listener) { themeListeners.add(listener); return () => themeListeners.delete(listener) },
|
|
71
|
+
ask(text) { post({ type: "ask", text: String(text) }) },
|
|
72
|
+
})
|
|
73
|
+
applyTheme(initialTheme)
|
|
74
|
+
}`;function F(r){return JSON.stringify(r).replace(/</g,"\\u003c")}function he(r,e,t){const o=t.has("three")?`<script type="importmap">${F({imports:de})}<\/script>`:"";return`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>${me}</style>${o}<script>(${fe})(${F(e)})<\/script></head><body>${r}</body></html>`}const ge=4e3;function xe(r){if(typeof r!="object"||r===null)return null;const e=r;if(e.cogpitView!==1)return null;switch(e.type){case"ready":return{type:"ready"};case"resize":return typeof e.height=="number"&&Number.isFinite(e.height)&&e.height>=0?{type:"resize",height:e.height}:null;case"error":return typeof e.message=="string"?{type:"error",message:e.message.slice(0,600)||"Unknown error"}:null;case"open":{if(typeof e.href!="string")return null;try{const t=new URL(e.href);return(t.protocol==="https:"||t.protocol==="http:")&&!t.username&&!t.password?{type:"open",href:t.href}:null}catch{return null}}case"ask":{const t=typeof e.text=="string"?e.text.trim().slice(0,ge):"";return t?{type:"ask",text:t}:null}default:return null}}const ve=`;(() => {
|
|
75
|
+
const { render, renderToString } = katex
|
|
76
|
+
const mathml = (options) => ({ output: "mathml", ...options })
|
|
77
|
+
katex.render = (tex, element, options) => render(tex, element, mathml(options))
|
|
78
|
+
katex.renderToString = (tex, options) => renderToString(tex, mathml(options))
|
|
79
|
+
})();`,be={d3:async()=>(await I(async()=>{const{default:r}=await import("./d3.min-DhuWnDrq.js");return{default:r}},[])).default,katex:async()=>{const[r,e]=await Promise.all([I(()=>import("./katex.min-C_ZjXvJu.js"),[]),I(()=>import("./auto-render.min-BCDUXXLr.js"),[])]);return[r.default,ve,e.default].join(`
|
|
80
|
+
;
|
|
81
|
+
`)},three:async()=>(await I(async()=>{const{default:r}=await import("./three.module.min-CXftPEfC.js");return{default:r}},[])).default.replaceAll('"./three.core.min.js"','"three/core"'),"three-core":async()=>(await I(async()=>{const{default:r}=await import("./three.core.min-D_80lYGt.js");return{default:r}},[])).default,"three-orbit-controls":async()=>(await I(async()=>{const{default:r}=await import("./OrbitControls-CcXenNM0.js");return{default:r}},[])).default};function ye(r){return Promise.all([...r].map(async e=>({name:e,code:await be[e]()})))}const J=280,we=48,_e=1600,Ee=15e3;function q(r){const e=K();if(!e)return;const{draft:t,token:o}=e.snapshot(),c=t.text.trimEnd();e.replace({...t,text:c?`${c}
|
|
82
|
+
|
|
83
|
+
${r}`:r},o),e.focus()}function ke(r){const e=H.c(4),[t,o]=d.useState(Se);let c,l;return e[0]!==r||e[1]!==t?(c=()=>{if(t||!r.current)return;const s=new IntersectionObserver(a=>{a.some(je)&&o(!0)},{rootMargin:"600px"});return s.observe(r.current),()=>s.disconnect()},l=[r,t],e[0]=r,e[1]=t,e[2]=c,e[3]=l):(c=e[2],l=e[3]),d.useEffect(c,l),t}function je(r){return r.isIntersecting}function Se(){return typeof IntersectionObserver>"u"}function Ae(r){const e=H.c(43),{source:t,complete:o,fallback:c}=r;let l;e[0]!==t?(l=pe(t)??"Interactive view",e[0]=t,e[1]=l):l=e[1];const s=l,[a,u]=d.useState(!1),[_,N]=d.useState(!1),[j,O]=d.useState(null),[p,A]=d.useState(0),R=d.useRef(null),S=ke(R);let E;e[2]!==o||e[3]!==c||e[4]!==p||e[5]!==S||e[6]!==a||e[7]!==t||e[8]!==s?(E=a?n.jsx("div",{className:"[&>div]:my-0 [&>div]:rounded-none [&>div]:border-0",children:c}):o?S?n.jsx(G,{html:t,title:s,onError:O},p):n.jsx("div",{style:{height:J}}):n.jsx("p",{className:"flex h-24 items-center justify-center text-xs text-muted-foreground",children:"The view appears when the reply finishes writing it."}),e[2]=o,e[3]=c,e[4]=p,e[5]=S,e[6]=a,e[7]=t,e[8]=s,e[9]=E):E=e[9];const T=E;let k;e[10]===Symbol.for("react.memo_cache_sentinel")?(k=n.jsx(re,{className:"size-3.5 shrink-0 text-muted-foreground","aria-hidden":"true"}),e[10]=k):k=e[10];let v;e[11]!==s?(v=n.jsx("h4",{className:"ml-1 min-w-0 flex-1 truncate text-[13px] font-medium",children:s}),e[11]=s,e[12]=v):v=e[12];let m;e[13]!==o||e[14]!==t?(m=!o&&n.jsxs("span",{className:"mr-1 flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx(X,{className:"size-3"})," Building · ",t.split(`
|
|
84
|
+
`).length," lines"]}),e[13]=o,e[14]=t,e[15]=m):m=e[15];const b=a?"Show the view":"Show source";let L,g;e[16]===Symbol.for("react.memo_cache_sentinel")?(L=()=>u(Le),g=n.jsx(ne,{"data-icon":"icon"}),e[16]=L,e[17]=g):(L=e[16],g=e[17]);let y;e[18]!==a||e[19]!==b?(y=n.jsx(M,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-pressed":a,"aria-label":"Show source",title:b,onClick:L,children:g}),e[18]=a,e[19]=b,e[20]=y):y=e[20];let f;e[21]!==o?(f=o&&n.jsxs(n.Fragment,{children:[n.jsx(M,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":"Reload view",title:"Reload",onClick:()=>{O(null),u(!1),A(Te)},children:n.jsx(oe,{"data-icon":"icon"})}),n.jsx(M,{type:"button",variant:"ghost",size:"icon-xs",className:"text-muted-foreground","aria-label":"Expand view",title:"Expand",onClick:()=>N(!0),children:n.jsx(se,{"data-icon":"icon"})})]}),e[21]=o,e[22]=f):f=e[22];let h;e[23]!==f||e[24]!==v||e[25]!==m||e[26]!==y?(h=n.jsxs("header",{className:"flex items-center gap-1 border-b border-border/70 py-1 pr-1.5 pl-3",children:[k,v,m,y,f]}),e[23]=f,e[24]=v,e[25]=m,e[26]=y,e[27]=h):h=e[27];let x;e[28]!==j||e[29]!==a||e[30]!==s?(x=j&&!a&&n.jsxs("div",{role:"alert",className:"flex items-center gap-2 border-t border-border/70 py-1 pr-1.5 pl-3 text-xs text-destructive",children:[n.jsx(ie,{className:"size-3.5 shrink-0","aria-hidden":"true"}),n.jsx("span",{className:"min-w-0 flex-1 truncate",title:j,children:j}),K()&&n.jsx(M,{type:"button",variant:"ghost",size:"xs",onClick:()=>q(`The interactive view "${s}" shows this error: ${j}
|
|
85
|
+
Please fix it.`),children:"Ask to fix"})]}),e[28]=j,e[29]=a,e[30]=s,e[31]=x):x=e[31];let i;e[32]!==o||e[33]!==_||e[34]!==t||e[35]!==s?(i=o&&n.jsx(Q,{open:_,onOpenChange:N,children:n.jsxs(Z,{className:"flex h-[88vh] w-[min(1280px,96vw)] max-w-none flex-col gap-3 p-4 sm:max-w-none",children:[n.jsx(ee,{className:"pr-8 text-sm",children:s}),n.jsx("div",{className:"min-h-0 flex-1 overflow-hidden rounded-lg border border-border",children:_&&n.jsx(G,{html:t,title:s,fill:!0,onError:O})})]})}),e[32]=o,e[33]=_,e[34]=t,e[35]=s,e[36]=i):i=e[36];let w;return e[37]!==T||e[38]!==h||e[39]!==x||e[40]!==i||e[41]!==s?(w=n.jsxs("section",{ref:R,"aria-label":s,"data-cogpit-block":!0,className:"my-3 overflow-hidden rounded-lg border border-border bg-card text-sm",children:[h,T,x,i]}),e[37]=T,e[38]=h,e[39]=x,e[40]=i,e[41]=s,e[42]=w):w=e[42],w}function Te(r){return r+1}function Le(r){return!r}function G(r){const e=H.c(30),{html:t,title:o,fill:c,onError:l}=r,s=c===void 0?!1:c,a=d.useRef(null),{theme:u}=te();let _;e[0]!==l||e[1]!==u?(_={theme:u,onError:l},e[0]=l,e[1]=u,e[2]=_):_=e[2];const N=d.useRef(_),[j,O]=d.useState(J),[p,A]=d.useState("loading");let R;e[3]!==l||e[4]!==u?(R=()=>{N.current={theme:u,onError:l}},e[3]=l,e[4]=u,e[5]=R):R=e[5],d.useLayoutEffect(R);let S,E;e[6]!==t?(S=()=>{let i=!1,w=!1;const V=ue(t),D=ye(V);D.catch(Ne);const $=B=>{var U;const P=(U=a.current)==null?void 0:U.contentWindow;if(!P||B.source!==P)return;const z=xe(B.data);if(z){switch(z.type){case"ready":{w=!0,D.then(C=>{i||(P.postMessage({type:"cogpit-view:render",html:he(t,N.current.theme,V),libraries:C},"*"),A("ready"))},C=>{i||(A("failed"),N.current.onError(C instanceof Error?C.message:String(C)))});return}case"resize":{O(Math.min(_e,Math.max(we,z.height)));return}case"error":{N.current.onError(z.message);return}}document.activeElement===a.current&&(z.type==="open"?window.open(z.href,"_blank","noopener,noreferrer"):q(z.text))}};window.addEventListener("message",$);const Y=window.setTimeout(()=>{!w&&!i&&A("failed")},Ee);return()=>{i=!0,window.removeEventListener("message",$),window.clearTimeout(Y)}},E=[t],e[6]=t,e[7]=S,e[8]=E):(S=e[7],E=e[8]),d.useLayoutEffect(S,E);let T,k;if(e[9]!==p||e[10]!==u?(T=()=>{var i,w;p==="ready"&&((w=(i=a.current)==null?void 0:i.contentWindow)==null||w.postMessage({type:"cogpit-view:theme",theme:u},"*"))},k=[u,p],e[9]=p,e[10]=u,e[11]=T,e[12]=k):(T=e[11],k=e[12]),d.useEffect(T,k),p==="failed"){let i;return e[13]===Symbol.for("react.memo_cache_sentinel")?(i=n.jsx("p",{role:"alert",className:"p-3 text-xs text-destructive",children:"This view could not load. Show its source to read it."}),e[13]=i):i=e[13],i}const v=s&&"h-full";let m;e[14]!==v?(m=W("relative",v),e[14]=v,e[15]=m):m=e[15];let b;e[16]!==p?(b=p==="loading"&&n.jsx("div",{className:"absolute inset-0 grid place-items-center text-muted-foreground",children:n.jsx(X,{className:"size-4"})}),e[16]=p,e[17]=b):b=e[17];const L=p!=="ready"&&"invisible";let g;e[18]!==L?(g=W("block w-full border-0",L),e[18]=L,e[19]=g):g=e[19];const y=s?"100%":j;let f;e[20]!==y?(f={height:y},e[20]=y,e[21]=f):f=e[21];let h;e[22]!==g||e[23]!==f||e[24]!==o?(h=n.jsx("iframe",{ref:a,title:o,src:ae,sandbox:"allow-scripts",referrerPolicy:"no-referrer",className:g,style:f}),e[22]=g,e[23]=f,e[24]=o,e[25]=h):h=e[25];let x;return e[26]!==b||e[27]!==h||e[28]!==m?(x=n.jsxs("div",{className:m,children:[b,h]}),e[26]=b,e[27]=h,e[28]=m,e[29]=x):x=e[29],x}function Ne(){}export{Ae as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as p,j as u,r as U}from"./vendor-react-gGw_S5I_.js";import{bb as w,bc as ae,x as he,bd as ue,be as fe,bf as we,bg as ve,bh as Ce,bi as be,bj as Se,bk as je,bl as Te,bm as ke,bn as ye,bo as Fe,W as Pe,bp as xe,bq as Oe,aH as se,aY as Q,br as Ne,a$ as Re,bs as Ae,bt as Ie,bu as Ee,bv as $e,bw as De,F as Be}from"./index-BYVl1VlW.js";import{bl as We,di as Me,bU as ie,ao as He,cX as Le,cS as _e,bo as Ue,cm as Ge,ba as le,cy as Ke,cJ as qe,aF as ze,c2 as Xe,a9 as Je,dj as Ve,cv as Ye,bQ as Qe,c8 as ce,dk as Ze,dl as pe,cA as et,cY as tt,dm as nt,aJ as ot,a3 as at,aX as re,cp as st,c3 as it,cC as lt,ae as ct,cD as rt,cB as dt}from"./vendor-ui-B0az9ATE.js";import"./vendor-markdown-BEJ8yVzA.js";function o(t,e,a,l,i,r,h){return{id:t,label:e,icon:l,run:i,shortcut:r,description:h,value:`${e} ${a}`}}function X(...t){return t.filter(e=>e!==!1&&e!==void 0)}function Z(t,e,a,l,i){const r=o(t,e,a,l,i);return{...r,value:`Help ${r.value}`}}function mt(t){const e=p.c(94);let a;e[0]!==t.canFocusComposer||e[1]!==t.extraActions||e[2]!==t.onDuplicateSession||e[3]!==t.onFindInConversation||e[4]!==t.onFocusComposer||e[5]!==t.onGoHome||e[6]!==t.onNewSession||e[7]!==t.onToggleMissionControl||e[8]!==t.showMission?(a=X(o("home","Go to Mission Control","home overview dashboard",_e,t.onGoHome),o("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",Le,t.onToggleMissionControl,w("missionControl")),...(t.extraActions??[]).map(ut),o("new-session","Start a new session","project agent chat create",We,t.onNewSession,w("newSession")),t.onDuplicateSession&&o("duplicate-session","Duplicate this session","copy fork clone branch thread",Me,t.onDuplicateSession),t.canFocusComposer&&o("focus-composer","Focus message composer","chat prompt input",ie,t.onFocusComposer,w("focusComposer")),t.onFindInConversation&&o("find-in-conversation","Find in conversation","search text transcript turns matches",He,t.onFindInConversation,w("findInConversation"))),e[0]=t.canFocusComposer,e[1]=t.extraActions,e[2]=t.onDuplicateSession,e[3]=t.onFindInConversation,e[4]=t.onFocusComposer,e[5]=t.onGoHome,e[6]=t.onNewSession,e[7]=t.onToggleMissionControl,e[8]=t.showMission,e[9]=a):a=e[9];const l=a;let i;e[10]!==t?(i=(t.projects??[]).slice(0,8).map(n=>o(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,Ue,()=>{var c;return(c=t.onOpenProject)==null?void 0:c.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),e[10]=t,e[11]=i):i=e[11];const r=i;let h;e[12]!==t?(h=(t.recentSessions??[]).slice(0,10).map(n=>{const N=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,P=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return o(`session-${n.dirName}-${n.fileName}`,N,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,ie,()=>{var $;return($=t.onOpenSession)==null?void 0:$.call(t,n.dirName,n.fileName)},void 0,P)}),e[12]=t,e[13]=h):h=e[13];const f=h;let g;if(e[14]!==t){const n=t.devices??[];g=n.length>1&&t.onSwitchDevice?n.slice(0,ae.length).map((c,N)=>o(`device-${c.id}`,c.isActive?`${c.name} (current)`:`Switch to ${c.name}`,`device machine host remote ${c.id}`,c.isLocal?Ge:le,()=>{var P;return(P=t.onSwitchDevice)==null?void 0:P.call(t,c.id)},w(ae[N]))):[],e[14]=t,e[15]=g}else g=e[15];const d=g;let m;if(e[16]!==t.canOpenTerminal||e[17]!==t.hasFileChanges||e[18]!==t.hasSession||e[19]!==t.onToggleBrowser||e[20]!==t.onToggleFileChanges||e[21]!==t.onToggleProjectFiles||e[22]!==t.onToggleSidebar||e[23]!==t.onToggleStats||e[24]!==t.onToggleWorktrees||e[25]!==t.showBrowser||e[26]!==t.showFileChanges||e[27]!==t.showProjectFiles||e[28]!==t.showSidebar||e[29]!==t.showStats||e[30]!==t.showWorktrees||e[31]!==t.supportsWorktrees){let n;e[33]!==t.hasSession||e[34]!==t.onToggleStats||e[35]!==t.showStats?(n=t.hasSession&&o("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",Ke,t.onToggleStats,w("toggleStats")),e[33]=t.hasSession,e[34]=t.onToggleStats,e[35]=t.showStats,e[36]=n):n=e[36];let c;e[37]!==t.onToggleProjectFiles||e[38]!==t.showProjectFiles?(c=t.onToggleProjectFiles&&o("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",qe,t.onToggleProjectFiles,w("projectFiles")),e[37]=t.onToggleProjectFiles,e[38]=t.showProjectFiles,e[39]=c):c=e[39];let N;e[40]!==t.onToggleBrowser||e[41]!==t.showBrowser?(N=t.onToggleBrowser&&o("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",ze,t.onToggleBrowser),e[40]=t.onToggleBrowser,e[41]=t.showBrowser,e[42]=N):N=e[42];let P;e[43]!==t.hasFileChanges||e[44]!==t.onToggleFileChanges||e[45]!==t.showFileChanges?(P=t.hasFileChanges&&o("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",Xe,t.onToggleFileChanges),e[43]=t.hasFileChanges,e[44]=t.onToggleFileChanges,e[45]=t.showFileChanges,e[46]=P):P=e[46];let $;e[47]!==t.canOpenTerminal||e[48]!==t.onToggleWorktrees||e[49]!==t.showWorktrees||e[50]!==t.supportsWorktrees?($=t.supportsWorktrees&&t.canOpenTerminal&&o("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Je,t.onToggleWorktrees),e[47]=t.canOpenTerminal,e[48]=t.onToggleWorktrees,e[49]=t.showWorktrees,e[50]=t.supportsWorktrees,e[51]=$):$=e[51],m=X(o("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Ve,t.onToggleSidebar,w("toggleSidebar")),n,c,N,P,$),e[16]=t.canOpenTerminal,e[17]=t.hasFileChanges,e[18]=t.hasSession,e[19]=t.onToggleBrowser,e[20]=t.onToggleFileChanges,e[21]=t.onToggleProjectFiles,e[22]=t.onToggleSidebar,e[23]=t.onToggleStats,e[24]=t.onToggleWorktrees,e[25]=t.showBrowser,e[26]=t.showFileChanges,e[27]=t.showProjectFiles,e[28]=t.showSidebar,e[29]=t.showStats,e[30]=t.showWorktrees,e[31]=t.supportsWorktrees,e[32]=m}else m=e[32];const C=m;let L;e[52]!==t?(L=X(t.onOpenProjectInEditor&&o("open-project-editor","Open project in editor","code cursor vscode zed workspace",it,t.onOpenProjectInEditor),t.onRevealProject&&o("reveal-project","Reveal project in file manager","finder explorer folder directory",st,t.onRevealProject),t.onCopyResumeCommand&&o("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",re,t.onCopyResumeCommand),t.onCopyProjectPath&&o("copy-project-path","Copy project path","workspace directory clipboard",re,t.onCopyProjectPath),t.onOpenIntegratedTerminal&&o("integrated-terminal","New integrated terminal","embedded shell command line process panel",at,t.onOpenIntegratedTerminal,w("newIntegratedTerminal")),t.canOpenTerminal&&o("terminal","Open in system terminal","external shell command line app",ot,t.onOpenTerminal,w("systemTerminal")),t.onTogglePreview&&o("preview","Toggle development preview","browser localhost dev server website",nt,t.onTogglePreview,w("preview")),t.onOpenConfig&&o("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",tt,t.onOpenConfig),o("settings","Open Cogpit settings","preferences network",et,t.onOpenSettings),t.onCheckAgents&&o("check-agents","Check agent setup","install sign in login doctor environment agents cli",pe,t.onCheckAgents),o("theme","Change theme & chat width","appearance light dark oled width narrow wide",Ze,t.onOpenTheme,w("themeSelector")),o("expand","Expand all groups","conversation details",ce,t.onExpandAll,w("expandAll")),o("expand-payloads","Expand all tool payloads","raw input result diff conversation details",ce,t.onExpandToolPayloads,w("expandToolPayloads")),o("collapse","Collapse all","conversation groups payloads details",Qe,t.onCollapseAll),t.onKillAll&&o("kill-all","Kill all agent processes","stop terminate halt everything runaway",Ye,t.onKillAll),t.onOpenDevices&&o("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",ct,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"manage")}),t.onOpenDevices&&o("add-device","Add device…","remote machine hub host connect pair new",le,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),e[52]=t,e[53]=L):L=e[53];const D=L;let B;e[54]!==t.onOpenKeyboardShortcuts?(B=X(Z("documentation","Documentation","docs guide manual readme getting started learn how to",dt,ht),t.onOpenKeyboardShortcuts&&Z("keyboard-shortcuts","Keyboard shortcuts","keys hotkeys keybindings cheat sheet customize",lt,t.onOpenKeyboardShortcuts),Z("report-issue","Report an issue","bug problem feedback support github",rt,gt)),e[54]=t.onOpenKeyboardShortcuts,e[55]=B):B=e[55];const G=B;let O;e[56]!==l?(O={value:"Navigation",items:l},e[56]=l,e[57]=O):O=e[57];let R;e[58]!==f?(R=f.length>0?[{value:"Recent sessions",items:f}]:[],e[58]=f,e[59]=R):R=e[59];let A;e[60]!==r?(A=r.length>0?[{value:"Projects",items:r}]:[],e[60]=r,e[61]=A):A=e[61];let S;e[62]!==d?(S=d.length>0?[{value:"Devices",items:d}]:[],e[62]=d,e[63]=S):S=e[63];let j;e[64]!==C?(j={value:"View",items:C},e[64]=C,e[65]=j):j=e[65];let T;e[66]!==D?(T={value:"Tools",items:D},e[66]=D,e[67]=T):T=e[67];let k;e[68]!==G?(k={value:"Help & docs",items:G},e[68]=G,e[69]=k):k=e[69];let W;e[70]!==S||e[71]!==j||e[72]!==T||e[73]!==k||e[74]!==O||e[75]!==R||e[76]!==A?(W=[O,...R,...A,...S,j,T,k],e[70]=S,e[71]=j,e[72]=T,e[73]=k,e[74]=O,e[75]=R,e[76]=A,e[77]=W):W=e[77];const M=W;let s;e[78]!==t?(s=function(c){t.onOpenChange(!1),c.run()},e[78]=t,e[79]=s):s=e[79];const H=s;let b;e[80]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(fe,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[80]=b):b=e[80];let y;e[81]!==t.loadingNavigation?(y=t.loadingNavigation&&u.jsxs("div",{className:"motion-enter flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",role:"status",children:[u.jsx(he,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[81]=t.loadingNavigation,e[82]=y):y=e[82];let I;e[83]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsx(we,{children:"No matching actions."}),e[83]=I):I=e[83];let F;e[84]!==M||e[85]!==H?(F=u.jsxs(ve,{className:"max-h-[min(26rem,60vh)]",children:[I,u.jsx(ft,{groups:M,onRun:H})]}),e[84]=M,e[85]=H,e[86]=F):F=e[86];let v;e[87]!==y||e[88]!==F?(v=u.jsxs(Ce,{label:"Search commands",loop:!0,children:[b,y,F]}),e[87]=y,e[88]=F,e[89]=v):v=e[89];let E;return e[90]!==t.onOpenChange||e[91]!==t.open||e[92]!==v?(E=u.jsx(ue,{open:t.open,onOpenChange:t.onOpenChange,title:"Command palette",description:"Search for a Cogpit action to run.",className:"max-w-xl",children:v}),e[90]=t.onOpenChange,e[91]=t.open,e[92]=v,e[93]=E):E=e[93],E}function gt(){return window.open(be,"_blank","noopener,noreferrer")}function ht(){return window.open(Se,"_blank","noopener,noreferrer")}function ut(t){return o(t.id,t.label,t.keywords,t.icon,t.onSelect)}function ft(t){const e=p.c(8),{groups:a,onRun:l}=t,i=je(Ct);let r;e[0]!==a||e[1]!==i?(r=i?a.map(g=>({group:g,score:Math.max(0,...g.items.map(d=>Te(d.value,i)))})).sort(vt).map(wt):a,e[0]=a,e[1]=i,e[2]=r):r=e[2];const h=r;let f;if(e[3]!==l||e[4]!==h){let g;e[6]!==l?(g=d=>u.jsx(ke,{heading:d.value,children:d.items.map(m=>{const C=m.icon;return u.jsxs(ye,{value:m.value,onSelect:()=>l(m),children:[u.jsx(C,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:m.label}),m.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:m.description})]}),m.shortcut&&u.jsx(Fe,{children:m.shortcut})]},m.id)})},d.value),e[6]=l,e[7]=g):g=e[7],f=h.map(g),e[3]=l,e[4]=h,e[5]=f}else f=e[5];return f}function wt(t){const{group:e}=t;return e}function vt(t,e){return e.score-t.score}function Ct(t){return t.search}async function de(t,e){const a=await Be(t,{signal:e});if(!a.ok)throw new Error(`Request failed (${a.status})`);const l=await a.json();return Array.isArray(l)?l:[]}function kt(t){var ee;const e=p.c(51);let a,l,i,r,h,f;e[0]!==t?({open:i,currentProjectDirName:a,projectCwd:h,onProcessStarted:l,launchTerminalRequest:f,...r}=t,e[0]=t,e[1]=a,e[2]=l,e[3]=i,e[4]=r,e[5]=h,e[6]=f):(a=e[1],l=e[2],i=e[3],r=e[4],h=e[5],f=e[6]);const g=f===void 0?0:f,d=Pe();let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[7]=m):m=e[7];const[C,L]=U.useState(m);let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[8]=D):D=e[8];const[B,G]=U.useState(D),[O,R]=U.useState(!1),A=U.useRef(0),S=xe();let j,T;e[9]!==S||e[10]!==i?(j=()=>{if(!i)return;const x=new AbortController,K=Re();return R(!0),Promise.allSettled([de("/api/projects",x.signal),de(Ae({limit:"12",perProject:"3"},S),x.signal)]).then(ge=>{const[te,ne]=ge;if(x.signal.aborted)return;const oe=ne.status==="fulfilled"?ne.value:[];Ie(oe,K),L(te.status==="fulfilled"?te.value:[]),G(oe),R(!1)}),()=>x.abort()},T=[i,S],e[9]=S,e[10]=i,e[11]=j,e[12]=T):(j=e[11],T=e[12]),U.useEffect(j,T);let k;e[13]!==C?(k=Oe(C),e[13]=C,e[14]=k):k=e[14];const W=k;let M;e:{if(h){M=h;break e}if(!a){M=null;break e}let x;e[15]!==a||e[16]!==C?(x=((ee=C.find(K=>K.dirName===a))==null?void 0:ee.path)??null,e[15]=a,e[16]=C,e[17]=x):x=e[17],M=x}const s=M;let H;e[18]!==l||e[19]!==d||e[20]!==s?(H=()=>{if(!s)return;const x=d.spawnTerminal({cwd:s}),K=s.replace(/\/+$/,"").split("/").at(-1)||"Terminal";l({id:x,name:K,type:"terminal",status:"running",source:s})},e[18]=l,e[19]=d,e[20]=s,e[21]=H):H=e[21];const b=H;let y,I;e[22]!==b||e[23]!==g||e[24]!==d.status||e[25]!==s?(I=()=>{g<=A.current||!s||d.status!=="connected"||(A.current=g,b())},y=[b,g,d.status,s],e[22]=b,e[23]=g,e[24]=d.status,e[25]=s,e[26]=y,e[27]=I):(y=e[26],I=e[27]),U.useEffect(I,y);let F;e[28]!==a||e[29]!==s?(F={path:s,dirName:a},e[28]=a,e[29]=s,e[30]=F):F=e[30];const v=F;let E;e[31]!==v?(E=()=>Ee(v),e[31]=v,e[32]=E):E=e[32];const n=E;let c;e[33]!==v?(c=()=>$e(v),e[33]=v,e[34]=c):c=e[34];const N=c,P=!se()&&Q("hostFiles"),$=Q("hostFiles")&&(!se()||Ne());let q;e[35]!==s?(q=()=>{s&&De(s)},e[35]=s,e[36]=q):q=e[36];const me=q;let _;e[37]!==b||e[38]!==d.status||e[39]!==s?(_=s&&d.status==="connected"&&Q("terminal")?b:void 0,e[37]=b,e[38]=d.status,e[39]=s,e[40]=_):_=e[40];const J=s&&$?n:void 0,V=s&&P?N:void 0,Y=s?me:void 0;let z;return e[41]!==O||e[42]!==i||e[43]!==r||e[44]!==B||e[45]!==W||e[46]!==_||e[47]!==J||e[48]!==V||e[49]!==Y?(z=u.jsx(mt,{...r,open:i,projects:W,recentSessions:B,loadingNavigation:O,onOpenIntegratedTerminal:_,onOpenProjectInEditor:J,onRevealProject:V,onCopyProjectPath:Y}),e[41]=O,e[42]=i,e[43]=r,e[44]=B,e[45]=W,e[46]=_,e[47]=J,e[48]=V,e[49]=Y,e[50]=z):z=e[50],z}export{kt as CommandPaletteHost};
|
|
1
|
+
import{c as p,j as u,r as U}from"./vendor-react-gGw_S5I_.js";import{bb as w,bc as ae,x as he,bd as ue,be as fe,bf as we,bg as ve,bh as Ce,bi as be,bj as Se,bk as je,bl as Te,bm as ke,bn as ye,bo as Fe,W as Pe,bp as xe,bq as Oe,aH as se,aY as Q,br as Ne,a$ as Re,bs as Ae,bt as Ie,bu as Ee,bv as $e,bw as De,F as Be}from"./index-Dv2TZ38C.js";import{bl as We,di as Me,bU as ie,ao as He,cX as Le,cS as _e,bo as Ue,cm as Ge,ba as le,cy as Ke,cJ as qe,aF as ze,c2 as Xe,a9 as Je,dj as Ve,cv as Ye,bQ as Qe,c8 as ce,dk as Ze,dl as pe,cA as et,cY as tt,dm as nt,aJ as ot,a3 as at,aX as re,cp as st,c3 as it,cC as lt,ae as ct,cD as rt,cB as dt}from"./vendor-ui-ClPj6-Gu.js";import"./vendor-markdown-BEJ8yVzA.js";function o(t,e,a,l,i,r,h){return{id:t,label:e,icon:l,run:i,shortcut:r,description:h,value:`${e} ${a}`}}function X(...t){return t.filter(e=>e!==!1&&e!==void 0)}function Z(t,e,a,l,i){const r=o(t,e,a,l,i);return{...r,value:`Help ${r.value}`}}function mt(t){const e=p.c(94);let a;e[0]!==t.canFocusComposer||e[1]!==t.extraActions||e[2]!==t.onDuplicateSession||e[3]!==t.onFindInConversation||e[4]!==t.onFocusComposer||e[5]!==t.onGoHome||e[6]!==t.onNewSession||e[7]!==t.onToggleMissionControl||e[8]!==t.showMission?(a=X(o("home","Go to Mission Control","home overview dashboard",_e,t.onGoHome),o("mission-control",t.showMission?"Exit Mission Control":"Open Mission Control","live sessions blocked waiting answer everything at once",Le,t.onToggleMissionControl,w("missionControl")),...(t.extraActions??[]).map(ut),o("new-session","Start a new session","project agent chat create",We,t.onNewSession,w("newSession")),t.onDuplicateSession&&o("duplicate-session","Duplicate this session","copy fork clone branch thread",Me,t.onDuplicateSession),t.canFocusComposer&&o("focus-composer","Focus message composer","chat prompt input",ie,t.onFocusComposer,w("focusComposer")),t.onFindInConversation&&o("find-in-conversation","Find in conversation","search text transcript turns matches",He,t.onFindInConversation,w("findInConversation"))),e[0]=t.canFocusComposer,e[1]=t.extraActions,e[2]=t.onDuplicateSession,e[3]=t.onFindInConversation,e[4]=t.onFocusComposer,e[5]=t.onGoHome,e[6]=t.onNewSession,e[7]=t.onToggleMissionControl,e[8]=t.showMission,e[9]=a):a=e[9];const l=a;let i;e[10]!==t?(i=(t.projects??[]).slice(0,8).map(n=>o(`project-${n.dirName}`,n.shortName,`${n.path} ${n.dirName} project workspace`,Ue,()=>{var c;return(c=t.onOpenProject)==null?void 0:c.call(t,n.dirName)},void 0,`${n.path} · ${n.sessionCount} session${n.sessionCount===1?"":"s"}`)),e[10]=t,e[11]=i):i=e[11];const r=i;let h;e[12]!==t?(h=(t.recentSessions??[]).slice(0,10).map(n=>{const N=(n.aiTitle||n.name||n.slug||n.lastUserMessage||n.firstUserMessage||n.sessionId).replace(/\s+/g," ").trim().slice(0,160)||n.sessionId,P=[n.projectShortName,n.gitBranch].filter(Boolean).join(" · ");return o(`session-${n.dirName}-${n.fileName}`,N,`${n.projectShortName} ${n.cwd??""} ${n.gitBranch??""} ${n.sessionId} recent thread conversation`,ie,()=>{var $;return($=t.onOpenSession)==null?void 0:$.call(t,n.dirName,n.fileName)},void 0,P)}),e[12]=t,e[13]=h):h=e[13];const f=h;let g;if(e[14]!==t){const n=t.devices??[];g=n.length>1&&t.onSwitchDevice?n.slice(0,ae.length).map((c,N)=>o(`device-${c.id}`,c.isActive?`${c.name} (current)`:`Switch to ${c.name}`,`device machine host remote ${c.id}`,c.isLocal?Ge:le,()=>{var P;return(P=t.onSwitchDevice)==null?void 0:P.call(t,c.id)},w(ae[N]))):[],e[14]=t,e[15]=g}else g=e[15];const d=g;let m;if(e[16]!==t.canOpenTerminal||e[17]!==t.hasFileChanges||e[18]!==t.hasSession||e[19]!==t.onToggleBrowser||e[20]!==t.onToggleFileChanges||e[21]!==t.onToggleProjectFiles||e[22]!==t.onToggleSidebar||e[23]!==t.onToggleStats||e[24]!==t.onToggleWorktrees||e[25]!==t.showBrowser||e[26]!==t.showFileChanges||e[27]!==t.showProjectFiles||e[28]!==t.showSidebar||e[29]!==t.showStats||e[30]!==t.showWorktrees||e[31]!==t.supportsWorktrees){let n;e[33]!==t.hasSession||e[34]!==t.onToggleStats||e[35]!==t.showStats?(n=t.hasSession&&o("toggle-stats",t.showStats?"Hide session details":"Show session details","stats tokens usage panel",Ke,t.onToggleStats,w("toggleStats")),e[33]=t.hasSession,e[34]=t.onToggleStats,e[35]=t.showStats,e[36]=n):n=e[36];let c;e[37]!==t.onToggleProjectFiles||e[38]!==t.showProjectFiles?(c=t.onToggleProjectFiles&&o("project-files",t.showProjectFiles?"Close project files":"Open project files","browse edit save workspace source code",qe,t.onToggleProjectFiles,w("projectFiles")),e[37]=t.onToggleProjectFiles,e[38]=t.showProjectFiles,e[39]=c):c=e[39];let N;e[40]!==t.onToggleBrowser||e[41]!==t.showBrowser?(N=t.onToggleBrowser&&o("toggle-browser",t.showBrowser?"Hide browser":"Show browser","web page live view browse panel",ze,t.onToggleBrowser),e[40]=t.onToggleBrowser,e[41]=t.showBrowser,e[42]=N):N=e[42];let P;e[43]!==t.hasFileChanges||e[44]!==t.onToggleFileChanges||e[45]!==t.showFileChanges?(P=t.hasFileChanges&&o("toggle-file-changes",t.showFileChanges?"Hide file changes":"Show file changes","diff edits review panel",Xe,t.onToggleFileChanges),e[43]=t.hasFileChanges,e[44]=t.onToggleFileChanges,e[45]=t.showFileChanges,e[46]=P):P=e[46];let $;e[47]!==t.canOpenTerminal||e[48]!==t.onToggleWorktrees||e[49]!==t.showWorktrees||e[50]!==t.supportsWorktrees?($=t.supportsWorktrees&&t.canOpenTerminal&&o("toggle-worktrees",t.showWorktrees?"Hide worktrees":"Show worktrees","git branches panel",Je,t.onToggleWorktrees),e[47]=t.canOpenTerminal,e[48]=t.onToggleWorktrees,e[49]=t.showWorktrees,e[50]=t.supportsWorktrees,e[51]=$):$=e[51],m=X(o("toggle-sidebar",t.showSidebar?"Hide session sidebar":"Show session sidebar","projects navigation panel",Ve,t.onToggleSidebar,w("toggleSidebar")),n,c,N,P,$),e[16]=t.canOpenTerminal,e[17]=t.hasFileChanges,e[18]=t.hasSession,e[19]=t.onToggleBrowser,e[20]=t.onToggleFileChanges,e[21]=t.onToggleProjectFiles,e[22]=t.onToggleSidebar,e[23]=t.onToggleStats,e[24]=t.onToggleWorktrees,e[25]=t.showBrowser,e[26]=t.showFileChanges,e[27]=t.showProjectFiles,e[28]=t.showSidebar,e[29]=t.showStats,e[30]=t.showWorktrees,e[31]=t.supportsWorktrees,e[32]=m}else m=e[32];const C=m;let L;e[52]!==t?(L=X(t.onOpenProjectInEditor&&o("open-project-editor","Open project in editor","code cursor vscode zed workspace",it,t.onOpenProjectInEditor),t.onRevealProject&&o("reveal-project","Reveal project in file manager","finder explorer folder directory",st,t.onRevealProject),t.onCopyResumeCommand&&o("copy-resume-command","Copy resume command","cli claude codex copilot terminal clipboard continue session",re,t.onCopyResumeCommand),t.onCopyProjectPath&&o("copy-project-path","Copy project path","workspace directory clipboard",re,t.onCopyProjectPath),t.onOpenIntegratedTerminal&&o("integrated-terminal","New integrated terminal","embedded shell command line process panel",at,t.onOpenIntegratedTerminal,w("newIntegratedTerminal")),t.canOpenTerminal&&o("terminal","Open in system terminal","external shell command line app",ot,t.onOpenTerminal,w("systemTerminal")),t.onTogglePreview&&o("preview","Toggle development preview","browser localhost dev server website",nt,t.onTogglePreview,w("preview")),t.onOpenConfig&&o("config",t.showConfig?"Close agent configuration":"Open agent configuration","skills commands claude settings files",tt,t.onOpenConfig),o("settings","Open Cogpit settings","preferences network",et,t.onOpenSettings),t.onCheckAgents&&o("check-agents","Check agent setup","install sign in login doctor environment agents cli",pe,t.onCheckAgents),o("theme","Change theme & chat width","appearance light dark oled width narrow wide",Ze,t.onOpenTheme,w("themeSelector")),o("expand","Expand all groups","conversation details",ce,t.onExpandAll,w("expandAll")),o("expand-payloads","Expand all tool payloads","raw input result diff conversation details",ce,t.onExpandToolPayloads,w("expandToolPayloads")),o("collapse","Collapse all","conversation groups payloads details",Qe,t.onCollapseAll),t.onKillAll&&o("kill-all","Kill all agent processes","stop terminate halt everything runaway",Ye,t.onKillAll),t.onOpenDevices&&o("manage-devices","Manage devices…","remote machines hub hosts edit rename remove switch",ct,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"manage")}),t.onOpenDevices&&o("add-device","Add device…","remote machine hub host connect pair new",le,()=>{var n;return(n=t.onOpenDevices)==null?void 0:n.call(t,"add")})),e[52]=t,e[53]=L):L=e[53];const D=L;let B;e[54]!==t.onOpenKeyboardShortcuts?(B=X(Z("documentation","Documentation","docs guide manual readme getting started learn how to",dt,ht),t.onOpenKeyboardShortcuts&&Z("keyboard-shortcuts","Keyboard shortcuts","keys hotkeys keybindings cheat sheet customize",lt,t.onOpenKeyboardShortcuts),Z("report-issue","Report an issue","bug problem feedback support github",rt,gt)),e[54]=t.onOpenKeyboardShortcuts,e[55]=B):B=e[55];const G=B;let O;e[56]!==l?(O={value:"Navigation",items:l},e[56]=l,e[57]=O):O=e[57];let R;e[58]!==f?(R=f.length>0?[{value:"Recent sessions",items:f}]:[],e[58]=f,e[59]=R):R=e[59];let A;e[60]!==r?(A=r.length>0?[{value:"Projects",items:r}]:[],e[60]=r,e[61]=A):A=e[61];let S;e[62]!==d?(S=d.length>0?[{value:"Devices",items:d}]:[],e[62]=d,e[63]=S):S=e[63];let j;e[64]!==C?(j={value:"View",items:C},e[64]=C,e[65]=j):j=e[65];let T;e[66]!==D?(T={value:"Tools",items:D},e[66]=D,e[67]=T):T=e[67];let k;e[68]!==G?(k={value:"Help & docs",items:G},e[68]=G,e[69]=k):k=e[69];let W;e[70]!==S||e[71]!==j||e[72]!==T||e[73]!==k||e[74]!==O||e[75]!==R||e[76]!==A?(W=[O,...R,...A,...S,j,T,k],e[70]=S,e[71]=j,e[72]=T,e[73]=k,e[74]=O,e[75]=R,e[76]=A,e[77]=W):W=e[77];const M=W;let s;e[78]!==t?(s=function(c){t.onOpenChange(!1),c.run()},e[78]=t,e[79]=s):s=e[79];const H=s;let b;e[80]===Symbol.for("react.memo_cache_sentinel")?(b=u.jsx(fe,{"aria-label":"Search commands",autoFocus:!0,placeholder:"Search commands..."}),e[80]=b):b=e[80];let y;e[81]!==t.loadingNavigation?(y=t.loadingNavigation&&u.jsxs("div",{className:"motion-enter flex items-center gap-2 px-3 py-2 text-xs text-muted-foreground",role:"status",children:[u.jsx(he,{className:"size-3.5"}),"Loading projects and sessions..."]}),e[81]=t.loadingNavigation,e[82]=y):y=e[82];let I;e[83]===Symbol.for("react.memo_cache_sentinel")?(I=u.jsx(we,{children:"No matching actions."}),e[83]=I):I=e[83];let F;e[84]!==M||e[85]!==H?(F=u.jsxs(ve,{className:"max-h-[min(26rem,60vh)]",children:[I,u.jsx(ft,{groups:M,onRun:H})]}),e[84]=M,e[85]=H,e[86]=F):F=e[86];let v;e[87]!==y||e[88]!==F?(v=u.jsxs(Ce,{label:"Search commands",loop:!0,children:[b,y,F]}),e[87]=y,e[88]=F,e[89]=v):v=e[89];let E;return e[90]!==t.onOpenChange||e[91]!==t.open||e[92]!==v?(E=u.jsx(ue,{open:t.open,onOpenChange:t.onOpenChange,title:"Command palette",description:"Search for a Cogpit action to run.",className:"max-w-xl",children:v}),e[90]=t.onOpenChange,e[91]=t.open,e[92]=v,e[93]=E):E=e[93],E}function gt(){return window.open(be,"_blank","noopener,noreferrer")}function ht(){return window.open(Se,"_blank","noopener,noreferrer")}function ut(t){return o(t.id,t.label,t.keywords,t.icon,t.onSelect)}function ft(t){const e=p.c(8),{groups:a,onRun:l}=t,i=je(Ct);let r;e[0]!==a||e[1]!==i?(r=i?a.map(g=>({group:g,score:Math.max(0,...g.items.map(d=>Te(d.value,i)))})).sort(vt).map(wt):a,e[0]=a,e[1]=i,e[2]=r):r=e[2];const h=r;let f;if(e[3]!==l||e[4]!==h){let g;e[6]!==l?(g=d=>u.jsx(ke,{heading:d.value,children:d.items.map(m=>{const C=m.icon;return u.jsxs(ye,{value:m.value,onSelect:()=>l(m),children:[u.jsx(C,{"aria-hidden":"true"}),u.jsxs("span",{className:"min-w-0 flex-1",children:[u.jsx("span",{className:"block truncate",children:m.label}),m.description&&u.jsx("span",{className:"block truncate text-xs text-muted-foreground",children:m.description})]}),m.shortcut&&u.jsx(Fe,{children:m.shortcut})]},m.id)})},d.value),e[6]=l,e[7]=g):g=e[7],f=h.map(g),e[3]=l,e[4]=h,e[5]=f}else f=e[5];return f}function wt(t){const{group:e}=t;return e}function vt(t,e){return e.score-t.score}function Ct(t){return t.search}async function de(t,e){const a=await Be(t,{signal:e});if(!a.ok)throw new Error(`Request failed (${a.status})`);const l=await a.json();return Array.isArray(l)?l:[]}function kt(t){var ee;const e=p.c(51);let a,l,i,r,h,f;e[0]!==t?({open:i,currentProjectDirName:a,projectCwd:h,onProcessStarted:l,launchTerminalRequest:f,...r}=t,e[0]=t,e[1]=a,e[2]=l,e[3]=i,e[4]=r,e[5]=h,e[6]=f):(a=e[1],l=e[2],i=e[3],r=e[4],h=e[5],f=e[6]);const g=f===void 0?0:f,d=Pe();let m;e[7]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[7]=m):m=e[7];const[C,L]=U.useState(m);let D;e[8]===Symbol.for("react.memo_cache_sentinel")?(D=[],e[8]=D):D=e[8];const[B,G]=U.useState(D),[O,R]=U.useState(!1),A=U.useRef(0),S=xe();let j,T;e[9]!==S||e[10]!==i?(j=()=>{if(!i)return;const x=new AbortController,K=Re();return R(!0),Promise.allSettled([de("/api/projects",x.signal),de(Ae({limit:"12",perProject:"3"},S),x.signal)]).then(ge=>{const[te,ne]=ge;if(x.signal.aborted)return;const oe=ne.status==="fulfilled"?ne.value:[];Ie(oe,K),L(te.status==="fulfilled"?te.value:[]),G(oe),R(!1)}),()=>x.abort()},T=[i,S],e[9]=S,e[10]=i,e[11]=j,e[12]=T):(j=e[11],T=e[12]),U.useEffect(j,T);let k;e[13]!==C?(k=Oe(C),e[13]=C,e[14]=k):k=e[14];const W=k;let M;e:{if(h){M=h;break e}if(!a){M=null;break e}let x;e[15]!==a||e[16]!==C?(x=((ee=C.find(K=>K.dirName===a))==null?void 0:ee.path)??null,e[15]=a,e[16]=C,e[17]=x):x=e[17],M=x}const s=M;let H;e[18]!==l||e[19]!==d||e[20]!==s?(H=()=>{if(!s)return;const x=d.spawnTerminal({cwd:s}),K=s.replace(/\/+$/,"").split("/").at(-1)||"Terminal";l({id:x,name:K,type:"terminal",status:"running",source:s})},e[18]=l,e[19]=d,e[20]=s,e[21]=H):H=e[21];const b=H;let y,I;e[22]!==b||e[23]!==g||e[24]!==d.status||e[25]!==s?(I=()=>{g<=A.current||!s||d.status!=="connected"||(A.current=g,b())},y=[b,g,d.status,s],e[22]=b,e[23]=g,e[24]=d.status,e[25]=s,e[26]=y,e[27]=I):(y=e[26],I=e[27]),U.useEffect(I,y);let F;e[28]!==a||e[29]!==s?(F={path:s,dirName:a},e[28]=a,e[29]=s,e[30]=F):F=e[30];const v=F;let E;e[31]!==v?(E=()=>Ee(v),e[31]=v,e[32]=E):E=e[32];const n=E;let c;e[33]!==v?(c=()=>$e(v),e[33]=v,e[34]=c):c=e[34];const N=c,P=!se()&&Q("hostFiles"),$=Q("hostFiles")&&(!se()||Ne());let q;e[35]!==s?(q=()=>{s&&De(s)},e[35]=s,e[36]=q):q=e[36];const me=q;let _;e[37]!==b||e[38]!==d.status||e[39]!==s?(_=s&&d.status==="connected"&&Q("terminal")?b:void 0,e[37]=b,e[38]=d.status,e[39]=s,e[40]=_):_=e[40];const J=s&&$?n:void 0,V=s&&P?N:void 0,Y=s?me:void 0;let z;return e[41]!==O||e[42]!==i||e[43]!==r||e[44]!==B||e[45]!==W||e[46]!==_||e[47]!==J||e[48]!==V||e[49]!==Y?(z=u.jsx(mt,{...r,open:i,projects:W,recentSessions:B,loadingNavigation:O,onOpenIntegratedTerminal:_,onOpenProjectInEditor:J,onRevealProject:V,onCopyProjectPath:Y}),e[41]=O,e[42]=i,e[43]=r,e[44]=B,e[45]=W,e[46]=_,e[47]=J,e[48]=V,e[49]=Y,e[50]=z):z=e[50],z}export{kt as CommandPaletteHost};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{bG as ye,bV as Ce,c as F,aC as ke,ae as X,ac as Z,aB as ve,aA as q,au as ae,B as O,F as A,bW as Ne,bX as Se,bY as we,bZ as De,b_ as Te,b$ as Ee,c0 as V,c1 as Re,c2 as ee,c3 as Ie,k as te,aa as le,c4 as Oe,a9 as ie,a5 as re,a3 as oe,a4 as ce,a7 as de,a6 as ue,a8 as me,x as ze,E as Ae,f as Le,U as Be,h as $e,i as Fe,b7 as Ge,az as Me,ax as ne,aw as Pe,ay as Ue,m as _e,c5 as Ve}from"./index-BYVl1VlW.js";import{c1 as Ke,a3 as He,a5 as Ye,bv as Je,cB as Qe,U as We,dt as xe,aF as fe,du as Xe,dv as Ze,dw as K,X as H,bl as qe,c_ as he,dx as et,b6 as tt,bR as nt,ao as st,cR as at}from"./vendor-ui-B0az9ATE.js";import{H as lt}from"./HighlightedEditor-G-YJnadM.js";import"./vendor-markdown-BEJ8yVzA.js";const it={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},rt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},se=["instructions","agents","skills","commands","settings"],ot={instructions:{label:"Instructions",icon:Qe,color:"text-muted-foreground"},agents:{label:"Agents",icon:Je,color:"text-muted-foreground"},skills:{label:"Skills",icon:Ye,color:"text-muted-foreground"},commands:{label:"Commands",icon:He,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ke,color:"text-muted-foreground"}};function Y(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Y(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function ct(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Y(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function ge(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const dt=Object.fromEntries(ye().map(l=>[l.kind,Ce(l.kind)]));function pe(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Xe,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=dt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function je(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=F("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let p;return e[6]!==u||e[7]!==m||e[8]!==d?(p=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=p):p=e[9],p}function ut({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,p]=o.useState(!1),w=o.useRef(null),y=o.useId();o.useEffect(()=>{var x;(x=w.current)==null||x.focus()},[]);const k=m==="project"&&e?e:l,b=!!l&&!!e;async function S(){if(!(!r.trim()||!k)){p(!0);try{const x=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:k,fileType:i,name:r.trim()})});if(x.ok){const g=await x.json();n(g.path,i,m)}}finally{p(!1)}}}return t.jsxs(ke,{className:"gap-3 px-3 py-2",children:[b&&t.jsxs(X,{children:[t.jsx(Z,{children:"Scope"}),t.jsxs(ve,{"aria-label":"File scope",value:[m],onValueChange:x=>{const g=x[0];(g==="global"||g==="project")&&c(g)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(q,{value:"global",className:"flex-1",children:[t.jsx(fe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(q,{value:"project",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(X,{children:[t.jsxs(Z,{htmlFor:y,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{id:y,ref:w,type:"text",value:r,onChange:x=>u(x.target.value),onKeyDown:x=>{x.key==="Enter"&&S(),x.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void S(),disabled:d||!r.trim()||!k,children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(H,{"data-icon":"inline-start"})})]})]})]})}function mt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:p,onRenameValueChange:w,onRenameSubmit:y,onRenameCancel:k,creatingInCategory:b,onCreated:S,onCancelCreate:x}=l,g=ot[i],C=g.icon;if(n.length===0&&!u)return null;let N;e[0]!==g.color?(N=F("size-3.5",g.color),e[0]=g.color,e[1]=N):N=e[1];let v;e[2]!==C||e[3]!==N?(v=t.jsx(C,{"data-icon":"inline-start",className:N}),e[2]=C,e[3]=N,e[4]=v):v=e[4];let T;e[5]!==g.label?(T=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:g.label}),e[5]=g.label,e[6]=T):T=e[6];let E;e[7]!==n.length?(E=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=E):E=e[8];let f;e[9]!==i||e[10]!==u?(f=u&&t.jsxs(Ne,{children:[t.jsx(Se,{render:t.jsx(O,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(we,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=f):f=e[11];let D;e[12]!==v||e[13]!==T||e[14]!==E||e[15]!==f?(D=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[v,T,E,f]}),e[12]=v,e[13]=T,e[14]=E,e[15]=f,e[16]=D):D=e[16];let z;if(e[17]!==n||e[18]!==m||e[19]!==k||e[20]!==c||e[21]!==y||e[22]!==w||e[23]!==r||e[24]!==p||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==k||e[30]!==c||e[31]!==y||e[32]!==w||e[33]!==r||e[34]!==p||e[35]!==d||e[36]!==s?(B=j=>{const U=s===j.path;if(d===j.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(ae,{value:p,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&y(),$.key==="Escape"&&k()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:y,disabled:!p.trim(),children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:k,children:t.jsx(H,{"data-icon":"inline-start"})})]},j.path);const M=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:j.name}),t.jsx(je,{linkTarget:j.linkTarget}),j.readOnly&&t.jsx(he,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),j.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:j.description})]}),t.jsx(pe,{cli:j.cli}),t.jsx(ge,{scope:j.scope,pluginName:j.pluginName})]}),P=F("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:P,onClick:()=>r(j),children:M},j.path):t.jsxs(De,{children:[t.jsx(Te,{render:t.jsx("button",{type:"button",className:P,onClick:()=>r(j)}),children:M}),t.jsx(Ee,{className:"min-w-36",children:j.readOnly?t.jsx(V,{children:t.jsx(Re,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(ee,{onClick:()=>c(j),children:"Rename"})}),t.jsx(Ie,{}),t.jsx(V,{children:t.jsx(ee,{variant:"destructive",onClick:()=>m(j),children:"Delete"})})]})})]},j.path)},e[28]=m,e[29]=k,e[30]=c,e[31]=y,e[32]=w,e[33]=r,e[34]=p,e[35]=d,e[36]=s,e[37]=B):B=e[37],z=n.map(B),e[17]=n,e[18]=m,e[19]=k,e[20]=c,e[21]=y,e[22]=w,e[23]=r,e[24]=p,e[25]=d,e[26]=s,e[27]=z}else z=e[27];let R;e[38]!==b||e[39]!==n.length?(R=n.length===0&&!b&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=b,e[39]=n.length,e[40]=R):R=e[40];let I;e[41]!==b||e[42]!==x||e[43]!==S?(I=b&&t.jsx(ut,{globalDir:b.globalDir,projectDir:b.projectDir,fileType:b.fileType,onCreated:S,onCancel:x}),e[41]=b,e[42]=x,e[43]=S,e[44]=I):I=e[44];let L;return e[45]!==D||e[46]!==z||e[47]!==R||e[48]!==I?(L=t.jsxs("section",{children:[D,z,R,I]}),e[45]=D,e[46]=z,e[47]=R,e[48]=I,e[49]=L):L=e[49],L}function xt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,p]=o.useState(!1),[w,y]=o.useState(!1),[k,b]=o.useState(!1),[S,x]=o.useState(!1),g=n!==null&&n!==r,C=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),y(!1),b(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(f=>f.json()).then(f=>{s(f.content??""),u(f.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const N=o.useCallback(async()=>{if(!(!g||C)){p(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),y(!0),setTimeout(()=>y(!1),2e3))}finally{p(!1)}}},[n,l.path,g,C]),v=o.useCallback(()=>{s(r)},[r]),T=o.useCallback(async()=>{if(!C){x(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(b(!1),e())}catch{}finally{x(!1)}}},[l.path,C,e]);o.useEffect(()=>{function f(D){!C&&(D.metaKey||D.ctrlKey)&&D.key==="s"&&(D.preventDefault(),N())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[N,C]);function E(){return w?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(te,{variant:"outline",className:F("h-5 text-xs",it[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(ge,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),C&&t.jsxs(te,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(he,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),g&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(je,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(lt,{value:n??"",onChange:s,readOnly:C,filePath:l.path}),!C&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(O,{size:"xs",onClick:N,disabled:!g||d,children:[t.jsx(K,{"data-icon":"inline-start"}),E()]}),t.jsxs(O,{variant:"outline",size:"xs",onClick:v,disabled:!g,children:[t.jsx(et,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(le,{open:k,onOpenChange:b,children:[t.jsxs(Oe,{render:t.jsx(O,{variant:"outline",size:"xs"}),children:[t.jsx(tt,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",disabled:S,children:"Cancel"}),t.jsxs(me,{variant:"destructive",size:"sm",disabled:S,onClick:()=>void T(),children:[S&&t.jsx(ze,{"data-icon":"inline-start"}),S?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ft(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ae,{className:"border-0",children:t.jsxs(Le,{children:[t.jsx(Be,{variant:"icon",children:t.jsx(nt,{})}),t.jsx($e,{children:"Select a configuration file"}),t.jsx(Fe,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function ht(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function gt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",ht(n)].some(r=>r.toLowerCase().includes(i)))}const kt=o.memo(function({projectPath:e,initialFilePath:i}){var Q,W;const n=Ge("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[p,w]=o.useState(!1),[y,k]=o.useState(null),[b,S]=o.useState(""),[x,g]=o.useState(null),[C,N]=o.useState(""),[v,T]=o.useState(null),E=o.useRef(!1),f=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",h=await A(a);if(h.ok){const _=await h.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!i||u||E.current)return;const a=s.flatMap(h=>Y(h.items,h.scope,h.pluginName)).find(h=>h.path===i);a&&(d(a),E.current=!0)},[i,u,s]);const D=ct(s),z=Object.fromEntries(se.map(a=>[a,gt(D[a],b)])),R=(Q=s.find(a=>a.scope==="global"))==null?void 0:Q.baseDir,I=(W=s.find(a=>a.scope==="project"))==null?void 0:W.baseDir,L=o.useCallback(a=>{d(a),w(!1),k(null)},[]),B=o.useCallback((a,h,_)=>{k(null),f(),d({path:a,name:a.split("/").pop()||"",fileType:h,readOnly:!1,scope:_,description:""})},[f]),j=o.useCallback(()=>{d(null),f()},[f]),U=o.useCallback(a=>{if(!n||!R&&!I)return;const h=rt[a];h&&k({category:a,globalDir:R?`${R}/${h.subdir}`:null,projectDir:I?`${I}/${h.subdir}`:null,fileType:h.fileType})},[n,R,I]),J=o.useCallback(a=>{!n||a.readOnly||T(a)},[n]),M=o.useCallback(async()=>{if(!n||!v||v.readOnly)return;const a=v;T(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),f())}catch{}},[n,f,v,c]),P=o.useCallback(a=>{if(!n||a.readOnly)return;const h=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");g(a),N(h)},[n]),$=o.useCallback(async()=>{if(!(!n||!x||!C.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:x.path,newName:C.trim()})});if(a.ok){const h=await a.json();g(null),N(""),await f(),h.newPath&&d({...x,path:h.newPath,name:h.newPath.split("/").pop()||x.name})}}catch{}},[n,x,C,f]),be=o.useCallback(()=>{g(null),N("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:F("min-h-0 shrink-0 flex-col border-r bg-sidebar md:flex md:w-80",c&&!p?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Me,{children:[t.jsx(ne,{children:t.jsx(st,{"data-icon":"inline-start"})}),t.jsx(Pe,{value:b,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),b&&t.jsx(ne,{align:"inline-end",children:t.jsx(Ue,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(H,{"data-icon":"inline-start"})})})]})}),t.jsx(_e,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,h)=>t.jsx(Ve,{className:"h-8 w-full"},h))}):se.map(a=>{const h=a==="agents"||a==="skills"||a==="commands";return t.jsx(mt,{category:a,items:z[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:L,onNewFile:n&&h?()=>U(a):void 0,onDeleteItem:n?J:void 0,onRenameItem:n?P:void 0,renamingPath:(x==null?void 0:x.path)??null,renameValue:C,onRenameValueChange:N,onRenameSubmit:$,onRenameCancel:be,creatingInCategory:n&&(y==null?void 0:y.category)===a?y:null,onCreated:B,onCancelCreate:()=>k(null)},a)})})})]}),t.jsx("div",{className:F("min-h-0 min-w-0 flex-1 flex-col md:flex",c&&!p?"flex":"hidden"),children:c?t.jsxs(t.Fragment,{children:[t.jsxs(O,{variant:"ghost",className:"min-h-11 shrink-0 justify-start md:hidden",onClick:()=>w(!0),children:[t.jsx(at,{"data-icon":"inline-start"}),"All configuration files"]}),t.jsx(xt,{file:c,onDeleted:j,readOnly:!n})]}):t.jsx(ft,{})}),t.jsx(le,{open:v!==null,onOpenChange:a=>{a||T(null)},children:t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',v==null?void 0:v.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",children:"Cancel"}),t.jsx(me,{variant:"destructive",size:"sm",onClick:()=>void M(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{kt as ConfigBrowser};
|
|
1
|
+
import{c as G,j as t,r as o}from"./vendor-react-gGw_S5I_.js";import{bG as ye,bV as Ce,c as F,aC as ke,ae as X,ac as Z,aB as ve,aA as q,au as ae,B as O,F as A,bW as Ne,bX as Se,bY as we,bZ as De,b_ as Te,b$ as Ee,c0 as V,c1 as Re,c2 as ee,c3 as Ie,k as te,aa as le,c4 as Oe,a9 as ie,a5 as re,a3 as oe,a4 as ce,a7 as de,a6 as ue,a8 as me,x as ze,E as Ae,f as Le,U as Be,h as $e,i as Fe,b7 as Ge,az as Me,ax as ne,aw as Pe,ay as Ue,m as _e,c5 as Ve}from"./index-Dv2TZ38C.js";import{c1 as Ke,a3 as He,a5 as Ye,bv as Je,cB as Qe,U as We,dt as xe,aF as fe,du as Xe,dv as Ze,dw as K,X as H,bl as qe,c_ as he,dx as et,b6 as tt,bR as nt,ao as st,cR as at}from"./vendor-ui-ClPj6-Gu.js";import{H as lt}from"./HighlightedEditor-B-bjFcyU.js";import"./vendor-markdown-BEJ8yVzA.js";const it={agent:"bg-muted text-muted-foreground",skill:"bg-muted text-muted-foreground",command:"bg-muted text-muted-foreground",instructions:"bg-muted text-muted-foreground",settings:"bg-muted text-muted-foreground"},rt={agents:{subdir:"agents",fileType:"agent"},skills:{subdir:"skills",fileType:"skill"},commands:{subdir:"commands",fileType:"command"}},se=["instructions","agents","skills","commands","settings"],ot={instructions:{label:"Instructions",icon:Qe,color:"text-muted-foreground"},agents:{label:"Agents",icon:Je,color:"text-muted-foreground"},skills:{label:"Skills",icon:Ye,color:"text-muted-foreground"},commands:{label:"Commands",icon:He,color:"text-muted-foreground"},settings:{label:"Settings",icon:Ke,color:"text-muted-foreground"}};function Y(l,e,i){const n=[];for(const s of l)s.type==="directory"&&s.children?n.push(...Y(s.children,e,i)):s.type==="file"&&n.push({name:s.name,path:s.path,fileType:s.fileType||"unknown",description:s.description||"",scope:e,pluginName:i,readOnly:s.readOnly??e==="plugin",cli:s.cli,linkTarget:s.linkTarget});return n}function ct(l){const e={instructions:[],agents:[],skills:[],commands:[],settings:[]};for(const i of l){const n=Y(i.items,i.scope,i.pluginName);for(const s of n)switch(s.fileType){case"instructions":e.instructions.push(s);break;case"agent":e.agents.push(s);break;case"skill":e.skills.push(s);break;case"command":e.commands.push(s);break;case"settings":default:e.settings.push(s)}}return e}function ge(l){const e=G.c(5),{scope:i,pluginName:n}=l;if(i==="plugin"&&n){let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsx(We,{"data-icon":"inline-start",className:"size-3"}),e[0]=r):r=e[0];let u;return e[1]!==n?(u=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[r,n]}),e[1]=n,e[2]=u):u=e[2],u}if(i==="project"){let r;return e[3]===Symbol.for("react.memo_cache_sentinel")?(r=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(xe,{"data-icon":"inline-start",className:"size-3"}),"project"]}),e[3]=r):r=e[3],r}let s;return e[4]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(fe,{"data-icon":"inline-start",className:"size-3"}),"global"]}),e[4]=s):s=e[4],s}const dt=Object.fromEntries(ye().map(l=>[l.kind,Ce(l.kind)]));function pe(l){const e=G.c(10),{cli:i,variant:n}=l,s=n===void 0?"compact":n;if(!i)return null;if(i.length===0){let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=t.jsx(Xe,{"data-icon":"inline-start",className:"size-3"}),e[0]=m):m=e[0];const c=s==="full"&&"unlinked";let d;return e[1]!==c?(d=t.jsxs("span",{className:"flex shrink-0 items-center gap-1 text-xs text-warning",title:"Present in the shared source directory but not linked into any CLI",children:[m,c]}),e[1]=c,e[2]=d):d=e[2],d}let r;if(e[3]!==i||e[4]!==s){let m;e[6]!==s?(m=c=>{const d=dt[c];return t.jsx("span",{title:d.label,className:s==="full"?"flex h-5 items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground":"flex size-5 items-center justify-center rounded border bg-muted text-xs font-medium text-muted-foreground",children:s==="full"?c:d.letter},c)},e[6]=s,e[7]=m):m=e[7],r=i.map(m),e[3]=i,e[4]=s,e[5]=r}else r=e[5];let u;return e[8]!==r?(u=t.jsx("span",{className:"flex items-center gap-0.5 shrink-0",children:r}),e[8]=r,e[9]=u):u=e[9],u}function je(l){const e=G.c(10),{linkTarget:i,variant:n,className:s}=l,r=n===void 0?"compact":n;if(!i)return null;let u;e[0]!==s?(u=F("flex min-w-0 shrink-0 items-center gap-1 text-info",s),e[0]=s,e[1]=u):u=e[1];const m=`Symlink → ${i}`;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=t.jsx(Ze,{"data-icon":"inline-start",className:"size-3 shrink-0"}),e[2]=c):c=e[2];let d;e[3]!==i||e[4]!==r?(d=r==="full"&&t.jsxs("span",{className:"truncate font-mono text-xs",children:["→ ",i]}),e[3]=i,e[4]=r,e[5]=d):d=e[5];let p;return e[6]!==u||e[7]!==m||e[8]!==d?(p=t.jsxs("span",{className:u,title:m,children:[c,d]}),e[6]=u,e[7]=m,e[8]=d,e[9]=p):p=e[9],p}function ut({globalDir:l,projectDir:e,fileType:i,onCreated:n,onCancel:s}){const[r,u]=o.useState(""),[m,c]=o.useState(e?"project":"global"),[d,p]=o.useState(!1),w=o.useRef(null),y=o.useId();o.useEffect(()=>{var x;(x=w.current)==null||x.focus()},[]);const k=m==="project"&&e?e:l,b=!!l&&!!e;async function S(){if(!(!r.trim()||!k)){p(!0);try{const x=await A("/api/config-browser/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dir:k,fileType:i,name:r.trim()})});if(x.ok){const g=await x.json();n(g.path,i,m)}}finally{p(!1)}}}return t.jsxs(ke,{className:"gap-3 px-3 py-2",children:[b&&t.jsxs(X,{children:[t.jsx(Z,{children:"Scope"}),t.jsxs(ve,{"aria-label":"File scope",value:[m],onValueChange:x=>{const g=x[0];(g==="global"||g==="project")&&c(g)},variant:"outline",size:"sm",spacing:0,className:"w-full",children:[t.jsxs(q,{value:"global",className:"flex-1",children:[t.jsx(fe,{"data-icon":"inline-start"}),"Global"]}),t.jsxs(q,{value:"project",className:"flex-1",children:[t.jsx(xe,{"data-icon":"inline-start"}),"Project"]})]})]}),t.jsxs(X,{children:[t.jsxs(Z,{htmlFor:y,children:[i.charAt(0).toUpperCase()+i.slice(1)," name"]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{id:y,ref:w,type:"text",value:r,onChange:x=>u(x.target.value),onKeyDown:x=>{x.key==="Enter"&&S(),x.key==="Escape"&&s()},placeholder:`${i} name...`,className:"h-7 min-w-0 flex-1 text-xs",disabled:d}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":`Create ${i}`,onClick:()=>void S(),disabled:d||!r.trim()||!k,children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel create",onClick:s,children:t.jsx(H,{"data-icon":"inline-start"})})]})]})]})}function mt(l){const e=G.c(50),{category:i,items:n,selectedPath:s,onSelect:r,onNewFile:u,onDeleteItem:m,onRenameItem:c,renamingPath:d,renameValue:p,onRenameValueChange:w,onRenameSubmit:y,onRenameCancel:k,creatingInCategory:b,onCreated:S,onCancelCreate:x}=l,g=ot[i],C=g.icon;if(n.length===0&&!u)return null;let N;e[0]!==g.color?(N=F("size-3.5",g.color),e[0]=g.color,e[1]=N):N=e[1];let v;e[2]!==C||e[3]!==N?(v=t.jsx(C,{"data-icon":"inline-start",className:N}),e[2]=C,e[3]=N,e[4]=v):v=e[4];let T;e[5]!==g.label?(T=t.jsx("span",{className:"flex-1 text-xs font-medium text-muted-foreground",children:g.label}),e[5]=g.label,e[6]=T):T=e[6];let E;e[7]!==n.length?(E=t.jsx("span",{className:"text-xs tabular-nums text-muted-foreground",children:n.length}),e[7]=n.length,e[8]=E):E=e[8];let f;e[9]!==i||e[10]!==u?(f=u&&t.jsxs(Ne,{children:[t.jsx(Se,{render:t.jsx(O,{variant:"ghost",size:"icon-xs",className:"opacity-0 transition-opacity group-hover:opacity-100","aria-label":`New ${i.slice(0,-1)}`,onClick:u}),children:t.jsx(qe,{"data-icon":"inline-start"})}),t.jsxs(we,{children:["New ",i.slice(0,-1)]})]}),e[9]=i,e[10]=u,e[11]=f):f=e[11];let D;e[12]!==v||e[13]!==T||e[14]!==E||e[15]!==f?(D=t.jsxs("div",{className:"group flex h-8 items-center gap-1.5 px-3",children:[v,T,E,f]}),e[12]=v,e[13]=T,e[14]=E,e[15]=f,e[16]=D):D=e[16];let z;if(e[17]!==n||e[18]!==m||e[19]!==k||e[20]!==c||e[21]!==y||e[22]!==w||e[23]!==r||e[24]!==p||e[25]!==d||e[26]!==s){let B;e[28]!==m||e[29]!==k||e[30]!==c||e[31]!==y||e[32]!==w||e[33]!==r||e[34]!==p||e[35]!==d||e[36]!==s?(B=j=>{const U=s===j.path;if(d===j.path)return t.jsxs("div",{className:"flex items-center gap-1 border-l-2 border-foreground/30 bg-accent px-3 py-1",children:[t.jsx(ae,{value:p,onChange:$=>w($.target.value),onKeyDown:$=>{$.key==="Enter"&&y(),$.key==="Escape"&&k()},autoFocus:!0,className:"h-7 min-w-0 flex-1 text-xs"}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Save name",onClick:y,disabled:!p.trim(),children:t.jsx(K,{"data-icon":"inline-start"})}),t.jsx(O,{variant:"ghost",size:"icon-xs","aria-label":"Cancel rename",onClick:k,children:t.jsx(H,{"data-icon":"inline-start"})})]},j.path);const M=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-sm",children:j.name}),t.jsx(je,{linkTarget:j.linkTarget}),j.readOnly&&t.jsx(he,{className:"size-2.5 shrink-0 text-muted-foreground/40"})]}),j.description&&t.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:j.description})]}),t.jsx(pe,{cli:j.cli}),t.jsx(ge,{scope:j.scope,pluginName:j.pluginName})]}),P=F("flex w-full items-center gap-2 border-l-2 px-3 py-2 text-left text-sm transition-colors",U?"border-foreground/30 bg-accent text-accent-foreground":"border-transparent text-muted-foreground hover:bg-accent hover:text-foreground");return!m||!c?t.jsx("button",{type:"button",className:P,onClick:()=>r(j),children:M},j.path):t.jsxs(De,{children:[t.jsx(Te,{render:t.jsx("button",{type:"button",className:P,onClick:()=>r(j)}),children:M}),t.jsx(Ee,{className:"min-w-36",children:j.readOnly?t.jsx(V,{children:t.jsx(Re,{children:"Read-only file"})}):t.jsxs(t.Fragment,{children:[t.jsx(V,{children:t.jsx(ee,{onClick:()=>c(j),children:"Rename"})}),t.jsx(Ie,{}),t.jsx(V,{children:t.jsx(ee,{variant:"destructive",onClick:()=>m(j),children:"Delete"})})]})})]},j.path)},e[28]=m,e[29]=k,e[30]=c,e[31]=y,e[32]=w,e[33]=r,e[34]=p,e[35]=d,e[36]=s,e[37]=B):B=e[37],z=n.map(B),e[17]=n,e[18]=m,e[19]=k,e[20]=c,e[21]=y,e[22]=w,e[23]=r,e[24]=p,e[25]=d,e[26]=s,e[27]=z}else z=e[27];let R;e[38]!==b||e[39]!==n.length?(R=n.length===0&&!b&&t.jsx("p",{className:"px-3 py-1 text-xs text-muted-foreground",children:"None configured"}),e[38]=b,e[39]=n.length,e[40]=R):R=e[40];let I;e[41]!==b||e[42]!==x||e[43]!==S?(I=b&&t.jsx(ut,{globalDir:b.globalDir,projectDir:b.projectDir,fileType:b.fileType,onCreated:S,onCancel:x}),e[41]=b,e[42]=x,e[43]=S,e[44]=I):I=e[44];let L;return e[45]!==D||e[46]!==z||e[47]!==R||e[48]!==I?(L=t.jsxs("section",{children:[D,z,R,I]}),e[45]=D,e[46]=z,e[47]=R,e[48]=I,e[49]=L):L=e[49],L}function xt({file:l,onDeleted:e,readOnly:i=!1}){const[n,s]=o.useState(null),[r,u]=o.useState(null),[m,c]=o.useState(!0),[d,p]=o.useState(!1),[w,y]=o.useState(!1),[k,b]=o.useState(!1),[S,x]=o.useState(!1),g=n!==null&&n!==r,C=i||l.readOnly;o.useEffect(()=>{c(!0),s(null),u(null),y(!1),b(!1),A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`).then(f=>f.json()).then(f=>{s(f.content??""),u(f.content??"")}).catch(()=>{s(""),u("")}).finally(()=>c(!1))},[l.path]);const N=o.useCallback(async()=>{if(!(!g||C)){p(!0);try{(await A("/api/config-browser/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:l.path,content:n})})).ok&&(u(n),y(!0),setTimeout(()=>y(!1),2e3))}finally{p(!1)}}},[n,l.path,g,C]),v=o.useCallback(()=>{s(r)},[r]),T=o.useCallback(async()=>{if(!C){x(!0);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(l.path)}`,{method:"DELETE"})).ok&&(b(!1),e())}catch{}finally{x(!1)}}},[l.path,C,e]);o.useEffect(()=>{function f(D){!C&&(D.metaKey||D.ctrlKey)&&D.key==="s"&&(D.preventDefault(),N())}return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[N,C]);function E(){return w?"Saved!":d?"Saving...":"Save"}return t.jsxs("div",{className:"flex flex-1 flex-col min-h-0 min-w-0",children:[t.jsxs("div",{className:"flex min-h-11 shrink-0 items-center gap-2 border-b bg-card px-4 py-2",children:[t.jsx(te,{variant:"outline",className:F("h-5 text-xs",it[l.fileType]||"bg-muted text-muted-foreground"),children:l.fileType}),t.jsx(ge,{scope:l.scope,pluginName:l.pluginName}),t.jsx(pe,{cli:l.cli,variant:"full"}),C&&t.jsxs(te,{variant:"outline",className:"h-5 bg-muted text-xs text-muted-foreground",children:[t.jsx(he,{"data-icon":"inline-start",className:"size-3"})," read-only"]}),g&&t.jsx("span",{className:"size-2 shrink-0 rounded-full bg-warning",title:"Unsaved changes"}),t.jsxs("div",{className:"flex items-center gap-2 ml-auto min-w-0",children:[t.jsx(je,{linkTarget:l.linkTarget,variant:"full"}),t.jsx("span",{className:"truncate font-mono text-xs text-muted-foreground",title:l.path,children:l.path})]})]}),m?t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm",children:"Loading..."}):t.jsxs("div",{className:"flex-1 min-h-0 overflow-hidden flex flex-col",children:[t.jsx(lt,{value:n??"",onChange:s,readOnly:C,filePath:l.path}),!C&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-t bg-card px-4 py-2",children:[t.jsxs(O,{size:"xs",onClick:N,disabled:!g||d,children:[t.jsx(K,{"data-icon":"inline-start"}),E()]}),t.jsxs(O,{variant:"outline",size:"xs",onClick:v,disabled:!g,children:[t.jsx(et,{"data-icon":"inline-start"}),"Discard"]}),t.jsx("div",{className:"flex-1"}),t.jsxs(le,{open:k,onOpenChange:b,children:[t.jsxs(Oe,{render:t.jsx(O,{variant:"outline",size:"xs"}),children:[t.jsx(tt,{"data-icon":"inline-start"}),"Delete"]}),t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',l.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",disabled:S,children:"Cancel"}),t.jsxs(me,{variant:"destructive",size:"sm",disabled:S,onClick:()=>void T(),children:[S&&t.jsx(ze,{"data-icon":"inline-start"}),S?"Deleting...":"Delete file"]})]})]})]})]})]})]})}function ft(){const l=G.c(1);let e;return l[0]===Symbol.for("react.memo_cache_sentinel")?(e=t.jsx(Ae,{className:"border-0",children:t.jsxs(Le,{children:[t.jsx(Be,{variant:"icon",children:t.jsx(nt,{})}),t.jsx($e,{children:"Select a configuration file"}),t.jsx(Fe,{children:"Browse instructions, agents, skills, commands, and settings from the sidebar."})]})}),l[0]=e):e=l[0],e}function ht(l){return l.cli?l.cli.length>0?l.cli.join(" "):"unlinked":""}function gt(l,e){if(!e)return l;const i=e.toLowerCase();return l.filter(n=>[n.name,n.description,n.path,n.linkTarget??"",ht(n)].some(r=>r.toLowerCase().includes(i)))}const kt=o.memo(function({projectPath:e,initialFilePath:i}){var Q,W;const n=Ge("configWrite"),[s,r]=o.useState([]),[u,m]=o.useState(!0),[c,d]=o.useState(null),[p,w]=o.useState(!1),[y,k]=o.useState(null),[b,S]=o.useState(""),[x,g]=o.useState(null),[C,N]=o.useState(""),[v,T]=o.useState(null),E=o.useRef(!1),f=o.useCallback(async()=>{if(!n){r([]),d(null),m(!1);return}m(!0);try{const a=e?`/api/config-browser/tree?cwd=${encodeURIComponent(e)}`:"/api/config-browser/tree",h=await A(a);if(h.ok){const _=await h.json();r(_.sections||[])}}finally{m(!1)}},[n,e]);o.useEffect(()=>{f()},[f]),o.useEffect(()=>{if(!i||u||E.current)return;const a=s.flatMap(h=>Y(h.items,h.scope,h.pluginName)).find(h=>h.path===i);a&&(d(a),E.current=!0)},[i,u,s]);const D=ct(s),z=Object.fromEntries(se.map(a=>[a,gt(D[a],b)])),R=(Q=s.find(a=>a.scope==="global"))==null?void 0:Q.baseDir,I=(W=s.find(a=>a.scope==="project"))==null?void 0:W.baseDir,L=o.useCallback(a=>{d(a),w(!1),k(null)},[]),B=o.useCallback((a,h,_)=>{k(null),f(),d({path:a,name:a.split("/").pop()||"",fileType:h,readOnly:!1,scope:_,description:""})},[f]),j=o.useCallback(()=>{d(null),f()},[f]),U=o.useCallback(a=>{if(!n||!R&&!I)return;const h=rt[a];h&&k({category:a,globalDir:R?`${R}/${h.subdir}`:null,projectDir:I?`${I}/${h.subdir}`:null,fileType:h.fileType})},[n,R,I]),J=o.useCallback(a=>{!n||a.readOnly||T(a)},[n]),M=o.useCallback(async()=>{if(!n||!v||v.readOnly)return;const a=v;T(null);try{(await A(`/api/config-browser/file?path=${encodeURIComponent(a.path)}`,{method:"DELETE"})).ok&&((c==null?void 0:c.path)===a.path&&d(null),f())}catch{}},[n,f,v,c]),P=o.useCallback(a=>{if(!n||a.readOnly)return;const h=a.name==="SKILL.md"?a.path.split("/").slice(-2,-1)[0]||a.name:a.name.replace(/\.[^.]+$/,"");g(a),N(h)},[n]),$=o.useCallback(async()=>{if(!(!n||!x||!C.trim()))try{const a=await A("/api/config-browser/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({oldPath:x.path,newName:C.trim()})});if(a.ok){const h=await a.json();g(null),N(""),await f(),h.newPath&&d({...x,path:h.newPath,name:h.newPath.split("/").pop()||x.name})}}catch{}},[n,x,C,f]),be=o.useCallback(()=>{g(null),N("")},[]);return n?t.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0",children:[t.jsxs("div",{className:F("min-h-0 shrink-0 flex-col border-r bg-sidebar md:flex md:w-80",c&&!p?"hidden":"flex w-full"),children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b px-3",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Configuration"}),e&&t.jsx("span",{className:"ml-auto truncate text-xs text-muted-foreground",title:e,children:e.split("/").pop()})]}),t.jsx("div",{className:"border-b p-2",children:t.jsxs(Me,{children:[t.jsx(ne,{children:t.jsx(st,{"data-icon":"inline-start"})}),t.jsx(Pe,{value:b,onChange:a=>S(a.target.value),placeholder:"Search configuration"}),b&&t.jsx(ne,{align:"inline-end",children:t.jsx(Ue,{size:"icon-xs","aria-label":"Clear search",onClick:()=>S(""),children:t.jsx(H,{"data-icon":"inline-start"})})})]})}),t.jsx(_e,{className:"flex-1",children:t.jsx("div",{className:"flex flex-col gap-1 py-2",children:u?t.jsx("div",{className:"flex flex-col gap-2 px-3 py-2","aria-label":"Loading configuration",children:Array.from({length:6},(a,h)=>t.jsx(Ve,{className:"h-8 w-full"},h))}):se.map(a=>{const h=a==="agents"||a==="skills"||a==="commands";return t.jsx(mt,{category:a,items:z[a],selectedPath:(c==null?void 0:c.path)??null,onSelect:L,onNewFile:n&&h?()=>U(a):void 0,onDeleteItem:n?J:void 0,onRenameItem:n?P:void 0,renamingPath:(x==null?void 0:x.path)??null,renameValue:C,onRenameValueChange:N,onRenameSubmit:$,onRenameCancel:be,creatingInCategory:n&&(y==null?void 0:y.category)===a?y:null,onCreated:B,onCancelCreate:()=>k(null)},a)})})})]}),t.jsx("div",{className:F("min-h-0 min-w-0 flex-1 flex-col md:flex",c&&!p?"flex":"hidden"),children:c?t.jsxs(t.Fragment,{children:[t.jsxs(O,{variant:"ghost",className:"min-h-11 shrink-0 justify-start md:hidden",onClick:()=>w(!0),children:[t.jsx(at,{"data-icon":"inline-start"}),"All configuration files"]}),t.jsx(xt,{file:c,onDeleted:j,readOnly:!n})]}):t.jsx(ft,{})}),t.jsx(le,{open:v!==null,onOpenChange:a=>{a||T(null)},children:t.jsxs(ie,{size:"sm",children:[t.jsxs(re,{children:[t.jsx(oe,{children:"Delete configuration file?"}),t.jsxs(ce,{children:['Delete "',v==null?void 0:v.name,'" permanently? This action cannot be undone.']})]}),t.jsxs(de,{children:[t.jsx(ue,{size:"sm",children:"Cancel"}),t.jsx(me,{variant:"destructive",size:"sm",onClick:()=>void M(),children:"Delete file"})]})]})})]}):t.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:"Server configuration is available to administrators only."})});export{kt as ConfigBrowser};
|