feat(bootstrap): allow lifecycle scripts only for agent-browser in SecStack profile - #7
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Modern npm (npm 11.17+ and npm 12 under RFC 868) blocks lifecycle scripts for installed dependencies by default.
agent-browserrelies on"postinstall": "node scripts/postinstall.js"to download/verify platform binaries, ensure executable permissions (chmod 0o755), write the.install-methodmarker, 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) throwsEALLOWSCRIPTS. Furthermore, configuring user-level~/.npmrcpollutes global npm configuration and triggers warnings across non-Pi projects.This PR configures
allowScriptsin the SecStack profile's npm root manifest (~/.pi/secstack-agent/npm/package.json):scripts/bootstrap.mjsensures~/.pi/secstack-agent/npm/package.jsoncontains"allowScripts": { "agent-browser": true }before runningpi install npm:agent-browser.secpi update --extensionsflow: When Pi updates npm packages within the profile, npm reads the manifest, permits the postinstall script for newer versions ofagent-browser, and natively preserves theallowScriptsfield when writing backpackage.json.agent-browserwithin the profile's npm root, leaving all other packages blocked and user projects unaffected.Verification
node --check scripts/bootstrap.mjspasses.ensureNpmAllowScripts()idempotently merges"allowScripts": { "agent-browser": true }into~/.pi/secstack-agent/npm/package.json.npm rebuild agent-browser --foreground-scriptsandPI_CODING_AGENT_DIR="$HOME/.pi/secstack-agent" pi update --extensionscleanly executepostinstall.jsand mark the native binary executable without errors or warnings.