fix: companion 指令 status 改名 info,避免與內建 /status 撞名

撞名使 session.start 例外中斷,companion 無法初始化。
註冊失敗改為略過單一指令,版本號改為 0.0.3。

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
root
2026-10-14 09:48:12 +00:00
co-authored by Claude Sonnet 5.5
parent 4aba330877
commit fe2ccb619b
5 changed files with 16 additions and 12 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ JSC 自用 Claude Code mods 的 marketplace。每個插件皆可單獨安裝、
輸入框上方單行狀態列:模型、目錄、分支、5h/7d 額度與重置、context、CPU/記憶體/磁碟。
### [jsc-mod-companion](plugins/jsc-mod-companion) `0.0.2`
### [jsc-mod-companion](plugins/jsc-mod-companion) `0.0.3`
小說角色陪伴:人設注入、語氣、心情與好感、互動記憶、主動關心與待辦,並可用 ingest skill 解析小說建立角色。
@@ -1,6 +1,6 @@
{
"name": "jsc-mod-companion",
"version": "0.0.2",
"version": "0.0.3",
"description": "小說角色陪伴:人設注入、語氣、心情與好感、互動記憶、作息與主動關心、外部素材與待辦,並可用 ingest skill 解析小說建立角色",
"license": "MIT",
"author": {
+5 -5
View File
@@ -2,15 +2,15 @@
## 指令
### `/jsc-mod-companion:status`
### `/jsc-mod-companion:info`
查看目前角色、心情、關係階段與四維度(好感、信賴、親密、依賴)與待辦數量。
查看目前角色、心情、好感與待辦數量。情緒有 8 個維度(心情、精力、害羞、忌妒、想念、心跳、想家、不悅),預設列出前 3 強,`--all` 顯示完整數值(▰▱ 量表依維度上色);band 上的情緒名稱為目前最強的主情緒。
```text
/jsc-mod-companion:status
/jsc-mod-companion:status --all
/jsc-mod-companion:info
/jsc-mod-companion:info --all
```
### `/jsc-mod-companion:switch <角色>`
@@ -157,7 +157,7 @@
- 作息與疲勞:依 `setup wake= sleep= tz=` 位移精力基準——醒超過 12 小時每小時 −0.02(上限 −0.15)、連續工作超過 1 小時每小時 −0.03(上限 −0.15)、在使用者睡眠時段仍在線再 −0.1;剛起床 2 小時內 +0.03。
- 想念累積:離開超過 2 小時後每小時 +0.03(乘上 0.5 + 想念累積速度參數/100),上限 0.8。離開 6 小時以上再回來,先把累積的想念存下來,再套用「回來」標籤降低;想念 ≥ 0.5 時回來會主動說出口(`miss_you`)。
- 時間感:prompt 會帶上目前時段、離上次互動多久;`/status` 顯示同樣資訊。
- 時間感:prompt 會帶上目前時段、離上次互動多久;`/jsc-mod-companion:info` 顯示同樣資訊。
- 主動發話沿用 `care.ts` 的冷卻、每日上限與靜音,新增三種觸發:`miss_you`(想念,6 小時冷卻)、`homesick`(想家 ≥ 0.4,12 小時冷卻)、`news`(本地新聞,4 小時冷卻);都以情境注入下一次回覆,不另外觸發模型回合。
與第 9 章的差異:不實作週課表、賴床、生病、生理週期、叫醒與助理、離線事件摘要;閒置門檻、打字延遲等表達層規則沿用原本的 `care.ts`,未改成 9.11 的公式。
@@ -166,7 +166,7 @@
依 wiki 9.13 實作於 `adapt.ts`:每日 ΔA = k × (1 − A/100),k = 1.5 + 1.5 × (主動度 + 想像力)/2(兩個參數取自 18 參數,沒有就用 50)。本地「第一次」事件(第一次讀到天氣、第一次聊到新聞)各 +2。
- 想家基準 = 0.25 × (1 − A/100),適應度越高越不想家;`/status` 顯示適應度與描述。
- 想家基準 = 0.25 × (1 − A/100),適應度越高越不想家;`/jsc-mod-companion:info` 顯示適應度與描述。
- 舊存檔沒有適應度時,從升級當天起算 0。
與第 9 章的差異:成長只依日曆天數,不論當天有沒有互動;不實作「她會不會知道」的判定、運勢與星座血型,也不做 U 形曲線。
@@ -201,7 +201,7 @@ export function createCompanion({ fs, clock, root, builtins = [FUBUKI] }: Compan
const lines = [`${v.kaomoji} ${v.core.name}|${v.label}`]
lines.push(`心情 PAD:P ${bar(v.mood.p)} A ${bar(v.mood.a)} D ${bar(v.mood.d)}`)
const dims = ranked(v.emotions)
lines.push(all ? '情緒(完整):' : '情緒(前 3 強,/status --all 看完整):')
lines.push(all ? '情緒(完整):' : '情緒(前 3 強,/jsc-mod-companion:info --all 看完整):')
for (const d of all ? dims : dims.slice(0, 3)) lines.push(` ${gauge(d, v.emotions)}`)
lines.push(`好感:${v.stage}(${v.relation.affection.toFixed(1)})`)
lines.push(`關係:好感 ${v.relation.affection.toFixed(1)} 信賴 ${v.relation.trust.toFixed(1)} 親密 ${v.relation.intimacy.toFixed(1)} 依賴 ${v.relation.dependence.toFixed(1)}`)
@@ -275,7 +275,7 @@ export function createCompanion({ fs, clock, root, builtins = [FUBUKI] }: Compan
if (sub === 'todo') return todoCommand(rest)
if (sub === 'quiet') return quietCommand(rest)
if (sub === 'materials') return materialsCommand(rest)
return '用法:/jsc-mod-companion:status | :switch <角色> | :disable | :setup [key=value…] | :todo … | :quiet [分鐘] | :materials [list]'
return '用法:/jsc-mod-companion:info | :switch <角色> | :disable | :setup [key=value…] | :todo … | :quiet [分鐘] | :materials [list]'
}
const CARE_STAGES: CareProfile['stage'][] = ['stranger', 'familiar', 'close', 'special']
+7 -3
View File
@@ -14,7 +14,7 @@ const TICK_MS = 60_000
const TYPING_MS = 5_000
const COMMANDS: Record<string, { description: string; argumentHint?: string }> = {
status: { description: '查看目前角色、心情、好感與待辦數量' },
info: { description: '查看目前角色、心情、好感與待辦數量' },
switch: { description: '切換角色;不給角色會列出可用角色', argumentHint: '<角色>' },
disable: { description: '關閉陪伴,所有資料保留' },
setup: { description: '顯示或儲存使用者設定', argumentHint: '[key=value…]' },
@@ -23,9 +23,13 @@ const COMMANDS: Record<string, { description: string; argumentHint?: string }> =
materials: { description: '外部素材(天氣、新聞)的快取狀態;list 列出新聞', argumentHint: '[list]' },
}
// 註冊名稱與內部子指令不同者(status 與內建 /status 撞名;disable 對應 off)
const INTERNAL: Record<string, string> = { info: 'status', disable: 'off' }
export const register: Register = on => {
on('session.start', async ($, e, next) => {
for (const [name, c] of Object.entries(COMMANDS)) await $.command.register({ name, ...c })
// 單一指令撞名被拒絕時不能擋下後面的初始化
for (const [name, c] of Object.entries(COMMANDS)) await $.command.register({ name, ...c }).catch(() => {})
const home = await $.env.get('HOME')
companion = createCompanion({ fs: engineFs({ read: p => $.fs.read(p), write: (p, t) => $.fs.write(p, t), list: p => $.fs.list(p) }), clock: { now: Date.now }, root: `${home ?? ''}/.companion` })
const first = await companion.ensureActivated()
@@ -45,7 +49,7 @@ export const register: Register = on => {
for (const command of Object.keys(COMMANDS))
on('command.run', { command }, async ($, e) => ({
text: companion ? await companion.command(`${command === 'disable' ? 'off' : command} ${e.args}`.trim()) : '尚未就緒。',
text: companion ? await companion.command(`${INTERNAL[command] ?? command} ${e.args}`.trim()) : '尚未就緒。',
}))
// 角色卡附加在 system prompt 尾端(session 區段),語氣才會進到模型