@jayyuen66/dsh-dir-prep-organize 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/README.zh-CN.md +7 -5
- package/client.js +232 -129
- package/host.js +114 -27
- package/package.json +69 -39
- package/types/host.d.ts +25 -15
- package/types/src/client-entry.d.ts +15 -6
- package/types/src/client-styles.d.ts +1 -0
- package/types/src/client-timeouts.d.ts +30 -0
- package/types/src/ui-messages.d.ts +3 -1
package/README.md
CHANGED
|
@@ -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-alpha.
|
|
28
|
+
- The `@deepseek-ai/dsh-*` dependencies stay pinned at `0.2.1-alpha.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.
|
|
@@ -33,9 +33,11 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
33
33
|
- The published artifact ships only `host.js`, `client.js`, `templates.data.mjs`, `types/`, `cordis.patch.yml`, `agents/` and `THIRD_PARTY_NOTICES.md` (package.json `files`). `LICENSE`, `README.md` and `package.json` are attached unconditionally by the registry client.
|
|
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
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
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-alpha.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-alpha.1`), `@deepseek-ai/cosmokit` (`1.8.6-alpha.1`, 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-alpha.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
|
+
- 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
|
+
- What is left in `dependencies` is this package's own runtime code: `@jayyuen66/dsh-plugin-shared`.
|
|
39
41
|
|
|
40
42
|
## Enabling it in dsh
|
|
41
43
|
|
|
@@ -82,7 +84,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
82
84
|
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
83
85
|
| Routing and token | All four are exact-match webServer routes (`kind: "exact"`); the **first statement** of every handler body is `guardTrust(req, res, { servingNonLoopback })` from shared/lib/trust, which writes a single 403 and returns without reading the body; `csrf` is a per-apply random token, issued by the two GETs and verified on organize |
|
|
84
86
|
| Order of the trust checks | Host authority → the `sec-fetch-site` allowlist (only same-origin/none/absent) → a verbatim `origin` vs Host comparison; the `isCrossOrigin` branch inside this package's handlers became unreachable once the gate landed and is deleted (the identical check inside the shared `guardBody` now sits behind the gate too), so the gate is what rejects cross-site traffic and supplies the sentence |
|
|
85
|
-
| Host authority is not a trusted local address | 403 with `{ok:false,error:"untrusted host authority"}`; `servingNonLoopback` comes from `webServer.host
|
|
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 |
|
|
86
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) |
|
|
87
89
|
| Wrong method | 405 with `Allow` and a JSON body: `{ok:false,error:"GET only"}` (organize/import answer `"POST only"`) |
|
|
88
90
|
| Missing or wrong CSRF | 403 with `{ok:false,error:"invalid csrf token"}` (the `guardBody` check, still behind the gate) |
|
package/README.zh-CN.md
CHANGED
|
@@ -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-alpha.
|
|
26
|
+
- `@deepseek-ai/dsh-*` 依赖仍精确钉在 `0.2.1-alpha.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` 要写明。
|
|
@@ -31,9 +31,11 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
31
31
|
- 发布产物只有 `host.js`、`client.js`、`templates.data.mjs`、`types/`、`cordis.patch.yml`、`agents/` 与 `THIRD_PARTY_NOTICES.md`(package.json 的 `files`);`LICENSE`、`README.md`、`package.json` 由 registry 客户端无条件附带。
|
|
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
|
-
-
|
|
35
|
-
|
|
36
|
-
|
|
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-alpha.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-alpha.1`)、`@deepseek-ai/cosmokit`(`1.8.6-alpha.1`,只经 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-alpha.2`)。声明它们不是礼节:pnpm 严格布局下,`types/host.d.ts` 里一枚没有任何 manifest 表认领的裸说明符就是解析不到——消费方那侧的声明入口根本过不了类型检查,而本仓自己的 typecheck 照绿,因为我们两张表都有它。`test/publish-manifest.test.ts` 因此按 `types/**/*.d.ts` 现扫这份名单,而不是照这段话抄,两边就此漂不开。`@deepseek-ai/dsh` 是唯一谁也没 import 的 peer:它指宿主本身,也就是 `engines.dsh` 用文字说的那件事。
|
|
37
|
+
- 每枚 peer 都在 `devDependencies` 里以同一枚精确版本再写一份,本仓自己的 typecheck、build 与测试靠它解析。其余 `@deepseek-ai/*` 在源码里是 type-only,在声明产物里也不留说明符,所以只留在 `devDependencies`。
|
|
38
|
+
- `dependencies` 剩下的确实是本包自己的运行期代码:`@jayyuen66/dsh-plugin-shared`。
|
|
37
39
|
|
|
38
40
|
## 在 dsh 里启用
|
|
39
41
|
|
|
@@ -80,7 +82,7 @@ dsh plugin --profile web add @jayyuen66/dsh-dir-prep-organize
|
|
|
80
82
|
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
83
|
| 路由与令牌 | 四条都是 webServer 精确路由(注册时 `kind: "exact"`);每条 handler 体的**第一条语句**是 `guardTrust(req, res, { servingNonLoopback })`(shared/lib/trust),非 trusted 即写一次 403 并 return,不再读 body;`csrf` 为 per-apply 随机令牌,两个 GET 下发、organize 回填 |
|
|
82
84
|
| 信任判据的次序 | Host 权威 → `sec-fetch-site` 白名单(只放 same-origin/none/缺失)→ `origin` 与 Host 逐字比对;本包 handler 里自家那枚 `isCrossOrigin` 分支在闸门落地后不可达、已删(共享层 `guardBody` 的同形检查也被闸门挡在前面),拒跨域的是闸门,错误文本由它给 |
|
|
83
|
-
| Host 权威不是本机可信地址 | 403 + `{ok:false,error:"untrusted host authority"}`;`servingNonLoopback` 取自 `webServer.host
|
|
85
|
+
| Host 权威不是本机可信地址 | 403 + `{ok:false,error:"untrusted host authority"}`;`servingNonLoopback` 取自 `isNonLoopbackBindHost(webServer.host)`(shared/lib/trust)——宿主的 `Config.host` 收任意本机接口地址、通配地址在载入即拒,所以跟 `"0.0.0.0"` 比字面量恒为 false;服务不报绑定地址时按只绑回环的保守档 |
|
|
84
86
|
| `sec-fetch-site` 不在白名单、或 origin 对不上 | 403 + `{ok:false,error:"cross-origin request rejected"}`(`origin` 为 `null` 的沙箱页,以及缺 Host 却又带了 `origin` 的本地面,同落这一句) |
|
|
85
87
|
| 方法不符 | 405 带 `Allow`,体是 JSON:`{ok:false,error:"GET only"}`(organize/import 为 `"POST only"`) |
|
|
86
88
|
| CSRF 缺失或错 | 403 + `{ok:false,error:"invalid csrf token"}`(`guardBody` 那一条,仍在闸门之后) |
|