Skip to content

fix(install): scope npm installs/audits to avoid pulling in apps/desktop - #38810

Closed
zakame wants to merge 4 commits into
NousResearch:mainfrom
zakame:fix/workspace-glob-desktop-isolation
Closed

fix(install): scope npm installs/audits to avoid pulling in apps/desktop#38810
zakame wants to merge 4 commits into
NousResearch:mainfrom
zakame:fix/workspace-glob-desktop-isolation

Conversation

@zakame

@zakame zakame commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #38772.

The root package.json workspaces: ["apps/*", ...] glob unconditionally pulls apps/desktop (Electron + node-pty@1.1.0, ~200 MB, requires make/g++ to build from source) into every unscoped npm command run from the repo root. This patch adds explicit workspace scoping to every internal npm install / npm audit call in the codebase, and adds convenience scripts to package.json so developers don't have to remember the right flags.

Changes

hermes_cli/main.py_build_web_ui

  • Add --workspace web to the npm ci / npm install call inside _build_web_ui(), so only the web workspace deps are resolved when building the dashboard frontend. Previously the call ran against the workspace root without scoping, triggering full apps/* resolution on every web rebuild.
  • Update all manual-recovery hints to use the scoped form npm install --workspace web && npm run build -w web so users following the hint don't accidentally trigger a desktop rebuild.

hermes_cli/main.py — TUI launch path

  • Add --workspace ui-tui to the inline npm install that runs when launching hermes tui with missing deps. Previously this ran unscoped from PROJECT_ROOT, resolving apps/* including desktop.

hermes_cli/tools_config.py

  • Add --workspaces=false to the npm install --silent calls that install root-level browser tool deps (agent-browser, Camofox). Root deps live in the root package.json and don't need any workspace to be resolved.

hermes_cli/doctor.pyrun_doctor npm audit block

  • Replace the single unscoped npm audit --json at PROJECT_ROOT with three scoped invocations: --workspaces=false for root deps, --workspace web for the web workspace, and --workspace ui-tui for the TUI workspace.
  • Update the remediation hint in each warning to use the matching scoped npm audit fix command, so users aren't directed to run an unscoped fix that would rebuild node-pty.
  • Fix check_dir tautology: npm_dir if audit_extra else npm_dir always evaluated to npm_dir; corrected to PROJECT_ROOT if audit_extra else npm_dir so workspace-scoped audits check the workspace root's node_modules.

package.json

Add convenience npm scripts for the most common scoped operations:

Script What it does
npm run install:root npm install --workspaces=false
npm run install:web npm install --workspace web
npm run install:tui npm install --workspace ui-tui
npm run install:desktop npm install --workspace apps/desktop
npm run audit:root npm audit --workspaces=false
npm run audit:web npm audit --workspace web
npm run audit:tui npm audit --workspace ui-tui
npm run audit:fix:root npm audit fix --workspaces=false
npm run audit:fix:web npm audit fix --workspace web
npm run audit:fix:tui npm audit fix --workspace ui-tui

tests/hermes_cli/test_cmd_update.py

  • Update the stale assertion for the _build_web_ui npm ci call to expect --workspace web.

tests/hermes_cli/test_tui_npm_install.py

  • Add test_tui_launch_install_uses_workspace_scope to assert that the TUI launch npm install carries --workspace ui-tui.

tests/hermes_cli/test_web_ui_build.py

  • Add test_npm_install_uses_workspace_web_scope to assert that _build_web_ui passes --workspace web adjacently in the npm install invocation, directly covering the most critical call site.

What this does NOT change

Test Plan

  • hermes dashboard still builds the dashboard (_build_web_ui path)
  • hermes --tui does not pull desktop deps on first launch
  • hermes update does not pull desktop deps (_update_node_dependencies unchanged)
  • hermes doctor reports separate audit results for root / web / ui-tui workspaces
  • npm run audit:fix:web can be run on a minimal Linux box without make/g++

@zakame
zakame requested a review from a team June 4, 2026 07:15
@zakame
zakame force-pushed the fix/workspace-glob-desktop-isolation branch from 3b65f2c to 135be94 Compare June 4, 2026 07:20
@zakame zakame changed the title fix: scope npm installs/audits to avoid pulling in apps/desktop (#38772) fix: scope npm installs/audits to avoid pulling in apps/desktop Jun 4, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard area/docker Docker image, Compose, packaging P2 Medium — degraded but workaround exists labels Jun 4, 2026
zakame added 4 commits June 5, 2026 11:19
Root package.json uses apps/* workspaces glob which unconditionally
includes apps/desktop (Electron + node-pty@1.1.0, ~200MB, requires
make/g++ to build) in every unscoped npm command run from the repo root.

This commit addresses the core problem by adding explicit workspace
scoping to all internal npm calls:

hermes_cli/main.py (_build_web_ui):
  - Add --workspace web to the npm install call so only the web
    workspace deps are resolved, never apps/desktop.

hermes_cli/tools_config.py:
  - Add --workspaces=false to agent-browser and Camofox root installs
    so only root-level deps (agent-browser, @streamdown/math) are
    installed, bypassing the workspace graph entirely.

hermes_cli/doctor.py (run_doctor npm audit):
  - Replace the single unscoped 'npm audit --json' at PROJECT_ROOT with
    three scoped invocations:
      * --workspaces=false for root deps (Browser tools)
      * --workspace web for the web workspace
      * --workspace ui-tui for the TUI workspace
  - Update remediation hints to use matching scoped 'npm audit fix'
    commands so users don't accidentally trigger a desktop rebuild.

package.json:
  - Add convenience scripts for scoped operations:
      npm run install:root  / install:web / install:tui / install:desktop
      npm run audit:root    / audit:web   / audit:tui
      npm run audit:fix:root / audit:fix:web / audit:fix:tui
    These give developers and CI a safe, explicit interface for the
    most common per-workspace tasks without accidentally pulling desktop.

Fixes NousResearch#38772
- Add --workspace ui-tui to the TUI launch npm install, the one call
  site missed by the prior commit. Without scoping it ran from
  PROJECT_ROOT and still resolved apps/desktop via the apps/* glob.

- Update the two manual-recovery hints in _build_web_ui (npm install
  failure and build failure paths) to use the scoped form
  `npm install --workspace web && npm run build -w web` so users
  following the hint don't accidentally trigger a desktop rebuild.

- Update the stale test assertion in test_cmd_update.py to expect
  --workspace web in the _build_web_ui npm ci call, which was
  previously unreachable through the if-guard and left the workspace-
  scoping change from the prior commit unverified.
- Update the --skip-build pre-build hint in the dashboard startup path
  to use `npm install --workspace web && npm run build -w web` so users
  don't accidentally trigger a desktop rebuild by following the hint.

- Add test_tui_launch_install_uses_workspace_scope to assert that the
  TUI launch npm install carries --workspace ui-tui, covering the call
  site added in the prior commit.
- check_dir = npm_dir if audit_extra else npm_dir evaluated identically in
  both branches; change to PROJECT_ROOT if audit_extra else npm_dir so
  workspace-scoped audits check the workspace root's node_modules
- Add test_npm_install_uses_workspace_web_scope asserting --workspace web is
  passed adjacently in the _build_web_ui npm install invocation
@zakame
zakame force-pushed the fix/workspace-glob-desktop-isolation branch from 393ccff to e242bec Compare June 5, 2026 04:08
@zakame zakame changed the title fix: scope npm installs/audits to avoid pulling in apps/desktop fix(install): scope npm installs/audits to avoid pulling in apps/desktop Jun 5, 2026
@teknium1

teknium1 commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Merged via #40543 — your four commits were cherry-picked onto current main with your authorship preserved per-commit (rebase merge). Resolved one conflict against the newer Termux install-context branch so both the Termux and non-Termux paths stay workspace-scoped. Added you to scripts/release.py AUTHOR_MAP so the attribution check passes. Thanks for the thorough fix across web build, TUI launch, tool setup, and doctor audits!

#40543

@zakame

zakame commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

@teknium1 thanks for the update and glad to help! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Root package.json workspaces glob unconditionally pulls apps/desktop (and bootstrap-installer) into every unscoped npm command

3 participants