@simonesiega/codex-limits 0.1.1 → 0.1.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/dist/cli.js +1 -1
- package/dist/index.js +39 -25
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -41481,7 +41481,7 @@ var init_app = __esm(async () => {
|
|
|
41481
41481
|
// package.json
|
|
41482
41482
|
var package_default = {
|
|
41483
41483
|
name: "@simonesiega/codex-limits",
|
|
41484
|
-
version: "0.1.
|
|
41484
|
+
version: "0.1.2",
|
|
41485
41485
|
description: "Check Codex usage limits, reset times, and reset-credit coupons from a fast, read-only terminal dashboard.",
|
|
41486
41486
|
type: "module",
|
|
41487
41487
|
bin: {
|
package/dist/index.js
CHANGED
|
@@ -1021,33 +1021,47 @@ var DESCRIPTION = "Check Codex limits, resets, and credits.";
|
|
|
1021
1021
|
var module = {
|
|
1022
1022
|
id: "codex-limits",
|
|
1023
1023
|
tui: async (api) => {
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
slash: { name: "codex-limits" },
|
|
1031
|
-
onSelect: async (dialog) => {
|
|
1032
|
-
dialog?.clear();
|
|
1033
|
-
api.ui.dialog.clear();
|
|
1034
|
-
await nextFrame();
|
|
1035
|
-
const target = api.ui.dialog;
|
|
1036
|
-
target.setSize("large");
|
|
1037
|
-
target.replace(() => alert(api, "Loading Codex limits..."));
|
|
1038
|
-
try {
|
|
1039
|
-
const result = await getCodexLimits();
|
|
1040
|
-
target.replace(() => alert(api, formatOpencodeLimits(result)));
|
|
1041
|
-
} catch (error) {
|
|
1042
|
-
const message = error instanceof Error ? error.message : "Could not load Codex limits.";
|
|
1043
|
-
api.ui.toast({ variant: "error", title: TITLE, message });
|
|
1044
|
-
target.replace(() => alert(api, message));
|
|
1045
|
-
}
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
]);
|
|
1024
|
+
const command = createCommand(api);
|
|
1025
|
+
const registration = registerCommandLayer(api, command);
|
|
1026
|
+
const dispose = registration.registered ? registration.dispose : api.command?.register(() => [command]);
|
|
1027
|
+
if (dispose) {
|
|
1028
|
+
api.lifecycle.onDispose(dispose);
|
|
1029
|
+
}
|
|
1049
1030
|
}
|
|
1050
1031
|
};
|
|
1032
|
+
function createCommand(api) {
|
|
1033
|
+
return {
|
|
1034
|
+
title: TITLE,
|
|
1035
|
+
value: "codex-limits.show",
|
|
1036
|
+
description: DESCRIPTION,
|
|
1037
|
+
category: "Codex",
|
|
1038
|
+
slash: { name: "codex-limits" },
|
|
1039
|
+
onSelect: async (dialog) => {
|
|
1040
|
+
dialog?.clear();
|
|
1041
|
+
api.ui.dialog.clear();
|
|
1042
|
+
await nextFrame();
|
|
1043
|
+
const target = api.ui.dialog;
|
|
1044
|
+
target.setSize("large");
|
|
1045
|
+
target.replace(() => alert(api, "Loading Codex limits..."));
|
|
1046
|
+
try {
|
|
1047
|
+
const result = await getCodexLimits();
|
|
1048
|
+
target.replace(() => alert(api, formatOpencodeLimits(result)));
|
|
1049
|
+
} catch (error) {
|
|
1050
|
+
const message = error instanceof Error ? error.message : "Could not load Codex limits.";
|
|
1051
|
+
api.ui.toast({ variant: "error", title: TITLE, message });
|
|
1052
|
+
target.replace(() => alert(api, message));
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
};
|
|
1056
|
+
}
|
|
1057
|
+
function registerCommandLayer(api, command) {
|
|
1058
|
+
const keymap = api.keymap;
|
|
1059
|
+
if (!keymap.registerLayer) {
|
|
1060
|
+
return { registered: false };
|
|
1061
|
+
}
|
|
1062
|
+
const dispose = keymap.registerLayer?.({ commands: [command], bindings: [] });
|
|
1063
|
+
return typeof dispose === "function" ? { registered: true, dispose } : { registered: true };
|
|
1064
|
+
}
|
|
1051
1065
|
function alert(api, message) {
|
|
1052
1066
|
return api.ui.DialogAlert({ title: TITLE, message });
|
|
1053
1067
|
}
|
package/package.json
CHANGED