create-skybridge 0.0.0-dev.a4ea8e7 → 0.0.0-dev.ac1e392

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.
Files changed (39) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +34 -40
  3. package/dist/index.test.d.ts +1 -0
  4. package/dist/index.test.js +22 -0
  5. package/index.js +6 -1
  6. package/package.json +7 -3
  7. package/template/.cursor/mcp.json +7 -0
  8. package/template/.nvmrc +1 -0
  9. package/template/.vscode/launch.json +16 -0
  10. package/template/.vscode/settings.json +3 -0
  11. package/template/.vscode/tasks.json +14 -0
  12. package/template/README.md +116 -0
  13. package/template/_gitignore +194 -0
  14. package/template/alpic.json +4 -0
  15. package/template/docs/demo.gif +0 -0
  16. package/template/package.json +21 -0
  17. package/template/pnpm-lock.yaml +317 -0
  18. package/template/pnpm-workspace.yaml +7 -0
  19. package/template/server/nodemon.json +5 -0
  20. package/template/server/package.json +36 -0
  21. package/template/server/pnpm-lock.yaml +3796 -0
  22. package/template/server/src/env.ts +12 -0
  23. package/template/server/src/index.ts +34 -0
  24. package/template/server/src/middleware.ts +54 -0
  25. package/template/server/src/pokedex.ts +148 -0
  26. package/template/server/src/server.ts +76 -0
  27. package/template/server/tsconfig.json +17 -0
  28. package/template/web/components.json +22 -0
  29. package/template/web/package.json +32 -0
  30. package/template/web/pnpm-lock.yaml +2629 -0
  31. package/template/web/src/components/ui/shadcn-io/spinner/index.tsx +272 -0
  32. package/template/web/src/helpers.ts +4 -0
  33. package/template/web/src/index.css +120 -0
  34. package/template/web/src/utils.ts +6 -0
  35. package/template/web/src/widgets/pokemon.tsx +203 -0
  36. package/template/web/tsconfig.app.json +34 -0
  37. package/template/web/tsconfig.json +13 -0
  38. package/template/web/tsconfig.node.json +26 -0
  39. package/template/web/vite.config.ts +16 -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,13 +1,8 @@
1
- import { spawnSync } from "node:child_process";
2
1
  import fs from "node:fs";
3
2
  import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
4
  import * as prompts from "@clack/prompts";
5
5
  import mri from "mri";
6
- const argv = mri(process.argv.slice(2), {
7
- boolean: ["help", "overwrite"],
8
- alias: { h: "help" },
9
- });
10
- const cwd = process.cwd();
11
6
  const defaultProjectName = "skybridge-project";
12
7
  // prettier-ignore
13
8
  const helpMessage = `\
@@ -23,23 +18,13 @@ Examples:
23
18
  create-skybridge my-app
24
19
  create-skybridge . --overwrite
25
20
  `;
26
- function run([command, ...args], options) {
27
- if (!command) {
28
- throw new Error("Command is required");
29
- }
30
- const { status, error } = spawnSync(command, args, options);
31
- if (status != null && status > 0) {
32
- process.exit(status);
33
- }
34
- if (error) {
35
- console.error(`\n${command} ${args.join(" ")} error!`);
36
- console.error(error);
37
- process.exit(1);
38
- }
39
- }
40
- async function init() {
21
+ export async function init(args = process.argv.slice(2)) {
22
+ const argv = mri(args, {
23
+ boolean: ["help", "overwrite"],
24
+ alias: { h: "help" },
25
+ });
41
26
  const argTargetDir = argv._[0]
42
- ? formatTargetDir(String(argv._[0]))
27
+ ? sanitizeTargetDir(String(argv._[0]))
43
28
  : undefined;
44
29
  const argOverwrite = argv.overwrite;
45
30
  const help = argv.help;
@@ -58,14 +43,14 @@ async function init() {
58
43
  defaultValue: defaultProjectName,
59
44
  placeholder: defaultProjectName,
60
45
  validate: (value) => {
61
- return value.length === 0 || formatTargetDir(value).length > 0
46
+ return value.length === 0 || sanitizeTargetDir(value).length > 0
62
47
  ? undefined
63
48
  : "Invalid project name";
64
49
  },
65
50
  });
66
51
  if (prompts.isCancel(projectName))
67
52
  return cancel();
68
- targetDir = formatTargetDir(projectName);
53
+ targetDir = sanitizeTargetDir(projectName);
69
54
  }
