Skip to content

Commit 8e4403b

Browse files
committed
implemented a purpose-based app suggestion system for the archpkg tool Issue #18 Solved
1 parent aebb051 commit 8e4403b

9 files changed

Lines changed: 777 additions & 18 deletions

File tree

README.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ archpkg-helper is designed to work across Linux distributions. While originally
2020

2121
## Features
2222

23+
- **Purpose-based App Suggestions**: Get app recommendations based on what you want to do (e.g., "video editing", "office work", "programming")
24+
- **Intelligent Query Matching**: Natural language processing to understand user intent (e.g., "apps to edit videos" → video editing)
2325
- Search for packages and generate install commands for:
2426
- pacman (Arch), AUR, apt (Debian/Ubuntu), dnf (Fedora), flatpak, snap
2527
- Cross-distro support (not limited to Arch)
@@ -120,7 +122,30 @@ After installation, the CLI is available as `archpkg`.
120122

121123
Here are some common commands for using the archpkg tool:
122124

123-
#### 1. Search for a Package
125+
#### 1. Purpose-based App Suggestions (NEW!)
126+
127+
Get app recommendations based on what you want to do:
128+
129+
```sh
130+
# Get video editing apps
131+
archpkg suggest "video editing"
132+
133+
# Get office applications
134+
archpkg suggest "office"
135+
136+
# Get programming tools
137+
archpkg suggest "coding"
138+
139+
# Natural language queries work too!
140+
archpkg suggest "apps to edit videos"
141+
archpkg suggest "programming tools"
142+
archpkg suggest "photo editing"
143+
144+
# List all available purposes
145+
archpkg suggest --list
146+
```
147+
148+
#### 2. Search for a Package
124149

125150
Search for a package across all supported package managers:
126151

@@ -131,7 +156,7 @@ archpkg search firefox
131156

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

134-
#### 2. Install a Package
159+
#### 3. Install a Package
135160

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

@@ -142,7 +167,7 @@ archpkg install firefox
142167

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

145-
#### 3. Install a Package from AUR (Arch User Repository)
170+
#### 4. Install a Package from AUR (Arch User Repository)
146171

147172
To install from the AUR specifically:
148173

@@ -153,7 +178,7 @@ archpkg install vscode --source aur
153178

154179
This installs `vscode` from the AUR.
155180

156-
#### 4. Install a Package from Pacman
181+
#### 5. Install a Package from Pacman
157182

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

