Add terminal commands for enhanced functionality

- Implemented 'about' command to provide information about the terminal.
- Created 'banner' command to display a welcome message based on terminal width.
- Added 'bluesky' command to fetch and display recent posts from Bluesky.
- Introduced 'clear' command to clear the terminal screen.
- Developed 'color' command to change the terminal's color scheme.
- Added 'contact' command to display contact information.
- Implemented 'date' command to show the current date and time.
- Created 'echo' command to echo back user messages.
- Added 'github' command to simulate opening the GitHub repository.
- Implemented 'help' command to list available commands.
- Developed 'history' command to show command history.
- Added 'privacy' command to display the privacy policy.
- Implemented 'whoami' command to show user information.
This commit is contained in:
2026-03-07 06:22:10 +11:00
parent bf283e8425
commit 288b48ddab
18 changed files with 501 additions and 274 deletions

View File

@@ -0,0 +1,25 @@
/**
* About command - Information about this terminal
*/
export default {
description: 'About this terminal',
execute: (term, writeClickable, VERSION) => {
return [
'',
'╔════════════════════════════════════════════════════════════╗',
'║ LIT.RUV.WTF TERMINAL ║',
'╚════════════════════════════════════════════════════════════╝',
'',
' A classic terminal interface built with xterm.js',
' Features: Keyboard navigation, Mouse support, CRT effects',
' Version: ' + VERSION,
' Built: ' + new Date().getFullYear(),
'',
' Technologies:',
' • xterm.js - Terminal emulator',
' • JavaScript - Terminal logic',
' • CSS3 - Classic CRT styling',
''
].join('\r\n');
}
};

View File

@@ -0,0 +1,24 @@
/**
* Banner command - Display welcome banner
*/
export default {
description: 'Display welcome banner',
execute: (term, writeClickable, VERSION, args, commandHistory, welcomeBannerFull, welcomeBannerCompact, welcomeBannerMinimal) => {
const cols = term.cols;
if (cols >= 78) {
term.writeln(welcomeBannerFull.split('\r\n').slice(0, -3).join('\r\n'));
writeClickable(' Type [command=help] for available commands.');
term.writeln(' Use ↑/↓ arrows to navigate command history.');
term.writeln('');
} else if (cols >= 40) {
term.writeln(welcomeBannerCompact.split('\r\n').slice(0, -2).join('\r\n'));
writeClickable(' Welcome! Type [command=help] for commands.');
term.writeln('');
} else {
term.writeln(welcomeBannerMinimal.split('\r\n').slice(0, -2).join('\r\n'));
writeClickable(' Type [command=help]');
term.writeln('');
}
return null;
}
};

View File

@@ -0,0 +1,79 @@
/**
* Bluesky command - Fetch recent posts from Bluesky
*/
export default {
description: 'Fetch recent posts from Bluesky',
execute: async (term, writeClickable, VERSION, args) => {
const actor = 'lit.mates.dev';
const limit = args[0] ? parseInt(args[0]) : 5;
try {
term.writeln('\r\n Fetching posts from Bluesky...\r\n');
const response = await fetch(
`https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=${actor}&limit=${limit}`
);
if (!response.ok) {
return ' Error: Unable to fetch Bluesky posts';
}
const data = await response.json();
if (!data.feed || data.feed.length === 0) {
return ' No posts found.';
}
let output = [' ╔════════════════════════════════════════════════════╗'];
output.push(' ║ BLUESKY POSTS - @lit.mates.dev ║');
output.push(' ╚════════════════════════════════════════════════════╝');
output.push('');
// Reverse to show oldest first, latest at bottom
const reversedFeed = [...data.feed].reverse();
reversedFeed.forEach((item, idx) => {
const post = item.post;
const text = post.record.text;
const createdAt = new Date(post.record.createdAt);
const date = createdAt.toLocaleDateString();
const time = createdAt.toLocaleTimeString('en-US', {
hour: '2-digit',
minute: '2-digit'
});
// Extract post ID from URI (at://did:plc:xxx/app.bsky.feed.post/{postId})
const postId = post.uri.split('/').pop();
const postUrl = `https://bsky.app/profile/${actor}/post/${postId}`;
output.push(` [${idx + 1}] ${date} ${time}`);
output.push(` ${postUrl}`);
output.push(' ────────────────────────────────────────');
// Wrap text to max 50 chars
const words = text.split(' ');
let line = ' ';
words.forEach(word => {
if (line.length + word.length + 1 > 52) {
output.push(line);
line = ' ' + word;
} else {
line += (line.length > 2 ? ' ' : '') + word;
}
});
if (line.length > 2) output.push(line);
output.push('');
output.push(`${post.likeCount || 0}${post.repostCount || 0} 💬 ${post.replyCount || 0}`);
output.push('');
});
output.push(` Usage: bluesky [count] (default: 5, max: 20)`);
output.push('');
return output.join('\r\n');
} catch (error) {
return ' Error: Failed to connect to Bluesky API';
}
}
};

View File

@@ -0,0 +1,10 @@
/**
* Clear command - Clear terminal screen
*/
export default {
description: 'Clear terminal screen',
execute: (term) => {
term.clear();
return null;
}
};

View File

@@ -0,0 +1,38 @@
/**
* Color command - Change color scheme
*/
export default {
description: 'Change color scheme',
execute: (term, writeClickable, VERSION, args) => {
const scheme = args[0] || '';
const schemes = {
green: { bg: '#001800', fg: '#00ff00', border: '#0f0' },
amber: { bg: '#1a0f00', fg: '#ffb000', border: '#ffb000' },
blue: { bg: '#000818', fg: '#00a0ff', border: '#00a0ff' },
white: { bg: '#0a0a0a', fg: '#e0e0e0', border: '#999' }
};
if (!scheme || !schemes[scheme]) {
return [
'',
' Available color schemes:',
' • green - Classic green terminal',
' • amber - Amber monochrome',
' • blue - IBM blue',
' • white - White phosphor',
'',
' Usage: color [scheme]',
''
].join('\r\n');
}
const colors = schemes[scheme];
term.options.theme.background = colors.bg;
term.options.theme.foreground = colors.fg;
document.querySelector('.container').style.borderColor = colors.border;
document.querySelector('.container').style.background = colors.bg;
document.body.style.color = colors.fg;
return `\r\n Color scheme changed to: ${scheme}\r\n`;
}
};

View File

@@ -0,0 +1,16 @@
/**
* Contact command - Contact information
*/
export default {
description: 'Contact information',
execute: () => {
return [
'',
' Contact Information:',
' ────────────────────',
' Email: contact@lit.ruv.wtf',
' Web: https://lit.ruv.wtf',
''
].join('\r\n');
}
};

View File

@@ -0,0 +1,20 @@
/**
* Date command - Display current date and time
*/
export default {
description: 'Display current date and time',
execute: () => {
const now = new Date();
return [
'',
' ' + now.toLocaleDateString('en-US', {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric'
}),
' ' + now.toLocaleTimeString('en-US'),
''
].join('\r\n');
}
};

View File

@@ -0,0 +1,9 @@
/**
* Echo command - Echo back message
*/
export default {
description: 'Echo back message',
execute: (term, writeClickable, VERSION, args) => {
return args.join(' ') || '';
}
};

View File

@@ -0,0 +1,9 @@
/**
* GitHub command - Open GitHub repository
*/
export default {
description: 'Open GitHub repository',
execute: () => {
return '\r\n Opening GitHub...\r\n (This would open your repository URL)\r\n';
}
};

View File

@@ -0,0 +1,32 @@
/**
* Help command - Display available commands
*/
export default {
description: 'Display available commands',
execute: (term, writeClickable) => {
term.writeln('');
term.writeln('╔════════════════════════════════════════════════════════════╗');
term.writeln('║ AVAILABLE COMMANDS ║');
term.writeln('╚════════════════════════════════════════════════════════════╝');
term.writeln('');
writeClickable(' [command=help] - Display this help message');
writeClickable(' [command=about] - Information about this terminal');
writeClickable(' [command=clear] - Clear the terminal screen');
term.writeln(' echo - Echo back your message (usage: echo [message])');
writeClickable(' [command=date] - Display current date and time');
writeClickable(' [command=whoami] - Display current user information');
writeClickable(' [command=history] - Show command history');
writeClickable(' [command=color] - Change terminal color scheme');
writeClickable(' [command=banner] - Display welcome banner');
writeClickable(' [command=bluesky] - Fetch recent posts from Bluesky');
writeClickable(' [command=chat] - Enter interactive chat (type /quit to exit)');
writeClickable(' [command=github] - Visit GitHub repository');
writeClickable(' [command=contact] - Display contact information');
writeClickable(' [command=privacy] - Display privacy policy');
term.writeln('');
term.writeln('Navigate: Use ↑/↓ arrows for command history');
term.writeln('Mouse: Click commands to run them');
term.writeln('');
return null;
}
};

View File

@@ -0,0 +1,17 @@
/**
* History command - Show command history
*/
export default {
description: 'Show command history',
execute: (term, writeClickable, VERSION, args, commandHistory) => {
if (commandHistory.length === 0) {
return '\r\n No command history yet.\r\n';
}
let output = ['\r\n Command History:', ' ───────────────'];
commandHistory.forEach((cmd, idx) => {
output.push(` ${(idx + 1).toString().padStart(3, ' ')} ${cmd}`);
});
output.push('');
return output.join('\r\n');
}
};

View File

@@ -0,0 +1,36 @@
/**
* Privacy command - Privacy policy
*/
export default {
description: 'Privacy policy',
execute: () => {
return [
'',
'╔════════════════════════════════════════════════════════════╗',
'║ PRIVACY POLICY ║',
'╚════════════════════════════════════════════════════════════╝',
'',
' Data Collection:',
' ────────────────',
' • This terminal uses localStorage to save your chat session',
' • Chat messages are stored on our Matrix homeserver',
' • No cookies or tracking scripts are used',
' • No analytics or third-party tracking',
'',
' Matrix Chat:',
' ────────────',
' • Chat credentials stored locally in your browser',
' • Messages sent through Matrix protocol (b.ruv.wtf)',
' • Use "chat disconnect" to clear stored credentials',
'',
' Your Rights:',
' ────────────',
' • Clear localStorage anytime via browser settings',
' • Request data deletion: contact@lit.ruv.wtf',
' • All code is open source and auditable',
'',
' Updates: Privacy policy last updated March 2026',
''
].join('\r\n');
}
};

View File

@@ -0,0 +1,15 @@
/**
* Whoami command - Display user information
*/
export default {
description: 'Display user information',
execute: () => {
return [
'',
' User: visitor@lit.ruv.wtf',
' Session: ' + Date.now(),
' Terminal: xterm.js',
''
].join('\r\n');
}
};