upfynai-code 2.6.3 → 2.6.5
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/cli.js +31 -3
- package/package.json +1 -1
- package/src/auth.js +11 -4
- package/src/config.js +7 -0
- package/src/connect.js +3 -3
package/bin/cli.js
CHANGED
|
@@ -5,13 +5,15 @@ import { login, logout, status } from '../src/auth.js';
|
|
|
5
5
|
import { openHosted, startLocal } from '../src/launch.js';
|
|
6
6
|
import { connect } from '../src/connect.js';
|
|
7
7
|
import { mcp } from '../src/mcp.js';
|
|
8
|
+
import { readConfig, writeConfig, DEFAULTS, displayUrl } from '../src/config.js';
|
|
9
|
+
import chalk from 'chalk';
|
|
8
10
|
|
|
9
11
|
const program = new Command();
|
|
10
12
|
|
|
11
13
|
program
|
|
12
14
|
.name('upfynai-code')
|
|
13
15
|
.description('Launch Upfyn AI coding environment from your terminal')
|
|
14
|
-
.version('2.6.
|
|
16
|
+
.version('2.6.5')
|
|
15
17
|
.option('--local', 'Start a local server instead of opening the hosted app')
|
|
16
18
|
.action(async (options) => {
|
|
17
19
|
if (options.local) {
|
|
@@ -24,8 +26,9 @@ program
|
|
|
24
26
|
program
|
|
25
27
|
.command('login')
|
|
26
28
|
.description('Authenticate with your Upfyn account')
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
+
.option('--server <url>', 'Server URL to authenticate against')
|
|
30
|
+
.action(async (options) => {
|
|
31
|
+
await login(options);
|
|
29
32
|
});
|
|
30
33
|
|
|
31
34
|
program
|
|
@@ -60,4 +63,29 @@ program
|
|
|
60
63
|
await mcp(options);
|
|
61
64
|
});
|
|
62
65
|
|
|
66
|
+
program
|
|
67
|
+
.command('config')
|
|
68
|
+
.description('View or update CLI configuration')
|
|
69
|
+
.option('--server <url>', 'Set the server URL')
|
|
70
|
+
.option('--reset', 'Reset config to defaults')
|
|
71
|
+
.action((options) => {
|
|
72
|
+
if (options.reset) {
|
|
73
|
+
writeConfig({ serverUrl: DEFAULTS.serverUrl, localPort: DEFAULTS.localPort });
|
|
74
|
+
console.log(chalk.green('\n Config reset to defaults.\n'));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (options.server) {
|
|
78
|
+
const cleaned = options.server.replace(/\/+$/, '');
|
|
79
|
+
writeConfig({ serverUrl: cleaned });
|
|
80
|
+
console.log(chalk.green(`\n Server set to: ${displayUrl(cleaned)}\n`));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Show current config
|
|
84
|
+
const config = readConfig();
|
|
85
|
+
console.log(chalk.bold('\n Upfyn Code — Config\n'));
|
|
86
|
+
console.log(` Server: ${chalk.cyan(displayUrl(config.serverUrl))}`);
|
|
87
|
+
console.log(` Local port: ${chalk.cyan(config.localPort)}`);
|
|
88
|
+
console.log(` Logged in: ${config.token ? chalk.green('Yes') : chalk.yellow('No')}\n`);
|
|
89
|
+
});
|
|
90
|
+
|
|
63
91
|
program.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "upfynai-code",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"description": "Unified AI coding interface — access AI chat, terminal, file explorer, git, and visual canvas from any browser. Connect your local machine and code from anywhere.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { readConfig, writeConfig, clearConfig } from './config.js';
|
|
3
|
+
import { readConfig, writeConfig, clearConfig, displayUrl } from './config.js';
|
|
4
4
|
|
|
5
5
|
async function apiCall(path, options = {}) {
|
|
6
6
|
const config = readConfig();
|
|
@@ -36,7 +36,12 @@ export async function validateToken() {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export async function login() {
|
|
39
|
+
export async function login(options = {}) {
|
|
40
|
+
// Allow --server flag to override the server URL
|
|
41
|
+
if (options.server) {
|
|
42
|
+
writeConfig({ serverUrl: options.server.replace(/\/+$/, '') });
|
|
43
|
+
}
|
|
44
|
+
|
|
40
45
|
console.log(chalk.bold('\n Upfyn Code — Login\n'));
|
|
41
46
|
|
|
42
47
|
const response = await prompts([
|
|
@@ -82,7 +87,9 @@ export async function login() {
|
|
|
82
87
|
const name = data.user.first_name || data.user.username;
|
|
83
88
|
console.log(chalk.green(`\n Logged in as ${chalk.bold(name)}!\n`));
|
|
84
89
|
} catch (err) {
|
|
85
|
-
|
|
90
|
+
const config = readConfig();
|
|
91
|
+
console.log(chalk.red(`\n Connection error. Could not reach ${displayUrl(config.serverUrl)}.`));
|
|
92
|
+
console.log(chalk.dim(' Check your network and try again.\n'));
|
|
86
93
|
process.exit(1);
|
|
87
94
|
}
|
|
88
95
|
}
|
|
@@ -110,6 +117,6 @@ export async function status() {
|
|
|
110
117
|
|
|
111
118
|
const name = user.first_name || user.username;
|
|
112
119
|
console.log(chalk.bold(` Logged in as: ${chalk.cyan(name)} (${chalk.dim(user.username)})`));
|
|
113
|
-
console.log(chalk.dim(` Server: ${config.serverUrl}`));
|
|
120
|
+
console.log(chalk.dim(` Server: ${displayUrl(config.serverUrl)}`));
|
|
114
121
|
console.log(chalk.dim(` Local port: ${config.localPort}\n`));
|
|
115
122
|
}
|
package/src/config.js
CHANGED
|
@@ -30,4 +30,11 @@ export function clearConfig() {
|
|
|
30
30
|
writeFileSync(CONFIG_PATH, JSON.stringify(DEFAULTS, null, 2) + '\n', 'utf-8');
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/** Display-friendly server label — masks the internal URL */
|
|
34
|
+
export function displayUrl(url) {
|
|
35
|
+
if (!url || url === DEFAULTS.serverUrl) return 'Upfyn Cloud';
|
|
36
|
+
// Custom server — show the hostname only
|
|
37
|
+
try { return new URL(url).host; } catch { return url; }
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
export { CONFIG_PATH, DEFAULTS };
|
package/src/connect.js
CHANGED
|
@@ -4,7 +4,7 @@ import { spawn } from 'child_process';
|
|
|
4
4
|
import { promises as fsPromises } from 'fs';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import chalk from 'chalk';
|
|
7
|
-
import { readConfig, writeConfig } from './config.js';
|
|
7
|
+
import { readConfig, writeConfig, displayUrl } from './config.js';
|
|
8
8
|
import { getToken, validateToken } from './auth.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -235,7 +235,7 @@ export async function connect(options = {}) {
|
|
|
235
235
|
const wsUrl = serverUrl.replace(/^http/, 'ws') + '/relay?token=' + encodeURIComponent(relayKey);
|
|
236
236
|
|
|
237
237
|
console.log(chalk.bold('\n Upfyn-Code Relay Client\n'));
|
|
238
|
-
console.log(` Server: ${chalk.cyan(serverUrl)}`);
|
|
238
|
+
console.log(` Server: ${chalk.cyan(displayUrl(serverUrl))}`);
|
|
239
239
|
console.log(` Machine: ${chalk.dim(os.hostname())}`);
|
|
240
240
|
console.log(` User: ${chalk.dim(os.userInfo().username)}\n`);
|
|
241
241
|
|
|
@@ -300,7 +300,7 @@ export async function connect(options = {}) {
|
|
|
300
300
|
|
|
301
301
|
ws.on('error', (err) => {
|
|
302
302
|
if (err.code === 'ECONNREFUSED') {
|
|
303
|
-
console.error(chalk.red(` Cannot reach ${serverUrl}. Is the server running?`));
|
|
303
|
+
console.error(chalk.red(` Cannot reach ${displayUrl(serverUrl)}. Is the server running?`));
|
|
304
304
|
}
|
|
305
305
|
});
|
|
306
306
|
}
|