Skip to content

feat: add sonilo-cli package and context7.json - #10

Merged
spencer-zqian merged 11 commits into
mainfrom
feat/py-cli-and-context7
Jul 23, 2026
Merged

feat: add sonilo-cli package and context7.json#10
spencer-zqian merged 11 commits into
mainfrom
feat/py-cli-and-context7

Conversation

@spencer-zqian

@spencer-zqian spencer-zqian commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports sonilo-js PR #12 to Python: a new sonilo-cli package plus a repo-root context7.json. Rebased on sonilo 0.5.0, so it also covers the new combined-soundtrack endpoints.

What is sonilo-cli for?

A command-line wrapper around the sonilo SDK, so you can generate music and SFX from the terminal without writing Python. Instead of a script:

from sonilo import Sonilo
Sonilo(api_key="sk-...").text_to_music.generate(prompt="warm lo-fi piano", duration=30).save("song.m4a")

you run:

sonilo text-to-music --prompt "warm lo-fi piano" --duration 30

Useful for quick demos, shell/CI/cron automation, and non-programmers. It's a thin layer — all capability comes from the SDK; the CLI only translates flags into SDK calls (hence zero third-party dependencies, stdlib argparse only).

What is context7.json for?

Context7 is a service that feeds up-to-date library docs to AI coding assistants so they stop hallucinating stale/wrong APIs. context7.json is the library-author config we hand Context7: which folders to skip when indexing, plus a set of agent-facing rules (read the key from SONILO_API_KEY; text-to-sfx/video-to-sfx are always async; result URLs are short-lived presigned links — don't send the auth header; which error types to catch). Once the repo is registered on Context7, anyone using an AI assistant to write Sonilo code gets our own accurate guidance instead of a guess.

What's included

  • New sonilo-cli package (bin: sonilo) wrapping the SDK: account, usage, text-to-music, video-to-music, text-to-sfx, video-to-sfx, video-to-sound, video-to-video-sound, tasks get/tasks wait. Auth via SONILO_API_KEY or --api-key. Async-only options (--format wav, --isolate-vocals, --preserve-speech) submit + poll automatically instead of streaming. Zero third-party deps (stdlib argparse).
  • Combined-soundtrack commands for the 0.5.0 endpoints: video-to-sound (mixed audio, default output.wav) and video-to-video-sound (source video with audio muxed in, default output.mp4). Both take --music-prompt/--sfx-prompt, --preserve-speech, --no-ducking, and a repeatable --stem music|music_processed|sfx that saves the individual layers next to the combined output (--output soundtrack.wavsoundtrack.music.m4a).
  • context7.json at the repo root — folder exclusions plus Python-flavored agent rules, including the new sound endpoints, the ducking tri-state gotcha, stem semantics, and the free trial.
  • CI + publishing: ci.yml installs and tests all three packages; new publish-cli.yml mirrors the video-kit OIDC trusted-publishing workflow (tag prefix sonilo-cli-v*).

Note on ducking

ducking is default-ON server-side, and build_v2s_parts only emits a boolean when it isn't None. The CLI therefore forwards None when --no-ducking is absent and False only when it's passed — forwarding a plain store_true default of False would have silently disabled the server default. Same tri-state for preserve_speech. Both directions are covered by tests that assert the field is absent from the form body when the flag is unset, not merely that it's false.

Dependency pin

sonilo-cli pins sonilo>=0.5,<0.6. The original >=0.4,<0.5 excluded 0.5.0 and would have reproduced the ResolutionImpossible that sonilo-video-kit just hit and fixed by widening to <0.6.

Not included — needs the account owner

  • First PyPI publish of sonilo-cli: for a brand-new project name, a PyPI Trusted Publisher must be configured for sonilo-cli before the first tag push, or the publish step fails. That's a PyPI org-settings action.
  • Registering the repo on Context7: context7.json is ready, but claiming the library at context7.com requires signing in there.

Test plan

  • pytest sonilo-cli → 28 passed
  • Full repo pytest (SDK) → 167 passed; pytest sonilo-video-kit → 52 passed (no regression)
  • 3-package editable install resolves cleanly against sonilo 0.5.0
  • Error paths: missing API key, invalid key (401 surfaced cleanly, no traceback), missing required flag, unknown command / unknown tasks subcommand, --video + --video-url together — all exit 1 with a one-line sonilo: message
  • Verified live against the production API: account and usage --days 7 return real data; text-to-music --duration 5 → valid 5.06s MP4/M4A (streaming path); text-to-sfx --duration 2 → valid 2.04s 16-bit/44.1kHz WAV (async submit → poll → presigned download). Billing confirmed to apply the documented minimums (5s music + 2s sfx billed as 10s + 3s).
  • video-to-sound / video-to-video-sound not live-tested (respx-stubbed only) — same submit/poll/download code paths as the tested commands

@sapient-app

sapient-app Bot commented Jul 22, 2026

Copy link
Copy Markdown

Sapient docs evals

Waiting for the staging docs URL before running evals.

Sapient will start the selected PR evals automatically when GitHub reports a successful docs deployment for this PR. This usually happens within 15 minutes.

Commit: eae756b
Status: waiting for staging docs URL

…nilo 0.5.x

The 0.5.0 SDK release adds these two endpoints and the CLI's `sonilo>=0.4,<0.5`
pin excluded it, making the packages unresolvable together. Widen the pin and
wire up both commands, being careful that unset --no-ducking/--preserve-speech
forward None (not False) so the server's default-ON ducking isn't silently
disabled.
@spencer-zqian
spencer-zqian merged commit df5352b into main Jul 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant