Loading...
Loading...
Add support for a new CLI command. Use when implementing a handler or adding to SIMPLE_SAFE.
npx skill4agent add ldayton/dippy add-command$ARGUMENTSls ~/source/tldr/pages/*/$ARGUMENTS*.md
cat ~/source/tldr/pages/*/$ARGUMENTS.md$ARGUMENTS --help
man $ARGUMENTSSIMPLE_SAFEsrc/dippy/core/allowlists.pytests/test_simple.pytests/cli/test_$ARGUMENTS.py"""Test cases for $ARGUMENTS."""
import pytest
from conftest import is_approved, needs_confirmation
TESTS = [
# Safe operations
("$ARGUMENTS <safe-subcommand>", True),
("$ARGUMENTS --help", True),
# Unsafe operations
("$ARGUMENTS <unsafe-subcommand>", False),
]
@pytest.mark.parametrize("command,expected", TESTS)
def test_command(check, command: str, expected: bool):
result = check(command)
if expected:
assert is_approved(result), f"Expected approve: {command}"
else:
assert needs_confirmation(result), f"Expected confirm: {command}"src/dippy/cli/$ARGUMENTS.py"""$ARGUMENTS handler for Dippy."""
from dippy.cli import Classification, HandlerContext
COMMANDS = ["$ARGUMENTS"]
SAFE_ACTIONS = frozenset({"list", "show", "status"})
def classify(ctx: HandlerContext) -> Classification:
tokens = ctx.tokens
action = tokens[1] if len(tokens) > 1 else None
if action in SAFE_ACTIONS:
return Classification("allow", description=f"$ARGUMENTS {action}")
return Classification("ask", description="$ARGUMENTS")just testjust check