thinkncollab-shell 0.0.19 → 2.0.0-beta.1
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/LICENSE +82 -0
- package/Readme.md +246 -502
- package/dist/bin/thinknsh.js +8 -0
- package/dist/src/commands/auth/login.js +7 -0
- package/dist/src/commands/auth/logout.js +7 -0
- package/dist/src/commands/auth/register.js +7 -0
- package/dist/src/commands/auth/whoami.js +7 -0
- package/dist/src/commands/dock/bench.js +7 -0
- package/dist/src/commands/dock/ci.js +7 -0
- package/dist/src/commands/dock/cluster.js +7 -0
- package/dist/src/commands/dock/containers.js +7 -0
- package/dist/src/commands/dock/dock.js +7 -0
- package/dist/src/commands/github/commits.js +7 -0
- package/dist/src/commands/github/issue-create.js +7 -0
- package/dist/src/commands/github/issues.js +7 -0
- package/dist/src/commands/github/pulls.js +7 -0
- package/dist/src/commands/github/statusgh.js +7 -0
- package/dist/src/commands/index.js +7 -0
- package/dist/src/commands/message/say.js +7 -0
- package/dist/src/commands/room/join.js +7 -0
- package/dist/src/commands/room/leave.js +7 -0
- package/dist/src/commands/room/rooms.js +7 -0
- package/dist/src/commands/room/sync.js +7 -0
- package/dist/src/commands/sandbox/console.js +7 -0
- package/dist/src/commands/sandbox/dep.js +7 -0
- package/dist/src/commands/sandbox/deploy.js +7 -0
- package/dist/src/commands/sandbox/dev.js +7 -0
- package/dist/src/commands/sandbox/exec.js +7 -0
- package/dist/src/commands/sandbox/freeze.js +7 -0
- package/dist/src/commands/sandbox/push.js +7 -0
- package/dist/src/commands/sandbox/resume.js +7 -0
- package/dist/src/commands/sandbox/sandbox.js +7 -0
- package/dist/src/commands/sandbox/share.js +7 -0
- package/dist/src/commands/sandbox/snapshot.js +7 -0
- package/dist/src/commands/sandbox/sync-deps.js +7 -0
- package/dist/src/commands/shell/doctor.js +7 -0
- package/dist/src/commands/shell/notifications.js +7 -0
- package/dist/src/commands/shell/notify.js +7 -0
- package/dist/src/commands/shell/status.js +7 -0
- package/dist/src/commands/shell/version.js +7 -0
- package/dist/src/commands/tasks/build.js +7 -0
- package/dist/src/commands/tasks/complete.js +7 -0
- package/dist/src/commands/tasks/create-task.js +7 -0
- package/dist/src/commands/tasks/loadtest.js +7 -0
- package/dist/src/commands/tasks/task-status.js +7 -0
- package/dist/src/commands/tasks/task.js +7 -0
- package/dist/src/commands/tasks/tasks.js +7 -0
- package/dist/src/commands/team/invite.js +7 -0
- package/dist/src/commands/team/myteam.js +7 -0
- package/dist/src/commands/team/teammates.js +7 -0
- package/dist/src/commands/terminal/share.js +7 -0
- package/dist/src/core/api-client.js +7 -0
- package/dist/src/core/crypto/e2ee-vault.js +7 -0
- package/dist/src/core/dep-store.js +7 -0
- package/dist/src/core/dependency-tracker.js +7 -0
- package/dist/src/core/geekload.js +7 -0
- package/dist/src/core/local-runner.js +7 -0
- package/dist/src/core/multi-lang-scanner.js +7 -0
- package/dist/src/core/notification-window.js +8 -0
- package/dist/src/core/notify-auth.js +7 -0
- package/dist/src/core/project-config.js +7 -0
- package/dist/src/core/sandbox/arch-shim.js +7 -0
- package/dist/src/core/sandbox/capsule-builder.js +7 -0
- package/dist/src/core/sandbox/cgroups.js +7 -0
- package/dist/src/core/sandbox/container-monitor.js +7 -0
- package/dist/src/core/sandbox/crun-manager.js +7 -0
- package/dist/src/core/sandbox/engine.js +7 -0
- package/dist/src/core/sandbox/image-manager.js +7 -0
- package/dist/src/core/sandbox/image-store.js +7 -0
- package/dist/src/core/sandbox/index.js +7 -0
- package/dist/src/core/sandbox/macos-sandbox.js +7 -0
- package/dist/src/core/sandbox/microvm-manager.js +7 -0
- package/dist/src/core/sandbox/native-service-manager.js +7 -0
- package/dist/src/core/sandbox/network.js +7 -0
- package/dist/src/core/sandbox/oci-exporter.js +7 -0
- package/dist/src/core/sandbox/oci-puller.js +7 -0
- package/dist/src/core/sandbox/oci-runtime-spec.js +7 -0
- package/dist/src/core/sandbox/policy-engine.js +7 -0
- package/dist/src/core/sandbox/port-proxy-daemon.js +7 -0
- package/dist/src/core/sandbox/room-sync-manager.js +7 -0
- package/dist/src/core/sandbox/runtime-manager.js +7 -0
- package/dist/src/core/sandbox/snapshot-manager.js +7 -0
- package/dist/src/core/sandbox/storage.js +7 -0
- package/dist/src/core/sandbox/supervisor.js +7 -0
- package/dist/src/core/sandbox/tunnel-daemon.js +7 -0
- package/dist/src/core/sandbox/tunnel.js +7 -0
- package/dist/src/core/sandbox/window-launcher.js +7 -0
- package/dist/src/core/sandbox/windows-wsl2.js +7 -0
- package/dist/src/core/sandbox-window.js +8 -0
- package/dist/src/core/shell.js +7 -0
- package/dist/src/core/websocket.js +7 -0
- package/dist/src/dock/api/routes.js +7 -0
- package/dist/src/dock/api/server.js +7 -0
- package/dist/src/dock/api/wire.js +7 -0
- package/dist/src/dock/bench/memory.js +7 -0
- package/dist/src/dock/bench/runner.js +7 -0
- package/dist/src/dock/build/builder.js +7 -0
- package/dist/src/dock/build/buildfile.js +7 -0
- package/dist/src/dock/build/buildkit.js +7 -0
- package/dist/src/dock/build/changes.js +7 -0
- package/dist/src/dock/ci/actions.js +7 -0
- package/dist/src/dock/ci/runner.js +7 -0
- package/dist/src/dock/ci/workflow.js +7 -0
- package/dist/src/dock/cli/api.js +7 -0
- package/dist/src/dock/cli/args.js +7 -0
- package/dist/src/dock/cli/commands.js +7 -0
- package/dist/src/dock/cli/compose.js +7 -0
- package/dist/src/dock/cli/context.js +7 -0
- package/dist/src/dock/cli/files.js +7 -0
- package/dist/src/dock/cli/format.js +7 -0
- package/dist/src/dock/cli/manage.js +7 -0
- package/dist/src/dock/cli/moved.js +7 -0
- package/dist/src/dock/cli/services.js +7 -0
- package/dist/src/dock/cli/session.js +7 -0
- package/dist/src/dock/cli/workspace.js +7 -0
- package/dist/src/dock/client.js +7 -0
- package/dist/src/dock/compat/cases.js +7 -0
- package/dist/src/dock/compat/runner.js +7 -0
- package/dist/src/dock/config.js +7 -0
- package/dist/src/dock/daemon-main.js +7 -0
- package/dist/src/dock/daemon.js +7 -0
- package/dist/src/dock/deploy/compose.js +7 -0
- package/dist/src/dock/engine.js +7 -0
- package/dist/src/dock/image/archive.js +7 -0
- package/dist/src/dock/image/auth.js +7 -0
- package/dist/src/dock/image/reference.js +7 -0
- package/dist/src/dock/image/registry.js +7 -0
- package/dist/src/dock/image/tar.js +7 -0
- package/dist/src/dock/index.js +7 -0
- package/dist/src/dock/linux/host.js +7 -0
- package/dist/src/dock/paths.js +7 -0
- package/dist/src/dock/runtime/emulation.js +7 -0
- package/dist/src/dock/runtime/fsevents.js +7 -0
- package/dist/src/dock/runtime/fsops.js +7 -0
- package/dist/src/dock/runtime/hostfwd.js +7 -0
- package/dist/src/dock/runtime/logs.js +7 -0
- package/dist/src/dock/runtime/network.js +7 -0
- package/dist/src/dock/runtime/ports.js +7 -0
- package/dist/src/dock/runtime/rootfs.js +7 -0
- package/dist/src/dock/runtime/seccomp-profile.LICENSE +202 -0
- package/dist/src/dock/runtime/seccomp-profile.json +1227 -0
- package/dist/src/dock/runtime/seccomp.js +7 -0
- package/dist/src/dock/runtime/spec.js +7 -0
- package/dist/src/dock/runtime/stats.js +7 -0
- package/dist/src/dock/runtime/volumes.js +7 -0
- package/dist/src/dock/selftest.js +7 -0
- package/dist/src/dock/setup/app.js +7 -0
- package/dist/src/dock/setup/autostart.js +7 -0
- package/dist/src/dock/setup/index.js +7 -0
- package/dist/src/dock/setup/integrate.js +7 -0
- package/dist/src/dock/setup/migrate.js +7 -0
- package/dist/src/dock/state/store.js +7 -0
- package/dist/src/dock/ui/page.js +385 -0
- package/dist/src/dock/ui/server.js +7 -0
- package/dist/src/dock/version.js +7 -0
- package/dist/src/dock/workspace/apps.js +7 -0
- package/dist/src/dock/workspace/workspace.js +7 -0
- package/dist/src/events/notifications.js +7 -0
- package/dist/src/utils/logger.js +7 -0
- package/dist/src/utils/terminalCrypto.js +7 -0
- package/package.json +41 -16
- package/bin/thinknsh.js +0 -71
- package/src/commands/auth/login.js +0 -84
- package/src/commands/auth/logout.js +0 -32
- package/src/commands/auth/register.js +0 -52
- package/src/commands/auth/whoami.js +0 -52
- package/src/commands/github/commits.js +0 -58
- package/src/commands/github/issue-create.js +0 -59
- package/src/commands/github/issues.js +0 -57
- package/src/commands/github/pulls.js +0 -58
- package/src/commands/github/statusgh.js +0 -50
- package/src/commands/index.js +0 -136
- package/src/commands/message/say.js +0 -49
- package/src/commands/room/join.js +0 -142
- package/src/commands/room/leave.js +0 -24
- package/src/commands/room/rooms.js +0 -66
- package/src/commands/shell/notify.js +0 -88
- package/src/commands/shell/status.js +0 -73
- package/src/commands/shell/version.js +0 -18
- package/src/commands/tasks/build.js +0 -190
- package/src/commands/tasks/complete.js +0 -940
- package/src/commands/tasks/create-task.js +0 -101
- package/src/commands/tasks/loadtest.js +0 -101
- package/src/commands/tasks/suggestTask.js +0 -0
- package/src/commands/tasks/task-status.js +0 -72
- package/src/commands/tasks/task.js +0 -182
- package/src/commands/tasks/tasks.js +0 -184
- package/src/commands/team/invite.js +0 -46
- package/src/commands/team/myteam.js +0 -78
- package/src/commands/team/teammates.js +0 -52
- package/src/commands/terminal/share.js +0 -261
- package/src/core/api-client.js +0 -246
- package/src/core/geekload.js +0 -524
- package/src/core/local-runner.js +0 -861
- package/src/core/notification-window.js +0 -165
- package/src/core/project-config.js +0 -100
- package/src/core/shell.js +0 -734
- package/src/core/websocket.js +0 -482
- package/src/events/notifications.js +0 -184
- package/src/utils/logger.js +0 -159
- package/src/utils/terminalCrypto.js +0 -47
package/src/commands/index.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
src/commands/index.js — Command Registry
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
class CommandRegistry {
|
|
7
|
-
constructor(shell) {
|
|
8
|
-
this.shell = shell;
|
|
9
|
-
this.commands = new Map();
|
|
10
|
-
this.aliases = new Map();
|
|
11
|
-
this.categories = new Map();
|
|
12
|
-
this.loadCommands();
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
loadCommands() {
|
|
16
|
-
const load = (path, category) => {
|
|
17
|
-
try {
|
|
18
|
-
const cmd = require(path);
|
|
19
|
-
if (!cmd || !cmd.name) {
|
|
20
|
-
console.error(chalk.red(`❌ BAD COMMAND (no name): ${path}`));
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
this.register(cmd, category);
|
|
24
|
-
}
|
|
25
|
-
catch (e) { console.error(chalk.red(`❌ Failed to load ${path}: ${e.message}`)); }
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Auth
|
|
29
|
-
load('./auth/login', 'auth');
|
|
30
|
-
load('./auth/logout', 'auth');
|
|
31
|
-
load('./auth/whoami', 'auth');
|
|
32
|
-
load('./auth/register', 'auth');
|
|
33
|
-
|
|
34
|
-
// Team
|
|
35
|
-
load('./team/myteam', 'team');
|
|
36
|
-
load('./team/teammates', 'team');
|
|
37
|
-
load('./team/invite', 'team');
|
|
38
|
-
|
|
39
|
-
// Room
|
|
40
|
-
load('./room/join', 'room');
|
|
41
|
-
load('./room/leave', 'room');
|
|
42
|
-
load('./room/rooms', 'room');
|
|
43
|
-
|
|
44
|
-
// Message
|
|
45
|
-
load('./message/say', 'message');
|
|
46
|
-
|
|
47
|
-
// Shell
|
|
48
|
-
load('./shell/status', 'shell');
|
|
49
|
-
load('./shell/notify', 'shell');
|
|
50
|
-
load('./shell/version', 'shell');
|
|
51
|
-
|
|
52
|
-
// Tasks
|
|
53
|
-
load('./tasks/tasks', 'tasks');
|
|
54
|
-
load('./tasks/task', 'tasks');
|
|
55
|
-
load('./tasks/task-status', 'tasks');
|
|
56
|
-
// load('./tasks/start', 'tasks');
|
|
57
|
-
load('./tasks/complete', 'tasks');
|
|
58
|
-
// load('./tasks/comment', 'tasks');
|
|
59
|
-
load('./tasks/create-task', 'tasks');
|
|
60
|
-
load('./tasks/loadtest', 'tasks');
|
|
61
|
-
load('./tasks/build', 'tasks');
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// Terminal
|
|
65
|
-
load('./terminal/share', 'terminal');
|
|
66
|
-
|
|
67
|
-
// GitHub
|
|
68
|
-
load('./github/statusgh', 'github');
|
|
69
|
-
load('./github/issues', 'github');
|
|
70
|
-
load('./github/pulls', 'github');
|
|
71
|
-
load('./github/commits', 'github');
|
|
72
|
-
load('./github/issue-create', 'github');
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
register(command, category) {
|
|
77
|
-
if (!command || !command.name) {
|
|
78
|
-
console.error(chalk.yellow(`⚠️ Skipping invalid command in category: ${category}`));
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
this.commands.set(command.name, command);
|
|
82
|
-
if (!this.categories.has(category)) this.categories.set(category, []);
|
|
83
|
-
this.categories.get(category).push(command.name);
|
|
84
|
-
if (command.aliases) command.aliases.forEach(a => this.aliases.set(a, command.name));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
addAlias(alias, command) { this.aliases.set(alias, command); }
|
|
88
|
-
|
|
89
|
-
getCommand(name) {
|
|
90
|
-
if (this.aliases.has(name)) name = this.aliases.get(name);
|
|
91
|
-
return this.commands.get(name);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async execute(input, shell) {
|
|
95
|
-
const args = shell.parseCommand(input);
|
|
96
|
-
const cmdName = args[0].toLowerCase();
|
|
97
|
-
const cmdArgs = args.slice(1);
|
|
98
|
-
const command = this.getCommand(cmdName);
|
|
99
|
-
if (!command) return false;
|
|
100
|
-
|
|
101
|
-
try {
|
|
102
|
-
if (command.requiresAuth && !shell.api?.isAuthenticated()) {
|
|
103
|
-
console.log(chalk.red('❌ Please login first: login'));
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
if (command.requiresRoom && !shell.ws?.getCurrentRoom()) {
|
|
107
|
-
console.log(chalk.red('❌ Please join a room first: join <room-id>'));
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
shell._lastCommand = cmdName; // ← backward compat
|
|
112
|
-
await command.execute(cmdArgs, shell, cmdName); // ← invokedAs as 3rd arg
|
|
113
|
-
} catch (error) {
|
|
114
|
-
console.log(chalk.red(`❌ Command error: ${error.message}`));
|
|
115
|
-
}
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
getHelpText() {
|
|
120
|
-
let help = chalk.cyan('\n📚 Available Commands:\n');
|
|
121
|
-
help += chalk.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n');
|
|
122
|
-
for (const [category, commands] of this.categories) {
|
|
123
|
-
help += chalk.yellow(`${category.toUpperCase()}:\n`);
|
|
124
|
-
commands.forEach(cmdName => {
|
|
125
|
-
const cmd = this.commands.get(cmdName);
|
|
126
|
-
if (!cmd || !cmdName) return; // ← ye line add karo
|
|
127
|
-
const aliases = cmd.aliases ? chalk.dim(` (${cmd.aliases.join(', ')})`) : '';
|
|
128
|
-
help += ` ${chalk.green(cmdName.padEnd(14))}${aliases} - ${cmd.description || ''}\n`;
|
|
129
|
-
});
|
|
130
|
-
help += '\n';
|
|
131
|
-
}
|
|
132
|
-
return help;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
module.exports = CommandRegistry;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Say Command
|
|
3
|
-
Usage: say <message>
|
|
4
|
-
*/
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
name: 'say',
|
|
9
|
-
description: 'Send a message to the current room',
|
|
10
|
-
aliases: ['msg', 'm', 'send'],
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
requiresRoom: true,
|
|
13
|
-
|
|
14
|
-
async execute(args, shell) {
|
|
15
|
-
const message = args.join(' ').trim();
|
|
16
|
-
if (!message) {
|
|
17
|
-
console.log(chalk.red('❌ Usage: say <message>'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const room = shell.ws.getCurrentRoom?.();
|
|
22
|
-
if (!room) {
|
|
23
|
-
console.log(chalk.red('❌ Not in any room. Use: join <room-id>'));
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
// Stop typing indicator if active
|
|
29
|
-
if (shell.isTyping) {
|
|
30
|
-
shell.ws.socket?.emit('thinknsh:typing', { roomId: room, typing: false });
|
|
31
|
-
shell.isTyping = false;
|
|
32
|
-
clearTimeout(shell.typingTimeout);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
await shell.ws.sendMessage(message);
|
|
36
|
-
|
|
37
|
-
const user = shell.api.getUser();
|
|
38
|
-
const time = new Date().toLocaleTimeString();
|
|
39
|
-
console.log(
|
|
40
|
-
chalk.dim(`[${time}] `) +
|
|
41
|
-
chalk.green(`${user?.name || 'You'}: `) +
|
|
42
|
-
chalk.white(message)
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log(chalk.red(`❌ Failed to send: ${error.message}`));
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
Join Command
|
|
3
|
-
|
|
4
|
-
Usage: join <room-id> [password]
|
|
5
|
-
|
|
6
|
-
Flow:
|
|
7
|
-
1. REST call → shell.api.joinRoom() — validates membership + fetches room info
|
|
8
|
-
2. WebSocket → thinknsh:join — registers socket in the room on the server
|
|
9
|
-
3. Wait for → thinknsh:joined — server confirms + sends message history
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const chalk = require('chalk');
|
|
13
|
-
|
|
14
|
-
// How long to wait for thinknsh:joined after emitting thinknsh:join (ms)
|
|
15
|
-
const JOIN_TIMEOUT_MS = 8000;
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
name: 'join',
|
|
19
|
-
description: 'Join a collaboration room',
|
|
20
|
-
aliases: ['enter', 'goto'],
|
|
21
|
-
requiresAuth: true,
|
|
22
|
-
|
|
23
|
-
async execute(args, shell) {
|
|
24
|
-
if (args.length === 0) {
|
|
25
|
-
console.log(chalk.red('❌ Usage: join <room-id> [password]'));
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const roomId = args[0];
|
|
30
|
-
const password = args[1];
|
|
31
|
-
|
|
32
|
-
// ── Step 1: auto-connect WebSocket if needed ──────────────────────
|
|
33
|
-
if (!shell.ws.isConnected()) {
|
|
34
|
-
console.log(chalk.dim(' Connecting...'));
|
|
35
|
-
try {
|
|
36
|
-
await shell.ws.connect();
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.log(chalk.red(`❌ WebSocket connect failed: ${err.message}`));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log(chalk.cyan(`🔗 Joining room ${chalk.bold(roomId)}...`));
|
|
44
|
-
|
|
45
|
-
// ── Step 2: REST call — validates membership, returns room meta ───
|
|
46
|
-
let result;
|
|
47
|
-
try {
|
|
48
|
-
result = await shell.api.joinRoom(roomId, password);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
if (error.message?.toLowerCase().includes('password')) {
|
|
51
|
-
console.log(chalk.red(`❌ Room requires a password: join ${roomId} <password>`));
|
|
52
|
-
} else if (error.message?.toLowerCase().includes('not found')) {
|
|
53
|
-
console.log(chalk.red(`❌ Room not found: ${roomId}`));
|
|
54
|
-
console.log(chalk.dim(' Type "rooms" to see available rooms'));
|
|
55
|
-
} else if (error.message?.toLowerCase().includes('not a member') ||
|
|
56
|
-
error.message?.toLowerCase().includes('unauthorized')) {
|
|
57
|
-
console.log(chalk.red(`❌ You are not a member of this room`));
|
|
58
|
-
} else {
|
|
59
|
-
console.log(chalk.red(`❌ Failed to join: ${error.message}`));
|
|
60
|
-
}
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const room = result.room || result;
|
|
65
|
-
const user = shell.api.getUser?.() || {};
|
|
66
|
-
|
|
67
|
-
// ── Step 3: emit thinknsh:join and wait for thinknsh:joined ──────
|
|
68
|
-
await new Promise((resolve) => {
|
|
69
|
-
const timer = setTimeout(() => {
|
|
70
|
-
shell.ws.socket?.off('thinknsh:joined', onJoined);
|
|
71
|
-
shell.ws.socket?.off('thinknsh:error', onError);
|
|
72
|
-
console.log(chalk.red('❌ Join timeout — server did not confirm. Try again.'));
|
|
73
|
-
resolve();
|
|
74
|
-
}, JOIN_TIMEOUT_MS);
|
|
75
|
-
|
|
76
|
-
function onJoined(data) {
|
|
77
|
-
clearTimeout(timer);
|
|
78
|
-
shell.ws.socket?.off('thinknsh:error', onError);
|
|
79
|
-
|
|
80
|
-
if (!data.success) {
|
|
81
|
-
console.log(chalk.red(`❌ Join rejected: ${data.message || 'unknown error'}`));
|
|
82
|
-
resolve();
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// ── Success output ────────────────────────────────────────
|
|
87
|
-
console.log(chalk.green(`✅ Joined ${chalk.bold(room.name || roomId)}`));
|
|
88
|
-
|
|
89
|
-
if (room.description)
|
|
90
|
-
console.log(chalk.dim(` 📝 ${room.description}`));
|
|
91
|
-
|
|
92
|
-
const participants = result.participants || [];
|
|
93
|
-
if (participants.length)
|
|
94
|
-
console.log(chalk.dim(` 👥 ${participants.length} participant(s)`));
|
|
95
|
-
|
|
96
|
-
// Recent message history from thinknsh:joined payload
|
|
97
|
-
const history = data.history || [];
|
|
98
|
-
if (history.length) {
|
|
99
|
-
console.log(chalk.cyan('\n📜 Recent messages:'));
|
|
100
|
-
history.slice(-5).forEach(msg => {
|
|
101
|
-
const time = new Date(msg.timestamp).toLocaleTimeString();
|
|
102
|
-
const isYou = msg.userId === user._id?.toString() || msg.userId === user.id?.toString();
|
|
103
|
-
const who = isYou ? chalk.green('you') : chalk.cyan(msg.name || 'Unknown');
|
|
104
|
-
const src = msg.source === 'shell' ? chalk.dim('[shell]') : '';
|
|
105
|
-
console.log(` ${chalk.dim(`[${time}]`)} ${who}${src}: ${msg.message}`);
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// Online participants
|
|
110
|
-
const online = participants.filter(p => p.online);
|
|
111
|
-
if (online.length) {
|
|
112
|
-
console.log(chalk.cyan('\n👥 Online:'));
|
|
113
|
-
online.forEach(p => {
|
|
114
|
-
const isYou = p.email === user.email ? chalk.green(' (you)') : '';
|
|
115
|
-
console.log(` ${chalk.green('●')} ${p.name || p.email}${isYou}`);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
console.log(chalk.dim('\n💡 say <message> to chat | leave to exit\n'));
|
|
120
|
-
resolve();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function onError(data) {
|
|
124
|
-
clearTimeout(timer);
|
|
125
|
-
shell.ws.socket?.off('thinknsh:joined', onJoined);
|
|
126
|
-
console.log(chalk.red(`❌ ${data.message || 'Join error'}`));
|
|
127
|
-
resolve();
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
shell.ws.socket.once('thinknsh:joined', onJoined);
|
|
131
|
-
shell.ws.socket.once('thinknsh:error', onError);
|
|
132
|
-
|
|
133
|
-
// Emit the WebSocket join event
|
|
134
|
-
shell.ws.socket.emit('thinknsh:join', {
|
|
135
|
-
roomId,
|
|
136
|
-
userId: user._id?.toString() || user.id?.toString(),
|
|
137
|
-
name: user.name || user.username || 'Unknown',
|
|
138
|
-
userType: user.model || user.role || 'User',
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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.ws.getCurrentRoom();
|
|
18
|
-
if (!room) { console.log(chalk.yellow('⚠️ Not in any room')); return; }
|
|
19
|
-
console.log(chalk.cyan(`👋 Leaving room...`));
|
|
20
|
-
await shell.ws.leaveRoom();
|
|
21
|
-
console.log(chalk.green(`✅ Left room`));
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,88 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
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.ws.getUser();
|
|
18
|
-
const room = shell.ws.getCurrentRoom();
|
|
19
|
-
const connected = shell.ws.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.ws.config.wsUrl}`);
|
|
29
|
-
console.log(` ${chalk.yellow('Socket ID:')} ${shell.ws.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
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Version Command
|
|
3
|
-
|
|
4
|
-
Usage: version
|
|
5
|
-
*/
|
|
6
|
-
const chalk = require('chalk');
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
name: 'version',
|
|
10
|
-
description: 'Show shell CLI version',
|
|
11
|
-
aliases: ['v', '-v', '--version'],
|
|
12
|
-
requiresAuth: false,
|
|
13
|
-
|
|
14
|
-
async execute(args, shell) {
|
|
15
|
-
const pkg = require('../../../package.json');
|
|
16
|
-
console.log(`\n ${chalk.yellow('ThinkNCollab CLI Version:')} ${chalk.green(pkg.version)}\n`);
|
|
17
|
-
}
|
|
18
|
-
};
|