@xelauvas/xela-cli 0.1.0 → 0.1.2
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 +2 -2
- package/bin/xela.cmd +72 -0
- package/bin/xela.js +120 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ AI coding assistant that works with **any model** — free or paid. Use OpenRout
|
|
|
12
12
|
|
|
13
13
|
**npm (recommended):**
|
|
14
14
|
```bash
|
|
15
|
-
npm install -g xela-cli
|
|
15
|
+
npm install -g @xelauvas/xela-cli
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
**One-liner:**
|
|
@@ -186,7 +186,7 @@ ollama pull deepseek-v3.2
|
|
|
186
186
|
|
|
187
187
|
```bash
|
|
188
188
|
# npm install
|
|
189
|
-
npm uninstall -g xela-cli
|
|
189
|
+
npm uninstall -g @xelauvas/xela-cli
|
|
190
190
|
|
|
191
191
|
# curl install
|
|
192
192
|
curl -fsSL https://raw.githubusercontent.com/xelauvas/codeclau/main/uninstall.sh | bash
|
package/bin/xela.cmd
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
setlocal
|
|
3
|
+
|
|
4
|
+
set "XELA_HOME=%USERPROFILE%\.xela"
|
|
5
|
+
set "XELA_CONFIG=%XELA_HOME%\config.cmd"
|
|
6
|
+
set "INSTALL_DIR=%~dp0.."
|
|
7
|
+
|
|
8
|
+
:: Create config on first run
|
|
9
|
+
if not exist "%XELA_CONFIG%" (
|
|
10
|
+
mkdir "%XELA_HOME%" 2>nul
|
|
11
|
+
(
|
|
12
|
+
echo @echo off
|
|
13
|
+
echo :: Xela Configuration
|
|
14
|
+
echo :: Provider: openrouter, groq, ollama, deepseek, openai, cerebras, sambanova
|
|
15
|
+
echo set "XELA_PROVIDER=openrouter"
|
|
16
|
+
echo.
|
|
17
|
+
echo :: API Key
|
|
18
|
+
echo set "OPENAI_API_KEY=sk-or-your-key-here"
|
|
19
|
+
echo.
|
|
20
|
+
echo :: Model ^(auto-detected from provider if not set^)
|
|
21
|
+
echo :: set "OPENAI_MODEL=qwen/qwen3.6-plus-preview:free"
|
|
22
|
+
echo.
|
|
23
|
+
echo :: Base URL ^(auto-detected from provider if not set^)
|
|
24
|
+
echo :: set "OPENAI_BASE_URL=https://openrouter.ai/api/v1"
|
|
25
|
+
) > "%XELA_CONFIG%"
|
|
26
|
+
echo.
|
|
27
|
+
echo Welcome to Xela!
|
|
28
|
+
echo Config created at %XELA_CONFIG%
|
|
29
|
+
echo Edit it: notepad %XELA_CONFIG%
|
|
30
|
+
echo.
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
:: Load config
|
|
34
|
+
call "%XELA_CONFIG%"
|
|
35
|
+
|
|
36
|
+
:: Auto-detect base URL
|
|
37
|
+
if not defined OPENAI_BASE_URL (
|
|
38
|
+
if "%XELA_PROVIDER%"=="openrouter" set "OPENAI_BASE_URL=https://openrouter.ai/api/v1"
|
|
39
|
+
if "%XELA_PROVIDER%"=="groq" set "OPENAI_BASE_URL=https://api.groq.com/openai/v1"
|
|
40
|
+
if "%XELA_PROVIDER%"=="ollama" set "OPENAI_BASE_URL=http://localhost:11434/v1"
|
|
41
|
+
if "%XELA_PROVIDER%"=="deepseek" set "OPENAI_BASE_URL=https://api.deepseek.com"
|
|
42
|
+
if "%XELA_PROVIDER%"=="cerebras" set "OPENAI_BASE_URL=https://api.cerebras.ai/v1"
|
|
43
|
+
if "%XELA_PROVIDER%"=="sambanova" set "OPENAI_BASE_URL=https://api.sambanova.ai/v1"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
:: Auto-detect model
|
|
47
|
+
if not defined OPENAI_MODEL (
|
|
48
|
+
if "%XELA_PROVIDER%"=="openrouter" set "OPENAI_MODEL=qwen/qwen3.6-plus-preview:free"
|
|
49
|
+
if "%XELA_PROVIDER%"=="groq" set "OPENAI_MODEL=qwen-qwq-32b"
|
|
50
|
+
if "%XELA_PROVIDER%"=="ollama" set "OPENAI_MODEL=qwen2.5-coder:7b"
|
|
51
|
+
if "%XELA_PROVIDER%"=="deepseek" set "OPENAI_MODEL=deepseek-chat"
|
|
52
|
+
if "%XELA_PROVIDER%"=="openai" set "OPENAI_MODEL=gpt-4o"
|
|
53
|
+
if "%XELA_PROVIDER%"=="cerebras" set "OPENAI_MODEL=llama-3.3-70b"
|
|
54
|
+
if "%XELA_PROVIDER%"=="sambanova" set "OPENAI_MODEL=Meta-Llama-3.3-70B-Instruct"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
:: Handle -m flag
|
|
58
|
+
:parse_args
|
|
59
|
+
if "%~1"=="-m" (
|
|
60
|
+
set "OPENAI_MODEL=%~2"
|
|
61
|
+
shift
|
|
62
|
+
shift
|
|
63
|
+
goto :parse_args
|
|
64
|
+
)
|
|
65
|
+
if "%~1"=="--model" (
|
|
66
|
+
set "OPENAI_MODEL=%~2"
|
|
67
|
+
shift
|
|
68
|
+
shift
|
|
69
|
+
goto :parse_args
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
node --import "%INSTALL_DIR%\src\_shims\register.js" "%INSTALL_DIR%\start.js" %*
|
package/bin/xela.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { execFileSync, execSync } from 'child_process';
|
|
3
|
+
import { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';
|
|
4
|
+
import { join } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { homedir } from 'os';
|
|
7
|
+
import { createInterface } from 'readline';
|
|
8
|
+
|
|
9
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
10
|
+
const INSTALL_DIR = join(__dirname, '..');
|
|
11
|
+
const XELA_HOME = join(homedir(), '.xela');
|
|
12
|
+
const XELA_CONFIG = join(XELA_HOME, 'config.json');
|
|
13
|
+
|
|
14
|
+
const PROVIDERS = {
|
|
15
|
+
openrouter: { baseUrl: 'https://openrouter.ai/api/v1', model: 'qwen/qwen3.6-plus-preview:free' },
|
|
16
|
+
groq: { baseUrl: 'https://api.groq.com/openai/v1', model: 'qwen-qwq-32b' },
|
|
17
|
+
ollama: { baseUrl: 'http://localhost:11434/v1', model: 'qwen2.5-coder:7b' },
|
|
18
|
+
deepseek: { baseUrl: 'https://api.deepseek.com', model: 'deepseek-chat' },
|
|
19
|
+
openai: { baseUrl: undefined, model: 'gpt-4o' },
|
|
20
|
+
cerebras: { baseUrl: 'https://api.cerebras.ai/v1', model: 'llama-3.3-70b' },
|
|
21
|
+
sambanova: { baseUrl: 'https://api.sambanova.ai/v1', model: 'Meta-Llama-3.3-70B-Instruct' },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
function ask(question) {
|
|
25
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
26
|
+
return new Promise(resolve => rl.question(question, answer => { rl.close(); resolve(answer.trim()); }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function setup() {
|
|
30
|
+
console.log('');
|
|
31
|
+
console.log(' Welcome to Xela! Let\'s get you set up.');
|
|
32
|
+
console.log('');
|
|
33
|
+
|
|
34
|
+
// Pick provider
|
|
35
|
+
const providerNames = Object.keys(PROVIDERS);
|
|
36
|
+
console.log(' Providers:');
|
|
37
|
+
providerNames.forEach((p, i) => console.log(` ${i + 1}. ${p}`));
|
|
38
|
+
console.log('');
|
|
39
|
+
const choice = await ask(' Pick a provider [1]: ');
|
|
40
|
+
const idx = (parseInt(choice) || 1) - 1;
|
|
41
|
+
const provider = providerNames[Math.min(idx, providerNames.length - 1)];
|
|
42
|
+
|
|
43
|
+
// Get API key (skip for ollama)
|
|
44
|
+
let apiKey = '';
|
|
45
|
+
if (provider === 'ollama') {
|
|
46
|
+
apiKey = 'ollama';
|
|
47
|
+
} else {
|
|
48
|
+
console.log('');
|
|
49
|
+
if (provider === 'openrouter') {
|
|
50
|
+
console.log(' Get a free key at: https://openrouter.ai/keys');
|
|
51
|
+
} else if (provider === 'groq') {
|
|
52
|
+
console.log(' Get a free key at: https://console.groq.com/keys');
|
|
53
|
+
} else if (provider === 'deepseek') {
|
|
54
|
+
console.log(' Get a key at: https://platform.deepseek.com/api_keys');
|
|
55
|
+
}
|
|
56
|
+
apiKey = await ask(' API key: ');
|
|
57
|
+
if (!apiKey) {
|
|
58
|
+
console.log(' No key provided. You can add it later in ~/.xela/config.json');
|
|
59
|
+
apiKey = '';
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
mkdirSync(XELA_HOME, { recursive: true });
|
|
64
|
+
const config = { provider, apiKey, model: '', baseUrl: '' };
|
|
65
|
+
writeFileSync(XELA_CONFIG, JSON.stringify(config, null, 2));
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log(` Saved to ${XELA_CONFIG}`);
|
|
68
|
+
console.log(' You can edit it anytime: nano ~/.xela/config.json');
|
|
69
|
+
console.log('');
|
|
70
|
+
return config;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Load or create config
|
|
74
|
+
let config = {};
|
|
75
|
+
if (!existsSync(XELA_CONFIG)) {
|
|
76
|
+
config = await setup();
|
|
77
|
+
} else {
|
|
78
|
+
try {
|
|
79
|
+
config = JSON.parse(readFileSync(XELA_CONFIG, 'utf-8'));
|
|
80
|
+
} catch {}
|
|
81
|
+
// If key is still placeholder, run setup again
|
|
82
|
+
if (!config.apiKey || config.apiKey === 'sk-or-your-key-here') {
|
|
83
|
+
config = await setup();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const provider = config.provider || 'openrouter';
|
|
88
|
+
const providerInfo = PROVIDERS[provider] || PROVIDERS.openrouter;
|
|
89
|
+
|
|
90
|
+
// Set env vars
|
|
91
|
+
if (config.apiKey) {
|
|
92
|
+
process.env.OPENAI_API_KEY = config.apiKey;
|
|
93
|
+
}
|
|
94
|
+
if (!process.env.OPENAI_BASE_URL) {
|
|
95
|
+
process.env.OPENAI_BASE_URL = config.baseUrl || providerInfo.baseUrl;
|
|
96
|
+
}
|
|
97
|
+
if (!process.env.OPENAI_MODEL) {
|
|
98
|
+
process.env.OPENAI_MODEL = config.model || providerInfo.model || 'gpt-4o';
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Handle -m/--model flag
|
|
102
|
+
const args = process.argv.slice(2);
|
|
103
|
+
for (let i = 0; i < args.length; i++) {
|
|
104
|
+
if ((args[i] === '-m' || args[i] === '--model') && args[i + 1]) {
|
|
105
|
+
process.env.OPENAI_MODEL = args[i + 1];
|
|
106
|
+
args.splice(i, 2);
|
|
107
|
+
i--;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Launch node with the TSX loader shim
|
|
112
|
+
try {
|
|
113
|
+
execFileSync(process.execPath, [
|
|
114
|
+
'--import', join(INSTALL_DIR, 'src', '_shims', 'register.js'),
|
|
115
|
+
join(INSTALL_DIR, 'start.js'),
|
|
116
|
+
...args,
|
|
117
|
+
], { stdio: 'inherit', env: process.env });
|
|
118
|
+
} catch (e) {
|
|
119
|
+
process.exit(e.status || 1);
|
|
120
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xelauvas/xela-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Xela — AI coding assistant powered by any model (OpenRouter, Groq, Ollama, DeepSeek, OpenAI)",
|
|
5
5
|
"author": "xelauvas",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
},
|
|
12
12
|
"keywords": ["ai", "coding", "assistant", "cli", "openrouter", "groq", "ollama", "deepseek", "xela"],
|
|
13
13
|
"bin": {
|
|
14
|
-
"xela": "./bin/xela"
|
|
14
|
+
"xela": "./bin/xela.js"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"bin/",
|