Repository navigation
Description
Feature Request: Add Prefix Requirements for Permission Prompts
Summary
Add configuration options to require text prefixes for permission responses (accept/reject/accept always) to prevent accidental approvals of sensitive operations.
Problem
Currently, OpenCode's permission system uses single keystrokes for responses:
- Enter - Accept once
- a - Accept always
- Esc - Reject
This creates a safety risk where users can accidentally press "a" and grant permanent permission for sensitive operations like git push, rm -rf, or file modifications. The single-keystroke approach prioritizes speed over safety, which may not be appropriate for all use cases.
Proposed Solution
Add a new configuration option permission.requirePrefix that allows users to require typed confirmation for permission responses:
Configuration Schema
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "ask",
"bash": "ask",
"requirePrefix": {
"enabled": true,
"acceptOnce": "yes",
"acceptAlways": "yes always",
"reject": "no"
}
}
}Alternative Simpler Configuration
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"edit": "ask",
"bash": "ask",
"requirePrefix": true // Uses default prefixes: "yes", "yes always", "no"
}
}Behavior Changes
When requirePrefix is enabled:
- Permission prompts show text input field instead of accepting single keystrokes
- Users must type the full prefix (e.g., "yes always") and press Enter
- Invalid input shows error message and prompts again
- Partial matches are rejected to prevent typos from being accepted
- Case-insensitive matching for better UX
- Timeout option could auto-reject after X seconds of inactivity
UI Mockup
Current:
Allow opencode to run: git push origin main
enter accept a accept always esc reject
With Prefix Required:
Allow opencode to run: git push origin main
Type 'yes' to accept once, 'yes always' to accept always, or 'no' to reject:
> _
Use Cases
- Production environments where accidental "accept always" could be catastrophic
- Team environments where junior developers need extra safety guardrails
- Compliance requirements that mandate explicit confirmation for certain operations
- CI/CD pipelines where human oversight is required for deployment commands
Implementation Considerations
Files to Modify
-
Configuration Schema (
packages/opencode/src/config/config.ts)- Add
requirePrefixoption to permission schema - Add validation for prefix strings
- Add
-
TUI Permission Handling (
packages/tui/internal/tui/tui.go)- Replace single-key handling with text input mode
- Add prefix validation logic
-
Permission UI (
packages/tui/internal/components/chat/message.go)- Update permission prompt display
- Add text input field for prefix entry
-
Type Definitions (
packages/sdk/go/config.go)- Add Go types for new configuration options
Backward Compatibility
- Default behavior unchanged - prefix requirements are opt-in
- Existing configurations continue working without modification
- Graceful fallback if prefix configuration is malformed
Security Benefits
- Prevents accidental "accept always" responses
- Forces deliberate decision-making for sensitive operations
- Audit trail improvement - typed responses are more intentional
- Configurable per-environment - strict in prod, relaxed in dev
Alternatives Considered
-
Confirmation dialog - "Are you sure?" prompt after "accept always"
- Less flexible than prefix system
- Still allows accidental double-confirmation
-
Delay before "accept always" - require holding key for 3 seconds
- Poor UX for legitimate use cases
- Doesn't prevent accidental presses
-
Remove "accept always" entirely
- Too restrictive for power users
- Breaks existing workflows
Related Issues
This addresses the broader security concern of making OpenCode safer for production use while maintaining its developer-friendly nature.
Implementation Priority
Medium-High - This is a safety feature that would benefit enterprise users and teams working with sensitive codebases, but doesn't break existing functionality.
Would you like me to submit this issue to the OpenCode repository? I'm so lazy, sorry.
Activity
github-actions commentedon Sep 9, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
ndrwstn commentedon Nov 22, 2025
I literally opened a duplicate feature request for this issue #3455. That one is newer and has an additional (and more important issue).