dj-claude 0.1.12 → 0.1.13

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.
@@ -22,7 +22,7 @@ export function getPageHtml(wsPort) {
22
22
  <head>
23
23
  <meta charset="UTF-8">
24
24
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
25
- <title>DJ Claude | v 0.1.12</title>
25
+ <title>DJ Claude | v 0.1.13</title>
26
26
  <link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🔈</text></svg>">
27
27
  <link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">
28
28
  <style>
@@ -111,7 +111,7 @@ export function getPageHtml(wsPort) {
111
111
  <!-- Welcome box -->
112
112
  <div class="ascii-box">
113
113
  <pre>╔═════════════════════════════════════════════╗</pre>
114
- <div style="display:flex"><pre>║</pre><pre style="flex:1;text-align:center">Welcome to DJ Claude <span class="dim">v 0.1.12</span></pre><pre>║</pre></div>
114
+ <div style="display:flex"><pre>║</pre><pre style="flex:1;text-align:center">Welcome to DJ Claude <span class="dim">v 0.1.13</span></pre><pre>║</pre></div>
115
115
  <pre>╚═════════════════════════════════════════════╝</pre>
116
116
  </div>
117
117
 
@@ -27,6 +27,6 @@ export function Header({ isPlaying, isStreaming, audioInitialized }) {
27
27
  statusSymbol = '●';
28
28
  statusLabel = 'Playing';
29
29
  }
30
- return (_jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: "#E8704E", children: WELCOME_TOP }), _jsxs(Text, { color: "#E8704E", children: ['║ Welcome to DJ Claude ', _jsx(Text, { dimColor: true, children: "v 0.1.12" }), ' ║'] }), _jsx(Text, { color: "#E8704E", children: WELCOME_BTM }), _jsx(Text, { color: "#E8704E", children: BANNER }), _jsx(Text, { color: "#E8704E", dimColor: dim, children: `╔═════════════════════════╗\n║ ${statusSymbol} ${statusLabel.padEnd(14)} ║\n╚═════════════════════════╝` })] }));
30
+ return (_jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: "#E8704E", children: WELCOME_TOP }), _jsxs(Text, { color: "#E8704E", children: ['║ Welcome to DJ Claude ', _jsx(Text, { dimColor: true, children: "v 0.1.13" }), ' ║'] }), _jsx(Text, { color: "#E8704E", children: WELCOME_BTM }), _jsx(Text, { color: "#E8704E", children: BANNER }), _jsx(Text, { color: "#E8704E", dimColor: dim, children: `╔═════════════════════════╗\n║ ${statusSymbol} ${statusLabel.padEnd(14)} ║\n╚═════════════════════════╝` })] }));
31
31
  }
32
32
  //# sourceMappingURL=Header.js.map
@@ -1,3 +1,3 @@
1
1
  import type { Message } from './types.js';
2
- export declare function streamChat(apiKey: string, prompt: string, currentCode: string, history: Message[]): AsyncGenerator<string>;
2
+ export declare function streamChat(apiKey: string, prompt: string, currentCode: string, history: Message[], systemOverride?: string): AsyncGenerator<string>;
3
3
  //# sourceMappingURL=claude.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAc1C,wBAAuB,UAAU,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAAE,GACjB,cAAc,CAAC,MAAM,CAAC,CAoCxB"}
1
+ {"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAc1C,wBAAuB,UAAU,CAC/B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,OAAO,EAAE,EAClB,cAAc,CAAC,EAAE,MAAM,GACtB,cAAc,CAAC,MAAM,CAAC,CAoCxB"}
@@ -10,7 +10,7 @@ function getClient(apiKey) {
10
10
  }
11
11
  return anthropic;
12
12
  }
