From a07241a0cb8875a2a3c60dc2b2cb37fb171b1f7b Mon Sep 17 00:00:00 2001 From: sam Date: Sat, 4 Oct 2025 22:01:51 +0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9C=20More=20light=20and=20light;=20mo?= =?UTF-8?q?re=20dark=20and=20dark=20our=20woes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/commands/ShellCommand.ts | 3 + src/lib/commands/index.ts | 1 + src/lib/commands/shakespeare.ts | 148 +++++++++++++++++++++++++++++++ src/lib/tools/ShellTool.ts | 16 ++-- 4 files changed, 162 insertions(+), 6 deletions(-) create mode 100644 src/lib/commands/shakespeare.ts diff --git a/src/lib/commands/ShellCommand.ts b/src/lib/commands/ShellCommand.ts index 52c34404..b8ec119f 100644 --- a/src/lib/commands/ShellCommand.ts +++ b/src/lib/commands/ShellCommand.ts @@ -11,6 +11,9 @@ export interface ShellCommand { /** Usage syntax for the command */ usage: string; + /** If true, this command is hidden from help and command listings (for easter eggs) */ + isEasterEgg?: boolean; + /** * Execute the command with the given arguments * @param args Array of command arguments (excluding the command name itself) diff --git a/src/lib/commands/index.ts b/src/lib/commands/index.ts index 4396089b..415c5ded 100644 --- a/src/lib/commands/index.ts +++ b/src/lib/commands/index.ts @@ -20,6 +20,7 @@ export { MvCommand } from './mv'; export { PwdCommand } from './pwd'; export { RmCommand } from './rm'; export { SedCommand } from './sed'; +export { ShakespeareCommand } from './shakespeare'; export { SortCommand } from './sort'; export { TailCommand } from './tail'; export { TouchCommand } from './touch'; diff --git a/src/lib/commands/shakespeare.ts b/src/lib/commands/shakespeare.ts new file mode 100644 index 00000000..c677c57d --- /dev/null +++ b/src/lib/commands/shakespeare.ts @@ -0,0 +1,148 @@ +import type { ShellCommand, ShellCommandResult } from "./ShellCommand"; +import { createSuccessResult } from "./ShellCommand"; + + +const ASCII_QUILLY = ` + + + @@@@@@% + @@ @@@ + @@ @@@ + @@ @@@ + @@%%% %@@@ @@@ + @@@@%@%@% @@@@ %@@@@% + @@@@@ @%% @@ @@@@@@@ + @@@@@ @@ @@@@@@% + @@@@ @%#@@ @@@@@@ + @@%@@@@@@@@ %@@@@@@% + @@% @ @@@ %@% @@ + @@ @@ %@@ @@ + @@ @@@%@@ %@@ + @@@@@%@@%@@@%# @@ + @@@@@@@%@@@@@@@@ @@ + @@ @@ @@ + @@ @@@ @@ @@ + @@ @@@ @@ @@ + @@ @@@ @@ @@ + @@ @@@ @@ @@ + @@ @@@ @@ @@ + @@ @@@ @@ @@ + @@ %@@ @@ @@ + @@ @@@ @@@ @@ + @@ @@@@@@@@% @@ + @@% %@% @@@ + @@ @@ + @@@ @@@ + @@@@@@@@@@@@% + @@% +`; + +/** + * Collection of Shakespeare poems + * Replace these placeholders with actual Shakespeare sonnets/excerpts + */ +const POEMS = [ + `From The Phoenix and the Turtle + +Here the anthem doth commence: +Love and constancy is dead; +Phoenix and the turtle fled +In a mutual flame from hence. + +So they loved, as love in twain +Had the essence but in one; +Two distincts, division none: +Number there in love was slain. + +Hearts remote, yet not asunder; +Distance, and no space was seen +'Twixt the turtle and his queen: +But in them it were a wonder. + +So between them love did shine, +That the turtle saw his right +Flaming in the phoenix' sight; +Either was the other's mine.`, + + `From Romeo and Juliet - Act III, Scene 5; Capulet’s orchard + +Juliet. Yon light is not day-light, I know it, I: +It is some meteor that the sun exhales,2110 +To be to thee this night a torch-bearer, +And light thee on thy way to Mantua: +Therefore stay yet; thou need'st not to be gone. + +Romeo. Let me be ta'en, let me be put to death; +I am content, so thou wilt have it so.2115 +I'll say yon grey is not the morning's eye, +'Tis but the pale reflex of Cynthia's brow; +Nor that is not the lark, whose notes do beat +The vaulty heaven so high above our heads: +I have more care to stay than will to go:2120 +Come, death, and welcome! Juliet wills it so. +How is't, my soul? let's talk; it is not day. + +Juliet. It is, it is: hie hence, be gone, away! +It is the lark that sings so out of tune, +Straining harsh discords and unpleasing sharps.2125 +Some say the lark makes sweet division; +This doth not so, for she divideth us: +Some say the lark and loathed toad change eyes, +O, now I would they had changed voices too! +Since arm from arm that voice doth us affray,2130 +Hunting thee hence with hunt's-up to the day, +O, now be gone; more light and light it grows. + +Romeo. More light and light; more dark and dark our woes!`, + + `From A lover's complaint + +'Now all these hearts that do on mine depend, +Feeling it break, with bleeding groans they pine; +And supplicant their sighs to you extend, +To leave the battery that you make 'gainst mine, +Lending soft audience to my sweet design,280 +And credent soul to that strong-bonded oath +That shall prefer and undertake my troth.' + +'This said, his watery eyes he did dismount, +Whose sights till then were levell'd on my face; +Each cheek a river running from a fount285 +With brinish current downward flow'd apace: +O, how the channel to the stream gave grace! +Who glazed with crystal gate the glowing roses +That flame through water which their hue encloses. + +'O father, what a hell of witchcraft lies290 +In the small orb of one particular tear! +But with the inundation of the eyes +What rocky heart to water will not wear? +What breast so cold that is not warmed here? +O cleft effect! cold modesty, hot wrath,295 +Both fire from hence and chill extincture hath.`, +]; + +/** + * Implementation of the 'shakespeare' command + * Display ASCII art and a random Shakespeare poem - an easter egg! + */ +export class ShakespeareCommand implements ShellCommand { + name = 'shakespeare'; + description = 'Display a quote from the Bard himself'; + usage = 'shakespeare'; + isEasterEgg = true; + + async execute(_args: string[], _cwd: string, _input?: string): Promise { + // Get random poem + const randomPoem = POEMS[Math.floor(Math.random() * POEMS.length)]; + + // Combine ASCII art and poem + const output = `${ASCII_QUILLY} + +${randomPoem} + +`; + + return createSuccessResult(output); + } +} diff --git a/src/lib/tools/ShellTool.ts b/src/lib/tools/ShellTool.ts index c51a3208..f51e6aca 100644 --- a/src/lib/tools/ShellTool.ts +++ b/src/lib/tools/ShellTool.ts @@ -25,6 +25,7 @@ import { PwdCommand, RmCommand, SedCommand, + ShakespeareCommand, SortCommand, TailCommand, TouchCommand, @@ -85,6 +86,7 @@ export class ShellTool implements Tool { this.registerCommand(new PwdCommand()); this.registerCommand(new RmCommand(fs)); this.registerCommand(new SedCommand(fs)); + this.registerCommand(new ShakespeareCommand()); this.registerCommand(new SortCommand(fs)); this.registerCommand(new TailCommand(fs)); this.registerCommand(new TouchCommand(fs)); @@ -493,13 +495,15 @@ export class ShellTool implements Tool { } /** - * Get list of available commands + * Get list of available commands (excludes hidden easter eggs) */ getAvailableCommands(): Array<{ name: string; description: string; usage: string }> { - return Array.from(this.commands.values()).map(cmd => ({ - name: cmd.name, - description: cmd.description, - usage: cmd.usage, - })); + return Array.from(this.commands.values()) + .filter(cmd => !cmd.isEasterEgg) // Hide easter egg commands from help + .map(cmd => ({ + name: cmd.name, + description: cmd.description, + usage: cmd.usage, + })); } } \ No newline at end of file