dsh-plugin-maoxuan-pet 0.0.0-stage → 0.2.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/LICENSE +37 -0
  3. package/NOTICE +29 -0
  4. package/README.md +187 -2
  5. package/assets/PROVENANCE.md +92 -0
  6. package/assets/icon.svg +17 -0
  7. package/assets/pet-blink.png +0 -0
  8. package/assets/pet-idle.png +0 -0
  9. package/assets/pet-read.png +0 -0
  10. package/assets/pet-talk.png +0 -0
  11. package/client.js +496 -0
  12. package/cordis.patch.yml +86 -0
  13. package/corpus/.catalog.json +2634 -0
  14. package/corpus/README.md +122 -0
  15. package/corpus/articles/bi-xu-zhu-yi-jing-ji-gong-zuo.md +35 -0
  16. package/corpus/articles/dang-wei-hui-de-gong-zuo-fang-fa.md +39 -0
  17. package/corpus/articles/fan-dui-ben-ben-zhu-yi.md +129 -0
  18. package/corpus/articles/fan-dui-dang-ba-gu.md +105 -0
  19. package/corpus/articles/fan-dui-zi-you-zhu-yi.md +57 -0
  20. package/corpus/articles/gai-zao-wo-men-de-xue-xi.md +75 -0
  21. package/corpus/articles/guan-xin-qun-zhong-sheng-huo-zhu-yi-gong-zuo-fang-fa.md +39 -0
  22. package/corpus/articles/guan-yu-jiu-zheng-dang-nei-de-cuo-wu-si-xiang.md +155 -0
  23. package/corpus/articles/guan-yu-ling-dao-fang-fa-de-ruo-gan-wen-ti.md +33 -0
  24. package/corpus/articles/guan-yu-zheng-que-chu-li-ren-min-nei-bu-mao-dun-de-wen-ti.md +183 -0
  25. package/corpus/articles/hu-nan-nong-min-yun-dong-kao-cha-bao-gao.md +207 -0
  26. package/corpus/articles/ji-nian-bai-qiu-en.md +23 -0
  27. package/corpus/articles/jiang-ge-ming-jin-xing-dao-di.md +43 -0
  28. package/corpus/articles/kang-ri-zhan-zheng-sheng-li-hou-de-shi-ju-he-wo-men-de-fang-zhen.md +51 -0
  29. package/corpus/articles/lun-chi-jiu-zhan.md +337 -0
  30. package/corpus/articles/lun-lian-he-zheng-fu.md +523 -0
  31. package/corpus/articles/lun-ren-min-min-zhu-zhuan-zheng.md +89 -0
  32. package/corpus/articles/lun-shi-da-guan-xi.md +195 -0
  33. package/corpus/articles/mao-dun-lun.md +251 -0
  34. package/corpus/articles/mei-guo-ji-zhe-an-na-liu-yi-si-si-te-lang-de-tan-hua.md +59 -0
  35. package/corpus/articles/mu-qian-xing-shi-he-wo-men-de-ren-wu.md +47 -0
  36. package/corpus/articles/nong-cun-diao-cha-de-xu-yan-he-ba.md +35 -0
  37. package/corpus/articles/qing-nian-yun-dong-de-fang-xiang.md +31 -0
  38. package/corpus/articles/shi-jian-lun.md +69 -0
  39. package/corpus/articles/wei-ren-min-fu-wu.md +25 -0
  40. package/corpus/articles/wu-si-yun-dong.md +25 -0
  41. package/corpus/articles/xing-xing-zhi-huo-ke-yi-liao-yuan.md +51 -0
  42. package/corpus/articles/yu-gong-yi-shan.md +27 -0
  43. package/corpus/articles/zhan-zheng-he-zhan-lue-wen-ti.md +93 -0
  44. package/corpus/articles/zheng-dun-dang-de-zuo-feng.md +105 -0
  45. package/corpus/articles/zhong-guo-de-hong-se-zheng-quan-wei-shi-me-neng-gou-cun-zai.md +45 -0
  46. package/corpus/articles/zhong-guo-ge-ming-zhan-zheng-de-zhan-lue-wen-ti.md +513 -0
  47. package/corpus/articles/zhong-guo-she-hui-ge-jie-ji-de-fen-xi.md +33 -0
  48. package/corpus/index.json +606 -0
  49. package/docs/API-CONTRACT.md +212 -0
  50. package/docs/CONTENT-FRAMEWORK.md +91 -0
  51. package/docs/INSTALL.md +105 -0
  52. package/docs/RELEASE.md +94 -0
  53. package/docs/preview-v3.png +0 -0
  54. package/index.js +1078 -0
  55. package/package.json +78 -4
  56. package/scripts/audit-corpus-coverage.mjs +63 -0
  57. package/skill/maoxuan-vademecum/SKILL.md +88 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.0 — 2026-11-01
