Skip to content

Commit 8cf4709

Browse files
authored
Merge pull request #25 from NickyLam/feat/pi-host-adapter
feat(hosts): add Pi coding agent host adapter
2 parents ed4219f + 294e558 commit 8cf4709

54 files changed

Lines changed: 2275 additions & 76 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ observable behavior and compatibility, not every internal refactor.
55

66
## Unreleased
77

8+
### Added
9+
10+
- Pi (pi.dev) is now a supported analysis-capable source-local host. The
11+
repository installs as a pi package (`pi install <repo>`) through a `pi`
12+
manifest in `package.json`, registers a `/better-harness` prompt template,
13+
and gains a Pi configured-asset provider (settings-declared pi packages,
14+
skills, prompt templates, extensions, and `AGENTS.md` context) plus a Pi
15+
session-evidence adapter that reads workspace-matching JSONL v3 transcripts
16+
under `~/.pi/agent/sessions/` with `PI_CODING_AGENT_DIR` and
17+
`PI_CODING_AGENT_SESSION_DIR` overrides. Pi's shell is the `pi` manifest in
18+
the existing `package.json`, so the public npm package still ships six host
19+
metadata roots and the Qoder runtime bundle remains Qoder-specific.
20+
821
### Changed
922

1023
- The `harness analyze` platform gate now names the full supported set
11-
(`qoder, codex, claude, cursor, qwen, copilot`) when it rejects an unsupported
12-
`--platform`, matching the session-analysis and asset-baseline gates. The
13-
existing error prefix and exit behavior are unchanged.
24+
(`qoder, codex, claude, cursor, qwen, copilot, pi`) when it rejects an
25+
unsupported `--platform`, matching the session-analysis and asset-baseline
26+
gates. The existing error prefix and exit behavior are unchanged.
1427

1528
## 0.3.0 - 2026-07-27
1629

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,34 @@ Qwen Code produces a self-contained `report.html` with paired `report.md` and
343343
`findings.json`. Session evidence coverage depends on Qwen Code's available
344344
transcript paths; missing or partial evidence remains explicit.
345345

