Skip to content

Expose project plan tools to Pi tasks#88

Merged
glittercowboy merged 1 commit intomainfrom
codex/project-plan-tool-daemon
Apr 29, 2026
Merged

Expose project plan tools to Pi tasks#88
glittercowboy merged 1 commit intomainfrom
codex/project-plan-tool-daemon

Conversation

@glittercowboy
Copy link
Copy Markdown
Contributor

@glittercowboy glittercowboy commented Apr 29, 2026

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

  • Bumps protocol-go to v0.26.0 for Task.planCapability.
  • Adds plan capability fields to task context and executor environment construction.
  • Strips inherited GSD_PLAN_* variables before adding the current task capability.
  • Adds Pi extension plan tools that call cloud /api/agent-plan/* routes with bearer auth.
  • Registers plan tools conditionally based on GSD_PLAN_API_BASE_URL, GSD_PLAN_CAPABILITY_TOKEN, and GSD_PLAN_CAPABILITY_EXPIRES_AT.

Verification

  • go test ./... passed.
  • go build -o gsd-cloud . passed.
  • cd internal/pi/extension && node --test *.test.mjs passed.

Dependency Order

  1. gsd-build/protocol-go#32 is merged and tagged v0.26.0.
  2. This daemon PR lands after protocol v0.26.0.
  3. The cloud app Project Plan Mode PR provides capability minting and REST endpoints used by these tools.

Post-Merge Actions

  • Push the next daemon release tag after merge.
  • Verify the daemon release workflow publishes artifacts.
  • Confirm installer/release flow points at the intended daemon version when release workflow completes.

Summary by CodeRabbit

  • Dependencies

    • Updated Go module protocol dependency.
  • New Features

    • Task-level plan capability is now propagated into execution environments.
    • New plan-based tools available when plan capability is present for working with plan API endpoints.
  • Tests

    • Added unit tests covering plan capability propagation and plan tool registration.
  • Chores

    • Extension packaging updated to include the new plan tools.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Go module
go.mod
Bump github.com/gsd-build/protocol-go from v0.25.0 to v0.26.0.
PI executor & tests
internal/pi/executor.go, internal/pi/executor_test.go
Add PlanCapability *protocol.PlanCapability to Options; inject/remove GSD_PLAN_* env vars when starting PI; add unit test asserting env file contains GSD_PLAN_* entries.
Extension: plan tools
internal/pi/extension/plan-tools.js, internal/pi/extension/index.ts, internal/pi/extension/plan-tools.test.mjs
New plan-tools.js exports hasPlanCapability and registerPlanTools implementing TypeBox-validated plan API tools; extension index registers these tools; tests verify registration and request formatting (mocking fetch).
Session actor & tests
internal/session/actor.go, internal/session/actor_test.go
Propagate protocol.Task.PlanCapability through taskContext into PI executor options; tests added to assert capability env vars are written by fake PI.
Release packaging
.github/workflows/release-daemon.yml
Include plan-tools.js in the packaged PI extension tarball.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

"I hop and I tinker, a carrot in paw,
I stitched in the plan-vars to make processes draw.
With tokens and URLs set in the breeze,
The PI will fetch plans with elegant ease.
🥕 — rabbit dev"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Expose project plan tools to Pi tasks' directly and clearly summarizes the main objective of the PR—adding plan capability metadata and tools to Pi task execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/project-plan-tool-daemon

Review rate limit: 8/10 reviews remaining, refill in 8 minutes and 11 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@glittercowboy glittercowboy force-pushed the codex/project-plan-tool-daemon branch from 5f68859 to 78296be Compare April 29, 2026 01:53
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/pi/executor.go (1)

351-357: Only inject GSD_PLAN_* when capability fields are complete.

Right now cap != nil appends 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f68859 and 78296be.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (9)
  • .github/workflows/release-daemon.yml
  • go.mod
  • internal/pi/executor.go
  • internal/pi/executor_test.go
  • internal/pi/extension/index.ts
  • internal/pi/extension/plan-tools.js
  • internal/pi/extension/plan-tools.test.mjs
  • internal/session/actor.go
  • internal/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

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