{"id":15724697,"url":"https://github.com/davenchy/linux-bot","last_synced_at":"2025-10-14T19:31:02.487Z","repository":{"id":218367360,"uuid":"746206084","full_name":"Davenchy/linux-bot","owner":"Davenchy","description":"A Linux virtual assistant powered by ChatGPT.","archived":true,"fork":false,"pushed_at":"2024-02-01T01:33:38.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-18T16:54:34.734Z","etag":null,"topics":["ai","chatbot","chatgpt","chatgpt-api","cli","command","linux","python","virtual-assistant"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Davenchy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-21T11:45:20.000Z","updated_at":"2024-08-05T02:57:26.000Z","dependencies_parsed_at":"2024-02-01T02:39:06.481Z","dependency_job_id":"2772d7e1-bf8d-495f-bc0d-728ead3fb09e","html_url":"https://github.com/Davenchy/linux-bot","commit_stats":null,"previous_names":["davenchy/linux-bot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Davenchy/linux-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davenchy%2Flinux-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davenchy%2Flinux-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davenchy%2Flinux-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davenchy%2Flinux-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Davenchy","download_url":"https://codeload.github.com/Davenchy/linux-bot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davenchy%2Flinux-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020650,"owners_count":26086898,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatbot","chatgpt","chatgpt-api","cli","command","linux","python","virtual-assistant"],"created_at":"2024-10-03T22:17:38.671Z","updated_at":"2025-10-14T19:31:02.218Z","avatar_url":"https://github.com/Davenchy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linux Bot - Beta\n\nLinux Bot is a virtual assistant for Linux powered by ChatGPT.\n\n## Installation\n\nMake sure to install all the necessary components by running:\n\n```bash\npip install -r requirements.txt\n```\n\nAdditionally, you'll need to provide your OpenAI API key:\n\n```bash\nexport OPENAI_API_KEY=\"YOUR_API_KEY\"\n```\n\n## Usage\n\nTo start using Linux Bot, run the following command:\n\n```bash\npython main.py\n```\n\n## Abilities\n\nLinux Bot still in beta but it comes with the following abilities for testing:\n\n- Awareness of the current working directory.\n- Awareness of the current date and time.\n- Capability to list files in any specified path.\n- Ability to read files and analyze their content.\n- Ability to get file type and size.\n- Awareness of the installed package managers.\n- Ability to check if a package is installed or not.\n- Ability to install packages using a package manager.\n- Ability to execute general shell commands and analyze their output and errors.\n- Awareness of the environment variables.\n- Connected disks and partitions, their information and usage.\n- System CPU and Memory usage.\n\n### Define Ability\n\n\u003e An ability is a function that takes arguments and returns a string.\n\n1. Decorate The Ability Function\n\n   - Use the `@assistant.use` decorator to define an ability.\n   - The `assistant` here is the instance of the `Assistant` class you want to\n     add the ability to.\n\n2. Add Argument Descriptions\n\n   - Add a description to the decorator for each argument describing\n     the purpose of the argument.\n\n3. Provide Type Annotations\n\n   - Type annotations are required for each argument as it helps the system to\n     understand the type of the argument.\n\n4. Write a DocString\n\n   - Add a DocString for the ability function to describe why the assistant\n     should use this ability.\n\n5. Return a String\n\n   - Make sure your ability function returns a string, which contains\n     the described output.\n\nHere's an example for the `get_files_list` ability:\n\n```python\nimport os\nfrom assistant import Assistant\n\n\n# Create a new assistant instance with some instructions\nassistant = Assistant(\"You are a helpful assistant\")\n\n\n@assistant.use(path=\"the path where you want to list the files\")\ndef get_files_list(path: str) -\u003e str:\n    \"\"\"Get a list of files in the specified path\"\"\"\n    files = os.listdir(os.path.expanduser(path))\n    return \", \".join(files)\n```\n\n1. Import necessary modules\n   The `assistant` module is required for the `Assistant` class.\n   Which is used to create a new assistant instance.\n2. Create a new assistant instance with some instructions\n   The assistant needs some instructions to describe its behavior.\n3. Define an ability function\n   - Use the `@assistant.use` decorator\n   - Add a description in the decorator for each argument\n   - Add type annotations for each argument\n   - Add a DocString for the ability function\n   - Return a string which contains the described output of the function\n\nYou can catch exceptions in the following way:\n\n```python\ntry:\n    files = os.listdir(os.path.expanduser(path))\n    return \", \".join(files)\nexcept Exception as err:\n    return f\"Error: failed to get the files list: {err}\"\n```\n\n## Assistant Abilities In Deep\n\n\u003e **AssistantAbility** is the object that contains the definition of an ability.\n\n```python\nfrom assistant import AssistantAbility\n\n\ndef get_files_list(path: str) -\u003e str:\n   ...\n\nability = AssistantAbility(\n   name=\"get_files_list\",\n   description=\"Get a list of files in the specified path\",\n   action=get_files_list\n)\nability.add_argument(\n   \"path\",\n   type=string,\n   description=\"The path where you want to list the files\",\n   is_required=True,\n)\n```\n\nthen you can assign the ability to an assistant instance:\n\n```python\nassistant_instance.add_ability(ability)\n```\n\nTo ease the process you can use `AssistantAbility.generate_from_function`\nbut you need to do some modifications.\n\n1. Move the ability description to the function itself as a docstring.\n2. Add type annotations to the argument and a description inside the decorator.\n3. Required arguments are arguments that do not have a default value.\n\nAfter modifications:\n\n```python\nfrom assistant import AssistantAbility\n\n\ndef get_files_list(path: str) -\u003e str:\n   \"\"\"Get a list of files in the specified path\"\"\"\n   ...\n\n\nability = AssistantAbility.generate_from_function(\n   path=\"The path where you want to list the files\"\n)(func)\n```\n\nNow it is much easier to define an ability but you could also use\n`Assistant.ability` function decorator to generate the ability object and\n**inject it into the function itself**.\n\n```python\nfrom assistant import Assistant\n\n\n@Assistant.ability(path=\"The path where you want to list the files\")\ndef get_files_list(path: str) -\u003e str:\n   \"\"\"Get a list of files in the specified path\"\"\"\n   ...\n```\n\n- To check if the function or any object has an ability object injected inside\n  use the `Assistant.has_injected_ability` function\n\n- To get the injected ability object use the `Assistant.get_injected_ability`\n  function, if the object does not have an ability object injected inside use\n  it will raise **ValueError**\n\n\u003e Note: `assistant.add_ability` can detect and use the injected ability object\n\u003e So you don't need to do any extra work\n\n```python\n@Assistant.ability(path=\"The path where you want to list the files\")\ndef get_files_list(path: str) -\u003e str:\n   \"\"\"Get a list of files in the specified path\"\"\"\n   ...\n\nassistant_instance.add_ability(get_files_list)\n```\n\n### Load Abilities From Modules\n\nNow let's clean up our code and move the abilities to another file and just\nimport the ability objects or the functions itself into our main file.\n\nLet's say you defined many ability objects in file called `abilities.py`\ninstead of loading them one by one you can load all of them at once:\n\n```python\nassistant_instance.import_abilities_module(\"abilities\")\n```\n\n### Quick Notes\n\n`assistant.use` uses `Assistant.ability` under the hood to generate\n**AssistantAbility** and inject it into the function then uses\n`assistant.add_ability` to load it.\n\n`Assistant.ability` uses `AssistantAbility.generate_from_function` under\nthe hood to generate **AssistantAbility** object.\n\n`assistant.import_abilities_module` loads all the functions from the module then\nuses functions with ability object injected into, means that\nany python code in `abilities.py` like in example will be executed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavenchy%2Flinux-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavenchy%2Flinux-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavenchy%2Flinux-bot/lists"}