Professional CLI tool powered by Apple Intelligence for on-device code generation. Features modern terminal UI, real-time streaming, multi-language support, and conversation management.
Inspired by Apple-AI-CLI.
- Rust 1.70+ (edition 2021)
- macOS 15+ with Apple Intelligence support (for future integration)
- Apple Silicon Mac recommended
cargo install apple-code-assistantThen use the apple-code binary:
apple-code --helpcargo build
cargo run -- --help# Simple generation
apple-code -p "hello world in Python" -l python --tool-mode
# Summarize a diff (smartcat-style)
git diff | apple-code -p "summarize the changes" --tool-mode --char-limit 8000
# Use a template for tests
apple-code -p "write tests for this function" -T tests --tool-modeBy default, some models may still wrap code in ``` fences and add explanations. To force plain code output suitable for files and editors:
# Only code written to the file (no markdown, no explanation)
apple-code -p "implement binary search" -l python --save -o binary_search.py --tool-modeYou can further tighten behavior with a prompt template in config.toml, for example:
[prompts.strict_code]
system = "Never use markdown or explanations. Return only the final code."Then call:
apple-code -p "implement binary search" -l python -T strict_code --save -o binary_search.py --tool-mode# Interactive mode (REPL with logo, /help, /exit, /history, /sessions)
cargo run -- -i
# Direct code generation with preview
cargo run -- -p "hello world in Python" -l python --preview
# Save to file
cargo run -- -p "quicksort" -l rust --save -o sort.rs
# Copy to clipboard
cargo run -- -p "utility function" --copy
# Use stdin as context (pipe data in, smartcat-style)
git diff | apple-code -p "summarize the changes"
git diff | apple-code -p "summarize the changes" > summary.txt
cat src/main.rs | apple-code -p "add doc comments to this code"
# Use prompt templates from config.toml
apple-code -p "write tests for this function" -T tests
apple-code -p "refactor this module" -T refactor -l rust
# Extend previous conversation in non-interactive mode
apple-code -p "summarize the architecture of this project" --extend-conversation
apple-code -p "now propose improvements" --extend-conversation
# Repeat input before output (useful in editors)
git diff | apple-code -p "apply these changes but fix formatting" --repeat-input --tool-mode
# Limit size of piped/context data and add globbed context files
git diff | apple-code -p "summarize the changes" --char-limit 8000 --context-glob "src/**/*.rs"
# Edit existing file (send file content + prompt to model, write result back)
cargo run -- -p "add error handling" -e src/main.rs
# Configuration
cargo run -- config --list
cargo run -- config --get theme
cargo run -- config --set default_language=python
cargo run -- config --reset
# List models and languages, test API
cargo run -- models
cargo run -- languages
cargo run -- test- Config – Load from
.envand~/.config/apple-code-assistant/config.toml; subcommandconfig --list/get/set/reset - Terminal UI – ASCII logo, theme (light/dark), bordered code preview
- Code generation – Trait-based client (mock included); direct mode with
-pand options - REPL – Interactive mode with
/help,/exit,/clear,/history,/sessions,/models,/languages,/test - Conversations – Sessions persisted under config dir;
/historyand/sessions - File operations –
--save -o <file>,--edit <file> - Clipboard –
--copy(arboard) - Syntax highlighting – syntect in preview and REPL when language is set
- Multi-language – 20+ languages and aliases;
languagessubcommand; validation of--language - Stdin piping – When stdin is not a TTY (e.g.
git diff | apple-code -p "…") the piped content is appended to the prompt (smartcat-style) - Prompt templates – Templates configurables dans
config.toml, sélectionnés via--template/-T - CLI conversations –
--extend-conversationpour réutiliser la dernière session,--repeat-inputpour rejouer l’entrée avant la sortie - Context control –
--char-limitpour borner la taille de stdin/contexte,--context-globpour ajouter des fichiers de contexte par glob - Tool mode –
--tool-modepour une sortie brute adaptée aux éditeurs (aucun cadre ni mise en forme) - Signals – Ctrl+C handled with “Operation cancelled”
A step-by-step development plan (phases 1–8) is in docs/DEVELOPMENT_PLAN.md.
MIT