create-skybridge 0.0.0-dev.eea25a3 → 0.0.0-dev.f762713

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alpic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -1,8 +1,10 @@
1
+ import { spawnSync } from "node:child_process";
1
2
  import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import { fileURLToPath } from "node:url";
4
5
  import * as prompts from "@clack/prompts";
5
6
  import mri from "mri";
7
+ const minimumPnpmVersion = 10;
6
8
  const defaultProjectName = "skybridge-project";
7
9
  // prettier-ignore
8
10
  const helpMessage = `\
@@ -13,20 +15,22 @@ Create a new Skybridge project by copying the starter template.
13
15
  Options:
14
16
  -h, --help show this help message
15
17
  --overwrite remove existing files in target directory
18
+ --immediate install dependencies and start development server
16
19
 
17
20
  Examples:
18
21
  create-skybridge my-app
19
- create-skybridge . --overwrite
22
+ create-skybridge . --overwrite --immediate
20
23
  `;
21
24
  export async function init(args = process.argv.slice(2)) {
22
25
  const argv = mri(args, {
23
- boolean: ["help", "overwrite"],
26
+ boolean: ["help", "overwrite", "immediate"],
24
27
  alias: { h: "help" },
25
28
  });
26
29
  const argTargetDir = argv._[0]
27
30
  ? sanitizeTargetDir(String(argv._[0]))
28
31
  : undefined;
29
32
  const argOverwrite = argv.overwrite;
33
+ const argImmediate = argv.immediate;
30
34
  const help = argv.help;
31
35
  if (help) {
32
36
  console.log(helpMessage);
@@ -48,8 +52,9 @@ export async function init(args = process.argv.slice(2)) {
48
52
  : "Invalid project name";
49
53
  },
50
54
  });
51
- if (prompts.isCancel(projectName))
55
+ if (prompts.isCancel(projectName)) {
52
56
  return cancel();
57
+ }
53
58
  targetDir = sanitizeTargetDir(projectName);
54
59
  }
55
60
  else {
@@ -77,8 +82,9 @@ export async function init(args = process.argv.slice(2)) {
77
82
  },
78
83
  ],
79
84
  });
80
- if (prompts.isCancel(res))
85
+ if (prompts.isCancel(res)) {
81
86
  return cancel();
87
+ }
82
88
  overwrite = res;
83
89
  }
