codexctl 0.1.5 → 0.4.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 ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Bhanu Korthiwada
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
20
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CodexCTL
2
2
 
3
- Codex CLI Profile Manager - Manage multiple OpenAI Codex CLI accounts
3
+ Codex CLI Profile Manager - Manage multiple AI CLI accounts (Codex, Claude, Gemini, OpenAI)
4
4
 
5
5
  ## Installation
6
6
 
@@ -13,39 +13,36 @@ Or use npx (no install):
13
13
  npx codexctl --help
14
14
  ```
15
15
 
16
- ## Usage
16
+ ## Quick Start
17
17
 
18
18
  ```bash
19
- # Save your current Codex CLI profile
20
- cdx save work
21
- cdx save personal
19
+ # Save your current CLI profile
20
+ codexctl save work
21
+ codexctl save personal
22
22
 
23
23
  # Switch between profiles
24
- cdx load work
25
- cdx load personal
24
+ codexctl load work
26
25
 
27
26
  # List all profiles
28
- cdx list
29
-
30
- # Quick-switch to previous profile
31
- cdx load -
32
-
33
- # Auto-switch to best profile based on quota
34
- cdx load auto
27
+ codexctl list
35
28
  ```
36
29
 
37
30
  ## Features
38
31
 
39
- - 🔐 **Optional Encryption** - age-based encryption for sensitive auth data
40
- - 🚀 **Fast Switching** - Switch accounts in < 1 second
41
- - 🤖 **Auto-Switcher** - Automatically pick the best profile based on quota
42
- - 📊 **Real-Time Quota** - Live usage data from OpenAI API
43
- - 🌳 **Concurrent Usage** - Use multiple profiles simultaneously
32
+ - Optional encryption for sensitive auth data
33
+ - Fast profile switching
34
+ - Multiple AI CLI support (Codex, Claude, Gemini, OpenAI)
35
+ - Export to use profiles concurrently in different terminals
36
+
37
+ ## Binary Package
44
38
 
45
- ## Documentation
39
+ This npm package downloads pre-built binaries from GitHub Releases on install.
46
40
 
47
- Full documentation: https://codexctl.repohelper.com
41
+ Supported platforms:
42
+ - Linux (x86_64, arm64)
43
+ - macOS (x86_64, arm64)
44
+ - Windows (x86_64)
48
45
 
49
46
  ## License
50
47
 
51
- MIT
48
+ MIT
package/bin/codexctl CHANGED
Binary file
Binary file
package/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // CodexCTL npm package - main entry point
2
+ // When package is used as library, this provides version info
3
+
4
+ module.exports = {
5
+ name: 'codexctl',
6
+ version: require('./package.json').version
7
+ };
package/install.js CHANGED
@@ -1,19 +1,18 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * CodexCTL Installation Script
4
- * Downloads the appropriate binary for the current platform
4
+ * Downloads the appropriate binary for the current platform from GitHub Releases
5
5
  */
6
6
 
7
7
  const https = require('https');
8
+ const http = require('http');
8
9
  const fs = require('fs');
9
10
  const path = require('path');
10
11
  const os = require('os');
11
- const { execSync } = require('child_process');
12
+ const { execSync, spawn } = require('child_process');
12
13
 
13
14
  const VERSION = require('./package.json').version;
14
- const BINARY_NAME = 'codexctl';
15
15
 
16
- // Platform mappings
17
16
  const platforms = {
18
17
  'darwin-x64': 'x86_64-apple-darwin',
19
18
  'darwin-arm64': 'aarch64-apple-darwin',
@@ -43,31 +42,43 @@ function getDownloadUrl(target) {
43
42
 
44
43
  function downloadFile(url, dest) {
45
44
  return new Promise((resolve, reject) => {
46
- const file = fs.createWriteStream(dest);
47
- https.get(url, { followRedirects: true }, (response) => {
45
+ const protocol = url.startsWith('https') ? https : http;
46
+
47
+ const request = protocol.get(url, { headers: { 'User-Agent': 'codexctl-install' } }, (response) => {
48
48
  if (response.statusCode === 302 || response.statusCode === 301) {
49
- // Follow redirect
50
- downloadFile(response.headers.location, dest).then(resolve).catch(reject);
51
- return;
49
+ const redirectUrl = response.headers.location;
50
+ if (redirectUrl) {
51
+ downloadFile(redirectUrl, dest).then(resolve).catch(reject);
52
+ return;
53
+ }
52
54
  }
53
55
 
54
56
  if (response.statusCode !== 200) {
55
- reject(new Error(`Download failed with status ${response.statusCode}`));
57
+ reject(new Error(`Download failed with status ${response.statusCode}: ${url}`));
56
58
  return;
57
59
  }
58
60
 
61
+ const file = fs.createWriteStream(dest);
59
62
  response.pipe(file);
60
63
  file.on('finish', () => {
61
64
  file.close();
62
65
  resolve();
63
66
  });
64
- }).on('error', reject);
67
+ });
68
+
69
+ request.on('error', reject);
65
70
  });
66
71
  }
67
72
 
68
73
  function extractArchive(archivePath, destDir) {
69
- if (archivePath.endsWith('.zip')) {
70
- execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: 'inherit' });
74
+ const ext = path.extname(archivePath);
75
+
76
+ if (ext === '.zip') {
77
+ if (os.platform() === 'win32') {
78
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${destDir}' -Force"`, { stdio: 'inherit' });
79
+ } else {
80
+ execSync(`unzip -o "${archivePath}" -d "${destDir}"`, { stdio: 'inherit' });
81
+ }
71
82
  } else {
72
83
  execSync(`tar -xzf "${archivePath}" -C "${destDir}"`, { stdio: 'inherit' });
73
84
  }
