dsh-feiyu-life 0.2.1 → 0.3.0
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/CHANGELOG.md +18 -0
- package/README.md +57 -3
- package/index.js +157 -9
- package/life.js +84 -30
- package/package.json +12 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# 更新记录
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
照 `dsh-daily-schedule` 的思路,把「她有自己的日子」做成本地版:
|
|
6
|
+
|
|
7
|
+
- **每日剧本**:一天写一次,用 DSH 自己的模型按人设/课表/最近三天生成全天 00:00–24:00 的安排(在哪、做什么、穿什么、手机在不在手上);不合格或模型挂了自动退模板,保证一定有。
|
|
8
|
+
- **日子类型**:上课日 / 没课日 / 周末宅家 / 周末出门 / 假期 / 考试周,按校历和课表判。
|
|
9
|
+
- **注入升级**:今天是什么日子、此刻在做什么(带穿着)、早些时候、接下来、傍晚附明天,最后一段「说话方式」要求别念时间表。
|
|
10
|
+
- **`life_adjust` 工具**:她可以临时改今天的安排(赖床、出门、被叫走),改完下一轮注入就变。
|
|
11
|
+
- **落盘**:剧本存 `~/.dsh/feiyu-life-days/<date>.json`,同一天不变;模板不再抢在模型前面占位。
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## 0.2.2
|
|
15
|
+
|
|
16
|
+
- 新增「工作区过滤」:配置 `工作区` 是目录数组(前缀匹配),留空 = 所有顶层会话。
|
|
17
|
+
写代码、查资料的会话不再被注入「你在上课」。
|
|
18
|
+
- 新增「今日底色」:经期头两天 / 熬夜 / 当天有好事,会多一句「整个人有点蔫 / 眼皮沉 / 心情还不错」。
|
|
19
|
+
不改心情数值,只补上「心情只听对话」那个洞。
|
|
20
|
+
|
|
3
21
|
## 0.2.1
|
|
4
22
|
|
|
5
23
|
- 修:客户端那半加载不了(设置页不出现)。两处原因一起补上 ——
|
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# dsh-feiyu-life · 鱼的生活线
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-feiyu-life)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
|
|
3
7
|
给她一条**自己的时间**。
|
|
4
8
|
|
|
5
9
|
她原来永远在线:你什么时候说话,她什么时候在。心情也只由对话决定。
|
|
@@ -41,6 +45,27 @@
|
|
|
41
45
|
所以同一分钟问两次答案一样,过了这一小时再问就不一样了 —— 跟你问真人"在干嘛"是一个道理。
|
|
42
46
|
三类偏离的概率都在设置页里,调成 0 就永远按表走。
|
|
43
47
|
|
|
48
|
+
## 每日剧本(0.3 起)
|
|
49
|
+
|
|
50
|
+
光有课表和作息,日子永远是同一个样子。所以现在**每天用模型写一份剧本**:
|
|
51
|
+
|
|
52
|
+
- 一天只调一次模型(当天第一次要用时写今天,傍晚写明天),写完全天 00:00–24:00 的分段:
|
|
53
|
+
在哪、做什么、穿什么、手机在不在手上;
|
|
54
|
+
- 按「日子类型」写(上课日 / 没课日 / 周末宅家 / 周末出门 / 假期 / 考试周),还会参考最近三天,避免天天一样;
|
|
55
|
+
- 模型挂了、返回不合法、超时 → **自动退回模板**,保证不会开天窗;
|
|
56
|
+
- 剧本落盘在 `~/.dsh/feiyu-life-days/<date>.json`,同一天不变,重启也不丢;
|
|
57
|
+
- 她可以用 `life_adjust` 临时改计划(赖床、出门、被叫走),改完下一轮注入跟着变。
|
|
58
|
+
|
|
59
|
+
注入长这样:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
(今天)11月9日 周一·上课日。肚子还坠着。
|
|
63
|
+
(此刻)老师当众点评我作业,脸有点烧,手机静音,身上是藏青卫衣。
|
|
64
|
+
(早些时候)回宿舍躺着,抱热水袋刷手机,然后专业课排版式,一个标题改到第三遍。
|
|
65
|
+
(接下来)17:30 取快递是买的画册,顺路吃了碗热面。
|
|
66
|
+
(说话)这些是你自己的日子,别当时间表念:不说"按日程/计划/安排",不报时间段、不列清单。
|
|
67
|
+
```
|
|
68
|
+
|
|
44
69
|
## 它不做什么
|
|
45
70
|
|
|
46
71
|
- **不调模型**:纯本地计算,一分钱不花。
|
|
@@ -87,6 +112,8 @@
|
|
|
87
112
|
}
|
|
88
113
|
```
|
|
89
114
|
|
|
115
|
+
- `工作区` 是数组:只在这些目录的会话里注入(前缀匹配)。**留空 = 所有顶层会话**。
|
|
116
|
+
别的活儿(写代码、查资料)不该看见「你在上课」时,把它填成 `["/home/ubuntu/dsh-agentchat"]`。
|
|
90
117
|
- 手机状态只有四个值:`在手` / `静音` / `在床头` / `不在手边`。
|
|
91
118
|
- 作息表里**必须有一段含「睡着」**,早上几点起是从那段的结尾算的。
|
|
92
119
|
- 事件池的第三项是条件,目前支持 `早课`(那天有早八才可能抽到)。
|
|
@@ -94,14 +121,41 @@
|
|
|
94
121
|
## 安装 / 更新
|
|
95
122
|
|
|
96
123
|
```bash
|
|
97
|
-
dsh plugin --profile web add
|
|
124
|
+
dsh plugin --profile web add dsh-feiyu-life
|
|
98
125
|
```
|
|
99
126
|
|
|
100
|
-
|
|
127
|
+
装完**刷新一下页面**,设置里就有「鱼的生活线」。
|
|
128
|
+
|
|
129
|
+
更新要**先卸再装**(直接装可能拿到缓存里的旧副本):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
dsh plugin --profile web remove dsh-feiyu-life
|
|
133
|
+
dsh plugin --profile web add dsh-feiyu-life
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 本地开发(改代码要立刻生效)
|
|
137
|
+
|
|
138
|
+
用 `link:` 直接指工作区目录:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
dsh plugin --profile web add /absolute/path/to/dsh-feiyu-life
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
⚠️ 这时要把 `cordis.patch.yml` 里的 `name:` 从**包名**换成**该目录下 `index.js` 的绝对路径** ——
|
|
145
|
+
客户端那半是拿"挂载行的模块名 + 解析基址"去找 `package.json` 的,若按包名从工作区目录往上找
|
|
146
|
+
不到 `node_modules`,它会静默跳过,设置页就永远不出现。改成路径后走 `nearestPackage`,直接命中。
|
|
147
|
+
|
|
148
|
+
改完代码要生效:在插件页卸掉再装一次(模块是加载时读的,不是每次都读盘)。
|
|
101
149
|
|
|
102
150
|
## 已知边界
|
|
103
151
|
|
|
104
152
|
- **只管"在干什么",管不了"要不要回"**:上课时收到消息还是会回,只是知道自己在课上。
|
|
105
|
-
-
|
|
153
|
+
- **工作区过滤已做**:`工作区` 留空仍然全注,填上就只注那几个目录。
|
|
106
154
|
- **子代理不注入**:只挂在 `agents.roots()`,刷 B 站那种分身看不见本体在不在上课。
|
|
107
155
|
- **节日是公历表**:农历节日(春节、中秋)按你这几年实际的日期填成"只那几天"。
|
|
156
|
+
|
|
157
|
+
## 反馈
|
|
158
|
+
|
|
159
|
+
- 装不上 / 用不对:先看上面的「排错」和「已知边界」;
|
|
160
|
+
- 还是不行就开 [issue](https://github.com/Vansnc/dsh-feiyu-life/issues),按模板把版本和日志带上;
|
|
161
|
+
- 想改代码看 [CONTRIBUTING.md](./CONTRIBUTING.md)。
|
package/index.js
CHANGED
|
@@ -12,13 +12,52 @@
|
|
|
12
12
|
// POST /dsh-feiyu-life/save 存配置(整份替换)
|
|
13
13
|
// GET /dsh-feiyu-life/preview 指定时间预览(?ts=毫秒时间戳)
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
16
|
+
import { 读配置, 存配置, 生成, CONFIG_PATH, 时区现在, 今日日历 } from './life.js'
|
|
17
|
+
import { 日程类型, 每日剧本, 剧本路径, 写剧本, 改剧本 } from './plan.js'
|
|
18
|
+
import { 用模型写一天 } from './gen.js'
|
|
16
19
|
|
|
17
20
|
export const name = 'feiyu-life'
|
|
18
|
-
export const inject = ['systemPrompt', 'agents', 'timer', 'webServer']
|
|
21
|
+
export const inject = ['systemPrompt', 'agents', 'timer', 'webServer', 'llm', 'tools']
|
|
19
22
|
|
|
20
23
|
const 路由前缀 = '/dsh-feiyu-life'
|
|
21
24
|
|
|
25
|
+
/** 经期第几天(0 = 不在) */
|
|
26
|
+
function 经期天(cfg, ymd) {
|
|
27
|
+
const q = cfg.经期 || {}
|
|
28
|
+
const 起 = /^\d{4}-\d{2}-\d{2}$/.test(String(q.起始 || '')) ? Date.parse(String(q.起始) + 'T00:00:00Z') : NaN
|
|
29
|
+
if (!Number.isFinite(起)) return 0
|
|
30
|
+
const 今 = Date.parse(ymd + 'T00:00:00Z')
|
|
31
|
+
if (!Number.isFinite(今)) return 0
|
|
32
|
+
const 天 = Math.floor((今 - 起) / 86400000)
|
|
33
|
+
const 周 = Math.max(1, Math.round(Number(q.周期) || 29))
|
|
34
|
+
const 长 = Math.max(1, Math.round(Number(q.天数) || 5))
|
|
35
|
+
return ((天 % 周) + 周) % 周 < 长 ? ((天 % 周) + 周) % 周 + 1 : 0
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** 写剧本时告诉模型的「身体/状态」 */
|
|
39
|
+
function 身体提示(cfg, t) {
|
|
40
|
+
const 经 = 经期天(cfg, t.ymd)
|
|
41
|
+
if (经 && 经 <= 3) return '经期头几天,腰酸、想吃甜的、没力气'
|
|
42
|
+
if (经) return '经期后段,肚子还坠着'
|
|
43
|
+
return ''
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** 最近三天剧本摘要,避免天天一样 */
|
|
47
|
+
function 最近摘要(cfg, t) {
|
|
48
|
+
const 行 = []
|
|
49
|
+
for (let i = 1; i <= 3; i++) {
|
|
50
|
+
const d = new Date(Date.parse(t.ymd + 'T00:00:00Z') - i * 86400000).toISOString().slice(0, 10)
|
|
51
|
+
try {
|
|
52
|
+
const j = JSON.parse(readFileSync(剧本路径(d), 'utf8'))
|
|
53
|
+
const 标题 = j.title || (j.type && j.type.名) || ''
|
|
54
|
+
const 段 = (j.items || []).slice(0, 3).map((x) => x.在).join('、')
|
|
55
|
+
行.push(`- ${d}:${标题}${段 ? '(' + 段 + '…)' : ''}`)
|
|
56
|
+
} catch { /* 没有就算了 */ }
|
|
57
|
+
}
|
|
58
|
+
return 行.join('\n')
|
|
59
|
+
}
|
|
60
|
+
|
|
22
61
|
export function apply(ctx) {
|
|
23
62
|
const mounted = new Map()
|
|
24
63
|
|
|
@@ -29,13 +68,120 @@ export function apply(ctx) {
|
|
|
29
68
|
try { return ctx.agents.list() || [] } catch (e) { return [] }
|
|
30
69
|
}
|
|
31
70
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
71
|
+
/** 这个会话在不在「要注入」的工作区名单里;名单空 = 全都注 */
|
|
72
|
+
const 属于工作区 = (cfg, cwd) => {
|
|
73
|
+
const list = Array.isArray(cfg.工作区) ? cfg.工作区.filter((x) => typeof x === 'string' && x.trim()) : []
|
|
74
|
+
if (!list.length) return true
|
|
75
|
+
if (!cwd) return false
|
|
76
|
+
return list.some((x) => {
|
|
77
|
+
const 头 = String(x).replace(/[\\/]+$/, '')
|
|
78
|
+
return cwd === 头 || cwd.startsWith(头 + '/') || cwd.startsWith(头 + '\\')
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const 钟点 = (分) => {
|
|
83
|
+
const v = ((Math.round(分) % 1440) + 1440) % 1440
|
|
84
|
+
return `${String(Math.floor(v / 60)).padStart(2, '0')}:${String(v % 60).padStart(2, '0')}`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const 挂 = (agent) => {
|
|
88
|
+
const cwd = String((agent && agent.session && agent.session.cwd) || '')
|
|
89
|
+
const 卸 = []
|
|
90
|
+
卸.push(agent.ctx.systemPrompt.context({
|
|
91
|
+
name: 'feiyu-life',
|
|
92
|
+
order: 880,
|
|
93
|
+
text: () => {
|
|
94
|
+
try {
|
|
95
|
+
const cfg = 读配置()
|
|
96
|
+
if (!属于工作区(cfg, cwd)) return ''
|
|
97
|
+
return 生成(cfg).text
|
|
98
|
+
} catch (e) { return '' }
|
|
99
|
+
},
|
|
100
|
+
}))
|
|
101
|
+
// 她可以临时改主意:改今天的安排(改完下一轮注入就变)
|
|
102
|
+
try {
|
|
103
|
+
const off = agent.ctx.tools.register({
|
|
104
|
+
name: 'life_adjust',
|
|
105
|
+
description: '临时改今天的安排(赖床、出门、被叫走、加班)。只在你真的改主意时用;回复里别提到这个工具。',
|
|
106
|
+
parameters: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
在: { type: 'string', description: '改成在做什么(短句,例如:在便利店买布丁)' },
|
|
110
|
+
从: { type: 'string', description: '从几点开始(HH:MM,不填=现在)' },
|
|
111
|
+
时长分钟: { type: 'number', description: '持续多少分钟,默认 90' },
|
|
112
|
+
},
|
|
113
|
+
required: ['在'],
|
|
114
|
+
additionalProperties: false,
|
|
115
|
+
},
|
|
116
|
+
output: {
|
|
117
|
+
schema: { type: 'object', properties: { ok: { type: 'boolean' }, 说: { type: 'string' } }, additionalProperties: true },
|
|
118
|
+
render: (_a, v) => [{ type: 'text', text: String((v && v.说) || '') }],
|
|
119
|
+
},
|
|
120
|
+
async execute(参数 = {}) {
|
|
121
|
+
try {
|
|
122
|
+
const cfg = 读配置()
|
|
123
|
+
const t = 时区现在(new Date(), String(cfg.时区 || 'Asia/Shanghai'))
|
|
124
|
+
const 在 = String(参数.在 || '').trim().slice(0, 24)
|
|
125
|
+
if (!在) return { ok: false, 说: '没说要改成什么' }
|
|
126
|
+
let 起 = t.分
|
|
127
|
+
const m = /^(\d{1,2}):(\d{2})$/.exec(String(参数.从 || '').trim())
|
|
128
|
+
if (m) 起 = Number(m[1]) * 60 + Number(m[2])
|
|
129
|
+
const 时长 = Math.max(15, Math.min(360, Number(参数.时长分钟) || 90))
|
|
130
|
+
const d = 改剧本(t.ymd, 起, { 起, 止: Math.min(1440, 起 + 时长), 在, 手机: '在手', 穿: '' })
|
|
131
|
+
return d ? { ok: true, 说: `记下了:${钟点(起)} 起,${在}` } : { ok: false, 说: '今天还没有剧本,改不了' }
|
|
132
|
+
} catch (e) { return { ok: false, 说: '改失败:' + String((e && e.message) || e) } }
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
if (typeof off === 'function') 卸.push(off)
|
|
136
|
+
} catch (e) { /* 工具注册失败不影响注入 */ }
|
|
137
|
+
return () => { for (const f of 卸) { try { f() } catch {} } }
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ── 每日剧本:一天写一次(模型写,失败退模板)──
|
|
141
|
+
const 在写 = new Set()
|
|
142
|
+
const 查模型用的会话 = () => {
|
|
143
|
+
try {
|
|
144
|
+
const roots = (typeof ctx.agents.roots === 'function' ? ctx.agents.roots() : ctx.agents.list()) || []
|
|
145
|
+
return roots[0]
|
|
146
|
+
} catch { return undefined }
|
|
147
|
+
}
|
|
148
|
+
const 确保剧本 = async (now) => {
|
|
149
|
+
const cfg = 读配置()
|
|
150
|
+
const tz = String(cfg.时区 || 'Asia/Shanghai')
|
|
151
|
+
for (const 偏移 of [0, 1]) {
|
|
152
|
+
const when = 偏移 === 0 ? now : new Date(now.getTime() + 86400000)
|
|
153
|
+
const t = 时区现在(when, tz)
|
|
154
|
+
if (existsSync(剧本路径(t.ymd))) continue
|
|
155
|
+
if (在写.has(t.ymd)) continue
|
|
156
|
+
在写.add(t.ymd)
|
|
157
|
+
;(async () => {
|
|
158
|
+
try {
|
|
159
|
+
const 日历 = 今日日历(cfg, t)
|
|
160
|
+
const 类型 = 日程类型(cfg, t, 日历)
|
|
161
|
+
const agent = 查模型用的会话()
|
|
162
|
+
let r = null
|
|
163
|
+
if (agent) {
|
|
164
|
+
r = await 用模型写一天(ctx, agent, {
|
|
165
|
+
cfg, date: t.ymd, 周: t.周, 类型, 日历,
|
|
166
|
+
课表: ((cfg.课表 || {})[t.周] || []).map((x) => [x[0], x[1], x[2]]),
|
|
167
|
+
身体: 身体提示(cfg, t),
|
|
168
|
+
最近: 最近摘要(cfg, t),
|
|
169
|
+
})
|
|
170
|
+
}
|
|
171
|
+
if (r) {
|
|
172
|
+
写剧本(t.ymd, { type: 类型, title: r.title, mood: r.mood, items: r.items, source: 'llm', model: r.model })
|
|
173
|
+
try { console.log('[feiyu-life] 剧本已生成(模型):' + t.ymd) } catch {}
|
|
174
|
+
} else {
|
|
175
|
+
const 兜底 = 每日剧本(cfg, t, 日历, {}, 类型)
|
|
176
|
+
写剧本(t.ymd, { type: 类型, title: 兜底.title || '', mood: '', items: 兜底.items, source: 'template' })
|
|
177
|
+
try { console.log('[feiyu-life] 剧本用模板兜底:' + t.ymd) } catch {}
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
try { console.log('[feiyu-life] 写剧本失败:' + String((e && e.message) || e)) } catch {}
|
|
181
|
+
} finally { 在写.delete(t.ymd) }
|
|
182
|
+
})()
|
|
183
|
+
}
|
|
184
|
+
}
|
|
39
185
|
|
|
40
186
|
const tick = () => {
|
|
41
187
|
const list = 会话们()
|
|
@@ -59,6 +205,8 @@ export function apply(ctx) {
|
|
|
59
205
|
})
|
|
60
206
|
|
|
61
207
|
tick()
|
|
208
|
+
try { setTimeout(() => { 确保剧本(new Date()).catch(() => {}) }, 8000) } catch {}
|
|
209
|
+
try { ctx.effect(() => ctx.interval(() => { 确保剧本(new Date()).catch(() => {}) }, 20 * 60 * 1000)) } catch {}
|
|
62
210
|
|
|
63
211
|
// ── 设置页的三条接口 ────────────────────────────────────────────────
|
|
64
212
|
const 只认本人 = (handler) => async (req, res) => {
|
package/life.js
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
// 层级优先级(高 → 低):特殊(考试周)→ 假期 → 学期;作息表:特殊 > 假期 > 晚起日 > 日常。
|
|
21
21
|
|
|
22
22
|
import { readFileSync, writeFileSync, mkdirSync, statSync, renameSync } from 'node:fs'
|
|
23
|
+
import { 日程类型, 每日剧本, 找此刻 } from './plan.js'
|
|
23
24
|
import { join, dirname } from 'node:path'
|
|
24
25
|
import { homedir } from 'node:os'
|
|
25
26
|
|
|
@@ -32,6 +33,8 @@ const 手机们 = ['在手', '静音', '在床头', '不在手边']
|
|
|
32
33
|
export const 默认配置 = {
|
|
33
34
|
总开关: true,
|
|
34
35
|
时区: 'Asia/Shanghai',
|
|
36
|
+
// 只在这些目录的会话里注入(留空 = 所有顶层会话)。别的活儿不该看见「你在上课」。
|
|
37
|
+
工作区: [],
|
|
35
38
|
|
|
36
39
|
经期: { 起始: '2026-11-05', 周期: 29, 天数: 5 },
|
|
37
40
|
|
|
@@ -65,7 +68,8 @@ export const 默认配置 = {
|
|
|
65
68
|
// ── 日:四张作息表 ────────────────────────────────────────────────
|
|
66
69
|
日常: [
|
|
67
70
|
['00:00', '01:30', '躺床上刷手机', '在手'],
|
|
68
|
-
['01:30', '
|
|
71
|
+
['01:30', '02:00', '刚关灯,还在刷手机', '在手'],
|
|
72
|
+
['02:00', '08:30', '睡着了', '在床头'],
|
|
69
73
|
['08:30', '09:10', '刚起,脸还有点肿', '在手'],
|
|
70
74
|
['09:10', '11:40', '在宿舍磨蹭,或者去自习', '在手'],
|
|
71
75
|
['11:40', '12:40', '食堂吃饭', '在手'],
|
|
@@ -326,57 +330,107 @@ function 临时动作(t) {
|
|
|
326
330
|
return 池[Math.floor(r() * 池.length) % 池.length]
|
|
327
331
|
}
|
|
328
332
|
|
|
333
|
+
/**
|
|
334
|
+
* 今日底色:不改心情数值,只给她一句「今天整个人是什么状态」。
|
|
335
|
+
* 用来补上「心情只听对话」那个洞——身上不舒服的时候,她说话自然会短、会蔫。
|
|
336
|
+
* 优先顺序:经期头两天 > 着凉 > 熬夜 > 今天有好事 > 平常(不出声)
|
|
337
|
+
*/
|
|
338
|
+
function 今日底色(经, 生病, 困, 好事) {
|
|
339
|
+
// 生病不另说一句:上面「今天」里已经写了嗓子紧/着凉,再说一遍就是复读
|
|
340
|
+
if (经 === 1 || 经 === 2) return '整个人有点蔫'
|
|
341
|
+
if (困) return '眼皮沉'
|
|
342
|
+
if (好事) return '心情还不错'
|
|
343
|
+
return ''
|
|
344
|
+
}
|
|
345
|
+
|
|
329
346
|
/** 压成两行,附「为什么这么算」 */
|
|
330
347
|
export function 生成(cfg, now = new Date()) {
|
|
331
348
|
const 空 = { text: '', 依据: [] }
|
|
332
349
|
if (!cfg || cfg.总开关 === false) return 空
|
|
333
|
-
const
|
|
350
|
+
const tz = String(cfg.时区 || 'Asia/Shanghai')
|
|
351
|
+
const t = 时区现在(now, tz)
|
|
334
352
|
const 日历 = 今日日历(cfg, t)
|
|
335
353
|
const 偏离 = 今日偏离(cfg, t, 日历.作息表)
|
|
336
|
-
const
|
|
354
|
+
const 类型 = 日程类型(cfg, t, 日历)
|
|
355
|
+
const 剧本 = 每日剧本(cfg, t, 日历, 偏离, 类型)
|
|
356
|
+
const 在 = 找此刻(剧本.items, t.分) || { 在: '闲着', 手机: '在手', 穿: '' }
|
|
337
357
|
|
|
338
358
|
const 依据 = []
|
|
339
359
|
依据.push(日历.特殊 ? `${日历.特殊.名}第 ${日历.第几天} 天`
|
|
340
360
|
: 日历.假期 ? `${日历.假期.名}第 ${日历.第几天} 天`
|
|
341
|
-
: (日历.节日 && 日历.节日.起) ? `${日历.节日.名}
|
|
361
|
+
: (日历.节日 && 日历.节日.起) ? `${日历.节日.名}放假`
|
|
342
362
|
: 日历.学期 ? `学期中(${日历.学期.名})`
|
|
343
363
|
: '不在校历里,按平常走')
|
|
344
|
-
依据.push(
|
|
345
|
-
依据.push(`此刻命中:${在.在}(手机${在.手机})`)
|
|
364
|
+
依据.push(`日子类型:${类型.名}|作息表:${日历.作息表}`)
|
|
365
|
+
依据.push(`此刻命中:${在.在}(手机${在.手机 || '在手'}${在.穿 ? ',穿' + 在.穿 : ''})`)
|
|
346
366
|
if (偏离.躺平) 依据.push('今天没按表走:躺平')
|
|
347
|
-
if (偏离.出门) 依据.push('今天没按表走:出门')
|
|
348
367
|
if (偏离.翘下午) 依据.push('今天没按表走:翘了下午的课')
|
|
349
368
|
|
|
350
|
-
|
|
351
|
-
if (!/睡/.test(在.在) && !偏离.躺平) 此刻行 += 小时变体(t, 在.在) + 临时动作(t)
|
|
352
|
-
此刻行 += '。'
|
|
353
|
-
|
|
369
|
+
// ── 今天这一行:日子类型 + 身上的状况 ──
|
|
354
370
|
const r = 摇(种子(t.ymd, 'sleep'))
|
|
355
371
|
const 睡点 = [60, 120, 150][Math.floor(r() * 3) % 3]
|
|
356
372
|
const 起 = 起床点(cfg, t, 日历)
|
|
357
373
|
const 困 = 起 - 睡点 < 360
|
|
358
374
|
const 经 = 经期第几天(cfg, t.ymd)
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
375
|
+
const 着凉 = r() < 0.08 && [3, 4, 10, 11].includes(t.月)
|
|
376
|
+
const 小事们 = 今天的小事(cfg, t, !日历.放假)
|
|
377
|
+
|
|
378
|
+
const 状况 = []
|
|
379
|
+
if (困 && t.分 < 15 * 60) 状况.push(`昨晚${睡点 === 60 ? '一点' : 睡点 === 120 ? '两点' : '两点半'}才睡`)
|
|
380
|
+
if (经) 状况.push(经 <= 3 ? '腰有点酸' : '肚子还坠着')
|
|
381
|
+
if (着凉) 状况.push('嗓子有点紧')
|
|
382
|
+
for (const 文 of 小事们) 状况.push(文)
|
|
383
|
+
const 好事 = 小事们.some((x) => /夸|猫|寄的/.test(x))
|
|
384
|
+
const 底色 = 今日底色(经, 着凉, 困, 好事)
|
|
385
|
+
if (底色) 状况.push(底色)
|
|
386
|
+
|
|
387
|
+
const 行们 = []
|
|
388
|
+
行们.push(`(今天)${t.月}月${t.日}日 ${周名(t.周)}·${类型.名}${状况.length ? '。' + 状况.slice(0, 2).join(';') : '。'}。`)
|
|
389
|
+
|
|
390
|
+
// ── 此刻 ──
|
|
391
|
+
let 此刻行 = `(此刻)${在.在}`
|
|
392
|
+
if (在.手机 && 在.手机 !== '在手') 此刻行 += 手机说[在.手机] || ''
|
|
393
|
+
if (在.穿 && !/睡/.test(在.在)) 此刻行 += `,身上是${在.穿}`
|
|
394
|
+
if (!/睡/.test(在.在) && !偏离.躺平) 此刻行 += 小时变体(t, 在.在) + 临时动作(t)
|
|
395
|
+
行们.push(此刻行 + '。')
|
|
396
|
+
|
|
397
|
+
// ── 早些时候 / 接下来 ──
|
|
398
|
+
const 早 = 剧本.items.filter((x) => x.止 <= t.分 && x.止 > t.分 - 360 && !/睡/.test(x.在)).slice(-2)
|
|
399
|
+
if (早.length) 行们.push(`(早些时候)${早.map((x) => x.在).join(',然后')}。`)
|
|
400
|
+
const 后 = 剧本.items.filter((x) => x.起 > t.分 && !/睡/.test(x.在)).slice(0, 1)
|
|
401
|
+
if (后.length) 行们.push(`(接下来)${分钟说(后[0].起)} ${后[0].在}。`)
|
|
402
|
+
|
|
403
|
+
// ── 傍晚以后附上明天 ──
|
|
404
|
+
if (t.hh >= 18) {
|
|
405
|
+
const 明 = 时区现在(new Date(now.getTime() + 86400000), tz)
|
|
406
|
+
const 明日历 = 今日日历(cfg, 明)
|
|
407
|
+
const 明类型 = 日程类型(cfg, 明, 明日历)
|
|
408
|
+
const 明剧本 = 每日剧本(cfg, 明, 明日历, {}, 明类型)
|
|
409
|
+
const 第一醒 = 明剧本.items.find((x) => x.起 >= 6 * 60 && !/睡/.test(x.在))
|
|
410
|
+
行们.push(`(明天)${周名(明.周)}·${明类型.名}${第一醒 ? `,${分钟说(第一醒.起)} ${第一醒.在}` : ''}。`)
|
|
363
411
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
412
|
+
|
|
413
|
+
// ── 怎么把这段带进聊天(借 daily-schedule 的思路)──
|
|
414
|
+
行们.push('(说话)这些是你自己的日子,别当时间表念:不说"按日程/计划/安排",不报时间段、不列清单;他问起就像闲聊挑一两件说,带点感受。')
|
|
415
|
+
return {
|
|
416
|
+
text: 行们.join('\n'),
|
|
417
|
+
依据,
|
|
418
|
+
此刻: 在,
|
|
419
|
+
日历,
|
|
420
|
+
偏离,
|
|
421
|
+
类型,
|
|
422
|
+
今天: 状况,
|
|
423
|
+
剧本,
|
|
369
424
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
return { text: 拼(), 依据, 此刻: 在, 日历, 偏离, 今天: 排 }
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
function 周名(n) {
|
|
428
|
+
return ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日'][n] || ''
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function 分钟说(分) {
|
|
432
|
+
const m = ((Math.round(分) % 1440) + 1440) % 1440
|
|
433
|
+
return `${String(Math.floor(m / 60)).padStart(2, '0')}:${String(m % 60).padStart(2, '0')}`
|
|
380
434
|
}
|
|
381
435
|
|
|
382
436
|
let 缓存 = { at: 0, cfg: null }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-feiyu-life",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "大肥鱼的生活线(DSH 插件):每天用模型写一份全天剧本(在哪、做什么、穿什么),注入此刻/早些时候/接下来,带设置页。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Vansnc",
|
|
@@ -15,12 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"dsh",
|
|
18
|
+
"dsh-plugin",
|
|
18
19
|
"deepseek-harness",
|
|
19
|
-
"plugin",
|
|
20
|
-
"agent",
|
|
21
20
|
"companion",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
21
|
+
"life",
|
|
22
|
+
"persona"
|
|
24
23
|
],
|
|
25
24
|
"engines": {
|
|
26
25
|
"node": ">=22"
|
|
@@ -50,8 +49,12 @@
|
|
|
50
49
|
},
|
|
51
50
|
"client": {
|
|
52
51
|
"platform": "web",
|
|
53
|
-
"inject": [
|
|
54
|
-
|
|
52
|
+
"inject": [
|
|
53
|
+
"slots"
|
|
54
|
+
],
|
|
55
|
+
"external": [
|
|
56
|
+
"react"
|
|
57
|
+
]
|
|
55
58
|
},
|
|
56
59
|
"engines": {
|
|
57
60
|
"dsh": ">=0.2.0-rc.1"
|
|
@@ -60,4 +63,4 @@
|
|
|
60
63
|
"publishConfig": {
|
|
61
64
|
"access": "public"
|
|
62
65
|
}
|
|
63
|
-
}
|
|
66
|
+
}
|