npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pi-http-util

v2.0.5

Published

HTTP utility functions for Pi Coding Agent

Downloads

591

Readme

HTTP Utility Extension

A PI Agent extension for fetching web content, transforming HTML into clean output, and making raw HTTP requests. It's main functionality http_fetch is designed to save tokens on LLM converting html to md or other compact shapes before passing it to the LLM.

Usage

Just tell the LLM to do something related to http, if your model has tool usage knowledge everything else is automatic.

Examples:

Give me an overview of the project at https://github.com/kulminaator/pi-http-util

or (your LLM most likely knows the addresses of news pages anyway)

Find me the first 5 headlines from the news today

or

Using our tools, make a http post request with json content {"question": "who is there"} against the server listening on localhost on port 9000

NB! llm might also invoke this on it's own when it feels the need to look something up. If you ask it something like this:

What are the latest changes that were done to threejs?

Installation

Via pi install (recommended)

Install directly from the GitHub repository:

pi install git:github.com/kulminaator/pi-http-util

or from npm:

pi install npm:pi-http-util

This writes the package to your user settings (~/.pi/agent/settings.json) so it is available for all projects. Use -l to install project-locally (.pi/settings.json) instead:

pi install -l git:github.com/kulminaator/pi-http-util

Pin to a specific tag or branch:

pi install git:github.com/kulminaator/[email protected]

Via settings.json

Add the package manually to your settings:

{
  "packages": [
    "git:github.com/kulminaator/pi-http-util"
  ]
}

Manual installation

Clone the repository and place it in pi's extension directory:

git clone https://github.com/kulminaator/pi-http-util.git ~/.pi/agent/extensions/pi-http-util

Or for project-local use:

git clone https://github.com/kulminaator/pi-http-util.git .pi/extensions/pi-http-util

Try it without installing

Test the extension for a single session:

pi -e git:github.com/kulminaator/pi-http-util

What tools get added and What It Does

Tools Registered

| Tool | Description | |------|-------------| | http_fetch | Fetch a URL with configurable HTTP method, headers, body, redirects, strip mode, truncation limits, and strategy | | in_page_search | Search a webpage for text with configurable strip mode (html2md, tags, attributes, whitespace, none), return matching snippets with surrounding context | | raw_http_request | Send raw HTTP requests with no content stripping, file I/O, and size limits |

Architecture

The design of http_fetch

We download original html and pass it through a converter, the most complex converter is html2md

The HTML-to-Markdown converter uses a SAX-style event-driven pipeline:

tokenize(html)  →  emitEvents(html)  →  processEvents(events)  →  markdown
   tokenizer       md_emitter            md_handler

The other methods like strip attributes and strip tags just remove tag attributes or whole tags from the content (with the aim to reduce the ingested size on llm).

Content-Type Safety

The resolveStripMethod(requested, contentType) function checks whether the response Content-Type contains text/html. If not, it returns "none" regardless of the requested mode (unless "none" was already requested). This prevents HTML-specific transformations from corrupting JSON, plain text, or other non-HTML payloads.

File Layout

Source code in src/ Tests in tests

Running the Tests

Requires Node.js ≥ 22 (for --experimental-strip-types to run TypeScript without compilation).

# Run all tests (recommended)
node --experimental-strip-types tests/pi-http-util/run-tests.ts

# Or run a single test file standalone
node --experimental-strip-types tests/pi-http-util/tokenizer.test.ts
node --experimental-strip-types tests/pi-http-util/integration.test.ts

Test writing guidelines:

Tests are split into logical files, each independently runnable:

  • Unit tests — pure functions from the extension modules, no I/O
  • Integration tests — spin up a local http.Server on a random port, exercise fetch + strip against real HTTP routes, tear down after
  • Shared harnesstest-harness.ts provides describe, test, counters, and runSummary() used by all files
  • Timeouts — each test has a 5-second timeout to prevent hangs