Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions .github/workflows/publish-pi-extension-stable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Publish pi-extension Stable

on:
workflow_dispatch:
inputs:
confirm:
description: 'Confirm version is already bumped in package.json'
required: true
type: boolean
default: false

permissions:
id-token: write # Required for OIDC
contents: read

concurrency:
group: publish-pi-extension-stable
cancel-in-progress: false

jobs:
publish-pi-extension-stable:
name: Publish pi-extension Stable Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup pnpm
uses: pnpm/action-setup@v2

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint pi-extension
run: pnpm eslint packages/pi-extension

- name: Format check pi-extension
run: pnpm prettier --check packages/pi-extension

- name: Type check pi-extension
run: |
cd packages/pi-extension
pnpm typecheck

- name: Run tests for pi-extension
run: |
cd packages/pi-extension
pnpm test

- name: Build pi-extension
run: |
cd packages/pi-extension
pnpm build

- name: Configure git
run: |
git config --global user.name "Parallel Developers"
git config --global user.email "developers@parallel.ai"

- name: Get current version
id: version
run: |
cd packages/pi-extension
VERSION=$(node -p "require('./package.json').version")
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "Current version: ${VERSION}"

if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
echo "Error: Tag v${VERSION} already exists. Please bump the version in package.json first."
exit 1
fi

- name: Generate changelog
id: changelog
run: |
cd packages/pi-extension

PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")

if [ -z "$PREV_TAG" ]; then
echo "No previous tag found, generating changelog from all commits"
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
else
echo "Generating changelog from ${PREV_TAG} to HEAD"
COMMITS=$(git log ${PREV_TAG}..HEAD --pretty=format:"- %s (%h)" --no-merges)
fi

FEATURES=$(echo "$COMMITS" | grep -E "^- feat(\(.+\))?:" || true)
FIXES=$(echo "$COMMITS" | grep -E "^- fix(\(.+\))?:" || true)
BREAKING=$(echo "$COMMITS" | grep -E "^- (feat|fix)(\(.+\))?!:" || echo "$COMMITS" | grep "BREAKING CHANGE" || true)

CHANGELOG="## v${{ steps.version.outputs.version }}\n\n"

if [ ! -z "$BREAKING" ]; then
CHANGELOG="${CHANGELOG}### ⚠️ Breaking Changes\n\n${BREAKING}\n\n"
fi

if [ ! -z "$FEATURES" ]; then
CHANGELOG="${CHANGELOG}### ✨ Features\n\n${FEATURES}\n\n"
fi

if [ ! -z "$FIXES" ]; then
CHANGELOG="${CHANGELOG}### 🐛 Bug Fixes\n\n${FIXES}\n\n"
fi

echo -e "$CHANGELOG" > /tmp/changelog.md
cat /tmp/changelog.md

- name: Create and push tag
run: |
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
git push origin "v${{ steps.version.outputs.version }}"

- name: Publish to npm
run: |
cd packages/pi-extension
npm publish --tag latest --access public

- name: Create GitHub Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.version.outputs.version }}
release_name: v${{ steps.version.outputs.version }}
body_path: /tmp/changelog.md
draft: false
prerelease: false

- name: Log published version
run: |
echo "✅ Published @parallel-web/pi-extension@${{ steps.version.outputs.version }}"
echo "Install with: npm install @parallel-web/pi-extension"
2 changes: 1 addition & 1 deletion PUBLISHING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This repository uses package-specific workflows for publishing to npm. Each pack
**Current packages:**
- `@parallel-web/ai-sdk-tools` - AI SDK tools for Parallel Web
- `@parallel-web/opencode-plugin` - Opencode plugin for Parallel Web
- `@parallel-web/pi-extension` - Pi extension for Parallel Web

**Note**: This monorepo is designed to support multiple packages. When adding new packages, create dedicated workflows following the naming pattern: `publish-{package-name}-canary.yml` and `publish-{package-name}-stable.yml`.

Expand Down Expand Up @@ -440,4 +441,3 @@ For issues with publishing:
2. Verify npm token permissions
3. Review this guide's troubleshooting section
4. Contact repository maintainers

140 changes: 140 additions & 0 deletions packages/pi-extension/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
# @parallel-web/pi-extension

Pi extension that adds `web_search` and `web_fetch` backed by Parallel.

Install it with:
```
pi install npm:@parallel-web/pi-extension
```

## What It Does

- Registers `web_search`
- Registers `web_fetch`
- Adds a `parallel-login` command for browser auth
- Stores the resulting Parallel API key in Pi's auth store

