create-skybridge 0.0.0-dev.5b3dd8c → 0.0.0-dev.5bad705
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/dist/index.js
CHANGED
|
@@ -100,7 +100,10 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
100
100
|
try {
|
|
101
101
|
const templateDir = fileURLToPath(new URL("../template", import.meta.url));
|
|
102
102
|
// Copy template to target directory
|
|
103
|
-
fs.cpSync(templateDir, root, {
|
|
103
|
+
fs.cpSync(templateDir, root, {
|
|
104
|
+
recursive: true,
|
|
105
|
+
filter: (src) => !src.endsWith(".npmrc"),
|
|
106
|
+
});
|
|
104
107
|
// Rename _gitignore to .gitignore
|
|
105
108
|
fs.renameSync(path.join(root, "_gitignore"), path.join(root, ".gitignore"));
|
|
106
109
|
// Update project name in package.json
|
package/dist/index.test.js
CHANGED
|
@@ -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,
|
|
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,10 +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
|
-
|
|
22
|
-
await fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"));
|
|
23
|
-
expect.fail(".npmrc should not be copied");
|
|
24
|
-
}
|
|
25
|
-
catch { }
|
|
21
|
+
expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
|
|
26
22
|
});
|
|
27
23
|
});
|
package/package.json
CHANGED
|
@@ -2,7 +2,6 @@ import express, { type Express } from "express";
|
|
|
2
2
|
|
|
3
3
|
import { 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,9 @@ app.use(express.json());
|
|
|
12
11
|
|
|
13
12
|
app.use(mcp(server));
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
const env = process.env.NODE_ENV || "development";
|
|
15
|
+
|
|
16
|
+
if (env !== "production") {
|
|
16
17
|
app.use(await widgetsDevServer());
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -22,7 +23,7 @@ app.listen(3000, (error) => {
|
|
|
22
23
|
process.exit(1);
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
console.log(`Server listening on port 3000 - ${env
|
|
26
|
+
console.log(`Server listening on port 3000 - ${env}`);
|
|
26
27
|
console.log(
|
|
27
28
|
"Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
|
|
28
29
|
);
|
|
@@ -41,26 +41,15 @@ const server = new McpServer(
|
|
|
41
41
|
question: z.string().describe("The user question."),
|
|
42
42
|
},
|
|
43
43
|
},
|
|
44
|
-
async ({ question
|
|
44
|
+
async ({ question }) => {
|
|
45
45
|
try {
|
|
46
46
|
// deterministic answer
|
|
47
|
-
const hash = question
|
|
47
|
+
const hash = question
|
|
48
|
+
.split("")
|
|
49
|
+
.reduce((acc, char) => acc + char.charCodeAt(0), 0);
|
|
48
50
|
const answer = Answers[hash % Answers.length];
|
|
49
51
|
return {
|
|
50
|
-
/**
|
|
51
|
-
* Arbitrary JSON passed only to the component.
|
|
52
|
-
* Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
|
|
53
|
-
* _meta is never shown to the model.
|
|
54
|
-
*/
|
|
55
|
-
_meta: {},
|
|
56
|
-
/**
|
|
57
|
-
* Structured data that is used to hydrate your component.
|
|
58
|
-
* ChatGPT injects this object into your iframe as window.openai.toolOutput
|
|
59
|
-
*/
|
|
60
52
|
structuredContent: { answer },
|
|
61
|
-
/**
|
|
62
|
-
* Optional free-form text that the model receives verbatim
|
|
63
|
-
*/
|
|
64
53
|
content: [],
|
|
65
54
|
isError: false,
|
|
66
55
|
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import "dotenv/config";
|
|
2
|
-
|
|
3
|
-
import { createEnv } from "@t3-oss/env-core";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
|
|
6
|
-
export const env = createEnv({
|
|
7
|
-
server: {
|
|
8
|
-
NODE_ENV: z.enum(["development", "production"]).default("development"),
|
|
9
|
-
},
|
|
10
|
-
runtimeEnv: process.env,
|
|
11
|
-
emptyStringAsUndefined: true,
|
|
12
|
-
});
|