Something went wrong. Try again.
🐱 Medium-horizon agent planning MCP server
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869-- 9plan SQLite Schema-- Requires SQLite with FTS5 support (built into Node.js 22.5.0+)
PRAGMA foreign_keys = ON;
-- Sessions tableCREATE TABLE IF NOT EXISTS sessions ( name TEXT PRIMARY KEY, task_description TEXT, created_at TEXT DEFAULT (datetime('now'))) STRICT;
-- Plans table with all lifecycle statesCREATE TABLE IF NOT EXISTS plans ( id TEXT PRIMARY KEY, session_name TEXT NOT NULL REFERENCES sessions(name) ON DELETE CASCADE, status TEXT NOT NULL CHECK (status IN ('queued', 'active', 'completed', 'discarded')), queue_position INTEGER,
goal TEXT NOT NULL, context TEXT, inputs TEXT, outputs TEXT, approach TEXT, success_criteria TEXT, notes TEXT, outcome TEXT,
created_at TEXT DEFAULT (datetime('now')), completed_at TEXT) STRICT;
-- Index for efficient queue queries (queued plans ordered by position)CREATE INDEX IF NOT EXISTS idx_plans_queue ON plans(session_name, status, queue_position) WHERE status = 'queued';
-- Index for finding the active plan quicklyCREATE INDEX IF NOT EXISTS idx_plans_active ON plans(session_name, status) WHERE status = 'active';
-- FTS5 virtual table for history search-- Searches across goal, context, inputs, outputs, and outcomeCREATE VIRTUAL TABLE IF NOT EXISTS plans_fts USING fts5( id, goal, context, inputs, outputs, outcome, content='plans', content_rowid='rowid');
-- Trigger: Keep FTS in sync on INSERTCREATE TRIGGER IF NOT EXISTS plans_ai AFTER INSERT ON plans BEGIN INSERT INTO plans_fts(rowid, id, goal, context, inputs, outputs, outcome) VALUES (new.rowid, new.id, new.goal, new.context, new.inputs, new.outputs, new.outcome);END;
-- Trigger: Keep FTS in sync on DELETECREATE TRIGGER IF NOT EXISTS plans_ad AFTER DELETE ON plans BEGIN INSERT INTO plans_fts(plans_fts, rowid, id, goal, context, inputs, outputs, outcome) VALUES ('delete', old.rowid, old.id, old.goal, old.context, old.inputs, old.outputs, old.outcome);END;
-- Trigger: Keep FTS in sync on UPDATECREATE TRIGGER IF NOT EXISTS plans_au AFTER UPDATE ON plans BEGIN INSERT INTO plans_fts(plans_fts, rowid, id, goal, context, inputs, outputs, outcome) VALUES ('delete', old.rowid, old.id, old.goal, old.context, old.inputs, old.outputs, old.outcome); INSERT INTO plans_fts(rowid, id, goal, context, inputs, outputs, outcome) VALUES (new.rowid, new.id, new.goal, new.context, new.inputs, new.outputs, new.outcome);END;