Skip to content

feat(bootstrap): allow lifecycle scripts only for agent-browser in SecStack profile - #7

Merged
eggmasonvalue merged 1 commit into
mainfrom
feat/agent-browser-allow-scripts
Sep 6, 2026
Merged

eggmasonvalue merged 1 commit into
mainfrom
feat/agent-browser-allow-scripts

Conversation

@eggmasonvalue

Copy link
Copy Markdown
Owner

Summary

Modern npm (npm 11.17+ and npm 12 under RFC 868) blocks lifecycle scripts for installed dependencies by default. agent-browser relies on "postinstall": "node scripts/postinstall.js" to download/verify platform binaries, ensure executable permissions (chmod 0o755), write the .install-method marker, and configure native shims. Without script permission, npm silently skips the postinstall hook.

Because SecStack installs npm packages using --prefix ~/.pi/secstack-agent/npm (project-scoped), passing CLI flags (--allow-scripts) or environment variables (npm_config_allow_scripts) throws EALLOWSCRIPTS. Furthermore, configuring user-level ~/.npmrc pollutes global npm configuration and triggers warnings across non-Pi projects.

This PR configures allowScripts in the SecStack profile's npm root manifest (~/.pi/secstack-agent/npm/package.json):

  • Bootstrap flow: scripts/bootstrap.mjs ensures ~/.pi/secstack-agent/npm/package.json contains "allowScripts": { "agent-browser": true } before running pi install npm:agent-browser.
  • secpi update --extensions flow: When Pi updates npm packages within the profile, npm reads the manifest, permits the postinstall script for newer versions of agent-browser, and natively preserves the allowScripts field when writing back package.json.
  • Isolation: Lifecycle scripts remain permitted strictly for agent-browser within the profile's npm root, leaving all other packages blocked and user projects unaffected.

Verification

  1. Verified node --check scripts/bootstrap.mjs passes.
  2. Verified ensureNpmAllowScripts() idempotently merges "allowScripts": { "agent-browser": true } into ~/.pi/secstack-agent/npm/package.json.
  3. Verified npm rebuild agent-browser --foreground-scripts and PI_CODING_AGENT_DIR="$HOME/.pi/secstack-agent" pi update --extensions cleanly execute postinstall.js and mark the native binary executable without errors or warnings.

@eggmasonvalue
eggmasonvalue merged commit 6a94473 into main Sep 6, 2026
2 checks passed
@eggmasonvalue
eggmasonvalue deleted the feat/agent-browser-allow-scripts branch September 6, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant