Repository navigation
Feat/windows installer - #152
Closed
hcyniubiaaa12 wants to merge 17 commits into
Closed
hcyniubiaaa12 wants to merge 17 commits into
hcyniubiaaa12 wants to merge 17 commits into
Conversation
仓库此前只有在 npm publish 的 prepack 里才跑检查,日常开发没有任何 护栏。新增 GitHub Actions 工作流,在 push/PR 触及 dsh-pet/** 时跑 typecheck、test、lint、format:check,与本地命令完全一致。 同时补上 Claude Code 使用的仓库级配置: - CLAUDE.md:架构导航(宿主半边 / 桌面壳 / 独立模式三层关系)与验证前置条件 - docs/agents/:本地 Markdown issue tracker、triage 标签、领域文档约定 实测四项检查在本机全绿(920 个测试,919 通过 1 跳过)。 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 新增 src/host/launch-plan.ts:parseAppRole / buildLaunchPlan 纯函数; 打包形态返回同一个 exe + 角色参数,环境清理清单由计划返回 - HelperProcess.start 改走启动计划,spawn 点只执行 envDelete - 独立模式入口接入角色/自启解析(目前恒为宿主) - 新增 runtime/electron-helper/tray-menu.js:托盘菜单模板纯函数; 现有接线仍只渲染宠物勾选,用户可见行为不变 - 补充单测,并把 tray-menu.js 加入发布必需文件清单 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 抽出 startStandalone 可编程入口(port/settingsUrl/幂等 shutdown),CLI 只保留参数解析与退出 - 新增 desktop/main.mjs 角色分流:host / --dsh-pet-helper / --dsh-pet-dpi-probe - 打包形态的启动计划不再解析或下载 Electron,改为同一个 exe + 角色参数拉起桌面壳 - 新增 electron-builder.yml、scripts/dist.mjs 与 npm run dist,产物输出到被忽略的 dist/ - 排除 assets/preview(65MB);内置 Electron 43.3.0;每用户 NSIS、不请求管理员、不用 UPX - 补测试:startStandalone 契约、packaged 启动计划、打包接线源码契约 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 桌面壳改用 __dirname 绝对路径加载 index.html:loadFile 的相对路径相对 app.getAppPath() 解析,打包后那是 asar 根,页面实际在 runtime/electron-helper/ - DPI 探测子进程在打包形态改用同一个 exe + --dsh-pet-dpi-probe 角色参数拉起 (开发形态仍是 Electron 二进制 + helper 脚本,行为不变) - 抽出 probeSpawnCommand 纯函数,并补源码契约测试钉住两种分支与绝对路径加载 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 新增 desktop-displays-contract.test.ts:deskGeometry() 必须复用 buildDeskGeometry(screen.getAllDisplays(), 主屏 id, platform);显示器变化经 pet:displays 推送,渲染端就地 applyDeskGeometry + relayout - 与 desktop-geometry.test.ts / displays.test.ts 的多屏用例一起,作为单屏机器 上无法物理双屏时「多显示器边界判定」的可复现证据 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 用 Playwright _electron 启动打包后的 DSH Pet.exe(helper 角色),经 mock 宿主 断言窗口数等于宠物数、内容区尺寸按配置 size 落定、页面可见且无未捕获错误 - mock 宿主记录全部应答状态,素材 4xx/5xx 直接失败;动画 video 实际解出帧才算通过 - 非 Windows 或未设置 DSH_PET_PACKAGED_EXE 时跳过并打印可操作提示 - 新增 package.json 的 test:packaged 独立入口,不改动 test:ui 语义 Co-Authored-By: Claude Code <noreply@anthropic.com>
打包宿主自身就是 Electron 进程,原先用 process.versions.electron 判定 「是不是 DSH 桌面应用」恒为真,菜单项错成「打开 DeepSeek Harness」并去 唤起不存在的 dsh:// 协议。 - 新增 DSH_PET_HOST_KIND(desktop / site / packaged)与纯函数 resolveHostKind / openTargetForHostKind:显式值优先,未设置时才回退到 Electron 嗅探(仅兼容 DSH 启动插件、无法注入环境变量的形态)。 - desktop/main.mjs 在启动 standalone 前显式设为 packaged;packaged 与 site 一样注入 DSH_PET_OPEN_TARGET=site,走现有带 token 的本机站点 URL。 - 测试覆盖三种形态的判定、嗅探回退,以及 packaged 必须得到 site 语义。 Co-Authored-By: Claude Code <noreply@anthropic.com>
- desktop/main.mjs 只在宿主角色、启动服务之前取单实例锁;拿不到锁立即退出, 不启动 standalone 服务、不拉起第二套 helper(壳与 DPI 探测角色不参与锁) - second-instance 经启动时序闸门:启动完成前的请求记为 pending,完成后合并执行一次, 自启延迟启动期间的手动双击不会提前弹窗 - 复用 helper 的 bridge 回调通道反向 POST /control:HelperProcess 记录请求行携带的 cb origin,壳遍历 windows Map 对全部宠物窗口 showInactive + 重钉置顶 + moveTop - startStandalone 句柄暴露 focusWindows,接上 focusDesktopWindows 登记表入口 - 新增 control-request / single-instance 纯逻辑单测与跨文件接线契约测试 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 新增 desktop/tray.mjs:宿主进程内创建唯一托盘,菜单模板复用 runtime/electron-helper/tray-menu.js,动作分发复用 lib/tray-actions.js; 配置读取与 display 写回走本机 HTTP(带 x-dsh-pet-token) - 新增 src/host/tray-actions.ts:动作分发、宠物拍平、display 翻转、 运行时 settingsUrl 校验、数据目录/图标路径与使用说明纯逻辑 - startStandalone 句柄暴露 token(与 settingsUrl 同源),供托盘调用 POST /dsh-pet-7340/pet-display;运行时文件断言同步覆盖 - 打包形态桌面壳不再自建托盘(DSH_PET_PACKAGED=1),插件形态保持原行为 - 退出先销毁托盘,再走 handle.shutdown(释放 effect → 关服务 → 清运行时文件), 完成后 app.exit(0);数据目录固定为 <DSH_HOME>/dsh-pet - 托盘创建不阻塞 ESM 入口求值,避免与 app.whenReady() 死锁 - 测试新增 32 个:动作分发/拍平/路径/说明 19 个,跨进程接线契约 13 个 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 抽出 runtime-settings 模块:运行时状态文件的解析、pid/端口/URL 一致性校验与过期判定 - 宠物右键菜单按可用性注入「AI 设置…」,点击时重新校验后交给系统浏览器,缺失/过期弹可读提示 - 托盘改用同一份读取/校验逻辑,点击时重新读取;过期提示不再打开旧 URL - 修正独立模式横幅中与事实不符的「右键打开 AI 设置」提示 - 新增运行时状态单测与跨进程接线契约测试 Co-Authored-By: Claude Code <noreply@anthropic.com>
- 新增 src/host/autostart.ts:登录项适配层(读写恒带 --autostart,勾选态含 任务管理器禁用态)、首次启动只初始化一次(~/.dsh/dsh-pet/autostart-initialized)、 自启延迟解析(默认 4000ms,DSH_PET_AUTOSTART_DELAY_MS 可覆盖、非法值回落) - desktop/main.mjs:首次以宿主启动时写一次系统登录项;--autostart 时延迟后再启动 standalone,期间不创建任何窗口;宿主启动改为不阻塞入口求值,延迟期间双击的第二个 进程立即退出(实测 150ms),pending 唤回在服务就绪后执行 - desktop/tray.mjs:自启勾选改走同一适配层,读系统真实状态 - NSIS:nsis.include + customUnInstall 卸载删除 HKCU Run 项;升级安装 (isUpdated)不清除,避免升级后自启静默丢失 - 测试:新增 autostart.test.ts(16)/ autostart-wiring.test.ts(11), 更新托盘接线契约 Co-Authored-By: Claude Code <noreply@anthropic.com>
解决 desktop/tray.mjs 与 tsdown.config.mjs 冲突:保留 ticket 07 的 runtime-settings 读取,同时保留 ticket 09 的登录项适配层与 autostart 入口; autostart.ts 的路径函数改从 runtime-settings 引入。 Co-Authored-By: Claude Code <noreply@anthropic.com>
- README 新增「Windows 安装版」:安装/首次启动(SmartScreen)/可用与不可用 功能/数据目录/开机自启/托盘/卸载,以及维护者的 npm run dist 构建说明 - 修正根 README 与包 README 的「独立运行」不可用清单:碎碎念与对话可在 AI 设置页配置 API 后使用,不可用项改为余额/DSH 会话工作状态/系统通知 - prepack-check 的体积 walk 跳过 dist/,避免安装包产物撑爆 npm 包体检查 Co-Authored-By: Claude Code <noreply@anthropic.com>
- README:安装版宿主自己的 Electron 配置目录改为 %APPDATA%\DSH Pet(与 productName / HKCU Run 值一致),卸载小节的保留目录同步修正;helper 的 %APPDATA%\dsh-pet-electron-helper 描述不变。 - helperLaunchPlan:打包形态下先检查 DSH_PET_ELECTRON_PATH。非空且指向存在的 文件时改用「外部 Electron 二进制 + asar 内 helper 入口」的显式覆盖计划 (buildLaunchPlan packaged:false);为空或路径不存在时保持应用自身 exe + --dsh-pet-helper 的内置运行时计划。两个分支都不触发下载。 - 新增 packagedElectronOverride 纯函数与单测,覆盖路径存在 / 不存在 / 空串; helperLaunchPlan 补打包形态显式覆盖与不下载分支的测试。 Co-Authored-By: Claude Code <noreply@anthropic.com>
- prepack-check 必需文件补上 main.js 顶层 require 的 probe-command.js 与 control-request.js,并新增按源码 require 核对的清单契约测试 - NSIS customInstall 在从未初始化过时写入 HKCU Run(值名与值数据与 Electron 43 实测格式逐字一致)并落 autostart-initialized 标记:安装时取消「立即运行」 也能开机自启;marker 存在时保持用户选择,重装/升级不写回 - 独立模式 CLI 显式声明 DSH_PET_HOST_KIND=site,不再依赖嗅探回退 Co-Authored-By: Claude Code <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.