sunpeak 0.1.22 โ 0.2.2
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/README.md +18 -77
- package/bin/sunpeak.js +87 -0
- package/dist/index.cjs +828 -1338
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -581
- package/dist/index.d.ts +98 -581
- package/dist/index.js +796 -1314
- package/dist/index.js.map +1 -1
- package/dist/styles/chatgpt/index.css +146 -0
- package/dist/styles/globals.css +220 -0
- package/package.json +34 -36
- package/template/.prettierignore +4 -0
- package/template/.prettierrc +9 -0
- package/template/README.md +47 -0
- package/template/assets/favicon.ico +0 -0
- package/template/components.json +21 -0
- package/template/dev/main.tsx +65 -0
- package/template/dev/styles.css +5 -0
- package/template/eslint.config.cjs +49 -0
- package/template/index.html +13 -0
- package/template/package.json +56 -0
- package/template/src/App.tsx +45 -0
- package/template/src/components/index.ts +2 -0
- package/template/src/components/shadcn/button.tsx +60 -0
- package/template/src/components/shadcn/card.tsx +76 -0
- package/template/src/components/shadcn/carousel.tsx +260 -0
- package/template/src/components/shadcn/index.ts +5 -0
- package/template/src/components/shadcn/label.tsx +24 -0
- package/template/src/components/shadcn/select.tsx +157 -0
- package/template/src/components/sunpeak-card.test.tsx +76 -0
- package/template/src/components/sunpeak-card.tsx +140 -0
- package/template/src/components/sunpeak-carousel.test.tsx +42 -0
- package/template/src/components/sunpeak-carousel.tsx +126 -0
- package/template/src/index.ts +3 -0
- package/template/src/lib/index.ts +1 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/styles/chatgpt.css +146 -0
- package/template/src/styles/globals.css +220 -0
- package/template/src/test/setup.ts +37 -0
- package/template/tsconfig.json +32 -0
- package/template/tsconfig.node.json +11 -0
- package/template/tsup.config.ts +23 -0
- package/template/vite.config.ts +35 -0
- package/template/vitest.config.ts +15 -0
package/README.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<a href="https://sunpeak.ai">
|
|
3
|
+
<picture>
|
|
4
|
+
<img alt="Sunpeak logo" src="https://sunpeak.ai/images/sunpeak_github.svg">
|
|
5
|
+
</picture>
|
|
6
|
+
</a>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
1
9
|
# sunpeak
|
|
2
10
|
|
|
3
11
|
[](https://www.npmjs.com/package/sunpeak)
|
|
@@ -7,71 +15,26 @@
|
|
|
7
15
|
[](https://www.typescriptlang.org/)
|
|
8
16
|
[](https://reactjs.org/)
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
The ChatGPT Apps UI SDK. Build and test your ChatGPT App UI locally with approved shadcn React components.
|
|
11
19
|
|
|
12
|
-

|
|
13
21
|
|
|
14
22
|
**Key Features:**
|
|
15
23
|
- ๐บ ChatGPT simulator for rapid UI component development.
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
- ๐งช Testing framework that replicates advanced
|
|
24
|
+
- ๐ React component library built with [shadcn/ui](https://ui.shadcn.com/) and [Tailwind](https://tailwindcss.com/).
|
|
25
|
+
- ๐ฑ Interface for custom components that work across genAI platforms.
|
|
26
|
+
- ๐ค Styles that fit the [OpenAI design system](https://developers.openai.com/apps-sdk/build/chatgpt-ui).
|
|
27
|
+
- ๐งช Testing framework that replicates advanced ChatGPT behavior locally.
|
|
20
28
|
|
|
21
29
|
## Quickstart
|
|
22
30
|
|
|
23
31
|
Requirements: Node (20+), pnpm (10+)
|
|
24
32
|
|
|
25
|
-
Use our `create-sunpeak` utility to scaffold your own sunpeak app:
|
|
26
|
-
|
|
27
33
|
```bash
|
|
28
|
-
pnpm dlx
|
|
34
|
+
pnpm dlx sunpeak init my-app
|
|
29
35
|
cd my-app && pnpm dev
|
|
30
36
|
```
|
|
31
37
|
|
|
32
|
-
## Building Apps
|
|
33
|
-
|
|
34
|
-
### Use library components
|
|
35
|
-
|
|
36
|
-
```tsx
|
|
37
|
-
import { GenAI, Carousel, Card } from 'sunpeak';
|
|
38
|
-
|
|
39
|
-
export const MyCarousel = GenAI(() => (
|
|
40
|
-
<Carousel>
|
|
41
|
-
<Card
|
|
42
|
-
image="https://sunpeak.ai/images/sun.svg"
|
|
43
|
-
imageAlt="Sunpeak logo"
|
|
44
|
-
imageMaxWidth={400}
|
|
45
|
-
imageMaxHeight={400}
|
|
46
|
-
header="Card Title"
|
|
47
|
-
>
|
|
48
|
-
Card content
|
|
49
|
-
</Card>
|
|
50
|
-
</Carousel>
|
|
51
|
-
));
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Create a custom App
|
|
55
|
-
|
|
56
|
-
```tsx
|
|
57
|
-
import { GenAI } from 'sunpeak';
|
|
58
|
-
import { Box, Typography } from '@mui/material';
|
|
59
|
-
|
|
60
|
-
export const MyApp = GenAI(({ maxHeight, colorScheme }) => (
|
|
61
|
-
<Box sx={{ p: 3 }}>
|
|
62
|
-
<Typography variant="h5" gutterBottom>
|
|
63
|
-
Hello GenAI!
|
|
64
|
-
</Typography>
|
|
65
|
-
<Typography variant="body1" color="text.secondary">
|
|
66
|
-
Theme: {colorScheme}
|
|
67
|
-
</Typography>
|
|
68
|
-
<Typography variant="body2">
|
|
69
|
-
Max height: {maxHeight}px
|
|
70
|
-
</Typography>
|
|
71
|
-
</Box>
|
|
72
|
-
));
|
|
73
|
-
```
|
|
74
|
-
|
|
75
38
|
## Supported Platforms
|
|
76
39
|
|
|
77
40
|
- โ
**OpenAI ChatGPT** - Fully supported ([design guidelines](https://developers.openai.com/apps-sdk/concepts/design-guidelines))
|
|
@@ -79,29 +42,6 @@ export const MyApp = GenAI(({ maxHeight, colorScheme }) => (
|
|
|
79
42
|
- ๐ **Anthropic Claude** - Design system available (SDK support coming soon)
|
|
80
43
|
- ๐ง **Custom platforms** - Implement your own platform adapter
|
|
81
44
|
|
|
82
|
-
## What's Included
|
|
83
|
-
|
|
84
|
-
### Components
|
|
85
|
-
- **GenAI** - Single interface for building Apps, all Apps must use this wrapper
|
|
86
|
-
- Automatic MUI theming (light/dark mode)
|
|
87
|
-
- Platform constraints (maxHeight)
|
|
88
|
-
- **Card** - Responsive card component
|
|
89
|
-
- **Carousel** - Horizontal scrolling carousel
|
|
90
|
-
- **ChatGPTSimulator** - Local development & testing environment
|
|
91
|
-
|
|
92
|
-
### Hooks
|
|
93
|
-
- **usePlatformGlobal** - Platform-agnostic global state access
|
|
94
|
-
- **useDisplayMode** - Get current display mode
|
|
95
|
-
- **useRequestDisplayMode** - Request a specific display mode (e.g., fullscreen)
|
|
96
|
-
- **useWidgetProps** - Access tool output data
|
|
97
|
-
- **useWidgetState** - Manage persistent widget state
|
|
98
|
-
- **useMaxHeight** - Get height constraints
|
|
99
|
-
- **useColorScheme** - Get current color scheme (light/dark)
|
|
100
|
-
|
|
101
|
-
### Design Systems
|
|
102
|
-
- **ChatGPT** - MUI theme following OpenAI Apps SDK guidelines
|
|
103
|
-
- **Custom** - Build your own MUI theme
|
|
104
|
-
|
|
105
45
|
## Contributing
|
|
106
46
|
|
|
107
47
|
We welcome your contributions!
|
|
@@ -110,5 +50,6 @@ For development quickstart on this package, see [DEVELOPMENT.md](./DEVELOPMENT.m
|
|
|
110
50
|
|
|
111
51
|
## Resources
|
|
112
52
|
|
|
113
|
-
- [
|
|
114
|
-
- [
|
|
53
|
+
- [ChatGPT Apps SDK Design Guidelines](https://developers.openai.com/apps-sdk/concepts/design-guidelines)
|
|
54
|
+
- [ChatGPT Apps SDK UI Documentation](https://developers.openai.com/apps-sdk/build/chatgpt-ui)
|
|
55
|
+
- [ChatGPT Apps SDK Examples](https://github.com/openai/openai-apps-sdk-examples)
|
package/bin/sunpeak.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { existsSync, mkdirSync, cpSync, readFileSync, writeFileSync } from 'fs';
|
|
4
|
+
import { join, dirname, basename } from 'path';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { createInterface } from 'readline';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
|
|
10
|
+
function prompt(question) {
|
|
11
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
rl.question(question, (answer) => {
|
|
14
|
+
rl.close();
|
|
15
|
+
resolve(answer.trim());
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function init(projectName) {
|
|
21
|
+
if (!projectName) {
|
|
22
|
+
projectName = await prompt('โ๏ธ ๐๏ธ Project name [my-app]: ');
|
|
23
|
+
if (!projectName) {
|
|
24
|
+
projectName = 'my-app'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const targetDir = join(process.cwd(), projectName);
|
|
29
|
+
|
|
30
|
+
if (existsSync(targetDir)) {
|
|
31
|
+
console.error(`Error: Directory "${projectName}" already exists`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const templateDir = join(__dirname, '..', 'template');
|
|
36
|
+
|
|
37
|
+
console.log(`โ๏ธ ๐๏ธ Creating ${projectName}...`);
|
|
38
|
+
|
|
39
|
+
mkdirSync(targetDir, { recursive: true });
|
|
40
|
+
|
|
41
|
+
cpSync(templateDir, targetDir, {
|
|
42
|
+
recursive: true,
|
|
43
|
+
filter: (src) => {
|
|
44
|
+
const name = basename(src);
|
|
45
|
+
return name !== 'node_modules' && name !== 'pnpm-lock.yaml';
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Read sunpeak version from root package.json
|
|
50
|
+
const rootPkgPath = join(__dirname, '..', 'package.json');
|
|
51
|
+
const rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf-8'));
|
|
52
|
+
const sunpeakVersion = `^${rootPkg.version}`;
|
|
53
|
+
|
|
54
|
+
// Update project package.json
|
|
55
|
+
const pkgPath = join(targetDir, 'package.json');
|
|
56
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
57
|
+
pkg.name = projectName;
|
|
58
|
+
|
|
59
|
+
// Replace workspace:* with actual version
|
|
60
|
+
if (pkg.dependencies?.sunpeak === 'workspace:*') {
|
|
61
|
+
pkg.dependencies.sunpeak = sunpeakVersion;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n');
|
|
65
|
+
|
|
66
|
+
console.log(`
|
|
67
|
+
Done! To get started:
|
|
68
|
+
|
|
69
|
+
cd ${projectName}
|
|
70
|
+
pnpm install && pnpm dev
|
|
71
|
+
|
|
72
|
+
See README.md for more details.
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const [,, command, ...args] = process.argv;
|
|
77
|
+
|
|
78
|
+
if (command === 'init') {
|
|
79
|
+
init(args[0]);
|
|
80
|
+
} else {
|
|
81
|
+
console.log(`
|
|
82
|
+
sunpeak - ChatGPT Apps UI SDK
|
|
83
|
+
|
|
84
|
+
Commands:
|
|
85
|
+
init [name] Create a new project from template
|
|
86
|
+
`);
|
|
87
|
+
}
|