Skip to content

feat(pi): add persistent /goal mode#1270

Open
rongyulin3 wants to merge 9 commits into
proma-ai:mainfrom
rongyulin3:feat/pi-goal-mode
Open

feat(pi): add persistent /goal mode#1270
rongyulin3 wants to merge 9 commits into
proma-ai:mainfrom
rongyulin3:feat/pi-goal-mode

Conversation

@rongyulin3

Copy link
Copy Markdown
Contributor

Summary

Proma's Pi Agent Runtime now supports a session-scoped persistent /goal mode.

User behavior

  • /goal <task> starts a persistent Goal in the current Pi session.
  • Unfinished Goals automatically continue across turns.
  • /goal stop stops the active Goal.
  • The Agent calls goal_complete after verified completion.
  • Goal state is persisted in the existing Pi session transcript.
  • Automatic continuation is bounded at 50 turns.

Implementation

  • Adds a Pi inline extension factory for Goal state, commands, lifecycle hooks, and completion tooling.
  • Loads the Goal extension alongside the existing Codex request-settings extension.
  • Waits for command-triggered nested Goal turns in Proma's direct AgentSession host before cleanup.
  • Converts visible Pi custom status messages into Proma-renderable messages while keeping hidden Goal context out of the UI.
  • Stops continuation after aborted/error assistant endings.

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 — passed
  • bun run --filter='@proma/electron' build:main — passed
  • Focused Pi/Goal tests — 38 passed, 0 failed
  • git diff --check — passed

Related design

  • docs/superpowers/specs/2026-07-22-pi-goal-mode-design.md
  • docs/superpowers/plans/2026-07-22-pi-goal-mode.md

Copilot AI review requested due to automatic review settings July 22, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 /goal starts.
  • 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
- 状态:设计已获用户批准,待实现
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants