← Catalog

@senad-d/protectme

Pi extension that guards agent network and website access with global and project allow lists.

Extension

Install

Install with PiG

pig install npm:@senad-d/protectme

Install with Pi

pi install npm:@senad-d/protectme
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "image": "https://raw.githubusercontent.com/senad-d/ProtectMe/main/img/demo.gif",
  "extensions": [
    "./src/extension.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 0.2.1 (README.md). PiG does not review it.

ProtectMe logo

pi package npm license Quality Gate Status

Network access guardrails for pi.
Let agents and direct Pi bash commands reach only approved network destinations from the terminal.


ProtectMe is a Pi extension for coding agents. It guards supported shell-network requests made by Pi agents or direct !/!! user bash commands, checks destinations against global and project allow lists, and blocks disallowed hosts before execution.

ProtectMe demo
ProtectMe demo: inspect and edit network guard configuration inside pi
  • Network guard boundary: covers supported curl, wget, http, and https invocations from Pi agent bash calls and Pi user bash commands.
  • Allow-list and deny-list policy: default block mode permits a small developer starter list and denies other unknown hosts; a deny list refuses hosts outright; allow mode is available as an explicit temporary bypass.
  • Project-aware configuration: trusted project config can extend global allow lists and override mode.
  • Prompted approvals: a repeated blocked request opens one prompt: allow or deny, once, for the session, for the project, or globally.
  • Secret-aware logging: blocked-attempt logs are local, bounded, and redact common credential-bearing command fragments.

Security: pi packages run with your full system permissions. ProtectMe is a guardrail for supported Pi command flows, not a sandbox, firewall, or proxy. Read SECURITY.md.

Table of Contents


Quick Start

pi install npm:@senad-d/protectme

Review the built-in starter allow list and add any narrow project-specific hosts as shown in Configuration, then start pi:

pi

Open the ProtectMe panel:

/protectme

Try a guarded request through Pi:

Ask the agent to run curl https://example.com only if ProtectMe allows the host; otherwise explain the block.

ProtectMe guards supported request-making shell commands. It does not run scanners, make network calls itself, or require API credentials.


Installation

ScopeCommandNotes
Globalpi install npm:@senad-d/protectmeLoads in every trusted pi project.
Project-localpi install npm:@senad-d/protectme -lWrites to .pi/settings.json in the current project.
One runpi -e npm:@senad-d/protectmeTry without changing settings.
Gitpi install git:github.com/senad-d/ProtectMe@<tag>Pin a tag or commit.
Local checkoutpi --no-extensions -e .Develop or smoke-test this repository in isolation.

Source checkout:

git clone https://github.com/senad-d/ProtectMe.git
cd ProtectMe
npm ci
npm run validate
pi --no-extensions -e .

Configuration

ProtectMe reads JSON config from global and project-local files. It does not require secrets. On runtime load, it creates a missing global config at ~/.pi/agent/protectme.json with the built-in defaults; project config is still only written when you confirm a /protectme edit or pick a project choice in the approval prompt.

ScopePathNotes
Global~/.pi/agent/protectme.jsonApplies across projects. PI_CODING_AGENT_DIR moves this path in standard Pi installations.
Project.pi/protectme.jsonApplies only when Pi reports the project as trusted. Inside a linked git worktree, this path resolves to the main worktree, so saved entries outlive the worktree. On save, ProtectMe adds protectme.json and .gitignore to .pi/.gitignore unless git already tracks the config.
SessionThe file named by PROTECTME_SESSION_CONFIGOptional. Holds the hosts allowed or denied "for session". Without it they are kept in memory until the session ends.
Block log.pi/agent/protectme_log.jsonlAppend-only local log for blocked attempts and for choices made in the approval prompt. Requests to listed hosts are not logged. Resolves to the main worktree like project config, and ProtectMe writes a .gitignore next to it when none exists.

Schema:

{
  "mode": "block",
  "allowList": ["example.com", "api.example2.com"],
  "denyList": ["tracker.example"]
}

Fields:

FieldRequiredMeaning
modeNo"block" blocks disallowed hosts. "allow" permits detected requests without prompts or blocked-attempt logs.
allowListNoHost entries allowed in block mode. Entries are normalized and deduplicated.
denyListNoHost entries refused in block mode, in the same format as allowList. A deny entry wins over an allow entry: with example.com allowed and api.example.com denied, api.example.com is refused. A denied host is refused at once, with no prompt.

A missing global config is initialized automatically with mode: "block" and this built-in starter allow list:

{
  "mode": "block",
  "allowList": [
    "localhost",
    "127.0.0.1",
    "::1",
    "pi.dev",
    "github.com",
    "npmjs.com",
    "registry.npmjs.org",
    "nodejs.org"
  ]
}

Resolution order:

  • Built-in starter entries load first.
  • Global config appends additional allowList entries.
  • Trusted project config appends additional allowList entries.
  • Global and trusted project denyList entries are joined. The starter list has none.
  • Trusted project mode overrides global mode when present.
  • Untrusted project config is ignored without reading project-local contents.
  • Invalid or unreadable loaded config fails closed with mode: "block" and an empty effective allow list. Deny entries of the config that is still valid keep applying.

Host matching rules:

  • example.com allows example.com, paths on that host, and child subdomains such as api.example.com.
  • api.example2.com allows itself and child subdomains, but not parent domain example2.com.
  • Public suffix entries such as com or co.uk are ignored and reported as warnings.
  • Single-label non-localhost entries such as internal-service match only that exact host.
  • localhost, IPv4, and IPv6 entries match exactly, including ports such as localhost:3000.
  • Local subdomains such as app.localhost are not covered by localhost; add app.localhost or another exact local hostname to your project allow list when needed.

Session file:

  • Set the environment variable PROTECTME_SESSION_CONFIG to a file path to keep the session lists in a file. A host program sets it to share one list between several Pi sessions.
  • The file has the shape { "allowList": ["example.com"], "denyList": ["tracker.example"] }. ProtectMe creates it on the first "for session" choice and reads it on every request.
  • Session entries apply on top of the config: a session deny wins over every allow, and a config deny wins over a session allow.
  • PROTECTME_SESSION_READS is a separate setting for research sessions. ask opens the prompt on the first try of a read-only curl or wget request and adds the row "Allow all read-only requests for this session". open lets read-only requests through unasked.

Blocked-attempt log retention:

  • .pi/agent/protectme_log.jsonl is append-only local state for blocked attempts and prompt choices.
  • ProtectMe reads recent entries with a bounded tail window and does not compact, upload, or delete the log.
  • Delete or truncate .pi/agent/protectme_log.jsonl if you want to clear local history.

Approval prompt

The first request to an unlisted host is blocked, and the agent is told to repeat it if the host is needed. The repeat opens the prompt. A session without a UI cannot ask, so the request stays blocked.

ProtectMe blocked a read-only network request.
Hosts: api.example.org, cdn.example.net
Saves: example.org (and its subdomains), example.net (and its subdomains)
  • The first line says whether the request is read-only or sends data. Read-only means a curl or wget call with no body, form, upload or method option.
  • Hosts lists every unlisted host of the command. One choice applies to all of them.
  • Saves is what a saved choice writes for each host: the registrable domain, which covers its subdomains. An IP address or localhost is saved as it is.

Choices:

ChoiceEffect
Allow onceThis call runs. Nothing is saved.
Allow for sessionThe hosts are allowed until the session ends, or in the session file when PROTECTME_SESSION_CONFIG is set.
Allow for projectAdds the entries to allowList in .pi/protectme.json.
Allow globallyAdds the entries to allowList in ~/.pi/agent/protectme.json.
Deny onceThis call is blocked. Nothing is saved. Cancelling the prompt does the same.
Deny for sessionThe hosts are refused for the session, with no further prompt.
Deny for projectAdds the entries to denyList in .pi/protectme.json.
Deny globallyAdds the entries to denyList in ~/.pi/agent/protectme.json.

The list shows the four deny choices first, so the cursor starts on Deny once. The project choices are missing when the project is not trusted. A choice whose config file is invalid or unreadable is missing too. To save another entry than the suggested one, use /protectme or edit the config file.

Other extensions can follow the prompt: ProtectMe emits herdr:blocked on pi.events with { active: true, id, label, guard } when the prompt opens and { active: false, id } when it closes. guard holds the command with secrets redacted, the hosts, the reason, the saved entry and the choice labels.


Commands and Tools

SurfaceNameUse it for
Command/protectmeInspect effective config, edit project settings, and view recent blocked hosts in Pi TUI mode.
Event guardtool_callBlock unsupported destinations in agent bash tool calls before execution.
Event guarduser_bashBlock unsupported destinations in direct Pi !/!! user bash commands before execution.
Custom toolsNoneProtectMe is event-based and does not register agent tools.

Guarded request CLIs:

  • curl
  • wget
  • http
  • https

ProtectMe also inspects approved non-network wrappers such as sudo, env, time, timeout, and nice when they launch a supported request CLI. URL-bearing proxy and resolver options are treated as additional destinations. Static option sources that can hide destinations, such as curl --config or wget --input-file, fail closed. A bare number in a target position, such as the value of an option ProtectMe does not know, also fails closed instead of being read as an IPv4 shorthand host.

What ProtectMe cannot see:

  • ProtectMe inspects only the command line of the guarded CLIs above. It is not a network sandbox.
  • Network access made by other programs is not checked. Examples: rustup-init downloading a toolchain, cargo fetching crates, npm install, pip install, git clone, scripts in any language, and anything a downloaded installer does after it starts.
  • Use OS or container network controls when you need every outbound connection enforced.

Suggested workflow:

  1. Start with /protectme to inspect mode, trust status, and allow-list counts.
  2. Keep mode as block and add only the narrow project-specific hosts you need, such as app.localhost for local subdomain testing.
  3. Let the agent or direct Pi !/!! commands run supported request CLIs normally.
  4. Read the approval prompt before choosing: check the hosts and the Saves line, and prefer the narrowest scope that does the job.

Troubleshooting

ProblemTry
Unexpected blockRun /protectme, inspect mode and counts, then add the intended host to project config or global config. A block that says "the host is on the deny list" needs the entry removed from denyList in the config or the session file.
Config warningFix invalid JSON, schema errors, unreadable files, or ignored invalid allow-list entries.
Project config ignoredTrust the project in Pi or use global config. ProtectMe does not read untrusted .pi/protectme.json.
Prompt unavailableUse Pi TUI mode for confirmation prompts, or edit config manually. Repeated attempts fail closed without UI confirmation.
Direct shell command was not blockedRun commands through Pi !/!!; commands outside Pi are outside ProtectMe's boundary.
Unsupported CLI was not blockedProtectMe v1 covers curl, wget, http, and https; use OS/container controls for other network tools.
Need a temporary bypassSet project config to { "mode": "allow" }, then switch back to block when finished.
Want a clean smoke testRun pi --no-extensions -e . from this repository.

Development and Validation

npm ci
npm run typecheck
npm run lint
npm run format:check
npm run test
npm run test:coverage
npm run check:pack
npm run validate

Isolated interactive smoke test:

pi --no-extensions -e .

npm run validate includes type checking, ESLint, formatting checks, script syntax checks, automated tests, and package dry-run validation. CI runs the same validation chain.

Project docs:


Update and Uninstall

pi update --extensions                    # update installed pi packages
pi update npm:@senad-d/protectme          # update ProtectMe only
pi remove npm:@senad-d/protectme          # remove global install
pi remove npm:@senad-d/protectme -l       # remove project-local install

Publishing

ProtectMe publishes to npm as @senad-d/protectme.

npm login
npm whoami
node scripts/publish-npm.mjs

Run the publish script only from a clean working tree after updating CHANGELOG.md.


License

MIT