create-skybridge 0.0.0-dev.1b2b016 → 0.0.0-dev.1b2cb1b

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 (117) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +373 -122
  4. package/index.js +6 -1
  5. package/package.json +15 -12
  6. package/templates/blank/.dockerignore +4 -0
  7. package/templates/blank/AGENTS.md +1 -0
  8. package/templates/blank/Dockerfile +53 -0
  9. package/templates/blank/README.md +92 -0
  10. package/templates/blank/_gitignore +7 -0
  11. package/templates/blank/alpic.json +3 -0
  12. package/templates/blank/node_modules/.bin/alpic +21 -0
  13. package/templates/blank/node_modules/.bin/sb +21 -0
  14. package/templates/blank/node_modules/.bin/skybridge +21 -0
  15. package/templates/blank/node_modules/.bin/tsc +21 -0
  16. package/templates/blank/node_modules/.bin/tsserver +21 -0
  17. package/templates/blank/node_modules/.bin/tsx +21 -0
  18. package/templates/blank/node_modules/.bin/vite +21 -0
  19. package/templates/blank/package.json +29 -0
  20. package/templates/blank/src/helpers.ts +4 -0
  21. package/templates/blank/src/server.ts +16 -0
  22. package/templates/blank/tsconfig.json +5 -0
  23. package/templates/blank/vite.config.ts +6 -0
  24. package/templates/demo/.dockerignore +4 -0
  25. package/templates/demo/AGENTS.md +1 -0
  26. package/templates/demo/Dockerfile +53 -0
  27. package/templates/demo/README.md +95 -0
  28. package/templates/demo/_gitignore +7 -0
  29. package/templates/demo/alpic.json +3 -0
  30. package/templates/demo/node_modules/.bin/alpic +21 -0
  31. package/templates/demo/node_modules/.bin/sb +21 -0
  32. package/templates/demo/node_modules/.bin/skybridge +21 -0
  33. package/templates/demo/node_modules/.bin/tsc +21 -0
  34. package/templates/demo/node_modules/.bin/tsserver +21 -0
  35. package/templates/demo/node_modules/.bin/tsx +21 -0
  36. package/templates/demo/node_modules/.bin/vite +21 -0
  37. package/templates/demo/package.json +41 -0
  38. package/templates/demo/src/helpers.ts +4 -0
  39. package/templates/demo/src/index.css +59 -0
  40. package/templates/demo/src/server.ts +94 -0
  41. package/templates/demo/src/views/components/doc-link.tsx +22 -0
  42. package/templates/demo/src/views/components/doc.tsx +21 -0
  43. package/templates/demo/src/views/components/nav.tsx +31 -0
  44. package/templates/demo/src/views/components/progress.tsx +35 -0
  45. package/templates/demo/src/views/components/steps/outro.tsx +68 -0
  46. package/templates/demo/src/views/components/steps/state.tsx +47 -0
  47. package/templates/demo/src/views/components/steps/tool-call.tsx +53 -0
  48. package/templates/demo/src/views/components/steps/tool-output.tsx +40 -0
  49. package/templates/demo/src/views/images/mascot/beret.png +0 -0
  50. package/templates/demo/src/views/images/mascot/chapka.png +0 -0
  51. package/templates/demo/src/views/images/mascot/cowboy-hat.png +0 -0
  52. package/templates/demo/src/views/images/mascot/fez.png +0 -0
  53. package/templates/demo/src/views/images/mascot/jester-hat.png +0 -0
  54. package/templates/demo/src/views/images/mascot/mitre.png +0 -0
  55. package/templates/demo/src/views/images/mascot/non-la.png +0 -0
  56. package/templates/demo/src/views/images/mascot/original.png +0 -0
  57. package/templates/demo/src/views/images/mascot/propeller-beanie.png +0 -0
  58. package/templates/demo/src/views/images/mascot/ski-mask.png +0 -0
  59. package/templates/demo/src/views/images/mascot/sombrero.png +0 -0
  60. package/templates/demo/src/views/images/mascot/top-hat.png +0 -0
  61. package/templates/demo/src/views/images/mascot/viking-helmet.png +0 -0
  62. package/templates/demo/src/views/onboarding.tsx +63 -0
  63. package/templates/demo/src/views/use-mascot.ts +60 -0
  64. package/templates/demo/tsconfig.json +11 -0
  65. package/{template/web → templates/demo}/vite.config.ts +1 -3
  66. package/templates/ecom/.dockerignore +4 -0
  67. package/templates/ecom/.env.template +2 -0
  68. package/templates/ecom/AGENTS.md +2 -0
  69. package/templates/ecom/Dockerfile +53 -0
  70. package/templates/ecom/README.md +92 -0
  71. package/templates/ecom/_gitignore +8 -0
  72. package/templates/ecom/alpic.json +3 -0
  73. package/templates/ecom/node_modules/.bin/alpic +21 -0
  74. package/templates/ecom/node_modules/.bin/sb +21 -0
  75. package/templates/ecom/node_modules/.bin/skybridge +21 -0
  76. package/templates/ecom/node_modules/.bin/tsc +21 -0
  77. package/templates/ecom/node_modules/.bin/tsserver +21 -0
  78. package/templates/ecom/node_modules/.bin/tsx +21 -0
  79. package/templates/ecom/node_modules/.bin/vite +21 -0
  80. package/templates/ecom/package.json +29 -0
  81. package/templates/ecom/src/helpers.ts +4 -0
  82. package/templates/ecom/src/lib/format.ts +56 -0
  83. package/templates/ecom/src/server.ts +125 -0
  84. package/templates/ecom/tsconfig.json +5 -0
  85. package/templates/ecom/vite.config.ts +6 -0
  86. package/template/.cursor/mcp.json +0 -7
  87. package/template/.nvmrc +0 -1
  88. package/template/.vscode/launch.json +0 -16
  89. package/template/.vscode/settings.json +0 -3
  90. package/template/.vscode/tasks.json +0 -14
  91. package/template/README.md +0 -116
  92. package/template/_gitignore +0 -194
  93. package/template/alpic.json +0 -4
  94. package/template/docs/demo.gif +0 -0
  95. package/template/package.json +0 -22
  96. package/template/pnpm-lock.yaml +0 -408
  97. package/template/pnpm-workspace.yaml +0 -7
  98. package/template/server/nodemon.json +0 -5
  99. package/template/server/package.json +0 -37
  100. package/template/server/pnpm-lock.yaml +0 -3796
  101. package/template/server/src/env.ts +0 -12
  102. package/template/server/src/index.ts +0 -34
  103. package/template/server/src/middleware.ts +0 -54
  104. package/template/server/src/pokedex.ts +0 -148
  105. package/template/server/src/server.ts +0 -76
  106. package/template/server/tsconfig.json +0 -17
  107. package/template/web/components.json +0 -22
  108. package/template/web/package.json +0 -33
  109. package/template/web/pnpm-lock.yaml +0 -2629
  110. package/template/web/src/components/ui/shadcn-io/spinner/index.tsx +0 -272
  111. package/template/web/src/helpers.ts +0 -4
  112. package/template/web/src/index.css +0 -120
  113. package/template/web/src/utils.ts +0 -6
  114. package/template/web/src/widgets/pokemon.tsx +0 -203
  115. package/template/web/tsconfig.app.json +0 -34
  116. package/template/web/tsconfig.json +0 -13
  117. package/template/web/tsconfig.node.json +0 -26
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.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export declare function init(args?: string[]): Promise<void>;
package/dist/index.js CHANGED
@@ -1,160 +1,411 @@
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
+ import spawn from "cross-spawn";
5
6
  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
