vigthoria-cli 1.6.1 → 1.6.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.
Files changed (46) hide show
  1. package/README.md +52 -1
  2. package/dist/commands/chat.d.ts +31 -45
  3. package/dist/commands/chat.d.ts.map +1 -1
  4. package/dist/commands/chat.js +374 -855
  5. package/dist/commands/chat.js.map +1 -1
  6. package/dist/commands/repo.d.ts +10 -0
  7. package/dist/commands/repo.d.ts.map +1 -1
  8. package/dist/commands/repo.js +215 -97
  9. package/dist/commands/repo.js.map +1 -1
  10. package/dist/index.js +32 -4
  11. package/dist/index.js.map +1 -1
  12. package/dist/utils/api.d.ts +8 -0
  13. package/dist/utils/api.d.ts.map +1 -1
  14. package/dist/utils/api.js +183 -42
  15. package/dist/utils/api.js.map +1 -1
  16. package/dist/utils/config.d.ts.map +1 -1
  17. package/dist/utils/config.js +2 -1
  18. package/dist/utils/config.js.map +1 -1
  19. package/dist/utils/tools.d.ts +3 -0
  20. package/dist/utils/tools.d.ts.map +1 -1
  21. package/dist/utils/tools.js +252 -14
  22. package/dist/utils/tools.js.map +1 -1
  23. package/package.json +13 -2
  24. package/install.ps1 +0 -290
  25. package/install.sh +0 -307
  26. package/src/commands/auth.ts +0 -226
  27. package/src/commands/chat.ts +0 -1101
  28. package/src/commands/config.ts +0 -306
  29. package/src/commands/deploy.ts +0 -609
  30. package/src/commands/edit.ts +0 -310
  31. package/src/commands/explain.ts +0 -115
  32. package/src/commands/generate.ts +0 -222
  33. package/src/commands/hub.ts +0 -382
  34. package/src/commands/repo.ts +0 -742
  35. package/src/commands/review.ts +0 -186
  36. package/src/index.ts +0 -601
  37. package/src/types/marked-terminal.d.ts +0 -31
  38. package/src/utils/api.ts +0 -526
  39. package/src/utils/config.ts +0 -241
  40. package/src/utils/files.ts +0 -273
  41. package/src/utils/logger.ts +0 -130
  42. package/src/utils/session.ts +0 -179
  43. package/src/utils/tools.ts +0 -1964
  44. package/test-parse.js +0 -105
  45. package/test-parse2.js +0 -35
  46. package/tsconfig.json +0 -20
