Files
OmniRoute/scripts/build/electronRuntimeDocs.mjs
Praveen K Palaniswamy 65e81158ab fix(ollama): route models by advertised capability (#11088)
Landed with the design call resolved per the owner's pick — **option 1**: the synced store is now endpoint-agnostic (persistDiscoveredModels and managedModelImport no longer drop non-chat models at write time), and chat selectability moved to read time (auto-pool expansion in autoStrategy applies filterChatSelectableModels; the models-route projection already had its chatOnly filter). Your discovery test now passes end-to-end (3/3): /api/show capabilities persist per connection and image/embedding requests route through the advertising host.

Reconciliation notes: conflicted areas merged onto the current tip (adobe discovery import, requestedModel preflight signature, resolvedProvider fast-path coexists with the synced-route override — explicit resolution wins); carried base-red drains (#10055 memoization, #11071 test variants) dropped as already-landed; the managed-model-import exclusion test was propagated to the new contract (image/video models persist; the read filter still hides them from chat pickers — pinned by a new assertion). Full battery: 205/206 focused (the one red is a confirmed periodic-timer timing flake on the loaded devbox — 20/20 isolated), autoCombo vitest 30/30, combo suites 46/46, gates + typecheck clean.

Thank you @yourspraveen — the capability probe + routing design was right; it just needed the store contract opened up. Fixes #11087.
2026-08-23 11:45:01 -03:00

66 lines
2.2 KiB
JavaScript

import { existsSync, lstatSync, readdirSync, rmSync } from "node:fs";
import { join, relative, resolve, sep } from "node:path";
export const ELECTRON_RUNTIME_DOC_PRUNE_RULES = Object.freeze({
localeRootFiles: Object.freeze(["CHANGELOG.md"]),
authoringDirectories: Object.freeze(["docs/research", "docs/superpowers"]),
});
function payloadSize(targetPath) {
const stat = lstatSync(targetPath);
if (!stat.isDirectory()) {
return { files: 1, bytes: stat.size };
}
return readdirSync(targetPath).reduce(
(total, entry) => {
const payload = payloadSize(join(targetPath, entry));
total.files += payload.files;
total.bytes += payload.bytes;
return total;
},
{ files: 0, bytes: 0 }
);
}
function removePayload(bundleRoot, relativePath, summary) {
const root = resolve(bundleRoot);
const targetPath = resolve(root, relativePath);
if (targetPath !== root && !targetPath.startsWith(`${root}${sep}`)) {
throw new Error(`[electron-docs] refusing to prune outside bundle root: ${relativePath}`);
}
if (!existsSync(targetPath)) return;
const payload = payloadSize(targetPath);
rmSync(targetPath, { recursive: true, force: true });
summary.removedFiles += payload.files;
summary.removedBytes += payload.bytes;
summary.removedPaths.push(relative(root, targetPath).split(sep).join("/"));
}
/**
* Remove docs that are useful while authoring OmniRoute but are never read by
* the packaged desktop runtime. Canonical docs remain untouched; bundleRoot is
* the disposable Electron staging directory.
*/
export function pruneElectronRuntimeDocs(bundleRoot) {
const summary = { removedFiles: 0, removedBytes: 0, removedPaths: [] };
const localesRoot = join(bundleRoot, "docs", "i18n");
if (existsSync(localesRoot)) {
for (const locale of readdirSync(localesRoot, { withFileTypes: true })) {
if (!locale.isDirectory()) continue;
for (const fileName of ELECTRON_RUNTIME_DOC_PRUNE_RULES.localeRootFiles) {
removePayload(bundleRoot, join("docs", "i18n", locale.name, fileName), summary);
}
}
}
for (const relativePath of ELECTRON_RUNTIME_DOC_PRUNE_RULES.authoringDirectories) {
removePayload(bundleRoot, relativePath, summary);
}
summary.removedPaths.sort();
return summary;
}