@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.
Files changed (137) hide show
  1. package/generation-variety.js +1 -1
  2. package/index.d.ts +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/llms/backend.js +1 -0
  6. package/llms/backend.js.map +1 -1
  7. package/llms/blockly.js +1 -0
  8. package/llms/blockly.js.map +1 -1
  9. package/llms/blockly.md +2 -3
  10. package/llms/bluesky.js +2 -0
  11. package/llms/bluesky.js.map +1 -1
  12. package/llms/board-games.js +9 -4
  13. package/llms/board-games.js.map +1 -1
  14. package/llms/board-games.md +3 -153
  15. package/llms/callai.js +1 -0
  16. package/llms/callai.js.map +1 -1
  17. package/llms/callai.md +1 -1
  18. package/llms/canvas-theme-colors.d.ts +2 -0
  19. package/llms/canvas-theme-colors.js +7 -0
  20. package/llms/canvas-theme-colors.js.map +1 -0
  21. package/llms/canvas-theme-colors.md +70 -0
  22. package/llms/image-gen.js +1 -0
  23. package/llms/image-gen.js.map +1 -1
  24. package/llms/image-gen.md +1 -1
  25. package/llms/index.d.ts +24 -2
  26. package/llms/index.js +64 -0
  27. package/llms/index.js.map +1 -1
  28. package/llms/keepsake.d.ts +2 -0
  29. package/llms/keepsake.js +9 -0
  30. package/llms/keepsake.js.map +1 -0
  31. package/llms/keepsake.md +74 -0
  32. package/llms/live-rooms.d.ts +2 -0
  33. package/llms/live-rooms.js +28 -0
  34. package/llms/live-rooms.js.map +1 -0
  35. package/llms/live-rooms.md +288 -0
  36. package/llms/media-capture.d.ts +2 -0
  37. package/llms/media-capture.js +27 -0
  38. package/llms/media-capture.js.map +1 -0
  39. package/llms/media-capture.md +190 -0
  40. package/llms/mic-capture.d.ts +2 -0
  41. package/llms/mic-capture.js +7 -0
  42. package/llms/mic-capture.js.map +1 -0
  43. package/llms/mic-capture.md +76 -0
  44. package/llms/needs.d.ts +12 -0
  45. package/llms/needs.js +71 -0
  46. package/llms/needs.js.map +1 -0
  47. package/llms/owner-secret.d.ts +2 -0
  48. package/llms/owner-secret.js +8 -0
  49. package/llms/owner-secret.js.map +1 -0
  50. package/llms/owner-secret.md +82 -0
  51. package/llms/p5.js +1 -0
  52. package/llms/p5.js.map +1 -1
  53. package/llms/p5.md +15 -69
  54. package/llms/photo-input.d.ts +2 -0
  55. package/llms/photo-input.js +7 -0
  56. package/llms/photo-input.js.map +1 -0
  57. package/llms/photo-input.md +141 -0
  58. package/llms/physics.js +1 -0
  59. package/llms/physics.js.map +1 -1
  60. package/llms/physics.md +7 -16
  61. package/llms/reskin.js +3 -8
  62. package/llms/reskin.js.map +1 -1
  63. package/llms/reskin.md +12 -78
  64. package/llms/richtext.md +2 -0
  65. package/llms/social-post.js +1 -0
  66. package/llms/social-post.js.map +1 -1
  67. package/llms/social-post.md +22 -4
  68. package/llms/sound-core.d.ts +2 -0
  69. package/llms/sound-core.js +7 -0
  70. package/llms/sound-core.js.map +1 -0
  71. package/llms/sound-core.md +131 -0
  72. package/llms/spotify.js +11 -1
  73. package/llms/spotify.js.map +1 -1
  74. package/llms/spotify.md +54 -50
  75. package/llms/strudel.js +2 -0
  76. package/llms/strudel.js.map +1 -1
  77. package/llms/strudel.md +24 -25
  78. package/llms/surface-board.d.ts +2 -0
  79. package/llms/surface-board.js +8 -0
  80. package/llms/surface-board.js.map +1 -0
  81. package/llms/surface-board.md +140 -0
  82. package/llms/surface-play-area.d.ts +2 -0
  83. package/llms/surface-play-area.js +8 -0
  84. package/llms/surface-play-area.js.map +1 -0
  85. package/llms/surface-play-area.md +51 -0
  86. package/llms/surface-presence.d.ts +2 -0
  87. package/llms/surface-presence.js +9 -0
  88. package/llms/surface-presence.js.map +1 -0
  89. package/llms/surface-presence.md +118 -0
  90. package/llms/third-party-embed.d.ts +2 -0
  91. package/llms/third-party-embed.js +8 -0
  92. package/llms/third-party-embed.js.map +1 -0
  93. package/llms/third-party-embed.md +110 -0
  94. package/llms/three-js.js +1 -1
  95. package/llms/three-js.js.map +1 -1
  96. package/llms/three-js.md +52 -18
  97. package/llms/touch-games.js +11 -11
  98. package/llms/touch-games.js.map +1 -1
  99. package/llms/touch-games.md +59 -354
  100. package/llms/types.d.ts +14 -0
  101. package/llms/ui-chat.js +2 -1
  102. package/llms/ui-chat.js.map +1 -1
  103. package/llms/ui-chat.md +25 -14
  104. package/llms/ui-weather.js +1 -1
  105. package/llms/ui-weather.js.map +1 -1
  106. package/llms/ui-weather.md +1 -2
  107. package/llms/use-vibe.js +1 -0
  108. package/llms/use-vibe.js.map +1 -1
  109. package/llms/use-viewer.js +1 -0
  110. package/llms/use-viewer.js.map +1 -1
  111. package/llms/voxel.js +1 -0
  112. package/llms/voxel.js.map +1 -1
  113. package/llms/voxel.md +33 -109
  114. package/llms/weather.d.ts +2 -0
  115. package/llms/weather.js +12 -0
  116. package/llms/weather.js.map +1 -0
  117. package/llms/weather.md +248 -0
  118. package/llms/web-audio.js +4 -21
  119. package/llms/web-audio.js.map +1 -1
  120. package/llms/web-audio.md +19 -951
  121. package/llms/web-music.d.ts +2 -0
  122. package/llms/web-music.js +8 -0
  123. package/llms/web-music.js.map +1 -0
  124. package/llms/web-music.md +895 -0
  125. package/llms/world-controls.d.ts +2 -0
  126. package/llms/world-controls.js +14 -0
  127. package/llms/world-controls.js.map +1 -0
  128. package/llms/world-controls.md +262 -0
  129. package/llms/worlds.js +2 -1
  130. package/llms/worlds.js.map +1 -1
  131. package/llms/worlds.md +5 -14
  132. package/llms/youtube.js +10 -1
  133. package/llms/youtube.js.map +1 -1
  134. package/llms/youtube.md +67 -53
  135. package/package.json +5 -5
  136. package/prompts.js +5 -19
  137. package/prompts.js.map +1 -1
