feat(kvb-org-organize): node --check and node -c count as light runs

watch.py treats node --check FILE and node -c FILE as a parse-only call: launched() no longer names it a program launch and light_program() admits it. Any other option, a missing file or a --require hook keeps the old heavy verdict; test_watch.py pins both sides.

🎯 Fix: 93 %
💥 Break: 2 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 91
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-17 18:43:40 +00:00
1 parent 58f4acdad9
commit e522e94b16
2 files changed
+23 -3

No files matched your search

+15 -3
View File
@@ -316,6 +316,7 @@ JS_TAIL = 64
SOURCE_BYTES = 1 << 20
JS_RUNNERS = frozenset({"node", "deno", "bun"})
JS_VALUE_OPTIONS = frozenset({"-r", "--require", "--import", "--loader", "-e", "--eval", "-p", "--print", "-c", "--config"})
NODE_CHECK = frozenset({"--check", "-c"})
PACKAGE_RUNNERS = frozenset({"npm", "pnpm", "yarn", "bun"})
FOLDER_OPTIONS = frozenset({"--cwd", "-C", "--dir", "--prefix"})
PACKAGE_OPTIONS = {
@@ -914,11 +915,22 @@ def tool(run: list[str]) -> tuple[str, list[str]]:
return os.path.basename(target), rest
def node_check(run: list[str]) -> bool:
"""Returns:
Whether run is `node --check FILE` or `node -c FILE`: node only
parses the file and runs none of it.
"""
return os.path.basename(run[0]) == "node" and len(run) == 3 and run[1] in NODE_CHECK and not run[2].startswith("-")
def launched(run: list[str]) -> str:
"""Returns:
The script or `-m` module a python call starts, or the script of a
node, deno or bun call (after a `run`); "" for none.
node, deno or bun call (after a `run`); "" for none and for
node_check().
"""
if node_check(run):
return ""
name = os.path.basename(run[0])
if PYTHON.fullmatch(name):
return python_target(run[1:])[0]
@@ -1890,7 +1902,7 @@ def light_program(run: list[str], words: list[str], base: str | None) -> bool:
return cargo_allowed(run, assignments(words))
if name == "find":
return not FIND_EXEC.intersection(args)
return name in LIGHT_TOOLS or light_test(name, args, base)
return name in LIGHT_TOOLS or node_check(run) or light_test(name, args, base)
def light_python(run: list[str], base: str | None) -> bool:
@@ -1922,7 +1934,7 @@ def light(command: str, cwd: str | None) -> bool:
Whether every simple command of it is a recognised small form: cd,
pushd or popd, or behind nothing but SAFE_PREFIXES and INERT_ENV or
LC_* assignments a LIGHT_TOOLS program (find without -exec), a
cargo_allowed() call, `python -m` of LIGHT_MODULES, `sh -c` of a
cargo_allowed() call, node_check(), `python -m` of LIGHT_MODULES, `sh -c` of a
light command, or light_test(); test files resolve relative to cwd
moved by every cd and env -C. A substitution, heredoc, background
job, unbalanced quote or second test run (test_runs()) makes it not
+8
View File
@@ -383,6 +383,7 @@ class TestHeavy(unittest.TestCase):
"node tests/e2e/cdp.mjs",
"node tools/shot.mjs",
"deno run -A tests/e2e/cdp.mjs",
"node --check --require ./tools/plain.mjs tools/shot.mjs",
"npx playwright test",
"npx --yes @playwright/test test",
"playwright test",
@@ -403,6 +404,8 @@ class TestHeavy(unittest.TestCase):
"python3 tools/plain.py",
"python3 -c 'import json'",
"node tools/plain.mjs",
"node --check tools/shot.mjs",
"node -c tools/shot.mjs",
"npx prettier --check .",
"playwright --version",
"tox --version",
@@ -424,6 +427,8 @@ class TestHeavy(unittest.TestCase):
"lizard -w -C 10 tools/plain.py",
"jq . config.json",
"python3 -m py_compile tools/plain.py",
"node --check tools/shot.mjs",
"node -c tools/plain.mjs",
"python3 -m pytest tests/test_watch.py",
"pytest tests/test_watch.py::TestA -q",
"python3 -m unittest tests.test_watch",
@@ -460,6 +465,9 @@ class TestHeavy(unittest.TestCase):
"make lint",
"python3 tools/plain.py",
"python3 -c 'import json'",
"node tools/plain.mjs",
"node --check",
"node --check --require ./tools/plain.mjs tools/shot.mjs",
"ruff check $(cat list)",
"cd $(mktemp -d) && python3 -m pytest test_watch.py",
"cd tests ; python3 -m pytest test_page.py",