fix: companion 改用 $.fs,修正 hooks 模組載入失敗
node-fs.ts 引用 node:fs/promises,hooks 沙箱不允許,導致 /companion 指令未註冊。 改為以引擎的 $.fs 包成 Fs adapter;rename 改為選用,無 rename 時直接覆寫。 版本號調整為 0.0.1。 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
6338b57df7
commit
94143a1f51
@@ -2,7 +2,7 @@ import type { Register } from 'claude-code'
|
||||
|
||||
import { fitCompanion } from './companion/band'
|
||||
import { createCompanion } from './companion/core'
|
||||
import { nodeFs } from './companion/node-fs'
|
||||
import { engineFs } from './companion/engine-fs'
|
||||
|
||||
let companion: ReturnType<typeof createCompanion> | undefined
|
||||
|
||||
@@ -14,7 +14,7 @@ export const register: Register = on => {
|
||||
argumentHint: 'status | switch <角色> | off | setup',
|
||||
})
|
||||
const home = await $.env.get('HOME')
|
||||
companion = createCompanion({ fs: nodeFs, clock: { now: Date.now }, root: `${home ?? ''}/.companion` })
|
||||
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()
|
||||
if (first.first) $.ui.toast(`已啟用 ${first.name}。用 /companion off 可關閉`)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user