@plexor-dev/claude-code-plugin 0.1.0-beta.31 → 0.1.0-beta.33

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.
@@ -1,67 +1,154 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * Plexor Claude Code Plugin - Uninstall Script
4
+ * Plexor Claude Code Plugin - Comprehensive Uninstall Script
5
5
  *
6
- * Removes slash commands from ~/.claude/commands/
7
- * Optionally restores backups if they exist.
6
+ * Runs on npm uninstall (when npm actually calls it).
7
+ * Also callable directly: node scripts/uninstall.js
8
+ *
9
+ * Performs complete cleanup:
10
+ * 1. Removes Plexor routing from ~/.claude/settings.json
11
+ * 2. Removes slash command files from ~/.claude/commands/
12
+ * 3. Removes plugin directory from ~/.claude/plugins/plexor/
13
+ * 4. Restores any backups if they exist
8
14
  */
9
15
 
10
16
  const fs = require('fs');
11
17
  const path = require('path');
12
- const os = require('os');
13
18
 
14
- const COMMANDS_SOURCE = path.join(__dirname, '..', 'commands');
15
- const CLAUDE_COMMANDS_DIR = path.join(os.homedir(), '.claude', 'commands');
19
+ // Get home directory - support both Unix and Windows
20
+ const home = process.env.HOME || process.env.USERPROFILE;
21
+ if (!home) {
22
+ console.log('Warning: HOME not set, skipping cleanup');
23
+ process.exit(0);
24
+ }
25
+
26
+ console.log('');
27
+ console.log(' Plexor plugin cleanup...');
28
+ console.log('');
29
+
30
+ const results = {
31
+ routing: false,
32
+ commands: [],
33
+ restored: [],
34
+ pluginDir: false
35
+ };
16
36
 
17
- function main() {
18
- try {
19
- // Get list of our command files
20
- const files = fs.readdirSync(COMMANDS_SOURCE)
21
- .filter(f => f.endsWith('.md'));
37
+ // 1. Remove routing from settings.json
38
+ // This is CRITICAL - do NOT depend on settings-manager module since it may not load during uninstall
39
+ try {
40
+ const settingsPath = path.join(home, '.claude', 'settings.json');
41
+ if (fs.existsSync(settingsPath)) {
42
+ const data = fs.readFileSync(settingsPath, 'utf8');
43
+ if (data && data.trim()) {
44
+ const settings = JSON.parse(data);
45
+ if (settings.env) {
46
+ const hadBaseUrl = !!settings.env.ANTHROPIC_BASE_URL;
47
+ const hadAuthToken = !!settings.env.ANTHROPIC_AUTH_TOKEN;
48
+
49
+ delete settings.env.ANTHROPIC_BASE_URL;
50
+ delete settings.env.ANTHROPIC_AUTH_TOKEN;
51
+
52
+ // Clean up empty env block
53
+ if (Object.keys(settings.env).length === 0) {
54
+ delete settings.env;
55
+ }
56
+
57
+ if (hadBaseUrl || hadAuthToken) {
58
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2), { mode: 0o600 });
59
+ results.routing = true;
60
+ }
61
+ }
62
+ }
63
+ }
64
+ } catch (e) {
65
+ console.log(` Warning: Could not clean settings.json: ${e.message}`);
66
+ }
22
67
 
23
- const removed = [];
24
- const restored = [];
68
+ // 2. Remove slash command files
69
+ // These are the Plexor-specific command files that get installed to ~/.claude/commands/
70
+ const plexorCommands = [
71
+ 'plexor-config.md',
72
+ 'plexor-enabled.md',
73
+ 'plexor-login.md',
74
+ 'plexor-logout.md',
75
+ 'plexor-mode.md',
76
+ 'plexor-provider.md',
77
+ 'plexor-settings.md',
78
+ 'plexor-setup.md',
79
+ 'plexor-status.md',
80
+ 'plexor-uninstall.md'
81
+ ];
25
82
 
