Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add Pi extension integration tests (close v2.39.0 follow-up gap) #163

@OthmanAdi

Description

@OthmanAdi

The Pi adapter ships a TypeScript runtime under .pi/skills/planning-with-files/extensions/planning-with-files/ (index.ts, runtime.ts, attestation.ts, plan.ts, constants.ts) but has no integration tests for the extension itself. Current Python tests under tests/test_pi_extension_*.py only verify that the package declares its capabilities; they do not exercise the runtime behavior. This was flagged as a v2.39.0 follow-up.

Goal

Add a small test suite that exercises the Pi extension's event handlers against a mocked @earendil-works/pi-coding-agent context. One test per declared event handler is enough to start.

Acceptance criteria

  • Tests live under .pi/skills/planning-with-files/extensions/planning-with-files/*.test.ts (or a sibling __tests__/ dir, your call).
  • One test per documented event handler: session_start, before_agent_start, tool_call, tool_result, agent_end, session_before_compact, session_shutdown, input. 8 tests minimum.
  • Tests use a mocked ctx (don't require a real Pi runtime). Pattern: stub ctx.fs.readFile, ctx.ui.notify, ctx.model.provider, ctx.model.id per test.
  • At least one test covers each mode: auto, parity, cache-safe, notify.
  • At least one test asserts that the SHA-256 attestation gate blocks injection on a mismatched hash.
  • Add a package.json test script (or use the bundled framework if one is already there). Document the run command in the PR description.

Hints

  1. Read .pi/skills/planning-with-files/extensions/planning-with-files/runtime.ts to learn the event handler surface.
  2. Read .pi/skills/planning-with-files/extensions/planning-with-files/attestation.ts for the attestation gate to test.
  3. Either Bun or Vitest both work; pick what's simplest to wire up.
  4. Don't test the real Pi runtime end-to-end (that requires @earendil-works/pi-coding-agent). Mock the context surface only.
  5. Look at tests/test_pi_extension_capabilities.py for the contract — your TypeScript tests can mirror that shape.

What this gets you

A merged PR closes this issue, earns you a permanent entry in CONTRIBUTORS.md, and meaningfully hardens the Pi adapter going forward. Real attribution on a project used by thousands of developers.

Questions

Comment on this issue or tag @OthmanAdi (or @TomXPRIME who owns the Pi adapter).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions