File: .opencode/agent/meridian-plan.md
Key Features:
- Tool restrictions: Read-only access (no write/edit/bash)
- Analysis tools: read, grep, glob, list, webfetch, websearch
- Planning tools: todowrite enabled
- Custom system prompt for planning workflow
- Temperature: 0.2 (focused, deterministic)
- Model: claude-sonnet-4
Purpose: Provides a specialized planning mode that prevents premature code changes while allowing thorough analysis and structured planning.
File: .opencode/plugin/meridian.ts
Key Changes:
-
Agent tracking via
chat.messagehook- Detects current agent (build, plan, meridian-plan, custom)
- Logs agent switches for debugging
-
Conditional behavior in
tool.execute.beforehook- Context review guard: Active in ALL agents
- Task creation enforcement: ONLY in
meridian-planagent - Other agents: Full features without restrictions
-
Universal hooks remain active across all agents:
- Session start/resume/compact context loading
- Session idle/stop cleanup reminders
- Memory and task tools always available
Benefits:
- Meridian features work in ANY agent (build, plan, custom)
- Planning workflow only enforced when user explicitly chooses
meridian-plan - No interference with user's preferred workflows
- Flexible and extensible
New Files:
AGENT_GUIDE.md- Complete guide to agent systemIMPLEMENTATION_NOTES.md- This file
Updated Files:
README.md- Added meridian-plan usage instructions- Updated directory structure to show
.opencode/agent/
Original Meridian (Claude Code):
{
"permissions": { "defaultMode": "plan" }
}- Forces Plan mode on session start
- Every session begins in planning workflow
- User must exit to Build mode
OpenCode Version:
- No "defaultMode" support in OpenCode
- Agent system is more flexible
- User chooses when to use planning workflow
Decision: Create optional meridian-plan agent
- Users opt-in to planning workflow
- Doesn't interfere with normal development
- Can create multiple specialized agents
Alternative Approach (Rejected): Always enforce task creation when ExitPlanMode is called
Problem:
- User uses built-in
planagent for quick analysis - Doesn't want task creation enforcement
- Gets annoying prompts
Solution Chosen:
Only enforce when currentAgent === "meridian-plan"
Benefits:
meridian-plan: Full Meridian planning workflowplan: Standard OpenCode planningbuild: Standard OpenCode implementation- Custom agents: Full Meridian features, no enforcement
Available Hooks:
- ✅
chat.message: Hasinput.agentfield - ✅
chat.params: Hasinput.agentfield - ❌
event: No agent information - ❌
tool.execute.before: No agent information
Decision: Use chat.message to track agent
- Store in plugin-scoped variable
- Access in
tool.execute.beforehook - Simple, reliable, works across all tool calls
let currentAgent: string = "build"; // Default to buildIf user never sends a message, assumes build agent.
if (previousAgent !== currentAgent) {
console.log(...); // Only log on change
}Avoids spamming console with repeated agent messages.
if (input.tool === "ExitPlanMode" && currentAgent === "meridian-plan") {
// Only block in meridian-plan
}
// Falls through for other agents - no restrictionif (existsSync(needsContextReviewFlag)) {
// Applies to ALL agents
removeContextReviewFlag();
throw new Error(...);
}Critical safety feature - never bypassed.
- Start OpenCode
- Switch to
meridian-planagent (Tab) - Discuss feature planning
- Agent creates plan with TodoWrite
- User approves
- Exit plan mode (Tab)
- Expected: Meridian prompts for task creation
- Create task
- Switch to
buildagent - Implement
- Start OpenCode
- Switch to
planagent (Tab) - Quick analysis
- Exit plan mode (Tab)
- Expected: No task creation prompt
- Continue working
- Start OpenCode (defaults to
build) - Make quick fix
- Expected: No restrictions, no prompts
- Optional: Use
task-managermanually if needed
- Work in any agent
- Session gets compacted
- Expected: Context reload in ALL agents
- Review context before continuing
- Agent-specific behavior resumes
- ❌ No automatic Plan mode on startup
- ✅ Explicit
meridian-planagent - ✅ All other agents have full Meridian features
- ✅ Task creation enforcement is opt-in
- ✅ Memory system (
memory-curator) - ✅ Task system (
task-manager) - ✅ Context preservation on resume/compact
- ✅ Session idle/stop hooks
- ✅ Coding standards enforcement
- ✅ Project configuration (config.yaml)
Original: "Meridian forces me into planning mode" OpenCode Version: "I choose when to use Meridian planning"
-
More Specialized Agents:
meridian-review: Code review focusmeridian-docs: Documentation focusmeridian-refactor: Refactoring focus
-
Agent-Specific Memory Queries:
if (currentAgent === "meridian-review") { // Auto-load security memory entries }
-
Agent Recommendations:
if (userMessage.includes("plan") && currentAgent !== "meridian-plan") { console.log("Tip: Use meridian-plan agent for structured planning"); }
-
Configuration-Based Agent Behavior:
# .meridian/config.yaml agents: meridian-plan: auto_create_tasks: true require_approval: true
- Minimal: Single variable assignment per message
- No file I/O
- No async operations
- Negligible performance impact
chat.messageruns on every message → UpdatescurrentAgenttool.execute.beforeruns before each tool → ReadscurrentAgent- No race conditions (single-threaded event loop)
- Enforced by OpenCode, not plugin
- Agent configuration in
.opencode/agent/meridian-plan.md - Cannot be bypassed by plugin code
- User can modify their own agent files (expected)
- Prevents tool usage until context reviewed
- File-based flag (
.meridian/.needs-context-review) - Removed on first tool attempt
- Applies to ALL agents (security feature)
-
Cannot force default agent
- OpenCode has no
defaultAgentconfig - User must manually select agent
- Could add console reminder
- OpenCode has no
-
Agent detection relies on chat.message
- If user never sends message, stays in "build"
- Acceptable: Session without messages is inactive
-
No agent-specific memory queries
- All agents see same memory entries
- Future enhancement opportunity
| Feature | Original (Claude Code) | OpenCode Version |
|---|---|---|
| Default mode | Forced Plan mode | User's choice (build) |
| Planning enforcement | Always (in Plan mode) | Opt-in (meridian-plan agent) |
| Memory system | ✅ Active | ✅ Active (all agents) |
| Task system | ✅ Active | ✅ Active (all agents) |
| Context preservation | ✅ Active | ✅ Active (all agents) |
| Tool restrictions | Via settings.json | Via agent definition |
| Flexibility | Limited (2 modes) | High (unlimited agents) |
| User control | Must use Plan mode | Choose workflow |
The OpenCode version of Meridian is more flexible than the original while maintaining all core features:
Retained:
- Memory management across sessions
- Task scaffolding and tracking
- Context preservation on compaction
- Coding standards enforcement
- Session lifecycle hooks
Improved:
- User control over workflow
- Support for custom agents
- No forced planning mode
- Extensible agent system
- Cleaner separation of concerns
Trade-off:
- Users must explicitly choose
meridian-planagent - No automatic planning mode on startup
- Requires user awareness of agent system
Recommendation:
Document in README and provide clear instructions for when to use meridian-plan agent.