dsh-codearts-dock 0.0.0-stage → 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 (50) hide show
  1. package/DISCLAIMER.md +47 -0
  2. package/LICENSE +21 -0
  3. package/README.md +172 -2
  4. package/SECURITY.md +47 -0
  5. package/THIRD_PARTY_NOTICES.md +64 -0
  6. package/client.js +3519 -0
  7. package/cordis.patch.yml +10 -0
  8. package/docs/DETAIL.md +25 -0
  9. package/docs/DETAIL.zh.md +25 -0
  10. package/docs/PUBLISHING.md +43 -0
  11. package/docs/preview.svg +78 -0
  12. package/icons/dsh-connect-codearts-128.png +0 -0
  13. package/icons/dsh-connect-codearts-256.png +0 -0
  14. package/locale/en.json +7 -0
  15. package/locale/zh.json +7 -0
  16. package/package.json +88 -4
  17. package/scripts/build-market-index.mjs +24 -0
  18. package/scripts/check-legal.sh +33 -0
  19. package/scripts/check-release.mjs +29 -0
  20. package/scripts/test.mjs +11 -0
  21. package/src/account.js +217 -0
  22. package/src/accounts.js +481 -0
  23. package/src/adapter.js +742 -0
  24. package/src/backup.js +89 -0
  25. package/src/catalog.js +269 -0
  26. package/src/checkin.js +271 -0
  27. package/src/credentials.js +435 -0
  28. package/src/features.js +79 -0
  29. package/src/gateway.js +521 -0
  30. package/src/health.js +18 -0
  31. package/src/index.js +1108 -0
  32. package/src/models.js +147 -0
  33. package/src/paths.js +36 -0
  34. package/src/preferences.js +90 -0
  35. package/src/protocol/crypto.js +160 -0
  36. package/src/protocol/sign.js +176 -0
  37. package/src/protocol/sm4.js +264 -0
  38. package/src/protocol/sse.js +134 -0
  39. package/src/sts.js +118 -0
  40. package/src/usage.js +55 -0
  41. package/test/accounts.test.mjs +322 -0
  42. package/test/adapter.test.mjs +234 -0
  43. package/test/assembler.test.mjs +86 -0
  44. package/test/features.test.mjs +257 -0
  45. package/test/live-probe.mjs +55 -0
  46. package/test/protocol.test.mjs +167 -0
  47. package/test/registration.test.mjs +301 -0
  48. package/test/sm4.test.mjs +64 -0
  49. package/test/ui.test.mjs +370 -0
  50. package/test/visual.test.mjs +438 -0
