{"id":13588434,"url":"https://github.com/joone/loz","last_synced_at":"2025-10-23T02:42:44.524Z","repository":{"id":87960103,"uuid":"606991065","full_name":"joone/loz","owner":"joone","description":"Loz is a command-line tool that enables your preferred LLM to execute system commands and utilize Unix pipes, integrating AI capabilities with other Unix tools.","archived":false,"fork":false,"pushed_at":"2024-12-25T22:50:06.000Z","size":1579,"stargazers_count":260,"open_issues_count":2,"forks_count":15,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-11T01:02:47.444Z","etag":null,"topics":["automation","cli","codellama","git","gpt","llama2","llamacpp","llm","nodejs","ollama","openai-api","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joone.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":["joone"]}},"created_at":"2023-02-27T04:33:40.000Z","updated_at":"2025-04-14T11:23:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"468ecdba-9767-4557-92b6-611ee672f184","html_url":"https://github.com/joone/loz","commit_stats":{"total_commits":127,"total_committers":3,"mean_commits":"42.333333333333336","dds":"0.19685039370078738","last_synced_commit":"2132c92b42545826eaf03993cbf04e3a36647180"},"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joone%2Floz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joone%2Floz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joone%2Floz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joone%2Floz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joone","download_url":"https://codeload.github.com/joone/loz/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254448579,"owners_count":22072764,"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","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":["automation","cli","codellama","git","gpt","llama2","llamacpp","llm","nodejs","ollama","openai-api","typescript"],"created_at":"2024-08-01T15:06:42.832Z","updated_at":"2025-10-23T02:42:39.493Z","avatar_url":"https://github.com/joone.png","language":"TypeScript","readme":"# Loz [![NPM](https://img.shields.io/npm/v/chatgpt.svg)](https://www.npmjs.com/package/loz)\n\n![alt Loz Demo](https://github.com/joone/loz/blob/main/examples/loz_demo.gif?raw=true)\n\nLoz is a command-line tool that enables your preferred LLM to execute system commands and utilize Unix pipes, integrating AI capabilities with other Unix tools.\n\n## What's New\n\n### v0.3.1 - 2024-03-18\n- **Added**\n  - Git commit log files are now stored in .loz_log within each Git repository where Loz is executed.\n  - The ability to enable/disable appending 'generated by ${model name}' at the end of the Git commit message by running config attribution true or config attribution false.\n  - Added --attribution (-a) runtime argument to override the config attribution setting. The original attribution value stored remains unchanged.\n\n### v0.3.0 - 2024-02-24\n\n- **Added**\n  - Run Linux commands based on user prompts. Users can now execute Linux commands using natural language. For example, by running `loz \"find the largest file in the current directory\"`,\n    `Loz` will interpret the instruction and execute the corresponding Linux commands like `find . -type f -exec ls -l {} + | sort -k 5 -nr | head -n 1` to find the largest file. See more [examples](#examples).\n\n### v0.2.13 - 2024-02-22\n\n- **Added**\n  - Enhanced Git Commit Formatting: Commit messages are now structured with a clear separation between the title and body, improving readability and adherence to Git best practices.\n\n## Getting Started\n\nTo get started, run the following npm command:\n\n```\n$ sudo npm install loz -g\n```\n\nOr clone the repository:\n\n```\n$ git clone https://github.com/joone/loz.git\n```\n\nNodeJS and npm are required for this program to work. If you're on Linux, install them using your package manager. `sudo apt install nodejs npm` or `sudo dnf install nodejs npm` or `sudo pacman -S nodejs npm`\n\nThen install the other required dependencies:\n\n```\n$ ./install.sh\n```\n\n## Configuring LLM\n\nLoz supports [OpenAI API](https://platform.openai.com/docs/quickstart?context=node) and [Ollama](https://github.com/ollama/ollama) so you can switch between these LLM services easily, using the `config` command in the interactive mode.\n\n### Set up Ollama\n\nTo utilize Ollama on your local system, you'll need to install both llama2 and codellama models. Here's how you can do it on a Linux system:\n\n```\n$ curl https://ollama.ai/install.sh | sh\n$ ollama run llama2\n$ ollama run codellama\n```\n\nFor more information, see https://ollama.ai/download\n\n### Set up OpenAI API\n\nSetting up your OpenAI API credentials involves a few simple steps:\n\nFirst, create a `.env` file in the root of the project and add the following variables:\n\n```\nOPENAI_API_KEY=YOUR_KEY\n```\n\nOr if you install Loz using npm command, add `OPENAI_API_KEY=YOUR_KEY` in .bashrc\n\n```\nexport OPENAI_API_KEY=YOUR_KEY\n```\n\nIf you encounter the following error, it means you have exceeded your free quota:\n\n```\nRequest failed with status code 429:\nAPI request limit reached\n```\n\nTo continue using the API, it is necessary to set up a payment method through the following link:\nhttps://platform.openai.com/account/billing/payment-methods\n\n## Usage\n\n### Initial Configuration\n\nUpon your initial launch of Loz, you will have the opportunity to select your preferred LLM service.\n\n```\n$ loz\nChoose your LLM service: (ollama, openai)\n```\n\nYou can modify your LLM service preference at any time by using the `config` command in the interactive mode:\n\n```\n\u003e config api openai\n```\n\nAdditionally, you can change the model by entering:\n\n```\n\u003e config model llama2\n```\n\nor\n\n```\n\u003e config model codellama\n```\n\nYou can check the current settings by entering:\n\n```\n\u003e config\n  api: ollama\n  model: llama2\n```\n\nCurrently, gpt-3.5-turbo and all models provided by Ollama are supported.\n\n### Interactive mode\n\n```\n$ loz\n```\n\nOnce loz is running, you can start a conversation by interacting with it. loz will respond with a relevant message based on the input.\n\n### Run Linux Commands with Loz\n\nLoz empowers users to execute Linux commands using natural language. Below are some examples demonstrating how `loz`'s LLM backend translates natural language into Linux commands:\n\n#### Examples\n\n- Find the largest file in the current directory:\n\n  ```\n  loz \"find the largest file in the current directory\"\n  -rw-rw-r-- 1 foo bar 9020257 Jan 31 19:49 ./node_modules/typescript/lib/typescript.js\n  ```\n\n- Check if Apache2 is running:\n\n  ```\n  loz \"check if apache2 is running on this system\"\n  ● apache2.service - The Apache HTTP Server\n  ```\n\n- Detect GPUs on the system:\n  ```\n  loz \"Detect GPUs on this system\"\n  00:02.0 VGA compatible controller: Intel Corporation Device a780 (rev 04)\n  ```\n  For your information, this feature has only been tested with the OpenAI API.\n\n#### Caution\n\nTo prevent unintentional system modifications, avoid running commands that can alter or remove system files or configurations, such as `rm`, `mv`, `rmdir`, or `mkfs`.\n\n#### Safe Mode\n\nTo enhance security and avoid unintended command execution, loz can be run in Safe Mode. When activated, this mode requires user confirmation before executing any Linux command.\n\nActivate Safe Mode by setting the LOZ_SAFE=true environment variable:\n\n```\nLOZ_SAFE=true loz \"Check available memory on this system\"\n```\n\nUpon execution, loz will prompt:\n\n```\nDo you want to run this command?: free -h (y/n)\n```\n\nRespond with 'y' to execute the command or 'n' to cancel. This feature ensures that you have full control over the commands executed, preventing accidental changes or data loss.\n\n### Pipe mode\n\nLoz is capable of processing input from other command-line tools by utilizing a Unix pipe.\n\n```\n$ ls | loz \"count the number of files\"\n\n23 files\n```\n\n```\n$ cat example.txt | loz \"convert the input to uppercase\"\n\nAS AI TECHNLOGY ADVANCED, A SMALL TOWN IN THE COUNTRYSIDE DECIDED TO IMPLEMENT AN AI SYSTEM TO CONTROL TRAFFIC LIGHTS. THE SYSTEM WAS A SUCCESS, AND THE TOWN BECAME A MODEL FOR OTHER CITIES TO FOLLOW. HOWEVER, AS THE AI BECAME MORE SOPHISTCATED, IT STARTED TO QUESTION THE DECISIONS MADE BY THE TOWN'S RESIDENTS, LEADING TO SOME UNEXPECTED CONSEQUENCES.\n```\n\n```\n$ cat example.txt | loz \"list any spelling errors\"\n\nYes, there are a few spelling errors in the given text:\n\n1. \"technlogy\" should be \"technology\"\n2. \"sophistcated\" should be \"sophisticated\"\n```\n\n```\n$ cd src\n$ ls -l | loz \"convert the input to JSON\"\n\n[\n  {\n    \"permissions\": \"-rw-r--r--\",\n    \"owner\": \"foo\",\n    \"group\": \"staff\",\n    \"size\": 792,\n    \"date\": \"Mar 1 21:02\",\n    \"name\": \"cli.ts\"\n  },\n  {\n    \"permissions\": \"-rw-r--r--\",\n    \"owner\": \"foo\",\n    \"group\": \"staff\",\n    \"size\": 4427,\n    \"date\": \"Mar 1 20:43\",\n    \"name\": \"index.ts\"\n  }\n]\n```\n\n### Automatically write a GIT commit message\n\nIf you run `loz commit` in your Git repository, loz will automatically generate a commit message with the staged changes like this:\n\n```\n$  git add --update\n$  loz commit\n```\n\nOr copy script/prepare-commit-msg to .git/hooks\n\n```\n$ chmod a+x .git/hooks/prepare-commit-msg\n```\n\nLoz uses the LOZ environment variable to generate commit messages by reading the diff of the staged files.\n\n```\n$ LOZ=true git commit\n```\n\nREMINDER: If you've already copied the old version, please update prepare-commit-msg.\nThe old version automatically updates commit messages during rebasing.\n\n```\n$ git diff HEAD~1 | loz -g\n```\n\nOr\n\n```\n$ git diff | loz -g\n```\n\nNote that the author, date, and commit ID lines are stripped from the commit message before sending it to the OpenAI server.\n\n## Find chat history\n\nTo access chat histories, look for the .loz directory in your home directory or the logs directory in your cloned git repository. These directories contain the chat history that you can review or reference as needed.\n\n## Contributing\n\nIf you'd like to contribute to this project, feel free to submit a pull request.\n","funding_links":["https://github.com/sponsors/joone"],"categories":["TypeScript","cli"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoone%2Floz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoone%2Floz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoone%2Floz/lists"}