create-skybridge 0.0.0-dev.10bf56b → 0.0.0-dev.1139380

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.10bf56b",
3
+ "version": "0.0.0-dev.1139380",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -44,31 +44,34 @@ This command starts:
44
44
  #### 3. Project structure
45
45
 
46
46
  ```
47
- ├── src/
48
- ├── server.ts # Server entry point
49
- ├── views/ # React components (one per view)
50
- ├── components/ # Shared UI components
51
- │ ├── helpers.ts # Shared utilities
52
- └── index.css # Global styles
53
- ├── vite.config.ts
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
54
56
  ├── alpic.json # Deployment config
57
+ ├── nodemon.json # Dev server config
55
58
  └── package.json
56
59
  ```
57
60
 
58
- ### Create your first view
61
+ ### Create your first widget
59
62
 
60
- #### 1. Add a new view
63
+ #### 1. Add a new widget
61
64
 
62
- - Register a tool in `src/server.ts` with a unique name (e.g., `my-view`) using [`registerTool`](https://docs.skybridge.tech/api-reference/register-tool) and a `view` config.
63
- - Create a matching React component at `src/views/my-view.tsx`. **The file name must match the view name exactly**.
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**.
64
67
 
65
- #### 2. Edit views with Hot Module Replacement (HMR)
68
+ #### 2. Edit widgets with Hot Module Replacement (HMR)
66
69
 
67
- Edit and save components in `src/views/` — changes will appear instantly inside your App.
70
+ Edit and save components in `web/src/widgets/` — changes will appear instantly inside your App.
68
71
 
69
72
  #### 3. Edit server code
70
73
 
71
- Modify files in `src/` and refresh the connection with your testing MCP Client to see the changes.
74
+ Modify files in `server/` and refresh the connection with your testing MCP Client to see the changes.
72
75
 
73
76
  ### Testing your App
74
77
 
@@ -2,5 +2,4 @@ node_modules/
2
2
  dist/
3
3
  .env*
4
4
  .DS_store
5
- *.tsbuildinfo
6
- .skybridge/
5
+ *.tsbuildinfo
@@ -10,9 +10,9 @@ case `uname` in
10
10
  esac
11
11
 
12
12
  if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
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
14
  else
15
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
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
16
  fi
17
17
  if [ -x "$basedir/node" ]; then
18
18
  exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
@@ -10,9 +10,9 @@ case `uname` in
10
10
  esac
11
11
 
12
12
  if [ -z "$NODE_PATH" ]; then
13
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
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
14
  else
15
- export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
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
16
  fi
17
17
  if [ -x "$basedir/node" ]; then
18
18
  exec "$basedir/node" "$basedir/../skybridge/bin/run.js" "$@"
@@ -15,14 +15,14 @@
15
15
  "@modelcontextprotocol/sdk": "^1.29.0",
16
16
  "react": "^19.2.4",
17
17
  "react-dom": "^19.2.4",
18
- "skybridge": ">=0.0.0-dev.10bf56b",
18
+ "skybridge": ">=0.35.14 <1.0.0",
19
19
  "vite": "^8.0.3",
20
20
  "zod": "^4.3.6"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@skybridge/devtools": ">=0.35.14 <1.0.0",
24
- "@types/node": "^24.12.0",
25
24
  "@types/react": "^19.2.14",
25
+ "@types/node": "^24.12.0",
26
26
  "@types/react-dom": "^19.2.3",
27
27
  "@vitejs/plugin-react": "^6.0.1",
28
28
  "alpic": "^1.104.1",
@@ -0,0 +1,82 @@
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
+ )
29
+ .registerWidget(
30
+ "magic-8-ball",
31
+ {
32
+ description: "Magic 8 Ball",
33
+ },
34
+ {
35
+ description: "For fortune-telling or seeking advice.",
36
+ inputSchema: {
37
+ question: z.string().describe("The user question."),
38
+ maxAnswers: z
39
+ .number()
40
+ .describe("The maximum number of answers to return.")
41
+ .optional(),
42
+ includeRandom: z
43
+ .boolean()
44
+ .describe("Whether to include a random answer.")
45
+ .optional(),
46
+ },
47
+ },
48
+ async ({ question }) => {
49
+ try {
50
+ // deterministic answer
51
+ const hash = question
52
+ .split("")
53
+ .reduce((acc, char) => acc + char.charCodeAt(0), 0);
54
+ const answer = Answers[hash % Answers.length];
55
+ return {
56
+ structuredContent: { answer },
57
+ content: [],
58
+ isError: false,
59
+ };
60
+ } catch (error) {
61
+ return {
62
+ content: [{ type: "text", text: `Error: ${error}` }],
63
+ isError: true,
64
+ };
65
+ }
66
+ },
67
+ )
68
+ .registerTool(
69
+ "get-answers",
70
+ {
71
+ description: "Get answers",
72
+ },
73
+ async () => {
74
+ return {
75
+ content: [{ type: "text", text: "Answers" }],
76
+ };
77
+ },
78
+ );
79
+
80
+ server.run();
81
+
82
+ export type AppType = typeof server;
@@ -2,10 +2,12 @@
2
2
  "extends": "skybridge/tsconfig",
