Skip to content

feat(session): add /goal slash command for stated session goal (RES-932) - #31

Merged
madeleinesong merged 1 commit into
gpdfrom
madeleine/res-932-add-a-goal-equivalent-to-gpd-cli-and-app
May 15, 2026
Merged

madeleinesong merged 1 commit into
gpdfrom
madeleine/res-932-add-a-goal-equivalent-to-gpd-cli-and-app

Conversation

@madeleinesong

Copy link
Copy Markdown

Summary

Adds a /goal slash command to the TUI that pins a user-stated session goal so the agent keeps it in view across every turn. Closes RES-932.

  • The goal is stored on the session row (new session.goal JSON column + drizzle migration) and surfaced into the system prompt on every model turn via a <session-goal> block.
  • The dialog takes a single text field with optional inline --budget=<v> and --time=<v> flags (e.g. Ship the paper --budget=$50 --time=2h). Submitting an empty value clears the goal — no separate /clear-goal needed.
  • PATCH /session/:id accepts {goal: {...} | null} on the existing update route; the generated SDK's session.update() exposes the new field. The OpenAPI generator output (packages/sdk/js/src/v2/gen/) was patched by hand to match the new shape — re-running bun run build in packages/sdk/js against this branch should produce equivalent output.

Design notes

  • Budget/time are free-form strings. No parser opinions — "$50" and "2h" are passed through verbatim into the system prompt. If we later want validation/tracking, the schema is already shaped to absorb it.
  • The goal re-reads on every turn, not just at run-loop entry. That way a /goal update mid-run reaches the very next model call instead of waiting for a fresh loop.
  • The /goal slash command lives at the session route level, alongside /rename and /share — mirrors the existing pattern for session-metadata commands.

Test plan

  • bun run typecheck (opencode + sdk) — clean
  • bun test test/session/goal.test.ts test/cli/tui/dialog-session-goal.test.ts — 7/7 pass
  • bun test test/session full sweep — 11 pre-existing abort/cancel timeouts (matches baseline; none touch goal logic)
  • Manual: launch TUI in a project, run /goal Find quantum gravity --budget=$50 --time=2h, confirm the goal text appears in subsequent agent reasoning
  • Manual: submit empty /goal to clear

Followups (deferred)

  • Re-running the SDK code generator (packages/sdk/js) to confirm the hand-patched goal field matches what hey-api emits from the updated OpenAPI spec.
  • Surfacing the active goal in the prompt footer/status bar so users see it without opening the dialog.
  • Wiring real budget/time tracking (cost meter, deadline countdown) — currently display-only via the system prompt.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Pins a user-stated session goal to the session row so every model turn's
system prompt includes it, keeping the agent centered on the objective
across the conversation. Optional --budget and --time values are parsed
from the same single-field dialog input (e.g. /goal Ship paper
--budget=$50 --time=2h) and rendered alongside the goal in the system
block. Submitting an empty value clears the goal.

- DB: new session.goal JSON column + drizzle migration
- Session service: setGoal/clearGoal + Session.goalSystemPrompt renderer
- Server: PATCH /session/:id accepts {goal} on update payload
- SDK: regenerated update() signature exposes goal field
- TUI: /goal opens a single-field dialog with inline flag parsing

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@madeleinesong has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minute and 40 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f5a0104c-fb99-480b-a793-0c8e0dd8d729

📥 Commits

Reviewing files that changed from the base of the PR and between a6e1159 and c087d5b.

⛔ Files ignored due to path filters (2)
  • packages/sdk/js/src/v2/gen/sdk.gen.ts is excluded by !**/gen/**
  • packages/sdk/js/src/v2/gen/types.gen.ts is excluded by !**/gen/**
📒 Files selected for processing (10)
  • packages/opencode/migration/20260515120000_add_session_goal/migration.sql
  • packages/opencode/src/cli/cmd/tui/component/dialog-session-goal.tsx
  • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
  • packages/opencode/src/server/instance/session.ts
  • packages/opencode/src/session/index.ts
  • packages/opencode/src/session/projectors.ts
  • packages/opencode/src/session/prompt.ts
  • packages/opencode/src/session/session.sql.ts
  • packages/opencode/test/cli/tui/dialog-session-goal.test.ts
  • packages/opencode/test/session/goal.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch madeleine/res-932-add-a-goal-equivalent-to-gpd-cli-and-app

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@madeleinesong
madeleinesong merged commit 1a3029b into gpd May 15, 2026
2 checks passed
cmaloney111 added a commit that referenced this pull request May 15, 2026
Reverting in favor of upstream opencode#27163 ("feat: add native
session goals", opened 2026-05-12, still open). Upstream ships:

  - Token + wall-clock usage accounting with budget-exhausted state
  - Model-facing read/create/mark-complete tools (a real forcing
    function — model can't ignore a passive system-prompt block the
    way it could here)
  - Auto-continue-on-idle + pause-on-abort
  - TUI prompt-input / session-header / footer surfaces
  - Real SDK codegen output (vs the hand-patched sdk.gen.ts /
    types.gen.ts in this PR that next regen would clobber)
  - 1243+ lines of test coverage vs ~120 here

PR #31's own "Followups (deferred)" section explicitly listed three
items upstream already provides: SDK regen, footer/status-bar
surface, real budget/time tracking. The implementation here was
display-only prompt injection with no enforcement.

Plan: wait for upstream anomalyco#27163 to merge, then sync via the normal
upstream-merge path. The gpd-cli companion (get-physics-done#228)
is a distinct surface (CLI, not in-runtime) and can land on its
own merits once it consumes the upstream-merged shape.

Cameron's f6a9017 on top (extending the RES-904 reward-hacking
gate to gpt/gemini/codex/kimi/trinity) touches a disjoint file set
and is preserved unchanged.

Reverts the 12 files PR #31 modified/added to their state at the
PR #30 merge (fb230ed):

  packages/opencode/migration/20260515120000_add_session_goal/migration.sql (deleted)
  packages/opencode/src/cli/cmd/tui/component/dialog-session-goal.tsx (deleted)
  packages/opencode/src/cli/cmd/tui/routes/session/index.tsx (restored)
  packages/opencode/src/server/instance/session.ts (restored)
  packages/opencode/src/session/index.ts (restored)
  packages/opencode/src/session/projectors.ts (restored)
  packages/opencode/src/session/prompt.ts (restored)
  packages/opencode/src/session/session.sql.ts (restored)
  packages/opencode/test/cli/tui/dialog-session-goal.test.ts (deleted)
  packages/opencode/test/session/goal.test.ts (deleted)
  packages/sdk/js/src/v2/gen/sdk.gen.ts (restored)
  packages/sdk/js/src/v2/gen/types.gen.ts (restored)
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