dsh-mcviseron-plugin 0.0.0-stage → 0.6.2
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/CHANGELOG.md +222 -0
- package/CONTRIBUTING.md +60 -0
- package/LICENSE +202 -0
- package/README.en.md +146 -0
- package/README.md +287 -2
- package/SECURITY.md +38 -0
- package/cordis.patch.yml +12 -0
- package/docs/automation-task.md +63 -0
- package/docs/migration-from-standalone.md +115 -0
- package/docs/release.md +85 -0
- package/lib/appearance.js +320 -0
- package/lib/auto-review-fix.js +453 -0
- package/lib/client.js +1266 -0
- package/lib/index.js +1701 -0
- package/lib/restart.js +226 -0
- package/lib/task-guard.js +736 -0
- package/package.json +148 -4
- package/scripts/repair-profile.mjs +77 -0
- package/src/api.ts +5 -0
- package/src/appearance/index.ts +103 -0
- package/src/auto-review-fix/index.ts +45 -0
- package/src/client/AppearanceScheduleRow.tsx +112 -0
- package/src/client/ConfigForm.tsx +284 -0
- package/src/client/FallbackRestartRow.tsx +23 -0
- package/src/client/RestartCard.tsx +108 -0
- package/src/client/SettingsSection.tsx +110 -0
- package/src/client/bridge.ts +131 -0
- package/src/client/driver.ts +166 -0
- package/src/client/index.ts +114 -0
- package/src/client/locales.ts +193 -0
- package/src/client/primitives.d.ts +15 -0
- package/src/client/section-presence.ts +33 -0
- package/src/client/styles.ts +154 -0
- package/src/components/auto-review-fix/index.ts +421 -0
- package/src/components/auto-review-fix/translate.ts +235 -0
- package/src/components/task-guard/index.ts +1077 -0
- package/src/index.ts +71 -0
- package/src/loopback.ts +48 -0
- package/src/namespace.ts +7 -0
- package/src/restart/index.ts +268 -0
- package/src/routes.ts +228 -0
- package/src/schedule.ts +125 -0
- package/src/task-guard/index.ts +52 -0
- package/src/volatile.ts +32 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { DEFAULT_SCHEDULE_CONFIG, normalizeScheduleConfig, periodAt, type Period, type ScheduleConfig } from '../schedule.ts'
|
|
2
|
+
import { readScheduleConfig, writeScheduleConfig } from './bridge.ts'
|
|
3
|
+
|
|
4
|
+
/** The live theme service as this plugin consumes it (structural, version-proof). */
|
|
5
|
+
export interface ThemeFace {
|
|
6
|
+
setTheme: (id: string) => void
|
|
7
|
+
getTheme?: () => { preference?: string }
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Where the durable config currently stands. */
|
|
11
|
+
export type BridgeState = 'loading' | 'ready' | 'unavailable'
|
|
12
|
+
|
|
13
|
+
/** Last write outcome, for the row's inline status. */
|
|
14
|
+
export type WriteState = 'idle' | 'saving' | 'saved' | 'failed'
|
|
15
|
+
|
|
16
|
+
/** Immutable snapshot the settings row renders. */
|
|
17
|
+
export interface DriverState {
|
|
18
|
+
config: ScheduleConfig
|
|
19
|
+
bridge: BridgeState
|
|
20
|
+
write: WriteState
|
|
21
|
+
/** Period the driver last applied, or undefined when nothing was applied. */
|
|
22
|
+
applied: Period | undefined
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** How often the driver re-reads the wall clock (and retries a failed bridge). */
|
|
26
|
+
const TICK_MS = 20_000
|
|
27
|
+
/** How long an unavailable bridge waits before the next automatic retry. */
|
|
28
|
+
const RETRY_MS = 60_000
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Owns the "switch theme when the wall clock crosses a boundary" loop.
|
|
32
|
+
*
|
|
33
|
+
* It deliberately does not fight manual theme changes: the theme is applied
|
|
34
|
+
* when the computed period differs from the last applied one (first tick after
|
|
35
|
+
* load, enabling the schedule, editing the window, and every boundary). A user
|
|
36
|
+
* who picks another palette in the meantime keeps it until the next boundary.
|
|
37
|
+
*/
|
|
38
|
+
export class ScheduleDriver {
|
|
39
|
+
private state: DriverState = {
|
|
40
|
+
config: { ...DEFAULT_SCHEDULE_CONFIG },
|
|
41
|
+
bridge: 'loading',
|
|
42
|
+
write: 'idle',
|
|
43
|
+
applied: undefined,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private readonly listeners = new Set<() => void>()
|
|
47
|
+
private timer: ReturnType<typeof setInterval> | undefined
|
|
48
|
+
private started = false
|
|
49
|
+
private lastRefresh = 0
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @param themeOf - resolves the theme service lazily, so the row still works
|
|
53
|
+
* while the theme plugin is absent or reloading.
|
|
54
|
+
* @param now - clock seam for tests and for hosts with a fake clock.
|
|
55
|
+
*/
|
|
56
|
+
constructor(
|
|
57
|
+
private readonly themeOf: () => ThemeFace | undefined,
|
|
58
|
+
private readonly now: () => Date = () => new Date(),
|
|
59
|
+
) {}
|
|
60
|
+
|
|
61
|
+
/** Stable snapshot reader for `useSyncExternalStore`. */
|
|
62
|
+
getState = (): DriverState => this.state
|
|
63
|
+
|
|
64
|
+
/** Subscribe to state changes; returns the unsubscriber. */
|
|
65
|
+
subscribe = (listener: () => void): (() => void) => {
|
|
66
|
+
this.listeners.add(listener)
|
|
67
|
+
return () => {
|
|
68
|
+
this.listeners.delete(listener)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Start the loop. Idempotent; the returned function stops it.
|
|
74
|
+
* @returns cleanup for `ctx.effect`.
|
|
75
|
+
*/
|
|
76
|
+
start(): () => void {
|
|
77
|
+
if (this.started) return () => {}
|
|
78
|
+
this.started = true
|
|
79
|
+
void this.refresh()
|
|
80
|
+
this.timer = setInterval(() => {
|
|
81
|
+
this.tick()
|
|
82
|
+
}, TICK_MS)
|
|
83
|
+
|
|
84
|
+
const onWake = (): void => {
|
|
85
|
+
this.tick()
|
|
86
|
+
}
|
|
87
|
+
const doc = typeof document === 'undefined' ? undefined : document
|
|
88
|
+
doc?.addEventListener('visibilitychange', onWake)
|
|
89
|
+
if (typeof window !== 'undefined') window.addEventListener('focus', onWake)
|
|
90
|
+
|
|
91
|
+
return () => {
|
|
92
|
+
this.started = false
|
|
93
|
+
if (this.timer !== undefined) clearInterval(this.timer)
|
|
94
|
+
this.timer = undefined
|
|
95
|
+
doc?.removeEventListener('visibilitychange', onWake)
|
|
96
|
+
if (typeof window !== 'undefined') window.removeEventListener('focus', onWake)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Load the durable config (initial load, row mount, and retry after a
|
|
102
|
+
* failed bridge). A missing namespace keeps the defaults.
|
|
103
|
+
*/
|
|
104
|
+
async refresh(): Promise<void> {
|
|
105
|
+
this.lastRefresh = Date.now()
|
|
106
|
+
const config = await readScheduleConfig()
|
|
107
|
+
if (config === undefined) {
|
|
108
|
+
if (this.state.bridge !== 'unavailable') this.setState({ bridge: 'unavailable' })
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
this.setState({ config, bridge: 'ready', write: this.state.write === 'failed' ? 'idle' : this.state.write })
|
|
112
|
+
this.apply()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Persist a patch through the Host bridge and apply it right away. A refused
|
|
117
|
+
* write reverts to the previously persisted config and reports `failed`.
|
|
118
|
+
* @param patch - the fields the user changed.
|
|
119
|
+
*/
|
|
120
|
+
async update(patch: Partial<ScheduleConfig>): Promise<void> {
|
|
121
|
+
const next = normalizeScheduleConfig({ ...this.state.config, ...patch })
|
|
122
|
+
if (next.enabled === this.state.config.enabled
|
|
123
|
+
&& next.lightStart === this.state.config.lightStart
|
|
124
|
+
&& next.lightEnd === this.state.config.lightEnd) return
|
|
125
|
+
this.setState({ write: 'saving' })
|
|
126
|
+
const saved = await writeScheduleConfig(next)
|
|
127
|
+
if (saved === undefined) {
|
|
128
|
+
this.setState({ write: 'failed' })
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
this.setState({ config: saved, bridge: 'ready', write: 'saved', applied: undefined })
|
|
132
|
+
this.apply()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Re-read the clock, retry a dead bridge, and apply a changed period. */
|
|
136
|
+
tick(): void {
|
|
137
|
+
if (this.state.bridge === 'unavailable' && Date.now() - this.lastRefresh > RETRY_MS) {
|
|
138
|
+
void this.refresh()
|
|
139
|
+
return
|
|
140
|
+
}
|
|
141
|
+
this.apply()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private apply(): void {
|
|
145
|
+
if (!this.state.config.enabled) {
|
|
146
|
+
if (this.state.applied !== undefined) this.setState({ applied: undefined })
|
|
147
|
+
return
|
|
148
|
+
}
|
|
149
|
+
const period = periodAt(this.now(), this.state.config)
|
|
150
|
+
if (this.state.applied === period) return
|
|
151
|
+
const theme = this.themeOf()
|
|
152
|
+
if (theme === undefined) return
|
|
153
|
+
try {
|
|
154
|
+
theme.setTheme(period)
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error('[dsh-mcviseron-plugin] failed to apply the scheduled theme:', error)
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
this.setState({ applied: period })
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private setState(patch: Partial<DriverState>): void {
|
|
163
|
+
this.state = { ...this.state, ...patch }
|
|
164
|
+
for (const listener of this.listeners) listener()
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
2
|
+
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
3
|
+
import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
|
|
4
|
+
import type {} from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
5
|
+
import type {} from '@deepseek-ai/dsh-client-ui-slots'
|
|
6
|
+
import { AppearanceScheduleRow } from './AppearanceScheduleRow.tsx'
|
|
7
|
+
import { FallbackRestartRow } from './FallbackRestartRow.tsx'
|
|
8
|
+
import { SettingsSection } from './SettingsSection.tsx'
|
|
9
|
+
import { ScheduleDriver, type ThemeFace } from './driver.ts'
|
|
10
|
+
import { en, zh, type McviseronKey } from './locales.ts'
|
|
11
|
+
import { sectionPresence } from './section-presence.ts'
|
|
12
|
+
|
|
13
|
+
const NS = 'mcviseron'
|
|
14
|
+
|
|
15
|
+
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
16
|
+
interface LocaleNamespaceMap {
|
|
17
|
+
mcviseron: McviseronKey
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const inject = ['slots', 'locale']
|
|
22
|
+
|
|
23
|
+
interface SlotFace {
|
|
24
|
+
inject: (name: string, callback: () => () => void) => void
|
|
25
|
+
register: (options: Record<string, unknown>, component: unknown) => () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register a list-slot entry without letting a rejected slot (a profile whose
|
|
30
|
+
* settings shell does not declare it) fail the whole client plugin and dispose
|
|
31
|
+
* the other registrations.
|
|
32
|
+
*/
|
|
33
|
+
function registerSafely(
|
|
34
|
+
ctx: ClientContext,
|
|
35
|
+
name: string,
|
|
36
|
+
options: Record<string, unknown>,
|
|
37
|
+
component: unknown,
|
|
38
|
+
onRegistered?: () => void,
|
|
39
|
+
onFailed?: (error: unknown) => void,
|
|
40
|
+
): void {
|
|
41
|
+
const slots = ctx.slots as unknown as SlotFace
|
|
42
|
+
try {
|
|
43
|
+
slots.inject(name, () => {
|
|
44
|
+
try {
|
|
45
|
+
const dispose = slots.register({ name, ...options }, component)
|
|
46
|
+
onRegistered?.()
|
|
47
|
+
return dispose
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error('[mcviseron] cannot register ' + name, error)
|
|
50
|
+
onFailed?.(error)
|
|
51
|
+
return () => {}
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('[mcviseron] cannot inject ' + name, error)
|
|
56
|
+
onFailed?.(error)
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Browser half of the master plugin: registers the locale dictionaries, the
|
|
62
|
+
* Appearance row, the MCviseron settings section, and the General restart
|
|
63
|
+
* fallback used when the settings shell does not declare `settings.section`.
|
|
64
|
+
*
|
|
65
|
+
* `theme` is resolved lazily instead of being declared in `inject`, because the
|
|
66
|
+
* row (and its persisted settings) must remain usable even when the theme
|
|
67
|
+
* plugin is absent or reloading; the driver simply retries on its next tick.
|
|
68
|
+
* @param ctx - client cordis context.
|
|
69
|
+
*/
|
|
70
|
+
export function apply(ctx: ClientContext): void {
|
|
71
|
+
try {
|
|
72
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'mcviseron: dictionaries')
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('[mcviseron] cannot register dictionaries', error)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const themeOf = (): ThemeFace | undefined => {
|
|
78
|
+
try {
|
|
79
|
+
const get = (ctx as unknown as { get?: (name: string) => unknown }).get
|
|
80
|
+
return (typeof get === 'function' ? get.call(ctx, 'theme') : undefined) as ThemeFace | undefined
|
|
81
|
+
} catch {
|
|
82
|
+
return undefined
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const driver = new ScheduleDriver(themeOf)
|
|
87
|
+
try {
|
|
88
|
+
ctx.effect(() => driver.start(), 'mcviseron: appearance schedule driver')
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('[mcviseron] cannot start the appearance driver', error)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// The theme registers Appearance at order 10 and Font settings at 11; 10.5
|
|
94
|
+
// keeps the schedule row directly under Appearance instead of below Font.
|
|
95
|
+
registerSafely(ctx, 'settings.general.item', {
|
|
96
|
+
id: 'mcviseron-appearance-schedule',
|
|
97
|
+
order: 10.5,
|
|
98
|
+
locale: NS,
|
|
99
|
+
inject: () => ({ driver }),
|
|
100
|
+
}, AppearanceScheduleRow)
|
|
101
|
+
|
|
102
|
+
registerSafely(ctx, 'settings.general.item', {
|
|
103
|
+
id: 'mcviseron-restart-fallback',
|
|
104
|
+
order: 13,
|
|
105
|
+
locale: NS,
|
|
106
|
+
}, FallbackRestartRow)
|
|
107
|
+
|
|
108
|
+
registerSafely(ctx, 'settings.section', {
|
|
109
|
+
id: 'mcviseron',
|
|
110
|
+
order: 115,
|
|
111
|
+
label: 'MCviseron',
|
|
112
|
+
locale: NS,
|
|
113
|
+
}, SettingsSection, () => { sectionPresence.markLive() }, (error) => { sectionPresence.markFailed(error) })
|
|
114
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export const zh = {
|
|
2
|
+
'row.title': '按时间自动切换深浅色',
|
|
3
|
+
'row.description': '按本机时间在浅色与深色之间自动切换:早间时段用浅色,其余时间用深色',
|
|
4
|
+
'row.enable': '开启按时间自动切换深浅色',
|
|
5
|
+
'row.disable': '关闭按时间自动切换深浅色',
|
|
6
|
+
'row.lightStart': '早间开始',
|
|
7
|
+
'row.lightEnd': '早间结束',
|
|
8
|
+
'row.dash': '至',
|
|
9
|
+
'row.next': '下次切换',
|
|
10
|
+
'row.timeHint': '使用本机时间,自动适配时区与夏令时',
|
|
11
|
+
'status.light': '当前为早间(浅色)',
|
|
12
|
+
'status.dark': '当前为晚间(深色)',
|
|
13
|
+
'status.off': '已关闭,配色跟随外观设置中的选择',
|
|
14
|
+
'status.unavailable': '无法读取插件设置:请确认 profile 中的插件条目 id 为 mcviseron',
|
|
15
|
+
'status.saving': '保存中…',
|
|
16
|
+
'status.saved': '已保存',
|
|
17
|
+
'status.failed': '保存失败,请重试',
|
|
18
|
+
'restart.title': '重启 DeepSeek Harness',
|
|
19
|
+
'restart.description': '关闭并重新启动桌面应用;正在运行的任务会被中断',
|
|
20
|
+
'restart.button': '重启',
|
|
21
|
+
'restart.checking': '正在检查桌面环境…',
|
|
22
|
+
'restart.ready': '仅重启应用,不会修改插件或配置',
|
|
23
|
+
'restart.restarting': '正在重启…窗口会短暂关闭',
|
|
24
|
+
'restart.failed': '重启失败,请重试',
|
|
25
|
+
'restart.confirm': '确定要重启 DeepSeek Harness 吗?正在运行的任务会被中断。',
|
|
26
|
+
'page.title': 'MCviseron 插件',
|
|
27
|
+
'page.description': '总插件的组件设置。外观设置仍在「通用 → 外观」中。',
|
|
28
|
+
'page.tab.restart': '重启',
|
|
29
|
+
'page.tab.components': '组件',
|
|
30
|
+
'page.restart.title': '重启 DeepSeek Harness',
|
|
31
|
+
'page.restart.description': '关闭并重新启动桌面应用;正在运行的任务会被中断',
|
|
32
|
+
'page.restart.ready': '可用',
|
|
33
|
+
'page.restart.unavailable': '当前环境不支持重启(仅 Windows 桌面版可用)',
|
|
34
|
+
'page.restart.routeMissing': '重启接口未加载:请确认 mcviseron-restart 条目已启用',
|
|
35
|
+
'page.restart.appPath': '应用路径',
|
|
36
|
+
'page.restart.button': '重启',
|
|
37
|
+
'page.restart.restarting': '正在重启…窗口会短暂关闭',
|
|
38
|
+
'page.restart.failed': '重启失败,请重试',
|
|
39
|
+
'page.restart.confirm': '确定要重启 DeepSeek Harness 吗?正在运行的任务会被中断。',
|
|
40
|
+
'page.components.title': '组件',
|
|
41
|
+
'page.components.appearance': '外观 · 按时间切换',
|
|
42
|
+
'page.components.appearanceHint': '设置位于「通用 → 外观」',
|
|
43
|
+
'page.components.autoReviewFix': 'Auto review 修复',
|
|
44
|
+
'page.components.autoReviewFixHint': '本页「Auto review 修复」子页',
|
|
45
|
+
'page.components.taskGuard': 'Todo 计划守卫',
|
|
46
|
+
'page.components.taskGuardHint': '本页「Todo 守卫」子页',
|
|
47
|
+
'page.components.restart': '重启 DeepSeek Harness',
|
|
48
|
+
'page.components.restartHint': '本页「重启」子页',
|
|
49
|
+
'page.components.note': '组件配置写入 master 条目(mcviseron)的 Config;若组件仍使用旧值,重启 DSH 后生效。',
|
|
50
|
+
'page.fallback.note': '设置分区未加载,重启入口暂时回退到通用设置。',
|
|
51
|
+
'page.tab.autoReview': 'Auto review 修复',
|
|
52
|
+
'page.tab.taskGuard': 'Todo 守卫',
|
|
53
|
+
'page.autoReview.title': 'Auto review 修复',
|
|
54
|
+
'page.autoReview.description': '退出保护与审批理由中文翻译;翻译同时写入审批事件,邮箱提醒也能收到。',
|
|
55
|
+
'page.taskGuard.title': 'Todo 计划守卫',
|
|
56
|
+
'page.taskGuard.description': '多阶段任务忘记更新 todo 时发出建议性 notice。',
|
|
57
|
+
'form.loading': '读取中…',
|
|
58
|
+
'form.saving': '保存中…',
|
|
59
|
+
'form.saved': '已保存',
|
|
60
|
+
'form.failed': '保存失败',
|
|
61
|
+
'form.unavailable': '无法读取插件设置:请确认 profile 中的插件条目 id 为 mcviseron',
|
|
62
|
+
'form.autoSave': '修改后自动保存',
|
|
63
|
+
'form.autoReview.translate': '翻译审批理由',
|
|
64
|
+
'form.autoReview.translateHint': '英文审查理由会附上中文翻译,并写入审批事件;转手动后被拒时,自动审查理由会作为 notice 交回 AI',
|
|
65
|
+
'form.autoReview.keepPreset': '退出时保持权限预设',
|
|
66
|
+
'form.autoReview.keepPresetHint': '关闭 DSH 时不再把 Auto 会话改成完全访问',
|
|
67
|
+
'form.autoReview.timeout': '翻译超时(毫秒)',
|
|
68
|
+
'form.autoReview.maxChars': '最大翻译字符数',
|
|
69
|
+
'form.autoReview.provider': '翻译 Provider',
|
|
70
|
+
'form.autoReview.model': '翻译 Model',
|
|
71
|
+
'form.autoReview.routeHint': '留空则跟随当前会话的模型路由',
|
|
72
|
+
'form.taskGuard.enabled': '启用 Todo 计划守卫',
|
|
73
|
+
'form.taskGuard.enabledHint': '多阶段任务忘记更新 todo 时发出建议性 notice',
|
|
74
|
+
'form.taskGuard.locale': '模型可见文本语言',
|
|
75
|
+
'form.taskGuard.localeZh': '中文',
|
|
76
|
+
'form.taskGuard.localeEn': 'English',
|
|
77
|
+
'form.taskGuard.stale': '停滞阈值(工具调用次数)',
|
|
78
|
+
'form.taskGuard.repeat': '重复提醒间隔(工具调用次数)',
|
|
79
|
+
'form.taskGuard.block': '硬拦截阈值',
|
|
80
|
+
'form.taskGuard.blockHint': '0 = 不硬拦截',
|
|
81
|
+
'form.taskGuard.rejectMissingActive': '拒绝缺少 in_progress 的写入',
|
|
82
|
+
'form.taskGuard.sourceKind': 'notice source kind',
|
|
83
|
+
'form.taskGuard.sourceAuto': 'auto(按会话格式)',
|
|
84
|
+
'form.taskGuard.sourceV3': 'v3',
|
|
85
|
+
'form.taskGuard.sourceV4': 'v4',
|
|
86
|
+
'form.taskGuard.maxListItems': 'notice 最多列出任务数',
|
|
87
|
+
'form.taskGuard.detectStepIntent': '识别步骤意图',
|
|
88
|
+
'form.taskGuard.detectStepIntentHint': '识别「Now I will …」等步骤意图,以及「All nets routed」「DRC passes」「原理图完成」等阶段完成语句;命中时提供可直接发送的 todo_write',
|
|
89
|
+
'form.taskGuard.translateTodo': '中文展示 todo 标题',
|
|
90
|
+
'form.taskGuard.translateTodoHint': '只影响 notice 展示,不改写模型写入的 todo',
|
|
91
|
+
'form.taskGuard.todoTimeout': 'todo 翻译超时(毫秒)',
|
|
92
|
+
'form.taskGuard.include': '只统计这些工具',
|
|
93
|
+
'form.taskGuard.exclude': '不统计这些工具',
|
|
94
|
+
'form.taskGuard.listHint': '逗号分隔,支持 *;留空表示全部',
|
|
95
|
+
} as const
|
|
96
|
+
|
|
97
|
+
export const en = {
|
|
98
|
+
'row.title': 'Switch light/dark by time',
|
|
99
|
+
'row.description': 'Follow the local wall clock: light during the morning window, dark for the rest of the day',
|
|
100
|
+
'row.enable': 'Enable the light/dark schedule',
|
|
101
|
+
'row.disable': 'Disable the light/dark schedule',
|
|
102
|
+
'row.lightStart': 'Light starts',
|
|
103
|
+
'row.lightEnd': 'Light ends',
|
|
104
|
+
'row.dash': 'to',
|
|
105
|
+
'row.next': 'Next switch',
|
|
106
|
+
'row.timeHint': 'Uses the local wall clock; time zones and daylight saving are handled automatically',
|
|
107
|
+
'status.light': 'Morning window (light)',
|
|
108
|
+
'status.dark': 'Evening window (dark)',
|
|
109
|
+
'status.off': 'Off — the palette follows the Appearance choice',
|
|
110
|
+
'status.unavailable': 'Cannot read the plugin settings: check that the profile entry id is mcviseron',
|
|
111
|
+
'status.saving': 'Saving…',
|
|
112
|
+
'status.saved': 'Saved',
|
|
113
|
+
'status.failed': 'Save failed — try again',
|
|
114
|
+
'restart.title': 'Restart DeepSeek Harness',
|
|
115
|
+
'restart.description': 'Closes and relaunches the desktop application; running tasks are interrupted',
|
|
116
|
+
'restart.button': 'Restart',
|
|
117
|
+
'restart.checking': 'Checking the desktop environment…',
|
|
118
|
+
'restart.ready': 'Only the app restarts; plugins and settings are untouched',
|
|
119
|
+
'restart.restarting': 'Restarting… the window will close briefly',
|
|
120
|
+
'restart.failed': 'Restart failed — try again',
|
|
121
|
+
'restart.confirm': 'Restart DeepSeek Harness now? Running tasks will be interrupted.',
|
|
122
|
+
'page.title': 'MCviseron plugin',
|
|
123
|
+
'page.description': 'Settings for the master plugin components. Appearance still lives under General → Appearance.',
|
|
124
|
+
'page.tab.restart': 'Restart',
|
|
125
|
+
'page.tab.components': 'Components',
|
|
126
|
+
'page.restart.title': 'Restart DeepSeek Harness',
|
|
127
|
+
'page.restart.description': 'Closes and relaunches the desktop application; running tasks are interrupted',
|
|
128
|
+
'page.restart.ready': 'Available',
|
|
129
|
+
'page.restart.unavailable': 'Restarting is available only in the Windows desktop app',
|
|
130
|
+
'page.restart.routeMissing': 'The restart route is not loaded: check that the mcviseron-restart entry is enabled',
|
|
131
|
+
'page.restart.appPath': 'App path',
|
|
132
|
+
'page.restart.button': 'Restart',
|
|
133
|
+
'page.restart.restarting': 'Restarting… the window will close briefly',
|
|
134
|
+
'page.restart.failed': 'Restart failed — try again',
|
|
135
|
+
'page.restart.confirm': 'Restart DeepSeek Harness now? Running tasks will be interrupted.',
|
|
136
|
+
'page.components.title': 'Components',
|
|
137
|
+
'page.components.appearance': 'Appearance · light/dark by time',
|
|
138
|
+
'page.components.appearanceHint': 'Configured under General → Appearance',
|
|
139
|
+
'page.components.autoReviewFix': 'Auto-review fix',
|
|
140
|
+
'page.components.autoReviewFixHint': 'The Auto-review fix tab on this page',
|
|
141
|
+
'page.components.taskGuard': 'Todo plan guard',
|
|
142
|
+
'page.components.taskGuardHint': 'The Todo guard tab on this page',
|
|
143
|
+
'page.components.restart': 'Restart DeepSeek Harness',
|
|
144
|
+
'page.components.restartHint': 'The Restart tab on this page',
|
|
145
|
+
'page.components.note': 'Component settings are written to the mcviseron entry config; restart DSH if a component still uses the old value.',
|
|
146
|
+
'page.fallback.note': 'The settings section is unavailable, so the restart entry falls back to General.',
|
|
147
|
+
'page.tab.autoReview': 'Auto-review fix',
|
|
148
|
+
'page.tab.taskGuard': 'Todo guard',
|
|
149
|
+
'page.autoReview.title': 'Auto-review fix',
|
|
150
|
+
'page.autoReview.description': 'Shutdown guard and Chinese approval-reason translation; the translation is also written into the approval event so email reminders receive it.',
|
|
151
|
+
'page.taskGuard.title': 'Todo plan guard',
|
|
152
|
+
'page.taskGuard.description': 'Advisory notices when multi-stage work stops updating its todo plan.',
|
|
153
|
+
'form.loading': 'Loading…',
|
|
154
|
+
'form.saving': 'Saving…',
|
|
155
|
+
'form.saved': 'Saved',
|
|
156
|
+
'form.failed': 'Save failed',
|
|
157
|
+
'form.unavailable': 'Cannot read the plugin settings: check that the profile entry id is mcviseron',
|
|
158
|
+
'form.autoSave': 'Changes save automatically',
|
|
159
|
+
'form.autoReview.translate': 'Translate the approval reason',
|
|
160
|
+
'form.autoReview.translateHint': 'Appends a Chinese translation to the reviewer note and writes it into the approval event; a manual rejection returns the auto-review reason to the AI',
|
|
161
|
+
'form.autoReview.keepPreset': 'Keep the permission preset on shutdown',
|
|
162
|
+
'form.autoReview.keepPresetHint': 'Stops DSH from rewriting Auto sessions to Full access while exiting',
|
|
163
|
+
'form.autoReview.timeout': 'Translation timeout (ms)',
|
|
164
|
+
'form.autoReview.maxChars': 'Maximum translation characters',
|
|
165
|
+
'form.autoReview.provider': 'Translation provider',
|
|
166
|
+
'form.autoReview.model': 'Translation model',
|
|
167
|
+
'form.autoReview.routeHint': 'Empty follows the current session route',
|
|
168
|
+
'form.taskGuard.enabled': 'Enable the Todo plan guard',
|
|
169
|
+
'form.taskGuard.enabledHint': 'Advisory notices when multi-stage work stops updating its todo plan',
|
|
170
|
+
'form.taskGuard.locale': 'Model-visible language',
|
|
171
|
+
'form.taskGuard.localeZh': '中文',
|
|
172
|
+
'form.taskGuard.localeEn': 'English',
|
|
173
|
+
'form.taskGuard.stale': 'Stale threshold (tool calls)',
|
|
174
|
+
'form.taskGuard.repeat': 'Repeat interval (tool calls)',
|
|
175
|
+
'form.taskGuard.block': 'Hard-stop threshold',
|
|
176
|
+
'form.taskGuard.blockHint': '0 = never hard-stop',
|
|
177
|
+
'form.taskGuard.rejectMissingActive': 'Reject writes without an in_progress task',
|
|
178
|
+
'form.taskGuard.sourceKind': 'Notice source kind',
|
|
179
|
+
'form.taskGuard.sourceAuto': 'auto (follow the session format)',
|
|
180
|
+
'form.taskGuard.sourceV3': 'v3',
|
|
181
|
+
'form.taskGuard.sourceV4': 'v4',
|
|
182
|
+
'form.taskGuard.maxListItems': 'Maximum tasks listed in a notice',
|
|
183
|
+
'form.taskGuard.detectStepIntent': 'Detect step intent',
|
|
184
|
+
'form.taskGuard.detectStepIntentHint': 'Recognizes step intent (“Now I will …”) and completion statements (“All nets routed”, “DRC passes”); the notice carries a ready todo_write',
|
|
185
|
+
'form.taskGuard.translateTodo': 'Show todo titles in Chinese',
|
|
186
|
+
'form.taskGuard.translateTodoHint': 'Display-only; stored todos are never rewritten',
|
|
187
|
+
'form.taskGuard.todoTimeout': 'Todo translation timeout (ms)',
|
|
188
|
+
'form.taskGuard.include': 'Count only these tools',
|
|
189
|
+
'form.taskGuard.exclude': 'Exclude these tools',
|
|
190
|
+
'form.taskGuard.listHint': 'Comma-separated, * supported; empty means all',
|
|
191
|
+
} satisfies Record<keyof typeof zh, string>
|
|
192
|
+
|
|
193
|
+
export type McviseronKey = keyof typeof zh
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module '@deepseek-ai/dsh-client-ui-primitives' {
|
|
2
|
+
import type { ReactElement } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface SwitchProps {
|
|
5
|
+
checked: boolean
|
|
6
|
+
onChange: (checked: boolean) => void
|
|
7
|
+
label?: string
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
title?: string
|
|
10
|
+
className?: string
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** The official settings switch supplied by the DSH client shell. */
|
|
14
|
+
export function Switch(props: SwitchProps): ReactElement | null
|
|
15
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
let live = false
|
|
2
|
+
let failure = ''
|
|
3
|
+
const listeners = new Set<() => void>()
|
|
4
|
+
|
|
5
|
+
function emit(): void {
|
|
6
|
+
for (const listener of [...listeners]) listener()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Tracks whether the MCviseron settings section registered successfully. The
|
|
11
|
+
* General fallback row is hidden while the section is live, so a profile whose
|
|
12
|
+
* settings shell does not declare `settings.section` still gets a restart entry.
|
|
13
|
+
*/
|
|
14
|
+
export const sectionPresence = {
|
|
15
|
+
isLive: (): boolean => live,
|
|
16
|
+
failure: (): string => failure,
|
|
17
|
+
subscribe: (listener: () => void): (() => void) => {
|
|
18
|
+
listeners.add(listener)
|
|
19
|
+
return () => {
|
|
20
|
+
listeners.delete(listener)
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
markLive: (): void => {
|
|
24
|
+
live = true
|
|
25
|
+
failure = ''
|
|
26
|
+
emit()
|
|
27
|
+
},
|
|
28
|
+
markFailed: (error: unknown): void => {
|
|
29
|
+
live = false
|
|
30
|
+
failure = error instanceof Error ? error.message : String(error)
|
|
31
|
+
emit()
|
|
32
|
+
},
|
|
33
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react'
|
|
2
|
+
|
|
3
|
+
const labelPrimary = 'var(--dsw-alias-label-primary, #1f2329)'
|
|
4
|
+
const labelSecondary = 'var(--dsw-alias-label-secondary, #5c6570)'
|
|
5
|
+
const labelTertiary = 'var(--dsw-alias-label-tertiary, #8a919b)'
|
|
6
|
+
const borderL2 = 'var(--dsw-alias-border-l2, rgba(0, 0, 0, 0.08))'
|
|
7
|
+
const fieldFill = 'var(--dsw-alias-bg-layer-1, rgba(0, 0, 0, 0.03))'
|
|
8
|
+
const accent = 'var(--dsw-alias-state-business-primary, #4176e6)'
|
|
9
|
+
|
|
10
|
+
export const pageStyles: Record<string, CSSProperties> = {
|
|
11
|
+
page: { display: 'flex', flexDirection: 'column', gap: 16, padding: '4px 0' },
|
|
12
|
+
heading: { margin: 0, fontSize: 18, lineHeight: '26px', color: labelPrimary },
|
|
13
|
+
lede: { margin: 0, fontSize: 13, lineHeight: '20px', color: labelSecondary },
|
|
14
|
+
tabs: { display: 'flex', gap: 4, borderBottom: '1px solid ' + borderL2 },
|
|
15
|
+
tab: {
|
|
16
|
+
padding: '8px 12px',
|
|
17
|
+
border: 'none',
|
|
18
|
+
background: 'transparent',
|
|
19
|
+
color: labelSecondary,
|
|
20
|
+
fontSize: 13,
|
|
21
|
+
fontFamily: 'inherit',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
},
|
|
24
|
+
tabActive: { boxShadow: 'inset 0 -2px 0 ' + accent, color: labelPrimary },
|
|
25
|
+
card: {
|
|
26
|
+
display: 'flex',
|
|
27
|
+
flexDirection: 'column',
|
|
28
|
+
gap: 8,
|
|
29
|
+
padding: '14px 16px',
|
|
30
|
+
border: '1px solid ' + borderL2,
|
|
31
|
+
borderRadius: 10,
|
|
32
|
+
},
|
|
33
|
+
cardTitle: { fontSize: 14, lineHeight: '20px', color: labelPrimary },
|
|
34
|
+
cardBody: { fontSize: 12, lineHeight: '18px', color: labelSecondary },
|
|
35
|
+
cardStatus: { fontSize: 12, lineHeight: '18px', color: labelTertiary },
|
|
36
|
+
cardActions: { display: 'flex', justifyContent: 'flex-end', gap: 8 },
|
|
37
|
+
componentRow: {
|
|
38
|
+
display: 'flex',
|
|
39
|
+
justifyContent: 'space-between',
|
|
40
|
+
alignItems: 'baseline',
|
|
41
|
+
gap: 16,
|
|
42
|
+
padding: '8px 0',
|
|
43
|
+
borderBottom: '1px solid ' + borderL2,
|
|
44
|
+
},
|
|
45
|
+
componentName: { fontSize: 13, lineHeight: '20px', color: labelPrimary },
|
|
46
|
+
componentHint: { fontSize: 12, lineHeight: '18px', color: labelTertiary, textAlign: 'right' },
|
|
47
|
+
form: { display: 'flex', flexDirection: 'column', gap: 10 },
|
|
48
|
+
formRow: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
gap: 4,
|
|
52
|
+
padding: '8px 0',
|
|
53
|
+
borderBottom: '1px solid ' + borderL2,
|
|
54
|
+
},
|
|
55
|
+
formLabel: { fontSize: 13, lineHeight: '18px', color: labelPrimary },
|
|
56
|
+
formHint: { fontSize: 11, lineHeight: '16px', color: labelTertiary },
|
|
57
|
+
formControl: {
|
|
58
|
+
width: '100%',
|
|
59
|
+
maxWidth: 420,
|
|
60
|
+
padding: '4px 8px',
|
|
61
|
+
border: '1px solid ' + borderL2,
|
|
62
|
+
borderRadius: 6,
|
|
63
|
+
background: fieldFill,
|
|
64
|
+
color: labelPrimary,
|
|
65
|
+
fontSize: 12,
|
|
66
|
+
fontFamily: 'inherit',
|
|
67
|
+
},
|
|
68
|
+
formStatus: { fontSize: 11, lineHeight: '16px', color: labelTertiary },
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const buttonShape: CSSProperties = {
|
|
72
|
+
padding: '4px 14px',
|
|
73
|
+
border: '1px solid ' + borderL2,
|
|
74
|
+
borderRadius: 6,
|
|
75
|
+
background: fieldFill,
|
|
76
|
+
color: labelPrimary,
|
|
77
|
+
fontSize: 12,
|
|
78
|
+
fontFamily: 'inherit',
|
|
79
|
+
cursor: 'pointer',
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Inline styles rather than a CSS bundle: the row is a single settings control,
|
|
84
|
+
* and reading the live `--dsw-alias-*` variables keeps it in step with the
|
|
85
|
+
* active palette (including third-party themes) without shipping a stylesheet.
|
|
86
|
+
*/
|
|
87
|
+
export const styles = {
|
|
88
|
+
row: {
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'flex-start',
|
|
91
|
+
justifyContent: 'space-between',
|
|
92
|
+
gap: 16,
|
|
93
|
+
padding: '10px 0',
|
|
94
|
+
flexWrap: 'wrap',
|
|
95
|
+
} satisfies CSSProperties,
|
|
96
|
+
text: {
|
|
97
|
+
display: 'flex',
|
|
98
|
+
flexDirection: 'column',
|
|
99
|
+
gap: 4,
|
|
100
|
+
minWidth: 0,
|
|
101
|
+
} satisfies CSSProperties,
|
|
102
|
+
title: {
|
|
103
|
+
fontSize: 14,
|
|
104
|
+
lineHeight: '20px',
|
|
105
|
+
color: labelPrimary,
|
|
106
|
+
} satisfies CSSProperties,
|
|
107
|
+
description: {
|
|
108
|
+
fontSize: 12,
|
|
109
|
+
lineHeight: '18px',
|
|
110
|
+
color: labelSecondary,
|
|
111
|
+
} satisfies CSSProperties,
|
|
112
|
+
status: {
|
|
113
|
+
fontSize: 12,
|
|
114
|
+
lineHeight: '18px',
|
|
115
|
+
color: labelTertiary,
|
|
116
|
+
} satisfies CSSProperties,
|
|
117
|
+
controls: {
|
|
118
|
+
display: 'flex',
|
|
119
|
+
alignItems: 'center',
|
|
120
|
+
gap: 12,
|
|
121
|
+
flex: '0 0 auto',
|
|
122
|
+
} satisfies CSSProperties,
|
|
123
|
+
times: {
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
gap: 6,
|
|
127
|
+
} satisfies CSSProperties,
|
|
128
|
+
field: {
|
|
129
|
+
display: 'flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
gap: 4,
|
|
132
|
+
} satisfies CSSProperties,
|
|
133
|
+
fieldLabel: {
|
|
134
|
+
fontSize: 12,
|
|
135
|
+
lineHeight: '18px',
|
|
136
|
+
color: labelSecondary,
|
|
137
|
+
} satisfies CSSProperties,
|
|
138
|
+
input: {
|
|
139
|
+
width: 84,
|
|
140
|
+
padding: '2px 6px',
|
|
141
|
+
border: '1px solid ' + borderL2,
|
|
142
|
+
borderRadius: 6,
|
|
143
|
+
background: fieldFill,
|
|
144
|
+
color: labelPrimary,
|
|
145
|
+
fontSize: 12,
|
|
146
|
+
fontFamily: 'inherit',
|
|
147
|
+
} satisfies CSSProperties,
|
|
148
|
+
dash: {
|
|
149
|
+
fontSize: 12,
|
|
150
|
+
color: labelTertiary,
|
|
151
|
+
} satisfies CSSProperties,
|
|
152
|
+
button: buttonShape,
|
|
153
|
+
buttonDisabled: { ...buttonShape, opacity: 0.6, cursor: 'default' } satisfies CSSProperties,
|
|
154
|
+
} as const
|