mirror of
https://github.com/kennethreitz/pytheory.git
synced 2026-06-05 14:50:18 +00:00
Multiline prompt: compact when short, stacks when context grows
Single line: pytheory[key=Am | bpm=140]> Multiline when >60 chars: key=Am | bpm=140 | drums=bossa nova | →lead(saw) rev=0.3 lp=2000 ♫> Shows active part synth and effects in the prompt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+26
-6
@@ -464,14 +464,34 @@ COMMANDS = {
|
||||
# ── Main ───────────────────────────────────────────────────────────────────
|
||||
|
||||
def _prompt(session):
|
||||
"""Build a context-aware prompt showing current state."""
|
||||
parts = [f"key={session.key.tonic_name}{('m' if session.key.mode == 'minor' else '')}"]
|
||||
parts.append(f"bpm={session.bpm}")
|
||||
"""Build a context-aware multiline prompt."""
|
||||
key_str = f"{session.key.tonic_name}{('m' if session.key.mode == 'minor' else '')}"
|
||||
ctx = [f"key={key_str}", f"bpm={session.bpm}"]
|
||||
if session.swing > 0:
|
||||
ctx.append(f"swing={session.swing}")
|
||||
if session._drum_preset:
|
||||
parts.append(f"drums={session._drum_preset}")
|
||||
ctx.append(f"drums={session._drum_preset}")
|
||||
if session.current_part is not None:
|
||||
parts.append(f"→{session.current_part.name}")
|
||||
return f"pytheory[{' '.join(parts)}]> "
|
||||
p = session.current_part
|
||||
fx = []
|
||||
if p.reverb_mix > 0: fx.append(f"rev={p.reverb_mix}")
|
||||
if p.delay_mix > 0: fx.append(f"del={p.delay_mix}")
|
||||
if p.lowpass > 0: fx.append(f"lp={int(p.lowpass)}")
|
||||
if p.distortion_mix > 0: fx.append(f"dist={p.distortion_mix}")
|
||||
if p.legato: fx.append("legato")
|
||||
part_str = f"{p.name}({p.synth})"
|
||||
if fx:
|
||||
part_str += f" {' '.join(fx)}"
|
||||
ctx.append(f"→{part_str}")
|
||||
|
||||
# Single line if short, multiline if long
|
||||
oneline = f"pytheory[{' | '.join(ctx)}]> "
|
||||
if len(oneline) <= 60:
|
||||
return oneline
|
||||
|
||||
# Multiline
|
||||
lines = " " + " | ".join(ctx)
|
||||
return f"{lines}\n♫> "
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user