Skip to content

feat(pi): add plan mode - #6372

Open
BillLeoutsakosvl346 wants to merge 4 commits into
refactor/pi-mode-foldersfrom
feature/pi-plan-mode
Open

feat(pi): add plan mode#6372
BillLeoutsakosvl346 wants to merge 4 commits into
refactor/pi-mode-foldersfrom
feature/pi-plan-mode

Conversation

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor

Summary

  • add a BYOK-only Plan mode that explores a disposable GitHub checkout in the existing Pi sandbox
  • remove the authenticated remote before Pi starts and provide no commit, push, PR, review, or GitHub-write finalization
  • reuse existing skills, memory, streaming, redaction, cancellation, and optional sandbox search extension
  • expose only the inputs and outputs needed for planning

Validation

  • PI executor and block/model/key-condition suites: 25 files, 464 passed, 1 skipped
  • Sim type-check
  • repository format and lint checks
  • check:import-specifiers
  • check:boundaries
  • check:audits (22 audits)

Stack

This PR is intentionally based on refactor/pi-mode-folders (PR #6362). After #6362 merges, this branch will be rebased onto current staging, the PR will be retargeted to staging, and the full validation and bot-review cycle will be repeated.

@vercel

vercel Bot commented Aug 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 7, 2026 7:10am

Request Review

@cursor

cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
New sandbox execution path with GitHub token use for clone-only access and BYOK keys in the sandbox; scope is bounded (no push/PR) but touches Pi handler routing, timeouts, and streaming behavior.

Overview
Adds a Plan (cloud_plan) mode to the Pi Coding Agent block: explore a GitHub repo in an ephemeral sandbox and return a Markdown implementation plan without commits, pushes, or PR writes.

Block & policy: New mode dropdown option, CLOUD_SANDBOX / CONTEXTUAL_MODES conditions so Plan shares sandbox inputs (repo, token, base branch, skills, memory, search) but hides PR/Babysit/Local fields and changedFiles/diff outputs. Plan is BYOK-only like Create/Update PR (isPiByokOnlyMode, API key visibility, copilot credential validation).

Execution: New runCloudPlanPi clones the repo, detaches the requested branch, removes origin, runs Pi with plan-specific guidance, optional sandbox search extension, and finalizePhases: 0 timeout budgeting. Handler routes cloud_plan, omits diff/PR outputs, and when streaming emits only the final plan text (not incremental narration).

Event pipeline: agent_end now extracts final text from the last assistant message’s text blocks; final events and redaction cover that text.

Reviewed by Cursor Bugbot for commit 2b653a6. Bugbot is set up for automated code reviews on this repo. Configure here.

@gitguardian

gitguardian Bot commented Aug 7, 2026

Copy link
Copy Markdown

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
While these secrets were previously flagged, we no longer have a reference to the
specific commits where they were detected. Once a secret has been leaked into a git
repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds a BYOK-only Plan mode that runs Pi against a disposable GitHub checkout and returns a planning document without a GitHub write/finalization phase.

  • Adds Plan-mode block inputs, output visibility, model-key handling, routing, and tests.
  • Introduces an ephemeral sandbox backend that clones the selected branch, removes the authenticated remote, runs Pi, and redacts streamed output.
  • Extends event normalization to expose the canonical final assistant response.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/pi/cloud/plan/backend.ts Implements the disposable Plan-mode clone, credential scoping, Pi execution, event handling, redaction, cancellation, and cleanup flow.
apps/sim/executor/handlers/pi/pi-handler.ts Routes cloud_plan executions, supplies contextual inputs, emits only the canonical final plan in streaming mode, and omits change-oriented outputs.
apps/sim/blocks/blocks/pi.ts Exposes Plan mode with its required sandbox inputs, BYOK behavior, contextual options, and Plan-appropriate outputs.
apps/sim/executor/handlers/pi/core/events.ts Extracts text blocks from the final assistant message into a canonical final event.
apps/sim/providers/pi-providers.ts Classifies Plan alongside other sandbox modes that require user-provided model credentials.

Sequence Diagram

sequenceDiagram
  participant Workflow
  participant Handler as Pi Handler
  participant Sandbox
  participant GitHub
  participant Pi

  Workflow->>Handler: Execute cloud_plan
  Handler->>Handler: Resolve BYOK key, skills, memory
  Handler->>Sandbox: Create disposable sandbox
  Sandbox->>GitHub: Clone selected/default branch
  Sandbox->>Sandbox: Detach checkout and remove origin
  Handler->>Sandbox: Write scrubbed prompt
  Sandbox->>Pi: Run with model/search credentials
  Pi-->>Handler: Progress and final events
  Handler-->>Workflow: Final Markdown plan and usage
  Sandbox-->>Handler: Dispose sandbox
Loading

Reviews (5): Last reviewed commit: "fix(pi): stream only final plan content" | Re-trigger Greptile

Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts
Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts Outdated
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 07949ce. Configure here.

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

Comment thread apps/sim/executor/handlers/pi/cloud/plan/backend.ts
@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@greptile

@BillLeoutsakosvl346

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot 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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2b653a6. Configure here.

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.

1 participant