Address review feedback: fix hardcoded paths, PATH logic, SQLite mode

1. Replace all hardcoded /Users/whitenoise-oc/ dev paths in SEACLIP.md
   and TEST.md files (seaclip, pm2, chromadb) with generic placeholders
2. Extract shared _EXTRA_PATH_DIRS constant and _augmented_path() helper
   in pm2_backend.py so _find_pm2() and _build_env() use identical logic
3. Open SQLite in read-only mode (file:...?mode=ro) in _query_db()
4. Add trailing newline to registry.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
yuhao
2026-04-08 08:00:21 +00:00
parent 369e02b9c0
commit 56552ea522
7 changed files with 21 additions and 23 deletions

View File

@@ -63,11 +63,7 @@ Skipped:
## Running Tests
```bash
# Activate the CLI-Anything venv
source /Users/whitenoise-oc/projects/CLI-Anything/.venv/bin/activate
# Install the package in dev mode
cd /Users/whitenoise-oc/projects/cli-anything-chromadb/agent-harness
cd agent-harness
pip install -e .
# Run all tests

View File

@@ -12,9 +12,8 @@ Test suites for the PM2 CLI-Anything harness.
## Running Tests
```bash
# Activate the CLI-Anything venv
source /Users/whitenoise-oc/projects/CLI-Anything/.venv/bin/activate
cd /Users/whitenoise-oc/projects/cli-anything-pm2/agent-harness
cd agent-harness
pip install -e .
# All tests
python -m pytest cli_anything/pm2/tests/ -v

View File

@@ -10,6 +10,18 @@ import shutil
import subprocess
from typing import Any
# Common directories where pm2 may be installed (Homebrew, global npm, system).
_EXTRA_PATH_DIRS = ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin"]
def _augmented_path(base_path: str | None = None) -> str:
"""Return PATH string with _EXTRA_PATH_DIRS prepended if missing."""
path = base_path if base_path is not None else os.environ.get("PATH", "")
for p in _EXTRA_PATH_DIRS:
if p not in path:
path = f"{p}:{path}"
return path
def _find_pm2() -> str:
"""Locate the pm2 binary on the system.
@@ -22,13 +34,7 @@ def _find_pm2() -> str:
Raises:
RuntimeError: If pm2 is not found.
"""
extra_paths = ["/opt/homebrew/bin", "/usr/local/bin", "/usr/bin"]
env_path = os.environ.get("PATH", "")
for p in extra_paths:
if p not in env_path:
env_path = f"{p}:{env_path}"
pm2_path = shutil.which("pm2", path=env_path)
pm2_path = shutil.which("pm2", path=_augmented_path())
if pm2_path is None:
raise RuntimeError(
"pm2 not found on this system. "
@@ -52,9 +58,7 @@ def _get_pm2() -> str:
def _build_env() -> dict[str, str]:
"""Build environment dict with proper PATH for subprocess."""
env = os.environ.copy()
extra = "/opt/homebrew/bin:/usr/local/bin"
if extra not in env.get("PATH", ""):
env["PATH"] = f"{extra}:{env.get('PATH', '')}"
env["PATH"] = _augmented_path(env.get("PATH", ""))
return env

View File

@@ -538,4 +538,4 @@
"contributor_url": "https://github.com/omerarslan0"
}
]
}
}

View File

@@ -30,7 +30,7 @@ or undo/redo stack.
## Backend
- **FastAPI** at `http://127.0.0.1:5200`
- **SQLite** at `/Users/whitenoise-oc/shrirama/seaclip-lite/seaclip.db`
- **SQLite** at the path specified by the `SEACLIP_DB` environment variable
## Install
@@ -120,7 +120,7 @@ cli-anything-seaclip
```bash
cd agent-harness
source /Users/whitenoise-oc/projects/CLI-Anything/.venv/bin/activate
pip install -e .
python -m pytest cli_anything/seaclip/tests/ -v
```

View File

@@ -69,7 +69,6 @@ Tests requiring the live backend are skipped gracefully if localhost:5200 is unr
```
============================= test session starts ==============================
platform darwin -- Python 3.14.3, pytest-9.0.2, pluggy-1.6.0
rootdir: /Users/whitenoise-oc/projects/cli-anything-seaclip/agent-harness
test_core.py 25 passed
test_full_e2e.py 10 passed

View File

@@ -96,7 +96,7 @@ class SeaClipBackend:
"SEACLIP_DB environment variable is required for direct database queries. "
"Set it to the path of your SeaClip-Lite seaclip.db file."
)
conn = sqlite3.connect(self.db_path)
conn = sqlite3.connect(f"file:{self.db_path}?mode=ro", uri=True)
conn.row_factory = sqlite3.Row
try:
rows = conn.execute(sql, params).fetchall()