- approval cards: one plain question per tool call (server/agent/ask.mjs maps commands and files to sentences; src/lib/ask.ts holds the translated templates), a compact calm card, the exact command under Details - Tasks: the opened task shows schedule, what it may do, last result, instructions and last answer; back link before the title like the chat's navbar; pause/resume and delete icons, Edit, Run now; pause and play icons added to the sprite - Models: 'This computer' shows graphics memory and RAM bars with what the chosen version takes, and one plain line about the SSD (src/lib/native-fit.ts, from the catalog's memory_gb and the hardware report; the n-gram table is not counted) - Models: one-line version list: Recommended (the fixed four), Swift, GSQ-RCO, NVFP4, Gyro, Unsloth groups, Use your own GGUF; RAM+VRAM in bold, download size muted, 'Uses SSD N GB' only where it applies - Tune: five steps with their own animated icons and states, a live speed readout and sparkline, a result card with the gain and what it was saved as; reduced motion respected; the tuner now reports each measurement's speed - catalog: memory_gb and mem_total per version (tools/strata_mcp.py) - tests: ask, native-fit, tune-phase, autotune speeds, memory figures; headless checks (ui-flows ui2/ui2d, scripts/approval-flow.mjs), light and dark
54 lines
3.8 KiB
JavaScript
54 lines
3.8 KiB
JavaScript
/** Item 2: an approval card asks in plain words; the exact command stays in the card's Details. */
|
|
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { askFor } from '../server/agent/ask.mjs';
|
|
import { TurnProjector } from '../server/agent/events.mjs';
|
|
|
|
const sh = command => askFor('pwsh', { command });
|
|
const ev = (type, data, seq = 1, time = 1000) => ({ type: 'event', event: { type, seq, time, data } });
|
|
|
|
test('opening a folder is asked as opening that folder, with the common ones by name', () => {
|
|
assert.deepEqual(sh('Start-Process explorer.exe -ArgumentList "C:\\Users\\Ana\\Documents"').id, 'open-known-folder');
|
|
assert.deepEqual(sh('Start-Process explorer.exe -ArgumentList "C:\\Users\\Ana\\Documents"').params, ['Documents']);
|
|
assert.deepEqual(sh('explorer.exe C:\\Users\\Ana\\Downloads').params, ['Downloads']);
|
|
assert.deepEqual(sh('Start-Process explorer.exe C:\\work\\Reports'), { id: 'open-folder', params: ['Reports'], why: 'opens-window', detail: 'C:\\work\\Reports' });
|
|
assert.equal(sh('Invoke-Item C:\\work\\plan.pdf').id, 'open-file');
|
|
assert.equal(sh('explorer.exe').id, 'open-explorer');
|
|
});
|
|
|
|
test('running a program, deleting, creating and copying are named for what they are', () => {
|
|
assert.deepEqual(sh('Start-Process "C:\\Users\\Ana\\Downloads\\setup.exe" -ArgumentList /S').params, ['setup.exe']);
|
|
assert.equal(sh('Start-Process "C:\\Users\\Ana\\Downloads\\setup.exe" -ArgumentList /S').id, 'run-program');
|
|
assert.deepEqual(sh('Remove-Item C:\\tmp\\old.txt -Force'), { id: 'delete', params: ['old.txt'], why: 'delete-why', detail: 'C:\\tmp\\old.txt' });
|
|
assert.equal(sh('rm -rf build').id, 'delete');
|
|
assert.equal(sh('New-Item -ItemType File -Path C:\\Users\\Ana\\Desktop\\notes.txt').id, 'create-file');
|
|
assert.equal(sh('mkdir C:\\work\\out').id, 'create-folder');
|
|
assert.equal(sh('Copy-Item a.txt b.txt').id, 'copy');
|
|
assert.equal(sh('Get-Date | Out-File C:\\x\\a.txt').id, 'write-file');
|
|
assert.equal(sh('echo hi > notes.txt').params[0], 'notes.txt');
|
|
assert.deepEqual(sh('git push origin main'), { id: 'git', params: ['push'], why: 'changes-repo' });
|
|
assert.equal(sh('npm install left-pad').id, 'install');
|
|
assert.equal(sh('python build.py').id, 'run-script');
|
|
});
|
|
|
|
test('files the agent writes or edits, and the tools that are not commands', () => {
|
|
assert.deepEqual(askFor('write', { file_path: 'C:/Users/Ana/Desktop/notes.txt' }), { id: 'create-file', params: ['notes.txt'], why: 'replaces-if-exists', detail: 'C:/Users/Ana/Desktop/notes.txt' });
|
|
assert.equal(askFor('edit', { file_path: 'C:/a/b.md' }).id, 'change-file');
|
|
assert.equal(askFor('job_kill', {}).id, 'stop-task');
|
|
assert.deepEqual(askFor('web_fetch', { url: 'https://example.com/a?b=1' }).params, ['example.com']);
|
|
assert.deepEqual(askFor('mcp__github__create_issue', {}).params, ['github / create_issue']);
|
|
});
|
|
|
|
test('what it cannot read it does not pretend to: a generic question, with the model\'s own description when there is one', () => {
|
|
assert.deepEqual(sh('foo --bar'), { id: 'run-command', params: [], why: 'run-command-why' });
|
|
assert.equal(askFor('pwsh', { command: 'foo --bar' }, 'Rebuild the index').detail, 'Rebuild the index');
|
|
assert.equal(sh('Get-Date; Remove-Item x.txt').id, 'run-steps', 'two different steps are said to be steps');
|
|
});
|
|
|
|
test('the card carries the question, and the exact command stays in its arguments for Details', () => {
|
|
const p = new TurnProjector({ startedAt: 0 });
|
|
const card = p.consume(ev('tool/call', { callId: 'a1', name: 'pwsh', arguments: JSON.stringify({ command: 'Start-Process explorer.exe -ArgumentList "C:\\Users\\Ana\\Documents"', description: 'Open Documents' }) }))[0].tool;
|
|
assert.equal(card.ask.id, 'open-known-folder'); assert.deepEqual(card.ask.params, ['Documents']);
|
|
assert.match(card.preview, /Start-Process explorer\.exe/, 'the command is still sent for the Details disclosure');
|
|
});
|