@@ -162,7 +187,7 @@ archpkg install firefox --source pacman
162187
```
163188

164189

165-
#### 5. Remove a Package
190+
#### 6. Remove a Package
166191

167192
To generate commands to remove a package:
168193

@@ -280,6 +305,11 @@ Top-level layout of this repository:
280305
archpkg-helper/
281306
├── .github/ # issue templates and pull request template
282307
├── archpkg/ # Core Python package code (CLI and logic)
308+
│ ├── suggest.py # Purpose-based app suggestions module
309+
│ ├── cli.py # Main CLI interface
310+
│ └── ... # Other modules
311+
├── data/ # Data files for suggestions
312+
│ └── purpose_mapping.yaml # Purpose-to-apps mapping (community-driven)
283313
├── install.sh # One-command installer script (uses pipx)
284314
├── pyproject.toml # Build/metadata configuration
285315
├── setup.py # Packaging configuration (entry points, deps)
@@ -308,6 +338,31 @@ Contributions are welcome! Please:
308338
5. Open a Pull Request
309339

310340
Report bugs or request features via the [issue tracker](https://github.com/AdmGenSameer/archpkg-helper/issues).
341+
342+
### Contributing to Purpose Mappings
343+
344+
The purpose-based suggestions are powered by a community-driven mapping file at `data/purpose_mapping.yaml`. You can help improve the suggestions by:
345+
346+
1. **Adding new purposes**: Add new categories of applications (e.g., "security", "education", "gaming")
347+
2. **Adding more apps**: Suggest additional applications for existing purposes
348+
3. **Improving descriptions**: Add better descriptions for applications
349+
4. **Adding synonyms**: Help improve the natural language processing by adding more phrase mappings
350+
351+
To contribute:
352+
1. Edit `data/purpose_mapping.yaml` to add your suggestions
353+
2. Test your changes with `python -m archpkg.cli suggest "your-purpose"`
354+
3. Submit a Pull Request with your improvements
355+
356+
Example contribution:
357+
```yaml
358+
# Add to data/purpose_mapping.yaml
359+
security:
360+
- firejail
361+
- tor
362+
- keepassxc
363+
- veracrypt
364+
- wireshark
365+
```
311366
---
312367
313368
## 🛣️ Roadmap
3.14 KB
Binary file not shown.
17.2 KB
Binary file not shown.

archpkg/cli.py

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from archpkg.search_dnf import search_dnf
2424
from archpkg.command_gen import generate_command
2525
from archpkg.logging_config import get_logger, PackageHelperLogger
26+
from archpkg.suggest import suggest_apps, list_purposes
2627

2728
console = Console()
2829
logger = get_logger(__name__)
@@ -316,10 +317,22 @@ def main() -> None:
316317
logger.info("Starting archpkg-helper CLI")
317318

318319
parser = argparse.ArgumentParser(description="Universal Package Helper CLI")
319-
parser.add_argument('query', type=str, nargs='*', help='Name of the software to search for')
320+
subparsers = parser.add_subparsers(dest='command', help='Available commands')
321+
322+
# Search command (default behavior)
323+
search_parser = subparsers.add_parser('search', help='Search for packages by name')
324+
search_parser.add_argument('query', type=str, nargs='*', help='Name of the software to search for')
325+
search_parser.add_argument('--aur', action='store_true', help='Prefer AUR packages over Pacman when both are available')
326+
327+
# Suggest command
328+
suggest_parser = subparsers.add_parser('suggest', help='Get app suggestions based on purpose')
329+
suggest_parser.add_argument('purpose', type=str, nargs='*', help='Purpose or use case (e.g., "video editing", "office")')
330+
suggest_parser.add_argument('--list', action='store_true', help='List all available purposes')
331+
332+
# Global arguments
320333
parser.add_argument('--debug', action='store_true', help='Enable debug logging to console')
321334
parser.add_argument('--log-info', action='store_true', help='Show logging configuration and exit')
322-
parser.add_argument('--aur', action='store_true', help='Prefer AUR packages over Pacman when both are available')
335+
323336
args = parser.parse_args()
324337

325338
# Enable debug mode if requested
@@ -342,15 +355,78 @@ def main() -> None:
342355
))
343356
return
344357

358+
# Handle different commands
359+
if args.command == 'suggest':
360+
handle_suggest_command(args)
361+
return
362+
elif args.command == 'search' or args.command is None:
363+
# Default to search behavior for backward compatibility
364+
handle_search_command(args)
365+
return
366+
else:
367+
console.print(Panel(
368+
"[red]Unknown command.[/red]\n\n"
369+
"[bold cyan]Available commands:[/bold cyan]\n"
370+
"- [cyan]archpkg search firefox[/cyan] - Search for packages by name\n"
371+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose\n"
372+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes\n"
373+
"- [cyan]archpkg --help[/cyan] - Show help information",
374+
title="Invalid Command",
375+
border_style="red"
376+
))
377+
return
378+
379+
380+
def handle_suggest_command(args) -> None:
381+
"""Handle the suggest command."""
382+
if args.list:
383+
logger.info("Listing all available purposes")
384+
list_purposes()
385+
return
386+
387+
if not args.purpose:
388+
console.print(Panel(
389+
"[red]No purpose specified.[/red]\n\n"
390+
"[bold cyan]Usage:[/bold cyan]\n"
391+
"- [cyan]archpkg suggest video editing[/cyan] - Get video editing apps\n"
392+
"- [cyan]archpkg suggest office[/cyan] - Get office applications\n"
393+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes\n"
394+
"- [cyan]archpkg suggest --help[/cyan] - Show help information",
395+
title="No Purpose Specified",
396+
border_style="red"
397+
))
398+
return
399+
400+
purpose = ' '.join(args.purpose)
401+
logger.info(f"Purpose suggestion query: '{purpose}'")
402+
403+
if not purpose.strip():
404+
logger.warning("Empty purpose query provided by user")
405+
console.print(Panel(
406+
"[red]Empty purpose query provided.[/red]\n\n"
407+
"[bold cyan]Usage:[/bold cyan]\n"
408+
"- [cyan]archpkg suggest video editing[/cyan] - Get video editing apps\n"
409+
"- [cyan]archpkg suggest office[/cyan] - Get office applications\n"
410+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes",
411+
title="Invalid Input",
412+
border_style="red"
413+
))
414+
return
415+
416+
# Display suggestions
417+
suggest_apps(purpose)
418+
419+
420+
def handle_search_command(args) -> None:
421+
"""Handle the search command (original functionality)."""
345422
if not args.query:
346423
console.print(Panel(
347424
"[red]No search query provided.[/red]\n\n"
348425
"[bold cyan]Usage:[/bold cyan]\n"
349-
"- [cyan]archpkg firefox[/cyan] - Search for Firefox\n"
350-
"- [cyan]archpkg visual studio code[/cyan] - Search for VS Code\n"
351-
"- [cyan]archpkg --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
352-
"- [cyan]archpkg --debug firefox[/cyan] - Search with debug output\n"
353-
"- [cyan]archpkg --log-info[/cyan] - Show logging configuration\n"
426+
"- [cyan]archpkg search firefox[/cyan] - Search for Firefox\n"
427+
"- [cyan]archpkg search visual studio code[/cyan] - Search for VS Code\n"
428+
"- [cyan]archpkg search --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
429+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose\n"
354430
"- [cyan]archpkg --help[/cyan] - Show help information",
355431
title="Invalid Input",
356432
border_style="red"
@@ -365,10 +441,10 @@ def main() -> None:
365441
console.print(Panel(
366442
"[red]Empty search query provided.[/red]\n\n"
367443
"[bold cyan]Usage:[/bold cyan]\n"
368-
"- [cyan]archpkg firefox[/cyan] - Search for Firefox\n"
369-
"- [cyan]archpkg visual studio code[/cyan] - Search for VS Code\n"
370-
"- [cyan]archpkg --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
371-
"- [cyan]archpkg --help[/cyan] - Show help information",
444+
"- [cyan]archpkg search firefox[/cyan] - Search for Firefox\n"
445+
"- [cyan]archpkg search visual studio code[/cyan] - Search for VS Code\n"
446+
"- [cyan]archpkg search --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
447+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose",
372448
title="Invalid Input",
373449
border_style="red"
374450
))

0 commit comments

Comments
 (0)