vmcode-cli 1.0.0

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.
Files changed (56) hide show
  1. package/INSTALLATION_METHODS.md +181 -0
  2. package/LICENSE +21 -0
  3. package/README.md +199 -0
  4. package/bin/npm-wrapper.js +171 -0
  5. package/bin/rg +0 -0
  6. package/bin/rg.exe +0 -0
  7. package/config.yaml.example +159 -0
  8. package/package.json +42 -0
  9. package/requirements.txt +7 -0
  10. package/scripts/install.js +132 -0
  11. package/setup.bat +114 -0
  12. package/setup.sh +135 -0
  13. package/src/__init__.py +4 -0
  14. package/src/core/__init__.py +1 -0
  15. package/src/core/agentic.py +2342 -0
  16. package/src/core/chat_manager.py +1201 -0
  17. package/src/core/config_manager.py +269 -0
  18. package/src/core/init.py +161 -0
  19. package/src/core/sub_agent.py +174 -0
  20. package/src/exceptions.py +75 -0
  21. package/src/llm/__init__.py +1 -0
  22. package/src/llm/client.py +149 -0
  23. package/src/llm/config.py +445 -0
  24. package/src/llm/prompts.py +569 -0
  25. package/src/llm/providers.py +402 -0
  26. package/src/llm/token_tracker.py +220 -0
  27. package/src/ui/__init__.py +1 -0
  28. package/src/ui/banner.py +103 -0
  29. package/src/ui/commands.py +489 -0
  30. package/src/ui/displays.py +167 -0
  31. package/src/ui/main.py +351 -0
  32. package/src/ui/prompt_utils.py +162 -0
  33. package/src/utils/__init__.py +1 -0
  34. package/src/utils/editor.py +158 -0
  35. package/src/utils/gitignore_filter.py +149 -0
  36. package/src/utils/logger.py +254 -0
  37. package/src/utils/markdown.py +32 -0
  38. package/src/utils/settings.py +94 -0
  39. package/src/utils/tools/__init__.py +55 -0
  40. package/src/utils/tools/command_executor.py +217 -0
  41. package/src/utils/tools/create_file.py +143 -0
  42. package/src/utils/tools/definitions.py +193 -0
  43. package/src/utils/tools/directory.py +374 -0
  44. package/src/utils/tools/file_editor.py +345 -0
  45. package/src/utils/tools/file_helpers.py +109 -0
  46. package/src/utils/tools/file_reader.py +331 -0
  47. package/src/utils/tools/formatters.py +458 -0
  48. package/src/utils/tools/parallel_executor.py +195 -0
  49. package/src/utils/validation.py +117 -0
  50. package/src/utils/web_search.py +71 -0
  51. package/vmcode-proxy/.env.example +5 -0
  52. package/vmcode-proxy/README.md +235 -0
  53. package/vmcode-proxy/package-lock.json +947 -0
  54. package/vmcode-proxy/package.json +20 -0
  55. package/vmcode-proxy/server.js +248 -0
  56. package/vmcode-proxy/server.js.bak +157 -0
