Expose project plan tools to Pi tasks#88
Conversation
📝 WalkthroughWalkthroughThe patch adds PlanCapability propagation and environment injection for PI executors, implements plan-related extension tools (JS/TS + tests), updates tests to cover env propagation, and bumps a Go module version; it also includes the new plan-tools file in the extension release package. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Session as Session Actor
participant Executor as PI Executor
participant PI as PI Process / Extension
participant PlanAPI as Plan HTTP API
Session->>Executor: Start with Task (includes PlanCapability)
Executor->>PI: Launch PI process with env (filtered + GSD_PLAN_* if present)
PI->>PlanAPI: HTTP requests (Authorization: Bearer GSD_PLAN_CAPABILITY_TOKEN)
PlanAPI-->>PI: JSON responses
PI-->>Executor: Tool-call outputs / errors
Executor-->>Session: Tool-call results back to session/task
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 8/10 reviews remaining, refill in 8 minutes and 11 seconds. Comment |
5f68859 to
78296be
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/pi/executor.go (1)
351-357: Only injectGSD_PLAN_*when capability fields are complete.Right now
cap != nilappends keys even when values are empty strings. Omitting incomplete capability env keeps downstream behavior unambiguous.♻️ Suggested refactor
- if cap != nil { + if cap != nil && + strings.TrimSpace(cap.APIBaseURL) != "" && + strings.TrimSpace(cap.Token) != "" && + strings.TrimSpace(cap.ExpiresAt) != "" { env = append(env, "GSD_PLAN_API_BASE_URL="+cap.APIBaseURL, "GSD_PLAN_CAPABILITY_TOKEN="+cap.Token, "GSD_PLAN_CAPABILITY_EXPIRES_AT="+cap.ExpiresAt, ) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/pi/executor.go` around lines 351 - 357, The current block appends GSD_PLAN_* env vars whenever cap != nil even if fields are empty; change it to only append the three variables when the capability is complete by checking cap != nil && cap.APIBaseURL != "" && cap.Token != "" && cap.ExpiresAt != "" (or equivalent all-non-empty check) before calling env = append(...); reference the cap variable and its fields APIBaseURL, Token, ExpiresAt and the env append site to locate and update the logic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/pi/executor.go`:
- Around line 351-357: The current block appends GSD_PLAN_* env vars whenever
cap != nil even if fields are empty; change it to only append the three
variables when the capability is complete by checking cap != nil &&
cap.APIBaseURL != "" && cap.Token != "" && cap.ExpiresAt != "" (or equivalent
all-non-empty check) before calling env = append(...); reference the cap
variable and its fields APIBaseURL, Token, ExpiresAt and the env append site to
locate and update the logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d3e62ae4-ba85-4aea-893f-c1ada25df8ed
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (9)
.github/workflows/release-daemon.ymlgo.modinternal/pi/executor.gointernal/pi/executor_test.gointernal/pi/extension/index.tsinternal/pi/extension/plan-tools.jsinternal/pi/extension/plan-tools.test.mjsinternal/session/actor.gointernal/session/actor_test.go
✅ Files skipped from review due to trivial changes (1)
- go.mod
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/pi/extension/index.ts
- internal/session/actor_test.go
- internal/pi/extension/plan-tools.test.mjs
Summary
Daemon task execution receives project plan capability metadata from relay tasks, exports it as task-scoped environment variables, and registers Pi project plan tools only when the capability is complete.
Why
Plan Mode needs agent-side tools without putting bearer tokens into prompts. The daemon is the local boundary that passes scoped credentials into the Pi extension and keeps plan tools absent when a task has no plan capability.
How It Works
v0.26.0forTask.planCapability.GSD_PLAN_*variables before adding the current task capability./api/agent-plan/*routes with bearer auth.GSD_PLAN_API_BASE_URL,GSD_PLAN_CAPABILITY_TOKEN, andGSD_PLAN_CAPABILITY_EXPIRES_AT.Verification
go test ./...passed.go build -o gsd-cloud .passed.cd internal/pi/extension && node --test *.test.mjspassed.Dependency Order
gsd-build/protocol-go#32is merged and taggedv0.26.0.v0.26.0.Post-Merge Actions
Summary by CodeRabbit
Dependencies
New Features
Tests
Chores