| 459 | } |
| 460 | |
| 461 | fn print_examples() { |
| 462 | println!("FILTER BY CURRENT PROJECT"); |
| 463 | println!("═══════════════════════════════════════════════════════════════════════════════\n"); |
| 464 | println!(" # Only prompts from current folder"); |
| 465 | println!(" ccql \"SELECT display FROM history WHERE project = '$(pwd)' LIMIT 10\"\n"); |
| 466 | println!(" # Transcripts from current project (via session join)"); |
| 467 | println!(" ccql \"SELECT t.tool_name, COUNT(*) as n FROM transcripts t"); |
| 468 | println!(" JOIN history h ON t._session_id = h.session_id"); |
| 469 | println!(" WHERE h.project = '$(pwd)' AND t.type='tool_use'"); |
| 470 | println!(" GROUP BY t.tool_name ORDER BY n DESC\"\n"); |
| 471 | |
| 472 | println!("HISTORY QUERIES"); |
| 473 | println!("═══════════════════════════════════════════════════════════════════════════════\n"); |
| 474 | println!(" # Recent prompts"); |
| 475 | println!(" ccql \"SELECT display FROM history ORDER BY timestamp DESC LIMIT 10\"\n"); |
| 476 | println!(" # Search prompts"); |
| 477 | println!(" ccql \"SELECT display FROM history WHERE display LIKE '%error%'\"\n"); |
| 478 | println!(" # Prompts by project"); |
| 479 | println!( |
| 480 | " ccql \"SELECT project, COUNT(*) as n FROM history GROUP BY project ORDER BY n DESC\"\n" |
| 481 | ); |
| 482 | println!(" # Long prompts (likely pasted code)"); |
| 483 | println!(" ccql \"SELECT LENGTH(display) as len, SUBSTR(display, 1, 60) as preview"); |
| 484 | println!(" FROM history ORDER BY len DESC LIMIT 10\"\n"); |
| 485 | println!(" # Recent Codex prompts from jhistory"); |
| 486 | println!(" ccql \"SELECT datetime(timestamp/1000, 'unixepoch') as time, display"); |
| 487 | println!(" FROM jhistory ORDER BY timestamp DESC LIMIT 10\"\n"); |
| 488 | |
| 489 | println!("TRANSCRIPT QUERIES"); |
| 490 | println!("═══════════════════════════════════════════════════════════════════════════════\n"); |
| 491 | println!(" # Tool usage stats"); |
| 492 | println!(" ccql \"SELECT tool_name, COUNT(*) as n FROM transcripts"); |
| 493 | println!(" WHERE type='tool_use' GROUP BY tool_name ORDER BY n DESC\"\n"); |
| 494 | println!(" # Most active sessions"); |
| 495 | println!(" ccql \"SELECT _session_id, COUNT(*) as n FROM transcripts"); |
| 496 | println!(" GROUP BY _session_id ORDER BY n DESC LIMIT 10\"\n"); |
| 497 | println!(" # Recent tool calls"); |
| 498 | println!(" ccql \"SELECT tool_name, timestamp FROM transcripts"); |
| 499 | println!(" WHERE type='tool_use' ORDER BY timestamp DESC LIMIT 20\"\n"); |
| 500 | println!(" # All messages in a session"); |
| 501 | println!(" ccql \"SELECT type, SUBSTR(COALESCE(content, tool_name), 1, 50) as preview"); |
| 502 | println!(" FROM transcripts WHERE _session_id='SESSION_ID'\"\n"); |
| 503 | println!(" # Find sessions mentioning a topic"); |
| 504 | println!(" ccql \"SELECT DISTINCT _session_id FROM transcripts"); |
| 505 | println!(" WHERE content LIKE '%authentication%'\"\n"); |
| 506 | |
| 507 | println!("TODO QUERIES"); |
| 508 | println!("═══════════════════════════════════════════════════════════════════════════════\n"); |
| 509 | println!(" # Pending todos"); |
| 510 | println!(" ccql \"SELECT content FROM todos WHERE status='pending'\"\n"); |
| 511 | println!(" # Todo counts by status"); |
| 512 | println!(" ccql \"SELECT status, COUNT(*) as n FROM todos GROUP BY status\"\n"); |
| 513 | println!(" # Todos by workspace"); |
| 514 | println!(" ccql \"SELECT _workspace_id, COUNT(*) as n FROM todos"); |
| 515 | println!(" GROUP BY _workspace_id ORDER BY n DESC\"\n"); |
| 516 | |
| 517 | println!("OUTPUT FORMATS"); |
| 518 | println!("═══════════════════════════════════════════════════════════════════════════════\n"); |