Skip to content

The agent that grows with you

fix(lint): stdin guard scans optional-skill scripts

alt-glitch6f4a16e1a8cd
diff --git a/optional-skills/creative/comfyui/scripts/auto_fix_deps.py b/optional-skills/creative/comfyui/scripts/auto_fix_deps.py
index 9c6bee96a3f..2977adfc38a 100755
--- a/optional-skills/creative/comfyui/scripts/auto_fix_deps.py
+++ b/optional-skills/creative/comfyui/scripts/auto_fix_deps.py
@@ -51,7 +51,9 @@ def run_cmd(cmd: list[str], *, dry_run: bool = False) -> tuple[int, str]:
if dry_run:
return 0, "[dry-run]"
log(f"$ {' '.join(cmd)}")
- proc = subprocess.run(cmd, capture_output=True, text=True, encoding='utf-8', errors='replace', check=False)
+ # health: allow HX006 -- node installs and multi-GB model downloads have no fair upper bound
+ proc = subprocess.run(cmd, capture_output=True, text=True, encoding='utf-8', errors='replace',
+ check=False, stdin=subprocess.DEVNULL)
out = (proc.stdout or "") + (proc.stderr or "")
return proc.returncode, out
diff --git a/optional-skills/security/unbroker/scripts/crypto.py b/optional-skills/security/unbroker/scripts/crypto.py
index 98594f5e840..135f940226e 100644
--- a/optional-skills/security/unbroker/scripts/crypto.py
+++ b/optional-skills/security/unbroker/scripts/crypto.py
@@ -53,7 +53,8 @@ def ensure_identity() -> Path:
p.parent.chmod(0o700)
except OSError:
pass
- subprocess.run(["age-keygen", "-o", str(p)], check=True, capture_output=True)
+ subprocess.run(["age-keygen", "-o", str(p)], check=True, capture_output=True,
+ stdin=subprocess.DEVNULL, timeout=30)
try:
p.chmod(0o600)
except OSError:
diff --git a/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py b/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py
index 053c0501582..9d062328df3 100755
--- a/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py
+++ b/optional-skills/software-development/ast-grep/scripts/ast_grep_helper.py
@@ -605,7 +605,8 @@ def cmd_install(_args: argparse.Namespace) -> int:
err(f"installer not found: {installer}")
return 1
trace(f"running installer: {' '.join(cmd)}")
- return subprocess.run(cmd).returncode
+ # health: allow HX006 -- the installer downloads a release; its duration depends on the network
+ return subprocess.run(cmd, stdin=subprocess.DEVNULL).returncode
def cmd_validate(args: argparse.Namespace) -> int:
diff --git a/scripts/check_subprocess_stdin.py b/scripts/check_subprocess_stdin.py
index e471b7c5ba6..0b12b45fe81 100644
--- a/scripts/check_subprocess_stdin.py
+++ b/scripts/check_subprocess_stdin.py
@@ -7,8 +7,8 @@ inherit this fd can cause the gateway to exit with stdin EOF during tool
execution (issue #14036, PR #39257).
This script checks that all subprocess.run() and subprocess.Popen() calls
-in TUI-context files (agent/, tools/, plugins/, tui_gateway/) explicitly
-set stdin= to prevent fd inheritance.
+in TUI-context files (agent/, tools/, plugins/, tui_gateway/,
+optional-skills/) explicitly set stdin= to prevent fd inheritance.
Exit codes:
0 — all calls are safe
@@ -36,6 +36,10 @@ TUI_CONTEXT_DIRS = [
"tools/",
"plugins/",
"tui_gateway/",
+ # Optional-skill scripts can run inside the backend process (a command
+ # builder calling a skill helper on a backend thread); their children would
+ # inherit the JSON-RPC stdin too.
+ "optional-skills/",
]
# User plugin roots — scanned at runtime if they exist. Plugins load from
@@ -73,16 +77,9 @@ KNOWN_SAFE = {
# file:line entry).
EXEMPT_MARKER = "noqa: subprocess-stdin"
-# Directories to skip entirely.
-SKIP_DIRS = {
- "tests/",
- "scripts/",
- "skills/",
- "optional-skills/",
- "hermes_cli/",
- "gateway/",
- "cron/",
-}
+# Directory names skipped at any depth below a context dir. Matching against the
+# path relative to that dir keeps a skill's own ``scripts/`` folder in scope.
+SKIP_DIRS = {"tests"}
_SPLAT_RE = re.compile(r"\*\*\s*([A-Za-z_][A-Za-z0-9_]*)")
@@ -228,8 +225,7 @@ def main() -> int:
continue
# Skip test files inside tools/ etc.
- parts = py_file.parts
- if any(skip.rstrip("/") in parts for skip in SKIP_DIRS):
+ if SKIP_DIRS & set(py_file.relative_to(dirpath).parts):
continue
content = py_file.read_text(encoding="utf-8-sig")