@plexor-dev/claude-code-plugin-localhost 0.1.0-localhost.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/LICENSE +21 -0
- package/README.md +114 -0
- package/commands/plexor-enabled.js +281 -0
- package/commands/plexor-enabled.md +48 -0
- package/commands/plexor-login.js +283 -0
- package/commands/plexor-login.md +27 -0
- package/commands/plexor-logout.js +143 -0
- package/commands/plexor-logout.md +27 -0
- package/commands/plexor-setup.md +172 -0
- package/commands/plexor-status.js +404 -0
- package/commands/plexor-status.md +21 -0
- package/commands/plexor-uninstall.js +293 -0
- package/commands/plexor-uninstall.md +30 -0
- package/hooks/intercept.js +634 -0
- package/hooks/track-response.js +376 -0
- package/lib/cache.js +107 -0
- package/lib/config.js +67 -0
- package/lib/constants.js +44 -0
- package/lib/index.js +19 -0
- package/lib/logger.js +36 -0
- package/lib/plexor-client.js +122 -0
- package/lib/server-sync.js +237 -0
- package/lib/session.js +156 -0
- package/lib/settings-manager.js +354 -0
- package/package.json +57 -0
- package/scripts/plexor-cli.sh +48 -0
- package/scripts/postinstall.js +342 -0
- package/scripts/uninstall.js +154 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Plexor Uninstall Command (STAGING)
|
|
5
|
+
*
|
|
6
|
+
* Comprehensive cleanup before npm uninstall.
|
|
7
|
+
*
|
|
8
|
+
* CRITICAL: npm's preuninstall hook does NOT run for global package uninstalls.
|
|
9
|
+
* Users MUST run this command BEFORE running npm uninstall -g.
|
|
10
|
+
*
|
|
11
|
+
* This command:
|
|
12
|
+
* 1. Removes Plexor routing from ~/.claude/settings.json
|
|
13
|
+
* 2. Removes slash command .md files from ~/.claude/commands/
|
|
14
|
+
* 3. Removes plugin directory ~/.claude/plugins/plexor/
|
|
15
|
+
* 4. Optionally removes ~/.plexor/ config directory
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const fs = require('fs');
|
|
19
|
+
const path = require('path');
|
|
20
|
+
const os = require('os');
|
|
21
|
+
|
|
22
|
+
// Get home directory, handling sudo case
|
|
23
|
+
function getHomeDir() {
|
|
24
|
+
if (process.env.SUDO_USER) {
|
|
25
|
+
const platform = os.platform();
|
|
26
|
+
if (platform === 'darwin') {
|
|
27
|
+
return path.join('/Users', process.env.SUDO_USER);
|
|
28
|
+
} else if (platform === 'linux') {
|
|
29
|
+
return path.join('/home', process.env.SUDO_USER);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return process.env.HOME || process.env.USERPROFILE || os.homedir();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const HOME_DIR = getHomeDir();
|
|
36
|
+
const CLAUDE_DIR = path.join(HOME_DIR, '.claude');
|
|
37
|
+
const CLAUDE_COMMANDS_DIR = path.join(CLAUDE_DIR, 'commands');
|
|
38
|
+
const CLAUDE_PLUGINS_DIR = path.join(CLAUDE_DIR, 'plugins', 'plexor');
|
|
39
|
+
const PLEXOR_CONFIG_DIR = path.join(HOME_DIR, '.plexor');
|
|
40
|
+
|
|
41
|
+
// All Plexor slash command files
|
|
42
|
+
const PLEXOR_COMMANDS = [
|
|
43
|
+
'plexor-enabled.md',
|
|
44
|
+
'plexor-login.md',
|
|
45
|
+
'plexor-logout.md',
|
|
46
|
+
'plexor-setup.md',
|
|
47
|
+
'plexor-status.md',
|
|
48
|
+
'plexor-uninstall.md',
|
|
49
|
+
'plexor-mode.md',
|
|
50
|
+
'plexor-provider.md',
|
|
51
|
+
'plexor-settings.md',
|
|
52
|
+
'plexor-config.md'
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Load settings manager if available
|
|
57
|
+
*/
|
|
58
|
+
function loadSettingsManager() {
|
|
59
|
+
// Try plugin dir first (installed location)
|
|
60
|
+
try {
|
|
61
|
+
const pluginLib = path.join(CLAUDE_PLUGINS_DIR, 'lib', 'settings-manager.js');
|
|
62
|
+
if (fs.existsSync(pluginLib)) {
|
|
63
|
+
const lib = require(pluginLib);
|
|
64
|
+
return lib.settingsManager;
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
// Continue to fallback
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Try package lib (during npm lifecycle)
|
|
71
|
+
try {
|
|
72
|
+
const lib = require('../lib/settings-manager');
|
|
73
|
+
return lib.settingsManager;
|
|
74
|
+
} catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Disable Plexor routing in Claude settings manually
|
|
81
|
+
* Fallback when settings-manager is not available
|
|
82
|
+
*/
|
|
83
|
+
function disableRoutingManually() {
|
|
84
|
+
const settingsPath = path.join(CLAUDE_DIR, 'settings.json');
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
if (!fs.existsSync(settingsPath)) {
|
|
88
|
+
return { success: true, message: 'Settings file does not exist' };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const data = fs.readFileSync(settingsPath, 'utf8');
|
|
92
|
+
if (!data || data.trim() === '') {
|
|
93
|
+
return { success: true, message: 'Settings file is empty' };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const settings = JSON.parse(data);
|
|
97
|
+
|
|
98
|
+
if (!settings.env) {
|
|
99
|
+
return { success: true, message: 'No env block in settings' };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Check if Plexor routing is active
|
|
103
|
+
const baseUrl = settings.env.ANTHROPIC_BASE_URL || '';
|
|
104
|
+
const isPlexorRouting = baseUrl.includes('plexor') || baseUrl.includes('staging.api');
|
|
105
|
+
|
|
106
|
+
if (!isPlexorRouting) {
|
|
107
|
+
return { success: true, message: 'Plexor routing not active' };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Remove Plexor env vars
|
|
111
|
+
delete settings.env.ANTHROPIC_BASE_URL;
|
|
112
|
+
delete settings.env.ANTHROPIC_AUTH_TOKEN;
|
|
113
|
+
|
|
114
|
+
// Clean up empty env block
|
|
115
|
+
if (Object.keys(settings.env).length === 0) {
|
|
116
|
+
delete settings.env;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Atomic write
|
|
120
|
+
const crypto = require('crypto');
|
|
121
|
+
const tempId = crypto.randomBytes(8).toString('hex');
|
|
122
|
+
const tempPath = path.join(CLAUDE_DIR, `.settings.${tempId}.tmp`);
|
|
123
|
+
|
|
124
|
+
fs.writeFileSync(tempPath, JSON.stringify(settings, null, 2), { mode: 0o600 });
|
|
125
|
+
fs.renameSync(tempPath, settingsPath);
|
|
126
|
+
|
|
127
|
+
return { success: true, message: 'Routing disabled' };
|
|
128
|
+
} catch (err) {
|
|
129
|
+
return { success: false, message: err.message };
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Remove slash command files
|
|
135
|
+
*/
|
|
136
|
+
function removeSlashCommands() {
|
|
137
|
+
let removed = 0;
|
|
138
|
+
let restored = 0;
|
|
139
|
+
|
|
140
|
+
for (const cmd of PLEXOR_COMMANDS) {
|
|
141
|
+
const cmdPath = path.join(CLAUDE_COMMANDS_DIR, cmd);
|
|
142
|
+
const backupPath = cmdPath + '.backup';
|
|
143
|
+
|
|
144
|
+
try {
|
|
145
|
+
if (fs.existsSync(cmdPath)) {
|
|
146
|
+
fs.unlinkSync(cmdPath);
|
|
147
|
+
removed++;
|
|
148
|
+
|
|
149
|
+
// Restore backup if exists
|
|
150
|
+
if (fs.existsSync(backupPath)) {
|
|
151
|
+
fs.renameSync(backupPath, cmdPath);
|
|
152
|
+
restored++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch {
|
|
156
|
+
// Continue with other files
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return { removed, restored };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Remove plugin directory
|
|
165
|
+
*/
|
|
166
|
+
function removePluginDirectory() {
|
|
167
|
+
try {
|
|
168
|
+
if (fs.existsSync(CLAUDE_PLUGINS_DIR)) {
|
|
169
|
+
fs.rmSync(CLAUDE_PLUGINS_DIR, { recursive: true, force: true });
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
} catch {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Remove config directory
|
|
180
|
+
*/
|
|
181
|
+
function removeConfigDirectory() {
|
|
182
|
+
try {
|
|
183
|
+
if (fs.existsSync(PLEXOR_CONFIG_DIR)) {
|
|
184
|
+
fs.rmSync(PLEXOR_CONFIG_DIR, { recursive: true, force: true });
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
} catch {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function main() {
|
|
194
|
+
const args = process.argv.slice(2);
|
|
195
|
+
|
|
196
|
+
// Handle help flag
|
|
197
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
198
|
+
console.log('');
|
|
199
|
+
console.log(' Usage: plexor-uninstall [options]');
|
|
200
|
+
console.log('');
|
|
201
|
+
console.log(' Cleans up Plexor integration before npm uninstall.');
|
|
202
|
+
console.log('');
|
|
203
|
+
console.log(' Options:');
|
|
204
|
+
console.log(' --remove-config, -c Also remove ~/.plexor/ config directory');
|
|
205
|
+
console.log(' --quiet, -q Suppress output messages');
|
|
206
|
+
console.log(' --help, -h Show this help message');
|
|
207
|
+
console.log('');
|
|
208
|
+
console.log(' After running this command:');
|
|
209
|
+
console.log(' npm uninstall -g @plexor-dev/claude-code-plugin-staging');
|
|
210
|
+
console.log('');
|
|
211
|
+
process.exit(0);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const removeConfig = args.includes('--remove-config') || args.includes('-c');
|
|
215
|
+
const quiet = args.includes('--quiet') || args.includes('-q');
|
|
216
|
+
|
|
217
|
+
if (!quiet) {
|
|
218
|
+
console.log('');
|
|
219
|
+
console.log(' Plexor Uninstall (STAGING) - Cleaning up...');
|
|
220
|
+
console.log('');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 1. Remove routing from ~/.claude/settings.json
|
|
224
|
+
let routingResult;
|
|
225
|
+
const settingsManager = loadSettingsManager();
|
|
226
|
+
|
|
227
|
+
if (settingsManager) {
|
|
228
|
+
try {
|
|
229
|
+
const success = settingsManager.disablePlexorRouting();
|
|
230
|
+
routingResult = { success, message: success ? 'Routing disabled via manager' : 'Already clean' };
|
|
231
|
+
} catch (err) {
|
|
232
|
+
routingResult = disableRoutingManually();
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
routingResult = disableRoutingManually();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (!quiet) {
|
|
239
|
+
console.log(routingResult.success
|
|
240
|
+
? ' ✓ Removed Plexor routing from Claude settings'
|
|
241
|
+
: ` ✗ Failed to remove routing: ${routingResult.message}`);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// 2. Remove slash command .md files
|
|
245
|
+
const cmdResult = removeSlashCommands();
|
|
246
|
+
if (!quiet) {
|
|
247
|
+
console.log(` ✓ Removed ${cmdResult.removed} slash command files`);
|
|
248
|
+
if (cmdResult.restored > 0) {
|
|
249
|
+
console.log(` ✓ Restored ${cmdResult.restored} backed-up files`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// 3. Remove plugin directory
|
|
254
|
+
const pluginRemoved = removePluginDirectory();
|
|
255
|
+
if (!quiet) {
|
|
256
|
+
console.log(pluginRemoved
|
|
257
|
+
? ' ✓ Removed plugin directory'
|
|
258
|
+
: ' ○ Plugin directory not found (already clean)');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// 4. Optionally remove config directory
|
|
262
|
+
if (removeConfig) {
|
|
263
|
+
const configRemoved = removeConfigDirectory();
|
|
264
|
+
if (!quiet) {
|
|
265
|
+
console.log(configRemoved
|
|
266
|
+
? ' ✓ Removed ~/.plexor config directory'
|
|
267
|
+
: ' ○ Config directory not found');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// Show next steps
|
|
272
|
+
if (!quiet) {
|
|
273
|
+
console.log('');
|
|
274
|
+
console.log(' ┌─────────────────────────────────────────────────────────────────┐');
|
|
275
|
+
console.log(' │ Cleanup complete! Now run: │');
|
|
276
|
+
console.log(' │ │');
|
|
277
|
+
console.log(' │ npm uninstall -g @plexor-dev/claude-code-plugin-staging │');
|
|
278
|
+
console.log(' │ │');
|
|
279
|
+
console.log(' └─────────────────────────────────────────────────────────────────┘');
|
|
280
|
+
console.log('');
|
|
281
|
+
console.log(' Your Claude Code is ready to work normally again.');
|
|
282
|
+
console.log('');
|
|
283
|
+
|
|
284
|
+
if (!removeConfig) {
|
|
285
|
+
console.log(' Note: ~/.plexor/ config directory was preserved.');
|
|
286
|
+
console.log(' To also remove it: plexor-uninstall --remove-config');
|
|
287
|
+
console.log(' Or manually: rm -rf ~/.plexor');
|
|
288
|
+
console.log('');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
main();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: plexor-uninstall
|
|
3
|
+
description: Clean up Plexor integration before uninstalling
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Runs comprehensive cleanup to prepare for npm uninstall.
|
|
7
|
+
|
|
8
|
+
**IMPORTANT**: Run this command BEFORE `npm uninstall -g @plexor-dev/claude-code-plugin-staging`
|
|
9
|
+
|
|
10
|
+
npm's preuninstall hook does NOT run for global package uninstalls, so this command
|
|
11
|
+
must be run manually to ensure proper cleanup.
|
|
12
|
+
|
|
13
|
+
This removes:
|
|
14
|
+
- Plexor routing from Claude settings (~/.claude/settings.json)
|
|
15
|
+
- Slash command files from ~/.claude/commands/
|
|
16
|
+
- Plugin directory ~/.claude/plugins/plexor/
|
|
17
|
+
|
|
18
|
+
Options:
|
|
19
|
+
- `--remove-config` or `-c`: Also remove ~/.plexor/ config directory
|
|
20
|
+
|
|
21
|
+
After running this command, run:
|
|
22
|
+
```bash
|
|
23
|
+
npm uninstall -g @plexor-dev/claude-code-plugin-staging
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
$ARGUMENTS: $ARGUMENTS
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
node ~/.claude/plugins/plexor/commands/plexor-uninstall.js $ARGUMENTS 2>&1 || plexor-uninstall $ARGUMENTS 2>&1
|
|
30
|
+
```
|