Просмотр исходного кода

UI: show plugins in /status (#4515)

Co-authored-by: GitHub Action <[email protected]>
Spoon 2 месяцев назад
Родитель
Сommit
16b41d2bea
1 измененных файлов с 48 добавлено и 0 удалено
  1. 48 0
      packages/opencode/src/cli/cmd/tui/component/dialog-status.tsx

+ 48 - 0
packages/opencode/src/cli/cmd/tui/component/dialog-status.tsx

@@ -11,6 +11,31 @@ export function DialogStatus() {
 
 
   const enabledFormatters = createMemo(() => sync.data.formatter.filter((f) => f.enabled))
   const enabledFormatters = createMemo(() => sync.data.formatter.filter((f) => f.enabled))
 
 
+  const plugins = createMemo(() => {
+    const list = sync.data.config.plugin ?? []
+    const result = list.map((value) => {
+      if (value.startsWith("file://")) {
+        const path = value.substring("file://".length)
+        const parts = path.split("/")
+        const filename = parts.pop() || path
+        if (!filename.includes(".")) return { name: filename }
+        const basename = filename.split(".")[0]
+        if (basename === "index") {
+          const dirname = parts.pop()
+          const name = dirname || basename
+          return { name }
+        }
+        return { name: basename }
+      }
+      const index = value.lastIndexOf("@")
+      if (index <= 0) return { name: value, version: "latest" }
+      const name = value.substring(0, index)
+      const version = value.substring(index + 1)
+      return { name, version }
+    })
+    return result.toSorted((a, b) => a.name.localeCompare(b.name))
+  })
+
   return (
   return (
     <box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
     <box paddingLeft={2} paddingRight={2} gap={1} paddingBottom={1}>
       <box flexDirection="row" justifyContent="space-between">
       <box flexDirection="row" justifyContent="space-between">
@@ -109,6 +134,29 @@ export function DialogStatus() {
           </For>
           </For>
         </box>
         </box>
       </Show>
       </Show>
+      <Show when={plugins().length > 0} fallback={<text fg={theme.text}>No Plugins</text>}>
+        <box>
+          <text fg={theme.text}>{plugins().length} Plugins</text>
+          <For each={plugins()}>
+            {(item) => (
+              <box flexDirection="row" gap={1}>
+                <text
+                  flexShrink={0}
+                  style={{
+                    fg: theme.success,
+                  }}
+                >
+                  •
+                </text>
+                <text wrapMode="word" fg={theme.text}>
+                  <b>{item.name}</b>
+                  {item.version && <span style={{ fg: theme.textMuted }}> @{item.version}</span>}
+                </text>
+              </box>
+            )}
+          </For>
+        </box>
+      </Show>
     </box>
     </box>
   )
   )
 }
 }