@ssamurias/dsh-fish 0.9.9 → 1.0.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 (65) hide show
  1. package/AGENTS.md +58 -24
  2. package/CHANGELOG.md +135 -42
  3. package/README.md +56 -161
  4. package/RELEASE-NOTES-0.8.3.md +71 -71
  5. package/RELEASE-NOTES-0.9.9.md +25 -53
  6. package/RELEASE-NOTES-1.0.0.md +137 -0
  7. package/lib/appoint.js +5 -4
  8. package/lib/ask.js +4 -3
  9. package/lib/at.js +8 -7
  10. package/lib/bili.js +1 -1
  11. package/lib/browse.js +29 -7
  12. package/lib/capture.js +23 -4
  13. package/lib/client.js +55 -13
  14. package/lib/comment.js +8 -7
  15. package/lib/compact.js +36 -8
  16. package/lib/contract.js +266 -0
  17. package/lib/curiosity.js +3 -2
  18. package/lib/deliver.js +6 -3
  19. package/lib/derive.js +152 -7
  20. package/lib/desk.js +1 -1
  21. package/lib/events.js +58 -28
  22. package/lib/guard.js +184 -184
  23. package/lib/health.js +36 -0
  24. package/lib/home.js +49 -2
  25. package/lib/hook.js +1 -1
  26. package/lib/identity.js +70 -12
  27. package/lib/import.js +302 -302
  28. package/lib/index.js +5 -1
  29. package/lib/intent.js +5 -3
  30. package/lib/keep.js +3 -2
  31. package/lib/keepsake.js +3 -2
  32. package/lib/letter.js +3 -3
  33. package/lib/look.js +15 -1
  34. package/lib/material.js +57 -1
  35. package/lib/note.js +94 -28
  36. package/lib/observe.js +2 -2
  37. package/lib/persona.js +204 -72
  38. package/lib/pocket.js +2 -2
  39. package/lib/proactive.js +7 -6
  40. package/lib/pronoun.js +75 -35
  41. package/lib/pronounask.js +11 -2
  42. package/lib/quality.js +1 -1
  43. package/lib/readme.js +1 -1
  44. package/lib/recall.js +184 -27
  45. package/lib/restrict.js +27 -1
  46. package/lib/say.js +14 -13
  47. package/lib/scheduler.js +80 -12
  48. package/lib/schema.js +24 -0
  49. package/lib/selfdoc.js +19 -8
  50. package/lib/sessionnote.js +44 -0
  51. package/lib/settings.js +16 -0
  52. package/lib/sources.js +99 -0
  53. package/lib/speak.js +1 -1
  54. package/lib/speechanchor.js +132 -0
  55. package/lib/stance.js +4 -3
  56. package/lib/sub.js +387 -0
  57. package/lib/talkmem.js +3 -2
  58. package/lib/turns.js +51 -24
  59. package/lib/use.js +21 -1
  60. package/lib/wish.js +3 -2
  61. package/package.json +3 -3
  62. package/tools/check-install.mjs +237 -0
  63. package/RELEASE.md +0 -154
  64. package/media/principle-loop-2x.png +0 -0
  65. package/media/principle-memory-2x.png +0 -0
package/lib/use.js CHANGED
@@ -20,6 +20,7 @@ import { similarity } from './derive.js'
20
20
  import { noteRegisteredTool } from './toolreg.js'
21
21
  import { callerInRoot } from './tenant.js'
22
22
  import { setToolUseWrap } from './tool.js'
23
+ import { fillOwner, fillOwnerDeep, primePronoun, pronounFor } from './pronoun.js'
23
24
 
24
25
  /** 一句话的上限:她在回忆里看到的是一条,不是一段。 */
25
26
  export const USE_LINE_MAX = 80
