@plexor-dev/claude-code-plugin-staging 0.1.0-beta.2 → 0.1.0-beta.21
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/README.md +4 -7
- package/commands/plexor-agent.js +84 -0
- package/commands/plexor-agent.md +36 -0
- package/commands/plexor-enabled.js +177 -18
- package/commands/plexor-enabled.md +31 -13
- package/commands/plexor-login.js +212 -43
- package/commands/plexor-login.md +4 -21
- package/commands/plexor-logout.js +72 -14
- package/commands/plexor-logout.md +2 -20
- package/commands/plexor-provider.js +62 -81
- package/commands/plexor-provider.md +23 -13
- package/commands/plexor-routing.js +77 -0
- package/commands/plexor-routing.md +37 -0
- package/commands/plexor-settings.js +161 -123
- package/commands/plexor-settings.md +38 -14
- package/commands/plexor-setup.js +253 -0
- package/commands/plexor-setup.md +16 -160
- package/commands/plexor-status.js +252 -24
- package/commands/plexor-status.md +1 -13
- package/commands/plexor-uninstall.js +319 -0
- package/commands/plexor-uninstall.md +12 -0
- package/hooks/intercept.js +211 -32
- package/hooks/track-response.js +302 -2
- package/lib/config-utils.js +314 -0
- package/lib/config.js +22 -3
- package/lib/constants.js +19 -1
- package/lib/logger.js +64 -5
- package/lib/settings-manager.js +233 -24
- package/lib/verify-route.js +84 -0
- package/package.json +6 -4
- package/scripts/postinstall.js +271 -44
- package/scripts/uninstall.js +194 -41
- package/commands/plexor-config.js +0 -170
- package/commands/plexor-config.md +0 -28
- package/commands/plexor-mode.js +0 -107
- package/commands/plexor-mode.md +0 -27
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plexor Config Command
|
|
5
|
-
* Display raw configuration (for debugging)
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
const CONFIG_PATH = path.join(process.env.HOME, '.plexor', 'config.json');
|
|
12
|
-
const SESSION_PATH = path.join(process.env.HOME, '.plexor', 'session.json');
|
|
13
|
-
const CACHE_PATH = path.join(process.env.HOME, '.plexor', 'cache.json');
|
|
14
|
-
const PLEXOR_DIR = path.join(process.env.HOME, '.plexor');
|
|
15
|
-
|
|
16
|
-
function fileExists(filePath) {
|
|
17
|
-
try {
|
|
18
|
-
return fs.existsSync(filePath);
|
|
19
|
-
} catch {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function getFileSize(filePath) {
|
|
25
|
-
try {
|
|
26
|
-
const stats = fs.statSync(filePath);
|
|
27
|
-
return stats.size;
|
|
28
|
-
} catch {
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function formatBytes(bytes) {
|
|
34
|
-
if (bytes === 0) return '0 B';
|
|
35
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
36
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
37
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function loadConfig() {
|
|
41
|
-
try {
|
|
42
|
-
if (!fs.existsSync(CONFIG_PATH)) {
|
|
43
|
-
return { error: 'not_found', message: 'Config file does not exist' };
|
|
44
|
-
}
|
|
45
|
-
const data = fs.readFileSync(CONFIG_PATH, 'utf8');
|
|
46
|
-
return { config: JSON.parse(data) };
|
|
47
|
-
} catch (err) {
|
|
48
|
-
if (err.code === 'ENOENT') {
|
|
49
|
-
return { error: 'not_found', message: 'Config file does not exist' };
|
|
50
|
-
}
|
|
51
|
-
if (err.code === 'EACCES') {
|
|
52
|
-
return { error: 'permission', message: 'Permission denied reading config' };
|
|
53
|
-
}
|
|
54
|
-
if (err instanceof SyntaxError) {
|
|
55
|
-
return { error: 'invalid_json', message: 'Config file contains invalid JSON' };
|
|
56
|
-
}
|
|
57
|
-
return { error: 'unknown', message: err.message };
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function maskApiKey(key) {
|
|
62
|
-
if (!key) return 'not set';
|
|
63
|
-
if (key.length <= 12) return '***masked***';
|
|
64
|
-
return key.substring(0, 8) + '...' + key.substring(key.length - 4);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function main() {
|
|
68
|
-
const args = process.argv.slice(2);
|
|
69
|
-
const showRaw = args.includes('--raw') || args.includes('-r');
|
|
70
|
-
const showPaths = args.includes('--paths') || args.includes('-p');
|
|
71
|
-
|
|
72
|
-
// Show paths only
|
|
73
|
-
if (showPaths) {
|
|
74
|
-
console.log(`┌─────────────────────────────────────────────┐`);
|
|
75
|
-
console.log(`│ Plexor File Paths │`);
|
|
76
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
77
|
-
console.log(`│ Directory: ${PLEXOR_DIR.substring(0, 31).padEnd(31)}│`);
|
|
78
|
-
console.log(`│ Config: ${CONFIG_PATH.substring(0, 34).padEnd(34)}│`);
|
|
79
|
-
console.log(`│ Session: ${SESSION_PATH.substring(0, 33).padEnd(33)}│`);
|
|
80
|
-
console.log(`│ Cache: ${CACHE_PATH.substring(0, 35).padEnd(35)}│`);
|
|
81
|
-
console.log(`└─────────────────────────────────────────────┘`);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const result = loadConfig();
|
|
86
|
-
|
|
87
|
-
if (result.error) {
|
|
88
|
-
const errorMessages = {
|
|
89
|
-
not_found: 'Config file does not exist',
|
|
90
|
-
permission: 'Permission denied reading config file',
|
|
91
|
-
invalid_json: 'Config file contains invalid JSON (corrupted?)',
|
|
92
|
-
unknown: result.message || 'Unknown error'
|
|
93
|
-
};
|
|
94
|
-
const errorMsg = errorMessages[result.error] || result.message;
|
|
95
|
-
const suggestion = result.error === 'invalid_json'
|
|
96
|
-
? 'Try: rm ~/.plexor/config.json && /plexor-login'
|
|
97
|
-
: 'Run /plexor-login to create configuration.';
|
|
98
|
-
|
|
99
|
-
console.log(`┌─────────────────────────────────────────────┐`);
|
|
100
|
-
console.log(`│ Configuration Error │`);
|
|
101
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
102
|
-
console.log(`│ Error: ${result.error.padEnd(35)}│`);
|
|
103
|
-
console.log(`│ ${errorMsg.substring(0, 42).padEnd(42)}│`);
|
|
104
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
105
|
-
console.log(`│ ${suggestion.substring(0, 42).padEnd(42)}│`);
|
|
106
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
107
|
-
console.log(`│ Expected path: │`);
|
|
108
|
-
console.log(`│ ${CONFIG_PATH.substring(0, 42).padEnd(42)}│`);
|
|
109
|
-
console.log(`└─────────────────────────────────────────────┘`);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const config = result.config;
|
|
114
|
-
|
|
115
|
-
// Show raw JSON
|
|
116
|
-
if (showRaw) {
|
|
117
|
-
// Mask API key in raw output
|
|
118
|
-
const safeConfig = JSON.parse(JSON.stringify(config));
|
|
119
|
-
if (safeConfig.auth?.api_key) {
|
|
120
|
-
safeConfig.auth.api_key = maskApiKey(safeConfig.auth.api_key);
|
|
121
|
-
}
|
|
122
|
-
console.log(JSON.stringify(safeConfig, null, 2));
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Show formatted config info
|
|
127
|
-
const configSize = getFileSize(CONFIG_PATH);
|
|
128
|
-
const sessionSize = getFileSize(SESSION_PATH);
|
|
129
|
-
const cacheSize = getFileSize(CACHE_PATH);
|
|
130
|
-
const hasSession = fileExists(SESSION_PATH);
|
|
131
|
-
const hasCache = fileExists(CACHE_PATH);
|
|
132
|
-
|
|
133
|
-
console.log(`┌─────────────────────────────────────────────┐`);
|
|
134
|
-
console.log(`│ Plexor Configuration │`);
|
|
135
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
136
|
-
console.log(`│ Version: ${(config.version || 1).toString().padEnd(33)}│`);
|
|
137
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
138
|
-
console.log(`│ Authentication │`);
|
|
139
|
-
console.log(`│ └── API Key: ${maskApiKey(config.auth?.api_key).padEnd(29)}│`);
|
|
140
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
141
|
-
console.log(`│ Settings │`);
|
|
142
|
-
|
|
143
|
-
const settings = config.settings || {};
|
|
144
|
-
const settingEntries = [
|
|
145
|
-
['enabled', settings.enabled ?? false],
|
|
146
|
-
['mode', settings.mode || 'balanced'],
|
|
147
|
-
['preferred_provider', settings.preferred_provider || 'auto'],
|
|
148
|
-
['apiUrl', settings.apiUrl || 'https://api.plexor.dev'],
|
|
149
|
-
['timeout', (settings.timeout || 5000) + 'ms'],
|
|
150
|
-
['localCacheEnabled', settings.localCacheEnabled ?? false]
|
|
151
|
-
];
|
|
152
|
-
|
|
153
|
-
for (const [key, value] of settingEntries) {
|
|
154
|
-
const displayValue = String(value).substring(0, 25);
|
|
155
|
-
console.log(`│ ├── ${key.padEnd(18)} ${displayValue.padEnd(18)}│`);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
159
|
-
console.log(`│ Files │`);
|
|
160
|
-
console.log(`│ ├── config.json: ${formatBytes(configSize).padEnd(24)}│`);
|
|
161
|
-
console.log(`│ ├── session.json: ${(hasSession ? formatBytes(sessionSize) : 'not found').padEnd(23)}│`);
|
|
162
|
-
console.log(`│ └── cache.json: ${(hasCache ? formatBytes(cacheSize) : 'not found').padEnd(25)}│`);
|
|
163
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
164
|
-
console.log(`│ Options: │`);
|
|
165
|
-
console.log(`│ /plexor-config --raw Show raw JSON │`);
|
|
166
|
-
console.log(`│ /plexor-config --paths Show file paths │`);
|
|
167
|
-
console.log(`└─────────────────────────────────────────────┘`);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
main();
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Configure Plexor settings (user)
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Plexor Config
|
|
6
|
-
|
|
7
|
-
Run this command to view configuration details:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
node ~/.claude/plugins/plexor/commands/plexor-config.js
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Options:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
node ~/.claude/plugins/plexor/commands/plexor-config.js --raw # Show raw JSON
|
|
17
|
-
node ~/.claude/plugins/plexor/commands/plexor-config.js --paths # Show file paths
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Use the Bash tool to execute this command.
|
|
21
|
-
|
|
22
|
-
**IMPORTANT**: After running this command and displaying the output, STOP. Do not:
|
|
23
|
-
- Read any files
|
|
24
|
-
- Explore the codebase
|
|
25
|
-
- Run additional commands
|
|
26
|
-
- Ask follow-up questions
|
|
27
|
-
|
|
28
|
-
The command output is the complete response. Simply show the output and wait for the user's next input.
|
package/commands/plexor-mode.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Plexor Mode Command
|
|
5
|
-
* Set optimization mode: eco, balanced, quality, passthrough
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const path = require('path');
|
|
10
|
-
|
|
11
|
-
const CONFIG_PATH = path.join(process.env.HOME, '.plexor', 'config.json');
|
|
12
|
-
const PLEXOR_DIR = path.join(process.env.HOME, '.plexor');
|
|
13
|
-
|
|
14
|
-
const VALID_MODES = ['eco', 'balanced', 'quality', 'passthrough'];
|
|
15
|
-
|
|
16
|
-
const MODE_INFO = {
|
|
17
|
-
eco: {
|
|
18
|
-
description: 'Maximum savings (~$0.04/1M tokens)',
|
|
19
|
-
models: 'Ministral 3B, small models'
|
|
20
|
-
},
|
|
21
|
-
balanced: {
|
|
22
|
-
description: 'Good balance (~$0.15/1M tokens)',
|
|
23
|
-
models: 'DeepSeek, Gemini Flash, Mistral Small'
|
|
24
|
-
},
|
|
25
|
-
quality: {
|
|
26
|
-
description: 'Premium models (~$5/1M tokens)',
|
|
27
|
-
models: 'Claude Opus, Gemini Pro, Mistral Large'
|
|
28
|
-
},
|
|
29
|
-
passthrough: {
|
|
30
|
-
description: 'No optimization',
|
|
31
|
-
models: 'Direct to requested model'
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
function loadConfig() {
|
|
36
|
-
try {
|
|
37
|
-
const data = fs.readFileSync(CONFIG_PATH, 'utf8');
|
|
38
|
-
return JSON.parse(data);
|
|
39
|
-
} catch {
|
|
40
|
-
return { version: 1, auth: {}, settings: {} };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function saveConfig(config) {
|
|
45
|
-
if (!fs.existsSync(PLEXOR_DIR)) {
|
|
46
|
-
fs.mkdirSync(PLEXOR_DIR, { recursive: true, mode: 0o700 });
|
|
47
|
-
}
|
|
48
|
-
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function main() {
|
|
52
|
-
const args = process.argv.slice(2);
|
|
53
|
-
const config = loadConfig();
|
|
54
|
-
const currentMode = config.settings?.mode || 'balanced';
|
|
55
|
-
|
|
56
|
-
// No args - show current mode and options
|
|
57
|
-
if (args.length === 0) {
|
|
58
|
-
console.log(`┌─────────────────────────────────────────────┐`);
|
|
59
|
-
console.log(`│ Plexor Optimization Mode │`);
|
|
60
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
61
|
-
console.log(`│ Current: ${currentMode.padEnd(33)}│`);
|
|
62
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
63
|
-
console.log(`│ Available modes: │`);
|
|
64
|
-
|
|
65
|
-
for (const mode of VALID_MODES) {
|
|
66
|
-
const marker = mode === currentMode ? '●' : '○';
|
|
67
|
-
const info = MODE_INFO[mode];
|
|
68
|
-
console.log(`│ ${marker} ${mode.padEnd(12)} ${info.description.substring(0, 26).padEnd(26)}│`);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
72
|
-
console.log(`│ Usage: /plexor-mode <mode> │`);
|
|
73
|
-
console.log(`│ Example: /plexor-mode eco │`);
|
|
74
|
-
console.log(`└─────────────────────────────────────────────┘`);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const newMode = args[0].toLowerCase();
|
|
79
|
-
|
|
80
|
-
if (!VALID_MODES.includes(newMode)) {
|
|
81
|
-
console.error(`Error: Invalid mode "${newMode}"`);
|
|
82
|
-
console.error(`Valid modes: ${VALID_MODES.join(', ')}`);
|
|
83
|
-
process.exit(1);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (newMode === currentMode) {
|
|
87
|
-
console.log(`Mode is already set to "${currentMode}"`);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
config.settings = config.settings || {};
|
|
92
|
-
config.settings.mode = newMode;
|
|
93
|
-
saveConfig(config);
|
|
94
|
-
|
|
95
|
-
const info = MODE_INFO[newMode];
|
|
96
|
-
console.log(`┌─────────────────────────────────────────────┐`);
|
|
97
|
-
console.log(`│ ✓ Mode Updated │`);
|
|
98
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
99
|
-
console.log(`│ Previous: ${currentMode.padEnd(32)}│`);
|
|
100
|
-
console.log(`│ New: ${newMode.padEnd(37)}│`);
|
|
101
|
-
console.log(`├─────────────────────────────────────────────┤`);
|
|
102
|
-
console.log(`│ ${info.description.padEnd(42)}│`);
|
|
103
|
-
console.log(`│ Models: ${info.models.substring(0, 34).padEnd(34)}│`);
|
|
104
|
-
console.log(`└─────────────────────────────────────────────┘`);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
main();
|
package/commands/plexor-mode.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Set Plexor optimization mode (eco/balanced/quality/passthrough) (user)
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Plexor Mode
|
|
6
|
-
|
|
7
|
-
Run this command to view or set the optimization mode:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
node ~/.claude/plugins/plexor/commands/plexor-mode.js
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
To set a specific mode, pass it as an argument:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
node ~/.claude/plugins/plexor/commands/plexor-mode.js balanced
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Use the Bash tool to execute this command.
|
|
20
|
-
|
|
21
|
-
**IMPORTANT**: After running this command and displaying the output, STOP. Do not:
|
|
22
|
-
- Read any files
|
|
23
|
-
- Explore the codebase
|
|
24
|
-
- Run additional commands
|
|
25
|
-
- Ask follow-up questions
|
|
26
|
-
|
|
27
|
-
The command output is the complete response. Simply show the output and wait for the user's next input.
|