Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 47 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ archpkg-helper is designed to work across Linux distributions. While originally

## Features

- **Intelligent Autocomplete**: Smart inline suggestions for package names with trie-based search, alias mapping, and frequency-based ranking
- **Purpose-based App Suggestions**: Get app recommendations based on what you want to do (e.g., "video editing", "office work", "programming")
- **Intelligent Query Matching**: Natural language processing to understand user intent (e.g., "apps to edit videos" → video editing)
- **Multi-shell Support**: Works seamlessly with bash, zsh, and fish shells
- Search for packages and generate install commands for:
- pacman (Arch), AUR, apt (Debian/Ubuntu), dnf (Fedora), flatpak, snap
- Cross-distro support (not limited to Arch)
Expand Down Expand Up @@ -136,7 +138,36 @@ After installation, the CLI is available as `archpkg`.

Here are some common commands for using the archpkg tool:

#### 1. Purpose-based App Suggestions (NEW!)
#### 1. Intelligent Autocomplete (NEW!)

Get smart inline suggestions as you type:

```sh
# Type and press Tab for suggestions
archpkg install vs<TAB>
# Shows: visual-studio-code, vscodium, vscode-insiders

archpkg install chr<TAB>
# Shows: chromium, google-chrome

# Abbreviation matching works too!
archpkg install vsc<TAB>
# Shows: visual-studio-code

# Context-aware suggestions
archpkg remove <TAB> # Shows recently used packages first
archpkg install <TAB> # Shows available packages
```

**Setup autocomplete:**
```sh
# Automatic setup for your shell
./scripts/autocomplete/install_completion.sh

# Or see docs/AUTOCOMPLETE.md for manual setup
```

#### 2. Purpose-based App Suggestions

Get app recommendations based on what you want to do:

Expand All @@ -159,7 +190,7 @@ archpkg suggest "photo editing"
archpkg suggest --list
```

#### 2. Search for a Package
#### 3. Search for a Package

Search for a package across all supported package managers:

Expand All @@ -170,7 +201,7 @@ archpkg search firefox

This command will search for the `firefox` package across multiple package managers (e.g., pacman, AUR, apt).

#### 3. Install a Package
#### 4. Install a Package

Once you have identified a package, use the install command to generate the correct installation command for your system:

Expand All @@ -181,7 +212,7 @@ archpkg install firefox

This will generate an appropriate installation command (e.g., `pacman -S firefox` for Arch-based systems).

#### 4. Install a Package from AUR (Arch User Repository)
#### 5. Install a Package from AUR (Arch User Repository)

To install from the AUR specifically:

Expand All @@ -192,7 +223,7 @@ archpkg install vscode --source aur

This installs `vscode` from the AUR.

#### 5. Install a Package from Pacman
#### 6. Install a Package from Pacman

To install a package directly using pacman (e.g., on Arch Linux):

Expand All @@ -201,7 +232,7 @@ archpkg install firefox --source pacman
```


#### 6. Remove a Package
#### 7. Remove a Package

To generate commands to remove a package:

Expand Down Expand Up @@ -320,10 +351,20 @@ archpkg-helper/
├── .github/ # issue templates and pull request template
├── archpkg/ # Core Python package code (CLI and logic)
│ ├── suggest.py # Purpose-based app suggestions module
│ ├── completion.py # Intelligent autocomplete backend
│ ├── cli.py # Main CLI interface
│ └── ... # Other modules
├── data/ # Data files for suggestions
│ └── purpose_mapping.yaml # Purpose-to-apps mapping (community-driven)
├── scripts/ # Utility scripts
│ ├── autocomplete/ # Shell completion scripts
│ │ ├── archpkg.bash # Bash completion script
│ │ ├── _archpkg # Zsh completion script
│ │ ├── archpkg.fish # Fish completion script
│ │ └── install_completion.sh # Auto-installation script
│ └── test_completion.py # Test script for autocomplete
├── docs/ # Documentation
│ └── AUTOCOMPLETE.md # Detailed autocomplete documentation
├── install.sh # One-command installer script (uses pipx)
├── pyproject.toml # Build/metadata configuration
├── setup.py # Packaging configuration (entry points, deps)
Expand Down
Binary file modified archpkg/__pycache__/cli.cpython-312.pyc
Binary file not shown.
Binary file added archpkg/__pycache__/completion.cpython-312.pyc
Binary file not shown.
Binary file modified archpkg/__pycache__/suggest.cpython-312.pyc
Binary file not shown.
35 changes: 35 additions & 0 deletions archpkg/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
from archpkg.command_gen import generate_command
from archpkg.logging_config import get_logger, PackageHelperLogger
from archpkg.suggest import suggest_apps, list_purposes
master
from archpkg.completion import complete_packages

from archpkg.cache import get_cache_manager, CacheConfig
main

console = Console()
logger = get_logger(__name__)
Expand Down Expand Up @@ -331,6 +335,12 @@ def main() -> None:
suggest_parser.add_argument('purpose', type=str, nargs='*', help='Purpose or use case (e.g., "video editing", "office")')
suggest_parser.add_argument('--list', action='store_true', help='List all available purposes')

# Completion command (as a subcommand)
completion_parser = subparsers.add_parser('complete', help='Generate completion suggestions (for shell integration)')
completion_parser.add_argument('query', type=str, nargs='*', help='Query to complete')
completion_parser.add_argument('--context', type=str, default='install', help='Completion context (install, remove, etc.)')
completion_parser.add_argument('--limit', type=int, default=10, help='Maximum number of suggestions')

# Global arguments
parser.add_argument('--debug', action='store_true', help='Enable debug logging to console')
parser.add_argument('--log-info', action='store_true', help='Show logging configuration and exit')
Expand Down Expand Up @@ -400,6 +410,9 @@ def main() -> None:
if args.command == 'suggest':
handle_suggest_command(args)
return
elif args.command == 'complete':
handle_completion_command(args)
return
elif args.command == 'search' or args.command is None:
# Default to search behavior for backward compatibility
handle_search_command(args, cache_manager)
Expand All @@ -418,6 +431,28 @@ def main() -> None:
return


def handle_completion_command(args) -> None:
"""Handle the completion command for shell integration."""
if not args.query:
# Return empty completion if no query provided
return

query = ' '.join(args.query)
logger.debug(f"Completion query: '{query}' with context: '{args.context}'")

if not query.strip():
return

# Get completions and output them
try:
completions = complete_packages(query, args.context, args.limit)
if completions:
print(completions)
except Exception as e:
logger.error(f"Completion failed: {e}")
# Don't output anything on error to avoid breaking shell completion


def handle_suggest_command(args) -> None:
"""Handle the suggest command."""
if args.list:
Expand Down
Loading
Loading