aboutsummaryrefslogtreecommitdiff
path: root/scripts/newos4-maintain.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/newos4-maintain.py')
-rw-r--r--scripts/newos4-maintain.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/scripts/newos4-maintain.py b/scripts/newos4-maintain.py
index acb81c3..fa20dfa 100644
--- a/scripts/newos4-maintain.py
+++ b/scripts/newos4-maintain.py
@@ -235,10 +235,24 @@ def check_help_coverage():
check makes the gap visible on every maintenance run.
"""
cmds, term = set(), open(os.path.join(ROOT, 'modules/core/terminal.js'), encoding='utf-8').read()
- for m in re.finditer(r'this\._baseWhitelist = \[(.*?)\];', term, re.S):
- cmds.update(re.findall(r"'([^']+)'", m.group(1)))
- for m in re.finditer(r'const internals = \[(.*?)\];', term, re.S):
- cmds.update(re.findall(r"'([^']+)'", m.group(1)))
+
+ # A JS comment inside one of these array literals used to desynchronise quote pairing: the
+ # apostrophe in "don't" (terminal.js:16) matched forward to the opening quote of 'ui', and the
+ # pseudo-command `t work"\n // …` joined the audited set — 367/368 forever, so a genuine gap was
+ # indistinguishable from the artefact (plan 2026-11-13_062052, fixed 2026-11-14).
+ def _tokens(pattern):
+ out = set()
+ for m in re.finditer(pattern, term, re.S):
+ body = re.sub(r'/\*.*?\*/', '', m.group(1), flags=re.S) # block comments
+ body = re.sub(r'//[^\n]*', '', body) # line comments
+ for tok in re.findall(r"'([^']+)'", body):
+ # Shape guard: a real command is a lowercase word. Anything else is parser debris.
+ if re.fullmatch(r'[a-z][a-z0-9_-]{0,40}', tok):
+ out.add(tok)
+ return out
+
+ cmds.update(_tokens(r'this\._baseWhitelist = \[(.*?)\];'))
+ cmds.update(_tokens(r'const internals = \[(.*?)\];'))
cmds.update(re.findall(r"cmd === ['\"]([a-z0-9_-]+)['\"]", term))
for p in glob.glob(os.path.join(ROOT, 'modules/**/*.js'), recursive=True):
if 'bundle' in p or '/test/' in p or '.bkp' in p:
@@ -252,9 +266,12 @@ def check_help_coverage():
if first and re.fullmatch(r'[a-z][a-z0-9_-]{0,40}', first[0].lstrip('./')):
documented.add(first[0].lstrip('./'))
missing = sorted(cmds - documented)
+ # Tokens are shape-guarded above, but collapse whitespace anyway: one bad token must never be able
+ # to reflow the whole digest (plan task 3).
+ shown = ' | '.join(m.replace('\n', ' ') for m in missing[:8])
add('PASS' if not missing else 'WARN',
f'help coverage {len(cmds) - len(missing)}/{len(cmds)} commands'
- + ('' if not missing else f' — undocumented: {", ".join(missing[:8])}'))
+ + ('' if not missing else f' — undocumented: {shown}'))
def check_regression_tests():
"""Every node-runnable test under modules/test/ must pass (2026-10-27).