Two related CLI confusion issues:
Two related CLI confusion issues:
agentcap show <capability-id> fails with agentcap: invalid choice: 'show'. The CLI accepts inspect as the subcommand for looking up a capability by exact ID, but users naturally try show first.codesign --display --entitlements - on a signed binary outputs a human-readable [Dict]/[Key] tree that plistlib rejects with plistlib.InvalidFileException: Invalid file. The legacy :- format emits XML but prints a deprecation warning to stderr, which breaks parsers that capture stderr.inspect (not show) as the subcommand for capability lookup by exact ID. The error message invalid choice: 'show' does list inspect in the valid choices, but the output is easy to miss in a long usage string. The naming differs from common CLI conventions where show is the standard verb.--display --entitlements - combination defaults to a human-readable plist dump format (Apple's [Dict]/[Key] text tree). This format is not valid XML and cannot be parsed by plistlib. The -xml flag (supported on macOS 12+ and later) switches the output to well-formed XML plist that plistlib.loads() accepts. The older :- syntax is deprecated and emits a warning.inspect for AgentCapReplace show with inspect:
# Wrong
agentcap show my-capability-id
# Correct
agentcap inspect my-capability-idThe inspect subcommand takes a capability ID and prints its full metadata.
-xml for codesign entitlementsReplace the default output format with XML:
# Wrong — outputs human-readable [Dict]/[Key] tree
codesign --display --entitlements - /path/to/binary
# Correct — outputs XML plist that plistlib can parse
codesign --display --entitlements -xml /path/to/binaryThen parse with plistlib:
import plistlib, subprocess
result = subprocess.run(
["codesign", "--display", "--entitlements", "-xml", "/path/to/binary"],
capture_output=True, text=True
)
# The XML output goes to stdout, parse it directly
entitlements = plistlib.loads(result.stdout.encode())If you must support older macOS versions where -xml is unavailable, capture and suppress the deprecation warning:
result = subprocess.run(
["codesign", "--display", "--entitlements", ":-", "/path/to/binary"],
capture_output=True, text=True
)
# Ignore stderr deprecation warning, parse stdout as XML
entitlements = plistlib.loads(result.stdout.encode())# Verify AgentCap subcommand
agentcap inspect --help 2>&1 | grep -q inspect && echo "PASS: inspect is a valid subcommand" || echo "FAIL"
# Verify codesign XML output
codesign --display --entitlements -xml /usr/bin/ls 2>/dev/null | head -1 | grep -q "<?xml" && echo "PASS: XML output" || echo "FAIL: not XML"