@plexor-dev/claude-code-plugin 0.1.0-beta.8 → 0.1.0-beta.9
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/commands/plexor-status.js +80 -43
- package/commands/plexor-status.md +10 -3
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Plexor Status Command
|
|
5
|
-
* Displays formatted status with usage statistics
|
|
5
|
+
* Displays formatted status with usage statistics and ANSI colors
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const fs = require('fs');
|
|
@@ -11,6 +11,24 @@ const https = require('https');
|
|
|
11
11
|
|
|
12
12
|
const CONFIG_PATH = path.join(process.env.HOME, '.plexor', 'config.json');
|
|
13
13
|
|
|
14
|
+
// ANSI color codes
|
|
15
|
+
const c = {
|
|
16
|
+
reset: '\x1b[0m',
|
|
17
|
+
bold: '\x1b[1m',
|
|
18
|
+
dim: '\x1b[2m',
|
|
19
|
+
green: '\x1b[32m',
|
|
20
|
+
yellow: '\x1b[33m',
|
|
21
|
+
blue: '\x1b[34m',
|
|
22
|
+
magenta: '\x1b[35m',
|
|
23
|
+
cyan: '\x1b[36m',
|
|
24
|
+
white: '\x1b[37m',
|
|
25
|
+
gray: '\x1b[90m',
|
|
26
|
+
bgBlue: '\x1b[44m',
|
|
27
|
+
bgGreen: '\x1b[42m',
|
|
28
|
+
bgYellow: '\x1b[43m',
|
|
29
|
+
bgGray: '\x1b[100m',
|
|
30
|
+
};
|
|
31
|
+
|
|
14
32
|
async function main() {
|
|
15
33
|
// Read config
|
|
16
34
|
let config;
|
|
@@ -18,7 +36,7 @@ async function main() {
|
|
|
18
36
|
const data = fs.readFileSync(CONFIG_PATH, 'utf8');
|
|
19
37
|
config = JSON.parse(data);
|
|
20
38
|
} catch (err) {
|
|
21
|
-
console.log(
|
|
39
|
+
console.log(`${c.yellow}Not configured.${c.reset} Run ${c.cyan}/plexor-login${c.reset} first.`);
|
|
22
40
|
process.exit(1);
|
|
23
41
|
}
|
|
24
42
|
|
|
@@ -30,7 +48,7 @@ async function main() {
|
|
|
30
48
|
const apiUrl = config.settings?.apiUrl || 'https://api.plexor.dev';
|
|
31
49
|
|
|
32
50
|
if (!apiKey) {
|
|
33
|
-
console.log(
|
|
51
|
+
console.log(`${c.yellow}Not authenticated.${c.reset} Run ${c.cyan}/plexor-login${c.reset} first.`);
|
|
34
52
|
process.exit(1);
|
|
35
53
|
}
|
|
36
54
|
|
|
@@ -49,9 +67,9 @@ async function main() {
|
|
|
49
67
|
|
|
50
68
|
// Extract data
|
|
51
69
|
const email = user.email || 'Unknown';
|
|
52
|
-
const tierName = user.tier?.name || 'Free';
|
|
53
|
-
const monthlyOpts = user.tier?.limits?.monthly_optimizations ||
|
|
54
|
-
const monthlyComps = user.tier?.limits?.monthly_completions ||
|
|
70
|
+
const tierName = (user.tier?.name || 'Free').charAt(0).toUpperCase() + (user.tier?.name || 'free').slice(1);
|
|
71
|
+
const monthlyOpts = user.tier?.limits?.monthly_optimizations || 10000;
|
|
72
|
+
const monthlyComps = user.tier?.limits?.monthly_completions || 100000;
|
|
55
73
|
|
|
56
74
|
const period = stats.period || {};
|
|
57
75
|
const summary = stats.summary || {};
|
|
@@ -68,49 +86,68 @@ async function main() {
|
|
|
68
86
|
const formatPct = (n) => (n || 0).toFixed(1);
|
|
69
87
|
const formatCost = (n) => (n || 0).toFixed(2);
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
const
|
|
89
|
+
// Calculate usage percentages for progress bars
|
|
90
|
+
const optsUsed = summary.total_optimizations || 0;
|
|
91
|
+
const compsUsed = summary.total_completions || 0;
|
|
92
|
+
const optsPct = Math.min((optsUsed / monthlyOpts) * 100, 100);
|
|
93
|
+
const compsPct = Math.min((compsUsed / monthlyComps) * 100, 100);
|
|
94
|
+
|
|
95
|
+
// Progress bar renderer
|
|
96
|
+
const progressBar = (pct, width = 30) => {
|
|
97
|
+
const filled = Math.round((pct / 100) * width);
|
|
98
|
+
const empty = width - filled;
|
|
99
|
+
const color = pct < 50 ? c.bgBlue : pct < 80 ? c.bgYellow : c.bgGreen;
|
|
100
|
+
return `${color}${' '.repeat(filled)}${c.reset}${c.bgGray}${' '.repeat(empty)}${c.reset}`;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const status = enabled ? `${c.green}● Active${c.reset}` : `${c.gray}○ Inactive${c.reset}`;
|
|
104
|
+
const optStatus = enabled ? `${c.green}Enabled${c.reset}` : `${c.gray}Disabled${c.reset}`;
|
|
105
|
+
const cacheStatus = localCache ? `${c.green}Enabled${c.reset}` : `${c.gray}Disabled${c.reset}`;
|
|
74
106
|
const cacheRate = formatPct((summary.cache_hit_rate || 0) * 100);
|
|
75
107
|
|
|
76
108
|
// Build dashboard URL
|
|
77
109
|
const dashboardUrl = apiUrl.replace('.api.', '.').replace('/api', '') + '/dashboard.html';
|
|
78
110
|
|
|
79
|
-
//
|
|
80
|
-
const
|
|
111
|
+
// Savings highlight
|
|
112
|
+
const savingsPct = summary.cost_saved_percent || 0;
|
|
113
|
+
const savingsColor = savingsPct > 50 ? c.green : savingsPct > 20 ? c.yellow : c.white;
|
|
81
114
|
|
|
82
115
|
console.log(`
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
${
|
|
87
|
-
${
|
|
88
|
-
${
|
|
89
|
-
|
|
90
|
-
${
|
|
91
|
-
${
|
|
92
|
-
${
|
|
93
|
-
${
|
|
94
|
-
${
|
|
95
|
-
${
|
|
96
|
-
${
|
|
97
|
-
${
|
|
98
|
-
|
|
99
|
-
${
|
|
100
|
-
${
|
|
101
|
-
|
|
102
|
-
${
|
|
103
|
-
|
|
104
|
-
${
|
|
105
|
-
|
|
106
|
-
${
|
|
107
|
-
|
|
108
|
-
${
|
|
109
|
-
${
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
${c.bold}${c.cyan}Plexor Status${c.reset}
|
|
117
|
+
|
|
118
|
+
${c.bold}Account${c.reset}
|
|
119
|
+
${c.gray}Tier:${c.reset} ${c.cyan}${tierName}${c.reset}
|
|
120
|
+
${c.gray}Email:${c.reset} ${email}
|
|
121
|
+
${c.gray}Status:${c.reset} ${status}
|
|
122
|
+
|
|
123
|
+
${c.bold}This Week${c.reset} ${c.dim}(${weekRange})${c.reset}
|
|
124
|
+
${c.gray}Requests:${c.reset} ${formatNum(summary.total_requests)}
|
|
125
|
+
${c.gray}Original tokens:${c.reset} ${formatNum(summary.original_tokens)}
|
|
126
|
+
${c.gray}Optimized tokens:${c.reset} ${formatNum(summary.optimized_tokens)}
|
|
127
|
+
${c.gray}Tokens saved:${c.reset} ${c.green}${formatNum(summary.tokens_saved)}${c.reset} ${c.dim}(${formatPct(summary.tokens_saved_percent)}%)${c.reset}
|
|
128
|
+
${c.gray}Baseline cost:${c.reset} $${formatCost(summary.baseline_cost)}
|
|
129
|
+
${c.gray}Actual cost:${c.reset} $${formatCost(summary.total_cost)}
|
|
130
|
+
${c.gray}Cost saved:${c.reset} ${savingsColor}$${formatCost(summary.cost_saved)}${c.reset} ${c.dim}(${formatPct(savingsPct)}%)${c.reset}
|
|
131
|
+
|
|
132
|
+
${c.bold}Usage Limits${c.reset}
|
|
133
|
+
${c.gray}Optimizations${c.reset}
|
|
134
|
+
${progressBar(optsPct)} ${formatPct(optsPct)}% used
|
|
135
|
+
${c.dim}${formatNum(optsUsed)} / ${formatNum(monthlyOpts)} this month${c.reset}
|
|
136
|
+
|
|
137
|
+
${c.gray}Completions${c.reset}
|
|
138
|
+
${progressBar(compsPct)} ${formatPct(compsPct)}% used
|
|
139
|
+
${c.dim}${formatNum(compsUsed)} / ${formatNum(monthlyComps)} this month${c.reset}
|
|
140
|
+
|
|
141
|
+
${c.bold}Performance${c.reset}
|
|
142
|
+
${c.gray}Cache hit rate:${c.reset} ${cacheRate}%
|
|
143
|
+
|
|
144
|
+
${c.bold}Settings${c.reset}
|
|
145
|
+
${c.gray}Optimization:${c.reset} ${optStatus}
|
|
146
|
+
${c.gray}Local cache:${c.reset} ${cacheStatus}
|
|
147
|
+
${c.gray}Mode:${c.reset} ${c.cyan}${mode}${c.reset}
|
|
148
|
+
${c.gray}Provider routing:${c.reset} ${c.cyan}${provider}${c.reset}
|
|
149
|
+
|
|
150
|
+
${c.dim}Dashboard:${c.reset} ${c.blue}${dashboardUrl}${c.reset}
|
|
114
151
|
`);
|
|
115
152
|
}
|
|
116
153
|
|
|
@@ -150,6 +187,6 @@ function fetchJson(apiUrl, endpoint, apiKey) {
|
|
|
150
187
|
}
|
|
151
188
|
|
|
152
189
|
main().catch(err => {
|
|
153
|
-
console.error(
|
|
190
|
+
console.error(`${c.red}Error:${c.reset} ${err.message}`);
|
|
154
191
|
process.exit(1);
|
|
155
192
|
});
|
|
@@ -4,14 +4,21 @@ description: Show Plexor optimization statistics and savings (user)
|
|
|
4
4
|
|
|
5
5
|
# Plexor Status
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Display Plexor optimization statistics with colors and progress bars.
|
|
8
8
|
|
|
9
9
|
## Instructions
|
|
10
10
|
|
|
11
|
-
Run the
|
|
11
|
+
Run the status script and show its output:
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
14
|
node ~/.claude/plugins/plexor/commands/plexor-status.js
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The script outputs colored terminal UI with:
|
|
18
|
+
- Account info and status
|
|
19
|
+
- Weekly usage statistics
|
|
20
|
+
- Progress bars for usage limits
|
|
21
|
+
- Cost savings breakdown
|
|
22
|
+
- Current settings
|
|
23
|
+
|
|
24
|
+
Do not add commentary - the script output is the complete response.
|
package/package.json
CHANGED