@tickrmeter/ai-usage 0.1.0 → 0.1.1
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/claude.js +15 -2
- package/dist/storage.js +1 -1
- package/package.json +1 -1
package/dist/claude.js
CHANGED
|
@@ -41,7 +41,19 @@ const finitePercent = (value) => typeof value === "number" && Number.isFinite(va
|
|
|
41
41
|
const resetIso = (value) => {
|
|
42
42
|
if (typeof value !== "string" && typeof value !== "number")
|
|
43
43
|
return undefined;
|
|
44
|
-
const
|
|
44
|
+
const normalized = typeof value === "string" ? value.trim() : value;
|
|
45
|
+
if (normalized === "")
|
|
46
|
+
return undefined;
|
|
47
|
+
const numeric = typeof normalized === "number" ? normalized : Number(normalized);
|
|
48
|
+
const isNumericTimestamp = Number.isFinite(numeric) && /^\d+(\.\d+)?$/.test(String(normalized));
|
|
49
|
+
let date = isNumericTimestamp
|
|
50
|
+
? new Date(numeric < 10_000_000_000 ? numeric * 1000 : numeric)
|
|
51
|
+
: new Date(normalized);
|
|
52
|
+
// Versions before 0.1.1 interpreted Unix seconds as milliseconds and
|
|
53
|
+
// persisted a 1970 ISO date. Recover that timestamp during the next sync.
|
|
54
|
+
if (!isNumericTimestamp && date.getTime() >= 1_000_000_000 && date.getTime() < 10_000_000_000) {
|
|
55
|
+
date = new Date(date.getTime() * 1000);
|
|
56
|
+
}
|
|
45
57
|
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
|
|
46
58
|
};
|
|
47
59
|
const extractClaudeSnapshot = (input, capturedAt = new Date()) => {
|
|
@@ -80,7 +92,8 @@ const readClaudeCapture = () => {
|
|
|
80
92
|
const snapshot = (0, storage_1.readJson)((0, storage_1.getClaudeCapturePath)());
|
|
81
93
|
if (!snapshot || snapshot.source !== "claude" || Number.isNaN(Date.parse(snapshot.capturedAt)))
|
|
82
94
|
return null;
|
|
83
|
-
|
|
95
|
+
const windows = snapshot.windows?.map((window) => ({ ...window, resetsAt: resetIso(window.resetsAt) }));
|
|
96
|
+
return { ...snapshot, windows, stale: Date.now() - Date.parse(snapshot.capturedAt) > 60 * 60 * 1000 };
|
|
84
97
|
};
|
|
85
98
|
exports.readClaudeCapture = readClaudeCapture;
|
|
86
99
|
const quote = (value) => `"${value.replace(/"/g, '\\"')}"`;
|
package/dist/storage.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.removeLocalBridgeCredential = exports.installFixedCliCopy = exports.writ
|
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
|
-
exports.CLI_VERSION = "0.1.
|
|
10
|
+
exports.CLI_VERSION = "0.1.1";
|
|
11
11
|
const getDataDir = () => process.env.TICKRMETER_AI_HOME || path_1.default.join(os_1.default.homedir(), ".tickrmeter-ai");
|
|
12
12
|
exports.getDataDir = getDataDir;
|
|
13
13
|
const getConfigPath = () => path_1.default.join((0, exports.getDataDir)(), "config.json");
|