Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fund=false
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ Same experience. Different brain. Zero dependencies on the original tools.
npm install -g @abdoknbgit/tau
```

**Requirements:** Node.js >= 20.0.0, Git, Bash, `gh` for GitHub automation.
**Requirements:** Node.js >= 20.0.0, Git, Bash, `gh` for GitHub automation, and Go 1.25.8+ to build the optional native Tau helpers from source.

If Go is missing, Tau still installs and runs. The native Markdown/code rendering and native read-only helper tools are skipped until Go is available or a package ships the matching prebuilt helper.

---

Expand Down
12 changes: 12 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,15 @@ const nativeShellParserBuild = spawnSync(
if (nativeShellParserBuild.status !== 0) {
process.exit(nativeShellParserBuild.status ?? 1)
}

const nativeToolsBuild = spawnSync(
process.execPath,
['scripts/build-native-tools.mjs'],
{
stdio: 'inherit',
windowsHide: true,
},
)
if (nativeToolsBuild.status !== 0) {
process.exit(nativeToolsBuild.status ?? 1)
}
63 changes: 63 additions & 0 deletions docs/native-tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Optional Native Tau Helpers

Tau bundles `dist/native/tau-tools[.exe]` as optional helper plumbing. The
bundle is resolved relative to Tau's installed package, so it is portable across
machines and not hardcoded to one local path.

Generated Markdown, Markdown tables, and code blocks are UI rendering concerns,
not agent tools. Tau's normal Markdown and code-block renderers call the native
helper underneath when available:

- `render-markdown` uses Charm Glamour with Tau's compact style for Markdown
and table rendering.
- `highlight-code` uses Chroma for broad language syntax highlighting.

If the helper is unavailable, Tau falls back to the existing TypeScript renderer
instead of breaking the session.

The helper is built by `npm run build` and `npm run build:native-tools`.
During npm install, `postinstall` also tries to build it when Go is available.
Current helper dependencies require Go 1.25.8 or newer when building from
source.

Published packages include the prebuilt helper under `dist/native`. Source
installs can rebuild it with Go, or skip it without breaking Tau.

Bubble Tea `pick` remains manual because it is interactive, not a safe automatic
agent call.

## Commands

```bash
dist/native/tau-tools highlight-code --in src/main.tsx --lang tsx
dist/native/tau-tools git-summary --repo . --pretty
dist/native/tau-tools sysinfo --pretty
dist/native/tau-tools fuzzy-rank --query model --in models.txt
dist/native/tau-tools pick --title "Model" --in models.txt
dist/native/tau-tools render-markdown --in README.md --style tau-compact-dark
```

## Included

- Bubble Tea, Bubbles, Lip Gloss: standalone manual picker only.
- go-git: exposed as the read-only `NativeGitSummary` agent tool.
- gopsutil: exposed as the read-only `NativeSysInfo` agent tool.
- Fuzzy matching: helper command only.
- Chroma code highlighting and Charm Glamour Markdown rendering: helper
commands used implicitly by Tau rendering.

`NativeRenderMarkdown` and `NativeHighlightCode` are deliberately not exposed as
agent tools. Normal generated code and requests like "make a summary Markdown
table" stay as regular Tau UI-rendered answers.

## Deliberately Avoided

- Gum: useful for scripts, but not a Tau runtime dependency.
- fzf: useful when already installed, but not required by Tau.
- Cobra and Viper: useful for large Go CLIs, but unnecessary for this helper.

To make a missing Go toolchain fail CI instead of skipping the helper, set:

```bash
TAU_REQUIRE_NATIVE_TOOLS=1 npm run build:native-tools
```
68 changes: 68 additions & 0 deletions native/tau-tools/fuzzy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package main

import (
"errors"
"flag"
"fmt"
"os"

"github.com/sahilm/fuzzy"
)

func runFuzzyRank(args []string) error {
fs := newFlagSet("fuzzy-rank")
inputPath := fs.String("in", "", "Read newline-delimited items from this file instead of stdin")
query := fs.String("query", "", "Fuzzy query")
limit := fs.Int("limit", 20, "Maximum matches to print")
jsonOutput := fs.Bool("json", false, "Print matches as JSON")
pretty := fs.Bool("pretty", false, "Pretty-print JSON")

if err := parseFlags(fs, args); err != nil {
if errors.Is(err, flag.ErrHelp) {
return nil
}
return err
}
if err := requireNonEmpty(*query, "--query"); err != nil {
return err
}
if *limit < 0 {
*limit = 0
}

items, err := readLines(*inputPath)
if err != nil {
return err
}

matches := fuzzy.Find(*query, items)
if *limit > 0 && len(matches) > *limit {
matches = matches[:*limit]
}

if *jsonOutput {
type match struct {
Index int `json:"index"`
String string `json:"string"`
Score int `json:"score"`
MatchedIndexes []int `json:"matchedIndexes"`
}
out := make([]match, 0, len(matches))
for _, m := range matches {
out = append(out, match{
Index: m.Index,
String: m.Str,
Score: m.Score,
MatchedIndexes: m.MatchedIndexes,
})
}
return writeJSON(out, *pretty)
}

for _, m := range matches {
if _, err := fmt.Fprintln(os.Stdout, m.Str); err != nil {
return err
}
}
return nil
}
158 changes: 158 additions & 0 deletions native/tau-tools/git.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
package main

import (
"errors"
"flag"
"time"

git "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
)

type gitSummary struct {
Repository string `json:"repository"`
Head *gitHead `json:"head,omitempty"`
Branches []string `json:"branches"`
Recent []gitCommit `json:"recent"`
Status []gitFileState `json:"status,omitempty"`
}

type gitHead struct {
Branch string `json:"branch,omitempty"`
Hash string `json:"hash"`
Short string `json:"short"`
Message string `json:"message"`
Author string `json:"author"`
Date time.Time `json:"date"`
}

type gitCommit struct {
Hash string `json:"hash"`
Short string `json:"short"`
Message string `json:"message"`
Author string `json:"author"`
Date time.Time `json:"date"`
}

type gitFileState struct {
Path string `json:"path"`
Worktree string `json:"worktree"`
Staging string `json:"staging"`
ExtraPath string `json:"extraPath,omitempty"`
}

func runGitSummary(args []string) error {
fs := newFlagSet("git-summary")
repoPath := fs.String("repo", ".", "Repository path")
limit := fs.Int("commits", 8, "Maximum recent commits to include")
pretty := fs.Bool("pretty", false, "Pretty-print JSON")
includeStatus := fs.Bool("status", true, "Include worktree status")

if err := parseFlags(fs, args); err != nil {
if errors.Is(err, flag.ErrHelp) {
return nil
}
return err
}
if *limit < 0 {
*limit = 0
}

repo, err := git.PlainOpenWithOptions(*repoPath, &git.PlainOpenOptions{
DetectDotGit: true,
})
if err != nil {
return err
}

summary := gitSummary{
Repository: *repoPath,
Branches: []string{},
Recent: []gitCommit{},
}

headRef, err := repo.Head()
if err == nil {
commit, commitErr := repo.CommitObject(headRef.Hash())
if commitErr == nil {
summary.Head = commitToHead(headRef, commit)
}
}

branches, err := repo.Branches()
if err == nil {
err = branches.ForEach(func(ref *plumbing.Reference) error {
summary.Branches = append(summary.Branches, ref.Name().Short())
return nil
})
if err != nil {
return err
}
}

if headRef != nil && *limit > 0 {
iter, err := repo.Log(&git.LogOptions{From: headRef.Hash()})
if err == nil {
count := 0
err = iter.ForEach(func(commit *object.Commit) error {
if count >= *limit {
return stopeach{}
}
summary.Recent = append(summary.Recent, gitCommit{
Hash: commit.Hash.String(),
Short: commit.Hash.String()[:12],
Message: commit.Message,
Author: commit.Author.Name,
Date: commit.Author.When,
})
count++
return nil
})
var stop stopeach
if err != nil && !errors.As(err, &stop) {
return err
}
}
}

if *includeStatus {
worktree, err := repo.Worktree()
if err == nil {
status, err := worktree.Status()
if err != nil {
return err
}
for path, state := range status {
summary.Status = append(summary.Status, gitFileState{
Path: path,
Worktree: string(state.Worktree),
Staging: string(state.Staging),
ExtraPath: state.Extra,
})
}
}
}

return writeJSON(summary, *pretty)
}

type stopeach struct{}

func (stopeach) Error() string { return "stop iteration" }

func commitToHead(ref *plumbing.Reference, commit *object.Commit) *gitHead {
branch := ""
if ref.Name().IsBranch() {
branch = ref.Name().Short()
}
hash := commit.Hash.String()
return &gitHead{
Branch: branch,
Hash: hash,
Short: hash[:12],
Message: commit.Message,
Author: commit.Author.Name,
Date: commit.Author.When,
}
}
67 changes: 67 additions & 0 deletions native/tau-tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
module github.com/abdoknbgit/tau/native/tau-tools

go 1.25.8

require (
charm.land/bubbles/v2 v2.1.0
charm.land/bubbletea/v2 v2.0.7
charm.land/glamour/v2 v2.0.0
charm.land/lipgloss/v2 v2.0.3
github.com/alecthomas/chroma/v2 v2.26.1
github.com/go-git/go-git/v5 v5.19.1
github.com/sahilm/fuzzy v0.1.2
github.com/shirou/gopsutil/v4 v4.26.5
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/charmbracelet/colorprofile v0.4.3 // indirect
github.com/charmbracelet/ultraviolet v0.0.0-20260525132238-948f4557a654 // indirect
github.com/charmbracelet/x/ansi v0.11.7 // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/charmbracelet/x/termios v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.6.3 // indirect
github.com/cyphar/filepath-securejoin v0.6.1 // indirect
github.com/dlclark/regexp2/v2 v2.1.1 // indirect
github.com/ebitengine/purego v0.10.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.9.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/mattn/go-runewidth v0.0.23 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/pjbgf/sha1cd v0.6.0 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.3.1 // indirect
github.com/tklauser/go-sysconf v0.3.16 // indirect
github.com/tklauser/numcpus v0.11.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yuin/goldmark v1.7.8 // indirect
github.com/yuin/goldmark-emoji v1.0.5 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/crypto v0.50.0 // indirect
golang.org/x/net v0.53.0 // indirect
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
golang.org/x/text v0.36.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
)
Loading
Loading