create-skybridge 0.0.0-dev.edc0ede → 0.0.0-dev.eea25a3
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.js +4 -70
- package/dist/index.test.js +1 -2
- package/package.json +1 -1
- package/template/.cursor/mcp.json +7 -0
- package/template/.nvmrc +1 -0
- package/template/.vscode/launch.json +16 -0
- package/template/.vscode/settings.json +3 -0
- package/template/.vscode/tasks.json +14 -0
- package/template/README.md +69 -19
- package/template/_gitignore +192 -2
- package/template/docs/demo.gif +0 -0
- package/template/pnpm-lock.yaml +317 -0
- package/template/server/package.json +4 -0
- package/template/server/pnpm-lock.yaml +3796 -0
- package/template/server/src/env.ts +12 -0
- package/template/server/src/index.ts +3 -4
- package/template/server/src/pokedex.ts +148 -0
- package/template/server/src/server.ts +60 -50
- package/template/web/components.json +22 -0
- package/template/web/package.json +9 -1
- package/template/web/pnpm-lock.yaml +2629 -0
- package/template/web/src/components/ui/shadcn-io/spinner/index.tsx +272 -0
- package/template/web/src/helpers.ts +1 -1
- package/template/web/src/index.css +113 -23
- package/template/web/src/utils.ts +6 -0
- package/template/web/src/widgets/pokemon.tsx +203 -0
- package/template/web/vite.config.ts +2 -1
- package/template/web/src/widgets/magic-8-ball.tsx +0 -22
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import "dotenv/config";
|
|
2
|
+
|
|
3
|
+
import { createEnv } from "@t3-oss/env-core";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
|
|
6
|
+
export const env = createEnv({
|
|
7
|
+
server: {
|
|
8
|
+
NODE_ENV: z.enum(["development", "production"]).default("development"),
|
|
9
|
+
},
|
|
10
|
+
runtimeEnv: process.env,
|
|
11
|
+
emptyStringAsUndefined: true,
|
|
12
|
+
});
|
|
@@ -2,6 +2,7 @@ import express, { type Express } from "express";
|
|
|
2
2
|
|
|
3
3
|
import { widgetsDevServer } from "skybridge/server";
|
|
4
4
|
import type { ViteDevServer } from "vite";
|
|
5
|
+
import { env } from "./env.js";
|
|
5
6
|
import { mcp } from "./middleware.js";
|
|
6
7
|
import server from "./server.js";
|
|
7
8
|
|
|
@@ -11,9 +12,7 @@ app.use(express.json());
|
|
|
11
12
|
|
|
12
13
|
app.use(mcp(server));
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (env !== "production") {
|
|
15
|
+
if (env.NODE_ENV !== "production") {
|
|
17
16
|
app.use(await widgetsDevServer());
|
|
18
17
|
}
|
|
19
18
|
|
|
@@ -23,7 +22,7 @@ app.listen(3000, (error) => {
|
|
|
23
22
|
process.exit(1);
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
console.log(`Server listening on port 3000 - ${env}`);
|
|
25
|
+
console.log(`Server listening on port 3000 - ${env.NODE_ENV}`);
|
|
27
26
|
console.log(
|
|
28
27
|
"Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
|
|
29
28
|
);
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export const getPokemon = async (name: string) => {
|
|
2
|
+
const query = `
|
|
3
|
+
query getPokemon($name: String!, $language: String!) {
|
|
4
|
+
pokemon(where: {name: {_eq: $name} is_default: {_eq: true}}) {
|
|
5
|
+
id
|
|
6
|
+
order
|
|
7
|
+
height
|
|
8
|
+
weight
|
|
9
|
+
pokemonstats {
|
|
10
|
+
base_stat
|
|
11
|
+
stat {
|
|
12
|
+
name
|
|
13
|
+
statnames(where: {language: {name: {_eq: $language}}}, limit: 1) {
|
|
14
|
+
name
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
pokemonabilities {
|
|
19
|
+
ability {
|
|
20
|
+
name
|
|
21
|
+
abilitynames(where: {language: {name: {_eq: $language}}}, limit: 1) {
|
|
22
|
+
name
|
|
23
|
+
}
|
|
24
|
+
abilityflavortexts(where: {language: {name: {_eq: $language}}}, limit: 1) {
|
|
25
|
+
flavor_text
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
pokemonsprites {
|
|
30
|
+
sprites
|
|
31
|
+
}
|
|
32
|
+
pokemontypes {
|
|
33
|
+
type {
|
|
34
|
+
name
|
|
35
|
+
typenames(where: {language: {name: {_eq: $language}}}, limit: 1) {
|
|
36
|
+
name
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
pokemonspecy {
|
|
41
|
+
pokemoncolor {
|
|
42
|
+
name
|
|
43
|
+
}
|
|
44
|
+
evolutionchain {
|
|
45
|
+
pokemonspecies {
|
|
46
|
+
pokemons(where: {is_default: {_eq: true}}) {
|
|
47
|
+
name
|
|
48
|
+
order
|
|
49
|
+
pokemonsprites {
|
|
50
|
+
sprites
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
pokemonspeciesflavortexts(where: {language: {name: {_eq: $language}}}, limit: 1) {
|
|
56
|
+
flavor_text
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const response = await fetch("https://graphql.pokeapi.co/v1beta2", {
|
|
64
|
+
method: "POST",
|
|
65
|
+
headers: {
|
|
66
|
+
"Content-Type": "application/json",
|
|
67
|
+
},
|
|
68
|
+
body: JSON.stringify({
|
|
69
|
+
query,
|
|
70
|
+
variables: { name: name.toLowerCase(), language: "en" },
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const result = await response.json();
|
|
75
|
+
const pokemon = result.data.pokemon[0] as {
|
|
76
|
+
id: number;
|
|
77
|
+
order: number;
|
|
78
|
+
height: number;
|
|
79
|
+
weight: number;
|
|
80
|
+
pokemonspecy: {
|
|
81
|
+
pokemoncolor: { name: string };
|
|
82
|
+
pokemonspeciesflavortexts: { flavor_text: string }[];
|
|
83
|
+
evolutionchain: {
|
|
84
|
+
pokemonspecies: {
|
|
85
|
+
pokemons: {
|
|
86
|
+
name: string;
|
|
87
|
+
order: number;
|
|
88
|
+
pokemonsprites: { sprites: { front_default: string } }[];
|
|
89
|
+
}[];
|
|
90
|
+
}[];
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
pokemonsprites: { sprites: { front_default: string } }[];
|
|
94
|
+
pokemonstats: {
|
|
95
|
+
base_stat: number;
|
|
96
|
+
stat: { name: string; statnames: { name: string }[] };
|
|
97
|
+
}[];
|
|
98
|
+
pokemontypes: {
|
|
99
|
+
type: { name: string; typenames: { name: string }[] };
|
|
100
|
+
}[];
|
|
101
|
+
pokemonabilities: {
|
|
102
|
+
ability: {
|
|
103
|
+
name: string;
|
|
104
|
+
abilitynames: { name: string }[];
|
|
105
|
+
abilityflavortexts: { flavor_text: string }[];
|
|
106
|
+
};
|
|
107
|
+
}[];
|
|
108
|
+
} | null;
|
|
109
|
+
|
|
110
|
+
if (!pokemon) {
|
|
111
|
+
throw new Error(`Pokemon ${name} not found`);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id: pokemon.id,
|
|
116
|
+
color: pokemon.pokemonspecy.pokemoncolor.name,
|
|
117
|
+
order: pokemon.order,
|
|
118
|
+
heightInMeters: pokemon.height / 10,
|
|
119
|
+
weightInKilograms: pokemon.weight / 10,
|
|
120
|
+
imageUrl: pokemon.pokemonsprites[0].sprites.front_default,
|
|
121
|
+
description: pokemon.pokemonspecy.pokemonspeciesflavortexts[0]?.flavor_text
|
|
122
|
+
.replace(/\n/g, " ")
|
|
123
|
+
.replace(/\.(?![^.]*$)/g, ". "),
|
|
124
|
+
stats: pokemon.pokemonstats.map((stat) => ({
|
|
125
|
+
id: stat.stat.name,
|
|
126
|
+
name: stat.stat.statnames[0].name,
|
|
127
|
+
value: stat.base_stat,
|
|
128
|
+
})),
|
|
129
|
+
types: pokemon.pokemontypes.map((type) => ({
|
|
130
|
+
id: type.type.name,
|
|
131
|
+
name: type.type.typenames[0].name,
|
|
132
|
+
})),
|
|
133
|
+
abilities: pokemon.pokemonabilities.map((ability) => ({
|
|
134
|
+
id: ability.ability.name,
|
|
135
|
+
name: ability.ability.abilitynames[0].name,
|
|
136
|
+
description: ability.ability.abilityflavortexts[0]?.flavor_text
|
|
137
|
+
.replace(/\n/g, " ")
|
|
138
|
+
.replace(/\.(?![^.]*$)/g, ". "),
|
|
139
|
+
})),
|
|
140
|
+
evolutions: pokemon.pokemonspecy.evolutionchain.pokemonspecies.map(
|
|
141
|
+
({ pokemons: [pokemon] }) => ({
|
|
142
|
+
id: pokemon.name,
|
|
143
|
+
order: pokemon.order,
|
|
144
|
+
imageUrl: pokemon.pokemonsprites[0].sprites.front_default,
|
|
145
|
+
}),
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
};
|
|
@@ -1,28 +1,6 @@
|
|
|
1
1
|
import { McpServer } from "skybridge/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
|
|
4
|
-
const Answers = [
|
|
5
|
-
"As I see it, yes",
|
|
6
|
-
"Ask again later",
|
|
7
|
-
"Better not tell you now",
|
|
8
|
-
"Cannot predict now",
|
|
9
|
-
"Concentrate and ask again",
|
|
10
|
-
"Don't count on it",
|
|
11
|
-
"It is certain",
|
|
12
|
-
"It is decidedly so",
|
|
13
|
-
"Most likely",
|
|
14
|
-
"My reply is no",
|
|
15
|
-
"My sources say no",
|
|
16
|
-
"Outlook good",
|
|
17
|
-
"Outlook not so good",
|
|
18
|
-
"Reply hazy, try again",
|
|
19
|
-
"Signs point to yes",
|
|
20
|
-
"Very doubtful",
|
|
21
|
-
"Without a doubt",
|
|
22
|
-
"Yes definitely",
|
|
23
|
-
"Yes",
|
|
24
|
-
"You may rely on it",
|
|
25
|
-
];
|
|
3
|
+
import { getPokemon } from "./pokedex.js";
|
|
26
4
|
|
|
27
5
|
const server = new McpServer(
|
|
28
6
|
{
|
|
@@ -30,37 +8,69 @@ const server = new McpServer(
|
|
|
30
8
|
version: "0.0.1",
|
|
31
9
|
},
|
|
32
10
|
{ capabilities: {} },
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
description: "For fortune-telling or seeking advice.",
|
|
40
|
-
inputSchema: {
|
|
41
|
-
question: z.string().describe("The user question."),
|
|
11
|
+
)
|
|
12
|
+
.registerWidget(
|
|
13
|
+
"pokemon",
|
|
14
|
+
{
|
|
15
|
+
description: "Pokedex entry for a pokemon",
|
|
42
16
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
17
|
+
{
|
|
18
|
+
description:
|
|
19
|
+
"Use this tool to get the most up to date information about a pokemon, using its name in english. This pokedex is much more complete than any other web_search tool. Always use it for anything related to pokemons.",
|
|
20
|
+
inputSchema: {
|
|
21
|
+
name: z.string().describe("Pokemon name, always in english"),
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async ({ name }) => {
|
|
25
|
+
try {
|
|
26
|
+
const { id, description, ...pokemon } = await getPokemon(name);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
/**
|
|
30
|
+
* Arbitrary JSON passed only to the component.
|
|
31
|
+
* Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
|
|
32
|
+
* _meta is never shown to the model.
|
|
33
|
+
*/
|
|
34
|
+
_meta: { id },
|
|
35
|
+
/**
|
|
36
|
+
* Structured data that is used to hydrate your component.
|
|
37
|
+
* ChatGPT injects this object into your iframe as window.openai.toolOutput
|
|
38
|
+
*/
|
|
39
|
+
structuredContent: { name, description, ...pokemon },
|
|
40
|
+
/**
|
|
41
|
+
* Optional free-form text that the model receives verbatim
|
|
42
|
+
*/
|
|
43
|
+
content: [
|
|
44
|
+
{
|
|
45
|
+
type: "text",
|
|
46
|
+
text: description ?? `A pokemon named ${name}.`,
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
isError: false,
|
|
50
|
+
};
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return {
|
|
53
|
+
content: [{ type: "text", text: `Error: ${error}` }],
|
|
54
|
+
isError: true,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
)
|
|
59
|
+
.registerTool(
|
|
60
|
+
"capture",
|
|
61
|
+
{
|
|
62
|
+
description: "Capture a pokemon",
|
|
63
|
+
inputSchema: {},
|
|
64
|
+
},
|
|
65
|
+
async () => {
|
|
51
66
|
return {
|
|
52
|
-
|
|
53
|
-
|
|
67
|
+
content: [
|
|
68
|
+
{ type: "text", text: `Great job, you've captured a new pokemon!` },
|
|
69
|
+
],
|
|
54
70
|
isError: false,
|
|
55
71
|
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
content: [{ type: "text", text: `Error: ${error}` }],
|
|
59
|
-
isError: true,
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
);
|
|
72
|
+
},
|
|
73
|
+
);
|
|
64
74
|
|
|
65
75
|
export default server;
|
|
66
76
|
export type AppType = typeof server;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema.json",
|
|
3
|
+
"style": "new-york",
|
|
4
|
+
"rsc": false,
|
|
5
|
+
"tsx": true,
|
|
6
|
+
"tailwind": {
|
|
7
|
+
"config": "",
|
|
8
|
+
"css": "src/index.css",
|
|
9
|
+
"baseColor": "neutral",
|
|
10
|
+
"cssVariables": true,
|
|
11
|
+
"prefix": ""
|
|
12
|
+
},
|
|
13
|
+
"iconLibrary": "lucide",
|
|
14
|
+
"aliases": {
|
|
15
|
+
"components": "@/components",
|
|
16
|
+
"utils": "@/lib/utils",
|
|
17
|
+
"ui": "@/components/ui",
|
|
18
|
+
"lib": "@/lib",
|
|
19
|
+
"hooks": "@/hooks"
|
|
20
|
+
},
|
|
21
|
+
"registries": {}
|
|
22
|
+
}
|
|
@@ -10,14 +10,22 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"skybridge": "catalog:",
|
|
13
|
+
"class-variance-authority": "^0.7.1",
|
|
14
|
+
"clsx": "^2.1.1",
|
|
15
|
+
"glob": "^11.0.3",
|
|
16
|
+
"lucide-react": "^0.546.0",
|
|
13
17
|
"react": "^19.1.1",
|
|
14
|
-
"react-dom": "^19.1.1"
|
|
18
|
+
"react-dom": "^19.1.1",
|
|
19
|
+
"tailwind-merge": "^3.3.1",
|
|
20
|
+
"tailwindcss": "^4.1.14"
|
|
15
21
|
},
|
|
16
22
|
"devDependencies": {
|
|
23
|
+
"@tailwindcss/vite": "^4.1.14",
|
|
17
24
|
"@types/node": "^24.6.0",
|
|
18
25
|
"@types/react": "^19.1.16",
|
|
19
26
|
"@types/react-dom": "^19.1.9",
|
|
20
27
|
"@vitejs/plugin-react": "^5.0.4",
|
|
28
|
+
"tw-animate-css": "^1.4.0",
|
|
21
29
|
"typescript": "~5.9.3",
|
|
22
30
|
"vite": "^7.1.11"
|
|
23
31
|
}
|