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/bin/thinknsh.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
ThinkNCollab Shell - CLI Entry Point
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Usage:
|
|
9
|
-
thinknsh - Start interactive shell
|
|
10
|
-
thinknsh <command> - Run single command
|
|
11
|
-
thinknsh --help - Show help
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const path = require('path');
|
|
15
|
-
const chalk = require('chalk');
|
|
16
|
-
const ThinkNCollabShell = require('../src/core/shell');
|
|
17
|
-
|
|
18
|
-
// Parse arguments
|
|
19
|
-
const args = process.argv.slice(2);
|
|
20
|
-
|
|
21
|
-
// Show help
|
|
22
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
23
|
-
console.log(`
|
|
24
|
-
${chalk.cyan('ThinkNCollab Shell - CLI')}
|
|
25
|
-
|
|
26
|
-
${chalk.yellow('Usage:')}
|
|
27
|
-
thinknsh Start interactive shell
|
|
28
|
-
thinknsh <command> Run single command
|
|
29
|
-
thinknsh --help Show this help
|
|
30
|
-
thinknsh --version Show version
|
|
31
|
-
|
|
32
|
-
${chalk.yellow('Examples:')}
|
|
33
|
-
thinknsh
|
|
34
|
-
thinknsh join room-123
|
|
35
|
-
thinknsh status
|
|
36
|
-
thinknsh help
|
|
37
|
-
|
|
38
|
-
${chalk.dim('For more commands, type "help" in the interactive shell')}
|
|
39
|
-
`);
|
|
40
|
-
process.exit(0);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Show version
|
|
44
|
-
if (args.includes('--version') || args.includes('-v')) {
|
|
45
|
-
const pkg = require('../package.json');
|
|
46
|
-
console.log(pkg.version);
|
|
47
|
-
process.exit(0);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const shell = new ThinkNCollabShell({
|
|
51
|
-
serverUrl: process.env.THINKNCOLLAB_SERVER || 'https://thinkncollab.com',
|
|
52
|
-
apiUrl: process.env.THINKNCOLLAB_API_URL || 'https://thinkncollab.com',
|
|
53
|
-
wsUrl: process.env.THINKNCOLLAB_WS_URL || 'https://thinkncollab.com',
|
|
54
|
-
autoConnect: process.env.THINKNCOLLAB_AUTO_CONNECT === 'true'
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
// If arguments provided, execute command and exit
|
|
58
|
-
if (args.length > 0) {
|
|
59
|
-
shell.execute(args.join(' ')).then(() => {
|
|
60
|
-
process.exit(0);
|
|
61
|
-
}).catch((error) => {
|
|
62
|
-
console.error(chalk.red(`Error: ${error.message}`));
|
|
63
|
-
process.exit(1);
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
// Start interactive shell
|
|
67
|
-
shell.start().catch((error) => {
|
|
68
|
-
console.error(chalk.red(`Fatal error: ${error.message}`));
|
|
69
|
-
process.exit(1);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
commands/auth/login.js
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
name: 'login',
|
|
9
|
-
description: 'Login to ThinkNCollab',
|
|
10
|
-
aliases: ['signin'],
|
|
11
|
-
requiresAuth: false,
|
|
12
|
-
|
|
13
|
-
async execute(args, shell) {
|
|
14
|
-
// Already logged in?
|
|
15
|
-
if (shell.api.isAuthenticated()) {
|
|
16
|
-
const u = shell.api.getUser();
|
|
17
|
-
console.log(chalk.green(`ā
Already logged in as ${u.name} (${u.email})`));
|
|
18
|
-
console.log(chalk.dim(' Run "logout" first to switch accounts.'));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// Collect credentials
|
|
23
|
-
let email = args[0];
|
|
24
|
-
let password = args[1];
|
|
25
|
-
|
|
26
|
-
if (!email || !password) {
|
|
27
|
-
const { input, password: passwordPrompt } = require('@inquirer/prompts');
|
|
28
|
-
if (!email) {
|
|
29
|
-
email = await input({
|
|
30
|
-
message: 'Email:',
|
|
31
|
-
validate: v => v.includes('@') || 'Enter a valid email'
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
if (!password) {
|
|
35
|
-
password = await passwordPrompt({
|
|
36
|
-
message: 'Password:',
|
|
37
|
-
mask: '*',
|
|
38
|
-
validate: v => v.length >= 1 || 'Password required'
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
console.log(chalk.blue('š Logging in...'));
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
const result = await shell.api.login(email, password);
|
|
47
|
-
|
|
48
|
-
// result.user is already normalised by api-client.getUser()
|
|
49
|
-
// shape: { _id, userId, email, name, userType }
|
|
50
|
-
const user = result.user;
|
|
51
|
-
|
|
52
|
-
// ā
Tell the WebSocket manager who the user is + pass the token
|
|
53
|
-
// This must happen BEFORE any join attempt
|
|
54
|
-
shell.ws.setUser(user, result.token);
|
|
55
|
-
|
|
56
|
-
// Connect WebSocket if not already connected
|
|
57
|
-
if (!shell.ws.isConnected()) {
|
|
58
|
-
try {
|
|
59
|
-
await shell.ws.connect(result.token);
|
|
60
|
-
console.log(chalk.dim(' š Connected to ThinkNCollab server'));
|
|
61
|
-
} catch (wsErr) {
|
|
62
|
-
// Non-fatal ā user can still use REST commands
|
|
63
|
-
console.log(chalk.yellow(` ā ļø WebSocket unavailable: ${wsErr.message}`));
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
// Already connected ā re-announce with new user identity
|
|
67
|
-
shell.ws._announceUser?.();
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
console.log(chalk.green(`ā
Welcome, ${user.name}!`));
|
|
71
|
-
console.log(chalk.dim(` Logged in as ${user.email}`));
|
|
72
|
-
|
|
73
|
-
} catch (err) {
|
|
74
|
-
if (err.message.includes('401') || err.message.toLowerCase().includes('invalid') ||
|
|
75
|
-
err.message.toLowerCase().includes('unauthorized')) {
|
|
76
|
-
console.log(chalk.red('ā Invalid email or password'));
|
|
77
|
-
} else if (err.message.includes('connect') || err.message.includes('ECONNREFUSED')) {
|
|
78
|
-
console.log(chalk.red(`ā Cannot reach server ā is it running?`));
|
|
79
|
-
} else {
|
|
80
|
-
console.log(chalk.red(`ā Login failed: ${err.message}`));
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Logout Command
|
|
3
|
-
|
|
4
|
-
Usage: logout
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const chalk = require('chalk');
|
|
8
|
-
const fs = require('fs-extra');
|
|
9
|
-
|
|
10
|
-
module.exports = {
|
|
11
|
-
name: 'logout',
|
|
12
|
-
description: 'Logout from ThinkNCollab',
|
|
13
|
-
aliases: ['signout', 'exit'],
|
|
14
|
-
requiresAuth: true,
|
|
15
|
-
|
|
16
|
-
async execute(args, shell) {
|
|
17
|
-
shell.printMessage(chalk.cyan('š Logging out...'));
|
|
18
|
-
|
|
19
|
-
try {
|
|
20
|
-
await shell.api.logout();
|
|
21
|
-
|
|
22
|
-
// Remove session file
|
|
23
|
-
const sessionPath = shell.getSessionPath();
|
|
24
|
-
await fs.remove(sessionPath);
|
|
25
|
-
|
|
26
|
-
shell.printMessage(chalk.green('ā
Logged out successfully'));
|
|
27
|
-
|
|
28
|
-
} catch (error) {
|
|
29
|
-
shell.printMessage(chalk.red(`ā Logout failed: ${error.message}`));
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
src/commands/auth/register.js
|
|
3
|
-
Register new account ā opens browser with pre-auth session
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const chalk = require('chalk');
|
|
7
|
-
const { exec } = require('child_process');
|
|
8
|
-
|
|
9
|
-
module.exports = {
|
|
10
|
-
name: 'register',
|
|
11
|
-
description: 'Create a new ThinkNCollab account',
|
|
12
|
-
aliases: ['signup', 'reg'],
|
|
13
|
-
requiresAuth: false,
|
|
14
|
-
|
|
15
|
-
async execute(args, shell) {
|
|
16
|
-
try {
|
|
17
|
-
console.log(chalk.cyan('š Opening registration in browser...'));
|
|
18
|
-
|
|
19
|
-
const baseUrl = shell.api.apiUrl || 'http://localhost:3001';
|
|
20
|
-
|
|
21
|
-
// Generate a CLI source token so backend knows it came from terminal
|
|
22
|
-
const crypto = require('crypto');
|
|
23
|
-
const cliRef = crypto.randomBytes(8).toString('hex');
|
|
24
|
-
|
|
25
|
-
const url = `${baseUrl}/register?ref=cli&cliRef=${cliRef}`;
|
|
26
|
-
|
|
27
|
-
// Open browser cross-platform
|
|
28
|
-
const openCmd = process.platform === 'win32'
|
|
29
|
-
? `start "" "${url}"`
|
|
30
|
-
: process.platform === 'darwin'
|
|
31
|
-
? `open "${url}"`
|
|
32
|
-
: `xdg-open "${url}"`;
|
|
33
|
-
|
|
34
|
-
exec(openCmd, (err) => {
|
|
35
|
-
if (err) {
|
|
36
|
-
console.log(chalk.yellow('ā ļø Could not open browser automatically.'));
|
|
37
|
-
console.log(chalk.dim(' Open this URL manually:'));
|
|
38
|
-
console.log(chalk.cyan(` ${url}`));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
console.log(chalk.green(`ā
Registration page opened!`));
|
|
43
|
-
console.log(chalk.dim(` URL: ${url}`));
|
|
44
|
-
console.log('');
|
|
45
|
-
console.log(chalk.dim(' After registering, come back and run:'));
|
|
46
|
-
console.log(chalk.cyan(' login'));
|
|
47
|
-
|
|
48
|
-
} catch (err) {
|
|
49
|
-
console.log(chalk.red(`ā Error: ${err.message}`));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
name: 'whoami',
|
|
5
|
-
description: 'Show current user information',
|
|
6
|
-
aliases: ['user', 'me'],
|
|
7
|
-
requiresAuth: false,
|
|
8
|
-
|
|
9
|
-
async execute(args, shell) {
|
|
10
|
-
const user = shell.api.getUser();
|
|
11
|
-
const room = shell.ws.getCurrentRoom?.();
|
|
12
|
-
const session = shell.api.session;
|
|
13
|
-
|
|
14
|
-
// ā
Server se last session history fetch karo
|
|
15
|
-
let lastSession = null;
|
|
16
|
-
try {
|
|
17
|
-
const history = await shell.api._request('GET', '/thinknsh/session/history');
|
|
18
|
-
// Current session chhod ke last wali lo
|
|
19
|
-
const prev = history.find(s => s._id !== session?.shellSessionId);
|
|
20
|
-
if (prev) lastSession = prev;
|
|
21
|
-
} catch {}
|
|
22
|
-
|
|
23
|
-
console.log(chalk.cyan('\nš¤ User Information:'));
|
|
24
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
25
|
-
console.log(` ${chalk.yellow('Name:')} ${user.name || 'Not set'}`);
|
|
26
|
-
console.log(` ${chalk.yellow('Email:')} ${user.email}`);
|
|
27
|
-
console.log(` ${chalk.yellow('User ID:')} ${user._id || 'N/A'}`);
|
|
28
|
-
console.log(` ${chalk.yellow('Type:')} ${user.userType || 'User'}`);
|
|
29
|
-
console.log(` ${chalk.yellow('Status:')} ${shell.ws.isConnected?.() ? chalk.green('ā Online') : chalk.gray('ā Offline')}`);
|
|
30
|
-
|
|
31
|
-
if (room) {
|
|
32
|
-
console.log(` ${chalk.yellow('Room:')} ${chalk.cyan(room)}`);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (session?.timestamp) {
|
|
36
|
-
console.log(` ${chalk.yellow('Login At:')} ${chalk.dim(new Date(session.timestamp).toLocaleString())}`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ā
Server se actual logout time
|
|
40
|
-
if (lastSession?.logoutAt) {
|
|
41
|
-
console.log(` ${chalk.yellow('Last Logout:')} ${chalk.dim(new Date(lastSession.logoutAt).toLocaleString())}`);
|
|
42
|
-
} else if (lastSession?.lastSeenAt) {
|
|
43
|
-
console.log(` ${chalk.yellow('Last Seen:')} ${chalk.dim(new Date(lastSession.lastSeenAt).toLocaleString())} ${chalk.red('(crash?)')}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (lastSession?.machineId) {
|
|
47
|
-
console.log(` ${chalk.yellow('Last Machine:')} ${chalk.dim(lastSession.machineId)}`);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
console.log();
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
GitHub commits Command
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const Table = require('cli-table3');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
name: 'commits',
|
|
9
|
-
description: 'List recent GitHub commits for the linked repository',
|
|
10
|
-
aliases: ['gh-commits'],
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
requiresRoom: true,
|
|
13
|
-
|
|
14
|
-
async execute(args, shell) {
|
|
15
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
16
|
-
if (!roomId) {
|
|
17
|
-
console.log(chalk.yellow('ā ļø Please join a room first: join <room-id>'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.log(chalk.dim('\n Fetching recent commits...\r'));
|
|
22
|
-
try {
|
|
23
|
-
const commits = await shell.api._request('GET', `/thinknsh/${roomId}/github/commits`);
|
|
24
|
-
console.log(' '.repeat(30) + '\r'); // clear line
|
|
25
|
-
|
|
26
|
-
console.log(chalk.cyan(`\nš Recent Commits (Last 15):`));
|
|
27
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
28
|
-
|
|
29
|
-
if (!commits || commits.length === 0) {
|
|
30
|
-
console.log(chalk.dim(' No commits found.'));
|
|
31
|
-
console.log();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const table = new Table({
|
|
36
|
-
head: ['SHA', 'Message', 'Author', 'Date'],
|
|
37
|
-
colWidths: [10, 45, 18, 15]
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
commits.forEach(commit => {
|
|
41
|
-
const shortSha = commit.sha.slice(0, 7);
|
|
42
|
-
const shortMsg = commit.message.split('\n')[0];
|
|
43
|
-
table.push([
|
|
44
|
-
chalk.yellow(shortSha),
|
|
45
|
-
chalk.white(shortMsg.length > 40 ? shortMsg.slice(0, 37) + '...' : shortMsg),
|
|
46
|
-
commit.author || '-',
|
|
47
|
-
new Date(commit.date).toLocaleDateString()
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
console.log(table.toString());
|
|
52
|
-
console.log();
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.log(' '.repeat(30) + '\r');
|
|
55
|
-
console.log(chalk.red(`ā Failed to fetch commits: ${error.message}`));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
GitHub issue-create Command
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
name: 'issue-create',
|
|
8
|
-
description: 'Create a new GitHub issue in the linked repository',
|
|
9
|
-
aliases: ['create-issue', 'gh-issue-create', 'gh-create-issue'],
|
|
10
|
-
requiresAuth: true,
|
|
11
|
-
requiresRoom: true,
|
|
12
|
-
|
|
13
|
-
async execute(args, shell) {
|
|
14
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
15
|
-
if (!roomId) {
|
|
16
|
-
console.log(chalk.yellow('ā ļø Please join a room first: join <room-id>'));
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let title = args[0];
|
|
21
|
-
let body = args.slice(1).join(' ');
|
|
22
|
-
|
|
23
|
-
// If title/body not provided via command line, prompt interactively
|
|
24
|
-
if (!title) {
|
|
25
|
-
try {
|
|
26
|
-
const { input } = require('@inquirer/prompts');
|
|
27
|
-
title = await input({
|
|
28
|
-
message: 'Enter issue title:',
|
|
29
|
-
validate: input => input.trim() ? true : 'Title is required'
|
|
30
|
-
});
|
|
31
|
-
body = await input({
|
|
32
|
-
message: 'Enter issue description (body) (optional):'
|
|
33
|
-
});
|
|
34
|
-
} catch (err) {
|
|
35
|
-
console.log(chalk.red('ā Missing arguments. Usage: issue-create <title> <body>'));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
console.log(chalk.dim('\n Creating GitHub issue...\r'));
|
|
41
|
-
try {
|
|
42
|
-
const result = await shell.api._request('POST', `/thinknsh/${roomId}/github/issues`, {
|
|
43
|
-
title,
|
|
44
|
-
body
|
|
45
|
-
});
|
|
46
|
-
console.log(' '.repeat(30) + '\r'); // clear line
|
|
47
|
-
|
|
48
|
-
console.log(chalk.green(`\nā
GitHub issue created successfully!`));
|
|
49
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
50
|
-
console.log(` ${chalk.yellow('Issue Number:')} #${result.number}`);
|
|
51
|
-
console.log(` ${chalk.yellow('Title:')} ${result.title}`);
|
|
52
|
-
console.log(` ${chalk.yellow('URL:')} ${chalk.cyan(result.html_url)}`);
|
|
53
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.log(' '.repeat(30) + '\r');
|
|
56
|
-
console.log(chalk.red(`ā Failed to create issue: ${error.message}`));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
GitHub issues Command
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const Table = require('cli-table3');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
name: 'issues',
|
|
9
|
-
description: 'List open GitHub issues for the linked repository',
|
|
10
|
-
aliases: ['gh-issues'],
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
requiresRoom: true,
|
|
13
|
-
|
|
14
|
-
async execute(args, shell) {
|
|
15
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
16
|
-
if (!roomId) {
|
|
17
|
-
console.log(chalk.yellow('ā ļø Please join a room first: join <room-id>'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.log(chalk.dim('\n Fetching open issues...\r'));
|
|
22
|
-
try {
|
|
23
|
-
const issues = await shell.api._request('GET', `/thinknsh/${roomId}/github/issues`);
|
|
24
|
-
console.log(' '.repeat(30) + '\r'); // clear line
|
|
25
|
-
|
|
26
|
-
console.log(chalk.cyan(`\nš Open GitHub Issues:`));
|
|
27
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
28
|
-
|
|
29
|
-
if (!issues || issues.length === 0) {
|
|
30
|
-
console.log(chalk.dim(' No open issues found in the linked repository.'));
|
|
31
|
-
console.log();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const table = new Table({
|
|
36
|
-
head: ['#', 'Title', 'Author', 'Comments', 'Updated At'],
|
|
37
|
-
colWidths: [8, 45, 15, 10, 15]
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
issues.forEach(issue => {
|
|
41
|
-
table.push([
|
|
42
|
-
chalk.green(`#${issue.number}`),
|
|
43
|
-
chalk.white(issue.title.length > 40 ? issue.title.slice(0, 37) + '...' : issue.title),
|
|
44
|
-
issue.user || '-',
|
|
45
|
-
issue.comments,
|
|
46
|
-
new Date(issue.updated_at).toLocaleDateString()
|
|
47
|
-
]);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
console.log(table.toString());
|
|
51
|
-
console.log();
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.log(' '.repeat(30) + '\r');
|
|
54
|
-
console.log(chalk.red(`ā Failed to fetch issues: ${error.message}`));
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
GitHub pulls Command
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const Table = require('cli-table3');
|
|
6
|
-
|
|
7
|
-
module.exports = {
|
|
8
|
-
name: 'pulls',
|
|
9
|
-
description: 'List open GitHub pull requests for the linked repository',
|
|
10
|
-
aliases: ['prs', 'gh-pulls', 'gh-prs'],
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
requiresRoom: true,
|
|
13
|
-
|
|
14
|
-
async execute(args, shell) {
|
|
15
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
16
|
-
if (!roomId) {
|
|
17
|
-
console.log(chalk.yellow('ā ļø Please join a room first: join <room-id>'));
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.log(chalk.dim('\n Fetching open pull requests...\r'));
|
|
22
|
-
try {
|
|
23
|
-
const pulls = await shell.api._request('GET', `/thinknsh/${roomId}/github/pulls`);
|
|
24
|
-
console.log(' '.repeat(30) + '\r'); // clear line
|
|
25
|
-
|
|
26
|
-
console.log(chalk.cyan(`\nš Open GitHub Pull Requests:`));
|
|
27
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
28
|
-
|
|
29
|
-
if (!pulls || pulls.length === 0) {
|
|
30
|
-
console.log(chalk.dim(' No open pull requests found.'));
|
|
31
|
-
console.log();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const table = new Table({
|
|
36
|
-
head: ['#', 'Title', 'Author', 'Status', 'Updated At'],
|
|
37
|
-
colWidths: [8, 45, 15, 10, 15]
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
pulls.forEach(pr => {
|
|
41
|
-
const statusStr = pr.draft ? chalk.gray('Draft') : chalk.green('Open');
|
|
42
|
-
table.push([
|
|
43
|
-
chalk.green(`#${pr.number}`),
|
|
44
|
-
chalk.white(pr.title.length > 40 ? pr.title.slice(0, 37) + '...' : pr.title),
|
|
45
|
-
pr.user || '-',
|
|
46
|
-
statusStr,
|
|
47
|
-
new Date(pr.updated_at).toLocaleDateString()
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
console.log(table.toString());
|
|
52
|
-
console.log();
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.log(' '.repeat(30) + '\r');
|
|
55
|
-
console.log(chalk.red(`ā Failed to fetch pull requests: ${error.message}`));
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
GitHub statusgh Command
|
|
3
|
-
*/
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
name: 'statusgh',
|
|
8
|
-
description: 'Show GitHub connection and linked repository status',
|
|
9
|
-
aliases: ['statusgt', 'gh-status'],
|
|
10
|
-
requiresAuth: true,
|
|
11
|
-
requiresRoom: true,
|
|
12
|
-
|
|
13
|
-
async execute(args, shell) {
|
|
14
|
-
const roomId = shell.ws.getCurrentRoom();
|
|
15
|
-
if (!roomId) {
|
|
16
|
-
console.log(chalk.yellow('ā ļø Please join a room first: join <room-id>'));
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
console.log(chalk.dim('\n Fetching GitHub status...\r'));
|
|
21
|
-
try {
|
|
22
|
-
const status = await shell.api._request('GET', `/thinknsh/${roomId}/github/status`);
|
|
23
|
-
console.log(' '.repeat(30) + '\r'); // clear line
|
|
24
|
-
|
|
25
|
-
console.log(chalk.cyan(`\nš GitHub Integration Status:`));
|
|
26
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
27
|
-
|
|
28
|
-
console.log(` ${chalk.yellow('GitHub Connection:')} ${status.connected ? chalk.green('Connected ā') : chalk.red('Not Connected ā')}`);
|
|
29
|
-
if (status.githubUsername) {
|
|
30
|
-
console.log(` ${chalk.yellow('GitHub Username:')} ${status.githubUsername}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
console.log(` ${chalk.yellow('Repository Linked:')} ${status.repoLinked ? chalk.green('Linked ā') : chalk.red('Not Linked ā')}`);
|
|
34
|
-
if (status.repo) {
|
|
35
|
-
console.log(` ${chalk.yellow('Repository Name:')} ${status.repo.fullName || `${status.repo.owner}/${status.repo.name}`}`);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
console.log(chalk.dim('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā'));
|
|
39
|
-
if (!status.connected) {
|
|
40
|
-
console.log(chalk.yellow('\nš” Please connect your GitHub account via the Web Dashboard integration panel.'));
|
|
41
|
-
} else if (!status.repoLinked) {
|
|
42
|
-
console.log(chalk.yellow('\nš” Please link a GitHub repository to this room on the Web Dashboard repository setting page.'));
|
|
43
|
-
}
|
|
44
|
-
console.log();
|
|
45
|
-
} catch (error) {
|
|
46
|
-
console.log(' '.repeat(30) + '\r');
|
|
47
|
-
console.log(chalk.red(`ā Failed to fetch GitHub status: ${error.message}`));
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|