@@ -0,0 +1,190 @@
1
+ # Media capture — photos, a live camera and voice recordings
2
+
3
+ The photo picker and the stream helpers above are this skill's two halves. Reach for the lightest
4
+ one that does the job:
5
+
6
+ | The app needs | Use |
7
+ | --- | --- |
8
+ | a photo or a few (a plant to identify, a receipt, an avatar, a product shot) | `PhotoPicker`: one input, no `capture`, so the phone offers Take Photo and the library |
9
+ | the camera as its whole point (a document scanner, a quick photo booth) | the two-button picker: `capture` on the main button, the library on the second |
10
+ | a camera that stays open (a QR scanner, a booth with a countdown or an overlay, AR) | the live viewfinder below |
11
+ | a voice memo, an audio note, a spoken answer | the recorder below |
12
+ | an audio file someone already has | `<input type="file" accept="audio/*">` behind a `Button` |
13
+
14
+ ## A live viewfinder
15
+
16
+ A viewfinder starts on a tap ("Start camera"), never on mount. The tap opens the stream with
17
+ `openStream`, the video plays inline, a flip button switches between the front and back cameras,
18
+ and the shot is the current frame drawn to a canvas. When the stream will not open, the picker
19
+ takes its place, so the person can still hand over a photo.
20
+
21
+ ```jsx
22
+ import { Button, ErrorNote, Row, Stack } from "@vibes.diy/ui";
23
+ import { openStream, stopStream, streamHelp } from "./lib/media.js";
24
+
25
+ function Viewfinder({ onShot }) {
26
+ const videoRef = React.useRef(null);
27
+ const streamRef = React.useRef(null);
28
+ const [facing, setFacing] = React.useState("environment"); // "user" is the selfie camera
29
+ const [live, setLive] = React.useState(false);
30
+ const [problem, setProblem] = React.useState("");
31
+ // Each open gets a number; closing, unmounting or a newer tap moves it on, so a stream that
32
+ // arrives for an older one is stopped instead of left running.
33
+ const request = React.useRef(0);
34
+
35
+ const stop = () => {
36
+ request.current += 1;
37
+ stopStream(streamRef.current);
38
+ streamRef.current = null;
39
+ setLive(false);
40
+ };
41
+ React.useEffect(() => {
42
+ const hide = () => document.visibilityState === "hidden" && stop();
43
+ document.addEventListener("visibilitychange", hide);
44
+ window.addEventListener("pagehide", stop);
45
+ return () => {
46
+ document.removeEventListener("visibilitychange", hide);
47
+ window.removeEventListener("pagehide", stop);
48
+ stop();
49
+ };
50
+ }, []);
51
+
52
+ // Called only from a tap: Start camera, Try again, or the flip button.
53
+ async function start(next = facing) {
54
+ const mine = ++request.current;
55
+ stopStream(streamRef.current);
56
+ streamRef.current = null;
57
+ const res = await openStream({ video: { facingMode: next, width: { ideal: 1280 } }, audio: false });
58
+ if (mine !== request.current || !videoRef.current) {
59
+ if (res.ok) stopStream(res.stream); // closed, unmounted or tapped again while the prompt was up
60
+ return;
61
+ }
62
+ if (!res.ok) {
63
+ setProblem(streamHelp(res.reason, "camera"));
64
+ return;
65
+ }
66
+ setProblem("");
67
+ streamRef.current = res.stream;
68
+ videoRef.current.srcObject = res.stream;
69
+ setFacing(next);
70
+ setLive(true);
71
+ }
72
+
73
+ function snap() {
74
+ const v = videoRef.current;
75
+ const canvas = document.createElement("canvas");
76
+ canvas.width = v.videoWidth;
77
+ canvas.height = v.videoHeight;
78
+ canvas.getContext("2d").drawImage(v, 0, 0);
79
+ canvas.toBlob((blob) => onShot(new File([blob], `shot-${Date.now()}.jpg`, { type: "image/jpeg" })), "image/jpeg", 0.9);
80
+ }
81
+
82
+ return (
83
+ <Stack gap={3}>
84
+ {/* playsInline + muted let iOS play the stream in the page instead of full screen. */}
85
+ <video ref={videoRef} autoPlay playsInline muted
86
+ className={`aspect-3/4 w-full rounded-md bg-muted object-cover ${facing === "user" ? "-scale-x-100" : ""}`} />
87
+ {live ? (
88
+ <Row gap={2} justify="center" align="center">
89
+ <Button size="lg" onClick={snap}>Take photo</Button>
90
+ <Button variant="quiet" onClick={() => start(facing === "user" ? "environment" : "user")}>Switch camera</Button>
91
+ <Button variant="quiet" onClick={stop}>Close camera</Button>
92
+ </Row>
93
+ ) : (
94
+ <Button size="lg" onClick={() => start()}>{problem ? "Try the camera again" : "Start camera"}</Button>
95
+ )}
96
+ {problem && (
97
+ <>
98
+ <ErrorNote>{problem}</ErrorNote>
99
+ <PhotoPicker label="Choose a photo instead" onChange={(files) => files[0] && onShot(files[0])} />
100
+ </>
101
+ )}
102
+ </Stack>
103
+ );
104
+ }
105
+ ```
106
+
107
+ The selfie preview is mirrored, like a mirror; the saved shot is not. A frame from the canvas
108
+ carries no EXIF, so it is safe to store; run it through `shrinkPhoto` when it should be smaller.
109
+
110
+ ## A voice recorder
111
+
112
+ Recording runs on a tap: Record opens the microphone with `openMic()` and starts a
113
+ `MediaRecorder`; while it runs the screen shows a red recording dot, a running timer, a level
114
+ meter, Stop and Cancel. Stop leaves the recording in a review state with a player, Save and
115
+ Record again; Cancel throws it away. The tracks stop as soon as recording ends.
116
+
117
+ ```js
118
+ // lib/recorder.js — plain module, no React.
119
+ import { openMic, stopStream } from "./media.js";
120
+
121
+ // Safari records MP4/AAC, Chrome and Firefox WebM/Opus: take the first one this browser supports.
122
+ const TYPES = ["audio/webm;codecs=opus", "audio/mp4;codecs=mp4a.40.2", "audio/mp4", "audio/webm"];
123
+ export const pickMimeType = () => TYPES.find((t) => window.MediaRecorder?.isTypeSupported(t)) ?? "";
124
+
125
+ // Call from the Record tap. Resolves { ok: true, stop, cancel, level } or { ok: false, reason }.
126
+ export async function startRecording() {
127
+ // The meter's AudioContext is created in the same tap, so iOS lets it run.
128
+ const ctx = new (window.AudioContext || window.webkitAudioContext)();
129
+ const mic = await openMic();
130
+ if (!mic.ok) {
131
+ ctx.close();
132
+ return mic;
133
+ }
134
+ const mimeType = pickMimeType();
135
+ const recorder = new MediaRecorder(mic.stream, mimeType ? { mimeType } : undefined);
136
+ const chunks = [];
137
+ recorder.ondataavailable = (e) => e.data.size > 0 && chunks.push(e.data);
138
+ recorder.start(250);
139
+
140
+ const analyser = ctx.createAnalyser();
141
+ analyser.fftSize = 512;
142
+ ctx.createMediaStreamSource(mic.stream).connect(analyser);
143
+ const samples = new Uint8Array(analyser.fftSize);
144
+ const level = () => { // 0..1, read from a requestAnimationFrame loop
145
+ analyser.getByteTimeDomainData(samples);
146
+ return Math.min(1, Math.max(...samples.map((s) => Math.abs(s - 128))) / 64);
147
+ };
148
+
149
+ const release = () => {
150
+ stopStream(mic.stream);
151
+ ctx.close();
152
+ };
153
+ const stop = () =>
154
+ new Promise((resolve) => {
155
+ recorder.onstop = () => {
156
+ release();
157
+ const type = recorder.mimeType || mimeType || "audio/webm";
158
+ const ext = type.includes("mp4") ? "m4a" : "webm";
159
+ resolve(new File([new Blob(chunks, { type })], `memo-${Date.now()}.${ext}`, { type }));
160
+ };
161
+ recorder.stop();
162
+ });
163
+ const cancel = () => {
164
+ recorder.onstop = release;
165
+ recorder.stop();
166
+ };
167
+ return { ok: true, stop, cancel, level };
168
+ }
169
+ ```
170
+
171
+ In the component, keep the session in a ref and cancel it in the unmount cleanup, on
172
+ `pagehide` and when `visibilitychange` finds the page hidden, the same as a stream, and number each Record tap like the viewfinder's `request` so a
173
+ session that starts after the person left is cancelled at once. While it records:
174
+
175
+ ```jsx
176
+ <Row gap={3} align="center" aria-live="polite">
177
+ <span className="h-3 w-3 animate-pulse rounded-full bg-destructive" aria-hidden="true" />
178
+ <Text>Recording {Math.floor(secs / 60)}:{String(secs % 60).padStart(2, "0")}</Text>
179
+ <Progress value={meter * 100} label="Input level" />
180
+ <Button onClick={finish}>Stop</Button>
181
+ <Button variant="quiet" onClick={() => session.current.cancel()}>Cancel</Button>
182
+ </Row>
183
+ ```
184
+
185
+ `secs` counts from a `startedAt` timestamp and `meter` reads `level()`, both from one
186
+ `requestAnimationFrame` loop (`Progress` comes from `@vibes.diy/ui/interactive`). Play the take back
187
+ before saving it: `<audio controls src={URL.createObjectURL(file)} />`, the duration beside it,
188
+ then save the `File` as `_files: { audio: file }` on the memo's record, whose `url` plays it later
189
+ in the same `<audio controls>`. A memo app shows its list of saved recordings, newest first, each
190
+ with its own player.
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const micCaptureConfig: LlmConfig;
@@ -0,0 +1,7 @@
1
+ export const micCaptureConfig = {
2
+ name: "mic-capture",
3
+ label: "Mic capture",
4
+ description: "Opening the microphone or camera: getUserMedia inside the tap that needs it, voice and music constraints, a plain reason when the stream is blocked, missing or busy, and every track stopped on finish, unmount and page hide.",
5
+ menu: false,
6
+ };
7
+ //# sourceMappingURL=mic-capture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mic-capture.js","sourceRoot":"","sources":["../../jsr/llms/mic-capture.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,iOAAiO;IACnO,IAAI,EAAE,KAAK;CACZ,CAAC"}
@@ -0,0 +1,76 @@
1
+ # Microphone and camera streams — asked for on the tap, stopped when done
2
+
3
+ `navigator.mediaDevices.getUserMedia` is a browser built-in. **Ask for the microphone or camera
4
+ inside the tap that needs it.** The person presses Record, Start camera or Tune, and that
5
+ handler's first `await` is the request, so the browser's permission prompt answers their own
6
+ press. A request on mount, in a `useEffect` or on page load asks a stranger for their microphone
7
+ before they know why, and on iOS it may never show at all.
8
+
9
+ ## `lib/media.js` — open, explain, stop
10
+
11
+ ```js
12
+ // lib/media.js — plain module, no React.
13
+ export const VOICE = { echoCancellation: true, noiseSuppression: true, autoGainControl: true };
14
+ export const MUSIC = { echoCancellation: false, noiseSuppression: false, autoGainControl: false };
15
+
16
+ // Call from the tap handler. Resolves { ok: true, stream } or { ok: false, reason }.
17
+ export async function openStream(constraints) {
18
+ if (!navigator.mediaDevices?.getUserMedia) return { ok: false, reason: "unsupported" };
19
+ try {
20
+ return { ok: true, stream: await navigator.mediaDevices.getUserMedia(constraints) };
21
+ } catch (err) {
22
+ if (err.name === "NotAllowedError" || err.name === "SecurityError") return { ok: false, reason: "blocked" };
23
+ if (err.name === "NotFoundError" || err.name === "OverconstrainedError") return { ok: false, reason: "missing" };
24
+ return { ok: false, reason: "busy" }; // NotReadableError, AbortError: another app holds it
25
+ }
26
+ }
27
+
28
+ export const openMic = (audio = VOICE) => openStream({ audio, video: false });
29
+
30
+ // Every track stops: the browser's recording light goes out and the device is free again.
31
+ export function stopStream(stream) {
32
+ stream?.getTracks().forEach((t) => t.stop());
33
+ }
34
+
35
+ // What to say when the stream did not open, in the app's own words.
36
+ export function streamHelp(reason, device = "microphone") {
37
+ if (reason === "blocked") return `Allow the ${device} for this site in your browser settings, then tap again.`;
38
+ if (reason === "missing") return `Connect a ${device} and tap again.`;
39
+ if (reason === "busy") return `Close the other app using your ${device}, then tap again.`;
40
+ return `This browser keeps the ${device} to itself. The rest of the app still works.`;
41
+ }
42
+ ```
43
+
44
+ ## Stop the tracks when the person is done
45
+
46
+ Stop every track when recording ends, when the component unmounts and when the page is hidden
47
+ (another tab, the phone locked), so the recording indicator never stays lit behind the person's
48
+ back. Switching tabs or locking a phone hides the page without a `pagehide`, so listen for
49
+ `visibilitychange` as well:
50
+
51
+ ```jsx
52
+ const streamRef = React.useRef(null);
53
+ React.useEffect(() => {
54
+ const stop = () => {
55
+ stopStream(streamRef.current);
56
+ streamRef.current = null;
57
+ };
58
+ const hide = () => document.visibilityState === "hidden" && stop();
59
+ document.addEventListener("visibilitychange", hide);
60
+ window.addEventListener("pagehide", stop);
61
+ return () => {
62
+ document.removeEventListener("visibilitychange", hide);
63
+ window.removeEventListener("pagehide", stop);
64
+ stop();
65
+ };
66
+ }, []);
67
+ ```
68
+
69
+ A stopped stream comes back with the next tap, never on its own when the page shows again.
70
+
71
+ ## A blocked state that keeps the app useful
72
+
73
+ When `openStream` resolves `ok: false`, show `streamHelp(reason)` beside the button that asked,
74
+ keep that button working so a second tap retries, and offer the path that needs no permission: a
75
+ typed note beside a voice memo, `<input type="file" accept="audio/*">` for a recording they already
76
+ have, or the photo picker beside a live camera.
@@ -0,0 +1,12 @@
1
+ export interface NeedsCatalogEntry {
2
+ readonly name: string;
3
+ readonly needs?: readonly string[];
4
+ readonly menu?: false;
5
+ readonly cues?: readonly string[];
6
+ readonly universal?: "always" | "edits";
7
+ readonly rail?: "reskin" | "custom";
8
+ }
9
+ export declare function expandSkills(names: readonly string[], catalog: readonly NeedsCatalogEntry[]): string[];
10
+ export declare function skillGraphProblems(catalog: readonly NeedsCatalogEntry[]): string[];
11
+ export declare function onSkillMenu(c: NeedsCatalogEntry): boolean;
12
+ export declare function universalSkillNames(catalog: readonly NeedsCatalogEntry[], turn: "first" | "edit"): string[];
package/llms/needs.js ADDED
@@ -0,0 +1,71 @@
1
+ export function expandSkills(names, catalog) {
2
+ const byName = new Map(catalog.map((c) => [c.name, c]));
3
+ const out = [];
4
+ const visiting = new Set();
5
+ function visit(name) {
6
+ if (out.includes(name) || visiting.has(name))
7
+ return;
8
+ visiting.add(name);
9
+ for (const need of byName.get(name)?.needs ?? [])
10
+ visit(need);
11
+ visiting.delete(name);
12
+ out.push(name);
13
+ }
14
+ for (const name of names)
15
+ visit(name);
16
+ return out;
17
+ }
18
+ function cycleFrom(start, byName) {
19
+ function walk(name, path) {
20
+ for (const need of byName.get(name)?.needs ?? []) {
21
+ if (need === start)
22
+ return [...path, need];
23
+ if (path.includes(need))
24
+ continue;
25
+ const found = walk(need, [...path, need]);
26
+ if (found !== undefined)
27
+ return found;
28
+ }
29
+ return undefined;
30
+ }
31
+ return walk(start, [start]);
32
+ }
33
+ export function skillGraphProblems(catalog) {
34
+ const byName = new Map(catalog.map((c) => [c.name, c]));
35
+ const position = new Map(catalog.map((c, i) => [c.name, i]));
36
+ const problems = [];
37
+ for (const c of catalog) {
38
+ for (const need of c.needs ?? []) {
39
+ const at = position.get(need);
40
+ if (at === undefined)
41
+ problems.push(`"${c.name}" needs "${need}", which is not in the catalog`);
42
+ else if (at > (position.get(c.name) ?? 0))
43
+ problems.push(`"${c.name}" needs "${need}", which comes after it in catalog order`);
44
+ }
45
+ const cycle = cycleFrom(c.name, byName);
46
+ if (cycle !== undefined)
47
+ problems.push(`"${c.name}" is on a needs cycle: ${cycle.join(" → ")}`);
48
+ if (c.menu === false) {
49
+ if (catalog.some((d) => (d.needs ?? []).includes(c.name)) === false)
50
+ problems.push(`"${c.name}" is menu: false and no skill needs it`);
51
+ if ((c.cues ?? []).length > 0)
52
+ problems.push(`"${c.name}" is menu: false and carries cues`);
53
+ }
54
+ if (c.universal !== undefined) {
55
+ if ((c.needs ?? []).length > 0)
56
+ problems.push(`"${c.name}" is universal and declares needs`);
57
+ if (c.menu === false)
58
+ problems.push(`"${c.name}" is universal and menu: false`);
59
+ }
60
+ }
61
+ return problems;
62
+ }
63
+ export function onSkillMenu(c) {
64
+ return c.menu !== false;
65
+ }
66
+ export function universalSkillNames(catalog, turn) {
67
+ return catalog
68
+ .filter((c) => c.universal === "always" || (turn === "edit" && c.universal === "edits"))
69
+ .map((c) => c.name);
70
+ }
71
+ //# sourceMappingURL=needs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"needs.js","sourceRoot":"","sources":["../../jsr/llms/needs.ts"],"names":[],"mappings":"AAsBA,MAAM,UAAU,YAAY,CAAC,KAAwB,EAAE,OAAqC;IAC1F,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAA+B,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACrF,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,SAAS,KAAK,CAAC,IAAY;QACzB,IAAI,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,OAAO;QACrD,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACnB,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9D,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO,GAAG,CAAC;AACb,CAAC;AAGD,SAAS,SAAS,CAAC,KAAa,EAAE,MAA8C;IAC9E,SAAS,IAAI,CA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AC,IAAI,gCAAgC,CAAC,CAAC;QAClF,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAGD,MAAM,UAAU,WAAW,CAAC,CAAoB;IAC9C,OAAO,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC;AAC1B,CAAC;AAMD,MAAM,UAAU,mBAAmB,CAAC,OAAqC,EAAE,IAAsB;IAC/F,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC;SACvF,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const ownerSecretConfig: LlmConfig;
@@ -0,0 +1,8 @@
1
+ export const ownerSecretConfig = {
2
+ name: "owner-secret",
3
+ label: "The owner's own key",
4
+ description: "Hidden: the owner's own key for a third-party service as one Setup item (missing-key verdict, Settings → Secrets steps, no redeploy), kept to backend.js, the /_api second door that spends it only on the owner's calls, refusals that keep their reason, and rotation",
5
+ menu: false,
6
+ teaches: ["missing-key"],
7
+ };
8
+ //# sourceMappingURL=owner-secret.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"owner-secret.js","sourceRoot":"","sources":["../../jsr/llms/owner-secret.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,iBAAiB,GAAc;IAC1C,IAAI,EAAE,cAAc;IACpB,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,yQAAyQ;IAC3Q,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,CAAC,aAAa,CAAC;CACzB,CAAC"}
@@ -0,0 +1,82 @@
1
+ # The owner's own key — one secret the app runs on
2
+
3
+ Some services answer only with a key, and the key belongs to the app's owner:
4
+ they create it on the service's site once, paste it into the vibe's Secrets,
5
+ and backend.js reads it as `ctx.secrets.<NAME>`. The service skill that loaded
6
+ this page names the secret and the provider pages; this page is what every
7
+ owner-key feature does the same way.
8
+
9
+ ## The owner's key, not each visitor's
10
+
11
+ The key is the owner's, its quota or bill is the owner's, and every visitor sees
12
+ what the owner's key can see. An app where each person sees **their own**
13
+ account is a **connection** instead: the platform runs the sign-in and holds the
14
+ credential, and the app's code never sees a token (the connections docs). So
15
+ never ask a visitor to paste a token or send one to a developer console: the
16
+ console trip in the service's steps is the owner's, once.
17
+
18
+ ## The secret is a Setup item
19
+
20
+ The key is one item on the app's Setup surface (the use-vibe docs' *Some apps
21
+ need setup before they work*). The `/setup` route marks it done when
22
+ `ctx.secrets.<NAME>` is present, and every feature route answers
23
+ `{ ok: false, reason: "missing-key" }` while it is absent, so the page can say
24
+ *not open yet* to a visitor and show the owner the steps.
25
+
26
+ The item's steps are written for someone who has never opened the provider's
27
+ console: each one links the exact page and uses that page's own words, and the
28
+ last two are always the same:
29
+
30
+ - Open this vibe's **Settings** tab,
31
+ `https://vibes.diy/vibes/mine/<ownerHandle>/<appSlug>/settings`, and under
32
+ **Secrets** enter the name (`YOUTUBE_API_KEY`, in so many words), paste the
33
+ value, and save. From a terminal: `npx vibes-diy secrets set <NAME> --vibe <ownerHandle>/<appSlug>`.
34
+ - Come back to the app: it works the moment the key is saved, with no redeploy.
35
+
36
+ Wherever the owner types the value (this tab, the terminal, or a secure field
37
+ the vibes.diy assistant opens for them), it lands in the same store under the
38
+ same name, so the app's copy only has to name it. The app never asks for the key
39
+ itself: no input, no form, no "paste your key here" field on any page, because a
40
+ value typed into the app is a value the app's own data and every visitor's
41
+ browser can reach.
42
+
43
+ ## The key never reaches the browser
44
+
45
+ Every call to the service is made in backend.js with `ctx.fetch`, and the key
46
+ rides only that request. App.jsx talks to the app's own `/_api/...` routes and
47
+ never names the service's API host. A key in a React component ships to every
48
+ visitor who views source.
49
+
50
+ ## The `/_api` routes are a second door
51
+
52
+ A published vibe's `/_api/...` routes answer anyone, so a route that calls the
53
+ service on every request lets a stranger spend the owner's quota or bill. Spend
54
+ the key on the owner's own calls and on the backend's scheduled jobs; a
55
+ visitor's request is answered from what those calls stored, with the date it was
56
+ read, or with a stated reason when nothing is stored yet.
57
+
58
+ ```js
59
+ // backend.js — who may spend the owner's key
60
+ const isOwnerCall = (ctx) => ctx.userInfo?.userHandle != null && ctx.userInfo.userHandle === ctx.appInfo.ownerHandle;
61
+ ```
62
+
63
+ A service that charges per call (voice, images, video) needs this most: a
64
+ visitor-facing route that generates with the owner's key is a wallet with a
65
+ public URL. Let visitors use it only behind a limit the owner sets, kept in a
66
+ document the backend checks before each call.
67
+
68
+ ## Errors keep their reason
69
+
70
+ Classify every refusal and pass the reason to the screen: the key is missing,
71
+ the key is wrong (the service's 401 or 403, which also means the Setup item
72
+ reads *Done* while one value is bad), the quota or rate limit is spent (keep the
73
+ service's own wait or reset time), or the item was not found. Wrap every route in
74
+ `try`/`catch` and answer with that reason, because an uncaught throw reaches the
75
+ page as a bare `500` that names nothing the owner can fix.
76
+
77
+ ## Rotating the key
78
+
79
+ The owner rotates a key by saving a new value under the same name, and handlers
80
+ read the current value on every call, so there is nothing to restart. When a key
81
+ leaks (pasted into a chat, committed somewhere), the fix is a fresh key from the
82
+ provider and the old one revoked there.
package/llms/p5.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const p5Config = {
2
2
  name: "p5",
3
+ needs: ["canvas-theme-colors"],
3
4
  label: "p5.js",
4
5
  description: "p5.js creative-coding library for 2D canvas and WEBGL sketches: generative art, flow " +
5
6
  "fields, particle systems, Perlin noise, seeded deterministic sketches, kaleidoscopes, " +
package/llms/p5.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"p5.js","sourceRoot":"","sources":["../../jsr/llms/p5.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAc;IACjC,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,OAAO;IACd,WAAW,EACT,uFAAuF;QACvF,wFAAwF;QACxF,sFAAsF;QACtF,wFAAwF;QACxF,0FAA0F;QAC1F,uFAAuF;QACvF,+JAA+J;IACjK,IAAI,EAAE;QACJ,IAAI;QACJ,OAAO;QACP,YAAY;QACZ,QAAQ;QACR,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,cAAc;QACd,gBAAgB;QAChB,cAAc;QACd,aAAa;KACd;IAID,YAAY,EAAE,2BAA2B;IACzC,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,SAAS;CACtB,CAAC"}
1
+ {"version":3,"file":"p5.js","sourceRoot":"","sources":["../../jsr/llms/p5.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAc;IACjC,IAAI,EAAE,IAAI;IAEV,KAAK,EAAE,CAAC,qBAAqB,CAAC;IAC9B,KAAK,EAAE,OAAO;IACd,WAAW,EACT,uFAAuF;QACvF,wFAAwF;QACxF,sFAAsF;QACtF,wFAAwF;QACxF,0FAA0F;QAC1F,uFAAuF;QACvF,+JAA+J;IACjK,IAAI,EAAE;QACJ,IAAI;QACJ,OAAO;QACP,YAAY;QACZ,QAAQ;QACR,gBAAgB;QAChB,iBAAiB;QACjB,YAAY;QACZ,cAAc;QACd,gBAAgB;QAChB,cAAc;QACd,aAAa;KACd;IAID,YAAY,EAAE,2BAA2B;IACzC,UAAU,EAAE,IAAI;IAChB,UAAU,EAAE,SAAS;CACtB,CAAC"}
package/llms/p5.md CHANGED
@@ -25,24 +25,12 @@ the instance so remounts do not leak a second draw loop.
25
25
  import React from "react";
26
26
  import p5 from "https://esm.sh/p5@1.11.13";
27
27
  import { Button, Row, Stack } from "@vibes.diy/ui";
28
+ // Canvas pixels cannot follow a CSS variable: lib/look.js (the canvas theme colours) resolves the
29
+ // injected theme tokens to concrete colours, the second argument the fallback for an unthemed app.
30
+ import { cssColor, watchLook } from "./lib/look.js";
28
31
 
29
32
  const TAU = Math.PI * 2;
30
33
 
31
- // Canvas pixels cannot follow a CSS variable, so resolve the injected theme
32
- // tokens to concrete colors once per mount. Setting `color` on a throwaway
33
- // element and reading it back returns a resolved `rgb(...)` string even when the
34
- // token's value is a `color-mix()` or another `var()`, and the second argument
35
- // is the fallback for an app with no theme injected.
36
- function cssColor(host, token, fallback) {
37
- const probe = document.createElement("span");
38
- probe.style.display = "none";
39
- probe.style.color = `var(${token}, ${fallback})`;
40
- host.appendChild(probe);
41
- const resolved = window.getComputedStyle(probe).color;
42
- probe.remove();
43
- return resolved || fallback;
44
- }
45
-
46
34
  // The sketch is a pure function of its parameters and its host element. Pass the
47
35
  // host in explicitly — never read p5's private `_userNode` to find it.
48
36
  function makeSketch({ params, host, stepsRef }) {
@@ -178,12 +166,11 @@ export default function App() {
178
166
 
179
167
  // The Style tab recolors a running app by swapping the CSS variables with
180
168
  // no remount, which every styled element follows and the canvas cannot.
181
- // Watching the document's stylesheets is what makes the sketch follow too.
182
- const observer = new MutationObserver(() => instance.retheme());
183
- observer.observe(document.head, { childList: true, subtree: true, characterData: true });
169
+ // watchLook tells the sketch, so it follows too.
170
+ const unwatch = watchLook(node, () => instance.retheme());
184
171
 
185
172
  return () => {
186
- observer.disconnect();
173
+ unwatch();
187
174
  instance.remove();
188
175
  };
189
176
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -298,24 +285,11 @@ utilities (`bg-background`, `text-foreground`), but **canvas pixels cannot follo
298
285
  variable**, so a sketch that inlines `"#00e5ff"` is the one part of a themed vibe
299
286
  its owner can never restyle.
300
287
 
301
- **Resolve the theme tokens to concrete colours at setup, and use a literal only
302
- as the fallback when no theme is injected.** Reading the custom property
303
- straight off the host with `getComputedStyle(host).getPropertyValue("--accent")`
304
- is enough when the token holds a plain colour, but a token whose value is a
305
- `color-mix()` or another `var()` comes back unresolved and p5 cannot parse it.
306
- Letting the browser resolve it works for every value:
288
+ **Resolve the theme tokens to concrete colours at setup with `cssColor` from
289
+ `lib/look.js` (the canvas theme colours), and use a literal only as the fallback
290
+ when no theme is injected:**
307
291
 
308
292
  ```js
309
- function cssColor(host, token, fallback) {
310
- const probe = document.createElement("span");
311
- probe.style.display = "none";
312
- probe.style.color = `var(${token}, ${fallback})`;
313
- host.appendChild(probe);
314
- const resolved = window.getComputedStyle(probe).color;
315
- probe.remove();
316
- return resolved || fallback;
317
- }
318
-
319
293
  p.setup = () => {
320
294
  p.createCanvas(w, h);
321
295
  const ink = p.color(cssColor(host, "--accent", "#00e5ff"));
@@ -327,41 +301,13 @@ p.setup = () => {
327
301
 
328
302
  Read the tokens **inside `setup`**, not at module scope, so a rebuilt instance
329
303
  picks up the current theme. Keep alpha in p5's hands with `setAlpha`: appending
330
- `"55"` to a token works only if the token happened to be a six-digit hex, and a
331
- resolved `rgb(...)` string it silently corrupts.
332
-
333
- **Reading at setup is not enough on its own, because a restyle does not rebuild
334
- the sketch.** The Style tab recolors a running app by swapping the page's CSS
335
- variables in place — it replaces the contents of a `<style>` element in the
336
- document head, with no remount — so every styled element re-renders through the
337
- cascade and the canvas, which is painted rather than styled, keeps the colours it
338
- resolved at setup until something unrelated happens to rebuild it. Watch the
339
- document's stylesheets and repaint:
340
-
341
- ```jsx
342
- // in the sketch: re-read and repaint on demand
343
- p.retheme = () => {
344
- if (palette === null) return; // setup has not run yet
345
- readPalette();
346
- p.stroke(palette.ink);
347
- p.background(palette.bg);
348
- };
349
-
350
- // in the component: same effect that built the instance, same cleanup
351
- const instance = new p5(makeSketch({ params, host: node }), node);
352
- const observer = new MutationObserver(() => instance.retheme());
353
- observer.observe(document.head, { childList: true, subtree: true, characterData: true });
354
- return () => {
355
- observer.disconnect();
356
- instance.remove();
357
- };
358
- ```
304
+ `"55"` to a token's string corrupts it.
359
305
 
360
- `characterData` and `subtree` are both needed: a first push APPENDS the style
361
- element, and every push after it rewrites the text of the one already there. The
362
- observer belongs to the effect that built the instance, so it is disconnected in
363
- the same cleanup that removes it — an observer outliving its sketch is the same
364
- leak as a draw loop outliving its canvas.
306
+ **A restyle does not rebuild the sketch**, so give the sketch a `p.retheme()`
307
+ that re-reads the palette and repaints, and call it from `watchLook` in the
308
+ effect that built the instance, disconnecting in the same cleanup that removes it
309
+ (the starter above does exactly this). An observer outliving its sketch is the
310
+ same leak as a draw loop outliving its canvas.
365
311
 
366
312
  ## Determinism — a picture is a handful of numbers
367
313
 
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const photoInputConfig: LlmConfig;
@@ -0,0 +1,7 @@
1
+ export const photoInputConfig = {
2
+ name: "photo-input",
3
+ label: "Photo input",
4
+ description: "The photo picker that offers the camera and the photo library: a hidden accept=image/* input with no capture behind the app's own button, multi-select, paste and drag-and-drop, an immediate preview with remove and replace, and shrinkPhoto (downscale, EXIF and location stripped) before storing.",
5
+ menu: false,
6
+ };
7
+ //# sourceMappingURL=photo-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"photo-input.js","sourceRoot":"","sources":["../../jsr/llms/photo-input.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,wSAAwS;IAC1S,IAAI,EAAE,KAAK;CACZ,CAAC"}