From f672241e9c399675724f161f94b06d933c7a7d39 Mon Sep 17 00:00:00 2001 From: boyreau Date: Sun, 8 Nov 2026 12:22:18 +0100 Subject: [PATCH] Fix subscripted-variable false positives; finalize plugin metadata verify-calculations.sh mistook subscripted/numbered variables (x_1, x1, 3x_1) for bare numeric equations, flagging e.g. "x_1 = 0" as the false claim "1 = 0". The single-letter variable regex only excluded adjacent letters, not trailing digits/underscores, and the prose segment extractor could start a fresh match right after such a break, mining a free digit out of the identifier. Also carries over the author/repository metadata and the SSH-vs-HTTP install note for the Forgejo marketplace (DISABLE_HTTP_GIT blocks the https URL; the ssh:// path has no /forgejo/ segment). Co-Authored-By: Claude Sonnet 5 --- .claude-plugin/marketplace.json | 2 +- .claude-plugin/plugin.json | 4 ++++ README.md | 15 ++++++++++++++- hooks/verify-calculations.sh | 22 +++++++++++++++++++--- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 3df508e..daaa2ee 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -2,7 +2,7 @@ "name": "claude-math", "description": "Marketplace à plugin unique : claude-math.", "owner": { - "name": "claude-math" + "name": "zo" }, "plugins": [ { diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index 462ea27..331ed72 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -2,5 +2,9 @@ "name": "claude-math", "description": "Exercices calibrés et correction pour un cours de mathématiques pour la cryptographie : génération de séries progressives, notation du cours, suivi de progression, et vérification automatique des calculs arithmétiques/modulaires tapés dans les messages.", "version": "1.0.0", + "author": { + "name": "zo" + }, + "repository": "https://zospace.freeboxos.fr/forgejo/zo/claude-math", "keywords": ["maths", "cryptographie", "arithmétique", "exercices"] } diff --git a/README.md b/README.md index b5ed61e..501c66a 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,23 @@ vérification automatique des calculs tapés dans les messages. > d'un message). Voir [Se passer de Nix](#se-passer-de-nix) pour l'adapter. ```bash -/plugin marketplace add +/plugin marketplace add https://zospace.freeboxos.fr/forgejo/zo/claude-math /plugin install claude-math@claude-math ``` +L'instance Forgejo refuse actuellement le git en HTTP (`DISABLE_HTTP_GIT`), si +bien que l'URL ci-dessus ne sert qu'à consulter le dépôt. Pour que +`/plugin marketplace add` fonctionne en HTTPS, passer `DISABLE_HTTP_GIT = +false` dans `app.ini` ; sinon, installer par SSH : + +```bash +/plugin marketplace add ssh://forgejo@zospace.freeboxos.fr/zo/claude-math +/plugin install claude-math@claude-math +``` + +Noter que le chemin diffère entre les deux protocoles : le segment `/forgejo/` +est celui du reverse-proxy web et n'existe pas côté SSH. + Le dépôt est à la fois le plugin (`.claude-plugin/plugin.json`) et une marketplace à entrée unique (`.claude-plugin/marketplace.json`), donc les deux commandes suffisent. diff --git a/hooks/verify-calculations.sh b/hooks/verify-calculations.sh index d3a54d5..d0fee23 100755 --- a/hooks/verify-calculations.sh +++ b/hooks/verify-calculations.sh @@ -185,9 +185,20 @@ MATH_RUN = re.compile(r'(?:[0-9]|\bmod\b|\bphi\b|\bgcd\b|\blcm\b|[+\-*/^()≡=,% def extract_segments(line): """Pull the mathematical runs out of a line that also carries prose, so `Euler's theorem gives 8^6 mod 15 = ... = 4 mod 15.` still gets checked - instead of being skipped because the sentence as a whole won't parse.""" + instead of being skipped because the sentence as a whole won't parse. + + A letter breaks a run (so identifiers don't get read as arithmetic), but + a digit/underscore right after it doesn't - so for `x_1 = 0` the `_` + broke the run and the following `1` started a *new* one, mining the + bogus standalone claim `1 = 0` out of a variable name. A run that starts + right after a letter/digit/underscore is such a fragment, chopped out of + a longer identifier, not a real standalone number - discard it instead + of checking it.""" segments = [] for m in MATH_RUN.finditer(line): + start = m.start() + if start > 0 and re.match(r'[a-zA-Z0-9_]', line[start - 1]): + continue seg = m.group(0).strip(' ,;:.') if not seg or not re.search(r'≡|=', seg): continue @@ -284,8 +295,13 @@ def verify_claim(line): # meaningless and slow enough to blow the hook's timeout. if re.search(r'[a-zA-Z]{2,}', re.sub(r'\b(mod|phi|gcd|lcm)\b', '', body)): return ('skip', None) - if len(parts) == 2 and re.search(r'(?