Skip to content

refactor(airc-bash): extract cmd_kick#218

Merged
joelteply merged 1 commit intocanaryfrom
refactor/extract-cmd-kick
Apr 28, 2026
Merged

refactor(airc-bash): extract cmd_kick#218
joelteply merged 1 commit intocanaryfrom
refactor/extract-cmd-kick

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Pulls cmd_kick (host-only peer eviction, 65 lines) into lib/airc_bash/cmd_kick.sh. airc: 2764 → 2711 (-53). Stacks alongside merged #213-#217.

Pulls cmd_kick (host-only peer eviction, 65 lines) into
lib/airc_bash/cmd_kick.sh. Standalone — kick is host moderation,
not identity — and extracting it first makes the surrounding
identity block contiguous for the next extraction PR.

  airc:                       2764 → 2711 lines (-53)
  lib/airc_bash/cmd_kick.sh:           +82 (65 body + 17 header)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 28, 2026 16:01
@joelteply joelteply merged commit 075c606 into canary Apr 28, 2026
1 check passed
@joelteply joelteply deleted the refactor/extract-cmd-kick branch April 28, 2026 16:01
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Extracts the host-only kick command implementation out of the airc bash monolith into a dedicated sourced module, continuing the ongoing lib/airc_bash/* decomposition.

Changes:

  • Added lib/airc_bash/cmd_kick.sh containing cmd_kick (peer eviction + SSH authorized_keys revocation).
  • Replaced the inline cmd_kick function in airc with a lib-dir-resolved source block.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
lib/airc_bash/cmd_kick.sh New sourced module exporting cmd_kick.
airc Removes inline cmd_kick body and sources the extracted module via _airc_lib_dir.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/airc_bash/cmd_kick.sh
# auth attempts fail because their key is gone.
#
# External cross-references (call-time): die, ensure_init, get_config_val,
# resolve_name, AIRC_HOME, AIRC_WRITE_DIR, MESSAGES.
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "External cross-references" list appears stale/inaccurate for this extracted module: cmd_kick uses _validate_peer_name, cmd_send, PEERS_DIR, AIRC_PYTHON, and $HOME/.ssh/authorized_keys, but does not reference resolve_name, AIRC_HOME, AIRC_WRITE_DIR, or MESSAGES. Please update the list so future extraction/refactor work doesn’t rely on incorrect dependencies.

Suggested change
# resolve_name, AIRC_HOME, AIRC_WRITE_DIR, MESSAGES.
# _validate_peer_name, cmd_send, PEERS_DIR, AIRC_PYTHON,
# $HOME/.ssh/authorized_keys.

Copilot uses AI. Check for mistakes.
Comment thread lib/airc_bash/cmd_kick.sh
Comment on lines +51 to +58
peer_ssh_pub=$(PEER_FILE="$peer_file" "$AIRC_PYTHON" -c '
import json, os
try:
p = json.load(open(os.environ["PEER_FILE"]))
print((p.get("ssh_pub") or "").strip())
except Exception:
pass
' 2>/dev/null || echo "")
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block uses an inline Python snippet to read ssh_pub out of the peer JSON. Since airc already provides get_config_val_in <path> <key> <default> (backed by airc_core.config) and it’s used elsewhere for peer-file reads, consider using that helper here (and then trimming whitespace) to reduce duplicated JSON-parsing logic.

Suggested change
peer_ssh_pub=$(PEER_FILE="$peer_file" "$AIRC_PYTHON" -c '
import json, os
try:
p = json.load(open(os.environ["PEER_FILE"]))
print((p.get("ssh_pub") or "").strip())
except Exception:
pass
' 2>/dev/null || echo "")
peer_ssh_pub=$(get_config_val_in "$peer_file" "ssh_pub" "")
peer_ssh_pub=$(printf '%s' "$peer_ssh_pub" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants