vtcode-bin 0.52.4

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 ADDED
@@ -0,0 +1,118 @@
1
+ # VT Code - npm Package
2
+
3
+ This directory contains the npm package configuration for publishing VT Code to GitHub Packages.
4
+
5
+ ## Package Details
6
+
7
+ - **Package Name**: `@vinhnx/vtcode`
8
+ - **Registry**: GitHub Packages
9
+ - **Repository**: https://github.com/vinhnx/vtcode
10
+
11
+ ## Installation
12
+
13
+ The package is published to GitHub Packages and can be installed with:
14
+
15
+ ```bash
16
+ npm install @vinhnx/vtcode
17
+ ```
18
+
19
+ Or as a global CLI tool:
20
+
21
+ ```bash
22
+ npm install -g @vinhnx/vtcode
23
+ ```
24
+
25
+ ## Features
26
+
27
+ - **Platform Support**: macOS, Linux, Windows
28
+ - **Architecture Support**: x64, arm64
29
+ - **Postinstall**: Automatically downloads the correct binary for your platform
30
+ - **CLI Integration**: Available as `vtcode` command after installation
31
+
32
+ ## How It Works
33
+
34
+ 1. **Installation**: When you install the package, the `postinstall` script runs
35
+ 2. **Binary Download**: Downloads the appropriate platform-specific binary from GitHub releases
36
+ 3. **Binary Setup**: Extracts and configures the binary for your system
37
+ 4. **CLI Ready**: The `vtcode` command is available immediately
38
+
39
+ ## Publishing
40
+
41
+ The release script (`scripts/release.sh`) automatically:
42
+
43
+ 1. Updates the npm package version
44
+ 2. Publishes to GitHub Packages during the release process
45
+ 3. Uploads with proper authentication
46
+
47
+ For manual publishing, see `scripts/publish-to-github.js`.
48
+
49
+ ## Configuration
50
+
51
+ ### GitHub Packages Authentication
52
+
53
+ Create a `.npmrc` file in your home directory:
54
+
55
+ ```
56
+ //npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
57
+ @vinhnx:registry=https://npm.pkg.github.com
58
+ ```
59
+
60
+ Or use the environment variable:
61
+
62
+ ```bash
63
+ export NODE_AUTH_TOKEN=YOUR_GITHUB_TOKEN
64
+ ```
65
+
66
+ See `.npmrc.example` for detailed setup instructions.
67
+
68
+ ## Files
69
+
70
+ - `package.json` - Package metadata and version
71
+ - `index.js` - Entry point and CLI wrapper
72
+ - `scripts/postinstall.js` - Downloads and sets up the binary
73
+ - `scripts/preuninstall.js` - Cleanup on uninstall
74
+ - `scripts/publish-to-github.js` - Manual publish script
75
+ - `.npmrc.example` - Authentication configuration template
76
+
77
+ ## Troubleshooting
78
+
79
+ ### Binary Download Fails
80
+
81
+ If the postinstall script fails to download the binary:
82
+
83
+ 1. Check your internet connection
84
+ 2. Verify the release exists: https://github.com/vinhnx/vtcode/releases
85
+ 3. Try manual installation:
86
+ ```bash
87
+ cargo install vtcode
88
+ ```
89
+
90
+ ### Permission Issues
91
+
92
+ On macOS/Linux, ensure the binary has execute permissions:
93
+
94
+ ```bash
95
+ chmod +x ./bin/vtcode-*
96
+ ```
97
+
98
+ ### Windows Issues
99
+
100
+ For Windows, ensure you have:
101
+ - PowerShell 5.0+ (for Expand-Archive)
102
+ - Or `7-Zip` installed
103
+
104
+ ## Development
105
+
106
+ When updating the release script, ensure:
107
+
108
+ 1. Version in `package.json` matches the main release version
109
+ 2. `.npmrc` is configured for GitHub Packages
110
+ 3. `GITHUB_TOKEN` environment variable is set during CI/CD
111
+ 4. Test postinstall script locally before release
112
+
113
+ ## Support
114
+
115
+ For issues or questions:
116
+
117
+ - GitHub Issues: https://github.com/vinhnx/vtcode/issues
118
+ - Documentation: https://github.com/vinhnx/vtcode/docs
package/index.js ADDED
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * VT Code - npm package entry point
5
+ * This serves as the main entry point for the npm package.
6
+ * It delegates to the Rust binary which is downloaded during postinstall.
7
+ */
8
+
9
+ const { spawn } = require('child_process');
10
+ const path = require('path');
11
+ const os = require('os');
12
+
13
+ // Determine the platform-specific binary path
14
+ const platform = os.platform();
15
+ const arch = os.arch();
16
+
17
+ let binaryName;
18
+ switch (platform) {
19
+ case 'darwin':
20
+ binaryName = arch === 'arm64' ? 'vtcode-macos-arm64' : 'vtcode-macos-x64';
21
+ break;
22
+ case 'linux':
23
+ binaryName = arch === 'arm64' ? 'vtcode-linux-arm64' : 'vtcode-linux-x64';
24
+ break;
25
+ case 'win32':
26
+ binaryName = 'vtcode-windows-x64.exe';
27
+ break;
28
+ default:
29
+ console.error(`Unsupported platform: ${platform}`);
30
+ process.exit(1);
31
+ }
32
+
33
+ const binaryPath = path.join(__dirname, 'bin', binaryName);
34
+
35
+ // Check if the binary exists
36
+ const fs = require('fs');
37
+ if (!fs.existsSync(binaryPath)) {
38
+ console.error('VT Code binary not found. Please run npm install again.');
39
+ console.error('If the problem persists, please install using cargo: cargo install vtcode');
40
+ process.exit(1);
41
+ }
42
+
43
+ // Execute the binary with all passed arguments
44
+ const args = process.argv.slice(2);
45
+ const child = spawn(binaryPath, args, {
46
+ stdio: 'inherit'
47
+ });
48
+
49
+ child.on('error', (err) => {
50
+ console.error('Failed to start VT Code:', err.message);
51
+ process.exit(1);
52
+ });
53
+
54
+ child.on('exit', (code) => {
55
+ process.exit(code || 0);
56
+ });
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "vtcode-bin",
3
+ "version": "0.52.4",
4
+ "description": "A Rust-based terminal coding agent with modular architecture supporting multiple LLM providers",
5
+ "keywords": [
6
+ "ai",
7
+ "coding",
8
+ "agent",
9
+ "llm",
10
+ "cli",
11
+ "rust"
12
+ ],
13
+ "homepage": "https://github.com/vinhnx/vtcode",
14
+ "bugs": {
15
+ "url": "https://github.com/vinhnx/vtcode/issues"
16
+ },
17
+ "license": "MIT",
18
+ "author": "vinhnx <vinhnx@users.noreply.github.com>",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/vinhnx/vtcode.git"
22
+ },
23
+ "readme": "README.md",
24
+ "main": "index.js",
25
+ "bin": {
26
+ "vtcode": "bin/vtcode"
27
+ },
28
+ "files": [
29
+ "index.js",
30
+ "bin/",
31
+ "scripts/",
32
+ "README.md"
33
+ ],
34
+ "scripts": {
35
+ "postinstall": "node scripts/postinstall.js",
36
+ "preuninstall": "node scripts/preuninstall.js"
37
+ },
38
+ "engines": {
39
+ "node": ">=14.0.0"
40
+ },
41
+ "os": [
42
+ "darwin",
43
+ "linux",
44
+ "win32"
45
+ ],
46
+ "cpu": [
47
+ "x64",
48
+ "arm64"
49
+ ]
50
+ }
@@ -0,0 +1,170 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Postinstall script for VT Code npm package
5
+ * Downloads the appropriate binary for the current platform
6
+ */
7
+
8
+ const https = require('https');
9
+ const fs = require('fs');
10
+ const path = require('path');
11
+ const os = require('os');
12
+ const { execSync } = require('child_process');
13
+
14
+ // Get package version
15
+ const packageJson = require('../package.json');
16
+ const version = packageJson.version;
17
+
18
+ // Determine platform and architecture
19
+ const platform = os.platform();
20
+ const arch = os.arch();
21
+
22
+ // Map platform/arch to release asset names
23
+ const assetMap = {
24
+ 'darwin': {
25
+ 'arm64': `vtcode-${version}-aarch64-apple-darwin.tar.gz`,
26
+ 'x64': `vtcode-${version}-x86_64-apple-darwin.tar.gz`
27
+ },
28
+ 'linux': {
29
+ 'arm64': `vtcode-${version}-aarch64-unknown-linux-gnu.tar.gz`,
30
+ 'x64': `vtcode-${version}-x86_64-unknown-linux-gnu.tar.gz`
31
+ },
32
+ 'win32': {
33
+ 'x64': `vtcode-${version}-x86_64-pc-windows-msvc.zip`
34
+ }
35
+ };
36
+
37
+ // Get the asset name for current platform
38
+ let assetName;
39
+ if (assetMap[platform] && assetMap[platform][arch]) {
40
+ assetName = assetMap[platform][arch];
41
+ } else {
42
+ console.error(`Unsupported platform/architecture: ${platform}/${arch}`);
43
+ process.exit(1);
44
+ }
45
+
46
+ // GitHub release URL
47
+ const downloadUrl = `https://github.com/vinhnx/vtcode/releases/download/v${version}/${assetName}`;
48
+ const binDir = path.join(__dirname, '..', 'bin');
49
+ const tempPath = path.join(binDir, assetName);
50
+
51
+ // Ensure bin directory exists
52
+ if (!fs.existsSync(binDir)) {
53
+ fs.mkdirSync(binDir, { recursive: true });
54
+ }
55
+
56
+ console.log(`Downloading VT Code v${version} for ${platform}/${arch}...`);
57
+
58
+ // Download function
59
+ function downloadFile(url, dest) {
60
+ return new Promise((resolve, reject) => {
61
+ const file = fs.createWriteStream(dest);
62
+
63
+ https.get(url, (response) => {
64
+ if (response.statusCode === 302 || response.statusCode === 301) {
65
+ // Handle redirects
66
+ downloadFile(response.headers.location, dest).then(resolve).catch(reject);
67
+ return;
68
+ }
69
+
70
+ if (response.statusCode !== 200) {
71
+ reject(new Error(`Download failed with status code: ${response.statusCode}`));
72
+ return;
73
+ }
74
+
75
+ response.pipe(file);
76
+
77
+ file.on('finish', () => {
78
+ file.close();
79
+ resolve();
80
+ });
81
+
82
+ file.on('error', (err) => {
83
+ fs.unlink(dest, () => { }); // Delete partial file
84
+ reject(err);
85
+ });
86
+ }).on('error', (err) => {
87
+ fs.unlink(dest, () => { }); // Delete partial file
88
+ reject(err);
89
+ });
90
+ });
91
+ }
92
+
93
+ // Extract function
94
+ function extractArchive(archivePath) {
95
+ const binDir = path.join(__dirname, '..', 'bin');
96
+
97
+ try {
98
+ if (archivePath.endsWith('.tar.gz')) {
99
+ execSync(`tar -xzf "${archivePath}" -C "${binDir}"`, { stdio: 'inherit' });
100
+ } else if (archivePath.endsWith('.zip')) {
101
+ if (platform === 'win32') {
102
+ execSync(`powershell Expand-Archive -Path "${archivePath}" -DestinationPath "${binDir}" -Force`, { stdio: 'inherit' });
103
+ } else {
104
+ execSync(`unzip -o "${archivePath}" -d "${binDir}"`, { stdio: 'inherit' });
105
+ }
106
+ }
107
+
108
+ // Clean up archive
109
+ fs.unlinkSync(archivePath);
110
+
111
+ // Find and rename the binary
112
+ const files = fs.readdirSync(binDir);
113
+ const binaryFile = files.find(file => file.startsWith('vtcode') && !file.includes('.') || file.endsWith('.exe'));
114
+
115
+ if (binaryFile) {
116
+ const oldPath = path.join(binDir, binaryFile);
117
+ let newPath;
118
+
119
+ switch (platform) {
120
+ case 'darwin':
121
+ newPath = path.join(binDir, arch === 'arm64' ? 'vtcode-macos-arm64' : 'vtcode-macos-x64');
122
+ break;
123
+ case 'linux':
124
+ newPath = path.join(binDir, arch === 'arm64' ? 'vtcode-linux-arm64' : 'vtcode-linux-x64');
125
+ break;
126
+ case 'win32':
127
+ newPath = path.join(binDir, 'vtcode-windows-x64.exe');
128
+ break;
129
+ }
130
+
131
+ if (newPath) {
132
+ fs.renameSync(oldPath, newPath);
133
+ // Make it executable (not needed on Windows)
134
+ if (platform !== 'win32') {
135
+ fs.chmodSync(newPath, 0o755);
136
+ }
137
+ }
138
+ }
139
+
140
+ console.log('VT Code installed successfully!');
141
+ } catch (error) {
142
+ console.error('Extraction failed:', error.message);
143
+ process.exit(1);
144
+ }
145
+ }
146
+
147
+ // Main installation process
148
+ async function install() {
149
+ try {
150
+ // Download the binary
151
+ await downloadFile(downloadUrl, tempPath);
152
+ console.log('Download complete. Extracting...');
153
+
154
+ // Extract the binary
155
+ extractArchive(tempPath);
156
+ } catch (error) {
157
+ console.error('Installation failed:', error.message);
158
+
159
+ // Try to provide alternative installation method
160
+ console.log('\nYou can also install VT Code using one of these methods:');
161
+ console.log('- Using Cargo: cargo install vtcode');
162
+ console.log('- Using Homebrew (macOS): brew install vinhnx/tap/vtcode');
163
+ console.log('- Download binaries directly from: https://github.com/vinhnx/vtcode/releases');
164
+
165
+ process.exit(1);
166
+ }
167
+ }
168
+
169
+ // Run installation
170
+ install();
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Preuninstall script for VT Code npm package
5
+ * Cleans up downloaded binaries
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+
11
+ const binDir = path.join(__dirname, '..', 'bin');
12
+
13
+ console.log('Cleaning up VT Code binaries...');
14
+
15
+ // Remove all files in the bin directory
16
+ try {
17
+ if (fs.existsSync(binDir)) {
18
+ const files = fs.readdirSync(binDir);
19
+ for (const file of files) {
20
+ const filePath = path.join(binDir, file);
21
+ fs.unlinkSync(filePath);
22
+ }
23
+ fs.rmdirSync(binDir);
24
+ }
25
+ console.log('Cleanup complete.');
26
+ } catch (error) {
27
+ console.error('Cleanup failed:', error.message);
28
+ }
@@ -0,0 +1,144 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to publish the package to GitHub Packages
5
+ * Usage: node scripts/publish-to-github.js
6
+ *
7
+ * This script will:
8
+ * 1. Check if GITHUB_TOKEN environment variable is set
9
+ * 2. Verify .npmrc configuration exists
10
+ * 3. Run npm publish to GitHub Packages
11
+ */
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { execSync } = require('child_process');
16
+
17
+ function checkEnvironment() {
18
+ if (!process.env.GITHUB_TOKEN) {
19
+ console.error('โคซ Error: GITHUB_TOKEN environment variable is not set');
20
+ console.error('Please set it before running this script:');
21
+ console.error('export GITHUB_TOKEN=your_github_personal_access_token_here');
22
+ console.error('');
23
+ console.error('Make sure your GitHub personal access token has the required scopes:');
24
+ console.error(' - write:packages (to publish packages)');
25
+ console.error(' - read:packages (to download packages)');
26
+ console.error(' - repo (to link packages to your repositories)');
27
+ process.exit(1);
28
+ }
29
+
30
+ console.log(' GITHUB_TOKEN environment variable is set');
31
+ }
32
+
33
+ function checkNpmrc() {
34
+ const npmrcPath = path.join(__dirname, '../.npmrc');
35
+ if (!fs.existsSync(npmrcPath)) {
36
+ console.error('โคซ Error: .npmrc file not found in npm directory');
37
+ console.error('Please create one with the proper GitHub Packages configuration');
38
+ console.error('See .npmrc.example for reference');
39
+ process.exit(1);
40
+ }
41
+
42
+ const npmrcContent = fs.readFileSync(npmrcPath, 'utf8');
43
+ // Check for valid GitHub Packages registry configuration
44
+ const githubRegistryPattern = /^\/\/npm\.pkg\.github\.com\/?:_authToken=/m;
45
+ let githubRegistryFound = false;
46
+
47
+ for (const line of npmrcContent.split(/\r?\n/)) {
48
+ const trimmed = line.trim();
49
+ if (
50
+ trimmed &&
51
+ !trimmed.startsWith('#') &&
52
+ githubRegistryPattern.test(trimmed)
53
+ ) {
54
+ githubRegistryFound = true;
55
+ break;
56
+ }
57
+ }
58
+
59
+ if (!githubRegistryFound) {
60
+ console.warn('โš ๏ธ Warning: .npmrc file does not contain a valid GitHub Packages registry configuration');
61
+ console.warn('Please check that your .npmrc includes: //npm.pkg.github.com/:_authToken=YOUR_TOKEN');
62
+ } else {
63
+ console.log(' .npmrc file contains GitHub Packages configuration');
64
+ }
65
+ }
66
+
67
+ function checkPackageJson() {
68
+ const packageJsonPath = path.join(__dirname, '../package.json');
69
+ if (!fs.existsSync(packageJsonPath)) {
70
+ console.error('โคซ Error: package.json not found in npm directory');
71
+ process.exit(1);
72
+ }
73
+
74
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
75
+ console.log(` Package: ${packageJson.name} (v${packageJson.version})`);
76
+
77
+ return packageJson;
78
+ }
79
+
80
+ function runPublish() {
81
+ console.log('\n๐Ÿš€ Starting publish process...');
82
+
83
+ try {
84
+ // Verify npm configuration
85
+ console.log('\n๐Ÿ“‹ Checking npm configuration...');
86
+ const npmWhoami = execSync('npm whoami', { encoding: 'utf8' }).trim();
87
+ console.log(`๐Ÿ‘ค Authenticated as: ${npmWhoami}`);
88
+
89
+ // Run npm publish
90
+ console.log('\n๐Ÿ“ฆ Publishing to GitHub Packages...');
91
+ const publishOutput = execSync('npm publish', {
92
+ cwd: path.join(__dirname, '..'),
93
+ encoding: 'utf8'
94
+ });
95
+
96
+ console.log(' Publish output:');
97
+ console.log(publishOutput);
98
+
99
+ console.log('\n๐ŸŽ‰ Package published successfully to GitHub Packages!');
100
+ console.log(`๐Ÿ”— View at: https://github.com/vinhnx/vtcode/pkgs/npm/vtcode`);
101
+ } catch (error) {
102
+ console.error('โคซ Error during publish:');
103
+ console.error(error.message);
104
+ if (error.stdout) console.error('STDOUT:', error.stdout);
105
+ if (error.stderr) console.error('STDERR:', error.stderr);
106
+ process.exit(1);
107
+ }
108
+ }
109
+
110
+ function main() {
111
+ console.log('๐Ÿ“ Publishing VT Code npm package to GitHub Packages');
112
+ console.log('=====================================================');
113
+
114
+ checkEnvironment();
115
+ checkNpmrc();
116
+ const packageJson = checkPackageJson();
117
+
118
+ console.log('\n๐Ÿ“‹ Verification complete. Ready to publish:');
119
+ console.log(` - Package: ${packageJson.name}`);
120
+ console.log(` - Version: ${packageJson.version}`);
121
+ console.log(` - Registry: GitHub Packages (configured in .npmrc)`);
122
+
123
+ // Ask for confirmation
124
+ const readline = require('readline');
125
+ const rl = readline.createInterface({
126
+ input: process.stdin,
127
+ output: process.stdout
128
+ });
129
+
130
+ rl.question('\nโš ๏ธ Do you want to proceed with publishing? (y/N): ', (answer) => {
131
+ rl.close();
132
+
133
+ if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
134
+ console.log('Publish cancelled.');
135
+ process.exit(0);
136
+ }
137
+
138
+ runPublish();
139
+ });
140
+ }
141
+
142
+ if (require.main === module) {
143
+ main();
144
+ }
@@ -0,0 +1,165 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to publish the package to npmjs.com (with different package name)
5
+ * Usage: node scripts/publish-to-npmjs.js
6
+ *
7
+ * This script will:
8
+ * 1. Check if NPM_TOKEN environment variable is set
9
+ * 2. Modify package.json to use a different name for npmjs.com
10
+ * 3. Run npm publish to npmjs.com
11
+ */
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+ const { execSync } = require('child_process');
16
+
17
+ function checkEnvironment() {
18
+ if (!process.env.NPM_TOKEN) {
19
+ console.error('โคซ Error: NPM_TOKEN environment variable is not set');
20
+ console.error('Please set it before running this script:');
21
+ console.error('export NPM_TOKEN=your_npm_access_token_here');
22
+ console.error('');
23
+ console.error('Make sure your npm access token has publish scope');
24
+ process.exit(1);
25
+ }
26
+
27
+ console.log(' NPM_TOKEN environment variable is set');
28
+ }
29
+
30
+ function checkNpmrc() {
31
+ const npmrcPath = path.join(__dirname, '../.npmrc');
32
+ if (!fs.existsSync(npmrcPath)) {
33
+ console.error('โคซ Error: .npmrc file not found in npm directory');
34
+ console.error('Please create one with the proper npmjs.com configuration');
35
+ console.error('See .npmrc.example for reference');
36
+ process.exit(1);
37
+ }
38
+
39
+ const npmrcContent = fs.readFileSync(npmrcPath, 'utf8');
40
+ // Check for valid npmjs.com registry configuration
41
+ const npmjsRegistryPattern = /^\/\/registry\.npmjs\.org\/?:_authToken=/m;
42
+ let npmjsRegistryFound = false;
43
+
44
+ for (const line of npmrcContent.split(/\r?\n/)) {
45
+ const trimmed = line.trim();
46
+ if (
47
+ trimmed &&
48
+ !trimmed.startsWith('#') &&
49
+ npmjsRegistryPattern.test(trimmed)
50
+ ) {
51
+ npmjsRegistryFound = true;
52
+ break;
53
+ }
54
+ }
55
+
56
+ if (!npmjsRegistryFound) {
57
+ console.warn('โš ๏ธ Warning: .npmrc file does not contain a valid npmjs.com registry configuration');
58
+ console.warn('Please check that your .npmrc includes: //registry.npmjs.org/:_authToken=YOUR_TOKEN');
59
+ } else {
60
+ console.log(' .npmrc file contains npmjs.com configuration');
61
+ }
62
+ }
63
+
64
+ function runPublish() {
65
+ console.log('\n๐Ÿš€ Starting publish process to npmjs.com...');
66
+
67
+ // Create temporary directory and copy files
68
+ const os = require('os');
69
+ const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'vtcode-npm-'));
70
+ const sourceDir = path.join(__dirname, '..');
71
+ const files = fs.readdirSync(sourceDir);
72
+
73
+ for (const file of files) {
74
+ if (file !== 'node_modules') { // Don't copy node_modules
75
+ const src = path.join(sourceDir, file);
76
+ const dest = path.join(tempDir, file);
77
+ if (fs.statSync(src).isDirectory()) {
78
+ const { cp } = require('child_process');
79
+ cp.execSync(`cp -r "${src}" "${dest}"`);
80
+ } else {
81
+ fs.copyFileSync(src, dest);
82
+ }
83
+ }
84
+ }
85
+
86
+ try {
87
+ // Read the current package.json and modify the name
88
+ const packageJsonPath = path.join(tempDir, 'package.json');
89
+ let packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
90
+
91
+ // Change the package name for npmjs.com (since 'vtcode' is taken)
92
+ packageJson.name = 'vtcode-bin';
93
+
94
+ // Remove the scoped registry config for npmjs.com publish
95
+ delete packageJson.publishConfig;
96
+
97
+ // Write the modified package.json
98
+ fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
99
+
100
+ console.log(` Package: ${packageJson.name} (v${packageJson.version})`);
101
+
102
+ // Verify npm configuration
103
+ console.log('\n๐Ÿ“‹ Checking npm configuration...');
104
+ const npmWhoami = execSync('npm whoami', { encoding: 'utf8', cwd: tempDir }).trim();
105
+ console.log(`๐Ÿ‘ค Authenticated as: ${npmWhoami}`);
106
+
107
+ // Run npm publish to npmjs.com
108
+ console.log('\n๐Ÿ“ฆ Publishing to npmjs.com...');
109
+ const publishOutput = execSync('npm publish', {
110
+ cwd: tempDir,
111
+ encoding: 'utf8'
112
+ });
113
+
114
+ console.log(' Publish output:');
115
+ console.log(publishOutput);
116
+
117
+ console.log('\n๐ŸŽ‰ Package published successfully to npmjs.com!');
118
+ console.log(`๐Ÿ”— View at: https://www.npmjs.com/package/vtcode-bin`);
119
+ } catch (error) {
120
+ console.error('โคซ Error during publish:');
121
+ console.error(error.message);
122
+ if (error.stdout) console.error('STDOUT:', error.stdout);
123
+ if (error.stderr) console.error('STDERR:', error.stderr);
124
+ process.exit(1);
125
+ } finally {
126
+ // Clean up temporary directory
127
+ const { spawn } = require('child_process');
128
+ const rmProcess = spawn('rm', ['-rf', tempDir]);
129
+ rmProcess.on('close', () => {
130
+ console.log(' Cleaned up temporary files.');
131
+ });
132
+ }
133
+ }
134
+
135
+ function main() {
136
+ console.log('๐Ÿ“ Publishing VT Code npm package to npmjs.com (with different name)');
137
+ console.log('=====================================================');
138
+
139
+ checkEnvironment();
140
+ checkNpmrc();
141
+
142
+ console.log('\n๐Ÿ“‹ Ready to publish:');
143
+
144
+ // Ask for confirmation
145
+ const readline = require('readline');
146
+ const rl = readline.createInterface({
147
+ input: process.stdin,
148
+ output: process.stdout
149
+ });
150
+
151
+ rl.question('\nโš ๏ธ Do you want to proceed with publishing to npmjs.com? (y/N): ', (answer) => {
152
+ rl.close();
153
+
154
+ if (answer.toLowerCase() !== 'y' && answer.toLowerCase() !== 'yes') {
155
+ console.log('Publish cancelled.');
156
+ process.exit(0);
157
+ }
158
+
159
+ runPublish();
160
+ });
161
+ }
162
+
163
+ if (require.main === module) {
164
+ main();
165
+ }