thinkncollab-shell 0.0.8 → 0.0.9
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/thinknsh.js +9 -7
- package/package.json +1 -1
- package/src/commands/auth/login.js +76 -76
- package/src/commands/auth/logout.js +31 -31
- package/src/commands/auth/register.js +51 -51
- package/src/commands/auth/whoami.js +51 -51
- package/src/commands/index.js +129 -129
- package/src/commands/message/say.js +42 -42
- package/src/commands/room/join.js +141 -141
- package/src/commands/room/leave.js +32 -32
- package/src/commands/room/rooms.js +65 -65
- package/src/commands/shell/notify.js +87 -87
- package/src/commands/shell/status.js +72 -72
- package/src/commands/tasks/complete.js +46 -46
- package/src/commands/tasks/create-task.js +100 -100
- package/src/commands/tasks/task-status.js +60 -60
- package/src/commands/tasks/task.js +74 -74
- package/src/commands/tasks/tasks.js +182 -182
- package/src/commands/team/invite.js +45 -45
- package/src/commands/team/myteam.js +77 -77
- package/src/commands/team/teammates.js +51 -51
- package/src/commands/terminal/share.js +251 -251
- package/src/core/api-client.js +245 -245
- package/src/core/project-config.js +99 -99
- package/src/core/shell.js +164 -35
- package/src/core/websocket.js +2 -2
- package/src/events/notifications.js +15 -28
- package/src/utils/logger.js +10 -20
|
@@ -1,183 +1,183 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
name: 'tasks',
|
|
8
|
-
description: 'List your tasks + suggested tasks in the current room',
|
|
9
|
-
aliases: ['mytasks', 'my-tasks'],
|
|
10
|
-
requiresAuth: true,
|
|
11
|
-
requiresRoom: true,
|
|
12
|
-
|
|
13
|
-
async execute(args, shell) {
|
|
14
|
-
const user = shell.api.getUser();
|
|
15
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
16
|
-
|
|
17
|
-
if (!user) { console.log(chalk.red('❌ Please login first')); return; }
|
|
18
|
-
if (!roomId) { console.log(chalk.yellow('⚠️ Join a room first: join <room-id>')); return; }
|
|
19
|
-
|
|
20
|
-
// ── Flags ────────────────────────────────────────────────────────────
|
|
21
|
-
const showAll = args.includes('--all') || args.includes('-a');
|
|
22
|
-
const noSuggestions = args.includes('--no-suggest') || args.includes('-ns');
|
|
23
|
-
const filterStatus = args.find(a => ['pending','inprogress','review','completed','reopened'].includes(a));
|
|
24
|
-
const topN = args.find(a => /^\d+$/.test(a)) || 5;
|
|
25
|
-
|
|
26
|
-
// ── Color maps ───────────────────────────────────────────────────────
|
|
27
|
-
const stColors = {
|
|
28
|
-
pending: chalk.yellow,
|
|
29
|
-
inprogress: chalk.blue,
|
|
30
|
-
review: chalk.magenta,
|
|
31
|
-
completed: chalk.green,
|
|
32
|
-
reopened: chalk.cyan,
|
|
33
|
-
};
|
|
34
|
-
const prColors = {
|
|
35
|
-
critical: chalk.red,
|
|
36
|
-
high: chalk.hex('#FF6B35'),
|
|
37
|
-
medium: chalk.yellow,
|
|
38
|
-
low: chalk.green,
|
|
39
|
-
};
|
|
40
|
-
const scoreColor = s => s >= 80 ? chalk.red(s) : s >= 60 ? chalk.yellow(s) : chalk.green(s);
|
|
41
|
-
const plColor = pl => ({
|
|
42
|
-
CRITICAL: chalk.red,
|
|
43
|
-
HIGH: chalk.hex('#FF6B35'),
|
|
44
|
-
MEDIUM: chalk.yellow,
|
|
45
|
-
LOW: chalk.green,
|
|
46
|
-
'VERY LOW': chalk.dim,
|
|
47
|
-
}[pl] || chalk.white);
|
|
48
|
-
|
|
49
|
-
// ── Helpers ──────────────────────────────────────────────────────────
|
|
50
|
-
const fmtDue = dueDate => {
|
|
51
|
-
if (!dueDate) return '';
|
|
52
|
-
const d = new Date(dueDate);
|
|
53
|
-
const days = Math.ceil((d - new Date().setHours(0,0,0,0)) / 86400000);
|
|
54
|
-
const str = d.toLocaleDateString('en-IN', { day:'2-digit', month:'short' });
|
|
55
|
-
if (days < 0) return chalk.red(` due:${str}(!)`);
|
|
56
|
-
if (days === 0) return chalk.yellow(` due:TODAY`);
|
|
57
|
-
if (days === 1) return chalk.yellow(` due:${str}`);
|
|
58
|
-
return chalk.dim(` due:${str}`);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const divider = (color = chalk.cyan) => color(' ' + '─'.repeat(58));
|
|
62
|
-
const subline = (label, val) =>
|
|
63
|
-
` ${chalk.dim(label+':')} ${chalk.dim(val)}`;
|
|
64
|
-
|
|
65
|
-
// ── Fetch ────────────────────────────────────────────────────────────
|
|
66
|
-
process.stdout.write(chalk.dim(' Fetching tasks...\r'));
|
|
67
|
-
|
|
68
|
-
let result;
|
|
69
|
-
try {
|
|
70
|
-
result = await shell.api._request('GET', `/thinknsh/${roomId}/tasks?n=${topN}`);
|
|
71
|
-
} catch (err) {
|
|
72
|
-
console.log(chalk.red(`\n ❌ ${err.message}\n`));
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
process.stdout.write(' '.repeat(30) + '\r'); // clear spinner line
|
|
77
|
-
|
|
78
|
-
// ════════════════════════════════════════════════════════════════════
|
|
79
|
-
// MY TASKS
|
|
80
|
-
// ════════════════════════════════════════════════════════════════════
|
|
81
|
-
let tasks = result.tasks || [];
|
|
82
|
-
|
|
83
|
-
if (filterStatus) tasks = tasks.filter(t => t.status === filterStatus);
|
|
84
|
-
if (!showAll) tasks = tasks.filter(t => !['completed','done'].includes(t.status));
|
|
85
|
-
|
|
86
|
-
console.log(divider());
|
|
87
|
-
console.log(chalk.cyan(` MY TASKS`) + chalk.dim(` (${tasks.length} active${result.total > tasks.length ? ` of ${result.total}` : ''})`));
|
|
88
|
-
console.log(divider());
|
|
89
|
-
|
|
90
|
-
if (!tasks.length) {
|
|
91
|
-
console.log(chalk.dim('\n No assigned tasks.\n'));
|
|
92
|
-
} else {
|
|
93
|
-
tasks.forEach((task, i) => {
|
|
94
|
-
const sc = stColors[task.status] || chalk.white;
|
|
95
|
-
const pc = prColors[task.priority] || chalk.white;
|
|
96
|
-
|
|
97
|
-
const num = chalk.dim(` ${String(i+1).padStart(2)}.`);
|
|
98
|
-
const status = sc(`[${(task.status || 'unknown').padEnd(10)}]`);
|
|
99
|
-
const title = task.status === 'completed'
|
|
100
|
-
? chalk.dim(task.title)
|
|
101
|
-
: chalk.white(task.title);
|
|
102
|
-
const due = fmtDue(task.dueDate);
|
|
103
|
-
const myStatus = task.myStatus && task.myStatus !== task.status
|
|
104
|
-
? chalk.dim(` (${task.myStatus})`)
|
|
105
|
-
: '';
|
|
106
|
-
const col = task.column ? chalk.dim(` [${task.column}]`) : '';
|
|
107
|
-
|
|
108
|
-
console.log(`\n${num} ${status} ${title}`);
|
|
109
|
-
console.log(subline('id', task._id) +
|
|
110
|
-
` ${chalk.dim('priority:')} ${pc(task.priority)}` +
|
|
111
|
-
due + myStatus + col);
|
|
112
|
-
|
|
113
|
-
if (task.description) {
|
|
114
|
-
const desc = task.description.length > 90
|
|
115
|
-
? task.description.slice(0, 87) + '...'
|
|
116
|
-
: task.description;
|
|
117
|
-
console.log(` ${chalk.dim(desc)}`);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// ════════════════════════════════════════════════════════════════════
|
|
123
|
-
// SUGGESTIONS
|
|
124
|
-
// ════════════════════════════════════════════════════════════════════
|
|
125
|
-
if (!noSuggestions) {
|
|
126
|
-
const suggestions = result.suggestions?.tasks || [];
|
|
127
|
-
const insights = result.suggestions?.insights || {};
|
|
128
|
-
const meta = result.suggestions?.metadata || {};
|
|
129
|
-
|
|
130
|
-
console.log('\n' + divider(chalk.magenta));
|
|
131
|
-
console.log(chalk.magenta(` SUGGESTED FOR YOU`) +
|
|
132
|
-
chalk.dim(` (top ${suggestions.length}${meta.totalScored ? ` of ${meta.totalScored} available` : ''})`));
|
|
133
|
-
console.log(divider(chalk.magenta));
|
|
134
|
-
|
|
135
|
-
if (!suggestions.length) {
|
|
136
|
-
console.log(chalk.dim('\n No suggestions — all tasks are assigned.\n'));
|
|
137
|
-
} else {
|
|
138
|
-
suggestions.forEach((task, i) => {
|
|
139
|
-
const pc = prColors[task.priority] || chalk.white;
|
|
140
|
-
const plc = plColor(task.priorityLevel);
|
|
141
|
-
const due = fmtDue(task.dueDate);
|
|
142
|
-
const col = task.column ? chalk.dim(` [${task.column}]`) : '';
|
|
143
|
-
const assignees = task.assigneeCount
|
|
144
|
-
? chalk.dim(` · ${task.assigneeCount} assigned`)
|
|
145
|
-
: chalk.dim(' · unassigned');
|
|
146
|
-
const urgentTag = task.isOverdue
|
|
147
|
-
? chalk.red(' ⚠ OVERDUE')
|
|
148
|
-
: task.isUrgent ? chalk.yellow(' ⏰ URGENT') : '';
|
|
149
|
-
|
|
150
|
-
const num = chalk.dim(` ${String(i+1).padStart(2)}.`);
|
|
151
|
-
const score = `[score:${scoreColor(task.score)}]`;
|
|
152
|
-
const level = plc(`[${task.priorityLevel}]`);
|
|
153
|
-
|
|
154
|
-
console.log(`\n${num} ${score} ${level} ${chalk.white(task.title)}${urgentTag}`);
|
|
155
|
-
console.log(subline('id', task._id) +
|
|
156
|
-
` ${chalk.dim('priority:')} ${pc(task.priority)}` +
|
|
157
|
-
due + col + assignees);
|
|
158
|
-
|
|
159
|
-
if (task.priorityReason) {
|
|
160
|
-
console.log(` ${chalk.dim('↳ ' + task.priorityReason)}`);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
// ── Insights bar ─────────────────────────────────────────────
|
|
165
|
-
console.log('\n' + divider(chalk.dim));
|
|
166
|
-
if (insights.focusRecommendation) {
|
|
167
|
-
console.log(` ${chalk.magenta('💡')} ${chalk.white(insights.focusRecommendation)}`);
|
|
168
|
-
}
|
|
169
|
-
if (insights.estimatedTime) {
|
|
170
|
-
console.log(` ${chalk.dim('⏱ Est. time:')} ${chalk.white(insights.estimatedTime)}`);
|
|
171
|
-
}
|
|
172
|
-
if (meta.scoreRange) {
|
|
173
|
-
console.log(` ${chalk.dim('📊 Score range:')} ${chalk.white(`${meta.scoreRange.min}–${meta.scoreRange.max}`)} ${chalk.dim('avg:')} ${chalk.white(meta.scoreRange.avg)}`);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ── Footer ───────────────────────────────────────────────────────────
|
|
179
|
-
console.log('\n' + divider());
|
|
180
|
-
console.log(chalk.dim(' task <id> · complete <id> · tasks --all · tasks 10 · tasks --no-suggest'));
|
|
181
|
-
console.log(divider() + '\n');
|
|
182
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
src/commands/tasks/tasks.js — List my tasks + suggestions in current room
|
|
3
|
+
*/
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
name: 'tasks',
|
|
8
|
+
description: 'List your tasks + suggested tasks in the current room',
|
|
9
|
+
aliases: ['mytasks', 'my-tasks'],
|
|
10
|
+
requiresAuth: true,
|
|
11
|
+
requiresRoom: true,
|
|
12
|
+
|
|
13
|
+
async execute(args, shell) {
|
|
14
|
+
const user = shell.api.getUser();
|
|
15
|
+
const roomId = shell.ws.getCurrentRoom();
|
|
16
|
+
|
|
17
|
+
if (!user) { console.log(chalk.red('❌ Please login first')); return; }
|
|
18
|
+
if (!roomId) { console.log(chalk.yellow('⚠️ Join a room first: join <room-id>')); return; }
|
|
19
|
+
|
|
20
|
+
// ── Flags ────────────────────────────────────────────────────────────
|
|
21
|
+
const showAll = args.includes('--all') || args.includes('-a');
|
|
22
|
+
const noSuggestions = args.includes('--no-suggest') || args.includes('-ns');
|
|
23
|
+
const filterStatus = args.find(a => ['pending','inprogress','review','completed','reopened'].includes(a));
|
|
24
|
+
const topN = args.find(a => /^\d+$/.test(a)) || 5;
|
|
25
|
+
|
|
26
|
+
// ── Color maps ───────────────────────────────────────────────────────
|
|
27
|
+
const stColors = {
|
|
28
|
+
pending: chalk.yellow,
|
|
29
|
+
inprogress: chalk.blue,
|
|
30
|
+
review: chalk.magenta,
|
|
31
|
+
completed: chalk.green,
|
|
32
|
+
reopened: chalk.cyan,
|
|
33
|
+
};
|
|
34
|
+
const prColors = {
|
|
35
|
+
critical: chalk.red,
|
|
36
|
+
high: chalk.hex('#FF6B35'),
|
|
37
|
+
medium: chalk.yellow,
|
|
38
|
+
low: chalk.green,
|
|
39
|
+
};
|
|
40
|
+
const scoreColor = s => s >= 80 ? chalk.red(s) : s >= 60 ? chalk.yellow(s) : chalk.green(s);
|
|
41
|
+
const plColor = pl => ({
|
|
42
|
+
CRITICAL: chalk.red,
|
|
43
|
+
HIGH: chalk.hex('#FF6B35'),
|
|
44
|
+
MEDIUM: chalk.yellow,
|
|
45
|
+
LOW: chalk.green,
|
|
46
|
+
'VERY LOW': chalk.dim,
|
|
47
|
+
}[pl] || chalk.white);
|
|
48
|
+
|
|
49
|
+
// ── Helpers ──────────────────────────────────────────────────────────
|
|
50
|
+
const fmtDue = dueDate => {
|
|
51
|
+
if (!dueDate) return '';
|
|
52
|
+
const d = new Date(dueDate);
|
|
53
|
+
const days = Math.ceil((d - new Date().setHours(0,0,0,0)) / 86400000);
|
|
54
|
+
const str = d.toLocaleDateString('en-IN', { day:'2-digit', month:'short' });
|
|
55
|
+
if (days < 0) return chalk.red(` due:${str}(!)`);
|
|
56
|
+
if (days === 0) return chalk.yellow(` due:TODAY`);
|
|
57
|
+
if (days === 1) return chalk.yellow(` due:${str}`);
|
|
58
|
+
return chalk.dim(` due:${str}`);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
const divider = (color = chalk.cyan) => color(' ' + '─'.repeat(58));
|
|
62
|
+
const subline = (label, val) =>
|
|
63
|
+
` ${chalk.dim(label+':')} ${chalk.dim(val)}`;
|
|
64
|
+
|
|
65
|
+
// ── Fetch ────────────────────────────────────────────────────────────
|
|
66
|
+
process.stdout.write(chalk.dim(' Fetching tasks...\r'));
|
|
67
|
+
|
|
68
|
+
let result;
|
|
69
|
+
try {
|
|
70
|
+
result = await shell.api._request('GET', `/thinknsh/${roomId}/tasks?n=${topN}`);
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.log(chalk.red(`\n ❌ ${err.message}\n`));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
process.stdout.write(' '.repeat(30) + '\r'); // clear spinner line
|
|
77
|
+
|
|
78
|
+
// ════════════════════════════════════════════════════════════════════
|
|
79
|
+
// MY TASKS
|
|
80
|
+
// ════════════════════════════════════════════════════════════════════
|
|
81
|
+
let tasks = result.tasks || [];
|
|
82
|
+
|
|
83
|
+
if (filterStatus) tasks = tasks.filter(t => t.status === filterStatus);
|
|
84
|
+
if (!showAll) tasks = tasks.filter(t => !['completed','done'].includes(t.status));
|
|
85
|
+
|
|
86
|
+
console.log(divider());
|
|
87
|
+
console.log(chalk.cyan(` MY TASKS`) + chalk.dim(` (${tasks.length} active${result.total > tasks.length ? ` of ${result.total}` : ''})`));
|
|
88
|
+
console.log(divider());
|
|
89
|
+
|
|
90
|
+
if (!tasks.length) {
|
|
91
|
+
console.log(chalk.dim('\n No assigned tasks.\n'));
|
|
92
|
+
} else {
|
|
93
|
+
tasks.forEach((task, i) => {
|
|
94
|
+
const sc = stColors[task.status] || chalk.white;
|
|
95
|
+
const pc = prColors[task.priority] || chalk.white;
|
|
96
|
+
|
|
97
|
+
const num = chalk.dim(` ${String(i+1).padStart(2)}.`);
|
|
98
|
+
const status = sc(`[${(task.status || 'unknown').padEnd(10)}]`);
|
|
99
|
+
const title = task.status === 'completed'
|
|
100
|
+
? chalk.dim(task.title)
|
|
101
|
+
: chalk.white(task.title);
|
|
102
|
+
const due = fmtDue(task.dueDate);
|
|
103
|
+
const myStatus = task.myStatus && task.myStatus !== task.status
|
|
104
|
+
? chalk.dim(` (${task.myStatus})`)
|
|
105
|
+
: '';
|
|
106
|
+
const col = task.column ? chalk.dim(` [${task.column}]`) : '';
|
|
107
|
+
|
|
108
|
+
console.log(`\n${num} ${status} ${title}`);
|
|
109
|
+
console.log(subline('id', task._id) +
|
|
110
|
+
` ${chalk.dim('priority:')} ${pc(task.priority)}` +
|
|
111
|
+
due + myStatus + col);
|
|
112
|
+
|
|
113
|
+
if (task.description) {
|
|
114
|
+
const desc = task.description.length > 90
|
|
115
|
+
? task.description.slice(0, 87) + '...'
|
|
116
|
+
: task.description;
|
|
117
|
+
console.log(` ${chalk.dim(desc)}`);
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ════════════════════════════════════════════════════════════════════
|
|
123
|
+
// SUGGESTIONS
|
|
124
|
+
// ════════════════════════════════════════════════════════════════════
|
|
125
|
+
if (!noSuggestions) {
|
|
126
|
+
const suggestions = result.suggestions?.tasks || [];
|
|
127
|
+
const insights = result.suggestions?.insights || {};
|
|
128
|
+
const meta = result.suggestions?.metadata || {};
|
|
129
|
+
|
|
130
|
+
console.log('\n' + divider(chalk.magenta));
|
|
131
|
+
console.log(chalk.magenta(` SUGGESTED FOR YOU`) +
|
|
132
|
+
chalk.dim(` (top ${suggestions.length}${meta.totalScored ? ` of ${meta.totalScored} available` : ''})`));
|
|
133
|
+
console.log(divider(chalk.magenta));
|
|
134
|
+
|
|
135
|
+
if (!suggestions.length) {
|
|
136
|
+
console.log(chalk.dim('\n No suggestions — all tasks are assigned.\n'));
|
|
137
|
+
} else {
|
|
138
|
+
suggestions.forEach((task, i) => {
|
|
139
|
+
const pc = prColors[task.priority] || chalk.white;
|
|
140
|
+
const plc = plColor(task.priorityLevel);
|
|
141
|
+
const due = fmtDue(task.dueDate);
|
|
142
|
+
const col = task.column ? chalk.dim(` [${task.column}]`) : '';
|
|
143
|
+
const assignees = task.assigneeCount
|
|
144
|
+
? chalk.dim(` · ${task.assigneeCount} assigned`)
|
|
145
|
+
: chalk.dim(' · unassigned');
|
|
146
|
+
const urgentTag = task.isOverdue
|
|
147
|
+
? chalk.red(' ⚠ OVERDUE')
|
|
148
|
+
: task.isUrgent ? chalk.yellow(' ⏰ URGENT') : '';
|
|
149
|
+
|
|
150
|
+
const num = chalk.dim(` ${String(i+1).padStart(2)}.`);
|
|
151
|
+
const score = `[score:${scoreColor(task.score)}]`;
|
|
152
|
+
const level = plc(`[${task.priorityLevel}]`);
|
|
153
|
+
|
|
154
|
+
console.log(`\n${num} ${score} ${level} ${chalk.white(task.title)}${urgentTag}`);
|
|
155
|
+
console.log(subline('id', task._id) +
|
|
156
|
+
` ${chalk.dim('priority:')} ${pc(task.priority)}` +
|
|
157
|
+
due + col + assignees);
|
|
158
|
+
|
|
159
|
+
if (task.priorityReason) {
|
|
160
|
+
console.log(` ${chalk.dim('↳ ' + task.priorityReason)}`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// ── Insights bar ─────────────────────────────────────────────
|
|
165
|
+
console.log('\n' + divider(chalk.dim));
|
|
166
|
+
if (insights.focusRecommendation) {
|
|
167
|
+
console.log(` ${chalk.magenta('💡')} ${chalk.white(insights.focusRecommendation)}`);
|
|
168
|
+
}
|
|
169
|
+
if (insights.estimatedTime) {
|
|
170
|
+
console.log(` ${chalk.dim('⏱ Est. time:')} ${chalk.white(insights.estimatedTime)}`);
|
|
171
|
+
}
|
|
172
|
+
if (meta.scoreRange) {
|
|
173
|
+
console.log(` ${chalk.dim('📊 Score range:')} ${chalk.white(`${meta.scoreRange.min}–${meta.scoreRange.max}`)} ${chalk.dim('avg:')} ${chalk.white(meta.scoreRange.avg)}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ── Footer ───────────────────────────────────────────────────────────
|
|
179
|
+
console.log('\n' + divider());
|
|
180
|
+
console.log(chalk.dim(' task <id> · complete <id> · tasks --all · tasks 10 · tasks --no-suggest'));
|
|
181
|
+
console.log(divider() + '\n');
|
|
182
|
+
}
|
|
183
183
|
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const chalk = require('chalk');
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
name: 'invite',
|
|
12
|
-
description: 'Invite someone to your team',
|
|
13
|
-
aliases: ['inv'],
|
|
14
|
-
requiresAuth: true,
|
|
15
|
-
|
|
16
|
-
async execute(args, shell) {
|
|
17
|
-
if (args.length === 0) {
|
|
18
|
-
console.log(chalk.red('❌ Usage: invite <email> [--role <role>]'));
|
|
19
|
-
console.log(chalk.dim(' Roles: admin, member, viewer'));
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const email = args[0];
|
|
24
|
-
const roleIndex = args.indexOf('--role');
|
|
25
|
-
const role = roleIndex !== -1 && args[roleIndex + 1] ? args[roleIndex + 1] : 'member';
|
|
26
|
-
|
|
27
|
-
console.log(chalk.cyan(`📧 Inviting ${email} as ${role}...`));
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const result = await shell.api.inviteTeammate(email, role);
|
|
31
|
-
|
|
32
|
-
console.log(chalk.green(`✅ Invitation sent to ${email}`));
|
|
33
|
-
|
|
34
|
-
if (result.inviteLink) {
|
|
35
|
-
console.log(chalk.dim(`📎 Invite link: ${result.inviteLink}`));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
} catch (error) {
|
|
39
|
-
if (error.message.includes('already')) {
|
|
40
|
-
console.log(chalk.yellow(`⚠️ ${email} is already a team member`));
|
|
41
|
-
} else {
|
|
42
|
-
console.log(chalk.red(`❌ Invitation failed: ${error.message}`));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
Invite Command
|
|
3
|
+
|
|
4
|
+
Usage: invite <email>
|
|
5
|
+
invite <email> --role <role>
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
|
|
10
|
+
module.exports = {
|
|
11
|
+
name: 'invite',
|
|
12
|
+
description: 'Invite someone to your team',
|
|
13
|
+
aliases: ['inv'],
|
|
14
|
+
requiresAuth: true,
|
|
15
|
+
|
|
16
|
+
async execute(args, shell) {
|
|
17
|
+
if (args.length === 0) {
|
|
18
|
+
console.log(chalk.red('❌ Usage: invite <email> [--role <role>]'));
|
|
19
|
+
console.log(chalk.dim(' Roles: admin, member, viewer'));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const email = args[0];
|
|
24
|
+
const roleIndex = args.indexOf('--role');
|
|
25
|
+
const role = roleIndex !== -1 && args[roleIndex + 1] ? args[roleIndex + 1] : 'member';
|
|
26
|
+
|
|
27
|
+
console.log(chalk.cyan(`📧 Inviting ${email} as ${role}...`));
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const result = await shell.api.inviteTeammate(email, role);
|
|
31
|
+
|
|
32
|
+
console.log(chalk.green(`✅ Invitation sent to ${email}`));
|
|
33
|
+
|
|
34
|
+
if (result.inviteLink) {
|
|
35
|
+
console.log(chalk.dim(`📎 Invite link: ${result.inviteLink}`));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (error.message.includes('already')) {
|
|
40
|
+
console.log(chalk.yellow(`⚠️ ${email} is already a team member`));
|
|
41
|
+
} else {
|
|
42
|
+
console.log(chalk.red(`❌ Invitation failed: ${error.message}`));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
46
|
};
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const chalk = require('chalk');
|
|
9
|
-
const Table = require('cli-table3');
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
name: 'myteam',
|
|
13
|
-
description: 'Show team information and members',
|
|
14
|
-
aliases: ['team', 'org'],
|
|
15
|
-
requiresAuth: true,
|
|
16
|
-
|
|
17
|
-
async execute(args, shell) {
|
|
18
|
-
const teamId = args[0] || shell.api.getUser()?.team;
|
|
19
|
-
|
|
20
|
-
if (!teamId) {
|
|
21
|
-
console.log(chalk.yellow('⚠️ You are not part of any team'));
|
|
22
|
-
console.log(chalk.dim('💡 Ask your team admin for an invite'));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
console.log(chalk.cyan(`\n👥 Team Information: ${teamId}`));
|
|
27
|
-
console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const teamInfo = await shell.api.getTeamInfo(teamId);
|
|
31
|
-
|
|
32
|
-
// Team details
|
|
33
|
-
console.log(` ${chalk.yellow('Name:')} ${teamInfo.name}`);
|
|
34
|
-
console.log(` ${chalk.yellow('Members:')} ${teamInfo.memberCount}`);
|
|
35
|
-
console.log(` ${chalk.yellow('Rooms:')} ${teamInfo.roomCount}`);
|
|
36
|
-
console.log(` ${chalk.yellow('Created:')} ${new Date(teamInfo.createdAt).toLocaleDateString()}`);
|
|
37
|
-
|
|
38
|
-
if (teamInfo.description) {
|
|
39
|
-
console.log(` ${chalk.yellow('Description:')} ${teamInfo.description}`);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
console.log();
|
|
43
|
-
|
|
44
|
-
// Team members table
|
|
45
|
-
const table = new Table({
|
|
46
|
-
head: ['Status', 'Name', 'Email', 'Role', 'Current Room'],
|
|
47
|
-
colWidths: [8, 20, 25, 12, 20]
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
teamInfo.members.forEach(member => {
|
|
51
|
-
const status = member.online ? chalk.green('●') : chalk.gray('○');
|
|
52
|
-
const room = member.currentRoom || '-';
|
|
53
|
-
table.push([
|
|
54
|
-
status,
|
|
55
|
-
member.name || member.email.split('@')[0],
|
|
56
|
-
member.email,
|
|
57
|
-
member.role || 'member',
|
|
58
|
-
room
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
console.log(table.toString());
|
|
63
|
-
console.log();
|
|
64
|
-
|
|
65
|
-
// Team activity
|
|
66
|
-
if (teamInfo.recentActivity && teamInfo.recentActivity.length > 0) {
|
|
67
|
-
console.log(chalk.cyan('📊 Recent Activity:'));
|
|
68
|
-
teamInfo.recentActivity.slice(0, 5).forEach(activity => {
|
|
69
|
-
const time = new Date(activity.timestamp).toLocaleTimeString();
|
|
70
|
-
console.log(chalk.dim(` [${time}] ${activity.user}: ${activity.action}`));
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.log(chalk.red(`❌ Failed to fetch team info: ${error.message}`));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
MyTeam Command
|
|
3
|
+
|
|
4
|
+
Usage: myteam
|
|
5
|
+
myteam [team-id]
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
const Table = require('cli-table3');
|
|
10
|
+
|
|
11
|
+
module.exports = {
|
|
12
|
+
name: 'myteam',
|
|
13
|
+
description: 'Show team information and members',
|
|
14
|
+
aliases: ['team', 'org'],
|
|
15
|
+
requiresAuth: true,
|
|
16
|
+
|
|
17
|
+
async execute(args, shell) {
|
|
18
|
+
const teamId = args[0] || shell.api.getUser()?.team;
|
|
19
|
+
|
|
20
|
+
if (!teamId) {
|
|
21
|
+
console.log(chalk.yellow('⚠️ You are not part of any team'));
|
|
22
|
+
console.log(chalk.dim('💡 Ask your team admin for an invite'));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
console.log(chalk.cyan(`\n👥 Team Information: ${teamId}`));
|
|
27
|
+
console.log(chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const teamInfo = await shell.api.getTeamInfo(teamId);
|
|
31
|
+
|
|
32
|
+
// Team details
|
|
33
|
+
console.log(` ${chalk.yellow('Name:')} ${teamInfo.name}`);
|
|
34
|
+
console.log(` ${chalk.yellow('Members:')} ${teamInfo.memberCount}`);
|
|
35
|
+
console.log(` ${chalk.yellow('Rooms:')} ${teamInfo.roomCount}`);
|
|
36
|
+
console.log(` ${chalk.yellow('Created:')} ${new Date(teamInfo.createdAt).toLocaleDateString()}`);
|
|
37
|
+
|
|
38
|
+
if (teamInfo.description) {
|
|
39
|
+
console.log(` ${chalk.yellow('Description:')} ${teamInfo.description}`);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
console.log();
|
|
43
|
+
|
|
44
|
+
// Team members table
|
|
45
|
+
const table = new Table({
|
|
46
|
+
head: ['Status', 'Name', 'Email', 'Role', 'Current Room'],
|
|
47
|
+
colWidths: [8, 20, 25, 12, 20]
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
teamInfo.members.forEach(member => {
|
|
51
|
+
const status = member.online ? chalk.green('●') : chalk.gray('○');
|
|
52
|
+
const room = member.currentRoom || '-';
|
|
53
|
+
table.push([
|
|
54
|
+
status,
|
|
55
|
+
member.name || member.email.split('@')[0],
|
|
56
|
+
member.email,
|
|
57
|
+
member.role || 'member',
|
|
58
|
+
room
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
console.log(table.toString());
|
|
63
|
+
console.log();
|
|
64
|
+
|
|
65
|
+
// Team activity
|
|
66
|
+
if (teamInfo.recentActivity && teamInfo.recentActivity.length > 0) {
|
|
67
|
+
console.log(chalk.cyan('📊 Recent Activity:'));
|
|
68
|
+
teamInfo.recentActivity.slice(0, 5).forEach(activity => {
|
|
69
|
+
const time = new Date(activity.timestamp).toLocaleTimeString();
|
|
70
|
+
console.log(chalk.dim(` [${time}] ${activity.user}: ${activity.action}`));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.log(chalk.red(`❌ Failed to fetch team info: ${error.message}`));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
78
|
};
|