create-skybridge 0.0.0-dev.1 → 0.0.0-dev.103c082
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/dist/index.d.ts +1 -1
- package/dist/index.js +192 -63
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +33 -0
- package/index.js +6 -1
- package/package.json +15 -8
- package/template/AGENTS.md +1 -0
- package/template/README.md +97 -0
- package/template/_gitignore +5 -0
- package/template/alpic.json +3 -0
- package/template/node_modules/.bin/alpic +21 -0
- package/template/node_modules/.bin/sb +21 -0
- package/template/node_modules/.bin/skybridge +21 -0
- package/template/node_modules/.bin/tsc +21 -0
- package/template/node_modules/.bin/tsserver +21 -0
- package/template/node_modules/.bin/tsx +21 -0
- package/template/node_modules/.bin/vite +21 -0
- package/template/package.json +34 -0
- package/template/server/src/index.ts +62 -0
- package/template/tsconfig.json +13 -0
- package/template/web/src/helpers.ts +4 -0
- package/template/web/src/index.css +152 -0
- package/template/web/src/widgets/magic-8-ball.tsx +27 -0
- package/template/web/vite.config.ts +15 -0
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function init(args?: string[]): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,49 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
import * as prompts from "@clack/prompts";
|
|
3
|
-
import mri from "mri";
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
4
2
|
import fs from "node:fs";
|
|
5
3
|
import path from "node:path";
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const cwd = process.cwd();
|
|
12
|
-
const TEMPLATE_REPO = "https://github.com/alpic-ai/apps-sdk-template";
|
|
13
|
-
const defaultTargetDir = "skybridge-project";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import * as prompts from "@clack/prompts";
|
|
6
|
+
import { downloadTemplate } from "giget";
|
|
7
|
+
import mri from "mri";
|
|
8
|
+
const defaultProjectName = "skybridge-project";
|
|
14
9
|
// prettier-ignore
|
|
15
10
|
const helpMessage = `\
|
|
16
11
|
Usage: create-skybridge [OPTION]... [DIRECTORY]
|
|
17
12
|
|
|
18
|
-
Create a new Skybridge project by
|
|
13
|
+
Create a new Skybridge project by copying the starter template.
|
|
19
14
|
|
|
20
15
|
Options:
|
|
21
16
|
-h, --help show this help message
|
|
17
|
+
--repo <uri> use a git repository instead of the built-in template
|
|
22
18
|
--overwrite remove existing files in target directory
|
|
19
|
+
--immediate install dependencies and start development server
|
|
20
|
+
|
|
21
|
+
Repository URI formats:
|
|
22
|
+
github:user/repo
|
|
23
|
+
gitlab:user/repo/subdirectory
|
|
24
|
+
bitbucket:user/repo#branch
|
|
23
25
|
|
|
24
26
|
Examples:
|
|
25
27
|
create-skybridge my-app
|
|
26
|
-
create-skybridge
|
|
28
|
+
create-skybridge my-app --repo github:alpic-ai/skybridge/examples/ecom-carousel
|
|
29
|
+
create-skybridge . --overwrite --immediate
|
|
27
30
|
`;
|
|
28
|
-
function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
process.exit(status);
|
|
35
|
-
}
|
|
36
|
-
if (error) {
|
|
37
|
-
console.error(`\n${command} ${args.join(" ")} error!`);
|
|
38
|
-
console.error(error);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function init() {
|
|
31
|
+
export async function init(args = process.argv.slice(2)) {
|
|
32
|
+
const argv = mri(args, {
|
|
33
|
+
boolean: ["help", "overwrite", "immediate"],
|
|
34
|
+
string: ["repo"],
|
|
35
|
+
alias: { h: "help" },
|
|
36
|
+
});
|
|
43
37
|
const argTargetDir = argv._[0]
|
|
44
|
-
?
|
|
38
|
+
? sanitizeTargetDir(String(argv._[0]))
|
|
45
39
|
: undefined;
|
|
40
|
+
const argRepo = argv.repo;
|
|
46
41
|
const argOverwrite = argv.overwrite;
|
|
42
|
+
const argImmediate = argv.immediate;
|
|
47
43
|
const help = argv.help;
|
|
48
44
|
if (help) {
|
|
49
45
|
console.log(helpMessage);
|
|
@@ -57,20 +53,21 @@ async function init() {
|
|
|
57
53
|
if (interactive) {
|
|
58
54
|
const projectName = await prompts.text({
|
|
59
55
|
message: "Project name:",
|
|
60
|
-
defaultValue:
|
|
61
|
-
placeholder:
|
|
56
|
+
defaultValue: defaultProjectName,
|
|
57
|
+
placeholder: defaultProjectName,
|
|
62
58
|
validate: (value) => {
|
|
63
|
-
return value
|
|
59
|
+
return !value || sanitizeTargetDir(value).length > 0
|
|
64
60
|
? undefined
|
|
65
61
|
: "Invalid project name";
|
|
66
62
|
},
|
|
67
63
|
});
|
|
68
|
-
if (prompts.isCancel(projectName))
|
|
64
|
+
if (prompts.isCancel(projectName)) {
|
|
69
65
|
return cancel();
|
|
70
|
-
|
|
66
|
+
}
|
|
67
|
+
targetDir = sanitizeTargetDir(projectName);
|
|
71
68
|
}
|
|
72
69
|
else {
|
|
73
|
-
targetDir =
|
|
70
|
+
targetDir = defaultProjectName;
|
|
74
71
|
}
|
|
75
72
|
}
|
|
76
73
|
// 2. Handle directory if exist and not empty
|
|
@@ -94,8 +91,9 @@ async function init() {
|
|
|
94
91
|
},
|
|
95
92
|
],
|
|
96
93
|
});
|
|
97
|
-
if (prompts.isCancel(res))
|
|
94
|
+
if (prompts.isCancel(res)) {
|
|
98
95
|
return cancel();
|
|
96
|
+
}
|
|
99
97
|
overwrite = res;
|
|
100
98
|
}
|
|
101
99
|
else {
|
|
@@ -107,51 +105,182 @@ async function init() {
|
|
|
107
105
|
emptyDir(targetDir);
|
|
108
106
|
break;
|
|
109
107
|
case "no":
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
prompts.log.error("Target directory is not empty.");
|
|
109
|
+
process.exit(1);
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
|
-
const root = path.join(cwd, targetDir);
|
|
115
|
-
// 3.
|
|
116
|
-
|
|
112
|
+
const root = path.join(process.cwd(), targetDir);
|
|
113
|
+
// 3. Download from repo or copy template
|
|
114
|
+
try {
|
|
115
|
+
if (argRepo) {
|
|
116
|
+
prompts.log.step(`Downloading ${argRepo}...`);
|
|
117
|
+
await downloadTemplate(argRepo, { dir: root });
|
|
118
|
+
prompts.log.success(`Project created in ${root}`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
prompts.log.step(`Copying template...`);
|
|
122
|
+
const templateDir = fileURLToPath(new URL("../template", import.meta.url));
|
|
123
|
+
// Copy template to target directory
|
|
124
|
+
fs.cpSync(templateDir, root, {
|
|
125
|
+
recursive: true,
|
|
126
|
+
filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
|
|
127
|
+
});
|
|
128
|
+
// Rename _gitignore to .gitignore
|
|
129
|
+
fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
|
|
130
|
+
prompts.log.success(`Project created in ${root}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
prompts.log.error("Failed to create project from template");
|
|
135
|
+
console.error(error);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
// Update project name in package.json
|
|
139
|
+
const pkgPath = path.join(root, "package.json");
|
|
140
|
+
if (!fs.existsSync(pkgPath)) {
|
|
141
|
+
prompts.log.error("No package.json found in project");
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
117
144
|
try {
|
|
118
|
-
|
|
119
|
-
|
|
145
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
146
|
+
pkg.name = path.basename(root);
|
|
147
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
prompts.log.error("Failed to update project name in package.json");
|
|
151
|
+
console.error(error);
|
|
152
|
+
process.exit(1);
|
|
153
|
+
}
|
|
154
|
+
const userAgent = process.env.npm_config_user_agent;
|
|
155
|
+
const pkgManager = userAgent?.split(" ")[0]?.split("/")[0] || "npm";
|
|
156
|
+
// 4. Ask about skills installation (installed by default)
|
|
157
|
+
let skill = true;
|
|
158
|
+
if (interactive) {
|
|
159
|
+
const skillsResult = await prompts.confirm({
|
|
160
|
+
message: "Install the coding agents skills? (recommended)",
|
|
161
|
+
initialValue: true,
|
|
162
|
+
});
|
|
163
|
+
if (prompts.isCancel(skillsResult)) {
|
|
164
|
+
return cancel();
|
|
165
|
+
}
|
|
166
|
+
skill = skillsResult;
|
|
167
|
+
}
|
|
168
|
+
if (skill) {
|
|
169
|
+
run([
|
|
170
|
+
...getPkgExecCmd(pkgManager, "skills"),
|
|
171
|
+
"add",
|
|
172
|
+
"alpic-ai/skybridge",
|
|
173
|
+
"-s",
|
|
174
|
+
"chatgpt-app-builder",
|
|
175
|
+
...(interactive ? [] : ["--yes", "-a", "claude-code"]),
|
|
176
|
+
], {
|
|
120
177
|
stdio: "inherit",
|
|
178
|
+
cwd: targetDir,
|
|
121
179
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
180
|
+
}
|
|
181
|
+
// 5. Ask about immediate installation
|
|
182
|
+
let immediate = argImmediate;
|
|
183
|
+
if (immediate === undefined) {
|
|
184
|
+
if (interactive) {
|
|
185
|
+
const immediateResult = await prompts.confirm({
|
|
186
|
+
message: `Install with ${pkgManager} and start now?`,
|
|
187
|
+
});
|
|
188
|
+
if (prompts.isCancel(immediateResult)) {
|
|
189
|
+
return cancel();
|
|
190
|
+
}
|
|
191
|
+
immediate = immediateResult;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
immediate = false;
|
|
126
195
|
}
|
|
127
|
-
prompts.log.success(`Project created in ${root}`);
|
|
128
|
-
prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
|
|
129
196
|
}
|
|
130
|
-
|
|
131
|
-
|
|
197
|
+
const installCmd = [pkgManager, "install"];
|
|
198
|
+
const runCmd = [pkgManager];
|
|
199
|
+
switch (pkgManager) {
|
|
200
|
+
case "yarn":
|
|
201
|
+
case "pnpm":
|
|
202
|
+
case "bun":
|
|
203
|
+
break;
|
|
204
|
+
case "deno":
|
|
205
|
+
runCmd.push("task");
|
|
206
|
+
break;
|
|
207
|
+
default:
|
|
208
|
+
runCmd.push("run");
|
|
209
|
+
}
|
|
210
|
+
runCmd.push("dev");
|
|
211
|
+
if (!immediate) {
|
|
212
|
+
prompts.outro(`Done! Next steps:
|
|
213
|
+
cd ${targetDir}
|
|
214
|
+
${installCmd.join(" ")}
|
|
215
|
+
${runCmd.join(" ")}
|
|
216
|
+
`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
prompts.log.step(`Installing dependencies with ${pkgManager}...`);
|
|
220
|
+
run(installCmd, {
|
|
221
|
+
stdio: "inherit",
|
|
222
|
+
cwd: root,
|
|
223
|
+
});
|
|
224
|
+
prompts.log.step("Starting dev server...");
|
|
225
|
+
run(runCmd, {
|
|
226
|
+
stdio: "inherit",
|
|
227
|
+
cwd: root,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function run([command, ...args], options) {
|
|
231
|
+
const { status, error } = spawnSync(command, args, options);
|
|
232
|
+
if (status != null && status > 0) {
|
|
233
|
+
process.exit(status);
|
|
234
|
+
}
|
|
235
|
+
if (error) {
|
|
236
|
+
console.error(`\n${command} ${args.join(" ")} error!`);
|
|
132
237
|
console.error(error);
|
|
133
238
|
process.exit(1);
|
|
134
239
|
}
|
|
135
240
|
}
|
|
136
|
-
function
|
|
137
|
-
return targetDir
|
|
241
|
+
function sanitizeTargetDir(targetDir) {
|
|
242
|
+
return (targetDir
|
|
243
|
+
.trim()
|
|
244
|
+
// Only keep alphanumeric, dash, underscore, dot, @, /
|
|
245
|
+
.replace(/[^a-zA-Z0-9\-_.@/]/g, "")
|
|
246
|
+
// Prevent path traversal
|
|
247
|
+
.replace(/\.\./g, "")
|
|
248
|
+
// Collapse multiple slashes
|
|
249
|
+
.replace(/\/+/g, "/")
|
|
250
|
+
// Remove leading/trailing slashes
|
|
251
|
+
.replace(/^\/+|\/+$/g, ""));
|
|
138
252
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
return
|
|
253
|
+
// Skip user's SPEC.md and IDE/agent preferences (.idea, .claude, etc.)
|
|
254
|
+
function isSkippedEntry(entry) {
|
|
255
|
+
return ((entry.name.startsWith(".") && entry.isDirectory()) ||
|
|
256
|
+
entry.name === "SPEC.md");
|
|
257
|
+
}
|
|
258
|
+
function isEmpty(dirPath) {
|
|
259
|
+
const entries = fs.readdirSync(dirPath, { withFileTypes: true });
|
|
260
|
+
return entries.every(isSkippedEntry);
|
|
142
261
|
}
|
|
143
262
|
function emptyDir(dir) {
|
|
144
263
|
if (!fs.existsSync(dir)) {
|
|
145
264
|
return;
|
|
146
265
|
}
|
|
147
|
-
for (const
|
|
148
|
-
if (
|
|
266
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
267
|
+
if (isSkippedEntry(entry)) {
|
|
149
268
|
continue;
|
|
150
269
|
}
|
|
151
|
-
fs.rmSync(path.
|
|
270
|
+
fs.rmSync(path.join(dir, entry.name), { recursive: true, force: true });
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
function getPkgExecCmd(pkgManager, cmd) {
|
|
274
|
+
switch (pkgManager) {
|
|
275
|
+
case "yarn":
|
|
276
|
+
return ["yarn", "dlx", cmd];
|
|
277
|
+
case "pnpm":
|
|
278
|
+
return ["pnpm", "dlx", cmd];
|
|
279
|
+
case "bun":
|
|
280
|
+
return ["bunx", cmd];
|
|
281
|
+
case "deno":
|
|
282
|
+
return ["deno", "run", "-A", `npm:${cmd}`];
|
|
283
|
+
default:
|
|
284
|
+
return ["npx", "--yes", cmd];
|
|
152
285
|
}
|
|
153
286
|
}
|
|
154
|
-
init().catch((e) => {
|
|
155
|
-
console.error(e);
|
|
156
|
-
process.exit(1);
|
|
157
|
-
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { init } from "./index.js";
|
|
6
|
+
describe("create-skybridge", () => {
|
|
7
|
+
let tempDirName;
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
tempDirName = `test-${randomBytes(2).toString("hex")}`;
|
|
10
|
+
});
|
|
11
|
+
afterEach(async () => {
|
|
12
|
+
await fs.rm(path.join(process.cwd(), tempDirName), {
|
|
13
|
+
recursive: true,
|
|
14
|
+
force: true,
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
it("should copy the template", { timeout: 10000 }, async () => {
|
|
18
|
+
const name = `../../${tempDirName}//project$`;
|
|
19
|
+
await init([name]);
|
|
20
|
+
await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
|
|
21
|
+
expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
|
|
22
|
+
});
|
|
23
|
+
it("should download template from repo", { timeout: 10000 }, async () => {
|
|
24
|
+
const name = `../../${tempDirName}//project$`;
|
|
25
|
+
await init([
|
|
26
|
+
name,
|
|
27
|
+
"--repo",
|
|
28
|
+
"github:alpic-ai/skybridge/examples/ecom-carousel",
|
|
29
|
+
]);
|
|
30
|
+
await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
|
|
31
|
+
expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
|
|
32
|
+
});
|
|
33
|
+
});
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,27 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.103c082",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Alpic",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/alpic-ai/skybridge.git"
|
|
10
|
+
},
|
|
7
11
|
"bin": {
|
|
8
|
-
"create-skybridge": "
|
|
12
|
+
"create-skybridge": "index.js"
|
|
9
13
|
},
|
|
10
14
|
"files": [
|
|
11
15
|
"index.js",
|
|
12
|
-
"dist"
|
|
16
|
+
"dist",
|
|
17
|
+
"template"
|
|
13
18
|
],
|
|
14
19
|
"dependencies": {
|
|
15
|
-
"@clack/prompts": "^
|
|
20
|
+
"@clack/prompts": "^1.1.0",
|
|
21
|
+
"giget": "^3.2.0",
|
|
16
22
|
"mri": "^1.2.0"
|
|
17
23
|
},
|
|
18
24
|
"devDependencies": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"typescript": "^5.9.3"
|
|
25
|
+
"typescript": "^6.0.2",
|
|
26
|
+
"vitest": "^4.1.2"
|
|
22
27
|
},
|
|
23
28
|
"scripts": {
|
|
24
|
-
"build": "tsc
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
31
|
+
"test:unit": "vitest run",
|
|
25
32
|
"test:type": "tsc --noEmit",
|
|
26
33
|
"test:format": "biome ci"
|
|
27
34
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This is a ChatGPT/MCP app built with Skybridge. ALWAYS use the `chatgpt-app-builder` skill when planning or updating the codebase.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Skybridge Starter
|
|
2
|
+
|
|
3
|
+
A minimal TypeScript template for building MCP and ChatGPT Apps with the [Skybridge](https://docs.skybridge.tech/home) framework.
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Node.js 24+
|
|
10
|
+
- HTTP tunnel such as [Alpic tunnel](https://docs.alpic.ai/cli/tunnel) if you want to test with remote MCP hosts like ChatGPT or Claude.ai.
|
|
11
|
+
|
|
12
|
+
### Local Development
|
|
13
|
+
|
|
14
|
+
#### 1. Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install
|
|
18
|
+
# or
|
|
19
|
+
yarn install
|
|
20
|
+
# or
|
|
21
|
+
pnpm install
|
|
22
|
+
# or
|
|
23
|
+
bun install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
#### 2. Start your local server
|
|
27
|
+
|
|
28
|
+
Run the development server from the root directory:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run dev
|
|
32
|
+
# or
|
|
33
|
+
yarn dev
|
|
34
|
+
# or
|
|
35
|
+
pnpm dev
|
|
36
|
+
# or
|
|
37
|
+
bun dev
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This command starts:
|
|
41
|
+
- Your MCP server at `http://localhost:3000/mcp`.
|
|
42
|
+
- Skybridge DevTools UI at `http://localhost:3000/`.
|
|
43
|
+
|
|
44
|
+
#### 3. Project structure
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
├── server/
|
|
48
|
+
│ └── src/
|
|
49
|
+
│ └── index.ts # Server entry point
|
|
50
|
+
├── web/
|
|
51
|
+
│ ├── src/
|
|
52
|
+
│ │ ├── widgets/ # React components (one per widget)
|
|
53
|
+
│ │ ├── helpers.ts # Shared utilities
|
|
54
|
+
│ │ └── index.css # Global styles
|
|
55
|
+
│ └── vite.config.ts
|
|
56
|
+
├── alpic.json # Deployment config
|
|
57
|
+
├── nodemon.json # Dev server config
|
|
58
|
+
└── package.json
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Create your first widget
|
|
62
|
+
|
|
63
|
+
#### 1. Add a new widget
|
|
64
|
+
|
|
65
|
+
- Register a widget in `server/src/server.ts` with a unique name (e.g., `my-widget`) using [`registerWidget`](https://docs.skybridge.tech/api-reference/register-widget)
|
|
66
|
+
- Create a matching React component at `web/src/widgets/my-widget.tsx`. **The file name must match the widget name exactly**.
|
|
67
|
+
|
|
68
|
+
#### 2. Edit widgets with Hot Module Replacement (HMR)
|
|
69
|
+
|
|
70
|
+
Edit and save components in `web/src/widgets/` — changes will appear instantly inside your App.
|
|
71
|
+
|
|
72
|
+
#### 3. Edit server code
|
|
73
|
+
|
|
74
|
+
Modify files in `server/` and refresh the connection with your testing MCP Client to see the changes.
|
|
75
|
+
|
|
76
|
+
### Testing your App
|
|
77
|
+
|
|
78
|
+
You can test your App locally by using our DevTools UI on `localhost:3000` while running the `pnpm dev` command.
|
|
79
|
+
|
|
80
|
+
To test your app with other MCP Clients like ChatGPT, Claude or VSCode, see [Testing Your App](https://docs.skybridge.tech/quickstart/test-your-app).
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## Deploy to Production
|
|
84
|
+
|
|
85
|
+
Skybridge is infrastructure vendor agnostic, and your app can be deployed on any cloud platform supporting MCP.
|
|
86
|
+
|
|
87
|
+
The simplest way to deploy your App in minutes is [Alpic](https://alpic.ai/).
|
|
88
|
+
1. Create an account on [Alpic platform](https://app.alpic.ai/).
|
|
89
|
+
2. Connect your GitHub repository to automatically deploy at each commit.
|
|
90
|
+
3. Use your remote App URL to connect it to MCP Clients, or use the Alpic Playground to easily test your App.
|
|
91
|
+
|
|
92
|
+
## Resources
|
|
93
|
+
- [Skybridge Documentation](https://docs.skybridge.tech/)
|
|
94
|
+
- [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
|
|
95
|
+
- [MCP Apps Documentation](https://github.com/modelcontextprotocol/ext-apps/tree/main)
|
|
96
|
+
- [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
|
|
97
|
+
- [Alpic Documentation](https://docs.alpic.ai/)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.104.1_@opentelemetry+api@1.9.0_arktype@2.1.27_rxjs@7.8.2_typescript@6.0.2/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.104.1_@opentelemetry+api@1.9.0_arktype@2.1.27_rxjs@7.8.2_typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.104.1_@opentelemetry+api@1.9.0_arktype@2.1.27_rxjs@7.8.2_typescript@6.0.2/node_modules/alpic/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/alpic@1.104.1_@opentelemetry+api@1.9.0_arktype@2.1.27_rxjs@7.8.2_typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../alpic/bin/run.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../alpic/bin/run.js" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../skybridge/bin/run.js" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules/skybridge/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/skybridge@0.35.14_@modelcontextprotocol+sdk@1.29.0_zod@4.3.6__@skybridge+devtools@0.35._9ddb2dfa56e61c7e1e71871404a50ada/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../skybridge/bin/run.js" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsc" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../typescript/bin/tsc" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules/typescript/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/typescript@6.0.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../typescript/bin/tsserver" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../typescript/bin/tsserver" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules/tsx/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/tsx@4.21.0/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../tsx/dist/cli.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../tsx/dist/cli.mjs" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.0.3_@types+node@24.12.0_esbuild@0.27.2_jiti@2.6.1_terser@5.44.1_tsx@4.21.0_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.0.3_@types+node@24.12.0_esbuild@0.27.2_jiti@2.6.1_terser@5.44.1_tsx@4.21.0_yaml@2.8.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.0.3_@types+node@24.12.0_esbuild@0.27.2_jiti@2.6.1_terser@5.44.1_tsx@4.21.0_yaml@2.8.2/node_modules/vite/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vite@8.0.3_@types+node@24.12.0_esbuild@0.27.2_jiti@2.6.1_terser@5.44.1_tsx@4.21.0_yaml@2.8.2/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../vite/bin/vite.js" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../vite/bin/vite.js" "$@"
|
|
21
|
+
fi
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "apps-sdk-template",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Alpic MCP Server Template",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"dev": "skybridge dev",
|
|
9
|
+
"build": "skybridge build",
|
|
10
|
+
"start": "skybridge start",
|
|
11
|
+
"deploy": "alpic deploy"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15
|
+
"react": "^19.2.4",
|
|
16
|
+
"react-dom": "^19.2.4",
|
|
17
|
+
"skybridge": ">=0.35.14 <1.0.0",
|
|
18
|
+
"vite": "^8.0.3",
|
|
19
|
+
"zod": "^4.3.6"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@skybridge/devtools": ">=0.35.14 <1.0.0",
|
|
23
|
+
"@types/react": "^19.2.14",
|
|
24
|
+
"@types/node": "^24.12.0",
|
|
25
|
+
"@types/react-dom": "^19.2.3",
|
|
26
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
27
|
+
"alpic": "^1.104.1",
|
|
28
|
+
"tsx": "^4.21.0",
|
|
29
|
+
"typescript": "^6.0.2"
|
|
30
|
+
},
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=24.14.1"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { McpServer } from "skybridge/server";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
const Answers = [
|
|
5
|
+
"As I see it, yes",
|
|
6
|
+
"Don't count on it",
|
|
7
|
+
"It is certain",
|
|
8
|
+
"It is decidedly so",
|
|
9
|
+
"Most likely",
|
|
10
|
+
"My reply is no",
|
|
11
|
+
"My sources say no",
|
|
12
|
+
"Outlook good",
|
|
13
|
+
"Outlook not so good",
|
|
14
|
+
"Signs point to yes",
|
|
15
|
+
"Very doubtful",
|
|
16
|
+
"Without a doubt",
|
|
17
|
+
"Yes definitely",
|
|
18
|
+
"Yes",
|
|
19
|
+
"You may rely on it",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const server = new McpServer(
|
|
23
|
+
{
|
|
24
|
+
name: "alpic-openai-app",
|
|
25
|
+
version: "0.0.1",
|
|
26
|
+
},
|
|
27
|
+
{ capabilities: {} },
|
|
28
|
+
).registerWidget(
|
|
29
|
+
"magic-8-ball",
|
|
30
|
+
{
|
|
31
|
+
description: "Magic 8 Ball",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
description: "For fortune-telling or seeking advice.",
|
|
35
|
+
inputSchema: {
|
|
36
|
+
question: z.string().describe("The user question."),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
async ({ question }) => {
|
|
40
|
+
try {
|
|
41
|
+
// deterministic answer
|
|
42
|
+
const hash = question
|
|
43
|
+
.split("")
|
|
44
|
+
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
45
|
+
const answer = Answers[hash % Answers.length];
|
|
46
|
+
return {
|
|
47
|
+
structuredContent: { answer },
|
|
48
|
+
content: [],
|
|
49
|
+
isError: false,
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: "text", text: `Error: ${error}` }],
|
|
54
|
+
isError: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
server.run();
|
|
61
|
+
|
|
62
|
+
export type AppType = typeof server;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
@import url("https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@1,600&display=swap");
|
|
2
|
+
|
|
3
|
+
.container {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-items: center;
|
|
7
|
+
min-height: 100%;
|
|
8
|
+
padding: 1rem;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.ball {
|
|
13
|
+
background: radial-gradient(
|
|
14
|
+
circle at 30% 30%,
|
|
15
|
+
#454565 0%,
|
|
16
|
+
#1c1c30 40%,
|
|
17
|
+
#0a0a10 100%
|
|
18
|
+
);
|
|
19
|
+
border-radius: 50%;
|
|
20
|
+
width: 12rem;
|
|
21
|
+
height: 12rem;
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
align-items: center;
|
|
25
|
+
justify-content: center;
|
|
26
|
+
font-family: monospace;
|
|
27
|
+
text-align: center;
|
|
28
|
+
position: relative;
|
|
29
|
+
box-shadow:
|
|
30
|
+
0 10px 30px rgba(0, 0, 0, 0.5),
|
|
31
|
+
0 5px 15px rgba(0, 0, 0, 0.3),
|
|
32
|
+
inset 0 -20px 40px rgba(0, 0, 0, 0.6);
|
|
33
|
+
animation:
|
|
34
|
+
float 3s ease-in-out infinite,
|
|
35
|
+
colorShift 15s ease-in-out infinite;
|
|
36
|
+
transition: transform 0.3s ease;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
border: 1px solid rgba(30, 30, 50, 0.6);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.ball:hover {
|
|
42
|
+
transform: scale(1.05) translateY(-8px);
|
|
43
|
+
animation: colorShift 15s ease-in-out infinite;
|
|
44
|
+
box-shadow:
|
|
45
|
+
0 20px 50px rgba(0, 0, 0, 0.6),
|
|
46
|
+
0 10px 25px rgba(0, 0, 0, 0.4),
|
|
47
|
+
inset 0 -20px 40px rgba(0, 0, 0, 0.6);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@keyframes float {
|
|
51
|
+
0%,
|
|
52
|
+
100% {
|
|
53
|
+
transform: translateY(0);
|
|
54
|
+
}
|
|
55
|
+
50% {
|
|
56
|
+
transform: translateY(-8px);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@keyframes colorShift {
|
|
61
|
+
0%,
|
|
62
|
+
100% {
|
|
63
|
+
background: radial-gradient(
|
|
64
|
+
circle at 30% 30%,
|
|
65
|
+
#454565 0%,
|
|
66
|
+
#1c1c30 40%,
|
|
67
|
+
#0a0a10 100%
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
25% {
|
|
71
|
+
background: radial-gradient(
|
|
72
|
+
circle at 30% 30%,
|
|
73
|
+
#3f4a65 0%,
|
|
74
|
+
#181e30 40%,
|
|
75
|
+
#090a10 100%
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
50% {
|
|
79
|
+
background: radial-gradient(
|
|
80
|
+
circle at 30% 30%,
|
|
81
|
+
#3a5065 0%,
|
|
82
|
+
#152230 40%,
|
|
83
|
+
#080a10 100%
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
75% {
|
|
87
|
+
background: radial-gradient(
|
|
88
|
+
circle at 30% 30%,
|
|
89
|
+
#3f4a65 0%,
|
|
90
|
+
#181e30 40%,
|
|
91
|
+
#090a10 100%
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.ball::before {
|
|
97
|
+
content: "";
|
|
98
|
+
position: absolute;
|
|
99
|
+
top: 8%;
|
|
100
|
+
left: 20%;
|
|
101
|
+
width: 30%;
|
|
102
|
+
height: 20%;
|
|
103
|
+
background: radial-gradient(
|
|
104
|
+
ellipse,
|
|
105
|
+
rgba(255, 255, 255, 0.3) 0%,
|
|
106
|
+
transparent 70%
|
|
107
|
+
);
|
|
108
|
+
border-radius: 50%;
|
|
109
|
+
pointer-events: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ball::after {
|
|
113
|
+
content: "";
|
|
114
|
+
position: absolute;
|
|
115
|
+
bottom: 8%;
|
|
116
|
+
right: 25%;
|
|
117
|
+
width: 25%;
|
|
118
|
+
height: 10%;
|
|
119
|
+
background: radial-gradient(
|
|
120
|
+
ellipse,
|
|
121
|
+
rgba(255, 255, 255, 0.1) 0%,
|
|
122
|
+
transparent 70%
|
|
123
|
+
);
|
|
124
|
+
border-radius: 50%;
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.question {
|
|
129
|
+
font-size: clamp(0.5rem, 2vw, 0.75rem);
|
|
130
|
+
color: lightgrey;
|
|
131
|
+
max-width: 90%;
|
|
132
|
+
word-wrap: break-word;
|
|
133
|
+
overflow-wrap: break-word;
|
|
134
|
+
text-align: center;
|
|
135
|
+
line-height: 1.3;
|
|
136
|
+
font-style: italic;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.answer {
|
|
140
|
+
font-family: "Playfair Display", serif;
|
|
141
|
+
font-style: italic;
|
|
142
|
+
font-size: 1.25rem;
|
|
143
|
+
font-weight: 600;
|
|
144
|
+
margin-top: 0.5rem;
|
|
145
|
+
color: #7dd3fc;
|
|
146
|
+
text-shadow: 0 0 10px rgba(125, 211, 252, 0.5);
|
|
147
|
+
max-width: 90%;
|
|
148
|
+
word-wrap: break-word;
|
|
149
|
+
overflow-wrap: break-word;
|
|
150
|
+
text-align: center;
|
|
151
|
+
line-height: 1.3;
|
|
152
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "@/index.css";
|
|
2
|
+
|
|
3
|
+
import { mountWidget } from "skybridge/web";
|
|
4
|
+
import { useToolInfo } from "../helpers.js";
|
|
5
|
+
|
|
6
|
+
function Magic8Ball() {
|
|
7
|
+
const { input, output } = useToolInfo<"magic-8-ball">();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<div className="container">
|
|
11
|
+
<div className="ball">
|
|
12
|
+
{output ? (
|
|
13
|
+
<>
|
|
14
|
+
<div className="question">{input.question}</div>
|
|
15
|
+
<div className="answer">{output.answer}</div>
|
|
16
|
+
</>
|
|
17
|
+
) : (
|
|
18
|
+
<div className="question">Shaking...</div>
|
|
19
|
+
)}
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default Magic8Ball;
|
|
26
|
+
|
|
27
|
+
mountWidget(<Magic8Ball />);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import { skybridge } from "skybridge/web";
|
|
4
|
+
import { defineConfig, type PluginOption } from "vite";
|
|
5
|
+
|
|
6
|
+
// https://vite.dev/config/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [skybridge() as PluginOption, react()],
|
|
9
|
+
root: __dirname,
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
"@": path.resolve(__dirname, "./src"),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|