usagemax 0.3.1 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "usagemax",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Link local coding-agent usage to your UsageMax profile",
5
5
  "license": "MIT",
6
6
  "author": "UsageMax",
package/src/cli.js CHANGED
@@ -10,7 +10,7 @@ import process from "node:process";
10
10
  import { promisify } from "node:util";
11
11
 
12
12
  import { prepareArchiveRecovery } from "./archives.js";
13
- import { buildSessionPlan, buildSnapshotPlan, normalizeLinkCode, scanPolicy, sourceSummary, validHttpsUrl } from "./core.js";
13
+ import { buildSessionPlan, buildSnapshotPlan, normalizeLinkCode, reportDateArgs, scanPolicy, sourceSummary, validHttpsUrl } from "./core.js";
14
14
  import { stableInstallationId } from "./installation.js";
15
15
  import { requestSnapshot } from "./transport.js";
16
16
  import { resumeUpload, restartExpiredUpload, withConfigLock } from "./resume.js";
@@ -18,7 +18,7 @@ import { CCUSAGE_VERSION, ccusageEnvironment, ccusageHome, discoverProviderArchi
18
18
 
19
19
  const require = createRequire(import.meta.url);
20
20
  const executeFile = promisify(execFile);
21
- const VERSION = "0.3.1";
21
+ const VERSION = "0.3.2";
22
22
  const PUBLIC_API_ORIGIN = "https://usagemax.com/api";
23
23
  const DEFAULT_LINK_ENDPOINT = `${PUBLIC_API_ORIGIN}/v1/devices/link`;
24
24
  const CONFIG_FILE = "config.json";
@@ -123,12 +123,7 @@ async function ccusageJson(config, { full = false, env } = {}) {
123
123
  // Reconcile yesterday once after the UTC date changes. All other incremental
124
124
  // scans parse only today; a metadata fingerprint avoids invoking ccusage when
125
125
  // no supported local source changed at all.
126
- if (full) {
127
- args.push("--since", "2024-01-01", "--until", new Date().toISOString().slice(0, 10));
128
- } else if (config?.lastSyncAt) {
129
- const today = new Date().toISOString().slice(0, 10);
130
- args.push("--last", config.lastReconciledDay === today ? "1" : "2");
131
- }
126
+ args.push(...reportDateArgs(config, { full }));
132
127
  const { stdout } = await executeFile(process.execPath, args, {
133
128
  encoding: "utf8",
134
129
  maxBuffer: MAX_REPORT_BYTES,
package/src/core.js CHANGED
@@ -427,3 +427,11 @@ export function sourceSummary(report) {
427
427
  });
428
428
  return [...new Set(sources)].sort();
429
429
  }
430
+ // Explicit UTC dates work with ccusage's combined daily/session sections.
431
+ export function reportDateArgs(config, { full = false, now = Date.now() } = {}) {
432
+ const today = new Date(now).toISOString().slice(0, 10);
433
+ const since = full || !config?.lastSyncAt ? "2024-01-01"
434
+ : config.lastReconciledDay === today ? today
435
+ : new Date(Date.parse(today + "T00:00:00Z") - 86_400_000).toISOString().slice(0, 10);
436
+ return ["--since", since, "--until", today];
437
+ }