Spaces:
Running on Zero
Running on Zero
docs: add claude/agents/skills guides with sole-author rule
Browse files
AGENTS.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AGENTS.md
|
| 2 |
+
|
| 3 |
+
Tool-agnostic agent guidance for the ACE Music Studio repo. If you're driving Claude Code, Cursor, Aider, Codex, or anything else with file-edit + shell access, **start here**.
|
| 4 |
+
|
| 5 |
+
This file is the authoritative project rulebook. `CLAUDE.md` is Claude-specific extensions; `SKILLS.md` is workflow rules. README.md is the public-facing project intro β different audience.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## TL;DR β the five rules
|
| 10 |
+
|
| 11 |
+
1. **Mayank Gupta is sole author on every commit.** No agent co-author trailers. No "generated withβ¦" footers. No `--author=` flag. Strip any tool-suggested attribution.
|
| 12 |
+
2. **Backend = ACE-Step 1.5 XL SFT, not ComfyUI.** Don't add a ComfyUI dependency under any guise.
|
| 13 |
+
3. **One pipeline instance for all modes.** Generate / Cover / Extend / Edit call different entry points on the same pipeline object. Don't instantiate per-mode β it doubles memory and breaks LoRA state.
|
| 14 |
+
4. **Don't pin `spaces` in `requirements.txt`.** HF Spaces' ZeroGPU build injects its own version. A pin causes pip-resolve failure.
|
| 15 |
+
5. **Locally is the source of truth.** All changes restart `python app.py` and verify on http://127.0.0.1:7860 BEFORE pushing to HF. The Space rebuild is ~5β10 min; iterate locally.
|
| 16 |
+
|
| 17 |
+
If you can't satisfy these without changing architectural shape, **ask the user before proceeding**.
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Project shape
|
| 22 |
+
|
| 23 |
+
Single-process Gradio 5.50 app, flat top-level Python layout.
|
| 24 |
+
|
| 25 |
+
```
|
| 26 |
+
app.py Gradio Blocks entry + bootstrap + event handlers
|
| 27 |
+
backend.py AceMusicBackend; @spaces.GPU; duration_for; generate_with_retry
|
| 28 |
+
modes.py call_generate / call_cover / call_extend / call_edit (pure handlers)
|
| 29 |
+
models.py auto_device, MODEL_CONFIGS, vram_limit_for, HF symlink helper
|
| 30 |
+
lora.py safetensors header sniff + applied_lora context manager
|
| 31 |
+
lyrics.py Qwen 2.5 7B inference (MLX on Mac, transformers on CUDA)
|
| 32 |
+
stems.py Demucs htdemucs_ft stem separation wrapper
|
| 33 |
+
postprocess.py loudness normalisation + fade in/out
|
| 34 |
+
ui.py Five per-tab builders
|
| 35 |
+
theme.py Soft Dark Restraint palette + minimal CSS
|
| 36 |
+
tooltips.py Centralised info= strings β single source of truth
|
| 37 |
+
tests/ L1+L2 tests + GPU-deselected smoke
|
| 38 |
+
docs/superpowers/ spec + plan + brainstorm artifacts
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
Same code path locally (MPS / CUDA) and on HF Spaces. The only branching is whether `_bootstrap()` does the cache-mirror dance (Spaces) or just the symlink step (local).
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
+
## Locked architecture decisions
|
| 46 |
+
|
| 47 |
+
These came out of brainstorming + spec design. Do not relitigate.
|
| 48 |
+
|
| 49 |
+
| Decision | Why | Code reference |
|
| 50 |
+
|---|---|---|
|
| 51 |
+
| One `AceMusicBackend` instance, lazy init | Avoids ~60 s pipeline rebuild per request; LoRA revert is cleaner | `backend.get_backend` |
|
| 52 |
+
| Mode dispatch = separate `call_*` functions | Clean handler boundaries; easy to test with mocked pipe | `modes.py` |
|
| 53 |
+
| MPS `vram_limit = None` | `torch.mps` has no `mem_get_info`; any VRAM gate raises AttributeError otherwise | `models.vram_limit_for` |
|
| 54 |
+
| `PYTORCH_ENABLE_MPS_FALLBACK=1` set at app import | A few MPS-unsupported ops crash mid-pipeline without it | `app.py` top-of-file |
|
| 55 |
+
| HF cache β `./models/<repo>/` symlink at boot | ACE-Step's loader looks at local paths, NOT the HF cache snapshot layout | `app._bootstrap` |
|
| 56 |
+
| MLX path for Qwen on Mac | mlx-lm is 3-4x faster than transformers on Apple Silicon for text inference | `lyrics.py` |
|
| 57 |
+
| Stacked LoRA with safetensors sniff | 4 bundled presets + arbitrary uploads; header check avoids corrupt-file crashes | `lora.py` |
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## Commit rules
|
| 62 |
+
|
| 63 |
+
- **Conventional Commits:** `<type>(<scope>): <subject>`
|
| 64 |
+
- types: `feat`, `fix`, `chore`, `docs`, `test`, `refactor`, `ci`, `perf`
|
| 65 |
+
- Subject is imperative, lowercase, **no trailing period**.
|
| 66 |
+
- Body explains **why** when not obvious. Reference plan task IDs (Task 7, Task A, etc.) when the change implements a specific plan step.
|
| 67 |
+
- Frequent small commits; one logical change per commit.
|
| 68 |
+
- **No agent attribution** in commit message or body. See rule 1.
|
| 69 |
+
- Don't `git push --force` to `main` unless the user explicitly says so.
|
| 70 |
+
|
| 71 |
+
---
|
| 72 |
+
|
| 73 |
+
## Verification rules
|
| 74 |
+
|
| 75 |
+
- **Tests must pass before committing.** `python -m pytest tests/ -q` from the project root.
|
| 76 |
+
- **Ruff must be clean.** `ruff check . && ruff format --check .`
|
| 77 |
+
- **The local app must boot.** `python app.py` β http://127.0.0.1:7860 reachable, no import error in `/tmp/ace-music-studio.log`.
|
| 78 |
+
- **For UI changes:** open the URL in a browser (or Playwright eval) and verify the change is rendered. Don't trust a clean test run + clean ruff as proof that the UI works.
|
| 79 |
+
- **For deployment changes:** push to HF Space, watch the build, verify the runtime stage transitions to `RUNNING` before claiming success.
|
| 80 |
+
|
| 81 |
+
If a change requires breaking these rules, write the reason in the commit body.
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## Testing conventions
|
| 86 |
+
|
| 87 |
+
- **TDD per the plan.** Failing test first, then implementation.
|
| 88 |
+
- **L1 + L2 in CI** (no GPU). The mode handlers are tested with a mocked pipeline. We do NOT mock ACE-Step internals.
|
| 89 |
+
- **L3 GPU smoke** is opt-in (`pytest -m gpu`). Lives in `tests/test_smoke_gpu.py`. Loads the real pipeline (~32 GB cache hit on a warm machine).
|
| 90 |
+
- **L4 HF Space smoke** is manual. Push, wait, click each tab, verify audio renders.
|
| 91 |
+
|
| 92 |
+
`pyproject.toml` has `addopts = -m 'not gpu'` so the default `pytest` invocation skips GPU. Add the marker before any test that touches ACE-Step weights.
|
| 93 |
+
|
| 94 |
+
---
|
| 95 |
+
|
| 96 |
+
## Out of scope (v1 cap β don't add without asking)
|
| 97 |
+
|
| 98 |
+
Per spec Β§13. If you find yourself "while I'm here"-ing into one of them, stop.
|
| 99 |
+
|
| 100 |
+
- Multi-prompt batch queue
|
| 101 |
+
- Persistent generation history
|
| 102 |
+
- User accounts
|
| 103 |
+
- Telemetry dashboard
|
| 104 |
+
- Voice cloning (RVC)
|
| 105 |
+
- LoRA training in-app
|
| 106 |
+
- ControlNet-style conditioning
|
| 107 |
+
- Spectrogram visualization
|
| 108 |
+
- Multi-language UI strings
|
| 109 |
+
- Watermarking output audio
|
| 110 |
+
- Browser audio editing
|
| 111 |
+
- Multi-tenant rate limiting
|
| 112 |
+
- DAW export
|
| 113 |
+
|
| 114 |
+
If a feature you're adding requires one of these as a sub-step, **ask the user** before proceeding.
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
## When you're not sure
|
| 119 |
+
|
| 120 |
+
1. Read `docs/superpowers/specs/2026-05-18-ace-music-studio-design.md` β that's the architectural source of truth.
|
| 121 |
+
2. Read `docs/superpowers/plans/2026-05-18-ace-music-studio.md` β the task-by-task breakdown.
|
| 122 |
+
3. Read `SKILLS.md` β process rules, debugging patterns, deployment workflow.
|
| 123 |
+
4. `git log --oneline` β every non-obvious decision has a fix-commit explaining the reasoning.
|
| 124 |
+
5. **Ask the user.** A clarifying question costs the user ten seconds. A wrong implementation costs everyone an hour.
|
CLAUDE.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Project Guidelines β ACE Music Studio
|
| 2 |
+
|
| 3 |
+
Working notes for AI assistants editing this repo. This file is the *what & why* β the locked architecture, the gotchas, the sole-author rule. Companion to `SKILLS.md` (the *how* β process, debugging, deployment workflow) and `AGENTS.md` (tool-agnostic version of this file).
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## β Sole-author rule (non-negotiable)
|
| 8 |
+
|
| 9 |
+
**Mayank Gupta is the sole author on every commit in this repo.** No exceptions.
|
| 10 |
+
|
| 11 |
+
When committing:
|
| 12 |
+
|
| 13 |
+
- **NO** `Co-Authored-By: Claudeβ¦` (or any agent name) trailer.
|
| 14 |
+
- **NO** "Generated with Claude Code" / "π€ Generated withβ¦" footers.
|
| 15 |
+
- **NO** `--author=β¦` flag β let git use the user's configured identity.
|
| 16 |
+
- **NO** attribution in PR descriptions.
|
| 17 |
+
|
| 18 |
+
If asked to amend, re-commit, or rebase, strip any prior agent attribution from the commit message. Treat any tooling that suggests adding a Claude trailer as a bug to ignore.
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
## Architecture facts (locked β do not relitigate)
|
| 23 |
+
|
| 24 |
+
Spec: `docs/superpowers/specs/2026-05-18-ace-music-studio-design.md`
|
| 25 |
+
Plan: `docs/superpowers/plans/2026-05-18-ace-music-studio.md`
|
| 26 |
+
|
| 27 |
+
1. **Backend is ACE-Step 1.5 XL SFT** β not ComfyUI. Installed from git (the package isn't on PyPI). The upstream repo is `git+https://github.com/ace-step/ACE-Step-1.5.git`; the Apple Silicon fork is `git+https://github.com/clockworksquirrel/ace-step-apple-silicon.git`.
|
| 28 |
+
2. **Five tabs.** Generate, Cover, Extend, Edit, Lyrics. Progressive disclosure β defaults stay short and reveal advanced controls only when asked.
|
| 29 |
+
3. **One pipeline instance.** Single ACE-Step pipeline; mode handlers (generate / cover / extend / edit) call different pipeline entry points. No re-instantiation between calls.
|
| 30 |
+
4. **`@spaces.GPU` is applied at module load time.** Identity decorator off Spaces. The decorator's `duration=` parameter takes a callable that estimates per-call timeout from `(mode, params, multiplier)`. Estimator clamps at `[60, 300] s`.
|
| 31 |
+
5. **Qwen 2.5 7B handles lyrics generation.** Text-only inference; full multimodal weights are NOT required. On Mac the MLX path is used via mlx-lm.
|
| 32 |
+
6. **HF cache β `./models/<repo>/` symlink.** ACE-Step looks for files at `local_model_path/...`. `app._bootstrap()` symlinks every cached snapshot into `./models/<org>/<repo>/` so the preload weights are findable. On Spaces, the build-user-owned `~/.cache/huggingface/hub` is mirrored to runtime-writable `~/hf-cache-rw/` first, then symlinked.
|
| 33 |
+
7. **One Gradio process. Lazy backend singleton.** `get_backend()` constructs the pipeline on the first request (~30β60 s warm-up). Module import is fast.
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Gotchas we already paid for (don't re-discover)
|
| 38 |
+
|
| 39 |
+
Each of these cost a debug cycle. Read once.
|
| 40 |
+
|
| 41 |
+
### MPS / Apple Silicon
|
| 42 |
+
|
| 43 |
+
- `torch.mps` has no `mem_get_info`. Any VRAM-gate that calls that method raises AttributeError. **Fix:** `vram_limit_for("mps")` returns `None` so the gate short-circuits.
|
| 44 |
+
- Several ops aren't implemented on the MPS backend (SDPA variants, some index ops). `app.py` sets `PYTORCH_ENABLE_MPS_FALLBACK=1` so they degrade to CPU instead of crashing.
|
| 45 |
+
|
| 46 |
+
### ACE-Step gotchas
|
| 47 |
+
|
| 48 |
+
TBD as discovered during M1+ implementation. Record new ones here as they come up.
|
| 49 |
+
|
| 50 |
+
### Dependency footguns
|
| 51 |
+
|
| 52 |
+
- `ace-step` is NOT on PyPI. Install from git (see `requirements.txt`).
|
| 53 |
+
- Don't pin `spaces` in `requirements.txt`. HF Spaces' ZeroGPU build injects its own version. A pin causes pip-resolve failure.
|
| 54 |
+
- `transformers >= 5` may break imports. **Pin:** `transformers>=4.45,<5.0`.
|
| 55 |
+
|
| 56 |
+
### Gradio 5 quirks
|
| 57 |
+
|
| 58 |
+
- Don't put `<script>` tags inside `gr.HTML` blocks β they get stripped. JS goes in `gr.Blocks(head=β¦)`.
|
| 59 |
+
- The Gradio 6.0 deprecation warnings about `theme=` / `css=` / `head=` on `Blocks` are benign on 5.50. Ignore until upgrade.
|
| 60 |
+
|
| 61 |
+
### HF Spaces deployment
|
| 62 |
+
|
| 63 |
+
- `preload_from_hub` is build-time only. Runtime falls back to network if any required file isn't preloaded. Use broad globs so configs + index.json files come along.
|
| 64 |
+
- ZeroGPU build injects `spaces==0.50.0`. If `requirements.txt` pins `spaces==0.30.0`, pip resolution fails. **Don't pin `spaces` at all** β let HF provide it.
|
| 65 |
+
- The `@spaces.GPU` decorator must be applied at module load. Runtime decoration isn't detected by ZeroGPU's startup analyzer.
|
| 66 |
+
|
| 67 |
+
---
|
| 68 |
+
|
| 69 |
+
## Coding conventions
|
| 70 |
+
|
| 71 |
+
- **Python 3.11.** HF Spaces base image is 3.11; older syntax (like no `match`) is fine.
|
| 72 |
+
- **Flat top-level layout.** No `src/`, no nested packages. One `.py` per responsibility.
|
| 73 |
+
- **No conda.** `python3.11 -m venv .venv`; `brew` for system binaries.
|
| 74 |
+
- **No emojis** in code or commits unless explicitly requested. UI strings (CTA banner, button labels) are OK because they're user-facing copy, not code.
|
| 75 |
+
- **Type hints on public functions.** Internal helpers can skip them when obvious.
|
| 76 |
+
- **Imports at the top of the file.** Inline imports only to break circular deps OR to defer heavy modules (ace-step, torch, mlx) for fast CI startup.
|
| 77 |
+
- **`ruff format` + `ruff check`** both pass in CI. No exceptions.
|
| 78 |
+
|
| 79 |
+
---
|
| 80 |
+
|
| 81 |
+
## Commits
|
| 82 |
+
|
| 83 |
+
- **Conventional Commits:** `<type>(<scope>): <subject>` β types: `feat`, `fix`, `chore`, `docs`, `test`, `refactor`, `ci`, `perf`.
|
| 84 |
+
- Subject is **imperative**, lowercase, no trailing period.
|
| 85 |
+
- Body explains **why** when not obvious. Reference the spec / plan section if relevant.
|
| 86 |
+
- Frequent small commits β one logical change per commit.
|
| 87 |
+
- **NO Claude trailer.** See top of file.
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## Testing
|
| 92 |
+
|
| 93 |
+
- **TDD per the plan.** Each implementation task has the failing test first.
|
| 94 |
+
- **L1 + L2 in CI** (no GPU): module structure, mocked pipeline call boundaries, ruff. `tests/test_smoke_gpu.py` is the GPU smoke; it's marked with `@pytest.mark.gpu` and skipped by default (pyproject `addopts = -m 'not gpu'`).
|
| 95 |
+
- **No mocks for ACE-Step internals.** Mock only the `pipe(...)` call boundary so the mode-handler logic is verified at the boundary.
|
| 96 |
+
- **Use `pytest -m gpu`** to opt into the GPU smoke (~32 GB download on a cold cache; runs full generate + cover + extend + edit).
|
| 97 |
+
|
| 98 |
+
---
|
| 99 |
+
|
| 100 |
+
## Out of scope for v1 (don't add without asking)
|
| 101 |
+
|
| 102 |
+
Per spec Β§13:
|
| 103 |
+
|
| 104 |
+
- Multi-prompt batch queue
|
| 105 |
+
- Persistent generation history
|
| 106 |
+
- User accounts
|
| 107 |
+
- Telemetry dashboard
|
| 108 |
+
- Voice cloning (RVC)
|
| 109 |
+
- LoRA training in-app
|
| 110 |
+
- ControlNet-style conditioning
|
| 111 |
+
- Spectrogram visualization
|
| 112 |
+
- Multi-language UI strings
|
| 113 |
+
- Watermarking output audio
|
| 114 |
+
- Browser audio editing
|
| 115 |
+
- Multi-tenant rate limiting
|
| 116 |
+
- DAW export
|
| 117 |
+
|
| 118 |
+
If a task feels like it needs one of these, stop and ask the user.
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
+
|
| 122 |
+
## When in doubt
|
| 123 |
+
|
| 124 |
+
1. Read the spec + plan. Fifteen minutes of reading vs a day of wrong implementation.
|
| 125 |
+
2. Read `SKILLS.md` for the process side β debugging, deployment, when to commit, when to verify.
|
| 126 |
+
3. `git log --oneline` β most non-obvious decisions have a fix-commit explaining the reasoning.
|
| 127 |
+
4. **Ask the user** before changing architectural shape or adding scope outside the v1 list.
|
SKILLS.md
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# SKILLS.md β how to work in this repo
|
| 2 |
+
|
| 3 |
+
Process rules and habits for editing ACE Music Studio. Companion to `CLAUDE.md` (which is *what & why*); this file is *how* β debugging, verification, deployment, when to commit, when to ship.
|
| 4 |
+
|
| 5 |
+
> **Default rule when in doubt:** stop and ask the user. The user prefers a question over wrong work.
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Investigation before fix
|
| 10 |
+
|
| 11 |
+
### Reproduce the bug before patching
|
| 12 |
+
|
| 13 |
+
When the user reports a layout, color, click, or visibility issue, **first action is verify, not code**. Open the local app (http://127.0.0.1:7860) in a browser OR via Playwright (`mcp__playwright__browser_*`) and reproduce the issue. Take a screenshot. THEN diagnose.
|
| 14 |
+
|
| 15 |
+
Skipping the visual repro twice in a row will produce a patch that fixes a different symptom than the one the user is seeing.
|
| 16 |
+
|
| 17 |
+
For shape / data bugs: read the stack trace fully, identify the line, then read the function β don't trust the line number alone.
|
| 18 |
+
|
| 19 |
+
### Pull HF Space logs when something runs there
|
| 20 |
+
|
| 21 |
+
For Spaces failures, the run logs are the source of truth.
|
| 22 |
+
|
| 23 |
+
```bash
|
| 24 |
+
HF_TOKEN=$(cat ~/.cache/huggingface/token)
|
| 25 |
+
curl -s -H "Authorization: Bearer ${HF_TOKEN}" \
|
| 26 |
+
"https://huggingface.co/api/spaces/techfreakworm/ace-music-studio/logs/run" \
|
| 27 |
+
> /tmp/hf-runtime.log
|
| 28 |
+
|
| 29 |
+
# Decode the SSE-style `data: {...}` lines
|
| 30 |
+
python3 << 'PY'
|
| 31 |
+
import json
|
| 32 |
+
msgs = []
|
| 33 |
+
for line in open('/tmp/hf-runtime.log'):
|
| 34 |
+
if line.startswith('data:'):
|
| 35 |
+
try: msgs.append(json.loads(line[5:].strip()).get('data', '').rstrip())
|
| 36 |
+
except Exception: pass
|
| 37 |
+
with open('/tmp/hf-runtime-decoded.log', 'w') as f:
|
| 38 |
+
f.write('\n'.join(msgs))
|
| 39 |
+
print(f'Decoded {len(msgs)} lines')
|
| 40 |
+
PY
|
| 41 |
+
|
| 42 |
+
tail -100 /tmp/hf-runtime-decoded.log
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
`/logs/run` is runtime container output. `/logs/build` is the image-build phase (pip install, preload, etc.). Different problems, different endpoints.
|
| 46 |
+
|
| 47 |
+
### Stage check before action
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
curl -s https://huggingface.co/api/spaces/techfreakworm/ace-music-studio/runtime | python3 -m json.tool
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
Terminal stages: `RUNNING`, `RUNTIME_ERROR`, `BUILD_ERROR`. Transient: `BUILDING`, `APP_STARTING`, `RUNNING_BUILDING` (live serving while a new build runs). Always check `errorMessage` first when stage is non-RUNNING.
|
| 54 |
+
|
| 55 |
+
### Sequential thinking for repeated failures
|
| 56 |
+
|
| 57 |
+
The user has called this out: if a fix doesn't work on the first try, **stop patching**. Use the `superpowers:sequential-thinking` MCP and the `superpowers:systematic-debugging` skill. Two failed fixes is the signal β go back to root-cause investigation before attempting fix #3.
|
| 58 |
+
|
| 59 |
+
Pattern that means you're guessing:
|
| 60 |
+
- "Just try changing X and see if it works"
|
| 61 |
+
- "I see another thing it could be β fix that too"
|
| 62 |
+
- Multiple changes in one commit chasing a symptom
|
| 63 |
+
|
| 64 |
+
Pattern that means you're investigating:
|
| 65 |
+
- One hypothesis per cycle
|
| 66 |
+
- Each hypothesis has a falsifying experiment
|
| 67 |
+
- Experiments produce evidence before code changes
|
| 68 |
+
|
| 69 |
+
---
|
| 70 |
+
|
| 71 |
+
## Running locally
|
| 72 |
+
|
| 73 |
+
```bash
|
| 74 |
+
cd /Users/techfreakworm/Projects/llm/music-generator
|
| 75 |
+
source .venv/bin/activate
|
| 76 |
+
# Restart cleanly (kill anything on 7860)
|
| 77 |
+
kill -9 $(lsof -ti:7860 2>/dev/null) 2>/dev/null || true
|
| 78 |
+
sleep 1
|
| 79 |
+
nohup .venv/bin/python app.py > /tmp/ace-music-studio.log 2>&1 &
|
| 80 |
+
disown
|
| 81 |
+
# Wait for ready
|
| 82 |
+
for i in $(seq 1 30); do curl -sf http://127.0.0.1:7860/ -o /dev/null && echo "ready ${i}s" && break; sleep 1; done
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
`/tmp/ace-music-studio.log` is the live log. Tail it during development. The Monitor tool with a `grep -E "ERROR|Traceback|Exception"` filter is the right way to watch it across many turns without blowing context.
|
| 86 |
+
|
| 87 |
+
LAN access for phone / tablet testing: `http://192.168.0.10:7860` (the LAN IP of the dev machine). Gradio binds to `0.0.0.0:7860` by default in `app.py`.
|
| 88 |
+
|
| 89 |
+
---
|
| 90 |
+
|
| 91 |
+
## Verification before committing
|
| 92 |
+
|
| 93 |
+
Before every commit:
|
| 94 |
+
|
| 95 |
+
1. **Tests pass.** `python -m pytest tests/ -q` β target 0 failures. New code adds new tests.
|
| 96 |
+
2. **Ruff clean.** `ruff check . && ruff format --check .` β both no-op.
|
| 97 |
+
3. **App boots.** Restart the local server (kill 7860, relaunch). Confirm "ready" within ~5 seconds and no traceback in `/tmp/ace-music-studio.log`.
|
| 98 |
+
4. **The change is visible.** For UI changes, click through the affected tab in the browser. For backend changes, click Generate and verify the output matches expectation.
|
| 99 |
+
|
| 100 |
+
Tests + ruff alone is not proof the UI works β the test suite mocks `pipe(...)` and doesn't exercise the Gradio render tree.
|
| 101 |
+
|
| 102 |
+
---
|
| 103 |
+
|
| 104 |
+
## When to commit
|
| 105 |
+
|
| 106 |
+
- **One logical change per commit.** A fix and a refactor are TWO commits, not one.
|
| 107 |
+
- After a test goes red β green, commit.
|
| 108 |
+
- After fixing a regression, commit BEFORE adding the next feature.
|
| 109 |
+
- Don't bundle "while I'm here" changes β they hide the actual fix in the diff.
|
| 110 |
+
|
| 111 |
+
Conventional Commits format:
|
| 112 |
+
|
| 113 |
+
```
|
| 114 |
+
<type>(<scope>): <subject>
|
| 115 |
+
|
| 116 |
+
<body β explains WHY, not what>
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
Types in use: `feat`, `fix`, `chore`, `docs`, `test`, `refactor`, `ci`, `perf`.
|
| 120 |
+
|
| 121 |
+
NO Claude trailer. NO "Generated withβ¦" footer. See `CLAUDE.md` rule 1.
|
| 122 |
+
|
| 123 |
+
---
|
| 124 |
+
|
| 125 |
+
## Deployment workflow
|
| 126 |
+
|
| 127 |
+
The repo has two remotes:
|
| 128 |
+
|
| 129 |
+
```
|
| 130 |
+
origin β git@github.com:techfreakworm/ace-music-studio.git
|
| 131 |
+
space β https://huggingface.co/spaces/techfreakworm/ace-music-studio
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
To push:
|
| 135 |
+
|
| 136 |
+
```bash
|
| 137 |
+
git push origin main
|
| 138 |
+
git push space main
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
After the `space` push, HF starts rebuilding. Watch:
|
| 142 |
+
|
| 143 |
+
```bash
|
| 144 |
+
TOKEN=$(cat ~/.cache/huggingface/token)
|
| 145 |
+
while true; do
|
| 146 |
+
STATE=$(curl -s -H "Authorization: Bearer $TOKEN" \
|
| 147 |
+
https://huggingface.co/api/spaces/techfreakworm/ace-music-studio/runtime \
|
| 148 |
+
| python3 -c "import json,sys; print(json.load(sys.stdin).get('stage','?'))")
|
| 149 |
+
echo "$(date +%H:%M:%S) $STATE"
|
| 150 |
+
case "$STATE" in
|
| 151 |
+
RUNNING|BUILD_ERROR|RUNTIME_ERROR) break ;;
|
| 152 |
+
esac
|
| 153 |
+
sleep 30
|
| 154 |
+
done
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Typical build time: ~5 min after weights are cached. First build with new preload globs: ~15β20 min.
|
| 158 |
+
|
| 159 |
+
### Don't push during HF testing
|
| 160 |
+
|
| 161 |
+
When the user is actively testing on the live Space, hold local commits β don't push mid-test. They'll explicitly say "push it now" when they're ready.
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## Adding a new model / weight
|
| 166 |
+
|
| 167 |
+
1. Add a `ModelConfig(...)` entry to `models.MODEL_CONFIGS`.
|
| 168 |
+
2. Add the file (or glob) to `preload_from_hub:` in `README.md`'s YAML frontmatter.
|
| 169 |
+
3. Run tests, restart server, verify in browser, then commit.
|
| 170 |
+
|
| 171 |
+
---
|
| 172 |
+
|
| 173 |
+
## Adding a new mode / tab
|
| 174 |
+
|
| 175 |
+
1. Spec the new mode in `docs/superpowers/specs/` first. Don't skip this.
|
| 176 |
+
2. Add a `call_<mode>(pipe, params)` to `modes.py`. Same shape as the existing handlers.
|
| 177 |
+
3. Add a `build_<mode>_tab()` to `ui.py`. Use the existing tabs as template.
|
| 178 |
+
4. Wire `on_<mode>_generate()` in `app.py` with `progress=gr.Progress(track_tqdm=True)`. Connect `c["generate_btn"].click(...)`.
|
| 179 |
+
5. Add tests in `tests/test_modes.py` mocking the `pipe` boundary.
|
| 180 |
+
6. Update tooltips dict in `tooltips.py`.
|
| 181 |
+
7. Update the spec + plan to reflect the new mode.
|
| 182 |
+
|
| 183 |
+
---
|
| 184 |
+
|
| 185 |
+
## When you have 2+ failed fixes
|
| 186 |
+
|
| 187 |
+
This is a process signal, not a coding signal. Stop coding.
|
| 188 |
+
|
| 189 |
+
1. Read `superpowers:systematic-debugging` (the Iron Law: no fixes without root-cause investigation).
|
| 190 |
+
2. Use `mcp__sequential-thinking__sequentialthinking` to walk through hypotheses one at a time.
|
| 191 |
+
3. Each hypothesis needs a falsifying experiment (a log line, a Playwright eval, a test). Run the experiment before writing code.
|
| 192 |
+
4. If 3+ fixes have failed, the architecture is wrong β escalate to the user, don't attempt fix #4.
|
| 193 |
+
|
| 194 |
+
This rule has saved several hours of thrashing in this repo. Honour it.
|
| 195 |
+
|
| 196 |
+
---
|
| 197 |
+
|
| 198 |
+
## Brainstorm + visual companion
|
| 199 |
+
|
| 200 |
+
When making material UI changes, use:
|
| 201 |
+
|
| 202 |
+
- `superpowers:brainstorming` to clarify what's actually being built
|
| 203 |
+
- `superpowers:frontend-design` (or `frontend-design:frontend-design`) for design quality
|
| 204 |
+
- The visual companion server (under `.superpowers/brainstorm/.../content/`) for mockups the user can click through
|
| 205 |
+
|
| 206 |
+
The user's `.superpowers/` directory is git-ignored and persists per project. Don't prematurely re-mockup β confirm with the user that mockups are wanted before generating them.
|
| 207 |
+
|
| 208 |
+
Default to RESTRAINT β single accent, single font, gradio-native shapes, progressive disclosure.
|
| 209 |
+
|
| 210 |
+
---
|
| 211 |
+
|
| 212 |
+
## Skills + sub-agents
|
| 213 |
+
|
| 214 |
+
When dispatching subagents (Agent tool):
|
| 215 |
+
|
| 216 |
+
- **Brief them like they walked in cold.** They see none of this conversation. Include file paths, line numbers, what to change, what NOT to change.
|
| 217 |
+
- **Don't make a subagent read the plan file.** Paste the relevant section into the prompt.
|
| 218 |
+
- **Use Opus for design + heavy refactors.** Sonnet for mechanical implementation. Haiku for trivial CSS / config changes.
|
| 219 |
+
- **One subagent per task.** Two parallel subagents touching the same file is a guaranteed merge conflict.
|
| 220 |
+
- **Subagents commit but don't push.** The user pushes when they've reviewed the diff locally.
|
| 221 |
+
|
| 222 |
+
---
|
| 223 |
+
|
| 224 |
+
## When in doubt
|
| 225 |
+
|
| 226 |
+
1. Re-read the spec at `docs/superpowers/specs/2026-05-18-ace-music-studio-design.md`.
|
| 227 |
+
2. `git log --oneline` β every non-obvious decision has a fix-commit explaining the reasoning.
|
| 228 |
+
3. Ask the user. They prefer answering a clarifying question to debugging wrong code an hour later.
|