Skip to content

Commit af5a6c6

Browse files
linmaogQoder-AI
andcommitted
feat(hosts): add Pi coding agent host adapter
Add Pi (pi.dev / @earendil-works/pi-coding-agent) as an analysis-capable source-local host, following the host contribution guide and the Qwen Code / GitHub Copilot host template. Native contracts were verified against @earendil-works/pi-coding-agent; a dated spec lives at docs/specs/2026-07-30-pi-host-support.md (pi-host-support) with stable PHS-AC acceptance ids. - Distribution shell: `pi` manifest in package.json plus a /better-harness prompt template, so `pi install <repo>` discovers the canonical skills/ root and registers the slash command. Pi reuses the existing package.json, so the package still ships six host metadata roots and the Qoder runtime bundle stays Qoder-only. - Configured assets: scripts/agent-customize/providers/pi.mjs inventories settings-declared pi packages, extensions, skills, prompt templates, and AGENTS.md context. It honors Pi's effective state -- autoload:false fails closed, and per-resource allowlists, `!` exclusions, and `+`/`-` overrides narrow reported resources -- and models piHome and the real user home independently so ~/.agents/skills is found under a relocated PI_CODING_AGENT_DIR. - Session evidence: scripts/session-analysis/platforms/pi.mjs reads workspace-matching JSONL v3 transcripts, resolves the session directory as CLI > env > settings > default, treats a custom session directory as the exact flat JSONL directory qualified by the session-header cwd, gates default-tree root existence on a workspace-keyed directory, and keeps partial/malformed usage explicit instead of zero-filling. - Register `pi` across the supported-platform set and --pi-home threading; the A-06 consistency test now covers seven hosts. - Sync the host adapter matrix, site docs (en/zh), references, READMEs, and CHANGELOG; add provider, session, autoload/filter, relocated-home, custom-dir, precedence, usage, and prompt-template expansion tests. Validated with npm run check (896 tests, pack verification) and against real local Pi data. Co-authored-by: QoderAI (Pi) <qoder_ai@qoder.com>
1 parent 3004766 commit af5a6c6

51 files changed

