moshcode 0.39.0 → 0.41.0
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/README.md +90 -0
- package/bin/moshcode.mjs +9 -0
- package/package.json +1 -1
- package/prd/0010-cloud-settings-sync.md +132 -0
- package/prd/README.md +1 -0
- package/src/cli-schema.mjs +65 -0
- package/src/dns-system.mjs +176 -6
- package/src/dns.mjs +33 -1
- package/src/games-chess.mjs +376 -0
- package/src/games-hangman.mjs +97 -0
- package/src/games-pacman.mjs +205 -0
- package/src/games-snake.mjs +111 -0
- package/src/games-tetris.mjs +221 -0
- package/src/games-tictactoe.mjs +124 -0
- package/src/games.mjs +337 -0
- package/src/settings-sync.mjs +659 -0
- package/src/tui.mjs +18 -0
- package/src/ui.mjs +3 -1
package/src/tui.mjs
CHANGED
|
@@ -15,6 +15,7 @@ import { runUpgrade } from "./upgrade.mjs";
|
|
|
15
15
|
import { locate, tilde } from "./pwd.mjs";
|
|
16
16
|
import { createPrd, listPrds, authoringPrompt } from "./prd.mjs";
|
|
17
17
|
import { loginAuto, whoami, logout } from "./auth.mjs";
|
|
18
|
+
import { loadCommand, saveCommand } from "./settings-sync.mjs";
|
|
18
19
|
import { createMirror, teeOutput } from "./mirror.mjs";
|
|
19
20
|
import { fetchMotdAd } from "./ads.mjs";
|
|
20
21
|
import { runScript } from "./runtime.mjs";
|
|
@@ -22,6 +23,7 @@ import { moshVocabulary } from "./commands.mjs";
|
|
|
22
23
|
import { mcpCommand, pluginCommand, skillCommand } from "./integrations.mjs";
|
|
23
24
|
import { stocksCommand } from "./advisor.mjs";
|
|
24
25
|
import { cryptoCommand } from "./crypto.mjs";
|
|
26
|
+
import { gamesCommand } from "./games.mjs";
|
|
25
27
|
import { canOpenBrowser, openBrowser } from "./open-url.mjs";
|
|
26
28
|
import { banner, hr, acid, ash, bone, dim, ok, err, warn, info, moshcodeVersion } from "./ui.mjs";
|
|
27
29
|
import { CORE_CLI_COMMAND_NAMES } from "./cli-schema.mjs";
|
|
@@ -728,6 +730,10 @@ export async function tui() {
|
|
|
728
730
|
continue;
|
|
729
731
|
}
|
|
730
732
|
if (cmd === "logout") { logout(); continue; }
|
|
733
|
+
// Settings sync. Never closes readline: both are one request and some
|
|
734
|
+
// printing, and the prompt is where you were about to type `/load` again.
|
|
735
|
+
if (cmd === "save") { await saveCommand(rest, { write: (l) => console.log(` ${l}`) }); continue; }
|
|
736
|
+
if (cmd === "load") { await loadCommand(rest, { write: (l) => console.log(` ${l}`) }); continue; }
|
|
731
737
|
if (cmd === "run") {
|
|
732
738
|
await runFile(rest);
|
|
733
739
|
continue;
|
|
@@ -877,6 +883,18 @@ export async function tui() {
|
|
|
877
883
|
await pluginCommand(rest);
|
|
878
884
|
continue;
|
|
879
885
|
}
|
|
886
|
+
// The arcade (src/games.mjs). Takes the terminal the way an engine session
|
|
887
|
+
// does, because every game reads single keypresses and readline cannot hand
|
|
888
|
+
// those over while it owns stdin. Listing is just printing, so it keeps the
|
|
889
|
+
// prompt.
|
|
890
|
+
if (cmd === "games" || cmd === "game" || cmd === "arcade" || cmd === "play") {
|
|
891
|
+
const listing = !rest.length || rest[0] === "list" || rest[0] === "ls" || rest[0] === "--json";
|
|
892
|
+
if (listing) { await gamesCommand(rest, { prefix: "/games" }); continue; }
|
|
893
|
+
rl.close();
|
|
894
|
+
await gamesCommand(rest, { prefix: "/games" });
|
|
895
|
+
rl = mkrl();
|
|
896
|
+
continue;
|
|
897
|
+
}
|
|
880
898
|
if (cmd === "socials" || cmd === "social") {
|
|
881
899
|
printSocials();
|
|
882
900
|
continue;
|
package/src/ui.mjs
CHANGED
|
@@ -12,7 +12,9 @@ export function moshcodeVersion() {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
const useColor = process.env.NO_COLOR == null && process.stdout.isTTY === true;
|
|
15
|
-
|
|
15
|
+
// Exported so a module with its own hues (the arcade's seven tetrominoes) mixes
|
|
16
|
+
// them the same way, and honours NO_COLOR without knowing it exists.
|
|
17
|
+
export const rgb = (r, g, b) => (s) => (useColor ? `\x1b[38;2;${r};${g};${b}m${s}\x1b[39m` : String(s));
|
|
16
18
|
const wrap = (o, c) => (s) => (useColor ? `\x1b[${o}m${s}\x1b[${c}m` : String(s));
|
|
17
19
|
|
|
18
20
|
export const acid = rgb(158, 240, 26);
|