(base) at@vm-mint:~/.local/share/opencode/log$ sqlite3 /home/at/.local/share/opencode/opencode.db
SQLite version 3.51.1 2025-11-28 17:28:25
Enter ".help" for usage hints.
sqlite> .tables
__drizzle_migrations event_sequence session
account message session_share
account_state part todo
control_account permission workspace
event project
sqlite> .schema
CREATE TABLE IF NOT EXISTS "__drizzle_migrations" (
id INTEGER PRIMARY KEY,
hash text NOT NULL,
created_at numeric,
name text,
applied_at TEXT
);
CREATE TABLE `project` (
`id` text PRIMARY KEY,
`worktree` text NOT NULL,
`vcs` text,
`name` text,
`icon_url` text,
`icon_color` text,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`time_initialized` integer,
`sandboxes` text NOT NULL
, `commands` text);
CREATE TABLE `message` (
`id` text PRIMARY KEY,
`session_id` text NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`data` text NOT NULL,
CONSTRAINT `fk_message_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
);
CREATE TABLE `part` (
`id` text PRIMARY KEY,
`message_id` text NOT NULL,
`session_id` text NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`data` text NOT NULL,
CONSTRAINT `fk_part_message_id_message_id_fk` FOREIGN KEY (`message_id`) REFERENCES `message`(`id`) ON DELETE CASCADE
);
CREATE TABLE `permission` (
`project_id` text PRIMARY KEY,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`data` text NOT NULL,
CONSTRAINT `fk_permission_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE
);
CREATE TABLE `session` (
`id` text PRIMARY KEY,
`project_id` text NOT NULL,
`parent_id` text,
`slug` text NOT NULL,
`directory` text NOT NULL,
`title` text NOT NULL,
`version` text NOT NULL,
`share_url` text,
`summary_additions` integer,
`summary_deletions` integer,
`summary_files` integer,
`summary_diffs` text,
`revert` text,
`permission` text,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
`time_compacting` integer,
`time_archived` integer, `workspace_id` text,
CONSTRAINT `fk_session_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE
);
CREATE TABLE `todo` (
`session_id` text NOT NULL,
`content` text NOT NULL,
`status` text NOT NULL,
`priority` text NOT NULL,
`position` integer NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
CONSTRAINT `todo_pk` PRIMARY KEY(`session_id`, `position`),
CONSTRAINT `fk_todo_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
);
CREATE TABLE `session_share` (
`session_id` text PRIMARY KEY,
`id` text NOT NULL,
`secret` text NOT NULL,
`url` text NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
CONSTRAINT `fk_session_share_session_id_session_id_fk` FOREIGN KEY (`session_id`) REFERENCES `session`(`id`) ON DELETE CASCADE
);
CREATE INDEX `part_session_idx` ON `part` (`session_id`);
CREATE INDEX `session_project_idx` ON `session` (`project_id`);
CREATE INDEX `session_parent_idx` ON `session` (`parent_id`);
CREATE INDEX `todo_session_idx` ON `todo` (`session_id`);
CREATE TABLE `control_account` (
`email` text NOT NULL,
`url` text NOT NULL,
`access_token` text NOT NULL,
`refresh_token` text NOT NULL,
`token_expiry` integer,
`active` integer NOT NULL,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL,
CONSTRAINT `control_account_pk` PRIMARY KEY(`email`, `url`)
);
CREATE TABLE `workspace` (
`id` text PRIMARY KEY,
`branch` text,
`project_id` text NOT NULL,
`type` text NOT NULL, `name` text, `directory` text, `extra` text,
CONSTRAINT `fk_workspace_project_id_project_id_fk` FOREIGN KEY (`project_id`) REFERENCES `project`(`id`) ON DELETE CASCADE
);
CREATE INDEX `session_workspace_idx` ON `session` (`workspace_id`);
CREATE TABLE `account` (
`id` text PRIMARY KEY,
`email` text NOT NULL,
`url` text NOT NULL,
`access_token` text NOT NULL,
`refresh_token` text NOT NULL,
`token_expiry` integer,
`time_created` integer NOT NULL,
`time_updated` integer NOT NULL
);
CREATE TABLE `account_state` (
`id` integer PRIMARY KEY NOT NULL,
`active_account_id` text, `active_org_id` text,
FOREIGN KEY (`active_account_id`) REFERENCES `account`(`id`) ON UPDATE no action ON DELETE set null
);
CREATE INDEX `message_session_time_created_id_idx` ON `message` (`session_id`,`time_created`,`id`);
CREATE INDEX `part_message_id_id_idx` ON `part` (`message_id`,`id`);
CREATE TABLE `event_sequence` (
`aggregate_id` text PRIMARY KEY,
`seq` integer NOT NULL
);
CREATE TABLE `event` (
`id` text PRIMARY KEY,
`aggregate_id` text NOT NULL,
`seq` integer NOT NULL,
`type` text NOT NULL,
`data` text NOT NULL,
CONSTRAINT `fk_event_aggregate_id_event_sequence_aggregate_id_fk` FOREIGN KEY (`aggregate_id`) REFERENCES `event_sequence`(`aggregate_id`) ON DELETE CASCADE
);
sqlite> SELECT * FROM part ORDER BY time_created desc LIMIT 5;
prt_d67be3a9c001swbSE3eI0vRxQk|msg_d67be3a9b001A4xf0JCv7KheGl|ses_2985bfd7cffenWOQm17BUksmBg|1775562013355|1775562013355|{"type":"text","text":"这个python脚本可以在命令行入参数量 按时间顺序打印指定数量的内容(每个问题附带回答为1个数量)"}
prt_d67bc64690019HKB7DiF6Yont6|msg_d67bc4b34001kDQ2wIvc88V3ra|ses_2985bfd7cffenWOQm17BUksmBg|1775561892969|1775561893708|{"type":"tool","tool":"write","callID":"call_function_4gppqbb5t4qb_1","state":{"status":"running","input":{"content":"import sqlite3\nimport json\n\nconn = sqlite3.connect('/home/at/.local/share/opencode/opencode.db')\ncursor = conn.cursor()\ncursor.execute(\"SELECT data FROM part WHERE session_id='ses_2985bfd7cffenWOQm17BUksmBg' ORDER BY time_created\")\n\nfor row in cursor.fetchall():\n data = json.loads(row[0])\n if data.get('type') == 'text':\n print(f\"\\n[回答]: {data.get('text', '')}\")\n elif data.get('type') == 'reasoning':\n print(f\"\\n[思考]: {data.get('text', '')}\")\n\nconn.close()","filePath":"/home/at/.local/share/opencode/log/extract_chat.py"},"time":{"start":1775561893708}}}
prt_d67bc631d001RUrIAmhUdiWRur|msg_d67bc4b34001kDQ2wIvc88V3ra|ses_2985bfd7cffenWOQm17BUksmBg|1775561892637|1775561892968|{"type":"reasoning","text":"用户想要把提取对话的Python脚本保存到log目录下。","time":{"start":1775561892637,"end":1775561892967},"metadata":{"anthropic":{"signature":"7593185d6c1b63047442559fbb6067ce7df19d08a87f22b97d2d239448216aa7"}}}
prt_d67bc631c001SgqbFSwr6k1277|msg_d67bc4b34001kDQ2wIvc88V3ra|ses_2985bfd7cffenWOQm17BUksmBg|1775561892636|1775561892636|{"type":"step-start"}
prt_d67bc4b1f001tFaXCsnNOT9ybq|msg_d67bc4b1e001TlMpgMLzd57sqQ|ses_2985bfd7cffenWOQm17BUksmBg|1775561886506|1775561886506|{"type":"text","text":"脚本保存到log下"}
sqlite>