Skip to content

ariane-emory/opencode-config

Repository files navigation

My (private) opencode config

This content goes at ~/.config/opencode.

Prompt Enhancer

The prompt enhancer functionality has been reimplemented in Go to replace the original Bash script. The new implementation provides equivalent functionality with improved robustness and maintainability.

Usage

The Go prompt enhancer is located in prompt-enhancer/ subdirectory:

cd prompt-enhancer
./prompt-enhancer <command> [model] "prompt text"

Available Commands

  • feature - New Feature Request
  • change - New Change Request
  • refactoring - New Refactoring Request Specification
  • tests - New Test Request
  • bugfix - Critical Bug Fix Request
  • question - Question (no code editing)
  • bare - Bare command (minimal formatting)

Examples

# Feature request with default model
./prompt-enhancer feature "Add a new authentication system"

# Question with specific model
./prompt-enhancer question github-copilot/claude-sonnet-4 "How does database work?"

# Question using ask alias (equivalent to question)
./prompt-enhancer ask "What is testing strategy?"

# Test request
./prompt-enhancer tests "Create comprehensive tests for user management"

# Feature request with RFC compliance (lowercase)
./prompt-enhancer feature rfc "Add a new authentication system"

# Feature request with model and RFC compliance (uppercase)
./prompt-enhancer feature qwen3-coder-flash RFC "Add a new authentication system"

Command Aliases

The prompt enhancer supports command aliases for convenience:

  • askquestion (Both commands behave identically)
# These two commands are equivalent:
./prompt-enhancer question "How does system work?"
./prompt-enhancer ask "How does system work?"

RFC Arguments

The prompt enhancer supports optional RFC arguments as an alternative to environment variables:

  • rfc (lowercase) - Equivalent to setting RFC2119=1, includes RFC2119 compliance phrase
  • RFC (uppercase) - Equivalent to setting RFC2119=1, includes RFC2119 compliance phrase and full (well, slightly trimmed) RFC2119 text

The RFC argument can be positioned as second or third argument:

# RFC as second argument (no model specified)
./prompt-enhancer feature rfc "Add authentication"

# RFC as third argument (with model specified)
./prompt-enhancer feature qwen3-coder-flash rfc "Add authentication"

Environment Variables

  • DEBUG__LOG_ARGUMENTS=1 - Enable argument parsing debug output
  • DEBUG__SKIP_ENHANCING=1 - Skip opencode enhancement step
  • DEBUG__OUTPUT_FENCES=1 - Wrap output in BEGIN/END markers
  • RFC2119=1 - Include RFC2119 compliance phrase
  • RFC2119=2 - Include full RFC2119 content

Note: Command-line RFC arguments take precedence over RFC2119 environment variable.

Semaphore File Mechanism

The prompt enhancer uses a semaphore file to coordinate with other plugins and prevent conflicts during operation.

Semaphore File Location

The semaphore file is created at: ~/.config/opencode/prompt-enhancer-semaphore

Behavior

  • Creation: The semaphore file is created immediately when prompt-enhancer starts
  • Deletion: The semaphore file is removed when prompt-enhancer exits (normally or due to error)
  • Purpose: Other plugins (such as terminal bell plugin) check for this file and skip their actions while helper is running
  • Cleanup: If a stale semaphore file exists from a previous crash, it will be automatically removed on startup

Plugin Integration

Plugins can check for semaphore file using standard file existence checks. For example, terminal bell plugin will not play sounds while semaphore file is present.

Invocation Logging

The prompt enhancer maintains an automatic log file that records all invocations, allowing you to easily review and re-execute previous commands.

Log File Location

The log file is created at: ~/.config/opencode/prompt-enhancer/log.md

Log Format

Each invocation is recorded as a Markdown list item with a timestamp:

- [HH:MM:SS] command arg1 arg2 ...

Example log file:

- [09:30:15] feature Add authentication system
- [09:35:22] question What is deployment process?
- [09:40:45] tests Create integration tests for API endpoints
- [09:45:12] Created semaphore file
- [09:45:15] Removed semaphore file

Features

  • Append-only: All entries are appended to the log, preserving chronological order
  • Atomic: File operations are atomic, ensuring no data corruption even with concurrent access
  • Always recorded: Entries are logged regardless of whether the enhancement succeeds or fails
  • Semaphore tracking: Semaphore file creation and deletion are also logged for debugging
  • Human-readable: Format is simple and suitable for copying commands for re-execution

Building

go build -o prompt-enhancer/prompt-enhancer ./prompt-enhancer

Testing

cd prompt-enhancer
go test -v

The Go implementation maintains full compatibility with the original Bash script's behavior and output format while providing better error handling, type safety, and testability.

A sample invocation

go build -o prompt-enhancer/prompt-enhancer ./prompt-enhancer && DEBUG__SKIP_ENHANCING=1 ~/oc/prompt-enhancer/prompt-enhancer ask rfc What does using RFC keyword in command do

Configuration Utilities

Toggle Paste Summary Script

The toggle-paste-summary.sh script provides a convenient way to toggle experimental disable_paste_summary configuration option without manually editing JSON.

Location

~/.config/opencode/scripts/toggle-paste-summary.sh

Usage

# Toggle current setting (true ↔ false)
./scripts/toggle-paste-summary.sh

# Enable (disable paste summary feature)
./scripts/toggle-paste-summary.sh --enable

# Disable (enable paste summary feature)
./scripts/toggle-paste-summary.sh --disable

# Check current status without modifying
./scripts/toggle-paste-summary.sh --status

# Show help information
./scripts/toggle-paste-summary.sh --help

Features

  • Automatic backup: Creates timestamped backups before each modification
  • JSON validation: Validates JSON structure before and after changes
  • Smart defaults: Handles missing experimental object gracefully
  • Atomic updates: Uses temporary files to prevent corruption
  • Clear feedback: Provides colored output showing current and new values
  • Error handling: Comprehensive error checking for file permissions, malformed JSON, etc.

Configuration Setting

The script modifies the following configuration path in opencode.json:

{
  "experimental": {
    "disable_paste_summary": true
  }
}

When disable_paste_summary is true, OpenCode will not display paste summaries. When false (or not present), paste summaries are shown normally.

Requirements

  • jq - JSON processor (install with brew install jq on macOS)

Examples

# Enable experimental feature (disable paste summaries)
$ ./scripts/toggle-paste-summary.sh --enable
ℹ Current setting: disable_paste_summary = false
ℹ Backup created: /Users/user/.config/opencode/opencode.json.backup.20251101_204419
✓ Updated setting: disable_paste_summary = true
✓ Paste summary is now DISABLED

# Check current status
$ ./scripts/toggle-paste-summary.sh --status
ℹ Current setting: disable_paste_summary = true
ℹ Paste summary is currently DISABLED

# Toggle back to default behavior
$ ./scripts/toggle-paste-summary.sh
ℹ Current setting: disable_paste_summary = true
ℹ Backup created: /Users/user/.config/opencode/opencode.json.backup.20251101_204425
✓ Updated setting: disable_paste_summary = false
✓ Paste summary is now ENABLED

opencode-config

About

My opencode configuration.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published