diff --git a/CLAUDE.md b/CLAUDE.md index b446685d..c13444f5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,6 +20,8 @@ npm >=11.17 blocks dependency install scripts until they're approved, which woul `postinstall` runs `@electron/rebuild` so `node-pty` matches Electron, not the host Node. `package.json` overrides `node-abi` so rebuild knows this Electron major. On Windows that compile needs **admin rights** to install or modify Visual Studio 2022 Build Tools, plus the **MSVC v143 Spectre-mitigated libs** component (`MSB8040` if it is missing). Do not strip `SpectreMitigation` from `binding.gyp`. Git Bash/MinGW is not a substitute. Details: [README.md](./README.md) (Install → Windows). +Agent shells on Windows (Claude Code) may set `NoDefaultCurrentDirectoryInExePath=1`, which makes node-pty's gyp step fail with `'GetCommitHash.bat' is not recognized`. Unset it for `npm ci` / `npm run build:win*`. + Machines without admin do not `npm install` from git. Produce a portable folder on a VS machine with `npm run build:win` and copy `dist/win-unpacked`. That path is run-only (`DevTool.exe`); it does not unlock `npm run dev`. ## Windows spawn PATH diff --git a/README.md b/README.md index 34cf4278..f7fea669 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A desktop application for managing development workspaces. Organize projects, ta Built with Electron, React, and TypeScript. -Windows support (Git Bash terminals, portable Node, `.cmd` agent shims) was contributed from the [TeleporterGuy/DevTool](https://github.com/TeleporterGuy/DevTool) fork. Their Windows/Pi direction is in [ROADMAP.md](./ROADMAP.md); a company-deploy security snapshot is in [SECURITY.md](./SECURITY.md). +Windows support (Git Bash terminals, portable Node, `.cmd` agent shims) was contributed from the [join3r/claude-project](https://github.com/join3r/claude-project) fork. Their Windows/Pi direction is in [ROADMAP.md](./ROADMAP.md); a company-deploy security snapshot is in [SECURITY.md](./SECURITY.md). ## Features @@ -110,7 +110,23 @@ Limits of this path: - It is **run-only**. You cannot `npm run dev` or change the Electron native addon without a VS build machine. - Architecture must match (x64 build for x64 Windows). -- This is a folder, not a Setup.exe. `electron-winstaller` stays unapproved until an installer is actually required. The portable `DevTool.exe` is unsigned (`signAndEditExecutable` is off so the build does not need Windows code-sign tools). +- The portable `DevTool.exe` is unsigned. The build still stamps DevTool's icon and version resources onto it (an `afterPack` hook, `scripts/win-rcedit.cjs`, runs the `rcedit` npm package; no certificate), so Task Manager and file properties say DevTool, not Electron. + +#### Windows installer (per-user Setup.exe) + +```bash +npm run build:win:setup +``` + +That writes `dist/DevTool-Setup-.exe` (per-user NSIS installer: no admin, installs under `%LOCALAPPDATA%\Programs\DevTool`, adds a Start Menu shortcut) and `dist/DevTool--win.zip` (the portable folder, zipped). The portable folder from `npm run build:win` stays the no-admin escape hatch. Uninstalling never touches `~/.devtool`. It is electron-builder NSIS, so `electron-winstaller` stays unapproved. + +Both are **unsigned** until a code-signing certificate exists. SmartScreen will warn: **More info → Run anyway**. + +Releases are cut by hand on the Windows build machine: `npm run release:win` builds both and uploads them as a **draft** GitHub Release (needs `gh` logged in); publish the draft on GitHub. With a certificate, `npm run release:win -- --signed` (see `scripts/sign-win.cjs` for `DEVTOOL_SIGN_CMD` / `DEVTOOL_PUBLISHER_NAME`) also uploads `latest.yml`, which lets signed installs update themselves. + +#### Updates + +Packaged builds check `github.com/join3r/claude-project/releases` at launch and every few hours (Settings → Updates, or the menu's **Check for Updates…**; the automatic check can be turned off). Unsigned builds — the portable folder, an unsigned Setup.exe, macOS/Linux dirs — never replace themselves: they say a new version exists and open its release page. Only a signed Setup.exe install downloads and installs updates on its own. ### Development @@ -125,6 +141,7 @@ Starts the app in development mode with hot reload. On Windows this still needs ```bash npm run build # Typecheck, then production JS/CSS bundle npm run build:win # Portable Windows folder (dist/win-unpacked) +npm run build:win:setup # Per-user Setup.exe + portable zip (dist/) npm run build:mac # Package macOS app npm run build:linux # Package Linux app ``` diff --git a/ROADMAP.md b/ROADMAP.md index 68e0d71c..4828f5bc 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -26,7 +26,7 @@ Company-deploy security snapshot (what this app actually is on a workstation): [ Stay on **0.x** until the app is something you would tell a friend to unzip. **1.0.0** is that call, not “Phase 5 finished.” -`package.json` is **0.5.1** (Phase 4.5 agent context links, a patch on Phase 4's `0.5.0`, like 1.3 / 1.4). Phase 2 landed without tagging `0.4.0` and stayed **0.3.2**, so Phase 3 used that skipped minor instead of jumping to `0.5.0`. Shape: +`package.json` is **0.6.0** (Phase 5 packaging + app identity). Phase 2 landed without tagging `0.4.0` and stayed **0.3.2**, so Phase 3 used that skipped minor instead of jumping to `0.5.0`. Shape: | Part | Meaning | | --- | --- | @@ -46,7 +46,7 @@ Work inside a phase is `0.x.y`; shipping the phase is the next `0.(x+1).0`. | Phase 3 done | `0.4.0` | | Phase 4 done | `0.5.0` (native `.ipynb` tabs) | | Phase 4.5 (agent context links) | `0.5.1` (tagged; not a numbered bump) | -| Phase 5 (packaging + app identity) | `0.6.0`+ (icon / name / NSIS / signing / updater as you tag them) | +| Phase 5 done (packaging + app identity) | `0.6.0` (signing dormant until a certificate; a signed build is a `0.6.x` patch) | | Phase 6 (Pi chat tab) | `0.7.0` | LSP is parked (see Ideas); it does not get a numbered phase or a minor. Phase 6 is the Pi chat tab; there is no Phase 7 until something else earns one. Phase 0.5 does not get a version. Ideas in the parking lot do not get a version until they are pulled into a phase. @@ -66,7 +66,7 @@ Already useful, keep it: Known gaps this fork must treat as work, not surprises: -- Windows packaging is a portable folder (`npm run build:win` → `dist/win-unpacked`), not a Setup.exe. That folder stays the no-admin escape hatch. An installer is **Phase 5** (electron-builder NSIS, not `electron-winstaller`). From-source `npm install` on Windows still needs admin + VS Build Tools + Spectre libs (see README). +- Windows packaging: the portable folder (`npm run build:win` → `dist/win-unpacked`) stays the no-admin escape hatch; Phase 5 added a per-user NSIS Setup.exe (`npm run build:win:setup`). Both are unsigned until a certificate exists. From-source `npm install` on Windows still needs admin + VS Build Tools + Spectre libs (see README). - Local Windows terminals are Git Bash (`Git\bin\bash.exe --login -i`, auto-detect; Settings can set a `bash.exe` path). PowerShell and Command Prompt are not product surfaces. Login-shell env **is** captured in `shell-env.ts`; do not copy that Unix PATH onto `process.env.PATH` (ConPTY `cmd.exe` lookup breaks — see AGENTS.md). - POSIX assumptions: worktree paths, hook inject (`curl` + `python3`). Remote Pi extension lives under `$HOME/.devtool-remote/` (Phase 2 moved it off `/tmp`). @@ -342,7 +342,7 @@ Tried and dropped during testing: a bare `path (lines …)` without `@` (Claude --- -## Phase 5 — Packaging, distribution, app identity +## Phase 5 — Packaging, distribution, app identity — done (`0.6.0`) Was going to sit behind language servers as a later phase. LSP is parked, so packaging is the next numbered phase after native notebooks (and the 4.5 context-links patch). **Packaging and making the app look like DevTool, not Electron.** @@ -361,11 +361,21 @@ Items 2–3 are small and independent of the certificate; they can tag as `0.5.x Software Center / MSI may be a **separate IT artifact**, not this phase’s default output. +**Status (landed in `0.6.0`):** + +- **2. Icon** — landed. `build/icon.png` is generated from join3r's iOS app icon (`npm run make-icon` → `scripts/make-icon.mjs`: macOS grid, rounded corners, transparent padding); electron-builder derives `.ico` / `.icns`. Window icon on Windows/Linux, Dock icon in macOS dev runs. +- **3. Name** — landed. `app.setName('DevTool')` with userData pinned to its old path (dev stays on `/devtool`, not merged into the packaged `DevTool` profile). Dev `Electron.app` plist gets `CFBundleName` / `CFBundleDisplayName` (postinstall + `predev`). Windows: an `afterPack` hook (`scripts/win-rcedit.cjs`, `rcedit` npm package) stamps icon + version resources with no certificate (exe stays unsigned), and `setAppUserModelId('com.devtool.app')` (`.dev` for dev runs). `signAndEditExecutable` stays `false`: on Windows, electron-builder's own rcedit step unpacks `winCodeSign`, and 7-Zip fails on its macOS symlinks without Developer Mode / admin (seen on the build machine). electron-builder then only signs the NSIS installer/uninstaller, so the `afterPack` hook calls `scripts/sign-win.cjs` on `DevTool.exe` itself (no-op without `DEVTOOL_SIGN_CMD`). +- **4. NSIS** — landed. `npm run build:win:setup` → per-user `DevTool-Setup-.exe` (no admin, Start Menu shortcut, never touches `~/.devtool`) + portable zip. `npm run release:win` uploads a draft GitHub Release from the Windows box. +- **5. Signing** — wired, dormant. No certificate. `scripts/sign-win.cjs` runs `DEVTOOL_SIGN_CMD` when set (token/cloud-HSM certs sign through a command, not a `.pfx`). Options to look at when it matters: Certum Open Source Code Signing, SignPath Foundation (needs CI builds), Azure Artifact Signing (check eligibility). Stem (`join3r/stem`) does not sign on Windows either. +- **6. Updates** — landed, stem's model. Every packaged build checks GitHub Releases (Settings → Updates, Check for Updates…, opt-out toggle). Unsigned builds only announce a new version and open its page; only a `--signed` Setup.exe install self-updates via electron-updater. Unsigned releases carry no `latest.yml`. + Stay out of: language servers, conda GUI, a second Windows shell, reviving JupyterLab-in-browser. -**Verify:** on Windows — exe icon, taskbar, Task Manager name, Start Menu shortcut, installer per-user without admin, portable folder still runs. On macOS — `npm run dev` menu bar and Dock say DevTool with the DevTool icon; packaged `build:mac` the same. +**Verify:** unit tests for version compare, release-redirect parsing, update-mode decision (signed NSIS vs portable vs dev), manual-check states, the config toggle and the sign hook. **Windows (Windows 11, 2026-10-01) — done:** `build:win` exe carries DevTool icon + version resources (unsigned), taskbar / title bar / Task Manager say DevTool, Git Bash + Pi tabs start; `build:win:setup` installs per-user without UAC under `%LOCALAPPDATA%\Programs\DevTool`, Start Menu shortcut, pinning groups on one button, `app-update.yml` names the fork; Settings → Updates and Help → Check for Updates… report up to date (no releases yet); uninstall keeps `~/.devtool`; dev runs group separately and update checks are off. **macOS — done:** dev and packaged `build:mac` say DevTool with the icon; dev userData stays `devtool`; packaged update check is `manual`. Not run: offline check (unit-tested). + +**Closeout:** done. `package.json` is **0.6.0**. Authenticode + self-update are wired but dormant until a certificate (then `release:win --signed`, a `0.6.x` patch). Next is Phase 6 (Pi chat tab). -**Effort:** icon + name are an evening; installer is days to a couple of weeks; signing + updater depend on the certificate. Ships as **`0.6.0`+** (tag slices as you actually copy them). +**Effort:** icon + name an evening; installer + updater a few evenings; signing waits on a certificate. Shipped as **`0.6.0`**. --- @@ -410,7 +420,7 @@ Parking lot. Do not start these instead of the numbered phases. Several items al | Language servers (Python, Markdown) | Parked. Monaco covers edit/view; analysis belongs in Pi. Optional sugar only if Monaco-without-Pi is painful. No minor reserved. | | Native notebook cells + kernel | Phase 4 (`0.5.0`) | | Agent context links from editor/notebook (Ctrl+L / Ctrl+Shift+L) | Phase 4.5 (`0.5.1`) | -| Windows installer + Authenticode + auto-update + app icon + app name (not "Electron") | Phase 5 | +| Windows installer + Authenticode + auto-update + app icon + app name (not "Electron") | Phase 5 (`0.6.0`; signing dormant until a certificate) | | Open workspace in VS Code / Cursor | Phase 1.2 | | Spyder as an external IDE | after Phase 3 | | Config-dir `0700`, scrollback id, IPC cwd allow-list | Parking lot (deferred; not packaging) | @@ -455,7 +465,7 @@ Keep upstream `master` as a remote (`upstream`) and rebase or merge periodically 9. Conda env picker on spawn (Phase 3). **Done** in `0.4.0`. 10. Native in-app `.ipynb` notebooks (Phase 4). **Done** in `0.5.0`. Not a JupyterLab browser launcher. 11. Agent context links from editor/notebook (Phase 4.5): Ctrl+L (selection, or current line / cell) and Ctrl+Shift+L (whole file) insert a compact `@path:lines` / cell / file link into the agent terminal or Claude chat. Tags `0.5.1`. -12. Packaging + app identity (Phase 5): keep portable `dist/win-unpacked`, app icon, app name (not "Electron" in the macOS menu bar / Windows Task Manager), then per-user NSIS Setup.exe + Start Menu, then Authenticode, then auto-update. Ships as `0.6.0`+. Do not insert LSP between 11 and 12. Do not revive browser JupyterLab. +12. Packaging + app identity (Phase 5): keep portable `dist/win-unpacked`, app icon, app name (not "Electron" in the macOS menu bar / Windows Task Manager), then per-user NSIS Setup.exe + Start Menu, then Authenticode, then auto-update. **Done** in `0.6.0` (signing/self-update dormant until a certificate). Do not revive browser JupyterLab. 13. Pi chat tab (Phase 6): `pi --mode rpc` in main, agent-neutral chat model shared with Claude chat, extension dialogs as cards. Ships as `0.7.0`. Skip a step only if the previous phase already includes it by accident (e.g. PATH work that makes conda trivial). @@ -498,7 +508,7 @@ Work machine constraints to re-test every phase: Git Bash, portable Node zip, Pi | 3 | `0.4.0` (shipped) | Conda picker on spawn | 1–2 weeks | | 4 | `0.5.0` (shipped) | Native `.ipynb` tabs (Monaco cells + conda kernel) | a focused pass | | 4.5 | `0.5.1` (shipped) | Ctrl+L selection (or line / cell) and Ctrl+Shift+L whole file → compact link in agent terminal / Claude chat | a short pass | -| 5 | `0.6.0`+ | Portable folder kept; app icon + DevTool name; per-user NSIS Setup.exe; then Authenticode; then auto-update | icon/name an evening; installer days–weeks; signing/updater depend on the cert | +| 5 | `0.6.0` (shipped) | Portable folder kept; app icon + DevTool name; per-user NSIS Setup.exe; update checks; Authenticode + self-update wired, dormant until a cert | a few evenings | | 6 | `0.7.0` | Pi chat tab over `pi --mode rpc` (timeline, composer, extension dialogs, resume) | 2–3 weeks of evenings | Language servers stay in the parking lot. They are not a numbered phase. There is no Phase 7 until something else earns one. diff --git a/SECURITY.md b/SECURITY.md index b96ad977..618e5877 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -2,7 +2,7 @@ Snapshot of what this fork actually is, from a security point of view, before putting it on company machines. Dated against **`0.5.0`** (Phase 4 native notebooks). Not a pentest. Not a promise that later phases stay clean. -This repository is a fork of [join3r/claude-project](https://github.com/join3r/claude-project). Work stays on [TeleporterGuy/DevTool](https://github.com/TeleporterGuy/DevTool). Product direction is in [ROADMAP.md](./ROADMAP.md). +This repository is a fork of [join3r/claude-project](https://github.com/join3r/claude-project). Work stays on [join3r/claude-project](https://github.com/join3r/claude-project). Product direction is in [ROADMAP.md](./ROADMAP.md). --- @@ -22,7 +22,7 @@ It will: It will **not**: - Sandbox Pi (or Claude/Codex). Models, API keys, and base URL stay in Pi’s own config (Phase 0.5). -- Add SSO, audit logs, DLP, or an update channel. +- Add SSO, audit logs, or DLP. The update check (below) talks to public GitHub Releases, not a managed company channel. - Replace company SSH/PKI policy. Host-key checking is TOFU (`accept-new`). If “an AI CLI with the developer’s credentials, on company source” is already a no, this app does not make that safer. If that is already accepted for a normal Git Bash window, the rest of this file is the *extra* surface DevTool adds. @@ -70,7 +70,9 @@ Severity is “what a company security review usually does with it,” not CVSS. ### Blocker -**Unsigned Windows portable folder.** `package.json` sets `signAndEditExecutable: false`. `npm run build:win` yields `dist/win-unpacked` with no Authenticode publisher. SmartScreen, AppLocker, WDAC, and “who shipped this?” all fire. There is no installer, no auto-update, no Electron fuses (`onlyLoadAppFromAsar`, `embeddedAsarIntegrityValidation`, `runAsNode`, cookie encryption). Anyone who can write into that folder can replace binaries. +**Unsigned Windows builds.** No certificate is configured: `npm run build:win` (`dist/win-unpacked`) and `npm run build:win:setup` (per-user NSIS Setup.exe) carry DevTool's icon and version resources but no Authenticode publisher. SmartScreen, AppLocker, WDAC, and “who shipped this?” all fire. No Electron fuses (`onlyLoadAppFromAsar`, `embeddedAsarIntegrityValidation`, `runAsNode`, cookie encryption). Anyone who can write into the install folder (per-user: `%LOCALAPPDATA%\Programs\DevTool`) can replace binaries. + +**Update check.** Packaged builds request `https://github.com/join3r/claude-project/releases/latest` at launch and every 6 h (Settings → Updates turns it off). Unsigned builds only report a newer version and open its page; they never download or replace themselves. Only a build signed through `scripts/sign-win.cjs` and installed with Setup.exe self-updates via electron-updater, which checks the downloaded installer's publisher. Unsigned releases ship without `latest.yml`, so no install self-updates to one. ### High diff --git a/build/icon.png b/build/icon.png new file mode 100644 index 00000000..7f0e2e50 Binary files /dev/null and b/build/icon.png differ diff --git a/eslint.config.mjs b/eslint.config.mjs index acd28d7d..d5ecb72e 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -55,5 +55,11 @@ export default tseslint.config( // Test doubles cast freely (window.api mocks, partial fixtures). '@typescript-eslint/no-explicit-any': 'off' } + }, + { + // CommonJS hooks electron-builder loads with require() (scripts/sign-win.cjs). + files: ['**/*.cjs'], + languageOptions: { sourceType: 'commonjs' }, + rules: { '@typescript-eslint/no-require-imports': 'off' } } ) diff --git a/package-lock.json b/package-lock.json index 6c27b4da..800a8bea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "devtool", - "version": "0.5.1", + "version": "0.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "devtool", - "version": "0.5.1", + "version": "0.6.0", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -24,6 +24,7 @@ "@xterm/addon-webgl": "^0.19.0", "@xterm/xterm": "^6.0.0", "dompurify": "^3.3.3", + "electron-updater": "^6.8.9", "highlight.js": "^11.11.1", "lucide-react": "^1.14.0", "marked": "^17.0.5", @@ -55,6 +56,8 @@ "eslint-plugin-react-hooks": "^7.1.1", "globals": "^17.12.0", "jsdom": "^29.1.1", + "pngjs": "^7.0.0", + "rcedit": "^5.0.2", "tailwindcss": "^4.2.4", "typescript": "^5.9.3", "typescript-eslint": "^8.70.1", @@ -1064,21 +1067,6 @@ "node": ">=12.0.0" } }, - "node_modules/@electron/osx-sign/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/@electron/osx-sign/node_modules/isbinaryfile": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-4.0.10.tgz", @@ -1092,29 +1080,6 @@ "url": "https://github.com/sponsors/gjtorikian/" } }, - "node_modules/@electron/osx-sign/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/@electron/osx-sign/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/@electron/rebuild": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/@electron/rebuild/-/rebuild-4.2.0.tgz", @@ -3919,44 +3884,6 @@ "node": ">=8" } }, - "node_modules/app-builder-lib/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/app-builder-lib/node_modules/fs-extra/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/app-builder-lib/node_modules/fs-extra/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/app-builder-lib/node_modules/semver": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", @@ -3974,7 +3901,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", - "dev": true, "license": "Python-2.0" }, "node_modules/aria-query": { @@ -4291,44 +4217,6 @@ "node": ">=12.0.0" } }, - "node_modules/builder-util/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/builder-util/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/builder-util/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -4737,6 +4625,77 @@ "node": ">= 8" } }, + "node_modules/cross-spawn-windows-exe": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/cross-spawn-windows-exe/-/cross-spawn-windows-exe-1.2.0.tgz", + "integrity": "sha512-mkLtJJcYbDCxEG7Js6eUnUNndWjyUZwJ3H7bErmmtOYU/Zb99DyUkpamuIZE0b3bhmJyZ7D90uS6f+CGxRRjOw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/malept" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/npm-cross-spawn-windows-exe?utm_medium=referral&utm_source=npm_fund" + } + ], + "license": "Apache-2.0", + "dependencies": { + "@malept/cross-spawn-promise": "^1.1.0", + "is-wsl": "^2.2.0", + "which": "^2.0.2" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/cross-spawn-windows-exe/node_modules/@malept/cross-spawn-promise": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@malept/cross-spawn-promise/-/cross-spawn-promise-1.1.1.tgz", + "integrity": "sha512-RTBGWL5FWQcg9orDOCcp4LvItNzUPcyEU9bwaeJX0rJ1IQxzucC48Y0/sQLp/g6t99IQgAlGIaesJS+gTn7tVQ==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/malept" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/subscription/pkg/npm-.malept-cross-spawn-promise?utm_medium=referral&utm_source=npm_fund" + } + ], + "license": "Apache-2.0", + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "engines": { + "node": ">= 10" + } + }, + "node_modules/cross-spawn-windows-exe/node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/cross-spawn-windows-exe/node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/cross-spawn/node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -5023,44 +4982,6 @@ "dmg-license": "^1.0.11" } }, - "node_modules/dmg-builder/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/dmg-builder/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/dmg-builder/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/dmg-license": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/dmg-license/-/dmg-license-1.0.11.tgz", @@ -5227,44 +5148,6 @@ "electron-winstaller": "5.4.0" } }, - "node_modules/electron-builder/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/electron-builder/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/electron-builder/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/electron-publish": { "version": "26.8.1", "resolved": "https://registry.npmjs.org/electron-publish/-/electron-publish-26.8.1.tgz", @@ -5282,51 +5165,54 @@ "mime": "^2.5.2" } }, - "node_modules/electron-publish/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "node_modules/electron-to-chromium": { + "version": "1.5.307", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.307.tgz", + "integrity": "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==", "dev": true, + "license": "ISC" + }, + "node_modules/electron-updater": { + "version": "6.8.9", + "resolved": "https://registry.npmjs.org/electron-updater/-/electron-updater-6.8.9.tgz", + "integrity": "sha512-ZhVxM9iGONUpZGI1FxdMRgJjUFXi7AYGVa5PwKlO1tV1/4zDxQmfKpXOHVztKrd6L9rLcFjERvi1Mf2vxyTkig==", "license": "MIT", "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" + "builder-util-runtime": "9.7.0", + "fs-extra": "^10.1.0", + "js-yaml": "^4.1.0", + "lazy-val": "^1.0.5", + "lodash.escaperegexp": "^4.1.2", + "lodash.isequal": "^4.5.0", + "semver": "~7.7.3", + "tiny-typed-emitter": "^2.1.0" } }, - "node_modules/electron-publish/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, + "node_modules/electron-updater/node_modules/builder-util-runtime": { + "version": "9.7.0", + "resolved": "https://registry.npmjs.org/builder-util-runtime/-/builder-util-runtime-9.7.0.tgz", + "integrity": "sha512-g/kR520giAFYkSXTzcmF3kqQq7wi8F6N6SzeDgZrqTBN+VHdmgWOyTdD1yD7AATDId/yXLvuP34CxW46/BwCdw==", "license": "MIT", "dependencies": { - "universalify": "^2.0.0" + "debug": "^4.3.4", + "sax": "^1.2.4" }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" + "engines": { + "node": ">=12.0.0" } }, - "node_modules/electron-publish/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", + "node_modules/electron-updater/node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, "engines": { - "node": ">= 10.0.0" + "node": ">=10" } }, - "node_modules/electron-to-chromium": { - "version": "1.5.307", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.307.tgz", - "integrity": "sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==", - "dev": true, - "license": "ISC" - }, "node_modules/electron-vite": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/electron-vite/-/electron-vite-5.0.0.tgz", @@ -6151,6 +6037,41 @@ "node": ">= 0.8" } }, + "node_modules/fs-extra": { + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/fs-extra/node_modules/jsonfile": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz", + "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==", + "license": "MIT", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/fs-extra/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "license": "MIT", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -6783,6 +6704,22 @@ "node": ">= 0.10" } }, + "node_modules/is-docker": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/is-docker/-/is-docker-2.2.1.tgz", + "integrity": "sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ==", + "dev": true, + "license": "MIT", + "bin": { + "is-docker": "cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -6829,6 +6766,19 @@ "license": "MIT", "peer": true }, + "node_modules/is-wsl": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-2.2.0.tgz", + "integrity": "sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-docker": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/isbinaryfile": { "version": "5.0.7", "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-5.0.7.tgz", @@ -6907,7 +6857,6 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", - "dev": true, "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -7067,7 +7016,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/lazy-val/-/lazy-val-1.0.5.tgz", "integrity": "sha512-0/BnGCCfyUMkBpeDgWihanIAF9JmZhHBgUhEqzvf+adhNGLoP6TaiI5oF8oyb3I45P+PcnrqihSf01M0l0G5+Q==", - "dev": true, "license": "MIT" }, "node_modules/levn": { @@ -7368,6 +7316,19 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.escaperegexp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.escaperegexp/-/lodash.escaperegexp-4.1.2.tgz", + "integrity": "sha512-TM9YBvyC84ZxE3rgfefxUWiQKLilstD6k7PTGt6wfbtXF8ixIJLOL3VYyV/z+ZiPLsVxAsKAFVwWlWeb2Y8Yyw==", + "license": "MIT" + }, + "node_modules/lodash.isequal": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", + "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", + "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.", + "license": "MIT" + }, "node_modules/lowercase-keys": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-2.0.0.tgz", @@ -8130,12 +8091,13 @@ } }, "node_modules/pngjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", - "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-7.0.0.tgz", + "integrity": "sha512-LKWqWJRhstyYo9pGvgor/ivk2w94eSjE3RGVuzLGlr3NmD8bf7RcYGze1mNdEHRP6TRP6rMuDHk5t44hnTRyow==", + "dev": true, "license": "MIT", "engines": { - "node": ">=10.13.0" + "node": ">=14.19.0" } }, "node_modules/postcss": { @@ -8419,6 +8381,15 @@ "node": ">=8" } }, + "node_modules/qrcode/node_modules/pngjs": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", + "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/qrcode/node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", @@ -8551,6 +8522,20 @@ "url": "https://opencollective.com/express" } }, + "node_modules/rcedit": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/rcedit/-/rcedit-5.0.2.tgz", + "integrity": "sha512-dgysxaeXZ4snLpPjn8aVtHvZDCx+aRcvZbaWBgl1poU6OPustMvOkj9a9ZqASQ6i5Y5szJ13LSvglEOwrmgUxA==", + "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn-windows-exe": "^1.1.0" + }, + "engines": { + "node": ">= 22.12.0" + } + }, "node_modules/react": { "version": "19.2.4", "resolved": "https://registry.npmjs.org/react/-/react-19.2.4.tgz", @@ -8790,7 +8775,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/sax/-/sax-1.5.0.tgz", "integrity": "sha512-21IYA3Q5cQf089Z6tgaUTr7lDAyzoTPx5HRtbhsME8Udispad8dC/+sziTNugOEx54ilvatQ9YCzl4KQLPcRHA==", - "dev": true, "license": "BlueOak-1.0.0", "engines": { "node": ">=11.0.0" @@ -9324,44 +9308,6 @@ "fs-extra": "^10.0.0" } }, - "node_modules/temp-file/node_modules/fs-extra": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", - "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/temp-file/node_modules/jsonfile": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz", - "integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==", - "dev": true, - "license": "MIT", - "dependencies": { - "universalify": "^2.0.0" - }, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, - "node_modules/temp-file/node_modules/universalify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", - "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 10.0.0" - } - }, "node_modules/tiny-async-pool": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/tiny-async-pool/-/tiny-async-pool-1.3.0.tgz", @@ -9382,6 +9328,12 @@ "semver": "bin/semver" } }, + "node_modules/tiny-typed-emitter": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-typed-emitter/-/tiny-typed-emitter-2.1.0.tgz", + "integrity": "sha512-qVtvMxeXbVej0cQWKqVSSAHmKZEHAvxdF8HEUBFWts8h+xEo5m/lEiPakuyZ3BnCBjOD8i24kzNOiOLLgsSxhA==", + "license": "MIT" + }, "node_modules/tinybench": { "version": "2.9.0", "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", diff --git a/package.json b/package.json index 593a91a8..1798634f 100644 --- a/package.json +++ b/package.json @@ -1,32 +1,40 @@ { "name": "devtool", - "version": "0.5.1", + "version": "0.6.0", "description": "Development workspace manager", "main": "out/main/index.js", "private": true, "scripts": { + "predev": "node scripts/patch-dev-electron-plist.mjs", "dev": "electron-vite dev", + "predev:cdp": "node scripts/patch-dev-electron-plist.mjs", "dev:cdp": "DEVTOOL_CDP_PORT=9222 electron-vite dev", "build": "npm run typecheck && electron-vite build", "build:mac": "npm run build && electron-builder --mac --dir", "build:linux": "npm run build && electron-builder --linux --dir", "build:win": "npm run build && electron-builder --win --dir", + "build:win:setup": "npm run build && electron-builder --win nsis zip --publish never", + "release:win": "node scripts/release-win.mjs", "typecheck": "tsc --noEmit -p tsconfig.typecheck.json", "lint": "eslint .", "test": "vitest run", "test:watch": "vitest", "test:notebook-live": "vitest run tests/notebook-kernel.live.test.ts", "postinstall": "node scripts/ensure-electron.mjs && npx @electron/rebuild -m . && node scripts/patch-dev-electron-plist.mjs", - "prepare": "node scripts/setup-git-hooks.mjs" + "prepare": "node scripts/setup-git-hooks.mjs", + "make-icon": "node scripts/make-icon.mjs" }, "build": { "appId": "com.devtool.app", "productName": "DevTool", + "copyright": "Copyright (c) join3r and TeleporterGuy. MIT License.", "directories": { - "output": "dist" + "output": "dist", + "buildResources": "build" }, "files": [ "out/**/*", + "build/icon.png", "node_modules/**/*", "!node_modules/.cache", "!node_modules/@anthropic-ai/claude-agent-sdk-*/**" @@ -45,17 +53,40 @@ "extendInfo": { "NSMicrophoneUsageDescription": "DevTool forwards microphone access to terminal apps you run inside it, such as Claude Code's voice mode.", "NSCameraUsageDescription": "DevTool forwards camera access to terminal apps you run inside it that request video input." - } + }, + "icon": "build/icon.png" }, "linux": { "target": "dir", - "category": "Development" + "category": "Development", + "icon": "build/icon.png" }, "win": { "target": "dir", - "signAndEditExecutable": false + "icon": "build/icon.png", + "signAndEditExecutable": false, + "signtoolOptions": { + "sign": "scripts/sign-win.cjs" + } + }, + "nsis": { + "oneClick": false, + "perMachine": false, + "allowElevation": false, + "allowToChangeInstallationDirectory": true, + "createDesktopShortcut": false, + "createStartMenuShortcut": true, + "shortcutName": "DevTool", + "deleteAppDataOnUninstall": false, + "artifactName": "DevTool-Setup-${version}.${ext}" + }, + "publish": { + "provider": "github", + "owner": "join3r", + "repo": "claude-project" }, - "electronDist": "node_modules/electron/dist" + "electronDist": "node_modules/electron/dist", + "afterPack": "scripts/win-rcedit.cjs" }, "keywords": [], "author": "", @@ -82,6 +113,8 @@ "eslint-plugin-react-hooks": "^7.1.1", "globals": "^17.12.0", "jsdom": "^29.1.1", + "pngjs": "^7.0.0", + "rcedit": "^5.0.2", "tailwindcss": "^4.2.4", "typescript": "^5.9.3", "typescript-eslint": "^8.70.1", @@ -103,6 +136,7 @@ "@xterm/addon-webgl": "^0.19.0", "@xterm/xterm": "^6.0.0", "dompurify": "^3.3.3", + "electron-updater": "^6.8.9", "highlight.js": "^11.11.1", "lucide-react": "^1.14.0", "marked": "^17.0.5", diff --git a/scripts/make-icon.mjs b/scripts/make-icon.mjs new file mode 100644 index 00000000..60d013f2 --- /dev/null +++ b/scripts/make-icon.mjs @@ -0,0 +1,73 @@ +#!/usr/bin/env node +// Builds the desktop app icon (build/icon.png) from the iOS app icon join3r +// designed. The iOS artwork is full-bleed and opaque — iOS masks it itself — +// so for desktop it is scaled to the macOS Big Sur grid (824px body on a +// 1024px canvas), given rounded corners, and padded with transparency. +// electron-builder derives .icns / .ico from this one PNG. +// +// One-shot: run by hand after the iOS artwork changes, commit the output. +// node scripts/make-icon.mjs +import { readFileSync, writeFileSync } from 'node:fs' +import { resolve } from 'node:path' +import { PNG } from 'pngjs' + +const SOURCE = resolve('ios/DevTool/Assets.xcassets/AppIcon.appiconset/AppIcon-1024.png') +const OUTPUT = resolve('build/icon.png') +const CANVAS = 1024 +const BODY = 824 +const RADIUS = 185 + +const src = PNG.sync.read(readFileSync(SOURCE)) +const out = new PNG({ width: CANVAS, height: CANVAS }) +const offset = (CANVAS - BODY) / 2 +const scale = src.width / BODY + +/** Area-average of the source pixels that map onto body pixel (x, y). */ +function sample(x, y) { + const x0 = x * scale + const y0 = y * scale + const x1 = x0 + scale + const y1 = y0 + scale + const acc = [0, 0, 0, 0] + let weight = 0 + for (let sy = Math.floor(y0); sy < Math.ceil(y1); sy++) { + const wy = Math.min(y1, sy + 1) - Math.max(y0, sy) + for (let sx = Math.floor(x0); sx < Math.ceil(x1); sx++) { + const wx = Math.min(x1, sx + 1) - Math.max(x0, sx) + const w = wx * wy + const i = (Math.min(sy, src.height - 1) * src.width + Math.min(sx, src.width - 1)) * 4 + for (let c = 0; c < 4; c++) acc[c] += src.data[i + c] * w + weight += w + } + } + return acc.map((v) => v / weight) +} + +/** Coverage (0..1) of pixel (x, y) by the rounded-rect body, anti-aliased over one pixel. */ +function coverage(x, y) { + const cx = x + 0.5 + const cy = y + 0.5 + const half = BODY / 2 + const qx = Math.abs(cx - half) - (half - RADIUS) + const qy = Math.abs(cy - half) - (half - RADIUS) + const outside = Math.hypot(Math.max(qx, 0), Math.max(qy, 0)) + const inside = Math.min(Math.max(qx, qy), 0) + const dist = outside + inside - RADIUS + return Math.min(Math.max(0.5 - dist, 0), 1) +} + +for (let y = 0; y < BODY; y++) { + for (let x = 0; x < BODY; x++) { + const a = coverage(x, y) + if (a === 0) continue + const [r, g, b, srcA] = sample(x, y) + const i = ((y + offset) * CANVAS + (x + offset)) * 4 + out.data[i] = Math.round(r) + out.data[i + 1] = Math.round(g) + out.data[i + 2] = Math.round(b) + out.data[i + 3] = Math.round(a * srcA) + } +} + +writeFileSync(OUTPUT, PNG.sync.write(out)) +console.log(`Wrote ${OUTPUT}`) diff --git a/scripts/patch-dev-electron-plist.mjs b/scripts/patch-dev-electron-plist.mjs index bffbd6b0..1b1e6802 100644 --- a/scripts/patch-dev-electron-plist.mjs +++ b/scripts/patch-dev-electron-plist.mjs @@ -1,8 +1,14 @@ #!/usr/bin/env node -// Patches the dev-mode Electron binary's Info.plist so the macOS permission -// prompts during `npm run dev` show DevTool-specific copy instead of the -// generic Electron defaults. Packaged builds get the same text via -// electron-builder's `mac.extendInfo` config in package.json. +// Patches the dev-mode Electron binary's Info.plist so `npm run dev` looks like +// DevTool, not Electron: the bold menu-bar app name and Dock tooltip come from +// CFBundleName / CFBundleDisplayName of the running bundle, which in dev is +// node_modules/electron/dist/Electron.app — app.setName() cannot rename it. +// Also gives the macOS permission prompts DevTool-specific copy. Packaged builds +// get the name from `productName` and the prompt text from `mac.extendInfo` in +// package.json. +// +// Runs from postinstall and as predev (an `npm install` re-extracts Electron.app). +// Idempotent; a no-op off macOS or when the bundle is missing. import { execFileSync } from 'node:child_process' import { existsSync } from 'node:fs' import { platform } from 'node:os' @@ -16,6 +22,8 @@ const plist = resolve( if (!existsSync(plist)) process.exit(0) const entries = { + CFBundleName: 'DevTool', + CFBundleDisplayName: 'DevTool', NSMicrophoneUsageDescription: "DevTool forwards microphone access to terminal apps you run inside it, such as Claude Code's voice mode.", NSCameraUsageDescription: diff --git a/scripts/release-win.mjs b/scripts/release-win.mjs new file mode 100644 index 00000000..1fa28835 --- /dev/null +++ b/scripts/release-win.mjs @@ -0,0 +1,80 @@ +#!/usr/bin/env node +// Builds the Windows release on the local Windows box and uploads it as a DRAFT +// GitHub Release on join3r/claude-project. You publish the draft by hand. +// +// npm run release:win unsigned: Setup.exe + portable zip +// npm run release:win -- --signed signed: also latest.yml (the auto-update feed) +// npm run release:win -- --no-upload build only, print what would be uploaded +// +// Unsigned releases never carry latest.yml, so no installed copy self-updates to +// an unsigned build: installs only hear "x.y.z is available" through the +// releases/latest redirect (src/main/updates.ts, `manual` mode). A signed build +// is stamped `devtoolSigned: true` in its package.json, which is what flips an +// NSIS install into electron-updater (`auto` mode). +// +// --signed needs DEVTOOL_SIGN_CMD (see scripts/sign-win.cjs) and +// DEVTOOL_PUBLISHER_NAME (the certificate subject CN; electron-updater checks +// downloaded installers against it). Upload needs `gh` logged in (or GH_TOKEN). +import { spawnSync } from 'node:child_process' +import { existsSync, readFileSync } from 'node:fs' +import { join, resolve } from 'node:path' + +const REPO = 'join3r/claude-project' +const args = new Set(process.argv.slice(2)) +const signed = args.has('--signed') +const upload = !args.has('--no-upload') + +function fail(message) { + console.error(`release-win: ${message}`) + process.exit(1) +} + +function run(command, commandArgs) { + console.log(`> ${command} ${commandArgs.join(' ')}`) + // shell: npm / npx / gh are .cmd shims on Windows. + const result = spawnSync(command, commandArgs, { stdio: 'inherit', shell: process.platform === 'win32' }) + if (result.status !== 0) fail(`${command} exited with ${result.status ?? result.signal}`) +} + +if (process.platform !== 'win32') fail('run this on the Windows build machine') + +const { version } = JSON.parse(readFileSync(resolve('package.json'), 'utf8')) +const tag = `v${version}` + +const builderArgs = ['electron-builder', '--win', 'nsis', 'zip', '--publish', 'never'] +if (signed) { + if (!process.env.DEVTOOL_SIGN_CMD) fail('--signed needs DEVTOOL_SIGN_CMD (see scripts/sign-win.cjs)') + const publisher = process.env.DEVTOOL_PUBLISHER_NAME + if (!publisher) fail('--signed needs DEVTOOL_PUBLISHER_NAME (the certificate subject CN)') + builderArgs.push( + '-c.extraMetadata.devtoolSigned=true', + `-c.win.signtoolOptions.publisherName=${JSON.stringify(publisher)}` + ) +} else { + console.log('release-win: building UNSIGNED (no --signed); the release gets no latest.yml') +} + +run('npm', ['run', 'build']) +run('npx', builderArgs) + +const dist = resolve('dist') +const setup = join(dist, `DevTool-Setup-${version}.exe`) +const assets = [setup, `${setup}.blockmap`, join(dist, `DevTool-${version}-win.zip`)] +if (signed) { + run('signtool', ['verify', '/pa', setup]) + run('signtool', ['verify', '/pa', join(dist, 'win-unpacked', 'DevTool.exe')]) + assets.push(join(dist, 'latest.yml')) +} +for (const file of assets) { + if (!existsSync(file)) fail(`missing build output ${file}`) +} + +console.log(`\nRelease ${tag} (${signed ? 'signed' : 'unsigned'}):`) +for (const file of assets) console.log(` ${file}`) + +if (!upload) process.exit(0) +run('gh', [ + 'release', 'create', tag, ...assets, + '--repo', REPO, '--draft', '--title', tag, '--generate-notes' +]) +console.log(`\nDraft ${tag} created on ${REPO}. Review and publish it on GitHub.`) diff --git a/scripts/sign-win.cjs b/scripts/sign-win.cjs new file mode 100644 index 00000000..8bd27bb5 --- /dev/null +++ b/scripts/sign-win.cjs @@ -0,0 +1,36 @@ +// electron-builder custom Windows sign hook (package.json build.win.signtoolOptions.sign). +// +// No certificate exists yet, so by default this does nothing and the build stays +// unsigned — rcedit still stamps DevTool's icon and version resources on the exe. +// Code-signing keys now live on a hardware token or cloud HSM, not in a .pfx, so +// signing is a command rather than CSC_LINK: set DEVTOOL_SIGN_CMD to the signtool +// (or vendor tool) invocation with `{file}` where the path goes, e.g. +// +// DEVTOOL_SIGN_CMD='signtool sign /fd sha256 /tr http://time.certum.pl /td sha256 /n "Your Name" "{file}"' +// +// scripts/release-win.mjs --signed requires it and checks the result with +// `signtool verify /pa`. +const { execSync } = require('node:child_process') + +/** The shell command for one file, or null when signing is not configured. */ +function signCommand(file, template = process.env.DEVTOOL_SIGN_CMD) { + if (!template || !template.trim()) return null + if (!template.includes('{file}')) { + throw new Error('DEVTOOL_SIGN_CMD must contain {file} where the path to sign goes') + } + return template.split('{file}').join(file.replace(/"/g, '')) +} + +async function sign(configuration) { + const command = signCommand(configuration.path) + if (!command) { + console.log(` • not signing ${configuration.path} (DEVTOOL_SIGN_CMD is unset)`) + return + } + console.log(` • signing ${configuration.path}`) + execSync(command, { stdio: 'inherit' }) +} + +module.exports = sign +module.exports.default = sign +module.exports.signCommand = signCommand diff --git a/scripts/win-rcedit.cjs b/scripts/win-rcedit.cjs new file mode 100644 index 00000000..5779b2f6 --- /dev/null +++ b/scripts/win-rcedit.cjs @@ -0,0 +1,43 @@ +// electron-builder afterPack hook (package.json build.afterPack). +// +// Stamps DevTool's icon and version resources on DevTool.exe with the `rcedit` +// npm package. electron-builder can do this itself (win.signAndEditExecutable), +// but on Windows it fetches rcedit from the winCodeSign archive, and 7-Zip cannot +// unpack that archive's macOS symlinks without Developer Mode or admin. So +// signAndEditExecutable stays false and this hook does the resource edit instead. +// The exe stays unsigned either way. +const path = require('node:path') +const sign = require('./sign-win.cjs') + +async function afterPack(context) { + if (context.electronPlatformName !== 'win32') return + const { packager, appOutDir } = context + const { appInfo } = packager + const exe = path.join(appOutDir, `${appInfo.productFilename}.exe`) + // The .ico electron-builder already converted from build/icon.png. + const icon = await packager.getIconPath() + const { rcedit } = await import('rcedit') + console.log(` • stamping resources file=${exe}`) + await rcedit(exe, { + icon: icon ?? undefined, + 'file-version': appInfo.shortVersion || appInfo.buildVersion, + 'product-version': appInfo.shortVersionWindows || appInfo.getVersionInWeirdWindowsForm(), + 'version-string': { + ProductName: appInfo.productName, + FileDescription: appInfo.productName, + LegalCopyright: appInfo.copyright, + // package.json has no author, so overwrite Electron's "GitHub, Inc." and + // "electron.exe" rather than leave them in file properties. + CompanyName: appInfo.companyName || appInfo.productName, + InternalName: appInfo.productFilename, + OriginalFilename: path.basename(exe) + } + }) + // With signAndEditExecutable off, electron-builder no longer signs the app exe + // (only the NSIS installer/uninstaller), so sign it here after stamping. + // No-op unless DEVTOOL_SIGN_CMD is set. + await sign({ path: exe }) +} + +module.exports = afterPack +module.exports.default = afterPack diff --git a/src/main/app-runtime.ts b/src/main/app-runtime.ts index 2e3dbc62..ae440127 100644 --- a/src/main/app-runtime.ts +++ b/src/main/app-runtime.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, ipcMain, nativeTheme, powerSaveBlocker, safeStorage } from 'electron' +import { app, BrowserWindow, ipcMain, nativeTheme, powerSaveBlocker, safeStorage, shell } from 'electron' import fs from 'fs' import os from 'os' import path from 'path' @@ -51,6 +51,10 @@ import { NotebookKernelManager } from './notebook-kernel' import { safeWebContentsSend } from './safe-ipc-send' import type { CondaEnvInfo } from '../shared/conda' import { registerMobileHandlers } from './ipc/mobile' +import { registerUpdateHandlers } from './ipc/updates' +import { createUpdates, type Updates } from './updates' +import { probeRedirect } from './release-redirect' +import { decideUpdateMode } from '../shared/updates' import { MobileService } from './mobile/mobile-service' import { PairingsStore } from './mobile/pairings-store' import { IdentityStore } from './mobile/identity' @@ -141,6 +145,7 @@ export class AppRuntime { private chatManager!: ClaudeChatManager /** Phones: relay connection, pairing and the inbox they see. Dormant while Mobile is off. */ private mobileService!: MobileService + private updates!: Updates private started = false private quitting = false private socksProxyEnabled = new Map() @@ -225,9 +230,48 @@ export class AppRuntime { }) this.chatManager = this.createChatManager() this.mobileService = this.createMobileService() + this.updates = this.createUpdates() this.registerEventForwarders() this.registerIpcHandlers() this.mobileService.start() + this.updates.start() + } + + /** The updater, for the app menu's "Check for Updates…". */ + getUpdates(): Updates { + return this.updates + } + + private createUpdates(): Updates { + let signed = false + try { + const pkg = JSON.parse(fs.readFileSync(path.join(app.getAppPath(), 'package.json'), 'utf8')) as { devtoolSigned?: unknown } + signed = pkg.devtoolSigned === true + } catch { + // Unreadable package.json: treat as unsigned. + } + const mode = decideUpdateMode({ + isPackaged: app.isPackaged, + platform: process.platform, + hasUpdateConfig: app.isPackaged && fs.existsSync(path.join(process.resourcesPath, 'app-update.yml')), + signed + }) + return createUpdates({ + mode, + appVersion: app.getVersion(), + autoCheck: () => this.config.autoCheckUpdates !== false, + broadcast: (status) => this.broadcastToAllWindows('updates-status', status), + openExternal: (url) => { void shell.openExternal(url).catch(() => {}) }, + probeRedirect: (url) => probeRedirect(url), + now: () => Date.now(), + log: (message) => this.logDebug(message), + loadAutoUpdater: async () => { + const mod = await import('electron-updater') + // `autoUpdater` is a lazy getter on a CJS module, which import() only + // exposes on `default` (the named binding comes back undefined). + return mod.autoUpdater ?? (mod as unknown as { default: typeof mod }).default.autoUpdater + } + }) } private createMobileService(): MobileService { @@ -516,6 +560,7 @@ export class AppRuntime { } this.persistWindowSession() this.mobileService?.stop() + this.updates?.close() this.ptySessions.saveAllScrollback() this.ptySessions.killAll() this.notebookKernels.shutdownAll() @@ -791,6 +836,7 @@ export class AppRuntime { listCondaEnvs: () => listCondaEnvs({}, { force: true }) }) registerMobileHandlers(ipc, { mobile: () => this.mobileService }) + registerUpdateHandlers(ipc, { updates: () => this.updates }) } /** diff --git a/src/main/index.ts b/src/main/index.ts index a2de21ec..81c5c536 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,4 +1,4 @@ -import { app, BrowserWindow, Menu, shell, systemPreferences } from 'electron' +import { app, BrowserWindow, dialog, Menu, shell, systemPreferences } from 'electron' import { join } from 'path' import { installBrokenPipeUncaughtHandler } from './broken-pipe' import { pathToFileURL } from 'url' @@ -15,6 +15,22 @@ import { isMenuZoomInKey } from '../shared/shortcut-label' // (do not rethrow — that aborts instead of the recoverable dialog). installBrokenPipeUncaughtHandler() +// Name the app DevTool, not the package's lowercase `devtool` (menu bar, About, +// notifications). Renaming also moves Electron's default userData, which would +// put dev runs (`/devtool`) on the packaged app's `/DevTool` — +// the same folder on case-insensitive macOS/Windows disks. Pin the old path so +// dev and prod Chromium storage stay apart, like the config dirs do. +const userDataPath = app.getPath('userData') +app.setName('DevTool') +app.setPath('userData', userDataPath) +if (process.platform === 'win32') { + // Matches build.appId, which NSIS stamps on the Start Menu shortcut, so the + // taskbar groups installed windows under that shortcut. Dev runs get their own id. + app.setAppUserModelId(app.isPackaged ? 'com.devtool.app' : 'com.devtool.app.dev') +} +/** Packaged via build.files; the project root in dev. */ +const APP_ICON_PATH = join(app.getAppPath(), 'build', 'icon.png') + if (process.env.DEVTOOL_CDP_PORT) { app.commandLine.appendSwitch('remote-debugging-port', process.env.DEVTOOL_CDP_PORT) } @@ -105,6 +121,45 @@ function focusExistingWindow(): void { if (process.platform === 'darwin') app.focus({ steal: true }) } +/** App menu → Check for Updates…: check now, answer in a dialog. */ +async function checkForUpdatesFromMenu(): Promise { + const updates = appRuntime?.getUpdates() + if (!updates) return + const owner = BrowserWindow.getFocusedWindow() + const show = (options: Electron.MessageBoxOptions) => + owner ? dialog.showMessageBox(owner, options) : dialog.showMessageBox(options) + if (updates.status().mode === 'none') { + await show({ type: 'info', message: 'Updates are off in development runs', detail: `DevTool ${app.getVersion()}` }) + return + } + const status = await updates.check() + if (status.state === 'error') { + await show({ type: 'warning', message: 'Could not check for updates', detail: status.error ?? '' }) + return + } + if (!status.available) { + await show({ type: 'info', message: 'DevTool is up to date', detail: `Version ${status.appVersion}` }) + return + } + if (status.mode === 'auto') { + await show({ + type: 'info', + message: `DevTool ${status.available} is downloading`, + detail: 'It installs when you quit DevTool, or restart from Settings → Updates once it is ready.' + }) + return + } + const { response } = await show({ + type: 'info', + message: `DevTool ${status.available} is available`, + detail: `You have ${status.appVersion}. Download it from the release page.`, + buttons: ['Open Release Page', 'Later'], + defaultId: 0, + cancelId: 1 + }) + if (response === 0) await updates.install() +} + function buildAppMenu(): void { const isMac = process.platform === 'darwin' @@ -120,6 +175,7 @@ function buildAppMenu(): void { label: app.name, submenu: [ { role: 'about' as const }, + { label: 'Check for Updates…', click: () => void checkForUpdatesFromMenu() }, { type: 'separator' as const }, { label: 'Settings...', @@ -245,7 +301,13 @@ function buildAppMenu(): void { { role: 'zoom' }, ...(isMac ? [{ type: 'separator' as const }, { role: 'front' as const }] : []) ] - } + }, + ...(isMac + ? [] + : [{ + label: 'Help', + submenu: [{ label: 'Check for Updates…', click: () => void checkForUpdatesFromMenu() }] + }]) ] Menu.setApplicationMenu(Menu.buildFromTemplate(template)) @@ -261,6 +323,8 @@ function createWindow(initialViewState?: WindowViewState | null, geometry?: Wind minHeight: 600, titleBarStyle: 'hiddenInset', trafficLightPosition: { x: 12, y: 12 }, + // macOS takes the bundle icon; Windows/Linux need it per window in dev (and Linux always). + ...(process.platform === 'darwin' ? {} : { icon: APP_ICON_PATH }), webPreferences: { preload: join(__dirname, '../preload/index.js'), contextIsolation: true, @@ -352,6 +416,10 @@ app.whenReady().then(async () => { return } releaseInstanceLock = lock.release + if (process.platform === 'darwin' && !app.isPackaged) { + // Dev runs Electron.app, whose bundle icon is Electron's. + app.dock?.setIcon(APP_ICON_PATH) + } await resolveShellEnv() // Warm the conda env list so the first local PTY can resolve a saved name without waiting. void listCondaEnvs().catch(() => {}) diff --git a/src/main/ipc/config-sanitize.ts b/src/main/ipc/config-sanitize.ts index dde85116..55a106b5 100644 --- a/src/main/ipc/config-sanitize.ts +++ b/src/main/ipc/config-sanitize.ts @@ -63,6 +63,7 @@ const CONFIG_FIELDS: { [K in keyof AppConfig]-?: Validator } = { piCommand: str, lazyLoadClaude: bool, keepAwakeWhileWorking: bool, + autoCheckUpdates: bool, claudeDefaultView: v.literal('terminal', 'chat'), lastProjectId: nullableStr, lastTaskId: nullableStr, diff --git a/src/main/ipc/updates.ts b/src/main/ipc/updates.ts new file mode 100644 index 00000000..a38bda28 --- /dev/null +++ b/src/main/ipc/updates.ts @@ -0,0 +1,16 @@ +import type { UpdateStatus } from '../../shared/updates' +import type { IpcRegistrar } from './registrar' + +/** The part of the updater the IPC surface drives. */ +export interface UpdatesControl { + status(): UpdateStatus + check(): Promise + install(): Promise +} + +/** Settings → Updates. Status changes are also broadcast as `updates-status`. */ +export function registerUpdateHandlers(ipc: IpcRegistrar, deps: { updates: () => UpdatesControl }): void { + ipc.handle('updates-get-status', [], () => deps.updates().status()) + ipc.handle('updates-check', [], () => deps.updates().check()) + ipc.handle('updates-install', [], () => deps.updates().install()) +} diff --git a/src/main/release-redirect.ts b/src/main/release-redirect.ts new file mode 100644 index 00000000..23f945cd --- /dev/null +++ b/src/main/release-redirect.ts @@ -0,0 +1,36 @@ +import { net } from 'electron' + +export interface RedirectProbe { + status: number + /** Where the server redirected to, or null when it answered without a redirect. */ + location: string | null +} + +/** + * One request that stops at the first redirect and reports where it pointed. + * Electron's `net` (Chromium's network stack) rather than Node's fetch: it uses + * the system proxy / PAC settings and Chromium's IPv6 fallback — Node's fetch + * hung for the full timeout on a Windows box's first request. `net.fetch` cannot + * do this: with `redirect: 'manual'` it rejects ("Redirect was cancelled"). + */ +export function probeRedirect(url: string, timeoutMs = 30_000): Promise { + return new Promise((resolve, reject) => { + const request = net.request({ url, redirect: 'manual' }) + const timer = setTimeout(() => { + request.abort() + reject(new Error(`No answer from ${new URL(url).host} within ${timeoutMs / 1000} s`)) + }, timeoutMs) + const settle = (result: RedirectProbe) => { + clearTimeout(timer) + resolve(result) + request.abort() + } + request.on('redirect', (status, _method, location) => settle({ status, location })) + request.on('response', (response) => settle({ status: response.statusCode, location: null })) + request.on('error', (error) => { + clearTimeout(timer) + reject(error) + }) + request.end() + }) +} diff --git a/src/main/updates.ts b/src/main/updates.ts new file mode 100644 index 00000000..eebe0fce --- /dev/null +++ b/src/main/updates.ts @@ -0,0 +1,174 @@ +import type { AppUpdater } from 'electron-updater' +import type { RedirectProbe } from './release-redirect' +import { + compareVersions, + parseLatestRelease, + RELEASES_URL, + type UpdateMode, + type UpdateStatus +} from '../shared/updates' + +// Whether a newer DevTool exists, and what this install can do about it. The +// mode (see UpdateMode) is decided once at startup from facts of the artifact. +// +// `manual` is one HTTPS request for where github.com/…/releases/latest redirects: +// it names the newest tag without the GitHub API (no token, no rate limit), and +// "install" opens that release page. `auto` hands the same question to +// electron-updater, which downloads the signed Setup.exe and runs it on restart +// or quit. Unsigned releases carry no latest.yml, so `auto` never sees them. +// +// First check shortly after launch, then every few hours; each tick re-reads the +// Settings toggle so it applies without a restart. "Check now" ignores the toggle. + +/** Off the cold-start path. */ +export const FIRST_CHECK_DELAY_MS = 30_000 +export const CHECK_EVERY_MS = 6 * 60 * 60_000 + +export interface UpdatesDeps { + mode: UpdateMode + appVersion: string + /** Settings → Updates → Check automatically. */ + autoCheck: () => boolean + /** Push a status change to every window. */ + broadcast: (status: UpdateStatus) => void + openExternal: (url: string) => void + /** Where a URL redirects (src/main/release-redirect.ts). */ + probeRedirect: (url: string) => Promise + now: () => number + log: (message: string) => void + /** electron-updater, loaded on first use in `auto` mode only. */ + loadAutoUpdater: () => Promise +} + +export interface Updates { + start(): void + status(): UpdateStatus + /** Look now, regardless of the automatic-check toggle. */ + check(): Promise + /** Restart into the downloaded build (`auto`), or open the release page. */ + install(): Promise + close(): void +} + +/** + * The newest released version, from where `/releases/latest` redirects. Null when + * nothing is published yet: GitHub then redirects to the releases list instead. + */ +export async function fetchLatestRelease( + probe: (url: string) => Promise +): Promise<{ version: string; url: string } | null> { + const { status, location } = await probe(`${RELEASES_URL}/latest`) + if (location?.replace(/\/$/, '').endsWith('/releases')) return null + const latest = parseLatestRelease(location) + if (!latest) throw new Error(`GitHub did not name a latest release (HTTP ${status})`) + return latest +} + +export function createUpdates(deps: UpdatesDeps): Updates { + const current: UpdateStatus = { + appVersion: deps.appVersion, + mode: deps.mode, + state: 'idle', + available: null, + releaseUrl: null, + checkedAt: null, + error: null + } + deps.log(`updates mode=${deps.mode} version=${deps.appVersion}`) + + let firstTimer: NodeJS.Timeout | null = null + let interval: NodeJS.Timeout | null = null + let inFlight: Promise | null = null + let updater: Promise | null = null + + function set(patch: Partial): void { + Object.assign(current, patch) + deps.broadcast({ ...current }) + } + + function getUpdater(): Promise { + updater ??= deps.loadAutoUpdater().then((autoUpdater) => { + const line = (message: unknown) => deps.log(`updates ${String(message)}`) + autoUpdater.logger = { info: line, warn: line, error: line, debug: () => undefined } + autoUpdater.autoDownload = true + autoUpdater.autoInstallOnAppQuit = true + autoUpdater.on('update-available', (info) => { + set({ state: 'downloading', available: info.version, releaseUrl: `${RELEASES_URL}/tag/v${info.version}` }) + }) + autoUpdater.on('update-downloaded', () => set({ state: 'ready' })) + // A download can fail long after the check resolved; an unlistened 'error' + // on an emitter would take main down. + autoUpdater.on('error', (error) => { + deps.log(`updates auto-update failed: ${error.message}`) + if (current.state === 'downloading' || current.state === 'checking') { + set({ state: 'error', error: error.message }) + } + }) + return autoUpdater + }) + return updater + } + + async function runCheck(): Promise { + if (deps.mode === 'auto') { + const autoUpdater = await getUpdater() + // A downloaded build stays ready until a restart consumes it. + if (current.state === 'ready') return + set({ state: 'checking', error: null }) + await autoUpdater.checkForUpdates() + if (current.state === 'checking') set({ state: 'idle', available: null, releaseUrl: null }) + set({ checkedAt: deps.now() }) + return + } + set({ state: 'checking', error: null }) + const latest = await fetchLatestRelease(deps.probeRedirect) + const newer = latest !== null && compareVersions(latest.version, deps.appVersion) > 0 + set({ + state: 'idle', + available: newer ? latest.version : null, + releaseUrl: newer ? latest.url : null, + checkedAt: deps.now() + }) + } + + function check(): Promise { + if (deps.mode === 'none') return Promise.resolve({ ...current }) + inFlight ??= runCheck() + .catch((error: unknown) => { + const message = error instanceof Error ? error.message : String(error) + deps.log(`updates check failed: ${message}`) + set({ state: 'error', error: message, checkedAt: deps.now() }) + }) + .then(() => ({ ...current })) + .finally(() => { inFlight = null }) + return inFlight + } + + function tick(): void { + if (deps.autoCheck()) void check() + } + + return { + start() { + if (deps.mode === 'none' || firstTimer || interval) return + firstTimer = setTimeout(() => { firstTimer = null; tick() }, FIRST_CHECK_DELAY_MS) + interval = setInterval(tick, CHECK_EVERY_MS) + }, + status: () => ({ ...current }), + check, + async install() { + if (deps.mode === 'auto' && current.state === 'ready') { + const autoUpdater = await getUpdater() + autoUpdater.quitAndInstall() + return + } + deps.openExternal(current.releaseUrl ?? `${RELEASES_URL}/latest`) + }, + close() { + if (firstTimer) clearTimeout(firstTimer) + if (interval) clearInterval(interval) + firstTimer = null + interval = null + } + } +} diff --git a/src/preload/index.ts b/src/preload/index.ts index 72786c24..52bd8c5a 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -28,6 +28,7 @@ import type { CondaListResult } from '../shared/conda' import type { NotebookKernelCondaOverride, NotebookKernelEvent } from '../shared/notebook' import type { AgentActivity } from '../shared/agent-activity' import type { MobilePairingInvite, MobileState } from '../shared/mobile' +import type { UpdateStatus } from '../shared/updates' import type { AiStatusEvent } from '../shared/ai-status' import type { ChatEvent, ChatImage, ChatPromptResponse, ChatSideAnswer, ChatSnapshot } from '../shared/claude-chat' import type { PermissionBehavior, PermissionSettingsSource, PermissionSourceKind } from '../shared/chat-permissions' @@ -423,6 +424,15 @@ const api = { const handler = (_event: Electron.IpcRendererEvent, state: MobileState) => callback(state) ipcRenderer.on('mobile-state-changed', handler) return () => ipcRenderer.removeListener('mobile-state-changed', handler) + }, + // Updates (Settings → Updates). Main owns the state; every change is also broadcast. + updatesGetStatus: (): Promise => ipcRenderer.invoke('updates-get-status'), + updatesCheck: (): Promise => ipcRenderer.invoke('updates-check'), + updatesInstall: (): Promise => ipcRenderer.invoke('updates-install'), + onUpdatesStatus: (callback: (status: UpdateStatus) => void): (() => void) => { + const handler = (_event: Electron.IpcRendererEvent, status: UpdateStatus) => callback(status) + ipcRenderer.on('updates-status', handler) + return () => ipcRenderer.removeListener('updates-status', handler) } } diff --git a/src/renderer/components/Settings.tsx b/src/renderer/components/Settings.tsx index 66650ab6..7dbfa22d 100644 --- a/src/renderer/components/Settings.tsx +++ b/src/renderer/components/Settings.tsx @@ -14,6 +14,7 @@ import { import { GrpHead, FormGroup, SetBlock, Group, GroupRow, SegCtl, Switch, Field, Select, HelperText, Disclosure, LinkBtn } from './ui' import ExternalIdesSettings from './ExternalIdesSettings' import MobileSettings from './settings/MobileSettings' +import UpdatesSettings from './settings/UpdatesSettings' import { formatShortcutForApp } from '../../shared/shortcut-label' interface Props { @@ -84,7 +85,7 @@ function parseNumberInput(value: string, fallback: number, min: number, max: num return Math.min(max, Math.max(min, parsed)) } -type SettingsTab = 'appearance' | 'terminal' | 'editor' | 'ai' | 'sidebar' | 'tasks' | 'mobile' +type SettingsTab = 'appearance' | 'terminal' | 'editor' | 'ai' | 'sidebar' | 'tasks' | 'mobile' | 'updates' const tabs: Array<{ id: SettingsTab; label: string }> = [ { id: 'appearance', label: 'Appearance' }, @@ -93,7 +94,8 @@ const tabs: Array<{ id: SettingsTab; label: string }> = [ { id: 'ai', label: 'AI Tools' }, { id: 'sidebar', label: 'Sidebar' }, { id: 'tasks', label: 'Tasks' }, - { id: 'mobile', label: 'Mobile' } + { id: 'mobile', label: 'Mobile' }, + { id: 'updates', label: 'Updates' } ] export default function Settings({ onClose }: Props): React.ReactElement { @@ -550,6 +552,9 @@ export default function Settings({ onClose }: Props): React.ReactElement { case 'mobile': return + case 'updates': + return + case 'sidebar': return ( <> diff --git a/src/renderer/components/settings/UpdatesSettings.tsx b/src/renderer/components/settings/UpdatesSettings.tsx new file mode 100644 index 00000000..31a56593 --- /dev/null +++ b/src/renderer/components/settings/UpdatesSettings.tsx @@ -0,0 +1,56 @@ +import React, { useEffect, useState } from 'react' +import { describeUpdateStatus, type UpdateStatus } from '../../../shared/updates' +import { useApp } from '../../context/AppContext' +import { Group, GroupRow, GrpHead, HelperText, LinkBtn, Switch } from '../ui' + +const MODE_HELP: Record, string> = { + auto: 'This install updates itself: a new version downloads in the background and installs when you quit or restart.', + manual: 'This build does not replace itself (portable folder or unsigned installer). DevTool tells you about a new version and opens its release page.' +} + +export default function UpdatesSettings(): React.ReactElement { + const { config, updateConfig } = useApp() + const [status, setStatus] = useState(null) + + useEffect(() => { + let alive = true + void window.api.updatesGetStatus().then(next => { if (alive) setStatus(next) }).catch(() => {}) + const off = window.api.onUpdatesStatus(next => setStatus(next)) + return () => { alive = false; off() } + }, []) + + if (!status || !config) return
+ + const busy = status.state === 'checking' || status.state === 'downloading' + const action = status.state === 'ready' + ? void window.api.updatesInstall()}>Restart to update + : status.available + ? void window.api.updatesInstall()}>Open release page + : void window.api.updatesCheck()}>Check now + + return ( + <> + Updates + + + {status.mode !== 'none' && ( + updateConfig({ autoCheckUpdates })} + /> + } + /> + )} + + {status.mode !== 'none' && {MODE_HELP[status.mode]}} + + ) +} diff --git a/src/shared/types.ts b/src/shared/types.ts index 96e2d8f0..bee78db6 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -426,6 +426,8 @@ export interface AppConfig { lazyLoadClaude: boolean /** Hold off system sleep while any agent tab is working (the display may still sleep). */ keepAwakeWhileWorking: boolean + /** Settings → Updates: look for a newer release at launch and every few hours (packaged builds). */ + autoCheckUpdates: boolean /** New Claude tabs (task auto-open, the tab bar's ✦) open as a terminal or a chat. */ claudeDefaultView: ClaudeView lastProjectId: string | null @@ -648,6 +650,7 @@ export const DEFAULT_CONFIG: AppConfig = { piCommand: '', lazyLoadClaude: true, keepAwakeWhileWorking: true, + autoCheckUpdates: true, claudeDefaultView: 'terminal', lastProjectId: null, lastTaskId: null, diff --git a/src/shared/updates.ts b/src/shared/updates.ts new file mode 100644 index 00000000..4a7bc4bd --- /dev/null +++ b/src/shared/updates.ts @@ -0,0 +1,91 @@ +// Update checks (Settings → Updates, "Check for Updates…"). Pure helpers shared +// by main and the renderer; the machinery lives in src/main/updates.ts. + +export const RELEASES_URL = 'https://github.com/join3r/claude-project/releases' + +/** + * How a release reaches this install — a fact of the artifact, decided once: + * - `auto`: a signed NSIS install. electron-updater downloads and swaps it. + * - `manual`: every other packaged build (portable folder, unsigned Setup.exe, + * macOS/Linux dirs). DevTool says a newer version exists and opens its page. + * - `none`: dev runs. Nothing on disk a release could replace. + */ +export type UpdateMode = 'auto' | 'manual' | 'none' + +export type UpdateState = 'idle' | 'checking' | 'downloading' | 'ready' | 'error' + +export interface UpdateStatus { + appVersion: string + mode: UpdateMode + state: UpdateState + /** Newer version that exists, or null when up to date / not checked yet. */ + available: string | null + /** Release page for `available`. */ + releaseUrl: string | null + /** Epoch ms of the last finished check. */ + checkedAt: number | null + error: string | null +} + +export interface UpdateModeFacts { + isPackaged: boolean + platform: string + /** resources/app-update.yml exists — electron-builder writes it for NSIS installs only. */ + hasUpdateConfig: boolean + /** package.json `devtoolSigned`, stamped by `release-win --signed`. */ + signed: boolean +} + +export function decideUpdateMode(facts: UpdateModeFacts): UpdateMode { + if (!facts.isPackaged) return 'none' + // Unsigned auto-update is not worth it: an unsigned build only ever says so. + if (facts.platform === 'win32' && facts.hasUpdateConfig && facts.signed) return 'auto' + return 'manual' +} + +/** + * Numeric compare of dotted versions (`0.6.0` vs `0.10.1`). A pre-release + * suffix (`-beta.1`) sorts before the same release. >0 when `a` is newer. + */ +export function compareVersions(a: string, b: string): number { + const split = (version: string) => { + const [core, pre] = version.replace(/^v/, '').split('-', 2) + return { parts: core.split('.').map((part) => parseInt(part, 10) || 0), pre: pre ?? null } + } + const left = split(a) + const right = split(b) + const length = Math.max(left.parts.length, right.parts.length) + for (let i = 0; i < length; i++) { + const diff = (left.parts[i] ?? 0) - (right.parts[i] ?? 0) + if (diff !== 0) return diff + } + if (left.pre === right.pre) return 0 + if (left.pre === null) return 1 + if (right.pre === null) return -1 + return left.pre < right.pre ? -1 : 1 +} + +/** + * The version a `/releases/latest` redirect names. Only the tag is taken from + * the `Location` header; the page URL is rebuilt on RELEASES_URL. Null for + * anything that is not a version tag (no releases yet, an error page). + */ +export function parseLatestRelease(location: string | null): { version: string; url: string } | null { + const tag = /\/releases\/tag\/(v?\d+(?:\.\d+)*(?:-[0-9A-Za-z.]+)?)$/.exec(location ?? '')?.[1] + if (!tag) return null + return { version: tag.replace(/^v/, ''), url: `${RELEASES_URL}/tag/${tag}` } +} + +/** The one-line status Settings → Updates shows. */ +export function describeUpdateStatus(status: UpdateStatus): string { + if (status.mode === 'none') return 'Update checks are off in development runs.' + switch (status.state) { + case 'checking': return 'Checking for updates…' + case 'downloading': return `Downloading ${status.available ?? 'update'}…` + case 'ready': return `${status.available ?? 'An update'} is ready — restart to install.` + case 'error': return `Could not check for updates: ${status.error ?? 'unknown error'}` + case 'idle': + if (status.available) return `${status.available} is available.` + return status.checkedAt ? 'DevTool is up to date.' : 'Not checked yet.' + } +} diff --git a/tests/editor-tab.test.tsx b/tests/editor-tab.test.tsx index 8330f3a7..599b04f3 100644 --- a/tests/editor-tab.test.tsx +++ b/tests/editor-tab.test.tsx @@ -319,8 +319,10 @@ describe('EditorTab', () => { }) async function press(keybinding: number): Promise { + // The editor registers its commands on mount, which can land after the + // file content shows up on a loaded runner (flaked on ubuntu CI). + await waitFor(() => expect(mocks.commands.get(keybinding)).toBeTypeOf('function')) const run = mocks.commands.get(keybinding) - expect(run).toBeTypeOf('function') await act(async () => { run!() await new Promise(resolve => setTimeout(resolve, 0)) diff --git a/tests/updates.test.ts b/tests/updates.test.ts new file mode 100644 index 00000000..88d80ee4 --- /dev/null +++ b/tests/updates.test.ts @@ -0,0 +1,170 @@ +import { createRequire } from 'node:module' +import { afterEach, describe, expect, it, vi } from 'vitest' +import { + compareVersions, + decideUpdateMode, + describeUpdateStatus, + parseLatestRelease, + RELEASES_URL, + type UpdateStatus +} from '../src/shared/updates' +import { createUpdates, FIRST_CHECK_DELAY_MS, type UpdatesDeps } from '../src/main/updates' +import { DEFAULT_CONFIG } from '../src/shared/types' +import { sanitizeConfigUpdate } from '../src/main/ipc/config-sanitize' + +const require = createRequire(import.meta.url) +const { signCommand } = require('../scripts/sign-win.cjs') as { + signCommand: (file: string, template?: string) => string | null +} + +describe('compareVersions', () => { + it('compares numerically, not as strings', () => { + expect(compareVersions('0.10.0', '0.9.9')).toBeGreaterThan(0) + expect(compareVersions('0.6.0', '0.6.0')).toBe(0) + expect(compareVersions('v0.6.1', '0.6.0')).toBeGreaterThan(0) + expect(compareVersions('0.6', '0.6.0')).toBe(0) + }) + + it('sorts a pre-release before its release', () => { + expect(compareVersions('0.6.0-beta.1', '0.6.0')).toBeLessThan(0) + expect(compareVersions('0.6.0', '0.6.0-beta.1')).toBeGreaterThan(0) + expect(compareVersions('0.6.0-beta.2', '0.6.0-beta.1')).toBeGreaterThan(0) + }) +}) + +describe('parseLatestRelease', () => { + it('takes the tag and rebuilds the URL on the repo', () => { + expect(parseLatestRelease('https://github.com/join3r/claude-project/releases/tag/v0.6.1')).toEqual({ + version: '0.6.1', + url: `${RELEASES_URL}/tag/v0.6.1` + }) + expect(parseLatestRelease('https://evil.example/x/releases/tag/v9.0.0')?.url).toBe(`${RELEASES_URL}/tag/v9.0.0`) + }) + + it('rejects anything that is not a version tag', () => { + expect(parseLatestRelease(null)).toBeNull() + expect(parseLatestRelease('https://github.com/join3r/claude-project/releases')).toBeNull() + expect(parseLatestRelease('https://github.com/join3r/claude-project/releases/tag/nightly')).toBeNull() + }) +}) + +describe('decideUpdateMode', () => { + const base = { isPackaged: true, platform: 'win32', hasUpdateConfig: true, signed: true } + + it('self-updates only a signed Windows NSIS install', () => { + expect(decideUpdateMode(base)).toBe('auto') + expect(decideUpdateMode({ ...base, signed: false })).toBe('manual') + // Portable folder: no app-update.yml. + expect(decideUpdateMode({ ...base, hasUpdateConfig: false })).toBe('manual') + expect(decideUpdateMode({ ...base, platform: 'darwin' })).toBe('manual') + }) + + it('does nothing in dev', () => { + expect(decideUpdateMode({ ...base, isPackaged: false })).toBe('none') + }) +}) + +describe('describeUpdateStatus', () => { + const status: UpdateStatus = { + appVersion: '0.6.0', mode: 'manual', state: 'idle', available: null, releaseUrl: null, checkedAt: null, error: null + } + it('reads each state', () => { + expect(describeUpdateStatus(status)).toBe('Not checked yet.') + expect(describeUpdateStatus({ ...status, checkedAt: 1 })).toBe('DevTool is up to date.') + expect(describeUpdateStatus({ ...status, available: '0.6.1' })).toBe('0.6.1 is available.') + expect(describeUpdateStatus({ ...status, state: 'error', error: 'offline' })).toContain('offline') + expect(describeUpdateStatus({ ...status, mode: 'none' })).toContain('development') + }) +}) + +describe('createUpdates (manual mode)', () => { + afterEach(() => { vi.useRealTimers() }) + + function setup(location: string | null, overrides: Partial = {}) { + const probeMock = vi.fn(async () => ({ status: 302, location })) + const broadcast = vi.fn() + const openExternal = vi.fn() + const updates = createUpdates({ + mode: 'manual', + appVersion: '0.6.0', + autoCheck: () => true, + broadcast, + openExternal, + probeRedirect: probeMock, + now: () => 1234, + log: () => {}, + loadAutoUpdater: () => { throw new Error('not in manual mode') }, + ...overrides + }) + return { updates, probeMock, broadcast, openExternal } + } + + it('reports a newer release and opens its page', async () => { + const { updates, openExternal } = setup('https://github.com/join3r/claude-project/releases/tag/v0.6.1') + const status = await updates.check() + expect(status).toMatchObject({ state: 'idle', available: '0.6.1', checkedAt: 1234 }) + await updates.install() + expect(openExternal).toHaveBeenCalledWith(`${RELEASES_URL}/tag/v0.6.1`) + }) + + it('stays quiet when the latest release is this one', async () => { + const { updates } = setup('https://github.com/join3r/claude-project/releases/tag/v0.6.0') + expect(await updates.check()).toMatchObject({ state: 'idle', available: null }) + }) + + it('treats a repo with no releases yet as up to date', async () => { + const { updates } = setup('https://github.com/join3r/claude-project/releases') + expect(await updates.check()).toMatchObject({ state: 'idle', available: null, checkedAt: 1234 }) + }) + + it('turns a failed lookup into an error state', async () => { + const { updates } = setup(null) + expect((await updates.check()).state).toBe('error') + }) + + it('joins a check already in flight', async () => { + const { updates, probeMock } = setup('https://github.com/join3r/claude-project/releases/tag/v0.6.1') + await Promise.all([updates.check(), updates.check()]) + expect(probeMock).toHaveBeenCalledTimes(1) + }) + + it('skips scheduled checks while the toggle is off', async () => { + vi.useFakeTimers() + const { updates, probeMock } = setup('https://github.com/join3r/claude-project/releases/tag/v0.6.1', { + autoCheck: () => false + }) + updates.start() + await vi.advanceTimersByTimeAsync(FIRST_CHECK_DELAY_MS + 1) + expect(probeMock).not.toHaveBeenCalled() + updates.close() + }) + + it('never checks in dev', async () => { + const { updates, probeMock } = setup('https://github.com/join3r/claude-project/releases/tag/v0.6.1', { mode: 'none' }) + await updates.check() + expect(probeMock).not.toHaveBeenCalled() + }) +}) + +describe('autoCheckUpdates config', () => { + it('defaults on and is accepted from the renderer', () => { + expect(DEFAULT_CONFIG.autoCheckUpdates).toBe(true) + expect(sanitizeConfigUpdate({ autoCheckUpdates: false }).config).toEqual({ autoCheckUpdates: false }) + }) +}) + +describe('sign-win hook', () => { + it('is a no-op without DEVTOOL_SIGN_CMD', () => { + expect(signCommand('C:\\dist\\DevTool.exe', '')).toBeNull() + expect(signCommand('C:\\dist\\DevTool.exe', undefined)).toBeNull() + }) + + it('substitutes the file path', () => { + expect(signCommand('C:\\dist\\DevTool.exe', 'signtool sign /fd sha256 "{file}"')) + .toBe('signtool sign /fd sha256 "C:\\dist\\DevTool.exe"') + }) + + it('refuses a command without {file}', () => { + expect(() => signCommand('x.exe', 'signtool sign')).toThrow(/\{file\}/) + }) +})