-
-
Notifications
You must be signed in to change notification settings - Fork 464
feat: add Pi Coding Agent support #862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
zhushanwen321
wants to merge
94
commits into
tiann:main
Choose a base branch
from
zhushanwen321:feat-pi-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 88 commits
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
9fcfcf2
docs: spec for hapi-pi-agent-backend
zhushanwen321 d629bab
docs: spec retrospect for hapi-pi-agent-backend
zhushanwen321 dfd4fd1
docs: plan for hapi-pi-agent-backend
zhushanwen321 8a193ac
docs: plan retrospect for hapi-pi-agent-backend
zhushanwen321 862be6b
feat(pi): add hapi pi command with JSONL transport and event converter
zhushanwen321 5b907b0
fix(pi): add Pi RPC types, fix double-cleanup/double-start/converter …
zhushanwen321 ad66c3f
docs: dev phase reviews and test results for hapi-pi-agent-backend
zhushanwen321 c17ec11
docs: taste review v2 pass after type definition fixes
zhushanwen321 ad061c9
docs: dev retrospect for hapi-pi-agent-backend
zhushanwen321 1652b97
test: test execution for hapi-pi-agent-backend (20/20 pass)
zhushanwen321 7d937aa
fix: add taste_review symlink for gate pattern match
zhushanwen321 1297f6a
docs: test retrospect for hapi-pi-agent-backend
zhushanwen321 e71b743
fix(web): add pi to MODEL_OPTIONS Record type
zhushanwen321 25492f0
ci: PR and CI evidence for hapi-pi-agent-backend
zhushanwen321 c88f84e
docs: overall retrospect for hapi-pi-agent-backend (all 5 phases)
zhushanwen321 8c59637
test(pi): add buffer split, missing fields, and handleResponse tests
zhushanwen321 845d093
fix(pi): set requiresRuntimeAssets to false — pi runs as subprocess, …
zhushanwen321 80ef884
refactor(cli): lazy import ensureRuntimeAssets to reduce startup over…
zhushanwen321 72ecd85
docs: add 15 manual E2E protocol test cases (TC-4-xx) based on real P…
zhushanwen321 51e49ef
test: E2E protocol test results for hapi-pi (11/15 pass)
zhushanwen321 ba6f356
test: fix TC-4-11 result — Pi set_model works with correct provider/m…
zhushanwen321 387ea3d
chore: remove .xyz-harness/ from git tracking, add to .gitignore
zhushanwen321 6c28949
fix(pi): resolve web UI bugs for hapi-pi integration
zhushanwen321 1acfe9f
fix(pi): address 4 web UI display bugs in hapi-pi integration
zhushanwen321 2031e1b
fix(pi): review round 1 - 1 must-fix issue
zhushanwen321 3437b78
fix(pi): review round 2 - 4 must-fix issues
19f5872
fix(pi): add session resume support and fix review issues
zhushanwen321 8554eb6
fix(pi): review round 1 - 3 must-fix issues
zhushanwen321 6eb4264
fix(pi): review round 2 - 2 must-fix issues
zhushanwen321 49d618b
refactor(workflow): improve pi-adaptation-review-loop robustness
zhushanwen321 2432074
test(pi): add coverage for pi flavor across shared, cli, and web
zhushanwen321 67b0cd9
feat(pi): implement P0 — context budget bar + dynamic model discovery
zhushanwen321 fb578d4
fix(pi): address code review findings + pre-existing test issue
zhushanwen321 2aaf3b1
feat(pi): P1 — session rename sync, thinking level UI, skills/commands
zhushanwen321 a2ba76f
feat(pi): implement P2 features — steer, queue modes, history, native…
zhushanwen321 b15ae77
feat(pi): implement P3 advanced features — compact, fork, clone, swit…
zhushanwen321 6787f3e
refactor(pi): clean up runPi.ts imports and readability
zhushanwen321 3fadc54
fix(pi): remove native image passing, fix version pollution
zhushanwen321 6010a6f
refactor(pi): extract hub helper, unify web hooks, fix import style
zhushanwen321 e033aac
chore: untrack .agents/skills and .pi, fix .xyz-harness in gitignore
zhushanwen321 da1d8a0
refactor: remove unused text message id from converter layer, update …
zhushanwen321 e83b77d
fix: update tests for pi resume support and text id removal
zhushanwen321 743c95c
fix: restore cursor resume branch in buildCliArgs
zhushanwen321 5ace364
refactor: remove pi-specific rename from syncEngine, align with other…
zhushanwen321 7d640ac
refactor: remove effort field from sessionConfigRpc, Pi self-handles RPC
zhushanwen321 dd1f028
refactor: consolidate Pi RPC layer from 36 methods to 3 generics
zhushanwen321 d32cc0f
chore: revert unrelated apiMachine test change
zhushanwen321 04b5c93
refactor: remove unused ThinkingLevel capability from flavors
zhushanwen321 f38b29a
refactor: drop Pi prefix from generic RPC method names
zhushanwen321 84a5dcb
refactor: remove 13 Pi RPC methods with no UI consumers
zhushanwen321 8eede35
refactor: extract session.ts and loop.ts from runPi.ts
zhushanwen321 b3820b2
refactor: normalize Pi file naming and improve test coverage
zhushanwen321 7899429
test: add E2E harness with 4 core helpers and integration specs
zhushanwen321 53312ec
fix: resolve Pi model selection and thinking level issues
zhushanwen321 95d96ad
refactor: remove 29 dead exports from feat-pi-support
zhushanwen321 b68b718
fix: resolve 7 PR review issues in Pi support
zhushanwen321 9f81ccf
fix: normalize Pi model object to string in hub sessionCache (#5), re…
zhushanwen321 510ca2c
fix(pi): preserve piAvailableModels on resume, document SetSessionCon…
zhushanwen321 b1fab89
refactor: remove unused Pi types, extract JsonLineParser, clean up re…
zhushanwen321 d1e5b4c
chore: remove unrelated E2E test harness from Pi support PR
zhushanwen321 ecc4710
merge: resolve conflicts with upstream/main
zhushanwen321 1ce5a1e
fix: wrap cursor model change handler for union type compatibility
zhushanwen321 157ea6b
fix: apply startup --model to Pi and remove duplicate lockfile entry
zhushanwen321 7f47a26
fix: update test expectation for effort endpoint error message
zhushanwen321 0d9c0d6
fix(pi): resolve 8 link-review defects + abort session termination
zhushanwen321 462894a
fix: restore cli version from integration test placeholder
zhushanwen321 3d892d0
fix(pi): send restored thinking level to Pi subprocess on startup
zhushanwen321 f277cf2
fix: restore cli package version from integration test residue
zhushanwen321 00cd34c
Merge remote-tracking branch 'upstream/main' into feat-pi-support
zhushanwen321 ebd4556
fix(pi): switch-to-remote handler preserves session instead of termin…
zhushanwen321 39d6997
fix(pi): remove permission mode selector (Pi RPC has no runtime switc…
zhushanwen321 a046ed5
fix(cli): realpath workspace root in apiMachine test assertion
zhushanwen321 ba0ffc8
fix(pi): keepalive reads current mode instead of constructor-time sta…
zhushanwen321 7dbd6c5
fix(pi): runner no longer passes permission flags to Pi subprocess
zhushanwen321 b2a67a6
fix(pi): preserve provider identity when persisting selected Pi model
zhushanwen321 326f758
fix(pi): model picker checkmark follows provider-qualified selection
zhushanwen321 56c1eeb
fix(pi): steer messages consumed immediately, not queued in pendingLo…
zhushanwen321 1211cdc
fix(pi): clear stale thinking level when switching to non-reasoning m…
zhushanwen321 c639dfb
fix(pi): return provider-qualified model in SetSessionConfig applied
zhushanwen321 264bc88
fix(pi): preserve piSelectedModel in bootstrapExistingSession metadata
zhushanwen321 b5a931a
fix(pi): await Pi confirmation before reporting model/effort applied
zhushanwen321 a1310e0
fix(pi): resolve set_model RPC so awaited model switch does not time out
zhushanwen321 a8b155c
fix(pi): drain pending localId on turn_start only; throw when set_mod…
zhushanwen321 b7343ae
fix(pi): exclude Pi from generic Ctrl/Cmd+M model cycler
zhushanwen321 f203816
fix(pi): commit PiSession config only after Pi confirms the RPC
zhushanwen321 6deb6d6
fix(pi): apply startup model only after Pi confirms set_model
zhushanwen321 ae7222a
fix(pi): do not persist startup model before Pi confirms set_model
zhushanwen321 c4927a3
fix(pi): apply startup effort only after Pi confirms set_thinking_level
zhushanwen321 197f26b
fix(pi): omit unknown runtime config from keepalive, don't clear pers…
zhushanwen321 693a32a
fix(pi): disable Ctrl/Cmd+M model cycler for Pi entirely
zhushanwen321 494762b
fix(pi): persist piSelectedModel from get_state and startup set_model…
zhushanwen321 1d8839a
fix(pi): default startingMode to remote — Pi has no local TUI path
zhushanwen321 08bbf24
fix(pi): resume with remote startingMode — no local TUI path
zhushanwen321 613df6a
fix: restore e2e/scratchlist.spec.ts deleted from main by mistake
zhushanwen321 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,3 +47,6 @@ cli/npm/main/ | |
| test-results/ | ||
| playwright-report/ | ||
| e2e-output/ | ||
| .xyz-harness | ||
| .agents/ | ||
| .pi/ | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,4 +83,4 @@ | |
| "@types/parse-path": "7.0.3" | ||
| }, | ||
| "packageManager": "bun@1.3.14" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { createRunnerLifecycle } from './runnerLifecycle'; | ||
| import type { RunnerLifecycle } from './runnerLifecycle'; | ||
|
|
||
| // Mock heavy deps | ||
| vi.mock('@/ui/logger', () => ({ | ||
| logger: { | ||
| debug: vi.fn(), | ||
| getLogPath: vi.fn(() => '/tmp/test.log'), | ||
| }, | ||
| })); | ||
|
|
||
| vi.mock('@/ui/terminalState', () => ({ | ||
| restoreTerminalState: vi.fn(), | ||
| })); | ||
|
|
||
| function createMockApiSession() { | ||
| return { | ||
| updateMetadata: vi.fn(), | ||
| sendSessionDeath: vi.fn(), | ||
| flush: vi.fn(), | ||
| close: vi.fn(), | ||
| } as unknown as Parameters<typeof createRunnerLifecycle>[0]['session']; | ||
| } | ||
|
|
||
| describe('createRunnerLifecycle', () => { | ||
| let lifecycle: RunnerLifecycle; | ||
|
|
||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| lifecycle = createRunnerLifecycle({ | ||
| session: createMockApiSession(), | ||
| logTag: 'test', | ||
| }); | ||
| }); | ||
|
|
||
| // --- D-9: hasExplicitSessionEndReason --- | ||
|
|
||
| describe('hasExplicitSessionEndReason', () => { | ||
| it('returns false initially', () => { | ||
| expect(lifecycle.hasExplicitSessionEndReason()).toBe(false); | ||
| }); | ||
|
|
||
| it('returns true after setSessionEndReason is called', () => { | ||
| lifecycle.setSessionEndReason('completed'); | ||
| expect(lifecycle.hasExplicitSessionEndReason()).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false after markCrash — markCrash does NOT set explicit flag', () => { | ||
| lifecycle.markCrash(new Error('boom')); | ||
| expect(lifecycle.hasExplicitSessionEndReason()).toBe(false); | ||
| }); | ||
|
|
||
| it('stays true once set — subsequent markCrash does not clear it', () => { | ||
| lifecycle.setSessionEndReason('handoff'); | ||
| lifecycle.markCrash(new Error('late crash')); | ||
| expect(lifecycle.hasExplicitSessionEndReason()).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| // --- markCrash sets reason to 'error' but not explicit --- | ||
|
|
||
| describe('markCrash', () => { | ||
| it('sets sessionEndReason to error via sendSessionDeath during cleanup', async () => { | ||
| const session = createMockApiSession(); | ||
| const lc = createRunnerLifecycle({ session, logTag: 'test' }); | ||
| lc.markCrash(new Error('fatal')); | ||
|
|
||
| // cleanup triggers sendSessionDeath — verify 'error' reason | ||
| await lc.cleanup(); | ||
| expect(session.sendSessionDeath).toHaveBeenCalledWith('error'); | ||
| }); | ||
| }); | ||
|
|
||
| // --- setSessionEndReason + cleanup propagates correct reason --- | ||
|
|
||
| describe('setSessionEndReason + cleanup', () => { | ||
| it('sends explicit reason via sendSessionDeath during cleanup', async () => { | ||
| const session = createMockApiSession(); | ||
| const lc = createRunnerLifecycle({ session, logTag: 'test' }); | ||
| lc.setSessionEndReason('completed'); | ||
|
|
||
| await lc.cleanup(); | ||
| expect(session.sendSessionDeath).toHaveBeenCalledWith('completed'); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Major] Preserve Pi provider selection when reusing an existing HAPI session
This PR persists provider-qualified
metadata.piSelectedModelso duplicatemodelIds can be disambiguated, butbootstrapExistingSession()rebuilds metadata from this whitelist. The added Pi preservation keepspiAvailableModelsand omitspiSelectedModel, so the first resume/local handoff update drops the provider identity again; after that the web falls back to modelId-only matching and startup model application can choose the wrong provider.Suggested fix: