Skip to content

fix: expose ./package.json in exports so dsh client scanner loads the browser half (#3043) - #3052

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-13_dsh-client-pkgjson-export
Oct 13, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-13_dsh-client-pkgjson-export

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

背景 / What

DSH(dsh-market 安装)的 Host 半体(压缩)工作正常,但 Harness Web GUI 的设置页完全不出现 bili 这一项。根因:package.json 的 exports 字段缺少 ./package.json 映射。

Node 的 exports 一旦声明即为封闭——未列出的子路径一律不可访问。于是 DSH 客户端扫描器用来定位包根的 require.resolve("billion-context/package.json") 抛出 ERR_PACKAGE_PATH_NOT_EXPORTED;该异常被上层 catch { return } 静默吞掉 → 客户端模块表里没有这条目 → 浏览器半体(settings.section)从不注册。已有的 ./dsh/package.json 帮不上忙(扫描器问的是 /package.json,不是 /dsh/package.json)。

修复 / How

在同一机制的两个写入点都补上 "./package.json": "./package.json" 自映射:

  1. 发布清单 package.json(dsh-market 安装路径,即本 issue 报告的场景);
  2. src/launcher.ts 的 bili dsh launcher shim(writeDshClientShimFiles)——它写出的 <dshHome>/node_modules/billion-context/package.json 由同一个扫描器读取,存在完全相同的缺陷。

并加两个回归测试钉住这两处:

  • tests/dsh-settings-ui.test.ts:断言发布清单含 ./package.json;
  • tests/launcher.test.ts:在既有 shim 测试里用 createRequire(home/probe.cjs).resolve("billion-context/package.json") 端到端复现扫描器的包根定位(修复前该 resolve 会抛错)。

影响面 / Behavior change

纯增量:只是让一个此前不可访问的子路径变得可解析,未改动任何既有可工作路径、wire/消息形状、配置面或持久化格式。唯一行为变化是 require("billion-context/package.json") 从「抛 ERR_PACKAGE_PATH_NOT_EXPORTED」变为「返回包根 path」——这正是期望结果。

验证 / Verification

本地(已 rebase 到当前 master):tsc --noEmit 通过;定向测试 tests/dsh-settings-ui.test.ts + tests/launcher.test.ts = 306 pass / 0 fail(1 个与本改动无关的环境性 skip)。全量回归与 build 交给 CI。

Closes #3043

…he browser half (#3043)

Node's `exports` map is closed once declared, so require.resolve(
"billion-context/package.json") threw ERR_PACKAGE_PATH_NOT_EXPORTED. dsh's
client scanner uses that resolve to locate the package root before reading the
dsh.client declaration; its catch swallows the throw, the entry drops out of
the client module table, and the browser half (settings.section) never
registers — the settings page vanishes while the host half keeps working.

Add the "./package.json" self-mapping at BOTH writer locations of the same
mechanism (the published manifest and the `bili dsh` launcher shim) and pin
both with regression tests that reproduce the scanner's root-locate resolve.

Fixes #3043
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-13_dsh-client-pkgjson-export (81325c3)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3452-pr.3052.58c716f

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3052.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

PR #3052 审核完成,结论:可合并。以下是独立审核过程(不是复读 issue):

审核过程

  • 原 issue 方向([Bug] exports 缺少 "./package.json",导致 DSH 客户端半体(设置页)完全不加载 #3043):报告者给出了源码级证据链——dsh-client-modules locatePkgJson() 用 require.resolve("<pkg>/package.json") 定位包根,catch { return } 静默吞错 → 客户端模块表缺条目 → 浏览器半体不注册。方案方向是修机制(让包根可解析)而非治标(动 UI/加兜底),成立。
  • 独立复现机制:用修复前的真实清单字节做隔离探针(挡掉工作区自引用干扰后),require.resolve("billion-context/package.json") 确实抛 ERR_PACKAGE_PATH_NOT_EXPORTED;补上该键后返回包根 path;既有 5 个子路径(. / ./server / ./dsh / ./client / ./dsh/package.json)逐一实测全部照常可解析,无一被破坏。
  • 回归清点(审过的既有行为):① 发布清单 exports 既有 5 键——未改动,改后全部照常 resolve(实测);② launcher shim 写出的 package.json 既有 4 键——未改动,既有 deepEqual 断言通过;③ 全仓无代码遍历或计数 exports 键(只有单键读取与写入点),新增键无消费方副作用;④ tests/index-entry-guard.test.ts 只断言 exports["."],不受影响;⑤ version 字段、kernel/、配置面、持久化格式均未触碰(CI 对应 guard 全绿)。高危模式逐项过:无语义漂移、无 fail-fast 变吞错、无阈值/时序/输出格式变化。
  • 测试有效性:两个新测试都有牙——manifest 测试删掉该键即失败;shim 测试用 createRequire(...).resolve("billion-context/package.json") 端到端复现扫描器的包根定位调用(修复前该调用抛错,已独立证实)。非恒真断言。
  • 基座新鲜度:分支 base(097e76c)落后当前 master 两个合并(fix: codex lane — keep the proactive compression channel alive (#3008) #3018 codex lane、fix(#2966): strip generate from prior.request in ResponsesWsHistory.expand() #2968 responses-ws leak),与本 PR 触碰文件零重叠(diff 验证为 0 行);本地 rebase 到当前 master 干净无冲突,rebased head 上 typecheck 通过 + 定向测试(dsh-settings-ui + launcher + index-entry-guard)= 311 pass / 0 fail。因无冲突,未 force-push 重推 rebase 版,避免无谓 CI 重跑。
  • CI:head 81325c3 上 24 个 check 全绿(ubuntu/windows × node 22/24 全量 test、static-gates、lock-sync/lane-guard/version-guard/kernel-guard/config-surface-guard 等、build-artifact、real-client lane)。
  • diff 整洁度:4 文件 24+/2-,每一行都与本 PR 目的相关,无跑题内容。

结构化八问

  1. 是什么问题:DSH Web GUI 设置页完全不出现 bili 这一项(浏览器半体未注册);压缩主功能(Host 半体)一直正常。
  2. 什么原因导致的:Node 的 exports 声明后即为封闭映射,漏了 ./package.json → 扫描器定位包根的 resolve 抛 ERR_PACKAGE_PATH_NOT_EXPORTED → 被上层 catch 静默吞掉 → 模块表缺条目。修的是机制层(包根不可解析),不是症状层。
  3. 影响范围与严重程度:所有走 DSH 客户端加载路径的安装(dsh-market 安装 + bili dsh launcher shim 副本),打开设置页即触发;特定功能完全不可用,主链路不受影响。
  4. 怎么修复的:在同一机制的两个写入点(发布清单 + writeDshClientShimFiles)都补 "./package.json": "./package.json" 自映射,各加一个回归测试钉住。
  5. 是否回归问题:无。见上面「回归清点」五项,既有行为全部保持。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。
  8. 是否引入新的配置:不涉及(exports 子路径属 npm 包面,不属 bili 配置面)。

行为变更披露(旧值→新值):require("billion-context/package.json") 从「抛 ERR_PACKAGE_PATH_NOT_EXPORTED」变为「返回包根 path」。纯增量开放访问,正是期望结果。

收工判定:满足 auto-merge gate 条件(单模块 fix、有回归测试、rebased head 绿、不碰 wire/配置/持久化/kernel、commit 带 Fixes #3043),可合并,请人工执行合并:#3052

@ranxianglei
ranxianglei merged commit 1851411 into master Oct 13, 2026
24 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.385-master.1851411 (rolling master tag).

npm install -g billion-context@0.0.385-master.1851411  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

ranxianglei pushed a commit that referenced this pull request Oct 13, 2026
… hosts (#3077)

The functional fix (exports ['./package.json']) already shipped via #3052 (commit 1851411), which also added a static manifest check and a shim probe. This PR is reduced to its one non-redundant piece: a regression test driving Node's real exports resolution of <pkg>/package.json through a node_modules symlink of the published package root - the exact path DSH Desktop's createRequire fallback takes without --expose-internals. Without the export this throws ERR_PACKAGE_PATH_NOT_EXPORTED and the client half is dropped silently.
@ranxianglei
ranxianglei deleted the 2026-10-13_dsh-client-pkgjson-export branch October 15, 2026 05:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] exports 缺少 "./package.json",导致 DSH 客户端半体(设置页)完全不加载

1 participant