@devness/useai 0.6.2 → 0.6.4
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.
- package/dist/index.js +59 -15
- 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.
|
|
687
|
+
VERSION = "0.6.4";
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
690
|
|
|
@@ -35205,24 +35205,51 @@ 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
|
-
|
|
35211
|
-
|
|
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(
|
|
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 (
|
|
35245
|
+
json(res, 502, { success: false, error: `Sessions sync failed (${date3}): ${sessionsRes.status} ${errBody}` });
|
|
35220
35246
|
return;
|
|
35221
35247
|
}
|
|
35222
35248
|
}
|
|
35249
|
+
const MILESTONE_CHUNK = 50;
|
|
35223
35250
|
const milestones = readJson(MILESTONES_FILE, []);
|
|
35224
|
-
for (let i = 0; i < milestones.length; i +=
|
|
35225
|
-
const chunk = milestones.slice(i, i +
|
|
35251
|
+
for (let i = 0; i < milestones.length; i += MILESTONE_CHUNK) {
|
|
35252
|
+
const chunk = milestones.slice(i, i + MILESTONE_CHUNK);
|
|
35226
35253
|
const milestonesRes = await fetch(`${USEAI_API}/api/publish`, {
|
|
35227
35254
|
method: "POST",
|
|
35228
35255
|
headers,
|
|
@@ -36531,14 +36558,31 @@ var init_stdio2 = __esm({
|
|
|
36531
36558
|
});
|
|
36532
36559
|
|
|
36533
36560
|
// src/index.ts
|
|
36534
|
-
var
|
|
36535
|
-
if (
|
|
36536
|
-
const args =
|
|
36561
|
+
var command = process.argv[2];
|
|
36562
|
+
if (command === "mcp" || command?.startsWith("--")) {
|
|
36563
|
+
const args = command === "mcp" ? process.argv.slice(3) : process.argv.slice(2);
|
|
36537
36564
|
const { runSetup: runSetup2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
36538
36565
|
await runSetup2(args);
|
|
36539
36566
|
process.exit(0);
|
|
36540
36567
|
}
|
|
36541
|
-
if (
|
|
36568
|
+
if (!command && process.stdin.isTTY) {
|
|
36569
|
+
const { AI_TOOLS: AI_TOOLS2 } = await Promise.resolve().then(() => (init_tools2(), tools_exports));
|
|
36570
|
+
const isInstalled = AI_TOOLS2.some((t) => {
|
|
36571
|
+
try {
|
|
36572
|
+
return t.isConfigured();
|
|
36573
|
+
} catch {
|
|
36574
|
+
return false;
|
|
36575
|
+
}
|
|
36576
|
+
});
|
|
36577
|
+
if (isInstalled) {
|
|
36578
|
+
command = "update";
|
|
36579
|
+
} else {
|
|
36580
|
+
const { runSetup: runSetup2 } = await Promise.resolve().then(() => (init_setup(), setup_exports));
|
|
36581
|
+
await runSetup2([]);
|
|
36582
|
+
process.exit(0);
|
|
36583
|
+
}
|
|
36584
|
+
}
|
|
36585
|
+
if (command === "update") {
|
|
36542
36586
|
const { default: chalk2 } = await Promise.resolve().then(() => (init_source(), source_exports));
|
|
36543
36587
|
const { fetchLatestVersion: fetchLatestVersion2, fetchDaemonHealth: fetchDaemonHealth2, killDaemon: killDaemon2, ensureDaemon: ensureDaemon2, installClaudeCodeHooks: installClaudeCodeHooks2, VERSION: VERSION3 } = await Promise.resolve().then(() => (init_dist(), dist_exports));
|
|
36544
36588
|
const { AI_TOOLS: AI_TOOLS2 } = await Promise.resolve().then(() => (init_tools2(), tools_exports));
|
|
@@ -36626,7 +36670,7 @@ if (subcommand === "update") {
|
|
|
36626
36670
|
`));
|
|
36627
36671
|
process.exit(0);
|
|
36628
36672
|
}
|
|
36629
|
-
if (
|
|
36673
|
+
if (command === "daemon") {
|
|
36630
36674
|
const { startDaemon: startDaemon2 } = await Promise.resolve().then(() => (init_daemon2(), daemon_exports));
|
|
36631
36675
|
const portArg = process.argv.indexOf("--port");
|
|
36632
36676
|
const port = portArg !== -1 ? parseInt(process.argv[portArg + 1], 10) : void 0;
|
|
@@ -36634,8 +36678,8 @@ if (subcommand === "daemon") {
|
|
|
36634
36678
|
await new Promise(() => {
|
|
36635
36679
|
});
|
|
36636
36680
|
}
|
|
36637
|
-
if (
|
|
36638
|
-
console.error(`Unknown
|
|
36681
|
+
if (command) {
|
|
36682
|
+
console.error(`Unknown command: "${command}"`);
|
|
36639
36683
|
console.error("Available commands: mcp, daemon, update");
|
|
36640
36684
|
process.exit(1);
|
|
36641
36685
|
}
|