@fish-under-sea/dsh-agent-teams-fish 1.0.2 → 2.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 (179) hide show
  1. package/NOTICE.md +13 -7
  2. package/README.en.md +20 -12
  3. package/README.md +20 -12
  4. package/compatibility.json +82 -46
  5. package/icon.png +0 -0
  6. package/lib/artifacts.js +148 -25
  7. package/lib/client/ActivityPanel.js +26 -5
  8. package/lib/client/WorkspaceActivity.js +6 -4
  9. package/lib/client/activity-monitor.js +113 -41
  10. package/lib/client/locales.js +14 -0
  11. package/lib/client.js +433 -199
  12. package/lib/client.js.map +1 -1
  13. package/lib/command.js +7 -4
  14. package/lib/git-artifact-stamp.json +2 -2
  15. package/lib/harness-compat.js +120 -62
  16. package/lib/index.js +7 -10
  17. package/lib/mailbox.js +15 -5
  18. package/lib/members.js +221 -154
  19. package/lib/snapshot.js +15 -10
  20. package/lib/state.js +41 -8
  21. package/lib/tools.js +123 -64
  22. package/lib/types/artifacts.d.ts +6 -3
  23. package/lib/types/client/activity-monitor.d.ts +13 -4
  24. package/lib/types/client/locales.d.ts +14 -0
  25. package/lib/types/harness-compat.d.ts +63 -16
  26. package/lib/types/mailbox.d.ts +2 -0
  27. package/lib/types/members.d.ts +5 -17
  28. package/lib/types/snapshot.d.ts +12 -7
  29. package/lib/types/state.d.ts +10 -3
  30. package/lib/types/types.d.ts +5 -0
  31. package/lib/types/web-routes.d.ts +2 -0
  32. package/lib/types/workspace-audit-service.d.ts +35 -0
  33. package/lib/types/workspace-audit-worker.d.ts +1 -0
  34. package/lib/web-routes.js +31 -0
  35. package/lib/workspace-audit-service.js +165 -0
  36. package/lib/workspace-audit-worker.js +11 -0
  37. package/lib/workspace-audit.js +6 -5
  38. package/locale/en.json +6 -0
  39. package/locale/zh.json +6 -0
  40. package/package.json +69 -64
  41. package/pnpm-workspace.yaml +306 -273
  42. package/release-notes/v0.1.25.md +16 -0
  43. package/release-notes/v0.1.26.md +19 -0
  44. package/release-notes/v0.1.27.md +42 -0
  45. package/release-notes/v0.1.28.md +45 -0
  46. package/release-notes/v0.1.29.md +23 -0
  47. package/release-notes/v1.1.0.md +42 -0
  48. package/release-notes/v2.0.0.md +17 -0
  49. package/scripts/artwork-role-match.test.mjs +517 -0
  50. package/scripts/capabilities.test.mjs +301 -0
  51. package/scripts/check-install-channel.mjs +55 -0
  52. package/scripts/check-install-channel.test.mjs +39 -0
  53. package/scripts/clean-build.mjs +14 -0
  54. package/scripts/client-harness-migration.test.mjs +46 -0
  55. package/scripts/compatibility.mjs +20 -0
  56. package/scripts/compatibility.test.mjs +187 -0
  57. package/scripts/corrupt-teamjson.test.mjs +180 -0
  58. package/scripts/custom-artwork.test.mjs +273 -0
  59. package/scripts/fallback-tdd.mjs +61 -0
  60. package/scripts/fixtures/harness-benchmark-scope.mjs +16 -0
  61. package/scripts/fixtures/harness-benchmark-scope.test.mjs +18 -0
  62. package/scripts/fixtures/harness-complex-case.mjs +201 -0
  63. package/scripts/fixtures/harness-complex-case.test.mjs +21 -0
  64. package/scripts/fixtures/harness-complex-oracle.mjs +63 -0
  65. package/scripts/fixtures/harness-issue-case.mjs +51 -0
  66. package/scripts/fixtures/harness-issue159-case.mjs +28 -0
  67. package/scripts/fixtures/harness-model-case.mjs +127 -0
  68. package/scripts/fixtures/harness-model-case.test.mjs +37 -0
  69. package/scripts/fixtures/harness-model-driver.mjs +100 -0
  70. package/scripts/fixtures/harness-runtime-credentials.mjs +23 -0
  71. package/scripts/fixtures/harness-runtime-entry.mjs +171 -0
  72. package/scripts/fixtures/harness-runtime-idle.mjs +42 -0
  73. package/scripts/fixtures/harness-runtime-llm.mjs +193 -0
  74. package/scripts/fixtures/harness-runtime-protocol.mjs +187 -0
  75. package/scripts/fixtures/harness-runtime-resume.mjs +24 -0
  76. package/scripts/fixtures/harness-runtime-stability.mjs +282 -0
  77. package/scripts/fixtures/harness-runtime-tools.mjs +13 -0
  78. package/scripts/fixtures/harness-runtime-web-approval.mjs +341 -0
  79. package/scripts/fixtures/issue-336-audit-worker.mjs +18 -0
  80. package/scripts/git-artifacts.mjs +64 -0
  81. package/scripts/git-artifacts.test.mjs +32 -0
  82. package/scripts/harness-compat-tdd.mjs +492 -0
  83. package/scripts/harness-issue-verify.mjs +26 -0
  84. package/scripts/harness-model-benchmark.mjs +163 -0
  85. package/scripts/harness-runtime-platform.test.mjs +31 -0
  86. package/scripts/harness-runtime-scenarios.mjs +297 -0
  87. package/scripts/harness-runtime-verify.mjs +169 -0
  88. package/scripts/harness-source-verify.mjs +211 -0
  89. package/scripts/harness-source-verify.test.mjs +97 -0
  90. package/scripts/harness-validation.mjs +68 -0
  91. package/scripts/harness-validation.test.mjs +95 -0
  92. package/scripts/http-body.test.mjs +72 -0
  93. package/scripts/import-vendor-artwork.mjs +78 -0
  94. package/scripts/inline-plan-blank-optional-tdd.mjs +121 -0
  95. package/scripts/issue-159.test.mjs +78 -0
  96. package/scripts/issue-188.test.mjs +148 -0
  97. package/scripts/issue-189.test.mjs +100 -0
  98. package/scripts/issue-203-card.test.mjs +181 -0
  99. package/scripts/issue-205.test.mjs +163 -0
  100. package/scripts/issue-234.test.mjs +424 -0
  101. package/scripts/issue-236-stale-module.test.mjs +63 -0
  102. package/scripts/issue-236.test.mjs +59 -0
  103. package/scripts/issue-262.test.mjs +98 -0
  104. package/scripts/issue-336.test.mjs +404 -0
  105. package/scripts/legacy-session-source-repair.test.mjs +201 -0
  106. package/scripts/lifecycle-verify.mjs +1573 -0
  107. package/scripts/lineage-identity.test.mjs +77 -0
  108. package/scripts/member-failure-tdd.mjs +451 -0
  109. package/scripts/member-spawn-recovery.test.mjs +92 -0
  110. package/scripts/quality-gates-amend.test.mjs +161 -0
  111. package/scripts/quality-gates-content-bound.test.mjs +572 -0
  112. package/scripts/quality-gates-cross-binding.test.mjs +184 -0
  113. package/scripts/quality-gates-excluded-scope.test.mjs +163 -0
  114. package/scripts/quality-gates-repair-scope.test.mjs +143 -0
  115. package/scripts/quality-gates-repair-wiring.test.mjs +189 -0
  116. package/scripts/quality-gates-tdd.mjs +1238 -0
  117. package/scripts/quality-gates-work-order.test.mjs +494 -0
  118. package/scripts/readme-version.mjs +89 -0
  119. package/scripts/readme-version.test.mjs +77 -0
  120. package/scripts/release-metadata.mjs +45 -0
  121. package/scripts/release-metadata.test.mjs +66 -0
  122. package/scripts/scoped-release.test.mjs +52 -0
  123. package/scripts/stability-tdd.mjs +144 -0
  124. package/scripts/stress-verify.mjs +548 -0
  125. package/scripts/symlink-support.mjs +46 -0
  126. package/scripts/sync-skill.mjs +103 -0
  127. package/scripts/tool-policies.test.mjs +280 -0
  128. package/scripts/update-skills.mjs +105 -0
  129. package/scripts/update-skills.test.mjs +79 -0
  130. package/scripts/upgrade-status.mjs +66 -0
  131. package/scripts/upgrade-status.test.mjs +83 -0
  132. package/scripts/verify-package.mjs +73 -0
  133. package/scripts/verify.mjs +2199 -0
  134. package/scripts/web-routes-verify.mjs +142 -0
  135. package/scripts/workspace-activity.test.mjs +346 -0
  136. package/scripts/workspace-summary.test.mjs +49 -0
  137. package/src/artifacts.ts +487 -0
  138. package/src/artwork-source.ts +262 -0
  139. package/src/capabilities.ts +113 -0
  140. package/src/client/ActivityPanel.module.css +2390 -0
  141. package/src/client/ActivityPanel.tsx +1507 -0
  142. package/src/client/AgentTeamsCard.module.css +148 -0
  143. package/src/client/AgentTeamsCard.tsx +155 -0
  144. package/src/client/StagingPlanEditor.tsx +829 -0
  145. package/src/client/TeamChatEntry.tsx +27 -0
  146. package/src/client/WorkspaceActivity.module.css +41 -0
  147. package/src/client/WorkspaceActivity.tsx +137 -0
  148. package/src/client/activity-model.ts +372 -0
  149. package/src/client/activity-monitor.ts +440 -0
  150. package/src/client/agent-teams-card-definition.ts +250 -0
  151. package/src/client/artwork.ts +374 -0
  152. package/src/client/icons.tsx +17 -0
  153. package/src/client/index.tsx +140 -0
  154. package/src/client/locales.ts +481 -0
  155. package/src/client/panel-geometry.ts +194 -0
  156. package/src/client/session-navigation.ts +73 -0
  157. package/src/client/workspace-state.ts +52 -0
  158. package/src/command.ts +145 -0
  159. package/src/css-modules.d.ts +4 -0
  160. package/src/event-types.ts +177 -0
  161. package/src/events.ts +78 -0
  162. package/src/harness-compat.ts +570 -0
  163. package/src/index.ts +599 -0
  164. package/src/lineage.ts +248 -0
  165. package/src/mailbox.ts +185 -0
  166. package/src/members.ts +1230 -0
  167. package/src/profiles.ts +765 -0
  168. package/src/quality-gates.ts +2124 -0
  169. package/src/scheduler.ts +554 -0
  170. package/src/snapshot.ts +333 -0
  171. package/src/state.ts +1317 -0
  172. package/src/tool-names.ts +14 -0
  173. package/src/tool-policies.ts +219 -0
  174. package/src/tools.ts +2939 -0
  175. package/src/types.ts +414 -0
  176. package/src/web-routes.ts +128 -0
  177. package/src/workspace-audit-service.ts +182 -0
  178. package/src/workspace-audit-worker.ts +12 -0
  179. package/src/workspace-audit.ts +57 -0
