thinkncollab-shell 0.0.8 → 0.0.10

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.
@@ -1,33 +1,33 @@
1
- /**
2
- * Leave Command
3
- *
4
- * Usage: leave
5
- */
6
-
7
- const chalk = require('chalk');
8
-
9
- module.exports = {
10
- name: 'leave',
11
- description: 'Leave current room',
12
- aliases: ['exit-room', 'part'],
13
- requiresAuth: true,
14
- requiresRoom: true,
15
-
16
- async execute(args, shell) {
17
- const room = shell.api.getCurrentRoom();
18
-
19
- if (!room) {
20
- console.log(chalk.yellow('⚠️ Not in any room'));
21
- return;
22
- }
23
-
24
- console.log(chalk.cyan(`👋 Leaving room: ${room.name}...`));
25
-
26
- try {
27
- await shell.api.leaveRoom();
28
- console.log(chalk.green(`✅ Left room: ${room.name}`));
29
- } catch (error) {
30
- console.log(chalk.red(`❌ Failed to leave: ${error.message}`));
31
- }
32
- }
1
+ /*
2
+ Leave Command
3
+
4
+ Usage: leave
5
+ */
6
+
7
+ const chalk = require('chalk');
8
+
9
+ module.exports = {
10
+ name: 'leave',
11
+ description: 'Leave current room',
12
+ aliases: ['exit-room', 'part'],
13
+ requiresAuth: true,
14
+ requiresRoom: true,
15
+
16
+ async execute(args, shell) {
17
+ const room = shell.api.getCurrentRoom();
18
+
19
+ if (!room) {
20
+ console.log(chalk.yellow('⚠️ Not in any room'));
21
+ return;
22
+ }
23
+
24
+ console.log(chalk.cyan(`👋 Leaving room: ${room.name}...`));
25
+
26
+ try {
27
+ await shell.api.leaveRoom();
28
+ console.log(chalk.green(`✅ Left room: ${room.name}`));
29
+ } catch (error) {
30
+ console.log(chalk.red(`❌ Failed to leave: ${error.message}`));
31
+ }
32
+ }
33
33
  };
@@ -1,66 +1,66 @@
1
- /**
2
- * Rooms Command
3
- *
4
- * Usage: rooms
5
- * rooms --all
6
- */
7
-
8
- const chalk = require('chalk');
9
-
10
- module.exports = {
11
- name: 'rooms',
12
- description: 'List available rooms',
13
- aliases: ['channels', 'ls'],
14
- requiresAuth: true,
15
-
16
- async execute(args, shell) {
17
- const showAll = args.includes('--all') || args.includes('-a');
18
-
19
- console.log(chalk.cyan('\n📋 Available Rooms:'));
20
- console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
21
-
22
- try {
23
- const rooms = await shell.api.getRooms();
24
- const currentRoom = shell.api.getCurrentRoom();
25
-
26
- if (rooms.length === 0) {
27
- console.log(chalk.yellow(' No rooms available'));
28
- console.log(chalk.dim('💡 Create a room with: join <new-room-name>'));
29
- return;
30
- }
31
-
32
- // Separate my rooms and other rooms
33
- const myRooms = rooms.filter(r => r.isMember);
34
- const otherRooms = rooms.filter(r => !r.isMember);
35
-
36
- if (myRooms.length > 0) {
37
- console.log(chalk.yellow('\n YOUR ROOMS:'));
38
- myRooms.forEach(room => {
39
- const current = currentRoom && currentRoom.id === room.id ? chalk.green(' (current)') : '';
40
- const active = room.active ? chalk.green('●') : chalk.gray('○');
41
- console.log(` ${active} ${chalk.white(room.name)}${current}`);
42
- console.log(chalk.dim(` ${room.participants} online · ${room.description || ''}`));
43
- });
44
- }
45
-
46
- if (otherRooms.length > 0 && showAll) {
47
- console.log(chalk.yellow('\n PUBLIC ROOMS:'));
48
- otherRooms.slice(0, 10).forEach(room => {
49
- console.log(` ○ ${chalk.white(room.name)}`);
50
- console.log(chalk.dim(` ${room.participants} online · ${room.description || ''}`));
51
- });
52
-
53
- if (otherRooms.length > 10) {
54
- console.log(chalk.dim(` ... and ${otherRooms.length - 10} more (use --all to see all)`));
55
- }
56
- } else if (otherRooms.length > 0) {
57
- console.log(chalk.dim(`\n 📌 ${otherRooms.length} other rooms available (use --all to see)`));
58
- }
59
-
60
- console.log(chalk.dim('\n💡 Type "join <room-name>" to join a room'));
61
-
62
- } catch (error) {
63
- console.log(chalk.red(`❌ Failed to fetch rooms: ${error.message}`));
64
- }
65
- }
1
+ /*
2
+ Rooms Command
3
+
4
+ Usage: rooms
5
+ rooms --all
6
+ */
7
+
8
+ const chalk = require('chalk');
9
+
10
+ module.exports = {
11
+ name: 'rooms',
12
+ description: 'List available rooms',
13
+ aliases: ['channels', 'ls'],
14
+ requiresAuth: true,
15
+
16
+ async execute(args, shell) {
17
+ const showAll = args.includes('--all') || args.includes('-a');
18
+
19
+ console.log(chalk.cyan('\n📋 Available Rooms:'));
20
+ console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
21
+
22
+ try {
23
+ const rooms = await shell.api.getRooms();
24
+ const currentRoom = shell.api.getCurrentRoom();
25
+
26
+ if (rooms.length === 0) {
27
+ console.log(chalk.yellow(' No rooms available'));
28
+ console.log(chalk.dim('💡 Create a room with: join <new-room-name>'));
29
+ return;
30
+ }
31
+
32
+ // Separate my rooms and other rooms
33
+ const myRooms = rooms.filter(r => r.isMember);
34
+ const otherRooms = rooms.filter(r => !r.isMember);
35
+
36
+ if (myRooms.length > 0) {
37
+ console.log(chalk.yellow('\n YOUR ROOMS:'));
38
+ myRooms.forEach(room => {
39
+ const current = currentRoom && currentRoom.id === room.id ? chalk.green(' (current)') : '';
40
+ const active = room.active ? chalk.green('●') : chalk.gray('○');
41
+ console.log(` ${active} ${chalk.white(room.name)}${current}`);
42
+ console.log(chalk.dim(` ${room.participants} online · ${room.description || ''}`));
43
+ });
44
+ }
45
+
46
+ if (otherRooms.length > 0 && showAll) {
47
+ console.log(chalk.yellow('\n PUBLIC ROOMS:'));
48
+ otherRooms.slice(0, 10).forEach(room => {
49
+ console.log(` ○ ${chalk.white(room.name)}`);
50
+ console.log(chalk.dim(` ${room.participants} online · ${room.description || ''}`));
51
+ });
52
+
53
+ if (otherRooms.length > 10) {
54
+ console.log(chalk.dim(` ... and ${otherRooms.length - 10} more (use --all to see all)`));
55
+ }
56
+ } else if (otherRooms.length > 0) {
57
+ console.log(chalk.dim(`\n 📌 ${otherRooms.length} other rooms available (use --all to see)`));
58
+ }
59
+
60
+ console.log(chalk.dim('\n💡 Type "join <room-name>" to join a room'));
61
+
62
+ } catch (error) {
63
+ console.log(chalk.red(`❌ Failed to fetch rooms: ${error.message}`));
64
+ }
65
+ }
66
66
  };
@@ -1,88 +1,88 @@
1
- /**
2
- * src/commands/shell/notify.js — Send notifications to room
3
- */
4
- const chalk = require('chalk');
5
-
6
- module.exports = {
7
- name: 'notify',
8
- description: 'Send a notification to the current room',
9
- aliases: ['notif'],
10
- requiresAuth: true,
11
- requiresRoom: true,
12
-
13
- // Usage:
14
- // notify info <message>
15
- // notify warn <message>
16
- // notify error <message>
17
- // notify success <message>
18
- // notify <message> ← defaults to 'info'
19
-
20
- async execute(args, shell) {
21
- if (!args.length) {
22
- console.log(chalk.yellow('Usage: notify <level> <message>'));
23
- console.log(chalk.dim(' Levels: info | warn | error | success'));
24
- console.log(chalk.dim(' Example: notify info deployment done'));
25
- return;
26
- }
27
-
28
- const levels = ['info', 'warn', 'warning', 'error', 'success'];
29
- let level, message;
30
-
31
- if (levels.includes(args[0].toLowerCase())) {
32
- level = args[0].toLowerCase() === 'warning' ? 'warn' : args[0].toLowerCase();
33
- message = args.slice(1).join(' ');
34
- } else {
35
- level = 'info';
36
- message = args.join(' ');
37
- }
38
-
39
- if (!message.trim()) {
40
- console.log(chalk.red('❌ Message cannot be empty'));
41
- return;
42
- }
43
-
44
- const levelColors = {
45
- info: chalk.blue,
46
- warn: chalk.yellow,
47
- error: chalk.red,
48
- success: chalk.green,
49
- };
50
- const levelIcons = {
51
- info: 'ℹ️ ',
52
- warn: '⚠️ ',
53
- error: '❌',
54
- success: '✅',
55
- };
56
-
57
- const color = levelColors[level] || chalk.blue;
58
- const icon = levelIcons[level] || 'ℹ️ ';
59
-
60
- try {
61
- await shell.ws.sendNotification(
62
- {
63
- type: level,
64
- title: `${level.charAt(0).toUpperCase() + level.slice(1)} from terminal`,
65
- message: message,
66
- data: {
67
- sentBy: shell.api.getUser()?.name || 'unknown',
68
- via: 'thinknsh',
69
- },
70
- },
71
- 'room'
72
- );
73
-
74
- // Also push to local notification window
75
- shell.pushNotification({
76
- type: 'notification',
77
- level: level,
78
- title: `Notify — ${level}`,
79
- message: message,
80
- });
81
-
82
- console.log(color(`${icon} Notification sent → [${level}] ${message}`));
83
-
84
- } catch (err) {
85
- console.log(chalk.red(`❌ Failed to send notification: ${err.message}`));
86
- }
87
- }
1
+ /*
2
+ src/commands/shell/notify.js — Send notifications to room
3
+ */
4
+ const chalk = require('chalk');
5
+
6
+ module.exports = {
7
+ name: 'notify',
8
+ description: 'Send a notification to the current room',
9
+ aliases: ['notif'],
10
+ requiresAuth: true,
11
+ requiresRoom: true,
12
+
13
+ // Usage:
14
+ // notify info <message>
15
+ // notify warn <message>
16
+ // notify error <message>
17
+ // notify success <message>
18
+ // notify <message> ← defaults to 'info'
19
+
20
+ async execute(args, shell) {
21
+ if (!args.length) {
22
+ console.log(chalk.yellow('Usage: notify <level> <message>'));
23
+ console.log(chalk.dim(' Levels: info | warn | error | success'));
24
+ console.log(chalk.dim(' Example: notify info deployment done'));
25
+ return;
26
+ }
27
+
28
+ const levels = ['info', 'warn', 'warning', 'error', 'success'];
29
+ let level, message;
30
+
31
+ if (levels.includes(args[0].toLowerCase())) {
32
+ level = args[0].toLowerCase() === 'warning' ? 'warn' : args[0].toLowerCase();
33
+ message = args.slice(1).join(' ');
34
+ } else {
35
+ level = 'info';
36
+ message = args.join(' ');
37
+ }
38
+
39
+ if (!message.trim()) {
40
+ console.log(chalk.red('❌ Message cannot be empty'));
41
+ return;
42
+ }
43
+
44
+ const levelColors = {
45
+ info: chalk.blue,
46
+ warn: chalk.yellow,
47
+ error: chalk.red,
48
+ success: chalk.green,
49
+ };
50
+ const levelIcons = {
51
+ info: 'ℹ️ ',
52
+ warn: '⚠️ ',
53
+ error: '❌',
54
+ success: '✅',
55
+ };
56
+
57
+ const color = levelColors[level] || chalk.blue;
58
+ const icon = levelIcons[level] || 'ℹ️ ';
59
+
60
+ try {
61
+ await shell.ws.sendNotification(
62
+ {
63
+ type: level,
64
+ title: `${level.charAt(0).toUpperCase() + level.slice(1)} from terminal`,
65
+ message: message,
66
+ data: {
67
+ sentBy: shell.api.getUser()?.name || 'unknown',
68
+ via: 'thinknsh',
69
+ },
70
+ },
71
+ 'room'
72
+ );
73
+
74
+ // Also push to local notification window
75
+ shell.pushNotification({
76
+ type: 'notification',
77
+ level: level,
78
+ title: `Notify — ${level}`,
79
+ message: message,
80
+ });
81
+
82
+ console.log(color(`${icon} Notification sent → [${level}] ${message}`));
83
+
84
+ } catch (err) {
85
+ console.log(chalk.red(`❌ Failed to send notification: ${err.message}`));
86
+ }
87
+ }
88
88
  };
@@ -1,73 +1,73 @@
1
- /**
2
- * Status Command
3
- *
4
- * Usage: status
5
- */
6
-
7
- const chalk = require('chalk');
8
- const os = require('os');
9
-
10
- module.exports = {
11
- name: 'status',
12
- description: 'Show shell and connection status',
13
- aliases: ['stats', 'info'],
14
- requiresAuth: false,
15
-
16
- async execute(args, shell) {
17
- const user = shell.api.getUser();
18
- const room = shell.api.getCurrentRoom();
19
- const connected = shell.api.isConnected();
20
-
21
- console.log(chalk.cyan('\n📊 ThinkNCollab Shell Status'));
22
- console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
23
-
24
- // Connection status
25
- console.log(` ${chalk.yellow('Connection:')} ${connected ? chalk.green('● Online') : chalk.red('○ Offline')}`);
26
-
27
- if (connected) {
28
- console.log(` ${chalk.yellow('Server:')} ${shell.api.config.wsUrl}`);
29
- console.log(` ${chalk.yellow('Socket ID:')} ${shell.api.getSocketId() || 'N/A'}`);
30
- }
31
-
32
- // Authentication
33
- console.log(` ${chalk.yellow('Auth:')} ${user ? chalk.green(`✓ ${user.email}`) : chalk.red('✗ Not logged in')}`);
34
-
35
- if (user) {
36
- console.log(` ${chalk.yellow('User:')} ${user.name || user.email}`);
37
- if (user.team) {
38
- console.log(` ${chalk.yellow('Team:')} ${user.team}`);
39
- }
40
- }
41
-
42
- // Room
43
- if (room) {
44
- console.log(` ${chalk.yellow('Current Room:')} ${chalk.cyan(room.name)} (${room.id})`);
45
- console.log(` ${chalk.yellow('Participants:')} ${room.participants?.length || 0}`);
46
- } else {
47
- console.log(` ${chalk.yellow('Current Room:')} ${chalk.gray('None')}`);
48
- }
49
-
50
- // Shell info
51
- console.log(`\n ${chalk.yellow('Shell Version:')} ${require('../../../package.json').version}`);
52
- console.log(` ${chalk.yellow('Node Version:')} ${process.version}`);
53
- console.log(` ${chalk.yellow('Platform:')} ${os.platform()} ${os.arch()}`);
54
- console.log(` ${chalk.yellow('Uptime:')} ${Math.floor(process.uptime() / 60)}m`);
55
- console.log(` ${chalk.yellow('Memory:')} ${Math.round(process.memoryUsage().rss / 1024 / 1024)} MB`);
56
- console.log(` ${chalk.yellow('History:')} ${shell.history.length} commands`);
57
-
58
- // Suggestions
59
- console.log(chalk.dim('\n💡 Tips:'));
60
- if (!user) {
61
- console.log(chalk.dim(' • Login with: login <email> <password>'));
62
- } else if (!room) {
63
- console.log(chalk.dim(' • Join a room with: join <room-id>'));
64
- console.log(chalk.dim(' • See available rooms: rooms'));
65
- } else {
66
- console.log(chalk.dim(' • Send messages with: say <message>'));
67
- console.log(chalk.dim(' • See teammates: teammates'));
68
- console.log(chalk.dim(' • Leave room: leave'));
69
- }
70
-
71
- console.log();
72
- }
1
+ /*
2
+ Status Command
3
+
4
+ Usage: status
5
+ */
6
+
7
+ const chalk = require('chalk');
8
+ const os = require('os');
9
+
10
+ module.exports = {
11
+ name: 'status',
12
+ description: 'Show shell and connection status',
13
+ aliases: ['stats', 'info'],
14
+ requiresAuth: false,
15
+
16
+ async execute(args, shell) {
17
+ const user = shell.api.getUser();
18
+ const room = shell.api.getCurrentRoom();
19
+ const connected = shell.api.isConnected();
20
+
21
+ console.log(chalk.cyan('\n📊 ThinkNCollab Shell Status'));
22
+ console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
23
+
24
+ // Connection status
25
+ console.log(` ${chalk.yellow('Connection:')} ${connected ? chalk.green('● Online') : chalk.red('○ Offline')}`);
26
+
27
+ if (connected) {
28
+ console.log(` ${chalk.yellow('Server:')} ${shell.api.config.wsUrl}`);
29
+ console.log(` ${chalk.yellow('Socket ID:')} ${shell.api.getSocketId() || 'N/A'}`);
30
+ }
31
+
32
+ // Authentication
33
+ console.log(` ${chalk.yellow('Auth:')} ${user ? chalk.green(`✓ ${user.email}`) : chalk.red('✗ Not logged in')}`);
34
+
35
+ if (user) {
36
+ console.log(` ${chalk.yellow('User:')} ${user.name || user.email}`);
37
+ if (user.team) {
38
+ console.log(` ${chalk.yellow('Team:')} ${user.team}`);
39
+ }
40
+ }
41
+
42
+ // Room
43
+ if (room) {
44
+ console.log(` ${chalk.yellow('Current Room:')} ${chalk.cyan(room.name)} (${room.id})`);
45
+ console.log(` ${chalk.yellow('Participants:')} ${room.participants?.length || 0}`);
46
+ } else {
47
+ console.log(` ${chalk.yellow('Current Room:')} ${chalk.gray('None')}`);
48
+ }
49
+
50
+ // Shell info
51
+ console.log(`\n ${chalk.yellow('Shell Version:')} ${require('../../../package.json').version}`);
52
+ console.log(` ${chalk.yellow('Node Version:')} ${process.version}`);
53
+ console.log(` ${chalk.yellow('Platform:')} ${os.platform()} ${os.arch()}`);
54
+ console.log(` ${chalk.yellow('Uptime:')} ${Math.floor(process.uptime() / 60)}m`);
55
+ console.log(` ${chalk.yellow('Memory:')} ${Math.round(process.memoryUsage().rss / 1024 / 1024)} MB`);
56
+ console.log(` ${chalk.yellow('History:')} ${shell.history.length} commands`);
57
+
58
+ // Suggestions
59
+ console.log(chalk.dim('\n💡 Tips:'));
60
+ if (!user) {
61
+ console.log(chalk.dim(' • Login with: login <email> <password>'));
62
+ } else if (!room) {
63
+ console.log(chalk.dim(' • Join a room with: join <room-id>'));
64
+ console.log(chalk.dim(' • See available rooms: rooms'));
65
+ } else {
66
+ console.log(chalk.dim(' • Send messages with: say <message>'));
67
+ console.log(chalk.dim(' • See teammates: teammates'));
68
+ console.log(chalk.dim(' • Leave room: leave'));
69
+ }
70
+
71
+ console.log();
72
+ }
73
73
  };
@@ -1,47 +1,47 @@
1
- /**
2
- * src/commands/tasks/complete.js — Mark your task assignment as completed
3
- */
4
- const chalk = require('chalk');
5
-
6
- module.exports = {
7
- name: 'complete',
8
- description: 'Mark a task as completed',
9
- aliases: ['done', 'finish', 'complete'],
10
- requiresAuth: true,
11
-
12
- async execute(args, shell) {
13
- if (!args[0]) {
14
- console.log(chalk.red('Usage: complete <task-id>'));
15
- return;
16
- }
17
-
18
- const taskId = args[0];
19
-
20
- try {
21
- const result = await shell.api._request('POST', `/thinknsh/${taskId}/cli/complete`);
22
-
23
- console.log(chalk.green(`✅ Task completed: "${result.task?.title || taskId}"`));
24
-
25
- if (result.allCompleted)
26
- console.log(chalk.green(' 🎉 All assignees have completed this task!'));
27
-
28
- // Push to notification window
29
- shell.pushNotification({
30
- type: 'notification',
31
- level: 'success',
32
- title: 'Task Completed',
33
- message: result.task?.title || taskId,
34
- });
35
-
36
- } catch (err) {
37
- if (err.message?.includes('403'))
38
- console.log(chalk.red('❌ You are not assigned to this task'));
39
- else if (err.message?.includes('404'))
40
- console.log(chalk.red('❌ Task not found'));
41
- else if (err.message?.includes('already'))
42
- console.log(chalk.yellow('⚠️ Task already completed'));
43
- else
44
- console.log(chalk.red(`❌ ${err.message}`));
45
- }
46
- }
1
+ /*
2
+ src/commands/tasks/complete.js — Mark your task assignment as completed
3
+ */
4
+ const chalk = require('chalk');
5
+
6
+ module.exports = {
7
+ name: 'complete',
8
+ description: 'Mark a task as completed',
9
+ aliases: ['done', 'finish', 'complete'],
10
+ requiresAuth: true,
11
+
12
+ async execute(args, shell) {
13
+ if (!args[0]) {
14
+ console.log(chalk.red('Usage: complete <task-id>'));
15
+ return;
16
+ }
17
+
18
+ const taskId = args[0];
19
+
20
+ try {
21
+ const result = await shell.api._request('POST', `/thinknsh/${taskId}/cli/complete`);
22
+
23
+ console.log(chalk.green(`✅ Task completed: "${result.task?.title || taskId}"`));
24
+
25
+ if (result.allCompleted)
26
+ console.log(chalk.green(' 🎉 All assignees have completed this task!'));
27
+
28
+ // Push to notification window
29
+ shell.pushNotification({
30
+ type: 'notification',
31
+ level: 'success',
32
+ title: 'Task Completed',
33
+ message: result.task?.title || taskId,
34
+ });
35
+
36
+ } catch (err) {
37
+ if (err.message?.includes('403'))
38
+ console.log(chalk.red('❌ You are not assigned to this task'));
39
+ else if (err.message?.includes('404'))
40
+ console.log(chalk.red('❌ Task not found'));
41
+ else if (err.message?.includes('already'))
42
+ console.log(chalk.yellow('⚠️ Task already completed'));
43
+ else
44
+ console.log(chalk.red(`❌ ${err.message}`));
45
+ }
46
+ }
47
47
  };