Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
94c2764
mycli: add notes, todo, and out subcommands to 'ud quick', mirroring …
Unique-Divine Oct 30, 2025
b62e5e8
algos: Use more concise heading prefix for problems so that the TOC w…
Unique-Divine Oct 30, 2025
b2e8a3b
algos: document a few fundamental patterns to go through
Unique-Divine Oct 30, 2025
c169722
dotfiles: document --help flags and commands across CLI
Unique-Divine Nov 5, 2025
af44c53
dotfiles(ud.sh): Write ud_test.sh -> ud_test.go for Go's test utilities
Unique-Divine Nov 9, 2025
c78f105
dotfiles(ud.sh): Add `ud nibi cfg` command and test target; clarify i…
Unique-Divine Nov 9, 2025
597da98
dotfiles: fix tests and complete migration from bash to Go
Unique-Divine Nov 9, 2025
8bfbe86
dotfiles: Add RPC vars and implement full network config handling in …
Unique-Divine Nov 9, 2025
c4c27ee
dotfiles: Remove "mycli" dir, as this tool is now part of the Unique-…
Unique-Divine Nov 10, 2025
b63fb18
algos: mine flood fill DFS problem for Anki
Unique-Divine Nov 11, 2025
b1153f1
algos: Record notes for new Anki cards; add content on Go slice imple…
Unique-Divine Nov 11, 2025
3424c08
algos: 001 - impl Go two sum solution
Unique-Divine Nov 12, 2025
7c7d2b4
ai-gym: init project with README
Unique-Divine Nov 12, 2025
18e0071
algos: work on DFS and stacks in Go
Unique-Divine Nov 12, 2025
477badd
algos(dfs): recursive and iterative solution to a problem in Go
Unique-Divine Nov 12, 2025
2aa9582
mycli: remove -cover flags from go test commands to speed them up
Unique-Divine Oct 30, 2025
12bf772
algos: 001 add two sum problem statement
Unique-Divine Nov 13, 2025
e0c53bc
algos: notes on a few array problems
Unique-Divine Nov 13, 2025
61cef4c
algos: impl 002 remove element solution
Unique-Divine Nov 14, 2025
6acf06c
algos: impl 003 - Move Zeros solution
Unique-Divine Nov 14, 2025
5156d4f
algos: add problem 4 description
Unique-Divine Nov 15, 2025
2fecb51
algos: Fix in tests for 000 to prevent reuse of tc.imgIn, which is
Unique-Divine Nov 15, 2025
565fbab
aictx: impl simple Unix-like CLI tool for building up context for LLMs
Unique-Divine Nov 15, 2025
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
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Unique-Divine/自由 (jiyuu)

CLI utilities monorepo solving concrete dev problems: Go coverage merging, Windows↔Linux encoding fixes, language-agnostic dev commands, Markdown TOC generation, and LLM context parsing. Built primarily in Go with TypeScript components.

## ⚡jiyuu

| Path | Description |
| ---- | ----------- |
| 📂 [gocovmerge](./gocovmerge/README.md) | Go coverage profile merger with modern CLI features |
| 📂 [markdown-toc](./markdown-toc/README.md) | Markdown table of contents (TOC) generator |
| 📂 [mycli](./mycli/README.md) | Language-agnostic “ud” CLI tool for personal use |
| 📂 [winfixtext](./winfixtext/README.md) | Text encoding fixer for Windows Unicode character issues |
| 📂 discord-nibiru | |
| 📂 [mdtoc](./mdtoc/README.md) | Markdown table of contents (TOC) generator |
| 📂 [mycli](./mycli/README.md) | Language-agnostic "ud" CLI tool for personal use |
| 📂 [winfixtext](./winfixtext/README.md) | Fixes Windows encoding issues and corrupted LLM text outputs |
| 📂 [aictx](./aictx/) | CLI tool for parsing files into LLM-compatible context |
| 📂 [bash-ts](./bash-ts/README.md) | Production TypeScript scripting library (bun install `@uniquedivine/bash`) for robust scripts with Bun runtime |
| 📂 [ud-jiyuu](./ud-jiyuu/README.md) | TypeScript package mimicking Rust/Go functionality |
| 📂 [discord-nibiru](./discord-nibiru/README.md) | Discord moderation bot for Nibiru community |
| 📦 scripts | Scripts crate in Rust |
| ├── justfile | Runs project-specific commands |
| └── README.md | |
Expand All @@ -24,3 +29,10 @@ cargo install just
You can view the list of available development commands with `just -ls`.

Ref: [github.com/casey/just](https://github.com/casey/just)

## Work In Progress

Some tools are experimental or under active development:

- **aictx**: Not yet implemented - planned CLI for LLM context file parsing
- **mdtoc**: Functional but still has open TODOs in sprint list
171 changes: 171 additions & 0 deletions aictx/aictx.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
package main

import (
"bytes"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"

cli "github.com/urfave/cli/v2"
)

func main() {
app := &cli.App{
Name: "aictx",
Usage: "Combine files into a single LLM-friendly output and copy it to the clipboard",
ArgsUsage: "<path> [path2 ...]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "write result to file in addition to copying it to the clipboard",
},
},
Action: runCat,
Commands: []*cli.Command{
{
Name: "cat",
Usage: "stitch one or more paths (files, directories, or globs)",
ArgsUsage: "<path> [path2 ...]",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "output",
Aliases: []string{"o"},
Usage: "write result to file in addition to copying it to the clipboard",
},
},
Action: runCat,
},
},
}

if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
}

func runCat(c *cli.Context) error {
outputPath := c.String("output")
rawArgs := c.Args().Slice()

if len(rawArgs) == 0 {
return cli.Exit("cat requires at least one path (file, directory, or glob)", 1)
}

paths, err := expandGlobs(rawArgs)
if err != nil {
return err
}
if len(paths) == 0 {
return cli.Exit("no paths matched", 1)
}

var buf bytes.Buffer
if err := stitchFiles(&buf, paths); err != nil {
return err
}
data := buf.Bytes()

if outputPath != "" {
if err := os.WriteFile(outputPath, data, 0o644); err != nil {
return err
}
}

if err := copyToClipboard(data); err != nil {
return err
}

// Optional: also print to stdout so you can see the stitched result in the terminal.
if _, err := os.Stdout.Write(data); err != nil {
return err
}

return nil
}

func expandGlobs(args []string) ([]string, error) {
var out []string
for _, a := range args {
matches, err := filepath.Glob(a)
if err != nil {
return nil, err
}
// If Glob finds matches, use them. Otherwise treat the arg as a literal path.
if len(matches) > 0 {
out = append(out, matches...)
} else {
out = append(out, a)
}
}
return out, nil
}

func copyToClipboard(data []byte) error {
cmd := exec.Command("pbcopy")
cmd.Stdin = bytes.NewReader(data)
return cmd.Run()
}

func stitchFiles(w io.Writer, paths []string) error {
for _, p := range paths {
if err := stitchPath(w, p); err != nil {
return err
}
}
return nil
}

func stitchPath(w io.Writer, path string) error {
info, err := os.Stat(path)
if err != nil {
return err
}

if info.IsDir() {
return stitchDir(w, path)
}
return stitchFile(w, path)
}

const fileSeparatorLines string = "========================================================"
const codeMarkerDepth4 string = "````"

func stitchFile(w io.Writer, path string) error {
// Header format can be tuned for LLM prompts.
if _, err := fmt.Fprintf(
w,
"\n%v\nFILE: %s\n%v\n",
fileSeparatorLines,
path,
fileSeparatorLines,
); err != nil {
return err
}

f, err := os.Open(path)
if err != nil {
return err
}
defer f.Close()

_, _ = fmt.Fprintf(w, "\n%v%v\n", codeMarkerDepth4, LangForPath(f.Name()))
_, err = io.Copy(w, f)
_, _ = fmt.Fprintf(w, "%v\n", codeMarkerDepth4)
return err
}

func stitchDir(w io.Writer, root string) error {
return filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
return stitchFile(w, path)
})
}
1 change: 1 addition & 0 deletions aictx/aictx_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package main_test
11 changes: 11 additions & 0 deletions aictx/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/Unique-Divine/jiyuu/aictx

go 1.22.12

require github.com/urfave/cli/v2 v2.27.7

require (
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
)
8 changes: 8 additions & 0 deletions aictx/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
github.com/cpuguy83/go-md2man/v2 v2.0.7 h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
github.com/cpuguy83/go-md2man/v2 v2.0.7/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
125 changes: 125 additions & 0 deletions aictx/languages.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package main

import (
"path/filepath"
"strings"
)

// extToLang maps file extensions (without leading ".") to a Markdown
// code fence language identifier.
//
// The values should match what common highlighters (GitHub, VS Code, etc.)
// expect after the ``` marker.
var extToLang = map[string]string{
// Go
"go": "go",
"mod": "go", // go.mod
// You can leave go.sum as plain text or map to "go" too if you prefer.
"sum": "",

// JavaScript / TypeScript
"js": "javascript",
"mjs": "javascript",
"cjs": "javascript",
"jsx": "jsx",
"ts": "typescript",
"tsx": "tsx",

// Python / Ruby / PHP
"py": "python",
"rb": "ruby",
"php": "php",

// Rust / C / C++ / C#
"rs": "rust",
"c": "c",
"h": "c",
"cpp": "cpp",
"cc": "cpp",
"cxx": "cpp",
"hpp": "cpp",
"cs": "csharp",

// Java / Kotlin / Scala
"java": "java",
"kt": "kotlin",
"kts": "kotlin",
"scala": "scala",

// Shell / CLI
"sh": "bash",
"bash": "bash",
"zsh": "bash",
"fish": "fish",
"ps1": "powershell",

// Web
"html": "html",
"htm": "html",
"css": "css",
"vue": "vue",
"svelte": "svelte",

// Data / config
"json": "json",
"yml": "yaml",
"yaml": "yaml",
"toml": "toml",
"ini": "ini",
"env": "", // usually key=value env files; plain text is fine

// SQL
"sql": "sql",

// Markdown / text
"md": "markdown",
"markdown": "markdown",
"txt": "",

// Docker / containers
"dockerfile": "docker",
"containerfile": "docker",

// Make / build
"makefile": "make",

// Solidity / web3
"sol": "solidity",

// Proto / gRPC
"proto": "protobuf",

// Misc
"yaml.tmpl": "yaml",
}

// LangForPath returns a language identifier suitable for use in a Markdown
// code fence based on the file extension of path.
//
// Example:
//
// ```go
// lang := LangForPath("main.go") // "go"
// ```
//
// If no mapping is found, it returns the empty string, meaning you should
// emit an untagged code fence.
func LangForPath(path string) string {
path = strings.ToLower(path)
if lang, ok := extToLang[path]; ok {
return lang
}

// Behavior for `filepath.Ext`
// foo.go -> ".go"
// README -> ""
ext := filepath.Ext(path) // e.g. ".go"
if ext == "" {
return ""
}
ext = ext[1:] // "go"
if lang, ok := extToLang[ext]; ok {
return lang
}
return ""
}
Loading
Loading