To build a useful plan, I need the target outcome first. What do you want to accomplish?
If helpful, reply in this format:
Goal:
Constraints (tech, timeline, no-go areas):
Definition of done:
Relevant area (files/folders/features):
User
Goal: Support additional commands from the user to be used along with the system prompt. Constraints: None. Definition of Done: Functionally added, with passing tests. Relevant area: features
Assistant
Great target. I explored the current flow and this is the best implementation path.
The system prompt is built in src/services/llm.ts:124 and injected from src/components/ChatWindow.tsx:167.
Right now, user input is sent as a plain user message in src/components/ChatWindow.tsx:180; there is no command parsing layer.
Config is centralized in src/types/index.ts:130, src/store/slices/configSlice.ts:6, and edited in .
User
The commands should be optionally added in settings and used to run as part of the initial summary. For example, an additional command like "Ensure package versions are up-to-date" which is attached to the end of the prompt producing the summary
Assistant
Perfect, that clarifies the intent.
I’d implement it as user-configured “summary commands” in Settings, appended to the system prompt only when generating the initial summary.
Plan
Add config field in src/types/index.ts:
(optional, default )
User
What counts as an initial summary? This hasn't been described yet. Lets expand: When a PR has been selected, generate a short summary to give context to the reviewer. The summary should give an overview of the PR and any areas to focus on.
Assistant
User
A PR summary should have a 'Summary' section which contains a short 3-4 line overview of the PR to give context, and a 'Focus On' section which has hints on sections that deserve more attention, such as complicated code, or large changes from the base
Assistant
Perfect — that gives a clear output contract for the auto-summary.
Updated behavior spec for the generated kickoff message:
Summary section:
3–4 short lines
concise overview of what the PR changes
context-first (what changed + why it matters)
Focus On section:
actionable review hints
highlight risky/complex/large-diff areas
prioritize things like security-sensitive paths, branching logic, migrations, and high-churn files
Planned prompt instruction (for the auto-summary turn):
Enforce exact headings:
## Summary
## Focus On
Enforce length/style:
Summary: exactly 3–4 lines
Focus On: compact bullets (3–6)
User
yes, clear
Assistant
Great — locked: on PR switch, clear chat and start fresh with auto-summary.
Here’s the implementation plan I’ll execute next (no changes made yet):
User
Summary generation should be optional with a user setting to turn on or off. The summary should be on by default
The prompt used to create the summary should be user editable and persist between sessions
There should be a 'Reset' option to set back to the original prompt
If a PR is empty, the summary should not be generated and a 'Empty PR' message shown instead
Failure to reach LLM to generate summary should result in 'Unable to generate summary' message
Summary should not be part of the chat history or context with the LLM
Rate limit summary generation to one-per-minute
Summary cached in sessionStorage
Assistant
User
Default prompt should be: "Create a 4-line summary of the PR to help a developer orient and gather context; use the PR description, PR commit messages, and code changes to create the summary. Identify areas of complexity or importance that the reviewer should focus on; this can be areas of large change or that alter the program flow. Show an output in two sections; "PR Context" contains the summary and "Focus Areas" contains the focus points. After giving the output, ask the reviewer if there are any areas that you can detail further.
Bold topics and areas of interest
Use emoticons to signal severity of focus areas
Ignore non-text files "
Assistant
User
per pr
Assistant
User
only the summary prompt
Assistant
User
Summary should be added as the 'Summary' tab on the right hand pane
Show generation-time timestamp at bottom of summary pane
Show spinner in pane while generating summary
Assistant
Perfect additions — this slots cleanly into the plan.
User
Summary generation will use the existing LLM configuration.
Assistant
Perfect — agreed. Summary generation will use the same existing LLM settings (llmBackend, llmEndpoint, llmApiKey, llmModel) with no separate summary-specific provider config.
Finalized plan updates with that constraint:
Reuse createLLMService(config) for summary calls.
Honor current behavior if LLM config is missing/invalid:
summary state becomes Unable to generate summary.
Keep summary isolated from chat history/context:
separate summary request path in PR state/UI
no summary content in messages sent for normal chat.
Keep all previously locked requirements:
optional summary (default on)
editable persisted summary prompt + reset only prompt
additional commands from Settings
empty PR => Empty PR
failure => Unable to generate summary
per-PR one/minute rate limit
sessionStorage cache
summary shown as Summary tab in right pane
User
Assistant
I’m blocked from executing /opsx-propose right now because plan mode is active and strictly read-only (I can’t run openspec new change or write artifact files yet).
I did prepare the change spec so we can create it immediately once write mode is enabled:
Proposed change name:add-pr-summary-tab
Target path:openspec/changes/add-pr-summary-tab/
Artifacts to create:proposal.md, design.md, tasks.md
Draft scope to encode in artifacts:
User
Done
Assistant
Created change add-pr-summary-tab and generated all required artifacts in one pass.
Ran verification before commit: npm run lint, npm run test, and npm run build (all passed).
Left unrelated untracked files untouched: .opencode/command/, .opencode/skills/, openspec/config.yaml.
If you want, I can also push this commit and/or open a PR.
User
Add the .opencode and openspec folders too
src/components/SettingsDialog.tsx:45
Proposed implementation plan (once we exit explore mode):
Add a command parser utility (likely src/lib/promptCommands.ts) that extracts command directives from user input and returns:
directives: string[] (extra instructions)
cleanUserMessage: string (actual user question)
Extend LLMService.buildSystemPrompt(...) in src/services/llm.ts:124 to accept optional per-request directives and append a clearly bounded section, e.g. ### Additional User Directives.
Update handleSend in src/components/ChatWindow.tsx:137 to:
parse the input
pass directives into buildSystemPrompt(...)
send cleanUserMessage as the final user message
Add tests:
parser unit tests in src/lib/utils.test.ts or a new test file
prompt-injection tests in src/services/llm.test.ts for directive inclusion/omission and formatting
optional integration-level test around ChatWindow send behavior if we want stronger coverage
Update docs in README.md with command syntax and examples.
Validate with npm run lint, npm run test, and npm run build (to satisfy your DoD).
One key product choice before implementation:
Do you want free-form directives (recommended), like /with focus on security and test gaps
or fixed slash commands like /security/bugs/tests mapped to predefined instructions?
Recommended default is free-form because it’s flexible and requires less UI/config work; fixed commands would add a command registry and validation UX.
summaryCommands: string[]
[]
Wire defaults + persistence in src/store/slices/configSlice.ts:
load from env/localStorage with safe fallback
persist as part of normal non-sensitive config
Extend Settings UI in src/components/SettingsDialog.tsx:
add a textarea like “Additional Summary Commands”
one command per line (example: Ensure package versions are up-to-date)
parse/trim/filter empty lines on save
Extend system prompt builder in src/services/llm.ts:
add optional param, e.g. buildSystemPrompt(context, options?: { summaryCommands?: string[] })
append section near prompt tail:
### Additional Summary Instructions
bullet list of configured commands
Apply only for initial summary in src/components/ChatWindow.tsx:
detect “initial summary request” and pass configured commands
otherwise keep existing behavior for normal chat
Add/adjust tests:
src/services/llm.test.ts: verifies commands are appended when provided, omitted when empty
src/store/slices/configSlice.test.ts: verifies persistence of summaryCommands
(optional) ChatWindow behavior test if we add a robust summary-trigger helper
Update docs in README.md:
describe settings field and that commands are used for initial summary generation
Recommended behavior details
Keep commands as newline-separated entries in UI, stored as string[].
Sanitize each command (trim whitespace, drop blanks).
Keep command section short and explicit in the final system prompt.
One important product decision to lock before implementation:
What counts as “initial summary”? (Recommended: first user turn where input matches summarize intent like “Summarize this PR”)
Alternative: auto-run summary immediately after PR load without user typing.
If you confirm that rule, I can move from explore to implementation cleanly.
Love this expansion — it removes the ambiguity.
Given your new requirement, here’s the concrete definition I’d use for “initial summary”:
When selectedPR changes to a non-null PR, the app automatically asks the LLM for a short kickoff summary.
The summary is generated once per selected PR load cycle (not on every render).
It should include:
overview of what changed
likely risk/focus areas for reviewer attention
Any configured “additional summary commands” from Settings are appended to the system prompt for this auto-summary call only.
Implementation plan (no code changes yet)
Config + types
Add summaryCommands: string[] to AppConfig in src/types/index.ts.
Default to [] in src/store/slices/configSlice.ts.
Persist with other non-sensitive config in localStorage.
Settings UX
Add a textarea in src/components/SettingsDialog.tsx:
label: “Additional Summary Commands”
format: one command per line
example: Ensure package versions are up-to-date
On save: trim lines, drop empties, store as string array.
Prompt composition
Extend buildSystemPrompt in src/services/llm.ts with optional summary directives.
Append a bounded section like:
### Additional Summary Instructions
bullet list of commands
Keep this section omitted when no commands exist.
Auto-summary behavior
In src/components/ChatWindow.tsx, add an effect that triggers on PR selection changes.
Use a deterministic “already summarized” guard (e.g., ref keyed by PR identity) to prevent duplicates.
Send a fixed user prompt for summary intent (e.g., “Provide a short reviewer-oriented summary with focus areas.”).
Include configured summary commands only for this call.
Stream response into chat as assistant message, same as existing flow/error handling.
Tests
src/services/llm.test.ts: verify additional summary instructions are included/omitted correctly.
src/store/slices/configSlice.test.ts: verify summaryCommands defaults and persistence.
Add or update ChatWindow tests to validate auto-summary is triggered once per PR selection and not spammed by rerenders.
Docs + plan hygiene
Update README.md settings table/usage notes.
Update plans/plan.md with this feature and completion criteria before/after implementation.
Run npm run lint, npm run test, npm run build as final verification.
One important UX decision to lock before I implement:
Should switching to a different PR clear existing chat automatically before inserting the new auto-summary, or keep prior chat history and append the new summary at the end?
Recommended: auto-clear on PR change to avoid mixing contexts across PRs.
Include configured settings commands at the end (e.g., “Ensure package versions are up-to-date”) for this auto-summary request only.
Implementation shape remains:
Add summaryCommands to config + Settings UI (one per line).
Auto-run summary when PR is selected.
Stream the result into chat as the first assistant context message for that PR.
Test prompt formatting + trigger behavior + config persistence.
Verify with lint/test/build.
One decision still needed (recommended default included):
On PR switch, clear prior chat?
Recommended: Yes, clear so each PR starts with its own Summary + Focus On context and avoids cross-PR confusion.
If you choose “No”, I’ll append the new auto-summary to the existing thread instead.
Config model updates
Add summaryCommands: string[] to AppConfig in src/types/index.ts.
Default it to [] in src/store/slices/configSlice.ts.
Keep it persisted in localStorage as a non-sensitive field.
Extend config tests in src/store/slices/configSlice.test.ts for default/load/save behavior.
Settings UI
In src/components/SettingsDialog.tsx, add “Additional Summary Commands” textarea.
Parse one command per line on save: trim, drop blank lines, store as string[].
Show helper text with example: Ensure package versions are up-to-date.
Prompt contract for auto-summary
Extend buildSystemPrompt in src/services/llm.ts to accept optional summary-only directives.
For auto-summary requests, append:
required structure (## Summary, ## Focus On)
format constraints (Summary = 3–4 short lines; Focus On = 3–6 bullets)
user-configured summary commands at the end.
Add tests in src/services/llm.test.ts for inclusion/omission and section contract.
Auto-summary orchestration
In src/components/ChatWindow.tsx, detect PR selection changes.
On change:
clear chat state
enqueue assistant streaming response from an auto-summary request
pass summary commands into system prompt only for this request
Guard against duplicate runs on rerender (track last summarized PR key in a ref).
Reuse existing streaming/error paths for consistency.
PR selection signal + clear behavior
Ensure PR changes (demo/manual/refresh-to-different PR) trigger new summary.
Keep same-PR refresh behavior from retriggering unless PR identity changes.
Use your chosen behavior: always clear prior chat when PR changes.
Documentation and plan hygiene
Update README.md with:
new Settings field
automatic summary behavior
output shape (Summary + Focus On)
Update plans/plan.md with this feature steps and completion status as work progresses.
Validation
Run npm run lint
Run npm run test
Run npm run build
Confirm all pass before marking done.
If you want, once we leave plan mode I’ll implement exactly this in one pass and report back with changed files + test/build results.
Great, this is a solid and precise feature set.
Here’s the implementation plan based on your expanded requirements.
Behavior Contract
On PR selection, show a reviewer kickoff panel (not a chat message) with:
Summary (3–4 short lines)
Focus On (review hotspots/risk hints)
Auto-summary is controlled by a new setting (on by default).
If PR is empty, skip LLM call and show Empty PR.
If LLM call fails, show Unable to generate summary.
Summary is never added to chat history and never sent back in later LLM chat context.
Summary generation is rate-limited to once per minute.
Generated summaries are cached in sessionStorage.
Planned Code Changes
src/types/index.ts
Extend AppConfig with:
summaryEnabled: boolean (default true)
summaryPrompt: string (user-editable, persisted)
summaryCommands: string[] (already discussed)
src/store/slices/configSlice.ts (+ tests)
Add defaults and persistence for those fields.
Keep sensitive-field stripping unchanged.
src/components/SettingsDialog.tsx
Add:
Toggle: “Generate PR Summary” (default on)
Textarea: editable summary prompt
Textarea: additional summary commands (one per line)
Empty PR rule: treat as empty when changed_files === 0 or loaded files array is empty.
Cache key: include PR identity (repo + number + head sha) and prompt/settings fingerprint so prompt edits don’t reuse stale summaries.
Rate limit: apply before network call; if blocked, return cached summary if present, otherwise show a neutral “rate-limited” state message (separate from failure).
Prompt reset: reset only summaryPrompt, not all settings.
Tests to Add
src/store/slices/configSlice.test.ts
defaults, persistence, reset-prompt behavior
src/services/llm.test.ts
summary prompt includes required sections and commands
Please disable plan mode (or switch to implementation mode), and I’ll run the OpenSpec commands to create the change and generate all artifacts in one step.