4
+
5
+ 首个公开版本。
6
+
7
+ ### 宠物与气泡
8
+ - 悬浮宠物「鲸鱼娘·小毛」:4 帧立绘(idle / talk / blink / read),Web `shell.overlay` 渲染,可拖拽、位置本地记忆。
9
+ - 红皮书气泡:深红封面 + 烫金书脊 + 米白内文;卡片绝对定位在宠物左侧,开合不移动宠物(宠物贴左边缘时自动翻到右侧)。
10
+ - 打开即已读:卡片显示的那一刻才标已读,右上角未读数随之消失;正在读的那条会被钉住,不会被新数据替换。
11
+ - 全部已读后仍停在上一次产出,`‹ ›` 可往回翻历史。
12
+ - 定时生成的新气泡自动弹出;手动关闭后不会自己重开。
13
+ - `收起` / `再督促` 为纯文字按钮;滚动条为烫金滑块 + 深红轨道。
14
+
15
+ ### 内容
16
+ - 单条气泡 = 引文 + 一句督促 + 启示,**合计 ≤200 字**(`fitLesson` 保证)。
17
+ - 三种取材模板轮转:`quote` 金句 / `excerpt` 文章节选(逐字整句)/ `summary` 小毛概括;游标 `templateCursor` 落盘,不因历史条数封顶而卡住。
18
+ - 启示落点六选一:客户 / 项目 / 组织 / 现金流 / 决策 / 自律;「人事」已按用户裁决改名为「组织」,旧状态文件读取时自动迁移。
19
+ - 反编造:`quote`/`excerpt` 必须逐字命中语料全文(`isVerbatim`,去空白兜底),否则降级为 `summary`;`summary` 永不回退成篇名。
20
+ - 模型复述原文的 `pua` 会被识别(≥8 字公共串)并整条丢弃。
21
+ - 无凭据 / 超时 / 非 JSON 时降级为本地摘录,UI 在页脚标注「离线摘录」,不冒充模型生成。
22
+
23
+ ### Host
24
+ - 5 条同源路由:`state` / `generate` / `dismiss` / `asset` / `corpus`;状态文件原子写(`.tmp` + `rename`)。
25
+ - 每小时生成一次,支持 `quietHours`、`everySeconds`、`maxBubbles`、`headless` 开关与子进程超时;并发手动触发时同步抢占 in-flight 位。
26
+ - 运行时把 `corpus/` 注册为 `maoxuan-vademecum` skill,preset `maoxuan-pet`(毛选创业参谋)= persona + skill + 工具。
27
+
28
+ ### 语料与素材
29
+ - 33 篇毛选全文(中文马克思主义文库公开电子文本),`corpus/index.json` 记录 `sourceUrl` 与版本;`verified: true` 的条目才参与轮转。
30
+ - 语料覆盖审计:`node scripts/audit-corpus-coverage.mjs`(金句逐字命中 33/33,节选可用 32/33)。
31
+
32
+ ### 验证
33
+ - `verify/smoke.mjs`(24 项)、`verify/contract.mjs`(38 项)、`verify/host.test.mjs`(18 项):不联网、不起子进程、不花模型调用。
34
+ - 真实环境做过 headless 生成 + headless Chrome/CDP 页面断言(宠物坐标不变、卡片在左、chip 暖色、按钮无盒、已读徽标消失、无未读仍有内容)。
35
+
36
+ ### 已知限制
37
+ - 只支持 Web 界面(`dsh.client.platform: web`)。
38
+ - 定时器只在 `dsh web` 进程存活时运行,进程停掉不补跑。
39
+ - 每次生成是独立的 headless 会话,不共享上下文;用最近 6 条督促避免重复。
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-maoxuan-pet contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ---
24
+
25
+ Third-party content notice:
26
+
27
+ `corpus/` bundles public electronic texts of Mao Zedong's writings collected
28
+ from the public archive 中文马克思主义文库 (https://www.marxists.org/chinese/).
29
+ Copyright in those texts belongs to their respective rights holders; they are
30
+ included here only for personal study and research, with source URLs recorded
31
+ in `corpus/index.json` and `corpus/README.md`. This project claims no rights in
32
+ them and does not sell them.
33
+
34
+ The pet artwork in `assets/` is AI-generated fan art of DeepSeek's unofficial
35
+ "whale girl" community mascot, dressed in a period Red Army uniform. It is not
36
+ official DeepSeek material and is not endorsed by DeepSeek. See
37
+ `assets/PROVENANCE.md`.
package/NOTICE ADDED
@@ -0,0 +1,29 @@
1
+ # NOTICE
2
+
3
+ dsh-plugin-maoxuan-pet
4
+ Copyright (c) 2026 Yuna and contributors
5
+
6
+ 本文件说明本仓库里**不属于 MIT 许可**的内容。代码本体见 [LICENSE](LICENSE)。
7
+
8
+ ## 1. 内置毛选语料(`corpus/`)
9
+
10
+ - 来源:[中文马克思主义文库 · 毛泽东](https://www.marxists.org/chinese/maozedong/index.htm),抓取日期 2026-10-31,共 33 篇(`corpus/index.json` 记录每篇的 `sourceUrl`)。
11
+ - 著作权归原作者及原出版方所有。本项目对正文的收录**仅用于个人学习、研究**,不构成再出版、发行或商业授权。
12
+ - 若需在商业场景公开引用原文,请自行核对正式出版物并取得授权。
13
+ - **权利人若不希望文本随本包分发**:删除 `corpus/articles/` 即可;此时 `quote`/`excerpt` 模板会安全降级为 `summary`(插件不会编造原文),也可运行 `node scripts/fetch-corpus.mjs` 自行重新获取。
14
+ - 语料不参与 `npm` 之外的再分发声明,也不代表本项目对原文主张任何权利。
15
+
16
+ ## 2. 立绘与图标(`assets/`)
17
+
18
+ - `pet-idle.png` / `pet-talk.png` / `pet-blink.png` / `pet-read.png`:AI 生成(gpt-image-2,2026-10-31),形象为民间同人设定「鲸鱼娘·小毛」(红军制服、抱《毛泽东选集》)。
19
+ 生成过程与 prompt 记录见 [assets/PROVENANCE.md](assets/PROVENANCE.md)。
20
+ - `icon.svg`:手写 SVG(纯几何图形)。
21
+ - 与 DeepSeek 官方无任何隶属或背书关系。
22
+
23
+ ## 3. 名称与立场
24
+
25
+ 本插件是一个桌宠 / 阅读督促工具,把毛选当作**产品与创业方法论**的文本来源。它不代表 DeepSeek、毛泽东著作出版方或任何政治组织的立场,也不作政治宣传。
26
+
27
+ ## 4. 第三方依赖
28
+
29
+ 运行时只依赖宿主 `@deepseek-ai/dsh`(peer dependency)与 Node 内置模块;`verify/` 与 `scripts/` 不引入任何第三方包。
package/README.md CHANGED
@@ -1,3 +1,188 @@
1
- # Temporary Holding Version
1
+ # dsh-maoxuan-pet · 鲸鱼娘·小毛
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > 一只穿红军制服、抱着《毛泽东选集》的鲸鱼娘,住在 DSH 的 Web 界面右下角。
4
+ > 每小时读一篇毛选,把它变成一句针对**你的**创业处境的思想 + 一句督促,
5
+ > 并且随时可以开一个新会话问她:根据毛选,我这一步该怎么走。
6
+
7
+ | 需求 | 实现 |
8
+ |---|---|
9
+ | 宠物形态、鲸鱼娘、红军制服、手捧毛选 | `assets/` 里 4 帧 AI 立绘(idle / talk / blink / read,640×1348 RGBA,红封面竖排「毛泽东选集」可辨),`client.js` 在 `shell.overlay` 槽位渲染悬浮宠物 |
10
+ | 每小时帮我读毛选 | Host 定时器按小时读 `corpus/` 里的下一篇(轮转、避开刚读过的) |
11
+ | 每小时生成思想 / PUA 我的话,出现在气泡里 | 每次生成 `spawn` 一个 `dsh --profile headless` 对话,拿到结构化 JSON 后推给气泡 |
12
+ | 有个 preset,能直接问「根据毛选我该怎么做」 | `maoxuan-pet`「毛选创业参谋」preset + 运行时注册的 `maoxuan-vademecum` skill 指向内置语料 |
13
+
14
+ ## 它到底怎么工作
15
+
16
+ ```
17
+ ┌─ DSH Web (dsh web) ───────────────────────────────────────────┐
18
+ │ │
19
+ │ index.js (Host) │
20
+ │ ├─ 状态:$DSH_HOME/storages/dsh-maoxuan-pet.json (原子写) │
21
+ │ ├─ 定时器:ctx.timeout 链 → quietHours / dailyLimit 约束 │
22
+ │ ├─ 语料:corpus/index.json → 轮转挑一篇 verified 的 │
23
+ │ ├─ 生成:spawn `dsh --profile headless --json "<prompt>"` │
24
+ │ │ └ 失败/超时/非 JSON → 本地摘录降级(标注“离线摘录”) │
25
+ │ ├─ 路由:/api/dsh-maoxuan-pet.{state,generate,dismiss, │
26
+ │ │ asset,corpus} │
27
+ │ └─ skill:把 corpus/ 注册成 maoxuan-vademecum │
28
+ │ │
29
+ │ client.js (Web) │
30
+ │ └─ shell.overlay → 宠物 + 气泡,20s 轮询 / 生成中 3s 轮询 │
31
+ │ │
32
+ │ cordis.patch.yml │
33
+ │ ├─ 插件行 dsh-maoxuan-pet │
34
+ │ └─ preset-maoxuan-pet「毛选创业参谋」(persona + skill + 工具) │
35
+ └───────────────────────────────────────────────────────────────┘
36
+ ```
37
+
38
+ 气泡里的每条内容都是**结构化**的,而且**整条不超过 200 字**:
39
+
40
+ | 字段 | 含义 |
41
+ |---|---|
42
+ | `template` | 三种模板轮转:`quote` 金句 / `excerpt` 文章节选 / `summary` 小毛概括 |
43
+ | `cite` | 上面那一句(逐字核对过;`summary` 是小毛的概括,不加引号),带来源链接 |
44
+ | `axis` | 启示落点,六选一:客户 / 项目 / 组织 / 现金流 / 决策 / 自律 |
45
+ | `pua` | 小毛对你说的一句话(≤40 字,第一人称;**模型复述原文时会整条丢弃**,气泡只留引文 + 启示) |
46
+ | `lesson` | 启示:一条硬规则 + 怎么验证(≤100 字,围绕 `axis`) |
47
+ | `chars` | 引文 + pua + 启示的实际字数,Host 保证 ≤200 |
48
+ | `mode` | `headless` = 模型生成;`offline` = 本地摘录降级(UI 会标「离线摘录」) |
49
+
50
+ 框架是这样设计的(`template × axis` 矩阵,而不是每次同一套):
51
+
52
+ ```
53
+ 取材 3 种:原文金句 / 文章节选(逐字取整句)/ 小毛概括(模型自己概括)
54
+ 落点 6 种:客户 · 项目 · 组织 · 现金流 · 决策 · 自律
55
+ 语气 3 种:sharp 硬话 · calm 冷静 · urgent 催
56
+ ```
57
+
58
+ - 模板游标 `templateCursor` 持久化在状态里,按 3 种循环;不会因为历史条数封顶而卡住;
59
+ - `axis` 在 prompt 里指定,并尽量避开上一条的落点;
60
+ - 引文句式/节选都在 `corpus/articles/<id>.md` 里做 `isVerbatim` 逐字校验,校验不过就退到 `summary`,绝不编造;
61
+ - 所有字段最后过一遍 `fitLesson`,把「引文 + pua + 启示」压进 200 字。
62
+
63
+ 为什么落点是 6 类名词、而「动作」不单列一类、字数预算怎么分、真实生成样例长什么样,
64
+ 见 [docs/CONTENT-FRAMEWORK.md](docs/CONTENT-FRAMEWORK.md)。语料能不能支撑 Quote 模板,跑一条审计就知道:
65
+
66
+ ```bash
67
+ node scripts/audit-corpus-coverage.mjs # 33 篇:金句逐字命中 33/33,节选可用 32/33
68
+ ```
69
+
70
+ ### 界面行为(这一版按用户逐条反馈定的)
71
+
72
+ 截图见 [docs/preview-v3.png](docs/preview-v3.png)(红皮书卡片 + `‹ ›` 翻看 + 纯文字按钮)。
73
+
74
+ - **红皮书卡片**:深红封面 + 烫金书脊,正文米白;卡片里不出现蓝/紫/绿,落点 chip 用同一族暖金。滚动条也换成烫金滑块 + 深红轨道。
75
+ - **宠物不动**:卡片绝对定位在宠物左侧(宠物被拖到靠左边缘时自动翻到右侧),点开/收起只让气泡出现或消失,宠物坐标不变。
76
+ - **打开即已读**:卡片真正显示的那一刻才把这条标已读,宠物右上角的未读数随之消失;正在读的那条会被"钉住",Host 把 `current` 推进到下一条时,眼前的文字不会跳。
77
+ - **没有未读也有内容**:全部读过后再点开,仍然停在上一次产出的那张卡,`‹ ›` 可以往前翻历史。
78
+ - **定时弹出**:整点生成的新气泡会自己弹出来;手动关掉的那条不会自己再弹,等下一条。
79
+ - **按钮无盒子**:`收起` / `再督促` 是纯文字 + 下划线,没有背景和边框。
80
+
81
+ ## 安装
82
+
83
+ 从 npm(推荐):
84
+
85
+ ```bash
86
+ dsh plugin --profile web add dsh-plugin-maoxuan-pet
87
+ # 然后 Ctrl+C 停掉 dsh web,再重新 `dsh web`,刷新页面
88
+ ```
89
+
90
+ 从源码(本目录):
91
+
92
+ ```bash
93
+ node install.mjs --dry-run # 先看要改什么
94
+ node install.mjs # 写入 profile 清单 + pnpm link
95
+ ```
96
+
97
+ 两种方式装完都要**手动重启** `dsh web`(Ctrl+C 后重新 `dsh web`),刷新页面。
98
+
99
+ 完整步骤、回滚、排错见 [docs/INSTALL.md](docs/INSTALL.md);内部接口见 [docs/API-CONTRACT.md](docs/API-CONTRACT.md)。
100
+
101
+ ### 长什么样
102
+
103
+ ![红皮书气泡](docs/preview-v3.png)
104
+
105
+ 深红封面 + 烫金书脊的气泡挂在宠物左侧;打开即已读,`‹ ›` 可以往回翻历史;
106
+ 定时生成的新气泡会自己弹出来。
107
+
108
+ ## 配置
109
+
110
+ ```yaml
111
+ - id: dsh-maoxuan-pet
112
+ config:
113
+ enabled: true
114
+ everySeconds: 3600 # 每小时
115
+ firstDelaySeconds: 90 # 启动后 90s 先来一次
116
+ quietHours: [2, 8] # 本地时间 02:00–08:00 不打扰
117
+ dailyLimit: 24 # 每天最多生成次数(防失控)
118
+ maxBubbles: 40
119
+ headless: true # false = 只用本地摘录,不花模型调用
120
+ dshBin: dsh
121
+ profile: headless
122
+ timeoutMs: 180000
123
+ businessContext: |-
124
+ 用户是一位正在创业的独立开发者……
125
+ ```
126
+
127
+ ## 用 preset 问「根据毛选我应该怎么做」
128
+
129
+ 新建会话 → preset 选 **「毛选创业参谋」**(id `maoxuan-pet`)→ 直接问。它会:
130
+
131
+ 1. 加载 `maoxuan-vademecum` skill(知道语料在哪、怎么检索);
132
+ 2. 用 `read` 打开对应篇目**全文**,取逐字原文;
133
+ 3. 按固定结构回答:原文金句(篇名 + 时间)→ 当时的问题与论证 → 方法 → 你的处境 → 今天能做的一步;
134
+ 4. 核不到原文就明说,不编造。
135
+
136
+ `maoxuan-vademecum` skill 是运行时由 Host 注册的(内容来自 `skill/maoxuan-vademecum/SKILL.md` + 语料索引),所以它永远指向当前安装目录,不写死路径。
137
+
138
+ ## 毛选语料
139
+
140
+ - **33 篇,全部 `verified: true`**,覆盖第一至第五卷(目录页实际解析出 329 篇,按“与创业最相关”白名单取 33 篇全文);
141
+ - 来源:中文马克思主义文库公开电子文本(https://www.marxists.org/chinese/maozedong/index.htm),GB2312 页面按 gb18030 解码,逐篇记录 URL 与抓取时间;
142
+ - 结构:`corpus/index.json` 索引 + `corpus/articles/<id>.md` 全文;每条带 `quote`(逐字核对)、`summary`、`businessAngle`、`verified`;
143
+ - 重新抓取 / 扩充:`npm run corpus`(见 `scripts/fetch-corpus.mjs`);
144
+ - 版权:文本版权归原权利人,此处仅用于个人学习研究,不用于售卖,详见 `corpus/README.md` 与 `LICENSE`。
145
+
146
+ ## 开发与验证
147
+
148
+ ```bash
149
+ npm test # node verify/smoke.mjs
150
+ npm run test:contract
151
+ node verify/host.test.mjs # 假 ctx 端到端:路由、状态、降级、原子写
152
+ node --check index.js
153
+ node --check client.js
154
+ ```
155
+
156
+ 验证边界见 [verify/README.md](verify/README.md):单元与端到端测试不联网、不启动子进程、不花模型调用。
157
+
158
+ 真实链路另做过一次隔离启动验证(`DSH_HOME=/tmp/... dsh web --port 3099`,不碰当前 GUI 的 profile):
159
+
160
+ | 验证 | 结果 |
161
+ |---|---|
162
+ | `--dump-config` 组装 | 插件行与 `preset-maoxuan-pet` 都在组合后的配置里 |
163
+ | `GET /api/dsh-maoxuan-pet.state` | 200,`corpus.count=33`,`nextRunAt` 已排定 |
164
+ | `GET /api/dsh-maoxuan-pet.asset?name=idle` | 200,`image/png`,640×1348 RGBA |
165
+ | 页面 boot payload | 含 `dsh-plugin-maoxuan-pet/client.js`,实际拉到的 bundle 里含本插件代码且可解析 |
166
+ | `POST /api/dsh-maoxuan-pet.generate`(真实 headless) | 61s,`mode: "headless"`,返回结构化气泡(篇名/金句/思想/启示/督促/动作) |
167
+ | 失败降级 | 无凭据时 5.5s 内降级为 `mode: "offline"` 并写入 `lastError` |
168
+
169
+ ### 两个真实踩到的坑(已在 docs/API-CONTRACT.md §6 详述)
170
+
171
+ 1. 自定义路由必须显式 `requestBody: 'buffered'`,否则 GET 会被 Host 直接 400、handler 不被调用;
172
+ 2. `ctx.timeout()` 必须在 `inject` 里声明 `'timer'`,否则真实 `dsh web` 启动 fatal。
173
+
174
+ ## 已知限制
175
+
176
+ - 只支持 Web 界面(`dsh.client.platform: web`),终端/TUI 里没有宠物;
177
+ - 定时器只在这个 `dsh web` 进程活着时走;进程停了不会补跑,重启后按 `nextRunAt` 决定是否补一次;
178
+ - headless 生成每次是一个独立会话(不复用上下文),好处是稳定、坏处是“它不记得昨天说过什么”——所以 prompt 里带了最近 6 条督促用来避免重复;
179
+ - 生图是 AI 生成,中文“毛泽东选集”可能不是逐字可辨,详见 `assets/PROVENANCE.md`;
180
+ - DeepSeek「鲸鱼娘」是民间同人设定,本项目不是官方素材,也不代表 DeepSeek 立场。
181
+
182
+ ## License
183
+
184
+ - **代码**:MIT,见 [LICENSE](LICENSE)。
185
+ - **内置毛选语料**(`corpus/`):**不是 MIT**。文本来自[中文马克思主义文库·毛泽东](https://www.marxists.org/chinese/maozedong/index.htm),著作权归原作者与出版方,
186
+ 本项目仅作个人学习、研究之用的整理,不构成再出版或商业授权。详见 [NOTICE](NOTICE) 与 [corpus/README.md](corpus/README.md)。
187
+ - **立绘**(`assets/`):AI 生成(gpt-image-2,2026-10-31),民间同人形象「鲸鱼娘·小毛」,与 DeepSeek 官方无关。生成记录见 [assets/PROVENANCE.md](assets/PROVENANCE.md)。
188
+ - 本项目与 DeepSeek、毛泽东著作出版方均无隶属关系;内容用于产品与创业方法论的阅读辅助,不作政治宣传。
@@ -0,0 +1,92 @@
1
+ # 素材来源与生成记录(PROVENANCE)
2
+
3
+ **素材性质:DeepSeek 民间同人形象「鲸鱼娘·小毛」——非官方素材,AI 生成。**
4
+ 与 DeepSeek 官方无任何关联,仅作本插件(dsh-plugin-maoxuan-pet)的宠物形象使用。
5
+
6
+ - 角色设定(用户原话):「画一个鲸鱼娘(deepseek 的民间 ip)…… 传中国的红军的制服…… 因为要读毛选,手里有毛选的书」。
7
+ - 生成日期:**2026-10-31**(America/New_York)。
8
+ - 生成模型:**gpt-image-2**,通过用户自建的中转线路调用(`POST /v1/images/generations` 文生图、`POST /v1/images/edits` 图生图 / 表情差分,图生图请求带 `background=transparent`)。
9
+ - 生成工具:
10
+ - 文生图:作者本机的一个 `gen_image.py` 脚本(个人 skill 目录,非本仓库代码,未随包分发)。
11
+ - 图生图 / 表情差分:临时 multipart 脚本(仅标准库,未入库),调用同一中转的 `/v1/images/edits`。
12
+ - 凭据处理:base URL / 模型名 / API key 全部经**环境变量**传入,未写入本仓库任何文件、日志或提交。本文件不含任何 key。
13
+ - 后处理:系统自带 `python3` + Pillow(12.1.0)+ numpy,脚本为临时脚本(未入库)。未安装任何新的系统依赖。
14
+
15
+ ## 生成流程
16
+
17
+ 1. **定角色**:文生图一张 1024×1536 的站姿「抱书微笑」立绘(`assets/raw/idle-v1.png`)。
18
+ 2. **定封面文字**:以该立绘为参考做图生图,只改「红封面上的竖排中文」,并直接要求 `background=transparent`,得到带 alpha 的 idle 底帧(`assets/raw/idle-text-v2.png`)。
19
+ 3. **做表情/姿势差分**:全部以 idle 底帧为参考做图生图,保持角色、服装、比例、配色、封面题字不变,只改表情或持书方式,输出仍为透明底:
20
+ - talk → `assets/raw/talk-final.png`
21
+ - blink → `assets/raw/blink-final.png`
22
+ - read → `assets/raw/read-v3.png`
23
+ 4. **统一画面**:四帧用**同一个裁剪框**(原图 1024×1536 的 `(160, 0, 880, 1516)`)裁切,先把透明区域外扩成相邻像素颜色(避免缩放时白边渗入轮廓),再 Lanczos 等比缩放到 **640×1348**,四帧共用同一画布与脚底线,切换帧时身体不跳。
24
+ 5. `assets/icon.svg`:**手写 SVG**(纯几何形状,非 AI 生成),红底圆角方块 + 暖白圆盘 + 蓝色鲸鱼尾 + 红五星,1506 字节。
25
+
26
+ 原始中间产物保留在 `assets/raw/`(本仓库 `.gitignore` 已忽略该目录,不随 git 提交;如需瘦身可直接删除)。
27
+
28
+ ## 每个文件的 prompt 全文
29
+
30
+ ### 1. `assets/pet-idle.png`(站姿抱书微笑)
31
+
32
+ 第一步(文生图,1024×1536):
33
+
34
+ > a cute chibi anime girl mascot based on a whale: deep navy-blue short bob hair with two small whale-fin shaped hair ornaments, a small blue whale tail fin peeking behind her back, big round dark-blue eyes, fair skin, cheerful, wearing an authentic 1920s-1930s Chinese Workers and Peasants Red Army uniform: grey-blue coarse cotton tunic with red collar tabs, a red cloth armband on the left upper arm, a grey-blue octagonal cloth cap with a small red five-pointed star on the front, grey-blue cloth trousers with puttees, black cloth shoes, holding a thick hardcover book hugged against her chest with both hands; the book cover is plain solid red with one subtle embossed small five-pointed star, the cover has NO text and NO letters, standing upright facing the viewer, gentle warm smile, mouth closed, clean 2D anime key-visual illustration, flat color with thin crisp lineart and soft cel shading, warm cozy palette, full body, centered, pure solid flat white background #FFFFFF, absolutely no shadow under the feet, no gradient, no frame, no text, no letters, no watermark, no 3D, not photorealistic
35
+
36
+ 第二步(图生图表情/题字,`background=transparent`):
37
+
38
+ > Same image, same character, fully transparent background. Only change: on the plain red front cover of the book, write the five Chinese characters 毛泽东选集 in warm off-white printed Chinese type, stacked vertically top to bottom, small, narrow, placed in the UPPER LEFT part of the red cover well above her hand so no character is covered by her hand or arm. Keep EXACTLY the same character, face design, hair, hat with red star, uniform, red armband, palette, lineart style, scale and framing. No shadows. Do not draw any text on the armband or clothing.
39
+
40
+ ### 2. `assets/pet-talk.png`(张嘴说话,供气泡同步)
41
+
42
+ > Same character, same pose. Only her expression changes: mouth open mid-sentence speaking warmly, bright friendly eyes, slightly raised chin. Keep EXACTLY the same character, hair, hat with red star, uniform, red armband, the red book with the vertical Chinese title on its cover, palette, lineart style, scale and framing. Fully transparent background, no shadows, no text on clothing.
43
+
44
+ ### 3. `assets/pet-blink.png`(闭眼/眨眼,与 idle 交替播放)
45
+
46
+ > Same character, same pose. Only her expression changes: eyes gently closed in a happy relaxed blink (curved eyelashes), mouth closed in a soft smile. Keep EXACTLY the same character, hair, hat with red star, uniform, red armband, the red book with the vertical Chinese title on its cover, palette, lineart style, scale and framing. Fully transparent background, no shadows, no text on clothing.
47
+
48
+ ### 4. `assets/pet-read.png`(低头看书)
49
+
50
+ > Same character, same hat, same uniform, same red armband, same art style and scale, fully transparent background. Pose change: she lowers her head and looks DOWN at the red book, which she now holds OPEN in both hands so we can see the warm white printed pages with neat vertical lines of tiny abstract Chinese text; the red cover with the five-pointed star stays visible under the pages; calm focused smile. Keep exactly the same character design, hair, face, hat with red star, palette, lineart. No shadows, no extra text on her clothing.
51
+
52
+ ## 实际交付与检查结果(真实执行)
53
+
54
+ | 文件 | 像素 | 色彩/通道 | `file` 输出 | 说明 |
55
+ | --- | --- | --- | --- | --- |
56
+ | `assets/pet-idle.png` | 640×1348 | RGBA,带 alpha | PNG image data, 640 x 1348, 8-bit/color RGBA, non-interlaced | 站姿抱书微笑,封面竖排「毛泽东选集」可辨 |
57
+ | `assets/pet-talk.png` | 640×1348 | RGBA,带 alpha | 同上 | 同姿势张嘴说话,封面题字保留(字号比 idle 略小、略挤) |
58
+ | `assets/pet-blink.png` | 640×1348 | RGBA,带 alpha | 同上 | 闭眼微笑,与 idle 仅表情不同 |
59
+ | `assets/pet-read.png` | 640×1348 | RGBA,带 alpha | 同上 | 低头看书,书摊开(见下方缺陷第 2 条) |
60
+ | `assets/icon.svg` | viewBox 512×512,1506 字节 | 纯几何矢量 | — | 红底 + 暖白圆盘 + 鲸鱼尾 + 红五星,手写 |
61
+
62
+ 每张 PNG 都用 `read_image` 逐张看过后才采用;另外把四帧合成到棋盘格背景上放大检查轮廓边缘,确认透明通道有效、无白色描边、脚底与发梢没有被裁断。
63
+
64
+ ## 缺陷与局限(如实记录)
65
+
66
+ 1. **封面中文是模型直接画出来的**,不是后期叠加:
67
+ - idle / blink / talk 三帧的红封面上,竖排「毛泽东选集」五字可辨;其中 talk 帧字号偏小、字距略挤,远看仍可读但不如 idle 干净(单张重试 3 次上限内未再重生成)。
68
+ - **read 帧的书是摊开的**,封面题字被书页遮住,因此该帧封面只保留五角星与米白书页上的抽象竖排小字,**没有可读的「毛泽东选集」字样**。若需要四帧都出现完整书名,需要前端在 read 帧叠加 SVG 文字。
69
+ 2. **制服**:帽子形制接近 1930 年代红军软帽/八角帽(正面红五星清晰、灰蓝土布质感),但帽檐比历史实物更挺括、略偏「军帽」感;红领章在 idle/talk/blink 是三角形小领章、在 read 帧是菱形块,帧间不完全一致。没有出现国民政府军、现代迷彩、纳粹/苏联符号。
70
+ 3. **手部**:四帧都是双手抱书或持书,手指被简化为四指团块(Q 版常见处理),没有出现多余手指或明显畸形,但也没有逐指分开。
71
+ 4. **鞋**:黑色布鞋鞋面上有一块肉色椭圆(脚背),放大看略像「鞋面开孔」,属轻微造型瑕疵。
72
+ 5. **帧间一致性**:四帧由同一底图 img2img 派生,构图、比例、配色、服装基本一致,但发梢分叉、鲸尾弯曲、腰带扣、领章形状等有细小差别。**不适合做逐像素动画**,只适合静态帧切换(插件里 idle↔blink 交替、talk 气泡同步、read 展示的用法)。
73
+ 6. 生成过程记录:blink 第一次透明底请求(`raw/blink-v2.png`)返回的是不带 alpha 的 RGB,已重新生成(`raw/blink-final.png`);read 第一版(`raw/read-v2.png`)帽形/领章与 idle 差异偏大,改用第二版(`raw/read-v3.png`)。
74
+ 7. 全部素材无第三方素材、无水印、无多余文字;`icon.svg` 为手写纯几何图形。
75
+
76
+ ## 复现方式(不含任何密钥)
77
+
78
+ ```bash
79
+ export GPT_IMAGE_BASE_URL="<用户自己的 OpenAI 兼容中转地址>"
80
+ export GPT_IMAGE_MODEL="gpt-image-2"
81
+ export GPT_IMAGE_API_KEY="<从用户私有的 key 文件按环境变量注入>"
82
+
83
+ # 1) 文生图底图
84
+ python3 ~/.codex/skills/gpt-image/scripts/gen_image.py --size 1024x1536 \
85
+ --prompt "<见上文 idle 第一步 prompt>" --output assets/raw/idle-v1.png
86
+
87
+ # 2) 表情/姿势差分:POST {GPT_IMAGE_BASE_URL}/images/edits(multipart)
88
+ # image=assets/raw/idle-text-v2.png, background=transparent, size=1024x1536
89
+ # prompt=<见上文各帧 prompt>
90
+
91
+ # 3) 统一裁剪 640×1348、透明区域颜色外扩、Lanczos 缩放(Pillow)
92
+ ```
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="512" height="512" role="img" aria-label="鲸鱼娘·小毛 图标:红军红底、暖白圆盘、蓝色鲸鱼尾、红色五角星">
2
+ <title>鲸鱼娘·小毛</title>
3
+ <!-- 底板:红军红圆角方块 -->
4
+ <rect x="0" y="0" width="512" height="512" rx="116" fill="#C1342B"/>
5
+ <!-- 内描边:在深色界面 / 深色插件市场卡片上保住边界 -->
6
+ <rect x="14" y="14" width="484" height="484" rx="104" fill="none" stroke="#FFF6E9" stroke-width="6" stroke-opacity="0.26"/>
7
+ <!-- 暖白圆盘:给蓝色鲸尾与红星提供对比度 -->
8
+ <circle cx="256" cy="262" r="150" fill="#FFF6E9"/>
9
+ <!-- 红五星:10 点纯几何星形,中心 (256,158),外径 36,内径 13.75 -->
10
+ <polygon fill="#C1342B" points="256,122 264.08,146.88 290.24,146.88 269.08,162.25 277.16,187.12 256,171.75 234.84,187.12 242.92,162.25 221.76,146.88 247.92,146.88"/>
11
+ <!-- 鲸鱼尾:右瓣尾鳍(圆头尾尖) -->
12
+ <path fill="#2E6FB8" d="M256 302 C288 306 326 298 356 280 C384 262 404 234 400 210 A24 24 0 0 0 358 204 C338 232 312 266 290 292 C278 302 266 300 256 302 Z"/>
13
+ <!-- 鲸鱼尾:左瓣尾鳍(与右瓣镜像对称) -->
14
+ <path fill="#2E6FB8" d="M256 302 C224 306 186 298 156 280 C128 262 108 234 112 210 A24 24 0 0 1 154 204 C174 232 200 266 222 292 C234 302 246 300 256 302 Z"/>
15
+ <!-- 尾柄:略深的蓝,把两瓣尾鳍收成一个「尾」 -->
16
+ <path fill="#1E4E8A" d="M240 302 C238 332 244 356 256 382 C268 356 274 332 272 302 Z"/>
17
+ </svg>
Binary file
Binary file
Binary file
Binary file