This repository contains OpenCode CLI plugins that extend sessions with reflection, text-to-speech, and Telegram notifications.
Primary plugins:
reflection.ts(reflection-3): validates task completion and workflow requirements.tts.ts: reads the final assistant response aloud (macOS or Coqui server).telegram.ts: posts completion notifications to Telegram and accepts replies.
Purpose: enforce completion gates (tests/PR/CI) and generate actionable feedback when tasks are incomplete.
Flow summary:
- Listens on
session.idle. - Builds task context from recent messages and tool usage.
- Requests a self-assessment JSON from the agent.
- Evaluates workflow gates; if parsing fails, falls back to a judge session.
- Writes artifacts to
.reflection/and posts feedback only if incomplete.
Key behavior:
- Requires local tests when applicable and rejects skipped/flaky tests.
- Requires PR and CI check evidence; no direct push to
main/master. - If
needs_user_actionis set, it shows a toast and does not push feedback. - Any utility sessions created by
reflection-3.ts(judge, routing classifier, etc.) must be deleted after use.
Documentation:
docs/reflection.md
Purpose: speak the final assistant response aloud.
Flow summary:
- Skips judge/reflection sessions.
- Extracts final assistant text and strips code/markdown.
- Uses configured engine (macOS
sayor Coqui server).
Documentation:
docs/tts.md
Purpose: send a Telegram notification when a task finishes and ingest replies via webhook.
Flow summary:
- On completion, sends a summary to Telegram.
- Stores reply context for routing responses back to sessions.
Documentation:
docs/telegram.md
Reflection uses two paths:
- Self-assessment path
- The agent returns JSON with evidence (tests, build, PR, CI).
- The plugin checks workflow gates and decides complete/incomplete.
- Judge fallback path
- If parsing fails, a judge session evaluates the self-assessment content.
- Judge returns JSON verdict (complete, severity, missing, next actions).
Artifacts:
.reflection/verdict_<session>.json(signals for TTS/Telegram gating).reflection/<session>_<timestamp>.json(full analysis record)
Never use console.log, console.error, console.warn, process.stdout.write, or process.stderr.write in plugin runtime code. Any output to stdout/stderr corrupts the OpenCode TUI.
For debug/diagnostic logging, write to log files instead:
- Reflection plugin:
.reflection/debug.log(enabled byREFLECTION_DEBUG=1) - TTS plugin:
~/.config/opencode/opencode-helpers/tts.log
Test files (test/*.ts) may use console.log for test output.
Before considering any task complete, you MUST:
- Run unit tests:
npm test— all tests must pass. - Run prompt evals:
npm run eval:judge,npm run eval:stuck,npm run eval:compression— all evals must pass. - If tests or evals fail, fix the issue and re-run until they pass.
- Never commit or create a PR with failing tests.
Promptfoo evals write logs and a SQLite database to a config directory. In this environment,
~/.promptfoo may be read-only. Use a writable local config directory and disable WAL/telemetry:
PROMPTFOO_CONFIG_DIR=$PWD/.promptfoo \
PROMPTFOO_DISABLE_WAL_MODE=1 \
PROMPTFOO_DISABLE_TELEMETRY=1 \
npm run eval:judgedocs/reflection.mddocs/tts.mddocs/telegram.md