UNPKG

ailock

Version:

AI-Proof File Guard - Protect sensitive files from accidental AI modifications

173 lines (153 loc) 5.89 kB
/** * Generate Zsh completion script for ailock */ export function generateZshCompletion() { return `#compdef ailock aiunlock # ailock zsh completion script # Generated by: ailock completion zsh _ailock() { local -a commands options local context state line # Define commands commands=( 'init:Initialize ailock configuration' 'lock:Lock files to prevent modifications' 'unlock:Unlock files to allow modifications' 'status:Show protection status' 'status-interactive:Interactive status dashboard' 'list:List protected files (alias: ls)' 'diagnose:Diagnose file protection issues' 'generate:Generate CI/CD and container configs' 'install-hooks:Install Git pre-commit hooks' 'completion:Generate shell completion script' 'setup-completion:Interactive completion setup' 'help:Show help information' ) # Main completion _arguments -C \\ '1: :->command' \\ '*:: :->args' case \$state in command) _describe -t commands 'ailock command' commands ;; args) case \$words[1] in init) _arguments \\ '--force[Force overwrite existing config]' \\ '--interactive[Interactive configuration setup]' \\ '--config-only[Only create config file without locking]' ;; lock) _arguments \\ '--verbose[Show detailed output]' \\ '--dry-run[Preview changes without applying]' \\ '--no-gitignore[Skip .gitignore integration]' \\ '*:file:_ailock_unlocked_files' ;; unlock) _arguments \\ '--verbose[Show detailed output]' \\ '--dry-run[Preview changes without applying]' \\ '--all[Unlock all files]' \\ '--no-gitignore[Skip .gitignore integration]' \\ '*:file:_ailock_locked_files' ;; status) _arguments \\ '--verbose[Show detailed status]' \\ '--simple[Simple output format]' \\ '--json[JSON output format]' ;; list|ls) _arguments \\ '--all[Show all files]' \\ '--long[Long format with details]' \\ '--locked-only[Show only locked files]' \\ '--unlocked-only[Show only unlocked files]' \\ '--json[JSON output format]' ;; diagnose) _arguments \\ '--verbose[Show detailed diagnostics]' \\ '1:file:_files' ;; generate) local -a templates templates=( 'github:GitHub Actions workflow' 'gitlab:GitLab CI pipeline' 'bitbucket:Bitbucket Pipeline' 'jenkins:Jenkins pipeline' 'circleci:CircleCI config' 'docker:Dockerfile' 'devcontainer:VS Code devcontainer' ) _describe -t templates 'template' templates ;; install-hooks) _arguments \\ '--force[Force overwrite existing hooks]' \\ '--yes[Skip confirmation prompts]' ;; completion) local -a shells shells=(bash zsh fish powershell) _arguments \\ '1:shell:(bash zsh fish powershell)' \\ '--install-instructions[Show installation instructions]' ;; setup-completion|help) # No additional arguments for these commands ;; *) # Default case - provide file completion _files ;; esac ;; esac } # Custom completion functions for file suggestions _ailock_locked_files() { local -a files files=(\${(f)"\$(ailock completion-helper --type locked-files --partial \$words[CURRENT] 2>/dev/null)"}) if [[ -n "\$files" ]]; then _describe -t files 'locked file' files else _files fi } _ailock_unlocked_files() { local -a files files=(\${(f)"\$(ailock completion-helper --type unlocked-files --partial \$words[CURRENT] 2>/dev/null)"}) if [[ -n "\$files" ]]; then _describe -t files 'unlocked file' files else _files fi } # Ensure completion system is initialized if ! command -v compdef &>/dev/null; then autoload -Uz compinit && compinit fi # Set up completion for both ailock and aiunlock if command -v compdef &>/dev/null; then compdef _ailock ailock compdef _ailock aiunlock fi # Lazy loading support (optional) # To enable lazy loading, wrap the function: # _ailock_lazy() { # unfunction "\$0" # source <(ailock completion zsh) # _ailock "\$@" # } # if command -v compdef &>/dev/null; then # compdef _ailock_lazy ailock # compdef _ailock_lazy aiunlock # fi `; } //# sourceMappingURL=zsh.js.map