cc-dev-template 0.1.101 → 0.1.102
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
|
@@ -20,8 +20,8 @@ const { homedir } = require('os');
|
|
|
20
20
|
|
|
21
21
|
// Usage API cache
|
|
22
22
|
const USAGE_CACHE_PATH = join(homedir(), '.claude', '.usage-cache.json');
|
|
23
|
-
const USAGE_CACHE_TTL =
|
|
24
|
-
const USAGE_HISTORY_MAX = 20; // ~
|
|
23
|
+
const USAGE_CACHE_TTL = 120000; // 2 minutes
|
|
24
|
+
const USAGE_HISTORY_MAX = 20; // ~40 min of readings at 2min intervals
|
|
25
25
|
|
|
26
26
|
// Background refresh mode: fetch usage data and write cache, then exit
|
|
27
27
|
if (process.argv.includes('--refresh')) {
|
|
@@ -373,6 +373,13 @@ function getUsageData() {
|
|
|
373
373
|
|
|
374
374
|
// Trigger background refresh if cache is stale
|
|
375
375
|
if (cacheAge > USAGE_CACHE_TTL) {
|
|
376
|
+
// Optimistic lock: claim the timestamp so other sessions see fresh cache
|
|
377
|
+
try {
|
|
378
|
+
const raw = readFileSync(USAGE_CACHE_PATH, 'utf-8');
|
|
379
|
+
const cache = JSON.parse(raw);
|
|
380
|
+
cache.timestamp = Date.now();
|
|
381
|
+
writeFileSync(USAGE_CACHE_PATH, JSON.stringify(cache));
|
|
382
|
+
} catch {}
|
|
376
383
|
try {
|
|
377
384
|
const child = spawn(process.execPath, [__filename, '--refresh'], {
|
|
378
385
|
detached: true,
|