feat(obelisk): index session summaries and guide incremental retrieval

- Add generic summaries table (source-agnostic, ready for Codex)
  - Index Claude Code away_summary events as session-level recaps
  - Add summaries() query API
  - Rewrite retrieval strategy in SKILL.md: never pull entire sessions,
    navigate horizontally (by timestamp) or vertically (by parent chain)
This commit is contained in:
tommy0103
2026-06-01 16:52:58 +08:00
parent a6be5172c3
commit 4bfced92b7
4 changed files with 30 additions and 1 deletions
+5
View File
@@ -62,6 +62,7 @@ function indexJsonl(db, fi) {
msg: db.prepare('INSERT OR REPLACE INTO messages (uuid,session_id,type,parent_uuid,timestamp,role,text,model,is_sidechain,agent_id,input_tokens,output_tokens) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'),
tc: db.prepare('INSERT OR REPLACE INTO tool_calls (id,message_uuid,session_id,name,input_json,file_path) VALUES (?,?,?,?,?,?)'),
tr: db.prepare('INSERT OR REPLACE INTO tool_results (tool_use_id,message_uuid,session_id,content,file_path) VALUES (?,?,?,?,?)'),
sum: db.prepare('INSERT OR REPLACE INTO summaries (id,session_id,timestamp,source,content) VALUES (?,?,?,?,?)'),
idx: db.prepare('INSERT OR REPLACE INTO index_state (jsonl_path,mtime,lines_processed) VALUES (?,?,?)'),
};
@@ -85,6 +86,10 @@ function indexJsonl(db, fi) {
const ts = obj.timestamp || null;
if (obj.type === 'ai-title' && obj.aiTitle) { sm.title = obj.aiTitle; return; }
if (obj.type === 'system' && obj.subtype === 'away_summary' && obj.content) {
ins.sum.run(obj.uuid || `${sid}-away-${ts}`, sid, ts, 'away_summary', obj.content);
return;
}
if (obj.type !== 'user' && obj.type !== 'assistant') return;
if (ts && (!sm.started_at || ts < sm.started_at)) sm.started_at = ts;