@anh3d0nic/qwen-code-termux-ice 16.0.4 → 16.0.7
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/bin/qwen-ice +25 -5
- package/package.json +6 -5
- package/scripts/build.js +88 -0
- package/scripts/build_package.js +37 -0
- package/scripts/build_sandbox.js +174 -0
- package/scripts/build_vscode_companion.js +30 -0
- package/scripts/check-build-status.js +148 -0
- package/scripts/check-i18n.ts +462 -0
- package/scripts/check-lockfile.js +74 -0
- package/scripts/clean.js +59 -0
- package/scripts/copy_bundle_assets.js +90 -0
- package/scripts/copy_files.js +86 -0
- package/scripts/create_alias.sh +39 -0
- package/scripts/dev.js +109 -0
- package/scripts/esbuild-shims.js +29 -0
- package/scripts/generate-git-commit-info.js +71 -0
- package/scripts/generate-settings-schema.ts +146 -0
- package/scripts/get-release-version.js +411 -0
- package/scripts/ice-mobile.js +5 -0
- package/scripts/ice-session.js +6 -0
- package/scripts/ice-skills.js +31 -0
- package/scripts/ice-teams.js +34 -0
- package/scripts/ice-v10.js +276 -0
- package/scripts/ice-v11.js +276 -0
- package/scripts/ice-v12.js +568 -0
- package/scripts/ice-v13.js +824 -0
- package/scripts/ice-v14.js +1059 -0
- package/scripts/ice-v15.js +1501 -0
- package/scripts/ice-v2.js +26 -0
- package/scripts/ice-v3-core.js +261 -0
- package/scripts/ice-v3.js +46 -0
- package/scripts/ice-v4.js +657 -0
- package/scripts/ice-v5.js +371 -0
- package/scripts/ice-v6.js +305 -0
- package/scripts/ice-v7.js +291 -0
- package/scripts/ice-v8.js +550 -0
- package/scripts/ice-v9.js +546 -0
- package/scripts/install-ice.sh +70 -0
- package/scripts/install.sh +136 -0
- package/scripts/installation/INSTALLATION_GUIDE.md +250 -0
- package/scripts/installation/install-qwen-with-source.bat +302 -0
- package/scripts/installation/install-qwen-with-source.sh +570 -0
- package/scripts/lint.js +205 -0
- package/scripts/local_telemetry.js +219 -0
- package/scripts/postinstall.cjs +235 -0
- package/scripts/pre-commit.js +22 -0
- package/scripts/prepare-package.js +186 -0
- package/scripts/prepare-termux.cjs +26 -0
- package/scripts/sandbox_command.js +128 -0
- package/scripts/start.js +86 -0
- package/scripts/telemetry.js +85 -0
- package/scripts/telemetry_gcp.js +188 -0
- package/scripts/telemetry_utils.js +450 -0
- package/scripts/test-v10.js +18 -0
- package/scripts/test-v11.js +18 -0
- package/scripts/test-v12.js +18 -0
- package/scripts/test-v13.js +18 -0
- package/scripts/test-v14.js +18 -0
- package/scripts/test-v3.js +47 -0
- package/scripts/test-v4.js +47 -0
- package/scripts/test-v6.js +59 -0
- package/scripts/test-v8.js +42 -0
- package/scripts/test-v9.js +18 -0
- package/scripts/test-windows-paths.js +51 -0
- package/scripts/tests/get-release-version.test.js +186 -0
- package/scripts/tests/test-setup.ts +12 -0
- package/scripts/tests/vitest.config.ts +26 -0
- package/scripts/unused-keys-only-in-locales.json +62 -0
- package/scripts/version.js +112 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/data/data/com.termux/files/usr/bin/bash
|
|
2
|
+
# ❄️ ICE v4.3 — One-Line Installer
|
|
3
|
+
# Qwen Code Termux by @anh3d0nic
|
|
4
|
+
# GitHub: github.com/anh3d0nic/qwen-code-termux-ice
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
# Functions
|
|
16
|
+
print_header() {
|
|
17
|
+
echo -e "${BLUE}"
|
|
18
|
+
echo "============================================================"
|
|
19
|
+
echo " ❄️ ICE v4.3 — Qwen Code Termux"
|
|
20
|
+
echo " Persistent AI Brain by @anh3d0nic"
|
|
21
|
+
echo "============================================================"
|
|
22
|
+
echo -e "${NC}"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
print_success() {
|
|
26
|
+
echo -e "${GREEN}✅ $1${NC}"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
print_warning() {
|
|
30
|
+
echo -e "${YELLOW}⚠️ $1${NC}"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
print_error() {
|
|
34
|
+
echo -e "${RED}❌ $1${NC}"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Check Termux
|
|
38
|
+
if [ ! -d "/data/data/com.termux/files" ]; then
|
|
39
|
+
print_error "This installer requires Termux on Android."
|
|
40
|
+
exit 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Check Python
|
|
44
|
+
if ! command -v python3 &> /dev/null; then
|
|
45
|
+
print_warning "Python3 not found. Installing..."
|
|
46
|
+
pkg install python -y
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
# Check pip
|
|
50
|
+
if ! command -v pip &> /dev/null; then
|
|
51
|
+
print_warning "pip not found. Installing..."
|
|
52
|
+
pkg install python-pip -y
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
print_header
|
|
56
|
+
|
|
57
|
+
# Install dependencies
|
|
58
|
+
echo "📦 Installing Python dependencies..."
|
|
59
|
+
pip install requests python-dotenv --quiet
|
|
60
|
+
print_success "Dependencies installed"
|
|
61
|
+
|
|
62
|
+
# Create directories
|
|
63
|
+
echo "📁 Creating directories..."
|
|
64
|
+
ICE_DIR="$HOME/.qwen"
|
|
65
|
+
mkdir -p "$ICE_DIR"
|
|
66
|
+
mkdir -p "$ICE_DIR/ice-memory"
|
|
67
|
+
print_success "Directories created"
|
|
68
|
+
|
|
69
|
+
# Copy ICE files
|
|
70
|
+
echo "📦 Copying ICE core files..."
|
|
71
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
72
|
+
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
|
73
|
+
|
|
74
|
+
cp "$REPO_DIR/.qwen/ice.py" "$ICE_DIR/" 2>/dev/null || print_warning "ice.py already exists"
|
|
75
|
+
cp "$REPO_DIR/.qwen/qwen.md" "$ICE_DIR/" 2>/dev/null || print_warning "qwen.md already exists"
|
|
76
|
+
cp "$REPO_DIR/.qwen/ice-auto-load.sh" "$ICE_DIR/" 2>/dev/null || print_warning "auto-load already exists"
|
|
77
|
+
print_success "ICE core files copied"
|
|
78
|
+
|
|
79
|
+
# Set permissions
|
|
80
|
+
echo "🔒 Setting permissions..."
|
|
81
|
+
chmod 700 "$ICE_DIR/ice-memory"
|
|
82
|
+
chmod +x "$ICE_DIR/ice.py" 2>/dev/null || true
|
|
83
|
+
chmod +x "$ICE_DIR/ice-auto-load.sh" 2>/dev/null || true
|
|
84
|
+
print_success "Permissions set"
|
|
85
|
+
|
|
86
|
+
# Add to bashrc
|
|
87
|
+
echo "📝 Configuring auto-load..."
|
|
88
|
+
if ! grep -q "ice-auto-load.sh" "$HOME/.bashrc" 2>/dev/null; then
|
|
89
|
+
echo "" >> "$HOME/.bashrc"
|
|
90
|
+
echo "# ❄️ ICE v4.3 Auto-Load" >> "$HOME/.bashrc"
|
|
91
|
+
echo "[ -f \"$ICE_DIR/ice-auto-load.sh\" ] && source \"$ICE_DIR/ice-auto-load.sh\"" >> "$HOME/.bashrc"
|
|
92
|
+
print_success "Added to ~/.bashrc"
|
|
93
|
+
else
|
|
94
|
+
print_warning "Auto-load already in ~/.bashrc"
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Create .env template
|
|
98
|
+
if [ ! -f "$ICE_DIR/.env" ]; then
|
|
99
|
+
echo "📝 Creating .env template..."
|
|
100
|
+
cat > "$ICE_DIR/.env" << 'ENVTEMPLATE'
|
|
101
|
+
# ❄️ ICE v4.3 — API Keys Configuration
|
|
102
|
+
# NEVER commit this file to git!
|
|
103
|
+
|
|
104
|
+
# Groq API Key (get from https://console.groq.com)
|
|
105
|
+
GROQ_API_KEY=
|
|
106
|
+
|
|
107
|
+
# Gemini API Key (get from https://aistudio.google.com)
|
|
108
|
+
GEMINI_API_KEY=
|
|
109
|
+
|
|
110
|
+
# Qwen OAuth — No key needed (built into Qwen Code)
|
|
111
|
+
ENVTEMPLATE
|
|
112
|
+
chmod 600 "$ICE_DIR/.env"
|
|
113
|
+
print_success ".env template created"
|
|
114
|
+
print_warning "Edit ~/.qwen/.env and add your API keys"
|
|
115
|
+
else
|
|
116
|
+
print_warning ".env already exists"
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
# Source bashrc
|
|
120
|
+
echo "🔄 Applying changes..."
|
|
121
|
+
source "$HOME/.bashrc" 2>/dev/null || true
|
|
122
|
+
print_success "Changes applied"
|
|
123
|
+
|
|
124
|
+
# Final message
|
|
125
|
+
echo ""
|
|
126
|
+
echo "============================================================"
|
|
127
|
+
echo " ✅ ICE v4.3 installed successfully!"
|
|
128
|
+
echo "============================================================"
|
|
129
|
+
echo ""
|
|
130
|
+
echo "📚 Next steps:"
|
|
131
|
+
echo " 1. Edit ~/.qwen/.env and add your API keys (optional)"
|
|
132
|
+
echo " 2. Open a new terminal or run: source ~/.bashrc"
|
|
133
|
+
echo " 3. Type: ice (to test ICE CLI)"
|
|
134
|
+
echo ""
|
|
135
|
+
echo "🔗 GitHub: github.com/anh3d0nic/qwen-code-termux-ice"
|
|
136
|
+
echo "============================================================"
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
# Installation Guide for Qwen Code with Source Tracking
|
|
2
|
+
|
|
3
|
+
This guide describes how to install Node.js and Qwen Code with source information tracking.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The installation scripts automate the process of installing Node.js (if not present or below version 20) and Qwen Code, while capturing and storing the installation source information for analytics and tracking purposes.
|
|
8
|
+
|
|
9
|
+
## Installation Scripts
|
|
10
|
+
|
|
11
|
+
We provide platform-specific installation scripts:
|
|
12
|
+
|
|
13
|
+
- **Linux/macOS**: `install-qwen-with-source.sh`
|
|
14
|
+
- **Windows**: `install-qwen-with-source.bat`
|
|
15
|
+
|
|
16
|
+
## Linux/macOS Installation
|
|
17
|
+
|
|
18
|
+
### Script: install-qwen-with-source.sh
|
|
19
|
+
|
|
20
|
+
#### Features:
|
|
21
|
+
|
|
22
|
+
- Checks for existing Node.js installation and version
|
|
23
|
+
- Installs Node.js 20+ if needed using NVM
|
|
24
|
+
- Installs Qwen Code globally with source information
|
|
25
|
+
- Stores the source information in `~/.qwen/source.json`
|
|
26
|
+
|
|
27
|
+
#### Usage:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Install with a specific source
|
|
31
|
+
sh install-qwen-with-source.sh --source github
|
|
32
|
+
|
|
33
|
+
# Install with internal source
|
|
34
|
+
sh install-qwen-with-source.sh -s internal
|
|
35
|
+
|
|
36
|
+
# Show help
|
|
37
|
+
sh install-qwen-with-source.sh --help
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Supported Source Values:
|
|
41
|
+
|
|
42
|
+
- `github` - Installed from GitHub repository
|
|
43
|
+
- `npm` - Installed from npm registry
|
|
44
|
+
- `internal` - Internal installation
|
|
45
|
+
- `local-build` - Local build installation
|
|
46
|
+
|
|
47
|
+
#### How it Works:
|
|
48
|
+
|
|
49
|
+
1. The script accepts a `--source` parameter to specify where Qwen Code is being installed from
|
|
50
|
+
2. It installs Node.js if needed
|
|
51
|
+
3. It installs Qwen Code globally
|
|
52
|
+
4. It creates `~/.qwen/source.json` with the specified source information
|
|
53
|
+
|
|
54
|
+
#### Important Notes:
|
|
55
|
+
|
|
56
|
+
⚠️ **After installation, you need to restart your terminal or run:**
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
source ~/.bashrc # For bash users
|
|
60
|
+
# or
|
|
61
|
+
source ~/.zshrc # For zsh users
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This is required to load the newly installed Node.js and Qwen Code into your PATH.
|
|
65
|
+
|
|
66
|
+
#### Prerequisites:
|
|
67
|
+
|
|
68
|
+
- curl (for NVM installation and script download)
|
|
69
|
+
- bash-compatible shell
|
|
70
|
+
|
|
71
|
+
## Windows Installation
|
|
72
|
+
|
|
73
|
+
### Script: install-qwen-with-source.bat
|
|
74
|
+
|
|
75
|
+
#### Features:
|
|
76
|
+
|
|
77
|
+
- Checks for existing Node.js installation and version (requires version 18+)
|
|
78
|
+
- Automatically downloads and installs Node.js 24 LTS if not present or version is too low
|
|
79
|
+
- Installs Qwen Code globally with source information
|
|
80
|
+
- Stores the source information in `%USERPROFILE%\.qwen\source.json`
|
|
81
|
+
|
|
82
|
+
#### Prerequisites:
|
|
83
|
+
|
|
84
|
+
- **PowerShell (Administrator)**: The script must be run in PowerShell with Administrator privileges
|
|
85
|
+
- Internet connection for downloading Node.js and Qwen Code
|
|
86
|
+
|
|
87
|
+
#### Usage:
|
|
88
|
+
|
|
89
|
+
> ⚠️ **Important**: You must run PowerShell as Administrator to install Node.js and global npm packages.
|
|
90
|
+
|
|
91
|
+
**Step 1**: Open PowerShell as Administrator
|
|
92
|
+
|
|
93
|
+
- Right-click on PowerShell and select "Run as Administrator"
|
|
94
|
+
- Or press `Win + X` and select "Windows PowerShell (Admin)"
|
|
95
|
+
|
|
96
|
+
**Step 2**: Navigate to the script directory and run:
|
|
97
|
+
|
|
98
|
+
```powershell
|
|
99
|
+
# Install with a specific source using --source parameter
|
|
100
|
+
./install-qwen-with-source.bat --source github
|
|
101
|
+
|
|
102
|
+
# Install with short parameter
|
|
103
|
+
./install-qwen-with-source.bat -s internal
|
|
104
|
+
|
|
105
|
+
# Use default source (unknown)
|
|
106
|
+
./install-qwen-with-source.bat
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Supported Source Values:
|
|
110
|
+
|
|
111
|
+
- `github` - Installed from GitHub repository
|
|
112
|
+
- `npm` - Installed from npm registry
|
|
113
|
+
- `internal` - Internal installation
|
|
114
|
+
- `local-build` - Local build installation
|
|
115
|
+
|
|
116
|
+
#### How it Works:
|
|
117
|
+
|
|
118
|
+
1. The script accepts a `--source` or `-s` parameter to specify where Qwen Code is being installed from
|
|
119
|
+
2. It checks if Node.js is already installed and if the version is 18 or higher
|
|
120
|
+
3. If Node.js is not installed or version is too low, it automatically downloads and installs Node.js 24 LTS
|
|
121
|
+
4. It installs Qwen Code globally using npm
|
|
122
|
+
5. It creates `%USERPROFILE%\.qwen\source.json` with the specified source information
|
|
123
|
+
|
|
124
|
+
#### Why Administrator Privileges are Required:
|
|
125
|
+
|
|
126
|
+
- Installing Node.js requires writing to `C:\Program Files\nodejs`
|
|
127
|
+
- Installing global npm packages requires elevated permissions
|
|
128
|
+
- Modifying system PATH environment variables requires Administrator access
|
|
129
|
+
|
|
130
|
+
## Installation Source Feature
|
|
131
|
+
|
|
132
|
+
### Overview
|
|
133
|
+
|
|
134
|
+
This feature implements the ability to capture and store the installation source of the Qwen Code package. The source information is used for analytics and tracking purposes.
|
|
135
|
+
|
|
136
|
+
### Storage Location
|
|
137
|
+
|
|
138
|
+
The installation source is stored in a separate file at:
|
|
139
|
+
|
|
140
|
+
- **Unix/Linux/macOS**: `~/.qwen/source.json`
|
|
141
|
+
- **Windows**: `%USERPROFILE%\.qwen\source.json` (equivalent to `C:\Users\{username}\.qwen\source.json`)
|
|
142
|
+
|
|
143
|
+
### File Format
|
|
144
|
+
|
|
145
|
+
The `source.json` file contains:
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"source": "github"
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### How the Source Information is Used
|
|
154
|
+
|
|
155
|
+
1. **Telemetry Tracking**: The source information is included in RUM (Real User Monitoring) telemetry logs
|
|
156
|
+
2. **Analytics**: Helps understand how users are discovering and installing Qwen Code
|
|
157
|
+
3. **Distribution Analysis**: Tracks which distribution channels are most popular
|
|
158
|
+
|
|
159
|
+
### Technical Implementation
|
|
160
|
+
|
|
161
|
+
- The source information is stored as a separate JSON file
|
|
162
|
+
- The `QwenLogger` class reads this file during telemetry initialization
|
|
163
|
+
- The source is included in the `app.channel` field of the RUM payload
|
|
164
|
+
- The implementation gracefully handles missing files, unknown values, and parsing errors
|
|
165
|
+
|
|
166
|
+
### Verification
|
|
167
|
+
|
|
168
|
+
After installation and restarting your terminal (or sourcing your shell configuration), you can verify the source information:
|
|
169
|
+
|
|
170
|
+
**Linux/macOS:**
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
cat ~/.qwen/source.json
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**Windows:**
|
|
177
|
+
|
|
178
|
+
```cmd
|
|
179
|
+
type %USERPROFILE%\.qwen\source.json
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Manual Installation (Without Source Tracking)
|
|
183
|
+
|
|
184
|
+
If you prefer not to use the installation scripts or don't want source tracking:
|
|
185
|
+
|
|
186
|
+
### Prerequisites
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# Node.js 20+
|
|
190
|
+
curl -qL https://www.npmjs.com/install.sh | sh
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### NPM Installation
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
npm install -g @qwen-code/qwen-code@latest
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Homebrew (macOS, Linux)
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
brew install qwen-code
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Troubleshooting
|
|
206
|
+
|
|
207
|
+
### Script Execution Issues
|
|
208
|
+
|
|
209
|
+
**Linux/macOS:**
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
# Run with sh
|
|
213
|
+
sh install-qwen-with-source.sh --source github
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Windows (PowerShell as Administrator):**
|
|
217
|
+
|
|
218
|
+
```powershell
|
|
219
|
+
# Run the script with --source parameter
|
|
220
|
+
./install-qwen-with-source.bat --source github
|
|
221
|
+
|
|
222
|
+
# Or with short parameter
|
|
223
|
+
./install-qwen-with-source.bat -s github
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### Node.js Installation Issues
|
|
227
|
+
|
|
228
|
+
**Linux/macOS:**
|
|
229
|
+
|
|
230
|
+
- Ensure NVM is installed: `curl -o- https://qwen-code-assets.oss-cn-hangzhou.aliyuncs.com/installation/install_nvm.sh | bash`
|
|
231
|
+
- Restart your terminal or run: `source ~/.bashrc`
|
|
232
|
+
|
|
233
|
+
**Windows:**
|
|
234
|
+
|
|
235
|
+
- Install NVM for Windows from: https://github.com/coreybutler/nvm-windows/releases
|
|
236
|
+
- After installation, run the script again
|
|
237
|
+
|
|
238
|
+
### Permission Issues
|
|
239
|
+
|
|
240
|
+
You may need administrative privileges for global npm installation:
|
|
241
|
+
|
|
242
|
+
- **Linux/macOS**: Use `sudo` with npm
|
|
243
|
+
- **Windows**: Run PowerShell as Administrator (required for Node.js installation and global npm packages)
|
|
244
|
+
|
|
245
|
+
## Notes
|
|
246
|
+
|
|
247
|
+
- The scripts require internet access to download Node.js and Qwen Code
|
|
248
|
+
- Administrative privileges may be required for global npm installation
|
|
249
|
+
- The installation source is stored locally and used for tracking purposes only
|
|
250
|
+
- If the source file is missing or invalid, the application continues to work normally
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
REM Script to install Node.js and Qwen Code with source information
|
|
3
|
+
REM This script handles the installation process and sets the installation source
|
|
4
|
+
REM
|
|
5
|
+
REM Usage: install-qwen-with-source.bat --source <source>
|
|
6
|
+
REM install-qwen-with-source.bat -s <source>
|
|
7
|
+
REM
|
|
8
|
+
|
|
9
|
+
setlocal enabledelayedexpansion
|
|
10
|
+
|
|
11
|
+
set "SOURCE=unknown"
|
|
12
|
+
|
|
13
|
+
REM Parse command line arguments
|
|
14
|
+
:parse_args
|
|
15
|
+
if "%~1"=="" goto end_parse
|
|
16
|
+
if /i "%~1"=="--source" (
|
|
17
|
+
if not "%~2"=="" (
|
|
18
|
+
set "SOURCE=%~2"
|
|
19
|
+
shift
|
|
20
|
+
shift
|
|
21
|
+
goto parse_args
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
if /i "%~1"=="-s" (
|
|
25
|
+
if not "%~2"=="" (
|
|
26
|
+
set "SOURCE=%~2"
|
|
27
|
+
shift
|
|
28
|
+
shift
|
|
29
|
+
goto parse_args
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
shift
|
|
33
|
+
goto parse_args
|
|
34
|
+
|
|
35
|
+
:end_parse
|
|
36
|
+
|
|
37
|
+
echo ===========================================
|
|
38
|
+
echo Qwen Code Installation Script with Source Tracking
|
|
39
|
+
echo ===========================================
|
|
40
|
+
echo.
|
|
41
|
+
echo INFO: Installation source: %SOURCE%
|
|
42
|
+
echo.
|
|
43
|
+
|
|
44
|
+
REM Check if Node.js is already installed
|
|
45
|
+
call :CheckCommandExists node
|
|
46
|
+
if !ERRORLEVEL! EQU 0 (
|
|
47
|
+
for /f "delims=" %%i in ('node --version') do set "NODE_VERSION=%%i"
|
|
48
|
+
echo INFO: Node.js is already installed: !NODE_VERSION!
|
|
49
|
+
|
|
50
|
+
REM Extract major version number
|
|
51
|
+
set "MAJOR_VERSION=!NODE_VERSION:v=!"
|
|
52
|
+
for /f "tokens=1 delims=." %%a in ("!MAJOR_VERSION!") do (
|
|
53
|
+
set "MAJOR_VERSION=%%a"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
if !MAJOR_VERSION! GEQ 20 (
|
|
57
|
+
echo INFO: Node.js version !NODE_VERSION! is sufficient. Skipping Node.js installation.
|
|
58
|
+
goto :InstallQwenCode
|
|
59
|
+
) else (
|
|
60
|
+
echo INFO: Node.js version !NODE_VERSION! is too low. Need version 20 or higher.
|
|
61
|
+
echo INFO: Installing Node.js 20+
|
|
62
|
+
call :InstallNodeJSDirectly
|
|
63
|
+
if !ERRORLEVEL! NEQ 0 (
|
|
64
|
+
echo ERROR: Failed to install Node.js. Cannot continue with Qwen Code installation.
|
|
65
|
+
exit /b 1
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
) else (
|
|
69
|
+
echo INFO: Node.js not found. Installing Node.js 20+
|
|
70
|
+
call :InstallNodeJSDirectly
|
|
71
|
+
if !ERRORLEVEL! NEQ 0 (
|
|
72
|
+
echo ERROR: Failed to install Node.js. Cannot continue with Qwen Code installation.
|
|
73
|
+
exit /b 1
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
:InstallQwenCode
|
|
78
|
+
|
|
79
|
+
REM Verify npm is available before installing Qwen Code
|
|
80
|
+
REM Always use full path to npm to avoid local node_modules conflicts
|
|
81
|
+
set "NODEJS_PATH=C:\Program Files\nodejs"
|
|
82
|
+
set "NODEJS_PATH_X86=C:\Program Files (x86)\nodejs"
|
|
83
|
+
|
|
84
|
+
if exist "!NODEJS_PATH!\npm.cmd" (
|
|
85
|
+
echo INFO: Using npm from !NODEJS_PATH!
|
|
86
|
+
set "NPM_CMD=!NODEJS_PATH!\npm.cmd"
|
|
87
|
+
) else if exist "!NODEJS_PATH_X86!\npm.cmd" (
|
|
88
|
+
echo INFO: Using npm from !NODEJS_PATH_X86!
|
|
89
|
+
set "NPM_CMD=!NODEJS_PATH_X86!\npm.cmd"
|
|
90
|
+
) else (
|
|
91
|
+
call :CheckCommandExists npm
|
|
92
|
+
if !ERRORLEVEL! NEQ 0 (
|
|
93
|
+
echo ERROR: npm command not found. Node.js installation may have failed.
|
|
94
|
+
echo INFO: Please restart your command prompt and try again.
|
|
95
|
+
echo INFO: If the problem persists, manually install Node.js from: https://nodejs.org/
|
|
96
|
+
exit /b 1
|
|
97
|
+
)
|
|
98
|
+
set "NPM_CMD=npm"
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
REM Install Qwen Code with source information
|
|
102
|
+
echo INFO: Installing Qwen Code with source: %SOURCE%
|
|
103
|
+
echo INFO: Running: %NPM_CMD% install -g @qwen-code/qwen-code@latest --registry https://registry.npmmirror.com
|
|
104
|
+
call "%NPM_CMD%" install -g @qwen-code/qwen-code@latest --registry https://registry.npmmirror.com
|
|
105
|
+
|
|
106
|
+
if %ERRORLEVEL% EQU 0 (
|
|
107
|
+
echo SUCCESS: Qwen Code installed successfully!
|
|
108
|
+
) else (
|
|
109
|
+
echo ERROR: Failed to install Qwen Code.
|
|
110
|
+
exit /b 1
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
REM Create source.json only if --source or -s was explicitly provided
|
|
114
|
+
if not "!SOURCE!"=="unknown" (
|
|
115
|
+
echo INFO: Creating source.json in %USERPROFILE%\.qwen...
|
|
116
|
+
|
|
117
|
+
set "QWEN_DIR=%USERPROFILE%\.qwen"
|
|
118
|
+
if not exist "!QWEN_DIR!" (
|
|
119
|
+
mkdir "!QWEN_DIR!"
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
REM Create the source.json file with the installation source
|
|
123
|
+
(
|
|
124
|
+
echo {
|
|
125
|
+
echo "source": "!SOURCE!"
|
|
126
|
+
echo }
|
|
127
|
+
) > "!QWEN_DIR!\source.json"
|
|
128
|
+
|
|
129
|
+
echo SUCCESS: Installation source saved to %USERPROFILE%\.qwen\source.json
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
REM Verify installation
|
|
133
|
+
call :CheckCommandExists qwen
|
|
134
|
+
if %ERRORLEVEL% EQU 0 (
|
|
135
|
+
echo SUCCESS: Qwen Code is available as 'qwen' command.
|
|
136
|
+
call qwen --version
|
|
137
|
+
) else (
|
|
138
|
+
echo WARNING: Qwen Code may not be in PATH. Please check your npm global bin directory.
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
echo.
|
|
142
|
+
echo ===========================================
|
|
143
|
+
echo SUCCESS: Installation completed!
|
|
144
|
+
echo The source information is stored in %USERPROFILE%\.qwen\source.json
|
|
145
|
+
echo Tips: Please restart your terminal and run: qwen
|
|
146
|
+
echo.
|
|
147
|
+
echo ===========================================
|
|
148
|
+
|
|
149
|
+
endlocal
|
|
150
|
+
exit /b 0
|
|
151
|
+
|
|
152
|
+
REM ============================================================
|
|
153
|
+
REM Function: CheckCommandExists
|
|
154
|
+
REM Description: Check if a command exists in the system
|
|
155
|
+
REM ============================================================
|
|
156
|
+
:CheckCommandExists
|
|
157
|
+
where %~1 >nul 2>&1
|
|
158
|
+
exit /b %ERRORLEVEL%
|
|
159
|
+
|
|
160
|
+
REM ============================================================
|
|
161
|
+
REM Function: InstallNodeJSDirectly
|
|
162
|
+
REM Description: Download and install Node.js directly from official website
|
|
163
|
+
REM ============================================================
|
|
164
|
+
:InstallNodeJSDirectly
|
|
165
|
+
echo INFO: Downloading Node.js LTS (20.x) from official website
|
|
166
|
+
|
|
167
|
+
REM Create temp directory for download
|
|
168
|
+
set "TEMP_DIR=%TEMP%\qwen-nodejs-install"
|
|
169
|
+
if not exist "%TEMP_DIR%" mkdir "%TEMP_DIR%"
|
|
170
|
+
|
|
171
|
+
REM Determine architecture
|
|
172
|
+
set "ARCH=x64"
|
|
173
|
+
if "%PROCESSOR_ARCHITECTURE%"=="x86" set "ARCH=x86"
|
|
174
|
+
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set "ARCH=x64"
|
|
175
|
+
if defined PROCESSOR_ARCHITEW6432 set "ARCH=x64"
|
|
176
|
+
|
|
177
|
+
REM Set Node.js download URL (LTS version 20.x)
|
|
178
|
+
set "NODE_VERSION=20.18.1"
|
|
179
|
+
set "NODE_URL=https://nodejs.org/dist/v!NODE_VERSION!/node-v!NODE_VERSION!-!ARCH!.msi"
|
|
180
|
+
set "NODE_INSTALLER=%TEMP_DIR%\nodejs-installer.msi"
|
|
181
|
+
|
|
182
|
+
echo INFO: Downloading from: !NODE_URL!
|
|
183
|
+
echo INFO: Architecture: !ARCH!
|
|
184
|
+
|
|
185
|
+
REM Download Node.js installer using PowerShell
|
|
186
|
+
powershell -Command "try { Invoke-WebRequest -Uri '!NODE_URL!' -OutFile '!NODE_INSTALLER!' -UseBasicParsing; Write-Host 'Download completed successfully.' } catch { Write-Host 'Download failed:' $_.Exception.Message; exit 1 }"
|
|
187
|
+
|
|
188
|
+
if !ERRORLEVEL! NEQ 0 (
|
|
189
|
+
echo ERROR: Failed to download Node.js installer from official source.
|
|
190
|
+
echo INFO: Please manually download and install Node.js from: https://nodejs.org/
|
|
191
|
+
echo INFO: After manual installation, restart your command prompt and run this script again.
|
|
192
|
+
exit /b 1
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
if not exist "!NODE_INSTALLER!" (
|
|
196
|
+
echo ERROR: Node.js installer not found after download.
|
|
197
|
+
exit /b 1
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
echo INFO: Installing Node.js silently
|
|
201
|
+
REM Install Node.js silently
|
|
202
|
+
msiexec /i "!NODE_INSTALLER!" /quiet /norestart ADDLOCAL=ALL
|
|
203
|
+
|
|
204
|
+
if !ERRORLEVEL! NEQ 0 (
|
|
205
|
+
echo ERROR: Failed to install Node.js.
|
|
206
|
+
echo INFO: You may need to run this script as Administrator.
|
|
207
|
+
echo INFO: Or manually install Node.js from: https://nodejs.org/
|
|
208
|
+
exit /b 1
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
echo INFO: Node.js installation completed.
|
|
212
|
+
|
|
213
|
+
REM Clean up installer
|
|
214
|
+
del "!NODE_INSTALLER!" 2>nul
|
|
215
|
+
rmdir "!TEMP_DIR!" 2>nul
|
|
216
|
+
|
|
217
|
+
REM Refresh environment variables
|
|
218
|
+
echo INFO: Refreshing environment variables
|
|
219
|
+
call :RefreshEnvVars
|
|
220
|
+
|
|
221
|
+
REM Verify installation and return success
|
|
222
|
+
set "NODEJS_INSTALL_PATH=C:\Program Files\nodejs"
|
|
223
|
+
if exist "!NODEJS_INSTALL_PATH!\node.exe" (
|
|
224
|
+
for /f "delims=" %%i in ('"!NODEJS_INSTALL_PATH!\node.exe" --version') do set "NODE_VERSION=%%i"
|
|
225
|
+
echo SUCCESS: Node.js !NODE_VERSION! installed successfully!
|
|
226
|
+
exit /b 0
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
set "NODEJS_INSTALL_PATH_X86=C:\Program Files (x86)\nodejs"
|
|
230
|
+
if exist "!NODEJS_INSTALL_PATH_X86!\node.exe" (
|
|
231
|
+
for /f "delims=" %%i in ('"!NODEJS_INSTALL_PATH_X86!\node.exe" --version') do set "NODE_VERSION=%%i"
|
|
232
|
+
echo SUCCESS: Node.js !NODE_VERSION! installed successfully!
|
|
233
|
+
exit /b 0
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
call :CheckCommandExists node
|
|
237
|
+
if !ERRORLEVEL! EQU 0 (
|
|
238
|
+
for /f "delims=" %%i in ('node --version') do set "NODE_VERSION=%%i"
|
|
239
|
+
echo SUCCESS: Node.js !NODE_VERSION! installed successfully!
|
|
240
|
+
exit /b 0
|
|
241
|
+
) else (
|
|
242
|
+
echo WARNING: Node.js installed but not found in PATH.
|
|
243
|
+
echo INFO: Trying to use Node.js from default installation path
|
|
244
|
+
|
|
245
|
+
REM Try to use Node.js directly from installation path
|
|
246
|
+
set "NODE_PATH=C:\Program Files\nodejs"
|
|
247
|
+
if exist "%NODE_PATH%\node.exe" (
|
|
248
|
+
echo INFO: Found Node.js at %NODE_PATH%
|
|
249
|
+
REM Update PATH for current session
|
|
250
|
+
set "PATH=%PATH%;%NODE_PATH%"
|
|
251
|
+
|
|
252
|
+
REM Test if node works now
|
|
253
|
+
"%NODE_PATH%\node.exe" --version >nul 2>&1
|
|
254
|
+
if !ERRORLEVEL! EQU 0 (
|
|
255
|
+
for /f "delims=" %%i in ('"%NODE_PATH%\node.exe" --version') do set "NODE_VERSION=%%i"
|
|
256
|
+
echo SUCCESS: Node.js %NODE_VERSION% is working from %NODE_PATH%
|
|
257
|
+
exit /b 0
|
|
258
|
+
)
|
|
259
|
+
)
|
|
260
|
+
|
|
261
|
+
REM Try x86 path
|
|
262
|
+
set "NODE_PATH_X86=C:\Program Files (x86)\nodejs"
|
|
263
|
+
if exist "%NODE_PATH_X86%\node.exe" (
|
|
264
|
+
echo INFO: Found Node.js at %NODE_PATH_X86%
|
|
265
|
+
REM Update PATH for current session
|
|
266
|
+
set "PATH=%PATH%;%NODE_PATH_X86%"
|
|
267
|
+
|
|
268
|
+
REM Test if node works now
|
|
269
|
+
"%NODE_PATH_X86%\node.exe" --version >nul 2>&1
|
|
270
|
+
if !ERRORLEVEL! EQU 0 (
|
|
271
|
+
for /f "delims=" %%i in ('"%NODE_PATH_X86%\node.exe" --version') do set "NODE_VERSION=%%i"
|
|
272
|
+
echo SUCCESS: Node.js %NODE_VERSION% is working from %NODE_PATH_X86%
|
|
273
|
+
exit /b 0
|
|
274
|
+
)
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
echo ERROR: Node.js installation completed but cannot be executed
|
|
278
|
+
exit /b 1
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
exit /b 0
|
|
282
|
+
|
|
283
|
+
REM ============================================================
|
|
284
|
+
REM Function: RefreshEnvVars
|
|
285
|
+
REM Description: Refresh environment variables without restarting
|
|
286
|
+
REM ============================================================
|
|
287
|
+
:RefreshEnvVars
|
|
288
|
+
REM Add Node.js to PATH if not already there
|
|
289
|
+
set "NODEJS_DIR=C:\Program Files\nodejs"
|
|
290
|
+
if exist "!NODEJS_DIR!\node.exe" (
|
|
291
|
+
echo INFO: Found Node.js at !NODEJS_DIR!
|
|
292
|
+
set "PATH=!PATH!;!NODEJS_DIR!"
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
REM Try alternative path for x86 systems
|
|
296
|
+
set "NODEJS_DIR_X86=C:\Program Files (x86)\nodejs"
|
|
297
|
+
if exist "!NODEJS_DIR_X86!\node.exe" (
|
|
298
|
+
echo INFO: Found Node.js at !NODEJS_DIR_X86!
|
|
299
|
+
set "PATH=!PATH!;!NODEJS_DIR_X86!"
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
exit /b 0
|