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
@@ -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 區段),語氣才會進到模型