dsh-strata-sync 0.10.2 → 0.10.3

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/README.md CHANGED
@@ -2,205 +2,122 @@
2
2
 
3
3
  **English** · [简体中文](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/README.zh-CN.md) · [繁體中文](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/README.zh-TW.md)
4
4
 
5
- A plugin that aligns **DeepSeek Harness (DSH)** with the model actually loaded by **Strata Server**, using a native DSH settings UI.
5
+ Connect **DeepSeek Harness (DSH)** to the model loaded in **Strata Server**, with model settings and summary controls in one DSH settings page.
6
6
 
7
- Open **Settings → dsh-strata-sync** to inspect differences, synchronize an existing Strata provider, or enable automatic synchronization when DSH starts.
7
+ The plugin reads Strata's model information, previews the changes, and updates DSH's custom model and context-compaction budgets. It also adds an editable length instruction to supported summary requests, helping the model keep checkpoints concise.
8
8
 
9
- Version 0.10.1 shortens the summary settings explanation. Keep the default prompt template or customize it with the dynamic `{target}` placeholder; DSH's native prompt and output cap remain unchanged.
9
+ ## What you can do
10
10
 
11
- ## What it does
11
+ - **Sync model settings:** context window, response output limit, and confirmed input types and reasoning levels.
12
+ - **Align compaction budgets:** update the matching policies in enabled DSH Agent presets.
13
+ - **Control summary length:** edit the supplemental prompt and adjust three target-length ratios.
14
+ - **Sync on startup:** optionally synchronize once after DSH becomes idle.
15
+ - **Review and recover:** preview differences, back up settings, and view the last synchronization result.
12
16
 
13
- ### Dynamic summary guidance
17
+ Strata Server is read-only to this plugin. Synchronization does not switch or load server models, change server settings, or send test inference requests. Unconfirmed model capabilities keep their existing DSH values.
14
18
 
15
- The compact **Dynamic summary target** card contains the enable switch, context divisor and editable **Supplemental summary prompt**. Expand **Calculation and limits** for the summary-output and source-length divisors, formula and limitations. Guidance is enabled by default; turning it off preserves DSH's native summary and automatic compaction.
19
+ ## Get started
16
20
 
17
- The editor shows the actual template appended to the native prompt. Its default is:
21
+ ### 1. Prepare the connection
18
22
 
19
- ```text
20
- Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
21
- ```
23
+ Load a model in Strata Server. In **DSH → Settings → Models**, configure its OpenAI-compatible provider, API URL and credentials, with an explicit custom model entry.
22
24
 
23
- Keep the literal `{target}` placeholder in your template; each occurrence is replaced with the target calculated for that summary. Templates may contain up to 2,048 characters. Replacement is plain text, not executable code. **Restore default prompt** restores the original English template in the editor; click **Save preferences** to apply edits or the restored default. Changing the interface language does not translate or overwrite the saved template. This edits only the supplement, never DSH's original summary instructions.
25
+ The plugin reuses that connection; you do not need to copy an API key into it.
24
26
 
25
- | Plugin preference | Default | Meaning |
26
- |---|---:|---|
27
- | `summaryGuidance` | `true` | Append guidance to supported summary requests. |
28
- | `summaryContextDivisor` | `16` | Divide the verified context by this value. |
29
- | `summaryOutputDivisor` | `2` | Divide the actual summary output cap by this value. |
30
- | `summarySourceDivisor` | `2` | Divide the estimated source length by this value. |
31
- | `summaryPromptTemplate` | English template above | Supplement appended after substituting `{target}`. |
32
-
33
- All three divisors accept finite numbers of at least 1, including decimals such as 1.5 or 2.5. A larger divisor makes its bound smaller. The final target is the smallest of the three bounds, rounded down; these controls do not change the actual output hard limit.
27
+ ### 2. Install the plugin
34
28
 
35
- For each supported summary:
29
+ In DSH's plugin manager, choose **Add plugin** and enter:
36
30
 
37
31
  ```text
38
- context = min(verified Strata context, existing DSH model context)
39
- target = floor(min(context / summaryContextDivisor,
40
- actual summary maxTokens / summaryOutputDivisor,
41
- selected-content estimated tokens / summarySourceDivisor))
32
+ dsh-strata-sync
42
33
  ```
43
34
 
44
- The source estimate covers the conversation span being replaced, including prior checkpoints in that span, but excludes system prompts and tool schemas. Read-only metadata queries verify the loaded model and context; the current request supplies its actual output cap. With 32K context, a 4,096-token summary cap and enough content, context divisors 32, 16 and 8 produce targets of 1,024, 2,048 and 2,048 tokens. The UI preview is a ceiling, not the actual target of a future request.
45
-
46
- Saving these controls changes only plugin preferences; it does not synchronize model budgets or change Strata Server settings. DSH's native prompt, eight-section format and request options remain intact. The default supplement is one sentence; a custom template is appended as entered. The target is a writing instruction, **not a new hard output limit or a guarantee against truncation**. No retry loop or extra inference request is added.
47
-
48
- Unverified routes/metadata, unknown native prompts, unpriced attachments, invalid templates, cancellation, disabled guidance and targets below 256 tokens leave the native request unchanged. Removing the plugin stops the supplement without rewriting saved conversation history.
49
-
50
- ### Automatic model capabilities (0.4.0)
51
-
52
- The preview includes **Input types**, **Reasoning levels**, and **Reasoning request mapping**, with the same backup, rollback and idle-only safeguards as token budgets.
53
-
54
- - Input types follow the server's explicit `architecture.input_modalities`: text, or text plus image. Unknown or unsupported values preserve the existing field.
55
- - Reasoning requires matching Strata identity, model identity and a reviewed chat-template fingerprint from `/props?model=...`. A model name alone is insufficient.
56
- - Verified Qwen3.8-Flash-Next templates offer **off / low / medium / xhigh**. Verified DeepSeek-V4.1-Flash templates offer **off / low / high / max**, including the inspected Huihui variants. The template, not quantization, determines eligibility.
57
- - Native DSH request mapping sends both thinking enablement and the selected effort. Unknown templates or unavailable props preserve existing reasoning settings and show a warning.
58
- - Provider defaults and current conversation selections are not changed. An incompatible provider default skips reasoning synchronization with a warning. Start a new conversation after syncing.
59
-
60
- See [capability evidence and exact mappings](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md). No additional plugin or Strata server changes are required.
61
-
62
- ### Existing synchronization features
63
-
64
- - Reads `/v1/models` and, when available, `/slots`. Uses the loaded canonical text-model ID and actual engine context; it never guesses context from a model name. Verified aliases refer to the same model; image-generation endpoints are excluded.
65
- - Updates that DSH model's context and output limit, and its native `compaction-basic` policy inside enabled Agent presets. The preview identifies the affected presets.
66
- - Shows server-reported values separately from client-derived budgets.
67
- - Uses **Follow Strata** for output selection by default. **Advanced settings** provides an explicit manual override. Server-reported output defaults, effective output values and their sources are shown separately. Default-model following remains optional.
68
- - When enabled before startup, synchronizes once per DSH host process/profile after tasks become idle. If a task starts during discovery, the pending sync waits and resumes after it finishes. There are no recurring checks after completion; other failures are shown in the UI and require manual retry or the next start. Enabling it during a session takes effect on the next start; use **Back up and sync** for an immediate sync. No generation requests, model loading or server changes.
69
- - Previews differences, rechecks the server and the same configuration revision before applying, rejects stale previews, backs up the profile and rolls back completed edits if a later edit fails. Preferences also use revision checks: untouched forms follow fresh values; locally edited forms report conflicts instead of silently overwriting another window.
70
- - Keeps a read-only last-sync result with model, budgets, output source and backup information. Reports verified and preserved capabilities separately.
71
- - Uses DSH's existing credential service. Keys never appear in the page or diagnostics; redirects are not followed.
72
-
73
- **Start a new conversation after syncing model or budget settings.** Existing conversations keep their selected model route and Agent preset revision. Default-model following and updated preset policies apply to new work; this plugin does not rewrite existing conversations or restart DSH. Dynamic summary guidance operates on supported summary requests while the updated plugin is active and does not require changing those saved settings.
74
-
75
- ## Compatibility
76
-
77
- Developed against **DSH desktop 0.2.1-rc.3** and Strata's OpenAI-compatible model/slot metadata. Requires the standard desktop services `configEditor`, `connection`, `agents`, `credentials`, `llm-pi-ai`, and enabled Agent presets containing `compaction-basic` (or an active legacy global compaction plugin). Only API-key or unauthenticated `openai-completions` providers are supported. Configure the provider in DSH Models first.
78
-
79
- Configure an explicit, nonempty custom `models` list for the Strata provider. Catalog-only routes and nonempty `modelOverrides` routes are rejected during preview, before any backup or write; the plugin does not convert catalog providers or combine incompatible model configuration formats.
80
-
81
- Unknown context, no loaded text model, ambiguous multiple loaded text models, or conflicting slot capacities are refused. Aliases are resolved to their loaded canonical model, and explicit non-text output endpoints are excluded. Invalid alias chains are refused. This version's UI follows one loaded text model; it does not select among multiple simultaneously loaded text models.
82
-
83
- The startup idle-wait scheduler includes a narrow DSH 0.2.1-rc.3 compatibility adapter for HMR's `executing.exit` context, following the host's own watcher pattern. This prevents timers created during a settings reload from retaining the completed HMR transaction. All writes still go through ConfigEditor and its normal transaction queue. Revalidate this adapter after upgrading DSH.
84
-
85
- ## Install
86
-
87
- Package name: `dsh-strata-sync` (formerly `@ethan741205/dsh-strata-sync`). Remove the old scoped plugin before installing this package to avoid loading two copies; retain its settings when migrating.
88
-
89
-
90
- For the existing npm release, finish active tasks and fully quit DSH Desktop, then install with the official DSH CLI:
35
+ Or, after finishing active tasks and fully quitting DSH Desktop, use the official CLI:
91
36
 
