ClaudeModsClaude Code 模組目錄
☰
● 0 人在線上 · 瀏覽 0 次
+ 提交作品
← 返回作品集
Reddit 貼文 · 其他

打造 Claude Code mod 的心得:提示框上方的狀態列 — Claude Code 插件/外掛 · ClaudeMods

回報這個作品這是你的作品?認領

在 ClaudeMods 了解這款 Claude Code 插件/外掛,查看原始來源與所需權限。 我收到 Lydia 的每週郵件,看到一個很令人興奮的消息:Claude Code 現在支援 mods,也就是以函式掛鉤撰寫的外掛,能在終端機與桌面版應用程式內繪製 UI。我讀完文件,做了建議的天氣列,很不錯。還能做什麼呢?我最近使用 Ponytail,效果很好,想知道它目前的等級,所以加上去;接著也加上 Caveman。很好玩,也很實用。以下是我的心得與作品。 mod 會針對 AbovePrompt 這類位置掛上 ui.render,回傳由少數元素(Box、Text、Button、Select、Link、Svg)組成的樹,並用 flexbox 排版。不是 HTML,也沒有 CSS。最小的列大概像這樣: on('ui.render', { component: 'AbovePrompt' }, async ($, e) => { const { Box, Text } = $.ui.resolve(e) return <Box flexDirection="row"><Text>hello from a mod</Text></Box> }) 如何把設定放在列內。設定經過幾次嘗試。這部分很有趣,因為 UI 非常有限:設定在 /config 裡,但桌面版沒有它。先用 /overalls weather minimal 指令,再加一個 ⚙ 按鈕,輸入…

TTroepster@Troepster
原貼文圖片1
已翻譯

關於這個 mod

我收到 Lydia 的每週郵件,看到一個很令人興奮的消息:Claude Code 現在支援 mods,也就是以函式掛鉤撰寫的外掛,能在終端機與桌面版應用程式內繪製 UI。我讀完文件,做了建議的天氣列,很不錯。還能做什麼呢?我最近使用 Ponytail,效果很好,想知道它目前的等級,所以加上去;接著也加上 Caveman。很好玩,也很實用。以下是我的心得與作品。

mod 如何繪製 UI

mod 會針對 AbovePrompt 這類位置掛上 ui.render,回傳由少數元素(Box、Text、Button、Select、Link、Svg)組成的樹,並用 flexbox 排版。不是 HTML,也沒有 CSS。最小的列大概像這樣:

on('ui.render', { component: 'AbovePrompt' }, async ($, e) => { const { Box, Text } = $.ui.resolve(e) return <Box flexDirection="row"><Text>hello from a mod</Text></Box> })

如何把設定放在列內

設定經過幾次嘗試。這部分很有趣,因為 UI 非常有限:設定在 /config 裡,但桌面版沒有它。一開始用了 /overalls weather minimal 指令,再加一個 ⚙ 按鈕,幫你把 /overalls 輸入提示框。可以用,但要按兩次。接著試下拉選單(Select)。一個選單只能有一個值,結果天氣明明開著,選取的卻顯示 "Weather: off"。在頂端加一個假的 ⚙ 選項才解決。然後我想把勾選符號對齊尾端、加入群組與子選單,但都沒有這些功能。選項只有值與標籤,不能設定樣式。右鍵選單沒有對應事件;工具提示也沒有 tooltip 屬性。可以用滑鼠懸停時出現的隱藏方框模擬,但方框不能離開狀態列,放在列上就擋住它正在解釋的內容,所以只保留在設定裡。

最後我自己做:⚙ 在狀態列內、橫列上方開啟有框線的 Config 方框,你按下時就能看到每個變更。每個選項都是普通按鈕,目前選項標上 ✓。相關開關在 │ 後共用一列(megacave 在 Caveman 旁,重設在 Limits 旁)。之後碰到狀態列的高度上限(視窗的一半),設定便改放在兩個有框線的欄位。

其他注意事項

單獨的 <Box> 在桌面版會垂直堆疊。要橫向排列,務必設定 flexDirection="row"。Flex 項目預設會縮小,桌面版因此會讓元件內的文字換行;flexShrink={0} 配合允許換行的父容器可解決,⚙ 也會留在第一列。MCP 伺服器狀態沒有 API。我從工具呼叫錯誤(401、connection refused)推斷,因此連接器登出後首次失敗就能被發現,Reconnect 會直接帶你到 Customize › Connectors。Ponytail 所有工作階段共用一個等級檔案,因此每個視窗都顯示最後設定的等級。我改成按工作階段追蹤,也向上游開了 issue。狀態放在 $.state(每個工作階段)或 $.store(跨工作階段)。模組變數在每次熱重載時都會重設。

