@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.
@@ -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('Not configured. Run /plexor-login first.');
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('Not authenticated. Run /plexor-login first.');
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
- const status = enabled ? '● Active' : '○ Inactive';
72
- const optEnabled = enabled ? 'Enabled' : 'Disabled';
73
- const cacheEnabled = localCache ? 'Enabled' : 'Disabled';
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
- // Output formatted status - each line is exactly 43 chars inner width
80
- const line = (content) => ` │ ${content.padEnd(43)}│`;
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
- ${line('Plexor Status')}
85
- ├─────────────────────────────────────────────┤
86
- ${line(`Account: ${tierName}`)}
87
- ${line(`Email: ${email}`)}
88
- ${line(`Status: ${status}`)}
89
- ├─────────────────────────────────────────────┤
90
- ${line(`This Week (${weekRange})`)}
91
- ${line(`├── Requests: ${formatNum(summary.total_requests)}`)}
92
- ${line(`├── Original tokens: ${formatNum(summary.original_tokens)}`)}
93
- ${line(`├── Optimized tokens: ${formatNum(summary.optimized_tokens)}`)}
94
- ${line(`├── Tokens saved: ${formatNum(summary.tokens_saved)} (${formatPct(summary.tokens_saved_percent)}%)`)}
95
- ${line(`├── Baseline cost: $${formatCost(summary.baseline_cost)}`)}
96
- ${line(`├── Actual cost: $${formatCost(summary.total_cost)}`)}
97
- ${line(`└── Cost saved: $${formatCost(summary.cost_saved)} (${formatPct(summary.cost_saved_percent)}%)`)}
98
- ├─────────────────────────────────────────────┤
99
- ${line('Performance')}
100
- ${line(`└── Cache hit rate: ${cacheRate}%`)}
101
- ├─────────────────────────────────────────────┤
102
- ${line('Limits')}
103
- ${line(`├── Monthly optimizations: ${formatNum(monthlyOpts)}`)}
104
- ${line(`└── Monthly completions: ${formatNum(monthlyComps)}`)}
105
- ├─────────────────────────────────────────────┤
106
- ${line('Settings')}
107
- ${line(`├── Optimization: ${optEnabled}`)}
108
- ${line(`├── Local cache: ${cacheEnabled}`)}
109
- ${line(`├── Mode: ${mode}`)}
110
- ${line(`└── Provider routing: ${provider}`)}
111
- └─────────────────────────────────────────────┘
112
-
113
- Dashboard: ${dashboardUrl}
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('Error:', err.message);
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
- Show current Plexor proxy status, configuration, and usage statistics.
7
+ Display Plexor optimization statistics with colors and progress bars.
8
8
 
9
9
  ## Instructions
10
10
 
11
- Run the plexor-status script and display its output directly to the user:
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
- Do not add any additional commentary - just show the script output.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plexor-dev/claude-code-plugin",
3
- "version": "0.1.0-beta.8",
3
+ "version": "0.1.0-beta.9",
4
4
  "description": "LLM cost optimization plugin for Claude Code - Save up to 90% on AI costs",
5
5
  "main": "lib/constants.js",
6
6
  "scripts": {