feat: implemented confirmation mechanism for tool invokation

This commit is contained in:
Xiaohan-Tian
2026-06-03 17:05:42 -07:00
parent 414565ecc9
commit ad1e0c2aa8
23 changed files with 860 additions and 84 deletions
+26
View File
@@ -50,6 +50,32 @@ describe('AddNotesTool', () => {
);
});
it('builds a confirmation summary for note creation', () => {
const track = new KGMidiTrack('Lead', 1);
const region = new KGMidiRegion('region-1', track.getId().toString(), track.getTrackIndex(), 'Verse Melody', 0, 32);
track.setRegions([region]);
const project = new KGProject('summary-project', 8, 0, 120, { numerator: 4, denominator: 4 }, 'C major');
project.setTracks([track]);
storeState.activeRegionId = region.getId();
vi.spyOn(KGCore, 'instance').mockReturnValue({
getCurrentProject: () => project,
getSelectedItems: () => [],
} as unknown as KGCore);
const tool = new AddNotesTool();
expect(tool.isReadOnlyTool()).toBe(false);
expect(tool.buildConfirmationContent({
notes: [
{ pitch: 'C4', start: 16, length: 4 },
{ pitch: 'E4', start: 20, length: 8 },
],
})).toBe(
'Allow creating 2 notes in region **Verse Melody** on track **Lead**, spanning bars 5 to 7?'
);
});
it('returns no compact summary when the target region cannot be resolved', () => {
const project = new KGProject('summary-project', 8, 0, 120, { numerator: 4, denominator: 4 }, 'C major');
vi.spyOn(KGCore, 'instance').mockReturnValue({