- const defaultProjectName = "skybridge-project";
12
- // prettier-ignore
13
- const helpMessage = `\
14
- Usage: create-skybridge [OPTION]... [DIRECTORY]
7
+ const OUTPUT_TAIL_LINES = 10;
8
+ const DEFAULT_PROJECT_NAME = "skybridge-project";
9
+ const PACKAGE_MANAGERS = ["bun", "deno", "npm", "pnpm", "yarn"];
10
+ const TEMPLATES = ["demo", "blank", "ecom"];
11
+ const pkg = JSON.parse(fs.readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8"));
12
+ const version = pkg.version;
13
+ const HELP_MESSAGE = `Usage: skybridge create [path] [options]
15
14
 
16
- Create a new Skybridge project by copying the starter template.
15
+ Skybridge v${version} - the fullstack framework for building MCP Apps
16
+
17
+ Arguments:
18
+ path Where the project will be created. Prompted when omitted.
17
19
 
18
20
  Options:
19
- -h, --help show this help message
20
- --overwrite remove existing files in target directory
21
+ --blank scaffold a minimal project without demo tools and views
22
+ --ecom scaffold the ecommerce template (search products, render carousel)
23
+ --overwrite remove existing files if target directory is not empty
24
+ --pm <choice> package manager to use (choices: ${PACKAGE_MANAGERS.join(", ")}. default to npm when none is provided or infered)
25
+ --skip-skills skip installing coding agent skills
26
+ --start start dev server
27
+ --yes skip prompts and use default values for unprovided options
28
+ --help display this help message
21
29
 
22
- Examples:
23
- create-skybridge my-app
24
- create-skybridge . --overwrite
25
- `;
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() {
41
- const argTargetDir = argv._[0]
42
- ? formatTargetDir(String(argv._[0]))
43
- : undefined;
44
- const argOverwrite = argv.overwrite;
45
- const help = argv.help;
46
- if (help) {
47
- console.log(helpMessage);
30
+ Non-interactive usage:
31
+ Mandatory: path argument and --yes option
32
+ Example: skybridge create my-app --yes`;
33
+ const isTTY = process.stdout.isTTY;
34
+ const _spinner = prompts.spinner();
35
+ const Spinner = {
36
+ start(msg) {
37
+ if (!isTTY) {
38
+ prompts.log.info(msg);
39
+ }
40
+ else {
41
+ _spinner.clear();
42
+ _spinner.start(msg);
43
+ }
44
+ },
45
+ stop(msg) {
46
+ if (!isTTY) {
47
+ prompts.log.success(msg);
48
+ }
49
+ else {
50
+ _spinner.stop(msg);
51
+ }
52
+ },
53
+ error(msg) {
54
+ if (!isTTY) {
55
+ prompts.log.error(msg);
56
+ }
57
+ else {
58
+ _spinner.error(msg);
59
+ }
60
+ },
61
+ };
62
+ export async function init(args = process.argv.slice(2)) {
63
+ const argv = mri(args, {
64
+ boolean: [
65
+ "help",
66
+ "blank",
67
+ "ecom",
68
+ "overwrite",
69
+ "skip-skills",
70
+ "start",
71
+ "yes",
72
+ ],
73
+ string: ["pm"],
74
+ alias: { h: "help" },
75
+ });
76
+ if (argv.help) {
77
+ console.log(HELP_MESSAGE);
48
78
  return;
49
79
  }
50
- const interactive = process.stdin.isTTY;
51
- const cancel = () => prompts.cancel("Operation cancelled");
52
- // 1. Get project name and target dir
53
- let targetDir = argTargetDir;
80
+ const { yes } = argv;
81
+ let targetDir = argv._[0] ? sanitizeTargetDir(String(argv._[0])) : undefined;
82
+ if (yes && !targetDir) {
83
+ abort("The target directory is required in non-interactive mode.", "Example: skybridge create my-app --yes");
84
+ }
85
+ let pm = parsePackageManager(argv.pm || "");
86
+ if (argv.pm && !pm) {
87
+ abort(`Invalid --pm value "${argv.pm}". Expected one of: ${PACKAGE_MANAGERS.join(", ")}.`);
88
+ }
89
+ console.log(); // cosmetic line break
90
+ prompts.intro(`\x1b[1;36m⛰ Welcome to Skybridge v${version} \x1b[22m- the fullstack framework for building MCP Apps\x1b[0m`);
91
+ // 1. Target directory
54
92
  if (!targetDir) {
55
- if (interactive) {
56
- const projectName = await prompts.text({
57
- message: "Project name:",
58
- defaultValue: defaultProjectName,
59
- placeholder: defaultProjectName,
60
- validate: (value) => {
61
- return value.length === 0 || formatTargetDir(value).length > 0
62
- ? undefined
63
- : "Invalid project name";
64
- },
93
+ const choice = await prompts.text({
94
+ message: "Project directory:",
95
+ placeholder: DEFAULT_PROJECT_NAME,
96
+ defaultValue: DEFAULT_PROJECT_NAME,
97
+ validate: (value) => !value || sanitizeTargetDir(value).length > 0
98
+ ? undefined
99
+ : "Invalid project name",
100
+ });
101
+ if (prompts.isCancel(choice)) {
102
+ return cancel();
103
+ }
104
+ targetDir = sanitizeTargetDir(choice);
105
+ }
106
+ // 2. Existing-directory handling
107
+ if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
108
+ if (argv.overwrite) {
109
+ emptyDir(targetDir);
110
+ }
111
+ else if (yes) {
112
+ prompts.log.error(`Target directory "${targetDir}" is not empty. Use --overwrite to remove existing files.`);
113
+ process.exit(1);
114
+ }
115
+ else {
116
+ const ok = await prompts.confirm({
117
+ message: `Target directory "${targetDir}" is not empty. Remove existing files?`,
118
+ initialValue: true,
65
119
  });
66
- if (prompts.isCancel(projectName))
120
+ if (prompts.isCancel(ok) || !ok) {
67
121
  return cancel();
68
- targetDir = formatTargetDir(projectName);
122
+ }
123
+ Spinner.start(`Cleaning up ${targetDir}`);
124
+ emptyDir(targetDir);
125
+ Spinner.stop(`Cleaned up ${targetDir}`);
69
126
  }
70
- else {
71
- targetDir = defaultProjectName;
127
+ }
128
+ // 3. Template
129
+ let template;
130
+ if (argv.blank) {
131
+ template = "blank";
132
+ }
133
+ if (argv.ecom) {
134
+ if (template) {
135
+ abort("Cannot specify both --blank and --ecom.");
72
136
  }
137
+ template = "ecom";
73
138
  }
74
- // 2. Handle directory if exist and not empty
75
- if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
76
- let overwrite = argOverwrite ? "yes" : undefined;
77
- if (!overwrite) {
78
- if (interactive) {
79
- const res = await prompts.select({
80
- message: (targetDir === "."
81
- ? "Current directory"
82
- : `Target directory "${targetDir}"`) +
83
- ` is not empty. Please choose how to proceed:`,
84
- options: [
85
- {
86
- label: "Cancel operation",
87
- value: "no",
88
- },
89
- {
90
- label: "Remove existing files and continue",
91
- value: "yes",
92
- },
93
- ],
94
- });
95
- if (prompts.isCancel(res))
96
- return cancel();
97
- overwrite = res;
98
- }
99
- else {
100
- overwrite = "no";
139
+ if (!template) {
140
+ if (yes) {
141
+ template = "demo";
142
+ }
143
+ else {
144
+ const choice = await prompts.select({
145
+ message: "Choose a template:",
146
+ options: [
147
+ {
148
+ value: "demo",
149
+ label: "demo",
150
+ hint: "starter code with tools and UI",
151
+ },
152
+ {
153
+ value: "blank",
154
+ label: "blank",
155
+ hint: "minimal boilerplate without tools",
156
+ },
157
+ {
158
+ value: "ecom",
159
+ label: "ecom",
160
+ hint: "ecommerce template with product search tool and carousel view",
161
+ },
162
+ ],
163
+ initialValue: "demo",
164
+ });
165
+ if (prompts.isCancel(choice)) {
166
+ return cancel();
101
167
  }
168
+ template = choice;
102
169
  }
103
- switch (overwrite) {
104
- case "yes":
105
- emptyDir(targetDir);
106
- break;
107
- case "no":
108
- cancel();
109
- return;
170
+ }
171
+ // 4. Copy template
172
+ const root = path.resolve(targetDir);
173
+ Spinner.start(`Copying ${template} template`);
174
+ try {
175
+ const templateDir = fileURLToPath(new URL(`../templates/${template}`, import.meta.url));
176
+ fs.cpSync(templateDir, root, {
177
+ recursive: true,
178
+ filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
179
+ });
180
+ const gitignoreSource = path.join(root, "_gitignore");
181
+ if (fs.existsSync(gitignoreSource)) {
182
+ fs.renameSync(gitignoreSource, path.join(root, ".gitignore"));
110
183
  }
184
+ Spinner.stop(`Copied ${template} template`);
111
185
  }
112
- const root = path.join(cwd, targetDir);
113
- // 3. Copy the repository
114
- prompts.log.step(`Copying template...`);
186
+ catch (error) {
187
+ Spinner.error("Failed to copy template");
188
+ abort(String(error));
189
+ }
190
+ // 5. Set package.json name to the project dir basename
115
191
  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",
192
+ const pkgPath = path.join(root, "package.json");
193
+ const projectPkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
194
+ projectPkg.name = path.basename(root);
195
+ fs.writeFileSync(pkgPath, `${JSON.stringify(projectPkg, null, 2)}\n`);
196
+ }
197
+ catch (error) {
198
+ abort("Failed to update project name in package.json.", String(error));
199
+ }
200
+ // Async spawn wrapper so a spinner can keep animating during the subprocess
201
+ // (cross-spawn.sync would block the event loop). Captures stdout/stderr to
202
+ // `output` when stdio is "pipe", trimmed to the last OUTPUT_TAIL_LINES lines
203
+ // — install errors land at the tail, so we keep that and prefix with an
204
+ // ellipsis when content gets dropped.
205
+ function spawnAsync(command, args) {
206
+ return new Promise((resolve) => {
207
+ let raw = "";
208
+ const child = spawn(command, args, {
209
+ stdio: ["ignore", "pipe", "pipe"],
210
+ cwd: root,
211
+ });
212
+ child.stdout?.on("data", (chunk) => {
213
+ raw += chunk.toString();
214
+ });
215
+ child.stderr?.on("data", (chunk) => {
216
+ raw += chunk.toString();
217
+ });
218
+ const done = (status) => {
219
+ const tail = [];
220
+ for (const part of raw.split("\n").reverse()) {
221
+ const line = part.trim();
222
+ if (!line) {
223
+ continue;
224
+ }
225
+ if (tail.length >= OUTPUT_TAIL_LINES) {
226
+ tail.push(`… (truncated, showing last ${OUTPUT_TAIL_LINES} lines)`);
227
+ break;
228
+ }
229
+ tail.push(line);
230
+ }
231
+ resolve({ status, output: tail.reverse().join("\n") });
232
+ };
233
+ child.on("close", done);
234
+ child.on("error", () => done(1));
235
+ });
236
+ }
237
+ // 6. Skills install (single Y/n prompt)
238
+ let installSkills;
239
+ if (argv["skip-skills"]) {
240
+ installSkills = false;
241
+ }
242
+ else if (yes) {
243
+ installSkills = true;
244
+ }
245
+ else {
246
+ const choice = await prompts.confirm({
247
+ message: "Install coding agent skills? (recommended)",
248
+ initialValue: true,
249
+ });
250
+ if (prompts.isCancel(choice)) {
251
+ return cancel();
252
+ }
253
+ installSkills = choice;
254
+ }
255
+ if (installSkills) {
256
+ Spinner.start("Installing coding agent skills");
257
+ const { status, output } = await spawnAsync("npx", [
258
+ "--yes",
259
+ "skills",
260
+ "add",
261
+ "alpic-ai/skybridge",
262
+ "--skill",
263
+ "chatgpt-app-builder",
264
+ "--agent",
265
+ "universal",
266
+ "claude-code",
267
+ "--copy", // something the symlink fails for some reason
268
+ "--yes",
269
+ ]);
270
+ // skills cli always returns 0 so we look for the success message
271
+ if (status === 0 && output.includes("Done!")) {
272
+ Spinner.stop(`Installed coding agent skills`);
273
+ }
274
+ else {
275
+ Spinner.error(`Failed to install coding agent skills:
276
+ \x1b[2m${output}\x1b[0m`);
277
+ prompts.log.error("Try manually: `npx skills add alpic-ai/skybridge`.");
278
+ }
279
+ }
280
+ // 7. Package manager — autodetect, prompt only if detection fails (interactive)
281
+ if (!pm) {
282
+ pm = detectPackageManager() || "npm";
283
+ }
284
+ if (!yes) {
285
+ const choice = await prompts.select({
286
+ message: "Choose a package manager:",
287
+ options: PACKAGE_MANAGERS.map((value) => ({ value })),
288
+ initialValue: pm,
120
289
  });
121
- // Set up .gitignore
122
- run(["mv", path.join(root, "_gitignore"), path.join(root, ".gitignore")], {
290
+ if (prompts.isCancel(choice)) {
291
+ return cancel();
292
+ }
293
+ pm = choice;
294
+ }
295
+ // 8. Always install dependencies
296
+ Spinner.start(`Installing dependencies with ${pm}`);
297
+ const { status, output } = await spawnAsync(pm, ["install"]);
298
+ if (status === 0) {
299
+ Spinner.stop(`Installed dependencies with ${pm}`);
300
+ }
301
+ else {
302
+ Spinner.error(`Dependency installation failed:
303
+ \x1b[2m${output}\x1b[0m`);
304
+ abort(`Try manually: cd ${targetDir} && ${pm} install`);
305
+ }
306
+ // 9. Start dev server?
307
+ let start = false;
308
+ if (argv.start) {
309
+ start = true;
310
+ }
311
+ else if (!yes) {
312
+ const choice = await prompts.confirm({
313
+ message: "Start dev server now?",
314
+ initialValue: true,
315
+ });
316
+ if (prompts.isCancel(choice)) {
317
+ return cancel();
318
+ }
319
+ start = choice;
320
+ }
321
+ if (start) {
322
+ prompts.outro(`Starting dev server in ${targetDir}…`);
323
+ const devResult = spawn.sync(pm, scriptArgs(pm, "dev"), {
123
324
  stdio: "inherit",
325
+ cwd: root,
124
326
  });
125
- // Update project name in package.json
126
- const pkgPath = path.join(root, "package.json");
127
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
128
- pkg.name = path.basename(root);
129
- fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
130
- prompts.log.success(`Project created in ${root}`);
131
- prompts.outro(`Done! Next steps:\n\n cd ${targetDir}\n pnpm install\n pnpm dev`);
327
+ process.exit(devResult.status ?? 0);
132
328
  }
133
- catch (error) {
134
- prompts.log.error("Failed to copy repository");
135
- console.error(error);
136
- process.exit(1);
329
+ prompts.log.success("All set! Next steps:");
330
+ prompts.log.info(`Start:
331
+ cd ${targetDir}
332
+ ${scriptCommand(pm, "dev")}`);
333
+ prompts.log.info(`Deploy:
334
+ ${scriptCommand(pm, "deploy")}`);
335
+ prompts.outro(`🛟 Need help?
336
+ Chat: https://discord.alpic.ai
337
+ Docs: https://docs.skybridge.tech`);
338
+ }
339
+ function cancel() {
340
+ prompts.cancel("Operation cancelled");
341
+ process.exit(0);
342
+ }
343
+ function abort(...lines) {
344
+ for (const line of lines) {
345
+ prompts.log.error(line);
137
346
  }
347
+ prompts.outro("Aborted");
348
+ process.exit(1);
138
349
  }
139
- function formatTargetDir(targetDir) {
350
+ function parsePackageManager(value) {
351
+ switch (value) {
352
+ case "bun":
353
+ return "bun";
354
+ case "deno":
355
+ return "deno";
356
+ case "npm":
357
+ return "npm";
358
+ case "pnpm":
359
+ return "pnpm";
360
+ case "yarn":
361
+ return "yarn";
362
+ default:
363
+ return undefined;
364
+ }
365
+ }
366
+ function detectPackageManager() {
367
+ const userAgent = process.env.npm_config_user_agent;
368
+ if (!userAgent) {
369
+ return undefined;
370
+ }
371
+ const name = userAgent.split(" ")[0]?.split("/")[0];
372
+ return parsePackageManager(name);
373
+ }
374
+ function scriptArgs(pm, script) {
375
+ switch (pm) {
376
+ case "yarn":
377
+ case "pnpm":
378
+ case "bun":
379
+ return [script];
380
+ case "deno":
381
+ return ["task", script];
382
+ case "npm":
383
+ return ["run", script];
384
+ }
385
+ }
386
+ function scriptCommand(pm, script) {
387
+ return [pm, ...scriptArgs(pm, script)].join(" ");
388
+ }
389
+ function sanitizeTargetDir(targetDir) {
140
390
  return targetDir.trim().replace(/\/+$/g, "");
141
391
  }
142
- function isEmpty(path) {
143
- const files = fs.readdirSync(path);
144
- return files.length === 0 || (files.length === 1 && files[0] === ".git");
392
+ // Skip user's SPEC.md and IDE/agent preferences (.idea, .claude, etc.)
393
+ function isSkippedEntry(entry) {
394
+ return ((entry.name.startsWith(".") && entry.isDirectory()) ||
395
+ entry.name === "SPEC.md");
396
+ }
397
+ function isEmpty(dirPath) {
398
+ const entries = fs.readdirSync(dirPath, { withFileTypes: true });
399
+ return entries.every(isSkippedEntry);
145
400
  }
146
401
  function emptyDir(dir) {
147
402
  if (!fs.existsSync(dir)) {
148
403
  return;
149
404
  }
150
- for (const file of fs.readdirSync(dir)) {
151
- if (file === ".git") {
405
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
406
+ if (isSkippedEntry(entry)) {
152
407
  continue;
153
408
  }
154
- fs.rmSync(path.resolve(dir, file), { recursive: true, force: true });
409
+ fs.rmSync(path.join(dir, entry.name), { recursive: true, force: true });
155
410
  }
156
411
  }
157
- init().catch((e) => {
158
- console.error(e);
159
- process.exit(1);
160
- });
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.1b2b016",
3
+ "version": "0.0.0-dev.1b2cb1b",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -14,20 +14,23 @@
14
14
  "files": [
15
15
  "index.js",
16
16
  "dist",
17
- "template"
17
+ "templates"
18
18
  ],
19
- "scripts": {
20
- "build": "tsc",
21
- "test:type": "tsc --noEmit",
22
- "test:format": "biome ci",
23
- "prepublishOnly": "pnpm run build"
24
- },
25
19
  "dependencies": {
26
- "@clack/prompts": "^0.11.0",
20
+ "@clack/prompts": "^1.7.0",
21
+ "cross-spawn": "^7.0.6",
27
22
  "mri": "^1.2.0"
28
23
  },
29
24
  "devDependencies": {
30
- "@types/node": "^25.0.3",
31
- "typescript": "^5.9.3"
25
+ "@types/cross-spawn": "^6.0.6",
26
+ "typescript": "^6.0.3",
27
+ "vitest": "^4.1.9"
28
+ },
29
+ "scripts": {
30
+ "build": "tsc",
31
+ "test": "pnpm run test:unit && pnpm run test:format",
32
+ "test:unit": "vitest run",
33
+ "format": "biome check --write --error-on-warnings",
34
+ "test:format": "biome ci"
32
35
  }
33
- }
36
+ }
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ .git
3
+ dist
4
+ .env*
@@ -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.