Skip to content
 
 

Repository files navigation

opencode-demo

A public showcase repository demonstrating how to combine GitHub Cloud, GitHub Actions, and OpenCode to automatically triage issues, propose fixes, run CI, and self-heal the main branch.

What this repository demonstrates

Workflow Trigger Outcome
issue-triage.yml New or edited issue Labels the issue (bug, enhancement, opencode-fix, etc.)
opencode-fix.yml Issue labeled opencode-fix or manual dispatch Runs OpenCode agent, creates a branch, opens a PR
ci.yml Push or pull request to main Runs pytest and ruff
main-health-check.yml Cron every 6 hours or manual dispatch Creates an opencode-fix issue if main CI fails

The planted bug

calculator/stats.py contains a bug in median().

For an even-length list the median should be the average of the two middle values, but the current implementation returns only the upper middle value:

>>> from calculator.stats import median
>>> median([1, 2, 3, 4])
3            # BUG: expected 2.5

You can reproduce the bug locally:

python demo/reproduce_issue.py

Setup

1. Clone the repository

git clone https://github.com/ccyflai/opencode-demo.git
cd opencode-demo

2. Create a virtual environment

python3 -m venv .venv
source .venv/bin/activate   # On Windows: .venv\Scripts\activate

3. Install dependencies

pip install -r requirements.txt
pip install -r requirements-dev.txt

4. Run the planted (failing) tests

pytest

You should see:

tests/test_stats.py::test_median_even FAILED

This is expected — the OpenCode agent is meant to fix it.

Running the demo end-to-end

Required secrets

Before the auto-fix workflow can run, add a secret in your GitHub repository:

  1. Go to Settings → Secrets and variables → Actions.
  2. Click New repository secret.
  3. Name: OPENAI_API_KEY
  4. Value: your API key for the configured OpenCode model.

If you use a custom endpoint (Azure OpenAI, local proxy, etc.), also add OPENAI_BASE_URL.

Trigger the workflow

  1. Open the pre-seeded issue titled "Median calculation returns wrong result for even-length lists".
  2. Apply the label opencode-fix (or let the triage workflow do it automatically).
  3. Watch the Actions tab for the OpenCode Auto-Fix workflow.
  4. When it completes, a pull request referencing Closes #1 is opened.
  5. CI runs on the PR. If all checks pass, review and merge.

Manual dispatch

You can also trigger the fix workflow manually:

  1. Go to Actions → OpenCode Auto-Fix → Run workflow.
  2. Enter the issue number.
  3. Click Run workflow.

Local inspection of the OpenCode prompt

The prompt template rendered for the agent lives in .opencode/prompts/fix_issue.md.

The agent behavior rules live in .opencode/agent.yml:

  • Model: github-copilot/kimi-k2.7-code
  • Allowed directories: repository root
  • Denied directories: .github/, .opencode/, .git/

Self-healing CI

main-health-check.yml runs every 6 hours. If tests on main fail, it automatically creates a labeled issue (opencode-fix, ci-failure, bug), which triggers the OpenCode agent to propose a fix.

Project structure

.
├── calculator/              # Demo Python package
│   ├── core.py
│   ├── stats.py             # <-- contains the median bug
│   └── cli.py
├── tests/
│   ├── test_core.py
│   ├── test_stats.py        # <-- exposes the median bug
│   └── test_cli.py
├── .opencode/
│   ├── agent.yml
│   └── prompts/fix_issue.md
├── .github/
│   ├── workflows/
│   │   ├── ci.yml
│   │   ├── issue-triage.yml
│   │   ├── opencode-fix.yml
│   │   └── main-health-check.yml
│   ├── scripts/
│   │   ├── prepare_fix_env.sh
│   │   └── run_opencode_fix.py
│   └── ISSUE_TEMPLATE/
│       └── bug_report.yml
├── demo/
│   └── reproduce_issue.py
├── pyproject.toml
├── requirements.txt
└── requirements-dev.txt

License

MIT

About

Showcase GitHub + OpenCode auto-fix workflow

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages