create-skybridge 0.0.0-dev.186dac9 → 0.0.0-dev.18753e6

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