Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bisheng-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: BiSheng core checks

on:
pull_request:
branches: [main, V1.3.1, codex/bisheng-unified]
branches: [main, V1.3.1, V1.3.2, codex/bisheng-unified]
workflow_dispatch:
inputs:
extended:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-boundary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Downstream Boundary Gatekeeper

on:
pull_request:
branches: [main, V1.3.1, codex/bisheng-unified]
branches: [main, V1.3.1, V1.3.2, codex/bisheng-unified]
workflow_dispatch:

permissions:
Expand Down
82 changes: 82 additions & 0 deletions build/safe-mode.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@
.column { display: flex; flex: 1 1 auto; flex-direction: column; width: min(100%, var(--page-max)); min-height: 0; margin-inline: auto; }
.summary, .notice, .safety, .actions, .list-heading, .empty { flex-shrink: 0; }
h1:empty { display:none; }
.content.with-profiles { overflow: auto; }
.with-profiles .column { flex: 0 0 auto; }
.with-profiles .list-card { flex-shrink: 0; max-height: 240px; }
.profile-maintenance { margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.profile-maintenance h2 { margin: 0 0 10px; font-size: 14px; }
.profile-maintenance select { max-width: 100%; padding: 7px; font: inherit; color: var(--ink); background: var(--surface); }
.profile-maintenance label { margin-right: 8px; font-size: 13px; }
.profile-reports { max-height: 160px; overflow: auto; padding-left: 20px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-feedback { font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.summary { margin: 0 0 10px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.notice { display: none; flex-shrink: 0; max-height: min(28vh, 220px); overflow: auto; margin: 0 0 14px; padding: 11px 13px; border-radius: 10px; font-size: 12px; line-height: 1.5; }
.notice.error { color: var(--danger); background: rgba(195,59,56,.08); }
Expand Down Expand Up @@ -148,6 +158,18 @@ <h1 class="nav-title" id="page-title"></h1>
<h1 id="heading"></h1>
<p class="summary" id="summary"></p>
<button class="agent-link" id="repair-agent" type="button"></button>
<section class="profile-maintenance" id="profile-maintenance" aria-labelledby="profile-heading" hidden>
<h2 id="profile-heading"></h2>
<label for="profile-selector" id="profile-selector-label"></label>
<select id="profile-selector"></select>
<ul class="profile-reports" id="profile-reports"></ul>
<div class="profile-actions">
<button class="button" id="profiles-inspect" type="button"></button>
<button class="button" id="profiles-repair" type="button"></button>
<button class="button" id="profiles-repair-all" type="button"></button>
</div>
<p class="profile-feedback" id="profile-feedback" role="status" aria-live="polite"></p>
</section>
<section class="list-card" aria-labelledby="selection-hint">
<label class="list-heading"><input type="checkbox" id="select-all" /><span id="selection-hint"></span></label>
<ul class="plugins" id="items"></ul>
Expand Down Expand Up @@ -289,6 +311,66 @@ <h1 id="heading"></h1>
}
notice.classList.add('visible', model.noticeTone === 'success' ? 'success' : 'error')
}
const maintenance = model.profileMaintenance
if (maintenance) {
const zh = model.locale === 'zh'
const section = document.getElementById('profile-maintenance')
section.hidden = false
document.querySelector('.content').classList.add('with-profiles')
setText('profile-heading', zh ? '普通 Profile 维护' : 'Normal Profile maintenance')
setText('profile-selector-label', zh ? '选择 Profile' : 'Select Profile')
setText('profiles-inspect', zh ? '检查 / 刷新' : 'Inspect / refresh')
setText('profiles-repair', zh ? '修复所选 Profile…' : 'Repair selected Profile…')
setText('profiles-repair-all', zh ? '修复所有普通 Profile…' : 'Repair all normal Profiles…')
const selector = document.getElementById('profile-selector')
const reports = Array.isArray(maintenance.reports) ? maintenance.reports : []
const repairableReports = reports.filter(report => report.repairable !== false)
for (const report of reports) {
if (report.repairable !== false) {
const option = document.createElement('option')
option.value = String(report.name)
option.textContent = String(report.name)
selector.appendChild(option)
}
const item = document.createElement('li')
item.textContent = String(report.name) + ': ' + String(report.status) + (report.detail ? '\n' + String(report.detail) : '')
document.getElementById('profile-reports').appendChild(item)
}
const inspect = document.getElementById('profiles-inspect')
const repair = document.getElementById('profiles-repair')
const repairAll = document.getElementById('profiles-repair-all')
inspect.hidden = !maintenance.canInspect
repair.hidden = repairAll.hidden = !maintenance.canRepair
selector.disabled = repairableReports.length === 0
repair.disabled = repairableReports.length === 0
if (reports.length === 0) setText('profile-feedback', zh ? '没有可维护的普通 Profile。' : 'No normal Profiles available for maintenance.')
let profileBusy = false
const runProfileAction = async (action, selection) => {
if (profileBusy) return
profileBusy = true
const controls = Array.from(document.querySelectorAll('button, input, select'))
const disabled = controls.map(control => control.disabled)
controls.forEach(control => { control.disabled = true })
section.setAttribute('aria-busy', 'true')
setText('profile-feedback', action === 'profiles-inspect'
? (zh ? '正在检查 Profile…' : 'Inspecting Profiles…')
: (zh ? '正在修复 Profile…' : 'Repairing Profiles…'))
try {
const result = await window.dshSafeMode.action(action, selection)
if (!result || result.ok === false) throw new Error(result && (result.error || result.notice) || (zh ? '操作未完成,请重试。' : 'The operation did not complete. Try again.'))
} catch (error) {
section.setAttribute('aria-busy', 'false')
setText('profile-feedback', (zh ? '操作失败:' : 'Operation failed: ') + (error instanceof Error ? error.message : String(error)))
controls.forEach((control, index) => { control.disabled = disabled[index] })
profileBusy = false
}
}
inspect.addEventListener('click', () => void runProfileAction('profiles-inspect', {}))
repair.addEventListener('click', () => {
if (selector.value) void runProfileAction('profiles-repair', { profiles: [selector.value] })
})
repairAll.addEventListener('click', () => void runProfileAction('profiles-repair', { all: true }))
}
const list = document.getElementById('items')
const empty = document.getElementById('empty')
const apply = document.getElementById('apply')
Expand Down
34 changes: 34 additions & 0 deletions docs/multi-profile-maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 多 Profile 检查、清理与增量维修

## 范围与入口

Profile 发现以当前应用传入的 DSH_HOME/profiles 为边界,只枚举直接子目录,按有效 package.json 中的 dsh.profile.bundles 识别,不维护 desktop/web/Enterprise 名单。大小写、下划线及空格保持原样。node_modules、隐藏目录(含 .generations)排除;desktop-safe-mode、链接目录、无效 manifest 单独报告,默认不修改。没有 manifest 的普通目录不当作 Profile。

普通冷启动、失败重试和 Harness 重启调用同一 profile-startup:串行遍历所有普通 Profile 做定点清理,一项失败不阻断其他 Profile 的检查。不会为所有闲置 Profile 重新投影或 sweep generation;只有当前将启动的 desktop 执行原有投影,且必须成功取得自己的使用 lease。该 Profile 正在使用或安装状态未知时,启动拒绝继续投影和加载。

安全模式页新增 Profile 检查列表,显示缺包、版本冲突、保留原因或使用中状态;可刷新、选择一个 Profile 或修复全部普通 Profile。维修需要本地确认,逐个执行并分别报告;运行中的普通 Profile 跳过。要维修当前正常环境,应先进入安全模式,原正常 Host 随重启退出;安全模式自己的 Host 保持运行且不会维修自己。

## 处理步骤

1. 只读检查使用与清理相同的资格规则,产生冲突项、动作/跳过原因和必需依赖缺失清单,不写锁或配置。
2. 自动清理仅删除归属明确、无其他顶层包直接 dependencies/optionalDependencies 需求的冲突官方入口。外部链接、显式本地源、npm 别名、tag 和复杂范围保留;仅精确版本、^/~完整版本或 * 视为可对齐 registry 声明。普通插件、私有依赖、会话及工作区源码保持原位,锁文件不改。
3. 显式增量维修重新发现并验证目标,对已有可管理官方声明对齐当前安装包版本,再保留旧依赖树和锁文件运行 DSH CLI plugin --profile <精确名称> install --no-frozen-lockfile。复用现有 generation-aware pnpm runner 和 Windows 控制台隐藏入口;不预删依赖树,不自动整树重建。pnpm 可复用 store,但可能下载缺包或执行安装脚本。
4. 安装正常结束后恢复对应 Profile generation 投影,并在冲突清理前后验证必需包 JSON、身份与精确官方版本。安装返回 0 不代表插件已激活;UI 明确要求退出安全模式后验证实际运行。

## 互斥、失败与中断

Host 从首次读取 Profile 前持有 .desktop-profile-use.lock,清理、初始化、generation 投影和增量维修使用同一个上游原子文件锁。存活 PID、不可识别的锁内容、旧 lock 或包管理器写锁会阻止修改;不能仅按年龄删除。新 Host 竞争维修中的 lease 时不会开始读取 Profile。直接运行不遵守这些协议的旧版/第三方运行时或裸 pnpm 不受这层协议完全约束,因此维护前仍应关闭它们。

增量安装在调用安装器之前写 .desktop-profile-repair-pending.json。确认已结束的失败保留原树和 pnpm 已完成的变更,返回错误,不进行破坏性回滚;其他 Profile 可继续。超时、信号退出或调用抛错而无法证明结束时保留标记并停止剩余批次。Host 和后续维修都拒绝使用该 Profile,以免与残留安装进程竞争。

本次不提供自动解除未知安装标记的 UI。遇到该状态,应先确认安装进程及其后代已经结束,再通过维修会话处理标记并重试;不能只因为父进程 PID 已退出就清掉。备份目录不是自动增量维修的前提,代码不会创建整个 node_modules 的副本。

无效/损坏 Profile 只展示错误,不自动改写 manifest 或重置用户设置。单项增量维修失败不会声称已生效,不将失败隐藏成成功。

## 源码与验证

发现:src/main/profile/profile-discovery.ts;计划/编排:profile-maintenance.ts;定点规则:profile-core-repair.ts;停用来源识别:profile-dependency-spec.ts;Host 协议:src/shared/profile-use.ts 和 src/host/profile-use.ts;实际入口:src/main/shell/profile-startup.ts、profile-maintenance.ts、app.ts 以及现有 build/safe-mode.html。

回归覆盖多目录与精确名称、所有 Profile 的只读计划、活动锁、Safe Mode/共享存储/外部链接隔离、首次启动目录、顺序安装与失败继续、未知中断停止、元数据复检、generation 互斥、Host 子进程生命周期、Safe Mode 操作解析和中英文页面交互。最终相关 15 个测试文件共 201 项通过;维修代理上下文测试另有 13 项通过,已将默认目录从旧 web 提示改为 desktop,并明确检查所有兄弟 Profile。npm run build、npm run typecheck、最终生产入口编译与 git diff --check 通过。本轮一次完整 npm test 为 3732 项通过、44 项失败、11 项跳过;失败包含 Office/图像沙箱、PTY/模拟 asar、Electron 环境、pnpm 集成超时及 PPT 页面断言,完整回归未全绿。后续补充的中断/首次启动/generation 互斥边界已在最终 201 项相关回归中验证。

已尝试独立临时 userData 的原生 Electron 页面探针,但工具沙箱以 Operation not permitted 拒绝 Electron sandbox 初始化;未关闭 Electron sandbox 绕过,因此原生视觉验收不算通过。Windows 实机 junction、文件占用、终止进程树、正式安装包升级、联网 pnpm 真实 Profile 修复和完整运行时激活仍待验收。
34 changes: 34 additions & 0 deletions docs/schedule-startup-compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 官方插件残留入口清理

## 故障

用户现场为 Desktop 0.14.0 → 0.14.1、核心 dsh 0.2.2-alpha.2 → 0.2.2-rc.5 升级后,desktop Profile 内残留 dsh-schedule@0.2.0-rc.2,遮蔽安装包自带 0.2.2-rc.5。旧 schedule 调用新版 agents 已移除的 roots(),required entry 激活失败并令 Host 退出。

## 当前方案

启动正确性由 app-boot 兼容补丁保证:仅把安装包所属 bundle 的插件入口固定到安装包解析结果,前后端从同一 manifest 发现,保留元数据;普通市场层和用户覆盖仍按原规则解析。

冷启动、失败重试和 Harness 重启共用 profile-startup.ts,发现当前 DSH_HOME/profiles 下全部有效普通 Profile(含 web、desktop、Enterprise、自定义名称),逐个检查并定点清理;特殊存储目录排除。当前 desktop 的 generation 投影与 sweep 在相同生命周期 lease 下执行。Safe Mode 跳过自动清理,但页面可检查所有 Profile,并显式选择单个或全部普通 Profile 做增量维修,详见 multi-profile-maintenance.md。

清理只删除同时满足以下条件的 Profile 顶层 @deepseek-ai 包入口:包名有效;Profile 与安装包 manifest 名称一致且版本不同;不是显式本地源;没有其他可读取的顶层包在 dependencies/optionalDependencies 声明依赖它;入口是普通目录或指向当前 node_modules 内部的 pnpm 链接。scope、node_modules、Profile 本身是链接时跳过;外部包链接、元数据不完整的依赖树也保留。不会递归扫描或删除普通插件的私有依赖、pnpm store 或 generation。

对被清理项已有的 Profile 根 registry 声明,仅将该项对齐为当前内置精确版本,不新建其他依赖。锁文件字节保持不变:下一次用户主动执行 pnpm 时可增量更新,冻结锁安装可能要求显式更新锁文件。根声明的对齐不能保证第三方依赖或旧 lock 永不重新投影旧入口;后续启动仍会检查,安装包来源规则始终生效。

自动启动清理没有 pnpm 子进程、下载、安装脚本、整树备份、重建或自动回滚;安全模式中用户明确确认的增量维修才运行 pnpm。Windows 占用导致单项移除失败时记录原始错误并延后处理,内置插件仍从安装包加载。不同启动进程通过 manifest 文件锁排他操作。复杂或无法确定归属的情况只保留并记录,不强制替换第三方插件 API。定点删除本身不提供备份恢复;依赖可由正常包管理操作重新生成。

## 官方 Desktop 基线核对

核对范围是 upstream-baseline.json 指定的 9c2670d3bce5275e0d1610272958121af87787bb(0.2.2-rc.5),不是最新 HEAD。

- [官方 main.ts](https://github.com/deepseek-ai/deepseek-harness/blob/9c2670d3bce5275e0d1610272958121af87787bb/apps/desktop/src/main.ts#L680-L685):backend.start 前调用 manager.applyRelease。
- [官方 project-manager.ts](https://github.com/deepseek-ai/deepseek-harness/blob/9c2670d3bce5275e0d1610272958121af87787bb/apps/desktop/src/project-manager.ts#L79-L89):明确不安装包,只读取 runtime、迁移 workspace 设置、初始化 Profile、移除旧投影。
- [官方 removeLinkProjections](https://github.com/deepseek-ai/deepseek-harness/blob/9c2670d3bce5275e0d1610272958121af87787bb/packages/boot/app-boot/src/profile.ts#L219-L254):只移除指向 .dsh-module-fallback/node_modules 的旧链接及所属旧目录,保留 pnpm 包和其他链接。
- [官方 sanitizeProfile](https://github.com/deepseek-ai/deepseek-harness/blob/9c2670d3bce5275e0d1610272958121af87787bb/packages/boot/app-boot/src/profile-sanitize.ts#L8-L33):恢复时备份用户 patch 并重写 bundle 列表,保留安装包与其他 manifest 字段。

基线官方实现没有通用版本冲突清除、启动自动安装或整树备份。本次定点清理是本产品的显式差异,不能称为直接移植官方行为。

## 验证边界

回归覆盖无安装清理、锁文件保持、已有 registry 声明对齐、其他 Profile/普通包/本地源/链接保护、重复并发启动、Safe Mode,以及清理旧 schedule 后真实 Host 启动。发行包旧版本使用最小模拟 fixture,不是旧包完整实现。

最终相关 9 个文件共 80 项测试通过;类型检查、npm run build、最终入口编译及 git diff --check 通过。串行完整 npm test 为 3645 项通过、42 项失败、11 项跳过,失败集中在此前已出现的 Office 沙箱、PTY/模拟 asar、Electron GUI 和运行环境断言;最后新增的 linked-scope 用例在最终相关测试中通过。启动耗时没有做正式性能基准,不能把小 fixture 的时间作为真实用户数据保证。尚未完成原生 Windows/junction/文件占用、正式升级安装包、全新 npm ci 补丁重放和完整浏览器 UI 验收。源码构建及临时 Host 成功不代表已安装应用已生效。
2 changes: 1 addition & 1 deletion ops/ci/upstream-baseline.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"repository": "https://github.com/dataelement/dsh-desktop.git",
"ref": "V0.14.1",
"commit": "64c72122a08bf0b2392c62f47a80aadb8b30226f"
"commit": "caa41a28a429e5eb16f2ee0b5a5047ca7902ed18"
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@
"**/@vscode/ripgrep-*/bin/rg",
"node_modules/@deepseek-ai/libreoffice-kit-*/**/*",
"node_modules/sherpa-onnx-*/**/*",
"node_modules/dsh-ppt/vendor/ppt-master/**/*",
"node_modules/dsh-ppt/lib/*.py",
"node_modules/@deepseek-ai/dsh-experimental-cua-macos/native/**/*"
],
"npmRebuild": false,
Expand Down
5 changes: 5 additions & 0 deletions packages/dsh-desktop-client-ui/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ window.__ModuleLoader__.load({
style.id = id
style.textContent = `${templateControlsCss}
[data-dsh-sidebar-brand-identity] { display:none !important; }
/* Match the menu tint over an opaque base so scrolling rows cannot show through. */
[data-menu-material="translucent"] > [id$="-models"] > [data-menu-group] > [data-menu-group-heading][data-stuck] {
background: linear-gradient(var(--dsw-menu-surface-fill), var(--dsw-menu-surface-fill)),
var(--dsw-alias-bg-base);
}
/* Third-party plugins (dshmarket, dsh-better-sidebar) draw custom icons via ::before on settings nav rows
and expect the fallback gear to disappear. rc.4's official sidebar no longer uses a navIcon class;
keep both the old span wrapper and a direct svg so either structure stays hidden. */
Expand Down
Loading
Loading