feat(pi): add persistent /goal mode#1270
Open
rongyulin3 wants to merge 9 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a Pi Agent Runtime–only, session-scoped persistent /goal mode to Proma’s Electron main process, enabling automatic multi-turn continuation with transcript-persisted goal state and renderer-safe status messaging.
Changes:
- Introduces a Pi inline Goal extension (
/goal,/goal stop,goal_complete) with transcript persistence and a 50-turn continuation cap. - Wires the Goal extension into Pi sessions via a shared extension-factory builder and adds a small lifecycle wait to avoid premature session cleanup after
/goalstarts. - Extends the Pi message adapter to surface visible custom Pi messages to Proma while keeping hidden goal context out of the UI, with focused Bun tests.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents the new Pi /goal mode behavior and safety limit. |
| docs/superpowers/specs/2026-07-22-pi-goal-mode-design.md | Adds the design spec for Pi Goal mode. |
| docs/superpowers/plans/2026-07-22-pi-goal-mode.md | Adds the implementation plan for Pi Goal mode. |
| apps/electron/src/main/lib/adapters/pi-message-adapter.ts | Converts visible Pi custom messages into Proma-renderable assistant messages; hides display: false. |
| apps/electron/src/main/lib/adapters/pi-message-adapter.test.ts | Adds coverage for visible vs hidden Pi custom messages. |
| apps/electron/src/main/lib/adapters/pi-goal-extension.ts | Implements the persistent Goal extension, state persistence, bounded continuation, and goal_complete. |
| apps/electron/src/main/lib/adapters/pi-goal-extension.test.ts | Adds Bun tests for state reconstruction, commands, tool behavior, and continuation/limit logic. |
| apps/electron/src/main/lib/adapters/pi-extension-factories.ts | Centralizes Pi extension factory construction (Goal + conditional Codex settings). |
| apps/electron/src/main/lib/adapters/pi-command-lifecycle.ts | Adds /goal start detection + waiting for nested follow-up turns to settle. |
| apps/electron/src/main/lib/adapters/pi-command-lifecycle.test.ts | Tests /goal start detection and waiting behavior. |
| apps/electron/src/main/lib/adapters/pi-agent-adapter.ts | Wires in Goal extension factories and waits after /goal to prevent early cleanup. |
| apps/electron/src/main/lib/adapters/pi-agent-adapter.test.ts | Verifies Goal extension is always loaded and Codex settings are preserved. |
| apps/electron/package.json | Bumps @proma/electron patch version for the feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+224
to
+233
| if (input === 'stop') { | ||
| const currentGoal = getState(ctx) | ||
| if (currentGoal?.status === 'active') { | ||
| goalState = withState(currentGoal, { status: 'stopped' }) | ||
| appendState(pi, goalState) | ||
| } | ||
| continuationQueued = false | ||
| notifyUsage(pi, ctx, '当前 Goal 已停止。') | ||
| return | ||
| } |
| # Pi 原生 `/goal` 持续模式设计 | ||
|
|
||
| - 日期:2026-07-22 | ||
| - 状态:设计已获用户批准,待实现 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Proma's Pi Agent Runtime now supports a session-scoped persistent
/goalmode.User behavior
/goal <task>starts a persistent Goal in the current Pi session./goal stopstops the active Goal.goal_completeafter verified completion.Implementation
AgentSessionhost before cleanup.Scope
This is intentionally session-scoped. It does not add Scheduler/Cron/Monitor behavior, cross-session background execution, or Claude Runtime changes.
Verification
With a fresh
bun install --frozen-lockfile:bun run typecheck— passedbun run --filter='@proma/electron' build:main— passedgit diff --check— passedRelated design
docs/superpowers/specs/2026-07-22-pi-goal-mode-design.mddocs/superpowers/plans/2026-07-22-pi-goal-mode.md