Auth resolution order:

1. Stored Pi auth for provider key `parallel`
2. `PARALLEL_API_KEY`

## Dogfooding Locally

Build the extension first:

```bash
pnpm --filter @parallel-web/pi-extension build
```

### Option 1: Load It Directly With `pi -e`

This is the fastest way to test a local checkout.

From the repo root:

```bash
pi --no-extensions --no-skills -e ./packages/pi-extension/dist/index.js
```

If the extension loads successfully, Pi will have:

- the `web_search` tool
- the `web_fetch` tool
- the `parallel-login` command
- per-session Parallel `session_id` reuse inside that Pi session

### Option 2: Symlink It Into Pi Extensions

This is better if you want Pi to auto-discover it and support `/reload`.

First build it:

```bash
pnpm --filter @parallel-web/pi-extension build
```

Then symlink the package directory into Pi's global extensions folder:

```bash
mkdir -p ~/.pi/agent/extensions
ln -s \
parallel-npm-packages/packages/pi-extension \
~/.pi/agent/extensions/parallel-pi-extension
```

Then start Pi normally:

```bash
pi
```

After code changes, rebuild and run `/reload` inside Pi:

```bash
pnpm --filter @parallel-web/pi-extension build
```

## Local Auth Testing

### Use Stored Pi Auth

Inside Pi, run:

```text
/parallel-login
```

That opens the browser for Parallel OAuth. On success, the API key is stored in Pi auth under `parallel`.

### Use Environment Variable Instead

```bash
export PARALLEL_API_KEY=your_key_here
pi --no-extensions --no-skills -e ./packages/pi-extension/dist/index.js
```

Note: stored Pi auth is preferred over `PARALLEL_API_KEY` if both exist.

### Override The OAuth Platform URL

For local or staging OAuth testing, set `PARALLEL_PLATFORM_URL` before starting Pi:

```bash
export PARALLEL_PLATFORM_URL=https://your-platform-host
pi --no-extensions --no-skills -e ./packages/pi-extension/dist/index.js
```

This changes the browser login endpoints used by `parallel-login` and on-demand auth.

## Quick Smoke Test

Once Pi is running with the extension loaded, ask something that should force web usage, for example:

```text
Search the web for the latest Parallel docs on OAuth and summarize them.
```

Or ask Pi to call the tool explicitly.

`web_search` requires `search_queries`.

`web_fetch` accepts multiple URLs in a single call, so the agent can batch extraction work instead of parallelizing many single-URL requests.

## Dev Loop

```bash
pnpm --filter @parallel-web/pi-extension build
pnpm --filter @parallel-web/pi-extension test
pnpm --filter @parallel-web/pi-extension typecheck
```

## Notes

- The extension uses the `parallel-web` TypeScript SDK directly.
- Search requests use Parallel SDK `basic` mode.
- Search requests include `client_model` when Pi has an active model selected.
- Search and extract requests reuse a generated `session_id` for the life of the current Pi session.
- The login flow tries to open your browser automatically.
- If automatic callback capture does not complete, the extension falls back to asking you to paste the callback URL.
- Skill suppression inside the extension is prompt-level only. If you want a clean dogfooding session without your usual skills list, start Pi with `--no-skills`.
28 changes: 28 additions & 0 deletions packages/pi-extension/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions packages/pi-extension/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@parallel-web/pi-extension",
"version": "1.0.0",
"description": "Add web search and web fetch to your pi agent",
"author": "Parallel Web",
"license": "MIT",
"type": "module",
"pi": {
"extensions": [
"./dist/index.js"
]
},
"files": [
"dist",
"package.json",
"README.md"
],
"dependencies": {
"parallel-web": "0.5.0",
"typebox": "^1.1.37"
},
"peerDependencies": {
"@mariozechner/pi-coding-agent": "^0.72.0"
},
"devDependencies": {
"@types/node": "^20.0.0"
},
"scripts": {
"build": "tsup",
"dev": "tsup --watch",
"test": "vitest run",
"typecheck": "tsc --noEmit",
"clean": "rm -rf dist"
},
"keywords": [
"pi.dev",
"pi agent",
"extension",
"parallel",
"web",
"search",
"fetch",
"ai"
],
"repository": {
"type": "git",
"url": "git+https://github.com/parallel-web/parallel-npm-packages.git",
"directory": "packages/pi-extension"
},
"publishConfig": {
"access": "public"
}
}
Loading
Loading