qualia-framework 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/README.md +50 -0
  2. package/bin/cli.js +519 -0
  3. package/framework/agents/architecture-strategist.md +53 -0
  4. package/framework/agents/backend-agent.md +150 -0
  5. package/framework/agents/code-simplicity-reviewer.md +86 -0
  6. package/framework/agents/frontend-agent.md +111 -0
  7. package/framework/agents/kieran-typescript-reviewer.md +96 -0
  8. package/framework/agents/performance-oracle.md +111 -0
  9. package/framework/agents/qualia-codebase-mapper.md +760 -0
  10. package/framework/agents/qualia-debugger.md +1203 -0
  11. package/framework/agents/qualia-executor.md +881 -0
  12. package/framework/agents/qualia-integration-checker.md +423 -0
  13. package/framework/agents/qualia-phase-researcher.md +453 -0
  14. package/framework/agents/qualia-plan-checker.md +699 -0
  15. package/framework/agents/qualia-planner.md +1241 -0
  16. package/framework/agents/qualia-project-researcher.md +602 -0
  17. package/framework/agents/qualia-research-synthesizer.md +236 -0
  18. package/framework/agents/qualia-roadmapper.md +605 -0
  19. package/framework/agents/qualia-verifier.md +685 -0
  20. package/framework/agents/team-orchestrator.md +228 -0
  21. package/framework/agents/teams/full-stack-team.md +48 -0
  22. package/framework/agents/teams/optimize-team.md +53 -0
  23. package/framework/agents/teams/review-team.md +62 -0
  24. package/framework/agents/teams/ship-team.md +86 -0
  25. package/framework/agents/test-agent.md +182 -0
  26. package/framework/askpass.sh +2 -0
  27. package/framework/commands/design.md +53 -0
  28. package/framework/commands/quick-db.md +22 -0
  29. package/framework/config/retention.json +35 -0
  30. package/framework/core/PRINCIPLES.md +77 -0
  31. package/framework/hooks/auto-format.sh +45 -0
  32. package/framework/hooks/block-env-edit.sh +42 -0
  33. package/framework/hooks/branch-guard.sh +46 -0
  34. package/framework/hooks/confirm-delete.sh +56 -0
  35. package/framework/hooks/migration-validate.sh +68 -0
  36. package/framework/hooks/notification-speak.sh +15 -0
  37. package/framework/hooks/pre-commit.sh +80 -0
  38. package/framework/hooks/pre-compact.sh +55 -0
  39. package/framework/hooks/pre-deploy-gate.sh +151 -0
  40. package/framework/hooks/qualia-colors.sh +32 -0
  41. package/framework/hooks/retention-cleanup.sh +43 -0
  42. package/framework/hooks/save-session-state.sh +153 -0
  43. package/framework/hooks/session-context-loader.sh +28 -0
  44. package/framework/hooks/session-learn.sh +30 -0
  45. package/framework/knowledge/claudecode-bible.md +1384 -0
  46. package/framework/knowledge/client-prefs.md +22 -0
  47. package/framework/knowledge/common-fixes.md +25 -0
  48. package/framework/knowledge/deployment-map.md +35 -0
  49. package/framework/knowledge/email-signature.html +1 -0
  50. package/framework/knowledge/employees.md +8 -0
  51. package/framework/knowledge/learned-patterns.md +51 -0
  52. package/framework/knowledge/optimization-research-2026.md +137 -0
  53. package/framework/knowledge/qualia-context.md +67 -0
  54. package/framework/knowledge/supabase-patterns.md +50 -0
  55. package/framework/knowledge/voice-agent-patterns.md +46 -0
  56. package/framework/qualia-engine/VERSION +1 -0
  57. package/framework/qualia-engine/bin/qualia-tools.js +2160 -0
  58. package/framework/qualia-engine/bin/qualia-tools.test.js +1054 -0
  59. package/framework/qualia-engine/references/checkpoints.md +775 -0
  60. package/framework/qualia-engine/references/continuation-format.md +249 -0
  61. package/framework/qualia-engine/references/decimal-phase-calculation.md +65 -0
  62. package/framework/qualia-engine/references/design-quality.md +56 -0
  63. package/framework/qualia-engine/references/git-integration.md +254 -0
  64. package/framework/qualia-engine/references/git-planning-commit.md +50 -0
  65. package/framework/qualia-engine/references/model-profile-resolution.md +32 -0
  66. package/framework/qualia-engine/references/model-profiles.md +73 -0
  67. package/framework/qualia-engine/references/phase-argument-parsing.md +61 -0
  68. package/framework/qualia-engine/references/planning-config.md +195 -0
  69. package/framework/qualia-engine/references/questioning.md +141 -0
  70. package/framework/qualia-engine/references/tdd.md +263 -0
  71. package/framework/qualia-engine/references/ui-brand.md +160 -0
  72. package/framework/qualia-engine/references/verification-patterns.md +612 -0
  73. package/framework/qualia-engine/templates/DEBUG.md +159 -0
  74. package/framework/qualia-engine/templates/DESIGN.md +81 -0
  75. package/framework/qualia-engine/templates/UAT.md +247 -0
  76. package/framework/qualia-engine/templates/codebase/architecture.md +255 -0
  77. package/framework/qualia-engine/templates/codebase/concerns.md +310 -0
  78. package/framework/qualia-engine/templates/codebase/conventions.md +307 -0
  79. package/framework/qualia-engine/templates/codebase/integrations.md +280 -0
  80. package/framework/qualia-engine/templates/codebase/stack.md +186 -0
  81. package/framework/qualia-engine/templates/codebase/structure.md +285 -0
  82. package/framework/qualia-engine/templates/codebase/testing.md +480 -0
  83. package/framework/qualia-engine/templates/config.json +35 -0
  84. package/framework/qualia-engine/templates/context.md +283 -0
  85. package/framework/qualia-engine/templates/continue-here.md +78 -0
  86. package/framework/qualia-engine/templates/debug-subagent-prompt.md +91 -0
  87. package/framework/qualia-engine/templates/discovery.md +146 -0
  88. package/framework/qualia-engine/templates/milestone-archive.md +123 -0
  89. package/framework/qualia-engine/templates/milestone.md +115 -0
  90. package/framework/qualia-engine/templates/phase-prompt.md +567 -0
  91. package/framework/qualia-engine/templates/planner-subagent-prompt.md +117 -0
  92. package/framework/qualia-engine/templates/project.md +184 -0
  93. package/framework/qualia-engine/templates/projects/ai-agent.md +156 -0
  94. package/framework/qualia-engine/templates/projects/mobile-app.md +181 -0
  95. package/framework/qualia-engine/templates/projects/voice-agent.md +134 -0
  96. package/framework/qualia-engine/templates/projects/website.md +137 -0
  97. package/framework/qualia-engine/templates/requirements.md +231 -0
  98. package/framework/qualia-engine/templates/research-project/ARCHITECTURE.md +204 -0
  99. package/framework/qualia-engine/templates/research-project/FEATURES.md +147 -0
  100. package/framework/qualia-engine/templates/research-project/PITFALLS.md +200 -0
  101. package/framework/qualia-engine/templates/research-project/STACK.md +120 -0
  102. package/framework/qualia-engine/templates/research-project/SUMMARY.md +170 -0
  103. package/framework/qualia-engine/templates/research.md +552 -0
  104. package/framework/qualia-engine/templates/roadmap.md +202 -0
  105. package/framework/qualia-engine/templates/state.md +176 -0
  106. package/framework/qualia-engine/templates/summary-complex.md +59 -0
  107. package/framework/qualia-engine/templates/summary-minimal.md +41 -0
  108. package/framework/qualia-engine/templates/summary-standard.md +48 -0
  109. package/framework/qualia-engine/templates/summary.md +246 -0
  110. package/framework/qualia-engine/templates/user-setup.md +311 -0
  111. package/framework/qualia-engine/templates/verification-report.md +322 -0
  112. package/framework/qualia-engine/workflows/add-phase.md +179 -0
  113. package/framework/qualia-engine/workflows/add-todo.md +157 -0
  114. package/framework/qualia-engine/workflows/audit-milestone.md +241 -0
  115. package/framework/qualia-engine/workflows/check-todos.md +176 -0
  116. package/framework/qualia-engine/workflows/complete-milestone.md +858 -0
  117. package/framework/qualia-engine/workflows/diagnose-issues.md +219 -0
  118. package/framework/qualia-engine/workflows/discovery-phase.md +289 -0
  119. package/framework/qualia-engine/workflows/discuss-phase.md +534 -0
  120. package/framework/qualia-engine/workflows/execute-phase.md +559 -0
  121. package/framework/qualia-engine/workflows/execute-plan.md +438 -0
  122. package/framework/qualia-engine/workflows/help.md +470 -0
  123. package/framework/qualia-engine/workflows/insert-phase.md +220 -0
  124. package/framework/qualia-engine/workflows/list-phase-assumptions.md +178 -0
  125. package/framework/qualia-engine/workflows/map-codebase.md +327 -0
  126. package/framework/qualia-engine/workflows/new-milestone.md +363 -0
  127. package/framework/qualia-engine/workflows/new-project.md +1037 -0
  128. package/framework/qualia-engine/workflows/pause-work.md +122 -0
  129. package/framework/qualia-engine/workflows/plan-milestone-gaps.md +256 -0
  130. package/framework/qualia-engine/workflows/plan-phase.md +422 -0
  131. package/framework/qualia-engine/workflows/progress.md +354 -0
  132. package/framework/qualia-engine/workflows/quick.md +252 -0
  133. package/framework/qualia-engine/workflows/remove-phase.md +326 -0
  134. package/framework/qualia-engine/workflows/research-phase.md +74 -0
  135. package/framework/qualia-engine/workflows/resume-project.md +306 -0
  136. package/framework/qualia-engine/workflows/set-profile.md +80 -0
  137. package/framework/qualia-engine/workflows/settings.md +145 -0
  138. package/framework/qualia-engine/workflows/transition.md +556 -0
  139. package/framework/qualia-engine/workflows/update.md +197 -0
  140. package/framework/qualia-engine/workflows/verify-phase.md +195 -0
  141. package/framework/qualia-engine/workflows/verify-work.md +625 -0
  142. package/framework/rules/context7.md +11 -0
  143. package/framework/rules/deployment.md +29 -0
  144. package/framework/rules/frontend.md +33 -0
  145. package/framework/rules/security.md +12 -0
  146. package/framework/rules/speed.md +20 -0
  147. package/framework/scripts/__pycache__/say.cpython-314.pyc +0 -0
  148. package/framework/scripts/apply-retention.sh +120 -0
  149. package/framework/scripts/bootstrap-pop-os.sh +354 -0
  150. package/framework/scripts/claude-voice +13 -0
  151. package/framework/scripts/cleanup.sh +131 -0
  152. package/framework/scripts/cowork-mode.sh +141 -0
  153. package/framework/scripts/generate-project-claude-md.sh +153 -0
  154. package/framework/scripts/load-test-webhook.js +172 -0
  155. package/framework/scripts/say.py +236 -0
  156. package/framework/scripts/showcase-video-recorder/ffmpeg-builder.js +167 -0
  157. package/framework/scripts/showcase-video-recorder/playwright-helpers.js +216 -0
  158. package/framework/scripts/speak.py +55 -0
  159. package/framework/scripts/speak.sh +18 -0
  160. package/framework/scripts/status.sh +138 -0
  161. package/framework/scripts/sync-to-framework.sh +65 -0
  162. package/framework/scripts/voice-hotkey.py +227 -0
  163. package/framework/scripts/voice-input.sh +51 -0
  164. package/framework/skills/animate/SKILL.md +202 -0
  165. package/framework/skills/bolder/SKILL.md +144 -0
  166. package/framework/skills/browser-qa/SKILL.md +536 -0
  167. package/framework/skills/clarify/SKILL.md +179 -0
  168. package/framework/skills/colorize/SKILL.md +170 -0
  169. package/framework/skills/critique/SKILL.md +126 -0
  170. package/framework/skills/deep-research/SKILL.md +271 -0
  171. package/framework/skills/delight/SKILL.md +329 -0
  172. package/framework/skills/deploy/SKILL.md +261 -0
  173. package/framework/skills/deploy-verify/SKILL.md +377 -0
  174. package/framework/skills/deploy-verify/scripts/canary-check.sh +206 -0
  175. package/framework/skills/deploy-verify/scripts/check-console-errors.js +147 -0
  176. package/framework/skills/deploy-verify/scripts/check-cwv.js +139 -0
  177. package/framework/skills/deploy-verify/scripts/project-detect.sh +84 -0
  178. package/framework/skills/deploy-verify/scripts/verify.sh +548 -0
  179. package/framework/skills/design-quieter/SKILL.md +130 -0
  180. package/framework/skills/distill/SKILL.md +149 -0
  181. package/framework/skills/docs-lookup/SKILL.md +78 -0
  182. package/framework/skills/fcm-notifications/SKILL.md +125 -0
  183. package/framework/skills/financial-ledger/SKILL.md +1039 -0
  184. package/framework/skills/frontend-master/NOTICE.md +4 -0
  185. package/framework/skills/frontend-master/SKILL.md +127 -0
  186. package/framework/skills/frontend-master/reference/color-and-contrast.md +132 -0
  187. package/framework/skills/frontend-master/reference/interaction-design.md +123 -0
  188. package/framework/skills/frontend-master/reference/motion-design.md +99 -0
  189. package/framework/skills/frontend-master/reference/responsive-design.md +114 -0
  190. package/framework/skills/frontend-master/reference/spatial-design.md +100 -0
  191. package/framework/skills/frontend-master/reference/typography.md +131 -0
  192. package/framework/skills/frontend-master/reference/ux-writing.md +107 -0
  193. package/framework/skills/harden/SKILL.md +357 -0
  194. package/framework/skills/i18n-rtl/SKILL.md +752 -0
  195. package/framework/skills/learn/SKILL.md +71 -0
  196. package/framework/skills/memory/SKILL.md +50 -0
  197. package/framework/skills/mobile-expo/SKILL.md +864 -0
  198. package/framework/skills/mobile-expo/references/store-checklist.md +550 -0
  199. package/framework/skills/nestjs-backend/README.md +73 -0
  200. package/framework/skills/nestjs-backend/SKILL.md +446 -0
  201. package/framework/skills/nestjs-backend/references/templates.md +1173 -0
  202. package/framework/skills/normalize/SKILL.md +79 -0
  203. package/framework/skills/onboard/SKILL.md +242 -0
  204. package/framework/skills/polish/SKILL.md +209 -0
  205. package/framework/skills/pr/SKILL.md +66 -0
  206. package/framework/skills/qualia/SKILL.md +153 -0
  207. package/framework/skills/qualia-add-todo/SKILL.md +68 -0
  208. package/framework/skills/qualia-audit-milestone/SKILL.md +92 -0
  209. package/framework/skills/qualia-check-todos/SKILL.md +55 -0
  210. package/framework/skills/qualia-complete-milestone/SKILL.md +108 -0
  211. package/framework/skills/qualia-debug/SKILL.md +149 -0
  212. package/framework/skills/qualia-design/SKILL.md +203 -0
  213. package/framework/skills/qualia-discuss-phase/SKILL.md +72 -0
  214. package/framework/skills/qualia-execute-phase/SKILL.md +86 -0
  215. package/framework/skills/qualia-help/SKILL.md +67 -0
  216. package/framework/skills/qualia-idk/SKILL.md +352 -0
  217. package/framework/skills/qualia-list-phase-assumptions/SKILL.md +67 -0
  218. package/framework/skills/qualia-new-milestone/SKILL.md +72 -0
  219. package/framework/skills/qualia-new-project/SKILL.md +92 -0
  220. package/framework/skills/qualia-optimize/SKILL.md +417 -0
  221. package/framework/skills/qualia-pause-work/SKILL.md +96 -0
  222. package/framework/skills/qualia-plan-milestone-gaps/SKILL.md +57 -0
  223. package/framework/skills/qualia-plan-phase/SKILL.md +101 -0
  224. package/framework/skills/qualia-progress/SKILL.md +53 -0
  225. package/framework/skills/qualia-quick/SKILL.md +89 -0
  226. package/framework/skills/qualia-research-phase/SKILL.md +88 -0
  227. package/framework/skills/qualia-resume-work/SKILL.md +62 -0
  228. package/framework/skills/qualia-review/SKILL.md +263 -0
  229. package/framework/skills/qualia-start/SKILL.md +182 -0
  230. package/framework/skills/qualia-verify-work/SKILL.md +105 -0
  231. package/framework/skills/qualia-workflow/SKILL.md +130 -0
  232. package/framework/skills/rag/SKILL.md +750 -0
  233. package/framework/skills/responsive/SKILL.md +231 -0
  234. package/framework/skills/retro/SKILL.md +284 -0
  235. package/framework/skills/sakani-conventions/SKILL.md +136 -0
  236. package/framework/skills/sakani-conventions/evals/evals.json +23 -0
  237. package/framework/skills/sakani-conventions/references/entities.md +365 -0
  238. package/framework/skills/sakani-conventions/references/error-codes.md +95 -0
  239. package/framework/skills/seo-master/SKILL.md +490 -0
  240. package/framework/skills/seo-master/references/checklist.md +199 -0
  241. package/framework/skills/seo-master/references/structured-data.md +609 -0
  242. package/framework/skills/ship/SKILL.md +202 -0
  243. package/framework/skills/stack-researcher/SKILL.md +215 -0
  244. package/framework/skills/status/SKILL.md +154 -0
  245. package/framework/skills/status/scripts/health-check.sh +562 -0
  246. package/framework/skills/subscription-payments/SKILL.md +250 -0
  247. package/framework/skills/supabase/SKILL.md +973 -0
  248. package/framework/skills/supabase/references/templates.md +159 -0
  249. package/framework/skills/team/SKILL.md +67 -0
  250. package/framework/skills/test-runner/SKILL.md +202 -0
  251. package/framework/skills/voice-agent/SKILL.md +407 -0
  252. package/framework/skills/zoho-workflow/SKILL.md +51 -0
  253. package/framework/statusline-command.sh +117 -0
  254. package/package.json +24 -0
  255. package/profiles/fawzi.json +16 -0
  256. package/profiles/hasan.json +16 -0
  257. package/profiles/moayad.json +16 -0
  258. package/templates/CLAUDE-owner.md +52 -0
  259. package/templates/CLAUDE.md.hbs +58 -0
  260. package/templates/env.claude.template +12 -0
  261. package/templates/settings.json +141 -0
