opencode-generative-ui 0.1.0

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.
@@ -0,0 +1,163 @@
1
+ // Pre-built CSS classes for SVG diagrams.
2
+ // Reverse-engineered from the claude.ai artifact rendering system based on the
3
+ // design guidelines extracted in guidelines.ts. These classes are what the
4
+ // guidelines mean by "already loaded in SVG widget".
5
+ export const SVG_STYLES = `
6
+ :root {
7
+ --p: #e0e0e0;
8
+ --s: #a0a0a0;
9
+ --t: #707070;
10
+ --bg2: #2a2a2a;
11
+ --b: #404040;
12
+ --color-text-primary: #e0e0e0;
13
+ --color-text-secondary: #a0a0a0;
14
+ --color-text-tertiary: #707070;
15
+ --color-text-info: #85B7EB;
16
+ --color-text-danger: #F09595;
17
+ --color-text-success: #97C459;
18
+ --color-text-warning: #EF9F27;
19
+ --color-background-primary: #1a1a1a;
20
+ --color-background-secondary: #2a2a2a;
21
+ --color-background-tertiary: #111111;
22
+ --color-background-info: #0C447C;
23
+ --color-background-danger: #791F1F;
24
+ --color-background-success: #27500A;
25
+ --color-background-warning: #633806;
26
+ --color-border-primary: rgba(255,255,255,0.4);
27
+ --color-border-secondary: rgba(255,255,255,0.3);
28
+ --color-border-tertiary: rgba(255,255,255,0.15);
29
+ --color-border-info: #85B7EB;
30
+ --color-border-danger: #F09595;
31
+ --color-border-success: #97C459;
32
+ --color-border-warning: #EF9F27;
33
+ --font-sans: system-ui, -apple-system, sans-serif;
34
+ --font-serif: Georgia, serif;
35
+ --font-mono: ui-monospace, monospace;
36
+ --border-radius-md: 8px;
37
+ --border-radius-lg: 12px;
38
+ --border-radius-xl: 16px;
39
+ }
40
+
41
+ /* Text classes */
42
+ svg .t { font-family: var(--font-sans); font-size: 14px; fill: var(--p); }
43
+ svg .ts { font-family: var(--font-sans); font-size: 12px; fill: var(--s); }
44
+ svg .th { font-family: var(--font-sans); font-size: 14px; font-weight: 500; fill: var(--p); }
45
+
46
+ /* Neutral box */
47
+ svg .box { fill: var(--bg2); stroke: var(--b); }
48
+
49
+ /* Clickable node */
50
+ svg .node { cursor: pointer; }
51
+ svg .node:hover { opacity: 0.8; }
52
+
53
+ /* Arrow connector */
54
+ svg .arr { stroke: var(--t); stroke-width: 1.5; fill: none; }
55
+
56
+ /* Leader line */
57
+ svg .leader { stroke: var(--t); stroke-width: 0.5; stroke-dasharray: 4 3; fill: none; }
58
+
59
+ /* Color ramp classes */
60
+
61
+ /* Purple: 800=#3C3489, 200=#AFA9EC, 100=#CECBF6 */
62
+ svg .c-purple > rect, svg .c-purple > circle, svg .c-purple > ellipse { fill: #3C3489; stroke: #AFA9EC; }
63
+ svg .c-purple > .th, svg .c-purple > .t { fill: #CECBF6; }
64
+ svg .c-purple > .ts { fill: #AFA9EC; }
65
+ svg rect.c-purple, svg circle.c-purple, svg ellipse.c-purple { fill: #3C3489; stroke: #AFA9EC; }
66
+
67
+ /* Teal: 800=#085041, 200=#5DCAA5, 100=#9FE1CB */
68
+ svg .c-teal > rect, svg .c-teal > circle, svg .c-teal > ellipse { fill: #085041; stroke: #5DCAA5; }
69
+ svg .c-teal > .th, svg .c-teal > .t { fill: #9FE1CB; }
70
+ svg .c-teal > .ts { fill: #5DCAA5; }
71
+ svg rect.c-teal, svg circle.c-teal, svg ellipse.c-teal { fill: #085041; stroke: #5DCAA5; }
72
+
73
+ /* Coral: 800=#712B13, 200=#F0997B, 100=#F5C4B3 */
74
+ svg .c-coral > rect, svg .c-coral > circle, svg .c-coral > ellipse { fill: #712B13; stroke: #F0997B; }
75
+ svg .c-coral > .th, svg .c-coral > .t { fill: #F5C4B3; }
76
+ svg .c-coral > .ts { fill: #F0997B; }
77
+ svg rect.c-coral, svg circle.c-coral, svg ellipse.c-coral { fill: #712B13; stroke: #F0997B; }
78
+
79
+ /* Pink: 800=#72243E, 200=#ED93B1, 100=#F4C0D1 */
80
+ svg .c-pink > rect, svg .c-pink > circle, svg .c-pink > ellipse { fill: #72243E; stroke: #ED93B1; }
81
+ svg .c-pink > .th, svg .c-pink > .t { fill: #F4C0D1; }
82
+ svg .c-pink > .ts { fill: #ED93B1; }
83
+ svg rect.c-pink, svg circle.c-pink, svg ellipse.c-pink { fill: #72243E; stroke: #ED93B1; }
84
+
85
+ /* Gray: 800=#444441, 200=#B4B2A9, 100=#D3D1C7 */
86
+ svg .c-gray > rect, svg .c-gray > circle, svg .c-gray > ellipse { fill: #444441; stroke: #B4B2A9; }
87
+ svg .c-gray > .th, svg .c-gray > .t { fill: #D3D1C7; }
88
+ svg .c-gray > .ts { fill: #B4B2A9; }
89
+ svg rect.c-gray, svg circle.c-gray, svg ellipse.c-gray { fill: #444441; stroke: #B4B2A9; }
90
+
91
+ /* Blue: 800=#0C447C, 200=#85B7EB, 100=#B5D4F4 */
92
+ svg .c-blue > rect, svg .c-blue > circle, svg .c-blue > ellipse { fill: #0C447C; stroke: #85B7EB; }
93
+ svg .c-blue > .th, svg .c-blue > .t { fill: #B5D4F4; }
94
+ svg .c-blue > .ts { fill: #85B7EB; }
95
+ svg rect.c-blue, svg circle.c-blue, svg ellipse.c-blue { fill: #0C447C; stroke: #85B7EB; }
96
+
97
+ /* Green: 800=#27500A, 200=#97C459, 100=#C0DD97 */
98
+ svg .c-green > rect, svg .c-green > circle, svg .c-green > ellipse { fill: #27500A; stroke: #97C459; }
99
+ svg .c-green > .th, svg .c-green > .t { fill: #C0DD97; }
100
+ svg .c-green > .ts { fill: #97C459; }
101
+ svg rect.c-green, svg circle.c-green, svg ellipse.c-green { fill: #27500A; stroke: #97C459; }
102
+
103
+ /* Amber: 800=#633806, 200=#EF9F27, 100=#FAC775 */
104
+ svg .c-amber > rect, svg .c-amber > circle, svg .c-amber > ellipse { fill: #633806; stroke: #EF9F27; }
105
+ svg .c-amber > .th, svg .c-amber > .t { fill: #FAC775; }
106
+ svg .c-amber > .ts { fill: #EF9F27; }
107
+ svg rect.c-amber, svg circle.c-amber, svg ellipse.c-amber { fill: #633806; stroke: #EF9F27; }
108
+
109
+ /* Red: 800=#791F1F, 200=#F09595, 100=#F7C1C1 */
110
+ svg .c-red > rect, svg .c-red > circle, svg .c-red > ellipse { fill: #791F1F; stroke: #F09595; }
111
+ svg .c-red > .th, svg .c-red > .t { fill: #F7C1C1; }
112
+ svg .c-red > .ts { fill: #F09595; }
113
+ svg rect.c-red, svg circle.c-red, svg ellipse.c-red { fill: #791F1F; stroke: #F09595; }
114
+
115
+ /* Pre-styled form elements */
116
+ button {
117
+ background: transparent;
118
+ border: 0.5px solid var(--color-border-secondary);
119
+ border-radius: var(--border-radius-md);
120
+ color: var(--color-text-primary);
121
+ padding: 6px 14px;
122
+ font-size: 14px;
123
+ cursor: pointer;
124
+ font-family: var(--font-sans);
125
+ }
126
+ button:hover { background: var(--color-background-secondary); }
127
+ button:active { transform: scale(0.98); }
128
+
129
+ input[type="range"] {
130
+ -webkit-appearance: none;
131
+ height: 4px;
132
+ background: var(--color-border-secondary);
133
+ border-radius: 2px;
134
+ outline: none;
135
+ }
136
+ input[type="range"]::-webkit-slider-thumb {
137
+ -webkit-appearance: none;
138
+ width: 18px;
139
+ height: 18px;
140
+ border-radius: 50%;
141
+ background: var(--color-text-primary);
142
+ cursor: pointer;
143
+ }
144
+
145
+ input[type="text"], input[type="number"], textarea, select {
146
+ height: 36px;
147
+ background: var(--color-background-primary);
148
+ border: 0.5px solid var(--color-border-tertiary);
149
+ border-radius: var(--border-radius-md);
150
+ color: var(--color-text-primary);
151
+ padding: 0 10px;
152
+ font-size: 14px;
153
+ font-family: var(--font-sans);
154
+ outline: none;
155
+ }
156
+ input[type="text"]:hover, input[type="number"]:hover, textarea:hover, select:hover {
157
+ border-color: var(--color-border-secondary);
158
+ }
159
+ input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
160
+ border-color: var(--color-border-primary);
161
+ box-shadow: 0 0 0 2px rgba(255,255,255,0.1);
162
+ }
163
+ `;
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "opencode-generative-ui",
3
+ "version": "0.1.0",
4
+ "description": "OpenCode plugin that renders HTML and SVG widgets in native macOS windows using Glimpse.",
5
+ "type": "module",
6
+ "exports": "./dist/index.js",
7
+ "main": "./dist/index.js",
8
+ "files": [
9
+ "dist",
10
+ "src/glimpseui.d.ts",
11
+ "README.md",
12
+ "LICENSE"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.build.json",
16
+ "clean": "rm -rf dist",
17
+ "prepublishOnly": "bun run clean && bun run build && bun run typecheck",
18
+ "typecheck": "tsc -p tsconfig.json"
19
+ },
20
+ "keywords": [
21
+ "opencode",
22
+ "opencode-plugin",
23
+ "plugin",
24
+ "widgets",
25
+ "svg",
26
+ "html",
27
+ "glimpseui"
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+ssh://git@github.com/tspython/opencode-generative-ui.git"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/tspython/opencode-generative-ui/issues"
35
+ },
36
+ "homepage": "https://github.com/tspython/opencode-generative-ui#readme",
37
+ "license": "MIT",
38
+ "publishConfig": {
39
+ "access": "public"
40
+ },
41
+ "dependencies": {
42
+ "@opencode-ai/plugin": "1.3.13",
43
+ "glimpseui": "^0.3.5"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^22.15.21",
47
+ "typescript": "^5.8.3"
48
+ },
49
+ "trustedDependencies": [
50
+ "glimpseui"
51
+ ]
52
+ }
@@ -0,0 +1,22 @@
1
+ declare module "glimpseui" {
2
+ import { EventEmitter } from "node:events";
3
+
4
+ export interface GlimpseOptions {
5
+ width?: number;
6
+ height?: number;
7
+ title?: string;
8
+ floating?: boolean;
9
+ }
10
+
11
+ export class GlimpseWindow extends EventEmitter {
12
+ send(js: string): void;
13
+ setHTML(html: string): void;
14
+ close(): void;
15
+ on(event: "message", listener: (data: unknown) => void): this;
16
+ on(event: "closed", listener: () => void): this;
17
+ on(event: "error", listener: (err: Error) => void): this;
18
+ on(event: string, listener: (...args: unknown[]) => void): this;
19
+ }
20
+
21
+ export function open(html: string, options?: GlimpseOptions): GlimpseWindow;
22
+ }