show-cached-data.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/usr/bin/env bash
  2. # Show the actual data that's being cached
  3. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  4. echo " WHAT'S IN THE CACHE (9,053 tokens)"
  5. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  6. echo ""
  7. echo "This is the EXACT data sent with EVERY request:"
  8. echo ""
  9. WORKSPACE="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
  10. echo "1️⃣ BASE SYSTEM PROMPT (~1,735 tokens)"
  11. echo " Location: packages/opencode/src/session/prompt/anthropic.txt"
  12. echo ""
  13. echo " Content preview:"
  14. echo " ┌────────────────────────────────────────────────"
  15. head -8 "$WORKSPACE/packages/opencode/src/session/prompt/anthropic.txt" | sed 's/^/ │ /'
  16. echo " │ ... (1,327 more words) ..."
  17. echo " └────────────────────────────────────────────────"
  18. echo ""
  19. echo " ❓ Why needed?"
  20. echo " • Tells AI it's OpenCode"
  21. echo " • Defines tone and style"
  22. echo " • Lists available tools"
  23. echo " • Sets coding standards"
  24. echo ""
  25. echo ""
  26. echo "2️⃣ PROJECT TREE (~525 tokens)"
  27. echo " Dynamically generated from your git repo"
  28. echo ""
  29. echo " Content preview:"
  30. echo " ┌────────────────────────────────────────────────"
  31. git ls-files 2>/dev/null | head -15 | sed 's/^/ │ /' || echo " │ (no git repo)"
  32. echo " │ ... (up to 200 files)"
  33. echo " └────────────────────────────────────────────────"
  34. echo ""
  35. echo " ❓ Why needed?"
  36. echo " • AI knows your project structure"
  37. echo " • Can suggest correct file paths"
  38. echo " • Understands your tech stack"
  39. echo ""
  40. echo ""
  41. echo "3️⃣ CUSTOM INSTRUCTIONS (~273 tokens)"
  42. echo " From AGENTS.md and CLAUDE.md"
  43. echo ""
  44. if [ -f "$WORKSPACE/packages/desktop/AGENTS.md" ]; then
  45. echo " AGENTS.md preview:"
  46. echo " ┌────────────────────────────────────────────────"
  47. head -10 "$WORKSPACE/packages/desktop/AGENTS.md" | sed 's/^/ │ /'
  48. echo " └────────────────────────────────────────────────"
  49. fi
  50. if [ -f "$HOME/.claude/CLAUDE.md" ]; then
  51. echo ""
  52. echo " CLAUDE.md preview:"
  53. echo " ┌────────────────────────────────────────────────"
  54. head -5 "$HOME/.claude/CLAUDE.md" | sed 's/^/ │ /'
  55. echo " └────────────────────────────────────────────────"
  56. fi
  57. echo ""
  58. echo " ❓ Why needed?"
  59. echo " • Project-specific coding standards"
  60. echo " • Custom behaviors you defined"
  61. echo ""
  62. echo ""
  63. echo "4️⃣ TOOL DEFINITIONS (~5,274 tokens)"
  64. echo " 14 tools × ~377 tokens each"
  65. echo ""
  66. echo " Example: 'read' tool definition:"
  67. echo " ┌────────────────────────────────────────────────"
  68. cat << 'TOOL'
  69. │ {
  70. │ "name": "read",
  71. │ "description": "Read files from the filesystem.
  72. │ Can read multiple files...",
  73. │ "input_schema": {
  74. │ "type": "object",
  75. │ "properties": {
  76. │ "paths": {
  77. │ "type": "array",
  78. │ "items": {"type": "string"},
  79. │ "description": "Array of file paths..."
  80. │ }
  81. │ },
  82. │ "required": ["paths"]
  83. │ }
  84. │ }
  85. TOOL
  86. echo " └────────────────────────────────────────────────"
  87. echo ""
  88. echo " Full list: read, write, edit, bash, grep, glob,"
  89. echo " ls, patch, webfetch, task, multiedit,"
  90. echo " lsp-diagnostics, lsp-hover, invalid"
  91. echo ""
  92. echo " ❓ Why needed?"
  93. echo " • AI knows what tools it can use"
  94. echo " • Understands tool parameters"
  95. echo " • Can call functions correctly"
  96. echo ""
  97. echo ""
  98. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  99. echo " THE KEY INSIGHT"
  100. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  101. echo ""
  102. echo "This data is REQUIRED for EVERY request:"
  103. echo ""
  104. echo "❌ Without it:"
  105. echo " User: \"Just say hi\""
  106. echo " API: [No context, no tools, no instructions]"
  107. echo " AI: \"Hi\" (but can't do anything else)"
  108. echo ""
  109. echo "✅ With it (cached):"
  110. echo " User: \"Just say hi\""
  111. echo " API: [9,053 tokens of context - from CACHE]"
  112. echo " AI: \"HI\" (and ready to use any tool, follow rules)"
  113. echo ""
  114. echo "Cost: Only ~905 tokens instead of 9,053! 💰"
  115. echo ""
  116. echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
  117. echo ""