cc-dev-template 0.1.105 → 0.1.107
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
|
@@ -242,6 +242,12 @@ function main() {
|
|
|
242
242
|
try { state = JSON.parse(readFileSync(sessionFile, 'utf-8')); }
|
|
243
243
|
catch { process.exit(0); }
|
|
244
244
|
|
|
245
|
+
// Completed sessions should not enforce policy — clean up stale file
|
|
246
|
+
if (state.phase === 'complete') {
|
|
247
|
+
try { unlinkSync(sessionFile); } catch {}
|
|
248
|
+
process.exit(0);
|
|
249
|
+
}
|
|
250
|
+
|
|
245
251
|
const caller = input.agent_type || 'orchestrator';
|
|
246
252
|
const tool = input.tool_name;
|
|
247
253
|
const toolInput = input.tool_input || {};
|
|
@@ -21,10 +21,10 @@ const { homedir } = require('os');
|
|
|
21
21
|
// Usage API cache
|
|
22
22
|
const USAGE_CACHE_PATH = join(homedir(), '.claude', '.usage-cache.json');
|
|
23
23
|
const USAGE_LOCK_PATH = join(homedir(), '.claude', '.usage-cache.lock');
|
|
24
|
-
const USAGE_CACHE_TTL =
|
|
25
|
-
const USAGE_ERROR_TTL =
|
|
24
|
+
const USAGE_CACHE_TTL = 180000; // 3 min refresh interval (API rate limit is ~10 calls/5 min)
|
|
25
|
+
const USAGE_ERROR_TTL = 600000; // 10 min backoff on errors (rate limit recovery is slow)
|
|
26
26
|
const USAGE_LOCK_TTL = 15000; // 15s lock (curl timeout is 5s, 15s is generous)
|
|
27
|
-
const USAGE_HISTORY_MAX = 20; // ~
|
|
27
|
+
const USAGE_HISTORY_MAX = 20; // ~60 min of readings at 3 min intervals
|
|
28
28
|
|
|
29
29
|
// Background refresh mode: fetch usage data and write cache, then exit
|
|
30
30
|
if (process.argv.includes('--refresh')) {
|
|
@@ -87,8 +87,8 @@ function getUsageBurnRate(history, key) {
|
|
|
87
87
|
const newest = history[history.length - 1];
|
|
88
88
|
const minutesElapsed = (newest.t - oldest.t) / 60000;
|
|
89
89
|
|
|
90
|
-
// Need at least
|
|
91
|
-
if (minutesElapsed <
|
|
90
|
+
// Need at least 6 minutes of data for a stable reading (2 refresh cycles)
|
|
91
|
+
if (minutesElapsed < 6) return null;
|
|
92
92
|
|
|
93
93
|
const deltaUtilization = newest[key] - oldest[key];
|
|
94
94
|
return deltaUtilization / minutesElapsed;
|