Skip to content

Commit f4593d7

Browse files
committed
Initial commit for first version.
0 parents  commit f4593d7

File tree

22 files changed

+1663
-0
lines changed

22 files changed

+1663
-0
lines changed

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v5
22+
with:
23+
go-version-file: go.mod
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v6
27+
with:
28+
distribution: goreleaser
29+
version: '~> v2'
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Binaries
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
tai
8+
9+
# Test binary, built with go test -c
10+
*.test
11+
12+
# Output of the go coverage tool
13+
*.out
14+
coverage.html
15+
16+
# Dependency directories
17+
vendor/
18+
19+
# Go workspace file
20+
go.work
21+
go.work.sum
22+
23+
# Environment files
24+
.env
25+
.env.*
26+
!.env.example
27+
28+
# IDE
29+
.idea/
30+
.vscode/
31+
*.swp
32+
*.swo
33+
34+
# OS
35+
.DS_Store
36+
Thumbs.db
37+
38+
# Build output
39+
dist/
40+
build/

.goreleaser.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
version: 2
2+
3+
project_name: tai
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
9+
builds:
10+
- id: tai
11+
main: ./cmd/tai/
12+
binary: tai
13+
goos:
14+
- linux
15+
- darwin
16+
goarch:
17+
- amd64
18+
- arm64
19+
ldflags:
20+
- -s -w -X github.com/NitorCreations/tai/internal/cli.Version={{.Version}}
21+
flags:
22+
- -trimpath
23+
24+
archives:
25+
- id: tai
26+
name_template: "tai_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
27+
formats:
28+
- tar.gz
29+
files:
30+
- none*
31+
32+
checksum:
33+
name_template: "tai_{{ .Version }}_checksums.txt"
34+
35+
release:
36+
github:
37+
owner: NitorCreations
38+
name: tai
39+
draft: false
40+
prerelease: auto
41+
42+
changelog:
43+
sort: asc
44+
filters:
45+
exclude:
46+
- "^docs:"
47+
- "^test:"
48+
- "^chore:"

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Nitor Creations
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
GO ?= go
2+
GOOS ?= $(shell $(GO) env GOOS)
3+
GIT_TAG := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
4+
5+
MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
6+
SOURCES := $(shell find . -name '*.go') $(MAKEFILE)
7+
8+
BUILD_FLAGS := -a -ldflags="-s -w -X github.com/NitorCreations/tai/internal/cli.Version=$(GIT_TAG)" -trimpath
9+
10+
BINARY64 := tai_$(GOOS)_amd64
11+
BINARYARM8 := tai_$(GOOS)_arm8
12+
13+
# https://en.wikipedia.org/wiki/Uname
14+
UNAME_M := $(shell uname -m)
15+
ifeq ($(UNAME_M),x86_64)
16+
BINARY := $(BINARY64)
17+
else ifeq ($(UNAME_M),amd64)
18+
BINARY := $(BINARY64)
19+
else ifeq ($(UNAME_M),arm64)
20+
BINARY := $(BINARYARM8)
21+
else ifeq ($(UNAME_M),aarch64)
22+
BINARY := $(BINARYARM8)
23+
else
24+
$(error Build on $(UNAME_M) is not supported, yet.)
25+
endif
26+
27+
all: dist/$(BINARY)
28+
29+
clean:
30+
$(RM) -r dist
31+
32+
dist/$(BINARY64): $(SOURCES)
33+
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@ ./cmd/tai/
34+
35+
dist/$(BINARYARM8): $(SOURCES)
36+
GOARCH=arm64 $(GO) build $(BUILD_FLAGS) -o $@ ./cmd/tai/
37+
38+
dist/tai: dist/$(BINARY) | dist
39+
rm -f dist/tai
40+
cp -f dist/$(BINARY) dist/tai
41+
42+
update:
43+
$(GO) get -u ./...
44+
$(GO) mod tidy
45+
46+
.PHONY: all update

