@vibes.diy/prompts 14.3.249 → 14.3.251
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/generation-variety.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/llms/backend.js +1 -0
- package/llms/backend.js.map +1 -1
- package/llms/blockly.js +1 -0
- package/llms/blockly.js.map +1 -1
- package/llms/blockly.md +2 -3
- package/llms/bluesky.js +2 -0
- package/llms/bluesky.js.map +1 -1
- package/llms/board-games.js +9 -4
- package/llms/board-games.js.map +1 -1
- package/llms/board-games.md +3 -153
- package/llms/callai.js +1 -0
- package/llms/callai.js.map +1 -1
- package/llms/callai.md +1 -1
- package/llms/canvas-theme-colors.d.ts +2 -0
- package/llms/canvas-theme-colors.js +7 -0
- package/llms/canvas-theme-colors.js.map +1 -0
- package/llms/canvas-theme-colors.md +70 -0
- package/llms/image-gen.js +1 -0
- package/llms/image-gen.js.map +1 -1
- package/llms/image-gen.md +1 -1
- package/llms/index.d.ts +24 -2
- package/llms/index.js +64 -0
- package/llms/index.js.map +1 -1
- package/llms/keepsake.d.ts +2 -0
- package/llms/keepsake.js +9 -0
- package/llms/keepsake.js.map +1 -0
- package/llms/keepsake.md +74 -0
- package/llms/live-rooms.d.ts +2 -0
- package/llms/live-rooms.js +28 -0
- package/llms/live-rooms.js.map +1 -0
- package/llms/live-rooms.md +288 -0
- package/llms/media-capture.d.ts +2 -0
- package/llms/media-capture.js +27 -0
- package/llms/media-capture.js.map +1 -0
- package/llms/media-capture.md +190 -0
- package/llms/mic-capture.d.ts +2 -0
- package/llms/mic-capture.js +7 -0
- package/llms/mic-capture.js.map +1 -0
- package/llms/mic-capture.md +76 -0
- package/llms/needs.d.ts +12 -0
- package/llms/needs.js +71 -0
- package/llms/needs.js.map +1 -0
- package/llms/owner-secret.d.ts +2 -0
- package/llms/owner-secret.js +8 -0
- package/llms/owner-secret.js.map +1 -0
- package/llms/owner-secret.md +82 -0
- package/llms/p5.js +1 -0
- package/llms/p5.js.map +1 -1
- package/llms/p5.md +15 -69
- package/llms/photo-input.d.ts +2 -0
- package/llms/photo-input.js +7 -0
- package/llms/photo-input.js.map +1 -0
- package/llms/photo-input.md +141 -0
- package/llms/physics.js +1 -0
- package/llms/physics.js.map +1 -1
- package/llms/physics.md +7 -16
- package/llms/reskin.js +3 -8
- package/llms/reskin.js.map +1 -1
- package/llms/reskin.md +12 -78
- package/llms/richtext.md +2 -0
- package/llms/social-post.js +1 -0
- package/llms/social-post.js.map +1 -1
- package/llms/social-post.md +22 -4
- package/llms/sound-core.d.ts +2 -0
- package/llms/sound-core.js +7 -0
- package/llms/sound-core.js.map +1 -0
- package/llms/sound-core.md +131 -0
- package/llms/spotify.js +11 -1
- package/llms/spotify.js.map +1 -1
- package/llms/spotify.md +54 -50
- package/llms/strudel.js +2 -0
- package/llms/strudel.js.map +1 -1
- package/llms/strudel.md +24 -25
- package/llms/surface-board.d.ts +2 -0
- package/llms/surface-board.js +8 -0
- package/llms/surface-board.js.map +1 -0
- package/llms/surface-board.md +140 -0
- package/llms/surface-play-area.d.ts +2 -0
- package/llms/surface-play-area.js +8 -0
- package/llms/surface-play-area.js.map +1 -0
- package/llms/surface-play-area.md +51 -0
- package/llms/surface-presence.d.ts +2 -0
- package/llms/surface-presence.js +9 -0
- package/llms/surface-presence.js.map +1 -0
- package/llms/surface-presence.md +118 -0
- package/llms/third-party-embed.d.ts +2 -0
- package/llms/third-party-embed.js +8 -0
- package/llms/third-party-embed.js.map +1 -0
- package/llms/third-party-embed.md +110 -0
- package/llms/three-js.js +1 -1
- package/llms/three-js.js.map +1 -1
- package/llms/three-js.md +52 -18
- package/llms/touch-games.js +11 -11
- package/llms/touch-games.js.map +1 -1
- package/llms/touch-games.md +59 -354
- package/llms/types.d.ts +14 -0
- package/llms/ui-chat.js +2 -1
- package/llms/ui-chat.js.map +1 -1
- package/llms/ui-chat.md +25 -14
- package/llms/ui-weather.js +1 -1
- package/llms/ui-weather.js.map +1 -1
- package/llms/ui-weather.md +1 -2
- package/llms/use-vibe.js +1 -0
- package/llms/use-vibe.js.map +1 -1
- package/llms/use-viewer.js +1 -0
- package/llms/use-viewer.js.map +1 -1
- package/llms/voxel.js +1 -0
- package/llms/voxel.js.map +1 -1
- package/llms/voxel.md +33 -109
- package/llms/weather.d.ts +2 -0
- package/llms/weather.js +12 -0
- package/llms/weather.js.map +1 -0
- package/llms/weather.md +248 -0
- package/llms/web-audio.js +4 -21
- package/llms/web-audio.js.map +1 -1
- package/llms/web-audio.md +19 -951
- package/llms/web-music.d.ts +2 -0
- package/llms/web-music.js +8 -0
- package/llms/web-music.js.map +1 -0
- package/llms/web-music.md +895 -0
- package/llms/world-controls.d.ts +2 -0
- package/llms/world-controls.js +14 -0
- package/llms/world-controls.js.map +1 -0
- package/llms/world-controls.md +262 -0
- package/llms/worlds.js +2 -1
- package/llms/worlds.js.map +1 -1
- package/llms/worlds.md +5 -14
- package/llms/youtube.js +10 -1
- package/llms/youtube.js.map +1 -1
- package/llms/youtube.md +67 -53
- package/package.json +5 -5
- package/prompts.js +5 -19
- package/prompts.js.map +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const worldControlsConfig = {
|
|
2
|
+
name: "world-controls",
|
|
3
|
+
needs: ["surface-play-area"],
|
|
4
|
+
label: "World controls",
|
|
5
|
+
description: "Any 3D place the person walks through as a player, on foot or flying, first-person, on a phone and a desktop: " +
|
|
6
|
+
"a 3D garden, house, museum, cave, island, maze, city or ship to walk around in. Load it beside three-js for every " +
|
|
7
|
+
"walked-through world; a model turned or spun on its own (a product viewer) is three-js alone. The useWorldControls hook from use-vibes: left thumb walks on a floating stick, right thumb " +
|
|
8
|
+
"looks, flick up to jump, tap and hold act on what is under the finger, a 🎥 button cycles free cam, first person " +
|
|
9
|
+
"and shoulder views, and the desktop gets pointer lock, WASD and Space. " +
|
|
10
|
+
"walk-through, first-person, walk around, explore, wander, fly around, 3D world",
|
|
11
|
+
teaches: ["useWorldControls"],
|
|
12
|
+
cues: ["first-person", "first person", "walk around", "explore", "wander"],
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=world-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-controls.js","sourceRoot":"","sources":["../../jsr/llms/world-controls.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,mBAAmB,GAAc;IAC5C,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,CAAC,mBAAmB,CAAC;IAC5B,KAAK,EAAE,gBAAgB;IACvB,WAAW,EAIT,gHAAgH;QAChH,oHAAoH;QACpH,4LAA4L;QAC5L,mHAAmH;QACnH,yEAAyE;QACzE,gFAAgF;IAElF,OAAO,EAAE,CAAC,kBAAkB,CAAC;IAE7B,IAAI,EAAE,CAAC,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,CAAC;CAC3E,CAAC"}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# World controls — walk, look and fly through a 3D world on a phone and a desktop
|
|
2
|
+
|
|
3
|
+
## Walk + look: move through a 3D world
|
|
4
|
+
|
|
5
|
+
A 3D world you walk, fly or look around in gets its controls from `useWorldControls` (from `use-vibes`), on phone and desktop alike. Hand it the root element and what each act means; the hook owns the gestures, keeps the root `touch-none`, and sizes the lens when you pass it the camera.
|
|
6
|
+
|
|
7
|
+
**Bind the root.** The ref you hand the hook goes on the outermost element the world fills, the one around the canvas and the HUD (`<div ref={rootRef} className="relative h-dvh w-full overflow-hidden touch-none">`). A ref the hook gets but no element carries attaches nothing, and the world cannot be walked.
|
|
8
|
+
|
|
9
|
+
Left half walks: a floating stick appears under the thumb. Right half looks: drag to turn, and a finger held near the screen's edge keeps turning.
|
|
10
|
+
|
|
11
|
+
Tap acts on what is under the finger; press and hold is the second action; a quick upward flick on the look side jumps.
|
|
12
|
+
|
|
13
|
+
- **The jump is judged as the finger lifts**, and the flick's up/down look is held back, so the
|
|
14
|
+
camera stays level through every jump.
|
|
15
|
+
- **`mode: "player"`** walks, looks and flicks; **`mode: "free"`** orbits a camera that zooms
|
|
16
|
+
with a pinch or the mouse wheel (`onPinch(factor)`, under 1 zooms in). With `flying: true`, a
|
|
17
|
+
flick down (`onFlick("down")`) sinks.
|
|
18
|
+
- **The callbacks speak screen sense.** `onMove(x, y)` is the walk vector with forward at `y < 0`;
|
|
19
|
+
`onLook(dx, dy)` and `onTurn(yaw, pitch)` arrive in radians, applied the same way; `onTap`,
|
|
20
|
+
`onHold` and `onAim` carry client coordinates.
|
|
21
|
+
- **Call `tick(dt)` once per frame** from the animation loop; the edge turn, the hold timer and
|
|
22
|
+
the finger trail advance on that clock, and `keys` holds every key code down right now.
|
|
23
|
+
- **The lens follows the screen.** Pass the `THREE.PerspectiveCamera` as `camera` and the hook
|
|
24
|
+
keeps its aspect current and widens the view on a phone held upright.
|
|
25
|
+
- **HUD controls live inside the root.** A press on a button, input or link there is that
|
|
26
|
+
control's own and never a world tap; mark any other piece that keeps its own touches (a slider,
|
|
27
|
+
a chip row) with `data-world-controls-ignore`.
|
|
28
|
+
|
|
29
|
+
A 🎥 button outside the menu cycles the views; on a phone the world opens in a free-cam overview that frames the whole scene. The views are **Free cam → First person → Shoulder view**; a desktop visitor opens in first person.
|
|
30
|
+
The overview's distance is the app's: scale the orbit radius by
|
|
31
|
+
`0.36 / (tan(fov / 2) · aspect)`, clamped to 1–2.2×, each frame, so a phone held upright still
|
|
32
|
+
frames the whole scene.
|
|
33
|
+
|
|
34
|
+
The one-line hint follows the current view.
|
|
35
|
+
|
|
36
|
+
The ☰ menu holds everything else, in this order: the views by name, fullscreen, how to play,
|
|
37
|
+
who else is here and what they did lately (players and activity), then invite a friend and all
|
|
38
|
+
worlds. Every world's menu carries the first three: the views, a Fullscreen entry that fills the
|
|
39
|
+
phone with the world (`requestFullscreen()` on the root, from the tap itself), and a How to play
|
|
40
|
+
entry that keeps the gestures one tap away after the hint has moved on.
|
|
41
|
+
|
|
42
|
+
**The desktop twin is the same world.** In the player views a click-to-play overlay calls
|
|
43
|
+
`requestLock()`, so the mouse looks under pointer lock; WASD or the arrows walk and Space jumps.
|
|
44
|
+
The V key cycles the views just as the 🎥 button does, once per press, and the overlay's control legend names it (`V views`).
|
|
45
|
+
`locked` reports the lock, so the overlay comes back when the player presses Esc, and `isTouch`
|
|
46
|
+
keeps the overlay off phones. While locked, a click under the crosshair is the tap and a
|
|
47
|
+
right-click is the hold (`onTap` / `onHold` at the screen centre). Free cam needs no lock: drag
|
|
48
|
+
orbits, a click is `onTap`, a right-click is `onHold`, and the wheel zooms.
|
|
49
|
+
|
|
50
|
+
### `App.jsx`
|
|
51
|
+
```jsx
|
|
52
|
+
import React from "react";
|
|
53
|
+
import * as THREE from "three";
|
|
54
|
+
import { useWorldControls } from "use-vibes";
|
|
55
|
+
import { Button, Card, Heading, IconButton, Stack, Text } from "@vibes.diy/ui";
|
|
56
|
+
import { readLook, watchLook } from "./lib/look.js";
|
|
57
|
+
|
|
58
|
+
const VIEWS = ["Free cam", "First person", "Shoulder view"];
|
|
59
|
+
const HINT = {
|
|
60
|
+
"Free cam": "drag to look around · pinch to zoom · 🎥 to step in",
|
|
61
|
+
"First person": "left thumb walks · right thumb looks · flick up to jump",
|
|
62
|
+
"Shoulder view": "tap a hedge to bloom it · hold to trim it back",
|
|
63
|
+
};
|
|
64
|
+
const stop = (e) => e.stopPropagation();
|
|
65
|
+
|
|
66
|
+
export default function App() {
|
|
67
|
+
const rootRef = React.useRef(null);
|
|
68
|
+
const canvasRef = React.useRef(null);
|
|
69
|
+
const [camera] = React.useState(() => new THREE.PerspectiveCamera(70, 1, 0.1, 500));
|
|
70
|
+
const [view, setView] = React.useState(() => (matchMedia("(pointer: coarse)").matches ? "Free cam" : "First person"));
|
|
71
|
+
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
72
|
+
const [howTo, setHowTo] = React.useState(false);
|
|
73
|
+
const [full, setFull] = React.useState(false);
|
|
74
|
+
const me = React.useRef({ pos: new THREE.Vector3(0, 0, 12), yaw: 0, pitch: 0, move: [0, 0], vy: 0, zoom: 34 });
|
|
75
|
+
const world = React.useRef({ hedges: [], colors: null });
|
|
76
|
+
|
|
77
|
+
const turn = (yaw, pitch) => {
|
|
78
|
+
me.current.yaw += yaw;
|
|
79
|
+
me.current.pitch = Math.max(-1.5, Math.min(1.5, me.current.pitch + pitch));
|
|
80
|
+
};
|
|
81
|
+
const look = (dx, dy) => turn(-dx, -dy); // radians, screen sense: a drag right turns right
|
|
82
|
+
const hedgeAt = (x, y) => {
|
|
83
|
+
const r = rootRef.current.getBoundingClientRect(); // taps arrive in client coordinates
|
|
84
|
+
const ray = new THREE.Raycaster();
|
|
85
|
+
ray.setFromCamera(new THREE.Vector2(((x - r.left) / r.width) * 2 - 1, 1 - ((y - r.top) / r.height) * 2), camera);
|
|
86
|
+
return ray.intersectObjects(world.current.hedges)[0]?.object;
|
|
87
|
+
};
|
|
88
|
+
const bloom = (hedge, on) => {
|
|
89
|
+
if (!hedge) return;
|
|
90
|
+
hedge.userData.bloom = on;
|
|
91
|
+
hedge.material.color.set(on ? world.current.colors.accent : world.current.colors.lead);
|
|
92
|
+
};
|
|
93
|
+
const { isTouch, locked, requestLock, tick } = useWorldControls(rootRef, {
|
|
94
|
+
mode: view === "Free cam" ? "free" : "player",
|
|
95
|
+
camera,
|
|
96
|
+
onMove: (x, y) => (me.current.move = [x, y]),
|
|
97
|
+
onLook: look,
|
|
98
|
+
onTurn: look,
|
|
99
|
+
onPinch: (factor) => (me.current.zoom = Math.max(8, Math.min(60, me.current.zoom * factor))),
|
|
100
|
+
onTap: (x, y) => bloom(hedgeAt(x, y), true),
|
|
101
|
+
onHold: (x, y) => bloom(hedgeAt(x, y), false),
|
|
102
|
+
onFlick: (dir) => dir === "up" && me.current.pos.y === 0 && (me.current.vy = 7),
|
|
103
|
+
});
|
|
104
|
+
const live = React.useRef({});
|
|
105
|
+
live.current = { tick, view };
|
|
106
|
+
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
const root = rootRef.current;
|
|
109
|
+
const renderer = new THREE.WebGLRenderer({ canvas: canvasRef.current, antialias: true });
|
|
110
|
+
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
|
|
111
|
+
const size = new ResizeObserver(() => renderer.setSize(root.clientWidth, root.clientHeight, false));
|
|
112
|
+
size.observe(root);
|
|
113
|
+
const scene = new THREE.Scene();
|
|
114
|
+
scene.fog = new THREE.Fog(0x000000, 30, 90);
|
|
115
|
+
const light = new THREE.HemisphereLight(0xffffff, 0xffffff, 1.4);
|
|
116
|
+
scene.add(light);
|
|
117
|
+
const groundGeo = new THREE.PlaneGeometry(60, 60);
|
|
118
|
+
const ground = new THREE.Mesh(groundGeo, new THREE.MeshLambertMaterial());
|
|
119
|
+
ground.rotation.x = -Math.PI / 2;
|
|
120
|
+
scene.add(ground);
|
|
121
|
+
const hedgeGeo = new THREE.BoxGeometry(5, 2, 1);
|
|
122
|
+
for (let i = 0; i < 10; i++) {
|
|
123
|
+
const hedge = new THREE.Mesh(hedgeGeo, new THREE.MeshLambertMaterial());
|
|
124
|
+
hedge.position.set(Math.cos(i * 0.63) * 18, 1, Math.sin(i * 0.63) * 18);
|
|
125
|
+
hedge.lookAt(0, 1, 0);
|
|
126
|
+
scene.add(hedge);
|
|
127
|
+
world.current.hedges.push(hedge);
|
|
128
|
+
}
|
|
129
|
+
// The garden wears the app's look: sky, light, ground and hedges all come from its tokens, and
|
|
130
|
+
// a restyle repaints them in place while the player keeps walking.
|
|
131
|
+
const paint = (colors) => {
|
|
132
|
+
world.current.colors = colors;
|
|
133
|
+
const sky = new THREE.Color(colors.backdrop).lerp(new THREE.Color(colors.lead), 0.2);
|
|
134
|
+
scene.background = sky;
|
|
135
|
+
scene.fog.color.copy(sky);
|
|
136
|
+
light.color.set(colors.surface);
|
|
137
|
+
light.groundColor.set(colors.lead);
|
|
138
|
+
ground.material.color.set(colors.surface);
|
|
139
|
+
for (const hedge of world.current.hedges) hedge.material.color.set(hedge.userData.bloom ? colors.accent : colors.lead);
|
|
140
|
+
};
|
|
141
|
+
paint(readLook(root));
|
|
142
|
+
const unwatch = watchLook(root, paint);
|
|
143
|
+
|
|
144
|
+
let raf = 0;
|
|
145
|
+
let last = performance.now();
|
|
146
|
+
const frame = (now) => {
|
|
147
|
+
const dt = Math.min((now - last) / 1000, 1 / 30);
|
|
148
|
+
last = now;
|
|
149
|
+
live.current.tick(dt);
|
|
150
|
+
const m = me.current;
|
|
151
|
+
const fwd = new THREE.Vector3(-Math.sin(m.yaw), 0, -Math.cos(m.yaw));
|
|
152
|
+
const side = new THREE.Vector3(-fwd.z, 0, fwd.x);
|
|
153
|
+
m.pos.addScaledVector(fwd, -m.move[1] * 5 * dt).addScaledVector(side, m.move[0] * 5 * dt); // forward is y < 0
|
|
154
|
+
m.vy -= 20 * dt;
|
|
155
|
+
m.pos.y = Math.max(0, m.pos.y + m.vy * dt);
|
|
156
|
+
if (m.pos.y === 0) m.vy = 0;
|
|
157
|
+
if (live.current.view === "Free cam") {
|
|
158
|
+
// Back the overview off on a narrow screen so the whole garden stays in frame.
|
|
159
|
+
const fit = Math.min(2.2, Math.max(1, 0.36 / (Math.tan((camera.fov * Math.PI) / 360) * camera.aspect)));
|
|
160
|
+
const d = m.zoom * fit;
|
|
161
|
+
camera.position.set(m.pos.x + Math.sin(m.yaw) * d, d * 0.7, m.pos.z + Math.cos(m.yaw) * d);
|
|
162
|
+
camera.lookAt(m.pos);
|
|
163
|
+
} else {
|
|
164
|
+
camera.position.copy(m.pos).y += 1.6;
|
|
165
|
+
if (live.current.view === "Shoulder view") camera.position.addScaledVector(fwd, -4).y += 1;
|
|
166
|
+
camera.rotation.set(m.pitch, m.yaw, 0, "YXZ");
|
|
167
|
+
}
|
|
168
|
+
renderer.render(scene, camera);
|
|
169
|
+
raf = requestAnimationFrame(frame);
|
|
170
|
+
};
|
|
171
|
+
raf = requestAnimationFrame(frame);
|
|
172
|
+
|
|
173
|
+
return () => {
|
|
174
|
+
cancelAnimationFrame(raf);
|
|
175
|
+
unwatch();
|
|
176
|
+
size.disconnect();
|
|
177
|
+
world.current.hedges.forEach((hedge) => hedge.material.dispose());
|
|
178
|
+
world.current.hedges = [];
|
|
179
|
+
hedgeGeo.dispose();
|
|
180
|
+
groundGeo.dispose();
|
|
181
|
+
ground.material.dispose();
|
|
182
|
+
renderer.dispose();
|
|
183
|
+
};
|
|
184
|
+
}, [camera]);
|
|
185
|
+
|
|
186
|
+
const cycle = () => setView((v) => VIEWS[(VIEWS.indexOf(v) + 1) % VIEWS.length]);
|
|
187
|
+
React.useEffect(() => {
|
|
188
|
+
// V cycles the views on a keyboard, once per press; a text field keeps its own V.
|
|
189
|
+
const onKey = (e) => {
|
|
190
|
+
if (e.code !== "KeyV" || e.repeat || e.target.closest?.("input, textarea, [contenteditable]")) return;
|
|
191
|
+
cycle();
|
|
192
|
+
};
|
|
193
|
+
const onFull = () => setFull(document.fullscreenElement !== null);
|
|
194
|
+
addEventListener("keydown", onKey);
|
|
195
|
+
document.addEventListener("fullscreenchange", onFull);
|
|
196
|
+
return () => {
|
|
197
|
+
removeEventListener("keydown", onKey);
|
|
198
|
+
document.removeEventListener("fullscreenchange", onFull);
|
|
199
|
+
};
|
|
200
|
+
}, []);
|
|
201
|
+
const toggleFullscreen = () => {
|
|
202
|
+
if (document.fullscreenElement) document.exitFullscreen();
|
|
203
|
+
else if (document.fullscreenEnabled) rootRef.current.requestFullscreen().catch(() => {});
|
|
204
|
+
};
|
|
205
|
+
return (
|
|
206
|
+
<div ref={rootRef} className="relative h-dvh w-full overflow-hidden bg-background text-foreground select-none touch-none">
|
|
207
|
+
<canvas ref={canvasRef} className="absolute inset-0 block w-full h-full select-none touch-none" />
|
|
208
|
+
<div className="absolute top-3 left-3 pointer-events-none">
|
|
209
|
+
<Text size="sm">{HINT[view]}</Text>
|
|
210
|
+
</div>
|
|
211
|
+
<div className="absolute top-3 right-3 flex gap-2" onPointerDown={stop}>
|
|
212
|
+
<IconButton icon="🎥" label={`View: ${view}`} onClick={cycle} />
|
|
213
|
+
<IconButton icon="☰" label={menuOpen ? "Hide menu" : "Show menu"} onClick={() => setMenuOpen(!menuOpen)} />
|
|
214
|
+
</div>
|
|
215
|
+
{menuOpen && (
|
|
216
|
+
<div className="absolute top-16 right-3 w-72" onPointerDown={stop}>
|
|
217
|
+
<Card>
|
|
218
|
+
<Stack gap={2}>
|
|
219
|
+
<Heading level={2}>Hedge Garden</Heading>
|
|
220
|
+
{VIEWS.map((v) => (
|
|
221
|
+
<Button key={v} variant={v === view ? "solid" : "quiet"} onClick={() => setView(v)}>
|
|
222
|
+
{v}
|
|
223
|
+
</Button>
|
|
224
|
+
))}
|
|
225
|
+
<Button variant="quiet" onClick={toggleFullscreen}>
|
|
226
|
+
{full ? "Exit fullscreen" : "Fullscreen"}
|
|
227
|
+
</Button>
|
|
228
|
+
<Button variant="quiet" onClick={() => setHowTo(!howTo)}>
|
|
229
|
+
How to play
|
|
230
|
+
</Button>
|
|
231
|
+
{howTo && (
|
|
232
|
+
<Text size="sm" muted>
|
|
233
|
+
Left thumb walks, right thumb looks. Tap a hedge to bloom it, hold to trim it, flick up to jump. On a
|
|
234
|
+
keyboard, V changes the view.
|
|
235
|
+
</Text>
|
|
236
|
+
)}
|
|
237
|
+
</Stack>
|
|
238
|
+
</Card>
|
|
239
|
+
</div>
|
|
240
|
+
)}
|
|
241
|
+
{!isTouch && !locked && view !== "Free cam" && (
|
|
242
|
+
<div className="absolute inset-0 z-20 flex items-center justify-center bg-background/80" onPointerDown={stop}>
|
|
243
|
+
<Card>
|
|
244
|
+
<Stack gap={3}>
|
|
245
|
+
<Heading level={2}>Hedge Garden</Heading>
|
|
246
|
+
<Button size="lg" onClick={requestLock}>
|
|
247
|
+
Click to play
|
|
248
|
+
</Button>
|
|
249
|
+
<Text size="sm" muted>
|
|
250
|
+
WASD walk · mouse look · Space jump · click bloom · V views · Esc frees the mouse
|
|
251
|
+
</Text>
|
|
252
|
+
</Stack>
|
|
253
|
+
</Card>
|
|
254
|
+
</div>
|
|
255
|
+
)}
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Grow it by changing what the acts mean: `voxel` makes the tap build and the hold break, a ruin
|
|
262
|
+
makes the tap open a door. The gesture numbers live in the hook; pass `tune` to adjust them.
|
package/llms/worlds.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const worldsConfig = {
|
|
2
2
|
name: "worlds",
|
|
3
|
+
needs: ["canvas-theme-colors"],
|
|
3
4
|
label: "Generative worlds",
|
|
4
5
|
description: "Living simulations on a canvas: ecosystems and terrariums (grass, grazers, hunters), ant farms, " +
|
|
5
6
|
"Conway's Game of Life and other cellular automata, falling sand, forest fires, boids and flocks, " +
|
|
@@ -9,7 +10,7 @@ export const worldsConfig = {
|
|
|
9
10
|
"through ImageData in the app's theme colours, dials for the rates, a census on a slow clock, and " +
|
|
10
11
|
"kept moments as recipes (seed, dials, tick, recorded taps) that replay into a living gallery. " +
|
|
11
12
|
"ecosystem, terrarium, ant farm, game of life, cellular automaton, falling sand, forest fire, " +
|
|
12
|
-
"boids, flocking, simulation, petri dish, predator prey, evolution, artificial life, screensaver world. Anything played or steered also loads touch-games for phone controls",
|
|
13
|
+
"boids, flocking, simulation, petri dish, predator prey, evolution, artificial life, screensaver world. Anything played or steered also loads touch-games for phone controls; a 3D world the person walks through as a player is three-js with world-controls",
|
|
13
14
|
cues: [
|
|
14
15
|
"ecosystem",
|
|
15
16
|
"terrarium",
|
package/llms/worlds.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worlds.js","sourceRoot":"","sources":["../../jsr/llms/worlds.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;
|
|
1
|
+
{"version":3,"file":"worlds.js","sourceRoot":"","sources":["../../jsr/llms/worlds.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;IAEd,KAAK,EAAE,CAAC,qBAAqB,CAAC;IAC9B,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EACT,kGAAkG;QAClG,mGAAmG;QACnG,mGAAmG;QACnG,oGAAoG;QACpG,oGAAoG;QACpG,mGAAmG;QACnG,gGAAgG;QAChG,+FAA+F;QAC/F,8PAA8P;IAChQ,IAAI,EAAE;QACJ,WAAW;QACX,WAAW;QACX,UAAU;QACV,YAAY;QACZ,cAAc;QACd,QAAQ;QACR,oBAAoB;QACpB,mBAAmB;QACnB,WAAW;QACX,cAAc;QACd,iBAAiB;QACjB,aAAa;QACb,OAAO;QACP,UAAU;QACV,UAAU;QACV,YAAY;QACZ,UAAU;QACV,MAAM;QACN,iBAAiB;QACjB,QAAQ;QACR,YAAY;QACZ,UAAU;QACV,QAAQ;QACR,eAAe;QACf,cAAc;QACd,WAAW;QACX,SAAS;QACT,SAAS;QACT,oBAAoB;KACrB;CACF,CAAC"}
|
package/llms/worlds.md
CHANGED
|
@@ -54,17 +54,6 @@ export function seededRandom(seed) {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
/** Resolve an injected theme token to a concrete colour once per mount (the p5 doc's probe). */
|
|
58
|
-
export function cssColor(host, token, fallback) {
|
|
59
|
-
const probe = document.createElement("span");
|
|
60
|
-
probe.style.display = "none";
|
|
61
|
-
probe.style.color = `var(${token}, ${fallback})`;
|
|
62
|
-
host.appendChild(probe);
|
|
63
|
-
const value = getComputedStyle(probe).color;
|
|
64
|
-
probe.remove();
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
57
|
/**
|
|
69
58
|
* Any CSS colour → [r, g, b] for ImageData. A canvas fill does the conversion, so a token that
|
|
70
59
|
* computes to `oklch(…)`, `color-mix(…)` or `rgb(50% …)` (measured: a computed style reports an
|
|
@@ -343,7 +332,8 @@ import { useFireproof } from "use-fireproof";
|
|
|
343
332
|
import { useVibe, useViewer } from "use-vibes";
|
|
344
333
|
import { Badge, Button, Card, Field, Heading, Input, Row, Skeleton, Spacer, Stack, Text } from "@vibes.diy/ui";
|
|
345
334
|
import { Slider } from "@vibes.diy/ui/interactive";
|
|
346
|
-
import { createWorld,
|
|
335
|
+
import { createWorld, rgb } from "./lib/world.js";
|
|
336
|
+
import { cssColor } from "./lib/look.js";
|
|
347
337
|
import { DEFAULT_PARAMS, census, meadowRules } from "./lib/rules.js";
|
|
348
338
|
|
|
349
339
|
const COLS = 160;
|
|
@@ -586,7 +576,7 @@ visible canvas with `imageSmoothingEnabled = false`.** That is one
|
|
|
586
576
|
measured, 60 paints of a 160 × 100 grid cost 42 ms in total, and a 240 × 160
|
|
587
577
|
meadow steps in about 2.6 ms. A `fillRect` per cell is tens of thousands of
|
|
588
578
|
calls a frame and is where a world turns into a slideshow. The palette is
|
|
589
|
-
built once per mount from the theme tokens (`cssColor` then `rgb`), so cell
|
|
579
|
+
built once per mount from the theme tokens (`cssColor` from `lib/look.js`, then `rgb`), so cell
|
|
590
580
|
colours follow the app's theme. For a world drawn as sprites rather than
|
|
591
581
|
cells (boids, ants with heading), paint the agents on top after the grid.
|
|
592
582
|
|
|
@@ -686,7 +676,8 @@ import React, { useEffect, useRef, useState } from "react";
|
|
|
686
676
|
import { useFireproof } from "use-fireproof";
|
|
687
677
|
import { useVibe } from "use-vibes";
|
|
688
678
|
import { Button, Card, Heading, Row, Segmented, Spacer, Stack, Text } from "@vibes.diy/ui";
|
|
689
|
-
import { createWorld,
|
|
679
|
+
import { createWorld, rgb } from "./lib/world.js";
|
|
680
|
+
import { cssColor } from "./lib/look.js";
|
|
690
681
|
import { SAND, WALL, WATER, sandRules } from "./lib/sand.js";
|
|
691
682
|
|
|
692
683
|
const COLS = 128;
|
package/llms/youtube.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const youtubeConfig = {
|
|
2
2
|
name: "youtube",
|
|
3
3
|
label: "YouTube channel stats",
|
|
4
|
-
description: "YouTube channel dashboards on the owner's own YouTube Data API v3 key: the setup steps the app shows when the key is missing, keeping the key in backend.js, resolving a channel from a handle or URL, reading videos through the uploads playlist instead of the 100-unit search endpoint, daily snapshots to chart change over time, and labeling the numbers an API key cannot see",
|
|
4
|
+
description: "YouTube on a page: playing videos, playlists and a channel's uploads in YouTube's own player, which needs no key and no setup; and channel stats dashboards on the owner's own YouTube Data API v3 key: the setup steps the app shows when the key is missing, keeping the key in backend.js, resolving a channel from a handle or URL, reading videos through the uploads playlist instead of the 100-unit search endpoint, daily snapshots to chart change over time, and labeling the numbers an API key cannot see",
|
|
5
5
|
cues: [
|
|
6
6
|
"youtube",
|
|
7
7
|
"my channel",
|
|
@@ -10,6 +10,15 @@ export const youtubeConfig = {
|
|
|
10
10
|
"video views",
|
|
11
11
|
"youtube stats",
|
|
12
12
|
"channel analytics",
|
|
13
|
+
"youtube video",
|
|
14
|
+
"youtube playlist",
|
|
15
|
+
],
|
|
16
|
+
needs: ["owner-secret", "third-party-embed"],
|
|
17
|
+
credential: "owner-secret",
|
|
18
|
+
egress: [
|
|
19
|
+
{ url: "https://www.googleapis.com/youtube/v3/channels?part=statistics", via: "platform" },
|
|
20
|
+
{ url: "https://www.youtube-nocookie.com/embed/dQw4w9WgXcQ", via: "frame" },
|
|
21
|
+
{ url: "https://www.youtube.com/oembed?url=https://www.youtube.com/watch?v=dQw4w9WgXcQ", via: "cors", checked: "2026-11-02" },
|
|
13
22
|
],
|
|
14
23
|
};
|
|
15
24
|
//# sourceMappingURL=youtube.js.map
|
package/llms/youtube.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../jsr/llms/youtube.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,
|
|
1
|
+
{"version":3,"file":"youtube.js","sourceRoot":"","sources":["../../jsr/llms/youtube.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,uBAAuB;IAC9B,WAAW,EACT,wfAAwf;IAC1f,IAAI,EAAE;QACJ,SAAS;QACT,YAAY;QACZ,kBAAkB;QAClB,aAAa;QACb,aAAa;QACb,eAAe;QACf,mBAAmB;QACnB,eAAe;QACf,kBAAkB;KACnB;IAED,KAAK,EAAE,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAC5C,UAAU,EAAE,cAAc;IAC1B,MAAM,EAAE;QACN,EAAE,GAAG,EAAE,gEAAgE,EAAE,GAAG,EAAE,UAAU,EAAE;QAC1F,EAAE,GAAG,EAAE,oDAAoD,EAAE,GAAG,EAAE,OAAO,EAAE;QAC3E,EAAE,GAAG,EAAE,gFAAgF,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;KAC9H;CACF,CAAC"}
|
package/llms/youtube.md
CHANGED
|
@@ -1,22 +1,60 @@
|
|
|
1
|
-
# YouTube
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
key
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
# YouTube — play videos with no key, chart a channel with the owner's own
|
|
2
|
+
|
|
3
|
+
Two different asks share the name. **Playing** a video, a playlist or a
|
|
4
|
+
channel's uploads inside the page needs no key, no backend and no setup: it is
|
|
5
|
+
YouTube's own player in a frame, and section 0 is all of it. **Counting** a
|
|
6
|
+
channel (subscribers, views, which videos are picking up) is the **YouTube Data
|
|
7
|
+
API v3** on a key the owner supplies, a `backend.js` feature, and sections 1–7
|
|
8
|
+
are the recipe that keeps the key safe, the quota survivable and the numbers
|
|
9
|
+
honest. Build the first for "show our videos", "my band's page", "a playlist of
|
|
10
|
+
clips"; build the second only when the ask is about the numbers.
|
|
11
|
+
|
|
12
|
+
## 0. Play a video: no key at all
|
|
13
|
+
|
|
14
|
+
A pasted YouTube link becomes a player through the privacy-enhanced host,
|
|
15
|
+
`www.youtube-nocookie.com`, which sets no cookie until the person presses play.
|
|
16
|
+
Parse the link into an id and build the `src`; the frame itself is the shared
|
|
17
|
+
`EmbedFrame`.
|
|
18
|
+
|
|
19
|
+
```jsx
|
|
20
|
+
// A share link → an embed src, or null when the link is not one YouTube can play here.
|
|
21
|
+
function youtubeEmbedSrc(link) {
|
|
22
|
+
let u;
|
|
23
|
+
try { u = new URL(link.trim()); } catch { return null; }
|
|
24
|
+
const host = u.hostname.replace(/^www\.|^m\./, "");
|
|
25
|
+
const list = u.searchParams.get("list");
|
|
26
|
+
const start = (u.searchParams.get("t") ?? u.searchParams.get("start") ?? "").match(/^(\d+)s?$/)?.[1];
|
|
27
|
+
const tail = start ? `?start=${start}` : "";
|
|
28
|
+
let id = null;
|
|
29
|
+
if (host === "youtu.be") id = u.pathname.slice(1);
|
|
30
|
+
else if (host === "youtube.com" || host === "music.youtube.com") {
|
|
31
|
+
const channel = u.pathname.match(/^\/channel\/UC([\w-]{22})(?:\/|$)/);
|
|
32
|
+
if (channel) return `https://www.youtube-nocookie.com/embed/videoseries?list=UU${channel[1]}`; // the channel's uploads
|
|
33
|
+
if (u.pathname === "/playlist" && /^[\w-]+$/.test(list ?? "")) return `https://www.youtube-nocookie.com/embed/videoseries?list=${list}`;
|
|
34
|
+
id = u.searchParams.get("v") ?? u.pathname.match(/^\/(?:shorts|embed|live)\/([\w-]{11})/)?.[1] ?? null;
|
|
35
|
+
}
|
|
36
|
+
if (!id || !/^[\w-]{11}$/.test(id)) return null;
|
|
37
|
+
return `https://www.youtube-nocookie.com/embed/${id}${tail}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// The player, once the link has parsed:
|
|
41
|
+
// <EmbedFrame src={youtubeEmbedSrc(video.link)} title={video.title} />
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- A **channel's uploads** play as one playlist: its id is the channel id with
|
|
45
|
+
`UC` turned into `UU`. Only a `/channel/UC…` link carries that id; an
|
|
46
|
+
`@handle` link does not, and turning a handle into an id costs a key, so ask
|
|
47
|
+
for a video or playlist link, or the channel's `/channel/` address.
|
|
48
|
+
- The title and thumbnail come from YouTube's keyless oEmbed endpoint,
|
|
49
|
+
`https://www.youtube.com/oembed`, read once when the link is added.
|
|
50
|
+
- Under each player, "Watch on YouTube" links the original
|
|
51
|
+
`https://www.youtube.com/watch?v=<id>` (the shared link-out rule).
|
|
52
|
+
- None of this touches the Data API, so none of the key sections below apply
|
|
53
|
+
to a page that only plays videos.
|
|
54
|
+
|
|
55
|
+
**The stats half is the owner's dashboard:** the key and quota are the owner's,
|
|
56
|
+
and every visitor sees the *owner's* channel. A visitor's own channel is a
|
|
57
|
+
connection, never a pasted token (the owner-key rules below).
|
|
20
58
|
|
|
21
59
|
## 1. The setup item: the owner's YouTube Data API key
|
|
22
60
|
|
|
@@ -36,49 +74,26 @@ one is a link to the exact page and uses the words that page uses:
|
|
|
36
74
|
Press **Create credentials**, choose **API key**, and copy the key. Then
|
|
37
75
|
open the key, and under **API restrictions** choose **Restrict key**, tick
|
|
38
76
|
**YouTube Data API v3**, and save.
|
|
39
|
-
3.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
4. Come back to the app. The dashboard works the moment the key is saved; no
|
|
45
|
-
redeploy.
|
|
46
|
-
|
|
47
|
-
Those steps are the item's copy on the Setup surface, with the vibe's real
|
|
48
|
-
handle and slug filled in from the `ownerHandle` and `appSlug` the `/setup`
|
|
49
|
-
route hands over. In the consumer flow, a dashboard whose key is not set
|
|
50
|
-
reads *Channel stats are not open yet*; the owner's Setup entry is where the
|
|
51
|
-
steps are, and later it is where a rotated key goes.
|
|
52
|
-
|
|
53
|
-
Only the owner can set or rotate a secret, and handlers see the current value on
|
|
54
|
-
every invocation — so the dashboard starts working the moment the key lands, with
|
|
55
|
-
no redeploy.
|
|
77
|
+
3. Save it under **Secrets** on this vibe's Settings tab as `YOUTUBE_API_KEY`,
|
|
78
|
+
then come back: the owner-key steps every item ends with.
|
|
79
|
+
|
|
80
|
+
In the consumer flow, a dashboard whose key is not set reads *Channel stats are
|
|
81
|
+
not open yet*.
|
|
56
82
|
|
|
57
83
|
## 2. The key never reaches the browser
|
|
58
84
|
|
|
59
85
|
Every YouTube request is made in backend.js with ctx.fetch and ctx.secrets.YOUTUBE_API_KEY; App.jsx never calls googleapis.com.
|
|
60
86
|
|
|
61
|
-
|
|
62
|
-
backend is the only place that knows the key exists. A key pasted into a React
|
|
63
|
-
component ships to every visitor who views source, and a restricted key is still
|
|
64
|
-
the owner's quota to spend.
|
|
87
|
+
A restricted key is still the owner's quota to spend.
|
|
65
88
|
|
|
66
89
|
### The `/_api` routes are the second door
|
|
67
90
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
stranger the owner's 10,000 daily units and a refresh button.
|
|
91
|
+
A handler that calls Google on every request hands a stranger the owner's
|
|
92
|
+
10,000 daily units and a refresh button.
|
|
71
93
|
|
|
72
94
|
Live YouTube calls are made only for the vibe owner; every other visitor is served from the stored snapshot, so a stranger can never spend the owner's quota.
|
|
73
95
|
|
|
74
|
-
|
|
75
|
-
app's owner and `ctx.userInfo` is `{ userHandle }` or `null` when the caller is
|
|
76
|
-
anonymous. One comparison at the top of the handler is the whole gate:
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
const isOwner = ctx.userInfo?.userHandle != null && ctx.userInfo.userHandle === ctx.appInfo.ownerHandle;
|
|
80
|
-
```
|
|
81
|
-
|
|
96
|
+
The owner gate is one comparison at the top of the handler (`isOwnerCall`).
|
|
82
97
|
Everyone else is answered from the daily snapshot docs section 5 already writes —
|
|
83
98
|
`{ ok: true, source: "snapshot", asOf: <day>, ... }`, so the client can say "as of
|
|
84
99
|
Tuesday" instead of implying the numbers are live — and
|
|
@@ -257,8 +272,7 @@ the reason through:
|
|
|
257
272
|
- `accessNotConfigured` — "Enable YouTube Data API v3 on this key's project."
|
|
258
273
|
- anything else — show the API's own `error.message`.
|
|
259
274
|
|
|
260
|
-
|
|
261
|
-
nothing they can act on, and the four cases above each have a different fix.
|
|
275
|
+
The four cases above each have a different fix, so each keeps its own words.
|
|
262
276
|
|
|
263
277
|
## Complete backend.js
|
|
264
278
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.251",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@adviser/cement": "~0.5.34",
|
|
42
|
-
"@vibes.diy/api-types": "14.3.
|
|
43
|
-
"@vibes.diy/call-ai-v2": "14.3.
|
|
44
|
-
"@vibes.diy/identity": "14.3.
|
|
45
|
-
"@vibes.diy/use-vibes-types": "14.3.
|
|
42
|
+
"@vibes.diy/api-types": "14.3.251",
|
|
43
|
+
"@vibes.diy/call-ai-v2": "14.3.251",
|
|
44
|
+
"@vibes.diy/identity": "14.3.251",
|
|
45
|
+
"@vibes.diy/use-vibes-types": "14.3.251",
|
|
46
46
|
"arktype": "~2.2.8",
|
|
47
47
|
"json-schema-faker": "~0.6.3"
|
|
48
48
|
},
|
package/prompts.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { loadAsset, KeyedResolvOnce } from "@adviser/cement";
|
|
2
2
|
import { getLlmCatalog, getLlmCatalogNames } from "./json-docs.js";
|
|
3
|
-
import { canonicalSkillName } from "./llms/index.js";
|
|
3
|
+
import { allConfigs, canonicalSkillName, expandSkills, universalSkillNames } from "./llms/index.js";
|
|
4
4
|
import { getColorsetCatalogNames, getThemeCatalogNames, renderLookTokenDisciplineBlock } from "./themes/index.js";
|
|
5
5
|
import { hasLookBrief, hasOwnTokenRules, LOOK_BRIEF_ASSET_PATH, lookVarietyDialect } from "./themes/looks/index.js";
|
|
6
6
|
import { renderLookPackageSection, renderReskinDoseSection, renderInstrumentArrangementSection, askIsBeatApp, askNamesInstrumentLayout, renderTextureNoteSection, renderVarietySection, } from "./generation-variety.js";
|
|
@@ -12,9 +12,7 @@ export function coreSkillNames(variant) {
|
|
|
12
12
|
if (variant === "initial-instant")
|
|
13
13
|
return [];
|
|
14
14
|
const isFirstTurn = variant === "initial" || variant === "initial-oneshot";
|
|
15
|
-
return isFirstTurn
|
|
16
|
-
? ["use-vibe", "use-viewer", "image-gen", "callai"]
|
|
17
|
-
: ["use-vibe", "use-viewer", "image-gen", "callai", "backend"];
|
|
15
|
+
return universalSkillNames(allConfigs, isFirstTurn ? "first" : "edit");
|
|
18
16
|
}
|
|
19
17
|
export const STARTER_IMPORTS_POINTER = "// The import lines for this app are in the <starter-imports> block after the skill docs below — use them verbatim here.";
|
|
20
18
|
export function generateImportStatements(llms) {
|
|
@@ -75,24 +73,12 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
75
73
|
const instantExtras = isInstant ? selectedNames.filter((name) => INSTANT_REPLACED_SKILLS.has(name) === false) : [];
|
|
76
74
|
if (isInstant)
|
|
77
75
|
selectedNames = [...(instantWantsImages ? ["image-gen"] : []), ...instantExtras];
|
|
78
|
-
for (const required of ["use-vibe", "use-viewer"]) {
|
|
79
|
-
if (isInstant === false && llmsCatalogNames.has(required) && !selectedNames.includes(required)) {
|
|
80
|
-
selectedNames.push(required);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
for (const capability of ["image-gen", "callai"]) {
|
|
84
|
-
if (isInstant === false && llmsCatalogNames.has(capability) && !selectedNames.includes(capability)) {
|
|
85
|
-
selectedNames.push(capability);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
const isFirstTurn = sessionDoc?.variant === "initial" || sessionDoc?.variant === "initial-oneshot" || sessionDoc?.variant === "initial-instant";
|
|
89
|
-
if (isFirstTurn === false && llmsCatalogNames.has("backend") && selectedNames.includes("backend") === false) {
|
|
90
|
-
selectedNames.push("backend");
|
|
91
|
-
}
|
|
92
76
|
for (const name of coreSkillNames(sessionDoc?.variant)) {
|
|
93
77
|
if (llmsCatalogNames.has(name) && selectedNames.includes(name) === false)
|
|
94
78
|
selectedNames.push(name);
|
|
95
79
|
}
|
|
80
|
+
const beforeNeeds = new Set(selectedNames);
|
|
81
|
+
selectedNames = expandSkills(selectedNames, llmsCatalog).filter((name) => llmsCatalogNames.has(name) && (isInstant === false || beforeNeeds.has(name) || INSTANT_REPLACED_SKILLS.has(name) === false));
|
|
96
82
|
const includeDemoData = sessionDoc?.demoData === true;
|
|
97
83
|
const chosenLlms = llmsCatalog.filter((l) => selectedNames.includes(l.name));
|
|
98
84
|
const coreNames = coreSkillNames(sessionDoc?.variant);
|
|
@@ -199,7 +185,7 @@ export async function makeBaseSystemPrompt(model, sessionDoc) {
|
|
|
199
185
|
typeof sessionDoc?.enrichedPrompt === "string" ? sessionDoc.enrichedPrompt : "",
|
|
200
186
|
userPrompt,
|
|
201
187
|
].join("\n");
|
|
202
|
-
const instrumentArrangementSection = chosenLlms.some((l) => l.name === "web-
|
|
188
|
+
const instrumentArrangementSection = chosenLlms.some((l) => l.name === "web-music") && askIsBeatApp(beatAsk) && askNamesInstrumentLayout(userPrompt) === false
|
|
203
189
|
? renderInstrumentArrangementSection(sessionDoc?.instrumentArrangement)
|
|
204
190
|
: "";
|
|
205
191
|
const themeDesignSection = [
|