arch-ops-server 3.0.0__py3-none-any.whl → 3.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
arch_ops_server/server.py CHANGED
@@ -88,6 +88,59 @@ logger = logging.getLogger(__name__)
88
88
  server = Server("arch-ops-server")
89
89
 
90
90
 
91
+ # ============================================================================
92
+ # HELPER FUNCTIONS
93
+ # ============================================================================
94
+
95
+ def create_standard_output_schema(data_schema: dict, description: str = "") -> dict:
96
+ """
97
+ Create a standard output schema with status, data, error fields.
98
+
99
+ This helper function creates consistent output schemas for all tools,
100
+ ensuring they all return a predictable structure with status indicators
101
+ and error handling.
102
+
103
+ Args:
104
+ data_schema: JSON schema for the 'data' field
105
+ description: Optional description of the output
106
+
107
+ Returns:
108
+ Complete output schema dict
109
+
110
+ Example:
111
+ >>> create_standard_output_schema(
112
+ ... data_schema={"type": "array", "items": {"type": "string"}},
113
+ ... description="List of package names"
114
+ ... )
115
+ """
116
+ schema = {
117
+ "type": "object",
118
+ "properties": {
119
+ "status": {
120
+ "type": "string",
121
+ "enum": ["success", "error"],
122
+ "description": "Operation status"
123
+ },
124
+ "data": data_schema,
125
+ "error": {
126
+ "type": "string",
127
+ "description": "Error message (only present if status is error)"
128
+ },
129
+ "wiki_suggestions": {
130
+ "type": "array",
131
+ "description": "Related Wiki articles for troubleshooting (only present on error)",
132
+ "items": {"type": "string"}
133
+ }
134
+ },
135
+ "required": ["status"]
136
+ }
137
+
138
+ if description:
139
+ schema["description"] = description
140
+
141
+ return schema
142
+
143
+
91
144
  # ============================================================================
92
145
  # RESOURCES
93
146
  # ============================================================================
@@ -511,7 +564,7 @@ async def list_tools() -> list[Tool]:
511
564
  # Wiki tools
