Skip to content
Draft
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
70 changes: 0 additions & 70 deletions .agents/skills/pi-processes-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,77 +67,8 @@ Always run `npm run reset` before a test session.
2. Prompt must instruct the agent to use npm scripts (not raw shell commands)
3. Prompt should tell the agent to not wait for confirmation between steps

## Example test prompts

### Testing the shipping feature workflow

Tests: process start, foreground execution, output reading, failure handling, re-runs.

```markdown
---
description: Test the shipping feature workflow
---

Run through all steps without waiting for confirmation. Keep messages short.

## 1. Start the server
Start `npm run server` (name: "api-server") as a background process.

## 2. Run tests
Run `npm run test` in the foreground. Note the error.

## 3. Run migrations
Run `npm run migrate` in the foreground. Check server logs to confirm restart.

## 4. Run tests again
Run `npm run test` in the foreground. Note the different error.

## 5. Fix and re-run
Run `npm run seed`, then `npm run test`. Tests should pass.

## 6. Clean up
Kill all processes and clear.
```

### Testing concurrent processes

Tests: multiple background processes, dock log interleaving, list action.

```markdown
---
description: Test concurrent background processes
---

Run through all steps without waiting for confirmation.

## 1. Start services
Start `npm run server` (name: "api-server") and `npm run dev` (name: "dev-server") as background processes.

## 2. Run build and tests
Start `npm run build` (name: "build", alertOnSuccess) and `npm run test` (name: "tests", alertOnFailure).

## 3. React to alerts
Handle each alert as it comes in.

## 4. List processes
Show all processes.

## 5. Clean up
Kill all and clear.
```

## Manual QA checklist

### Dock

- Dock appears when processes start (follow mode)
- `Ctrl+Shift+P` toggles dock visibility
- `h/l` switches focused process
- `f` toggles focus mode (single process filter)
- `Shift+F` toggles follow mode
- `x` kills focused process
- `q` closes/unfocuses dock

### /ps overlay

- `/ps` opens full panel
Expand All @@ -155,7 +86,6 @@ Kill all and clear.
- `j/k` scrolls
- `f` toggles follow mode
- Search: `/` enters search, `Enter` activates, `n/N` cycles, `Esc` clears
- Current match highlight is stronger than non-current matches

## Reporting format

Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ name: CI

on:
push:
branches:
- main
pull_request:

concurrency:
Expand Down Expand Up @@ -32,5 +30,8 @@ jobs:
- name: Typecheck
run: pnpm typecheck

- name: Test
run: pnpm run --if-present test
- name: Unit tests
run: pnpm test

- name: E2E tests
run: pnpm test:e2e
12 changes: 12 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Typecheck
run: pnpm typecheck

- name: Unit tests
run: pnpm test

- name: E2E tests
run: pnpm test:e2e

- name: Get release info
id: release-info
run: |
Expand Down
27 changes: 20 additions & 7 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# pi-processes

Public Pi extension for managing background processes.
Public Pi package for managing background processes. Exposes multiple Pi extensions.

## Tool and command audience

The `process` tool and all `/ps:*` commands are for **LLM use only**, not for users directly. Users can monitor processes via `/ps:logs` and kill them via `/ps:list`, but they should never be the ones starting processes that is the agent's job.
The `process` tool and all `/ps:*` commands are for **LLM use only**, not for users directly. Users can monitor processes via `/ps:logs` and kill them via `/ps:list`, but they should never be the ones starting processes -- that is the agent's job.

During UI tests that require processes to be running, either give the user a prompt to send to the agent (which will start the processes via the `process` tool), or use tmux to drive it programmatically. Never instruct the user to run shell commands manually.

Expand All @@ -14,13 +14,26 @@ During UI tests that require processes to be running, either give the user a pro

## Scripts

- `pnpm typecheck`, `pnpm lint`, `pnpm format`, `pnpm changeset`
- `pnpm typecheck`, `pnpm lint`, `pnpm format`, `pnpm test`, `pnpm test:e2e`, `pnpm changeset`

## Debug flags
## Testing

- `PI_PROCESSES_DEBUG_PREVIEW=1` enables the temporary `process` tool action `debug_preview` for local renderer/UI preview work.
- Keep this flag off in normal use and user-facing examples.
Unit tests live next to the source as `src/**/*.test.ts` and run with `pnpm test`.

Use unit tests for behavior that can be isolated with mocks: registry state, log storage, output parsing, watch matching, event emission, throttling, kill timeout behavior, command parsing, and other pure or narrowly scoped manager internals. Unit tests should stay fast, deterministic, and Pi-independent. Mock child processes, filesystem access, timers, and process-group calls when the test is about manager behavior rather than operating-system behavior.

E2E tests live in `tests/e2e/**/*.e2e.ts` and run with `pnpm test:e2e`. They use `vitest.e2e.config.ts`, real temporary directories, real log files, and real child processes. Use e2e tests when the point is to prove integration with Node process spawning, process groups, stdin/stdout/stderr streams, real filesystem cleanup, executable scripts, shell scripts, Node scripts, or long-running watcher flows. E2E tests must remain Pi-independent and should not import extension UI code.

E2E tests use the fixtures in `tests/e2e/fixtures.ts`. Each test gets a `cwd` temporary directory that is removed with fixture cleanup. Use `addScript(name)` to copy a fixture script into that directory, and `addFile(name, content?)` to create marker/input files during a test. Write commands explicitly in tests, such as `./server.sh`, `bash ./crash-on-file.sh`, or `node ./watcher.mjs`.

Avoid fixed sleeps in both unit and e2e tests. Prefer event-driven helpers that wait for process end, watch matches, output events, or marker-driven script behavior. Use fake timers only for intentional timer behavior in unit tests.

## Structure

- `src/index.ts` - entry, `src/manager.ts` - process manager, `src/config.ts` - config loader, `src/constants/` - types/constants, `src/commands/` - slash commands + settings, `src/tools/` - tool/actions, `src/hooks/` - event hooks, `src/components/` - TUI, `src/utils/` - helpers, `src/test/` - test scripts
- `src/` - pi-agnostic process management (manager, types, protocol, utils). Zero pi imports.
- `extensions/processes/` - core extension: tool registration, settings, hooks, event bridge, request/command handlers
- `extensions/processes-list/` - `/ps`, `/ps:kill`, `/ps:clear` commands and TUI components
- `extensions/processes-logs/` - `/ps:logs` command and log overlay
- `extensions/processes-dock/` - `/ps:dock`, `/ps:pin` commands, dock widget, status widget

See `PLAN.md` for the full architecture and implementation plan.
Loading