70
55
  else {
71
56
  targetDir = defaultProjectName;
@@ -109,19 +94,23 @@ async function init() {
109
94
  return;
110
95
  }
111
96
  }
112
- const root = path.join(cwd, targetDir);
97
+ const root = path.join(process.cwd(), targetDir);
113
98
  // 3. Copy the repository
114
99
  prompts.log.step(`Copying template...`);
115
100
  try {
116
- const templateDir = new URL("../template", import.meta.url).pathname;
117
- // Copy directly to target directory
118
- run(["cp", "-r", `${templateDir}/.`, root], {
119
- stdio: "inherit",
120
- });
121
- // Set up .gitignore
122
- run(["mv", path.join(root, "_gitignore"), path.join(root, ".gitignore")], {
123
- stdio: "inherit",
124
- });
101
+ const templateDir = fileURLToPath(new URL("../template", import.meta.url));
102
+ // Copy template to target directory
103
+ fs.cpSync(templateDir, root, { recursive: true });
104
+ // Rename _gitignore to .gitignore
105
+ fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
106
+ // Update project name in package.json
107
+ const name = path.basename(root);
108
+ for (const dir of ["", "server", "web"]) {
109
+ const pkgPath = path.join(root, dir, "package.json");
110
+ const pkg = fs.readFileSync(pkgPath, "utf-8");
111
+ const fixed = pkg.replace(/apps-sdk-template/g, name);
112
+ fs.writeFileSync(pkgPath, fixed);
113
+ }
125
114
  prompts.log.success(`Project created in ${root}`);
126
115
  prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
127
116
  }
@@ -131,8 +120,17 @@ async function init() {
131
120
  process.exit(1);
132
121
  }
133
122
  }
134
- function formatTargetDir(targetDir) {
135
- return targetDir.trim().replace(/\/+$/g, "");
123
+ function sanitizeTargetDir(targetDir) {
124
+ return (targetDir
125
+ .trim()
126
+ // Only keep alphanumeric, dash, underscore, dot, @, /
127
+ .replace(/[^a-zA-Z0-9\-_.@/]/g, "")
128
+ // Prevent path traversal
129
+ .replace(/\.\./g, "")
130
+ // Collapse multiple slashes
131
+ .replace(/\/+/g, "/")
132
+ // Remove leading/trailing slashes
133
+ .replace(/^\/+|\/+$/g, ""));
136
134
  }
137
135
  function isEmpty(path) {
138
136
  const files = fs.readdirSync(path);
@@ -149,7 +147,3 @@ function emptyDir(dir) {
149
147
  fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
150
148
  }
151
149
  }
152
- init().catch((e) => {
153
- console.error(e);
154
- process.exit(1);
155
- });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { afterEach, beforeEach, describe, 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 scaffold a new project", async () => {
18
+ const name = `../../${tempDirName}//project$`;
19
+ await init([name]);
20
+ await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
+ });
22
+ });
package/index.js CHANGED
@@ -1,3 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import "./dist/index.js";
3
+ import { init } from "./dist/index.js";
4
+
5
+ init().catch((e) => {
6
+ console.error(e);
7
+ process.exit(1);
8
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.a4ea8e7",
3
+ "version": "0.0.0-dev.ac1e392",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -13,10 +13,13 @@
13
13
  },
14
14
  "files": [
15
15
  "index.js",
16
- "dist"
16
+ "dist",
17
+ "template"
17
18
  ],
18
19
  "scripts": {
19
20
  "build": "tsc",
21
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
22
+ "test:unit": "vitest run",
20
23
  "test:type": "tsc --noEmit",
21
24
  "test:format": "biome ci",
22
25
  "prepublishOnly": "pnpm run build"
@@ -27,6 +30,7 @@
27
30
  },
28
31
  "devDependencies": {
29
32
  "@types/node": "^25.0.3",
30
- "typescript": "^5.9.3"
33
+ "typescript": "^5.9.3",
34
+ "vitest": "^2.1.9"
31
35
  }
32
36
  }
