@devness/useai 0.6.2 → 0.6.3

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 (2) hide show
  1. package/dist/index.js +32 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -684,7 +684,7 @@ var VERSION;
684
684
  var init_version = __esm({
685
685
  "../shared/dist/constants/version.js"() {
686
686
  "use strict";
687
- VERSION = "0.6.2";
687
+ VERSION = "0.6.3";
688
688
  }
689
689
  });
690
690
 
@@ -35205,18 +35205,44 @@ async function handleLocalSync(req, res) {
35205
35205
  "Content-Type": "application/json",
35206
35206
  "Authorization": `Bearer ${token}`
35207
35207
  };
35208
- const CHUNK_SIZE = 50;
35209
35208
  const sessions2 = deduplicateSessions(readJson(SESSIONS_FILE, []));
35210
- for (let i = 0; i < sessions2.length; i += CHUNK_SIZE) {
35211
- const chunk = sessions2.slice(i, i + CHUNK_SIZE);
35209
+ const byDate = /* @__PURE__ */ new Map();
35210
+ for (const s of sessions2) {
35211
+ const date3 = s.started_at.slice(0, 10);
35212
+ const arr = byDate.get(date3);
35213
+ if (arr) arr.push(s);
35214
+ else byDate.set(date3, [s]);
35215
+ }
35216
+ for (const [date3, daySessions] of byDate) {
35217
+ let totalSeconds = 0;
35218
+ const clients = {};
35219
+ const taskTypes = {};
35220
+ const languages = {};
35221
+ for (const s of daySessions) {
35222
+ totalSeconds += s.duration_seconds;
35223
+ clients[s.client] = (clients[s.client] ?? 0) + s.duration_seconds;
35224
+ taskTypes[s.task_type] = (taskTypes[s.task_type] ?? 0) + s.duration_seconds;
35225
+ for (const lang of s.languages) {
35226
+ languages[lang] = (languages[lang] ?? 0) + s.duration_seconds;
35227
+ }
35228
+ }
35229
+ const payload = {
35230
+ date: date3,
35231
+ total_seconds: totalSeconds,
35232
+ clients,
35233
+ task_types: taskTypes,
35234
+ languages,
35235
+ sessions: daySessions,
35236
+ sync_signature: ""
35237
+ };
35212
35238
  const sessionsRes = await fetch(`${USEAI_API}/api/sync`, {
35213
35239
  method: "POST",
35214
35240
  headers,
35215
- body: JSON.stringify({ sessions: chunk })
35241
+ body: JSON.stringify(payload)
35216
35242
  });
35217
35243
  if (!sessionsRes.ok) {
35218
35244
  const errBody = await sessionsRes.text();
35219
- json(res, 502, { success: false, error: `Sessions sync failed (chunk ${Math.floor(i / CHUNK_SIZE) + 1}): ${sessionsRes.status} ${errBody}` });
35245
+ json(res, 502, { success: false, error: `Sessions sync failed (${date3}): ${sessionsRes.status} ${errBody}` });
35220
35246
  return;
35221
35247
  }
35222
35248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devness/useai",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Track your AI-assisted development workflow. MCP server that records usage metrics across all your AI tools.",
5
5
  "keywords": [
6
6
  "mcp",