@@ -0,0 +1,187 @@
1
+ import assert from 'node:assert/strict'
2
+ import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, symlinkSync } from 'node:fs'
3
+ import { spawnSync } from 'node:child_process'
4
+ import { tmpdir } from 'node:os'
5
+ import { join } from 'node:path'
6
+ import { fileURLToPath } from 'node:url'
7
+ import test from 'node:test'
8
+ import { inspectInstallation } from './doctor.mjs'
9
+ import { policy, workspacePolicy, requiredHostPeers, validatePolicy, validatePackageCompatibility, declaredHostVersions } from './compatibility.mjs'
10
+ import { noSymlinkSupport } from './symlink-support.mjs'
11
+
12
+ const sourcePolicy = { ...policy, sourceCandidates: [{ version: '0.2.0', repository: 'https://github.com/deepseek-ai/deepseek-harness', commit: '21638c56315ae6a2b552d6091945d3144c9af32e', evidence: 'docs/harness-0.2.0-pre-adaptation/README.md' }] }
13
+
14
+ test('source candidates pass the peer gate without entering the published download matrix', () => {
15
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
16
+ for (const name of Object.keys(pkg.peerDependencies)) if (name.startsWith('@deepseek-ai/dsh-')) pkg.peerDependencies[name] += ' || 0.2.0'
17
+ assert.ok(declaredHostVersions(sourcePolicy).includes('0.2.0'))
18
+ assert.ok(!validatePackageCompatibility(pkg, sourcePolicy).includes('0.2.0'))
19
+ const matrix = spawnSync(process.execPath, [fileURLToPath(new URL('./compatibility.mjs', import.meta.url)), '--github-output'], { encoding: 'utf8' })
20
+ assert.equal(matrix.status, 0, matrix.stderr)
21
+ assert.ok(!JSON.parse(matrix.stdout.trim().slice('hosts='.length)).includes('0.2.0'))
22
+ for (const sourceCandidates of [
23
+ [...sourcePolicy.sourceCandidates, sourcePolicy.sourceCandidates[0]],
24
+ [{ ...sourcePolicy.sourceCandidates[0], version: '^0.2.0' }],
25
+ [{ ...sourcePolicy.sourceCandidates[0], version: '0.2.0\n' }],
26
+ [{ ...sourcePolicy.sourceCandidates[0], commit: 'master' }],
27
+ [{ ...sourcePolicy.sourceCandidates[0], version: policy.recommendedHost }],
28
+ ]) assert.throws(() => validatePolicy({ ...policy, sourceCandidates }), /Source candidates/)
29
+ pkg.peerDependencies['@deepseek-ai/dsh-agent'] = pkg.peerDependencies['@deepseek-ai/dsh-agent'].replace(' || 0.2.0', '')
30
+ assert.throws(() => validatePackageCompatibility(pkg, sourcePolicy), /source candidates/)
31
+ })
32
+
33
+ test('doctor distinguishes source-preview acceptance from released host validation', t => {
34
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-source-'))
35
+ t.after(() => rmSync(root, { recursive: true, force: true }))
36
+ writeFileSync(join(root, 'package.json'), JSON.stringify({ name: '@deepseek-ai/dsh', version: '0.2.0' }))
37
+ const result = inspectInstallation(root, undefined, sourcePolicy)
38
+ assert.equal(result.ok, true)
39
+ assert.equal(result.validation.kind, 'source-preview')
40
+ assert.equal(result.validation.sourceCommitVerified, false)
41
+ assert.equal(result.validation.commit, sourcePolicy.sourceCandidates[0].commit)
42
+ assert.ok(!result.supportedHosts.includes('0.2.0'))
43
+ assert.match(result.limits.join(), /does not verify that the installed release matches/)
44
+ })
45
+
46
+ test('doctor runs through an installed bin symlink and reports success or failure', { skip: noSymlinkSupport }, t => {
47
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-bin-'))
48
+ t.after(() => rmSync(root, { recursive: true, force: true }))
49
+ const host = join(root, 'host')
50
+ mkdirSync(host)
51
+ writeFileSync(join(host, 'package.json'), JSON.stringify({ name: '@deepseek-ai/dsh', version: policy.recommendedHost }))
52
+ const bin = join(root, 'dsh-agent-teams-doctor')
53
+ symlinkSync(fileURLToPath(new URL('./doctor.mjs', import.meta.url)), bin, 'file')
54
+ // Unix executes the installed shebang directly. Windows does not implement
55
+ // shebangs: invoke Node with the same symlink path, retaining the argv[1]
56
+ // versus import.meta.url regression without relying on a command shell.
57
+ const windows = process.platform === 'win32'
58
+ const executable = windows ? process.execPath : bin
59
+ const args = [...(windows ? [bin] : []), '--host-root', host, '--json']
60
+ const run = () => spawnSync(executable, args, { encoding: 'utf8', timeout: 5_000 })
61
+ const supported = run()
62
+ assert.equal(supported.error, undefined)
63
+ assert.equal(supported.status, 0, supported.stderr)
64
+ assert.match(supported.stdout, /"checkedPackages"/, 'bin must execute instead of silently importing the script')
65
+ assert.equal(JSON.parse(supported.stdout).ok, true)
66
+ writeFileSync(join(host, 'package.json'), JSON.stringify({ name: '@deepseek-ai/dsh', version: '0.1.0-rc.8' }))
67
+ const unsupported = run()
68
+ assert.equal(unsupported.status, 1, unsupported.stderr)
69
+ assert.equal(JSON.parse(unsupported.stdout).ok, false)
70
+ })
71
+
72
+ test('policy rejects floating targets, duplicates, and alpha recommendation', () => {
73
+ assert.deepEqual(validatePolicy(policy), policy.supportedHosts.map(host => host.version))
74
+ for (const version of ['latest', '^0.1.2-rc.1', '0.1.2-rc.1\n']) {
75
+ assert.throws(() => validatePolicy({ ...policy, supportedHosts: [{ version, track: 'recommended' }] }))
76
+ }
77
+ assert.throws(() => validatePolicy({ ...policy, supportedHosts: [...policy.supportedHosts, policy.supportedHosts[0]] }))
78
+ assert.throws(() => validatePackageCompatibility({ devDependencies: { '@deepseek-ai/dsh': '^0.1.2-rc.1' } }))
79
+ })
80
+
81
+ test('doctor detects transitive cohort mixing even with an exact CLI version', t => {
82
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-'))
83
+ t.after(() => rmSync(root, { recursive: true, force: true }))
84
+ function pkg(directory, name, version, dependencies = {}) {
85
+ mkdirSync(directory, { recursive: true })
86
+ writeFileSync(join(directory, 'package.json'), JSON.stringify({ name, version, dependencies }))
87
+ }
88
+ pkg(root, '@deepseek-ai/dsh', '0.1.2-alpha.2', { '@deepseek-ai/dsh-agent': '^0.1.2-alpha.2' })
89
+ const dependency = join(root, 'node_modules/@deepseek-ai/dsh-agent')
90
+ pkg(dependency, '@deepseek-ai/dsh-agent', '0.1.2-rc.1')
91
+ const mixed = inspectInstallation(root)
92
+ assert.equal(mixed.ok, false)
93
+ assert.equal(mixed.checkedPackages, 2)
94
+ assert.match(mixed.problems.join(), /differ from host/)
95
+ pkg(dependency, '@deepseek-ai/dsh-agent', '0.1.2-alpha.2')
96
+ assert.equal(inspectInstallation(root).ok, true)
97
+ pkg(root, '@deepseek-ai/dsh', '0.1.0-rc.8')
98
+ assert.match(inspectInstallation(root).problems.join(), /Unsupported host/)
99
+ })
100
+
101
+ test('doctor follows profile peers and rejects duplicate runtime identities', t => {
102
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-profile-'))
103
+ t.after(() => rmSync(root, { recursive: true, force: true }))
104
+ const write = (path, data) => {
105
+ mkdirSync(path, { recursive: true })
106
+ writeFileSync(join(path, 'package.json'), JSON.stringify(data))
107
+ }
108
+ write(root, { name: '@deepseek-ai/dsh', version: '0.1.2-rc.1', dependencies: { '@deepseek-ai/dsh-agent': '0.1.2-rc.1' } })
109
+ write(join(root, 'node_modules/@deepseek-ai/dsh-agent'), { name: '@deepseek-ai/dsh-agent', version: '0.1.2-rc.1' })
110
+ const profile = join(root, 'profile')
111
+ write(join(profile, 'node_modules/@fish-under-sea/dsh-agent-teams-fish'), {
112
+ name: '@fish-under-sea/dsh-agent-teams-fish', version: '0.1.16-rc.1', peerDependencies: { '@deepseek-ai/dsh-agent': '0.1.2-rc.1' },
113
+ })
114
+ write(join(profile, 'node_modules/@deepseek-ai/dsh-agent'), { name: '@deepseek-ai/dsh-agent', version: '0.1.2-rc.1' })
115
+ assert.match(inspectInstallation(root, profile).problems.join(), /Multiple resolved identities/)
116
+ })
117
+
118
+ test('policy rejects missing or mixed development overrides', () => {
119
+ const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
120
+ const workspace = structuredClone(workspacePolicy)
121
+ assert.doesNotThrow(() => validatePackageCompatibility(pkg))
122
+ delete workspace.overrides['@deepseek-ai/dsh-agent']
123
+ assert.throws(() => validatePackageCompatibility(pkg, policy, workspace), /override/)
124
+ workspace.overrides['@deepseek-ai/dsh-agent'] = '0.1.2-alpha.2'
125
+ assert.throws(() => validatePackageCompatibility(pkg, policy, workspace), /override/)
126
+ assert.throws(() => validatePackageCompatibility({ ...pkg, pnpm: { overrides: {} } }), /pnpm-workspace/)
127
+ })
128
+
129
+ test('policy rejects removed host peers and range-qualified or conditional DSH overrides', () => {
130
+ const original = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'))
131
+ for (const name of requiredHostPeers) {
132
+ const pkg = structuredClone(original)
133
+ delete pkg.peerDependencies[name]
134
+ assert.throws(() => validatePackageCompatibility(pkg), /Missing required host peer/)
135
+ }
136
+ for (const selector of ['parent>@deepseek-ai/dsh-agent', '@deepseek-ai/dsh-agent@^0.1.2', '@deepseek-ai/dsh@>=0.1>react']) {
137
+ const pkg = structuredClone(original)
138
+ const workspace = structuredClone(workspacePolicy)
139
+ workspace.overrides[selector] = policy.recommendedHost
140
+ assert.throws(() => validatePackageCompatibility(pkg, policy, workspace), /bare DSH package name/)
141
+ }
142
+ })
143
+
144
+ test('doctor reports missing nonoptional Cordis peers and required plugin imports even with optional metadata', t => {
145
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-required-'))
146
+ t.after(() => rmSync(root, { recursive: true, force: true }))
147
+ const write = (path, data) => {
148
+ mkdirSync(path, { recursive: true })
149
+ writeFileSync(join(path, 'package.json'), JSON.stringify(data))
150
+ }
151
+ write(root, { name: '@deepseek-ai/dsh', version: policy.recommendedHost, peerDependencies: { '@deepseek-ai/cordis': '^4.0.2' } })
152
+ assert.match(inspectInstallation(root).problems.join(), /Missing packages.*cordis/)
153
+ write(join(root, 'node_modules/@deepseek-ai/cordis'), { name: '@deepseek-ai/cordis', version: '4.0.2' })
154
+ const profile = join(root, 'profile')
155
+ write(join(profile, 'node_modules/@fish-under-sea/dsh-agent-teams-fish'), {
156
+ name: '@fish-under-sea/dsh-agent-teams-fish', version: '0.1.16-rc.1',
157
+ peerDependencies: { '@deepseek-ai/dsh-subagent': policy.recommendedHost },
158
+ peerDependenciesMeta: { '@deepseek-ai/dsh-subagent': { optional: true } },
159
+ })
160
+ assert.match(inspectInstallation(root, profile).problems.join(), /dsh-subagent \(plugin runtime\)/)
161
+ })
162
+
163
+ test('doctor detects peer-only drift and a mismatched installed plugin', t => {
164
+ const root = mkdtempSync(join(tmpdir(), 'agent-teams-doctor-peer-'))
165
+ t.after(() => rmSync(root, { recursive: true, force: true }))
166
+ const write = (path, data) => {
167
+ mkdirSync(path, { recursive: true })
168
+ writeFileSync(join(path, 'package.json'), JSON.stringify(data))
169
+ }
170
+ write(root, { name: '@deepseek-ai/dsh', version: '0.1.2-rc.1', dependencies: { '@deepseek-ai/dsh-agent': '0.1.2-rc.1' } })
171
+ write(join(root, 'node_modules/@deepseek-ai/dsh-agent'), {
172
+ name: '@deepseek-ai/dsh-agent', version: '0.1.2-rc.1', peerDependencies: { '@deepseek-ai/dsh-session': '*' },
173
+ })
174
+ write(join(root, 'node_modules/@deepseek-ai/dsh-session'), { name: '@deepseek-ai/dsh-session', version: '0.1.2-alpha.2' })
175
+ assert.match(inspectInstallation(root).problems.join(), /differ from host/)
176
+ write(join(root, 'node_modules/@deepseek-ai/dsh-session'), { name: '@deepseek-ai/dsh-session', version: '0.1.2-rc.1' })
177
+ assert.equal(inspectInstallation(root).ok, true)
178
+ const profile = join(root, 'profile')
179
+ write(join(profile, 'node_modules/@fish-under-sea/dsh-agent-teams-fish'), { name: '@fish-under-sea/dsh-agent-teams-fish', version: '0.1.15' })
180
+ assert.match(inspectInstallation(root, profile).problems.join(), /0\.1\.15/)
181
+ })
182
+
183
+ test('released target enters the download matrix and replaces the old source prediction', () => {
184
+ assert.equal(policy.recommendedHost, '0.2.2-rc.1')
185
+ assert.ok(validatePolicy(policy).includes('0.2.2-rc.1'))
186
+ assert.ok(!declaredHostVersions().includes('0.2.0'))
187
+ })
@@ -0,0 +1,180 @@
1
+ import test from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+ import { mkdtemp, mkdir, writeFile, rm, chmod } from 'node:fs/promises'
4
+ import { tmpdir } from 'node:os'
5
+ import { join } from 'node:path'
6
+
7
+ // Regression test for the corrupt-team.json issue: a state file that exists
8
+ // but fails JSON parsing (truncated write, disk corruption, manual edit,
9
+ // merge-conflict markers) must never leak a raw SyntaxError through the two
10
+ // global host integration points:
11
+ // A) the `agent/pre-step` mailbox-admission hook (src/mailbox.ts)
12
+ // B) the member delegation guard wrapping subagents.start (src/members.ts)
13
+ // Node >= 23.6 imports the type-stripping-compatible plugin sources directly.
14
+ const { installMailboxAdmission } = await import('../src/mailbox.ts')
15
+ const { installMemberDelegationGuard } = await import('../src/members.ts')
16
+ const { SUBAGENT_DESCRIPTOR_VERSION } = await import('@deepseek-ai/dsh-subagent')
17
+
18
+ const STATE_DIR = '.agent-teams-state'
19
+ const CAPTAIN_ID = 'captain-session-0001'
20
+ const MEMBER_ID = 'member-session-0001'
21
+ const MEMBER_NAME = 'alice'
22
+ const TEAM_ID = 'team-a'
23
+ const NOW = 1_700_000_000_000
24
+ const CORRUPT_JSON = '{"id": "team-a", "members": [ TRUNCATED'
25
+
26
+ const validTeam = (overrides = {}) => ({
27
+ id: TEAM_ID,
28
+ name: 'Corrupt State Team',
29
+ captainSessionId: CAPTAIN_ID,
30
+ createdAt: NOW,
31
+ members: [{ id: MEMBER_ID, name: MEMBER_NAME, role: 'engineer', joinedAt: NOW, status: 'idle' }],
32
+ tasks: [],
33
+ taskSeq: 0,
34
+ ...overrides,
35
+ })
36
+
37
+ async function workspaceWith(team) {
38
+ const root = await mkdtemp(join(tmpdir(), 'corrupt-teamjson-test-'))
39
+ const stateRoot = join(root, STATE_DIR)
40
+ await mkdir(join(stateRoot, TEAM_ID, 'inbox'), { recursive: true })
41
+ await writeFile(join(stateRoot, TEAM_ID, 'team.json'), typeof team === 'string' ? team : JSON.stringify(team, null, 2))
42
+ return { root, stateRoot }
43
+ }
44
+
45
+ function memberSession(cwd) {
46
+ return {
47
+ header: { cwd },
48
+ ownEvents: () => [{
49
+ type: 'subagent/descriptor',
50
+ data: { version: SUBAGENT_DESCRIPTOR_VERSION, mode: 'continuable', provider: 'in-process', label: `agent-teams:${TEAM_ID}:${MEMBER_NAME}` },
51
+ }],
52
+ }
53
+ }
54
+
55
+ /** Minimal ctx whose logger captures warnings and whose `on` records the hook. */
56
+ function hookContext() {
57
+ const listeners = new Map()
58
+ const warnings = []
59
+ const ctx = { on: (name, listener) => { listeners.set(name, listener); return () => listeners.delete(name) }, logger: { warn: m => warnings.push(m) } }
60
+ return { ctx, listeners, warnings }
61
+ }
62
+
63
+ const settlementDecision = () => ({
64
+ kind: 'enter',
65
+ messages: [{
66
+ source: {
67
+ kind: 'subagent-settled',
68
+ senderSessionId: MEMBER_ID,
69
+ summary: `Background subagent ${MEMBER_ID} finished and will do no further work unless you send it more.`,
70
+ },
71
+ content: [],
72
+ }],
73
+ })
74
+
75
+ test('A1: corrupt team.json degrades mailbox admission to plain pass-through instead of escaping the pre-step hook', async t => {
76
+ const { root, stateRoot } = await workspaceWith(CORRUPT_JSON)
77
+ t.after(() => rm(root, { recursive: true, force: true }))
78
+ const { ctx, listeners, warnings } = hookContext()
79
+ installMailboxAdmission(ctx, STATE_DIR)
80
+ const decision = settlementDecision()
81
+ const result = await listeners.get('agent/pre-step')(
82
+ { agent: { id: CAPTAIN_ID, session: { header: { cwd: root }, ownEvents: () => [] } }, turn: 1 },
83
+ async () => decision,
84
+ )
85
+ assert.equal(result.kind, 'enter', 'host step must be admitted')
86
+ assert.deepEqual(result.messages, decision.messages, 'settlement inputs must pass through untouched')
87
+ assert.ok(warnings.some(m => m.includes('mailbox admission degraded')), 'degradation must be logged')
88
+ await rm(stateRoot, { recursive: true, force: true })
89
+ })
90
+
91
+ test('A2: valid team.json keeps mailbox admission working on the same hook path', async t => {
92
+ const { root } = await workspaceWith(validTeam())
93
+ t.after(() => rm(root, { recursive: true, force: true }))
94
+ const { ctx, listeners, warnings } = hookContext()
95
+ installMailboxAdmission(ctx, STATE_DIR)
96
+ const result = await listeners.get('agent/pre-step')(
97
+ { agent: { id: CAPTAIN_ID, session: { header: { cwd: root }, ownEvents: () => [] } }, turn: 1 },
98
+ async () => settlementDecision(),
99
+ )
100
+ assert.equal(result.kind, 'enter')
101
+ assert.equal(warnings.length, 0, 'no degradation warning on valid state')
102
+ })
103
+
104
+ test('B1: corrupt team.json rejects delegated spawn with an actionable error, not a raw SyntaxError', async t => {
105
+ const { root } = await workspaceWith(CORRUPT_JSON)
106
+ t.after(() => rm(root, { recursive: true, force: true }))
107
+ const runtime = { start: async () => ({ childId: 'child' }), startContinuable: async () => ({ childId: 'child' }) }
108
+ const ctx = { subagents: runtime, agents: { get: () => undefined }, effect: f => f() }
109
+ installMemberDelegationGuard(ctx, STATE_DIR, 1)
110
+ await assert.rejects(
111
+ runtime.start('child', { parent: { id: MEMBER_ID, session: memberSession(root) } }),
112
+ error => !(error instanceof SyntaxError)
113
+ && /delegation guard could not read the team state/.test(error.message)
114
+ && error.message.includes('team.json'),
115
+ 'guard must reject with a clean, actionable message naming the corrupt file',
116
+ )
117
+ })
118
+
119
+ test('B2: valid team.json with a removed member still gets the intended guard rejection', async t => {
120
+ const { root } = await workspaceWith(validTeam({
121
+ members: [{ id: MEMBER_ID, name: MEMBER_NAME, role: 'engineer', joinedAt: NOW, status: 'removed' }],
122
+ }))
123
+ t.after(() => rm(root, { recursive: true, force: true }))
124
+ const runtime = { start: async () => ({ childId: 'child' }), startContinuable: async () => ({ childId: 'child' }) }
125
+ const ctx = { subagents: runtime, agents: { get: () => undefined }, effect: f => f() }
126
+ installMemberDelegationGuard(ctx, STATE_DIR, 1)
127
+ await assert.rejects(
128
+ runtime.start('child', { parent: { id: MEMBER_ID, session: memberSession(root) } }),
129
+ /no longer admitting delegated work/,
130
+ )
131
+ })
132
+
133
+ test('B3: valid team.json still enforces the member delegation depth limit', async t => {
134
+ const { root } = await workspaceWith(validTeam())
135
+ t.after(() => rm(root, { recursive: true, force: true }))
136
+ const runtime = { start: async () => ({ childId: 'grandchild' }), startContinuable: async () => ({ childId: 'grandchild' }) }
137
+ const memberAgent = { id: MEMBER_ID, session: memberSession(root) }
138
+ const ctx = { subagents: runtime, agents: { get: id => (id === MEMBER_ID ? memberAgent : undefined) }, effect: f => f() }
139
+ installMemberDelegationGuard(ctx, STATE_DIR, 1)
140
+ const descendant = { id: 'descendant-1', session: { header: { cwd: root, parentSession: MEMBER_ID }, ownEvents: () => [] } }
141
+ await assert.rejects(
142
+ runtime.start('grandchild', { parent: descendant }),
143
+ /delegation limit \(1\) reached/,
144
+ )
145
+ })
146
+
147
+ const isRoot = typeof process.getuid === 'function' && process.getuid() === 0
148
+
149
+ test('B4: unreadable (EACCES) team.json rejects delegated spawn with the actionable guard error', async t => {
150
+ if (process.platform === 'win32') { t.skip('Windows chmod does not enforce POSIX read permissions; skipping') ; return }
151
+ if (isRoot) { t.skip('chmod-based EACCES is not enforced for root; skipping') ; return }
152
+ const { root } = await workspaceWith(validTeam())
153
+ t.after(() => rm(root, { recursive: true, force: true }))
154
+ await chmod(join(root, STATE_DIR, TEAM_ID, 'team.json'), 0o000)
155
+ const runtime = { start: async () => ({ childId: 'child' }), startContinuable: async () => ({ childId: 'child' }) }
156
+ const ctx = { subagents: runtime, agents: { get: () => undefined }, effect: f => f() }
157
+ installMemberDelegationGuard(ctx, STATE_DIR, 1)
158
+ await assert.rejects(
159
+ runtime.start('child', { parent: { id: MEMBER_ID, session: memberSession(root) } }),
160
+ error => !(error instanceof SyntaxError)
161
+ && /delegation guard could not read the team state/.test(error.message)
162
+ && error.message.includes('unreadable')
163
+ && /EACCES/.test(error.message),
164
+ 'guard must surface the EACCES cause inside the clean, actionable message',
165
+ )
166
+ })
167
+
168
+ test('B5: missing state directory (ENOENT guard branch) yields the intended member rejection, not a read error', async t => {
169
+ const root = await mkdtemp(join(tmpdir(), 'corrupt-teamjson-empty-'))
170
+ t.after(() => rm(root, { recursive: true, force: true }))
171
+ const runtime = { start: async () => ({ childId: 'child' }), startContinuable: async () => ({ childId: 'child' }) }
172
+ const ctx = { subagents: runtime, agents: { get: () => undefined }, effect: f => f() }
173
+ installMemberDelegationGuard(ctx, STATE_DIR, 1)
174
+ await assert.rejects(
175
+ runtime.start('child', { parent: { id: MEMBER_ID, session: memberSession(root) } }),
176
+ error => /no longer admitting delegated work/.test(error.message)
177
+ && !/could not read the team state/.test(error.message),
178
+ 'ENOENT must map to undefined team state and the normal member rejection',
179
+ )
180
+ })
@@ -0,0 +1,273 @@
1
+ /**
2
+ * Artwork resolution checks: the packaged slugs, the vendor-namespace lookup
3
+ * chain, and custom-directory resolution.
4
+ *
5
+ * Run after `tsc -p tsconfig.json`:
6
+ * node --test scripts/custom-artwork.test.mjs
7
+ */
8
+
9
+ import { test } from 'node:test'
10
+ import assert from 'node:assert/strict'
11
+ import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises'
12
+ import { tmpdir } from 'node:os'
13
+ import { join } from 'node:path'
14
+ import {
15
+ ARTWORK_ROLES,
16
+ ARTWORK_VENDORS,
17
+ PACKAGED_ARTWORK_SLUGS,
18
+ artworkCandidates,
19
+ artworkStems,
20
+ findCustomArtwork,
21
+ findPackagedArtwork,
22
+ isAllowedArtwork,
23
+ packagedArtworkContentType,
24
+ packagedArtworkNames,
25
+ } from '../lib/artwork-source.js'
26
+
27
+ const PNG = Buffer.from('89504e470d0a1a0a', 'hex')
28
+
29
+ async function artDir() {
30
+ const dir = await mkdtemp(join(tmpdir(), 'agent-teams-art-'))
31
+ return { dir, done: () => rm(dir, { recursive: true, force: true }) }
32
+ }
33
+
34
+ test('every packaged slug stays servable exactly as shipped', () => {
35
+ assert.equal(PACKAGED_ARTWORK_SLUGS.length, 15)
36
+ for (const slug of PACKAGED_ARTWORK_SLUGS) {
37
+ assert.deepEqual(artworkCandidates(slug), [slug], `${slug} must resolve to itself`)
38
+ assert.ok(isAllowedArtwork(slug), `${slug} must stay allowed`)
39
+ }
40
+ })
41
+
42
+ test('vendor namespaces cover the 18 vendors and 10 roles', () => {
43
+ assert.equal(ARTWORK_VENDORS.length, 18)
44
+ assert.equal(ARTWORK_ROLES.length, 10)
45
+ assert.ok(ARTWORK_VENDORS.includes('deepseek'))
46
+ assert.ok(ARTWORK_VENDORS.includes('hunyuan'))
47
+ // 2026-10-08:第二轮素材新增的 6 个厂商;前 10 个有厂商 × 岗位图,这 6 个里只有
48
+ // minimax 有,其余沿厂商通用图兜底。
49
+ for (const vendor of ['minimax', 'meta', 'mistral', 'rwkv', 'seed', 'ernie']) {
50
+ assert.ok(ARTWORK_VENDORS.includes(vendor), `${vendor} 必须在厂商表里`)
51
+ }
52
+ // 2026-10-11:第三轮素材新增 stepfun / jev —— 两个都只有厂商通用图与立绘,
53
+ // 岗位请求沿 `member-<vendor>-v2.png` 兜底(与 meta / rwkv 等同一档)。
54
+ for (const vendor of ['stepfun', 'jev']) {
55
+ assert.ok(ARTWORK_VENDORS.includes(vendor), `${vendor} 必须在厂商表里`)
56
+ }
57
+ // 2026-10-12:新增 mimo(小米 MiMo),同样只有厂商通用图与立绘。
58
+ assert.ok(ARTWORK_VENDORS.includes('mimo'), 'mimo 必须在厂商表里')
59
+ assert.ok(ARTWORK_ROLES.includes('operator'))
60
+ // 2026-10-05 登记、2026-10-08 出图:audio / video 已有 10 个厂商的岗位图。
61
+ assert.ok(ARTWORK_ROLES.includes('audio'))
62
+ assert.ok(ARTWORK_ROLES.includes('video'))
63
+ })
64
+
65
+ test('a brand request for a newly added vendor stays inside the family', () => {
66
+ assert.deepEqual(artworkCandidates('brand-minimax.svg'), [
67
+ 'brand-minimax.svg',
68
+ 'brand-minimax.png',
69
+ 'brand.svg',
70
+ 'brand.png',
71
+ ])
72
+ // 新厂商的岗位图缺失时先沿 vendor 兜底(自家角色),岗位通用图留作链尾。
73
+ assert.deepEqual(artworkCandidates('member-ernie-engineer-v2.png'), [
74
+ 'member-ernie-engineer-v2.png',
75
+ 'member-ernie-v2.png',
76
+ 'member-engineer-v2.png',
77
+ ])
78
+ })
79
+
80
+ test('a brand request lists the svg, its png sibling, then the family default', () => {
81
+ assert.deepEqual(artworkCandidates('brand-hunyuan.svg'), [
82
+ 'brand-hunyuan.svg',
83
+ 'brand-hunyuan.png',
84
+ 'brand.svg',
85
+ 'brand.png',
86
+ ])
87
+ })
88
+
89
+ test('a brand request for an unknown vendor is refused', () => {
90
+ assert.deepEqual(artworkCandidates('brand-nope.svg'), [])
91
+ })
92
+
93
+ test('a non-png member request stays refused even after the brand family', () => {
94
+ assert.deepEqual(artworkCandidates('member-deepseek-qa-v2.svg'), [])
95
+ })
96
+
97
+ test('a vendor+role request degrades to the vendor character, then the role', () => {
98
+ // 2026-10-11 修复:链序曾是 `vendor+role → role → vendor`。岗位通用图(随包鲸鱼)对
99
+ // 每个岗位都存在,所以「岗位」那一跳**永远**抢先命中,「厂商通用图」那一跳是死代码 ——
100
+ // 于是只有通用档的 7 家(meta / mistral / rwkv / seed / ernie / stepfun / jev)的
101
+ // 厂商角色永远不可达:徽标明明显示 StepFun,头像却是通用岗位鲸鱼(用户截图现场)。
102
+ // 现在把厂商那一跳提到岗位之前:厂商身份是这套头像的主诉求,岗位图仍然在链尾兜底。
103
+ assert.deepEqual(artworkCandidates('member-deepseek-qa-v2.png'), [
104
+ 'member-deepseek-qa-v2.png',
105
+ 'member-deepseek-v2.png',
106
+ 'member-qa-v2.png',
107
+ ])
108
+ })
109
+
110
+ test('a generic-only vendor reaches its own character on the second hop', () => {
111
+ // 只有通用图的厂商:第 1 跳落空后必须命中自家角色,而不是掉回岗位通用鲸鱼。
112
+ for (const vendor of ['meta', 'mistral', 'rwkv', 'seed', 'ernie', 'stepfun', 'jev', 'mimo']) {
113
+ assert.deepEqual(artworkCandidates(`member-${vendor}-qa-v2.png`), [
114
+ `member-${vendor}-qa-v2.png`,
115
+ `member-${vendor}-v2.png`,
116
+ 'member-qa-v2.png',
117
+ ], `${vendor} 的厂商角色必须可达`)
118
+ }
119
+ })
120
+
121
+ test('a -full request prefers the vendor HD art over the role avatar', () => {
122
+ // 厂商立绘(member-<vendor>-full-v2.webp)此前同样是死文件:`-full` 链在岗位那一段
123
+ // 就命中 256 头像,厂商大图永远轮不到。点击放大必须给出厂商立绘。
124
+ assert.deepEqual(artworkCandidates('member-deepseek-qa-full-v2.png'), [
125
+ 'member-deepseek-qa-full-v2.png',
126
+ 'member-deepseek-qa-v2.png',
127
+ 'member-deepseek-full-v2.png',
128
+ 'member-deepseek-v2.png',
129
+ 'member-qa-full-v2.png',
130
+ 'member-qa-v2.png',
131
+ ])
132
+ })
133
+
134
+ test('the captain degrades per vendor, then to the packaged whale', () => {
135
+ assert.deepEqual(artworkCandidates('team-lead-deepseek-v2.png'), [
136
+ 'team-lead-deepseek-v2.png',
137
+ 'team-lead-v2.png',
138
+ ])
139
+ assert.deepEqual(artworkCandidates('team-lead-v2.png'), ['team-lead-v2.png'])
140
+ })
141
+
142
+ test('foreign names never reach the filesystem', () => {
143
+ for (const slug of [
144
+ '../secret.png',
145
+ '/etc/passwd',
146
+ 'nope.png',
147
+ 'team-lead-evil-v2.png',
148
+ 'action-nope-v2.png',
149
+ 'member-deepseek-qa-v2.svg',
150
+ ]) {
151
+ assert.equal(isAllowedArtwork(slug), false, `${slug} must be rejected`)
152
+ assert.deepEqual(artworkCandidates(slug), [])
153
+ }
154
+ })
155
+
156
+ test('an unknown vendor or role token degrades to what is known', () => {
157
+ // A provider this fork does not know still gets the role artwork instead of
158
+ // a broken image; unknown tokens never appear in a candidate name.
159
+ assert.deepEqual(artworkCandidates('member-evil-qa-v2.png'), ['member-qa-v2.png'])
160
+ assert.deepEqual(artworkCandidates('member-deepseek-evil-v2.png'), ['member-deepseek-v2.png'])
161
+ assert.deepEqual(artworkCandidates('member-deepseek-qa-evil-v2.png'), [
162
+ 'member-deepseek-qa-v2.png',
163
+ 'member-deepseek-v2.png',
164
+ 'member-qa-v2.png',
165
+ ])
166
+ })
167
+
168
+ test('stems probe the exact name before the -v2-less alias', () => {
169
+ assert.deepEqual(artworkStems('member-qa-v2.png'), ['member-qa-v2', 'member-qa'])
170
+ assert.deepEqual(artworkStems('member-deepseek-qa-v2.png'), ['member-deepseek-qa-v2', 'member-deepseek-qa'])
171
+ })
172
+
173
+ test('the exact vendor+role file wins and keeps its media type', async () => {
174
+ const { dir, done } = await artDir()
175
+ try {
176
+ await writeFile(join(dir, 'member-deepseek-qa-v2.png'), PNG)
177
+ await writeFile(join(dir, 'member-qa-v2.png'), Buffer.from('other'))
178
+ const found = await findCustomArtwork(dir, 'member-deepseek-qa-v2.png')
179
+ assert.equal(found?.path, join(dir, 'member-deepseek-qa-v2.png'))
180
+ assert.equal(found?.contentType, 'image/png')
181
+ assert.deepEqual(found?.data, PNG)
182
+ } finally {
183
+ await done()
184
+ }
185
+ })
186
+
187
+ test('the -v2-less alias answers the same slug', async () => {
188
+ const { dir, done } = await artDir()
189
+ try {
190
+ await writeFile(join(dir, 'team-lead-deepseek.png'), PNG)
191
+ const found = await findCustomArtwork(dir, 'team-lead-deepseek-v2.png')
192
+ assert.equal(found?.path, join(dir, 'team-lead-deepseek.png'))
193
+ } finally {
194
+ await done()
195
+ }
196
+ })
197
+
198
+ test('other image formats resolve with their own media type', async () => {
199
+ const { dir, done } = await artDir()
200
+ try {
201
+ await writeFile(join(dir, 'member-deepseek-engineer-v2.webp'), PNG)
202
+ await writeFile(join(dir, 'member-deepseek-docs-v2.svg'), '<svg/>')
203
+ assert.equal((await findCustomArtwork(dir, 'member-deepseek-engineer-v2.png'))?.contentType, 'image/webp')
204
+ assert.equal((await findCustomArtwork(dir, 'member-deepseek-docs-v2.png'))?.contentType, 'image/svg+xml')
205
+ } finally {
206
+ await done()
207
+ }
208
+ })
209
+
210
+ test('unknown slugs and missing directories fall back to packaged art', async () => {
211
+ const { dir, done } = await artDir()
212
+ try {
213
+ assert.equal(await findCustomArtwork(dir, '../secret.png'), undefined)
214
+ assert.equal(await findCustomArtwork(dir, 'member-deepseek-qa-v2.png'), undefined)
215
+ assert.equal(await findCustomArtwork(join(dir, 'nope'), 'member-deepseek-qa-v2.png'), undefined)
216
+ } finally {
217
+ await done()
218
+ }
219
+ })
220
+
221
+ test('member/leader candidates probe every accepted extension inside the bundle', () => {
222
+ // 高清预览族随包的是 .webp,而客户端请求的永远是 .png 名字。
223
+ assert.deepEqual(packagedArtworkNames('member-deepseek-qa-full-v2.png').slice(0, 3), [
224
+ 'member-deepseek-qa-full-v2.png',
225
+ 'member-deepseek-qa-full-v2.webp',
226
+ 'member-deepseek-qa-full-v2.jpg',
227
+ ])
228
+ assert.equal(packagedArtworkNames('member-deepseek-qa-full-v2.png').at(-1), 'member-deepseek-qa-full-v2.svg')
229
+ assert.deepEqual(packagedArtworkNames('team-lead-qwen-full-v2.png').slice(0, 2), [
230
+ 'team-lead-qwen-full-v2.png',
231
+ 'team-lead-qwen-full-v2.webp',
232
+ ])
233
+ // 商标与活动状态图保持严格候选名,避免改动它们既有的 .svg 优先顺序。
234
+ assert.deepEqual(packagedArtworkNames('brand-minimax.svg'), ['brand-minimax.svg'])
235
+ assert.deepEqual(packagedArtworkNames('brand.svg'), ['brand.svg'])
236
+ assert.deepEqual(packagedArtworkNames('action-working-v2.png'), ['action-working-v2.png'])
237
+ })
238
+
239
+ test('a packaged -full request answers the webp sibling with the webp media type', async () => {
240
+ const { dir, done } = await artDir()
241
+ try {
242
+ await writeFile(join(dir, 'member-deepseek-security-full-v2.webp'), Buffer.from('WEBP'))
243
+ const hit = await findPackagedArtwork(dir, 'member-deepseek-security-full-v2.png')
244
+ assert.equal(hit?.path, join(dir, 'member-deepseek-security-full-v2.webp'))
245
+ assert.equal(hit?.contentType, 'image/webp')
246
+ assert.deepEqual(hit?.data, Buffer.from('WEBP'))
247
+ // 同一 stem 的 .png 一旦存在仍然优先(头像族随包的就是 PNG)。
248
+ await writeFile(join(dir, 'member-deepseek-security-v2.png'), Buffer.from('PNG'))
249
+ assert.equal((await findPackagedArtwork(dir, 'member-deepseek-security-v2.png'))?.contentType, 'image/png')
250
+ assert.equal(await findPackagedArtwork(dir, 'member-deepseek-qa-v2.png'), undefined)
251
+ } finally {
252
+ await done()
253
+ }
254
+ })
255
+
256
+ test('a directory named like a slug is not served as artwork', async () => {
257
+ const { dir, done } = await artDir()
258
+ try {
259
+ await mkdir(join(dir, 'member-deepseek-qa-v2.png'))
260
+ assert.equal(await findCustomArtwork(dir, 'member-deepseek-qa-v2.png'), undefined)
261
+ } finally {
262
+ await done()
263
+ }
264
+ })
265
+
266
+ test('a packaged slug keeps the media type of its own extension', () => {
267
+ // The bundle carries PNG artwork *and* brand SVGs; assuming PNG for every
268
+ // packaged file is what made badges silently vanish in 0.3.1.
269
+ assert.equal(packagedArtworkContentType('member-qwen-qa-v2.png'), 'image/png')
270
+ assert.equal(packagedArtworkContentType('brand-deepseek.svg'), 'image/svg+xml')
271
+ assert.equal(packagedArtworkContentType('brand-qwen.png'), 'image/png')
272
+ assert.equal(packagedArtworkContentType('member-qwen-qa-v2.webp'), 'image/webp')
273
+ })