├── .devcontainer ├── Dockerfile ├── devcontainer.json └── docker-compose.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── custom.md └── workflows │ └── build.yaml ├── .gitignore ├── CONTRIBUTORS ├── LICENSE ├── README.md ├── VERSION ├── assets ├── ask.gif ├── config.gif ├── explain.gif ├── suggest.gif └── tapes │ ├── ask.tape │ ├── config.tape │ ├── explain.tape │ └── suggest.tape ├── build.ps1 ├── build.sh ├── e2e ├── requirements.txt ├── tests │ ├── ask.robot │ ├── config.robot │ ├── explain.robot │ ├── help.robot │ ├── suggest.robot │ └── version.robot ├── tlm.resource └── tlm_lib.py ├── go.mod ├── go.sum ├── install.ps1 ├── install.sh ├── main.go └── pkg ├── app ├── app.go ├── app_test.go ├── hooks.go ├── release.go └── release_manager.go ├── ask ├── SYSTEM ├── api.go ├── ask.go └── cli.go ├── config ├── api.go ├── cli.go ├── config.go ├── config_test.go ├── form.go └── style.go ├── explain ├── SYSTEM ├── api.go ├── cli.go ├── explain.go └── explain_test.go ├── packer ├── directory.go ├── internal │ ├── binary.go │ ├── exclude.go │ ├── file.go │ ├── include.go │ ├── render.go │ └── token.go ├── packer.go ├── result.go └── xml.tmpl ├── rag └── rag.go ├── shell ├── errors.go ├── shell.go ├── shell_darwin.go ├── shell_linux.go ├── shell_test.go └── shell_windows.go └── suggest ├── SYSTEM ├── api.go ├── api_test.go ├── cli.go ├── form.go ├── suggest.go └── suggest_test.go /.devcontainer/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mcr.microsoft.com/devcontainers/go:1.20 2 | 3 | WORKDIR /workspace 4 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tlama", 3 | "dockerComposeFile": "docker-compose.yaml", 4 | "workspaceFolder": "/workspace", 5 | "service": "app", 6 | "customizations": { 7 | "vscode": { 8 | "settings": { 9 | "explorer.autoReveal": false, 10 | "launch": { 11 | "version": "0.2.0", 12 | "configurations": [ 13 | { 14 | "name": "ttlama", 15 | "type": "go", 16 | "request": "launch", 17 | "mode": "auto", 18 | "program": "cmd/cli.go", 19 | "args": [ 20 | "-p", 21 | "list all directories" 22 | ], 23 | "console": "internalConsole", 24 | "internalConsoleOptions": "openOnSessionStart" 25 | } 26 | ], 27 | "compounds": [] 28 | } 29 | }, 30 | "extensions": [ 31 | "GitHub.copilot", 32 | "golang.Go", 33 | "ms-azuretools.vscode-docker" 34 | ] 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /.devcontainer/docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | 3 | services: 4 | app: 5 | build: 6 | context: . 7 | dockerfile: Dockerfile 8 | command: tail -f /dev/null 9 | volumes: 10 | - ../:/workspace:cached 11 | - ${HOME}/.ssh:/root/.ssh 12 | ollama: 13 | volumes: 14 | - ollama:/root/.ollama 15 | container_name: ollama 16 | pull_policy: always 17 | tty: true 18 | restart: unless-stopped 19 | image: ollama/ollama:latest 20 | ports: 21 | - 11434:11434 22 | deploy: 23 | resources: 24 | reservations: 25 | devices: 26 | - driver: ${OLLAMA_GPU_DRIVER-nvidia} 27 | count: ${OLLAMA_GPU_COUNT-1} 28 | capabilities: 29 | - gpu 30 | 31 | volumes: 32 | ollama: {} 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help me improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | *A clear and concise description of what the bug is.* 12 | 13 | **Console Output** 14 | *If applicable, add console output.* 15 | 16 | **tlm Version** 17 | *Which tlm version are you running? Type `tlm version` to get the version* 18 | 19 | e.g. `tlm 1.0 (windows/amd64)` 20 | 21 | 22 | **Platform Information (please complete the following information):** 23 | *Which operating system are you running on?*- 24 | 25 | 26 | **Additional context** 27 | *Add any other context about the problem here.* 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/custom.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Custom issue template 3 | about: Describe this issue template's purpose here. 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | -------------------------------------------------------------------------------- /.github/workflows/build.yaml: -------------------------------------------------------------------------------- 1 | name: ci 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v4 10 | 11 | - name: Setup Go 1.21 12 | uses: actions/setup-go@v4 13 | with: 14 | go-version: 1.21 15 | 16 | - name: Cache Go modules 17 | uses: actions/cache@v3 18 | with: 19 | path: | 20 | ~/.cache/go-build 21 | ~/go/pkg/mod 22 | key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 23 | 24 | - name: Display Go version 25 | run: go version 26 | 27 | - name: Install dependencies 28 | run: go install github.com/yusufcanb/tlm 29 | 30 | - name: Build 31 | run: bash build.sh $(cat VERSION) 32 | 33 | - name: Archive artifacts 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: dist 37 | path: dist/ 38 | retention-days: 1 39 | e2e: 40 | runs-on: ubuntu-latest 41 | steps: 42 | - uses: actions/checkout@v4 43 | 44 | - name: Download artifacts 45 | uses: actions/download-artifact@v4 46 | with: 47 | name: dist 48 | 49 | - name: Cache pip dependencies 50 | uses: actions/cache@v3 51 | with: 52 | path: ~/.cache/pip 53 | key: ${{ runner.os }}-pip-${{ hashFiles('e2e/requirements.txt') }} 54 | 55 | - name: Install tlm 56 | run: | 57 | mv $(cat VERSION)/tlm_$(cat VERSION)_linux_amd64 /usr/local/bin/tlm 58 | chmod +x /usr/local/bin/tlm 59 | tlm help 60 | 61 | - name: Set up Python 3.11 62 | uses: actions/setup-python@v3 63 | with: 64 | python-version: 3.11 65 | 66 | - name: Install dependencies 67 | run: pip install -r e2e/requirements.txt 68 | 69 | - name: Run Tests wo/ Ollama 70 | run: robot --outputdir dist --name tlm --include no-ollama tests/ 71 | working-directory: e2e/ 72 | 73 | - name: Archive e2e artifacts 74 | uses: actions/upload-artifact@v4 75 | if: always() 76 | with: 77 | name: e2e-report 78 | path: e2e/dist/ 79 | 80 | needs: 81 | - build 82 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # If you prefer the allow list template instead of the deny list, see community template: 2 | # https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore 3 | # 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, built with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | # Dependency directories (remove the comment below to include it) 18 | # vendor/ 19 | 20 | # Go workspace file 21 | go.work 22 | .idea 23 | .repomix/ 24 | dist/ 25 | .venv/ 26 | .vscode/ 27 | __pycache__/ -------------------------------------------------------------------------------- /CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | Yusuf Can Bayrak 2 | Slim Abid 3 | Ermin Omeragic 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 Yusuf Can Bayrak 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # tlm - Local CLI Copilot, powered by Ollama. 💻🦙 2 | 3 | ![Latest Build](https://img.shields.io/github/actions/workflow/status/yusufcanb/tlm/build.yaml?style=for-the-badge&logo=github) 4 | [![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/yusufcanb_tlm?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge&logo=sonar)](https://sonarcloud.io/project/overview?id=yusufcanb_tlm) 5 | [![Latest Release](https://img.shields.io/github/v/release/yusufcanb/tlm?display_name=release&style=for-the-badge&logo=github&link=https%3A%2F%2Fgithub.com%2Fyusufcanb%2Ftlm%2Freleases)](https://github.com/yusufcanb/tlm/releases) 6 | 7 | tlm is your CLI companion which requires nothing except your workstation. It uses most efficient and powerful open-source models like [Llama 3.3](https://ollama.com/library/llama3.3), [Phi4](https://ollama.com/library/phi4), [DeepSeek-R1](https://ollama.com/library/deepseek-r1), [Qwen](https://ollama.com/library/qwen2.5-coder) of your choice in your local environment to provide you the best possible command line assistance. 8 | 9 | | Get a suggestion | Explain a command | 10 | | -------------------------------- | -------------------------------- | 11 | | ![Suggest](./assets/suggest.gif) | ![Explain](./assets/explain.gif) | 12 | 13 | | Ask with context (One-liner RAG) | Configure your favorite model | 14 | | -------------------------------- | ------------------------------ | 15 | | ![Ask](./assets/ask.gif) | ![Config](./assets/config.gif) | 16 | 17 | ## Features 18 | 19 | - 💸 No API Key (Subscription) is required. (ChatGPT, Claude, Github Copilot, Azure OpenAI, etc.) 20 | 21 | - 📡 No internet connection is required. 22 | 23 | - 💻 Works on macOS, Linux and Windows. 24 | 25 | - 👩🏻‍💻 Automatic shell detection. (Powershell, Bash, Zsh) 26 | 27 | - 🚀 One liner generation and command explanation. 28 | 29 | - 🖺 No-brainer RAG (Retrieval Augmented Generation) 30 | 31 | - 🧠 Experiment any model. ([Llama3](https://ollama.com/library/llama3.3), [Phi4](https://ollama.com/library/phi4), [DeepSeek-R1](https://ollama.com/library/deepseek-r1), [Qwen](https://ollama.com/library/qwen2.5-coder)) with parameters of your choice. 32 | 33 | ## Installation 34 | 35 | Installation can be done in two ways; 36 | 37 | - [Installation script](#installation-script) (recommended) 38 | - [Go Install](#go-install) 39 | 40 | ### Installation Script 41 | 42 | Installation script is the recommended way to install tlm. 43 | It will recognize the which platform and architecture to download and will execute install command for you. 44 | 45 | #### Linux and macOS; 46 | 47 | Download and execute the installation script by using the following command; 48 | 49 | ```bash 50 | curl -fsSL https://raw.githubusercontent.com/yusufcanb/tlm/1.2/install.sh | sudo -E bash 51 | ``` 52 | 53 | #### Windows (Powershell 5.5 or higher) 54 | 55 | Download and execute the installation script by using the following command; 56 | 57 | ```powershell 58 | Invoke-RestMethod -Uri https://raw.githubusercontent.com/yusufcanb/tlm/1.2/install.ps1 | Invoke-Expression 59 | ``` 60 | 61 | ### Go Install 62 | 63 | If you have Go 1.22 or higher installed on your system, you can easily use the following command to install tlm; 64 | 65 | ```bash 66 | go install github.com/yusufcanb/tlm@1.2 67 | ``` 68 | 69 | You're ready! Check installation by using the following command; 70 | 71 | ```bash 72 | tlm 73 | ``` 74 | 75 | ## Usage 76 | 77 | ``` 78 | $ tlm 79 | NAME: 80 | tlm - terminal copilot, powered by open-source models. 81 | 82 | USAGE: 83 | tlm suggest "" 84 | tlm s --model=qwen2.5-coder:1.5b --style=stable "" 85 | 86 | tlm explain "" # explain a command 87 | tlm e --model=llama3.2:1b --style=balanced "" # explain a command with a overrided model 88 | 89 | tlm ask "" # ask a question 90 | tlm ask --context . --include *.md "" # ask a question with a context 91 | 92 | VERSION: 93 | 1.2 94 | 95 | COMMANDS: 96 | ask, a Asks a question (beta) 97 | suggest, s Suggests a command. 98 | explain, e Explains a command. 99 | config, c Configures language model, style and shell 100 | version, v Prints tlm version. 101 | help, h Shows a list of commands or help for one command 102 | 103 | GLOBAL OPTIONS: 104 | --help, -h show help 105 | --version, -v print the version 106 | ``` 107 | 108 | ### Ask - Ask something with or without context 109 | 110 | Ask a question with context. Here is an example question with a context of this repositories Go files under ask package. 111 | 112 | ``` 113 | $ tlm ask --help 114 | NAME: 115 | tlm ask - Asks a question (beta) 116 | 117 | USAGE: 118 | tlm ask "" # ask a question 119 | tlm ask --context . --include *.md "" # ask a question with a context 120 | 121 | OPTIONS: 122 | --context value, -c value context directory path 123 | --include value, -i value [ --include value, -i value ] include patterns. e.g. --include=*.txt or --include=*.txt,*.md 124 | --exclude value, -e value [ --exclude value, -e value ] exclude patterns. e.g. --exclude=**/*_test.go or --exclude=*.pyc,*.pyd 125 | --interactive, --it enable interactive chat mode (default: false) 126 | --model value, -m value override the model for command suggestion. (default: qwen2 5-coder:3b) 127 | --help, -h show help 128 | ``` 129 | 130 | ### Suggest - Get Command by Prompt 131 | 132 | ``` 133 | $ tlm suggest --help 134 | NAME: 135 | tlm suggest - Suggests a command. 136 | 137 | USAGE: 138 | tlm suggest 139 | tlm suggest --model=llama3.2:1b 140 | tlm suggest --model=llama3.2:1b --style= 141 | 142 | DESCRIPTION: 143 | suggests a command for given prompt. 144 | 145 | COMMANDS: 146 | help, h Shows a list of commands or help for one command 147 | 148 | OPTIONS: 149 | --model value, -m value override the model for command suggestion. (default: qwen2.5-coder:3b) 150 | --style value, -s value override the style for command suggestion. (default: balanced) 151 | --help, -h show help 152 | ``` 153 | 154 | ### Explain - Explain a Command 155 | 156 | ``` 157 | $ tlm explain --help 158 | NAME: 159 | tlm explain - Explains a command. 160 | 161 | USAGE: 162 | tlm explain 163 | tlm explain --model=llama3.2:1b 164 | tlm explain --model=llama3.2:1b --style= 165 | 166 | DESCRIPTION: 167 | explains given shell command. 168 | 169 | COMMANDS: 170 | help, h Shows a list of commands or help for one command 171 | 172 | OPTIONS: 173 | --model value, -m value override the model for command suggestion. (default: qwen2.5-coder:3b) 174 | --style value, -s value override the style for command suggestion. (default: balanced) 175 | --help, -h show help 176 | ``` 177 | 178 | ## Uninstall 179 | 180 | On Linux and macOS; 181 | 182 | ```bash 183 | rm /usr/local/bin/tlm 184 | rm ~/.tlm.yml 185 | ``` 186 | 187 | On Windows; 188 | 189 | ```powershell 190 | Remove-Item -Recurse -Force "C:\Users\$env:USERNAME\AppData\Local\Programs\tlm" 191 | Remove-Item -Force "$HOME\.tlm.yml" 192 | ``` 193 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.2 -------------------------------------------------------------------------------- /assets/ask.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufcanb/tlm/9cae6f5154b29db7319405dcc3cd15e58012d07f/assets/ask.gif -------------------------------------------------------------------------------- /assets/config.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufcanb/tlm/9cae6f5154b29db7319405dcc3cd15e58012d07f/assets/config.gif -------------------------------------------------------------------------------- /assets/explain.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufcanb/tlm/9cae6f5154b29db7319405dcc3cd15e58012d07f/assets/explain.gif -------------------------------------------------------------------------------- /assets/suggest.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufcanb/tlm/9cae6f5154b29db7319405dcc3cd15e58012d07f/assets/suggest.gif -------------------------------------------------------------------------------- /assets/tapes/ask.tape: -------------------------------------------------------------------------------- 1 | Output ask.gif 2 | 3 | Set Shell zsh 4 | Set Theme "Cyberdyne" 5 | 6 | Set Width 1200 7 | Set Height 600 8 | Set FontSize 22 9 | 10 | Hide 11 | Type "source ~/.zshrc && clear" 12 | Enter 13 | Hide 14 | 15 | Show 16 | Type "tlm ask --context . --include=pkg/ask/**/*.go 'briefly explain tlm ask command'" 17 | Sleep 500ms 18 | Enter 19 | Sleep 15s 20 | -------------------------------------------------------------------------------- /assets/tapes/config.tape: -------------------------------------------------------------------------------- 1 | Output config.gif 2 | 3 | Set Shell zsh 4 | Set Theme "Cyberdyne" 5 | 6 | Set Width 1200 7 | Set Height 600 8 | Set FontSize 22 9 | 10 | Hide 11 | Type "source ~/.zshrc && clear" 12 | Enter 13 | Hide 14 | 15 | Show 16 | Type "tlm config" 17 | Sleep 250ms 18 | Enter 19 | Sleep 2s 20 | 21 | Down 22 | Sleep 500ms 23 | 24 | Down 25 | Sleep 500ms 26 | 27 | Down 28 | Sleep 750ms 29 | 30 | Down 31 | Sleep 750ms 32 | 33 | Down 34 | Sleep 750ms 35 | 36 | Down 37 | Sleep 300ms 38 | 39 | Down 40 | Sleep 300ms 41 | 42 | Down 43 | Sleep 300ms 44 | 45 | Down 46 | Sleep 300ms 47 | 48 | 49 | Sleep 2s 50 | -------------------------------------------------------------------------------- /assets/tapes/explain.tape: -------------------------------------------------------------------------------- 1 | Output explain.gif 2 | 3 | Set Shell zsh 4 | Set Theme "Cyberdyne" 5 | 6 | Set Width 1200 7 | Set Height 650 8 | Set FontSize 22 9 | 10 | Hide 11 | Type "source ~/.zshrc && clear" 12 | Enter 13 | 14 | Show 15 | Type 'tlm explain "sed -r s/(foo)(bar)/\2\1/; s/\b([a-z]+)\b/\U\1/g; /baz/d\ in > out"' 16 | Sleep 500ms 17 | Enter 18 | Sleep 5s 19 | -------------------------------------------------------------------------------- /assets/tapes/suggest.tape: -------------------------------------------------------------------------------- 1 | Output suggest.gif 2 | 3 | Set Shell zsh 4 | Set Theme "Cyberdyne" 5 | 6 | Set Width 1200 7 | Set Height 650 8 | Set FontSize 22 9 | 10 | Hide 11 | Type "source ~/.zshrc && clear" 12 | Enter 13 | 14 | Show 15 | Type "tlm suggest 'list all network interfaces but only their ip addresses'" 16 | Sleep 250ms 17 | Enter 18 | Sleep 6s 19 | 20 | Enter 21 | Sleep 1s 22 | 23 | Up 24 | Sleep 500ms 25 | Up 26 | Sleep 500ms 27 | Enter 28 | 29 | Sleep 3s 30 | -------------------------------------------------------------------------------- /build.ps1: -------------------------------------------------------------------------------- 1 | # Parameters 2 | $targets = "darwin", "linux", "windows" 3 | $archs = "amd64", "arm64" 4 | $appName = "tlm" 5 | 6 | # Command-Line Version Argument 7 | $version = $args[0] 8 | if (-not $version) { 9 | Write-Output "Error: Please provide a version number as a command-line argument." 10 | exit 1 11 | } 12 | 13 | # Housekeeping 14 | Remove-Item -Recurse -Force "dist" -ErrorAction SilentlyContinue 15 | New-Item -ItemType Directory -Path "dist" 16 | 17 | # Build Function (Helper) 18 | Function Build-Target($os, $version, $arch) { 19 | $outputName = "${appName}_${version}_${os}_${arch}" 20 | $sha1 = (git rev-parse --short HEAD).Trim() 21 | if ($os -eq "windows") { 22 | $outputName += ".exe" 23 | } 24 | 25 | Write-Output "Building for $os/$arch (version: $version) -> $outputName" 26 | # Invokes the Go toolchain (assumes it's in the PATH) 27 | go build -o "dist/$version/$outputName" -ldflags "-X main.sha1ver=$sha1" "main.go" 28 | } 29 | 30 | # Build for each target OS 31 | foreach ($os in $targets) { 32 | 33 | foreach ($arch in $archs) { 34 | $env:GOOS = $os 35 | $env:GOARCH = $arch 36 | $env:CGO_ENABLED = 0 37 | Build-Target $os $version $arch 38 | } 39 | 40 | } 41 | 42 | Write-Output "Done!" -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Function to perform builds 4 | build() { 5 | os=$1 6 | app_name=$2 7 | version=$3 8 | arch=$4 9 | sha1=$(git rev-parse --short HEAD | tr -d '\n') 10 | 11 | # Determine output filename with optional .exe extension 12 | output_name="${app_name}_${version}_${os}_${arch}" 13 | if [[ "$os" == "windows" ]]; then 14 | output_name="${output_name}.exe" 15 | fi 16 | 17 | echo "Building for $os/$arch (version: $version) -> $output_name" 18 | CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -o "dist/${version}/${output_name}" -ldflags "-X main.sha1ver=$sha1" main.go 19 | } 20 | 21 | # Operating systems to target 22 | targets=("darwin" "linux" "windows") 23 | app_name="tlm" 24 | 25 | if [ $# -eq 0 ]; then 26 | echo "Error: Please provide a version number as a command-line argument." 27 | exit 1 28 | fi 29 | 30 | version=$1 31 | 32 | # Clear old build artifacts 33 | rm -rf dist 34 | 35 | # Create the output directory 36 | mkdir dist 37 | 38 | # Build for each OS 39 | for os in "${targets[@]}"; do 40 | build $os $app_name $version "arm64" 41 | build $os $app_name $version "amd64" 42 | done 43 | 44 | echo "Done!" -------------------------------------------------------------------------------- /e2e/requirements.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yusufcanb/tlm/9cae6f5154b29db7319405dcc3cd15e58012d07f/e2e/requirements.txt -------------------------------------------------------------------------------- /e2e/tests/ask.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library Collections 3 | Library OperatingSystem 4 | Resource ../tlm.resource 5 | 6 | Suite Setup Run Command tlm config set llm.model ${model} 7 | Suite Teardown Run Command tlm config set llm.model ${model} 8 | 9 | Test Tags command=ask 10 | 11 | Name tlm ask 12 | 13 | 14 | *** Variables *** 15 | ${model} qwen2.5-coder:3b 16 | 17 | 18 | *** Test Cases *** 19 | tlm ask 20 | ${rc} ${output}= Run Command tlm ask 21 | Verify Help Command Output ${rc} ${output} 22 | 23 | tlm ask 24 | ${rc} ${output}= Run Command tlm ask "Why the sky is blue? Name the concept." 25 | 26 | Should Be Equal As Integers ${rc} 0 27 | Should Contain ${output} Rayleigh scatte 28 | 29 | ${rc} ${output}= Run Command tlm a "Why the sky is blue? Name the concept." 30 | 31 | Should Be Equal As Integers ${rc} 0 32 | Should Contain ${output} Rayleigh scattering 33 | 34 | tlm ask --context= --include= 35 | ${rc} ${output}= Run Command tlm ask --context=. --include=**/*.robot "explain provided context" 36 | ${expected_file_list}= Create List tests/ask.robot tests/suggest.robot tests/help.robot 37 | 38 | Verify Ask Command Output With Context 39 | ... ${rc} 40 | ... ${output} 41 | ... ${expected_file_list} 42 | 43 | tlm ask --context= --exclude= 44 | ${rc} ${output}= Run Command tlm ask --context=. --exclude=**/*.robot "explain provided context" 45 | ${expected_file_list}= Create List tlm.resource tlm_lib.py requirements.txt 46 | Verify Ask Command Output With Context 47 | ... ${rc} 48 | ... ${output} 49 | ... ${expected_file_list} 50 | 51 | tlm ask (no ollama) 52 | [Tags] no-ollama 53 | 54 | # Test that the command fails when OLLAMA_HOST is not set 55 | Remove Environment Variable OLLAMA_HOST 56 | ${rc} ${output}= Run Command tlm ask "What is the meaning of life?" 57 | Should Not Be Equal As Integers ${rc} 0 58 | Should Contain ${output} (err) 59 | Should Contain 60 | ... ${output} 61 | ... OLLAMA_HOST environment variable is not set 62 | 63 | # Test the command fails when OLLAMA_HOST is set but not reachable 64 | Set Environment Variable OLLAMA_HOST http://localhost:11434 65 | ${rc} ${output}= Run Command tlm ask "What is the meaning of life?" 66 | 67 | Should Not Be Equal As Integers ${rc} 0 68 | Should Contain ${output} (err) 69 | Should Contain 70 | ... ${output} 71 | ... Ollama connection failed. Please check your Ollama if it's running or configured correctly. 72 | 73 | tlm ask (non-exist model) 74 | ${model}= Set Variable non-exist-model:1b 75 | Run Command tlm config set llm.model ${model} 76 | 77 | ${rc} ${output}= Run Command tlm ask 'What is the meaning of life?' 78 | Should Not Be Equal As Integers ${rc} 0 79 | Should Contain ${output} model "${model}" not found, try pulling it first 80 | 81 | 82 | *** Keywords *** 83 | Verify Ask Command Output With Context 84 | [Arguments] ${rc} ${output} ${expected_file_list} 85 | 86 | Should Be Equal As Numbers ${rc} 0 87 | 88 | FOR ${file} IN @{expected_file_list} 89 | Should Contain ${output} ${file} 90 | END 91 | 92 | Should Contain ${output} Context Summary: 93 | Should Contain ${output} Total Files: 94 | Should Contain ${output} Total Chars: 95 | Should Contain ${output} Total Tokens: 96 | 97 | Verify Help Command Output 98 | [Arguments] ${rc} ${output} 99 | 100 | Should Not Be Equal As Numbers ${rc} 0 101 | 102 | Should Contain ${output} NAME: 103 | Should Contain ${output} tlm ask - Asks a question 104 | 105 | Should Contain ${output} USAGE: 106 | Should Contain ${output} tlm ask "" 107 | Should Contain ${output} tlm ask --context . --include *.md "" 108 | -------------------------------------------------------------------------------- /e2e/tests/config.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library Collections 3 | Library OperatingSystem 4 | Resource ../tlm.resource 5 | 6 | Test Setup Remove Config File 7 | 8 | Test Tags command=explain 9 | 10 | Name tlm explain 11 | 12 | 13 | *** Variables *** 14 | ${model} qwen2.5-coder:1.5b 15 | ${style} balanced 16 | 17 | 18 | *** Test Cases *** 19 | tlm config 20 | ${rc} ${output}= Run Hanging Command And Verify Output tlm config "ls -all" 21 | Should Contain ${output} 22 | ... Sets a default model from the list of all available models. 23 | ... Use `ollama pull ` to download new models. 24 | 25 | Should Contain ${output} 26 | ... Sets a default model from the list of all available models. 27 | ... Use `ollama pull ` to download new models. 28 | 29 | tlm config ls 30 | ${rc} ${output}= Run Command tlm config ls 31 | 32 | tlm config set 33 | ${rc} ${output}= Run Command tlm config set llm.model ${model} 34 | 35 | tlm config get 36 | ${rc} ${output}= Run Command tlm config get llm.model 37 | 38 | 39 | *** Keywords *** 40 | Remove Config File 41 | ${HOME_DIR}= Get Environment Variable HOME 42 | Remove File path=${HOME_DIR}/.tlm.yml 43 | -------------------------------------------------------------------------------- /e2e/tests/explain.robot: -------------------------------------------------------------------------------- 1 | *** Settings *** 2 | Library Collections 3 | Library OperatingSystem 4 | Resource ../tlm.resource 5 | 6 | Suite Setup Run Command tlm config set llm.model ${model} 7 | Suite Teardown Run Command tlm config set llm.model ${model} 8 | 9 | Test Tags command=explain 10 | 11 | Name tlm explain 12 | 13 | 14 | *** Variables *** 15 | ${model} qwen2.5-coder:1.5b 16 | ${model2} llama3.2:1b 17 | ${style} balanced 18 | 19 | 20 | *** Test Cases *** 21 | tlm explain 22 | ${rc} ${output}= Run Command tlm explain "ls -all" 23 | Should Contain ${output} list ignore_case=True 24 | Should Contain ${output} file ignore_case=True 25 | 26 | tlm explain --model= --style=