90aa802980203062cbe52abdccf05a5a766853da
11
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
90aa802980 |
La segunda opinión: un juicio sobre tus números, con la probabilidad que trae
Tests / test (push) Canceled after 0s
Publish Docker images / build (., ./web/Dockerfile, web) (push) Canceled after 0s
Publish Docker images / build (./api, ./api/Dockerfile, api) (push) Canceled after 0s
Preguntaste si se podía implementar Jev, y con qué API. Resulta que Jev se sirve por OpenCode Zen,
así que una sola cuenta cubre esto y cualquier otra cosa apuntada a ese gateway:
POST https://opencode.ai/zen/v1/systemone Bearer <clave> model: jev-1.13
Y ahí está la razón de que valga la pena: Jev no es un modelo de chat. Le mandás un *estado* y
preguntas tipadas — sí/no (`noul`), opción (`choice`), rúbrica (`score`) — y contesta todas en una
sola petición con el valor **y la probabilidad que le puso**. "62% probable" se puede discutir;
"tomate una semana de descarga" no. Así que no entra por el Coach (que necesita *escribir*) y no se
fuerza dentro de su lista de proveedores: tiene su módulo, sus dos rutas y su tarjeta.
Qué hace. En Salud, arriba de la grilla, una tarjeta con cuatro respuestas: qué tan listo estás para
entrenar fuerte (nivel 1-5, con el número al lado), si la semana pide bajar carga (62% probable), qué
parte del cuerpo parece menos recuperada, y qué métrica de salud merece atención — esa última con la
última lectura de la métrica que nombró, para que "vigilá tu frecuencia en reposo" venga con el 62
que lo motivó. La hoja detrás del ⓘ dice a dónde va y exactamente qué se envía, con el mismo resumen
que devuelve el servidor.
Lo que sale, y lo que no. Se decide en `api/jev.js` y son agregados: una semana de cada métrica por
campo como la escribió el teléfono, series por parte del cuerpo de 4 semanas y de la última, sesiones,
días desde la última, RPE medio, estancamientos *por nombre de ejercicio*, el último pesaje y su
cambio. Ningún identificador: ni perfil, ni nombre, ni títulos de entrenamientos, ni ids de
ejercicios, ni chat — hay un test que lo afirma sobre el JSON, porque es una promesa que hacen los
docs y nada más la miraba. La única excepción es deliberada y está documentada: la nota de
*limitaciones* del cuestionario del Coach, porque "hombro malo" cambia la respuesta. (Los títulos sí
estuvieron un rato ahí: los saqué al escribir ese test, y el test se quedó.)
Un juicio no es una instrucción, y el código lo trata así. Cada respuesta se muestra con su
probabilidad; una pregunta que el modelo no contestó se muestra como no contestada, nunca como un
cero; un nivel que no habíamos ofrecido se marca en vez de disfrazarse de propio; y si los datos
cambiaron desde que se pidió (una sesión registrada, una noche que llegó) la tarjeta lo dice en lugar
de seguir pareciendo actual. Tampoco corre por temporizador: cuesta una petición, así que pasa cuando
alguien aprieta *Preguntar*, con cupo por perfil y por día y un piso de diez minutos aplicados en el
servidor, no en la pantalla.
El Coach, además, lo recibe como `secondOpinion` en su payload **solo si tiene menos de seis horas**,
como evidencia con confianza adjunta para citar en `why`, nunca como una orden ni como un cambio de
plan. Es la mitad que faltaba de "y el Coach escribe con eso".
El lector de respuestas es tolerante a propósito: el contrato de la petición está documentado, la
respuesta no la vimos nunca del servicio real, así que acepta las formas plausibles
(`answers`/`results`, `option`/`answer`/`choice`, `probability` o una distribución sobre los niveles),
normaliza lo que encuentra y devuelve `null` por lo que no puede leer. El cuerpo crudo queda guardado
al lado del parseado (y sale con `?raw=1`): la primera llamada real se puede mirar, y una forma mal
adivinada es un arreglo, no un misterio.
Dos cosas que encontré escribiendo esto y que quedan arregladas: una variable de entorno vacía se
leía como **cero** (`Number('')` pasa un chequeo ingenuo), así que un cupo sin configurar era "cero
peticiones" — un feature que parece configurado y no funciona nunca; y agregar la palabra *Back*
para la espalda redefinió el botón *Atrás* de la app a "Espalda", porque en un objeto literal la
última clave gana y nada lo dice. El catálogo de español tiene ahora un test que falla si una clave
se escribe dos veces, mutación comprobada.
Cobertura: 11 tests del módulo (el estado, las preguntas, cada forma de respuesta, la promesa de
privacidad, el cupo), 5 de las rutas contra un gateway de mentira y el servidor real, 6 del modelo de
vista en el frontend y 5 de render por la tarjeta real. API 259 en verde, frontend 1696, build OK.
|
||
|
|
87bfd6d4c4 |
Rebrand to KuentaGYM, and start a new profile in pounds and Spanish
The app is now KuentaGYM everywhere a user can see it, and a fresh profile no longer starts on upstream's English/kg defaults. Both are this fork's decisions, so both are pinned by tests rather than left to a find-and-replace. Rename (1,270 references, 149 files) - Visible surfaces: the Login/Home/mobile-onboarding wordmark, the Settings version line, the printed plan, the PWA title + manifest, and the 17 branded strings across all 14 locale packs. - Infrastructure: repo links, the container images and the release endpoints now name git.dploy.lol/dsantillan/kuentagym; .gitea/workflows/docker-publish.yml publishes to this forge's registry instead of gitea.com. - The Android/iOS application id stays ch.duartesantos.opengym on purpose: changing it would make the mobile app a different app that could never update an installed copy. Three things the mechanical pass would have broken, fixed here - The update check asked gitlab.com for upstream's releases and would have installed upstream's APK, putting the old name back on the phone. It now reads this fork's Gitea releases API (the assets shape differs), with the tests rewritten to the payload Gitea actually returns. - Renaming the mobile state/pairing files (opengym-state.json, opengym-remote.json) would lose the on-device copy of a history whose WebView storage may have been evicted, and silently unpair the device. Both are read under their old names and written forward under the new ones. - Renaming the exported plan-file marker (openGym_plan) rejected every plan shared before the rename as "not a plan file". Both markers are accepted. Defaults: pounds and Spanish - DEF.unit = 'lb', DEF.lang = 'es', plus every fallback that independently assumed en/kg (the <html lang> attribute, the Settings pickers, the Store, the MCP, the Coach payload). - Server-generated push copy existed only in English and pt-BR, so a Spanish profile would have been notified in English; Spanish added. - The demo seed states unit: 'kg' — its seeded numbers are kilograms, and inheriting the new default would have introduced an 82.4 lb lifter benching 60. - The module-level language in i18n-core stays English: it is the only language whose strings need no pack, so `t()`, dates, numbers and lists agree before a pack loads. Starting there on 'es' formats a Spanish-shaped UI with English strings. Also - api/package.json's test glob missed push-messages.test.js and verify-error.test.js, which sat beside the modules they cover and never ran. - README, docs/, website/ and the issue templates no longer describe upstream's GitLab/GitHub pipeline, Discord, sponsorship or public demo as if they were this fork's; upstream history and attribution are preserved (NOTICE.md). |
||
|
|
b4feea6a2e | Merge !102: Workout view: Allow multiple routines | ||
|
|
d0aaa7205d |
Coach: a failed run on the phone says why, a message with no plan asks for one, the chat has context
- Phone with own key: the provider's or validator's reason reaches the chat line and toast (BYOK_ERRORS + jobErrorText); no more "instance owner" wording where there is none (#58) - CoachChat: a message with no routines refines/creates instead of reviewing an empty window; menu entry "Start a new plan" (Discord "Coach reset" thread) - payload: refine without a previous plan becomes a create with userNote; the last six chat lines travel as `conversation` (documented in common.md, prompts.js regenerated) - OpenAI model list cut to Chat-Completions models (isChatModel); Gemini placeholder names AQ. keys - 3 new strings in 14 packs, pt-BR guard 626/616/3db560d7; tests for all of it |
||
|
|
8b917b6331 |
Combine routines (ENG-9) phase 2: Coach — array-tolerant plan week
The plan fingerprint is computed in two runtimes that share no build step
(frontend/src/lib/coach.js and api/coach/core/) and must stay byte-for-byte
matched. Both now normalise every weekday to a routine-id list:
- canonicalPlan / cleanPlan: day value -> [].concat(S.week[d]); filter
S.week?.[d]?.length. A legacy bare string and a one-element list are
indistinguishable downstream.
- hashPlan (both): week join -> k + '=' + list.join('+'). A single-routine
plan's fingerprint is byte-identical to pre-upgrade — no false-stale storm.
- aggregates.plannedDays counts scheduled days, not routines.
- coach.js currentValue/markStale compare `week` by canonical join;
CHANGE_APPLY.week writes [c.after] (single-routine op, collapses a
combined day — same limitation as DayOverride); changeValues.fmt renders
a week array as " + "-joined routine names before the generic branch.
- prompts/common.md + review.md: plan.week is a list; a `week` change names
exactly one routine and replaces the day. core/prompts.js regenerated.
Tests: shared combined-day fixture (client hashPlan === server hashPlan),
legacy scalar vs one-element array identical, canonicalPlan order,
CHANGE_APPLY.week, markStale canonical compare, changeValues rendering.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JVbWJtoyQU4WgwFR4eAKgy
|
||
|
|
02c75b320d |
Coach: ein API-Key gilt fuer die ganze Instanz, Warm-ups zaehlen nicht, Retries bei 429/5xx, sichtbare Admin-Felder
- Instanz-Modus: nur eine persoenliche Anmeldung (Setup-Token/OAuth) bindet sich an das erste Profil, ein API-Key ist gemessen und wird von allen Profilen unter den Tageslimits geteilt. Die Bindung passiert jetzt wirklich beim Einreihen eines Jobs (jobs.enqueue), vorher gab es sie nur in den Tests. - HTTP-Adapter: 429/500/502/503/504/529 werden zweimal mit kurzer Pause wiederholt, ein 4xx nie. retryDelayMs fuer Tests. - Payload: Warm-up-Saetze wie in progression.js aus readSession/stalls, done/planned, Top-Satz, setsByBodyPart und workingWeights herausgefiltert; in vollen Sessions als warmup:true markiert, common.md sagt dem Modell, was das ist. - Admin-Karte: .field im Card hat jetzt eine sichtbare Flaeche, die Limit-Zahlenfelder sind echte Felder statt weisser Browser-Boxen; Text zu 'Whose account pays' unterscheidet API-Key und persoenliche Anmeldung. - Neuer Test e2e-apikey: Key ueber die Admin-Routen einlegen, Modelle listen, Review durch die echte Queue gegen einen lokalen Anthropic/OpenAI/Gemini-Stand-in, inkl. Header, Cache-Block, Schema, Retry und Auth-Fehler. api 150, frontend 1029, mcp 45 gruen. |
||
|
|
5116f8770d |
Coach: Regeln als cachebarer System-Prompt, Schema-erzwungenes JSON, halbierte Payload
Der Prompt ist gesplittet: die Regeln (byteidentisch pro Task) fahren als System-Message,
nur die Payload wechselt — ein llama.cpp/Ollama-Endpunkt trifft damit seinen KV-Prefix-Cache,
Anthropic cached den Block explizit (cache_control ephemeral). Die Payload selbst: kompaktes
JSON statt Einrueckung, volle Saetze nur fuer die letzten fuenf Sessions (aeltere als eine
Zeile pro Uebung; aggregates zaehlt Stalls ohnehin uebers ganze Fenster), Bibliothek als
{id,n,bp} und fuer Reviews auf 100 gedeckelt. ~14.600 Tokens pro Review vorher, ~5.900 jetzt
plus gecachter Prefix. Dazu: response_format json_schema (Fallback json_object, dann ohne,
wie gehabt), temperature 0 nur auf dem kompatiblen Endpunkt, Gemini/Anthropic bekommen die
Regeln ebenfalls als System-Teil. api 142, frontend 799, mcp 36 gruen.
|
||
|
|
9edcdaa9f3 |
Coach: Vorschlaege bleiben, Diagramme in den Karten, Workout-Debrief, Vergleich auf der Instanz, Routine verbessern
Was der Coach vorgeschlagen hat, verschwindet nach Ja/Nein nicht mehr: die Chat-Zeile traegt eine Referenz ins Log, das jetzt jede Aenderung samt before/after (auch abgelehnte), Notizen, Evidenz und bei Plaenen die Routinen behaelt; eine Recap-Karte im Thread und ein Verlauf- Sheet oeffnen alles wieder. Unter jeder Review liegen die Zahlen aus dem zitierten Fenster — Sessions, Dauer, Volumen, Koerpergewicht als Kurve mit Ziel, geschaetztes 1RM erste→letzte Session, Saetze pro Koerperregion — auf dem Geraet gerechnet (lib/coach-insights.js). Neu: Job-Art `debrief` (eine Session, kein Planeingriff: Score 1–10, lief gut / beobachten / naechstes Mal; validateDebrief im Core, eigener Prompt), Vergleich mit anderen auf der Instanz (Admin-Schalter `community`, pro Person Opt-in serverseitig, Mediane ab drei Teilnehmern, Epley-1RM, lb→kg; auch als `cohort` im Prompt), und "Routine verbessern" als fokussierte Review. Schnell-Chips ueber dem Composer, deutsche Strings, Doku, Changelog. Tests: api 136, frontend 799, mcp 36. |
||
|
|
b3340e31b5 |
Coach: eine Session ist kein Trend; Changelog, Doku und .env fuer Chat, Timeout und Bibliotheks-Deckel
Die Review-Regel verbietet strukturelle Aenderungen unter drei Sessions oder einer Woche Daten — qwen2.5:3b hatte auf Staging nach EINER Session eine Bein-Uebung entfernt, 'weil keine Beinarbeit'. Dazu die Changelog-Eintraege fuer den Chat, das Admin-Dashboard, den Job-Timeout und den 160er-Deckel, COACH_JOB_TIMEOUT_MS in .env.example und in AI_COACH.md, und Schritt 3 der Doku beschreibt den Chat statt des alten Intake-Buttons. |
||
|
|
5fb237682b |
Coach: der Fall ohne Vorgeschichte, und was der Validator durchgelassen hat
common.md wird jedem Prompt vorangestellt, also galt Regel 5 -- "jede Begruendung nennt das, was in ihren Daten dafuer sprach" -- auch beim ersten Plan fuer jemanden, der noch nichts geloggt hat. Da gibt es nichts zu nennen, und die Regel hat das Modell genau dorthin gedraengt, wo es sich etwas ausdenkt. Neu steht dabei, worauf man sich stattdessen beruft: Ziel, Erfahrung, Tage, Ausruestung, Einschraenkungen -- und dass ein fehlendes window kein Fehler ist. review.md sagt jetzt ausserdem, dass ohne Sessions die ehrliche Antwort nochange ist, statt einen Grund zu erfinden. repsMax stand im Validator, aber in keiner Tabelle -- das Modell konnte einen Typ nicht verwenden, den wir akzeptieren. payload.js laesst history ganz weg, wenn nichts mit Gewicht geloggt ist. Damit lief die FR-20-Deckelung ins Leere und ein erfundenes Startgewicht ging unveraendert an einen Anfaenger durch. Ohne Vergleichswerte fliegt weight jetzt raus; die erste Session setzt die Basis, so wie create.md es ohnehin verspricht. Dazu vier Luecken, die alle dieselbe Form haben -- etwas wird gezaehlt oder gesetzt, aber nicht auf Eindeutigkeit geprueft: - Zwei Routinen mit derselben id: known ist ein Set, die Woche validierte, ohne dass feststand, welche der beiden gemeint ist. - Dieselbe Uebung zweimal in einer Routine: danach ist jedes reorder unerfuellbar (es verlangt jede id genau einmal) und jede gezielte Aenderung trifft die erste Kopie. - Eine leere Woche uebersprang die Tagesanzahl-Pruefung ganz: "vier Tage" wurde mit einem Plan beantwortet, der gar nichts einplant. - inc war nach oben offen. add-routine trug ausserdem repsMin, prog und inc nicht mit, obwohl der Bundle-Pfad sie kennt. Die drei Codex-Flags sind aus invoke() in ein exportiertes argvFor() gewandert und werden jetzt beim Wert geprueft. Sie waren vorher nirgends getestet -- eines davon zu loeschen war ein gruener Build. |
||
|
|
7be3978476 |
Coach: server plumbing, consent, payload boundary, credential model
First of six. Everything here is transport and boundary: a job can run, its answer can be parsed, and nothing yet judges whether that answer is safe to act on. The validator and the apply path are the next PR, and the seam is explicit — jobs.js carries an answer no further than `unvalidated`, and a test pins that so the next PR has something to replace. Whose account pays, settled first because it decides what the rest may be: instance one account in coach.json, for the single-profile instance profile one account per profile, in its own coach-auth-<uid>.json In instance mode the credential binds to the first profile that spends it and every other profile is refused — no job, not a dismissible warning. A warning moves the decision onto whoever clicks past it and the decision is about somebody's personal subscription. A profile credential is deliberately not a field on state-<uid>.json: that blob syncs and travels in the user's export, and a credential in a backup is the mistake we are avoiding, not repeating. openGym does not interpret any provider's terms; it offers the shape that does not need the interpretation and refuses the shape that does. The privilege drop now fails closed. It only ever engaged when the server ran as root, so adding a USER line to the Dockerfile for unrelated hardening would have silently left the provider runtime on the server's uid. On Linux, no drop means no job, and the admin card says so. ./data is no longer sealed with a blanket 0700. It is a host bind mount and this container is root, so sealing it landed on the host as root-owned and took the owner's own directory hostage — backup scripts, jq, the MCP server in issue #19. The files that hold secrets carry 0600 themselves instead, which is what the directory mode was standing in for; db.json gained an explicit mode rather than inheriting umask once the blanket came off. Bodyweight and per-side, folded in rather than deferred: v1.2.4 made `weight` mean *added* load on a bodyweight exercise, so it is 0 on a good session and every load-shaped signal reads flat. Uncorrected, the Coach would have looked at a working push-up progression and proposed adding weight to a push-up. The payload carries bodyweight/side/repsMax, the session reader carries set count, and the prompts say reps then sets are the progression and per-side targets step in twos. coach-parity.test.js pins the server's three copied reading rules against the frontend's originals over a table of configs — modeOf was never actually pinned, and it is the one that was predicted to drift. No AI dependency lands here: api/ still installs @simplewebauthn/server and web-push and nothing else. Jobs run against the in-repo fixture provider, so CI needs no account, no network and no image build. 33 api tests, 361 frontend tests (169 of them parity), locales in sync. |