Polish pass: lint, safety hardening, packaging, tests, CI#1
Conversation
Lint (ruff): - Remove unused imports (asyncio, datetime, typing.Optional) - Drop an f-string with no placeholders - ruff check . is clean Bug fixes: - command_parser: git passthrough no longer lowercases arguments. It now captures from the original (case-preserving) string, so branch names and commit messages survive (e.g. "git commit -m AddFeatureX"). - telegram_bot: create DATA_DIR before logging.basicConfig opens bot.log, which otherwise raises FileNotFoundError at import time. Safety hardening (security-relevant tooling): - shell_ghost.is_safe now blocks piping into a shell interpreter regardless of intervening text/whitespace (e.g. "curl http://x | bash"). The literal DANGEROUS_PATTERNS entries only matched the exact "curl | bash" spacing. Hardcoded path: - install.sh: env template no longer ships a literal /home/YOUR_USER path; the data dir is resolved from the bot user's actual home at install time. Packaging: - Add requirements.txt (python-telegram-bot, httpx) and pyproject.toml. Tests (pure logic only; no telegram/httpx/GPU/model imports): - tests/ with 46 unit tests for command_parser, shell_ghost (classification + file creation), and memory (JSON store, isolated via monkeypatch/tmp_path). CI: - .github/workflows/ci.yml runs ruff + pytest on 3.11/3.12, installing only ruff+pytest (no heavy runtime deps); pytest scoped to ./tests. Documented TODO (not changed to avoid altering routing): leading "do" in the execute pattern over-matches conversational phrases like "do you remember...". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Independent verification — verdict: solid ✅Reviewed adversarially on a clean clone (fresh venv, only Claims confirmed
CI is genuinely green-able without GPUs/models (the common trap this avoids)
Bug fixes behave as described
No secrets / hardcoded paths: scan clean; Minor (non-blocking, not a regression): No overclaims in the body; the "NOT verified" section is candid and accurate. LGTM. — automated independent review |
Hygiene-only polish pass on the Python sources. No new product features, no benchmarks, no behavior changes to command routing beyond the bug fixes noted below.
Verified locally
ruff check .— clean (0 issues). Started from 4 findings (3 unused imports, 1 placeholderless f-string), all auto-fixed.pytest -q— 46 passed. Tests cover pure logic only and import no heavy/runtime-only deps (notelegram,httpx, GPU, or model weights):command_parser: intent detection + NL→shell building + file-create extractionshell_ghost:is_safe/needs_confirmationclassification andcreate_file(against a tmp dir;execute()is never run, audit log monkeypatched)memory: JSON store round-trips, history trimming, corrupt-file recovery (paths isolated viamonkeypatch/tmp_path)CIN_DATA_DIR.NOT verified (out of scope / no environment)
telegram_bot.py) was not executed or imported — it needspython-telegram-bot+httpxand a live bot token / Ollama / network. Reviewed by reading only.install.shand the systemd unit were not run (need root + apt).Changes
Lint
asyncio,datetime.datetime,typing.Optional); drop one placeholderless f-string.Bug fixes
command_parsergit passthrough no longer lowercases arguments — it now captures from the original case-preserving string, so branch names / commit messages survive (e.g.git commit -m AddFeatureXpreviously becameaddfeaturex).telegram_botcreatesDATA_DIRbeforelogging.basicConfigopensbot.log, fixing aFileNotFoundErrorat import time when the dir doesn't exist yet.Safety hardening (security-relevant tooling)
shell_ghost.is_safenow blocks piping into a shell interpreter regardless of intervening text/whitespace (e.g.curl http://x | bash). The literalDANGEROUS_PATTERNSentries only matched the exactcurl | bashspacing and let real commands through. This strictly reduces what can run — no new capability.Hardcoded path
install.shenv template no longer ships a literal/home/YOUR_USERpath; the data dir is resolved from the bot user's actual home at install time.Packaging
requirements.txt(python-telegram-bot,httpx— the only third-party imports) and a minimalpyproject.toml.Tests + CI
tests/(46 tests, pure-logic only)..github/workflows/ci.yml: ruff + pytest on Python 3.11/3.12, installing only ruff+pytest (no heavy runtime deps); pytest scoped to./tests. Green-able without GPUs/models.Documented (not changed)
command_parser: the leadingdoin the execute pattern over-matches conversational phrases like "do you remember my name?" (routes to command instead of chat). Left as-is to avoid altering routing in a hygiene pass.🤖 Generated with Claude Code