Files
Strata/app/host/scripts/tools-shots.mjs
T
Niko1221 4058aa782b Layout move for 0.2.16: the top level becomes app/, engine/, terminal/, docs/, tools/ and .github/
Made by tools/layout/move_0216.py (the commit before this one) on db8e0be9c, the final code head of 0.2.16:
- 75 git mv (renames, so `git log --follow` and blame keep working; packaging/acceptance_matrix.md shows as delete + add because its links
  changed too) and 3 removals: SETUP.bat, UPDATE.bat and update.sh (setup.py --update pulls the code now);
- 1,425 path edits in 307 files: root-relative paths in CI, Docker, .gitignore and the release scripts; Markdown links; Python and
  Node joins from a root that moved with its folder; explicit edits for code that computes a root or names a moved path; tables of
  repository paths inside tests.

engine/ holds what CMake builds (src, include, cmake, metal, sycl, spark, third_party, the C++ tests and benches). app/ is the desktop
app and its host (was apps/). terminal/ is the Terminal in the layout of the installed one (strata.py, setup.py, strata_cli,
strata_control, serve, bin, data, ref, crates, the Python tools and tests). docs/ has the documentation, docs/lang/ the translated
READMEs, docs/history and docs/bench-results. tools/ has the repository's own checks, packaging, docker, research and nix.
tests/core/test_tqp_ref.py is a pytest file and stays with the Python tests (terminal/tests/core/).
AGENTS.md, README.md, LICENSE, setup.sh and START-HERE.bat stay at the root.

No behaviour change: the same command lines, the same sources. For this head a replay of the script gave the same numbers and the path
scan (tools/layout/checks/path_scan.py) reports no hit; the suites and the builds run on this commit next.
2026-11-17 13:19:21 +01:00

82 lines
6.1 KiB
JavaScript

