refactor: 拆分 cockpit 為可個別安裝的 statusbar 與 companion

- statusbar:輸入框上方狀態列,指令 /statusbar
- companion:小說角色陪伴,指令 /companion,自行渲染角色行
- companion 資料目錄改為 ~/.companion
- 整併 M4 檔案至 companion;M2 實作移至 hooks/companion/persona
- README 移除本機資料夾安裝,補上更新與移除指令

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-10-12 13:57:24 +08:00
co-authored by Claude Sonnet 5.5
parent 66fefa79a4
commit ba5b50ad1d
50 changed files with 162 additions and 133 deletions
+33
View File
@@ -0,0 +1,33 @@
import { bar, lineWidth } from './seg'
import type { Seg } from './seg'
import type { View } from './core'
const axis = (v: number) => bar(((v + 1) / 2) * 100, 3)
// 由完整版往下捨棄次要資訊:氣泡 → 待辦 → PAD 條 → 好感階段;緊湊版只留「顏文字 名字 心情」
function line(v: View, level: number, compact: boolean, bubble?: string): Seg[] {
const out: Seg[] = [
{ text: `${v.kaomoji} `, color: 'claude' },
{ text: v.core.name, bold: true },
{ text: ' ' },
{ text: v.label, color: 'suggestion' },
]
if (compact) return out
const dot = { text: ' · ', dim: true }
if (level < 3) out.push(dot, { text: `P${axis(v.mood.p)} A${axis(v.mood.a)} D${axis(v.mood.d)}`, dim: true })
if (level < 4) out.push(dot, { text: v.stage })
if (level < 2 && v.todos > 0) out.push(dot, { text: `☐${v.todos}`, color: 'warning' })
if (level < 1 && bubble) out.push(dot, { text: `💬 ${bubble}`, dim: true })
return out
}
export const COMPANION_MAX_LEVEL = 4
export function fitCompanion(v: View, columns: number, compact = false, bubble?: string): Seg[] {
if (compact) return line(v, 0, true)
for (let level = 0; level <= COMPANION_MAX_LEVEL; level++) {
const l = line(v, level, false, bubble)
if (lineWidth(l) <= columns) return l
}
return line(v, 0, true)
}