Comments: trim to the established cadence

The MCP code came in with 5–8 line file headers, JSDoc on every
one-line wrapper, and inline explanations that referenced the PR
itself ("so the MCP server can reuse it") — none of which matches
api/server.js or frontend/src/lib/, where comments are one-line,
fact-shaped and never mention the change that introduced them.

Trimmed across mcp/src/*.js, i18n-core.js, i18n.js, exercises.js,
format.js, mcp/test/tools.test.js, mcp/vitest.config.js and
mcp/README.md. Tool prefaces lost their numbers; duplicate fs.watch
rationale folded into one; the ASCII import diagram in the README
replaced with a paragraph; the cross-references and self-references
removed. Also fixed two real defects: a corrupted Cyrillic word in a
state.js comment and a missing space in a tools.test.js comment.

No code changes; 92 frontend + 32 MCP tests still pass.
This commit is contained in:
Pengboi committed 2026-07-26 19:47:52 +01:00
1 parent 4143ab8676
commit 6aaf2a3eea
11 files changed
+93 -245

No files matched your search

+1 -3
View File
@@ -1,6 +1,4 @@
import { EXDB } from './exercises-data.js'
// Imports i18n-core (not i18n.js) so this stays loadable from plain Node — the MCP server
// reuses EXIDX/musclesOf/etc. without dragging in the React + Vite-only i18n.js.
import { t } from './i18n-core.js'
export { EXDB }
@@ -31,7 +29,7 @@ export const allExercises = st => [...(st.customEx || []), ...EXDB]
// Media normally sits next to the app (img/ and gif/, mounted into the web container).
// A build can point them somewhere else — the demo build pulls them off a CDN instead of
// shipping ~140 MB of images into the deployment. `import.meta.env` is undefined in plain
// Node; guard with `?.` so this module is loadable from Node without Vite (see i18n-core.js).
// Node; the guard keeps this module loadable without Vite.
const ENV = import.meta.env || {}
const IMG_BASE = ENV.VITE_IMG_BASE || 'img/'
const GIF_BASE = ENV.VITE_GIF_BASE || 'gif/'
-2
View File
@@ -1,6 +1,4 @@
// Formatting + date helpers (ported from the vanilla app, unit taken from the store where needed).
// Imports i18n-core (not i18n.js) so this pure helper stays loadable from plain Node — that's
// what lets the MCP server reuse it instead of reimplementing number/date formatting.
import { dateLocale, t } from './i18n-core.js'
export const todayISO = () => {
const d = new Date()
+10 -24
View File
@@ -1,13 +1,6 @@
// Pure, runtime-agnostic core of the i18n module.
//
// Split out of i18n.js so the pure-function training helpers (format.js, exercises.js and
// everything they import transitively — history, progression, onerm, muscles, demoSeed) can
// be required from plain Node too. That reuse is what lets the MCP server compute 1RM, muscle
// balance and progression prescriptions without re-implementing them — the same code that
// produces the numbers shown in the UI produces the numbers an LLM answers with.
//
// Everything browser-specific (React subscription hook, Vite's import.meta.glob lazy-loads of
// locale packs) stays in i18n.js, which re-exports these readers verbatim.
// Runtime-agnostic core of the i18n module: state, constants and readers (t, dateLocale,
// instrFor, getLang). Plain Node-loadable — the browser-only pieces (import.meta.glob lazy
// loads, the React subscription hook) live in i18n.js and re-export from here.
export const LANGS = {
en: 'English', de: 'Deutsch', es: 'Español', fr: 'Français', it: 'Italiano',
@@ -20,12 +13,10 @@ export const DATE_LOCALES = {
pl: 'pl-PL', tr: 'tr-TR', ru: 'ru-RU', zh: 'zh-CN', ko: 'ko-KR', hi: 'hi-IN'
}
// Mutable module state. `lang`/`dict`/`instr` are the readers' inputs; the browser-side
// `setLang` (in i18n.js) is the only writer, so they stay private to this module.
let lang = 'en'
let dict = {}
let instr = null // { exId: [steps] } for the current language, null = English
let version = 0
let lang = 'en' // set only by _setLangState, called from i18n.js setLang
let dict = {} // current locale pack (empty = English fallback)
let instr = null // { exId: [steps] } for the current language, null = English
let version = 0 // bumped on every setLang; drives the React subscription selector
export const getLang = () => lang
export const dateLocale = () => DATE_LOCALES[lang] || 'en-GB'
@@ -41,14 +32,9 @@ export function t(s, ...args) {
// Instructions for an exercise in the current language (English steps as fallback).
export const instrFor = ex => (instr && instr[ex.id]) || ex.st || []
/**
* Internal setter invoked by i18n.js's `setLang` once the locale pack has been loaded.
* Kept here — rather than just exported as `setLang` — because loading packs requires
* Vite's `import.meta.glob`, which would drag this file straight back into not being
* Node-safe. Returns the new version so the caller can notify its React subscribers.
*
* Both `dict` and `instr` may be passed as `null` to reset to English.
*/
// Called by i18n.js's setLang once the locale pack has been loaded — kept here rather than
// exported as setLang because loading packs requires import.meta.glob, which is Vite-only.
// Both `dict` and `instr` may be null to reset to English.
export function _setLangState(newLang, newDict, newInstr) {
lang = LANGS[newLang] ? newLang : 'en'
dict = lang === 'en' ? {} : (newDict || {})
+4 -11
View File
@@ -1,10 +1,7 @@
// Browser-only shell of the i18n module.
//
// Pure state, constants and readers (t, dateLocale, instrFor, getLang, LANGS, INSTR_LANGS)
// live in i18n-core.js so plain Node can reuse the training logic without a Vite environment.
// This file adds the two pieces that genuinely need the browser: the async `setLang` (which
// lazy-loads locale packs via import.meta.glob) and the React subscription hook `useLang`
// (which re-renders components on language switch).
// Browser-only shell of the i18n module. The runtime-agnostic state and readers live
// in i18n-core.js (plain Node-loadable); this file adds the two pieces that genuinely need
// the browser: `setLang` (which lazy-loads locale packs via import.meta.glob) and the React
// subscription hook `useLang`.
import { useSyncExternalStore } from 'react'
import {
@@ -12,8 +9,6 @@ import {
getLang, dateLocale, t, instrFor, getVersion, _setLangState
} from './i18n-core.js'
// Re-export everything verbatim so existing callers (`import { t } from '../lib/i18n.js'`)
// keep working unchanged — the split is invisible at the import site.
export { LANGS, INSTR_LANGS, DATE_LOCALES, getLang, dateLocale, t, instrFor }
// Vite code-splits each locale pack into its own chunk via import.meta.glob; instructions use
@@ -27,8 +22,6 @@ const notify = () => { subs.forEach(f => f()) }
export async function setLang(l) {
if (!LANGS[l]) l = 'en'
// _setLangState mutates core state and bumps the version; we read it back for the
// subscription selector below.
if (l === getLang() && getVersion() > 0) return
let dict = {}, instr = null
try {