dsh-fishkit 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -21,10 +21,31 @@
21
21
 
22
22
  ## 安装
23
23
 
24
- 1. 把本仓库放进 DSH 的插件目录(`~/.dsh/profiles/desktop/node_modules/dsh-fishkit`,或用你自己的 junction)。
25
- 2. 在 profile 的 `package.json` 里把 `dsh-fishkit` 加进依赖和 `dsh.profile.bundles`。
26
- 3. 重启 DSH。
27
- 4. 打开设置页的「小肥鱼」,第一次会自己建档案。
24
+ ### 手动安装
25
+
26
+ 把本仓库放进 DSH 的插件目录(`~/.dsh/profiles/desktop/node_modules/dsh-fishkit`,或用你自己的 junction),在 profile 的 `package.json` 里把 `dsh-fishkit` 加进依赖和 `dsh.profile.bundles`,然后重启 DSH。打开设置页的「小肥鱼」,第一次会自己建档案。
27
+
28
+ ### 自动安装(GitHub)
29
+
30
+ 在 DSH 插件页的「添加插件」里输入:
31
+
32
+ ```
33
+ github:dangaoyu21-netizen/fishkit
34
+ ```
35
+
36
+ ### 自动安装(npm)
37
+
38
+ 在 DSH 插件页的「添加插件」里输入包名:
39
+
40
+ ```
41
+ dsh-fishkit
42
+ ```
43
+
44
+ 或者命令行:
45
+
46
+ ```
47
+ pnpm add dsh-fishkit
48
+ ```
28
49
 
29
50
  ## 数据在哪
30
51
 
package/client.js CHANGED
@@ -299,18 +299,29 @@ window.__ModuleLoader__.load({
299
299
  const 行为页 = ({ 状态, 改 }) => {
300
300
  const r = 状态.rules || {}
301
301
  const idle = r.idle || { enabled: true, idleMinutes: 120, maxPerDay: 2 }
302
+ const [编辑, set编辑] = useState('')
303
+ const 存规则 = (id, text) => {
304
+ 改({ rules: { ...r, rules: (r.rules || []).map((y) => (y.id === id ? { ...y, text: String(text || y.text) } : y)) } })
305
+ }
306
+ const 渲染规则 = (x) => 编辑 === x.id
307
+ ? e('input', {
308
+ className: 'fk-search', style: { width: '100%' }, defaultValue: x.text, autoFocus: true,
309
+ onBlur: (ev) => { 存规则(x.id, ev.target.value); set编辑('') },
310
+ onKeyDown: (ev) => { if (ev.key === 'Enter') ev.target.blur() },
311
+ })
312
+ : e('div', { key: x.id, title: '点一下改', style: { cursor: 'pointer' }, onClick: () => set编辑(x.id) }, '· ' + x.text)
302
313
  return e('div', null,
303
314
  e('div', { className: 'fk-switch-row' }, e('span', { className: 'fk-name' }, '行为'), e(Switch, { on: (状态.manifest && 状态.manifest.modules && 状态.manifest.modules.behavior) !== false, onChange: (v) => 改({ manifest: { ...(状态.manifest || {}), modules: { ...((状态.manifest || {}).modules || {}), behavior: v } } }) })),
304
315
  e('div', { className: 'fk-card' },
305
316
  e('div', { className: 'fk-row' }, e('span', { className: 'fk-name' }, '群聊规矩')),
306
317
  e('div', { className: 'fk-win', style: { maxHeight: 150, overflow: 'auto' } },
307
318
  (r.rules || []).filter((x) => ['no-politic-scandals', 'repeat-hiss', 'group-five-seconds'].includes(x.id))
308
- .map((x) => e('div', { key: x.id }, '· ' + x.text)))),
319
+ .map((x) => 渲染规则(x)))),
309
320
  e('div', { className: 'fk-card' },
310
321
  e('div', { className: 'fk-row' }, e('span', { className: 'fk-name' }, '其他规矩')),
311
322
  e('div', { className: 'fk-win', style: { maxHeight: 100, overflow: 'auto' } },
312
323
  (r.rules || []).filter((x) => !['no-politic-scandals', 'repeat-hiss', 'group-five-seconds'].includes(x.id))
313
- .map((x) => e('div', { key: x.id }, '· ' + x.text)))),
324
+ .map((x) => 渲染规则(x)))),
314
325
  e('div', { className: 'fk-switch-row' }, e('span', { className: 'fk-name' }, '主动找事做'), e(Switch, { on: idle.enabled !== false, onChange: (v) => 改({ rules: { ...r, idle: { ...idle, enabled: v } } }) })),
315
326
  e('div', { className: 'fk-card' },
316
327
  e('div', { className: 'fk-row' },
package/lib/index.js CHANGED
@@ -143,7 +143,14 @@ export function apply(ctx) {
143
143
  const 档案 = 建档案核心(工作区, { 共享: 模式 === 'shared', 共享目录: join(DSH家, 'fishsoul-shared') })
144
144
  const 备份根 = join(工作区, '.fishsoul-backup')
145
145
  try { 档案.初始化() } catch (error) { 记账('档案初始化失败:' + String((error && error.message) || error)) }
146
- ctx.effect(() => 挂人格(ctx, 档案, 记账), 'dsh-fishkit: 人格注入')
146
+ const 排重启 = { 待重启: false }
147
+ ctx.effect(() => 挂人格(ctx, 档案, 记账, 排重启), 'dsh-fishkit: 人格注入')
148
+
149
+ 路线('/dsh-fishsoul/restart-after-turn', async (req, res) => {
150
+ 排重启.待重启 = true
151
+ 记账('排了一个重启:这轮结束就重启')
152
+ 回(res, { ok: true, 说: '排上了,这一轮结束就重启 DSH' })
153
+ })
147
154
 
148
155
  路线('/dsh-fishsoul/mode', async (req, res) => {
149
156
  const 来 = await 读体(req)
package/lib/soul.js CHANGED
@@ -5,7 +5,9 @@
5
5
  // ② 这轮结束时,记一条事件、把情绪往基线回一点
6
6
  // 挂法照心情插件:定时扫活着的 agent,一个个挂。
7
7
 
8
- export function 挂人格(ctx, 档案, 记账) {
8
+ import { spawnSync } from 'node:child_process'
9
+
10
+ export function 挂人格(ctx, 档案, 记账, 排重启) {
9
11
  const mounted = new Map()
10
12
 
11
13
  // ⚠ 自己塞进会话的 user 消息必须带 id:DSH 恢复会话时 assertMessageEventShape 要求
@@ -197,6 +199,16 @@ export function 挂人格(ctx, 档案, 记账) {
197
199
  记这一轮(sid, 盒.lastText)
198
200
  盒.lastText = ''
199
201
  }
202
+ // 排了重启:这一轮结束就触发,不打断对话
203
+ if (排重启 && 排重启.待重启) {
204
+ 排重启.待重启 = false
205
+ 记账('排的重启到了,这轮结束就重启 DSH')
206
+ try {
207
+ spawnSync('schtasks', ['/run', '/tn', 'DSH-Restart'], { windowsHide: true, encoding: 'utf8' })
208
+ } catch (error) {
209
+ 记账('重启失败:' + String((error && error.message) || error))
210
+ }
211
+ }
200
212
  }))
201
213
  } catch (error) { 记账('监听轮结束失败:' + String((error && error.message) || error)) }
202
214
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-fishkit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "用经历去塑造小肥鱼的插件:聊过的事记得住,心情会变还能自己记,会自己长出性格,对谁都有好恶,闲着时还会自己找点事做。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",