fix: missing minisweagent_path module + add nix checks

- Patch upstream pyproject.toml to include minisweagent_path in py-modules
- Copy mini-swe-agent/src/minisweagent into package for importability
- Add 3 nix checks: package-contents, cli-commands, doctor
- All binaries tested: hermes, hermes-agent, hermes-acp
- hermes gateway, config, status, claw migrate all verified working
This commit is contained in:
Ciphercat 2026-03-16 01:15:13 +00:00
commit 1d95780fff
3 changed files with 94 additions and 1 deletions

76
checks.nix Normal file
View file

@ -0,0 +1,76 @@
{ pkgs, hermes-agent }:
{
# Verify package contents — binaries exist and are executable
package-contents = pkgs.runCommand "hermes-package-contents" { } ''
set -e
echo "=== Checking binaries ==="
test -x ${hermes-agent}/bin/hermes || (echo "FAIL: hermes binary missing"; exit 1)
test -x ${hermes-agent}/bin/hermes-agent || (echo "FAIL: hermes-agent binary missing"; exit 1)
test -x ${hermes-agent}/bin/hermes-acp || (echo "FAIL: hermes-acp binary missing"; exit 1)
echo "PASS: All binaries present"
echo "=== Checking version ==="
${hermes-agent}/bin/hermes version 2>&1 | grep -q "Hermes Agent" || (echo "FAIL: version check"; exit 1)
echo "PASS: Version check"
echo "=== Checking key Python modules ==="
SITE=${hermes-agent}/lib/python3.12/site-packages
for mod in agent cli.py gateway cron tools run_agent.py model_tools.py minisweagent_path.py acp_adapter honcho_integration; do
if [ ! -e "$SITE/$mod" ] && [ ! -e "$SITE/$mod.py" ]; then
echo "FAIL: Missing module $mod"
exit 1
fi
done
echo "PASS: All key modules present"
echo "=== Checking wrapped PATH includes runtime deps ==="
cat ${hermes-agent}/bin/hermes | grep -q "PATH" || (echo "FAIL: hermes not wrapped with PATH"; exit 1)
echo "PASS: PATH wrapping"
echo "=== All checks passed ==="
mkdir -p $out
echo "ok" > $out/result
'';
# Verify hermes CLI subcommands are accessible
cli-commands = pkgs.runCommand "hermes-cli-commands" { } ''
set -e
export HOME=$(mktemp -d)
echo "=== Checking hermes --help ==="
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "gateway" || (echo "FAIL: gateway subcommand missing"; exit 1)
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "claw" || (echo "FAIL: claw subcommand missing"; exit 1)
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "config" || (echo "FAIL: config subcommand missing"; exit 1)
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "cron" || (echo "FAIL: cron subcommand missing"; exit 1)
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "skills" || (echo "FAIL: skills subcommand missing"; exit 1)
${hermes-agent}/bin/hermes --help 2>&1 | grep -q "acp" || (echo "FAIL: acp subcommand missing"; exit 1)
echo "PASS: All subcommands accessible"
echo "=== Checking hermes config ==="
${hermes-agent}/bin/hermes config 2>&1 | grep -q "Config:" || (echo "FAIL: config output"; exit 1)
echo "PASS: Config command"
echo "=== Checking hermes claw migrate --help ==="
${hermes-agent}/bin/hermes claw migrate --help 2>&1 | grep -q "OpenClaw" || (echo "FAIL: claw migrate"; exit 1)
echo "PASS: Claw migrate"
echo "=== All CLI checks passed ==="
mkdir -p $out
echo "ok" > $out/result
'';
# Verify doctor runs without crashing
doctor = pkgs.runCommand "hermes-doctor" { } ''
set -e
export HOME=$(mktemp -d)
echo "=== Running hermes doctor ==="
${hermes-agent}/bin/hermes doctor 2>&1 | grep -q "Python" || (echo "FAIL: doctor"; exit 1)
echo "PASS: Doctor runs successfully"
mkdir -p $out
echo "ok" > $out/result
'';
}

View file

@ -17,6 +17,11 @@
default = self.packages.${system}.hermes-agent;
};
checks = import ./checks.nix {
inherit pkgs;
hermes-agent = self.packages.${system}.hermes-agent;
};
devShells.default = pkgs.mkShell {
packages = [ self.packages.${system}.hermes-agent ];
};

View file

@ -147,7 +147,19 @@ pythonPackages.buildPythonApplication {
# Don't run tests during build
doCheck = false;
# mini-swe-agent is included via fetchSubmodules and referenced at runtime
# Upstream pyproject.toml is missing minisweagent_path from py-modules.
# Also ensure mini-swe-agent/src is importable.
postPatch = ''
# Fix: add minisweagent_path.py to py-modules if missing from pyproject.toml
if [ -f minisweagent_path.py ] && ! grep -q minisweagent_path pyproject.toml; then
sed -i 's/py-modules = \[/py-modules = ["minisweagent_path", /' pyproject.toml
fi
# Make mini-swe-agent importable by copying src into the package
if [ -d mini-swe-agent/src/minisweagent ]; then
cp -r mini-swe-agent/src/minisweagent .
fi
'';
postFixup = ''
# Wrap binaries with runtime deps on PATH