README.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# tai — Terminal AI
2+
3+
Generate shell commands from natural language, right in your terminal.
4+
5+
tai uses your GitHub Copilot SDK to suggest commands. Select one, run it, or edit it before executing.
6+
7+
## Prerequisites
8+
9+
- [GitHub Copilot CLI](https://github.com/features/copilot/cli) — installed and logged in (subscription required)
10+
11+
## Installation
12+
13+
```sh
14+
curl -fsSL https://raw.githubusercontent.com/NitorCreations/tai/main/install.sh | sh
15+
```
16+
17+
The binary is placed at `~/.local/share/tai/tai`.
18+
19+
### Shell integration (recommended)
20+
21+
The shell integration shim lets tai place commands directly into your shell history and prompt line instead of executing them in a subshell:
22+
23+
```sh
24+
~/.local/share/tai/tai install # auto-detects bash or zsh
25+
~/.local/share/tai/tai install bash # explicit
26+
~/.local/share/tai/tai install zsh # explicit
27+
```
28+
29+
This writes a shim script to `~/.local/bin/tai`. Bind it to a key (e.g. `Alt+t`) for quick access from anywhere in the terminal.
30+
31+
### Alternative: add binary to PATH
32+
33+
If you prefer not to use the shell integration, add the install directory to your PATH instead:
34+
35+
```sh
36+
export PATH="$HOME/.local/share/tai:$PATH"
37+
```
38+
39+
Add this to `~/.bashrc` or `~/.zshrc` to make it permanent.
40+
41+
### Tab completions (optional)
42+
43+
```sh
44+
# bash
45+
~/.local/share/tai/tai completion bash >> ~/.bashrc
46+
47+
# zsh
48+
~/.local/share/tai/tai completion zsh >> ~/.zshrc
49+
```
50+
51+
## Usage
52+
53+
```sh
54+
tai ask # open interactive prompt
55+
tai ask "list open ports" # start with a query pre-filled
56+
```
57+
58+
### TUI key bindings
59+
60+
| State | Key | Action |
61+
|---|---|---|
62+
| Input | `Enter` | Submit query |
63+
| Results | `` / `` | Navigate suggestions |
64+
| Results | `Enter` | Accept and run command |
65+
| Results | `Tab` | Edit command before running |
66+
| Results | `/` | Follow-up query (refine results) |
67+
| Editing | `Enter` | Run edited command |
68+
| Editing | `Esc` | Cancel edit, back to results |
69+
| Follow-up | `Enter` | Submit follow-up |
70+
| Follow-up | `Esc` / `Ctrl+C` | Back to results |
71+
| Any | `Ctrl+C` | Quit |
72+
73+
Commands marked with `` are flagged as potentially destructive.
74+
75+
## Configuration
76+
77+
Config file: `~/.config/tai/config.json`
78+
79+
```sh
80+
tai config get model # print current model
81+
tai config set model gpt-4o # change model
82+
tai config edit # open in $EDITOR
83+
tai config reset # restore defaults
84+
```
85+
86+
Default model is `auto` (Copilot selects the model).
87+
88+
## Building from source
89+
90+
```sh
91+
git clone https://github.com/NitorCreations/tai.git
92+
cd tai
93+
make
94+
```
95+
96+
The binary is placed in `dist/`.
97+
98+
## License
99+
100+
MIT — see [LICENSE](LICENSE).

cmd/tai/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/NitorCreations/tai/internal/cli"
7+
)
8+
9+
func main() {
10+
os.Exit(cli.Execute())
11+
}

go.mod

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
module github.com/NitorCreations/tai
2+
3+
go 1.26
4+
5+
require (
6+
github.com/charmbracelet/bubbles v1.0.0
7+
github.com/charmbracelet/bubbletea v1.3.10
8+
github.com/charmbracelet/lipgloss v1.1.0
9+
github.com/github/copilot-sdk/go v0.1.32
10+
github.com/spf13/cobra v1.10.2
11+
golang.org/x/sys v0.42.0
12+
)
13+
14+
require (
15+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
16+
github.com/charmbracelet/colorprofile v0.4.3 // indirect
17+
github.com/charmbracelet/x/ansi v0.11.6 // indirect
18+
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
19+
github.com/charmbracelet/x/term v0.2.2 // indirect
20+
github.com/clipperhouse/displaywidth v0.11.0 // indirect
21+
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
22+
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
23+
github.com/google/jsonschema-go v0.4.2 // indirect
24+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
25+
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
26+
github.com/mattn/go-isatty v0.0.20 // indirect
27+
github.com/mattn/go-localereader v0.0.1 // indirect
28+
github.com/mattn/go-runewidth v0.0.21 // indirect
29+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
30+
github.com/muesli/cancelreader v0.2.2 // indirect
31+
github.com/muesli/termenv v0.16.0 // indirect
32+
github.com/rivo/uniseg v0.4.7 // indirect
33+
github.com/spf13/pflag v1.0.10 // indirect
34+
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
35+
golang.org/x/text v0.35.0 // indirect
36+
)

0 commit comments

Comments
 (0)