92
37
  ```sh
93
38
  dsh plugin --profile desktop add dsh-strata-sync --registry=https://registry.npmjs.org/
94
39
  ```
95
40
 
96
- Reopen DSH after installation. The bundle is automatically selected on its first installation; an already installed but disabled bundle must be enabled in DSH's plugin manager.
41
+ Reopen DSH if needed to load the settings page. If the plugin is disabled, enable it in the plugin manager.
97
42
 
98
- To install **0.10.2 with the editable summary prompt** from source, use Node.js 22 or newer, finish active tasks and fully quit DSH Desktop before the final installation command:
43
+ ### 3. Preview and synchronize
99
44
 
100
- ```sh
101
- git clone https://github.com/ethan741205/dsh-strata-sync.git
102
- cd dsh-strata-sync
103
- npm ci
104
- npm test
105
- npm pack
106
- dsh plugin --profile desktop add ./dsh-strata-sync-0.10.2.tgz
107
- ```
108
-
109
- Use an absolute tarball path if running the last command elsewhere. DSH's plugin installer selects the included bundle; it can require a desktop reload to mount the new browser entry. Finish any active task before restarting DSH.
110
-
111
- Then open **Settings → dsh-strata-sync**:
112
-
113
- 1. Choose the existing Strata provider and save preferences. Keep **Follow Strata** enabled, or open **Advanced settings** for a manual output override.
114
- 2. Click **Check differences** to read the loaded model and preview the proposed settings.
115
- 3. Click **Back up and sync** while DSH is idle.
116
- 4. Optionally enable **Automatically sync when DSH starts** and save. It defaults to off and takes effect on the next start. Existing `autoSync: true` preferences now use startup behavior.
117
- 5. Start a new conversation to use the new Agent preset revision.
118
-
119
- The **Dynamic summary target** card is independent of model synchronization. Leave guidance enabled, keep the default template, and use divisors 16 / 2 / 2 to retain the previous behavior, or change these preferences and save. Turning this switch off does not disable DSH's own compaction.
45
+ Open **Settings → dsh-strata-sync**:
120
46
 
121
- No API key needs to be copied into this plugin. Set up or repair credentials in DSH Models settings.
47
+ 1. Select your Strata provider and click **Save preferences**.
48
+ 2. Click **Check differences** to inspect the loaded model and proposed changes.
49
+ 3. While DSH is idle, click **Back up and sync**.
50
+ 4. **Start a new conversation** to use the updated model and Agent preset settings.
122
51
 
123
- ## Changes in 0.10.1
52
+ Existing conversations keep their selected model route and preset revision. To make future setup automatic, enable **Automatically sync when DSH starts** and save. This option is off by default and takes effect on the next start; it waits for idle and does not poll continuously.
124
53
 
125
- - Shortens the summary UI explanation to the formula and native-summary fallback. Calculation and runtime behavior are unchanged; full details remain in this README.
54
+ ## Model and output settings
126
55
 
127
- ## Changes in 0.10.0
56
+ | Setting | How it is chosen |
57
+ |---|---|
58
+ | Model and context | Strata's loaded text model and verified context capacity. |
59
+ | Response output limit | Manual override, if set; otherwise the verified Strata output default. If unavailable or unlimited, use 30% of context, capped at 16,384 tokens. |
60
+ | Input types | Confirmed server capabilities, such as text or text plus image. |
61
+ | Reasoning levels | Verified model-template support; unknown templates preserve existing settings. |
62
+ | Default model | Follows the loaded Strata model when **Follow the loaded Strata model as the default** is enabled. |
128
63
 
129
- - Makes the actual supplemental prompt editable, with a dynamic `{target}` placeholder and Restore default prompt action.
130
- - Simplifies the summary card and moves detailed formula explanations into expandable help in all three languages. Adds advanced output/source divisors and decimal support for all three divisors.
131
- - Validates and saves prompt edits through existing backup and revision safeguards without changing native instructions or other budgets.
64
+ Keep **Follow Strata output limit** enabled for automatic selection. Turn it off to set a manual override under **Advanced settings**. The preview shows the server default, effective value and source separately.
132
65
 
133
- ## Changes in 0.9.0
66
+ When synchronizing, the plugin sets a 4,096-token summary output cap and 4,096-token compaction headroom. The effective compaction trigger is the smaller of **80% of context** and **context − response output − 4,096**. Recent-content retention is **(context − response output) × 16%**, rounded down. These are client-side budgets calculated by the plugin, not settings supplied by Strata.
134
67
 
135
- - Adds a default-on switch for the supplemental summary guidance and an adjustable context divisor, defaulting to 16.
136
- - Saves both controls through the existing preferences and revision checks, with matching English, Simplified Chinese and Traditional Chinese UI and documentation.
137
- - Keeps native summary instructions, hard output limits, other budgets and server settings unchanged when saving these controls.
68
+ For example, with automatic output calculation, a 32K context uses a 9,830-token response allowance and an 18,842-token compaction trigger. It does **not** necessarily compact at 80%.
138
69
 
139
- ## Changes in 0.5.0
70
+ ## Summary prompt and target length
140
71
 
141
- - Follows DSH’s native locale service; removes the independent language selector and product disclaimer.
142
- - Performs one optional startup sync per host process/profile, waiting for idle. Hot reloads and reopening Settings do not repeat it.
143
- - Preserves the existing opt-in `autoSync` preference; no recurring server polling.
72
+ **Dynamic summary target** is enabled by default. It supplements DSH's native summary instructions; disabling it keeps native summary and compaction behavior.
144
73
 
145
- ## Changes in 0.3.0
74
+ The editable **Supplemental summary prompt** starts with:
146
75
 
147
- - Adds English, Simplified Chinese and Traditional Chinese UI selection with local persistence.
148
- - Includes all three README editions in the package.
149
- - Keeps the synchronization backend and budgets unchanged.
150
-
151
- ## Changes in 0.2.0
152
-
153
- - Moves the dsh-strata-sync interface into DSH's native **Settings** navigation.
154
- - Uses English throughout the interface and repository documentation.
155
- - Preserves the synchronization policy, optional idle polling, backups and existing-conversation behavior described below.
76
+ ```text
77
+ Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
78
+ ```
156
79
 
157
- ## Budget policy
80
+ Keep `{target}` in your text—it is replaced with the calculated token target before each supported summary. The template can contain up to 2,048 characters. Use **Restore default prompt** to reset it, then **Save preferences** to apply your choice.
158
81
 
