import { DsBotState } from './src/dsbot-state.js' import { installGates } from './src/gates.js' import { dsbotStatePath, sanshengStatePath } from './src/paths.js' import { SanshengStore } from './src/store.js' import { installTools } from './src/tools.js' export const name = 'sansheng' export const inject = ['tools'] /** * 三省六部伴侣插件。原生 group_goal 是阶段进度唯一权威; * 这里只补 DS Bot 没有的东西:项目三角色绑定、审查记录、目标门禁。 */ export async function apply(ctx, config = {}) { const home = typeof config.home === 'string' && config.home.trim() !== '' ? config.home : undefined const store = new SanshengStore( typeof config.statePath === 'string' && config.statePath !== '' ? config.statePath : sanshengStatePath(home), ) const dsbot = new DsBotState( typeof config.dsbotStatePath === 'string' && config.dsbotStatePath !== '' ? config.dsbotStatePath : dsbotStatePath(home), ) try { await store.load() } catch (error) { console.warn(`sansheng: 无法读取 ${store.file}:${error?.message ?? error}`) } installGates({ ctx, store, dsbot }) installTools({ ctx, store, dsbot }) }