3
3
 
4
4
  "compilerOptions": {
5
+ "outDir": "dist",
6
+ "types": ["node", "vite/client"],
5
7
  "paths": {
6
- "@/*": ["./src/*"]
8
+ "@/*": ["./web/src/*"]
7
9
  }
8
10
  },
9
11
 
10
- "include": ["src", ".skybridge/**/*.d.ts"]
12
+ "include": ["server/src", "web/src"]
11
13
  }
@@ -0,0 +1,4 @@
1
+ import { generateHelpers } from "skybridge/web";
2
+ import type { AppType } from "../../server/src/index.js";
3
+
4
+ export const { useToolInfo } = generateHelpers<AppType>();
@@ -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 />);
@@ -1,10 +1,12 @@
1
1
  import path from "node:path";
2
2
  import react from "@vitejs/plugin-react";
3
3
  import { skybridge } from "skybridge/web";
4
- import { defineConfig } from "vite";
4
+ import { defineConfig, type PluginOption } from "vite";
5
5
 
6
+ // https://vite.dev/config/
6
7
  export default defineConfig({
7
- plugins: [skybridge(), react()],
8
+ plugins: [skybridge() as PluginOption, react()],
9
+ root: __dirname,
8
10
  resolve: {
9
11
  alias: {
10
12
  "@": path.resolve(__dirname, "./src"),
@@ -1,22 +0,0 @@
1
- export function Ball({
2
- question,
3
- answer,
4
- }: {
5
- question?: string;
6
- answer?: string;
7
- }) {
8
- return (
9
- <div className="container">
10
- <div className="ball">
11
- {answer ? (
12
- <>
13
- <div className="question">{question}</div>
14
- <div className="answer">{answer}</div>
15
- </>
16
- ) : (
17
- <div className="question">Shaking...</div>
18
- )}
19
- </div>
20
- </div>
21
- );
22
- }
@@ -1,4 +0,0 @@
1
- import { generateHelpers } from "skybridge/web";
2
- import type { AppType } from "./server.js";
3
-
4
- export const { useToolInfo, useCallTool } = generateHelpers<AppType>();
@@ -1,61 +0,0 @@
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
- ).registerTool(
29
- {
30
- name: "magic-8-ball",
31
- description: "For fortune-telling or seeking advice.",
32
- inputSchema: {
33
- question: z.string().describe("The user question."),
34
- },
35
- view: {
36
- component: "magic-8-ball",
37
- description: "Magic 8 Ball",
38
- },
39
- },
40
- async ({ question }) => {
41
- try {
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
- isError: false,
49
- };
50
- } catch (error) {
51
- return {
52
- content: [{ type: "text", text: `Error: ${error}` }],
53
- isError: true,
54
- };
55
- }
56
- },
57
- );
58
-
59
- server.run();
60
-
61
- export type AppType = typeof server;
@@ -1,10 +0,0 @@
1
- import "@/index.css";
2
-
3
- import { Ball } from "../components/ball.js";
4
- import { useToolInfo } from "../helpers.js";
5
-
6
- export default function Magic8Ball() {
7
- const { input, output } = useToolInfo<"magic-8-ball">();
8
-
9
- return <Ball question={input?.question} answer={output?.answer} />;
10
- }
File without changes