fix(cli): resolve duplicate 'skills' subparser crash on Python 3.11+

Fixes #898 — Python 3.11 changed argparse to raise an exception on
duplicate subparser names (CPython #94331). The 'skills' name was
registered twice: once for Skills Hub and once for skills config.

Changes:
- Remove duplicate 'skills' subparser registration
- Add 'config' as a sub-action under the existing 'hermes skills' command
- Route 'hermes skills config' to skills_config module
- Add regression test to catch future duplicates

Migration: 'hermes skills' (config) is now 'hermes skills config'
This commit is contained in:
Bartok Moltbot 2026-03-11 03:33:27 -04:00 committed by teknium1
parent 5abee4fb23
commit ae1c11c5a5
2 changed files with 47 additions and 17 deletions

View file

@ -0,0 +1,35 @@
"""Test that skills subparser doesn't conflict (regression test for #898)."""
import argparse
def test_no_duplicate_skills_subparser():
"""Ensure 'skills' subparser is only registered once to avoid Python 3.11+ crash.
Python 3.11 changed argparse to raise an exception on duplicate subparser
names instead of silently overwriting (see CPython #94331).
This test will fail with:
argparse.ArgumentError: argument command: conflicting subparser: skills
if the duplicate 'skills' registration is reintroduced.
"""
# Force fresh import of the module where parser is constructed
# If there are duplicate 'skills' subparsers, this import will raise
# argparse.ArgumentError at module load time
import importlib
import sys
# Remove cached module if present
if 'hermes_cli.main' in sys.modules:
del sys.modules['hermes_cli.main']
try:
import hermes_cli.main # noqa: F401
except argparse.ArgumentError as e:
if "conflicting subparser" in str(e):
raise AssertionError(
f"Duplicate subparser detected: {e}. "
"See issue #898 for details."
) from e
raise