@code-insights/cli 2.1.0 → 3.0.1

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 (271) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/README.md +146 -156
  3. package/dashboard-dist/assets/index-BMhL7wL8.css +1 -0
  4. package/dashboard-dist/assets/index-CuCBzQyQ.js +548 -0
  5. package/dashboard-dist/dist/assets/index-BMhL7wL8.css +1 -0
  6. package/dashboard-dist/dist/assets/index-CUWKxcRo.js +548 -0
  7. package/dashboard-dist/dist/assets/index-CuCBzQyQ.js +548 -0
  8. package/dashboard-dist/dist/favicon.svg +4 -0
  9. package/dashboard-dist/dist/index.html +33 -0
  10. package/dashboard-dist/favicon.svg +4 -0
  11. package/dashboard-dist/index.html +33 -0
  12. package/dist/commands/config.d.ts.map +1 -1
  13. package/dist/commands/config.js +188 -69
  14. package/dist/commands/config.js.map +1 -1
  15. package/dist/commands/dashboard.d.ts +16 -0
  16. package/dist/commands/dashboard.d.ts.map +1 -0
  17. package/dist/commands/dashboard.js +82 -0
  18. package/dist/commands/dashboard.js.map +1 -0
  19. package/dist/commands/init.d.ts +3 -4
  20. package/dist/commands/init.d.ts.map +1 -1
  21. package/dist/commands/init.js +24 -201
  22. package/dist/commands/init.js.map +1 -1
  23. package/dist/commands/install-hook.d.ts.map +1 -1
  24. package/dist/commands/install-hook.js +4 -21
  25. package/dist/commands/install-hook.js.map +1 -1
  26. package/dist/commands/open.d.ts +2 -1
  27. package/dist/commands/open.d.ts.map +1 -1
  28. package/dist/commands/open.js +10 -21
  29. package/dist/commands/open.js.map +1 -1
  30. package/dist/commands/reset.d.ts.map +1 -1
  31. package/dist/commands/reset.js +38 -69
  32. package/dist/commands/reset.js.map +1 -1
  33. package/dist/commands/stats/actions/error-handler.d.ts.map +1 -1
  34. package/dist/commands/stats/actions/error-handler.js +1 -11
  35. package/dist/commands/stats/actions/error-handler.js.map +1 -1
  36. package/dist/commands/stats/data/local.d.ts +0 -2
  37. package/dist/commands/stats/data/local.d.ts.map +1 -1
  38. package/dist/commands/stats/data/local.js +44 -44
  39. package/dist/commands/stats/data/local.js.map +1 -1
  40. package/dist/commands/stats/data/source.d.ts +3 -9
  41. package/dist/commands/stats/data/source.d.ts.map +1 -1
  42. package/dist/commands/stats/data/source.js +3 -35
  43. package/dist/commands/stats/data/source.js.map +1 -1
  44. package/dist/commands/stats/data/types.d.ts +1 -12
  45. package/dist/commands/stats/data/types.d.ts.map +1 -1
  46. package/dist/commands/stats/data/types.js +0 -16
  47. package/dist/commands/stats/data/types.js.map +1 -1
  48. package/dist/commands/stats/shared.d.ts.map +1 -1
  49. package/dist/commands/stats/shared.js +1 -5
  50. package/dist/commands/stats/shared.js.map +1 -1
  51. package/dist/commands/status.d.ts.map +1 -1
  52. package/dist/commands/status.js +53 -92
  53. package/dist/commands/status.js.map +1 -1
  54. package/dist/commands/sync.d.ts +5 -5
  55. package/dist/commands/sync.d.ts.map +1 -1
  56. package/dist/commands/sync.js +31 -39
  57. package/dist/commands/sync.js.map +1 -1
  58. package/dist/commands/telemetry.d.ts.map +1 -1
  59. package/dist/commands/telemetry.js +0 -1
  60. package/dist/commands/telemetry.js.map +1 -1
  61. package/dist/constants/llm-providers.d.ts +5 -0
  62. package/dist/constants/llm-providers.d.ts.map +1 -0
  63. package/dist/constants/llm-providers.js +56 -0
  64. package/dist/constants/llm-providers.js.map +1 -0
  65. package/dist/db/client.d.ts +17 -0
  66. package/dist/db/client.d.ts.map +1 -0
  67. package/dist/db/client.js +53 -0
  68. package/dist/db/client.js.map +1 -0
  69. package/dist/db/migrate.d.ts +9 -0
  70. package/dist/db/migrate.d.ts.map +1 -0
  71. package/dist/db/migrate.js +31 -0
  72. package/dist/db/migrate.js.map +1 -0
  73. package/dist/db/read.d.ts +42 -0
  74. package/dist/db/read.d.ts.map +1 -0
  75. package/dist/db/read.js +194 -0
  76. package/dist/db/read.js.map +1 -0
  77. package/dist/db/schema.d.ts +3 -0
  78. package/dist/db/schema.d.ts.map +1 -0
  79. package/dist/db/schema.js +129 -0
  80. package/dist/db/schema.js.map +1 -0
  81. package/dist/db/write.d.ts +24 -0
  82. package/dist/db/write.d.ts.map +1 -0
  83. package/dist/db/write.js +287 -0
  84. package/dist/db/write.js.map +1 -0
  85. package/dist/firebase/client.d.ts +5 -0
  86. package/dist/firebase/client.d.ts.map +1 -1
  87. package/dist/firebase/client.js +23 -0
  88. package/dist/firebase/client.js.map +1 -1
  89. package/dist/index.js +12 -12
  90. package/dist/index.js.map +1 -1
  91. package/dist/providers/context.d.ts +3 -0
  92. package/dist/providers/context.d.ts.map +1 -0
  93. package/dist/providers/context.js +13 -0
  94. package/dist/providers/context.js.map +1 -0
  95. package/dist/providers/copilot.d.ts +18 -0
  96. package/dist/providers/copilot.d.ts.map +1 -0
  97. package/dist/providers/copilot.js +289 -0
  98. package/dist/providers/copilot.js.map +1 -0
  99. package/dist/providers/cursor.d.ts.map +1 -1
  100. package/dist/providers/cursor.js +8 -3
  101. package/dist/providers/cursor.js.map +1 -1
  102. package/dist/providers/registry.d.ts.map +1 -1
  103. package/dist/providers/registry.js +3 -0
  104. package/dist/providers/registry.js.map +1 -1
  105. package/dist/types.d.ts +38 -47
  106. package/dist/types.d.ts.map +1 -1
  107. package/dist/utils/browser.d.ts +6 -0
  108. package/dist/utils/browser.d.ts.map +1 -0
  109. package/dist/utils/browser.js +23 -0
  110. package/dist/utils/browser.js.map +1 -0
  111. package/dist/utils/config.d.ts +9 -21
  112. package/dist/utils/config.d.ts.map +1 -1
  113. package/dist/utils/config.js +23 -50
  114. package/dist/utils/config.js.map +1 -1
  115. package/dist/utils/telemetry.js +2 -7
  116. package/dist/utils/telemetry.js.map +1 -1
  117. package/dist/utils/tips.js +1 -1
  118. package/dist/utils/tips.js.map +1 -1
  119. package/package.json +19 -5
  120. package/server-dist/dist/index.d.ts +12 -0
  121. package/server-dist/dist/index.d.ts.map +1 -0
  122. package/server-dist/dist/index.js +92 -0
  123. package/server-dist/dist/index.js.map +1 -0
  124. package/server-dist/dist/llm/analysis.d.ts +80 -0
  125. package/server-dist/dist/llm/analysis.d.ts.map +1 -0
  126. package/server-dist/dist/llm/analysis.js +509 -0
  127. package/server-dist/dist/llm/analysis.js.map +1 -0
  128. package/server-dist/dist/llm/client.d.ts +27 -0
  129. package/server-dist/dist/llm/client.d.ts.map +1 -0
  130. package/server-dist/dist/llm/client.js +71 -0
  131. package/server-dist/dist/llm/client.js.map +1 -0
  132. package/server-dist/dist/llm/index.d.ts +7 -0
  133. package/server-dist/dist/llm/index.d.ts.map +1 -0
  134. package/server-dist/dist/llm/index.js +5 -0
  135. package/server-dist/dist/llm/index.js.map +1 -0
  136. package/server-dist/dist/llm/prompts.d.ts +73 -0
  137. package/server-dist/dist/llm/prompts.d.ts.map +1 -0
  138. package/server-dist/dist/llm/prompts.js +242 -0
  139. package/server-dist/dist/llm/prompts.js.map +1 -0
  140. package/server-dist/dist/llm/providers/anthropic.d.ts +3 -0
  141. package/server-dist/dist/llm/providers/anthropic.d.ts.map +1 -0
  142. package/server-dist/dist/llm/providers/anthropic.js +45 -0
  143. package/server-dist/dist/llm/providers/anthropic.js.map +1 -0
  144. package/server-dist/dist/llm/providers/gemini.d.ts +3 -0
  145. package/server-dist/dist/llm/providers/gemini.d.ts.map +1 -0
  146. package/server-dist/dist/llm/providers/gemini.js +51 -0
  147. package/server-dist/dist/llm/providers/gemini.js.map +1 -0
  148. package/server-dist/dist/llm/providers/ollama.d.ts +12 -0
  149. package/server-dist/dist/llm/providers/ollama.d.ts.map +1 -0
  150. package/server-dist/dist/llm/providers/ollama.js +61 -0
  151. package/server-dist/dist/llm/providers/ollama.js.map +1 -0
  152. package/server-dist/dist/llm/providers/openai.d.ts +3 -0
  153. package/server-dist/dist/llm/providers/openai.d.ts.map +1 -0
  154. package/server-dist/dist/llm/providers/openai.js +39 -0
  155. package/server-dist/dist/llm/providers/openai.js.map +1 -0
  156. package/server-dist/dist/llm/types.d.ts +22 -0
  157. package/server-dist/dist/llm/types.d.ts.map +1 -0
  158. package/server-dist/dist/llm/types.js +5 -0
  159. package/server-dist/dist/llm/types.js.map +1 -0
  160. package/server-dist/dist/routes/analysis.d.ts +4 -0
  161. package/server-dist/dist/routes/analysis.d.ts.map +1 -0
  162. package/server-dist/dist/routes/analysis.js +103 -0
  163. package/server-dist/dist/routes/analysis.js.map +1 -0
  164. package/server-dist/dist/routes/analytics.d.ts +4 -0
  165. package/server-dist/dist/routes/analytics.d.ts.map +1 -0
  166. package/server-dist/dist/routes/analytics.js +47 -0
  167. package/server-dist/dist/routes/analytics.js.map +1 -0
  168. package/server-dist/dist/routes/config.d.ts +4 -0
  169. package/server-dist/dist/routes/config.d.ts.map +1 -0
  170. package/server-dist/dist/routes/config.js +108 -0
  171. package/server-dist/dist/routes/config.js.map +1 -0
  172. package/server-dist/dist/routes/export.d.ts +4 -0
  173. package/server-dist/dist/routes/export.d.ts.map +1 -0
  174. package/server-dist/dist/routes/export.js +52 -0
  175. package/server-dist/dist/routes/export.js.map +1 -0
  176. package/server-dist/dist/routes/insights.d.ts +4 -0
  177. package/server-dist/dist/routes/insights.d.ts.map +1 -0
  178. package/server-dist/dist/routes/insights.js +80 -0
  179. package/server-dist/dist/routes/insights.js.map +1 -0
  180. package/server-dist/dist/routes/messages.d.ts +4 -0
  181. package/server-dist/dist/routes/messages.d.ts.map +1 -0
  182. package/server-dist/dist/routes/messages.js +19 -0
  183. package/server-dist/dist/routes/messages.js.map +1 -0
  184. package/server-dist/dist/routes/projects.d.ts +4 -0
  185. package/server-dist/dist/routes/projects.d.ts.map +1 -0
  186. package/server-dist/dist/routes/projects.js +32 -0
  187. package/server-dist/dist/routes/projects.js.map +1 -0
  188. package/server-dist/dist/routes/sessions.d.ts +4 -0
  189. package/server-dist/dist/routes/sessions.d.ts.map +1 -0
  190. package/server-dist/dist/routes/sessions.js +65 -0
  191. package/server-dist/dist/routes/sessions.js.map +1 -0
  192. package/server-dist/dist/utils.d.ts +6 -0
  193. package/server-dist/dist/utils.d.ts.map +1 -0
  194. package/server-dist/dist/utils.js +9 -0
  195. package/server-dist/dist/utils.js.map +1 -0
  196. package/server-dist/index.d.ts +12 -0
  197. package/server-dist/index.d.ts.map +1 -0
  198. package/server-dist/index.js +92 -0
  199. package/server-dist/index.js.map +1 -0
  200. package/server-dist/llm/analysis.d.ts +80 -0
  201. package/server-dist/llm/analysis.d.ts.map +1 -0
  202. package/server-dist/llm/analysis.js +509 -0
  203. package/server-dist/llm/analysis.js.map +1 -0
  204. package/server-dist/llm/client.d.ts +27 -0
  205. package/server-dist/llm/client.d.ts.map +1 -0
  206. package/server-dist/llm/client.js +71 -0
  207. package/server-dist/llm/client.js.map +1 -0
  208. package/server-dist/llm/index.d.ts +7 -0
  209. package/server-dist/llm/index.d.ts.map +1 -0
  210. package/server-dist/llm/index.js +5 -0
  211. package/server-dist/llm/index.js.map +1 -0
  212. package/server-dist/llm/prompts.d.ts +73 -0
  213. package/server-dist/llm/prompts.d.ts.map +1 -0
  214. package/server-dist/llm/prompts.js +242 -0
  215. package/server-dist/llm/prompts.js.map +1 -0
  216. package/server-dist/llm/providers/anthropic.d.ts +3 -0
  217. package/server-dist/llm/providers/anthropic.d.ts.map +1 -0
  218. package/server-dist/llm/providers/anthropic.js +45 -0
  219. package/server-dist/llm/providers/anthropic.js.map +1 -0
  220. package/server-dist/llm/providers/gemini.d.ts +3 -0
  221. package/server-dist/llm/providers/gemini.d.ts.map +1 -0
  222. package/server-dist/llm/providers/gemini.js +51 -0
  223. package/server-dist/llm/providers/gemini.js.map +1 -0
  224. package/server-dist/llm/providers/ollama.d.ts +12 -0
  225. package/server-dist/llm/providers/ollama.d.ts.map +1 -0
  226. package/server-dist/llm/providers/ollama.js +61 -0
  227. package/server-dist/llm/providers/ollama.js.map +1 -0
  228. package/server-dist/llm/providers/openai.d.ts +3 -0
  229. package/server-dist/llm/providers/openai.d.ts.map +1 -0
  230. package/server-dist/llm/providers/openai.js +39 -0
  231. package/server-dist/llm/providers/openai.js.map +1 -0
  232. package/server-dist/llm/types.d.ts +22 -0
  233. package/server-dist/llm/types.d.ts.map +1 -0
  234. package/server-dist/llm/types.js +5 -0
  235. package/server-dist/llm/types.js.map +1 -0
  236. package/server-dist/routes/analysis.d.ts +4 -0
  237. package/server-dist/routes/analysis.d.ts.map +1 -0
  238. package/server-dist/routes/analysis.js +103 -0
  239. package/server-dist/routes/analysis.js.map +1 -0
  240. package/server-dist/routes/analytics.d.ts +4 -0
  241. package/server-dist/routes/analytics.d.ts.map +1 -0
  242. package/server-dist/routes/analytics.js +47 -0
  243. package/server-dist/routes/analytics.js.map +1 -0
  244. package/server-dist/routes/config.d.ts +4 -0
  245. package/server-dist/routes/config.d.ts.map +1 -0
  246. package/server-dist/routes/config.js +108 -0
  247. package/server-dist/routes/config.js.map +1 -0
  248. package/server-dist/routes/export.d.ts +4 -0
  249. package/server-dist/routes/export.d.ts.map +1 -0
  250. package/server-dist/routes/export.js +52 -0
  251. package/server-dist/routes/export.js.map +1 -0
  252. package/server-dist/routes/insights.d.ts +4 -0
  253. package/server-dist/routes/insights.d.ts.map +1 -0
  254. package/server-dist/routes/insights.js +80 -0
  255. package/server-dist/routes/insights.js.map +1 -0
  256. package/server-dist/routes/messages.d.ts +4 -0
  257. package/server-dist/routes/messages.d.ts.map +1 -0
  258. package/server-dist/routes/messages.js +19 -0
  259. package/server-dist/routes/messages.js.map +1 -0
  260. package/server-dist/routes/projects.d.ts +4 -0
  261. package/server-dist/routes/projects.d.ts.map +1 -0
  262. package/server-dist/routes/projects.js +32 -0
  263. package/server-dist/routes/projects.js.map +1 -0
  264. package/server-dist/routes/sessions.d.ts +4 -0
  265. package/server-dist/routes/sessions.d.ts.map +1 -0
  266. package/server-dist/routes/sessions.js +65 -0
  267. package/server-dist/routes/sessions.js.map +1 -0
  268. package/server-dist/utils.d.ts +6 -0
  269. package/server-dist/utils.d.ts.map +1 -0
  270. package/server-dist/utils.js +9 -0
  271. package/server-dist/utils.js.map +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,45 @@