@@ -0,0 +1,438 @@
1
+ /**
2
+ * Visual-contract checks against the reference connector card.
3
+ *
4
+ * The two plugins are both connector cards in the same settings panel, so a
5
+ * user sees them side by side and expects the same visual language. This test
6
+ * pins the VALUES, not just the class names: an earlier audit passed because it
7
+ * matched `.dca-btn` existing while the rule underneath had drifted back to the
8
+ * old padding. Every assertion here is a number or a token taken from the
9
+ * reference's stylesheet.
10
+ *
11
+ * It reads the shipped browser half as text, so it runs without a DOM.
12
+ */
13
+
14
+ import assert from 'node:assert/strict'
15
+ import { readFileSync } from 'node:fs'
16
+
17
+ const results = []
18
+ const check = (name, fn) => {
19
+ try {
20
+ fn()
21
+ results.push(`✓ ${name}`)
22
+ } catch (error) {
23
+ results.push(`✗ ${name}\n ${error.message}`)
24
+ process.exitCode = 1
25
+ }
26
+ }
27
+
28
+ const source = readFileSync(new URL('../client.js', import.meta.url), 'utf8')
29
+
30
+ /** Assert one exact declaration substring appears in the stylesheet. */
31
+ const has = (needle, why) => {
32
+ assert.ok(source.includes(needle), `${why}\n missing: ${needle}`)
33
+ }
34
+
35
+ check('buttons use the reference geometry and its inverted primary', () => {
36
+ has('padding:5px 14px;border-radius:8px;min-height:32px', 'button box')
37
+ has('background:var(--dsw-alias-label-primary,#e6e6e6)', 'primary is an inverted surface, not a brand fill')
38
+ // Inline row actions are one step smaller, not a different shape.
39
+ has('font-size:12px;line-height:20px;font-weight:500;\n padding:3px 10px', 'small button')
40
+ })
41
+
42
+ check('inputs are monospace 12/20 on bg-l1', () => {
43
+ has('padding:4px 8px;border-radius:6px', 'input box')
44
+ has('font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace', 'input is monospace')
45
+ has('background:var(--dsw-alias-bg-l1,transparent)', 'input rests on bg-l1')
46
+ })
47
+
48
+ check('cards sit on bg-layer-3 with a border-l2 frame at radius 12', () => {
49
+ has('border-radius:12px;background:var(--dsw-alias-bg-layer-3', 'card surface')
50
+ has('.dca-card:hover{border-color:var(--dsw-alias-label-dimmed,#777)}', 'card brightens on hover')
51
+ })
52
+
53
+ check('the section switcher is a sticky underlined tab strip, not cards', () => {
54
+ has('padding:7px 11px;margin-bottom:-1px', 'tab geometry')
55
+ has('border-bottom:2px solid transparent', 'tab underline is the state carrier')
56
+ assert.ok(source.includes('position:sticky'), 'the strip must pin above scrolling content')
57
+ assert.ok(
58
+ !source.includes('dca-tab-cell'),
59
+ 'card-shaped tab cells are not the reference shape and must not come back',
60
+ )
61
+ })
62
+
63
+ check('the account pool is a grid table with an uppercase header row', () => {
64
+ has('grid-template-areas:', 'pool rows are a grid, so columns reflow on a narrow panel')
65
+ has('text-transform:uppercase', 'header row is uppercase')
66
+ has('font-size:11px;font-weight:600;letter-spacing:.02em', 'header typography')
67
+ has('padding:10px 14px', 'row rhythm')
68
+ })
69
+
70
+ check('one bulk claim button sits beside the daily switch', () => {
71
+ // Restored on request, in the place the reference puts it: one control for the
72
+ // whole pool, on the switch row. Still NEVER one per row — a daily bonus must
73
+ // not cost one click per account.
74
+ assert.ok(source.includes("'pool.checkinAll': ['一键签到'"), 'the bulk button exists')
75
+ assert.ok(source.includes('dca-checkin-now'), 'and sits on the switch row')
76
+ assert.ok(
77
+ !source.includes('dca-pool-col-checkin'),
78
+ 'never a per-row claim control',
79
+ )
80
+ // Disabled when there is nothing to claim, so a press that cannot act never
81
+ // looks like a broken button.
82
+ assert.ok(source.includes('disabled: anyBusy || busyId !== null || !anyClaimable'), 'disabled with nothing to claim')
83
+ assert.ok(source.includes("allSigned ? t('pool.allSigned')"), 'explains when the whole pool is already done')
84
+ })
85
+
86
+ check('import lives inside the add-account card, revealed on demand', () => {
87
+ assert.ok(source.includes("className: 'dca-card dca-details dca-add-tools'"), 'the add form is a disclosure when accounts already exist')
88
+ // One card component owns both, so the user never picks a method up front.
89
+ const tools = source.slice(source.indexOf('function AccountTools('))
90
+ const body = tools.slice(0, tools.indexOf('\n /**', 10))
91
+ assert.ok(body.includes("postRoute('/accounts/add'"), 'the pair form')
92
+ assert.ok(body.includes("postRoute('/accounts/import'"), 'the bulk form, same component')
93
+ })
94
+
95
+ check('models render as cards on bg-layer-2, not nowrap table columns', () => {
96
+ has('padding:10px 12px;background:var(--dsw-alias-bg-layer-2', 'model row surface')
97
+ assert.ok(source.includes('.dca-model-off{background:'), 'disabled models keep readable text rather than fading the whole row')
98
+ assert.ok(!source.includes('.dca-model-off{opacity:'), 'the whole model row is not dimmed')
99
+ has('.dca-model-meta{', 'facts collapse onto one meta line')
100
+ assert.ok(!source.includes('dca-table'), 'the six-column table is gone')
101
+ })
102
+
103
+ check('hints and row metadata use the reference type scale', () => {
104
+ has('color:var(--dsw-alias-label-tertiary,#999);font-size:12px;line-height:18px', 'hint line')
105
+ has('font-size:11px;line-height:16px', 'row metadata line')
106
+ })
107
+
108
+ check('the switch writes the preference; the button fires a one-off run', () => {
109
+ // Two callers now, and the distinction is the whole point: a SWITCH expresses
110
+ // a standing preference, a BUTTON performs an action once. Swapping them would
111
+ // make the button opt someone into daily automation, or make the switch claim
112
+ // on every toggle.
113
+ const calls = [...source.matchAll(/postRoute\('\/checkin\/auto', \{([^}]*)\}\)/g)]
114
+ assert.equal(calls.length, 2, 'two callers of the check-in route')
115
+ const prefs = calls.filter((c) => c[1].includes('enabled'))
116
+ const oneOff = calls.filter((c) => c[1].includes('now'))
117
+ assert.equal(prefs.length, 1, 'exactly one writes the preference')
118
+ assert.equal(oneOff.length, 1, 'exactly one fires a one-off sweep')
119
+ assert.ok(!prefs[0][1].includes('now'), 'the switch never fires a sweep')
120
+ assert.ok(!oneOff[0][1].includes('enabled'), 'the button never flips the preference')
121
+ })
122
+
123
+ check('every class the markup uses has a rule in the stylesheet', () => {
124
+ // THE BUG THIS CATCHES: after a component rebuild the markup kept its class
125
+ // names while the rules for them were gone. `node --check` passes, the client
126
+ // loads, and the page renders unstyled — three separate audits missed it
127
+ // because they asked whether a class was *named*, never whether it was
128
+ // *styled*.
129
+ const css = source.slice(source.indexOf('const CSS = `'), source.indexOf('`\n\n /**'))
130
+ const used = new Set()
131
+ for (const m of source.matchAll(/className: '([^']+)'/g)) {
132
+ for (const cls of m[1].split(/\s+/)) if (cls) used.add(cls)
133
+ }
134
+ const defined = new Set([...css.matchAll(/\.(dca-[a-z0-9-]+)/g)].map((m) => m[1]))
135
+ const unstyled = [...used].filter((cls) => cls.startsWith('dca-') && !defined.has(cls))
136
+ assert.deepEqual(unstyled, [], `classes used but never styled: ${unstyled.join(', ')}`)
137
+ })
138
+
139
+ check('the account row is two lines: identity, then a probe line', () => {
140
+ has('.dca-pool-account-row{', 'identity line')
141
+ has('.dca-pool-probe{', 'probe line')
142
+ has('justify-self:end;text-align:right;font-variant-numeric:tabular-nums', 'credits hug the right')
143
+ })
144
+
145
+ check('switches are the platform checkbox, not a painted toggle', () => {
146
+ has('.dca-switchrow input[type="checkbox"]', 'a real checkbox input')
147
+ has('accent-color:var(--dsw-alias-brand-primary,#5686fe)', 'sized and drawn by the engine')
148
+ })
149
+
150
+ check('model rows indent their second line to the name', () => {
151
+ has('padding-inline-start:22px', '22px = the checkbox box plus its gap')
152
+ })
153
+
154
+ check('import opens the system picker, and export downloads a file', () => {
155
+ // The reference opens the OS picker straight from the button: a ceremony
156
+ // dialog in front of a dialog the OS is about to show is one click of
157
+ // nothing. Export writes a file rather than a clipboard string, because a
158
+ // button labelled 导出 that leaves nothing on disk is a lie.
159
+ assert.ok(source.includes("fileInput.current?.click()"), 'the import button opens the picker')
160
+ assert.ok(source.includes('type: \'file\''), 'a real file input exists')
161
+ assert.ok(source.includes('anchor.download = name'), 'export triggers a download')
162
+ assert.ok(source.includes('URL.createObjectURL'), 'export builds a Blob URL')
163
+ })
164
+
165
+ check('the import preview shows what will be written before writing it', () => {
166
+ assert.ok(source.includes("postRoute('/accounts/preview'"), 'a preview route is called')
167
+ assert.ok(source.includes('pool.previewTotal'), 'the confirmation states the count')
168
+ })
169
+
170
+ check('the settings nav glyph is registered under the section\'s own id', () => {
171
+ // The shell addresses the glyph by id: an id that does not equal the
172
+ // settings.section id never renders, and nothing reports it. Both come from
173
+ // one inject callback so the pairing cannot drift.
174
+ assert.ok(source.includes("'settings.section.icon'"), 'the icon seat is used')
175
+ assert.ok(
176
+ source.includes("name: 'settings.section.icon', id: 'dsh-connect-codearts'"),
177
+ 'the glyph id must equal the section id',
178
+ )
179
+ assert.ok(source.includes('NAV_ICON'), 'the glyph has artwork')
180
+ assert.ok(source.includes("data:image/png;base64,"), 'embedded as a data URL, not fetched at paint time')
181
+ assert.ok(
182
+ source.includes('settings nav icon failed to register (page unaffected)'),
183
+ 'a host without the icon seat must still get the page',
184
+ )
185
+ })
186
+
187
+ check('the pool and check-in switches are iOS-style, not bare checkboxes', () => {
188
+ // 38x22 track with a 16px knob that slides 16px; the input stays present but
189
+ // invisible so the role, keyboard handling and checked state survive.
190
+ has('.dca-sw{position:relative;display:inline-block;width:38px;height:22px', 'track box')
191
+ has('.dca-sw input{position:absolute;opacity:0', 'the real input is kept, not removed')
192
+ has('width:16px;height:16px;border-radius:50%', 'knob')
193
+ has('transform:translateX(16px)', 'knob slides when checked')
194
+ has('input:checked + .dca-sw-track{background:var(--dsw-alias-brand-primary', 'checked track uses the accent')
195
+ })
196
+
197
+ check('the account pool has no on/off switch: the selected account just serves', () => {
198
+ // The switch was removed on request. Which account serves is not a preference
199
+ // to toggle — the selected account serves every request and a failure is
200
+ // reported as it is, so there is nothing to turn on or off.
201
+ const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
202
+ assert.ok(!source.includes("postRoute('/pool'"), 'no pool route is called from the card')
203
+ assert.ok(!source.includes('pool.enableHint'), 'its hint is gone too')
204
+ assert.ok(!host.includes("route('/pool'"), 'the host no longer serves that route')
205
+ assert.ok(!host.includes('nextAccountClient'), 'failover wiring is gone with it')
206
+ // The daily check-in switch is a different decision and stays.
207
+ assert.ok(source.includes("postRoute('/checkin/auto'"), 'the check-in switch remains')
208
+ })
209
+
210
+ check('the provider is declared, so Settings → Models renders a card for it', () => {
211
+ // THE BUG THIS CATCHES: `registerAdapter` alone makes the route routable and
212
+ // feeds the model picker, but Settings → Models builds its rows from the
213
+ // configurable-provider DIRECTORY. With only an adapter the plugin is
214
+ // half-installed: models selectable, no card in the page where a user manages
215
+ // providers. The two symptoms look unrelated and have one cause.
216
+ const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
217
+ assert.ok(host.includes('registerConfigurableProviders'), 'the directory entry is declared')
218
+ assert.ok(host.includes('registerModelDiscovery'), 'discovery is offered to that page')
219
+ assert.ok(
220
+ host.includes('registerAdapter'),
221
+ 'the adapter is registered too — all three, or the plugin is half-installed',
222
+ )
223
+ })
224
+
225
+ check('a model row carries its own selection and capability switches', () => {
226
+ // The row is where a user decides what this provider may send, so the controls
227
+ // live on the row: selection checkbox, image, and "can disable thinking".
228
+ assert.ok(source.includes('dca-model-check'), 'per-row selection checkbox')
229
+ assert.ok(source.includes("setOverride(model.id, { images:"), 'per-row image switch')
230
+ assert.ok(source.includes("setOverride(model.id, { allowOff:"), 'per-row thinking switch')
231
+ assert.ok(source.includes('dca-model-off'), 'an unticked model recedes but stays visible')
232
+ })
233
+
234
+ check('an unticked model leaves the picker, a reset restores everything', () => {
235
+ // `null` is "offer everything" and is NOT the same as an empty array, which
236
+ // would empty the picker with no way back.
237
+ const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
238
+ assert.ok(host.includes("route('/models/select'"), 'a save route exists')
239
+ assert.ok(host.includes('enabledIds === null'), 'null is distinguished from an empty list')
240
+ assert.ok(host.includes("emit('llm/models-updated'"), 'the picker is told to reload, without a restart')
241
+ })
242
+
243
+ check('edits are a draft until saved, with a visible dirty marker', () => {
244
+ assert.ok(source.includes('models.dirty'), 'unsaved edits are marked')
245
+ assert.ok(source.includes('models.discard'), 'they can be discarded')
246
+ assert.ok(source.includes("postRoute('/models/select'"), 'saving writes them')
247
+ })
248
+
249
+ check('an account can be renamed from its row', () => {
250
+ // Without a name, several accounts are indistinguishable: the row shows a
251
+ // masked AK, which tells a user nothing about which account is which.
252
+ assert.ok(source.includes('dca-rename-btn'), 'the name is an inline editor trigger')
253
+ assert.ok(source.includes("postRoute('/accounts/rename'"), 'it saves through the route')
254
+ assert.ok(source.includes('renameable === false'), 'a derived label starts the editor EMPTY, not prefilled')
255
+ assert.ok(source.includes("event.key === 'Escape'"), 'Escape cancels — an accidental click must not save')
256
+ assert.ok(source.includes("event.key === 'Enter'"), 'Enter commits')
257
+ })
258
+
259
+ check('save and discard live in a persistent action bar', () => {
260
+ // A bar that appears only once something is dirty moves under the pointer at
261
+ // the exact moment the user is looking for it. The reference keeps it present
262
+ // and disables it, which is also what the shared `.dca-btn` disabled style is
263
+ // for.
264
+ assert.ok(source.includes('dca-model-actions'), 'the bar exists')
265
+ assert.ok(source.includes('dca-model-actions-buttons'), 'buttons sit together at the end')
266
+ assert.ok(source.includes('disabled: !dirty || busy !== null'), 'disabled when there is nothing to save')
267
+ assert.ok(source.includes('position:sticky;bottom:0;z-index:3'), 'the save bar remains at the viewport edge')
268
+ assert.ok(source.includes('dca-save-status'), 'the persistent bar explains saved and unsaved state')
269
+ })
270
+
271
+ check('the composer panel lists every account, not just the serving one', () => {
272
+ // The reference's panel is a table of the whole pool: "which account" and "how
273
+ // many credits" are the same fact about the same thing, so splitting them made
274
+ // the panel read as two unrelated blocks.
275
+ assert.ok(source.includes('dca-pop-table'), 'a real table, so balances align in one column')
276
+ assert.ok(source.includes('dca-pop-num'), 'the figure column is right-aligned and tabular')
277
+ assert.ok(source.includes('dca-pop-dot'), 'each row carries a state dot')
278
+ assert.ok(source.includes('dca-pop-mark-reason'), 'a reason sits UNDER the name, not beside it')
279
+ assert.ok(source.includes("postRoute('/accounts/activate'"), 'a row switches the pool on click')
280
+ assert.ok(source.includes("getRoute('/accounts')"), 'the panel reads the pool, not just /account')
281
+ })
282
+
283
+ check('the panel header carries refresh and settings, in that order', () => {
284
+ // Refresh acts on the table right below it (local, repeatable); settings leaves
285
+ // the panel. A navigating control goes LAST so a press meant for "bring this up
286
+ // to date" cannot land on "leave".
287
+ const head = source.slice(source.indexOf("className: 'dca-pop-head'"))
288
+ const refreshAt = head.indexOf('dca-pop-refresh')
289
+ const settingsAt = head.indexOf('dca-pop-settings')
290
+ assert.ok(refreshAt > 0, 'refresh is in the header')
291
+ assert.ok(settingsAt > refreshAt, 'settings comes after refresh')
292
+ assert.ok(source.includes('dca-pop-refresh-icon-spin'), 'refresh spins while it runs')
293
+ assert.ok(source.includes('dca-pop-soon'), 'a lapsing balance warns on its own line')
294
+ })
295
+
296
+ check('reasoning levels are shown in the reader\'s language, not their ids', () => {
297
+ // The model page printed `model.defaultStrength` raw, so the same level read
298
+ // `high` there and 高 in the picker. One fact must read the same everywhere.
299
+ assert.ok(source.includes('EFFORT_LABELS'), 'a label table exists')
300
+ assert.ok(source.includes('function effortLabel('), 'and a resolver reads it')
301
+ assert.ok(source.includes('isChinese() ? pair[0] : pair[1]'), 'it follows the document language')
302
+ assert.ok(!source.includes('${t(\'models.effort\')} ${model.defaultStrength'), 'the raw id is not printed')
303
+ for (const zh of ['关闭', '低', '中', '高', '最高']) {
304
+ assert.ok(source.includes(`'${zh}'`), `${zh} must be in the label table`)
305
+ }
306
+ })
307
+
308
+ check('the add-account fields are one row, named by their placeholders', () => {
309
+ // Form labels remain visible after input. The drawer is compact when closed,
310
+ // while helper text is revealed only when a user asks for it.
311
+ assert.ok(source.includes("className: 'dca-fields'"), 'the fields share a row')
312
+ assert.ok(source.includes("className: 'dca-form-field'"), 'visible labels remain after typing')
313
+ assert.ok(source.includes("placeholder: t('account.placeholderAk')"), 'the AK field has a useful hint')
314
+ assert.ok(source.includes("htmlFor: 'dca-ak2'"), 'the visible label remains after typing')
315
+ assert.ok(source.includes("type: showSecret ? 'text' : 'password'"), 'the secret can be revealed on demand')
316
+ assert.ok(source.includes("placeholder: t('account.placeholderSk')"), 'so does the SK field')
317
+ })
318
+
319
+ check('the panel has one refresh, in its header, and no instruction label', () => {
320
+ // The bottom refresh duplicated the header one; two controls for one action
321
+ // invite the question of whether they differ. The old label —
322
+ // 「点击查看码道账号与积分」 — was an instruction printed INSIDE the thing it
323
+ // told you to click, which reads as a leftover from the trigger.
324
+ assert.ok(!source.includes("className: 'dca-pop-foot'"), 'no bottom action row')
325
+ assert.ok(!source.includes('点击查看码道账号与积分'), 'the click instruction is gone')
326
+ assert.ok(source.includes("'chip.panelTitle': ['码道账号与积分'"), 'the panel names itself instead')
327
+ assert.ok(source.includes("className: 'dca-pop-refresh'"), 'the header refresh remains')
328
+ // Exactly one refresh control INSIDE THE PANEL. The model page has its own,
329
+ // which is a different surface with its own refresh route.
330
+ const panel = source.slice(source.indexOf('function ComposerChip('))
331
+ const inPanel = [...panel.matchAll(/onClick: refresh/g)].length
332
+ assert.equal(inPanel, 1, `expected one refresh control in the panel, found ${inPanel}`)
333
+ })
334
+
335
+ check('an account row lights up on hover, and the serving row does not', () => {
336
+ // Hover belongs to the SWITCH, not the row: the credits cell is not clickable,
337
+ // so lighting it up would promise an action it cannot perform.
338
+ assert.ok(source.includes('.dca-pop-switch:hover:not(:disabled){background'), 'the row body fills on hover')
339
+ assert.ok(source.includes('.dca-pop-switch:focus-visible'), 'keyboard gets the same affordance')
340
+ assert.ok(source.includes('.dca-pop-switch:active:not(:disabled)'), 'and a pressed state')
341
+ assert.ok(!source.includes('.dca-pop-table tbody tr:hover'), 'the row itself never lights up')
342
+ // The serving row's switch is disabled, so it must not offer a click target.
343
+ assert.ok(source.includes('.dca-pop-row-current .dca-pop-name{font-weight:600}'), 'the serving row reads as current')
344
+ assert.ok(source.includes("className: account.active ? 'dca-pop-row-current'"), 'and is marked')
345
+ })
346
+
347
+ check('the settings button opens this plugin\'s own settings section', () => {
348
+ // Two routes, best first, exactly as the reference does it.
349
+ //
350
+ // Route 1 reads the shell's STORE SEAT — verified against the shipped client:
351
+ // ui-settings-general registers `{ name: 'sidebar.settings', store: shellStore }`
352
+ // whose actions are { open, close, select, openSection }. NOT `settings.section`
353
+ // (that slot lists the pages and carries no store), and NOT
354
+ // `pluginNavigation.openBundle` (that lands on the bundle's PAGE, not the section).
355
+ assert.ok(source.includes("SETTINGS_SLOT = 'sidebar.settings'"), 'reads the real seat slot')
356
+ assert.ok(!source.includes("entries('settings.section')"), 'not the pages slot — it has no store')
357
+ assert.ok(source.includes('actions?.openSection'), 'calls openSection on the shell instance')
358
+ assert.ok(source.includes('openSection(sectionId)'), 'opens the section named by its id')
359
+ assert.ok(
360
+ source.includes("openThroughStoreSeat(softGet, 'dsh-connect-codearts')"),
361
+ 'and that id is this plugin\'s own section',
362
+ )
363
+ // The shell pins create() to its one live instance; a bare handle would move a
364
+ // dialog nobody renders. The comment says so, and the code uses create().
365
+ assert.ok(source.includes('seat.create()'), 'goes through the pinned instance')
366
+ // 'shell' + `open` is the older-shell path: the dialog opens without
367
+ // preselection, and route 2 clicks the row.
368
+ assert.ok(source.includes("return 'shell'"), 'reports the partially-opened shell')
369
+ assert.ok(source.includes('actions?.open'), 'falls back to plain open on an older store')
370
+ // Route 2: drive the chrome, guarded so an already-open panel is not toggled shut.
371
+ assert.ok(source.includes('data-shortcut-modal="settings"'), 'the shell\'s own panel attribute')
372
+ assert.ok(source.includes('aria-haspopup="dialog"'), 'the sidebar trigger selector')
373
+ assert.ok(source.includes('=== null) {'), 'only clicks the trigger when the panel is absent')
374
+ assert.ok(!source.includes('navigation.openBundle('), 'the bundle-page route is gone')
375
+ })
376
+
377
+ check('the settings jump is a standing function, not a conditional prop', () => {
378
+ // A click that does nothing beats a button that is sometimes absent: the shell
379
+ // may still be applying when this module runs, so the button must exist always.
380
+ const chip = source.slice(source.indexOf('function ComposerChip('))
381
+ assert.ok(chip.includes('const openSettings = () => {'), 'declared unconditionally')
382
+ assert.ok(!chip.includes('openSettings\n ? h('), 'no render branch on its presence')
383
+ })
384
+
385
+ check('the default thinking level is chosen, not captioned', () => {
386
+ // A caption told the user what upstream decided. A reasoning model's default
387
+ // is a decision the user makes per model, and the picker cannot express a
388
+ // per-model default on its own.
389
+ assert.ok(source.includes("className: 'dca-effort-select'"), 'a select, not a label')
390
+ assert.ok(source.includes("setOverride(model.id, { defaultStrength:"), 'it writes the override')
391
+ assert.ok(source.includes('dca-effort'), 'and carries the inline effort styling')
392
+ })
393
+
394
+ check('an override the model cannot honour is ignored, not sent upstream', () => {
395
+ // A stale preference, or one hand-edited in preferences.json, must not become
396
+ // a request the gateway rejects.
397
+ const catalog = readFileSync(new URL('../src/catalog.js', import.meta.url), 'utf8')
398
+ assert.ok(catalog.includes("(model.strengths ?? []).includes(override.defaultStrength)"), 'the level is validated')
399
+ assert.ok(catalog.includes(': model.defaultStrength'), 'and falls back to upstream')
400
+ })
401
+
402
+ check('the model page reports the EFFECTIVE default, not upstream\'s', () => {
403
+ // Showing one value while the adapter sends another is the "shows A, bills B"
404
+ // trap this plugin keeps guarding against.
405
+ const host = readFileSync(new URL('../src/index.js', import.meta.url), 'utf8')
406
+ assert.ok(host.includes('deps.catalog.effective(model)'), 'the row is the effective model')
407
+ })
408
+
409
+ check('the model catalog has search, active filter, and useful sorting', () => {
410
+ assert.ok(source.includes("type: 'search', className: 'dca-input dca-search'"), 'searches name and id')
411
+ assert.ok(source.includes("'aria-pressed': filter === value"), 'filter state is accessible')
412
+ assert.ok(source.includes("['ratio', 'models.sortRatio']"), 'can compare models by multiplier')
413
+ assert.ok(source.includes('visibleModels.map'), 'only filtered models render')
414
+ })
415
+
416
+ check('diagnostics lead with health and offer redacted copy', () => {
417
+ assert.ok(source.includes('dca-diagnostic-summary'), 'health summary is above machine details')
418
+ assert.ok(source.includes('navigator.clipboard.writeText(reportText)'), 'one action copies the redacted report')
419
+ assert.ok(source.includes("h('details', { className: 'dca-card dca-details' }"), 'technical internals are collapsed')
420
+ })
421
+
422
+ check('settings tab panels stay mounted and have matching controls', () => {
423
+ assert.ok(source.includes('hidden: tab !== id'), 'switching tabs keeps component state')
424
+ assert.ok(source.includes("'aria-controls': `${panelId}-panel-${id}`"), 'each tab points to its own panel')
425
+ assert.ok(source.includes('tabButtons.current[next]?.focus()'), 'keyboard navigation moves focus as well as selection')
426
+ })
427
+
428
+ check('settings routes populate independently and can be retried', () => {
429
+ assert.ok(source.includes('getRoute(path, { signal: controller.signal })'), 'the four reads are cancellable')
430
+ assert.ok(source.includes('if (controller.signal.aborted) return false'), 'a superseded response cannot replace fresh data')
431
+ assert.ok(source.includes('setData((current) => ({ ...current, [path]: value }))'), 'fast status does not wait for account probes')
432
+ assert.ok(source.includes('onSaved: loadModels'), 'model saves reload only the model catalog')
433
+ assert.ok(source.includes("t('common.retry')"), 'a failed read can be retried in place')
434
+ })
435
+
436
+ console.log(results.join('\n'))
437
+ if (process.exitCode) console.log('\nvisual: some checks failed')
438
+ else console.log('\nvisual: all checks passed')