Files
SoulStream/handoff/tools/audit-commands.cjs
T
KeelrLeek 9f0601027c android: the handoff — the pending rounds, the pipeline, and what is unverified
Everything written this session that has not been through the device: rounds 43
to 48 (each patch adversarially verified, 43's transient-notice expectation
fixed), a partial round 49, the pipeline scripts, the Android Auto design and
the icon comparison mock. Also the two harness changes that were never A/B'd —
adaptive waits, which may only shorten a declared wait and never lengthen it,
and a ship that runs the mock walk and the deploy at the same time. The A/B and
its 255-step baseline are in handoff/tools; main stays at what the phone has
actually walked.
2026-09-14 07:57:41 -05:00

31 lines
1.9 KiB
JavaScript

// Which backend commands does the phone never call? The remaining feature
// surface, by fact rather than by memory. A command counts as used when its
// api.js wrapper is referenced from src/mobile or the shared modules the
// phone imports, or when it is invoked by name there.
const fs = require('fs');
const path = require('path');
const root = 'F:/Coding/SoulStream/';
const read = (p) => fs.readFileSync(root + p, 'utf8');
const api = read('src/lib/api.js');
const fnByCmd = {};
for (const m of api.matchAll(/export const (\w+) = [\s\S]*?invoke\(\s*"([a-z_:|]+)"/g)) if (!fnByCmd[m[2]]) fnByCmd[m[2]] = m[1];
for (const m of api.matchAll(/export (?:async )?function (\w+)\b[\s\S]*?invoke\(\s*"([a-z_:|]+)"/g)) if (!fnByCmd[m[2]]) fnByCmd[m[2]] = m[1];
const walk = (d) => fs.readdirSync(root + d, { withFileTypes: true }).flatMap((e) => e.isDirectory() ? walk(d + '/' + e.name) : [d + '/' + e.name]);
const phone = [...walk('src/mobile'), 'src/lib/sources.js', 'src/lib/catalogMatch.js', 'src/lib/events.js', 'src/lib/localReleaseType.js', 'src/lib/editions.js']
.filter((p) => fs.existsSync(root + p)).map(read).join('\n');
const cmds = new Set();
for (const f of fs.readdirSync(root + 'src-tauri/src').filter((x) => x.endsWith('.rs'))) {
const s = read('src-tauri/src/' + f);
for (const m of s.matchAll(/#\[tauri::command\][^\n]*\n(?:[^\n]*\n)?\s*(?:pub\s+)?(?:async\s+)?fn\s+(\w+)/g)) cmds.add(m[1]);
}
const used = [];
const unused = [];
for (const c of [...cmds].sort()) {
const fn = fnByCmd[c];
const hit = (fn && new RegExp('\\b' + fn + '\\b').test(phone)) || new RegExp('"' + c + '"').test(phone);
(hit ? used : unused).push(c + (fn ? '' : ' (no api wrapper)'));
}
console.log(cmds.size + ' commands: ' + used.length + ' called from the phone, ' + unused.length + ' never');
console.log('--- never called from the phone ---');
console.log(unused.join('\n'));