lystbot 0.2.0 → 0.2.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/package.json +2 -2
- package/src/config.js +23 -5
- package/src/index.js +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lystbot",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "LystBot CLI - Manage your lists from the terminal",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"cli",
|
|
19
19
|
"productivity"
|
|
20
20
|
],
|
|
21
|
-
"author": "
|
|
21
|
+
"author": "TourAround UG",
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"commander": "^12.0.0"
|
package/src/config.js
CHANGED
|
@@ -2,12 +2,30 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const os = require('os');
|
|
4
4
|
|
|
5
|
+
// Support per-agent config via LYSTBOT_CONFIG env var or --config flag
|
|
6
|
+
let _configPath = process.env.LYSTBOT_CONFIG || null;
|
|
7
|
+
|
|
8
|
+
function setConfigPath(p) {
|
|
9
|
+
_configPath = p;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getConfigDir() {
|
|
13
|
+
if (_configPath) return path.dirname(_configPath);
|
|
14
|
+
return path.join(os.homedir(), '.lystbot');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getConfigPath() {
|
|
18
|
+
if (_configPath) return _configPath;
|
|
19
|
+
return path.join(os.homedir(), '.lystbot', 'config.json');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Keep backwards compat
|
|
5
23
|
const CONFIG_DIR = path.join(os.homedir(), '.lystbot');
|
|
6
24
|
const CONFIG_PATH = path.join(CONFIG_DIR, 'config.json');
|
|
7
25
|
|
|
8
26
|
function read() {
|
|
9
27
|
try {
|
|
10
|
-
const data = fs.readFileSync(
|
|
28
|
+
const data = fs.readFileSync(getConfigPath(), 'utf8');
|
|
11
29
|
return JSON.parse(data);
|
|
12
30
|
} catch {
|
|
13
31
|
return null;
|
|
@@ -15,13 +33,13 @@ function read() {
|
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
function write(config) {
|
|
18
|
-
fs.mkdirSync(
|
|
19
|
-
fs.writeFileSync(
|
|
36
|
+
fs.mkdirSync(getConfigDir(), { recursive: true });
|
|
37
|
+
fs.writeFileSync(getConfigPath(), JSON.stringify(config, null, 2) + '\n');
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
function remove() {
|
|
23
41
|
try {
|
|
24
|
-
fs.unlinkSync(
|
|
42
|
+
fs.unlinkSync(getConfigPath());
|
|
25
43
|
return true;
|
|
26
44
|
} catch {
|
|
27
45
|
return false;
|
|
@@ -53,4 +71,4 @@ function getBaseUrl() {
|
|
|
53
71
|
return PROD_URL;
|
|
54
72
|
}
|
|
55
73
|
|
|
56
|
-
module.exports = { read, write, remove, getApiKey, getBaseUrl, setCustomUrl, PROD_URL, CONFIG_PATH };
|
|
74
|
+
module.exports = { read, write, remove, getApiKey, getBaseUrl, setCustomUrl, setConfigPath, getConfigPath, PROD_URL, CONFIG_PATH };
|
package/src/index.js
CHANGED
|
@@ -5,16 +5,21 @@ const { randomUUID } = require('crypto');
|
|
|
5
5
|
const readline = require('readline');
|
|
6
6
|
const config = require('./config');
|
|
7
7
|
const api = require('./api');
|
|
8
|
+
const pkg = require('../package.json');
|
|
8
9
|
|
|
9
10
|
const program = new Command();
|
|
10
11
|
|
|
11
12
|
program
|
|
12
13
|
.name('lystbot')
|
|
13
14
|
.description('📋 LystBot CLI - Manage your lists from the terminal')
|
|
14
|
-
.version(
|
|
15
|
+
.version(pkg.version)
|
|
15
16
|
.option('--api <url>', 'Use custom API URL')
|
|
17
|
+
.option('--config <path>', 'Use custom config file (for multi-agent setups)')
|
|
16
18
|
.hook('preAction', () => {
|
|
17
19
|
const opts = program.opts();
|
|
20
|
+
if (opts.config) {
|
|
21
|
+
config.setConfigPath(opts.config);
|
|
22
|
+
}
|
|
18
23
|
if (opts.api) {
|
|
19
24
|
config.setCustomUrl(opts.api);
|
|
20
25
|
console.log(`🔗 API: ${opts.api}\n`);
|