How humanerd-drew/opencode-drewgent works
Purpose and Entry Points
This is a forkable local opencode AI-agent runtime template, not a conventional application. It configures agent identity, instructions, specialized subagents, durable knowledge, scheduled automation, and optional Discord access. Primary interactive entry is opencode after scripts/setup.sh; operational entry points include scripts/discord_bot.py, scripts/drewgent_cron.py, and cron/cron_agent.py.
Agent Configuration and Governance
opencode.jsonc is the runtime integration/configuration boundary. Repository-level rules and operating conventions live in AGENTS.md and .opencode/instructions/00-architecture.md. The vault-like identity hierarchy separates immutable behavioral rules, persona, and self-model:
• @identity/brain/rules.md
• @identity/persona/SOUL.md
• @identity/SELF_MODEL.md
This implements priority-based governance: brain/rules override persona and task-level preferences; tiered autonomy limits which changes the agent may perform without human approval.
Delegation and Specialist Agents
The orchestrated agent delegates work to focused profiles under .opencode/agents/, including planner, explorer, implementer, reviewer, SRE, and analyst:
• .opencode/agents/orchestrator.md
• .opencode/agents/implementer.md
• .opencode/agents/reviewer.md
Profiles encode role boundaries, model/cost intent, and permissions (notably read-only exploration/review versus editing). Isolated, parallel work is routed through the GJC delegation tool at .opencode/tools/delegate.ts; same-context tasks use opencode-native delegation. This is the main control-flow boundary between planning, execution, and quality gate stages.
Knowledge, Memory, and Skills
Long-term agent knowledge is filesystem-backed and tool-accessible rather than embedded in application code. Memory operations and graph retrieval are exposed through:
• .opencode/plugins/knowledge.js
• .opencode/tools/remember.ts
• .opencode/tools/recall.ts
skills/ is the primary on-demand capability catalog: each skill’s SKILL.md supplies workflow instructions and may include scripts/references. @action/skills/ is a bundled/action-oriented skill layer. The expected flow is request → select relevant skill/profile → retrieve provenance and memory → execute → write reusable facts or artifacts back to the knowledge system.
Proactive Automation and Work Persistence
Scheduled work is configured in cron/jobs.json and executed by scheduler/runtime modules:
• cron/scheduler.py
• cron/jobs.py
• scripts/drewgent_cron.py
Operational scripts handle cron health, self-healing, log rotation, knowledge ingestion, graph queries, and Kanban dispatch/worker execution. Kanban provides persistence across agent/session failure, with work intended to progress through explorer → implementer → reviewer. Key runners are scripts/run_kanban_worker.py and scripts/kanban_maintenance.py.
External Interfaces and Services
The Discord gateway maps Discord threads to persistent opencode sessions and streams agent activity:
• scripts/discord_bot.py
• scripts/discord_send.py
It requires DISCORD_BOT_TOKEN. Configured MCP boundaries include local codebase-memory graph access, Gajae-Code worktree/tmux coordination, Safari browsing, Discord, and WordPress; a remote Astryx design-system server is also documented. Environment secrets/configuration are expected through .env based on .env.example.
Deployment and Runtime Infrastructure
The main runtime is opencode plus Python automation, with Node.js used where needed (for example, the WhatsApp bridge under scripts/whatsapp-bridge/). Persistent background execution is platform-native:
• services/launchd/ai.yourgent-opencode.plist.example
• services/systemd/yourgent-opencode.service
• services/windows/setup-scheduled-tasks.ps1
GitHub Actions cover tests, Nix, Docker publishing, supply-chain auditing, and docs/site deployment. The repository is therefore a configurable local agent operating environment whose durable state and behavior are chiefly defined by Markdown/JSON configuration, skill content, and external opencode/MCP services.
Main entry points: orchestrator.md Orchestrator profile · scheduler.py Cron scheduler · knowledge.js Knowledge service · opencode.jsonc Runtime integration
Components 18
Governance
- Runtime integration · Configures opencode and MCP integration boundaries.
opencode.jsonc - Repository rules
AGENTS.md - Architecture instructions
.opencode/instructions/00-architecture.md - Identity hierarchy · Rules override persona and self-model preferences.
@identity/brain/rules.md
Agent Control
- Orchestrator profile · Selects specialists and directs work stages.
.opencode/agents/orchestrator.md - Implementer profile
.opencode/agents/implementer.md - Reviewer profile · Read-only quality gate for delegated work.
.opencode/agents/reviewer.md - GJC delegation · Routes isolated work through worktree/tmux coordination.
.opencode/tools/delegate.ts
Knowledge & Skills
- Knowledge service · Filesystem-backed memory operations and graph retrieval.
.opencode/plugins/knowledge.js - Remember / recall · Writes reusable facts and retrieves provenance.
.opencode/tools/remember.ts - Skill catalog · Skill instructions select capabilities and supporting resources.
Automation & Work
- Scheduled jobs
cron/jobs.json - Cron scheduler · Loads and executes configured scheduled work.
cron/scheduler.py - Kanban worker · Persists and advances work across explorer, implementer, and reviewer stages.
scripts/run_kanban_worker.py
Interfaces & Runtime
- opencode runtime · Primary interactive agent entry point.
- Discord gateway · Maps Discord threads to persistent opencode sessions and streams activity.
scripts/discord_bot.py - Environment secrets · Supplies tokens and external service configuration.
.env.example - Background service hosts · Launchd, systemd, and Windows scheduled-task deployment options.
Connections 18
- Runtime integration → opencode runtime: configures
- Repository rules → opencode runtime: governs
- Architecture instructions → opencode runtime: instructs
- Identity hierarchy → opencode runtime: sets priority rules
- opencode runtime → Orchestrator profile: runs
- Orchestrator profile → Implementer profile: delegates execution
- Orchestrator profile → Reviewer profile: sends for review
- Orchestrator profile → GJC delegation: isolates parallel work
- opencode runtime → Skill catalog: selects workflows
- opencode runtime → Knowledge service: uses
- Remember / recall → Knowledge service: reads and writes
- Cron scheduler → Scheduled jobs: loads
- Cron scheduler → opencode runtime: triggers agent work
- Kanban worker → Orchestrator profile: dispatches staged work
- Discord gateway → opencode runtime: creates sessions
- Environment secrets → Discord gateway: provides bot token
- Runtime integration → Knowledge service: registers boundary
- Background service hosts → Cron scheduler: keeps running