refactor(airc-bash): extract cmd_kick#218
Conversation
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>
There was a problem hiding this comment.
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.shcontainingcmd_kick(peer eviction + SSH authorized_keys revocation). - Replaced the inline
cmd_kickfunction inaircwith a lib-dir-resolvedsourceblock.
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.
| # 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. |
There was a problem hiding this comment.
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.
| # resolve_name, AIRC_HOME, AIRC_WRITE_DIR, MESSAGES. | |
| # _validate_peer_name, cmd_send, PEERS_DIR, AIRC_PYTHON, | |
| # $HOME/.ssh/authorized_keys. |
| 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 "") |
There was a problem hiding this comment.
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.
| 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:]]*$//') |
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.