@@ -0,0 +1,181 @@
1
+ # vmCode Installation Methods
2
+
3
+ ## Summary
4
+
5
+ vmCode now supports **two installation methods**:
6
+
7
+ 1. **npm install** - Recommended, easiest
8
+ 2. **Git clone + setup script** - For development/contributors
9
+
10
+ Both methods result in a `vmcode` command you can run from anywhere.
11
+
12
+ ---
13
+
14
+ ## Method 1: npm install (Recommended)
15
+
16
+ ```bash
17
+ npm install -g vmcode-cli
18
+ vmcode
19
+ ```
20
+
21
+ **What happens:**
22
+ - Downloads package from npm
23
+ - Runs `scripts/install.js` post-install
24
+ - Checks for Python 3.9+
25
+ - Installs Python dependencies via pip
26
+ - Creates `config.yaml` from example
27
+ - Sets up global `vmcode` command
28
+
29
+ **Requirements:**
30
+ - Node.js 14+
31
+ - Python 3.9+
32
+ - pip
33
+
34
+ **Files used:**
35
+ - `package.json` - npm package definition
36
+ - `bin/npm-wrapper.js` - entry point
37
+ - `scripts/install.js` - post-install script
38
+ - `.npmignore` - controls what's published
39
+
40
+ ---
41
+
42
+ ## Method 2: Git Clone + Setup
43
+
44
+ ```bash
45
+ git clone <repository-url>
46
+ cd vmcode
47
+ ./setup.sh # Linux/macOS
48
+ # or
49
+ setup.bat # Windows
50
+ ```
51
+
52
+ **What happens:**
53
+ - Checks for Python 3.9+
54
+ - Installs Python dependencies via pip
55
+ - Creates `config.yaml` from example
56
+ - Creates `vmcode` command in `~/.local/bin/` (Linux/macOS) or `%USERPROFILE%\bin` (Windows)
57
+ - Adds to PATH (or shows instructions)
58
+
59
+ **Requirements:**
60
+ - Python 3.9+
61
+ - pip
62
+
63
+ **Files used:**
64
+ - `setup.sh` - Linux/macOS setup script
65
+ - `setup.bat` - Windows setup script
66
+
67
+ ---
68
+
69
+ ## How the Git Clone Setup Works
70
+
71
+ ### Linux/macOS (`setup.sh`)
72
+
73
+ 1. Creates `~/.local/bin/vmcode` script
74
+ 2. Makes it executable
75
+ 3. Checks if `~/.local/bin` is in PATH
76
+ 4. If not in PATH, shows instructions to add to `~/.bashrc` or `~/.zshrc`
77
+
78
+ ### Windows (`setup.bat`)
79
+
80
+ 1. Creates `%USERPROFILE%\bin\vmcode.bat` batch file
81
+ 2. Checks if `%USERPROFILE%\bin` is in PATH
82
+ 3. If not in PATH, shows GUI instructions to add to Environment Variables
83
+
84
+ ---
85
+
86
+ ## Files Summary
87
+
88
+ ### npm Installation
89
+ ```
90
+ bin/npm-wrapper.js # npm entry point (launches Python)
91
+ scripts/install.js # npm post-install (installs deps)
92
+ package.json # npm package definition
93
+ .npmignore # npm package exclusions
94
+ ```
95
+
96
+ ### Git Clone Installation
97
+ ```
98
+ setup.sh # Linux/macOS setup
99
+ setup.bat # Windows setup
100
+ ```
101
+
102
+ ### Shared (Both methods)
103
+ ```
104
+ config.yaml.example # Configuration template
105
+ requirements.txt # Python dependencies
106
+ src/ # Python application
107
+ .gitignore # Protects config.yaml
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Comparison
113
+
114
+ | Feature | npm | Git Clone |
115
+ |---------|-----|------------|
116
+ | Easiest | ✅ | ❌ |
117
+ | Auto-deps | ✅ | ✅ |
118
+ | Auto-config | ✅ | ✅ |
119
+ | Auto-command | ✅ | ✅ |
120
+ | No npm required | ❌ | ✅ |
121
+ | For contributors | ❌ | ✅ |
122
+ | Published to registry | ✅ | ❌ |
123
+
124
+ ---
125
+
126
+ ## Choosing a Method
127
+
128
+ **Use npm if:**
129
+ - You want the easiest installation
130
+ - You don't need to modify the code
131
+ - You're an end user
132
+
133
+ **Use git clone if:**
134
+ - You want to contribute
135
+ - You need to modify the code
136
+ - You don't have npm installed
137
+ - You're developing vmCode
138
+
139
+ ---
140
+
141
+ ## Troubleshooting
142
+
143
+ ### "vmcode: command not found" (npm)
144
+ ```bash
145
+ # Check npm global location
146
+ npm config get prefix
147
+
148
+ # Add to PATH (example for Linux/macOS)
149
+ export PATH="$(npm config get prefix)/bin:$PATH"
150
+ ```
151
+
152
+ ### "vmcode: command not found" (git clone)
153
+ ```bash
154
+ # For Linux/macOS
155
+ export PATH="$HOME/.local/bin:$PATH"
156
+ # Then reload shell
157
+ source ~/.bashrc # or ~/.zshrc
158
+ ```
159
+
160
+ ### "Python not found"
161
+ - Install Python 3.9+ from https://python.org
162
+ - Make sure it's in your PATH
163
+
164
+ ---
165
+
166
+ ## Uninstallation
167
+
168
+ ### npm
169
+ ```bash
170
+ npm uninstall -g vmcode-cli
171
+ ```
172
+
173
+ ### Git Clone
174
+ ```bash
175
+ # Remove the command
176
+ rm ~/.local/bin/vmcode # Linux/macOS
177
+ rm %USERPROFILE%\bin\vmcode.bat # Windows
178
+
179
+ # Remove the project
180
+ rm -rf vmcode
181
+ ```
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Vincent Miranda
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
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,199 @@
1
+ ## vmCode
2
+
3
+ A CLI-based AI coding assistant capable of codebase search, file editing, computer use, and web search.
4
+
5
+ <img width="1850" height="396" alt="image" src="https://github.com/user-attachments/assets/4f20cc22-a7d9-4423-afbf-15bbe1e29890" />
6
+
7
+ ## Features
8
+
9
+ - **Multiple LLM Provider Support**: OpenAI, Anthropic, OpenRouter, GLM, Gemini, Kimi, MiniMax, and local models
10
+ - **Tool-Based Interaction**: Code search (`rg`), file editing, directory operations, and web search
11
+ - **Multiple Modes**: Edit (full access), Plan (read-only), and Learn (documentation style)
12
+ - **Parallel Execution**: Run multiple tools concurrently for efficiency
13
+ - **Conversation History**: Markdown logging with context compaction
14
+ - **Approval Workflows**: Safety checks for dangerous commands
15
+
16
+ ## vmCode Free Tier
17
+
18
+ The `vmcode_free` provider is included as a convenient default option for new users. It uses free LLM models with **no API key required**.
19
+
20
+ ### How It Works
21
+
22
+ When using `vmcode_free`, your conversations are routed through vmCode's proxy server to access free LLM models:
23
+
24
+ - All chat messages, code snippets, and file content are sent to the proxy
25
+ - The proxy forwards requests to the underlying LLM provider
26
+ - This enables free access without requiring individual API keys
27
+
28
+ ### Use Cases
29
+
30
+ - **Quick testing** - Try vmCode immediately without configuration
31
+ - **Evaluation** - Test the tool before committing to a paid provider
32
+ - **Development** - Non-sensitive work where convenience is preferred
33
+
34
+ ### Recommended Setup
35
+
36
+ For production work or sensitive code, we recommend using other providers. Type `/provider` to see all options
37
+
38
+ ## Installation
39
+
40
+ ### Option 1: npm install (Recommended)
41
+
42
+ ```bash
43
+ # Install globally (requires Python 3.9+)
44
+ npm install -g vmcode-cli
45
+
46
+ # Run vmcode
47
+ vmcode
48
+ ```
49
+
50
+ Or use npx without installing:
51
+
52
+ ```bash
53
+ npx vmcode-cli
54
+ ```
55
+
56
+ ### What Gets Installed
57
+
58
+ The npm package automatically:
59
+ 1. Checks for Python 3.9+ on your system
60
+ 2. Installs Python dependencies via pip
61
+ 3. Creates `config.yaml` from `config.yaml.example` if missing
62
+ 4. Sets up the `vmcode` command globally
63
+
64
+ **Requirements:**
65
+ - Node.js 14+ (for npm)
66
+ - Python 3.9+ (for the application)
67
+ - pip (to install Python dependencies)
68
+
69
+ If Python is not found, the installer will guide you through installing it.
70
+
71
+ ### Option 2: Git Clone
72
+
73
+ ```bash
74
+ # Clone the repository
75
+ git clone <repository-url>
76
+ cd vmcode
77
+
78
+ # Run setup script
79
+ ./setup.sh # Linux/macOS
80
+ # or
81
+ setup.bat # Windows
82
+ ```
83
+
84
+ The setup script automatically:
85
+ 1. Checks for Python 3.9+ on your system
86
+ 2. Installs Python dependencies via pip
87
+ 3. Creates `config.yaml` from `config.yaml.example` if missing
88
+ 4. Sets up the `vmcode` command alias
89
+
90
+ **Requirements:**
91
+ - Python 3.9+
92
+ - pip (to install Python dependencies)
93
+
94
+ ## Configuration
95
+
96
+ ### Setting API Keys
97
+
98
+ You have three options to set your API keys:
99
+
100
+ #### Option 1: Interactive Commands (Recommended)
101
+
102
+ Run the app and use the built-in commands:
103
+ ```
104
+ > /key sk-your-api-key-here
105
+ > /provider openai
106
+ ```
107
+
108
+ #### Option 2: Edit config.yaml Directly
109
+
110
+ Edit `config.yaml` in the project root and add your keys:
111
+
112
+ ```yaml
113
+ # OpenAI
114
+ OPENAI_API_KEY: "sk-your-key-here"
115
+ OPENAI_MODEL: gpt-4o-mini
116
+
117
+ # Anthropic (Claude)
118
+ ANTHROPIC_API_KEY: "sk-ant-your-key-here"
119
+ ANTHROPIC_MODEL: claude-3-5-sonnet-20241022
120
+
121
+ # Or any other supported provider...
122
+ ```
123
+
124
+ **Note:** `config.yaml` is automatically created from `config.yaml.example` on first run and is in `.gitignore` to protect your secrets.
125
+
126
+ #### Option 3: Environment Variables
127
+
128
+ Set environment variables (they take precedence over config.yaml):
129
+
130
+ ```bash
131
+ export OPENAI_API_KEY="sk-your-key-here"
132
+ export ANTHROPIC_API_KEY="sk-ant-your-key-here"
133
+
134
+ vmcode
135
+ ```
136
+
137
+ ### Available Environment Variables
138
+
139
+ - `ANTHROPIC_API_KEY` - Anthropic (Claude) API key
140
+ - `OPENAI_API_KEY` - OpenAI API key
141
+ - `GLM_API_KEY` - GLM (Zhipu AI) API key
142
+ - `GEMINI_API_KEY` - Google Gemini API key
143
+ - `OPENROUTER_API_KEY` - OpenRouter API key
144
+ - `KIMI_API_KEY` - Kimi (Moonshot AI) API key
145
+ - `MINIMAX_API_KEY` - MiniMax API key
146
+
147
+ ## Commands
148
+
149
+ - `/provider <name>` - Switch LLM provider
150
+ - `/model <name>` - Set model for current provider
151
+ - `/key <api_key>` - Set API key for current provider
152
+ - `/mode <edit|plan|learn>` - Switch interaction mode
153
+ - `/config` - Show all configuration settings
154
+ - `/help` - Display all available commands
155
+
156
+ /help Menu:
157
+ <img width="1843" height="1349" alt="image" src="https://github.com/user-attachments/assets/631ab805-f012-4bb6-a031-c82a339e94c5" />
158
+
159
+
160
+ ## Project Structure
161
+
162
+ ```
163
+ vmcode/
164
+ ├── bin/
165
+ │ └── npm-wrapper.js # npm entry point
166
+ ├── scripts/
167
+ │ └── install.js # npm post-install script
168
+ ├── config.yaml # Your API keys and settings (not in git)
169
+ ├── requirements.txt # Python dependencies
170
+ ├── package.json # npm package definition
171
+ ├── setup.sh # Git clone setup script (Linux/macOS)
172
+ ├── setup.bat # Git clone setup script (Windows)
173
+ ├── .npmignore # npm package exclusions
174
+ ├── .gitignore # git exclusions
175
+ ├── src/
176
+ │ ├── core/ # Core orchestration and state management
177
+ │ ├── llm/ # LLM client and provider configurations
178
+ │ ├── ui/ # CLI interface and commands
179
+ │ └── utils/ # Utilities (file ops, search, validation)
180
+ └── tests/ # Test suite (for development)
181
+ ```
182
+
183
+ ## Security
184
+
185
+ - `config.yaml` is excluded from git via `.gitignore`
186
+ - Never commit API keys or sensitive configuration
187
+ - Use environment variables for CI/CD or shared environments
188
+
189
+ ## Development
190
+
191
+ vmCode is currently in active development. Production readiness is in progress with focus on:
192
+ - Comprehensive test coverage
193
+ - Documentation
194
+ - Error handling improvements
195
+ <<<<<<< HEAD
196
+ - Performance optimizationsour License Here]
197
+ =======
198
+ - Performance optimizations
199
+ >>>>>>> df3957ea1d8e3da51ed06e8960637514281db96d
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * vmCode - npm wrapper for Python application
4
+ * This script launches the Python vmcode application
5
+ */
6
+
7
+ const { spawn } = require('child_process');
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ // Get the package directory
12
+ const packageDir = __dirname;
13
+ const pythonScript = path.join(packageDir, 'src', 'ui', 'main.py');
14
+
15
+ function findPython() {
16
+ const possibleCommands = ['python3', 'python', 'python3.9', 'python3.10', 'python3.11', 'python3.12'];
17
+
18
+ for (const cmd of possibleCommands) {
19
+ try {
20
+ const result = spawnSync(cmd, ['--version'], { stdio: 'ignore' });
21
+ if (result.status === 0) {
22
+ return cmd;
23
+ }
24
+ } catch (e) {
25
+ // Continue to next command
26
+ }
27
+ }
28
+
29
+ return null;
30
+ }
31
+
32
+ function spawnSync(command, args, options) {
33
+ const { spawnSync: sync } = require('child_process');
34
+ return sync(command, args, options);
35
+ }
36
+
37
+ function checkPythonDependencies(pythonCmd) {
38
+ // Check if requirements are installed
39
+ const requirementsFile = path.join(packageDir, 'requirements.txt');
40
+
41
+ if (!fs.existsSync(requirementsFile)) {
42
+ return true; // No requirements file, assume OK
43
+ }
44
+
45
+ try {
46
+ // Try importing a key module to check if dependencies are installed
47
+ const result = spawnSync(pythonCmd, ['-c', 'import rich, requests, yaml'], {
48
+ stdio: 'ignore',
49
+ cwd: packageDir
50
+ });
51
+
52
+ return result.status === 0;
53
+ } catch (e) {
54
+ return false;
55
+ }
56
+ }
57
+
58
+ function installPythonDependencies(pythonCmd) {
59
+ console.log('Installing Python dependencies...');
60
+ const requirementsFile = path.join(packageDir, 'requirements.txt');
61
+
62
+ const installProcess = spawn(pythonCmd, ['-m', 'pip', 'install', '-r', requirementsFile], {
63
+ stdio: 'inherit',
64
+ cwd: packageDir
65
+ });
66
+
67
+ return new Promise((resolve, reject) => {
68
+ installProcess.on('close', (code) => {
69
+ if (code === 0) {
70
+ resolve();
71
+ } else {
72
+ reject(new Error(`Failed to install Python dependencies (exit code ${code})`));
73
+ }
74
+ });
75
+ });
76
+ }
77
+
78
+ function showSetupMessage() {
79
+ console.log('\n' + '='.repeat(60));
80
+ console.log('vmCode - Terminal-based AI coding assistant');
81
+ console.log('='.repeat(60));
82
+ console.log('\nFirst-time setup needed!\n');
83
+ console.log('1. Python is required (3.9 or later)');
84
+ console.log('2. Python dependencies need to be installed\n');
85
+ console.log('To complete setup, run:');
86
+ console.log(' npm run install\n');
87
+ console.log('Or manually:');
88
+ console.log(' python3 -m pip install -r requirements.txt\n');
89
+ console.log('Then run vmcode again.\n');
90
+ }
91
+
92
+ function checkConfig() {
93
+ const configFile = path.join(packageDir, 'config.yaml');
94
+ const configExample = path.join(packageDir, 'config.yaml.example');
95
+
96
+ if (!fs.existsSync(configFile)) {
97
+ if (fs.existsSync(configExample)) {
98
+ console.log('\n⚠️ No config.yaml found!');
99
+ console.log('Creating from config.yaml.example...\n');
100
+
101
+ try {
102
+ fs.copyFileSync(configExample, configFile);
103
+ console.log('✓ config.yaml created');
104
+ console.log('\nIMPORTANT: Edit config.yaml and add your API keys!');
105
+ console.log('Or set them via environment variables:');
106
+ console.log(' export OPENAI_API_KEY="sk-your-key-here"\n');
107
+ } catch (e) {
108
+ console.log('Failed to create config.yaml:', e.message);
109
+ }
110
+ }
111
+ }
112
+ }
113
+
114
+ async function main() {
115
+ // Find Python executable
116
+ const pythonCmd = findPython();
117
+
118
+ if (!pythonCmd) {
119
+ console.error('\n❌ Error: Python 3.9+ is not installed or not in PATH');
120
+ console.error('Please install Python from https://python.org\n');
121
+ process.exit(1);
122
+ }
123
+
124
+ console.log(`✓ Using Python: ${pythonCmd}`);
125
+
126
+ // Check and install Python dependencies
127
+ if (!checkPythonDependencies(pythonCmd)) {
128
+ console.log('\n⚠️ Python dependencies not installed');
129
+ try {
130
+ await installPythonDependencies(pythonCmd);
131
+ console.log('✓ Python dependencies installed\n');
132
+ } catch (e) {
133
+ console.error('\n❌ Failed to install dependencies:', e.message);
134
+ console.error('Try running: npm run install\n');
135
+ process.exit(1);
136
+ }
137
+ }
138
+
139
+ // Check/create config
140
+ checkConfig();
141
+
142
+ // Run the Python application
143
+ const pythonProcess = spawn(pythonCmd, [pythonScript], {
144
+ stdio: 'inherit',
145
+ cwd: packageDir
146
+ });
147
+
148
+ pythonProcess.on('close', (code) => {
149
+ process.exit(code || 0);
150
+ });
151
+
152
+ pythonProcess.on('error', (err) => {
153
+ console.error('\n❌ Failed to start vmcode:', err.message);
154
+ process.exit(1);
155
+ });
156
+
157
+ // Forward signals
158
+ process.on('SIGINT', () => {
159
+ pythonProcess.kill('SIGINT');
160
+ });
161
+
162
+ process.on('SIGTERM', () => {
163
+ pythonProcess.kill('SIGTERM');
164
+ });
165
+ }
166
+
167
+ // Run main function
168
+ main().catch(err => {
169
+ console.error('\n❌ Unexpected error:', err);
170
+ process.exit(1);
171
+ });
package/bin/rg ADDED
Binary file
package/bin/rg.exe ADDED
Binary file