Kōyō is a keyboard configuration project focusing on QMK firmware for both Moonlander and Corne (crkbd) keyboards. The name (紅葉) refers to autumn leaves in Japanese, reflecting the project's aesthetic and design philosophy.
- Ask for specific files or code snippets when needed for context
- Request clarification when requirements are unclear
- Think step-by-step through complex problems
- Admit uncertainty rather than make assumptions
- Use established project patterns when suggesting solutions
Always ask for:
- Specific file contents when modifying existing code
- Current implementation when suggesting changes
- Clarification about project context when unsure
- Confirmation before suggesting major changes
Use clear, specific requests like:
- "Could you show me the current content of utils.sh?"
- "To help with this, I need to see how this is currently implemented in {file}"
- "Before proceeding, could you confirm if this follows your current pattern in {similar_file}?"
- "I'm unsure about {specific_aspect}. Could you clarify?"
- Acknowledge the context provided
- Ask for any missing information
- Present solution with explanations
- Offer to clarify or adjust as needed
- Follow existing patterns in the codebase
- Use consistent error handling
- Maintain existing logging patterns
- Keep scripts focused and modular
- The project uses specific logging functions (debug_log, success_log, etc.)
- Config values should be accessed through get_config
- Scripts should support --dry-run where applicable
- Error handling should be consistent and clear
config.yml
: Central configuration file containing paths and keyboard-specific settingsutils.sh
: Common utilities for logging and config readingsetup.sh
: Installation script for dependencies and environment setupupdate_svg.sh
: Script for generating keyboard layout visualizationkoyo
: Main CLI tool
koyo/
├── assets/ # Visual assets and configs
│ ├── kd_config.yaml # Keymap-drawer configuration
│ ├── kd_layout.yaml # Keyboard layout specification
│ └── layout.svg # Generated layout visualization
├── qmk/ # QMK configurations
│ ├── crkbd/ # Corne keyboard files
│ │ ├── flash.sh # Flashing script
│ │ └── src/ # Source files
│ └── moonlander/ # Moonlander keyboard files
│ ├── flash.sh # Flashing script
│ └── src/ # Source files
- QMK Firmware
- keymap-drawer (for layout visualization)
- yq (for YAML processing)
- ZSH shell
-
QMK Setup:
- Uses QMK CLI for firmware management
- Configures QMK home directory
- Handles both fresh installations and updates
-
Layout Configuration:
- Uses keymap-drawer for visualization
- Supports custom key mappings and combos
- Maintains consistent layout across keyboards
-
Utility Functions:
- Logging with colors and icons
- Config reading with yq
- Error handling and dry-run support
-
Setting up environment:
./setup.sh
-
Updating layout SVG:
./update_svg.sh # or koyo update svg
-
Flashing keyboards:
koyo moonlander flash koyo crkbd flash
-
Script Structure:
- Use strict mode (
set -e
) - Implement proper error handling
- Support dry-run mode where applicable
- Use strict mode (
-
Logging:
- Use utility functions: debug_log, success_log, error_log, warning_log
- Provide clear, actionable feedback
- Use consistent icons and colors
-
Configuration:
- Use YAML for configuration files
- Access config values through get_config utility
- Support environment-specific overrides
-
QMK Setup:
- Always configure QMK home directory
- Run qmk setup for fresh installations
- Verify dependencies before operations
-
Layout Generation:
- Handle YAML syntax carefully, especially with special characters
- Use proper keycode mappings in kd_config.yaml
- Verify paths before operations
-
Permission Issues:
- Handle script permissions explicitly
- Use sudo when needed for system-level operations
- Check file existence before operations
-
Error Handling:
- Exit on critical errors
- Provide helpful error messages
- Clean up on exit when necessary
-
Configuration:
- Keep paths in config.yml
- Use relative paths when possible
- Support configuration overrides
-
Testing:
- Support dry-run mode
- Verify dependencies
- Check file permissions and existence
- Cross-keyboard compatibility
- Clear visual layout representation
- Easy setup and configuration
- Consistent error handling
- Clear user feedback
- Modular design
#!/usr/bin/env bash
# Get the directory of this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Source utilities
source "$SCRIPT_DIR/utils.sh"
# Enable strict mode
set -euo pipefail
# Get repo path from config
KOYO_REPO=$(eval echo "$(get_config '.paths.repo_dir')")
check_dependency() {
debug_log "Checking dependency installation..."
if ! command -v dependency &>/dev/null; then
debug_log "Warning: dependency not found"
if [[ "$DRY_RUN" == "true" ]]; then
debug_log "Would prompt to install dependency"
return
fi
prompt_log "Would you like to install dependency now? (y/n)"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
# Installation logic here
success_log "Dependency installed successfully"
else
warning_log "Please install dependency manually before continuing"
exit 1
fi
else
success_log "Dependency found"
fi
}
# config.yml
paths:
qmk_dir: "$HOME/repos/qmk/qmk_firmware"
repo_dir: "$HOME/repos/nikbrunner/koyo"
# Access in scripts
QMK_DIR=$(eval echo "$(get_config '.paths.qmk_dir')")
if ! some_command; then
error_log "Failed to execute command"
exit 1
fi
# kd_layout.yaml example structure
layout: {qmk_keyboard: crkbd/rev1, qmk_layout: LAYOUT_split_3x5_3}
layers:
LY_BAS:
- {t: key, h: hold} # Standard key with hold function
- {t: tap, h: hold, s: shifted} # Key with shift function