dsh-codearts-dock 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DISCLAIMER.md +2 -2
- package/README.md +14 -17
- package/SECURITY.md +2 -4
- package/client.js +422 -450
- package/docs/DETAIL.md +4 -5
- package/docs/DETAIL.zh.md +4 -5
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
- package/src/adapter.js +0 -27
- package/src/checkin.js +5 -5
- package/src/features.js +4 -4
- package/src/health.js +0 -3
- package/src/index.js +22 -101
- package/src/preferences.js +9 -12
- package/test/accounts.test.mjs +22 -0
- package/test/features.test.mjs +59 -76
- package/test/registration.test.mjs +3 -1
- package/test/ui.test.mjs +425 -63
- package/test/visual.test.mjs +16 -34
- package/src/usage.js +0 -55
package/test/visual.test.mjs
CHANGED
|
@@ -47,7 +47,7 @@ check('inputs are monospace 12/20 on bg-l1', () => {
|
|
|
47
47
|
|
|
48
48
|
check('cards sit on bg-layer-3 with a border-l2 frame at radius 12', () => {
|
|
49
49
|
has('border-radius:12px;background:var(--dsw-alias-bg-layer-3', 'card surface')
|
|
50
|
-
|
|
50
|
+
assert.ok(!source.includes('.dca-card:hover'), 'passive cards do not imply a click action')
|
|
51
51
|
})
|
|
52
52
|
|
|
53
53
|
check('the section switcher is a sticky underlined tab strip, not cards', () => {
|
|
@@ -67,12 +67,8 @@ check('the account pool is a grid table with an uppercase header row', () => {
|
|
|
67
67
|
has('padding:10px 14px', 'row rhythm')
|
|
68
68
|
})
|
|
69
69
|
|
|
70
|
-
check('one bulk claim button
|
|
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.
|
|
70
|
+
check('one bulk claim button serves the account pool', () => {
|
|
74
71
|
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
72
|
assert.ok(
|
|
77
73
|
!source.includes('dca-pool-col-checkin'),
|
|
78
74
|
'never a per-row claim control',
|
|
@@ -105,19 +101,10 @@ check('hints and row metadata use the reference type scale', () => {
|
|
|
105
101
|
has('font-size:11px;line-height:16px', 'row metadata line')
|
|
106
102
|
})
|
|
107
103
|
|
|
108
|
-
check('
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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')
|
|
104
|
+
check('check-in is a manual action with no automatic switch or route', () => {
|
|
105
|
+
assert.ok(source.includes("postRoute('/checkin/claim-all', {})"), 'manual claim uses a dedicated route')
|
|
106
|
+
assert.ok(!source.includes('/checkin/auto'), 'the automatic route is gone')
|
|
107
|
+
assert.ok(!source.includes('pool.autoTitle'), 'the automatic switch is gone')
|
|
121
108
|
})
|
|
122
109
|
|
|
123
110
|
check('every class the markup uses has a rule in the stylesheet', () => {
|
|
@@ -142,8 +129,14 @@ check('the account row is two lines: identity, then a probe line', () => {
|
|
|
142
129
|
has('justify-self:end;text-align:right;font-variant-numeric:tabular-nums', 'credits hug the right')
|
|
143
130
|
})
|
|
144
131
|
|
|
145
|
-
check('
|
|
146
|
-
has('.dca-
|
|
132
|
+
check('narrow settings layouts follow panel width, not viewport width', () => {
|
|
133
|
+
has('.dca-settings{container:dca-settings / inline-size;', 'the settings root defines the query container')
|
|
134
|
+
has('@container dca-settings (max-width:420px)', 'the narrow rules query the panel')
|
|
135
|
+
assert.ok(!/@media\s*\(\s*max-width/.test(source), 'settings must also adapt inside a wide window')
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
check('selection controls retain native checkbox styling', () => {
|
|
139
|
+
has('.dca-model-controls input[type="checkbox"]', 'a real model checkbox input')
|
|
147
140
|
has('accent-color:var(--dsw-alias-brand-primary,#5686fe)', 'sized and drawn by the engine')
|
|
148
141
|
})
|
|
149
142
|
|
|
@@ -184,16 +177,6 @@ check('the settings nav glyph is registered under the section\'s own id', () =>
|
|
|
184
177
|
)
|
|
185
178
|
})
|
|
186
179
|
|
|
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
180
|
check('the account pool has no on/off switch: the selected account just serves', () => {
|
|
198
181
|
// The switch was removed on request. Which account serves is not a preference
|
|
199
182
|
// to toggle — the selected account serves every request and a failure is
|
|
@@ -203,8 +186,7 @@ check('the account pool has no on/off switch: the selected account just serves',
|
|
|
203
186
|
assert.ok(!source.includes('pool.enableHint'), 'its hint is gone too')
|
|
204
187
|
assert.ok(!host.includes("route('/pool'"), 'the host no longer serves that route')
|
|
205
188
|
assert.ok(!host.includes('nextAccountClient'), 'failover wiring is gone with it')
|
|
206
|
-
|
|
207
|
-
assert.ok(source.includes("postRoute('/checkin/auto'"), 'the check-in switch remains')
|
|
189
|
+
assert.ok(source.includes("postRoute('/checkin/claim-all'"), 'manual check-in remains')
|
|
208
190
|
})
|
|
209
191
|
|
|
210
192
|
check('the provider is declared, so Settings → Models renders a card for it', () => {
|
|
@@ -428,7 +410,7 @@ check('settings tab panels stay mounted and have matching controls', () => {
|
|
|
428
410
|
check('settings routes populate independently and can be retried', () => {
|
|
429
411
|
assert.ok(source.includes('getRoute(path, { signal: controller.signal })'), 'the four reads are cancellable')
|
|
430
412
|
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')
|
|
413
|
+
assert.ok(source.includes('setData((current) => ({ ...current, [path]: mergeCredits(path, current[path], value) }))'), 'fast status does not wait for account probes')
|
|
432
414
|
assert.ok(source.includes('onSaved: loadModels'), 'model saves reload only the model catalog')
|
|
433
415
|
assert.ok(source.includes("t('common.retry')"), 'a failed read can be retried in place')
|
|
434
416
|
})
|
package/src/usage.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/** Bounded local request metadata. No prompts, responses, tool arguments, or account identities. */
|
|
2
|
-
import { randomUUID } from 'node:crypto'
|
|
3
|
-
import { readFileSync } from 'node:fs'
|
|
4
|
-
import { mkdir, writeFile, rename } from 'node:fs/promises'
|
|
5
|
-
import { join } from 'node:path'
|
|
6
|
-
import { CONFIG_DIR } from './paths.js'
|
|
7
|
-
export const USAGE_LIMIT = 200
|
|
8
|
-
const finite = (n) => Number.isFinite(n) && n >= 0 ? Math.round(n) : null
|
|
9
|
-
const statuses = ['success', 'error', 'aborted']
|
|
10
|
-
export function sanitizeUsage(row) {
|
|
11
|
-
return {
|
|
12
|
-
id: typeof row.id === 'string' && /^[a-f\d-]{36}$/.test(row.id) ? row.id : randomUUID(),
|
|
13
|
-
at: finite(row.at) ?? Date.now(),
|
|
14
|
-
model: typeof row.model === 'string' ? row.model.slice(0, 200) : 'unknown',
|
|
15
|
-
durationMs: finite(row.durationMs) ?? 0,
|
|
16
|
-
inputTokens: finite(row.inputTokens), outputTokens: finite(row.outputTokens),
|
|
17
|
-
status: statuses.includes(row.status) ? row.status : 'error',
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export function createUsageStore({ directory = CONFIG_DIR, enabled = () => true } = {}) {
|
|
21
|
-
const path = join(directory, 'usage.json')
|
|
22
|
-
let rows
|
|
23
|
-
let epoch = 0
|
|
24
|
-
let pending = Promise.resolve()
|
|
25
|
-
function read() {
|
|
26
|
-
if (!rows) {
|
|
27
|
-
try {
|
|
28
|
-
const raw = JSON.parse(readFileSync(path, 'utf8'))
|
|
29
|
-
rows = Array.isArray(raw) ? raw.filter((row) => row && typeof row === 'object').slice(-USAGE_LIMIT).map(sanitizeUsage) : []
|
|
30
|
-
} catch { rows = [] }
|
|
31
|
-
}
|
|
32
|
-
return rows
|
|
33
|
-
}
|
|
34
|
-
function write() {
|
|
35
|
-
const snapshot = JSON.stringify(read())
|
|
36
|
-
const next = pending.then(async () => {
|
|
37
|
-
await mkdir(directory, { recursive: true })
|
|
38
|
-
const temp = `${path}.${randomUUID()}.tmp`
|
|
39
|
-
await writeFile(temp, `${snapshot}\n`, { mode: 0o600 })
|
|
40
|
-
await rename(temp, path)
|
|
41
|
-
})
|
|
42
|
-
pending = next.catch(() => {})
|
|
43
|
-
return next
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
generation: () => enabled() ? epoch : null,
|
|
47
|
-
list: () => ({ ok: true, enabled: enabled(), limit: USAGE_LIMIT, records: read().slice().reverse() }),
|
|
48
|
-
record: (entry, startedEpoch = epoch) => {
|
|
49
|
-
if (!enabled() || startedEpoch !== epoch) return Promise.resolve()
|
|
50
|
-
rows = [...read(), sanitizeUsage(entry)].slice(-USAGE_LIMIT)
|
|
51
|
-
return write()
|
|
52
|
-
},
|
|
53
|
-
clear: () => { epoch += 1; rows = []; return write() },
|
|
54
|
-
}
|
|
55
|
-
}
|