Lines changed: 1944 additions & 75 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: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ Pick your coding agent — you can be looking at your first report in minutes:
153153
| **Qoder Desktop / CLI** | Nothing to install when Qoder Desktop is installed — Better Harness is built in and available to both. Open your repository and use the report prompt below. |
154154
| **GitHub Copilot CLI** | Add the repository marketplace, install `better-harness@better-harness`, start a new session, then use the report prompt below. |
155155
| **Cursor** | Load the plugin from source — see [Installation](#installation). |
156+
| **Pi** | Install the repository as a pi package: `pi install https://github.com/QoderAI/better-harness`, start a new session, then use `/better-harness` or `/skill:better-harness`. |
156157

157158
Once installed, ask Better Harness to generate the host's durable report:
158159

@@ -162,8 +163,8 @@ Once installed, ask Better Harness to generate the host's durable report:
162163

163164
Better Harness scopes behavior claims to relevant Task Episodes and the
164165
surrounding project mechanisms. Qoder produces a Canvas report; Claude Code,
165-
Codex, Cursor, Qwen Code, and GitHub Copilot produce self-contained HTML with
166-
paired Markdown. Missing or partial evidence remains explicit. See the
166+
Codex, Cursor, Qwen Code, GitHub Copilot, and Pi produce self-contained HTML
167+
with paired Markdown. Missing or partial evidence remains explicit. See the
167168
[Host Adapter Matrix](docs/adapters/README.md) for current coverage and output
168169
differences.
169170

@@ -336,6 +337,34 @@ transcripts under `~/.copilot/session-state/`. Copilot records no per-response
336337
token usage, and VS Code Copilot Chat has no supported durable transcript; both
337338
remain explicit evidence boundaries.
338339

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

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

README.zh-CN.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ Better Harness 开放了三个相互关联的层次,而不只是一个斜杠
147147
| **Qoder Desktop / CLI** | 安装 Qoder Desktop 后无需额外安装——Better Harness 已内置,并可在桌面端和 CLI 中使用。打开仓库并使用下方的报告提示词。 |
148148
| **GitHub Copilot CLI** | 添加本仓库 Marketplace,安装 `better-harness@better-harness`,启动新会话,然后使用下方的报告提示词。 |
149149
| **Cursor** | 从源码加载插件——参见[安装](#installation)|
150+
| **Pi** | 以 pi package 安装本仓库:`pi install https://github.com/QoderAI/better-harness`,启动新会话,然后使用 `/better-harness``/skill:better-harness`|
150151

151152
安装完成后,让 Better Harness 生成当前宿主支持的持久化报告:
152153

@@ -155,7 +156,7 @@ Better Harness 开放了三个相互关联的层次,而不只是一个斜杠
155156
```
156157

157158
Better Harness 会将行为断言限定在相关的任务过程片段(Task Episode)及其周边项目机制内。
158-
Qoder 生成 Canvas 报告;Claude Code、Codex、Cursor、Qwen CodeGitHub Copilot 生成自包含的 HTML 报告及配套 Markdown。
159+
Qoder 生成 Canvas 报告;Claude Code、Codex、Cursor、Qwen CodeGitHub Copilot 和 Pi 生成自包含的 HTML 报告及配套 Markdown。
159160
缺失或不完整的证据会被明确标注。有关当前覆盖范围和输出差异,请参阅
160161
[宿主适配器矩阵](docs/adapters/README.md)
161162

@@ -319,6 +320,31 @@ Copilot 会话证据来自 `~/.copilot/session-state/` 下与工作区匹配的
319320
Copilot 不记录逐次响应的 token 用量,VS Code Copilot Chat 也没有受支持的持久化会话记录;
320321
两者均作为明确的证据边界保留。
321322

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

324350
## 从源码开发和打包

docs/adapters/README.md

Lines changed: 21 additions & 6 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
@@ -17,10 +17,11 @@ judgment stays in `skills/`, `models/`, `references/`, `templates/`, and
1717
`scripts/<capability>/`.
1818

1919
The `@qoderai/better-harness` npm package includes the Qoder, Claude Code,
20-
Codex, Cursor, Qwen, and GitHub Copilot plugin metadata roots. The generated
20+
Codex, Cursor, Qwen, Copilot, and Pi plugin metadata roots. The generated
2121
Qoder runtime bundle includes only the Qoder shell, `.qoder-plugin/`; non-Qoder
2222
generated host artifacts remain source-local. Claude Code installs its shell
23-
through the repository's native marketplace manifest.
23+
through the repository's native marketplace manifest. Pi installs the repository
24+
as a pi package through the `pi` manifest in `package.json`.
2425

2526
| Host | Positioning | Shell | Configured Assets | Session Evidence | Default Output | Rules / Prompts | Smoke |
2627
| --- | --- | --- | --- | --- | --- | --- | --- |
@@ -31,6 +32,8 @@ through the repository's native marketplace manifest.
3132
| 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 |
3233
| 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 |
3334

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 |
36+
3437
## Discovery And Evidence
3538

3639
- Claude Code discovers the canonical root `skills/` directory through
@@ -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/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/docs/hosts/adapter-matrix.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,19 @@ host-neutral.
1919
| Claude Code | Analysis-capable source-local host | `.claude-plugin/` | Workspace-matching local Claude transcripts when present | Self-contained HTML + Markdown |
2020
| Codex | Analysis-capable source-local host | `.codex-plugin/` | Codex sessions | Self-contained HTML + Markdown |
2121
| Cursor | Analysis-capable source-local host | `.cursor-plugin/` | Workspace-matched transcripts, metadata, and audit logs; partial coverage stays explicit | Self-contained HTML + Markdown |
22+
| Qwen Code | Analysis-capable source-local host | `qwen-extension.json` | Workspace-matching JSONL transcripts under `~/.qwen/projects/<slug>/chats/` | Self-contained HTML + Markdown |
23+
| GitHub Copilot | Analysis-capable source-local host | `.github/plugin/` | Workspace-matching transcripts under `~/.copilot/session-state/<id>/events.jsonl` | Self-contained HTML + Markdown |
24+
| Pi | Analysis-capable source-local host | `pi` manifest in `package.json` | Workspace-matching JSONL transcripts under `~/.pi/agent/sessions/` | Self-contained HTML + Markdown |
2225

23-
The `@qoderai/better-harness` npm package includes all four plugin metadata
26+
The `@qoderai/better-harness` npm package includes all six plugin metadata
2427
roots. The generated Qoder runtime bundle includes only the Qoder shell;
2528
non-Qoder generated host artifacts remain source-local.
2629

2730
## Output modes
2831

2932
- **Qoder Canvas** — renderer-owned `findings.json`, Canvas-only
3033
`canvas.json`, and `report.canvas.tsx`.
31-
- **HTML visual** — portable Claude Code/Codex/Cursor contract covering
34+
- **HTML visual** — portable Claude Code/Codex/Cursor/Qwen/Copilot/Pi contract covering
3235
`findings.json`, `report.md`, and a self-contained `report.html`
3336
(see the [live demo](pathname:///demo/better-harness-report/)).
3437
- **Markdown-only** — no visual companion.

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)