omnibot3000 1.8.2
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/.prettierrc +18 -0
- package/README.md +9 -0
- package/api/server.ts +153 -0
- package/eslint.config.js +103 -0
- package/index.html +22 -0
- package/netlify.toml +9 -0
- package/nodemon.json +4 -0
- package/omnibot3000.code-workspace +55 -0
- package/package.json +58 -0
- package/pnpm-workspace.yaml +2 -0
- package/public/fonts/vt220.woff2 +0 -0
- package/src/App.module.css +128 -0
- package/src/App.tsx +193 -0
- package/src/Error.tsx +80 -0
- package/src/commons/OmnibotSpeak.module.css +43 -0
- package/src/commons/OmnibotSpeak.tsx +31 -0
- package/src/commons/api/api.ts +150 -0
- package/src/commons/constants.ts +34 -0
- package/src/commons/favicon.ts +69 -0
- package/src/commons/hooks/useConfig.tsx +50 -0
- package/src/commons/hooks/useKeyPress.tsx +76 -0
- package/src/commons/hooks/useStorage.tsx +38 -0
- package/src/commons/layout/Background.module.css +47 -0
- package/src/commons/layout/Background.tsx +138 -0
- package/src/commons/layout/Breadcrumb.module.css +28 -0
- package/src/commons/layout/Breadcrumb.tsx +54 -0
- package/src/commons/layout/Container.module.css +51 -0
- package/src/commons/layout/Container.tsx +60 -0
- package/src/commons/layout/Footer.module.css +36 -0
- package/src/commons/layout/Footer.tsx +74 -0
- package/src/commons/layout/Header.module.css +73 -0
- package/src/commons/layout/Header.tsx +102 -0
- package/src/commons/layout/Menu.module.css +36 -0
- package/src/commons/layout/Menu.tsx +37 -0
- package/src/commons/persona.txt +38 -0
- package/src/commons/styles/debug.css +71 -0
- package/src/commons/styles/main.css +221 -0
- package/src/commons/styles/vt220.css +69 -0
- package/src/commons/ui/Button.tsx +22 -0
- package/src/commons/ui/Caret.tsx +20 -0
- package/src/commons/ui/Line.tsx +64 -0
- package/src/commons/ui/ScrollSnap.tsx +51 -0
- package/src/commons/ui/Separator.tsx +19 -0
- package/src/commons/ui/Spacer.tsx +12 -0
- package/src/commons/utils/canvas.ts +20 -0
- package/src/commons/utils/color.ts +4 -0
- package/src/commons/utils/math.ts +43 -0
- package/src/commons/utils/strings.ts +47 -0
- package/src/commons/utils/styles.ts +11 -0
- package/src/commons/utils/system.ts +6 -0
- package/src/commons/utils/version.ts +24 -0
- package/src/features/chat/Chat.module.css +8 -0
- package/src/features/chat/Chat.tsx +188 -0
- package/src/features/chat/commons/strings.ts +6 -0
- package/src/features/chat/components/Message.module.css +28 -0
- package/src/features/chat/components/Message.tsx +45 -0
- package/src/features/chat/components/Toolbar.module.css +19 -0
- package/src/features/chat/components/Toolbar.tsx +44 -0
- package/src/features/chat/hooks/useChatCompletionStore.tsx +160 -0
- package/src/features/cli/Cli.module.css +75 -0
- package/src/features/cli/Cli.tsx +303 -0
- package/src/features/console/cmd.ts +93 -0
- package/src/features/console/config.ts +106 -0
- package/src/features/help/Help.module.css +8 -0
- package/src/features/help/Help.tsx +78 -0
- package/src/features/history/History.module.css +77 -0
- package/src/features/history/History.tsx +92 -0
- package/src/features/home/Home.module.css +26 -0
- package/src/features/home/Home.tsx +101 -0
- package/src/features/life/Life.module.css +8 -0
- package/src/features/life/Life.tsx +16 -0
- package/src/features/life/generation.ts +103 -0
- package/src/features/life/lifeforms.ts +138 -0
- package/src/features/life/types.ts +5 -0
- package/src/features/version/Version.module.css +8 -0
- package/src/features/version/Version.tsx +70 -0
- package/src/global.d.ts +10 -0
- package/src/main.tsx +32 -0
- package/src/vite-env.d.ts +16 -0
- package/tsconfig.api.json +16 -0
- package/tsconfig.json +47 -0
- package/upgrade.sh +22 -0
- package/vite.config.ts +51 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {Lifeform} from "@life/types";
|
|
2
|
+
|
|
3
|
+
export const BLOCK: Lifeform = [
|
|
4
|
+
[0, 0] /* O O */,
|
|
5
|
+
[1, 0] /* O O */,
|
|
6
|
+
[0, 1],
|
|
7
|
+
[1, 1],
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
export const TUB: Lifeform = [
|
|
11
|
+
[1, 0] /* . O . */,
|
|
12
|
+
[0, 1] /* O . O */,
|
|
13
|
+
[2, 1] /* . O . */,
|
|
14
|
+
[1, 2],
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export const BOAT: Lifeform = [
|
|
18
|
+
[0, 0] /* O O . */,
|
|
19
|
+
[1, 0] /* O . O */,
|
|
20
|
+
[0, 1] /* . O . */,
|
|
21
|
+
[2, 1],
|
|
22
|
+
[1, 2],
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
export const BEEHIVE: Lifeform = [
|
|
26
|
+
[1, 0] /* . O O . */,
|
|
27
|
+
[2, 0] /* O . . O */,
|
|
28
|
+
[0, 1] /* . O O . */,
|
|
29
|
+
[3, 1],
|
|
30
|
+
[1, 2],
|
|
31
|
+
[2, 2],
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
export const LOAF: Lifeform = [
|
|
35
|
+
[1, 0] /* . O O . */,
|
|
36
|
+
[2, 0] /* O . . O */,
|
|
37
|
+
[0, 1] /* . O . O */,
|
|
38
|
+
[3, 1] /* . . O . */,
|
|
39
|
+
[1, 2],
|
|
40
|
+
[3, 2],
|
|
41
|
+
[2, 3],
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export const GLIDER: Lifeform = [
|
|
45
|
+
[1, 0] /* . O . */,
|
|
46
|
+
[2, 1] /* . . O */,
|
|
47
|
+
[0, 2] /* O O O */,
|
|
48
|
+
[1, 2],
|
|
49
|
+
[2, 2],
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
export const LWSS: Lifeform = [
|
|
53
|
+
[1, 0] /* . O . . O */,
|
|
54
|
+
[4, 0] /* O . . . . */,
|
|
55
|
+
[0, 1] /* O . . . O */,
|
|
56
|
+
[0, 2] /* O O O O . */,
|
|
57
|
+
[4, 2],
|
|
58
|
+
[0, 3],
|
|
59
|
+
[1, 3],
|
|
60
|
+
[2, 3],
|
|
61
|
+
[3, 3],
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export const MWSS: Lifeform = [
|
|
65
|
+
[2, 0] /* . . O O O O */,
|
|
66
|
+
[3, 0] /* O . . . . O */,
|
|
67
|
+
[4, 0] /* . . . . . O */,
|
|
68
|
+
[5, 0] /* O . . . O . */,
|
|
69
|
+
[0, 1],
|
|
70
|
+
[5, 1],
|
|
71
|
+
[5, 2],
|
|
72
|
+
[0, 3],
|
|
73
|
+
[4, 3],
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
export const HWSS: Lifeform = [
|
|
77
|
+
[3, 0] /* . . . O O O O */,
|
|
78
|
+
[4, 0] /* O . . . . . O */,
|
|
79
|
+
[5, 0] /* . . . . . . O */,
|
|
80
|
+
[6, 0] /* O . . . . O . */,
|
|
81
|
+
[0, 1],
|
|
82
|
+
[6, 1],
|
|
83
|
+
[6, 2],
|
|
84
|
+
[0, 3],
|
|
85
|
+
[5, 3],
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
export const BLINKER: Lifeform = [
|
|
89
|
+
[1, 0] /* . O . */,
|
|
90
|
+
[1, 1] /* . O . */,
|
|
91
|
+
[1, 2] /* . O . */,
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
export const TOAD: Lifeform = [
|
|
95
|
+
[1, 0] /* . O O O */,
|
|
96
|
+
[2, 0] /* O O O . */,
|
|
97
|
+
[3, 0],
|
|
98
|
+
[0, 1],
|
|
99
|
+
[1, 1],
|
|
100
|
+
[2, 1],
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
export const BEACON: Lifeform = [
|
|
104
|
+
[0, 0] /* O O . */,
|
|
105
|
+
[1, 0] /* O O . */,
|
|
106
|
+
[0, 1] /* . O O */,
|
|
107
|
+
[1, 1] /* . O O */,
|
|
108
|
+
[1, 2],
|
|
109
|
+
[2, 2],
|
|
110
|
+
[1, 3],
|
|
111
|
+
[2, 3],
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export const R_PENTOMINO: Lifeform = [
|
|
115
|
+
[1, 0] /* . O O */,
|
|
116
|
+
[2, 0] /* O O . */,
|
|
117
|
+
[0, 1] /* . O . */,
|
|
118
|
+
[1, 1],
|
|
119
|
+
[1, 2],
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
const LIFEFORMS: Lifeform[] = [
|
|
123
|
+
//BLOCK,
|
|
124
|
+
//TUB,
|
|
125
|
+
//BOAT,
|
|
126
|
+
//BEEHIVE,
|
|
127
|
+
//LOAF,
|
|
128
|
+
GLIDER,
|
|
129
|
+
LWSS,
|
|
130
|
+
MWSS,
|
|
131
|
+
HWSS,
|
|
132
|
+
//BLINKER,
|
|
133
|
+
//TOAD,
|
|
134
|
+
//BEACON,
|
|
135
|
+
R_PENTOMINO,
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
export default LIFEFORMS;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {memo, useEffect, useRef, useState} from "react";
|
|
2
|
+
|
|
3
|
+
import {NAME, VERSION} from "@commons/constants";
|
|
4
|
+
import OmnibotSpeak from "@commons/OmnibotSpeak";
|
|
5
|
+
import Container from "@layout/Container";
|
|
6
|
+
import {displayPackageVersion} from "@utils/version";
|
|
7
|
+
|
|
8
|
+
import useChatCompletionStore from "@chat/hooks/useChatCompletionStore";
|
|
9
|
+
import styles from "@help/Help.module.css";
|
|
10
|
+
|
|
11
|
+
import cls from "classnames";
|
|
12
|
+
|
|
13
|
+
console.info(JSON.stringify(import.meta.env, null, 2));
|
|
14
|
+
|
|
15
|
+
const API_PORT = Number(import.meta.env.API_PORT) || 3001;
|
|
16
|
+
const API_PATH = import.meta.env.API_PATH || "/api";
|
|
17
|
+
|
|
18
|
+
interface Package {
|
|
19
|
+
name: string;
|
|
20
|
+
version: [number, number, number];
|
|
21
|
+
size: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const PACKAGES_API = `${window.location.origin}:${API_PORT}${API_PATH}/packages`;
|
|
25
|
+
|
|
26
|
+
const Version = () => {
|
|
27
|
+
const chatStore = useChatCompletionStore();
|
|
28
|
+
|
|
29
|
+
const hasRunOnce = useRef(false);
|
|
30
|
+
const [response, setResponse] = useState<string>("loading...");
|
|
31
|
+
const [loading, setLoading] = useState<boolean>(false);
|
|
32
|
+
|
|
33
|
+
const getResponse = async () => {
|
|
34
|
+
const response = await fetch(PACKAGES_API);
|
|
35
|
+
|
|
36
|
+
const packages: Package[] = await response.json();
|
|
37
|
+
|
|
38
|
+
const list = packages
|
|
39
|
+
.map((pkg) => {
|
|
40
|
+
return `${pkg.name} **${pkg.version.join(".")}** \n`;
|
|
41
|
+
})
|
|
42
|
+
.join("");
|
|
43
|
+
|
|
44
|
+
const text = `# __${NAME}__ version **${VERSION.join(".")}**\n${list}`;
|
|
45
|
+
setLoading(false);
|
|
46
|
+
setResponse(text);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (hasRunOnce.current) return;
|
|
51
|
+
hasRunOnce.current = true;
|
|
52
|
+
|
|
53
|
+
chatStore.resetChat();
|
|
54
|
+
setLoading(true);
|
|
55
|
+
getResponse();
|
|
56
|
+
displayPackageVersion();
|
|
57
|
+
}, []);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className={styles.root}>
|
|
61
|
+
<Container>
|
|
62
|
+
<div className={cls("text", styles.body)}>
|
|
63
|
+
<OmnibotSpeak truth={response} hasCaret={loading} />
|
|
64
|
+
</div>
|
|
65
|
+
</Container>
|
|
66
|
+
</div>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default memo(Version);
|
package/src/global.d.ts
ADDED
package/src/main.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {StrictMode} from "react";
|
|
2
|
+
import {createRoot} from "react-dom/client";
|
|
3
|
+
|
|
4
|
+
import favIcon from "@commons/favicon";
|
|
5
|
+
import {displayPackageVersion} from "@utils/version";
|
|
6
|
+
|
|
7
|
+
import {ConfigProvider} from "@hooks/useConfig";
|
|
8
|
+
|
|
9
|
+
import App from "@/App";
|
|
10
|
+
import ErrorBoundary from "@/Error";
|
|
11
|
+
|
|
12
|
+
const root = createRoot(document.getElementById("root")!);
|
|
13
|
+
|
|
14
|
+
root.render(
|
|
15
|
+
<StrictMode>
|
|
16
|
+
<ErrorBoundary>
|
|
17
|
+
<ConfigProvider>
|
|
18
|
+
<App />
|
|
19
|
+
</ConfigProvider>
|
|
20
|
+
</ErrorBoundary>
|
|
21
|
+
</StrictMode>,
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
window.addEventListener("DOMContentLoaded", () => {
|
|
25
|
+
favIcon();
|
|
26
|
+
displayPackageVersion();
|
|
27
|
+
document.body.style.visibility = "visible";
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
window.onscroll = () => {
|
|
31
|
+
window.scrollTo(0, 0);
|
|
32
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
|
|
3
|
+
declare module "*.css" {
|
|
4
|
+
const content: {[className: string]: string};
|
|
5
|
+
export default content;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
declare module "*.module.css" {
|
|
9
|
+
const classes: {[key: string]: string};
|
|
10
|
+
export default classes;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module "*.txt?raw" {
|
|
14
|
+
const content: string;
|
|
15
|
+
export default content;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
/* linting */
|
|
9
|
+
"strict": true,
|
|
10
|
+
/* paths */
|
|
11
|
+
"rootDir": "./api/",
|
|
12
|
+
"outDir": "./dist/api/"
|
|
13
|
+
},
|
|
14
|
+
"include": ["./api/**/*.ts"],
|
|
15
|
+
"exclude": []
|
|
16
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"types": ["vite/client"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"useDefineForClassFields": true,
|
|
9
|
+
/* bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"isolatedModules": true,
|
|
13
|
+
"moduleDetection": "force",
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
|
+
/* linting */
|
|
17
|
+
"strict": true,
|
|
18
|
+
"noUnusedLocals": true,
|
|
19
|
+
"noUnusedParameters": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
/* paths */
|
|
22
|
+
"rootDir": "./",
|
|
23
|
+
"outDir": "./dist/",
|
|
24
|
+
"baseUrl": "./src/",
|
|
25
|
+
"paths": {
|
|
26
|
+
"@/*": ["*"],
|
|
27
|
+
"@root/*": ["../*"],
|
|
28
|
+
"@commons/*": ["commons/*"],
|
|
29
|
+
"@api/*": ["commons/api/*"],
|
|
30
|
+
"@hooks/*": ["commons/hooks/*"],
|
|
31
|
+
"@layout/*": ["commons/layout/*"],
|
|
32
|
+
"@styles/*": ["commons/styles/*"],
|
|
33
|
+
"@ui/*": ["commons/ui/*"],
|
|
34
|
+
"@utils/*": ["commons/utils/*"],
|
|
35
|
+
"@chat/*": ["features/chat/*"],
|
|
36
|
+
"@cli/*": ["features/cli/*"],
|
|
37
|
+
"@console/*": ["features/console/*"],
|
|
38
|
+
"@help/*": ["features/help/*"],
|
|
39
|
+
"@history/*": ["features/history/*"],
|
|
40
|
+
"@home/*": ["features/home/*"],
|
|
41
|
+
"@life/*": ["features/life/*"],
|
|
42
|
+
"@version/*": ["features/version/*"],
|
|
43
|
+
"@images/*": ["/images/*"]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"include": ["src", "api"]
|
|
47
|
+
}
|
package/upgrade.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
clear
|
|
3
|
+
|
|
4
|
+
PNPM_PIDS=$(pgrep -f "pnpm")
|
|
5
|
+
|
|
6
|
+
if [ ! -z "$PNPM_PIDS" ]; then
|
|
7
|
+
pkill -TERM -f "pnpm"
|
|
8
|
+
sleep 2
|
|
9
|
+
REMAINING_PIDS=$(pgrep -f "pnpm")
|
|
10
|
+
if [ ! -z "$REMAINING_PIDS" ]; then
|
|
11
|
+
pkill -KILL -f "pnpm"
|
|
12
|
+
sleep 1
|
|
13
|
+
fi
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
if [ -d "node_modules" ]; then
|
|
17
|
+
rm -rf node_modules
|
|
18
|
+
fi
|
|
19
|
+
timeout 10s pnpm self-update
|
|
20
|
+
pnpm up --latest
|
|
21
|
+
|
|
22
|
+
echo
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {defineConfig, loadEnv} from "vite";
|
|
2
|
+
import tsconfigPaths from "vite-tsconfig-paths";
|
|
3
|
+
|
|
4
|
+
import pkg from "./package.json";
|
|
5
|
+
|
|
6
|
+
import react from "@vitejs/plugin-react";
|
|
7
|
+
|
|
8
|
+
/* https://vitejs.dev/config/ */
|
|
9
|
+
export default defineConfig(({mode}) => {
|
|
10
|
+
const env = loadEnv(mode, process.cwd(), "");
|
|
11
|
+
|
|
12
|
+
console.info(
|
|
13
|
+
"\n\x1b[1m\x1b[32m%s\x1b[0m %s \x1b[32m%s\x1b[0m %s \x1b[36m%s\x1b[0m",
|
|
14
|
+
"→",
|
|
15
|
+
"Running",
|
|
16
|
+
`${pkg["x-display-name"]} v${pkg.version}`,
|
|
17
|
+
"dev server at",
|
|
18
|
+
`http://${env.DOMAIN}:${env.DEV_PORT}`,
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
define: {
|
|
23
|
+
__APP_VERSION__: JSON.stringify(pkg.version),
|
|
24
|
+
__APP_NAME__: JSON.stringify(pkg["x-display-name"]),
|
|
25
|
+
"import.meta.env.DOMAIN": JSON.stringify(env.DOMAIN),
|
|
26
|
+
"import.meta.env.DEV_PORT": JSON.stringify(env.DEV_PORT),
|
|
27
|
+
"import.meta.env.API_PORT": JSON.stringify(env.API_PORT),
|
|
28
|
+
"import.meta.env.API_PATH": JSON.stringify(env.API_PATH),
|
|
29
|
+
"import.meta.env.BASE_PATH": JSON.stringify(process.cwd()),
|
|
30
|
+
},
|
|
31
|
+
plugins: [react(), tsconfigPaths()],
|
|
32
|
+
server: {
|
|
33
|
+
host: true,
|
|
34
|
+
port: 3000,
|
|
35
|
+
allowedHosts: [env.DOMAIN],
|
|
36
|
+
watch: {
|
|
37
|
+
usePolling: false /* speed up updates */,
|
|
38
|
+
ignored: ["**/node_modules/**", "**/dist/**"],
|
|
39
|
+
},
|
|
40
|
+
hmr: {
|
|
41
|
+
protocol: "ws",
|
|
42
|
+
host: env.DOMAIN,
|
|
43
|
+
port: Number(env.DEV_PORT),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
optimizeDeps: {
|
|
47
|
+
include: ["react", "react-dom"],
|
|
48
|
+
exclude: [] /* exclude heavy libs not much used */,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
});
|