2
2
 
3
3
  All notable changes to `@code-insights/cli` will be documented in this file.
4
4
 
5
+ ## [3.0.0] - 2026-02-28
6
+
7
+ See [MIGRATION.md](../MIGRATION.md) for the full upgrade guide from v2.
8
+
9
+ ### Breaking Changes
10
+
11
+ - **Firebase removed** — No Firestore sync, no Firebase credentials, no service account required. All data is stored locally in SQLite at `~/.code-insights/data.db`.
12
+ - **`connect` command removed** — Generated Firebase connection URLs. No longer needed.
13
+ - **`init` config format changed** — v2 config had Firebase credentials fields. v3 config has only sync settings and optional LLM config. Re-run `code-insights init` after upgrading.
14
+ - **Data source changed to SQLite** — v2 wrote to Firestore. v3 writes to local SQLite. Existing Firestore data is not migrated. Re-sync with `code-insights sync --force`.
15
+ - **Hosted dashboard removed** — The dashboard at code-insights.app is no longer maintained.
16
+
17
+ ### Added
18
+
19
+ - **`dashboard` command** — Starts a local Hono server and opens the built-in React SPA at `localhost:7890`. Replaces the hosted dashboard.
20
+ - **Embedded Vite + React SPA** — Full browser dashboard for session browsing, analytics, and insights. No external URL required.
21
+ - **Server-side LLM analysis** — API keys are stored and used server-side. No key exposure to the browser.
22
+ - **Multi-tool support** — Session providers for Cursor, Codex CLI, and Copilot CLI (in addition to Claude Code).
23
+ - **`config llm` command** — Interactive and non-interactive LLM provider configuration (Anthropic, OpenAI, Gemini, Ollama).
24
+ - **`--source <tool>` flag on `sync`** — Sync only from a specific tool.
25
+ - **`--verbose` flag on `sync`** — Show diagnostic warnings from providers.
26
+ - **`--regenerate-titles` flag on `sync`** — Regenerate session titles from content.
27
+ - **`--no-sync` flag on `stats`** — Skip auto-sync before displaying analytics.
28
+
29
+ ### Changed
30
+
31
+ - **`init`** — No longer requires Firebase credentials. Sets up local SQLite database and config only.
32
+ - **`open`** — Now opens `localhost:7890` (local dashboard server) instead of code-insights.app.
33
+ - **`reset`** — Clears local SQLite database and sync state instead of Firestore data.
34
+ - **`sync`** — Writes to local SQLite instead of Firestore.
35
+ - **`status`** — Reports SQLite session counts and local sync state.
36
+
37
+ ## [2.1.0] - 2026-02-27
38
+
39
+ ### Added
40
+ - **CopilotProvider** — VS Code Copilot Chat session support (`sourceTool: 'copilot'`)
41
+ - **`status` command multi-tool summary** — displays session counts broken down by source tool (Claude Code, Cursor, Codex CLI, Copilot)
42
+ - **`reset` now clears `stats` collection** — ensures the `stats/usage` document is wiped on full reset
43
+
5
44
  ## [2.0.0] - 2026-02-26
