├── LICENSE ├── .gitignore ├── main.go ├── go.mod ├── internal └── cralwer │ └── crawler.go ├── cmd ├── root.go └── scan.go ├── go.sum └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2025 NAME HERE 3 | */ 4 | package main 5 | 6 | import "github.com/phillip-england/xray/cmd" 7 | 8 | func main() { 9 | cmd.Execute() 10 | } 11 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/phillip-england/xray 2 | 3 | go 1.24.0 4 | 5 | require ( 6 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 7 | github.com/spf13/cobra v1.10.1 // indirect 8 | github.com/spf13/pflag v1.0.9 // indirect 9 | ) 10 | -------------------------------------------------------------------------------- /internal/cralwer/crawler.go: -------------------------------------------------------------------------------- 1 | package cralwer 2 | 3 | type Crawler struct { 4 | TargetDirPath string 5 | } 6 | 7 | func NewCrawler(targetDirPath string) (Crawler, error) { 8 | var c Crawler 9 | c.TargetDirPath = targetDirPath 10 | return c, nil 11 | } 12 | 13 | 14 | -------------------------------------------------------------------------------- /cmd/root.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "os" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | var rootCmd = &cobra.Command{ 10 | Use: "xray", 11 | Short: "Generate a full-text snapshot of your project for LLM analysis", 12 | Long: `xray is a simple CLI tool that crawls your project, collects all files 13 | (not excluded by .gitignore), and compiles them into a single text file. 14 | 15 | This file can then be given to an LLM to provide complete project context. 16 | Perfect for documentation generation, code reviews, or AI-driven analysis.`, 17 | // Run: func(cmd *cobra.Command, args []string) { 18 | // // Future: call the crawling + file aggregation logic 19 | // }, 20 | } 21 | 22 | func Execute() { 23 | err := rootCmd.Execute() 24 | if err != nil { 25 | os.Exit(1) 26 | } 27 | } 28 | 29 | func init() { 30 | rootCmd.Flags().BoolP("toggle", "t", false, "Example toggle flag for future features") 31 | } -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= 2 | github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= 3 | github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= 4 | github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= 5 | github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s= 6 | github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0= 7 | github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= 8 | github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 9 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 10 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 11 | -------------------------------------------------------------------------------- /cmd/scan.go: -------------------------------------------------------------------------------- 1 | package cmd 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/spf13/cobra" 7 | ) 8 | 9 | var ( 10 | outputFile string 11 | ) 12 | 13 | // scanCmd represents the command for scanning & compiling files 14 | var scanCmd = &cobra.Command{ 15 | Use: "scan", 16 | Short: "Scan the project and compile files into a single output", 17 | Long: `Scan the current project directory, respect .gitignore, 18 | and compile all included files into a single text file for LLM input. 19 | 20 | Example: 21 | xray scan --output project.txt 22 | `, 23 | RunE: func(cmd *cobra.Command, args []string) error { 24 | // --- Boilerplate only, no real logic yet --- 25 | fmt.Println("Scanning project...") 26 | fmt.Printf("Output will be written to: %s\n", outputFile) 27 | fmt.Println("TODO: Implement scan & compile logic here") 28 | return nil 29 | }, 30 | } 31 | 32 | func init() { 33 | rootCmd.AddCommand(scanCmd) 34 | 35 | // Flags 36 | scanCmd.Flags().StringVarP(&outputFile, "output", "o", "project.txt", "Path to output file") 37 | } 38 | 39 | 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xray 2 | 3 | `xray` is a lightweight CLI tool for generating a **complete textual snapshot of your codebase** for use with LLMs or other tools that need full project context. 4 | 5 | ## 📖 What It Does 6 | - **Crawls your project**: Recursively walks through all directories starting from the project root. 7 | - **Respects `.gitignore`**: Files and directories ignored by Git are skipped. 8 | - **Collects all files**: Reads the contents of each non-ignored file. 9 | - **Compiles into a single text file**: Produces one large text blob representing the entire project. 10 | 11 | ## 🏁 Motivation 12 | Large Language Models (LLMs) often need **complete context** to generate accurate insights, documentation, or code refactors. `xray` provides a **simple, universal way** to give LLMs the full picture of your project without manually copying files. 13 | 14 | ## 🗺️ Basic Flow 15 | 1. Run `xray` in the project root. 16 | 2. The tool reads the `.gitignore` to exclude unwanted files. 17 | 3. All included files are combined into one text output. 18 | 4. The final text file can be **fed into an LLM** for analysis. 19 | 20 | ## 📌 Roadmap 21 | - [ ] Basic file crawling and text compilation. 22 | - [ ] Optional output formatting (e.g., JSON, Markdown). 23 | - [ ] Incremental crawling (only changed files). 24 | - [ ] Integration with LLM APIs. 25 | 26 | --- 27 | 28 | ## ⚡ Quick Start 29 | ```bash 30 | # Install 31 | go install github.com/yourusername/xray@latest 32 | 33 | # Run in your project root 34 | xray scan --------------------------------------------------------------------------------