@@ -0,0 +1,20 @@
1
+ # Speed Rules (MANDATORY)
2
+
3
+ **NEVER use Task(Explore) or Task(general-purpose) for simple file lookups or code searches.** Use direct tools instead:
4
+ - **Glob** for finding files by name/pattern
5
+ - **Grep** for searching code content
6
+ - **Read** for reading specific files
7
+ - Only use Task(Explore) when you genuinely need 5+ rounds of deep codebase archaeology
8
+
9
+ **NEVER spawn subagents when direct tools work.** Subagents are slow — a direct Glob or Grep returns in seconds.
10
+
11
+ **Bias toward action, not exploration.** If Fawzi asks you to fix something and you know the project structure, just do it.
12
+
13
+ **Use shortcuts:**
14
+ - `/ship` — Full deploy pipeline (quality gates → commit → deploy → verify)
15
+ - `/status` — Quick project health check
16
+ - `/audit` — Deep security + quality audit
17
+ - `/switch <project>` — Switch project context
18
+ - `/memory` — View/manage persistent rules
19
+ - `/learn` — Save a lesson from a mistake
20
+ - `/handoff` — Save context before /clear
@@ -0,0 +1,120 @@
1
+ #!/bin/bash
2
+ # Apply retention policies based on retention.json
3
+ #
4
+ # Usage: ./apply-retention.sh [--dry-run]
5
+ #
6
+ # Cross-platform: uses node instead of jq for JSON parsing
7
+
8
+ set -e
9
+
10
+ CLAUDE_DIR="$HOME/.claude"
11
+ CONFIG="$CLAUDE_DIR/config/retention.json"
12
+ ARCHIVE_DIR="$CLAUDE_DIR/archive"
13
+ DRY_RUN=false
14
+
15
+ if [[ "$1" == "--dry-run" ]]; then
16
+ DRY_RUN=true
17
+ echo "DRY RUN MODE - No changes will be made"
18
+ fi
19
+
20
+ log() {
21
+ echo "[$(date '+%H:%M:%S')] $1"
22
+ }
23
+
24
+ # Helper: read JSON config value using node (replaces jq)
25
+ json_cfg() {
26
+ local field="$1"
27
+ node -e "try{const d=JSON.parse(require('fs').readFileSync('$CONFIG','utf8'));const v=$field;process.stdout.write(String(v))}catch(e){process.stderr.write(e.message);process.exit(1)}" 2>/dev/null
28
+ }
29
+
30
+ # Check if node is available (needed for JSON parsing)
31
+ if ! command -v node &> /dev/null; then
32
+ echo "Error: node is required for JSON parsing. Install Node.js from https://nodejs.org"
33
+ exit 1
34
+ fi
35
+
36
+ # Check if config exists
37
+ if [[ ! -f "$CONFIG" ]]; then
38
+ echo "Error: Config file not found: $CONFIG"
39
+ exit 1
40
+ fi
41
+
42
+ # Parse retention values using node instead of jq
43
+ FILE_HISTORY_DAYS=$(json_cfg "d.policies['file-history'].max_age_days")
44
+ DEBUG_DAYS=$(json_cfg "d.policies['debug-logs'].max_age_days")
45
+ SNAPSHOT_DAYS=$(json_cfg "d.policies['shell-snapshots'].max_age_days")
46
+ TODO_DAYS=$(json_cfg "d.policies.todos.archive_after_days")
47
+ PROJECT_DAYS=$(json_cfg "d.policies.projects.archive_after_days")
48
+ SESSION_DAYS=$(json_cfg "d.policies['session-env'].max_age_days")
49
+
50
+ log "=== Applying Retention Policies ==="
51
+ log "Config: $CONFIG"
52
+
53
+ # Create archive directories
54
+ mkdir -p "$ARCHIVE_DIR/todos" "$ARCHIVE_DIR/projects" "$ARCHIVE_DIR/debug"
55
+
56
+ # 1. File-history retention
57
+ log "Cleaning file-history (>$FILE_HISTORY_DAYS days)..."
58
+ count=$(find "$CLAUDE_DIR/file-history" -type f -mtime +"$FILE_HISTORY_DAYS" 2>/dev/null | wc -l)
59
+ log " Found $count files to remove"
60
+ if [[ "$DRY_RUN" == false ]]; then
61
+ find "$CLAUDE_DIR/file-history" -type f -mtime +"$FILE_HISTORY_DAYS" -delete 2>/dev/null || true
62
+ fi
63
+
64
+ # 2. Debug log retention
65
+ log "Cleaning debug logs (>$DEBUG_DAYS days)..."
66
+ count=$(find "$CLAUDE_DIR/debug" -type f -mtime +"$DEBUG_DAYS" 2>/dev/null | wc -l)
67
+ log " Found $count files to archive/remove"
68
+ if [[ "$DRY_RUN" == false ]]; then
69
+ # Move old debug logs to archive
70
+ find "$CLAUDE_DIR/debug" -type f -mtime +"$DEBUG_DAYS" -exec mv {} "$ARCHIVE_DIR/debug/" \; 2>/dev/null || true
71
+ fi
72
+
73
+ # 3. Shell snapshots retention
74
+ log "Cleaning shell snapshots (>$SNAPSHOT_DAYS days)..."
75
+ count=$(find "$CLAUDE_DIR/shell-snapshots" -type f -mtime +"$SNAPSHOT_DAYS" 2>/dev/null | wc -l)
76
+ log " Found $count files to remove"
77
+ if [[ "$DRY_RUN" == false ]]; then
78
+ find "$CLAUDE_DIR/shell-snapshots" -type f -mtime +"$SNAPSHOT_DAYS" -delete 2>/dev/null || true
79
+ fi
80
+
81
+ # 4. Todos archival
82
+ log "Archiving old todos (>$TODO_DAYS days)..."
83
+ count=$(find "$CLAUDE_DIR/todos" -name "*.json" -mtime +"$TODO_DAYS" 2>/dev/null | wc -l)
84
+ log " Found $count files to archive"
85
+ if [[ "$DRY_RUN" == false ]]; then
86
+ find "$CLAUDE_DIR/todos" -name "*.json" -mtime +"$TODO_DAYS" -exec mv {} "$ARCHIVE_DIR/todos/" \; 2>/dev/null || true
87
+ fi
88
+
89
+ # 5. Projects compression
90
+ log "Compressing old project sessions (>$PROJECT_DAYS days)..."
91
+ count=$(find "$CLAUDE_DIR/projects" -name "*.jsonl" -mtime +"$PROJECT_DAYS" 2>/dev/null | wc -l)
92
+ log " Found $count files to compress"
93
+ if [[ "$DRY_RUN" == false ]]; then
94
+ find "$CLAUDE_DIR/projects" -name "*.jsonl" -mtime +"$PROJECT_DAYS" -exec gzip {} \; 2>/dev/null || true
95
+ fi
96
+
97
+ # 6. Session-env cleanup (empty directories)
98
+ log "Cleaning empty session-env directories..."
99
+ count=$(find "$CLAUDE_DIR/session-env" -type d -empty 2>/dev/null | wc -l)
100
+ log " Found $count empty directories"
101
+ if [[ "$DRY_RUN" == false ]]; then
102
+ find "$CLAUDE_DIR/session-env" -type d -empty -delete 2>/dev/null || true
103
+ fi
104
+
105
+ # 7. Old session-env files
106
+ log "Cleaning old session-env files (>$SESSION_DAYS days)..."
107
+ count=$(find "$CLAUDE_DIR/session-env" -type f -mtime +"$SESSION_DAYS" 2>/dev/null | wc -l)
108
+ log " Found $count files to remove"
109
+ if [[ "$DRY_RUN" == false ]]; then
110
+ find "$CLAUDE_DIR/session-env" -type f -mtime +"$SESSION_DAYS" -delete 2>/dev/null || true
111
+ fi
112
+
113
+ log "=== Retention Policies Applied ==="
114
+
115
+ # Show current sizes
116
+ log ""
117
+ log "Current .claude directory sizes:"
118
+ du -sh "$CLAUDE_DIR/projects" "$CLAUDE_DIR/file-history" "$CLAUDE_DIR/debug" "$CLAUDE_DIR/shell-snapshots" "$CLAUDE_DIR/todos" 2>/dev/null | while read line; do
119
+ log " $line"
120
+ done
@@ -0,0 +1,354 @@
1
+ #!/usr/bin/env bash
2
+ # ============================================================
3
+ # Qualia Solutions — Full Pop!_OS Bootstrap
4
+ # Run once on a fresh Pop!_OS install to get the full dev env
5
+ # ============================================================
6
+
7
+ set -euo pipefail
8
+
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ REPO_DIR="$(dirname "$SCRIPT_DIR")"
11
+ CLAUDE_DIR="$HOME/.claude"
12
+
13
+ echo ""
14
+ echo "=================================================="
15
+ echo " Qualia Solutions - Pop!_OS Full Bootstrap "
16
+ echo "=================================================="
17
+ echo ""
18
+
19
+ # ---- System packages ----
20
+ echo "[1/14] Installing system packages..."
21
+ sudo apt update
22
+ sudo apt install -y \
23
+ git gh build-essential curl wget jq htop neovim vim tree pv \
24
+ inotify-tools software-properties-common apt-transport-https \
25
+ ca-certificates gnupg lsb-release unzip zip tar \
26
+ python3 python3-pip python3-venv pipx \
27
+ docker.io docker-compose \
28
+ openssh-client openssh-server ufw bluez bluez-tools \
29
+ network-manager rsync smartmontools hwinfo inxi \
30
+ ffmpeg gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \
31
+ gstreamer1.0-libav pavucontrol \
32
+ fonts-jetbrains-mono fonts-firacode fonts-noto fonts-noto-color-emoji \
33
+ fonts-font-awesome fonts-dejavu fonts-liberation \
34
+ gnome-tweaks gnome-shell-extensions
35
+ echo " OK system packages"
36
+ echo ""
37
+
38
+ # ---- Node.js ----
39
+ echo "[2/14] Installing Node.js 22 LTS..."
40
+ if ! command -v node &>/dev/null || [[ "$(node --version)" != v22* ]]; then
41
+ curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
42
+ sudo apt install -y nodejs
43
+ fi
44
+ echo " OK node $(node --version)"
45
+ echo ""
46
+
47
+ # ---- Google Chrome ----
48
+ echo "[3/14] Installing Google Chrome..."
49
+ if ! command -v google-chrome-stable &>/dev/null; then
50
+ wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg 2>/dev/null || true
51
+ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null
52
+ sudo apt update && sudo apt install -y google-chrome-stable
53
+ fi
54
+ echo " OK chrome"
55
+ echo ""
56
+
57
+ # ---- VS Code ----
58
+ echo "[4/14] Installing VS Code..."
59
+ if ! command -v code &>/dev/null; then
60
+ wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/ms.gpg
61
+ sudo install -D -o root -g root -m 644 /tmp/ms.gpg /etc/apt/keyrings/packages.microsoft.gpg
62
+ echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null
63
+ sudo apt update && sudo apt install -y code
64
+ rm -f /tmp/ms.gpg
65
+ fi
66
+ echo " OK vscode"
67
+ echo ""
68
+
69
+ # ---- Cursor ----
70
+ echo "[5/14] Installing Cursor..."
71
+ if [ ! -f /opt/cursor/cursor.appimage ]; then
72
+ echo " Downloading Cursor AppImage..."
73
+ wget -q -O /tmp/cursor.appimage "https://downloader.cursor.sh/linux/appImage/x64"
74
+ chmod +x /tmp/cursor.appimage
75
+ sudo mkdir -p /opt/cursor
76
+ sudo mv /tmp/cursor.appimage /opt/cursor/cursor.appimage
77
+ mkdir -p ~/.local/share/applications
78
+ cat > ~/.local/share/applications/cursor.desktop << 'EOF'
79
+ [Desktop Entry]
80
+ Name=Cursor
81
+ Exec=/opt/cursor/cursor.appimage --no-sandbox %F
82
+ Terminal=false
83
+ Type=Application
84
+ Icon=cursor
85
+ Categories=Development;IDE;
86
+ MimeType=text/plain;
87
+ EOF
88
+ fi
89
+ echo " OK cursor"
90
+ echo ""
91
+
92
+ # ---- Claude Desktop ----
93
+ echo "[6/14] Installing Claude Desktop..."
94
+ if ! command -v claude-desktop &>/dev/null && ! dpkg -l | grep -q claude-desktop; then
95
+ echo " Downloading Claude Desktop .deb..."
96
+ wget -q -O /tmp/claude-desktop.deb "https://storage.googleapis.com/anthropic-downloads/claude-desktop/claude-desktop-debian.deb" || {
97
+ echo " WARN: Could not download Claude Desktop. Install manually from https://claude.ai/download"
98
+ }
99
+ if [ -f /tmp/claude-desktop.deb ]; then
100
+ sudo dpkg -i /tmp/claude-desktop.deb || sudo apt install -f -y
101
+ rm -f /tmp/claude-desktop.deb
102
+ fi
103
+ fi
104
+ mkdir -p ~/.config/Claude
105
+ cat > ~/.config/Claude/claude_desktop_config.json << 'EOF'
106
+ {
107
+ "preferences": {
108
+ "localAgentModeTrustedFolders": [
109
+ "/home/qualia/Desktop",
110
+ "/home/qualia"
111
+ ],
112
+ "coworkScheduledTasksEnabled": true,
113
+ "sidebarMode": "task",
114
+ "coworkWebSearchEnabled": true
115
+ }
116
+ }
117
+ EOF
118
+ echo " OK claude desktop"
119
+ echo ""
120
+
121
+ # ---- Flatpak apps ----
122
+ echo "[7/14] Installing Flatpak apps..."
123
+ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
124
+ flatpak install -y flathub com.discordapp.Discord 2>/dev/null || true
125
+ flatpak install -y flathub com.anydesk.Anydesk 2>/dev/null || true
126
+ flatpak install -y flathub com.mitchellh.ghostty 2>/dev/null || echo " WARN: Ghostty not available via Flatpak — install manually"
127
+ echo " OK flatpak apps"
128
+ echo ""
129
+
130
+ # ---- npm globals ----
131
+ echo "[8/14] Installing npm global packages..."
132
+ mkdir -p ~/.npm-global
133
+ npm config set prefix "$HOME/.npm-global"
134
+ export PATH="$HOME/.npm-global/bin:$PATH"
135
+ npm i -g pnpm typescript typescript-language-server vercel @railway/cli \
136
+ eas-cli expo-cli stripe md-to-pdf firecrawl-cli @openai/codex supabase \
137
+ @anthropic-ai/claude-code
138
+ echo " OK npm globals"
139
+ echo ""
140
+
141
+ # ---- pipx ----
142
+ echo "[9/14] Installing pipx packages..."
143
+ pipx install poetry 2>/dev/null || true
144
+ pipx install modal 2>/dev/null || true
145
+ echo " OK pipx"
146
+ echo ""
147
+
148
+ # ---- Git config ----
149
+ echo "[10/14] Configuring git..."
150
+ git config --global user.name "qualiasolutions"
151
+ git config --global user.email "info@qualiasolutions.net"
152
+ git config --global core.editor "cursor --wait"
153
+ git config --global init.defaultBranch main
154
+ git config --global pull.rebase true
155
+ git config --global fetch.prune true
156
+ git config --global diff.colorMoved zebra
157
+ git config --global merge.conflictstyle diff3
158
+ git config --global alias.co checkout
159
+ git config --global alias.br branch
160
+ git config --global alias.ci commit
161
+ git config --global alias.st status
162
+ git config --global alias.unstage "reset HEAD --"
163
+ git config --global alias.last "log -1 HEAD"
164
+ git config --global alias.amend "commit --amend --no-edit"
165
+ git config --global alias.lg "log --oneline --graph --decorate -20"
166
+ git config --global alias.aa "add --all"
167
+ git config --global alias.cm "commit -m"
168
+ cat > ~/.gitignore_global << 'EOF'
169
+ .DS_Store
170
+ .env
171
+ .env.*
172
+ !.env.example
173
+ !.env.sample
174
+ .idea/
175
+ .vscode/
176
+ *.swp
177
+ *.swo
178
+ *~
179
+ node_modules/
180
+ EOF
181
+ git config --global core.excludesFile ~/.gitignore_global
182
+ echo " OK git config"
183
+ echo ""
184
+
185
+ # ---- Ghostty config ----
186
+ echo "[11/14] Configuring Ghostty terminal..."
187
+ mkdir -p ~/.config/ghostty/themes
188
+
189
+ cat > ~/.config/ghostty/themes/Qualia << 'EOF'
190
+ palette = 0=#151d2d
191
+ palette = 1=#d94343
192
+ palette = 2=#2ecc71
193
+ palette = 3=#eab308
194
+ palette = 4=#3498db
195
+ palette = 5=#8B5CF6
196
+ palette = 6=#00D9B3
197
+ palette = 7=#b5bfe2
198
+ palette = 8=#6b7582
199
+ palette = 9=#EC4899
200
+ palette = 10=#10B981
201
+ palette = 11=#f39c12
202
+ palette = 12=#7b9ef0
203
+ palette = 13=#f4b8e4
204
+ palette = 14=#00FFD1
205
+ palette = 15=#fafbfe
206
+ background = #0a0a14
207
+ foreground = #e6ecf7
208
+ cursor-color = #00FFD1
209
+ cursor-text = #0a0a14
210
+ selection-background = #1a2231
211
+ selection-foreground = #fafbfe
212
+ EOF
213
+
214
+ cat > ~/.config/ghostty/config << 'EOF'
215
+ theme = Qualia
216
+ font-family = JetBrains Mono
217
+ font-size = 14
218
+ font-thicken = true
219
+ adjust-cell-height = 4
220
+ window-padding-x = 12
221
+ window-padding-y = 8
222
+ window-decoration = auto
223
+ window-title-font-family = JetBrains Mono
224
+ confirm-close-surface = false
225
+ window-save-state = always
226
+ window-inherit-working-directory = true
227
+ window-inherit-font-size = true
228
+ cursor-style = bar
229
+ cursor-style-blink = false
230
+ mouse-hide-while-typing = true
231
+ copy-on-select = clipboard
232
+ link-url = true
233
+ scrollback-limit = 100000
234
+ clipboard-paste-protection = false
235
+ clipboard-trim-trailing-spaces = true
236
+ shell-integration = detect
237
+ shell-integration-features = cursor,sudo,title
238
+ keybind = ctrl+shift+d=new_split:right
239
+ keybind = ctrl+shift+e=new_split:down
240
+ keybind = ctrl+shift+h=goto_split:left
241
+ keybind = ctrl+shift+l=goto_split:right
242
+ keybind = ctrl+shift+j=goto_split:bottom
243
+ keybind = ctrl+shift+k=goto_split:top
244
+ keybind = ctrl+shift+w=close_surface
245
+ keybind = ctrl+shift+t=new_tab
246
+ keybind = ctrl+shift+n=new_window
247
+ keybind = ctrl+1=goto_tab:1
248
+ keybind = ctrl+2=goto_tab:2
249
+ keybind = ctrl+3=goto_tab:3
250
+ keybind = ctrl+4=goto_tab:4
251
+ keybind = ctrl+5=goto_tab:5
252
+ keybind = ctrl+equal=increase_font_size:1
253
+ keybind = ctrl+minus=decrease_font_size:1
254
+ keybind = ctrl+0=reset_font_size
255
+ keybind = ctrl+shift+left=resize_split:left,20
256
+ keybind = ctrl+shift+right=resize_split:right,20
257
+ keybind = ctrl+shift+up=resize_split:up,20
258
+ keybind = ctrl+shift+down=resize_split:down,20
259
+ gtk-single-instance = true
260
+ bold-is-bright = true
261
+ EOF
262
+ echo " OK ghostty config"
263
+ echo ""
264
+
265
+ # ---- Bash config ----
266
+ echo "[12/14] Updating .bashrc..."
267
+ if ! grep -q "Qualia Dev Environment" ~/.bashrc 2>/dev/null; then
268
+ cat >> ~/.bashrc << 'BASHEOF'
269
+
270
+ # === Qualia Dev Environment ===
271
+
272
+ # PATH additions
273
+ export PATH="$HOME/.local/bin:$PATH"
274
+ export PATH="$HOME/.npm-global/bin:$PATH"
275
+
276
+ # pnpm
277
+ export PNPM_HOME="$HOME/.local/share/pnpm"
278
+ case ":$PATH:" in
279
+ *":$PNPM_HOME:"*) ;;
280
+ *) export PATH="$PNPM_HOME:$PATH" ;;
281
+ esac
282
+
283
+ # ElevenLabs TTS (fill in your key)
284
+ export ELEVEN_API_KEY="YOUR_ELEVEN_API_KEY_HERE"
285
+
286
+ # Cowork mode toggle
287
+ alias cowork="~/.claude/scripts/cowork-mode.sh"
288
+ BASHEOF
289
+ fi
290
+ echo " OK bashrc"
291
+ echo ""
292
+
293
+ # ---- Claude Code config sync ----
294
+ echo "[13/14] Syncing Claude Code config..."
295
+ bash "$REPO_DIR/team-sync/setup.sh"
296
+ echo ""
297
+
298
+ # ---- Python venv for TTS ----
299
+ echo "[14/14] Setting up Claude TTS venv..."
300
+ if [ ! -d "$CLAUDE_DIR/venv" ]; then
301
+ python3 -m venv "$CLAUDE_DIR/venv"
302
+ fi
303
+ "$CLAUDE_DIR/venv/bin/pip" install -q elevenlabs requests httpx pydantic websockets
304
+ echo " OK tts venv"
305
+ echo ""
306
+
307
+ # ---- Docker group ----
308
+ sudo usermod -aG docker "$USER" 2>/dev/null || true
309
+
310
+ # ---- Firewall ----
311
+ echo "Enabling firewall..."
312
+ sudo ufw --force enable
313
+ sudo ufw default deny incoming
314
+ sudo ufw default allow outgoing
315
+ sudo ufw allow ssh
316
+ echo " OK firewall"
317
+ echo ""
318
+
319
+ # ---- NVIDIA check ----
320
+ echo "Checking NVIDIA..."
321
+ if command -v nvidia-smi &>/dev/null; then
322
+ nvidia-smi --query-gpu=name,driver_version --format=csv,noheader
323
+ echo " OK nvidia"
324
+ else
325
+ echo " WARN: nvidia-smi not found. Install drivers: sudo apt install system76-driver-nvidia"
326
+ fi
327
+ echo ""
328
+
329
+ # ---- Done ----
330
+ echo "=================================================="
331
+ echo " Bootstrap complete! "
332
+ echo "=================================================="
333
+ echo ""
334
+ echo "NEXT STEPS:"
335
+ echo ""
336
+ echo " 1. Fill in API keys:"
337
+ echo " nano ~/.claude/settings.json"
338
+ echo " (replace all YOUR_*_HERE placeholders)"
339
+ echo ""
340
+ echo " 2. Fill in ElevenLabs key:"
341
+ echo " nano ~/.bashrc"
342
+ echo " (replace YOUR_ELEVEN_API_KEY_HERE)"
343
+ echo ""
344
+ echo " 3. Authenticate GitHub:"
345
+ echo " gh auth login"
346
+ echo ""
347
+ echo " 4. Authenticate Vercel:"
348
+ echo " vercel login"
349
+ echo ""
350
+ echo " 5. Log out and back in (for Docker group)"
351
+ echo ""
352
+ echo " 6. Verify everything:"
353
+ echo " claude --version && gh auth status && vercel whoami && nvidia-smi"
354
+ echo ""
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ # Voice Claude - DISABLED auto-speak, use manual speak only
3
+ # Run: echo "text" | ~/.claude/scripts/speak.py
4
+ # Requires ELEVEN_API_KEY in shell profile (~/.zshrc)
5
+
6
+ if [ -z "$ELEVEN_API_KEY" ]; then
7
+ echo "Warning: ELEVEN_API_KEY not set. Voice output will be disabled." >&2
8
+ echo "Add to ~/.zshrc: export ELEVEN_API_KEY=\"your-key\"" >&2
9
+ fi
10
+
11
+ # Just run claude normally - no voice capture
12
+ # To speak something manually: echo "hello" | ~/.claude/scripts/speak.py
13
+ exec claude "$@"
@@ -0,0 +1,131 @@
1
+ #!/bin/bash
2
+ # ~/.claude cleanup script
3
+ # Run periodically to keep the directory lean
4
+ # Schedule: 0 3 * * 0 ~/.claude/scripts/cleanup.sh >> ~/.claude/cleanup.log 2>&1
5
+ # Cross-platform: portable file cleanup (no xargs), cross-platform stat
6
+
7
+ set -e
8
+ CLAUDE_DIR="$HOME/.claude"
9
+ cd "$CLAUDE_DIR" || exit 1
10
+
11
+ echo "=== Claude Config Cleanup $(date) ==="
12
+ echo ""
13
+
14
+ # 0. Remove orphaned worktree project entries
15
+ echo "Cleaning orphaned worktree entries..."
16
+ count=$(ls -d projects/-var-tmp-* 2>/dev/null | wc -l || echo 0)
17
+ rm -rf projects/-var-tmp-* 2>/dev/null || true
18
+ echo " Removed: $count orphaned worktree directories"
19
+
20
+ # 0.1 Remove stale security warning files
21
+ echo "Cleaning orphaned security warning files..."
22
+ count=$(ls security_warnings_state_*.json 2>/dev/null | wc -l || echo 0)
23
+ rm -f security_warnings_state_*.json 2>/dev/null || true
24
+ echo " Removed: $count security warning files"
25
+
26
+ # 0.2 Clean plugin cache older than 7 days
27
+ echo "Cleaning plugin cache older than 7 days..."
28
+ count=$(find plugins/cache -mindepth 2 -maxdepth 2 -type d -mtime +7 2>/dev/null | wc -l || echo 0)
29
+ find plugins/cache -mindepth 2 -maxdepth 2 -type d -mtime +7 -exec rm -rf {} + 2>/dev/null || true
30
+ echo " Removed: $count cached plugin versions"
31
+
32
+ # Keep last N shell snapshots (reduced from 20) — portable, no xargs
33
+ KEEP_SNAPSHOTS=10
34
+ echo "Cleaning shell snapshots (keeping last $KEEP_SNAPSHOTS)..."
35
+ count=$(ls -t shell-snapshots/*.sh 2>/dev/null | tail -n +$((KEEP_SNAPSHOTS + 1)) | wc -l)
36
+ ls -t shell-snapshots/*.sh 2>/dev/null | tail -n +$((KEEP_SNAPSHOTS + 1)) | while IFS= read -r f; do
37
+ rm -f "$f"
38
+ done
39
+ echo " Removed: $count files"
40
+
41
+ # Keep last N debug logs (reduced from 30) — portable, no xargs
42
+ KEEP_DEBUG=15
43
+ echo "Cleaning debug logs (keeping last $KEEP_DEBUG)..."
44
+ count=$(ls -t debug/*.txt 2>/dev/null | tail -n +$((KEEP_DEBUG + 1)) | wc -l)
45
+ ls -t debug/*.txt 2>/dev/null | tail -n +$((KEEP_DEBUG + 1)) | while IFS= read -r f; do
46
+ rm -f "$f"
47
+ done
48
+ echo " Removed: $count files"
49
+
50
+ # Clean old file-history sessions (older than 14 days)
51
+ echo "Cleaning file-history older than 14 days..."
52
+ count=$(find file-history/ -mindepth 1 -maxdepth 1 -type d -mtime +14 2>/dev/null | wc -l)
53
+ find file-history/ -mindepth 1 -maxdepth 1 -type d -mtime +14 -exec rm -rf {} \; 2>/dev/null
54
+ echo " Removed: $count sessions"
55
+
56
+ # Clean old project sessions (older than 14 days for jsonl, 30 days for dirs)
57
+ echo "Cleaning project session logs older than 14 days..."
58
+ count=$(find projects/ -name "*.jsonl" -mtime +14 2>/dev/null | wc -l)
59
+ find projects/ -name "*.jsonl" -mtime +14 -delete 2>/dev/null
60
+ echo " Removed: $count session logs"
61
+
62
+ echo "Cleaning project UUID directories older than 14 days..."
63
+ count=$(find projects/ -mindepth 2 -maxdepth 2 -type d -mtime +14 2>/dev/null | wc -l)
64
+ find projects/ -mindepth 2 -maxdepth 2 -type d -mtime +14 -exec rm -rf {} \; 2>/dev/null
65
+ echo " Removed: $count project session directories"
66
+
67
+ # Clean empty todo files (2 bytes = [])
68
+ echo "Cleaning empty todo files..."
69
+ count=$(find todos/ -name "*.json" -size 2c 2>/dev/null | wc -l)
70
+ find todos/ -name "*.json" -size 2c -delete 2>/dev/null
71
+ echo " Removed: $count empty files"
72
+
73
+ # Clean old todos (older than 7 days)
74
+ echo "Cleaning old todo files..."
75
+ count=$(find todos/ -name "*.json" -mtime +7 2>/dev/null | wc -l)
76
+ find todos/ -name "*.json" -mtime +7 -delete 2>/dev/null
77
+ echo " Removed: $count old files"
78
+
79
+ # Clean old session-env files (older than 14 days)
80
+ echo "Cleaning session-env older than 14 days..."
81
+ count=$(find session-env/ -name "*.json" -mtime +14 2>/dev/null | wc -l)
82
+ find session-env/ -name "*.json" -mtime +14 -delete 2>/dev/null
83
+ echo " Removed: $count files"
84
+
85
+ # Clean old session-env UUID directories (older than 7 days)
86
+ echo "Cleaning session-env UUID directories older than 7 days..."
87
+ count=$(find session-env/ -mindepth 1 -maxdepth 1 -type d -mtime +7 2>/dev/null | wc -l)
88
+ find session-env/ -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \; 2>/dev/null
89
+ echo " Removed: $count directories"
90
+
91
+ # Clean old task output files (older than 7 days)
92
+ echo "Cleaning old task files..."
93
+ count=$(find tasks/ -name "*.json" -mtime +7 2>/dev/null | wc -l)
94
+ find tasks/ -name "*.json" -mtime +7 -delete 2>/dev/null
95
+ echo " Removed: $count files"
96
+
97
+ # Clean old paste-cache files (older than 3 days)
98
+ echo "Cleaning paste-cache older than 3 days..."
99
+ count=$(find paste-cache/ -type f -mtime +3 2>/dev/null | wc -l)
100
+ find paste-cache/ -type f -mtime +3 -delete 2>/dev/null
101
+ echo " Removed: $count files"
102
+
103
+ # Rotate history.jsonl if larger than 5MB — cross-platform stat
104
+ if [ -f history.jsonl ]; then
105
+ size=$(stat -c%s history.jsonl 2>/dev/null || stat -f%z history.jsonl 2>/dev/null || node -e "console.log(require('fs').statSync('history.jsonl').size)" 2>/dev/null || echo 0)
106
+ if [ "$size" -gt 5242880 ]; then
107
+ echo "Rotating history.jsonl (>5MB)..."
108
+ mkdir -p archive
109
+ mv history.jsonl "archive/history-$(date +%Y%m%d).jsonl"
110
+ touch history.jsonl
111
+ echo " Archived to archive/history-$(date +%Y%m%d).jsonl"
112
+ fi
113
+ fi
114
+
115
+ # Remove empty directories
116
+ echo "Removing empty directories..."
117
+ find projects/ -type d -empty -delete 2>/dev/null
118
+ find file-history/ -type d -empty -delete 2>/dev/null
119
+ find todos/ -type d -empty -delete 2>/dev/null
120
+ find session-env/ -type d -empty -delete 2>/dev/null
121
+
122
+ # Report disk usage
123
+ echo ""
124
+ echo "=== Current Disk Usage ==="
125
+ du -sh "$CLAUDE_DIR" 2>/dev/null
126
+ echo ""
127
+ echo "Breakdown:"
128
+ du -sh "$CLAUDE_DIR"/*/ 2>/dev/null | sort -hr | head -10
129
+
130
+ echo ""
131
+ echo "Cleanup complete!"