@@ -155,11 +156,28 @@ export async function recordUse(root, { tool, out, sessionId, now = Date.now() }
155
156
  export function withUse(def, { root, tool }) {
156
157
  const run = def?.execute
157
158
  if (typeof run !== 'function') return def
159
+ // 工具说明是注册期一次性交出去的(之后不会再求值),所以先按 root 把代词读进来:
160
+ // 模板里写的是 `{T}`,这里填成 他 / 她 / TA(1.0.0,issue #127 的彻底方案)。
161
+ primePronoun(root)
158
162
  // 按属性描述符复制,不用 `{ ...def }`:展开会把 getter 当场求值成死值。
159
163
  // bili_speak 的说明是 getter(随「能不能说话」现取),展开之后就定格在启动那一刻,
160
164
  // 之后开关怎么翻,她读到的说明都不变(issue #62 后续)。
161
165
  const props = Object.getOwnPropertyDescriptors(def)
162
166
  delete props.execute
167
+ // 说明与参数描述里的 `{T}` 也在这一层填:这是「注册期的一次性文本」,
168
+ // 填完就固定了;getter 说明则包一层,每次读都按当前配置填。
169
+ for (const key of ['description', 'brief']) {
170
+ const d = props[key]
171
+ if (!d) continue
172
+ if ('value' in d && typeof d.value === 'string') d.value = fillOwner(d.value, pronounFor(root))
173
+ else if (typeof d.get === 'function') {
174
+ const orig = d.get
175
+ d.get = () => fillOwner(orig.call(def), pronounFor(root))
176
+ }
177
+ }
178
+ if (props.parameters && 'value' in props.parameters) {
179
+ props.parameters.value = fillOwnerDeep(props.parameters.value, pronounFor(root))
180
+ }
163
181
  const wrapped = Object.create(Object.getPrototypeOf(def), props)
164
182
  async function execute(args, exec) {
165
183
  // 记录之前先问一句「这次调用是不是发生在这个家里」(2026-11-09 外部用户报告):
@@ -168,7 +186,9 @@ export function withUse(def, { root, tool }) {
168
186
  // 出门 / 请神那条会话仍然算她(判据在 callerInRoot 里与 checkCaller 一致)。
169
187
  const own = callerInRoot(root, exec)
170
188
  try {
171
- const out = await run(args, exec)
189
+ // 返回值里的 `{T}` 在这里填:卡片、便条回执、回忆正文都走这条出口。
190
+ // 只认这一个记号,所以返回值里她的原话、用户原话都不会被碰。
191
+ const out = fillOwnerDeep(await run(args, exec), pronounFor(root))
172
192
  if (own) await recordUse(root, { tool, out, sessionId: exec?.sessionId })
173
193
  return out
174
194
  } catch (err) {
package/lib/wish.js CHANGED
@@ -53,6 +53,7 @@
53
53
 
54
54
  import { tsMs } from './schema.js'
55
55
  import { similarity } from './derive.js'
56
+ import { fillOwner } from './pronoun.js'
56
57
 
57
58
  /** 一次最多摆几条。多了就成了许愿清单。 */
58
59
  export const WISH_SHOW_MAX = 2
@@ -193,8 +194,8 @@ export function toolArrived(e, has) {
193
194
 
194
195
  /** 她那句话怎么收尾——只陈述结局,不给建议。 */
195
196
  export function wishTail(verdict) {
196
- if (verdict === 'approve') return '他答应了,还没见到'
197
- if (verdict === 'later') return '他说以后再说'
197
+ if (verdict === 'approve') return fillOwner('{T}答应了,还没见到')
198
+ if (verdict === 'later') return fillOwner('{T}说以后再说')
198
199
  if (verdict === 'reject') return '那次不行'
199
200
  return '你问过,还没有答复'
200
201
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssamurias/dsh-fish",
3
- "version": "0.9.9",
3
+ "version": "1.0.0",
4
4
  "description": "养一条会自己长大的鱼:没有人格设置,通过事件流长大。她可以自己刷 B 站、会写日记给你看,四个阶段完成后才会开始有立场。状态库在 ~/.dsh-fish,不能删除记录。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -19,8 +19,8 @@
19
19
  "AGENTS.md",
20
20
  "CHANGELOG.md",
21
21
  "RELEASE-NOTES-*.md",
22
- "RELEASE.md",
23
- "scripts"
22
+ "scripts",
23
+ "tools"
24
24
  ],
25
25
  "scripts": {
26
26
  "test": "node --test"
@@ -0,0 +1,237 @@
1
+ #!/usr/bin/env node
2
+ // 安装自查:插件没跑起来的时候用这个。
3
+ //
4
+ // 为什么需要它:DSH 加载的是 node_modules 里那份**副本**,不是 profile 里写的那条源目录;
5
+ // 而 pnpm 装到一半失败时,副本可能是个空目录。插件自己这时候根本没被执行,
6
+ // 所以它「自检」看不见自己没装进来——只能从外面查。
7
+ //
8
+ // 用法(零依赖,node 18+ 就能跑,不需要插件已加载):
9
+ // node check-install.mjs
10
+ // node check-install.mjs --home D:/DSH --profile desktop
11
+ //
12
+ // 退出码:0 = 看着没问题;1 = 查到不对劲;2 = 参数/环境问题。
13
+
14
+ import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
15
+ import { homedir } from 'node:os'
16
+ import { join, posix, resolve } from 'node:path'
17
+
18
+ export const PKG_NAME = 'dsh-fish'
19
+ const DEP_FIELDS = ['dependencies', 'devDependencies', 'optionalDependencies']
20
+
21
+ /** 形如 `D:/x`、`D:\x`、`\\server\share` 的 Windows 绝对路径 */
22
+ function isWinAbs(p) {
23
+ return /^[A-Za-z]:[\\/]/.test(p) || /^\\\\/.test(p)
24
+ }
25
+
26
+ /** 按 Windows 语义拼相对路径——POSIX 上的 path.resolve 认不得盘符 */
27
+ function winResolve(base, rel) {
28
+ const b = base.replace(/\\/g, '/')
29
+ const drive = /^([A-Za-z]:)/.exec(b)?.[1] ?? ''
30
+ const rest = b.slice(drive.length) || '/'
31
+ return drive + posix.resolve(rest, rel.replace(/\\/g, '/'))
32
+ }
33
+
34
+ /** `file:D:/x` / `file:/d/x` / `file:../../x` → 绝对路径;`link:` 和其它协议返回 ''。 */
35
+ export function parseFileDep(spec, profileDir) {
36
+ if (typeof spec !== 'string') return ''
37
+ const m = /^file:(.+)$/.exec(spec.trim())
38
+ if (!m) return ''
39
+ const raw = m[1].trim()
40
+ if (!raw) return ''
41
+ // Windows 绝对路径(`D:/x`、`D:\x`、`\\server\share`)在 POSIX 上也必须原样保留:
42
+ // `path.resolve('/home/runner', 'D:/x')` 会把它当成相对路径,拼成
43
+ // `/home/runner/D:/x`(CI 上 3 个 ubuntu job 就是这么红的,2026-10-30)。
44
+ if (isWinAbs(raw)) return raw.replace(/\\/g, '/')
45
+ // profile 目录本身是 Windows 路径(Windows 上跑、或在 Linux 上核对 Windows 的配置):
46
+ // 按 Windows 语义拼,否则 POSIX 的 resolve 会把 `C:/p/desktop` 也当相对路径。
47
+ if (isWinAbs(String(profileDir ?? ''))) return winResolve(String(profileDir), raw)
48
+ return resolve(profileDir, raw)
49
+ }
50
+
51
+ /** 从 package.json 文本里取 dsh-fish 的依赖写法;坏 JSON 返回 null。 */
52
+ export function readDep(text) {
53
+ let pkg
54
+ try {
55
+ pkg = JSON.parse(text)
56
+ } catch {
57
+ return null
58
+ }
59
+ for (const f of DEP_FIELDS) {
60
+ const v = pkg?.[f]?.[PKG_NAME]
61
+ if (typeof v === 'string') return v
62
+ }
63
+ return ''
64
+ }
65
+
66
+ /** 读一个目录里 package.json 的版本号;读不到返回 ''。 */
67
+ export function versionOf(dir) {
68
+ try {
69
+ return JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))?.version ?? ''
70
+ } catch {
71
+ return ''
72
+ }
73
+ }
74
+
75
+ /** 数一个目录里 .js 文件的个数(副本是空的 / 只落了一半,这个数字会明显偏低)。 */
76
+ export function countJs(dir) {
77
+ let n = 0
78
+ const walk = (d, depth) => {
79
+ if (depth > 3) return
80
+ let items = []
81
+ try {
82
+ items = readdirSync(d, { withFileTypes: true })
83
+ } catch {
84
+ return
85
+ }
86
+ for (const it of items) {
87
+ if (it.name === 'node_modules') continue
88
+ if (it.isDirectory()) walk(join(d, it.name), depth + 1)
89
+ else if (it.name.endsWith('.js') || it.name.endsWith('.mjs')) n += 1
90
+ }
91
+ }
92
+ walk(dir, 0)
93
+ return n
94
+ }
95
+
96
+ /**
97
+ * 查一个 profile。
98
+ * 返回 {profile, source, sourceVersion, copy, copyVersion, sourceJs, copyJs, verdict, why}
99
+ * verdict: ok | empty-copy | stale-copy | no-dep | no-profile
100
+ */
101
+ export function inspectProfile(profileDir) {
102
+ const pkgFile = join(profileDir, 'package.json')
103
+ const out = {
104
+ profile: profileDir,
105
+ source: '',
106
+ sourceVersion: '',
107
+ copy: join(profileDir, 'node_modules', PKG_NAME),
108
+ copyVersion: '',
109
+ sourceJs: 0,
110
+ copyJs: 0,
111
+ verdict: 'no-profile',
112
+ why: '',
113
+ }
114
+ if (!existsSync(pkgFile)) {
115
+ out.why = '这个 profile 里没有 package.json'
116
+ return out
117
+ }
118
+ let text
119
+ try {
120
+ text = readFileSync(pkgFile, 'utf8')
121
+ } catch (err) {
122
+ out.why = `package.json 读不了:${err?.message ?? err}`
123
+ return out
124
+ }
125
+ const dep = readDep(text)
126
+ if (dep === null) {
127
+ out.why = 'package.json 不是合法 JSON'
128
+ return out
129
+ }
130
+ if (!dep) {
131
+ out.verdict = 'no-dep'
132
+ out.why = 'profile 的 dependencies 里没有 dsh-fish'
133
+ return out
134
+ }
135
+ out.verdict = 'no-dep'
136
+ out.why = `依赖写法是 ${dep}`
137
+ if (dep.startsWith('link:')) {
138
+ out.why = `依赖写法是 ${dep}(软链安装,没有副本,不需要比对)`
139
+ return out
140
+ }
141
+
142
+ out.source = parseFileDep(dep, profileDir)
143
+ if (!out.source) {
144
+ out.why = `依赖写法是 ${dep}(不是 file:,没法定位源目录)`
145
+ return out
146
+ }
147
+ out.sourceVersion = versionOf(out.source)
148
+ out.copyVersion = versionOf(out.copy)
149
+ out.sourceJs = countJs(out.source)
150
+ out.copyJs = countJs(out.copy)
151
+
152
+ if (!existsSync(out.copy)) {
153
+ out.verdict = 'empty-copy'
154
+ out.why = 'node_modules 里没有 dsh-fish:pnpm 根本没装成功'
155
+ } else if (!out.copyVersion) {
156
+ out.verdict = 'empty-copy'
157
+ out.why = 'node_modules/dsh-fish 里没有能读的 package.json:副本是空的或只落了一半'
158
+ } else if (out.copyJs < out.sourceJs * 0.8) {
159
+ out.verdict = 'empty-copy'
160
+ out.why = `副本只有 ${out.copyJs} 个 js 文件,源目录有 ${out.sourceJs} 个:装了一半`
161
+ } else if (out.copyVersion !== out.sourceVersion) {
162
+ out.verdict = 'stale-copy'
163
+ out.why = `源目录是 ${out.sourceVersion || '?'},跑的是 ${out.copyVersion}(副本没跟上)`
164
+ } else {
165
+ out.verdict = 'ok'
166
+ out.why = `副本与源目录都是 ${out.copyVersion}(${out.copyJs} 个 js 文件)`
167
+ }
168
+ return out
169
+ }
170
+
171
+ /** 找出一个 DSH_HOME 下所有装过 dsh-fish 的 profile。 */
172
+ export function findProfiles(home = join(homedir(), '.dsh')) {
173
+ const root = join(home, 'profiles')
174
+ if (!existsSync(root)) return []
175
+ const out = []
176
+ for (const name of readdirSync(root)) {
177
+ const dir = join(root, name)
178
+ try {
179
+ if (!statSync(dir).isDirectory()) continue
180
+ } catch {
181
+ continue
182
+ }
183
+ if (!existsSync(join(dir, 'package.json'))) continue
184
+ const dep = readDep(readFileSync(join(dir, 'package.json'), 'utf8'))
185
+ if (dep) out.push(dir)
186
+ }
187
+ return out
188
+ }
189
+
190
+ const LABEL = {
191
+ ok: '正常',
192
+ 'stale-copy': '装的是旧副本',
193
+ 'empty-copy': '副本空的/装了一半',
194
+ 'no-dep': '不是这套装法',
195
+ 'no-profile': '没找到 profile',
196
+ }
197
+
198
+ export function main(argv = process.argv.slice(2)) {
199
+ const arg = (name, dflt = '') => {
200
+ const i = argv.indexOf(`--${name}`)
201
+ return i >= 0 && argv[i + 1] ? argv[i + 1] : dflt
202
+ }
203
+ const home = arg('home', join(homedir(), '.dsh'))
204
+ const only = arg('profile', '').toLowerCase()
205
+ let dirs = findProfiles(home)
206
+ if (only) {
207
+ dirs = dirs.filter((d) => d.split(/[\\/]/).pop().toLowerCase() === only)
208
+ if (!dirs.length) {
209
+ console.error(`在 ${home} 里没找到 profile「${only}」,或者它没装 dsh-fish`)
210
+ return 2
211
+ }
212
+ }
213
+ if (!dirs.length) {
214
+ console.error(`在 ${home}\\profiles 里没找到任何装过 dsh-fish 的 profile`)
215
+ return 2
216
+ }
217
+
218
+ let bad = 0
219
+ for (const dir of dirs) {
220
+ const r = inspectProfile(dir)
221
+ const name = dir.split(/[\\/]/).pop()
222
+ console.log(`\n[${name}] ${LABEL[r.verdict] ?? r.verdict}`)
223
+ if (r.source) console.log(` 源目录 ${r.source}`)
224
+ if (r.copy) console.log(` 实际跑 ${r.copy}`)
225
+ console.log(` 说明 ${r.why}`)
226
+ if (r.verdict === 'empty-copy' || r.verdict === 'stale-copy') {
227
+ bad += 1
228
+ console.log(' 修法 关掉 DSH → 在 profile 目录里 pnpm install --force(或删掉 node_modules/dsh-fish)→ 再启动')
229
+ }
230
+ }
231
+ console.log(bad ? '\n有问题:上面标出来的那几条按「修法」重装一次。' : '\n看着没问题。')
232
+ return bad ? 1 : 0
233
+ }
234
+
235
+ if (import.meta.url === `file://${process.argv[1]?.replace(/\\/g, '/')}` || process.argv[1]?.endsWith('check-install.mjs')) {
236
+ process.exitCode = main()
237
+ }
package/RELEASE.md DELETED
@@ -1,154 +0,0 @@
1
- # 发版流程(dsh-fish)
2
-
3
- > 适用 0.9.1 之后。本仓库的规矩是**先改在本地、后发布**:本地 `main` 改完、测试全绿,等维护者明确说「发」再执行第 3 步起的命令。没点头就只做到第 2 步。
4
- >
5
- > 本机环境:Windows + Git Bash;仓库在 `D:/deepseekagent/02-我的项目/大肥鱼/plugin`;`gh` 在 `/c/Users/DANG/bin/gh`(登录名 `ssamurias`);npm 账号同名。
6
-
7
- ---
8
-
9
- ## 0. 发布前先确认三件事
10
-
11
- ```bash
12
- cd "D:/deepseekagent/02-我的项目/大肥鱼/plugin"
13
- git status --short # 必须是空的
14
- git log --oneline origin/main..HEAD # 看看这次要发几个提交
15
- npm whoami --registry=https://registry.npmjs.org/ # 必须是 ssamurias;报 E401 就先 npm login(见第 4 步)
16
- gh auth status # 必须是 ssamurias
17
- ```
18
-
19
- - 发布本身**不碰本地 profile**,不用关 DSH Desktop。
20
- - 只有「发完在本地装一遍验证」时才要先关应用——运行中替换已加载的包会 `ERR_PNPM_EPERM`(避坑指南第 3 节)。
21
- - 本机 npm 账号开了 2FA 的话,`npm publish` 会要 6 位验证码,见第 4 步。
22
-
23
- ---
24
-
25
- ## 1. 发布前自检(每次都要跑,别跳)
26
-
27
- - [ ] `package.json` 的 `version` 就是要发的号(修 bug 发 patch,如 `0.9.3`;一批改动发 minor,如 `0.9.6`)
28
- - [ ] `node --test` 全绿(当前基线见 `AGENTS.md` 第 6 节;现在是 \*\*2237 pass / 0 fail\\*\\*,约 28 秒)
29
- - [ ] `CHANGELOG.md` 顶部有本节,条目按 issue 编号写全
30
- - [ ] `RELEASE-NOTES-x.y.z.md` 已写,且与 `CHANGELOG.md` 口径一致(issue 条数、PR 编号、日期)
31
- - [ ] `README.md` 顶部「当前版本」段已换成这一版
32
- - [ ] 升级路径有变化时,`README.md`「从旧版升到 0.9.x」表补了行,`AGENTS.md`「包名与装法」补了守门条目
33
- - [ ] `npm pack --dry-run` 的文件清单对:`lib/`、`media/`、`scripts/`、`cordis.patch.yml`、`README.md`、`AGENTS.md`、`CHANGELOG.md`、`RELEASE-NOTES-*.md`、`RELEASE.md`;**不含 `test/`**
34
- - [ ] 包里没有敏感文件(`.env`、profile、cookie、备份档)
35
-
36
- ```bash
37
- node --test
38
- npm pack --dry-run
39
- ```
40
-
41
- `npm pack --dry-run` 只打印清单、不真打包;看完记得确认没有 `test/`、没有 `~/.dsh-fish` 相关的东西。
42
-
43
- ---
44
-
45
- ## 2. 本地提交(不 push)
46
-
47
- ```bash
48
- git add -A
49
- git commit -m "0.9.x:<一句话说清这一版>"
50
- ```
51
-
52
- - 0.9.1 就是这么发出去的:先在本地攒了 10 个提交(含四个社区 PR 的合并提交),维护者说「发」之后才推。之后同样先攒、别边改边推。
53
- - 没点头就停在这里。下面每一步都会动线上(GitHub / npm),发布出去基本收不回。
54
-
55
- ---
56
-
57
- ## 3. 推代码上 GitHub
58
-
59
- ```bash
60
- git push origin main
61
- ```
62
-
63
- - 若 `github.com:443` 不通(本机常见),改用 Git Data API 推:`node D:/deepseekagent/04-小工具/fish-push-generic.mjs`(逐提交建树、建 commit,并断言树 SHA 与本地一致),成功后 `node D:/deepseekagent/04-小工具/fish-realign-shas.mjs`(按 `.git/push-map.json` 把本地 SHA 对齐成服务端版本,同时更新 `origin/main`)。原理与三个坑见避坑指南第 27 节。
64
- - **不要** `git push --force` / `git push --delete`:会被 CC Safety Net 拦下。确需删远端引用,用 `gh api -X DELETE /repos/ssamurias/dsh-fish/git/refs/<ref>`。
65
- - 推完去 Actions 看一眼三档 Node(20 / 22 / 24)是否全绿:`gh run list --limit 3`。
66
-
67
- ---
68
-
69
- ## 4. 发 npm 包(需要你手动跑,可整段复制)
70
-
71
- > 这一段是给维护者本人执行的:登录和 2FA 都在你的终端里完成,agent 不代跑发布。
72
- > **本机的 2FA 是 Windows 系统密钥(安全密钥)**,所以每次发布都要走一遍完整登录流程;发完后 npm 的 CDN 大约要 **3 分钟** 才看得到新版本,核对命令等一会儿再跑。
73
- > **本机 npm 默认 registry 是 `https://registry.npmmirror.com`,所以每条命令都必须显式带 `--registry=https://registry.npmjs.org/`**,否则会得到看似「包不存在 / 没权限」的 E404。
74
-
75
- ```bash
76
- cd "D:/deepseekagent/02-我的项目/大肥鱼/plugin"
77
-
78
- # 0) 确认身份:返回 ssamurias 就说明本机已经登录,可以跳过第 1 步
79
- npm whoami --registry=https://registry.npmjs.org/
80
-
81
- # 1) 只有第 0 步报 E401 / 不是 ssamurias 时才需要:浏览器登录
82
- npm login --registry=https://registry.npmjs.org/
83
- npm whoami --registry=https://registry.npmjs.org/
84
-
85
- # 2) 发布(开了 2FA 就在末尾加 --otp=123456)
86
- npm publish --registry=https://registry.npmjs.org/
87
-
88
- # 3) 核对:等约 3 分钟再跑,应为 0.9.x 和 latest -> 0.9.x
89
- npm view @ssamurias/dsh-fish version dist-tags --registry=https://registry.npmjs.org/
90
- ```
91
-
92
- - **不想每条都带参数**:`npm config set registry https://registry.npmjs.org/`,发完再改回 `npm config set registry https://registry.npmmirror.com/`。
93
- - **scoped 包没有写权限时 npm 故意返回 404(不是 403)**:看到 E404 先查 `npm whoami`,别怀疑包名或网络。
94
- - 本包已经是公开包,**不需要** `--access public`(只有首次发布才要)。
95
- - 常见报错:
96
- - `E401`:没登录 / token 过期 → `npm logout --registry=...` 再 `npm login --registry=...`
97
- - `E403`:账号没有 `@ssamurias` scope 写权限,或开了 2FA 没给 `--otp`
98
- - `EPUBLISHCONFLICT`:这个版本号已经发过 → 已发布版本不能覆盖,升 patch 号重来
99
- - `npm publish --dry-run` 可以先看会打进去哪些文件,不会真的发。
100
- - 用户端注意:pnpm 的 `minimumReleaseAge`(默认 24 小时)会把「太新」的版本回滚掉;本机 profile 已设 `minimumReleaseAge: 0`(避坑指南第 3 节)。
101
-
102
- ## 5. 打 tag + 建 GitHub Release
103
-
104
- **npm 发布成功之后**再做这一步,npm 失败就停住、别打 tag(免得留一个指向没发出去的版本的悬空 tag)。
105
-
106
- ```bash
107
- git tag -a v0.9.x -m "0.9.x"
108
- git push origin v0.9.x
109
- export PATH="/c/Users/DANG/bin:$PATH"
110
- gh release create v0.9.x -F RELEASE-NOTES-0.9.x.md --title "0.9.x"
111
- ```
112
-
113
- - Release 正文直接用仓库里的 `RELEASE-NOTES-*.md`(`-F` 读文件),不要在网页上手打——两边会不一致。
114
- - 想先存草稿:`gh release create v0.9.x -F RELEASE-NOTES-0.9.x.md --draft`,检查完再 `gh release edit v0.9.x --draft=false`。
115
- - `git push origin v0.9.x` 若也卡在 443:用 `gh api -X POST repos/ssamurias/dsh-fish/git/tags` 在服务端建 tag 对象,再 `gh api -X POST repos/ssamurias/dsh-fish/git/refs -f ref=refs/tags/v0.9.x -f sha=<tag对象sha>`。
116
- - 兜底也可以在网页上建 Release(会自动建 tag),但正文仍以 `RELEASE-NOTES-*.md` 为准,别手打。
117
-
118
- ---
119
-
120
- ## 6. 发布后验证
121
-
122
- ```bash
123
- npm view @ssamurias/dsh-fish version dist-tags
124
- npm view @ssamurias/dsh-fish@0.9.x dist.tarball
125
- gh release view v0.9.x
126
- ```
127
-
128
- - `dist-tags.latest` 要指向新版本;`dist.tarball` 能取到 URL 就说明包在。
129
- - 想真装一遍:**先关 DSH Desktop**,用临时 profile 试装(不要直接动 `desktop` profile)——`bundles` 与 `dependencies` 必须一一对应,先只改依赖、装包,再用目录联接的临时 profile 跑 `--dump-config` 预演(避坑指南第 1 节)。
130
- - 回 issue:这一版修到的每条 issue 各回一条「x.y.z 已发布,装法见 README,有问题随时回」,等作者确认后再关。
131
- - 给这一版合入的 PR 作者留一句「已随 x.y.z 发布」;PR 没合并的不要在 GitHub 上点 merge,在回帖里说清「以提交形式合入」。
132
-
133
- ---
134
-
135
- ## 7. 出问题时怎么回滚
136
-
137
- | 对象 | 命令 | 说明 |
138
- | --- | --- | --- |
139
- | npm 版本 | `npm unpublish @ssamurias/dsh-fish@0.9.x` | 72 小时内可撤;超过 72 小时改用 `npm deprecate @ssamurias/dsh-fish@0.9.x "原因,请装 x.y.z"`,不要再发同名版本 |
140
- | git tag | `git tag -d v0.9.x` 然后 `git push --delete origin v0.9.x` | `--delete` 被拦时用 `gh api -X DELETE /repos/ssamurias/dsh-fish/git/refs/tags/v0.9.x` |
141
- | GitHub Release | `gh release delete v0.9.x` | 加 `--cleanup-tag` 连 tag 一起删 |
142
- | 代码 | 用 `git revert <提交>` 再正常 push | **不要** force push `main` |
143
-
144
- ---
145
-
146
- ## 8. 这个项目特有的坑(发布前扫一眼)
147
-
148
- - **包名 / 迁移脚本别动**:`@ssamurias/dsh-fish`、`cordis.patch.yml` 的 `id: dsh-fish`、`lib/selfupdate.js` 的 `normalizeScript()` 三条都在 `AGENTS.md` 的「包名与装法」,发布前改它们等于给自己造升级事故。
149
- - **升级说明要和脚本一致**:`scripts/fix-legacy-link.mjs` 现在认三种依赖写法(`link:` / `file:` tgz / 版本号)。改了它,`README.md` 升级表与 `RELEASE-NOTES-*.md` 必须同步改,否则用户照文档做还是会崩。
150
- - **`desktop` profile 被应用独占**:`dsh plugin --profile desktop ...` 会被拒,验证要用别的 profile。
151
- - **别在应用运行时替换已加载的包**:`ERR_PNPM_EPERM`,包目录会被留成「已删除」。
152
- - 备份照旧放 `D:/deepseekagent/dsh-fix-backup/`,不要放进仓库。
153
-
154
-
Binary file
Binary file