Skip to content

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

Merged
teknium1 merged 6 commits into
mainfrom
hermes/hermes-ff798e6b
Jun 7, 2026
Merged

fix(install): scope npm installs/audits to avoid pulling in apps/desktop (#38358)#40543
teknium1 merged 6 commits into
mainfrom
hermes/hermes-ff798e6b

Conversation

@teknium1

@teknium1 teknium1 commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Summary

hermes update / hermes web / hermes tui now scope their npm installs to the workspace they actually need, so multi-workspace repos no longer pull in apps/desktop (Electron ~200MB) and fail. Fixes #38358 (and the sibling #38772).

Root cause: _build_web_ui() ran npm ci/install from the workspace root with no --workspace flag, so npm resolved the entire workspace graph — including apps/desktop — and the Electron postinstall failure aborted the whole step. _update_node_dependencies() Step 2 already scoped correctly; the other install/audit sites did not.

Changes

  • hermes_cli/main.py: scope web build install to --workspace web and TUI launch install to --workspace ui-tui (non-Termux path; the Termux branch keeps its own context). Fix stale cd web && npm install hints to workspace-scoped equivalents.
  • hermes_cli/tools_config.py: post-setup root installs use --workspaces=false (2 sites).
  • hermes_cli/doctor.py: npm audit splits into root (--workspaces=false) + per-workspace targets; scoped remediation hints.
  • package.json: add install:* / audit:* workspace helper scripts.
  • Tests updated for the scoped commands; new tests assert web/TUI scope.

Validation

Before After
_build_web_ui install (multi-workspace + apps/desktop) npm ci --silent → resolves desktop → Electron fail npm ci --workspace web --silent → desktop never resolved
Targeted tests 69 passed (web_ui_build, tui_npm_install, cmd_update); 106 passed (doctor/release)
E2E Real multi-workspace tree: install scoped to --workspace web, apps/desktop never touched

Salvaged from #38810 by @zakame onto current main (resolved a conflict with the newer Termux install-context branch so both paths stay scoped). Authorship preserved per-commit. Also supersedes the narrower #38396 by @luyao618, who fixed the same web-build site first — both credited.

Infographic

scoped-workspace-installs

@teknium1
teknium1 requested a review from a team June 6, 2026 14:39
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-ff798e6b vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9962 on HEAD, 9962 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5167 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels Jun 6, 2026
zakame and others added 6 commits June 6, 2026 08:05
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 #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
Conflict resolution prefixes --workspace web before --silent (preserving
the Termux npm_workspace_args path); update test_cmd_update fixture to match.
Add zakame@zakame.net -> zakame mapping so CI author check passes.
The non-Termux web/TUI install path now scopes to --workspace <name>;
update two fixtures that asserted the old unscoped install commands.
@teknium1
teknium1 force-pushed the hermes/hermes-ff798e6b branch from 83eee58 to 83276f5 Compare June 6, 2026 15:05

@alpindiay alpindiay left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR #40543 Review: fix(install): scope npm installs/audits

Summary: Scopes npm install/audit commands with --workspaces=false, --workspace web, or --workspace ui-tui to prevent the root apps/* glob from pulling in apps/desktop (Electron + node-pty) unnecessarily.

What I checked: security (hardcoded secrets, shell injection, path traversal), bugs (logic errors, off-by-one, race conditions), style (commented-out code, debug prints), and test coverage.

[PASS] What looks good

  • No security issues. All npm arguments come from fixed tuples, not user input. The fix_cmd strings use f-strings with code-constant paths -- no shell injection vector.
  • Test coverage is solid. New tests for TUI install workspace scope and web UI install workspace scope. Existing tests updated to match new argument order.
  • The check_dir logic is correct. Workspace-scoped audits (--workspace web, --workspace ui-tui) resolve check_dir = PROJECT_ROOT, standalone whatsapp-bridge uses its own dir. No logic error.
  • Good comments. Every scoping change has a clear reference to the motivating issue (#38772).
  • No debug prints or commented-out code left behind.
  • package.json convenience scripts (install:root, audit:web, etc.) are a nice UX addition for manual runs.

[NOTE] Minor observations (non-blocking)

  1. Unrelated AUTHOR_MAP addition in scripts/release.py -- zakame@zakame.net mapping is unrelated to npm scoping. Trivial and harmless, but PRs should stay focused.
  2. fix_cmd branch ordering (cosmetic). The if audit_extra and audit_extra[0] == "--workspace" check catches --workspace web/ui-tui, and the elif audit_extra == ["--workspaces=false"] catches the other case. This works because "--workspaces=false" != "--workspace", but it relies on singular vs plural spelling difference. Fine for the limited set of known audit args.

Verdict: LGTM -- safe to merge.

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

Labels

area/config Config system, migrations, profiles 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.

_build_web_ui() npm install missing --workspace web flag breaks "hermes update" on multi-workspace repos

4 participants