anveesa 0.7.2 → 0.7.3

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/Cargo.toml ADDED
@@ -0,0 +1,30 @@
1
+ [package]
2
+ name = "anveesa"
3
+ version = "0.7.3"
4
+ edition = "2024"
5
+ default-run = "anveesa"
6
+ description = "Multi-provider terminal AI assistant — TUI, web UI, and one-shot mode backed by any OpenAI-compatible API"
7
+ license = "MIT"
8
+ repository = "https://github.com/PandhuWibowo/anveesa-cli"
9
+ homepage = "https://github.com/PandhuWibowo/anveesa-cli"
10
+ documentation = "https://github.com/PandhuWibowo/anveesa-cli#readme"
11
+ keywords = ["ai", "cli", "llm", "assistant", "tui"]
12
+ categories = ["command-line-utilities", "development-tools"]
13
+ readme = "README.md"
14
+ exclude = ["npm/", ".github/", "src/web_ui.html"]
15
+
16
+ [dependencies]
17
+ base64 = "0.22"
18
+ anyhow = "1.0"
19
+ clap = { version = "4.5", features = ["derive"] }
20
+ libc = "0.2"
21
+ crossterm = "0.28"
22
+ ratatui = "0.29"
23
+ reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls", "stream"] }
24
+ rustyline = "14"
25
+ serde = { version = "1.0", features = ["derive"] }
26
+ serde_json = "1.0"
27
+ tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "process", "time", "sync", "io-util", "signal", "net"] }
28
+ tokio-stream = { version = "0.1", features = ["sync"] }
29
+ toml = "0.8"
30
+ axum = { version = "0.7", features = ["json"] }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Pandhu Wibowo
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/bin/anveesa.js ADDED
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ function findBinary() {
8
+ const platform = process.platform;
9
+ const ext = platform === 'win32' ? '.exe' : '';
10
+
11
+ // Prefer the latest local release build in a development checkout.
12
+ const devPath = path.join(__dirname, '..', 'target', 'release', 'anveesa' + ext);
13
+ if (fs.existsSync(devPath)) return devPath;
14
+
15
+ // Installed npm packages keep the downloaded binary in the package bin/ directory.
16
+ const bundled = path.join(__dirname, 'anveesa' + ext);
17
+ if (fs.existsSync(bundled)) return bundled;
18
+
19
+ // Check if there's a sibling directory with the binary
20
+ const sibling = path.join(__dirname, 'target', 'release', 'anveesa' + ext);
21
+ if (fs.existsSync(sibling)) return sibling;
22
+
23
+ return null;
24
+ }
25
+
26
+ const binaryPath = findBinary();
27
+
28
+ if (!binaryPath) {
29
+ console.error('❌ anveesa binary not found.');
30
+ console.error('');
31
+ console.error('Try reinstalling: npm install -g anveesa');
32
+ console.error('Or build from source: cargo build --release');
33
+ process.exit(1);
34
+ }
35
+
36
+ const args = process.argv.slice(2);
37
+ const child = spawn(binaryPath, args, {
38
+ cwd: process.cwd(),
39
+ stdio: 'inherit',
40
+ env: { ...process.env },
41
+ });
42
+
43
+ child.on('error', (error) => {
44
+ console.error('Error running anveesa:', error.message);
45
+ process.exit(1);
46
+ });
47
+
48
+ child.on('exit', (code) => {
49
+ process.exit(code ?? 1);
50
+ });
package/package.json CHANGED
@@ -1,36 +1,49 @@
1
1
  {
2
2
  "name": "anveesa",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "description": "Multi-provider terminal AI assistant — TUI, web UI, and one-shot mode backed by any OpenAI-compatible API",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/PandhuWibowo/anveesa-cli.git"
5
+ "main": "bin/anveesa.js",
6
+ "bin": {
7
+ "anveesa": "bin/anveesa.js"
8
+ },
9
+ "scripts": {
10
+ "build": "cargo build --release",
11
+ "postinstall": "node scripts/install.js",
12
+ "prepublishOnly": "npm run build"
9
13
  },
10
- "homepage": "https://github.com/PandhuWibowo/anveesa-cli#readme",
14
+ "files": [
15
+ "bin/anveesa.js",
16
+ "scripts/install.js",
17
+ "Cargo.toml",
18
+ "Cargo.lock",
19
+ "src/",
20
+ "README.md"
21
+ ],
11
22
  "keywords": [
12
23
  "ai",
13
24
  "cli",
14
- "llm",
15
- "assistant",
16
- "tui",
25
+ "terminal",
26
+ "rust",
17
27
  "openai",
18
- "anthropic",
28
+ "agent",
29
+ "copilot",
30
+ "tui",
31
+ "llm",
19
32
  "deepseek",
20
- "groq"
33
+ "groq",
34
+ "anthropic"
21
35
  ],
22
- "bin": {
23
- "anveesa": "./bin/anveesa"
36
+ "license": "MIT",
37
+ "engines": {
38
+ "node": ">=16"
24
39
  },
25
- "scripts": {
26
- "postinstall": "node install.js"
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/pandhuwibowo/anveesa-cli.git"
27
43
  },
28
- "engines": {
29
- "node": ">=18"
44
+ "homepage": "https://github.com/pandhuwibowo/anveesa-cli",
45
+ "bugs": {
46
+ "url": "https://github.com/pandhuwibowo/anveesa-cli/issues"
30
47
  },
31
- "files": [
32
- "bin/",
33
- "install.js",
34
- "README.md"
35
- ]
48
+ "author": "Anveesa"
36
49
  }
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Installation script for anveesa npm package
5
+ * This script checks if the Rust binary exists and provides instructions if not
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const https = require('https');
11
+ const { execFileSync } = require('child_process');
12
+
13
+ const PACKAGE = require(path.join(__dirname, '..', 'package.json'));
14
+ const REPO = 'pandhuwibowo/anveesa-cli';
15
+ const BIN_DIR = path.join(__dirname, '..', 'bin');
16
+ const REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
17
+
18
+ function getPlatformInfo() {
19
+ const platform = process.platform;
20
+ const arch = process.arch;
21
+
22
+ if (platform === 'darwin' && arch === 'arm64')
23
+ return { platform: 'macos', target: 'aarch64-apple-darwin', ext: '' };
24
+ if (platform === 'darwin' && arch === 'x64')
25
+ return { platform: 'macos', target: 'x86_64-apple-darwin', ext: '' };
26
+ if (platform === 'linux' && arch === 'x64')
27
+ return { platform: 'linux', target: 'x86_64-unknown-linux-gnu', ext: '' };
28
+ if (platform === 'linux' && arch === 'arm64')
29
+ return { platform: 'linux', target: 'aarch64-unknown-linux-gnu', ext: '' };
30
+ if (platform === 'win32' && arch === 'x64')
31
+ return { platform: 'windows', target: 'x86_64-pc-windows-msvc', ext: '.exe' };
32
+
33
+ return null;
34
+ }
35
+
36
+ function getExecutableName() {
37
+ return process.platform === 'win32' ? 'anveesa.exe' : 'anveesa';
38
+ }
39
+
40
+ function getBinaryPath() {
41
+ return path.join(BIN_DIR, getExecutableName());
42
+ }
43
+
44
+ function getBinaryUrl() {
45
+ const info = getPlatformInfo();
46
+ if (!info) return null;
47
+ const version = PACKAGE.version;
48
+ return `https://github.com/${REPO}/releases/download/v${version}/anveesa-${version}-${info.target}.tar.gz`;
49
+ }
50
+
51
+ function download(url, dest, redirects = 0) {
52
+ return new Promise((resolve, reject) => {
53
+ const request = https.get(url, {
54
+ headers: { 'User-Agent': `anveesa-install/${PACKAGE.version}` },
55
+ }, (res) => {
56
+ if (REDIRECT_STATUSES.has(res.statusCode)) {
57
+ res.resume();
58
+ if (!res.headers.location) {
59
+ reject(new Error(`HTTP ${res.statusCode} without Location header`));
60
+ return;
61
+ }
62
+ if (redirects >= 5) {
63
+ reject(new Error('too many redirects'));
64
+ return;
65
+ }
66
+
67
+ const nextUrl = new URL(res.headers.location, url).toString();
68
+ resolve(download(nextUrl, dest, redirects + 1));
69
+ return;
70
+ }
71
+
72
+ if (res.statusCode !== 200) {
73
+ res.resume();
74
+ reject(new Error(res.statusCode === 404 ? '404' : `HTTP ${res.statusCode}`));
75
+ return;
76
+ }
77
+
78
+ const file = fs.createWriteStream(dest);
79
+ file.on('finish', () => { file.close(resolve); });
80
+ file.on('error', (err) => {
81
+ fs.unlink(dest, () => {});
82
+ reject(err);
83
+ });
84
+ res.pipe(file);
85
+ }).on('error', (err) => {
86
+ fs.unlink(dest, () => {});
87
+ reject(err);
88
+ });
89
+ request.setTimeout(30000, () => {
90
+ request.destroy(new Error('download timed out'));
91
+ });
92
+ });
93
+ }
94
+
95
+ async function tryDownloadBinary() {
96
+ const url = getBinaryUrl();
97
+ if (!url) {
98
+ console.log('⚠ Unsupported platform:', process.platform, process.arch);
99
+ return false;
100
+ }
101
+
102
+ console.log('⬇ Downloading prebuilt binary for', process.platform, process.arch);
103
+
104
+ const tarPath = path.join(__dirname, 'anveesa-bin.tar.gz');
105
+ try {
106
+ if (!fs.existsSync(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true });
107
+
108
+ await download(url, tarPath);
109
+
110
+ // Extract
111
+ execFileSync('tar', ['xzf', tarPath, '-C', BIN_DIR], { stdio: 'inherit' });
112
+ fs.unlinkSync(tarPath);
113
+
114
+ // Make executable
115
+ const binary = getBinaryPath();
116
+ if (fs.existsSync(binary)) {
117
+ if (process.platform !== 'win32') fs.chmodSync(binary, 0o755);
118
+ } else {
119
+ console.log('⚠ Downloaded archive did not contain', getExecutableName());
120
+ return false;
121
+ }
122
+
123
+ console.log('✓ Binary downloaded successfully');
124
+ return true;
125
+ } catch (e) {
126
+ if (e.message === '404') {
127
+ console.log('ℹ No prebuilt binary for this version yet');
128
+ }
129
+ fs.unlink(tarPath, () => {});
130
+ return false;
131
+ }
132
+ }
133
+
134
+ function tryBuildFromSource() {
135
+ try {
136
+ console.log('⚙ Building from source (requires Rust)...');
137
+ execFileSync('cargo', ['build', '--release'], { cwd: path.join(__dirname, '..'), stdio: 'inherit' });
138
+
139
+ const src = path.join(__dirname, '..', 'target', 'release', getExecutableName());
140
+ const dest = getBinaryPath();
141
+
142
+ if (fs.existsSync(src)) {
143
+ if (!fs.existsSync(BIN_DIR)) fs.mkdirSync(BIN_DIR, { recursive: true });
144
+ fs.copyFileSync(src, dest);
145
+ if (process.platform !== 'win32') fs.chmodSync(dest, 0o755);
146
+ console.log('✓ Built from source successfully');
147
+ return true;
148
+ }
149
+ } catch (e) {
150
+ if (e.code === 'ENOENT') {
151
+ console.log('⚠ Build from source failed: cargo was not found');
152
+ } else {
153
+ console.log('⚠ Build from source failed');
154
+ }
155
+ }
156
+ return false;
157
+ }
158
+
159
+ function hasUsableExistingBinary() {
160
+ const existing = getBinaryPath();
161
+ if (!fs.existsSync(existing)) return false;
162
+
163
+ try {
164
+ if (process.platform !== 'win32') fs.chmodSync(existing, 0o755);
165
+ execFileSync(existing, ['--help'], { stdio: 'ignore', timeout: 5000 });
166
+ return true;
167
+ } catch (e) {
168
+ console.log('ℹ Existing anveesa binary is not usable on this platform; replacing it');
169
+ return false;
170
+ }
171
+ }
172
+
173
+ async function install() {
174
+ // Check if binary already exists
175
+ if (hasUsableExistingBinary()) {
176
+ console.log('✓ anveesa binary already installed');
177
+ return;
178
+ }
179
+
180
+ // Try download first
181
+ if (await tryDownloadBinary()) return;
182
+
183
+ // Fallback to build from source
184
+ if (tryBuildFromSource()) return;
185
+
186
+ console.error('');
187
+ console.error('✗ Could not install anveesa binary.');
188
+ console.error('');
189
+ const url = getBinaryUrl();
190
+ if (url) {
191
+ console.error(`No prebuilt binary was available for anveesa v${PACKAGE.version}:`);
192
+ console.error(` ${url}`);
193
+ console.error('');
194
+ }
195
+ console.error('Install Rust: https://rustup.rs/');
196
+ console.error('Then run: npm install -g anveesa');
197
+ console.error('');
198
+ console.error('Or grab a prebuilt binary from:');
199
+ console.error(' https://github.com/pandhuwibowo/anveesa-cli/releases');
200
+ process.exit(1);
201
+ }
202
+
203
+ install();
package/src/cli.rs ADDED
@@ -0,0 +1,126 @@
1
+ use clap::{Args, Parser, Subcommand};
2
+
3
+ #[derive(Debug, Parser)]
4
+ #[command(
5
+ name = "anveesa",
6
+ version,
7
+ about = "Terminal AI wrapper for multiple providers"
8
+ )]
9
+ pub struct Cli {
10
+ #[command(subcommand)]
11
+ pub command: Option<Command>,
12
+
13
+ #[command(flatten)]
14
+ pub ask_options: AskOptions,
15
+
16
+ #[arg(value_name = "PROMPT", trailing_var_arg = true)]
17
+ pub prompt: Vec<String>,
18
+ }
19
+
20
+ #[derive(Debug, Subcommand)]
21
+ pub enum Command {
22
+ /// Ask the configured AI provider.
23
+ Ask(AskArgs),
24
+ /// List available providers.
25
+ Providers,
26
+ /// Manage the Anveesa config file.
27
+ Config(ConfigArgs),
28
+ /// Manage saved interactive sessions.
29
+ Sessions(SessionsArgs),
30
+ /// Launch a browser-based chat UI on localhost.
31
+ Web(WebArgs),
32
+ }
33
+
34
+ #[derive(Debug, Args)]
35
+ pub struct WebArgs {
36
+ #[command(flatten)]
37
+ pub options: AskOptions,
38
+
39
+ /// Port to listen on (default 8374).
40
+ #[arg(long, default_value = "8374")]
41
+ pub port: u16,
42
+ }
43
+
44
+ #[derive(Debug, Args)]
45
+ pub struct SessionsArgs {
46
+ #[command(subcommand)]
47
+ pub command: SessionsCommand,
48
+ }
49
+
50
+ #[derive(Debug, Subcommand)]
51
+ pub enum SessionsCommand {
52
+ /// List all saved sessions.
53
+ List,
54
+ /// Delete sessions. Without flags, deletes the session for the current directory.
55
+ Clear {
56
+ /// Delete all saved sessions.
57
+ #[arg(long)]
58
+ all: bool,
59
+ },
60
+ }
61
+
62
+ #[derive(Debug, Args)]
63
+ pub struct AskArgs {
64
+ #[command(flatten)]
65
+ pub options: AskOptions,
66
+
67
+ #[arg(value_name = "PROMPT", trailing_var_arg = true)]
68
+ pub prompt: Vec<String>,
69
+ }
70
+
71
+ #[derive(Debug, Args, Clone, Default)]
72
+ pub struct AskOptions {
73
+ /// Provider name from the config.
74
+ #[arg(short, long)]
75
+ pub provider: Option<String>,
76
+
77
+ /// Model name to send to the provider.
78
+ #[arg(short, long)]
79
+ pub model: Option<String>,
80
+
81
+ /// Optional system instruction.
82
+ #[arg(long)]
83
+ pub system: Option<String>,
84
+
85
+ /// Append stdin to the prompt.
86
+ #[arg(long)]
87
+ pub stdin: bool,
88
+
89
+ /// Auto-approve file writes and command execution without prompting.
90
+ #[arg(short = 'y', long)]
91
+ pub yes: bool,
92
+ }
93
+
94
+ #[derive(Debug, Args)]
95
+ pub struct ConfigArgs {
96
+ #[command(subcommand)]
97
+ pub command: ConfigCommand,
98
+ }
99
+
100
+ #[derive(Debug, Subcommand)]
101
+ pub enum ConfigCommand {
102
+ /// Create a starter config at the default path.
103
+ Init {
104
+ /// Overwrite an existing config file.
105
+ #[arg(long)]
106
+ force: bool,
107
+ },
108
+ /// Set the default model for a provider.
109
+ SetModel {
110
+ /// Provider name from the config. Defaults to default_provider.
111
+ #[arg(short, long)]
112
+ provider: Option<String>,
113
+
114
+ /// Model name to use by default.
115
+ model: String,
116
+ },
117
+ /// Set the default provider.
118
+ SetProvider {
119
+ /// Provider name from the config.
120
+ provider: String,
121
+ },
122
+ /// Print the config path.
123
+ Path,
124
+ /// Print the effective config.
125
+ Show,
126
+ }