@jayyuen66/dsh-dir-prep-organize 0.1.2-rc → 0.1.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 +21 -29
- package/README.zh-CN.md +24 -32
- package/client.js +423 -215
- package/cordis.patch.yml +12 -16
- package/host.js +380 -381
- package/package.json +49 -51
- package/types/host.d.ts +118 -77
- package/types/src/client-entry.d.ts +20 -7
- package/types/src/client-styles.d.ts +1 -0
- package/types/src/client-timeouts.d.ts +30 -0
- package/types/src/host-messages.d.ts +0 -2
- package/types/src/remote.d.ts +24 -0
- package/types/src/templates.d.ts +4 -4
- package/types/src/ui-messages.d.ts +5 -3
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
- "Organize" hands the draft plus the top level of the session cwd (file names, sizes, full text of key text files) plus the session's recent real turns to the current default model for a rewrite.
|
|
10
10
|
- On success the draft is replaced; on failure it stays untouched and the button shows an error state for 4 seconds (reason in its title).
|
|
11
11
|
- Picking a template inserts it into the draft: a whole fill when the draft is empty, an append after one blank line otherwise.
|
|
12
|
-
- The default list is 85 curated role templates generated by scripts/gen-defaults.mjs from this package's agents/ role library (
|
|
12
|
+
- The default list is 85 curated role templates generated by scripts/gen-defaults.mjs from this package's agents/ role library (21 department directories, 293 role .md files).
|
|
13
13
|
- That table **stays host-side only**: the client bundle no longer inlines it - the generated file is 640KB and used to push `client.js` to 711KB.
|
|
14
|
-
- The browser
|
|
14
|
+
- The browser calls the Remote `defaults` method once, lazily - on the first menu open or settings-card visit - and reuses it in-process afterwards.
|
|
15
15
|
- While it has not arrived the menus show a loading row rather than the existing "no templates" hint, and a failure surfaces the host's own reason plus a Retry button. Nothing is fetched at all when the user already has their own templates.
|
|
16
16
|
- The "Prompt templates" card on the settings page covers per-entry add/edit/delete, two-step restore of defaults, one-click import of the whole built-in library, import of a local .md or directory by path, and registration of import allowed directories.
|
|
17
17
|
- Templates and allowed directories are read and written through the host settings with zero LLM calls, and no model tool is registered.
|
|
@@ -25,7 +25,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
- Host range `>= 0.2.0-rc.2`, written to both `peerDependencies` and `engines.dsh`. Only `peerDependencies` is actually enforced: since `0.1.7-rc.1` the host evaluates it when loading plugins and disables an entry that fails (`compatibility-preflight.ts` → `deny()`), whereas `engines.dsh` has no reader at this host version.
|
|
28
|
-
- The `@deepseek-ai/dsh-*` dependencies stay pinned at `0.2.1-
|
|
28
|
+
- The `@deepseek-ai/dsh-*` dependencies stay pinned at `0.2.1-rc.2`, the version this package is built and tested against. The 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 now checks them separately.
|
|
29
29
|
- The client half is `dsh.client.platform = web` with `immediately`.
|
|
30
30
|
- The publishing form is one repository per package, `repository.url` is git+https://github.com/JayYuen666/dsh-dir-prep-organize.git ; issues go to that repository's issue tracker (`bugs`).
|
|
31
31
|
- Requires Node.js `>= 22.12`. This is an ESM-only package: use `import { apply } from "@jayyuen66/dsh-dir-prep-organize"` or `require("@jayyuen66/dsh-dir-prep-organize")`. There is **no default export** — `import pkg from …` fails with `does not provide an export named 'default'`; take the named exports instead. That Node floor is what makes `require()` of this ESM entry work at all, which is why `engines.node` is declared.
|
|
@@ -34,8 +34,8 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
34
34
|
- The built-in template table lives in 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 85 templates in memory even without opening the dropdown - `host.js` is now roughly a tenth of its former size, and the browser already fetched this data lazily anyway.
|
|
35
35
|
- `agents/` is not authored here: it comes from the upstream project [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh) (MIT). Its copyright and licence notice ship in `THIRD_PARTY_NOTICES.md`, because MIT requires it in every distributed copy.
|
|
36
36
|
- No `@deepseek-ai/*` goes in `dependencies`, and that is not a style preference. Consumers of this package are dsh plugins installed into a profile (`nodeLinker: hoisted`, `autoInstallPeers: false`), so any host package listed under `dependencies` is written into that profile as a **real directory**, coexisting with the copy the host process 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's `dsh-agent-loop` reads a `ToolRuntime` mounted from the duplicate using its own copy's symbol, gets `undefined`, and **every native tool call throws** `Cannot read properties of undefined (reading 'prepare')` — the whole profile loses its tools. This package's build, typecheck and tests all stay green right up to that point, so `test/publish-manifest.test.ts` pins the invariant in the manifest instead.
|
|
37
|
-
- The two host packages the shipped `host.js` imports as **values** are required (non-optional) `peerDependencies`: `@deepseek-ai/schemastery` (the host's fork — only it resolves 0.1.7 `.volatile()` fields into live references) and `@deepseek-ai/dsh-brand` (`0.2.1-
|
|
38
|
-
- Every host package the emitted **declarations** name is declared under `peerDependencies`, and each one reached only there is *optional*: `@deepseek-ai/cordis` (`4.0.5
|
|
37
|
+
- The two host packages the shipped `host.js` imports as **values** are required (non-optional) `peerDependencies`: `@deepseek-ai/schemastery` (the host's fork — only it resolves 0.1.7 `.volatile()` fields into live references) and `@deepseek-ai/dsh-brand` (`0.2.1-rc.2`). The host provides them at runtime and a profile installs no peers, so no duplicate appears. `build-host.mjs` externalizes `dependencies` *and* `peerDependencies`, so the bare specifiers in `host.js` stay exactly as they were — that is the ruling behind `brandString`: the peer keeps the specifier external and the official function body out of the artifact, while a `devDependencies`-only entry lets rolldown inline it (`test/build-host.test.ts` pins both "specifier present" and "function body absent").
|
|
38
|
+
- Every host package the emitted **declarations** name is declared under `peerDependencies`, and each one reached only there is *optional*: `@deepseek-ai/cordis` (`4.0.5`), `@deepseek-ai/cosmokit` (`1.8.6`, reached only through schemastery's `Dict`) and `@deepseek-ai/dsh-agent-default-model`, `-client-locale`, `-client-ui-conversation`, `-client-ui-renderer`, `-client-ui-settings`, `-client-ui-slots`, `-fs`, `-llm`, `-session` (all `0.2.1-rc.2`). 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, so the declaration entry simply would not typecheck on the consumer's side while this repository's own typecheck stays green — here both tables carry it. `test/publish-manifest.test.ts` reads that roster off `types/**/*.d.ts` rather than off this paragraph, so the two cannot drift apart. `@deepseek-ai/dsh` is the one peer nothing imports: it names the host, which is what `engines.dsh` says in words.
|
|
39
39
|
- Every peer is repeated in `devDependencies` at the same exact pin; that is what lets this repository's own typecheck, build and tests resolve them. The remaining `@deepseek-ai/*` entries here are type-only in source and leave no specifier in the declarations either, so they stay in `devDependencies` alone.
|
|
40
40
|
- What is left in `dependencies` is this package's own runtime code: `@jayyuen66/dsh-plugin-shared`.
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
43
43
|
|
|
44
44
|
- Installing the package contributes the bundle patch layer (`dsh.bundle.patch` points at `./cordis.patch.yml`), which inserts `- id: dir-prep-organize` with `name` set to the package name.
|
|
45
45
|
- Removal goes through `dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`.
|
|
46
|
-
- The host half hard-injects
|
|
46
|
+
- The host half hard-injects settings: without it the card is disabled with a warning and the "Template" dropdown falls back to the built-in curated set. The client read surface is the official Typert Remote service `dirPrepOrganize`, registered through an injected child fiber; no `webServer` dependency is involved.
|
|
47
47
|
- The client half registers slot `conversation.input.right` (organize id `dir-prep-organize` order 99, templates id `dir-prep-organize-templates` order 100) and the settings card slot `plugins.bundle.config`.
|
|
48
48
|
- The card slot key = the bundle package name `@jayyuen66/dsh-dir-prep-organize`: the host dispatches `entryKey: pkg.name` (source of truth: `dsh.profile.bundles` in `~/.dsh/profiles/web/package.json`), so a bare entry id never matches and the card renders nowhere.
|
|
49
49
|
- The settings namespace and `configForms.get()` stay the bare entry id `dir-prep-organize` - not the same identifier as that slot key.
|
|
@@ -52,10 +52,10 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
52
52
|
|
|
53
53
|
| Aspect | Fact |
|
|
54
54
|
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
-
| Tool registration | None. The host half only `inject`s
|
|
55
|
+
| Tool registration | None. The host half only `inject`s settings and never touches the host tool registry |
|
|
56
56
|
| Organize call | Host `llm.stream`: one user text message (**request-only input** - no `id`, no `source`; see the three-evidence note at the top of `host.ts`) plus a `system` rule block; the model comes from `agentDefaultModel.currentSelection()` (provider/model/reasoningEffort) and its absence reports "No model selection is available" |
|
|
57
57
|
| Role point of view | Optional `roleText` injected into the "Reference role" part of the system block; it only borrows terminology and tone, it never executes the role's tasks |
|
|
58
|
-
| Limits | All three live in config and every request takes them through `limits`: `organizeTimeoutMs` defaults to 120000 ms (a volatile reference read via `.get()`), `maxSnippetBytes` to 262144 (256 KiB) and `readConcurrency` to 8 (plain values, no `.get()`); the client request timeout is `organizeTimeoutMs` + 5000 ms (125000 when the host value is absent; the other
|
|
58
|
+
| Limits | All three live in config and every request takes them through `limits`: `organizeTimeoutMs` defaults to 120000 ms (a volatile reference read via `.get()`), `maxSnippetBytes` to 262144 (256 KiB) and `readConcurrency` to 8 (plain values, no `.get()`); the client request timeout is `organizeTimeoutMs` + 5000 ms (125000 when the host value is absent; the other four reads use a 125000 ms constant); directory/conversation/role text are never truncated; a finish reason other than `stop` (including a missing finish chunk) fails and never writes back |
|
|
59
59
|
|
|
60
60
|
## Settings
|
|
61
61
|
|
|
@@ -66,37 +66,29 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
66
66
|
| `organizeTimeoutMs` | natural, `.volatile()` | `120000` | The LLM abort deadline in ms; the host reads it per request via `config.organizeTimeoutMs.get()`. Being volatile it is projected into this entry's form snapshot, and of the three it is the only one the client half reads (`rawOrganizeTimeoutMsOf`), used to set the organize fetch timeout to "this value + 5000 ms". ⚠ Clamped to `[1, 2147483647]`: 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** for it: `src/client-entry.ts` writes only `templates` and `importAllowRoots`, so changing it means settings.yaml or the row's `config:` |
|
|
67
67
|
| `maxSnippetBytes` | natural (non-volatile) | `262144` | Per-file cap for the key-file snippet; 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 it is not projected into the form snapshot, so there is no card row either - deployment value only (settings.yaml / row `config:`) |
|
|
68
68
|
| `readConcurrency` | natural (non-volatile) | `8` | Bounded read concurrency for the key-file snippets and for directory imports (sub-directory listings, third-level counting, candidate reads). Same as above: no projection, no card control. ⚠ Clamped to `[1, 64]` before use: `0` or a negative value made the bounded map recurse into itself forever until the host process was killed by the OOM killer, and a huge value simply defeats the fd ceiling this field exists to hold |
|
|
69
|
-
| `importBodyMaxBytes` | natural (non-volatile) | `8388608` | Byte cap on the bodies of the two POST routes, organize and import (depth-of-defense against a memory blow-up, not a functional truncation: those routes carry the organized draft and the template products, not the file payloads themselves); over the cap is 413, and `guardBody` meters the stream and returns early at the crossing, so the worst resident memory is exactly this watermark. Same as above: no projection, no card control |
|
|
70
69
|
| Restore defaults | — | — | Unsets `templates` back to the curated set and leaves `importAllowRoots` untouched; two-step confirm, the second click must come within 4 seconds |
|
|
71
70
|
| Storage | — | — | Settings namespace `dir-prep-organize` (0.1.7 implicit registration: the namespace is this entry's id, and the fields projected into the settings form are the `.volatile()` ones on `Config` in host.ts - `templates`, `importAllowRoots`, `organizeTimeoutMs`, of which the card writes the first two; `maxSnippetBytes` and `readConcurrency` stay plain values; the curated set stays on the host half and is served on demand, not as a host `base`), persisted in the settings.yaml under `<dsh data dir>` (`$DSH_HOME`) |
|
|
72
71
|
|
|
73
72
|
## Public interface
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| Host authority is not a trusted local address | 403 with `{ok:false,error:"untrusted host authority"}`; `servingNonLoopback` comes from `isNonLoopbackBindHost(webServer.host)` (shared/lib/trust) - the host takes any local interface address as `Config.host` and rejects the wildcard address at load, so comparing against `"0.0.0.0"` would be permanently false; a service that reports no bind address keeps the conservative loopback-only setting |
|
|
88
|
-
| `sec-fetch-site` outside the allowlist, or origin mismatch | 403 with `{ok:false,error:"cross-origin request rejected"}` (opaque `origin: null` sandbox pages, and a local request that carries `origin` but no Host, land here too) |
|
|
89
|
-
| Wrong method | 405 with `Allow` and a JSON body: `{ok:false,error:"GET only"}` (organize/import answer `"POST only"`) |
|
|
90
|
-
| Missing or wrong CSRF | 403 with `{ok:false,error:"invalid csrf token"}` (the `guardBody` check, still behind the gate) |
|
|
91
|
-
| Body over the configured cap (8 MiB by default) | 413 with `{ok:false,error:"request body too large"}` |
|
|
92
|
-
| Broken stream or invalid JSON | 400 with `{ok:false,error}` (`"request body unreadable"` for a broken stream; invalid JSON uses the dictionary text) |
|
|
93
|
-
| Business failure | Still 200 with `{ok:false,error}`; the import endpoint's out-of-bounds and malformed-path branches are the exception - 403 and 400 (see Data and privacy) |
|
|
74
|
+
Official Typert Remote namespace `dirPrepOrganize`, registered through an injected child fiber. Authentication and transport are enforced by the host `/api` gateway (Host/DNS-rebinding/Origin checks, signed browser-session cookie, body limits); the package opens no HTTP routes and keeps no CSRF token of its own.
|
|
75
|
+
|
|
76
|
+
| Method | Input | Success payload |
|
|
77
|
+
| ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
|
78
|
+
| `defaults` | — | `ok/templates[{id,name,description,text,group,emoji}]` (the curated set) |
|
|
79
|
+
| `context` | `{ sessionId }` | `ok/cwd/truncated/skipped/entries[{name,isDir,sizeBytes,snippet}]` |
|
|
80
|
+
| `model` | `{ sessionId }` | `ok/provider/model/reasoningEffort` |
|
|
81
|
+
| `organize` | `{ sessionId, prompt, entriesSummary, roleText? }` | `ok/content` |
|
|
82
|
+
| `importTemplates` | `{ path, sessionId }` (`path` exactly empty = whole built-in library) | `ok/count/truncated/skipped/entries` |
|
|
83
|
+
|
|
84
|
+
- 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 for callers that surface it.
|
|
85
|
+
- Result parsing on the client keeps its defensive defaults: a non-object payload or a missing `ok:true` becomes a visible error, never an empty list.
|
|
94
86
|
|
|
95
87
|
## Data and privacy
|
|
96
88
|
|
|
97
89
|
| Aspect | Fact |
|
|
98
90
|
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
99
|
-
| Network calls |
|
|
91
|
+
| Network calls | No outbound requests: the read surface is reached through the host gateway's RPC channel, and no environment variable is read |
|
|
100
92
|
| Data on disk | The only data written to disk is `templates` and `importAllowRoots` in settings |
|
|
101
93
|
| What one organize call sends | The full draft, the session cwd path, top-level directory entries with the full text of key text files, real user/assistant turns (framework-injected messages and tool results are filtered out), and the optional role body |
|
|
102
94
|
| Snippet extensions | 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 types are not whitelisted |
|
package/README.zh-CN.md
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
- 「整理」把草稿 + 会话 cwd 的顶层目录(文件名/大小/关键文本文件全文)+ 会话最近真人对话交给当前默认模型重写。
|
|
10
10
|
- 成功直接替换草稿;失败草稿原值不动、按钮转失败态 4 秒(title 带原因)。
|
|
11
11
|
- 「模板」点选即插入草稿:空草稿整段填入,非空草稿末尾空一行追加。
|
|
12
|
-
- 默认列表是 85 条内置精选角色模板(scripts/gen-defaults.mjs 生成自包内 agents/ 角色库:
|
|
13
|
-
- 那张表**只留在 host 半**:client 半不再打包它(生成表 640KB,曾让 `client.js` 涨到 711KB
|
|
12
|
+
- 默认列表是 85 条内置精选角色模板(scripts/gen-defaults.mjs 生成自包内 agents/ 角色库:21 个部门目录、293 个角色 .md)。
|
|
13
|
+
- 那张表**只留在 host 半**:client 半不再打包它(生成表 640KB,曾让 `client.js` 涨到 711KB),改为首次打开「整理」/「模板」菜单或进设置卡时经 Remote 的 `defaults` 方法按需拉一发并进程内复用;未就绪时菜单里是「正在载入…」占位行,失败则显形为原因 + 重试按钮(不静默显示空列表)。用户已设置过自己的模板时一发都不发。
|
|
14
14
|
- 设置页一张「提示词模板」卡承载逐条增删改、两步确认恢复默认、一键导入内置全部角色、按路径导入本地 .md 或目录、登记导入允许目录。
|
|
15
15
|
- 模板与允许目录的读写走宿主 settings,零 LLM,也不注册任何模型工具。
|
|
16
16
|
|
|
@@ -23,7 +23,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
- 宿主区间 `>= 0.2.0-rc.2`,同时写进 `peerDependencies` 与 `engines.dsh`。真正生效的只有 `peerDependencies`:自 `0.1.7-rc.1` 起宿主载入插件时会校验它并把不兼容的条目**停用**(`compatibility-preflight.ts` 的 `deny()`);`engines.dsh` 在该宿主版本上没有任何读者。
|
|
26
|
-
- `@deepseek-ai/dsh-*` 依赖仍精确钉在 `0.2.1-
|
|
26
|
+
- `@deepseek-ai/dsh-*` 依赖仍精确钉在 `0.2.1-rc.2`——那是本包构建并测过的宿主版本。区间是对**它能跑在哪些宿主上**的声明,钉版是对**它在哪个宿主版本上编译过**的事实;把两者混成一条断言,正是发布门禁现在把它们拆开分别验的原因。
|
|
27
27
|
- client 半 `dsh.client.platform = web`、`immediately`。
|
|
28
28
|
- 发布形态为按包单仓,`repository.url` 为 git+https://github.com/JayYuen666/dsh-dir-prep-organize.git ;问题反馈走同一仓库的 issue(`bugs`)。
|
|
29
29
|
- 要求 Node.js `>= 22.12`。本包是纯 ESM:用 `import { apply } from "@jayyuen66/dsh-dir-prep-organize"` 或 `require("@jayyuen66/dsh-dir-prep-organize")`。**没有默认导出**——`import pkg from …` 会报 `does not provide an export named 'default'`,请取具名导出。正是这个 Node 下限让 `require()` 能吃下这个 ESM 入口,所以 `engines.node` 要写明。
|
|
@@ -32,8 +32,8 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
32
32
|
- 内置精选模板表单独成一个产物,**首次用到时才载入**,不再随插件载入就进内存。它原先被打进 `host.js`,于是即便用户从不开「模板」下拉,也要替 85 条模板付内存——现在 `host.js` 只有原先的约十分之一,而浏览器那一侧本来就是按需拉的。
|
|
33
33
|
- `agents/` 并非本仓原创:它来自上游项目 [`agency-agents-zh`](https://github.com/jnMetaCode/agency-agents-zh)(MIT)。MIT 要求声明随每一份分发副本一起给出,故其版权与许可声明收录在 `THIRD_PARTY_NOTICES.md`。
|
|
34
34
|
- `dependencies` 里不放任何 `@deepseek-ai/*`,这不是风格偏好。本包的消费方是 dsh 插件,被装进 profile(`nodeLinker: hoisted`、`autoInstallPeers: false`),宿主包只要出现在 `dependencies`,pnpm 就会在那棵 profile 依赖树里把它落成**真实目录**,与宿主进程已经加载的那份并存。而 `@deepseek-ai/dsh-tools` 的 `TOOL_RUNTIME_SCHEDULER` 是普通 `Symbol`(不是 `Symbol.for`),符号身份按模块实例计算——宿主 `dsh-agent-loop` 拿自己那份的 Symbol 去读由副本挂载出来的 `ToolRuntime`,得到 `undefined`,于是**每一次原生工具调用都抛** `Cannot read properties of undefined (reading 'prepare')`,整个 profile 的工具一起失效。本包的构建、类型检查与测试在这之前全部照绿,所以判据由 `test/publish-manifest.test.ts` 落在 manifest 面。
|
|
35
|
-
- 产物 `host.js` 里以**值**导入的两枚宿主包是非 optional 的 `peerDependencies`:`@deepseek-ai/schemastery`(宿主 fork,0.1.7 的 `.volatile()` 活引用只有它解析得出来)与 `@deepseek-ai/dsh-brand`(`0.2.1-
|
|
36
|
-
- 凡被**声明产物**点名的宿主包都写进 `peerDependencies`,其中只在那里现身的都判为 optional:`@deepseek-ai/cordis`(`4.0.5
|
|
35
|
+
- 产物 `host.js` 里以**值**导入的两枚宿主包是非 optional 的 `peerDependencies`:`@deepseek-ai/schemastery`(宿主 fork,0.1.7 的 `.volatile()` 活引用只有它解析得出来)与 `@deepseek-ai/dsh-brand`(`0.2.1-rc.2`)。运行期由宿主在场提供,而 profile 不装 peer,所以不产生副本。`build-host.mjs` 的外部化名单读 `dependencies` ∪ `peerDependencies`,两张表都读,所以 `host.js` 里的裸说明符一字未变——这正是 `brandString` 那处裁定的落点:落 peer 保住「说明符在」,只写 `devDependencies` 就会被 rolldown 把官方函数体内联进来(`test/build-host.test.ts` 同时钉「说明符在」与「函数体不在」)。
|
|
36
|
+
- 凡被**声明产物**点名的宿主包都写进 `peerDependencies`,其中只在那里现身的都判为 optional:`@deepseek-ai/cordis`(`4.0.5`)、`@deepseek-ai/cosmokit`(`1.8.6`,只经 schemastery 的 `Dict` 现身)以及 `@deepseek-ai/dsh-agent-default-model`、`-client-locale`、`-client-ui-conversation`、`-client-ui-renderer`、`-client-ui-settings`、`-client-ui-slots`、`-fs`、`-llm`、`-session`(全为 `0.2.1-rc.2`)。声明它们不是礼节:pnpm 严格布局下,`types/host.d.ts` 里一枚没有任何 manifest 表认领的裸说明符就是解析不到——消费方那侧的声明入口根本过不了类型检查,而本仓自己的 typecheck 照绿,因为我们两张表都有它。`test/publish-manifest.test.ts` 因此按 `types/**/*.d.ts` 现扫这份名单,而不是照这段话抄,两边就此漂不开。`@deepseek-ai/dsh` 是唯一谁也没 import 的 peer:它指宿主本身,也就是 `engines.dsh` 用文字说的那件事。
|
|
37
37
|
- 每枚 peer 都在 `devDependencies` 里以同一枚精确版本再写一份,本仓自己的 typecheck、build 与测试靠它解析。其余 `@deepseek-ai/*` 在源码里是 type-only,在声明产物里也不留说明符,所以只留在 `devDependencies`。
|
|
38
38
|
- `dependencies` 剩下的确实是本包自己的运行期代码:`@jayyuen66/dsh-plugin-shared`。
|
|
39
39
|
|
|
@@ -41,7 +41,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
41
41
|
|
|
42
42
|
- 装包即由包内 bundle patch(`dsh.bundle.patch` 指向 `./cordis.patch.yml`)注入 `- id: dir-prep-organize`(`name` 为包名)。
|
|
43
43
|
- 卸载用 `dsh plugin --profile web remove @jayyuen66/dsh-dir-prep-organize`。
|
|
44
|
-
- host 半硬依赖
|
|
44
|
+
- host 半硬依赖 settings:缺它时设置卡停用并 warn,「模板」下拉回落内置精选集。客户端读面是官方 Typert Remote 服务 `dirPrepOrganize`,经注入子 fiber 注册;不依赖 `webServer`。
|
|
45
45
|
- client 半注册槽 `conversation.input.right`(整理 id `dir-prep-organize` order 99、模板 id `dir-prep-organize-templates` order 100),另注册设置卡槽 `plugins.bundle.config`。
|
|
46
46
|
- 卡槽 key = bundle 包名 `@jayyuen66/dsh-dir-prep-organize`:该槽按 bundle 包名 keyed(宿主派发 `entryKey: pkg.name`,真源是 `~/.dsh/profiles/web/package.json` 的 `dsh.profile.bundles`);写成裸条目 id 就不命中,卡片整张不渲染。
|
|
47
47
|
- settings 命名空间与 `configForms.get()` 仍是裸条目 id `dir-prep-organize`,与上面的 slot key 不是一回事。
|
|
@@ -50,65 +50,57 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
50
50
|
|
|
51
51
|
| 面 | 事实 |
|
|
52
52
|
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
-
| 模型工具注册 | 无。host 半只 `inject`
|
|
53
|
+
| 模型工具注册 | 无。host 半只 `inject` settings,不碰宿主工具注册面 |
|
|
54
54
|
| 整理调用 | 宿主 `llm.stream`:单条 user 文本消息(**request-only 输入**,不带 `id`/`source`,见 `host.ts` 上方那条注释的三条证据)+ `system` 规则段;模型取 `agentDefaultModel.currentSelection()` 的 provider/model/reasoningEffort,取不到即报「当前无可用模型选择」 |
|
|
55
55
|
| 角色视角 | 可选 `roleText` 注入 system 的「参考角色」段,只借术语与措辞重写草稿,不代为执行角色的任务 |
|
|
56
|
-
| 时限与上限 | 三枚都进 config,路由每次请求经 `limits` 取一次:`organizeTimeoutMs` 默认 120000 ms(volatile 引用,`.get()` 现读)、`maxSnippetBytes` 默认 262144(256 KiB)、`readConcurrency` 默认 8(后两位是普通值形态,不经 `.get()`);client 请求超时 = `organizeTimeoutMs` + 5000 ms(宿主值缺席按 120000 算,即 125000
|
|
56
|
+
| 时限与上限 | 三枚都进 config,路由每次请求经 `limits` 取一次:`organizeTimeoutMs` 默认 120000 ms(volatile 引用,`.get()` 现读)、`maxSnippetBytes` 默认 262144(256 KiB)、`readConcurrency` 默认 8(后两位是普通值形态,不经 `.get()`);client 请求超时 = `organizeTimeoutMs` + 5000 ms(宿主值缺席按 120000 算,即 125000;另外四个读面用常量 125000 ms);目录/对话/角色正文一律不截断;流终态非 `stop`(含缺 finish 块)判失败且不写回 |
|
|
57
57
|
|
|
58
58
|
## 设置项
|
|
59
59
|
|
|
60
60
|
| 字段 | 类型 | 默认 | 说明 |
|
|
61
61
|
| ------------------- | ------------------------------------------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
-
| `templates` | `{id,name,description,text,group,emoji}[]` | 未设置 | 全 string 字段,description/group/emoji 缺省空串;保存时 name 或 text 为空的条目被剔除,emoji 截到 12 字符,id 缺失或撞名确定性补 `tpl-<index>`;未设置时下拉回落内置 85 条精选(生成集留在 host 半、经
|
|
62
|
+
| `templates` | `{id,name,description,text,group,emoji}[]` | 未设置 | 全 string 字段,description/group/emoji 缺省空串;保存时 name 或 text 为空的条目被剔除,emoji 截到 12 字符,id 缺失或撞名确定性补 `tpl-<index>`;未设置时下拉回落内置 85 条精选(生成集留在 host 半、经 `defaults` 读面按需下发,不再是 host 的 base)。⚠ 隐式注册下「未设置」到客户端就是**空表**(schemastery 对 array 字段把缺失值 cast 成 `[]`,不给默认并不产生 undefined),所以空表一律按未设置回落内置;只有「非空数组但逐项非法」才渲染空列表 |
|
|
63
63
|
| `importAllowRoots` | `string[]` | `[]` | 导入端点的额外允许根,逐条登记目录;非字符串与纯空白项丢弃、去重;未登记 = 只放行会话 cwd 与内置角色库 |
|
|
64
64
|
| `organizeTimeoutMs` | natural,`.volatile()` | `120000` | LLM 整理中止时限(毫秒),host 侧 `config.organizeTimeoutMs.get()` 每次请求现读。标了 volatile ⇒ 随宿主投影进本条目的表单快照,三枚里 client 半只读它一枚(`rawOrganizeTimeoutMsOf`),用来把 organize 的 fetch 超时定为「该值 + 5000 ms」。⚠ 使用前夹进 `[1, 2147483647]`:超过 2^31-1 时 Node 的 `setTimeout` 会打一条 `TimeoutOverflowWarning` 然后**静默改用 1 ms**,「把超时调大」于是变成「立刻失败」。⚠ 卡片**没有**它的控件:`src/client-entry.ts` 只写 `templates` 与 `importAllowRoots`,改它得动 settings.yaml 或注册行的 `config:` |
|
|
65
65
|
| `maxSnippetBytes` | natural(非 volatile) | `262144` | 单个关键文件摘要的字节上限,超出整份跳过(不喂半份摘要)并计 `skipped.tooLarge`;导入候选读取用同一枚。非 volatile ⇒ 不进表单快照,卡片自然也没有它的行;只能按部署值给(settings.yaml / 行 `config:`) |
|
|
66
66
|
| `readConcurrency` | natural(非 volatile) | `8` | 关键文件摘要读取与目录导入(子目录 listDir、第三层清点、候选读取)的有界并发度;同上,无投影、无卡上控件。⚠ 使用前夹进 `[1, 64]`:`0` 或负数会让有界 map 无限自递归直到宿主进程被 OOM killer 杀掉,而配成极大值则直接废掉这个字段存在的理由(那道 fd 上界) |
|
|
67
|
-
| `importBodyMaxBytes` | natural(非 volatile) | `8388608` | organize / import 两条 POST 的 body 字节上限(内存防爆纵深防御,非功能截断:两条路由提交的是整理草稿与模板产物,不是大文件本体);超限即 413,guardBody 流式计量并在越界处早退,所以最坏常驻内存就是这一枚水位。同上,无投影、无卡上控件 |
|
|
68
67
|
| 恢复默认 | — | — | unset `templates` 回落精选集、不动 `importAllowRoots`;两步确认,第二次点击须在 4 秒内 |
|
|
69
68
|
| 存储位置 | — | — | settings 命名空间 `dir-prep-organize`(0.1.7 隐式注册:命名空间 = 本条目 id,投影进设置表单的是 host.ts `Config` 上标了 `.volatile()` 的 `templates`/`importAllowRoots`/`organizeTimeoutMs`,其中卡片只写前两枚;`maxSnippetBytes` 与 `readConcurrency` 是普通值形态),落在 `<dsh 数据目录>`(`$DSH_HOME`)的 settings.yaml |
|
|
70
69
|
|
|
71
70
|
## 对外接口
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
81
|
-
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
| Host 权威不是本机可信地址 | 403 + `{ok:false,error:"untrusted host authority"}`;`servingNonLoopback` 取自 `isNonLoopbackBindHost(webServer.host)`(shared/lib/trust)——宿主的 `Config.host` 收任意本机接口地址、通配地址在载入即拒,所以跟 `"0.0.0.0"` 比字面量恒为 false;服务不报绑定地址时按只绑回环的保守档 |
|
|
86
|
-
| `sec-fetch-site` 不在白名单、或 origin 对不上 | 403 + `{ok:false,error:"cross-origin request rejected"}`(`origin` 为 `null` 的沙箱页,以及缺 Host 却又带了 `origin` 的本地面,同落这一句) |
|
|
87
|
-
| 方法不符 | 405 带 `Allow`,体是 JSON:`{ok:false,error:"GET only"}`(organize/import 为 `"POST only"`) |
|
|
88
|
-
| CSRF 缺失或错 | 403 + `{ok:false,error:"invalid csrf token"}`(`guardBody` 那一条,仍在闸门之后) |
|
|
89
|
-
| body 超配置上限(默认 8 MiB) | 413 + `{ok:false,error:"request body too large"}` |
|
|
90
|
-
| 坏流或非法 JSON | 400 + `{ok:false,error}`(坏流 `"request body unreadable"`,非法 JSON 走字典文案) |
|
|
91
|
-
| 业务失败 | 仍回 200 + `{ok:false,error}`;导入路径越界/非法段例外,回 403 与 400(见数据与隐私) |
|
|
72
|
+
官方 Typert Remote 命名空间 `dirPrepOrganize`,经注入子 fiber 注册。认证与传输边界由宿主 `/api` 网关承担(Host/DNS 重绑定/Origin 闸、已登录会话 cookie、body 上限);本包不再开 HTTP 路由,也没有自建 CSRF 令牌。
|
|
73
|
+
|
|
74
|
+
| 方法 | 入参 | 成功回执 |
|
|
75
|
+
| ----------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------------ |
|
|
76
|
+
| `defaults` | — | `ok/templates[{id,name,description,text,group,emoji}]`(内置精选集) |
|
|
77
|
+
| `context` | `{ sessionId }` | `ok/cwd/truncated/skipped/entries[{name,isDir,sizeBytes,snippet}]` |
|
|
78
|
+
| `model` | `{ sessionId }` | `ok/provider/model/reasoningEffort` |
|
|
79
|
+
| `organize` | `{ sessionId, prompt, entriesSummary, roleText? }` | `ok/content` |
|
|
80
|
+
| `importTemplates` | `{ path, sessionId }`(`path` 精确空串 = 内置角色库全量) | `ok/count/truncated/skipped/entries` |
|
|
81
|
+
|
|
82
|
+
- 业务失败仍是 `ok:false` + `error`。导入的路径策略分支例外:越界路径或 `path` 字段坏形状会额外带 `status` 403 / 400,供调用方原样呈现。
|
|
83
|
+
- 客户端解析器保留防御默认:非对象载荷或缺 `ok:true` 一律变成可见错误,绝不渲染成空列表。
|
|
92
84
|
|
|
93
85
|
## 数据与隐私
|
|
94
86
|
|
|
95
87
|
| 面 | 事实 |
|
|
96
88
|
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
97
|
-
| 网络调用 |
|
|
89
|
+
| 网络调用 | 不发起任何外部请求:读面经宿主 /api 网关的 RPC 通道到达,也不读任何环境变量 |
|
|
98
90
|
| 落盘 | 唯一落盘数据是 settings 里的 `templates` 与 `importAllowRoots` |
|
|
99
91
|
| 一次整理发给模型的全部内容 | 草稿全文、会话 cwd 路径、顶层目录条目与关键文本文件全文、真人 user/assistant 文本(框架注入消息与 tool 结果被过滤)、可选角色正文 |
|
|
100
92
|
| 摘要扩展名 | 只取 20 种代码/文档扩展名(ts/tsx/js/jsx/mjs/cjs/py/rs/go/java/rb/json/toml/md/sql/graphql/proto/css/scss/less);yaml/env 类不在白名单 |
|
|
101
93
|
| 敏感文件名 | 文件名含 credential/secret/id_rsa/.pem/.p12/.pfx/keystore/.env/.key 者永不取正文 |
|
|
102
94
|
| 单文件上限与并发 | 单文件超 `maxSnippetBytes`(默认 256 KiB)或大小未知即整份跳过(不喂半份摘要),读取按 `readConcurrency`(默认 8)有界并发;两位都是配置字段,也都不是卡上的控件 |
|
|
103
95
|
| 计数与回显 | 超限/读失败/更深层未扫/非角色都计入 `skipped` 并回显,`truncated` 如实上报 |
|
|
104
|
-
|
|
|
96
|
+
| 导入读面 `importTemplates` | 只读:不调模型、不写盘。绝对路径默认拒绝,仅放行会话 cwd、包内 `agents/`、`importAllowRoots` 三类根之内,`.`/`..`/隐藏段(如 `.ssh`)一律拒,越界回 403 并回显解析后的路径 |
|
|
105
97
|
|
|
106
98
|
## 常见问题
|
|
107
99
|
|
|
108
100
|
| 现象 | 处理 |
|
|
109
101
|
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
110
102
|
| 点了「整理」草稿没变? | 失败不改草稿;按钮 4 秒失败态,title 写原因。常见为无会话 cwd(sessionId 缺失或会话不存在)、无模型选择、模型终态非 stop、`organizeTimeoutMs` 到点(默认 120 秒) |
|
|
111
|
-
| 模型报上下文超限? |
|
|
103
|
+
| 模型报上下文超限? | 目录/对话/角色正文都不截断,超限由模型报错、用户自行精简 |
|
|
112
104
|
| 导入本地角色被拒? | 绝对路径默认拒绝,且设置卡没有会话上下文(POST 的 `sessionId` 为空串),路径须落在内置 `agents/` 或已登记目录内、且不含 `.`/`..`/隐藏段;越界回执会点名允许区并回显解析后的路径 |
|
|
113
105
|
| 导入条数比预期少? | 看回执 `skipped` 四项:目录只扫顶层与一层子目录(第三层只计 `deeper`)、超 `maxSnippetBytes`(默认 256 KiB)计 `tooLarge`、frontmatter 前 20 行解析不出 name 计 `unnamed`、读失败计 `unreadable` |
|
|
114
106
|
| 改模板不生效 / 语言不对? | 编辑先本地暂存,点「保存」后对新开的下拉生效;设置卡、输入框旁那两个 dock 按钮(文案与注册 label 都进了 `ui-messages.ts` 字典)、以及 host 回执都跟随官方 locale 插件的语言偏好(host 侧每请求现读,无需重启),而 agents/ 角色库与模板正文属用户数据、不做机翻 |
|