@codemieai/code 0.2.0 → 0.3.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 (258) hide show
  1. package/README.md +38 -7
  2. package/dist/agents/core/session/ensure-session.d.ts.map +1 -1
  3. package/dist/agents/core/session/ensure-session.js +14 -11
  4. package/dist/agents/core/session/ensure-session.js.map +1 -1
  5. package/dist/agents/plugins/claude/plugin/{codemie-statusline.mjs → session-status.mjs} +1 -0
  6. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/SKILL.md +641 -0
  7. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/references/leaderboard-dashboard-report.md +225 -0
  8. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/references/people-spending-dashboard-report.md +746 -0
  9. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/references/people-spending-dashboard-template.html +3270 -0
  10. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/scripts/analytics-cli.js +893 -0
  11. package/dist/agents/plugins/claude/plugin/skills/codemie-analytics/scripts/inspect-schema.js +211 -0
  12. package/dist/agents/plugins/claude/plugin/skills/codemie-html-report/README.md +39 -0
  13. package/dist/agents/plugins/claude/plugin/skills/codemie-html-report/SKILL.md +117 -26
  14. package/dist/agents/plugins/claude/plugin/skills/codemie-html-report/scripts/inject-css.js +40 -0
  15. package/dist/agents/plugins/claude/plugin/skills/codemie-html-report/scripts/inject-data.js +68 -0
  16. package/dist/agents/plugins/claude/plugin/skills/codemie-html-report/style-guide/css/bundle.css +1 -0
  17. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/SKILL.md +240 -0
  18. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/assistants.md +256 -0
  19. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/categories.md +101 -0
  20. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/datasources.md +401 -0
  21. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/integrations.md +242 -0
  22. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/skills.md +191 -0
  23. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/users.md +38 -0
  24. package/dist/agents/plugins/claude/plugin/skills/codemie-sdk/examples/workflows.md +151 -0
  25. package/dist/agents/plugins/claude/plugin/skills/msgraph/scripts/msgraph.js +12 -2
  26. package/dist/agents/plugins/claude/plugin/statusline.mjs +216 -0
  27. package/dist/agents/plugins/claude/statusline-installer.d.ts +8 -0
  28. package/dist/agents/plugins/claude/statusline-installer.d.ts.map +1 -0
  29. package/dist/agents/plugins/claude/statusline-installer.js +127 -0
  30. package/dist/agents/plugins/claude/statusline-installer.js.map +1 -0
  31. package/dist/agents/plugins/codemie-code.plugin.d.ts.map +1 -1
  32. package/dist/agents/plugins/codemie-code.plugin.js +5 -0
  33. package/dist/agents/plugins/codemie-code.plugin.js.map +1 -1
  34. package/dist/cli/commands/assistants/chat/index.d.ts.map +1 -1
  35. package/dist/cli/commands/assistants/chat/index.js +8 -2
  36. package/dist/cli/commands/assistants/chat/index.js.map +1 -1
  37. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.d.ts +3 -2
  38. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.d.ts.map +1 -1
  39. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.js +5 -4
  40. package/dist/cli/commands/assistants/setup/generators/claude-agent-generator.js.map +1 -1
  41. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts +3 -2
  42. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.d.ts.map +1 -1
  43. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js +8 -6
  44. package/dist/cli/commands/assistants/setup/generators/claude-skill-generator.js.map +1 -1
  45. package/dist/cli/commands/assistants/setup/helpers.d.ts +3 -2
  46. package/dist/cli/commands/assistants/setup/helpers.d.ts.map +1 -1
  47. package/dist/cli/commands/assistants/setup/helpers.js +3 -2
  48. package/dist/cli/commands/assistants/setup/helpers.js.map +1 -1
  49. package/dist/cli/commands/assistants/setup/index.d.ts.map +1 -1
  50. package/dist/cli/commands/assistants/setup/index.js +7 -13
  51. package/dist/cli/commands/assistants/setup/index.js.map +1 -1
  52. package/dist/cli/commands/assistants/setup/summary/index.d.ts +3 -3
  53. package/dist/cli/commands/assistants/setup/summary/index.d.ts.map +1 -1
  54. package/dist/cli/commands/assistants/setup/summary/index.js +5 -5
  55. package/dist/cli/commands/assistants/setup/summary/index.js.map +1 -1
  56. package/dist/cli/commands/install.d.ts.map +1 -1
  57. package/dist/cli/commands/install.js +40 -0
  58. package/dist/cli/commands/install.js.map +1 -1
  59. package/dist/cli/commands/profile/display.d.ts.map +1 -1
  60. package/dist/cli/commands/profile/display.js +1 -0
  61. package/dist/cli/commands/profile/display.js.map +1 -1
  62. package/dist/cli/commands/proxy/connectors/desktop-managed-mcp-servers.json +0 -6
  63. package/dist/cli/commands/proxy/connectors/desktop.d.ts.map +1 -1
  64. package/dist/cli/commands/proxy/connectors/desktop.js +20 -10
  65. package/dist/cli/commands/proxy/connectors/desktop.js.map +1 -1
  66. package/dist/cli/commands/sdk/assistants.d.ts +3 -0
  67. package/dist/cli/commands/sdk/assistants.d.ts.map +1 -0
  68. package/dist/cli/commands/sdk/assistants.js +211 -0
  69. package/dist/cli/commands/sdk/assistants.js.map +1 -0
  70. package/dist/cli/commands/sdk/categories.d.ts +3 -0
  71. package/dist/cli/commands/sdk/categories.d.ts.map +1 -0
  72. package/dist/cli/commands/sdk/categories.js +186 -0
  73. package/dist/cli/commands/sdk/categories.js.map +1 -0
  74. package/dist/cli/commands/sdk/datasources.d.ts +3 -0
  75. package/dist/cli/commands/sdk/datasources.d.ts.map +1 -0
  76. package/dist/cli/commands/sdk/datasources.js +276 -0
  77. package/dist/cli/commands/sdk/datasources.js.map +1 -0
  78. package/dist/cli/commands/sdk/index.d.ts +3 -0
  79. package/dist/cli/commands/sdk/index.d.ts.map +1 -0
  80. package/dist/cli/commands/sdk/index.js +23 -0
  81. package/dist/cli/commands/sdk/index.js.map +1 -0
  82. package/dist/cli/commands/sdk/integrations.d.ts +3 -0
  83. package/dist/cli/commands/sdk/integrations.d.ts.map +1 -0
  84. package/dist/cli/commands/sdk/integrations.js +220 -0
  85. package/dist/cli/commands/sdk/integrations.js.map +1 -0
  86. package/dist/cli/commands/sdk/llm.d.ts +3 -0
  87. package/dist/cli/commands/sdk/llm.d.ts.map +1 -0
  88. package/dist/cli/commands/sdk/llm.js +48 -0
  89. package/dist/cli/commands/sdk/llm.js.map +1 -0
  90. package/dist/cli/commands/sdk/services/assistants.d.ts +13 -0
  91. package/dist/cli/commands/sdk/services/assistants.d.ts.map +1 -0
  92. package/dist/cli/commands/sdk/services/assistants.js +60 -0
  93. package/dist/cli/commands/sdk/services/assistants.js.map +1 -0
  94. package/dist/cli/commands/sdk/services/categories.d.ts +8 -0
  95. package/dist/cli/commands/sdk/services/categories.d.ts.map +1 -0
  96. package/dist/cli/commands/sdk/services/categories.js +19 -0
  97. package/dist/cli/commands/sdk/services/categories.js.map +1 -0
  98. package/dist/cli/commands/sdk/services/datasources.d.ts +33 -0
  99. package/dist/cli/commands/sdk/services/datasources.d.ts.map +1 -0
  100. package/dist/cli/commands/sdk/services/datasources.js +268 -0
  101. package/dist/cli/commands/sdk/services/datasources.js.map +1 -0
  102. package/dist/cli/commands/sdk/services/index.d.ts +6 -0
  103. package/dist/cli/commands/sdk/services/index.d.ts.map +1 -0
  104. package/dist/cli/commands/sdk/services/index.js +6 -0
  105. package/dist/cli/commands/sdk/services/index.js.map +1 -0
  106. package/dist/cli/commands/sdk/services/integrations.d.ts +27 -0
  107. package/dist/cli/commands/sdk/services/integrations.d.ts.map +1 -0
  108. package/dist/cli/commands/sdk/services/integrations.js +59 -0
  109. package/dist/cli/commands/sdk/services/integrations.js.map +1 -0
  110. package/dist/cli/commands/sdk/services/llm.d.ts +4 -0
  111. package/dist/cli/commands/sdk/services/llm.d.ts.map +1 -0
  112. package/dist/cli/commands/sdk/services/llm.js +7 -0
  113. package/dist/cli/commands/sdk/services/llm.js.map +1 -0
  114. package/dist/cli/commands/sdk/services/skills.d.ts +23 -0
  115. package/dist/cli/commands/sdk/services/skills.d.ts.map +1 -0
  116. package/dist/cli/commands/sdk/services/skills.js +69 -0
  117. package/dist/cli/commands/sdk/services/skills.js.map +1 -0
  118. package/dist/cli/commands/sdk/services/users.d.ts +4 -0
  119. package/dist/cli/commands/sdk/services/users.d.ts.map +1 -0
  120. package/dist/cli/commands/sdk/services/users.js +7 -0
  121. package/dist/cli/commands/sdk/services/users.js.map +1 -0
  122. package/dist/cli/commands/sdk/services/workflows.d.ts +7 -0
  123. package/dist/cli/commands/sdk/services/workflows.d.ts.map +1 -0
  124. package/dist/cli/commands/sdk/services/workflows.js +34 -0
  125. package/dist/cli/commands/sdk/services/workflows.js.map +1 -0
  126. package/dist/cli/commands/sdk/skills.d.ts +3 -0
  127. package/dist/cli/commands/sdk/skills.d.ts.map +1 -0
  128. package/dist/cli/commands/sdk/skills.js +492 -0
  129. package/dist/cli/commands/sdk/skills.js.map +1 -0
  130. package/dist/cli/commands/sdk/users.d.ts +3 -0
  131. package/dist/cli/commands/sdk/users.d.ts.map +1 -0
  132. package/dist/cli/commands/sdk/users.js +81 -0
  133. package/dist/cli/commands/sdk/users.js.map +1 -0
  134. package/dist/cli/commands/sdk/utils/cli-utils.d.ts +35 -0
  135. package/dist/cli/commands/sdk/utils/cli-utils.d.ts.map +1 -0
  136. package/dist/cli/commands/sdk/utils/cli-utils.js +110 -0
  137. package/dist/cli/commands/sdk/utils/cli-utils.js.map +1 -0
  138. package/dist/cli/commands/sdk/utils/datasource-types.d.ts +9 -0
  139. package/dist/cli/commands/sdk/utils/datasource-types.d.ts.map +1 -0
  140. package/dist/cli/commands/sdk/utils/datasource-types.js +61 -0
  141. package/dist/cli/commands/sdk/utils/datasource-types.js.map +1 -0
  142. package/dist/cli/commands/sdk/utils/file-utils.d.ts +8 -0
  143. package/dist/cli/commands/sdk/utils/file-utils.d.ts.map +1 -0
  144. package/dist/cli/commands/sdk/utils/file-utils.js +21 -0
  145. package/dist/cli/commands/sdk/utils/file-utils.js.map +1 -0
  146. package/dist/cli/commands/sdk/utils/render.d.ts +82 -0
  147. package/dist/cli/commands/sdk/utils/render.d.ts.map +1 -0
  148. package/dist/cli/commands/sdk/utils/render.js +149 -0
  149. package/dist/cli/commands/sdk/utils/render.js.map +1 -0
  150. package/dist/cli/commands/sdk/workflows.d.ts +3 -0
  151. package/dist/cli/commands/sdk/workflows.d.ts.map +1 -0
  152. package/dist/cli/commands/sdk/workflows.js +170 -0
  153. package/dist/cli/commands/sdk/workflows.js.map +1 -0
  154. package/dist/cli/commands/setup.js +4 -0
  155. package/dist/cli/commands/setup.js.map +1 -1
  156. package/dist/cli/commands/shared/prompts/storage-scope.d.ts +2 -1
  157. package/dist/cli/commands/shared/prompts/storage-scope.d.ts.map +1 -1
  158. package/dist/cli/commands/shared/prompts/storage-scope.js +4 -3
  159. package/dist/cli/commands/shared/prompts/storage-scope.js.map +1 -1
  160. package/dist/cli/commands/skills/add.d.ts.map +1 -1
  161. package/dist/cli/commands/skills/add.js +28 -9
  162. package/dist/cli/commands/skills/add.js.map +1 -1
  163. package/dist/cli/commands/skills/lib/skills-sh-telemetry.d.ts +5 -0
  164. package/dist/cli/commands/skills/lib/skills-sh-telemetry.d.ts.map +1 -1
  165. package/dist/cli/commands/skills/lib/skills-sh-telemetry.js +22 -4
  166. package/dist/cli/commands/skills/lib/skills-sh-telemetry.js.map +1 -1
  167. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.d.ts +3 -2
  168. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.d.ts.map +1 -1
  169. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.js +29 -14
  170. package/dist/cli/commands/skills/setup/generators/claude-skill-generator.js.map +1 -1
  171. package/dist/cli/commands/skills/setup/helpers.d.ts +3 -2
  172. package/dist/cli/commands/skills/setup/helpers.d.ts.map +1 -1
  173. package/dist/cli/commands/skills/setup/helpers.js +6 -8
  174. package/dist/cli/commands/skills/setup/helpers.js.map +1 -1
  175. package/dist/cli/commands/skills/setup/index.js +8 -16
  176. package/dist/cli/commands/skills/setup/index.js.map +1 -1
  177. package/dist/cli/commands/skills/setup/sync.d.ts.map +1 -1
  178. package/dist/cli/commands/skills/setup/sync.js +6 -5
  179. package/dist/cli/commands/skills/setup/sync.js.map +1 -1
  180. package/dist/cli/commands/uninstall.d.ts.map +1 -1
  181. package/dist/cli/commands/uninstall.js +17 -0
  182. package/dist/cli/commands/uninstall.js.map +1 -1
  183. package/dist/cli/index.js +2 -0
  184. package/dist/cli/index.js.map +1 -1
  185. package/dist/env/types.d.ts +11 -4
  186. package/dist/env/types.d.ts.map +1 -1
  187. package/dist/env/types.js +5 -0
  188. package/dist/env/types.js.map +1 -1
  189. package/dist/migrations/004-skills-assistants-top-level.migration.d.ts +10 -0
  190. package/dist/migrations/004-skills-assistants-top-level.migration.d.ts.map +1 -0
  191. package/dist/migrations/004-skills-assistants-top-level.migration.js +65 -0
  192. package/dist/migrations/004-skills-assistants-top-level.migration.js.map +1 -0
  193. package/dist/migrations/005-skill-slug-format.migration.d.ts +10 -0
  194. package/dist/migrations/005-skill-slug-format.migration.d.ts.map +1 -0
  195. package/dist/migrations/005-skill-slug-format.migration.js +82 -0
  196. package/dist/migrations/005-skill-slug-format.migration.js.map +1 -0
  197. package/dist/migrations/index.d.ts +2 -0
  198. package/dist/migrations/index.d.ts.map +1 -1
  199. package/dist/migrations/index.js +2 -2
  200. package/dist/migrations/index.js.map +1 -1
  201. package/dist/providers/core/codemie-auth-helpers.d.ts +4 -1
  202. package/dist/providers/core/codemie-auth-helpers.d.ts.map +1 -1
  203. package/dist/providers/core/codemie-auth-helpers.js +21 -18
  204. package/dist/providers/core/codemie-auth-helpers.js.map +1 -1
  205. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.d.ts.map +1 -1
  206. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.js +4 -2
  207. package/dist/providers/plugins/anthropic-subscription/anthropic-subscription.setup-steps.js.map +1 -1
  208. package/dist/providers/plugins/sso/proxy/plugins/endpoint-blocker.plugin.d.ts.map +1 -1
  209. package/dist/providers/plugins/sso/proxy/plugins/endpoint-blocker.plugin.js +14 -6
  210. package/dist/providers/plugins/sso/proxy/plugins/endpoint-blocker.plugin.js.map +1 -1
  211. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts +1 -0
  212. package/dist/providers/plugins/sso/proxy/plugins/index.d.ts.map +1 -1
  213. package/dist/providers/plugins/sso/proxy/plugins/index.js +3 -0
  214. package/dist/providers/plugins/sso/proxy/plugins/index.js.map +1 -1
  215. package/dist/providers/plugins/sso/proxy/plugins/session-expiry-handler.plugin.d.ts +9 -0
  216. package/dist/providers/plugins/sso/proxy/plugins/session-expiry-handler.plugin.d.ts.map +1 -0
  217. package/dist/providers/plugins/sso/proxy/plugins/session-expiry-handler.plugin.js +23 -0
  218. package/dist/providers/plugins/sso/proxy/plugins/session-expiry-handler.plugin.js.map +1 -0
  219. package/dist/providers/plugins/sso/proxy/proxy-errors.d.ts.map +1 -1
  220. package/dist/providers/plugins/sso/proxy/proxy-errors.js +1 -2
  221. package/dist/providers/plugins/sso/proxy/proxy-errors.js.map +1 -1
  222. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts +10 -0
  223. package/dist/providers/plugins/sso/proxy/sso.proxy.d.ts.map +1 -1
  224. package/dist/providers/plugins/sso/proxy/sso.proxy.js +77 -2
  225. package/dist/providers/plugins/sso/proxy/sso.proxy.js.map +1 -1
  226. package/dist/providers/plugins/sso/session/processors/metrics/metrics-aggregator.js +1 -1
  227. package/dist/providers/plugins/sso/session/processors/metrics/metrics-aggregator.js.map +1 -1
  228. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js +2 -2
  229. package/dist/providers/plugins/sso/session/processors/metrics/metrics-api-client.js.map +1 -1
  230. package/dist/providers/plugins/sso/session/processors/metrics/metrics-sync-processor.js +1 -1
  231. package/dist/providers/plugins/sso/session/processors/metrics/metrics-sync-processor.js.map +1 -1
  232. package/dist/providers/plugins/sso/sso.auth.d.ts.map +1 -1
  233. package/dist/providers/plugins/sso/sso.auth.js +10 -2
  234. package/dist/providers/plugins/sso/sso.auth.js.map +1 -1
  235. package/dist/providers/plugins/sso/sso.setup-steps.d.ts.map +1 -1
  236. package/dist/providers/plugins/sso/sso.setup-steps.js +3 -1
  237. package/dist/providers/plugins/sso/sso.setup-steps.js.map +1 -1
  238. package/dist/utils/config.d.ts +16 -11
  239. package/dist/utils/config.d.ts.map +1 -1
  240. package/dist/utils/config.js +87 -82
  241. package/dist/utils/config.js.map +1 -1
  242. package/dist/utils/paths.d.ts +5 -0
  243. package/dist/utils/paths.d.ts.map +1 -1
  244. package/dist/utils/paths.js +14 -0
  245. package/dist/utils/paths.js.map +1 -1
  246. package/dist/utils/profile.d.ts +0 -2
  247. package/dist/utils/profile.d.ts.map +1 -1
  248. package/dist/utils/profile.js +0 -5
  249. package/dist/utils/profile.js.map +1 -1
  250. package/dist/utils/security.d.ts.map +1 -1
  251. package/dist/utils/security.js +18 -8
  252. package/dist/utils/security.js.map +1 -1
  253. package/dist/utils/slug.d.ts +2 -0
  254. package/dist/utils/slug.d.ts.map +1 -0
  255. package/dist/utils/slug.js +6 -0
  256. package/dist/utils/slug.js.map +1 -0
  257. package/package.json +4 -2
  258. package/scripts/postinstall.mjs +52 -0