我的作品:Overalls

Overalls:claude code 的資訊列。顯示上下文「天氣」、迷你趨勢圖與大約剩餘回合數,5 小時與每週用量上限及重設倒數、附 Reconnect 按鈕的 MCP 錯誤、遭拒的工具呼叫、執行中的子代理,以及 Ponytail 和 Caveman 等級下拉選單。所有項目都能在 ⚙ 方框內切換。

claude plugin marketplace add Troepster/overalls claude plugin install overalls@overalls

採用 MIT 授權,在本機執行,README 列出它讀取的所有資料:https://github.com/Troepster/overalls

還有人在做 mods 嗎?很想看看大家用它做什麼,也請告訴我漏掉了哪些明顯的事情。由 /u/Troepster 投稿 [link] [comments]

安裝

安裝方式請查看原始來源。

原文 / README

So I got my weekly mail from Lydia and saw something very exciting: Claude Code now supports mods, plugins written as function hooks that can draw UI inside the app, in both the terminal and the desktop app. So I went through the docs and built the suggested weather band, very nice. Then what else can I do with it? I recently started using Ponytail with great success and wanted to know what level it's running at, so let's add that… and after that, why not Caveman as well. Bottom line, great fun and very useful. Here's what I learned, then what I made. How a mod draws UI A mod hooks ui.render for a spot like AbovePrompt and returns a tree of a few elements ( Box , Text , Button , Select , Link , Svg ), laid out with flexbox. Not HTML, no CSS. The smallest band is about this: on('ui.render', { component: 'AbovePrompt' }, async ($, e) => { const { Box, Text } = $.ui.resolve(e) return <Box flexDirection="row"><Text>hello from a mod</Text></Box> }) How I did config inline The config took a few goes This was the fun part, because the UI is so limited: Settings live in /config , but that doesn't exist in the desktop app. So first a /overalls weather minimal command, then a ⚙ button that typed /overalls into the prompt for you. Works, but two clicks. Next a dropdown ( Select ). One dropdown can only hold one value, so it showed "Weather: off" as selected while weather was clearly on. Fixed with a dummy ⚙ option at the top. Then I wanted ticks lined up at the end, and groups, and submenus… none of that exists. An option is just a value and a label, no styling. Right-click menu? No such event. Tooltips? No tooltip prop either. You can fake one with a hidden box that shows on hover, but it can't leave the band, so on the bar it covered the very thing it was explaining. Kept them only in the config. So in the end I built my own: ⚙ opens a bordered Config box inside the band, above the bar, so you see each change happen as you click. Every option is a plain button with a ✓ on the current one. Related switches share a row behind a │ (megacave sits next to Caveman, resets next to Limits). Then the band hit its height cap (half the window), so the settings went into two bordered columns. Other gotchas A bare <Box> stacks vertically in the desktop app. Always set flexDirection="row" if you want a row. Flex items shrink by default, so the desktop app wraps text inside a widget. flexShrink={0} plus a wrapping parent fixes it, and the ⚙ stays put on the first row. There's no API for MCP server status. I infer it from tool-call errors (401s, connection refused), which catches a logged-out connector on its first failure, and Reconnect takes you straight to Customize › Connectors. Ponytail keeps one level file for all your sessions, so every window showed whichever level was set last. I track it per session instead (and opened an issue upstream). State lives in $.state (per session) or $.store (across sessions). Module variables reset on every hot reload. What I made: Overalls Overalls: informative bar in claude code A band that shows context "weather" with a sparkline and roughly how many turns are left, 5h and weekly limits with reset countdowns, MCP errors with a Reconnect button, refused tool calls, running subagents, and Ponytail and Caveman levels as dropdowns. Everything is a toggle in the ⚙ box. claude plugin marketplace add Troepster/overalls claude plugin install overalls@overalls MIT, runs locally, and the README lists everything it reads: https://github.com/Troepster/overalls Anyone else building mods? Would love to see what else people are doing with them. Also please give me some feedback on obvious things I missed. submitted by /u/Troepster [link] [comments]

查看原始來源 ↗

更多類似作品