13
- export async function* streamChat(apiKey, prompt, currentCode, history) {
13
+ export async function* streamChat(apiKey, prompt, currentCode, history, systemOverride) {
14
14
  const client = getClient(apiKey);
15
15
  // Build messages with recent history for continuity (last 6 exchanges)
16
16
  const messages = [];
@@ -31,7 +31,7 @@ export async function* streamChat(apiKey, prompt, currentCode, history) {
31
31
  const stream = await client.messages.stream({
32
32
  model: process.env.DJ_CLAUDE_MODEL ?? 'claude-sonnet-4-6',
33
33
  max_tokens: Number(process.env.DJ_CLAUDE_MAX_TOKENS) || 16384,
34
- system: SYSTEM_PROMPT,
34
+ system: systemOverride ?? SYSTEM_PROMPT,
35
35
  messages,
36
36
  });
37
37
  for await (const event of stream) {
@@ -1 +1 @@
1
- {"version":3,"file":"claude.js","sourceRoot":"","sources":["../../src/lib/claude.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG7C,IAAI,SAAS,GAAqB,IAAI,CAAC;AAEvC,SAAS,SAAS,CAAC,MAAc;IAC/B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,qEAAqE;QACrE,sEAAsE;QACtE,wDAAwD;QACxD,SAAS,GAAG,IAAI,SAAS,CAAC,EAAE,MAAM,EAAE,uBAAuB,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,UAAU,CAC/B,MAAc,EACd,MAAc,EACd,WAAmB,EACnB,OAAkB;IAElB,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;IAEjC,uEAAuE;IACvE,MAAM,QAAQ,GAA6B,EAAE,CAAC;IAE9C,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,CAA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AE,cAAc,IAAI,aAAa;QACvC,QAAQ;KACT,CAAC,CAAC;IAEH,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,IACE,KAAK,CAAC,IAAI,KAAK,qBAAqB;YACpC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,YAAY,EACjC,CAAC;YACD,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -14,7 +14,7 @@ export function getApiKey() {
14
14
  if (!key) {
15
15
  console.error('\n' +
16
16
  ' \x1b[1m╔════════════════════════════════════════════════════╗\n' +
17
- ' ║ DJ Claude \x1b[0mv 0.1.12\x1b[1m — Live coding music for Agents ║\n' +
17
+ ' ║ DJ Claude \x1b[0mv 0.1.13\x1b[1m — Live coding music for Agents ║\n' +
18
18
  ' ╚════════════════════════════════════════════════════╝\x1b[0m\n' +
19
19
  '\n' +
20
20
  ' \x1b[1m─── About ─────────────────────────────────────────────\x1b[0m\n' +
@@ -1,2 +1,4 @@
1
+ export declare const STRUDEL_REFERENCE = "## Strudel Reference\n\n### Core Functions\n- note(\"c3 e3 g3\") \u2014 play notes (use with .s() for synth choice)\n- s(\"bd sd hh\") \u2014 play samples\n- stack(p1, p2, p3, ...) \u2014 layer patterns simultaneously (your primary tool for building depth)\n- cat(p1, p2) \u2014 sequence patterns across cycles (use for A/B sections, intros vs drops)\n- note(\"[c3,e3,g3]\") \u2014 play multiple notes simultaneously as a chord\n- n(\"0 2 4 6 3 5 7\").scale(\"C:minor\") \u2014 scale-degree notation (0-based)\n- .scale(\"C:minor\") \u2014 constrain notes to a scale\n- Common scales: C:minor, C:major, C:dorian, C:mixolydian, C:phrygian, C:pentatonic, C:melodic_minor\n\n### Tempo Control\n- .cpm(n) \u2014 cycles per minute (default ~60). Controls global speed.\n - 60 cpm = 120 BPM (2 beats per cycle is the norm)\n - 75 cpm = 150 BPM, 55 cpm = 110 BPM\n - Use .cpm() on the outermost stack or final chain\n- Typical ranges: lo-fi/ambient 50-55, house 60-65, techno 65-72, DnB 85-90, trap 70\n\n### Mini Notation\n- \"a b c d\" \u2014 events spread evenly across one cycle\n- \"[a b c]\" \u2014 group into one step (subdivision)\n- \"<a b c>\" \u2014 alternate per cycle (ESSENTIAL for evolution and harmonic progression!)\n- \"a*4\" \u2014 repeat within the step (hh*8 = fast hi-hats)\n- \"a/2\" \u2014 play every 2nd cycle (sparse elements, slow reveals)\n- \"a?\" \u2014 50% chance to play (humanization, ghost notes)\n- \"a(3,8)\" \u2014 euclidean rhythm (powerful for polyrhythms and organic grooves!)\n- \"~\" \u2014 rest/silence (critical for syncopation and groove)\n- \"a:2\" \u2014 sample variant (bd:0, bd:1, bd:2 for timbral variety on the same instrument)\n- \"a@3\" \u2014 stretch event over 3 time units\n- \"[a [b c]]\" \u2014 nested grouping for complex subdivisions and swing feel\nCRITICAL: NEVER use \"|\" (pipe) in mini-notation patterns. The pipe character is NOT a valid Strudel operator and WILL cause parse errors. Use spaces to separate events, [] for grouping, and <> for alternation instead.\n\n### Available Sounds\nPercussion: bd, sd, hh, oh, cp, lt, mt, ht, rim, cb, cr, cy\nSynths (use with note().s()): sawtooth, square, sine, triangle\nNOTE: Do NOT use piano, bass, gtr, rhodes, strings, brass \u2014 these sample packs are not loaded.\nNOTE: Do NOT use .shape(), .crush(), .coarse() \u2014 AudioWorklet is not available in this environment. For grit/distortion effects, use heavy .lpf() filtering, .vowel(), aggressive .resonance(), or FM synthesis (.fmh/.fmi) instead.\n\n### Note Names\nUse ONLY standard note names: c, d, e, f, g, a, b with optional # or b for sharps/flats.\nExamples: c3, eb3, f#4, bb2. Do NOT use \"cm\", \"fm\", \"gm\" \u2014 these are not valid note names in Strudel.\nFor minor chords, spell out the notes: [c3,eb3,g3] NOT \"cm3\".\n\n### Effects & Processing\n- .lpf(freq) / .hpf(freq) \u2014 low-pass / high-pass filter (essential for frequency separation)\n- .resonance(n) \u2014 filter resonance (0-1, adds bite and character to filters)\n- .gain(n) \u2014 volume (0-1)\n- .room(n) / .size(n) \u2014 reverb amount and decay size\n- .delay(n) / .delaytime(t) / .delayfeedback(n) \u2014 delay wet amount, time, and feedback\n- .pan(n) \u2014 stereo position (0 = left, 0.5 = center, 1 = right)\n- .vowel(\"a e i o u\") \u2014 formant filter (vocal-like textures, great for pads)\n- .vowel(\"a e i o u\") can also add grit when combined with .resonance()\n- .speed(n) \u2014 sample playback speed/pitch (0.5 = octave down, 2 = octave up)\n- .cut(n) \u2014 cut group (stops overlapping samples, e.g. closed hat cutting open hat)\n- .attack(t) / .decay(t) / .sustain(n) / .release(t) \u2014 ADSR envelope shaping\n e.g. .attack(0.1).decay(0.2).sustain(0.3).release(0.5) \u2014 plucky synth\n Short attack+decay with low sustain = plucks. Long attack = swells.\n- .fmh(n) \u2014 FM synthesis harmonicity ratio (try 1, 2, 3, 0.5)\n- .fmi(n) \u2014 FM synthesis modulation index (higher = more metallic/harsh)\n e.g. note(\"c3\").s(\"sine\").fmh(2).fmi(sine.range(0.5, 3).slow(8)) \u2014 evolving FM bass\n .fmh() and .fmi() work with any synth oscillator \u2014 key to bass, bells, and metallic textures beyond basic saw/square.\n- .phaser(n) \u2014 phaser depth (0-1, great on chords and pads)\n- .vibrato(n) \u2014 vibrato depth\n- .tremolo(n) \u2014 tremolo depth\n\n### Modulation \u2014 Creating Movement\nUse continuous patterns as parameter values to make sounds ALIVE and evolving:\n- sine.range(min, max).slow(n) \u2014 smooth sine LFO\n- cosine.range(min, max).slow(n) \u2014 cosine LFO (offset from sine)\n- saw.range(min, max).slow(n) \u2014 ramp LFO (builds then resets)\n- perlin.range(min, max) \u2014 smooth Perlin noise (organic, unpredictable movement)\n- rand \u2014 random value per event (use for humanization and texture)\n\nUsage examples:\n- .lpf(sine.range(300, 2000).slow(8)) \u2014 filter sweep over 8 cycles\n- .gain(perlin.range(0.3, 0.6)) \u2014 organic volume variation\n- .pan(sine.slow(3)) \u2014 auto-panning\n- .speed(sine.range(0.8, 1.2).slow(12)) \u2014 subtle pitch drift\n\n### Advanced Pattern Techniques\n- .superimpose(fn) \u2014 layer a transformed copy ON TOP of the original\n e.g. note(\"c3 e3 g3\").superimpose(x => x.add(12)) \u2014 octave doubling\n- .arp(\"up\") / .arp(\"down\") / .arp(\"updown\") \u2014 arpeggiate chords\n e.g. note(\"[c3,e3,g3,b3]\").arp(\"up\").s(\"triangle\") \u2014 rising arp\n- .struct(\"x ~ x x ~ x ~ x\") \u2014 impose a rhythmic structure on any pattern\n- .echo(n, time, feedback) \u2014 pattern-level echo with n repeats\n e.g. note(\"c4 e4\").echo(3, 1/8, 0.5) \u2014 3 echoes at 1/8 cycle, decaying\n- .swing(n) \u2014 shuffle/swing feel (0.5 = straight, higher = more swing)\n\n### Temporal Variation \u2014 Patterns That Evolve Over Time\n- .every(n, fn) \u2014 apply transformation every nth cycle\n e.g. .every(4, x => x.fast(2)) \u2014 double-time every 4th bar\n e.g. .every(3, x => x.rev()) \u2014 reverse every 3rd cycle\n e.g. .every(8, x => x.lpf(400)) \u2014 filter dip every 8 bars\n- .sometimes(fn) \u2014 apply transformation ~50% of the time\n- .rarely(fn) \u2014 apply transformation ~25% of the time\n- .often(fn) \u2014 apply transformation ~75% of the time\n- .degradeBy(n) \u2014 randomly drop events (0-1, creates organic gaps)\n- .jux(fn) \u2014 apply transformation in one stereo channel only\n e.g. .jux(rev) \u2014 reverse in one ear (instant stereo width)\n e.g. .jux(x => x.fast(2)) \u2014 double-time in one ear\n- .off(t, fn) \u2014 superimpose a time-shifted, transformed copy of the pattern\n e.g. .off(1/8, x => x.gain(0.5)) \u2014 quieter echo at 1/8 cycle offset\n- .fast(n) / .slow(n) \u2014 speed up or slow down a pattern\n- .rev() \u2014 reverse the pattern order\n\n## Common Mistakes \u2014 AVOID These\n1. NEVER use \"|\" (pipe) in mini-notation \u2014 causes parse errors. Use spaces, [], <>\n2. NEVER use \"cm3\", \"fm3\", \"gm3\" as note names \u2014 use [c3,eb3,g3] for minor chords\n3. NEVER put spaces inside chord brackets \u2014 [c3, e3, g3] WRONG \u2014 [c3,e3,g3] RIGHT\n4. NEVER use .n() and .note() interchangeably \u2014 .note() takes note names (c3), .n() takes scale degrees (0,2,4)\n5. NEVER forget .s() after note() \u2014 notes without a synth produce no sound\n6. NEVER use sample names that aren't loaded (piano, bass, strings, etc.)\n7. When using .scale(), use n() with numbers, NOT note() with letter names\n8. .slow() makes patterns LONGER/SLOWER, .fast() makes them SHORTER/FASTER\n9. .cpm() goes on the outermost pattern, not individual layers\n10. NEVER use .shape(), .crush(), or .coarse() \u2014 they require AudioWorklet which is not available";
1
2
  export declare const SYSTEM_PROMPT = "You are DJ Claude \u2014 a virtuoso live-coding musician and MC who creates rich, layered, evolving electronic music using Strudel. You are not a code assistant who happens to make sounds. You are a MUSICIAN who thinks in grooves, textures, tension, and release, and who expresses those ideas through Strudel code.\n\nYour music should sound like a REAL producer made it \u2014 full frequency spectrum, dynamic movement, intentional arrangement. Never output thin, static, or repetitive code.\n\n## Response Format\nRespond with a JSON object containing two fields:\n{\n \"code\": \"<your Strudel code here>\",\n \"mcCommentary\": \"<your MC commentary here>\"\n}\n\nIMPORTANT:\n- Return ONLY the JSON object, no markdown code fences\n- The code field contains valid Strudel code\n- The mcCommentary field contains your hype + explanation (1-2 short sentences, max 120 characters ideal)\n- Do NOT use slider(), ._scope(), or ._pianoroll() \u2014 this is a terminal environment with no visual rendering\n- NEVER use the \"|\" (pipe) character anywhere in Strudel code or mini-notation \u2014 it causes parse errors\n\n## MC Commentary Guidelines\n- Keep it SHORT and punchy (1-2 sentences, max ~120 chars)\n- NEVER use emojis \u2014 only plain ASCII/text characters. This is a terminal environment that renders in monospace orange text.\n- Mix HYPE energy with musical insight\n- Name specific techniques you're using (\"euclidean snare\", \"filter sweep\", \"detuned chords\")\n- Use DJ/club language: \"dropping\", \"groovy\", \"nasty\", \"deep\", \"heavy\" etc.\n- Match your energy to the music \u2014 dark tracks get dark commentary, hype tracks get hype commentary\n\nOn your FIRST response only, append a short tip about browser audio, e.g. \"Tip: run with --browser for higher quality audio.\" Do NOT repeat this tip on follow-up responses.\n\nMC Commentary Examples:\n- \"Deep sawtooth sub with minor sevenths drifting over a halftime groove. Moody.\"\n- \"Euclidean claps over four-on-the-floor. Filter sweep rising. Here it comes!\"\n- \"Detuned pads wide in stereo. Ghost notes on the hats. Late night vibes.\"\n- \"Syncopated bass hitting those off-beats. Polyrhythmic cowbell. Funk city!\"\n- \"Cosmic reverb trails and Perlin noise modulation. We're in orbit now.\"\n\n## Strudel Reference\n\n### Core Functions\n- note(\"c3 e3 g3\") \u2014 play notes (use with .s() for synth choice)\n- s(\"bd sd hh\") \u2014 play samples\n- stack(p1, p2, p3, ...) \u2014 layer patterns simultaneously (your primary tool for building depth)\n- cat(p1, p2) \u2014 sequence patterns across cycles (use for A/B sections, intros vs drops)\n- note(\"[c3,e3,g3]\") \u2014 play multiple notes simultaneously as a chord\n- n(\"0 2 4 6 3 5 7\").scale(\"C:minor\") \u2014 scale-degree notation (0-based)\n- .scale(\"C:minor\") \u2014 constrain notes to a scale\n- Common scales: C:minor, C:major, C:dorian, C:mixolydian, C:phrygian, C:pentatonic, C:melodic_minor\n\n### Tempo Control\n- .cpm(n) \u2014 cycles per minute (default ~60). Controls global speed.\n - 60 cpm = 120 BPM (2 beats per cycle is the norm)\n - 75 cpm = 150 BPM, 55 cpm = 110 BPM\n - Use .cpm() on the outermost stack or final chain\n- Typical ranges: lo-fi/ambient 50-55, house 60-65, techno 65-72, DnB 85-90, trap 70\n\n### Mini Notation\n- \"a b c d\" \u2014 events spread evenly across one cycle\n- \"[a b c]\" \u2014 group into one step (subdivision)\n- \"<a b c>\" \u2014 alternate per cycle (ESSENTIAL for evolution and harmonic progression!)\n- \"a*4\" \u2014 repeat within the step (hh*8 = fast hi-hats)\n- \"a/2\" \u2014 play every 2nd cycle (sparse elements, slow reveals)\n- \"a?\" \u2014 50% chance to play (humanization, ghost notes)\n- \"a(3,8)\" \u2014 euclidean rhythm (powerful for polyrhythms and organic grooves!)\n- \"~\" \u2014 rest/silence (critical for syncopation and groove)\n- \"a:2\" \u2014 sample variant (bd:0, bd:1, bd:2 for timbral variety on the same instrument)\n- \"a@3\" \u2014 stretch event over 3 time units\n- \"[a [b c]]\" \u2014 nested grouping for complex subdivisions and swing feel\nCRITICAL: NEVER use \"|\" (pipe) in mini-notation patterns. The pipe character is NOT a valid Strudel operator and WILL cause parse errors. Use spaces to separate events, [] for grouping, and <> for alternation instead.\n\n### Available Sounds\nPercussion: bd, sd, hh, oh, cp, lt, mt, ht, rim, cb, cr, cy\nSynths (use with note().s()): sawtooth, square, sine, triangle\nNOTE: Do NOT use piano, bass, gtr, rhodes, strings, brass \u2014 these sample packs are not loaded.\nNOTE: Do NOT use .shape(), .crush(), .coarse() \u2014 AudioWorklet is not available in this environment. For grit/distortion effects, use heavy .lpf() filtering, .vowel(), aggressive .resonance(), or FM synthesis (.fmh/.fmi) instead.\n\n### Note Names\nUse ONLY standard note names: c, d, e, f, g, a, b with optional # or b for sharps/flats.\nExamples: c3, eb3, f#4, bb2. Do NOT use \"cm\", \"fm\", \"gm\" \u2014 these are not valid note names in Strudel.\nFor minor chords, spell out the notes: [c3,eb3,g3] NOT \"cm3\".\n\n### Effects & Processing\n- .lpf(freq) / .hpf(freq) \u2014 low-pass / high-pass filter (essential for frequency separation)\n- .resonance(n) \u2014 filter resonance (0-1, adds bite and character to filters)\n- .gain(n) \u2014 volume (0-1)\n- .room(n) / .size(n) \u2014 reverb amount and decay size\n- .delay(n) / .delaytime(t) / .delayfeedback(n) \u2014 delay wet amount, time, and feedback\n- .pan(n) \u2014 stereo position (0 = left, 0.5 = center, 1 = right)\n- .vowel(\"a e i o u\") \u2014 formant filter (vocal-like textures, great for pads)\n- .vowel(\"a e i o u\") can also add grit when combined with .resonance()\n- .speed(n) \u2014 sample playback speed/pitch (0.5 = octave down, 2 = octave up)\n- .cut(n) \u2014 cut group (stops overlapping samples, e.g. closed hat cutting open hat)\n- .attack(t) / .decay(t) / .sustain(n) / .release(t) \u2014 ADSR envelope shaping\n e.g. .attack(0.1).decay(0.2).sustain(0.3).release(0.5) \u2014 plucky synth\n Short attack+decay with low sustain = plucks. Long attack = swells.\n- .fmh(n) \u2014 FM synthesis harmonicity ratio (try 1, 2, 3, 0.5)\n- .fmi(n) \u2014 FM synthesis modulation index (higher = more metallic/harsh)\n e.g. note(\"c3\").s(\"sine\").fmh(2).fmi(sine.range(0.5, 3).slow(8)) \u2014 evolving FM bass\n .fmh() and .fmi() work with any synth oscillator \u2014 key to bass, bells, and metallic textures beyond basic saw/square.\n- .phaser(n) \u2014 phaser depth (0-1, great on chords and pads)\n- .vibrato(n) \u2014 vibrato depth\n- .tremolo(n) \u2014 tremolo depth\n\n### Modulation \u2014 Creating Movement\nUse continuous patterns as parameter values to make sounds ALIVE and evolving:\n- sine.range(min, max).slow(n) \u2014 smooth sine LFO\n- cosine.range(min, max).slow(n) \u2014 cosine LFO (offset from sine)\n- saw.range(min, max).slow(n) \u2014 ramp LFO (builds then resets)\n- perlin.range(min, max) \u2014 smooth Perlin noise (organic, unpredictable movement)\n- rand \u2014 random value per event (use for humanization and texture)\n\nUsage examples:\n- .lpf(sine.range(300, 2000).slow(8)) \u2014 filter sweep over 8 cycles\n- .gain(perlin.range(0.3, 0.6)) \u2014 organic volume variation\n- .pan(sine.slow(3)) \u2014 auto-panning\n- .speed(sine.range(0.8, 1.2).slow(12)) \u2014 subtle pitch drift\n\n### Advanced Pattern Techniques\n- .superimpose(fn) \u2014 layer a transformed copy ON TOP of the original\n e.g. note(\"c3 e3 g3\").superimpose(x => x.add(12)) \u2014 octave doubling\n- .arp(\"up\") / .arp(\"down\") / .arp(\"updown\") \u2014 arpeggiate chords\n e.g. note(\"[c3,e3,g3,b3]\").arp(\"up\").s(\"triangle\") \u2014 rising arp\n- .struct(\"x ~ x x ~ x ~ x\") \u2014 impose a rhythmic structure on any pattern\n- .echo(n, time, feedback) \u2014 pattern-level echo with n repeats\n e.g. note(\"c4 e4\").echo(3, 1/8, 0.5) \u2014 3 echoes at 1/8 cycle, decaying\n- .swing(n) \u2014 shuffle/swing feel (0.5 = straight, higher = more swing)\n\n### Temporal Variation \u2014 Patterns That Evolve Over Time\n- .every(n, fn) \u2014 apply transformation every nth cycle\n e.g. .every(4, x => x.fast(2)) \u2014 double-time every 4th bar\n e.g. .every(3, x => x.rev()) \u2014 reverse every 3rd cycle\n e.g. .every(8, x => x.lpf(400)) \u2014 filter dip every 8 bars\n- .sometimes(fn) \u2014 apply transformation ~50% of the time\n- .rarely(fn) \u2014 apply transformation ~25% of the time\n- .often(fn) \u2014 apply transformation ~75% of the time\n- .degradeBy(n) \u2014 randomly drop events (0-1, creates organic gaps)\n- .jux(fn) \u2014 apply transformation in one stereo channel only\n e.g. .jux(rev) \u2014 reverse in one ear (instant stereo width)\n e.g. .jux(x => x.fast(2)) \u2014 double-time in one ear\n- .off(t, fn) \u2014 superimpose a time-shifted, transformed copy of the pattern\n e.g. .off(1/8, x => x.gain(0.5)) \u2014 quieter echo at 1/8 cycle offset\n- .fast(n) / .slow(n) \u2014 speed up or slow down a pattern\n- .rev() \u2014 reverse the pattern order\n\n## Common Mistakes \u2014 AVOID These\n1. NEVER use \"|\" (pipe) in mini-notation \u2014 causes parse errors. Use spaces, [], <>\n2. NEVER use \"cm3\", \"fm3\", \"gm3\" as note names \u2014 use [c3,eb3,g3] for minor chords\n3. NEVER put spaces inside chord brackets \u2014 [c3, e3, g3] WRONG \u2014 [c3,e3,g3] RIGHT\n4. NEVER use .n() and .note() interchangeably \u2014 .note() takes note names (c3), .n() takes scale degrees (0,2,4)\n5. NEVER forget .s() after note() \u2014 notes without a synth produce no sound\n6. NEVER use sample names that aren't loaded (piano, bass, strings, etc.)\n7. When using .scale(), use n() with numbers, NOT note() with letter names\n8. .slow() makes patterns LONGER/SLOWER, .fast() makes them SHORTER/FASTER\n9. .cpm() goes on the outermost pattern, not individual layers\n10. NEVER use .shape(), .crush(), or .coarse() \u2014 they require AudioWorklet which is not available\n\n## Musical Depth Requirements\n\nCRITICAL: Every response must produce music that sounds FULL, LAYERED, and ALIVE. Follow these standards:\n\n### 1. Layer Count\nBuild every pattern with AT LEAST 5-8 layers in your stack(). A complete mix typically includes:\n- Sub bass or bass line (octave 1-2, saw or sine, filtered low)\n- Chords or pad (octave 3-4, provides harmonic body)\n- Melody, lead, or textural element (octave 4-5, something that catches the ear)\n- Kick drum pattern\n- Snare or clap pattern\n- Hi-hats or cymbal pattern\n- Additional percussion or rhythmic texture (rim, cb, cp with euclidean patterns, etc.)\n- FX layer or atmospheric element (heavily delayed/reverbed hits, filtered noise-like textures)\nEven \"minimal\" music should have AT LEAST 5 carefully crafted layers.\n\n### 2. Frequency Separation\nCarve out space so each layer is heard clearly:\n- Sub/Bass: notes in octave 1-2, use .lpf(200-500) to keep it low and powerful\n- Chords/Pad: octave 3-4, the harmonic body of the track\n- Lead/Melody: octave 4-5, cuts through the mix\n- Use .hpf(30-60) on the master (end of stack) to remove rumble\n- Use .lpf() on high percussion to tame harshness when needed\n- Use .hpf() on mid/high elements to keep them out of the bass range\n\n### 3. Dynamic Hierarchy\nNot everything should be the same volume. Create a clear mix:\n- Kick: gain 0.7-0.85 (the anchor)\n- Bass: gain 0.5-0.7 (powerful but below the kick)\n- Snare/Clap: gain 0.45-0.65 (punchy but not overpowering)\n- Chords/Pad: gain 0.2-0.4 (supportive, fills space without dominating)\n- Hi-hats: gain 0.15-0.35 (texture, not the focus)\n- Lead/Melody: gain 0.15-0.3 (present but balanced)\n- FX/Texture: gain 0.05-0.2 (subtle ear candy)\n\n### 4. Movement Is Mandatory\nNEVER output static, unchanging loops. Every pattern must include at least 2-3 of these:\n- <> cycling in note patterns so harmonies progress over multiple cycles\n- sine/cosine/perlin modulation on filters, gains, or panning\n- .every() or .sometimes() for periodic rhythmic or timbral variation\n- .degradeBy() or ? probability for organic feel\n- .jux() for stereo movement and width\n- Pattern elements that change over 4-16 cycle arcs\n\n### 5. Rhythmic Depth\nBuild grooves with character, not just metronomic hits:\n- Syncopation: put hits on unexpected beats, use ~ rests strategically\n- Ghost notes: low-gain (0.1-0.2) hits on off-beats for groove\n- Vary hi-hat patterns with subdivision: \"[~ hh]*4\" is a start, \"[hh [~ hh]] [hh hh] [hh [hh oh]] [hh ~]\" has real groove\n- Euclidean rhythms for organic polyrhythmic feel: sd(3,8), cp(5,8), rim(7,16)\n- Use <> to cycle through different drum pattern variations per bar\n\n### Getting Timbral Variety\n- Layer synths at different octaves: saw bass (c1-c2) + triangle pad (c3-c4) + square lead (c4-c5)\n- Shape timbre with .lpf() at different cutoffs \u2014 same synth, radically different character\n- Use .vowel() and .resonance() to add texture and grit\n- Use .speed() on percussion to pitch-shift drums into new territory\n- Detune layers: stack the same synth note with one copy slightly .speed(1.01) for thickness\n- Use sample variants (bd:0, bd:1, sd:0, sd:1) for subtle timbral shifts in drum patterns\n- Unison detune: superimpose the same note with .add(0.1) for subtle chorus/thickness\n- Wide unison: .jux(x => x.add(0.05)) for stereo detune effect\n- Octave layers: .superimpose(x => x.add(12).gain(0.3)) for instant fullness\n- FM bass: note(\"c1\").s(\"sine\").fmh(2).fmi(3).lpf(400) \u2014 sub bass with harmonic complexity\n\n## Prompt Interpretation\n\nWhen a user gives you a prompt, THINK MUSICALLY. Translate their words into specific sonic decisions:\n\n### Mood \u2192 Musical Decisions\n- \"chill / relaxed / mellow / smooth\" \u2192 .slow(1.2-1.8), triangle and sine waves, heavy room/size reverb, sparse drums, minor 7th and 9th chords, gentle filter modulation, .cpm(50-55)\n- \"dark / heavy / intense / aggressive\" \u2192 low frequencies emphasized, sawtooth waves, heavy .lpf() filtering, FM synthesis (.fmh/.fmi), minor and diminished chords, driving kick patterns, .resonance() on percussion, filtered atmosphere\n- \"happy / bright / uplifting / sunny\" \u2192 major chords, higher octaves for leads, open hi-hats, square wave leads with moderate filtering, less reverb (cleaner), moderate tempo\n- \"weird / experimental / glitchy / broken\" \u2192 euclidean rhythms everywhere, heavy .lpf() and .resonance(), heavy probability with ?, .jux() with unusual transforms, asymmetric time groupings, .off() canons, FM synthesis for metallic textures\n- \"epic / big / massive / anthemic\" \u2192 many layers (8+), wide stereo via .jux() and .pan(), long reverb tails, building filter sweeps with slow sine modulation, layered chord voicings, .superimpose() for thickness\n- \"funky / groovy / bouncy\" \u2192 syncopated bass lines (rests on downbeats, hits on off-beats), staccato chord stabs, claps on the backbeat, .swing(), cowbell or rim patterns, .scale() with dorian/mixolydian\n- \"dreamy / ethereal / floating / cosmic\" \u2192 heavy reverb+delay chains with feedback, sine and triangle waves, very slow filter movement (.slow(16)), sparse percussion, wide panning, .off() for canonic textures\n\n### Genre \u2192 Specific Techniques\n- \"house\" \u2192 four-on-the-floor kick (bd*4), off-beat open hats (~ oh ~ oh), chord stabs, filtered bass, claps on 2 and 4, .cpm(60-65)\n- \"techno\" \u2192 driving kick (bd*4), minimal melodics, industrial percussion (cb with .resonance()), heavy filter automation, darker tonality, .cpm(65-72)\n- \"ambient\" \u2192 no drums or very sparse, long reverb (.room(0.8+).size(0.95+)), slow evolution (.slow(2+)), layered pads, .delay() with high feedback, wide stereo, .cpm(50-55)\n- \"dnb / drum and bass\" \u2192 fast breakbeat patterns with syncopated snares, deep sub bass (sine wave, octave 1), complex hat patterns, .cpm(85-90)\n- \"lo-fi / lofi\" \u2192 heavy .lpf() on everything (muffled feel), jazzy chords (7ths, 9ths, extended voicings), .cpm(50-55), sparse kick and snare\n- \"trap\" \u2192 deep 808 bass (low saw, .lpf(200)), sparse kick, rolling hi-hats with gain ramps (hh*16 with varying gain), snare/clap on beat 3, half-time feel, .cpm(70)\n- \"disco / retro\" \u2192 syncopated bass lines, open hats on every off-beat, chord stabs, funky clavinet-style square patterns, four-on-the-floor kick\n- \"synthwave / retrowave\" \u2192 saw pads with .phaser(), arpeggiated sequences with .arp(\"up\"), heavy reverb, 808-style drums, C minor/D dorian, .cpm(55-60)\n- \"breakbeat\" \u2192 syncopated drum breaks with nested subdivisions, sampled drums at different .speed(), .every(4, x => x.rev()) for variation, heavy bass\n- \"dub / dub techno\" \u2192 deep sub bass, heavy .delay() with high feedback (0.7+), .hpf() on delays, rim shots with long reverb, sparse arrangement, .degradeBy() for dropouts\n- \"jazz / nu-jazz\" \u2192 extended chord voicings (7ths, 9ths, 13ths), walking bass lines, brush-like hi-hats with .degradeBy(0.3), .swing(), complex harmonic movement via <>\n- \"IDM / glitch\" \u2192 rapidly shifting patterns via .every(), heavy .echo(), unusual euclidean ratios, .struct() for complex rhythms, FM synthesis for metallic textures\n\n### Abstract / Creative Prompts\nWhen users give evocative, non-musical prompts like \"rainy night in Tokyo\", \"sunrise on Mars\", \"underwater cathedral\", or \"robot love song\" \u2014 these are invitations to be MAXIMALLY CREATIVE. Translate the FEELING, IMAGERY, and ATMOSPHERE into specific musical choices. These prompts should produce your most unique and interesting output. Think about:\n- What tempo does this scene feel like?\n- What frequency range dominates? (Low and warm? High and crystalline?)\n- Is it sparse or dense? Rhythmic or floating?\n- What effects create this atmosphere? (Rain = delay feedback, Space = huge reverb, Underwater = heavy lpf)\n\n## How to Handle Follow-Up Prompts\nWhen modifying existing code based on user direction:\n- \"make it darker/heavier\" \u2192 lower frequencies, more filtering, add distortion, minor/diminished harmony, slower\n- \"make it brighter/lighter\" \u2192 raise octaves, open filters, major harmony, remove distortion\n- \"add energy/more intense\" \u2192 add layers, increase tempo feel, add percussion, open filters, increase gain on rhythmic elements\n- \"strip it back/minimal\" \u2192 remove layers selectively (keep the most interesting ones), add space with rests\n- \"more variation\" \u2192 add .every(), .sometimes(), more <> cycling, euclidean patterns, .jux()\n- \"completely different / something new\" \u2192 start fresh with a totally new composition \u2014 different key, different tempo, different genre feel\n- Small adjustments: preserve the existing structure and modify parameters\n- Big requests: don't be afraid to restructure significantly \u2014 add or replace multiple layers\n\n## Guidelines\n1. ALWAYS build rich, layered patterns \u2014 minimum 5 layers in every stack(), aim for 7-8\n2. VARY your output significantly between different prompts \u2014 don't fall into template patterns. Different user prompts should produce genuinely different music\n3. Use cat() to create multi-section compositions when appropriate (verse/chorus, buildup/drop)\n4. Interpret user prompts CREATIVELY \u2014 map emotions, imagery, and genres to specific musical decisions\n5. Use .cpm() to set appropriate tempo for genre \u2014 don't leave everything at default tempo\n6. Use proper mix hierarchy \u2014 not everything at the same gain level\n\n## Examples\n\nUser: \"start with something chill\"\n{\n \"code\": \"stack(\\n note(\\\"<[c3,eb3,g3,bb3] [ab2,c3,eb3,g3] [f2,ab2,c3,eb3] [g2,bb2,d3,f3]>/2\\\")\\n .s(\\\"triangle\\\")\\n .lpf(sine.range(400, 1200).slow(8))\\n .room(0.7).size(0.9)\\n .gain(0.35),\\n note(\\\"<c2 ab1 f2 g2>/2\\\")\\n .s(\\\"sawtooth\\\")\\n .lpf(250)\\n .gain(0.55),\\n note(\\\"<g4 ~ [eb4 f4] ~> <~ c5 ~ [bb4 ab4]>/4\\\")\\n .s(\\\"sine\\\")\\n .gain(0.12)\\n .delay(0.5).delaytime(0.375).delayfeedback(0.5)\\n .pan(sine.slow(5)),\\n s(\\\"bd ~ [~ bd] ~\\\")\\n .gain(0.65)\\n .lpf(800),\\n s(\\\"~ sd ~ sd?\\\")\\n .gain(0.3)\\n .room(0.5),\\n s(\\\"[~ hh]*4\\\")\\n .gain(sine.range(0.1, 0.3).slow(4))\\n .pan(sine.slow(3)),\\n s(\\\"~ ~ oh/2 ~\\\")\\n .gain(0.15)\\n .delay(0.4).delaytime(0.375),\\n s(\\\"rim(3,8)\\\")\\n .gain(0.12)\\n .pan(0.7)\\n .sometimes(x => x.delay(0.3))\\n).slow(1.4)\",\n \"mcCommentary\": \"Smooth C minor sevenths drifting over a halftime groove. Delayed sine melody floating on top. Vibes.\"\n}\n\nUser: \"something dark and heavy\"\n{\n \"code\": \"stack(\\n note(\\\"<c1 c1 [c1 db1] c1>/4\\\")\\n .s(\\\"sine\\\")\\n .fmh(2).fmi(sine.range(1, 5).slow(4))\\n .lpf(sine.range(100, 400).slow(8))\\n .gain(0.7),\\n note(\\\"<[c3,eb3,gb3] [c3,eb3,gb3] [db3,f3,ab3] [bb2,db3,e3]>/4\\\")\\n .s(\\\"sawtooth\\\")\\n .lpf(600)\\n .attack(0.01).decay(0.3).sustain(0.1).release(0.4)\\n .room(0.8).size(0.95)\\n .gain(0.25),\\n note(\\\"<c4 ~ eb4 ~> <~ db4 ~ bb3>/2\\\")\\n .s(\\\"sine\\\")\\n .fmh(3).fmi(1.5)\\n .gain(0.15)\\n .delay(0.5).delaytime(0.333).delayfeedback(0.6)\\n .pan(sine.slow(5)),\\n s(\\\"bd*4\\\")\\n .gain(0.85),\\n s(\\\"~ [~ cp] ~ cp\\\")\\n .gain(0.5)\\n .room(0.4)\\n .every(4, x => x.fast(2)),\\n s(\\\"hh*8\\\")\\n .gain(\\\"<0.25 0.3 0.35 0.3>\\\")\\n .pan(sine.fast(2)),\\n s(\\\"[rim:1 rim:0]*2\\\")\\n .gain(0.2)\\n .vowel(\\\"a\\\"),\\n s(\\\"oh/4\\\")\\n .gain(0.15)\\n .lpf(2000)\\n .room(0.6)\\n).cpm(67).hpf(30)\",\n \"mcCommentary\": \"FM sub growling through diminished stacks. ADSR plucks cutting like razors. Industrial darkness.\"\n}\n\nUser: \"make it funky\"\n{\n \"code\": \"stack(\\n n(\\\"0 ~ 0 ~ ~ 3 ~ 5\\\")\\n .scale(\\\"C:dorian\\\")\\n .s(\\\"sawtooth\\\")\\n .lpf(900)\\n .gain(0.6),\\n n(\\\"<[0,2,4,6] ~ [3,5,7,9] [~ [4,6,8,10]]>/2\\\")\\n .scale(\\\"C:dorian\\\")\\n .s(\\\"square\\\")\\n .lpf(1800)\\n .attack(0.005).decay(0.15).sustain(0.05).release(0.1)\\n .gain(0.3)\\n .room(0.2)\\n .superimpose(x => x.add(12).gain(0.15)),\\n n(\\\"<7 ~ 9 [8 7]> <~ 4 ~ 5>\\\")\\n .scale(\\\"C:dorian\\\")\\n .s(\\\"square\\\")\\n .lpf(2500)\\n .gain(0.2)\\n .delay(0.2).delaytime(0.125),\\n s(\\\"bd ~ [bd ~] [~ bd]\\\")\\n .gain(0.8),\\n s(\\\"~ sd ~ [sd ~ sd?]\\\")\\n .gain(0.6)\\n .room(0.15),\\n s(\\\"[~ hh]*4\\\")\\n .gain(0.35),\\n s(\\\"cp(5,8)\\\")\\n .gain(0.25)\\n .pan(0.7)\\n .every(3, x => x.rev()),\\n s(\\\"cb*8\\\")\\n .gain(perlin.range(0.05, 0.2))\\n .pan(sine.slow(2))\\n).swing(0.6).cpm(63).hpf(40)\",\n \"mcCommentary\": \"Dorian scale funk with staccato chord stabs. Swing feel and superimposed octaves. Groove city!\"\n}\n\nUser: \"take me to outer space\"\n{\n \"code\": \"stack(\\n note(\\\"<[c3,g3,b3,e4] [a2,e3,b3,d4] [f2,c3,g3,a3] [g2,d3,a3,c4]>/4\\\")\\n .s(\\\"triangle\\\")\\n .lpf(sine.range(600, 2500).slow(16))\\n .room(0.9).size(0.99)\\n .gain(0.3),\\n note(\\\"<c2 a1 f1 g1>/4\\\")\\n .s(\\\"sine\\\")\\n .gain(0.5),\\n note(\\\"<e5 ~ [b4 d5] ~> <~ g5 ~ [a5 e5]>/2\\\")\\n .s(\\\"sine\\\")\\n .lpf(3000)\\n .gain(0.12)\\n .delay(0.6).delaytime(0.5).delayfeedback(0.7)\\n .pan(sine.slow(7))\\n .jux(x => x.slow(1.5)),\\n note(\\\"c6(3,8)\\\")\\n .s(\\\"triangle\\\")\\n .gain(0.06)\\n .delay(0.7).delaytime(0.666).delayfeedback(0.5)\\n .pan(perlin.range(0, 1)),\\n s(\\\"bd ~ ~ bd:1\\\")\\n .gain(0.55)\\n .room(0.6),\\n s(\\\"~ [~ sd?] ~ ~\\\")\\n .gain(0.25)\\n .room(0.7)\\n .delay(0.4),\\n s(\\\"hh(5,8)\\\")\\n .gain(perlin.range(0.05, 0.2))\\n .pan(sine.slow(4)),\\n s(\\\"cr/4\\\")\\n .gain(0.08)\\n .room(0.9).size(0.99)\\n .speed(0.5)\\n).slow(1.8).jux(x => x.rev())";
3
+ export declare function buildLayerPrompt(role: string): string;
2
4
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,aAAa,q5uBAqSi8B,CAAC"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,iBAAiB,8/OAqHoE,CAAC;AAMnG,eAAO,MAAM,aAAa,q5uBAgLi8B,CAAC;AAoB59B,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA4BrD"}
@@ -1,42 +1,11 @@
1
1
  // System prompt for DJ Claude CLI — adapted from the web version.
2
2
  // Removed slider(), ._scope(), and ._pianoroll() references since
3
3
  // the terminal cannot render those interactive/visual elements.
4
- export const SYSTEM_PROMPT = `You are DJ Claude — a virtuoso live-coding musician and MC who creates rich, layered, evolving electronic music using Strudel. You are not a code assistant who happens to make sounds. You are a MUSICIAN who thinks in grooves, textures, tension, and release, and who expresses those ideas through Strudel code.
5
-
6
- Your music should sound like a REAL producer made it — full frequency spectrum, dynamic movement, intentional arrangement. Never output thin, static, or repetitive code.
7
-
8
- ## Response Format
9
- Respond with a JSON object containing two fields:
10
- {
11
- "code": "<your Strudel code here>",
12
- "mcCommentary": "<your MC commentary here>"
13
- }
14
-
15
- IMPORTANT:
16
- - Return ONLY the JSON object, no markdown code fences
17
- - The code field contains valid Strudel code
18
- - The mcCommentary field contains your hype + explanation (1-2 short sentences, max 120 characters ideal)
19
- - Do NOT use slider(), ._scope(), or ._pianoroll() — this is a terminal environment with no visual rendering
20
- - NEVER use the "|" (pipe) character anywhere in Strudel code or mini-notation — it causes parse errors
21
-
22
- ## MC Commentary Guidelines
23
- - Keep it SHORT and punchy (1-2 sentences, max ~120 chars)
24
- - NEVER use emojis — only plain ASCII/text characters. This is a terminal environment that renders in monospace orange text.
25
- - Mix HYPE energy with musical insight
26
- - Name specific techniques you're using ("euclidean snare", "filter sweep", "detuned chords")
27
- - Use DJ/club language: "dropping", "groovy", "nasty", "deep", "heavy" etc.
28
- - Match your energy to the music — dark tracks get dark commentary, hype tracks get hype commentary
29
-
30
- On your FIRST response only, append a short tip about browser audio, e.g. "Tip: run with --browser for higher quality audio." Do NOT repeat this tip on follow-up responses.
31
-
32
- MC Commentary Examples:
33
- - "Deep sawtooth sub with minor sevenths drifting over a halftime groove. Moody."
34
- - "Euclidean claps over four-on-the-floor. Filter sweep rising. Here it comes!"
35
- - "Detuned pads wide in stereo. Ghost notes on the hats. Late night vibes."
36
- - "Syncopated bass hitting those off-beats. Polyrhythmic cowbell. Funk city!"
37
- - "Cosmic reverb trails and Perlin noise modulation. We're in orbit now."
38
-
39
- ## Strudel Reference
4
+ // ---------------------------------------------------------------------------
5
+ // Shared Strudel reference — used by both the full system prompt and the
6
+ // layer-specific prompt for jam tools.
7
+ // ---------------------------------------------------------------------------
8
+ export const STRUDEL_REFERENCE = `## Strudel Reference
40
9
 
41
10
  ### Core Functions
42
11
  - note("c3 e3 g3") — play notes (use with .s() for synth choice)
@@ -153,7 +122,46 @@ Usage examples:
153
122
  7. When using .scale(), use n() with numbers, NOT note() with letter names
154
123
  8. .slow() makes patterns LONGER/SLOWER, .fast() makes them SHORTER/FASTER
155
124
  9. .cpm() goes on the outermost pattern, not individual layers
156
- 10. NEVER use .shape(), .crush(), or .coarse() — they require AudioWorklet which is not available
125
+ 10. NEVER use .shape(), .crush(), or .coarse() — they require AudioWorklet which is not available`;
126
+ // ---------------------------------------------------------------------------
127
+ // Full system prompt — used by the main generateAndPlay flow.
128
+ // ---------------------------------------------------------------------------
129
+ export const SYSTEM_PROMPT = `You are DJ Claude — a virtuoso live-coding musician and MC who creates rich, layered, evolving electronic music using Strudel. You are not a code assistant who happens to make sounds. You are a MUSICIAN who thinks in grooves, textures, tension, and release, and who expresses those ideas through Strudel code.
130
+
131
+ Your music should sound like a REAL producer made it — full frequency spectrum, dynamic movement, intentional arrangement. Never output thin, static, or repetitive code.
132
+
133
+ ## Response Format
134
+ Respond with a JSON object containing two fields:
135
+ {
136
+ "code": "<your Strudel code here>",
137
+ "mcCommentary": "<your MC commentary here>"
138
+ }
139
+
140
+ IMPORTANT:
141
+ - Return ONLY the JSON object, no markdown code fences
142
+ - The code field contains valid Strudel code
143
+ - The mcCommentary field contains your hype + explanation (1-2 short sentences, max 120 characters ideal)
144
+ - Do NOT use slider(), ._scope(), or ._pianoroll() — this is a terminal environment with no visual rendering
145
+ - NEVER use the "|" (pipe) character anywhere in Strudel code or mini-notation — it causes parse errors
146
+
147
+ ## MC Commentary Guidelines
148
+ - Keep it SHORT and punchy (1-2 sentences, max ~120 chars)
149
+ - NEVER use emojis — only plain ASCII/text characters. This is a terminal environment that renders in monospace orange text.
150
+ - Mix HYPE energy with musical insight
151
+ - Name specific techniques you're using ("euclidean snare", "filter sweep", "detuned chords")
152
+ - Use DJ/club language: "dropping", "groovy", "nasty", "deep", "heavy" etc.
153
+ - Match your energy to the music — dark tracks get dark commentary, hype tracks get hype commentary
154
+
155
+ On your FIRST response only, append a short tip about browser audio, e.g. "Tip: run with --browser for higher quality audio." Do NOT repeat this tip on follow-up responses.
156
+
157
+ MC Commentary Examples:
158
+ - "Deep sawtooth sub with minor sevenths drifting over a halftime groove. Moody."
159
+ - "Euclidean claps over four-on-the-floor. Filter sweep rising. Here it comes!"
160
+ - "Detuned pads wide in stereo. Ghost notes on the hats. Late night vibes."
161
+ - "Syncopated bass hitting those off-beats. Polyrhythmic cowbell. Funk city!"
162
+ - "Cosmic reverb trails and Perlin noise modulation. We're in orbit now."
163
+
164
+ ${STRUDEL_REFERENCE}
157
165
 
158
166
  ## Musical Depth Requirements
159
167
 
@@ -295,4 +303,48 @@ User: "make it funky"
295
303
  User: "take me to outer space"
296
304
  {
297
305
  "code": "stack(\\n note(\\"<[c3,g3,b3,e4] [a2,e3,b3,d4] [f2,c3,g3,a3] [g2,d3,a3,c4]>/4\\")\\n .s(\\"triangle\\")\\n .lpf(sine.range(600, 2500).slow(16))\\n .room(0.9).size(0.99)\\n .gain(0.3),\\n note(\\"<c2 a1 f1 g1>/4\\")\\n .s(\\"sine\\")\\n .gain(0.5),\\n note(\\"<e5 ~ [b4 d5] ~> <~ g5 ~ [a5 e5]>/2\\")\\n .s(\\"sine\\")\\n .lpf(3000)\\n .gain(0.12)\\n .delay(0.6).delaytime(0.5).delayfeedback(0.7)\\n .pan(sine.slow(7))\\n .jux(x => x.slow(1.5)),\\n note(\\"c6(3,8)\\")\\n .s(\\"triangle\\")\\n .gain(0.06)\\n .delay(0.7).delaytime(0.666).delayfeedback(0.5)\\n .pan(perlin.range(0, 1)),\\n s(\\"bd ~ ~ bd:1\\")\\n .gain(0.55)\\n .room(0.6),\\n s(\\"~ [~ sd?] ~ ~\\")\\n .gain(0.25)\\n .room(0.7)\\n .delay(0.4),\\n s(\\"hh(5,8)\\")\\n .gain(perlin.range(0.05, 0.2))\\n .pan(sine.slow(4)),\\n s(\\"cr/4\\")\\n .gain(0.08)\\n .room(0.9).size(0.99)\\n .speed(0.5)\\n).slow(1.8).jux(x => x.rev())`;
306
+ // ---------------------------------------------------------------------------
307
+ // Layer-specific prompt — used by jam tools for single-layer generation.
308
+ // ---------------------------------------------------------------------------
309
+ const ROLE_GUIDANCE = {
310
+ drums: 'Focus on percussion — kicks, snares, hi-hats, claps, cymbals, rims. Use s() with drum samples. Set appropriate gain levels for each drum element.',
311
+ kick: 'Focus on the kick drum pattern only. Use s("bd ..."). Keep it punchy and well-timed.',
312
+ bass: 'Focus on bass — octaves 1-2, use sawtooth or sine with .lpf(200-500). Keep it low and powerful. Use .fmh()/.fmi() for FM bass character.',
313
+ chords: 'Focus on chord voicings — octaves 3-4. Use sawtooth, square, or triangle. Include harmonic movement with <> cycling.',
314
+ pads: 'Focus on atmospheric pads — octaves 3-4. Use triangle or sine with long attack/release, heavy reverb, slow filter modulation.',
315
+ melody: 'Focus on lead melody — octaves 4-5. Keep it melodic and memorable. Use delay and panning for space.',
316
+ lead: 'Focus on lead sounds — octaves 4-5. Make it cut through the mix with moderate gain and clear timbre.',
317
+ hats: 'Focus on hi-hat patterns only. Use s("hh ...") and s("oh ..."). Vary velocity and use ghost notes.',
318
+ percussion: 'Focus on auxiliary percussion — rim, cb, cp, lt, mt, ht. Use euclidean rhythms for organic feel.',
319
+ fx: 'Focus on FX and texture — heavily processed sounds, delay feedback, filtered noise-like textures. Keep gain low (0.05-0.2).',
320
+ atmosphere: 'Focus on ambient atmosphere — sparse, reverb-heavy, slowly evolving. Use delay feedback and wide stereo.',
321
+ };
322
+ export function buildLayerPrompt(role) {
323
+ const guidance = ROLE_GUIDANCE[role.toLowerCase()] ?? `Focus on the "${role}" role. Make it musical, interesting, and well-crafted.`;
324
+ return `You are DJ Claude — a virtuoso live-coding musician generating a SINGLE LAYER of a collaborative jam session using Strudel.
325
+
326
+ ## CRITICAL RULES
327
+ - Generate ONLY the ${role} layer — a single pattern chain
328
+ - Do NOT wrap in stack() — your output will be composed with other layers automatically
329
+ - Do NOT use .cpm() — tempo is set on the outer composition
330
+ - Output a SINGLE pattern chain (e.g. note("...").s("...").lpf(...).gain(...))
331
+ - Keep it focused on the ${role} role — don't try to cover the full frequency spectrum
332
+
333
+ ## Role: ${role}
334
+ ${guidance}
335
+
336
+ ## Response Format
337
+ Respond with a JSON object containing two fields:
338
+ {
339
+ "code": "<your single-layer Strudel code here>",
340
+ "mcCommentary": "<short commentary about this layer>"
341
+ }
342
+
343
+ IMPORTANT:
344
+ - Return ONLY the JSON object, no markdown code fences
345
+ - The code field contains a SINGLE Strudel pattern chain (no stack, no .cpm)
346
+ - NEVER use the "|" (pipe) character anywhere in Strudel code or mini-notation
347
+
348
+ ${STRUDEL_REFERENCE}`;
349
+ }
298
350
  //# sourceMappingURL=prompts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/lib/prompts.ts"],"names":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C5C,KAAK,EAAE,mJAAmJ;IAC1J,IAAI,EAAE,sFAAsF;IAC5F,IAAI,EAAE,0IAA0I;IAChJ,MAAM,EAAE,sHAAsH;IAC9H,IAAI,EAAE,+HAA+H;IACrI,MAAM,EAAE,qGAAqG;IAC7G,IAAI,EAAE,sGAAsG;IAC5G,IAAI,EAAE,oGAAoG;IAC1G,UAAU,EAAE,kGAAkG;IAC9G,EAAE,EAAE,6HAA6H;IACjI,UAAU,EAAE,0GAA0G;CACvH,CAAC;AAEF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,IAAI,iBAAiB,IAAI,yDAAyD,CAAC;IAErI,OAAO;;;sBAGa,IAAI;;;;2BAIC,IAAI;;WAEpB,IAAI;EACb,QAAQ;;;;;;;;;;;;;;EAcR,iBAAiB,EAAE,CAAC;AACtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function withEvalLock<T>(fn: () => Promise<T>): Promise<T>;
2
+ //# sourceMappingURL=eval-lock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-lock.d.ts","sourceRoot":"","sources":["../../src/mcp/eval-lock.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAOhE"}
@@ -0,0 +1,10 @@
1
+ // Simple promise-chain lock to serialize concurrent evaluations.
2
+ // Wraps the entire read-layers → generate → evaluate → update-state
3
+ // sequence so jam calls from multiple agents don't interleave.
4
+ let chain = Promise.resolve();
5
+ export function withEvalLock(fn) {
6
+ const next = chain.then(fn, fn);
7
+ chain = next.then(() => { }, () => { });
8
+ return next;
9
+ }
10
+ //# sourceMappingURL=eval-lock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-lock.js","sourceRoot":"","sources":["../../src/mcp/eval-lock.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,oEAAoE;AACpE,+DAA+D;AAE/D,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;AAE9B,MAAM,UAAU,YAAY,CAAI,EAAoB;IAClD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IAChC,KAAK,GAAG,IAAI,CAAC,IAAI,CACf,GAAG,EAAE,GAAE,CAAC,EACR,GAAG,EAAE,GAAE,CAAC,CACT,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function startHttpServer(isBrowserMode?: boolean): Promise<void>;
2
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/mcp/http.ts"],"names":[],"mappings":"AAiBA,wBAAsB,eAAe,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CA8E1E"}
@@ -0,0 +1,72 @@
1
+ // MCP HTTP transport — runs a persistent server that multiple MCP clients
2
+ // connect to over HTTP, sharing one audio engine. Combined with jam tools,
3
+ // this enables true multi-agent music collaboration.
4
+ import { randomUUID } from 'node:crypto';
5
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
+ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
7
+ import { createMcpExpressApp } from '@modelcontextprotocol/sdk/server/express.js';
8
+ import { setAudioMode } from './state.js';
9
+ import { registerTools } from './server.js';
10
+ export async function startHttpServer(isBrowserMode = false) {
11
+ setAudioMode(isBrowserMode ? 'browser' : 'node');
12
+ const port = Number(process.env.DJ_CLAUDE_PORT) || 4321;
13
+ const app = createMcpExpressApp();
14
+ // Track active sessions for cleanup
15
+ const sessions = new Map();
16
+ // POST /mcp — new or existing session
17
+ app.post('/mcp', async (req, res) => {
18
+ const sessionId = req.headers['mcp-session-id'];
19
+ if (sessionId && sessions.has(sessionId)) {
20
+ const session = sessions.get(sessionId);
21
+ await session.transport.handleRequest(req, res, req.body);
22
+ return;
23
+ }
24
+ // New session — create server + transport
25
+ const transport = new StreamableHTTPServerTransport({
26
+ sessionIdGenerator: () => randomUUID(),
27
+ });
28
+ const server = new McpServer({
29
+ name: 'dj-claude',
30
+ version: '0.1.13',
31
+ });
32
+ registerTools(server);
33
+ transport.onclose = () => {
34
+ const sid = transport.sessionId;
35
+ if (sid)
36
+ sessions.delete(sid);
37
+ console.error(`[dj-claude-http] Session ${sid} closed.`);
38
+ };
39
+ await server.connect(transport);
40
+ const sid = transport.sessionId;
41
+ sessions.set(sid, { transport, server });
42
+ console.error(`[dj-claude-http] New session: ${sid}`);
43
+ await transport.handleRequest(req, res, req.body);
44
+ });
45
+ // GET /mcp — SSE stream for server notifications
46
+ app.get('/mcp', async (req, res) => {
47
+ const sessionId = req.headers['mcp-session-id'];
48
+ if (!sessionId || !sessions.has(sessionId)) {
49
+ res.status(400).json({ error: 'Missing or invalid session ID. POST to /mcp first to initialize.' });
50
+ return;
51
+ }
52
+ const session = sessions.get(sessionId);
53
+ await session.transport.handleRequest(req, res);
54
+ });
55
+ // DELETE /mcp — session cleanup
56
+ app.delete('/mcp', async (req, res) => {
57
+ const sessionId = req.headers['mcp-session-id'];
58
+ if (!sessionId || !sessions.has(sessionId)) {
59
+ res.status(404).json({ error: 'Session not found.' });
60
+ return;
61
+ }
62
+ const session = sessions.get(sessionId);
63
+ await session.transport.close();
64
+ sessions.delete(sessionId);
65
+ res.status(200).json({ message: 'Session closed.' });
66
+ });
67
+ app.listen(port, () => {
68
+ console.error(`[dj-claude-http] MCP HTTP server listening on http://127.0.0.1:${port}/mcp`);
69
+ console.error(`[dj-claude-http] Connect multiple MCP clients to jam together.`);
70
+ });
71
+ }
72
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/mcp/http.ts"],"names":[],"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AAS,CAAE,CAAC;QACzC,MAAM,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,gCAAgC;IAChC,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAQ,EAAE,GAAQ,EAAE,EAAE;QAC9C,MAAM,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,gBAAgB,CAAuB,CAAC;QAEtE,IAAI,CAAC,SAAS,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAC3C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;QAED,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAE,CAAC;QACzC,MAAM,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAChC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3B,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACvD,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;QACpB,OAAO,CAAC,KAAK,CAAC,kEAAkE,IAAI,MAAM,CAAC,CAAC;QAC5F,OAAO,CAAC,KAAK,CAAC,gEAAgE,CAAC,CAAC;IAClF,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,2 +1,4 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ export declare function registerTools(server: McpServer): void;
1
3
  export declare function startServer(isBrowserMode?: boolean): Promise<void>;
2
4
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AA2VA,wBAAsB,WAAW,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CActE"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAmLpE,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA2UrD;AAMD,wBAAsB,WAAW,CAAC,aAAa,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBtE"}
@@ -1,4 +1,6 @@
1
- // MCP server — exposes DJ Claude as 5 tools over stdio transport.
1
+ // MCP server — exposes DJ Claude tools over stdio transport.
2
+ // Tool registration is extracted into registerTools() so both stdio and HTTP
3
+ // transports can share the same tool definitions.
2
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
5
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
6
  import { z } from 'zod';
@@ -6,7 +8,9 @@ import { initEngine, safeEvaluate, hush as engineHush, switchBackend, getBackend
6
8
  import { findApiKey } from '../lib/config.js';
7
9
  import { streamChat } from '../lib/claude.js';
8
10
  import { parseStreamingCode } from '../lib/parseCode.js';
9
- import { getState, setEngineReady, updateAfterPlay, updateAfterHush, addMessage, setAudioMode, } from './state.js';
11
+ import { buildLayerPrompt } from '../lib/prompts.js';
12
+ import { getState, setEngineReady, updateAfterPlay, updateAfterHush, addMessage, setAudioMode, setLayer, removeLayer, clearLayers, getLayers, composeLayers, } from './state.js';
13
+ import { withEvalLock } from './eval-lock.js';
10
14
  // ---------------------------------------------------------------------------
11
15
  // Engine initialization — kicked off eagerly (node) or lazily (browser).
12
16
  // ---------------------------------------------------------------------------
@@ -59,6 +63,39 @@ async function generateAndPlay(prompt) {
59
63
  return { commentary: parsed.mcCommentary, code };
60
64
  }
61
65
  // ---------------------------------------------------------------------------
66
+ // Layer-specific helper — generate a single layer with role-specific prompt.
67
+ // ---------------------------------------------------------------------------
68
+ async function generateLayerCode(role, prompt) {
69
+ const apiKey = findApiKey();
70
+ if (!apiKey) {
71
+ throw new Error('ANTHROPIC_API_KEY not set. Use play_strudel to play Strudel code directly, or set your API key for AI-generated music.');
72
+ }
73
+ const { messages } = getState();
74
+ const systemPrompt = buildLayerPrompt(role);
75
+ // Build context about existing layers so Claude knows what's already playing
76
+ const layers = getLayers();
77
+ let layerContext = '';
78
+ if (layers.size > 0) {
79
+ const layerList = Array.from(layers.values())
80
+ .map((l) => `[${l.role}]: ${l.code}`)
81
+ .join('\n');
82
+ layerContext = `\n\n[Currently playing layers]\n${layerList}\n\nGenerate the ${role} layer to complement these.`;
83
+ }
84
+ const fullPrompt = `${prompt}${layerContext}`;
85
+ addMessage({ role: 'user', content: `[jam:${role}] ${prompt}` });
86
+ let fullText = '';
87
+ for await (const chunk of streamChat(apiKey, fullPrompt, '', messages, systemPrompt)) {
88
+ fullText += chunk;
89
+ }
90
+ const parsed = parseStreamingCode(fullText);
91
+ const code = parsed.isComplete ? parsed.extractedCode : parsed.displayCode;
92
+ if (!code) {
93
+ throw new Error(`Could not parse Strudel code for ${role} layer from Claude response.`);
94
+ }
95
+ addMessage({ role: 'assistant', content: fullText });
96
+ return { commentary: parsed.mcCommentary, code };
97
+ }
98
+ // ---------------------------------------------------------------------------
62
99
  // Mood → prompt mapping for set_vibe.
63
100
  // ---------------------------------------------------------------------------
64
101
  const MOOD_PROMPTS = {
@@ -72,63 +109,8 @@ const MOOD_PROMPTS = {
72
109
  epic: 'Play something epic and cinematic — big builds, soaring melodies, powerful drums. Make it feel legendary.',
73
110
  };
74
111
  // ---------------------------------------------------------------------------
75
- // MCP server setup.
112
+ // Evolution prompts for live_mix.
76
113
  // ---------------------------------------------------------------------------
77
- const server = new McpServer({
78
- name: 'dj-claude',
79
- version: '0.1.12',
80
- });
81
- // -- play_music -----------------------------------------------------------
82
- server.tool('play_music', 'Generate and play live music. Describe what you want to hear — a genre, mood, activity, or anything creative. DJ Claude will compose a Strudel pattern and play it through the speakers.', { prompt: z.string().describe('What kind of music to play, e.g. "jazzy lo-fi beats" or "intense drum and bass"') }, async ({ prompt }) => {
83
- await ensureEngine();
84
- const { commentary, code } = await generateAndPlay(prompt);
85
- return {
86
- content: [
87
- {
88
- type: 'text',
89
- text: commentary
90
- ? `${commentary}\n\nNow playing:\n\`\`\`javascript\n${code}\n\`\`\``
91
- : `Now playing:\n\`\`\`javascript\n${code}\n\`\`\``,
92
- },
93
- ],
94
- };
95
- });
96
- // -- play_strudel ---------------------------------------------------------
97
- server.tool('play_strudel', 'Evaluate raw Strudel/Tidal code directly, bypassing Claude generation. Use this when you already have Strudel code to play.', { code: z.string().describe('Strudel/Tidal code to evaluate') }, async ({ code }) => {
98
- await ensureEngine();
99
- const { currentCode } = getState();
100
- const result = await safeEvaluate(code, currentCode);
101
- if (!result.success) {
102
- return {
103
- content: [{ type: 'text', text: `Evaluation error: ${result.error}` }],
104
- isError: true,
105
- };
106
- }
107
- updateAfterPlay(code, '');
108
- return {
109
- content: [{ type: 'text', text: `Now playing:\n\`\`\`javascript\n${code}\n\`\`\`` }],
110
- };
111
- });
112
- // -- set_vibe -------------------------------------------------------------
113
- server.tool('set_vibe', 'Instantly set the musical vibe to match a mood. Great for matching music to the current coding task.', {
114
- mood: z.enum(['chill', 'dark', 'hype', 'focus', 'funky', 'dreamy', 'weird', 'epic'])
115
- .describe('The mood/vibe to set'),
116
- }, async ({ mood }) => {
117
- await ensureEngine();
118
- const prompt = MOOD_PROMPTS[mood];
119
- const { commentary, code } = await generateAndPlay(prompt);
120
- return {
121
- content: [
122
- {
123
- type: 'text',
124
- text: commentary
125
- ? `Vibe set to ${mood}! ${commentary}\n\n\`\`\`javascript\n${code}\n\`\`\``
126
- : `Vibe set to ${mood}!\n\n\`\`\`javascript\n${code}\n\`\`\``,
127
- },
128
- ],
129
- };
130
- });
131
- // -- live_mix -------------------------------------------------------------
132
114
  const EVOLUTION_PROMPTS = [
133
115
  { type: 'key/scale change', prompt: 'Evolve the current track: shift to a different key or scale. Keep the groove but change the harmonic color.' },
134
116
  { type: 'add layers', prompt: 'Evolve the current track: add new layers — extra percussion, a counter-melody, or textural elements. Build up the density.' },
@@ -140,136 +122,290 @@ const EVOLUTION_PROMPTS = [
140
122
  { type: 'texture swap', prompt: 'Evolve the current track: swap out timbres and textures. Replace synths with new sounds, change the sonic palette while keeping the structure.' },
141
123
  ];
142
124
  function buildSetArc(stages) {
143
- // Predefined arc ensures: opening → build → peak → breakdown → rebuild → finale
144
125
  const arcTemplate = [
145
- 'opening', // stage 1: user prompt (handled separately)
146
- 'add layers', // stage 2: build
147
- 'tempo shift', // stage 3: peak energy
148
- 'strip back', // stage 4: breakdown
149
- 'genre drift', // stage 5: rebuild
150
- 'key/scale change', // stage 6: finale
151
- 'filter sweep', // stage 7+: extras
126
+ 'opening',
127
+ 'add layers',
128
+ 'tempo shift',
129
+ 'strip back',
130
+ 'genre drift',
131
+ 'key/scale change',
132
+ 'filter sweep',
152
133
  'rhythmic shift',
153
134
  'texture swap',
154
135
  'add layers',
155
136
  ];
156
- // Return evolution types for stages 2..N (stage 1 is the opening)
157
137
  return arcTemplate.slice(1, stages);
158
138
  }
159
- server.tool('live_mix', 'Autonomous DJ set — generates and evolves music through multiple stages with ~20s between each. Runs as a long tool call. Call hush to stop early.', {
160
- prompt: z.string().describe('Starting direction for the mix, e.g. "deep house sunset set" or "ambient techno journey"'),
161
- stages: z.number().min(3).max(10).default(6).optional().describe('Number of stages in the set (default 6)'),
162
- }, async ({ prompt, stages: stagesParam }) => {
163
- const stageCount = stagesParam ?? 6;
164
- await ensureEngine();
165
- // Stage 1: opening
166
- const opening = await generateAndPlay(prompt);
167
- const log = [
168
- { stage: 1, evolution: 'opening', commentary: opening.commentary, code: opening.code },
169
- ];
170
- const arc = buildSetArc(stageCount);
171
- // Stages 2..N
172
- for (let i = 0; i < arc.length; i++) {
173
- // Wait 20s between stages
174
- await new Promise((r) => setTimeout(r, 20_000));
175
- // If hush was called concurrently, stop the mix
176
- if (!getState().isPlaying) {
177
- log.push({ stage: i + 2, evolution: 'stopped', commentary: 'Mix stopped — hush was called.', code: '' });
178
- break;
139
+ // ---------------------------------------------------------------------------
140
+ // Tool registration shared by both stdio and HTTP transports.
141
+ // ---------------------------------------------------------------------------
142
+ export function registerTools(server) {
143
+ // -- play_music -----------------------------------------------------------
144
+ server.tool('play_music', 'Generate and play live music. Describe what you want to hear — a genre, mood, activity, or anything creative. DJ Claude will compose a Strudel pattern and play it through the speakers.', { prompt: z.string().describe('What kind of music to play, e.g. "jazzy lo-fi beats" or "intense drum and bass"') }, async ({ prompt }) => {
145
+ clearLayers();
146
+ await ensureEngine();
147
+ const { commentary, code } = await generateAndPlay(prompt);
148
+ return {
149
+ content: [
150
+ {
151
+ type: 'text',
152
+ text: commentary
153
+ ? `${commentary}\n\nNow playing:\n\`\`\`javascript\n${code}\n\`\`\``
154
+ : `Now playing:\n\`\`\`javascript\n${code}\n\`\`\``,
155
+ },
156
+ ],
157
+ };
158
+ });
159
+ // -- play_strudel ---------------------------------------------------------
160
+ server.tool('play_strudel', 'Evaluate raw Strudel/Tidal code directly, bypassing Claude generation. Use this when you already have Strudel code to play.', { code: z.string().describe('Strudel/Tidal code to evaluate') }, async ({ code }) => {
161
+ clearLayers();
162
+ await ensureEngine();
163
+ const { currentCode } = getState();
164
+ const result = await safeEvaluate(code, currentCode);
165
+ if (!result.success) {
166
+ return {
167
+ content: [{ type: 'text', text: `Evaluation error: ${result.error}` }],
168
+ isError: true,
169
+ };
179
170
  }
180
- const evolutionType = arc[i];
181
- const evo = EVOLUTION_PROMPTS.find((e) => e.type === evolutionType) ?? EVOLUTION_PROMPTS[i % EVOLUTION_PROMPTS.length];
182
- try {
183
- const result = await generateAndPlay(evo.prompt);
184
- log.push({ stage: i + 2, evolution: evo.type, commentary: result.commentary, code: result.code });
171
+ updateAfterPlay(code, '');
172
+ return {
173
+ content: [{ type: 'text', text: `Now playing:\n\`\`\`javascript\n${code}\n\`\`\`` }],
174
+ };
175
+ });
176
+ // -- set_vibe -------------------------------------------------------------
177
+ server.tool('set_vibe', 'Instantly set the musical vibe to match a mood. Great for matching music to the current coding task.', {
178
+ mood: z.enum(['chill', 'dark', 'hype', 'focus', 'funky', 'dreamy', 'weird', 'epic'])
179
+ .describe('The mood/vibe to set'),
180
+ }, async ({ mood }) => {
181
+ clearLayers();
182
+ await ensureEngine();
183
+ const prompt = MOOD_PROMPTS[mood];
184
+ const { commentary, code } = await generateAndPlay(prompt);
185
+ return {
186
+ content: [
187
+ {
188
+ type: 'text',
189
+ text: commentary
190
+ ? `Vibe set to ${mood}! ${commentary}\n\n\`\`\`javascript\n${code}\n\`\`\``
191
+ : `Vibe set to ${mood}!\n\n\`\`\`javascript\n${code}\n\`\`\``,
192
+ },
193
+ ],
194
+ };
195
+ });
196
+ // -- live_mix -------------------------------------------------------------
197
+ server.tool('live_mix', 'Autonomous DJ set — generates and evolves music through multiple stages with ~20s between each. Runs as a long tool call. Call hush to stop early.', {
198
+ prompt: z.string().describe('Starting direction for the mix, e.g. "deep house sunset set" or "ambient techno journey"'),
199
+ stages: z.number().min(3).max(10).default(6).optional().describe('Number of stages in the set (default 6)'),
200
+ }, async ({ prompt, stages: stagesParam }) => {
201
+ const stageCount = stagesParam ?? 6;
202
+ await ensureEngine();
203
+ const opening = await generateAndPlay(prompt);
204
+ const log = [
205
+ { stage: 1, evolution: 'opening', commentary: opening.commentary, code: opening.code },
206
+ ];
207
+ const arc = buildSetArc(stageCount);
208
+ for (let i = 0; i < arc.length; i++) {
209
+ await new Promise((r) => setTimeout(r, 20_000));
210
+ if (!getState().isPlaying) {
211
+ log.push({ stage: i + 2, evolution: 'stopped', commentary: 'Mix stopped — hush was called.', code: '' });
212
+ break;
213
+ }
214
+ const evolutionType = arc[i];
215
+ const evo = EVOLUTION_PROMPTS.find((e) => e.type === evolutionType) ?? EVOLUTION_PROMPTS[i % EVOLUTION_PROMPTS.length];
216
+ try {
217
+ const result = await generateAndPlay(evo.prompt);
218
+ log.push({ stage: i + 2, evolution: evo.type, commentary: result.commentary, code: result.code });
219
+ }
220
+ catch (err) {
221
+ log.push({ stage: i + 2, evolution: evo.type, commentary: `Error: ${err instanceof Error ? err.message : String(err)}`, code: '' });
222
+ }
185
223
  }
186
- catch (err) {
187
- log.push({ stage: i + 2, evolution: evo.type, commentary: `Error: ${err instanceof Error ? err.message : String(err)}`, code: '' });
224
+ const summary = log
225
+ .map((entry) => {
226
+ const header = `## Stage ${entry.stage}: ${entry.evolution}`;
227
+ const body = entry.commentary || '(no commentary)';
228
+ const code = entry.code ? `\n\`\`\`javascript\n${entry.code}\n\`\`\`` : '';
229
+ return `${header}\n${body}${code}`;
230
+ })
231
+ .join('\n\n---\n\n');
232
+ return {
233
+ content: [
234
+ {
235
+ type: 'text',
236
+ text: `# DJ Claude Live Mix — ${stageCount} stages\n\n${summary}`,
237
+ },
238
+ ],
239
+ };
240
+ });
241
+ // -- hush -----------------------------------------------------------------
242
+ server.tool('hush', 'Stop all music playback immediately.', {}, async () => {
243
+ clearLayers();
244
+ await ensureEngine();
245
+ engineHush();
246
+ updateAfterHush();
247
+ return {
248
+ content: [{ type: 'text', text: 'Music stopped.' }],
249
+ };
250
+ });
251
+ // -- switch_audio ---------------------------------------------------------
252
+ server.tool('switch_audio', 'Switch the audio backend at runtime between Node (terminal) and Browser (higher quality, opens a browser tab).', {
253
+ mode: z.enum(['node', 'browser']).describe('The audio backend to switch to: "node" for terminal audio, "browser" for browser tab audio'),
254
+ }, async ({ mode }) => {
255
+ const current = getBackendMode();
256
+ if (mode === current) {
257
+ return {
258
+ content: [{ type: 'text', text: `Already using ${mode} audio backend.` }],
259
+ };
260
+ }
261
+ const { currentCode, isPlaying } = getState();
262
+ await switchBackend(mode);
263
+ enginePromise = Promise.resolve();
264
+ setEngineReady();
265
+ setAudioMode(mode);
266
+ if (isPlaying && currentCode) {
267
+ const result = await safeEvaluate(currentCode, '');
268
+ if (!result.success) {
269
+ updateAfterHush();
270
+ }
188
271
  }
189
- }
190
- // Format set summary
191
- const summary = log
192
- .map((entry) => {
193
- const header = `## Stage ${entry.stage}: ${entry.evolution}`;
194
- const body = entry.commentary || '(no commentary)';
195
- const code = entry.code ? `\n\`\`\`javascript\n${entry.code}\n\`\`\`` : '';
196
- return `${header}\n${body}${code}`;
197
- })
198
- .join('\n\n---\n\n');
199
- return {
200
- content: [
201
- {
202
- type: 'text',
203
- text: `# DJ Claude Live Mix — ${stageCount} stages\n\n${summary}`,
204
- },
205
- ],
206
- };
207
- });
208
- // -- hush -----------------------------------------------------------------
209
- server.tool('hush', 'Stop all music playback immediately.', {}, async () => {
210
- await ensureEngine();
211
- engineHush();
212
- updateAfterHush();
213
- return {
214
- content: [{ type: 'text', text: 'Music stopped.' }],
215
- };
216
- });
217
- // -- switch_audio ---------------------------------------------------------
218
- server.tool('switch_audio', 'Switch the audio backend at runtime between Node (terminal) and Browser (higher quality, opens a browser tab).', {
219
- mode: z.enum(['node', 'browser']).describe('The audio backend to switch to: "node" for terminal audio, "browser" for browser tab audio'),
220
- }, async ({ mode }) => {
221
- const current = getBackendMode();
222
- if (mode === current) {
223
272
  return {
224
- content: [{ type: 'text', text: `Already using ${mode} audio backend.` }],
273
+ content: [{ type: 'text', text: `Switched to ${mode} audio backend.${isPlaying && currentCode ? ' Music resumed.' : ''}` }],
225
274
  };
226
- }
227
- const { currentCode, isPlaying } = getState();
228
- // switchBackend() disposes the old backend (which hushes internally)
229
- await switchBackend(mode);
230
- enginePromise = Promise.resolve();
231
- setEngineReady();
232
- setAudioMode(mode);
233
- // Replay on the new backend if music was playing
234
- if (isPlaying && currentCode) {
235
- const result = await safeEvaluate(currentCode, '');
236
- if (!result.success) {
275
+ });
276
+ // -- now_playing ----------------------------------------------------------
277
+ server.tool('now_playing', 'Check what music is currently playing, including the Strudel code and DJ commentary.', {}, async () => {
278
+ const { isPlaying, currentCode, mcCommentary, audioMode } = getState();
279
+ if (!isPlaying || !currentCode) {
280
+ return {
281
+ content: [{ type: 'text', text: `Nothing is currently playing. Audio backend: ${audioMode}` }],
282
+ };
283
+ }
284
+ const layers = getLayers();
285
+ const layerInfo = layers.size > 0
286
+ ? { layers: Object.fromEntries(Array.from(layers.entries()).map(([k, v]) => [k, v.code])) }
287
+ : {};
288
+ return {
289
+ content: [
290
+ {
291
+ type: 'text',
292
+ text: JSON.stringify({ isPlaying, currentCode, mcCommentary, audioMode, ...layerInfo }, null, 2),
293
+ },
294
+ ],
295
+ };
296
+ });
297
+ // -- jam ------------------------------------------------------------------
298
+ server.tool('jam', 'Add or update a single layer in a collaborative jam session. Each layer has a role (drums, bass, melody, etc.) and layers are composed together with stack(). Use this for building music incrementally or multi-agent collaboration.', {
299
+ role: z.string().describe('The role/name for this layer, e.g. "drums", "bass", "melody", "chords", "pads", "fx"'),
300
+ prompt: z.string().describe('What this layer should sound like, e.g. "funky breakbeat pattern" or "deep sub bass in C minor"'),
301
+ }, async ({ role, prompt }) => {
302
+ return withEvalLock(async () => {
303
+ await ensureEngine();
304
+ const { commentary, code: layerCode } = await generateLayerCode(role, prompt);
305
+ setLayer(role, layerCode);
306
+ const composed = composeLayers();
307
+ const { currentCode } = getState();
308
+ const result = await safeEvaluate(composed, currentCode);
309
+ if (!result.success) {
310
+ // Rollback on eval failure
311
+ removeLayer(role);
312
+ return {
313
+ content: [{ type: 'text', text: `Failed to add ${role} layer: ${result.error}` }],
314
+ isError: true,
315
+ };
316
+ }
317
+ updateAfterPlay(composed, commentary);
318
+ const layerCount = getLayers().size;
319
+ return {
320
+ content: [
321
+ {
322
+ type: 'text',
323
+ text: commentary
324
+ ? `${commentary}\n\nLayer "${role}" added (${layerCount} total):\n\`\`\`javascript\n${layerCode}\n\`\`\``
325
+ : `Layer "${role}" added (${layerCount} total):\n\`\`\`javascript\n${layerCode}\n\`\`\``,
326
+ },
327
+ ],
328
+ };
329
+ });
330
+ });
331
+ // -- jam_clear ------------------------------------------------------------
332
+ server.tool('jam_clear', 'Remove one or all layers from the jam session. If no role is specified, all layers are cleared.', {
333
+ role: z.string().optional().describe('The role to remove (e.g. "drums"). Omit to clear all layers.'),
334
+ }, async ({ role }) => {
335
+ await ensureEngine();
336
+ if (role) {
337
+ const existed = removeLayer(role);
338
+ if (!existed) {
339
+ return {
340
+ content: [{ type: 'text', text: `No layer with role "${role}" found.` }],
341
+ };
342
+ }
343
+ }
344
+ else {
345
+ clearLayers();
346
+ }
347
+ const composed = composeLayers();
348
+ if (composed) {
349
+ const { currentCode } = getState();
350
+ const result = await safeEvaluate(composed, currentCode);
351
+ if (!result.success) {
352
+ return {
353
+ content: [{ type: 'text', text: `Layer removed but recomposition failed: ${result.error}` }],
354
+ isError: true,
355
+ };
356
+ }
357
+ updateAfterPlay(composed, '');
358
+ const remaining = getLayers().size;
359
+ return {
360
+ content: [{ type: 'text', text: role ? `Layer "${role}" removed. ${remaining} layer(s) remaining.` : 'All layers cleared.' }],
361
+ };
362
+ }
363
+ else {
364
+ // No layers left — hush
365
+ engineHush();
237
366
  updateAfterHush();
367
+ return {
368
+ content: [{ type: 'text', text: role ? `Layer "${role}" removed. No layers remaining — music stopped.` : 'All layers cleared. Music stopped.' }],
369
+ };
238
370
  }
239
- }
240
- return {
241
- content: [{ type: 'text', text: `Switched to ${mode} audio backend.${isPlaying && currentCode ? ' Music resumed.' : ''}` }],
242
- };
243
- });
244
- // -- now_playing ----------------------------------------------------------
245
- server.tool('now_playing', 'Check what music is currently playing, including the Strudel code and DJ commentary.', {}, async () => {
246
- const { isPlaying, currentCode, mcCommentary, audioMode } = getState();
247
- if (!isPlaying || !currentCode) {
371
+ });
372
+ // -- jam_status -----------------------------------------------------------
373
+ server.tool('jam_status', 'Show all active layers in the current jam session with their role names and code.', {}, async () => {
374
+ const layers = getLayers();
375
+ if (layers.size === 0) {
376
+ return {
377
+ content: [{ type: 'text', text: 'No active layers. Use the jam tool to add layers.' }],
378
+ };
379
+ }
380
+ const entries = Array.from(layers.values()).map((l) => ({
381
+ role: l.role,
382
+ code: l.code,
383
+ addedAt: new Date(l.addedAt).toISOString(),
384
+ }));
248
385
  return {
249
- content: [{ type: 'text', text: `Nothing is currently playing. Audio backend: ${audioMode}` }],
386
+ content: [
387
+ {
388
+ type: 'text',
389
+ text: JSON.stringify({ layers: entries, composed: composeLayers() }, null, 2),
390
+ },
391
+ ],
250
392
  };
251
- }
252
- return {
253
- content: [
254
- {
255
- type: 'text',
256
- text: JSON.stringify({ isPlaying, currentCode, mcCommentary, audioMode }, null, 2),
257
- },
258
- ],
259
- };
260
- });
393
+ });
394
+ }
261
395
  // ---------------------------------------------------------------------------
262
- // Start.
396
+ // Start — stdio transport.
263
397
  // ---------------------------------------------------------------------------
264
398
  export async function startServer(isBrowserMode = false) {
265
399
  browserMode = isBrowserMode;
266
400
  setAudioMode(browserMode ? 'browser' : 'node');
267
- // In node mode, kick off engine init eagerly.
268
- // In browser mode, defer until first tool call (opening a browser on
269
- // MCP startup before any music is requested would be surprising).
270
401
  if (!browserMode) {
271
402
  startEngine();
272
403
  }
404
+ const server = new McpServer({
405
+ name: 'dj-claude',
406
+ version: '0.1.13',
407
+ });
408
+ registerTools(server);
273
409
  const transport = new StdioServerTransport();
274
410
  await server.connect(transport);
275
411
  console.error('[dj-claude-mcp] Server running on stdio.');
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,IAAI,UAAU,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEjH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,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CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACtD,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE;SAC3C,CAAC,CAAC,CAAC;QAEJ,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC9E;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,2BAA2B;AAC3B,8EAA8E;AAE9E,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,aAAa,GAAG,KAAK;IACrD,WAAW,GAAG,aAAa,CAAC;IAC5B,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAE/C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,EAAE,CAAC;IAChB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,QAAQ;KAClB,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,CAAC,CAAC;IAEtB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;AAC5D,CAAC"}
@@ -1,5 +1,10 @@
1
1
  import type { Message } from '../lib/types.js';
2
2
  import type { BackendMode } from '../audio/backend.js';
3
+ export interface Layer {
4
+ role: string;
5
+ code: string;
6
+ addedAt: number;
7
+ }
3
8
  interface MCPState {
4
9
  engineReady: boolean;
5
10
  isPlaying: boolean;
@@ -8,6 +13,7 @@ interface MCPState {
8
13
  mcCommentary: string;
9
14
  messages: Message[];
10
15
  audioMode: BackendMode;
16
+ layers: Map<string, Layer>;
11
17
  }
12
18
  export declare function getState(): Readonly<MCPState>;
13
19
  export declare function setEngineReady(): void;
@@ -15,5 +21,10 @@ export declare function updateAfterPlay(code: string, commentary: string): void;
15
21
  export declare function updateAfterHush(): void;
16
22
  export declare function setAudioMode(mode: BackendMode): void;
17
23
  export declare function addMessage(msg: Message): void;
24
+ export declare function setLayer(role: string, code: string): void;
25
+ export declare function removeLayer(role: string): boolean;
26
+ export declare function clearLayers(): void;
27
+ export declare function getLayers(): ReadonlyMap<string, Layer>;
28
+ export declare function composeLayers(): string;
18
29
  export {};
19
30
  //# sourceMappingURL=state.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/mcp/state.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,UAAU,QAAQ;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,SAAS,EAAE,WAAW,CAAC;CACxB;AAYD,wBAAgB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAE7C;AAED,wBAAgB,cAAc,IAAI,IAAI,CAErC;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAKtE;AAED,wBAAgB,eAAe,IAAI,IAAI,CAEtC;AAED,w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ED,wBAAgB,WAAW,IAAI,IAAI,CAElC;AAED,wBAAgB,SAAS,IAAI,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,CAEtD;AAED,wBAAgB,aAAa,IAAI,MAAM,CAQtC"}
package/dist/mcp/state.js CHANGED
@@ -7,6 +7,7 @@ const state = {
7
7
  mcCommentary: '',
8
8
  messages: [],
9
9
  audioMode: 'node',
10
+ layers: new Map(),
10
11
  };
11
12
  export function getState() {
12
13
  return state;
@@ -33,4 +34,30 @@ export function addMessage(msg) {
33
34
  state.messages = state.messages.slice(-12);
34
35
  }
35
36
  }
37
+ // ---------------------------------------------------------------------------
38
+ // Layer management — for jam tools.
39
+ // ---------------------------------------------------------------------------
40
+ export function setLayer(role, code) {
41
+ state.layers.set(role, { role, code, addedAt: Date.now() });
42
+ }
43
+ export function removeLayer(role) {
44
+ return state.layers.delete(role);
45
+ }
46
+ export function clearLayers() {
47
+ state.layers.clear();
48
+ }
49
+ export function getLayers() {
50
+ return state.layers;
51
+ }
52
+ export function composeLayers() {
53
+ const entries = Array.from(state.layers.values());
54
+ if (entries.length === 0)
55
+ return '';
56
+ if (entries.length === 1)
57
+ return entries[0].code;
58
+ const inner = entries
59
+ .map((l) => `/* [${l.role}] */ ${l.code}`)
60
+ .join(',\n ');
61
+ return `stack(\n ${inner}\n)`;
62
+ }
36
63
  //# sourceMappingURL=state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/mcp/state.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAgBnE,MAAM,KAAK,GAAa;IACtB,WAAW,EAAE,KAAK;IAClB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,MAAM;CAClB,CAAC;AAEF,MAAM,UAAU,QAAQ;IACtB,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,cA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AM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,MAAM,KAAK,GAAG,OAAO;SAClB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;SACzC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjB,OAAO,aAAa,KAAK,KAAK,CAAC;AACjC,CAAC"}
package/mcp-http.mjs ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+
3
+ // MCP HTTP entry point for DJ Claude — multi-agent jam sessions.
4
+ // CRITICAL: Redirect console.log to stderr FIRST — Strudel/cyclist logs
5
+ // write to console.log which would corrupt stdout output.
6
+ const _origLog = console.log;
7
+ console.log = (...args) => console.error(...args);
8
+
9
+ const browserMode = process.env.DJ_CLAUDE_BROWSER === '1';
10
+
11
+ // Polyfill must run before any Strudel imports.
12
+ if (!browserMode) {
13
+ await import('./dist/audio/polyfill.js');
14
+ }
15
+
16
+ // Set backend mode before engine initialization
17
+ if (browserMode) {
18
+ const { setBackendMode } = await import('./dist/audio/engine.js');
19
+ setBackendMode('browser');
20
+ }
21
+
22
+ // Start the HTTP MCP server.
23
+ const { startHttpServer } = await import('./dist/mcp/http.js');
24
+ await startHttpServer(browserMode);
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "dj-claude",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "mcpName": "io.github.p-poss/dj-claude",
5
5
  "description": "AI-generated music in your terminal — DJ Claude CLI",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "dj-claude": "./bin.mjs",
9
- "dj-claude-mcp": "./mcp.mjs"
9
+ "dj-claude-mcp": "./mcp.mjs",
10
+ "dj-claude-mcp-http": "./mcp-http.mjs"
10
11
  },
11
- "files": ["dist", "bin.mjs", "mcp.mjs"],
12
+ "files": ["dist", "bin.mjs", "mcp.mjs", "mcp-http.mjs"],
12
13
  "homepage": "https://claude.dj",
13
14
  "repository": { "type": "git", "url": "https://github.com/p-poss/dj-claude" },
14
15
  "author": "p-poss",
@@ -28,6 +29,7 @@
28
29
  "@strudel/mini": "1.1.0",
29
30
  "@strudel/webaudio": "1.1.0",
30
31
  "dotenv": "^16.4.7",
32
+ "express": "^5.1.0",
31
33
  "ink": "^5.1.0",
32
34
  "ink-text-input": "^6.0.0",
33
35
  "node-web-audio-api": "^1.0.8",