159
- Strata reports model/context and a shared output default through `/props?model=...` → `default_generation_settings.params.n_predict` (the server's shared `max_tokens`). This default is not a hard model limit: an explicit client request overrides it. Strata does **not** supply DSH's compaction policy. The following are this plugin's client-side choices, designed around DSH 0.2.1-rc.3's native 4,096-token context safety margin:
82
+ Expand **Calculation and limits** for the additional ratios:
160
83
 
161
- ```text
162
- ordinary output = explicit manual override, else verified positive server n_predict
163
- fallback output = min(16384, floor(context × 0.30))
164
- compaction headroom = 4096
165
- summary maxTokens = 4096
166
- thresholdRatio = 0.8
167
- retainRatio = 0.16
168
- effective trigger = floor(min(context × 0.8, context − ordinary output − 4096))
169
- recent retention = floor((context − ordinary output) × 0.16)
170
- ```
84
+ | Divisor | Default | Limits the target to |
85
+ |---|---:|---|
86
+ | Context (N) | 16 | Context ÷ N |
87
+ | Summary output (O) | 2 | Actual summary output cap ÷ O |
88
+ | Source length (S) | 2 | Estimated content being summarized ÷ S |
171
89
 
172
- Output selection: an explicit manual override takes priority; otherwise use a positive integer from matching Strata/model props. Missing/null, `-1` or `0` means no fixed server cap and uses the calculated fallback. Unavailable or unverifiable props also use the fallback and show that the server limit could not be verified. Malformed explicit values are rejected. A positive server cap that leaves too little compaction space is refused, not silently replaced. The source is shown as **Strata Server default**, **Manual override**, or **Automatic calculation**. Summary output remains 4,096; compaction and retention are recalculated from the selected ordinary-output allowance.
90
+ The target is the smallest result, rounded down. All divisors accept decimals of at least 1. Increasing a divisor lowers its bound; another bound may still determine the final target. Context uses the smaller verified server/client window, and the source estimate excludes system prompts and tool definitions.
173
91
 
174
- These table examples use the calculated fallback (no manual or fixed server limit):
92
+ With 32K context, a 4,096-token summary cap and enough source content, the defaults target **2,048 tokens**. This is a writing instruction, **not a hard output limit or a guarantee against truncation**. The UI previews a ceiling; the actual request may have a smaller target.
175
93
 
176
- | Context | Ordinary output | Summary output | Headroom | Compaction trigger | Recent retention |
177
- |---|---:|---:|---:|---:|---:|
178
- | 32,768 | 9,830 | 4,096 | 4,096 | 18,842 (57.50%) | 3,670 |
179
- | 65,536 | 16,384 | 4,096 | 4,096 | 45,056 (68.75%) | 7,864 |
94
+ Saving summary preferences does not change model budgets. Native prompt content is preserved, and no extra inference or retry loop is added. If the request cannot be verified or safely estimated, or the target is below 256 tokens, the original summary request proceeds unchanged.
180
95
 
181
- An explicit output override must leave a valid positive compaction budget and retention smaller than the trigger. Contexts below 8,192 are unsupported. Reasoning choices synchronize only when verified as described above; credentials, other providers and other model policies are preserved. The selected route's retention is normalized to `retainRatio: 0.16` instead of retaining an incompatible absolute override.
96
+ ## Backups and compatibility
182
97
 
183
- This fixes invalid small-window compaction budgets such as the native `headroomTokens: 65536` default on a 32K route. Dynamic summary guidance uses the current summary cap to calculate a shorter writing target; it does not increase or reduce that cap. Neither feature **guarantees that a model finishes every response or summary within its token cap**. Reasoning also consumes output tokens. Strata's `fit_max_tokens` is not read or changed, and server-side `false` does not disable DSH's own output clamp.
98
+ Settings writes create a backup of `cordis.patch.yml` under the profile's `backups/strata-sync/` directory. Synchronization checks for concurrent edits and attempts to roll back completed changes if a later step fails. Backups may contain private configuration; keep them local.
184
99
 
185
- ## Backups and recovery
100
+ Removing the plugin does not undo previously synchronized settings. To restore a backup, fully quit DSH first.
186
101
 
187
- Every applied settings operation saves the current `cordis.patch.yml` beside the profile under `backups/strata-sync/`. Backups can contain private provider configuration; keep them local. The UI reports the backup path after application. DSH's own config editor handles individual atomic writes and hot reload. Multi-entry updates use compensating rollback, not a database transaction; a concurrent external edit can require manual recovery from the recorded backup.
102
+ Tested with **DSH Desktop 0.2.1-rc.3**. Use an API-key or unauthenticated OpenAI-compatible provider with an explicit custom model list and an enabled Agent preset containing `compaction-basic`. Contexts below 8,192 tokens, catalog-only providers, nonempty `modelOverrides`, and ambiguous loaded-model metadata are unsupported.
188
103
 
189
- Disabling auto-sync cancels a pending startup sync and disables it for future starts. Removing the plugin does **not** undo model/budget settings previously applied. Restore the desired backup with DSH stopped if you want to undo them.
104
+ See [verified capabilities and reasoning mappings](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md) and [validation notes](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md) for technical details and test coverage.
190
105
 
191
106
  ## Development
192
107
 
193
- `src/plugin.mjs` is the host plugin, `src/client.js` is the native ModuleLoader/React UI, `src/core.mjs` is metadata discovery and pure budget planning, and `src/summary.mjs` provides the native summary-request middleware. Build copies them into the publishable `dist/` directory; no bundled private app source is included.
108
+ Requires Node.js 22 or newer.
194
109
 
195
110
  ```sh
111
+ git clone https://github.com/ethan741205/dsh-strata-sync.git
112
+ cd dsh-strata-sync
196
113
  npm ci
197
114
  npm test
198
115
  npm run build
199
- npm pack --dry-run
116
+ npm pack
200
117
  ```
201
118
 
202
- Automated tests cover discovery and credentials/redirect safety, budgets, rollback, concurrent edits, startup deferral, aliases and non-text generators, HMR deduplication, preset activation, request mappings and the multilingual settings UI. Dynamic summary tests cover target calculation and the native request integration; UI tests verify the preview ceiling and distinguish it from the actual per-request target. Tests use simulated endpoints and DSH services; they do not generate model responses or establish a real-world truncation rate. See [validation notes](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md) for the verified version and checks.
119
+ To install your build, fully quit DSH and run `dsh plugin --profile desktop add <path-to-generated.tgz>`.
203
120
 
204
- References: [DSH compaction documentation](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/compaction/compaction-basic/README.md), [Strata](https://github.com/Niko1221/Strata).
121
+ Source: `src/plugin.mjs` (host integration), `src/core.mjs` (discovery and budgets), `src/summary.mjs` (summary guidance), and `src/client.js` (settings UI).
205
122
 
206
- MIT licensed.
123
+ [npm](https://www.npmjs.com/package/dsh-strata-sync) · [Report an issue](https://github.com/ethan741205/dsh-strata-sync/issues) · [MIT license](https://github.com/ethan741205/dsh-strata-sync/blob/main/LICENSE)
@@ -2,167 +2,122 @@
2
2
 
3
3
  [English](https://github.com/ethan741205/dsh-strata-sync/blob/main/README.md) · **简体中文** · [繁體中文](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/README.zh-TW.md)
4
4
 
5
- 让 **DeepSeek Harness(DSH)** 对齐 **Strata Server** 实际加载的模型,并在 DSH **设置 → dsh-strata-sync** 中提供操作界面。
5
+ 让 **DeepSeek Harness(DSH)** 连接 **Strata Server** 当前加载的模型,在同一个 DSH 设置页管理模型配置与摘要控制。
6
6
 
7
- 0.10.1 进一步精简摘要设置说明。可保留默认提示词模板,或使用动态 `{target}` 自定义内容;DSH 原生提示词与输出硬上限保持不变。
7
+ 插件读取 Strata 的模型信息,预览差异,再更新 DSH 自定义模型与上下文压缩预算。它还会为支持的摘要请求补充可编辑的长度指令,帮助模型生成精简的摘要。
8
8
 
9
- ## 功能
9
+ ## 可以做什么
10
10
 
11
- ### 动态摘要引导
11
+ - **同步模型设置:**上下文窗口、回复输出上限,以及已确认的输入类型和推理等级。
12
+ - **对齐压缩预算:**更新已启用的 DSH Agent 预设中,对应模型的压缩策略。
13
+ - **控制摘要长度:**编辑补充提示词,调整三项目标长度比例。
14
+ - **启动时同步:**可选择在 DSH 启动并空闲后同步一次。
15
+ - **预览与恢复:**检查差异、备份设置,并查看最近一次同步结果。
12
16
 
13
- 精简的“**动态摘要目标**”区域包含启用开关、上下文除数和可编辑的“**摘要补充提示词**”;展开“**计算方式与限制**”可调整摘要输出与原文长度的除数,并查看公式与限制。功能默认开启,关闭后仍保留 DSH 原生摘要与自动压缩。
17
+ 插件只读访问 Strata Server。同步不会切换或加载服务器模型、修改服务器设置,也不会发送测试推理请求。无法确认的模型能力会保留 DSH 原有值。
14
18
 
15
- 编辑框直接显示实际附加到原生提示词的模板,默认内容如下:
19
+ ## 开始使用
16
20
 
17
- ```text
18
- Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
19
- ```
21
+ ### 1. 准备连接
20
22
 
21
- 模板须保留字面的 `{target}`,每次摘要时会将所有出现位置替换为本次计算的目标。长度最多 2,048 个字符;只做文本替换,不执行代码。“**恢复默认提示词**”会将编辑框恢复为原本的英文模板,修改或恢复后点击“**保存偏好**”才会应用。切换界面语言不会翻译或覆盖已保存的模板。这里只编辑补充内容,不修改 DSH 原生摘要指令。
23
+ 先在 Strata Server 加载模型,再到 **DSH → 设置 → 模型**,配置兼容 OpenAI 的提供方、API 地址与认证,并明确添加自定义模型条目。
22
24
 
23
- | 插件偏好 | 默认值 | 含义 |
24
- |---|---:|---|
25
- | `summaryGuidance` | `true` | 对支持的摘要请求附加补充提示词。 |
26
- | `summaryContextDivisor` | `16` | 以上下文除以此值。 |
27
- | `summaryOutputDivisor` | `2` | 以本次摘要输出硬上限除以此值。 |
28
- | `summarySourceDivisor` | `2` | 以原文估算长度除以此值。 |
29
- | `summaryPromptTemplate` | 上方英文模板 | 替换 `{target}` 后附加的补充内容。 |
25
+ 插件直接复用这个连接,无需另外复制 API key。
30
26
 
31
- 三项除数都接受至少为 1 的有限数值,也支持 1.5、2.5 等小数。除数越大,对应限制越小;最终取三项限制的最小值并向下取整,不会改变实际输出硬上限。
27
+ ### 2. 安装插件
32
28
 
33
- 每次支持的摘要请求都会重新计算:
29
+ 在 DSH 插件管理器选择**添加插件**,输入:
34
30
 
35
31
  ```text
36
- 上下文 = min(已确认的 Strata 上下文, DSH 已有模型上下文)
37
- 目标 = floor(min(上下文 / summaryContextDivisor,
38
- 本次摘要实际 maxTokens / summaryOutputDivisor,
39
- 待替换内容的估算 tokens / summarySourceDivisor))
32
+ dsh-strata-sync
40
33
  ```
41
34
 
42
- 原文估算涵盖这次要替换的对话片段及其中的旧摘要,不含系统提示词和工具定义。只读查询核对加载模型与上下文,实际输出硬上限来自当前请求。32K 上下文、4,096-token 摘要上限且原文足够长时,上下文除数 32、16、8 分别得到 1,024、2,048、2,048 tokens。UI 预览显示目标上限,不是未来请求的实际目标。
43
-
44
- 保存这些控件只修改插件偏好,不会同步模型预算或修改 Strata Server 设置。DSH 原生提示词、八个章节和请求参数保持不变。默认补充内容只有一句,自定义模板则按输入内容附加。目标是写作指令,**不是新的输出硬上限,也不能保证不截断**;不增加重试流程或额外推理请求。
45
-
46
- 无法确认路由或信息、原生提示词格式未知、附件用量无法估算、模板无效、请求取消、功能关闭或目标低于 256 tokens 时,保留原生请求。移除插件会停止附加内容,不改写已保存的对话历史。
47
-
48
- ### 模型能力自动同步(0.4.0)
49
-
50
- 预览新增“输入类型”“推理等级”和“推理请求映射”,与 token 预算共用备份、回滚及空闲时才应用的保护。
51
-
52
- - 输入类型按服务器明确报告的 `architecture.input_modalities` 设置为文本或文本+图片;缺少信息或格式不支持时保留原值。
53
- - 推理等级从 `/props?model=...` 核对 Strata 身份、模型身份及已审查的对话模板指纹,不只凭名称猜测。
54
- - 已验证的 Qwen3.8-Flash-Next:**off/low/medium/xhigh**;DeepSeek-V4.1-Flash:**off/low/high/max**。包含已核对的 Huihui 版本,以模板而非量化名称判定。
55
- - 使用 DSH 原生请求映射,同时设置是否思考及推理等级。模板未知或无法获取 props 时,保留原推理设置并显示原因。
56
- - 不修改提供方默认等级或当前对话选择。提供方默认值与已验证选项冲突时,跳过推理同步并提示。同步后请开启新对话。
57
-
58
- 详见[能力验证与映射表](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md)。不新增其他插件、不修改 Strata 设置。
59
-
60
- ### 已有同步功能
61
-
62
- - 读取 `/v1/models` 和可用的 `/slots`,确认文本模型的正式 ID 和引擎实际上下文,不从模型名称猜测。已确认的别名视为同一模型,图片生成端点不计入文本模型选择。
63
- - 更新选定 DSH 模型的上下文、输出上限,以及已启用 Agent 预设中的原生 `compaction-basic` 策略;预览会列出受影响的预设。
64
- - 默认使用“跟随 Strata”选择输出上限;手动覆盖放在“高级设置”。分别显示服务器原值、实际采用值与来源,也可选择让默认模型跟随服务器。
65
- - 自动同步默认关闭;在启动前启用后,每次 DSH 宿主进程启动、所有任务空闲时同步一次。查询途中开始任务时保留待同步状态,任务完成后补做;成功后不再定期查询。其他错误需手动重试或下次启动再试。运行期间启用会在下次启动生效;立即同步请点击“备份并同步”。
66
- - 应用前重新确认服务器与同一份设置版本、拒绝过期预览、备份设置;后续写入失败时回滚已完成的更改。偏好保存也会核对版本;未编辑的表单跟随最新值,已有编辑时提示冲突,避免覆盖其他窗口的更改。
67
- - 同步完成后保留只读结果,包含模型、预算、输出来源及备份信息,并区分已确认与保留原值的能力。
68
- - 沿用 DSH 现有认证,不在页面或诊断中显示密钥,不跟随 HTTP 重定向。
69
-
70
- **同步模型或预算设置后请开启新对话。** 已有对话保留原模型路由与 Agent 预设版本;插件不改写已有对话、不重启 DSH,也不增加额外推理请求。新版插件启用期间,动态摘要引导会作用于支持的摘要请求,不需要修改这些已保存设置。
71
-
72
- ## 安装与使用
73
-
74
- 包名为 `dsh-strata-sync`(原名 `@ethan741205/dsh-strata-sync`);迁移时保留原设置,移除旧 scoped 插件后再安装新包,避免同时加载两份。
75
-
76
-
77
- 如需安装已有的 npm 版本,先完成任务并完全退出 DSH Desktop,再使用官方 DSH CLI 从 npm 官方 registry 安装:
35
+ 也可以先完成当前任务、完全退出 DSH Desktop,再使用官方 CLI:
78
36
 
79
37
  ```sh
80
38
  dsh plugin --profile desktop add dsh-strata-sync --registry=https://registry.npmjs.org/
81
39
  ```
82
40
 
83
- 完成后重新打开 DSH。首次安装会自动选中 bundle;已安装但禁用的 bundle 需在插件管理器重新启用。
84
-
85
- 要从源码安装**包含摘要提示词编辑器的 0.10.2**,请使用 Node.js 22 或更新版本构建,并在最后的安装命令前完成任务、完全退出 DSH Desktop:
41
+ 如设置页尚未出现,请重新打开 DSH。若插件处于禁用状态,请在插件管理器启用。
86
42
 
87
- ```sh
88
- git clone https://github.com/ethan741205/dsh-strata-sync.git
89
- cd dsh-strata-sync
90
- npm ci
91
- npm test
92
- npm pack
93
- dsh plugin --profile desktop add ./dsh-strata-sync-0.10.2.tgz
94
- ```
43
+ ### 3. 预览并同步
95
44
 
96
- 执行最后一行前同样需要完全退出 DSH Desktop,安装完成后重新打开。在其他目录执行时,请使用安装包的绝对路径。
45
+ 打开**设置 → dsh-strata-sync**:
97
46
 
98
- 先在 DSH 模型设置建立 Strata 提供方,再打开 **设置 → dsh-strata-sync**:
47
+ 1. 选择 Strata 提供方,点击**保存偏好**。
48
+ 2. 点击**检查差异**,查看已加载模型与拟修改的设置。
49
+ 3. 在 DSH 空闲时,点击**备份并同步**。
50
+ 4. **开启新对话**,使用更新后的模型与 Agent 预设。
99
51
 
100
- 1. 选择已有 Strata 提供方,点击“保存偏好”。保留“跟随 Strata”,需要手动覆盖输出上限时再展开“高级设置”。
101
- 2. 点击“检查差异”,预览当前加载模型与建议设置。
102
- 3. DSH 空闲时点击“备份并同步”。
103
- 4. 如需自动同步,勾选“启动 DSH 时自动同步”并保存,下次启动生效。原有 `autoSync: true` 会沿用为启动同步。
104
- 5. 开启新对话,使用更新后的 Agent 预设。
52
+ 已有对话会保留原先选定的模型路由和预设版本。如需自动设置,可勾选**启动 DSH 时自动同步**并保存。此选项默认关闭,下次启动才生效;会等待空闲,不会持续轮询。
105
53
 
106
- “动态摘要目标”控件独立于模型同步。保持“启用摘要提示补充”开启、使用默认模板及 16/2/2 的除数,即沿用先前行为,也可修改后保存偏好。关闭此开关不会禁用 DSH 自身的压缩功能。
54
+ ## 模型与输出设置
107
55
 
108
- 无需把 API key 复制到此插件;认证问题请在 DSH 模型设置处理。
56
+ | 设置 | 如何决定 |
57
+ |---|---|
58
+ | 模型与上下文 | 采用 Strata 已加载的文本模型及已确认的上下文容量。 |
59
+ | 回复输出上限 | 优先使用手动覆盖值;否则采用已确认的 Strata 输出默认值。无法取得或未限制时,使用上下文的 30%,最多 16,384 tokens。 |
60
+ | 输入类型 | 采用服务器已确认的能力,例如文本或文本+图片。 |
61
+ | 推理等级 | 根据已验证的模型模板确定;未知模板保留原有设置。 |
62
+ | 默认模型 | 启用**默认模型跟随 Strata 已加载的模型**时,跟随服务器当前模型。 |
109
63
 
110
- ## 兼容性
64
+ 保持**输出上限跟随 Strata**开启,即可自动选择。关闭后可在**高级设置**输入手动覆盖值。预览会分别显示服务器默认值、实际应用值及其来源。
111
65
 
112
- 基于 **DSH Desktop 0.2.1-rc.3** 开发和验证。需要标准桌面服务 `configEditor`、`connection`、`agents`、`credentials`、`llm-pi-ai`,以及包含 `compaction-basic` 的已启用 Agent 预设,或生效中的旧式全局压缩插件。仅支持 API key 或无认证的 `openai-completions` 提供方。
66
+ 同步时,插件将摘要输出上限和压缩预留空间均设为 4,096 tokens。实际压缩阈值取**上下文的 80%**与**上下文 − 回复输出预算 − 4,096**中的较小值,近期内容保留量为 **(上下文 − 回复输出预算)× 16%**,向下取整。这些是插件计算的客户端预算,并非 Strata 提供的设置。
113
67
 
114
- Strata 提供方必须明确设置非空的自定义 `models` 列表。仅依赖内置模型目录,或包含非空 `modelOverrides` 的路由,会在预览时拒绝,尚未备份或写入;插件不会将目录型提供方转换为自定义列表,或混用不兼容格式。
68
+ 例如,采用自动输出计算时,32K 上下文的回复预算为 9,830 tokens,压缩阈值为 18,842 tokens,**不一定在 80% 时压缩**。
115
69
 
116
- 无法确认上下文、未加载文本模型、多个文本模型无法判定、slot 容量相互冲突时,会拒绝同步。别名会对应到已加载的正式模型,明确输出非文本的端点会排除;无效别名链会拒绝。目前 UI 跟随单个已加载文本模型,不提供多模型选择器。
70
+ ## 摘要提示词与目标长度
117
71
 
118
- 启动等待调度包含 DSH 0.2.1-rc.3 的 HMR `executing.exit` 兼容处理,避免计时器保留已完成的设置事务;所有写入仍通过 ConfigEditor 的正常队列。升级 DSH 后需重新验证此兼容处理。
72
+ **动态摘要目标**默认开启,在 DSH 原生摘要指令后补充要求;关闭后仍保留原生摘要与压缩行为。
119
73
 
120
- ## 预算策略
121
-
122
- Strata 通过 `/props?model=...` 的 `default_generation_settings.params.n_predict` 提供共享 `max_tokens` 默认值,以及模型与上下文信息。这不是模型硬性上限,客户端明确指定的请求值会覆盖它。Strata **不提供 DSH 压缩策略**。以下是此插件的客户端策略,配合 DSH 0.2.1-rc.3 原生 4,096-token 上下文安全余量:
74
+ 可编辑的**摘要补充提示词**默认内容为:
123
75
 
124
76
  ```text
125
- 普通输出 = 明确手动覆盖值,否则采用已确认的服务器正整数 n_predict
126
- 备用输出 = min(16384, floor(上下文 × 0.30))
127
- 压缩余量 = 4096
128
- 摘要 maxTokens = 4096
129
- thresholdRatio = 0.8
130
- retainRatio = 0.16
131
- 实际压缩阈值 = floor(min(上下文 × 0.8, 上下文 − 普通输出 − 4096))
132
- 近期对话保留量 = floor((上下文 − 普通输出) × 0.16)
77
+ Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
133
78
  ```
134
79
 
135
- 输出选择顺序:手动覆盖 → 已确认的服务器正整数值 → 自动计算。缺少值、null、`-1` 或 `0` 表示没有固定上限;无法获取或确认服务器与模型身份时,也使用备用计算并显示原因。明确但格式错误的值会拒绝同步;正数上限若使压缩空间不足,也会拒绝,不会悄悄换成其他值。UI 显示“Strata Server 默认值/手动覆盖/自动计算”。摘要上限仍是 4,096,压缩阈值与保留量按选定的普通输出上限重算。
80
+ 请保留 `{target}`,每次支持的摘要请求前,它会替换成计算出的 token 目标。模板最多 2,048 个字符。点击**恢复默认提示词**可重置内容,再点击**保存偏好**应用修改。
136
81
 
137
- 下表为没有手动覆盖或固定服务器上限时的备用计算示例:
82
+ 展开**计算方式与限制**,可以调整其余比例:
138
83
 
139
- | 上下文 | 普通输出 | 摘要输出 | 压缩余量 | 压缩阈值 | 近期保留量 |
140
- |---|---:|---:|---:|---:|---:|
141
- | 32,768 | 9,830 | 4,096 | 4,096 | 18,842(57.50%) | 3,670 |
142
- | 65,536 | 16,384 | 4,096 | 4,096 | 45,056(68.75%) | 7,864 |
84
+ | 除数 | 默认值 | 将目标限制为 |
85
+ |---|---:|---|
86
+ | 上下文(N) | 16 | 上下文 ÷ N |
87
+ | 摘要输出(O) | 2 | 本次摘要实际输出上限 ÷ O |
88
+ | 原文长度(S) | 2 | 待摘要内容的估算长度 ÷ S |
89
+
90
+ 目标取三项结果的最小值,再向下取整。所有除数均支持大于或等于 1 的小数。增加除数会降低对应上限,但最终目标仍可能由另一项上限决定。上下文取已确认的服务器与客户端窗口中较小者,原文估算不包含系统提示词和工具定义。
143
91
 
144
- 自定义输出上限必须留下有效的正数压缩预算,且近期保留量须低于阈值。不支持小于 8,192 的上下文。推理选项仅在确认支持时同步;保留认证、其他提供方与其他模型策略;选定路由的保留量统一为 `retainRatio: 0.16`,避免沿用不兼容的绝对值。
92
+ 32K 上下文、摘要上限为 4,096 tokens 且原文足够长时,默认目标为 **2,048 tokens**。这是写作指令,**不是输出硬上限,也不能保证不截断**。界面预览的是目标上限,实际请求的目标可能更小。
145
93
 
146
- 此策略可修正 32K 路由沿用原生 `headroomTokens: 65536` 等不适当预算。动态摘要引导根据本次摘要上限计算较短的写作目标,不会提高或降低硬上限;两项功能都**不能保证模型每次都能在输出上限内完成回答或摘要**,推理也会消耗输出 tokens。不读取或修改 Strata 的 `fit_max_tokens`;服务器设为 `false` 也不会禁用 DSH 自身的输出限制。
94
+ 保存摘要偏好不会改变模型预算,也不会替换原生提示词或增加额外推理、重试循环。无法验证请求、无法安全估算内容,或目标小于 256 tokens 时,会沿用原本的摘要请求。
147
95
 
148
- ## 备份与恢复
96
+ ## 备份与兼容性
149
97
 
150
- 每次应用前,将当前 `cordis.patch.yml` 备份至 profile 旁的 `backups/strata-sync/`,UI 会显示路径。备份可能包含私人提供方设置,请保留在本机,不要公开。
98
+ 写入设置前,会将 `cordis.patch.yml` 备份到配置目录下的 `backups/strata-sync/`。同步会检查是否有并发修改,并在后续步骤失败时尝试回滚已完成的更改。备份可能包含私人配置,请保存在本机。
151
99
 
152
- ConfigEditor 负责单项原子写入与热加载;跨多项设置采用补偿回滚,并非数据库事务。如果同时有外部修改,可能需要依据备份手动恢复。关闭自动同步可取消尚未执行的启动同步,并禁用后续启动同步;移除插件**不会撤销已应用的模型与预算**。需要还原时,请先关闭 DSH 再恢复指定备份。
100
+ 移除插件不会撤销已经同步的设置。如需恢复备份,请先完全退出 DSH。
153
101
 
154
- ## 开发与版本
102
+ 已在 **DSH Desktop 0.2.1-rc.3** 上验证。请使用 API key 或无需认证的 OpenAI 兼容提供方,明确配置自定义模型列表,并启用包含 `compaction-basic` 的 Agent 预设。不支持小于 8,192 tokens 的上下文、仅使用模型目录的提供方、非空的 `modelOverrides`,或无法明确判断已加载模型的信息。
155
103
 
156
- 0.10.1 将摘要界面说明缩短为公式与沿用原生摘要的提示,计算及运行机制不变,完整说明保留在 README。
104
+ 技术细节与测试范围请见[已验证能力与推理映射](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md)及[验证记录](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md)。
157
105
 
158
- 0.10.0 加入补充提示词编辑器、动态 `{target}` 与恢复默认功能,精简三语摘要区域,新增高级输出/原文除数与三项除数的小数支持,并沿用备份与版本冲突保护。
106
+ ## 开发
159
107
 
160
- 0.9.0 加入默认开启的摘要提示补充开关及可调整的上下文除数(默认 16),沿用偏好保存与版本冲突保护,并同步三语界面和文档。保存这两个控件不改变原生摘要指令、输出硬上限、其他预算或服务器设置。
108
+ 需要 Node.js 22 或更新版本。
161
109
 
162
- 0.5.0 移除独立语言菜单与产品声明,改为跟随 DSH 语言及启动时单次同步。0.3.0 首次加入三语 UI,0.2.0 将 UI 移入原生设置。
110
+ ```sh
111
+ git clone https://github.com/ethan741205/dsh-strata-sync.git
112
+ cd dsh-strata-sync
113
+ npm ci
114
+ npm test
115
+ npm run build
116
+ npm pack
117
+ ```
163
118
 
164
- `src/plugin.mjs` 为宿主插件,`src/client.js` 为原生 ModuleLoader/React UI,`src/core.mjs` 负责信息读取与纯预算计算,`src/summary.mjs` 提供原生摘要请求中间件。执行 `npm test`、`npm run build`、`npm pack --dry-run` 验证。安装包只包含原创插件代码,不包含私人应用程序源码、认证或对话。
119
+ 安装自行构建的版本前,请完全退出 DSH,再执行 `dsh plugin --profile desktop add <path-to-generated.tgz>`。
165
120
 
166
- 自动测试覆盖信息读取、认证与重定向安全、预算、回滚、并发修改、启动等待、别名与非文本生成模型、HMR 去重、预设启用、请求映射及三语界面。动态摘要测试覆盖目标计算与原生请求整合;UI 测试确认预览上限与每次请求实际目标的区别。测试使用模拟服务,不生成模型回答,也不代表实际截断率已验证。版本与验证范围见 [VALIDATION](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md)。参考:[DSH 压缩文档](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/compaction/compaction-basic/README.md)、[Strata](https://github.com/Niko1221/Strata)。
121
+ 源码:`src/plugin.mjs`(宿主整合)、`src/core.mjs`(信息读取与预算)、`src/summary.mjs`(摘要引导)、`src/client.js`(设置界面)。
167
122
 
168
- MIT 许可。
123
+ [npm](https://www.npmjs.com/package/dsh-strata-sync) · [反馈问题](https://github.com/ethan741205/dsh-strata-sync/issues) · [MIT 许可证](https://github.com/ethan741205/dsh-strata-sync/blob/main/LICENSE)
@@ -2,167 +2,122 @@
2
2
 
3
3
  [English](https://github.com/ethan741205/dsh-strata-sync/blob/main/README.md) · [简体中文](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/README.zh-CN.md) · **繁體中文**
4
4
 
5
- 讓 **DeepSeek Harness(DSH)** 對齊 **Strata Server** 實際載入的模型,並在 DSH **設定 → dsh-strata-sync** 中提供操作介面。
5
+ 讓 **DeepSeek Harness(DSH)** 連接 **Strata Server** 目前載入的模型,在同一個 DSH 設定頁管理模型配置與摘要控制。
6
6
 
7
- 0.10.1 進一步精簡摘要設定說明。可保留預設提示詞範本,或使用動態 `{target}` 自訂內容;DSH 原生提示詞與輸出硬上限保持不變。
7
+ 外掛讀取 Strata 的模型資訊、預覽差異,再更新 DSH 自訂模型與上下文壓縮預算。它也會為支援的摘要請求補充可編輯的長度指令,幫助模型產生精簡的摘要。
8
8
 
9
- ## 功能
9
+ ## 可以做什麼
10
10
 
11
- ### 動態摘要引導
11
+ - **同步模型設定:**上下文視窗、回覆輸出上限,以及已確認的輸入類型和推理等級。
12
+ - **對齊壓縮預算:**更新已啟用的 DSH Agent 預設中,對應模型的壓縮政策。
13
+ - **控制摘要長度:**編輯補充提示詞,調整三項目標長度比例。
14
+ - **啟動時同步:**可選擇在 DSH 啟動並閒置後同步一次。
15
+ - **預覽與復原:**檢查差異、備份設定,並查看最近一次同步結果。
12
16
 
13
- 精簡的「**動態摘要目標**」區塊包含啟用開關、上下文除數和可編輯的「**摘要補充提示詞**」;展開「**計算方式與限制**」可調整摘要輸出與原文長度的除數,並查看公式與限制。功能預設開啟,關閉後仍保留 DSH 原生摘要與自動壓縮。
17
+ 外掛僅以唯讀方式存取 Strata Server。同步不會切換或載入伺服器模型、修改伺服器設定,也不會傳送測試推論請求。無法確認的模型能力會保留 DSH 原有值。
14
18
 
15
- 編輯框直接顯示實際附加至原生提示詞的範本,預設內容如下:
19
+ ## 開始使用
16
20
 
17
- ```text
18
- Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
19
- ```
21
+ ### 1. 準備連線
20
22
 
21
- 範本須保留字面的 `{target}`,每次摘要時會將所有出現位置替換為當次計算的目標。長度最多 2,048 個字元;只做文字替換,不執行程式碼。「**還原預設提示詞**」會將編輯框恢復為原本的英文範本,修改或還原後按「**儲存偏好**」才會套用。切換介面語言不會翻譯或覆寫已儲存的範本。這裡只編輯補充內容,不修改 DSH 原生摘要指令。
23
+ 先在 Strata Server 載入模型,再到 **DSH → 設定 → 模型**,設定相容 OpenAI 的提供者、API 網址與認證,並明確新增自訂模型項目。
22
24
 
23
- | 外掛偏好 | 預設值 | 含義 |
24
- |---|---:|---|
25
- | `summaryGuidance` | `true` | 對支援的摘要請求附加補充提示詞。 |
26
- | `summaryContextDivisor` | `16` | 以上下文除以此值。 |
27
- | `summaryOutputDivisor` | `2` | 以當次摘要輸出硬上限除以此值。 |
28
- | `summarySourceDivisor` | `2` | 以原文估算長度除以此值。 |
29
- | `summaryPromptTemplate` | 上方英文範本 | 替換 `{target}` 後附加的補充內容。 |
25
+ 外掛直接沿用這個連線,不必另外複製 API key。
30
26
 
31
- 三項除數都接受至少為 1 的有限數值,也支援 1.5、2.5 等小數。除數越大,對應限制越小;最終取三項限制的最小值並向下取整,不會改變實際輸出硬上限。
27
+ ### 2. 安裝外掛
32
28
 
33
- 每次支援的摘要請求都會重新計算:
29
+ 在 DSH 外掛管理員選擇**新增外掛**,輸入:
34
30
 
35
31
  ```text
36
- 上下文 = min(已確認的 Strata 上下文, DSH 既有模型上下文)
37
- 目標 = floor(min(上下文 / summaryContextDivisor,
38
- 本次摘要實際 maxTokens / summaryOutputDivisor,
39
- 待替換內容的估算 tokens / summarySourceDivisor))
32
+ dsh-strata-sync
40
33
  ```
41
34
 
42
- 原文估算涵蓋這次要替換的對話片段與其中的舊摘要,不含系統提示詞和工具定義。唯讀查詢核對載入模型與上下文,實際輸出硬上限來自當次請求。32K 上下文、4,096-token 摘要上限且原文足夠長時,上下文除數 32、16、8 分別得到 1,024、2,048、2,048 tokens。UI 預覽顯示目標上限,不是未來請求的實際目標。
43
-
44
- 儲存這些控制項只更改外掛偏好,不會同步模型預算或修改 Strata Server 設定。DSH 原生提示詞、八個章節和請求參數保持不變。預設補充內容只有一句,自訂範本則按輸入內容附加。目標是寫作指令,**不是新的輸出硬上限,也不能保證不截斷**;不增加重試流程或額外推論請求。
45
-
46
- 無法確認路由或資訊、原生提示詞格式未知、附件用量無法估算、範本無效、請求取消、功能關閉或目標低於 256 tokens 時,保留原生請求。移除外掛會停止附加內容,不重寫已儲存的對話歷史。
47
-
48
- ### 模型能力自動同步(0.4.0)
49
-
50
- 預覽新增「輸入類型」、「推理等級」和「推理請求對應」,與 token 預算共用備份、回復及閒置才套用的保護。
51
-
52
- - 輸入類型依伺服器明確回報的 `architecture.input_modalities` 設定為文字或文字+圖片;缺少資訊或格式不支援時保留原值。
53
- - 推理等級從 `/props?model=...` 核對 Strata 身分、模型身分及已審查的對話範本指紋,不單憑名稱猜測。
54
- - 已驗證的 Qwen3.8-Flash-Next:**off/low/medium/xhigh**;DeepSeek-V4.1-Flash:**off/low/high/max**。包含已核對的 Huihui 版本,以範本而非量化名稱判定。
55
- - 使用 DSH 原生請求對應,同時設定是否思考及推理等級。範本未知或無法取得 props 時,保留原推理設定並顯示原因。
56
- - 不修改供應者預設等級或目前對話選擇。供應者預設值與已驗證選項衝突時,跳過推理同步並提示。同步後請開新對話。
57
-
58
- 詳見[能力驗證與對應表](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md)。不新增其他外掛、不修改 Strata 設定。
59
-
60
- ### 既有同步功能
61
-
62
- - 讀取 `/v1/models` 與可用的 `/slots`,確認文字模型的正式 ID 和引擎實際上下文,不從模型名稱猜測。已確認的別名視為同一模型,圖片生成端點不列入文字模型選擇。
63
- - 更新選定 DSH 模型的上下文、輸出上限,以及已啟用 Agent 範本中的原生 `compaction-basic` 策略;預覽會列出受影響的範本。
64
- - 預設使用「跟隨 Strata」選擇輸出上限;手動覆寫放在「進階設定」。分開顯示伺服器原值、實際採用值與來源,也可選擇讓預設模型跟隨伺服器。
65
- - 自動同步預設關閉;在啟動前啟用後,每次 DSH 宿主程序啟動、所有工作閒置時同步一次。查詢途中開始工作時保留待同步狀態,工作完成後補做;成功後不再定期查詢。其他錯誤需手動重試或下次啟動再試。執行期間啟用會在下次啟動生效;立即同步請按「備份並同步」。
66
- - 套用前重新確認伺服器與同一份設定版本、拒絕過期預覽、備份設定;後續寫入失敗時回復已完成的變更。偏好儲存也會核對版本;未編輯的表單跟隨最新值,已有編輯時提示衝突,避免覆蓋其他視窗的變更。
67
- - 同步完成後保留唯讀結果,包含模型、預算、輸出來源及備份資訊,並區分已確認與保留原值的能力。
68
- - 沿用 DSH 現有認證,不在頁面或診斷中顯示金鑰,不跟隨 HTTP 重新導向。
69
-
70
- **同步模型或預算設定後請開新對話。** 既有對話保留原模型路由與 Agent 範本版本;外掛不重寫既有對話、不重啟 DSH,也不增加額外推論請求。新版外掛啟用期間,動態摘要引導會作用於支援的摘要請求,不需要修改這些已儲存設定。
71
-
72
- ## 安裝與使用
73
-
74
- 套件名稱為 `dsh-strata-sync`(原名 `@ethan741205/dsh-strata-sync`);遷移時保留原設定,移除舊 scoped 插件後再安裝新套件,避免同時載入兩份。
75
-
76
-
77
- 若要安裝既有的 npm 版本,先完成工作並完全結束 DSH Desktop,再使用官方 DSH CLI 從 npm 官方 registry 安裝:
35
+ 也可以先完成目前工作、完全結束 DSH Desktop,再使用官方 CLI:
78
36
 
79
37
  ```sh
80
38
  dsh plugin --profile desktop add dsh-strata-sync --registry=https://registry.npmjs.org/
81
39
  ```
82
40
 
83
- 完成後重新開啟 DSH。首次安裝會自動選取 bundle;已安裝但停用的 bundle 需在外掛管理員重新啟用。
84
-
85
- 要從原始碼安裝**包含摘要提示詞編輯器的 0.10.2**,請使用 Node.js 22 或更新版本建置,並在最後的安裝命令前完成工作、完全結束 DSH Desktop:
41
+ 若設定頁尚未出現,請重新開啟 DSH。若外掛處於停用狀態,請在外掛管理員啟用。
86
42
 
87
- ```sh
88
- git clone https://github.com/ethan741205/dsh-strata-sync.git
89
- cd dsh-strata-sync
90
- npm ci
91
- npm test
92
- npm pack
93
- dsh plugin --profile desktop add ./dsh-strata-sync-0.10.2.tgz
94
- ```
43
+ ### 3. 預覽並同步
95
44
 
96
- 執行最後一行前同樣需要完全結束 DSH Desktop,安裝完成後重新開啟。在其他目錄執行時,請使用套件的絕對路徑。
45
+ 開啟**設定 → dsh-strata-sync**:
97
46
 
98
- 先在 DSH 模型設定建立 Strata 供應者,再開啟 **設定 → dsh-strata-sync**:
47
+ 1. 選擇 Strata 提供方,點選**儲存偏好**。
48
+ 2. 點選**檢查差異**,查看已載入模型與預計修改的設定。
49
+ 3. 在 DSH 閒置時,點選**備份並同步**。
50
+ 4. **開啟新對話**,使用更新後的模型與 Agent 預設。
99
51
 
100
- 1. 選擇既有 Strata 供應者,按「儲存偏好」。保留「跟隨 Strata」,需要手動覆寫輸出上限時再展開「進階設定」。
101
- 2. 按「檢查差異」,預覽目前載入模型與建議設定。
102
- 3. DSH 閒置時按「備份並同步」。
103
- 4. 如需自動同步,勾選「啟動 DSH 時自動同步」並儲存,下次啟動生效。原有 `autoSync: true` 會沿用為啟動同步。
104
- 5. 開啟新對話,使用更新後的 Agent 範本。
52
+ 既有對話會保留原先選定的模型路由和預設版本。如需自動設定,可勾選**啟動 DSH 時自動同步**並儲存。此選項預設關閉,下次啟動才生效;會等待閒置,不會持續輪詢。
105
53
 
106
- 「動態摘要目標」控制項獨立於模型同步。保持「啟用摘要提示補充」開啟、使用預設範本及 16/2/2 的除數,即沿用先前行為,也可修改後儲存偏好。關閉此開關不會停用 DSH 自身的壓縮功能。
54
+ ## 模型與輸出設定
107
55
 
108
- 不需要把 API key 複製到此外掛;認證問題請在 DSH 模型設定處理。
56
+ | 設定 | 如何決定 |
57
+ |---|---|
58
+ | 模型與上下文 | 採用 Strata 已載入的文字模型及已確認的上下文容量。 |
59
+ | 回覆輸出上限 | 優先使用手動覆寫值;否則採用已確認的 Strata 輸出預設值。無法取得或未限制時,使用上下文的 30%,最多 16,384 tokens。 |
60
+ | 輸入類型 | 採用伺服器已確認的能力,例如文字或文字+圖片。 |
61
+ | 推理等級 | 依已驗證的模型範本決定;未知範本保留原有設定。 |
62
+ | 預設模型 | 啟用**預設模型跟隨 Strata 已載入的模型**時,跟隨伺服器目前模型。 |
109
63
 
110
- ## 相容性
64
+ 保持**輸出上限跟隨 Strata**開啟,即可自動選擇。關閉後可在**進階設定**輸入手動覆寫值。預覽會分別顯示伺服器預設值、實際套用值及其來源。
111
65
 
112
- 以 **DSH Desktop 0.2.1-rc.3** 開發及驗證。需要標準桌面服務 `configEditor`、`connection`、`agents`、`credentials`、`llm-pi-ai`,以及含 `compaction-basic` 的已啟用 Agent 範本,或作用中的舊式全域壓縮外掛。僅支援 API key 或無認證的 `openai-completions` 供應者。
66
+ 同步時,外掛將摘要輸出上限和壓縮預留空間均設為 4,096 tokens。實際壓縮門檻取**上下文的 80%**與**上下文 − 回覆輸出預算 − 4,096**中的較小值,近期內容保留量為 **(上下文 − 回覆輸出預算)× 16%**,向下取整。這些是外掛計算的客戶端預算,並非 Strata 提供的設定。
113
67
 
114
- Strata 供應者必須明確設定非空的自訂 `models` 清單。僅依賴內建模型目錄,或含非空 `modelOverrides` 的路由,會在預覽時拒絕,尚未備份或寫入;外掛不會將目錄型供應者轉換成自訂清單,或混用不相容格式。
68
+ 例如,採用自動輸出計算時,32K 上下文的回覆預算為 9,830 tokens,壓縮門檻為 18,842 tokens,**不一定在 80% 時壓縮**。
115
69
 
116
- 無法確認上下文、未載入文字模型、多個文字模型無法判定、slot 容量互相衝突時,會拒絕同步。別名會對應至已載入的正式模型,明確輸出非文字的端點會排除;無效別名鏈會拒絕。目前 UI 跟隨單一已載入文字模型,不提供多模型選擇器。
70
+ ## 摘要提示詞與目標長度
117
71
 
118
- 啟動等待排程含 DSH 0.2.1-rc.3 的 HMR `executing.exit` 相容處理,避免計時器保留已完成的設定交易;所有寫入仍透過 ConfigEditor 的正常佇列。升級 DSH 後需重新驗證此相容處理。
72
+ **動態摘要目標**預設開啟,在 DSH 原生摘要指令後補充要求;關閉後仍保留原生摘要與壓縮行為。
119
73
 
120
- ## 預算策略
121
-
122
- Strata 透過 `/props?model=...` 的 `default_generation_settings.params.n_predict` 提供共用 `max_tokens` 預設值,以及模型與上下文資訊。這不是模型硬性上限,客戶端明確指定的請求值會覆寫它。Strata **不提供 DSH 壓縮策略**。下列是此外掛的用戶端策略,配合 DSH 0.2.1-rc.3 原生 4,096-token 上下文安全餘裕:
74
+ 可編輯的**摘要補充提示詞**預設內容為:
123
75
 
124
76
  ```text
125
- 一般輸出 = 明確手動覆寫值,否則採用已確認的伺服器正整數 n_predict
126
- 備用輸出 = min(16384, floor(上下文 × 0.30))
127
- 壓縮餘裕 = 4096
128
- 摘要 maxTokens = 4096
129
- thresholdRatio = 0.8
130
- retainRatio = 0.16
131
- 實際壓縮門檻 = floor(min(上下文 × 0.8, 上下文 − 一般輸出 − 4096))
132
- 近期對話保留量 = floor((上下文 − 一般輸出) × 0.16)
77
+ Keep the entire checkpoint, including all required headings, within a target of {target} tokens by retaining only information essential to continue the remaining work, consolidating prior summaries, and removing redundant or obsolete details.
133
78
  ```
134
79
 
135
- 輸出選擇順序:手動覆寫 → 已確認的伺服器正整數值 → 自動計算。缺少值、null、`-1` 或 `0` 代表沒有固定上限;無法取得或確認伺服器與模型身分時,也使用備用計算並顯示原因。明確但格式錯誤的值會拒絕同步;正數上限若使壓縮空間不足,也會拒絕,不會偷偷換成別的值。UI 顯示「Strata Server 預設值/手動覆寫/自動計算」。摘要上限仍是 4,096,壓縮門檻與保留量依選定的一般輸出上限重算。
80
+ 請保留 `{target}`,每次支援的摘要請求前,它會替換成計算出的 token 目標。範本最多 2,048 個字元。點選**還原預設提示詞**可重設內容,再點選**儲存偏好**套用修改。
136
81
 
137
- 下表為沒有手動覆寫或固定伺服器上限時的備用計算範例:
82
+ 展開**計算方式與限制**,可以調整其餘比例:
138
83
 
139
- | 上下文 | 一般輸出 | 摘要輸出 | 壓縮餘裕 | 壓縮門檻 | 近期保留量 |
140
- |---|---:|---:|---:|---:|---:|
141
- | 32,768 | 9,830 | 4,096 | 4,096 | 18,842(57.50%) | 3,670 |
142
- | 65,536 | 16,384 | 4,096 | 4,096 | 45,056(68.75%) | 7,864 |
84
+ | 除數 | 預設值 | 將目標限制為 |
85
+ |---|---:|---|
86
+ | 上下文(N) | 16 | 上下文 ÷ N |
87
+ | 摘要輸出(O) | 2 | 本次摘要實際輸出上限 ÷ O |
88
+ | 原文長度(S) | 2 | 待摘要內容的估算長度 ÷ S |
89
+
90
+ 目標取三項結果的最小值,再向下取整。所有除數均支援大於或等於 1 的小數。增加除數會降低對應上限,但最終目標仍可能由另一項上限決定。上下文取已確認的伺服器與客戶端視窗中較小者,原文估算不包含系統提示詞和工具定義。
143
91
 
144
- 自訂輸出上限必須保留有效的正數壓縮預算,且近期保留量須低於門檻。不支援小於 8,192 的上下文。推理選項僅於確認支援時同步;保留認證、其他供應者與其他模型策略;選定路由的保留量統一為 `retainRatio: 0.16`,以免沿用不相容的絕對值。
92
+ 32K 上下文、摘要上限為 4,096 tokens 且原文足夠長時,預設目標為 **2,048 tokens**。這是寫作指令,**不是輸出硬上限,也不能保證不截斷**。介面預覽的是目標上限,實際請求的目標可能更小。
145
93
 
146
- 此策略可修正 32K 路由沿用原生 `headroomTokens: 65536` 等不適當預算。動態摘要引導依本次摘要上限計算較短的寫作目標,不會提高或降低硬上限;兩項功能都**不能保證模型每次都能在輸出上限內完成回答或摘要**,推理也會消耗輸出 tokens。不讀取或修改 Strata 的 `fit_max_tokens`;伺服器設為 `false` 也不會停用 DSH 自身的輸出限制。
94
+ 儲存摘要偏好不會改變模型預算,也不會替換原生提示詞或增加額外推論、重試循環。無法驗證請求、無法安全估算內容,或目標小於 256 tokens 時,會沿用原本的摘要請求。
147
95
 
148
- ## 備份與復原
96
+ ## 備份與相容性
149
97
 
150
- 每次套用前,將目前 `cordis.patch.yml` 備份至 profile 旁的 `backups/strata-sync/`,UI 會顯示路徑。備份可能包含私人供應者設定,請留在本機,不要公開。
98
+ 寫入設定前,會將 `cordis.patch.yml` 備份至設定目錄下的 `backups/strata-sync/`。同步會檢查是否有並行修改,並在後續步驟失敗時嘗試回復已完成的變更。備份可能包含私人設定,請儲存在本機。
151
99
 
152
- ConfigEditor 負責個別原子寫入與熱載入;跨多項設定採補償回復,並非資料庫交易。若同時有外部修改,可能需要依備份手動復原。關閉自動同步可取消尚未執行的啟動同步,並停用後續啟動同步;移除外掛**不會撤銷已套用的模型與預算**。需要還原時,請先關閉 DSH 再恢復指定備份。
100
+ 移除外掛不會撤銷已經同步的設定。如需還原備份,請先完全結束 DSH。
153
101
 
154
- ## 開發與版本
102
+ 已在 **DSH Desktop 0.2.1-rc.3** 上驗證。請使用 API key 或不需認證的 OpenAI 相容提供者,明確設定自訂模型清單,並啟用包含 `compaction-basic` 的 Agent 預設。不支援小於 8,192 tokens 的上下文、僅使用模型目錄的提供者、非空的 `modelOverrides`,或無法明確判斷已載入模型的資訊。
155
103
 
156
- 0.10.1 將摘要介面說明縮短為公式與沿用原生摘要的提示,計算及執行機制不變,完整說明保留在 README。
104
+ 技術細節與測試範圍請見[已驗證能力與推理對應](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/CAPABILITIES.md)及[驗證紀錄](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md)。
157
105
 
158
- 0.10.0 加入補充提示詞編輯器、動態 `{target}` 與還原預設功能,精簡三語摘要區塊,新增進階輸出/原文除數與三項除數的小數支援,並沿用備份與版本衝突保護。
106
+ ## 開發
159
107
 
160
- 0.9.0 加入預設開啟的摘要提示補充開關及可調整的上下文除數(預設 16),沿用偏好儲存與版本衝突保護,並同步三語介面和文件。儲存這兩個控制項不改變原生摘要指令、輸出硬上限、其他預算或伺服器設定。
108
+ 需要 Node.js 22 或更新版本。
161
109
 
162
- 0.5.0 移除獨立語言選單與產品聲明,改為跟隨 DSH 語言及啟動時單次同步。0.3.0 首次加入三語 UI,0.2.0 將 UI 移入原生設定。
110
+ ```sh
111
+ git clone https://github.com/ethan741205/dsh-strata-sync.git
112
+ cd dsh-strata-sync
113
+ npm ci
114
+ npm test
115
+ npm run build
116
+ npm pack
117
+ ```
163
118
 
164
- `src/plugin.mjs` 為宿主外掛,`src/client.js` 為原生 ModuleLoader/React UI,`src/core.mjs` 負責資訊讀取與純預算計算,`src/summary.mjs` 提供原生摘要請求中介層。執行 `npm test`、`npm run build`、`npm pack --dry-run` 驗證。套件只包含原創外掛程式,不包含私人應用程式原始碼、認證或對話。
119
+ 安裝自行建置的版本前,請完全結束 DSH,再執行 `dsh plugin --profile desktop add <path-to-generated.tgz>`。
165
120
 
166
- 自動測試涵蓋資訊讀取、認證與重新導向安全、預算、回復、並行修改、啟動等待、別名與非文字生成模型、HMR 去重、範本啟用、請求對應及三語介面。動態摘要測試涵蓋目標計算與原生請求整合;UI 測試確認預覽上限與每次請求實際目標的區別。測試使用模擬服務,不產生模型回答,也不代表實際截斷率已驗證。版本與驗證範圍見 [VALIDATION](https://github.com/ethan741205/dsh-strata-sync/blob/main/docs/VALIDATION.md)。參考:[DSH 壓縮文件](https://github.com/deepseek-ai/deepseek-harness/blob/master/packages/compaction/compaction-basic/README.md)、[Strata](https://github.com/Niko1221/Strata)。
121
+ 原始碼:`src/plugin.mjs`(宿主整合)、`src/core.mjs`(資訊讀取與預算)、`src/summary.mjs`(摘要引導)、`src/client.js`(設定介面)。
167
122
 
168
- MIT 授權。
123
+ [npm](https://www.npmjs.com/package/dsh-strata-sync) · [回報問題](https://github.com/ethan741205/dsh-strata-sync/issues) · [MIT 授權](https://github.com/ethan741205/dsh-strata-sync/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-strata-sync",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
4
4
  "description": "Native DSH settings UI for synchronizing Strata Server models, context and compaction budgets",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",