6
45
 
7
46
  ### Added
package/README.md CHANGED
@@ -1,262 +1,252 @@
1
1
  # Code Insights CLI
2
2
 
3
- Command-line tool that parses AI coding session history and provides terminal analytics. Optionally syncs to your own Firebase Firestore for the web dashboard.
3
+ Analyze AI coding sessions from the terminal. Parses session history from Claude Code, Cursor, Codex CLI, and Copilot CLI stores everything in a local SQLite database and serves a built-in browser dashboard.
4
4
 
5
- Full documentation: [docs.code-insights.app](https://docs.code-insights.app)
5
+ **Local-first. No accounts. No cloud. No data leaves your machine.**
6
6
 
7
- ## Prerequisites
8
-
9
- - **Node.js** 18 or later
10
- - **For local-only stats:** No additional setup required
11
- - **For Firebase sync + web dashboard:** A Firebase project with Firestore enabled (see [Quick Start](https://docs.code-insights.app/getting-started/quick-start/))
12
-
13
- ## Installation
7
+ ## Install
14
8
 
15
9
  ```bash
16
10
  npm install -g @code-insights/cli
17
11
  ```
18
12
 
19
- Verify it works:
13
+ Verify:
20
14
 
21
15
  ```bash
22
16
  code-insights --version
23
17
  ```
24
18
 
25
- ## Commands
26
-
27
- ### `code-insights init`
28
-
29
- Configure Code Insights with your data source preference and optional Firebase credentials.
19
+ ## Quick Start
30
20
 
31
21
  ```bash
32
- # Quick setup import directly from files (recommended)
33
- code-insights init \
34
- --from-json ~/Downloads/serviceAccountKey.json \
35
- --web-config ~/Downloads/firebase-web-config.js
36
-
37
- # Interactive setup — prompts for data source + credentials
22
+ # 1. Initialize (creates ~/.code-insights/ config and database)
38
23
  code-insights init
39
- ```
40
-
41
- **Flags:**
42
- - `--from-json <path>` — Path to the Firebase service account key (auto-sets data source to Firebase)
43
- - `--web-config <path>` — Path to the Firebase web SDK config (JSON or JS snippet)
44
24
 
45
- During interactive setup, the CLI first asks for your preferred data source:
46
- - **Local** (recommended) — Stats read from local session files. No Firebase required.
47
- - **Firebase** — Stats read from Firestore. Requires Firebase credentials.
48
-
49
- Configuration is stored in `~/.code-insights/config.json`. Web config is stored separately in `~/.code-insights/web-config.json`.
25
+ # 2. Sync sessions from all detected AI tools
26
+ code-insights sync
50
27
 
51
- ### `code-insights stats`
28
+ # 3. Open the built-in dashboard
29
+ code-insights dashboard
30
+ ```
52
31
 
53
- Terminal analytics for your AI coding sessions. Works without Firebase.
32
+ The dashboard opens at `http://localhost:7890` and shows your sessions, analytics, and LLM-powered insights.
54
33
 
55
- ```bash
56
- # Dashboard overview (default: last 7 days)
57
- code-insights stats
34
+ ## Supported Tools
58
35
 
59
- # Cost breakdown by project and model
60
- code-insights stats cost
36
+ | Tool | Data Location |
37
+ |------|---------------|
38
+ | **Claude Code** | `~/.claude/projects/**/*.jsonl` |
39
+ | **Cursor** | Workspace storage SQLite (macOS, Linux, Windows) |
40
+ | **Codex CLI** | `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` |
41
+ | **Copilot CLI** | `~/.copilot/session-state/{id}/events.jsonl` |
61
42
 
62
- # Per-project detail cards with sparklines
63
- code-insights stats projects
43
+ Sessions from all tools are discovered automatically during sync.
64
44
 
65
- # Today's sessions with time, cost, model details
66
- code-insights stats today
45
+ ## Dashboard
67
46
 
68
- # Model usage distribution and cost chart
69
- code-insights stats models
47
+ ```bash
48
+ code-insights dashboard
70
49
  ```
71
50
 
72
- **Shared flags:**
51
+ Opens the built-in React dashboard at `http://localhost:7890`. The dashboard provides:
73
52
 
74
- | Flag | Short | Description |
75
- |------|-------|-------------|
76
- | `--local` | | Force local data source (no Firebase) |
77
- | `--remote` | | Force Firestore data source |
78
- | `--period <range>` | | Time range: `7d`, `30d`, `90d`, or `all` (default: `7d`) |
79
- | `--project <name>` | `-p` | Scope to a specific project (fuzzy matching) |
80
- | `--source <tool>` | `-s` | Filter by source tool (e.g., `claude-code`, `cursor`) |
81
- | `--no-sync` | | Skip auto-sync before displaying stats |
53
+ - **Session Browser** search, filter, and view full session details
54
+ - **Analytics** — usage patterns, cost trends, activity charts
55
+ - **LLM Insights** AI-generated summaries, decisions, learnings, and techniques
56
+ - **Settings** configure your LLM provider for analysis
82
57
 
83
- ### `code-insights config`
58
+ > **Screenshot:** _Coming soon_
84
59
 
85
- View and manage CLI configuration.
60
+ ### Custom Port
86
61
 
87
62
  ```bash
88
- # Show current configuration
89
- code-insights config
90
-
91
- # Set data source preference
92
- code-insights config set-source local # Local-only mode
93
- code-insights config set-source firebase # Firebase mode
63
+ code-insights dashboard --port 8080
94
64
  ```
95
65
 
96
- ### `code-insights connect`
66
+ ## CLI Commands
97
67
 
98
- Generate a URL to connect the web dashboard to your Firebase.
68
+ ### Setup & Configuration
99
69
 
100
70
  ```bash
101
- code-insights connect
102
- ```
71
+ # Interactive setup — prompts for Claude dir, excluded projects, etc.
72
+ code-insights init
103
73
 
104
- The URL includes your Firebase web config base64-encoded as a query parameter. Open it in a browser to connect the dashboard to your Firestore — no manual configuration needed.
74
+ # Show current configuration
75
+ code-insights config
105
76
 
106
- ### `code-insights open`
77
+ # Configure LLM provider for session analysis (interactive)
78
+ code-insights config llm
107
79
 
108
- Open the web dashboard in your browser.
80
+ # Configure LLM provider with flags (non-interactive)
81
+ code-insights config llm --provider anthropic --model claude-sonnet-4-20250514 --api-key sk-ant-...
109
82
 
110
- ```bash
111
- # Open the dashboard
112
- code-insights open
83
+ # Show current LLM configuration
84
+ code-insights config llm --show
113
85
 
114
- # Open filtered to the current project
115
- code-insights open --project
86
+ # Set a config value (e.g., disable telemetry)
87
+ code-insights config set telemetry false
116
88
  ```
117
89
 
118
- If Firebase web config is set up, the URL includes your config for automatic connection.
119
-
120
- ### `code-insights sync`
121
-
122
- Sync sessions from all supported tools to Firestore.
90
+ ### Sync
123
91
 
124
92
  ```bash
125
- # Sync new/modified sessions
93
+ # Sync new and modified sessions (incremental)
126
94
  code-insights sync
127
95
 
128
96
  # Force re-sync all sessions
129
97
  code-insights sync --force
130
98
 
131
- # Preview what would be synced
99
+ # Preview what would be synced (no changes made)
132
100
  code-insights sync --dry-run
133
101
 
134
- # Sync specific project only
135
- code-insights sync --project "my-project"
136
-
137
102
  # Sync only from a specific tool
138
103
  code-insights sync --source cursor
104
+ code-insights sync --source claude-code
105
+ code-insights sync --source codex-cli
106
+ code-insights sync --source copilot-cli
107
+
108
+ # Sync only sessions from a specific project
109
+ code-insights sync --project "my-project"
139
110
 
140
- # Quiet mode (for hooks)
141
- code-insights sync --quiet
111
+ # Quiet mode (useful for hooks)
112
+ code-insights sync -q
113
+
114
+ # Show diagnostic warnings from providers
115
+ code-insights sync --verbose
142
116
 
143
117
  # Regenerate titles for all sessions
144
118
  code-insights sync --regenerate-titles
145
-
146
- # Sync even when data source is set to local
147
- code-insights sync --force-remote
148
119
  ```
149
120
 
150
- > **Note:** When data source is set to `local`, sync shows a warning and exits. Use `--force-remote` to override, or switch with `config set-source firebase`.
121
+ ### Terminal Analytics
151
122
 
152
- ### `code-insights status`
123
+ ```bash
124
+ # Overview: sessions, cost, activity (last 7 days)
125
+ code-insights stats
153
126
 
154
- Show sync status, statistics, and data source preference.
127
+ # Cost breakdown by project and model
128
+ code-insights stats cost
155
129
 
156
- ```bash
157
- code-insights status
130
+ # Per-project detail cards
131
+ code-insights stats projects
132
+
133
+ # Today's sessions with time, cost, and model details
134
+ code-insights stats today
135
+
136
+ # Model usage distribution and cost chart
137
+ code-insights stats models
158
138
  ```
159
139
 
160
- Displays:
161
- - Data source preference (local or Firebase)
162
- - Configuration status
163
- - Total sessions synced
164
- - Projects tracked
165
- - Last sync time
140
+ **Shared flags for all `stats` subcommands:**
166
141
 
167
- ### `code-insights reset`
142
+ | Flag | Description |
143
+ |------|-------------|
144
+ | `--period 7d\|30d\|90d\|all` | Time range (default: `7d`) |
145
+ | `--project <name>` | Scope to a specific project (fuzzy matching) |
146
+ | `--source <tool>` | Filter by source tool |
147
+ | `--no-sync` | Skip auto-sync before displaying stats |
168
148
 
169
- Delete all data from Firestore and reset local sync state.
149
+ ### Status & Maintenance
170
150
 
171
151
  ```bash
172
- # Interactive (asks for confirmation)
173
- code-insights reset
152
+ # Show sync statistics (sessions, projects, last sync)
153
+ code-insights status
154
+
155
+ # Open the local dashboard in your browser (server must already be running)
156
+ code-insights open
174
157
 
175
- # Skip confirmation
158
+ # Delete all local data and reset sync state
176
159
  code-insights reset --confirm
177
160
  ```
178
161
 
179
- > **Note:** In local mode, this clears the local stats cache only. Firestore data is not affected.
180
-
181
- ### `code-insights install-hook`
182
-
183
- Install a Claude Code hook for automatic sync after each session.
162
+ ### Auto-Sync Hook
184
163
 
185
164
  ```bash
165
+ # Install a Claude Code hook — auto-syncs when sessions end
186
166
  code-insights install-hook
167
+
168
+ # Remove the hook
169
+ code-insights uninstall-hook
187
170
  ```
188
171
 
189
- > **Note:** In local mode, the hook is not installed (sync requires Firebase).
172
+ ### Telemetry
190
173
 
191
- ### `code-insights uninstall-hook`
174
+ Anonymous usage telemetry is opt-out. No PII is collected.
192
175
 
193
- Remove the automatic sync hook.
176
+ ```bash
177
+ code-insights telemetry status # Check current status
178
+ code-insights telemetry disable # Disable telemetry
179
+ code-insights telemetry enable # Re-enable telemetry
180
+ ```
181
+
182
+ Alternatively, set the environment variable:
194
183
 
195
184
  ```bash
196
- code-insights uninstall-hook
185
+ CODE_INSIGHTS_TELEMETRY_DISABLED=1 code-insights sync
197
186
  ```
198
187
 
199
- ### `code-insights telemetry`
188
+ ## LLM Configuration
200
189
 
201
- Manage anonymous usage telemetry. Telemetry is opt-out and helps improve the CLI.
190
+ Session analysis (summaries, decisions, learnings) requires an LLM provider. Configure it via CLI or the dashboard Settings page.
202
191
 
203
192
  ```bash
204
- # Check telemetry status
205
- code-insights telemetry status
193
+ code-insights config llm
194
+ ```
206
195
 
207
- # Disable telemetry
208
- code-insights telemetry disable
196
+ **Supported providers:**
209
197
 
210
- # Re-enable telemetry
211
- code-insights telemetry enable
212
- ```
198
+ | Provider | Models | Requires API Key |
199
+ |----------|--------|-----------------|
200
+ | Anthropic | claude-opus-4-6, claude-sonnet-4-6, etc. | Yes |
201
+ | OpenAI | gpt-4o, gpt-4o-mini, etc. | Yes |
202
+ | Google Gemini | gemini-2.0-flash, gemini-2.0-pro, etc. | Yes |
203
+ | Ollama | llama3.2, qwen2.5-coder, etc. | No (local) |
213
204
 
214
- No personally identifiable information is collected. See the [telemetry documentation](https://github.com/melagiri/code-insights) for details.
205
+ API keys are stored in `~/.code-insights/config.json` (mode 0o600, readable only by you).
215
206
 
216
- ## How It Works
207
+ ## Development
217
208
 
218
- ### Session Parsing
209
+ This is a pnpm workspace monorepo with three packages: `cli`, `dashboard`, and `server`.
210
+
211
+ ```bash
212
+ # Clone
213
+ git clone https://github.com/melagiri/code-insights.git
214
+ cd code-insights
219
215
 
220
- The CLI reads JSONL files from `~/.claude/projects/` which contain:
221
- - User and assistant messages
222
- - Tool calls (Edit, Write, Bash, etc.)
223
- - Timestamps and metadata
216
+ # Install all dependencies
217
+ pnpm install
224
218
 
225
- Each session is parsed to extract:
226
- - Project name and path
227
- - Start/end times and duration
228
- - Message counts
229
- - Tool call statistics
230
- - Git branch (if available)
231
- - Claude version
232
- - Token usage, estimated costs, and model information (when available)
219
+ # Build all packages
220
+ pnpm build
233
221
 
234
- ### Incremental Sync
222
+ # Link CLI for local testing
223
+ cd cli && npm link
224
+ code-insights --version
235
225
 
236
- Sync state is tracked in `~/.code-insights/sync-state.json`:
237
- - File modification times are recorded
238
- - Only new or modified files are processed
239
- - Use `--force` to bypass and re-sync everything
226
+ # Watch mode (CLI only)
227
+ cd cli && pnpm dev
228
+ ```
240
229
 
241
- ### Multi-Device Support
230
+ ### Workspace Structure
242
231
 
243
- Project IDs are generated from git remote URLs when available:
244
- - Same repo on different machines → same project ID
245
- - Non-git projects fall back to path-based hash
246
- - Each session records device metadata (hostname, platform)
232
+ ```
233
+ code-insights/
234
+ ├── cli/ # This package Node.js CLI, SQLite, providers
235
+ ├── dashboard/ # Vite + React SPA
236
+ └── server/ # Hono API server (serves dashboard + REST API)
237
+ ```
247
238
 
248
- ### Title Generation
239
+ ### Contributing
249
240
 
250
- Sessions are automatically titled based on:
251
- 1. Claude's own title (if present in session)
252
- 2. First user message (cleaned up)
253
- 3. Session character detection (deep focus, bug hunt, etc.)
254
- 4. Fallback to timestamp
241
+ See [CONTRIBUTING.md](https://github.com/melagiri/code-insights/blob/master/CONTRIBUTING.md) for code style, PR guidelines, and how to add a new source tool provider.
255
242
 
256
- ## Contributing
243
+ ## Privacy
257
244
 
258
- See [CONTRIBUTING.md](https://github.com/melagiri/code-insights/blob/master/CONTRIBUTING.md) for development setup, code style, and PR guidelines.
245
+ - All session data is stored in `~/.code-insights/data.db` (SQLite) on your machine
246
+ - No cloud accounts required
247
+ - No data is transmitted anywhere (unless you explicitly use an LLM provider with a remote API key)
248
+ - Anonymous telemetry collects only aggregate usage counts — no session content, no file paths
259
249
 
260
250
  ## License
261
251
 
262
- MIT License — see [LICENSE](https://github.com/melagiri/code-insights/blob/master/LICENSE) for details.
252
+ MIT — see [LICENSE](https://github.com/melagiri/code-insights/blob/master/LICENSE) for details.