@@ -0,0 +1,7 @@
1
+ {
2
+ "mcpServers": {
3
+ "local": {
4
+ "url": "http://localhost:3000/mcp"
5
+ }
6
+ }
7
+ }
@@ -0,0 +1 @@
1
+ lts/jod
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": "0.0.1",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug MCP Server",
6
+ "type": "node",
7
+ "request": "launch",
8
+ "program": "${workspaceFolder}/dist/index.js",
9
+ "console": "integratedTerminal",
10
+ "sourceMaps": true,
11
+ "outFiles": ["${workspaceFolder}/dist/**/*.js"],
12
+ "preLaunchTask": "npm: build",
13
+ "stopOnEntry": false
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "editor.formatOnSave": true
3
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": "2.0.0",
3
+ "tasks": [
4
+ {
5
+ "type": "shell",
6
+ "command": "npm",
7
+ "args": ["build"],
8
+ "group": "build",
9
+ "label": "npm: build",
10
+ "detail": "npm build",
11
+ "problemMatcher": ["$tsc"]
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,116 @@
1
+ # ChatGPT Apps SDK Alpic Starter
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.
10
+
11
+ ## Getting Started
12
+
13
+ ### Prerequisites
14
+
15
+ - Node.js 22+ (see `.nvmrc` for exact version)
16
+ - pnpm (install with `npm install -g pnpm`)
17
+ - Ngrok
18
+
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.
22
+
23
+ #### 1. Install
24
+
25
+ ```bash
26
+ pnpm install
27
+ ```
28
+
29
+ #### 2. Start the Development Server
30
+
31
+ Run the development server from the root directory:
32
+
33
+ ```bash
34
+ pnpm dev
35
+ ```
36
+
37
+ This command starts an Express server on port 3000. This server packages:
38
+
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
43
+
44
+ In a separate terminal, expose your local server using ngrok:
45
+
46
+ ```bash
47
+ ngrok http 3000
48
+ ```
49
+
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
64
+
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")
68
+
69
+ #### 6. Develop with HMR
70
+
71
+ Now you can edit React components in `web` and see changes instantly:
72
+
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
77
+
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**.
79
+
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.
90
+
91
+ ## Deploy to Production
92
+
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
+
97
+ - In ChatGPT, navigate to **Settings → Connectors → Create** and add your MCP server URL (e.g., `https://your-app-name.alpic.live`)
98
+
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
+ ## Resources
113
+
114
+ - [Apps SDK Documentation](https://developers.openai.com/apps-sdk)
115
+ - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
116
+ - [Alpic Documentation](https://docs.alpic.ai/)
@@ -0,0 +1,194 @@
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
+ 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
+ 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
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "https://assets.alpic.ai/alpic.json",
3
+ "buildOutputDir": "server/dist"
4
+ }
Binary file
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "apps-sdk-template",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "description": "Alpic MCP Server Template",
6
+ "type": "module",
7
+ "packageManager": "pnpm@10.18.3",
8
+ "scripts": {
9
+ "dev": "pnpm --filter @apps-sdk-template/server dev",
10
+ "build": "pnpm web:build && rm -rf server/dist && pnpm --filter=@apps-sdk-template/server --prod deploy server/dist && cp -r web/dist server/dist/assets && pnpm --filter=@apps-sdk-template/server build",
11
+ "start": "pnpm server:start",
12
+ "inspector": "pnpm --filter @apps-sdk-template/server inspector",
13
+ "server:build": "pnpm --filter @apps-sdk-template/server build",
14
+ "server:start": "pnpm --filter @apps-sdk-template/server start",
15
+ "web:build": "pnpm --filter @apps-sdk-template/web build",
16
+ "web:preview": "pnpm --filter @apps-sdk-template/web preview"
17
+ },
18
+ "devDependencies": {
19
+ "tsx": "^4.19.4"
20
+ }
21
+ }