26
- for (const file of files) {
27
- const dest = path.join(CLAUDE_COMMANDS_DIR, file);
28
- const backupPath = dest + '.backup';
83
+ try {
84
+ const commandsDir = path.join(home, '.claude', 'commands');
85
+ if (fs.existsSync(commandsDir)) {
86
+ for (const cmd of plexorCommands) {
87
+ const cmdPath = path.join(commandsDir, cmd);
88
+ const backupPath = cmdPath + '.backup';
29
89
 
30
- if (fs.existsSync(dest)) {
31
- fs.unlinkSync(dest);
32
- removed.push(file.replace('.md', ''));
90
+ if (fs.existsSync(cmdPath)) {
91
+ fs.unlinkSync(cmdPath);
92
+ results.commands.push(cmd.replace('.md', ''));
33
93
 
34
94
  // Restore backup if it exists
35
95
  if (fs.existsSync(backupPath)) {
36
- fs.renameSync(backupPath, dest);
37
- restored.push(file);
96
+ fs.renameSync(backupPath, cmdPath);
97
+ results.restored.push(cmd);
38
98
  }
39
99
  }
40
100
  }
101
+ }
102
+ } catch (e) {
103
+ console.log(` Warning: Could not clean commands: ${e.message}`);
104
+ }
41
105
 
42
- if (removed.length > 0) {
43
- console.log('');
44
- console.log(' Plexor plugin uninstalled');
45
- console.log('');
46
- console.log(' Removed commands:');
47
- removed.forEach(cmd => console.log(` /${cmd}`));
48
-
49
- if (restored.length > 0) {
50
- console.log('');
51
- console.log(' Restored from backup:');
52
- restored.forEach(f => console.log(` ${f}`));
53
- }
106
+ // 3. Remove plugin directory
107
+ try {
108
+ const pluginDir = path.join(home, '.claude', 'plugins', 'plexor');
109
+ if (fs.existsSync(pluginDir)) {
110
+ fs.rmSync(pluginDir, { recursive: true, force: true });
111
+ results.pluginDir = true;
112
+ }
113
+ } catch (e) {
114
+ console.log(` Warning: Could not remove plugin directory: ${e.message}`);
115
+ }
54
116
 
55
- console.log('');
56
- console.log(' Note: ~/.plexor/ config directory was preserved.');
57
- console.log(' To remove it: rm -rf ~/.plexor');
58
- console.log('');
59
- }
117
+ // Output results
118
+ if (results.routing || results.commands.length > 0 || results.pluginDir) {
119
+ console.log(' Plexor plugin uninstalled');
120
+ console.log('');
60
121
 
61
- } catch (error) {
62
- // Don't fail uninstall on errors - just warn
63
- console.warn(` Warning: Could not fully uninstall: ${error.message}`);
122
+ if (results.routing) {
123
+ console.log(' Removed Plexor routing from Claude settings');
124
+ console.log(' (Claude Code now connects directly to Anthropic)');
125
+ console.log('');
64
126
  }
127
+
128
+ if (results.commands.length > 0) {
129
+ console.log(' Removed commands:');
130
+ results.commands.forEach(cmd => console.log(` /${cmd}`));
131
+ console.log('');
132
+ }
133
+
134
+ if (results.restored.length > 0) {
135
+ console.log(' Restored from backup:');
136
+ results.restored.forEach(f => console.log(` ${f}`));
137
+ console.log('');
138
+ }
139
+
140
+ if (results.pluginDir) {
141
+ console.log(' Removed plugin directory');
142
+ console.log('');
143
+ }
144
+
145
+ console.log(' Note: ~/.plexor/ config directory was preserved.');
146
+ console.log(' To remove it: rm -rf ~/.plexor');
147
+ console.log('');
148
+ } else {
149
+ console.log(' No Plexor components found to clean up.');
150
+ console.log('');
65
151
  }
66
152
 
67
- main();
153
+ console.log(' Cleanup complete');
154
+ console.log('');