@@ -76,48 +87,63 @@ function extractArchive(archivePath, destDir) {
76
87
  async function install() {
77
88
  const binDir = path.join(__dirname, 'bin');
78
89
 
79
- // Skip if binaries already exist (development or manual install)
80
- if (fs.existsSync(path.join(binDir, BINARY_NAME))) {
90
+ // Skip if binaries already exist
91
+ if (fs.existsSync(path.join(binDir, 'codexctl'))) {
81
92
  console.log('CodexCTL binaries already exist, skipping download');
82
93
  return;
83
94
  }
84
95
 
85
- // Ensure bin directory exists
86
96
  if (!fs.existsSync(binDir)) {
87
97
  fs.mkdirSync(binDir, { recursive: true });
88
98
  }
89
-
99
+
90
100
  const target = getPlatform();
91
- const url = getDownloadUrl(target);
92
101
  const ext = target.includes('windows') ? 'zip' : 'tar.gz';
93
102
  const archivePath = path.join(binDir, `codexctl-${target}.${ext}`);
94
103
 
95
104
  console.log(`Downloading CodexCTL v${VERSION} for ${target}...`);
105
+
106
+ const url = getDownloadUrl(target);
96
107
  console.log(`URL: ${url}`);
97
108
 
98
109
  try {
110
+ // First try direct download
99
111
  await downloadFile(url, archivePath);
100
- console.log('Download complete, extracting...');
101
-
102
- extractArchive(archivePath, binDir);
103
- fs.unlinkSync(archivePath);
104
-
105
- // Make binaries executable on Unix
106
- if (os.platform() !== 'win32') {
107
- execSync(`chmod +x "${path.join(binDir, BINARY_NAME)}"`);
108
- execSync(`chmod +x "${path.join(binDir, 'cdx')}"`);
112
+ } catch (err) {
113
+ // If direct fails, try latest tag
114
+ const latestUrl = getDownloadUrl(target).replace(`/v${VERSION}`, '/latest');
115
+ console.log(`Retrying with latest...`);
116
+ await downloadFile(latestUrl, archivePath);
117
+ }
118
+
119
+ console.log('Extracting...');
120
+ extractArchive(archivePath, binDir);
121
+
122
+ // Clean up archive
123
+ fs.unlinkSync(archivePath);
124
+
125
+ // Make executable
126
+ if (os.platform() !== 'win32') {
127
+ try {
128
+ fs.chmodSync(path.join(binDir, 'codexctl'), 0o755);
129
+ } catch (e) {
130
+ // Try cdx if codexctl name differs
131
+ const cdxPath = path.join(binDir, 'cdx');
132
+ if (fs.existsSync(cdxPath)) {
133
+ fs.chmodSync(cdxPath, 0o755);
134
+ }
109
135
  }
110
-
111
- console.log('CodexCTL installed successfully!');
112
- console.log('Run: cdx --help');
113
- } catch (error) {
114
- console.error('Installation failed:', error.message);
115
- console.error('You can manually download from: https://github.com/repohelper/codexctl/releases');
116
- process.exit(1);
117
136
  }
137
+
138
+ console.log('CodexCTL installed successfully!');
139
+ console.log('Run: codexctl --help');
118
140
  }
119
141
 
120
142
  install().catch(err => {
121
- console.error('Unexpected error:', err);
143
+ console.error('Installation failed:', err.message);
144
+ console.error('');
145
+ console.error('To install manually:');
146
+ console.error(`1. Download from: https://github.com/repohelper/codexctl/releases`);
147
+ console.error(`2. Extract and add to your PATH`);
122
148
  process.exit(1);
123
- });
149
+ });
package/package.json CHANGED
@@ -1,37 +1,26 @@
1
1
  {
2
2
  "name": "codexctl",
3
- "version": "0.1.5",
4
- "description": "Codex CLI Profile Manager - Manage multiple OpenAI Codex CLI accounts",
3
+ "version": "0.4.1",
4
+ "description": "Codex CLI Profile Manager - Manage multiple AI CLI accounts",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "codexctl": "./bin/codexctl",
8
8
  "cdx": "./bin/cdx"
9
9
  },
10
10
  "scripts": {
11
- "postinstall": "node install.js",
12
11
  "test": "echo 'Binary package - no tests'"
13
12
  },
14
13
  "repository": {
15
14
  "type": "git",
16
15
  "url": "git+https://github.com/repohelper/codexctl.git"
17
16
  },
18
- "keywords": [
19
- "ai",
20
- "cli",
21
- "profile",
22
- "manager",
23
- "codex",
24
- "claude",
25
- "gemini",
26
- "openai",
27
- "multi-account"
28
- ],
17
+ "keywords": ["ai", "cli", "codex", "claude", "gemini", "openai", "profile", "manager"],
29
18
  "author": "Bhanu Korthiwada",
30
19
  "license": "MIT",
31
20
  "bugs": {
32
21
  "url": "https://github.com/repohelper/codexctl/issues"
33
22
  },
34
- "homepage": "https://codexctl.repohelper.com",
23
+ "homepage": "https://github.com/repohelper/codexctl",
35
24
  "engines": {
36
25
  "node": ">=16"
37
26
  },
@@ -40,11 +29,5 @@
40
29
  "install.js",
41
30
  "README.md",
42
31
  "LICENSE"
43
- ],
44
- "trusted-publishers": [
45
- {
46
- "type": "GitHub Actions",
47
- "workflow": "release.yml"
48
- }
49
32
  ]
50
- }
33
+ }
package/bin/cdx DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- const { spawn } = require('child_process');
3
- const path = require('path');
4
-
5
- const binaryPath = path.join(__dirname, '..', 'bin', 'cdx');
6
- const child = spawn(binaryPath, process.argv.slice(2), {
7
- stdio: 'inherit',
8
- windowsHide: true
9
- });
10
-
11
- child.on('exit', (code) => {
12
- process.exit(code);
13
- });