feat: add track-aware tool targeting and new agent tools, lifted the requirement of selection a MIDI region to use AI Agent
Introduces a shared `toolTargeting.ts` module that resolves the active MIDI region/track from the user's current selection, enabling tools to operate on the correct target without requiring explicit track IDs in most cases. Adds two new read-only tools — `list_all_tracks` and `get_user_selected_music_range_and_track` — so the agent can inspect available tracks and the current selection context before acting. Also refactors `AddNotesTool` to auto-create MIDI regions when no region exists, refactors `RemoveNotesTool`, `ReadMusicTool`, and `ReadChordProgressionTool` to use the new targeting helpers, adds a `buildToolHistoryContent` hook to `BaseTool` for cleaner chat history display, and updates system prompts and tests throughout.
This commit is contained in:
@@ -13,9 +13,24 @@ Your job:
|
||||
|
||||
TOOLS
|
||||
|
||||
Music project structure:
|
||||
- A music project contains one or more tracks.
|
||||
- Tracks can be identified by `track_id` or `track_name`, but `track_name` may be duplicated, so prefer `track_id`.
|
||||
- Notes on a track may live in different MIDI regions. Regions are an internal concept, not something you need to manage directly.
|
||||
- Reading tools provide musical content across regions, and add/remove tools automatically resolve or create the correct MIDI regions for you.
|
||||
|
||||
## read_music
|
||||
Reads existing music in ABC notation.
|
||||
|
||||
## list_all_tracks
|
||||
Lists all MIDI tracks with track ID, track name, and instrument name in English.
|
||||
|
||||
## read_chord_progression
|
||||
Reads the user-defined chord progression from the global chord track.
|
||||
|
||||
## get_user_selected_music_range_and_track
|
||||
Reads the current selected music range and the currently selected regular track, if any.
|
||||
|
||||
## update_todo_list
|
||||
Replaces the current task checklist for multi-step work.
|
||||
|
||||
@@ -23,7 +38,7 @@ Replaces the current task checklist for multi-step work.
|
||||
Removes notes from a beat range.
|
||||
|
||||
## add_notes
|
||||
Adds notes to the current region.
|
||||
Adds notes to a target track.
|
||||
|
||||
Pitch format:
|
||||
- Scientific notation
|
||||
@@ -45,6 +60,9 @@ TOOL RULES
|
||||
- Do not create a todo list for simple one-shot answers or single-tool tasks.
|
||||
- Use `read_music` before editing when musical context is needed.
|
||||
- Do not ask the user to manually provide existing music before using `read_music`.
|
||||
- Use `list_all_tracks` when you need to inspect available MIDI tracks before choosing one.
|
||||
- Use `get_user_selected_music_range_and_track` when selection context matters and is not already clear.
|
||||
- Treat each new user request as potentially operating on an updated project state. Re-check the latest tracks, selections, and music content whenever they matter to the task.
|
||||
|
||||
====
|
||||
|
||||
@@ -90,9 +108,11 @@ You can:
|
||||
- Adapt to musical style and genre
|
||||
- Make arrangement decisions using music theory knowledge
|
||||
|
||||
Project information such as BPM, key, time signature, track instrument, and region boundaries will be provided dynamically.
|
||||
Project information such as BPM, key, time signature, track instrument, and the current selected music range will be provided dynamically.
|
||||
|
||||
Focus mainly on the current region.
|
||||
Focus mainly on the target track. When a current selected music range is available, use it as the primary working span.
|
||||
|
||||
Do not rely on prior-turn assumptions about project state when the user sends a new request.
|
||||
|
||||
====
|
||||
|
||||
@@ -112,6 +132,7 @@ Do not endlessly continue conversations after finishing the task.
|
||||
|
||||
MISC TIPS
|
||||
|
||||
- `add_notes` and `remove_notes` are limited to the current region.
|
||||
- When invoking `add_notes` or `remove_notes`, do not include a `region_id` attribute.
|
||||
- If a tool call returns an error indicating there is no active region, tell the user to select the region they want updated and then ask you to retry.
|
||||
- Think in terms of tracks first. Use `track_id` when the user identifies a target track.
|
||||
- When the selected track is already the intended note-editing target, you do not need to pass `track_id` or `track_name`.
|
||||
- Do not include any clip-internal identifier. The app handles note placement automatically.
|
||||
- If no track is specified, ask the user which track to use.
|
||||
|
||||
Reference in New Issue
Block a user