346+
### Pi
347+
348+
Install the repository as a [pi package](https://pi.dev/docs/latest/packages):
349+
350+
```bash
351+
pi install https://github.com/QoderAI/better-harness
352+
```
353+
354+
Or try it for a single run without changing settings:
355+
356+
```bash
357+
pi -e git:github.com/QoderAI/better-harness
358+
```
359+
360+
Pi discovers the `better-harness` Skill and the `/better-harness` prompt
361+
template through the `pi` manifest in `package.json`. Start a new Pi session
362+
in the repository you want to review and run the report prompt:
363+
364+
```text
365+
/better-harness review this project's AI coding workflow and generate a report
366+
```
367+
368+
Pi defaults to a self-contained `report.html` with paired `report.md` and
369+
`findings.json` under the repository's `.pi/better-harness` report root. Pi
370+
session evidence is read from workspace-matching JSONL transcripts under
371+
`~/.pi/agent/sessions/`; missing evidence stays explicit rather than being
372+
inferred.
373+
346374
## Develop and package from source
347375

348376
Development requires Node.js `>=22.20.0 <25.0.0` and npm

README.zh-CN.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,31 @@ qwen extensions install QoderAI/better-harness
325325
Qwen Code 产出自包含的 `report.html`,并配套 `report.md``findings.json`
326326
会话证据覆盖范围取决于 Qwen Code 可用的会话记录路径;缺失或不完整的证据保持显式标注。
327327

328+
### Pi
329+
330+
将本仓库作为 [pi package](https://pi.dev/docs/latest/packages) 安装:
331+
332+
```bash
333+
pi install https://github.com/QoderAI/better-harness
334+
```
335+
336+
或在不修改设置的情况下单次试用:
337+
338+
```bash
339+
pi -e git:github.com/QoderAI/better-harness
340+
```
341+
342+
Pi 通过 `package.json` 中的 `pi` manifest 发现 `better-harness` Skill 和
343+
`/better-harness` 提示模板。在需要审查的仓库中启动新的 Pi 会话,运行报告提示词:
344+
345+
```text
346+
/better-harness 审查此项目的 AI 编码工作流并生成报告
347+
```
348+
349+
Pi 默认在仓库的 `.pi/better-harness` 报告根目录下生成自包含的 `report.html`
350+
及配套的 `report.md``findings.json`。Pi 会话证据读自
351+
`~/.pi/agent/sessions/` 下与工作区匹配的 JSONL 会话记录;缺失的证据会被明确标注而不会被推断。
352+
328353
<a id="develop-and-package-from-source"></a>
329354

330355
## 从源码开发和打包

docs/adapters/README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Host Adapter Matrix
22

3-
This is the single entry point for Claude Code, Codex, Qoder, Cursor, Qwen, and
4-
GitHub Copilot host boundaries. Do not create `docs/adapters/claude-code.md`,
3+
This is the single entry point for Claude Code, Codex, Qoder, Cursor, Qwen,
4+
GitHub Copilot, and Pi host boundaries. Do not create `docs/adapters/claude-code.md`,
55
`docs/adapters/codex.md`, `docs/adapters/qoder.md`, `docs/adapters/cursor.md`,
6-
`docs/adapters/qwen.md`, or `docs/adapters/copilot.md` by default.
6+
`docs/adapters/qwen.md`, `docs/adapters/copilot.md`, or `docs/adapters/pi.md` by default.
77

88
Adding another host? Follow
99
[Contributing a New Coding Agent Host](contributing-new-coding-agent.md) before
@@ -16,11 +16,13 @@ providers, real session-evidence adapters, and output modes. Canonical product
1616
judgment stays in `skills/`, `models/`, `references/`, `templates/`, and
1717
`scripts/<capability>/`.
1818

19-
The `@qoderai/better-harness` npm package includes the Qoder, Claude Code,
20-
Codex, Cursor, Qwen, and GitHub Copilot plugin metadata roots. The generated
21-
Qoder runtime bundle includes only the Qoder shell, `.qoder-plugin/`; non-Qoder
22-
generated host artifacts remain source-local. Claude Code installs its shell
23-
through the repository's native marketplace manifest.
19+
The `@qoderai/better-harness` npm package includes six filesystem metadata
20+
roots for Qoder, Claude Code, Codex, Cursor, Qwen, and Copilot, plus Pi install
21+
metadata in the existing `package.json`. The generated Qoder runtime bundle
22+
includes only the Qoder shell, `.qoder-plugin/`; non-Qoder generated host
23+
artifacts remain source-local. Claude Code installs its shell through the
24+
repository's native marketplace manifest. Pi installs the repository as a pi
25+
package through the `pi` manifest in `package.json`.
2426

2527
| Host | Positioning | Shell | Configured Assets | Session Evidence | Default Output | Rules / Prompts | Smoke |
2628
| --- | --- | --- | --- | --- | --- | --- | --- |
@@ -30,6 +32,7 @@ through the repository's native marketplace manifest.
3032
| Cursor | Analysis-capable source-local host | `.cursor-plugin/` | `scripts/agent-customize/providers/cursor.mjs` | `scripts/session-analysis/platforms/cursor.mjs` | self-contained HTML + Markdown | `.cursor` + `.codex` compatibility + `AGENTS.md` | `agent --plugin-dir . --mode ask --print` -> Cursor evidence bundle -> validated `html` render |
3133
| Qwen Code | Analysis-capable source-local host | `qwen-extension.json` | `scripts/agent-customize/providers/qwen.mjs` | `scripts/session-analysis/platforms/qwen.mjs` | self-contained HTML + Markdown | `.qwen` + `QWEN.md` + `AGENTS.md` | `harness prepare --platform qwen` -> finalize with `html-report` validation |
3234
| GitHub Copilot | Analysis-capable source-local host | `.github/plugin/` | `scripts/agent-customize/providers/copilot.mjs` | `scripts/session-analysis/platforms/copilot.mjs` | self-contained HTML + Markdown | `.github` + `AGENTS.md` + `~/.copilot` | `copilot plugin marketplace add .` -> `copilot plugin install better-harness@better-harness` -> configured-asset baseline -> validated `html` render |
35+
| Pi | Analysis-capable source-local host | `pi` manifest in `package.json` | `scripts/agent-customize/providers/pi.mjs` | `scripts/session-analysis/platforms/pi.mjs` | self-contained HTML + Markdown | `.pi` + `.agents` + `AGENTS.md` | `pi install <source>` or `pi -e <source>` -> `/better-harness` prompt template -> validated `html` render |
3336

3437
## Discovery And Evidence
3538

@@ -79,13 +82,25 @@ through the repository's native marketplace manifest.
7982
`.github/plugin/` shell is native Copilot install/discovery metadata included
8083
in the public npm package; it does not own Copilot evidence collection.
8184

85+
- Pi configured assets are inventoried through
86+
`scripts/agent-customize/providers/pi.mjs`, covering `~/.pi/agent`
87+
(settings-declared pi packages, skills, prompt templates, extensions, the
88+
global `AGENTS.md` context file), the shared `.agents/skills` directories,
89+
and project `.pi` assets. Session evidence comes from
90+
`scripts/session-analysis/platforms/pi.mjs`, which reads workspace-matching
91+
JSONL transcripts under `~/.pi/agent/sessions/--<cwd-slug>--/` and honors the
92+
`PI_CODING_AGENT_DIR` and `PI_CODING_AGENT_SESSION_DIR` overrides. Pi
93+
discovers the canonical root `skills/` directory and the `prompts/`
94+
templates through the `pi` manifest in `package.json`; that manifest is
95+
install/discovery metadata and does not own Pi evidence collection.
96+
8297
## Output Modes
8398

8499
Canonical templates live under `templates/reporting/`.
85100

86101
- `qoder-canvas.md`: Qoder Canvas output contract, covering renderer-owned
87102
`findings.json`, Canvas-only `canvas.json`, and `report.canvas.tsx`.
88-
- `html-visual.md`: portable Claude Code/Codex/Cursor/Qwen/Copilot visual output contract, covering
103+
- `html-visual.md`: portable Claude Code/Codex/Cursor/Qwen/Copilot/Pi visual output contract, covering
89104
`findings.json`, `report.md`, and `report.html`.
90105
- Markdown-only output has no visual companion.
91106

docs/adapters/contributing-new-coding-agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ sessions, reports, and packaging have different owners. Search for the existing
134134
host set before editing:
135135

136136
```bash
137-
rg -n "qoder|codex|claude|cursor|qwen|copilot" scripts test references templates docs package.json
137+
rg -n "qoder|codex|claude|cursor|qwen|copilot|pi" scripts test references templates docs package.json
138138
```
139139

140140
Use the results as an inventory, not a replacement template. Typical registration

docs/adrs/directory-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ scripts/
7676
core-change-watch/ # [active] static structure/core-path/history evidence
7777
session-analysis.mjs # [active] thin shim; new exports -> scripts/session-analysis/
7878
session-analysis/ # [active] session evidence collection/normalization
79-
platforms/<host>.mjs # Qoder/Codex/Claude/Cursor/Qwen/Copilot host adapters
79+
platforms/<host>.mjs # Qoder/Codex/Claude/Cursor/Qwen/Copilot/Pi host adapters
8080
ides/<ide>/ # target editor-local evidence not covered by host adapters
8181
<business-capability>/ # [target] new capability owner
8282
cli.mjs # use cli.mjs for new capabilities

docs/community.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This is the complete reference. For the common cases, see Start Here above.
3737
| Style grammar | Yes | `templates/style/` | Directive-only visual language; no runnable skeletons | Selected by report/style routing | Style-template tests and no copied runtime skeletons |
3838
| Structured knowledge | Candidate only | `knowledge-base/{official,community}/...` | `knowledge.md`, interim `schema.json`, fixtures, namespace uniqueness | Docs-only until registry spec, compiler, and binding tests exist | Namespace check, schema/fixture review, migration note |
3939
| Examples and operating models | Yes | `case-studies/` | Named example, scope, evidence boundary, non-runtime status | Reference material only unless separately bound | Link/path check; no runtime-policy claims |
40-
| Host shell and packaging | Thin, or generated only after a split trigger | `.claude-plugin/`, `.qoder-plugin/`, `.cursor-plugin/`, `.codex-plugin/`, `.github/plugin/`, `qwen-extension.json`, future lifecycle shells | Install/discovery metadata and pointers to canonical owners | Public npm package includes all six current metadata roots; the Qoder runtime bundle includes only `.qoder-plugin/`, and generated host artifacts stay source-local | `scripts/npm-package/` verification, or split adapter note plus target builder |
40+
| Host shell and packaging | Thin, or generated only after a split trigger | `.claude-plugin/`, `.qoder-plugin/`, `.cursor-plugin/`, `.codex-plugin/`, `.github/plugin/`, `qwen-extension.json`, the `pi` manifest in `package.json`, future lifecycle shells | Install/discovery metadata and pointers to canonical owners | Public npm package includes all six current metadata roots; the Qoder runtime bundle includes only `.qoder-plugin/`, and generated host artifacts stay source-local | `scripts/npm-package/` verification, or split adapter note plus target builder |
4141

4242
## Non-Extension Boundaries
4343

docs/concepts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ until you need diagnosis. See [../models/routing.md](../models/routing.md).
7373
| Project evidence | `better-harness core-change-watch` | Project, history, core-path, and diff signals |
7474
| Change confidence | `hooks/git-scripts/blast-radius` | Symbol-graph blast radius of a change |
7575
| Dependency governance | `better-harness dependency-governance` | Update automation, audit, stale-dep signals |
76-
| Session evidence | `better-harness session-analysis` | Normalize Qoder, Codex, Claude, Cursor, Qwen, or Copilot session behavior |
76+
| Session evidence | `better-harness session-analysis` | Normalize Qoder, Codex, Claude, Cursor, Qwen, Copilot, or Pi session behavior |
7777
| Agent assets | `better-harness coding-agent-practices inventory` | Inventory configured agent surfaces |
7878
| Guardrails | `hooks/`, `scripts/agent-guardrails` | Secret scanning and lifecycle checks |
7979

docs/glossary.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ for extension surfaces, read [community.md](community.md).
6060
| `core-change-watch` | Project, history, core-path, and current-diff evidence collection. | [scripts/core-change-watch](../scripts/core-change-watch) |
6161
| Blast radius | The symbol-graph reach of a change, computed with tree-sitter (JS/TS, Go, Python) as a git hook. | [hooks/git-scripts/blast-radius](../hooks/git-scripts/blast-radius) |
6262
| `dependency-governance` | Update-automation, audit, and stale-dependency signals. | [scripts/dependency-governance](../scripts/dependency-governance) |
63-
| `session-analysis` | Normalizes Qoder, Codex, Claude, Cursor, Qwen, or Copilot agent session behavior into evidence. | [scripts/session-analysis](../scripts/session-analysis) |
63+
| `session-analysis` | Normalizes Qoder, Codex, Claude, Cursor, Qwen, Copilot, or Pi agent session behavior into evidence. | [scripts/session-analysis](../scripts/session-analysis) |
6464
| Guardrails | Change-time enforcement: secret scanning and lifecycle hook checks. | [hooks](../hooks), [scripts/agent-guardrails](../scripts/agent-guardrails) |
6565

6666
## The Action Loop (Report → Change)
@@ -79,7 +79,7 @@ for extension surfaces, read [community.md](community.md).
7979
|---|---|---|
8080
| Skill | A repeatable agent workflow defined by `SKILL.md` frontmatter plus a concise workflow. | [community.md](community.md); report use: [report contract](../skills/better-harness/SKILL.md#report-output) |
8181
| Host adapter | Per-host discovery and evidence-shape glue (e.g. Qoder, Codex); keeps the engine host-neutral. | [adapters/README.md](adapters/README.md) |
82-
| Host shell | Thin host metadata (`.claude-plugin/`, `.qoder-plugin/`, `.cursor-plugin/`, `.codex-plugin/`, `.github/plugin/`, `qwen-extension.json`, or a future lifecycle shell) that exposes canonical behavior without owning product logic; the public npm package ships all six current metadata roots, while the Qoder runtime bundle includes only `.qoder-plugin/`. | [ARCHITECTURE.md](ARCHITECTURE.md) |
82+
| Host shell | Thin host metadata (`.claude-plugin/`, `.qoder-plugin/`, `.cursor-plugin/`, `.codex-plugin/`, `.github/plugin/`, `qwen-extension.json`, the `pi` manifest in `package.json`, or a future lifecycle shell) that exposes canonical behavior without owning product logic; the public npm package ships all six current metadata roots, while the Qoder runtime bundle includes only `.qoder-plugin/`. | [ARCHITECTURE.md](ARCHITECTURE.md) |
8383
| Canonical owner | The single directory that owns a behavior's product judgment; host shells and mirrors point back to it. | [ARCHITECTURE.md](ARCHITECTURE.md) |
8484

8585
## "I Want To… → Use"

0 commit comments

Comments
 (0)