lystbot 0.1.0 → 0.2.0

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +54 -43
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lystbot",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "LystBot CLI - Manage your lists from the terminal",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -24,56 +24,67 @@ program
24
24
  // ── login ──────────────────────────────────────────────
25
25
  program
26
26
  .command('login')
27
- .description('Authenticate with LystBot')
28
- .option('--token <api-key>', 'Set API key directly')
29
- .action(async (options) => {
30
- if (options.token) {
31
- config.write({ apiKey: options.token, apiUrl: config.getBaseUrl() });
32
- console.log('✅ Logged in! API key stored.');
33
- return;
34
- }
35
-
36
- // Interactive registration
37
- const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
38
- const ask = (q) => new Promise(resolve => rl.question(q, resolve));
27
+ .description('Authenticate with your LystBot API key (from the app)')
28
+ .argument('[api-key]', 'Your API key from the LystBot app')
29
+ .action(async (apiKey) => {
30
+ if (!apiKey) {
31
+ // Interactive: ask for the key
32
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
33
+ const ask = (q) => new Promise(resolve => rl.question(q, resolve));
39
34
 
40
- console.log('🔐 LystBot Device Registration\n');
41
- const name = await ask('Device name (e.g. "My Laptop"): ');
42
- rl.close();
35
+ console.log('🔑 LystBot CLI Login\n');
36
+ console.log('Open the LystBot app Settings AI Agents → copy your API key.\n');
37
+ apiKey = await ask('API Key: ');
38
+ rl.close();
43
39
 
44
- if (!name.trim()) {
45
- console.error('❌ Name cannot be empty.');
46
- process.exit(1);
40
+ if (!apiKey.trim()) {
41
+ console.error('❌ API key cannot be empty.');
42
+ process.exit(1);
43
+ }
44
+ apiKey = apiKey.trim();
47
45
  }
48
46
 
49
- console.log('\n⏳ Registering device...');
50
- const uuid = randomUUID();
51
- const device = await api.rawRequest('POST', '/devices/register', {
52
- uuid,
53
- name: name.trim(),
54
- platform: 'cli',
55
- });
56
-
57
- console.log(`📱 Device registered: ${device.uuid}`);
58
-
59
- // API key may come directly in register response or via separate endpoint
60
- let apiKey = device.api_key || device.apiKey;
61
- if (!apiKey) {
62
- console.log('⏳ Fetching API key...');
63
- const keyData = await api.rawRequest('GET', `/devices/${device.uuid}/api-key`, null, {
64
- 'X-Device-UUID': device.uuid,
65
- });
66
- apiKey = keyData.api_key || keyData.apiKey;
47
+ // Verify the key works
48
+ config.write({ apiKey, apiUrl: config.getBaseUrl() });
49
+ try {
50
+ const lists = await api.request('GET', '/lists');
51
+ const count = (lists.lists || lists).length;
52
+ console.log(`✅ Logged in! Found ${count} list${count !== 1 ? 's' : ''} on your account.`);
53
+ console.log('');
54
+ console.log('💡 Set your bot name so users see who\'s making changes:');
55
+ console.log(' lystbot profile --name "My Agent" --emoji "🤖"');
56
+ } catch {
57
+ // Key might still be valid but lists endpoint could fail for other reasons
58
+ console.log('✅ API key stored. Run `lystbot lists` to verify.');
67
59
  }
60
+ });
68
61
 
69
- config.write({
70
- apiKey,
71
- deviceUuid: device.uuid,
72
- deviceName: name.trim(),
73
- apiUrl: config.getBaseUrl(),
74
- });
62
+ // ── profile ────────────────────────────────────────────
63
+ program
64
+ .command('profile')
65
+ .description('View or update your bot profile (name, emoji)')
66
+ .option('--name <name>', 'Set bot display name')
67
+ .option('--emoji <emoji>', 'Set bot emoji')
68
+ .action(async (options) => {
69
+ config.getApiKey();
70
+ const updates = {};
71
+ if (options.name) updates.name = options.name;
72
+ if (options.emoji) updates.signature_emoji = options.emoji;
73
+
74
+ if (Object.keys(updates).length === 0) {
75
+ console.log('🤖 Bot Profile');
76
+ console.log('');
77
+ console.log('Set your name and emoji so users see who\'s making changes:');
78
+ console.log(' lystbot profile --name "My Agent" --emoji "🤖"');
79
+ console.log('');
80
+ console.log('Without a name, you\'ll show up as "Bot" in the app.');
81
+ return;
82
+ }
75
83
 
76
- console.log(' Logged in! You\'re all set 🎉');
84
+ await api.request('PATCH', '/agents/me', updates);
85
+ console.log(`✅ Profile updated!`);
86
+ if (options.name) console.log(` Name: ${options.name}`);
87
+ if (options.emoji) console.log(` Emoji: ${options.emoji}`);
77
88
  });
78
89
 
79
90
  // ── logout ─────────────────────────────────────────────