84
90
  else {
@@ -100,7 +106,10 @@ export async function init(args = process.argv.slice(2)) {
100
106
  try {
101
107
  const templateDir = fileURLToPath(new URL("../template", import.meta.url));
102
108
  // Copy template to target directory
103
- fs.cpSync(templateDir, root, { recursive: true });
109
+ fs.cpSync(templateDir, root, {
110
+ recursive: true,
111
+ filter: (src) => !src.endsWith(".npmrc"),
112
+ });
104
113
  // Rename _gitignore to .gitignore
105
114
  fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
106
115
  // Update project name in package.json
@@ -112,13 +121,72 @@ export async function init(args = process.argv.slice(2)) {
112
121
  fs.writeFileSync(pkgPath, fixed);
113
122
  }
114
123
  prompts.log.success(`Project created in ${root}`);
115
- prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
116
124
  }
117
125
  catch (error) {
118
126
  prompts.log.error("Failed to copy repository");
119
127
  console.error(error);
120
128
  process.exit(1);
121
129
  }
130
+ // 4. Ask about immediate installation
131
+ let immediate = argImmediate;
132
+ if (immediate === undefined) {
133
+ if (interactive) {
134
+ const immediateResult = await prompts.confirm({
135
+ message: `Install with pnpm and start now?`,
136
+ });
137
+ if (prompts.isCancel(immediateResult)) {
138
+ return cancel();
139
+ }
140
+ immediate = immediateResult;
141
+ }
142
+ else {
143
+ immediate = false;
144
+ }
145
+ }
146
+ const installCmd = ["pnpm", "install"];
147
+ const runCmd = ["pnpm", "dev"];
148
+ if (!immediate) {
149
+ prompts.outro(`Done! Next steps:
150
+ cd ${targetDir}
151
+ ${installCmd.join(" ")}
152
+ ${runCmd.join(" ")}
153
+ `);
154
+ return;
155
+ }
156
+ // check if pnpm is installed
157
+ const result = spawnSync("pnpm", ["--version"], { encoding: "utf-8" });
158
+ if (result.error || result.status !== 0) {
159
+ console.error("Error: pnpm is not installed. Please install pnpm first.");
160
+ process.exit(1);
161
+ }
162
+ // check if pnpm major is greater or equal to the one set in package.json packageManager, which should do the trick
163
+ const version = result.stdout.trim();
164
+ const major = Number(version.split(".")[0]);
165
+ if (Number.isNaN(major) || major < minimumPnpmVersion) {
166
+ console.error(`Error: pnpm version ${version} is too old. Minimum required version is ${minimumPnpmVersion}.`);
167
+ process.exit(1);
168
+ }
169
+ prompts.log.step(`Installing dependencies with pnpm...`);
170
+ run(installCmd, {
171
+ stdio: "inherit",
172
+ cwd: root,
173
+ });
174
+ prompts.log.step("Starting dev server...");
175
+ run(runCmd, {
176
+ stdio: "inherit",
177
+ cwd: root,
178
+ });
179
+ }
180
+ function run([command, ...args], options) {
181
+ const { status, error } = spawnSync(command, args, options);
182
+ if (status != null && status > 0) {
183
+ process.exit(status);
184
+ }
185
+ if (error) {
186
+ console.error(`\n${command} ${args.join(" ")} error!`);
187
+ console.error(error);
188
+ process.exit(1);
189
+ }
122
190
  }
123
191
  function sanitizeTargetDir(targetDir) {
124
192
  return (targetDir
@@ -1,7 +1,7 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  import fs from "node:fs/promises";
3
3
  import path from "node:path";
4
- import { afterEach, beforeEach, describe, it } from "vitest";
4
+ import { afterEach, beforeEach, describe, expect, it } from "vitest";
5
5
  import { init } from "./index.js";
6
6
  describe("create-skybridge", () => {
7
7
  let tempDirName;
@@ -18,5 +18,6 @@ describe("create-skybridge", () => {
18
18
  const name = `../../${tempDirName}//project$`;
19
19
  await init([name]);
20
20
  await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
+ expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
21
22
  });
22
23
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.eea25a3",
3
+ "version": "0.0.0-dev.f762713",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -16,14 +16,6 @@
16
16
  "dist",
17
17
  "template"
18
18
  ],
19
- "scripts": {
20
- "build": "tsc",
21
- "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
22
- "test:unit": "vitest run",
23
- "test:type": "tsc --noEmit",
24
- "test:format": "biome ci",
25
- "prepublishOnly": "pnpm run build"
26
- },
27
19
  "dependencies": {
28
20
  "@clack/prompts": "^0.11.0",
29
21
  "mri": "^1.2.0"
@@ -32,5 +24,12 @@
32
24
  "@types/node": "^25.0.3",
33
25
  "typescript": "^5.9.3",
34
26
  "vitest": "^2.1.9"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
31
+ "test:unit": "vitest run",
32
+ "test:type": "tsc --noEmit",
33
+ "test:format": "biome ci"
35
34
  }
36
- }
35
+ }
@@ -1,24 +1,16 @@
1
1
  # ChatGPT Apps SDK Alpic Starter
2
2
 
3
- This repository is a minimal Typescript application demonstrating how to build an OpenAI Apps SDK compatible MCP server with widget rendering in ChatGPT.
4
-
5
- ![Demo](docs/demo.gif)
6
-
7
- ## Overview
8
-
9
- This project shows how to integrate a Typescript express application with the ChatGPT Apps SDK using the Model Context Protocol (MCP). It includes a working MCP server that exposes tools and resources that can be called from ChatGPT, with responses rendered natively in ChatGPT. It also includes MCP tools without UI widgets.
3
+ A minimal TypeScript template for building OpenAI Apps SDK compatible MCP servers with widget rendering in ChatGPT.
10
4
 
11
5
  ## Getting Started
12
6
 
13
7
  ### Prerequisites
14
8
 
15
- - Node.js 22+ (see `.nvmrc` for exact version)
9
+ - Node.js 22+
16
10
  - pnpm (install with `npm install -g pnpm`)
17
- - Ngrok
11
+ - HTTP tunnel such as [ngrok](https://ngrok.com/download)
18
12
 
19
- ### Local Development with Hot Module Replacement (HMR)
20
-
21
- This project uses Vite for React widget development with full HMR support, allowing you to see changes in real-time, directly within ChatGPT conversation, without restarting the server.
13
+ ### Local Development
22
14
 
23
15
  #### 1. Install
24
16
 
@@ -26,7 +18,7 @@ This project uses Vite for React widget development with full HMR support, allow
26
18
  pnpm install
27
19
  ```
28
20
 
29
- #### 2. Start the Development Server
21
+ #### 2. Start your local server
30
22
 
31
23
  Run the development server from the root directory:
32
24
 
@@ -36,79 +28,37 @@ pnpm dev
36
28
 
37
29
  This command starts an Express server on port 3000. This server packages:
38
30
 
39
- - an MCP endpoint on `/mcp` - aka the ChatGPT App Backend
40
- - a React application on Vite HMR dev server - aka the ChatGPT App Frontend
41
-
42
- #### 3. Expose Your Local Server
31
+ - an MCP endpoint on `/mcp` (the app backend)
32
+ - a React application on Vite HMR dev server (the UI elements to be displayed in ChatGPT)
43
33
 
44
- In a separate terminal, expose your local server using ngrok:
34
+ #### 3. Connect to ChatGPT
45
35
 
36
+ - ChatGPT requires connectors to be publicly accessible. To expose your server on the Internet, run:
46
37
  ```bash
47
38
  ngrok http 3000
48
39
  ```
40
+ - In ChatGPT, navigate to **Settings → Connectors → Create** and add the forwarding URL provided by ngrok suffixed with `/mcp` (e.g. `https://3785c5ddc4b6.ngrok-free.app/mcp`)
49
41
 
50
- Copy the forwarding URL from ngrok output:
51
-
52
- ```bash
53
- Forwarding https://3785c5ddc4b6.ngrok-free.app -> http://localhost:3000
54
- ```
55
-
56
- #### 4. Connect to ChatGPT
57
-
58
- - Enable **Settings → Connectors → Advanced → Developer mode** in the ChatGPT client
59
- - Navigate to **Settings → Connectors → Create**
60
- - Enter your ngrok URL with the `/mcp` path (e.g., `https://3785c5ddc4b6.ngrok-free.app/mcp`)
61
- - Click **Create**
62
-
63
- #### 5. Test Your Integration
42
+ ### Create your first widget
64
43
 
65
- - Start a new conversation in ChatGPT
66
- - Select your newly created connector using **the + button → Your connector**
67
- - Try prompting the model (e.g., "Show me pikachu details")
44
+ #### 1. Add a new widget
68
45
 
69
- #### 6. Develop with HMR
46
+ - Register a widget in `server/server.ts` with a unique name (e.g., `my-widget`)
47
+ - Create a matching React component at `web/src/widgets/my-widget.tsx`. The file name must match the widget name exactly
70
48
 
71
- Now you can edit React components in `web` and see changes instantly:
49
+ #### 2. Edit widgets with Hot Module Replacement (HMR)
72
50
 
73
- - Make changes to any component
74
- - Save the file
75
- - The widget will automatically update in ChatGPT without refreshing or reconnecting
76
- - The Express server and MCP server continue running without interruption
51
+ Edit and save components in `web/src/widgets/` — changes appear instantly in ChatGPT
77
52
 
78
- **Note:** When you modify widget components, changes will be reflected immediately. If you modify MCP server code (in `src/`), you may need to reload your connector in **Settings → Connectors → [Your connector] → Reload**.
53
+ #### 3. Edit server code
79
54
 
80
- ## Widget Naming Convention
81
-
82
- **Important:** For a widget to work properly, the name of the endpoint in your MCP server must match the file name of the corresponding React component in `web/src/widgets/`.
83
-
84
- For example:
85
-
86
- - If you create a widget endpoint named `pokemon-card`, you must create a corresponding React component file at `web/src/widgets/pokemon-card.tsx`
87
- - The endpoint name and the widget file name (without the `.tsx` extension) must be identical
88
-
89
- This naming convention allows the system to automatically map widget requests to their corresponding React components.
55
+ Modify files in `server/` and reload your ChatGPT connector in **Settings → Connectors → [Your connector] → Reload**
90
56
 
91
57
  ## Deploy to Production
92
58
 
93
- Use Alpic to deploy your OpenAI App to production.
94
-
95
- [![Deploy on Alpic](https://assets.alpic.ai/button.svg)](https://app.alpic.ai/new/clone?repositoryUrl=https%3A%2F%2Fgithub.com%2Falpic-ai%2Fapps-sdk-template)
96
-
59
+ - Use [Alpic](https://alpic.ai/) to deploy your OpenAI App to production
97
60
  - In ChatGPT, navigate to **Settings → Connectors → Create** and add your MCP server URL (e.g., `https://your-app-name.alpic.live`)
98
61
 
99
- ## Project Structure
100
-
101
- ```
102
- .
103
- ├── server/
104
- │ ├── app.ts # OpenAI App extension class with widget API implementation
105
- │ ├── server.ts # MCP server with tool/resource/prompt registration
106
- │ └── index.ts # Express server definition
107
- └── web/
108
- └── src/
109
- └── widgets/ # React widget components (must match endpoint names)
110
- ```
111
-
112
62
  ## Resources
113
63
 
114
64
  - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
@@ -1,194 +1,4 @@
1
- # =============================================================================
2
- # OPERATING SYSTEM FILES
3
- # =============================================================================
4
- .DS_Store
5
- .DS_Store?
6
- ._*
7
- .Spotlight-V100
8
- .Trashes
9
- ehthumbs.db
10
- Thumbs.db
11
-
12
- # =============================================================================
13
- # NODE.JS & PACKAGE MANAGERS
14
- # =============================================================================
15
1
  node_modules/
16
- npm-debug.log*
17
- yarn-debug.log*
18
- yarn-error.log*
19
- .pnpm-debug.log*
20
- .npm
21
- .pnp.js
22
- .pnp.cjs
23
- .pnp.mjs
24
- .pnp.json
25
- .pnp.ts
26
-
27
- # =============================================================================
28
- # TYPESCRIPT & JAVASCRIPT
29
- # =============================================================================
30
- *.tsbuildinfo
31
- .tscache/
32
- *.js.map
33
- *.mjs.map
34
- *.cjs.map
35
- *.d.ts.map
36
- *.d.ts
37
- !*.d.ts.template
38
- *.tgz
39
- .eslintcache
40
- .rollup.cache
41
-
42
- # =============================================================================
43
- # PYTHON
44
- # =============================================================================
45
- __pycache__/
46
- *.py[cod]
47
- *$py.class
48
- *.so
49
- .Python
50
- develop-eggs/
51
- eggs/
52
- .eggs/
53
- lib/
54
- lib64/
55
- parts/
56
- sdist/
57
- var/
58
- wheels/
59
- *.egg-info/
60
- .installed.cfg
61
- *.egg
62
- .pytest_cache/
63
- .coverage
64
- htmlcov/
65
- .tox/
66
- .venv
67
- venv/
68
- ENV/
69
-
70
- # =============================================================================
71
- # JAVA
72
- # =============================================================================
73
- *.class
74
- *.jar
75
- *.war
76
- *.nar
77
- *.ear
78
- hs_err_pid*
79
- target/
80
- .gradle/
81
-
82
- # =============================================================================
83
- # RUBY
84
- # =============================================================================
85
- *.gem
86
- *.rbc
87
- /.config
88
- /coverage/
89
- /InstalledFiles
90
- /pkg/
91
- /spec/reports/
92
- /spec/examples.txt
93
- /test/tmp/
94
- /test/version_tmp/
95
- /tmp/
96
- .byebug_history
97
-
98
- # =============================================================================
99
- # BUILD & DISTRIBUTION
100
- # =============================================================================
101
- build/
102
2
  dist/
103
- dist-ssr/
104
- out/
105
-
106
- # =============================================================================
107
- # COMPILED FILES
108
- # =============================================================================
109
- *.com
110
- *.dll
111
- *.exe
112
- *.o
113
-
114
- # =============================================================================
115
- # PACKAGE & ARCHIVE FILES
116
- # =============================================================================
117
- *.7z
118
- *.dmg
119
- *.gz
120
- *.iso
121
- *.rar
122
- *.tar
123
- *.tar.gz
124
- *.zip
125
-
126
- # =============================================================================
127
- # LOGS & DATABASES
128
- # =============================================================================
129
- *.log
130
- *.sql
131
- *.sqlite
132
- *.sqlite3
133
- logs/
134
-
135
- # =============================================================================
136
- # TESTING & COVERAGE
137
- # =============================================================================
138
- coverage/
139
- .nyc_output/
140
-
141
- # =============================================================================
142
- # CACHE & TEMPORARY FILES
143
- # =============================================================================
144
- .cache/
145
- .parcel-cache/
146
- *.bak
147
-
148
- # =============================================================================
149
- # ENVIRONMENT & CONFIGURATION
150
- # =============================================================================
151
- .env
152
- .env.local
153
- .env.development.local
154
- .env.test.local
155
- .env.production.local
156
- .sample-env
157
- sample.*
158
- !sample.template.*
159
- *.local
160
- mcp-servers.json
161
- mcp-config.json
162
-
163
- # =============================================================================
164
- # DEMO & EXAMPLE DIRECTORIES
165
- # =============================================================================
166
- demo/
167
- demos/
168
- example/
169
- examples/
170
- samples/
171
-
172
- # =============================================================================
173
- # GENERATED DOCUMENTATION
174
- # =============================================================================
175
- docs/api/
176
-
177
- # =============================================================================
178
- # EDITOR DIRECTORIES AND FILES
179
- # =============================================================================
180
- .vscode/*
181
- !.vscode/extensions.json
182
- .idea
183
- *.suo
184
- *.ntvs*
185
- *.njsproj
186
- *.sln
187
- *.sw?
188
-
189
- # =============================================================================
190
- # APPLICATION SPECIFIC
191
- # =============================================================================
192
- repomix-output*
193
- duckdata/
194
- .claude
3
+ .env*
4
+ .DS_store
@@ -16,10 +16,7 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@modelcontextprotocol/sdk": "^1.24.3",
19
- "@t3-oss/env-core": "^0.13.8",
20
- "dotenv": "^17.2.3",
21
19
  "express": "^5.1.0",
22
- "lodash": "^4.17.21",
23
20
  "skybridge": "catalog:",
24
21
  "vite": "^7.1.11",
25
22
  "zod": "^4.1.13"
@@ -27,7 +24,6 @@
27
24
  "devDependencies": {
28
25
  "@modelcontextprotocol/inspector": "^0.17.5",
29
26
  "@types/express": "^5.0.3",
30
- "@types/lodash": "^4.17.20",
31
27
  "@types/node": "^22.15.30",
32
28
  "nodemon": "^3.1.10",
33
29
  "tsx": "^4.19.2",
@@ -1,8 +1,7 @@
1
1
  import express, { type Express } from "express";
2
2
 
3
- import { widgetsDevServer } from "skybridge/server";
3
+ import { devtoolsStaticServer, widgetsDevServer } from "skybridge/server";
4
4
  import type { ViteDevServer } from "vite";
5
- import { env } from "./env.js";
6
5
  import { mcp } from "./middleware.js";
7
6
  import server from "./server.js";
8
7
 
@@ -12,7 +11,10 @@ app.use(express.json());
12
11
 
13
12
  app.use(mcp(server));
14
13
 
15
- if (env.NODE_ENV !== "production") {
14
+ const env = process.env.NODE_ENV || "development";
15
+
16
+ if (env !== "production") {
17
+ app.use(await devtoolsStaticServer());
16
18
  app.use(await widgetsDevServer());
17
19
  }
18
20
 
@@ -22,7 +24,7 @@ app.listen(3000, (error) => {
22
24
  process.exit(1);
23
25
  }
24
26
 
25
- console.log(`Server listening on port 3000 - ${env.NODE_ENV}`);
27
+ console.log(`Server listening on port 3000 - ${env}`);
26
28
  console.log(
27
29
  "Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
28
30
  );