@jayyuen66/dsh-dir-prep-organize 0.1.6 → 0.1.7

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 CHANGED
@@ -3,6 +3,35 @@
3
3
  格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循
4
4
  [语义化版本](https://semver.org/lang/zh-CN/)。最新版本在最上。
5
5
 
6
+ ## 0.1.7
7
+
8
+ 这一版让润色跟随会话当前的模型选择,把模板写入改成宿主校验的光标插入,并把插件页展示面收进包内。
9
+
10
+ ### Changed
11
+
12
+ - **润色模型来源改为会话活线优先**:`organize` 先读活 Agent 的 `model.current()`,旧宿主回落 `agent.options`,
13
+ 两者都没有才用 `agentDefaultModel.currentSelection()`。
14
+ - **模板改为光标插入**:`captureInsertion()` + `insertText()` 由宿主按发起的选区核验,草稿里的引用块与附件
15
+ 不再被整稿替换抹平;输入框处于提交期时两个入口禁用,宿主拒绝插入时不回落 `setDraft`。
16
+ - **润色结果写回增加版本凭据**:新增 `src/input-writeback.ts`,按会话 id、草稿版本、输入动作面身份与
17
+ `phase` 判定;请求期间继续输入、切换会话或进入提交期都会放弃写回,并提示「输入框内容已变化」。
18
+ - **设置卡改用 shared 的卡片骨架**:正文改为「角色库」小节,保存与撤销走统一 `SaveBar`,样式使用
19
+ `CARD_UI_CSS` 与 `dsu-*` 控件类。
20
+ - **Remote 参数校验改用 zod strict codec**:新增 `zod` 运行期依赖,client 产物按宿主 `PLATFORM_MODULES`
21
+ 外部化;`THIRD_PARTY_NOTICES` 同步补声明。
22
+ - **宿主开发依赖抬到 `0.2.2-alpha.2`**:catalog、overrides 与 devDependencies 同值;`engines.dsh` 与
23
+ peer 的支持窗口保持 `^0.2.1-rc.3`。
24
+ - **插件页展示元数据进包**:新增 `locale/en.json`、`locale/zh.json` 与 `docs/DETAIL.md`、`docs/DETAIL.zh.md`;
25
+ `exports` 增加 `./locale/*.json`,`files` 收进 locale 与 docs。
26
+
27
+ ### Fixed
28
+
29
+ - **请求在途时用户继续编辑,旧润色结果会覆盖新草稿**:写回改为读最新一帧并核对版本戳,过期结果不再落地。
30
+ - **模板插入会重建整份草稿**:改走输入框的插入面后只插入文本,引用块与附件保持原样。
31
+ - **干净 npm 安装与宿主品牌包的 cordis 线冲突**:`@deepseek-ai/cordis` 的 optional peer 改为
32
+ `~4.0.5 || 4.0.6-alpha.1`,既接受宿主当前要求的 `~4.0.5`,也接受编译所用的
33
+ `4.0.6-alpha.1`;编译期精确钉版仍留在 `devDependencies`。
34
+
6
35
  ## 0.1.6
7
36
 
8
37
  这一版收口客户端交互与错误文案,并把构建、CI 与伞工作区基线统一;模板数据与 85 条内置精选不变。
package/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  <h1 align="center">dsh-dir-prep-organize</h1>
6
6
 
7
- <p align="center"><em>Two buttons beside the dsh chat input: rewrite the draft with the current directory in view, and drop a role template into it.</em></p>
7
+ <p align="center"><em>Two buttons beside the dsh chat input: rewrite the draft with the current directory in view, and insert a role template at the caret.</em></p>
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/v/@jayyuen66/dsh-dir-prep-organize?style=flat-square&logo=npm&logoColor=white" alt="npm version" /></a>
11
- <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/dm/@jayyuen66/dsh-dir-prep-organize?style=flat-square" alt="npm downloads" /></a>
11
+ <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/d18m/@jayyuen66/dsh-dir-prep-organize?style=flat-square" alt="npm downloads (18 months)" /></a>
12
12
  <a href="https://github.com/JayYuen666/dsh-dir-prep-organize/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/JayYuen666/dsh-dir-prep-organize/ci.yml?branch=main&style=flat-square&label=ci" alt="ci" /></a>
13
13
  <img src="https://img.shields.io/badge/license-MIT-4c1?style=flat-square" alt="MIT" />
14
14
  <img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
@@ -27,7 +27,7 @@
27
27
  <a href="./README.zh-CN.md"><img src="https://img.shields.io/badge/lang-简体中文-658EFF?style=flat-square" alt="简体中文" /></a>
28
28
  </p>
29
29
 
30
- **A [dsh](https://github.com/deepseek-ai/deepseek-harness) plugin: a split "Polish" button that hands your draft, the top level of the session directory and the recent real turns to the current default model for a rewrite, plus a "Template" dropdown of role templates. Zero model tools, zero HTTP routes of its own.**
30
+ **A [dsh](https://github.com/deepseek-ai/deepseek-harness) plugin: a split "Polish" button that hands your draft, the top level of the session directory and the recent real turns to the model selected for that conversation (falling back to the host default) for a rewrite, plus a "Template" dropdown of role templates. Zero model tools, zero HTTP routes of its own.**
31
31
 
32
32
  ## <img src="https://api.iconify.design/lucide/file-text.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Contents
33
33
 
@@ -51,14 +51,14 @@
51
51
  - Adds **two controls** to the right of the web chat input: a split "Polish" button (main key + caret) and a "Template" dropdown.
52
52
  - The main key polishes directly; the caret key offers "polish in a role's style".
53
53
  - The dropdown groups entries by their `group` field; an entry with an empty group lands in "General".
54
- - **Polish** sends the draft, the top level of the session cwd (file names, sizes, and the full text of key text files), and the session's **real** user/assistant turns to the current default model, then replaces the draft with the rewrite.
54
+ - **Polish** sends the draft, the top level of the session cwd (file names, sizes, and the full text of key text files), and the session's **real** user/assistant turns to the model selected for that conversation (falling back to the host default), then replaces the draft with the rewrite. The result is written back only while the session, draft revision and input phase are unchanged.
55
55
  - On failure the draft is **never** touched: the button shows an error state for 4 seconds with the reason in its tooltip.
56
- - **Templates** insert text into the draft: a whole fill when the draft is empty, an append after one blank line otherwise.
56
+ - **Templates** insert text at the caret through the input box's insert face: quoted blocks and attachments stay intact, and a stale insertion is refused instead of replacing the draft. Both controls are disabled while the input box is submitting.
57
57
  - The built-in set is **85 curated role templates**, generated by `scripts/gen-defaults.mjs` from this package's `agents/` role library - a vendored collection of several hundred role `.md` files across more than twenty department directories. The curated 85 is the number that matters to a user; the library size is not pinned here because it changes whenever the upstream project is refreshed.
58
58
  - That table **stays host-side**: the client bundle no longer inlines it. The generated file is ~640 KB and used to push `client.js` to ~711 KB.
59
59
  - The browser calls the Remote `defaults` method **once, lazily** (first menu open or first settings-card visit) and reuses it in-process. Nothing is fetched at all when the user already has their own templates.
60
60
  - While it has not arrived the menu shows a loading row - not the "no templates" hint. A failure surfaces the host's own reason plus a Retry button.
61
- - The **"Template library"** card covers per-entry add/edit/delete, a two-step restore of the defaults, one-click import of the whole built-in library, import of a local `.md` or directory **by path**, and registration of extra allowed import directories. That card is **one list feeding two places**: the input-box "Template" dropdown and the "Polish" ▾ role menu.
61
+ - The settings card's **"Role library"** section covers per-entry add/edit/delete, a two-step restore of the defaults, one-click import of the whole built-in library, import of a local `.md` or directory **by path**, and registration of extra allowed import directories. That section is **one list feeding two places**: the input-box "Template" dropdown and the "Polish" ▾ role menu.
62
62
  - Templates and allowed directories are read and written through the host settings with **zero LLM calls**, and **no model tool is registered**.
63
63
 
64
64
  ## <img src="https://api.iconify.design/lucide/package.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Install
@@ -70,12 +70,12 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
70
70
  Remove with `dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`. The package is on the public npm registry, so installation needs no credentials and no scoped-registry line.
71
71
 
72
72
  - **Requires Node.js `>= 22.12`.** This is an ESM-only package. Use the **named** exports (`import { apply } from "@jayyuen66/dsh-dir-prep-organize"`); there is **no default export**, so `import pkg from …` fails with `does not provide an export named 'default'`. That Node floor is what makes `require()` of an ESM entry work at all, which is why `engines.node` is declared.
73
- - **Requires host `dsh` at the `0.2.1-rc.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.3`), and it **decides alone**: `evaluatePluginCompatibility` returns on the `engines.dsh` branch before it ever looks at `peerDependencies`. Measured against the real host code: `0.2.0-rc.2` is **refused**, `0.2.1-rc.3` and `0.2.2` pass, `0.3.0` is refused. A refused host needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`.
74
- - **The `@deepseek-ai/dsh-*` pins stay at `0.2.1-rc.3`** - the version this package is built and tested against. The `engines.dsh` range is a claim about which *hosts* it runs on; the pin is a fact about which host version it was *compiled* against. Mixing the two is why the publish gate checks them separately.
73
+ - **Requires host `dsh` at the `0.2.1-rc.3` line.** The requirement the host actually reads is `engines.dsh` (`^0.2.1-rc.3`), and it **decides alone**: `evaluatePluginCompatibility` returns on the `engines.dsh` branch before it ever looks at `peerDependencies`. Measured against the real host code: `0.2.0-rc.2` is **refused**, `0.2.1-rc.3` and `0.2.2` pass, `0.3.0` is refused. A refused host needs the explicit risk grant `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`. The support window rolls: this package is verified against the three most recently released host versions at publish time and re-verified once the window moves, so the version number in this bullet is not a standing promise.
74
+ - **The `@deepseek-ai/dsh-*` development pins are at `0.2.2-alpha.2`** - the host line this package is built and tested against. `engines.dsh` and the optional peer ranges carry the separately checked support window (`^0.2.1-rc.3`); the pin is a fact about which host version it was *compiled* against, not a restatement of that window. Mixing the two is why the publish gate checks them separately.
75
75
  - **No `@deepseek-ai/*` under `dependencies`, by contract** (`test/publish-manifest.test.ts` enforces it). Consumer profiles install with `nodeLinker: hoisted` and `autoInstallPeers: false`, so a host package under `dependencies` is materialized as a **real directory** next to the copy the running host already loaded. `@deepseek-ai/dsh-tools` keys its tool-runtime scheduler with a plain `Symbol` (not `Symbol.for`), so symbol identity is per module instance: the host reads the scheduler off the profile copy, gets `undefined`, and **every native tool call throws** - while this package's build, typecheck and coverage gates stay green right up to that moment.
76
76
  - **The two host packages `host.js` imports as values are required peers**: `@deepseek-ai/schemastery` (the host's fork - only it resolves the `.volatile()` fields) and `@deepseek-ai/dsh-brand`. `build-host.mjs` externalizes `dependencies` **and** `peerDependencies`, so the bare specifiers stay in the artifact; a devDependencies-only entry would let the bundler inline the official function body. `test/build-host.test.ts` pins both "specifier present" and "function body absent".
77
77
  - **Every host package the emitted declarations name is declared under `peerDependencies`**, and each one reached only there is *optional* (`@deepseek-ai/cordis`, `cosmokit`, and the `dsh-agent-default-model` / client-ui / `fs` / `llm` / `session` family). Declaring them is not ceremony: under pnpm's strict layout a bare specifier in `types/host.d.ts` that no manifest table names is unresolvable on the consumer's side, while this repository's own typecheck stays green. The test reads that roster off `types/**/*.d.ts` rather than off this paragraph, so the two cannot drift apart.
78
- - **What ships**: `host.js`, `client.js`, `templates.data.mjs`, `types/`, `cordis.patch.yml`, `agents/` and `THIRD_PARTY_NOTICES.md`. `package.json`, `README*` and `LICENSE` are attached unconditionally by the registry client.
78
+ - **What ships**: `host.js`, `client.js`, `templates.data.mjs`, `types/`, `cordis.patch.yml`, `agents/`, `locale/`, `docs/` and `THIRD_PARTY_NOTICES.md`. `package.json`, `README*` and `LICENSE` are attached unconditionally by the registry client.
79
79
  - **The built-in table ships as its own artifact and is loaded on first use**, not at plugin load. It used to be bundled into `host.js`, so every user paid for the templates in memory even without opening the dropdown.
80
80
  - **`agents/` is not authored here**: it comes from [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh) (MIT). The copyright and licence notice ship in `THIRD_PARTY_NOTICES.md`, because MIT requires it in every distributed copy. Do not hand-edit files under `agents/`.
81
81
 
@@ -90,7 +90,7 @@ If your profile pins `@jayyuen66/dsh-plugin-shared` with a pnpm `overrides` entr
90
90
  - A layer line may read `# == <layer>` or `# == <layer>, patched by <path>`; accept both forms.
91
91
  2. **The dropdown fills**: open "Template" and the built-in list arrives through the Remote `defaults` method. A loading row means the call is in flight; a failure shows the host's reason plus Retry.
92
92
  3. **Polish works**: press the main key. The draft is replaced on success; on failure it is untouched and the button turns into an error state whose tooltip carries the reason.
93
- 4. **The settings card renders**: "Template library" appears on the settings page, edits stage locally and take effect after **Save**.
93
+ 4. **The settings card renders**: the "Role library" section appears on the settings page, edits stage locally and take effect after **Save**.
94
94
 
95
95
  ## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> What it does not provide
96
96
 
@@ -100,7 +100,7 @@ Worth knowing before you look for them:
100
100
  - **It opens no HTTP route of its own.** The data plane is the official Typert Remote namespace `dirPrepOrganize`, registered through an injected child fiber, reached through the host `/api` gateway. Authentication, Host/DNS-rebinding/Origin checks, the signed browser-session cookie and body limits are all the gateway's - this package keeps no CSRF token and no route table.
101
101
  - **It adds no CLI subcommand.**
102
102
  - **It reads no environment variable** and makes no outbound request of its own.
103
- - What it *does* consume: the host `settings` service (hard-injected), `llm.stream`, `agentDefaultModel`, and the session/filesystem services. Without `settings` the card is disabled with a warning and the dropdown falls back to the built-in curated set.
103
+ - What it *does* consume: the host `settings` service (hard-injected, so the entry does not activate without it), `llm.stream`, `agentDefaultModel`, and the session/agent/filesystem services. When the settings form itself is not ready, the card renders disabled with a status hint while the dropdown falls back to the built-in curated set.
104
104
 
105
105
  ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Enabling it in dsh
106
106
 
@@ -111,18 +111,20 @@ Worth knowing before you look for them:
111
111
  - The settings namespace and `configForms.get()` stay the **bare entry id** `dir-prep-organize` - deliberately not the same identifier as that slot key.
112
112
  - The client half is `dsh.client.platform = web` with `immediately`.
113
113
  - The card follows the official locale plugin's preference for its own labels and copy; the host half reads the preference per request, so switching language needs no restart.
114
+ - The plugin page reads its title, description and detail document from `locale/<lang>.json` (`meta.title`, `meta.description`, `meta.detail`). `docs/DETAIL.md` and `docs/DETAIL.zh.md` ship in the tarball; without `meta.detail` the host falls back to the README.
114
115
 
115
116
  ## <img src="https://api.iconify.design/lucide/sparkles.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> The polish call
116
117
 
117
118
  | Aspect | Fact |
118
119
  |---|---|
119
120
  | Transport | Host `llm.stream`: one **request-only** user text message (no `id`, no `source`) plus a `system` rule block |
120
- | Model | `agentDefaultModel.currentSelection()` - provider / model / reasoningEffort. Its absence reports "No model selection is available" |
121
+ | Model | The live agent's current selection first - `agent.model.current()` on current hosts, `agent.options` on older ones - then `agentDefaultModel.currentSelection()`. Its absence reports "No model selection is available" |
122
+ | Draft guard | The rewrite is written back only if the session id, input action face, draft revision and input phase (`plain`) are unchanged. Otherwise the call reports "The input box changed; the polished text was not applied" and leaves the draft alone |
121
123
  | Role style | An optional `roleText` injected into the user message's `<data>` fence (never into the system block - see the trust-order note above `buildOrganizeSystem`). It borrows terminology and tone only; it never executes the role's tasks |
122
124
  | Finish reason | Anything other than `stop` - including a missing finish chunk - **fails** and never writes back to the draft |
123
125
  | Timeout | `organizeTimeoutMs`, default 120000 ms, read per request via `.get()`. The client fetch timeout is that value + 5000 ms |
124
- | Input caps | `maxSnippetBytes` (262144 = 256 KiB) per key file, `readConcurrency` (8) for reads. Directory, conversation and role text are **never truncated** |
125
- | No truncation, on purpose | A model context-overflow error is the feedback, and the user slims the input. A payload above the endpoint body cap gets a 413 instead |
126
+ | Input caps | `maxSnippetBytes` (262144 = 256 KiB) per key file, a 2 MiB total snippet budget, and `readConcurrency` (8) for reads. A file over the per-file cap, or a snippet past the total budget, is skipped whole and counted in `skipped.tooLarge`. Directory listings, conversation text and role bodies are **never truncated** |
127
+ | No truncation, on purpose | Directory listings, conversation text and role bodies go in whole: a model context-overflow error is the feedback, and the user slims the input. A payload above the endpoint body cap gets a 413 instead |
126
128
 
127
129
  ## <img src="https://api.iconify.design/lucide/layout-template.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Templates
128
130
 
@@ -131,6 +133,7 @@ Worth knowing before you look for them:
131
133
  | Entry shape | `{ id, name, description, text, group, emoji }`, all strings. `description` / `group` / `emoji` default to empty strings |
132
134
  | Validation on save | Entries with an empty `name` or `text` are dropped; `emoji` is cut to 12 characters; a missing or colliding `id` is deterministically replaced by `tpl-<index>` |
133
135
  | Built-in set | 85 curated templates generated from the `agents/` role library. The dropdown falls back to them when `templates` is unset |
136
+ | Insertion | Uses the input box's version-checked insert face (`captureInsertion()` + `insertText()`). Text goes in at the caret, quoted blocks and attachments stay intact, and a stale insertion inserts nothing |
134
137
  | "Unset" is an empty array | Under implicit registration schemastery casts a missing array field to `[]`, so **an empty list always means "fall back to built-in"**. Only a non-empty array whose items are all invalid renders as an empty list |
135
138
  | Restore defaults | Unsets `templates` back to the curated set and leaves `importAllowRoots` untouched. Two-step confirm; the second click must come within 4 seconds |
136
139
  | Import | By path: a local `.md` file or a directory. `path` exactly empty imports the whole built-in library. A role file whose code fence never closes is rejected instead of silently importing half its body |
@@ -143,7 +146,7 @@ Namespace `dir-prep-organize` equals the settings entry id. Fields projected int
143
146
  |---|---|---|---|---|
144
147
  | `templates` | `{id,name,description,text,group,emoji}[]` | unset | **yes** | The user's own templates. Unset falls back to the 85 built-in entries |
145
148
  | `importAllowRoots` | `string[]` | `[]` | **yes** | Extra allowed roots for the import endpoint. Non-strings and whitespace-only items are dropped; duplicates removed. With nothing registered, only the session cwd and the built-in role library are allowed |
146
- | `organizeTimeoutMs` | natural, volatile | `120000` | **no** | The LLM abort deadline in ms. Positive values are truncated and clamped to `[1, 2147483647]`; non-finite or ≤0 values fall back to `120000` instead of becoming an instant timeout. Past 2^31-1 Node's `setTimeout` prints a `TimeoutOverflowWarning` and silently uses **1 ms**, which turns "raise the timeout" into "fail instantly". The card has no control, so changing it means `settings.yaml` or the row's `config:` |
149
+ | `organizeTimeoutMs` | natural, volatile | `120000` | **no** | The LLM abort deadline in ms. Values are truncated and clamped to `[1, 2147483647]`; non-finite values fall back to `120000`. `0` passes the schema and clamps to 1 ms, so it really does mean an immediate timeout. Past 2^31-1 Node's `setTimeout` prints a `TimeoutOverflowWarning` and silently uses **1 ms**, which turns "raise the timeout" into "fail instantly". The card has no control, so changing it means `settings.yaml` or the row's `config:` |
147
150
  | `maxSnippetBytes` | natural, non-volatile | `262144` | **no** | Per-file cap for key-file snippets; a larger file, or one whose size is unknown, is skipped whole and counted in `skipped.tooLarge`. Import candidates use the same cap. Non-volatile means no form projection, hence no card row - deployment value only |
148
151
  | `readConcurrency` | natural, non-volatile | `8` | **no** | Bounded read concurrency for snippets and directory imports. Clamped to `[1, 64]`: `0` or a negative value made the bounded map recurse forever until the host was killed by the OOM killer, and a huge value defeats the fd ceiling this field exists to hold |
149
152
 
@@ -162,6 +165,7 @@ Official Typert Remote namespace **`dirPrepOrganize`**, registered through an in
162
165
  | `importTemplates` | `{ path, sessionId }` (`path` exactly empty = whole built-in library) | `ok` / `count` / `truncated` / `skipped` / `entries` |
163
166
 
164
167
  - Business failures stay `ok:false` with `error`. The import path-policy branches are the exception: an out-of-bounds path or a malformed `path` field also carries `status` 403 or 400.
168
+ - `model` is the preflight read of the default selection; `organize` prefers the live agent's selection as described under "The polish call".
165
169
  - Result parsing on the client keeps defensive defaults: a non-object payload or a missing `ok:true` becomes a **visible error**, never an empty list.
166
170
 
167
171
  ## <img src="https://api.iconify.design/lucide/lock.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> Data and privacy
@@ -173,7 +177,7 @@ Official Typert Remote namespace **`dirPrepOrganize`**, registered through an in
173
177
  | What one polish call sends | The full draft, the session cwd path, top-level directory entries **with the full text of key text files**, the real user/assistant turns (framework-injected messages and tool results are filtered out), and the optional role body |
174
178
  | Which files get a snippet | Only 20 code/document extensions (ts/tsx/js/jsx/mjs/cjs/py/rs/go/java/rb/json/toml/md/sql/graphql/proto/css/scss/less). `yaml` / `env` are **not** whitelisted |
175
179
  | Sensitive file names | Any file whose name matches `credentials` / `secret(s)` / `id_rsa` / `pem` / `p12` / `pfx` / `keystore` / `env` / `key(s)` / `token(s)` / `auth` / `passwd` / `password` / `account(s)` **at a separator boundary** never gets a snippet. The boundary is deliberate: a naive substring match would drop `monkey.js` and `AUTHORS.md`, while a miss would send credential text to a third-party model |
176
- | Caps and concurrency | A single file over `maxSnippetBytes`, or with unknown size, is skipped whole - never half-summarized. Reads run with `readConcurrency` |
180
+ | Caps and concurrency | A single file over `maxSnippetBytes`, or with unknown size, is skipped whole - never half-summarized. Collected snippets share a 2 MiB budget; once it is exhausted the rest are skipped whole and counted in `skipped.tooLarge`. Reads run with `readConcurrency` |
177
181
  | Counters | Too-large / unreadable / deeper-level / non-role cases are counted in `skipped`, shown in the UI, and reflected honestly by `truncated` |
178
182
  | Import endpoint | **Read-only**: no model call, no disk writes. Absolute paths are refused by default; only paths inside the session cwd, the package's `agents/` and `importAllowRoots` pass. `.` / `..` / hidden segments (such as `.ssh`) are always rejected, and an out-of-bounds path answers 403 echoing the resolved path |
179
183
 
@@ -181,18 +185,18 @@ Official Typert Remote namespace **`dirPrepOrganize`**, registered through an in
181
185
 
182
186
  Registered honestly, one entry per class.
183
187
 
184
- - **Nothing is truncated for you.** Directory listings, conversation text and role bodies go in whole. A context overflow is the model's error to report and yours to slim - this plugin will not silently drop half your draft.
188
+ - **Nothing is truncated for you.** Directory listings, conversation text and role bodies go in whole. Snippets are omitted whole rather than shortened: one over the per-file cap or past the 2 MiB total budget is counted and left out. A context overflow is the model's error to report and yours to slim - this plugin will not silently drop half your draft.
185
189
  - **The import card has no session context.** Its POST sends `sessionId` as an empty string, so an import must live inside the built-in `agents/` or a registered root, and must contain no `.` / `..` / hidden segments. The rejection names the allowed zones and echoes the resolved path.
186
190
  - **Directory import reaches two levels.** The top level plus one sub-directory level; a third level is only **counted** as `deeper`, never imported.
187
191
  - **A file whose name cannot be parsed from the first 20 frontmatter lines counts as `unnamed`** and is skipped rather than guessed.
188
192
  - **Machine translation does not exist here.** The `agents/` role library and template bodies are user data; they are never translated, whichever interface language is active.
189
- - **The polish path is best-effort about the model's answer.** A non-`stop` finish reason fails the whole call; a model that returns prose instead of a rewrite replaces your draft with that prose.
193
+ - **The polish path is best-effort about the model's answer.** A non-`stop` finish reason fails the whole call; a model that returns prose instead of a rewrite replaces your draft with that prose, unless the draft or input phase changed meanwhile and the write-back is refused.
190
194
 
191
195
  ## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> FAQ
192
196
 
193
197
  | Symptom | What happens |
194
198
  |---|---|
195
- | Nothing changed after pressing "Polish" | Failures never touch the draft; the button shows an error state for a few seconds with the reason in its tooltip. Usual causes: no session cwd (`sessionId` missing or session unknown), no model selection, a finish reason other than `stop`, or the `organizeTimeoutMs` deadline |
199
+ | Nothing changed after pressing "Polish" | Failures never touch the draft; the button shows an error state for a few seconds with the reason in its tooltip. Usual causes: no session cwd (`sessionId` missing or session unknown), no model selection, a finish reason other than `stop`, the `organizeTimeoutMs` deadline, or the draft/selection changing while the request was in flight (the result is discarded) |
196
200
  | The model reports a context overflow | Working as designed: input is deliberately not truncated, so the model error is the feedback. A payload above the endpoint body cap gets 413 instead |
197
201
  | Importing local roles was refused | Absolute paths are refused by default and the card has no session context. The path must live inside the built-in `agents/` or a registered directory and contain no `.` / `..` / hidden segments |
198
202
  | Fewer entries imported than expected | Read the four `skipped` counters: `deeper` (third level, counted only), `tooLarge` (over `maxSnippetBytes`), `unnamed` (no name in the first 20 frontmatter lines), `unreadable` (read failure) |
package/README.zh-CN.md CHANGED
@@ -4,11 +4,11 @@
4
4
 
5
5
  <h1 align="center">dsh-dir-prep-organize</h1>
6
6
 
7
- <p align="center"><em>dsh 输入框旁的两个按钮:看着当前目录把草稿重写一遍,或者把一份角色模板放进草稿。</em></p>
7
+ <p align="center"><em>dsh 输入框旁的两个按钮:看着当前目录把草稿重写一遍,或者把一份角色模板插到光标处。</em></p>
8
8
 
9
9
  <p align="center">
10
10
  <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/v/@jayyuen66/dsh-dir-prep-organize?style=flat-square&logo=npm&logoColor=white" alt="npm version" /></a>
11
- <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/dm/@jayyuen66/dsh-dir-prep-organize?style=flat-square" alt="npm downloads" /></a>
11
+ <a href="https://www.npmjs.com/package/@jayyuen66/dsh-dir-prep-organize"><img src="https://img.shields.io/npm/d18m/@jayyuen66/dsh-dir-prep-organize?style=flat-square" alt="npm downloads (18 months)" /></a>
12
12
  <a href="https://github.com/JayYuen666/dsh-dir-prep-organize/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/JayYuen666/dsh-dir-prep-organize/ci.yml?branch=main&style=flat-square&label=ci" alt="ci" /></a>
13
13
  <img src="https://img.shields.io/badge/license-MIT-4c1?style=flat-square" alt="MIT" />
14
14
  <img src="https://img.shields.io/badge/node-%3E%3D22.12-4c1?style=flat-square&logo=nodedotjs&logoColor=white" alt="node" />
@@ -27,7 +27,7 @@
27
27
  <a href="./README.md"><img src="https://img.shields.io/badge/lang-English-658EFF?style=flat-square" alt="English" /></a>
28
28
  </p>
29
29
 
30
- **一个 [dsh](https://github.com/deepseek-ai/deepseek-harness) 插件:一个可拆分「润色」按钮——把草稿、会话目录顶层与最近的真实对话交给当前默认模型重写;外加一个角色模板下拉。零模型工具、零自建 HTTP 路由。**
30
+ **一个 [dsh](https://github.com/deepseek-ai/deepseek-harness) 插件:一个可拆分「润色」按钮——把草稿、会话目录顶层与最近的真实对话交给当前会话选定的模型(取不到时回落宿主默认模型)重写;外加一个角色模板下拉。零模型工具、零自建 HTTP 路由。**
31
31
 
32
32
  ## <img src="https://api.iconify.design/lucide/file-text.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 目录
33
33
 
@@ -51,14 +51,14 @@
51
51
  - 在 web 输入框右侧加**两个控件**:一个可拆分的「润色」按钮(主键 + ▾),一个「模板」下拉。
52
52
  - 主键直接润色;▾ 键提供「以某个角色的风格润色」。
53
53
  - 下拉按条目的 `group` 字段分组,`group` 为空的条目落在「通用」里。
54
- - **润色**会把草稿、会话 cwd 的顶层(文件名、大小、关键文本文件的全文)以及会话里**真实的** user/assistant 轮次交给当前默认模型,然后用重写结果替换草稿。
54
+ - **润色**会把草稿、会话 cwd 的顶层(文件名、大小、关键文本文件的全文)以及会话里**真实的** user/assistant 轮次交给当前会话选定的模型(取不到时回落宿主默认模型),然后用重写结果替换草稿。只有会话、草稿版本与输入阶段都没变时才写回。
55
55
  - 失败时草稿**绝不**被改动:按钮进入错误态若干秒,原因写在其 tooltip 里。
56
- - **模板**会把文本插进草稿:草稿为空时整份填入,否则空一行后追加。
56
+ - **模板**经输入框的插入面写到光标处:引用块与附件保持原样;插入凭据过期时宿主拒绝插入,而不是重建整份草稿。输入框处于提交期时两个控件禁用。
57
57
  - 内置集是 **85 条精选角色模板**,由 `scripts/gen-defaults.mjs` 从本包的 `agents/` 角色库生成——那是从上游项目移入的几百份角色 `.md`,分布在二十多个部门目录下。对用户有意义的是那 85 条;角色库的份数不在这里钉死,因为上游一刷新它就变。
58
58
  - 这张表**只在宿主侧**:客户端产物不再内联它。生成文件约 640 KB,曾把 `client.js` 推到约 711 KB。
59
59
  - 浏览器**懒加载、只调一次** Remote 的 `defaults` 方法(首次打开菜单或首次进设置卡),之后在进程内复用。用户已经有自己的模板时**一个字节都不拉**。
60
60
  - 数据还没到时菜单显示一行 loading,而不是「没有模板」那句提示;失败时把宿主自己的原因和「重试」按钮一起显示出来。
61
- - **「模板库」**设置卡覆盖:逐条增/改/删、两步恢复默认、一键导入整套内置库、按路径导入本地 `.md` 或目录、登记额外的允许导入目录。这张卡是**一份列表同时喂两处**——输入框「模板」下拉,与「润色」▾ 的角色菜单。
61
+ - 设置卡的**「角色库」**小节覆盖:逐条增/改/删、两步恢复默认、一键导入整套内置库、按路径导入本地 `.md` 或目录、登记额外的允许导入目录。这个小节是**一份列表同时喂两处**——输入框「模板」下拉,与「润色」▾ 的角色菜单。
62
62
  - 模板与允许目录都经宿主设置读写,**零 LLM 调用**,且**不注册任何模型工具**。
63
63
 
64
64
  ## <img src="https://api.iconify.design/lucide/package.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 安装
@@ -70,12 +70,12 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
70
70
  卸载:`dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`。包在公共 npm 上,安装不需要凭据,也不需要配作用域源。
71
71
 
72
72
  - **要求 Node.js `>= 22.12`。** 本包是纯 ESM。用**具名**导出(`import { apply } from "@jayyuen66/dsh-dir-prep-organize"`);**没有 default 导出**,所以 `import pkg from …` 会报 `does not provide an export named 'default'`。正是这个 Node 下限让 ESM 入口的 `require()` 形式可用,所以声明了 `engines.node`。
73
- - **要求宿主 `dsh` 在 `0.2.1-rc.3` 这条线上。** 宿主真正读的是 `engines.dsh`(`^0.2.1-rc.3`),而且它**单独决定**:`evaluatePluginCompatibility` 在 `engines.dsh` 那一支就返回了,根本走不到读 `peerDependencies` 的那段。对宿主真实代码实测:`0.2.0-rc.2` **被拒**,`0.2.1-rc.3` 与 `0.2.2` 通过,`0.3.0` 被拒。被拒的宿主需要走显式担责的授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`。
74
- - **`@deepseek-ai/dsh-*` 的钉版保持在 `0.2.1-rc.3`**——本包编译与测试所对着的那一版。`engines.dsh` 那个范围是关于「能在哪些**宿主**上跑」的声明;钉版是关于「它是对着哪个宿主版本**编译**的」的事实。把两者混为一谈,正是发布门禁分开检查它们的原因。
73
+ - **要求宿主 `dsh` 在 `0.2.1-rc.3` 这条线上。** 宿主真正读的是 `engines.dsh`(`^0.2.1-rc.3`),而且它**单独决定**:`evaluatePluginCompatibility` 在 `engines.dsh` 那一支就返回了,根本走不到读 `peerDependencies` 的那段。对宿主真实代码实测:`0.2.0-rc.2` **被拒**,`0.2.1-rc.3` 与 `0.2.2` 通过,`0.3.0` 被拒。被拒的宿主需要走显式担责的授权 `dsh plugin --profile <p> allow-version <pkg>@<ver> --dsh-version <exact> --accept-risk`。支持窗口是滚动的:本包在发布时最近的三个已发布宿主版本上逐版取证,窗口滚动后重新取证,不把这一句里的版本号当长期承诺。
74
+ - **`@deepseek-ai/dsh-*` 的开发依赖钉在 `0.2.2-alpha.2`**——本包编译与测试所对着的那条宿主线。`engines.dsh` 与 optional peer 范围承载单独判读的支持窗口(`^0.2.1-rc.3`);钉版是关于「它是对着哪个宿主版本**编译**的」的事实,不是那个窗口的复述。把两者混为一谈,正是发布门禁分开检查它们的原因。
75
75
  - **`dependencies` 里不放任何 `@deepseek-ai/*`,这是契约**(`test/publish-manifest.test.ts` 钉着)。消费方 profile 用 `nodeLinker: hoisted` 且 `autoInstallPeers: false` 安装,于是写在 `dependencies` 里的宿主包会被落成**真实目录**,与运行中的宿主已加载的那份并存。`@deepseek-ai/dsh-tools` 的工具运行期调度键是普通 `Symbol`(不是 `Symbol.for`),符号身份按模块实例算:宿主从 profile 副本上读那个键拿到 `undefined`,于是**每一次原生工具调用都抛**——而本包的构建、类型检查、覆盖率门禁在此之前全部照绿。
76
76
  - **`host.js` 按值导入的那两枚宿主包是必需 peer**:`@deepseek-ai/schemastery`(宿主 fork——只有它能把 `.volatile()` 字段解析成活引用)与 `@deepseek-ai/dsh-brand`。`build-host.mjs` 外部化 `dependencies` **与** `peerDependencies`,所以裸说明符留在产物里;只写 `devDependencies` 会让打包器把官方函数体内联进去。`test/build-host.test.ts` 同时钉「说明符在」与「函数体不在」。
77
77
  - **声明里点到的每一枚宿主包都落在 `peerDependencies`**,凡是只能从那里到达的都是 *optional*(`@deepseek-ai/cordis`、`cosmokit`,以及 `dsh-agent-default-model` / client-ui / `fs` / `llm` / `session` 那一族)。声明它们不是仪式:pnpm 严格布局下,`types/host.d.ts` 里一枚没有被任何 manifest 表点名的裸说明符在消费方侧解析不到,而本仓自己的类型检查照样绿。那条清单由测试从 `types/**/*.d.ts` 现量读,不从这段文字读,所以两边不会漂移。
78
- - **随包发的东西**:`host.js`、`client.js`、`templates.data.mjs`、`types/`、`cordis.patch.yml`、`agents/` 与 `THIRD_PARTY_NOTICES.md`。`package.json`、`README*` 与 `LICENSE` 由发布器无条件附带。
78
+ - **随包发的东西**:`host.js`、`client.js`、`templates.data.mjs`、`types/`、`cordis.patch.yml`、`agents/`、`locale/`、`docs/` 与 `THIRD_PARTY_NOTICES.md`。`package.json`、`README*` 与 `LICENSE` 由发布器无条件附带。
79
79
  - **内置表单独一个产物、首次使用时才加载**,不是插件装载时加载。它以前被打进 `host.js`,于是每个用户即使从不开那个下拉,也要在内存里付一份模板的代价。
80
80
  - **`agents/` 不是本仓写的**:来自 [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh)(MIT)。版权与许可声明随包发在 `THIRD_PARTY_NOTICES.md` 里,因为 MIT 要求它出现在每一份分发副本中。**不要手改 `agents/` 下的任何文件。**
81
81
 
@@ -90,7 +90,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
90
90
  - 层行可能是 `# == <层>`,也可能是 `# == <层>, patched by <路径>`;两种都得认。
91
91
  2. **下拉能填出来**:打开「模板」,内置列表经 Remote 的 `defaults` 方法到达。一行 loading 表示还在路上;失败会显示宿主的原因加「重试」。
92
92
  3. **润色能用**:按主键。成功即替换草稿;失败则草稿不动,按钮进入错误态,原因在 tooltip 里。
93
- 4. **设置卡渲染出来**:「模板库」出现在设置页,改动先进草稿,点**保存**后生效。
93
+ 4. **设置卡渲染出来**:「角色库」小节出现在设置页,改动先进草稿,点**保存**后生效。
94
94
 
95
95
  ## <img src="https://api.iconify.design/lucide/circle-slash.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 它不提供什么
96
96
 
@@ -100,7 +100,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
100
100
  - **它没有自建的 HTTP 路由。** 数据面是官方 Typert Remote 命名空间 `dirPrepOrganize`,经注入的子 fiber 注册,走宿主 `/api` 网关。认证、Host/DNS 重绑定/Origin 判据、签名浏览器会话 cookie、body 上限全归网关——本包不持有 CSRF token,也没有路由表。
101
101
  - **它不加 CLI 子命令。**
102
102
  - **它不读任何环境变量**,也没有自己的出站请求。
103
- - 它**确实**消费的东西:宿主 `settings` 服务(硬注入)、`llm.stream`、`agentDefaultModel`,以及会话与文件系统服务。缺 `settings` 时设置卡禁用并告警,下拉回落到内置精选集。
103
+ - 它**确实**消费的东西:宿主 `settings` 服务(硬注入,缺它条目根本不激活)、`llm.stream`、`agentDefaultModel`,以及会话、Agent 与文件系统服务。设置表单本身没就绪时,卡片禁用并显示状态提示,下拉回落到内置精选集。
104
104
 
105
105
  ## <img src="https://api.iconify.design/lucide/plug.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 在 dsh 里启用
106
106
 
@@ -111,18 +111,20 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
111
111
  - 设置命名空间与 `configForms.get()` 仍是**裸条目 id** `dir-prep-organize`——与那个槽位 key 刻意不是同一个标识。
112
112
  - 客户端半是 `dsh.client.platform = web` 且带 `immediately`。
113
113
  - 卡片的文案遵循官方 locale 插件的偏好;宿主半每次请求现读该偏好,所以切语言不必重启。
114
+ - 插件页的标题、说明与详情文档来自 `locale/<语言>.json`(`meta.title`、`meta.description`、`meta.detail`)。`docs/DETAIL.md` 与 `docs/DETAIL.zh.md` 随包发布;没有声明 `meta.detail` 时宿主才回落到 README。
114
115
 
115
116
  ## <img src="https://api.iconify.design/lucide/sparkles.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 润色调用
116
117
 
117
118
  | 面 | 事实 |
118
119
  |---|---|
119
120
  | 传输 | 宿主 `llm.stream`:一条**仅请求态**的 user 文本消息(无 `id`、无 `source`)加一段 `system` 规则块 |
120
- | 模型 | `agentDefaultModel.currentSelection()`——provider / model / reasoningEffort。取不到时回报 "No model selection is available" |
121
+ | 模型 | 先取会话活 Agent 的当前选择——新宿主读 `agent.model.current()`,旧宿主回落 `agent.options`——再回落 `agentDefaultModel.currentSelection()`。取不到时回报 "No model selection is available" |
122
+ | 写回闸门 | 只有会话 id、输入动作面身份、草稿版本与输入阶段(`plain`)都没变时才写回。否则回报「输入框内容已变化,润色结果未写回」,草稿保持原样 |
121
123
  | 角色风格 | 可选的 `roleText` 注入 user 消息的 `<data>` 围栏(不进 system——见 `buildOrganizeSystem` 的信任序注释)。它只借用术语与语气,**从不执行该角色的任务** |
122
124
  | finish reason | 除 `stop` 之外(含缺 finish 块)一律**失败**,且绝不写回草稿 |
123
125
  | 超时 | `organizeTimeoutMs`,默认 120000 ms,每次请求经 `.get()` 读。客户端 fetch 超时是它 + 5000 ms |
124
- | 输入上限 | `maxSnippetBytes`(262144 = 256 KiB)按关键文件、`readConcurrency`(8)按读并发。目录、对话与角色正文**从不截断** |
125
- | 为什么刻意不截断 | 模型报上下文溢出就是反馈,由用户自己收窄输入。载荷超过端点 body 上限则得到 413 |
126
+ | 输入上限 | `maxSnippetBytes`(262144 = 256 KiB)按关键文件、摘要总量 2 MiB、`readConcurrency`(8)按读并发。超过单文件上限、或超出总量预算的摘要整份跳过并计入 `skipped.tooLarge`。目录、对话与角色正文**从不截断** |
127
+ | 为什么刻意不截断 | 目录、对话与角色正文都整份进去:模型报上下文溢出就是反馈,由用户自己收窄输入。载荷超过端点 body 上限则得到 413 |
126
128
 
127
129
  ## <img src="https://api.iconify.design/lucide/layout-template.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 模板
128
130
 
@@ -131,6 +133,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
131
133
  | 条目形状 | `{ id, name, description, text, group, emoji }`,全部字符串。`description` / `group` / `emoji` 默认空串 |
132
134
  | 保存时校验 | `name` 或 `text` 为空的条目被丢掉;`emoji` 截到 12 字符;缺失或撞车的 `id` 确定性地替换成 `tpl-<index>` |
133
135
  | 内置集 | 从 `agents/` 角色库生成的 85 条精选模板。`templates` 未设置时下拉回落到它们 |
136
+ | 插入 | 走输入框的版本校验插入面(`captureInsertion()` + `insertText()`)。文本写到光标处,引用块与附件保持原样;凭据过期时什么都不插入 |
134
137
  | 「未设置」= 空数组 | 隐式注册下 schemastery 会把缺失的数组字段 cast 成 `[]`,所以**空列表永远意味着「回落到内置」**。只有非空数组且条目全部非法,才渲染成空列表 |
135
138
  | 恢复默认 | 把 `templates` 退回精选集,`importAllowRoots` 不动。两步确认,第二次点击须在 4 秒内 |
136
139
  | 导入 | 按路径:本地 `.md` 文件或目录。`path` 恰为空串 = 导入整套内置库。角色文件的代码围栏没有结束标记时直接拒绝,不会静默只导入半篇正文 |
@@ -143,7 +146,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
143
146
  |---|---|---|---|---|
144
147
  | `templates` | `{id,name,description,text,group,emoji}[]` | 未设置 | **有** | 用户自己的模板。未设置时回落到 85 条内置 |
145
148
  | `importAllowRoots` | `string[]` | `[]` | **有** | 导入端点的额外允许根,逐个目录登记;非字符串与纯空白项丢弃,重复项去重。一个都没登记时只允许会话 cwd 与内置角色库 |
146
- | `organizeTimeoutMs` | natural,volatile | `120000` | **无** | LLM 中止时限(毫秒)。正数先取整再夹到 `[1, 2147483647]`;非有限数与 ≤0 回落到 `120000`,不会变成"立刻超时"。超过 2^31-1 时 Node 的 `setTimeout` 会打 `TimeoutOverflowWarning` 并静默用 **1 ms**,于是"调大超时"变成"立刻失败"。卡上没有控件,改它只能经 `settings.yaml` 或该行的 `config:` |
149
+ | `organizeTimeoutMs` | natural,volatile | `120000` | **无** | LLM 中止时限(毫秒)。取值先取整再夹到 `[1, 2147483647]`;非有限数回落到 `120000`。`0` 能过 schema,夹完是 1 ms,所以它确实表示"立刻超时"。超过 2^31-1 时 Node 的 `setTimeout` 会打 `TimeoutOverflowWarning` 并静默用 **1 ms**,于是"调大超时"变成"立刻失败"。卡上没有控件,改它只能经 `settings.yaml` 或该行的 `config:` |
147
150
  | `maxSnippetBytes` | natural,非 volatile | `262144` | **无** | 关键文件摘要的单文件上限;超过、或大小未知的文件整份跳过并计入 `skipped.tooLarge`。导入候选用同一个上限。非 volatile 意味着不进表单快照,所以也没有卡上的行——纯部署值 |
148
151
  | `readConcurrency` | natural,非 volatile | `8` | **无** | 摘要与目录导入的有界读并发。夹在 `[1, 64]`:`0` 或负数会让那套有界 map 自我递归直到宿主被 OOM killer 杀掉,而过大的值直接废掉这个字段存在的意义(fd 上限) |
149
152
 
@@ -162,6 +165,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
162
165
  | `importTemplates` | `{ path, sessionId }`(`path` 恰为空串 = 整套内置库) | `ok` / `count` / `truncated` / `skipped` / `entries` |
163
166
 
164
167
  - 业务失败一律 `ok:false` 带 `error`。导入路径策略那几支是例外:越界路径或形状不对的 `path` 还会额外带 `status` 403 或 400。
168
+ - `model` 只是对默认选择的预检;`organize` 优先用会话活 Agent 的选择,见「润色调用」。
165
169
  - 客户端解析结果保留防御性默认:非对象载荷、或缺 `ok:true`,都变成**可见的错误**,绝不变成空列表。
166
170
 
167
171
  ## <img src="https://api.iconify.design/lucide/lock.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 数据与隐私
@@ -173,7 +177,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
173
177
  | 一次润色发出去什么 | 完整草稿、会话 cwd 路径、顶层目录条目**连同关键文本文件的全文**、真实的 user/assistant 轮次(框架注入的消息与工具结果被滤掉),以及可选的角色正文 |
174
178
  | 哪些文件会取摘要 | 只有 20 种代码/文档扩展名(ts/tsx/js/jsx/mjs/cjs/py/rs/go/java/rb/json/toml/md/sql/graphql/proto/css/scss/less)。`yaml` / `env` **不在**白名单 |
175
179
  | 敏感文件名 | 名字在**分隔符边界**上命中 `credentials` / `secret(s)` / `id_rsa` / `pem` / `p12` / `pfx` / `keystore` / `env` / `key(s)` / `token(s)` / `auth` / `passwd` / `password` / `account(s)` 的文件,永不取摘要。边界是刻意的:朴素子串匹配会误杀 `monkey.js` 与 `AUTHORS.md`,而漏匹配会把凭据全文发给第三方模型 |
176
- | 上限与并发 | 单个文件超过 `maxSnippetBytes`、或大小未知,整份跳过——绝不半份摘要。读按 `readConcurrency` 跑 |
180
+ | 上限与并发 | 单个文件超过 `maxSnippetBytes`、或大小未知,整份跳过——绝不半份摘要。收集到的摘要共享 2 MiB 总量预算;用完之后其余整份跳过并计入 `skipped.tooLarge`。读按 `readConcurrency` 跑 |
177
181
  | 计数器 | 过大 / 读不出 / 更深层 / 非角色这几类计入 `skipped`,在 UI 里显示,并由 `truncated` 如实反映 |
178
182
  | 导入端点 | **只读**:不调模型、不写盘。绝对路径默认拒绝;只有会话 cwd、本包的 `agents/` 与 `importAllowRoots` 之内通过。`.` / `..` / 隐藏段(如 `.ssh`)一律拒绝,越界路径回 403 并回显解析后的路径 |
179
183
 
@@ -181,18 +185,18 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
181
185
 
182
186
  按类登记,每类一条。
183
187
 
184
- - **没有任何东西替你截断。** 目录列表、对话文本与角色正文都是整份进去的。上下文溢出是模型的报错,也是你收窄输入的依据——本插件不会静默丢掉你半份草稿。
188
+ - **没有任何东西替你截断。** 目录列表、对话文本与角色正文都是整份进去的。摘要则是整份略去而不是缩短:超过单文件上限、或超出 2 MiB 总量预算的,会记进计数并整条不放。上下文溢出是模型的报错,也是你收窄输入的依据——本插件不会静默丢掉你半份草稿。
185
189
  - **导入卡没有会话上下文。** 它的 POST 把 `sessionId` 发成空串,所以导入目标必须在内置 `agents/` 或某个已登记的根之内,且不含 `.` / `..` / 隐藏段。拒绝时会点名允许区并回显解析后的路径。
186
190
  - **目录导入只到两层。** 顶层加一层子目录;第三层只被**计数**为 `deeper`,永不导入。
187
191
  - **前 20 行 frontmatter 里解析不出名字的文件计为 `unnamed`**,跳过而不是猜。
188
192
  - **这里没有机器翻译。** `agents/` 角色库与模板正文是用户数据,无论界面语言如何,永不被翻译。
189
- - **润色对模型回答只能尽力而为。** finish reason 不是 `stop` 就整趟失败;而模型若返回散文而不是重写结果,草稿就被那段散文替换掉。
193
+ - **润色对模型回答只能尽力而为。** finish reason 不是 `stop` 就整趟失败;而模型若返回散文而不是重写结果,草稿就被那段散文替换掉——除非草稿或输入阶段在途中变了,这次写回会被拒绝。
190
194
 
191
195
  ## <img src="https://api.iconify.design/lucide/circle-help.svg?color=%23658EFF&height=22" height="22" width="22" align="absmiddle" alt="" /> 常见问题
192
196
 
193
197
  | 症状 | 怎么回事 |
194
198
  |---|---|
195
- | 按了「润色」什么都没变 | 失败从不碰草稿;按钮进入错误态若干秒,原因在 tooltip 里。常见成因:没有会话 cwd(`sessionId` 缺失或会话未知)、没有模型选择、finish reason 不是 `stop`、或撞上 `organizeTimeoutMs` 时限 |
199
+ | 按了「润色」什么都没变 | 失败从不碰草稿;按钮进入错误态若干秒,原因在 tooltip 里。常见成因:没有会话 cwd(`sessionId` 缺失或会话未知)、没有模型选择、finish reason 不是 `stop`、撞上 `organizeTimeoutMs` 时限,或请求途中草稿/模型选择变了(结果被丢弃) |
196
200
  | 模型报上下文溢出 | 这是设计如此:输入刻意不截断,模型报错就是反馈。载荷超过端点 body 上限则得到 413 |
197
201
  | 导入本地角色被拒 | 绝对路径默认拒绝,而卡片没有会话上下文。路径必须在内置 `agents/` 或某个已登记目录之内,且不含 `.` / `..` / 隐藏段 |
198
202
  | 导入的条目比预期少 | 看四个 `skipped` 计数器:`deeper`(第三层,只计数)、`tooLarge`(超过 `maxSnippetBytes`)、`unnamed`(前 20 行 frontmatter 里没有名字)、`unreadable`(读失败) |
@@ -47,6 +47,8 @@ SOFTWARE.
47
47
  ## 运行期依赖
48
48
 
49
49
  运行期依赖的许可由各自包随包分发,本包不再重复其文本:`@deepseek-ai/cosmokit`、
50
- `@deepseek-ai/dsh-brand`、`@deepseek-ai/schemastery`、`@jayyuen66/dsh-plugin-shared`。
50
+ `@deepseek-ai/dsh-brand`、`@deepseek-ai/schemastery`、`@jayyuen66/dsh-plugin-shared`、`zod`。
51
+ `zod` 由设置卡的 `src/remote.ts` 以值引入(strict codec 的形状校验),client 产物按宿主
52
+ `PLATFORM_MODULES` 保持 `require("zod")` 外部化。
51
53
  其中 `@deepseek-ai/cosmokit` 仅出现在本包发布的类型声明里——schemastery 的 `Schema` 类型
52
54
  把 `Dict` 取自 cosmokit,声明文件点名它就必须让它可解析,故列为运行期依赖而非开发依赖。