mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
refactor: separate local voice handlers and instructions
This commit is contained in:
1 parent
318d37ad8d
commit
638902296a
17 files changed
+1094
-951
No files matched your search
@@ -648,7 +648,7 @@ test('the DISPLAY rail starts collapsed on a first run, and a stored choice wins
|
||||
// ── Voice: instruction-only, tool schema byte-unchanged ─────────────────────
|
||||
|
||||
test('the voice TOOL SCHEMA is byte-identical to main — the mission mapping is instructions only', () => {
|
||||
const src = fs.readFileSync(new URL('../server/providers/local.js', import.meta.url), 'utf8');
|
||||
const src = fs.readFileSync(new URL('../server/providers/openai/tools.js', import.meta.url), 'utf8');
|
||||
const start = src.indexOf('const GEV_REALTIME_TOOLS = [');
|
||||
assert.ok(start > 0, 'GEV_REALTIME_TOOLS must still be a single literal array');
|
||||
const end = src.indexOf('\n];\n', start);
|
||||
@@ -666,16 +666,18 @@ test('the voice TOOL SCHEMA is byte-identical to main — the mission mapping is
|
||||
'the first-run missions must ride EXISTING tools: no schema edit, no cache bust',
|
||||
);
|
||||
|
||||
const instructions = fs.readFileSync(new URL('../server/providers/openai/instructions.js', import.meta.url), 'utf8');
|
||||
|
||||
// ...and the mapping that makes them reachable by voice is one instruction
|
||||
// string, whose rollback is deleting that string. Anchored to a LIVE array
|
||||
// entry — a quote at the start of its own line — so commenting the paragraph
|
||||
// out reads as the removal it is, not as a passing substring match.
|
||||
assert.match(
|
||||
src,
|
||||
instructions,
|
||||
/\n\s+'NAMED VIEWS are shorthand/,
|
||||
'the mission mapping must be an active instruction entry, not commented out',
|
||||
);
|
||||
const mapping = src.slice(src.indexOf('NAMED VIEWS are shorthand'));
|
||||
const mapping = instructions.slice(instructions.indexOf('NAMED VIEWS are shorthand'));
|
||||
const paragraph = mapping.slice(0, mapping.indexOf("',\n"));
|
||||
for (const layerId of [
|
||||
'local-datacenters', 'local-dams', 'telegeography-submarine-cables', 'local-firms', 'earthquakes',
|
||||
@@ -687,7 +689,7 @@ test('the voice TOOL SCHEMA is byte-identical to main — the mission mapping is
|
||||
});
|
||||
|
||||
test('every layer a mission drives is already in the shipped set_layer_visibility enum', () => {
|
||||
const src = fs.readFileSync(new URL('../server/providers/local.js', import.meta.url), 'utf8');
|
||||
const src = fs.readFileSync(new URL('../server/providers/openai/tools.js', import.meta.url), 'utf8');
|
||||
const tool = src.slice(src.indexOf("name: 'set_layer_visibility'"), src.indexOf("name: 'show_data_layers_menu'"));
|
||||
const missionLayerIds = Object.values(FIRST_RUN_MISSIONS).flatMap((mission) => mission.layerIds || []);
|
||||
assert.ok(missionLayerIds.length > 0);
|
||||
|
||||
@@ -8,7 +8,7 @@ const ui = readFileSync(new URL('./ui.js', import.meta.url), 'utf8');
|
||||
const radio = readFileSync(new URL('./data/radio.js', import.meta.url), 'utf8');
|
||||
const rocketLaunches = readFileSync(new URL('./data/rocketLaunches.js', import.meta.url), 'utf8');
|
||||
const realtime = readFileSync(new URL('./voice/gevRealtime.js', import.meta.url), 'utf8');
|
||||
const voice = readFileSync(new URL('../server/providers/local.js', import.meta.url), 'utf8');
|
||||
const voice = ['tools', 'instructions'].map(name => readFileSync(new URL(`../server/providers/openai/${name}.js`, import.meta.url), 'utf8')).join('\n');
|
||||
const css = readFileSync(new URL('../style.css', import.meta.url), 'utf8');
|
||||
|
||||
/** Parse the Realtime tool array out of the Vite config as real data. */
|
||||
|
||||
@@ -2,7 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import test from 'node:test';
|
||||
|
||||
const voiceConfig = readFileSync(new URL('../../server/providers/local.js', import.meta.url), 'utf8');
|
||||
const voiceConfig = readFileSync(new URL('../../server/providers/openai/instructions.js', import.meta.url), 'utf8');
|
||||
const realtime = readFileSync(new URL('./gevRealtime.js', import.meta.url), 'utf8');
|
||||
|
||||
test('aircraft identity narration acknowledges missing enrichment', () => {
|
||||
|
||||
@@ -35,7 +35,7 @@ test('every live basemap is reachable by its own id — no enum value without a
|
||||
assert.equal(normalizeStackId('Esri'), 'esri-imagery');
|
||||
assert.equal(normalizeStackId('esri imagery'), 'esri-imagery');
|
||||
// And the voice tool's enum must equal the set of live ids — no drift either way.
|
||||
const config = readFileSync(new URL('../../server/providers/local.js', import.meta.url), 'utf8');
|
||||
const config = readFileSync(new URL('../../server/providers/openai/tools.js', import.meta.url), 'utf8');
|
||||
const enumMatch = config.match(/enum: \[('photoreal'[^\]]*)\],\s*\n\s*description: 'photoreal = Google 3D/);
|
||||
assert.ok(enumMatch, 'set_map_stack enum literal must still be findable');
|
||||
const enumIds = enumMatch[1].split(',').map((s) => s.trim().replace(/^'|'$/g, ''));
|
||||
|
||||
Reference in new issue
Block a user