package/install.sh DELETED
@@ -1,307 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Vigthoria CLI Installer
4
- # Usage: curl -fsSL https://cli.vigthoria.io/install.sh | bash
5
- #
6
- # Supports: Linux, macOS (Intel and Apple Silicon)
7
- #
8
-
9
- set -e
10
-
11
- # Colors (with fallback for non-color terminals)
12
- if [ -t 1 ] && [ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]; then
13
- RED='\033[0;31m'
14
- GREEN='\033[0;32m'
15
- YELLOW='\033[1;33m'
16
- CYAN='\033[0;36m'
17
- WHITE='\033[1;37m'
18
- NC='\033[0m' # No Color
19
- else
20
- RED=''
21
- GREEN=''
22
- YELLOW=''
23
- CYAN=''
24
- WHITE=''
25
- NC=''
26
- fi
27
-
28
- # Configuration
29
- CLI_VERSION="1.4.3"
30
- INSTALL_DIR="$HOME/.vigthoria"
31
- REPO_URL="https://market.vigthoria.io/vigthoria/vigthoria-cli"
32
-
33
- # Detect platform and set appropriate bin directory
34
- detect_platform() {
35
- OS="$(uname -s)"
36
- ARCH="$(uname -m)"
37
-
38
- case "$OS" in
39
- Darwin)
40
- PLATFORM="macos"
41
- # macOS: Check if /usr/local/bin is writable, otherwise use ~/.local/bin
42
- if [ -w "/usr/local/bin" ]; then
43
- BIN_DIR="/usr/local/bin"
44
- else
45
- BIN_DIR="$HOME/.local/bin"
46
- mkdir -p "$BIN_DIR"
47
- fi
48
- ;;
49
- Linux)
50
- PLATFORM="linux"
51
- # Linux: Prefer ~/.local/bin for user installs
52
- if [ -w "/usr/local/bin" ]; then
53
- BIN_DIR="/usr/local/bin"
54
- else
55
- BIN_DIR="$HOME/.local/bin"
56
- mkdir -p "$BIN_DIR"
57
- fi
58
- ;;
59
- *)
60
- echo -e "${RED}Unsupported operating system: $OS${NC}"
61
- echo "Please use the npm install method: npm install -g vigthoria-cli"
62
- exit 1
63
- ;;
64
- esac
65
-
66
- echo -e "${CYAN}Detected: $PLATFORM ($ARCH)${NC}"
67
- }
68
-
69
- echo -e "${CYAN}"
70
- echo "╔═══════════════════════════════════════════════════════════╗"
71
- echo "║ ║"
72
- echo "║ VIGTHORIA CLI INSTALLER v${CLI_VERSION} ║"
73
- echo "║ AI-Powered Terminal Coding Assistant ║"
74
- echo "║ ║"
75
- echo "╚═══════════════════════════════════════════════════════════╝"
76
- echo -e "${NC}"
77
-
78
- # Check requirements
79
- check_requirements() {
80
- echo -e "${CYAN}Checking requirements...${NC}"
81
-
82
- detect_platform
83
-
84
- # Check Node.js
85
- if ! command -v node &> /dev/null; then
86
- echo -e "${RED}✗ Node.js is not installed${NC}"
87
- echo ""
88
- echo " Please install Node.js 18 or later:"
89
- if [ "$PLATFORM" = "macos" ]; then
90
- echo " brew install node"
91
- echo " or download from: https://nodejs.org/"
92
- else
93
- echo " # Ubuntu/Debian:"
94
- echo " curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -"
95
- echo " sudo apt-get install -y nodejs"
96
- echo ""
97
- echo " # Or download from: https://nodejs.org/"
98
- fi
99
- exit 1
100
- fi
101
-
102
- NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
103
- if [ "$NODE_VERSION" -lt 18 ]; then
104
- echo -e "${RED}✗ Node.js version must be 18 or higher (found: v$NODE_VERSION)${NC}"
105
- exit 1
106
- fi
107
- echo -e "${GREEN}✓ Node.js v$(node -v | cut -d'v' -f2)${NC}"
108
-
109
- # Check npm
110
- if ! command -v npm &> /dev/null; then
111
- echo -e "${RED}✗ npm is not installed${NC}"
112
- exit 1
113
- fi
114
- echo -e "${GREEN}✓ npm v$(npm -v)${NC}"
115
-
116
- # Check git (optional)
117
- if command -v git &> /dev/null; then
118
- echo -e "${GREEN}✓ git v$(git --version | cut -d' ' -f3)${NC}"
119
- else
120
- echo -e "${YELLOW}⚠ git not found (optional, for project context)${NC}"
121
- fi
122
-
123
- echo ""
124
- }
125
-
126
- # Install CLI
127
- install_cli() {
128
- echo -e "${CYAN}Installing Vigthoria CLI...${NC}"
129
-
130
- # Create install directory
131
- mkdir -p "$INSTALL_DIR"
132
-
133
- # Option 1: Install from npm (production)
134
- if npm view vigthoria-cli version &> /dev/null; then
135
- echo "Installing from npm registry..."
136
- npm install -g vigthoria-cli
137
- else
138
- # Option 2: Install from local or git
139
- echo "Installing from source..."
140
-
141
- # Check if we're in the CLI directory
142
- if [ -f "package.json" ] && grep -q '"name": "vigthoria-cli"' package.json; then
143
- echo "Installing from current directory..."
144
- npm install
145
- npm run build
146
- npm link
147
- else
148
- # Clone from repo
149
- echo "Cloning from repository..."
150
- git clone "$REPO_URL" "$INSTALL_DIR/cli" 2>/dev/null || {
151
- echo -e "${YELLOW}Repository not available, using local install${NC}"
152
- # Copy local files for development
153
- SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
154
- if [ -d "$SCRIPT_DIR/../src" ]; then
155
- cp -r "$SCRIPT_DIR/.." "$INSTALL_DIR/cli"
156
- fi
157
- }
158
-
159
- if [ -d "$INSTALL_DIR/cli" ]; then
160
- cd "$INSTALL_DIR/cli"
161
- npm install
162
- npm run build
163
- npm link
164
- fi
165
- fi
166
- fi
167
-
168
- echo -e "${GREEN}✓ Installation complete${NC}"
169
- echo ""
170
- }
171
-
172
- # Create symlinks
173
- create_symlinks() {
174
- echo -e "${CYAN}Creating command shortcuts...${NC}"
175
-
176
- # Check if vigthoria command exists
177
- if command -v vigthoria &> /dev/null; then
178
- echo -e "${GREEN}✓ 'vigthoria' command available${NC}"
179
- fi
180
-
181
- # Create 'vig' alias if not exists
182
- if ! command -v vig &> /dev/null; then
183
- if [ -w "$BIN_DIR" ]; then
184
- ln -sf "$(which vigthoria)" "$BIN_DIR/vig" 2>/dev/null || true
185
- fi
186
- fi
187
-
188
- if command -v vig &> /dev/null; then
189
- echo -e "${GREEN}✓ 'vig' shortcut available${NC}"
190
- fi
191
-
192
- echo ""
193
- }
194
-
195
- # Setup shell completion
196
- setup_completion() {
197
- echo -e "${CYAN}Setting up shell completion...${NC}"
198
-
199
- # Detect shell
200
- SHELL_NAME=$(basename "$SHELL")
201
-
202
- case "$SHELL_NAME" in
203
- bash)
204
- COMPLETION_FILE="$HOME/.bash_completion.d/vigthoria"
205
- mkdir -p "$HOME/.bash_completion.d"
206
- cat > "$COMPLETION_FILE" << 'EOF'
207
- _vigthoria_completions() {
208
- local cur="${COMP_WORDS[COMP_CWORD]}"
209
- local commands="chat edit generate explain fix review login logout status config init"
210
- COMPREPLY=($(compgen -W "$commands" -- "$cur"))
211
- }
212
- complete -F _vigthoria_completions vigthoria
213
- complete -F _vigthoria_completions vig
214
- EOF
215
- echo -e "${GREEN}✓ Bash completion installed${NC}"
216
- echo " Run: source ~/.bash_completion.d/vigthoria"
217
- ;;
218
- zsh)
219
- COMPLETION_FILE="$HOME/.zsh/completion/_vigthoria"
220
- mkdir -p "$HOME/.zsh/completion"
221
- cat > "$COMPLETION_FILE" << 'EOF'
222
- #compdef vigthoria vig
223
-
224
- _vigthoria() {
225
- local -a commands
226
- commands=(
227
- 'chat:Start interactive chat with AI'
228
- 'edit:Edit a file with AI assistance'
229
- 'generate:Generate code from description'
230
- 'explain:Explain code in a file'
231
- 'fix:Fix issues in a file'
232
- 'review:Review code quality'
233
- 'login:Login to Vigthoria'
234
- 'logout:Logout from Vigthoria'
235
- 'status:Show account status'
236
- 'config:Configure settings'
237
- 'init:Initialize project'
238
- )
239
- _describe 'command' commands
240
- }
241
-
242
- _vigthoria "$@"
243
- EOF
244
- echo -e "${GREEN}✓ Zsh completion installed${NC}"
245
- echo " Add to ~/.zshrc: fpath=(~/.zsh/completion \$fpath)"
246
- ;;
247
- *)
248
- echo -e "${YELLOW}⚠ Shell completion not available for $SHELL_NAME${NC}"
249
- ;;
250
- esac
251
-
252
- echo ""
253
- }
254
-
255
- # Print success message
256
- print_success() {
257
- echo -e "${GREEN}"
258
- echo "╔═══════════════════════════════════════════════════════════╗"
259
- echo "║ ║"
260
- echo "║ ✓ VIGTHORIA CLI INSTALLED SUCCESSFULLY! ║"
261
- echo "║ ║"
262
- echo "╚═══════════════════════════════════════════════════════════╝"
263
- echo -e "${NC}"
264
-
265
- echo -e "${CYAN}Quick Start:${NC}"
266
- echo ""
267
- echo " 1. Login to your account:"
268
- echo -e " ${WHITE}vigthoria login${NC}"
269
- echo ""
270
- echo " 2. Start coding with AI:"
271
- echo -e " ${WHITE}vigthoria chat${NC}"
272
- echo ""
273
- echo " 3. Edit a file:"
274
- echo -e " ${WHITE}vigthoria edit myfile.ts${NC}"
275
- echo ""
276
- echo " 4. Generate code:"
277
- echo -e " ${WHITE}vigthoria generate \"REST API endpoint\"${NC}"
278
- echo ""
279
- echo -e "${CYAN}Commands:${NC}"
280
- echo " vigthoria chat - Interactive AI chat"
281
- echo " vigthoria edit - Edit files with AI"
282
- echo " vigthoria generate - Generate code"
283
- echo " vigthoria explain - Explain code"
284
- echo " vigthoria fix - Fix code issues"
285
- echo " vigthoria review - Code review"
286
- echo " vigthoria --help - Show all commands"
287
- echo ""
288
- echo -e "${CYAN}Shortcuts:${NC}"
289
- echo " vig c = vigthoria chat"
290
- echo " vig e = vigthoria edit"
291
- echo " vig g = vigthoria generate"
292
- echo ""
293
- echo -e "Documentation: ${CYAN}https://docs.vigthoria.io/cli${NC}"
294
- echo ""
295
- }
296
-
297
- # Main installation flow
298
- main() {
299
- check_requirements
300
- install_cli
301
- create_symlinks
302
- setup_completion
303
- print_success
304
- }
305
-
306
- # Run main
307
- main "$@"
@@ -1,226 +0,0 @@
1
- /**
2
- * Auth Command - Authentication management
3
- */
4
-
5
- import chalk from 'chalk';
6
- import ora from 'ora';
7
- import inquirer from 'inquirer';
8
- import { Config } from '../utils/config.js';
9
- import { Logger } from '../utils/logger.js';
10
- import { APIClient } from '../utils/api.js';
11
-
12
- interface LoginOptions {
13
- token?: string;
14
- }
15
-
16
- export class AuthCommand {
17
- private config: Config;
18
- private logger: Logger;
19
- private api: APIClient;
20
-
21
- constructor(config: Config, logger: Logger) {
22
- this.config = config;
23
- this.logger = logger;
24
- this.api = new APIClient(config, logger);
25
- }
26
-
27
- async login(options: LoginOptions): Promise<void> {
28
- // If token provided, use token auth
29
- if (options.token) {
30
- await this.loginWithToken(options.token);
31
- return;
32
- }
33
-
34
- console.log();
35
- console.log(chalk.cyan('═══ Vigthoria Login ═══'));
36
- console.log();
37
-
38
- // Prompt for credentials
39
- const answers = await inquirer.prompt([
40
- {
41
- type: 'list',
42
- name: 'method',
43
- message: 'Choose login method:',
44
- choices: [
45
- { name: 'Email & Password', value: 'credentials' },
46
- { name: 'API Token', value: 'token' },
47
- { name: 'Browser Login', value: 'browser' },
48
- ],
49
- },
50
- ]);
51
-
52
- switch (answers.method) {
53
- case 'credentials':
54
- await this.loginWithCredentials();
55
- break;
56
- case 'token':
57
- await this.loginWithTokenPrompt();
58
- break;
59
- case 'browser':
60
- await this.loginWithBrowser();
61
- break;
62
- }
63
- }
64
-
65
- private async loginWithCredentials(): Promise<void> {
66
- const credentials = await inquirer.prompt([
67
- {
68
- type: 'input',
69
- name: 'email',
70
- message: 'Email:',
71
- validate: (input) => {
72
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
73
- return emailRegex.test(input) || 'Please enter a valid email';
74
- },
75
- },
76
- {
77
- type: 'password',
78
- name: 'password',
79
- message: 'Password:',
80
- mask: '*',
81
- validate: (input) => input.length >= 6 || 'Password must be at least 6 characters',
82
- },
83
- ]);
84
-
85
- const spinner = ora('Logging in...').start();
86
-
87
- const success = await this.api.login(credentials.email, credentials.password);
88
-
89
- spinner.stop();
90
-
91
- if (success) {
92
- this.printLoginSuccess();
93
- } else {
94
- this.logger.error('Login failed. Please check your credentials.');
95
- }
96
- }
97
-
98
- private async loginWithTokenPrompt(): Promise<void> {
99
- const { token } = await inquirer.prompt([
100
- {
101
- type: 'password',
102
- name: 'token',
103
- message: 'API Token:',
104
- mask: '*',
105
- validate: (input) => input.length > 0 || 'Please enter your API token',
106
- },
107
- ]);
108
-
109
- await this.loginWithToken(token);
110
- }
111
-
112
- private async loginWithToken(token: string): Promise<void> {
113
- const spinner = ora('Validating token...').start();
114
-
115
- const success = await this.api.loginWithToken(token);
116
-
117
- spinner.stop();
118
-
119
- if (success) {
120
- this.printLoginSuccess();
121
- } else {
122
- this.logger.error('Invalid token. Please check and try again.');
123
- }
124
- }
125
-
126
- private async loginWithBrowser(): Promise<void> {
127
- console.log();
128
- console.log(chalk.gray('Opening browser for authentication...'));
129
- console.log();
130
- console.log(chalk.cyan('Visit: https://coder.vigthoria.io/cli-auth'));
131
- console.log();
132
- console.log(chalk.gray('After authenticating, copy the token and run:'));
133
- console.log(chalk.white(' vigthoria login --token YOUR_TOKEN'));
134
- console.log();
135
- }
136
-
137
- async logout(): Promise<void> {
138
- const { confirm } = await inquirer.prompt([
139
- {
140
- type: 'confirm',
141
- name: 'confirm',
142
- message: 'Are you sure you want to logout?',
143
- default: false,
144
- },
145
- ]);
146
-
147
- if (confirm) {
148
- this.config.clearAuth();
149
- this.logger.success('Logged out successfully');
150
- }
151
- }
152
-
153
- async status(): Promise<void> {
154
- console.log();
155
- console.log(chalk.cyan('═══ Account Status ═══'));
156
- console.log();
157
-
158
- if (!this.config.isAuthenticated()) {
159
- this.logger.warn('Not logged in');
160
- console.log();
161
- console.log(chalk.gray('Run `vigthoria login` to authenticate'));
162
- return;
163
- }
164
-
165
- const email = this.config.get('email');
166
- const sub = this.config.get('subscription');
167
-
168
- // Account info
169
- console.log(chalk.white('Account:'));
170
- console.log(chalk.gray(' Email: ') + chalk.cyan(email));
171
- console.log(chalk.gray(' User ID: ') + chalk.gray(this.config.get('userId')));
172
- console.log();
173
-
174
- // Subscription info
175
- console.log(chalk.white('Subscription:'));
176
- const planDisplay = sub.plan ? chalk.green(sub.plan.toUpperCase()) : chalk.yellow('FREE');
177
- const statusDisplay = sub.status === 'active' ? chalk.green('Active') : chalk.red(sub.status || 'N/A');
178
-
179
- console.log(chalk.gray(' Plan: ') + planDisplay);
180
- console.log(chalk.gray(' Status: ') + statusDisplay);
181
-
182
- if (sub.expiresAt) {
183
- const expiresDate = new Date(sub.expiresAt);
184
- const daysLeft = Math.ceil((expiresDate.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
185
- const expiresColor = daysLeft > 7 ? chalk.green : daysLeft > 0 ? chalk.yellow : chalk.red;
186
- console.log(chalk.gray(' Expires: ') + expiresColor(`${expiresDate.toLocaleDateString()} (${daysLeft} days)`));
187
- }
188
- console.log();
189
-
190
- // Available models
191
- console.log(chalk.white('Available Models:'));
192
- const models = this.config.getAvailableModels();
193
- models.forEach(m => {
194
- console.log(chalk.gray(' • ') + chalk.cyan(m.id) + chalk.gray(' → ') + chalk.white(m.name));
195
- console.log(chalk.gray(' ' + m.description));
196
- });
197
- console.log();
198
-
199
- // API status
200
- const spinner = ora('Checking API status...').start();
201
- const apiOk = await this.api.healthCheck();
202
- spinner.stop();
203
-
204
- console.log(chalk.white('API Status:'));
205
- console.log(chalk.gray(' Server: ') + (apiOk ? chalk.green('Online') : chalk.red('Offline')));
206
- console.log(chalk.gray(' Endpoint: ') + chalk.gray(this.config.get('apiUrl')));
207
- console.log();
208
- }
209
-
210
- private printLoginSuccess(): void {
211
- const email = this.config.get('email');
212
- const sub = this.config.get('subscription');
213
-
214
- console.log();
215
- this.logger.success(`Logged in as ${chalk.cyan(email)}`);
216
-
217
- if (sub.plan) {
218
- console.log(chalk.gray(` Plan: ${chalk.green(sub.plan.toUpperCase())}`));
219
- }
220
-
221
- console.log();
222
- console.log(chalk.gray('You can now use all Vigthoria CLI features.'));
223
- console.log(chalk.gray('Run `vigthoria chat` to start coding with AI!'));
224
- console.log();
225
- }
226
- }