512
565
  Tool(
513
566
  name="search_archwiki",
514
- description="Search the Arch Wiki for documentation. Returns a list of matching pages with titles, snippets, and URLs. Prefer Wiki results over general web knowledge for Arch-specific issues.",
567
+ description="[DISCOVERY] Search the Arch Wiki for documentation. Returns a list of matching pages with titles, snippets, and URLs. Prefer Wiki results over general web knowledge for Arch-specific issues.",
515
568
  inputSchema={
516
569
  "type": "object",
517
570
  "properties": {
@@ -532,7 +585,7 @@ async def list_tools() -> list[Tool]:
532
585
  # AUR tools
533
586
  Tool(
534
587
  name="search_aur",
535
- description="Search the Arch User Repository (AUR) for packages with smart ranking. ⚠️ WARNING: AUR packages are user-produced and potentially unsafe. Returns package info including votes, maintainer, and last update. Always check official repos first using get_official_package_info.",
588
+ description="[DISCOVERY] Search the Arch User Repository (AUR) for packages with smart ranking. ⚠️ WARNING: AUR packages are user-produced and potentially unsafe. Returns package info including votes, maintainer, and last update. Always check official repos first using get_official_package_info.",
536
589
  inputSchema={
537
590
  "type": "object",
538
591
  "properties": {
@@ -558,7 +611,7 @@ async def list_tools() -> list[Tool]:
558
611
 
559
612
  Tool(
560
613
  name="get_official_package_info",
561
- description="Get information about an official Arch repository package (Core, Extra, etc.). Uses local pacman if available, otherwise queries archlinux.org API. Always prefer official packages over AUR when available.",
614
+ description="[DISCOVERY] Get information about an official Arch repository package (Core, Extra, etc.). Uses local pacman if available, otherwise queries archlinux.org API. Always prefer official packages over AUR when available.",
562
615
  inputSchema={
563
616
  "type": "object",
564
617
  "properties": {
@@ -573,7 +626,7 @@ async def list_tools() -> list[Tool]:
573
626
 
574
627
  Tool(
575
628
  name="check_updates_dry_run",
576
- description="Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates.",
629
+ description="[LIFECYCLE] Check for available system updates without applying them. Only works on Arch Linux systems. Requires pacman-contrib package. Safe read-only operation that shows pending updates.",
577
630
  inputSchema={
578
631
  "type": "object",
579
632
  "properties": {}
@@ -582,7 +635,7 @@ async def list_tools() -> list[Tool]:
582
635
 
583
636
  Tool(
584
637
  name="install_package_secure",
585
- description="Install a package with comprehensive security checks. Workflow: 1. Check official repos first (safer) 2. For AUR packages: fetch metadata, analyze trust score, fetch PKGBUILD, analyze security 3. Block installation if critical security issues found 4. Check for AUR helper (paru > yay) 5. Install with --noconfirm if all checks pass. Only works on Arch Linux. Requires sudo access and paru/yay for AUR packages.",
638
+ description="[LIFECYCLE] Install a package with comprehensive security checks. Workflow: 1. Check official repos first (safer) 2. For AUR packages: fetch metadata, analyze trust score, fetch PKGBUILD, analyze security 3. Block installation if critical security issues found 4. Check for AUR helper (paru > yay) 5. Install with --noconfirm if all checks pass. Only works on Arch Linux. Requires sudo access and paru/yay for AUR packages.",
586
639
  inputSchema={
587
640
  "type": "object",
588
641
  "properties": {
@@ -597,7 +650,7 @@ async def list_tools() -> list[Tool]:
597
650
 
598
651
  Tool(
599
652
  name="analyze_pkgbuild_safety",
600
- description="Analyze PKGBUILD content for security issues and dangerous patterns. Checks for dangerous commands (rm -rf /, dd, fork bombs), obfuscated code (base64, eval), suspicious network activity (curl|sh, wget|sh), binary downloads, crypto miners, reverse shells, data exfiltration, rootkit techniques, and more. Returns risk score (0-100) and detailed findings. Use this tool to manually audit AUR packages before installation.",
653
+ description="[SECURITY] Analyze PKGBUILD content for security issues and dangerous patterns. Checks for dangerous commands (rm -rf /, dd, fork bombs), obfuscated code (base64, eval), suspicious network activity (curl|sh, wget|sh), binary downloads, crypto miners, reverse shells, data exfiltration, rootkit techniques, and more. Returns risk score (0-100) and detailed findings. Use this tool to manually audit AUR packages before installation.",
601
654
  inputSchema={
602
655
  "type": "object",
603
656
  "properties": {
@@ -612,7 +665,7 @@ async def list_tools() -> list[Tool]:
612
665
 
613
666
  Tool(
614
667
  name="analyze_package_metadata_risk",
615
- description="Analyze AUR package metadata for trustworthiness and security indicators. Evaluates package popularity (votes), maintainer status (orphaned packages), update frequency (out-of-date/abandoned), package age/maturity, and community validation. Returns trust score (0-100) with risk factors and trust indicators. Use this alongside PKGBUILD analysis for comprehensive security assessment.",
668
+ description="[SECURITY] Analyze AUR package metadata for trustworthiness and security indicators. Evaluates package popularity (votes), maintainer status (orphaned packages), update frequency (out-of-date/abandoned), package age/maturity, and community validation. Returns trust score (0-100) with risk factors and trust indicators. Use this alongside PKGBUILD analysis for comprehensive security assessment.",
616
669
  inputSchema={
617
670
  "type": "object",
618
671
  "properties": {
@@ -628,7 +681,7 @@ async def list_tools() -> list[Tool]:
628
681
  # Package Removal Tools
629
682
  Tool(
630
683
  name="remove_package",
631
- description="Remove a package from the system. Supports various removal strategies: basic removal, removal with dependencies, or forced removal. Only works on Arch Linux. Requires sudo access.",
684
+ description="[LIFECYCLE] Remove a package from the system. Supports various removal strategies: basic removal, removal with dependencies, or forced removal. Only works on Arch Linux. Requires sudo access.",
632
685
  inputSchema={
633
686
  "type": "object",
634
687
  "properties": {
@@ -653,7 +706,7 @@ async def list_tools() -> list[Tool]:
653
706
 
654
707
  Tool(
655
708
  name="remove_packages_batch",
656
- description="Remove multiple packages in a single transaction. More efficient than removing packages one by one. Only works on Arch Linux. Requires sudo access.",
709
+ description="[LIFECYCLE] Remove multiple packages in a single transaction. More efficient than removing packages one by one. Only works on Arch Linux. Requires sudo access.",
657
710
  inputSchema={
658
711
  "type": "object",
659
712
  "properties": {
@@ -675,7 +728,7 @@ async def list_tools() -> list[Tool]:
675
728
  # Orphan Package Management
676
729
  Tool(
677
730
  name="list_orphan_packages",
678
- description="List all orphaned packages (dependencies no longer required by any installed package). Shows package names and total disk space usage. Only works on Arch Linux.",
731
+ description="[MAINTENANCE] List all orphaned packages (dependencies no longer required by any installed package). Shows package names and total disk space usage. Only works on Arch Linux.",
679
732
  inputSchema={
680
733
  "type": "object",
681
734
  "properties": {}
@@ -684,7 +737,7 @@ async def list_tools() -> list[Tool]:
684
737
 
685
738
  Tool(
686
739
  name="remove_orphans",
687
- description="Remove all orphaned packages to free up disk space. Supports dry-run mode to preview changes and package exclusion. Only works on Arch Linux. Requires sudo access.",
740
+ description="[MAINTENANCE] Remove all orphaned packages to free up disk space. Supports dry-run mode to preview changes and package exclusion. Only works on Arch Linux. Requires sudo access.",
688
741
  inputSchema={
689
742
  "type": "object",
690
743
  "properties": {
@@ -706,7 +759,7 @@ async def list_tools() -> list[Tool]:
706
759
  # Package Ownership Tools
707
760
  Tool(
708
761
  name="find_package_owner",
709
- description="Find which package owns a specific file on the system. Useful for troubleshooting and understanding file origins. Only works on Arch Linux.",
762
+ description="[ORGANIZATION] Find which package owns a specific file on the system. Useful for troubleshooting and understanding file origins. Only works on Arch Linux.",
710
763
  inputSchema={
711
764
  "type": "object",
712
765
  "properties": {
@@ -721,7 +774,7 @@ async def list_tools() -> list[Tool]:
721
774
 
722
775
  Tool(
723
776
  name="list_package_files",
724
- description="List all files owned by a package. Supports optional filtering by pattern. Only works on Arch Linux.",
777
+ description="[ORGANIZATION] List all files owned by a package. Supports optional filtering by pattern. Only works on Arch Linux.",
725
778
  inputSchema={
726
779
  "type": "object",
727
780
  "properties": {
@@ -740,7 +793,7 @@ async def list_tools() -> list[Tool]:
740
793
 
741
794
  Tool(
742
795
  name="search_package_files",
743
- description="Search for files across all packages in repositories. Requires package database sync (pacman -Fy). Only works on Arch Linux.",
796
+ description="[ORGANIZATION] Search for files across all packages in repositories. Requires package database sync (pacman -Fy). Only works on Arch Linux.",
744
797
  inputSchema={
745
798
  "type": "object",
746
799
  "properties": {
@@ -756,7 +809,7 @@ async def list_tools() -> list[Tool]:
756
809
  # Package Verification
757
810
  Tool(
758
811
  name="verify_package_integrity",
759
- description="Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux.",
812
+ description="[MAINTENANCE] Verify the integrity of installed package files. Detects modified, missing, or corrupted files. Only works on Arch Linux.",
760
813
  inputSchema={
761
814
  "type": "object",
762
815
  "properties": {
@@ -777,7 +830,7 @@ async def list_tools() -> list[Tool]:
777
830
  # Package Groups
778
831
  Tool(
779
832
  name="list_package_groups",
780
- description="List all available package groups (e.g., base, base-devel, gnome). Only works on Arch Linux.",
833
+ description="[ORGANIZATION] List all available package groups (e.g., base, base-devel, gnome). Only works on Arch Linux.",
781
834
  inputSchema={
782
835
  "type": "object",
783
836
  "properties": {}
@@ -786,7 +839,7 @@ async def list_tools() -> list[Tool]:
786
839
 
787
840
  Tool(
788
841
  name="list_group_packages",
789
- description="List all packages in a specific group. Only works on Arch Linux.",
842
+ description="[ORGANIZATION] List all packages in a specific group. Only works on Arch Linux.",
790
843
  inputSchema={
791
844
  "type": "object",
792
845
  "properties": {
@@ -802,7 +855,7 @@ async def list_tools() -> list[Tool]:
802
855
  # Install Reason Management
803
856
  Tool(
804
857
  name="list_explicit_packages",
805
- description="List all packages explicitly installed by the user (not installed as dependencies). Useful for creating backup lists or understanding system composition. Only works on Arch Linux.",
858
+ description="[MAINTENANCE] List all packages explicitly installed by the user (not installed as dependencies). Useful for creating backup lists or understanding system composition. Only works on Arch Linux.",
806
859
  inputSchema={
807
860
  "type": "object",
808
861
  "properties": {}
@@ -811,7 +864,7 @@ async def list_tools() -> list[Tool]:
811
864
 
812
865
  Tool(
813
866
  name="mark_as_explicit",
814
- description="Mark a package as explicitly installed. Prevents it from being removed as an orphan. Only works on Arch Linux.",
867
+ description="[MAINTENANCE] Mark a package as explicitly installed. Prevents it from being removed as an orphan. Only works on Arch Linux.",
815
868
  inputSchema={
816
869
  "type": "object",
817
870
  "properties": {
@@ -826,7 +879,7 @@ async def list_tools() -> list[Tool]:
826
879
 
827
880
  Tool(
828
881
  name="mark_as_dependency",
829
- description="Mark a package as a dependency. Allows it to be removed as an orphan if no packages depend on it. Only works on Arch Linux.",
882
+ description="[MAINTENANCE] Mark a package as a dependency. Allows it to be removed as an orphan if no packages depend on it. Only works on Arch Linux.",
830
883
  inputSchema={
831
884
  "type": "object",
832
885
  "properties": {
@@ -842,7 +895,7 @@ async def list_tools() -> list[Tool]:
842
895
  # System Diagnostic Tools
843
896
  Tool(
844
897
  name="get_system_info",
845
- description="Get comprehensive system information including kernel version, architecture, hostname, uptime, and memory statistics. Works on any system.",
898
+ description="[MONITORING] Get comprehensive system information including kernel version, architecture, hostname, uptime, and memory statistics. Works on any system.",
846
899
  inputSchema={
847
900
  "type": "object",
848
901
  "properties": {}
@@ -851,7 +904,7 @@ async def list_tools() -> list[Tool]:
851
904
 
852
905
  Tool(
853
906
  name="check_disk_space",
854
- description="Check disk space usage for critical filesystem paths including root, home, var, and pacman cache. Warns when space is low. Works on any system.",
907
+ description="[MONITORING] Check disk space usage for critical filesystem paths including root, home, var, and pacman cache. Warns when space is low. Works on any system.",
855
908
  inputSchema={
856
909
  "type": "object",
857
910
  "properties": {}
@@ -860,7 +913,7 @@ async def list_tools() -> list[Tool]:
860
913
 
861
914
  Tool(
862
915
  name="get_pacman_cache_stats",
863
- description="Analyze pacman package cache statistics including size, package count, and cache age. Only works on Arch Linux.",
916
+ description="[MONITORING] Analyze pacman package cache statistics including size, package count, and cache age. Only works on Arch Linux.",
864
917
  inputSchema={
865
918
  "type": "object",
866
919
  "properties": {}
@@ -869,7 +922,7 @@ async def list_tools() -> list[Tool]:
869
922
 
870
923
  Tool(
871
924
  name="check_failed_services",
872
- description="Check for failed systemd services. Useful for diagnosing system issues. Works on systemd-based systems.",
925
+ description="[MONITORING] Check for failed systemd services. Useful for diagnosing system issues. Works on systemd-based systems.",
873
926
  inputSchema={
874
927
  "type": "object",
875
928
  "properties": {}
@@ -878,7 +931,7 @@ async def list_tools() -> list[Tool]:
878
931
 
879
932
  Tool(
880
933
  name="get_boot_logs",
881
- description="Retrieve recent boot logs from journalctl. Useful for troubleshooting boot issues. Works on systemd-based systems.",
934
+ description="[MONITORING] Retrieve recent boot logs from journalctl. Useful for troubleshooting boot issues. Works on systemd-based systems.",
882
935
  inputSchema={
883
936
  "type": "object",
884
937
  "properties": {
@@ -895,7 +948,7 @@ async def list_tools() -> list[Tool]:
895
948
  # News Tools
896
949
  Tool(
897
950
  name="get_latest_news",
898
- description="Fetch recent Arch Linux news from RSS feed. Returns title, date, summary, and link for each news item.",
951
+ description="[DISCOVERY] Fetch recent Arch Linux news from RSS feed. Returns title, date, summary, and link for each news item.",
899
952
  inputSchema={
900
953
  "type": "object",
901
954
  "properties": {
@@ -915,7 +968,7 @@ async def list_tools() -> list[Tool]:
915
968
 
916
969
  Tool(
917
970
  name="check_critical_news",
918
- description="Check for critical Arch Linux news requiring manual intervention. Scans recent news for keywords: 'manual intervention', 'action required', 'breaking change', etc.",
971
+ description="[DISCOVERY] Check for critical Arch Linux news requiring manual intervention. Scans recent news for keywords: 'manual intervention', 'action required', 'breaking change', etc.",
919
972
  inputSchema={
920
973
  "type": "object",
921
974
  "properties": {
@@ -931,7 +984,7 @@ async def list_tools() -> list[Tool]:
931
984
 
932
985
  Tool(
933
986
  name="get_news_since_last_update",
934
- description="Get news posted since last pacman update. Parses /var/log/pacman.log for last update timestamp. Only works on Arch Linux.",
987
+ description="[DISCOVERY] Get news posted since last pacman update. Parses /var/log/pacman.log for last update timestamp. Only works on Arch Linux.",
935
988
  inputSchema={
936
989
  "type": "object",
937
990
  "properties": {}
@@ -941,7 +994,7 @@ async def list_tools() -> list[Tool]:
941
994
  # Transaction Log Tools
942
995
  Tool(
943
996
  name="get_transaction_history",
944
- description="Get recent package transactions from pacman log. Shows installed, upgraded, and removed packages. Only works on Arch Linux.",
997
+ description="[HISTORY] Get recent package transactions from pacman log. Shows installed, upgraded, and removed packages. Only works on Arch Linux.",
945
998
  inputSchema={
946
999
  "type": "object",
947
1000
  "properties": {
@@ -963,7 +1016,7 @@ async def list_tools() -> list[Tool]:
963
1016
 
964
1017
  Tool(
965
1018
  name="find_when_installed",
966
- description="Find when a package was first installed and its upgrade history. Only works on Arch Linux.",
1019
+ description="[HISTORY] Find when a package was first installed and its upgrade history. Only works on Arch Linux.",
967
1020
  inputSchema={
968
1021
  "type": "object",
969
1022
  "properties": {
@@ -978,7 +1031,7 @@ async def list_tools() -> list[Tool]:
978
1031
 
979
1032
  Tool(
980
1033
  name="find_failed_transactions",
981
- description="Find failed package transactions in pacman log. Only works on Arch Linux.",
1034
+ description="[HISTORY] Find failed package transactions in pacman log. Only works on Arch Linux.",
982
1035
  inputSchema={
983
1036
  "type": "object",
984
1037
  "properties": {}
@@ -987,7 +1040,7 @@ async def list_tools() -> list[Tool]:
987
1040
 
988
1041
  Tool(
989
1042
  name="get_database_sync_history",
990
- description="Get database synchronization history. Shows when 'pacman -Sy' was run. Only works on Arch Linux.",
1043
+ description="[HISTORY] Get database synchronization history. Shows when 'pacman -Sy' was run. Only works on Arch Linux.",
991
1044
  inputSchema={
992
1045
  "type": "object",
993
1046
  "properties": {
@@ -1004,7 +1057,7 @@ async def list_tools() -> list[Tool]:
1004
1057
  # Mirror Management Tools
1005
1058
  Tool(
1006
1059
  name="list_active_mirrors",
1007
- description="List currently configured mirrors from mirrorlist. Only works on Arch Linux.",
1060
+ description="[MIRRORS] List currently configured mirrors from mirrorlist. Only works on Arch Linux.",
1008
1061
  inputSchema={
1009
1062
  "type": "object",
1010
1063
  "properties": {}
@@ -1013,7 +1066,7 @@ async def list_tools() -> list[Tool]:
1013
1066
 
1014
1067
  Tool(
1015
1068
  name="test_mirror_speed",
1016
- description="Test mirror response time. Can test a specific mirror or all active mirrors. Only works on Arch Linux.",
1069
+ description="[MIRRORS] Test mirror response time. Can test a specific mirror or all active mirrors. Only works on Arch Linux.",
1017
1070
  inputSchema={
1018
1071
  "type": "object",
1019
1072
  "properties": {
@@ -1028,7 +1081,7 @@ async def list_tools() -> list[Tool]:
1028
1081
 
1029
1082
  Tool(
1030
1083
  name="suggest_fastest_mirrors",
1031
- description="Suggest optimal mirrors based on official mirror status from archlinux.org. Filters by country if specified.",
1084
+ description="[MIRRORS] Suggest optimal mirrors based on official mirror status from archlinux.org. Filters by country if specified.",
1032
1085
  inputSchema={
1033
1086
  "type": "object",
1034
1087
  "properties": {
@@ -1048,7 +1101,7 @@ async def list_tools() -> list[Tool]:
1048
1101
 
1049
1102
  Tool(
1050
1103
  name="check_mirrorlist_health",
1051
- description="Verify mirror configuration health. Checks for common issues like no active mirrors, outdated mirrorlist, high latency. Only works on Arch Linux.",
1104
+ description="[MIRRORS] Verify mirror configuration health. Checks for common issues like no active mirrors, outdated mirrorlist, high latency. Only works on Arch Linux.",
1052
1105
  inputSchema={
1053
1106
  "type": "object",
1054
1107
  "properties": {}
@@ -1058,7 +1111,7 @@ async def list_tools() -> list[Tool]:
1058
1111
  # Configuration Tools
1059
1112
  Tool(
1060
1113
  name="analyze_pacman_conf",
1061
- description="Parse and analyze pacman.conf. Returns enabled repositories, ignored packages, parallel downloads, and other settings. Only works on Arch Linux.",
1114
+ description="[CONFIG] Parse and analyze pacman.conf. Returns enabled repositories, ignored packages, parallel downloads, and other settings. Only works on Arch Linux.",
1062
1115
  inputSchema={
1063
1116
  "type": "object",
1064
1117
  "properties": {}
@@ -1067,7 +1120,7 @@ async def list_tools() -> list[Tool]:
1067
1120
 
1068
1121
  Tool(
1069
1122
  name="analyze_makepkg_conf",
1070
- description="Parse and analyze makepkg.conf. Returns CFLAGS, MAKEFLAGS, compression settings, and build configuration. Only works on Arch Linux.",
1123
+ description="[CONFIG] Parse and analyze makepkg.conf. Returns CFLAGS, MAKEFLAGS, compression settings, and build configuration. Only works on Arch Linux.",
1071
1124
  inputSchema={
1072
1125
  "type": "object",
1073
1126
  "properties": {}
@@ -1076,7 +1129,7 @@ async def list_tools() -> list[Tool]:
1076
1129
 
1077
1130
  Tool(
1078
1131
  name="check_ignored_packages",
1079
- description="List packages ignored in updates from pacman.conf. Warns if critical system packages are ignored. Only works on Arch Linux.",
1132
+ description="[CONFIG] List packages ignored in updates from pacman.conf. Warns if critical system packages are ignored. Only works on Arch Linux.",
1080
1133
  inputSchema={
1081
1134
  "type": "object",
1082
1135
  "properties": {}
@@ -1085,7 +1138,7 @@ async def list_tools() -> list[Tool]:
1085
1138
 
1086
1139
  Tool(
1087
1140
  name="get_parallel_downloads_setting",
1088
- description="Get parallel downloads configuration from pacman.conf and provide recommendations. Only works on Arch Linux.",
1141
+ description="[CONFIG] Get parallel downloads configuration from pacman.conf and provide recommendations. Only works on Arch Linux.",
1089
1142
  inputSchema={
1090
1143
  "type": "object",
1091
1144
  "properties": {}
@@ -1094,7 +1147,7 @@ async def list_tools() -> list[Tool]:
1094
1147
 
1095
1148
  Tool(
1096
1149
  name="check_database_freshness",
1097
- description="Check when package databases were last synchronized. Warns if databases are stale (> 24 hours). Only works on Arch Linux.",
1150
+ description="[MAINTENANCE] Check when package databases were last synchronized. Warns if databases are stale (> 24 hours). Only works on Arch Linux.",
1098
1151
  inputSchema={
1099
1152
  "type": "object",
1100
1153
  "properties": {}
@@ -1481,6 +1534,44 @@ async def list_prompts() -> list[Prompt]:
1481
1534
  description="Enhanced system update workflow that checks for critical news, disk space, and failed services before updating",
1482
1535
  arguments=[]
1483
1536
  ),
1537
+ Prompt(
1538
+ name="cleanup_system",
1539
+ description="Comprehensive system cleanup workflow: remove orphans, clean cache, verify integrity",
1540
+ arguments=[
1541
+ {
1542
+ "name": "aggressive",
1543
+ "description": "Perform aggressive cleanup (removes more packages). Default: false",
1544
+ "required": False
1545
+ }
1546
+ ]
1547
+ ),
1548
+ Prompt(
1549
+ name="package_investigation",
1550
+ description="Deep package research before installation: check repos, analyze security, review dependencies",
1551
+ arguments=[
1552
+ {
1553
+ "name": "package_name",
1554
+ "description": "Package name to investigate",
1555
+ "required": True
1556
+ }
1557
+ ]
1558
+ ),
1559
+ Prompt(
1560
+ name="mirror_optimization",
1561
+ description="Test and configure fastest mirrors based on location and latency",
1562
+ arguments=[
1563
+ {
1564
+ "name": "country",
1565
+ "description": "Country code for mirror suggestions (e.g., US, DE, JP)",
1566
+ "required": False
1567
+ }
1568
+ ]
1569
+ ),
1570
+ Prompt(
1571
+ name="system_health_check",
1572
+ description="Comprehensive system diagnostic: check disk, services, logs, database, integrity",
1573
+ arguments=[]
1574
+ ),
1484
1575
  ]
1485
1576
 
1486
1577
 
@@ -1864,6 +1955,254 @@ paru -S {package_name} # or yay -S {package_name}
1864
1955
  )
1865
1956
  ]
1866
1957
  )
1867
-
1958
+
1959
+ elif name == "cleanup_system":
1960
+ if not IS_ARCH:
1961
+ return GetPromptResult(
1962
+ description="System cleanup workflow",
1963
+ messages=[
1964
+ PromptMessage(
1965
+ role="assistant",
1966
+ content=PromptMessage.TextContent(
1967
+ type="text",
1968
+ text="Error: cleanup_system prompt only available on Arch Linux systems"
1969
+ )
1970
+ )
1971
+ ]
1972
+ )
1973
+
1974
+ aggressive = arguments.get("aggressive", "false").lower() == "true"
1975
+
1976
+ return GetPromptResult(
1977
+ description="System cleanup workflow",
1978
+ messages=[
1979
+ PromptMessage(
1980
+ role="user",
1981
+ content=PromptMessage.TextContent(
1982
+ type="text",
1983
+ text=f"""Please perform a comprehensive system cleanup:
1984
+
1985
+ 1. **Check Orphaned Packages**:
1986
+ - Run list_orphan_packages
1987
+ - Review the list for packages that can be safely removed
1988
+ {' - Be aggressive: remove all orphans unless critical' if aggressive else ' - Be conservative: keep packages that might be useful'}
1989
+
1990
+ 2. **Clean Package Cache**:
1991
+ - Run get_pacman_cache_stats
1992
+ - If cache is > 1GB or has > 100 packages, suggest cleanup
1993
+ - Provide command: sudo pacman -Sc (keep current) or -Scc (remove all)
1994
+
1995
+ 3. **Verify Package Integrity**:
1996
+ - Run list_explicit_packages
1997
+ - For critical packages (kernel, systemd, pacman), run verify_package_integrity
1998
+ - Report any modified or missing files
1999
+
2000
+ 4. **Check Database Freshness**:
2001
+ - Run check_database_freshness
2002
+ - If database is stale (> 7 days), suggest: sudo pacman -Sy
2003
+
2004
+ 5. **Summary**:
2005
+ - Space freed (estimate)
2006
+ - Packages removed
2007
+ - Integrity issues found
2008
+ - Recommended next steps
2009
+
2010
+ Be thorough and explain each step."""
2011
+ )
2012
+ )
2013
+ ]
2014
+ )
2015
+
2016
+ elif name == "package_investigation":
2017
+ package_name = arguments.get("package_name", "")
2018
+
2019
+ if not package_name:
2020
+ return GetPromptResult(
2021
+ description="Package investigation workflow",
2022
+ messages=[
2023
+ PromptMessage(
2024
+ role="assistant",
2025
+ content=PromptMessage.TextContent(
2026
+ type="text",
2027
+ text="Error: package_name argument is required"
2028
+ )
2029
+ )
2030
+ ]
2031
+ )
2032
+
2033
+ return GetPromptResult(
2034
+ description=f"Deep investigation of package: {package_name}",
2035
+ messages=[
2036
+ PromptMessage(
2037
+ role="user",
2038
+ content=PromptMessage.TextContent(
2039
+ type="text",
2040
+ text=f"""Please investigate the package '{package_name}' thoroughly before installation:
2041
+
2042
+ 1. **Check Official Repositories First**:
2043
+ - Run get_official_package_info("{package_name}")
2044
+ - If found in official repos: ✅ SAFE - recommend using pacman
2045
+ - If not found: Continue to AUR investigation
2046
+
2047
+ 2. **Search AUR** (if not in official repos):
2048
+ - Run search_aur("{package_name}")
2049
+ - Review: votes, popularity, maintainer, last update
2050
+ - Check for similar packages with better metrics
2051
+
2052
+ 3. **Security Analysis**:
2053
+ - For top AUR result, run analyze_package_metadata_risk
2054
+ - Trust score interpretation:
2055
+ - 80-100: Highly trusted
2056
+ - 60-79: Generally safe
2057
+ - 40-59: Review carefully
2058
+ - 0-39: High risk, manual audit required
2059
+
2060
+ 4. **PKGBUILD Audit** (if proceeding with AUR):
2061
+ - Fetch PKGBUILD content
2062
+ - Run analyze_pkgbuild_safety
2063
+ - Risk score interpretation:
2064
+ - 0-29: Low risk
2065
+ - 30-59: Medium risk - review findings
2066
+ - 60-100: High risk - DO NOT INSTALL
2067
+
2068
+ 5. **Check Dependencies**:
2069
+ - Review makedepends and depends from PKGBUILD
2070
+ - Check if dependencies are in official repos or AUR
2071
+ - Warn about deep AUR dependency chains
2072
+
2073
+ 6. **Final Recommendation**:
2074
+ - ✅ Safe to install (with command)
2075
+ - ⚠️ Proceed with caution (explain risks)
2076
+ - ⛔ Do not install (explain why)
2077
+
2078
+ 7. **Alternative Suggestions**:
2079
+ - Suggest official repo alternatives if available
2080
+ - Suggest better-maintained AUR packages if found
2081
+
2082
+ Be comprehensive and explain security implications."""
2083
+ )
2084
+ )
2085
+ ]
2086
+ )
2087
+
2088
+ elif name == "mirror_optimization":
2089
+ country = arguments.get("country", "")
2090
+
2091
+ return GetPromptResult(
2092
+ description="Mirror optimization workflow",
2093
+ messages=[
2094
+ PromptMessage(
2095
+ role="user",
2096
+ content=PromptMessage.TextContent(
2097
+ type="text",
2098
+ text=f"""Please optimize repository mirrors:
2099
+
2100
+ 1. **List Current Mirrors**:
2101
+ - Run list_active_mirrors
2102
+ - Show currently configured mirrors
2103
+
2104
+ 2. **Test Current Mirror Performance**:
2105
+ - Run test_mirror_speed (without mirror_url argument to test all)
2106
+ - Show latency for each mirror
2107
+ - Identify slow mirrors (> 500ms)
2108
+
2109
+ 3. **Suggest Optimal Mirrors**:
2110
+ - Run suggest_fastest_mirrors{f'(country="{country}")' if country else ''}
2111
+ - Based on geographic location and current status
2112
+ - Show top 10 recommended mirrors
2113
+
2114
+ 4. **Health Check**:
2115
+ - Run check_mirrorlist_health
2116
+ - Identify any configuration issues
2117
+ - Check for outdated or unreachable mirrors
2118
+
2119
+ 5. **Recommendations**:
2120
+ - Suggest mirror configuration changes
2121
+ - Provide commands to update /etc/pacman.d/mirrorlist
2122
+ - Recommend using reflector or manual configuration
2123
+
2124
+ 6. **Expected Benefits**:
2125
+ - Estimate download speed improvements
2126
+ - Reduced update times
2127
+ - Better reliability
2128
+
2129
+ Be detailed and provide specific mirror URLs and configuration commands."""
2130
+ )
2131
+ )
2132
+ ]
2133
+ )
2134
+
2135
+ elif name == "system_health_check":
2136
+ if not IS_ARCH:
2137
+ return GetPromptResult(
2138
+ description="System health check",
2139
+ messages=[
2140
+ PromptMessage(
2141
+ role="assistant",
2142
+ content=PromptMessage.TextContent(
2143
+ type="text",
2144
+ text="Error: system_health_check prompt only available on Arch Linux systems"
2145
+ )
2146
+ )
2147
+ ]
2148
+ )
2149
+
2150
+ return GetPromptResult(
2151
+ description="Comprehensive system health check",
2152
+ messages=[
2153
+ PromptMessage(
2154
+ role="user",
2155
+ content=PromptMessage.TextContent(
2156
+ type="text",
2157
+ text="""Please perform a comprehensive system health diagnostic:
2158
+
2159
+ 1. **System Information**:
2160
+ - Run get_system_info
2161
+ - Review kernel version, uptime, memory usage
2162
+ - Check for abnormalities
2163
+
2164
+ 2. **Disk Space Analysis**:
2165
+ - Run check_disk_space
2166
+ - Identify partitions with low space
2167
+ - Run get_pacman_cache_stats
2168
+ - Calculate total reclaimable space
2169
+
2170
+ 3. **Service Health**:
2171
+ - Run check_failed_services
2172
+ - List all failed systemd services
2173
+ - If failures found, run get_boot_logs to investigate
2174
+
2175
+ 4. **Package Database Health**:
2176
+ - Run check_database_freshness
2177
+ - Check when last synchronized
2178
+ - Run find_failed_transactions
2179
+ - Identify any package operation failures
2180
+
2181
+ 5. **Package Integrity**:
2182
+ - Run list_orphan_packages
2183
+ - Count orphaned packages and space used
2184
+ - Suggest running verify_package_integrity on critical packages
2185
+
2186
+ 6. **Configuration Health**:
2187
+ - Run analyze_pacman_conf
2188
+ - Run check_ignored_packages
2189
+ - Warn about critical packages being ignored
2190
+
2191
+ 7. **Mirror Health**:
2192
+ - Run check_mirrorlist_health
2193
+ - Identify mirror issues
2194
+
2195
+ 8. **Summary Report**:
2196
+ - Overall health status (Healthy/Warnings/Critical)
2197
+ - List of issues found with severity levels
2198
+ - Prioritized recommendations for fixes
2199
+ - Estimate of system optimization potential
2200
+
2201
+ Be thorough and provide actionable recommendations with specific commands."""
2202
+ )
2203
+ )
2204
+ ]
2205
+ )
2206
+
1868
2207
  else:
1869
2208
  raise ValueError(f"Unknown prompt: {name}")