@@ -0,0 +1,641 @@
1
+ ---
2
+ name: codemie-analytics
3
+ description: >
4
+ CodeMie Analytics expert — use this skill whenever the user asks about CodeMie usage data,
5
+ AI adoption metrics, user leaderboards, CLI insights, spending, LiteLLM costs, token usage,
6
+ or wants to build a dashboard/report from CodeMie or LiteLLM APIs.
7
+ Also triggers for: "who uses CodeMie most", "show me AI analytics", "get spending data",
8
+ "generate a report", "leaderboard", "cost analysis", "LiteLLM customer info",
9
+ "enrich CSV with costs", "top performers", "AI champions", "tier distribution",
10
+ or any custom analytics query against the platform.
11
+ Always use this skill when CodeMie analytics, reporting, or cost data is involved.
12
+ ---
13
+
14
+ # CodeMie Analytics Skill
15
+
16
+ You are an analytics expert for the CodeMie (EPAM AI/Run) platform. You know every analytics
17
+ API endpoint, how to call LiteLLM directly, and how to orchestrate data into a final report.
18
+
19
+ The plumbing (config lookup, SSO credential decryption, token refresh messaging) lives in
20
+ `scripts/analytics-cli.js`. You never need to touch those details — just invoke the CLI and
21
+ react to what it prints.
22
+
23
+ ---
24
+
25
+ ## Step 1 — Understand what the user wants
26
+
27
+ Identify the analytics scenario. The CLI supports these command families:
28
+
29
+ ### Leaderboard (AI Champions)
30
+
31
+ The leaderboard ranks users across **6 scoring dimensions**:
32
+ - D1: Core Platform Usage (20%) — conversations, assistant interactions
33
+ - D2: Core Platform Creation (20%) — assistants, datasources created
34
+ - D3: Workflow Usage (10%) — workflow executions
35
+ - D4: Workflow Creation (10%) — workflows authored
36
+ - D5: CLI & Agentic Engineering (30%) — coding agent sessions, tokens, repos
37
+ - D6: Impact & Knowledge (10%) — marketplace publishing, knowledge sharing
38
+
39
+ **Tiers**: pioneer (80+), expert (65+), advanced (45+), practitioner (25+), newcomer (<25)
40
+
41
+ | Scenario | Command | What it retrieves |
42
+ |----------|---------|-------------------|
43
+ | Full leaderboard (paginated, filterable) | `leaderboard` | `data.rows[]` — rank, user_name, total_score, tier_name, score_delta, `dimensions[]` (id/score/weight per D1–D6), `summary_metrics{}` (cli_sessions, active_days, total_lines_added, total_spend, web_conversations, …) |
44
+ | Leaderboard KPI summary | `leaderboard-summary` | `data` — total_users, avg_score, top_score, `tier_counts{}` (pioneer/expert/advanced/practitioner/newcomer counts and percentages) |
45
+ | Single user champion profile | `leaderboard-user <id\|email>` | `data` — same shape as a leaderboard row but for one user; includes full dimension breakdown and all summary_metrics |
46
+ | Tier distribution | `leaderboard-tiers` | `data.rows[]` — tier_name, user_count, percentage; one row per tier |
47
+ | Average dimension scores | `leaderboard-dimensions` | `data.rows[]` — dimension id/label, avg_score, weight; one row per D1–D6 |
48
+ | Top N performers | `leaderboard-top [limit]` | `data.rows[]` — same shape as `leaderboard` rows, limited to top N (max 50, default 10) |
49
+ | Score histogram | `leaderboard-scores` | `data.rows[]` — score_range (e.g. "0-10"), user_count; one row per 10-point bin |
50
+ | Framework metadata | `leaderboard-framework` | `data.framework{}` — title, principles, calculation_steps; `data.tiers[]` — name, label, min_score; `data.dimensions[]` — id, label, weight, description |
51
+ | Computation snapshots | `leaderboard-snapshots` | `data.rows[]` — snapshot_id, created_at, status, period_start, period_end, user_count |
52
+ | Available seasons | `leaderboard-seasons --view monthly\|quarterly` | `data.rows[]` — season_key (e.g. "2026-03"), label, start_date, end_date |
53
+
54
+ Leaderboard filters: `--view` (current/monthly/quarterly), `--season-key` (2026-03, 2026-Q1),
55
+ `--tier`, `--intent` (cli_focused/platform_focused/hybrid/sdlc_unicorn), `--search`, `--sort-by`, `--sort-order`.
56
+
57
+ ### CLI Insights
58
+
59
+ | Scenario | Command | What it retrieves |
60
+ |----------|---------|-------------------|
61
+ | Full CLI overview (agents, repos, tools, errors) | `cli-insights` | Composite object with sub-keys: `summary` (total sessions, cost, tokens, repos, users), `agents[]` (agent name + session count), `top_users[]`, `top_repos[]`, `errors[]`, `llms[]` |
62
+ | User classification & top spenders | `cli-insights-users` | `data.rows[]` — user_name, classification (cli_focused/platform_focused/hybrid/sdlc_unicorn), total_cost, session_count, token_count |
63
+ | Detailed single-user CLI profile | `cli-insights-user <name>` | Composite: key_metrics (sessions, cost, tokens, repos, tools), tools[], models[], repositories[], workflow_intent, category_breakdown[] |
64
+ | Project classification & top by cost | `cli-insights-projects` | `data.rows[]` — project_name, classification, total_cost, session_count, user_count |
65
+ | Usage patterns (weekday, hourly, session depth) | `cli-insights-patterns` | Composite with sub-keys: `weekday.data.rows[]` (weekday_name, session_count), `hourly.data.rows[]` (hour_utc, session_count), `session_depth.data.rows[]` (depth_bucket, count) |
66
+
67
+ ### General Analytics
68
+
69
+ | Scenario | Command | What it retrieves |
70
+ |----------|---------|-------------------|
71
+ | Overall usage summary (tokens, cost, users) | `summaries` | `data` — total_cost, total_tokens, total_requests, unique_users (MAU), unique_users_daily (DAU), cli_invocations, assistants_count, workflows_count, skills_count, mcp_servers_count |
72
+ | User list + activity trends | `users` | `data.rows[]` — user_name, email, total_cost, total_tokens, last_active; plus `activity[]` time-series |
73
+ | Per-project spending | `projects-spending` | `data.rows[]` — project_name, total_cost, total_tokens, user_count, request_count |
74
+ | Per-project activity time-series | `projects-activity` | Composite with `activity.data.rows[]` and `uniqueDaily.data.rows[]` |
75
+ | LLM model breakdown | `llms-usage` | `data.rows[]` — model_name, request_count, total_tokens, input_tokens, output_tokens, total_cost |
76
+ | Tool usage | `tools-usage` | `data.rows[]` — tool_name, invocation_count, success_count, error_count, total_tokens |
77
+ | Workflow execution analytics | `workflows` | `data.rows[]` — workflow_name, run_count, success_count, failure_count, avg_duration_ms, total_cost |
78
+ | Agent execution analytics | `agents-usage` | `data.rows[]` — assistant_name, execution_count, total_cost, total_tokens |
79
+ | Embedding model usage | `embeddings-usage` | `data.rows[]` — model_name, request_count, total_tokens, total_cost |
80
+ | Chat assistant conversations | `assistants-chats` | `data.rows[]` — assistant, conversation_count, user_count, total_cost |
81
+ | Webhook invocation analytics | `webhooks-usage` | `data.rows[]` — user_id, invocation_count, total_cost |
82
+ | MCP server usage | `mcp-servers` | `data.rows[]` — mcp_name, request_count, user_count, total_cost |
83
+ | MCP server usage by user | `mcp-servers-by-users` | `data.rows[]` — user_name, mcp_name, request_count |
84
+ | Power user analytics | `power-users` | `data.rows[]` — user_email, session_count, total_cost, features_used |
85
+ | Knowledge sharing metrics | `knowledge-sharing` | `data.rows[]` — user_email, shared_count, viewed_count |
86
+ | Top agents by usage | `top-agents` | `data.rows[]` — assistant_name, execution_count, total_cost |
87
+ | Top workflows by usage | `top-workflows` | `data.rows[]` — workflow_name, run_count, total_cost |
88
+ | Assets published to marketplace | `marketplace` | `data.rows[]` — user_email, asset_name, published_at |
89
+ | Budget alerts (soft + hard limits) | `budget` | Composite with `soft.data.rows[]` and `hard.data.rows[]` — user_email, max_spent (users approaching or over limit) |
90
+ | Personal spending & budget | `spending` | `data` — current_spend, budget_limit, hard_budget_limit, budget_reset_at, percentage_used |
91
+ | Per-user spending (platform + cli split) | `spending-by-users` | Composite with `platform.data.rows[]` and `cli.data.rows[]` — user_name/email, total_cost, token_count |
92
+ | Weekly engagement histogram | `engagement` | `data.rows[]` — day_label, hour_start, feature_type, session_count, cost; covers last 7 days in 3-hour intervals |
93
+
94
+ ### LiteLLM & CSV Enrichment
95
+
96
+ | Scenario | Command | Output |
97
+ |----------|---------|--------|
98
+ | LiteLLM customer lookup | `litellm-customer [user_id]` | JSON |
99
+ | LiteLLM spend logs | `litellm-spend` | Spend entries |
100
+ | LiteLLM virtual keys | `litellm-keys` | Key info |
101
+ | Enrich CSV/Excel with LiteLLM costs | `enrich-csv <file>` | Enriched table |
102
+ | Unlisted / experimental endpoint | `custom /v1/analytics/<path>` | Raw JSON — use a named command if one exists |
103
+
104
+ ---
105
+
106
+ ## Security
107
+
108
+ **Never include raw API keys, bearer tokens, cookie values, LiteLLM keys, or session
109
+ credentials in your responses to the user.** If CLI output contains sensitive fields
110
+ (e.g. from `litellm-keys`), the CLI automatically redacts them — but if you encounter
111
+ any token, key, or secret in raw output, redact it before displaying. Never run `env`,
112
+ `printenv`, or similar commands that could expose `LITELLM_KEY` or `CODEMIE_API_KEY`
113
+ to the conversation context.
114
+
115
+ ---
116
+
117
+ ## Step 2 — Run the analytics CLI
118
+
119
+ The CLI script lives at `scripts/analytics-cli.js` next to this skill. It handles
120
+ authentication internally. If something is wrong with credentials, it prints a clear
121
+ actionable message to stderr; pass that along to the user verbatim.
122
+
123
+ ```bash
124
+ node ${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/analytics-cli.js <command> [options]
125
+ ```
126
+
127
+ LiteLLM commands (`litellm-*`, `enrich-csv`) require `LITELLM_URL` + `LITELLM_KEY` env vars.
128
+
129
+ ### Collecting data for reports (batch pattern)
130
+
131
+ **Only fetch the data the report actually needs.** Read the user's request, identify which
132
+ sections the report requires, and collect only the relevant endpoints. Do not run every
133
+ available command — unnecessary fetches waste time and tokens.
134
+
135
+ When building an HTML report, run all needed CLI commands in a single Bash call using
136
+ `--save <filepath>` on each. This triggers one permission prompt for the entire
137
+ collection phase and keeps API responses out of the conversation context.
138
+
139
+ ### Directory layout
140
+
141
+ Every report lives in its own folder under `reports/`. Derive the folder name from the
142
+ current date and a short kebab-case description of the report:
143
+
144
+ ```
145
+ reports/
146
+ 2026-05-07-cli-usage/ ← report folder (date + name)
147
+ cli-usage.html ← the HTML report (saved here directly)
148
+ temp/ ← all temp/data files go here
149
+ summaries.json
150
+ summaries.schema.json
151
+ cli-insights.json
152
+ ...
153
+ ```
154
+
155
+ **Never overwrite an existing report folder.** Always resolve a free name before creating
156
+ anything. Use a suffix loop — this is mandatory, not optional:
157
+
158
+ ```bash
159
+ BASE=reports/$(date +%Y-%m-%d)-<short-name>
160
+ REPORT_DIR=$BASE
161
+ n=2
162
+ while [ -d "$REPORT_DIR" ]; do REPORT_DIR="${BASE}-${n}"; n=$((n+1)); done
163
+ OUT="$REPORT_DIR/temp"
164
+ ```
165
+
166
+ Then run only the commands the report needs:
167
+
168
+ ```bash
169
+ CLI=${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/analytics-cli.js
170
+ mkdir -p "$OUT" && \
171
+ node $CLI summaries --save "$OUT/summaries.json" && \
172
+ node $CLI cli-insights --save "$OUT/cli-insights.json" && \
173
+ # ... only endpoints needed for this report ...
174
+ echo "✓ All data saved → $OUT"
175
+ ```
176
+
177
+ Each command prints: `✓ Saved → <path>`. The final `echo` confirms the directory
178
+ path — save it, you will reference it in every subsequent step.
179
+
180
+ **Do not `cat`, `Read`, or print the saved JSON files into the conversation.**
181
+ Raw API responses can be hundreds of KB. Use Step 2.5 to inspect structure instead.
182
+
183
+ Temp files are not cleaned up automatically.
184
+
185
+ ### Common filter flags
186
+
187
+ | Flag | Example | Notes |
188
+ |------|---------|-------|
189
+ | `--time-period` | `last_30_days` | Predefined period |
190
+ | `--start-date` | `2024-01-01T00:00:00` | Custom range start |
191
+ | `--end-date` | `2024-03-31T23:59:59` | Custom range end |
192
+ | `--users` | `alice,bob` | Comma-separated usernames |
193
+ | `--projects` | `my-project` | Comma-separated project names |
194
+ | `--page` | `1` | Pagination |
195
+ | `--per-page` | `100` | Results per page (default 50) |
196
+ | `--output` | `json` | `json` \| `table` \| `csv` |
197
+ | `--pretty` | (flag) | Pretty-print JSON |
198
+
199
+ ### Leaderboard-specific flags
200
+
201
+ | Flag | Example | Notes |
202
+ |------|---------|-------|
203
+ | `--view` | `monthly` | `current` \| `monthly` \| `quarterly` |
204
+ | `--season-key` | `2026-Q1` | Specific season to query |
205
+ | `--tier` | `pioneer` | Filter by tier |
206
+ | `--intent` | `cli_focused` | Filter by user intent profile |
207
+ | `--search` | `john` | Partial name/email search |
208
+ | `--sort-by` | `total_score` | `rank` \| `total_score` \| `user_name` \| `tier_level` |
209
+ | `--sort-order` | `desc` | `asc` \| `desc` |
210
+ | `--limit` | `20` | Max entries for `leaderboard-top` (max 50) |
211
+
212
+ ### Example invocations
213
+
214
+ ```bash
215
+ CLI=${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/analytics-cli.js
216
+
217
+ # Full leaderboard — top 50 pioneers sorted by score
218
+ node $CLI leaderboard --tier pioneer --sort-by total_score --sort-order desc --per-page 50 --pretty
219
+
220
+ # Single user champion profile
221
+ node $CLI leaderboard-user user@example.com --pretty
222
+
223
+ # Leaderboard KPI summary for Q1 2026
224
+ node $CLI leaderboard-summary --view quarterly --season-key 2026-Q1 --pretty
225
+
226
+ # Dimension averages (D1–D6) for current snapshot
227
+ node $CLI leaderboard-dimensions --pretty
228
+
229
+ # Tier distribution
230
+ node $CLI leaderboard-tiers --pretty
231
+
232
+ # Top 10 performers
233
+ node $CLI leaderboard-top 10 --pretty
234
+
235
+ # 30-day platform summary
236
+ node $CLI summaries --time-period last_30_days --pretty
237
+
238
+ # Full CLI insights
239
+ node $CLI cli-insights --time-period last_30_days --pretty
240
+
241
+ # Detailed CLI profile for a specific user
242
+ node $CLI cli-insights-user alice@example.com --time-period last_30_days --pretty
243
+
244
+ # Usage patterns (weekday + hourly + session depth)
245
+ node $CLI cli-insights-patterns --time-period last_30_days --pretty
246
+
247
+ # Per-user spending breakdown
248
+ node $CLI spending-by-users --time-period last_30_days --pretty
249
+
250
+ # Custom endpoint
251
+ node $CLI custom /v1/analytics/mcp-servers --time-period last_30_days --pretty
252
+ ```
253
+
254
+ ---
255
+
256
+ ## Step 2.5 — Inspect data structure
257
+
258
+ After collection, run `inspect-schema.js` to generate a compact `.schema.json` file
259
+ alongside each saved JSON — one permission prompt, no data in context:
260
+
261
+ ```bash
262
+ node ${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/inspect-schema.js "$OUT"
263
+ ```
264
+
265
+ Output is a short listing of generated schema files with sizes, for example:
266
+ ```
267
+ Schemas written to: reports/2026-05-07-cli-usage/temp/
268
+ ✓ leaderboard-top.schema.json (1.3 KB)
269
+ ✓ summaries.schema.json (0.4 KB)
270
+ ...
271
+ ```
272
+
273
+ Then **read only the `.schema.json` files you actually need** for the report using the
274
+ `Read` tool. Each schema shows field names, types, array lengths, and string samples —
275
+ enough to write extraction code without touching the raw responses:
276
+
277
+ > **CRITICAL — schema is the source of truth for field names.**
278
+ > Never use field names or metric IDs from this skill's documentation when writing
279
+ > report code. Documentation can be stale. The `.schema.json` files are generated from
280
+ > live API responses and are always correct. Every `id`, key, or column name referenced
281
+ > in JS must be verified against the schema you just read — not assumed from the tables
282
+ > above. If the schema contradicts the docs, trust the schema.
283
+
284
+ ```json
285
+ {
286
+ "_envelope": "[envelope] data_as_of: '2026-05-07T02:00:10', total_count: 50",
287
+ "data": {
288
+ "rows": {
289
+ "_type": "array",
290
+ "_count": 50,
291
+ "_item": {
292
+ "rank": "number",
293
+ "user_name": "string ~ 'Jane Smith'",
294
+ "total_score": "number",
295
+ "tier_name": "string ~ 'expert'",
296
+ "score_delta": "number | null",
297
+ "dimensions": { "_type": "array", "_count": 6, "_item": { "id": "string ~ 'd1'", "score": "number", "weight": "number" } },
298
+ "summary_metrics": { "cli_sessions": "number", "active_days": "number", "total_lines_added": "number", "total_spend": "number" }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ ```
304
+
305
+ ---
306
+
307
+ ## Step 3 — Build the HTML report
308
+
309
+ **Save the HTML report directly inside `$REPORT_DIR`** (not in `temp/`).
310
+ Use a kebab-case filename matching the folder name:
311
+
312
+ ```
313
+ reports/2026-05-07-cli-usage/cli-usage.html
314
+ reports/2026-05-07-leaderboard/leaderboard.html
315
+ reports/2026-05-07-spending/spending.html
316
+ ```
317
+
318
+ ### Step 3a — Write the HTML
319
+
320
+ Invoke the **`codemie-html-report`** skill. Pass:
321
+
322
+ 1. **The schemas** inspected in Step 2.5 — field names and structure.
323
+ 2. **The user's intent** — e.g. "leaderboard dashboard with tier distribution".
324
+ 3. **Timestamp context** — `_envelope` lines in schemas include `data_as_of`.
325
+ 4. **Output path** — e.g. `$REPORT_DIR/leaderboard.html`.
326
+
327
+ The HTML skill writes the file using `/*__CSS__*/` for styles and
328
+ **`/*__DATA:name__*/` placeholders for all embedded JS data arrays**:
329
+
330
+ ```html
331
+ <script>
332
+ const LEADERBOARD = /*__DATA:leaderboard__*/;
333
+ const SUMMARIES = /*__DATA:summaries__*/;
334
+ </script>
335
+ ```
336
+
337
+ Each placeholder name maps to a saved file in `$OUT` (without the `.json` extension).
338
+
339
+ ### Step 3b — Inject data
340
+
341
+ **After the HTML file exists**, run the shared `inject-data.js` from the `codemie-html-report`
342
+ skill. It matches each JSON file in `$OUT` to a `/*__DATA:name__*/` placeholder by filename
343
+ (without `.json`) and replaces it in-place.
344
+
345
+ **Do not run inject-data.js before the HTML file is written.**
346
+
347
+ ```bash
348
+ node ${CLAUDE_PLUGIN_ROOT}/skills/codemie-html-report/scripts/inject-data.js \
349
+ "$REPORT_DIR/<report>.html" "$OUT"
350
+ ```
351
+
352
+ Placeholder names must exactly match the JSON filenames — `/*__DATA:leaderboard-top__*/`
353
+ is only replaced when `leaderboard-top.json` exists in `$OUT`.
354
+
355
+ Expected output:
356
+ ```
357
+ ✓ injected leaderboard-top
358
+ ✓ injected summaries
359
+ ✓ 2 data block(s) injected into reports/2026-05-07-<name>/<report>.html
360
+ ```
361
+
362
+ ---
363
+
364
+ ## Full API Reference
365
+
366
+ ### Leaderboard endpoints (`GET /v1/analytics/leaderboard/...`)
367
+
368
+ Admin-only. All accept `snapshot_id`, `view`, `season_key` query params.
369
+
370
+ | Endpoint | Additional Params | Returns |
371
+ |----------|------------------|---------|
372
+ | `/leaderboard/summary` | — | Total users, tier counts, top score |
373
+ | `/leaderboard/entries` | `tier`, `search`, `intent`, `sort_by`, `sort_order`, `page`, `per_page` | Paginated ranked entries |
374
+ | `/leaderboard/user/{user_id}` | path: user ID or email | Full user profile with D1–D6 breakdown |
375
+ | `/leaderboard/tiers` | — | Tier name, count, percentage |
376
+ | `/leaderboard/scores` | — | Score histogram (10-point bins) |
377
+ | `/leaderboard/dimensions` | — | Average D1–D6 scores |
378
+ | `/leaderboard/top-performers` | `limit` (default 3, max 50) | Top N by total score |
379
+ | `/leaderboard/snapshots` | `view`, `status`, `is_final`, `page`, `per_page` | Computation snapshots |
380
+ | `/leaderboard/seasons` | `view` (required: monthly/quarterly), `page`, `per_page` | Available seasonal periods |
381
+ | `/leaderboard/framework` | — | Static metadata: dimensions, tiers, intents, scoring |
382
+ | `/leaderboard/compute` (POST) | `period_days`, `view`, `season_key` | Triggers manual computation |
383
+
384
+ ### CLI Insights endpoints (`GET /v1/analytics/cli-insights-...`)
385
+
386
+ | Endpoint | Params | Returns |
387
+ |----------|--------|---------|
388
+ | `/cli-insights-weekday-pattern` | time filters | Weekday usage patterns |
389
+ | `/cli-insights-hourly-usage` | time filters | Hourly usage patterns |
390
+ | `/cli-insights-session-depth` | time filters | Session depth distribution |
391
+ | `/cli-insights-user-classification` | time filters | User classification breakdown |
392
+ | `/cli-insights-top-users-by-cost` | time filters | Top users ranked by cost |
393
+ | `/cli-insights-top-spenders` | time filters | Top spenders |
394
+ | `/cli-insights-users` | time filters | CLI user list |
395
+ | `/cli-insights-user-detail` | `user_name` (required), `user_id` | Full user detail |
396
+ | `/cli-insights-user-key-metrics` | `user_name` (required), `user_id` | User KPIs |
397
+ | `/cli-insights-user-tools` | `user_name` (required), `user_id` | User tool usage |
398
+ | `/cli-insights-user-models` | `user_name` (required), `user_id` | User model usage |
399
+ | `/cli-insights-user-workflow-intent` | `user_name` (required), `user_id` | User workflow intent |
400
+ | `/cli-insights-user-classification-detail` | `user_name` (required), `user_id` | User classification detail |
401
+ | `/cli-insights-user-category-breakdown` | `user_name` (required), `user_id` | User category breakdown |
402
+ | `/cli-insights-user-repositories` | `user_name` (required), `user_id` | User repositories |
403
+ | `/cli-insights-project-classification` | time filters | Project classification |
404
+ | `/cli-insights-top-projects-by-cost` | time filters | Top projects by cost |
405
+
406
+ ### Standard CLI analytics (`GET /v1/analytics/cli-...`)
407
+
408
+ | Endpoint | Returns |
409
+ |----------|---------|
410
+ | `/cli-summary` | CLI totals (tokens, cost, sessions) |
411
+ | `/cli-agents` | Agent breakdown |
412
+ | `/cli-llms` | Model breakdown |
413
+ | `/cli-users` | CLI user activity |
414
+ | `/cli-errors` | Error logs |
415
+ | `/cli-repositories` | Repo activity |
416
+ | `/cli-top-performers` | Top by lines added |
417
+ | `/cli-top-versions` | CLI version distribution |
418
+ | `/cli-top-proxy-endpoints` | LiteLLM endpoint usage |
419
+ | `/cli-tools` | Tool usage |
420
+
421
+ ### Dashboard analytics (`GET /v1/analytics/...`)
422
+
423
+ All accept time filters + `users` + `projects` + `page` + `per_page`.
424
+
425
+ | Endpoint | Returns |
426
+ |----------|---------|
427
+ | `/summaries` | Platform totals (tokens, cost, unique users) |
428
+ | `/users-spending` | Per-user cost + tokens |
429
+ | `/users-activity` | Activity time-series |
430
+ | `/users-unique-daily` | Unique users/day |
431
+ | `/users` | User list |
432
+ | `/projects-spending` | Per-project spending |
433
+ | `/projects-activity` | Project activity time-series |
434
+ | `/projects-unique-daily` | Unique projects/day |
435
+ | `/llms-usage` | LLM model usage |
436
+ | `/tools-usage` | Tool usage |
437
+ | `/workflows` | Workflow runs |
438
+ | `/agents-usage` | Agent executions |
439
+ | `/embeddings-usage` | Embedding model usage |
440
+ | `/assistants-chats` | Chat assistant conversations |
441
+ | `/webhooks-invocation` | Webhook usage |
442
+ | `/mcp-servers` | MCP server usage |
443
+ | `/mcp-servers-by-users` | MCP by user |
444
+ | `/power-users` | Power user analytics |
445
+ | `/knowledge-sharing` | Knowledge sharing metrics |
446
+ | `/top-agents-usage` | Top agents |
447
+ | `/top-workflow-usage` | Top workflows |
448
+ | `/published-to-marketplace` | Marketplace publishing |
449
+
450
+ ### Spending & Budget endpoints
451
+
452
+ | Endpoint | Method | Returns |
453
+ |----------|--------|---------|
454
+ | `/spending` | GET | Current user: spend, budget_limit, hard_budget_limit, reset time |
455
+ | `/budget_usage` | GET | Per-key budget rows with % used |
456
+ | `/budget-soft-limit` | GET | Soft limit warnings |
457
+ | `/budget-hard-limit` | GET | Hard limit hits |
458
+ | `/spending/by-users/platform` | GET | Per-user platform spending |
459
+ | `/spending/by-users/cli` | GET | Per-user CLI spending |
460
+
461
+ ### Engagement
462
+
463
+ | Endpoint | Method | Returns |
464
+ |----------|--------|---------|
465
+ | `/engagement/weekly-histogram` | GET | 3h intervals, last 7 days, by feature type |
466
+
467
+ ### LiteLLM endpoints (via `LITELLM_URL` + `LITELLM_KEY`)
468
+
469
+ | Endpoint | Method | Params | Description |
470
+ |----------|--------|--------|-------------|
471
+ | `/customer/info` | GET | `user_id` | Customer spend + budget + allowed models |
472
+ | `/spend/logs` | GET | `start_date`, `end_date`, `user_id` | Spend log entries |
473
+ | `/key/info` | GET | `key` | Virtual key details + spend |
474
+ | `/model/info` | GET | — | Available models |
475
+ | `/health` | GET | — | Proxy health |
476
+
477
+ ### Response envelope
478
+
479
+ Most CodeMie endpoints return:
480
+ ```json
481
+ {
482
+ "data": { ... },
483
+ "metadata": {
484
+ "timestamp": "2024-03-15T12:00:00Z",
485
+ "data_as_of": "2024-03-15T12:00:00Z",
486
+ "filters_applied": {},
487
+ "execution_time_ms": 45.2
488
+ }
489
+ }
490
+ ```
491
+
492
+ Always extract `response.data` for the actual payload.
493
+
494
+ ---
495
+
496
+ ## Custom analytics requests
497
+
498
+ For endpoints not covered by preset commands:
499
+
500
+ ```bash
501
+ node analytics-cli.js custom /v1/analytics/mcp-servers --time-period last_30_days
502
+
503
+ # POST endpoints
504
+ node analytics-cli.js custom /v1/analytics/ai-adoption-overview --method POST \
505
+ --time-period last_30_days
506
+ ```
507
+
508
+ ---
509
+
510
+ ## Offline CLI analytics (no API key needed)
511
+
512
+ The `codemie analytics` CLI command reads **local session files** from `~/.codemie/sessions/`
513
+ with no API calls:
514
+
515
+ ```bash
516
+ codemie analytics --last 7d --output json
517
+ codemie analytics --agent claude --last 30d --export csv
518
+ ```
519
+
520
+ ---
521
+
522
+ ## Report References
523
+
524
+ Reference files in `references/` describe canonical report layouts. **Always check the
525
+ relevant reference before building a new HTML report** — it defines the exact components,
526
+ charts, data structure, and modal design to use, ensuring consistency across users.
527
+
528
+ | Report type | Reference file | When to use |
529
+ |-------------|---------------|-------------|
530
+ | Leaderboard dashboard | [`${CLAUDE_PLUGIN_ROOT}/references/leaderboard-dashboard-report.md`](${CLAUDE_PLUGIN_ROOT}/references/leaderboard-dashboard-report.md) | Any request for leaderboard rankings, AI champions, top performers, tier distribution |
531
+ | People spending dashboard | [`${CLAUDE_PLUGIN_ROOT}/references/people-spending-dashboard-report.md`](${CLAUDE_PLUGIN_ROOT}/references/people-spending-dashboard-report.md) | Any request to track LiteLLM costs for a specific list of users (cohort, team, bootcamp, project) |
532
+
533
+ ---
534
+
535
+ ## Use Cases
536
+
537
+ ### Use Case: People Spending Dashboard (cohort / team / bootcamp)
538
+
539
+ **Trigger phrases**: "build a spending dashboard for people from X", "track LiteLLM costs
540
+ for a list of users", "how much did this team spend", "bootcamp spending report",
541
+ "costs for people in this CSV/Excel".
542
+
543
+ **Also applies when**: the user asks to enrich analytics with EPAM employee data, map
544
+ platform users to EPAM people, or look up user assignments/org details.
545
+
546
+ **⚠️ EPAM People & Assignments Finder — required for this use case only**
547
+
548
+ Before proceeding, verify the assistant is accessible:
549
+
550
+ ```bash
551
+ node ${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/analytics-cli.js \
552
+ custom /v1/assistants/5ca384d0-d042-480c-a0a9-d28150e2352f 2>&1 | head -5
553
+ ```
554
+
555
+ If the command returns an auth error, HTTP 401/403/404, or "No CodeMie credentials" —
556
+ **stop. Do not run anything else.** Notify the user:
557
+
558
+ > ⛔ **EPAM People & Assignments Finder** assistant is not configured on your account.
559
+ >
560
+ > **Assistant:** EPAM People & Assignments Finder
561
+ > **ID:** `5ca384d0-d042-480c-a0a9-d28150e2352f`
562
+ >
563
+ > Add it with:
564
+ > ```bash
565
+ > codemie assistants add 5ca384d0-d042-480c-a0a9-d28150e2352f
566
+ > ```
567
+ > Or open in browser and click **Add to my assistants**:
568
+ > https://codemie.lab.epam.com/#/assistants/5ca384d0-d042-480c-a0a9-d28150e2352f
569
+ >
570
+ > Once added, resume this session with:
571
+ > ```bash
572
+ > claude -f
573
+ > ```
574
+
575
+ **Full workflow** (see `${CLAUDE_PLUGIN_ROOT}/references/people-spending-dashboard-report.md` for all details):
576
+
577
+ 1. **Parse the list** from Excel/CSV using `openpyxl`. Skip header and TOTAL rows.
578
+ 2. **Fetch 3 LiteLLM accounts per user** using Python `asyncio` + `aiohttp` (semaphore 25,
579
+ `ssl=False`). Account patterns:
580
+ - Web: `email` (plain)
581
+ - CLI: `email_codemie_cli`
582
+ - Premium: `email_codemie_premium_models`
583
+ Use `end_user_id` param (not `user_id`) on `GET /customer/info`.
584
+ 3. **Save raw results** to `/tmp/` to avoid re-fetching on HTML rebuild.
585
+ 4. **Build users array** — sum three spend values, extract budget fields per account.
586
+ 5. **Fetch leaderboard** — paginate ALL pages (`--per-page 500`), ~25 pages for 12k users.
587
+ Expect ~60% of a typical cohort to appear.
588
+ 6. **Fetch CLI insights** — `cli-insights-users --per-page 500 topBySpend` for top CLI users.
589
+ Expect ~3–5% coverage for a general cohort.
590
+ 7. **Compute KPIs** — grand total, per-type totals, active user count, avg spend.
591
+ Budget projection: `avg_spend_per_active × total_users × 1.20`.
592
+ 8. **Generate HTML** — use `str.replace()` with `__TOKEN__` markers (never f-strings, which
593
+ conflict with JS `${...}` template literals).
594
+ 9. **Wire table clicks** — use `data-email` attribute + event delegation (never `onclick=""`
595
+ attributes, which break under Python quote escaping).
596
+ 10. **Save** to `reports/<date>-<name>/<name>.html` (temp/data files in `reports/<date>-<name>/temp/`).
597
+
598
+ **Key commands:**
599
+ ```bash
600
+ CLI=${CLAUDE_PLUGIN_ROOT}/skills/codemie-analytics/scripts/analytics-cli.js
601
+
602
+ # Leaderboard (run in a loop for all pages)
603
+ node $CLI leaderboard --per-page 500 --page <N> --output json
604
+
605
+ # CLI top spenders
606
+ node $CLI cli-insights-users --time-period last_30_days --per-page 500 --output json
607
+ ```
608
+
609
+ **LiteLLM fetch** requires Python (not the analytics CLI) because it needs
610
+ `LITELLM_URL` + `LITELLM_KEY` env vars and concurrent calls for 1,000+ accounts.
611
+
612
+ ---
613
+
614
+ ## Tips
615
+
616
+ - **Always run the CLI first**, capture JSON, then hand it to the report skill — don't
617
+ hardcode example data.
618
+ - If a command returns paginated data, loop through all pages or set `--per-page 500`.
619
+ - For time-series charts, use `/users-unique-daily` or `/projects-unique-daily` endpoints.
620
+ - Budget warnings: flag rows where `spend / max_budget > 0.8` (warn) and `> 1.0` (error).
621
+ - For the **leaderboard dashboard**, combine `leaderboard` + `leaderboard-summary` +
622
+ `leaderboard-tiers` + `leaderboard-dimensions` to build a comprehensive view. Then follow
623
+ `${CLAUDE_PLUGIN_ROOT}/references/leaderboard-dashboard-report.md` for the exact HTML structure.
624
+ - For a **people spending dashboard**, fetch LiteLLM directly with Python async (3 accounts
625
+ per user), then enrich with leaderboard + CLI insights. Follow
626
+ `${CLAUDE_PLUGIN_ROOT}/references/people-spending-dashboard-report.md` for the exact HTML structure.
627
+ - For a **single user deep-dive**, combine `leaderboard-user <email>` with
628
+ `cli-insights-user <name>` for the full picture (champion score + CLI activity).
629
+ - If the CLI prints an auth error, forward its message verbatim — it already tells the user
630
+ what to do next.
631
+ - Always save HTML reports to `reports/<date>-<name>/<name>.html`; temp/data files go in `reports/<date>-<name>/temp/`.
632
+
633
+ ## Type-Aware Rendering for `metrics[]` Arrays
634
+
635
+ Analytics `metrics[]` arrays are **heterogeneous** — each item carries a `type` field
636
+ (`"number"`, `"string"`, `"date"`, …) and a `format` field. The `value` is numeric for most
637
+ items but may be an ISO date string or plain string for others.
638
+
639
+ **Always inspect `m.type` (and `m.format`) per item before formatting.** Never apply a single
640
+ numeric or percent formatter to the whole array — doing so silently produces `NaN` for
641
+ string/date items.