{"id":30265032,"url":"https://github.com/placek/tertius-vim","last_synced_at":"2026-04-16T12:01:36.945Z","repository":{"id":309688728,"uuid":"1037183602","full_name":"placek/tertius-vim","owner":"placek","description":"AI assistant to git workflow in vim","archived":false,"fork":false,"pushed_at":"2025-09-02T09:28:02.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-02T11:25:49.825Z","etag":null,"topics":["git","llm","vim","workflow"],"latest_commit_sha":null,"homepage":"","language":"Vim Script","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/placek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2025-08-13T07:31:00.000Z","updated_at":"2025-09-02T09:28:05.000Z","dependencies_parsed_at":"2025-08-13T19:32:27.727Z","dependency_job_id":null,"html_url":"https://github.com/placek/tertius-vim","commit_stats":null,"previous_names":["placek/tertius-vim"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/placek/tertius-vim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Ftertius-vim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Ftertius-vim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Ftertius-vim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Ftertius-vim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/placek","download_url":"https://codeload.github.com/placek/tertius-vim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/placek%2Ftertius-vim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31884929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T11:36:10.202Z","status":"ssl_error","status_checked_at":"2026-04-16T11:36:09.652Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["git","llm","vim","workflow"],"created_at":"2025-08-15T22:26:20.879Z","updated_at":"2026-04-16T12:01:36.925Z","avatar_url":"https://github.com/placek.png","language":"Vim Script","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tertius.vim\n\nUtilities to streamline a **Git feature-branch workflow** with a little LLM help.\nTertius opens small, throwaway scratch buffers where you can draft a **user story**, **commit message**, **pull-request description**, **code review summary**, or a **todo list**, then calls your LLM to generate or refine the text based on real repository context (commits, diffs). It also includes a helper to **bootstrap a feature branch** from a drafted user story.\n\n\u003e Requires `git` and `curl`, plus an OpenAI-compatible API (key via `OPENAI_API_KEY`).\n\n---\n\n## Features\n\n* **LLM-assisted texts**:\n  * Commit message generator (analyzes branch commits \u0026 diff).\n  * User story composer.\n  * Pull-request description builder.\n  * Code-review outline on the feature branch.\n  * Developer todo list (xit format).\n\n* **Feature-branch bootstrapper**:\n  * From a drafted user story buffer, Tertius can:\n\n    * `git add .`\n    * `git stash`\n    * `git fetch --all`\n    * checkout default branch (configurable)\n    * create/switch to `-B \u003csanitized-branch-name\u003e`\n    * make an (allow-empty) initial commit from the buffer contents\n  * Branch name is derived from the **first line** of your user-story buffer, lowercased and slugified (`a–z, 0–9, -`).\n\n---\n\n## Installation\n\nUse any Vim plugin manager; the plugin is a single Vimscript file.\n\n### vim-plug\n\n```vim\ncall plug#begin('~/.vim/plugged')\nPlug 'placek/tertius-vim'\ncall plug#end()\n```\n\n### packer.nvim (Neovim, Lua)\n\n```lua\nuse { 'placek/tertius-vim' }\n```\n\n### lazy.nvim\n\n```lua\n{ 'placek/tertius-vim' }\n```\n\n### Pathogen\n\n```bash\ncd ~/.vim/bundle\ngit clone https://github.com/placek/tertius-vim.git\n```\n\n---\n\n## Configuration\n\nAll knobs live in `g:tertius_config` (defaults shown):\n\n```vim\nlet g:tertius_config = {\n\\ 'gitExec': 'git',\n\\ 'curlExec': 'curl',\n\\ 'defaultBranch': 'origin/master',\n\\ 'llmBaseUrl': 'https://api.openai.com/v1',\n\\ 'llmModel': 'gpt-4o',\n\\ 'userStoryIdPattern': '\\[\\([^\\]]\\+\\)\\]', \" capture [TICKET-123] etc.\n\\}\n```\n\nEnvironment variables:\n\n* `OPENAI_API_KEY` – **required**.\n* `OPENAI_BASE_URL` – optional override for `g:tertius_config.llmBaseUrl`.\n* `OPENAI_MODEL` – optional override for `g:tertius_config.llmModel`.\n\n\u003e If `git`/`curl` aren’t found, the plugin will echo an error.\n\nGit default branch is used when bootstrapping a feature branch from a user story. Such a branch can be configured with:\n\n```sh\ngit config --global core.default origin/main\n```\n\nIf this option is not set, Tertius defaults to `g:tertius_config.defaultBranch`.\n\n\nThe `userStoryIdPattern` is used to extract the user story ID from the first line of the user story buffer, e.g., `[PROJ-42]` or `[TICKET-123]`.\n\n---\n\n## Commands \u0026 Functions\n\nTertius exposes Vim **functions** (callable via `:call`) and ships minimal mappings/autocmds you can replace with your own. Functions read the **current buffer** as input (unless noted).\n\n### Core generator\n\n* `:call Tertius('commit_message', getline(1, '$'))`\n  Low-level entrypoint used by helpers below. Sends a system prompt (from config) and the provided content to the LLM, optionally invoking built-in “tools” to:\n\n  * list commits on the current branch since it diverged from the default branch\n  * fetch a specific commit’s message and diff\n\n### High-level helpers\n\n* `:call TertiusCommitMessage()`\n  Generate a **commit message** for the staged changes + optional text in your `gitcommit` buffer.\n\n* `:call TertiusOpenUserStoryWindow()`\n  Open a scratch buffer (`/tmp/tertius_user_story`) to draft a **user story**.\n\n* `:call TertiusUserStory()`\n  Ask the LLM to **compose/improve** the user story using your current buffer content.\n\n* `:call TertiusOpenPullRequestWindow()`\n  Open a scratch buffer for a **pull-request description**.\n\n* `:call TertiusPullRequest()`\n  Generate the **PR description** from recent commit messages/context.\n\n* `:call TertiusOpenCodeReviewWindow()`\n  Open a scratch buffer and immediately populate a **code-review** outline for the current feature branch.\n\n* `:call TertiusTodoList()`\n  Generate a developer **todo list** in xit format from the current buffer context.\n\n### Feature-branch bootstrap (auto)\n\nWhen you close (`BufUnload`) the **user story** buffer (`/tmp/tertius_user_story`), Tertius:\n\n1. Slugifies the first line into a branch name, e.g.\n   “Add OAuth login \\[PROJ-42]” → `add-oauth-login-proj-42`\n2. Runs: `git add .`, `git stash`, `git fetch --all`,\n   `git checkout \u003cdefaultBranch\u003e`, `git checkout -B \u003cbranch\u003e`,\n   and makes an **allow-empty** commit with the buffer text as the message.\n\nThis gives you a ready feature branch with initial context committed.\n\n---\n\n## Default filetype autocmds\n\nTertius defines a few buffer-local conveniences:\n\n* On `FileType gitcommit`: create a normal-mode mapping that calls `TertiusCommitMessage()`.\n* On `FileType tertius_user_story`: create a normal-mode mapping that calls `TertiusUserStory()`.\n* On `BufUnload /tmp/tertius_user_story`: run feature-branch bootstrap (above).\n\n\u003e **Note:** The stock mappings are intentionally minimal so you can bind your own keys. See below.\n\n---\n\n## Recommended key mappings\n\nThe plugin ships simple `nnoremap` lines; you can (and probably should) add your own in `vimrc/init.vim`. Examples:\n\n```vim\n\" User story flow\nnnoremap \u003cleader\u003eus :call TertiusOpenUserStoryWindow()\u003cCR\u003e\nnnoremap \u003cleader\u003euS :call TertiusUserStory()\u003cCR\u003e\n\n\" Pull request\nnnoremap \u003cleader\u003epr :call TertiusOpenPullRequestWindow()\u003cCR\u003e\nnnoremap \u003cleader\u003epR :call TertiusPullRequest()\u003cCR\u003e\n\n\" Code review\nnnoremap \u003cleader\u003ecr :call TertiusOpenCodeReviewWindow()\u003cCR\u003e\n\n\" Commit message (in a gitcommit buffer)\nautocmd FileType gitcommit nnoremap \u003cbuffer\u003e \u003cleader\u003ecm :call TertiusCommitMessage()\u003cCR\u003e\n\n\" Todo list\nnnoremap \u003cleader\u003etd :call TertiusTodoList()\u003cCR\u003e\n```\n\n---\n\n## How it talks to your LLM\n\nTertius performs one or more `/chat/completions` calls with:\n\n* the relevant **system prompt** (from `g:tertius_config.prompts.*`)\n* your buffer text as **user content**\n* optional **function/tool calls** so the model can:\n\n  * list commits on the current branch since its merge-base with the default branch\n  * fetch a specific commit’s message/diff\n\nResponses are written back into the current buffer.\n\n---\n\n## Tips \u0026 Caveats\n\n* Set `OPENAI_API_KEY` (and optionally `OPENAI_BASE_URL`/`OPENAI_MODEL`) in your shell before launching Vim/Neovim.\n* The **branch bootstrap** uses your user-story’s **first line** for the branch name. Keep it slug-friendly.\n* If you use a default branch other than `origin/master`, set:\n\n  ```vim\n  let g:tertius_config.defaultBranch = 'origin/main'\n  ```\n* The commit-message helper works best when you’ve staged changes and/or have a diff in the buffer (e.g. via a `gitcommit` buffer).\n\n---\n\n## License\n\nMIT\n\n---\n\n## Acknowledgements / Source\n\n* Implementation details and defaults come from the plugin source: `plugin/tertius.vim`. ([GitHub][1])\n\n---\n\n[1]: https://raw.githubusercontent.com/placek/tertius-vim/refs/heads/master/plugin/tertius.vim \"raw.githubusercontent.com\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplacek%2Ftertius-vim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplacek%2Ftertius-vim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplacek%2Ftertius-vim/lists"}