create-skybridge 0.0.0-dev.df0cfdd → 0.0.0-dev.df1e961
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 +101 -15
- package/package.json +1 -1
- package/templates/blank/README.md +2 -1
- package/templates/blank/package.json +5 -5
- package/templates/blank/src/index.ts +3 -0
- package/templates/blank/src/server.ts +7 -11
- package/templates/demo/README.md +3 -1
- package/templates/demo/evals/start.eval.ts +11 -0
- package/templates/demo/node_modules/.bin/vitest +21 -0
- package/templates/demo/package.json +11 -6
- package/templates/demo/src/index.ts +3 -0
- package/templates/demo/src/server.ts +86 -88
- package/templates/demo/src/views/onboarding.tsx +3 -3
- package/templates/demo/tsconfig.evals.json +11 -0
- package/templates/demo/vite.config.ts +2 -2
- package/templates/ecom/README.md +2 -1
- package/templates/ecom/node_modules/.bin/ladle +2 -2
- package/templates/ecom/package.json +3 -3
- package/templates/ecom/src/components/view-frame.tsx +4 -4
- package/templates/ecom/src/index.ts +3 -0
- package/templates/ecom/src/server.ts +13 -17
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { fileURLToPath } from "node:url";
|
|
4
5
|
import * as prompts from "@clack/prompts";
|
|
@@ -8,6 +9,7 @@ const OUTPUT_TAIL_LINES = 10;
|
|
|
8
9
|
const DEFAULT_PROJECT_NAME = "skybridge-project";
|
|
9
10
|
const PACKAGE_MANAGERS = ["bun", "deno", "npm", "pnpm", "yarn"];
|
|
10
11
|
const TEMPLATES = ["demo", "blank", "ecom"];
|
|
12
|
+
const REPO = "alpic-ai/skybridge";
|
|
11
13
|
const pkg = JSON.parse(fs.readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf-8"));
|
|
12
14
|
const version = pkg.version;
|
|
13
15
|
const HELP_MESSAGE = `Usage: skybridge create [path] [options]
|
|
@@ -18,14 +20,15 @@ Arguments:
|
|
|
18
20
|
path Where the project will be created. Prompted when omitted.
|
|
19
21
|
|
|
20
22
|
Options:
|
|
21
|
-
--blank
|
|
22
|
-
--ecom
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
--
|
|
23
|
+
--blank scaffold a minimal project without demo tools and views
|
|
24
|
+
--ecom scaffold the ecommerce template (search products, render carousel)
|
|
25
|
+
--example <name> scaffold a copy of examples/<name> from the latest Skybridge release
|
|
26
|
+
--overwrite remove existing files if target directory is not empty
|
|
27
|
+
--pm <choice> package manager to use (choices: ${PACKAGE_MANAGERS.join(", ")}. default to npm when none is provided or infered)
|
|
28
|
+
--skip-skills skip installing coding agent skills
|
|
29
|
+
--start start dev server
|
|
30
|
+
--yes skip prompts and use default values for unprovided options
|
|
31
|
+
--help display this help message
|
|
29
32
|
|
|
30
33
|
Non-interactive usage:
|
|
31
34
|
Mandatory: path argument and --yes option
|
|
@@ -70,7 +73,7 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
70
73
|
"start",
|
|
71
74
|
"yes",
|
|
72
75
|
],
|
|
73
|
-
string: ["pm"],
|
|
76
|
+
string: ["pm", "example"],
|
|
74
77
|
alias: { h: "help" },
|
|
75
78
|
});
|
|
76
79
|
if (argv.help) {
|
|
@@ -82,6 +85,13 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
82
85
|
if (yes && !targetDir) {
|
|
83
86
|
abort("The target directory is required in non-interactive mode.", "Example: skybridge create my-app --yes");
|
|
84
87
|
}
|
|
88
|
+
if (argv.example !== undefined && !/^[\w.-]+$/.test(argv.example)) {
|
|
89
|
+
abort("--example requires a name, e.g. --example auth-descope.");
|
|
90
|
+
}
|
|
91
|
+
if (argv.example && (argv.blank || argv.ecom)) {
|
|
92
|
+
abort("Cannot combine --example with --blank or --ecom.");
|
|
93
|
+
}
|
|
94
|
+
const example = argv.example;
|
|
85
95
|
let pm = parsePackageManager(argv.pm || "");
|
|
86
96
|
if (argv.pm && !pm) {
|
|
87
97
|
abort(`Invalid --pm value "${argv.pm}". Expected one of: ${PACKAGE_MANAGERS.join(", ")}.`);
|
|
@@ -104,6 +114,18 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
104
114
|
targetDir = sanitizeTargetDir(choice);
|
|
105
115
|
}
|
|
106
116
|
// 2. Existing-directory handling
|
|
117
|
+
let downloaded;
|
|
118
|
+
if (example) {
|
|
119
|
+
Spinner.start(`Downloading ${example} example`);
|
|
120
|
+
try {
|
|
121
|
+
downloaded = await downloadExample(example);
|
|
122
|
+
Spinner.stop(`Downloaded ${example} example`);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
Spinner.error(`Failed to download ${example} example`);
|
|
126
|
+
abort(error instanceof Error ? error.message : String(error));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
107
129
|
if (fs.existsSync(targetDir) && !isEmpty(targetDir)) {
|
|
108
130
|
if (argv.overwrite) {
|
|
109
131
|
emptyDir(targetDir);
|
|
@@ -136,7 +158,7 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
136
158
|
}
|
|
137
159
|
template = "ecom";
|
|
138
160
|
}
|
|
139
|
-
if (!template) {
|
|
161
|
+
if (!template && !example) {
|
|
140
162
|
if (yes) {
|
|
141
163
|
template = "demo";
|
|
142
164
|
}
|
|
@@ -170,23 +192,31 @@ export async function init(args = process.argv.slice(2)) {
|
|
|
170
192
|
}
|
|
171
193
|
// 4. Copy template
|
|
172
194
|
const root = path.resolve(targetDir);
|
|
173
|
-
|
|
195
|
+
const templatesDir = fileURLToPath(new URL("../templates", import.meta.url));
|
|
196
|
+
const source = downloaded?.source ?? path.join(templatesDir, template ?? "demo");
|
|
197
|
+
Spinner.start(`Copying ${example ?? template} template`);
|
|
174
198
|
try {
|
|
175
|
-
|
|
176
|
-
fs.cpSync(templateDir, root, {
|
|
199
|
+
fs.cpSync(source, root, {
|
|
177
200
|
recursive: true,
|
|
178
201
|
filter: (src) => [".npmrc"].every((file) => !src.endsWith(file)),
|
|
179
202
|
});
|
|
203
|
+
const gitignore = path.join(root, ".gitignore");
|
|
180
204
|
const gitignoreSource = path.join(root, "_gitignore");
|
|
181
205
|
if (fs.existsSync(gitignoreSource)) {
|
|
182
|
-
fs.renameSync(gitignoreSource,
|
|
206
|
+
fs.renameSync(gitignoreSource, gitignore);
|
|
207
|
+
}
|
|
208
|
+
else if (!fs.existsSync(gitignore)) {
|
|
209
|
+
fs.copyFileSync(path.join(templatesDir, "demo", "_gitignore"), gitignore);
|
|
183
210
|
}
|
|
184
|
-
Spinner.stop(`Copied ${template} template`);
|
|
211
|
+
Spinner.stop(`Copied ${example ?? template} template`);
|
|
185
212
|
}
|
|
186
213
|
catch (error) {
|
|
187
214
|
Spinner.error("Failed to copy template");
|
|
188
215
|
abort(String(error));
|
|
189
216
|
}
|
|
217
|
+
finally {
|
|
218
|
+
downloaded?.cleanup();
|
|
219
|
+
}
|
|
190
220
|
// 5. Set package.json name to the project dir basename
|
|
191
221
|
try {
|
|
192
222
|
const pkgPath = path.join(root, "package.json");
|
|
@@ -340,6 +370,62 @@ ${scriptCommand(pm, "deploy")}`);
|
|
|
340
370
|
Chat: https://discord.alpic.ai
|
|
341
371
|
Docs: https://docs.skybridge.tech`);
|
|
342
372
|
}
|
|
373
|
+
async function fetchJson(url) {
|
|
374
|
+
const res = await fetch(url, {
|
|
375
|
+
headers: { accept: "application/vnd.github+json" },
|
|
376
|
+
});
|
|
377
|
+
if (!res.ok) {
|
|
378
|
+
throw new Error(`GitHub returned ${res.status} for ${url}.`);
|
|
379
|
+
}
|
|
380
|
+
return res.json();
|
|
381
|
+
}
|
|
382
|
+
async function downloadExample(name) {
|
|
383
|
+
const api = `https://api.github.com/repos/${REPO}`;
|
|
384
|
+
const { tag_name: tag } = await fetchJson(`${api}/releases/latest`);
|
|
385
|
+
const entries = await fetchJson(`${api}/contents/examples?ref=${tag}`);
|
|
386
|
+
const available = entries
|
|
387
|
+
.filter((entry) => entry.type === "dir")
|
|
388
|
+
.map((entry) => entry.name);
|
|
389
|
+
if (!available.includes(name)) {
|
|
390
|
+
throw new Error(`Unknown example "${name}". Available examples:\n ${available.join("\n ")}`);
|
|
391
|
+
}
|
|
392
|
+
const res = await fetch(`https://codeload.github.com/${REPO}/tar.gz/${tag}`);
|
|
393
|
+
if (!res.ok) {
|
|
394
|
+
throw new Error(`GitHub returned ${res.status} while fetching ${REPO}.`);
|
|
395
|
+
}
|
|
396
|
+
const archive = Buffer.from(await res.arrayBuffer());
|
|
397
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "skybridge-example-"));
|
|
398
|
+
const cleanup = () => fs.rmSync(tmp, { recursive: true, force: true });
|
|
399
|
+
try {
|
|
400
|
+
const tar = spawn("tar", ["-xz", "-C", tmp], {
|
|
401
|
+
stdio: ["pipe", "ignore", "pipe"],
|
|
402
|
+
});
|
|
403
|
+
let stderr = "";
|
|
404
|
+
tar.stderr?.on("data", (chunk) => {
|
|
405
|
+
stderr += chunk.toString();
|
|
406
|
+
});
|
|
407
|
+
const exit = new Promise((resolve, reject) => {
|
|
408
|
+
tar.on("error", (error) => reject(error.code === "ENOENT"
|
|
409
|
+
? new Error("`tar` is required to extract the example.")
|
|
410
|
+
: error));
|
|
411
|
+
tar.on("close", (status) => status === 0
|
|
412
|
+
? resolve()
|
|
413
|
+
: reject(new Error(`tar exited with ${status}: ${stderr.trim()}`)));
|
|
414
|
+
});
|
|
415
|
+
tar.stdin?.on("error", () => { });
|
|
416
|
+
tar.stdin?.end(archive);
|
|
417
|
+
await exit;
|
|
418
|
+
const [extracted] = fs.readdirSync(tmp);
|
|
419
|
+
if (!extracted) {
|
|
420
|
+
throw new Error("Downloaded archive is empty.");
|
|
421
|
+
}
|
|
422
|
+
return { source: path.join(tmp, extracted, "examples", name), cleanup };
|
|
423
|
+
}
|
|
424
|
+
catch (error) {
|
|
425
|
+
cleanup();
|
|
426
|
+
throw error;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
343
429
|
function cancel() {
|
|
344
430
|
prompts.cancel("Operation cancelled");
|
|
345
431
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -48,7 +48,8 @@ This command starts:
|
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
├── src/
|
|
51
|
-
│ ├──
|
|
51
|
+
│ ├── index.ts # Entry point (starts the app)
|
|
52
|
+
│ ├── server.ts # App definition (tools, views)
|
|
52
53
|
│ └── helpers.ts # Shared utilities
|
|
53
54
|
├── vite.config.ts
|
|
54
55
|
├── alpic.json # Deployment config
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
"deploy": "alpic deploy"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
15
|
+
"skybridge": "^0.0.0-dev.df1e961",
|
|
16
|
+
"vite": "^8.1.5",
|
|
17
|
+
"zod": "^4.4.3"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@skybridge/devtools": "^
|
|
21
|
-
"@skybridge/vite-plugin": "^0.0.0-dev.
|
|
20
|
+
"@skybridge/devtools": "^0.0.0-dev.df1e961",
|
|
21
|
+
"@skybridge/vite-plugin": "^0.0.0-dev.df1e961",
|
|
22
22
|
"@types/node": "^24.13.3",
|
|
23
23
|
"alpic": "^1.155.0",
|
|
24
24
|
"tsx": "^4.23.1",
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const server = new McpServer(
|
|
4
|
-
{
|
|
5
|
-
name: "skybridge-blank",
|
|
6
|
-
version: "0.0.1",
|
|
7
|
-
},
|
|
8
|
-
{ capabilities: {} },
|
|
9
|
-
);
|
|
1
|
+
import { Skybridge } from "skybridge/server";
|
|
10
2
|
|
|
11
3
|
// Register tools with `server.registerTool(...)`.
|
|
12
4
|
// Docs: https://docs.skybridge.tech/api-reference/register-tool
|
|
13
5
|
|
|
14
|
-
export
|
|
6
|
+
export const app = new Skybridge({
|
|
7
|
+
name: "skybridge-blank",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
handler: (server) => server,
|
|
10
|
+
});
|
|
15
11
|
|
|
16
|
-
export type AppType = typeof
|
|
12
|
+
export type AppType = typeof app;
|
package/templates/demo/README.md
CHANGED
|
@@ -48,11 +48,13 @@ This command starts:
|
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
├── src/
|
|
51
|
-
│ ├──
|
|
51
|
+
│ ├── index.ts # Entry point (starts the app)
|
|
52
|
+
│ ├── server.ts # App definition (tools, views)
|
|
52
53
|
│ ├── views/ # React components (one per view)
|
|
53
54
|
│ ├── components/ # Shared UI components
|
|
54
55
|
│ ├── helpers.ts # Shared utilities
|
|
55
56
|
│ └── index.css # Global styles
|
|
57
|
+
├── evals/ # Model-driven scenarios (pnpm evals, needs ANTHROPIC_API_KEY)
|
|
56
58
|
├── vite.config.ts
|
|
57
59
|
├── alpic.json # Deployment config
|
|
58
60
|
└── package.json
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
2
|
+
import { start } from "@skybridge/test";
|
|
3
|
+
import { expect, it } from "vitest";
|
|
4
|
+
import { app } from "../src/server.js";
|
|
5
|
+
|
|
6
|
+
it("reaches the onboarding tool from a natural prompt", async () => {
|
|
7
|
+
const chat = await start({ app, model: anthropic("claude-sonnet-4-5") });
|
|
8
|
+
await chat.send("Get me started with Skybridge, my name is Ada");
|
|
9
|
+
|
|
10
|
+
expect.chat(chat).toHaveCalledToolOnce("start");
|
|
11
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
+
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
+
basedir=`cygpath -w "$basedir"`
|
|
8
|
+
fi
|
|
9
|
+
;;
|
|
10
|
+
esac
|
|
11
|
+
|
|
12
|
+
if [ -z "$NODE_PATH" ]; then
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vitest@4.1.10_@opentelemetry+api@1.9.1_@types+node@24.13.3_@vitest+ui@4.1.10_jsdom@29.1_07746666baa47915e6a10611198811a1/node_modules/vitest/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vitest@4.1.10_@opentelemetry+api@1.9.1_@types+node@24.13.3_@vitest+ui@4.1.10_jsdom@29.1_07746666baa47915e6a10611198811a1/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
|
+
else
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vitest@4.1.10_@opentelemetry+api@1.9.1_@types+node@24.13.3_@vitest+ui@4.1.10_jsdom@29.1_07746666baa47915e6a10611198811a1/node_modules/vitest/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/vitest@4.1.10_@opentelemetry+api@1.9.1_@types+node@24.13.3_@vitest+ui@4.1.10_jsdom@29.1_07746666baa47915e6a10611198811a1/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
+
fi
|
|
17
|
+
if [ -x "$basedir/node" ]; then
|
|
18
|
+
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
19
|
+
else
|
|
20
|
+
exec node "$basedir/../vitest/vitest.mjs" "$@"
|
|
21
|
+
fi
|
|
@@ -9,32 +9,37 @@
|
|
|
9
9
|
"dev:tunnel": "skybridge dev --tunnel",
|
|
10
10
|
"build": "skybridge build",
|
|
11
11
|
"start": "skybridge start",
|
|
12
|
-
"deploy": "alpic deploy"
|
|
12
|
+
"deploy": "alpic deploy",
|
|
13
|
+
"evals": "vitest run evals",
|
|
14
|
+
"evals:types": "tsc --noEmit -p tsconfig.evals.json"
|
|
13
15
|
},
|
|
14
16
|
"dependencies": {
|
|
15
17
|
"@alpic-ai/ui": "^1.155.0",
|
|
16
|
-
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
17
18
|
"lucide-react": "^1.25.0",
|
|
18
19
|
"react": "^19.2.7",
|
|
19
20
|
"react-dom": "^19.2.7",
|
|
20
|
-
"skybridge": "^0.0.0-dev.
|
|
21
|
+
"skybridge": "^0.0.0-dev.df1e961",
|
|
21
22
|
"sonner": "^2.0.7",
|
|
22
23
|
"tw-animate-css": "^1.4.0",
|
|
23
24
|
"vite": "^8.1.5",
|
|
24
25
|
"zod": "^4.4.3"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@
|
|
28
|
-
"@skybridge/
|
|
28
|
+
"@ai-sdk/anthropic": "^2.0.90",
|
|
29
|
+
"@skybridge/devtools": "^0.0.0-dev.df1e961",
|
|
30
|
+
"@skybridge/test": "beta",
|
|
31
|
+
"@skybridge/vite-plugin": "^0.0.0-dev.df1e961",
|
|
29
32
|
"@tailwindcss/vite": "^4.3.3",
|
|
30
33
|
"@types/node": "^24.13.3",
|
|
31
34
|
"@types/react": "^19.2.17",
|
|
32
35
|
"@types/react-dom": "^19.2.3",
|
|
33
36
|
"@vitejs/plugin-react": "^6.0.3",
|
|
37
|
+
"ai": "^5.0.0",
|
|
34
38
|
"alpic": "^1.155.0",
|
|
35
39
|
"tailwindcss": "^4.3.3",
|
|
36
40
|
"tsx": "^4.23.1",
|
|
37
|
-
"typescript": "^6.0.3"
|
|
41
|
+
"typescript": "^6.0.3",
|
|
42
|
+
"vitest": "^4.1.10"
|
|
38
43
|
},
|
|
39
44
|
"engines": {
|
|
40
45
|
"node": ">=24.18.0"
|
|
@@ -1,94 +1,92 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Skybridge } from "skybridge/server";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
4
|
+
export const app = new Skybridge({
|
|
5
|
+
name: "alpic-openai-app",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
handler: (server) =>
|
|
8
|
+
server
|
|
9
|
+
.registerTool(
|
|
10
|
+
{
|
|
11
|
+
name: "start",
|
|
12
|
+
description: "Onboard Skybridge",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
name: z.string().optional().describe("The user name."),
|
|
15
|
+
},
|
|
16
|
+
annotations: {
|
|
17
|
+
title: "Start Skybridge onboarding",
|
|
18
|
+
readOnlyHint: true,
|
|
19
|
+
destructiveHint: false,
|
|
20
|
+
openWorldHint: false,
|
|
21
|
+
},
|
|
22
|
+
_meta: {
|
|
23
|
+
"openai/toolInvocation/invoking":
|
|
24
|
+
"Starting the Skybridge onboarding…",
|
|
25
|
+
"openai/toolInvocation/invoked": "Onboarding ready.",
|
|
26
|
+
},
|
|
27
|
+
view: {
|
|
28
|
+
component: "onboarding",
|
|
29
|
+
// Replace with the URL your widget will be served from in production.
|
|
30
|
+
domain: "https://skybridge.tech",
|
|
31
|
+
description: "Onboarding deck",
|
|
32
|
+
csp: {
|
|
33
|
+
resourceDomains: [
|
|
34
|
+
"https://fonts.googleapis.com",
|
|
35
|
+
"https://fonts.gstatic.com",
|
|
36
|
+
],
|
|
37
|
+
redirectDomains: ["https://docs.skybridge.tech"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
39
40
|
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const prediction =
|
|
79
|
-
predictions[Math.floor(Math.random() * predictions.length)];
|
|
80
|
-
|
|
81
|
-
// simulate backend work
|
|
82
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
41
|
+
async ({ name }) => {
|
|
42
|
+
return {
|
|
43
|
+
structuredContent: { name },
|
|
44
|
+
content: [{ type: "text", text: `User name: ${name ?? "friend"}` }],
|
|
45
|
+
isError: false,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
.registerTool(
|
|
50
|
+
{
|
|
51
|
+
name: "get-fortune-cookie",
|
|
52
|
+
description: "Get fortune cookie",
|
|
53
|
+
annotations: {
|
|
54
|
+
title: "Get a fortune cookie",
|
|
55
|
+
readOnlyHint: true,
|
|
56
|
+
destructiveHint: false,
|
|
57
|
+
openWorldHint: false,
|
|
58
|
+
},
|
|
59
|
+
_meta: {
|
|
60
|
+
"openai/toolInvocation/invoking": "Cracking open a fortune cookie…",
|
|
61
|
+
"openai/toolInvocation/invoked": "Fortune revealed.",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
async () => {
|
|
65
|
+
const predictions = [
|
|
66
|
+
"A pleasant surprise is waiting for you.",
|
|
67
|
+
"Your hard work will soon pay off.",
|
|
68
|
+
"An unexpected friendship will brighten your week.",
|
|
69
|
+
"The best is yet to come.",
|
|
70
|
+
"A small step today leads to a giant leap tomorrow.",
|
|
71
|
+
"Trust your instincts: they are sharper than you think.",
|
|
72
|
+
"Adventure awaits just around the corner.",
|
|
73
|
+
"A long-forgotten idea will return with great success.",
|
|
74
|
+
"Kindness given today will be returned threefold.",
|
|
75
|
+
"Something you lost will soon be found.",
|
|
76
|
+
];
|
|
77
|
+
const prediction =
|
|
78
|
+
predictions[Math.floor(Math.random() * predictions.length)];
|
|
83
79
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
content: [{ type: "text", text: prediction }],
|
|
87
|
-
isError: false,
|
|
88
|
-
};
|
|
89
|
-
},
|
|
90
|
-
);
|
|
80
|
+
// simulate backend work
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
91
82
|
|
|
92
|
-
|
|
83
|
+
return {
|
|
84
|
+
structuredContent: { prediction },
|
|
85
|
+
content: [{ type: "text", text: prediction }],
|
|
86
|
+
isError: false,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
),
|
|
90
|
+
});
|
|
93
91
|
|
|
94
|
-
export type AppType = typeof
|
|
92
|
+
export type AppType = typeof app;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@/index.css";
|
|
2
2
|
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useUser } from "skybridge/web";
|
|
5
5
|
import Nav from "./components/nav.js";
|
|
6
6
|
import Progress from "./components/progress.js";
|
|
7
7
|
import Outro from "./components/steps/outro.js";
|
|
@@ -18,8 +18,8 @@ const STEPS = [
|
|
|
18
18
|
] as const;
|
|
19
19
|
|
|
20
20
|
export default function Onboarding() {
|
|
21
|
-
//
|
|
22
|
-
const { theme } =
|
|
21
|
+
// useUser: read user environment info (theme, locale, user agent).
|
|
22
|
+
const { theme } = useUser();
|
|
23
23
|
|
|
24
24
|
const [step, setStep] = useState(0);
|
|
25
25
|
const { img } = useMascot();
|
|
@@ -5,7 +5,7 @@ import react from "@vitejs/plugin-react";
|
|
|
5
5
|
import { defineConfig } from "vite";
|
|
6
6
|
|
|
7
7
|
export default defineConfig({
|
|
8
|
-
plugins: [skybridge(), react(), tailwindcss()],
|
|
8
|
+
plugins: [skybridge({ evals: {} }), react(), tailwindcss()],
|
|
9
9
|
server: {
|
|
10
10
|
forwardConsole: {
|
|
11
11
|
unhandledErrors: true,
|
|
@@ -14,7 +14,7 @@ export default defineConfig({
|
|
|
14
14
|
},
|
|
15
15
|
resolve: {
|
|
16
16
|
alias: {
|
|
17
|
-
"@": path.resolve(
|
|
17
|
+
"@": path.resolve(import.meta.dirname, "./src"),
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
20
|
});
|
package/templates/ecom/README.md
CHANGED
|
@@ -48,7 +48,8 @@ This command starts:
|
|
|
48
48
|
|
|
49
49
|
```
|
|
50
50
|
├── src/
|
|
51
|
-
│ ├──
|
|
51
|
+
│ ├── index.ts # Entry point (starts the app)
|
|
52
|
+
│ ├── server.ts # App definition (tools, views)
|
|
52
53
|
│ └── helpers.ts # Shared utilities
|
|
53
54
|
├── vite.config.ts
|
|
54
55
|
├── alpic.json # Deployment config
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.
|
|
13
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@types+node@24.13.3_@types+react@19.2.17_jiti@2.
|
|
15
|
+
export NODE_PATH="/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules/@ladle/react/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/@ladle+react@5.1.1_@swc+helpers@0.5.23_@types+node@24.13.3_@types+react@19.2.17_jiti@2._9105ecfa2ac4b29fe87a036530c3844f/node_modules:/home/runner/work/skybridge/skybridge/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../@ladle/react/lib/cli/cli.js" "$@"
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"react": "^19.2.4",
|
|
18
18
|
"react-dom": "^19.2.4",
|
|
19
|
-
"skybridge": "^0.0.0-dev.
|
|
19
|
+
"skybridge": "^0.0.0-dev.df1e961",
|
|
20
20
|
"vite": "^8.1.3",
|
|
21
21
|
"zod": "^4.4.3"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@ladle/react": "^5.1.1",
|
|
25
|
-
"@skybridge/devtools": "^
|
|
26
|
-
"@skybridge/vite-plugin": "^0.0.0-dev.
|
|
25
|
+
"@skybridge/devtools": "^0.0.0-dev.df1e961",
|
|
26
|
+
"@skybridge/vite-plugin": "^0.0.0-dev.df1e961",
|
|
27
27
|
"@types/node": "^24.13.2",
|
|
28
28
|
"@types/react": "^19.2.14",
|
|
29
29
|
"@types/react-dom": "^19.2.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useUser } from "skybridge/web";
|
|
3
3
|
import { darkTheme, lightTheme } from "../design/tokens";
|
|
4
4
|
import { cx } from "../lib/cx";
|
|
5
5
|
import { viewFrame } from "./view-frame.css";
|
|
@@ -10,8 +10,8 @@ import { viewFrame } from "./view-frame.css";
|
|
|
10
10
|
* variables the color contract declares) and paints the base surface + font +
|
|
11
11
|
* content color so descendants inherit from the DS instead of the host page.
|
|
12
12
|
*
|
|
13
|
-
* It follows the host theme via
|
|
14
|
-
* (e.g. always light), drop
|
|
13
|
+
* It follows the host theme via useUser(). To lock the widget to one palette
|
|
14
|
+
* (e.g. always light), drop useUser and hardcode the theme class.
|
|
15
15
|
*
|
|
16
16
|
* Keep view entry files thin: render <ViewFrame> at the root and let this carry
|
|
17
17
|
* the theme + base-style boilerplate.
|
|
@@ -19,7 +19,7 @@ import { viewFrame } from "./view-frame.css";
|
|
|
19
19
|
type ViewFrameProps = HTMLAttributes<HTMLDivElement>;
|
|
20
20
|
|
|
21
21
|
export function ViewFrame({ className, ...rest }: ViewFrameProps) {
|
|
22
|
-
const { theme } =
|
|
22
|
+
const { theme } = useUser();
|
|
23
23
|
const themeClass = theme === "dark" ? darkTheme : lightTheme;
|
|
24
24
|
|
|
25
25
|
return <div {...rest} className={cx(themeClass, viewFrame, className)} />;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { Skybridge } from "skybridge/server";
|
|
3
3
|
import { CAROUSEL_RANGE, MIN_SEARCH_ITERATIONS } from "./config.js";
|
|
4
4
|
import {
|
|
5
5
|
renderCarouselDefinition,
|
|
@@ -15,15 +15,12 @@ if (existsSync(".env")) {
|
|
|
15
15
|
process.loadEnvFile();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
// @todo: adapt this server-wide prompt to your catalog.
|
|
26
|
-
instructions: `\
|
|
18
|
+
export const app = new Skybridge({
|
|
19
|
+
// @todo: name and version your app.
|
|
20
|
+
name: "skybridge-ecom",
|
|
21
|
+
version: "0.0.1",
|
|
22
|
+
// @todo: adapt this server-wide prompt to your catalog.
|
|
23
|
+
instructions: `\
|
|
27
24
|
Two phases:
|
|
28
25
|
|
|
29
26
|
SEARCH: Call search-products ${MIN_SEARCH_ITERATIONS}+ times before presenting, never off one call. \
|
|
@@ -33,11 +30,10 @@ once the carousel renders.
|
|
|
33
30
|
|
|
34
31
|
RENDER: After curating, call render-carousel with the chosen product IDs (aim for ${CAROUSEL_RANGE}). \
|
|
35
32
|
Speak once it renders, then recommend products in carousel order.`,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
handler: (server) =>
|
|
34
|
+
server
|
|
35
|
+
.registerTool(searchProductsDefinition, searchProductsHandler)
|
|
36
|
+
.registerTool(renderCarouselDefinition, renderCarouselHandler),
|
|
37
|
+
});
|
|
40
38
|
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
export type AppType = typeof server;
|
|
39
|
+
export type AppType = typeof app;
|