/**
* Settings -> Tools screenshots from the real UI. The host's /api/agent/tools answer is replaced by a fixture (page.route) so every state can be
* shown without a model or a Harness.
*
* STRATA_URL=http://127.0.0.1:8899 SHOTS=./tools-shots node scripts/tools-shots.mjs
*/
import { chromium } from 'playwright-core';
import { existsSync, mkdirSync } from 'node:fs';
import { join, resolve } from 'node:path';
const BASE = process.env.STRATA_URL;
if (!BASE) { console.error('STRATA_URL is required'); process.exit(2); }
const SHOTS = resolve(process.env.SHOTS ?? 'tools-shots');
mkdirSync(SHOTS, { recursive: true });
const CHROME = process.env.CHROME ?? ['C:/Program Files/Google/Chrome/Application/chrome.exe', '/usr/bin/google-chrome'].find(existsSync);
const group = (id, name, about, area, asks = false, enabled = true) => ({ id, name, about, area, asks, enabled });
const GROUPS = [
group('shell', 'Run commands', 'Lets the assistant run commands, for example to open a folder or start a program.', 'computer', true),
group('files', 'Read and change files', 'Lets the assistant read, create and edit files in your chat folder.', 'computer', true),
group('find', 'Find files and text', 'Lets the assistant look for files by name and search inside them. It only reads.', 'computer'),
group('jobs', 'Long-running jobs', 'Lets the assistant start a slow command in the background and check on it later.', 'computer', true),
group('fetch', 'Open web pages', 'Lets the assistant read a web page you point it to.', 'web'),
group('search', 'Search the web', 'Lets the assistant search the web when it needs fresh information.', 'web'),
group('helpers', 'Helper assistants', 'Lets the assistant start helpers that work on parts of a task at the same time.', 'together'),
group('goals', 'Goals', 'Lets you give a goal with /goal. The assistant keeps working until it is done.', 'together'),
group('todo', 'To-do list', 'Lets the assistant keep a checklist while it works on a big task.', 'together'),
group('skills', 'Skills', 'Lets the assistant use your saved skills when they fit the task.', 'together'),
group('present', 'Show results', 'Lets the assistant show a page or file in the preview next to the chat.', 'together'),
];
const base = () => ({ groups: GROUPS.map(g => ({ ...g })), search: { provider: 'builtin', keySet: false }, browser: { enabled: false, found: true, name: 'Google Chrome' }, custom: [] });
const STATES = {
fresh: base(),
busy: (() => { const s = base(); s.groups[3].enabled = false; s.groups[5].enabled = false; s.browser.enabled = true;
s.custom = [
{ id: 'c1', name: 'Release notes', about: 'Write release notes in our house style.', kind: 'instructions', enabled: true, summary: 'Start with a one-line summary…' },
{ id: 'c2', name: 'Check website', about: 'Check that our website answers.', kind: 'command', enabled: true, summary: 'curl -I https://example.com', command: 'curl -I https://example.com' },
{ id: 'c3', name: 'Issue tracker', about: 'Look up and update issues.', kind: 'server', enabled: false, summary: 'https://issues.example/mcp', address: 'https://issues.example/mcp' },
]; return s; })(),
key: (() => { const s = base(); s.search = { provider: 'exa', keySet: false }; return s; })(),
nobrowser: (() => { const s = base(); s.browser = { enabled: false, found: false, name: null }; return s; })(),
};
const browser = await chromium.launch({ executablePath: CHROME, headless: true });
let page = null, context = null;
let current = 'fresh';
const shot = async name => { await page.waitForTimeout(500); await page.screenshot({ path: join(SHOTS, `${name}.png`) }); console.log(`shot ${name}.png`); };
const open = async state => {
current = state;
if (!page) {
context = await browser.newContext({ viewport: { width: 1360, height: 980 } });
page = await context.newPage();
page.on('pageerror', e => console.log('pageerror', e.message.slice(0, 300)));
page.on('console', m => { if (m.type() === 'error') console.log('console', m.text().slice(0, 300)); });
await page.route('**/api/agent/tools**', route => route.fulfill({ status: 200, contentType: 'application/json', body: JSON.stringify(STATES[current]) }));
await page.goto(`${BASE}/`);
const skip = page.getByText('Go straight to the app');
await skip.waitFor({ timeout: 8000 }).then(() => skip.click()).catch(() => {});
await page.goto(`${BASE}/#/settings`);
await page.waitForSelector('#settings-tab-Tools', { timeout: 20000 });
await page.locator('#settings-tab-Tools').evaluate(el => el.click());
} else {
// The Tools panel loads its list when it is shown: leave it and come back to load the next fixture.
await page.locator('#settings-tab-Appearance').evaluate(el => el.click());
await page.waitForTimeout(300);
}
await page.locator('#settings-tab-Tools').evaluate(el => el.click());
await page.waitForSelector('.settings-tools', { timeout: 10000 });
};
await open('fresh'); await shot('01-tools-top');
await page.getByRole('heading', { name: 'Web search' }).evaluate(el => el.scrollIntoView({ block: 'start' })); await shot('02-tools-web-and-browser');
await open('busy'); await page.getByRole('heading', { name: 'Your own tools' }).evaluate(el => el.scrollIntoView({ block: 'start' })); await shot('03-your-own-tools');
await open('key'); await page.getByRole('heading', { name: 'Web search' }).evaluate(el => el.scrollIntoView({ block: 'start' })); await shot('04-search-with-key');
await open('nobrowser'); await page.getByRole('heading', { name: 'Web browser' }).evaluate(el => el.scrollIntoView({ block: 'start' })); await shot('05-no-browser-found');
await open('fresh');
await page.getByRole('button', { name: 'Add a tool' }).click(); await shot('06-add-tool-instructions');
await page.getByRole('dialog').getByLabel('How it works').click();
await page.getByRole('option', { name: 'Run a command' }).click(); await shot('07-add-tool-command');
await page.getByRole('dialog').getByLabel('How it works').click();
await page.getByRole('option', { name: 'Connect a tool server (MCP)' }).click(); await shot('08-add-tool-server');
await browser.close();